@mortenbrudvik/waveui 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +357 -72
  2. package/dist/components/button/Toolbar.cjs +1 -1
  3. package/dist/components/button/Toolbar.cjs.map +1 -1
  4. package/dist/components/button/Toolbar.mjs +25 -30
  5. package/dist/components/button/Toolbar.mjs.map +1 -1
  6. package/dist/components/button/Toolbar.navigation.cjs +2 -0
  7. package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
  8. package/dist/components/button/Toolbar.navigation.mjs +17 -0
  9. package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
  10. package/dist/components/data-display/Avatar.cjs +1 -1
  11. package/dist/components/data-display/Avatar.cjs.map +1 -1
  12. package/dist/components/data-display/Avatar.context.cjs +2 -0
  13. package/dist/components/data-display/Avatar.context.cjs.map +1 -0
  14. package/dist/components/data-display/Avatar.context.mjs +9 -0
  15. package/dist/components/data-display/Avatar.context.mjs.map +1 -0
  16. package/dist/components/data-display/Avatar.mjs +66 -61
  17. package/dist/components/data-display/Avatar.mjs.map +1 -1
  18. package/dist/components/data-display/InteractionTag.cjs +2 -0
  19. package/dist/components/data-display/InteractionTag.cjs.map +1 -0
  20. package/dist/components/data-display/InteractionTag.mjs +234 -0
  21. package/dist/components/data-display/InteractionTag.mjs.map +1 -0
  22. package/dist/components/data-display/Tag.cjs +1 -1
  23. package/dist/components/data-display/Tag.cjs.map +1 -1
  24. package/dist/components/data-display/Tag.mjs +222 -90
  25. package/dist/components/data-display/Tag.mjs.map +1 -1
  26. package/dist/components/data-display/TagGroup.cjs +2 -0
  27. package/dist/components/data-display/TagGroup.cjs.map +1 -0
  28. package/dist/components/data-display/TagGroup.context.cjs +2 -0
  29. package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
  30. package/dist/components/data-display/TagGroup.context.mjs +113 -0
  31. package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
  32. package/dist/components/data-display/TagGroup.mjs +149 -0
  33. package/dist/components/data-display/TagGroup.mjs.map +1 -0
  34. package/dist/components/data-display/tagStyles.cjs +2 -0
  35. package/dist/components/data-display/tagStyles.cjs.map +1 -0
  36. package/dist/components/data-display/tagStyles.mjs +108 -0
  37. package/dist/components/data-display/tagStyles.mjs.map +1 -0
  38. package/dist/components/feedback/Toaster.cjs +1 -1
  39. package/dist/components/feedback/Toaster.cjs.map +1 -1
  40. package/dist/components/feedback/Toaster.mjs +213 -181
  41. package/dist/components/feedback/Toaster.mjs.map +1 -1
  42. package/dist/components/input/Combobox.expand.cjs +1 -1
  43. package/dist/components/input/Combobox.expand.cjs.map +1 -1
  44. package/dist/components/input/Combobox.expand.mjs +7 -7
  45. package/dist/components/input/Combobox.expand.mjs.map +1 -1
  46. package/dist/components/input/Option.cjs +1 -1
  47. package/dist/components/input/Option.cjs.map +1 -1
  48. package/dist/components/input/Option.mjs +16 -11
  49. package/dist/components/input/Option.mjs.map +1 -1
  50. package/dist/components/input/SwatchPicker.cjs.map +1 -1
  51. package/dist/components/input/SwatchPicker.context.cjs.map +1 -1
  52. package/dist/components/input/SwatchPicker.context.mjs.map +1 -1
  53. package/dist/components/input/SwatchPicker.mjs.map +1 -1
  54. package/dist/components/input/TagPicker.cjs +1 -1
  55. package/dist/components/input/TagPicker.cjs.map +1 -1
  56. package/dist/components/input/TagPicker.context.cjs +2 -0
  57. package/dist/components/input/TagPicker.context.cjs.map +1 -0
  58. package/dist/components/input/TagPicker.context.mjs +20 -0
  59. package/dist/components/input/TagPicker.context.mjs.map +1 -0
  60. package/dist/components/input/TagPicker.create.cjs +2 -0
  61. package/dist/components/input/TagPicker.create.cjs.map +1 -0
  62. package/dist/components/input/TagPicker.create.mjs +24 -0
  63. package/dist/components/input/TagPicker.create.mjs.map +1 -0
  64. package/dist/components/input/TagPicker.mjs +13 -279
  65. package/dist/components/input/TagPicker.mjs.map +1 -1
  66. package/dist/components/input/TagPicker.option.cjs +2 -0
  67. package/dist/components/input/TagPicker.option.cjs.map +1 -0
  68. package/dist/components/input/TagPicker.option.mjs +45 -0
  69. package/dist/components/input/TagPicker.option.mjs.map +1 -0
  70. package/dist/components/input/TagPicker.overflow.cjs +2 -0
  71. package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
  72. package/dist/components/input/TagPicker.overflow.mjs +153 -0
  73. package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
  74. package/dist/components/input/TagPicker.parts.cjs +2 -0
  75. package/dist/components/input/TagPicker.parts.cjs.map +1 -0
  76. package/dist/components/input/TagPicker.parts.mjs +425 -0
  77. package/dist/components/input/TagPicker.parts.mjs.map +1 -0
  78. package/dist/components/input/TagPicker.root.cjs +2 -0
  79. package/dist/components/input/TagPicker.root.cjs.map +1 -0
  80. package/dist/components/input/TagPicker.root.mjs +416 -0
  81. package/dist/components/input/TagPicker.root.mjs.map +1 -0
  82. package/dist/components/layout/Accordion.cjs.map +1 -1
  83. package/dist/components/layout/Accordion.mjs.map +1 -1
  84. package/dist/components/navigation/Hamburger.cjs +2 -0
  85. package/dist/components/navigation/Hamburger.cjs.map +1 -0
  86. package/dist/components/navigation/Hamburger.mjs +54 -0
  87. package/dist/components/navigation/Hamburger.mjs.map +1 -0
  88. package/dist/components/navigation/Nav.cjs +1 -1
  89. package/dist/components/navigation/Nav.cjs.map +1 -1
  90. package/dist/components/navigation/Nav.context.cjs +2 -0
  91. package/dist/components/navigation/Nav.context.cjs.map +1 -0
  92. package/dist/components/navigation/Nav.context.mjs +137 -0
  93. package/dist/components/navigation/Nav.context.mjs.map +1 -0
  94. package/dist/components/navigation/Nav.mjs +151 -258
  95. package/dist/components/navigation/Nav.mjs.map +1 -1
  96. package/dist/components/navigation/Nav.parts.cjs +2 -0
  97. package/dist/components/navigation/Nav.parts.cjs.map +1 -0
  98. package/dist/components/navigation/Nav.parts.mjs +77 -0
  99. package/dist/components/navigation/Nav.parts.mjs.map +1 -0
  100. package/dist/components/navigation/Nav.root.cjs +2 -0
  101. package/dist/components/navigation/Nav.root.cjs.map +1 -0
  102. package/dist/components/navigation/Nav.root.mjs +78 -0
  103. package/dist/components/navigation/Nav.root.mjs.map +1 -0
  104. package/dist/components/navigation/NavDrawer.cjs +2 -0
  105. package/dist/components/navigation/NavDrawer.cjs.map +1 -0
  106. package/dist/components/navigation/NavDrawer.context.cjs +2 -0
  107. package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
  108. package/dist/components/navigation/NavDrawer.context.mjs +11 -0
  109. package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
  110. package/dist/components/navigation/NavDrawer.mjs +179 -0
  111. package/dist/components/navigation/NavDrawer.mjs.map +1 -0
  112. package/dist/components/overlays/Dialog.cjs +1 -1
  113. package/dist/components/overlays/Dialog.cjs.map +1 -1
  114. package/dist/components/overlays/Dialog.mjs +190 -125
  115. package/dist/components/overlays/Dialog.mjs.map +1 -1
  116. package/dist/components/overlays/Dialog.shared.cjs +1 -1
  117. package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
  118. package/dist/components/overlays/Dialog.shared.mjs +157 -81
  119. package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
  120. package/dist/components/overlays/Dialog.slots.cjs +2 -0
  121. package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
  122. package/dist/components/overlays/Dialog.slots.mjs +129 -0
  123. package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
  124. package/dist/components/overlays/Drawer.cjs +1 -1
  125. package/dist/components/overlays/Drawer.cjs.map +1 -1
  126. package/dist/components/overlays/Drawer.context.cjs +2 -0
  127. package/dist/components/overlays/Drawer.context.cjs.map +1 -0
  128. package/dist/components/overlays/Drawer.context.mjs +29 -0
  129. package/dist/components/overlays/Drawer.context.mjs.map +1 -0
  130. package/dist/components/overlays/Drawer.mjs +12 -187
  131. package/dist/components/overlays/Drawer.mjs.map +1 -1
  132. package/dist/components/overlays/Drawer.panel.cjs +2 -0
  133. package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
  134. package/dist/components/overlays/Drawer.panel.mjs +159 -0
  135. package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
  136. package/dist/components/overlays/Drawer.parts.cjs +2 -0
  137. package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
  138. package/dist/components/overlays/Drawer.parts.mjs +152 -0
  139. package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
  140. package/dist/components/overlays/Drawer.root.cjs +2 -0
  141. package/dist/components/overlays/Drawer.root.cjs.map +1 -0
  142. package/dist/components/overlays/Drawer.root.mjs +207 -0
  143. package/dist/components/overlays/Drawer.root.mjs.map +1 -0
  144. package/dist/components/overlays/Drawer.scroll.cjs +2 -0
  145. package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
  146. package/dist/components/overlays/Drawer.scroll.mjs +42 -0
  147. package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
  148. package/dist/hooks/useDismiss.cjs.map +1 -1
  149. package/dist/hooks/useDismiss.mjs.map +1 -1
  150. package/dist/hooks/useFocusTrap.cjs +1 -1
  151. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  152. package/dist/hooks/useFocusTrap.mjs +115 -98
  153. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  154. package/dist/hooks/useModalLayer.cjs +1 -1
  155. package/dist/hooks/useModalLayer.cjs.map +1 -1
  156. package/dist/hooks/useModalLayer.mjs +35 -22
  157. package/dist/hooks/useModalLayer.mjs.map +1 -1
  158. package/dist/hooks/useRestoreFocus.cjs +1 -1
  159. package/dist/hooks/useRestoreFocus.cjs.map +1 -1
  160. package/dist/hooks/useRestoreFocus.mjs +91 -78
  161. package/dist/hooks/useRestoreFocus.mjs.map +1 -1
  162. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  163. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  164. package/dist/hooks/useRovingTabIndex.mjs +102 -78
  165. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  166. package/dist/index.cjs +1 -1
  167. package/dist/index.d.cts +2226 -221
  168. package/dist/index.d.ts +2226 -221
  169. package/dist/index.mjs +115 -107
  170. package/dist/lib/classNames.cjs +1 -1
  171. package/dist/lib/classNames.cjs.map +1 -1
  172. package/dist/lib/classNames.mjs +137 -77
  173. package/dist/lib/classNames.mjs.map +1 -1
  174. package/dist/lib/icons.cjs +1 -1
  175. package/dist/lib/icons.cjs.map +1 -1
  176. package/dist/lib/icons.mjs +13 -6
  177. package/dist/lib/icons.mjs.map +1 -1
  178. package/dist/lib/layers.cjs +1 -1
  179. package/dist/lib/layers.cjs.map +1 -1
  180. package/dist/lib/layers.mjs +53 -47
  181. package/dist/lib/layers.mjs.map +1 -1
  182. package/dist/styles.css +1 -1
  183. package/package.json +1 -1
  184. package/src/styles/tokens.css +25 -0
