@agent-factory-platform/ui-kit 0.7.1 → 0.9.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 +22 -0
- package/dist/charts/adapter.js +111 -0
- package/dist/charts/basic.d.ts +2 -0
- package/dist/charts/basic.js +115 -0
- package/dist/charts/chart-tooltip.js +21 -0
- package/dist/charts/event-markers-primitive.d.ts +10 -1
- package/dist/charts/event-markers-primitive.js +116 -0
- package/dist/charts/index.d.ts +1 -0
- package/dist/charts/ohlc-annotations.d.ts +56 -0
- package/dist/charts/ohlc-annotations.js +84 -0
- package/dist/charts/ohlc.d.ts +5 -1
- package/dist/charts/ohlc.js +240 -0
- package/dist/charts/series.js +584 -0
- package/dist/charts/theme.js +35 -0
- package/dist/charts/time-combo.js +17 -0
- package/dist/component-api.js +3 -5
- package/dist/component-api.json.js +9 -0
- package/dist/component-manifest.json.js +9 -0
- package/dist/components/alert.js +35 -0
- package/dist/components/avatar.js +101 -0
- package/dist/components/badge.js +111 -0
- package/dist/components/button-group.js +22 -0
- package/dist/components/button.js +64 -0
- package/dist/components/calendar-period-navigator.js +34 -0
- package/dist/components/card.js +35 -0
- package/dist/components/chart-frame.js +53 -0
- package/dist/components/color-picker.js +155 -0
- package/dist/components/combobox.js +129 -0
- package/dist/components/command-dialog.js +89 -0
- package/dist/components/confirm-dialog.js +57 -0
- package/dist/components/data-table.js +135 -0
- package/dist/components/date-time.js +203 -0
- package/dist/components/disclosure.js +29 -0
- package/dist/components/drawer.js +150 -0
- package/dist/components/dropdown-select.js +191 -0
- package/dist/components/field.js +21 -0
- package/dist/components/floating-window.js +159 -0
- package/dist/components/heading.js +21 -0
- package/dist/components/hover-tip.js +90 -0
- package/dist/components/icon-tip.js +12 -0
- package/dist/components/input-group.js +16 -0
- package/dist/components/input-otp.js +56 -0
- package/dist/components/input.js +44 -0
- package/dist/components/item.js +47 -0
- package/dist/components/kbd.js +18 -0
- package/dist/components/line-chart.js +79 -0
- package/dist/components/listbox.js +33 -0
- package/dist/components/live-value.js +26 -0
- package/dist/components/modal.js +140 -0
- package/dist/components/multi-select.js +54 -0
- package/dist/components/native-select.js +17 -0
- package/dist/components/navigation.js +42 -0
- package/dist/components/page.js +24 -0
- package/dist/components/popover-menu.js +164 -0
- package/dist/components/progress.js +23 -0
- package/dist/components/resizable-pane.js +73 -0
- package/dist/components/scroll-load-more.js +61 -0
- package/dist/components/seg-slider.js +42 -0
- package/dist/components/segmented-control.js +46 -0
- package/dist/components/selection-controls.js +119 -0
- package/dist/components/sidebar.js +23 -0
- package/dist/components/skeleton.js +9 -0
- package/dist/components/slider.js +162 -0
- package/dist/components/sliding-tabs.js +118 -0
- package/dist/components/spinner.js +9 -0
- package/dist/components/spotlight-tour.js +122 -0
- package/dist/components/stat-card.js +23 -0
- package/dist/components/state-view.js +75 -0
- package/dist/components/stats-table.js +17 -0
- package/dist/components/table.js +24 -0
- package/dist/components/tag-pill.d.ts +4 -1
- package/dist/components/tag-pill.js +69 -0
- package/dist/components/theme-editor.js +159 -0
- package/dist/components/toast.js +66 -0
- package/dist/components/toolbar.js +46 -0
- package/dist/components/utility.js +19 -0
- package/dist/components/widget-frame.js +41 -0
- package/dist/components/widget-picker.js +87 -0
- package/dist/components/workspace-grid.js +468 -0
- package/dist/focus-modality.js +3 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +228 -5564
- package/dist/lib/cn.js +6 -0
- package/dist/lib/focus-modality.js +16 -0
- package/dist/lib/motion.js +27 -0
- package/dist/lib/viewport.js +13 -0
- package/dist/manifest.js +5 -7
- package/dist/styles.js +1 -1
- package/dist/theme.js +158 -0
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsxs as u, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as F, useId as O, useState as y, useEffect as R, useMemo as j } from "react";
|
|
3
|
+
import { Search as q, Check as M } from "lucide-react";
|
|
4
|
+
import { Popover as v } from "radix-ui";
|
|
5
|
+
import { cn as S } from "../lib/cn.js";
|
|
6
|
+
function B({
|
|
7
|
+
value: k,
|
|
8
|
+
options: d,
|
|
9
|
+
onValueChange: C,
|
|
10
|
+
label: A,
|
|
11
|
+
resultsLabel: N,
|
|
12
|
+
placeholder: L,
|
|
13
|
+
emptyText: $,
|
|
14
|
+
disabled: x = !1,
|
|
15
|
+
className: I
|
|
16
|
+
}) {
|
|
17
|
+
const f = F(null), p = O(), t = d.find((e) => e.value === k), [w, m] = y((t == null ? void 0 : t.label) ?? ""), [o, i] = y(!1), [b, s] = y(0);
|
|
18
|
+
R(() => {
|
|
19
|
+
o || m((t == null ? void 0 : t.label) ?? "");
|
|
20
|
+
}, [o, t == null ? void 0 : t.label]);
|
|
21
|
+
const a = j(() => {
|
|
22
|
+
const e = w.trim().toLocaleLowerCase();
|
|
23
|
+
return !e || e === (t == null ? void 0 : t.label.toLocaleLowerCase()) ? [...d] : d.filter(
|
|
24
|
+
(r) => `${r.label} ${r.meta ?? ""}`.toLocaleLowerCase().includes(e)
|
|
25
|
+
);
|
|
26
|
+
}, [d, w, t == null ? void 0 : t.label]), h = (e, r) => {
|
|
27
|
+
var n;
|
|
28
|
+
for (let c = 0; c < a.length; c += 1) {
|
|
29
|
+
const g = (e + c * r + a.length) % a.length;
|
|
30
|
+
if (!((n = a[g]) != null && n.disabled)) return g;
|
|
31
|
+
}
|
|
32
|
+
return -1;
|
|
33
|
+
}, D = (e) => {
|
|
34
|
+
const r = a[e];
|
|
35
|
+
!r || r.disabled || (C(r.value), m(r.label), i(!1), requestAnimationFrame(() => {
|
|
36
|
+
var n;
|
|
37
|
+
return (n = f.current) == null ? void 0 : n.focus();
|
|
38
|
+
}));
|
|
39
|
+
}, P = (e) => {
|
|
40
|
+
s((r) => {
|
|
41
|
+
const n = a.length ? (r + e + a.length) % a.length : 0;
|
|
42
|
+
return h(n, e);
|
|
43
|
+
});
|
|
44
|
+
}, z = (e) => {
|
|
45
|
+
x || (e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), o ? P(e.key === "ArrowDown" ? 1 : -1) : (i(!0), s(h(e.key === "ArrowDown" ? 0 : a.length - 1, e.key === "ArrowDown" ? 1 : -1)))) : e.key === "Enter" && o ? (e.preventDefault(), D(b)) : e.key === "Escape" && o ? (e.preventDefault(), i(!1), m((t == null ? void 0 : t.label) ?? "")) : e.key === "Home" && o ? (e.preventDefault(), s(h(0, 1))) : e.key === "End" && o && (e.preventDefault(), s(h(a.length - 1, -1))));
|
|
46
|
+
}, E = o && b >= 0 ? `${p}-option-${b}` : void 0;
|
|
47
|
+
return /* @__PURE__ */ u(v.Root, { open: o, onOpenChange: i, children: [
|
|
48
|
+
/* @__PURE__ */ l(v.Trigger, { asChild: !0, children: /* @__PURE__ */ u("div", { className: S("relative min-w-0", I), children: [
|
|
49
|
+
/* @__PURE__ */ l(q, { size: 14, className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-graphite", "aria-hidden": !0 }),
|
|
50
|
+
/* @__PURE__ */ l(
|
|
51
|
+
"input",
|
|
52
|
+
{
|
|
53
|
+
ref: f,
|
|
54
|
+
role: "combobox",
|
|
55
|
+
"aria-label": A,
|
|
56
|
+
"aria-controls": p,
|
|
57
|
+
"aria-expanded": o,
|
|
58
|
+
"aria-autocomplete": "list",
|
|
59
|
+
"aria-activedescendant": E,
|
|
60
|
+
autoComplete: "off",
|
|
61
|
+
disabled: x,
|
|
62
|
+
placeholder: L,
|
|
63
|
+
value: w,
|
|
64
|
+
onFocus: () => {
|
|
65
|
+
x || i(!0);
|
|
66
|
+
},
|
|
67
|
+
onChange: (e) => {
|
|
68
|
+
m(e.target.value), s(0), i(!0);
|
|
69
|
+
},
|
|
70
|
+
onKeyDown: z,
|
|
71
|
+
className: "h-control-default w-full rounded-control border border-border bg-surface-raised pl-9 pr-3 font-product text-body-sm text-ink outline-none placeholder:text-graphite focus:border-rust focus-visible:ring-2 focus-visible:ring-rust/20 disabled:cursor-not-allowed disabled:opacity-50"
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
] }) }),
|
|
75
|
+
/* @__PURE__ */ l(v.Portal, { children: /* @__PURE__ */ u(
|
|
76
|
+
v.Content,
|
|
77
|
+
{
|
|
78
|
+
role: "listbox",
|
|
79
|
+
id: p,
|
|
80
|
+
"aria-label": N,
|
|
81
|
+
sideOffset: 4,
|
|
82
|
+
align: "start",
|
|
83
|
+
collisionPadding: 8,
|
|
84
|
+
onOpenAutoFocus: (e) => {
|
|
85
|
+
var r;
|
|
86
|
+
e.preventDefault(), (r = f.current) == null || r.focus();
|
|
87
|
+
},
|
|
88
|
+
onCloseAutoFocus: (e) => {
|
|
89
|
+
var r;
|
|
90
|
+
e.preventDefault(), (r = f.current) == null || r.focus();
|
|
91
|
+
},
|
|
92
|
+
className: "af-popup-bound z-50 max-h-command-results w-overlay-sm overflow-y-auto rounded-panel border border-border bg-surface-raised p-1 font-product text-body-sm text-ink shadow-pop outline-none",
|
|
93
|
+
children: [
|
|
94
|
+
a.length === 0 && /* @__PURE__ */ l("div", { className: "px-3 py-2 text-caption text-graphite", children: $ }),
|
|
95
|
+
a.map((e, r) => {
|
|
96
|
+
const n = r === b, c = e.value === k;
|
|
97
|
+
return /* @__PURE__ */ u(
|
|
98
|
+
"div",
|
|
99
|
+
{
|
|
100
|
+
id: `${p}-option-${r}`,
|
|
101
|
+
role: "option",
|
|
102
|
+
"aria-selected": c,
|
|
103
|
+
"aria-disabled": e.disabled || void 0,
|
|
104
|
+
"data-active": n || void 0,
|
|
105
|
+
onPointerMove: () => {
|
|
106
|
+
e.disabled || s(r);
|
|
107
|
+
},
|
|
108
|
+
onPointerDown: (g) => g.preventDefault(),
|
|
109
|
+
onClick: () => D(r),
|
|
110
|
+
className: "flex min-h-row-default cursor-default items-center gap-2 rounded-control px-3 outline-none data-[active]:bg-surface-hover aria-disabled:pointer-events-none aria-disabled:opacity-50",
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ u("span", { className: "min-w-0 flex-1", children: [
|
|
113
|
+
/* @__PURE__ */ l("span", { className: "block truncate", children: e.label }),
|
|
114
|
+
e.meta && /* @__PURE__ */ l("span", { className: "block truncate text-caption text-graphite", children: e.meta })
|
|
115
|
+
] }),
|
|
116
|
+
c && /* @__PURE__ */ l(M, { size: 14, className: "shrink-0 text-rust", "aria-hidden": !0 })
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
e.value
|
|
120
|
+
);
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
) })
|
|
125
|
+
] });
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
B as Combobox
|
|
129
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { Search as N } from "lucide-react";
|
|
3
|
+
import { cn as l } from "../lib/cn.js";
|
|
4
|
+
import { Modal as w } from "./modal.js";
|
|
5
|
+
function D({
|
|
6
|
+
open: s,
|
|
7
|
+
onClose: d,
|
|
8
|
+
title: a,
|
|
9
|
+
query: m,
|
|
10
|
+
onQueryChange: c,
|
|
11
|
+
placeholder: h,
|
|
12
|
+
inputRef: b,
|
|
13
|
+
busy: t = !1,
|
|
14
|
+
filters: f,
|
|
15
|
+
filter: p,
|
|
16
|
+
onFilterChange: u,
|
|
17
|
+
filterAriaLabel: x,
|
|
18
|
+
children: v,
|
|
19
|
+
footer: i,
|
|
20
|
+
onKeyDown: g,
|
|
21
|
+
className: k
|
|
22
|
+
}) {
|
|
23
|
+
return /* @__PURE__ */ e(w, { open: s, onClose: d, title: a, size: "command", sheetUntilPx: 640, bare: !0, children: /* @__PURE__ */ n("div", { "data-command-dialog": !0, className: l("flex min-h-0 flex-col", k), onKeyDown: g, children: [
|
|
24
|
+
/* @__PURE__ */ n(
|
|
25
|
+
"div",
|
|
26
|
+
{
|
|
27
|
+
"data-slot": "command-search",
|
|
28
|
+
className: "flex min-h-command-search shrink-0 items-center gap-2 border-b border-divider px-4",
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ e(N, { size: 17, className: "shrink-0 text-graphite", "aria-hidden": !0 }),
|
|
31
|
+
/* @__PURE__ */ e(
|
|
32
|
+
"input",
|
|
33
|
+
{
|
|
34
|
+
ref: b,
|
|
35
|
+
value: m,
|
|
36
|
+
onChange: (r) => c(r.target.value),
|
|
37
|
+
placeholder: h,
|
|
38
|
+
"aria-label": a,
|
|
39
|
+
"aria-busy": t,
|
|
40
|
+
autoComplete: "off",
|
|
41
|
+
spellCheck: !1,
|
|
42
|
+
className: "min-w-0 flex-1 bg-transparent font-sohne text-body text-ink outline-none placeholder:text-graphite"
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
t && /* @__PURE__ */ e(
|
|
46
|
+
"span",
|
|
47
|
+
{
|
|
48
|
+
className: "size-4 shrink-0 animate-spin rounded-full border-2 border-graphite/25 border-t-graphite",
|
|
49
|
+
"aria-hidden": !0
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ e("kbd", { className: "hidden rounded-control border border-border bg-surface-muted px-1.5 py-0.5 font-mono text-micro text-graphite sm:inline", children: "Esc" })
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ e(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
"data-slot": "command-filters",
|
|
60
|
+
role: "group",
|
|
61
|
+
"aria-label": x,
|
|
62
|
+
className: "flex min-h-row-default shrink-0 items-end gap-4 overflow-x-auto border-b border-divider px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
63
|
+
children: f.map((r) => {
|
|
64
|
+
const o = r.value === p;
|
|
65
|
+
return /* @__PURE__ */ e(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
type: "button",
|
|
69
|
+
"aria-pressed": o,
|
|
70
|
+
disabled: r.disabled,
|
|
71
|
+
onClick: () => u(r.value),
|
|
72
|
+
className: l(
|
|
73
|
+
"relative h-row-default shrink-0 px-0.5 font-sohne text-caption outline-none transition-colors focus-visible:ring-2 focus-visible:ring-rust/35 disabled:pointer-events-none disabled:opacity-45",
|
|
74
|
+
o ? "font-[500] text-ink after:absolute after:inset-x-0 after:bottom-0 after:h-0.5 after:bg-rust" : "text-graphite hover:text-ink"
|
|
75
|
+
),
|
|
76
|
+
children: r.label
|
|
77
|
+
},
|
|
78
|
+
r.value
|
|
79
|
+
);
|
|
80
|
+
})
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ e("div", { className: "min-h-0 max-h-command-results flex-1 overflow-y-auto px-2 py-2", children: v }),
|
|
84
|
+
i && /* @__PURE__ */ e("div", { className: "min-h-row-compact shrink-0 border-t border-divider px-4 py-2 font-sohne text-data text-graphite", children: i })
|
|
85
|
+
] }) });
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
D as CommandDialog
|
|
89
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Button as l } from "./button.js";
|
|
3
|
+
import { Modal as x } from "./modal.js";
|
|
4
|
+
function O({
|
|
5
|
+
open: s,
|
|
6
|
+
onClose: e,
|
|
7
|
+
title: f,
|
|
8
|
+
message: o,
|
|
9
|
+
body: n,
|
|
10
|
+
confirmLabel: a,
|
|
11
|
+
cancelLabel: t,
|
|
12
|
+
closeLabel: c,
|
|
13
|
+
onConfirm: m,
|
|
14
|
+
confirmVariant: h,
|
|
15
|
+
busy: i = !1,
|
|
16
|
+
busyLabel: v,
|
|
17
|
+
confirmDisabled: p = !1
|
|
18
|
+
}) {
|
|
19
|
+
return /* @__PURE__ */ d(
|
|
20
|
+
x,
|
|
21
|
+
{
|
|
22
|
+
open: s,
|
|
23
|
+
onClose: i ? () => {
|
|
24
|
+
} : e,
|
|
25
|
+
title: f,
|
|
26
|
+
closeLabel: c ?? t,
|
|
27
|
+
footer: /* @__PURE__ */ d("div", { className: "flex items-center justify-end gap-2", children: [
|
|
28
|
+
/* @__PURE__ */ r(
|
|
29
|
+
l,
|
|
30
|
+
{
|
|
31
|
+
variant: "secondary",
|
|
32
|
+
onClick: e,
|
|
33
|
+
disabled: i,
|
|
34
|
+
children: t
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ r(
|
|
38
|
+
l,
|
|
39
|
+
{
|
|
40
|
+
variant: h ?? "primary",
|
|
41
|
+
onClick: () => void m(),
|
|
42
|
+
disabled: i || p,
|
|
43
|
+
"aria-busy": i || void 0,
|
|
44
|
+
children: i ? v ?? a : a
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
] }),
|
|
48
|
+
children: [
|
|
49
|
+
o && /* @__PURE__ */ r("p", { className: "font-sohne text-body-sm leading-relaxed text-ash", children: o }),
|
|
50
|
+
n && /* @__PURE__ */ r("div", { className: "mt-3", children: n })
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
O as ConfirmDialog
|
|
57
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as s, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowUp as B, ArrowDown as $, ChevronsUpDown as q } from "lucide-react";
|
|
3
|
+
import { useState as E, useRef as F, useMemo as G } from "react";
|
|
4
|
+
import { cn as f } from "../lib/cn.js";
|
|
5
|
+
function Y({
|
|
6
|
+
label: P,
|
|
7
|
+
columns: i,
|
|
8
|
+
rows: u,
|
|
9
|
+
rowKey: v,
|
|
10
|
+
emptyText: I,
|
|
11
|
+
density: L = "default",
|
|
12
|
+
className: S,
|
|
13
|
+
selectedRowKey: z,
|
|
14
|
+
onRowActivate: p,
|
|
15
|
+
rowAriaLabel: M
|
|
16
|
+
}) {
|
|
17
|
+
const [l, V] = E(null), N = F(null), D = i.map((t) => Math.max(1, t.width ?? 100)), T = D.reduce((t, e) => t + e, 0), [X, y] = E({}), n = i.map((t, e) => X[t.id] ?? D[e] / T * 100), k = G(() => {
|
|
18
|
+
if (!l) return [...u];
|
|
19
|
+
const t = i.find((r) => r.id === l.id);
|
|
20
|
+
if (!(t != null && t.sortValue)) return [...u];
|
|
21
|
+
const e = l.direction === "ascending" ? 1 : -1;
|
|
22
|
+
return [...u].sort((r, o) => {
|
|
23
|
+
var d, h;
|
|
24
|
+
const a = ((d = t.sortValue) == null ? void 0 : d.call(t, r)) ?? "", c = ((h = t.sortValue) == null ? void 0 : h.call(t, o)) ?? "";
|
|
25
|
+
return (typeof a == "number" && typeof c == "number" ? a - c : String(a).localeCompare(String(c))) * e;
|
|
26
|
+
});
|
|
27
|
+
}, [i, u, l]), x = (t, e) => {
|
|
28
|
+
t >= n.length - 1 || y((r) => {
|
|
29
|
+
const o = r[i[t].id] ?? n[t], a = r[i[t + 1].id] ?? n[t + 1], c = o + a, d = Math.min(10, c / 3), h = Math.min(c - d, Math.max(d, o + e));
|
|
30
|
+
return { ...r, [i[t].id]: h, [i[t + 1].id]: c - h };
|
|
31
|
+
});
|
|
32
|
+
}, j = (t, e) => {
|
|
33
|
+
t.key === "ArrowLeft" ? (t.preventDefault(), x(e, -5)) : t.key === "ArrowRight" && (t.preventDefault(), x(e, 5));
|
|
34
|
+
}, w = (t, e) => {
|
|
35
|
+
var C;
|
|
36
|
+
if (t.button !== 0) return;
|
|
37
|
+
t.preventDefault();
|
|
38
|
+
const r = t.currentTarget, o = t.clientX, a = ((C = N.current) == null ? void 0 : C.getBoundingClientRect().width) ?? 1, c = n[e], d = n[e] + n[e + 1];
|
|
39
|
+
r.setPointerCapture(t.pointerId);
|
|
40
|
+
const h = (b) => {
|
|
41
|
+
const W = Math.min(
|
|
42
|
+
d - Math.min(10, d / 3),
|
|
43
|
+
Math.max(Math.min(10, d / 3), c + (b.clientX - o) / a * 100)
|
|
44
|
+
);
|
|
45
|
+
y((U) => ({ ...U, [i[e].id]: W, [i[e + 1].id]: d - W }));
|
|
46
|
+
}, g = (b) => {
|
|
47
|
+
r.hasPointerCapture(b.pointerId) && r.releasePointerCapture(b.pointerId), r.removeEventListener("pointermove", h), r.removeEventListener("pointerup", g), r.removeEventListener("pointercancel", g);
|
|
48
|
+
};
|
|
49
|
+
r.addEventListener("pointermove", h), r.addEventListener("pointerup", g), r.addEventListener("pointercancel", g);
|
|
50
|
+
};
|
|
51
|
+
return /* @__PURE__ */ s("div", { className: f("min-w-0 overflow-x-auto rounded-panel border border-border", S), children: /* @__PURE__ */ m("table", { ref: N, "aria-label": P, className: "w-full min-w-xl border-collapse table-fixed", children: [
|
|
52
|
+
/* @__PURE__ */ s("colgroup", { children: i.map((t, e) => /* @__PURE__ */ s("col", { style: { width: `${n[e]}%` } }, t.id)) }),
|
|
53
|
+
/* @__PURE__ */ s("thead", { className: "bg-surface-muted font-product text-micro uppercase text-graphite", children: /* @__PURE__ */ s("tr", { className: "h-row-compact", children: i.map((t, e) => {
|
|
54
|
+
var o;
|
|
55
|
+
const r = (l == null ? void 0 : l.id) === t.id ? l.direction : void 0;
|
|
56
|
+
return /* @__PURE__ */ m(
|
|
57
|
+
"th",
|
|
58
|
+
{
|
|
59
|
+
scope: "col",
|
|
60
|
+
"aria-sort": r ?? (t.sortValue ? "none" : void 0),
|
|
61
|
+
className: f("relative px-3 font-[500]", t.pinned && t.id === ((o = i[0]) == null ? void 0 : o.id) && "sticky left-0 z-20 bg-surface-muted", t.align === "right" ? "text-right" : "text-left"),
|
|
62
|
+
children: [
|
|
63
|
+
t.sortValue ? /* @__PURE__ */ m(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
type: "button",
|
|
67
|
+
onClick: () => V((a) => ({
|
|
68
|
+
id: t.id,
|
|
69
|
+
direction: (a == null ? void 0 : a.id) === t.id && a.direction === "ascending" ? "descending" : "ascending"
|
|
70
|
+
})),
|
|
71
|
+
className: f(
|
|
72
|
+
"inline-flex h-control-compact max-w-full items-center gap-1 rounded-control outline-none hover:text-ink focus-visible:ring-2 focus-visible:ring-rust",
|
|
73
|
+
t.align === "right" && "ml-auto"
|
|
74
|
+
),
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ s("span", { className: "truncate", children: t.header }),
|
|
77
|
+
r === "ascending" ? /* @__PURE__ */ s(B, { size: 12, "aria-hidden": !0 }) : r === "descending" ? /* @__PURE__ */ s($, { size: 12, "aria-hidden": !0 }) : /* @__PURE__ */ s(q, { size: 12, "aria-hidden": !0 })
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
) : t.header,
|
|
81
|
+
t.resizeLabel && e < i.length - 1 && /* @__PURE__ */ s(
|
|
82
|
+
"span",
|
|
83
|
+
{
|
|
84
|
+
role: "separator",
|
|
85
|
+
tabIndex: 0,
|
|
86
|
+
"aria-label": t.resizeLabel,
|
|
87
|
+
"aria-orientation": "vertical",
|
|
88
|
+
"aria-valuemin": Math.min(10, (n[e] + n[e + 1]) / 3),
|
|
89
|
+
"aria-valuemax": Math.round(n[e] + n[e + 1] - Math.min(10, (n[e] + n[e + 1]) / 3)),
|
|
90
|
+
"aria-valuenow": Math.round(n[e]),
|
|
91
|
+
onKeyDown: (a) => j(a, e),
|
|
92
|
+
onPointerDown: (a) => w(a, e),
|
|
93
|
+
className: "absolute inset-y-0 right-0 z-10 w-1 cursor-col-resize touch-none bg-transparent outline-none hover:bg-rust focus-visible:bg-rust"
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
t.id
|
|
99
|
+
);
|
|
100
|
+
}) }) }),
|
|
101
|
+
/* @__PURE__ */ m("tbody", { className: "font-data text-data tabular-nums text-ink", children: [
|
|
102
|
+
k.map((t) => /* @__PURE__ */ s(
|
|
103
|
+
"tr",
|
|
104
|
+
{
|
|
105
|
+
tabIndex: p ? 0 : void 0,
|
|
106
|
+
"aria-label": M == null ? void 0 : M(t),
|
|
107
|
+
"aria-selected": z === void 0 ? void 0 : z === v(t),
|
|
108
|
+
onClick: (e) => {
|
|
109
|
+
e.target.closest("a,button,input,select,textarea") || p == null || p(t);
|
|
110
|
+
},
|
|
111
|
+
onKeyDown: (e) => {
|
|
112
|
+
e.target === e.currentTarget && p && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), p(t));
|
|
113
|
+
},
|
|
114
|
+
className: f("border-t border-divider hover:bg-surface-hover focus-visible:outline focus-visible:outline-rust", L === "compact" ? "h-row-compact" : "h-row-default", z === v(t) && "bg-surface-hover"),
|
|
115
|
+
children: i.map((e) => {
|
|
116
|
+
var r;
|
|
117
|
+
return /* @__PURE__ */ s(
|
|
118
|
+
"td",
|
|
119
|
+
{
|
|
120
|
+
className: f("truncate px-3", e.pinned && e.id === ((r = i[0]) == null ? void 0 : r.id) && "sticky left-0 z-10 bg-surface-canvas", e.align === "right" ? "text-right" : "text-left"),
|
|
121
|
+
children: e.cell(t)
|
|
122
|
+
},
|
|
123
|
+
e.id
|
|
124
|
+
);
|
|
125
|
+
})
|
|
126
|
+
},
|
|
127
|
+
v(t)
|
|
128
|
+
)),
|
|
129
|
+
k.length === 0 && /* @__PURE__ */ s("tr", { className: "h-row-touch border-t border-divider", children: /* @__PURE__ */ s("td", { colSpan: i.length, className: "px-3 text-center font-product text-caption text-graphite", children: I }) })
|
|
130
|
+
] })
|
|
131
|
+
] }) });
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
Y as DataTable
|
|
135
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { jsxs as h, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronLeft as E, ChevronRight as H } from "lucide-react";
|
|
3
|
+
import { useState as F, useId as Y, useMemo as _, useEffect as L } from "react";
|
|
4
|
+
import { Popover as y } from "radix-ui";
|
|
5
|
+
import { cn as Z } from "../lib/cn.js";
|
|
6
|
+
import { Button as N } from "./button.js";
|
|
7
|
+
import { Field as G } from "./field.js";
|
|
8
|
+
import { Input as J } from "./input.js";
|
|
9
|
+
function u(e) {
|
|
10
|
+
const [i, o, s] = e.split("-").map(Number);
|
|
11
|
+
return new Date(Date.UTC(i, o - 1, s));
|
|
12
|
+
}
|
|
13
|
+
function k(e) {
|
|
14
|
+
return [
|
|
15
|
+
e.getUTCFullYear(),
|
|
16
|
+
String(e.getUTCMonth() + 1).padStart(2, "0"),
|
|
17
|
+
String(e.getUTCDate()).padStart(2, "0")
|
|
18
|
+
].join("-");
|
|
19
|
+
}
|
|
20
|
+
function P(e, i) {
|
|
21
|
+
const o = u(e);
|
|
22
|
+
return o.setUTCDate(o.getUTCDate() + i), k(o);
|
|
23
|
+
}
|
|
24
|
+
function p(e) {
|
|
25
|
+
return `${e.getUTCFullYear()}-${String(e.getUTCMonth() + 1).padStart(2, "0")}`;
|
|
26
|
+
}
|
|
27
|
+
function Q({
|
|
28
|
+
value: e,
|
|
29
|
+
onValueChange: i,
|
|
30
|
+
label: o,
|
|
31
|
+
locale: s,
|
|
32
|
+
weekdayLabels: d,
|
|
33
|
+
previousMonthLabel: c,
|
|
34
|
+
nextMonthLabel: l,
|
|
35
|
+
dateLabel: g = (w) => w,
|
|
36
|
+
minimum: f,
|
|
37
|
+
maximum: D,
|
|
38
|
+
className: j
|
|
39
|
+
}) {
|
|
40
|
+
const w = e ? u(e) : /* @__PURE__ */ new Date(), [v, C] = F(() => p(w)), S = Y(), [R, M] = v.split("-").map(Number), b = new Date(Date.UTC(R, M - 1, 1)), T = new Date(b);
|
|
41
|
+
T.setUTCDate(1 - b.getUTCDay());
|
|
42
|
+
const V = Array.from({ length: 42 }, (t, n) => {
|
|
43
|
+
const a = new Date(T);
|
|
44
|
+
return a.setUTCDate(T.getUTCDate() + n), k(a);
|
|
45
|
+
}), $ = k(/* @__PURE__ */ new Date()), K = _(
|
|
46
|
+
() => new Intl.DateTimeFormat(s, { year: "numeric", month: "long", timeZone: "UTC" }).format(b),
|
|
47
|
+
[s, v]
|
|
48
|
+
);
|
|
49
|
+
L(() => {
|
|
50
|
+
e && C(p(u(e)));
|
|
51
|
+
}, [e]);
|
|
52
|
+
const U = (t) => {
|
|
53
|
+
const n = new Date(b);
|
|
54
|
+
n.setUTCMonth(n.getUTCMonth() + t), C(p(n));
|
|
55
|
+
}, A = (t) => {
|
|
56
|
+
C(p(u(t))), requestAnimationFrame(() => {
|
|
57
|
+
var n;
|
|
58
|
+
(n = document.querySelector(`[data-calendar-id="${S}"] [data-date="${t}"]`)) == null || n.focus();
|
|
59
|
+
});
|
|
60
|
+
}, O = (t, n) => {
|
|
61
|
+
const a = {
|
|
62
|
+
ArrowLeft: -1,
|
|
63
|
+
ArrowRight: 1,
|
|
64
|
+
ArrowUp: -7,
|
|
65
|
+
ArrowDown: 7
|
|
66
|
+
}[t.key];
|
|
67
|
+
if (a)
|
|
68
|
+
t.preventDefault(), A(P(n, a));
|
|
69
|
+
else if (t.key === "Home" || t.key === "End") {
|
|
70
|
+
t.preventDefault();
|
|
71
|
+
const m = u(n).getUTCDay();
|
|
72
|
+
A(P(n, t.key === "Home" ? -m : 6 - m));
|
|
73
|
+
} else (t.key === "PageUp" || t.key === "PageDown") && (t.preventDefault(), U(t.key === "PageUp" ? -1 : 1));
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ h("div", { className: Z("font-product text-body-sm text-ink", j), children: [
|
|
76
|
+
/* @__PURE__ */ h("div", { className: "mb-2 flex h-row-default items-center justify-between", children: [
|
|
77
|
+
/* @__PURE__ */ r(N, { size: "icon", variant: "ghost", "aria-label": c, onClick: () => U(-1), children: /* @__PURE__ */ r(E, { size: 14, "aria-hidden": !0 }) }),
|
|
78
|
+
/* @__PURE__ */ r("span", { className: "font-[500]", children: K }),
|
|
79
|
+
/* @__PURE__ */ r(N, { size: "icon", variant: "ghost", "aria-label": l, onClick: () => U(1), children: /* @__PURE__ */ r(H, { size: 14, "aria-hidden": !0 }) })
|
|
80
|
+
] }),
|
|
81
|
+
/* @__PURE__ */ h("div", { role: "grid", "aria-label": o, "data-calendar-id": S, children: [
|
|
82
|
+
/* @__PURE__ */ r("div", { role: "row", className: "grid grid-cols-7", children: d.map((t) => /* @__PURE__ */ r("span", { role: "columnheader", className: "grid h-row-compact place-items-center text-micro text-graphite", children: t }, t)) }),
|
|
83
|
+
Array.from({ length: 6 }, (t, n) => /* @__PURE__ */ r("div", { role: "row", className: "grid grid-cols-7", children: V.slice(n * 7, n * 7 + 7).map((a) => {
|
|
84
|
+
const m = u(a), I = m.getUTCMonth() !== M - 1, x = a === e, q = !!(f && a < f || D && a > D);
|
|
85
|
+
return /* @__PURE__ */ r("span", { role: "gridcell", "aria-selected": x, children: /* @__PURE__ */ r(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
"data-date": a,
|
|
90
|
+
"aria-label": g(a),
|
|
91
|
+
"aria-current": a === $ ? "date" : void 0,
|
|
92
|
+
"aria-pressed": x,
|
|
93
|
+
disabled: q,
|
|
94
|
+
tabIndex: x || !e && m.getUTCDate() === 1 && !I ? 0 : -1,
|
|
95
|
+
onKeyDown: (B) => O(B, a),
|
|
96
|
+
onClick: () => {
|
|
97
|
+
i(a), C(p(m));
|
|
98
|
+
},
|
|
99
|
+
className: "grid size-control-default place-items-center rounded-control font-data text-caption tabular-nums text-ink outline-none hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-rust disabled:opacity-30 data-[outside=true]:text-graphite aria-pressed:bg-rust aria-pressed:text-on-accent",
|
|
100
|
+
"data-outside": I || void 0,
|
|
101
|
+
children: m.getUTCDate()
|
|
102
|
+
}
|
|
103
|
+
) }, a);
|
|
104
|
+
}) }, n))
|
|
105
|
+
] })
|
|
106
|
+
] });
|
|
107
|
+
}
|
|
108
|
+
function z({
|
|
109
|
+
value: e,
|
|
110
|
+
onValueChange: i,
|
|
111
|
+
label: o,
|
|
112
|
+
calendarLabel: s,
|
|
113
|
+
placeholder: d,
|
|
114
|
+
displayValue: c = (g) => g,
|
|
115
|
+
...l
|
|
116
|
+
}) {
|
|
117
|
+
const [g, f] = F(!1);
|
|
118
|
+
return /* @__PURE__ */ h(y.Root, { open: g, onOpenChange: f, children: [
|
|
119
|
+
/* @__PURE__ */ r(y.Trigger, { asChild: !0, children: /* @__PURE__ */ r(N, { variant: "secondary", "aria-label": o, className: "w-full justify-start", children: e ? c(e) : d }) }),
|
|
120
|
+
/* @__PURE__ */ r(y.Portal, { children: /* @__PURE__ */ r(
|
|
121
|
+
y.Content,
|
|
122
|
+
{
|
|
123
|
+
role: "dialog",
|
|
124
|
+
"aria-label": s,
|
|
125
|
+
sideOffset: 4,
|
|
126
|
+
collisionPadding: 8,
|
|
127
|
+
className: "z-50 w-80 rounded-panel border border-border bg-surface-raised p-3 shadow-pop outline-none",
|
|
128
|
+
children: /* @__PURE__ */ r(
|
|
129
|
+
Q,
|
|
130
|
+
{
|
|
131
|
+
...l,
|
|
132
|
+
value: e,
|
|
133
|
+
label: s,
|
|
134
|
+
onValueChange: (D) => {
|
|
135
|
+
i(D), f(!1);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
) })
|
|
141
|
+
] });
|
|
142
|
+
}
|
|
143
|
+
function ie({
|
|
144
|
+
start: e,
|
|
145
|
+
end: i,
|
|
146
|
+
onChange: o,
|
|
147
|
+
startLabel: s,
|
|
148
|
+
endLabel: d,
|
|
149
|
+
...c
|
|
150
|
+
}) {
|
|
151
|
+
return /* @__PURE__ */ h("div", { className: "grid min-w-0 gap-2 sm:grid-cols-2", children: [
|
|
152
|
+
/* @__PURE__ */ r(
|
|
153
|
+
z,
|
|
154
|
+
{
|
|
155
|
+
...c,
|
|
156
|
+
value: e,
|
|
157
|
+
label: s,
|
|
158
|
+
maximum: i || void 0,
|
|
159
|
+
onValueChange: (l) => o({ start: l, end: i })
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ r(
|
|
163
|
+
z,
|
|
164
|
+
{
|
|
165
|
+
...c,
|
|
166
|
+
value: i,
|
|
167
|
+
label: d,
|
|
168
|
+
minimum: e || void 0,
|
|
169
|
+
onValueChange: (l) => o({ start: e, end: l })
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
] });
|
|
173
|
+
}
|
|
174
|
+
function se({
|
|
175
|
+
label: e,
|
|
176
|
+
value: i,
|
|
177
|
+
onValueChange: o,
|
|
178
|
+
timezone: s,
|
|
179
|
+
minimum: d,
|
|
180
|
+
maximum: c
|
|
181
|
+
}) {
|
|
182
|
+
return /* @__PURE__ */ r(G, { label: e, children: /* @__PURE__ */ h("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
183
|
+
/* @__PURE__ */ r(
|
|
184
|
+
J,
|
|
185
|
+
{
|
|
186
|
+
type: "time",
|
|
187
|
+
"aria-label": e,
|
|
188
|
+
value: i,
|
|
189
|
+
min: d,
|
|
190
|
+
max: c,
|
|
191
|
+
onChange: (l) => o(l.target.value),
|
|
192
|
+
className: "min-w-0 flex-1 font-data tabular-nums"
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ r("span", { className: "shrink-0 font-mono text-data text-graphite", children: s })
|
|
196
|
+
] }) });
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
Q as Calendar,
|
|
200
|
+
z as DatePicker,
|
|
201
|
+
ie as DateRangePicker,
|
|
202
|
+
se as TimeField
|
|
203
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown as s } from "lucide-react";
|
|
3
|
+
import { Accordion as r, Collapsible as i } from "radix-ui";
|
|
4
|
+
function f({
|
|
5
|
+
value: t,
|
|
6
|
+
title: n,
|
|
7
|
+
children: a
|
|
8
|
+
}) {
|
|
9
|
+
return /* @__PURE__ */ e(r.Root, { type: "single", collapsible: !0, className: "overflow-hidden rounded-panel border border-border bg-surface-fog", children: /* @__PURE__ */ o(r.Item, { value: t, children: [
|
|
10
|
+
/* @__PURE__ */ e(r.Header, { children: /* @__PURE__ */ o(r.Trigger, { className: "group flex h-row-default w-full items-center justify-between gap-3 px-3 font-sohne text-body-sm font-[500] text-ink outline-none transition-colors hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-rust", children: [
|
|
11
|
+
/* @__PURE__ */ e("span", { children: n }),
|
|
12
|
+
/* @__PURE__ */ e(s, { size: 14, className: "shrink-0 text-graphite transition-transform group-data-[state=open]:rotate-180", "aria-hidden": !0 })
|
|
13
|
+
] }) }),
|
|
14
|
+
/* @__PURE__ */ e(r.Content, { className: "border-t border-divider px-3 py-2 font-sohne text-caption text-graphite", children: a })
|
|
15
|
+
] }) });
|
|
16
|
+
}
|
|
17
|
+
function p({ title: t, children: n }) {
|
|
18
|
+
return /* @__PURE__ */ o(i.Root, { className: "overflow-hidden rounded-panel border border-border bg-surface-fog", children: [
|
|
19
|
+
/* @__PURE__ */ o(i.Trigger, { className: "group flex h-row-default w-full items-center justify-between gap-3 px-3 font-sohne text-body-sm font-[500] text-ink outline-none transition-colors hover:bg-surface-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-rust", children: [
|
|
20
|
+
/* @__PURE__ */ e("span", { children: t }),
|
|
21
|
+
/* @__PURE__ */ e(s, { size: 14, className: "shrink-0 text-graphite transition-transform group-data-[state=open]:rotate-180", "aria-hidden": !0 })
|
|
22
|
+
] }),
|
|
23
|
+
/* @__PURE__ */ e(i.Content, { className: "border-t border-divider px-3 py-2 font-sohne text-caption text-graphite", children: n })
|
|
24
|
+
] });
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
f as Accordion,
|
|
28
|
+
p as Collapsible
|
|
29
|
+
};
|