@mortenbrudvik/waveui 0.10.0 → 0.12.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 (258) hide show
  1. package/README.md +454 -74
  2. package/dist/components/button/Link.cjs +1 -1
  3. package/dist/components/button/Link.cjs.map +1 -1
  4. package/dist/components/button/Link.mjs +4 -4
  5. package/dist/components/button/Toolbar.cjs +1 -1
  6. package/dist/components/button/Toolbar.cjs.map +1 -1
  7. package/dist/components/button/Toolbar.mjs +25 -30
  8. package/dist/components/button/Toolbar.mjs.map +1 -1
  9. package/dist/components/button/Toolbar.navigation.cjs +2 -0
  10. package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
  11. package/dist/components/button/Toolbar.navigation.mjs +17 -0
  12. package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
  13. package/dist/components/data-display/Avatar.cjs +1 -1
  14. package/dist/components/data-display/Avatar.cjs.map +1 -1
  15. package/dist/components/data-display/Avatar.context.cjs +2 -0
  16. package/dist/components/data-display/Avatar.context.cjs.map +1 -0
  17. package/dist/components/data-display/Avatar.context.mjs +9 -0
  18. package/dist/components/data-display/Avatar.context.mjs.map +1 -0
  19. package/dist/components/data-display/Avatar.mjs +66 -61
  20. package/dist/components/data-display/Avatar.mjs.map +1 -1
  21. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  22. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  23. package/dist/components/data-display/AvatarGroup.mjs +10 -10
  24. package/dist/components/data-display/InfoButton.cjs +1 -1
  25. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  26. package/dist/components/data-display/InfoButton.mjs +12 -12
  27. package/dist/components/data-display/InteractionTag.cjs +2 -0
  28. package/dist/components/data-display/InteractionTag.cjs.map +1 -0
  29. package/dist/components/data-display/InteractionTag.mjs +234 -0
  30. package/dist/components/data-display/InteractionTag.mjs.map +1 -0
  31. package/dist/components/data-display/Tag.cjs +1 -1
  32. package/dist/components/data-display/Tag.cjs.map +1 -1
  33. package/dist/components/data-display/Tag.mjs +222 -90
  34. package/dist/components/data-display/Tag.mjs.map +1 -1
  35. package/dist/components/data-display/TagGroup.cjs +2 -0
  36. package/dist/components/data-display/TagGroup.cjs.map +1 -0
  37. package/dist/components/data-display/TagGroup.context.cjs +2 -0
  38. package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
  39. package/dist/components/data-display/TagGroup.context.mjs +113 -0
  40. package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
  41. package/dist/components/data-display/TagGroup.mjs +149 -0
  42. package/dist/components/data-display/TagGroup.mjs.map +1 -0
  43. package/dist/components/data-display/tagStyles.cjs +2 -0
  44. package/dist/components/data-display/tagStyles.cjs.map +1 -0
  45. package/dist/components/data-display/tagStyles.mjs +108 -0
  46. package/dist/components/data-display/tagStyles.mjs.map +1 -0
  47. package/dist/components/feedback/Toaster.cjs +1 -1
  48. package/dist/components/feedback/Toaster.cjs.map +1 -1
  49. package/dist/components/feedback/Toaster.mjs +287 -255
  50. package/dist/components/feedback/Toaster.mjs.map +1 -1
  51. package/dist/components/input/Combobox.cjs +1 -1
  52. package/dist/components/input/Combobox.cjs.map +1 -1
  53. package/dist/components/input/Combobox.expand.cjs +1 -1
  54. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  55. package/dist/components/input/Combobox.expand.mjs +7 -7
  56. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  57. package/dist/components/input/Combobox.mjs +176 -175
  58. package/dist/components/input/Combobox.mjs.map +1 -1
  59. package/dist/components/input/DatePicker.cjs +1 -1
  60. package/dist/components/input/DatePicker.cjs.map +1 -1
  61. package/dist/components/input/DatePicker.mjs +188 -187
  62. package/dist/components/input/DatePicker.mjs.map +1 -1
  63. package/dist/components/input/Dropdown.cjs +1 -1
  64. package/dist/components/input/Dropdown.cjs.map +1 -1
  65. package/dist/components/input/Dropdown.mjs +41 -40
  66. package/dist/components/input/Dropdown.mjs.map +1 -1
  67. package/dist/components/input/Option.cjs +1 -1
  68. package/dist/components/input/Option.cjs.map +1 -1
  69. package/dist/components/input/Option.mjs +101 -94
  70. package/dist/components/input/Option.mjs.map +1 -1
  71. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  72. package/dist/components/input/SwatchPicker.context.cjs.map +1 -1
  73. package/dist/components/input/SwatchPicker.context.mjs.map +1 -1
  74. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  75. package/dist/components/input/TagPicker.cjs +1 -1
  76. package/dist/components/input/TagPicker.cjs.map +1 -1
  77. package/dist/components/input/TagPicker.context.cjs +2 -0
  78. package/dist/components/input/TagPicker.context.cjs.map +1 -0
  79. package/dist/components/input/TagPicker.context.mjs +20 -0
  80. package/dist/components/input/TagPicker.context.mjs.map +1 -0
  81. package/dist/components/input/TagPicker.create.cjs +2 -0
  82. package/dist/components/input/TagPicker.create.cjs.map +1 -0
  83. package/dist/components/input/TagPicker.create.mjs +24 -0
  84. package/dist/components/input/TagPicker.create.mjs.map +1 -0
  85. package/dist/components/input/TagPicker.mjs +13 -279
  86. package/dist/components/input/TagPicker.mjs.map +1 -1
  87. package/dist/components/input/TagPicker.option.cjs +2 -0
  88. package/dist/components/input/TagPicker.option.cjs.map +1 -0
  89. package/dist/components/input/TagPicker.option.mjs +45 -0
  90. package/dist/components/input/TagPicker.option.mjs.map +1 -0
  91. package/dist/components/input/TagPicker.overflow.cjs +2 -0
  92. package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
  93. package/dist/components/input/TagPicker.overflow.mjs +153 -0
  94. package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
  95. package/dist/components/input/TagPicker.parts.cjs +2 -0
  96. package/dist/components/input/TagPicker.parts.cjs.map +1 -0
  97. package/dist/components/input/TagPicker.parts.mjs +425 -0
  98. package/dist/components/input/TagPicker.parts.mjs.map +1 -0
  99. package/dist/components/input/TagPicker.root.cjs +2 -0
  100. package/dist/components/input/TagPicker.root.cjs.map +1 -0
  101. package/dist/components/input/TagPicker.root.mjs +417 -0
  102. package/dist/components/input/TagPicker.root.mjs.map +1 -0
  103. package/dist/components/input/TimePicker.cjs +1 -1
  104. package/dist/components/input/TimePicker.cjs.map +1 -1
  105. package/dist/components/input/TimePicker.mjs +156 -154
  106. package/dist/components/input/TimePicker.mjs.map +1 -1
  107. package/dist/components/layout/Accordion.cjs.map +1 -1
  108. package/dist/components/layout/Accordion.mjs.map +1 -1
  109. package/dist/components/navigation/Hamburger.cjs +2 -0
  110. package/dist/components/navigation/Hamburger.cjs.map +1 -0
  111. package/dist/components/navigation/Hamburger.mjs +54 -0
  112. package/dist/components/navigation/Hamburger.mjs.map +1 -0
  113. package/dist/components/navigation/Menu.popover.cjs +1 -1
  114. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  115. package/dist/components/navigation/Menu.popover.mjs +137 -127
  116. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  117. package/dist/components/navigation/Menu.root.cjs +1 -1
  118. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  119. package/dist/components/navigation/Menu.root.mjs +4 -4
  120. package/dist/components/navigation/Nav.cjs +1 -1
  121. package/dist/components/navigation/Nav.cjs.map +1 -1
  122. package/dist/components/navigation/Nav.context.cjs +2 -0
  123. package/dist/components/navigation/Nav.context.cjs.map +1 -0
  124. package/dist/components/navigation/Nav.context.mjs +137 -0
  125. package/dist/components/navigation/Nav.context.mjs.map +1 -0
  126. package/dist/components/navigation/Nav.mjs +151 -258
  127. package/dist/components/navigation/Nav.mjs.map +1 -1
  128. package/dist/components/navigation/Nav.parts.cjs +2 -0
  129. package/dist/components/navigation/Nav.parts.cjs.map +1 -0
  130. package/dist/components/navigation/Nav.parts.mjs +77 -0
  131. package/dist/components/navigation/Nav.parts.mjs.map +1 -0
  132. package/dist/components/navigation/Nav.root.cjs +2 -0
  133. package/dist/components/navigation/Nav.root.cjs.map +1 -0
  134. package/dist/components/navigation/Nav.root.mjs +78 -0
  135. package/dist/components/navigation/Nav.root.mjs.map +1 -0
  136. package/dist/components/navigation/NavDrawer.cjs +2 -0
  137. package/dist/components/navigation/NavDrawer.cjs.map +1 -0
  138. package/dist/components/navigation/NavDrawer.context.cjs +2 -0
  139. package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
  140. package/dist/components/navigation/NavDrawer.context.mjs +11 -0
  141. package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
  142. package/dist/components/navigation/NavDrawer.mjs +179 -0
  143. package/dist/components/navigation/NavDrawer.mjs.map +1 -0
  144. package/dist/components/overlays/Dialog.cjs +1 -1
  145. package/dist/components/overlays/Dialog.cjs.map +1 -1
  146. package/dist/components/overlays/Dialog.mjs +188 -123
  147. package/dist/components/overlays/Dialog.mjs.map +1 -1
  148. package/dist/components/overlays/Dialog.shared.cjs +1 -1
  149. package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
  150. package/dist/components/overlays/Dialog.shared.mjs +157 -81
  151. package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
  152. package/dist/components/overlays/Dialog.slots.cjs +2 -0
  153. package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
  154. package/dist/components/overlays/Dialog.slots.mjs +129 -0
  155. package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
  156. package/dist/components/overlays/Drawer.cjs +1 -1
  157. package/dist/components/overlays/Drawer.cjs.map +1 -1
  158. package/dist/components/overlays/Drawer.context.cjs +2 -0
  159. package/dist/components/overlays/Drawer.context.cjs.map +1 -0
  160. package/dist/components/overlays/Drawer.context.mjs +29 -0
  161. package/dist/components/overlays/Drawer.context.mjs.map +1 -0
  162. package/dist/components/overlays/Drawer.mjs +12 -187
  163. package/dist/components/overlays/Drawer.mjs.map +1 -1
  164. package/dist/components/overlays/Drawer.panel.cjs +2 -0
  165. package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
  166. package/dist/components/overlays/Drawer.panel.mjs +159 -0
  167. package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
  168. package/dist/components/overlays/Drawer.parts.cjs +2 -0
  169. package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
  170. package/dist/components/overlays/Drawer.parts.mjs +152 -0
  171. package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
  172. package/dist/components/overlays/Drawer.root.cjs +2 -0
  173. package/dist/components/overlays/Drawer.root.cjs.map +1 -0
  174. package/dist/components/overlays/Drawer.root.mjs +207 -0
  175. package/dist/components/overlays/Drawer.root.mjs.map +1 -0
  176. package/dist/components/overlays/Drawer.scroll.cjs +2 -0
  177. package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
  178. package/dist/components/overlays/Drawer.scroll.mjs +42 -0
  179. package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
  180. package/dist/components/overlays/Popover.cjs +1 -1
  181. package/dist/components/overlays/Popover.cjs.map +1 -1
  182. package/dist/components/overlays/Popover.mjs +173 -162
  183. package/dist/components/overlays/Popover.mjs.map +1 -1
  184. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  185. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  186. package/dist/components/overlays/TeachingPopover.mjs +96 -91
  187. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  188. package/dist/components/overlays/Tooltip.cjs +1 -1
  189. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  190. package/dist/components/overlays/Tooltip.mjs +47 -47
  191. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  192. package/dist/components/portal/Portal.cjs +1 -1
  193. package/dist/components/portal/Portal.cjs.map +1 -1
  194. package/dist/components/portal/Portal.mjs +5 -5
  195. package/dist/components/table/DataGrid.cjs +1 -1
  196. package/dist/components/table/DataGrid.cjs.map +1 -1
  197. package/dist/components/table/DataGrid.mjs +1 -1
  198. package/dist/hooks/useDismiss.cjs.map +1 -1
  199. package/dist/hooks/useDismiss.mjs.map +1 -1
  200. package/dist/hooks/useFocusTrap.cjs +1 -1
  201. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  202. package/dist/hooks/useFocusTrap.mjs +115 -98
  203. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  204. package/dist/hooks/useFocusVisible.cjs +2 -0
  205. package/dist/hooks/useFocusVisible.cjs.map +1 -0
  206. package/dist/hooks/useFocusVisible.mjs +49 -0
  207. package/dist/hooks/useFocusVisible.mjs.map +1 -0
  208. package/dist/hooks/useFocusableGroup.cjs +2 -0
  209. package/dist/hooks/useFocusableGroup.cjs.map +1 -0
  210. package/dist/hooks/useFocusableGroup.mjs +70 -0
  211. package/dist/hooks/useFocusableGroup.mjs.map +1 -0
  212. package/dist/hooks/useModalLayer.cjs +1 -1
  213. package/dist/hooks/useModalLayer.cjs.map +1 -1
  214. package/dist/hooks/useModalLayer.mjs +34 -21
  215. package/dist/hooks/useModalLayer.mjs.map +1 -1
  216. package/dist/hooks/useModalOpen.cjs +2 -0
  217. package/dist/hooks/useModalOpen.cjs.map +1 -0
  218. package/dist/hooks/useModalOpen.mjs +14 -0
  219. package/dist/hooks/useModalOpen.mjs.map +1 -0
  220. package/dist/hooks/usePopupPosition.cjs +1 -1
  221. package/dist/hooks/usePopupPosition.cjs.map +1 -1
  222. package/dist/hooks/usePopupPosition.mjs +82 -53
  223. package/dist/hooks/usePopupPosition.mjs.map +1 -1
  224. package/dist/hooks/useResolvedTarget.cjs +2 -0
  225. package/dist/hooks/useResolvedTarget.cjs.map +1 -0
  226. package/dist/hooks/useResolvedTarget.mjs +37 -0
  227. package/dist/hooks/useResolvedTarget.mjs.map +1 -0
  228. package/dist/hooks/useRestoreFocus.cjs +1 -1
  229. package/dist/hooks/useRestoreFocus.cjs.map +1 -1
  230. package/dist/hooks/useRestoreFocus.mjs +91 -78
  231. package/dist/hooks/useRestoreFocus.mjs.map +1 -1
  232. package/dist/hooks/useRovingGrid.cjs +1 -1
  233. package/dist/hooks/useRovingGrid.cjs.map +1 -1
  234. package/dist/hooks/useRovingGrid.mjs +8 -57
  235. package/dist/hooks/useRovingGrid.mjs.map +1 -1
  236. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  237. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  238. package/dist/hooks/useRovingTabIndex.mjs +180 -121
  239. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  240. package/dist/index.cjs +1 -1
  241. package/dist/index.d.cts +3070 -269
  242. package/dist/index.d.ts +3070 -269
  243. package/dist/index.mjs +127 -107
  244. package/dist/lib/classNames.cjs +1 -1
  245. package/dist/lib/classNames.cjs.map +1 -1
  246. package/dist/lib/classNames.mjs +137 -77
  247. package/dist/lib/classNames.mjs.map +1 -1
  248. package/dist/lib/icons.cjs +1 -1
  249. package/dist/lib/icons.cjs.map +1 -1
  250. package/dist/lib/icons.mjs +13 -6
  251. package/dist/lib/icons.mjs.map +1 -1
  252. package/dist/lib/layers.cjs +1 -1
  253. package/dist/lib/layers.cjs.map +1 -1
  254. package/dist/lib/layers.mjs +120 -111
  255. package/dist/lib/layers.mjs.map +1 -1
  256. package/dist/styles.css +1 -1
  257. package/package.json +1 -1
  258. package/src/styles/tokens.css +25 -0
