@bioturing/components 0.39.1 → 0.40.1

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 (128) hide show
  1. package/dist/base.d.ts +35 -1
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +47 -1
  4. package/dist/base.js.map +1 -1
  5. package/dist/components/base-menu/component.d.ts +1 -1
  6. package/dist/components/base-menu/index.d.ts +1 -1
  7. package/dist/components/base-menu/index.d.ts.map +1 -1
  8. package/dist/components/base-menu/item.d.ts +1 -1
  9. package/dist/components/base-menu/item.d.ts.map +1 -1
  10. package/dist/components/base-menu/item.js +1 -1
  11. package/dist/components/base-menu/item.js.map +1 -1
  12. package/dist/components/button/component.d.ts +1 -1
  13. package/dist/components/button/component.d.ts.map +1 -1
  14. package/dist/components/button/component.js +18 -17
  15. package/dist/components/button/component.js.map +1 -1
  16. package/dist/components/checkbox/component.d.ts.map +1 -1
  17. package/dist/components/choice-list/component.d.ts +8 -4
  18. package/dist/components/choice-list/component.d.ts.map +1 -1
  19. package/dist/components/choice-list/component.js +89 -94
  20. package/dist/components/choice-list/component.js.map +1 -1
  21. package/dist/components/color-select/component.js +6 -6
  22. package/dist/components/combobox/component.js +1 -1
  23. package/dist/components/combobox/component.js.map +1 -1
  24. package/dist/components/command-palette/component.d.ts +6 -0
  25. package/dist/components/command-palette/component.d.ts.map +1 -1
  26. package/dist/components/command-palette/component.js +182 -63
  27. package/dist/components/command-palette/component.js.map +1 -1
  28. package/dist/components/command-palette/index.d.ts +3 -1
  29. package/dist/components/command-palette/index.d.ts.map +1 -1
  30. package/dist/components/command-palette/style.css +1 -1
  31. package/dist/components/drag-drop/draggable.js +1 -1
  32. package/dist/components/drag-drop/draggable.js.map +1 -1
  33. package/dist/components/drag-drop/droppable.js +1 -1
  34. package/dist/components/drag-drop/droppable.js.map +1 -1
  35. package/dist/components/drag-drop/types.d.ts +1 -1
  36. package/dist/components/drag-drop/types.d.ts.map +1 -1
  37. package/dist/components/drag-drop/value.js +13 -13
  38. package/dist/components/dropdown-menu/component.d.ts +1 -1
  39. package/dist/components/dropdown-menu/component.d.ts.map +1 -1
  40. package/dist/components/dropdown-menu/component.js +162 -135
  41. package/dist/components/dropdown-menu/component.js.map +1 -1
  42. package/dist/components/dropdown-menu/divider.js +2 -2
  43. package/dist/components/dropdown-menu/divider.js.map +1 -1
  44. package/dist/components/dropdown-menu/item.js +2 -2
  45. package/dist/components/dropdown-menu/item.js.map +1 -1
  46. package/dist/components/dropdown-menu/style.css +1 -1
  47. package/dist/components/dropdown-menu/useDropdownMenu.js +1 -1
  48. package/dist/components/dropdown-menu/useDropdownMenu.js.map +1 -1
  49. package/dist/components/hooks/antd.d.ts.map +1 -1
  50. package/dist/components/hooks/index.d.ts +1 -0
  51. package/dist/components/hooks/index.d.ts.map +1 -1
  52. package/dist/components/hooks/useBaseUIPlacement.d.ts +64 -0
  53. package/dist/components/hooks/useBaseUIPlacement.d.ts.map +1 -0
  54. package/dist/components/hooks/useBaseUIPlacement.js +61 -0
  55. package/dist/components/hooks/useBaseUIPlacement.js.map +1 -0
  56. package/dist/components/hooks/useControlledState.d.ts +1 -0
  57. package/dist/components/hooks/useControlledState.d.ts.map +1 -1
  58. package/dist/components/hooks/useControlledState.js +16 -16
  59. package/dist/components/hooks/useControlledState.js.map +1 -1
  60. package/dist/components/hooks/useTransitionStatus.js +2 -2
  61. package/dist/components/hooks/useTransitionStatus.js.map +1 -1
  62. package/dist/components/icon-button/style.css +1 -1
  63. package/dist/components/nav/index.d.ts.map +1 -1
  64. package/dist/components/nav/item.d.ts +1 -1
  65. package/dist/components/nav/item.d.ts.map +1 -1
  66. package/dist/components/nav/item.js +1 -1
  67. package/dist/components/nav/item.js.map +1 -1
  68. package/dist/components/popup-panel/component.d.ts +4 -4
  69. package/dist/components/popup-panel/component.d.ts.map +1 -1
  70. package/dist/components/popup-panel/component.js +142 -152
  71. package/dist/components/popup-panel/component.js.map +1 -1
  72. package/dist/components/resizable/component.js +1 -1
  73. package/dist/components/resizable/component.js.map +1 -1
  74. package/dist/components/scroll-area/component.d.ts +1 -1
  75. package/dist/components/scroll-area/component.d.ts.map +1 -1
  76. package/dist/components/scroll-area/component.js +1 -1
  77. package/dist/components/scroll-area/component.js.map +1 -1
  78. package/dist/components/select/component.d.ts.map +1 -1
  79. package/dist/components/select/component.js +153 -138
  80. package/dist/components/select/component.js.map +1 -1
  81. package/dist/components/select/item.js +13 -13
  82. package/dist/components/select-trigger/component.js +19 -19
  83. package/dist/components/splitter/splitter.d.ts.map +1 -1
  84. package/dist/components/splitter/splitter.js +53 -51
  85. package/dist/components/splitter/splitter.js.map +1 -1
  86. package/dist/components/stack/StackChild.js +2 -2
  87. package/dist/components/stack/StackChild.js.map +1 -1
  88. package/dist/components/toast/component.d.ts +1 -1
  89. package/dist/components/toast/component.d.ts.map +1 -1
  90. package/dist/components/toast/component.js +1 -1
  91. package/dist/components/toast/component.js.map +1 -1
  92. package/dist/components/toast/function.d.ts +2 -2
  93. package/dist/components/toast/function.d.ts.map +1 -1
  94. package/dist/components/toast/function.js +1 -1
  95. package/dist/components/toast/function.js.map +1 -1
  96. package/dist/components/transition/component.d.ts +1 -1
  97. package/dist/components/transition/component.d.ts.map +1 -1
  98. package/dist/components/transition/component.js +2 -2
  99. package/dist/components/transition/component.js.map +1 -1
  100. package/dist/components/tree/useTreeCommon.d.ts.map +1 -1
  101. package/dist/components/utils/WithRenderProp.d.ts +1 -1
  102. package/dist/components/utils/WithRenderProp.d.ts.map +1 -1
  103. package/dist/components/utils/WithRenderProp.js +1 -1
  104. package/dist/components/utils/WithRenderProp.js.map +1 -1
  105. package/dist/components/utils/index.d.ts +1 -0
  106. package/dist/components/utils/index.d.ts.map +1 -1
  107. package/dist/components/utils/renderProp.d.ts +24 -0
  108. package/dist/components/utils/renderProp.d.ts.map +1 -0
  109. package/dist/components/utils/renderProp.js +19 -0
  110. package/dist/components/utils/renderProp.js.map +1 -0
  111. package/dist/components/vertical-collapsible-panel/component.js +1 -1
  112. package/dist/components/vertical-collapsible-panel/component.js.map +1 -1
  113. package/dist/index.js +162 -158
  114. package/dist/index.js.map +1 -1
  115. package/dist/metadata.d.ts.map +1 -1
  116. package/dist/metadata.js +14 -14
  117. package/dist/metadata.js.map +1 -1
  118. package/dist/stats.html +1 -1
  119. package/dist/tailwind.css +125 -1
  120. package/package.json +3 -3
  121. package/dist/components/cmdk/command-score.d.ts +0 -2
  122. package/dist/components/cmdk/command-score.d.ts.map +0 -1
  123. package/dist/components/cmdk/command-score.js +0 -48
  124. package/dist/components/cmdk/command-score.js.map +0 -1
  125. package/dist/components/cmdk/index.d.ts +0 -440
  126. package/dist/components/cmdk/index.d.ts.map +0 -1
  127. package/dist/components/cmdk/index.js +0 -595
  128. package/dist/components/cmdk/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/cmdk/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpE,KAAK,QAAQ,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC;AAC/C,KAAK,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAuE3C,KAAK,aAAa,GAAG,CACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,EAAE,KAChB,MAAM,CAAC;AACZ,MAAM,MAAM,YAAY,GAAG,QAAQ,GACjC,QAAQ,GAAG;IACT;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,aAAa,C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AAW,EAAE,CAAC;AAC/B,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,CAAC;AAC/B,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,CAAC;AACjC,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,CAAC;AACzC,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,CAAC;AACnC,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,CAAC;AAmDrC,8CAA8C;AAC9C,iBAAS,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,CAI1D"}
