tembro 6.0.3 → 6.1.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/CHANGELOG.md +13 -0
- package/dist/components/actions/action-menu.d.ts +11 -1
- package/dist/components/calendar/calendar-range-scheduler.cjs +1 -0
- package/dist/components/calendar/calendar-range-scheduler.d.ts +20 -0
- package/dist/components/calendar/calendar-range-scheduler.js +1 -0
- package/dist/components/calendar/date-time-picker.cjs +1 -0
- package/dist/components/calendar/date-time-picker.d.ts +15 -0
- package/dist/components/calendar/date-time-picker.js +1 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/charts/chart-card.cjs +1 -0
- package/dist/components/charts/chart-card.d.ts +24 -0
- package/dist/components/charts/chart-card.js +1 -0
- package/dist/components/charts/index.d.ts +1 -0
- package/dist/components/command/advanced-command-menu.cjs +1 -0
- package/dist/components/command/advanced-command-menu.d.ts +25 -0
- package/dist/components/command/advanced-command-menu.js +1 -0
- package/dist/components/command/index.d.ts +1 -0
- package/dist/components/data-table/data-grid.cjs +1 -0
- package/dist/components/data-table/data-grid.d.ts +15 -0
- package/dist/components/data-table/data-grid.js +1 -0
- package/dist/components/data-table/index.d.ts +1 -0
- package/dist/components/data-table/public.d.ts +1 -0
- package/dist/components/display/index.d.ts +0 -2
- package/dist/components/feedback/async-boundary.cjs +1 -0
- package/dist/components/feedback/async-boundary.d.ts +12 -0
- package/dist/components/feedback/async-boundary.js +1 -0
- package/dist/components/feedback/index.d.ts +1 -0
- package/dist/components/filters/index.d.ts +0 -1
- package/dist/components/inputs/index.d.ts +1 -0
- package/dist/components/inputs/multi-select.cjs +1 -0
- package/dist/components/inputs/multi-select.d.ts +16 -0
- package/dist/components/inputs/multi-select.js +1 -0
- package/dist/components/inputs/public.d.ts +1 -0
- package/dist/components/inputs/time-picker.d.ts +11 -3
- package/dist/components/modern/file-manager.cjs +1 -0
- package/dist/components/modern/file-manager.d.ts +20 -0
- package/dist/components/modern/file-manager.js +1 -0
- package/dist/components/modern/index.d.ts +4 -1
- package/dist/components/modern/map.cjs +1 -0
- package/dist/components/modern/map.d.ts +29 -0
- package/dist/components/modern/map.js +1 -0
- package/dist/components/modern/media-player.cjs +1 -0
- package/dist/components/modern/media-player.d.ts +21 -0
- package/dist/components/modern/media-player.js +1 -0
- package/dist/components/modern/spreadsheet.cjs +1 -0
- package/dist/components/modern/spreadsheet.d.ts +35 -0
- package/dist/components/modern/spreadsheet.js +1 -0
- package/dist/components/notifications/action-toast.cjs +1 -0
- package/dist/components/notifications/action-toast.d.ts +16 -0
- package/dist/components/notifications/action-toast.js +1 -0
- package/dist/components/notifications/index.d.ts +1 -0
- package/dist/components/overlay/drawer.d.ts +3 -1
- package/dist/components/patterns/index.d.ts +1 -0
- package/dist/components/patterns/permissions-matrix.cjs +1 -0
- package/dist/components/patterns/permissions-matrix.d.ts +19 -0
- package/dist/components/patterns/permissions-matrix.js +1 -0
- package/dist/components/patterns/public.d.ts +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/src/components/actions/action-menu.cjs +1 -1
- package/dist/src/components/actions/action-menu.js +47 -39
- package/dist/src/components/actions/copy-button.cjs +1 -1
- package/dist/src/components/actions/copy-button.js +4 -1
- package/dist/src/components/calendar/calendar-range-scheduler.cjs +1 -0
- package/dist/src/components/calendar/calendar-range-scheduler.js +75 -0
- package/dist/src/components/calendar/date-picker.cjs +1 -1
- package/dist/src/components/calendar/date-picker.js +5 -8
- package/dist/src/components/calendar/date-range-picker.cjs +1 -1
- package/dist/src/components/calendar/date-range-picker.js +12 -27
- package/dist/src/components/calendar/date-time-picker.cjs +1 -0
- package/dist/src/components/calendar/date-time-picker.js +36 -0
- package/dist/src/components/calendar/index.cjs +1 -1
- package/dist/src/components/calendar/index.js +5 -3
- package/dist/src/components/charts/chart-card.cjs +1 -0
- package/dist/src/components/charts/chart-card.js +55 -0
- package/dist/src/components/charts/index.cjs +1 -1
- package/dist/src/components/charts/index.js +3 -2
- package/dist/src/components/command/advanced-command-menu.cjs +1 -0
- package/dist/src/components/command/advanced-command-menu.js +57 -0
- package/dist/src/components/command/index.cjs +1 -1
- package/dist/src/components/command/index.js +3 -2
- package/dist/src/components/data-table/data-grid.cjs +1 -0
- package/dist/src/components/data-table/data-grid.js +32 -0
- package/dist/src/components/data-table/data-table-saved-filters.cjs +1 -1
- package/dist/src/components/data-table/data-table-saved-filters.js +11 -11
- package/dist/src/components/data-table/data-table.cjs +1 -1
- package/dist/src/components/data-table/data-table.js +175 -174
- package/dist/src/components/data-table/index.cjs +1 -1
- package/dist/src/components/data-table/index.js +15 -14
- package/dist/src/components/data-table/public.cjs +1 -1
- package/dist/src/components/data-table/public.js +3 -2
- package/dist/src/components/display/index.cjs +1 -1
- package/dist/src/components/display/index.js +9 -11
- package/dist/src/components/feedback/async-boundary.cjs +1 -0
- package/dist/src/components/feedback/async-boundary.js +22 -0
- package/dist/src/components/feedback/index.cjs +1 -1
- package/dist/src/components/feedback/index.js +2 -1
- package/dist/src/components/filters/index.cjs +1 -1
- package/dist/src/components/filters/index.js +2 -3
- package/dist/src/components/inputs/color-picker.cjs +1 -1
- package/dist/src/components/inputs/color-picker.js +63 -46
- package/dist/src/components/inputs/index.cjs +1 -1
- package/dist/src/components/inputs/index.js +13 -12
- package/dist/src/components/inputs/multi-select.cjs +1 -0
- package/dist/src/components/inputs/multi-select.js +80 -0
- package/dist/src/components/inputs/public.cjs +1 -1
- package/dist/src/components/inputs/public.js +13 -12
- package/dist/src/components/inputs/slider.cjs +1 -1
- package/dist/src/components/inputs/slider.js +3 -3
- package/dist/src/components/inputs/tag-input.cjs +1 -1
- package/dist/src/components/inputs/tag-input.js +7 -4
- package/dist/src/components/inputs/time-picker.cjs +1 -1
- package/dist/src/components/inputs/time-picker.js +90 -34
- package/dist/src/components/modern/file-manager.cjs +1 -0
- package/dist/src/components/modern/file-manager.js +75 -0
- package/dist/src/components/modern/index.cjs +1 -1
- package/dist/src/components/modern/index.js +7 -4
- package/dist/src/components/modern/map.cjs +1 -0
- package/dist/src/components/modern/map.js +158 -0
- package/dist/src/components/modern/media-player.cjs +1 -0
- package/dist/src/components/modern/media-player.js +176 -0
- package/dist/src/components/modern/resizable-panel.cjs +1 -1
- package/dist/src/components/modern/resizable-panel.js +39 -32
- package/dist/src/components/modern/spreadsheet.cjs +1 -0
- package/dist/src/components/modern/spreadsheet.js +97 -0
- package/dist/src/components/navigation/pagination.cjs +1 -1
- package/dist/src/components/navigation/pagination.js +5 -5
- package/dist/src/components/notifications/action-toast.cjs +1 -0
- package/dist/src/components/notifications/action-toast.js +49 -0
- package/dist/src/components/notifications/index.cjs +1 -1
- package/dist/src/components/notifications/index.js +3 -2
- package/dist/src/components/notifications/toast.cjs +1 -1
- package/dist/src/components/notifications/toast.js +68 -63
- package/dist/src/components/overlay/alert-dialog.cjs +1 -1
- package/dist/src/components/overlay/alert-dialog.js +8 -6
- package/dist/src/components/overlay/drawer.cjs +1 -1
- package/dist/src/components/overlay/drawer.js +38 -20
- package/dist/src/components/patterns/index.cjs +1 -1
- package/dist/src/components/patterns/index.js +2 -1
- package/dist/src/components/patterns/permissions-matrix.cjs +1 -0
- package/dist/src/components/patterns/permissions-matrix.js +43 -0
- package/dist/src/components/patterns/public.cjs +1 -1
- package/dist/src/components/patterns/public.js +2 -1
- package/dist/src/components/ui/checkbox/index.cjs +1 -1
- package/dist/src/components/ui/checkbox/index.js +2 -1
- package/dist/src/components/ui/dialog/index.cjs +1 -1
- package/dist/src/components/ui/dialog/index.js +8 -8
- package/dist/src/components/ui/dropdown-menu/index.cjs +1 -1
- package/dist/src/components/ui/dropdown-menu/index.js +21 -19
- package/dist/src/components/ui/input/group.cjs +1 -1
- package/dist/src/components/ui/input/group.js +8 -8
- package/dist/src/components/ui/popover/index.cjs +1 -1
- package/dist/src/components/ui/popover/index.js +10 -10
- package/dist/src/components/ui/tabs/index.cjs +1 -1
- package/dist/src/components/ui/tabs/index.js +6 -6
- package/dist/src/components/ui/toggle-group/index.cjs +1 -1
- package/dist/src/components/ui/toggle-group/index.js +2 -2
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.js +111 -104
- package/dist/src/public-component-surface.cjs +1 -1
- package/dist/src/public-component-surface.js +59 -14
- package/package.json +1 -2
- package/packages/cli/dist/index.cjs +45 -165
- package/packages/cli/vendor/src/components/actions/action-menu.tsx +47 -19
- package/packages/cli/vendor/src/components/actions/copy-button.tsx +2 -2
- package/packages/cli/vendor/src/components/calendar/calendar-range-scheduler.tsx +72 -0
- package/packages/cli/vendor/src/components/calendar/date-picker.tsx +2 -5
- package/packages/cli/vendor/src/components/calendar/date-range-picker.tsx +5 -12
- package/packages/cli/vendor/src/components/calendar/date-time-picker.tsx +53 -0
- package/packages/cli/vendor/src/components/calendar/index.ts +5 -3
- package/packages/cli/vendor/src/components/charts/chart-card.tsx +81 -0
- package/packages/cli/vendor/src/components/charts/index.ts +1 -0
- package/packages/cli/vendor/src/components/command/advanced-command-menu.tsx +88 -0
- package/packages/cli/vendor/src/components/command/index.ts +2 -1
- package/packages/cli/vendor/src/components/data-table/data-grid.tsx +59 -0
- package/packages/cli/vendor/src/components/data-table/data-table.tsx +45 -34
- package/packages/cli/vendor/src/components/data-table/index.ts +3 -2
- package/packages/cli/vendor/src/components/data-table/public.ts +1 -0
- package/packages/cli/vendor/src/components/display/index.ts +3 -5
- package/packages/cli/vendor/src/components/feedback/async-boundary.tsx +36 -0
- package/packages/cli/vendor/src/components/feedback/index.ts +1 -0
- package/packages/cli/vendor/src/components/filters/index.ts +0 -1
- package/packages/cli/vendor/src/components/inputs/color-picker.tsx +15 -1
- package/packages/cli/vendor/src/components/inputs/index.ts +1 -0
- package/packages/cli/vendor/src/components/inputs/multi-select.tsx +75 -0
- package/packages/cli/vendor/src/components/inputs/public.ts +1 -0
- package/packages/cli/vendor/src/components/inputs/slider.tsx +3 -3
- package/packages/cli/vendor/src/components/inputs/tag-input.tsx +4 -4
- package/packages/cli/vendor/src/components/inputs/time-picker.tsx +91 -38
- package/packages/cli/vendor/src/components/modern/file-manager.tsx +79 -0
- package/packages/cli/vendor/src/components/modern/index.ts +4 -1
- package/packages/cli/vendor/src/components/modern/map.tsx +146 -0
- package/packages/cli/vendor/src/components/modern/media-player.tsx +182 -0
- package/packages/cli/vendor/src/components/modern/resizable-panel.tsx +15 -5
- package/packages/cli/vendor/src/components/modern/spreadsheet.tsx +155 -0
- package/packages/cli/vendor/src/components/navigation/pagination.tsx +9 -5
- package/packages/cli/vendor/src/components/notifications/action-toast.tsx +78 -0
- package/packages/cli/vendor/src/components/notifications/index.ts +2 -1
- package/packages/cli/vendor/src/components/notifications/toast.tsx +20 -10
- package/packages/cli/vendor/src/components/overlay/alert-dialog.tsx +3 -5
- package/packages/cli/vendor/src/components/overlay/drawer.tsx +22 -11
- package/packages/cli/vendor/src/components/patterns/index.ts +1 -0
- package/packages/cli/vendor/src/components/patterns/permissions-matrix.tsx +71 -0
- package/packages/cli/vendor/src/components/patterns/public.ts +1 -0
- package/packages/cli/vendor/src/components/ui/checkbox/index.tsx +3 -1
- package/packages/cli/vendor/src/components/ui/dialog/index.tsx +4 -4
- package/packages/cli/vendor/src/components/ui/dropdown-menu/index.tsx +18 -22
- package/packages/cli/vendor/src/components/ui/popover/index.tsx +4 -4
- package/packages/cli/vendor/src/components/ui/tabs/index.tsx +8 -3
- package/packages/cli/vendor/src/components/ui/toggle-group/index.tsx +6 -6
- package/packages/cli/vendor/src/index.ts +0 -2
- package/packages/cli/vendor/src/public-component-surface.ts +13 -4
- package/packages/cli/vendor/templates/showcase/src/showcase/data/registry.ts +6 -6
- package/packages/cli/vendor/templates/showcase/src/showcase/layout/HeroSection.tsx +23 -8
- package/packages/cli/vendor/templates/showcase/src/showcase/layout/WorkbenchSidebar.tsx +1 -1
- package/packages/cli/vendor/templates/showcase/src/showcase/sections/PatternsSection.tsx +1 -1
- package/packages/cli/vendor/templates/styles/globals.css +0 -120
- package/registry.json +3197 -2794
- package/dist/components/display/info-card.cjs +0 -1
- package/dist/components/display/info-card.d.ts +0 -51
- package/dist/components/display/info-card.js +0 -1
- package/dist/components/display/statistic.cjs +0 -1
- package/dist/components/display/statistic.d.ts +0 -25
- package/dist/components/display/statistic.js +0 -1
- package/dist/components/filters/filter-bar.cjs +0 -1
- package/dist/components/filters/filter-bar.d.ts +0 -28
- package/dist/components/filters/filter-bar.js +0 -1
- package/dist/components/modern/image-cropper.cjs +0 -1
- package/dist/components/modern/image-cropper.d.ts +0 -39
- package/dist/components/modern/image-cropper.js +0 -1
- package/dist/components/ui/number-field/index.cjs +0 -1
- package/dist/components/ui/number-field/index.d.ts +0 -18
- package/dist/components/ui/number-field/index.js +0 -1
- package/dist/components/ui/toolbar/index.cjs +0 -1
- package/dist/components/ui/toolbar/index.d.ts +0 -14
- package/dist/components/ui/toolbar/index.js +0 -1
- package/dist/src/components/display/info-card.cjs +0 -1
- package/dist/src/components/display/info-card.js +0 -124
- package/dist/src/components/display/statistic.cjs +0 -1
- package/dist/src/components/display/statistic.js +0 -104
- package/dist/src/components/filters/filter-bar.cjs +0 -1
- package/dist/src/components/filters/filter-bar.js +0 -103
- package/dist/src/components/modern/image-cropper.cjs +0 -1
- package/dist/src/components/modern/image-cropper.js +0 -143
- package/dist/src/components/ui/number-field/index.cjs +0 -1
- package/dist/src/components/ui/number-field/index.js +0 -73
- package/dist/src/components/ui/toolbar/index.cjs +0 -1
- package/dist/src/components/ui/toolbar/index.js +0 -50
- package/packages/cli/vendor/src/components/display/info-card.tsx +0 -195
- package/packages/cli/vendor/src/components/display/statistic.tsx +0 -114
- package/packages/cli/vendor/src/components/filters/filter-bar.tsx +0 -163
- package/packages/cli/vendor/src/components/modern/image-cropper.tsx +0 -226
- package/packages/cli/vendor/src/components/ui/number-field/index.tsx +0 -89
- package/packages/cli/vendor/src/components/ui/toolbar/index.tsx +0 -67
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/utils.js";
|
|
3
3
|
import * as t from "react";
|
|
4
4
|
import { GripVerticalIcon as n } from "lucide-react";
|
|
5
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/modern/resizable-panel.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
7
|
+
var a = t.createContext(null);
|
|
8
|
+
function o(e) {
|
|
9
9
|
if (typeof e == "number") return e;
|
|
10
10
|
if (typeof e == "string") {
|
|
11
11
|
let t = Number.parseFloat(e.replace("%", ""));
|
|
12
12
|
return Number.isFinite(t) ? t : void 0;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
let d = t.useRef(null), f = t.Children.toArray(
|
|
17
|
-
let e = f.map((e) =>
|
|
15
|
+
function s({ direction: n = "horizontal", className: i, children: s, ...u }) {
|
|
16
|
+
let d = t.useRef(null), f = t.Children.toArray(s).filter((e) => t.isValidElement(e) && e.type === c), p = f.length, m = t.useMemo(() => {
|
|
17
|
+
let e = f.map((e) => o(e.props.defaultSize)), t = e.reduce((e, t) => e + (t ?? 0), 0), n = e.filter((e) => e === void 0).length, r = Math.max(100 - t, 0), i = n > 0 ? r / n : p > 0 ? 100 / p : 100;
|
|
18
18
|
return e.map((e) => e ?? i);
|
|
19
19
|
}, [p, f]), h = t.useMemo(() => f.map((e) => e.props.minSize ?? 15), [f]), [g, _] = t.useState(m);
|
|
20
20
|
t.useEffect(() => {
|
|
@@ -34,19 +34,19 @@ function o({ direction: n = "horizontal", className: o, children: l, ...u }) {
|
|
|
34
34
|
n,
|
|
35
35
|
h,
|
|
36
36
|
p
|
|
37
|
-
]), y = t.Children.map(
|
|
37
|
+
]), y = t.Children.map(s, (e) => {
|
|
38
38
|
if (!t.isValidElement(e)) return e;
|
|
39
|
-
if (e.type ===
|
|
39
|
+
if (e.type === c) {
|
|
40
40
|
let n = f.findIndex((t) => t === e);
|
|
41
41
|
return t.cloneElement(e, { "data-panel-index": n });
|
|
42
42
|
}
|
|
43
|
-
if (e.type ===
|
|
44
|
-
let n = t.Children.toArray(
|
|
43
|
+
if (e.type === l) {
|
|
44
|
+
let n = t.Children.toArray(s).slice(0, t.Children.toArray(s).indexOf(e)).filter((e) => t.isValidElement(e) && e.type === c).length - 1;
|
|
45
45
|
return t.cloneElement(e, { "data-handle-index": n });
|
|
46
46
|
}
|
|
47
47
|
return e;
|
|
48
48
|
});
|
|
49
|
-
return /* @__PURE__ */ r(
|
|
49
|
+
return /* @__PURE__ */ r(a.Provider, {
|
|
50
50
|
value: {
|
|
51
51
|
direction: n,
|
|
52
52
|
getSize: (e) => g[e] ?? 100 / Math.max(p, 1),
|
|
@@ -56,58 +56,65 @@ function o({ direction: n = "horizontal", className: o, children: l, ...u }) {
|
|
|
56
56
|
ref: d,
|
|
57
57
|
"data-slot": "resizable-panel-group",
|
|
58
58
|
"data-direction": n,
|
|
59
|
-
className: e("flex
|
|
59
|
+
className: e("flex", n === "horizontal" ? "flex-row items-stretch" : "flex-col", i),
|
|
60
60
|
...u,
|
|
61
61
|
children: y
|
|
62
62
|
})
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
let u = t.useContext(
|
|
65
|
+
function c({ className: n, style: i, defaultSize: s, minSize: c, ...l }) {
|
|
66
|
+
let u = t.useContext(a), d = Number(l["data-panel-index"] ?? 0), f = u ? u.getSize(d) : o(s) ?? 100;
|
|
67
67
|
return /* @__PURE__ */ r("div", {
|
|
68
68
|
"data-slot": "resizable-panel",
|
|
69
|
-
className: e("min-h-24 overflow-auto rounded-lg border bg-card p-3", n),
|
|
69
|
+
className: e("min-h-24 min-w-0 overflow-auto rounded-[var(--aui-card-radius,var(--radius-lg))] border border-[color:var(--aui-card-border,var(--border))] bg-card p-3 shadow-[var(--aui-card-shadow,0_10px_24px_rgba(15,23,42,0.07))]", n),
|
|
70
70
|
style: {
|
|
71
71
|
flexBasis: `${f}%`,
|
|
72
72
|
flexGrow: 0,
|
|
73
73
|
flexShrink: 0,
|
|
74
|
-
...
|
|
74
|
+
...i
|
|
75
75
|
},
|
|
76
76
|
...l
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
let
|
|
81
|
-
return /* @__PURE__ */
|
|
79
|
+
function l({ className: o, ...s }) {
|
|
80
|
+
let c = t.useContext(a), l = Number(s["data-handle-index"] ?? 0), u = t.useRef(null);
|
|
81
|
+
return /* @__PURE__ */ i("button", {
|
|
82
82
|
type: "button",
|
|
83
83
|
"data-slot": "resizable-handle",
|
|
84
84
|
"aria-label": "Resize panels",
|
|
85
|
-
|
|
85
|
+
"aria-orientation": c?.direction ?? "horizontal",
|
|
86
|
+
className: e("group relative flex shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", c?.direction === "horizontal" ? "w-4 cursor-col-resize px-1" : "h-4 cursor-row-resize py-1", o),
|
|
86
87
|
onPointerDown: (e) => {
|
|
87
|
-
|
|
88
|
+
c && (u.current = {
|
|
88
89
|
pointerId: e.pointerId,
|
|
89
|
-
axis:
|
|
90
|
+
axis: c.direction === "horizontal" ? e.clientX : e.clientY
|
|
90
91
|
}, e.currentTarget.setPointerCapture(e.pointerId));
|
|
91
92
|
},
|
|
92
93
|
onPointerMove: (e) => {
|
|
93
|
-
if (!
|
|
94
|
-
let t =
|
|
95
|
-
n !== 0 && (
|
|
94
|
+
if (!c || !u.current || u.current.pointerId !== e.pointerId) return;
|
|
95
|
+
let t = c.direction === "horizontal" ? e.clientX : e.clientY, n = t - u.current.axis;
|
|
96
|
+
n !== 0 && (u.current.axis = t, c.resizePanels(l, n));
|
|
96
97
|
},
|
|
97
98
|
onPointerUp: (e) => {
|
|
98
|
-
|
|
99
|
+
u.current?.pointerId === e.pointerId && (u.current = null);
|
|
99
100
|
},
|
|
100
101
|
onPointerCancel: () => {
|
|
101
|
-
|
|
102
|
+
u.current = null;
|
|
102
103
|
},
|
|
103
104
|
onKeyDown: (e) => {
|
|
104
|
-
if (!
|
|
105
|
+
if (!c) return;
|
|
105
106
|
let t = e.shiftKey ? 24 : 12;
|
|
106
|
-
|
|
107
|
+
c.direction === "horizontal" && e.key === "ArrowLeft" && (e.preventDefault(), c.resizePanels(l, -t)), c.direction === "horizontal" && e.key === "ArrowRight" && (e.preventDefault(), c.resizePanels(l, t)), c.direction === "vertical" && e.key === "ArrowUp" && (e.preventDefault(), c.resizePanels(l, -t)), c.direction === "vertical" && e.key === "ArrowDown" && (e.preventDefault(), c.resizePanels(l, t));
|
|
107
108
|
},
|
|
108
|
-
...
|
|
109
|
-
children: /* @__PURE__ */ r(
|
|
109
|
+
...s,
|
|
110
|
+
children: [/* @__PURE__ */ r("span", {
|
|
111
|
+
"aria-hidden": "true",
|
|
112
|
+
className: e("absolute rounded-full bg-border transition-colors group-hover:bg-ring/55", c?.direction === "horizontal" ? "inset-y-2 left-1/2 w-px -translate-x-1/2" : "inset-x-2 top-1/2 h-px -translate-y-1/2")
|
|
113
|
+
}), /* @__PURE__ */ r("span", {
|
|
114
|
+
className: "relative grid size-5 place-items-center rounded-full border border-border/75 bg-background shadow-sm transition-colors group-hover:border-ring/45",
|
|
115
|
+
children: /* @__PURE__ */ r(n, { className: e("size-3", c?.direction === "vertical" && "rotate-90") })
|
|
116
|
+
})]
|
|
110
117
|
});
|
|
111
118
|
}
|
|
112
119
|
//#endregion
|
|
113
|
-
export {
|
|
120
|
+
export { l as ResizableHandle, c as ResizablePanel, s as ResizablePanelGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o(e){return e===`center`?`text-center`:e===`right`?`text-right`:`text-left`}function s(e,t){return{key:`row-${Date.now()}-${t}`,cells:Object.fromEntries(e.map(e=>[e.key,``]))}}function c({columns:e,rows:c,defaultRows:l=[],onRowsChange:u,onCellChange:d,selectedCell:f,defaultSelectedCell:p,onSelectedCellChange:m,readOnly:h=!1,showRowNumbers:g=!0,showAddRow:_=!0,addRowLabel:v=`Add row`,empty:y=`No rows yet.`,className:b,...x}){let[S,C]=r.useState(l),[w,T]=r.useState(p),E=c??S,D=f??w,O=(e,t)=>{c===void 0&&C(e),u?.(e,t)},k=e=>{f===void 0&&T(e),m?.(e)},A=(e,t)=>{let n=E.map(n=>n.key===e.rowKey?{...n,cells:{...n.cells,[e.columnKey]:t}}:n);O(n,e),d?.(t,e,n)},j=()=>{O([...E,s(e,E.length+1)])};return(0,a.jsxs)(`div`,{"data-slot":`spreadsheet`,className:t.cn(`grid min-w-0 gap-3 rounded-lg border bg-card p-3 shadow-sm`,b),...x,children:[(0,a.jsx)(`div`,{className:`overflow-auto rounded-lg border`,children:(0,a.jsxs)(`table`,{className:`w-full min-w-[48rem] border-collapse text-sm`,children:[(0,a.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted/80 backdrop-blur`,children:(0,a.jsxs)(`tr`,{children:[g?(0,a.jsx)(`th`,{className:`w-12 border-b border-r px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:`#`}):null,e.map(e=>(0,a.jsx)(`th`,{className:t.cn(`border-b border-r px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground last:border-r-0`,o(e.align)),style:{width:e.width},children:e.label},e.key))]})}),(0,a.jsx)(`tbody`,{children:E.length?E.map((n,r)=>(0,a.jsxs)(`tr`,{"data-readonly":n.readOnly||void 0,className:`odd:bg-background even:bg-muted/18`,children:[g?(0,a.jsx)(`th`,{className:`border-r px-3 py-1.5 text-left text-xs font-medium text-muted-foreground`,children:r+1}):null,e.map(e=>{let i={rowKey:n.key,columnKey:e.key},s=D?.rowKey===n.key&&D.columnKey===e.key,c=n.cells[e.key]??``,l=h||n.readOnly||e.readOnly;return(0,a.jsx)(`td`,{"data-selected":s||void 0,className:`border-r border-t p-0 last:border-r-0 data-[selected=true]:ring-2 data-[selected=true]:ring-inset data-[selected=true]:ring-primary/55`,children:l&&e.formatter?(0,a.jsx)(`div`,{className:t.cn(`min-h-10 px-3 py-2`,o(e.align)),children:e.formatter(c,n)}):(0,a.jsx)(`input`,{"aria-label":`${String(e.label)} row ${r+1}`,value:c,readOnly:l,className:t.cn(`h-10 w-full bg-transparent px-3 outline-none transition focus:bg-background read-only:cursor-default`,o(e.align)),onFocus:()=>k(i),onChange:e=>A(i,e.target.value)})},e.key)})]},n.key)):(0,a.jsx)(`tr`,{children:(0,a.jsx)(`td`,{colSpan:e.length+ +!!g,className:`h-32 text-center text-sm text-muted-foreground`,children:y})})})]})}),_&&!h?(0,a.jsx)(n.Button,{type:`button`,className:`w-fit`,variant:`outline`,size:`sm`,leftIcon:(0,a.jsx)(i.PlusIcon,{}),onClick:j,children:v}):null]})}exports.Spreadsheet=c;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../ui/button/index.js";
|
|
4
|
+
import * as n from "react";
|
|
5
|
+
import { PlusIcon as r } from "lucide-react";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/modern/spreadsheet.tsx
|
|
8
|
+
function o(e) {
|
|
9
|
+
return e === "center" ? "text-center" : e === "right" ? "text-right" : "text-left";
|
|
10
|
+
}
|
|
11
|
+
function s(e, t) {
|
|
12
|
+
return {
|
|
13
|
+
key: `row-${Date.now()}-${t}`,
|
|
14
|
+
cells: Object.fromEntries(e.map((e) => [e.key, ""]))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function c({ columns: c, rows: l, defaultRows: u = [], onRowsChange: d, onCellChange: f, selectedCell: p, defaultSelectedCell: m, onSelectedCellChange: h, readOnly: g = !1, showRowNumbers: _ = !0, showAddRow: v = !0, addRowLabel: y = "Add row", empty: b = "No rows yet.", className: x, ...S }) {
|
|
18
|
+
let [C, w] = n.useState(u), [T, E] = n.useState(m), D = l ?? C, O = p ?? T, k = (e, t) => {
|
|
19
|
+
l === void 0 && w(e), d?.(e, t);
|
|
20
|
+
}, A = (e) => {
|
|
21
|
+
p === void 0 && E(e), h?.(e);
|
|
22
|
+
}, j = (e, t) => {
|
|
23
|
+
let n = D.map((n) => n.key === e.rowKey ? {
|
|
24
|
+
...n,
|
|
25
|
+
cells: {
|
|
26
|
+
...n.cells,
|
|
27
|
+
[e.columnKey]: t
|
|
28
|
+
}
|
|
29
|
+
} : n);
|
|
30
|
+
k(n, e), f?.(t, e, n);
|
|
31
|
+
}, M = () => {
|
|
32
|
+
k([...D, s(c, D.length + 1)]);
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ a("div", {
|
|
35
|
+
"data-slot": "spreadsheet",
|
|
36
|
+
className: e("grid min-w-0 gap-3 rounded-lg border bg-card p-3 shadow-sm", x),
|
|
37
|
+
...S,
|
|
38
|
+
children: [/* @__PURE__ */ i("div", {
|
|
39
|
+
className: "overflow-auto rounded-lg border",
|
|
40
|
+
children: /* @__PURE__ */ a("table", {
|
|
41
|
+
className: "w-full min-w-[48rem] border-collapse text-sm",
|
|
42
|
+
children: [/* @__PURE__ */ i("thead", {
|
|
43
|
+
className: "sticky top-0 z-10 bg-muted/80 backdrop-blur",
|
|
44
|
+
children: /* @__PURE__ */ a("tr", { children: [_ ? /* @__PURE__ */ i("th", {
|
|
45
|
+
className: "w-12 border-b border-r px-3 py-2 text-left text-xs font-medium text-muted-foreground",
|
|
46
|
+
children: "#"
|
|
47
|
+
}) : null, c.map((t) => /* @__PURE__ */ i("th", {
|
|
48
|
+
className: e("border-b border-r px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground last:border-r-0", o(t.align)),
|
|
49
|
+
style: { width: t.width },
|
|
50
|
+
children: t.label
|
|
51
|
+
}, t.key))] })
|
|
52
|
+
}), /* @__PURE__ */ i("tbody", { children: D.length ? D.map((t, n) => /* @__PURE__ */ a("tr", {
|
|
53
|
+
"data-readonly": t.readOnly || void 0,
|
|
54
|
+
className: "odd:bg-background even:bg-muted/18",
|
|
55
|
+
children: [_ ? /* @__PURE__ */ i("th", {
|
|
56
|
+
className: "border-r px-3 py-1.5 text-left text-xs font-medium text-muted-foreground",
|
|
57
|
+
children: n + 1
|
|
58
|
+
}) : null, c.map((r) => {
|
|
59
|
+
let a = {
|
|
60
|
+
rowKey: t.key,
|
|
61
|
+
columnKey: r.key
|
|
62
|
+
}, s = O?.rowKey === t.key && O.columnKey === r.key, c = t.cells[r.key] ?? "", l = g || t.readOnly || r.readOnly;
|
|
63
|
+
return /* @__PURE__ */ i("td", {
|
|
64
|
+
"data-selected": s || void 0,
|
|
65
|
+
className: "border-r border-t p-0 last:border-r-0 data-[selected=true]:ring-2 data-[selected=true]:ring-inset data-[selected=true]:ring-primary/55",
|
|
66
|
+
children: l && r.formatter ? /* @__PURE__ */ i("div", {
|
|
67
|
+
className: e("min-h-10 px-3 py-2", o(r.align)),
|
|
68
|
+
children: r.formatter(c, t)
|
|
69
|
+
}) : /* @__PURE__ */ i("input", {
|
|
70
|
+
"aria-label": `${String(r.label)} row ${n + 1}`,
|
|
71
|
+
value: c,
|
|
72
|
+
readOnly: l,
|
|
73
|
+
className: e("h-10 w-full bg-transparent px-3 outline-none transition focus:bg-background read-only:cursor-default", o(r.align)),
|
|
74
|
+
onFocus: () => A(a),
|
|
75
|
+
onChange: (e) => j(a, e.target.value)
|
|
76
|
+
})
|
|
77
|
+
}, r.key);
|
|
78
|
+
})]
|
|
79
|
+
}, t.key)) : /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i("td", {
|
|
80
|
+
colSpan: c.length + +!!_,
|
|
81
|
+
className: "h-32 text-center text-sm text-muted-foreground",
|
|
82
|
+
children: b
|
|
83
|
+
}) }) })]
|
|
84
|
+
})
|
|
85
|
+
}), v && !g ? /* @__PURE__ */ i(t, {
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "w-fit",
|
|
88
|
+
variant: "outline",
|
|
89
|
+
size: "sm",
|
|
90
|
+
leftIcon: /* @__PURE__ */ i(r, {}),
|
|
91
|
+
onClick: M,
|
|
92
|
+
children: y
|
|
93
|
+
}) : null]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { c as Spreadsheet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o(e,t){let n=Math.max(t-e+1,0);return Array.from({length:n},(t,n)=>n+e)}function s(e,t,n=1){if(t<=n*2+5)return o(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,s=i<t-1;return!a&&s?[...o(1,n*2+3),`ellipsis`,t]:a&&!s?[1,`ellipsis`,...o(t-(n*2+3)+1,t)]:[1,`ellipsis`,...o(r,i),`ellipsis`,t]}function c({className:e,page:r,pageCount:o,onPageChange:c,siblingCount:l=1,showEdges:u=!0,disabled:d=!1,labels:f,compact:p=!1,totalCount:m,pageSize:h,pageSizeOptions:g,onPageSizeChange:_,showSummary:v=!1,...y}){let b=Math.max(o,1),x=Math.min(Math.max(r,1),b),S=s(x,b,l),C=e=>{let t=Math.min(Math.max(e,1),b);t!==x&&c(t)};return(0,a.jsxs)(`nav`,{"data-slot":`pagination`,"aria-label":`Pagination`,className:t.cn(`flex flex-wrap items-center justify-center gap-1 rounded-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o(e,t){let n=Math.max(t-e+1,0);return Array.from({length:n},(t,n)=>n+e)}function s(e,t,n=1){if(t<=n*2+5)return o(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,s=i<t-1;return!a&&s?[...o(1,n*2+3),`ellipsis`,t]:a&&!s?[1,`ellipsis`,...o(t-(n*2+3)+1,t)]:[1,`ellipsis`,...o(r,i),`ellipsis`,t]}function c({className:e,page:r,pageCount:o,onPageChange:c,siblingCount:l=1,showEdges:u=!0,disabled:d=!1,labels:f,compact:p=!1,totalCount:m,pageSize:h,pageSizeOptions:g,onPageSizeChange:_,showSummary:v=!1,...y}){let b=Math.max(o,1),x=Math.min(Math.max(r,1),b),S=s(x,b,l),C=e=>{let t=Math.min(Math.max(e,1),b);t!==x&&c(t)};return(0,a.jsxs)(`nav`,{"data-slot":`pagination`,"aria-label":`Pagination`,className:t.cn(`flex flex-wrap items-center justify-center gap-1.5 rounded-[var(--radius-lg)] border border-border/72 bg-background/84 p-1.5 shadow-[0_1px_2px_rgba(15,23,42,0.04)] backdrop-blur`,e),...y,children:[v&&m!==void 0&&h?(0,a.jsxs)(`div`,{className:`mr-1 rounded-[var(--radius-md)] bg-muted/55 px-2.5 py-1.5 text-xs font-medium text-muted-foreground`,children:[Math.min((x-1)*h+1,m),`-`,Math.min(x*h,m),` of `,m]}):null,u&&(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x<=1,"aria-label":f?.first??`First page`,onClick:()=>C(1),children:(0,a.jsx)(i.ChevronFirstIcon,{})}),(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x<=1,"aria-label":f?.previous??`Previous page`,onClick:()=>C(x-1),children:(0,a.jsx)(i.ChevronLeftIcon,{})}),S.map((e,r)=>e===`ellipsis`?(0,a.jsxs)(`span`,{"data-slot":`pagination-ellipsis`,className:`flex size-8 items-center justify-center text-muted-foreground`,children:[(0,a.jsx)(i.MoreHorizontalIcon,{className:`size-4`}),(0,a.jsx)(`span`,{className:`sr-only`,children:`More pages`})]},`ellipsis-${r}`):(0,a.jsx)(n.Button,{type:`button`,variant:e===x?`default`:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d,"aria-current":e===x?`page`:void 0,"aria-label":f?.page?.(e)??`Page ${e}`,onClick:()=>C(e),className:t.cn(`tabular-nums`,e===x&&`shadow-[0_8px_20px_rgba(15,23,42,0.14)]`,e!==x&&`border-border/70 bg-background/80 shadow-none hover:bg-muted/70`),children:e},e)),(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x>=b,"aria-label":f?.next??`Next page`,onClick:()=>C(x+1),children:(0,a.jsx)(i.ChevronRightIcon,{})}),u&&(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x>=b,"aria-label":f?.last??`Last page`,onClick:()=>C(b),children:(0,a.jsx)(i.ChevronLastIcon,{})}),g&&h&&_?(0,a.jsxs)(`label`,{className:`ml-1 inline-flex h-9 items-center gap-2 rounded-[var(--radius-md)] border border-border/70 bg-background/90 px-3 text-xs font-medium text-muted-foreground`,children:[(0,a.jsx)(`span`,{children:`Rows`}),(0,a.jsx)(`select`,{className:`rounded-sm bg-transparent text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:h,onChange:e=>_(Number(e.target.value)),disabled:d,children:g.map(e=>(0,a.jsx)(`option`,{value:e,children:e},e))})]}):null]})}exports.Pagination=c,exports.getPaginationItems=s;
|
|
@@ -35,11 +35,11 @@ function d({ className: l, page: d, pageCount: f, onPageChange: p, siblingCount:
|
|
|
35
35
|
return /* @__PURE__ */ c("nav", {
|
|
36
36
|
"data-slot": "pagination",
|
|
37
37
|
"aria-label": "Pagination",
|
|
38
|
-
className: e("flex flex-wrap items-center justify-center gap-1 rounded-
|
|
38
|
+
className: e("flex flex-wrap items-center justify-center gap-1.5 rounded-[var(--radius-lg)] border border-border/72 bg-background/84 p-1.5 shadow-[0_1px_2px_rgba(15,23,42,0.04)] backdrop-blur", l),
|
|
39
39
|
...w,
|
|
40
40
|
children: [
|
|
41
41
|
C && y !== void 0 && b ? /* @__PURE__ */ c("div", {
|
|
42
|
-
className: "px-2 text-xs text-muted-foreground",
|
|
42
|
+
className: "mr-1 rounded-[var(--radius-md)] bg-muted/55 px-2.5 py-1.5 text-xs font-medium text-muted-foreground",
|
|
43
43
|
children: [
|
|
44
44
|
Math.min((E - 1) * b + 1, y),
|
|
45
45
|
"-",
|
|
@@ -81,7 +81,7 @@ function d({ className: l, page: d, pageCount: f, onPageChange: p, siblingCount:
|
|
|
81
81
|
"aria-current": n === E ? "page" : void 0,
|
|
82
82
|
"aria-label": _?.page?.(n) ?? `Page ${n}`,
|
|
83
83
|
onClick: () => O(n),
|
|
84
|
-
className: e(n !== E && "border-border/70 bg-background/80 shadow-none"),
|
|
84
|
+
className: e("tabular-nums", n === E && "shadow-[0_8px_20px_rgba(15,23,42,0.14)]", n !== E && "border-border/70 bg-background/80 shadow-none hover:bg-muted/70"),
|
|
85
85
|
children: n
|
|
86
86
|
}, n)),
|
|
87
87
|
/* @__PURE__ */ s(t, {
|
|
@@ -103,9 +103,9 @@ function d({ className: l, page: d, pageCount: f, onPageChange: p, siblingCount:
|
|
|
103
103
|
children: /* @__PURE__ */ s(r, {})
|
|
104
104
|
}),
|
|
105
105
|
x && b && S ? /* @__PURE__ */ c("label", {
|
|
106
|
-
className: "ml-1 inline-flex items-center gap-2 rounded-
|
|
106
|
+
className: "ml-1 inline-flex h-9 items-center gap-2 rounded-[var(--radius-md)] border border-border/70 bg-background/90 px-3 text-xs font-medium text-muted-foreground",
|
|
107
107
|
children: [/* @__PURE__ */ s("span", { children: "Rows" }), /* @__PURE__ */ s("select", {
|
|
108
|
-
className: "bg-transparent text-foreground outline-none",
|
|
108
|
+
className: "rounded-sm bg-transparent text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
109
109
|
value: b,
|
|
110
110
|
onChange: (e) => S(Number(e.target.value)),
|
|
111
111
|
disabled: g,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../ui/button/index.cjs"),n=require("./toast.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o({toast:e,children:r,onClick:i,...o}){let s=n.useToast();return(0,a.jsx)(t.Button,{...o,onClick:t=>{i?.(t),!t.defaultPrevented&&c(s,e)},children:r})}function s({onUndo:e,label:n=`Undo`}){return(0,a.jsx)(t.Button,{type:`button`,size:`sm`,variant:`outline`,leftIcon:(0,a.jsx)(i.RotateCcwIcon,{className:`size-3.5`}),onClick:e,children:n})}function c(e,{actionLabel:n=`Action`,onAction:r,undoLabel:i,onUndo:o,...c}){let l=o?(0,a.jsx)(s,{onUndo:o,label:i}):r?(0,a.jsx)(t.Button,{type:`button`,size:`sm`,variant:`outline`,onClick:r,children:n}):void 0;return e.addToast({...c,action:l})}function l(){let e=n.useToast();return r.useCallback(t=>typeof t==`object`&&t&&!r.isValidElement(t)&&!Array.isArray(t)?c(e,t):e.info(t),[e])}exports.ActionToastButton=o,exports.showActionToast=c,exports.useActionToast=l;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Button as e } from "../ui/button/index.js";
|
|
3
|
+
import { useToast as t } from "./toast.js";
|
|
4
|
+
import * as n from "react";
|
|
5
|
+
import { RotateCcwIcon as r } from "lucide-react";
|
|
6
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/notifications/action-toast.tsx
|
|
8
|
+
function a({ toast: n, children: r, onClick: a, ...o }) {
|
|
9
|
+
let c = t();
|
|
10
|
+
return /* @__PURE__ */ i(e, {
|
|
11
|
+
...o,
|
|
12
|
+
onClick: (e) => {
|
|
13
|
+
a?.(e), !e.defaultPrevented && s(c, n);
|
|
14
|
+
},
|
|
15
|
+
children: r
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function o({ onUndo: t, label: n = "Undo" }) {
|
|
19
|
+
return /* @__PURE__ */ i(e, {
|
|
20
|
+
type: "button",
|
|
21
|
+
size: "sm",
|
|
22
|
+
variant: "outline",
|
|
23
|
+
leftIcon: /* @__PURE__ */ i(r, { className: "size-3.5" }),
|
|
24
|
+
onClick: t,
|
|
25
|
+
children: n
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function s(t, { actionLabel: n = "Action", onAction: r, undoLabel: a, onUndo: s, ...c }) {
|
|
29
|
+
let l = s ? /* @__PURE__ */ i(o, {
|
|
30
|
+
onUndo: s,
|
|
31
|
+
label: a
|
|
32
|
+
}) : r ? /* @__PURE__ */ i(e, {
|
|
33
|
+
type: "button",
|
|
34
|
+
size: "sm",
|
|
35
|
+
variant: "outline",
|
|
36
|
+
onClick: r,
|
|
37
|
+
children: n
|
|
38
|
+
}) : void 0;
|
|
39
|
+
return t.addToast({
|
|
40
|
+
...c,
|
|
41
|
+
action: l
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function c() {
|
|
45
|
+
let e = t();
|
|
46
|
+
return n.useCallback((t) => typeof t == "object" && t && !n.isValidElement(t) && !Array.isArray(t) ? s(e, t) : e.info(t), [e]);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { a as ActionToastButton, s as showActionToast, c as useActionToast };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./toast.cjs"),t=require("./notification-center.cjs");exports.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./toast.cjs"),t=require("./action-toast.cjs"),n=require("./notification-center.cjs");exports.ActionToastButton=t.ActionToastButton,exports.NotificationCenter=n.NotificationCenter,exports.ToastProvider=e.ToastProvider,exports.showActionToast=t.showActionToast,exports.useActionToast=t.useActionToast,exports.useToast=e.useToast;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ToastProvider as e, useToast as t } from "./toast.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ActionToastButton as n, showActionToast as r, useActionToast as i } from "./action-toast.js";
|
|
3
|
+
import { NotificationCenter as a } from "./notification-center.js";
|
|
4
|
+
export { n as ActionToastButton, a as NotificationCenter, e as ToastProvider, r as showActionToast, i as useActionToast, t as useToast };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");var
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime"),o=require("react-dom");var s=r.createContext(null),c={default:`border-border bg-popover text-popover-foreground`,success:`border-emerald-500/20 bg-emerald-500/10 text-emerald-950 dark:text-emerald-100`,info:`border-blue-500/20 bg-blue-500/10 text-blue-950 dark:text-blue-100`,warning:`border-amber-500/20 bg-amber-500/10 text-amber-950 dark:text-amber-100`,danger:`border-destructive/20 bg-destructive/10 text-destructive`,loading:`border-border bg-popover text-popover-foreground`},l={default:(0,a.jsx)(i.InfoIcon,{className:`size-4`}),success:(0,a.jsx)(i.CheckCircle2Icon,{className:`size-4`}),info:(0,a.jsx)(i.InfoIcon,{className:`size-4`}),warning:(0,a.jsx)(i.TriangleAlertIcon,{className:`size-4`}),danger:(0,a.jsx)(i.AlertCircleIcon,{className:`size-4`}),loading:(0,a.jsx)(i.Loader2Icon,{className:`size-4 animate-spin`})};function u(){return`toast-${Date.now()}-${Math.random().toString(16).slice(2)}`}function d(e){return typeof e==`object`&&!!e&&!r.isValidElement(e)&&!Array.isArray(e)}function f(e,t){return d(e)?{...e,tone:e.tone??t}:{title:e,tone:t}}function p(e,t){return typeof e==`function`?e(t):e}var m={"top-right":`right-4 top-4`,"top-left":`left-4 top-4`,"bottom-right":`bottom-4 right-4`,"bottom-left":`bottom-4 left-4`,"top-center":`left-1/2 top-4 -translate-x-1/2`,"bottom-center":`bottom-4 left-1/2 -translate-x-1/2`};function h({children:e,defaultDuration:n=4e3,maxToasts:i=5,pauseOnHover:c=!0,position:l=`top-right`}){let[d,h]=r.useState([]),[_,v]=r.useState(null);r.useEffect(()=>{v(document.body)},[]);let y=r.useCallback(e=>{h(t=>t.filter(t=>t.id!==e))},[]),b=r.useCallback(e=>{let t=e.id??u(),r={tone:`default`,duration:n,dismissible:!0,...e,id:t};return h(e=>[r,...e.filter(e=>e.id!==t)].slice(0,i)),t},[n,i]),x=r.useCallback((e,t)=>{h(n=>n.map(n=>n.id===e?{...n,...t}:n))},[]),S=r.useCallback(()=>{h([])},[]),C=r.useCallback(e=>b(f(e,`success`)),[b]),w=r.useCallback(e=>b(f(e,`info`)),[b]),T=r.useCallback(e=>b(f(e,`warning`)),[b]),E=r.useCallback(e=>b(f(e,`danger`)),[b]),D=r.useCallback(e=>b({duration:0,...f(e,`loading`)}),[b]),O=r.useCallback(async(e,t)=>{let r=b({duration:0,dismissible:!1,...f(t.loading,`loading`)});try{let i=await e;return x(r,{duration:n,dismissible:!0,...f(p(t.success,i),`success`)}),i}catch(e){throw x(r,{duration:n,dismissible:!0,...f(p(t.error,e),`danger`)}),e}},[b,n,x]),k=r.useMemo(()=>({toasts:d,addToast:b,updateToast:x,dismissToast:y,clearToasts:S,success:C,info:w,warning:T,error:E,loading:D,promise:O}),[b,S,y,E,w,D,O,C,d,x,T]),A=(0,a.jsx)(`div`,{"data-slot":`toast-viewport`,className:t.cn(`fixed z-[100] flex w-[min(calc(100vw-2rem),24rem)] flex-col gap-2 pointer-events-none`,m[l]),children:d.map(e=>(0,a.jsx)(g,{toast:e,pauseOnHover:c,onDismiss:y},e.id))});return(0,a.jsxs)(s.Provider,{value:k,children:[e,_?(0,o.createPortal)(A,_):null]})}function g({toast:e,pauseOnHover:o,onDismiss:s}){let u=e.tone??`default`,[d,f]=r.useState(!1);return r.useEffect(()=>{if(e.duration===1/0||e.duration===0||o&&d)return;let t=window.setTimeout(()=>s(e.id),e.duration??4e3);return()=>window.clearTimeout(t)},[d,s,o,e.duration,e.id]),(0,a.jsxs)(`div`,{"data-slot":`toast`,"data-tone":u,className:t.cn(`pointer-events-auto flex gap-3 rounded-lg border p-3 shadow-lg backdrop-blur`,c[u]),role:`status`,"aria-live":`polite`,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[(0,a.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:l[u]}),(0,a.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[e.group?(0,a.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-[0.18em] text-muted-foreground`,children:e.group}):null,e.title&&(0,a.jsx)(`div`,{className:`text-sm font-medium leading-none`,children:e.title}),e.description&&(0,a.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.description}),e.action&&(0,a.jsx)(`div`,{className:`pt-1`,children:e.action})]}),e.dismissible!==!1&&(0,a.jsxs)(n.Button,{type:`button`,variant:`ghost`,size:`icon-xs`,onClick:()=>s(e.id),children:[(0,a.jsx)(i.XIcon,{}),(0,a.jsx)(`span`,{className:`sr-only`,children:`Dismiss`})]})]})}function _(){let e=r.useContext(s);if(!e)throw Error(`useToast must be used inside ToastProvider`);return e}exports.ToastProvider=h,exports.useToast=_;
|
|
@@ -4,15 +4,16 @@ import { Button as t } from "../ui/button/index.js";
|
|
|
4
4
|
import * as n from "react";
|
|
5
5
|
import { AlertCircleIcon as r, CheckCircle2Icon as i, InfoIcon as a, Loader2Icon as o, TriangleAlertIcon as s, XIcon as c } from "lucide-react";
|
|
6
6
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
import { createPortal as d } from "react-dom";
|
|
7
8
|
//#region src/components/notifications/toast.tsx
|
|
8
|
-
var
|
|
9
|
+
var f = n.createContext(null), p = {
|
|
9
10
|
default: "border-border bg-popover text-popover-foreground",
|
|
10
11
|
success: "border-emerald-500/20 bg-emerald-500/10 text-emerald-950 dark:text-emerald-100",
|
|
11
12
|
info: "border-blue-500/20 bg-blue-500/10 text-blue-950 dark:text-blue-100",
|
|
12
13
|
warning: "border-amber-500/20 bg-amber-500/10 text-amber-950 dark:text-amber-100",
|
|
13
14
|
danger: "border-destructive/20 bg-destructive/10 text-destructive",
|
|
14
15
|
loading: "border-border bg-popover text-popover-foreground"
|
|
15
|
-
},
|
|
16
|
+
}, m = {
|
|
16
17
|
default: /* @__PURE__ */ l(a, { className: "size-4" }),
|
|
17
18
|
success: /* @__PURE__ */ l(i, { className: "size-4" }),
|
|
18
19
|
info: /* @__PURE__ */ l(a, { className: "size-4" }),
|
|
@@ -20,14 +21,14 @@ var d = n.createContext(null), f = {
|
|
|
20
21
|
danger: /* @__PURE__ */ l(r, { className: "size-4" }),
|
|
21
22
|
loading: /* @__PURE__ */ l(o, { className: "size-4 animate-spin" })
|
|
22
23
|
};
|
|
23
|
-
function
|
|
24
|
+
function h() {
|
|
24
25
|
return `toast-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function g(e) {
|
|
27
28
|
return typeof e == "object" && !!e && !n.isValidElement(e) && !Array.isArray(e);
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
30
|
+
function _(e, t) {
|
|
31
|
+
return g(e) ? {
|
|
31
32
|
...e,
|
|
32
33
|
tone: e.tone ?? t
|
|
33
34
|
} : {
|
|
@@ -35,10 +36,10 @@ function g(e, t) {
|
|
|
35
36
|
tone: t
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function v(e, t) {
|
|
39
40
|
return typeof e == "function" ? e(t) : e;
|
|
40
41
|
}
|
|
41
|
-
var
|
|
42
|
+
var y = {
|
|
42
43
|
"top-right": "right-4 top-4",
|
|
43
44
|
"top-left": "left-4 top-4",
|
|
44
45
|
"bottom-right": "bottom-4 right-4",
|
|
@@ -46,11 +47,15 @@ var v = {
|
|
|
46
47
|
"top-center": "left-1/2 top-4 -translate-x-1/2",
|
|
47
48
|
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
|
|
48
49
|
};
|
|
49
|
-
function
|
|
50
|
-
let [s, c] = n.useState([]),
|
|
50
|
+
function b({ children: t, defaultDuration: r = 4e3, maxToasts: i = 5, pauseOnHover: a = !0, position: o = "top-right" }) {
|
|
51
|
+
let [s, c] = n.useState([]), [p, m] = n.useState(null);
|
|
52
|
+
n.useEffect(() => {
|
|
53
|
+
m(document.body);
|
|
54
|
+
}, []);
|
|
55
|
+
let g = n.useCallback((e) => {
|
|
51
56
|
c((t) => t.filter((t) => t.id !== e));
|
|
52
|
-
}, []),
|
|
53
|
-
let t = e.id ??
|
|
57
|
+
}, []), b = n.useCallback((e) => {
|
|
58
|
+
let t = e.id ?? h(), n = {
|
|
54
59
|
tone: "default",
|
|
55
60
|
duration: r,
|
|
56
61
|
dismissible: !0,
|
|
@@ -58,79 +63,79 @@ function y({ children: t, defaultDuration: r = 4e3, maxToasts: i = 5, pauseOnHov
|
|
|
58
63
|
id: t
|
|
59
64
|
};
|
|
60
65
|
return c((e) => [n, ...e.filter((e) => e.id !== t)].slice(0, i)), t;
|
|
61
|
-
}, [r, i]),
|
|
66
|
+
}, [r, i]), S = n.useCallback((e, t) => {
|
|
62
67
|
c((n) => n.map((n) => n.id === e ? {
|
|
63
68
|
...n,
|
|
64
69
|
...t
|
|
65
70
|
} : n));
|
|
66
|
-
}, []),
|
|
71
|
+
}, []), C = n.useCallback(() => {
|
|
67
72
|
c([]);
|
|
68
|
-
}, []),
|
|
73
|
+
}, []), w = n.useCallback((e) => b(_(e, "success")), [b]), T = n.useCallback((e) => b(_(e, "info")), [b]), E = n.useCallback((e) => b(_(e, "warning")), [b]), D = n.useCallback((e) => b(_(e, "danger")), [b]), O = n.useCallback((e) => b({
|
|
69
74
|
duration: 0,
|
|
70
|
-
...
|
|
71
|
-
}), [
|
|
72
|
-
let n =
|
|
75
|
+
..._(e, "loading")
|
|
76
|
+
}), [b]), k = n.useCallback(async (e, t) => {
|
|
77
|
+
let n = b({
|
|
73
78
|
duration: 0,
|
|
74
79
|
dismissible: !1,
|
|
75
|
-
...
|
|
80
|
+
..._(t.loading, "loading")
|
|
76
81
|
});
|
|
77
82
|
try {
|
|
78
83
|
let i = await e;
|
|
79
|
-
return
|
|
84
|
+
return S(n, {
|
|
80
85
|
duration: r,
|
|
81
86
|
dismissible: !0,
|
|
82
|
-
...
|
|
87
|
+
..._(v(t.success, i), "success")
|
|
83
88
|
}), i;
|
|
84
89
|
} catch (e) {
|
|
85
|
-
throw
|
|
90
|
+
throw S(n, {
|
|
86
91
|
duration: r,
|
|
87
92
|
dismissible: !0,
|
|
88
|
-
...
|
|
93
|
+
..._(v(t.error, e), "danger")
|
|
89
94
|
}), e;
|
|
90
95
|
}
|
|
91
96
|
}, [
|
|
92
|
-
|
|
97
|
+
b,
|
|
93
98
|
r,
|
|
94
|
-
|
|
95
|
-
]),
|
|
99
|
+
S
|
|
100
|
+
]), A = n.useMemo(() => ({
|
|
96
101
|
toasts: s,
|
|
97
|
-
addToast:
|
|
98
|
-
updateToast:
|
|
99
|
-
dismissToast:
|
|
100
|
-
clearToasts:
|
|
101
|
-
success:
|
|
102
|
-
info:
|
|
103
|
-
warning:
|
|
104
|
-
error:
|
|
105
|
-
loading:
|
|
106
|
-
promise:
|
|
102
|
+
addToast: b,
|
|
103
|
+
updateToast: S,
|
|
104
|
+
dismissToast: g,
|
|
105
|
+
clearToasts: C,
|
|
106
|
+
success: w,
|
|
107
|
+
info: T,
|
|
108
|
+
warning: E,
|
|
109
|
+
error: D,
|
|
110
|
+
loading: O,
|
|
111
|
+
promise: k
|
|
107
112
|
}), [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
S,
|
|
113
|
+
b,
|
|
114
|
+
C,
|
|
115
|
+
g,
|
|
116
|
+
D,
|
|
113
117
|
T,
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
O,
|
|
119
|
+
k,
|
|
120
|
+
w,
|
|
116
121
|
s,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
])
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
children:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
122
|
+
S,
|
|
123
|
+
E
|
|
124
|
+
]), j = /* @__PURE__ */ l("div", {
|
|
125
|
+
"data-slot": "toast-viewport",
|
|
126
|
+
className: e("fixed z-[100] flex w-[min(calc(100vw-2rem),24rem)] flex-col gap-2 pointer-events-none", y[o]),
|
|
127
|
+
children: s.map((e) => /* @__PURE__ */ l(x, {
|
|
128
|
+
toast: e,
|
|
129
|
+
pauseOnHover: a,
|
|
130
|
+
onDismiss: g
|
|
131
|
+
}, e.id))
|
|
132
|
+
});
|
|
133
|
+
return /* @__PURE__ */ u(f.Provider, {
|
|
134
|
+
value: A,
|
|
135
|
+
children: [t, p ? d(j, p) : null]
|
|
131
136
|
});
|
|
132
137
|
}
|
|
133
|
-
function
|
|
138
|
+
function x({ toast: r, pauseOnHover: i, onDismiss: a }) {
|
|
134
139
|
let o = r.tone ?? "default", [s, d] = n.useState(!1);
|
|
135
140
|
return n.useEffect(() => {
|
|
136
141
|
if (r.duration === Infinity || r.duration === 0 || i && s) return;
|
|
@@ -145,7 +150,7 @@ function b({ toast: r, pauseOnHover: i, onDismiss: a }) {
|
|
|
145
150
|
]), /* @__PURE__ */ u("div", {
|
|
146
151
|
"data-slot": "toast",
|
|
147
152
|
"data-tone": o,
|
|
148
|
-
className: e("flex gap-3 rounded-lg border p-3 shadow-lg backdrop-blur",
|
|
153
|
+
className: e("pointer-events-auto flex gap-3 rounded-lg border p-3 shadow-lg backdrop-blur", p[o]),
|
|
149
154
|
role: "status",
|
|
150
155
|
"aria-live": "polite",
|
|
151
156
|
onMouseEnter: () => d(!0),
|
|
@@ -153,7 +158,7 @@ function b({ toast: r, pauseOnHover: i, onDismiss: a }) {
|
|
|
153
158
|
children: [
|
|
154
159
|
/* @__PURE__ */ l("div", {
|
|
155
160
|
className: "mt-0.5 shrink-0",
|
|
156
|
-
children:
|
|
161
|
+
children: m[o]
|
|
157
162
|
}),
|
|
158
163
|
/* @__PURE__ */ u("div", {
|
|
159
164
|
className: "min-w-0 flex-1 space-y-1",
|
|
@@ -189,10 +194,10 @@ function b({ toast: r, pauseOnHover: i, onDismiss: a }) {
|
|
|
189
194
|
]
|
|
190
195
|
});
|
|
191
196
|
}
|
|
192
|
-
function
|
|
193
|
-
let e = n.useContext(
|
|
197
|
+
function S() {
|
|
198
|
+
let e = n.useContext(f);
|
|
194
199
|
if (!e) throw Error("useToast must be used inside ToastProvider");
|
|
195
200
|
return e;
|
|
196
201
|
}
|
|
197
202
|
//#endregion
|
|
198
|
-
export {
|
|
203
|
+
export { b as ToastProvider, S as useToast };
|