@mortenbrudvik/waveui 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +357 -72
  2. package/dist/components/button/Toolbar.cjs +1 -1
  3. package/dist/components/button/Toolbar.cjs.map +1 -1
  4. package/dist/components/button/Toolbar.mjs +25 -30
  5. package/dist/components/button/Toolbar.mjs.map +1 -1
  6. package/dist/components/button/Toolbar.navigation.cjs +2 -0
  7. package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
  8. package/dist/components/button/Toolbar.navigation.mjs +17 -0
  9. package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
  10. package/dist/components/data-display/Avatar.cjs +1 -1
  11. package/dist/components/data-display/Avatar.cjs.map +1 -1
  12. package/dist/components/data-display/Avatar.context.cjs +2 -0
  13. package/dist/components/data-display/Avatar.context.cjs.map +1 -0
  14. package/dist/components/data-display/Avatar.context.mjs +9 -0
  15. package/dist/components/data-display/Avatar.context.mjs.map +1 -0
  16. package/dist/components/data-display/Avatar.mjs +66 -61
  17. package/dist/components/data-display/Avatar.mjs.map +1 -1
  18. package/dist/components/data-display/InteractionTag.cjs +2 -0
  19. package/dist/components/data-display/InteractionTag.cjs.map +1 -0
  20. package/dist/components/data-display/InteractionTag.mjs +234 -0
  21. package/dist/components/data-display/InteractionTag.mjs.map +1 -0
  22. package/dist/components/data-display/Tag.cjs +1 -1
  23. package/dist/components/data-display/Tag.cjs.map +1 -1
  24. package/dist/components/data-display/Tag.mjs +222 -90
  25. package/dist/components/data-display/Tag.mjs.map +1 -1
  26. package/dist/components/data-display/TagGroup.cjs +2 -0
  27. package/dist/components/data-display/TagGroup.cjs.map +1 -0
  28. package/dist/components/data-display/TagGroup.context.cjs +2 -0
  29. package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
  30. package/dist/components/data-display/TagGroup.context.mjs +113 -0
  31. package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
  32. package/dist/components/data-display/TagGroup.mjs +149 -0
  33. package/dist/components/data-display/TagGroup.mjs.map +1 -0
  34. package/dist/components/data-display/tagStyles.cjs +2 -0
  35. package/dist/components/data-display/tagStyles.cjs.map +1 -0
  36. package/dist/components/data-display/tagStyles.mjs +108 -0
  37. package/dist/components/data-display/tagStyles.mjs.map +1 -0
  38. package/dist/components/feedback/Toaster.cjs +1 -1
  39. package/dist/components/feedback/Toaster.cjs.map +1 -1
  40. package/dist/components/feedback/Toaster.mjs +213 -181
  41. package/dist/components/feedback/Toaster.mjs.map +1 -1
  42. package/dist/components/input/Combobox.expand.cjs +1 -1
  43. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  44. package/dist/components/input/Combobox.expand.mjs +7 -7
  45. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  46. package/dist/components/input/Option.cjs +1 -1
  47. package/dist/components/input/Option.cjs.map +1 -1
  48. package/dist/components/input/Option.mjs +16 -11
  49. package/dist/components/input/Option.mjs.map +1 -1
  50. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  51. package/dist/components/input/SwatchPicker.context.cjs.map +1 -1
  52. package/dist/components/input/SwatchPicker.context.mjs.map +1 -1
  53. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  54. package/dist/components/input/TagPicker.cjs +1 -1
  55. package/dist/components/input/TagPicker.cjs.map +1 -1
  56. package/dist/components/input/TagPicker.context.cjs +2 -0
  57. package/dist/components/input/TagPicker.context.cjs.map +1 -0
  58. package/dist/components/input/TagPicker.context.mjs +20 -0
  59. package/dist/components/input/TagPicker.context.mjs.map +1 -0
  60. package/dist/components/input/TagPicker.create.cjs +2 -0
  61. package/dist/components/input/TagPicker.create.cjs.map +1 -0
  62. package/dist/components/input/TagPicker.create.mjs +24 -0
  63. package/dist/components/input/TagPicker.create.mjs.map +1 -0
  64. package/dist/components/input/TagPicker.mjs +13 -279
  65. package/dist/components/input/TagPicker.mjs.map +1 -1
  66. package/dist/components/input/TagPicker.option.cjs +2 -0
  67. package/dist/components/input/TagPicker.option.cjs.map +1 -0
  68. package/dist/components/input/TagPicker.option.mjs +45 -0
  69. package/dist/components/input/TagPicker.option.mjs.map +1 -0
  70. package/dist/components/input/TagPicker.overflow.cjs +2 -0
  71. package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
  72. package/dist/components/input/TagPicker.overflow.mjs +153 -0
  73. package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
  74. package/dist/components/input/TagPicker.parts.cjs +2 -0
  75. package/dist/components/input/TagPicker.parts.cjs.map +1 -0
  76. package/dist/components/input/TagPicker.parts.mjs +425 -0
  77. package/dist/components/input/TagPicker.parts.mjs.map +1 -0
  78. package/dist/components/input/TagPicker.root.cjs +2 -0
  79. package/dist/components/input/TagPicker.root.cjs.map +1 -0
  80. package/dist/components/input/TagPicker.root.mjs +416 -0
  81. package/dist/components/input/TagPicker.root.mjs.map +1 -0
  82. package/dist/components/layout/Accordion.cjs.map +1 -1
  83. package/dist/components/layout/Accordion.mjs.map +1 -1
  84. package/dist/components/navigation/Hamburger.cjs +2 -0
  85. package/dist/components/navigation/Hamburger.cjs.map +1 -0
  86. package/dist/components/navigation/Hamburger.mjs +54 -0
  87. package/dist/components/navigation/Hamburger.mjs.map +1 -0
  88. package/dist/components/navigation/Nav.cjs +1 -1
  89. package/dist/components/navigation/Nav.cjs.map +1 -1
  90. package/dist/components/navigation/Nav.context.cjs +2 -0
  91. package/dist/components/navigation/Nav.context.cjs.map +1 -0
  92. package/dist/components/navigation/Nav.context.mjs +137 -0
  93. package/dist/components/navigation/Nav.context.mjs.map +1 -0
  94. package/dist/components/navigation/Nav.mjs +151 -258
  95. package/dist/components/navigation/Nav.mjs.map +1 -1
  96. package/dist/components/navigation/Nav.parts.cjs +2 -0
  97. package/dist/components/navigation/Nav.parts.cjs.map +1 -0
  98. package/dist/components/navigation/Nav.parts.mjs +77 -0
  99. package/dist/components/navigation/Nav.parts.mjs.map +1 -0
  100. package/dist/components/navigation/Nav.root.cjs +2 -0
  101. package/dist/components/navigation/Nav.root.cjs.map +1 -0
  102. package/dist/components/navigation/Nav.root.mjs +78 -0
  103. package/dist/components/navigation/Nav.root.mjs.map +1 -0
  104. package/dist/components/navigation/NavDrawer.cjs +2 -0
  105. package/dist/components/navigation/NavDrawer.cjs.map +1 -0
  106. package/dist/components/navigation/NavDrawer.context.cjs +2 -0
  107. package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
  108. package/dist/components/navigation/NavDrawer.context.mjs +11 -0
  109. package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
  110. package/dist/components/navigation/NavDrawer.mjs +179 -0
  111. package/dist/components/navigation/NavDrawer.mjs.map +1 -0
  112. package/dist/components/overlays/Dialog.cjs +1 -1
  113. package/dist/components/overlays/Dialog.cjs.map +1 -1
  114. package/dist/components/overlays/Dialog.mjs +190 -125
  115. package/dist/components/overlays/Dialog.mjs.map +1 -1
  116. package/dist/components/overlays/Dialog.shared.cjs +1 -1
  117. package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
  118. package/dist/components/overlays/Dialog.shared.mjs +157 -81
  119. package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
  120. package/dist/components/overlays/Dialog.slots.cjs +2 -0
  121. package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
  122. package/dist/components/overlays/Dialog.slots.mjs +129 -0
  123. package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
  124. package/dist/components/overlays/Drawer.cjs +1 -1
  125. package/dist/components/overlays/Drawer.cjs.map +1 -1
  126. package/dist/components/overlays/Drawer.context.cjs +2 -0
  127. package/dist/components/overlays/Drawer.context.cjs.map +1 -0
  128. package/dist/components/overlays/Drawer.context.mjs +29 -0
  129. package/dist/components/overlays/Drawer.context.mjs.map +1 -0
  130. package/dist/components/overlays/Drawer.mjs +12 -187
  131. package/dist/components/overlays/Drawer.mjs.map +1 -1
  132. package/dist/components/overlays/Drawer.panel.cjs +2 -0
  133. package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
  134. package/dist/components/overlays/Drawer.panel.mjs +159 -0
  135. package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
  136. package/dist/components/overlays/Drawer.parts.cjs +2 -0
  137. package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
  138. package/dist/components/overlays/Drawer.parts.mjs +152 -0
  139. package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
  140. package/dist/components/overlays/Drawer.root.cjs +2 -0
  141. package/dist/components/overlays/Drawer.root.cjs.map +1 -0
  142. package/dist/components/overlays/Drawer.root.mjs +207 -0
  143. package/dist/components/overlays/Drawer.root.mjs.map +1 -0
  144. package/dist/components/overlays/Drawer.scroll.cjs +2 -0
  145. package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
  146. package/dist/components/overlays/Drawer.scroll.mjs +42 -0
  147. package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
  148. package/dist/hooks/useDismiss.cjs.map +1 -1
  149. package/dist/hooks/useDismiss.mjs.map +1 -1
  150. package/dist/hooks/useFocusTrap.cjs +1 -1
  151. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  152. package/dist/hooks/useFocusTrap.mjs +115 -98
  153. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  154. package/dist/hooks/useModalLayer.cjs +1 -1
  155. package/dist/hooks/useModalLayer.cjs.map +1 -1
  156. package/dist/hooks/useModalLayer.mjs +35 -22
  157. package/dist/hooks/useModalLayer.mjs.map +1 -1
  158. package/dist/hooks/useRestoreFocus.cjs +1 -1
  159. package/dist/hooks/useRestoreFocus.cjs.map +1 -1
  160. package/dist/hooks/useRestoreFocus.mjs +91 -78
  161. package/dist/hooks/useRestoreFocus.mjs.map +1 -1
  162. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  163. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  164. package/dist/hooks/useRovingTabIndex.mjs +102 -78
  165. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  166. package/dist/index.cjs +1 -1
  167. package/dist/index.d.cts +2226 -221
  168. package/dist/index.d.ts +2226 -221
  169. package/dist/index.mjs +115 -107
  170. package/dist/lib/classNames.cjs +1 -1
  171. package/dist/lib/classNames.cjs.map +1 -1
  172. package/dist/lib/classNames.mjs +137 -77
  173. package/dist/lib/classNames.mjs.map +1 -1
  174. package/dist/lib/icons.cjs +1 -1
  175. package/dist/lib/icons.cjs.map +1 -1
  176. package/dist/lib/icons.mjs +13 -6
  177. package/dist/lib/icons.mjs.map +1 -1
  178. package/dist/lib/layers.cjs +1 -1
  179. package/dist/lib/layers.cjs.map +1 -1
  180. package/dist/lib/layers.mjs +53 -47
  181. package/dist/lib/layers.mjs.map +1 -1
  182. package/dist/styles.css +1 -1
  183. package/package.json +1 -1
  184. package/src/styles/tokens.css +25 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Nav.mjs","names":["_Fragment","useId","useId$1","React","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","reportMissingContext","componentName","warnDuplicateValue","kind","useNavValue","context","registerValue","useRecordCategory","categoryStore","iconClasses","renderIcon","icon","slotRendersContent","renderSlot","cn","className","itemClasses","focusRingInset","disabledStyles","subItemClasses","categoryButtonClasses","childrenOf","element","children","isThenable","forEachElement","nodes","node","visit","child","error","isPart","types","getElementType","containsValue","found","NavItem","NavSubItem","selected","findCategoriesContaining","result","current","inner","NavCategory","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","isLink","href","handleClick","disabled","onClick","content","Fragment","withIcon","stable","entryClassName","classes","buttonRest","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","containsCurrent","currentCategory","buttonLabel","label","items","parts","isText","part","navCategoryClassNames","toggleCategory","ChevronDownIcon","navItemClassNames","navSubItemClassNames","NavRoot","valueProp","defaultValueProp","openCategoriesProp","controlledValue","resolveDeprecatedProp","selectedValue","defaultValue","defaultSelectedValue","onNavItemSelect","warnDeprecated","setValue","useControllable","onValueChange","notifyNavItemSelect","useEventCallback","select","next","initialOpenCategories","defaultOpenCategories","setOpenCategories","onOpenCategoriesChange","previous","entry","valueCountsRef","counts","key","count","remaining","contextValue","navClassNames","Nav"],"sources":["../../../src/components/navigation/Nav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navCategoryClassNames,\n navClassNames,\n navItemClassNames,\n navSubItemClassNames,\n} from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport {\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { getElementType } from '../../lib/children';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n/** The two value namespaces of a Nav: items (Nav.Item and Nav.SubItem) and categories. */\ntype NavValueKind = 'item' | 'category';\n\n/**\n * The category each sub-item was last shown in, by sub-item value: written from layout effects by\n * the mounted sub-items and by a closed category whose children hold the current value, read by\n * the categories with `useSyncExternalStore`. An entry outlives its sub-item, so a category closed\n * after its current sub-item was shown still knows it contains the current page.\n */\ninterface NavCategoryStore {\n /**\n * Records the category a mounted item renders in, or a closed category whose children hold the\n * value; `null` (an item outside any category) forgets an earlier entry, so a value moved out of\n * a category no longer marks it.\n */\n record: (value: string, category: string | null) => void;\n /** Forgets the entry of `value` while it is still `category`. */\n forget: (value: string, category: string) => void;\n /** The category last recorded for a sub-item value. */\n get: (value: string) => string | undefined;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction createCategoryStore(): NavCategoryStore {\n const categories = new Map<string, string>();\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n record(value, category) {\n if ((categories.get(value) ?? null) === category) return;\n if (category === null) categories.delete(value);\n else categories.set(value, category);\n notify();\n },\n forget(value, category) {\n if (categories.get(value) !== category) return;\n categories.delete(value);\n notify();\n },\n get: (value) => categories.get(value),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface NavContextValue {\n /** The selected item value (`''` when nothing is selected). */\n value: string;\n /** Selects an item (activation handler: also fires the deprecated `onNavItemSelect`). */\n select: (value: string) => void;\n openCategories: readonly string[];\n toggleCategory: (value: string) => void;\n /** Registers a mounted item or category value (duplicate warning); returns the cleanup. */\n registerValue: (kind: NavValueKind, value: string) => () => void;\n /** The `currentCategory` hint of the Nav. */\n currentCategory: string | undefined;\n categoryStore: NavCategoryStore;\n}\n\nconst NavContext = React.createContext<NavContextValue | null>(null);\nNavContext.displayName = 'NavContext';\n\nconst noop = () => {};\nconst INERT_NAV_CONTEXT: NavContextValue = {\n value: '',\n select: noop,\n openCategories: [],\n toggleCategory: noop,\n registerValue: () => noop,\n currentCategory: undefined,\n categoryStore: { record: noop, forget: noop, get: () => undefined, subscribe: () => noop },\n};\n\n/**\n * The value of the Nav.Category a sub-item renders in (`null` outside a category). It renders no\n * element; a sub-item outside a category is valid, so there is no missing-context error.\n */\nconst NavCategoryValueContext = React.createContext<string | null>(null);\nNavCategoryValueContext.displayName = 'NavCategoryValueContext';\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useNavContext(componentName: string): NavContextValue {\n const context = React.useContext(NavContext);\n if (context) return context;\n reportMissingContext(componentName, 'Nav');\n return INERT_NAV_CONTEXT;\n}\n\nfunction warnDuplicateValue(kind: NavValueKind, value: string): void {\n warnOnce(\n `Nav:duplicate-${kind}:${value}`,\n kind === 'item'\n ? `Nav: several items share the value \"${value}\". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.`\n : `Nav: several categories share the value \"${value}\". Nav.Category values must be unique within a Nav; they open and close together.`,\n );\n}\n\n/** Registers the value of a mounted item or category, so Nav can warn about duplicates. */\nfunction useNavValue(context: NavContextValue, kind: NavValueKind, value: string): void {\n const { registerValue } = context;\n React.useEffect(() => registerValue(kind, value), [registerValue, kind, value]);\n}\n\n/**\n * Records the category a mounted item renders in, which the category reads once closed (`null`\n * outside a category, which forgets a stale entry for the value).\n */\nfunction useRecordCategory(context: NavContextValue, value: string): void {\n const category = React.useContext(NavCategoryValueContext);\n const { categoryStore } = context;\n React.useLayoutEffect(() => {\n categoryStore.record(value, category);\n }, [categoryStore, value, category]);\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Properties for the Nav component. */\nexport interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue'> {\n /** Controlled value of the selected nav item. */\n value?: string;\n /**\n * Selected nav item value for uncontrolled usage.\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new value when the selection changes (not when the current item is re-selected). */\n onValueChange?: (value: string) => void;\n /** @deprecated Use `value`. */\n selectedValue?: string;\n /** @deprecated Use `defaultValue`. */\n defaultSelectedValue?: string;\n /**\n * @deprecated Use `onValueChange`. Unlike `onValueChange`, it fires on every activation,\n * re-selecting the current item included (0.4 behaviour).\n */\n onNavItemSelect?: (value: string) => void;\n /** Controlled list of open category values. */\n openCategories?: readonly string[];\n /**\n * Categories open initially (uncontrolled). Without it, the categories that contain the\n * selected item (`value`, else `defaultValue`) start open, so the current page is visible on the\n * first render; an empty list keeps every category closed.\n */\n defaultOpenCategories?: readonly string[];\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange?: (openCategories: string[]) => void;\n /**\n * The `value` of the category that contains the current item, for sub-items Nav cannot find by\n * itself (rendered by your own component inside a closed category). Usually not needed: Nav\n * finds sub-items among a category's children (through Fragments and wrapper elements) and\n * remembers the category of the current sub-item once it has been shown. A hint, not state:\n * unlike Fluent's `selectedCategoryValue` it has no default or change callback.\n */\n currentCategory?: string;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the NavCategory sub-component. */\nexport interface NavCategoryProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * Value identifying this category (used by `openCategories`), unique among the categories of\n * the Nav (a duplicate warns in development).\n */\n value: string;\n /**\n * Label of the category's toggle button (any content). Without it, the text children are used\n * as the label — deprecated: pass the label here and only the sub-items as children.\n */\n label?: React.ReactNode;\n /**\n * Icon displayed before the category label. Rendered with `aria-hidden=\"true\"`. A falsy icon\n * (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /** The category's sub-items (`Nav.SubItem`), rendered in its list while it is open. */\n children?: React.ReactNode;\n /** Ref to the category's `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * The props of Nav.Item that every branch shares ({@link NavItemAnchorProps},\n * {@link NavItemButtonProps}, {@link NavItemDynamicProps}).\n */\nexport interface NavItemOwnProps {\n /**\n * Value identifying this nav item, unique among the items and sub-items of the Nav (a duplicate\n * warns in development).\n */\n value: string;\n /**\n * Icon displayed before the item label. Rendered with `aria-hidden=\"true\"`. A falsy icon (`''`,\n * `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Whether the item is disabled: a native `disabled` button, or an `aria-disabled` link without\n * `href`. Activating a disabled item never selects it; a disabled item whose value is the\n * current `value` still shows as current (`aria-current=\"page\"` and the selected look), because\n * the current value belongs to the app.\n */\n disabled?: boolean;\n /** Label content. */\n children?: React.ReactNode;\n}\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Button items\n * declare them as `undefined`, so they are a type error without `href` instead of landing on the\n * `<button>`. `rel` cannot be listed (React types it on every element, RDFa); a button item drops\n * it at run time instead.\n */\ntype NoAnchorOnlyAttributes = {\n [\n K in Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>\n >\n ]?: undefined;\n};\n\n/**\n * Nav.Item rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement`. 0.4 typed every item's handlers on `HTMLButtonElement`, so with a string\n * `href` an unannotated 0.4 handler that reads a button-only member (such as\n * `e.currentTarget.form`) no longer compiles; a handler already typed as\n * `React.MouseEventHandler<HTMLButtonElement>` still does (React handler types are bivariant).\n */\nexport interface NavItemAnchorProps\n extends\n NavItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.Item rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavItemButtonProps\n extends\n NavItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavItemOwnProps> {\n /** Button items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavItem sub-component: link props with `href`, button props without.\n *\n * A union type (0.4 had an interface): an interface cannot extend it, so extend one branch\n * (`interface X extends NavItemButtonProps`) or intersect (`type X = NavItemProps & { … }`).\n * `React.ComponentProps<typeof Nav.Item>` resolves to the last overload,\n * {@link NavItemDynamicProps}.\n */\nexport type NavItemProps = NavItemAnchorProps | NavItemButtonProps;\n\n/**\n * Nav.Item with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Resolved after the button and link signatures.\n *\n * Only the attributes both elements share are accepted (no `target`, `download`, `type`, `form`,\n * …), and handlers receive events of either element (`HTMLAnchorElement | HTMLButtonElement`).\n * 0.4 typed them as button events (`HTMLAttributes<HTMLButtonElement>`), so an unannotated 0.4\n * handler that reads a button-only member (such as `e.currentTarget.form`) no longer compiles here;\n * narrow `e.currentTarget` first. (A string `href` types handlers on `HTMLAnchorElement`, see\n * {@link NavItemAnchorProps}; no `href` keeps `HTMLButtonElement`.)\n */\nexport interface NavItemDynamicProps\n extends\n NavItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/**\n * The props of Nav.SubItem that every branch shares: those of {@link NavItemOwnProps} without\n * `icon`.\n */\nexport type NavSubItemOwnProps = Omit<NavItemOwnProps, 'icon'>;\n\n/**\n * Nav.SubItem rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement` (0.4: `HTMLButtonElement`); see {@link NavItemAnchorProps}.\n */\nexport interface NavSubItemAnchorProps\n extends\n NavSubItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavSubItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.SubItem rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavSubItemButtonProps\n extends\n NavSubItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** Button sub-items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavSubItem sub-component: link props with `href`, button props without.\n * A union type like {@link NavItemProps} (extend a branch or intersect; `React.ComponentProps`\n * resolves to {@link NavSubItemDynamicProps}).\n */\nexport type NavSubItemProps = NavSubItemAnchorProps | NavSubItemButtonProps;\n\n/**\n * Nav.SubItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Only the attributes both elements share are accepted, and handlers\n * receive events of either element (0.4 typed them as button events); see\n * {@link NavItemDynamicProps}.\n */\nexport interface NavSubItemDynamicProps\n extends\n NavSubItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** The props both entry kinds share at runtime (the union narrowed by `href`). */\ntype NavEntryProps = NavItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst iconClasses = 'flex h-5 w-5 shrink-0 items-center justify-center';\n\n/**\n * The `icon` slot of Nav.Item and Nav.Category, or `null` when it renders nothing. A falsy icon\n * (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4 and as in\n * Avatar, and so is a collection whose items render nothing, so no empty 20px box is rendered\n * before the label. The check does not consume a generator: renderSlot still renders its items.\n */\nfunction renderIcon(\n icon: Slot<'span'> | undefined,\n className: string | undefined,\n): React.ReactElement | null {\n return icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(className, iconClasses), { 'aria-hidden': true })\n : null;\n}\n\nconst itemClasses = {\n base: cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary',\n idle: 'text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst subItemClasses = {\n base: cn(\n 'flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'text-primary font-semibold',\n idle: 'text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst categoryButtonClasses = cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n // A closed category that contains the current page shows the selected look of an item.\n 'data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary',\n focusRingInset,\n);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ntype ElementWithChildren = React.ReactElement<{ value?: unknown; children?: React.ReactNode }>;\n\nfunction childrenOf(element: ElementWithChildren): React.ReactNode {\n const { children } = element.props;\n return typeof children === 'function' ? undefined : children;\n}\n\n/** Whether a thrown value suspends rendering (a loading lazy chunk, a pending promise). */\nfunction isThenable(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/*\n * The walks below run during Nav's render and reach consumer content at any depth. Content that\n * is still loading inside the consumer's own <Suspense> (a promise child, a lazy node, a\n * `React.lazy` component) suspends that boundary when React renders it; walking it must never\n * suspend Nav itself, which would hide the whole Nav behind an outer boundary. So a child that\n * cannot be read yet is skipped, and a lazy type that is still loading is not a part (its\n * children are still walked). Parts written in a Server Component arrive as loaded client\n * references and are recognized.\n */\n\n/** Calls `visit` with each element of `nodes` (as `React.Children.forEach`), skipping pending ones. */\nfunction forEachElement(nodes: React.ReactNode, visit: (child: ElementWithChildren) => void): void {\n if (Array.isArray(nodes)) {\n for (const node of nodes as React.ReactNode[]) forEachElement(node, visit);\n return;\n }\n try {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<ElementWithChildren['props']>(child)) visit(child);\n });\n } catch (error) {\n if (!isThenable(error)) throw error;\n }\n}\n\n/** Whether `element` is one of `types`; a lazy type still loading is none (it never suspends). */\nfunction isPart(element: ElementWithChildren, ...types: unknown[]): boolean {\n return types.includes(getElementType(element, { suspend: false }));\n}\n\n/**\n * Whether `nodes` contain a Nav.Item/Nav.SubItem element with `value === selected` (parts written\n * in a Server Component, lazy client references, included). Called during render only.\n */\nfunction containsValue(nodes: React.ReactNode, selected: string): boolean {\n let found = false;\n forEachElement(nodes, (child) => {\n if (found) return;\n if (isPart(child, NavItem, NavSubItem) && child.props.value === selected) {\n found = true;\n } else {\n found = containsValue(childrenOf(child), selected);\n }\n });\n return found;\n}\n\n/** The values of the Nav.Category elements (at any depth of JSX) that contain `selected`. */\nfunction findCategoriesContaining(nodes: React.ReactNode, selected: string): string[] {\n const result: string[] = [];\n if (!selected) return result;\n const visit = (current: React.ReactNode) => {\n forEachElement(current, (child) => {\n const inner = childrenOf(child);\n if (\n isPart(child, NavCategory) &&\n typeof child.props.value === 'string' &&\n containsValue(inner, selected)\n ) {\n result.push(child.props.value);\n }\n visit(inner);\n });\n };\n visit(nodes);\n return result;\n}\n\n/**\n * Whether a click on a link opens it somewhere other than the current page, checked as routers\n * do: a modifier key (a new tab or window, a download), a mouse button other than the main one, a\n * `target` other than `_self`, or a `download` link. Only when the default is not prevented does\n * the browser actually open it there.\n */\nfunction opensElsewhere(event: React.MouseEvent<HTMLElement>): boolean {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return true;\n }\n const link = event.currentTarget;\n const target = link.getAttribute('target');\n return (!!target && target.toLowerCase() !== '_self') || link.hasAttribute('download');\n}\n\n/** The stable classes of an entry, written literally by Nav.Item and Nav.SubItem. */\ninterface NavEntryClassNames {\n root: string;\n listItem: string;\n icon?: string;\n content?: string;\n}\n\n/** Shared rendering of Nav.Item and Nav.SubItem (link or button). */\nfunction renderNavEntry(\n props: NavEntryProps,\n context: NavContextValue,\n classes: { base: string; selected: string; idle: string },\n stable: NavEntryClassNames,\n withIcon: boolean,\n): React.ReactElement {\n const { value, icon, disabled = false, href, className, children, onClick, ref, ...rest } = props;\n const isSelected = context.value === value;\n const isLink = href !== undefined;\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n // A link is still selected when the consumer prevents its default (client-side routing:\n // `preventDefault()` + `router.push(href)`, whatever the modifier keys: the browser then opens\n // nothing elsewhere), but not when the browser opens it elsewhere (the current page does not\n // change); a button honours `preventDefault()` (C-COMPOSE).\n if (isLink ? !event.defaultPrevented && opensElsewhere(event) : event.defaultPrevented) return;\n context.select(value);\n };\n\n const content = (\n <>\n {withIcon && renderIcon(icon, stable.icon)}\n {withIcon ? (\n <span className={cn(stable.content, 'flex-1 text-start')}>{children}</span>\n ) : (\n children\n )}\n </>\n );\n\n const entryClassName = cn(\n stable.root,\n classes.base,\n isSelected ? classes.selected : classes.idle,\n className,\n );\n\n if (isLink) {\n return (\n <li className={stable.listItem}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={disabled ? undefined : href}\n role={disabled ? 'link' : rest.role}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </a>\n </li>\n );\n }\n\n // `rel` only belongs on a link: a button item drops it (React types it on every element).\n const { rel, ...buttonRest } = rest;\n return (\n <li className={stable.listItem}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={disabled}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </button>\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Nav.Category\n// ---------------------------------------------------------------------------\n\n/**\n * A collapsible group of sub-items. Its toggle button shows `label` and reports `aria-expanded`\n * (and `aria-controls` while open); the sub-items render in a nested list while it is open.\n * Open state lives on `Nav` (`openCategories`/`defaultOpenCategories`).\n *\n * A closed category that contains the current item marks its toggle button with\n * `aria-current=\"true\"` (the button is not the page's link, so not `\"page\"`),\n * `data-contains-current` and the selected look of `Nav.Item`. It contains the current item when\n * a `Nav.SubItem` with the current value is among its children (through Fragments and wrapper\n * elements, also in the server HTML), when the current sub-item was last shown in it (and has not\n * moved among another category's children since), or when it is the Nav's `currentCategory`. An\n * open category is not marked: its sub-item shows the current page.\n *\n * Also exported as `NavCategory` (import the flat name from React Server Components).\n */\nconst NavCategory = ({\n value,\n label,\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavCategoryProps) => {\n const context = useNavContext('Nav.Category');\n const {\n value: currentValue,\n openCategories,\n toggleCategory,\n currentCategory,\n categoryStore,\n } = context;\n useNavValue(context, 'category', value);\n const listId = useId('wave-nav-category');\n const isOpen = openCategories.includes(value);\n\n // The current sub-item is among the children of this closed category (also on the server).\n const holdsCurrentChild = !isOpen && currentValue !== '' && containsValue(children, currentValue);\n // The current sub-item was last shown in this category (none on the server).\n const holdsShownCurrent = React.useSyncExternalStore(\n categoryStore.subscribe,\n () => currentValue !== '' && categoryStore.get(currentValue) === value,\n () => false,\n );\n // Children that hold the current sub-item make this the category the Nav remembers for it, so a\n // category it was shown in before it moved here is no longer marked. The entry is forgotten when\n // they stop holding it (an open category records through its mounted sub-item instead).\n React.useLayoutEffect(() => {\n if (!holdsCurrentChild) return;\n categoryStore.record(currentValue, value);\n return () => categoryStore.forget(currentValue, value);\n }, [categoryStore, holdsCurrentChild, currentValue, value]);\n const containsCurrent =\n !isOpen && (currentCategory === value || holdsShownCurrent || holdsCurrentChild);\n\n let buttonLabel: React.ReactNode = label;\n let items: React.ReactNode = children;\n if (label === undefined) {\n // Deprecated 0.4 path: the text children are the label, the other children the sub-items.\n warnDeprecated(\n 'Nav.Category',\n 'text children as the label',\n 'label',\n 'Pass the category label in `label` and only the sub-items as children.',\n );\n const parts = React.Children.toArray(children);\n const isText = (part: unknown) => typeof part === 'string' || typeof part === 'number';\n buttonLabel = parts.filter(isText).join('');\n items = parts.filter((part) => !isText(part));\n }\n\n return (\n <li ref={ref} {...rest} className={cn(navCategoryClassNames.root, className)}>\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-current={containsCurrent ? true : undefined}\n data-contains-current={containsCurrent ? '' : undefined}\n onClick={() => toggleCategory(value)}\n className={cn(navCategoryClassNames.button, categoryButtonClasses)}\n >\n {renderIcon(icon, navCategoryClassNames.icon)}\n <span className={cn(navCategoryClassNames.label, 'flex-1 text-start')}>{buttonLabel}</span>\n <ChevronDownIcon\n className={cn(\n navCategoryClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isOpen && 'rotate-180',\n )}\n />\n </button>\n {isOpen && (\n <NavCategoryValueContext.Provider value={value}>\n <ul id={listId} className={cn(navCategoryClassNames.list, 'm-0 list-none p-0')}>\n {items}\n </ul>\n </NavCategoryValueContext.Provider>\n )}\n </li>\n );\n};\nNavCategory.displayName = 'NavCategory';\n\n// ---------------------------------------------------------------------------\n// Nav.Item / Nav.SubItem\n// ---------------------------------------------------------------------------\n\n/**\n * A top-level navigation entry: a link when `href` is given (anchor props), a button otherwise\n * (button props). Clicking selects it (`aria-current=\"page\"`); activating a disabled entry never\n * selects it (a disabled entry whose value is the current value still shows as current).\n *\n * A click that opens a link somewhere other than the current page selects nothing (the consumer's\n * `onClick` still runs, and the browser opens the link): Ctrl/Cmd/Shift/Alt-click, a mouse button\n * other than the main one, a `target` other than `_self`, or a `download` link. When the consumer's\n * `onClick` calls `preventDefault()` (client-side routing), the browser opens nothing, so the item\n * is selected whatever the keys, button or `target`.\n *\n * Typed by overloads, resolved in order: without `href` (button props, button events), with a\n * string `href` (anchor props, anchor events), then an `href` that may be `undefined` at run time\n * ({@link NavItemDynamicProps}: events of either element).\n *\n * Also exported as `NavItem` (import the flat name from React Server Components).\n */\nfunction NavItem(props: NavItemButtonProps): React.ReactElement;\nfunction NavItem(props: NavItemAnchorProps): React.ReactElement;\nfunction NavItem(props: NavItemDynamicProps): React.ReactElement;\nfunction NavItem(props: NavItemProps | NavItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.Item');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(\n props as NavEntryProps,\n context,\n itemClasses,\n {\n root: navItemClassNames.root,\n listItem: navItemClassNames.listItem,\n icon: navItemClassNames.icon,\n content: navItemClassNames.content,\n },\n true,\n );\n}\nNavItem.displayName = 'NavItem';\n\n/**\n * An indented entry inside a `Nav.Category`: a link when `href` is given, a button otherwise.\n * Selected like `Nav.Item` (a click that the browser opens somewhere else selects nothing; one\n * whose default your `onClick` prevents is selected), and typed by overloads like `Nav.Item`\n * (button, link, then {@link NavSubItemDynamicProps}).\n *\n * Also exported as `NavSubItem` (import the flat name from React Server Components).\n */\nfunction NavSubItem(props: NavSubItemButtonProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemAnchorProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemDynamicProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemProps | NavSubItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.SubItem');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(\n props as NavEntryProps,\n context,\n subItemClasses,\n { root: navSubItemClassNames.root, listItem: navSubItemClassNames.listItem },\n false,\n );\n}\nNavSubItem.displayName = 'NavSubItem';\n\n// ---------------------------------------------------------------------------\n// Nav (root)\n// ---------------------------------------------------------------------------\n\nconst NavRoot = ({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n selectedValue,\n defaultSelectedValue,\n onNavItemSelect,\n openCategories: openCategoriesProp,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n className,\n children,\n ref,\n ...rest\n}: NavProps) => {\n const controlledValue = resolveDeprecatedProp(\n 'Nav',\n valueProp,\n selectedValue,\n 'selectedValue',\n 'value',\n );\n const defaultValue =\n resolveDeprecatedProp(\n 'Nav',\n defaultValueProp,\n defaultSelectedValue,\n 'defaultSelectedValue',\n 'defaultValue',\n ) ?? '';\n if (onNavItemSelect !== undefined) warnDeprecated('Nav', 'onNavItemSelect', 'onValueChange');\n\n const [value, setValue] = useControllable(controlledValue, defaultValue, onValueChange);\n const notifyNavItemSelect = useEventCallback(onNavItemSelect);\n const select = React.useCallback(\n (next: string) => {\n setValue(next);\n // Deprecated event-named alias: every activation, re-selection included (C-NAMING).\n notifyNavItemSelect(next);\n },\n [setValue, notifyNavItemSelect],\n );\n\n const [initialOpenCategories] = React.useState<readonly string[]>(\n () =>\n defaultOpenCategories ?? findCategoriesContaining(children, controlledValue ?? defaultValue),\n );\n const [openCategories, setOpenCategories] = useControllable<readonly string[]>(\n openCategoriesProp,\n initialOpenCategories,\n (next) => onOpenCategoriesChange?.([...next]),\n );\n const toggleCategory = React.useCallback(\n (category: string) => {\n setOpenCategories((previous) =>\n previous.includes(category)\n ? previous.filter((entry) => entry !== category)\n : [...previous, category],\n );\n },\n [setOpenCategories],\n );\n\n // Duplicate values (C-DEV): the mounted items and categories per value (written from their\n // effects only); a second one with a value already in use warns once per value.\n const valueCountsRef = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((kind: NavValueKind, entry: string) => {\n const counts = (valueCountsRef.current ??= new Map<string, number>());\n const key = `${kind}:${entry}`;\n const count = (counts.get(key) ?? 0) + 1;\n counts.set(key, count);\n if (count > 1) warnDuplicateValue(kind, entry);\n return () => {\n const remaining = (counts.get(key) ?? 1) - 1;\n if (remaining > 0) counts.set(key, remaining);\n else counts.delete(key);\n };\n }, []);\n\n const [categoryStore] = React.useState(createCategoryStore);\n\n const contextValue = React.useMemo<NavContextValue>(\n () => ({\n value,\n select,\n openCategories,\n toggleCategory,\n registerValue,\n currentCategory,\n categoryStore,\n }),\n [value, select, openCategories, toggleCategory, registerValue, currentCategory, categoryStore],\n );\n\n return (\n <NavContext.Provider value={contextValue}>\n <nav\n aria-label=\"Navigation\"\n {...rest}\n ref={ref}\n className={cn(\n navClassNames.root,\n 'w-60 border-e border-border bg-background py-2',\n className,\n )}\n >\n <ul className={cn(navClassNames.list, 'm-0 list-none p-0')}>{children}</ul>\n </nav>\n </NavContext.Provider>\n );\n};\nNavRoot.displayName = 'Nav';\n\n/**\n * A vertical side navigation (`<nav>` landmark, default name \"Navigation\") with items, links and\n * collapsible categories.\n *\n * - **Selection**: `value`/`defaultValue`/`onValueChange` (`onValueChange` fires only when the\n * value changes). The deprecated `selectedValue`/`defaultSelectedValue`/`onNavItemSelect` still\n * work; `onNavItemSelect` keeps firing on every activation, re-selection included. A click that\n * opens a link in another tab or window (or downloads it) selects nothing, unless the item's\n * `onClick` prevents the default (client-side routing: then nothing opens elsewhere).\n * - **Categories**: `openCategories`/`defaultOpenCategories`/`onOpenCategoriesChange`. Without\n * `defaultOpenCategories`, the categories containing the selected item (`value` or\n * `defaultValue`) start open. A closed category that contains the selected item marks its toggle\n * (`aria-current=\"true\"`, `data-contains-current`, the selected look); pass `currentCategory`\n * for sub-items your own component renders inside a closed category.\n * - **Values** are unique: among the items and sub-items, and among the categories (a duplicate\n * warns in development).\n *\n * Sub-components are also exported under flat names (`NavCategory`, `NavItem`, `NavSubItem`):\n * React Server Components import those, because dotted access (`Nav.Item`) needs a client file.\n */\nexport const Nav = /* @__PURE__ */ Object.assign(NavRoot, {\n Category: NavCategory,\n Item: NavItem,\n SubItem: NavSubItem,\n});\n\nexport { NavCategory, NavItem, NavSubItem };\n"],"mappings":";;;;;;;;;;;;;;AAkDA,SAASI,IAAwC;CAC/C,IAAMC,oBAAa,IAAI,IAAoB,GACrCC,oBAAY,IAAI,IAAgB,GAChCC,UAAeD,EAAU,SAAS,MAAaE,EAAS,CAAC;CAC/D,OAAO;EACL,OAAO,GAAO,GAAU;GACtB,CAAKH,EAAW,IAAII,CAAK,KAAK,UAAUC,MACpCA,MAAa,OAAML,EAAW,OAAOI,CAAK,IACzCJ,EAA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["_Fragment","useId","useId$1","React","iconClasses","renderIcon","icon","slotRendersContent","renderSlot","cn","className","itemClasses","focusRingInset","disabledStyles","subItemClasses","rowClasses","rowHoverClasses","actionsClasses","categoryButtonClasses","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","context","value","isLink","href","rovingProps","roving","hasActions","actions","itemId","generatedId","idProps","handleClick","disabled","onClick","content","Fragment","withIcon","stable","children","entryClassName","classes","listItemClassName","actionsGroup","materialiseSlotContent","buttonRest","NavCategory","useNavContext","NavRovingContext","currentValue","listId","isOpen","openCategories","holdsCurrentChild","containsValue","holdsShownCurrent","categoryStore","containsCurrent","currentCategory","listRef","buttonLabel","label","items","parts","isText","part","navCategoryClassNames","toggleCategory","ChevronDownIcon","NavCategoryValueContext","markNavPart","NavItem","useNavValue","useRecordCategory","navItemClassNames","NavSubItem","navSubItemClassNames","Nav","NavRoot","NavSectionHeader","NavDivider","NavAppItem","NavAppItemStatic"],"sources":["../../../src/components/navigation/Nav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navCategoryClassNames,\n navItemClassNames,\n navSubItemClassNames,\n} from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnDeprecated } from '../../lib/dev';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport { useId } from '../../hooks/useId';\nimport {\n NavCategoryValueContext,\n NavRovingContext,\n containsValue,\n markNavPart,\n useNavContext,\n useNavListChildCheck,\n useNavValue,\n useRecordCategory,\n type NavContextValue,\n type NavRovingContextValue,\n type NoAnchorOnlyAttributes,\n} from './Nav.context';\nimport { NavAppItem, NavAppItemStatic, NavDivider, NavSectionHeader } from './Nav.parts';\nimport { NavRoot } from './Nav.root';\n\n/*\n * The Nav compound: the item types, styles and rendering of Nav.Item and Nav.SubItem, Nav.Category,\n * the `Object.assign` with its JSDoc, the flat names and the type re-exports. Nothing imports this\n * module but the barrel: the root (`Nav.root.tsx`) and the contexts (`Nav.context.ts`) recognise\n * the parts by the markers set next to each `displayName` below; the structural parts live in\n * `Nav.parts.tsx`.\n */\n\nexport type { NavProps } from './Nav.root';\nexport type {\n NavSectionHeaderProps,\n NavDividerProps,\n NavAppItemOwnProps,\n NavAppItemAnchorProps,\n NavAppItemButtonProps,\n NavAppItemProps,\n NavAppItemDynamicProps,\n NavAppItemStaticProps,\n} from './Nav.parts';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Properties for the NavCategory sub-component. */\nexport interface NavCategoryProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * Value identifying this category (used by `openCategories`), unique among the categories of\n * the Nav (a duplicate warns in development).\n */\n value: string;\n /**\n * Label of the category's toggle button (any content). Without it, the text children are used\n * as the label — deprecated: pass the label here and only the sub-items as children.\n */\n label?: React.ReactNode;\n /**\n * Icon displayed before the category label. Rendered with `aria-hidden=\"true\"`. A falsy icon\n * (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * The category's sub-items (`Nav.SubItem`), and `Nav.SectionHeader` and `Nav.Divider`, rendered\n * in its list while it is open.\n */\n children?: React.ReactNode;\n /** Ref to the category's `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * The props of Nav.Item that every branch shares ({@link NavItemAnchorProps},\n * {@link NavItemButtonProps}, {@link NavItemDynamicProps}).\n */\nexport interface NavItemOwnProps {\n /**\n * Value identifying this nav item, unique among the items and sub-items of the Nav (a duplicate\n * warns in development).\n */\n value: string;\n /**\n * Icon displayed before the item label. Rendered with `aria-hidden=\"true\"`. A falsy icon (`''`,\n * `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Whether the item is disabled: a native `disabled` button, or an `aria-disabled` link without\n * `href`. Activating a disabled item never selects it; a disabled item whose value is the\n * current `value` still shows as current (`aria-current=\"page\"` and the selected look), because\n * the current value belongs to the app.\n */\n disabled?: boolean;\n /** Label content. */\n children?: React.ReactNode;\n /**\n * Controls beside the item in its row (Fluent's SplitNavItem): a ToggleButton that pins the\n * page, a MenuButton with more commands, each with its own name (a Tooltip with\n * `relationship=\"label\"` names an icon-only one). They render after the item's link or button,\n * never inside it, in a group named by the item; each is a Tab stop after the item, and a click\n * or key on one never selects the item. They are drawn while the row is hovered or has focus,\n * while one of them is pressed or has its popup open, and always in forced colours and on touch\n * screens; otherwise they are transparent and still focusable. They stay enabled when the item\n * is `disabled`. With actions, the selected background and indicator are drawn on the row (the\n * item's list item, `.wave-nav-item__list-item`), so a `className` on the item no longer covers\n * them. Content that renders nothing renders no group. Fluent's `actionButton`, `toggleButton`\n * and `menuButton` slots and their tooltips are your own controls here.\n */\n actions?: React.ReactNode;\n}\n\n/**\n * Nav.Item rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement`. 0.4 typed every item's handlers on `HTMLButtonElement`, so with a string\n * `href` an unannotated 0.4 handler that reads a button-only member (such as\n * `e.currentTarget.form`) no longer compiles; a handler already typed as\n * `React.MouseEventHandler<HTMLButtonElement>` still does (React handler types are bivariant).\n */\nexport interface NavItemAnchorProps\n extends\n NavItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.Item rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavItemButtonProps\n extends\n NavItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavItemOwnProps> {\n /** Button items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavItem sub-component: link props with `href`, button props without.\n *\n * A union type (0.4 had an interface): an interface cannot extend it, so extend one branch\n * (`interface X extends NavItemButtonProps`) or intersect (`type X = NavItemProps & { … }`).\n * `React.ComponentProps<typeof Nav.Item>` resolves to the last overload,\n * {@link NavItemDynamicProps}.\n */\nexport type NavItemProps = NavItemAnchorProps | NavItemButtonProps;\n\n/**\n * Nav.Item with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Resolved after the button and link signatures.\n *\n * Only the attributes both elements share are accepted (no `target`, `download`, `type`, `form`,\n * …), and handlers receive events of either element (`HTMLAnchorElement | HTMLButtonElement`).\n * 0.4 typed them as button events (`HTMLAttributes<HTMLButtonElement>`), so an unannotated 0.4\n * handler that reads a button-only member (such as `e.currentTarget.form`) no longer compiles here;\n * narrow `e.currentTarget` first. (A string `href` types handlers on `HTMLAnchorElement`, see\n * {@link NavItemAnchorProps}; no `href` keeps `HTMLButtonElement`.)\n */\nexport interface NavItemDynamicProps\n extends\n NavItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/**\n * The props of Nav.SubItem that every branch shares: those of {@link NavItemOwnProps} without\n * `icon`.\n */\nexport type NavSubItemOwnProps = Omit<NavItemOwnProps, 'icon'>;\n\n/**\n * Nav.SubItem rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement` (0.4: `HTMLButtonElement`); see {@link NavItemAnchorProps}.\n */\nexport interface NavSubItemAnchorProps\n extends\n NavSubItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavSubItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.SubItem rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavSubItemButtonProps\n extends\n NavSubItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** Button sub-items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavSubItem sub-component: link props with `href`, button props without.\n * A union type like {@link NavItemProps} (extend a branch or intersect; `React.ComponentProps`\n * resolves to {@link NavSubItemDynamicProps}).\n */\nexport type NavSubItemProps = NavSubItemAnchorProps | NavSubItemButtonProps;\n\n/**\n * Nav.SubItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Only the attributes both elements share are accepted, and handlers\n * receive events of either element (0.4 typed them as button events); see\n * {@link NavItemDynamicProps}.\n */\nexport interface NavSubItemDynamicProps\n extends\n NavSubItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** The props both entry kinds share at runtime (the union narrowed by `href`). */\ntype NavEntryProps = NavItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst iconClasses = 'flex h-5 w-5 shrink-0 items-center justify-center';\n\n/**\n * The `icon` slot of Nav.Item and Nav.Category, or `null` when it renders nothing. A falsy icon\n * (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4 and as in\n * Avatar, and so is a collection whose items render nothing, so no empty 20px box is rendered\n * before the label. The check does not consume a generator: renderSlot still renders its items.\n */\nfunction renderIcon(\n icon: Slot<'span'> | undefined,\n className: string | undefined,\n): React.ReactElement | null {\n return icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(className, iconClasses), { 'aria-hidden': true })\n : null;\n}\n\nconst itemClasses = {\n base: cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary',\n idle: 'text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n // With actions, the selected background and indicator move to the row (D121).\n selectedInRow: 'text-primary font-semibold',\n rowSelected: 'bg-subtle-selected border-s-2 border-s-primary',\n};\n\nconst subItemClasses = {\n base: cn(\n 'flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'text-primary font-semibold',\n idle: 'text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n // Sub-items have no selected background: a sub-item row gets only the hover.\n selectedInRow: 'text-primary font-semibold',\n rowSelected: undefined,\n};\n\n/** The classes an entry's link or button and its row share. */\ninterface NavEntryClasses {\n base: string;\n selected: string;\n idle: string;\n selectedInRow: string;\n rowSelected: string | undefined;\n}\n\n/**\n * The row of an entry with actions (D121): the list item lays out the link or button and the\n * actions side by side and carries the selected look, or the hover of an enabled entry. A list\n * item cannot be disabled, so its hover needs no gate.\n */\nconst rowClasses =\n 'group/nav-row flex items-center transition-colors motion-reduce:transition-none';\nconst rowHoverClasses = 'hover:bg-subtle-hover';\n\n/**\n * The actions element (D120). Each direct child is transparent until the row is hovered or has\n * focus inside it, and is always drawn in forced colours and on devices without hover; a child\n * that is or holds a pressed toggle or an expanded trigger stays drawn (the first pair covers an\n * action wrapped in a Tooltip's span, the second a bare one). Opacity keeps every action\n * focusable, so Shift+Tab and a focus return reach it. No motion.\n */\nconst actionsClasses = cn(\n 'flex shrink-0 items-center gap-1 pe-2',\n '*:opacity-0 group-hover/nav-row:*:opacity-100 group-focus-within/nav-row:*:opacity-100',\n 'forced-colors:*:opacity-100 [@media(hover:none)]:*:opacity-100',\n '*:has-[[aria-pressed=true]]:opacity-100 *:has-[[aria-expanded=true]]:opacity-100',\n '[&>[aria-pressed=true]]:opacity-100 [&>[aria-expanded=true]]:opacity-100',\n);\n\nconst categoryButtonClasses = cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n // A closed category that contains the current page shows the selected look of an item.\n 'data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary',\n focusRingInset,\n);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Whether a click on a link opens it somewhere other than the current page, checked as routers\n * do: a modifier key (a new tab or window, a download), a mouse button other than the main one, a\n * `target` other than `_self`, or a `download` link. Only when the default is not prevented does\n * the browser actually open it there.\n */\nfunction opensElsewhere(event: React.MouseEvent<HTMLElement>): boolean {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return true;\n }\n const link = event.currentTarget;\n const target = link.getAttribute('target');\n return (!!target && target.toLowerCase() !== '_self') || link.hasAttribute('download');\n}\n\n/** The stable classes of an entry, written literally by Nav.Item and Nav.SubItem. */\ninterface NavEntryClassNames {\n root: string;\n listItem: string;\n actions: string;\n icon?: string;\n content?: string;\n}\n\n/**\n * Shared rendering of Nav.Item and Nav.SubItem (link or button). Inside an arrow-key body\n * (`roving` provided) the link or button also carries `data-roving-value={value}`, after the\n * consumer's attributes; in a plain Nav nothing is added. With `actions` that render content, the\n * list item becomes the row (D121) and holds the link or button, then the actions in a group named\n * by it through `generatedId` (unless the consumer gave an `id`), siblings, never nested (D119).\n */\nfunction renderNavEntry(\n props: NavEntryProps,\n context: NavContextValue,\n roving: NavRovingContextValue | null,\n classes: NavEntryClasses,\n stable: NavEntryClassNames,\n withIcon: boolean,\n generatedId: string,\n): React.ReactElement {\n const {\n value,\n icon,\n disabled = false,\n href,\n className,\n children,\n onClick,\n actions,\n ref,\n ...rest\n } = props;\n const isSelected = context.value === value;\n const isLink = href !== undefined;\n const rovingProps = roving ? { 'data-roving-value': value } : undefined;\n // No empty group (`actions={cond && <Button />}` with `cond` false); the id is rendered only\n // while the group points at it, so an item without actions keeps its 0.10 HTML.\n const hasActions = slotRendersContent(actions);\n const itemId = rest.id ?? generatedId;\n const idProps = hasActions ? { id: itemId } : undefined;\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n // A link is still selected when the consumer prevents its default (client-side routing:\n // `preventDefault()` + `router.push(href)`, whatever the modifier keys: the browser then opens\n // nothing elsewhere), but not when the browser opens it elsewhere (the current page does not\n // change); a button honours `preventDefault()` (C-COMPOSE).\n if (isLink ? !event.defaultPrevented && opensElsewhere(event) : event.defaultPrevented) return;\n context.select(value);\n };\n\n const content = (\n <>\n {withIcon && renderIcon(icon, stable.icon)}\n {withIcon ? (\n <span className={cn(stable.content, 'flex-1 text-start')}>{children}</span>\n ) : (\n children\n )}\n </>\n );\n\n const entryClassName = cn(\n stable.root,\n classes.base,\n isSelected ? (hasActions ? classes.selectedInRow : classes.selected) : classes.idle,\n hasActions && 'min-w-0 flex-1',\n className,\n );\n\n const listItemClassName = hasActions\n ? cn(\n stable.listItem,\n rowClasses,\n isSelected && classes.rowSelected ? classes.rowSelected : !disabled && rowHoverClasses,\n )\n : stable.listItem;\n\n const actionsGroup = hasActions ? (\n <span\n role=\"group\"\n aria-labelledby={itemId}\n data-wave-nav-actions=\"\"\n className={cn(stable.actions, actionsClasses)}\n >\n {materialiseSlotContent(actions)}\n </span>\n ) : null;\n\n if (isLink) {\n return (\n <li className={listItemClassName}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n {...idProps}\n {...rovingProps}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={disabled ? undefined : href}\n role={disabled ? 'link' : rest.role}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </a>\n {actionsGroup}\n </li>\n );\n }\n\n // `rel` only belongs on a link: a button item drops it (React types it on every element).\n const { rel, ...buttonRest } = rest;\n return (\n <li className={listItemClassName}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n {...idProps}\n {...rovingProps}\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={disabled}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </button>\n {actionsGroup}\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Nav.Category\n// ---------------------------------------------------------------------------\n\n/**\n * A collapsible group of sub-items. Its toggle button shows `label` and reports `aria-expanded`\n * (and `aria-controls` while open); the sub-items render in a nested list while it is open.\n * Open state lives on `Nav` (`openCategories`/`defaultOpenCategories`).\n *\n * A closed category that contains the current item marks its toggle button with\n * `aria-current=\"true\"` (the button is not the page's link, so not `\"page\"`),\n * `data-contains-current` and the selected look of `Nav.Item`. It contains the current item when\n * a `Nav.SubItem` with the current value is among its children (through Fragments and wrapper\n * elements, also in the server HTML), when the current sub-item was last shown in it (and has not\n * moved among another category's children since), or when it is the Nav's `currentCategory`. An\n * open category is not marked: its sub-item shows the current page.\n *\n * Also exported as `NavCategory` (import the flat name from React Server Components).\n */\nconst NavCategory = ({\n value,\n label,\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavCategoryProps) => {\n const context = useNavContext('Nav.Category');\n const roving = React.useContext(NavRovingContext);\n const {\n value: currentValue,\n openCategories,\n toggleCategory,\n currentCategory,\n categoryStore,\n } = context;\n useNavValue(context, 'category', value);\n const listId = useId('wave-nav-category');\n const isOpen = openCategories.includes(value);\n\n // The current sub-item is among the children of this closed category (also on the server).\n const holdsCurrentChild = !isOpen && currentValue !== '' && containsValue(children, currentValue);\n // The current sub-item was last shown in this category (none on the server).\n const holdsShownCurrent = React.useSyncExternalStore(\n categoryStore.subscribe,\n () => currentValue !== '' && categoryStore.get(currentValue) === value,\n () => false,\n );\n // Children that hold the current sub-item make this the category the Nav remembers for it, so a\n // category it was shown in before it moved here is no longer marked. The entry is forgotten when\n // they stop holding it (an open category records through its mounted sub-item instead).\n React.useLayoutEffect(() => {\n if (!holdsCurrentChild) return;\n categoryStore.record(currentValue, value);\n return () => categoryStore.forget(currentValue, value);\n }, [categoryStore, holdsCurrentChild, currentValue, value]);\n const containsCurrent =\n !isOpen && (currentCategory === value || holdsShownCurrent || holdsCurrentChild);\n // Inside an arrow-key body: whether this is a closed category that holds the current page (the\n // body's first Tab stop), before paint; nothing is reported in a plain Nav.\n React.useLayoutEffect(() => {\n if (!roving) return;\n roving.reportCurrentCategory(value, containsCurrent);\n return () => roving.reportCurrentCategory(value, false);\n }, [roving, value, containsCurrent]);\n // Development only: every child of the open list is an <li> (`Nav.Category:list-child`).\n const listRef = React.useRef<HTMLUListElement>(null);\n useNavListChildCheck(listRef, 'Nav.Category', 'sub-items');\n\n let buttonLabel: React.ReactNode = label;\n let items: React.ReactNode = children;\n if (label === undefined) {\n // Deprecated 0.4 path: the text children are the label, the other children the sub-items.\n warnDeprecated(\n 'Nav.Category',\n 'text children as the label',\n 'label',\n 'Pass the category label in `label` and only the sub-items as children.',\n );\n const parts = React.Children.toArray(children);\n const isText = (part: unknown) => typeof part === 'string' || typeof part === 'number';\n buttonLabel = parts.filter(isText).join('');\n items = parts.filter((part) => !isText(part));\n }\n\n return (\n <li ref={ref} {...rest} className={cn(navCategoryClassNames.root, className)}>\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-current={containsCurrent ? true : undefined}\n data-contains-current={containsCurrent ? '' : undefined}\n data-roving-value={roving ? `wave-nav-category:${value}` : undefined}\n onClick={() => toggleCategory(value)}\n className={cn(navCategoryClassNames.button, categoryButtonClasses)}\n >\n {renderIcon(icon, navCategoryClassNames.icon)}\n <span className={cn(navCategoryClassNames.label, 'flex-1 text-start')}>{buttonLabel}</span>\n <ChevronDownIcon\n className={cn(\n navCategoryClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isOpen && 'rotate-180',\n )}\n />\n </button>\n {isOpen && (\n <NavCategoryValueContext.Provider value={value}>\n <ul\n ref={listRef}\n id={listId}\n className={cn(navCategoryClassNames.list, 'm-0 list-none p-0')}\n >\n {items}\n </ul>\n </NavCategoryValueContext.Provider>\n )}\n </li>\n );\n};\nNavCategory.displayName = 'NavCategory';\nmarkNavPart(NavCategory, 'category');\n\n// ---------------------------------------------------------------------------\n// Nav.Item / Nav.SubItem\n// ---------------------------------------------------------------------------\n\n/**\n * A top-level navigation entry: a link when `href` is given (anchor props), a button otherwise\n * (button props). Clicking selects it (`aria-current=\"page\"`); activating a disabled entry never\n * selects it (a disabled entry whose value is the current value still shows as current).\n *\n * A click that opens a link somewhere other than the current page selects nothing (the consumer's\n * `onClick` still runs, and the browser opens the link): Ctrl/Cmd/Shift/Alt-click, a mouse button\n * other than the main one, a `target` other than `_self`, or a `download` link. When the consumer's\n * `onClick` calls `preventDefault()` (client-side routing), the browser opens nothing, so the item\n * is selected whatever the keys, button or `target`.\n *\n * `actions` puts your own controls (a pin toggle, a menu button) beside the item in its row, in a\n * group named by the item; they never select it.\n *\n * Typed by overloads, resolved in order: without `href` (button props, button events), with a\n * string `href` (anchor props, anchor events), then an `href` that may be `undefined` at run time\n * ({@link NavItemDynamicProps}: events of either element).\n *\n * Also exported as `NavItem` (import the flat name from React Server Components).\n */\nfunction NavItem(props: NavItemButtonProps): React.ReactElement;\nfunction NavItem(props: NavItemAnchorProps): React.ReactElement;\nfunction NavItem(props: NavItemDynamicProps): React.ReactElement;\nfunction NavItem(props: NavItemProps | NavItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.Item');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n const roving = React.useContext(NavRovingContext);\n // Called always, rendered only while the item's actions render (D119).\n const generatedId = useId('wave-nav-item');\n return renderNavEntry(\n props as NavEntryProps,\n context,\n roving,\n itemClasses,\n {\n root: navItemClassNames.root,\n listItem: navItemClassNames.listItem,\n actions: navItemClassNames.actions,\n icon: navItemClassNames.icon,\n content: navItemClassNames.content,\n },\n true,\n generatedId,\n );\n}\nNavItem.displayName = 'NavItem';\nmarkNavPart(NavItem, 'entry');\n\n/**\n * An indented entry inside a `Nav.Category`: a link when `href` is given, a button otherwise.\n * Selected like `Nav.Item` (a click that the browser opens somewhere else selects nothing; one\n * whose default your `onClick` prevents is selected), and typed by overloads like `Nav.Item`\n * (button, link, then {@link NavSubItemDynamicProps}). Takes `actions` like `Nav.Item`.\n *\n * Also exported as `NavSubItem` (import the flat name from React Server Components).\n */\nfunction NavSubItem(props: NavSubItemButtonProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemAnchorProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemDynamicProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemProps | NavSubItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.SubItem');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n const roving = React.useContext(NavRovingContext);\n // Called always, rendered only while the sub-item's actions render (D119).\n const generatedId = useId('wave-nav-item');\n return renderNavEntry(\n props as NavEntryProps,\n context,\n roving,\n subItemClasses,\n {\n root: navSubItemClassNames.root,\n listItem: navSubItemClassNames.listItem,\n actions: navSubItemClassNames.actions,\n },\n false,\n generatedId,\n );\n}\nNavSubItem.displayName = 'NavSubItem';\nmarkNavPart(NavSubItem, 'entry');\n\n/**\n * A vertical side navigation (`<nav>` landmark, default name \"Navigation\") with items, links and\n * collapsible categories.\n *\n * - **Selection**: `value`/`defaultValue`/`onValueChange` (`onValueChange` fires only when the\n * value changes). The deprecated `selectedValue`/`defaultSelectedValue`/`onNavItemSelect` still\n * work; `onNavItemSelect` keeps firing on every activation, re-selection included. A click that\n * opens a link in another tab or window (or downloads it) selects nothing, unless the item's\n * `onClick` prevents the default (client-side routing: then nothing opens elsewhere).\n * - **Categories**: `openCategories`/`defaultOpenCategories`/`onOpenCategoriesChange`. Without\n * `defaultOpenCategories`, the categories containing the selected item (`value` or\n * `defaultValue`) start open. A closed category that contains the selected item marks its toggle\n * (`aria-current=\"true\"`, `data-contains-current`, the selected look); pass `currentCategory`\n * for sub-items your own component renders inside a closed category.\n * - **Values** are unique: among the items and sub-items, and among the categories (a duplicate\n * warns in development).\n * - **Structure**: every child of the Nav, and of a category, is a part or your own `<li>`; a\n * development warning names anything else (a `<div>`, text, the wrapper of a Tooltip around an\n * item). `Nav.SectionHeader` is a heading between groups of items (`<h3>` unless\n * `headingLevel`, which stands for the `as` of Fluent's NavSectionHeader), and `Nav.Divider` a\n * line between groups, hidden from assistive technology (Fluent's NavDivider is a separator).\n * - **App identity**: `Nav.AppItem` shows the app's name and logo at the top, as a link with\n * `href` or a button; it is never selected. `Nav.AppItemStatic` shows them as plain text.\n * - **Item actions**: `actions` on `Nav.Item` and `Nav.SubItem` (Fluent's SplitNavItem) puts your\n * own controls beside the item, in a group named by it; each is a Tab stop after the item, and\n * none selects it. They are drawn while the row is hovered or has focus, while one is pressed or\n * has its menu open, and always on touch screens and in forced colours. With actions, a selected\n * item's background and indicator are drawn on its row (`.wave-nav-item__list-item`).\n *\n * Sub-components are also exported under flat names (`NavCategory`, `NavItem`, `NavSubItem`,\n * `NavSectionHeader`, `NavDivider`, `NavAppItem`, `NavAppItemStatic`): React Server Components\n * import those, because dotted access (`Nav.Item`) needs a client file.\n */\nexport const Nav = /* @__PURE__ */ Object.assign(NavRoot, {\n Category: NavCategory,\n Item: NavItem,\n SubItem: NavSubItem,\n SectionHeader: NavSectionHeader,\n Divider: NavDivider,\n AppItem: NavAppItem,\n AppItemStatic: NavAppItemStatic,\n});\n\nexport {\n NavCategory,\n NavItem,\n NavSubItem,\n NavSectionHeader,\n NavDivider,\n NavAppItem,\n NavAppItemStatic,\n};\n"],"mappings":";;;;;;;;;;;;;;AA0PA,IAAMI,IAAc;AAQpB,SAASC,EACP,GACA,GAC2B;CAC3B,OAAOC,KAAQC,EAAmBD,CAAI,IAClCE,EAAWF,GAAM,QAAQG,EAAGC,GAAWN,CAAW,GAAG,EAAE,eAAe,GAAK,CAAC,IAC5E;AACN;AAEA,IAAMO,IAAc;CAClB,MAAMF,EACJ,gIACAG,GACAC,CACF;CACA,UAAU;CACV,MAAM;CAEN,eAAe;CACf,aAAa;AACf,GAEMC,IAAiB;CACrB,MAAML,EACJ,kIACAG,GACAC,CACF;CACA,UAAU;CACV,MAAM;CAEN,eAAe;CACf,aAAa,KAAA;AACf,GAgBME,IACJ,mFACIC,IAAkB,yBASlBC,IAAiBR,EACrB,yCACA,0FACA,kEACA,oFACA,0EACF,GAEMS,IAAwBT,EAC5B,2LAEA,+JACAG,CACF;AAYA,SAASO,EAAe,GAA+C;CACrE,IAAIC,EAAM,WAAW,KAAKA,EAAM,WAAWA,EAAM,WAAWA,EAAM,YAAYA,EAAM,QAClF,OAAO;CAET,IAAMC,IAAOD,EAAM,eACbE,IAASD,EAAK,aAAa,QAAQ;CACzC,OAAQ,CAAC,CAACC,KAAUA,EAAO,YAAY,MAAM,WAAYD,EAAK,aAAa,UAAU;AACvF;AAkBA,SAASE,EACP,GACA,GACA,GACA,GACA,GACA,GACA,GACoB;CACpB,IAAM,EACJ,UACA,SACA,cAAW,IACX,SACA,cACA,aACA,YACA,YACA,QACA,GAAGC,MACDC,GACEC,IAAaC,EAAQ,UAAUC,GAC/BC,IAASC,MAAS,KAAA,GAClBC,IAAcC,IAAS,EAAE,qBAAqBJ,EAAM,IAAI,K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ExC,AADAyB,EAAYnD,GAAS,QAAQF,EAAM,KAAK,GACxCsD,EAAkBpD,GAASF,EAAM,KAAK;CACtC,IAAMO,IAAS7B,EAAM,WAAWmD,CAAgB,GAE1ClB,IAAcnC,EAAM,eAAe;CACzC,OAAOsB,EACLE,GACAE,GACAK,GACArB,GACA;EACE,MAAMqE,EAAkB;EACxB,UAAUA,EAAkB;EAC5B,SAASA,EAAkB;EAC3B,MAAMA,EAAkB;EACxB,SAASA,EAAkB;CAC7B,GACA,IACA5C,CACF;AACF;AACA,EAAQ,cAAc,WACtBwC,EAAYC,GAAS,OAAO;AAa5B,SAASI,EAAW,GAAqE;CACvF,IAAMtD,IAAU0B,EAAc,aAAa;CAE3C,AADAyB,EAAYnD,GAAS,QAAQF,EAAM,KAAK,GACxCsD,EAAkBpD,GAASF,EAAM,KAAK;CACtC,IAAMO,IAAS7B,EAAM,WAAWmD,CAAgB,GAE1ClB,IAAcnC,EAAM,eAAe;CACzC,OAAOsB,EACLE,GACAE,GACAK,GACAlB,GACA;EACE,MAAMoE,EAAqB;EAC3B,UAAUA,EAAqB;EAC/B,SAASA,EAAqB;CAChC,GACA,IACA9C,CACF;AACF;AACA,EAAW,cAAc,cACzBwC,EAAYK,GAAY,OAAO;AAmC/B,IAAaE,IAAsB,uBAAO,OAAOC,GAAS;CACxD,UAAUhC;CACV,MAAMyB;CACN,SAASI;CACT,eAAeI;CACf,SAASC;CACT,SAASC;CACT,eAAeC;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/slot.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../lib/styles.cjs"),a=require("./Nav.context.cjs");let o=require("react");o=e.__toESM(o,1);let s=require("react/jsx-runtime");var c=({headingLevel:e=3,className:i,children:o,ref:c,...l})=>{if(a.useNavContext(`Nav.SectionHeader`),!n.slotRendersContent(o))return null;let u=`h${e}`;return(0,s.jsx)(`li`,{className:r.navSectionHeaderClassNames.listItem,children:(0,s.jsx)(u,{...l,ref:c,className:t.cn(r.navSectionHeaderClassNames.root,`m-0 px-4 pt-3 pb-1 text-caption-1 font-semibold text-muted-foreground text-start`,i),children:n.materialiseSlotContent(o)})})};c.displayName=`NavSectionHeader`;var l=({className:e,ref:n,...i})=>(a.useNavContext(`Nav.Divider`),(0,s.jsx)(`li`,{...i,ref:n,"aria-hidden":`true`,className:t.cn(r.navDividerClassNames.root,`my-1 h-0 border-t border-border forced-colors:border-[CanvasText]`,e)}));l.displayName=`NavDivider`;var u=`flex w-full items-center gap-2 px-4 py-2 text-subtitle-2 text-start text-foreground`,d=t.cn(u,`no-underline bg-transparent transition-colors motion-reduce:transition-none not-disabled:not-aria-disabled:hover:bg-subtle-hover`,i.focusRingInset,i.disabledStyles),f=`flex min-h-5 min-w-5 shrink-0 items-center justify-center`;function p(e){a.useNavContext(`Nav.AppItem`);let{icon:i,href:o,className:c,children:l,ref:u,...p}=e,m=(0,s.jsxs)(s.Fragment,{children:[i&&n.slotRendersContent(i)?n.renderSlot(i,`span`,t.cn(r.navAppItemClassNames.icon,f),{"aria-hidden":!0}):null,(0,s.jsx)(`span`,{className:t.cn(r.navAppItemClassNames.content,`flex-1 text-start`),children:l})]});if(o!==void 0)return(0,s.jsx)(`li`,{className:r.navAppItemClassNames.listItem,children:(0,s.jsx)(`a`,{...p,ref:u,href:o,className:t.cn(r.navAppItemClassNames.root,d,c),children:m})});let{rel:h,value:g,..._}=p;return(0,s.jsx)(`li`,{className:r.navAppItemClassNames.listItem,children:(0,s.jsx)(`button`,{type:`button`,..._,ref:u,className:t.cn(r.navAppItemClassNames.root,d,c),children:m})})}p.displayName=`NavAppItem`;var m=({icon:e,className:i,children:o,ref:c,...l})=>(a.useNavContext(`Nav.AppItemStatic`),(0,s.jsx)(`li`,{className:r.navAppItemStaticClassNames.listItem,children:(0,s.jsxs)(`div`,{...l,ref:c,className:t.cn(r.navAppItemStaticClassNames.root,u,`cursor-default`,i),children:[e&&n.slotRendersContent(e)?n.renderSlot(e,`span`,t.cn(r.navAppItemStaticClassNames.icon,f),{"aria-hidden":!0}):null,(0,s.jsx)(`span`,{className:t.cn(r.navAppItemStaticClassNames.content,`flex-1 text-start`),children:o})]})}));m.displayName=`NavAppItemStatic`,exports.NavAppItem=p,exports.NavAppItemStatic=m,exports.NavDivider=l,exports.NavSectionHeader=c;
2
+ //# sourceMappingURL=Nav.parts.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.parts.cjs","names":["slotRendersContent","navSectionHeaderClassNames","cn","materialiseSlotContent","navDividerClassNames","focusRingInset","disabledStyles","_Fragment","renderSlot","navAppItemClassNames","navAppItemStaticClassNames","require_runtime","require_cn","require_slot","require_classNames","require_styles","require_Nav_context","react","react_jsx_runtime","NavSectionHeader","rest","children","Heading","headingLevel","className","NavDivider","appItemLayoutClasses","appItemClasses","appIconClasses","NavAppItem","props","content","icon","href","buttonRest","NavAppItemStatic"],"sources":["../../../src/components/navigation/Nav.parts.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navAppItemClassNames,\n navAppItemStaticClassNames,\n navDividerClassNames,\n navSectionHeaderClassNames,\n} from '../../lib/classNames';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport type { HeadingLevel, Slot } from '../../lib/types';\nimport { useNavContext, type NoAnchorOnlyAttributes } from './Nav.context';\n\n/*\n * The parts of a Nav that carry no value: Nav.SectionHeader, Nav.Divider, Nav.AppItem and\n * Nav.AppItemStatic. Each renders its own list item, so the Nav's lists stay valid; none is\n * selected or registers with the Nav. Imports only the contexts (`Nav.context.ts`); `Nav.tsx`\n * attaches the parts to the compound.\n */\n\n// ---------------------------------------------------------------------------\n// Nav.SectionHeader\n// ---------------------------------------------------------------------------\n\n/** Properties for the NavSectionHeader sub-component. */\nexport interface NavSectionHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /**\n * Level of the heading element (`<h1>` … `<h6>`). Pick the level that fits the page's outline.\n * Fluent's NavSectionHeader changes its element through `as`.\n * @default 3\n */\n headingLevel?: HeadingLevel;\n /** The header text. A header whose children render nothing renders nothing at all. */\n children?: React.ReactNode;\n /** Ref to the heading element. */\n ref?: React.Ref<HTMLHeadingElement>;\n}\n\n/**\n * A heading between groups of items (`<h3>` by default, `headingLevel`), in its own list item. It\n * names nothing by itself: place it before the items it introduces. A header whose children render\n * nothing renders nothing. It may also sit in a `Nav.Category`, between its sub-items.\n *\n * Also exported as `NavSectionHeader` (import the flat name from React Server Components).\n */\nexport const NavSectionHeader = ({\n headingLevel = 3,\n className,\n children,\n ref,\n ...rest\n}: NavSectionHeaderProps) => {\n useNavContext('Nav.SectionHeader');\n // An empty heading fails axe's empty-heading rule: no content, no list item and no heading.\n if (!slotRendersContent(children)) return null;\n const Heading: `h${HeadingLevel}` = `h${headingLevel}`;\n return (\n <li className={navSectionHeaderClassNames.listItem}>\n <Heading\n {...rest}\n ref={ref}\n className={cn(\n navSectionHeaderClassNames.root,\n 'm-0 px-4 pt-3 pb-1 text-caption-1 font-semibold text-muted-foreground text-start',\n className,\n )}\n >\n {materialiseSlotContent(children)}\n </Heading>\n </li>\n );\n};\nNavSectionHeader.displayName = 'NavSectionHeader';\n\n// ---------------------------------------------------------------------------\n// Nav.Divider\n// ---------------------------------------------------------------------------\n\n/** Properties for the NavDivider sub-component. */\nexport interface NavDividerProps extends Omit<\n React.HTMLAttributes<HTMLLIElement>,\n 'children' | 'role' | 'aria-hidden'\n> {\n /** Ref to the divider's list item. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * A line between groups of items, in its own list item, hidden from assistive technology (a list\n * holds only list items; use `Nav.SectionHeader` to name a group). Fluent's NavDivider is a\n * `separator`, which a list cannot hold, so this one is decorative.\n *\n * Also exported as `NavDivider` (import the flat name from React Server Components).\n */\nexport const NavDivider = ({ className, ref, ...rest }: NavDividerProps) => {\n useNavContext('Nav.Divider');\n return (\n <li\n {...rest}\n ref={ref}\n // After the rest: a consumer's `aria-hidden={false}` would bring back an invalid list child.\n aria-hidden=\"true\"\n className={cn(\n navDividerClassNames.root,\n 'my-1 h-0 border-t border-border forced-colors:border-[CanvasText]',\n className,\n )}\n />\n );\n};\nNavDivider.displayName = 'NavDivider';\n\n// ---------------------------------------------------------------------------\n// Nav.AppItem / Nav.AppItemStatic\n// ---------------------------------------------------------------------------\n\n/** The props of Nav.AppItem that every branch shares. */\nexport interface NavAppItemOwnProps {\n /**\n * The app's logo or an Avatar, before its name. Rendered with `aria-hidden=\"true\"` in a box at\n * least 20px square that grows with its content. A falsy icon (`''`, `0`) or a list of nothing\n * renders no icon box.\n */\n icon?: Slot<'span'>;\n /** The app's name. */\n children?: React.ReactNode;\n}\n\n/**\n * Nav.AppItem rendered as a link (`href` given): anchor attributes, handlers typed on\n * `HTMLAnchorElement`.\n */\nexport interface NavAppItemAnchorProps\n extends\n NavAppItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavAppItemOwnProps> {\n /**\n * URL of the app's start page; renders an `<a>`. Required in this branch, so `href`\n * discriminates the union.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/**\n * Nav.AppItem rendered as a button (no `href`): button attributes without `value` (an app item is\n * never selected).\n */\nexport interface NavAppItemButtonProps\n extends\n NavAppItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavAppItemOwnProps | 'value'> {\n /** Button app items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** Properties for the NavAppItem sub-component: link props with `href`, button props without. */\nexport type NavAppItemProps = NavAppItemAnchorProps | NavAppItemButtonProps;\n\n/**\n * Nav.AppItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise; only the attributes both elements share, handlers of either element.\n */\nexport interface NavAppItemDynamicProps\n extends\n NavAppItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavAppItemOwnProps> {\n /** URL of the app's start page; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** Properties for the NavAppItemStatic sub-component. */\nexport interface NavAppItemStaticProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The app's logo or an Avatar (as Nav.AppItem's `icon`). */\n icon?: Slot<'span'>;\n /** The app's name. */\n children?: React.ReactNode;\n /** Ref to the `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The props of both app item branches at run time (the union narrowed by `href`). */\ntype NavAppItemRuntimeProps = NavAppItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavAppItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n/** Layout of both app items: Nav.Item's padding and gap with the subtitle type. */\nconst appItemLayoutClasses =\n 'flex w-full items-center gap-2 px-4 py-2 text-subtitle-2 text-start text-foreground';\n\nconst appItemClasses = cn(\n appItemLayoutClasses,\n 'no-underline bg-transparent transition-colors motion-reduce:transition-none not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n focusRingInset,\n disabledStyles,\n);\n\n/** The icon box: at least 20px square, so a 32px logo or a medium Avatar fits. */\nconst appIconClasses = 'flex min-h-5 min-w-5 shrink-0 items-center justify-center';\n\n/**\n * The app's name and logo at the top of the navigation: a link with `href` (the app's start page),\n * a button otherwise. It is never selected and never marked as the current page (a consumer's\n * `aria-current` passes through), has no `value` and is not registered with the Nav; a click runs\n * only your `onClick` and the browser's default. A `disabled` button or an `aria-disabled` link\n * looks unavailable; the item adds no disabled logic of its own. Fluent's AppItem picks its element\n * through `as`; here `href` does.\n *\n * Typed by overloads like `Nav.Item`, resolved in order: without `href` (button props), with a\n * string `href` (anchor props), then an `href` that may be `undefined` at run time\n * ({@link NavAppItemDynamicProps}).\n *\n * Also exported as `NavAppItem` (import the flat name from React Server Components).\n */\nexport function NavAppItem(props: NavAppItemButtonProps): React.ReactElement;\nexport function NavAppItem(props: NavAppItemAnchorProps): React.ReactElement;\nexport function NavAppItem(props: NavAppItemDynamicProps): React.ReactElement;\nexport function NavAppItem(props: NavAppItemProps | NavAppItemDynamicProps): React.ReactElement {\n useNavContext('Nav.AppItem');\n const { icon, href, className, children, ref, ...rest } = props as NavAppItemRuntimeProps;\n const content = (\n <>\n {icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(navAppItemClassNames.icon, appIconClasses), {\n 'aria-hidden': true,\n })\n : null}\n <span className={cn(navAppItemClassNames.content, 'flex-1 text-start')}>{children}</span>\n </>\n );\n\n if (href !== undefined) {\n return (\n <li className={navAppItemClassNames.listItem}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={href}\n className={cn(navAppItemClassNames.root, appItemClasses, className)}\n >\n {content}\n </a>\n </li>\n );\n }\n\n // `rel` belongs only on a link and `value` on nothing: an app item is never selected.\n const { rel, value, ...buttonRest } = rest;\n return (\n <li className={navAppItemClassNames.listItem}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n className={cn(navAppItemClassNames.root, appItemClasses, className)}\n >\n {content}\n </button>\n </li>\n );\n}\nNavAppItem.displayName = 'NavAppItem';\n\n/**\n * The app's name and logo as plain text (not a link or button): the layout of `Nav.AppItem` in a\n * `<div>`, not focusable, with no role and no hover. It does not carry Nav.AppItem's class.\n *\n * Also exported as `NavAppItemStatic` (import the flat name from React Server Components).\n */\nexport const NavAppItemStatic = ({\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavAppItemStaticProps) => {\n useNavContext('Nav.AppItemStatic');\n return (\n <li className={navAppItemStaticClassNames.listItem}>\n <div\n {...rest}\n ref={ref}\n className={cn(\n navAppItemStaticClassNames.root,\n appItemLayoutClasses,\n 'cursor-default',\n className,\n )}\n >\n {icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(navAppItemStaticClassNames.icon, appIconClasses), {\n 'aria-hidden': true,\n })\n : null}\n <span className={cn(navAppItemStaticClassNames.content, 'flex-1 text-start')}>\n {children}\n </span>\n </div>\n </li>\n );\n};\nNavAppItemStatic.displayName = 'NavAppItemStatic';\n"],"mappings":"qTA6CA,IAAamB,GAAoB,CAC/B,eAAe,EACf,YACA,WACA,MACA,GAAGC,KACwB,CAG3B,GAFAJ,EAAA,cAAc,mBAAmB,EAE7B,CAAChB,EAAAA,mBAAmBqB,CAAQ,EAAG,OAAO,KAC1C,IAAMC,EAA8B,IAAIC,IACxC,OACE,EAAAL,EAAA,IAAA,CAAC,KAAD,CAAI,UAAWjB,EAAAA,2BAA2B,SACxC,UAAA,EAAAiB,EAAA,IAAA,CAACI,EAAD,CACE,GAAIF,EACC,MACL,UAAWlB,EAAAA,GACTD,EAAAA,2BAA2B,KAC3B,mFACAuB,CACF,EAEC,SAAArB,EAAAA,uBAAuBkB,CAAQ,CACzB,CAAA,CACP,CAAA,CAER,EACA,EAAiB,YAAc,mBAsB/B,IAAaI,GAAc,CAAE,YAAW,MAAK,GAAGL,MAC9CJ,EAAA,cAAc,aAAa,GAEzB,EAAAE,EAAA,IAAA,CAAC,KAAD,CACE,GAAIE,EACC,MAEL,cAAY,OACZ,UAAWlB,EAAAA,GACTE,EAAAA,qBAAqB,KACrB,oEACAoB,CACF,CACD,CAAA,GAGL,EAAW,YAAc,aAoFzB,IAAME,EACJ,sFAEIC,EAAiBzB,EAAAA,GACrBwB,EACA,mIACArB,EAAAA,eACAC,EAAAA,cACF,EAGMsB,EAAiB,4DAmBvB,SAAgBC,EAAW,EAAqE,CAC9Fb,EAAA,cAAc,aAAa,EAC3B,GAAM,CAAE,OAA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3BgB,EACA,iBACAF,CACF,EARF,SAAA,CAUGQ,GAAQhC,EAAAA,mBAAmBgC,CAAI,EAC5BxB,EAAAA,WAAWwB,EAAM,OAAQ9B,EAAAA,GAAGQ,EAAAA,2BAA2B,KAAMkB,CAAc,EAAG,CAC5E,cAAe,EACjB,CAAC,EACD,MACJ,EAAAV,EAAA,IAAA,CAAC,OAAD,CAAM,UAAWhB,EAAAA,GAAGQ,EAAAA,2BAA2B,QAAS,mBAAmB,EACxE,UACG,CAAA,CACH,GACH,CAAA,GAGR,EAAiB,YAAc"}
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { materialiseSlotContent as t, renderSlot as n, slotRendersContent as r } from "../../lib/slot.mjs";
4
+ import { navAppItemClassNames as i, navAppItemStaticClassNames as a, navDividerClassNames as o, navSectionHeaderClassNames as s } from "../../lib/classNames.mjs";
5
+ import { disabledStyles as c, focusRingInset as l } from "../../lib/styles.mjs";
6
+ import { useNavContext as u } from "./Nav.context.mjs";
7
+ import "react";
8
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
9
+ //#region src/components/navigation/Nav.parts.tsx
10
+ var m = ({ headingLevel: n = 3, className: i, children: a, ref: o, ...c }) => {
11
+ if (u("Nav.SectionHeader"), !r(a)) return null;
12
+ let l = `h${n}`;
13
+ return /* @__PURE__ */ f("li", {
14
+ className: s.listItem,
15
+ children: /* @__PURE__ */ f(l, {
16
+ ...c,
17
+ ref: o,
18
+ className: e(s.root, "m-0 px-4 pt-3 pb-1 text-caption-1 font-semibold text-muted-foreground text-start", i),
19
+ children: t(a)
20
+ })
21
+ });
22
+ };
23
+ m.displayName = "NavSectionHeader";
24
+ var h = ({ className: t, ref: n, ...r }) => (u("Nav.Divider"), /* @__PURE__ */ f("li", {
25
+ ...r,
26
+ ref: n,
27
+ "aria-hidden": "true",
28
+ className: e(o.root, "my-1 h-0 border-t border-border forced-colors:border-[CanvasText]", t)
29
+ }));
30
+ h.displayName = "NavDivider";
31
+ var g = "flex w-full items-center gap-2 px-4 py-2 text-subtitle-2 text-start text-foreground", _ = e(g, "no-underline bg-transparent transition-colors motion-reduce:transition-none not-disabled:not-aria-disabled:hover:bg-subtle-hover", l, c), v = "flex min-h-5 min-w-5 shrink-0 items-center justify-center";
32
+ function y(t) {
33
+ u("Nav.AppItem");
34
+ let { icon: a, href: o, className: s, children: c, ref: l, ...m } = t, h = /* @__PURE__ */ p(d, { children: [a && r(a) ? n(a, "span", e(i.icon, v), { "aria-hidden": !0 }) : null, /* @__PURE__ */ f("span", {
35
+ className: e(i.content, "flex-1 text-start"),
36
+ children: c
37
+ })] });
38
+ if (o !== void 0) return /* @__PURE__ */ f("li", {
39
+ className: i.listItem,
40
+ children: /* @__PURE__ */ f("a", {
41
+ ...m,
42
+ ref: l,
43
+ href: o,
44
+ className: e(i.root, _, s),
45
+ children: h
46
+ })
47
+ });
48
+ let { rel: g, value: y, ...b } = m;
49
+ return /* @__PURE__ */ f("li", {
50
+ className: i.listItem,
51
+ children: /* @__PURE__ */ f("button", {
52
+ type: "button",
53
+ ...b,
54
+ ref: l,
55
+ className: e(i.root, _, s),
56
+ children: h
57
+ })
58
+ });
59
+ }
60
+ y.displayName = "NavAppItem";
61
+ var b = ({ icon: t, className: i, children: o, ref: s, ...c }) => (u("Nav.AppItemStatic"), /* @__PURE__ */ f("li", {
62
+ className: a.listItem,
63
+ children: /* @__PURE__ */ p("div", {
64
+ ...c,
65
+ ref: s,
66
+ className: e(a.root, g, "cursor-default", i),
67
+ children: [t && r(t) ? n(t, "span", e(a.icon, v), { "aria-hidden": !0 }) : null, /* @__PURE__ */ f("span", {
68
+ className: e(a.content, "flex-1 text-start"),
69
+ children: o
70
+ })]
71
+ })
72
+ }));
73
+ b.displayName = "NavAppItemStatic";
74
+ //#endregion
75
+ export { y as NavAppItem, b as NavAppItemStatic, h as NavDivider, m as NavSectionHeader };
76
+
77
+ //# sourceMappingURL=Nav.parts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.parts.mjs","names":["_Fragment","NavSectionHeader","rest","useNavContext","slotRendersContent","children","Heading","headingLevel","navSectionHeaderClassNames","cn","className","materialiseSlotContent","NavDivider","navDividerClassNames","appItemLayoutClasses","appItemClasses","focusRingInset","disabledStyles","appIconClasses","NavAppItem","props","content","Fragment","icon","renderSlot","navAppItemClassNames","href","buttonRest","NavAppItemStatic","navAppItemStaticClassNames"],"sources":["../../../src/components/navigation/Nav.parts.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navAppItemClassNames,\n navAppItemStaticClassNames,\n navDividerClassNames,\n navSectionHeaderClassNames,\n} from '../../lib/classNames';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport type { HeadingLevel, Slot } from '../../lib/types';\nimport { useNavContext, type NoAnchorOnlyAttributes } from './Nav.context';\n\n/*\n * The parts of a Nav that carry no value: Nav.SectionHeader, Nav.Divider, Nav.AppItem and\n * Nav.AppItemStatic. Each renders its own list item, so the Nav's lists stay valid; none is\n * selected or registers with the Nav. Imports only the contexts (`Nav.context.ts`); `Nav.tsx`\n * attaches the parts to the compound.\n */\n\n// ---------------------------------------------------------------------------\n// Nav.SectionHeader\n// ---------------------------------------------------------------------------\n\n/** Properties for the NavSectionHeader sub-component. */\nexport interface NavSectionHeaderProps extends React.HTMLAttributes<HTMLHeadingElement> {\n /**\n * Level of the heading element (`<h1>` … `<h6>`). Pick the level that fits the page's outline.\n * Fluent's NavSectionHeader changes its element through `as`.\n * @default 3\n */\n headingLevel?: HeadingLevel;\n /** The header text. A header whose children render nothing renders nothing at all. */\n children?: React.ReactNode;\n /** Ref to the heading element. */\n ref?: React.Ref<HTMLHeadingElement>;\n}\n\n/**\n * A heading between groups of items (`<h3>` by default, `headingLevel`), in its own list item. It\n * names nothing by itself: place it before the items it introduces. A header whose children render\n * nothing renders nothing. It may also sit in a `Nav.Category`, between its sub-items.\n *\n * Also exported as `NavSectionHeader` (import the flat name from React Server Components).\n */\nexport const NavSectionHeader = ({\n headingLevel = 3,\n className,\n children,\n ref,\n ...rest\n}: NavSectionHeaderProps) => {\n useNavContext('Nav.SectionHeader');\n // An empty heading fails axe's empty-heading rule: no content, no list item and no heading.\n if (!slotRendersContent(children)) return null;\n const Heading: `h${HeadingLevel}` = `h${headingLevel}`;\n return (\n <li className={navSectionHeaderClassNames.listItem}>\n <Heading\n {...rest}\n ref={ref}\n className={cn(\n navSectionHeaderClassNames.root,\n 'm-0 px-4 pt-3 pb-1 text-caption-1 font-semibold text-muted-foreground text-start',\n className,\n )}\n >\n {materialiseSlotContent(children)}\n </Heading>\n </li>\n );\n};\nNavSectionHeader.displayName = 'NavSectionHeader';\n\n// ---------------------------------------------------------------------------\n// Nav.Divider\n// ---------------------------------------------------------------------------\n\n/** Properties for the NavDivider sub-component. */\nexport interface NavDividerProps extends Omit<\n React.HTMLAttributes<HTMLLIElement>,\n 'children' | 'role' | 'aria-hidden'\n> {\n /** Ref to the divider's list item. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * A line between groups of items, in its own list item, hidden from assistive technology (a list\n * holds only list items; use `Nav.SectionHeader` to name a group). Fluent's NavDivider is a\n * `separator`, which a list cannot hold, so this one is decorative.\n *\n * Also exported as `NavDivider` (import the flat name from React Server Components).\n */\nexport const NavDivider = ({ className, ref, ...rest }: NavDividerProps) => {\n useNavContext('Nav.Divider');\n return (\n <li\n {...rest}\n ref={ref}\n // After the rest: a consumer's `aria-hidden={false}` would bring back an invalid list child.\n aria-hidden=\"true\"\n className={cn(\n navDividerClassNames.root,\n 'my-1 h-0 border-t border-border forced-colors:border-[CanvasText]',\n className,\n )}\n />\n );\n};\nNavDivider.displayName = 'NavDivider';\n\n// ---------------------------------------------------------------------------\n// Nav.AppItem / Nav.AppItemStatic\n// ---------------------------------------------------------------------------\n\n/** The props of Nav.AppItem that every branch shares. */\nexport interface NavAppItemOwnProps {\n /**\n * The app's logo or an Avatar, before its name. Rendered with `aria-hidden=\"true\"` in a box at\n * least 20px square that grows with its content. A falsy icon (`''`, `0`) or a list of nothing\n * renders no icon box.\n */\n icon?: Slot<'span'>;\n /** The app's name. */\n children?: React.ReactNode;\n}\n\n/**\n * Nav.AppItem rendered as a link (`href` given): anchor attributes, handlers typed on\n * `HTMLAnchorElement`.\n */\nexport interface NavAppItemAnchorProps\n extends\n NavAppItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavAppItemOwnProps> {\n /**\n * URL of the app's start page; renders an `<a>`. Required in this branch, so `href`\n * discriminates the union.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/**\n * Nav.AppItem rendered as a button (no `href`): button attributes without `value` (an app item is\n * never selected).\n */\nexport interface NavAppItemButtonProps\n extends\n NavAppItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavAppItemOwnProps | 'value'> {\n /** Button app items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** Properties for the NavAppItem sub-component: link props with `href`, button props without. */\nexport type NavAppItemProps = NavAppItemAnchorProps | NavAppItemButtonProps;\n\n/**\n * Nav.AppItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise; only the attributes both elements share, handlers of either element.\n */\nexport interface NavAppItemDynamicProps\n extends\n NavAppItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavAppItemOwnProps> {\n /** URL of the app's start page; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** Properties for the NavAppItemStatic sub-component. */\nexport interface NavAppItemStaticProps extends React.HTMLAttributes<HTMLDivElement> {\n /** The app's logo or an Avatar (as Nav.AppItem's `icon`). */\n icon?: Slot<'span'>;\n /** The app's name. */\n children?: React.ReactNode;\n /** Ref to the `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** The props of both app item branches at run time (the union narrowed by `href`). */\ntype NavAppItemRuntimeProps = NavAppItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavAppItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n/** Layout of both app items: Nav.Item's padding and gap with the subtitle type. */\nconst appItemLayoutClasses =\n 'flex w-full items-center gap-2 px-4 py-2 text-subtitle-2 text-start text-foreground';\n\nconst appItemClasses = cn(\n appItemLayoutClasses,\n 'no-underline bg-transparent transition-colors motion-reduce:transition-none not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n focusRingInset,\n disabledStyles,\n);\n\n/** The icon box: at least 20px square, so a 32px logo or a medium Avatar fits. */\nconst appIconClasses = 'flex min-h-5 min-w-5 shrink-0 items-center justify-center';\n\n/**\n * The app's name and logo at the top of the navigation: a link with `href` (the app's start page),\n * a button otherwise. It is never selected and never marked as the current page (a consumer's\n * `aria-current` passes through), has no `value` and is not registered with the Nav; a click runs\n * only your `onClick` and the browser's default. A `disabled` button or an `aria-disabled` link\n * looks unavailable; the item adds no disabled logic of its own. Fluent's AppItem picks its element\n * through `as`; here `href` does.\n *\n * Typed by overloads like `Nav.Item`, resolved in order: without `href` (button props), with a\n * string `href` (anchor props), then an `href` that may be `undefined` at run time\n * ({@link NavAppItemDynamicProps}).\n *\n * Also exported as `NavAppItem` (import the flat name from React Server Components).\n */\nexport function NavAppItem(props: NavAppItemButtonProps): React.ReactElement;\nexport function NavAppItem(props: NavAppItemAnchorProps): React.ReactElement;\nexport function NavAppItem(props: NavAppItemDynamicProps): React.ReactElement;\nexport function NavAppItem(props: NavAppItemProps | NavAppItemDynamicProps): React.ReactElement {\n useNavContext('Nav.AppItem');\n const { icon, href, className, children, ref, ...rest } = props as NavAppItemRuntimeProps;\n const content = (\n <>\n {icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(navAppItemClassNames.icon, appIconClasses), {\n 'aria-hidden': true,\n })\n : null}\n <span className={cn(navAppItemClassNames.content, 'flex-1 text-start')}>{children}</span>\n </>\n );\n\n if (href !== undefined) {\n return (\n <li className={navAppItemClassNames.listItem}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={href}\n className={cn(navAppItemClassNames.root, appItemClasses, className)}\n >\n {content}\n </a>\n </li>\n );\n }\n\n // `rel` belongs only on a link and `value` on nothing: an app item is never selected.\n const { rel, value, ...buttonRest } = rest;\n return (\n <li className={navAppItemClassNames.listItem}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n className={cn(navAppItemClassNames.root, appItemClasses, className)}\n >\n {content}\n </button>\n </li>\n );\n}\nNavAppItem.displayName = 'NavAppItem';\n\n/**\n * The app's name and logo as plain text (not a link or button): the layout of `Nav.AppItem` in a\n * `<div>`, not focusable, with no role and no hover. It does not carry Nav.AppItem's class.\n *\n * Also exported as `NavAppItemStatic` (import the flat name from React Server Components).\n */\nexport const NavAppItemStatic = ({\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavAppItemStaticProps) => {\n useNavContext('Nav.AppItemStatic');\n return (\n <li className={navAppItemStaticClassNames.listItem}>\n <div\n {...rest}\n ref={ref}\n className={cn(\n navAppItemStaticClassNames.root,\n appItemLayoutClasses,\n 'cursor-default',\n className,\n )}\n >\n {icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(navAppItemStaticClassNames.icon, appIconClasses), {\n 'aria-hidden': true,\n })\n : null}\n <span className={cn(navAppItemStaticClassNames.content, 'flex-1 text-start')}>\n {children}\n </span>\n </div>\n </li>\n );\n};\nNavAppItemStatic.displayName = 'NavAppItemStatic';\n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A;CACD,CAAA;CAKR,IAAM,EAAE,QAAK,UAAO,GAAGM,MAAezB;CACtC,OACE,kBAAC,MAAD;EAAI,WAAWuB,EAAqB;EAClC,UAAA,kBAAC,UAAD;GACE,MAAK;GACL,GAAKE;GACA;GACL,WAAWlB,EAAGgB,EAAqB,MAAMV,GAAgBL,CAAS;GAEjE,UAAAW;EACK,CAAA;CACN,CAAA;AAER;AACA,EAAW,cAAc;AAQzB,IAAaO,KAAoB,EAC/B,SACA,cACA,aACA,QACA,GAAG1B,SAEHC,EAAc,mBAAmB,GAE/B,kBAAC,MAAD;CAAI,WAAW0B,EAA2B;CACxC,UAAA,kBAAC,OAAD;EACE,GAAI3B;EACC;EACL,WAAWO,EACToB,EAA2B,MAC3Bf,GACA,kBACAJ,CACF;EARF,UAAA,CAUGa,KAAQnB,EAAmBmB,CAAI,IAC5BC,EAAWD,GAAM,QAAQd,EAAGoB,EAA2B,MAAMX,CAAc,GAAG,EAC5E,eAAe,GACjB,CAAC,IACD,MACJ,kBAAC,QAAD;GAAM,WAAWT,EAAGoB,EAA2B,SAAS,mBAAmB;GACxE;EACG,CAAA,CACH;;AACH,CAAA;AAGR,EAAiB,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/classNames.cjs"),i=require("../../hooks/useEventCallback.cjs"),a=require("../../hooks/useControllable.cjs"),o=require("./Nav.context.cjs");let s=require("react");s=e.__toESM(s,1);let c=require("react/jsx-runtime");function l(e,t,r){n.warnOnce(`${e}:duplicate-${t}:${r}`,t===`item`?`${e}: several items share the value "${r}". Nav.Item and Nav.SubItem values must be unique within a ${e}; every item with the current value is marked as the current page.`:`${e}: several categories share the value "${r}". Nav.Category values must be unique within a ${e}; they open and close together.`)}function u({componentName:e,value:t,defaultValue:n,onValueChange:r,onActivate:c,openCategories:u,defaultOpenCategories:d,onOpenCategoriesChange:f,currentCategory:p,children:m}){let[h,g]=a.useControllable(t,n,r),_=i.useEventCallback(c),v=s.useCallback(e=>{g(e),_(e)},[g,_]),[y]=s.useState(()=>d??o.findCategoriesContaining(m,t??n)),[b,x]=a.useControllable(u,y,e=>f?.([...e])),S=s.useCallback(e=>{x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[x]),C=s.useRef(null),w=s.useCallback((t,n)=>{let r=C.current??=new Map,i=`${t}:${n}`,a=(r.get(i)??0)+1;return r.set(i,a),a>1&&l(e,t,n),()=>{let e=(r.get(i)??1)-1;e>0?r.set(i,e):r.delete(i)}},[e]),[T]=s.useState(o.createCategoryStore);return s.useMemo(()=>({value:h,select:v,openCategories:b,toggleCategory:S,registerValue:w,currentCategory:p,categoryStore:T}),[h,v,b,S,w,p,T])}var d=({value:e,defaultValue:i,onValueChange:a,selectedValue:l,defaultSelectedValue:d,onNavItemSelect:f,openCategories:p,defaultOpenCategories:m,onOpenCategoriesChange:h,currentCategory:g,className:_,children:v,ref:y,...b})=>{let x=n.resolveDeprecatedProp(`Nav`,e,l,`selectedValue`,`value`),S=n.resolveDeprecatedProp(`Nav`,i,d,`defaultSelectedValue`,`defaultValue`)??``;f!==void 0&&n.warnDeprecated(`Nav`,`onNavItemSelect`,`onValueChange`);let C=u({componentName:`Nav`,value:x,defaultValue:S,onValueChange:a,onActivate:f,openCategories:p,defaultOpenCategories:m,onOpenCategoriesChange:h,currentCategory:g,children:v}),w=s.useRef(null);return o.useNavListChildCheck(w,`Nav`,`items`),(0,c.jsx)(o.NavContext.Provider,{value:C,children:(0,c.jsx)(`nav`,{"aria-label":`Navigation`,...b,ref:y,className:t.cn(r.navClassNames.root,`w-60 border-e border-border bg-background py-2`,_),children:(0,c.jsx)(`ul`,{ref:w,className:t.cn(r.navClassNames.list,`m-0 list-none p-0`),children:v})})})};d.displayName=`Nav`,exports.NavRoot=d,exports.useNavRootState=u;
2
+ //# sourceMappingURL=Nav.root.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.root.cjs","names":["useControllable","useEventCallback","React","findCategoriesContaining","createCategoryStore","resolveDeprecatedProp","NavContext","cn","navClassNames","require_runtime","require_cn","require_dev","require_classNames","require_useEventCallback","require_useControllable","require_Nav_context","react","react_jsx_runtime","warnDuplicateValue","componentName","kind","value","useNavRootState","controlledValue","openCategoriesProp","setValue","defaultValue","onValueChange","notifyActivate","onActivate","select","next","initialOpenCategories","defaultOpenCategories","children","openCategories","setOpenCategories","onOpenCategoriesChange","toggleCategory","previous","category","entry","valueCountsRef","registerValue","counts","key","count","remaining","categoryStore","currentCategory","NavRoot","valueProp","defaultValueProp","rest","selectedValue","defaultSelectedValue","onNavItemSelect","contextValue","listRef","className"],"sources":["../../../src/components/navigation/Nav.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { navClassNames } from '../../lib/classNames';\nimport { resolveDeprecatedProp, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport {\n NavContext,\n createCategoryStore,\n findCategoriesContaining,\n useNavListChildCheck,\n type NavContextValue,\n type NavValueKind,\n} from './Nav.context';\n\n/*\n * The Nav root, and `useNavRootState`, the one state model of Nav and NavDrawer: the selection,\n * the open categories, the duplicate-value registry and the category store. `Nav.tsx` attaches the\n * parts to `NavRoot` and re-exports `NavProps`; NavDrawer renders the state in its own panel.\n * Imports no part (the walks recognise them by their markers, `Nav.context.ts`).\n */\n\n/** Properties for the Nav component. */\nexport interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue'> {\n /** Controlled value of the selected nav item. */\n value?: string;\n /**\n * Selected nav item value for uncontrolled usage.\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new value when the selection changes (not when the current item is re-selected). */\n onValueChange?: (value: string) => void;\n /** @deprecated Use `value`. */\n selectedValue?: string;\n /** @deprecated Use `defaultValue`. */\n defaultSelectedValue?: string;\n /**\n * @deprecated Use `onValueChange`. Unlike `onValueChange`, it fires on every activation,\n * re-selecting the current item included (0.4 behaviour).\n */\n onNavItemSelect?: (value: string) => void;\n /** Controlled list of open category values. */\n openCategories?: readonly string[];\n /**\n * Categories open initially (uncontrolled). Without it, the categories that contain the\n * selected item (`value`, else `defaultValue`) start open, so the current page is visible on the\n * first render; an empty list keeps every category closed.\n */\n defaultOpenCategories?: readonly string[];\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange?: (openCategories: string[]) => void;\n /**\n * The `value` of the category that contains the current item, for sub-items Nav cannot find by\n * itself (rendered by your own component inside a closed category). Usually not needed: Nav\n * finds sub-items among a category's children (through Fragments and wrapper elements) and\n * remembers the category of the current sub-item once it has been shown. A hint, not state:\n * unlike Fluent's `selectedCategoryValue` it has no default or change callback.\n */\n currentCategory?: string;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** What useNavRootState reads: the root's props with Nav's deprecated aliases already resolved. */\nexport interface UseNavRootStateOptions {\n /** The public component: the key and text prefix of the duplicate-value warnings. */\n componentName: string;\n /** Controlled selected value (`undefined`: uncontrolled). */\n value: string | undefined;\n /** Initial selected value of an uncontrolled root (`''`: nothing selected). */\n defaultValue: string;\n /** Called with the new value when it changes (`useControllable`). */\n onValueChange: ((value: string) => void) | undefined;\n /**\n * Called on every activation, re-selection included, after the value update (Nav's deprecated\n * `onNavItemSelect`, NavDrawer's `onItemSelect`).\n */\n onActivate?: (value: string) => void;\n /** Controlled list of open category values (`undefined`: uncontrolled). */\n openCategories: readonly string[] | undefined;\n /** Categories open initially; without it, the categories that contain the selected value. */\n defaultOpenCategories: readonly string[] | undefined;\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange: ((openCategories: string[]) => void) | undefined;\n /** The value of the category that contains the current item (the root's hint). */\n currentCategory: string | undefined;\n /**\n * Scanned once, at mount, for the categories that contain the selected value (when\n * `defaultOpenCategories` is absent).\n */\n children: React.ReactNode;\n}\n\n/** Warns once per duplicated value; `componentName` is the key and text prefix. */\nfunction warnDuplicateValue(componentName: string, kind: NavValueKind, value: string): void {\n warnOnce(\n `${componentName}:duplicate-${kind}:${value}`,\n kind === 'item'\n ? `${componentName}: several items share the value \"${value}\". Nav.Item and Nav.SubItem values must be unique within a ${componentName}; every item with the current value is marked as the current page.`\n : `${componentName}: several categories share the value \"${value}\". Nav.Category values must be unique within a ${componentName}; they open and close together.`,\n );\n}\n\n/**\n * The state of a Nav root (Nav, NavDrawer). Returns the context value to provide through\n * `NavContext`, memoised: the same object while none of its fields changes.\n *\n * - The selection through `useControllable` (`onValueChange` only on a change); `select` sets the\n * value, then calls `onActivate` on every activation.\n * - The open categories through `useControllable` (a new array to `onOpenCategoriesChange`),\n * initially `defaultOpenCategories`, else the categories that contain `value ?? defaultValue`,\n * found once in `children` (through Fragments and wrapper elements; parts written in a Server\n * Component included).\n * - The duplicate-value registry (`${componentName}:duplicate-item:<value>` and\n * `…:duplicate-category:<value>`, once per value) and the category store.\n */\nexport function useNavRootState({\n componentName,\n value: controlledValue,\n defaultValue,\n onValueChange,\n onActivate,\n openCategories: openCategoriesProp,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n children,\n}: UseNavRootStateOptions): NavContextValue {\n const [value, setValue] = useControllable(controlledValue, defaultValue, onValueChange);\n const notifyActivate = useEventCallback(onActivate);\n const select = React.useCallback(\n (next: string) => {\n setValue(next);\n // Event-named callback: every activation, re-selection included (C-NAMING).\n notifyActivate(next);\n },\n [setValue, notifyActivate],\n );\n\n const [initialOpenCategories] = React.useState<readonly string[]>(\n () =>\n defaultOpenCategories ?? findCategoriesContaining(children, controlledValue ?? defaultValue),\n );\n const [openCategories, setOpenCategories] = useControllable<readonly string[]>(\n openCategoriesProp,\n initialOpenCategories,\n (next) => onOpenCategoriesChange?.([...next]),\n );\n const toggleCategory = React.useCallback(\n (category: string) => {\n setOpenCategories((previous) =>\n previous.includes(category)\n ? previous.filter((entry) => entry !== category)\n : [...previous, category],\n );\n },\n [setOpenCategories],\n );\n\n // Duplicate values (C-DEV): the mounted items and categories per value (written from their\n // effects only); a second one with a value already in use warns once per value.\n const valueCountsRef = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback(\n (kind: NavValueKind, entry: string) => {\n const counts = (valueCountsRef.current ??= new Map<string, number>());\n const key = `${kind}:${entry}`;\n const count = (counts.get(key) ?? 0) + 1;\n counts.set(key, count);\n if (count > 1) warnDuplicateValue(componentName, kind, entry);\n return () => {\n const remaining = (counts.get(key) ?? 1) - 1;\n if (remaining > 0) counts.set(key, remaining);\n else counts.delete(key);\n };\n },\n [componentName],\n );\n\n const [categoryStore] = React.useState(createCategoryStore);\n\n return React.useMemo<NavContextValue>(\n () => ({\n value,\n select,\n openCategories,\n toggleCategory,\n registerValue,\n currentCategory,\n categoryStore,\n }),\n [value, select, openCategories, toggleCategory, registerValue, currentCategory, categoryStore],\n );\n}\n\nexport const NavRoot = ({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n selectedValue,\n defaultSelectedValue,\n onNavItemSelect,\n openCategories,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n className,\n children,\n ref,\n ...rest\n}: NavProps) => {\n const controlledValue = resolveDeprecatedProp(\n 'Nav',\n valueProp,\n selectedValue,\n 'selectedValue',\n 'value',\n );\n const defaultValue =\n resolveDeprecatedProp(\n 'Nav',\n defaultValueProp,\n defaultSelectedValue,\n 'defaultSelectedValue',\n 'defaultValue',\n ) ?? '';\n if (onNavItemSelect !== undefined) warnDeprecated('Nav', 'onNavItemSelect', 'onValueChange');\n\n const contextValue = useNavRootState({\n componentName: 'Nav',\n value: controlledValue,\n defaultValue,\n onValueChange,\n onActivate: onNavItemSelect,\n openCategories,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n children,\n });\n // Development only: every child of the list is an <li> (`Nav:list-child`).\n const listRef = React.useRef<HTMLUListElement>(null);\n useNavListChildCheck(listRef, 'Nav', 'items');\n\n return (\n <NavContext.Provider value={contextValue}>\n <nav\n aria-label=\"Navigation\"\n {...rest}\n ref={ref}\n className={cn(\n navClassNames.root,\n 'w-60 border-e border-border bg-background py-2',\n className,\n )}\n >\n <ul ref={listRef} className={cn(navClassNames.list, 'm-0 list-none p-0')}>\n {children}\n </ul>\n </nav>\n </NavContext.Provider>\n );\n};\nNavRoot.displayName = 'Nav';\n"],"mappings":"6WA+FA,SAASkB,EAAmB,EAAuB,EAAoB,EAAqB,CAC1FP,EAAA,SACE,GAAGQ,EAAc,aAAaC,EAAK,GAAGC,IACtCD,IAAS,OACL,GAAGD,EAAc,mCAAmCE,EAAM,6DAA6DF,EAAc,oEACrI,GAAGA,EAAc,wCAAwCE,EAAM,iDAAiDF,EAAc,gCACpI,CACF,CAeA,SAAgBG,EAAgB,CAC9B,gBACA,MAAOC,EACP,eACA,gBACA,aACA,eAAgBC,EAChB,wBACA,yBACA,kBACA,YAC0C,CAC1C,GAAM,CAACH,EAAOI,GAAYzB,EAAAA,gBAAgBuB,EAAiBG,EAAcC,CAAa,EAChFC,EAAiB3B,EAAAA,iBAAiB4B,CAAU,EAC5CC,EAAS5B,EAAM,YAClB,GAAiB,CAChBuB,EAASM,CAAI,EAEbH,EAAeG,CAAI,CACrB,EACA,CAACN,EAAUG,CAAc,CAC3B,EAEM,CAACI,GAAyB9B,EAAM,aAElC+B,GAAyB9B,EAAAA,yBAAyB+B,EAAUX,GAAmBG,CAAY,CAC/F,EACM,CAACS,EAAgBC,GAAqBpC,EAAAA,gBAC1CwB,EACAQ,EACC,GAASK,IAAyB,CAAC,GAAGN,CAAI,CAAC,CAC9C,EACMO,EAAiBpC,EAAM,YAC1B,GAAqB,CACpBkC,EAAmB,GACjBG,EAAS,SAASC,CAAQ,EACtBD,EAAS,OAAQ,GAAUE,IAAUD,CAAQ,EAC7C,CAAC,GAAGD,EAAUC,CAAQ,CAC5B,CACF,EACA,CAACJ,CAAiB,CACpB,EAIMM,EAAiBxC,EAA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,UAAA,EAAAxC,EAAA,IAAA,CAAC,MAAD,CACE,aAAW,aACX,GAAIoC,EACC,MACL,UAAW9C,EAAAA,GACTC,EAAAA,cAAc,KACd,iDACAmD,CACF,EAEA,UAAA,EAAA1C,EAAA,IAAA,CAAC,KAAD,CAAI,IAAKyC,EAAS,UAAWnD,EAAAA,GAAGC,EAAAA,cAAc,KAAM,mBAAmB,EACpE,UACC,CAAA,CACD,CAAA,CACc,CAAA,CAEzB,EACA,EAAQ,YAAc"}
@@ -0,0 +1,78 @@
1
+ "use client";
2
+ import { cn as e } from "../../lib/cn.mjs";
3
+ import { resolveDeprecatedProp as t, warnDeprecated as n, warnOnce as r } from "../../lib/dev.mjs";
4
+ import { navClassNames as i } from "../../lib/classNames.mjs";
5
+ import { useEventCallback as a } from "../../hooks/useEventCallback.mjs";
6
+ import { useControllable as o } from "../../hooks/useControllable.mjs";
7
+ import { NavContext as s, createCategoryStore as c, findCategoriesContaining as l, useNavListChildCheck as u } from "./Nav.context.mjs";
8
+ import * as d from "react";
9
+ import { jsx as f } from "react/jsx-runtime";
10
+ //#region src/components/navigation/Nav.root.tsx
11
+ function p(e, t, n) {
12
+ r(`${e}:duplicate-${t}:${n}`, t === "item" ? `${e}: several items share the value "${n}". Nav.Item and Nav.SubItem values must be unique within a ${e}; every item with the current value is marked as the current page.` : `${e}: several categories share the value "${n}". Nav.Category values must be unique within a ${e}; they open and close together.`);
13
+ }
14
+ function m({ componentName: e, value: t, defaultValue: n, onValueChange: r, onActivate: i, openCategories: s, defaultOpenCategories: u, onOpenCategoriesChange: f, currentCategory: m, children: h }) {
15
+ let [g, _] = o(t, n, r), v = a(i), y = d.useCallback((e) => {
16
+ _(e), v(e);
17
+ }, [_, v]), [b] = d.useState(() => u ?? l(h, t ?? n)), [x, S] = o(s, b, (e) => f?.([...e])), C = d.useCallback((e) => {
18
+ S((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
19
+ }, [S]), w = d.useRef(null), T = d.useCallback((t, n) => {
20
+ let r = w.current ??= /* @__PURE__ */ new Map(), i = `${t}:${n}`, a = (r.get(i) ?? 0) + 1;
21
+ return r.set(i, a), a > 1 && p(e, t, n), () => {
22
+ let e = (r.get(i) ?? 1) - 1;
23
+ e > 0 ? r.set(i, e) : r.delete(i);
24
+ };
25
+ }, [e]), [E] = d.useState(c);
26
+ return d.useMemo(() => ({
27
+ value: g,
28
+ select: y,
29
+ openCategories: x,
30
+ toggleCategory: C,
31
+ registerValue: T,
32
+ currentCategory: m,
33
+ categoryStore: E
34
+ }), [
35
+ g,
36
+ y,
37
+ x,
38
+ C,
39
+ T,
40
+ m,
41
+ E
42
+ ]);
43
+ }
44
+ var h = ({ value: r, defaultValue: a, onValueChange: o, selectedValue: c, defaultSelectedValue: l, onNavItemSelect: p, openCategories: h, defaultOpenCategories: g, onOpenCategoriesChange: _, currentCategory: v, className: y, children: b, ref: x, ...S }) => {
45
+ let C = t("Nav", r, c, "selectedValue", "value"), w = t("Nav", a, l, "defaultSelectedValue", "defaultValue") ?? "";
46
+ p !== void 0 && n("Nav", "onNavItemSelect", "onValueChange");
47
+ let T = m({
48
+ componentName: "Nav",
49
+ value: C,
50
+ defaultValue: w,
51
+ onValueChange: o,
52
+ onActivate: p,
53
+ openCategories: h,
54
+ defaultOpenCategories: g,
55
+ onOpenCategoriesChange: _,
56
+ currentCategory: v,
57
+ children: b
58
+ }), E = d.useRef(null);
59
+ return u(E, "Nav", "items"), /* @__PURE__ */ f(s.Provider, {
60
+ value: T,
61
+ children: /* @__PURE__ */ f("nav", {
62
+ "aria-label": "Navigation",
63
+ ...S,
64
+ ref: x,
65
+ className: e(i.root, "w-60 border-e border-border bg-background py-2", y),
66
+ children: /* @__PURE__ */ f("ul", {
67
+ ref: E,
68
+ className: e(i.list, "m-0 list-none p-0"),
69
+ children: b
70
+ })
71
+ })
72
+ });
73
+ };
74
+ h.displayName = "Nav";
75
+ //#endregion
76
+ export { h as NavRoot, m as useNavRootState };
77
+
78
+ //# sourceMappingURL=Nav.root.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.root.mjs","names":["React","warnDuplicateValue","componentName","kind","value","useNavRootState","controlledValue","openCategoriesProp","setValue","useControllable","defaultValue","onValueChange","notifyActivate","useEventCallback","onActivate","select","next","initialOpenCategories","defaultOpenCategories","findCategoriesContaining","children","openCategories","setOpenCategories","onOpenCategoriesChange","toggleCategory","previous","category","entry","valueCountsRef","registerValue","counts","key","count","remaining","categoryStore","createCategoryStore","currentCategory","NavRoot","valueProp","defaultValueProp","rest","resolveDeprecatedProp","selectedValue","defaultSelectedValue","onNavItemSelect","warnDeprecated","contextValue","listRef","useNavListChildCheck","NavContext","cn","navClassNames","className"],"sources":["../../../src/components/navigation/Nav.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { navClassNames } from '../../lib/classNames';\nimport { resolveDeprecatedProp, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport {\n NavContext,\n createCategoryStore,\n findCategoriesContaining,\n useNavListChildCheck,\n type NavContextValue,\n type NavValueKind,\n} from './Nav.context';\n\n/*\n * The Nav root, and `useNavRootState`, the one state model of Nav and NavDrawer: the selection,\n * the open categories, the duplicate-value registry and the category store. `Nav.tsx` attaches the\n * parts to `NavRoot` and re-exports `NavProps`; NavDrawer renders the state in its own panel.\n * Imports no part (the walks recognise them by their markers, `Nav.context.ts`).\n */\n\n/** Properties for the Nav component. */\nexport interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue'> {\n /** Controlled value of the selected nav item. */\n value?: string;\n /**\n * Selected nav item value for uncontrolled usage.\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new value when the selection changes (not when the current item is re-selected). */\n onValueChange?: (value: string) => void;\n /** @deprecated Use `value`. */\n selectedValue?: string;\n /** @deprecated Use `defaultValue`. */\n defaultSelectedValue?: string;\n /**\n * @deprecated Use `onValueChange`. Unlike `onValueChange`, it fires on every activation,\n * re-selecting the current item included (0.4 behaviour).\n */\n onNavItemSelect?: (value: string) => void;\n /** Controlled list of open category values. */\n openCategories?: readonly string[];\n /**\n * Categories open initially (uncontrolled). Without it, the categories that contain the\n * selected item (`value`, else `defaultValue`) start open, so the current page is visible on the\n * first render; an empty list keeps every category closed.\n */\n defaultOpenCategories?: readonly string[];\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange?: (openCategories: string[]) => void;\n /**\n * The `value` of the category that contains the current item, for sub-items Nav cannot find by\n * itself (rendered by your own component inside a closed category). Usually not needed: Nav\n * finds sub-items among a category's children (through Fragments and wrapper elements) and\n * remembers the category of the current sub-item once it has been shown. A hint, not state:\n * unlike Fluent's `selectedCategoryValue` it has no default or change callback.\n */\n currentCategory?: string;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** What useNavRootState reads: the root's props with Nav's deprecated aliases already resolved. */\nexport interface UseNavRootStateOptions {\n /** The public component: the key and text prefix of the duplicate-value warnings. */\n componentName: string;\n /** Controlled selected value (`undefined`: uncontrolled). */\n value: string | undefined;\n /** Initial selected value of an uncontrolled root (`''`: nothing selected). */\n defaultValue: string;\n /** Called with the new value when it changes (`useControllable`). */\n onValueChange: ((value: string) => void) | undefined;\n /**\n * Called on every activation, re-selection included, after the value update (Nav's deprecated\n * `onNavItemSelect`, NavDrawer's `onItemSelect`).\n */\n onActivate?: (value: string) => void;\n /** Controlled list of open category values (`undefined`: uncontrolled). */\n openCategories: readonly string[] | undefined;\n /** Categories open initially; without it, the categories that contain the selected value. */\n defaultOpenCategories: readonly string[] | undefined;\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange: ((openCategories: string[]) => void) | undefined;\n /** The value of the category that contains the current item (the root's hint). */\n currentCategory: string | undefined;\n /**\n * Scanned once, at mount, for the categories that contain the selected value (when\n * `defaultOpenCategories` is absent).\n */\n children: React.ReactNode;\n}\n\n/** Warns once per duplicated value; `componentName` is the key and text prefix. */\nfunction warnDuplicateValue(componentName: string, kind: NavValueKind, value: string): void {\n warnOnce(\n `${componentName}:duplicate-${kind}:${value}`,\n kind === 'item'\n ? `${componentName}: several items share the value \"${value}\". Nav.Item and Nav.SubItem values must be unique within a ${componentName}; every item with the current value is marked as the current page.`\n : `${componentName}: several categories share the value \"${value}\". Nav.Category values must be unique within a ${componentName}; they open and close together.`,\n );\n}\n\n/**\n * The state of a Nav root (Nav, NavDrawer). Returns the context value to provide through\n * `NavContext`, memoised: the same object while none of its fields changes.\n *\n * - The selection through `useControllable` (`onValueChange` only on a change); `select` sets the\n * value, then calls `onActivate` on every activation.\n * - The open categories through `useControllable` (a new array to `onOpenCategoriesChange`),\n * initially `defaultOpenCategories`, else the categories that contain `value ?? defaultValue`,\n * found once in `children` (through Fragments and wrapper elements; parts written in a Server\n * Component included).\n * - The duplicate-value registry (`${componentName}:duplicate-item:<value>` and\n * `…:duplicate-category:<value>`, once per value) and the category store.\n */\nexport function useNavRootState({\n componentName,\n value: controlledValue,\n defaultValue,\n onValueChange,\n onActivate,\n openCategories: openCategoriesProp,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n children,\n}: UseNavRootStateOptions): NavContextValue {\n const [value, setValue] = useControllable(controlledValue, defaultValue, onValueChange);\n const notifyActivate = useEventCallback(onActivate);\n const select = React.useCallback(\n (next: string) => {\n setValue(next);\n // Event-named callback: every activation, re-selection included (C-NAMING).\n notifyActivate(next);\n },\n [setValue, notifyActivate],\n );\n\n const [initialOpenCategories] = React.useState<readonly string[]>(\n () =>\n defaultOpenCategories ?? findCategoriesContaining(children, controlledValue ?? defaultValue),\n );\n const [openCategories, setOpenCategories] = useControllable<readonly string[]>(\n openCategoriesProp,\n initialOpenCategories,\n (next) => onOpenCategoriesChange?.([...next]),\n );\n const toggleCategory = React.useCallback(\n (category: string) => {\n setOpenCategories((previous) =>\n previous.includes(category)\n ? previous.filter((entry) => entry !== category)\n : [...previous, category],\n );\n },\n [setOpenCategories],\n );\n\n // Duplicate values (C-DEV): the mounted items and categories per value (written from their\n // effects only); a second one with a value already in use warns once per value.\n const valueCountsRef = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback(\n (kind: NavValueKind, entry: string) => {\n const counts = (valueCountsRef.current ??= new Map<string, number>());\n const key = `${kind}:${entry}`;\n const count = (counts.get(key) ?? 0) + 1;\n counts.set(key, count);\n if (count > 1) warnDuplicateValue(componentName, kind, entry);\n return () => {\n const remaining = (counts.get(key) ?? 1) - 1;\n if (remaining > 0) counts.set(key, remaining);\n else counts.delete(key);\n };\n },\n [componentName],\n );\n\n const [categoryStore] = React.useState(createCategoryStore);\n\n return React.useMemo<NavContextValue>(\n () => ({\n value,\n select,\n openCategories,\n toggleCategory,\n registerValue,\n currentCategory,\n categoryStore,\n }),\n [value, select, openCategories, toggleCategory, registerValue, currentCategory, categoryStore],\n );\n}\n\nexport const NavRoot = ({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n selectedValue,\n defaultSelectedValue,\n onNavItemSelect,\n openCategories,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n className,\n children,\n ref,\n ...rest\n}: NavProps) => {\n const controlledValue = resolveDeprecatedProp(\n 'Nav',\n valueProp,\n selectedValue,\n 'selectedValue',\n 'value',\n );\n const defaultValue =\n resolveDeprecatedProp(\n 'Nav',\n defaultValueProp,\n defaultSelectedValue,\n 'defaultSelectedValue',\n 'defaultValue',\n ) ?? '';\n if (onNavItemSelect !== undefined) warnDeprecated('Nav', 'onNavItemSelect', 'onValueChange');\n\n const contextValue = useNavRootState({\n componentName: 'Nav',\n value: controlledValue,\n defaultValue,\n onValueChange,\n onActivate: onNavItemSelect,\n openCategories,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n children,\n });\n // Development only: every child of the list is an <li> (`Nav:list-child`).\n const listRef = React.useRef<HTMLUListElement>(null);\n useNavListChildCheck(listRef, 'Nav', 'items');\n\n return (\n <NavContext.Provider value={contextValue}>\n <nav\n aria-label=\"Navigation\"\n {...rest}\n ref={ref}\n className={cn(\n navClassNames.root,\n 'w-60 border-e border-border bg-background py-2',\n className,\n )}\n >\n <ul ref={listRef} className={cn(navClassNames.list, 'm-0 list-none p-0')}>\n {children}\n </ul>\n </nav>\n </NavContext.Provider>\n );\n};\nNavRoot.displayName = 'Nav';\n"],"mappings":";;;;;;;;;;AA+FA,SAASC,EAAmB,GAAuB,GAAoB,GAAqB;CAC1F,EACE,GAAGC,EAAc,aAAaC,EAAK,GAAGC,KACtCD,MAAS,SACL,GAAGD,EAAc,mCAAmCE,EAAM,6DAA6DF,EAAc,sEACrI,GAAGA,EAAc,wCAAwCE,EAAM,iDAAiDF,EAAc,gCACpI;AACF;AAeA,SAAgBG,EAAgB,EAC9B,kBACA,OAAOC,GACP,iBACA,kBACA,eACA,gBAAgBC,GAChB,0BACA,2BACA,oBACA,eAC0C;CAC1C,IAAM,CAACH,GAAOI,KAAYC,EAAgBH,GAAiBI,GAAcC,CAAa,GAChFC,IAAiBC,EAAiBC,CAAU,GAC5CC,IAASf,EAAM,aAClB,MAAiB;EAGhB,AAFAQ,EAASQ,CAAI,GAEbJ,EAAeI,CAAI;CACrB,GACA,CAACR,GAAUI,CAAc,CAC3B,GAEM,CAACK,KAAyBjB,EAAM,eAElCkB,KAAyBC,EAAyBC,GAAUd,KAAmBI,CAAY,CAC/F,GACM,CAACW,GAAgBC,KAAqBb,EAC1CF,GACAU,IACC,MAASM,IAAyB,CAAC,GAAGP,CAAI,CAAC,CAC9C,GACMQ,IAAiBxB,EAAM,aAC1B,MAAqB;EACpB,GAAmB,MACjByB,EAAS,SAASC,CAAQ,IACtBD,EAAS,QAAQ,MAAUE,MAAUD,CAAQ,IAC7C,CAAC,GAAGD,GAAUC,CAAQ,CAC5B;CACF,GACA,CAACJ,CAAiB,CACpB,GAIMM,IAAiB5B,EAAM,OAAmC,IAAI,GAC9D6B,IAAgB7B,EAAM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AA,kBAAC,MAAD;IAAI,KAAKL;IAAS,WAAWG,EAAGC,EAAc,MAAM,mBAAmB;IACpE;GACC,CAAA;EACD,CAAA;CACc,CAAA;AAEzB;AACA,EAAQ,cAAc"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/composeEventHandlers.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useId.cjs"),o=require("../../hooks/useRovingTabIndex.cjs"),s=require("../../hooks/useMergedRefs.cjs"),c=require("../button/Toolbar.navigation.cjs"),l=require("./Nav.context.cjs"),u=require("./Nav.root.cjs"),d=require("../overlays/Dialog.shared.cjs"),f=require("../overlays/Drawer.panel.cjs"),p=require("../overlays/Drawer.scroll.cjs"),m=require("./NavDrawer.context.cjs");let h=require("react");h=e.__toESM(h,1);let g=require("react/jsx-runtime");var _=`NavDrawer:unreachable`,v="NavDrawer is closed and nothing can open it: it is uncontrolled (no `open` prop), and a Hamburger inside it cannot be reached while it is closed. Control it with `open` and `onOpenChange`, and open it from a Hamburger (or any button) outside it.",y=`NavDrawer:loose-items`,b=`NavDrawer: a list item sits outside NavDrawer.Body and NavDrawer.Footer, the parts that render a list. Move Nav.Item, Nav.Category and the other Nav parts into NavDrawer.Body or NavDrawer.Footer.`;function x(e){for(let t of Array.from(e.querySelectorAll(`li`))){let e=t.parentElement?.localName;if(e!==`ul`&&e!==`ol`)return!0}return!1}var S={scrollState:`none`,registerBody:()=>()=>{}};function C(e){return h.useContext(m.NavDrawerLayoutContext)||(n.reportMissingContext(e,`NavDrawer`),S)}var w=({type:e=`overlay`,open:r,defaultOpen:o,onOpenChange:s,onItemSelect:c,position:S=`start`,size:C=`small`,separator:w=!0,modalType:T=`modal`,unmountOnClose:E=!0,finalFocusRef:D,backdrop:O,value:k,defaultValue:A,onValueChange:j,openCategories:M,defaultOpenCategories:N,onOpenCategoriesChange:P,currentCategory:F,"aria-label":I,"aria-labelledby":L,"aria-describedby":R,id:z,children:B,ref:V,...H})=>{let[U,W]=d.useModalOpenState(r,o,s),G=f.useDrawerOpen(e,U),K=u.useNavRootState({componentName:`NavDrawer`,value:k,defaultValue:A??``,onValueChange:j,onActivate:c,openCategories:M,defaultOpenCategories:N,onOpenCategoriesChange:P,currentCategory:F,children:B}),ee=T===`non-modal`?`non-modal`:`modal`,te=a.useId(`wave-nav-drawer`),q=z??te,[ne,J]=h.useState(null),Y=h.useCallback(e=>(J(t=>t??e),()=>J(t=>t===e?null:t)),[]),X=p.useScrollState(ne),re=h.useMemo(()=>({scrollState:X,registerBody:Y}),[X,Y]),ie=h.useMemo(()=>({open:G,requestOpen:W,panelId:q,type:e}),[G,W,q,e]),Z=r===void 0&&!U;h.useEffect(()=>{Z&&n.warnOnce(_,v)},[Z]);let Q=h.useRef(null);h.useEffect(()=>{if(!n.isDev||n.hasWarned(y))return;let e=Q.current;e&&x(e)&&n.warnOnce(y,b)});let $={"aria-label":I??(L===void 0?`Navigation`:void 0),"aria-labelledby":L,"aria-describedby":R},ae=e===`overlay`?$:void 0,oe=(0,g.jsx)(f.DrawerPanel,{componentName:`NavDrawer`,type:e,open:G,requestOpen:W,position:S,size:C,separator:w,modalType:ee,unmountOnClose:E,inlineAs:`div`,trigger:d.inertModalTrigger,finalFocusRef:D,rootClassName:t.cn(i.drawerClassNames.root,i.navDrawerClassNames.root),backdropClassName:t.cn(i.drawerClassNames.backdrop,i.navDrawerClassNames.backdrop),backdrop:O,id:q,...ae,...H,ref:V,children:(0,g.jsx)(`nav`,{ref:Q,...$,className:t.cn(i.navDrawerClassNames.nav,`flex min-h-0 flex-1 flex-col`),children:B})});return d.useModalTriggerSession(d.inertModalTrigger,G),(0,g.jsx)(l.NavContext.Provider,{value:K,children:(0,g.jsx)(m.NavDrawerContext.Provider,{value:ie,children:(0,g.jsx)(m.NavDrawerLayoutContext.Provider,{value:re,children:oe})})})};w.displayName=`NavDrawer`;var T=({className:e,children:n,ref:r,...a})=>{let{scrollState:o}=C(`NavDrawer.Header`);return(0,g.jsx)(`div`,{"data-scroll-state":o,...a,ref:r,className:t.cn(i.navDrawerHeaderClassNames.root,`flex shrink-0 items-center gap-2 ps-2.5 pe-2 py-2`,p.scrollSeparatorClasses.header,e),children:n})};T.displayName=`NavDrawerHeader`;var E=({focusMode:e=`tab`,className:n,onKeyDown:a,onFocus:u,children:d,ref:f,...p})=>{let{scrollState:m,registerBody:_}=C(`NavDrawer.Body`),v=h.useContext(l.NavContext),y=e===`arrow`,[b,x]=h.useState(null),S=h.useCallback((e,t)=>{x(n=>t?e:n===e?null:n)},[]),w=h.useMemo(()=>({reportCurrentCategory:S}),[S]),T=v?.value??``,E=b===null?T||null:`wave-nav-category:${b}`,{containerProps:D}=o.useRovingTabIndex({itemSelector:c.TOOLBAR_ITEM_SELECTOR,manageTabIndex:!0,tabStop:`last-focused`,orientation:`both`,loop:!0,homeEndKeys:!0,typeahead:!1,activeValue:E}),O=h.useCallback(e=>e?_(e):void 0,[_]),k=s.useMergedRefs(f,O,y?D.ref:null),A=h.useRef(null);return l.useNavListChildCheck(A,`NavDrawer.Body`,`items`),(0,g.jsx)(`div`,{"data-focus-mode":e,"data-scroll-state":m,...p,ref:k,"data-roving-container":y?``:void 0,onKeyDown:r.composeEventHandlers(a,y?D.onKeyDown:void 0),onFocus:r.composeEventHandlers(u,y?D.onFocus:void 0,{checkDefaultPrevented:!1}),className:t.cn(i.navDrawerBodyClassNames.root,`min-h-0 flex-1 overflow-y-auto py-2`,n),children:(0,g.jsx)(l.NavRovingContext.Provider,{value:y?w:null,children:(0,g.jsx)(`ul`,{ref:A,className:t.cn(i.navDrawerBodyClassNames.list,`m-0 list-none p-0`),children:d})})})};E.displayName=`NavDrawerBody`;var D=({className:e,children:n,ref:r,...a})=>{let{scrollState:o}=C(`NavDrawer.Footer`),s=h.useRef(null);return l.useNavListChildCheck(s,`NavDrawer.Footer`,`items`),(0,g.jsx)(`div`,{"data-scroll-state":o,...a,ref:r,className:t.cn(i.navDrawerFooterClassNames.root,`shrink-0 py-2`,p.scrollSeparatorClasses.footer,e),children:(0,g.jsx)(`ul`,{ref:s,className:t.cn(i.navDrawerFooterClassNames.list,`m-0 list-none p-0`),children:n})})};D.displayName=`NavDrawerFooter`;var O=Object.assign(w,{Header:T,Body:E,Footer:D});exports.NavDrawer=O,exports.NavDrawerBody=E,exports.NavDrawerFooter=D,exports.NavDrawerHeader=T;
2
+ //# sourceMappingURL=NavDrawer.cjs.map