@@ -1,595 +0,0 @@
1
- "use client";
2
- import { jsxs as Z, jsx as g } from "react/jsx-runtime";
3
- import s, { useId as M } from "react";
4
- import { Dialog as F } from "@base-ui-components/react";
5
- import { commandScore as pe } from "./command-score.js";
6
- import O from "merge-refs";
7
- import { WithRenderProp as y } from "../utils/WithRenderProp.js";
8
- const T = '[cmdk-group=""]', X = '[cmdk-group-items=""]', be = '[cmdk-group-heading=""]', le = '[cmdk-item=""]', ie = `${le}:not([aria-disabled="true"])`, Y = "cmdk-item-select", _ = "data-value", Se = (t, n, r) => pe(t, n, r), ue = s.createContext(void 0), B = () => s.useContext(ue), ae = s.createContext(void 0), ee = () => s.useContext(ae), de = s.createContext(void 0), fe = s.forwardRef(
9
- (t, n) => {
10
- const r = L(() => ({
11
- /** Value of the search query. */
12
- search: "",
13
- /** Currently selected item value. */
14
- value: t.value ?? t.defaultValue ?? "",
15
- /** Currently selected item id. */
16
- selectedItemId: void 0,
17
- filtered: {
18
- /** The count of all visible items. */
19
- count: 0,
20
- /** Map from visible item id to its search score. */
21
- items: /* @__PURE__ */ new Map(),
22
- /** Set of groups with at least one visible item. */
23
- groups: /* @__PURE__ */ new Set()
24
- }
25
- })), u = L(() => /* @__PURE__ */ new Set()), i = L(() => /* @__PURE__ */ new Map()), a = L(
26
- () => /* @__PURE__ */ new Map()
27
- ), d = L(() => /* @__PURE__ */ new Set()), m = me(t), {
28
- label: f,
29
- children: h,
30
- value: b,
31
- onValueChange: I,
32
- filter: C,
33
- shouldFilter: E,
34
- loop: P,
35
- disablePointerSelection: ve = !1,
36
- vimBindings: K = !0,
37
- ...N
38
- } = t, $ = M(), j = M(), p = M(), D = s.useRef(null), R = Le();
39
- k(() => {
40
- if (b !== void 0) {
41
- const e = b.trim();
42
- r.current.value = e, S.emit();
43
- }
44
- }, [b]), k(() => {
45
- R(6, re);
46
- }, []);
47
- const S = s.useMemo(() => ({
48
- subscribe: (e) => (d.current.add(e), () => d.current.delete(e)),
49
- snapshot: () => r.current,
50
- setState: (e, l, o) => {
51
- if (!Object.is(r.current[e], l)) {
52
- if (r.current[e] = l, e === "search")
53
- H(), U(), R(1, z);
54
- else if (e === "value") {
55
- if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
56
- const c = document.getElementById(p);
57
- c ? c.focus() : document.getElementById($)?.focus();
58
- }
59
- if (R(7, () => {
60
- r.current.selectedItemId = A()?.id, S.emit();
61
- }), o || R(5, re), m.current?.value !== void 0) {
62
- const c = l ?? "";
63
- m.current.onValueChange?.(c);
64
- return;
65
- }
66
- }
67
- S.emit();
68
- }
69
- },
70
- emit: () => {
71
- d.current.forEach((e) => e());
72
- }
73
- }), []), q = s.useMemo(
74
- () => ({
75
- // Keep id → {value, keywords} mapping up-to-date
76
- value: (e, l, o) => {
77
- l !== a.current.get(e)?.value && (a.current.set(e, { value: l, keywords: o }), r.current.filtered.items.set(e, te(l, o)), R(2, () => {
78
- U(), S.emit();
79
- }));
80
- },
81
- // Track item lifecycle (mount, unmount)
82
- item: (e, l) => (u.current.add(e), l && (i.current.has(l) ? i.current.get(l).add(e) : i.current.set(l, /* @__PURE__ */ new Set([e]))), R(3, () => {
83
- H(), U(), r.current.value || z(), S.emit();
84
- }), () => {
85
- a.current.delete(e), u.current.delete(e), r.current.filtered.items.delete(e);
86
- const o = A();
87
- R(4, () => {
88
- H(), o?.getAttribute("id") === e && z(), S.emit();
89
- });
90
- }),
91
- // Track group lifecycle (mount, unmount)
92
- group: (e) => (i.current.has(e) || i.current.set(e, /* @__PURE__ */ new Set()), () => {
93
- a.current.delete(e), i.current.delete(e);
94
- }),
95
- filter: () => m.current.shouldFilter,
96
- label: f || t["aria-label"],
97
- getDisablePointerSelection: () => m.current.disablePointerSelection,
98
- listId: $,
99
- inputId: p,
100
- labelId: j,
101
- listInnerRef: D
102
- }),
103
- []
104
- );
105
- function te(e, l) {
106
- const o = m.current?.filter ?? Se;
107
- return e ? o(e, r.current.search, l) : 0;
108
- }
109
- function U() {
110
- if (!r.current.search || // Explicitly false, because true | undefined is the default
111
- m.current.shouldFilter === !1)
112
- return;
113
- const e = r.current.filtered.items, l = [];
114
- r.current.filtered.groups.forEach((c) => {
115
- const v = i.current.get(c);
116
- let x = 0;
117
- v.forEach((Q) => {
118
- const ge = e.get(Q);
119
- x = Math.max(ge, x);
120
- }), l.push([c, x]);
121
- });
122
- const o = D.current;
123
- V().sort((c, v) => {
124
- const x = c.getAttribute("id"), Q = v.getAttribute("id");
125
- return (e.get(Q) ?? 0) - (e.get(x) ?? 0);
126
- }).forEach((c) => {
127
- const v = c.closest(X);
128
- v ? v.appendChild(
129
- c.parentElement === v ? c : c.closest(`${X} > *`)
130
- ) : o.appendChild(
131
- c.parentElement === o ? c : c.closest(`${X} > *`)
132
- );
133
- }), l.sort((c, v) => v[1] - c[1]).forEach((c) => {
134
- const v = D.current?.querySelector(
135
- `${T}[${_}="${encodeURIComponent(c[0])}"]`
136
- );
137
- v?.parentElement.appendChild(v);
138
- });
139
- }
140
- function z() {
141
- const l = V().find(
142
- (o) => o.getAttribute("aria-disabled") !== "true"
143
- )?.getAttribute(_);
144
- S.setState("value", l || void 0);
145
- }
146
- function H() {
147
- if (!r.current.search || // Explicitly false, because true | undefined is the default
148
- m.current.shouldFilter === !1) {
149
- r.current.filtered.count = u.current.size;
150
- return;
151
- }
152
- r.current.filtered.groups = /* @__PURE__ */ new Set();
153
- let e = 0;
154
- for (const l of u.current) {
155
- const o = a.current.get(l)?.value ?? "", c = a.current.get(l)?.keywords ?? [], v = te(o, c);
156
- r.current.filtered.items.set(l, v), v > 0 && e++;
157
- }
158
- for (const [l, o] of i.current)
159
- for (const c of o)
160
- if (r.current.filtered.items.get(c) > 0) {
161
- r.current.filtered.groups.add(l);
162
- break;
163
- }
164
- r.current.filtered.count = e;
165
- }
166
- function re() {
167
- const e = A();
168
- e && (e.parentElement?.firstChild === e && e.closest(T)?.querySelector(be)?.scrollIntoView({ block: "nearest" }), e.scrollIntoView({ block: "nearest" }));
169
- }
170
- function A() {
171
- return D.current?.querySelector(
172
- `${le}[aria-selected="true"]`
173
- );
174
- }
175
- function V() {
176
- return Array.from(
177
- D.current?.querySelectorAll(ie) || []
178
- );
179
- }
180
- function W(e) {
181
- const o = V()[e];
182
- o && S.setState("value", o.getAttribute(_));
183
- }
184
- function J(e) {
185
- const l = A(), o = V(), c = o.findIndex((x) => x === l);
186
- let v = o[c + e];
187
- m.current?.loop && (v = c + e < 0 ? o[o.length - 1] : c + e === o.length ? o[0] : o[c + e]), v && S.setState("value", v.getAttribute(_));
188
- }
189
- function ne(e) {
190
- let o = A()?.closest(T), c;
191
- for (; o && !c; )
192
- o = e > 0 ? Ae(o, T) : _e(o, T), c = o?.querySelector(ie);
193
- c ? S.setState("value", c.getAttribute(_)) : J(e);
194
- }
195
- const oe = () => W(V().length - 1), ce = (e) => {
196
- e.preventDefault(), e.metaKey ? oe() : e.altKey ? ne(1) : J(1);
197
- }, se = (e) => {
198
- e.preventDefault(), e.metaKey ? W(0) : e.altKey ? ne(-1) : J(-1);
199
- };
200
- return /* @__PURE__ */ Z(
201
- y,
202
- {
203
- ref: n,
204
- tabIndex: -1,
205
- ...N,
206
- "cmdk-root": "",
207
- onKeyDown: (e) => {
208
- N.onKeyDown?.(e);
209
- const l = e.nativeEvent.isComposing || e.keyCode === 229;
210
- if (!(e.defaultPrevented || l))
211
- switch (e.key) {
212
- case "n":
213
- case "j": {
214
- K && e.ctrlKey && ce(e);
215
- break;
216
- }
217
- case "ArrowDown": {
218
- ce(e);
219
- break;
220
- }
221
- case "p":
222
- case "k": {
223
- K && e.ctrlKey && se(e);
224
- break;
225
- }
226
- case "ArrowUp": {
227
- se(e);
228
- break;
229
- }
230
- case "Home": {
231
- e.preventDefault(), W(0);
232
- break;
233
- }
234
- case "End": {
235
- e.preventDefault(), oe();
236
- break;
237
- }
238
- case "Enter": {
239
- e.preventDefault();
240
- const o = A();
241
- if (o) {
242
- const c = new Event(Y);
243
- o.dispatchEvent(c);
244
- }
245
- }
246
- }
247
- },
248
- children: [
249
- /* @__PURE__ */ g(
250
- "label",
251
- {
252
- "cmdk-label": "",
253
- htmlFor: q.inputId,
254
- id: q.labelId,
255
- style: Pe,
256
- children: f
257
- }
258
- ),
259
- G(t, (e) => /* @__PURE__ */ g(ae.Provider, { value: S, children: /* @__PURE__ */ g(ue.Provider, { value: q, children: e }) }))
260
- ]
261
- }
262
- );
263
- }
264
- ), Ee = s.forwardRef(
265
- (t, n) => {
266
- const r = M(), u = s.useRef(null), i = s.useContext(de), a = B(), d = me(t), m = d.current?.forceMount ?? i?.forceMount;
267
- k(() => {
268
- if (!m)
269
- return a.item(r, i?.id);
270
- }, [m]);
271
- const f = he(
272
- r,
273
- u,
274
- [t.value, t.children, u],
275
- t.keywords
276
- ), h = ee(), b = w(
277
- (p) => p.value && p.value === f.current
278
- ), I = w(
279
- (p) => m || a.filter() === !1 ? !0 : p.search ? p.filtered.items.get(r) > 0 : !0
280
- );
281
- s.useEffect(() => {
282
- const p = u.current;
283
- if (!(!p || t.disabled))
284
- return p.addEventListener(Y, C), () => p.removeEventListener(Y, C);
285
- }, [I, t.onSelect, t.disabled]);
286
- function C() {
287
- E(), d.current.onSelect?.(f.current);
288
- }
289
- function E() {
290
- h.setState("value", f.current, !0);
291
- }
292
- if (!I) return null;
293
- const {
294
- disabled: P,
295
- value: ve,
296
- onSelect: K,
297
- forceMount: N,
298
- keywords: $,
299
- ...j
300
- } = t;
301
- return /* @__PURE__ */ g(
302
- y,
303
- {
304
- ref: O(u, n),
305
- ...j,
306
- id: r,
307
- "cmdk-item": "",
308
- role: "option",
309
- "aria-disabled": !!P,
310
- "aria-selected": !!b,
311
- "data-disabled": !!P,
312
- "data-selected": !!b,
313
- onPointerMove: P || a.getDisablePointerSelection() ? void 0 : E,
314
- onClick: P ? void 0 : C,
315
- children: t.children
316
- }
317
- );
318
- }
319
- ), Ce = s.forwardRef(
320
- (t, n) => {
321
- const { heading: r, children: u, forceMount: i, ...a } = t, d = M(), m = s.useRef(null), f = s.useRef(null), h = M(), b = B(), I = w(
322
- (E) => i || b.filter() === !1 ? !0 : E.search ? E.filtered.groups.has(d) : !0
323
- );
324
- k(() => b.group(d), []), he(d, m, [t.value, t.heading, f]);
325
- const C = s.useMemo(
326
- () => ({ id: d, forceMount: i }),
327
- [i]
328
- );
329
- return /* @__PURE__ */ Z(
330
- y,
331
- {
332
- ref: O(m, n),
333
- ...a,
334
- "cmdk-group": "",
335
- role: "presentation",
336
- hidden: I ? void 0 : !0,
337
- children: [
338
- r && /* @__PURE__ */ g(
339
- "div",
340
- {
341
- ref: f,
342
- "cmdk-group-heading": "",
343
- "aria-hidden": !0,
344
- id: h,
345
- children: r
346
- }
347
- ),
348
- G(t, (E) => /* @__PURE__ */ g(
349
- "div",
350
- {
351
- "cmdk-group-items": "",
352
- role: "group",
353
- "aria-labelledby": r ? h : void 0,
354
- children: /* @__PURE__ */ g(de.Provider, { value: C, children: E })
355
- }
356
- ))
357
- ]
358
- }
359
- );
360
- }
361
- ), Ie = s.forwardRef(
362
- (t, n) => {
363
- const { alwaysRender: r, ...u } = t, i = s.useRef(null), a = w((d) => !d.search);
364
- return !r && !a ? null : /* @__PURE__ */ g(
365
- y,
366
- {
367
- ref: O(i, n),
368
- ...u,
369
- "cmdk-separator": "",
370
- role: "separator"
371
- }
372
- );
373
- }
374
- ), we = s.forwardRef(
375
- (t, n) => {
376
- const { onValueChange: r, ...u } = t, i = t.value != null, a = ee(), d = w((h) => h.search), m = w((h) => h.selectedItemId), f = B();
377
- return s.useEffect(() => {
378
- t.value != null && a.setState("search", t.value);
379
- }, [t.value]), /* @__PURE__ */ g(
380
- y,
381
- {
382
- as: "input",
383
- ref: n,
384
- ...u,
385
- "cmdk-input": "",
386
- autoComplete: "off",
387
- autoCorrect: "off",
388
- spellCheck: !1,
389
- "aria-autocomplete": "list",
390
- role: "combobox",
391
- "aria-expanded": !0,
392
- "aria-controls": f.listId,
393
- "aria-labelledby": f.labelId,
394
- "aria-activedescendant": m,
395
- id: f.inputId,
396
- type: "text",
397
- value: i ? t.value : d,
398
- onChange: (h) => {
399
- i || a.setState("search", h.target.value), r?.(h.target.value);
400
- }
401
- }
402
- );
403
- }
404
- ), ye = s.forwardRef(
405
- (t, n) => {
406
- const { children: r, label: u = "Suggestions", ...i } = t, a = s.useRef(null), d = s.useRef(null), m = w((h) => h.selectedItemId), f = B();
407
- return s.useEffect(() => {
408
- if (d.current && a.current) {
409
- const h = d.current, b = a.current;
410
- let I;
411
- const C = new ResizeObserver(() => {
412
- I = requestAnimationFrame(() => {
413
- const E = h.offsetHeight;
414
- b.style.setProperty(
415
- "--cmdk-list-height",
416
- E.toFixed(1) + "px"
417
- );
418
- });
419
- });
420
- return C.observe(h), () => {
421
- cancelAnimationFrame(I), C.unobserve(h);
422
- };
423
- }
424
- }, []), /* @__PURE__ */ g(
425
- y,
426
- {
427
- ref: O(a, n),
428
- ...i,
429
- "cmdk-list": "",
430
- role: "listbox",
431
- tabIndex: -1,
432
- "aria-activedescendant": m,
433
- "aria-label": u,
434
- id: f.listId,
435
- children: G(t, (h) => /* @__PURE__ */ g(
436
- "div",
437
- {
438
- ref: O(d, f.listInnerRef),
439
- "cmdk-list-sizer": "",
440
- children: h
441
- }
442
- ))
443
- }
444
- );
445
- }
446
- ), Re = s.forwardRef(
447
- (t, n) => {
448
- const {
449
- open: r,
450
- onOpenChange: u,
451
- overlayClassName: i,
452
- contentClassName: a,
453
- container: d,
454
- ...m
455
- } = t;
456
- return /* @__PURE__ */ g(F.Root, { open: r, onOpenChange: u, children: /* @__PURE__ */ Z(F.Portal, { container: d, children: [
457
- /* @__PURE__ */ g(F.Backdrop, { "cmdk-overlay": "", className: i }),
458
- /* @__PURE__ */ g(
459
- F.Popup,
460
- {
461
- "aria-label": t.label,
462
- "cmdk-dialog": "",
463
- className: a,
464
- children: /* @__PURE__ */ g(fe, { ref: n, ...m })
465
- }
466
- )
467
- ] }) });
468
- }
469
- ), xe = s.forwardRef(
470
- (t, n) => w((u) => u.filtered.count === 0) ? /* @__PURE__ */ g(
471
- y,
472
- {
473
- ref: n,
474
- ...t,
475
- "cmdk-empty": "",
476
- role: "presentation"
477
- }
478
- ) : null
479
- ), ke = s.forwardRef(
480
- (t, n) => {
481
- const { progress: r, children: u, label: i = "Loading...", ...a } = t;
482
- return /* @__PURE__ */ g(
483
- y,
484
- {
485
- ref: n,
486
- ...a,
487
- "cmdk-loading": "",
488
- role: "progressbar",
489
- "aria-valuenow": r,
490
- "aria-valuemin": 0,
491
- "aria-valuemax": 100,
492
- "aria-label": i,
493
- children: G(t, (d) => /* @__PURE__ */ g("div", { "aria-hidden": !0, children: d }))
494
- }
495
- );
496
- }
497
- ), Ge = Object.assign(fe, {
498
- List: ye,
499
- Item: Ee,
500
- Input: we,
501
- Group: Ce,
502
- Separator: Ie,
503
- Dialog: Re,
504
- Empty: xe,
505
- Loading: ke
506
- });
507
- function Ae(t, n) {
508
- let r = t.nextElementSibling;
509
- for (; r; ) {
510
- if (r.matches(n)) return r;
511
- r = r.nextElementSibling;
512
- }
513
- }
514
- function _e(t, n) {
515
- let r = t.previousElementSibling;
516
- for (; r; ) {
517
- if (r.matches(n)) return r;
518
- r = r.previousElementSibling;
519
- }
520
- }
521
- function me(t) {
522
- const n = s.useRef(t);
523
- return k(() => {
524
- n.current = t;
525
- }), n;
526
- }
527
- const k = typeof window > "u" ? s.useEffect : s.useLayoutEffect;
528
- function L(t) {
529
- const n = s.useRef(void 0);
530
- return n.current === void 0 && (n.current = t()), n;
531
- }
532
- function w(t) {
533
- const n = ee(), r = () => t(n.snapshot());
534
- return s.useSyncExternalStore(n.subscribe, r, r);
535
- }
536
- function he(t, n, r, u = []) {
537
- const i = s.useRef(void 0), a = B();
538
- return k(() => {
539
- const d = (() => {
540
- for (const f of r) {
541
- if (typeof f == "string")
542
- return f.trim();
543
- if (typeof f == "object" && "current" in f)
544
- return f.current ? f.current.textContent?.trim() : i.current;
545
- }
546
- })(), m = u.map((f) => f.trim());
547
- a.value(t, d, m), n.current?.setAttribute(_, d), i.current = d;
548
- }), i;
549
- }
550
- const Le = () => {
551
- const [t, n] = s.useState(), r = L(() => /* @__PURE__ */ new Map());
552
- return k(() => {
553
- r.current.forEach((u) => u()), r.current = /* @__PURE__ */ new Map();
554
- }, [t]), (u, i) => {
555
- r.current.set(u, i), n({});
556
- };
557
- };
558
- function Me(t) {
559
- const n = t.type;
560
- return typeof n == "function" ? n(t.props) : "render" in n ? n.render(t.props) : t;
561
- }
562
- function G({ asChild: t, children: n }, r) {
563
- return t && s.isValidElement(n) ? s.cloneElement(
564
- Me(n),
565
- { ref: n.ref },
566
- // @ts-expect-error expect error here
567
- r(n.props.children)
568
- ) : r(n);
569
- }
570
- const Pe = {
571
- position: "absolute",
572
- width: "1px",
573
- height: "1px",
574
- padding: "0",
575
- margin: "-1px",
576
- overflow: "hidden",
577
- clip: "rect(0, 0, 0, 0)",
578
- whiteSpace: "nowrap",
579
- borderWidth: "0"
580
- };
581
- export {
582
- Ge as Command,
583
- Re as CommandDialog,
584
- xe as CommandEmpty,
585
- Ce as CommandGroup,
586
- we as CommandInput,
587
- Ee as CommandItem,
588
- ye as CommandList,
589
- ke as CommandLoading,
590
- fe as CommandRoot,
591
- Ie as CommandSeparator,
592
- Se as defaultFilter,
593
- w as useCommandState
594
- };
595
- //# sourceMappingURL=index.js.map