@@ -57,22 +57,37 @@ function _(e, t, n) {
57
57
  for (let r = e; r && r !== t; r = r.parentElement) if (g(r, n)) return !0;
58
58
  return !1;
59
59
  }
60
- function v(e) {
60
+ var v = "[tabindex], [data-roving-value]";
61
+ function y(e, t) {
62
+ try {
63
+ return e.matches(t);
64
+ } catch {
65
+ return !1;
66
+ }
67
+ }
68
+ function b(e) {
69
+ let t = /* @__PURE__ */ new Map();
70
+ for (let n of e) n.type === "attributes" && n.attributeName === "tabindex" && t.set(n.target, n);
71
+ let n = /* @__PURE__ */ new Set();
72
+ for (let [e, r] of t) r.oldValue === e.getAttribute("tabindex") && n.add(e);
73
+ return n;
74
+ }
75
+ function x(e) {
61
76
  return e.tabIndex >= 0 && !e.hasAttribute("disabled");
62
77
  }
63
- function y(e) {
78
+ function S(e) {
64
79
  let { element: t } = e;
65
- if (!e.nested || v(t)) return t;
80
+ if (!e.nested || x(t)) return t;
66
81
  let n = t.querySelector("[tabindex=\"0\"]");
67
82
  if (n) return n;
68
83
  let r = o(t);
69
84
  return r instanceof HTMLElement ? r : null;
70
85
  }
71
- function b(e) {
86
+ function C(e) {
72
87
  let t = e.getAttribute("data-roving-disabled");
73
- return t !== null && t !== "false" || x(e) ? !0 : !e.hasAttribute("data-disabled-focusable") && e.getAttribute("aria-disabled") === "true";
88
+ return t !== null && t !== "false" || w(e) ? !0 : !e.hasAttribute("data-disabled-focusable") && e.getAttribute("aria-disabled") === "true";
74
89
  }
75
- function x(e) {
90
+ function w(e) {
76
91
  if (e.disabled === !0) return !0;
77
92
  try {
78
93
  return e.matches(":disabled");
@@ -80,7 +95,7 @@ function x(e) {
80
95
  return !1;
81
96
  }
82
97
  }
83
- function S(e) {
98
+ function T(e) {
84
99
  if (!e || e.nodeType !== 1) return !1;
85
100
  let t = e, n = t.getAttribute("role");
86
101
  if (n !== null && p.has(n)) return !0;
@@ -90,10 +105,10 @@ function S(e) {
90
105
  let i = t.closest("[contenteditable]");
91
106
  return i !== null && i.getAttribute("contenteditable") !== "false";
92
107
  }
93
- function C(e) {
94
- return !e.nested && !S(e.element);
108
+ function E(e) {
109
+ return !e.nested && !T(e.element);
95
110
  }
96
- function w(e, t, n) {
111
+ function D(e, t, n) {
97
112
  let r = e.ownerDocument.defaultView;
98
113
  if (!r) return !1;
99
114
  for (let i = e; i && i !== t; i = i.parentElement) {
@@ -118,14 +133,14 @@ function te(e) {
118
133
  return !1;
119
134
  }
120
135
  }
121
- function T(e) {
122
- return [e.value, e.disabled ? 0 : C(e) ? 1 : 2];
136
+ function O(e) {
137
+ return [e.value, e.disabled ? 0 : E(e) ? 1 : 2];
123
138
  }
124
- function E(e, t, n, r) {
139
+ function k(e, t, n, r) {
125
140
  let i = e.some(([, e]) => e === 1) ? 1 : 2, a = e.filter(([, e]) => e === i).map(([e]) => e);
126
141
  return n === "last-focused" && r !== null && a.includes(r) ? r : t !== null && t !== "" && a.includes(t) ? t : a[0] ?? null;
127
142
  }
128
- function D(e, t) {
143
+ function A(e, t) {
129
144
  if (!t) return e;
130
145
  let n = new Map(e.map((e) => [e.value, e])), r = [];
131
146
  for (let e of t) {
@@ -134,7 +149,7 @@ function D(e, t) {
134
149
  }
135
150
  return r;
136
151
  }
137
- var O = class {
152
+ var j = class {
138
153
  container = null;
139
154
  lastFocused = null;
140
155
  options = {
@@ -155,20 +170,22 @@ var O = class {
155
170
  subscribe = (e) => (this.notify = e, this.observe(), () => {
156
171
  this.notify = null, this.disconnect();
157
172
  });
158
- getSnapshot = () => this.container ? (this.dirty && (this.dirty = !1, this.snapshot = JSON.stringify(this.resolveOwn().map(T))), this.snapshot) : "";
173
+ getSnapshot = () => this.container ? (this.dirty && (this.dirty = !1, this.snapshot = JSON.stringify(this.resolveOwn().map(O))), this.snapshot) : "";
159
174
  getServerSnapshot = () => "";
160
175
  setContainer(e) {
161
- e !== this.container && (this.disconnect(), this.container = e, this.dirty = !0, this.notify && (this.observe(), this.notify()));
176
+ if (e === this.container) return;
177
+ let t = this.takeRecords();
178
+ this.disconnect(), this.container && this.options.manageTabIndex && this.release(this.container, "all", t), this.container = e, this.dirty = !0, this.notify && (this.observe(), this.notify());
162
179
  }
163
180
  recordFocus(e) {
164
- C(e) && (this.lastFocused = e.value);
181
+ E(e) && (this.lastFocused = e.value);
165
182
  }
166
183
  setOptions(e) {
167
184
  let t = this.options;
168
- this.options = e, (t.itemSelector !== e.itemSelector || t.manageTabIndex !== e.manageTabIndex || t.roleComposites !== e.roleComposites) && (this.dirty = !0, this.notify?.());
185
+ this.options = e, t.manageTabIndex && !e.manageTabIndex && this.container && this.release(this.container, "all", this.takeRecords()), (t.itemSelector !== e.itemSelector || t.manageTabIndex !== e.manageTabIndex || t.roleComposites !== e.roleComposites) && (this.dirty = !0, this.notify?.());
169
186
  }
170
187
  resolve(e = this.container) {
171
- return D(this.resolveOwn(e), this.options.items);
188
+ return A(this.resolveOwn(e), this.options.items);
172
189
  }
173
190
  resolveOwn(e = this.container) {
174
191
  if (!e) return [];
@@ -192,39 +209,45 @@ var O = class {
192
209
  value: this.valueOf(u, d),
193
210
  element: u,
194
211
  nested: d,
195
- disabled: b(u)
212
+ disabled: C(u)
196
213
  };
197
- d && !f.disabled && !y(f) && (f.disabled = !0), n && !f.disabled && w(u, e, c) && (f.disabled = !0), a.push(f);
214
+ d && !f.disabled && !S(f) && (f.disabled = !0), n && !f.disabled && D(u, e, c) && (f.disabled = !0), a.push(f);
198
215
  }
199
216
  return a;
200
217
  }
201
218
  stamp() {
202
219
  if (!this.options.manageTabIndex || !this.container) return;
203
- this.release(this.container);
204
- let e = this.resolve(), t = this.options.tabStop === "none" ? null : E(e.map(T), this.options.activeValue, this.options.tabStop, this.lastFocused);
220
+ this.release(this.container, "stale");
221
+ let e = this.resolve(), t = this.options.tabStop === "none" ? null : k(e.map(O), this.options.activeValue, this.options.tabStop, this.lastFocused);
205
222
  for (let n of e) {
206
223
  if (n.nested) continue;
207
- let { element: e } = n, r = this.stamped.get(e);
208
- r || (r = {
209
- tabIndex: e.getAttribute("tabindex"),
210
- addedValue: !e.hasAttribute("data-roving-value")
211
- }, this.stamped.set(e, r));
212
- let i = n.value === t ? "0" : "-1";
213
- e.getAttribute("tabindex") !== i && e.setAttribute("tabindex", i), e.hasAttribute("data-roving-value") || e.setAttribute("data-roving-value", n.value);
224
+ let { element: e } = n, r = n.value === t ? "0" : "-1", i = e.getAttribute("tabindex"), a = this.stamped.get(e);
225
+ a ? (i !== a.stamped && (a.tabIndex = i), a.stamped = r) : (a = {
226
+ tabIndex: i,
227
+ stamped: r,
228
+ addedValue: null
229
+ }, this.stamped.set(e, a)), i !== r && e.setAttribute("tabindex", r), e.hasAttribute("data-roving-value") || (e.setAttribute("data-roving-value", n.value), a.addedValue = n.value);
214
230
  }
215
231
  }
216
- release(e) {
217
- let t;
218
- try {
219
- t = Array.from(e.querySelectorAll(this.options.itemSelector));
220
- } catch {
221
- return;
232
+ release(e, t, n = []) {
233
+ let r = b(n), { itemSelector: i, roleComposites: a } = this.options;
234
+ for (let n of Array.from(e.querySelectorAll(v))) {
235
+ let o = this.stamped.get(n);
236
+ if (!o || t === "stale" && y(n, i) && !_(n, e, a)) continue;
237
+ this.stamped.delete(n);
238
+ let s = n.getAttribute("tabindex");
239
+ !(s !== o.stamped || r.has(n)) && s !== o.tabIndex && (o.tabIndex === null ? n.removeAttribute("tabindex") : n.setAttribute("tabindex", o.tabIndex)), o.addedValue !== null && n.getAttribute("data-roving-value") === o.addedValue && n.removeAttribute("data-roving-value");
222
240
  }
223
- for (let n of t) {
224
- let t = this.stamped.get(n);
225
- t && _(n, e, this.options.roleComposites) && (this.stamped.delete(n), t.tabIndex === null ? n.removeAttribute("tabindex") : n.setAttribute("tabindex", t.tabIndex), t.addedValue && n.removeAttribute("data-roving-value"));
241
+ }
242
+ adopt(e) {
243
+ for (let t of b(e)) {
244
+ let e = this.stamped.get(t);
245
+ e && (e.tabIndex = t.getAttribute("tabindex"));
226
246
  }
227
247
  }
248
+ takeRecords() {
249
+ return this.observer?.takeRecords() ?? [];
250
+ }
228
251
  valueOf(e, t) {
229
252
  let n = t ? null : e.getAttribute("data-roving-value");
230
253
  if (n !== null) return n;
@@ -232,12 +255,13 @@ var O = class {
232
255
  return r === void 0 && (this.autoCounter += 1, r = `auto-${this.autoCounter}`, this.autoValues.set(e, r)), r;
233
256
  }
234
257
  observe() {
235
- this.container && !this.observer && typeof MutationObserver < "u" && (this.observer = new MutationObserver(() => {
236
- this.stamp(), this.dirty = !0, this.notify?.();
258
+ this.container && !this.observer && typeof MutationObserver < "u" && (this.observer = new MutationObserver((e) => {
259
+ this.adopt(e), this.stamp(), this.dirty = !0, this.notify?.();
237
260
  }), this.observer.observe(this.container, {
238
261
  subtree: !0,
239
262
  childList: !0,
240
263
  attributes: !0,
264
+ attributeOldValue: !0,
241
265
  attributeFilter: h
242
266
  }), this.dirty = !0);
243
267
  }
@@ -245,7 +269,7 @@ var O = class {
245
269
  this.observer?.disconnect(), this.observer = null;
246
270
  }
247
271
  };
248
- function k(e) {
272
+ function M(e) {
249
273
  if (e === "") return null;
250
274
  try {
251
275
  return JSON.parse(e);
@@ -253,13 +277,13 @@ function k(e) {
253
277
  return null;
254
278
  }
255
279
  }
256
- function A(e) {
280
+ function N(e) {
257
281
  return e.getAttribute("data-roving-text") ?? e.textContent ?? "";
258
282
  }
259
- function j(e, t) {
283
+ function P(e, t) {
260
284
  return !t || typeof t.nodeType != "number" ? !1 : t === e || e.contains(t);
261
285
  }
262
- function M(e, t, n) {
286
+ function F(e, t, n) {
263
287
  if (e.length === 0 || !t || typeof t.nodeType != "number") return null;
264
288
  let r = new Map(e.map((e) => [e.element, e]));
265
289
  for (let e = t; e && e !== n; e = e.parentNode) {
@@ -268,24 +292,24 @@ function M(e, t, n) {
268
292
  }
269
293
  return null;
270
294
  }
271
- function N(e, t, n) {
272
- return e ? t === y(e) : t === n;
295
+ function I(e, t, n) {
296
+ return e ? t === S(e) : t === n;
273
297
  }
274
- function P(o, s) {
275
- let f = s === void 0 ? void 0 : o, { activeValue: p = null, items: m, orientation: h = "horizontal", loop: g = !0, dir: _, itemSelector: v = d, typeahead: b = !1, homeEndKeys: x = !0, tabStop: w = "active", manageTabIndex: T = !1, onFocusMove: D } = s ?? o, [P] = u.useState(() => new O()), F = u.useSyncExternalStore(P.subscribe, P.getSnapshot, P.getServerSnapshot), [I, L] = u.useState(null), [R, z] = u.useState(null), B = f === void 0 && m === void 0;
298
+ function L(o, s) {
299
+ let f = s === void 0 ? void 0 : o, { activeValue: p = null, items: m, orientation: h = "horizontal", loop: g = !0, dir: _, itemSelector: v = d, typeahead: y = !1, homeEndKeys: b = !0, tabStop: x = "active", manageTabIndex: C = !1, onFocusMove: w } = s ?? o, [D] = u.useState(() => new j()), O = u.useSyncExternalStore(D.subscribe, D.getSnapshot, D.getServerSnapshot), [A, L] = u.useState(null), [R, z] = u.useState(null), B = f === void 0 && m === void 0;
276
300
  u.useLayoutEffect(() => {
277
- P.setOptions({
301
+ D.setOptions({
278
302
  itemSelector: v,
279
- manageTabIndex: T,
303
+ manageTabIndex: C,
280
304
  items: m,
281
305
  activeValue: p,
282
- tabStop: w,
306
+ tabStop: x,
283
307
  roleComposites: B
284
- }), f && P.setContainer(f.current), P.stamp();
308
+ }), f && D.setContainer(f.current), D.stamp();
285
309
  }), u.useEffect(() => {
286
310
  e && !te(v) && t(`useRovingTabIndex:itemSelector:${v}`, `useRovingTabIndex: itemSelector "${v}" is not a valid CSS selector in this browser; no item is navigable or tabbable.`);
287
311
  }, [v]);
288
- let V = u.useMemo(() => k(F), [F]), H = u.useMemo(() => {
312
+ let V = u.useMemo(() => M(O), [O]), H = u.useMemo(() => {
289
313
  if (!m) return V;
290
314
  if (V) {
291
315
  let e = new Map(V), t = m.flatMap((t) => {
@@ -295,27 +319,27 @@ function P(o, s) {
295
319
  if (t.length > 0) return t;
296
320
  }
297
321
  return m.map((e) => [e, 1]);
298
- }, [m, V]), U = w === "none" ? null : H ? E(H, p, w, R) : p || null, W = u.useCallback((e) => e === U ? 0 : -1, [U]), G = u.useCallback((e) => {
299
- P.setContainer(e), f && n(f, e);
300
- }, [P, f]), K = u.useRef([]), q = u.useRef([]), { onTypeahead: ne, isSearching: re } = l({
322
+ }, [m, V]), U = x === "none" ? null : H ? k(H, p, x, R) : p || null, W = u.useCallback((e) => e === U ? 0 : -1, [U]), G = u.useCallback((e) => {
323
+ D.setContainer(e), f && n(f, e);
324
+ }, [D, f]), K = u.useRef([]), q = u.useRef([]), { onTypeahead: ne, isSearching: re } = l({
301
325
  getItems: () => K.current,
302
326
  onMatch: (e, t) => {
303
327
  q.current = t;
304
328
  }
305
329
  }), J = (e) => {
306
330
  if (!e || e.disabled) return !1;
307
- let t = y(e);
308
- return !t || (t.focus(), !ee(t)) ? !1 : (P.recordFocus(e), !0);
331
+ let t = S(e);
332
+ return !t || (t.focus(), !ee(t)) ? !1 : (D.recordFocus(e), !0);
309
333
  }, Y = (e) => {
310
334
  for (let t of e) if (J(t)) return;
311
335
  }, X = r((e, t) => {
312
336
  let n = e.metaKey || (e.altKey || e.ctrlKey) && !c(e);
313
- if (e.defaultPrevented || n || S(e.target)) return;
314
- let r = P.container ?? e.currentTarget;
315
- if (!j(r, e.target)) return;
316
- let o = P.resolve(r), s = o.filter((e) => !e.disabled);
337
+ if (e.defaultPrevented || n || T(e.target)) return;
338
+ let r = D.container ?? e.currentTarget;
339
+ if (!P(r, e.target)) return;
340
+ let o = D.resolve(r), s = o.filter((e) => !e.disabled);
317
341
  if (s.length === 0) return;
318
- let l = M(o, e.target, r), u = !1, d = [], f = t ? null : i(e.key, {
342
+ let l = F(o, e.target, r), u = !1, d = [], f = t ? null : i(e.key, {
319
343
  orientation: h,
320
344
  dir: _ ?? a(e.currentTarget)
321
345
  });
@@ -331,9 +355,9 @@ function P(o, s) {
331
355
  o[n].disabled || d.push(o[n]);
332
356
  }
333
357
  }
334
- } else !t && x && (e.key === "Home" || e.key === "End") ? (u = !0, d = e.key === "Home" ? s : [...s].reverse()) : b && N(l, e.target, r) && (K.current = o.map((e) => ({
358
+ } else !t && b && (e.key === "Home" || e.key === "End") ? (u = !0, d = e.key === "Home" ? s : [...s].reverse()) : y && I(l, e.target, r) && (K.current = o.map((e) => ({
335
359
  value: e.value,
336
- text: A(e.element),
360
+ text: N(e.element),
337
361
  disabled: e.disabled
338
362
  })), q.current = [], ne(e, l?.value ?? null) && (u = !0, d = q.current.flatMap((e) => s.filter((t) => t.value === e))));
339
363
  if (u) {
@@ -341,24 +365,24 @@ function P(o, s) {
341
365
  for (let t of d) {
342
366
  if (t === l) return;
343
367
  if (J(t)) {
344
- D?.(t.value, e);
368
+ w?.(t.value, e);
345
369
  return;
346
370
  }
347
371
  }
348
372
  }
349
373
  }), Z = r((e) => X(e, !1)), Q = r((e) => {
350
- b && e.key === " " && re() && X(e, !0);
374
+ y && e.key === " " && re() && X(e, !0);
351
375
  }), $ = r((e) => {
352
- let t = P.container ?? e.currentTarget;
353
- if (!j(t, e.target)) return;
354
- let n = M(P.resolve(t), e.target, t);
355
- n && (P.recordFocus(n), L(n.value), C(n) && z(n.value), P.stamp());
376
+ let t = D.container ?? e.currentTarget;
377
+ if (!P(t, e.target)) return;
378
+ let n = F(D.resolve(t), e.target, t);
379
+ n && (D.recordFocus(n), L(n.value), E(n) && z(n.value), D.stamp());
356
380
  }), ie = r((e) => {
357
- J(P.resolve().find((t) => t.value === e));
381
+ J(D.resolve().find((t) => t.value === e));
358
382
  }), ae = r(() => {
359
- Y(P.resolve().filter((e) => !e.disabled));
383
+ Y(D.resolve().filter((e) => !e.disabled));
360
384
  }), oe = r(() => {
361
- Y(P.resolve().filter((e) => !e.disabled).reverse());
385
+ Y(D.resolve().filter((e) => !e.disabled).reverse());
362
386
  });
363
387
  return {
364
388
  containerProps: u.useMemo(() => ({
@@ -377,13 +401,13 @@ function P(o, s) {
377
401
  handleKeyDownCapture: Q,
378
402
  handleFocus: $,
379
403
  getTabIndex: W,
380
- focusedValue: I,
404
+ focusedValue: A,
381
405
  focusValue: ie,
382
406
  focusFirst: ae,
383
407
  focusLast: oe
384
408
  };
385
409
  }
386
410
  //#endregion
387
- export { w as isHiddenByCss, P as useRovingTabIndex };
411
+ export { D as isHiddenByCss, L as useRovingTabIndex };
388
412
 
389
413
  //# sourceMappingURL=useRovingTabIndex.mjs.map