@cascivo/react 0.9.0 → 0.10.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.
- 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 +4 -3
- package/readme.body.md +5 -5
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./dropdown.module.js";
|
|
4
|
+
import { composeRefs as t, createMachine as n, useMachine as r, useSignal as i, useSignalEffect as a, useSignals as o } from "@cascivo/core";
|
|
5
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
|
+
import { cloneElement as l, useRef as u } from "react";
|
|
7
|
+
//#region ../components/src/dropdown/dropdown.tsx
|
|
8
|
+
var d = n({
|
|
9
|
+
initial: "closed",
|
|
10
|
+
states: {
|
|
11
|
+
closed: { on: { OPEN: "open" } },
|
|
12
|
+
open: { on: { CLOSE: "closed" } }
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
function f({ trigger: n, items: f, onSelect: p, placement: m = "bottom-start", open: h, onOpenChange: g }) {
|
|
16
|
+
o();
|
|
17
|
+
let [_, v] = r(d), y = u(null), b = u(null), x = u(null), S = u([]), C = i(-1), w = h !== void 0, T = w ? h : _.value === "open", E = i(T);
|
|
18
|
+
E.value = T;
|
|
19
|
+
let D = f.map((e, t) => ({
|
|
20
|
+
item: e,
|
|
21
|
+
index: t
|
|
22
|
+
})).filter(({ item: e }) => !e.separator && !e.disabled).map(({ index: e }) => e), O = (e) => {
|
|
23
|
+
w || v(e ? "OPEN" : "CLOSE"), g?.(e);
|
|
24
|
+
};
|
|
25
|
+
a(() => {
|
|
26
|
+
let e = C.value;
|
|
27
|
+
E.value && e >= 0 && S.current[e]?.focus();
|
|
28
|
+
}), a(() => {
|
|
29
|
+
E.value ? C.value = D[0] ?? -1 : C.value = -1;
|
|
30
|
+
}), a(() => {
|
|
31
|
+
E.value ? x.current?.showPopover() : x.current?.hidePopover();
|
|
32
|
+
}), a(() => {
|
|
33
|
+
let e = x.current;
|
|
34
|
+
if (!e) return;
|
|
35
|
+
let t = (e) => {
|
|
36
|
+
e.newState === "closed" && O(!1);
|
|
37
|
+
};
|
|
38
|
+
return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
|
|
39
|
+
});
|
|
40
|
+
let k = (e) => {
|
|
41
|
+
let t = f[e];
|
|
42
|
+
!t || t.separator || t.disabled || (p?.(t.value), O(!1), b.current?.focus());
|
|
43
|
+
}, A = (e) => {
|
|
44
|
+
D.length !== 0 && (C.value = D[(D.indexOf(C.value) + e + D.length) % D.length] ?? -1);
|
|
45
|
+
}, j = (e) => {
|
|
46
|
+
switch (e.key) {
|
|
47
|
+
case "ArrowDown":
|
|
48
|
+
e.preventDefault(), A(1);
|
|
49
|
+
break;
|
|
50
|
+
case "ArrowUp":
|
|
51
|
+
e.preventDefault(), A(-1);
|
|
52
|
+
break;
|
|
53
|
+
case "Home":
|
|
54
|
+
e.preventDefault(), C.value = D[0] ?? -1;
|
|
55
|
+
break;
|
|
56
|
+
case "End":
|
|
57
|
+
e.preventDefault(), C.value = D[D.length - 1] ?? -1;
|
|
58
|
+
break;
|
|
59
|
+
case "Escape":
|
|
60
|
+
e.preventDefault(), O(!1), b.current?.focus();
|
|
61
|
+
break;
|
|
62
|
+
case "Enter":
|
|
63
|
+
case " ":
|
|
64
|
+
e.preventDefault(), k(C.value);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}, M = n, N = l(M, {
|
|
68
|
+
ref: t(b, M.props.ref),
|
|
69
|
+
onClick: (e) => {
|
|
70
|
+
M.props.onClick?.(e), O(!T);
|
|
71
|
+
},
|
|
72
|
+
"aria-haspopup": "menu",
|
|
73
|
+
"aria-expanded": T
|
|
74
|
+
});
|
|
75
|
+
return /* @__PURE__ */ c("div", {
|
|
76
|
+
ref: y,
|
|
77
|
+
className: e.root,
|
|
78
|
+
children: [N, /* @__PURE__ */ s("div", {
|
|
79
|
+
ref: x,
|
|
80
|
+
popover: "auto",
|
|
81
|
+
role: "menu",
|
|
82
|
+
"data-placement": m,
|
|
83
|
+
"data-state": T ? "open" : "closed",
|
|
84
|
+
className: e.menu,
|
|
85
|
+
onKeyDown: j,
|
|
86
|
+
children: f.map((t, n) => t.separator ? /* @__PURE__ */ s("div", {
|
|
87
|
+
role: "separator",
|
|
88
|
+
className: e.separator
|
|
89
|
+
}, `sep-${n}`) : /* @__PURE__ */ c("button", {
|
|
90
|
+
type: "button",
|
|
91
|
+
role: "menuitem",
|
|
92
|
+
ref: (e) => {
|
|
93
|
+
S.current[n] = e;
|
|
94
|
+
},
|
|
95
|
+
tabIndex: C.value === n ? 0 : -1,
|
|
96
|
+
disabled: t.disabled,
|
|
97
|
+
className: e.item,
|
|
98
|
+
onClick: () => k(n),
|
|
99
|
+
children: [t.icon && /* @__PURE__ */ s("span", {
|
|
100
|
+
className: e.icon,
|
|
101
|
+
"aria-hidden": "true",
|
|
102
|
+
children: t.icon
|
|
103
|
+
}), t.label]
|
|
104
|
+
}, t.value))
|
|
105
|
+
})]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { f as Dropdown };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./editable.module.js";
|
|
4
|
+
import { cn as t, useSignal as n, useSignalEffect as r, useSignals as i } from "@cascivo/core";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { useRef as s } from "react";
|
|
7
|
+
//#region ../components/src/editable/editable.tsx
|
|
8
|
+
function c({ value: c, onValueChange: l, placeholder: u, disabled: d = !1, submitOnBlur: f = !0, onCancel: p, className: m, ...h }) {
|
|
9
|
+
i();
|
|
10
|
+
let g = n(!1), _ = n(c), v = s(null), y = s(p);
|
|
11
|
+
y.current = p;
|
|
12
|
+
let b = s(l);
|
|
13
|
+
b.current = l, g.value || (_.value = c), r(() => {
|
|
14
|
+
if (g.value) {
|
|
15
|
+
let e = v.current;
|
|
16
|
+
e && (e.focus(), e.select());
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
function x() {
|
|
20
|
+
b.current(_.value), g.value = !1;
|
|
21
|
+
}
|
|
22
|
+
function S() {
|
|
23
|
+
_.value = c, g.value = !1, y.current?.();
|
|
24
|
+
}
|
|
25
|
+
return g.value ? /* @__PURE__ */ a("div", {
|
|
26
|
+
className: t(e.wrapper, e.editing, m),
|
|
27
|
+
...h,
|
|
28
|
+
children: /* @__PURE__ */ a("input", {
|
|
29
|
+
ref: v,
|
|
30
|
+
className: e.input,
|
|
31
|
+
value: _.value,
|
|
32
|
+
onChange: (e) => {
|
|
33
|
+
_.value = e.currentTarget.value;
|
|
34
|
+
},
|
|
35
|
+
onKeyDown: (e) => {
|
|
36
|
+
e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && (e.preventDefault(), S());
|
|
37
|
+
},
|
|
38
|
+
onBlur: () => {
|
|
39
|
+
f ? x() : S();
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
}) : /* @__PURE__ */ a("div", {
|
|
43
|
+
className: t(e.wrapper, m),
|
|
44
|
+
"data-disabled": d ? "" : void 0,
|
|
45
|
+
...h,
|
|
46
|
+
children: /* @__PURE__ */ o("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
className: e.preview,
|
|
49
|
+
disabled: d,
|
|
50
|
+
onClick: () => {
|
|
51
|
+
d || (g.value = !0);
|
|
52
|
+
},
|
|
53
|
+
children: [/* @__PURE__ */ a("span", {
|
|
54
|
+
className: e["preview-text"],
|
|
55
|
+
children: c || /* @__PURE__ */ a("span", {
|
|
56
|
+
className: e.placeholder,
|
|
57
|
+
children: u
|
|
58
|
+
})
|
|
59
|
+
}), /* @__PURE__ */ a("span", {
|
|
60
|
+
className: e["edit-icon"],
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
})]
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { c as Editable };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
var e = {
|
|
4
|
+
wrapper: "_wrapper_5e6r0_2",
|
|
5
|
+
preview: "_preview_5e6r0_8",
|
|
6
|
+
"preview-text": "_preview-text_5e6r0_42",
|
|
7
|
+
placeholder: "_placeholder_5e6r0_46",
|
|
8
|
+
"edit-icon": "_edit-icon_5e6r0_50",
|
|
9
|
+
editing: "_editing_5e6r0_69",
|
|
10
|
+
input: "_input_5e6r0_70"
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./empty-state.module.js";
|
|
4
|
+
import { cn as t } from "@cascivo/core";
|
|
5
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
6
|
+
//#region ../components/src/empty-state/empty-state.tsx
|
|
7
|
+
function i({ icon: i, title: a, description: o, action: s, size: c = "md", className: l, ...u }) {
|
|
8
|
+
return /* @__PURE__ */ r("div", {
|
|
9
|
+
"data-size": c,
|
|
10
|
+
className: t(e["empty-state"], l),
|
|
11
|
+
...u,
|
|
12
|
+
children: [
|
|
13
|
+
i && /* @__PURE__ */ n("span", {
|
|
14
|
+
className: e.icon,
|
|
15
|
+
"aria-hidden": "true",
|
|
16
|
+
children: i
|
|
17
|
+
}),
|
|
18
|
+
/* @__PURE__ */ n("h3", {
|
|
19
|
+
className: e.title,
|
|
20
|
+
children: a
|
|
21
|
+
}),
|
|
22
|
+
o && /* @__PURE__ */ n("p", {
|
|
23
|
+
className: e.description,
|
|
24
|
+
children: o
|
|
25
|
+
}),
|
|
26
|
+
s && /* @__PURE__ */ n("div", {
|
|
27
|
+
className: e.action,
|
|
28
|
+
children: s
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { i as EmptyState };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./fab.module.js";
|
|
4
|
+
import { DismissableLayer as t, Presence as n, cn as r, useControllableSignal as i, useRovingFocus as a, useSignalEffect as o, useSignals as s } from "@cascivo/core";
|
|
5
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
6
|
+
import { useId as u, useRef as d } from "react";
|
|
7
|
+
//#region ../components/src/fab/fab.tsx
|
|
8
|
+
function f({ children: f, label: p, onClick: m, actions: h, position: g = "bottom-end", open: _, defaultOpen: v, onOpenChange: y, className: b }) {
|
|
9
|
+
s();
|
|
10
|
+
let x = h != null && h.length > 0, [S, C] = i({
|
|
11
|
+
value: _,
|
|
12
|
+
defaultValue: v ?? !1,
|
|
13
|
+
onChange: y
|
|
14
|
+
}), w = a({
|
|
15
|
+
orientation: "vertical",
|
|
16
|
+
loop: !0
|
|
17
|
+
}), T = d(null), E = d(null), D = u(), O = d(!1);
|
|
18
|
+
o(() => {
|
|
19
|
+
let e = x && S.value;
|
|
20
|
+
e && !O.current ? E.current?.querySelector("[role=\"menuitem\"]:not([aria-disabled=\"true\"])")?.focus() : !e && O.current && T.current?.focus(), O.current = e;
|
|
21
|
+
});
|
|
22
|
+
let k = (e) => {
|
|
23
|
+
e.disabled || (e.onSelect(), C(!1));
|
|
24
|
+
}, A = /* @__PURE__ */ c("button", {
|
|
25
|
+
ref: T,
|
|
26
|
+
type: "button",
|
|
27
|
+
"aria-label": p,
|
|
28
|
+
className: e.fab,
|
|
29
|
+
...x ? {
|
|
30
|
+
"aria-haspopup": "menu",
|
|
31
|
+
"aria-expanded": S.value,
|
|
32
|
+
"aria-controls": D,
|
|
33
|
+
"data-state": S.value ? "open" : "closed",
|
|
34
|
+
onClick: () => C(!S.value)
|
|
35
|
+
} : { onClick: m },
|
|
36
|
+
children: /* @__PURE__ */ c("span", {
|
|
37
|
+
className: e.icon,
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
children: f
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
return x ? /* @__PURE__ */ c(t, {
|
|
43
|
+
onDismiss: () => C(!1),
|
|
44
|
+
escapeDismisses: S.value,
|
|
45
|
+
disableOutsidePointer: !S.value,
|
|
46
|
+
children: /* @__PURE__ */ l("div", {
|
|
47
|
+
className: r(e.root, b),
|
|
48
|
+
"data-position": g,
|
|
49
|
+
children: [/* @__PURE__ */ c(n, {
|
|
50
|
+
present: S,
|
|
51
|
+
children: /* @__PURE__ */ c("menu", {
|
|
52
|
+
ref: E,
|
|
53
|
+
id: D,
|
|
54
|
+
role: "menu",
|
|
55
|
+
"aria-label": p,
|
|
56
|
+
className: e.dial,
|
|
57
|
+
children: h.map((t, n) => {
|
|
58
|
+
let r = w.getItemProps(n);
|
|
59
|
+
return /* @__PURE__ */ c("li", {
|
|
60
|
+
role: "presentation",
|
|
61
|
+
className: e.dialItem,
|
|
62
|
+
children: /* @__PURE__ */ l("button", {
|
|
63
|
+
ref: r.ref,
|
|
64
|
+
type: "button",
|
|
65
|
+
role: "menuitem",
|
|
66
|
+
tabIndex: r.tabIndex,
|
|
67
|
+
"aria-disabled": t.disabled || void 0,
|
|
68
|
+
className: e.action,
|
|
69
|
+
onKeyDown: r.onKeyDown,
|
|
70
|
+
onFocus: r.onFocus,
|
|
71
|
+
onClick: () => k(t),
|
|
72
|
+
children: [/* @__PURE__ */ c("span", {
|
|
73
|
+
className: e.actionLabel,
|
|
74
|
+
children: t.label
|
|
75
|
+
}), /* @__PURE__ */ c("span", {
|
|
76
|
+
className: e.actionIcon,
|
|
77
|
+
"aria-hidden": "true",
|
|
78
|
+
children: t.icon
|
|
79
|
+
})]
|
|
80
|
+
})
|
|
81
|
+
}, t.id ?? n);
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
}), A]
|
|
85
|
+
})
|
|
86
|
+
}) : /* @__PURE__ */ c("div", {
|
|
87
|
+
className: r(e.root, b),
|
|
88
|
+
"data-position": g,
|
|
89
|
+
children: A
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { f as Fab };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
var e = {
|
|
4
|
+
root: "_root_142gl_2",
|
|
5
|
+
fab: "_fab_142gl_21",
|
|
6
|
+
icon: "_icon_142gl_48",
|
|
7
|
+
dial: "_dial_142gl_60",
|
|
8
|
+
dialItem: "_dialItem_142gl_91",
|
|
9
|
+
action: "_action_142gl_95",
|
|
10
|
+
actionLabel: "_actionLabel_142gl_129",
|
|
11
|
+
actionIcon: "_actionIcon_142gl_134"
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { e as default };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Label as e } from "../label/label.js";
|
|
4
|
+
import t from "./field.module.js";
|
|
5
|
+
import { cn as n, useId as r } from "@cascivo/core";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
import { Children as o, cloneElement as s, isValidElement as c } from "react";
|
|
8
|
+
//#region ../components/src/field/field.tsx
|
|
9
|
+
var l = /* @__PURE__ */ new Set();
|
|
10
|
+
function u() {
|
|
11
|
+
return globalThis.process?.env?.NODE_ENV !== "production";
|
|
12
|
+
}
|
|
13
|
+
function d(e, t) {
|
|
14
|
+
if (!u() || e == null || t.props.label == null) return;
|
|
15
|
+
let n = String(e);
|
|
16
|
+
l.has(n) || (l.add(n), console.warn(`cascivo Field: both the Field and its child control define a \`label\` (${n}). Omit the child's \`label\` inside a Field — it renders a second <label> for the same control. The Field owns the label.`));
|
|
17
|
+
}
|
|
18
|
+
function f({ label: l, description: u, error: f, required: p = !1, disabled: m = !1, id: h, children: g, className: _ }) {
|
|
19
|
+
let v = r("cascade-field"), y = h ?? v, b = `${y}-description`, x = `${y}-error`, S = [u ? b : null, f ? x : null].filter(Boolean).join(" ") || void 0, C = { id: y };
|
|
20
|
+
S && (C["aria-describedby"] = S), f && (C["aria-invalid"] = !0), (m || g.props.disabled) && (C.disabled = !0), c(g) && d(l, g);
|
|
21
|
+
let w = c(g) ? s(o.only(g), C) : g;
|
|
22
|
+
return /* @__PURE__ */ a("div", {
|
|
23
|
+
className: n(t.field, _),
|
|
24
|
+
"data-disabled": m ? "" : void 0,
|
|
25
|
+
children: [
|
|
26
|
+
l && /* @__PURE__ */ i(e, {
|
|
27
|
+
htmlFor: y,
|
|
28
|
+
required: p,
|
|
29
|
+
disabled: m,
|
|
30
|
+
children: l
|
|
31
|
+
}),
|
|
32
|
+
w,
|
|
33
|
+
u && /* @__PURE__ */ i("p", {
|
|
34
|
+
id: b,
|
|
35
|
+
className: t.description,
|
|
36
|
+
children: u
|
|
37
|
+
}),
|
|
38
|
+
f && /* @__PURE__ */ i("p", {
|
|
39
|
+
id: x,
|
|
40
|
+
role: "alert",
|
|
41
|
+
className: t.error,
|
|
42
|
+
children: f
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { f as Field };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Spinner as e } from "../spinner/spinner.js";
|
|
4
|
+
import t from "./file-uploader.module.js";
|
|
5
|
+
import { cn as n, useSignal as r, useSignals as i } from "@cascivo/core";
|
|
6
|
+
import { builtin as a, t as o } from "@cascivo/i18n";
|
|
7
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
8
|
+
import { useRef as l } from "react";
|
|
9
|
+
//#region ../components/src/file-uploader/file-uploader.tsx
|
|
10
|
+
function u(e, t) {
|
|
11
|
+
let n = t.split(",").map((e) => e.trim()).filter(Boolean);
|
|
12
|
+
return n.length === 0 ? !0 : n.some((t) => t.startsWith(".") ? e.name.toLowerCase().endsWith(t.toLowerCase()) : t.endsWith("/*") ? e.type.startsWith(t.slice(0, -1)) : e.type === t);
|
|
13
|
+
}
|
|
14
|
+
function d(e) {
|
|
15
|
+
return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : e >= 1024 ? `${(e / 1024).toFixed(1)} KB` : `${e} B`;
|
|
16
|
+
}
|
|
17
|
+
function f({ files: f = [], onFilesAdded: p, onRemove: m, multiple: h = !1, accept: g, maxSize: _, onRejected: v, label: y, hint: b, labels: x, disabled: S = !1, className: C }) {
|
|
18
|
+
i();
|
|
19
|
+
let w = l(null), T = r(!1), E = y ?? x?.label ?? o(a.fileUploader.label), D = x?.drop ?? o(a.fileUploader.drop), O = x?.uploading ?? o(a.fileUploader.uploading), k = x?.complete ?? o(a.fileUploader.complete), A = x?.error ?? o(a.fileUploader.error), j = (e) => x?.remove ? x.remove.replace("{name}", e) : o(a.fileUploader.remove, { name: e }), M = `cascade-uploader-${E.toLowerCase().replace(/\s+/g, "-")}`, N = `${M}-label`, P = `${M}-hint`, F = (e) => {
|
|
20
|
+
if (!e || e.length === 0) return;
|
|
21
|
+
let t = h ? Array.from(e) : Array.from(e).slice(0, 1), n = [], r = [], i = [];
|
|
22
|
+
for (let e of t) g && !u(e, g) ? r.push(e) : _ !== void 0 && e.size > _ ? i.push(e) : n.push(e);
|
|
23
|
+
r.length > 0 && v?.(r, "type"), i.length > 0 && v?.(i, "size"), n.length > 0 && p?.(n);
|
|
24
|
+
};
|
|
25
|
+
return /* @__PURE__ */ c("div", {
|
|
26
|
+
className: n(t.uploader, C),
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ s("span", {
|
|
29
|
+
id: N,
|
|
30
|
+
className: t.label,
|
|
31
|
+
children: E
|
|
32
|
+
}),
|
|
33
|
+
/* @__PURE__ */ s("input", {
|
|
34
|
+
ref: w,
|
|
35
|
+
type: "file",
|
|
36
|
+
className: t.input,
|
|
37
|
+
tabIndex: -1,
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
multiple: h,
|
|
40
|
+
accept: g,
|
|
41
|
+
disabled: S,
|
|
42
|
+
onChange: (e) => {
|
|
43
|
+
F(e.target.files), e.target.value = "";
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
/* @__PURE__ */ s("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
className: t.zone,
|
|
49
|
+
"data-state": T.value ? "dragover" : "idle",
|
|
50
|
+
disabled: S,
|
|
51
|
+
"aria-describedby": b ? `${N} ${P}` : N,
|
|
52
|
+
onClick: () => w.current?.click(),
|
|
53
|
+
onDragEnter: (e) => {
|
|
54
|
+
e.preventDefault(), S || (T.value = !0);
|
|
55
|
+
},
|
|
56
|
+
onDragOver: (e) => e.preventDefault(),
|
|
57
|
+
onDragLeave: () => {
|
|
58
|
+
T.value = !1;
|
|
59
|
+
},
|
|
60
|
+
onDrop: (e) => {
|
|
61
|
+
e.preventDefault(), T.value = !1, !S && F(e.dataTransfer.files);
|
|
62
|
+
},
|
|
63
|
+
children: D
|
|
64
|
+
}),
|
|
65
|
+
b && /* @__PURE__ */ s("span", {
|
|
66
|
+
id: P,
|
|
67
|
+
className: t.hint,
|
|
68
|
+
children: b
|
|
69
|
+
}),
|
|
70
|
+
f.length > 0 && /* @__PURE__ */ s("ul", {
|
|
71
|
+
className: t.list,
|
|
72
|
+
"aria-live": "polite",
|
|
73
|
+
children: f.map((n) => /* @__PURE__ */ c("li", {
|
|
74
|
+
className: t.file,
|
|
75
|
+
"data-state": n.status,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ c("span", {
|
|
78
|
+
className: t.status,
|
|
79
|
+
children: [
|
|
80
|
+
n.status === "uploading" && /* @__PURE__ */ s(e, {
|
|
81
|
+
size: "sm",
|
|
82
|
+
label: O
|
|
83
|
+
}),
|
|
84
|
+
n.status === "complete" && /* @__PURE__ */ s("span", {
|
|
85
|
+
className: t["glyph-complete"],
|
|
86
|
+
"aria-label": k,
|
|
87
|
+
children: "✓"
|
|
88
|
+
}),
|
|
89
|
+
n.status === "error" && /* @__PURE__ */ s("span", {
|
|
90
|
+
className: t["glyph-error"],
|
|
91
|
+
"aria-label": A,
|
|
92
|
+
children: "✕"
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ s("span", {
|
|
97
|
+
className: t.name,
|
|
98
|
+
children: n.name
|
|
99
|
+
}),
|
|
100
|
+
n.size !== void 0 && /* @__PURE__ */ s("span", {
|
|
101
|
+
className: t.size,
|
|
102
|
+
children: d(n.size)
|
|
103
|
+
}),
|
|
104
|
+
/* @__PURE__ */ s("button", {
|
|
105
|
+
type: "button",
|
|
106
|
+
className: t.remove,
|
|
107
|
+
"aria-label": j(n.name),
|
|
108
|
+
onClick: () => m?.(n.id),
|
|
109
|
+
children: "✕"
|
|
110
|
+
}),
|
|
111
|
+
n.status === "error" && n.errorMessage && /* @__PURE__ */ s("span", {
|
|
112
|
+
className: t["error-message"],
|
|
113
|
+
children: n.errorMessage
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
}, n.id))
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { f as FileUploader };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
var e = {
|
|
4
|
+
uploader: "_uploader_bw6tn_2",
|
|
5
|
+
label: "_label_bw6tn_9",
|
|
6
|
+
input: "_input_bw6tn_15",
|
|
7
|
+
zone: "_zone_bw6tn_24",
|
|
8
|
+
hint: "_hint_bw6tn_57",
|
|
9
|
+
list: "_list_bw6tn_62",
|
|
10
|
+
file: "_file_bw6tn_71",
|
|
11
|
+
status: "_status_bw6tn_88",
|
|
12
|
+
"glyph-complete": "_glyph-complete_bw6tn_94",
|
|
13
|
+
"glyph-error": "_glyph-error_bw6tn_98",
|
|
14
|
+
name: "_name_bw6tn_102",
|
|
15
|
+
size: "_size_bw6tn_109",
|
|
16
|
+
remove: "_remove_bw6tn_115",
|
|
17
|
+
"error-message": "_error-message_bw6tn_135"
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { e as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./filter.module.js";
|
|
4
|
+
import { useControllableSignal as t, useSignals as n } from "@cascivo/core";
|
|
5
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
6
|
+
//#region ../components/src/filter/filter.tsx
|
|
7
|
+
function i({ options: i, value: a, defaultValue: o = [], onValueChange: s, onChange: c, multi: l = !1, variant: u = "pill", className: d, ...f }) {
|
|
8
|
+
n();
|
|
9
|
+
let [p, m] = t({
|
|
10
|
+
value: a,
|
|
11
|
+
defaultValue: o,
|
|
12
|
+
onChange: s ?? c
|
|
13
|
+
});
|
|
14
|
+
function h(e) {
|
|
15
|
+
let t = p.value, n;
|
|
16
|
+
n = l ? t.includes(e) ? t.filter((t) => t !== e) : [...t, e] : t.includes(e) ? [] : [e], m(n);
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ r("div", {
|
|
19
|
+
role: "group",
|
|
20
|
+
className: [e.filter, d].filter(Boolean).join(" "),
|
|
21
|
+
"data-variant": u,
|
|
22
|
+
...f,
|
|
23
|
+
children: i.map((t) => /* @__PURE__ */ r("button", {
|
|
24
|
+
type: "button",
|
|
25
|
+
className: e.item,
|
|
26
|
+
"data-selected": p.value.includes(t.value) || void 0,
|
|
27
|
+
onClick: () => h(t.value),
|
|
28
|
+
"aria-pressed": p.value.includes(t.value),
|
|
29
|
+
children: t.label
|
|
30
|
+
}, t.value))
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { i as Filter };
|