@cascivo/react 0.17.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/action-sheet/action-sheet.js +1 -1
- package/dist/breadcrumb/breadcrumb.js +7 -7
- package/dist/checkbox/checkbox.js +11 -10
- package/dist/color-picker/color-picker.js +81 -77
- package/dist/combobox/combobox.js +81 -76
- package/dist/command-menu/command-menu.js +104 -104
- package/dist/comparison/comparison.js +18 -18
- package/dist/data-table/data-table.css +1 -1
- package/dist/data-table/data-table.js +148 -121
- package/dist/data-table/data-table.module.js +29 -29
- package/dist/date-picker/date-picker.js +98 -93
- package/dist/date-range-picker/date-range-picker.js +1 -1
- package/dist/dock/dock.js +2 -2
- package/dist/dropdown/dropdown.js +43 -40
- package/dist/editable/editable.js +29 -20
- package/dist/fab/fab.js +37 -37
- package/dist/field/field.js +24 -17
- package/dist/file-uploader/file-uploader.js +24 -23
- package/dist/filter/filter.js +11 -11
- package/dist/index.d.ts +1302 -85
- package/dist/input/input.js +14 -13
- package/dist/navigation-menu/navigation-menu.js +9 -9
- package/dist/node/action-sheet/action-sheet.js +1 -1
- package/dist/node/breadcrumb/breadcrumb.js +7 -7
- package/dist/node/checkbox/checkbox.js +11 -10
- package/dist/node/color-picker/color-picker.js +81 -77
- package/dist/node/combobox/combobox.js +81 -76
- package/dist/node/command-menu/command-menu.js +104 -104
- package/dist/node/comparison/comparison.js +18 -18
- package/dist/node/data-table/data-table.js +148 -121
- package/dist/node/data-table/data-table.module.js +29 -29
- package/dist/node/date-picker/date-picker.js +98 -93
- package/dist/node/date-range-picker/date-range-picker.js +1 -1
- package/dist/node/dock/dock.js +2 -2
- package/dist/node/dropdown/dropdown.js +43 -40
- package/dist/node/editable/editable.js +29 -20
- package/dist/node/fab/fab.js +37 -37
- package/dist/node/field/field.js +24 -17
- package/dist/node/file-uploader/file-uploader.js +24 -23
- package/dist/node/filter/filter.js +11 -11
- package/dist/node/input/input.js +14 -13
- package/dist/node/navigation-menu/navigation-menu.js +9 -9
- package/dist/node/number-input/number-input.js +28 -27
- package/dist/node/overflow-menu/overflow-menu.js +7 -7
- package/dist/node/progress/progress.js +3 -3
- package/dist/node/progress-circle/progress-circle.js +8 -8
- package/dist/node/progress-indicator/progress-indicator.js +1 -1
- package/dist/node/qr-code/qr-code.js +11 -11
- package/dist/node/radial-progress/radial-progress.js +9 -9
- package/dist/node/radio/radio.js +10 -9
- package/dist/node/react/src/index.js +93 -93
- package/dist/node/resizable/resizable.js +24 -24
- package/dist/node/search/search.js +35 -31
- package/dist/node/select/select.js +15 -14
- package/dist/node/side-nav/side-nav.js +35 -35
- package/dist/node/side-nav/side-nav.module.js +27 -27
- package/dist/node/slider/slider.js +13 -12
- package/dist/node/spinner/spinner.js +4 -4
- package/dist/node/steps/steps.js +10 -10
- package/dist/node/structured-list/structured-list.js +14 -14
- package/dist/node/swap/swap.js +5 -5
- package/dist/node/switcher/switcher.js +5 -5
- package/dist/node/tags-input/tags-input.js +20 -16
- package/dist/node/textarea/textarea.js +14 -13
- package/dist/node/time-picker/time-picker.js +21 -20
- package/dist/node/toggle/toggle.js +8 -7
- package/dist/node/tree-view/tree-view.js +43 -43
- package/dist/node/virtual-list/virtual-list.js +10 -10
- package/dist/node/wheel-picker/wheel-picker.js +36 -36
- package/dist/number-input/number-input.js +28 -27
- package/dist/overflow-menu/overflow-menu.js +7 -7
- package/dist/progress/progress.js +3 -3
- package/dist/progress-circle/progress-circle.js +8 -8
- package/dist/progress-indicator/progress-indicator.js +1 -1
- package/dist/qr-code/qr-code.js +11 -11
- package/dist/radial-progress/radial-progress.js +9 -9
- package/dist/radio/radio.js +10 -9
- package/dist/react/src/index.js +93 -93
- package/dist/resizable/resizable.js +24 -24
- package/dist/search/search.js +35 -31
- package/dist/select/select.js +15 -14
- package/dist/side-nav/side-nav.css +1 -1
- package/dist/side-nav/side-nav.js +35 -35
- package/dist/side-nav/side-nav.module.js +27 -27
- package/dist/slider/slider.js +13 -12
- package/dist/spinner/spinner.js +4 -4
- package/dist/steps/steps.js +10 -10
- package/dist/structured-list/structured-list.js +14 -14
- package/dist/styles.css +2 -2
- package/dist/swap/swap.js +5 -5
- package/dist/switcher/switcher.js +5 -5
- package/dist/tags-input/tags-input.js +20 -16
- package/dist/textarea/textarea.js +14 -13
- package/dist/time-picker/time-picker.js +21 -20
- package/dist/toggle/toggle.js +8 -7
- package/dist/tree-view/tree-view.js +43 -43
- package/dist/virtual-list/virtual-list.js +10 -10
- package/dist/wheel-picker/wheel-picker.js +36 -36
- package/package.json +4 -4
- package/readme.body.md +4 -3
|
@@ -4,11 +4,11 @@ import { Spinner as e } from "../spinner/spinner.js";
|
|
|
4
4
|
import { Kbd as t } from "../kbd/kbd.js";
|
|
5
5
|
import n from "./command-menu.module.js";
|
|
6
6
|
import { useId as r, useRef as i } from "react";
|
|
7
|
-
import { batch as a, cn as o, focusElement as s, useEffectPropSignal as c, useSignal as l, useSignalEffect as u, useSignals as
|
|
8
|
-
import { builtin as
|
|
9
|
-
import { jsx as
|
|
7
|
+
import { batch as a, cn as o, focusElement as s, useEffectPropSignal as c, useSignal as l, useSignalEffect as u, useSignals as d } from "@cascivo/core";
|
|
8
|
+
import { builtin as f, t as p } from "@cascivo/i18n";
|
|
9
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
10
|
//#region ../components/src/command-menu/command-menu.tsx
|
|
11
|
-
function
|
|
11
|
+
function g(e, t) {
|
|
12
12
|
if (e.length === 0) return {
|
|
13
13
|
score: 1,
|
|
14
14
|
indices: []
|
|
@@ -25,21 +25,21 @@ function h(e, t) {
|
|
|
25
25
|
indices: s
|
|
26
26
|
} : null;
|
|
27
27
|
}
|
|
28
|
-
function g(e, t) {
|
|
29
|
-
return h(e, t)?.score ?? 0;
|
|
30
|
-
}
|
|
31
28
|
function _(e, t) {
|
|
32
|
-
|
|
29
|
+
return g(e, t)?.score ?? 0;
|
|
30
|
+
}
|
|
31
|
+
function v(e, t) {
|
|
32
|
+
let n = _(e, t.label);
|
|
33
33
|
for (let r of t.keywords ?? []) {
|
|
34
|
-
let t =
|
|
34
|
+
let t = _(e, r);
|
|
35
35
|
t > n && (n = t);
|
|
36
36
|
}
|
|
37
37
|
return n;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function ee(e, t) {
|
|
40
40
|
if (t.length === 0) return e;
|
|
41
41
|
let r = new Set(t), i = [], a = "", o = r.has(0), s = (e) => {
|
|
42
|
-
a !== "" && (i.push(o ? /* @__PURE__ */
|
|
42
|
+
a !== "" && (i.push(o ? /* @__PURE__ */ m("mark", {
|
|
43
43
|
className: n.match,
|
|
44
44
|
children: a
|
|
45
45
|
}, e) : a), a = "");
|
|
@@ -50,7 +50,7 @@ function v(e, t) {
|
|
|
50
50
|
}
|
|
51
51
|
return s(e.length), i;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function te(e, t) {
|
|
54
54
|
for (let n of t) {
|
|
55
55
|
let t = n.prefix;
|
|
56
56
|
if (t) {
|
|
@@ -66,49 +66,49 @@ function y(e, t) {
|
|
|
66
66
|
}
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
let E = S ?? f
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
|
|
75
|
-
let
|
|
69
|
+
function y({ open: _, onOpenChange: y, groups: ne, placeholder: b, emptyLabel: x, hotkey: re = !0, label: S, ariaLabel: ie, loading: C = !1, onQueryChange: w, scopes: T = [], className: ae }) {
|
|
70
|
+
d();
|
|
71
|
+
let E = ie ?? S ?? p(f.commandMenu.label), D = x ?? p(f.commandMenu.empty), O = r(), k = `${O}-listbox`, A = i(null), j = i(null), M = i([]), N = i(y);
|
|
72
|
+
N.current = y;
|
|
73
|
+
let P = i(w);
|
|
74
|
+
P.current = w;
|
|
75
|
+
let F = c(_), oe = c(re), I = l(""), L = l(0), R = l([]), z = l(null), se = R.value.at(-1)?.groups ?? ne, B = b ?? R.value.at(-1)?.placeholder ?? p(f.commandMenu.placeholder), V = T.find((e) => e.id === z.value) ?? null, H = se.filter((e) => !z.value || !e.scope || e.scope === z.value).map((e) => ({
|
|
76
76
|
heading: e.heading,
|
|
77
77
|
items: e.items.map((e) => ({
|
|
78
78
|
item: e,
|
|
79
|
-
score:
|
|
79
|
+
score: v(I.value, e)
|
|
80
80
|
})).filter(({ score: e }) => e > 0).sort((e, t) => t.score - e.score).map(({ item: e }) => ({
|
|
81
81
|
item: e,
|
|
82
|
-
indices:
|
|
82
|
+
indices: g(I.value, e.label)?.indices ?? []
|
|
83
83
|
}))
|
|
84
|
-
})).filter((e) => e.items.length > 0), U = H.flatMap((e) => e.items.map((e) => e.item)), W = U.flatMap((e, t) => e.disabled ? [] : [t]), G = W.includes(L.value) ? L.value : W[0] ?? -1, K = (e) => `${
|
|
84
|
+
})).filter((e) => e.items.length > 0), U = H.flatMap((e) => e.items.map((e) => e.item)), W = U.flatMap((e, t) => e.disabled ? [] : [t]), G = W.includes(L.value) ? L.value : W[0] ?? -1, K = (e) => `${O}-option-${e}`;
|
|
85
85
|
u(() => {
|
|
86
|
-
let e =
|
|
87
|
-
e && (
|
|
86
|
+
let e = A.current;
|
|
87
|
+
e && (F.value ? e.open || (a(() => {
|
|
88
88
|
I.value = "", L.value = 0, R.value = [], z.value = null;
|
|
89
|
-
}), typeof e.showModal == "function" && e.showModal(), s(
|
|
89
|
+
}), typeof e.showModal == "function" && e.showModal(), s(j.current)) : e.open && (R.value = [], e.close()));
|
|
90
90
|
}), u(() => {
|
|
91
|
-
let e =
|
|
91
|
+
let e = A.current;
|
|
92
92
|
if (!e) return;
|
|
93
|
-
let t = () =>
|
|
93
|
+
let t = () => N.current(!1);
|
|
94
94
|
return e.addEventListener("close", t), () => e.removeEventListener("close", t);
|
|
95
95
|
}), u(() => {
|
|
96
|
-
if (!
|
|
96
|
+
if (!oe.value) return;
|
|
97
97
|
let e = (e) => {
|
|
98
|
-
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k" && (e.preventDefault(),
|
|
98
|
+
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k" && (e.preventDefault(), N.current(!F.value));
|
|
99
99
|
};
|
|
100
100
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
101
101
|
});
|
|
102
102
|
let q = (e) => {
|
|
103
103
|
L.value = e;
|
|
104
|
-
let t =
|
|
104
|
+
let t = M.current[e];
|
|
105
105
|
t && typeof t.scrollIntoView == "function" && t.scrollIntoView({ block: "nearest" });
|
|
106
106
|
}, J = (e) => {
|
|
107
107
|
if (W.length === 0) return;
|
|
108
108
|
let t = W[(W.indexOf(G) + e + W.length) % W.length];
|
|
109
109
|
t !== void 0 && q(t);
|
|
110
110
|
}, Y = (e) => {
|
|
111
|
-
e.onSelect(),
|
|
111
|
+
e.onSelect(), y(!1);
|
|
112
112
|
}, X = (e, t) => {
|
|
113
113
|
if (!(!e || e.disabled)) {
|
|
114
114
|
if (e.page) {
|
|
@@ -123,9 +123,9 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
123
123
|
n && Y(n);
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
|
-
t !== "secondary" && (e.onSelect?.(),
|
|
126
|
+
t !== "secondary" && (e.onSelect?.(), y(!1));
|
|
127
127
|
}
|
|
128
|
-
},
|
|
128
|
+
}, ce = (e) => {
|
|
129
129
|
if (T.length === 0) return;
|
|
130
130
|
let t = [null, ...T.map((e) => e.id)], n = t[(t.indexOf(z.value) + e + t.length) % t.length];
|
|
131
131
|
a(() => {
|
|
@@ -134,12 +134,12 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
134
134
|
}, Z = () => {
|
|
135
135
|
a(() => {
|
|
136
136
|
z.value = null, L.value = 0;
|
|
137
|
-
}), s(
|
|
137
|
+
}), s(j.current);
|
|
138
138
|
}, Q = () => {
|
|
139
139
|
a(() => {
|
|
140
140
|
R.value = R.value.slice(0, -1), I.value = "", L.value = 0;
|
|
141
141
|
});
|
|
142
|
-
},
|
|
142
|
+
}, le = (e) => {
|
|
143
143
|
switch (e.key) {
|
|
144
144
|
case "ArrowDown":
|
|
145
145
|
e.preventDefault(), J(1);
|
|
@@ -148,7 +148,7 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
148
148
|
e.preventDefault(), J(-1);
|
|
149
149
|
break;
|
|
150
150
|
case "Tab":
|
|
151
|
-
T.length > 0 && (e.preventDefault(),
|
|
151
|
+
T.length > 0 && (e.preventDefault(), ce(e.shiftKey ? -1 : 1));
|
|
152
152
|
break;
|
|
153
153
|
case "Home":
|
|
154
154
|
e.preventDefault(), W[0] !== void 0 && q(W[0]);
|
|
@@ -166,24 +166,24 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
166
166
|
I.value === "" && (R.value.length > 0 ? (e.preventDefault(), Q()) : z.value && (e.preventDefault(), Z()));
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
|
-
}, le = (e) => {
|
|
170
|
-
e.key === "Escape" && (e.preventDefault(), R.value.length > 0 ? Q() : k.current?.close());
|
|
171
169
|
}, ue = (e) => {
|
|
172
|
-
e.
|
|
170
|
+
e.key === "Escape" && (e.preventDefault(), R.value.length > 0 ? Q() : A.current?.close());
|
|
171
|
+
}, de = (e) => {
|
|
172
|
+
e.target === A.current && A.current?.close();
|
|
173
173
|
}, $ = -1;
|
|
174
|
-
return /* @__PURE__ */
|
|
175
|
-
ref:
|
|
174
|
+
return /* @__PURE__ */ m("dialog", {
|
|
175
|
+
ref: A,
|
|
176
176
|
"aria-label": E,
|
|
177
|
-
className: o(n.dialog,
|
|
178
|
-
onClick:
|
|
179
|
-
onKeyDown:
|
|
180
|
-
children: /* @__PURE__ */
|
|
177
|
+
className: o(n.dialog, ae),
|
|
178
|
+
onClick: de,
|
|
179
|
+
onKeyDown: ue,
|
|
180
|
+
children: /* @__PURE__ */ h("div", {
|
|
181
181
|
className: n.panel,
|
|
182
182
|
children: [
|
|
183
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ h("div", {
|
|
184
184
|
className: n.search,
|
|
185
185
|
children: [
|
|
186
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ h("svg", {
|
|
187
187
|
className: n.searchIcon,
|
|
188
188
|
"aria-hidden": "true",
|
|
189
189
|
viewBox: "0 0 16 16",
|
|
@@ -193,30 +193,30 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
193
193
|
stroke: "currentColor",
|
|
194
194
|
strokeWidth: "1.5",
|
|
195
195
|
strokeLinecap: "round",
|
|
196
|
-
children: [/* @__PURE__ */
|
|
196
|
+
children: [/* @__PURE__ */ m("circle", {
|
|
197
197
|
cx: "7",
|
|
198
198
|
cy: "7",
|
|
199
199
|
r: "4.5"
|
|
200
|
-
}), /* @__PURE__ */
|
|
200
|
+
}), /* @__PURE__ */ m("line", {
|
|
201
201
|
x1: "10.5",
|
|
202
202
|
y1: "10.5",
|
|
203
203
|
x2: "14",
|
|
204
204
|
y2: "14"
|
|
205
205
|
})]
|
|
206
206
|
}),
|
|
207
|
-
V && /* @__PURE__ */
|
|
207
|
+
V && /* @__PURE__ */ h("span", {
|
|
208
208
|
className: n.scopeChip,
|
|
209
|
-
children: [V.label, /* @__PURE__ */
|
|
209
|
+
children: [V.label, /* @__PURE__ */ m("button", {
|
|
210
210
|
type: "button",
|
|
211
211
|
className: n.scopeClear,
|
|
212
|
-
"aria-label": f
|
|
212
|
+
"aria-label": p(f.commandMenu.clearScope),
|
|
213
213
|
onClick: Z,
|
|
214
|
-
children: /* @__PURE__ */
|
|
214
|
+
children: /* @__PURE__ */ m("svg", {
|
|
215
215
|
viewBox: "0 0 16 16",
|
|
216
216
|
width: "12",
|
|
217
217
|
height: "12",
|
|
218
218
|
"aria-hidden": "true",
|
|
219
|
-
children: /* @__PURE__ */
|
|
219
|
+
children: /* @__PURE__ */ m("path", {
|
|
220
220
|
d: "M4 4l8 8M12 4l-8 8",
|
|
221
221
|
fill: "none",
|
|
222
222
|
stroke: "currentColor",
|
|
@@ -226,77 +226,77 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
226
226
|
})
|
|
227
227
|
})]
|
|
228
228
|
}),
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
ref:
|
|
229
|
+
/* @__PURE__ */ m("input", {
|
|
230
|
+
ref: j,
|
|
231
231
|
type: "text",
|
|
232
232
|
role: "combobox",
|
|
233
233
|
"aria-expanded": "true",
|
|
234
|
-
"aria-controls":
|
|
234
|
+
"aria-controls": k,
|
|
235
235
|
"aria-activedescendant": G >= 0 ? K(G) : void 0,
|
|
236
236
|
"aria-autocomplete": "list",
|
|
237
237
|
"aria-label": E,
|
|
238
238
|
autoComplete: "off",
|
|
239
239
|
spellCheck: !1,
|
|
240
240
|
className: n.input,
|
|
241
|
-
placeholder:
|
|
241
|
+
placeholder: B,
|
|
242
242
|
value: I.value,
|
|
243
243
|
onChange: (e) => {
|
|
244
244
|
let t = e.target.value;
|
|
245
245
|
if (!z.value && T.length > 0) {
|
|
246
|
-
let e =
|
|
246
|
+
let e = te(t, T);
|
|
247
247
|
e && (z.value = e.scope.id, t = e.rest);
|
|
248
248
|
}
|
|
249
|
-
I.value = t, L.value = 0,
|
|
249
|
+
I.value = t, L.value = 0, P.current?.(t);
|
|
250
250
|
},
|
|
251
|
-
onKeyDown:
|
|
251
|
+
onKeyDown: le
|
|
252
252
|
})
|
|
253
253
|
]
|
|
254
254
|
}),
|
|
255
|
-
T.length > 0 && /* @__PURE__ */
|
|
255
|
+
T.length > 0 && /* @__PURE__ */ h("div", {
|
|
256
256
|
className: n.scopes,
|
|
257
|
-
children: [/* @__PURE__ */
|
|
257
|
+
children: [/* @__PURE__ */ m("span", {
|
|
258
258
|
className: n.scopesLabel,
|
|
259
|
-
children: f
|
|
260
|
-
}), T.map((e) => /* @__PURE__ */
|
|
259
|
+
children: p(f.commandMenu.scopeLabel)
|
|
260
|
+
}), T.map((e) => /* @__PURE__ */ h("button", {
|
|
261
261
|
type: "button",
|
|
262
262
|
className: n.scopePill,
|
|
263
263
|
"data-active": e.id === z.value || void 0,
|
|
264
264
|
onClick: () => {
|
|
265
265
|
a(() => {
|
|
266
266
|
z.value = z.value === e.id ? null : e.id, L.value = 0;
|
|
267
|
-
}), s(
|
|
267
|
+
}), s(j.current);
|
|
268
268
|
},
|
|
269
|
-
children: [e.prefix && /* @__PURE__ */
|
|
269
|
+
children: [e.prefix && /* @__PURE__ */ m("span", {
|
|
270
270
|
className: n.scopePrefix,
|
|
271
271
|
children: e.prefix
|
|
272
272
|
}), e.label]
|
|
273
273
|
}, e.id))]
|
|
274
274
|
}),
|
|
275
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ h("div", {
|
|
276
276
|
className: n.list,
|
|
277
|
-
children: [/* @__PURE__ */
|
|
277
|
+
children: [/* @__PURE__ */ m("div", {
|
|
278
278
|
role: "listbox",
|
|
279
|
-
id:
|
|
279
|
+
id: k,
|
|
280
280
|
"aria-label": S,
|
|
281
281
|
tabIndex: 0,
|
|
282
|
-
children: H.map((e, r) => /* @__PURE__ */
|
|
282
|
+
children: H.map((e, r) => /* @__PURE__ */ h("div", {
|
|
283
283
|
role: "group",
|
|
284
284
|
"aria-label": e.heading,
|
|
285
285
|
className: n.group,
|
|
286
|
-
children: [e.heading && /* @__PURE__ */
|
|
286
|
+
children: [e.heading && /* @__PURE__ */ h("div", {
|
|
287
287
|
className: n.heading,
|
|
288
288
|
"aria-hidden": "true",
|
|
289
|
-
children: [/* @__PURE__ */
|
|
289
|
+
children: [/* @__PURE__ */ m("span", { children: e.heading }), I.value !== "" && /* @__PURE__ */ m("span", {
|
|
290
290
|
className: n.count,
|
|
291
|
-
children: f
|
|
291
|
+
children: p(f.commandMenu.matches, { count: e.items.length })
|
|
292
292
|
})]
|
|
293
293
|
}), e.items.map((e) => {
|
|
294
294
|
let { item: r, indices: i } = e;
|
|
295
295
|
$++;
|
|
296
296
|
let a = $;
|
|
297
|
-
return /* @__PURE__ */
|
|
297
|
+
return /* @__PURE__ */ h("div", {
|
|
298
298
|
ref: (e) => {
|
|
299
|
-
|
|
299
|
+
M.current[a] = e;
|
|
300
300
|
},
|
|
301
301
|
id: K(a),
|
|
302
302
|
role: "option",
|
|
@@ -310,50 +310,50 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
310
310
|
},
|
|
311
311
|
onClick: () => X(r, "primary"),
|
|
312
312
|
children: [
|
|
313
|
-
r.icon && /* @__PURE__ */
|
|
313
|
+
r.icon && /* @__PURE__ */ m("span", {
|
|
314
314
|
className: n.icon,
|
|
315
315
|
"aria-hidden": "true",
|
|
316
316
|
children: r.icon
|
|
317
317
|
}),
|
|
318
|
-
/* @__PURE__ */
|
|
318
|
+
/* @__PURE__ */ h("span", {
|
|
319
319
|
className: n.text,
|
|
320
|
-
children: [/* @__PURE__ */
|
|
320
|
+
children: [/* @__PURE__ */ m("span", {
|
|
321
321
|
className: n.label,
|
|
322
|
-
children:
|
|
323
|
-
}), r.description && /* @__PURE__ */
|
|
322
|
+
children: ee(r.label, i)
|
|
323
|
+
}), r.description && /* @__PURE__ */ m("span", {
|
|
324
324
|
className: n.description,
|
|
325
325
|
children: r.description
|
|
326
326
|
})]
|
|
327
327
|
}),
|
|
328
|
-
r.status && /* @__PURE__ */
|
|
328
|
+
r.status && /* @__PURE__ */ h("span", {
|
|
329
329
|
className: n.status,
|
|
330
330
|
"data-tone": r.status.tone ?? "neutral",
|
|
331
|
-
children: [/* @__PURE__ */
|
|
331
|
+
children: [/* @__PURE__ */ m("span", {
|
|
332
332
|
className: n.statusDot,
|
|
333
333
|
"aria-hidden": "true"
|
|
334
334
|
}), r.status.label]
|
|
335
335
|
}),
|
|
336
|
-
r.actions && r.actions.length > 0 && /* @__PURE__ */
|
|
336
|
+
r.actions && r.actions.length > 0 && /* @__PURE__ */ m("span", {
|
|
337
337
|
className: n.actions,
|
|
338
|
-
children: r.actions.map((e) => /* @__PURE__ */
|
|
338
|
+
children: r.actions.map((e) => /* @__PURE__ */ h("span", {
|
|
339
339
|
className: n.action,
|
|
340
340
|
onClick: (t) => {
|
|
341
341
|
t.stopPropagation(), Y(e);
|
|
342
342
|
},
|
|
343
|
-
children: [e.label, e.shortcut && /* @__PURE__ */
|
|
343
|
+
children: [e.label, e.shortcut && /* @__PURE__ */ m("span", {
|
|
344
344
|
className: n.actionKeys,
|
|
345
345
|
"aria-hidden": "true",
|
|
346
|
-
children: e.shortcut.map((e, n) => /* @__PURE__ */
|
|
346
|
+
children: e.shortcut.map((e, n) => /* @__PURE__ */ m(t, {
|
|
347
347
|
size: "sm",
|
|
348
348
|
children: e
|
|
349
349
|
}, n))
|
|
350
350
|
})]
|
|
351
351
|
}, e.id))
|
|
352
352
|
}),
|
|
353
|
-
r.shortcut && /* @__PURE__ */
|
|
353
|
+
r.shortcut && /* @__PURE__ */ m("span", {
|
|
354
354
|
className: n.shortcut,
|
|
355
355
|
"aria-hidden": "true",
|
|
356
|
-
children: r.shortcut.map((e, n) => /* @__PURE__ */
|
|
356
|
+
children: r.shortcut.map((e, n) => /* @__PURE__ */ m(t, {
|
|
357
357
|
size: "sm",
|
|
358
358
|
children: e
|
|
359
359
|
}, n))
|
|
@@ -362,51 +362,51 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
362
362
|
}, r.id);
|
|
363
363
|
})]
|
|
364
364
|
}, e.heading ?? `group-${r}`))
|
|
365
|
-
}), U.length === 0 && (C ? /* @__PURE__ */
|
|
365
|
+
}), U.length === 0 && (C ? /* @__PURE__ */ h("div", {
|
|
366
366
|
role: "status",
|
|
367
367
|
className: n.empty,
|
|
368
|
-
children: [/* @__PURE__ */
|
|
369
|
-
}) : /* @__PURE__ */
|
|
368
|
+
children: [/* @__PURE__ */ m(e, { size: "sm" }), p(f.commandMenu.loading)]
|
|
369
|
+
}) : /* @__PURE__ */ m("div", {
|
|
370
370
|
role: "status",
|
|
371
371
|
className: n.empty,
|
|
372
|
-
children:
|
|
372
|
+
children: D
|
|
373
373
|
}))]
|
|
374
374
|
}),
|
|
375
|
-
/* @__PURE__ */
|
|
375
|
+
/* @__PURE__ */ h("div", {
|
|
376
376
|
className: n.footer,
|
|
377
377
|
"aria-hidden": "true",
|
|
378
378
|
children: [
|
|
379
|
-
/* @__PURE__ */
|
|
379
|
+
/* @__PURE__ */ h("span", {
|
|
380
380
|
className: n.hint,
|
|
381
381
|
children: [
|
|
382
|
-
/* @__PURE__ */
|
|
382
|
+
/* @__PURE__ */ m(t, {
|
|
383
383
|
size: "sm",
|
|
384
384
|
children: "↑"
|
|
385
385
|
}),
|
|
386
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ m(t, {
|
|
387
387
|
size: "sm",
|
|
388
388
|
children: "↓"
|
|
389
389
|
}),
|
|
390
390
|
" navigate"
|
|
391
391
|
]
|
|
392
392
|
}),
|
|
393
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ h("span", {
|
|
394
394
|
className: n.hint,
|
|
395
|
-
children: [/* @__PURE__ */
|
|
395
|
+
children: [/* @__PURE__ */ m(t, {
|
|
396
396
|
size: "sm",
|
|
397
397
|
children: "↵"
|
|
398
398
|
}), " open"]
|
|
399
399
|
}),
|
|
400
|
-
T.length > 0 && /* @__PURE__ */
|
|
400
|
+
T.length > 0 && /* @__PURE__ */ h("span", {
|
|
401
401
|
className: n.hint,
|
|
402
|
-
children: [/* @__PURE__ */
|
|
402
|
+
children: [/* @__PURE__ */ m(t, {
|
|
403
403
|
size: "sm",
|
|
404
404
|
children: "Tab"
|
|
405
405
|
}), " scope"]
|
|
406
406
|
}),
|
|
407
|
-
/* @__PURE__ */
|
|
407
|
+
/* @__PURE__ */ h("span", {
|
|
408
408
|
className: n.hint,
|
|
409
|
-
children: [/* @__PURE__ */
|
|
409
|
+
children: [/* @__PURE__ */ m(t, {
|
|
410
410
|
size: "sm",
|
|
411
411
|
children: "esc"
|
|
412
412
|
}), " close"]
|
|
@@ -418,4 +418,4 @@ function b({ open: g, onOpenChange: b, groups: te, placeholder: ne, emptyLabel:
|
|
|
418
418
|
});
|
|
419
419
|
}
|
|
420
420
|
//#endregion
|
|
421
|
-
export {
|
|
421
|
+
export { y as CommandMenu, g as fuzzyMatch, _ as fuzzyScore };
|
|
@@ -7,37 +7,37 @@ import { builtin as o, t as s } from "@cascivo/i18n";
|
|
|
7
7
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
8
|
//#region ../components/src/comparison/comparison.tsx
|
|
9
9
|
var u = (e) => Math.min(100, Math.max(0, e));
|
|
10
|
-
function d({ after: d, before: f, position: p, defaultPosition: m = 50, onPositionChange: h, orientation: g = "horizontal", keyboardStep: _ = 5, label: v,
|
|
10
|
+
function d({ after: d, before: f, position: p, defaultPosition: m = 50, onPositionChange: h, orientation: g = "horizontal", keyboardStep: _ = 5, label: v, ariaLabel: y, className: b, ...x }) {
|
|
11
11
|
a();
|
|
12
|
-
let
|
|
12
|
+
let S = t(null), C = i(!1), [w, T] = r({
|
|
13
13
|
value: p,
|
|
14
14
|
defaultValue: m,
|
|
15
15
|
onChange: h
|
|
16
|
-
}),
|
|
17
|
-
let t =
|
|
16
|
+
}), E = Math.round(u(w.value)), D = (e) => {
|
|
17
|
+
let t = S.current;
|
|
18
18
|
if (!t) return;
|
|
19
19
|
let n = t.getBoundingClientRect();
|
|
20
|
-
|
|
21
|
-
},
|
|
20
|
+
T(u(g === "vertical" ? (e.clientY - n.top) / n.height * 100 : (e.clientX - n.left) / n.width * 100));
|
|
21
|
+
}, O = (e) => {
|
|
22
22
|
let t = g === "vertical" ? "ArrowUp" : "ArrowLeft", n = g === "vertical" ? "ArrowDown" : "ArrowRight", r = null;
|
|
23
|
-
e.key === t || e.key === "ArrowLeft" || e.key === "ArrowUp" ? r =
|
|
23
|
+
e.key === t || e.key === "ArrowLeft" || e.key === "ArrowUp" ? r = E - _ : e.key === n || e.key === "ArrowRight" || e.key === "ArrowDown" ? r = E + _ : e.key === "Home" ? r = 0 : e.key === "End" ? r = 100 : e.key === "PageUp" ? r = E + _ * 2 : e.key === "PageDown" && (r = E - _ * 2), r !== null && (e.preventDefault(), T(u(r)));
|
|
24
24
|
};
|
|
25
25
|
return /* @__PURE__ */ l("div", {
|
|
26
|
-
ref:
|
|
26
|
+
ref: S,
|
|
27
27
|
"data-orientation": g,
|
|
28
|
-
"data-dragging":
|
|
29
|
-
className: n(e.comparison,
|
|
30
|
-
style: { "--position": `${
|
|
28
|
+
"data-dragging": C.value || void 0,
|
|
29
|
+
className: n(e.comparison, b),
|
|
30
|
+
style: { "--position": `${E}%` },
|
|
31
31
|
onPointerDown: (e) => {
|
|
32
|
-
|
|
32
|
+
C.value = !0, e.currentTarget.setPointerCapture?.(e.pointerId), D(e);
|
|
33
33
|
},
|
|
34
34
|
onPointerMove: (e) => {
|
|
35
|
-
|
|
35
|
+
C.value && D(e);
|
|
36
36
|
},
|
|
37
37
|
onPointerUp: (e) => {
|
|
38
|
-
|
|
38
|
+
C.value = !1, e.currentTarget.releasePointerCapture?.(e.pointerId);
|
|
39
39
|
},
|
|
40
|
-
...
|
|
40
|
+
...x,
|
|
41
41
|
children: [
|
|
42
42
|
/* @__PURE__ */ c("div", {
|
|
43
43
|
className: e.item,
|
|
@@ -53,13 +53,13 @@ function d({ after: d, before: f, position: p, defaultPosition: m = 50, onPositi
|
|
|
53
53
|
children: /* @__PURE__ */ c("div", {
|
|
54
54
|
role: "slider",
|
|
55
55
|
tabIndex: 0,
|
|
56
|
-
"aria-label": v ?? s(o.comparison.label),
|
|
56
|
+
"aria-label": y ?? v ?? s(o.comparison.label),
|
|
57
57
|
"aria-orientation": g,
|
|
58
58
|
"aria-valuemin": 0,
|
|
59
59
|
"aria-valuemax": 100,
|
|
60
|
-
"aria-valuenow":
|
|
60
|
+
"aria-valuenow": E,
|
|
61
61
|
className: e.handle,
|
|
62
|
-
onKeyDown:
|
|
62
|
+
onKeyDown: O
|
|
63
63
|
})
|
|
64
64
|
})
|
|
65
65
|
]
|