{"version":3,"file":"PageNotification.mjs","sources":["../../../src/components/PageNotification/PageNotification.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React, { type ReactNode } from 'react';\n\nimport type { Status } from '../../util/variant-types';\n\nimport Button from '../Button';\nimport Heading from '../Heading';\nimport { hasSlotContent, IconSlot, useSemanticIcon } from '../Icon';\nimport Text from '../Text';\n\nimport styles from './PageNotification.module.css';\n\nexport type PageNotificationProps = Omit<\n  React.HTMLAttributes<HTMLElement>,\n  'style'\n> & {\n  // Component API\n  /**\n   * CSS class names that can be appended to the component.\n   */\n  className?: string;\n  /**\n   * Callback when notification is dismissed. When passed in, renders banner with a close icon in the top right.\n   */\n  onDismiss?: () => void;\n  /**\n   * CSS properties defined for the HTML element. Includes the component's CSS Custom Properties:\n   *\n   * - `--page-notification__bg`\n   * - `--page-notification__fg`\n   */\n  style?: PageNotificationCSSProperties;\n  // Design API\n  /**\n   * Whether the button layout for the call to action is vertical or horizontal.\n   */\n  buttonLayout?: 'vertical' | 'horizontal';\n  /**\n   * Slot for a button or other interactive element to direct a user to a follow-up action\n   */\n  callToAction?: ReactNode;\n  /**\n   * Keyword to characterize the state of the notification\n   *\n   * **Default is `\"informational\"`**.\n   */\n  status?: Status;\n  /**\n   * Secondary text used to describe the content in more detail\n   */\n  subTitle?: ReactNode;\n  /**\n   * The title/heading of the component\n   */\n  title?: string;\n};\n\nexport interface PageNotificationCSSProperties extends React.CSSProperties {\n  /**\n   * Custom property to customize the background color of this component (e.g., background color)\n   */\n  '--page-notification__bg'?: string;\n\n  /**\n   * Custom property to customize the foreground color of this component (e.g., text, icon, etc.)\n   */\n  '--page-notification__fg'?: string;\n}\n\n/**\n * ## Usage\n *\n * * Notifications related to a section of a page (like a card, popover, or modal) should use an Inline Notification.\n * * Page Notifications are intended to display short messages. Ideally, a max of 3 lines.\n *\n * ## Interaction\n *\n * Designers can specify whether the notification is dismissible or not. A dismissible notification renders with a close icon in the top right.\n *\n * ## Content & Accessibility\n *\n * ### Do's\n *\n * * Focus on a single message or piece of information.\n * * Ensure users can get the basic message and take action by scanning just the heading and CTA(s).\n * * Title: be short and descriptive, communicate the main message, and use sentence case.\n * * Body: keep to 1-2 sentences and use sentence case.\n *\n * ### Don'ts\n *\n * * Don't rely on color to convey meaning.\n * * Don't punctuate the end of the title.\n * * Don't repeat or paraphrase information from the heading in the body.\n * * Don't truncate content; if more information is needed, link to it or consider a different component.\n */\nexport const PageNotification = ({\n  buttonLayout = 'vertical',\n  callToAction,\n  className,\n  subTitle,\n  onDismiss,\n  status = 'informational',\n  title,\n  ...other\n}: PageNotificationProps) => {\n  const componentClassName = clsx(\n    // Base styles\n    styles['page-notification'],\n    status && styles[`page-notification--status-${status}`],\n    className,\n  );\n\n  // Both icons here are semantic: the status icon carries the notification's severity,\n  // and the dismiss button is the same close affordance used everywhere else. The app\n  // sets either one through `IconProvider`, not per notification.\n  const statusIcon = useSemanticIcon(status);\n  const closeIcon = useSemanticIcon('close');\n\n  return (\n    <aside className={componentClassName} {...other}>\n      {hasSlotContent(statusIcon) && (\n        <IconSlot\n          className={styles['page-notification__icon']}\n          content={statusIcon}\n          purpose=\"decorative\"\n          size=\"24px\"\n        />\n      )}\n\n      <div\n        className={clsx(\n          styles['page-notification__body'],\n          buttonLayout && styles[`page-notification--has-${buttonLayout}-cta`],\n        )}\n      >\n        <div\n          className={clsx(\n            styles['page-notification__text'],\n            subTitle && styles['page-notification--with-subTitle'],\n          )}\n        >\n          {title && (\n            <Heading as=\"h3\" preset=\"title-md\">\n              {title}\n            </Heading>\n          )}\n          {subTitle && (\n            <Text as=\"p\" preset=\"body-sm\">\n              {subTitle}\n            </Text>\n          )}\n        </div>\n        {callToAction && (\n          <div className={styles['page-notification__call-to-action']}>\n            {callToAction}\n          </div>\n        )}\n      </div>\n      {onDismiss && (\n        <Button\n          aria-label=\"Dismiss the notification\"\n          className={styles['page-notification__close-button']}\n          icon={closeIcon}\n          iconLayout=\"icon-only\"\n          onClick={onDismiss}\n          rank=\"tertiary\"\n          size=\"lg\"\n          variant=\"neutral\"\n        ></Button>\n      )}\n    </aside>\n  );\n};\n\nPageNotification.displayName = 'PageNotification';\n"],"names":["React"],"mappings":";;;;;;;;;;AAqEA;;;;;;;;;;;;;;;;;;;;;;;;;AAyBG;AACI,MAAM,gBAAgB,GAAG,CAAC,EAC/B,YAAY,GAAG,UAAU,EACzB,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,MAAM,GAAG,eAAe,EACxB,KAAK,EACL,GAAG,KAAK,EACc,KAAI;IAC1B,MAAM,kBAAkB,GAAG,IAAI;;AAE7B,IAAA,MAAM,CAAC,mBAAmB,CAAC,EAC3B,MAAM,IAAI,MAAM,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAA,CAAE,CAAC,EACvD,SAAS,CACV;;;;AAKD,IAAA,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;AAC1C,IAAA,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,CAAC;AAE1C,IAAA,QACEA,cAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAO,SAAS,EAAE,kBAAkB,KAAM,KAAK,EAAA;QAC5C,cAAc,CAAC,UAAU,CAAC,KACzBA,cAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,EACP,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,EAC5C,OAAO,EAAE,UAAU,EACnB,OAAO,EAAC,YAAY,EACpB,IAAI,EAAC,MAAM,EAAA,CACX,CACH;AAED,QAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,yBAAyB,CAAC,EACjC,YAAY,IAAI,MAAM,CAAC,0BAA0B,YAAY,CAAA,IAAA,CAAM,CAAC,CACrE,EAAA;AAED,YAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,yBAAyB,CAAC,EACjC,QAAQ,IAAI,MAAM,CAAC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