{"version":3,"file":"Notification.cjs","sources":["../../../src/components/Notification/Notification.tsx"],"sourcesContent":["import {\n  Box,\n  BoxProps,\n  createVarsResolver,\n  ElementProps,\n  factory,\n  Factory,\n  getRadius,\n  getThemeColor,\n  RaikouColor,\n  RaikouRadius,\n  StylesApiProps,\n  useProps,\n  useStyles,\n} from '../../core';\nimport { CloseButton } from '../CloseButton';\nimport { Loader } from '../Loader';\nimport {\n  NotificationBodyStyle,\n  NotificationCloseButtonStyle,\n  NotificationDescriptionStyle,\n  NotificationIconStyle,\n  NotificationLoaderStyle,\n  NotificationRootStyle,\n  NotificationTitleStyle,\n} from './Notification.css';\n\nexport type NotificationStylesNames =\n  | 'root'\n  | 'icon'\n  | 'loader'\n  | 'body'\n  | 'title'\n  | 'description'\n  | 'closeButton';\nexport type NotificationCssVariables = {\n  root: '--notification-radius' | '--notification-color';\n};\n\nexport interface NotificationProps\n  extends BoxProps,\n    StylesApiProps<NotificationFactory>,\n    ElementProps<'div', 'title'> {\n  variant?: string;\n\n  /** Called when close button is clicked */\n  onClose?: () => void;\n\n  /** Controls notification line or icon color, key of `theme.colors` or any valid CSS color, `theme.primaryColor` by default */\n  color?: RaikouColor;\n\n  /** Key of `theme.radius` or any valid CSS value to set `border-radius`, `theme.defaultRadius` by default */\n  radius?: RaikouRadius;\n\n  /** Notification icon, replaces color line */\n  icon?: React.ReactNode;\n\n  /** Notification title, displayed before body */\n  title?: React.ReactNode;\n\n  /** Notification body, place main text here */\n  children?: React.ReactNode;\n\n  /** Replaces colored line or icon with Loader component */\n  loading?: boolean;\n\n  /** Determines whether notification should have a border, `false` by default */\n  withBorder?: boolean;\n\n  /** Determines whether close button should be visible, `true` by default */\n  withCloseButton?: boolean;\n\n  /** Props passed down to the close button */\n  closeButtonProps?: Record<string, any>;\n}\n\nexport type NotificationFactory = Factory<{\n  props: NotificationProps;\n  ref: HTMLDivElement;\n  stylesNames: NotificationStylesNames;\n  vars: NotificationCssVariables;\n}>;\n\nconst defaultProps: Partial<NotificationProps> = {\n  withCloseButton: true,\n};\n\nconst varsResolver = createVarsResolver<NotificationFactory>((theme, { radius, color }) => ({\n  root: {\n    '--notification-radius': radius === undefined ? undefined : getRadius(radius),\n    '--notification-color': color ? getThemeColor(color, theme) : undefined,\n  },\n}));\n\nexport const Notification = factory<NotificationFactory>((_props, ref) => {\n  const props = useProps('Notification', defaultProps, _props);\n  const {\n    className,\n    color,\n    radius,\n    loading,\n    withCloseButton,\n    withBorder,\n    title,\n    icon,\n    children,\n    onClose,\n    closeButtonProps,\n    classNames,\n    style,\n    styles,\n    unstyled,\n    variant,\n    vars,\n    mod,\n    ...others\n  } = props;\n\n  const getStyles = useStyles<NotificationFactory>({\n    name: 'Notification',\n    classes: {\n      root: NotificationRootStyle,\n      icon: NotificationIconStyle,\n      loader: NotificationLoaderStyle,\n      body: NotificationBodyStyle,\n      title: NotificationTitleStyle,\n      description: NotificationDescriptionStyle,\n      closeButton: NotificationCloseButtonStyle,\n    },\n    props,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    vars,\n    varsResolver,\n  });\n\n  return (\n    <Box\n      {...getStyles('root')}\n      mod={[{ 'data-with-icon': !!icon || loading, 'data-with-border': withBorder }, mod]}\n      ref={ref}\n      variant={variant}\n      {...others}\n      role=\"alert\"\n    >\n      {icon && !loading && <div {...getStyles('icon')}>{icon}</div>}\n      {loading && <Loader size={28} color={color} {...getStyles('loader')} />}\n\n      <div {...getStyles('body')}>\n        {title && <div {...getStyles('title')}>{title}</div>}\n\n        <Box {...getStyles('description')} mod={{ 'data-with-title': !!title }}>\n          {children}\n        </Box>\n      </div>\n\n      {withCloseButton && (\n        <CloseButton\n          iconSize={16}\n          color=\"gray\"\n          {...closeButtonProps}\n          unstyled={unstyled}\n          onClick={onClose}\n          {...getStyles('closeButton')}\n        />\n      )}\n    </Box>\n  );\n});\n\nNotification.displayName = '@raikou/core/Notification';\n"],"names":["createVarsResolver","getRadius","getThemeColor","factory","useProps","useStyles","NotificationRootStyle","NotificationIconStyle","NotificationLoaderStyle","NotificationBodyStyle","NotificationTitleStyle","NotificationDescriptionStyle","NotificationCloseButtonStyle","jsxs","Box","jsx","Loader","CloseButton"],"mappings":";;;;;;;;;;;;;;;;;;;AAmFA,MAAM,YAA2C,GAAA;AAAA,EAC/C,eAAiB,EAAA;AACnB,CAAA;AAEA,MAAM,eAAeA,qCAAwC,CAAA,CAAC,OAAO,EAAE,MAAA,EAAQ,OAAa,MAAA;AAAA,EAC1F,IAAM,EAAA;AAAA,IACJ,uBAAyB,EAAA,MAAA,KAAW,KAAY,CAAA,GAAA,KAAA,CAAA,GAAYC,kBAAU,MAAM,CAAA;AAAA,IAC5E,sBAAwB,EAAA,KAAA,GAAQC,2BAAc,CAAA,KAAA,EAAO,KAAK,CAAI,GAAA,KAAA;AAAA;AAElE,CAAE,CAAA,CAAA;AAEK,MAAM,YAAe,GAAAC,eAAA,CAA6B,CAAC,MAAA,EAAQ,GAAQ,KAAA;AACxE,EAAA,MAAM,KAAQ,GAAAC,iBAAA,CAAS,cAAgB,EAAA,YAAA,EAAc,MAAM,CAAA;AAC3D,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,OAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,GAAA;AAAA,IACA,GAAG;AAAA,GACD,GAAA,KAAA;AAEJ,EAAA,MAAM,YAAYC,mBAA+B,CAAA;AAAA,IAC/C,IAAM,EAAA,cAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,IAAM,EAAAC,sCAAA;AAAA,MACN,IAAM,EAAAC,sCAAA;AAAA,MACN,MAAQ,EAAAC,wCAAA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