@mortenbrudvik/waveui 0.9.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.
- package/README.md +758 -152
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +25 -30
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.navigation.cjs +2 -0
- package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
- package/dist/components/button/Toolbar.navigation.mjs +17 -0
- package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.context.cjs +2 -0
- package/dist/components/data-display/Avatar.context.cjs.map +1 -0
- package/dist/components/data-display/Avatar.context.mjs +9 -0
- package/dist/components/data-display/Avatar.context.mjs.map +1 -0
- package/dist/components/data-display/Avatar.mjs +66 -61
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/InteractionTag.cjs +2 -0
- package/dist/components/data-display/InteractionTag.cjs.map +1 -0
- package/dist/components/data-display/InteractionTag.mjs +234 -0
- package/dist/components/data-display/InteractionTag.mjs.map +1 -0
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +222 -90
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/data-display/TagGroup.cjs +2 -0
- package/dist/components/data-display/TagGroup.cjs.map +1 -0
- package/dist/components/data-display/TagGroup.context.cjs +2 -0
- package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
- package/dist/components/data-display/TagGroup.context.mjs +113 -0
- package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
- package/dist/components/data-display/TagGroup.mjs +149 -0
- package/dist/components/data-display/TagGroup.mjs.map +1 -0
- package/dist/components/data-display/tagStyles.cjs +2 -0
- package/dist/components/data-display/tagStyles.cjs.map +1 -0
- package/dist/components/data-display/tagStyles.mjs +108 -0
- package/dist/components/data-display/tagStyles.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +1 -1
- package/dist/components/feedback/Toaster.cjs.map +1 -1
- package/dist/components/feedback/Toaster.mjs +213 -181
- package/dist/components/feedback/Toaster.mjs.map +1 -1
- package/dist/components/input/Calendar.cjs +2 -0
- package/dist/components/input/Calendar.cjs.map +1 -0
- package/dist/components/input/Calendar.mjs +352 -0
- package/dist/components/input/Calendar.mjs.map +1 -0
- package/dist/components/input/Calendar.views.cjs +2 -0
- package/dist/components/input/Calendar.views.cjs.map +1 -0
- package/dist/components/input/Calendar.views.mjs +194 -0
- package/dist/components/input/Calendar.views.mjs.map +1 -0
- package/dist/components/input/ColorArea.cjs +1 -1
- package/dist/components/input/ColorArea.cjs.map +1 -1
- package/dist/components/input/ColorArea.mjs +18 -18
- package/dist/components/input/ColorArea.mjs.map +1 -1
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +7 -7
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +232 -156
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/Combobox.text.cjs +2 -0
- package/dist/components/input/Combobox.text.cjs.map +1 -0
- package/dist/components/input/Combobox.text.mjs +24 -0
- package/dist/components/input/Combobox.text.mjs.map +1 -0
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +203 -288
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +135 -109
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Listbox.cjs +2 -0
- package/dist/components/input/Listbox.cjs.map +1 -0
- package/dist/components/input/Listbox.mjs +134 -0
- package/dist/components/input/Listbox.mjs.map +1 -0
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +163 -97
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.context.cjs +2 -0
- package/dist/components/input/SwatchPicker.context.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.context.mjs +35 -0
- package/dist/components/input/SwatchPicker.context.mjs.map +1 -0
- package/dist/components/input/SwatchPicker.mjs +131 -103
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.swatches.cjs +2 -0
- package/dist/components/input/SwatchPicker.swatches.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.swatches.mjs +207 -0
- package/dist/components/input/SwatchPicker.swatches.mjs.map +1 -0
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.context.cjs +2 -0
- package/dist/components/input/TagPicker.context.cjs.map +1 -0
- package/dist/components/input/TagPicker.context.mjs +20 -0
- package/dist/components/input/TagPicker.context.mjs.map +1 -0
- package/dist/components/input/TagPicker.create.cjs +2 -0
- package/dist/components/input/TagPicker.create.cjs.map +1 -0
- package/dist/components/input/TagPicker.create.mjs +24 -0
- package/dist/components/input/TagPicker.create.mjs.map +1 -0
- package/dist/components/input/TagPicker.mjs +13 -274
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/TagPicker.option.cjs +2 -0
- package/dist/components/input/TagPicker.option.cjs.map +1 -0
- package/dist/components/input/TagPicker.option.mjs +45 -0
- package/dist/components/input/TagPicker.option.mjs.map +1 -0
- package/dist/components/input/TagPicker.overflow.cjs +2 -0
- package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
- package/dist/components/input/TagPicker.overflow.mjs +153 -0
- package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
- package/dist/components/input/TagPicker.parts.cjs +2 -0
- package/dist/components/input/TagPicker.parts.cjs.map +1 -0
- package/dist/components/input/TagPicker.parts.mjs +425 -0
- package/dist/components/input/TagPicker.parts.mjs.map +1 -0
- package/dist/components/input/TagPicker.root.cjs +2 -0
- package/dist/components/input/TagPicker.root.cjs.map +1 -0
- package/dist/components/input/TagPicker.root.mjs +416 -0
- package/dist/components/input/TagPicker.root.mjs.map +1 -0
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +77 -77
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/dateUtils.cjs +1 -1
- package/dist/components/input/dateUtils.cjs.map +1 -1
- package/dist/components/input/dateUtils.mjs +114 -96
- package/dist/components/input/dateUtils.mjs.map +1 -1
- package/dist/components/input/pickerLabels.cjs +2 -0
- package/dist/components/input/pickerLabels.cjs.map +1 -0
- package/dist/components/input/pickerLabels.mjs +16 -0
- package/dist/components/input/pickerLabels.mjs.map +1 -0
- package/dist/components/input/pickerValues.cjs +2 -0
- package/dist/components/input/pickerValues.cjs.map +1 -0
- package/dist/components/input/pickerValues.mjs +24 -0
- package/dist/components/input/pickerValues.mjs.map +1 -0
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/navigation/Hamburger.cjs +2 -0
- package/dist/components/navigation/Hamburger.cjs.map +1 -0
- package/dist/components/navigation/Hamburger.mjs +54 -0
- package/dist/components/navigation/Hamburger.mjs.map +1 -0
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.context.cjs +2 -0
- package/dist/components/navigation/Nav.context.cjs.map +1 -0
- package/dist/components/navigation/Nav.context.mjs +137 -0
- package/dist/components/navigation/Nav.context.mjs.map +1 -0
- package/dist/components/navigation/Nav.mjs +151 -258
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Nav.parts.cjs +2 -0
- package/dist/components/navigation/Nav.parts.cjs.map +1 -0
- package/dist/components/navigation/Nav.parts.mjs +77 -0
- package/dist/components/navigation/Nav.parts.mjs.map +1 -0
- package/dist/components/navigation/Nav.root.cjs +2 -0
- package/dist/components/navigation/Nav.root.cjs.map +1 -0
- package/dist/components/navigation/Nav.root.mjs +78 -0
- package/dist/components/navigation/Nav.root.mjs.map +1 -0
- package/dist/components/navigation/NavDrawer.cjs +2 -0
- package/dist/components/navigation/NavDrawer.cjs.map +1 -0
- package/dist/components/navigation/NavDrawer.context.cjs +2 -0
- package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
- package/dist/components/navigation/NavDrawer.context.mjs +11 -0
- package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
- package/dist/components/navigation/NavDrawer.mjs +179 -0
- package/dist/components/navigation/NavDrawer.mjs.map +1 -0
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +190 -125
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Dialog.shared.cjs +1 -1
- package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
- package/dist/components/overlays/Dialog.shared.mjs +157 -81
- package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +2 -0
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
- package/dist/components/overlays/Dialog.slots.mjs +129 -0
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.context.cjs +2 -0
- package/dist/components/overlays/Drawer.context.cjs.map +1 -0
- package/dist/components/overlays/Drawer.context.mjs +29 -0
- package/dist/components/overlays/Drawer.context.mjs.map +1 -0
- package/dist/components/overlays/Drawer.mjs +12 -187
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.cjs +2 -0
- package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
- package/dist/components/overlays/Drawer.panel.mjs +159 -0
- package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
- package/dist/components/overlays/Drawer.parts.cjs +2 -0
- package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
- package/dist/components/overlays/Drawer.parts.mjs +152 -0
- package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
- package/dist/components/overlays/Drawer.root.cjs +2 -0
- package/dist/components/overlays/Drawer.root.cjs.map +1 -0
- package/dist/components/overlays/Drawer.root.mjs +207 -0
- package/dist/components/overlays/Drawer.root.mjs.map +1 -0
- package/dist/components/overlays/Drawer.scroll.cjs +2 -0
- package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
- package/dist/components/overlays/Drawer.scroll.mjs +42 -0
- package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
- package/dist/components/table/useGridNavigation.cjs +1 -1
- package/dist/components/table/useGridNavigation.cjs.map +1 -1
- package/dist/components/table/useGridNavigation.mjs +67 -70
- package/dist/components/table/useGridNavigation.mjs.map +1 -1
- package/dist/hooks/useActiveDescendant.cjs +2 -0
- package/dist/hooks/useActiveDescendant.cjs.map +1 -0
- package/dist/hooks/useActiveDescendant.mjs +56 -0
- package/dist/hooks/useActiveDescendant.mjs.map +1 -0
- package/dist/hooks/useDismiss.cjs.map +1 -1
- package/dist/hooks/useDismiss.mjs.map +1 -1
- package/dist/hooks/useFocusTrap.cjs +1 -1
- package/dist/hooks/useFocusTrap.cjs.map +1 -1
- package/dist/hooks/useFocusTrap.mjs +115 -98
- package/dist/hooks/useFocusTrap.mjs.map +1 -1
- package/dist/hooks/useListbox.cjs +1 -1
- package/dist/hooks/useListbox.cjs.map +1 -1
- package/dist/hooks/useListbox.mjs +250 -210
- package/dist/hooks/useListbox.mjs.map +1 -1
- package/dist/hooks/useModalLayer.cjs +1 -1
- package/dist/hooks/useModalLayer.cjs.map +1 -1
- package/dist/hooks/useModalLayer.mjs +35 -22
- package/dist/hooks/useModalLayer.mjs.map +1 -1
- package/dist/hooks/useRestoreFocus.cjs +1 -1
- package/dist/hooks/useRestoreFocus.cjs.map +1 -1
- package/dist/hooks/useRestoreFocus.mjs +91 -78
- package/dist/hooks/useRestoreFocus.mjs.map +1 -1
- package/dist/hooks/useRovingGrid.cjs +2 -0
- package/dist/hooks/useRovingGrid.cjs.map +1 -0
- package/dist/hooks/useRovingGrid.mjs +69 -0
- package/dist/hooks/useRovingGrid.mjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +102 -78
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4391 -394
- package/dist/index.d.ts +4391 -394
- package/dist/index.mjs +115 -101
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +170 -74
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/date.cjs +2 -0
- package/dist/lib/date.cjs.map +1 -0
- package/dist/lib/date.mjs +44 -0
- package/dist/lib/date.mjs.map +1 -0
- package/dist/lib/focus.cjs +1 -1
- package/dist/lib/focus.cjs.map +1 -1
- package/dist/lib/focus.mjs +5 -2
- package/dist/lib/focus.mjs.map +1 -1
- package/dist/lib/icons.cjs +1 -1
- package/dist/lib/icons.cjs.map +1 -1
- package/dist/lib/icons.mjs +13 -6
- package/dist/lib/icons.mjs.map +1 -1
- package/dist/lib/layers.cjs +1 -1
- package/dist/lib/layers.cjs.map +1 -1
- package/dist/lib/layers.mjs +53 -47
- package/dist/lib/layers.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Accordion.mjs","names":["useId","useId$1","React","AccordionContext","AccordionItemContext","AccordionPanelSlotContext","EMPTY","INERT_ACCORDION","INERT_ITEM","IN_PANEL","AccordionHeadingOutsideContext","HEADING_CLASS","useAccordionContext","reportMissingContext","component","useAccordionItemContext","warnDuplicateValue","value","toItems","AccordionRoot","openItemsProp","rest","props","multiple","type","warnDeprecated","defaultOpenItems","onOpenItemsChange","controlledSingle","openItem","controlled","initialItems","defaultOpenItem","openItems","setOpenItems","useControllable","list","next","onOpenItemChange","openCount","warnOnce","toggle","prev","v","itemCountsRef","registerItem","counts","count","remaining","baseId","context","headingLevel","cn","accordionClassNames","className","findPart","node","child","found","part","barrier","getElementType","AccordionItem","idOf","id","element","wrapsTriggerOnly","AccordionTrigger","AccordionPanel","misplacedMessage","headingLevelProp","accordion","isOpen","toggleValue","Heading","triggerElement","panelElement","parts","extra","flattenChildren","children","keyed","key","trigger","panel","accordionTriggerClassNames","hasTrigger","hasPanel","triggerIdProp","panelIdProp","hasPanelContent","extraPanelContent","itemContext","getPartId","panelSlot","accordionItemClassNames","idProp","item","inPanel","headingOutside","state","button","disabledStyles","focusRingInset","composeEventHandlers","onClick","ChevronDownIcon","slot","accordionPanelClassNames","Accordion"],"sources":["../../../src/components/layout/Accordion.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n accordionClassNames,\n accordionItemClassNames,\n accordionPanelClassNames,\n accordionTriggerClassNames,\n} from '../../lib/classNames';\nimport { flattenChildren, getElementType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { reportMissingContext, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { getPartId } from './disclosureIds';\n\n/** Heading level of the element that wraps each Accordion trigger. */\nexport type AccordionHeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/* ------------------------------------------------------------------ */\n/* Contexts */\n/* ------------------------------------------------------------------ */\n\ninterface AccordionContextValue {\n openItems: readonly string[];\n toggle: (value: string) => void;\n /** Counts a mounted Item's value (warns when several Items share it); returns the unregister. */\n registerItem: (value: string) => () => void;\n baseId: string;\n headingLevel: AccordionHeadingLevel;\n}\n\ninterface AccordionItemContextValue {\n value: string;\n isOpen: boolean;\n /** Id of the trigger button: the consumer `id` of the Item's Trigger, else a generated one. */\n triggerId: string;\n /** Id of the panel region: the consumer `id` of the Item's Panel, else a generated one. */\n panelId: string;\n /** Whether the Item renders a panel region while open (a Panel, or other content). */\n hasPanelContent: boolean;\n headingLevel: AccordionHeadingLevel;\n toggle: () => void;\n}\n\n/**\n * What an Accordion.Panel renders after its own children. Kept out of the item context, so a new\n * `extra` (a new array on every Item render) re-renders only the Panel.\n */\ninterface AccordionPanelSlotValue {\n /** Children of the Item that are neither Trigger nor Panel: rendered after the Panel content. */\n extra: React.ReactNode;\n /** `true` inside a Panel's content, where a Trigger or Panel is misplaced. */\n inPanel: boolean;\n}\n\nconst AccordionContext = React.createContext<AccordionContextValue | null>(null);\nconst AccordionItemContext = React.createContext<AccordionItemContextValue | null>(null);\nconst AccordionPanelSlotContext = React.createContext<AccordionPanelSlotValue | null>(null);\n\nconst EMPTY: readonly string[] = [];\n\nconst INERT_ACCORDION: AccordionContextValue = {\n openItems: EMPTY,\n toggle: () => {},\n registerItem: () => () => {},\n baseId: 'wave-accordion-inert',\n headingLevel: 3,\n};\n\nconst INERT_ITEM: AccordionItemContextValue = {\n value: '',\n isOpen: false,\n triggerId: 'wave-accordion-inert-trigger',\n panelId: 'wave-accordion-inert-panel',\n hasPanelContent: false,\n headingLevel: 3,\n toggle: () => {},\n};\n\nconst IN_PANEL: AccordionPanelSlotValue = { extra: null, inPanel: true };\n\n/**\n * `true` inside a wrapper component chain that holds only the item's Trigger (a Tooltip): the Item\n * renders the heading around the wrapper, so the Trigger renders its button without one.\n */\nconst AccordionHeadingOutsideContext = React.createContext(false);\n\n/**\n * Classes of the heading around each trigger button. `grid` stretches its child to the full row,\n * so a wrapper between the heading and the button (a Tooltip's inline-block `<span>`) does not\n * shrink the full-width button and move its chevron away from the row end.\n */\nconst HEADING_CLASS = 'm-0 grid';\n\n/**\n * C-CONTEXT: throws in development; in production logs once (`reportMissingContext`) and returns\n * the inert value.\n */\nfunction useAccordionContext(component: string): AccordionContextValue {\n const context = React.useContext(AccordionContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion>');\n return INERT_ACCORDION;\n}\n\nfunction useAccordionItemContext(component: string): AccordionItemContextValue {\n const context = React.useContext(AccordionItemContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion.Item>');\n return INERT_ITEM;\n}\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Accordion:duplicate:${value}`,\n `Accordion: several items share the value \"${value}\". Item values must be unique within an ` +\n 'Accordion; items with the same value open and close together and share their trigger and ' +\n 'panel ids.',\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Accordion */\n/* ------------------------------------------------------------------ */\n\n/** Props shared by {@link AccordionSingleProps} and {@link AccordionMultipleProps}. */\nexport interface AccordionBaseProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Level of the heading element (`<h1>`–`<h6>`) that wraps every trigger button (WAI-ARIA\n * Accordion pattern). Each `Accordion.Item` can override it.\n * @default 3\n */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Props of an Accordion in which at most one item is open (the default). */\nexport interface AccordionSingleProps extends AccordionBaseProps {\n /**\n * Whether only one or multiple items can be open at a time.\n * @default 'single'\n */\n type?: Extract<SelectionMode, 'single'>;\n /** Controlled open item (`null`: every item closed). */\n openItem?: string | null;\n /** Initially open item for uncontrolled usage. */\n defaultOpenItem?: string | null;\n /** Called with the new open item (`null` when it closed) when it changes. */\n onOpenItemChange?: (openItem: string | null) => void;\n /** @deprecated Use `openItem` (single mode); `openItems` belongs to `type=\"multiple\"`. */\n openItems?: readonly string[];\n /**\n * @deprecated Use `defaultOpenItem` (single mode); `defaultOpenItems` belongs to\n * `type=\"multiple\"`.\n */\n defaultOpenItems?: readonly string[];\n /**\n * @deprecated Use `onOpenItemChange` (single mode); `onOpenItemsChange` belongs to\n * `type=\"multiple\"`.\n */\n onOpenItemsChange?: (openItems: string[]) => void;\n}\n\n/** Props of an Accordion in which any number of items can be open. */\nexport interface AccordionMultipleProps extends AccordionBaseProps {\n /** Whether only one or multiple items can be open at a time. */\n type: Extract<SelectionMode, 'multiple'>;\n /** Controlled array of open item values (a readonly array is accepted). */\n openItems?: readonly string[];\n /**\n * Initially open items for uncontrolled usage.\n * @default []\n */\n defaultOpenItems?: readonly string[];\n /** Called with the new open items (a new array) when they change. */\n onOpenItemsChange?: (openItems: string[]) => void;\n openItem?: never;\n defaultOpenItem?: never;\n onOpenItemChange?: never;\n}\n\n/**\n * Properties for the Accordion component: a discriminated union on `type`. Single mode\n * (default) uses `openItem`/`defaultOpenItem`/`onOpenItemChange`; `type=\"multiple\"` uses\n * `openItems`/`defaultOpenItems`/`onOpenItemsChange`.\n *\n * A union cannot be extended by an `interface` (TS2312), which 0.4's interface allowed: extend\n * `AccordionSingleProps` or `AccordionMultipleProps` instead\n * (`interface MyProps extends AccordionSingleProps {}`), or intersect the union\n * (`type MyProps = AccordionProps & { … }`).\n */\nexport type AccordionProps = AccordionSingleProps | AccordionMultipleProps;\n\nfunction toItems(value: string | null | undefined): readonly string[] | undefined {\n if (value === undefined) return undefined;\n return value === null ? EMPTY : [value];\n}\n\n// The Accordion root, documented on the exported `Accordion` const.\nconst AccordionRoot = (props: AccordionProps) => {\n const {\n type,\n openItem,\n defaultOpenItem,\n onOpenItemChange,\n openItems: openItemsProp,\n defaultOpenItems,\n onOpenItemsChange,\n headingLevel = 3,\n className,\n children,\n ref,\n ...rest\n } = props as Omit<AccordionSingleProps, 'type'> & { type?: SelectionMode };\n const multiple = type === 'multiple';\n\n if (!multiple) {\n if (openItemsProp !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'openItems',\n 'openItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (defaultOpenItems !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'defaultOpenItems',\n 'defaultOpenItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (onOpenItemsChange !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'onOpenItemsChange',\n 'onOpenItemChange',\n 'In single mode the Accordion reports one value.',\n );\n }\n }\n\n const controlledSingle = multiple ? undefined : openItem;\n const controlled = React.useMemo(\n () => toItems(controlledSingle) ?? openItemsProp,\n [controlledSingle, openItemsProp],\n );\n const [initialItems] = React.useState(\n () => (multiple ? undefined : toItems(defaultOpenItem)) ?? defaultOpenItems ?? EMPTY,\n );\n\n const handleChange = (next: readonly string[]) => {\n const list = [...next];\n if (!multiple) onOpenItemChange?.(list[0] ?? null);\n onOpenItemsChange?.(list);\n };\n\n const [openItems, setOpenItems] = useControllable<readonly string[]>(\n controlled,\n initialItems,\n handleChange,\n );\n\n const openCount = openItems.length;\n React.useEffect(() => {\n if (!multiple && openCount > 1) {\n warnOnce(\n 'Accordion:single-multiple-open',\n `Accordion: type=\"single\" allows one open item, but ${openCount} are open. Pass \\`openItem\\`, or use type=\"multiple\".`,\n );\n }\n }, [multiple, openCount]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setOpenItems((prev) => {\n if (prev.includes(value)) return prev.filter((v) => v !== value);\n return multiple ? [...prev, value] : [value];\n });\n },\n [multiple, setOpenItems],\n );\n\n // How many mounted Items hold each value, to warn about a repeated value (C-DEV). Only the Items'\n // effects touch it (through `registerItem`), never render.\n const itemCountsRef = React.useRef<Map<string, number>>(null);\n const registerItem = React.useCallback((value: string) => {\n itemCountsRef.current ??= new Map();\n const counts = itemCountsRef.current;\n const count = (counts.get(value) ?? 0) + 1;\n counts.set(value, count);\n if (count > 1) warnDuplicateValue(value);\n return () => {\n const remaining = (counts.get(value) ?? 1) - 1;\n if (remaining > 0) counts.set(value, remaining);\n else counts.delete(value);\n };\n }, []);\n\n const baseId = useId('accordion');\n const context = React.useMemo<AccordionContextValue>(\n () => ({ openItems, toggle, registerItem, baseId, headingLevel }),\n [openItems, toggle, registerItem, baseId, headingLevel],\n );\n\n return (\n <AccordionContext.Provider value={context}>\n {/* A nested Accordion's direct children are not inside the outer Item. */}\n <AccordionItemContext.Provider value={null}>\n <AccordionPanelSlotContext.Provider value={null}>\n <AccordionHeadingOutsideContext.Provider value={false}>\n <div\n ref={ref}\n className={cn(accordionClassNames.root, 'divide-y divide-border', className)}\n {...rest}\n >\n {children}\n </div>\n </AccordionHeadingOutsideContext.Provider>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n </AccordionContext.Provider>\n );\n};\nAccordionRoot.displayName = 'Accordion';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionItem sub-component. */\nexport interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this accordion item. */\n value: string;\n /** Heading level of this item's trigger; overrides the Accordion's `headingLevel`. */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the item `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface PartProps {\n id?: unknown;\n children?: unknown;\n}\n\n/**\n * The first `part` element in `node`: the node itself, or an element found through Fragments\n * and the `children` of wrapper elements (a Tooltip around a Trigger). The search does not enter\n * `barrier` elements or a nested Accordion/Item, and cannot see what a component renders itself.\n * Parts are identified by their unwrapped element type, so parts written in a Server Component\n * (lazy client references) are found too. A `React.lazy` still loading (content inside the\n * consumer's own `<Suspense>`) is no part and never suspends the Item: its children are searched.\n */\nfunction findPart(\n node: unknown,\n part: React.ElementType,\n barrier: React.ElementType,\n): React.ReactElement<PartProps> | undefined {\n if (Array.isArray(node)) {\n for (const child of node) {\n const found = findPart(child, part, barrier);\n if (found) return found;\n }\n return undefined;\n }\n if (!React.isValidElement<PartProps>(node)) return undefined;\n const type = getElementType(node, { suspend: false });\n if (type === part) return node;\n if (type === barrier || type === AccordionRoot || type === AccordionItem) return undefined;\n return findPart(node.props.children, part, barrier);\n}\n\n/**\n * The consumer `id` of a Trigger or Panel element, if it has one. An empty `id` counts as none,\n * here and where the Trigger and Panel render their id (`idProp || generated`).\n */\nfunction idOf(element: React.ReactElement<PartProps> | undefined): string | undefined {\n const id = element?.props.id;\n return typeof id === 'string' && id !== '' ? id : undefined;\n}\n\n/**\n * Whether `node` is a chain of wrapper components, each with the next as its only child, that ends\n * at an Accordion.Trigger: a Tooltip around the Trigger. The Item puts the heading around such a\n * chain instead of inside it, so no heading ends up in a wrapper's phrasing `<span>`. Elements\n * (`<div>`, `<span>`) render as written: the heading stays inside them.\n */\nfunction wrapsTriggerOnly(node: unknown): boolean {\n if (!React.isValidElement<PartProps>(node)) return false;\n const type = getElementType(node, { suspend: false });\n if (\n typeof type === 'string' ||\n type === AccordionTrigger ||\n type === AccordionPanel ||\n type === AccordionRoot ||\n type === AccordionItem\n ) {\n return false;\n }\n const child = node.props.children as React.ReactNode;\n return getElementType(child, { suspend: false }) === AccordionTrigger || wrapsTriggerOnly(child);\n}\n\nfunction misplacedMessage(component: 'Accordion.Trigger' | 'Accordion.Panel'): string {\n return (\n `${component} was rendered inside the panel of an Accordion.Item, so it is not the item's ` +\n `${component === 'Accordion.Trigger' ? 'header' : 'panel'}. Place Accordion.Trigger and ` +\n 'Accordion.Panel directly in Accordion.Item, in a Fragment, or in an element that wraps them ' +\n 'as `children` (such as a Tooltip). The Item cannot see inside a component that renders them ' +\n 'itself and treats that component as panel content.'\n );\n}\n\n/**\n * One section of an Accordion. Place an `Accordion.Trigger` and an `Accordion.Panel` inside it:\n * directly, in a Fragment, or in an element that wraps them as `children` (for example a Tooltip\n * around the Trigger). A component that renders a Trigger or Panel itself is not seen through: it\n * counts as panel content, and a development warning says so.\n *\n * The trigger button sits in a heading (`headingLevel`). A wrapper component whose only child is\n * the Trigger (a Tooltip, also several nested) goes inside that heading, around the button, so\n * the heading never ends up in the wrapper's inline `<span>` and the button keeps the full row.\n * An element such as a `<div>`, or a wrapper that holds more than the Trigger, renders as written,\n * with the heading inside it.\n *\n * Without a Trigger the item's `value` is the button label. Other children (plain text included)\n * are rendered in the panel, after the Panel's own content.\n */\nconst AccordionItem = ({\n value,\n headingLevel: headingLevelProp,\n className,\n children,\n ref,\n ...rest\n}: AccordionItemProps) => {\n const accordion = useAccordionContext('Accordion.Item');\n const isOpen = accordion.openItems.includes(value);\n const { toggle: toggleValue, baseId, registerItem } = accordion;\n React.useEffect(() => registerItem(value), [registerItem, value]);\n const headingLevel = headingLevelProp ?? accordion.headingLevel;\n const Heading: `h${AccordionHeadingLevel}` = `h${headingLevel}`;\n\n let triggerElement: React.ReactElement<PartProps> | undefined;\n let panelElement: React.ReactElement<PartProps> | undefined;\n const parts: React.ReactNode[] = [];\n const extra: React.ReactNode[] = [];\n for (const { key, node: child } of flattenChildren(children)) {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n const trigger = findPart(child, AccordionTrigger, AccordionPanel);\n const panel = findPart(child, AccordionPanel, AccordionTrigger);\n if (trigger || panel) {\n triggerElement ??= trigger;\n panelElement ??= panel;\n parts.push(\n wrapsTriggerOnly(child) ? (\n <Heading key={key} className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>\n <AccordionHeadingOutsideContext.Provider value={true}>\n {child}\n </AccordionHeadingOutsideContext.Provider>\n </Heading>\n ) : (\n keyed\n ),\n );\n } else {\n extra.push(keyed);\n }\n }\n const hasTrigger = triggerElement !== undefined;\n const hasPanel = panelElement !== undefined;\n const triggerIdProp = idOf(triggerElement);\n const panelIdProp = idOf(panelElement);\n const hasPanelContent = hasPanel || extra.length > 0;\n const extraPanelContent = hasPanel && extra.length > 0 ? extra : null;\n\n const itemContext = React.useMemo<AccordionItemContextValue>(\n () => ({\n value,\n isOpen,\n triggerId: triggerIdProp ?? getPartId(baseId, 'trigger', value),\n panelId: panelIdProp ?? getPartId(baseId, 'panel', value),\n hasPanelContent,\n headingLevel,\n toggle: () => toggleValue(value),\n }),\n [value, isOpen, baseId, triggerIdProp, panelIdProp, hasPanelContent, headingLevel, toggleValue],\n );\n const panelSlot = React.useMemo<AccordionPanelSlotValue>(\n () => ({ extra: extraPanelContent, inPanel: false }),\n [extraPanelContent],\n );\n\n return (\n <AccordionItemContext.Provider value={itemContext}>\n <AccordionPanelSlotContext.Provider value={panelSlot}>\n <div\n ref={ref}\n data-state={isOpen ? 'open' : 'closed'}\n className={cn(accordionItemClassNames.root, className)}\n {...rest}\n >\n {hasTrigger ? null : <AccordionTrigger>{value}</AccordionTrigger>}\n {parts}\n {!hasPanel && extra.length > 0 ? <AccordionPanel>{extra}</AccordionPanel> : null}\n </div>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n );\n};\nAccordionItem.displayName = 'AccordionItem';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Trigger */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionTrigger sub-component (merged onto the trigger `<button>`). */\nexport interface AccordionTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Ref to the trigger `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * The button that opens and closes its Accordion.Item, wrapped in a heading (`headingLevel`); when\n * it is the only child of a wrapper component in the Item (a Tooltip), the heading goes around\n * that wrapper instead (see `Accordion.Item`). Its props land on the `<button>`: `className` is\n * merged (yours wins), `onClick` runs before the toggle (call `event.preventDefault()` to keep the\n * item as it is), `ref` receives the button, and a non-empty `id` replaces the generated one (the\n * panel's `aria-labelledby` follows it).\n */\nconst AccordionTrigger = ({\n id: idProp,\n className,\n children,\n onClick,\n ref,\n ...rest\n}: AccordionTriggerProps) => {\n const item = useAccordionItemContext('Accordion.Trigger');\n const inPanel = React.useContext(AccordionPanelSlotContext)?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) {\n warnOnce('Accordion.Trigger:inside-panel', misplacedMessage('Accordion.Trigger'));\n }\n }, [inPanel]);\n const headingOutside = React.useContext(AccordionHeadingOutsideContext);\n const Heading: `h${AccordionHeadingLevel}` = `h${item.headingLevel}`;\n const state = item.isOpen ? 'open' : 'closed';\n\n const button = (\n <button\n type=\"button\"\n className={cn(\n accordionTriggerClassNames.root,\n 'flex w-full items-center justify-between gap-2 px-4 py-3 text-start text-body-1 font-semibold text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n disabledStyles,\n focusRingInset,\n className,\n )}\n {...rest}\n // A misplaced Trigger (inside the panel) still toggles, but only the item's own trigger\n // carries the item's id and panel reference.\n id={idProp || (inPanel ? undefined : item.triggerId)}\n // Only a panel region the item renders is referenced (none without panel content).\n aria-controls={!inPanel && item.hasPanelContent ? item.panelId : undefined}\n aria-expanded={item.isOpen}\n data-state={state}\n onClick={composeEventHandlers(onClick, item.toggle)}\n ref={ref}\n >\n {children}\n <ChevronDownIcon\n size={16}\n className={cn(\n accordionTriggerClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n item.isOpen && 'rotate-180',\n )}\n />\n </button>\n );\n // Inside a wrapper chain (a Tooltip) the Item has rendered the heading around the wrapper.\n return headingOutside ? (\n button\n ) : (\n <Heading className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>{button}</Heading>\n );\n};\nAccordionTrigger.displayName = 'AccordionTrigger';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Panel */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionPanel sub-component (merged onto the `role=\"region\"` element). */\nexport interface AccordionPanelProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the panel `<div role=\"region\">`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * The content region of an Accordion.Item, rendered only while the item is open and labelled by\n * its trigger. Its props (className merged, `ref`, `data-*`, handlers) land on the region, and a\n * non-empty `id` replaces the generated one (the trigger's `aria-controls` follows it).\n */\nconst AccordionPanel = ({ id: idProp, className, children, ref, ...rest }: AccordionPanelProps) => {\n const item = useAccordionItemContext('Accordion.Panel');\n const slot = React.useContext(AccordionPanelSlotContext);\n const inPanel = slot?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) warnOnce('Accordion.Panel:inside-panel', misplacedMessage('Accordion.Panel'));\n }, [inPanel]);\n if (!item.isOpen) return null;\n if (inPanel) {\n // Misplaced: its content joins the enclosing region (one region and one panel id per item).\n return (\n <div\n className={cn(accordionPanelClassNames.root, className)}\n {...rest}\n id={idProp || undefined}\n ref={ref}\n >\n {children}\n </div>\n );\n }\n return (\n <AccordionPanelSlotContext.Provider value={IN_PANEL}>\n <div\n role=\"region\"\n className={cn(\n accordionPanelClassNames.root,\n 'px-4 pb-3 text-body-1 text-muted-foreground',\n className,\n )}\n {...rest}\n id={idProp || item.panelId}\n aria-labelledby={item.triggerId}\n data-state=\"open\"\n ref={ref}\n >\n {children}\n {slot?.extra}\n </div>\n </AccordionPanelSlotContext.Provider>\n );\n};\nAccordionPanel.displayName = 'AccordionPanel';\n\n/* ------------------------------------------------------------------ */\n/* Export */\n/* ------------------------------------------------------------------ */\n\n/**\n * A vertically stacked set of disclosure sections (WAI-ARIA Accordion pattern). Each\n * `Accordion.Item` renders an `Accordion.Trigger` button inside a heading (`headingLevel`) and an\n * `Accordion.Panel` region that is shown while the item is open.\n *\n * Single mode (the default) keeps at most one item open (`openItem`, `defaultOpenItem`,\n * `onOpenItemChange`); `type=\"multiple\"` lets any number of items open (`openItems`,\n * `defaultOpenItems`, `onOpenItemsChange`). Each Item's `value` must be unique within its\n * Accordion: a development warning names a repeated value.\n *\n * Sub-components are also exported under flat names (`AccordionItem`, `AccordionTrigger`,\n * `AccordionPanel`) for React Server Components, which cannot use the dotted form.\n */\nexport const Accordion = /* @__PURE__ */ Object.assign(AccordionRoot, {\n Item: AccordionItem,\n Trigger: AccordionTrigger,\n Panel: AccordionPanel,\n});\n\nexport { AccordionItem, AccordionTrigger, AccordionPanel };\n"],"mappings":";;;;;;;;;;;;;;AA0DA,IAAMG,IAAmBD,EAAM,cAA4C,IAAI,GACzEE,IAAuBF,EAAM,cAAgD,IAAI,GACjFG,IAA4BH,EAAM,cAA8C,IAAI,GAEpFI,IAA2B,CAAC,GAE5BC,IAAyC;CAC7C,WAAWD;CACX,cAAc,CAAC;CACf,0BAA0B,CAAC;CAC3B,QAAQ;CACR,cAAc;AAChB,GAEME,IAAwC;CAC5C,OAAO;CACP,QAAQ;CACR,WAAW;CACX,SAAS;CACT,iBAAiB;CACjB,cAAc;CACd,cAAc,CAAC;AACjB,GAEMC,IAAoC;CAAE,OAAO;CAAM,SAAS;AAAK,GAMjEC,IAAiCR,EAAM,cAAc,EAAK,GAO1DS,IAAgB;AAMtB,SAASC,EAAoB,GAA0C;CAIrE,OAHgBV,EAAM,WAAWC,CAC7B,MACJU,EAAqBC,GAAW,aAAa,GACtCP;AACT;AAEA,SAASQ,EAAwB,GAA8C;CAI7E,OAHgBb,EAAM,WAAWE,CAC7B,MACJS,EAAqBC,GAAW,kBAAkB,GAC3CN;AACT;AAEA,SAASQ,EAAmB,GAAqB;CAC/C,EACE,uBAAuBC,KACvB,6CAA6CA,EAAM,4IAGrD;AACF;AA2EA,SAASC,EAAQ,GAAiE;CAChF,IAAID,MAAU,KAAA,GACd,OAAOA,MAAU,OAAOX,IAAQ,CAACW,CAAK;AACxC;AAGA,IAAME,KAAiB,MAA0B;CAC/C,IAAM,EACJ,SACA,aACA,oBACA,qBACA,WAAWC,GACX,qBACA,sBACA,kBAAe,GACf,cACA,aACA,QACA,GAAGC,MACDC,GACEC,IAAWC,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C,IAGA,kBAAC,OAAD;EACE,WAAW9C,EAAGwD,EAAyB,MAAMtD,CAAS;EACtD,GAAIjC;EACJ,IAAI2E,KAAU,KAAA;EACT;EAEJ;CACE,CAAA,IAIP,kBAAC3F,EAA0B,UAA3B;EAAoC,OAAOI;EACzC,UAAA,kBAAC,OAAD;GACE,MAAK;GACL,WAAW2C,EACTwD,EAAyB,MACzB,+CACAtD,CACF;GACA,GAAIjC;GACJ,IAAI2E,KAAUC,EAAK;GACnB,mBAAiBA,EAAK;GACtB,cAAW;GACN;GAXP,UAAA,CAaGjB,GACA2B,GAAM,KACJ;;CAC6B,CAAA,IAhCb;AAkC3B;AACA,EAAe,cAAc;AAmB7B,IAAaE,IAA4B,uBAAO,OAAO1F,GAAe;CACpE,MAAM2C;CACN,SAASK;CACT,OAAOC;AACT,CAAC"}
|
|
1
|
+
{"version":3,"file":"Accordion.mjs","names":["useId","useId$1","React","AccordionContext","AccordionItemContext","AccordionPanelSlotContext","EMPTY","INERT_ACCORDION","INERT_ITEM","IN_PANEL","AccordionHeadingOutsideContext","HEADING_CLASS","useAccordionContext","reportMissingContext","component","useAccordionItemContext","warnDuplicateValue","value","toItems","AccordionRoot","openItemsProp","rest","props","multiple","type","warnDeprecated","defaultOpenItems","onOpenItemsChange","controlledSingle","openItem","controlled","initialItems","defaultOpenItem","openItems","setOpenItems","useControllable","list","next","onOpenItemChange","openCount","warnOnce","toggle","prev","v","itemCountsRef","registerItem","counts","count","remaining","baseId","context","headingLevel","cn","accordionClassNames","className","findPart","node","child","found","part","barrier","getElementType","AccordionItem","idOf","id","element","wrapsTriggerOnly","AccordionTrigger","AccordionPanel","misplacedMessage","headingLevelProp","accordion","isOpen","toggleValue","Heading","triggerElement","panelElement","parts","extra","flattenChildren","children","keyed","key","trigger","panel","accordionTriggerClassNames","hasTrigger","hasPanel","triggerIdProp","panelIdProp","hasPanelContent","extraPanelContent","itemContext","getPartId","panelSlot","accordionItemClassNames","idProp","item","inPanel","headingOutside","state","button","disabledStyles","focusRingInset","composeEventHandlers","onClick","ChevronDownIcon","slot","accordionPanelClassNames","Accordion"],"sources":["../../../src/components/layout/Accordion.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n accordionClassNames,\n accordionItemClassNames,\n accordionPanelClassNames,\n accordionTriggerClassNames,\n} from '../../lib/classNames';\nimport { flattenChildren, getElementType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { reportMissingContext, warnDeprecated, warnOnce } from '../../lib/dev';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport type { HeadingLevel, SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { getPartId } from './disclosureIds';\n\n/** Heading level of the element that wraps each Accordion trigger: the shared {@link HeadingLevel}. */\nexport type AccordionHeadingLevel = HeadingLevel;\n\n/* ------------------------------------------------------------------ */\n/* Contexts */\n/* ------------------------------------------------------------------ */\n\ninterface AccordionContextValue {\n openItems: readonly string[];\n toggle: (value: string) => void;\n /** Counts a mounted Item's value (warns when several Items share it); returns the unregister. */\n registerItem: (value: string) => () => void;\n baseId: string;\n headingLevel: AccordionHeadingLevel;\n}\n\ninterface AccordionItemContextValue {\n value: string;\n isOpen: boolean;\n /** Id of the trigger button: the consumer `id` of the Item's Trigger, else a generated one. */\n triggerId: string;\n /** Id of the panel region: the consumer `id` of the Item's Panel, else a generated one. */\n panelId: string;\n /** Whether the Item renders a panel region while open (a Panel, or other content). */\n hasPanelContent: boolean;\n headingLevel: AccordionHeadingLevel;\n toggle: () => void;\n}\n\n/**\n * What an Accordion.Panel renders after its own children. Kept out of the item context, so a new\n * `extra` (a new array on every Item render) re-renders only the Panel.\n */\ninterface AccordionPanelSlotValue {\n /** Children of the Item that are neither Trigger nor Panel: rendered after the Panel content. */\n extra: React.ReactNode;\n /** `true` inside a Panel's content, where a Trigger or Panel is misplaced. */\n inPanel: boolean;\n}\n\nconst AccordionContext = React.createContext<AccordionContextValue | null>(null);\nconst AccordionItemContext = React.createContext<AccordionItemContextValue | null>(null);\nconst AccordionPanelSlotContext = React.createContext<AccordionPanelSlotValue | null>(null);\n\nconst EMPTY: readonly string[] = [];\n\nconst INERT_ACCORDION: AccordionContextValue = {\n openItems: EMPTY,\n toggle: () => {},\n registerItem: () => () => {},\n baseId: 'wave-accordion-inert',\n headingLevel: 3,\n};\n\nconst INERT_ITEM: AccordionItemContextValue = {\n value: '',\n isOpen: false,\n triggerId: 'wave-accordion-inert-trigger',\n panelId: 'wave-accordion-inert-panel',\n hasPanelContent: false,\n headingLevel: 3,\n toggle: () => {},\n};\n\nconst IN_PANEL: AccordionPanelSlotValue = { extra: null, inPanel: true };\n\n/**\n * `true` inside a wrapper component chain that holds only the item's Trigger (a Tooltip): the Item\n * renders the heading around the wrapper, so the Trigger renders its button without one.\n */\nconst AccordionHeadingOutsideContext = React.createContext(false);\n\n/**\n * Classes of the heading around each trigger button. `grid` stretches its child to the full row,\n * so a wrapper between the heading and the button (a Tooltip's inline-block `<span>`) does not\n * shrink the full-width button and move its chevron away from the row end.\n */\nconst HEADING_CLASS = 'm-0 grid';\n\n/**\n * C-CONTEXT: throws in development; in production logs once (`reportMissingContext`) and returns\n * the inert value.\n */\nfunction useAccordionContext(component: string): AccordionContextValue {\n const context = React.useContext(AccordionContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion>');\n return INERT_ACCORDION;\n}\n\nfunction useAccordionItemContext(component: string): AccordionItemContextValue {\n const context = React.useContext(AccordionItemContext);\n if (context) return context;\n reportMissingContext(component, '<Accordion.Item>');\n return INERT_ITEM;\n}\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Accordion:duplicate:${value}`,\n `Accordion: several items share the value \"${value}\". Item values must be unique within an ` +\n 'Accordion; items with the same value open and close together and share their trigger and ' +\n 'panel ids.',\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Accordion */\n/* ------------------------------------------------------------------ */\n\n/** Props shared by {@link AccordionSingleProps} and {@link AccordionMultipleProps}. */\nexport interface AccordionBaseProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Level of the heading element (`<h1>`–`<h6>`) that wraps every trigger button (WAI-ARIA\n * Accordion pattern). Each `Accordion.Item` can override it.\n * @default 3\n */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/** Props of an Accordion in which at most one item is open (the default). */\nexport interface AccordionSingleProps extends AccordionBaseProps {\n /**\n * Whether only one or multiple items can be open at a time.\n * @default 'single'\n */\n type?: Extract<SelectionMode, 'single'>;\n /** Controlled open item (`null`: every item closed). */\n openItem?: string | null;\n /** Initially open item for uncontrolled usage. */\n defaultOpenItem?: string | null;\n /** Called with the new open item (`null` when it closed) when it changes. */\n onOpenItemChange?: (openItem: string | null) => void;\n /** @deprecated Use `openItem` (single mode); `openItems` belongs to `type=\"multiple\"`. */\n openItems?: readonly string[];\n /**\n * @deprecated Use `defaultOpenItem` (single mode); `defaultOpenItems` belongs to\n * `type=\"multiple\"`.\n */\n defaultOpenItems?: readonly string[];\n /**\n * @deprecated Use `onOpenItemChange` (single mode); `onOpenItemsChange` belongs to\n * `type=\"multiple\"`.\n */\n onOpenItemsChange?: (openItems: string[]) => void;\n}\n\n/** Props of an Accordion in which any number of items can be open. */\nexport interface AccordionMultipleProps extends AccordionBaseProps {\n /** Whether only one or multiple items can be open at a time. */\n type: Extract<SelectionMode, 'multiple'>;\n /** Controlled array of open item values (a readonly array is accepted). */\n openItems?: readonly string[];\n /**\n * Initially open items for uncontrolled usage.\n * @default []\n */\n defaultOpenItems?: readonly string[];\n /** Called with the new open items (a new array) when they change. */\n onOpenItemsChange?: (openItems: string[]) => void;\n openItem?: never;\n defaultOpenItem?: never;\n onOpenItemChange?: never;\n}\n\n/**\n * Properties for the Accordion component: a discriminated union on `type`. Single mode\n * (default) uses `openItem`/`defaultOpenItem`/`onOpenItemChange`; `type=\"multiple\"` uses\n * `openItems`/`defaultOpenItems`/`onOpenItemsChange`.\n *\n * A union cannot be extended by an `interface` (TS2312), which 0.4's interface allowed: extend\n * `AccordionSingleProps` or `AccordionMultipleProps` instead\n * (`interface MyProps extends AccordionSingleProps {}`), or intersect the union\n * (`type MyProps = AccordionProps & { … }`).\n */\nexport type AccordionProps = AccordionSingleProps | AccordionMultipleProps;\n\nfunction toItems(value: string | null | undefined): readonly string[] | undefined {\n if (value === undefined) return undefined;\n return value === null ? EMPTY : [value];\n}\n\n// The Accordion root, documented on the exported `Accordion` const.\nconst AccordionRoot = (props: AccordionProps) => {\n const {\n type,\n openItem,\n defaultOpenItem,\n onOpenItemChange,\n openItems: openItemsProp,\n defaultOpenItems,\n onOpenItemsChange,\n headingLevel = 3,\n className,\n children,\n ref,\n ...rest\n } = props as Omit<AccordionSingleProps, 'type'> & { type?: SelectionMode };\n const multiple = type === 'multiple';\n\n if (!multiple) {\n if (openItemsProp !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'openItems',\n 'openItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (defaultOpenItems !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'defaultOpenItems',\n 'defaultOpenItem',\n 'In single mode the Accordion takes one value.',\n );\n }\n if (onOpenItemsChange !== undefined) {\n warnDeprecated(\n 'Accordion',\n 'onOpenItemsChange',\n 'onOpenItemChange',\n 'In single mode the Accordion reports one value.',\n );\n }\n }\n\n const controlledSingle = multiple ? undefined : openItem;\n const controlled = React.useMemo(\n () => toItems(controlledSingle) ?? openItemsProp,\n [controlledSingle, openItemsProp],\n );\n const [initialItems] = React.useState(\n () => (multiple ? undefined : toItems(defaultOpenItem)) ?? defaultOpenItems ?? EMPTY,\n );\n\n const handleChange = (next: readonly string[]) => {\n const list = [...next];\n if (!multiple) onOpenItemChange?.(list[0] ?? null);\n onOpenItemsChange?.(list);\n };\n\n const [openItems, setOpenItems] = useControllable<readonly string[]>(\n controlled,\n initialItems,\n handleChange,\n );\n\n const openCount = openItems.length;\n React.useEffect(() => {\n if (!multiple && openCount > 1) {\n warnOnce(\n 'Accordion:single-multiple-open',\n `Accordion: type=\"single\" allows one open item, but ${openCount} are open. Pass \\`openItem\\`, or use type=\"multiple\".`,\n );\n }\n }, [multiple, openCount]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setOpenItems((prev) => {\n if (prev.includes(value)) return prev.filter((v) => v !== value);\n return multiple ? [...prev, value] : [value];\n });\n },\n [multiple, setOpenItems],\n );\n\n // How many mounted Items hold each value, to warn about a repeated value (C-DEV). Only the Items'\n // effects touch it (through `registerItem`), never render.\n const itemCountsRef = React.useRef<Map<string, number>>(null);\n const registerItem = React.useCallback((value: string) => {\n itemCountsRef.current ??= new Map();\n const counts = itemCountsRef.current;\n const count = (counts.get(value) ?? 0) + 1;\n counts.set(value, count);\n if (count > 1) warnDuplicateValue(value);\n return () => {\n const remaining = (counts.get(value) ?? 1) - 1;\n if (remaining > 0) counts.set(value, remaining);\n else counts.delete(value);\n };\n }, []);\n\n const baseId = useId('accordion');\n const context = React.useMemo<AccordionContextValue>(\n () => ({ openItems, toggle, registerItem, baseId, headingLevel }),\n [openItems, toggle, registerItem, baseId, headingLevel],\n );\n\n return (\n <AccordionContext.Provider value={context}>\n {/* A nested Accordion's direct children are not inside the outer Item. */}\n <AccordionItemContext.Provider value={null}>\n <AccordionPanelSlotContext.Provider value={null}>\n <AccordionHeadingOutsideContext.Provider value={false}>\n <div\n ref={ref}\n className={cn(accordionClassNames.root, 'divide-y divide-border', className)}\n {...rest}\n >\n {children}\n </div>\n </AccordionHeadingOutsideContext.Provider>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n </AccordionContext.Provider>\n );\n};\nAccordionRoot.displayName = 'Accordion';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionItem sub-component. */\nexport interface AccordionItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this accordion item. */\n value: string;\n /** Heading level of this item's trigger; overrides the Accordion's `headingLevel`. */\n headingLevel?: AccordionHeadingLevel;\n /** Ref to the item `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface PartProps {\n id?: unknown;\n children?: unknown;\n}\n\n/**\n * The first `part` element in `node`: the node itself, or an element found through Fragments\n * and the `children` of wrapper elements (a Tooltip around a Trigger). The search does not enter\n * `barrier` elements or a nested Accordion/Item, and cannot see what a component renders itself.\n * Parts are identified by their unwrapped element type, so parts written in a Server Component\n * (lazy client references) are found too. A `React.lazy` still loading (content inside the\n * consumer's own `<Suspense>`) is no part and never suspends the Item: its children are searched.\n */\nfunction findPart(\n node: unknown,\n part: React.ElementType,\n barrier: React.ElementType,\n): React.ReactElement<PartProps> | undefined {\n if (Array.isArray(node)) {\n for (const child of node) {\n const found = findPart(child, part, barrier);\n if (found) return found;\n }\n return undefined;\n }\n if (!React.isValidElement<PartProps>(node)) return undefined;\n const type = getElementType(node, { suspend: false });\n if (type === part) return node;\n if (type === barrier || type === AccordionRoot || type === AccordionItem) return undefined;\n return findPart(node.props.children, part, barrier);\n}\n\n/**\n * The consumer `id` of a Trigger or Panel element, if it has one. An empty `id` counts as none,\n * here and where the Trigger and Panel render their id (`idProp || generated`).\n */\nfunction idOf(element: React.ReactElement<PartProps> | undefined): string | undefined {\n const id = element?.props.id;\n return typeof id === 'string' && id !== '' ? id : undefined;\n}\n\n/**\n * Whether `node` is a chain of wrapper components, each with the next as its only child, that ends\n * at an Accordion.Trigger: a Tooltip around the Trigger. The Item puts the heading around such a\n * chain instead of inside it, so no heading ends up in a wrapper's phrasing `<span>`. Elements\n * (`<div>`, `<span>`) render as written: the heading stays inside them.\n */\nfunction wrapsTriggerOnly(node: unknown): boolean {\n if (!React.isValidElement<PartProps>(node)) return false;\n const type = getElementType(node, { suspend: false });\n if (\n typeof type === 'string' ||\n type === AccordionTrigger ||\n type === AccordionPanel ||\n type === AccordionRoot ||\n type === AccordionItem\n ) {\n return false;\n }\n const child = node.props.children as React.ReactNode;\n return getElementType(child, { suspend: false }) === AccordionTrigger || wrapsTriggerOnly(child);\n}\n\nfunction misplacedMessage(component: 'Accordion.Trigger' | 'Accordion.Panel'): string {\n return (\n `${component} was rendered inside the panel of an Accordion.Item, so it is not the item's ` +\n `${component === 'Accordion.Trigger' ? 'header' : 'panel'}. Place Accordion.Trigger and ` +\n 'Accordion.Panel directly in Accordion.Item, in a Fragment, or in an element that wraps them ' +\n 'as `children` (such as a Tooltip). The Item cannot see inside a component that renders them ' +\n 'itself and treats that component as panel content.'\n );\n}\n\n/**\n * One section of an Accordion. Place an `Accordion.Trigger` and an `Accordion.Panel` inside it:\n * directly, in a Fragment, or in an element that wraps them as `children` (for example a Tooltip\n * around the Trigger). A component that renders a Trigger or Panel itself is not seen through: it\n * counts as panel content, and a development warning says so.\n *\n * The trigger button sits in a heading (`headingLevel`). A wrapper component whose only child is\n * the Trigger (a Tooltip, also several nested) goes inside that heading, around the button, so\n * the heading never ends up in the wrapper's inline `<span>` and the button keeps the full row.\n * An element such as a `<div>`, or a wrapper that holds more than the Trigger, renders as written,\n * with the heading inside it.\n *\n * Without a Trigger the item's `value` is the button label. Other children (plain text included)\n * are rendered in the panel, after the Panel's own content.\n */\nconst AccordionItem = ({\n value,\n headingLevel: headingLevelProp,\n className,\n children,\n ref,\n ...rest\n}: AccordionItemProps) => {\n const accordion = useAccordionContext('Accordion.Item');\n const isOpen = accordion.openItems.includes(value);\n const { toggle: toggleValue, baseId, registerItem } = accordion;\n React.useEffect(() => registerItem(value), [registerItem, value]);\n const headingLevel = headingLevelProp ?? accordion.headingLevel;\n const Heading: `h${AccordionHeadingLevel}` = `h${headingLevel}`;\n\n let triggerElement: React.ReactElement<PartProps> | undefined;\n let panelElement: React.ReactElement<PartProps> | undefined;\n const parts: React.ReactNode[] = [];\n const extra: React.ReactNode[] = [];\n for (const { key, node: child } of flattenChildren(children)) {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n const trigger = findPart(child, AccordionTrigger, AccordionPanel);\n const panel = findPart(child, AccordionPanel, AccordionTrigger);\n if (trigger || panel) {\n triggerElement ??= trigger;\n panelElement ??= panel;\n parts.push(\n wrapsTriggerOnly(child) ? (\n <Heading key={key} className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>\n <AccordionHeadingOutsideContext.Provider value={true}>\n {child}\n </AccordionHeadingOutsideContext.Provider>\n </Heading>\n ) : (\n keyed\n ),\n );\n } else {\n extra.push(keyed);\n }\n }\n const hasTrigger = triggerElement !== undefined;\n const hasPanel = panelElement !== undefined;\n const triggerIdProp = idOf(triggerElement);\n const panelIdProp = idOf(panelElement);\n const hasPanelContent = hasPanel || extra.length > 0;\n const extraPanelContent = hasPanel && extra.length > 0 ? extra : null;\n\n const itemContext = React.useMemo<AccordionItemContextValue>(\n () => ({\n value,\n isOpen,\n triggerId: triggerIdProp ?? getPartId(baseId, 'trigger', value),\n panelId: panelIdProp ?? getPartId(baseId, 'panel', value),\n hasPanelContent,\n headingLevel,\n toggle: () => toggleValue(value),\n }),\n [value, isOpen, baseId, triggerIdProp, panelIdProp, hasPanelContent, headingLevel, toggleValue],\n );\n const panelSlot = React.useMemo<AccordionPanelSlotValue>(\n () => ({ extra: extraPanelContent, inPanel: false }),\n [extraPanelContent],\n );\n\n return (\n <AccordionItemContext.Provider value={itemContext}>\n <AccordionPanelSlotContext.Provider value={panelSlot}>\n <div\n ref={ref}\n data-state={isOpen ? 'open' : 'closed'}\n className={cn(accordionItemClassNames.root, className)}\n {...rest}\n >\n {hasTrigger ? null : <AccordionTrigger>{value}</AccordionTrigger>}\n {parts}\n {!hasPanel && extra.length > 0 ? <AccordionPanel>{extra}</AccordionPanel> : null}\n </div>\n </AccordionPanelSlotContext.Provider>\n </AccordionItemContext.Provider>\n );\n};\nAccordionItem.displayName = 'AccordionItem';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Trigger */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionTrigger sub-component (merged onto the trigger `<button>`). */\nexport interface AccordionTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Ref to the trigger `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * The button that opens and closes its Accordion.Item, wrapped in a heading (`headingLevel`); when\n * it is the only child of a wrapper component in the Item (a Tooltip), the heading goes around\n * that wrapper instead (see `Accordion.Item`). Its props land on the `<button>`: `className` is\n * merged (yours wins), `onClick` runs before the toggle (call `event.preventDefault()` to keep the\n * item as it is), `ref` receives the button, and a non-empty `id` replaces the generated one (the\n * panel's `aria-labelledby` follows it).\n */\nconst AccordionTrigger = ({\n id: idProp,\n className,\n children,\n onClick,\n ref,\n ...rest\n}: AccordionTriggerProps) => {\n const item = useAccordionItemContext('Accordion.Trigger');\n const inPanel = React.useContext(AccordionPanelSlotContext)?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) {\n warnOnce('Accordion.Trigger:inside-panel', misplacedMessage('Accordion.Trigger'));\n }\n }, [inPanel]);\n const headingOutside = React.useContext(AccordionHeadingOutsideContext);\n const Heading: `h${AccordionHeadingLevel}` = `h${item.headingLevel}`;\n const state = item.isOpen ? 'open' : 'closed';\n\n const button = (\n <button\n type=\"button\"\n className={cn(\n accordionTriggerClassNames.root,\n 'flex w-full items-center justify-between gap-2 px-4 py-3 text-start text-body-1 font-semibold text-foreground',\n 'not-disabled:not-aria-disabled:hover:bg-subtle-hover not-disabled:not-aria-disabled:active:bg-subtle-pressed',\n disabledStyles,\n focusRingInset,\n className,\n )}\n {...rest}\n // A misplaced Trigger (inside the panel) still toggles, but only the item's own trigger\n // carries the item's id and panel reference.\n id={idProp || (inPanel ? undefined : item.triggerId)}\n // Only a panel region the item renders is referenced (none without panel content).\n aria-controls={!inPanel && item.hasPanelContent ? item.panelId : undefined}\n aria-expanded={item.isOpen}\n data-state={state}\n onClick={composeEventHandlers(onClick, item.toggle)}\n ref={ref}\n >\n {children}\n <ChevronDownIcon\n size={16}\n className={cn(\n accordionTriggerClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n item.isOpen && 'rotate-180',\n )}\n />\n </button>\n );\n // Inside a wrapper chain (a Tooltip) the Item has rendered the heading around the wrapper.\n return headingOutside ? (\n button\n ) : (\n <Heading className={cn(accordionTriggerClassNames.heading, HEADING_CLASS)}>{button}</Heading>\n );\n};\nAccordionTrigger.displayName = 'AccordionTrigger';\n\n/* ------------------------------------------------------------------ */\n/* Accordion.Panel */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the AccordionPanel sub-component (merged onto the `role=\"region\"` element). */\nexport interface AccordionPanelProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Ref to the panel `<div role=\"region\">`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * The content region of an Accordion.Item, rendered only while the item is open and labelled by\n * its trigger. Its props (className merged, `ref`, `data-*`, handlers) land on the region, and a\n * non-empty `id` replaces the generated one (the trigger's `aria-controls` follows it).\n */\nconst AccordionPanel = ({ id: idProp, className, children, ref, ...rest }: AccordionPanelProps) => {\n const item = useAccordionItemContext('Accordion.Panel');\n const slot = React.useContext(AccordionPanelSlotContext);\n const inPanel = slot?.inPanel ?? false;\n React.useEffect(() => {\n if (inPanel) warnOnce('Accordion.Panel:inside-panel', misplacedMessage('Accordion.Panel'));\n }, [inPanel]);\n if (!item.isOpen) return null;\n if (inPanel) {\n // Misplaced: its content joins the enclosing region (one region and one panel id per item).\n return (\n <div\n className={cn(accordionPanelClassNames.root, className)}\n {...rest}\n id={idProp || undefined}\n ref={ref}\n >\n {children}\n </div>\n );\n }\n return (\n <AccordionPanelSlotContext.Provider value={IN_PANEL}>\n <div\n role=\"region\"\n className={cn(\n accordionPanelClassNames.root,\n 'px-4 pb-3 text-body-1 text-muted-foreground',\n className,\n )}\n {...rest}\n id={idProp || item.panelId}\n aria-labelledby={item.triggerId}\n data-state=\"open\"\n ref={ref}\n >\n {children}\n {slot?.extra}\n </div>\n </AccordionPanelSlotContext.Provider>\n );\n};\nAccordionPanel.displayName = 'AccordionPanel';\n\n/* ------------------------------------------------------------------ */\n/* Export */\n/* ------------------------------------------------------------------ */\n\n/**\n * A vertically stacked set of disclosure sections (WAI-ARIA Accordion pattern). Each\n * `Accordion.Item` renders an `Accordion.Trigger` button inside a heading (`headingLevel`) and an\n * `Accordion.Panel` region that is shown while the item is open.\n *\n * Single mode (the default) keeps at most one item open (`openItem`, `defaultOpenItem`,\n * `onOpenItemChange`); `type=\"multiple\"` lets any number of items open (`openItems`,\n * `defaultOpenItems`, `onOpenItemsChange`). Each Item's `value` must be unique within its\n * Accordion: a development warning names a repeated value.\n *\n * Sub-components are also exported under flat names (`AccordionItem`, `AccordionTrigger`,\n * `AccordionPanel`) for React Server Components, which cannot use the dotted form.\n */\nexport const Accordion = /* @__PURE__ */ Object.assign(AccordionRoot, {\n Item: AccordionItem,\n Trigger: AccordionTrigger,\n Panel: AccordionPanel,\n});\n\nexport { AccordionItem, AccordionTrigger, AccordionPanel };\n"],"mappings":";;;;;;;;;;;;;;AA0DA,IAAMG,IAAmBD,EAAM,cAA4C,IAAI,GACzEE,IAAuBF,EAAM,cAAgD,IAAI,GACjFG,IAA4BH,EAAM,cAA8C,IAAI,GAEpFI,IAA2B,CAAC,GAE5BC,IAAyC;CAC7C,WAAWD;CACX,cAAc,CAAC;CACf,0BAA0B,CAAC;CAC3B,QAAQ;CACR,cAAc;AAChB,GAEME,IAAwC;CAC5C,OAAO;CACP,QAAQ;CACR,WAAW;CACX,SAAS;CACT,iBAAiB;CACjB,cAAc;CACd,cAAc,CAAC;AACjB,GAEMC,IAAoC;CAAE,OAAO;CAAM,SAAS;AAAK,GAMjEC,IAAiCR,EAAM,cAAc,EAAK,GAO1DS,IAAgB;AAMtB,SAASC,EAAoB,GAA0C;CAIrE,OAHgBV,EAAM,WAAWC,CAC7B,MACJU,EAAqBC,GAAW,aAAa,GACtCP;AACT;AAEA,SAASQ,EA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AS,WAAWtB,EAAGiC,EAA2B,SAAS1E,CAAa;EAAI,UAAA0F;CAAgB,CAAA;AAEhG;AACA,EAAiB,cAAc;AAiB/B,IAAMjC,KAAkB,EAAE,IAAI4B,GAAQ,cAAW,aAAU,QAAK,GAAG3E,QAAgC;CACjG,IAAM4E,IAAOlF,EAAwB,iBAAiB,GAChD4F,IAAOzG,EAAM,WAAWG,CAAyB,GACjD6F,IAAUS,GAAM,WAAW;CAkBjC,OAjBAzG,EAAM,gBAAgB;EACpB,AAAIgG,KAAS1D,EAAS,gCAAgC6B,EAAiB,iBAAiB,CAAC;CAC3F,GAAG,CAAC6B,CAAO,CAAC,GACPD,EAAK,SACNC,IAGA,kBAAC,OAAD;EACE,WAAW9C,EAAGwD,EAAyB,MAAMtD,CAAS;EACtD,GAAIjC;EACJ,IAAI2E,KAAU,KAAA;EACT;EAEJ;CACE,CAAA,IAIP,kBAAC3F,EAA0B,UAA3B;EAAoC,OAAOI;EACzC,UAAA,kBAAC,OAAD;GACE,MAAK;GACL,WAAW2C,EACTwD,EAAyB,MACzB,+CACAtD,CACF;GACA,GAAIjC;GACJ,IAAI2E,KAAUC,EAAK;GACnB,mBAAiBA,EAAK;GACtB,cAAW;GACN;GAXP,UAAA,CAaGjB,GACA2B,GAAM,KACJ;;CAC6B,CAAA,IAhCb;AAkC3B;AACA,EAAe,cAAc;AAmB7B,IAAaE,IAA4B,uBAAO,OAAO1F,GAAe;CACpE,MAAM2C;CACN,SAASK;CACT,OAAOC;AACT,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/slot.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/classNames.cjs"),o=require("../button/Button.cjs"),s=require("../button/Button.slots.cjs"),c=require("../../lib/icons.cjs"),l=require("./NavDrawer.context.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f={"extra-small":12,small:16,medium:20,large:24,"extra-large":28},p=({appearance:e=`subtle`,size:p=`medium`,icon:m,onClick:h,className:g,children:_,ref:v,...y})=>{let b=u.useContext(l.NavDrawerContext),{glyph:x,button:S}=s.unwrapButtonGlyph(m),C=r.slotRendersContent(x),w=S===null&&m!=null&&!C;u.useEffect(()=>{w&&n.warnOnce(`Hamburger:icon-empty`,"Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.")},[w]),u.useEffect(()=>{S&&n.warnOnce(`Hamburger:icon-button`,`Hamburger: \`icon\` received ${S}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \`icon={<MyIcon />}\`.`)},[S]);let T=r.materialiseSlotContent(_),E=!!y[`aria-label`]||!!y[`aria-labelledby`]||!!y.title||r.slotRendersContent(T),D=b?e=>{e.target instanceof Node&&e.currentTarget.contains(e.target)&&b.requestOpen(!b.open,{reason:`trigger`,event:e.nativeEvent})}:void 0,O=b?{"aria-expanded":b.open,"aria-controls":b.panelId,"aria-haspopup":void 0}:void 0;return(0,d.jsx)(o.Button,{...y,"aria-label":E?y[`aria-label`]:`Navigation`,...O,ref:v,appearance:e,size:p,icon:s.withPartClass(C?x:(0,d.jsx)(c.NavigationIcon,{size:f[p]}),a.hamburgerClassNames.icon),onClick:i.composeEventHandlers(h,D),className:t.cn(a.hamburgerClassNames.root,g),children:T})};p.displayName=`Hamburger`,exports.Hamburger=p;
|
|
2
|
+
//# sourceMappingURL=Hamburger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hamburger.cjs","names":["React","NavDrawerContext","unwrapButtonGlyph","slotRendersContent","materialiseSlotContent","Button","withPartClass","NavigationIcon","hamburgerClassNames","composeEventHandlers","cn","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_Button","require_Button_slots","require_icons","require_NavDrawer_context","react","react_jsx_runtime","GLYPH_SIZES","Hamburger","rest","drawer","iconButton","icon","glyphRenders","glyph","iconEmpty","label","children","named","toggle","event","stateProps","size","onClick","className"],"sources":["../../../src/components/navigation/Hamburger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { hamburgerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { NavigationIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Appearance, Size } from '../../lib/types';\nimport { Button } from '../button/Button';\nimport { unwrapButtonGlyph, withPartClass } from '../button/Button.slots';\nimport { NavDrawerContext } from './NavDrawer.context';\n\n/*\n * Hamburger: a Button with the navigation glyph that toggles the NavDrawer it sits in. Reads only\n * the NavDrawer's context module (never `NavDrawer.tsx`), so it holds no drawer machinery.\n */\n\n/** Properties for the Hamburger component. */\nexport interface HamburgerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Visual style. Fluent's `transparent` look is WaveUI's `subtle` (WaveUI's `transparent` is\n * link-coloured).\n * @default 'subtle'\n */\n appearance?: Appearance;\n /**\n * Size: the button's height and the glyph (12, 16, 20, 24 or 28px).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Replaces the navigation glyph (three bars). Decorative (`aria-hidden`). Unlike Button's `icon`,\n * a Hamburger always shows a glyph: `null`, `undefined` and a value that renders nothing keep\n * the default (the last warns in development). A `<button>` or `Button` passed here is not\n * nested: its children become the glyph and its props are dropped, with a warning.\n */\n icon?: Slot<'span'>;\n /**\n * The button's name. Without `aria-label`, `aria-labelledby`, `title` or a visible label\n * (children), the Hamburger is named \"Navigation\"; localize it here. The name stays the same\n * while the drawer opens and closes (the state is `aria-expanded`).\n * @default 'Navigation'\n */\n 'aria-label'?: string;\n /**\n * Unavailable but focusable (see `Button.disabledFocusable`): no toggle, no `onClick`.\n * @default false\n */\n disabledFocusable?: boolean;\n /** Ref to the `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** The default glyph's size per button size. */\nconst GLYPH_SIZES: Readonly<Record<Size, number>> = {\n 'extra-small': 12,\n small: 16,\n medium: 20,\n large: 24,\n 'extra-large': 28,\n};\n\n/**\n * A button that opens and closes a navigation drawer: a `Button` (`subtle`, icon-only) with the\n * navigation glyph, named \"Navigation\" by default. Inside a `NavDrawer` (in its header) it toggles\n * that drawer and reports it with `aria-expanded` and `aria-controls`. Elsewhere (your page\n * header) it is a plain button: pass `aria-expanded={open}`, `aria-controls` (while the drawer's\n * panel is rendered) and, for an overlay drawer, `aria-haspopup=\"dialog\"`, and toggle your state\n * in `onClick`. Fluent's `Hamburger`.\n *\n * @example\n * <Hamburger\n * aria-expanded={open}\n * aria-controls={open ? 'main-nav' : undefined}\n * aria-haspopup=\"dialog\"\n * onClick={() => setOpen(!open)}\n * />\n */\nexport const Hamburger = ({\n appearance = 'subtle',\n size = 'medium',\n icon,\n onClick,\n className,\n children,\n ref,\n ...rest\n}: HamburgerProps) => {\n const drawer = React.useContext(NavDrawerContext);\n\n // A required indicator (C-SLOTS): a button passed as `icon` is unwrapped, never nested, and a\n // value that renders nothing keeps the default glyph.\n const { glyph, button: iconButton } = unwrapButtonGlyph(icon);\n const glyphRenders = slotRendersContent(glyph);\n // An unwrapped button reports its own warning only.\n const iconEmpty = iconButton === null && icon != null && !glyphRenders;\n React.useEffect(() => {\n if (iconEmpty) {\n warnOnce(\n 'Hamburger:icon-empty',\n 'Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.',\n );\n }\n }, [iconEmpty]);\n React.useEffect(() => {\n if (iconButton) {\n warnOnce(\n 'Hamburger:icon-button',\n `Hamburger: \\`icon\\` received ${iconButton}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \\`icon={<MyIcon />}\\`.`,\n );\n }\n }, [iconButton]);\n\n // The default name, while nothing else names the button. A generator label is read once; its\n // items are what renders.\n const label = materialiseSlotContent(children);\n const named =\n Boolean(rest['aria-label']) ||\n Boolean(rest['aria-labelledby']) ||\n Boolean(rest.title) ||\n slotRendersContent(label);\n\n // Inside a NavDrawer: the toggle, after the consumer's onClick (`preventDefault()` skips it). A\n // click that bubbles through the React tree from a portal opened inside it is not its own\n // (C-COMPOSE).\n const toggle = drawer\n ? (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;\n drawer.requestOpen(!drawer.open, { reason: 'trigger', event: event.nativeEvent });\n }\n : undefined;\n // The drawer's state wins over a consumer's (the modal triggers' rule); no `aria-haspopup`, as\n // the Hamburger is inside the surface it toggles.\n const stateProps = drawer\n ? {\n 'aria-expanded': drawer.open,\n 'aria-controls': drawer.panelId,\n 'aria-haspopup': undefined,\n }\n : undefined;\n\n return (\n <Button\n {...rest}\n aria-label={named ? rest['aria-label'] : 'Navigation'}\n {...stateProps}\n ref={ref}\n appearance={appearance}\n size={size}\n icon={withPartClass(\n glyphRenders ? glyph : <NavigationIcon size={GLYPH_SIZES[size]} />,\n hamburgerClassNames.icon,\n )}\n onClick={composeEventHandlers(onClick, toggle)}\n className={cn(hamburgerClassNames.root, className)}\n >\n {label}\n </Button>\n );\n};\nHamburger.displayName = 'Hamburger';\n"],"mappings":"mdAsDA,IAAMuB,EAA8C,CAClD,cAAe,GACf,MAAO,GACP,OAAQ,GACR,MAAO,GACP,cAAe,EACjB,EAkBaC,GAAa,CACxB,aAAa,SACb,OAAO,SACP,OACA,UACA,YACA,WACA,MACA,GAAGC,KACiB,CACpB,IAAMC,EAAS1B,EAAM,WAAWC,EAAAA,gBAAgB,EAI1C,CAAE,QAAO,OAAQ0B,GAAezB,EAAAA,kBAAkB0B,CAAI,EACtDC,EAAe1B,EAAAA,mBAAmB2B,CAAK,EAEvCC,EAAYJ,IAAe,MAAQC,GAAQ,MAAQ,CAACC,EAC1DR,EAAM,cAAgB,CAChBU,GACFlB,EAAA,SACE,uBACA,mKACF,CAEJ,EAAG,CAACkB,CAAS,CAAC,EACdV,EAAM,cAAgB,CAChBM,GACFd,EAAA,SACE,wBACA,gCAAgCc,EAAW,iJAC7C,CAEJ,EAAG,CAACA,CAAU,CAAC,EAIf,IAAMK,EAAQ5B,EAAAA,uBAAuB6B,CAAQ,EACvCC,EACJ,EAAQT,EAAK,eACb,EAAQA,EAAK,oBACb,EAAQA,EAAK,OACbtB,EAAAA,mBAAmB6B,CAAK,EAKpBG,EAAST,EACV,GAA+C,CACxCU,EAAM,kBAAkB,MAAUA,EAAM,cAAc,SAASA,EAAM,MAAM,GACjFV,EAAO,YAAY,CAACA,EAAO,KAAM,CAAE,OAAQ,UAAW,MAAOU,EAAM,WAAY,CAAC,CAClF,EACA,IAAA,GAGEC,EAAaX,EACf,CACE,gBAAiBA,EAAO,KACxB,gBAAiBA,EAAO,QACxB,gBAAiB,IAAA,EACnB,EACA,IAAA,GAEJ,OACE,EAAAJ,EAAA,IAAA,CAACjB,EAAAA,OAAD,CACE,GAAIoB,EACJ,aAAYS,EAAQT,EAAK,cAAgB,aACzC,GAAIY,EACC,MACO,aACN,OACN,KAAM/B,EAAAA,cACJuB,EAAeC,GAAQ,EAAAR,EAAA,IAAA,CAACf,EAAAA,eAAD,CAAgB,KAAMgB,EAAYe,EAAQ,CAAA,EACjE9B,EAAAA,oBAAoB,IACtB,EACA,QAASC,EAAAA,qBAAqB8B,EAASJ,CAAM,EAC7C,UAAWzB,EAAAA,GAAGF,EAAAA,oBAAoB,KAAMgC,CAAS,EAEhD,SAAAR,CACK,CAAA,CAEZ,EACA,EAAU,YAAc"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/cn.mjs";
|
|
3
|
+
import { warnOnce as t } from "../../lib/dev.mjs";
|
|
4
|
+
import { materialiseSlotContent as n, slotRendersContent as r } from "../../lib/slot.mjs";
|
|
5
|
+
import { composeEventHandlers as i } from "../../lib/composeEventHandlers.mjs";
|
|
6
|
+
import { hamburgerClassNames as a } from "../../lib/classNames.mjs";
|
|
7
|
+
import { Button as o } from "../button/Button.mjs";
|
|
8
|
+
import { unwrapButtonGlyph as s, withPartClass as c } from "../button/Button.slots.mjs";
|
|
9
|
+
import { NavigationIcon as l } from "../../lib/icons.mjs";
|
|
10
|
+
import { NavDrawerContext as u } from "./NavDrawer.context.mjs";
|
|
11
|
+
import * as d from "react";
|
|
12
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
13
|
+
//#region src/components/navigation/Hamburger.tsx
|
|
14
|
+
var p = {
|
|
15
|
+
"extra-small": 12,
|
|
16
|
+
small: 16,
|
|
17
|
+
medium: 20,
|
|
18
|
+
large: 24,
|
|
19
|
+
"extra-large": 28
|
|
20
|
+
}, m = ({ appearance: m = "subtle", size: h = "medium", icon: g, onClick: _, className: v, children: y, ref: b, ...x }) => {
|
|
21
|
+
let S = d.useContext(u), { glyph: C, button: w } = s(g), T = r(C), E = w === null && g != null && !T;
|
|
22
|
+
d.useEffect(() => {
|
|
23
|
+
E && t("Hamburger:icon-empty", "Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.");
|
|
24
|
+
}, [E]), d.useEffect(() => {
|
|
25
|
+
w && t("Hamburger:icon-button", `Hamburger: \`icon\` received ${w}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \`icon={<MyIcon />}\`.`);
|
|
26
|
+
}, [w]);
|
|
27
|
+
let D = n(y), O = !!x["aria-label"] || !!x["aria-labelledby"] || !!x.title || r(D), k = S ? (e) => {
|
|
28
|
+
e.target instanceof Node && e.currentTarget.contains(e.target) && S.requestOpen(!S.open, {
|
|
29
|
+
reason: "trigger",
|
|
30
|
+
event: e.nativeEvent
|
|
31
|
+
});
|
|
32
|
+
} : void 0, A = S ? {
|
|
33
|
+
"aria-expanded": S.open,
|
|
34
|
+
"aria-controls": S.panelId,
|
|
35
|
+
"aria-haspopup": void 0
|
|
36
|
+
} : void 0;
|
|
37
|
+
return /* @__PURE__ */ f(o, {
|
|
38
|
+
...x,
|
|
39
|
+
"aria-label": O ? x["aria-label"] : "Navigation",
|
|
40
|
+
...A,
|
|
41
|
+
ref: b,
|
|
42
|
+
appearance: m,
|
|
43
|
+
size: h,
|
|
44
|
+
icon: c(T ? C : /* @__PURE__ */ f(l, { size: p[h] }), a.icon),
|
|
45
|
+
onClick: i(_, k),
|
|
46
|
+
className: e(a.root, v),
|
|
47
|
+
children: D
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
m.displayName = "Hamburger";
|
|
51
|
+
//#endregion
|
|
52
|
+
export { m as Hamburger };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=Hamburger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hamburger.mjs","names":["React","GLYPH_SIZES","Hamburger","rest","drawer","NavDrawerContext","iconButton","unwrapButtonGlyph","icon","glyphRenders","slotRendersContent","glyph","iconEmpty","warnOnce","label","materialiseSlotContent","children","named","toggle","event","stateProps","Button","withPartClass","NavigationIcon","size","hamburgerClassNames","composeEventHandlers","onClick","cn","className"],"sources":["../../../src/components/navigation/Hamburger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { hamburgerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { NavigationIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Appearance, Size } from '../../lib/types';\nimport { Button } from '../button/Button';\nimport { unwrapButtonGlyph, withPartClass } from '../button/Button.slots';\nimport { NavDrawerContext } from './NavDrawer.context';\n\n/*\n * Hamburger: a Button with the navigation glyph that toggles the NavDrawer it sits in. Reads only\n * the NavDrawer's context module (never `NavDrawer.tsx`), so it holds no drawer machinery.\n */\n\n/** Properties for the Hamburger component. */\nexport interface HamburgerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Visual style. Fluent's `transparent` look is WaveUI's `subtle` (WaveUI's `transparent` is\n * link-coloured).\n * @default 'subtle'\n */\n appearance?: Appearance;\n /**\n * Size: the button's height and the glyph (12, 16, 20, 24 or 28px).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Replaces the navigation glyph (three bars). Decorative (`aria-hidden`). Unlike Button's `icon`,\n * a Hamburger always shows a glyph: `null`, `undefined` and a value that renders nothing keep\n * the default (the last warns in development). A `<button>` or `Button` passed here is not\n * nested: its children become the glyph and its props are dropped, with a warning.\n */\n icon?: Slot<'span'>;\n /**\n * The button's name. Without `aria-label`, `aria-labelledby`, `title` or a visible label\n * (children), the Hamburger is named \"Navigation\"; localize it here. The name stays the same\n * while the drawer opens and closes (the state is `aria-expanded`).\n * @default 'Navigation'\n */\n 'aria-label'?: string;\n /**\n * Unavailable but focusable (see `Button.disabledFocusable`): no toggle, no `onClick`.\n * @default false\n */\n disabledFocusable?: boolean;\n /** Ref to the `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** The default glyph's size per button size. */\nconst GLYPH_SIZES: Readonly<Record<Size, number>> = {\n 'extra-small': 12,\n small: 16,\n medium: 20,\n large: 24,\n 'extra-large': 28,\n};\n\n/**\n * A button that opens and closes a navigation drawer: a `Button` (`subtle`, icon-only) with the\n * navigation glyph, named \"Navigation\" by default. Inside a `NavDrawer` (in its header) it toggles\n * that drawer and reports it with `aria-expanded` and `aria-controls`. Elsewhere (your page\n * header) it is a plain button: pass `aria-expanded={open}`, `aria-controls` (while the drawer's\n * panel is rendered) and, for an overlay drawer, `aria-haspopup=\"dialog\"`, and toggle your state\n * in `onClick`. Fluent's `Hamburger`.\n *\n * @example\n * <Hamburger\n * aria-expanded={open}\n * aria-controls={open ? 'main-nav' : undefined}\n * aria-haspopup=\"dialog\"\n * onClick={() => setOpen(!open)}\n * />\n */\nexport const Hamburger = ({\n appearance = 'subtle',\n size = 'medium',\n icon,\n onClick,\n className,\n children,\n ref,\n ...rest\n}: HamburgerProps) => {\n const drawer = React.useContext(NavDrawerContext);\n\n // A required indicator (C-SLOTS): a button passed as `icon` is unwrapped, never nested, and a\n // value that renders nothing keeps the default glyph.\n const { glyph, button: iconButton } = unwrapButtonGlyph(icon);\n const glyphRenders = slotRendersContent(glyph);\n // An unwrapped button reports its own warning only.\n const iconEmpty = iconButton === null && icon != null && !glyphRenders;\n React.useEffect(() => {\n if (iconEmpty) {\n warnOnce(\n 'Hamburger:icon-empty',\n 'Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.',\n );\n }\n }, [iconEmpty]);\n React.useEffect(() => {\n if (iconButton) {\n warnOnce(\n 'Hamburger:icon-button',\n `Hamburger: \\`icon\\` received ${iconButton}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \\`icon={<MyIcon />}\\`.`,\n );\n }\n }, [iconButton]);\n\n // The default name, while nothing else names the button. A generator label is read once; its\n // items are what renders.\n const label = materialiseSlotContent(children);\n const named =\n Boolean(rest['aria-label']) ||\n Boolean(rest['aria-labelledby']) ||\n Boolean(rest.title) ||\n slotRendersContent(label);\n\n // Inside a NavDrawer: the toggle, after the consumer's onClick (`preventDefault()` skips it). A\n // click that bubbles through the React tree from a portal opened inside it is not its own\n // (C-COMPOSE).\n const toggle = drawer\n ? (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;\n drawer.requestOpen(!drawer.open, { reason: 'trigger', event: event.nativeEvent });\n }\n : undefined;\n // The drawer's state wins over a consumer's (the modal triggers' rule); no `aria-haspopup`, as\n // the Hamburger is inside the surface it toggles.\n const stateProps = drawer\n ? {\n 'aria-expanded': drawer.open,\n 'aria-controls': drawer.panelId,\n 'aria-haspopup': undefined,\n }\n : undefined;\n\n return (\n <Button\n {...rest}\n aria-label={named ? rest['aria-label'] : 'Navigation'}\n {...stateProps}\n ref={ref}\n appearance={appearance}\n size={size}\n icon={withPartClass(\n glyphRenders ? glyph : <NavigationIcon size={GLYPH_SIZES[size]} />,\n hamburgerClassNames.icon,\n )}\n onClick={composeEventHandlers(onClick, toggle)}\n className={cn(hamburgerClassNames.root, className)}\n >\n {label}\n </Button>\n );\n};\nHamburger.displayName = 'Hamburger';\n"],"mappings":";;;;;;;;;;;;;AAsDA,IAAMC,IAA8C;CAClD,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAkBaC,KAAa,EACxB,gBAAa,UACb,UAAO,UACP,SACA,YACA,cACA,aACA,QACA,GAAGC,QACiB;CACpB,IAAMC,IAASJ,EAAM,WAAWK,CAAgB,GAI1C,EAAE,UAAO,QAAQC,MAAeC,EAAkBC,CAAI,GACtDC,IAAeC,EAAmBC,CAAK,GAEvCC,IAAYN,MAAe,QAAQE,KAAQ,QAAQ,CAACC;CAS1D,AARAT,EAAM,gBAAgB;EACpB,AAAIY,KACFC,EACE,wBACA,mKACF;CAEJ,GAAG,CAACD,CAAS,CAAC,GACdZ,EAAM,gBAAgB;EACpB,AAAIM,KACFO,EACE,yBACA,gCAAgCP,EAAW,iJAC7C;CAEJ,GAAG,CAACA,CAAU,CAAC;CAIf,IAAMQ,IAAQC,EAAuBC,CAAQ,GACvCC,IACJ,EAAQd,EAAK,iBACb,EAAQA,EAAK,sBACb,EAAQA,EAAK,SACbO,EAAmBI,CAAK,GAKpBI,IAASd,KACV,MAA+C;EAC9C,AAAMe,EAAM,kBAAkB,QAAUA,EAAM,cAAc,SAASA,EAAM,MAAM,KACjFf,EAAO,YAAY,CAACA,EAAO,MAAM;GAAE,QAAQ;GAAW,OAAOe,EAAM;EAAY,CAAC;CAClF,IACA,KAAA,GAGEC,IAAahB,IACf;EACE,iBAAiBA,EAAO;EACxB,iBAAiBA,EAAO;EACxB,iBAAiB,KAAA;CACnB,IACA,KAAA;CAEJ,OACE,kBAACiB,GAAD;EACE,GAAIlB;EACJ,cAAYc,IAAQd,EAAK,gBAAgB;EACzC,GAAIiB;EACC;EACO;EACN;EACN,MAAME,EACJb,IAAeE,IAAQ,kBAACY,GAAD,EAAgB,MAAMtB,EAAYuB,GAAQ,CAAA,GACjEC,EAAoB,IACtB;EACA,SAASC,EAAqBC,GAAST,CAAM;EAC7C,WAAWU,EAAGH,EAAoB,MAAMI,CAAS;EAEhD,UAAAf;CACK,CAAA;AAEZ;AACA,EAAU,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/classNames.cjs"),a=require("../../hooks/useId.cjs"),o=require("../../lib/styles.cjs"),s=require("../../lib/icons.cjs"),c=require("./Nav.context.cjs"),l=require("./Nav.parts.cjs"),u=require("./Nav.root.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=`flex h-5 w-5 shrink-0 items-center justify-center`;function m(e,n){return e&&r.slotRendersContent(e)?r.renderSlot(e,`span`,t.cn(n,p),{"aria-hidden":!0}):null}var h={base:t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,o.focusRingInset,o.disabledStyles),selected:`bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary`,idle:`text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,selectedInRow:`text-primary font-semibold`,rowSelected:`bg-subtle-selected border-s-2 border-s-primary`},g={base:t.cn(`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`,o.focusRingInset,o.disabledStyles),selected:`text-primary font-semibold`,idle:`text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,selectedInRow:`text-primary font-semibold`,rowSelected:void 0},_=`group/nav-row flex items-center transition-colors motion-reduce:transition-none`,v=`hover:bg-subtle-hover`,y=t.cn(`flex shrink-0 items-center gap-1 pe-2`,`*:opacity-0 group-hover/nav-row:*:opacity-100 group-focus-within/nav-row:*:opacity-100`,`forced-colors:*:opacity-100 [@media(hover:none)]:*:opacity-100`,`*:has-[[aria-pressed=true]]:opacity-100 *:has-[[aria-expanded=true]]:opacity-100`,`[&>[aria-pressed=true]]:opacity-100 [&>[aria-expanded=true]]:opacity-100`),b=t.cn(`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`,`data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary`,o.focusRingInset);function x(e){if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;let t=e.currentTarget,n=t.getAttribute(`target`);return!!n&&n.toLowerCase()!==`_self`||t.hasAttribute(`download`)}function S(e,n,i,a,o,s,c){let{value:l,icon:u,disabled:d=!1,href:p,className:h,children:g,onClick:b,actions:S,ref:C,...w}=e,T=n.value===l,E=p!==void 0,D=i?{"data-roving-value":l}:void 0,O=r.slotRendersContent(S),k=w.id??c,A=O?{id:k}:void 0,j=e=>{if(d){e.preventDefault();return}b?.(e),!(E?!e.defaultPrevented&&x(e):e.defaultPrevented)&&n.select(l)},M=(0,f.jsxs)(f.Fragment,{children:[s&&m(u,o.icon),s?(0,f.jsx)(`span`,{className:t.cn(o.content,`flex-1 text-start`),children:g}):g]}),N=t.cn(o.root,a.base,T?O?a.selectedInRow:a.selected:a.idle,O&&`min-w-0 flex-1`,h),P=O?t.cn(o.listItem,_,T&&a.rowSelected?a.rowSelected:!d&&v):o.listItem,F=O?(0,f.jsx)(`span`,{role:`group`,"aria-labelledby":k,"data-wave-nav-actions":``,className:t.cn(o.actions,y),children:r.materialiseSlotContent(S)}):null;if(E)return(0,f.jsxs)(`li`,{className:P,children:[(0,f.jsx)(`a`,{...w,...A,...D,ref:C,href:d?void 0:p,role:d?`link`:w.role,"aria-disabled":d?!0:w[`aria-disabled`],"aria-current":T?`page`:void 0,onClick:j,className:N,children:M}),F]});let{rel:I,...L}=w;return(0,f.jsxs)(`li`,{className:P,children:[(0,f.jsx)(`button`,{type:`button`,...L,...A,...D,ref:C,disabled:d,"aria-current":T?`page`:void 0,onClick:j,className:N,children:M}),F]})}var C=({value:e,label:r,icon:o,className:l,children:u,ref:p,...h})=>{let g=c.useNavContext(`Nav.Category`),_=d.useContext(c.NavRovingContext),{value:v,openCategories:y,toggleCategory:x,currentCategory:S,categoryStore:C}=g;c.useNavValue(g,`category`,e);let w=a.useId(`wave-nav-category`),T=y.includes(e),E=!T&&v!==``&&c.containsValue(u,v),D=d.useSyncExternalStore(C.subscribe,()=>v!==``&&C.get(v)===e,()=>!1);d.useLayoutEffect(()=>{if(E)return C.record(v,e),()=>C.forget(v,e)},[C,E,v,e]);let O=!T&&(S===e||D||E);d.useLayoutEffect(()=>{if(_)return _.reportCurrentCategory(e,O),()=>_.reportCurrentCategory(e,!1)},[_,e,O]);let k=d.useRef(null);c.useNavListChildCheck(k,`Nav.Category`,`sub-items`);let A=r,j=u;if(r===void 0){n.warnDeprecated(`Nav.Category`,`text children as the label`,`label`,"Pass the category label in `label` and only the sub-items as children.");let e=d.Children.toArray(u),t=e=>typeof e==`string`||typeof e==`number`;A=e.filter(t).join(``),j=e.filter(e=>!t(e))}return(0,f.jsxs)(`li`,{ref:p,...h,className:t.cn(i.navCategoryClassNames.root,l),children:[(0,f.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":T?w:void 0,"aria-current":O?!0:void 0,"data-contains-current":O?``:void 0,"data-roving-value":_?`wave-nav-category:${e}`:void 0,onClick:()=>x(e),className:t.cn(i.navCategoryClassNames.button,b),children:[m(o,i.navCategoryClassNames.icon),(0,f.jsx)(`span`,{className:t.cn(i.navCategoryClassNames.label,`flex-1 text-start`),children:A}),(0,f.jsx)(s.ChevronDownIcon,{className:t.cn(i.navCategoryClassNames.expandIcon,`shrink-0 transition-transform motion-reduce:transition-none`,T&&`rotate-180`)})]}),T&&(0,f.jsx)(c.NavCategoryValueContext.Provider,{value:e,children:(0,f.jsx)(`ul`,{ref:k,id:w,className:t.cn(i.navCategoryClassNames.list,`m-0 list-none p-0`),children:j})})]})};C.displayName=`NavCategory`,c.markNavPart(C,`category`);function w(e){let t=c.useNavContext(`Nav.Item`);c.useNavValue(t,`item`,e.value),c.useRecordCategory(t,e.value);let n=d.useContext(c.NavRovingContext),r=a.useId(`wave-nav-item`);return S(e,t,n,h,{root:i.navItemClassNames.root,listItem:i.navItemClassNames.listItem,actions:i.navItemClassNames.actions,icon:i.navItemClassNames.icon,content:i.navItemClassNames.content},!0,r)}w.displayName=`NavItem`,c.markNavPart(w,`entry`);function T(e){let t=c.useNavContext(`Nav.SubItem`);c.useNavValue(t,`item`,e.value),c.useRecordCategory(t,e.value);let n=d.useContext(c.NavRovingContext),r=a.useId(`wave-nav-item`);return S(e,t,n,g,{root:i.navSubItemClassNames.root,listItem:i.navSubItemClassNames.listItem,actions:i.navSubItemClassNames.actions},!1,r)}T.displayName=`NavSubItem`,c.markNavPart(T,`entry`);var E=Object.assign(u.NavRoot,{Category:C,Item:w,SubItem:T,SectionHeader:l.NavSectionHeader,Divider:l.NavDivider,AppItem:l.NavAppItem,AppItemStatic:l.NavAppItemStatic});exports.Nav=E,exports.NavAppItem=l.NavAppItem,exports.NavAppItemStatic=l.NavAppItemStatic,exports.NavCategory=C,exports.NavDivider=l.NavDivider,exports.NavItem=w,exports.NavSectionHeader=l.NavSectionHeader,exports.NavSubItem=T;
|
|
2
2
|
//# sourceMappingURL=Nav.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Nav.cjs","names":["React","slotRendersContent","renderSlot","cn","focusRingInset","disabledStyles","getElementType","_Fragment","useId","navCategoryClassNames","ChevronDownIcon","navItemClassNames","navSubItemClassNames","resolveDeprecatedProp","useControllable","useEventCallback","navClassNames","require_runtime","require_cn","require_children","require_dev","require_slot","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_styles","require_icons","react","react_jsx_runtime","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","componentName","warnDuplicateValue","kind","useNavValue","context","registerValue","useRecordCategory","categoryStore","iconClasses","renderIcon","icon","className","itemClasses","subItemClasses","categoryButtonClasses","childrenOf","element","children","isThenable","forEachElement","nodes","node","visit","child","error","isPart","types","containsValue","found","NavItem","NavSubItem","selected","findCategoriesContaining","result","current","inner","NavCategory","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","isLink","href","handleClick","disabled","onClick","content","withIcon","stable","entryClassName","classes","buttonRest","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","containsCurrent","currentCategory","buttonLabel","label","items","parts","isText","part","toggleCategory","NavRoot","valueProp","defaultValueProp","openCategoriesProp","controlledValue","selectedValue","defaultValue","defaultSelectedValue","onNavItemSelect","setValue","onValueChange","notifyNavItemSelect","select","next","initialOpenCategories","defaultOpenCategories","setOpenCategories","onOpenCategoriesChange","previous","entry","valueCountsRef","counts","key","count","remaining","contextValue","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":"wfAkDA,SAAS8B,GAAwC,CAC/C,IAAMC,EAAa,IAAI,IACjBC,EAAY,IAAI,IAChBC,MAAeD,EAAU,QAAS,GAAaE,EAAS,CAAC,EAC/D,MAAO,CACL,OAAO,EAAO,EAAU,EACjBH,EAAW,IAAII,CAAK,GAAK,QAAUC,IACpCA,IAAa,KAAML,EAAW,OAAOI,CAAK,EACzCJ,EAAW,IAAII,EAAOC,CAAQ,EACnCH,EAAO,EACT,EACA,OAAO,EAAO,EAAU,CAClBF,EAAW,IAAII,CAAK,IAAMC,IAC9BL,EAAW,OAAOI,CAAK,EACvBF,EAAO,EACT,EACA,IAAM,GAAUF,EAAW,IAAII,CAAK,EACpC,UAAU,EAAU,CAElB,OADAH,EAAU,IAAIE,CAAQ,MACT,CACXF,EAAU,OAAOE,CAAQ,CAC3B,CACF,CACF,CACF,CAgBA,IAAMG,EAAarC,EAAM,cAAsC,IAAI,EACnE,EAAW,YAAc,aAEzB,IAAMsC,MAAa,CAAC,EACdC,EAAqC,CACzC,MAAO,GACP,OAAQD,EACR,eAAgB,CAAC,EACjB,eAAgBA,EAChB,kBAAqBA,EACrB,gBAAiB,IAAA,GACjB,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CACvE,CAAA,CACc,CAAA,CAEzB,EACA,EAAQ,YAAc,MAsBtB,IAAa2H,EAAsB,OAAO,OAAO1B,EAAS,CACxD,SAAUnC,EACV,KAAMP,EACN,QAASC,CACX,CAAC"}
|
|
1
|
+
{"version":3,"file":"Nav.cjs","names":["slotRendersContent","renderSlot","cn","focusRingInset","disabledStyles","_Fragment","materialiseSlotContent","useNavContext","React","NavRovingContext","useId","containsValue","navCategoryClassNames","ChevronDownIcon","NavCategoryValueContext","markNavPart","navItemClassNames","navSubItemClassNames","NavRoot","NavSectionHeader","NavDivider","NavAppItem","NavAppItemStatic","require_runtime","require_cn","require_dev","require_slot","require_classNames","require_useId","require_styles","require_icons","require_Nav_context","require_Nav_parts","require_Nav_root","react","react_jsx_runtime","iconClasses","renderIcon","icon","className","itemClasses","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","withIcon","stable","children","entryClassName","classes","listItemClassName","actionsGroup","buttonRest","NavCategory","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","categoryStore","containsCurrent","currentCategory","listRef","buttonLabel","label","items","parts","isText","part","toggleCategory","NavItem","NavSubItem","Nav"],"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":"idA0PA,IAAMoC,EAAc,oDAQpB,SAASC,EACP,EACA,EAC2B,CAC3B,OAAOC,GAAQtC,EAAAA,mBAAmBsC,CAAI,EAClCrC,EAAAA,WAAWqC,EAAM,OAAQpC,EAAAA,GAAGqC,EAAWH,CAAW,EAAG,CAAE,cAAe,EAAK,CAAC,EAC5E,IACN,CAEA,IAAMI,EAAc,CAClB,KAAMtC,EAAAA,GACJ,+HACAC,EAAAA,eACAC,EAAAA,cACF,EACA,SAAU,4EACV,KAAM,uEAEN,cAAe,6BACf,YAAa,gDACf,EAEMqC,EAAiB,CACrB,KAAMvC,EAAAA,GACJ,iIACAC,EAAAA,eACAC,EAAAA,cACF,EACA,SAAU,6BACV,KAAM,kIAEN,cAAe,6BACf,YAAa,IAAA,EACf,EAgBMsC,EACJ,kFACIC,EAAkB,wBASlBC,EAAiB1C,EAAAA,GACrB,wCACA,yFACA,iEACA,mFACA,0EACF,EAEM2C,EAAwB3C,EAAAA,GAC5B,0LAEA,8JACAC,EAAAA,cACF,EAYA,SAAS2C,EAAe,EAA+C,CACrE,GAAIC,EAAM,SAAW,GAAKA,EAAM,SAAWA,EAAM,SAAWA,EAAM,UAAYA,EAAM,OAClF,MAAO,GAET,IAAMC,EAAOD,EAAM,cAC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A,YAAYgF,EAAS,OAAO,EAa5B,SAASC,EAAW,EAAqE,CACvF,IAAM1C,EAAU/C,EAAAA,cAAc,aAAa,EAC3CwB,EAAA,YAAYuB,EAAS,OAAQF,EAAM,KAAK,EACxCrB,EAAA,kBAAkBuB,EAASF,EAAM,KAAK,EACtC,IAAMO,EAASnD,EAAM,WAAWC,EAAAA,gBAAgB,EAE1CsD,EAAcrD,EAAAA,MAAM,eAAe,EACzC,OAAOwC,EACLE,EACAE,EACAK,EACAlB,EACA,CACE,KAAMxB,EAAAA,qBAAqB,KAC3B,SAAUA,EAAAA,qBAAqB,SAC/B,QAASA,EAAAA,qBAAqB,OAChC,EACA,GACA8C,CACF,CACF,CACA,EAAW,YAAc,aACzBhD,EAAAA,YAAYiF,EAAY,OAAO,EAmC/B,IAAaC,EAAsB,OAAO,OAAO/E,EAAAA,QAAS,CACxD,SAAU2D,EACV,KAAMkB,EACN,QAASC,EACT,cAAe7E,EAAAA,iBACf,QAASC,EAAAA,WACT,QAASC,EAAAA,WACT,cAAeC,EAAAA,gBACjB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs"),n=require("../../lib/dev.cjs");let r=require("react");r=e.__toESM(r,1);function i(){let e=new Map,t=new Set,n=()=>t.forEach(e=>e());return{record(t,r){(e.get(t)??null)!==r&&(r===null?e.delete(t):e.set(t,r),n())},forget(t,r){e.get(t)===r&&(e.delete(t),n())},get:t=>e.get(t),subscribe(e){return t.add(e),()=>{t.delete(e)}}}}var a=r.createContext(null);a.displayName=`NavContext`;var o=()=>{},s={value:``,select:o,openCategories:[],toggleCategory:o,registerValue:()=>o,currentCategory:void 0,categoryStore:{record:o,forget:o,get:()=>void 0,subscribe:()=>o}},c=r.createContext(null);c.displayName=`NavCategoryValueContext`;function l(e){return r.useContext(a)||(n.reportMissingContext(e,`Nav`),s)}function u(e,t,n){let{registerValue:i}=e;r.useEffect(()=>i(t,n),[i,t,n])}function d(e,t){let n=r.useContext(c),{categoryStore:i}=e;r.useLayoutEffect(()=>{i.record(t,n)},[i,t,n])}var f=r.createContext(null);f.displayName=`NavRovingContext`;var p=Symbol.for(`wave.navPart`);function m(e,t){return e[p]=t,e}function h(e){let n=t.getElementType(e,{suspend:!1});if(typeof n!=`function`&&typeof n!=`object`||n===null)return null;let r=n[p];return r===`entry`||r===`category`?r:null}function g(e){let{children:t}=e.props;return typeof t==`function`?void 0:t}function _(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&typeof e.then==`function`}function v(e,t){if(Array.isArray(e)){for(let n of e)v(n,t);return}try{r.Children.forEach(e,e=>{r.isValidElement(e)&&t(e)})}catch(e){if(!_(e))throw e}}function y(e,t){let n=!1;return v(e,e=>{n||=h(e)===`entry`&&e.props.value===t||y(g(e),t)}),n}function b(e,t){let n=[];if(!t)return n;let r=e=>{v(e,e=>{let i=g(e);h(e)===`category`&&typeof e.props.value==`string`&&y(i,t)&&n.push(e.props.value),r(i)})};return r(e),n}var x={items:`Use the Nav parts (Nav.Item, Nav.Category, Nav.SectionHeader, Nav.Divider, Nav.AppItem, Nav.AppItemStatic) as its children, or wrap your own content in an <li>.`,"sub-items":`Use Nav.SubItem, Nav.SectionHeader and Nav.Divider as its children, or wrap your own content in an <li>.`},S=new Set([`li`,`script`,`template`]);function C(e){for(let t of Array.from(e.childNodes))if(t.nodeType===Node.ELEMENT_NODE){let e=t.localName.toLowerCase();if(!S.has(e))return`a <${e}> element`}else if(t.nodeType===Node.TEXT_NODE&&(t.textContent??``).trim()!==``)return`text`;return null}function w(e,t,i){r.useEffect(()=>{if(!n.isDev)return;let r=`${t}:list-child`,a=e.current;if(!a||n.hasWarned(r))return;let o=C(a);o!==null&&n.warnOnce(r,`${t}: its list holds ${o}, but a list can hold only <li> elements. ${x[i]}`)})}exports.NavCategoryValueContext=c,exports.NavContext=a,exports.NavRovingContext=f,exports.containsValue=y,exports.createCategoryStore=i,exports.findCategoriesContaining=b,exports.getNavPartKind=h,exports.markNavPart=m,exports.useNavContext=l,exports.useNavListChildCheck=w,exports.useNavValue=u,exports.useRecordCategory=d;
|
|
2
|
+
//# sourceMappingURL=Nav.context.cjs.map
|