{"version":3,"file":"List.mjs","sources":["../../../src/components/List/List.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport React from 'react';\nimport { createContext, useContext } from 'react';\n\nimport { type Size } from '../../util/variant-types';\n\nimport styles from './List.module.css';\n\n// List component utilities\nexport type OrderedListProps = React.HTMLAttributes<HTMLOListElement> & {\n  // Design API\n  /**\n   * Size of the list and its item (controls spacing but requires proper usage of `Text`/`Heading` when composing)\n   */\n  size?: Extract<Size, 'xs' | 'sm' | 'md'>;\n  /**\n   * Marker to use with the given list type\n   * - for `OrderedList`, will use no marker or the `default` marker (e.g., \"1.\")\n   */\n  markerType?: 'none' | 'default';\n  // Component API\n};\n\nexport type UnorderedListProps = React.HTMLAttributes<HTMLUListElement> & {\n  // Design API\n  /**\n   * Size of the list and its item (controls spacing but requires proper usage of `Text`/`Heading` when composing)\n   */\n  size?: Extract<Size, 'xs' | 'sm' | 'md'>;\n  /**\n   * Marker to use with the given list type\n   * - for `UnorderedList`, will use no marker or the `default` marker (e.g., \"•\")\n   */\n  markerType?: 'none' | 'default';\n  // Component API\n};\n\n// List item component utilities\nexport type ListItemProps = React.HTMLAttributes<HTMLLIElement> & {\n  // Component API\n  size?: Extract<Size, 'xs' | 'sm' | 'md'>;\n};\n\nexport const ListContext = createContext<{\n  size: UnorderedListProps['size'] | OrderedListProps['size'];\n}>({ size: 'md' });\n\nexport function getListStyleProps(\n  props: OrderedListProps | UnorderedListProps,\n) {\n  const { className, size = 'md', markerType } = props;\n  return {\n    className: clsx(\n      styles['list'],\n      styles[`list--size-${size}`],\n      markerType && styles[`list--markerType-${markerType}`],\n      className,\n    ),\n  };\n}\n\nexport function getListItemStyleProps(props: ListItemProps) {\n  const { className, size = 'md' } = props;\n\n  return {\n    className: clsx(\n      styles['list-item'],\n      styles[`list-item--size-${size}`],\n      className,\n    ),\n  };\n}\n\nconst ListItem = (props: ListItemProps) => {\n  const { children, ...rest } = props;\n  const { size } = useContext(ListContext);\n\n  return <li {...getListItemStyleProps({ ...rest, size })}>{children}</li>;\n};\n\n/**\n * ## Usage\n *\n * * **Unordered**: Used for content where the order is not important.\n * * **Ordered**: Used for content where the order is important.\n * * EDS supports 1 level of nesting because our current products don't require deeper nesting.\n *\n * ### Unordered Lists\n *\n * | Type/Use | Description | Example |\n * |----------|-------------|---------|\n * |Data presentation|Presents grouped or related information in an organized manner.|A list of user names with their status or profile images.|\n * |Hierarchical Data|Displays nested items or subcategories.|A file tree or nested comments in a discussion thread.|\n *\n * ### Ordered Lists\n *\n * | Type/Use | Description | Example |\n * |----------|-------------|---------|\n * |Steps / Instructions|Lists steps in a specific order.|A step-by-step guide for setting up an account.|\n * |Nested steps|Breaks a long list of steps into groups of steps that accomplish a discrete action or piece of the overall task.|Long, complex procedures.|\n *\n * ### Best Practices\n *\n * * Include headings for lists that use custom characters instead of standard bullets or numbering.\n * * Don't rely on custom character bullets to convey meaning.\n * * Don't use multiple custom characters for one list item.\n *\n * ## Content & Accessibility\n *\n * ### Do's\n *\n * * Keep each list item short and to the point.\n * * Use parallel structure in list items to aid understanding.\n *\n * @param props options for the list to control size and marker type\n * @returns ReactNode\n */\nexport const UnorderedList = (props: UnorderedListProps) => {\n  const { children, size } = props;\n  return (\n    <ListContext.Provider value={{ size }}>\n      <ul {...getListStyleProps(props)}>{children}</ul>\n    </ListContext.Provider>\n  );\n};\n\n/**\n * Control a list of text items that are semantically ordered (ordinal sequence by number).\n *\n * @param props options for the list to control size and marker type\n * @returns ReactNode\n */\nexport const OrderedList = (props: OrderedListProps) => {\n  const { children, size } = props;\n  return (\n    <ListContext.Provider value={{ size }}>\n      <ol {...getListStyleProps(props)}>{children}</ol>\n    </ListContext.Provider>\n  );\n};\n\nUnorderedList.displayName = 'UnorderedList';\nOrderedList.displayName = 'OrderedList';\nListItem.displayName = 'ListItem';\n\nUnorderedList.ListItem = ListItem;\nOrderedList.ListItem = ListItem;\n"],"names":["React"],"mappings":";;;;AA2CO,MAAM,WAAW,GAAG,aAAa,CAErC,EAAE,IAAI,E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