{"version":3,"file":"Affix.cjs","sources":["../../../src/components/Affix/Affix.tsx"],"sourcesContent":["import {\n  Box,\n  BoxProps,\n  createVarsResolver,\n  ElementProps,\n  factory,\n  Factory,\n  getDefaultZIndex,\n  rem,\n  StylesApiProps,\n  useProps,\n  useStyles,\n} from '../../core';\nimport { OptionalPortal, PortalProps } from '../Portal';\nimport { AffixRootStyle } from './Affix.css';\n\nexport type AffixStylesNames = 'root';\nexport type AffixCssVariables = {\n  root: '--affix-z-index' | '--affix-top' | '--affix-left' | '--affix-bottom' | '--affix-right';\n};\n\nexport interface AffixBaseProps {\n  /** Root element `z-index` property, `200` by default */\n  zIndex?: string | number;\n\n  /** Determines whether component should be rendered within portal, `true` by default */\n  withinPortal?: boolean;\n\n  /** Props to pass down to the `Portal` component when `withinPortal` is set */\n  portalProps?: Omit<PortalProps, 'children'>;\n\n  /** Affix position on screen, defaults value is `{ bottom: 0, right: 0 }` */\n  position?: {\n    top?: string | number;\n    left?: string | number;\n    bottom?: string | number;\n    right?: string | number;\n  };\n}\n\nexport interface AffixProps\n  extends BoxProps,\n    AffixBaseProps,\n    StylesApiProps<AffixFactory>,\n    ElementProps<'div'> {}\n\nexport type AffixFactory = Factory<{\n  props: AffixProps;\n  ref: HTMLDivElement;\n  stylesNames: AffixStylesNames;\n  vars: AffixCssVariables;\n}>;\n\nconst defaultProps: Partial<AffixProps> = {\n  position: { bottom: 0, right: 0 },\n  zIndex: getDefaultZIndex('modal'),\n  withinPortal: true,\n};\n\nconst varsResolver = createVarsResolver<AffixFactory>((_, { zIndex, position }) => ({\n  root: {\n    '--affix-z-index': zIndex?.toString(),\n    '--affix-top': rem(position?.top),\n    '--affix-left': rem(position?.left),\n    '--affix-bottom': rem(position?.bottom),\n    '--affix-right': rem(position?.right),\n  },\n}));\n\nexport const Affix = factory<AffixFactory>((_props, ref) => {\n  const props = useProps('Affix', defaultProps, _props);\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    unstyled,\n    vars,\n    portalProps,\n    zIndex,\n    withinPortal,\n    position,\n    ...others\n  } = props;\n\n  const getStyles = useStyles<AffixFactory>({\n    name: 'Affix',\n    classes: {\n      root: AffixRootStyle,\n    },\n    props,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    vars,\n    varsResolver,\n  });\n\n  return (\n    <OptionalPortal {...portalProps} withinPortal={withinPortal}>\n      <Box ref={ref} {...getStyles('root')} {...others} />\n    </OptionalPortal>\n  );\n});\n\nAffix.displayName = '@raikou/core/Affix';\n"],"names":["getDefaultZIndex","createVarsResolver","rem","factory","useProps","useStyles","AffixRootStyle","jsx","OptionalPortal","Box"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,MAAM,YAAoC,GAAA;AAAA,EACxC,QAAU,EAAA,EAAE,MAAQ,EAAA,CAAA,EAAG,OAAO,CAAE,EAAA;AAAA,EAChC,MAAA,EAAQA,kCAAiB,OAAO,CAAA;AAAA,EAChC,YAAc,EAAA;AAChB,CAAA;AAEA,MAAM,eAAeC,qCAAiC,CAAA,CAAC,GAAG,EAAE,MAAA,EAAQ,UAAgB,MAAA;AAAA,EAClF,IAAM,EAAA;AAAA,IACJ,iBAAA,EAAmB,QAAQ,QAAS,EAAA;AAAA,IACpC,aAAA,EAAeC,OAAI,CAAA,QAAA,EAAU,GAAG,CAAA;AAAA,IAChC,cAAA,EAAgBA,OAAI,CAAA,QAAA,EAAU,IAAI,CAAA;AAAA,IAClC,gBAAA,EAAkBA,OAAI,CAAA,QAAA,EAAU,MAAM,CAAA;AAAA,IACtC,eAAA,EAAiBA,OAAI,CAAA,QAAA,EAAU,KAAK;AAAA;AAExC,CAAE,CAAA,CAAA;AAEK,MAAM,KAAQ,GAAAC,eAAA,CAAsB,CAAC,MAAA,EAAQ,GAAQ,KAAA;AAC1D,EAAA,MAAM,KAAQ,GAAAC,iBAAA,CAAS,OAAS,EAAA,YAAA,EAAc,MAAM,CAAA;AACpD,EAAM,MAAA;AAAA,IACJ,UAAA;AAAA,IACA,SAAA;AAAA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