@@ -0,0 +1,137 @@
1
+ "use client";
2
+ import { getElementType as e } from "../../lib/children.mjs";
3
+ import { hasWarned as t, isDev as n, reportMissingContext as r, warnOnce as i } from "../../lib/dev.mjs";
4
+ import * as a from "react";
5
+ //#region src/components/navigation/Nav.context.ts
6
+ function o() {
7
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = () => t.forEach((e) => e());
8
+ return {
9
+ record(t, r) {
10
+ (e.get(t) ?? null) !== r && (r === null ? e.delete(t) : e.set(t, r), n());
11
+ },
12
+ forget(t, r) {
13
+ e.get(t) === r && (e.delete(t), n());
14
+ },
15
+ get: (t) => e.get(t),
16
+ subscribe(e) {
17
+ return t.add(e), () => {
18
+ t.delete(e);
19
+ };
20
+ }
21
+ };
22
+ }
23
+ var s = a.createContext(null);
24
+ s.displayName = "NavContext";
25
+ var c = () => {}, l = {
26
+ value: "",
27
+ select: c,
28
+ openCategories: [],
29
+ toggleCategory: c,
30
+ registerValue: () => c,
31
+ currentCategory: void 0,
32
+ categoryStore: {
33
+ record: c,
34
+ forget: c,
35
+ get: () => void 0,
36
+ subscribe: () => c
37
+ }
38
+ }, u = a.createContext(null);
39
+ u.displayName = "NavCategoryValueContext";
40
+ function d(e) {
41
+ return a.useContext(s) || (r(e, "Nav"), l);
42
+ }
43
+ function f(e, t, n) {
44
+ let { registerValue: r } = e;
45
+ a.useEffect(() => r(t, n), [
46
+ r,
47
+ t,
48
+ n
49
+ ]);
50
+ }
51
+ function p(e, t) {
52
+ let n = a.useContext(u), { categoryStore: r } = e;
53
+ a.useLayoutEffect(() => {
54
+ r.record(t, n);
55
+ }, [
56
+ r,
57
+ t,
58
+ n
59
+ ]);
60
+ }
61
+ var m = a.createContext(null);
62
+ m.displayName = "NavRovingContext";
63
+ var h = Symbol.for("wave.navPart");
64
+ function g(e, t) {
65
+ return e[h] = t, e;
66
+ }
67
+ function _(t) {
68
+ let n = e(t, { suspend: !1 });
69
+ if (typeof n != "function" && typeof n != "object" || n === null) return null;
70
+ let r = n[h];
71
+ return r === "entry" || r === "category" ? r : null;
72
+ }
73
+ function v(e) {
74
+ let { children: t } = e.props;
75
+ return typeof t == "function" ? void 0 : t;
76
+ }
77
+ function y(e) {
78
+ return (typeof e == "object" || typeof e == "function") && e !== null && typeof e.then == "function";
79
+ }
80
+ function b(e, t) {
81
+ if (Array.isArray(e)) {
82
+ for (let n of e) b(n, t);
83
+ return;
84
+ }
85
+ try {
86
+ a.Children.forEach(e, (e) => {
87
+ a.isValidElement(e) && t(e);
88
+ });
89
+ } catch (e) {
90
+ if (!y(e)) throw e;
91
+ }
92
+ }
93
+ function x(e, t) {
94
+ let n = !1;
95
+ return b(e, (e) => {
96
+ n ||= _(e) === "entry" && e.props.value === t || x(v(e), t);
97
+ }), n;
98
+ }
99
+ function S(e, t) {
100
+ let n = [];
101
+ if (!t) return n;
102
+ let r = (e) => {
103
+ b(e, (e) => {
104
+ let i = v(e);
105
+ _(e) === "category" && typeof e.props.value == "string" && x(i, t) && n.push(e.props.value), r(i);
106
+ });
107
+ };
108
+ return r(e), n;
109
+ }
110
+ var C = {
111
+ items: "Use the Nav parts (Nav.Item, Nav.Category, Nav.SectionHeader, Nav.Divider, Nav.AppItem, Nav.AppItemStatic) as its children, or wrap your own content in an <li>.",
112
+ "sub-items": "Use Nav.SubItem, Nav.SectionHeader and Nav.Divider as its children, or wrap your own content in an <li>."
113
+ }, w = /* @__PURE__ */ new Set([
114
+ "li",
115
+ "script",
116
+ "template"
117
+ ]);
118
+ function T(e) {
119
+ for (let t of Array.from(e.childNodes)) if (t.nodeType === Node.ELEMENT_NODE) {
120
+ let e = t.localName.toLowerCase();
121
+ if (!w.has(e)) return `a <${e}> element`;
122
+ } else if (t.nodeType === Node.TEXT_NODE && (t.textContent ?? "").trim() !== "") return "text";
123
+ return null;
124
+ }
125
+ function E(e, r, o) {
126
+ a.useEffect(() => {
127
+ if (!n) return;
128
+ let a = `${r}:list-child`, s = e.current;
129
+ if (!s || t(a)) return;
130
+ let c = T(s);
131
+ c !== null && i(a, `${r}: its list holds ${c}, but a list can hold only <li> elements. ${C[o]}`);
132
+ });
133
+ }
134
+ //#endregion
135
+ export { u as NavCategoryValueContext, s as NavContext, m as NavRovingContext, x as containsValue, o as createCategoryStore, S as findCategoriesContaining, _ as getNavPartKind, g as markNavPart, d as useNavContext, E as useNavListChildCheck, f as useNavValue, p as useRecordCategory };
136
+
137
+ //# sourceMappingURL=Nav.context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Nav.context.mjs","names":["React","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","reportMissingContext","componentName","useNavValue","context","registerValue","kind","useRecordCategory","categoryStore","NavRovingContext","NAV_PART","markNavPart","component","getNavPartKind","type","getElementType","node","childrenOf","element","children","isThenable","forEachElement","nodes","visit","child","error","containsValue","found","selected","findCategoriesContaining","result","current","inner","LIST_CHILD_ADVICE","ALLOWED_LIST_CHILDREN","describeInvalidListChild","list","tag","useNavListChildCheck","isDev","key","owner","hasWarned","invalid","warnOnce","contents"],"sources":["../../../src/components/navigation/Nav.context.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\nimport { hasWarned, isDev, reportMissingContext, warnOnce } from '../../lib/dev';\n\n/*\n * The contexts of a Nav root (Nav, NavDrawer) and its parts: the root's state (`NavContext`), the\n * category a sub-item renders in and the roving bookkeeping of an arrow-key body; the category\n * store; the part markers and the children walks that find the current page; the development check\n * of a Nav list's children; and the link-only attributes mask of the button items. Internal; it\n * imports no component, so a root reaches the parts through their markers, never through an import.\n */\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n/** The two value namespaces of a Nav: items (Nav.Item and Nav.SubItem) and categories. */\nexport type NavValueKind = 'item' | 'category';\n\n/**\n * The category each sub-item was last shown in, by sub-item value: written from layout effects by\n * the mounted sub-items and by a closed category whose children hold the current value, read by\n * the categories with `useSyncExternalStore`. An entry outlives its sub-item, so a category closed\n * after its current sub-item was shown still knows it contains the current page.\n */\nexport interface NavCategoryStore {\n /**\n * Records the category a mounted item renders in, or a closed category whose children hold the\n * value; `null` (an item outside any category) forgets an earlier entry, so a value moved out of\n * a category no longer marks it.\n */\n record(value: string, category: string | null): void;\n /** Forgets the entry of `value` while it is still `category`. */\n forget(value: string, category: string): void;\n /** The category last recorded for a sub-item value. */\n get(value: string): string | undefined;\n /** Subscribes to every change of an entry; returns the unsubscribe function. */\n subscribe(listener: () => void): () => void;\n}\n\n/** A new, empty category store (one per Nav root, created once). */\nexport function createCategoryStore(): NavCategoryStore {\n const categories = new Map<string, string>();\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n record(value, category) {\n if ((categories.get(value) ?? null) === category) return;\n if (category === null) categories.delete(value);\n else categories.set(value, category);\n notify();\n },\n forget(value, category) {\n if (categories.get(value) !== category) return;\n categories.delete(value);\n notify();\n },\n get: (value) => categories.get(value),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/** The context a Nav root (Nav, NavDrawer) provides to its parts (0.10's fields, unchanged). */\nexport interface NavContextValue {\n /** The selected item value (`''` when nothing is selected). */\n value: string;\n /**\n * Activation of an item: sets the value, then calls the root's `onActivate` (every activation,\n * re-selection included; Nav's deprecated `onNavItemSelect`).\n */\n select: (value: string) => void;\n /** The values of the open categories. */\n openCategories: readonly string[];\n /** Opens a closed category, closes an open one. */\n toggleCategory: (value: string) => void;\n /** Registers a mounted item or category value (duplicate warning); returns the cleanup. */\n registerValue: (kind: NavValueKind, value: string) => () => void;\n /** The `currentCategory` hint of the root. */\n currentCategory: string | undefined;\n /** The categories the sub-items were last shown in. */\n categoryStore: NavCategoryStore;\n}\n\n/** The state of the Nav root around a part (`null` outside one). */\nexport const NavContext = React.createContext<NavContextValue | null>(null);\nNavContext.displayName = 'NavContext';\n\nconst noop = () => {};\nconst INERT_NAV_CONTEXT: NavContextValue = {\n value: '',\n select: noop,\n openCategories: [],\n toggleCategory: noop,\n registerValue: () => noop,\n currentCategory: undefined,\n categoryStore: { record: noop, forget: noop, get: () => undefined, subscribe: () => noop },\n};\n\n/**\n * The value of the Nav.Category a sub-item renders in (`null` outside a category). It renders no\n * element; a sub-item outside a category is valid, so there is no missing-context error.\n */\nexport const NavCategoryValueContext = React.createContext<string | null>(null);\nNavCategoryValueContext.displayName = 'NavCategoryValueContext';\n\n/**\n * The Nav root's context for the part `componentName` (C-CONTEXT): outside a Nav it throws\n * `[WaveUI] <componentName> must be used within Nav` in development, and in production logs once\n * and returns an inert value.\n */\nexport function useNavContext(componentName: string): NavContextValue {\n const context = React.useContext(NavContext);\n if (context) return context;\n reportMissingContext(componentName, 'Nav');\n return INERT_NAV_CONTEXT;\n}\n\n/** Registers the value of a mounted item or category, so the root can warn about duplicates. */\nexport function useNavValue(context: NavContextValue, kind: NavValueKind, value: string): void {\n const { registerValue } = context;\n React.useEffect(() => registerValue(kind, value), [registerValue, kind, value]);\n}\n\n/**\n * Records the category a mounted item renders in, which the category reads once closed (`null`\n * outside a category, which forgets a stale entry for the value).\n */\nexport function useRecordCategory(context: NavContextValue, value: string): void {\n const category = React.useContext(NavCategoryValueContext);\n const { categoryStore } = context;\n React.useLayoutEffect(() => {\n categoryStore.record(value, category);\n }, [categoryStore, value, category]);\n}\n\n// ---------------------------------------------------------------------------\n// Roving bookkeeping (an arrow-key body)\n// ---------------------------------------------------------------------------\n\n/** What an arrow-key body (NavDrawer.Body `focusMode=\"arrow\"`) gives the Nav parts inside it. */\nexport interface NavRovingContextValue {\n /**\n * Called by every Nav.Category from a layout effect keyed on `[context, value, containsCurrent]`:\n * `(value, true)` while it is a closed category that holds the current page, `(value, false)`\n * when it stops being one and in the effect's cleanup (an unmount, StrictMode's double mount).\n * Must be stable (memoised by the provider).\n */\n reportCurrentCategory: (category: string, holdsCurrent: boolean) => void;\n}\n\n/**\n * Provided (non-null) inside an arrow-key body: every Nav.Item and Nav.SubItem renders\n * `data-roving-value={value}` on its link or button (after the consumer's attributes: the\n * bookkeeping wins), and every category toggle `data-roving-value={'wave-nav-category:' + value}`\n * (stable, also while open), and reports as {@link NavRovingContextValue} says. `null` (the\n * default, every plain Nav): nothing is rendered or reported, so a Nav's server HTML is 0.10's.\n */\nexport const NavRovingContext = React.createContext<NavRovingContextValue | null>(null);\nNavRovingContext.displayName = 'NavRovingContext';\n\n// ---------------------------------------------------------------------------\n// Part markers and the children walks\n// ---------------------------------------------------------------------------\n\n/** What a marked Nav part is to the walks: an entry (Nav.Item, Nav.SubItem) or a category. */\nexport type NavPartKind = 'entry' | 'category';\n\n/**\n * The marker property of a Nav part, read only by {@link getNavPartKind}. A registry symbol\n * (`Symbol.for`), as Field's label marker (`fieldLabel.ts`): the ESM and CJS copies of the package\n * share it, so a part marked by one copy is recognised by the other.\n */\nconst NAV_PART: symbol = Symbol.for('wave.navPart');\n\n/**\n * Marks `component` as a Nav part of `kind`, so the walks of a Nav root recognise its elements\n * without importing it; call it next to `displayName`. Returns `component`.\n */\nexport function markNavPart<T extends object>(component: T, kind: NavPartKind): T {\n (component as Record<symbol, unknown>)[NAV_PART] = kind;\n return component;\n}\n\n/**\n * The kind of Nav part `node` is an element of, or `null` for anything else. The type is resolved\n * with `getElementType(node, { suspend: false })`: a lazy client reference (a part written in a\n * Server Component) is recognised, and a lazy type still loading is no part (it never suspends).\n */\nexport function getNavPartKind(node: React.ReactNode): NavPartKind | null {\n const type = getElementType(node, { suspend: false });\n if ((typeof type !== 'function' && typeof type !== 'object') || type === null) return null;\n const kind = (type as Record<symbol, unknown>)[NAV_PART];\n return kind === 'entry' || kind === 'category' ? kind : null;\n}\n\ntype ElementWithChildren = React.ReactElement<{ value?: unknown; children?: React.ReactNode }>;\n\nfunction childrenOf(element: ElementWithChildren): React.ReactNode {\n const { children } = element.props;\n return typeof children === 'function' ? undefined : children;\n}\n\n/** Whether a thrown value suspends rendering (a loading lazy chunk, a pending promise). */\nfunction isThenable(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/*\n * The walks below run during the render of a Nav root and of a category, and reach consumer\n * content at any depth. Content that is still loading inside the consumer's own <Suspense> (a\n * promise child, a lazy node, a `React.lazy` component) suspends that boundary when React renders\n * it; walking it must never suspend the Nav itself, which would hide the whole Nav behind an outer\n * boundary. So a child that cannot be read yet is skipped, and a lazy type that is still loading is\n * not a part (its children are still walked). Parts written in a Server Component arrive as loaded\n * client references and are recognized.\n */\n\n/** Calls `visit` with each element of `nodes` (as `React.Children.forEach`), skipping pending ones. */\nfunction forEachElement(nodes: React.ReactNode, visit: (child: ElementWithChildren) => void): void {\n if (Array.isArray(nodes)) {\n for (const node of nodes as React.ReactNode[]) forEachElement(node, visit);\n return;\n }\n try {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<ElementWithChildren['props']>(child)) visit(child);\n });\n } catch (error) {\n if (!isThenable(error)) throw error;\n }\n}\n\n/**\n * Whether `nodes` contain a Nav.Item/Nav.SubItem element with `value === selected` (parts written\n * in a Server Component, lazy client references, included). Called during render only; never\n * suspends.\n */\nexport function containsValue(nodes: React.ReactNode, selected: string): boolean {\n let found = false;\n forEachElement(nodes, (child) => {\n if (found) return;\n if (getNavPartKind(child) === 'entry' && child.props.value === selected) {\n found = true;\n } else {\n found = containsValue(childrenOf(child), selected);\n }\n });\n return found;\n}\n\n/** The values of the Nav.Category elements (at any depth of JSX) that contain `selected`. */\nexport function findCategoriesContaining(nodes: React.ReactNode, selected: string): string[] {\n const result: string[] = [];\n if (!selected) return result;\n const visit = (current: React.ReactNode) => {\n forEachElement(current, (child) => {\n const inner = childrenOf(child);\n if (\n getNavPartKind(child) === 'category' &&\n typeof child.props.value === 'string' &&\n containsValue(inner, selected)\n ) {\n result.push(child.props.value);\n }\n visit(inner);\n });\n };\n visit(nodes);\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// The list-child check\n// ---------------------------------------------------------------------------\n\n/** The advice of the list-child warning, by what the list holds. */\nconst LIST_CHILD_ADVICE = {\n items:\n 'Use the Nav parts (Nav.Item, Nav.Category, Nav.SectionHeader, Nav.Divider, Nav.AppItem, Nav.AppItemStatic) as its children, or wrap your own content in an <li>.',\n 'sub-items':\n 'Use Nav.SubItem, Nav.SectionHeader and Nav.Divider as its children, or wrap your own content in an <li>.',\n} as const;\n\n/** Element children a list may hold besides `<li>`: script-supporting elements (React's streaming placeholders). */\nconst ALLOWED_LIST_CHILDREN = new Set(['li', 'script', 'template']);\n\n/**\n * What the first child node of `list` that a list cannot hold is (`a <div> element`, `text`), or\n * `null` when every child is an `<li>`, a script-supporting element, whitespace text or a comment.\n */\nfunction describeInvalidListChild(list: HTMLElement): string | null {\n for (const node of Array.from(list.childNodes)) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const tag = (node as Element).localName.toLowerCase();\n if (!ALLOWED_LIST_CHILDREN.has(tag)) return `a <${tag}> element`;\n } else if (node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim() !== '') {\n return 'text';\n }\n }\n return null;\n}\n\n/**\n * Development only: after every commit of the calling component, warns once per `owner`\n * (`${owner}:list-child`) at the first child node of `list` that is neither an `<li>`, `<script>`\n * nor `<template>` element nor whitespace text (comments, and the nothing that `null`, Fragments\n * and Suspense boundaries render, never warn). `contents` picks the advice: `'items'` the Nav\n * parts, `'sub-items'` Nav.SubItem, Nav.SectionHeader and Nav.Divider.\n */\nexport function useNavListChildCheck(\n list: React.RefObject<HTMLUListElement | null>,\n owner: string,\n contents: 'items' | 'sub-items',\n): void {\n React.useEffect(() => {\n if (!isDev) return;\n const key = `${owner}:list-child`;\n const element = list.current;\n if (!element || hasWarned(key)) return;\n const invalid = describeInvalidListChild(element);\n if (invalid === null) return;\n warnOnce(\n key,\n `${owner}: its list holds ${invalid}, but a list can hold only <li> elements. ${LIST_CHILD_ADVICE[contents]}`,\n );\n });\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Button items\n * declare them as `undefined`, so they are a type error without `href` instead of landing on the\n * `<button>`. `rel` cannot be listed (React types it on every element, RDFa); a button item drops\n * it at run time instead.\n */\nexport type NoAnchorOnlyAttributes = {\n [\n K in Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>\n >\n ]?: undefined;\n};\n"],"mappings":"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"}
@@ -1,291 +1,184 @@
1
1
  "use client";
