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