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