@tradalab/lyra 3.17.0 → 3.18.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 +2 -2
- package/dist/blocks/index.d.ts +89 -6
- package/dist/blocks/index.js +337 -72
- package/dist/blocks/index.js.map +1 -1
- package/dist/{chunk-AIULLZYM.js → chunk-D2O4GTCC.js} +12 -3
- package/dist/chunk-D2O4GTCC.js.map +1 -0
- package/dist/hooks/index.d.ts +10 -3
- package/dist/hooks/index.js +1 -1
- package/dist/{plate-BJ19iaVV.d.ts → plate-iXwbupLU.d.ts} +1 -1
- package/dist/{plate-picker-dhKLjz_6.d.ts → plate-picker-DdC2HFo6.d.ts} +1 -1
- package/dist/shell/index.d.ts +2 -2
- package/dist/shell/index.js +1 -1
- package/dist/ui/index.d.ts +2 -2
- package/dist/{use-compact-BvI4sJf9.d.ts → use-compact-ahmJWpSH.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-AIULLZYM.js.map +0 -1
package/dist/blocks/index.js
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Label, Badge, Combobox, ComboboxInput, ComboboxContent, ComboboxEmpty, ComboboxList, ComboboxItem, Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, Spinner, Alert, AlertDescription, FieldGroup, FieldSet, FieldLegend, FieldDescription, Field, FieldContent, FieldLabel, FieldSeparator, Progress } from '../chunk-ASSRDIKG.js';
|
|
2
|
+
import { Label, Badge, Combobox, ComboboxInput, ComboboxContent, ComboboxEmpty, ComboboxList, ComboboxItem, Drawer, DrawerTrigger, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription, Calendar, Spinner, Alert, AlertDescription, FieldGroup, FieldSet, FieldLegend, FieldDescription, Field, FieldContent, FieldLabel, FieldSeparator, Progress } from '../chunk-ASSRDIKG.js';
|
|
3
3
|
export { PreferenceScript } from '../chunk-ASSRDIKG.js';
|
|
4
4
|
import { NativeSelect, NativeSelectOption } from '../chunk-KSF233MC.js';
|
|
5
|
-
export { useCompact, usePlate } from '../chunk-
|
|
5
|
+
export { useCompact, usePlate } from '../chunk-D2O4GTCC.js';
|
|
6
6
|
import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter, RadioGroup, RadioGroupItem, Switch } from '../chunk-UNRT3B6P.js';
|
|
7
7
|
export { PlatePicker } from '../chunk-UNRT3B6P.js';
|
|
8
8
|
export { BEARING_PLATES, PLATES, derivePlate, isPlate } from '../chunk-D7DMRCDY.js';
|
|
9
9
|
import '../chunk-OH3OMK7A.js';
|
|
10
10
|
import { isConnectionColor, CONNECTION_COLOR_NAMES, CONNECTION_COLORS, addTag } from '../chunk-A3T2BEQH.js';
|
|
11
|
-
import { Dialog, DialogOverlay, DialogContent, DialogTitle, DialogDescription } from '../chunk-L4LQCVOF.js';
|
|
11
|
+
import { Dialog, DialogOverlay, DialogContent, DialogTitle, DialogDescription, Popover, PopoverTrigger, PopoverContent } from '../chunk-L4LQCVOF.js';
|
|
12
12
|
import { foldText } from '../chunk-5XFDQRXV.js';
|
|
13
|
-
import { Avatar, AvatarImage, AvatarFallback } from '../chunk-VXW3K5O5.js';
|
|
13
|
+
import { Textarea, InputGroup, InputGroupInput, InputGroupAddon, Avatar, AvatarImage, AvatarFallback, InputGroupButton } from '../chunk-VXW3K5O5.js';
|
|
14
14
|
import { Button, Input } from '../chunk-VGOGWZCF.js';
|
|
15
15
|
import { cn } from '../chunk-XH55BHUU.js';
|
|
16
|
-
import * as
|
|
17
|
-
import { createContext, useState, useContext, useCallback, useMemo, useId } from 'react';
|
|
16
|
+
import * as React6 from 'react';
|
|
17
|
+
import { createContext, useState, useRef, useContext, useCallback, useMemo, useId } from 'react';
|
|
18
18
|
import { Slot } from 'radix-ui';
|
|
19
19
|
import { FormProvider, Controller, useFormContext } from 'react-hook-form';
|
|
20
20
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
21
|
-
import { ChevronRight, XIcon, CheckIcon, CopyIcon, RefreshCwIcon, PlusIcon, ListIcon, FolderOpen, Folder, File } from 'lucide-react';
|
|
21
|
+
import { ChevronRight, XIcon, LockIcon, CheckIcon, CopyIcon, RefreshCwIcon, PlusIcon, ListIcon, CalendarIcon, FolderOpen, Folder, File } from 'lucide-react';
|
|
22
|
+
import { format } from 'date-fns';
|
|
23
|
+
import { enUS } from 'date-fns/locale/en-US';
|
|
24
|
+
import { ja } from 'date-fns/locale/ja';
|
|
25
|
+
import { vi } from 'date-fns/locale/vi';
|
|
22
26
|
|
|
23
27
|
var Form = FormProvider;
|
|
24
|
-
var FormFieldContext =
|
|
28
|
+
var FormFieldContext = React6.createContext(null);
|
|
25
29
|
var FormField = ({
|
|
26
30
|
...props
|
|
27
31
|
}) => {
|
|
28
32
|
return /* @__PURE__ */ jsx(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
29
33
|
};
|
|
30
34
|
var useFormField = () => {
|
|
31
|
-
const fieldContext =
|
|
32
|
-
const itemContext =
|
|
35
|
+
const fieldContext = React6.useContext(FormFieldContext);
|
|
36
|
+
const itemContext = React6.useContext(FormItemContext);
|
|
33
37
|
const { getFieldState, formState } = useFormContext();
|
|
34
38
|
if (!fieldContext) {
|
|
35
39
|
throw new Error("useFormField should be used within <FormField>");
|
|
@@ -45,9 +49,9 @@ var useFormField = () => {
|
|
|
45
49
|
...fieldState
|
|
46
50
|
};
|
|
47
51
|
};
|
|
48
|
-
var FormItemContext =
|
|
52
|
+
var FormItemContext = React6.createContext(null);
|
|
49
53
|
function FormItem({ className, ...props }) {
|
|
50
|
-
const id =
|
|
54
|
+
const id = React6.useId();
|
|
51
55
|
return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
|
|
52
56
|
}
|
|
53
57
|
function FormLabel({ className, ...props }) {
|
|
@@ -138,31 +142,92 @@ function PanelCard({ title, description, hint, action, children }) {
|
|
|
138
142
|
] })
|
|
139
143
|
] });
|
|
140
144
|
}
|
|
145
|
+
var shell = cn("fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", "p-4 w-[min(400px,calc(100vw-2rem))]", "focus:outline-none");
|
|
146
|
+
function Lines({ items }) {
|
|
147
|
+
return /* @__PURE__ */ jsx("ul", { className: "mt-2 list-disc space-y-1 pl-5 text-sm", children: items.map((item, i) => /* @__PURE__ */ jsx("li", { children: item }, i)) });
|
|
148
|
+
}
|
|
141
149
|
function ConfirmDialog({ options, onConfirm, onCancel }) {
|
|
150
|
+
const [reason, setReason] = useState("");
|
|
151
|
+
const missing = !!options.reason?.required && reason.trim() === "";
|
|
142
152
|
return /* @__PURE__ */ jsxs(Dialog, { open: true, onOpenChange: (val) => !val && onCancel(), children: [
|
|
143
153
|
/* @__PURE__ */ jsx(DialogOverlay, { className: "fixed inset-0 bg-white/10" }),
|
|
144
|
-
/* @__PURE__ */ jsxs(DialogContent, { className:
|
|
154
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: shell, children: [
|
|
145
155
|
/* @__PURE__ */ jsx(DialogTitle, { className: "text-sm font-medium", children: options.title }),
|
|
146
156
|
options.description != null && /* @__PURE__ */ jsx(DialogDescription, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-muted-foreground", children: options.description }) }),
|
|
147
|
-
/* @__PURE__ */
|
|
157
|
+
options.consequences && options.consequences.length > 0 && /* @__PURE__ */ jsx(Lines, { items: options.consequences }),
|
|
158
|
+
options.reversible != null && /* @__PURE__ */ jsx("p", { className: cn("mt-2 text-xs", options.reversible ? "text-muted-foreground" : "text-destructive"), children: options.reversible ? options.reversibleText ?? "This can be undone." : options.irreversibleText ?? "This cannot be undone." }),
|
|
159
|
+
options.reason && /* @__PURE__ */ jsxs("label", { className: "mt-3 grid gap-1.5 text-sm", children: [
|
|
160
|
+
/* @__PURE__ */ jsx("span", { children: options.reason.label }),
|
|
161
|
+
/* @__PURE__ */ jsx(Textarea, { value: reason, placeholder: options.reason.placeholder, onChange: (e) => setReason(e.target.value), rows: 3 })
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex justify-end gap-2", children: [
|
|
148
164
|
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onCancel, children: options.cancelText ?? "Cancel" }),
|
|
149
|
-
/* @__PURE__ */ jsx(
|
|
165
|
+
/* @__PURE__ */ jsx(
|
|
166
|
+
Button,
|
|
167
|
+
{
|
|
168
|
+
size: "sm",
|
|
169
|
+
disabled: missing,
|
|
170
|
+
onClick: () => onConfirm(reason.trim()),
|
|
171
|
+
className: cn(options.danger && "bg-red-600 hover:bg-red-700 text-white"),
|
|
172
|
+
children: options.confirmText ?? "Confirm"
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
] })
|
|
176
|
+
] })
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
function BlockedDialog({ options, onClose }) {
|
|
180
|
+
return /* @__PURE__ */ jsxs(Dialog, { open: true, onOpenChange: (val) => !val && onClose(), children: [
|
|
181
|
+
/* @__PURE__ */ jsx(DialogOverlay, { className: "fixed inset-0 bg-white/10" }),
|
|
182
|
+
/* @__PURE__ */ jsxs(DialogContent, { className: shell, children: [
|
|
183
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "text-sm font-medium", children: options.title }),
|
|
184
|
+
options.description != null && /* @__PURE__ */ jsx(DialogDescription, { asChild: true, children: /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-muted-foreground", children: options.description }) }),
|
|
185
|
+
/* @__PURE__ */ jsx(Lines, { items: options.blockers }),
|
|
186
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex justify-end gap-2", children: [
|
|
187
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onClick: onClose, children: options.closeText ?? "Close" }),
|
|
188
|
+
options.action && /* @__PURE__ */ jsx(
|
|
189
|
+
Button,
|
|
190
|
+
{
|
|
191
|
+
size: "sm",
|
|
192
|
+
onClick: () => {
|
|
193
|
+
onClose();
|
|
194
|
+
options.action.onClick();
|
|
195
|
+
},
|
|
196
|
+
children: options.action.label
|
|
197
|
+
}
|
|
198
|
+
)
|
|
150
199
|
] })
|
|
151
200
|
] })
|
|
152
201
|
] });
|
|
153
202
|
}
|
|
154
203
|
var ConfirmContext = createContext(null);
|
|
204
|
+
var ConfirmReasonContext = createContext(null);
|
|
205
|
+
var BlockedContext = createContext(null);
|
|
155
206
|
function ConfirmProvider({ children }) {
|
|
156
207
|
const [state, setState] = useState(null);
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
208
|
+
const open = useRef(null);
|
|
209
|
+
const next = useRef(0);
|
|
210
|
+
const show = (o) => {
|
|
211
|
+
open.current?.dismiss();
|
|
212
|
+
open.current = o;
|
|
213
|
+
setState(o);
|
|
214
|
+
};
|
|
215
|
+
const confirm = (options) => new Promise((resolve) => show({ id: ++next.current, kind: "confirm", options, resolve, dismiss: () => resolve(false) }));
|
|
216
|
+
const confirmReason = (options) => new Promise(
|
|
217
|
+
(resolve) => show({ id: ++next.current, kind: "reason", options, resolve, dismiss: () => resolve(null) })
|
|
218
|
+
);
|
|
219
|
+
const blocked = (options) => new Promise((resolve) => show({ id: ++next.current, kind: "blocked", options, resolve, dismiss: () => resolve() }));
|
|
220
|
+
const done = (fn) => {
|
|
221
|
+
fn();
|
|
222
|
+
open.current = null;
|
|
160
223
|
setState(null);
|
|
161
224
|
};
|
|
162
|
-
return /* @__PURE__ */
|
|
225
|
+
return /* @__PURE__ */ jsx(ConfirmContext.Provider, { value: confirm, children: /* @__PURE__ */ jsx(ConfirmReasonContext.Provider, { value: confirmReason, children: /* @__PURE__ */ jsxs(BlockedContext.Provider, { value: blocked, children: [
|
|
163
226
|
children,
|
|
164
|
-
state && /* @__PURE__ */ jsx(ConfirmDialog, { options: state.options, onConfirm: () =>
|
|
165
|
-
|
|
227
|
+
state?.kind === "confirm" && /* @__PURE__ */ jsx(ConfirmDialog, { options: state.options, onConfirm: () => done(() => state.resolve(true)), onCancel: () => done(() => state.resolve(false)) }, state.id),
|
|
228
|
+
state?.kind === "reason" && /* @__PURE__ */ jsx(ConfirmDialog, { options: state.options, onConfirm: (r) => done(() => state.resolve(r)), onCancel: () => done(() => state.resolve(null)) }, state.id),
|
|
229
|
+
state?.kind === "blocked" && /* @__PURE__ */ jsx(BlockedDialog, { options: state.options, onClose: () => done(() => state.resolve()) }, state.id)
|
|
230
|
+
] }) }) });
|
|
166
231
|
}
|
|
167
232
|
var useConfirm = () => {
|
|
168
233
|
const ctx = useContext(ConfirmContext);
|
|
@@ -171,6 +236,20 @@ var useConfirm = () => {
|
|
|
171
236
|
}
|
|
172
237
|
return ctx;
|
|
173
238
|
};
|
|
239
|
+
var useConfirmReason = () => {
|
|
240
|
+
const ctx = useContext(ConfirmReasonContext);
|
|
241
|
+
if (!ctx) {
|
|
242
|
+
throw new Error("useConfirmReason must be used inside ConfirmProvider");
|
|
243
|
+
}
|
|
244
|
+
return ctx;
|
|
245
|
+
};
|
|
246
|
+
var useBlocked = () => {
|
|
247
|
+
const ctx = useContext(BlockedContext);
|
|
248
|
+
if (!ctx) {
|
|
249
|
+
throw new Error("useBlocked must be used inside ConfirmProvider");
|
|
250
|
+
}
|
|
251
|
+
return ctx;
|
|
252
|
+
};
|
|
174
253
|
|
|
175
254
|
// src/blocks/tree/data.ts
|
|
176
255
|
var DIGITS = /\d+/g;
|
|
@@ -805,8 +884,8 @@ function TzPicker({
|
|
|
805
884
|
search: labels?.search ?? "Search timezone",
|
|
806
885
|
noMatch: labels?.noMatch ?? "No match"
|
|
807
886
|
};
|
|
808
|
-
const own =
|
|
809
|
-
const entries =
|
|
887
|
+
const own = React6.useMemo(() => browserTz(), []);
|
|
888
|
+
const entries = React6.useMemo(() => {
|
|
810
889
|
const zones = allZones();
|
|
811
890
|
const out = [];
|
|
812
891
|
if (allowInherit) out.push({ tz: "", name: l.inherit, offset: "" });
|
|
@@ -853,6 +932,204 @@ function TzPicker({
|
|
|
853
932
|
}
|
|
854
933
|
);
|
|
855
934
|
}
|
|
935
|
+
function MobileSheet({ title, description, trigger, open, onOpenChange, className, children }) {
|
|
936
|
+
return /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange, children: [
|
|
937
|
+
trigger && /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }),
|
|
938
|
+
/* @__PURE__ */ jsxs(DrawerContent, { children: [
|
|
939
|
+
/* @__PURE__ */ jsxs(DrawerHeader, { children: [
|
|
940
|
+
/* @__PURE__ */ jsx(DrawerTitle, { className: "text-base", children: title }),
|
|
941
|
+
description && /* @__PURE__ */ jsx(DrawerDescription, { className: "text-sm", children: description })
|
|
942
|
+
] }),
|
|
943
|
+
/* @__PURE__ */ jsx("div", { className: cn("min-h-0 overflow-y-auto px-4 pb-[calc(1.5rem+env(safe-area-inset-bottom))] text-sm", className), children })
|
|
944
|
+
] })
|
|
945
|
+
] });
|
|
946
|
+
}
|
|
947
|
+
var CALENDAR_LOCALES = { vi, ja, en: enUS };
|
|
948
|
+
function datePattern(locale) {
|
|
949
|
+
const parts = new Intl.DateTimeFormat(locale, { day: "2-digit", month: "2-digit", year: "numeric" }).formatToParts(
|
|
950
|
+
new Date(2001, 10, 22)
|
|
951
|
+
);
|
|
952
|
+
const order = [];
|
|
953
|
+
let sep = "/";
|
|
954
|
+
for (const p of parts) {
|
|
955
|
+
if (p.type === "day") order.push("d");
|
|
956
|
+
else if (p.type === "month") order.push("m");
|
|
957
|
+
else if (p.type === "year") order.push("y");
|
|
958
|
+
else if (p.type === "literal" && order.length === 1) sep = p.value.trim() || p.value;
|
|
959
|
+
}
|
|
960
|
+
return order.length === 3 ? { order, sep } : { order: ["d", "m", "y"], sep: "/" };
|
|
961
|
+
}
|
|
962
|
+
var pad = (n, w) => String(n).padStart(w, "0");
|
|
963
|
+
function isoOf(y, m, d) {
|
|
964
|
+
const dt = new Date(Date.UTC(y, m - 1, d));
|
|
965
|
+
if (dt.getUTCFullYear() !== y || dt.getUTCMonth() !== m - 1 || dt.getUTCDate() !== d) return null;
|
|
966
|
+
return `${pad(y, 4)}-${pad(m, 2)}-${pad(d, 2)}`;
|
|
967
|
+
}
|
|
968
|
+
function formatDate(iso, pattern) {
|
|
969
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
|
|
970
|
+
if (!m) return "";
|
|
971
|
+
const by = { y: m[1], m: m[2], d: m[3] };
|
|
972
|
+
return pattern.order.map((p) => by[p]).join(pattern.sep);
|
|
973
|
+
}
|
|
974
|
+
function parseDate(text, pattern) {
|
|
975
|
+
const t = text.trim();
|
|
976
|
+
if (/^\d{4}-\d{1,2}-\d{1,2}$/.test(t)) {
|
|
977
|
+
const [y2, mo, d] = t.split("-").map(Number);
|
|
978
|
+
return isoOf(y2, mo, d);
|
|
979
|
+
}
|
|
980
|
+
const nums = t.split(/\D+/).filter(Boolean);
|
|
981
|
+
if (nums.length !== 3) return null;
|
|
982
|
+
const by = {};
|
|
983
|
+
pattern.order.forEach((p, i) => by[p] = Number(nums[i]));
|
|
984
|
+
let y = by.y;
|
|
985
|
+
if (nums[pattern.order.indexOf("y")].length <= 2) y += y <= (/* @__PURE__ */ new Date()).getFullYear() % 100 + 10 ? 2e3 : 1900;
|
|
986
|
+
return isoOf(y, by.m, by.d);
|
|
987
|
+
}
|
|
988
|
+
function toDate(iso) {
|
|
989
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
|
|
990
|
+
return m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : void 0;
|
|
991
|
+
}
|
|
992
|
+
function fromDate(d) {
|
|
993
|
+
return `${pad(d.getFullYear(), 4)}-${pad(d.getMonth() + 1, 2)}-${pad(d.getDate(), 2)}`;
|
|
994
|
+
}
|
|
995
|
+
function useCoarsePointer() {
|
|
996
|
+
const [coarse, setCoarse] = React6.useState(false);
|
|
997
|
+
React6.useEffect(() => {
|
|
998
|
+
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
999
|
+
const mql = window.matchMedia("(pointer: coarse)");
|
|
1000
|
+
const onChange = () => setCoarse(mql.matches);
|
|
1001
|
+
onChange();
|
|
1002
|
+
mql.addEventListener("change", onChange);
|
|
1003
|
+
return () => mql.removeEventListener("change", onChange);
|
|
1004
|
+
}, []);
|
|
1005
|
+
return coarse;
|
|
1006
|
+
}
|
|
1007
|
+
function DateField({
|
|
1008
|
+
value,
|
|
1009
|
+
onChange,
|
|
1010
|
+
locale,
|
|
1011
|
+
id,
|
|
1012
|
+
disabled,
|
|
1013
|
+
required,
|
|
1014
|
+
min,
|
|
1015
|
+
max,
|
|
1016
|
+
todayLabel = "Today",
|
|
1017
|
+
clearLabel = "Clear",
|
|
1018
|
+
pickLabel = "Pick a date",
|
|
1019
|
+
className,
|
|
1020
|
+
...aria
|
|
1021
|
+
}) {
|
|
1022
|
+
const pattern = React6.useMemo(() => datePattern(locale), [locale]);
|
|
1023
|
+
const placeholder = pattern.order.map((p) => p === "y" ? "yyyy" : p === "m" ? "mm" : "dd").join(pattern.sep);
|
|
1024
|
+
const [text, setText] = React6.useState(() => formatDate(value, pattern));
|
|
1025
|
+
const [bad, setBad] = React6.useState(false);
|
|
1026
|
+
const [open, setOpen] = React6.useState(false);
|
|
1027
|
+
const coarse = useCoarsePointer();
|
|
1028
|
+
const [seen, setSeen] = React6.useState(value);
|
|
1029
|
+
if (seen !== value) {
|
|
1030
|
+
setSeen(value);
|
|
1031
|
+
setText(formatDate(value, pattern));
|
|
1032
|
+
setBad(false);
|
|
1033
|
+
}
|
|
1034
|
+
const inRange = (iso) => (!min || iso >= min) && (!max || iso <= max);
|
|
1035
|
+
const commit = () => {
|
|
1036
|
+
if (text.trim() === "") {
|
|
1037
|
+
setBad(false);
|
|
1038
|
+
if (value !== "") onChange("");
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
const iso = parseDate(text, pattern);
|
|
1042
|
+
if (!iso || !inRange(iso)) {
|
|
1043
|
+
setBad(true);
|
|
1044
|
+
setText(formatDate(value, pattern));
|
|
1045
|
+
return;
|
|
1046
|
+
}
|
|
1047
|
+
setBad(false);
|
|
1048
|
+
setText(formatDate(iso, pattern));
|
|
1049
|
+
if (iso !== value) onChange(iso);
|
|
1050
|
+
};
|
|
1051
|
+
const pick = (iso) => {
|
|
1052
|
+
setOpen(false);
|
|
1053
|
+
setBad(false);
|
|
1054
|
+
setText(formatDate(iso, pattern));
|
|
1055
|
+
if (iso !== value) onChange(iso);
|
|
1056
|
+
};
|
|
1057
|
+
const lang = locale.split("-")[0];
|
|
1058
|
+
const calendarLocale = CALENDAR_LOCALES[lang] ?? enUS;
|
|
1059
|
+
const today = fromDate(/* @__PURE__ */ new Date());
|
|
1060
|
+
const selected = toDate(value);
|
|
1061
|
+
const calendar = /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1062
|
+
/* @__PURE__ */ jsx(
|
|
1063
|
+
Calendar,
|
|
1064
|
+
{
|
|
1065
|
+
mode: "single",
|
|
1066
|
+
locale: calendarLocale,
|
|
1067
|
+
formatters: { formatWeekdayName: (d) => format(d, lang === "vi" ? "EEEEE" : "EEEEEE", { locale: calendarLocale }) },
|
|
1068
|
+
selected,
|
|
1069
|
+
defaultMonth: selected,
|
|
1070
|
+
captionLayout: "dropdown",
|
|
1071
|
+
disabled: [...min ? [{ before: toDate(min) }] : [], ...max ? [{ after: toDate(max) }] : []],
|
|
1072
|
+
onSelect: (d) => d && pick(fromDate(d))
|
|
1073
|
+
}
|
|
1074
|
+
),
|
|
1075
|
+
/* @__PURE__ */ jsxs("div", { className: "flex justify-between gap-2 px-2 pb-2", children: [
|
|
1076
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => pick(""), disabled: required, children: clearLabel }),
|
|
1077
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => pick(today), disabled: !inRange(today), children: todayLabel })
|
|
1078
|
+
] })
|
|
1079
|
+
] });
|
|
1080
|
+
const trigger = /* @__PURE__ */ jsx(InputGroupButton, { type: "button", size: "icon-xs", "aria-label": pickLabel, disabled, children: /* @__PURE__ */ jsx(CalendarIcon, {}) });
|
|
1081
|
+
return /* @__PURE__ */ jsxs(InputGroup, { className, "data-disabled": disabled || void 0, children: [
|
|
1082
|
+
/* @__PURE__ */ jsx(
|
|
1083
|
+
InputGroupInput,
|
|
1084
|
+
{
|
|
1085
|
+
id,
|
|
1086
|
+
inputMode: "numeric",
|
|
1087
|
+
autoComplete: "off",
|
|
1088
|
+
placeholder,
|
|
1089
|
+
value: text,
|
|
1090
|
+
disabled,
|
|
1091
|
+
required,
|
|
1092
|
+
"aria-label": aria["aria-label"],
|
|
1093
|
+
"aria-invalid": bad || aria["aria-invalid"] || void 0,
|
|
1094
|
+
onChange: (e) => {
|
|
1095
|
+
setText(e.target.value);
|
|
1096
|
+
setBad(false);
|
|
1097
|
+
},
|
|
1098
|
+
onBlur: commit,
|
|
1099
|
+
onKeyDown: (e) => {
|
|
1100
|
+
if (e.key === "Enter") {
|
|
1101
|
+
e.preventDefault();
|
|
1102
|
+
commit();
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
),
|
|
1107
|
+
/* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-end", children: coarse ? /* @__PURE__ */ jsx(MobileSheet, { title: pickLabel, open, onOpenChange: setOpen, trigger, children: /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: calendar }) }) : /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
1108
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: trigger }),
|
|
1109
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "end", children: calendar })
|
|
1110
|
+
] }) })
|
|
1111
|
+
] });
|
|
1112
|
+
}
|
|
1113
|
+
function LockedReason({ children, className }) {
|
|
1114
|
+
return /* @__PURE__ */ jsxs("p", { "data-slot": "locked-reason", className: cn("text-muted-foreground flex items-start gap-1 text-xs", className), children: [
|
|
1115
|
+
/* @__PURE__ */ jsx(LockIcon, { "aria-hidden": true, className: "mt-px size-3 shrink-0" }),
|
|
1116
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
1117
|
+
] });
|
|
1118
|
+
}
|
|
1119
|
+
function UnsavedBadge({ children, className }) {
|
|
1120
|
+
return /* @__PURE__ */ jsxs(
|
|
1121
|
+
"span",
|
|
1122
|
+
{
|
|
1123
|
+
"data-slot": "unsaved-badge",
|
|
1124
|
+
role: "status",
|
|
1125
|
+
className: cn("inline-flex items-center gap-1.5 text-xs font-medium text-amber-700 dark:text-amber-400", className),
|
|
1126
|
+
children: [
|
|
1127
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "size-1.5 rounded-full bg-current" }),
|
|
1128
|
+
children
|
|
1129
|
+
]
|
|
1130
|
+
}
|
|
1131
|
+
);
|
|
1132
|
+
}
|
|
856
1133
|
var FALLBACK = {
|
|
857
1134
|
placeholder: "Select\u2026",
|
|
858
1135
|
search: "Search",
|
|
@@ -869,7 +1146,7 @@ function OptionPicker({
|
|
|
869
1146
|
}) {
|
|
870
1147
|
const t = (k) => labels?.[k] ?? FALLBACK[k];
|
|
871
1148
|
const placeholder = labels?.placeholder ?? FALLBACK.placeholder;
|
|
872
|
-
const entries =
|
|
1149
|
+
const entries = React6.useMemo(() => {
|
|
873
1150
|
const out = [{ id: "", label: placeholder, none: true }, ...options];
|
|
874
1151
|
if (value !== "" && !options.some((o) => o.id === value)) {
|
|
875
1152
|
out.push({ id: value, label: value });
|
|
@@ -921,18 +1198,6 @@ function AuthCard({ title, description, logo, brand, footer, children, className
|
|
|
921
1198
|
footer
|
|
922
1199
|
] }) });
|
|
923
1200
|
}
|
|
924
|
-
function MobileSheet({ title, description, trigger, open, onOpenChange, className, children }) {
|
|
925
|
-
return /* @__PURE__ */ jsxs(Drawer, { open, onOpenChange, children: [
|
|
926
|
-
trigger && /* @__PURE__ */ jsx(DrawerTrigger, { asChild: true, children: trigger }),
|
|
927
|
-
/* @__PURE__ */ jsxs(DrawerContent, { children: [
|
|
928
|
-
/* @__PURE__ */ jsxs(DrawerHeader, { children: [
|
|
929
|
-
/* @__PURE__ */ jsx(DrawerTitle, { className: "text-base", children: title }),
|
|
930
|
-
description && /* @__PURE__ */ jsx(DrawerDescription, { className: "text-sm", children: description })
|
|
931
|
-
] }),
|
|
932
|
-
/* @__PURE__ */ jsx("div", { className: cn("min-h-0 overflow-y-auto px-4 pb-[calc(1.5rem+env(safe-area-inset-bottom))] text-sm", className), children })
|
|
933
|
-
] })
|
|
934
|
-
] });
|
|
935
|
-
}
|
|
936
1201
|
function ChoiceDrawer({ options, value, onValueChange, ...sheet }) {
|
|
937
1202
|
return /* @__PURE__ */ jsx(MobileSheet, { ...sheet, children: /* @__PURE__ */ jsx(RadioGroup, { value: value ?? "", onValueChange: (v) => onValueChange(v), className: "-mx-4 gap-0 divide-y divide-border", children: options.map((option) => /* @__PURE__ */ jsxs("label", { className: "flex min-h-12 cursor-pointer items-center justify-between gap-4 px-4 py-3 active:bg-muted", children: [
|
|
938
1203
|
/* @__PURE__ */ jsx("span", { children: option.label }),
|
|
@@ -984,21 +1249,21 @@ function McpSettings({
|
|
|
984
1249
|
className
|
|
985
1250
|
}) {
|
|
986
1251
|
const t = { ...FALLBACK2, ...labels };
|
|
987
|
-
const id =
|
|
988
|
-
const [status, setStatus] =
|
|
989
|
-
const [loadError, setLoadError] =
|
|
990
|
-
const [error, setError] =
|
|
991
|
-
const [busy, setBusy] =
|
|
992
|
-
const [copied, setCopied] =
|
|
993
|
-
const [calls, setCalls] =
|
|
994
|
-
const changes =
|
|
995
|
-
const callKey =
|
|
996
|
-
const load =
|
|
1252
|
+
const id = React6.useId();
|
|
1253
|
+
const [status, setStatus] = React6.useState(null);
|
|
1254
|
+
const [loadError, setLoadError] = React6.useState(null);
|
|
1255
|
+
const [error, setError] = React6.useState(null);
|
|
1256
|
+
const [busy, setBusy] = React6.useState(false);
|
|
1257
|
+
const [copied, setCopied] = React6.useState(false);
|
|
1258
|
+
const [calls, setCalls] = React6.useState([]);
|
|
1259
|
+
const changes = React6.useRef(0);
|
|
1260
|
+
const callKey = React6.useRef(0);
|
|
1261
|
+
const load = React6.useCallback(() => {
|
|
997
1262
|
setLoadError(null);
|
|
998
1263
|
api.status().then(setStatus, (err) => setLoadError(messageOf(err)));
|
|
999
1264
|
}, [api]);
|
|
1000
|
-
|
|
1001
|
-
|
|
1265
|
+
React6.useEffect(load, [load]);
|
|
1266
|
+
React6.useEffect(() => {
|
|
1002
1267
|
if (!api.onCall) return;
|
|
1003
1268
|
return api.onCall((call) => {
|
|
1004
1269
|
setCalls((prev) => [{ ...call, key: ++callKey.current, at: /* @__PURE__ */ new Date() }, ...prev].slice(0, RECENT_CALLS));
|
|
@@ -1013,7 +1278,7 @@ function McpSettings({
|
|
|
1013
1278
|
);
|
|
1014
1279
|
});
|
|
1015
1280
|
}, [api]);
|
|
1016
|
-
|
|
1281
|
+
React6.useEffect(() => {
|
|
1017
1282
|
if (!copied) return;
|
|
1018
1283
|
const timer = setTimeout(() => setCopied(false), 2e3);
|
|
1019
1284
|
return () => clearTimeout(timer);
|
|
@@ -1276,26 +1541,26 @@ function LlmSettings({ api, labels, className, header, footer }) {
|
|
|
1276
1541
|
const size = (bytes) => f.size?.(bytes) ?? sizeOf(bytes);
|
|
1277
1542
|
const nameOf = (pid) => api.providerName?.(pid) ?? pid;
|
|
1278
1543
|
const slotLabel = (s) => f.slotLabel?.(s) ?? s.label;
|
|
1279
|
-
const id =
|
|
1280
|
-
const [state, setState] =
|
|
1281
|
-
const [drivers, setDrivers] =
|
|
1282
|
-
const [driversError, setDriversError] =
|
|
1283
|
-
const [found, setFound] =
|
|
1284
|
-
const [loadError, setLoadError] =
|
|
1285
|
-
const [error, setError] =
|
|
1286
|
-
const [busy, setBusy] =
|
|
1287
|
-
const [draft, setDraft] =
|
|
1288
|
-
const [draftError, setDraftError] =
|
|
1289
|
-
const [removing, setRemoving] =
|
|
1290
|
-
const [models, setModels] =
|
|
1291
|
-
const [typed, setTyped] =
|
|
1292
|
-
const [pulls, setPulls] =
|
|
1293
|
-
const [library, setLibrary] =
|
|
1294
|
-
const [pullName, setPullName] =
|
|
1544
|
+
const id = React6.useId();
|
|
1545
|
+
const [state, setState] = React6.useState(null);
|
|
1546
|
+
const [drivers, setDrivers] = React6.useState([]);
|
|
1547
|
+
const [driversError, setDriversError] = React6.useState(null);
|
|
1548
|
+
const [found, setFound] = React6.useState([]);
|
|
1549
|
+
const [loadError, setLoadError] = React6.useState(null);
|
|
1550
|
+
const [error, setError] = React6.useState(null);
|
|
1551
|
+
const [busy, setBusy] = React6.useState(false);
|
|
1552
|
+
const [draft, setDraft] = React6.useState(null);
|
|
1553
|
+
const [draftError, setDraftError] = React6.useState(null);
|
|
1554
|
+
const [removing, setRemoving] = React6.useState(null);
|
|
1555
|
+
const [models, setModels] = React6.useState({});
|
|
1556
|
+
const [typed, setTyped] = React6.useState({});
|
|
1557
|
+
const [pulls, setPulls] = React6.useState({});
|
|
1558
|
+
const [library, setLibrary] = React6.useState(null);
|
|
1559
|
+
const [pullName, setPullName] = React6.useState("");
|
|
1295
1560
|
const failed = (err) => {
|
|
1296
1561
|
if (!api.isCanceled?.(err)) setError(messageOf2(err));
|
|
1297
1562
|
};
|
|
1298
|
-
const load =
|
|
1563
|
+
const load = React6.useCallback(() => {
|
|
1299
1564
|
setLoadError(null);
|
|
1300
1565
|
setDriversError(null);
|
|
1301
1566
|
api.state().then(setState, (err) => setLoadError(messageOf2(err)));
|
|
@@ -1303,8 +1568,8 @@ function LlmSettings({ api, labels, className, header, footer }) {
|
|
|
1303
1568
|
api.detect?.().then(setFound, () => {
|
|
1304
1569
|
});
|
|
1305
1570
|
}, [api]);
|
|
1306
|
-
|
|
1307
|
-
|
|
1571
|
+
React6.useEffect(load, [load]);
|
|
1572
|
+
React6.useEffect(() => {
|
|
1308
1573
|
if (!api.onPull) return;
|
|
1309
1574
|
return api.onPull(
|
|
1310
1575
|
(p) => setPulls((prev) => {
|
|
@@ -1314,7 +1579,7 @@ function LlmSettings({ api, labels, className, header, footer }) {
|
|
|
1314
1579
|
})
|
|
1315
1580
|
);
|
|
1316
1581
|
}, [api]);
|
|
1317
|
-
const listModels =
|
|
1582
|
+
const listModels = React6.useCallback(
|
|
1318
1583
|
(provider2) => {
|
|
1319
1584
|
api.models(provider2).then(
|
|
1320
1585
|
(ms) => setModels((prev) => ({ ...prev, [provider2]: ms })),
|
|
@@ -1324,8 +1589,8 @@ function LlmSettings({ api, labels, className, header, footer }) {
|
|
|
1324
1589
|
},
|
|
1325
1590
|
[api]
|
|
1326
1591
|
);
|
|
1327
|
-
const bound =
|
|
1328
|
-
|
|
1592
|
+
const bound = React6.useMemo(() => new Set((state?.slots ?? []).map((s) => s.provider).filter(Boolean)), [state]);
|
|
1593
|
+
React6.useEffect(() => {
|
|
1329
1594
|
for (const p of bound) if (!(p in models)) listModels(p);
|
|
1330
1595
|
}, [bound, models, listModels]);
|
|
1331
1596
|
const change = async (action) => {
|
|
@@ -1818,6 +2083,6 @@ function LlmSettings({ api, labels, className, header, footer }) {
|
|
|
1818
2083
|
);
|
|
1819
2084
|
}
|
|
1820
2085
|
|
|
1821
|
-
export { AuthCard, AvatarTile, BarList, ChoiceDrawer, ColorSwatches, ConfirmContext, ConfirmDialog, ConfirmProvider, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, LlmSettings, McpSettings, MobileSheet, OptionPicker, Panel, PanelCard, StatTile, TagInput, TreeDndProvider, TreeExpander, TreeIcon, TreeLabel, TreeLines, TreeNode, TreeNodeContent, TreeNodeTrigger, TreeProvider, TreeView, TzPicker, filterTree, flattenTree, loadExpanded, moveId, planDrop, sameOrder, saveExpanded, sortTree, useConfirm, useFormField, useTreeDndNode, useTreeDndRoot };
|
|
2086
|
+
export { AuthCard, AvatarTile, BarList, BlockedContext, BlockedDialog, ChoiceDrawer, ColorSwatches, ConfirmContext, ConfirmDialog, ConfirmProvider, ConfirmReasonContext, DateField, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, LlmSettings, LockedReason, McpSettings, MobileSheet, OptionPicker, Panel, PanelCard, StatTile, TagInput, TreeDndProvider, TreeExpander, TreeIcon, TreeLabel, TreeLines, TreeNode, TreeNodeContent, TreeNodeTrigger, TreeProvider, TreeView, TzPicker, UnsavedBadge, datePattern, filterTree, flattenTree, formatDate, loadExpanded, moveId, parseDate, planDrop, sameOrder, saveExpanded, sortTree, useBlocked, useConfirm, useConfirmReason, useFormField, useTreeDndNode, useTreeDndRoot };
|
|
1822
2087
|
//# sourceMappingURL=index.js.map
|
|
1823
2088
|
//# sourceMappingURL=index.js.map
|