@cascivo/react 0.9.0 → 0.10.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 +5 -5
- package/dist/command-menu/command-menu.js +2 -2
- package/dist/field/field.js +24 -15
- package/dist/index.d.ts +13 -0
- package/dist/node/accordion/accordion.js +95 -0
- package/dist/node/accordion/accordion.module.js +13 -0
- package/dist/node/action-sheet/action-sheet.js +91 -0
- package/dist/node/action-sheet/action-sheet.module.js +14 -0
- package/dist/node/alert/alert.js +55 -0
- package/dist/node/alert/alert.module.js +13 -0
- package/dist/node/alert-dialog/alert-dialog.js +68 -0
- package/dist/node/alert-dialog/alert-dialog.module.js +13 -0
- package/dist/node/app-shell/app-shell.js +80 -0
- package/dist/node/app-shell/app-shell.module.js +14 -0
- package/dist/node/aspect-ratio/aspect-ratio.js +22 -0
- package/dist/node/aspect-ratio/aspect-ratio.module.js +8 -0
- package/dist/node/avatar/avatar.js +57 -0
- package/dist/node/avatar/avatar.module.js +10 -0
- package/dist/node/avatar-group/avatar-group.js +26 -0
- package/dist/node/avatar-group/avatar-group.module.js +8 -0
- package/dist/node/badge/badge.js +17 -0
- package/dist/node/badge/badge.module.js +5 -0
- package/dist/node/blockquote/blockquote.js +18 -0
- package/dist/node/blockquote/blockquote.module.js +8 -0
- package/dist/node/bottom-sheet/bottom-sheet.js +111 -0
- package/dist/node/bottom-sheet/bottom-sheet.module.js +16 -0
- package/dist/node/breadcrumb/breadcrumb.js +28 -0
- package/dist/node/breadcrumb/breadcrumb.module.js +5 -0
- package/dist/node/button/button.js +31 -0
- package/dist/node/button/button.module.js +5 -0
- package/dist/node/button-group/button-group.js +39 -0
- package/dist/node/button-group/button-group.module.js +5 -0
- package/dist/node/calendar/calendar.js +195 -0
- package/dist/node/calendar/calendar.module.js +16 -0
- package/dist/node/card/card.js +45 -0
- package/dist/node/card/card.module.js +11 -0
- package/dist/node/carousel/carousel.js +138 -0
- package/dist/node/carousel/carousel.module.js +15 -0
- package/dist/node/chat-bubble/chat-bubble.js +33 -0
- package/dist/node/chat-bubble/chat-bubble.module.js +13 -0
- package/dist/node/checkbox/checkbox.js +38 -0
- package/dist/node/checkbox/checkbox.module.js +10 -0
- package/dist/node/checkbox-card/checkbox-card.js +48 -0
- package/dist/node/checkbox-card/checkbox-card.module.js +13 -0
- package/dist/node/code/code.js +16 -0
- package/dist/node/code/code.module.js +5 -0
- package/dist/node/code-snippet/code-snippet.js +116 -0
- package/dist/node/code-snippet/code-snippet.module.js +19 -0
- package/dist/node/code-snippet/highlight.js +69 -0
- package/dist/node/collapsible/collapsible.js +42 -0
- package/dist/node/collapsible/collapsible.module.js +10 -0
- package/dist/node/color-picker/color-picker.js +268 -0
- package/dist/node/color-picker/color-picker.module.js +20 -0
- package/dist/node/combobox/combobox.js +164 -0
- package/dist/node/combobox/combobox.module.js +21 -0
- package/dist/node/command-menu/command-menu.js +425 -0
- package/dist/node/command-menu/command-menu.module.js +36 -0
- package/dist/node/comparison/comparison.js +69 -0
- package/dist/node/comparison/comparison.module.js +11 -0
- package/dist/node/contained-list/contained-list.js +41 -0
- package/dist/node/contained-list/contained-list.module.js +13 -0
- package/dist/node/context-menu/context-menu.js +89 -0
- package/dist/node/context-menu/context-menu.module.js +9 -0
- package/dist/node/copy-button/copy-button.js +58 -0
- package/dist/node/copy-button/copy-button.module.js +8 -0
- package/dist/node/data-list/data-list.js +27 -0
- package/dist/node/data-list/data-list.module.js +10 -0
- package/dist/node/data-table/data-table.js +370 -0
- package/dist/node/data-table/data-table.module.js +35 -0
- package/dist/node/date-picker/date-picker.js +218 -0
- package/dist/node/date-picker/date-picker.module.js +25 -0
- package/dist/node/date-range-picker/date-range-picker.js +196 -0
- package/dist/node/date-range-picker/date-range-picker.module.js +20 -0
- package/dist/node/dock/dock.js +34 -0
- package/dist/node/dock/dock.module.js +10 -0
- package/dist/node/drawer/drawer.js +95 -0
- package/dist/node/drawer/drawer.module.js +15 -0
- package/dist/node/dropdown/dropdown.js +109 -0
- package/dist/node/dropdown/dropdown.module.js +11 -0
- package/dist/node/editable/editable.js +67 -0
- package/dist/node/editable/editable.module.js +13 -0
- package/dist/node/empty-state/empty-state.js +34 -0
- package/dist/node/empty-state/empty-state.module.js +11 -0
- package/dist/node/fab/fab.js +93 -0
- package/dist/node/fab/fab.module.js +14 -0
- package/dist/node/field/field.js +48 -0
- package/dist/node/field/field.module.js +9 -0
- package/dist/node/file-uploader/file-uploader.js +122 -0
- package/dist/node/file-uploader/file-uploader.module.js +20 -0
- package/dist/node/filter/filter.js +34 -0
- package/dist/node/filter/filter.module.js +8 -0
- package/dist/node/form/form.js +95 -0
- package/dist/node/form/form.module.js +5 -0
- package/dist/node/header/header.js +44 -0
- package/dist/node/header/header.module.js +13 -0
- package/dist/node/header-panel/header-panel.js +74 -0
- package/dist/node/header-panel/header-panel.module.js +11 -0
- package/dist/node/heading/heading.js +24 -0
- package/dist/node/heading/heading.module.js +5 -0
- package/dist/node/hover-card/hover-card.js +84 -0
- package/dist/node/hover-card/hover-card.module.js +8 -0
- package/dist/node/icon-button/icon-button.js +21 -0
- package/dist/node/icon-button/icon-button.module.js +5 -0
- package/dist/node/image/image.js +64 -0
- package/dist/node/image/image.module.js +11 -0
- package/dist/node/index.js +2 -0
- package/dist/node/indicator/indicator.js +18 -0
- package/dist/node/indicator/indicator.module.js +8 -0
- package/dist/node/inline-loading/inline-loading.js +76 -0
- package/dist/node/inline-loading/inline-loading.module.js +11 -0
- package/dist/node/input/input.js +54 -0
- package/dist/node/input/input.module.js +11 -0
- package/dist/node/input-group/input-group.js +41 -0
- package/dist/node/input-group/input-group.module.js +11 -0
- package/dist/node/item/item.js +52 -0
- package/dist/node/item/item.module.js +12 -0
- package/dist/node/join/join.js +14 -0
- package/dist/node/join/join.module.js +5 -0
- package/dist/node/kbd/kbd.js +16 -0
- package/dist/node/kbd/kbd.module.js +5 -0
- package/dist/node/label/label.js +25 -0
- package/dist/node/label/label.module.js +9 -0
- package/dist/node/layouts/src/auto-grid/auto-grid.js +19 -0
- package/dist/node/layouts/src/auto-grid/auto-grid.module.js +6 -0
- package/dist/node/layouts/src/center/center.js +18 -0
- package/dist/node/layouts/src/center/center.module.js +5 -0
- package/dist/node/layouts/src/columns/columns.js +23 -0
- package/dist/node/layouts/src/columns/columns.module.js +8 -0
- package/dist/node/layouts/src/flex/flex.js +22 -0
- package/dist/node/layouts/src/flex/flex.module.js +5 -0
- package/dist/node/layouts/src/grid/grid.js +57 -0
- package/dist/node/layouts/src/grid/grid.module.js +9 -0
- package/dist/node/layouts/src/spacer/spacer.js +19 -0
- package/dist/node/layouts/src/spacer/spacer.module.js +5 -0
- package/dist/node/link/link.js +22 -0
- package/dist/node/link/link.module.js +5 -0
- package/dist/node/list/list.js +23 -0
- package/dist/node/list/list.module.js +8 -0
- package/dist/node/log-viewer/log-viewer.js +184 -0
- package/dist/node/log-viewer/log-viewer.module.js +18 -0
- package/dist/node/menu/menu.js +121 -0
- package/dist/node/menu/menu.module.js +10 -0
- package/dist/node/menu-button/menu-button.js +92 -0
- package/dist/node/menu-button/menu-button.module.js +10 -0
- package/dist/node/menubar/menubar.js +103 -0
- package/dist/node/menubar/menubar.module.js +10 -0
- package/dist/node/modal/modal.js +70 -0
- package/dist/node/modal/modal.module.js +13 -0
- package/dist/node/multi-select/multi-select.js +106 -0
- package/dist/node/multi-select/multi-select.module.js +17 -0
- package/dist/node/native-select/native-select.js +37 -0
- package/dist/node/native-select/native-select.module.js +9 -0
- package/dist/node/navigation-menu/navigation-menu.js +99 -0
- package/dist/node/navigation-menu/navigation-menu.module.js +12 -0
- package/dist/node/notification/notification.js +134 -0
- package/dist/node/notification/notification.module.js +13 -0
- package/dist/node/number-input/number-input.js +145 -0
- package/dist/node/number-input/number-input.module.js +14 -0
- package/dist/node/otp-input/otp-input.js +70 -0
- package/dist/node/otp-input/otp-input.module.js +8 -0
- package/dist/node/overflow-menu/overflow-menu.js +65 -0
- package/dist/node/overflow-menu/overflow-menu.module.js +9 -0
- package/dist/node/pagination/pagination.js +92 -0
- package/dist/node/pagination/pagination.module.js +13 -0
- package/dist/node/password-input/password-input.js +80 -0
- package/dist/node/password-input/password-input.module.js +13 -0
- package/dist/node/popover/popover.js +49 -0
- package/dist/node/popover/popover.module.js +8 -0
- package/dist/node/popover/use-popover.js +57 -0
- package/dist/node/progress/progress.js +17 -0
- package/dist/node/progress/progress.module.js +8 -0
- package/dist/node/progress-bar/progress-bar.js +44 -0
- package/dist/node/progress-bar/progress-bar.module.js +13 -0
- package/dist/node/progress-circle/progress-circle.js +48 -0
- package/dist/node/progress-circle/progress-circle.module.js +11 -0
- package/dist/node/progress-indicator/progress-indicator.js +36 -0
- package/dist/node/progress-indicator/progress-indicator.module.js +12 -0
- package/dist/node/prose/prose.js +15 -0
- package/dist/node/prose/prose.module.js +5 -0
- package/dist/node/pull-to-refresh/pull-to-refresh.js +82 -0
- package/dist/node/pull-to-refresh/pull-to-refresh.module.js +11 -0
- package/dist/node/qr-code/encode.js +585 -0
- package/dist/node/qr-code/qr-code.js +41 -0
- package/dist/node/qr-code/qr-code.module.js +8 -0
- package/dist/node/radial-progress/radial-progress.js +28 -0
- package/dist/node/radial-progress/radial-progress.module.js +8 -0
- package/dist/node/radio/radio.js +49 -0
- package/dist/node/radio/radio.module.js +11 -0
- package/dist/node/radio-card/radio-card.js +63 -0
- package/dist/node/radio-card/radio-card.module.js +13 -0
- package/dist/node/rating-group/rating-group.js +37 -0
- package/dist/node/rating-group/rating-group.module.js +8 -0
- package/dist/node/react/src/index.js +138 -0
- package/dist/node/react/src/theme.js +54 -0
- package/dist/node/relative-time/relative-time.js +66 -0
- package/dist/node/relative-time/relative-time.module.js +5 -0
- package/dist/node/resizable/resizable.js +80 -0
- package/dist/node/resizable/resizable.module.js +10 -0
- package/dist/node/scroll-area/scroll-area.js +38 -0
- package/dist/node/scroll-area/scroll-area.module.js +5 -0
- package/dist/node/search/search.js +94 -0
- package/dist/node/search/search.module.js +11 -0
- package/dist/node/segmented-control/segmented-control.js +43 -0
- package/dist/node/segmented-control/segmented-control.module.js +8 -0
- package/dist/node/select/select.js +71 -0
- package/dist/node/select/select.module.js +13 -0
- package/dist/node/separator/separator.js +21 -0
- package/dist/node/separator/separator.module.js +5 -0
- package/dist/node/sheet/sheet.js +50 -0
- package/dist/node/sheet/sheet.module.js +11 -0
- package/dist/node/shell-header/shell-header.js +166 -0
- package/dist/node/shell-header/shell-header.module.js +25 -0
- package/dist/node/side-nav/side-nav.js +333 -0
- package/dist/node/side-nav/side-nav.module.js +33 -0
- package/dist/node/skeleton/skeleton.js +25 -0
- package/dist/node/skeleton/skeleton.module.js +9 -0
- package/dist/node/skip-nav/skip-nav.js +27 -0
- package/dist/node/skip-nav/skip-nav.module.js +5 -0
- package/dist/node/slider/slider.js +29 -0
- package/dist/node/slider/slider.module.js +9 -0
- package/dist/node/spinner/spinner.js +18 -0
- package/dist/node/spinner/spinner.module.js +8 -0
- package/dist/node/stack/stack.js +19 -0
- package/dist/node/stack/stack.module.js +8 -0
- package/dist/node/stat/stat.js +41 -0
- package/dist/node/stat/stat.module.js +13 -0
- package/dist/node/status/status.js +20 -0
- package/dist/node/status/status.module.js +9 -0
- package/dist/node/steps/steps.js +35 -0
- package/dist/node/steps/steps.module.js +10 -0
- package/dist/node/storage/src/drivers.js +36 -0
- package/dist/node/storage/src/persisted-signal.js +43 -0
- package/dist/node/structured-list/structured-list.js +101 -0
- package/dist/node/structured-list/structured-list.module.js +14 -0
- package/dist/node/swap/swap.js +36 -0
- package/dist/node/swap/swap.module.js +9 -0
- package/dist/node/swipe-item/swipe-item.js +62 -0
- package/dist/node/swipe-item/swipe-item.module.js +14 -0
- package/dist/node/switcher/switcher.js +32 -0
- package/dist/node/switcher/switcher.module.js +10 -0
- package/dist/node/tabs/tabs.js +95 -0
- package/dist/node/tabs/tabs.module.js +10 -0
- package/dist/node/tag/tag.js +26 -0
- package/dist/node/tag/tag.module.js +8 -0
- package/dist/node/tags-input/tags-input.js +64 -0
- package/dist/node/tags-input/tags-input.module.js +10 -0
- package/dist/node/text/text.js +18 -0
- package/dist/node/text/text.module.js +5 -0
- package/dist/node/textarea/textarea.js +56 -0
- package/dist/node/textarea/textarea.module.js +11 -0
- package/dist/node/tile/tile.js +39 -0
- package/dist/node/tile/tile.module.js +9 -0
- package/dist/node/time-picker/time-picker.js +62 -0
- package/dist/node/time-picker/time-picker.module.js +11 -0
- package/dist/node/timeline/timeline.js +41 -0
- package/dist/node/timeline/timeline.module.js +13 -0
- package/dist/node/toast/toast.js +85 -0
- package/dist/node/toast/toast.module.js +13 -0
- package/dist/node/toc/toc.js +42 -0
- package/dist/node/toc/toc.module.js +5 -0
- package/dist/node/toc/use-toc-from-region.js +18 -0
- package/dist/node/toggle/toggle.js +39 -0
- package/dist/node/toggle/toggle.module.js +10 -0
- package/dist/node/toggle-group/toggle-group.js +55 -0
- package/dist/node/toggle-group/toggle-group.module.js +8 -0
- package/dist/node/toggletip/toggletip.js +49 -0
- package/dist/node/toggletip/toggletip.module.js +9 -0
- package/dist/node/tooltip/tooltip.js +58 -0
- package/dist/node/tooltip/tooltip.module.js +8 -0
- package/dist/node/tree-view/tree-view.js +201 -0
- package/dist/node/tree-view/tree-view.module.js +15 -0
- package/dist/node/user/user.js +37 -0
- package/dist/node/user/user.module.js +11 -0
- package/dist/node/visually-hidden/visually-hidden.js +15 -0
- package/dist/node/visually-hidden/visually-hidden.module.js +5 -0
- package/dist/react/src/theme.js +35 -29
- package/package.json +3 -2
- package/readme.body.md +5 -5
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Spinner as e } from "../spinner/spinner.js";
|
|
4
|
+
import { Kbd as t } from "../kbd/kbd.js";
|
|
5
|
+
import n from "./command-menu.module.js";
|
|
6
|
+
import { batch as r, cn as i, useSignal as a, useSignalEffect as o, useSignals as s } from "@cascivo/core";
|
|
7
|
+
import { builtin as c, t as l } from "@cascivo/i18n";
|
|
8
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
|
+
import { useId as ee, useRef as f } from "react";
|
|
10
|
+
//#region ../components/src/command-menu/command-menu.tsx
|
|
11
|
+
function p(e, t) {
|
|
12
|
+
if (e.length === 0) return {
|
|
13
|
+
score: 1,
|
|
14
|
+
indices: []
|
|
15
|
+
};
|
|
16
|
+
let n = e.toLowerCase(), r = t.toLowerCase(), i = 0, a = 0, o = -2, s = [];
|
|
17
|
+
for (let e = 0; e < r.length && a < n.length; e++) {
|
|
18
|
+
if (r[e] !== n[a]) continue;
|
|
19
|
+
i += 1, e === o + 1 && (i += 4);
|
|
20
|
+
let t = e === 0 ? " " : r[e - 1];
|
|
21
|
+
(t === " " || t === "-" || t === "_" || t === "/") && (i += 8), o = e, s.push(e), a++;
|
|
22
|
+
}
|
|
23
|
+
return a === n.length ? {
|
|
24
|
+
score: i,
|
|
25
|
+
indices: s
|
|
26
|
+
} : null;
|
|
27
|
+
}
|
|
28
|
+
function m(e, t) {
|
|
29
|
+
return p(e, t)?.score ?? 0;
|
|
30
|
+
}
|
|
31
|
+
function h(e, t) {
|
|
32
|
+
let n = m(e, t.label);
|
|
33
|
+
for (let r of t.keywords ?? []) {
|
|
34
|
+
let t = m(e, r);
|
|
35
|
+
t > n && (n = t);
|
|
36
|
+
}
|
|
37
|
+
return n;
|
|
38
|
+
}
|
|
39
|
+
function g(e, t) {
|
|
40
|
+
if (t.length === 0) return e;
|
|
41
|
+
let r = new Set(t), i = [], a = "", o = r.has(0), s = (e) => {
|
|
42
|
+
a !== "" && (i.push(o ? /* @__PURE__ */ u("mark", {
|
|
43
|
+
className: n.match,
|
|
44
|
+
children: a
|
|
45
|
+
}, e) : a), a = "");
|
|
46
|
+
};
|
|
47
|
+
for (let t = 0; t < e.length; t++) {
|
|
48
|
+
let n = r.has(t);
|
|
49
|
+
n !== o && (s(t), o = n), a += e[t];
|
|
50
|
+
}
|
|
51
|
+
return s(e.length), i;
|
|
52
|
+
}
|
|
53
|
+
function _(e, t) {
|
|
54
|
+
for (let n of t) {
|
|
55
|
+
let t = n.prefix;
|
|
56
|
+
if (t) {
|
|
57
|
+
if (e.startsWith(`${t} `) || e.startsWith(`${t}:`)) return {
|
|
58
|
+
scope: n,
|
|
59
|
+
rest: e.slice(t.length + 1).replace(/^\s+/, "")
|
|
60
|
+
};
|
|
61
|
+
if (!/\w/.test(t) && e.startsWith(t)) return {
|
|
62
|
+
scope: n,
|
|
63
|
+
rest: e.slice(t.length).replace(/^\s+/, "")
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function v({ open: m, onOpenChange: v, groups: te, placeholder: y, emptyLabel: b, hotkey: x = !0, label: S, loading: C = !1, onQueryChange: w, scopes: T = [], className: E }) {
|
|
70
|
+
s();
|
|
71
|
+
let D = S ?? l(c.commandMenu.label), ne = b ?? l(c.commandMenu.empty), O = ee(), k = `${O}-listbox`, A = f(null), j = f(null), M = f([]), N = f(v);
|
|
72
|
+
N.current = v;
|
|
73
|
+
let P = f(w);
|
|
74
|
+
P.current = w;
|
|
75
|
+
let F = a(m);
|
|
76
|
+
F.value = m;
|
|
77
|
+
let I = a(x);
|
|
78
|
+
I.value = x;
|
|
79
|
+
let L = a(""), R = a(0), z = a([]), B = a(null), re = z.value.at(-1)?.groups ?? te, ie = y ?? z.value.at(-1)?.placeholder ?? l(c.commandMenu.placeholder), V = T.find((e) => e.id === B.value) ?? null, H = re.filter((e) => !B.value || !e.scope || e.scope === B.value).map((e) => ({
|
|
80
|
+
heading: e.heading,
|
|
81
|
+
items: e.items.map((e) => ({
|
|
82
|
+
item: e,
|
|
83
|
+
score: h(L.value, e)
|
|
84
|
+
})).filter(({ score: e }) => e > 0).sort((e, t) => t.score - e.score).map(({ item: e }) => ({
|
|
85
|
+
item: e,
|
|
86
|
+
indices: p(L.value, e.label)?.indices ?? []
|
|
87
|
+
}))
|
|
88
|
+
})).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(R.value) ? R.value : W[0] ?? -1, K = (e) => `${O}-option-${e}`;
|
|
89
|
+
o(() => {
|
|
90
|
+
let e = A.current;
|
|
91
|
+
e && (F.value ? e.open || (r(() => {
|
|
92
|
+
L.value = "", R.value = 0, z.value = [], B.value = null;
|
|
93
|
+
}), typeof e.showModal == "function" && e.showModal(), j.current?.focus()) : e.open && (z.value = [], e.close()));
|
|
94
|
+
}), o(() => {
|
|
95
|
+
let e = A.current;
|
|
96
|
+
if (!e) return;
|
|
97
|
+
let t = () => N.current(!1);
|
|
98
|
+
return e.addEventListener("close", t), () => e.removeEventListener("close", t);
|
|
99
|
+
}), o(() => {
|
|
100
|
+
if (!I.value) return;
|
|
101
|
+
let e = (e) => {
|
|
102
|
+
(e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k" && (e.preventDefault(), N.current(!F.value));
|
|
103
|
+
};
|
|
104
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
105
|
+
});
|
|
106
|
+
let q = (e) => {
|
|
107
|
+
R.value = e;
|
|
108
|
+
let t = M.current[e];
|
|
109
|
+
t && typeof t.scrollIntoView == "function" && t.scrollIntoView({ block: "nearest" });
|
|
110
|
+
}, J = (e) => {
|
|
111
|
+
if (W.length === 0) return;
|
|
112
|
+
let t = W[(W.indexOf(G) + e + W.length) % W.length];
|
|
113
|
+
t !== void 0 && q(t);
|
|
114
|
+
}, Y = (e) => {
|
|
115
|
+
e.onSelect(), v(!1);
|
|
116
|
+
}, X = (e, t) => {
|
|
117
|
+
if (!(!e || e.disabled)) {
|
|
118
|
+
if (e.page) {
|
|
119
|
+
if (t === "secondary") return;
|
|
120
|
+
r(() => {
|
|
121
|
+
z.value = [...z.value, e.page], L.value = "", R.value = 0;
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (e.actions && e.actions.length > 0) {
|
|
126
|
+
let n = t === "secondary" ? e.actions[1] : e.actions[0];
|
|
127
|
+
n && Y(n);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
t !== "secondary" && (e.onSelect?.(), v(!1));
|
|
131
|
+
}
|
|
132
|
+
}, ae = (e) => {
|
|
133
|
+
if (T.length === 0) return;
|
|
134
|
+
let t = [null, ...T.map((e) => e.id)], n = t[(t.indexOf(B.value) + e + t.length) % t.length];
|
|
135
|
+
r(() => {
|
|
136
|
+
B.value = n ?? null, R.value = 0;
|
|
137
|
+
});
|
|
138
|
+
}, Z = () => {
|
|
139
|
+
r(() => {
|
|
140
|
+
B.value = null, R.value = 0;
|
|
141
|
+
}), j.current?.focus();
|
|
142
|
+
}, Q = () => {
|
|
143
|
+
r(() => {
|
|
144
|
+
z.value = z.value.slice(0, -1), L.value = "", R.value = 0;
|
|
145
|
+
});
|
|
146
|
+
}, oe = (e) => {
|
|
147
|
+
switch (e.key) {
|
|
148
|
+
case "ArrowDown":
|
|
149
|
+
e.preventDefault(), J(1);
|
|
150
|
+
break;
|
|
151
|
+
case "ArrowUp":
|
|
152
|
+
e.preventDefault(), J(-1);
|
|
153
|
+
break;
|
|
154
|
+
case "Tab":
|
|
155
|
+
T.length > 0 && (e.preventDefault(), ae(e.shiftKey ? -1 : 1));
|
|
156
|
+
break;
|
|
157
|
+
case "Home":
|
|
158
|
+
e.preventDefault(), W[0] !== void 0 && q(W[0]);
|
|
159
|
+
break;
|
|
160
|
+
case "End": {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
let t = W[W.length - 1];
|
|
163
|
+
t !== void 0 && q(t);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case "Enter":
|
|
167
|
+
e.preventDefault(), G >= 0 && X(U[G], e.metaKey || e.ctrlKey ? "secondary" : "primary");
|
|
168
|
+
break;
|
|
169
|
+
case "Backspace":
|
|
170
|
+
L.value === "" && (z.value.length > 0 ? (e.preventDefault(), Q()) : B.value && (e.preventDefault(), Z()));
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}, se = (e) => {
|
|
174
|
+
e.key === "Escape" && (e.preventDefault(), z.value.length > 0 ? Q() : A.current?.close());
|
|
175
|
+
}, ce = (e) => {
|
|
176
|
+
e.target === A.current && A.current?.close();
|
|
177
|
+
}, $ = -1;
|
|
178
|
+
return /* @__PURE__ */ u("dialog", {
|
|
179
|
+
ref: A,
|
|
180
|
+
"aria-label": D,
|
|
181
|
+
className: i(n.dialog, E),
|
|
182
|
+
onClick: ce,
|
|
183
|
+
onKeyDown: se,
|
|
184
|
+
children: /* @__PURE__ */ d("div", {
|
|
185
|
+
className: n.panel,
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ d("div", {
|
|
188
|
+
className: n.search,
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ d("svg", {
|
|
191
|
+
className: n.searchIcon,
|
|
192
|
+
"aria-hidden": "true",
|
|
193
|
+
viewBox: "0 0 16 16",
|
|
194
|
+
width: "16",
|
|
195
|
+
height: "16",
|
|
196
|
+
fill: "none",
|
|
197
|
+
stroke: "currentColor",
|
|
198
|
+
strokeWidth: "1.5",
|
|
199
|
+
strokeLinecap: "round",
|
|
200
|
+
children: [/* @__PURE__ */ u("circle", {
|
|
201
|
+
cx: "7",
|
|
202
|
+
cy: "7",
|
|
203
|
+
r: "4.5"
|
|
204
|
+
}), /* @__PURE__ */ u("line", {
|
|
205
|
+
x1: "10.5",
|
|
206
|
+
y1: "10.5",
|
|
207
|
+
x2: "14",
|
|
208
|
+
y2: "14"
|
|
209
|
+
})]
|
|
210
|
+
}),
|
|
211
|
+
V && /* @__PURE__ */ d("span", {
|
|
212
|
+
className: n.scopeChip,
|
|
213
|
+
children: [V.label, /* @__PURE__ */ u("button", {
|
|
214
|
+
type: "button",
|
|
215
|
+
className: n.scopeClear,
|
|
216
|
+
"aria-label": l(c.commandMenu.clearScope),
|
|
217
|
+
onClick: Z,
|
|
218
|
+
children: /* @__PURE__ */ u("svg", {
|
|
219
|
+
viewBox: "0 0 16 16",
|
|
220
|
+
width: "12",
|
|
221
|
+
height: "12",
|
|
222
|
+
"aria-hidden": "true",
|
|
223
|
+
children: /* @__PURE__ */ u("path", {
|
|
224
|
+
d: "M4 4l8 8M12 4l-8 8",
|
|
225
|
+
fill: "none",
|
|
226
|
+
stroke: "currentColor",
|
|
227
|
+
strokeWidth: "1.5",
|
|
228
|
+
strokeLinecap: "round"
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
})]
|
|
232
|
+
}),
|
|
233
|
+
/* @__PURE__ */ u("input", {
|
|
234
|
+
ref: j,
|
|
235
|
+
type: "text",
|
|
236
|
+
role: "combobox",
|
|
237
|
+
"aria-expanded": "true",
|
|
238
|
+
"aria-controls": k,
|
|
239
|
+
"aria-activedescendant": G >= 0 ? K(G) : void 0,
|
|
240
|
+
"aria-autocomplete": "list",
|
|
241
|
+
"aria-label": D,
|
|
242
|
+
autoComplete: "off",
|
|
243
|
+
spellCheck: !1,
|
|
244
|
+
className: n.input,
|
|
245
|
+
placeholder: ie,
|
|
246
|
+
value: L.value,
|
|
247
|
+
onChange: (e) => {
|
|
248
|
+
let t = e.target.value;
|
|
249
|
+
if (!B.value && T.length > 0) {
|
|
250
|
+
let e = _(t, T);
|
|
251
|
+
e && (B.value = e.scope.id, t = e.rest);
|
|
252
|
+
}
|
|
253
|
+
L.value = t, R.value = 0, P.current?.(t);
|
|
254
|
+
},
|
|
255
|
+
onKeyDown: oe
|
|
256
|
+
})
|
|
257
|
+
]
|
|
258
|
+
}),
|
|
259
|
+
T.length > 0 && /* @__PURE__ */ d("div", {
|
|
260
|
+
className: n.scopes,
|
|
261
|
+
children: [/* @__PURE__ */ u("span", {
|
|
262
|
+
className: n.scopesLabel,
|
|
263
|
+
children: l(c.commandMenu.scopeLabel)
|
|
264
|
+
}), T.map((e) => /* @__PURE__ */ d("button", {
|
|
265
|
+
type: "button",
|
|
266
|
+
className: n.scopePill,
|
|
267
|
+
"data-active": e.id === B.value || void 0,
|
|
268
|
+
onClick: () => {
|
|
269
|
+
r(() => {
|
|
270
|
+
B.value = B.value === e.id ? null : e.id, R.value = 0;
|
|
271
|
+
}), j.current?.focus();
|
|
272
|
+
},
|
|
273
|
+
children: [e.prefix && /* @__PURE__ */ u("span", {
|
|
274
|
+
className: n.scopePrefix,
|
|
275
|
+
children: e.prefix
|
|
276
|
+
}), e.label]
|
|
277
|
+
}, e.id))]
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ d("div", {
|
|
280
|
+
className: n.list,
|
|
281
|
+
children: [/* @__PURE__ */ u("div", {
|
|
282
|
+
role: "listbox",
|
|
283
|
+
id: k,
|
|
284
|
+
"aria-label": S,
|
|
285
|
+
tabIndex: 0,
|
|
286
|
+
children: H.map((e, r) => /* @__PURE__ */ d("div", {
|
|
287
|
+
role: "group",
|
|
288
|
+
"aria-label": e.heading,
|
|
289
|
+
className: n.group,
|
|
290
|
+
children: [e.heading && /* @__PURE__ */ d("div", {
|
|
291
|
+
className: n.heading,
|
|
292
|
+
"aria-hidden": "true",
|
|
293
|
+
children: [/* @__PURE__ */ u("span", { children: e.heading }), L.value !== "" && /* @__PURE__ */ u("span", {
|
|
294
|
+
className: n.count,
|
|
295
|
+
children: l(c.commandMenu.matches, { count: e.items.length })
|
|
296
|
+
})]
|
|
297
|
+
}), e.items.map((e) => {
|
|
298
|
+
let { item: r, indices: i } = e;
|
|
299
|
+
$++;
|
|
300
|
+
let a = $;
|
|
301
|
+
return /* @__PURE__ */ d("div", {
|
|
302
|
+
ref: (e) => {
|
|
303
|
+
M.current[a] = e;
|
|
304
|
+
},
|
|
305
|
+
id: K(a),
|
|
306
|
+
role: "option",
|
|
307
|
+
"aria-selected": a === G,
|
|
308
|
+
"aria-disabled": r.disabled || void 0,
|
|
309
|
+
"data-state": a === G ? "active" : void 0,
|
|
310
|
+
"data-disabled": r.disabled || void 0,
|
|
311
|
+
className: n.option,
|
|
312
|
+
onMouseEnter: () => {
|
|
313
|
+
r.disabled || (R.value = a);
|
|
314
|
+
},
|
|
315
|
+
onClick: () => X(r, "primary"),
|
|
316
|
+
children: [
|
|
317
|
+
r.icon && /* @__PURE__ */ u("span", {
|
|
318
|
+
className: n.icon,
|
|
319
|
+
"aria-hidden": "true",
|
|
320
|
+
children: r.icon
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ d("span", {
|
|
323
|
+
className: n.text,
|
|
324
|
+
children: [/* @__PURE__ */ u("span", {
|
|
325
|
+
className: n.label,
|
|
326
|
+
children: g(r.label, i)
|
|
327
|
+
}), r.description && /* @__PURE__ */ u("span", {
|
|
328
|
+
className: n.description,
|
|
329
|
+
children: r.description
|
|
330
|
+
})]
|
|
331
|
+
}),
|
|
332
|
+
r.status && /* @__PURE__ */ d("span", {
|
|
333
|
+
className: n.status,
|
|
334
|
+
"data-tone": r.status.tone ?? "neutral",
|
|
335
|
+
children: [/* @__PURE__ */ u("span", {
|
|
336
|
+
className: n.statusDot,
|
|
337
|
+
"aria-hidden": "true"
|
|
338
|
+
}), r.status.label]
|
|
339
|
+
}),
|
|
340
|
+
r.actions && r.actions.length > 0 && /* @__PURE__ */ u("span", {
|
|
341
|
+
className: n.actions,
|
|
342
|
+
children: r.actions.map((e) => /* @__PURE__ */ d("span", {
|
|
343
|
+
className: n.action,
|
|
344
|
+
onClick: (t) => {
|
|
345
|
+
t.stopPropagation(), Y(e);
|
|
346
|
+
},
|
|
347
|
+
children: [e.label, e.shortcut && /* @__PURE__ */ u("span", {
|
|
348
|
+
className: n.actionKeys,
|
|
349
|
+
"aria-hidden": "true",
|
|
350
|
+
children: e.shortcut.map((e, n) => /* @__PURE__ */ u(t, {
|
|
351
|
+
size: "sm",
|
|
352
|
+
children: e
|
|
353
|
+
}, n))
|
|
354
|
+
})]
|
|
355
|
+
}, e.id))
|
|
356
|
+
}),
|
|
357
|
+
r.shortcut && /* @__PURE__ */ u("span", {
|
|
358
|
+
className: n.shortcut,
|
|
359
|
+
"aria-hidden": "true",
|
|
360
|
+
children: r.shortcut.map((e, n) => /* @__PURE__ */ u(t, {
|
|
361
|
+
size: "sm",
|
|
362
|
+
children: e
|
|
363
|
+
}, n))
|
|
364
|
+
})
|
|
365
|
+
]
|
|
366
|
+
}, r.id);
|
|
367
|
+
})]
|
|
368
|
+
}, e.heading ?? `group-${r}`))
|
|
369
|
+
}), U.length === 0 && (C ? /* @__PURE__ */ d("div", {
|
|
370
|
+
role: "status",
|
|
371
|
+
className: n.empty,
|
|
372
|
+
children: [/* @__PURE__ */ u(e, { size: "sm" }), l(c.commandMenu.loading)]
|
|
373
|
+
}) : /* @__PURE__ */ u("div", {
|
|
374
|
+
role: "status",
|
|
375
|
+
className: n.empty,
|
|
376
|
+
children: ne
|
|
377
|
+
}))]
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ d("div", {
|
|
380
|
+
className: n.footer,
|
|
381
|
+
"aria-hidden": "true",
|
|
382
|
+
children: [
|
|
383
|
+
/* @__PURE__ */ d("span", {
|
|
384
|
+
className: n.hint,
|
|
385
|
+
children: [
|
|
386
|
+
/* @__PURE__ */ u(t, {
|
|
387
|
+
size: "sm",
|
|
388
|
+
children: "↑"
|
|
389
|
+
}),
|
|
390
|
+
/* @__PURE__ */ u(t, {
|
|
391
|
+
size: "sm",
|
|
392
|
+
children: "↓"
|
|
393
|
+
}),
|
|
394
|
+
" navigate"
|
|
395
|
+
]
|
|
396
|
+
}),
|
|
397
|
+
/* @__PURE__ */ d("span", {
|
|
398
|
+
className: n.hint,
|
|
399
|
+
children: [/* @__PURE__ */ u(t, {
|
|
400
|
+
size: "sm",
|
|
401
|
+
children: "↵"
|
|
402
|
+
}), " open"]
|
|
403
|
+
}),
|
|
404
|
+
T.length > 0 && /* @__PURE__ */ d("span", {
|
|
405
|
+
className: n.hint,
|
|
406
|
+
children: [/* @__PURE__ */ u(t, {
|
|
407
|
+
size: "sm",
|
|
408
|
+
children: "Tab"
|
|
409
|
+
}), " scope"]
|
|
410
|
+
}),
|
|
411
|
+
/* @__PURE__ */ d("span", {
|
|
412
|
+
className: n.hint,
|
|
413
|
+
children: [/* @__PURE__ */ u(t, {
|
|
414
|
+
size: "sm",
|
|
415
|
+
children: "esc"
|
|
416
|
+
}), " close"]
|
|
417
|
+
})
|
|
418
|
+
]
|
|
419
|
+
})
|
|
420
|
+
]
|
|
421
|
+
})
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
export { v as CommandMenu, p as fuzzyMatch, m as fuzzyScore };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
var e = {
|
|
4
|
+
dialog: "_dialog_1dfrg_2",
|
|
5
|
+
panel: "_panel_1dfrg_62",
|
|
6
|
+
search: "_search_1dfrg_72",
|
|
7
|
+
searchIcon: "_searchIcon_1dfrg_80",
|
|
8
|
+
scopeChip: "_scopeChip_1dfrg_85",
|
|
9
|
+
scopeClear: "_scopeClear_1dfrg_101",
|
|
10
|
+
input: "_input_1dfrg_123",
|
|
11
|
+
scopes: "_scopes_1dfrg_142",
|
|
12
|
+
scopesLabel: "_scopesLabel_1dfrg_153",
|
|
13
|
+
scopePill: "_scopePill_1dfrg_163",
|
|
14
|
+
scopePrefix: "_scopePrefix_1dfrg_193",
|
|
15
|
+
list: "_list_1dfrg_199",
|
|
16
|
+
group: "_group_1dfrg_205",
|
|
17
|
+
heading: "_heading_1dfrg_209",
|
|
18
|
+
count: "_count_1dfrg_222",
|
|
19
|
+
option: "_option_1dfrg_228",
|
|
20
|
+
icon: "_icon_1dfrg_253",
|
|
21
|
+
text: "_text_1dfrg_260",
|
|
22
|
+
label: "_label_1dfrg_268",
|
|
23
|
+
match: "_match_1dfrg_274",
|
|
24
|
+
description: "_description_1dfrg_280",
|
|
25
|
+
status: "_status_1dfrg_289",
|
|
26
|
+
statusDot: "_statusDot_1dfrg_316",
|
|
27
|
+
actions: "_actions_1dfrg_325",
|
|
28
|
+
action: "_action_1dfrg_325",
|
|
29
|
+
actionKeys: "_actionKeys_1dfrg_369",
|
|
30
|
+
shortcut: "_shortcut_1dfrg_374",
|
|
31
|
+
empty: "_empty_1dfrg_392",
|
|
32
|
+
footer: "_footer_1dfrg_400",
|
|
33
|
+
hint: "_hint_1dfrg_411"
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { e as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./comparison.module.js";
|
|
4
|
+
import { cn as t, useControllableSignal as n, useSignal as r, useSignals as i } from "@cascivo/core";
|
|
5
|
+
import { builtin as a, t as o } from "@cascivo/i18n";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
import { useRef as l } from "react";
|
|
8
|
+
//#region ../components/src/comparison/comparison.tsx
|
|
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, className: y, ...b }) {
|
|
11
|
+
i();
|
|
12
|
+
let x = l(null), S = r(!1), [C, w] = n({
|
|
13
|
+
value: p,
|
|
14
|
+
defaultValue: m,
|
|
15
|
+
onChange: h
|
|
16
|
+
}), T = Math.round(u(C.value)), E = (e) => {
|
|
17
|
+
let t = x.current;
|
|
18
|
+
if (!t) return;
|
|
19
|
+
let n = t.getBoundingClientRect();
|
|
20
|
+
w(u(g === "vertical" ? (e.clientY - n.top) / n.height * 100 : (e.clientX - n.left) / n.width * 100));
|
|
21
|
+
}, D = (e) => {
|
|
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 = T - _ : e.key === n || e.key === "ArrowRight" || e.key === "ArrowDown" ? r = T + _ : e.key === "Home" ? r = 0 : e.key === "End" ? r = 100 : e.key === "PageUp" ? r = T + _ * 2 : e.key === "PageDown" && (r = T - _ * 2), r !== null && (e.preventDefault(), w(u(r)));
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ c("div", {
|
|
26
|
+
ref: x,
|
|
27
|
+
"data-orientation": g,
|
|
28
|
+
"data-dragging": S.value || void 0,
|
|
29
|
+
className: t(e.comparison, y),
|
|
30
|
+
style: { "--position": `${T}%` },
|
|
31
|
+
onPointerDown: (e) => {
|
|
32
|
+
S.value = !0, e.currentTarget.setPointerCapture?.(e.pointerId), E(e);
|
|
33
|
+
},
|
|
34
|
+
onPointerMove: (e) => {
|
|
35
|
+
S.value && E(e);
|
|
36
|
+
},
|
|
37
|
+
onPointerUp: (e) => {
|
|
38
|
+
S.value = !1, e.currentTarget.releasePointerCapture?.(e.pointerId);
|
|
39
|
+
},
|
|
40
|
+
...b,
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ s("div", {
|
|
43
|
+
className: e.item,
|
|
44
|
+
children: d
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ s("div", {
|
|
47
|
+
className: e.before,
|
|
48
|
+
"aria-hidden": "true",
|
|
49
|
+
children: f
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ s("div", {
|
|
52
|
+
className: e.divider,
|
|
53
|
+
children: /* @__PURE__ */ s("div", {
|
|
54
|
+
role: "slider",
|
|
55
|
+
tabIndex: 0,
|
|
56
|
+
"aria-label": v ?? o(a.comparison.label),
|
|
57
|
+
"aria-orientation": g,
|
|
58
|
+
"aria-valuemin": 0,
|
|
59
|
+
"aria-valuemax": 100,
|
|
60
|
+
"aria-valuenow": T,
|
|
61
|
+
className: e.handle,
|
|
62
|
+
onKeyDown: D
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { d as Comparison };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./contained-list.module.js";
|
|
4
|
+
import { Slot as t, cn as n } from "@cascivo/core";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region ../components/src/contained-list/contained-list.tsx
|
|
7
|
+
function a({ label: t, kind: a = "on-page", action: o, className: s, children: c, ...l }) {
|
|
8
|
+
return /* @__PURE__ */ i("div", {
|
|
9
|
+
"data-kind": a,
|
|
10
|
+
className: n(e.root, s),
|
|
11
|
+
...l,
|
|
12
|
+
children: [/* @__PURE__ */ i("div", {
|
|
13
|
+
className: e.header,
|
|
14
|
+
children: [/* @__PURE__ */ r("h3", {
|
|
15
|
+
className: e.label,
|
|
16
|
+
children: t
|
|
17
|
+
}), o ? /* @__PURE__ */ r("div", {
|
|
18
|
+
className: e.action,
|
|
19
|
+
children: o
|
|
20
|
+
}) : null]
|
|
21
|
+
}), /* @__PURE__ */ r("ul", {
|
|
22
|
+
className: e.list,
|
|
23
|
+
children: c
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function o({ asChild: i = !1, onClick: a, className: o, children: s, ...c }) {
|
|
28
|
+
let l = i || typeof a == "function", u = i ? t : "div";
|
|
29
|
+
return /* @__PURE__ */ r("li", {
|
|
30
|
+
className: e.item,
|
|
31
|
+
"data-interactive": l ? "" : void 0,
|
|
32
|
+
children: /* @__PURE__ */ r(u, {
|
|
33
|
+
className: n(e.itemContent, o),
|
|
34
|
+
onClick: a,
|
|
35
|
+
...c,
|
|
36
|
+
children: s
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { a as ContainedList, o as ContainedListItem };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
var e = {
|
|
4
|
+
root: "_root_u2rtc_2",
|
|
5
|
+
header: "_header_u2rtc_11",
|
|
6
|
+
label: "_label_u2rtc_25",
|
|
7
|
+
action: "_action_u2rtc_33",
|
|
8
|
+
list: "_list_u2rtc_39",
|
|
9
|
+
item: "_item_u2rtc_45",
|
|
10
|
+
itemContent: "_itemContent_u2rtc_57"
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as default };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./context-menu.module.js";
|
|
4
|
+
import { useSignal as t, useSignalEffect as n, useSignals as r } from "@cascivo/core";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { useRef as o } from "react";
|
|
7
|
+
//#region ../components/src/context-menu/context-menu.tsx
|
|
8
|
+
function s({ children: s }) {
|
|
9
|
+
r();
|
|
10
|
+
let c = o(null), l = o(null), u = t(!1), d = () => {
|
|
11
|
+
let e = c.current;
|
|
12
|
+
return e ? Array.from(e.querySelectorAll("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")) : [];
|
|
13
|
+
}, f = (e) => {
|
|
14
|
+
let t = d();
|
|
15
|
+
t.length !== 0 && t[e(t, t.indexOf(document.activeElement))]?.focus();
|
|
16
|
+
}, p = (e) => {
|
|
17
|
+
switch (e.key) {
|
|
18
|
+
case "ArrowDown":
|
|
19
|
+
e.preventDefault(), f((e, t) => t < 0 ? 0 : (t + 1) % e.length);
|
|
20
|
+
break;
|
|
21
|
+
case "ArrowUp":
|
|
22
|
+
e.preventDefault(), f((e, t) => t < 0 ? e.length - 1 : (t - 1 + e.length) % e.length);
|
|
23
|
+
break;
|
|
24
|
+
case "Home":
|
|
25
|
+
e.preventDefault(), f(() => 0);
|
|
26
|
+
break;
|
|
27
|
+
case "End":
|
|
28
|
+
e.preventDefault(), f((e) => e.length - 1);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
n(() => {
|
|
33
|
+
let e = c.current;
|
|
34
|
+
if (e) if (u.value) {
|
|
35
|
+
try {
|
|
36
|
+
e.showPopover();
|
|
37
|
+
} catch {}
|
|
38
|
+
d()[0]?.focus();
|
|
39
|
+
} else try {
|
|
40
|
+
e.hidePopover();
|
|
41
|
+
} catch {}
|
|
42
|
+
}), n(() => {
|
|
43
|
+
let e = c.current;
|
|
44
|
+
if (!e) return;
|
|
45
|
+
let t = (e) => {
|
|
46
|
+
e.newState === "closed" && (u.value = !1);
|
|
47
|
+
};
|
|
48
|
+
return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
|
|
49
|
+
});
|
|
50
|
+
function m(e) {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
let t = l.current;
|
|
53
|
+
t && (t.style.setProperty("--cascivo-context-x", `${e.clientX}px`), t.style.setProperty("--cascivo-context-y", `${e.clientY}px`), u.value = !0);
|
|
54
|
+
}
|
|
55
|
+
let [h, ...g] = Array.isArray(s) ? s : [s];
|
|
56
|
+
return /* @__PURE__ */ a("div", {
|
|
57
|
+
ref: l,
|
|
58
|
+
onContextMenu: m,
|
|
59
|
+
className: e.wrapper,
|
|
60
|
+
children: [h, /* @__PURE__ */ i("div", {
|
|
61
|
+
ref: c,
|
|
62
|
+
popover: "auto",
|
|
63
|
+
role: "menu",
|
|
64
|
+
"data-state": u.value ? "open" : "closed",
|
|
65
|
+
className: e.menu,
|
|
66
|
+
onKeyDown: p,
|
|
67
|
+
children: g
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function c({ children: t, onSelect: n, disabled: r }) {
|
|
72
|
+
function a() {
|
|
73
|
+
r || n();
|
|
74
|
+
}
|
|
75
|
+
function o(e) {
|
|
76
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), a());
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ i("div", {
|
|
79
|
+
role: "menuitem",
|
|
80
|
+
tabIndex: r ? -1 : 0,
|
|
81
|
+
"aria-disabled": r,
|
|
82
|
+
onClick: a,
|
|
83
|
+
onKeyDown: o,
|
|
84
|
+
className: e.item,
|
|
85
|
+
children: t
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { s as ContextMenu, c as ContextMenuItem };
|