2
2
  import { cn as e } from "../../lib/cn.mjs";
3
- import { getElementType as t } from "../../lib/children.mjs";
4
- import { reportMissingContext as n, resolveDeprecatedProp as r, warnDeprecated as i, warnOnce as a } from "../../lib/dev.mjs";
5
- import { renderSlot as o, slotRendersContent as s } from "../../lib/slot.mjs";
6
- import { navCategoryClassNames as c, navClassNames as l, navItemClassNames as u, navSubItemClassNames as d } from "../../lib/classNames.mjs";
7
- import { useEventCallback as f } from "../../hooks/useEventCallback.mjs";
8
- import { useControllable as p } from "../../hooks/useControllable.mjs";
9
- import { useId as m } from "../../hooks/useId.mjs";
10
- import { disabledStyles as h, focusRingInset as g } from "../../lib/styles.mjs";
11
- import { ChevronDownIcon as _ } from "../../lib/icons.mjs";
12
- import * as v from "react";
13
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
3
+ import { warnDeprecated as t } from "../../lib/dev.mjs";
4
+ import { materialiseSlotContent as n, renderSlot as r, slotRendersContent as i } from "../../lib/slot.mjs";
5
+ import { navCategoryClassNames as a, navItemClassNames as o, navSubItemClassNames as s } from "../../lib/classNames.mjs";
6
+ import { useId as c } from "../../hooks/useId.mjs";
7
+ import { disabledStyles as l, focusRingInset as u } from "../../lib/styles.mjs";
8
+ import { ChevronDownIcon as d } from "../../lib/icons.mjs";
9
+ import { NavCategoryValueContext as f, NavRovingContext as p, containsValue as m, markNavPart as h, useNavContext as g, useNavListChildCheck as _, useNavValue as v, useRecordCategory as y } from "./Nav.context.mjs";
10
+ import { NavAppItem as b, NavAppItemStatic as x, NavDivider as S, NavSectionHeader as C } from "./Nav.parts.mjs";
11
+ import { NavRoot as w } from "./Nav.root.mjs";
12
+ import * as T from "react";
13
+ import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
14
14
  //#region src/components/navigation/Nav.tsx
