@godxjp/ui 5.0.2 → 6.0.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 +101 -142
- package/dist/app/index.d.ts +140 -0
- package/dist/app/index.js +38 -0
- package/dist/app.prop-IobwLwaM.d.ts +90 -0
- package/dist/checkbox-NkFkqsQ8.d.ts +13 -0
- package/dist/chunk-2XW7J3EI.js +226 -0
- package/dist/chunk-3F2AKYRD.js +416 -0
- package/dist/chunk-3KPEZ5CF.js +37 -0
- package/dist/chunk-3UGU5TYP.js +89 -0
- package/dist/chunk-6RA3KSVK.js +588 -0
- package/dist/chunk-7NZFVD24.js +122 -0
- package/dist/chunk-7PWBC4BY.js +25 -0
- package/dist/chunk-7S7MYFXE.js +61 -0
- package/dist/chunk-7WRZG2IG.js +71 -0
- package/dist/chunk-B775Y6BE.js +1 -0
- package/dist/chunk-BHV2FUOA.js +111 -0
- package/dist/chunk-BI3HERR7.js +70 -0
- package/dist/chunk-BPSKQUL2.js +68 -0
- package/dist/chunk-CDWPQ5RP.js +187 -0
- package/dist/chunk-CP2LET6N.js +244 -0
- package/dist/chunk-CQBADMFG.js +20 -0
- package/dist/chunk-CRERCLIZ.js +33 -0
- package/dist/chunk-DU6ZYZRP.js +238 -0
- package/dist/chunk-DY5C44UP.js +55 -0
- package/dist/chunk-E4HJNQ62.js +117 -0
- package/dist/chunk-E76QIYSY.js +93 -0
- package/dist/chunk-F7PG4OEV.js +37 -0
- package/dist/chunk-GDSVW62T.js +171 -0
- package/dist/chunk-H2FHJOLU.js +178 -0
- package/dist/chunk-HJEBRCXL.js +55 -0
- package/dist/chunk-ICM6XBST.js +16 -0
- package/dist/chunk-IK7I3ABN.js +88 -0
- package/dist/chunk-L6J44O74.js +144 -0
- package/dist/chunk-LDSLS6HE.js +1 -0
- package/dist/chunk-LVNUHUEZ.js +191 -0
- package/dist/chunk-M64MVRLS.js +92 -0
- package/dist/chunk-NGQW3KEM.js +402 -0
- package/dist/chunk-NZ4FOC5N.js +559 -0
- package/dist/chunk-PIIRNAXA.js +26 -0
- package/dist/chunk-S66TJXJU.js +33 -0
- package/dist/chunk-SMLKNECP.js +133 -0
- package/dist/chunk-TAHBM3F2.js +66 -0
- package/dist/chunk-TO33OY4L.js +150 -0
- package/dist/chunk-TO7URV7U.js +51 -0
- package/dist/chunk-TOO5AEKL.js +81 -0
- package/dist/chunk-U3GHAOIJ.js +299 -0
- package/dist/chunk-U7N2A7A3.js +9 -0
- package/dist/chunk-UX634MYF.js +123 -0
- package/dist/chunk-V6UWJKZF.js +28 -0
- package/dist/chunk-VOHTRR5X.js +28 -0
- package/dist/chunk-WRFKVUPW.js +332 -0
- package/dist/chunk-WXW43RK5.js +24 -0
- package/dist/chunk-XG7XDYIM.js +60 -0
- package/dist/chunk-YFCQKO3B.js +842 -0
- package/dist/chunk-ZDWXGWLY.js +73 -0
- package/dist/chunk-ZLK5SPT6.js +11 -0
- package/dist/chunk-ZS6DTAM2.js +31 -0
- package/dist/chunk-ZT5UEUBO.js +1 -0
- package/dist/components/admin/index.d.ts +80 -0
- package/dist/components/admin/index.js +38 -0
- package/dist/components/data-display/badge.d.ts +12 -0
- package/dist/components/data-display/badge.js +3 -0
- package/dist/components/data-display/card.d.ts +87 -0
- package/dist/components/data-display/card.js +2 -0
- package/dist/components/data-display/index.d.ts +72 -0
- package/dist/components/data-display/index.js +89 -0
- package/dist/components/data-display/popover.d.ts +13 -0
- package/dist/components/data-display/popover.js +2 -0
- package/dist/components/data-display/scroll-area.d.ts +7 -0
- package/dist/components/data-display/scroll-area.js +2 -0
- package/dist/components/data-display/table.d.ts +10 -0
- package/dist/components/data-display/table.js +3 -0
- package/dist/components/data-entry/autocomplete.d.ts +16 -0
- package/dist/components/data-entry/autocomplete.js +8 -0
- package/dist/components/data-entry/calendar.d.ts +16 -0
- package/dist/components/data-entry/calendar.js +4 -0
- package/dist/components/data-entry/cascader.d.ts +32 -0
- package/dist/components/data-entry/cascader.js +13 -0
- package/dist/components/data-entry/checkbox.d.ts +13 -0
- package/dist/components/data-entry/checkbox.js +4 -0
- package/dist/components/data-entry/color-picker.d.ts +16 -0
- package/dist/components/data-entry/color-picker.js +6 -0
- package/dist/components/data-entry/command.d.ts +69 -0
- package/dist/components/data-entry/command.js +3 -0
- package/dist/components/data-entry/date-picker.d.ts +16 -0
- package/dist/components/data-entry/date-picker.js +8 -0
- package/dist/components/data-entry/date-range-picker.d.ts +16 -0
- package/dist/components/data-entry/date-range-picker.js +8 -0
- package/dist/components/data-entry/index.d.ts +53 -0
- package/dist/components/data-entry/index.js +152 -0
- package/dist/components/data-entry/input.d.ts +6 -0
- package/dist/components/data-entry/input.js +2 -0
- package/dist/components/data-entry/label.d.ts +8 -0
- package/dist/components/data-entry/label.js +2 -0
- package/dist/components/data-entry/radio.d.ts +24 -0
- package/dist/components/data-entry/radio.js +4 -0
- package/dist/components/data-entry/select.d.ts +18 -0
- package/dist/components/data-entry/select.js +3 -0
- package/dist/components/data-entry/slider.d.ts +16 -0
- package/dist/components/data-entry/slider.js +2 -0
- package/dist/components/data-entry/switch.d.ts +17 -0
- package/dist/components/data-entry/switch.js +2 -0
- package/dist/components/data-entry/textarea.d.ts +6 -0
- package/dist/components/data-entry/textarea.js +3 -0
- package/dist/components/data-entry/time-picker.d.ts +16 -0
- package/dist/components/data-entry/time-picker.js +7 -0
- package/dist/components/data-entry/transfer.d.ts +17 -0
- package/dist/components/data-entry/transfer.js +11 -0
- package/dist/components/data-entry/tree-select.d.ts +26 -0
- package/dist/components/data-entry/tree-select.js +13 -0
- package/dist/components/data-entry/upload.d.ts +42 -0
- package/dist/components/data-entry/upload.js +11 -0
- package/dist/components/feedback/alert.d.ts +60 -0
- package/dist/components/feedback/alert.js +7 -0
- package/dist/components/feedback/dialog.d.ts +64 -0
- package/dist/components/feedback/dialog.js +7 -0
- package/dist/components/feedback/index.d.ts +16 -0
- package/dist/components/feedback/index.js +14 -0
- package/dist/components/feedback/sheet.d.ts +24 -0
- package/dist/components/feedback/sheet.js +2 -0
- package/dist/components/feedback/sonner.d.ts +6 -0
- package/dist/components/feedback/sonner.js +1 -0
- package/dist/components/general/button.d.ts +20 -0
- package/dist/components/general/button.js +2 -0
- package/dist/components/general/index.d.ts +6 -0
- package/dist/components/general/index.js +2 -0
- package/dist/components/layout/index.d.ts +71 -0
- package/dist/components/layout/index.js +5 -0
- package/dist/components/navigation/dropdown-menu.d.ts +28 -0
- package/dist/components/navigation/dropdown-menu.js +2 -0
- package/dist/components/navigation/index.d.ts +32 -0
- package/dist/components/navigation/index.js +12 -0
- package/dist/components/navigation/pagination.d.ts +11 -0
- package/dist/components/navigation/pagination.js +7 -0
- package/dist/components/navigation/steps.d.ts +12 -0
- package/dist/components/navigation/steps.js +3 -0
- package/dist/components/navigation/tabs-items.d.ts +12 -0
- package/dist/components/navigation/tabs-items.js +3 -0
- package/dist/components/navigation/tabs.d.ts +12 -0
- package/dist/components/navigation/tabs.js +2 -0
- package/dist/components/query/index.d.ts +43 -0
- package/dist/components/query/index.js +8 -0
- package/dist/components/ui/index.d.ts +57 -0
- package/dist/components/ui/index.js +37 -0
- package/dist/content.prop-D1Dd3TAc.d.ts +31 -0
- package/dist/data-display.prop-DNTAzmDy.d.ts +58 -0
- package/dist/data-entry.prop-BEGA1lTq.d.ts +323 -0
- package/dist/data-table-D1u_rKLK.d.ts +83 -0
- package/dist/data.prop-BVvfKC_g.d.ts +41 -0
- package/dist/feedback.prop-BmxUlpAW.d.ts +64 -0
- package/dist/filter-bar-B7OGFO9S.d.ts +10 -0
- package/dist/form/index.d.ts +21 -0
- package/dist/form/index.js +4 -0
- package/dist/form.prop-BHgpuFFm.d.ts +41 -0
- package/dist/format-date-ByyZoqI5.d.ts +51 -0
- package/dist/general.prop-D7brMPNL.d.ts +16 -0
- package/dist/i18n/index.d.ts +217 -0
- package/dist/i18n/index.js +2 -0
- package/dist/index.d.ts +46 -26
- package/dist/index.js +39 -13062
- package/dist/inline-C5u6ptJV.d.ts +10 -0
- package/dist/interaction.prop-Cdn7wOtq.d.ts +25 -0
- package/dist/layout.prop-4TCNvyQZ.d.ts +20 -0
- package/dist/layout.prop-C795F0qg.d.ts +112 -0
- package/dist/lib/datetime/index.d.ts +31 -0
- package/dist/lib/datetime/index.js +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +1 -0
- package/dist/navigation.prop-DpZqcXey.d.ts +78 -0
- package/dist/navigation.prop-DxBiClEH.d.ts +20 -0
- package/dist/props/components/index.d.ts +27 -0
- package/dist/props/components/index.js +1 -0
- package/dist/props/index.d.ts +28 -0
- package/dist/props/index.js +3 -0
- package/dist/props/registry.d.ts +649 -0
- package/dist/props/registry.js +1 -0
- package/dist/props/vocabulary/index.d.ts +7 -0
- package/dist/props/vocabulary/index.js +1 -0
- package/dist/query.prop-hIPrk2zI.d.ts +71 -0
- package/dist/search-input-uP01rY1L.d.ts +22 -0
- package/dist/shared.prop-BNRJc9K0.d.ts +45 -0
- package/dist/styles/alert-layout.css +191 -0
- package/dist/styles/badge-layout.css +22 -0
- package/dist/styles/card-layout.css +373 -0
- package/dist/styles/control.css +504 -0
- package/dist/styles/data-display-layout.css +246 -0
- package/dist/styles/density.css +43 -0
- package/dist/styles/dialog-layout.css +84 -0
- package/dist/styles/index.css +105 -0
- package/dist/styles/layout.css +479 -0
- package/dist/styles/shell-layout.css +604 -0
- package/dist/styles/table-layout.css +109 -0
- package/dist/theme/example.service.css +37 -0
- package/dist/tokens/base.css +13 -0
- package/dist/tokens/foundation.css +151 -0
- package/dist/tokens/primitives/badge.css +13 -0
- package/dist/tokens/primitives/card.css +29 -0
- package/dist/tokens/primitives/control.css +55 -0
- package/dist/tokens/primitives/feedback.css +17 -0
- package/dist/tokens/primitives/layout.css +20 -0
- package/dist/tokens/primitives/navigation.css +13 -0
- package/dist/tokens/primitives/table.css +10 -0
- package/dist/types-mvzYGrma.d.ts +37 -0
- package/dist/use-toast-Dol5bdY3.d.ts +34 -0
- package/package.json +279 -117
- package/scripts/ui-audit.mjs +179 -0
- package/BRAND.md +0 -296
- package/CHANGELOG.md +0 -668
- package/config/eslint.js +0 -54
- package/config/prettier.cjs +0 -20
- package/config/tsconfig.base.json +0 -22
- package/config/vitest.base.ts +0 -26
- package/dist/MiniMonth-YAmPGEpC.d.ts +0 -143
- package/dist/Table.types-BbsxoIYE.d.ts +0 -352
- package/dist/color-DO0qqUAb.d.ts +0 -38
- package/dist/components/composites.d.ts +0 -963
- package/dist/components/composites.js +0 -7343
- package/dist/components/composites.js.map +0 -1
- package/dist/components/primitives.d.ts +0 -2744
- package/dist/components/primitives.js +0 -7356
- package/dist/components/primitives.js.map +0 -1
- package/dist/components/shell.d.ts +0 -182
- package/dist/components/shell.js +0 -774
- package/dist/components/shell.js.map +0 -1
- package/dist/hooks.d.ts +0 -100
- package/dist/hooks.js +0 -558
- package/dist/hooks.js.map +0 -1
- package/dist/i18n.d.ts +0 -61
- package/dist/i18n.js +0 -860
- package/dist/i18n.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/padding-DY0JV5Ja.d.ts +0 -16
- package/dist/preferences.d.ts +0 -132
- package/dist/preferences.js +0 -262
- package/dist/preferences.js.map +0 -1
- package/dist/props.d.ts +0 -86
- package/dist/props.js +0 -16
- package/dist/props.js.map +0 -1
- package/dist/size-CQwNvOWd.d.ts +0 -19
- package/dist/types-LTj-2bl-.d.ts +0 -30
- package/dist/useTableViews-D5NIAJ7h.d.ts +0 -154
- package/src/tokens/tailwind.css +0 -158
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Popover, PopoverTrigger, PopoverContent } from './chunk-DY5C44UP.js';
|
|
2
|
+
import { Input } from './chunk-VOHTRR5X.js';
|
|
3
|
+
import { Button } from './chunk-HJEBRCXL.js';
|
|
4
|
+
import { useTranslation } from './chunk-3F2AKYRD.js';
|
|
5
|
+
import { isValidHhmm, formatTimeOfDay, normalizeHhmm } from './chunk-YFCQKO3B.js';
|
|
6
|
+
import { cn } from './chunk-U7N2A7A3.js';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { Clock } from 'lucide-react';
|
|
9
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
|
+
|
|
11
|
+
function pad2(n) {
|
|
12
|
+
return String(n).padStart(2, "0");
|
|
13
|
+
}
|
|
14
|
+
function buildMinutes(step) {
|
|
15
|
+
const safe = Math.min(60, Math.max(1, step));
|
|
16
|
+
const items = [];
|
|
17
|
+
for (let m = 0; m < 60; m += safe) items.push(m);
|
|
18
|
+
return items;
|
|
19
|
+
}
|
|
20
|
+
function parseHhmm(value) {
|
|
21
|
+
const normalized = value ? normalizeHhmm(value) : null;
|
|
22
|
+
if (!normalized) return { hour: 9, minute: 0 };
|
|
23
|
+
const [h, m] = normalized.split(":").map(Number);
|
|
24
|
+
return { hour: h, minute: m };
|
|
25
|
+
}
|
|
26
|
+
function TimeColumn({
|
|
27
|
+
label,
|
|
28
|
+
items,
|
|
29
|
+
selected,
|
|
30
|
+
onSelect
|
|
31
|
+
}) {
|
|
32
|
+
const listRef = React.useRef(null);
|
|
33
|
+
React.useEffect(() => {
|
|
34
|
+
listRef.current?.querySelector('[data-selected="true"]')?.scrollIntoView({ block: "center" });
|
|
35
|
+
}, [selected]);
|
|
36
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
37
|
+
/* @__PURE__ */ jsx("div", { className: "text-muted-foreground border-b px-1 py-1.5 text-center text-xs font-medium", children: label }),
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
ref: listRef,
|
|
42
|
+
className: "h-52 [scrollbar-width:thin] [scrollbar-gutter:stable] overflow-y-scroll overscroll-contain p-1",
|
|
43
|
+
children: items.map((item) => /* @__PURE__ */ jsx(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
type: "button",
|
|
47
|
+
"data-selected": item === selected,
|
|
48
|
+
className: cn(
|
|
49
|
+
"hover:bg-accent flex w-full items-center justify-center rounded-md py-1.5 text-sm tabular-nums transition-colors",
|
|
50
|
+
item === selected && "bg-primary text-primary-foreground hover:bg-primary/90"
|
|
51
|
+
),
|
|
52
|
+
onClick: () => {
|
|
53
|
+
onSelect(item);
|
|
54
|
+
},
|
|
55
|
+
children: pad2(item)
|
|
56
|
+
},
|
|
57
|
+
item
|
|
58
|
+
))
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
function TimePickerPanel({ value, minuteStep, onChange, onDone }) {
|
|
64
|
+
const { t } = useTranslation();
|
|
65
|
+
const { hour, minute } = parseHhmm(value);
|
|
66
|
+
const minutes = buildMinutes(minuteStep);
|
|
67
|
+
const snappedMinute = minutes.includes(minute) ? minute : minutes[0];
|
|
68
|
+
const [draft, setDraft] = React.useState(value);
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
setDraft(value);
|
|
71
|
+
}, [value]);
|
|
72
|
+
const commitDraft = () => {
|
|
73
|
+
const normalized = normalizeHhmm(draft);
|
|
74
|
+
if (!normalized) return;
|
|
75
|
+
onChange(normalized);
|
|
76
|
+
onDone?.();
|
|
77
|
+
};
|
|
78
|
+
const commit = (next) => {
|
|
79
|
+
onChange(next);
|
|
80
|
+
onDone?.();
|
|
81
|
+
};
|
|
82
|
+
return /* @__PURE__ */ jsxs("div", { className: "w-36", children: [
|
|
83
|
+
/* @__PURE__ */ jsxs("div", { className: "divide-border flex divide-x", children: [
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
TimeColumn,
|
|
86
|
+
{
|
|
87
|
+
label: t("dataEntry.timePicker.hour"),
|
|
88
|
+
items: Array.from({ length: 24 }, (_, i) => i),
|
|
89
|
+
selected: hour,
|
|
90
|
+
onSelect: (h) => {
|
|
91
|
+
onChange(`${pad2(h)}:${pad2(snappedMinute)}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
TimeColumn,
|
|
97
|
+
{
|
|
98
|
+
label: t("dataEntry.timePicker.minute"),
|
|
99
|
+
items: minutes,
|
|
100
|
+
selected: snappedMinute,
|
|
101
|
+
onSelect: (m) => {
|
|
102
|
+
commit(`${pad2(hour)}:${pad2(m)}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] }),
|
|
107
|
+
/* @__PURE__ */ jsx("div", { className: "border-t p-2", children: /* @__PURE__ */ jsx(
|
|
108
|
+
Input,
|
|
109
|
+
{
|
|
110
|
+
value: draft,
|
|
111
|
+
onChange: (e) => {
|
|
112
|
+
setDraft(e.target.value);
|
|
113
|
+
},
|
|
114
|
+
inputMode: "numeric",
|
|
115
|
+
autoComplete: "off",
|
|
116
|
+
placeholder: t("dataEntry.timePicker.typeLabel"),
|
|
117
|
+
"aria-label": t("dataEntry.timePicker.typeLabel"),
|
|
118
|
+
className: "text-center tabular-nums",
|
|
119
|
+
onKeyDown: (e) => {
|
|
120
|
+
if (e.key === "Enter") {
|
|
121
|
+
e.preventDefault();
|
|
122
|
+
commitDraft();
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onBlur: () => {
|
|
126
|
+
const normalized = normalizeHhmm(draft);
|
|
127
|
+
if (normalized) setDraft(normalized);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
) })
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
function TimePicker({
|
|
134
|
+
value: controlledValue,
|
|
135
|
+
defaultValue,
|
|
136
|
+
onChange,
|
|
137
|
+
placeholder,
|
|
138
|
+
disabled,
|
|
139
|
+
className,
|
|
140
|
+
id,
|
|
141
|
+
minuteStep = 5
|
|
142
|
+
}) {
|
|
143
|
+
const { t } = useTranslation();
|
|
144
|
+
const [open, setOpen] = React.useState(false);
|
|
145
|
+
const [internal, setInternal] = React.useState(defaultValue ?? "");
|
|
146
|
+
const isControlled = controlledValue !== void 0;
|
|
147
|
+
const value = isControlled ? controlledValue : internal;
|
|
148
|
+
const resolvedPlaceholder = placeholder ?? t("dataEntry.timePicker.placeholder");
|
|
149
|
+
const setValue = (next) => {
|
|
150
|
+
if (!isControlled) setInternal(next);
|
|
151
|
+
onChange?.(next);
|
|
152
|
+
};
|
|
153
|
+
const display = value && isValidHhmm(value) ? formatTimeOfDay(value) : value || null;
|
|
154
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
155
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
156
|
+
Button,
|
|
157
|
+
{
|
|
158
|
+
id,
|
|
159
|
+
type: "button",
|
|
160
|
+
variant: "outline",
|
|
161
|
+
disabled,
|
|
162
|
+
className: cn(
|
|
163
|
+
"w-full justify-start text-left font-normal tabular-nums",
|
|
164
|
+
!display && "text-muted-foreground",
|
|
165
|
+
className
|
|
166
|
+
),
|
|
167
|
+
children: [
|
|
168
|
+
/* @__PURE__ */ jsx(Clock, { className: "mr-2 size-4 shrink-0", "aria-hidden": "true" }),
|
|
169
|
+
display ?? resolvedPlaceholder
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
) }),
|
|
173
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
174
|
+
TimePickerPanel,
|
|
175
|
+
{
|
|
176
|
+
value: value || "09:00",
|
|
177
|
+
minuteStep,
|
|
178
|
+
onChange: setValue,
|
|
179
|
+
onDone: () => {
|
|
180
|
+
setOpen(false);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
) })
|
|
184
|
+
] });
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { TimePicker };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { normalizeTreeOptions, formatPathLabels, getNodeByPath, filterTreeOptions, pathsEqual, pathKey } from './chunk-SMLKNECP.js';
|
|
2
|
+
import { Checkbox } from './chunk-E76QIYSY.js';
|
|
3
|
+
import { Command, CommandInput } from './chunk-V6UWJKZF.js';
|
|
4
|
+
import { Popover, PopoverTrigger, PopoverContent } from './chunk-DY5C44UP.js';
|
|
5
|
+
import { ScrollArea, ScrollBar } from './chunk-3KPEZ5CF.js';
|
|
6
|
+
import { Button } from './chunk-HJEBRCXL.js';
|
|
7
|
+
import { useTranslation } from './chunk-3F2AKYRD.js';
|
|
8
|
+
import { cn } from './chunk-U7N2A7A3.js';
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
import { X, ChevronsUpDown, Check, ChevronRight } from 'lucide-react';
|
|
11
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
12
|
+
|
|
13
|
+
function pathInValues(path, values) {
|
|
14
|
+
return values.some((v) => pathsEqual(v, path));
|
|
15
|
+
}
|
|
16
|
+
function togglePath(values, path) {
|
|
17
|
+
if (pathInValues(path, values)) return values.filter((v) => !pathsEqual(v, path));
|
|
18
|
+
return [...values, path];
|
|
19
|
+
}
|
|
20
|
+
function Cascader({
|
|
21
|
+
options: optionsProp,
|
|
22
|
+
value,
|
|
23
|
+
defaultValue,
|
|
24
|
+
onChange,
|
|
25
|
+
multiple,
|
|
26
|
+
changeOnSelect,
|
|
27
|
+
showSearch,
|
|
28
|
+
placeholder,
|
|
29
|
+
disabled,
|
|
30
|
+
className,
|
|
31
|
+
id,
|
|
32
|
+
expandTrigger = "click",
|
|
33
|
+
fieldNames,
|
|
34
|
+
allowClear = true
|
|
35
|
+
}) {
|
|
36
|
+
const { t } = useTranslation();
|
|
37
|
+
const options = React.useMemo(
|
|
38
|
+
() => normalizeTreeOptions(optionsProp, fieldNames),
|
|
39
|
+
[optionsProp, fieldNames]
|
|
40
|
+
);
|
|
41
|
+
const [open, setOpen] = React.useState(false);
|
|
42
|
+
const [activePath, setActivePath] = React.useState([]);
|
|
43
|
+
const [search, setSearch] = React.useState("");
|
|
44
|
+
const isControlledSingle = !multiple && value !== void 0;
|
|
45
|
+
const isControlledMulti = multiple && value !== void 0;
|
|
46
|
+
const [internalSingle, setInternalSingle] = React.useState(
|
|
47
|
+
multiple ? [] : defaultValue ?? []
|
|
48
|
+
);
|
|
49
|
+
const [internalMulti, setInternalMulti] = React.useState(
|
|
50
|
+
defaultValue ?? []
|
|
51
|
+
);
|
|
52
|
+
const singleValue = isControlledSingle ? value : internalSingle;
|
|
53
|
+
const multiValue = isControlledMulti ? value : internalMulti;
|
|
54
|
+
const resolvedPlaceholder = placeholder ?? t("dataEntry.cascader.placeholder");
|
|
55
|
+
const displayLabel = React.useMemo(() => {
|
|
56
|
+
if (multiple) {
|
|
57
|
+
if (!multiValue.length) return null;
|
|
58
|
+
return multiValue.map((path) => formatPathLabels(getNodeByPath(options, path))).join(", ");
|
|
59
|
+
}
|
|
60
|
+
if (!singleValue.length) return null;
|
|
61
|
+
return formatPathLabels(getNodeByPath(options, singleValue));
|
|
62
|
+
}, [multiple, multiValue, singleValue, options]);
|
|
63
|
+
const commitSingle = (path) => {
|
|
64
|
+
if (!isControlledSingle) setInternalSingle(path);
|
|
65
|
+
onChange?.(path, getNodeByPath(options, path));
|
|
66
|
+
setOpen(false);
|
|
67
|
+
setActivePath([]);
|
|
68
|
+
setSearch("");
|
|
69
|
+
};
|
|
70
|
+
const commitMulti = (paths) => {
|
|
71
|
+
if (!isControlledMulti) setInternalMulti(paths);
|
|
72
|
+
onChange?.(
|
|
73
|
+
paths,
|
|
74
|
+
paths.map((p) => getNodeByPath(options, p))
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
const columns = React.useMemo(() => {
|
|
78
|
+
const cols = [options];
|
|
79
|
+
for (const segment of activePath) {
|
|
80
|
+
const col = cols.at(-1);
|
|
81
|
+
const node = col?.find((n) => n.value === segment);
|
|
82
|
+
if (node?.children?.length) cols.push(node.children);
|
|
83
|
+
else break;
|
|
84
|
+
}
|
|
85
|
+
return cols;
|
|
86
|
+
}, [options, activePath]);
|
|
87
|
+
const handleSelectNode = (node, path) => {
|
|
88
|
+
const hasChildren = (node.children?.length ?? 0) > 0 && node.isLeaf !== true;
|
|
89
|
+
if (hasChildren && !changeOnSelect) {
|
|
90
|
+
setActivePath(path);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (multiple) {
|
|
94
|
+
commitMulti(togglePath(multiValue, path));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
commitSingle(path);
|
|
98
|
+
};
|
|
99
|
+
const isSearching = showSearch && search.trim().length > 0;
|
|
100
|
+
const searchResults = React.useMemo(
|
|
101
|
+
() => isSearching ? filterTreeOptions(options, search) : [],
|
|
102
|
+
[options, search, isSearching]
|
|
103
|
+
);
|
|
104
|
+
const handleOpenChange = (next) => {
|
|
105
|
+
setOpen(next);
|
|
106
|
+
if (!next) {
|
|
107
|
+
setSearch("");
|
|
108
|
+
setActivePath([]);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const clearValue = (e) => {
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
if (multiple) commitMulti([]);
|
|
114
|
+
else commitSingle([]);
|
|
115
|
+
};
|
|
116
|
+
const renderCascadeColumns = () => /* @__PURE__ */ jsxs(ScrollArea, { className: "w-full", children: [
|
|
117
|
+
/* @__PURE__ */ jsx("div", { className: "flex max-h-[min(280px,50vh)]", children: columns.map((col, colIndex) => /* @__PURE__ */ jsx(
|
|
118
|
+
"ul",
|
|
119
|
+
{
|
|
120
|
+
className: "min-w-[9rem] border-r last:border-r-0",
|
|
121
|
+
onMouseLeave: expandTrigger === "hover" ? () => setActivePath(activePath.slice(0, colIndex)) : void 0,
|
|
122
|
+
children: col.map((node) => {
|
|
123
|
+
const path = [...activePath.slice(0, colIndex), node.value];
|
|
124
|
+
const hasChildren = (node.children?.length ?? 0) > 0 && node.isLeaf !== true;
|
|
125
|
+
const active = activePath[colIndex] === node.value;
|
|
126
|
+
const selected = multiple ? pathInValues(path, multiValue) : pathsEqual(path, singleValue);
|
|
127
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
128
|
+
"button",
|
|
129
|
+
{
|
|
130
|
+
type: "button",
|
|
131
|
+
disabled: node.disabled,
|
|
132
|
+
className: cn(
|
|
133
|
+
"flex w-full items-center gap-1 px-3 py-2 text-sm outline-none",
|
|
134
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
135
|
+
active && "bg-accent/70 font-medium",
|
|
136
|
+
node.disabled && "pointer-events-none opacity-50"
|
|
137
|
+
),
|
|
138
|
+
onMouseEnter: expandTrigger === "hover" && hasChildren ? () => setActivePath(path) : void 0,
|
|
139
|
+
onClick: () => !node.disabled && handleSelectNode(node, path),
|
|
140
|
+
children: [
|
|
141
|
+
multiple && /* @__PURE__ */ jsx(
|
|
142
|
+
Checkbox,
|
|
143
|
+
{
|
|
144
|
+
checked: selected,
|
|
145
|
+
disabled: node.disabled,
|
|
146
|
+
className: "mr-1",
|
|
147
|
+
"aria-hidden": true,
|
|
148
|
+
tabIndex: -1
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
!multiple && selected && /* @__PURE__ */ jsx(Check, { className: "mr-1 size-4 shrink-0", "aria-hidden": "true" }),
|
|
152
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-left", children: node.label }),
|
|
153
|
+
hasChildren && /* @__PURE__ */ jsx(ChevronRight, { className: "size-4 shrink-0 opacity-50", "aria-hidden": "true" })
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
) }, node.value);
|
|
157
|
+
})
|
|
158
|
+
},
|
|
159
|
+
colIndex
|
|
160
|
+
)) }),
|
|
161
|
+
/* @__PURE__ */ jsx(ScrollBar, { orientation: "horizontal" })
|
|
162
|
+
] });
|
|
163
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
164
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
165
|
+
Button,
|
|
166
|
+
{
|
|
167
|
+
id,
|
|
168
|
+
type: "button",
|
|
169
|
+
variant: "outline",
|
|
170
|
+
role: "combobox",
|
|
171
|
+
"aria-expanded": open,
|
|
172
|
+
disabled,
|
|
173
|
+
className: cn(
|
|
174
|
+
"w-full justify-between font-normal",
|
|
175
|
+
!displayLabel && "text-muted-foreground",
|
|
176
|
+
className
|
|
177
|
+
),
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: displayLabel ?? resolvedPlaceholder }),
|
|
180
|
+
/* @__PURE__ */ jsxs("span", { className: "ml-2 flex shrink-0 items-center gap-1", children: [
|
|
181
|
+
allowClear && displayLabel && !disabled && /* @__PURE__ */ jsx(
|
|
182
|
+
X,
|
|
183
|
+
{
|
|
184
|
+
className: "size-4 opacity-50 hover:opacity-100",
|
|
185
|
+
"aria-hidden": "true",
|
|
186
|
+
onClick: clearValue
|
|
187
|
+
}
|
|
188
|
+
),
|
|
189
|
+
/* @__PURE__ */ jsx(ChevronsUpDown, { className: "size-4 opacity-50", "aria-hidden": "true" })
|
|
190
|
+
] })
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
) }),
|
|
194
|
+
/* @__PURE__ */ jsxs(
|
|
195
|
+
PopoverContent,
|
|
196
|
+
{
|
|
197
|
+
className: "w-auto min-w-[var(--radix-popover-trigger-width)] p-0",
|
|
198
|
+
align: "start",
|
|
199
|
+
children: [
|
|
200
|
+
showSearch && /* @__PURE__ */ jsx("div", { className: "border-b p-2", children: /* @__PURE__ */ jsx(Command, { shouldFilter: false, children: /* @__PURE__ */ jsx(
|
|
201
|
+
CommandInput,
|
|
202
|
+
{
|
|
203
|
+
placeholder: t("dataEntry.cascader.searchPlaceholder"),
|
|
204
|
+
value: search,
|
|
205
|
+
onValueChange: setSearch
|
|
206
|
+
}
|
|
207
|
+
) }) }),
|
|
208
|
+
isSearching ? /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-[min(300px,50vh)]", children: /* @__PURE__ */ jsx("div", { className: "p-1", children: searchResults.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground py-6 text-center text-sm", children: t("dataEntry.cascader.empty") }) : searchResults.map(({ path, labels }) => {
|
|
209
|
+
const label = labels.join(" / ");
|
|
210
|
+
const selected = multiple ? pathInValues(path, multiValue) : pathsEqual(path, singleValue);
|
|
211
|
+
return /* @__PURE__ */ jsxs(
|
|
212
|
+
"button",
|
|
213
|
+
{
|
|
214
|
+
type: "button",
|
|
215
|
+
className: cn(
|
|
216
|
+
"flex w-full items-center rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
217
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
218
|
+
selected && "bg-accent/60"
|
|
219
|
+
),
|
|
220
|
+
onClick: () => handleSelectNode({ value: path.at(-1)}, path),
|
|
221
|
+
children: [
|
|
222
|
+
multiple ? /* @__PURE__ */ jsx(Checkbox, { checked: selected, className: "mr-2", "aria-hidden": true, tabIndex: -1 }) : /* @__PURE__ */ jsx(
|
|
223
|
+
Check,
|
|
224
|
+
{
|
|
225
|
+
className: cn(
|
|
226
|
+
"mr-2 size-4 shrink-0",
|
|
227
|
+
selected ? "opacity-100" : "opacity-0"
|
|
228
|
+
),
|
|
229
|
+
"aria-hidden": "true"
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-left", children: label })
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
pathKey(path)
|
|
236
|
+
);
|
|
237
|
+
}) }) }) : renderCascadeColumns()
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
] });
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export { Cascader };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Label } from './chunk-7PWBC4BY.js';
|
|
2
|
+
import { cn } from './chunk-U7N2A7A3.js';
|
|
3
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function ChoiceField({ id, label, description, className, children }) {
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("ui-choice-field", className), children: [
|
|
7
|
+
/* @__PURE__ */ jsx("div", { className: "ui-choice-control", children }),
|
|
8
|
+
/* @__PURE__ */ jsxs("div", { className: "ui-choice-content", children: [
|
|
9
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, className: "ui-choice-label", children: label }),
|
|
10
|
+
description ? /* @__PURE__ */ jsx("p", { className: "ui-choice-description", children: description }) : null
|
|
11
|
+
] })
|
|
12
|
+
] });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/components/data-entry/choice-option.ts
|
|
16
|
+
function choiceGroupClassName(_orientation = "vertical", className) {
|
|
17
|
+
return cn("ui-choice-group", className);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { ChoiceField, choiceGroupClassName };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cn } from './chunk-U7N2A7A3.js';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var Slider = React.forwardRef(
|
|
7
|
+
({ className, defaultValue, value, min = 0, max = 100, ...props }, ref) => {
|
|
8
|
+
const values = React.useMemo(
|
|
9
|
+
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
10
|
+
[defaultValue, max, min, value]
|
|
11
|
+
);
|
|
12
|
+
return /* @__PURE__ */ jsxs(
|
|
13
|
+
SliderPrimitive.Root,
|
|
14
|
+
{
|
|
15
|
+
ref,
|
|
16
|
+
"data-slot": "slider",
|
|
17
|
+
className: cn("ui-slider", className),
|
|
18
|
+
defaultValue,
|
|
19
|
+
min,
|
|
20
|
+
max,
|
|
21
|
+
value,
|
|
22
|
+
...props,
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsx(SliderPrimitive.Track, { "data-slot": "slider-track", className: "ui-slider-track", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { "data-slot": "slider-range", className: "ui-slider-range" }) }),
|
|
25
|
+
values.map((_, index) => /* @__PURE__ */ jsx(SliderPrimitive.Thumb, { "data-slot": "slider-thumb", className: "ui-slider-thumb" }, index))
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
32
|
+
|
|
33
|
+
export { Slider };
|