{"version":3,"file":"VisualPageIndicator.mjs","sources":["../../../src/components/VisualPageIndicator/VisualPageIndicator.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React from 'react';\nimport { assertEdsUsage } from '../../util/logging';\n\nimport styles from './VisualPageIndicator.module.css';\n\nexport type VisualPageIndicatorProps = {\n  // Component API\n  /**\n   * CSS class names that can be appended to the component.\n   */\n  className?: string;\n  // Design API\n  /**\n   * Index of the active page in the indicator (0-based).\n   */\n  activePage: number;\n  /**\n   * Total number of pages available in this experience\n   */\n  totalPageCount: number;\n};\n\n/**\n * ## Usage\n *\n * Show to users which step they are on, in a given flow. Help to illustrate current position on\n * pagination experiences.\n *\n * ## Interaction\n *\n * Users can specify a number of dots, with each dot representing a discrete page of content in the\n * user interface. The active dot takes on a different color, to signal that it is the current\n * \"position\" within a set.\n *\n * The individual dots are not interactive; a user cannot move their position by clicking any\n * particular dot.\n *\n * `totalPageCount` sets how many dots render, and `activePage` marks which one is current. The\n * index is zero-based, so the last page is `totalPageCount - 1`. Fewer than two dots warns, and an\n * `activePage` outside the range logs an error.\n *\n * ## Content & Accessibility\n *\n * This is a visual cue only. The dots render as empty list items with no text, so assistive tech\n * gets no sense of which step is current. Always state the position in text nearby, for example a\n * \"Step 2 of 5\" label alongside the indicator.\n *\n * ### Do's\n *\n * * Use when there is a wizard-like experience, where there are a fixed number of steps, and you need to indicate which step the user is on, currently.\n * * For control, add adjacent buttons that let a user navigate to the next/previous step in the flow. This can be tied to logic to update the current dot in the set.\n * * For `Modal`, the next/previous buttons can be located together and right aligned. In such a layout, \"Next\" is treated as the primary button and is right most.\n *\n * ### Don'ts\n *\n * * Avoid using `VisualPageIndicator` without adjoined buttons for control.\n * * Avoid relying on, or building, any interaction with `VisualPageIndicator`, as the tap / click targets are very small and provide a poor UX.\n */\nexport const VisualPageIndicator = ({\n  className,\n  activePage,\n  totalPageCount,\n  ...other\n}: VisualPageIndicatorProps) => {\n  const componentClassName = clsx(styles['visual-page-indicator'], className);\n\n  assertEdsUsage(\n    [totalPageCount < 2],\n    'The minimum allowed count of indicators is 2',\n  );\n\n  assertEdsUsage(\n    [activePage < 0, activePage > totalPageCount - 1],\n    `The position in the indicator is out of range: [0, ${totalPageCount - 1}]`,\n    'error',\n  );\n\n  return (\n    <ul className={componentClassName} {...other}>\n      {Array(totalPageCount)\n        .fill(0)\n        .map((_, index) => {\n          return `Page ${index}`;\n        })\n        .map((name, index) => {\n          return (\n            <li\n              className={clsx(\n                styles['visual-page-indicator__item'],\n                index === activePage && styles['visual-page-indicator--active'],\n              )}\n              key={name}\n            ></li>\n          );\n        })}\n    </ul>\n  );\n};\n\nVisualPageIndicator.displayName = 'VisualPageIndicator';\n"],"names":["React"],"mappings":";;;;;AAuBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCG;AACI,MAAM,mBAAmB,GAAG,CAAC,EAClC,SAAS,EACT,UAAU,EACV,cAAc,EACd,GAAG,KAAK,EACiB,KAAI;IAC7B,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,SAAS,CAAC;IAE3E,cAAc,CACZ,CAAC,cAAc,GAAG,CAAC,CAAC,EACpB,8CAA8C,CAC/C;IAED,cAAc,CACZ,CAAC,UAAU,GAAG,CAAC,EAAE,UAAU,GAAG,cAAc,GAAG,CAAC,CAAC,EACjD,sDAAsD,cAAc,GAAG,CAAC,CAAA,CAAA,CAAG,EAC3E,OAAO,CACR;IAED,QACEA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAE,kBAAkB,EAAA,GAAM,KAAK,EAAA,EACzC,KAAK,CAAC,cAAc;SAClB,IAAI,CAAC,CAAC;AACN,SAAA,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAI;QAChB,OAAO,CAAA,KAAA,EAAQ,KAAK,CAAA,CAAE;AACxB,IAAA,CAAC;AACA,SAAA,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,KAAI;QACnB,QACEA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,6BAA6B,CAAC,EACrC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,+BAA+B,CAAC,CAChE,EACD,GAAG,EAAE,IAAI,EAAA,CACL;IAEV,CAAC,CAAC,CACD;AAET;AAEA,mBAAmB,CAAC,WAAW,GAAG,qBAAqB;;"}