@opennsw/jsonforms-renderers 0.10.0 → 0.12.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/LICENSE +201 -0
- package/README.md +24 -53
- package/dist/index.d.ts +17 -2
- package/dist/renderers.cjs.js +3 -3
- package/dist/renderers.es.js +2008 -1487
- package/package.json +1 -1
package/dist/renderers.es.js
CHANGED
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { useContext as
|
|
6
|
-
import { rankWith as te, isStringControl as
|
|
7
|
-
import { withJsonFormsControlProps as
|
|
8
|
-
import { Box as
|
|
9
|
-
import { ChevronDownIcon as
|
|
10
|
-
import
|
|
11
|
-
const
|
|
12
|
-
function
|
|
1
|
+
var fr = Object.defineProperty;
|
|
2
|
+
var pr = (e, r, t) => r in e ? fr(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
|
+
var gt = (e, r, t) => pr(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { jsx as i, jsxs as y, Fragment as ve } from "react/jsx-runtime";
|
|
5
|
+
import { useContext as Mt, createContext as zt, useMemo as We, useEffect as me, useState as j, useRef as ue, useCallback as $e } from "react";
|
|
6
|
+
import { rankWith as te, isStringControl as hr, or as tt, isNumberControl as mr, isIntegerControl as gr, isBooleanControl as yr, isEnumControl as Ft, isOneOfControl as Ut, Resolve as Pe, schemaMatches as Me, isDateControl as br, isDateTimeControl as vr, isTimeControl as wr, uiTypeIs as Xe, and as $t, not as Er, optionIs as Tr, update as xr, createDefaultValue as Ar, isObjectArrayControl as Rr, isPrimitiveArrayControl as Cr } from "@jsonforms/core";
|
|
7
|
+
import { withJsonFormsControlProps as pe, useJsonForms as Ve, JsonFormsDispatch as Ye, withJsonFormsArrayControlProps as Sr, withJsonFormsLayoutProps as Ge } from "@jsonforms/react";
|
|
8
|
+
import { Box as k, Flex as F, Text as h, TextField as Oe, Checkbox as Or, RadioGroup as yt, ScrollArea as Pt, Select as qe, Spinner as _e, Button as ze, Tabs as Je, Heading as _t, Card as jt, Tooltip as Be, IconButton as je, Table as Se } from "@radix-ui/themes";
|
|
9
|
+
import { ChevronDownIcon as Vt, FileTextIcon as Nr, DownloadIcon as at, CheckCircledIcon as Dr, Cross2Icon as ct, ExclamationTriangleIcon as ut, UploadIcon as Ue, TrashIcon as Ir, PlusIcon as kr } from "@radix-ui/react-icons";
|
|
10
|
+
import Ht from "dayjs";
|
|
11
|
+
const Wt = zt(null);
|
|
12
|
+
function Ci({
|
|
13
13
|
children: e,
|
|
14
|
-
onUpload:
|
|
15
|
-
getDownloadUrl:
|
|
14
|
+
onUpload: r,
|
|
15
|
+
getDownloadUrl: t
|
|
16
16
|
}) {
|
|
17
|
-
const
|
|
18
|
-
return /* @__PURE__ */
|
|
17
|
+
const n = { onUpload: r, getDownloadUrl: t };
|
|
18
|
+
return /* @__PURE__ */ i(Wt.Provider, { value: n, children: e });
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
return
|
|
20
|
+
function Lr() {
|
|
21
|
+
return Mt(Wt);
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
function
|
|
23
|
+
const Bt = zt(null);
|
|
24
|
+
function Si({
|
|
25
25
|
children: e,
|
|
26
|
-
services:
|
|
26
|
+
services: r
|
|
27
27
|
}) {
|
|
28
|
-
const
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
-
return !
|
|
34
|
-
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
e === !1 && r
|
|
38
|
-
}, [e,
|
|
39
|
-
},
|
|
40
|
-
`).map((
|
|
41
|
-
`) : "",
|
|
28
|
+
const t = We(() => r, [r]);
|
|
29
|
+
return /* @__PURE__ */ i(Bt.Provider, { value: t, children: e });
|
|
30
|
+
}
|
|
31
|
+
function Mr(e) {
|
|
32
|
+
const r = Mt(Bt);
|
|
33
|
+
return !r || !e ? null : r[e] ?? null;
|
|
34
|
+
}
|
|
35
|
+
const Re = (e, r, t, n = void 0) => {
|
|
36
|
+
me(() => {
|
|
37
|
+
e === !1 && t(r, n);
|
|
38
|
+
}, [e, r, t, n]);
|
|
39
|
+
}, we = (e, r) => e ? e.split(`
|
|
40
|
+
`).map((t) => t.trim() === "is a required property" ? `${r || "This field"} is required` : t).join(`
|
|
41
|
+
`) : "", zr = ({
|
|
42
42
|
data: e,
|
|
43
|
-
handleChange:
|
|
44
|
-
path:
|
|
45
|
-
label:
|
|
46
|
-
required:
|
|
47
|
-
errors:
|
|
48
|
-
uischema:
|
|
49
|
-
schema:
|
|
50
|
-
enabled:
|
|
51
|
-
visible:
|
|
43
|
+
handleChange: r,
|
|
44
|
+
path: t,
|
|
45
|
+
label: n,
|
|
46
|
+
required: l,
|
|
47
|
+
errors: o,
|
|
48
|
+
uischema: s,
|
|
49
|
+
schema: u,
|
|
50
|
+
enabled: a,
|
|
51
|
+
visible: c = !0
|
|
52
52
|
}) => {
|
|
53
|
-
var
|
|
54
|
-
if (
|
|
53
|
+
var f;
|
|
54
|
+
if (Re(c, t, r), c === !1)
|
|
55
55
|
return null;
|
|
56
|
-
const
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
|
|
56
|
+
const d = o.length === 0;
|
|
57
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
58
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
|
|
59
|
+
n,
|
|
60
60
|
" ",
|
|
61
|
-
|
|
61
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
62
62
|
] }),
|
|
63
|
-
/* @__PURE__ */
|
|
64
|
-
|
|
63
|
+
/* @__PURE__ */ i(
|
|
64
|
+
Oe.Root,
|
|
65
65
|
{
|
|
66
66
|
value: e || "",
|
|
67
|
-
onChange: (
|
|
68
|
-
disabled: !
|
|
69
|
-
placeholder: (
|
|
70
|
-
color:
|
|
71
|
-
id:
|
|
67
|
+
onChange: (p) => r(t, p.target.value),
|
|
68
|
+
disabled: !a,
|
|
69
|
+
placeholder: (f = s.options) == null ? void 0 : f.placeholder,
|
|
70
|
+
color: d ? void 0 : "red",
|
|
71
|
+
id: t
|
|
72
72
|
}
|
|
73
73
|
),
|
|
74
|
-
!
|
|
75
|
-
|
|
74
|
+
!d && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
|
|
75
|
+
u.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: u.description })
|
|
76
76
|
] }) });
|
|
77
|
-
},
|
|
77
|
+
}, Fr = te(1, hr), Ur = pe(zr), $r = ({
|
|
78
78
|
data: e,
|
|
79
|
-
handleChange:
|
|
80
|
-
path:
|
|
81
|
-
label:
|
|
82
|
-
required:
|
|
83
|
-
errors:
|
|
84
|
-
uischema:
|
|
85
|
-
schema:
|
|
86
|
-
enabled:
|
|
87
|
-
visible:
|
|
79
|
+
handleChange: r,
|
|
80
|
+
path: t,
|
|
81
|
+
label: n,
|
|
82
|
+
required: l,
|
|
83
|
+
errors: o,
|
|
84
|
+
uischema: s,
|
|
85
|
+
schema: u,
|
|
86
|
+
enabled: a,
|
|
87
|
+
visible: c = !0
|
|
88
88
|
}) => {
|
|
89
|
-
var
|
|
90
|
-
if (
|
|
89
|
+
var p;
|
|
90
|
+
if (Re(c, t, r), c === !1)
|
|
91
91
|
return null;
|
|
92
|
-
const
|
|
93
|
-
if (
|
|
94
|
-
t
|
|
92
|
+
const d = o.length === 0, f = (g) => {
|
|
93
|
+
if (g === "") {
|
|
94
|
+
r(t, void 0);
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
const
|
|
98
|
-
isNaN(
|
|
97
|
+
const b = Number(g);
|
|
98
|
+
isNaN(b) || r(t, b);
|
|
99
99
|
};
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
|
|
100
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
101
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
|
|
102
|
+
n,
|
|
103
103
|
" ",
|
|
104
|
-
|
|
104
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
105
105
|
] }),
|
|
106
|
-
/* @__PURE__ */
|
|
107
|
-
|
|
106
|
+
/* @__PURE__ */ i(
|
|
107
|
+
Oe.Root,
|
|
108
108
|
{
|
|
109
109
|
type: "number",
|
|
110
110
|
value: e ?? "",
|
|
111
|
-
onChange: (
|
|
112
|
-
disabled: !
|
|
113
|
-
placeholder: (
|
|
114
|
-
color:
|
|
115
|
-
id:
|
|
111
|
+
onChange: (g) => f(g.target.value),
|
|
112
|
+
disabled: !a,
|
|
113
|
+
placeholder: (p = s.options) == null ? void 0 : p.placeholder,
|
|
114
|
+
color: d ? void 0 : "red",
|
|
115
|
+
id: t
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
|
-
!
|
|
119
|
-
|
|
118
|
+
!d && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
|
|
119
|
+
u.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: u.description })
|
|
120
120
|
] }) });
|
|
121
|
-
},
|
|
121
|
+
}, Pr = te(2, tt(mr, gr)), _r = pe($r), jr = ({
|
|
122
122
|
data: e,
|
|
123
|
-
handleChange:
|
|
124
|
-
path:
|
|
125
|
-
label:
|
|
126
|
-
required:
|
|
127
|
-
errors:
|
|
128
|
-
schema:
|
|
129
|
-
enabled:
|
|
130
|
-
visible:
|
|
123
|
+
handleChange: r,
|
|
124
|
+
path: t,
|
|
125
|
+
label: n,
|
|
126
|
+
required: l,
|
|
127
|
+
errors: o,
|
|
128
|
+
schema: s,
|
|
129
|
+
enabled: u,
|
|
130
|
+
visible: a = !0
|
|
131
131
|
}) => {
|
|
132
|
-
if (
|
|
132
|
+
if (Re(a, t, r), a === !1)
|
|
133
133
|
return null;
|
|
134
|
-
const
|
|
135
|
-
return /* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
|
|
134
|
+
const c = o.length === 0;
|
|
135
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
136
|
+
/* @__PURE__ */ y(F, { gap: "2", align: "center", children: [
|
|
137
|
+
/* @__PURE__ */ i(
|
|
138
|
+
Or,
|
|
139
139
|
{
|
|
140
140
|
checked: !!e,
|
|
141
|
-
onCheckedChange: (
|
|
142
|
-
disabled: !
|
|
143
|
-
id:
|
|
141
|
+
onCheckedChange: (d) => r(t, d === !0),
|
|
142
|
+
disabled: !u,
|
|
143
|
+
id: t
|
|
144
144
|
}
|
|
145
145
|
),
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
|
|
146
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", htmlFor: t, children: [
|
|
147
|
+
n,
|
|
148
148
|
" ",
|
|
149
|
-
|
|
149
|
+
l && "*"
|
|
150
150
|
] })
|
|
151
151
|
] }),
|
|
152
|
-
!
|
|
153
|
-
|
|
152
|
+
!c && /* @__PURE__ */ i(h, { color: "red", size: "1", className: "block mt-1", children: we(o, n) }),
|
|
153
|
+
s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", className: "block mt-1", children: s.description })
|
|
154
154
|
] });
|
|
155
|
-
},
|
|
155
|
+
}, Vr = te(2, yr), Hr = pe(jr), Wr = ({
|
|
156
156
|
data: e,
|
|
157
|
-
handleChange:
|
|
158
|
-
path:
|
|
159
|
-
label:
|
|
160
|
-
required:
|
|
161
|
-
errors:
|
|
162
|
-
schema:
|
|
163
|
-
enabled:
|
|
164
|
-
visible:
|
|
157
|
+
handleChange: r,
|
|
158
|
+
path: t,
|
|
159
|
+
label: n,
|
|
160
|
+
required: l,
|
|
161
|
+
errors: o,
|
|
162
|
+
schema: s,
|
|
163
|
+
enabled: u,
|
|
164
|
+
visible: a = !0
|
|
165
165
|
}) => {
|
|
166
|
-
if (
|
|
166
|
+
if (Re(a, t, r), a === !1)
|
|
167
167
|
return null;
|
|
168
|
-
const
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
value:
|
|
172
|
-
label:
|
|
168
|
+
const c = o.length === 0;
|
|
169
|
+
let d = [];
|
|
170
|
+
s.enum ? d = s.enum.map((p) => ({ value: p, label: String(p) })) : s.oneOf && (d = s.oneOf.map((p) => ({
|
|
171
|
+
value: p.const,
|
|
172
|
+
label: p.title || String(p.const)
|
|
173
173
|
})));
|
|
174
|
-
const
|
|
175
|
-
return /* @__PURE__ */
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
|
|
174
|
+
const f = e;
|
|
175
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
176
|
+
/* @__PURE__ */ y(h, { as: "div", size: "2", weight: "bold", children: [
|
|
177
|
+
n,
|
|
178
178
|
" ",
|
|
179
|
-
|
|
179
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
180
180
|
] }),
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
|
|
181
|
+
/* @__PURE__ */ i(
|
|
182
|
+
yt.Root,
|
|
183
183
|
{
|
|
184
|
-
value:
|
|
185
|
-
onValueChange: (
|
|
186
|
-
const
|
|
187
|
-
|
|
184
|
+
value: f !== void 0 ? String(f) : "",
|
|
185
|
+
onValueChange: (p) => {
|
|
186
|
+
const g = d.find((b) => String(b.value) === p);
|
|
187
|
+
g && r(t, g.value);
|
|
188
188
|
},
|
|
189
|
-
disabled: !
|
|
190
|
-
children: /* @__PURE__ */
|
|
191
|
-
|
|
189
|
+
disabled: !u,
|
|
190
|
+
children: /* @__PURE__ */ i(
|
|
191
|
+
F,
|
|
192
192
|
{
|
|
193
193
|
direction: "row",
|
|
194
194
|
style: {
|
|
@@ -196,107 +196,107 @@ const ge = (e, t, r, o = void 0) => {
|
|
|
196
196
|
columnGap: "clamp(14px, 3vw, 36px)",
|
|
197
197
|
rowGap: "clamp(8px, 1.6vw, 14px)"
|
|
198
198
|
},
|
|
199
|
-
children:
|
|
200
|
-
/* @__PURE__ */
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
] }, String(
|
|
199
|
+
children: d.map((p) => /* @__PURE__ */ y(F, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
|
|
200
|
+
/* @__PURE__ */ i(yt.Item, { value: String(p.value) }),
|
|
201
|
+
/* @__PURE__ */ i(h, { size: "2", color: u ? void 0 : "gray", children: p.label })
|
|
202
|
+
] }, String(p.value)))
|
|
203
203
|
}
|
|
204
204
|
)
|
|
205
205
|
}
|
|
206
206
|
),
|
|
207
|
-
!
|
|
208
|
-
|
|
207
|
+
!c && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
|
|
208
|
+
s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: s.description })
|
|
209
209
|
] }) });
|
|
210
|
-
},
|
|
211
|
-
var
|
|
212
|
-
return
|
|
213
|
-
},
|
|
210
|
+
}, Br = (e, r, t) => {
|
|
211
|
+
var l;
|
|
212
|
+
return tt(Ft, Ut)(e, r, t) && ((l = e == null ? void 0 : e.options) == null ? void 0 : l.format) === "radio" ? 3 : -1;
|
|
213
|
+
}, Xr = pe(Wr), Yr = ({
|
|
214
214
|
data: e,
|
|
215
|
-
handleChange:
|
|
216
|
-
path:
|
|
217
|
-
label:
|
|
218
|
-
required:
|
|
219
|
-
errors:
|
|
220
|
-
schema:
|
|
221
|
-
uischema:
|
|
222
|
-
enabled:
|
|
223
|
-
visible:
|
|
215
|
+
handleChange: r,
|
|
216
|
+
path: t,
|
|
217
|
+
label: n,
|
|
218
|
+
required: l,
|
|
219
|
+
errors: o,
|
|
220
|
+
schema: s,
|
|
221
|
+
uischema: u,
|
|
222
|
+
enabled: a,
|
|
223
|
+
visible: c = !0
|
|
224
224
|
}) => {
|
|
225
|
-
var
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
229
|
-
if (!
|
|
230
|
-
const
|
|
231
|
-
|
|
225
|
+
var D, z, V;
|
|
226
|
+
Re(c, t, r);
|
|
227
|
+
const d = ((D = u.options) == null ? void 0 : D.autocomplete) === !0, [f, p] = j(!1), [g, b] = j(""), [M, N] = j(0), U = ue(null);
|
|
228
|
+
if (me(() => {
|
|
229
|
+
if (!d || !f) return;
|
|
230
|
+
const v = (x) => {
|
|
231
|
+
U.current && !U.current.contains(x.target) && p(!1);
|
|
232
232
|
};
|
|
233
|
-
return document.addEventListener("mousedown",
|
|
234
|
-
}, [
|
|
233
|
+
return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
|
|
234
|
+
}, [d, f]), c === !1)
|
|
235
235
|
return null;
|
|
236
|
-
const T =
|
|
237
|
-
let
|
|
238
|
-
|
|
239
|
-
value: String(
|
|
240
|
-
label:
|
|
236
|
+
const T = o.length === 0;
|
|
237
|
+
let R = [];
|
|
238
|
+
s.enum ? R = s.enum.map((v) => ({ value: String(v), label: String(v) })) : s.oneOf && (R = s.oneOf.map((v) => ({
|
|
239
|
+
value: String(v.const),
|
|
240
|
+
label: v.title || String(v.const)
|
|
241
241
|
})));
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
const
|
|
245
|
-
t
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
},
|
|
249
|
-
(
|
|
242
|
+
const I = e !== void 0 ? String(e) : "", A = ((z = u.options) == null ? void 0 : z.placeholder) || "Select an option";
|
|
243
|
+
if (d) {
|
|
244
|
+
const v = ((V = R.find((O) => O.value === I)) == null ? void 0 : V.label) ?? "", x = f ? R.filter((O) => O.label.toLowerCase().includes(g.toLowerCase())) : R, re = Math.min(M, x.length - 1), X = (O) => {
|
|
245
|
+
r(t, O.value), p(!1);
|
|
246
|
+
}, Y = (O) => {
|
|
247
|
+
O.stopPropagation(), r(t, void 0), b("");
|
|
248
|
+
}, L = (O) => {
|
|
249
|
+
(O.key === "Enter" || O.key === " ") && Y(O);
|
|
250
250
|
};
|
|
251
|
-
return /* @__PURE__ */
|
|
252
|
-
/* @__PURE__ */
|
|
253
|
-
|
|
251
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
252
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
|
|
253
|
+
n,
|
|
254
254
|
" ",
|
|
255
|
-
|
|
255
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
256
256
|
] }),
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
|
|
257
|
+
/* @__PURE__ */ y("div", { ref: U, style: { position: "relative" }, children: [
|
|
258
|
+
/* @__PURE__ */ i(
|
|
259
|
+
Oe.Root,
|
|
260
260
|
{
|
|
261
|
-
id:
|
|
262
|
-
value:
|
|
263
|
-
placeholder:
|
|
264
|
-
disabled: !
|
|
261
|
+
id: t,
|
|
262
|
+
value: f ? g : v,
|
|
263
|
+
placeholder: A,
|
|
264
|
+
disabled: !a,
|
|
265
265
|
style: T ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
|
|
266
|
-
onChange: (
|
|
267
|
-
|
|
266
|
+
onChange: (O) => {
|
|
267
|
+
b(O.target.value), N(0), f || p(!0);
|
|
268
268
|
},
|
|
269
269
|
onFocus: () => {
|
|
270
|
-
|
|
270
|
+
a && !f && (b(""), N(0), p(!0));
|
|
271
271
|
},
|
|
272
|
-
onKeyDown: (
|
|
273
|
-
|
|
272
|
+
onKeyDown: (O) => {
|
|
273
|
+
O.key === "Escape" ? p(!1) : O.key === "ArrowDown" ? (O.preventDefault(), f ? N((G) => Math.min(G + 1, x.length - 1)) : (b(""), p(!0))) : O.key === "ArrowUp" ? (O.preventDefault(), f && N((G) => Math.max(G - 1, 0))) : O.key === "Enter" && f && x[re] && (O.preventDefault(), X(x[re]));
|
|
274
274
|
},
|
|
275
|
-
children: /* @__PURE__ */
|
|
276
|
-
|
|
275
|
+
children: /* @__PURE__ */ i(Oe.Slot, { side: "right", children: /* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
|
|
276
|
+
I && a && /* @__PURE__ */ i(
|
|
277
277
|
"span",
|
|
278
278
|
{
|
|
279
279
|
role: "button",
|
|
280
280
|
tabIndex: 0,
|
|
281
|
-
onMouseDown: (
|
|
282
|
-
onClick:
|
|
283
|
-
onKeyDown:
|
|
281
|
+
onMouseDown: (O) => O.preventDefault(),
|
|
282
|
+
onClick: Y,
|
|
283
|
+
onKeyDown: L,
|
|
284
284
|
style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
|
|
285
285
|
"aria-label": "Clear selection",
|
|
286
286
|
children: "×"
|
|
287
287
|
}
|
|
288
288
|
),
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
|
|
289
|
+
/* @__PURE__ */ i(
|
|
290
|
+
Vt,
|
|
291
291
|
{
|
|
292
|
-
style: { transform:
|
|
292
|
+
style: { transform: f ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
|
|
293
293
|
}
|
|
294
294
|
)
|
|
295
295
|
] }) })
|
|
296
296
|
}
|
|
297
297
|
),
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
f && /* @__PURE__ */ i(
|
|
299
|
+
k,
|
|
300
300
|
{
|
|
301
301
|
style: {
|
|
302
302
|
position: "absolute",
|
|
@@ -310,194 +310,278 @@ const ge = (e, t, r, o = void 0) => {
|
|
|
310
310
|
border: "1px solid var(--gray-a6)",
|
|
311
311
|
overflow: "hidden"
|
|
312
312
|
},
|
|
313
|
-
children: /* @__PURE__ */
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
children: /* @__PURE__ */ i(Pt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(k, { p: "1", children: [
|
|
314
|
+
x.length === 0 && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "No results found." }) }),
|
|
315
|
+
x.map((O, G) => /* @__PURE__ */ i(
|
|
316
|
+
k,
|
|
317
317
|
{
|
|
318
318
|
px: "3",
|
|
319
319
|
py: "2",
|
|
320
|
-
onMouseDown: (
|
|
321
|
-
onClick: () =>
|
|
322
|
-
onMouseEnter: () =>
|
|
320
|
+
onMouseDown: (Q) => Q.preventDefault(),
|
|
321
|
+
onClick: () => X(O),
|
|
322
|
+
onMouseEnter: () => N(G),
|
|
323
323
|
style: {
|
|
324
324
|
cursor: "pointer",
|
|
325
325
|
borderRadius: "var(--radius-2)",
|
|
326
|
-
backgroundColor:
|
|
326
|
+
backgroundColor: G === re ? "var(--accent-4)" : O.value === I ? "var(--accent-3)" : void 0
|
|
327
327
|
},
|
|
328
|
-
children: /* @__PURE__ */
|
|
328
|
+
children: /* @__PURE__ */ i(h, { size: "2", children: O.label })
|
|
329
329
|
},
|
|
330
|
-
|
|
330
|
+
O.value
|
|
331
331
|
))
|
|
332
332
|
] }) })
|
|
333
333
|
}
|
|
334
334
|
)
|
|
335
335
|
] }),
|
|
336
|
-
!T && /* @__PURE__ */
|
|
337
|
-
|
|
336
|
+
!T && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
|
|
337
|
+
s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: s.description })
|
|
338
338
|
] }) });
|
|
339
339
|
}
|
|
340
|
-
return /* @__PURE__ */
|
|
341
|
-
/* @__PURE__ */
|
|
342
|
-
|
|
340
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
341
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
|
|
342
|
+
n,
|
|
343
343
|
" ",
|
|
344
|
-
|
|
344
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
345
345
|
] }),
|
|
346
|
-
/* @__PURE__ */
|
|
347
|
-
/* @__PURE__ */
|
|
348
|
-
/* @__PURE__ */
|
|
346
|
+
/* @__PURE__ */ y(qe.Root, { value: I, onValueChange: (v) => r(t, v), disabled: !a, children: [
|
|
347
|
+
/* @__PURE__ */ i(qe.Trigger, { placeholder: A, color: T ? void 0 : "red", id: t }),
|
|
348
|
+
/* @__PURE__ */ i(qe.Content, { children: R.map((v) => /* @__PURE__ */ i(qe.Item, { value: v.value, children: v.label }, v.value)) })
|
|
349
349
|
] }),
|
|
350
|
-
!T && /* @__PURE__ */
|
|
351
|
-
|
|
350
|
+
!T && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
|
|
351
|
+
s.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: s.description })
|
|
352
352
|
] }) });
|
|
353
|
-
},
|
|
353
|
+
}, Kr = te(2, tt(Ft, Ut)), Gr = pe(Yr), Xt = /\{([A-Za-z0-9_]+)(?:\(([^(){}]*)\))?\}/g, qr = {
|
|
354
|
+
today: (e) => Ht().format(e || "YYYY-MM-DD")
|
|
355
|
+
}, Jr = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint", bt = (e, r) => Object.prototype.hasOwnProperty.call(e, r);
|
|
356
|
+
function rt(e, r, t = {}) {
|
|
357
|
+
const n = { ...qr, ...t };
|
|
358
|
+
return e.replace(Xt, (l, o, s) => {
|
|
359
|
+
let u;
|
|
360
|
+
if (s === void 0) {
|
|
361
|
+
if (!bt(r, o)) return l;
|
|
362
|
+
u = r[o];
|
|
363
|
+
} else {
|
|
364
|
+
if (!bt(n, o)) return l;
|
|
365
|
+
try {
|
|
366
|
+
u = n[o](s);
|
|
367
|
+
} catch {
|
|
368
|
+
return l;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return u == null ? "" : Jr(u) ? String(u) : l;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function dt(e) {
|
|
375
|
+
const r = [];
|
|
376
|
+
let t = 0;
|
|
377
|
+
for (const n of e.matchAll(Xt))
|
|
378
|
+
n.index > t && r.push(e.slice(t, n.index)), r.push(n[2] === void 0 ? { name: n[1] } : { name: n[1], arg: n[2] }), t = n.index + n[0].length;
|
|
379
|
+
return t < e.length && r.push(e.slice(t)), r;
|
|
380
|
+
}
|
|
381
|
+
function Zr(e) {
|
|
382
|
+
if (typeof e == "string" && e.length > 0) return e;
|
|
383
|
+
if (e && typeof e == "object" && typeof e.value == "string") {
|
|
384
|
+
const r = e.value;
|
|
385
|
+
return r.length > 0 ? r : void 0;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function Qr(e) {
|
|
389
|
+
if (typeof e == "string") return e.length > 0 ? { parent: e } : void 0;
|
|
390
|
+
if (!e || typeof e != "object") return;
|
|
391
|
+
const r = Object.entries(e);
|
|
392
|
+
if (r.length === 0) return;
|
|
393
|
+
const t = {}, n = [];
|
|
394
|
+
for (const [l, o] of r)
|
|
395
|
+
typeof o == "string" && o.length > 0 ? t[l] = o : n.push(l);
|
|
396
|
+
return n.length > 0 && console.warn(`x-search.dependsOn: ignoring invalid entries [${n.join(", ")}]`), Object.keys(t).length === 0 ? (console.warn("x-search.dependsOn: map has no valid entries; search will not fetch until fixed"), {}) : t;
|
|
397
|
+
}
|
|
398
|
+
function en(e, r, t) {
|
|
399
|
+
const n = {};
|
|
400
|
+
for (const [l, o] of Object.entries(e))
|
|
401
|
+
n[l] = Zr(Pe.data(r, t ? `${t}.${o}` : o));
|
|
402
|
+
return n;
|
|
403
|
+
}
|
|
404
|
+
function vt(e, r) {
|
|
405
|
+
return r ? { ...e, name: rt(r, e) } : e;
|
|
406
|
+
}
|
|
407
|
+
const tn = {
|
|
354
408
|
"small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
|
|
355
409
|
"large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
|
|
356
410
|
"large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
|
|
357
|
-
},
|
|
411
|
+
}, rn = ({
|
|
358
412
|
data: e,
|
|
359
|
-
handleChange:
|
|
360
|
-
path:
|
|
361
|
-
label:
|
|
362
|
-
required:
|
|
363
|
-
errors:
|
|
364
|
-
enabled:
|
|
365
|
-
visible:
|
|
366
|
-
schema:
|
|
367
|
-
uischema:
|
|
413
|
+
handleChange: r,
|
|
414
|
+
path: t,
|
|
415
|
+
label: n,
|
|
416
|
+
required: l,
|
|
417
|
+
errors: o,
|
|
418
|
+
enabled: s,
|
|
419
|
+
visible: u = !0,
|
|
420
|
+
schema: a,
|
|
421
|
+
uischema: c
|
|
368
422
|
}) => {
|
|
369
|
-
var
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
423
|
+
var Ke, ye;
|
|
424
|
+
const d = (a == null ? void 0 : a["x-search"]) ?? {
|
|
425
|
+
service: "",
|
|
426
|
+
displayTemplate: ""
|
|
427
|
+
}, f = d.service ?? "", p = d.mode ?? "large-paginated-list", g = tn[p], b = (g == null ? void 0 : g.fetchOnOpen) ?? !1, M = typeof d.displayTemplate == "string" ? d.displayTemplate : "", N = Ve(), U = t.split(".").slice(0, -1).join("."), { parentValues: T, parentValuesKey: R, missingParent: I } = We(() => {
|
|
428
|
+
var be;
|
|
429
|
+
const E = Qr(d.dependsOn);
|
|
430
|
+
if (!E) return { parentValues: void 0, parentValuesKey: "", missingParent: !1 };
|
|
431
|
+
const Z = en(E, (be = N.core) == null ? void 0 : be.data, U), le = Object.keys(Z).length === 0 || Object.values(Z).some((Ce) => !Ce);
|
|
432
|
+
return { parentValues: Z, parentValuesKey: JSON.stringify(Z), missingParent: le };
|
|
433
|
+
}, [d.dependsOn, (Ke = N.core) == null ? void 0 : Ke.data, U]), A = We(() => T ? { ...d.params, ...T } : d.params, [T, R, d.params]), D = Mr(f), z = a.type === "object", V = z ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, v = z ? V == null ? void 0 : V.value : e, x = V == null ? void 0 : V.label, re = f ? D ? g ? M ? null : "x-search.displayTemplate is required." : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${f}" is not registered.` : "Search not configured.", X = s !== !1, Y = !o || o.length === 0, [L, O] = j(!1), [G, Q] = j(""), [de, ne] = j([]), [Ne, S] = j(!1), [K, fe] = j(!1), [Ee, ee] = j(!1), [ge, ie] = j(null), [Te, m] = j(void 0), w = ue(void 0), $ = ue(null), B = ue(null), q = ue(null), J = ue(void 0), C = ue(void 0);
|
|
434
|
+
me(() => {
|
|
435
|
+
if (!T) return;
|
|
436
|
+
const E = C.current;
|
|
437
|
+
if (C.current = T, !E || !v) return;
|
|
438
|
+
Object.keys(T).some((le) => E[le] !== void 0 && E[le] !== T[le]) && r(t, z ? void 0 : null);
|
|
439
|
+
}, [R, v, r, t, z]), me(() => {
|
|
440
|
+
var be, Ce;
|
|
441
|
+
if (re) {
|
|
442
|
+
m(void 0), J.current = void 0;
|
|
375
443
|
return;
|
|
376
444
|
}
|
|
377
|
-
if (
|
|
378
|
-
|
|
379
|
-
B({ id: S, name: N });
|
|
445
|
+
if (!v) {
|
|
446
|
+
m(void 0), J.current = void 0;
|
|
380
447
|
return;
|
|
381
448
|
}
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
449
|
+
if (((be = J.current) == null ? void 0 : be.value) === v && ((Ce = J.current) == null ? void 0 : Ce.label) === x) return;
|
|
450
|
+
if (z && x) {
|
|
451
|
+
m({ id: v, name: x }), J.current = { value: v, label: x };
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (m({ id: v, name: x ?? v }), !(D != null && D.resolve)) {
|
|
455
|
+
J.current = { value: v, label: x };
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
let E = !1;
|
|
459
|
+
const Z = v, le = x;
|
|
460
|
+
return D.resolve(Z, A).then((He) => {
|
|
461
|
+
E || (He && m(vt(He, M)), J.current = { value: Z, label: le });
|
|
386
462
|
}).catch(() => {
|
|
463
|
+
E || (J.current = { value: Z, label: le });
|
|
387
464
|
}), () => {
|
|
388
|
-
|
|
465
|
+
E = !0;
|
|
389
466
|
};
|
|
390
|
-
}, [
|
|
391
|
-
const
|
|
392
|
-
async (
|
|
393
|
-
var
|
|
394
|
-
if (
|
|
395
|
-
|
|
467
|
+
}, [re, v, x, z, D, A, M]);
|
|
468
|
+
const P = $e(
|
|
469
|
+
async (E, Z = !1) => {
|
|
470
|
+
var be;
|
|
471
|
+
if (re) return;
|
|
472
|
+
if (!D) {
|
|
473
|
+
ie("Search service not configured.");
|
|
396
474
|
return;
|
|
397
475
|
}
|
|
398
|
-
(
|
|
399
|
-
const
|
|
400
|
-
|
|
476
|
+
(be = B.current) == null || be.abort();
|
|
477
|
+
const le = new AbortController();
|
|
478
|
+
B.current = le, Z ? ee(!0) : (fe(!0), ee(!1), ie(null));
|
|
401
479
|
try {
|
|
402
|
-
const
|
|
403
|
-
query:
|
|
404
|
-
cursor:
|
|
405
|
-
signal:
|
|
406
|
-
params:
|
|
407
|
-
})
|
|
408
|
-
|
|
480
|
+
const Ce = await D.search({
|
|
481
|
+
query: E,
|
|
482
|
+
cursor: Z ? w.current : void 0,
|
|
483
|
+
signal: le.signal,
|
|
484
|
+
params: A
|
|
485
|
+
});
|
|
486
|
+
if (le.signal.aborted) return;
|
|
487
|
+
const He = (Ce.options ?? []).map((nt) => vt(nt, M));
|
|
488
|
+
ne(Z ? (nt) => [...nt, ...He] : He), w.current = Ce.nextCursor, S(((g == null ? void 0 : g.paginated) ?? !1) && Ce.nextCursor != null);
|
|
409
489
|
} catch {
|
|
410
|
-
if (
|
|
411
|
-
|
|
490
|
+
if (le.signal.aborted) return;
|
|
491
|
+
ie("Failed to load results. Please try again.");
|
|
412
492
|
} finally {
|
|
413
|
-
|
|
493
|
+
le.signal.aborted || (Z ? ee(!1) : fe(!1));
|
|
414
494
|
}
|
|
415
495
|
},
|
|
416
|
-
[
|
|
496
|
+
[re, D, g == null ? void 0 : g.paginated, A, M]
|
|
417
497
|
);
|
|
418
|
-
if (
|
|
419
|
-
if (!
|
|
420
|
-
const
|
|
421
|
-
|
|
498
|
+
if (me(() => {
|
|
499
|
+
if (!L) return;
|
|
500
|
+
const E = (Z) => {
|
|
501
|
+
q.current && !q.current.contains(Z.target) && O(!1);
|
|
422
502
|
};
|
|
423
|
-
return document.addEventListener("mousedown",
|
|
424
|
-
}, [
|
|
425
|
-
var
|
|
426
|
-
|
|
427
|
-
}, [
|
|
428
|
-
if (!
|
|
429
|
-
if (
|
|
430
|
-
|
|
503
|
+
return document.addEventListener("mousedown", E), () => document.removeEventListener("mousedown", E);
|
|
504
|
+
}, [L]), me(() => {
|
|
505
|
+
var E;
|
|
506
|
+
L || ((E = B.current) == null || E.abort(), Q(""), ne([]), S(!1), ie(null), fe(!1), ee(!1), w.current = void 0);
|
|
507
|
+
}, [L]), me(() => {
|
|
508
|
+
if (!L) return;
|
|
509
|
+
if (I) {
|
|
510
|
+
ne([]), S(!1), ie(null), w.current = void 0;
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
if (!G && !b) {
|
|
514
|
+
ne([]), S(!1), ie(null), w.current = void 0;
|
|
431
515
|
return;
|
|
432
516
|
}
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
return
|
|
436
|
-
|
|
437
|
-
},
|
|
438
|
-
|
|
517
|
+
$.current && clearTimeout($.current);
|
|
518
|
+
const E = G ? 300 : 0;
|
|
519
|
+
return $.current = setTimeout(() => {
|
|
520
|
+
ne([]), S(!1), w.current = void 0, P(G);
|
|
521
|
+
}, E), () => {
|
|
522
|
+
$.current && clearTimeout($.current);
|
|
439
523
|
};
|
|
440
|
-
}, [b,
|
|
524
|
+
}, [G, L, b, P, I, R]), Re(u, t, r), u === !1)
|
|
441
525
|
return null;
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
},
|
|
445
|
-
t
|
|
446
|
-
},
|
|
447
|
-
|
|
448
|
-
},
|
|
449
|
-
(
|
|
450
|
-
},
|
|
451
|
-
return /* @__PURE__ */
|
|
452
|
-
/* @__PURE__ */
|
|
453
|
-
|
|
526
|
+
const se = () => {
|
|
527
|
+
Q(""), ne([]), S(!1), ie(null), w.current = void 0, O(!0);
|
|
528
|
+
}, H = (E) => {
|
|
529
|
+
r(t, z ? { value: E.id, label: E.name } : E.id), m(E), J.current = { value: E.id, label: z ? E.name : void 0 }, O(!1);
|
|
530
|
+
}, _ = (E) => {
|
|
531
|
+
E.stopPropagation(), r(t, void 0), m(void 0);
|
|
532
|
+
}, De = (E) => {
|
|
533
|
+
(E.key === "Enter" || E.key === " ") && _(E);
|
|
534
|
+
}, Fe = ((ye = c == null ? void 0 : c.options) == null ? void 0 : ye.placeholder) ?? "Select an option";
|
|
535
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
536
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: t, children: [
|
|
537
|
+
n,
|
|
454
538
|
" ",
|
|
455
|
-
|
|
539
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
456
540
|
] }),
|
|
457
|
-
/* @__PURE__ */
|
|
458
|
-
/* @__PURE__ */
|
|
459
|
-
|
|
541
|
+
/* @__PURE__ */ y("div", { ref: q, style: { position: "relative" }, children: [
|
|
542
|
+
/* @__PURE__ */ i(
|
|
543
|
+
Oe.Root,
|
|
460
544
|
{
|
|
461
|
-
id:
|
|
462
|
-
value:
|
|
463
|
-
placeholder:
|
|
464
|
-
disabled:
|
|
465
|
-
readOnly:
|
|
466
|
-
style:
|
|
467
|
-
onChange: (
|
|
468
|
-
|
|
545
|
+
id: t,
|
|
546
|
+
value: L ? G : (Te == null ? void 0 : Te.name) ?? "",
|
|
547
|
+
placeholder: L && (g != null && g.searchable) ? "Search..." : Fe,
|
|
548
|
+
disabled: !X,
|
|
549
|
+
readOnly: L && !(g != null && g.searchable),
|
|
550
|
+
style: Y ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
|
|
551
|
+
onChange: (E) => {
|
|
552
|
+
g != null && g.searchable && (Q(E.target.value), L || se());
|
|
469
553
|
},
|
|
470
554
|
onFocus: () => {
|
|
471
|
-
|
|
555
|
+
X && !L && se();
|
|
472
556
|
},
|
|
473
|
-
onKeyDown: (
|
|
474
|
-
|
|
557
|
+
onKeyDown: (E) => {
|
|
558
|
+
E.key === "Escape" && O(!1);
|
|
475
559
|
},
|
|
476
|
-
children: /* @__PURE__ */
|
|
477
|
-
|
|
560
|
+
children: /* @__PURE__ */ i(Oe.Slot, { side: "right", children: /* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
|
|
561
|
+
v && X && /* @__PURE__ */ i(
|
|
478
562
|
"span",
|
|
479
563
|
{
|
|
480
564
|
role: "button",
|
|
481
565
|
tabIndex: 0,
|
|
482
|
-
onMouseDown: (
|
|
483
|
-
onClick:
|
|
484
|
-
onKeyDown:
|
|
566
|
+
onMouseDown: (E) => E.preventDefault(),
|
|
567
|
+
onClick: _,
|
|
568
|
+
onKeyDown: De,
|
|
485
569
|
style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
|
|
486
570
|
"aria-label": "Clear selection",
|
|
487
571
|
children: "×"
|
|
488
572
|
}
|
|
489
573
|
),
|
|
490
|
-
/* @__PURE__ */
|
|
491
|
-
|
|
574
|
+
/* @__PURE__ */ i(
|
|
575
|
+
Vt,
|
|
492
576
|
{
|
|
493
|
-
style: { transform:
|
|
577
|
+
style: { transform: L ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
|
|
494
578
|
}
|
|
495
579
|
)
|
|
496
580
|
] }) })
|
|
497
581
|
}
|
|
498
582
|
),
|
|
499
|
-
|
|
500
|
-
|
|
583
|
+
L && /* @__PURE__ */ i(
|
|
584
|
+
k,
|
|
501
585
|
{
|
|
502
586
|
style: {
|
|
503
587
|
position: "absolute",
|
|
@@ -511,471 +595,586 @@ const ge = (e, t, r, o = void 0) => {
|
|
|
511
595
|
border: "1px solid var(--gray-a6)",
|
|
512
596
|
overflow: "hidden"
|
|
513
597
|
},
|
|
514
|
-
children:
|
|
515
|
-
|
|
516
|
-
!
|
|
517
|
-
!
|
|
518
|
-
|
|
519
|
-
|
|
598
|
+
children: re ? /* @__PURE__ */ i(k, { p: "3", children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: re }) }) : /* @__PURE__ */ i(Pt, { style: { maxHeight: 240 }, children: /* @__PURE__ */ y(k, { p: "1", children: [
|
|
599
|
+
K && /* @__PURE__ */ i(F, { justify: "center", p: "4", children: /* @__PURE__ */ i(_e, {}) }),
|
|
600
|
+
!K && ge && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(h, { size: "2", color: "red", children: ge }) }),
|
|
601
|
+
!K && !ge && de.length === 0 && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: I ? "Select the related field first." : G || b ? "No results found." : "Type to search…" }) }),
|
|
602
|
+
de.map((E) => /* @__PURE__ */ i(
|
|
603
|
+
k,
|
|
520
604
|
{
|
|
521
605
|
px: "3",
|
|
522
606
|
py: "2",
|
|
523
|
-
onMouseDown: (
|
|
524
|
-
onClick: () =>
|
|
607
|
+
onMouseDown: (Z) => Z.preventDefault(),
|
|
608
|
+
onClick: () => H(E),
|
|
525
609
|
style: {
|
|
526
610
|
cursor: "pointer",
|
|
527
611
|
borderRadius: "var(--radius-2)",
|
|
528
|
-
backgroundColor:
|
|
612
|
+
backgroundColor: E.id === v ? "var(--accent-3)" : void 0
|
|
529
613
|
},
|
|
530
614
|
className: "hover:bg-(--gray-3)",
|
|
531
|
-
children: /* @__PURE__ */
|
|
615
|
+
children: /* @__PURE__ */ i(h, { size: "2", children: E.name })
|
|
532
616
|
},
|
|
533
|
-
|
|
617
|
+
E.id
|
|
534
618
|
)),
|
|
535
|
-
(
|
|
536
|
-
|
|
619
|
+
(g == null ? void 0 : g.paginated) && Ne && !Ee && /* @__PURE__ */ i(k, { px: "3", py: "2", children: /* @__PURE__ */ i(
|
|
620
|
+
ze,
|
|
537
621
|
{
|
|
538
622
|
variant: "ghost",
|
|
539
623
|
size: "1",
|
|
540
624
|
style: { width: "100%" },
|
|
541
|
-
onMouseDown: (
|
|
542
|
-
onClick: () => void
|
|
625
|
+
onMouseDown: (E) => E.preventDefault(),
|
|
626
|
+
onClick: () => void P(G, !0),
|
|
543
627
|
children: "Load more"
|
|
544
628
|
}
|
|
545
629
|
) }),
|
|
546
|
-
|
|
630
|
+
Ee && /* @__PURE__ */ i(F, { justify: "center", p: "2", children: /* @__PURE__ */ i(_e, {}) })
|
|
547
631
|
] }) })
|
|
548
632
|
}
|
|
549
633
|
)
|
|
550
634
|
] }),
|
|
551
|
-
!
|
|
552
|
-
|
|
635
|
+
!Y && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(o, n) }),
|
|
636
|
+
a.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: a.description })
|
|
553
637
|
] }) });
|
|
554
|
-
},
|
|
638
|
+
}, nn = pe(rn), on = te(
|
|
555
639
|
3,
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
return (e.type === "string" || e.type === "object") && typeof (
|
|
640
|
+
Me((e) => {
|
|
641
|
+
const r = e["x-search"];
|
|
642
|
+
return (e.type === "string" || e.type === "object") && typeof (r == null ? void 0 : r.service) == "string" && r.service !== "";
|
|
559
643
|
})
|
|
560
|
-
),
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
644
|
+
), sn = (e) => {
|
|
645
|
+
if (e)
|
|
646
|
+
return /^\d{2}:\d{2}$/.test(e) ? `${e}:00` : e;
|
|
647
|
+
}, wt = (e, r) => {
|
|
648
|
+
if (!e) return "";
|
|
649
|
+
const t = e.match(/^(\d{2}:\d{2})(:\d{2})?/);
|
|
650
|
+
return t ? r ? `${t[1]}${t[2] ?? ":00"}` : t[1] : e;
|
|
651
|
+
}, ln = (e, r) => Ht(`${e}T${r}`).format(), an = ({ path: e, label: r, required: t, errors: n, description: l, children: o }) => {
|
|
652
|
+
const s = n.length === 0;
|
|
653
|
+
return /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
654
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
|
|
655
|
+
r,
|
|
565
656
|
" ",
|
|
566
|
-
|
|
657
|
+
t && /* @__PURE__ */ i(h, { color: "red", children: "*" })
|
|
567
658
|
] }),
|
|
568
|
-
|
|
569
|
-
!
|
|
570
|
-
|
|
659
|
+
o,
|
|
660
|
+
!s && /* @__PURE__ */ i(h, { color: "red", size: "1", children: we(n, r) }),
|
|
661
|
+
l && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: l })
|
|
571
662
|
] }) });
|
|
572
|
-
},
|
|
663
|
+
}, cn = ({
|
|
573
664
|
data: e,
|
|
574
|
-
handleChange:
|
|
575
|
-
path:
|
|
576
|
-
label:
|
|
577
|
-
required:
|
|
578
|
-
errors:
|
|
579
|
-
schema:
|
|
580
|
-
|
|
581
|
-
|
|
665
|
+
handleChange: r,
|
|
666
|
+
path: t,
|
|
667
|
+
label: n,
|
|
668
|
+
required: l,
|
|
669
|
+
errors: o,
|
|
670
|
+
schema: s,
|
|
671
|
+
uischema: u,
|
|
672
|
+
enabled: a,
|
|
673
|
+
visible: c = !0
|
|
582
674
|
}) => {
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
675
|
+
var I;
|
|
676
|
+
if (me(() => {
|
|
677
|
+
c === !1 && r(t, void 0);
|
|
678
|
+
}, [c, t, r]), c === !1)
|
|
586
679
|
return null;
|
|
587
|
-
const d =
|
|
588
|
-
if (
|
|
589
|
-
return
|
|
590
|
-
/* @__PURE__ */
|
|
591
|
-
|
|
680
|
+
const d = o.length === 0, f = typeof e == "string" ? e : "", p = ((I = u == null ? void 0 : u.options) == null ? void 0 : I.showSeconds) === !0, g = p ? 1 : 60, b = (A) => /* @__PURE__ */ i(an, { path: t, label: n, required: l, errors: o, description: s.description, children: A });
|
|
681
|
+
if (s.format === "time")
|
|
682
|
+
return b(
|
|
683
|
+
/* @__PURE__ */ i(
|
|
684
|
+
Oe.Root,
|
|
592
685
|
{
|
|
593
686
|
type: "time",
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
687
|
+
step: g,
|
|
688
|
+
value: wt(f, p),
|
|
689
|
+
onChange: (A) => r(t, sn(A.target.value)),
|
|
690
|
+
disabled: !a,
|
|
597
691
|
color: d ? void 0 : "red",
|
|
598
|
-
id:
|
|
692
|
+
id: t
|
|
599
693
|
}
|
|
600
694
|
)
|
|
601
695
|
);
|
|
602
|
-
const
|
|
603
|
-
if (!
|
|
604
|
-
t
|
|
696
|
+
const M = s.format === "date-time", [N = "", U = ""] = f.split("T"), T = wt(U, p), R = (A, D) => {
|
|
697
|
+
if (!A) {
|
|
698
|
+
r(t, void 0);
|
|
605
699
|
return;
|
|
606
700
|
}
|
|
607
|
-
t
|
|
701
|
+
r(t, M ? ln(A, D || "00:00") : A);
|
|
608
702
|
};
|
|
609
|
-
return
|
|
610
|
-
/* @__PURE__ */
|
|
611
|
-
/* @__PURE__ */
|
|
612
|
-
|
|
703
|
+
return b(
|
|
704
|
+
/* @__PURE__ */ y(F, { gap: "2", align: "center", children: [
|
|
705
|
+
/* @__PURE__ */ i(
|
|
706
|
+
Oe.Root,
|
|
613
707
|
{
|
|
614
708
|
type: "date",
|
|
615
|
-
value:
|
|
616
|
-
disabled: !
|
|
709
|
+
value: N,
|
|
710
|
+
disabled: !a,
|
|
617
711
|
color: d ? void 0 : "red",
|
|
618
|
-
onChange: (
|
|
619
|
-
id:
|
|
712
|
+
onChange: (A) => R(A.target.value, T),
|
|
713
|
+
id: t,
|
|
620
714
|
style: { flex: 1 }
|
|
621
715
|
}
|
|
622
716
|
),
|
|
623
|
-
|
|
624
|
-
|
|
717
|
+
M && /* @__PURE__ */ i(
|
|
718
|
+
Oe.Root,
|
|
625
719
|
{
|
|
626
720
|
type: "time",
|
|
627
|
-
|
|
628
|
-
|
|
721
|
+
step: g,
|
|
722
|
+
value: T,
|
|
723
|
+
disabled: !a || !N,
|
|
629
724
|
color: d ? void 0 : "red",
|
|
630
|
-
onChange: (
|
|
725
|
+
onChange: (A) => R(N, A.target.value),
|
|
631
726
|
style: { flex: 1 }
|
|
632
727
|
}
|
|
633
728
|
)
|
|
634
729
|
] })
|
|
635
730
|
);
|
|
636
|
-
},
|
|
731
|
+
}, un = te(2, tt(br, vr, wr)), dn = pe(cn), fn = ({
|
|
637
732
|
uischema: e,
|
|
638
|
-
schema:
|
|
639
|
-
path:
|
|
640
|
-
renderers:
|
|
641
|
-
cells:
|
|
642
|
-
enabled:
|
|
643
|
-
visible:
|
|
733
|
+
schema: r,
|
|
734
|
+
path: t,
|
|
735
|
+
renderers: n,
|
|
736
|
+
cells: l,
|
|
737
|
+
enabled: o,
|
|
738
|
+
visible: s = !0
|
|
644
739
|
}) => {
|
|
645
|
-
const
|
|
646
|
-
return
|
|
647
|
-
|
|
740
|
+
const a = e.elements;
|
|
741
|
+
return s === !1 ? null : /* @__PURE__ */ i(F, { direction: "column", gap: "4", children: a.map((c, d) => /* @__PURE__ */ i(
|
|
742
|
+
Ye,
|
|
648
743
|
{
|
|
649
|
-
uischema:
|
|
650
|
-
schema:
|
|
651
|
-
path:
|
|
652
|
-
renderers:
|
|
653
|
-
cells:
|
|
654
|
-
enabled:
|
|
744
|
+
uischema: c,
|
|
745
|
+
schema: r,
|
|
746
|
+
path: t,
|
|
747
|
+
renderers: n,
|
|
748
|
+
cells: l,
|
|
749
|
+
enabled: o
|
|
655
750
|
},
|
|
656
|
-
`${
|
|
751
|
+
`${t}-${d}`
|
|
657
752
|
)) });
|
|
658
|
-
},
|
|
753
|
+
}, pn = te(1, Xe("VerticalLayout")), hn = ({
|
|
659
754
|
uischema: e,
|
|
660
|
-
schema:
|
|
661
|
-
path:
|
|
662
|
-
renderers:
|
|
663
|
-
cells:
|
|
664
|
-
enabled:
|
|
665
|
-
visible:
|
|
755
|
+
schema: r,
|
|
756
|
+
path: t,
|
|
757
|
+
renderers: n,
|
|
758
|
+
cells: l,
|
|
759
|
+
enabled: o,
|
|
760
|
+
visible: s = !0
|
|
666
761
|
}) => {
|
|
667
|
-
const
|
|
668
|
-
return
|
|
669
|
-
|
|
762
|
+
const a = e.elements;
|
|
763
|
+
return s === !1 ? null : /* @__PURE__ */ i(F, { direction: "row", gap: "4", children: a.map((c, d) => /* @__PURE__ */ i(k, { style: { flex: 1 }, children: /* @__PURE__ */ i(
|
|
764
|
+
Ye,
|
|
670
765
|
{
|
|
671
|
-
uischema:
|
|
672
|
-
schema:
|
|
673
|
-
path:
|
|
674
|
-
renderers:
|
|
675
|
-
cells:
|
|
676
|
-
enabled:
|
|
766
|
+
uischema: c,
|
|
767
|
+
schema: r,
|
|
768
|
+
path: t,
|
|
769
|
+
renderers: n,
|
|
770
|
+
cells: l,
|
|
771
|
+
enabled: o
|
|
677
772
|
}
|
|
678
|
-
) }, `${
|
|
679
|
-
},
|
|
773
|
+
) }, `${t}-${d}`)) });
|
|
774
|
+
}, mn = te(1, Xe("HorizontalLayout")), gn = ({
|
|
680
775
|
uischema: e,
|
|
681
|
-
schema:
|
|
682
|
-
path:
|
|
683
|
-
renderers:
|
|
684
|
-
cells:
|
|
685
|
-
enabled:
|
|
686
|
-
visible:
|
|
776
|
+
schema: r,
|
|
777
|
+
path: t,
|
|
778
|
+
renderers: n,
|
|
779
|
+
cells: l,
|
|
780
|
+
enabled: o,
|
|
781
|
+
visible: s = !0
|
|
687
782
|
}) => {
|
|
688
|
-
const
|
|
689
|
-
return
|
|
690
|
-
|
|
691
|
-
/* @__PURE__ */
|
|
692
|
-
|
|
783
|
+
const u = e, a = u.elements;
|
|
784
|
+
return s === !1 ? null : /* @__PURE__ */ y(k, { mb: "6", children: [
|
|
785
|
+
u.label && /* @__PURE__ */ i(_t, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: u.label }),
|
|
786
|
+
/* @__PURE__ */ i(F, { direction: "column", gap: "4", children: a.map((c, d) => /* @__PURE__ */ i(
|
|
787
|
+
Ye,
|
|
693
788
|
{
|
|
694
|
-
uischema:
|
|
695
|
-
schema:
|
|
696
|
-
path:
|
|
697
|
-
renderers:
|
|
698
|
-
cells:
|
|
699
|
-
enabled:
|
|
789
|
+
uischema: c,
|
|
790
|
+
schema: r,
|
|
791
|
+
path: t,
|
|
792
|
+
renderers: n,
|
|
793
|
+
cells: l,
|
|
794
|
+
enabled: o
|
|
700
795
|
},
|
|
701
|
-
`${
|
|
796
|
+
`${t}-${d}`
|
|
702
797
|
)) })
|
|
703
798
|
] });
|
|
704
|
-
},
|
|
799
|
+
}, yn = te(1, Xe("Group")), bn = ({
|
|
705
800
|
uischema: e,
|
|
706
|
-
schema:
|
|
707
|
-
path:
|
|
708
|
-
renderers:
|
|
709
|
-
cells:
|
|
710
|
-
enabled:
|
|
711
|
-
visible:
|
|
801
|
+
schema: r,
|
|
802
|
+
path: t,
|
|
803
|
+
renderers: n,
|
|
804
|
+
cells: l,
|
|
805
|
+
enabled: o,
|
|
806
|
+
visible: s = !0
|
|
712
807
|
}) => {
|
|
713
|
-
var
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
const
|
|
717
|
-
return /* @__PURE__ */
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
/* @__PURE__ */
|
|
720
|
-
|
|
808
|
+
var p;
|
|
809
|
+
const a = e.elements.filter((g) => g.type === "Category"), [c, d] = j(((p = a[0]) == null ? void 0 : p.label) || "");
|
|
810
|
+
if (s === !1 || !a.length) return null;
|
|
811
|
+
const f = a.find((g) => g.label === c) ? c : a[0].label;
|
|
812
|
+
return /* @__PURE__ */ y(Je.Root, { value: f, onValueChange: d, children: [
|
|
813
|
+
/* @__PURE__ */ i(Je.List, { children: a.map((g, b) => /* @__PURE__ */ i(Je.Trigger, { value: g.label, children: g.label }, `${t}-${b}`)) }),
|
|
814
|
+
/* @__PURE__ */ i(k, { pt: "3", children: a.map((g, b) => /* @__PURE__ */ i(Je.Content, { value: g.label, children: /* @__PURE__ */ i(F, { direction: "column", gap: "4", children: g.elements.map((M, N) => /* @__PURE__ */ i(
|
|
815
|
+
Ye,
|
|
721
816
|
{
|
|
722
|
-
uischema:
|
|
723
|
-
schema:
|
|
724
|
-
path:
|
|
725
|
-
renderers:
|
|
726
|
-
cells:
|
|
727
|
-
enabled:
|
|
817
|
+
uischema: M,
|
|
818
|
+
schema: r,
|
|
819
|
+
path: t,
|
|
820
|
+
renderers: n,
|
|
821
|
+
cells: l,
|
|
822
|
+
enabled: o
|
|
728
823
|
},
|
|
729
|
-
`${
|
|
730
|
-
)) }) }, `${
|
|
824
|
+
`${t}-${b}-${N}`
|
|
825
|
+
)) }) }, `${t}-${b}`)) })
|
|
731
826
|
] });
|
|
732
|
-
},
|
|
733
|
-
function
|
|
827
|
+
}, vn = te(1, Xe("Categorization"));
|
|
828
|
+
function xe(e) {
|
|
734
829
|
return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
|
|
735
830
|
}
|
|
736
|
-
function
|
|
737
|
-
const
|
|
738
|
-
if (
|
|
739
|
-
if (
|
|
740
|
-
const
|
|
741
|
-
return
|
|
831
|
+
function Ae(e) {
|
|
832
|
+
const r = e.split(",").map((o) => o.trim()).filter(Boolean), t = r.filter((o) => o.startsWith(".")), l = (t.length > 0 ? t : r).map((o) => {
|
|
833
|
+
if (o.endsWith("/*")) return o.split("/")[0].toUpperCase() + "S";
|
|
834
|
+
if (o.startsWith(".")) return o.slice(1).toUpperCase();
|
|
835
|
+
const s = o.split("/")[1];
|
|
836
|
+
return s ? s.toUpperCase() : o;
|
|
742
837
|
});
|
|
743
|
-
return [...new Set(
|
|
838
|
+
return [...new Set(l)].join(", ");
|
|
839
|
+
}
|
|
840
|
+
const wn = "image/png,image/jpeg,image/gif,image/webp,application/pdf,text/html,text/plain,.png,.jpg,.jpeg,.gif,.webp,.pdf,.html,.htm,.txt";
|
|
841
|
+
function Yt(e, r) {
|
|
842
|
+
return r.split(",").map((n) => n.trim()).filter(Boolean).some((n) => n === "*" || n === "*/*" ? !0 : n.endsWith("/*") ? (e.type ?? "").startsWith(n.slice(0, -1)) : n.startsWith(".") ? e.name.toLowerCase().endsWith(n.toLowerCase()) : e.type === n);
|
|
843
|
+
}
|
|
844
|
+
function En(e) {
|
|
845
|
+
const r = !!e.type, t = it(e.name) !== void 0;
|
|
846
|
+
return !r && !t ? !0 : Yt(e, wn);
|
|
847
|
+
}
|
|
848
|
+
function it(e) {
|
|
849
|
+
const r = e.split(/[/\\]/).pop() ?? e, t = r.lastIndexOf(".");
|
|
850
|
+
if (!(t <= 0 || t === r.length - 1))
|
|
851
|
+
return r.slice(t);
|
|
852
|
+
}
|
|
853
|
+
function Tn(e, r, t) {
|
|
854
|
+
Kt(new Blob([e], { type: t }), r);
|
|
744
855
|
}
|
|
745
|
-
function
|
|
856
|
+
function Kt(e, r) {
|
|
857
|
+
const t = URL.createObjectURL(e), n = document.createElement("a");
|
|
858
|
+
n.href = t, n.download = r, n.click(), setTimeout(() => URL.revokeObjectURL(t), 0);
|
|
859
|
+
}
|
|
860
|
+
async function xn(e, r) {
|
|
861
|
+
const t = await fetch(e);
|
|
862
|
+
if (!t.ok) throw new Error(`Download failed (${t.status})`);
|
|
863
|
+
Kt(await t.blob(), r);
|
|
864
|
+
}
|
|
865
|
+
function An(e, r, t) {
|
|
866
|
+
const n = t.name || t.key;
|
|
867
|
+
if (!e) return n;
|
|
868
|
+
const l = ft(e, r, n), o = it(t.name ?? "") ?? it(t.key);
|
|
869
|
+
return !o || l.toLowerCase().endsWith(o.toLowerCase()) ? l : `${l}${o}`;
|
|
870
|
+
}
|
|
871
|
+
const Rn = /* @__PURE__ */ new Set(["/", "\\", "<", ">", ":", '"', "|", "?", "*"]), Cn = (e) => Rn.has(e) || e.charCodeAt(0) < 32 || e.charCodeAt(0) === 127;
|
|
872
|
+
function Sn(e, r) {
|
|
873
|
+
const t = Array.from(e, (n) => Cn(n) ? "_" : n).join("").trim();
|
|
874
|
+
return t === "" || t.startsWith(".") ? r : t;
|
|
875
|
+
}
|
|
876
|
+
function ft(e, r, t) {
|
|
877
|
+
const n = r !== null && typeof r == "object" && !Array.isArray(r) ? r : {};
|
|
878
|
+
return Sn(rt(e, n), t);
|
|
879
|
+
}
|
|
880
|
+
function On(e) {
|
|
746
881
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
747
882
|
}
|
|
748
|
-
const
|
|
883
|
+
const Nn = ({
|
|
749
884
|
data: e,
|
|
750
|
-
handleChange:
|
|
751
|
-
path:
|
|
752
|
-
label:
|
|
753
|
-
required:
|
|
754
|
-
uischema:
|
|
755
|
-
schema:
|
|
756
|
-
enabled:
|
|
757
|
-
errors:
|
|
758
|
-
visible:
|
|
885
|
+
handleChange: r,
|
|
886
|
+
path: t,
|
|
887
|
+
label: n,
|
|
888
|
+
required: l,
|
|
889
|
+
uischema: o,
|
|
890
|
+
schema: s,
|
|
891
|
+
enabled: u,
|
|
892
|
+
errors: a,
|
|
893
|
+
visible: c = !0
|
|
759
894
|
}) => {
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
|
|
895
|
+
const d = Lr();
|
|
896
|
+
Re(c, t, r);
|
|
897
|
+
const f = !a || a.length === 0, p = (s == null ? void 0 : s["x-file"]) ?? {}, g = (o == null ? void 0 : o.options) ?? {}, b = p.maxFiles ?? g.maxFiles ?? 1, M = p.maxSize ?? g.maxSize ?? 5 * 1024 * 1024, N = p.accept ?? g.accept ?? "image/*,application/pdf", U = typeof p.fileName == "string" ? p.fileName : void 0, T = b > 1, R = u !== !1, [I, A] = j(!1), [D, z] = j(null), [V, v] = j({}), [x, re] = j({}), X = ue(/* @__PURE__ */ new Set()), Y = ue(null), L = On(e), O = L.length >= b, G = (m) => {
|
|
898
|
+
const w = x[m];
|
|
899
|
+
return { name: (w == null ? void 0 : w.name) ?? m, type: w == null ? void 0 : w.type };
|
|
900
|
+
}, Q = async (m) => {
|
|
901
|
+
var B, q;
|
|
902
|
+
const w = (B = x[m]) == null ? void 0 : B.blobUrl;
|
|
903
|
+
if (w) return w;
|
|
904
|
+
const $ = await ((q = d == null ? void 0 : d.getDownloadUrl) == null ? void 0 : q.call(d, m));
|
|
905
|
+
return $ == null ? void 0 : $.url;
|
|
906
|
+
}, de = (m, w) => {
|
|
907
|
+
v(($) => ({ ...$, [m]: w }));
|
|
908
|
+
}, ne = (m) => {
|
|
909
|
+
v((w) => {
|
|
910
|
+
if (!w[m]) return w;
|
|
911
|
+
const $ = { ...w };
|
|
912
|
+
return delete $[m], $;
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
me(() => () => {
|
|
916
|
+
X.current.forEach((m) => URL.revokeObjectURL(m)), X.current.clear();
|
|
765
917
|
}, []);
|
|
766
|
-
const
|
|
767
|
-
async (
|
|
768
|
-
if (
|
|
769
|
-
|
|
918
|
+
const Ne = $e(
|
|
919
|
+
async (m) => {
|
|
920
|
+
if (z(null), L.length >= b) {
|
|
921
|
+
z(`Maximum ${b} file${b > 1 ? "s" : ""} allowed.`);
|
|
770
922
|
return;
|
|
771
923
|
}
|
|
772
|
-
if (
|
|
773
|
-
|
|
924
|
+
if (m.size > M) {
|
|
925
|
+
z(`File exceeds the ${xe(M)} limit.`);
|
|
774
926
|
return;
|
|
775
927
|
}
|
|
776
|
-
if (!
|
|
777
|
-
|
|
928
|
+
if (!Yt(m, N)) {
|
|
929
|
+
z(`Invalid type. Accepted: ${Ae(N)}`);
|
|
778
930
|
return;
|
|
779
931
|
}
|
|
780
|
-
if (!(
|
|
781
|
-
|
|
932
|
+
if (!(d != null && d.onUpload)) {
|
|
933
|
+
z("Upload service not configured.");
|
|
782
934
|
return;
|
|
783
935
|
}
|
|
784
936
|
try {
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
937
|
+
const w = await d.onUpload(m), $ = URL.createObjectURL(m);
|
|
938
|
+
X.current.add($);
|
|
939
|
+
const B = {
|
|
940
|
+
key: w.key,
|
|
941
|
+
name: w.name ?? m.name,
|
|
942
|
+
type: m.type || void 0,
|
|
943
|
+
blobUrl: $
|
|
944
|
+
};
|
|
945
|
+
re((J) => ({ ...J, [w.key]: B }));
|
|
946
|
+
const q = [...L, w.key];
|
|
947
|
+
r(t, T ? q : q[0]);
|
|
791
948
|
} catch {
|
|
792
|
-
|
|
949
|
+
z("Upload failed. Please try again."), Y.current && (Y.current.value = "");
|
|
793
950
|
}
|
|
794
951
|
},
|
|
795
|
-
[
|
|
952
|
+
[L, b, M, N, d, t, r, T]
|
|
796
953
|
);
|
|
797
|
-
if (
|
|
954
|
+
if (c === !1)
|
|
798
955
|
return null;
|
|
799
|
-
const
|
|
800
|
-
|
|
801
|
-
},
|
|
802
|
-
var
|
|
803
|
-
|
|
804
|
-
},
|
|
805
|
-
var
|
|
806
|
-
(
|
|
807
|
-
},
|
|
808
|
-
if (!
|
|
809
|
-
|
|
810
|
-
var
|
|
811
|
-
const
|
|
812
|
-
return
|
|
813
|
-
});
|
|
814
|
-
const
|
|
815
|
-
t
|
|
816
|
-
},
|
|
817
|
-
var
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
if (
|
|
821
|
-
(
|
|
956
|
+
const S = (m) => {
|
|
957
|
+
m.preventDefault(), m.stopPropagation(), !(!R || O) && A(m.type === "dragenter" || m.type === "dragover");
|
|
958
|
+
}, K = (m) => {
|
|
959
|
+
var w;
|
|
960
|
+
m.preventDefault(), m.stopPropagation(), A(!1), !(!R || O) && (w = m.dataTransfer.files) != null && w[0] && Ne(m.dataTransfer.files[0]);
|
|
961
|
+
}, fe = (m) => {
|
|
962
|
+
var w;
|
|
963
|
+
(w = m.target.files) != null && w[0] && (Ne(m.target.files[0]), m.target.value = "");
|
|
964
|
+
}, Ee = (m) => {
|
|
965
|
+
if (!R) return;
|
|
966
|
+
re(($) => {
|
|
967
|
+
var J;
|
|
968
|
+
const B = { ...$ }, q = (J = B[m]) == null ? void 0 : J.blobUrl;
|
|
969
|
+
return q && (URL.revokeObjectURL(q), X.current.delete(q)), delete B[m], B;
|
|
970
|
+
}), ne(m);
|
|
971
|
+
const w = L.filter(($) => $ !== m);
|
|
972
|
+
r(t, T ? w.length > 0 ? w : void 0 : w[0]);
|
|
973
|
+
}, ee = async (m, w) => {
|
|
974
|
+
var q, J;
|
|
975
|
+
m.preventDefault(), ne(w);
|
|
976
|
+
const $ = (q = x[w]) == null ? void 0 : q.blobUrl;
|
|
977
|
+
if ($) {
|
|
978
|
+
(J = window.open($, "_blank", "noopener,noreferrer")) == null || J.focus();
|
|
822
979
|
return;
|
|
823
980
|
}
|
|
824
|
-
const
|
|
825
|
-
if (
|
|
981
|
+
const B = window.open("", "_blank");
|
|
982
|
+
if (B)
|
|
826
983
|
try {
|
|
827
|
-
const
|
|
828
|
-
|
|
984
|
+
const C = await Q(w);
|
|
985
|
+
C ? B.location.href = C : (B.close(), de(w, "Unable to open file."));
|
|
829
986
|
} catch {
|
|
830
|
-
|
|
987
|
+
B.close(), de(w, "Unable to open file.");
|
|
988
|
+
}
|
|
989
|
+
}, ge = async (m, w) => {
|
|
990
|
+
ne(m);
|
|
991
|
+
try {
|
|
992
|
+
const $ = await Q(m);
|
|
993
|
+
if (!$) {
|
|
994
|
+
de(m, "Unable to download file.");
|
|
995
|
+
return;
|
|
831
996
|
}
|
|
997
|
+
await xn($, w);
|
|
998
|
+
} catch {
|
|
999
|
+
de(m, "Unable to download file.");
|
|
1000
|
+
}
|
|
832
1001
|
};
|
|
833
|
-
if (!
|
|
834
|
-
const ie =
|
|
835
|
-
return /* @__PURE__ */
|
|
836
|
-
/* @__PURE__ */
|
|
837
|
-
/* @__PURE__ */
|
|
838
|
-
|
|
839
|
-
|
|
1002
|
+
if (!R && L.length === 0) return null;
|
|
1003
|
+
const ie = b - L.length, Te = R && !O;
|
|
1004
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
1005
|
+
/* @__PURE__ */ y(F, { align: "center", justify: "between", mb: "2", children: [
|
|
1006
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", children: [
|
|
1007
|
+
n,
|
|
1008
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: " *" })
|
|
840
1009
|
] }),
|
|
841
|
-
/* @__PURE__ */
|
|
1010
|
+
/* @__PURE__ */ i(h, { size: "1", color: "gray", children: T ? `Up to ${b} files · ${xe(M)} each · ${Ae(N)}` : `${xe(M)} · ${Ae(N)}` })
|
|
842
1011
|
] }),
|
|
843
|
-
|
|
844
|
-
var
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
{
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
1012
|
+
L.map((m, w) => {
|
|
1013
|
+
var H;
|
|
1014
|
+
const $ = w + 1, B = (H = x[m]) == null ? void 0 : H.name, q = An(U, { index: $ }, { name: B, key: m }), J = U ? q : B ?? "Uploaded File", C = !!(U && B), P = V[m], se = En(G(m));
|
|
1015
|
+
return /* @__PURE__ */ y(jt, { size: "2", variant: "surface", mb: "2", children: [
|
|
1016
|
+
/* @__PURE__ */ y(F, { align: "center", gap: "3", children: [
|
|
1017
|
+
/* @__PURE__ */ i(
|
|
1018
|
+
k,
|
|
1019
|
+
{
|
|
1020
|
+
style: {
|
|
1021
|
+
background: "var(--blue-3)",
|
|
1022
|
+
padding: 8,
|
|
1023
|
+
borderRadius: 6,
|
|
1024
|
+
color: "var(--blue-9)",
|
|
1025
|
+
flexShrink: 0
|
|
1026
|
+
},
|
|
1027
|
+
children: /* @__PURE__ */ i(Nr, { width: "20", height: "20" })
|
|
1028
|
+
}
|
|
1029
|
+
),
|
|
1030
|
+
/* @__PURE__ */ y(k, { style: { flex: 1, overflow: "hidden" }, children: [
|
|
1031
|
+
/* @__PURE__ */ i(
|
|
1032
|
+
h,
|
|
1033
|
+
{
|
|
1034
|
+
size: "2",
|
|
1035
|
+
weight: "bold",
|
|
1036
|
+
style: {
|
|
1037
|
+
display: "block",
|
|
1038
|
+
overflow: "hidden",
|
|
1039
|
+
textOverflow: "ellipsis",
|
|
1040
|
+
whiteSpace: "nowrap"
|
|
1041
|
+
},
|
|
1042
|
+
children: J
|
|
1043
|
+
}
|
|
1044
|
+
),
|
|
1045
|
+
C && /* @__PURE__ */ i(
|
|
1046
|
+
h,
|
|
1047
|
+
{
|
|
1048
|
+
size: "1",
|
|
1049
|
+
color: "gray",
|
|
1050
|
+
style: {
|
|
1051
|
+
display: "block",
|
|
1052
|
+
overflow: "hidden",
|
|
1053
|
+
textOverflow: "ellipsis",
|
|
1054
|
+
whiteSpace: "nowrap"
|
|
1055
|
+
},
|
|
1056
|
+
children: B
|
|
1057
|
+
}
|
|
1058
|
+
)
|
|
1059
|
+
] }),
|
|
1060
|
+
/* @__PURE__ */ y(F, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
|
|
1061
|
+
se && /* @__PURE__ */ i(ze, { variant: "soft", color: "blue", size: "1", onClick: (_) => void ee(_, m), children: "View" }),
|
|
1062
|
+
/* @__PURE__ */ i(Be, { content: "Download", children: /* @__PURE__ */ i(
|
|
1063
|
+
je,
|
|
1064
|
+
{
|
|
1065
|
+
variant: "ghost",
|
|
1066
|
+
color: "gray",
|
|
1067
|
+
"aria-label": "Download",
|
|
1068
|
+
onClick: () => void ge(m, q),
|
|
1069
|
+
children: /* @__PURE__ */ i(at, {})
|
|
1070
|
+
}
|
|
1071
|
+
) }),
|
|
1072
|
+
/* @__PURE__ */ i(Dr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
|
|
1073
|
+
R && /* @__PURE__ */ i(je, { variant: "ghost", color: "gray", onClick: () => Ee(m), children: /* @__PURE__ */ i(ct, {}) })
|
|
1074
|
+
] })
|
|
1075
|
+
] }),
|
|
1076
|
+
P && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: P })
|
|
1077
|
+
] }, m);
|
|
879
1078
|
}),
|
|
880
|
-
|
|
1079
|
+
Te && /* @__PURE__ */ y(
|
|
881
1080
|
"div",
|
|
882
1081
|
{
|
|
883
1082
|
role: "button",
|
|
884
1083
|
tabIndex: 0,
|
|
885
1084
|
onClick: () => {
|
|
886
|
-
var
|
|
887
|
-
return (
|
|
1085
|
+
var m;
|
|
1086
|
+
return (m = Y.current) == null ? void 0 : m.click();
|
|
888
1087
|
},
|
|
889
|
-
onKeyDown: (
|
|
890
|
-
var
|
|
891
|
-
(
|
|
1088
|
+
onKeyDown: (m) => {
|
|
1089
|
+
var w;
|
|
1090
|
+
(m.key === "Enter" || m.key === " ") && (m.preventDefault(), (w = Y.current) == null || w.click());
|
|
892
1091
|
},
|
|
893
|
-
onDragEnter:
|
|
894
|
-
onDragLeave:
|
|
895
|
-
onDragOver:
|
|
896
|
-
onDrop:
|
|
1092
|
+
onDragEnter: S,
|
|
1093
|
+
onDragLeave: S,
|
|
1094
|
+
onDragOver: S,
|
|
1095
|
+
onDrop: K,
|
|
897
1096
|
style: { cursor: "pointer" },
|
|
898
1097
|
className: [
|
|
899
1098
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
900
1099
|
"transition-all duration-200 ease-in-out",
|
|
901
|
-
|
|
1100
|
+
I ? "border-blue-500 bg-blue-50" : D ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
|
|
902
1101
|
].join(" "),
|
|
903
1102
|
children: [
|
|
904
|
-
/* @__PURE__ */
|
|
905
|
-
/* @__PURE__ */
|
|
906
|
-
/* @__PURE__ */
|
|
907
|
-
/* @__PURE__ */
|
|
908
|
-
/* @__PURE__ */
|
|
909
|
-
] }) : /* @__PURE__ */
|
|
910
|
-
/* @__PURE__ */
|
|
911
|
-
/* @__PURE__ */
|
|
912
|
-
/* @__PURE__ */
|
|
913
|
-
|
|
1103
|
+
/* @__PURE__ */ i("input", { ref: Y, type: "file", style: { display: "none" }, accept: N, onChange: fe }),
|
|
1104
|
+
/* @__PURE__ */ i(F, { direction: "column", align: "center", gap: "2", children: D ? /* @__PURE__ */ y(ve, { children: [
|
|
1105
|
+
/* @__PURE__ */ i(ut, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
|
|
1106
|
+
/* @__PURE__ */ i(h, { size: "2", color: "red", weight: "medium", children: D }),
|
|
1107
|
+
/* @__PURE__ */ i(h, { size: "1", color: "gray", children: "Click to try again" })
|
|
1108
|
+
] }) : /* @__PURE__ */ y(ve, { children: [
|
|
1109
|
+
/* @__PURE__ */ i(Ue, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
|
|
1110
|
+
/* @__PURE__ */ i(h, { size: "2", weight: "medium", children: L.length > 0 ? `Add another file (${ie} remaining)` : "Click to upload or drag and drop" }),
|
|
1111
|
+
/* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
|
|
1112
|
+
xe(M),
|
|
914
1113
|
" max · ",
|
|
915
|
-
|
|
1114
|
+
Ae(N)
|
|
916
1115
|
] })
|
|
917
1116
|
] }) })
|
|
918
1117
|
]
|
|
919
1118
|
}
|
|
920
1119
|
),
|
|
921
|
-
|
|
1120
|
+
R && O && T && /* @__PURE__ */ y(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
|
|
922
1121
|
"Maximum ",
|
|
923
|
-
|
|
1122
|
+
b,
|
|
924
1123
|
" files uploaded. Remove one to replace it."
|
|
925
1124
|
] }),
|
|
926
|
-
!
|
|
1125
|
+
!f && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(a, n) })
|
|
927
1126
|
] });
|
|
928
|
-
},
|
|
1127
|
+
}, Dn = pe(Nn), In = te(
|
|
929
1128
|
10,
|
|
930
1129
|
// high rank to beat default array renderer
|
|
931
|
-
|
|
1130
|
+
$t(
|
|
932
1131
|
// Match both single-file (type: string) and multi-file (type: array)
|
|
933
|
-
|
|
1132
|
+
Me((e) => {
|
|
934
1133
|
if (e.type === "string" && e.format === "file") return !0;
|
|
935
1134
|
if (e.type === "array") {
|
|
936
|
-
const
|
|
937
|
-
return (
|
|
1135
|
+
const r = e.items;
|
|
1136
|
+
return (r == null ? void 0 : r.type) === "string" && (r == null ? void 0 : r.format) === "file";
|
|
938
1137
|
}
|
|
939
1138
|
return !1;
|
|
940
1139
|
})
|
|
941
1140
|
)
|
|
942
1141
|
);
|
|
943
|
-
function
|
|
944
|
-
return e !== !1 &&
|
|
945
|
-
}
|
|
946
|
-
class
|
|
947
|
-
}
|
|
948
|
-
async function
|
|
949
|
-
const { read:
|
|
950
|
-
if (
|
|
951
|
-
throw new
|
|
952
|
-
const
|
|
953
|
-
if (!
|
|
954
|
-
throw new
|
|
955
|
-
const
|
|
1142
|
+
function Gt(e, r) {
|
|
1143
|
+
return e !== !1 && r !== !0;
|
|
1144
|
+
}
|
|
1145
|
+
class st extends Error {
|
|
1146
|
+
}
|
|
1147
|
+
async function kn(e, r) {
|
|
1148
|
+
const { read: t, utils: n } = await import("@e965/xlsx"), l = t(e, { type: "array", cellDates: !0 });
|
|
1149
|
+
if (l.SheetNames.length === 0)
|
|
1150
|
+
throw new st("This file has no sheets.");
|
|
1151
|
+
const o = r ?? l.SheetNames[0], s = l.Sheets[o];
|
|
1152
|
+
if (!s)
|
|
1153
|
+
throw new st(`This file doesn't have a sheet named "${o}".`);
|
|
1154
|
+
const u = n.sheet_to_json(s, { header: 1, raw: !0, defval: null });
|
|
956
1155
|
return {
|
|
957
|
-
sheetName:
|
|
958
|
-
matrix:
|
|
959
|
-
rowCount:
|
|
960
|
-
colCount: Math.max(0, ...
|
|
1156
|
+
sheetName: o,
|
|
1157
|
+
matrix: u,
|
|
1158
|
+
rowCount: u.length,
|
|
1159
|
+
colCount: Math.max(0, ...u.map((a) => a.length))
|
|
961
1160
|
};
|
|
962
1161
|
}
|
|
963
|
-
function
|
|
964
|
-
let
|
|
965
|
-
for (;
|
|
966
|
-
const
|
|
967
|
-
|
|
1162
|
+
function Ln(e) {
|
|
1163
|
+
let r = e + 1, t = "";
|
|
1164
|
+
for (; r > 0; ) {
|
|
1165
|
+
const n = (r - 1) % 26;
|
|
1166
|
+
t = String.fromCharCode(65 + n) + t, r = Math.floor((r - 1) / 26);
|
|
968
1167
|
}
|
|
969
|
-
return
|
|
1168
|
+
return t;
|
|
970
1169
|
}
|
|
971
|
-
class
|
|
972
|
-
constructor(
|
|
973
|
-
super(
|
|
974
|
-
|
|
975
|
-
this.code =
|
|
1170
|
+
class ce extends Error {
|
|
1171
|
+
constructor(t, n) {
|
|
1172
|
+
super(n ?? t);
|
|
1173
|
+
gt(this, "code");
|
|
1174
|
+
this.code = t, this.name = "FormulaError";
|
|
976
1175
|
}
|
|
977
1176
|
}
|
|
978
|
-
const
|
|
1177
|
+
const Mn = [
|
|
979
1178
|
// Logical
|
|
980
1179
|
// IF is excluded here even though its native body is real, non-stub code —
|
|
981
1180
|
// see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
|
|
@@ -1001,7 +1200,7 @@ const $t = [
|
|
|
1001
1200
|
// DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
|
|
1002
1201
|
"DATE",
|
|
1003
1202
|
"TODAY"
|
|
1004
|
-
],
|
|
1203
|
+
], zn = [
|
|
1005
1204
|
"MAX",
|
|
1006
1205
|
"MIN",
|
|
1007
1206
|
"MAXA",
|
|
@@ -1020,7 +1219,7 @@ const $t = [
|
|
|
1020
1219
|
"COUNTA",
|
|
1021
1220
|
// not present in fast-formula-parser's function table at all.
|
|
1022
1221
|
"UPPER"
|
|
1023
|
-
],
|
|
1222
|
+
], Fn = ["YEAR", "MONTH", "DAY", "WEEKDAY"], Un = ["IF"], $n = [
|
|
1024
1223
|
"CONCATENATE",
|
|
1025
1224
|
"CONCAT",
|
|
1026
1225
|
"LEN",
|
|
@@ -1031,115 +1230,115 @@ const $t = [
|
|
|
1031
1230
|
"MID",
|
|
1032
1231
|
"FIND",
|
|
1033
1232
|
"SEARCH"
|
|
1034
|
-
],
|
|
1035
|
-
|
|
1036
|
-
...
|
|
1037
|
-
...
|
|
1038
|
-
|
|
1039
|
-
...
|
|
1040
|
-
]),
|
|
1041
|
-
function
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
let
|
|
1045
|
-
for (; (
|
|
1046
|
-
const
|
|
1047
|
-
if (!
|
|
1048
|
-
throw new
|
|
1233
|
+
], Pn = /* @__PURE__ */ new Set([
|
|
1234
|
+
...Mn,
|
|
1235
|
+
...zn,
|
|
1236
|
+
...Fn,
|
|
1237
|
+
...$n,
|
|
1238
|
+
...Un
|
|
1239
|
+
]), _n = /"(?:[^"]|"")*"/g, Et = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
|
|
1240
|
+
function jn(e) {
|
|
1241
|
+
const r = e.replace(_n, (n) => " ".repeat(n.length));
|
|
1242
|
+
Et.lastIndex = 0;
|
|
1243
|
+
let t;
|
|
1244
|
+
for (; (t = Et.exec(r)) !== null; ) {
|
|
1245
|
+
const n = t[1].toUpperCase();
|
|
1246
|
+
if (!Pn.has(n))
|
|
1247
|
+
throw new ce("NAME", `Function ${n} is not allowed.`);
|
|
1049
1248
|
}
|
|
1050
1249
|
}
|
|
1051
|
-
function
|
|
1052
|
-
let
|
|
1053
|
-
if (
|
|
1054
|
-
if (typeof
|
|
1055
|
-
if (typeof
|
|
1056
|
-
if (typeof
|
|
1057
|
-
throw
|
|
1250
|
+
function Vn(e, r, t) {
|
|
1251
|
+
let n = e;
|
|
1252
|
+
if (n == null) throw t.NA;
|
|
1253
|
+
if (typeof n == "object" && !(n instanceof t) && (n = r.retrieveRef(n)), n instanceof t) throw n;
|
|
1254
|
+
if (typeof n == "boolean") return n;
|
|
1255
|
+
if (typeof n == "number") return n !== 0;
|
|
1256
|
+
throw t.VALUE;
|
|
1058
1257
|
}
|
|
1059
|
-
function
|
|
1258
|
+
function qt(e) {
|
|
1060
1259
|
return e !== null && typeof e == "object" && "value" in e ? e.value : e;
|
|
1061
1260
|
}
|
|
1062
|
-
function
|
|
1063
|
-
const
|
|
1064
|
-
return Array.isArray(
|
|
1261
|
+
function Le(e) {
|
|
1262
|
+
const r = qt(e);
|
|
1263
|
+
return Array.isArray(r) ? r.flat(1 / 0) : [r];
|
|
1065
1264
|
}
|
|
1066
|
-
function
|
|
1067
|
-
const
|
|
1068
|
-
return Array.isArray(
|
|
1265
|
+
function W(e) {
|
|
1266
|
+
const r = qt(e);
|
|
1267
|
+
return Array.isArray(r) ? r.flat(1 / 0)[0] : r;
|
|
1069
1268
|
}
|
|
1070
|
-
function
|
|
1071
|
-
return e === void 0 ? void 0 :
|
|
1269
|
+
function Ze(e) {
|
|
1270
|
+
return e === void 0 ? void 0 : W(e);
|
|
1072
1271
|
}
|
|
1073
|
-
function
|
|
1272
|
+
function ae(e) {
|
|
1074
1273
|
return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1075
1274
|
}
|
|
1076
|
-
function
|
|
1077
|
-
return e instanceof
|
|
1275
|
+
function Hn(e, r) {
|
|
1276
|
+
return e instanceof r ? e : new r(e.message || "#ERROR!");
|
|
1078
1277
|
}
|
|
1079
|
-
function
|
|
1080
|
-
return e.find((
|
|
1278
|
+
function oe(e) {
|
|
1279
|
+
return e.find((r) => r instanceof Error);
|
|
1081
1280
|
}
|
|
1082
|
-
function
|
|
1083
|
-
const
|
|
1084
|
-
throw
|
|
1085
|
-
},
|
|
1086
|
-
const
|
|
1087
|
-
if (
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1281
|
+
function Wn(e, r) {
|
|
1282
|
+
const t = (o) => {
|
|
1283
|
+
throw Hn(o, r);
|
|
1284
|
+
}, n = (o, { checkArgsForErrors: s = !0 } = {}) => (...u) => {
|
|
1285
|
+
const a = u.flatMap(Le);
|
|
1286
|
+
if (s) {
|
|
1287
|
+
const d = oe(a);
|
|
1288
|
+
d && t(d);
|
|
1090
1289
|
}
|
|
1091
|
-
const
|
|
1092
|
-
return
|
|
1093
|
-
},
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
const
|
|
1097
|
-
return
|
|
1290
|
+
const c = o(...a);
|
|
1291
|
+
return c instanceof Error ? t(c) : c;
|
|
1292
|
+
}, l = (o, { toText: s = !1 } = {}) => (u) => {
|
|
1293
|
+
const a = W(u), c = oe([a]);
|
|
1294
|
+
c && t(c);
|
|
1295
|
+
const d = o(s ? ae(a) : a);
|
|
1296
|
+
return d instanceof Error ? t(d) : d;
|
|
1098
1297
|
};
|
|
1099
1298
|
return {
|
|
1100
1299
|
// valueIfTrue/valueIfFalse are passed through unretrieved (not
|
|
1101
1300
|
// dereferenced or type-checked here) — that's what makes
|
|
1102
1301
|
// `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
|
|
1103
|
-
IF: (
|
|
1104
|
-
const
|
|
1105
|
-
if (
|
|
1106
|
-
return
|
|
1302
|
+
IF: (o, s, u, a) => {
|
|
1303
|
+
const c = Vn(s, o, r);
|
|
1304
|
+
if (u == null) throw r.NA;
|
|
1305
|
+
return c ? u : a ?? !1;
|
|
1107
1306
|
},
|
|
1108
1307
|
// Empty input -> 0, matching both the hand-rolled engine this replaces
|
|
1109
1308
|
// and formulajs's own convention for MAX/MIN.
|
|
1110
|
-
MAX:
|
|
1111
|
-
MIN:
|
|
1112
|
-
MAXA:
|
|
1113
|
-
MINA:
|
|
1114
|
-
MEDIAN:
|
|
1309
|
+
MAX: n(e.MAX),
|
|
1310
|
+
MIN: n(e.MIN),
|
|
1311
|
+
MAXA: n(e.MAXA),
|
|
1312
|
+
MINA: n(e.MINA),
|
|
1313
|
+
MEDIAN: n(e.MEDIAN),
|
|
1115
1314
|
// COUNTA counts non-blank entries; an error value among the args is
|
|
1116
1315
|
// itself non-blank and gets counted (matching formulajs's own COUNTA,
|
|
1117
1316
|
// which never checks for errors), so this skips the error propagation
|
|
1118
1317
|
// the other aggregates use.
|
|
1119
|
-
COUNTA:
|
|
1120
|
-
LARGE: (
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
const
|
|
1124
|
-
return
|
|
1318
|
+
COUNTA: n(e.COUNTA, { checkArgsForErrors: !1 }),
|
|
1319
|
+
LARGE: (o, s) => {
|
|
1320
|
+
const u = Le(o), a = W(s), c = oe([...u, a]);
|
|
1321
|
+
c && t(c);
|
|
1322
|
+
const d = e.LARGE(u, a);
|
|
1323
|
+
return d instanceof Error ? t(d) : d;
|
|
1125
1324
|
},
|
|
1126
|
-
SMALL: (
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
const
|
|
1130
|
-
return
|
|
1325
|
+
SMALL: (o, s) => {
|
|
1326
|
+
const u = Le(o), a = W(s), c = oe([...u, a]);
|
|
1327
|
+
c && t(c);
|
|
1328
|
+
const d = e.SMALL(u, a);
|
|
1329
|
+
return d instanceof Error ? t(d) : d;
|
|
1131
1330
|
},
|
|
1132
|
-
PERMUT: (
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1331
|
+
PERMUT: (o, s) => {
|
|
1332
|
+
const u = [W(o), W(s)], a = oe(u);
|
|
1333
|
+
a && t(a);
|
|
1334
|
+
const c = e.PERMUT(u[0], u[1]);
|
|
1335
|
+
return c instanceof Error ? t(c) : c;
|
|
1137
1336
|
},
|
|
1138
|
-
PERMUTATIONA: (
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
const
|
|
1142
|
-
return
|
|
1337
|
+
PERMUTATIONA: (o, s) => {
|
|
1338
|
+
const u = [W(o), W(s)], a = oe(u);
|
|
1339
|
+
a && t(a);
|
|
1340
|
+
const c = e.PERMUTATIONA(u[0], u[1]);
|
|
1341
|
+
return c instanceof Error ? t(c) : c;
|
|
1143
1342
|
},
|
|
1144
1343
|
// match_type is intentionally ignored and forced to 0 (exact match)
|
|
1145
1344
|
// regardless of what the formula author supplied — approximate/sorted
|
|
@@ -1147,43 +1346,43 @@ function Yt(e, t) {
|
|
|
1147
1346
|
// Excel's own default too) risks silently mis-ranking unsorted
|
|
1148
1347
|
// real-world data. Same scope decision as the hand-rolled engine this
|
|
1149
1348
|
// replaces, carried forward deliberately rather than dropped.
|
|
1150
|
-
MATCH: (
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
const
|
|
1154
|
-
return
|
|
1349
|
+
MATCH: (o, s) => {
|
|
1350
|
+
const u = W(o), a = Le(s), c = oe([u, ...a]);
|
|
1351
|
+
c && t(c);
|
|
1352
|
+
const d = e.MATCH(u, a, 0);
|
|
1353
|
+
return d instanceof Error ? t(d) : d;
|
|
1155
1354
|
},
|
|
1156
|
-
SWITCH: (...
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1159
|
-
const
|
|
1160
|
-
return
|
|
1355
|
+
SWITCH: (...o) => {
|
|
1356
|
+
const s = o.map(W), u = oe(s);
|
|
1357
|
+
u && t(u);
|
|
1358
|
+
const a = e.SWITCH(...s);
|
|
1359
|
+
return a instanceof Error ? t(a) : a;
|
|
1161
1360
|
},
|
|
1162
|
-
SUBSTITUTE: (
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
const
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
return
|
|
1361
|
+
SUBSTITUTE: (o, s, u, a) => {
|
|
1362
|
+
const c = [ae(W(o)), ae(W(s)), ae(W(u))];
|
|
1363
|
+
a !== void 0 && c.push(W(a));
|
|
1364
|
+
const d = oe(c);
|
|
1365
|
+
d && t(d);
|
|
1366
|
+
const f = e.SUBSTITUTE(...c);
|
|
1367
|
+
return f instanceof Error ? t(f) : f;
|
|
1169
1368
|
},
|
|
1170
|
-
TEXTJOIN: (
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
const
|
|
1174
|
-
return
|
|
1369
|
+
TEXTJOIN: (o, s, ...u) => {
|
|
1370
|
+
const a = ae(W(o)), c = W(s), d = u.flatMap(Le).map(ae), f = oe([a, c]);
|
|
1371
|
+
f && t(f);
|
|
1372
|
+
const p = e.TEXTJOIN(a, c, d);
|
|
1373
|
+
return p instanceof Error ? t(p) : p;
|
|
1175
1374
|
},
|
|
1176
|
-
UPPER:
|
|
1375
|
+
UPPER: l(e.UPPER),
|
|
1177
1376
|
// See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
|
|
1178
1377
|
// fast-formula-parser's own (real, but broken-for-Date-cells) versions.
|
|
1179
|
-
YEAR:
|
|
1180
|
-
MONTH:
|
|
1181
|
-
DAY:
|
|
1182
|
-
WEEKDAY: (
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
const
|
|
1186
|
-
return
|
|
1378
|
+
YEAR: l(e.YEAR),
|
|
1379
|
+
MONTH: l(e.MONTH),
|
|
1380
|
+
DAY: l(e.DAY),
|
|
1381
|
+
WEEKDAY: (o, s) => {
|
|
1382
|
+
const u = W(o), a = W(s), c = oe([u]);
|
|
1383
|
+
c && t(c);
|
|
1384
|
+
const d = e.WEEKDAY(u, a);
|
|
1385
|
+
return d instanceof Error ? t(d) : d;
|
|
1187
1386
|
},
|
|
1188
1387
|
// See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
|
|
1189
1388
|
// formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
|
|
@@ -1194,54 +1393,54 @@ function Yt(e, t) {
|
|
|
1194
1393
|
// Flattens every argument (a whole range included) and joins with no
|
|
1195
1394
|
// separator, matching Excel's own range-argument behavior — the native
|
|
1196
1395
|
// implementation instead inserts stray commas for a whole-range argument.
|
|
1197
|
-
CONCATENATE: (...
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
const
|
|
1201
|
-
return
|
|
1396
|
+
CONCATENATE: (...o) => {
|
|
1397
|
+
const s = o.flatMap(Le), u = oe(s);
|
|
1398
|
+
u && t(u);
|
|
1399
|
+
const a = e.CONCATENATE(...s.map(ae));
|
|
1400
|
+
return a instanceof Error ? t(a) : a;
|
|
1202
1401
|
},
|
|
1203
|
-
CONCAT: (...
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1206
|
-
const
|
|
1207
|
-
return
|
|
1402
|
+
CONCAT: (...o) => {
|
|
1403
|
+
const s = o.flatMap(Le), u = oe(s);
|
|
1404
|
+
u && t(u);
|
|
1405
|
+
const a = e.CONCAT(...s.map(ae));
|
|
1406
|
+
return a instanceof Error ? t(a) : a;
|
|
1208
1407
|
},
|
|
1209
|
-
LEN:
|
|
1210
|
-
TRIM:
|
|
1211
|
-
LOWER:
|
|
1212
|
-
LEFT: (
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
const
|
|
1216
|
-
return
|
|
1408
|
+
LEN: l(e.LEN, { toText: !0 }),
|
|
1409
|
+
TRIM: l(e.TRIM, { toText: !0 }),
|
|
1410
|
+
LOWER: l(e.LOWER, { toText: !0 }),
|
|
1411
|
+
LEFT: (o, s) => {
|
|
1412
|
+
const u = W(o), a = Ze(s), c = oe([u]);
|
|
1413
|
+
c && t(c);
|
|
1414
|
+
const d = e.LEFT(ae(u), a);
|
|
1415
|
+
return d instanceof Error ? t(d) : d;
|
|
1217
1416
|
},
|
|
1218
|
-
RIGHT: (
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
const
|
|
1222
|
-
return
|
|
1417
|
+
RIGHT: (o, s) => {
|
|
1418
|
+
const u = W(o), a = Ze(s), c = oe([u]);
|
|
1419
|
+
c && t(c);
|
|
1420
|
+
const d = e.RIGHT(ae(u), a);
|
|
1421
|
+
return d instanceof Error ? t(d) : d;
|
|
1223
1422
|
},
|
|
1224
|
-
MID: (
|
|
1225
|
-
const
|
|
1226
|
-
|
|
1227
|
-
const
|
|
1228
|
-
return
|
|
1423
|
+
MID: (o, s, u) => {
|
|
1424
|
+
const a = W(o), c = W(s), d = W(u), f = oe([a, c, d]);
|
|
1425
|
+
f && t(f);
|
|
1426
|
+
const p = e.MID(ae(a), c, d);
|
|
1427
|
+
return p instanceof Error ? t(p) : p;
|
|
1229
1428
|
},
|
|
1230
|
-
FIND: (
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1429
|
+
FIND: (o, s, u) => {
|
|
1430
|
+
const a = W(o), c = W(s), d = Ze(u), f = oe([a, c]);
|
|
1431
|
+
f && t(f);
|
|
1432
|
+
const p = e.FIND(ae(a), ae(c), d);
|
|
1433
|
+
return p instanceof Error ? t(p) : p;
|
|
1235
1434
|
},
|
|
1236
|
-
SEARCH: (
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1240
|
-
return
|
|
1435
|
+
SEARCH: (o, s, u) => {
|
|
1436
|
+
const a = W(o), c = W(s), d = Ze(u), f = oe([a, c]);
|
|
1437
|
+
f && t(f);
|
|
1438
|
+
const p = e.SEARCH(ae(a), ae(c), d);
|
|
1439
|
+
return p instanceof Error ? t(p) : p;
|
|
1241
1440
|
}
|
|
1242
1441
|
};
|
|
1243
1442
|
}
|
|
1244
|
-
const
|
|
1443
|
+
const Bn = {
|
|
1245
1444
|
"#REF!": "REF",
|
|
1246
1445
|
"#VALUE!": "VALUE",
|
|
1247
1446
|
"#DIV/0!": "DIV0",
|
|
@@ -1250,100 +1449,100 @@ const Jt = {
|
|
|
1250
1449
|
"#NUM!": "NUM",
|
|
1251
1450
|
"#NULL!": "NULL"
|
|
1252
1451
|
};
|
|
1253
|
-
function
|
|
1254
|
-
return
|
|
1255
|
-
}
|
|
1256
|
-
function
|
|
1257
|
-
if (e instanceof
|
|
1258
|
-
if (e instanceof
|
|
1259
|
-
const
|
|
1260
|
-
return
|
|
1452
|
+
function Tt(e) {
|
|
1453
|
+
return Bn[e.error] ?? "ERROR";
|
|
1454
|
+
}
|
|
1455
|
+
function xt(e, r) {
|
|
1456
|
+
if (e instanceof ce) return e;
|
|
1457
|
+
if (e instanceof r) {
|
|
1458
|
+
const t = e.details;
|
|
1459
|
+
return t instanceof ce ? t : t instanceof r ? new ce(Tt(t), t.message) : new ce(Tt(e), e.message);
|
|
1261
1460
|
}
|
|
1262
|
-
return new
|
|
1461
|
+
return new ce("ERROR", e instanceof Error ? e.message : void 0);
|
|
1263
1462
|
}
|
|
1264
|
-
function
|
|
1265
|
-
return Math.max(0, ...e.map((
|
|
1463
|
+
function Xn(e) {
|
|
1464
|
+
return Math.max(0, ...e.map((r) => (r == null ? void 0 : r.length) ?? 0));
|
|
1266
1465
|
}
|
|
1267
|
-
function
|
|
1268
|
-
return (
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
throw new
|
|
1272
|
-
const
|
|
1273
|
-
return
|
|
1466
|
+
function Yn(e) {
|
|
1467
|
+
return (r) => {
|
|
1468
|
+
const t = e[r.row - 1];
|
|
1469
|
+
if (r.row < 1 || r.col < 1 || t == null || r.col - 1 >= t.length)
|
|
1470
|
+
throw new ce("REF");
|
|
1471
|
+
const n = t[r.col - 1];
|
|
1472
|
+
return n == null || n === "" ? null : n;
|
|
1274
1473
|
};
|
|
1275
1474
|
}
|
|
1276
|
-
function
|
|
1277
|
-
return (
|
|
1278
|
-
const
|
|
1279
|
-
if (
|
|
1280
|
-
throw new
|
|
1281
|
-
const
|
|
1282
|
-
for (let
|
|
1283
|
-
const
|
|
1284
|
-
if (
|
|
1285
|
-
const
|
|
1286
|
-
for (let
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1475
|
+
function Kn(e) {
|
|
1476
|
+
return (r) => {
|
|
1477
|
+
const t = Math.min(r.from.row, r.to.row), n = Math.min(r.from.col, r.to.col), l = Math.max(r.from.row, r.to.row), o = Math.max(r.from.col, r.to.col), s = Xn(e);
|
|
1478
|
+
if (t > e.length || n > s)
|
|
1479
|
+
throw new ce("REF");
|
|
1480
|
+
const u = Math.min(l, e.length), a = [];
|
|
1481
|
+
for (let c = t; c <= u; c++) {
|
|
1482
|
+
const d = e[c - 1], f = [];
|
|
1483
|
+
if (d != null) {
|
|
1484
|
+
const p = Math.min(o, d.length);
|
|
1485
|
+
for (let g = n; g <= p; g++) {
|
|
1486
|
+
const b = d[g - 1];
|
|
1487
|
+
f.push(b == null || b === "" ? null : b);
|
|
1289
1488
|
}
|
|
1290
1489
|
}
|
|
1291
|
-
|
|
1490
|
+
a.push(f);
|
|
1292
1491
|
}
|
|
1293
|
-
return
|
|
1492
|
+
return a;
|
|
1294
1493
|
};
|
|
1295
1494
|
}
|
|
1296
|
-
function
|
|
1495
|
+
function Gn(e) {
|
|
1297
1496
|
if (e == null || e === "") return null;
|
|
1298
1497
|
if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
|
|
1299
1498
|
return e;
|
|
1300
|
-
throw new
|
|
1301
|
-
}
|
|
1302
|
-
async function
|
|
1303
|
-
if (typeof e != "string") throw new
|
|
1304
|
-
const
|
|
1305
|
-
if (
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
const [
|
|
1499
|
+
throw new ce("VALUE");
|
|
1500
|
+
}
|
|
1501
|
+
async function Jt(e, r) {
|
|
1502
|
+
if (typeof e != "string") throw new ce("ERROR");
|
|
1503
|
+
const t = e.trim();
|
|
1504
|
+
if (t === "") throw new ce("ERROR");
|
|
1505
|
+
const n = t.startsWith("=") ? t.slice(1) : t;
|
|
1506
|
+
jn(n);
|
|
1507
|
+
const [l, o] = await Promise.all([
|
|
1309
1508
|
import("fast-formula-parser"),
|
|
1310
1509
|
import("@formulajs/formulajs")
|
|
1311
|
-
]),
|
|
1312
|
-
...
|
|
1510
|
+
]), s = l.default ?? l, u = s.FormulaError, a = new s({
|
|
1511
|
+
...r,
|
|
1313
1512
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- formulajs's own types are all `any`-typed; formulaFunctions.ts narrows the surface it actually calls.
|
|
1314
|
-
functions:
|
|
1513
|
+
functions: Wn(o, u)
|
|
1315
1514
|
});
|
|
1316
|
-
let
|
|
1515
|
+
let c;
|
|
1317
1516
|
try {
|
|
1318
|
-
|
|
1319
|
-
} catch (
|
|
1320
|
-
throw
|
|
1517
|
+
c = a.parse(n, { row: 1, col: 1, sheet: "Sheet1" });
|
|
1518
|
+
} catch (d) {
|
|
1519
|
+
throw xt(d, u);
|
|
1321
1520
|
}
|
|
1322
|
-
if (
|
|
1323
|
-
throw
|
|
1324
|
-
return
|
|
1325
|
-
}
|
|
1326
|
-
async function
|
|
1327
|
-
return
|
|
1328
|
-
}
|
|
1329
|
-
const
|
|
1330
|
-
async function
|
|
1331
|
-
const
|
|
1332
|
-
return
|
|
1333
|
-
onVariable: (
|
|
1334
|
-
const
|
|
1335
|
-
return
|
|
1521
|
+
if (c instanceof u)
|
|
1522
|
+
throw xt(c, u);
|
|
1523
|
+
return Gn(c);
|
|
1524
|
+
}
|
|
1525
|
+
async function qn(e, r) {
|
|
1526
|
+
return Jt(r, { onCell: Yn(e), onRange: Kn(e) });
|
|
1527
|
+
}
|
|
1528
|
+
const At = -1;
|
|
1529
|
+
async function Zt(e, r) {
|
|
1530
|
+
const t = Object.keys(e);
|
|
1531
|
+
return Jt(r, {
|
|
1532
|
+
onVariable: (n) => {
|
|
1533
|
+
const l = t.indexOf(n);
|
|
1534
|
+
return l === -1 ? null : { row: At, col: l + 1 };
|
|
1336
1535
|
},
|
|
1337
|
-
onCell: (
|
|
1338
|
-
if (
|
|
1339
|
-
throw new
|
|
1536
|
+
onCell: (n) => {
|
|
1537
|
+
if (n.row === At) return e[t[n.col - 1]] ?? null;
|
|
1538
|
+
throw new ce("REF");
|
|
1340
1539
|
},
|
|
1341
1540
|
onRange: () => {
|
|
1342
|
-
throw new
|
|
1541
|
+
throw new ce("REF");
|
|
1343
1542
|
}
|
|
1344
1543
|
});
|
|
1345
1544
|
}
|
|
1346
|
-
const
|
|
1545
|
+
const Qt = {
|
|
1347
1546
|
REF: "#REF!",
|
|
1348
1547
|
VALUE: "#VALUE!",
|
|
1349
1548
|
DIV0: "#DIV/0!",
|
|
@@ -1353,195 +1552,195 @@ const Ir = {
|
|
|
1353
1552
|
NUM: "#NUM!",
|
|
1354
1553
|
NULL: "#NULL!"
|
|
1355
1554
|
};
|
|
1356
|
-
function
|
|
1357
|
-
const
|
|
1358
|
-
return
|
|
1359
|
-
}
|
|
1360
|
-
async function
|
|
1361
|
-
return e.length === 0 ?
|
|
1362
|
-
id: typeof (
|
|
1363
|
-
label: (
|
|
1555
|
+
function pt(e) {
|
|
1556
|
+
const r = e instanceof ce ? e.code : "ERROR";
|
|
1557
|
+
return Qt[r];
|
|
1558
|
+
}
|
|
1559
|
+
async function Jn(e, r) {
|
|
1560
|
+
return e.length === 0 ? r.map((t) => ({
|
|
1561
|
+
id: typeof (t == null ? void 0 : t.id) == "string" ? t.id : "(unknown)",
|
|
1562
|
+
label: (t == null ? void 0 : t.label) ?? "(unknown)",
|
|
1364
1563
|
value: null,
|
|
1365
|
-
error:
|
|
1564
|
+
error: Qt.ERROR
|
|
1366
1565
|
})) : Promise.all(
|
|
1367
|
-
|
|
1566
|
+
r.map(async (t) => {
|
|
1368
1567
|
try {
|
|
1369
|
-
if (!
|
|
1370
|
-
throw new
|
|
1371
|
-
return { id:
|
|
1372
|
-
} catch (
|
|
1568
|
+
if (!t || typeof t.label != "string" || typeof t.expression != "string" || typeof t.id != "string")
|
|
1569
|
+
throw new ce("ERROR");
|
|
1570
|
+
return { id: t.id, label: t.label, value: await qn(e, t.expression) };
|
|
1571
|
+
} catch (n) {
|
|
1373
1572
|
return {
|
|
1374
|
-
id: typeof (
|
|
1375
|
-
label: (
|
|
1573
|
+
id: typeof (t == null ? void 0 : t.id) == "string" ? t.id : "(unknown)",
|
|
1574
|
+
label: (t == null ? void 0 : t.label) ?? "(unknown)",
|
|
1376
1575
|
value: null,
|
|
1377
|
-
error:
|
|
1576
|
+
error: pt(n)
|
|
1378
1577
|
};
|
|
1379
1578
|
}
|
|
1380
1579
|
})
|
|
1381
1580
|
);
|
|
1382
1581
|
}
|
|
1383
|
-
function
|
|
1384
|
-
const
|
|
1385
|
-
for (const { id:
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1582
|
+
function Rt(e) {
|
|
1583
|
+
const r = /* @__PURE__ */ new Set();
|
|
1584
|
+
for (const { id: t } of e) {
|
|
1585
|
+
if (r.has(t)) return t;
|
|
1586
|
+
r.add(t);
|
|
1388
1587
|
}
|
|
1389
1588
|
return null;
|
|
1390
1589
|
}
|
|
1391
|
-
function
|
|
1392
|
-
const { columnHeader:
|
|
1393
|
-
if (
|
|
1590
|
+
function er(e) {
|
|
1591
|
+
const { columnHeader: r, rowHeader: t, columns: n, rows: l } = e;
|
|
1592
|
+
if (n !== void 0 && !Array.isArray(n))
|
|
1394
1593
|
return "columns must be an array of { id, label } objects.";
|
|
1395
|
-
if (
|
|
1594
|
+
if (l !== void 0 && !Array.isArray(l))
|
|
1396
1595
|
return "rows must be an array of { id, label } objects.";
|
|
1397
|
-
if (
|
|
1596
|
+
if (n !== void 0 && n.length === 0)
|
|
1398
1597
|
return "columns is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
|
|
1399
|
-
if (
|
|
1598
|
+
if (l !== void 0 && l.length === 0)
|
|
1400
1599
|
return "rows is declared but empty — declare at least one field, or omit it entirely for raw matrix mode.";
|
|
1401
|
-
const
|
|
1402
|
-
if (
|
|
1403
|
-
return `columns[${
|
|
1404
|
-
const
|
|
1405
|
-
if (
|
|
1406
|
-
return `rows[${
|
|
1407
|
-
const
|
|
1408
|
-
if (
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1600
|
+
const o = (d) => !!d && typeof d.id == "string" && d.id !== "" && typeof d.label == "string" && d.label !== "", s = n == null ? void 0 : n.findIndex((d) => !o(d));
|
|
1601
|
+
if (s != null && s !== -1)
|
|
1602
|
+
return `columns[${s}] must be a { id, label } object with non-empty string fields.`;
|
|
1603
|
+
const u = l == null ? void 0 : l.findIndex((d) => !o(d));
|
|
1604
|
+
if (u != null && u !== -1)
|
|
1605
|
+
return `rows[${u}] must be a { id, label } object with non-empty string fields.`;
|
|
1606
|
+
const a = !!n && n.length > 0, c = !!l && l.length > 0;
|
|
1607
|
+
if (a) {
|
|
1608
|
+
const d = Rt(n);
|
|
1609
|
+
if (d) return `duplicate column id "${d}" — every declared column id must be unique.`;
|
|
1411
1610
|
}
|
|
1412
|
-
if (
|
|
1413
|
-
const
|
|
1414
|
-
if (
|
|
1611
|
+
if (c) {
|
|
1612
|
+
const d = Rt(l);
|
|
1613
|
+
if (d) return `duplicate row id "${d}" — every declared row id must be unique.`;
|
|
1415
1614
|
}
|
|
1416
|
-
return
|
|
1417
|
-
}
|
|
1418
|
-
function
|
|
1419
|
-
const
|
|
1420
|
-
if (
|
|
1421
|
-
const { columnHeader:
|
|
1422
|
-
return
|
|
1423
|
-
}
|
|
1424
|
-
function
|
|
1425
|
-
return (
|
|
1426
|
-
const
|
|
1427
|
-
return
|
|
1428
|
-
|
|
1429
|
-
}),
|
|
1615
|
+
return r && t ? "columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape." : a && c ? "columns and rows cannot both be declared — pick one orientation for the persisted sheet shape." : r && !a ? "columnHeader is true but columns is missing or empty — declare the column list columnHeader positions map to." : t && !c ? "rowHeader is true but rows is missing or empty — declare the row list rowHeader positions map to." : null;
|
|
1616
|
+
}
|
|
1617
|
+
function Ct(e, r = {}) {
|
|
1618
|
+
const t = er(r);
|
|
1619
|
+
if (t) throw new Error(`x-spreadsheet: ${t}`);
|
|
1620
|
+
const { columnHeader: n, rowHeader: l, columns: o, rows: s } = r;
|
|
1621
|
+
return o && o.length > 0 ? Zn(e, o, n === !0) : s && s.length > 0 ? Qn(e, s, l === !0) : e;
|
|
1622
|
+
}
|
|
1623
|
+
function Zn(e, r, t) {
|
|
1624
|
+
return (t ? e.slice(1) : e).map((l) => {
|
|
1625
|
+
const o = /* @__PURE__ */ Object.create(null);
|
|
1626
|
+
return r.forEach((s, u) => {
|
|
1627
|
+
o[s.id] = l[u] ?? null;
|
|
1628
|
+
}), o;
|
|
1430
1629
|
});
|
|
1431
1630
|
}
|
|
1432
|
-
function
|
|
1433
|
-
const
|
|
1434
|
-
return Array.from({ length:
|
|
1435
|
-
const
|
|
1436
|
-
return
|
|
1437
|
-
var
|
|
1438
|
-
d
|
|
1439
|
-
}),
|
|
1631
|
+
function Qn(e, r, t) {
|
|
1632
|
+
const n = t ? 1 : 0, l = Math.max(0, ...e.map((s) => s.length)), o = Math.max(0, l - n);
|
|
1633
|
+
return Array.from({ length: o }, (s, u) => {
|
|
1634
|
+
const a = n + u, c = /* @__PURE__ */ Object.create(null);
|
|
1635
|
+
return r.forEach((d, f) => {
|
|
1636
|
+
var p;
|
|
1637
|
+
c[d.id] = ((p = e[f]) == null ? void 0 : p[a]) ?? null;
|
|
1638
|
+
}), c;
|
|
1440
1639
|
});
|
|
1441
1640
|
}
|
|
1442
|
-
function
|
|
1641
|
+
function tr(e) {
|
|
1443
1642
|
return !Array.isArray(e[0]);
|
|
1444
1643
|
}
|
|
1445
|
-
function
|
|
1446
|
-
const
|
|
1447
|
-
for (const { id:
|
|
1448
|
-
t
|
|
1449
|
-
return
|
|
1644
|
+
function eo(e) {
|
|
1645
|
+
const r = /* @__PURE__ */ Object.create(null);
|
|
1646
|
+
for (const { id: t, label: n, value: l, error: o } of e)
|
|
1647
|
+
r[t] = o === void 0 ? { label: n, value: l } : { label: n, value: l, error: o };
|
|
1648
|
+
return r;
|
|
1450
1649
|
}
|
|
1451
|
-
function
|
|
1452
|
-
const
|
|
1453
|
-
return
|
|
1650
|
+
function lt(e, r) {
|
|
1651
|
+
const t = (n) => n instanceof Date ? n.toISOString() : n ?? null;
|
|
1652
|
+
return t(e) === t(r);
|
|
1454
1653
|
}
|
|
1455
|
-
function
|
|
1456
|
-
const
|
|
1457
|
-
return
|
|
1458
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
1459
|
-
const
|
|
1460
|
-
return
|
|
1654
|
+
function to(e, r) {
|
|
1655
|
+
const t = e ?? {}, n = r ?? {}, l = Object.keys(t);
|
|
1656
|
+
return l.length !== Object.keys(n).length ? !1 : l.every((o) => {
|
|
1657
|
+
if (!Object.prototype.hasOwnProperty.call(n, o)) return !1;
|
|
1658
|
+
const s = t[o], u = n[o];
|
|
1659
|
+
return s.label === u.label && s.error === u.error && lt(s.value, u.value);
|
|
1461
1660
|
});
|
|
1462
1661
|
}
|
|
1463
|
-
function
|
|
1464
|
-
if (e == null ||
|
|
1465
|
-
const
|
|
1466
|
-
if (
|
|
1467
|
-
if (
|
|
1468
|
-
const
|
|
1469
|
-
return
|
|
1662
|
+
function ro(e, r) {
|
|
1663
|
+
if (e == null || r == null) return e === r;
|
|
1664
|
+
const t = Array.isArray(e);
|
|
1665
|
+
if (t !== Array.isArray(r)) return !1;
|
|
1666
|
+
if (t) {
|
|
1667
|
+
const s = e, u = r;
|
|
1668
|
+
return s.length === u.length && s.every((a, c) => lt(a, u[c]));
|
|
1470
1669
|
}
|
|
1471
|
-
const
|
|
1472
|
-
return
|
|
1670
|
+
const n = e, l = r, o = Object.keys(n);
|
|
1671
|
+
return o.length !== Object.keys(l).length ? !1 : o.every((s) => Object.prototype.hasOwnProperty.call(l, s) && lt(n[s], l[s]));
|
|
1473
1672
|
}
|
|
1474
|
-
function
|
|
1475
|
-
if (e ===
|
|
1476
|
-
if (e == null ||
|
|
1477
|
-
const
|
|
1478
|
-
return
|
|
1673
|
+
function no(e, r) {
|
|
1674
|
+
if (e === r) return !0;
|
|
1675
|
+
if (e == null || r == null) return !1;
|
|
1676
|
+
const t = e, n = r;
|
|
1677
|
+
return t.length !== n.length ? !1 : t.every((l, o) => ro(l, n[o]));
|
|
1479
1678
|
}
|
|
1480
|
-
function
|
|
1679
|
+
function oo(e) {
|
|
1481
1680
|
return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
|
|
1482
1681
|
}
|
|
1483
|
-
function
|
|
1682
|
+
function rr(e, r) {
|
|
1484
1683
|
if (e.length === 0) return [];
|
|
1485
|
-
const
|
|
1486
|
-
for (const
|
|
1487
|
-
|
|
1488
|
-
for (const
|
|
1489
|
-
for (const
|
|
1490
|
-
|
|
1491
|
-
if (
|
|
1492
|
-
const
|
|
1493
|
-
(
|
|
1494
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
1495
|
-
const
|
|
1496
|
-
return
|
|
1684
|
+
const t = [], n = /* @__PURE__ */ new Set();
|
|
1685
|
+
for (const o of r ?? [])
|
|
1686
|
+
n.has(o) || (n.add(o), t.push(o));
|
|
1687
|
+
for (const o of e)
|
|
1688
|
+
for (const s of Object.keys(o))
|
|
1689
|
+
n.has(s) || (n.add(s), t.push(s));
|
|
1690
|
+
if (t.length === 0) return [];
|
|
1691
|
+
const l = e.map(
|
|
1692
|
+
(o) => t.map((s) => {
|
|
1693
|
+
if (!Object.prototype.hasOwnProperty.call(o, s)) return null;
|
|
1694
|
+
const u = o[s];
|
|
1695
|
+
return oo(u) ? u : null;
|
|
1497
1696
|
})
|
|
1498
1697
|
);
|
|
1499
|
-
return [
|
|
1698
|
+
return [t, ...l];
|
|
1500
1699
|
}
|
|
1501
|
-
function
|
|
1502
|
-
const
|
|
1503
|
-
return Array.from({ length:
|
|
1700
|
+
function io(e) {
|
|
1701
|
+
const r = Math.max(0, ...e.map((t) => t.length));
|
|
1702
|
+
return Array.from({ length: r }, (t, n) => e.map((l) => l[n] ?? null));
|
|
1504
1703
|
}
|
|
1505
|
-
const
|
|
1506
|
-
function
|
|
1704
|
+
const so = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", lo = 10 * 1024 * 1024, ot = 200, ao = 50, co = [];
|
|
1705
|
+
function St(e) {
|
|
1507
1706
|
return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1508
1707
|
}
|
|
1509
|
-
const
|
|
1708
|
+
const uo = ({
|
|
1510
1709
|
data: e,
|
|
1511
|
-
handleChange:
|
|
1512
|
-
path:
|
|
1513
|
-
label:
|
|
1514
|
-
required:
|
|
1515
|
-
schema:
|
|
1516
|
-
enabled:
|
|
1517
|
-
readonly:
|
|
1518
|
-
errors:
|
|
1519
|
-
visible:
|
|
1710
|
+
handleChange: r,
|
|
1711
|
+
path: t,
|
|
1712
|
+
label: n,
|
|
1713
|
+
required: l,
|
|
1714
|
+
schema: o,
|
|
1715
|
+
enabled: s,
|
|
1716
|
+
readonly: u,
|
|
1717
|
+
errors: a,
|
|
1718
|
+
visible: c = !0
|
|
1520
1719
|
}) => {
|
|
1521
|
-
|
|
1522
|
-
const
|
|
1523
|
-
() =>
|
|
1524
|
-
), [
|
|
1525
|
-
(
|
|
1526
|
-
if (!
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
|
|
1720
|
+
Re(c, t, r);
|
|
1721
|
+
const d = !a || a.length === 0, f = Gt(s, u), p = (o == null ? void 0 : o["x-spreadsheet"]) ?? {}, g = (o == null ? void 0 : o["x-evaluate"]) ?? co, b = p.accept ?? so, M = p.maxSize ?? lo, N = p.columnHeader === !0, U = p.rowHeader === !0, T = p.columns, R = p.rows, I = Array.isArray(T) && T.length > 0, A = Array.isArray(R) && R.length > 0, D = er({ columnHeader: N, rowHeader: U, columns: T, rows: R }), z = p.showSheet !== !1, V = p.sheetName, v = p.persistSheet !== !1, x = e ?? null, [re, X] = j(
|
|
1722
|
+
() => x != null && x.sheet || Object.keys((x == null ? void 0 : x.derivations) ?? {}).length > 0 ? "ready" : "empty"
|
|
1723
|
+
), [Y, L] = j(null), [O, G] = j(!1), [Q, de] = j(null), [ne, Ne] = j(null), S = ue(null), K = ue(null), fe = (x == null ? void 0 : x.sheet) ?? null, Ee = $e(
|
|
1724
|
+
(C) => {
|
|
1725
|
+
if (!tr(C)) return C;
|
|
1726
|
+
const P = A ? R : I ? T : void 0, se = rr(
|
|
1727
|
+
C,
|
|
1728
|
+
P == null ? void 0 : P.map((H) => H.id)
|
|
1530
1729
|
);
|
|
1531
|
-
return
|
|
1730
|
+
return A ? io(se) : se;
|
|
1532
1731
|
},
|
|
1533
|
-
[
|
|
1534
|
-
),
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
Math.max(0, ...
|
|
1538
|
-
),
|
|
1539
|
-
return /* @__PURE__ */
|
|
1540
|
-
/* @__PURE__ */
|
|
1541
|
-
!
|
|
1542
|
-
/* @__PURE__ */
|
|
1543
|
-
|
|
1544
|
-
var
|
|
1732
|
+
[I, A, T, R]
|
|
1733
|
+
), ee = We(() => Q ?? (fe ? Ee(fe) : null), [Q, fe, Ee]), ge = ((ne == null ? void 0 : ne.matrix) === ee ? ne.derivations : null) ?? (x == null ? void 0 : x.derivations) ?? {}, ie = ee != null || x != null, Te = We(() => {
|
|
1734
|
+
const C = I ? 1 : 0, P = A ? 1 : 0, se = ee ? ee.slice(C) : [], H = se.slice(0, ot), _ = Math.min(
|
|
1735
|
+
ao,
|
|
1736
|
+
Math.max(0, ...H.map((ye) => Math.max(0, ye.length - P)))
|
|
1737
|
+
), De = Array.from({ length: _ }, (ye, E) => E + P), Fe = "", Ke = A && !I;
|
|
1738
|
+
return /* @__PURE__ */ i(ve, { children: ee && z && /* @__PURE__ */ y(k, { mt: "3", children: [
|
|
1739
|
+
/* @__PURE__ */ i(k, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ y(Se.Root, { variant: "surface", size: "1", children: [
|
|
1740
|
+
!Ke && /* @__PURE__ */ i(Se.Header, { children: /* @__PURE__ */ y(Se.Row, { children: [
|
|
1741
|
+
/* @__PURE__ */ i(Se.ColumnHeaderCell, { children: Fe }),
|
|
1742
|
+
De.map((ye) => {
|
|
1743
|
+
var E;
|
|
1545
1744
|
return (
|
|
1546
1745
|
// This row only renders when hasRows isn't the sole
|
|
1547
1746
|
// flag set (see suppressColumnHeaderRow) — so reaching
|
|
@@ -1549,229 +1748,294 @@ const vn = ({
|
|
|
1549
1748
|
// looked up positionally — never read from the matrix
|
|
1550
1749
|
// cell itself, which only ever holds the id) or both
|
|
1551
1750
|
// are false (columnLetter fallback).
|
|
1552
|
-
/* @__PURE__ */
|
|
1751
|
+
/* @__PURE__ */ i(Se.ColumnHeaderCell, { children: I ? ((E = T == null ? void 0 : T[ye]) == null ? void 0 : E.label) ?? "" : Ln(ye) }, ye)
|
|
1553
1752
|
);
|
|
1554
1753
|
})
|
|
1555
1754
|
] }) }),
|
|
1556
|
-
/* @__PURE__ */
|
|
1557
|
-
var
|
|
1558
|
-
const
|
|
1559
|
-
return /* @__PURE__ */
|
|
1560
|
-
/* @__PURE__ */
|
|
1561
|
-
|
|
1755
|
+
/* @__PURE__ */ i(Se.Body, { children: H.map((ye, E) => {
|
|
1756
|
+
var le;
|
|
1757
|
+
const Z = C + E;
|
|
1758
|
+
return /* @__PURE__ */ y(Se.Row, { children: [
|
|
1759
|
+
/* @__PURE__ */ i(
|
|
1760
|
+
Se.RowHeaderCell,
|
|
1562
1761
|
{
|
|
1563
|
-
style:
|
|
1564
|
-
children:
|
|
1762
|
+
style: A ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
|
|
1763
|
+
children: A ? ((le = R == null ? void 0 : R[Z]) == null ? void 0 : le.label) ?? "" : I ? "" : Z + 1
|
|
1565
1764
|
}
|
|
1566
1765
|
),
|
|
1567
|
-
|
|
1568
|
-
] },
|
|
1766
|
+
De.map((be) => /* @__PURE__ */ i(Se.Cell, { children: St(ye[be]) }, be))
|
|
1767
|
+
] }, E);
|
|
1569
1768
|
}) })
|
|
1570
1769
|
] }) }),
|
|
1571
|
-
|
|
1770
|
+
se.length > ot && /* @__PURE__ */ y(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1572
1771
|
"Showing first ",
|
|
1573
|
-
|
|
1772
|
+
ot,
|
|
1574
1773
|
" of ",
|
|
1575
|
-
|
|
1774
|
+
se.length,
|
|
1576
1775
|
" rows"
|
|
1577
1776
|
] })
|
|
1578
1777
|
] }) });
|
|
1579
|
-
}, [
|
|
1580
|
-
async (
|
|
1581
|
-
if (
|
|
1582
|
-
|
|
1778
|
+
}, [ee, z, I, A, T, R]), m = $e(
|
|
1779
|
+
async (C) => {
|
|
1780
|
+
if (L(null), C.size > M) {
|
|
1781
|
+
L(`File exceeds the ${xe(M)} limit.`);
|
|
1583
1782
|
return;
|
|
1584
1783
|
}
|
|
1585
|
-
if (!
|
|
1586
|
-
|
|
1784
|
+
if (!b.split(",").map((_) => _.trim()).some((_) => _ === "*" || _ === "*/*" ? !0 : _.endsWith("/*") ? C.type.startsWith(_.slice(0, -1)) : _.startsWith(".") ? C.name.toLowerCase().endsWith(_.toLowerCase()) : C.type === _)) {
|
|
1785
|
+
L(`Invalid type. Accepted: ${Ae(b)}`);
|
|
1587
1786
|
return;
|
|
1588
1787
|
}
|
|
1589
|
-
|
|
1590
|
-
let
|
|
1788
|
+
X("parsing");
|
|
1789
|
+
let H;
|
|
1591
1790
|
try {
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
} catch (
|
|
1595
|
-
|
|
1596
|
-
|
|
1791
|
+
const _ = await C.arrayBuffer();
|
|
1792
|
+
H = (await kn(_, V)).matrix;
|
|
1793
|
+
} catch (_) {
|
|
1794
|
+
X("error"), L(
|
|
1795
|
+
_ instanceof st ? _.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
|
|
1597
1796
|
);
|
|
1598
1797
|
return;
|
|
1599
1798
|
}
|
|
1600
|
-
if (
|
|
1799
|
+
if (I || A)
|
|
1601
1800
|
try {
|
|
1602
|
-
|
|
1603
|
-
} catch (
|
|
1604
|
-
|
|
1801
|
+
H = Ee(Ct(H, { columnHeader: N, rowHeader: U, columns: T, rows: R }));
|
|
1802
|
+
} catch (_) {
|
|
1803
|
+
X("error"), L(_ instanceof Error ? _.message : "Failed to process this sheet.");
|
|
1605
1804
|
return;
|
|
1606
1805
|
}
|
|
1607
|
-
|
|
1806
|
+
K.current = (e == null ? void 0 : e.sheet) ?? null, de(H), X("ready");
|
|
1608
1807
|
},
|
|
1609
|
-
[
|
|
1808
|
+
[b, M, V, e, N, U, T, R, I, A, Ee]
|
|
1610
1809
|
);
|
|
1611
|
-
if (
|
|
1612
|
-
|
|
1613
|
-
}, [
|
|
1614
|
-
if (
|
|
1615
|
-
let
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
},
|
|
1619
|
-
if (
|
|
1620
|
-
|
|
1810
|
+
if (me(() => {
|
|
1811
|
+
Q != null && fe != null && fe !== K.current && de(null);
|
|
1812
|
+
}, [Q, fe]), me(() => {
|
|
1813
|
+
if (D || g.length === 0 && !v) return;
|
|
1814
|
+
let C = !1;
|
|
1815
|
+
const P = (H) => {
|
|
1816
|
+
f && (to(x == null ? void 0 : x.derivations, H == null ? void 0 : H.derivations) && no(x == null ? void 0 : x.sheet, H == null ? void 0 : H.sheet) || (K.current = (H == null ? void 0 : H.sheet) ?? null, r(t, H)));
|
|
1817
|
+
}, se = ee ?? [];
|
|
1818
|
+
if (se.length === 0) {
|
|
1819
|
+
x != null && P(void 0);
|
|
1621
1820
|
return;
|
|
1622
1821
|
}
|
|
1623
|
-
return
|
|
1624
|
-
if (
|
|
1625
|
-
let
|
|
1626
|
-
if (
|
|
1627
|
-
if (
|
|
1822
|
+
return Jn(se, g).then((H) => {
|
|
1823
|
+
if (C) return;
|
|
1824
|
+
let _;
|
|
1825
|
+
if (Q != null) {
|
|
1826
|
+
if (v)
|
|
1628
1827
|
try {
|
|
1629
|
-
|
|
1630
|
-
} catch (
|
|
1631
|
-
|
|
1828
|
+
_ = Ct(se, { columnHeader: I, rowHeader: A, columns: T, rows: R });
|
|
1829
|
+
} catch (Fe) {
|
|
1830
|
+
L(Fe instanceof Error ? Fe.message : "Failed to process this sheet.");
|
|
1632
1831
|
return;
|
|
1633
1832
|
}
|
|
1634
1833
|
} else
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1834
|
+
_ = x == null ? void 0 : x.sheet;
|
|
1835
|
+
L(null);
|
|
1836
|
+
const De = eo(H);
|
|
1837
|
+
Ne({ matrix: se, derivations: De }), P(_ === void 0 ? { derivations: De } : { sheet: _, derivations: De });
|
|
1639
1838
|
}), () => {
|
|
1640
|
-
|
|
1839
|
+
C = !0;
|
|
1641
1840
|
};
|
|
1642
|
-
}, [
|
|
1841
|
+
}, [ee, Q, g, f, v, I, A, T, R, D]), c === !1)
|
|
1643
1842
|
return null;
|
|
1644
|
-
if (
|
|
1645
|
-
return /* @__PURE__ */
|
|
1646
|
-
/* @__PURE__ */
|
|
1647
|
-
/* @__PURE__ */
|
|
1843
|
+
if (D)
|
|
1844
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
1845
|
+
/* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: n }),
|
|
1846
|
+
/* @__PURE__ */ y(h, { size: "2", color: "red", style: { display: "block" }, children: [
|
|
1648
1847
|
"Invalid x-spreadsheet config: ",
|
|
1649
|
-
|
|
1848
|
+
D
|
|
1650
1849
|
] })
|
|
1651
1850
|
] });
|
|
1652
|
-
if (!
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
},
|
|
1656
|
-
var
|
|
1657
|
-
|
|
1658
|
-
},
|
|
1659
|
-
var
|
|
1660
|
-
(
|
|
1661
|
-
},
|
|
1662
|
-
|
|
1663
|
-
},
|
|
1664
|
-
return /* @__PURE__ */
|
|
1665
|
-
/* @__PURE__ */
|
|
1666
|
-
/* @__PURE__ */
|
|
1667
|
-
/* @__PURE__ */
|
|
1668
|
-
|
|
1669
|
-
|
|
1851
|
+
if (!f && !ie) return null;
|
|
1852
|
+
const w = (C) => {
|
|
1853
|
+
C.preventDefault(), C.stopPropagation(), f && G(C.type === "dragenter" || C.type === "dragover");
|
|
1854
|
+
}, $ = (C) => {
|
|
1855
|
+
var P;
|
|
1856
|
+
C.preventDefault(), C.stopPropagation(), G(!1), f && (P = C.dataTransfer.files) != null && P[0] && m(C.dataTransfer.files[0]);
|
|
1857
|
+
}, B = (C) => {
|
|
1858
|
+
var P;
|
|
1859
|
+
(P = C.target.files) != null && P[0] && (m(C.target.files[0]), C.target.value = "");
|
|
1860
|
+
}, q = () => {
|
|
1861
|
+
f && (de(null), Ne(null), K.current = null, L(null), X("empty"), r(t, void 0));
|
|
1862
|
+
}, J = z && ee == null && x != null;
|
|
1863
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
1864
|
+
/* @__PURE__ */ y(F, { align: "center", justify: "between", mb: "2", children: [
|
|
1865
|
+
/* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
|
|
1866
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", children: [
|
|
1867
|
+
n,
|
|
1868
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: " *" })
|
|
1670
1869
|
] }),
|
|
1671
|
-
|
|
1672
|
-
/* @__PURE__ */
|
|
1673
|
-
|
|
1870
|
+
ie && f && /* @__PURE__ */ y(ve, { children: [
|
|
1871
|
+
/* @__PURE__ */ i(Be, { content: "Replace spreadsheet", children: /* @__PURE__ */ i(
|
|
1872
|
+
je,
|
|
1674
1873
|
{
|
|
1675
1874
|
variant: "ghost",
|
|
1676
1875
|
size: "1",
|
|
1677
1876
|
onClick: () => {
|
|
1678
|
-
var
|
|
1679
|
-
return (
|
|
1877
|
+
var C;
|
|
1878
|
+
return (C = S.current) == null ? void 0 : C.click();
|
|
1680
1879
|
},
|
|
1681
1880
|
"aria-label": "Replace spreadsheet",
|
|
1682
|
-
children: /* @__PURE__ */
|
|
1881
|
+
children: /* @__PURE__ */ i(Ue, {})
|
|
1683
1882
|
}
|
|
1684
1883
|
) }),
|
|
1685
|
-
/* @__PURE__ */
|
|
1686
|
-
|
|
1884
|
+
/* @__PURE__ */ i(Be, { content: "Remove spreadsheet", children: /* @__PURE__ */ i(
|
|
1885
|
+
je,
|
|
1687
1886
|
{
|
|
1688
1887
|
variant: "ghost",
|
|
1689
1888
|
size: "1",
|
|
1690
1889
|
color: "gray",
|
|
1691
|
-
onClick:
|
|
1890
|
+
onClick: q,
|
|
1692
1891
|
"aria-label": "Remove spreadsheet",
|
|
1693
|
-
children: /* @__PURE__ */
|
|
1892
|
+
children: /* @__PURE__ */ i(ct, {})
|
|
1694
1893
|
}
|
|
1695
1894
|
) })
|
|
1696
1895
|
] })
|
|
1697
1896
|
] }),
|
|
1698
|
-
/* @__PURE__ */
|
|
1699
|
-
|
|
1897
|
+
/* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
|
|
1898
|
+
xe(M),
|
|
1700
1899
|
" max · ",
|
|
1701
|
-
|
|
1900
|
+
Ae(b)
|
|
1702
1901
|
] })
|
|
1703
1902
|
] }),
|
|
1704
|
-
|
|
1705
|
-
/* @__PURE__ */
|
|
1706
|
-
|
|
1903
|
+
ie && Y && /* @__PURE__ */ i(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: Y }),
|
|
1904
|
+
/* @__PURE__ */ i("input", { ref: S, type: "file", style: { display: "none" }, accept: b, onChange: B }),
|
|
1905
|
+
f && !ie && /* @__PURE__ */ i(
|
|
1707
1906
|
"div",
|
|
1708
1907
|
{
|
|
1709
1908
|
role: "button",
|
|
1710
1909
|
tabIndex: 0,
|
|
1711
1910
|
onClick: () => {
|
|
1712
|
-
var
|
|
1713
|
-
return (
|
|
1911
|
+
var C;
|
|
1912
|
+
return (C = S.current) == null ? void 0 : C.click();
|
|
1714
1913
|
},
|
|
1715
|
-
onKeyDown: (
|
|
1716
|
-
var
|
|
1717
|
-
(
|
|
1914
|
+
onKeyDown: (C) => {
|
|
1915
|
+
var P;
|
|
1916
|
+
(C.key === "Enter" || C.key === " ") && (C.preventDefault(), (P = S.current) == null || P.click());
|
|
1718
1917
|
},
|
|
1719
|
-
onDragEnter:
|
|
1720
|
-
onDragLeave:
|
|
1721
|
-
onDragOver:
|
|
1722
|
-
onDrop:
|
|
1918
|
+
onDragEnter: w,
|
|
1919
|
+
onDragLeave: w,
|
|
1920
|
+
onDragOver: w,
|
|
1921
|
+
onDrop: $,
|
|
1723
1922
|
style: { cursor: "pointer" },
|
|
1724
1923
|
className: [
|
|
1725
1924
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
1726
1925
|
"transition-all duration-200 ease-in-out",
|
|
1727
|
-
|
|
1926
|
+
O ? "border-blue-500 bg-blue-50" : Y ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
|
|
1728
1927
|
].join(" "),
|
|
1729
|
-
children: /* @__PURE__ */
|
|
1730
|
-
/* @__PURE__ */
|
|
1731
|
-
/* @__PURE__ */
|
|
1732
|
-
] }) :
|
|
1733
|
-
/* @__PURE__ */
|
|
1734
|
-
/* @__PURE__ */
|
|
1735
|
-
/* @__PURE__ */
|
|
1736
|
-
] }) : /* @__PURE__ */
|
|
1737
|
-
/* @__PURE__ */
|
|
1738
|
-
/* @__PURE__ */
|
|
1739
|
-
/* @__PURE__ */
|
|
1740
|
-
|
|
1928
|
+
children: /* @__PURE__ */ i(F, { direction: "column", align: "center", gap: "2", children: re === "parsing" ? /* @__PURE__ */ y(ve, { children: [
|
|
1929
|
+
/* @__PURE__ */ i(_e, { size: "3" }),
|
|
1930
|
+
/* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
|
|
1931
|
+
] }) : Y ? /* @__PURE__ */ y(ve, { children: [
|
|
1932
|
+
/* @__PURE__ */ i(ut, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
|
|
1933
|
+
/* @__PURE__ */ i(h, { size: "2", color: "red", weight: "medium", children: Y }),
|
|
1934
|
+
/* @__PURE__ */ i(h, { size: "1", color: "gray", children: "Click to try again" })
|
|
1935
|
+
] }) : /* @__PURE__ */ y(ve, { children: [
|
|
1936
|
+
/* @__PURE__ */ i(Ue, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
|
|
1937
|
+
/* @__PURE__ */ i(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
|
|
1938
|
+
/* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
|
|
1939
|
+
xe(M),
|
|
1741
1940
|
" max · ",
|
|
1742
|
-
|
|
1941
|
+
Ae(b)
|
|
1743
1942
|
] })
|
|
1744
1943
|
] }) })
|
|
1745
1944
|
}
|
|
1746
1945
|
),
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
Object.keys(
|
|
1750
|
-
/* @__PURE__ */
|
|
1751
|
-
/* @__PURE__ */
|
|
1752
|
-
/* @__PURE__ */
|
|
1753
|
-
|
|
1946
|
+
Te,
|
|
1947
|
+
J && /* @__PURE__ */ i(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
|
|
1948
|
+
Object.keys(ge).length > 0 && /* @__PURE__ */ y(k, { mt: "3", children: [
|
|
1949
|
+
/* @__PURE__ */ i(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
|
|
1950
|
+
/* @__PURE__ */ i(F, { direction: "column", gap: "1", children: Object.entries(ge).map(([C, P]) => /* @__PURE__ */ y(F, { justify: "between", children: [
|
|
1951
|
+
/* @__PURE__ */ i(h, { size: "2", children: P.label }),
|
|
1952
|
+
P.error ? /* @__PURE__ */ i(h, { size: "2", color: "red", children: P.error }) : (
|
|
1754
1953
|
// d.value is CellValue | null now (SUM/AVERAGE aren't the only
|
|
1755
1954
|
// possible results anymore — INDEX/CONCATENATE can return a
|
|
1756
1955
|
// string, a bare comparison can return a boolean, etc.), so
|
|
1757
1956
|
// `.toLocaleString()` would throw for e.g. a boolean result.
|
|
1758
1957
|
// Reuse the same formatCell used for the sheet-preview grid.
|
|
1759
|
-
/* @__PURE__ */
|
|
1958
|
+
/* @__PURE__ */ i(h, { size: "2", children: St(P.value) })
|
|
1760
1959
|
)
|
|
1761
|
-
] },
|
|
1960
|
+
] }, C)) })
|
|
1762
1961
|
] }),
|
|
1763
|
-
!
|
|
1962
|
+
!d && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(a, n) })
|
|
1764
1963
|
] });
|
|
1765
|
-
},
|
|
1964
|
+
}, fo = pe(uo), po = te(
|
|
1766
1965
|
10,
|
|
1767
1966
|
// matches FileControlTester's rank — beats the default object/Group renderer
|
|
1768
|
-
|
|
1967
|
+
Me(
|
|
1769
1968
|
(e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
|
|
1770
1969
|
)
|
|
1970
|
+
), ho = "Sheet1", mo = "xlsx";
|
|
1971
|
+
function go(e) {
|
|
1972
|
+
if (e === void 0) return null;
|
|
1973
|
+
if (!Array.isArray(e)) return "columns must be an array of { id, label } objects.";
|
|
1974
|
+
if (e.length === 0)
|
|
1975
|
+
return "columns is declared but empty — declare at least one field, or omit it entirely.";
|
|
1976
|
+
const r = e.findIndex(
|
|
1977
|
+
(t) => !t || typeof t != "object" || typeof t.id != "string" || t.id === "" || typeof t.label != "string" || t.label === ""
|
|
1978
|
+
);
|
|
1979
|
+
return r !== -1 ? `columns[${r}] must be a { id, label } object with non-empty string fields.` : null;
|
|
1980
|
+
}
|
|
1981
|
+
function yo(e, r) {
|
|
1982
|
+
if (!tr(e)) return e;
|
|
1983
|
+
const t = rr(
|
|
1984
|
+
e,
|
|
1985
|
+
r == null ? void 0 : r.map((s) => s.id)
|
|
1986
|
+
);
|
|
1987
|
+
if (!r || t.length === 0) return t;
|
|
1988
|
+
const n = new Map(r.map((s) => [s.id, s.label])), [l, ...o] = t;
|
|
1989
|
+
return [l.map((s) => n.get(String(s)) ?? s), ...o];
|
|
1990
|
+
}
|
|
1991
|
+
const bo = ({ data: e, path: r, label: t, schema: n, visible: l = !0 }) => {
|
|
1992
|
+
const [o, s] = j(null), u = Ve();
|
|
1993
|
+
if (l === !1)
|
|
1994
|
+
return null;
|
|
1995
|
+
const a = (n == null ? void 0 : n["x-spreadsheet-export"]) ?? {}, c = a.columns, d = a.sheetName ?? ho, f = a.fileType ?? mo, p = a.fileName ?? `export.${f}`, g = go(c);
|
|
1996
|
+
if (g)
|
|
1997
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
1998
|
+
/* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: t }),
|
|
1999
|
+
/* @__PURE__ */ y(h, { size: "2", color: "red", style: { display: "block" }, children: [
|
|
2000
|
+
"Invalid x-spreadsheet-export config: ",
|
|
2001
|
+
g
|
|
2002
|
+
] })
|
|
2003
|
+
] });
|
|
2004
|
+
const b = Array.isArray(e) && e.length > 0, M = async () => {
|
|
2005
|
+
var N, U;
|
|
2006
|
+
if (b) {
|
|
2007
|
+
s(null);
|
|
2008
|
+
try {
|
|
2009
|
+
const T = await import("@e965/xlsx"), R = yo(e, c), I = T.utils.aoa_to_sheet(R), A = T.utils.book_new();
|
|
2010
|
+
T.utils.book_append_sheet(A, I, d);
|
|
2011
|
+
const D = r.split(".").slice(0, -1).join("."), z = D ? Pe.data((N = u.core) == null ? void 0 : N.data, D) : (U = u.core) == null ? void 0 : U.data;
|
|
2012
|
+
T.writeFile(A, ft(p, z, `export.${f}`), { bookType: f });
|
|
2013
|
+
} catch (T) {
|
|
2014
|
+
s(T instanceof Error ? T.message : "Failed to build the workbook.");
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
};
|
|
2018
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
2019
|
+
/* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: t }),
|
|
2020
|
+
/* @__PURE__ */ y(ze, { type: "button", variant: "soft", disabled: !b, onClick: () => void M(), children: [
|
|
2021
|
+
/* @__PURE__ */ i(at, {}),
|
|
2022
|
+
" Download Spreadsheet"
|
|
2023
|
+
] }),
|
|
2024
|
+
o && /* @__PURE__ */ i(h, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: o })
|
|
2025
|
+
] });
|
|
2026
|
+
}, vo = pe(bo), wo = te(
|
|
2027
|
+
10,
|
|
2028
|
+
$t(
|
|
2029
|
+
Me((e) => {
|
|
2030
|
+
const r = e["x-spreadsheet-export"];
|
|
2031
|
+
return e.type === "array" && typeof r == "object" && r !== null;
|
|
2032
|
+
}),
|
|
2033
|
+
Er(Tr("editable", !0))
|
|
2034
|
+
)
|
|
1771
2035
|
);
|
|
1772
|
-
class
|
|
2036
|
+
class Ie extends Error {
|
|
1773
2037
|
}
|
|
1774
|
-
const
|
|
2038
|
+
const Ot = 5e6, Eo = 1024, To = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, xo = {
|
|
1775
2039
|
// Default is true, which would silently drop what in many formats is most of
|
|
1776
2040
|
// the payload.
|
|
1777
2041
|
ignoreAttributes: !1,
|
|
@@ -1818,478 +2082,735 @@ const dr = 5e6, En = 1024, Rn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["'
|
|
|
1818
2082
|
maxNestedTags: 100,
|
|
1819
2083
|
strictReservedNames: !0
|
|
1820
2084
|
};
|
|
1821
|
-
function
|
|
1822
|
-
const
|
|
1823
|
-
return
|
|
2085
|
+
function Ao(e) {
|
|
2086
|
+
const r = new Set(e);
|
|
2087
|
+
return r.size === 0 ? () => !1 : (t, n) => (
|
|
1824
2088
|
// A string while the library's own `jPath` option is true (the default) and
|
|
1825
2089
|
// a matcher object otherwise; both stringify to the same dotted path.
|
|
1826
|
-
|
|
2090
|
+
r.has(typeof n == "string" ? n : n.toString()) || r.has(t)
|
|
1827
2091
|
);
|
|
1828
2092
|
}
|
|
1829
|
-
function
|
|
1830
|
-
const
|
|
1831
|
-
return
|
|
1832
|
-
}
|
|
1833
|
-
async function
|
|
1834
|
-
var
|
|
1835
|
-
if (typeof e != "string") throw new
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1838
|
-
if (
|
|
1839
|
-
throw new
|
|
1840
|
-
`This document is too large to parse (over ${
|
|
2093
|
+
function Ro(e) {
|
|
2094
|
+
const r = e instanceof Error ? e.message : "";
|
|
2095
|
+
return r.startsWith("[SECURITY] Invalid name:") ? "This document uses a reserved JavaScript name (__proto__, constructor or prototype) as an element or attribute name, which cannot be represented safely." : r === "External entities are not supported" || r === "Parameter entities are not supported" ? `${r}. Please remove the DOCTYPE entity declarations and try again.` : r.startsWith("Maximum nested tags exceeded") ? "This document is nested too deeply to parse." : r.startsWith("Entity count") || r.includes("exceeds maximum allowed") ? "This document declares too many or too large entity definitions to expand safely." : "This doesn't look like a valid XML document. Please check the file and try again.";
|
|
2096
|
+
}
|
|
2097
|
+
async function Co(e, r = {}) {
|
|
2098
|
+
var c;
|
|
2099
|
+
if (typeof e != "string") throw new Ie("This file could not be read as text.");
|
|
2100
|
+
const t = e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
2101
|
+
if (t.trim() === "") throw new Ie("This file is empty.");
|
|
2102
|
+
if (t.length > Ot)
|
|
2103
|
+
throw new Ie(
|
|
2104
|
+
`This document is too large to parse (over ${Ot / 1e6} million characters).`
|
|
1841
2105
|
);
|
|
1842
|
-
const
|
|
1843
|
-
if (
|
|
1844
|
-
throw new
|
|
1845
|
-
`This document declares the unsupported encoding "${
|
|
2106
|
+
const n = (c = To.exec(t.slice(0, Eo))) == null ? void 0 : c[1];
|
|
2107
|
+
if (n && !/^utf-?8$/i.test(n))
|
|
2108
|
+
throw new Ie(
|
|
2109
|
+
`This document declares the unsupported encoding "${n}". Only UTF-8 is supported.`
|
|
1846
2110
|
);
|
|
1847
|
-
const { XMLParser:
|
|
1848
|
-
if (
|
|
1849
|
-
const { msg:
|
|
1850
|
-
throw new
|
|
2111
|
+
const { XMLParser: l, XMLValidator: o } = await import("fast-xml-parser"), s = o.validate(t, { allowBooleanAttributes: !1 });
|
|
2112
|
+
if (s !== !0) {
|
|
2113
|
+
const { msg: d, line: f, col: p } = s.err;
|
|
2114
|
+
throw new Ie(`Invalid XML at line ${f}, column ${p}: ${d}`);
|
|
1851
2115
|
}
|
|
1852
|
-
const
|
|
1853
|
-
...
|
|
1854
|
-
removeNSPrefix:
|
|
1855
|
-
isArray:
|
|
2116
|
+
const u = new l({
|
|
2117
|
+
...xo,
|
|
2118
|
+
removeNSPrefix: r.removeNamespaces === !0,
|
|
2119
|
+
isArray: Ao(r.arrayPaths ?? [])
|
|
1856
2120
|
});
|
|
1857
|
-
let
|
|
2121
|
+
let a;
|
|
2122
|
+
try {
|
|
2123
|
+
a = u.parse(t);
|
|
2124
|
+
} catch (d) {
|
|
2125
|
+
throw new Ie(Ro(d));
|
|
2126
|
+
}
|
|
2127
|
+
if (a == null || typeof a != "object" || Array.isArray(a))
|
|
2128
|
+
throw new Ie("This document has no root element.");
|
|
2129
|
+
return a;
|
|
2130
|
+
}
|
|
2131
|
+
function nr(e, r, t) {
|
|
2132
|
+
const { path: n, default: l } = typeof t == "string" ? { path: t, default: void 0 } : t, o = Pe.data(e, r ? `${r}.${n}` : n);
|
|
2133
|
+
return o ?? l;
|
|
2134
|
+
}
|
|
2135
|
+
function So(e, r, t) {
|
|
2136
|
+
const n = {};
|
|
2137
|
+
for (const [l, o] of Object.entries(t)) {
|
|
2138
|
+
const s = nr(e, r, o);
|
|
2139
|
+
if (s === void 0) return;
|
|
2140
|
+
n[l] = s;
|
|
2141
|
+
}
|
|
2142
|
+
return n;
|
|
2143
|
+
}
|
|
2144
|
+
async function Oo(e, r) {
|
|
1858
2145
|
try {
|
|
1859
|
-
|
|
1860
|
-
} catch (
|
|
1861
|
-
|
|
2146
|
+
return { status: "ok", value: await Zt(e, r) };
|
|
2147
|
+
} catch (t) {
|
|
2148
|
+
return { status: "error", error: pt(t) };
|
|
1862
2149
|
}
|
|
1863
|
-
if (s == null || typeof s != "object" || Array.isArray(s))
|
|
1864
|
-
throw new Ee("This document has no root element.");
|
|
1865
|
-
return s;
|
|
1866
2150
|
}
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
return e == null || e === "" ? Te : Array.isArray(e) || e instanceof Date ? ce(e) : typeof e == "object" ? Te : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? ce(e) : Te;
|
|
2151
|
+
function or(e, r) {
|
|
2152
|
+
return e == null ? "" : typeof e == "number" ? e.toFixed(No(r)) : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1870
2153
|
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
2154
|
+
function No(e) {
|
|
2155
|
+
return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
|
|
2156
|
+
}
|
|
2157
|
+
const ke = { found: !1 }, he = (e) => ({ found: !0, value: e });
|
|
2158
|
+
function Nt(e) {
|
|
2159
|
+
return e == null || e === "" ? ke : Array.isArray(e) || e instanceof Date ? he(e) : typeof e == "object" ? ke : typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? he(e) : ke;
|
|
2160
|
+
}
|
|
2161
|
+
const Do = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), Io = /* @__PURE__ */ new Set(["false", "0", "no", "n"]), ko = /^(\d{4}-\d{2}-\d{2})(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?)?$/;
|
|
2162
|
+
async function Lo(e, r, t) {
|
|
2163
|
+
switch (r.as) {
|
|
1874
2164
|
case void 0:
|
|
1875
|
-
return
|
|
2165
|
+
return he(e);
|
|
1876
2166
|
case "string":
|
|
1877
|
-
return
|
|
2167
|
+
return he(e instanceof Date ? e.toISOString() : String(e));
|
|
1878
2168
|
case "number": {
|
|
1879
|
-
const
|
|
1880
|
-
return Number.isFinite(
|
|
2169
|
+
const n = e instanceof Date ? e.getTime() : Number(e);
|
|
2170
|
+
return Number.isFinite(n) ? he(r.decimals === void 0 ? n : or(n, r.decimals)) : ke;
|
|
1881
2171
|
}
|
|
1882
2172
|
case "boolean": {
|
|
1883
|
-
const
|
|
1884
|
-
return
|
|
2173
|
+
const n = String(e).trim().toLowerCase();
|
|
2174
|
+
return Do.has(n) ? he(!0) : Io.has(n) ? he(!1) : ke;
|
|
1885
2175
|
}
|
|
1886
2176
|
case "date": {
|
|
1887
|
-
const { default:
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
2177
|
+
const { default: n } = await import("dayjs"), { default: l } = await import("./customParseFormat-D14EWdSX.js").then((u) => u.c);
|
|
2178
|
+
if (n.extend(l), t === "export") {
|
|
2179
|
+
const u = typeof e == "string" ? ko.exec(e) : null, a = e instanceof Date ? n(e) : u ? n(u[1], "YYYY-MM-DD", !0) : null;
|
|
2180
|
+
return a != null && a.isValid() ? he(a.format(r.format ?? "YYYY-MM-DD")) : ke;
|
|
2181
|
+
}
|
|
2182
|
+
const o = e instanceof Date ? e.toISOString() : String(e), s = r.format ? n(o, r.format, !0) : n(o);
|
|
2183
|
+
return s.isValid() ? he(s.format("YYYY-MM-DD")) : ke;
|
|
1891
2184
|
}
|
|
1892
2185
|
}
|
|
1893
2186
|
}
|
|
1894
|
-
async function
|
|
1895
|
-
if (
|
|
1896
|
-
const
|
|
1897
|
-
for (const [
|
|
1898
|
-
const
|
|
1899
|
-
if (!
|
|
1900
|
-
|
|
2187
|
+
async function Mo(e, r) {
|
|
2188
|
+
if (r.formula !== void 0) {
|
|
2189
|
+
const t = {};
|
|
2190
|
+
for (const [n, l] of Object.entries(r.inputs ?? {})) {
|
|
2191
|
+
const o = Nt(Pe.data(e, l));
|
|
2192
|
+
if (!o.found || Array.isArray(o.value)) return ke;
|
|
2193
|
+
t[n] = o.value;
|
|
1901
2194
|
}
|
|
1902
2195
|
try {
|
|
1903
|
-
return
|
|
1904
|
-
} catch (
|
|
1905
|
-
throw new Error(`
|
|
2196
|
+
return he(await Zt(t, r.formula));
|
|
2197
|
+
} catch (n) {
|
|
2198
|
+
throw new Error(`writeTo "${r.to}": ${pt(n)}`);
|
|
1906
2199
|
}
|
|
1907
2200
|
}
|
|
1908
|
-
if (
|
|
1909
|
-
return
|
|
2201
|
+
if (r.from === void 0) throw new Error(`writeTo "${r.to}" needs either "from" or "formula".`);
|
|
2202
|
+
return Nt(Pe.data(e, r.from));
|
|
1910
2203
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
if (
|
|
1917
|
-
|
|
1918
|
-
|
|
2204
|
+
const Qe = "@_", ir = "#text", et = (e) => e.split(".").filter(Boolean), sr = (e) => e.startsWith(Qe) || e === ir;
|
|
2205
|
+
function lr(e, r) {
|
|
2206
|
+
if (typeof e.to != "string" || et(e.to).length === 0) return '"to" must be a non-empty path.';
|
|
2207
|
+
if (e.format !== void 0 && e.as !== "date") return '"format" needs "as": "date".';
|
|
2208
|
+
if (e.decimals !== void 0) {
|
|
2209
|
+
if (r === "import")
|
|
2210
|
+
return '"decimals" only applies on export — on import it would put text in a number field.';
|
|
2211
|
+
if (e.as !== "number") return '"decimals" needs "as": "number".';
|
|
2212
|
+
const { decimals: t } = e;
|
|
2213
|
+
if (!Number.isInteger(t) || t < 0 || t > 100)
|
|
2214
|
+
return '"decimals" must be a whole number from 0 to 100.';
|
|
2215
|
+
}
|
|
2216
|
+
if (r === "export") {
|
|
2217
|
+
const t = et(e.to);
|
|
2218
|
+
for (const [n, l] of t.entries()) {
|
|
2219
|
+
if (l === Qe) return '"@_" needs an attribute name after it, e.g. "@_id".';
|
|
2220
|
+
if (sr(l) && n < t.length - 1)
|
|
2221
|
+
return `"${l}" must be the last segment — it belongs to the element before it.`;
|
|
1919
2222
|
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2223
|
+
}
|
|
2224
|
+
return null;
|
|
2225
|
+
}
|
|
2226
|
+
function Dt(e, r, t) {
|
|
2227
|
+
const n = t ? ` To give "${r}" both text and attributes, write its text to "${r}.${ir}".` : "";
|
|
2228
|
+
return new Error(`writeTo "${e}": "${r}" is written both as a value and as the parent of other values.${n}`);
|
|
2229
|
+
}
|
|
2230
|
+
function ar(e) {
|
|
2231
|
+
const r = {}, t = /* @__PURE__ */ new Set([r]);
|
|
2232
|
+
for (const { to: n, value: l } of e) {
|
|
2233
|
+
const o = et(n);
|
|
2234
|
+
if (o.length === 0) continue;
|
|
2235
|
+
let s = r;
|
|
2236
|
+
for (const [c, d] of o.slice(0, -1).entries()) {
|
|
2237
|
+
const f = s[d];
|
|
2238
|
+
if (f === void 0) {
|
|
2239
|
+
const p = {};
|
|
2240
|
+
t.add(p), s[d] = p, s = p;
|
|
2241
|
+
} else if (t.has(f))
|
|
2242
|
+
s = f;
|
|
2243
|
+
else
|
|
2244
|
+
throw Dt(n, o.slice(0, c + 1).join("."), o[c + 1].startsWith(Qe));
|
|
2245
|
+
}
|
|
2246
|
+
const u = o[o.length - 1], a = s[u];
|
|
2247
|
+
if (t.has(a)) {
|
|
2248
|
+
const c = Object.keys(a).some((d) => d.startsWith(Qe));
|
|
2249
|
+
throw Dt(n, o.join("."), c);
|
|
1924
2250
|
}
|
|
1925
|
-
|
|
2251
|
+
s[u] = l;
|
|
1926
2252
|
}
|
|
1927
2253
|
return r;
|
|
1928
2254
|
}
|
|
1929
|
-
const
|
|
2255
|
+
const zo = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean";
|
|
2256
|
+
async function ht(e, r, t) {
|
|
2257
|
+
const n = [];
|
|
2258
|
+
for (const l of r) {
|
|
2259
|
+
const o = lr(l, t);
|
|
2260
|
+
if (o) throw new Error(`writeTo "${l.to}": ${o}`);
|
|
2261
|
+
const s = et(l.to), u = t === "export" && sr(s[s.length - 1]), a = (f) => {
|
|
2262
|
+
if (!(u && f == null)) {
|
|
2263
|
+
if (u && !zo(f)) {
|
|
2264
|
+
const p = f instanceof Date ? ' Add "as": "date" to write a date.' : "";
|
|
2265
|
+
throw new Error(
|
|
2266
|
+
`writeTo "${l.to}": an attribute or #text value must be text, a number or a boolean.${p}`
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
n.push({ to: l.to, value: f });
|
|
2270
|
+
}
|
|
2271
|
+
};
|
|
2272
|
+
let c = await Mo(e, l);
|
|
2273
|
+
const d = c.found && Array.isArray(c.value);
|
|
2274
|
+
if (c.found && d && l.writeTo) {
|
|
2275
|
+
const f = await Promise.all(
|
|
2276
|
+
c.value.map(
|
|
2277
|
+
async (p) => ar(await ht(p, l.writeTo, t))
|
|
2278
|
+
)
|
|
2279
|
+
);
|
|
2280
|
+
a(f);
|
|
2281
|
+
continue;
|
|
2282
|
+
}
|
|
2283
|
+
if (c.found && !d && l.writeTo)
|
|
2284
|
+
throw new Error(`writeTo "${l.to}": "writeTo" is set, but "from" did not resolve to a repeating element.`);
|
|
2285
|
+
if (c.found && !d && l.map) {
|
|
2286
|
+
const f = c.value instanceof Date ? c.value.toISOString() : String(c.value);
|
|
2287
|
+
Object.prototype.hasOwnProperty.call(l.map, f) && (c = he(l.map[f]));
|
|
2288
|
+
}
|
|
2289
|
+
if (c.found && !d && (c = await Lo(c.value, l, t)), !c.found) {
|
|
2290
|
+
if (l.default === void 0) continue;
|
|
2291
|
+
a(l.default);
|
|
2292
|
+
continue;
|
|
2293
|
+
}
|
|
2294
|
+
a(c.value);
|
|
2295
|
+
}
|
|
2296
|
+
return n;
|
|
2297
|
+
}
|
|
2298
|
+
const Fo = ".xml,text/xml,application/xml", Uo = 5 * 1024 * 1024, $o = ({
|
|
1930
2299
|
data: e,
|
|
1931
|
-
handleChange:
|
|
1932
|
-
path:
|
|
1933
|
-
label:
|
|
1934
|
-
required:
|
|
1935
|
-
schema:
|
|
1936
|
-
enabled:
|
|
1937
|
-
readonly:
|
|
1938
|
-
errors:
|
|
1939
|
-
visible:
|
|
2300
|
+
handleChange: r,
|
|
2301
|
+
path: t,
|
|
2302
|
+
label: n,
|
|
2303
|
+
required: l,
|
|
2304
|
+
schema: o,
|
|
2305
|
+
enabled: s,
|
|
2306
|
+
readonly: u,
|
|
2307
|
+
errors: a,
|
|
2308
|
+
visible: c = !0
|
|
1940
2309
|
}) => {
|
|
1941
|
-
|
|
1942
|
-
const
|
|
1943
|
-
async (
|
|
1944
|
-
var
|
|
1945
|
-
const
|
|
1946
|
-
if (
|
|
1947
|
-
|
|
2310
|
+
Re(c, t, r);
|
|
2311
|
+
const d = !a || a.length === 0, f = Gt(s, u), p = (o == null ? void 0 : o["x-xml"]) ?? {}, g = p.accept ?? Fo, b = p.maxSize ?? Uo, M = p.arrayPaths, N = p.removeNamespaces === !0, U = p.writeTo, T = p.writeBase ?? "root", R = p.persistDocument !== !1, I = Ve(), A = e ?? null, [D, z] = j(() => A ? "ready" : "empty"), [V, v] = j(null), [x, re] = j(!1), X = ue(null), Y = ue(0), L = A != null, O = U !== void 0 && U.length > 0, G = $e(
|
|
2312
|
+
async (S) => {
|
|
2313
|
+
var Te;
|
|
2314
|
+
const K = ++Y.current;
|
|
2315
|
+
if (v(null), S.size > b) {
|
|
2316
|
+
v(`File exceeds the ${xe(b)} limit.`);
|
|
1948
2317
|
return;
|
|
1949
2318
|
}
|
|
1950
|
-
if (!
|
|
1951
|
-
|
|
2319
|
+
if (!g.split(",").map((m) => m.trim()).some((m) => m === "*" || m === "*/*" ? !0 : m.endsWith("/*") ? S.type.startsWith(m.slice(0, -1)) : m.startsWith(".") ? S.name.toLowerCase().endsWith(m.toLowerCase()) : S.type === m)) {
|
|
2320
|
+
v(`Invalid type. Accepted: ${Ae(g)}`);
|
|
1952
2321
|
return;
|
|
1953
2322
|
}
|
|
1954
|
-
|
|
1955
|
-
let
|
|
2323
|
+
z("parsing");
|
|
2324
|
+
let ee;
|
|
1956
2325
|
try {
|
|
1957
|
-
const
|
|
1958
|
-
|
|
1959
|
-
} catch (
|
|
1960
|
-
if (
|
|
1961
|
-
|
|
1962
|
-
|
|
2326
|
+
const m = await S.text();
|
|
2327
|
+
ee = await Co(m, { arrayPaths: M, removeNamespaces: N });
|
|
2328
|
+
} catch (m) {
|
|
2329
|
+
if (K !== Y.current) return;
|
|
2330
|
+
z("error"), v(
|
|
2331
|
+
m instanceof Ie ? m.message : "This doesn't look like a valid XML document. Please check the file and try again."
|
|
1963
2332
|
);
|
|
1964
2333
|
return;
|
|
1965
2334
|
}
|
|
1966
|
-
let
|
|
1967
|
-
if (
|
|
2335
|
+
let ge = [];
|
|
2336
|
+
if (U && U.length > 0)
|
|
1968
2337
|
try {
|
|
1969
|
-
|
|
1970
|
-
} catch (
|
|
1971
|
-
if (
|
|
1972
|
-
|
|
2338
|
+
ge = await ht(ee, U, "import");
|
|
2339
|
+
} catch (m) {
|
|
2340
|
+
if (K !== Y.current) return;
|
|
2341
|
+
z("error"), v(m instanceof Error ? m.message : "This document could not be mapped onto the form.");
|
|
1973
2342
|
return;
|
|
1974
2343
|
}
|
|
1975
|
-
if (
|
|
1976
|
-
|
|
1977
|
-
const
|
|
1978
|
-
for (const
|
|
1979
|
-
|
|
2344
|
+
if (K !== Y.current) return;
|
|
2345
|
+
R && r(t, ee);
|
|
2346
|
+
const ie = T === "parent" ? t.split(".").slice(0, -1).join(".") : "";
|
|
2347
|
+
for (const m of ge) (Te = I.dispatch) == null || Te.call(I, xr(ie ? `${ie}.${m.to}` : m.to, () => m.value));
|
|
2348
|
+
z("ready");
|
|
1980
2349
|
},
|
|
1981
|
-
[
|
|
2350
|
+
[g, b, M, N, U, T, R, t, r, I]
|
|
1982
2351
|
);
|
|
1983
|
-
if (
|
|
1984
|
-
const
|
|
1985
|
-
|
|
1986
|
-
},
|
|
1987
|
-
var
|
|
1988
|
-
|
|
1989
|
-
},
|
|
1990
|
-
var
|
|
1991
|
-
(
|
|
2352
|
+
if (c === !1 || !f && !L) return null;
|
|
2353
|
+
const Q = (S) => {
|
|
2354
|
+
S.preventDefault(), S.stopPropagation(), f && re(S.type === "dragenter" || S.type === "dragover");
|
|
2355
|
+
}, de = (S) => {
|
|
2356
|
+
var K;
|
|
2357
|
+
S.preventDefault(), S.stopPropagation(), re(!1), f && (K = S.dataTransfer.files) != null && K[0] && G(S.dataTransfer.files[0]);
|
|
2358
|
+
}, ne = (S) => {
|
|
2359
|
+
var K;
|
|
2360
|
+
(K = S.target.files) != null && K[0] && (G(S.target.files[0]), S.target.value = "");
|
|
1992
2361
|
};
|
|
1993
|
-
return /* @__PURE__ */
|
|
1994
|
-
/* @__PURE__ */
|
|
1995
|
-
/* @__PURE__ */
|
|
1996
|
-
/* @__PURE__ */
|
|
1997
|
-
|
|
1998
|
-
|
|
2362
|
+
return /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
2363
|
+
/* @__PURE__ */ y(F, { align: "center", justify: "between", mb: "2", children: [
|
|
2364
|
+
/* @__PURE__ */ y(F, { align: "center", gap: "1", children: [
|
|
2365
|
+
/* @__PURE__ */ y(h, { as: "label", size: "2", weight: "bold", children: [
|
|
2366
|
+
n,
|
|
2367
|
+
l && /* @__PURE__ */ i(h, { color: "red", children: " *" })
|
|
1999
2368
|
] }),
|
|
2000
|
-
!
|
|
2001
|
-
/* @__PURE__ */
|
|
2002
|
-
|
|
2369
|
+
!O && L && f && /* @__PURE__ */ y(ve, { children: [
|
|
2370
|
+
/* @__PURE__ */ i(Be, { content: "Replace document", children: /* @__PURE__ */ i(
|
|
2371
|
+
je,
|
|
2003
2372
|
{
|
|
2004
2373
|
variant: "ghost",
|
|
2005
2374
|
size: "1",
|
|
2006
2375
|
onClick: () => {
|
|
2007
|
-
var
|
|
2008
|
-
return (
|
|
2376
|
+
var S;
|
|
2377
|
+
return (S = X.current) == null ? void 0 : S.click();
|
|
2009
2378
|
},
|
|
2010
2379
|
"aria-label": "Replace document",
|
|
2011
|
-
children: /* @__PURE__ */
|
|
2380
|
+
children: /* @__PURE__ */ i(Ue, {})
|
|
2012
2381
|
}
|
|
2013
2382
|
) }),
|
|
2014
|
-
/* @__PURE__ */
|
|
2015
|
-
|
|
2016
|
-
}, "aria-label": "Remove document", children: /* @__PURE__ */
|
|
2383
|
+
/* @__PURE__ */ i(Be, { content: "Remove document", children: /* @__PURE__ */ i(je, { variant: "ghost", size: "1", color: "gray", onClick: () => {
|
|
2384
|
+
f && (++Y.current, v(null), z("empty"), r(t, void 0));
|
|
2385
|
+
}, "aria-label": "Remove document", children: /* @__PURE__ */ i(ct, {}) }) })
|
|
2017
2386
|
] })
|
|
2018
2387
|
] }),
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
|
|
2388
|
+
/* @__PURE__ */ y(F, { align: "center", gap: "2", children: [
|
|
2389
|
+
/* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
|
|
2390
|
+
xe(b),
|
|
2022
2391
|
" max · ",
|
|
2023
|
-
|
|
2392
|
+
Ae(g)
|
|
2024
2393
|
] }),
|
|
2025
|
-
|
|
2026
|
-
var
|
|
2027
|
-
return (
|
|
2028
|
-
}, disabled:
|
|
2029
|
-
|
|
2394
|
+
O && f && /* @__PURE__ */ y(ze, { size: "1", variant: "soft", onClick: () => {
|
|
2395
|
+
var S;
|
|
2396
|
+
return (S = X.current) == null ? void 0 : S.click();
|
|
2397
|
+
}, disabled: D === "parsing", children: [
|
|
2398
|
+
D === "parsing" ? /* @__PURE__ */ i(_e, { size: "1" }) : /* @__PURE__ */ i(Ue, {}),
|
|
2030
2399
|
"Upload"
|
|
2031
2400
|
] })
|
|
2032
2401
|
] })
|
|
2033
2402
|
] }),
|
|
2034
|
-
(
|
|
2035
|
-
/* @__PURE__ */
|
|
2036
|
-
!
|
|
2403
|
+
(O || L) && V && /* @__PURE__ */ i(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: V }),
|
|
2404
|
+
/* @__PURE__ */ i("input", { ref: X, type: "file", style: { display: "none" }, accept: g, onChange: ne }),
|
|
2405
|
+
!O && f && !L && /* @__PURE__ */ i(
|
|
2037
2406
|
"div",
|
|
2038
2407
|
{
|
|
2039
2408
|
role: "button",
|
|
2040
2409
|
tabIndex: 0,
|
|
2041
2410
|
onClick: () => {
|
|
2042
|
-
var
|
|
2043
|
-
return (
|
|
2411
|
+
var S;
|
|
2412
|
+
return (S = X.current) == null ? void 0 : S.click();
|
|
2044
2413
|
},
|
|
2045
|
-
onKeyDown: (
|
|
2046
|
-
var
|
|
2047
|
-
(
|
|
2414
|
+
onKeyDown: (S) => {
|
|
2415
|
+
var K;
|
|
2416
|
+
(S.key === "Enter" || S.key === " ") && (S.preventDefault(), (K = X.current) == null || K.click());
|
|
2048
2417
|
},
|
|
2049
|
-
onDragEnter:
|
|
2050
|
-
onDragLeave:
|
|
2051
|
-
onDragOver:
|
|
2052
|
-
onDrop:
|
|
2418
|
+
onDragEnter: Q,
|
|
2419
|
+
onDragLeave: Q,
|
|
2420
|
+
onDragOver: Q,
|
|
2421
|
+
onDrop: de,
|
|
2053
2422
|
style: { cursor: "pointer" },
|
|
2054
2423
|
className: [
|
|
2055
2424
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
2056
2425
|
"transition-all duration-200 ease-in-out",
|
|
2057
|
-
|
|
2426
|
+
x ? "border-blue-500 bg-blue-50" : V ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
|
|
2058
2427
|
].join(" "),
|
|
2059
|
-
children: /* @__PURE__ */
|
|
2060
|
-
/* @__PURE__ */
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
] }) :
|
|
2063
|
-
/* @__PURE__ */
|
|
2064
|
-
/* @__PURE__ */
|
|
2065
|
-
/* @__PURE__ */
|
|
2066
|
-
] }) : /* @__PURE__ */
|
|
2067
|
-
/* @__PURE__ */
|
|
2068
|
-
/* @__PURE__ */
|
|
2069
|
-
/* @__PURE__ */
|
|
2070
|
-
|
|
2428
|
+
children: /* @__PURE__ */ i(F, { direction: "column", align: "center", gap: "2", children: D === "parsing" ? /* @__PURE__ */ y(ve, { children: [
|
|
2429
|
+
/* @__PURE__ */ i(_e, { size: "3" }),
|
|
2430
|
+
/* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Parsing document…" })
|
|
2431
|
+
] }) : V ? /* @__PURE__ */ y(ve, { children: [
|
|
2432
|
+
/* @__PURE__ */ i(ut, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
|
|
2433
|
+
/* @__PURE__ */ i(h, { size: "2", color: "red", weight: "medium", children: V }),
|
|
2434
|
+
/* @__PURE__ */ i(h, { size: "1", color: "gray", children: "Click to try again" })
|
|
2435
|
+
] }) : /* @__PURE__ */ y(ve, { children: [
|
|
2436
|
+
/* @__PURE__ */ i(Ue, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
|
|
2437
|
+
/* @__PURE__ */ i(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
|
|
2438
|
+
/* @__PURE__ */ y(h, { size: "1", color: "gray", children: [
|
|
2439
|
+
xe(b),
|
|
2071
2440
|
" max · ",
|
|
2072
|
-
|
|
2441
|
+
Ae(g)
|
|
2073
2442
|
] })
|
|
2074
2443
|
] }) })
|
|
2075
2444
|
}
|
|
2076
2445
|
),
|
|
2077
|
-
!
|
|
2446
|
+
!d && /* @__PURE__ */ i(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: we(a, n) })
|
|
2078
2447
|
] });
|
|
2079
|
-
},
|
|
2448
|
+
}, Po = pe($o), _o = te(
|
|
2080
2449
|
10,
|
|
2081
|
-
|
|
2082
|
-
const
|
|
2083
|
-
return e.type === "object" && typeof
|
|
2450
|
+
Me((e) => {
|
|
2451
|
+
const r = e["x-xml"];
|
|
2452
|
+
return e.type === "object" && typeof r == "object" && r !== null;
|
|
2084
2453
|
})
|
|
2085
|
-
)
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2454
|
+
), jo = "root", It = "export.xml", Vo = {
|
|
2455
|
+
format: !0,
|
|
2456
|
+
indentBy: " ",
|
|
2457
|
+
ignoreAttributes: !1,
|
|
2458
|
+
attributeNamePrefix: "@_",
|
|
2459
|
+
textNodeName: "#text",
|
|
2460
|
+
suppressBooleanAttributes: !1,
|
|
2461
|
+
processEntities: !0
|
|
2462
|
+
};
|
|
2463
|
+
function Ho(e) {
|
|
2464
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
2465
|
+
return 'declaration must be an object, e.g. { "standalone": "no" }, or {} for the defaults.';
|
|
2466
|
+
const { version: r, encoding: t, standalone: n, ...l } = e, [o] = Object.keys(l);
|
|
2467
|
+
return o ? `declaration has an unknown key "${o}" — only version, encoding and standalone.` : r !== void 0 && r !== "1.0" && r !== "1.1" ? 'declaration.version must be "1.0" or "1.1".' : t !== void 0 && t !== "UTF-8" ? 'declaration.encoding can only be "UTF-8" — the file is always written as UTF-8.' : n !== void 0 && n !== "yes" && n !== "no" ? 'declaration.standalone must be "yes" or "no".' : null;
|
|
2097
2468
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2469
|
+
function cr(e) {
|
|
2470
|
+
for (const r of e) {
|
|
2471
|
+
if (r === null || typeof r != "object" || Array.isArray(r))
|
|
2472
|
+
return "every writeTo entry must be an object.";
|
|
2473
|
+
const { to: t, writeTo: n } = r, l = lr(r, "export");
|
|
2474
|
+
if (l) return `writeTo "${t}": ${l}`;
|
|
2475
|
+
if (n !== void 0) {
|
|
2476
|
+
if (!Array.isArray(n)) return `writeTo "${t}": its nested writeTo must be an array.`;
|
|
2477
|
+
const o = cr(n);
|
|
2478
|
+
if (o) return o;
|
|
2479
|
+
}
|
|
2103
2480
|
}
|
|
2481
|
+
return null;
|
|
2104
2482
|
}
|
|
2105
|
-
function
|
|
2106
|
-
return e
|
|
2483
|
+
function Wo({ writeTo: e, declaration: r }) {
|
|
2484
|
+
return e === void 0 ? "writeTo is required — see docs/xml-export-control.md." : Array.isArray(e) ? e.length === 0 ? "writeTo is declared but empty — declare at least one entry." : cr(e) ?? (r === void 0 ? null : Ho(r)) : "writeTo must be an array of { from | formula, to } entries.";
|
|
2107
2485
|
}
|
|
2108
|
-
function
|
|
2109
|
-
return
|
|
2486
|
+
function Bo({ version: e = "1.0", standalone: r }) {
|
|
2487
|
+
return { "@_version": e, "@_encoding": "UTF-8", ...r && { "@_standalone": r } };
|
|
2488
|
+
}
|
|
2489
|
+
function Xo(e) {
|
|
2490
|
+
return e == null ? !0 : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1;
|
|
2110
2491
|
}
|
|
2111
|
-
const
|
|
2112
|
-
var
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2492
|
+
const Yo = ({ path: e, label: r, schema: t, visible: n = !0 }) => {
|
|
2493
|
+
var T, R;
|
|
2494
|
+
const l = (t == null ? void 0 : t["x-xml-export"]) ?? {}, o = l.rootElement ?? jo, s = l.fileName ?? It, u = l.writeTo, a = l.writeBase ?? "root", c = l.declaration, d = Wo(l), f = Ve(), p = a === "parent" ? e.split(".").slice(0, -1).join(".") : "", g = p ? Pe.data((T = f.core) == null ? void 0 : T.data, p) : (R = f.core) == null ? void 0 : R.data, [b, M] = j(null), N = Xo(g), U = $e(async () => {
|
|
2495
|
+
if (u) {
|
|
2496
|
+
M(null);
|
|
2497
|
+
try {
|
|
2498
|
+
const I = ar(await ht(g, u, "export")), { XMLBuilder: A } = await import("fast-xml-parser"), D = {
|
|
2499
|
+
...c && { "?xml": Bo(c) },
|
|
2500
|
+
[o]: I
|
|
2501
|
+
}, z = new A(Vo).build(D);
|
|
2502
|
+
Tn(z, ft(s, g, It), "application/xml");
|
|
2503
|
+
} catch (I) {
|
|
2504
|
+
M(I instanceof Error ? I.message : "This export could not be built.");
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
}, [u, g, c, o, s]);
|
|
2508
|
+
return n === !1 ? null : d ? /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
2509
|
+
/* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: r }),
|
|
2510
|
+
/* @__PURE__ */ y(h, { size: "2", color: "red", style: { display: "block" }, children: [
|
|
2511
|
+
"Invalid x-xml-export config: ",
|
|
2512
|
+
d
|
|
2513
|
+
] })
|
|
2514
|
+
] }) : /* @__PURE__ */ y(k, { mb: "4", children: [
|
|
2515
|
+
/* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", style: { display: "block", marginBottom: "var(--space-2)" }, children: r }),
|
|
2516
|
+
/* @__PURE__ */ y(ze, { size: "1", variant: "soft", disabled: N, onClick: () => void U(), children: [
|
|
2517
|
+
/* @__PURE__ */ i(at, {}),
|
|
2518
|
+
"Download XML"
|
|
2519
|
+
] }),
|
|
2520
|
+
b && /* @__PURE__ */ i(h, { size: "2", color: "red", style: { display: "block", marginTop: "var(--space-2)" }, children: b })
|
|
2521
|
+
] });
|
|
2522
|
+
}, Ko = pe(Yo), Go = te(
|
|
2523
|
+
10,
|
|
2524
|
+
Me((e) => {
|
|
2525
|
+
const r = e["x-xml-export"];
|
|
2526
|
+
return e.type === "object" && typeof r == "object" && r !== null;
|
|
2527
|
+
})
|
|
2528
|
+
), qo = "{value}", Jo = 2, Zo = {}, Qo = ({ data: e, handleChange: r, path: t, label: n, schema: l, visible: o = !0 }) => {
|
|
2529
|
+
var D;
|
|
2530
|
+
Re(o, t, r);
|
|
2531
|
+
const s = l == null ? void 0 : l["x-computed"], u = (s == null ? void 0 : s.inputs) ?? Zo, a = (s == null ? void 0 : s.formula) ?? "", c = (s == null ? void 0 : s.format) ?? qo, d = (s == null ? void 0 : s.decimals) ?? Jo, f = Ve(), p = t.split(".").slice(0, -1).join("."), g = So((D = f.core) == null ? void 0 : D.data, p, u), b = g ? JSON.stringify(g) : null, M = f.readonly === !0, [N, U] = j(() => typeof e == "number" ? "ok" : "unavailable"), [T, R] = j(() => typeof e == "number" ? e : null), [I, A] = j(null);
|
|
2532
|
+
return me(() => {
|
|
2533
|
+
if (!o) return;
|
|
2534
|
+
let z = !1;
|
|
2535
|
+
const V = (v) => {
|
|
2536
|
+
M || v !== e && r(t, v);
|
|
2120
2537
|
};
|
|
2121
|
-
if (
|
|
2122
|
-
|
|
2538
|
+
if (g === void 0) {
|
|
2539
|
+
U("unavailable"), A(null), R(null), V(void 0);
|
|
2123
2540
|
return;
|
|
2124
2541
|
}
|
|
2125
|
-
return
|
|
2126
|
-
if (
|
|
2127
|
-
const
|
|
2128
|
-
if (
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
),
|
|
2542
|
+
return U((v) => v === "ok" ? v : "loading"), Oo(g, a).then((v) => {
|
|
2543
|
+
if (z) return;
|
|
2544
|
+
const x = v.status === "ok" && typeof v.value == "number" && Number.isFinite(v.value) ? v.value : null;
|
|
2545
|
+
if (x === null) {
|
|
2546
|
+
U("error"), A(
|
|
2547
|
+
v.status === "error" ? v.error ?? "Unable to compute value." : "Computed value must be a number."
|
|
2548
|
+
), R(null), V(void 0);
|
|
2132
2549
|
return;
|
|
2133
2550
|
}
|
|
2134
|
-
|
|
2551
|
+
U("ok"), A(null), R(x), V(x);
|
|
2135
2552
|
}), () => {
|
|
2136
|
-
|
|
2553
|
+
z = !0;
|
|
2137
2554
|
};
|
|
2138
|
-
}, [
|
|
2139
|
-
/* @__PURE__ */
|
|
2140
|
-
|
|
2141
|
-
/* @__PURE__ */
|
|
2142
|
-
/* @__PURE__ */
|
|
2143
|
-
] }) :
|
|
2144
|
-
|
|
2555
|
+
}, [b, a, o, M]), o === !1 ? null : /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ y(F, { direction: "column", gap: "1", children: [
|
|
2556
|
+
/* @__PURE__ */ i(h, { as: "label", size: "2", weight: "bold", children: n }),
|
|
2557
|
+
N === "unavailable" ? /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Not yet available." }) : N === "loading" ? /* @__PURE__ */ y(F, { align: "center", gap: "2", children: [
|
|
2558
|
+
/* @__PURE__ */ i(_e, { size: "1" }),
|
|
2559
|
+
/* @__PURE__ */ i(h, { size: "2", color: "gray", children: "Computing…" })
|
|
2560
|
+
] }) : N === "error" ? /* @__PURE__ */ i(h, { size: "2", color: "red", children: I }) : /* @__PURE__ */ i(h, { size: "2", children: rt(c, { value: or(T, d) }) }),
|
|
2561
|
+
l.description && /* @__PURE__ */ i(h, { size: "1", color: "gray", children: l.description })
|
|
2145
2562
|
] }) });
|
|
2146
|
-
},
|
|
2563
|
+
}, ei = pe(Qo), ti = te(
|
|
2147
2564
|
5,
|
|
2148
|
-
|
|
2149
|
-
const
|
|
2150
|
-
return e.type === "number" && typeof
|
|
2565
|
+
Me((e) => {
|
|
2566
|
+
const r = e["x-computed"];
|
|
2567
|
+
return e.type === "number" && typeof r == "object" && r !== null;
|
|
2151
2568
|
})
|
|
2152
|
-
),
|
|
2569
|
+
), ur = "seq", kt = 2, ri = (e) => e == null || e === "", dr = (e) => typeof e == "object" && e !== null && !Array.isArray(e) ? e : void 0, ni = (e) => {
|
|
2570
|
+
const r = e == null ? void 0 : e["x-template"];
|
|
2571
|
+
if (typeof r != "object" || r === null) return;
|
|
2572
|
+
const { template: t, inputs: n } = r;
|
|
2573
|
+
if (!(typeof t != "string" || t === ""))
|
|
2574
|
+
return { template: t, inputs: n };
|
|
2575
|
+
}, mt = (e) => typeof e == "object" && e.name === ur && e.arg !== void 0, oi = (e) => e.every((r, t) => !mt(r) || typeof e[t - 1] != "object" && typeof e[t + 1] != "object"), ii = (e) => {
|
|
2576
|
+
const r = /* @__PURE__ */ new Set();
|
|
2577
|
+
for (const t of dt(e))
|
|
2578
|
+
typeof t == "object" && t.arg === void 0 && r.add(t.name);
|
|
2579
|
+
return [...r];
|
|
2580
|
+
}, si = (e) => {
|
|
2581
|
+
const r = [];
|
|
2582
|
+
for (const [t, n] of Object.entries((e == null ? void 0 : e.properties) ?? {})) {
|
|
2583
|
+
const l = ni(n);
|
|
2584
|
+
l && r.push([t, l]);
|
|
2585
|
+
}
|
|
2586
|
+
return r;
|
|
2587
|
+
}, li = (e, r, t) => {
|
|
2588
|
+
var l;
|
|
2589
|
+
const n = {};
|
|
2590
|
+
for (const o of ii(t.template)) {
|
|
2591
|
+
const s = nr(e, r, ((l = t.inputs) == null ? void 0 : l[o]) ?? o);
|
|
2592
|
+
n[o] = typeof s == "string" || typeof s == "number" || typeof s == "boolean" ? String(s) : "";
|
|
2593
|
+
}
|
|
2594
|
+
return n;
|
|
2595
|
+
}, ai = (e) => (r) => {
|
|
2596
|
+
const t = r.trim() === "" ? kt : Number(r);
|
|
2597
|
+
return `${e}`.padStart(Number.isInteger(t) && t >= 0 ? t : kt, "0");
|
|
2598
|
+
}, ci = (e) => {
|
|
2599
|
+
const r = (n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2600
|
+
let t = "";
|
|
2601
|
+
for (const n of dt(e))
|
|
2602
|
+
typeof n == "string" ? t += r(n) : t += mt(n) ? "(\\d+)" : ".*?";
|
|
2603
|
+
return new RegExp(`^${t}$`);
|
|
2604
|
+
}, ui = (e, r, t) => {
|
|
2605
|
+
var o, s;
|
|
2606
|
+
const n = ci(t.template);
|
|
2607
|
+
let l = 0;
|
|
2608
|
+
for (const u of e) {
|
|
2609
|
+
const a = (o = dr(u)) == null ? void 0 : o[r];
|
|
2610
|
+
if (typeof a != "string") continue;
|
|
2611
|
+
const c = Number((s = n.exec(a)) == null ? void 0 : s[1]);
|
|
2612
|
+
Number.isFinite(c) && c > l && (l = c);
|
|
2613
|
+
}
|
|
2614
|
+
return l;
|
|
2615
|
+
}, di = (e, r, t, n, l, o) => {
|
|
2616
|
+
const s = si(e);
|
|
2617
|
+
if (s.length === 0) return r;
|
|
2618
|
+
const u = dr(r);
|
|
2619
|
+
if (!u) return r;
|
|
2620
|
+
const a = { ...u };
|
|
2621
|
+
for (const [c, d] of s) {
|
|
2622
|
+
if (!ri(a[c])) continue;
|
|
2623
|
+
const f = dt(d.template), p = {};
|
|
2624
|
+
if (f.some(mt)) {
|
|
2625
|
+
if (!oi(f)) {
|
|
2626
|
+
console.warn(
|
|
2627
|
+
`x-template: {seq(…)} needs literal text between it and other placeholders; not numbering "${d.template}"`
|
|
2628
|
+
);
|
|
2629
|
+
continue;
|
|
2630
|
+
}
|
|
2631
|
+
const g = Math.max(o[c] ?? 0, ui(t, c, d)) + 1;
|
|
2632
|
+
o[c] = g, p[ur] = ai(g);
|
|
2633
|
+
}
|
|
2634
|
+
a[c] = rt(d.template, li(n, l, d), p);
|
|
2635
|
+
}
|
|
2636
|
+
return a;
|
|
2637
|
+
}, fi = ({ path: e, items: r, itemsSchema: t, rootSchema: n, addItem: l, sequences: o }) => {
|
|
2638
|
+
const s = Ve();
|
|
2639
|
+
return /* @__PURE__ */ i(k, { mt: "2", children: /* @__PURE__ */ y(ze, { type: "button", variant: "surface", onClick: () => {
|
|
2640
|
+
var c;
|
|
2641
|
+
const a = di(
|
|
2642
|
+
t,
|
|
2643
|
+
Ar(t, n),
|
|
2644
|
+
r,
|
|
2645
|
+
(c = s.core) == null ? void 0 : c.data,
|
|
2646
|
+
// The object CONTAINING the array, not the row: a row being filled is
|
|
2647
|
+
// empty, so what a template reaches for sits alongside the array.
|
|
2648
|
+
e.split(".").slice(0, -1).join("."),
|
|
2649
|
+
o.current
|
|
2650
|
+
);
|
|
2651
|
+
l && l(e, a)();
|
|
2652
|
+
}, children: [
|
|
2653
|
+
/* @__PURE__ */ i(kr, {}),
|
|
2654
|
+
"Add Item"
|
|
2655
|
+
] }) });
|
|
2656
|
+
}, pi = ({
|
|
2153
2657
|
data: e,
|
|
2154
|
-
path:
|
|
2155
|
-
schema:
|
|
2156
|
-
uischema:
|
|
2157
|
-
enabled:
|
|
2158
|
-
visible:
|
|
2159
|
-
addItem:
|
|
2160
|
-
removeItems:
|
|
2161
|
-
rootSchema:
|
|
2162
|
-
arraySchema:
|
|
2658
|
+
path: r,
|
|
2659
|
+
schema: t,
|
|
2660
|
+
uischema: n,
|
|
2661
|
+
enabled: l,
|
|
2662
|
+
visible: o,
|
|
2663
|
+
addItem: s,
|
|
2664
|
+
removeItems: u,
|
|
2665
|
+
rootSchema: a,
|
|
2666
|
+
arraySchema: c
|
|
2163
2667
|
}) => {
|
|
2164
|
-
const
|
|
2165
|
-
if (
|
|
2668
|
+
const d = ue({}), f = c ? t : t.items, p = c || t;
|
|
2669
|
+
if (o === !1 || !f || typeof f != "object" || Array.isArray(f))
|
|
2166
2670
|
return null;
|
|
2167
|
-
const
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
}, S = (N) => {
|
|
2171
|
-
if (c) {
|
|
2172
|
-
const D = c(t, [N]);
|
|
2671
|
+
const g = f, b = Array.isArray(e) ? e : [], M = p.title || "Array Items", N = n.options ?? {}, U = l && N.addable !== !1, T = l && N.removable !== !1, R = N.itemLabel || "Item", I = (A) => {
|
|
2672
|
+
if (u) {
|
|
2673
|
+
const D = u(r, [A]);
|
|
2173
2674
|
D && D();
|
|
2174
2675
|
}
|
|
2175
2676
|
};
|
|
2176
|
-
return /* @__PURE__ */
|
|
2177
|
-
/* @__PURE__ */
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
var
|
|
2181
|
-
const
|
|
2182
|
-
return /* @__PURE__ */
|
|
2183
|
-
/* @__PURE__ */
|
|
2184
|
-
/* @__PURE__ */
|
|
2185
|
-
|
|
2677
|
+
return /* @__PURE__ */ i(k, { mb: "6", children: /* @__PURE__ */ y(F, { direction: "column", gap: "4", children: [
|
|
2678
|
+
/* @__PURE__ */ i(h, { as: "div", size: "4", weight: "bold", children: M }),
|
|
2679
|
+
b.length === 0 && /* @__PURE__ */ i(k, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ i(h, { size: "2", color: "gray", children: "No items have been added yet." }) }),
|
|
2680
|
+
b.map((A, D) => {
|
|
2681
|
+
var V;
|
|
2682
|
+
const z = `${r}.${D}`;
|
|
2683
|
+
return /* @__PURE__ */ i(jt, { size: "3", variant: "surface", children: /* @__PURE__ */ y(F, { direction: "column", gap: "4", children: [
|
|
2684
|
+
/* @__PURE__ */ y(F, { justify: "between", align: "center", children: [
|
|
2685
|
+
/* @__PURE__ */ y(h, { size: "3", weight: "bold", children: [
|
|
2686
|
+
R,
|
|
2687
|
+
" ",
|
|
2186
2688
|
D + 1
|
|
2187
2689
|
] }),
|
|
2188
|
-
|
|
2189
|
-
|
|
2690
|
+
T && /* @__PURE__ */ y(
|
|
2691
|
+
ze,
|
|
2190
2692
|
{
|
|
2191
2693
|
type: "button",
|
|
2192
2694
|
color: "red",
|
|
2193
2695
|
variant: "soft",
|
|
2194
|
-
onClick: () =>
|
|
2696
|
+
onClick: () => I(D),
|
|
2195
2697
|
title: "Remove item",
|
|
2196
2698
|
children: [
|
|
2197
|
-
/* @__PURE__ */
|
|
2699
|
+
/* @__PURE__ */ i(Ir, {}),
|
|
2198
2700
|
"Remove"
|
|
2199
2701
|
]
|
|
2200
2702
|
}
|
|
2201
2703
|
)
|
|
2202
2704
|
] }),
|
|
2203
|
-
/* @__PURE__ */
|
|
2204
|
-
|
|
2705
|
+
/* @__PURE__ */ i(k, { children: /* @__PURE__ */ i(
|
|
2706
|
+
Ye,
|
|
2205
2707
|
{
|
|
2206
|
-
schema:
|
|
2207
|
-
uischema: ((
|
|
2708
|
+
schema: g,
|
|
2709
|
+
uischema: ((V = n.options) == null ? void 0 : V.detail) || (g.type === "object" || g.properties ? {
|
|
2208
2710
|
type: "VerticalLayout",
|
|
2209
|
-
elements: Object.keys(
|
|
2711
|
+
elements: Object.keys(g.properties || {}).map((v) => ({
|
|
2210
2712
|
type: "Control",
|
|
2211
|
-
scope: `#/properties/${
|
|
2713
|
+
scope: `#/properties/${v}`
|
|
2212
2714
|
}))
|
|
2213
2715
|
} : {
|
|
2214
2716
|
type: "Control",
|
|
2215
2717
|
scope: "#"
|
|
2216
2718
|
}),
|
|
2217
|
-
path:
|
|
2218
|
-
enabled:
|
|
2719
|
+
path: z,
|
|
2720
|
+
enabled: l,
|
|
2219
2721
|
renderers: void 0,
|
|
2220
2722
|
cells: void 0
|
|
2221
2723
|
}
|
|
2222
2724
|
) })
|
|
2223
|
-
] }) },
|
|
2725
|
+
] }) }, z);
|
|
2224
2726
|
}),
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2727
|
+
U && /* @__PURE__ */ i(
|
|
2728
|
+
fi,
|
|
2729
|
+
{
|
|
2730
|
+
path: r,
|
|
2731
|
+
items: b,
|
|
2732
|
+
itemsSchema: g,
|
|
2733
|
+
rootSchema: a,
|
|
2734
|
+
addItem: s,
|
|
2735
|
+
sequences: d
|
|
2736
|
+
}
|
|
2737
|
+
)
|
|
2229
2738
|
] }) });
|
|
2230
|
-
},
|
|
2231
|
-
const
|
|
2232
|
-
return
|
|
2233
|
-
},
|
|
2234
|
-
{ tester:
|
|
2235
|
-
{ tester:
|
|
2236
|
-
{ tester:
|
|
2237
|
-
{ tester:
|
|
2238
|
-
{ tester:
|
|
2239
|
-
{ tester:
|
|
2240
|
-
{ tester:
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
{ tester:
|
|
2245
|
-
{ tester:
|
|
2246
|
-
{ tester:
|
|
2739
|
+
}, Lt = Sr(pi), hi = te(3, Rr), mi = ({ uischema: e, visible: r }) => {
|
|
2740
|
+
const t = e;
|
|
2741
|
+
return r === !1 ? null : /* @__PURE__ */ i(k, { mb: "4", children: /* @__PURE__ */ i(_t, { size: "4", children: t.text }) });
|
|
2742
|
+
}, gi = te(1, Xe("Label")), yi = te(3, Cr), Oi = [
|
|
2743
|
+
{ tester: Fr, renderer: Ur },
|
|
2744
|
+
{ tester: Pr, renderer: _r },
|
|
2745
|
+
{ tester: Vr, renderer: Hr },
|
|
2746
|
+
{ tester: Br, renderer: Xr },
|
|
2747
|
+
{ tester: on, renderer: nn },
|
|
2748
|
+
{ tester: Kr, renderer: Gr },
|
|
2749
|
+
{ tester: un, renderer: dn },
|
|
2750
|
+
// The layout renderers take their props from withJsonFormsLayoutProps, which
|
|
2751
|
+
// evaluates the layout's rule into `visible` and `enabled`, as
|
|
2752
|
+
// withJsonFormsControlProps does for the controls.
|
|
2753
|
+
{ tester: pn, renderer: Ge(fn) },
|
|
2754
|
+
{ tester: mn, renderer: Ge(hn) },
|
|
2755
|
+
{ tester: yn, renderer: Ge(gn) },
|
|
2756
|
+
{ tester: vn, renderer: Ge(bn) },
|
|
2757
|
+
{ tester: In, renderer: Dn },
|
|
2758
|
+
{ tester: po, renderer: fo },
|
|
2759
|
+
{ tester: wo, renderer: vo },
|
|
2247
2760
|
// After SpreadsheetControl on purpose: both testers rank 10, and a tie is
|
|
2248
2761
|
// resolved by registration order (see XmlControlTester's comment).
|
|
2249
|
-
{ tester:
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
{ tester:
|
|
2762
|
+
{ tester: _o, renderer: Po },
|
|
2763
|
+
// Also rank 10, but matches the distinct `x-xml-export` keyword rather
|
|
2764
|
+
// than `x-xml`, so it never ties with XmlControlTester on the same schema
|
|
2765
|
+
// node (see XmlExportControlTester's own comment).
|
|
2766
|
+
{ tester: Go, renderer: Ko },
|
|
2767
|
+
{ tester: ti, renderer: ei },
|
|
2768
|
+
{ tester: hi, renderer: Lt },
|
|
2769
|
+
{ tester: yi, renderer: Lt },
|
|
2770
|
+
{ tester: gi, renderer: mi }
|
|
2254
2771
|
];
|
|
2255
2772
|
export {
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2773
|
+
Lt as ArrayControl,
|
|
2774
|
+
hi as ArrayControlTester,
|
|
2775
|
+
jr as BooleanControl,
|
|
2776
|
+
Vr as BooleanControlTester,
|
|
2777
|
+
bn as CategorizationLayoutRenderer,
|
|
2778
|
+
vn as CategorizationLayoutTester,
|
|
2779
|
+
ei as ComputedControl,
|
|
2780
|
+
ti as ComputedControlTester,
|
|
2781
|
+
cn as DateControl,
|
|
2782
|
+
un as DateControlTester,
|
|
2783
|
+
Dn as FileControl,
|
|
2784
|
+
In as FileControlTester,
|
|
2785
|
+
gn as GroupLayoutRenderer,
|
|
2786
|
+
yn as GroupLayoutTester,
|
|
2787
|
+
hn as HorizontalLayoutRenderer,
|
|
2788
|
+
mn as HorizontalLayoutTester,
|
|
2789
|
+
mi as LabelRenderer,
|
|
2790
|
+
gi as LabelTester,
|
|
2791
|
+
$r as NumberControl,
|
|
2792
|
+
Pr as NumberControlTester,
|
|
2793
|
+
Wr as RadioControl,
|
|
2794
|
+
Br as RadioControlTester,
|
|
2795
|
+
nn as SearchSelectControl,
|
|
2796
|
+
on as SearchSelectControlTester,
|
|
2797
|
+
Si as SearchServiceProvider,
|
|
2798
|
+
Yr as SelectControl,
|
|
2799
|
+
Kr as SelectControlTester,
|
|
2800
|
+
fo as SpreadsheetControl,
|
|
2801
|
+
po as SpreadsheetControlTester,
|
|
2802
|
+
vo as SpreadsheetExportControl,
|
|
2803
|
+
wo as SpreadsheetExportControlTester,
|
|
2804
|
+
zr as TextControl,
|
|
2805
|
+
Fr as TextControlTester,
|
|
2806
|
+
Ci as UploadProvider,
|
|
2807
|
+
fn as VerticalLayoutRenderer,
|
|
2808
|
+
pn as VerticalLayoutTester,
|
|
2809
|
+
Po as XmlControl,
|
|
2810
|
+
_o as XmlControlTester,
|
|
2811
|
+
Ko as XmlExportControl,
|
|
2812
|
+
Go as XmlExportControlTester,
|
|
2813
|
+
Oi as radixRenderers,
|
|
2814
|
+
Mr as useSearchService,
|
|
2815
|
+
Lr as useUpload
|
|
2295
2816
|
};
|