15
- function S() {
16
- let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = () => t.forEach((e) => e());
17
- return {
18
- record(t, r) {
19
- (e.get(t) ?? null) !== r && (r === null ? e.delete(t) : e.set(t, r), n());
20
- },
21
- forget(t, r) {
22
- e.get(t) === r && (e.delete(t), n());
23
- },
24
- get: (t) => e.get(t),
25
- subscribe(e) {
26
- return t.add(e), () => {
27
- t.delete(e);
28
- };
29
- }
30
- };
31
- }
32
- var C = v.createContext(null);
33
- C.displayName = "NavContext";
34
- var w = () => {}, T = {
35
- value: "",
36
- select: w,
37
- openCategories: [],
38
- toggleCategory: w,
39
- registerValue: () => w,
40
- currentCategory: void 0,
41
- categoryStore: {
42
- record: w,
43
- forget: w,
44
- get: () => void 0,
45
- subscribe: () => w
46
- }
47
- }, E = v.createContext(null);
48
- E.displayName = "NavCategoryValueContext";
49
- function D(e) {
50
- return v.useContext(C) || (n(e, "Nav"), T);
51
- }
52
- function O(e, t) {
53
- a(`Nav:duplicate-${e}:${t}`, e === "item" ? `Nav: several items share the value "${t}". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.` : `Nav: several categories share the value "${t}". Nav.Category values must be unique within a Nav; they open and close together.`);
15
+ var k = "flex h-5 w-5 shrink-0 items-center justify-center";
16
+ function A(t, n) {
17
+ return t && i(t) ? r(t, "span", e(n, k), { "aria-hidden": !0 }) : null;
54
18
  }
55
- function k(e, t, n) {
56
- let { registerValue: r } = e;
57
- v.useEffect(() => r(t, n), [
58
- r,
59
- t,
60
- n
61
- ]);
62
- }
63
- function A(e, t) {
64
- let n = v.useContext(E), { categoryStore: r } = e;
65
- v.useLayoutEffect(() => {
66
- r.record(t, n);
67
- }, [
68
- r,
69
- t,
70
- n
71
- ]);
72
- }
73
- var j = "flex h-5 w-5 shrink-0 items-center justify-center";
74
- function M(t, n) {
75
- return t && s(t) ? o(t, "span", e(n, j), { "aria-hidden": !0 }) : null;
76
- }
77
- var N = {
78
- base: e("flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none", g, h),
19
+ var j = {
20
+ base: e("flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none", u, l),
79
21
  selected: "bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary",
80
- idle: "text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover"
81
- }, P = {
82
- base: e("flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none", g, h),
22
+ idle: "text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover",
23
+ selectedInRow: "text-primary font-semibold",
24
+ rowSelected: "bg-subtle-selected border-s-2 border-s-primary"
25
+ }, M = {
26
+ base: e("flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none", u, l),
83
27
  selected: "text-primary font-semibold",
84
- idle: "text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover"
85
- }, F = e("flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none", "data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary", g);
86
- function I(e) {
87
- let { children: t } = e.props;
88
- return typeof t == "function" ? void 0 : t;
89
- }
28
+ idle: "text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover",
29
+ selectedInRow: "text-primary font-semibold",
30
+ rowSelected: void 0
31
+ }, N = "group/nav-row flex items-center transition-colors motion-reduce:transition-none", P = "hover:bg-subtle-hover", F = e("flex shrink-0 items-center gap-1 pe-2", "*:opacity-0 group-hover/nav-row:*:opacity-100 group-focus-within/nav-row:*:opacity-100", "forced-colors:*:opacity-100 [@media(hover:none)]:*:opacity-100", "*:has-[[aria-pressed=true]]:opacity-100 *:has-[[aria-expanded=true]]:opacity-100", "[&>[aria-pressed=true]]:opacity-100 [&>[aria-expanded=true]]:opacity-100"), I = e("flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none", "data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary", u);
90
32
  function L(e) {
91
- return (typeof e == "object" || typeof e == "function") && e !== null && typeof e.then == "function";
92
- }
93
- function R(e, t) {
94
- if (Array.isArray(e)) {
95
- for (let n of e) R(n, t);
96
- return;
97
- }
98
- try {
99
- v.Children.forEach(e, (e) => {
100
- v.isValidElement(e) && t(e);
101
- });
102
- } catch (e) {
103
- if (!L(e)) throw e;
104
- }
105
- }
106
- function z(e, ...n) {
107
- return n.includes(t(e, { suspend: !1 }));
108
- }
109
- function B(e, t) {
110
- let n = !1;
111
- return R(e, (e) => {
112
- n ||= z(e, G, K) && e.props.value === t ? !0 : B(I(e), t);
113
- }), n;
114
- }
115
- function V(e, t) {
116
- let n = [];
117
- if (!t) return n;
118
- let r = (e) => {
119
- R(e, (e) => {
120
- let i = I(e);
121
- z(e, W) && typeof e.props.value == "string" && B(i, t) && n.push(e.props.value), r(i);
122
- });
123
- };
124
- return r(e), n;
125
- }
126
- function H(e) {
127
33
  if (e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return !0;
128
34
  let t = e.currentTarget, n = t.getAttribute("target");
129
35
  return !!n && n.toLowerCase() !== "_self" || t.hasAttribute("download");
130
36
  }
131
- function U(t, n, r, i, a) {
132
- let { value: o, icon: s, disabled: c = !1, href: l, className: u, children: d, onClick: f, ref: p, ...m } = t, h = n.value === o, g = l !== void 0, _ = (e) => {
133
- if (c) {
37
+ function R(t, r, a, o, s, c, l) {
38
+ let { value: u, icon: d, disabled: f = !1, href: p, className: m, children: h, onClick: g, actions: _, ref: v, ...y } = t, b = r.value === u, x = p !== void 0, S = a ? { "data-roving-value": u } : void 0, C = i(_), w = y.id ?? l, T = C ? { id: w } : void 0, k = (e) => {
39
+ if (f) {
134
40
  e.preventDefault();
135
41
  return;
136
42
  }
137
- f?.(e), !(g ? !e.defaultPrevented && H(e) : e.defaultPrevented) && n.select(o);
138
- }, v = /* @__PURE__ */ x(y, { children: [a && M(s, i.icon), a ? /* @__PURE__ */ b("span", {
139
- className: e(i.content, "flex-1 text-start"),
140
- children: d
141
- }) : d] }), S = e(i.root, r.base, h ? r.selected : r.idle, u);
142
- if (g) return /* @__PURE__ */ b("li", {
143
- className: i.listItem,
144
- children: /* @__PURE__ */ b("a", {
145
- ...m,
146
- ref: p,
147
- href: c ? void 0 : l,
148
- role: c ? "link" : m.role,
149
- "aria-disabled": c ? !0 : m["aria-disabled"],
150
- "aria-current": h ? "page" : void 0,
151
- onClick: _,
152
- className: S,
153
- children: v
154
- })
43
+ g?.(e), !(x ? !e.defaultPrevented && L(e) : e.defaultPrevented) && r.select(u);
44
+ }, j = /* @__PURE__ */ O(E, { children: [c && A(d, s.icon), c ? /* @__PURE__ */ D("span", {
45
+ className: e(s.content, "flex-1 text-start"),
46
+ children: h
47
+ }) : h] }), M = e(s.root, o.base, b ? C ? o.selectedInRow : o.selected : o.idle, C && "min-w-0 flex-1", m), I = C ? e(s.listItem, N, b && o.rowSelected ? o.rowSelected : !f && P) : s.listItem, R = C ? /* @__PURE__ */ D("span", {
48
+ role: "group",
49
+ "aria-labelledby": w,
50
+ "data-wave-nav-actions": "",
51
+ className: e(s.actions, F),
52
+ children: n(_)
53
+ }) : null;
54
+ if (x) return /* @__PURE__ */ O("li", {
55
+ className: I,
56
+ children: [/* @__PURE__ */ D("a", {
57
+ ...y,
58
+ ...T,
59
+ ...S,
60
+ ref: v,
61
+ href: f ? void 0 : p,
62
+ role: f ? "link" : y.role,
63
+ "aria-disabled": f ? !0 : y["aria-disabled"],
64
+ "aria-current": b ? "page" : void 0,
65
+ onClick: k,
66
+ className: M,
67
+ children: j
68
+ }), R]
155
69
  });
156
- let { rel: C, ...w } = m;
157
- return /* @__PURE__ */ b("li", {
158
- className: i.listItem,
159
- children: /* @__PURE__ */ b("button", {
70
+ let { rel: z, ...B } = y;
71
+ return /* @__PURE__ */ O("li", {
72
+ className: I,
73
+ children: [/* @__PURE__ */ D("button", {
160
74
  type: "button",
161
- ...w,
162
- ref: p,
163
- disabled: c,
164
- "aria-current": h ? "page" : void 0,
165
- onClick: _,
166
- className: S,
167
- children: v
168
- })
75
+ ...B,
76
+ ...T,
77
+ ...S,
78
+ ref: v,
79
+ disabled: f,
80
+ "aria-current": b ? "page" : void 0,
81
+ onClick: k,
82
+ className: M,
83
+ children: j
84
+ }), R]
169
85
  });
170
86
  }
171
- var W = ({ value: t, label: n, icon: r, className: a, children: o, ref: s, ...l }) => {
172
- let u = D("Nav.Category"), { value: d, openCategories: f, toggleCategory: p, currentCategory: h, categoryStore: g } = u;
173
- k(u, "category", t);
174
- let y = m("wave-nav-category"), S = f.includes(t), C = !S && d !== "" && B(o, d), w = v.useSyncExternalStore(g.subscribe, () => d !== "" && g.get(d) === t, () => !1);
175
- v.useLayoutEffect(() => {
176
- if (C) return g.record(d, t), () => g.forget(d, t);
87
+ var z = ({ value: n, label: r, icon: i, className: o, children: s, ref: l, ...u }) => {
88
+ let h = g("Nav.Category"), y = T.useContext(p), { value: b, openCategories: x, toggleCategory: S, currentCategory: C, categoryStore: w } = h;
89
+ v(h, "category", n);
90
+ let E = c("wave-nav-category"), k = x.includes(n), j = !k && b !== "" && m(s, b), M = T.useSyncExternalStore(w.subscribe, () => b !== "" && w.get(b) === n, () => !1);
91
+ T.useLayoutEffect(() => {
92
+ if (j) return w.record(b, n), () => w.forget(b, n);
93
+ }, [
94
+ w,
95
+ j,
96
+ b,
97
+ n
98
+ ]);
99
+ let N = !k && (C === n || M || j);
100
+ T.useLayoutEffect(() => {
101
+ if (y) return y.reportCurrentCategory(n, N), () => y.reportCurrentCategory(n, !1);
177
102
  }, [
178
- g,
179
- C,
180
- d,
181
- t
103
+ y,
104
+ n,
105
+ N
182
106
  ]);
183
- let T = !S && (h === t || w || C), O = n, A = o;
184
- if (n === void 0) {
185
- i("Nav.Category", "text children as the label", "label", "Pass the category label in `label` and only the sub-items as children.");
186
- let e = v.Children.toArray(o), t = (e) => typeof e == "string" || typeof e == "number";
187
- O = e.filter(t).join(""), A = e.filter((e) => !t(e));
107
+ let P = T.useRef(null);
108
+ _(P, "Nav.Category", "sub-items");
109
+ let F = r, L = s;
110
+ if (r === void 0) {
111
+ t("Nav.Category", "text children as the label", "label", "Pass the category label in `label` and only the sub-items as children.");
112
+ let e = T.Children.toArray(s), n = (e) => typeof e == "string" || typeof e == "number";
113
+ F = e.filter(n).join(""), L = e.filter((e) => !n(e));
188
114
  }
189
- return /* @__PURE__ */ x("li", {
190
- ref: s,
191
- ...l,
192
- className: e(c.root, a),
193
- children: [/* @__PURE__ */ x("button", {
115
+ return /* @__PURE__ */ O("li", {
116
+ ref: l,
117
+ ...u,
118
+ className: e(a.root, o),
119
+ children: [/* @__PURE__ */ O("button", {
194
120
  type: "button",
195
- "aria-expanded": S,
196
- "aria-controls": S ? y : void 0,
197
- "aria-current": T ? !0 : void 0,
198
- "data-contains-current": T ? "" : void 0,
199
- onClick: () => p(t),
200
- className: e(c.button, F),
121
+ "aria-expanded": k,
122
+ "aria-controls": k ? E : void 0,
123
+ "aria-current": N ? !0 : void 0,
124
+ "data-contains-current": N ? "" : void 0,
125
+ "data-roving-value": y ? `wave-nav-category:${n}` : void 0,
126
+ onClick: () => S(n),
127
+ className: e(a.button, I),
201
128
  children: [
202
- M(r, c.icon),
203
- /* @__PURE__ */ b("span", {
204
- className: e(c.label, "flex-1 text-start"),
205
- children: O
129
+ A(i, a.icon),
130
+ /* @__PURE__ */ D("span", {
131
+ className: e(a.label, "flex-1 text-start"),
132
+ children: F
206
133
  }),
207
- /* @__PURE__ */ b(_, { className: e(c.expandIcon, "shrink-0 transition-transform motion-reduce:transition-none", S && "rotate-180") })
134
+ /* @__PURE__ */ D(d, { className: e(a.expandIcon, "shrink-0 transition-transform motion-reduce:transition-none", k && "rotate-180") })
208
135
  ]
209
- }), S && /* @__PURE__ */ b(E.Provider, {
210
- value: t,
211
- children: /* @__PURE__ */ b("ul", {
212
- id: y,
213
- className: e(c.list, "m-0 list-none p-0"),
214
- children: A
136
+ }), k && /* @__PURE__ */ D(f.Provider, {
137
+ value: n,
138
+ children: /* @__PURE__ */ D("ul", {
139
+ ref: P,
140
+ id: E,
141
+ className: e(a.list, "m-0 list-none p-0"),
142
+ children: L
215
143
  })
216
144
  })]
217
145
  });
218
146
  };
219
- W.displayName = "NavCategory";
220
- function G(e) {
221
- let t = D("Nav.Item");
222
- return k(t, "item", e.value), A(t, e.value), U(e, t, N, {
223
- root: u.root,
224
- listItem: u.listItem,
225
- icon: u.icon,
226
- content: u.content
227
- }, !0);
228
- }
229
- G.displayName = "NavItem";
230
- function K(e) {
231
- let t = D("Nav.SubItem");
232
- return k(t, "item", e.value), A(t, e.value), U(e, t, P, {
233
- root: d.root,
234
- listItem: d.listItem
235
- }, !1);
236
- }
237
- K.displayName = "NavSubItem";
238
- var q = ({ value: t, defaultValue: n, onValueChange: a, selectedValue: o, defaultSelectedValue: s, onNavItemSelect: c, openCategories: u, defaultOpenCategories: d, onOpenCategoriesChange: m, currentCategory: h, className: g, children: _, ref: y, ...x }) => {
239
- let w = r("Nav", t, o, "selectedValue", "value"), T = r("Nav", n, s, "defaultSelectedValue", "defaultValue") ?? "";
240
- c !== void 0 && i("Nav", "onNavItemSelect", "onValueChange");
241
- let [E, D] = p(w, T, a), k = f(c), A = v.useCallback((e) => {
242
- D(e), k(e);
243
- }, [D, k]), [j] = v.useState(() => d ?? V(_, w ?? T)), [M, N] = p(u, j, (e) => m?.([...e])), P = v.useCallback((e) => {
244
- N((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
245
- }, [N]), F = v.useRef(null), I = v.useCallback((e, t) => {
246
- let n = F.current ??= /* @__PURE__ */ new Map(), r = `${e}:${t}`, i = (n.get(r) ?? 0) + 1;
247
- return n.set(r, i), i > 1 && O(e, t), () => {
248
- let e = (n.get(r) ?? 1) - 1;
249
- e > 0 ? n.set(r, e) : n.delete(r);
250
- };
251
- }, []), [L] = v.useState(S), R = v.useMemo(() => ({
252
- value: E,
253
- select: A,
254
- openCategories: M,
255
- toggleCategory: P,
256
- registerValue: I,
257
- currentCategory: h,
258
- categoryStore: L
259
- }), [
260
- E,
261
- A,
262
- M,
263
- P,
264
- I,
265
- h,
266
- L
267
- ]);
268
- return /* @__PURE__ */ b(C.Provider, {
269
- value: R,
270
- children: /* @__PURE__ */ b("nav", {
271
- "aria-label": "Navigation",
272
- ...x,
273
- ref: y,
274
- className: e(l.root, "w-60 border-e border-border bg-background py-2", g),
275
- children: /* @__PURE__ */ b("ul", {
276
- className: e(l.list, "m-0 list-none p-0"),
277
- children: _
278
- })
279
- })
280
- });
281
- };
282
- q.displayName = "Nav";
283
- var J = /* @__PURE__ */ Object.assign(q, {
284
- Category: W,
285
- Item: G,
286
- SubItem: K
147
+ z.displayName = "NavCategory", h(z, "category");
148
+ function B(e) {
149
+ let t = g("Nav.Item");
150
+ v(t, "item", e.value), y(t, e.value);
151
+ let n = T.useContext(p), r = c("wave-nav-item");
152
+ return R(e, t, n, j, {
153
+ root: o.root,
154
+ listItem: o.listItem,
155
+ actions: o.actions,
156
+ icon: o.icon,
157
+ content: o.content
158
+ }, !0, r);
159
+ }
160
+ B.displayName = "NavItem", h(B, "entry");
161
+ function V(e) {
162
+ let t = g("Nav.SubItem");
163
+ v(t, "item", e.value), y(t, e.value);
164
+ let n = T.useContext(p), r = c("wave-nav-item");
165
+ return R(e, t, n, M, {
166
+ root: s.root,
167
+ listItem: s.listItem,
168
+ actions: s.actions
169
+ }, !1, r);
170
+ }
171
+ V.displayName = "NavSubItem", h(V, "entry");
172
+ var H = /* @__PURE__ */ Object.assign(w, {
173
+ Category: z,
174
+ Item: B,
175
+ SubItem: V,
176
+ SectionHeader: C,
177
+ Divider: S,
178
+ AppItem: b,
179
+ AppItemStatic: x
287
180
  });
288
181
  //#endregion
289
- export { J as Nav, W as NavCategory, G as NavItem, K as NavSubItem };
182
+ export { H as Nav, b as NavAppItem, x as NavAppItemStatic, z as NavCategory, S as NavDivider, B as NavItem, C as NavSectionHeader, V as NavSubItem };
290
183
 
291
184
  //# sourceMappingURL=Nav.mjs.map