@mortenbrudvik/waveui 0.14.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/README.md +413 -53
  2. package/dist/components/data-display/InfoButton.cjs +1 -1
  3. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  4. package/dist/components/data-display/InfoButton.mjs +90 -82
  5. package/dist/components/data-display/InfoButton.mjs.map +1 -1
  6. package/dist/components/data-display/InfoLabel.cjs +1 -1
  7. package/dist/components/data-display/InfoLabel.cjs.map +1 -1
  8. package/dist/components/data-display/InfoLabel.mjs +19 -18
  9. package/dist/components/data-display/InfoLabel.mjs.map +1 -1
  10. package/dist/components/data-display/List.cjs +1 -1
  11. package/dist/components/data-display/List.cjs.map +1 -1
  12. package/dist/components/data-display/List.mjs +405 -219
  13. package/dist/components/data-display/List.mjs.map +1 -1
  14. package/dist/components/data-display/List.registry.cjs +1 -1
  15. package/dist/components/data-display/List.registry.cjs.map +1 -1
  16. package/dist/components/data-display/List.registry.mjs +12 -6
  17. package/dist/components/data-display/List.registry.mjs.map +1 -1
  18. package/dist/components/feedback/MessageBarGroup.cjs +2 -0
  19. package/dist/components/feedback/MessageBarGroup.cjs.map +1 -0
  20. package/dist/components/feedback/MessageBarGroup.mjs +63 -0
  21. package/dist/components/feedback/MessageBarGroup.mjs.map +1 -0
  22. package/dist/components/feedback/ProgressBar.cjs +1 -1
  23. package/dist/components/feedback/ProgressBar.cjs.map +1 -1
  24. package/dist/components/feedback/ProgressBar.mjs +41 -39
  25. package/dist/components/feedback/ProgressBar.mjs.map +1 -1
  26. package/dist/components/feedback/Toaster.cjs +1 -1
  27. package/dist/components/feedback/Toaster.cjs.map +1 -1
  28. package/dist/components/feedback/Toaster.mjs +222 -216
  29. package/dist/components/feedback/Toaster.mjs.map +1 -1
  30. package/dist/components/input/Combobox.cjs +1 -1
  31. package/dist/components/input/Combobox.cjs.map +1 -1
  32. package/dist/components/input/Combobox.mjs +163 -148
  33. package/dist/components/input/Combobox.mjs.map +1 -1
  34. package/dist/components/input/Dropdown.cjs +1 -1
  35. package/dist/components/input/Dropdown.cjs.map +1 -1
  36. package/dist/components/input/Dropdown.mjs +132 -117
  37. package/dist/components/input/Dropdown.mjs.map +1 -1
  38. package/dist/components/input/Listbox.cjs +1 -1
  39. package/dist/components/input/Listbox.cjs.map +1 -1
  40. package/dist/components/input/Listbox.mjs +90 -78
  41. package/dist/components/input/Listbox.mjs.map +1 -1
  42. package/dist/components/input/Option.cjs +1 -1
  43. package/dist/components/input/Option.cjs.map +1 -1
  44. package/dist/components/input/Option.data.cjs +2 -0
  45. package/dist/components/input/Option.data.cjs.map +1 -0
  46. package/dist/components/input/Option.data.mjs +114 -0
  47. package/dist/components/input/Option.data.mjs.map +1 -0
  48. package/dist/components/input/Option.mjs +21 -17
  49. package/dist/components/input/Option.mjs.map +1 -1
  50. package/dist/components/layout/Accordion.cjs +1 -1
  51. package/dist/components/layout/Accordion.cjs.map +1 -1
  52. package/dist/components/layout/Accordion.mjs +124 -109
  53. package/dist/components/layout/Accordion.mjs.map +1 -1
  54. package/dist/components/layout/Carousel.cjs +1 -1
  55. package/dist/components/layout/Carousel.cjs.map +1 -1
  56. package/dist/components/layout/Carousel.mjs +207 -193
  57. package/dist/components/layout/Carousel.mjs.map +1 -1
  58. package/dist/components/layout/FlatTree.cjs +2 -0
  59. package/dist/components/layout/FlatTree.cjs.map +1 -0
  60. package/dist/components/layout/FlatTree.context.cjs +2 -0
  61. package/dist/components/layout/FlatTree.context.cjs.map +1 -0
  62. package/dist/components/layout/FlatTree.context.mjs +20 -0
  63. package/dist/components/layout/FlatTree.context.mjs.map +1 -0
  64. package/dist/components/layout/FlatTree.item.cjs +2 -0
  65. package/dist/components/layout/FlatTree.item.cjs.map +1 -0
  66. package/dist/components/layout/FlatTree.item.mjs +90 -0
  67. package/dist/components/layout/FlatTree.item.mjs.map +1 -0
  68. package/dist/components/layout/FlatTree.mjs +276 -0
  69. package/dist/components/layout/FlatTree.mjs.map +1 -0
  70. package/dist/components/layout/TabList.cjs +1 -1
  71. package/dist/components/layout/TabList.cjs.map +1 -1
  72. package/dist/components/layout/TabList.mjs +149 -108
  73. package/dist/components/layout/TabList.mjs.map +1 -1
  74. package/dist/components/layout/Tree.cjs.map +1 -1
  75. package/dist/components/layout/Tree.context.cjs +1 -1
  76. package/dist/components/layout/Tree.context.cjs.map +1 -1
  77. package/dist/components/layout/Tree.context.mjs +2 -1
  78. package/dist/components/layout/Tree.context.mjs.map +1 -1
  79. package/dist/components/layout/Tree.core.cjs +1 -1
  80. package/dist/components/layout/Tree.core.cjs.map +1 -1
  81. package/dist/components/layout/Tree.core.mjs +162 -148
  82. package/dist/components/layout/Tree.core.mjs.map +1 -1
  83. package/dist/components/layout/Tree.mjs.map +1 -1
  84. package/dist/components/layout/Tree.selection.cjs +1 -1
  85. package/dist/components/layout/Tree.selection.cjs.map +1 -1
  86. package/dist/components/layout/Tree.selection.mjs +11 -57
  87. package/dist/components/layout/Tree.selection.mjs.map +1 -1
  88. package/dist/components/layout/useFlatTree.cjs +2 -0
  89. package/dist/components/layout/useFlatTree.cjs.map +1 -0
  90. package/dist/components/layout/useFlatTree.mjs +83 -0
  91. package/dist/components/layout/useFlatTree.mjs.map +1 -0
  92. package/dist/components/navigation/Menu.popover.cjs +1 -1
  93. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  94. package/dist/components/navigation/Menu.popover.mjs +154 -168
  95. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  96. package/dist/components/navigation/Nav.cjs +1 -1
  97. package/dist/components/navigation/Nav.cjs.map +1 -1
  98. package/dist/components/navigation/Nav.mjs +156 -136
  99. package/dist/components/navigation/Nav.mjs.map +1 -1
  100. package/dist/components/navigation/NavDrawer.cjs +1 -1
  101. package/dist/components/navigation/NavDrawer.cjs.map +1 -1
  102. package/dist/components/navigation/NavDrawer.mjs +48 -45
  103. package/dist/components/navigation/NavDrawer.mjs.map +1 -1
  104. package/dist/components/overlays/Dialog.cjs +1 -1
  105. package/dist/components/overlays/Dialog.cjs.map +1 -1
  106. package/dist/components/overlays/Dialog.mjs +128 -122
  107. package/dist/components/overlays/Dialog.mjs.map +1 -1
  108. package/dist/components/overlays/Dialog.slots.cjs +1 -1
  109. package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
  110. package/dist/components/overlays/Dialog.slots.mjs +12 -12
  111. package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
  112. package/dist/components/overlays/Drawer.cjs.map +1 -1
  113. package/dist/components/overlays/Drawer.mjs.map +1 -1
  114. package/dist/components/overlays/Drawer.panel.cjs +1 -1
  115. package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
  116. package/dist/components/overlays/Drawer.panel.mjs +97 -81
  117. package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
  118. package/dist/components/overlays/Drawer.root.cjs +1 -1
  119. package/dist/components/overlays/Drawer.root.cjs.map +1 -1
  120. package/dist/components/overlays/Drawer.root.mjs +34 -31
  121. package/dist/components/overlays/Drawer.root.mjs.map +1 -1
  122. package/dist/components/overlays/Popover.cjs +1 -1
  123. package/dist/components/overlays/Popover.cjs.map +1 -1
  124. package/dist/components/overlays/Popover.mjs +231 -216
  125. package/dist/components/overlays/Popover.mjs.map +1 -1
  126. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  127. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  128. package/dist/components/overlays/TeachingPopover.parts.cjs +1 -1
  129. package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -1
  130. package/dist/components/overlays/TeachingPopover.parts.mjs +199 -177
  131. package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -1
  132. package/dist/components/overlays/TeachingPopover.root.cjs +1 -1
  133. package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -1
  134. package/dist/components/overlays/TeachingPopover.root.mjs +93 -92
  135. package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -1
  136. package/dist/components/overlays/Tooltip.cjs +1 -1
  137. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  138. package/dist/components/overlays/Tooltip.mjs +66 -61
  139. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  140. package/dist/components/provider/WaveProvider.cjs +1 -1
  141. package/dist/components/provider/WaveProvider.cjs.map +1 -1
  142. package/dist/components/provider/WaveProvider.mjs +26 -23
  143. package/dist/components/provider/WaveProvider.mjs.map +1 -1
  144. package/dist/components/table/DataGrid.cjs +1 -1
  145. package/dist/components/table/DataGrid.cjs.map +1 -1
  146. package/dist/components/table/DataGrid.context.cjs +2 -0
  147. package/dist/components/table/DataGrid.context.cjs.map +1 -0
  148. package/dist/components/table/DataGrid.context.mjs +74 -0
  149. package/dist/components/table/DataGrid.context.mjs.map +1 -0
  150. package/dist/components/table/DataGrid.header.cjs +2 -0
  151. package/dist/components/table/DataGrid.header.cjs.map +1 -0
  152. package/dist/components/table/DataGrid.header.mjs +168 -0
  153. package/dist/components/table/DataGrid.header.mjs.map +1 -0
  154. package/dist/components/table/DataGrid.mjs +488 -591
  155. package/dist/components/table/DataGrid.mjs.map +1 -1
  156. package/dist/components/table/DataGrid.sizing.cjs +2 -0
  157. package/dist/components/table/DataGrid.sizing.cjs.map +1 -0
  158. package/dist/components/table/DataGrid.sizing.mjs +187 -0
  159. package/dist/components/table/DataGrid.sizing.mjs.map +1 -0
  160. package/dist/components/table/DataGrid.store.cjs +2 -0
  161. package/dist/components/table/DataGrid.store.cjs.map +1 -0
  162. package/dist/components/table/DataGrid.store.mjs +108 -0
  163. package/dist/components/table/DataGrid.store.mjs.map +1 -0
  164. package/dist/components/table/DataGrid.window.cjs +2 -0
  165. package/dist/components/table/DataGrid.window.cjs.map +1 -0
  166. package/dist/components/table/DataGrid.window.mjs +165 -0
  167. package/dist/components/table/DataGrid.window.mjs.map +1 -0
  168. package/dist/components/table/Table.cjs +1 -1
  169. package/dist/components/table/Table.cjs.map +1 -1
  170. package/dist/components/table/Table.mjs +74 -72
  171. package/dist/components/table/Table.mjs.map +1 -1
  172. package/dist/components/table/Table.resize.cjs +2 -0
  173. package/dist/components/table/Table.resize.cjs.map +1 -0
  174. package/dist/components/table/Table.resize.mjs +98 -0
  175. package/dist/components/table/Table.resize.mjs.map +1 -0
  176. package/dist/components/table/useGridNavigation.cjs +1 -1
  177. package/dist/components/table/useGridNavigation.cjs.map +1 -1
  178. package/dist/components/table/useGridNavigation.mjs +343 -140
  179. package/dist/components/table/useGridNavigation.mjs.map +1 -1
  180. package/dist/components/table/useTableColumnSizing.cjs +2 -0
  181. package/dist/components/table/useTableColumnSizing.cjs.map +1 -0
  182. package/dist/components/table/useTableColumnSizing.mjs +76 -0
  183. package/dist/components/table/useTableColumnSizing.mjs.map +1 -0
  184. package/dist/components/table/useTableFeatures.cjs +2 -0
  185. package/dist/components/table/useTableFeatures.cjs.map +1 -0
  186. package/dist/components/table/useTableFeatures.mjs +110 -0
  187. package/dist/components/table/useTableFeatures.mjs.map +1 -0
  188. package/dist/components/table/useTableSelection.cjs +2 -0
  189. package/dist/components/table/useTableSelection.cjs.map +1 -0
  190. package/dist/components/table/useTableSelection.mjs +39 -0
  191. package/dist/components/table/useTableSelection.mjs.map +1 -0
  192. package/dist/components/table/useTableSort.cjs +2 -0
  193. package/dist/components/table/useTableSort.cjs.map +1 -0
  194. package/dist/components/table/useTableSort.mjs +58 -0
  195. package/dist/components/table/useTableSort.mjs.map +1 -0
  196. package/dist/hooks/useActiveDescendant.cjs +1 -1
  197. package/dist/hooks/useActiveDescendant.cjs.map +1 -1
  198. package/dist/hooks/useActiveDescendant.mjs +33 -25
  199. package/dist/hooks/useActiveDescendant.mjs.map +1 -1
  200. package/dist/hooks/useCollapsePresence.cjs +2 -0
  201. package/dist/hooks/useCollapsePresence.cjs.map +1 -0
  202. package/dist/hooks/useCollapsePresence.mjs +21 -0
  203. package/dist/hooks/useCollapsePresence.mjs.map +1 -0
  204. package/dist/hooks/useFocusBeforeClose.cjs +2 -0
  205. package/dist/hooks/useFocusBeforeClose.cjs.map +1 -0
  206. package/dist/hooks/useFocusBeforeClose.mjs +33 -0
  207. package/dist/hooks/useFocusBeforeClose.mjs.map +1 -0
  208. package/dist/hooks/useListbox.cjs +1 -1
  209. package/dist/hooks/useListbox.cjs.map +1 -1
  210. package/dist/hooks/useListbox.mjs +140 -130
  211. package/dist/hooks/useListbox.mjs.map +1 -1
  212. package/dist/hooks/useMotion.cjs +2 -0
  213. package/dist/hooks/useMotion.cjs.map +1 -0
  214. package/dist/hooks/useMotion.mjs +14 -0
  215. package/dist/hooks/useMotion.mjs.map +1 -0
  216. package/dist/hooks/usePresenceGroup.cjs +2 -0
  217. package/dist/hooks/usePresenceGroup.cjs.map +1 -0
  218. package/dist/hooks/usePresenceGroup.mjs +68 -0
  219. package/dist/hooks/usePresenceGroup.mjs.map +1 -0
  220. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  221. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  222. package/dist/hooks/useRovingTabIndex.mjs +1 -1
  223. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  224. package/dist/hooks/useSelection.cjs +2 -0
  225. package/dist/hooks/useSelection.cjs.map +1 -0
  226. package/dist/hooks/useSelection.mjs +57 -0
  227. package/dist/hooks/useSelection.mjs.map +1 -0
  228. package/dist/hooks/useVirtualWindow.cjs +2 -0
  229. package/dist/hooks/useVirtualWindow.cjs.map +1 -0
  230. package/dist/hooks/useVirtualWindow.mjs +102 -0
  231. package/dist/hooks/useVirtualWindow.mjs.map +1 -0
  232. package/dist/index.cjs +1 -1
  233. package/dist/index.d.cts +2249 -179
  234. package/dist/index.d.ts +2249 -179
  235. package/dist/index.mjs +147 -135
  236. package/dist/lib/classNames.cjs +1 -1
  237. package/dist/lib/classNames.cjs.map +1 -1
  238. package/dist/lib/classNames.mjs +125 -95
  239. package/dist/lib/classNames.mjs.map +1 -1
  240. package/dist/lib/columnSizing.cjs +2 -0
  241. package/dist/lib/columnSizing.cjs.map +1 -0
  242. package/dist/lib/columnSizing.mjs +27 -0
  243. package/dist/lib/columnSizing.mjs.map +1 -0
  244. package/dist/lib/flatTree.cjs +2 -0
  245. package/dist/lib/flatTree.cjs.map +1 -0
  246. package/dist/lib/flatTree.mjs +118 -0
  247. package/dist/lib/flatTree.mjs.map +1 -0
  248. package/dist/lib/motion.cjs +2 -0
  249. package/dist/lib/motion.cjs.map +1 -0
  250. package/dist/lib/motion.mjs +43 -0
  251. package/dist/lib/motion.mjs.map +1 -0
  252. package/dist/lib/selection.cjs +2 -0
  253. package/dist/lib/selection.cjs.map +1 -0
  254. package/dist/lib/selection.mjs +28 -0
  255. package/dist/lib/selection.mjs.map +1 -0
  256. package/dist/lib/treeCascade.cjs +2 -0
  257. package/dist/lib/treeCascade.cjs.map +1 -0
  258. package/dist/lib/treeCascade.mjs +52 -0
  259. package/dist/lib/treeCascade.mjs.map +1 -0
  260. package/dist/lib/virtual.cjs +2 -0
  261. package/dist/lib/virtual.cjs.map +1 -0
  262. package/dist/lib/virtual.mjs +54 -0
  263. package/dist/lib/virtual.mjs.map +1 -0
  264. package/dist/styles.css +1 -1
  265. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.core.mjs","names":["useId","useId$1","React","EMPTY","ITEM_IN_LABEL_MESSAGE","warnDuplicateValue","value","SELECTED_WITH_MULTIPLE_MESSAGE","CHECKED_WITHOUT_MULTIPLE_MESSAGE","SINGLE_WITHOUT_SELECTED_MESSAGE","forestInTreeOrder","entries","entry","a","b","TREE_ITEM_SELECTOR","ACTION_ITEM_SELECTOR","ACTIONS_ON_ITEM_FOCUS","ASIDE_OFF_ON_ITEM_FOCUS","ACTIONS_VISIBILITY","ASIDE_OFF_WITH_ACTIONS","END_CELL_SHARED","focusFirstAction","toolbar","item","cssHidden","el","isHiddenInput","concealed","marker","TreeRoot","rest","initialExpanded","defaultExpandedItems","expandedList","setExpandedList","useControllable","expandedItems","onExpandedItemsChange","next","expanded","toggle","prev","v","expand","added","values","activate","useEventCallback","initialChecked","defaultCheckedItems","pendingDetails","checkedList","setCheckedList","checkedItems","onCheckedItemsChange","checked","topLevel","registerTopLevel","toggleChecked","forest","toggleCheck","previous","effectiveSelected","selectionMode","selected","warnOnce","hasCheckedProps","focusedItem","setFocusedItem","valueCounts","registerValue","isDev","counts","count","remaining","useRovingTabIndex","context","current","getTabIndex","focusValue","navigationMode","mergedRef","useMergedRefs","ref","containerProps","handleKeyDown","event","syncTypeaheadText","handleKeyDownCapture","handleBlur","TreeContext","TreeParentContext","TreeCheckForcedContext","cn","treeClassNames","className","composeEventHandlers","onKeyDown","onKeyDownCapture","onFocus","onBlur","TreeLabelContext","label","treeitem","personaName","text","isOwnKeyEvent","target","isOwnClick","TreeItemActions","treegrid","rovingRef","rovingKeyDown","rovingFocus","popupFocus","setPopupFocus","frame","handleToolbarFocus","handleToolbarBlur","isOwnEvent","popup","isEditableTarget","getArrowIntent","getDirection","labelledBy","isPrev","onReturn","treeItemClassNames","TreeItem","props","typeaheadText","ctx","useTreeContext","parent","insideLabel","isExpanded","labelId","asideId","ancestorListed","itemRef","layoutIds","setLayoutIds","registerLayout","ids","itemContext","nameId","nestedItems","labelContent","firstChildValue","children","child","keyed","key","isElementOfType","iconNode","icon","slotRendersContent","renderSlot","iconAfterNode","iconAfter","hasAside","aside","hasActions","actions","hasChildren","leaf","chevron","expandIcon","ChevronRightIcon","multiple","ownNode","collectItems","checkState","computeCheckStates","selectionEntry","isTopLevel","isSelected","isCurrent","handleClick","onClick","siblings","intent","focusedAction","inOwnActions","handleFocus","handleActionsBlur","action","active","checkbox","forcedColors","SubtractIcon","CheckIcon","radio","indicator","groupListed","joinIds","TreeItemContext","materialiseSlotContent"],"sources":["../../../src/components/layout/Tree.core.tsx"],"sourcesContent":["import * as React from 'react';\nimport { joinIds } from '../../lib/aria';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { treeClassNames, treeItemClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { isHiddenInput } from '../../lib/focus';\nimport { CheckIcon, ChevronRightIcon, SubtractIcon } from '../../lib/icons';\nimport type { SelectionMode } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { isHiddenByCss, useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport {\n TreeCheckForcedContext,\n TreeContext,\n TreeItemContext,\n TreeLabelContext,\n TreeParentContext,\n useTreeContext,\n type PersonaLayoutIds,\n type TreeContextValue,\n type TreeItemContextValue,\n type TreeSelectionEntry,\n} from './Tree.context';\nimport {\n collectItems,\n computeCheckStates,\n toggleCheck,\n type CheckState,\n type TreeNode,\n} from './Tree.selection';\n\nconst EMPTY: readonly string[] = [];\n\nconst ITEM_IN_LABEL_MESSAGE =\n 'Tree.Item was rendered inside the label of another Tree.Item, so it is not part of that ' +\n \"item's child group: the parent cannot expand, its name includes the nested text, and a \" +\n 'treeitem sits inside a label (axe aria-required-parent). A Tree.Item finds its nested items ' +\n 'among its own children (written directly, in Fragments, or returned by a render function such ' +\n 'as `children.map(renderNode)`), but not inside a component that renders Tree.Item itself. ' +\n 'Build a data-driven tree with a render function instead of a recursive component.';\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Tree:duplicate:${value}`,\n `Tree: several items share the value \"${value}\". Item values must be unique within a Tree; ` +\n 'items with the same value share their expanded, selected and focus state.',\n );\n}\n\nconst SELECTED_WITH_MULTIPLE_MESSAGE =\n 'Tree: `selected` has no effect with selectionMode=\"multiple\"; use `checkedItems`, and ' +\n '`current` for the item the user is on.';\n\nconst CHECKED_WITHOUT_MULTIPLE_MESSAGE =\n 'Tree: `checkedItems` and `defaultCheckedItems` need selectionMode=\"multiple\"; without it the ' +\n 'tree draws no checkboxes and ignores them.';\n\nconst SINGLE_WITHOUT_SELECTED_MESSAGE =\n 'Tree: selectionMode=\"single\" draws a radio on every item for `selected`; pass `selected` ' +\n '(null while nothing is selected) and update it from `onItemSelect`.';\n\n/** The registered top-level subtrees in document order, which is the tree order of their items. */\nfunction forestInTreeOrder(\n entries: ReadonlySet<React.RefObject<TreeSelectionEntry | null>> | null,\n): TreeNode[] {\n if (!entries) return [];\n return Array.from(entries, (entry) => entry.current)\n .filter((entry): entry is TreeSelectionEntry => entry !== null)\n .sort((a, b) => {\n if (!a.element || !b.element || a.element === b.element) return 0;\n return a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1;\n })\n .map((entry) => entry.node);\n}\n\n/**\n * The tree's own items for the tab stop and the arrow keys: the treeitems. A row's actions are a\n * roving container of their own, which the default selector would count as one more item.\n */\nconst TREE_ITEM_SELECTOR = '[role=\"treeitem\"]';\n\n/** Every focusable control a row's actions can hold (Toolbar's rule). */\nconst ACTION_ITEM_SELECTOR = 'button, [href], input, select, textarea, [role=\"button\"], [tabindex]';\n\n/**\n * Shows a row's actions while focus is on its item (also after a click) or inside the item's own\n * row, never in its child group, so Tab and the treegrid arrows reach them. The item's\n * `:focus-within`, not its `:focus`: while focus moves from the item into an action, Chromium has\n * already ended the item's `:focus` (but keeps `:focus-within` on it, the common ancestor) when it\n * checks that the action can take focus, and a hidden action refuses it.\n */\nconst ACTIONS_ON_ITEM_FOCUS =\n '[&:focus-within:not(:has(>[role=group]_:focus))>[data-tree-row]_[data-tree-actions]]:visible';\n\n/** Makes the aside invisible while its actions show for focus, where they take its place. */\nconst ASIDE_OFF_ON_ITEM_FOCUS =\n '[@media(hover:hover)]:not-forced-colors:[&:focus-within:not(:has(>[role=group]_:focus))>[data-tree-row]_[data-tree-aside]]:invisible';\n\n/**\n * The actions stay invisible until the row is hovered or the item or an action has focus, and\n * always show in forced colors and without hover (touch). An invisible action takes no focus.\n * They also show while a surface opened from an action is open (its trigger is expanded) and\n * while focus is in such a surface (`data-focus-in-popup`), so the surface's focus return, which\n * runs after its trigger already reports it closed, reaches the action.\n */\nconst ACTIONS_VISIBILITY =\n 'invisible group-hover/row:visible focus-within:visible forced-colors:visible [@media(hover:none)]:visible has-[[aria-expanded=true]]:visible data-[focus-in-popup]:visible';\n\n/** The aside gives way to the actions where the two share one place. */\nconst ASIDE_OFF_WITH_ACTIONS =\n 'not-forced-colors:group-hover/row:invisible [@media(hover:hover)]:not-forced-colors:group-focus-within/end:invisible [@media(hover:hover)]:not-forced-colors:group-has-[[aria-expanded=true]]/end:invisible [@media(hover:hover)]:not-forced-colors:group-has-[[data-focus-in-popup]]/end:invisible';\n\n/** Aside and actions share one cell, and sit side by side where the actions always show. */\nconst END_CELL_SHARED = '[&>*]:[grid-area:1/1] forced-colors:flex [@media(hover:none)]:flex';\n\n/**\n * Focuses the first action of an item's own row that takes focus, trying them in order and\n * skipping what the roving hook skips: natively disabled, marked `data-roving-disabled`,\n * `aria-disabled` unless focusable-disabled, hidden form inputs, anything inside a `hidden` or\n * `inert` element of the toolbar, and what CSS hides (the hook's own `isHiddenByCss`). `false` when\n * focus did not move into the row's actions.\n */\nfunction focusFirstAction(item: HTMLElement): boolean {\n const toolbar = item.querySelector<HTMLElement>(':scope > [data-tree-row] [data-tree-actions]');\n if (!toolbar) return false;\n const cssHidden = new Map<Element, boolean>();\n for (const el of Array.from(toolbar.querySelectorAll<HTMLElement>(ACTION_ITEM_SELECTOR))) {\n if (isHiddenInput(el) || el.matches(':disabled')) continue;\n const concealed = el.closest('[hidden], [inert]');\n if (concealed && toolbar.contains(concealed)) continue;\n const marker = el.getAttribute('data-roving-disabled');\n if (marker !== null && marker !== 'false') continue;\n if (\n el.getAttribute('aria-disabled') === 'true' &&\n !el.hasAttribute('data-disabled-focusable')\n ) {\n continue;\n }\n if (isHiddenByCss(el, toolbar, cssHidden)) continue;\n el.focus();\n if (el.ownerDocument.activeElement === el) return true;\n }\n return false;\n}\n\n/* ------------------------------------------------------------------ */\n/* Tree */\n/* ------------------------------------------------------------------ */\n\n/** The second argument of `onCheckedItemsChange`. */\nexport interface TreeCheckedItemsChangeDetails {\n /** The item that was toggled. */\n value: string;\n /** Its new state (a toggle never leaves it mixed). */\n checked: boolean;\n /** The DOM event of the toggle: a keyboard event for Space, a mouse event for a click. */\n event: Event;\n}\n\n/** Properties for the Tree component. */\nexport interface TreeProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Controlled list of expanded item values. */\n expandedItems?: readonly string[];\n /**\n * Item values that are expanded initially (uncontrolled).\n * @default []\n */\n defaultExpandedItems?: readonly string[];\n /** Called with the new list of expanded item values when an item expands or collapses. */\n onExpandedItemsChange?: (expandedItems: string[]) => void;\n /**\n * Called with an item's value every time it is activated (a click on its row, Enter, or Space\n * unless the tree has checkboxes), also when the same item is activated again.\n */\n onItemSelect?: (value: string) => void;\n /**\n * Value of the selected item. When set (also to `null`), every item carries `aria-selected`, and\n * the selected item is where keyboard focus enters the tree. It has no effect with\n * `selectionMode=\"multiple\"` (a development warning): items carry `aria-checked` instead. With\n * `selectionMode=\"single\"` every item carries `aria-selected` even while it is not set (a\n * development warning: the radios need it).\n */\n selected?: string | null;\n /** Value of the current item (for example the open page): it gets `aria-current=\"true\"`. */\n current?: string | null;\n /**\n * How items are selected. `'none'`: activation only (0.7; `selected` highlights one item).\n * `'single'`: a radio indicator on every item for `selected`/`onItemSelect`. `'multiple'`: a\n * checkbox on every item, bound to `checkedItems`; checking an item checks its descendants, and a\n * parent shows checked, mixed or unchecked from them. Fluent's `'multiselect'` is `'multiple'`.\n * @default 'none'\n */\n selectionMode?: 'none' | SelectionMode;\n /** Controlled checked items (`selectionMode=\"multiple\"`); see the cascade rule in the component docs. */\n checkedItems?: readonly string[];\n /**\n * Initially checked items (uncontrolled).\n * @default []\n */\n defaultCheckedItems?: readonly string[];\n /**\n * Called with every checked item (in tree order) when a check changes (Fluent's `onCheckedChange`).\n * WaveUI always passes `details`; it is typed optional until 1.0.\n */\n onCheckedItemsChange?: (checkedItems: string[], details?: TreeCheckedItemsChangeDetails) => void;\n /**\n * `'tree'`: Tab from a focused item enters its actions. `'treegrid'`: the \"next\" arrow\n * (ArrowRight, ArrowLeft in RTL) moves into an item's actions and \"previous\" returns; on an\n * expanded parent \"next\" no longer moves to the first child (ArrowDown does). The roles stay\n * `tree` and `treeitem` (Fluent's `navigationMode`).\n * @default 'tree'\n */\n navigationMode?: 'tree' | 'treegrid';\n /** Ref to the `role=\"tree\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport const TreeRoot = ({\n expandedItems,\n defaultExpandedItems,\n onExpandedItemsChange,\n onItemSelect,\n selected,\n current,\n selectionMode = 'none',\n navigationMode = 'tree',\n checkedItems,\n defaultCheckedItems,\n onCheckedItemsChange,\n className,\n children,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onBlur,\n ref,\n ...rest\n}: TreeProps) => {\n const [initialExpanded] = React.useState<readonly string[]>(() => defaultExpandedItems ?? EMPTY);\n const [expandedList, setExpandedList] = useControllable<readonly string[]>(\n expandedItems,\n initialExpanded,\n (next) => onExpandedItemsChange?.([...next]),\n );\n const expanded = React.useMemo(() => new Set(expandedList), [expandedList]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setExpandedList((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n },\n [setExpandedList],\n );\n\n const expand = React.useCallback(\n (values: readonly string[]) => {\n setExpandedList((prev) => {\n const added = values.filter((v) => !prev.includes(v));\n return added.length > 0 ? [...prev, ...added] : prev;\n });\n },\n [setExpandedList],\n );\n\n const activate = useEventCallback((value: string) => {\n onItemSelect?.(value);\n });\n\n // Checked items (`selectionMode=\"multiple\"`). useControllable passes the value only, so a toggle\n // hands `details` to the change callback through a ref it writes and clears in the same event.\n const [initialChecked] = React.useState<readonly string[]>(() => defaultCheckedItems ?? EMPTY);\n const pendingDetails = React.useRef<TreeCheckedItemsChangeDetails | undefined>(undefined);\n const [checkedList, setCheckedList] = useControllable<readonly string[]>(\n checkedItems,\n initialChecked,\n (next) => onCheckedItemsChange?.([...next], pendingDetails.current),\n );\n const checked = React.useMemo(() => new Set(checkedList), [checkedList]);\n\n // The top-level items' subtrees (each item scans its own children), read when a check toggles:\n // they give the emitted list its tree order.\n const topLevel = React.useRef<Set<React.RefObject<TreeSelectionEntry | null>> | null>(null);\n const registerTopLevel = React.useCallback(\n (entry: React.RefObject<TreeSelectionEntry | null>) => {\n topLevel.current ??= new Set();\n const entries = topLevel.current;\n entries.add(entry);\n return () => {\n entries.delete(entry);\n };\n },\n [],\n );\n const toggleChecked = useEventCallback((value: string, event: Event) => {\n const forest = forestInTreeOrder(topLevel.current);\n setCheckedList((previous) => {\n const next = toggleCheck(forest, previous, value);\n pendingDetails.current = { value, checked: next.includes(value), event };\n return next;\n });\n pendingDetails.current = undefined;\n });\n\n // An item carries aria-checked or aria-selected, never both (APG); in single mode every item\n // carries aria-selected from the first render, so the radios and the state agree.\n const effectiveSelected =\n selectionMode === 'multiple'\n ? undefined\n : selectionMode === 'single'\n ? (selected ?? null)\n : selected;\n\n React.useEffect(() => {\n if (selectionMode === 'multiple' && selected !== undefined) {\n warnOnce('Tree:selected-with-multiple', SELECTED_WITH_MULTIPLE_MESSAGE);\n }\n }, [selectionMode, selected]);\n React.useEffect(() => {\n if (selectionMode === 'single' && selected === undefined) {\n warnOnce('Tree:single-without-selected', SINGLE_WITHOUT_SELECTED_MESSAGE);\n }\n }, [selectionMode, selected]);\n const hasCheckedProps = checkedItems !== undefined || defaultCheckedItems !== undefined;\n React.useEffect(() => {\n if (selectionMode !== 'multiple' && hasCheckedProps) {\n warnOnce('Tree:checked-without-multiple', CHECKED_WITHOUT_MULTIPLE_MESSAGE);\n }\n }, [selectionMode, hasCheckedProps]);\n\n // The item that has focus while focus is inside the tree: it holds the tab stop, so Shift+Tab\n // leaves the tree. Cleared when focus leaves; the next entry goes to `selected`, else the first.\n const [focusedItem, setFocusedItem] = React.useState<string | null>(null);\n\n // How many mounted items carry each value (written from the items' effects only).\n const valueCounts = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((value: string) => {\n if (!isDev) return () => {};\n valueCounts.current ??= new Map();\n const counts = valueCounts.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 { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: focusedItem ?? effectiveSelected ?? null,\n itemSelector: TREE_ITEM_SELECTOR,\n orientation: 'vertical',\n loop: false,\n typeahead: true,\n });\n\n const context = React.useMemo<TreeContextValue>(\n () => ({\n expanded,\n toggle,\n expand,\n activate,\n selected: effectiveSelected,\n current,\n getTabIndex,\n focusValue,\n onItemFocus: setFocusedItem,\n focusedItem,\n navigationMode,\n registerValue,\n selectionMode,\n checked,\n toggleChecked,\n registerTopLevel,\n }),\n [\n expanded,\n toggle,\n expand,\n activate,\n effectiveSelected,\n current,\n getTabIndex,\n focusValue,\n focusedItem,\n navigationMode,\n registerValue,\n selectionMode,\n checked,\n toggleChecked,\n registerTopLevel,\n ],\n );\n\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // Typeahead reads `data-roving-text` at key time: fill it from each item's label first.\n if (event.key.length === 1) syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDown(event);\n };\n\n // A Space that continues a search is typeahead too, taken before the item would activate on it.\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === ' ') syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDownCapture(event);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n const next = event.relatedTarget as Node | null;\n if (!next || !event.currentTarget.contains(next)) setFocusedItem(null);\n };\n\n return (\n <TreeContext.Provider value={context}>\n <TreeParentContext.Provider value={null}>\n <TreeCheckForcedContext.Provider value={false}>\n <div\n role=\"tree\"\n data-selection-mode={selectionMode}\n aria-multiselectable={selectionMode === 'multiple' ? true : undefined}\n className={cn(treeClassNames.root, 'text-body-1', className)}\n {...rest}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyDownCapture={composeEventHandlers(onKeyDownCapture, handleKeyDownCapture)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, handleBlur, { checkDefaultPrevented: false })}\n ref={mergedRef}\n >\n {/* A Tree has its own items, also when it renders inside a label (a portaled popup). */}\n <TreeLabelContext.Provider value={false}>{children}</TreeLabelContext.Provider>\n </div>\n </TreeCheckForcedContext.Provider>\n </TreeParentContext.Provider>\n </TreeContext.Provider>\n );\n};\nTreeRoot.displayName = 'Tree';\n\n/* ------------------------------------------------------------------ */\n/* Tree.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the TreeItem sub-component. */\nexport interface TreeItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this tree item. */\n value: string;\n /**\n * Icon displayed before the label. Rendered in a `<span>` hidden from assistive technology\n * (`aria-hidden`); pass a slot object (`{ className, children, … }`) to customise it. A falsy\n * icon (`''`, `0`) or a list of nothing renders no span.\n */\n icon?: Slot<'span'>;\n /** Icon after the label (decorative, `aria-hidden`; a falsy value renders nothing, as `icon`). */\n iconAfter?: Slot<'span'>;\n /**\n * Replaces the expand chevron (decorative). `null`/`undefined` keep the chevron; `false`, or\n * anything that renders nothing, hides it (`aria-expanded` still reports the state). Not rotated.\n */\n expandIcon?: Slot<'span'>;\n /**\n * Non-interactive content at the end of the row, such as a count or a badge. It describes the item\n * (`aria-describedby`); it hides while the actions show on hover or focus.\n */\n aside?: React.ReactNode;\n /**\n * Buttons at the end of the row (a toolbar named by the item's label). Shown while the row is\n * hovered or the item or its actions have focus, and always in forced colors and without hover\n * (touch). Tab reaches them from the focused item (`navigationMode=\"tree\"`), or the arrow keys do\n * (`\"treegrid\"`). Keys and clicks on them never activate or check the item.\n *\n * They also stay shown while a Menu, Popover or Dialog rendered inside them holds focus or its\n * trigger among them is expanded, so its focus return reaches the action. A dialog your app\n * renders elsewhere and opens from an action through state (a \"Delete…\" menu item that opens a\n * confirm Dialog) closes after the actions have hidden again (on devices with hover, outside\n * forced colors): a hidden action cannot take focus, so focus returns to the nearest element\n * that can, normally the item. Render such a Dialog inside `actions` (its `Dialog.Trigger`\n * there, or the controlled Dialog next to the Menu that opens it) to return focus to the action;\n * `finalFocusRef` cannot name it, since it is still hidden when the dialog closes.\n */\n actions?: React.ReactNode;\n /**\n * Renders the item as a leaf even when it has nested `Tree.Item`s: they are not rendered, and\n * the item has no `aria-expanded` and does not expand. An item is expandable only while it has\n * nested items, so `leaf={false}` does not make an item without them expandable. To load the\n * children on first expansion, give the item a placeholder child (a \"Loading…\" `Tree.Item`)\n * until they arrive.\n * @default false\n */\n leaf?: boolean;\n /** Ref to the `role=\"treeitem\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Sets the typeahead text (`data-roving-text`, read by the roving hook) of every rendered\n * treeitem to the text of its label (a persona layout's name when the label holds one), so neither\n * the icon nor the nested items take part. A consumer `data-roving-text` on a Tree.Item is kept on\n * its label and wins.\n */\nfunction syncTypeaheadText(tree: HTMLElement): void {\n tree.querySelectorAll<HTMLElement>('[role=\"treeitem\"]').forEach((treeitem) => {\n const label = treeitem.querySelector<HTMLElement>(\n ':scope > [data-tree-row] > [data-tree-label]',\n );\n if (!label) return;\n // A persona layout's name is the item's name, so it is its typeahead text too (not the media,\n // such as an avatar's initials, or the description).\n const personaName = label.querySelector<HTMLElement>('[data-tree-persona-name]');\n const text =\n label.getAttribute('data-roving-text') ?? personaName?.textContent ?? label.textContent ?? '';\n if (treeitem.getAttribute('data-roving-text') !== text) {\n treeitem.setAttribute('data-roving-text', text);\n }\n });\n}\n\n/**\n * Whether a keyboard event belongs to this treeitem: its target (the focused element) is this\n * treeitem or inside its row, not a nested item and not the row's actions (their keys are theirs).\n */\nfunction isOwnKeyEvent(event: React.KeyboardEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n if (target?.closest?.('[data-tree-actions]')) return false;\n return target?.closest?.('[role=\"treeitem\"]') === event.currentTarget;\n}\n\n/**\n * Whether a click landed on this treeitem's own row (or on the treeitem element itself). Clicks\n * in its child group, including the indentation gutter beside the nested rows, clicks on nested\n * items, on its checkbox and on its actions are not its own.\n */\nfunction isOwnClick(event: React.MouseEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n if (target === event.currentTarget) return true;\n if (target?.closest?.('[data-tree-checkbox], [data-tree-actions]')) return false;\n return target?.closest?.('[data-tree-row]')?.parentElement === event.currentTarget;\n}\n\ninterface TreeItemActionsProps {\n /** Id of the element that names the item. */\n labelledBy: string;\n /**\n * `'last-focused'` while the actions hold a Tab stop (their item has focus, tree mode), else\n * `'none'`.\n */\n tabStop: 'last-focused' | 'none';\n /** `'treegrid'`: the arrows do not wrap, and \"previous\" on the first action returns to the item. */\n navigationMode: 'tree' | 'treegrid';\n /** Moves focus back to the item. */\n onReturn: () => void;\n children: React.ReactNode;\n}\n\n/**\n * A row's actions: the consumer's controls rove with the arrow keys and hold at most one Tab\n * stop. A key pressed on an action is the action's: ArrowDown and ArrowUp on an action that opens\n * a popup (`aria-haspopup`) never move focus to another item. In treegrid navigation, \"previous\"\n * on the first action returns to the item.\n */\nconst TreeItemActions = ({\n labelledBy,\n tabStop,\n navigationMode,\n onReturn,\n children,\n}: TreeItemActionsProps) => {\n const treegrid = navigationMode === 'treegrid';\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleFocus: rovingFocus,\n } = useRovingTabIndex({\n itemSelector: ACTION_ITEM_SELECTOR,\n manageTabIndex: true,\n orientation: 'horizontal',\n loop: !treegrid,\n tabStop,\n });\n\n // Focus in a surface opened from an action (a Menu, Popover or Dialog rendered in a portal, whose\n // focus events reach the toolbar through the React tree): `'inside'`. Once focus leaves such a\n // surface for anywhere but the toolbar, `'leaving'` until the next frame, because the surface's\n // focus return comes later in that close (its layout phase, or a microtask).\n const [popupFocus, setPopupFocus] = React.useState<'inside' | 'leaving' | null>(null);\n React.useEffect(() => {\n if (popupFocus !== 'leaving') return;\n const frame = requestAnimationFrame(() => setPopupFocus(null));\n return () => cancelAnimationFrame(frame);\n }, [popupFocus]);\n\n const handleToolbarFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n rovingFocus(event);\n setPopupFocus(event.currentTarget.contains(event.target) ? null : 'inside');\n };\n\n const handleToolbarBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n // An action's own blur: its focus-within reveal decides.\n if (event.currentTarget.contains(event.target)) return;\n const next = event.relatedTarget;\n // Back to an action: its focus clears the hold.\n if (next instanceof Node && event.currentTarget.contains(next)) return;\n setPopupFocus('leaving');\n };\n\n /** Whether the key is treegrid's \"previous\" for an action (the roving order settles it). */\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>): boolean => {\n // A key from a popup an action opened reaches here through the React tree: not ours.\n if (event.defaultPrevented || !isOwnEvent(event)) return false;\n const target = event.target as HTMLElement;\n const popup = target.getAttribute('aria-haspopup');\n if (\n (event.key === 'ArrowDown' || event.key === 'ArrowUp') &&\n popup !== null &&\n popup !== 'false'\n ) {\n event.preventDefault();\n return false;\n }\n if (!treegrid || event.altKey || event.ctrlKey || event.metaKey || isEditableTarget(target)) {\n return false;\n }\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n return intent === 'prev';\n };\n\n const handleToolbarKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n const isPrev = handleKeyDown(event);\n if (event.defaultPrevented) return;\n rovingKeyDown(event);\n // \"Previous\" that the roving order did not take (the first action it reaches) returns.\n if (isPrev && event.target === document.activeElement) {\n event.preventDefault();\n onReturn();\n }\n };\n\n return (\n <span\n role=\"toolbar\"\n aria-labelledby={labelledBy}\n aria-orientation=\"horizontal\"\n data-tree-actions=\"\"\n data-roving-container=\"\"\n ref={rovingRef}\n data-focus-in-popup={popupFocus === null ? undefined : ''}\n onKeyDown={handleToolbarKeyDown}\n onFocus={handleToolbarFocus}\n onBlur={handleToolbarBlur}\n className={cn(\n treeItemClassNames.actions,\n 'inline-flex items-center gap-1',\n ACTIONS_VISIBILITY,\n )}\n >\n {children}\n </span>\n );\n};\nTreeItemActions.displayName = 'TreeItemActions';\n\n/**\n * One node of a Tree. Text and other content are the label; nested `Tree.Item` children form its\n * child group, which is shown while the item is expanded.\n *\n * Nested items must be `Tree.Item` elements among the item's own children: written directly, in\n * Fragments, or returned by a render function (`{node.children.map(renderNode)}`). A component\n * that renders `Tree.Item` itself (a recursive `<NodeView node={child} />`) is not recognised:\n * its output becomes part of the label, so the parent cannot expand (a development warning names\n * this). Render data-driven trees with a render function instead. The checks of a\n * `selectionMode=\"multiple\"` tree cascade by the same rule, so an item that such a component\n * renders is not checked with its parent.\n *\n * `ref` and every other prop land on the `role=\"treeitem\"` element, which contains the label row\n * and the child group. Its `onClick` receives only clicks on its own row (not on its child group\n * or nested items) and its `onKeyDown` only keys pressed while focus is on it or in its row; both\n * run before the built-in behaviour (call `event.preventDefault()` to skip it). In a checkbox\n * tree, a click on the item's checkbox toggles its check and is not passed to `onClick`, and\n * neither is a click on its actions; `onKeyDown` receives no keys pressed in the actions. Its\n * other event handlers (`onFocus`, `onDoubleClick`, `onContextMenu` and the rest) are not\n * filtered: as DOM events bubble, they also receive events from its child group and nested items\n * (compare `event.target` with `event.currentTarget` to tell them apart).\n *\n * `actions` render in a toolbar at the end of the row, named by the item; keys and clicks on them\n * belong to them and never activate or check the item. `aside` sits before them and describes the\n * item.\n *\n * The item is named by its label (`aria-labelledby`), not by its icon or nested items; an\n * `aria-label` or `aria-labelledby` prop replaces that name. Typeahead matches the label text too\n * (a `data-roving-text` prop replaces it).\n */\nexport const TreeItem = ({\n value,\n icon,\n iconAfter,\n expandIcon,\n aside,\n actions,\n leaf = false,\n className,\n children,\n onClick,\n onKeyDown,\n onFocus,\n onBlur,\n ref,\n ...props\n}: TreeItemProps) => {\n const { 'data-roving-text': typeaheadText, ...rest } = props as typeof props & {\n 'data-roving-text'?: string;\n };\n const ctx = useTreeContext('Tree.Item');\n const parent = React.useContext(TreeParentContext);\n const insideLabel = React.useContext(TreeLabelContext);\n const isExpanded = ctx.expanded.has(value);\n const labelId = useId('tree-item-label');\n const asideId = useId('tree-item-aside');\n const ancestorListed = React.useContext(TreeCheckForcedContext);\n const itemRef = React.useRef<HTMLDivElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, itemRef);\n // A Tree.ItemPersonaLayout in the label registers its name and description: the item is named\n // by the name only and described by the description.\n const [layoutIds, setLayoutIds] = React.useState<PersonaLayoutIds | null>(null);\n const registerLayout = React.useCallback((ids: PersonaLayoutIds) => {\n setLayoutIds(ids);\n return () => setLayoutIds((current) => (current === ids ? null : current));\n }, []);\n const itemContext = React.useMemo<TreeItemContextValue>(\n () => ({ registerLayout }),\n [registerLayout],\n );\n const nameId = layoutIds?.nameId ?? labelId;\n\n const { registerValue, registerTopLevel } = ctx;\n React.useEffect(() => registerValue(value), [registerValue, value]);\n React.useEffect(() => {\n if (insideLabel) warnOnce('Tree.Item:inside-label', ITEM_IN_LABEL_MESSAGE);\n }, [insideLabel]);\n\n // Nested Tree.Items (and, as in 0.4, nested Trees) form the child group; the rest is the label.\n // Parts are identified through their element type, so parts written in a Server Component\n // (lazy references) count too.\n const nestedItems: React.ReactNode[] = [];\n const labelContent: React.ReactNode[] = [];\n let firstChildValue: string | undefined;\n flattenChildren(children).forEach(({ key, node: child }) => {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n if (isElementOfType<TreeItemProps>(child, TreeItem)) {\n firstChildValue ??= child.props.value;\n nestedItems.push(keyed);\n } else if (isElementOfType(child, TreeRoot)) {\n nestedItems.push(keyed);\n } else {\n labelContent.push(keyed);\n }\n });\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4\n // and as in Avatar, and so is a collection whose items render nothing: no empty span adds a gap\n // to the row. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(treeItemClassNames.icon, 'inline-flex shrink-0'), {\n 'aria-hidden': true,\n })\n : null;\n const iconAfterNode =\n iconAfter && slotRendersContent(iconAfter)\n ? renderSlot(iconAfter, 'span', cn(treeItemClassNames.iconAfter, 'inline-flex shrink-0'), {\n 'aria-hidden': true,\n })\n : null;\n // No empty aside and no empty toolbar (`actions={cond && <Button />}` with `cond` false).\n const hasAside = slotRendersContent(aside);\n const hasActions = slotRendersContent(actions);\n const hasChildren = nestedItems.length > 0 && !leaf;\n\n // The optional-indicator slot rule (C-SLOTS): `null`/`undefined` keep the chevron, `false` or\n // content that renders nothing hides it (the spacer keeps the column), and a custom glyph is\n // rendered as given, not rotated.\n let chevron: React.ReactNode = <span className=\"w-3 shrink-0\" aria-hidden=\"true\" />;\n if (hasChildren && (expandIcon === undefined || expandIcon === null)) {\n chevron = (\n <ChevronRightIcon\n className={cn(\n treeItemClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isExpanded ? 'rotate-90' : 'wave-rtl:-scale-x-100',\n )}\n />\n );\n } else if (hasChildren && slotRendersContent(expandIcon)) {\n chevron = renderSlot(\n expandIcon,\n 'span',\n cn(treeItemClassNames.expandIcon, 'inline-flex shrink-0'),\n { 'aria-hidden': true },\n );\n }\n\n // Checkbox tree: the item computes its state from its own subtree (the child-group rule) and\n // the checked list, so every state renders on the server and needs no other item. A top-level\n // item also hands its subtree to the root, which orders a toggle's list by it.\n const multiple = ctx.selectionMode === 'multiple';\n const ownNode = React.useMemo<TreeNode | null>(\n () =>\n multiple\n ? {\n value,\n children: leaf ? [] : collectItems(children, { item: TreeItem, tree: TreeRoot }),\n }\n : null,\n [multiple, value, leaf, children],\n );\n const checkState: CheckState | undefined = ownNode\n ? computeCheckStates([ownNode], ctx.checked, ancestorListed).get(value)\n : undefined;\n const selectionEntry = React.useRef<TreeSelectionEntry | null>(null);\n React.useLayoutEffect(() => {\n selectionEntry.current = ownNode ? { node: ownNode, element: itemRef.current } : null;\n });\n const isTopLevel = parent === null && !insideLabel;\n React.useLayoutEffect(\n () => (multiple && isTopLevel ? registerTopLevel(selectionEntry) : undefined),\n [multiple, isTopLevel, registerTopLevel],\n );\n const isSelected = ctx.selected !== undefined ? ctx.selected === value : undefined;\n const isCurrent = ctx.current !== undefined && ctx.current !== null && ctx.current === value;\n\n const activate = () => {\n if (hasChildren) ctx.toggle(value);\n ctx.activate(value);\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!isOwnClick(event)) return;\n onClick?.(event);\n if (!event.defaultPrevented) activate();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!isOwnKeyEvent(event)) return;\n onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n activate();\n return;\n case ' ':\n event.preventDefault();\n // A checkbox tree toggles the focused item's check (APG); the other modes activate.\n if (checkState !== undefined) ctx.toggleChecked(value, event.nativeEvent);\n else activate();\n return;\n case '*': {\n event.preventDefault();\n const siblings = event.currentTarget.parentElement?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"][aria-expanded=\"false\"][data-roving-value]',\n );\n ctx.expand(\n Array.from(siblings ?? [], (el) => el.getAttribute('data-roving-value') ?? '').filter(\n Boolean,\n ),\n );\n return;\n }\n default:\n }\n\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (intent === 'next') {\n event.preventDefault();\n if (hasChildren && !isExpanded) {\n ctx.toggle(value);\n return;\n }\n // Treegrid navigation moves into the row's actions, also from an open parent (Down reaches\n // its first child), where APG's tree moves to the first child.\n if (ctx.navigationMode === 'treegrid' && focusFirstAction(event.currentTarget)) return;\n if (hasChildren && firstChildValue !== undefined) ctx.focusValue(firstChildValue);\n } else if (intent === 'prev') {\n event.preventDefault();\n if (hasChildren && isExpanded) ctx.toggle(value);\n else if (parent !== null) ctx.focusValue(parent);\n }\n };\n\n // Focus in the actions: tracked from the events, because a removed element fires no reliable\n // blur. A blur that leaves for another element, or from an element still in the document, ends it.\n const focusedAction = React.useRef<Element | null>(null);\n const inOwnActions = (event: React.FocusEvent<HTMLElement>) =>\n (event.target as Element).closest('[data-tree-actions]')?.closest('[role=\"treeitem\"]') ===\n event.currentTarget;\n // Focus on the item, or on one of its own actions (a click), makes it the active item.\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget || inOwnActions(event)) ctx.onItemFocus(value);\n if (inOwnActions(event)) focusedAction.current = event.target as Element;\n };\n\n const handleActionsBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (inOwnActions(event) && (event.relatedTarget !== null || event.target.isConnected)) {\n focusedAction.current = null;\n }\n };\n // An action that had focus is gone (no longer in the document) and focus fell to the page: it\n // goes to the item instead. Focus anywhere else ends the record at the next render.\n React.useLayoutEffect(() => {\n const action = focusedAction.current;\n if (!action) return;\n const item = itemRef.current;\n const active = item?.ownerDocument.activeElement;\n if (active && active !== item.ownerDocument.body) {\n focusedAction.current = null;\n } else if (item && !action.isConnected) {\n focusedAction.current = null;\n item.focus({ preventScroll: true });\n }\n });\n\n // The checkbox never takes focus (APG: focus stays on tree items): a press on it focuses its\n // item instead, and its click toggles the check without activating the item.\n const keepFocusOnItem = (event: React.MouseEvent<HTMLSpanElement>) => {\n event.preventDefault();\n itemRef.current?.focus({ preventScroll: true });\n };\n const handleCheckboxClick = (event: React.MouseEvent<HTMLSpanElement>) => {\n ctx.toggleChecked(value, event.nativeEvent);\n };\n\n const checkbox =\n checkState === undefined ? null : (\n <span\n role=\"checkbox\"\n aria-checked={checkState === 'mixed' ? 'mixed' : checkState === 'checked'}\n aria-labelledby={nameId}\n tabIndex={-1}\n data-tree-checkbox=\"\"\n onMouseDown={keepFocusOnItem}\n onClick={handleCheckboxClick}\n className={cn(\n treeItemClassNames.indicator,\n // Checkbox's box: 16px inside a 24px target (the pseudo-element), WCAG 2.5.8.\n 'relative inline-flex size-4 shrink-0 items-center justify-center rounded-xs border transition-colors motion-reduce:transition-none',\n 'before:absolute before:-inset-1',\n checkState === 'unchecked'\n ? cn('border-stroke-accessible bg-transparent', forcedColors.control)\n : 'border-primary bg-primary text-primary-foreground forced-colors:border-[Highlight] forced-colors:bg-[Highlight]',\n )}\n >\n {checkState === 'mixed' ? (\n <SubtractIcon size={12} className={forcedColors.selectedLeaf} />\n ) : checkState === 'checked' ? (\n <CheckIcon size={12} className={forcedColors.selectedLeaf} />\n ) : null}\n </span>\n );\n\n // Single mode: a decorative radio (the treeitem's aria-selected carries the state). A click on\n // it is a click on the row, so it activates the item.\n const radio =\n ctx.selectionMode === 'single' ? (\n <span\n aria-hidden=\"true\"\n className={cn(\n treeItemClassNames.indicator,\n 'inline-flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors motion-reduce:transition-none',\n isSelected\n ? 'border-2 border-primary forced-colors:border-[Highlight]'\n : cn('border-stroke-accessible', forcedColors.control),\n )}\n >\n {isSelected && (\n <span className={cn('block size-2 rounded-full bg-primary', forcedColors.selectedLeaf)} />\n )}\n </span>\n ) : null;\n // A tree item shows its checkbox in multiple mode, its radio in single mode, and nothing else.\n const indicator = checkbox ?? radio;\n\n // Items in this item's group are checked when the list checks this item or an ancestor.\n const groupListed = ancestorListed || (multiple && ctx.checked.has(value));\n\n return (\n <div\n role=\"treeitem\"\n aria-selected={isSelected}\n aria-current={isCurrent ? true : undefined}\n data-checked={checkState === 'checked' ? '' : undefined}\n data-mixed={checkState === 'mixed' ? '' : undefined}\n className={cn(\n treeItemClassNames.root,\n // The focus ring is drawn on the row: an outline on the treeitem would surround its\n // whole subtree.\n 'block outline-none',\n '[&:focus-visible>[data-tree-row]]:outline-2 [&:focus-visible>[data-tree-row]]:-outline-offset-2 [&:focus-visible>[data-tree-row]]:outline-ring',\n hasActions && ACTIONS_ON_ITEM_FOCUS,\n hasActions && hasAside && ASIDE_OFF_ON_ITEM_FOCUS,\n className,\n )}\n {...rest}\n // Named by its label only: the treeitem also contains its icon and its child group. A\n // consumer aria-labelledby or aria-label replaces it.\n aria-labelledby={\n rest['aria-labelledby'] ?? (rest['aria-label'] === undefined ? nameId : undefined)\n }\n // The aside describes the item, after a consumer description.\n aria-describedby={joinIds(\n rest['aria-describedby'],\n hasAside ? asideId : undefined,\n layoutIds?.descriptionId,\n )}\n aria-expanded={hasChildren ? isExpanded : undefined}\n // From the checked list, after the rest props, so a consumer cannot contradict it.\n aria-checked={\n checkState === undefined\n ? undefined\n : checkState === 'mixed'\n ? 'mixed'\n : checkState === 'checked'\n }\n tabIndex={ctx.getTabIndex(value)}\n data-roving-value={value}\n data-selected={isSelected ? '' : undefined}\n data-current={isCurrent ? '' : undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={(event) =>\n composeEventHandlers(onFocus, handleFocus, { checkDefaultPrevented: false })(event)\n }\n onBlur={(event) =>\n composeEventHandlers(onBlur, handleActionsBlur, { checkDefaultPrevented: false })(event)\n }\n ref={mergedRef}\n >\n <div\n data-tree-row=\"\"\n className={cn(\n treeItemClassNames.row,\n 'flex cursor-pointer items-center gap-1.5 rounded px-2 py-1 hover:bg-subtle-hover',\n hasActions && 'group/row',\n isSelected && cn('bg-subtle-selected font-semibold', forcedColors.selectedContainer),\n )}\n >\n {chevron}\n {indicator}\n {iconNode}\n <span\n id={labelId}\n data-tree-label=\"\"\n data-roving-text={typeaheadText}\n // The label shrinks (and truncates) when the row has content after it.\n className={cn(\n treeItemClassNames.label,\n 'truncate',\n (iconAfterNode || hasAside || hasActions) && 'min-w-0',\n )}\n >\n <TreeCheckForcedContext.Provider value={false}>\n <TreeLabelContext.Provider value>\n <TreeItemContext.Provider value={itemContext}>\n {labelContent}\n </TreeItemContext.Provider>\n </TreeLabelContext.Provider>\n </TreeCheckForcedContext.Provider>\n </span>\n {iconAfterNode}\n {(hasAside || hasActions) && (\n <span\n data-tree-end=\"\"\n className={cn(\n 'group/end ms-auto inline-grid shrink-0 items-center gap-1',\n hasAside && hasActions && END_CELL_SHARED,\n )}\n >\n {hasAside && (\n <span\n id={asideId}\n data-tree-aside=\"\"\n className={cn(\n treeItemClassNames.aside,\n 'inline-flex items-center text-caption-1 text-muted-foreground',\n hasActions && ASIDE_OFF_WITH_ACTIONS,\n )}\n >\n {materialiseSlotContent(aside)}\n </span>\n )}\n {hasActions && (\n <TreeItemActions\n labelledBy={nameId}\n tabStop={\n ctx.navigationMode === 'tree' && ctx.focusedItem === value\n ? 'last-focused'\n : 'none'\n }\n navigationMode={ctx.navigationMode}\n onReturn={() => ctx.focusValue(value)}\n >\n {materialiseSlotContent(actions)}\n </TreeItemActions>\n )}\n </span>\n )}\n </div>\n {hasChildren && isExpanded && (\n <TreeParentContext.Provider value={value}>\n <TreeCheckForcedContext.Provider value={groupListed}>\n <TreeLabelContext.Provider value={false}>\n <div role=\"group\" className={cn(treeItemClassNames.group, 'ps-4')}>\n {nestedItems}\n </div>\n </TreeLabelContext.Provider>\n </TreeCheckForcedContext.Provider>\n </TreeParentContext.Provider>\n )}\n </div>\n );\n};\nTreeItem.displayName = 'TreeItem';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMG,KAA2B,CAAC,GAE5BC,KACJ;AAOF,SAASC,GAAmB,GAAqB;CAC/C,EACE,kBAAkBC,KAClB,wCAAwCA,EAAM,u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mBAAgB;MAChB,WAAW5C,EACTkC,EAAmB,OACnB,iEACAmC,KAAc/I,EAChB;MAEC,UAAAkL,EAAuBpC,CAAK;KACzB,CAAA,GAEPC,KACC,kBAACrD,GAAD;MACE,YAAYoC;MACZ,SACEd,EAAI,mBAAmB,UAAUA,EAAI,gBAAgB9H,IACjD,iBACA;MAEN,gBAAgB8H,EAAI;MACpB,gBAAgBA,EAAI,WAAW9H,CAAK;MAEnC,UAAAgM,EAAuBlC,CAAO;KAChB,CAAA,CAEf;;GAEL;EACJ,CAAA,GAAAC,KAAe7B,KACd,kBAAC5C,EAAkB,UAAnB;GAAmC;GACjC,UAAA,kBAACC,EAAuB,UAAxB;IAAiC,OAAOsG;IACtC,UAAA,kBAAC7F,EAAiB,UAAlB;KAA2B,OAAO;KAChC,UAAA,kBAAC,OAAD;MAAK,MAAK;MAAQ,WAAWR,EAAGkC,EAAmB,OAAO,MAAM;MAC7D,UAAAmB;KACE,CAAA;IACoB,CAAA;GACI,CAAA;EACP,CAAA,CAE3B;;AAET;AACA,EAAS,cAAc"}
1
+ {"version":3,"file":"Tree.core.mjs","names":["useId","useId$1","React","EMPTY","ITEM_IN_LABEL_MESSAGE","warnDuplicateValue","value","SELECTED_WITH_MULTIPLE_MESSAGE","CHECKED_WITHOUT_MULTIPLE_MESSAGE","SINGLE_WITHOUT_SELECTED_MESSAGE","forestInTreeOrder","entries","entry","a","b","TREE_ITEM_SELECTOR","ACTION_ITEM_SELECTOR","ACTIONS_ON_ITEM_FOCUS","ASIDE_OFF_ON_ITEM_FOCUS","ACTIONS_VISIBILITY","ASIDE_OFF_WITH_ACTIONS","END_CELL_SHARED","focusFirstAction","toolbar","item","cssHidden","el","isHiddenInput","concealed","marker","TreeRoot","rest","initialExpanded","defaultExpandedItems","expandedList","setExpandedList","useControllable","expandedItems","onExpandedItemsChange","next","expanded","toggle","prev","v","expand","added","values","activate","useEventCallback","initialChecked","defaultCheckedItems","pendingDetails","checkedList","setCheckedList","checkedItems","onCheckedItemsChange","checked","topLevel","registerTopLevel","toggleChecked","forest","toggleCheck","previous","effectiveSelected","selectionMode","selected","warnOnce","hasCheckedProps","focusedItem","setFocusedItem","valueCounts","registerValue","isDev","counts","count","remaining","useRovingTabIndex","context","current","getTabIndex","focusValue","navigationMode","motion","mergedRef","useMergedRefs","ref","containerProps","handleKeyDown","event","syncTypeaheadText","handleKeyDownCapture","handleBlur","TreeContext","TreeParentContext","TreeCheckForcedContext","cn","treeClassNames","className","composeEventHandlers","onKeyDown","onKeyDownCapture","onFocus","onBlur","TreeLabelContext","label","treeitem","personaName","text","isOwnKeyEvent","target","isOwnClick","TreeItemActions","treegrid","rovingRef","rovingKeyDown","rovingFocus","popupFocus","setPopupFocus","frame","handleToolbarFocus","handleToolbarBlur","isOwnEvent","popup","isEditableTarget","getArrowIntent","getDirection","labelledBy","isPrev","onReturn","treeItemClassNames","TreeItem","props","typeaheadText","ctx","useTreeContext","parent","insideLabel","isExpanded","labelId","asideId","ancestorListed","itemRef","layoutIds","setLayoutIds","registerLayout","ids","itemContext","nameId","nestedItems","labelContent","firstChildValue","children","child","keyed","key","isElementOfType","iconNode","icon","slotRendersContent","renderSlot","iconAfterNode","iconAfter","hasAside","aside","hasActions","actions","hasChildren","leaf","groupRef","isGroupMounted","collapseRef","collapsePresenceProps","collapseClassName","useCollapsePresence","chevron","expandIcon","ChevronRightIcon","multiple","ownNode","collectItems","checkState","computeCheckStates","selectionEntry","isTopLevel","isSelected","isCurrent","handleClick","onClick","siblings","intent","focusedAction","inOwnActions","handleFocus","handleActionsBlur","action","active","checkbox","forcedColors","SubtractIcon","CheckIcon","radio","indicator","groupListed","joinIds","TreeItemContext","materialiseSlotContent"],"sources":["../../../src/components/layout/Tree.core.tsx"],"sourcesContent":["import * as React from 'react';\nimport { joinIds } from '../../lib/aria';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { treeClassNames, treeItemClassNames } from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { isDev, warnOnce } from '../../lib/dev';\nimport { getArrowIntent, getDirection } from '../../lib/direction';\nimport { isEditableTarget, isOwnEvent } from '../../lib/events';\nimport { isHiddenInput } from '../../lib/focus';\nimport { CheckIcon, ChevronRightIcon, SubtractIcon } from '../../lib/icons';\nimport type { MotionSlot, SelectionMode } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport { useCollapsePresence } from '../../hooks/useCollapsePresence';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { isHiddenByCss, useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport {\n TreeCheckForcedContext,\n TreeContext,\n TreeItemContext,\n TreeLabelContext,\n TreeParentContext,\n useTreeContext,\n type PersonaLayoutIds,\n type TreeContextValue,\n type TreeItemContextValue,\n type TreeSelectionEntry,\n} from './Tree.context';\nimport {\n collectItems,\n computeCheckStates,\n toggleCheck,\n type CheckState,\n type TreeNode,\n} from './Tree.selection';\n\nconst EMPTY: readonly string[] = [];\n\nconst ITEM_IN_LABEL_MESSAGE =\n 'Tree.Item was rendered inside the label of another Tree.Item, so it is not part of that ' +\n \"item's child group: the parent cannot expand, its name includes the nested text, and a \" +\n 'treeitem sits inside a label (axe aria-required-parent). A Tree.Item finds its nested items ' +\n 'among its own children (written directly, in Fragments, or returned by a render function such ' +\n 'as `children.map(renderNode)`), but not inside a component that renders Tree.Item itself. ' +\n 'Build a data-driven tree with a render function instead of a recursive component.';\n\nfunction warnDuplicateValue(value: string): void {\n warnOnce(\n `Tree:duplicate:${value}`,\n `Tree: several items share the value \"${value}\". Item values must be unique within a Tree; ` +\n 'items with the same value share their expanded, selected and focus state.',\n );\n}\n\nconst SELECTED_WITH_MULTIPLE_MESSAGE =\n 'Tree: `selected` has no effect with selectionMode=\"multiple\"; use `checkedItems`, and ' +\n '`current` for the item the user is on.';\n\nconst CHECKED_WITHOUT_MULTIPLE_MESSAGE =\n 'Tree: `checkedItems` and `defaultCheckedItems` need selectionMode=\"multiple\"; without it the ' +\n 'tree draws no checkboxes and ignores them.';\n\nconst SINGLE_WITHOUT_SELECTED_MESSAGE =\n 'Tree: selectionMode=\"single\" draws a radio on every item for `selected`; pass `selected` ' +\n '(null while nothing is selected) and update it from `onItemSelect`.';\n\n/** The registered top-level subtrees in document order, which is the tree order of their items. */\nfunction forestInTreeOrder(\n entries: ReadonlySet<React.RefObject<TreeSelectionEntry | null>> | null,\n): TreeNode[] {\n if (!entries) return [];\n return Array.from(entries, (entry) => entry.current)\n .filter((entry): entry is TreeSelectionEntry => entry !== null)\n .sort((a, b) => {\n if (!a.element || !b.element || a.element === b.element) return 0;\n return a.element.compareDocumentPosition(b.element) & Node.DOCUMENT_POSITION_FOLLOWING\n ? -1\n : 1;\n })\n .map((entry) => entry.node);\n}\n\n/**\n * The tree's own items for the tab stop and the arrow keys: the treeitems. A row's actions are a\n * roving container of their own, which the default selector would count as one more item.\n */\nconst TREE_ITEM_SELECTOR = '[role=\"treeitem\"]';\n\n/** Every focusable control a row's actions can hold (Toolbar's rule). */\nconst ACTION_ITEM_SELECTOR = 'button, [href], input, select, textarea, [role=\"button\"], [tabindex]';\n\n/**\n * Shows a row's actions while focus is on its item (also after a click) or inside the item's own\n * row, never in its child group (a grandchild of the item: the group sits in its collapse\n * element), so Tab and the treegrid arrows reach them. The item's `:focus-within`, not its\n * `:focus`: while focus moves from the item into an action, Chromium has already ended the item's\n * `:focus` (but keeps `:focus-within` on it, the common ancestor) when it checks that the action\n * can take focus, and a hidden action refuses it.\n */\nconst ACTIONS_ON_ITEM_FOCUS =\n '[&:focus-within:not(:has(>*>[role=group]_:focus))>[data-tree-row]_[data-tree-actions]]:visible';\n\n/** Makes the aside invisible while its actions show for focus, where they take its place. */\nconst ASIDE_OFF_ON_ITEM_FOCUS =\n '[@media(hover:hover)]:not-forced-colors:[&:focus-within:not(:has(>*>[role=group]_:focus))>[data-tree-row]_[data-tree-aside]]:invisible';\n\n/**\n * The actions stay invisible until the row is hovered or the item or an action has focus, and\n * always show in forced colors and without hover (touch). An invisible action takes no focus.\n * They also show while a surface opened from an action is open (its trigger is expanded) and\n * while focus is in such a surface (`data-focus-in-popup`), so the surface's focus return, which\n * runs after its trigger already reports it closed, reaches the action.\n */\nconst ACTIONS_VISIBILITY =\n 'invisible group-hover/row:visible focus-within:visible forced-colors:visible [@media(hover:none)]:visible has-[[aria-expanded=true]]:visible data-[focus-in-popup]:visible';\n\n/** The aside gives way to the actions where the two share one place. */\nconst ASIDE_OFF_WITH_ACTIONS =\n 'not-forced-colors:group-hover/row:invisible [@media(hover:hover)]:not-forced-colors:group-focus-within/end:invisible [@media(hover:hover)]:not-forced-colors:group-has-[[aria-expanded=true]]/end:invisible [@media(hover:hover)]:not-forced-colors:group-has-[[data-focus-in-popup]]/end:invisible';\n\n/** Aside and actions share one cell, and sit side by side where the actions always show. */\nconst END_CELL_SHARED = '[&>*]:[grid-area:1/1] forced-colors:flex [@media(hover:none)]:flex';\n\n/**\n * Focuses the first action of an item's own row that takes focus, trying them in order and\n * skipping what the roving hook skips: natively disabled, marked `data-roving-disabled`,\n * `aria-disabled` unless focusable-disabled, hidden form inputs, anything inside a `hidden` or\n * `inert` element of the toolbar, and what CSS hides (the hook's own `isHiddenByCss`). `false` when\n * focus did not move into the row's actions.\n */\nfunction focusFirstAction(item: HTMLElement): boolean {\n const toolbar = item.querySelector<HTMLElement>(':scope > [data-tree-row] [data-tree-actions]');\n if (!toolbar) return false;\n const cssHidden = new Map<Element, boolean>();\n for (const el of Array.from(toolbar.querySelectorAll<HTMLElement>(ACTION_ITEM_SELECTOR))) {\n if (isHiddenInput(el) || el.matches(':disabled')) continue;\n const concealed = el.closest('[hidden], [inert]');\n if (concealed && toolbar.contains(concealed)) continue;\n const marker = el.getAttribute('data-roving-disabled');\n if (marker !== null && marker !== 'false') continue;\n if (\n el.getAttribute('aria-disabled') === 'true' &&\n !el.hasAttribute('data-disabled-focusable')\n ) {\n continue;\n }\n if (isHiddenByCss(el, toolbar, cssHidden)) continue;\n el.focus();\n if (el.ownerDocument.activeElement === el) return true;\n }\n return false;\n}\n\n/* ------------------------------------------------------------------ */\n/* Tree */\n/* ------------------------------------------------------------------ */\n\n/** The second argument of `onCheckedItemsChange`. */\nexport interface TreeCheckedItemsChangeDetails {\n /** The item that was toggled. */\n value: string;\n /** Its new state (a toggle never leaves it mixed). */\n checked: boolean;\n /** The DOM event of the toggle: a keyboard event for Space, a mouse event for a click. */\n event: Event;\n}\n\n/** Properties for the Tree component. */\nexport interface TreeProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Controlled list of expanded item values. */\n expandedItems?: readonly string[];\n /**\n * Item values that are expanded initially (uncontrolled).\n * @default []\n */\n defaultExpandedItems?: readonly string[];\n /** Called with the new list of expanded item values when an item expands or collapses. */\n onExpandedItemsChange?: (expandedItems: string[]) => void;\n /**\n * Called with an item's value every time it is activated (a click on its row, Enter, or Space\n * unless the tree has checkboxes), also when the same item is activated again.\n */\n onItemSelect?: (value: string) => void;\n /**\n * Value of the selected item. When set (also to `null`), every item carries `aria-selected`, and\n * the selected item is where keyboard focus enters the tree. It has no effect with\n * `selectionMode=\"multiple\"` (a development warning): items carry `aria-checked` instead. With\n * `selectionMode=\"single\"` every item carries `aria-selected` even while it is not set (a\n * development warning: the radios need it).\n */\n selected?: string | null;\n /** Value of the current item (for example the open page): it gets `aria-current=\"true\"`. */\n current?: string | null;\n /**\n * How items are selected. `'none'`: activation only (0.7; `selected` highlights one item).\n * `'single'`: a radio indicator on every item for `selected`/`onItemSelect`. `'multiple'`: a\n * checkbox on every item, bound to `checkedItems`; checking an item checks its descendants, and a\n * parent shows checked, mixed or unchecked from them. Fluent's `'multiselect'` is `'multiple'`.\n * @default 'none'\n */\n selectionMode?: 'none' | SelectionMode;\n /** Controlled checked items (`selectionMode=\"multiple\"`); see the cascade rule in the component docs. */\n checkedItems?: readonly string[];\n /**\n * Initially checked items (uncontrolled).\n * @default []\n */\n defaultCheckedItems?: readonly string[];\n /**\n * Called with every checked item (in tree order) when a check changes (Fluent's `onCheckedChange`).\n * WaveUI always passes `details`; it is typed optional until 1.0.\n */\n onCheckedItemsChange?: (checkedItems: string[], details?: TreeCheckedItemsChangeDetails) => void;\n /**\n * `'tree'`: Tab from a focused item enters its actions. `'treegrid'`: the \"next\" arrow\n * (ArrowRight, ArrowLeft in RTL) moves into an item's actions and \"previous\" returns; on an\n * expanded parent \"next\" no longer moves to the first child (ArrowDown does). The roles stay\n * `tree` and `treeitem` (Fluent's `navigationMode`).\n * @default 'tree'\n */\n navigationMode?: 'tree' | 'treegrid';\n /**\n * Replaces the collapse of every child group in the tree (Fluent's `Tree collapseMotion`), on\n * the element around each `role=\"group\"` element: by default the space a group takes opens\n * from nothing and closes back to it, with a fade, over the normal duration (200 ms) with the\n * max easy-ease curve, both ways. `null` turns it off (a group appears and disappears at once);\n * a class string or `{ className }` replaces it, written as `MotionSlot` describes. A\n * `WaveProvider` with `motion=\"none\"` turns the default off, and a value here still applies\n * under it. The expand chevron's turn is not part of it, and a nested `Tree` takes its own.\n * @default the collapse described above\n */\n motion?: MotionSlot | null;\n /** Ref to the `role=\"tree\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport const TreeRoot = ({\n expandedItems,\n defaultExpandedItems,\n onExpandedItemsChange,\n onItemSelect,\n selected,\n current,\n selectionMode = 'none',\n navigationMode = 'tree',\n checkedItems,\n defaultCheckedItems,\n onCheckedItemsChange,\n motion,\n className,\n children,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onBlur,\n ref,\n ...rest\n}: TreeProps) => {\n const [initialExpanded] = React.useState<readonly string[]>(() => defaultExpandedItems ?? EMPTY);\n const [expandedList, setExpandedList] = useControllable<readonly string[]>(\n expandedItems,\n initialExpanded,\n (next) => onExpandedItemsChange?.([...next]),\n );\n const expanded = React.useMemo(() => new Set(expandedList), [expandedList]);\n\n const toggle = React.useCallback(\n (value: string) => {\n setExpandedList((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n },\n [setExpandedList],\n );\n\n const expand = React.useCallback(\n (values: readonly string[]) => {\n setExpandedList((prev) => {\n const added = values.filter((v) => !prev.includes(v));\n return added.length > 0 ? [...prev, ...added] : prev;\n });\n },\n [setExpandedList],\n );\n\n const activate = useEventCallback((value: string) => {\n onItemSelect?.(value);\n });\n\n // Checked items (`selectionMode=\"multiple\"`). useControllable passes the value only, so a toggle\n // hands `details` to the change callback through a ref it writes and clears in the same event.\n const [initialChecked] = React.useState<readonly string[]>(() => defaultCheckedItems ?? EMPTY);\n const pendingDetails = React.useRef<TreeCheckedItemsChangeDetails | undefined>(undefined);\n const [checkedList, setCheckedList] = useControllable<readonly string[]>(\n checkedItems,\n initialChecked,\n (next) => onCheckedItemsChange?.([...next], pendingDetails.current),\n );\n const checked = React.useMemo(() => new Set(checkedList), [checkedList]);\n\n // The top-level items' subtrees (each item scans its own children), read when a check toggles:\n // they give the emitted list its tree order.\n const topLevel = React.useRef<Set<React.RefObject<TreeSelectionEntry | null>> | null>(null);\n const registerTopLevel = React.useCallback(\n (entry: React.RefObject<TreeSelectionEntry | null>) => {\n topLevel.current ??= new Set();\n const entries = topLevel.current;\n entries.add(entry);\n return () => {\n entries.delete(entry);\n };\n },\n [],\n );\n const toggleChecked = useEventCallback((value: string, event: Event) => {\n const forest = forestInTreeOrder(topLevel.current);\n setCheckedList((previous) => {\n const next = toggleCheck(forest, previous, value);\n pendingDetails.current = { value, checked: next.includes(value), event };\n return next;\n });\n pendingDetails.current = undefined;\n });\n\n // An item carries aria-checked or aria-selected, never both (APG); in single mode every item\n // carries aria-selected from the first render, so the radios and the state agree.\n const effectiveSelected =\n selectionMode === 'multiple'\n ? undefined\n : selectionMode === 'single'\n ? (selected ?? null)\n : selected;\n\n React.useEffect(() => {\n if (selectionMode === 'multiple' && selected !== undefined) {\n warnOnce('Tree:selected-with-multiple', SELECTED_WITH_MULTIPLE_MESSAGE);\n }\n }, [selectionMode, selected]);\n React.useEffect(() => {\n if (selectionMode === 'single' && selected === undefined) {\n warnOnce('Tree:single-without-selected', SINGLE_WITHOUT_SELECTED_MESSAGE);\n }\n }, [selectionMode, selected]);\n const hasCheckedProps = checkedItems !== undefined || defaultCheckedItems !== undefined;\n React.useEffect(() => {\n if (selectionMode !== 'multiple' && hasCheckedProps) {\n warnOnce('Tree:checked-without-multiple', CHECKED_WITHOUT_MULTIPLE_MESSAGE);\n }\n }, [selectionMode, hasCheckedProps]);\n\n // The item that has focus while focus is inside the tree: it holds the tab stop, so Shift+Tab\n // leaves the tree. Cleared when focus leaves; the next entry goes to `selected`, else the first.\n const [focusedItem, setFocusedItem] = React.useState<string | null>(null);\n\n // How many mounted items carry each value (written from the items' effects only).\n const valueCounts = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((value: string) => {\n if (!isDev) return () => {};\n valueCounts.current ??= new Map();\n const counts = valueCounts.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 { containerProps, getTabIndex, focusValue } = useRovingTabIndex({\n activeValue: focusedItem ?? effectiveSelected ?? null,\n itemSelector: TREE_ITEM_SELECTOR,\n orientation: 'vertical',\n loop: false,\n typeahead: true,\n });\n\n const context = React.useMemo<TreeContextValue>(\n () => ({\n expanded,\n toggle,\n expand,\n activate,\n selected: effectiveSelected,\n current,\n getTabIndex,\n focusValue,\n onItemFocus: setFocusedItem,\n focusedItem,\n navigationMode,\n registerValue,\n selectionMode,\n checked,\n toggleChecked,\n registerTopLevel,\n motion,\n }),\n [\n expanded,\n toggle,\n expand,\n activate,\n effectiveSelected,\n current,\n getTabIndex,\n focusValue,\n focusedItem,\n navigationMode,\n registerValue,\n selectionMode,\n checked,\n toggleChecked,\n registerTopLevel,\n motion,\n ],\n );\n\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, containerProps.ref);\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n // Typeahead reads `data-roving-text` at key time: fill it from each item's label first.\n if (event.key.length === 1) syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDown(event);\n };\n\n // A Space that continues a search is typeahead too, taken before the item would activate on it.\n const handleKeyDownCapture = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === ' ') syncTypeaheadText(event.currentTarget);\n containerProps.onKeyDownCapture(event);\n };\n\n const handleBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n const next = event.relatedTarget as Node | null;\n if (!next || !event.currentTarget.contains(next)) setFocusedItem(null);\n };\n\n return (\n <TreeContext.Provider value={context}>\n <TreeParentContext.Provider value={null}>\n <TreeCheckForcedContext.Provider value={false}>\n <div\n role=\"tree\"\n data-selection-mode={selectionMode}\n aria-multiselectable={selectionMode === 'multiple' ? true : undefined}\n className={cn(treeClassNames.root, 'text-body-1', className)}\n {...rest}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n onKeyDownCapture={composeEventHandlers(onKeyDownCapture, handleKeyDownCapture)}\n onFocus={composeEventHandlers(onFocus, containerProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, handleBlur, { checkDefaultPrevented: false })}\n ref={mergedRef}\n >\n {/* A Tree has its own items, also when it renders inside a label (a portaled popup). */}\n <TreeLabelContext.Provider value={false}>{children}</TreeLabelContext.Provider>\n </div>\n </TreeCheckForcedContext.Provider>\n </TreeParentContext.Provider>\n </TreeContext.Provider>\n );\n};\nTreeRoot.displayName = 'Tree';\n\n/* ------------------------------------------------------------------ */\n/* Tree.Item */\n/* ------------------------------------------------------------------ */\n\n/** Properties for the TreeItem sub-component. */\nexport interface TreeItemProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Unique value identifying this tree item. */\n value: string;\n /**\n * Icon displayed before the label. Rendered in a `<span>` hidden from assistive technology\n * (`aria-hidden`); pass a slot object (`{ className, children, … }`) to customise it. A falsy\n * icon (`''`, `0`) or a list of nothing renders no span.\n */\n icon?: Slot<'span'>;\n /** Icon after the label (decorative, `aria-hidden`; a falsy value renders nothing, as `icon`). */\n iconAfter?: Slot<'span'>;\n /**\n * Replaces the expand chevron (decorative). `null`/`undefined` keep the chevron; `false`, or\n * anything that renders nothing, hides it (`aria-expanded` still reports the state). Not rotated.\n */\n expandIcon?: Slot<'span'>;\n /**\n * Non-interactive content at the end of the row, such as a count or a badge. It describes the item\n * (`aria-describedby`); it hides while the actions show on hover or focus.\n */\n aside?: React.ReactNode;\n /**\n * Buttons at the end of the row (a toolbar named by the item's label). Shown while the row is\n * hovered or the item or its actions have focus, and always in forced colors and without hover\n * (touch). Tab reaches them from the focused item (`navigationMode=\"tree\"`), or the arrow keys do\n * (`\"treegrid\"`). Keys and clicks on them never activate or check the item.\n *\n * They also stay shown while a Menu, Popover or Dialog rendered inside them holds focus or its\n * trigger among them is expanded, so its focus return reaches the action. A dialog your app\n * renders elsewhere and opens from an action through state (a \"Delete…\" menu item that opens a\n * confirm Dialog) closes after the actions have hidden again (on devices with hover, outside\n * forced colors): a hidden action cannot take focus, so focus returns to the nearest element\n * that can, normally the item. Render such a Dialog inside `actions` (its `Dialog.Trigger`\n * there, or the controlled Dialog next to the Menu that opens it) to return focus to the action;\n * `finalFocusRef` cannot name it, since it is still hidden when the dialog closes.\n */\n actions?: React.ReactNode;\n /**\n * Renders the item as a leaf even when it has nested `Tree.Item`s: they are not rendered, and\n * the item has no `aria-expanded` and does not expand. An item is expandable only while it has\n * nested items, so `leaf={false}` does not make an item without them expandable. To load the\n * children on first expansion, give the item a placeholder child (a \"Loading…\" `Tree.Item`)\n * until they arrive.\n * @default false\n */\n leaf?: boolean;\n /** Ref to the `role=\"treeitem\"` element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Sets the typeahead text (`data-roving-text`, read by the roving hook) of every rendered\n * treeitem to the text of its label (a persona layout's name when the label holds one), so neither\n * the icon nor the nested items take part. A consumer `data-roving-text` on a Tree.Item is kept on\n * its label and wins.\n */\nfunction syncTypeaheadText(tree: HTMLElement): void {\n tree.querySelectorAll<HTMLElement>('[role=\"treeitem\"]').forEach((treeitem) => {\n const label = treeitem.querySelector<HTMLElement>(\n ':scope > [data-tree-row] > [data-tree-label]',\n );\n if (!label) return;\n // A persona layout's name is the item's name, so it is its typeahead text too (not the media,\n // such as an avatar's initials, or the description).\n const personaName = label.querySelector<HTMLElement>('[data-tree-persona-name]');\n const text =\n label.getAttribute('data-roving-text') ?? personaName?.textContent ?? label.textContent ?? '';\n if (treeitem.getAttribute('data-roving-text') !== text) {\n treeitem.setAttribute('data-roving-text', text);\n }\n });\n}\n\n/**\n * Whether a keyboard event belongs to this treeitem: its target (the focused element) is this\n * treeitem or inside its row, not a nested item and not the row's actions (their keys are theirs).\n */\nfunction isOwnKeyEvent(event: React.KeyboardEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n if (target?.closest?.('[data-tree-actions]')) return false;\n return target?.closest?.('[role=\"treeitem\"]') === event.currentTarget;\n}\n\n/**\n * Whether a click landed on this treeitem's own row (or on the treeitem element itself). Clicks\n * in its child group, including the indentation gutter beside the nested rows, clicks on nested\n * items, on its checkbox and on its actions are not its own.\n *\n * While the child group exits, its collapse element is `inert`, which hit-tests like an element\n * the pointer passes through: a pointer click in the group's box lands on the treeitem element\n * itself, and is not its own either (it would expand the item again and activate it). A click\n * without a pointer (`detail` 0: Enter on a focused item, a screen reader's click) still is.\n */\nfunction isOwnClick(event: React.MouseEvent<HTMLElement>): boolean {\n const target = event.target as Element | null;\n if (target === event.currentTarget) {\n return event.detail === 0 || !event.currentTarget.querySelector(':scope > [inert]');\n }\n if (target?.closest?.('[data-tree-checkbox], [data-tree-actions]')) return false;\n return target?.closest?.('[data-tree-row]')?.parentElement === event.currentTarget;\n}\n\ninterface TreeItemActionsProps {\n /** Id of the element that names the item. */\n labelledBy: string;\n /**\n * `'last-focused'` while the actions hold a Tab stop (their item has focus, tree mode), else\n * `'none'`.\n */\n tabStop: 'last-focused' | 'none';\n /** `'treegrid'`: the arrows do not wrap, and \"previous\" on the first action returns to the item. */\n navigationMode: 'tree' | 'treegrid';\n /** Moves focus back to the item. */\n onReturn: () => void;\n children: React.ReactNode;\n}\n\n/**\n * A row's actions: the consumer's controls rove with the arrow keys and hold at most one Tab\n * stop. A key pressed on an action is the action's: ArrowDown and ArrowUp on an action that opens\n * a popup (`aria-haspopup`) never move focus to another item. In treegrid navigation, \"previous\"\n * on the first action returns to the item.\n */\nconst TreeItemActions = ({\n labelledBy,\n tabStop,\n navigationMode,\n onReturn,\n children,\n}: TreeItemActionsProps) => {\n const treegrid = navigationMode === 'treegrid';\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleFocus: rovingFocus,\n } = useRovingTabIndex({\n itemSelector: ACTION_ITEM_SELECTOR,\n manageTabIndex: true,\n orientation: 'horizontal',\n loop: !treegrid,\n tabStop,\n });\n\n // Focus in a surface opened from an action (a Menu, Popover or Dialog rendered in a portal, whose\n // focus events reach the toolbar through the React tree): `'inside'`. Once focus leaves such a\n // surface for anywhere but the toolbar, `'leaving'` until the next frame, because the surface's\n // focus return comes later in that close (its layout phase, or a microtask).\n const [popupFocus, setPopupFocus] = React.useState<'inside' | 'leaving' | null>(null);\n React.useEffect(() => {\n if (popupFocus !== 'leaving') return;\n const frame = requestAnimationFrame(() => setPopupFocus(null));\n return () => cancelAnimationFrame(frame);\n }, [popupFocus]);\n\n const handleToolbarFocus = (event: React.FocusEvent<HTMLSpanElement>) => {\n rovingFocus(event);\n setPopupFocus(event.currentTarget.contains(event.target) ? null : 'inside');\n };\n\n const handleToolbarBlur = (event: React.FocusEvent<HTMLSpanElement>) => {\n // An action's own blur: its focus-within reveal decides.\n if (event.currentTarget.contains(event.target)) return;\n const next = event.relatedTarget;\n // Back to an action: its focus clears the hold.\n if (next instanceof Node && event.currentTarget.contains(next)) return;\n setPopupFocus('leaving');\n };\n\n /** Whether the key is treegrid's \"previous\" for an action (the roving order settles it). */\n const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>): boolean => {\n // A key from a popup an action opened reaches here through the React tree: not ours.\n if (event.defaultPrevented || !isOwnEvent(event)) return false;\n const target = event.target as HTMLElement;\n const popup = target.getAttribute('aria-haspopup');\n if (\n (event.key === 'ArrowDown' || event.key === 'ArrowUp') &&\n popup !== null &&\n popup !== 'false'\n ) {\n event.preventDefault();\n return false;\n }\n if (!treegrid || event.altKey || event.ctrlKey || event.metaKey || isEditableTarget(target)) {\n return false;\n }\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n return intent === 'prev';\n };\n\n const handleToolbarKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {\n const isPrev = handleKeyDown(event);\n if (event.defaultPrevented) return;\n rovingKeyDown(event);\n // \"Previous\" that the roving order did not take (the first action it reaches) returns.\n if (isPrev && event.target === document.activeElement) {\n event.preventDefault();\n onReturn();\n }\n };\n\n return (\n <span\n role=\"toolbar\"\n aria-labelledby={labelledBy}\n aria-orientation=\"horizontal\"\n data-tree-actions=\"\"\n data-roving-container=\"\"\n ref={rovingRef}\n data-focus-in-popup={popupFocus === null ? undefined : ''}\n onKeyDown={handleToolbarKeyDown}\n onFocus={handleToolbarFocus}\n onBlur={handleToolbarBlur}\n className={cn(\n treeItemClassNames.actions,\n 'inline-flex items-center gap-1',\n ACTIONS_VISIBILITY,\n )}\n >\n {children}\n </span>\n );\n};\nTreeItemActions.displayName = 'TreeItemActions';\n\n/**\n * One node of a Tree. Text and other content are the label; nested `Tree.Item` children form its\n * child group, which is shown while the item is expanded.\n *\n * The child group renders as the only child of a collapse element (its stable class\n * `wave-tree-item__collapse`), which opens and closes the group's space (the Tree's `motion`) and\n * has no box of its own while the item is expanded, so the group lays out in the item as before.\n * An item expanded by default appears without motion. After a collapse the group stays in the\n * document until the collapse ends, `inert` (its items leave the arrow keys and typeahead at once)\n * while the item already reports itself collapsed; expanding the item again during the collapse\n * keeps the same group. Focus inside the group when the item collapses moves to the item. A\n * pointer click that falls through the exiting group onto the item (an `inert` element lets the\n * pointer through) is not the item's: it neither expands nor activates it.\n *\n * Nested items must be `Tree.Item` elements among the item's own children: written directly, in\n * Fragments, or returned by a render function (`{node.children.map(renderNode)}`). A component\n * that renders `Tree.Item` itself (a recursive `<NodeView node={child} />`) is not recognised:\n * its output becomes part of the label, so the parent cannot expand (a development warning names\n * this). Render data-driven trees with a render function instead. The checks of a\n * `selectionMode=\"multiple\"` tree cascade by the same rule, so an item that such a component\n * renders is not checked with its parent.\n *\n * `ref` and every other prop land on the `role=\"treeitem\"` element, which contains the label row\n * and the child group (in its collapse element). Its `onClick` receives only clicks on its own\n * row (not on its child group or nested items) and its `onKeyDown` only keys pressed while focus\n * is on it or in its row; both run before the built-in behaviour (call `event.preventDefault()`\n * to skip it). In a checkbox tree, a click on the item's checkbox toggles its check and is not\n * passed to `onClick`, and neither is a click on its actions; `onKeyDown` receives no keys pressed\n * in the actions. Its other event handlers (`onFocus`, `onDoubleClick`, `onContextMenu` and the\n * rest) are not filtered: as DOM events bubble, they also receive events from its child group and\n * nested items (compare `event.target` with `event.currentTarget` to tell them apart).\n *\n * `actions` render in a toolbar at the end of the row, named by the item; keys and clicks on them\n * belong to them and never activate or check the item. `aside` sits before them and describes the\n * item.\n *\n * The item is named by its label (`aria-labelledby`), not by its icon or nested items; an\n * `aria-label` or `aria-labelledby` prop replaces that name. Typeahead matches the label text too\n * (a `data-roving-text` prop replaces it).\n */\nexport const TreeItem = ({\n value,\n icon,\n iconAfter,\n expandIcon,\n aside,\n actions,\n leaf = false,\n className,\n children,\n onClick,\n onKeyDown,\n onFocus,\n onBlur,\n ref,\n ...props\n}: TreeItemProps) => {\n const { 'data-roving-text': typeaheadText, ...rest } = props as typeof props & {\n 'data-roving-text'?: string;\n };\n const ctx = useTreeContext('Tree.Item');\n const parent = React.useContext(TreeParentContext);\n const insideLabel = React.useContext(TreeLabelContext);\n const isExpanded = ctx.expanded.has(value);\n const labelId = useId('tree-item-label');\n const asideId = useId('tree-item-aside');\n const ancestorListed = React.useContext(TreeCheckForcedContext);\n const itemRef = React.useRef<HTMLDivElement>(null);\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, itemRef);\n // A Tree.ItemPersonaLayout in the label registers its name and description: the item is named\n // by the name only and described by the description.\n const [layoutIds, setLayoutIds] = React.useState<PersonaLayoutIds | null>(null);\n const registerLayout = React.useCallback((ids: PersonaLayoutIds) => {\n setLayoutIds(ids);\n return () => setLayoutIds((current) => (current === ids ? null : current));\n }, []);\n const itemContext = React.useMemo<TreeItemContextValue>(\n () => ({ registerLayout }),\n [registerLayout],\n );\n const nameId = layoutIds?.nameId ?? labelId;\n\n const { registerValue, registerTopLevel } = ctx;\n React.useEffect(() => registerValue(value), [registerValue, value]);\n React.useEffect(() => {\n if (insideLabel) warnOnce('Tree.Item:inside-label', ITEM_IN_LABEL_MESSAGE);\n }, [insideLabel]);\n\n // Nested Tree.Items (and, as in 0.4, nested Trees) form the child group; the rest is the label.\n // Parts are identified through their element type, so parts written in a Server Component\n // (lazy references) count too.\n const nestedItems: React.ReactNode[] = [];\n const labelContent: React.ReactNode[] = [];\n let firstChildValue: string | undefined;\n flattenChildren(children).forEach(({ key, node: child }) => {\n const keyed = <React.Fragment key={key}>{child}</React.Fragment>;\n if (isElementOfType<TreeItemProps>(child, TreeItem)) {\n firstChildValue ??= child.props.value;\n nestedItems.push(keyed);\n } else if (isElementOfType(child, TreeRoot)) {\n nestedItems.push(keyed);\n } else {\n labelContent.push(keyed);\n }\n });\n\n // A falsy icon (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4\n // and as in Avatar, and so is a collection whose items render nothing: no empty span adds a gap\n // to the row. The check does not consume a generator: renderSlot still renders its items.\n const iconNode =\n icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(treeItemClassNames.icon, 'inline-flex shrink-0'), {\n 'aria-hidden': true,\n })\n : null;\n const iconAfterNode =\n iconAfter && slotRendersContent(iconAfter)\n ? renderSlot(iconAfter, 'span', cn(treeItemClassNames.iconAfter, 'inline-flex shrink-0'), {\n 'aria-hidden': true,\n })\n : null;\n // No empty aside and no empty toolbar (`actions={cond && <Button />}` with `cond` false).\n const hasAside = slotRendersContent(aside);\n const hasActions = slotRendersContent(actions);\n const hasChildren = nestedItems.length > 0 && !leaf;\n\n // The child group renders in a collapse element (the presence element) while the item is\n // expanded and, after a collapse, until that element's motion ends; focus inside the group when\n // the item collapses moves to this item, which the roving hook then treats as the focused item.\n const groupRef = React.useRef<HTMLDivElement | null>(null);\n const {\n isMounted: isGroupMounted,\n wrapperRef: collapseRef,\n presenceProps: collapsePresenceProps,\n className: collapseClassName,\n } = useCollapsePresence(hasChildren && isExpanded, {\n motion: ctx.motion,\n partRef: groupRef,\n getTrigger: () => itemRef.current,\n });\n\n // The optional-indicator slot rule (C-SLOTS): `null`/`undefined` keep the chevron, `false` or\n // content that renders nothing hides it (the spacer keeps the column), and a custom glyph is\n // rendered as given, not rotated.\n let chevron: React.ReactNode = <span className=\"w-3 shrink-0\" aria-hidden=\"true\" />;\n if (hasChildren && (expandIcon === undefined || expandIcon === null)) {\n chevron = (\n <ChevronRightIcon\n className={cn(\n treeItemClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isExpanded ? 'rotate-90' : 'wave-rtl:-scale-x-100',\n )}\n />\n );\n } else if (hasChildren && slotRendersContent(expandIcon)) {\n chevron = renderSlot(\n expandIcon,\n 'span',\n cn(treeItemClassNames.expandIcon, 'inline-flex shrink-0'),\n { 'aria-hidden': true },\n );\n }\n\n // Checkbox tree: the item computes its state from its own subtree (the child-group rule) and\n // the checked list, so every state renders on the server and needs no other item. A top-level\n // item also hands its subtree to the root, which orders a toggle's list by it.\n const multiple = ctx.selectionMode === 'multiple';\n const ownNode = React.useMemo<TreeNode | null>(\n () =>\n multiple\n ? {\n value,\n children: leaf ? [] : collectItems(children, { item: TreeItem, tree: TreeRoot }),\n }\n : null,\n [multiple, value, leaf, children],\n );\n const checkState: CheckState | undefined = ownNode\n ? computeCheckStates([ownNode], ctx.checked, ancestorListed).get(value)\n : undefined;\n const selectionEntry = React.useRef<TreeSelectionEntry | null>(null);\n React.useLayoutEffect(() => {\n selectionEntry.current = ownNode ? { node: ownNode, element: itemRef.current } : null;\n });\n const isTopLevel = parent === null && !insideLabel;\n React.useLayoutEffect(\n () => (multiple && isTopLevel ? registerTopLevel(selectionEntry) : undefined),\n [multiple, isTopLevel, registerTopLevel],\n );\n const isSelected = ctx.selected !== undefined ? ctx.selected === value : undefined;\n const isCurrent = ctx.current !== undefined && ctx.current !== null && ctx.current === value;\n\n const activate = () => {\n if (hasChildren) ctx.toggle(value);\n ctx.activate(value);\n };\n\n const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {\n if (!isOwnClick(event)) return;\n onClick?.(event);\n if (!event.defaultPrevented) activate();\n };\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!isOwnKeyEvent(event)) return;\n onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return;\n\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n activate();\n return;\n case ' ':\n event.preventDefault();\n // A checkbox tree toggles the focused item's check (APG); the other modes activate.\n if (checkState !== undefined) ctx.toggleChecked(value, event.nativeEvent);\n else activate();\n return;\n case '*': {\n event.preventDefault();\n const siblings = event.currentTarget.parentElement?.querySelectorAll<HTMLElement>(\n ':scope > [role=\"treeitem\"][aria-expanded=\"false\"][data-roving-value]',\n );\n ctx.expand(\n Array.from(siblings ?? [], (el) => el.getAttribute('data-roving-value') ?? '').filter(\n Boolean,\n ),\n );\n return;\n }\n default:\n }\n\n const intent = getArrowIntent(event.key, {\n orientation: 'horizontal',\n dir: getDirection(event.currentTarget),\n });\n if (intent === 'next') {\n event.preventDefault();\n if (hasChildren && !isExpanded) {\n ctx.toggle(value);\n return;\n }\n // Treegrid navigation moves into the row's actions, also from an open parent (Down reaches\n // its first child), where APG's tree moves to the first child.\n if (ctx.navigationMode === 'treegrid' && focusFirstAction(event.currentTarget)) return;\n if (hasChildren && firstChildValue !== undefined) ctx.focusValue(firstChildValue);\n } else if (intent === 'prev') {\n event.preventDefault();\n if (hasChildren && isExpanded) ctx.toggle(value);\n else if (parent !== null) ctx.focusValue(parent);\n }\n };\n\n // Focus in the actions: tracked from the events, because a removed element fires no reliable\n // blur. A blur that leaves for another element, or from an element still in the document, ends it.\n const focusedAction = React.useRef<Element | null>(null);\n const inOwnActions = (event: React.FocusEvent<HTMLElement>) =>\n (event.target as Element).closest('[data-tree-actions]')?.closest('[role=\"treeitem\"]') ===\n event.currentTarget;\n // Focus on the item, or on one of its own actions (a click), makes it the active item.\n const handleFocus = (event: React.FocusEvent<HTMLDivElement>) => {\n if (event.target === event.currentTarget || inOwnActions(event)) ctx.onItemFocus(value);\n if (inOwnActions(event)) focusedAction.current = event.target as Element;\n };\n\n const handleActionsBlur = (event: React.FocusEvent<HTMLDivElement>) => {\n if (inOwnActions(event) && (event.relatedTarget !== null || event.target.isConnected)) {\n focusedAction.current = null;\n }\n };\n // An action that had focus is gone (no longer in the document) and focus fell to the page: it\n // goes to the item instead. Focus anywhere else ends the record at the next render.\n React.useLayoutEffect(() => {\n const action = focusedAction.current;\n if (!action) return;\n const item = itemRef.current;\n const active = item?.ownerDocument.activeElement;\n if (active && active !== item.ownerDocument.body) {\n focusedAction.current = null;\n } else if (item && !action.isConnected) {\n focusedAction.current = null;\n item.focus({ preventScroll: true });\n }\n });\n\n // The checkbox never takes focus (APG: focus stays on tree items): a press on it focuses its\n // item instead, and its click toggles the check without activating the item.\n const keepFocusOnItem = (event: React.MouseEvent<HTMLSpanElement>) => {\n event.preventDefault();\n itemRef.current?.focus({ preventScroll: true });\n };\n const handleCheckboxClick = (event: React.MouseEvent<HTMLSpanElement>) => {\n ctx.toggleChecked(value, event.nativeEvent);\n };\n\n const checkbox =\n checkState === undefined ? null : (\n <span\n role=\"checkbox\"\n aria-checked={checkState === 'mixed' ? 'mixed' : checkState === 'checked'}\n aria-labelledby={nameId}\n tabIndex={-1}\n data-tree-checkbox=\"\"\n onMouseDown={keepFocusOnItem}\n onClick={handleCheckboxClick}\n className={cn(\n treeItemClassNames.indicator,\n // Checkbox's box: 16px inside a 24px target (the pseudo-element), WCAG 2.5.8.\n 'relative inline-flex size-4 shrink-0 items-center justify-center rounded-xs border transition-colors motion-reduce:transition-none',\n 'before:absolute before:-inset-1',\n checkState === 'unchecked'\n ? cn('border-stroke-accessible bg-transparent', forcedColors.control)\n : 'border-primary bg-primary text-primary-foreground forced-colors:border-[Highlight] forced-colors:bg-[Highlight]',\n )}\n >\n {checkState === 'mixed' ? (\n <SubtractIcon size={12} className={forcedColors.selectedLeaf} />\n ) : checkState === 'checked' ? (\n <CheckIcon size={12} className={forcedColors.selectedLeaf} />\n ) : null}\n </span>\n );\n\n // Single mode: a decorative radio (the treeitem's aria-selected carries the state). A click on\n // it is a click on the row, so it activates the item.\n const radio =\n ctx.selectionMode === 'single' ? (\n <span\n aria-hidden=\"true\"\n className={cn(\n treeItemClassNames.indicator,\n 'inline-flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors motion-reduce:transition-none',\n isSelected\n ? 'border-2 border-primary forced-colors:border-[Highlight]'\n : cn('border-stroke-accessible', forcedColors.control),\n )}\n >\n {isSelected && (\n <span className={cn('block size-2 rounded-full bg-primary', forcedColors.selectedLeaf)} />\n )}\n </span>\n ) : null;\n // A tree item shows its checkbox in multiple mode, its radio in single mode, and nothing else.\n const indicator = checkbox ?? radio;\n\n // Items in this item's group are checked when the list checks this item or an ancestor.\n const groupListed = ancestorListed || (multiple && ctx.checked.has(value));\n\n return (\n <div\n role=\"treeitem\"\n aria-selected={isSelected}\n aria-current={isCurrent ? true : undefined}\n data-checked={checkState === 'checked' ? '' : undefined}\n data-mixed={checkState === 'mixed' ? '' : undefined}\n className={cn(\n treeItemClassNames.root,\n // The focus ring is drawn on the row: an outline on the treeitem would surround its\n // whole subtree.\n 'block outline-none',\n '[&:focus-visible>[data-tree-row]]:outline-2 [&:focus-visible>[data-tree-row]]:-outline-offset-2 [&:focus-visible>[data-tree-row]]:outline-ring',\n hasActions && ACTIONS_ON_ITEM_FOCUS,\n hasActions && hasAside && ASIDE_OFF_ON_ITEM_FOCUS,\n className,\n )}\n {...rest}\n // Named by its label only: the treeitem also contains its icon and its child group. A\n // consumer aria-labelledby or aria-label replaces it.\n aria-labelledby={\n rest['aria-labelledby'] ?? (rest['aria-label'] === undefined ? nameId : undefined)\n }\n // The aside describes the item, after a consumer description.\n aria-describedby={joinIds(\n rest['aria-describedby'],\n hasAside ? asideId : undefined,\n layoutIds?.descriptionId,\n )}\n aria-expanded={hasChildren ? isExpanded : undefined}\n // From the checked list, after the rest props, so a consumer cannot contradict it.\n aria-checked={\n checkState === undefined\n ? undefined\n : checkState === 'mixed'\n ? 'mixed'\n : checkState === 'checked'\n }\n tabIndex={ctx.getTabIndex(value)}\n data-roving-value={value}\n data-selected={isSelected ? '' : undefined}\n data-current={isCurrent ? '' : undefined}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n onFocus={(event) =>\n composeEventHandlers(onFocus, handleFocus, { checkDefaultPrevented: false })(event)\n }\n onBlur={(event) =>\n composeEventHandlers(onBlur, handleActionsBlur, { checkDefaultPrevented: false })(event)\n }\n ref={mergedRef}\n >\n <div\n data-tree-row=\"\"\n className={cn(\n treeItemClassNames.row,\n 'flex cursor-pointer items-center gap-1.5 rounded px-2 py-1 hover:bg-subtle-hover',\n hasActions && 'group/row',\n isSelected && cn('bg-subtle-selected font-semibold', forcedColors.selectedContainer),\n )}\n >\n {chevron}\n {indicator}\n {iconNode}\n <span\n id={labelId}\n data-tree-label=\"\"\n data-roving-text={typeaheadText}\n // The label shrinks (and truncates) when the row has content after it.\n className={cn(\n treeItemClassNames.label,\n 'truncate',\n (iconAfterNode || hasAside || hasActions) && 'min-w-0',\n )}\n >\n <TreeCheckForcedContext.Provider value={false}>\n <TreeLabelContext.Provider value>\n <TreeItemContext.Provider value={itemContext}>\n {labelContent}\n </TreeItemContext.Provider>\n </TreeLabelContext.Provider>\n </TreeCheckForcedContext.Provider>\n </span>\n {iconAfterNode}\n {(hasAside || hasActions) && (\n <span\n data-tree-end=\"\"\n className={cn(\n 'group/end ms-auto inline-grid shrink-0 items-center gap-1',\n hasAside && hasActions && END_CELL_SHARED,\n )}\n >\n {hasAside && (\n <span\n id={asideId}\n data-tree-aside=\"\"\n className={cn(\n treeItemClassNames.aside,\n 'inline-flex items-center text-caption-1 text-muted-foreground',\n hasActions && ASIDE_OFF_WITH_ACTIONS,\n )}\n >\n {materialiseSlotContent(aside)}\n </span>\n )}\n {hasActions && (\n <TreeItemActions\n labelledBy={nameId}\n tabStop={\n ctx.navigationMode === 'tree' && ctx.focusedItem === value\n ? 'last-focused'\n : 'none'\n }\n navigationMode={ctx.navigationMode}\n onReturn={() => ctx.focusValue(value)}\n >\n {materialiseSlotContent(actions)}\n </TreeItemActions>\n )}\n </span>\n )}\n </div>\n {isGroupMounted && (\n <TreeParentContext.Provider value={value}>\n <TreeCheckForcedContext.Provider value={groupListed}>\n <TreeLabelContext.Provider value={false}>\n <div\n ref={collapseRef}\n {...collapsePresenceProps}\n className={cn(treeItemClassNames.collapse, collapseClassName)}\n >\n <div ref={groupRef} role=\"group\" className={cn(treeItemClassNames.group, 'ps-4')}>\n {nestedItems}\n </div>\n </div>\n </TreeLabelContext.Provider>\n </TreeCheckForcedContext.Provider>\n </TreeParentContext.Provider>\n )}\n </div>\n );\n};\nTreeItem.displayName = 'TreeItem';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAMG,KAA2B,CAAC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A,kBAACtE,EAAuB,UAAxB;MAAiC,OAAO;MACtC,UAAA,kBAACS,EAAiB,UAAlB;OAA2B,OAAA;OACzB,UAAA,kBAACqG,GAAgB,UAAjB;QAA0B,OAAO1D;QAC9B,UAAAG;OACuB,CAAA;MACD,CAAA;KACI,CAAA;IAC7B,CAAA;IACLW;KACCE,KAAYE,MACZ,kBAAC,QAAD;KACE,iBAAc;KACd,WAAWrE,EACT,6DACAmE,KAAYE,KAAc/I,EAC5B;KALF,UAAA,CAOG6I,KACC,kBAAC,QAAD;MACE,IAAIvB;MACJ,mBAAgB;MAChB,WAAW5C,EACTkC,EAAmB,OACnB,iEACAmC,KAAchJ,EAChB;MAEC,UAAAyL,EAAuB1C,CAAK;KACzB,CAAA,GAEPC,KACC,kBAACrD,GAAD;MACE,YAAYoC;MACZ,SACEd,EAAI,mBAAmB,UAAUA,EAAI,gBAAgB/H,IACjD,iBACA;MAEN,gBAAgB+H,EAAI;MACpB,gBAAgBA,EAAI,WAAW/H,CAAK;MAEnC,UAAAuM,EAAuBxC,CAAO;KAChB,CAAA,CAEf;;GAEL;EACJ,CAAA,GAAAI,MACC,kBAAC5E,EAAkB,UAAnB;GAAmC;GACjC,UAAA,kBAACC,EAAuB,UAAxB;IAAiC,OAAO4G;IACtC,UAAA,kBAACnG,EAAiB,UAAlB;KAA2B,OAAO;KAChC,UAAA,kBAAC,OAAD;MACE,KAAKmE;MACL,GAAIC;MACJ,WAAW5E,EAAGkC,EAAmB,UAAU2C,EAAiB;MAE5D,UAAA,kBAAC,OAAD;OAAK,KAAKJ;OAAU,MAAK;OAAQ,WAAWzE,EAAGkC,EAAmB,OAAO,MAAM;OAC5E,UAAAmB;MACE,CAAA;KACF,CAAA;IACoB,CAAA;GACI,CAAA;EACP,CAAA,CAE3B;;AAET;AACA,EAAS,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.mjs","names":["Tree","TreeRoot","TreeItem","TreeItemPersonaLayout"],"sources":["../../../src/components/layout/Tree.tsx"],"sourcesContent":["import { TreeItem, TreeRoot } from './Tree.core';\nimport { TreeItemPersonaLayout } from './Tree.itemPersonaLayout';\n\nexport type { TreeCheckedItemsChangeDetails, TreeItemProps, TreeProps } from './Tree.core';\nexport type { TreeItemPersonaLayoutProps } from './Tree.itemPersonaLayout';\n\n/**\n * A hierarchical list (WAI-ARIA Tree View pattern) with a single tab stop: Up/Down move between\n * visible items, Home/End to the first/last, Right expands or moves to the first child (or into\n * the row's actions, see below), Left collapses or moves to the parent (both mirrored in RTL),\n * Enter activates (and toggles a parent), and so does Space unless the tree has checkboxes, `*`\n * expands the siblings, and typing jumps to an item by its text.\n *\n * Keyboard focus enters at the `selected` item, else the first item; while focus is inside, the\n * tab stop follows it, so Shift+Tab leaves the tree.\n *\n * `selectionMode=\"multiple\"` draws a checkbox on every item, bound to `checkedItems`: Space\n * toggles the focused item's check, a click on the checkbox toggles it, and a click elsewhere on\n * the row activates the item (as Enter does). Checks cascade: checking an item checks every item\n * nested in it, and an item shows checked when all of its nested items are checked, mixed when\n * some are. `onCheckedItemsChange` receives every checked item in tree order (fully checked parents\n * included), followed by listed values that match no item, and `details` (`value`, `checked`,\n * `event`).\n *\n * Row content: `actions` (buttons at the end of the row, in a toolbar named by the item, shown on\n * hover and focus, and always where there is no hover or colors are forced), `aside` (a count or a\n * badge that describes the item), `iconAfter` and `expandIcon`. Tab from the focused item enters\n * its actions and Shift+Tab returns. Keys and clicks on the actions never activate or check the\n * item. With `navigationMode=\"treegrid\"`, Right (Left in right-to-left layouts) moves from an\n * item into its actions and Left returns, the actions take no Tab stop, and on an open parent Right\n * moves into its actions rather than to its first child (Down does); the roles stay `tree` and\n * `treeitem`.\n *\n * Items are `Tree.Item` elements; nested items are written in their parent's children (directly,\n * in Fragments, or returned by a render function), not rendered by a component of their own.\n * Every item needs a `value` that is unique within the Tree. `Tree.ItemPersonaLayout` lays out a\n * person (media, name and description) as an item's label.\n *\n * `Tree.Item` and `Tree.ItemPersonaLayout` are also exported as `TreeItem` and\n * `TreeItemPersonaLayout` for React Server Components, which cannot use the dotted form.\n */\nexport const Tree = /* @__PURE__ */ Object.assign(TreeRoot, {\n Item: TreeItem,\n ItemPersonaLayout: TreeItemPersonaLayout,\n});\n\nexport { TreeItem, TreeItemPersonaLayout };\n"],"mappings":";;;;AAyCA,IAAaA,IAAuB,uBAAO,OAAOC,GAAU;CAC1D,MAAMC;CACN,mBAAmBC;AACrB,CAAC"}
1
+ {"version":3,"file":"Tree.mjs","names":["Tree","TreeRoot","TreeItem","TreeItemPersonaLayout"],"sources":["../../../src/components/layout/Tree.tsx"],"sourcesContent":["import { TreeItem, TreeRoot } from './Tree.core';\nimport { TreeItemPersonaLayout } from './Tree.itemPersonaLayout';\n\nexport type { TreeCheckedItemsChangeDetails, TreeItemProps, TreeProps } from './Tree.core';\nexport type { TreeItemPersonaLayoutProps } from './Tree.itemPersonaLayout';\n\n/**\n * A hierarchical list (WAI-ARIA Tree View pattern) with a single tab stop: Up/Down move between\n * visible items, Home/End to the first/last, Right expands or moves to the first child (or into\n * the row's actions, see below), Left collapses or moves to the parent (both mirrored in RTL),\n * Enter activates (and toggles a parent), and so does Space unless the tree has checkboxes, `*`\n * expands the siblings, and typing jumps to an item by its text.\n *\n * Keyboard focus enters at the `selected` item, else the first item; while focus is inside, the\n * tab stop follows it, so Shift+Tab leaves the tree.\n *\n * A child group opens and closes its space with a short collapse and fade (the Tree's `motion`;\n * none under reduced motion or a `WaveProvider` with `motion=\"none\"`), and focus inside a group\n * that collapses moves to its item.\n *\n * `selectionMode=\"multiple\"` draws a checkbox on every item, bound to `checkedItems`: Space\n * toggles the focused item's check, a click on the checkbox toggles it, and a click elsewhere on\n * the row activates the item (as Enter does). Checks cascade: checking an item checks every item\n * nested in it, and an item shows checked when all of its nested items are checked, mixed when\n * some are. `onCheckedItemsChange` receives every checked item in tree order (fully checked parents\n * included), followed by listed values that match no item, and `details` (`value`, `checked`,\n * `event`).\n *\n * Row content: `actions` (buttons at the end of the row, in a toolbar named by the item, shown on\n * hover and focus, and always where there is no hover or colors are forced), `aside` (a count or a\n * badge that describes the item), `iconAfter` and `expandIcon`. Tab from the focused item enters\n * its actions and Shift+Tab returns. Keys and clicks on the actions never activate or check the\n * item. With `navigationMode=\"treegrid\"`, Right (Left in right-to-left layouts) moves from an\n * item into its actions and Left returns, the actions take no Tab stop, and on an open parent Right\n * moves into its actions rather than to its first child (Down does); the roles stay `tree` and\n * `treeitem`.\n *\n * Items are `Tree.Item` elements; nested items are written in their parent's children (directly,\n * in Fragments, or returned by a render function), not rendered by a component of their own.\n * Every item needs a `value` that is unique within the Tree. `Tree.ItemPersonaLayout` lays out a\n * person (media, name and description) as an item's label.\n *\n * `Tree.Item` and `Tree.ItemPersonaLayout` are also exported as `TreeItem` and\n * `TreeItemPersonaLayout` for React Server Components, which cannot use the dotted form.\n */\nexport const Tree = /* @__PURE__ */ Object.assign(TreeRoot, {\n Item: TreeItem,\n ItemPersonaLayout: TreeItemPersonaLayout,\n});\n\nexport { TreeItem, TreeItemPersonaLayout };\n"],"mappings":";;;;AA6CA,IAAaA,IAAuB,uBAAO,OAAOC,GAAU;CAC1D,MAAMC;CACN,mBAAmBC;AACrB,CAAC"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs");let n=require("react");n=e.__toESM(n,1);function r(e,i){let a=[];for(let o of n.Children.toArray(e)){if(!n.isValidElement(o))continue;let e=t.getElementType(o,{suspend:!1});if(e===n.Fragment){a.push(...r(o.props.children,i));continue}if(e===i.tree||e!==i.item)continue;let{value:s,leaf:c,children:l}=o.props;typeof s==`string`&&a.push({value:s,children:c===!0?[]:r(l,i)})}return a}function i(e,t){for(let n of e)t(n),i(n.children,t)}function a(e,t){for(let n of e){if(n.value===t)return[n];let e=a(n.children,t);if(e)return[n,...e]}return null}function o(e,t,n=!1){let r=new Map;i(e,e=>{r.has(e.value)||r.set(e.value,e)});let a=new Map,o=(e,n)=>{let i=n||t.has(e.value),s=e.children.map(e=>o(e,i)),c;return c=i?`checked`:s.length===0?`unchecked`:s.every(e=>e===`checked`)?`checked`:s.some(e=>e!==`unchecked`)?`mixed`:`unchecked`,r.get(e.value)===e&&a.set(e.value,c),c};for(let t of e)o(t,n);return a}function s(e,t,n){let r=o(e,new Set(t)),s=new Set;for(let[e,t]of r)t===`checked`&&s.add(e);let c=new Set;i(e,e=>c.add(e.value));let l=Array.from(new Set(t.filter(e=>!c.has(e)))),u=a(e,n);if(u){let e=u[u.length-1],t=r.get(n)!==`checked`;i([e],e=>{t?s.add(e.value):s.delete(e.value)});for(let e=u.length-2;e>=0;--e){let t=u[e];t.children.every(e=>s.has(e.value))?s.add(t.value):s.delete(t.value)}}else{let e=l.indexOf(n);e===-1?l.push(n):l.splice(e,1)}let d=[],f=new Set;return i(e,e=>{s.has(e.value)&&!f.has(e.value)&&(f.add(e.value),d.push(e.value))}),[...d,...l]}exports.collectItems=r,exports.computeCheckStates=o,exports.toggleCheck=s;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs"),n=require("../../lib/treeCascade.cjs");let r=require("react");r=e.__toESM(r,1);function i(e,n){let a=[];for(let o of r.Children.toArray(e)){if(!r.isValidElement(o))continue;let e=t.getElementType(o,{suspend:!1});if(e===r.Fragment){a.push(...i(o.props.children,n));continue}if(e===n.tree||e!==n.item)continue;let{value:s,leaf:c,children:l}=o.props;typeof s==`string`&&a.push({value:s,children:c===!0?[]:i(l,n)})}return a}exports.collectItems=i,exports.computeCheckStates=n.computeCheckStates,exports.toggleCheck=n.toggleCheck;
2
2
  //# sourceMappingURL=Tree.selection.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.selection.cjs","names":["React","getElementType","require_runtime","require_children","react","collectItems","nodes","node","children","type","types","nested","value","leaf","forEachNode","visit","findPath","below","computeCheckStates","first","candidate","states","forced","forcedAbove","listed","current","childStates","child","state","childState","top","ancestorListed","toggleCheck","checked","itemValue","known","unmatched","listedValue","path","target","turnOn","index","ancestor","at","ordered","seen"],"sources":["../../../src/components/layout/Tree.selection.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\n\n/** One Tree.Item of the cascade model: its value and the items nested in it. */\nexport interface TreeNode {\n value: string;\n children: TreeNode[];\n}\n\n/** The check state of an item in a `selectionMode=\"multiple\"` tree. */\nexport type CheckState = 'checked' | 'mixed' | 'unchecked';\n\n/** The element types the scan compares with: the item type, and the tree type (a tree of its own). */\nexport interface TreeElementTypes {\n item: unknown;\n tree: unknown;\n}\n\ninterface ItemElementProps {\n value?: unknown;\n leaf?: unknown;\n children?: React.ReactNode;\n}\n\n/**\n * The Tree.Item elements among `children`, recursively and in element order: the rule that forms\n * an item's child group (items written directly, in Fragments, or returned by a render function),\n * so the items of a collapsed item count too. A `leaf` item has none; a nested tree is a tree of\n * its own; any other element is not entered (an item that a component renders is not part of a\n * child group). A lazy type whose code is still loading is skipped instead of suspending the\n * caller (`getElementType(…, { suspend: false })`, as walks deeper than the direct children do).\n */\nexport function collectItems(children: React.ReactNode, types: TreeElementTypes): TreeNode[] {\n const nodes: TreeNode[] = [];\n for (const node of React.Children.toArray(children)) {\n if (!React.isValidElement<ItemElementProps>(node)) continue;\n const type = getElementType(node, { suspend: false });\n if (type === React.Fragment) {\n // Flattened here rather than through `flattenChildren`, which resolves lazy types with\n // suspending: a Fragment's items belong to the enclosing group.\n nodes.push(...collectItems(node.props.children, types));\n continue;\n }\n if (type === types.tree || type !== types.item) continue;\n const { value, leaf, children: nested } = node.props;\n if (typeof value !== 'string') continue;\n nodes.push({ value, children: leaf === true ? [] : collectItems(nested, types) });\n }\n return nodes;\n}\n\nfunction forEachNode(nodes: readonly TreeNode[], visit: (node: TreeNode) => void): void {\n for (const node of nodes) {\n visit(node);\n forEachNode(node.children, visit);\n }\n}\n\n/** The first item with `value` in tree order and its ancestors, from the top down; `null` if none. */\nfunction findPath(nodes: readonly TreeNode[], value: string): TreeNode[] | null {\n for (const node of nodes) {\n if (node.value === value) return [node];\n const below = findPath(node.children, value);\n if (below) return [node, ...below];\n }\n return null;\n}\n\n/**\n * The check state of every item: checked when its value is listed, when an ancestor's value is\n * listed (or `ancestorListed`), or when it has nested items and all of them are checked; mixed\n * when some of them are checked or mixed; else unchecked. For a value that several items share,\n * the first item in tree order decides the entry.\n */\nexport function computeCheckStates(\n nodes: readonly TreeNode[],\n listed: ReadonlySet<string>,\n ancestorListed = false,\n): Map<string, CheckState> {\n const first = new Map<string, TreeNode>();\n forEachNode(nodes, (candidate) => {\n if (!first.has(candidate.value)) first.set(candidate.value, candidate);\n });\n const states = new Map<string, CheckState>();\n const visit = (current: TreeNode, forcedAbove: boolean): CheckState => {\n const forced = forcedAbove || listed.has(current.value);\n const childStates = current.children.map((child) => visit(child, forced));\n let state: CheckState;\n if (forced) state = 'checked';\n else if (childStates.length === 0) state = 'unchecked';\n else if (childStates.every((childState) => childState === 'checked')) state = 'checked';\n else if (childStates.some((childState) => childState !== 'unchecked')) state = 'mixed';\n else state = 'unchecked';\n if (first.get(current.value) === current) states.set(current.value, state);\n return state;\n };\n for (const top of nodes) visit(top, ancestorListed);\n return states;\n}\n\n/**\n * The checked items after toggling `value`. A checked item and every item nested in it become\n * unchecked; an unchecked or mixed one and every item nested in it become checked; its ancestors\n * then follow their nested items. Returns every checked item in tree order (fully checked parents\n * included, mixed ones not), each value once, followed by the listed values that match no item,\n * in their order; a value that no item has is added to, or removed from, those.\n */\nexport function toggleCheck(\n nodes: readonly TreeNode[],\n listed: readonly string[],\n value: string,\n): string[] {\n const states = computeCheckStates(nodes, new Set(listed));\n const checked = new Set<string>();\n for (const [itemValue, state] of states) {\n if (state === 'checked') checked.add(itemValue);\n }\n const known = new Set<string>();\n forEachNode(nodes, (candidate) => known.add(candidate.value));\n const unmatched = Array.from(new Set(listed.filter((listedValue) => !known.has(listedValue))));\n\n const path = findPath(nodes, value);\n if (path) {\n const target = path[path.length - 1];\n const turnOn = states.get(value) !== 'checked';\n forEachNode([target], (candidate) => {\n if (turnOn) checked.add(candidate.value);\n else checked.delete(candidate.value);\n });\n for (let index = path.length - 2; index >= 0; index -= 1) {\n const ancestor = path[index];\n if (ancestor.children.every((child) => checked.has(child.value))) checked.add(ancestor.value);\n else checked.delete(ancestor.value);\n }\n } else {\n const at = unmatched.indexOf(value);\n if (at === -1) unmatched.push(value);\n else unmatched.splice(at, 1);\n }\n\n const ordered: string[] = [];\n const seen = new Set<string>();\n forEachNode(nodes, (candidate) => {\n if (checked.has(candidate.value) && !seen.has(candidate.value)) {\n seen.add(candidate.value);\n ordered.push(candidate.value);\n }\n });\n return [...ordered, ...unmatched];\n}\n"],"mappings":"iJAgCA,SAAgBK,EAAa,EAA2B,EAAqC,CAC3F,IAAMC,EAAoB,CAAC,EAC3B,IAAK,IAAMC,KAAQP,EAAM,SAAS,QAAQQ,CAAQ,EAAG,CACnD,GAAI,CAACR,EAAM,eAAiCO,CAAI,EAAG,SACnD,IAAME,EAAOR,EAAAA,eAAeM,EAAM,CAAE,QAAS,EAAM,CAAC,EACpD,GAAIE,IAAST,EAAM,SAAU,CAG3BM,EAAM,KAAK,GAAGD,EAAaE,EAAK,MAAM,SAAUG,CAAK,CAAC,EACtD,QACF,CACA,GAAID,IAASC,EAAM,MAAQD,IAASC,EAAM,KAAM,SAChD,GAAM,CAAE,QAAO,OAAM,SAAUC,GAAWJ,EAAK,MAC3C,OAAOK,GAAU,UACrBN,EAAM,KAAK,CAAE,QAAO,SAAUO,IAAS,GAAO,CAAC,EAAIR,EAAaM,EAAQD,CAAK,CAAE,CAAC,CAClF,CACA,OAAOJ,CACT,CAEA,SAASQ,EAAY,EAA4B,EAAuC,CACtF,IAAK,IAAMP,KAAQD,EACjBS,EAAMR,CAAI,EACVO,EAAYP,EAAK,SAAUQ,CAAK,CAEpC,CAGA,SAASC,EAAS,EAA4B,EAAkC,CAC9E,IAAK,IAAMT,KAAQD,EAAO,CACxB,GAAIC,EAAK,QAAUK,EAAO,MAAO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,CAAK,EAClC,GAAI0B,EAAM,CACR,IAAMC,EAASD,EAAKA,EAAK,OAAS,GAC5BE,EAASnB,EAAO,IAAIT,CAAK,IAAM,UACrCE,EAAY,CAACyB,CAAM,EAAI,GAAc,CAC/BC,EAAQP,EAAQ,IAAIb,EAAU,KAAK,EAClCa,EAAQ,OAAOb,EAAU,KAAK,CACrC,CAAC,EACD,IAAK,IAAIqB,EAAQH,EAAK,OAAS,EAAGG,GAAS,EAAG,IAAY,CACxD,IAAMC,EAAWJ,EAAKG,GAClBC,EAAS,SAAS,MAAO,GAAUT,EAAQ,IAAIN,EAAM,KAAK,CAAC,EAAGM,EAAQ,IAAIS,EAAS,KAAK,EACvFT,EAAQ,OAAOS,EAAS,KAAK,CACpC,CACF,KAAO,CACL,IAAMC,EAAKP,EAAU,QAAQxB,CAAK,EAC9B+B,IAAO,GAAIP,EAAU,KAAKxB,CAAK,EAC9BwB,EAAU,OAAOO,EAAI,CAAC,CAC7B,CAEA,IAAMC,EAAoB,CAAC,EACrBC,EAAO,IAAI,IAOjB,OANA/B,EAAYR,EAAQ,GAAc,CAC5B2B,EAAQ,IAAIb,EAAU,KAAK,GAAK,CAACyB,EAAK,IAAIzB,EAAU,KAAK,IAC3DyB,EAAK,IAAIzB,EAAU,KAAK,EACxBwB,EAAQ,KAAKxB,EAAU,KAAK,EAEhC,CAAC,EACM,CAAC,GAAGwB,EAAS,GAAGR,CAAS,CAClC"}
1
+ {"version":3,"file":"Tree.selection.cjs","names":["React","getElementType","require_runtime","require_children","require_treeCascade","react","collectItems","nodes","node","children","type","types","nested","value","leaf"],"sources":["../../../src/components/layout/Tree.selection.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\nimport type { TreeNode } from '../../lib/treeCascade';\n\nexport { computeCheckStates, toggleCheck } from '../../lib/treeCascade';\nexport type { CheckState, TreeNode } from '../../lib/treeCascade';\n\n/** The element types the scan compares with: the item type, and the tree type (a tree of its own). */\nexport interface TreeElementTypes {\n item: unknown;\n tree: unknown;\n}\n\ninterface ItemElementProps {\n value?: unknown;\n leaf?: unknown;\n children?: React.ReactNode;\n}\n\n/**\n * The Tree.Item elements among `children`, recursively and in element order: the rule that forms\n * an item's child group (items written directly, in Fragments, or returned by a render function),\n * so the items of a collapsed item count too. A `leaf` item has none; a nested tree is a tree of\n * its own; any other element is not entered (an item that a component renders is not part of a\n * child group). A lazy type whose code is still loading is skipped instead of suspending the\n * caller (`getElementType(…, { suspend: false })`, as walks deeper than the direct children do).\n */\nexport function collectItems(children: React.ReactNode, types: TreeElementTypes): TreeNode[] {\n const nodes: TreeNode[] = [];\n for (const node of React.Children.toArray(children)) {\n if (!React.isValidElement<ItemElementProps>(node)) continue;\n const type = getElementType(node, { suspend: false });\n if (type === React.Fragment) {\n // Flattened here rather than through `flattenChildren`, which resolves lazy types with\n // suspending: a Fragment's items belong to the enclosing group.\n nodes.push(...collectItems(node.props.children, types));\n continue;\n }\n if (type === types.tree || type !== types.item) continue;\n const { value, leaf, children: nested } = node.props;\n if (typeof value !== 'string') continue;\n nodes.push({ value, children: leaf === true ? [] : collectItems(nested, types) });\n }\n return nodes;\n}\n"],"mappings":"wLA2BA,SAAgBM,EAAa,EAA2B,EAAqC,CAC3F,IAAMC,EAAoB,CAAC,EAC3B,IAAK,IAAMC,KAAQR,EAAM,SAAS,QAAQS,CAAQ,EAAG,CACnD,GAAI,CAACT,EAAM,eAAiCQ,CAAI,EAAG,SACnD,IAAME,EAAOT,EAAAA,eAAeO,EAAM,CAAE,QAAS,EAAM,CAAC,EACpD,GAAIE,IAASV,EAAM,SAAU,CAG3BO,EAAM,KAAK,GAAGD,EAAaE,EAAK,MAAM,SAAUG,CAAK,CAAC,EACtD,QACF,CACA,GAAID,IAASC,EAAM,MAAQD,IAASC,EAAM,KAAM,SAChD,GAAM,CAAE,QAAO,OAAM,SAAUC,GAAWJ,EAAK,MAC3C,OAAOK,GAAU,UACrBN,EAAM,KAAK,CAAE,QAAO,SAAUO,IAAS,GAAO,CAAC,EAAIR,EAAaM,EAAQD,CAAK,CAAE,CAAC,CAClF,CACA,OAAOJ,CACT"}
@@ -1,73 +1,27 @@
1
1
  "use client";
2
2
  import { getElementType as e } from "../../lib/children.mjs";
3
- import * as t from "react";
3
+ import { computeCheckStates as t, toggleCheck as n } from "../../lib/treeCascade.mjs";
4
+ import * as r from "react";
4
5
  //#region src/components/layout/Tree.selection.ts
5
- function n(r, i) {
6
+ function i(t, n) {
6
7
  let a = [];
7
- for (let o of t.Children.toArray(r)) {
8
- if (!t.isValidElement(o)) continue;
9
- let r = e(o, { suspend: !1 });
10
- if (r === t.Fragment) {
11
- a.push(...n(o.props.children, i));
8
+ for (let o of r.Children.toArray(t)) {
9
+ if (!r.isValidElement(o)) continue;
10
+ let t = e(o, { suspend: !1 });
11
+ if (t === r.Fragment) {
12
+ a.push(...i(o.props.children, n));
12
13
  continue;
13
14
  }
14
- if (r === i.tree || r !== i.item) continue;
15
+ if (t === n.tree || t !== n.item) continue;
15
16
  let { value: s, leaf: c, children: l } = o.props;
16
17
  typeof s == "string" && a.push({
17
18
  value: s,
18
- children: c === !0 ? [] : n(l, i)
19
+ children: c === !0 ? [] : i(l, n)
19
20
  });
20
21
  }
21
22
  return a;
22
23
  }
23
- function r(e, t) {
24
- for (let n of e) t(n), r(n.children, t);
25
- }
26
- function i(e, t) {
27
- for (let n of e) {
28
- if (n.value === t) return [n];
29
- let e = i(n.children, t);
30
- if (e) return [n, ...e];
31
- }
32
- return null;
33
- }
34
- function a(e, t, n = !1) {
35
- let i = /* @__PURE__ */ new Map();
36
- r(e, (e) => {
37
- i.has(e.value) || i.set(e.value, e);
38
- });
39
- let a = /* @__PURE__ */ new Map(), o = (e, n) => {
40
- let r = n || t.has(e.value), s = e.children.map((e) => o(e, r)), c;
41
- return c = r ? "checked" : s.length === 0 ? "unchecked" : s.every((e) => e === "checked") ? "checked" : s.some((e) => e !== "unchecked") ? "mixed" : "unchecked", i.get(e.value) === e && a.set(e.value, c), c;
42
- };
43
- for (let t of e) o(t, n);
44
- return a;
45
- }
46
- function o(e, t, n) {
47
- let o = a(e, new Set(t)), s = /* @__PURE__ */ new Set();
48
- for (let [e, t] of o) t === "checked" && s.add(e);
49
- let c = /* @__PURE__ */ new Set();
50
- r(e, (e) => c.add(e.value));
51
- let l = Array.from(new Set(t.filter((e) => !c.has(e)))), u = i(e, n);
52
- if (u) {
53
- let e = u[u.length - 1], t = o.get(n) !== "checked";
54
- r([e], (e) => {
55
- t ? s.add(e.value) : s.delete(e.value);
56
- });
57
- for (let e = u.length - 2; e >= 0; --e) {
58
- let t = u[e];
59
- t.children.every((e) => s.has(e.value)) ? s.add(t.value) : s.delete(t.value);
60
- }
61
- } else {
62
- let e = l.indexOf(n);
63
- e === -1 ? l.push(n) : l.splice(e, 1);
64
- }
65
- let d = [], f = /* @__PURE__ */ new Set();
66
- return r(e, (e) => {
67
- s.has(e.value) && !f.has(e.value) && (f.add(e.value), d.push(e.value));
68
- }), [...d, ...l];
69
- }
70
24
  //#endregion
71
- export { n as collectItems, a as computeCheckStates, o as toggleCheck };
25
+ export { i as collectItems, t as computeCheckStates, n as toggleCheck };
72
26
 
73
27
  //# sourceMappingURL=Tree.selection.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.selection.mjs","names":["React","collectItems","nodes","node","children","type","getElementType","types","nested","value","leaf","forEachNode","visit","findPath","below","computeCheckStates","first","candidate","states","forced","forcedAbove","listed","current","childStates","child","state","childState","top","ancestorListed","toggleCheck","checked","itemValue","known","unmatched","listedValue","path","target","turnOn","index","ancestor","at","ordered","seen"],"sources":["../../../src/components/layout/Tree.selection.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\n\n/** One Tree.Item of the cascade model: its value and the items nested in it. */\nexport interface TreeNode {\n value: string;\n children: TreeNode[];\n}\n\n/** The check state of an item in a `selectionMode=\"multiple\"` tree. */\nexport type CheckState = 'checked' | 'mixed' | 'unchecked';\n\n/** The element types the scan compares with: the item type, and the tree type (a tree of its own). */\nexport interface TreeElementTypes {\n item: unknown;\n tree: unknown;\n}\n\ninterface ItemElementProps {\n value?: unknown;\n leaf?: unknown;\n children?: React.ReactNode;\n}\n\n/**\n * The Tree.Item elements among `children`, recursively and in element order: the rule that forms\n * an item's child group (items written directly, in Fragments, or returned by a render function),\n * so the items of a collapsed item count too. A `leaf` item has none; a nested tree is a tree of\n * its own; any other element is not entered (an item that a component renders is not part of a\n * child group). A lazy type whose code is still loading is skipped instead of suspending the\n * caller (`getElementType(…, { suspend: false })`, as walks deeper than the direct children do).\n */\nexport function collectItems(children: React.ReactNode, types: TreeElementTypes): TreeNode[] {\n const nodes: TreeNode[] = [];\n for (const node of React.Children.toArray(children)) {\n if (!React.isValidElement<ItemElementProps>(node)) continue;\n const type = getElementType(node, { suspend: false });\n if (type === React.Fragment) {\n // Flattened here rather than through `flattenChildren`, which resolves lazy types with\n // suspending: a Fragment's items belong to the enclosing group.\n nodes.push(...collectItems(node.props.children, types));\n continue;\n }\n if (type === types.tree || type !== types.item) continue;\n const { value, leaf, children: nested } = node.props;\n if (typeof value !== 'string') continue;\n nodes.push({ value, children: leaf === true ? [] : collectItems(nested, types) });\n }\n return nodes;\n}\n\nfunction forEachNode(nodes: readonly TreeNode[], visit: (node: TreeNode) => void): void {\n for (const node of nodes) {\n visit(node);\n forEachNode(node.children, visit);\n }\n}\n\n/** The first item with `value` in tree order and its ancestors, from the top down; `null` if none. */\nfunction findPath(nodes: readonly TreeNode[], value: string): TreeNode[] | null {\n for (const node of nodes) {\n if (node.value === value) return [node];\n const below = findPath(node.children, value);\n if (below) return [node, ...below];\n }\n return null;\n}\n\n/**\n * The check state of every item: checked when its value is listed, when an ancestor's value is\n * listed (or `ancestorListed`), or when it has nested items and all of them are checked; mixed\n * when some of them are checked or mixed; else unchecked. For a value that several items share,\n * the first item in tree order decides the entry.\n */\nexport function computeCheckStates(\n nodes: readonly TreeNode[],\n listed: ReadonlySet<string>,\n ancestorListed = false,\n): Map<string, CheckState> {\n const first = new Map<string, TreeNode>();\n forEachNode(nodes, (candidate) => {\n if (!first.has(candidate.value)) first.set(candidate.value, candidate);\n });\n const states = new Map<string, CheckState>();\n const visit = (current: TreeNode, forcedAbove: boolean): CheckState => {\n const forced = forcedAbove || listed.has(current.value);\n const childStates = current.children.map((child) => visit(child, forced));\n let state: CheckState;\n if (forced) state = 'checked';\n else if (childStates.length === 0) state = 'unchecked';\n else if (childStates.every((childState) => childState === 'checked')) state = 'checked';\n else if (childStates.some((childState) => childState !== 'unchecked')) state = 'mixed';\n else state = 'unchecked';\n if (first.get(current.value) === current) states.set(current.value, state);\n return state;\n };\n for (const top of nodes) visit(top, ancestorListed);\n return states;\n}\n\n/**\n * The checked items after toggling `value`. A checked item and every item nested in it become\n * unchecked; an unchecked or mixed one and every item nested in it become checked; its ancestors\n * then follow their nested items. Returns every checked item in tree order (fully checked parents\n * included, mixed ones not), each value once, followed by the listed values that match no item,\n * in their order; a value that no item has is added to, or removed from, those.\n */\nexport function toggleCheck(\n nodes: readonly TreeNode[],\n listed: readonly string[],\n value: string,\n): string[] {\n const states = computeCheckStates(nodes, new Set(listed));\n const checked = new Set<string>();\n for (const [itemValue, state] of states) {\n if (state === 'checked') checked.add(itemValue);\n }\n const known = new Set<string>();\n forEachNode(nodes, (candidate) => known.add(candidate.value));\n const unmatched = Array.from(new Set(listed.filter((listedValue) => !known.has(listedValue))));\n\n const path = findPath(nodes, value);\n if (path) {\n const target = path[path.length - 1];\n const turnOn = states.get(value) !== 'checked';\n forEachNode([target], (candidate) => {\n if (turnOn) checked.add(candidate.value);\n else checked.delete(candidate.value);\n });\n for (let index = path.length - 2; index >= 0; index -= 1) {\n const ancestor = path[index];\n if (ancestor.children.every((child) => checked.has(child.value))) checked.add(ancestor.value);\n else checked.delete(ancestor.value);\n }\n } else {\n const at = unmatched.indexOf(value);\n if (at === -1) unmatched.push(value);\n else unmatched.splice(at, 1);\n }\n\n const ordered: string[] = [];\n const seen = new Set<string>();\n forEachNode(nodes, (candidate) => {\n if (checked.has(candidate.value) && !seen.has(candidate.value)) {\n seen.add(candidate.value);\n ordered.push(candidate.value);\n }\n });\n return [...ordered, ...unmatched];\n}\n"],"mappings":";;;;AAgCA,SAAgBC,EAAa,GAA2B,GAAqC;CAC3F,IAAMC,IAAoB,CAAC;CAC3B,KAAK,IAAMC,KAAQH,EAAM,SAAS,QAAQI,CAAQ,GAAG;EACnD,IAAI,CAACJ,EAAM,eAAiCG,CAAI,GAAG;EACnD,IAAME,IAAOC,EAAeH,GAAM,EAAE,SAAS,GAAM,CAAC;EACpD,IAAIE,MAASL,EAAM,UAAU;GAG3B,EAAM,KAAK,GAAGC,EAAaE,EAAK,MAAM,UAAUI,CAAK,CAAC;GACtD;EACF;EACA,IAAIF,MAASE,EAAM,QAAQF,MAASE,EAAM,MAAM;EAChD,IAAM,EAAE,UAAO,SAAM,UAAUC,MAAWL,EAAK;EAC/C,AAAI,OAAOM,KAAU,YACrBP,EAAM,KAAK;GAAE;GAAO,UAAUQ,MAAS,KAAO,CAAC,IAAIT,EAAaO,GAAQD,CAAK;EAAE,CAAC;CAClF;CACA,OAAOL;AACT;AAEA,SAASS,EAAY,GAA4B,GAAuC;CACtF,KAAK,IAAMR,KAAQD,GAEjB,AADAU,EAAMT,CAAI,GACVQ,EAAYR,EAAK,UAAUS,CAAK;AAEpC;AAGA,SAASC,EAAS,GAA4B,GAAkC;CAC9E,KAAK,IAAMV,KAAQD,GAAO;EACxB,IAAIC,EAAK,UAAUM,GAAO,OAAO,CAACN,CAAI;EACtC,IAAMW,IAAQD,EAASV,EAAK,UAAUM,CAAK;EAC3C,IAAIK,GAAO,OAAO,CAACX,GAAM,GAAGW,CAAK;CACnC;CACA,OAAO;AACT;AAQA,SAAgBC,EACd,GACA,GACA,IAAiB,IACQ;CACzB,IAAMC,oBAAQ,IAAI,IAAsB;CACxC,EAAYd,IAAQ,MAAc;EAChC,AAAKc,EAAM,IAAIC,EAAU,KAAK,KAAGD,EAAM,IAAI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B,IAAQH,EAAK,SAAS,GAAGG,KAAS,GAAG,KAAY;GACxD,IAAMC,IAAWJ,EAAKG;GACtB,AAAIC,EAAS,SAAS,OAAO,MAAUT,EAAQ,IAAIN,EAAM,KAAK,CAAC,IAAGM,EAAQ,IAAIS,EAAS,KAAK,IACvFT,EAAQ,OAAOS,EAAS,KAAK;EACpC;CACF,OAAO;EACL,IAAMC,IAAKP,EAAU,QAAQxB,CAAK;EAClC,AAAI+B,MAAO,KAAIP,EAAU,KAAKxB,CAAK,IAC9BwB,EAAU,OAAOO,GAAI,CAAC;CAC7B;CAEA,IAAMC,IAAoB,CAAC,GACrBC,oBAAO,IAAI,IAAY;CAO7B,OANA/B,EAAYT,IAAQ,MAAc;EAChC,AAAI4B,EAAQ,IAAIb,EAAU,KAAK,KAAK,CAACyB,EAAK,IAAIzB,EAAU,KAAK,MAC3DyB,EAAK,IAAIzB,EAAU,KAAK,GACxBwB,EAAQ,KAAKxB,EAAU,KAAK;CAEhC,CAAC,GACM,CAAC,GAAGwB,GAAS,GAAGR,CAAS;AAClC"}
1
+ {"version":3,"file":"Tree.selection.mjs","names":["React","collectItems","nodes","node","children","type","getElementType","types","nested","value","leaf","computeCheckStates","toggleCheck"],"sources":["../../../src/components/layout/Tree.selection.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\nimport type { TreeNode } from '../../lib/treeCascade';\n\nexport { computeCheckStates, toggleCheck } from '../../lib/treeCascade';\nexport type { CheckState, TreeNode } from '../../lib/treeCascade';\n\n/** The element types the scan compares with: the item type, and the tree type (a tree of its own). */\nexport interface TreeElementTypes {\n item: unknown;\n tree: unknown;\n}\n\ninterface ItemElementProps {\n value?: unknown;\n leaf?: unknown;\n children?: React.ReactNode;\n}\n\n/**\n * The Tree.Item elements among `children`, recursively and in element order: the rule that forms\n * an item's child group (items written directly, in Fragments, or returned by a render function),\n * so the items of a collapsed item count too. A `leaf` item has none; a nested tree is a tree of\n * its own; any other element is not entered (an item that a component renders is not part of a\n * child group). A lazy type whose code is still loading is skipped instead of suspending the\n * caller (`getElementType(…, { suspend: false })`, as walks deeper than the direct children do).\n */\nexport function collectItems(children: React.ReactNode, types: TreeElementTypes): TreeNode[] {\n const nodes: TreeNode[] = [];\n for (const node of React.Children.toArray(children)) {\n if (!React.isValidElement<ItemElementProps>(node)) continue;\n const type = getElementType(node, { suspend: false });\n if (type === React.Fragment) {\n // Flattened here rather than through `flattenChildren`, which resolves lazy types with\n // suspending: a Fragment's items belong to the enclosing group.\n nodes.push(...collectItems(node.props.children, types));\n continue;\n }\n if (type === types.tree || type !== types.item) continue;\n const { value, leaf, children: nested } = node.props;\n if (typeof value !== 'string') continue;\n nodes.push({ value, children: leaf === true ? [] : collectItems(nested, types) });\n }\n return nodes;\n}\n"],"mappings":";;;;;AA2BA,SAAgBC,EAAa,GAA2B,GAAqC;CAC3F,IAAMC,IAAoB,CAAC;CAC3B,KAAK,IAAMC,KAAQH,EAAM,SAAS,QAAQI,CAAQ,GAAG;EACnD,IAAI,CAACJ,EAAM,eAAiCG,CAAI,GAAG;EACnD,IAAME,IAAOC,EAAeH,GAAM,EAAE,SAAS,GAAM,CAAC;EACpD,IAAIE,MAASL,EAAM,UAAU;GAG3B,EAAM,KAAK,GAAGC,EAAaE,EAAK,MAAM,UAAUI,CAAK,CAAC;GACtD;EACF;EACA,IAAIF,MAASE,EAAM,QAAQF,MAASE,EAAM,MAAM;EAChD,IAAM,EAAE,UAAO,SAAM,UAAUC,MAAWL,EAAK;EAC/C,AAAI,OAAOM,KAAU,YACrBP,EAAM,KAAK;GAAE;GAAO,UAAUQ,MAAS,KAAO,CAAC,IAAIT,EAAaO,GAAQD,CAAK;EAAE,CAAC;CAClF;CACA,OAAOL;AACT"}
@@ -0,0 +1,2 @@
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/dev.cjs"),n=require("../../hooks/useEventCallback.cjs"),r=require("../../hooks/useControllable.cjs"),i=require("../../lib/treeCascade.cjs"),a=require("../../lib/flatTree.cjs");let o=require("react");o=e.__toESM(o,1);var s=[];function c(e){switch(e.kind){case`unknown-parent`:return`useFlatTree: the item "${e.value}" has the parentValue "${e.parentValue}", which matches no item; it is shown as a root.`;case`cycle`:return`useFlatTree: the parentValue links form a cycle at "${e.value}"; the link of that item to its parent is ignored and it is shown as a root.`;case`duplicate-value`:return`useFlatTree: duplicate item value "${e.value}" (item ${e.index}); only the first item with a value is used.`}}function l(e,l={}){let{expandedItems:u,defaultExpandedItems:d,onExpandedItemsChange:f,checkedItems:p,defaultCheckedItems:m,onCheckedItemsChange:h,selectionMode:g=`none`}=l,_=o.useMemo(()=>a.buildFlatTreeIndex(e),[e]);o.useEffect(()=>{let e=new Set;for(let n of _.issues)e.has(n.kind)||(e.add(n.kind),t.warnOnce(`useFlatTree:${n.kind}`,c(n)))},[_]);let[v]=o.useState(()=>d??s),[y,b]=r.useControllable(u,v,e=>f?.([...e])),x=o.useMemo(()=>new Set(y),[y]),S=o.useCallback(e=>{let t=typeof e==`string`?[e]:e;b(e=>{let n=new Set(e),r=[];for(let e of t)n.has(e)||(n.add(e),r.push(e));return r.length>0?[...e,...r]:e})},[b]),C=o.useCallback(e=>{b(t=>t.includes(e)?t.filter(t=>t!==e):t)},[b]),w=o.useCallback(e=>{b(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[b]),T=o.useCallback(e=>(_.byValue.get(e)?.isBranch??!1)&&x.has(e),[_,x]),[E]=o.useState(()=>m??s),D=o.useRef(void 0),[O,k]=r.useControllable(p,E,e=>h?.([...e],D.current)),A=g===`multiple`,j=o.useMemo(()=>A?a.flatTreeForest(_):null,[_,A]),M=o.useMemo(()=>j?i.computeCheckStates(j,new Set(O)):null,[j,O]),N=n.useEventCallback((e,t,n)=>{let r=j??a.flatTreeForest(_);k(a=>{if((i.computeCheckStates(r,new Set(a)).get(e)??(a.includes(e)?`checked`:`unchecked`))===(t?`checked`:`unchecked`))return a;let o=i.toggleCheck(r,a,e);return o.includes(e)!==t&&(o=i.toggleCheck(r,o,e)),D.current=n?{value:e,checked:o.includes(e),event:n}:void 0,o}),D.current=void 0}),P=o.useMemo(()=>{let e=a.visibleFlatItems(_,x);return M?e.map(e=>({...e,checked:M.get(e.item.value)??`unchecked`})):e},[_,x,M]),F=o.useMemo(()=>{let e=new Map;for(let t of P)e.set(t.item.value,t);return e},[P]),I=o.useCallback(e=>F.get(e),[F]),L=o.useMemo(()=>({selectionMode:g}),[g]),R=o.useCallback(()=>L,[L]);return o.useMemo(()=>({visibleItems:P,getItem:I,expand:S,collapse:C,toggle:w,isExpanded:T,setChecked:N,getTreeProps:R}),[P,I,S,C,w,T,N,R])}exports.useFlatTree=l;
2
+ //# sourceMappingURL=useFlatTree.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFlatTree.cjs","names":["React","buildFlatTreeIndex","useControllable","flatTreeForest","computeCheckStates","useEventCallback","toggleCheck","visibleFlatItems","require_runtime","require_dev","require_useEventCallback","require_useControllable","require_treeCascade","require_flatTree","react","EMPTY","issueMessage","issue","useFlatTree","options","index","items","reported","initialExpanded","defaultExpandedItems","expandedList","setExpandedList","expandedItems","onExpandedItemsChange","next","expandedSet","expand","values","value","seen","prev","added","v","collapse","toggle","isExpanded","initialChecked","defaultCheckedItems","pendingDetails","checkedList","setCheckedList","checkedItems","onCheckedItemsChange","isMultiple","selectionMode","forest","checkStates","setChecked","nodes","previous","checked","event","visibleItems","rows","row","rowsByValue","map","getItem","treeProps","getTreeProps"],"sources":["../../../src/components/layout/useFlatTree.ts"],"sourcesContent":["import * as React from 'react';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { warnOnce } from '../../lib/dev';\nimport {\n buildFlatTreeIndex,\n flatTreeForest,\n visibleFlatItems,\n type FlatTreeItemData,\n type FlatTreeIssue,\n type VisibleFlatItem,\n} from '../../lib/flatTree';\nimport { computeCheckStates, toggleCheck, type CheckState } from '../../lib/treeCascade';\nimport type { SelectionMode } from '../../lib/types';\nimport type { TreeCheckedItemsChangeDetails } from './Tree.core';\n\nconst EMPTY: readonly string[] = [];\n\n/** Options of {@link useFlatTree}: the state names and shapes of the nested `Tree`. */\nexport interface UseFlatTreeOptions {\n /** Controlled list of expanded item values. */\n expandedItems?: readonly string[];\n /**\n * Item values that are expanded initially (uncontrolled).\n * @default []\n */\n defaultExpandedItems?: readonly string[];\n /** Called with the new list of expanded item values when an item expands or collapses. */\n onExpandedItemsChange?: (expandedItems: string[]) => void;\n /** Controlled checked items (`selectionMode=\"multiple\"`); the cascade rule is the nested `Tree`'s. */\n checkedItems?: readonly string[];\n /**\n * Initially checked items (uncontrolled).\n * @default []\n */\n defaultCheckedItems?: readonly string[];\n /**\n * Called with every checked item (in tree order) when a check changes. `details` is passed when\n * `setChecked` got an `event`; it is typed optional until 1.0.\n */\n onCheckedItemsChange?: (checkedItems: string[], details?: TreeCheckedItemsChangeDetails) => void;\n /**\n * How items are selected, as `Tree`. With `'multiple'` every visible row carries its `checked`\n * state; the model's `getTreeProps()` hands the mode on to `FlatTree`.\n * @default 'none'\n */\n selectionMode?: 'none' | SelectionMode;\n}\n\n/** The state and the visible rows of a flat tree, from {@link useFlatTree}. */\nexport interface FlatTreeModel {\n /**\n * The rows to show: the roots and the children of every expanded branch, in tree order. With\n * `selectionMode: 'multiple'` each row has its `checked` state. The array and its rows keep\n * their identity until the items, the expanded set or the checked set change.\n */\n visibleItems: readonly (VisibleFlatItem & { checked?: CheckState })[];\n /** The visible row of `value`; `undefined` for an item under a collapsed branch or an unknown value. */\n getItem(value: string): (VisibleFlatItem & { checked?: CheckState }) | undefined;\n /**\n * Expands `value`, or every value of a list in one change (one `onExpandedItemsChange` call, as\n * `*` on a tree item makes). Nothing happens, and nothing is called, if every value is already in\n * the expanded set.\n */\n expand(value: string | readonly string[]): void;\n /** Collapses `value`. Nothing happens, and nothing is called, if it is not in the expanded set. */\n collapse(value: string): void;\n /** Expands `value` when it is collapsed and collapses it when it is expanded. */\n toggle(value: string): void;\n /** Whether `value` is a branch (an item with child items, or typed `'branch'`) in the expanded set. */\n isExpanded(value: string): boolean;\n /**\n * Sets the check state of `value`, with the cascade of the nested `Tree`: the item and everything\n * nested in it, then its ancestors from their children. Nothing is called when the item is\n * already in that state; a mixed item is set to `checked` as requested. A value that matches no\n * item is added to, or removed from, the checked list. `event` becomes `details.event` of\n * `onCheckedItemsChange`; without it the callback gets no `details`. It works in any\n * `selectionMode` (the rows carry `checked` only with `'multiple'`), and on a disabled item too.\n */\n setChecked(value: string, checked: boolean, event?: Event): void;\n /** The props `FlatTree` takes from the model, for `<FlatTree model={model} {...model.getTreeProps()} />`. */\n getTreeProps(): { selectionMode: 'none' | SelectionMode };\n}\n\nfunction issueMessage(issue: FlatTreeIssue): string {\n switch (issue.kind) {\n case 'unknown-parent':\n return (\n `useFlatTree: the item \"${issue.value}\" has the parentValue \"${issue.parentValue}\", which ` +\n 'matches no item; it is shown as a root.'\n );\n case 'cycle':\n return (\n `useFlatTree: the parentValue links form a cycle at \"${issue.value}\"; the link of that ` +\n 'item to its parent is ignored and it is shown as a root.'\n );\n case 'duplicate-value':\n return (\n `useFlatTree: duplicate item value \"${issue.value}\" (item ${issue.index}); only the first ` +\n 'item with a value is used.'\n );\n }\n}\n\n/**\n * The model of a flat tree: items listed with a `parentValue` link, in any order, become the rows\n * a windowed tree shows (`FlatTree`), without building an element tree. Returns the visible rows\n * (with `level`, `position`, `setSize` and `expanded` for the tree ARIA), the expanded and\n * checked state, and the actions on them.\n *\n * Pass `items` as a stable reference or memoise it: the index of the items is rebuilt when its\n * identity changes. Expanded and checked state work as in `Tree`: pass `expandedItems` or\n * `checkedItems` to control it (a stable array, or the rows are rebuilt on every render), or\n * `defaultExpandedItems` and `defaultCheckedItems` to start uncontrolled; the change callbacks\n * fire once per change. When `items` is replaced, the expanded and checked values stay in the\n * state: a value that matches no item is ignored for the rows until an item with it returns, and\n * it is changed only by you.\n *\n * Development warnings, once each: an unknown `parentValue` (the item is a root), a cycle of\n * parents (cut) and a duplicate value (the first item wins).\n *\n * @example\n * const model = useFlatTree(items, { defaultExpandedItems: ['docs'] });\n * model.visibleItems.map((row) => row.item.label);\n */\nexport function useFlatTree(\n items: readonly FlatTreeItemData[],\n options: UseFlatTreeOptions = {},\n): FlatTreeModel {\n const {\n expandedItems,\n defaultExpandedItems,\n onExpandedItemsChange,\n checkedItems,\n defaultCheckedItems,\n onCheckedItemsChange,\n selectionMode = 'none',\n } = options;\n\n const index = React.useMemo(() => buildFlatTreeIndex(items), [items]);\n React.useEffect(() => {\n const reported = new Set<string>();\n for (const issue of index.issues) {\n if (reported.has(issue.kind)) continue;\n reported.add(issue.kind);\n warnOnce(`useFlatTree:${issue.kind}`, issueMessage(issue));\n }\n }, [index]);\n\n const [initialExpanded] = React.useState<readonly string[]>(() => defaultExpandedItems ?? EMPTY);\n const [expandedList, setExpandedList] = useControllable<readonly string[]>(\n expandedItems,\n initialExpanded,\n (next) => onExpandedItemsChange?.([...next]),\n );\n const expandedSet = React.useMemo(() => new Set(expandedList), [expandedList]);\n\n const expand = React.useCallback(\n (value: string | readonly string[]) => {\n const values = typeof value === 'string' ? [value] : value;\n setExpandedList((prev) => {\n // Sets, not array searches: `*` can expand thousands of siblings against a large set.\n const seen = new Set(prev);\n const added: string[] = [];\n for (const v of values) {\n if (seen.has(v)) continue;\n seen.add(v);\n added.push(v);\n }\n return added.length > 0 ? [...prev, ...added] : prev;\n });\n },\n [setExpandedList],\n );\n const collapse = React.useCallback(\n (value: string) => {\n setExpandedList((prev) => (prev.includes(value) ? prev.filter((v) => v !== value) : prev));\n },\n [setExpandedList],\n );\n const toggle = React.useCallback(\n (value: string) => {\n setExpandedList((prev) =>\n prev.includes(value) ? prev.filter((v) => v !== value) : [...prev, value],\n );\n },\n [setExpandedList],\n );\n const isExpanded = React.useCallback(\n (value: string) => (index.byValue.get(value)?.isBranch ?? false) && expandedSet.has(value),\n [index, expandedSet],\n );\n\n // useControllable passes the value only, so `details` reaches the change callback through a ref\n // written and cleared in the same event (the nested Tree does the same).\n const [initialChecked] = React.useState<readonly string[]>(() => defaultCheckedItems ?? EMPTY);\n const pendingDetails = React.useRef<TreeCheckedItemsChangeDetails | undefined>(undefined);\n const [checkedList, setCheckedList] = useControllable<readonly string[]>(\n checkedItems,\n initialChecked,\n (next) => onCheckedItemsChange?.([...next], pendingDetails.current),\n );\n\n const isMultiple = selectionMode === 'multiple';\n const forest = React.useMemo(\n () => (isMultiple ? flatTreeForest(index) : null),\n [index, isMultiple],\n );\n const checkStates = React.useMemo(\n () => (forest ? computeCheckStates(forest, new Set(checkedList)) : null),\n [forest, checkedList],\n );\n\n const setChecked = useEventCallback((value: string, checked: boolean, event?: Event) => {\n const nodes = forest ?? flatTreeForest(index);\n setCheckedList((previous) => {\n const current =\n computeCheckStates(nodes, new Set(previous)).get(value) ??\n (previous.includes(value) ? 'checked' : 'unchecked');\n if (current === (checked ? 'checked' : 'unchecked')) return previous;\n let next = toggleCheck(nodes, previous, value);\n // A mixed item turns checked on a toggle; asked to be unchecked it needs a second one.\n if (next.includes(value) !== checked) next = toggleCheck(nodes, next, value);\n pendingDetails.current = event ? { value, checked: next.includes(value), event } : undefined;\n return next;\n });\n pendingDetails.current = undefined;\n });\n\n const visibleItems = React.useMemo(() => {\n const rows = visibleFlatItems(index, expandedSet);\n if (!checkStates) return rows;\n return rows.map((row) => ({ ...row, checked: checkStates.get(row.item.value) ?? 'unchecked' }));\n }, [index, expandedSet, checkStates]);\n\n const rowsByValue = React.useMemo(() => {\n const map = new Map<string, (typeof visibleItems)[number]>();\n for (const row of visibleItems) map.set(row.item.value, row);\n return map;\n }, [visibleItems]);\n const getItem = React.useCallback((value: string) => rowsByValue.get(value), [rowsByValue]);\n\n const treeProps = React.useMemo(() => ({ selectionMode }), [selectionMode]);\n const getTreeProps = React.useCallback(() => treeProps, [treeProps]);\n\n return React.useMemo(\n () => ({\n visibleItems,\n getItem,\n expand,\n collapse,\n toggle,\n isExpanded,\n setChecked,\n getTreeProps,\n }),\n [visibleItems, getItem, expand, collapse, toggle, isExpanded, setChecked, getTreeProps],\n );\n}\n"],"mappings":"kTAgBA,IAAMe,EAA2B,CAAC,EAoElC,SAASC,EAAa,EAA8B,CAClD,OAAQC,EAAM,KAAd,CACE,IAAK,iBACH,MACE,0BAA0BA,EAAM,MAAM,yBAAyBA,EAAM,YAAY,kDAGrF,IAAK,QACH,MACE,uDAAuDA,EAAM,MAAM,8EAGvE,IAAK,kBACH,MACE,sCAAsCA,EAAM,MAAM,UAAUA,EAAM,MAAM,6CAG9E,CACF,CAuBA,SAAgBC,EACd,EACA,EAA8B,CAAC,EAChB,CACf,GAAM,CACJ,gBACA,uBACA,wBACA,eACA,sBACA,uBACA,gBAAgB,QACdC,EAEEC,EAAQpB,EAAM,YAAcC,EAAAA,mBAAmBoB,CAAK,EAAG,CAACA,CAAK,CAAC,EACpEP,EAAM,cAAgB,CACpB,IAAMQ,EAAW,IAAI,IACrB,IAAK,IAAML,KAASG,EAAM,OACpBE,EAAS,IAAIL,EAAM,IAAI,IAC3BK,EAAS,IAAIL,EAAM,IAAI,EACvBR,EAAA,SAAS,eAAeQ,EAAM,OAAQD,EAAaC,CAAK,CAAC,EAE7D,EAAG,CAACG,CAAK,CAAC,EAEV,GAAM,CAACG,GAAmBvB,EAAM,aAAkCwB,GAAwBT,CAAK,EACzF,CAACU,EAAcC,GAAmBxB,EAAAA,gBACtCyB,EACAJ,EACC,GAASK,IAAwB,CAAC,GAAGC,CAAI,CAAC,CAC7C,EACMC,EAAc9B,EAAM,YAAc,IAAI,IAAIyB,CAAY,EAAG,CAACA,CAAY,CAAC,EAEvEM,EAAS/B,EAAM,YAClB,GAAsC,CACrC,IAAMgC,EAAS,OAAOC,GAAU,SAAW,CAACA,CAAK,EAAIA,EACrDP,EAAiB,GAAS,CAExB,IAAMQ,EAAO,IAAI,IAAIC,CAAI,EACnBC,EAAkB,CAAC,EACzB,IAAK,IAAMC,KAAKL,EACVE,EAAK,IAAI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