@opennsw/jsonforms-renderers 0.8.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/customParseFormat-CLvZwox5.cjs +1 -0
- package/dist/customParseFormat-D14EWdSX.js +150 -0
- package/dist/index.d.ts +4 -0
- package/dist/jsonforms-renderers.css +1 -1
- package/dist/renderers.cjs.js +3 -3
- package/dist/renderers.es.js +1575 -1061
- package/package.json +6 -2
package/dist/renderers.es.js
CHANGED
|
@@ -1,195 +1,194 @@
|
|
|
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 Nn({
|
|
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
|
-
const
|
|
19
|
-
return /* @__PURE__ */ n(
|
|
17
|
+
const o = { onUpload: t, getDownloadUrl: r };
|
|
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
|
-
|
|
38
|
-
e === !1 && r(t,
|
|
39
|
-
}, [e, t, r,
|
|
40
|
-
},
|
|
35
|
+
const ge = (e, t, r, o = void 0) => {
|
|
36
|
+
ue(() => {
|
|
37
|
+
e === !1 && r(t, o);
|
|
38
|
+
}, [e, t, r, o]);
|
|
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,
|
|
46
|
-
label:
|
|
47
|
-
required:
|
|
48
|
-
errors:
|
|
45
|
+
label: o,
|
|
46
|
+
required: u,
|
|
47
|
+
errors: i,
|
|
49
48
|
uischema: l,
|
|
50
|
-
schema:
|
|
51
|
-
enabled:
|
|
52
|
-
visible:
|
|
49
|
+
schema: c,
|
|
50
|
+
enabled: s,
|
|
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__ */
|
|
60
|
-
|
|
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: [
|
|
59
|
+
o,
|
|
61
60
|
" ",
|
|
62
|
-
|
|
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: (
|
|
69
|
-
disabled: !
|
|
70
|
-
placeholder: (
|
|
71
|
-
color:
|
|
67
|
+
onChange: (f) => t(r, f.target.value),
|
|
68
|
+
disabled: !s,
|
|
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,
|
|
82
|
-
label:
|
|
83
|
-
required:
|
|
84
|
-
errors:
|
|
81
|
+
label: o,
|
|
82
|
+
required: u,
|
|
83
|
+
errors: i,
|
|
85
84
|
uischema: l,
|
|
86
|
-
schema:
|
|
87
|
-
enabled:
|
|
88
|
-
visible:
|
|
85
|
+
schema: c,
|
|
86
|
+
enabled: s,
|
|
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__ */
|
|
103
|
-
|
|
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: [
|
|
102
|
+
o,
|
|
104
103
|
" ",
|
|
105
|
-
|
|
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: (
|
|
113
|
-
disabled: !
|
|
114
|
-
placeholder: (
|
|
115
|
-
color:
|
|
111
|
+
onChange: (y) => g(y.target.value),
|
|
112
|
+
disabled: !s,
|
|
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,
|
|
126
|
-
label:
|
|
127
|
-
required:
|
|
128
|
-
errors:
|
|
125
|
+
label: o,
|
|
126
|
+
required: u,
|
|
127
|
+
errors: i,
|
|
129
128
|
schema: l,
|
|
130
|
-
enabled:
|
|
131
|
-
visible:
|
|
129
|
+
enabled: c,
|
|
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__ */
|
|
148
|
-
|
|
146
|
+
/* @__PURE__ */ m(p, { as: "label", size: "2", htmlFor: r, children: [
|
|
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,
|
|
160
|
-
label:
|
|
161
|
-
required:
|
|
162
|
-
errors:
|
|
159
|
+
label: o,
|
|
160
|
+
required: u,
|
|
161
|
+
errors: i,
|
|
163
162
|
schema: l,
|
|
164
|
-
enabled:
|
|
165
|
-
visible:
|
|
163
|
+
enabled: c,
|
|
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__ */
|
|
178
|
-
|
|
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: [
|
|
177
|
+
o,
|
|
179
178
|
" ",
|
|
180
|
-
|
|
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,210 +196,308 @@ const ce = (e, t, r, i = 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
|
-
},
|
|
212
|
-
var
|
|
213
|
-
return
|
|
214
|
-
},
|
|
210
|
+
}, dt = (e, t, r) => {
|
|
211
|
+
var u;
|
|
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,
|
|
218
|
-
label:
|
|
219
|
-
required:
|
|
220
|
-
errors:
|
|
217
|
+
label: o,
|
|
218
|
+
required: u,
|
|
219
|
+
errors: i,
|
|
221
220
|
schema: l,
|
|
222
|
-
uischema:
|
|
223
|
-
enabled:
|
|
224
|
-
visible:
|
|
221
|
+
uischema: c,
|
|
222
|
+
enabled: s,
|
|
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
|
-
|
|
238
|
-
|
|
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: [
|
|
342
|
+
o,
|
|
239
343
|
" ",
|
|
240
|
-
|
|
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: u ? void 0 : "red",
|
|
248
|
-
id: r
|
|
249
|
-
}
|
|
250
|
-
),
|
|
251
|
-
/* @__PURE__ */ n(Ne.Content, { children: y.map((v) => /* @__PURE__ */ n(Ne.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,
|
|
264
|
-
label:
|
|
265
|
-
required:
|
|
266
|
-
errors:
|
|
361
|
+
label: o,
|
|
362
|
+
required: u,
|
|
363
|
+
errors: i,
|
|
267
364
|
enabled: l,
|
|
268
|
-
visible:
|
|
269
|
-
schema:
|
|
270
|
-
uischema:
|
|
365
|
+
visible: c = !0,
|
|
366
|
+
schema: s,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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__ */
|
|
356
|
-
|
|
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: [
|
|
453
|
+
o,
|
|
357
454
|
" ",
|
|
358
|
-
|
|
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:
|
|
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),
|
|
369
466
|
style: W ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
|
|
370
|
-
onChange: (
|
|
371
|
-
|
|
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,341 +511,340 @@ const ce = (e, t, r, i = void 0) => {
|
|
|
414
511
|
border: "1px solid var(--gray-a6)",
|
|
415
512
|
overflow: "hidden"
|
|
416
513
|
},
|
|
417
|
-
children:
|
|
418
|
-
Z && /* @__PURE__ */ n(
|
|
419
|
-
!Z &&
|
|
420
|
-
!Z && !
|
|
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
|
-
he && /* @__PURE__ */ n(
|
|
546
|
+
he && /* @__PURE__ */ n(k, { justify: "center", p: "2", children: /* @__PURE__ */ n(xe, {}) })
|
|
450
547
|
] }) })
|
|
451
548
|
}
|
|
452
549
|
)
|
|
453
550
|
] }),
|
|
454
|
-
!W && /* @__PURE__ */ n(
|
|
455
|
-
|
|
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
|
-
),
|
|
464
|
-
const l =
|
|
465
|
-
return /* @__PURE__ */ n(
|
|
466
|
-
/* @__PURE__ */
|
|
560
|
+
), wt = (e, t) => qr(`${e}T${t}`).format(), Et = ({ path: e, label: t, required: r, errors: o, description: u, children: i }) => {
|
|
561
|
+
const l = o.length === 0;
|
|
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
|
-
|
|
472
|
-
!l && /* @__PURE__ */ n(
|
|
473
|
-
|
|
568
|
+
i,
|
|
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,
|
|
479
|
-
label:
|
|
480
|
-
required:
|
|
481
|
-
errors:
|
|
576
|
+
label: o,
|
|
577
|
+
required: u,
|
|
578
|
+
errors: i,
|
|
482
579
|
schema: l,
|
|
483
|
-
enabled:
|
|
484
|
-
visible:
|
|
580
|
+
enabled: c,
|
|
581
|
+
visible: s = !0
|
|
485
582
|
}) => {
|
|
486
|
-
if (
|
|
487
|
-
|
|
488
|
-
}, [
|
|
583
|
+
if (ue(() => {
|
|
584
|
+
s === !1 && t(r, void 0);
|
|
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,
|
|
543
|
-
renderers:
|
|
544
|
-
cells:
|
|
545
|
-
enabled:
|
|
640
|
+
renderers: o,
|
|
641
|
+
cells: u,
|
|
642
|
+
enabled: i,
|
|
546
643
|
visible: l = !0
|
|
547
644
|
}) => {
|
|
548
|
-
const
|
|
549
|
-
return l === !1 ? null : /* @__PURE__ */ n(
|
|
550
|
-
|
|
645
|
+
const s = e.elements;
|
|
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
|
-
renderers:
|
|
556
|
-
cells:
|
|
557
|
-
enabled:
|
|
652
|
+
renderers: o,
|
|
653
|
+
cells: u,
|
|
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,
|
|
565
|
-
renderers:
|
|
566
|
-
cells:
|
|
567
|
-
enabled:
|
|
662
|
+
renderers: o,
|
|
663
|
+
cells: u,
|
|
664
|
+
enabled: i,
|
|
568
665
|
visible: l = !0
|
|
569
666
|
}) => {
|
|
570
|
-
const
|
|
571
|
-
return l === !1 ? null : /* @__PURE__ */ n(
|
|
572
|
-
|
|
667
|
+
const s = e.elements;
|
|
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
|
-
renderers:
|
|
578
|
-
cells:
|
|
579
|
-
enabled:
|
|
674
|
+
renderers: o,
|
|
675
|
+
cells: u,
|
|
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,
|
|
586
|
-
renderers:
|
|
587
|
-
cells:
|
|
588
|
-
enabled:
|
|
683
|
+
renderers: o,
|
|
684
|
+
cells: u,
|
|
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
|
-
renderers:
|
|
601
|
-
cells:
|
|
602
|
-
enabled:
|
|
697
|
+
renderers: o,
|
|
698
|
+
cells: u,
|
|
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,
|
|
611
|
-
renderers:
|
|
612
|
-
cells:
|
|
613
|
-
enabled:
|
|
708
|
+
renderers: o,
|
|
709
|
+
cells: u,
|
|
710
|
+
enabled: i,
|
|
614
711
|
visible: l = !0
|
|
615
712
|
}) => {
|
|
616
|
-
var
|
|
617
|
-
const
|
|
618
|
-
if (l === !1 || !
|
|
619
|
-
const
|
|
620
|
-
return /* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */ n(
|
|
622
|
-
/* @__PURE__ */ n(
|
|
623
|
-
|
|
713
|
+
var f;
|
|
714
|
+
const s = e.elements.filter((y) => y.type === "Category"), [d, a] = H(((f = s[0]) == null ? void 0 : f.label) || "");
|
|
715
|
+
if (l === !1 || !s.length) return null;
|
|
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
|
-
renderers:
|
|
629
|
-
cells:
|
|
630
|
-
enabled:
|
|
725
|
+
renderers: o,
|
|
726
|
+
cells: u,
|
|
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,
|
|
656
|
-
label:
|
|
657
|
-
required:
|
|
658
|
-
uischema:
|
|
752
|
+
label: o,
|
|
753
|
+
required: u,
|
|
754
|
+
uischema: i,
|
|
659
755
|
schema: l,
|
|
660
|
-
enabled:
|
|
661
|
-
errors:
|
|
662
|
-
visible:
|
|
756
|
+
enabled: c,
|
|
757
|
+
errors: s,
|
|
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
|
|
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
|
-
}, Z = (
|
|
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
|
-
}, he = async (
|
|
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__ */
|
|
742
|
-
|
|
743
|
-
|
|
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: [
|
|
838
|
+
o,
|
|
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 Ct = ({
|
|
|
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 Ct = ({
|
|
|
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,42 +940,42 @@ const Ct = ({
|
|
|
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 i = t ??
|
|
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
957
|
sheetName: i,
|
|
862
|
-
matrix:
|
|
863
|
-
rowCount:
|
|
864
|
-
colCount: Math.max(0, ...
|
|
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
|
-
const
|
|
871
|
-
r = String.fromCharCode(65 +
|
|
966
|
+
const o = (t - 1) % 26;
|
|
967
|
+
r = String.fromCharCode(65 + o) + r, t = Math.floor((t - 1) / 26);
|
|
872
968
|
}
|
|
873
969
|
return r;
|
|
874
970
|
}
|
|
875
|
-
class
|
|
876
|
-
constructor(r,
|
|
877
|
-
super(
|
|
878
|
-
|
|
971
|
+
class oe extends Error {
|
|
972
|
+
constructor(r, o) {
|
|
973
|
+
super(o ?? r);
|
|
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 It = [
|
|
|
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 It = [
|
|
|
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,115 +1031,115 @@ const It = [
|
|
|
935
1031
|
"MID",
|
|
936
1032
|
"FIND",
|
|
937
1033
|
"SEARCH"
|
|
938
|
-
],
|
|
939
|
-
|
|
940
|
-
...
|
|
941
|
-
...
|
|
942
|
-
...
|
|
943
|
-
...
|
|
944
|
-
]),
|
|
945
|
-
function
|
|
946
|
-
const t = e.replace(
|
|
947
|
-
|
|
1034
|
+
], jt = /* @__PURE__ */ new Set([
|
|
1035
|
+
...$t,
|
|
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 =
|
|
950
|
-
const
|
|
951
|
-
if (!
|
|
952
|
-
throw new
|
|
1045
|
+
for (; (r = or.exec(t)) !== null; ) {
|
|
1046
|
+
const o = r[1].toUpperCase();
|
|
1047
|
+
if (!jt.has(o))
|
|
1048
|
+
throw new oe("NAME", `Function ${o} is not allowed.`);
|
|
953
1049
|
}
|
|
954
1050
|
}
|
|
955
|
-
function
|
|
956
|
-
let
|
|
957
|
-
if (
|
|
958
|
-
if (typeof
|
|
959
|
-
if (typeof
|
|
960
|
-
if (typeof
|
|
1051
|
+
function Kt(e, t, r) {
|
|
1052
|
+
let o = e;
|
|
1053
|
+
if (o == null) throw r.NA;
|
|
1054
|
+
if (typeof o == "object" && !(o instanceof r) && (o = t.retrieveRef(o)), o instanceof r) throw o;
|
|
1055
|
+
if (typeof o == "boolean") return o;
|
|
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
|
-
function
|
|
967
|
-
const t =
|
|
1062
|
+
function Ce(e) {
|
|
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
|
|
987
|
-
const r = (
|
|
988
|
-
throw
|
|
989
|
-
},
|
|
990
|
-
const
|
|
1082
|
+
function Yt(e, t) {
|
|
1083
|
+
const r = (i) => {
|
|
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
|
|
997
|
-
},
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
const
|
|
1001
|
-
return
|
|
1091
|
+
const d = i(...s);
|
|
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: (
|
|
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.
|
|
1014
|
-
MAX:
|
|
1015
|
-
MIN:
|
|
1016
|
-
MAXA:
|
|
1017
|
-
MINA:
|
|
1018
|
-
MEDIAN:
|
|
1110
|
+
MAX: o(e.MAX),
|
|
1111
|
+
MIN: o(e.MIN),
|
|
1112
|
+
MAXA: o(e.MAXA),
|
|
1113
|
+
MINA: o(e.MINA),
|
|
1114
|
+
MEDIAN: o(e.MEDIAN),
|
|
1019
1115
|
// COUNTA counts non-blank entries; an error value among the args is
|
|
1020
1116
|
// itself non-blank and gets counted (matching formulajs's own COUNTA,
|
|
1021
1117
|
// which never checks for errors), so this skips the error propagation
|
|
1022
1118
|
// the other aggregates use.
|
|
1023
|
-
COUNTA:
|
|
1024
|
-
LARGE: (
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
return
|
|
1119
|
+
COUNTA: o(e.COUNTA, { checkArgsForErrors: !1 }),
|
|
1120
|
+
LARGE: (i, l) => {
|
|
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
|
-
SMALL: (
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
const
|
|
1034
|
-
return
|
|
1126
|
+
SMALL: (i, l) => {
|
|
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
|
-
PERMUT: (
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1039
|
-
const
|
|
1040
|
-
return
|
|
1132
|
+
PERMUT: (i, l) => {
|
|
1133
|
+
const c = [V(i), V(l)], s = q(c);
|
|
1134
|
+
s && r(s);
|
|
1135
|
+
const d = e.PERMUT(c[0], c[1]);
|
|
1136
|
+
return d instanceof Error ? r(d) : d;
|
|
1041
1137
|
},
|
|
1042
|
-
PERMUTATIONA: (
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1045
|
-
const
|
|
1046
|
-
return
|
|
1138
|
+
PERMUTATIONA: (i, l) => {
|
|
1139
|
+
const c = [V(i), V(l)], s = q(c);
|
|
1140
|
+
s && r(s);
|
|
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
|
|
@@ -1051,43 +1147,43 @@ function $t(e, t) {
|
|
|
1051
1147
|
// Excel's own default too) risks silently mis-ranking unsorted
|
|
1052
1148
|
// real-world data. Same scope decision as the hand-rolled engine this
|
|
1053
1149
|
// replaces, carried forward deliberately rather than dropped.
|
|
1054
|
-
MATCH: (
|
|
1055
|
-
const
|
|
1150
|
+
MATCH: (i, l) => {
|
|
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;
|
|
1155
|
+
},
|
|
1156
|
+
SWITCH: (...i) => {
|
|
1157
|
+
const l = i.map(V), c = q(l);
|
|
1056
1158
|
c && r(c);
|
|
1057
|
-
const
|
|
1058
|
-
return
|
|
1159
|
+
const s = e.SWITCH(...l);
|
|
1160
|
+
return s instanceof Error ? r(s) : s;
|
|
1059
1161
|
},
|
|
1060
|
-
|
|
1061
|
-
const
|
|
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);
|
|
1062
1166
|
a && r(a);
|
|
1063
|
-
const
|
|
1064
|
-
return
|
|
1167
|
+
const g = e.SUBSTITUTE(...d);
|
|
1168
|
+
return g instanceof Error ? r(g) : g;
|
|
1065
1169
|
},
|
|
1066
|
-
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
const y = e.SUBSTITUTE(...c);
|
|
1072
|
-
return y instanceof Error ? r(y) : y;
|
|
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;
|
|
1073
1175
|
},
|
|
1074
|
-
|
|
1075
|
-
const o = X(M(s)), c = M(l), u = a.flatMap(pe).map(X), y = V([o, c]);
|
|
1076
|
-
y && r(y);
|
|
1077
|
-
const p = e.TEXTJOIN(o, c, u);
|
|
1078
|
-
return p instanceof Error ? r(p) : p;
|
|
1079
|
-
},
|
|
1080
|
-
UPPER: f(e.UPPER),
|
|
1176
|
+
UPPER: u(e.UPPER),
|
|
1081
1177
|
// See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
|
|
1082
1178
|
// fast-formula-parser's own (real, but broken-for-Date-cells) versions.
|
|
1083
|
-
YEAR:
|
|
1084
|
-
MONTH:
|
|
1085
|
-
DAY:
|
|
1086
|
-
WEEKDAY: (
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1089
|
-
const
|
|
1090
|
-
return
|
|
1179
|
+
YEAR: u(e.YEAR),
|
|
1180
|
+
MONTH: u(e.MONTH),
|
|
1181
|
+
DAY: u(e.DAY),
|
|
1182
|
+
WEEKDAY: (i, l) => {
|
|
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.
|
|
@@ -1098,54 +1194,54 @@ function $t(e, t) {
|
|
|
1098
1194
|
// Flattens every argument (a whole range included) and joins with no
|
|
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
|
-
CONCATENATE: (...
|
|
1102
|
-
const l =
|
|
1103
|
-
a && r(a);
|
|
1104
|
-
const o = e.CONCATENATE(...l.map(X));
|
|
1105
|
-
return o instanceof Error ? r(o) : o;
|
|
1106
|
-
},
|
|
1107
|
-
CONCAT: (...s) => {
|
|
1108
|
-
const l = s.flatMap(pe), a = V(l);
|
|
1109
|
-
a && r(a);
|
|
1110
|
-
const o = e.CONCAT(...l.map(X));
|
|
1111
|
-
return o instanceof Error ? r(o) : o;
|
|
1112
|
-
},
|
|
1113
|
-
LEN: f(e.LEN, { toText: !0 }),
|
|
1114
|
-
TRIM: f(e.TRIM, { toText: !0 }),
|
|
1115
|
-
LOWER: f(e.LOWER, { toText: !0 }),
|
|
1116
|
-
LEFT: (s, l) => {
|
|
1117
|
-
const a = M(s), o = xe(l), c = V([a]);
|
|
1197
|
+
CONCATENATE: (...i) => {
|
|
1198
|
+
const l = i.flatMap(Ce), c = q(l);
|
|
1118
1199
|
c && r(c);
|
|
1119
|
-
const
|
|
1120
|
-
return
|
|
1200
|
+
const s = e.CONCATENATE(...l.map(ne));
|
|
1201
|
+
return s instanceof Error ? r(s) : s;
|
|
1121
1202
|
},
|
|
1122
|
-
|
|
1123
|
-
const
|
|
1203
|
+
CONCAT: (...i) => {
|
|
1204
|
+
const l = i.flatMap(Ce), c = q(l);
|
|
1124
1205
|
c && r(c);
|
|
1125
|
-
const
|
|
1126
|
-
return
|
|
1206
|
+
const s = e.CONCAT(...l.map(ne));
|
|
1207
|
+
return s instanceof Error ? r(s) : s;
|
|
1208
|
+
},
|
|
1209
|
+
LEN: u(e.LEN, { toText: !0 }),
|
|
1210
|
+
TRIM: u(e.TRIM, { toText: !0 }),
|
|
1211
|
+
LOWER: u(e.LOWER, { toText: !0 }),
|
|
1212
|
+
LEFT: (i, l) => {
|
|
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;
|
|
1217
|
+
},
|
|
1218
|
+
RIGHT: (i, l) => {
|
|
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: (
|
|
1129
|
-
const
|
|
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: (
|
|
1135
|
-
const
|
|
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: (
|
|
1141
|
-
const
|
|
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 _t = {
|
|
|
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
|
|
1176
|
-
const
|
|
1177
|
-
return
|
|
1271
|
+
throw new oe("REF");
|
|
1272
|
+
const o = r[t.col - 1];
|
|
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),
|
|
1183
|
-
if (r > e.length ||
|
|
1184
|
-
throw new
|
|
1185
|
-
const
|
|
1186
|
-
for (let
|
|
1187
|
-
const
|
|
1188
|
-
if (
|
|
1189
|
-
const
|
|
1190
|
-
for (let
|
|
1191
|
-
const
|
|
1192
|
-
|
|
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);
|
|
1279
|
+
if (r > e.length || o > l)
|
|
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
|
-
|
|
1291
|
+
s.push(g);
|
|
1196
1292
|
}
|
|
1197
|
-
return
|
|
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
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
const [
|
|
1305
|
+
if (r === "") throw new oe("ERROR");
|
|
1306
|
+
const o = r.startsWith("=") ? r.slice(1) : r;
|
|
1307
|
+
Xt(o);
|
|
1308
|
+
const [u, i] = await Promise.all([
|
|
1213
1309
|
import("fast-formula-parser"),
|
|
1214
1310
|
import("@formulajs/formulajs")
|
|
1215
|
-
]), l =
|
|
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
|
|
1237
|
-
onVariable: (
|
|
1238
|
-
const
|
|
1239
|
-
return
|
|
1332
|
+
return xr(t, {
|
|
1333
|
+
onVariable: (o) => {
|
|
1334
|
+
const u = r.indexOf(o);
|
|
1335
|
+
return u === -1 ? null : { row: sr, col: u + 1 };
|
|
1240
1336
|
},
|
|
1241
|
-
onCell: (
|
|
1242
|
-
if (
|
|
1243
|
-
throw new
|
|
1337
|
+
onCell: (o) => {
|
|
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!",
|
|
@@ -1257,525 +1353,943 @@ const ur = {
|
|
|
1257
1353
|
NUM: "#NUM!",
|
|
1258
1354
|
NULL: "#NULL!"
|
|
1259
1355
|
};
|
|
1260
|
-
function
|
|
1261
|
-
const t = e instanceof
|
|
1262
|
-
return
|
|
1356
|
+
function qe(e) {
|
|
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
|
|
1276
|
-
} catch (
|
|
1370
|
+
throw new oe("ERROR");
|
|
1371
|
+
return { id: r.id, label: r.label, value: await rn(e, r.expression) };
|
|
1372
|
+
} catch (o) {
|
|
1277
1373
|
return {
|
|
1278
1374
|
id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
|
|
1279
1375
|
label: (r == null ? void 0 : r.label) ?? "(unknown)",
|
|
1280
1376
|
value: null,
|
|
1281
|
-
error:
|
|
1377
|
+
error: qe(o)
|
|
1282
1378
|
};
|
|
1283
1379
|
}
|
|
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 "${i}" — every ${t === "columnHeader" ? "column header" : "column-A value"} must be unique to shape as records.`
|
|
1304
|
-
);
|
|
1305
|
-
r.add(i);
|
|
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
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
return i.forEach((l, a) => {
|
|
1315
|
-
l != null && (s[l] = f[a] ?? null);
|
|
1316
|
-
}), s;
|
|
1424
|
+
function nn(e, t, r) {
|
|
1425
|
+
return (r ? e.slice(1) : e).map((u) => {
|
|
1426
|
+
const i = /* @__PURE__ */ Object.create(null);
|
|
1427
|
+
return t.forEach((l, c) => {
|
|
1428
|
+
i[l.id] = u[c] ?? null;
|
|
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
|
-
|
|
1334
|
-
const
|
|
1335
|
-
for (const { id:
|
|
1336
|
-
|
|
1337
|
-
return
|
|
1445
|
+
function sn(e) {
|
|
1446
|
+
const t = /* @__PURE__ */ Object.create(null);
|
|
1447
|
+
for (const { id: r, label: o, value: u, error: i } of e)
|
|
1448
|
+
t[r] = i === void 0 ? { label: o, value: u } : { label: o, value: u, error: i };
|
|
1449
|
+
return t;
|
|
1338
1450
|
}
|
|
1339
|
-
|
|
1340
|
-
|
|
1451
|
+
function Ye(e, t) {
|
|
1452
|
+
const r = (o) => o instanceof Date ? o.toISOString() : o ?? null;
|
|
1453
|
+
return r(e) === r(t);
|
|
1454
|
+
}
|
|
1455
|
+
function cn(e, t) {
|
|
1456
|
+
const r = e ?? {}, o = t ?? {}, u = Object.keys(r);
|
|
1457
|
+
return u.length !== Object.keys(o).length ? !1 : u.every((i) => {
|
|
1458
|
+
if (!Object.prototype.hasOwnProperty.call(o, i)) return !1;
|
|
1459
|
+
const l = r[i], c = o[i];
|
|
1460
|
+
return l.label === c.label && l.error === c.error && Ye(l.value, c.value);
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
function an(e, t) {
|
|
1464
|
+
if (e == null || t == null) return e === t;
|
|
1465
|
+
const r = Array.isArray(e);
|
|
1466
|
+
if (r !== Array.isArray(t)) return !1;
|
|
1467
|
+
if (r) {
|
|
1468
|
+
const l = e, c = t;
|
|
1469
|
+
return l.length === c.length && l.every((s, d) => Ye(s, c[d]));
|
|
1470
|
+
}
|
|
1471
|
+
const o = e, u = t, i = Object.keys(o);
|
|
1472
|
+
return i.length !== Object.keys(u).length ? !1 : i.every((l) => Object.prototype.hasOwnProperty.call(u, l) && Ye(o[l], u[l]));
|
|
1473
|
+
}
|
|
1474
|
+
function un(e, t) {
|
|
1475
|
+
if (e === t) return !0;
|
|
1476
|
+
if (e == null || t == null) return !1;
|
|
1477
|
+
const r = e, o = t;
|
|
1478
|
+
return r.length !== o.length ? !1 : r.every((u, i) => an(u, o[i]));
|
|
1479
|
+
}
|
|
1480
|
+
function dn(e) {
|
|
1481
|
+
return e === null || typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e instanceof Date;
|
|
1482
|
+
}
|
|
1483
|
+
function fn(e, t) {
|
|
1484
|
+
if (e.length === 0) return [];
|
|
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;
|
|
1497
|
+
})
|
|
1498
|
+
);
|
|
1499
|
+
return [r, ...u];
|
|
1500
|
+
}
|
|
1501
|
+
function hn(e) {
|
|
1502
|
+
const t = Math.max(0, ...e.map((r) => r.length));
|
|
1503
|
+
return Array.from({ length: t }, (r, o) => e.map((u) => u[o] ?? null));
|
|
1504
|
+
}
|
|
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) {
|
|
1341
1507
|
return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1342
1508
|
}
|
|
1343
|
-
const
|
|
1509
|
+
const vn = ({
|
|
1344
1510
|
data: e,
|
|
1345
1511
|
handleChange: t,
|
|
1346
1512
|
path: r,
|
|
1347
|
-
label:
|
|
1348
|
-
required:
|
|
1349
|
-
schema:
|
|
1513
|
+
label: o,
|
|
1514
|
+
required: u,
|
|
1515
|
+
schema: i,
|
|
1350
1516
|
enabled: l,
|
|
1351
|
-
readonly:
|
|
1352
|
-
errors:
|
|
1353
|
-
visible:
|
|
1517
|
+
readonly: c,
|
|
1518
|
+
errors: s,
|
|
1519
|
+
visible: d = !0
|
|
1354
1520
|
}) => {
|
|
1355
|
-
|
|
1356
|
-
const
|
|
1357
|
-
() =>
|
|
1358
|
-
), [
|
|
1359
|
-
|
|
1360
|
-
if (
|
|
1361
|
-
|
|
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;
|
|
1532
|
+
},
|
|
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;
|
|
1545
|
+
return (
|
|
1546
|
+
// This row only renders when hasRows isn't the sole
|
|
1547
|
+
// flag set (see suppressColumnHeaderRow) — so reaching
|
|
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)
|
|
1553
|
+
);
|
|
1554
|
+
})
|
|
1555
|
+
] }) }),
|
|
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: [
|
|
1560
|
+
/* @__PURE__ */ n(
|
|
1561
|
+
ve.RowHeaderCell,
|
|
1562
|
+
{
|
|
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
|
|
1565
|
+
}
|
|
1566
|
+
),
|
|
1567
|
+
se.map((rr) => /* @__PURE__ */ n(ve.Cell, { children: ur(we[rr]) }, rr))
|
|
1568
|
+
] }, Ae);
|
|
1569
|
+
}) })
|
|
1570
|
+
] }) }),
|
|
1571
|
+
X.length > Be && /* @__PURE__ */ m(p, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1572
|
+
"Showing first ",
|
|
1573
|
+
Be,
|
|
1574
|
+
" of ",
|
|
1575
|
+
X.length,
|
|
1576
|
+
" rows"
|
|
1577
|
+
] })
|
|
1578
|
+
] }) });
|
|
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.`);
|
|
1362
1583
|
return;
|
|
1363
1584
|
}
|
|
1364
|
-
if (!
|
|
1365
|
-
|
|
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)}`);
|
|
1366
1587
|
return;
|
|
1367
1588
|
}
|
|
1368
|
-
|
|
1369
|
-
let
|
|
1589
|
+
G("parsing");
|
|
1590
|
+
let F;
|
|
1370
1591
|
try {
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
} catch (
|
|
1374
|
-
|
|
1375
|
-
|
|
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."
|
|
1376
1597
|
);
|
|
1377
1598
|
return;
|
|
1378
1599
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
t(r, ie), W("ready");
|
|
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");
|
|
1388
1608
|
},
|
|
1389
|
-
[
|
|
1609
|
+
[w, L, z, e, O, R, T, S, N, D, M]
|
|
1390
1610
|
);
|
|
1391
|
-
if (
|
|
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);
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
return tn(X, y).then((F) => {
|
|
1624
|
+
if (A) return;
|
|
1625
|
+
let U;
|
|
1626
|
+
if (J != null) {
|
|
1627
|
+
if (E)
|
|
1628
|
+
try {
|
|
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.");
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
} else
|
|
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 });
|
|
1639
|
+
}), () => {
|
|
1640
|
+
A = !0;
|
|
1641
|
+
};
|
|
1642
|
+
}, [P, J, y, g, E, N, D, T, S, $]), d === !1)
|
|
1392
1643
|
return null;
|
|
1393
|
-
if (
|
|
1394
|
-
return /* @__PURE__ */
|
|
1395
|
-
/* @__PURE__ */ n(
|
|
1396
|
-
/* @__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
|
+
] })
|
|
1397
1651
|
] });
|
|
1398
|
-
if (!
|
|
1399
|
-
const
|
|
1400
|
-
|
|
1401
|
-
},
|
|
1402
|
-
var
|
|
1403
|
-
|
|
1404
|
-
},
|
|
1405
|
-
var
|
|
1406
|
-
(
|
|
1407
|
-
},
|
|
1408
|
-
|
|
1409
|
-
},
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
|
|
1417
|
-
i,
|
|
1418
|
-
f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
|
|
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: [
|
|
1668
|
+
o,
|
|
1669
|
+
u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
|
|
1419
1670
|
] }),
|
|
1420
|
-
|
|
1421
|
-
/* @__PURE__ */ n(
|
|
1422
|
-
|
|
1671
|
+
ee && g && /* @__PURE__ */ m(ae, { children: [
|
|
1672
|
+
/* @__PURE__ */ n($e, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
|
|
1673
|
+
ke,
|
|
1423
1674
|
{
|
|
1424
1675
|
variant: "ghost",
|
|
1425
1676
|
size: "1",
|
|
1426
1677
|
onClick: () => {
|
|
1427
|
-
var
|
|
1428
|
-
return (
|
|
1678
|
+
var A;
|
|
1679
|
+
return (A = h.current) == null ? void 0 : A.click();
|
|
1429
1680
|
},
|
|
1430
1681
|
"aria-label": "Replace spreadsheet",
|
|
1431
|
-
children: /* @__PURE__ */ n(
|
|
1682
|
+
children: /* @__PURE__ */ n(Oe, {})
|
|
1432
1683
|
}
|
|
1433
1684
|
) }),
|
|
1434
|
-
/* @__PURE__ */ n(
|
|
1435
|
-
|
|
1685
|
+
/* @__PURE__ */ n($e, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
|
|
1686
|
+
ke,
|
|
1436
1687
|
{
|
|
1437
1688
|
variant: "ghost",
|
|
1438
1689
|
size: "1",
|
|
1439
1690
|
color: "gray",
|
|
1440
|
-
onClick:
|
|
1691
|
+
onClick: He,
|
|
1441
1692
|
"aria-label": "Remove spreadsheet",
|
|
1442
|
-
children: /* @__PURE__ */ n(
|
|
1693
|
+
children: /* @__PURE__ */ n(Je, {})
|
|
1443
1694
|
}
|
|
1444
1695
|
) })
|
|
1445
1696
|
] })
|
|
1446
1697
|
] }),
|
|
1447
|
-
/* @__PURE__ */
|
|
1448
|
-
|
|
1698
|
+
/* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
|
|
1699
|
+
pe(L),
|
|
1449
1700
|
" max · ",
|
|
1450
|
-
|
|
1701
|
+
me(w)
|
|
1451
1702
|
] })
|
|
1452
1703
|
] }),
|
|
1453
|
-
|
|
1454
|
-
/* @__PURE__ */ n("input", { ref:
|
|
1455
|
-
|
|
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(
|
|
1456
1707
|
"div",
|
|
1457
1708
|
{
|
|
1458
1709
|
role: "button",
|
|
1459
1710
|
tabIndex: 0,
|
|
1460
1711
|
onClick: () => {
|
|
1461
|
-
var
|
|
1462
|
-
return (
|
|
1712
|
+
var A;
|
|
1713
|
+
return (A = h.current) == null ? void 0 : A.click();
|
|
1463
1714
|
},
|
|
1464
|
-
onKeyDown: (
|
|
1465
|
-
var
|
|
1466
|
-
(
|
|
1715
|
+
onKeyDown: (A) => {
|
|
1716
|
+
var v;
|
|
1717
|
+
(A.key === "Enter" || A.key === " ") && (A.preventDefault(), (v = h.current) == null || v.click());
|
|
1467
1718
|
},
|
|
1468
|
-
onDragEnter:
|
|
1469
|
-
onDragLeave:
|
|
1470
|
-
onDragOver:
|
|
1471
|
-
onDrop:
|
|
1719
|
+
onDragEnter: Se,
|
|
1720
|
+
onDragLeave: Se,
|
|
1721
|
+
onDragOver: Se,
|
|
1722
|
+
onDrop: Ve,
|
|
1472
1723
|
style: { cursor: "pointer" },
|
|
1473
1724
|
className: [
|
|
1474
1725
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
1475
1726
|
"transition-all duration-200 ease-in-out",
|
|
1476
|
-
|
|
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"
|
|
1477
1728
|
].join(" "),
|
|
1478
|
-
children: /* @__PURE__ */ n(
|
|
1479
|
-
/* @__PURE__ */ n(
|
|
1480
|
-
/* @__PURE__ */ n(
|
|
1481
|
-
] }) :
|
|
1482
|
-
/* @__PURE__ */ n(
|
|
1483
|
-
/* @__PURE__ */ n(
|
|
1484
|
-
/* @__PURE__ */ n(
|
|
1485
|
-
] }) : /* @__PURE__ */
|
|
1486
|
-
/* @__PURE__ */ n(
|
|
1487
|
-
/* @__PURE__ */ n(
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
|
|
1729
|
+
children: /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: K === "parsing" ? /* @__PURE__ */ m(ae, { children: [
|
|
1730
|
+
/* @__PURE__ */ n(xe, { size: "3" }),
|
|
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),
|
|
1490
1741
|
" max · ",
|
|
1491
|
-
|
|
1742
|
+
me(w)
|
|
1492
1743
|
] })
|
|
1493
1744
|
] }) })
|
|
1494
1745
|
}
|
|
1495
1746
|
),
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
// This row only renders when rowHeader isn't the sole
|
|
1504
|
-
// flag set (see suppressColumnHeaderRow) — so reaching
|
|
1505
|
-
// here, either columnHeader is true (real labels) or
|
|
1506
|
-
// both are false (columnLetter fallback).
|
|
1507
|
-
/* @__PURE__ */ n(P.ColumnHeaderCell, { children: w ? Ce((E = Z[0]) == null ? void 0 : E[d]) : Nt(d) }, d)
|
|
1508
|
-
);
|
|
1509
|
-
})
|
|
1510
|
-
] }) }),
|
|
1511
|
-
/* @__PURE__ */ n(P.Body, { children: G.map((d, E) => {
|
|
1512
|
-
var te;
|
|
1513
|
-
const q = _ + E;
|
|
1514
|
-
return /* @__PURE__ */ g(P.Row, { children: [
|
|
1515
|
-
/* @__PURE__ */ n(
|
|
1516
|
-
P.RowHeaderCell,
|
|
1517
|
-
{
|
|
1518
|
-
style: I ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
|
|
1519
|
-
children: I ? Ce((te = Z[q]) == null ? void 0 : te[0]) : w ? "" : q + 1
|
|
1520
|
-
}
|
|
1521
|
-
),
|
|
1522
|
-
Ee.map((ie) => /* @__PURE__ */ n(P.Cell, { children: Ce(d[ie]) }, ie))
|
|
1523
|
-
] }, E);
|
|
1524
|
-
}) })
|
|
1525
|
-
] }) }),
|
|
1526
|
-
Q.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1527
|
-
"Showing first ",
|
|
1528
|
-
ve,
|
|
1529
|
-
" of ",
|
|
1530
|
-
Q.length,
|
|
1531
|
-
" rows"
|
|
1532
|
-
] })
|
|
1533
|
-
] }),
|
|
1534
|
-
re && L && /* @__PURE__ */ g(R, { mt: "3", children: [
|
|
1535
|
-
/* @__PURE__ */ n(R, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g(P.Root, { variant: "surface", size: "1", children: [
|
|
1536
|
-
/* @__PURE__ */ n(P.Header, { children: /* @__PURE__ */ g(P.Row, { children: [
|
|
1537
|
-
/* @__PURE__ */ n(P.ColumnHeaderCell, {}),
|
|
1538
|
-
Re.map((d) => /* @__PURE__ */ n(P.ColumnHeaderCell, { children: d }, d))
|
|
1539
|
-
] }) }),
|
|
1540
|
-
/* @__PURE__ */ n(P.Body, { children: Oe.map((d, E) => /* @__PURE__ */ g(P.Row, { children: [
|
|
1541
|
-
/* @__PURE__ */ n(P.RowHeaderCell, { children: E + 1 }),
|
|
1542
|
-
Re.map((q) => /* @__PURE__ */ n(P.Cell, { children: Ce(d[q]) }, q))
|
|
1543
|
-
] }, E)) })
|
|
1544
|
-
] }) }),
|
|
1545
|
-
re.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1546
|
-
"Showing first ",
|
|
1547
|
-
ve,
|
|
1548
|
-
" of ",
|
|
1549
|
-
re.length,
|
|
1550
|
-
" rows"
|
|
1551
|
-
] })
|
|
1552
|
-
] }),
|
|
1553
|
-
De && /* @__PURE__ */ n(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
|
|
1554
|
-
Object.keys(he).length > 0 && /* @__PURE__ */ g(R, { mt: "3", children: [
|
|
1555
|
-
/* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
|
|
1556
|
-
/* @__PURE__ */ n(S, { direction: "column", gap: "1", children: Object.entries(he).map(([d, E]) => /* @__PURE__ */ g(S, { justify: "between", children: [
|
|
1557
|
-
/* @__PURE__ */ n(h, { size: "2", children: E.label }),
|
|
1558
|
-
E.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: E.error }) : (
|
|
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 }) : (
|
|
1559
1754
|
// d.value is CellValue | null now (SUM/AVERAGE aren't the only
|
|
1560
1755
|
// possible results anymore — INDEX/CONCATENATE can return a
|
|
1561
1756
|
// string, a bare comparison can return a boolean, etc.), so
|
|
1562
1757
|
// `.toLocaleString()` would throw for e.g. a boolean result.
|
|
1563
1758
|
// Reuse the same formatCell used for the sheet-preview grid.
|
|
1564
|
-
/* @__PURE__ */ n(
|
|
1759
|
+
/* @__PURE__ */ n(p, { size: "2", children: ur(v.value) })
|
|
1565
1760
|
)
|
|
1566
|
-
] },
|
|
1761
|
+
] }, A)) })
|
|
1567
1762
|
] }),
|
|
1568
|
-
!
|
|
1763
|
+
!a && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
|
|
1569
1764
|
] });
|
|
1570
|
-
},
|
|
1765
|
+
}, bn = fe(vn), wn = te(
|
|
1571
1766
|
10,
|
|
1572
1767
|
// matches FileControlTester's rank — beats the default object/Group renderer
|
|
1573
|
-
|
|
1768
|
+
De(
|
|
1574
1769
|
(e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
|
|
1575
1770
|
)
|
|
1576
1771
|
);
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1772
|
+
class Ee extends Error {
|
|
1773
|
+
}
|
|
1774
|
+
const dr = 5e6, En = 1024, Rn = /^<\?xml\s+[^>]*\bencoding\s*=\s*["']([^"']+)["']/i, An = {
|
|
1775
|
+
// Default is true, which would silently drop what in many formats is most of
|
|
1776
|
+
// the payload.
|
|
1777
|
+
ignoreAttributes: !1,
|
|
1778
|
+
// Non-empty, so `@_id` and a sibling <id> element can coexist on one node.
|
|
1779
|
+
attributeNamePrefix: "@_",
|
|
1780
|
+
textNodeName: "#text",
|
|
1781
|
+
parseTagValue: !0,
|
|
1782
|
+
// Default is false, which would make <line qty="10"/> a string while
|
|
1783
|
+
// <line><qty>10</qty></line> is a number.
|
|
1784
|
+
parseAttributeValue: !0,
|
|
1785
|
+
// Defaults are hex: true, leadingZeros: true, which turn "00742" into 742 and
|
|
1786
|
+
// "0x1A" into 26 — silent, irreversible corruption of the zero-padded SKUs,
|
|
1787
|
+
// postcodes and invoice refs that fill real XML.
|
|
1788
|
+
numberParseOptions: { hex: !1, leadingZeros: !1, eNotation: !0 },
|
|
1789
|
+
trimValues: !0,
|
|
1790
|
+
// CDATA merges into the node's ordinary text value: whether an author wrapped
|
|
1791
|
+
// a value in CDATA is an encoding detail, not content.
|
|
1792
|
+
cdataPropName: !1,
|
|
1793
|
+
commentPropName: !1,
|
|
1794
|
+
// Enabled so `&` and DOCTYPE-declared entities resolve. Verified against
|
|
1795
|
+
// 5.11.1 and pinned in parse.test.ts: the library refuses external and
|
|
1796
|
+
// parameter entities, caps declarations, and leaves a nested entity reference
|
|
1797
|
+
// literal rather than expanding it — so no XXE or amplification guard of our
|
|
1798
|
+
// own is needed.
|
|
1799
|
+
processEntities: !0,
|
|
1800
|
+
// Default is false. Despite the name, this is what decodes NUMERIC character
|
|
1801
|
+
// references (`é`), which are core XML — left off they persist as
|
|
1802
|
+
// literal text. The HTML named set comes along as a harmless superset.
|
|
1803
|
+
htmlEntities: !0,
|
|
1804
|
+
// Defaults are both false, which injects a `?xml` key of transport metadata
|
|
1805
|
+
// into the document root.
|
|
1806
|
+
ignoreDeclaration: !0,
|
|
1807
|
+
ignorePiTags: !0,
|
|
1808
|
+
// A leaf with no attributes collapses to its bare value, so <qty>10</qty> is
|
|
1809
|
+
// `10`. Only genuinely mixed nodes get a '#text' key.
|
|
1810
|
+
alwaysCreateTextNode: !1,
|
|
1811
|
+
preserveOrder: !1,
|
|
1812
|
+
// Prefixes are kept so <a:Name> and <b:Name> stay distinguishable;
|
|
1813
|
+
// x-xml.removeNamespaces opts out per field, lossily — see docs.
|
|
1814
|
+
removeNSPrefix: !1,
|
|
1815
|
+
// Library defaults, restated because they are load-bearing: the depth bound
|
|
1816
|
+
// is what stops a deeply-nested document overflowing the stack here and in
|
|
1817
|
+
// every recursive consumer downstream.
|
|
1818
|
+
maxNestedTags: 100,
|
|
1819
|
+
strictReservedNames: !0
|
|
1820
|
+
};
|
|
1821
|
+
function Cn(e) {
|
|
1822
|
+
const t = new Set(e);
|
|
1823
|
+
return t.size === 0 ? () => !1 : (r, o) => (
|
|
1824
|
+
// A string while the library's own `jPath` option is true (the default) and
|
|
1825
|
+
// a matcher object otherwise; both stringify to the same dotted path.
|
|
1826
|
+
t.has(typeof o == "string" ? o : o.toString()) || t.has(r)
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1829
|
+
function Tn(e) {
|
|
1830
|
+
const t = e instanceof Error ? e.message : "";
|
|
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.";
|
|
1832
|
+
}
|
|
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.");
|
|
1836
|
+
const r = e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
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).`
|
|
1841
|
+
);
|
|
1842
|
+
const o = (d = Rn.exec(r.slice(0, En))) == null ? void 0 : d[1];
|
|
1843
|
+
if (o && !/^utf-?8$/i.test(o))
|
|
1844
|
+
throw new Ee(
|
|
1845
|
+
`This document declares the unsupported encoding "${o}". Only UTF-8 is supported.`
|
|
1846
|
+
);
|
|
1847
|
+
const { XMLParser: u, XMLValidator: i } = await import("fast-xml-parser"), l = i.validate(r, { allowBooleanAttributes: !1 });
|
|
1848
|
+
if (l !== !0) {
|
|
1849
|
+
const { msg: a, line: g, col: f } = l.err;
|
|
1850
|
+
throw new Ee(`Invalid XML at line ${g}, column ${f}: ${a}`);
|
|
1851
|
+
}
|
|
1852
|
+
const c = new u({
|
|
1853
|
+
...An,
|
|
1854
|
+
removeNSPrefix: t.removeNamespaces === !0,
|
|
1855
|
+
isArray: Cn(t.arrayPaths ?? [])
|
|
1856
|
+
});
|
|
1857
|
+
let s;
|
|
1858
|
+
try {
|
|
1859
|
+
s = c.parse(r);
|
|
1860
|
+
} catch (a) {
|
|
1861
|
+
throw new Ee(Tn(a));
|
|
1862
|
+
}
|
|
1863
|
+
if (s == null || typeof s != "object" || Array.isArray(s))
|
|
1864
|
+
throw new Ee("This document has no root element.");
|
|
1865
|
+
return s;
|
|
1866
|
+
}
|
|
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;
|
|
1870
|
+
}
|
|
1871
|
+
const On = /* @__PURE__ */ new Set(["true", "1", "yes", "y"]), xn = /* @__PURE__ */ new Set(["false", "0", "no", "n"]);
|
|
1872
|
+
async function Nn(e, t) {
|
|
1873
|
+
switch (t.as) {
|
|
1874
|
+
case void 0:
|
|
1875
|
+
return ce(e);
|
|
1876
|
+
case "string":
|
|
1877
|
+
return ce(e instanceof Date ? e.toISOString() : String(e));
|
|
1878
|
+
case "number": {
|
|
1879
|
+
const r = e instanceof Date ? e.getTime() : Number(e);
|
|
1880
|
+
return Number.isFinite(r) ? ce(r) : Te;
|
|
1881
|
+
}
|
|
1882
|
+
case "boolean": {
|
|
1883
|
+
const r = String(e).trim().toLowerCase();
|
|
1884
|
+
return On.has(r) ? ce(!0) : xn.has(r) ? ce(!1) : Te;
|
|
1885
|
+
}
|
|
1886
|
+
case "date": {
|
|
1887
|
+
const { default: r } = await import("dayjs"), { default: o } = await import("./customParseFormat-D14EWdSX.js").then((l) => l.c);
|
|
1888
|
+
r.extend(o);
|
|
1889
|
+
const u = e instanceof Date ? e.toISOString() : String(e), i = t.format ? r(u, t.format, !0) : r(u);
|
|
1890
|
+
return i.isValid() ? ce(i.format("YYYY-MM-DD")) : Te;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
async function In(e, t) {
|
|
1895
|
+
if (t.formula !== void 0) {
|
|
1896
|
+
const r = {};
|
|
1897
|
+
for (const [o, u] of Object.entries(t.inputs ?? {})) {
|
|
1898
|
+
const i = fr(Ke.data(e, u));
|
|
1899
|
+
if (!i.found || Array.isArray(i.value)) return Te;
|
|
1900
|
+
r[o] = i.value;
|
|
1901
|
+
}
|
|
1902
|
+
try {
|
|
1903
|
+
return ce(await Nr(r, t.formula));
|
|
1904
|
+
} catch (o) {
|
|
1905
|
+
throw new Error(`x-xml.writeTo "${t.to}": ${qe(o)}`);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
if (t.from === void 0) throw new Error(`x-xml.writeTo "${t.to}" needs either "from" or "formula".`);
|
|
1909
|
+
return fr(Ke.data(e, t.from));
|
|
1910
|
+
}
|
|
1911
|
+
async function kn(e, t) {
|
|
1912
|
+
const r = [];
|
|
1913
|
+
for (const o of t) {
|
|
1914
|
+
let u = await In(e, o);
|
|
1915
|
+
const i = u.found && Array.isArray(u.value);
|
|
1916
|
+
if (u.found && !i && o.map) {
|
|
1917
|
+
const l = u.value instanceof Date ? u.value.toISOString() : String(u.value);
|
|
1918
|
+
Object.prototype.hasOwnProperty.call(o.map, l) && (u = ce(o.map[l]));
|
|
1919
|
+
}
|
|
1920
|
+
if (u.found && !i && (u = await Nn(u.value, o)), !u.found) {
|
|
1921
|
+
if (o.default === void 0) continue;
|
|
1922
|
+
r.push({ to: o.to, value: o.default });
|
|
1923
|
+
continue;
|
|
1924
|
+
}
|
|
1925
|
+
r.push({ to: o.to, value: u.value });
|
|
1926
|
+
}
|
|
1927
|
+
return r;
|
|
1928
|
+
}
|
|
1929
|
+
const Dn = ".xml,text/xml,application/xml", Mn = 5 * 1024 * 1024, zn = ({
|
|
1930
|
+
data: e,
|
|
1931
|
+
handleChange: t,
|
|
1932
|
+
path: r,
|
|
1933
|
+
label: o,
|
|
1934
|
+
required: u,
|
|
1935
|
+
schema: i,
|
|
1936
|
+
enabled: l,
|
|
1937
|
+
readonly: c,
|
|
1938
|
+
errors: s,
|
|
1939
|
+
visible: d = !0
|
|
1940
|
+
}) => {
|
|
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.`);
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
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)}`);
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
W("parsing");
|
|
1955
|
+
let P;
|
|
1956
|
+
try {
|
|
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."
|
|
1963
|
+
);
|
|
1964
|
+
return;
|
|
1965
|
+
}
|
|
1966
|
+
let Q = [];
|
|
1967
|
+
if (R && R.length > 0)
|
|
1968
|
+
try {
|
|
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.");
|
|
1973
|
+
return;
|
|
1974
|
+
}
|
|
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");
|
|
1980
|
+
},
|
|
1981
|
+
[y, w, L, O, R, T, S, r, t, N]
|
|
1982
|
+
);
|
|
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 = "");
|
|
1992
|
+
};
|
|
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: [
|
|
1997
|
+
o,
|
|
1998
|
+
u && /* @__PURE__ */ n(p, { color: "red", children: " *" })
|
|
1999
|
+
] }),
|
|
2000
|
+
!C && Y && g && /* @__PURE__ */ m(ae, { children: [
|
|
2001
|
+
/* @__PURE__ */ n($e, { content: "Replace document", children: /* @__PURE__ */ n(
|
|
2002
|
+
ke,
|
|
2003
|
+
{
|
|
2004
|
+
variant: "ghost",
|
|
2005
|
+
size: "1",
|
|
2006
|
+
onClick: () => {
|
|
2007
|
+
var h;
|
|
2008
|
+
return (h = G.current) == null ? void 0 : h.click();
|
|
2009
|
+
},
|
|
2010
|
+
"aria-label": "Replace document",
|
|
2011
|
+
children: /* @__PURE__ */ n(Oe, {})
|
|
2012
|
+
}
|
|
2013
|
+
) }),
|
|
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, {}) }) })
|
|
2017
|
+
] })
|
|
2018
|
+
] }),
|
|
2019
|
+
/* @__PURE__ */ m(k, { align: "center", gap: "2", children: [
|
|
2020
|
+
/* @__PURE__ */ m(p, { size: "1", color: "gray", children: [
|
|
2021
|
+
pe(w),
|
|
2022
|
+
" max · ",
|
|
2023
|
+
me(y)
|
|
2024
|
+
] }),
|
|
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, {}),
|
|
2030
|
+
"Upload"
|
|
2031
|
+
] })
|
|
2032
|
+
] })
|
|
2033
|
+
] }),
|
|
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(
|
|
2037
|
+
"div",
|
|
2038
|
+
{
|
|
2039
|
+
role: "button",
|
|
2040
|
+
tabIndex: 0,
|
|
2041
|
+
onClick: () => {
|
|
2042
|
+
var h;
|
|
2043
|
+
return (h = G.current) == null ? void 0 : h.click();
|
|
2044
|
+
},
|
|
2045
|
+
onKeyDown: (h) => {
|
|
2046
|
+
var x;
|
|
2047
|
+
(h.key === "Enter" || h.key === " ") && (h.preventDefault(), (x = G.current) == null || x.click());
|
|
2048
|
+
},
|
|
2049
|
+
onDragEnter: J,
|
|
2050
|
+
onDragLeave: J,
|
|
2051
|
+
onDragOver: J,
|
|
2052
|
+
onDrop: he,
|
|
2053
|
+
style: { cursor: "pointer" },
|
|
2054
|
+
className: [
|
|
2055
|
+
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
2056
|
+
"transition-all duration-200 ease-in-out",
|
|
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"
|
|
2058
|
+
].join(" "),
|
|
2059
|
+
children: /* @__PURE__ */ n(k, { direction: "column", align: "center", gap: "2", children: $ === "parsing" ? /* @__PURE__ */ m(ae, { children: [
|
|
2060
|
+
/* @__PURE__ */ n(xe, { size: "3" }),
|
|
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),
|
|
2071
|
+
" max · ",
|
|
2072
|
+
me(y)
|
|
2073
|
+
] })
|
|
2074
|
+
] }) })
|
|
2075
|
+
}
|
|
2076
|
+
),
|
|
2077
|
+
!a && /* @__PURE__ */ n(p, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: de(s, o) })
|
|
2078
|
+
] });
|
|
2079
|
+
}, Ln = fe(zn), Fn = te(
|
|
2080
|
+
10,
|
|
2081
|
+
De((e) => {
|
|
2082
|
+
const t = e["x-xml"];
|
|
2083
|
+
return e.type === "object" && typeof t == "object" && t !== null;
|
|
2084
|
+
})
|
|
2085
|
+
);
|
|
2086
|
+
function Un(e, t, r) {
|
|
2087
|
+
const o = {};
|
|
2088
|
+
for (const [u, i] of Object.entries(r)) {
|
|
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;
|
|
2092
|
+
o[u] = c;
|
|
1584
2093
|
} else
|
|
1585
|
-
|
|
2094
|
+
o[u] = d;
|
|
1586
2095
|
}
|
|
1587
|
-
return
|
|
2096
|
+
return o;
|
|
1588
2097
|
}
|
|
1589
|
-
async function
|
|
2098
|
+
async function Pn(e, t) {
|
|
1590
2099
|
try {
|
|
1591
|
-
return { status: "ok", value: await
|
|
2100
|
+
return { status: "ok", value: await Nr(e, t) };
|
|
1592
2101
|
} catch (r) {
|
|
1593
|
-
return { status: "error", error:
|
|
2102
|
+
return { status: "error", error: qe(r) };
|
|
1594
2103
|
}
|
|
1595
2104
|
}
|
|
1596
|
-
function
|
|
1597
|
-
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);
|
|
1598
2107
|
}
|
|
1599
|
-
function
|
|
2108
|
+
function _n(e) {
|
|
1600
2109
|
return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
|
|
1601
2110
|
}
|
|
1602
|
-
const
|
|
1603
|
-
var
|
|
1604
|
-
|
|
1605
|
-
const l =
|
|
1606
|
-
return
|
|
1607
|
-
if (!
|
|
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(() => {
|
|
2116
|
+
if (!i) return;
|
|
1608
2117
|
let W = !1;
|
|
1609
|
-
const
|
|
1610
|
-
|
|
2118
|
+
const z = (E) => {
|
|
2119
|
+
L || E !== e && t(r, E);
|
|
1611
2120
|
};
|
|
1612
|
-
if (
|
|
1613
|
-
|
|
2121
|
+
if (y === void 0) {
|
|
2122
|
+
R("unavailable"), D(null), S(null), z(void 0);
|
|
1614
2123
|
return;
|
|
1615
2124
|
}
|
|
1616
|
-
return
|
|
2125
|
+
return R((E) => E === "ok" ? E : "loading"), Pn(y, s).then((E) => {
|
|
1617
2126
|
if (W) return;
|
|
1618
|
-
const
|
|
1619
|
-
if (
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
),
|
|
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);
|
|
1623
2132
|
return;
|
|
1624
2133
|
}
|
|
1625
|
-
|
|
2134
|
+
R("ok"), D(null), S(b), z(b);
|
|
1626
2135
|
}), () => {
|
|
1627
2136
|
W = !0;
|
|
1628
2137
|
};
|
|
1629
|
-
}, [
|
|
1630
|
-
/* @__PURE__ */ n(
|
|
1631
|
-
|
|
1632
|
-
/* @__PURE__ */ n(
|
|
1633
|
-
/* @__PURE__ */ n(
|
|
1634
|
-
] }) :
|
|
1635
|
-
|
|
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: [
|
|
2141
|
+
/* @__PURE__ */ n(xe, { size: "1" }),
|
|
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 })
|
|
1636
2145
|
] }) });
|
|
1637
|
-
},
|
|
2146
|
+
}, jn = fe(Wn), Bn = te(
|
|
1638
2147
|
5,
|
|
1639
|
-
|
|
2148
|
+
De((e) => {
|
|
1640
2149
|
const t = e["x-computed"];
|
|
1641
2150
|
return e.type === "number" && typeof t == "object" && t !== null;
|
|
1642
2151
|
})
|
|
1643
|
-
),
|
|
2152
|
+
), Xn = ({
|
|
1644
2153
|
data: e,
|
|
1645
2154
|
path: t,
|
|
1646
2155
|
schema: r,
|
|
1647
|
-
uischema:
|
|
1648
|
-
enabled:
|
|
1649
|
-
visible:
|
|
2156
|
+
uischema: o,
|
|
2157
|
+
enabled: u,
|
|
2158
|
+
visible: i,
|
|
1650
2159
|
addItem: l,
|
|
1651
|
-
removeItems:
|
|
1652
|
-
rootSchema:
|
|
1653
|
-
arraySchema:
|
|
2160
|
+
removeItems: c,
|
|
2161
|
+
rootSchema: s,
|
|
2162
|
+
arraySchema: d
|
|
1654
2163
|
}) => {
|
|
1655
|
-
const
|
|
1656
|
-
if (
|
|
2164
|
+
const a = d ? r : r.items, g = d || r;
|
|
2165
|
+
if (i === !1 || !a || typeof a != "object" || Array.isArray(a))
|
|
1657
2166
|
return null;
|
|
1658
|
-
const
|
|
1659
|
-
const
|
|
1660
|
-
l && l(t,
|
|
1661
|
-
},
|
|
1662
|
-
if (
|
|
1663
|
-
const
|
|
1664
|
-
|
|
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();
|
|
1665
2174
|
}
|
|
1666
2175
|
};
|
|
1667
|
-
return /* @__PURE__ */ n(
|
|
1668
|
-
/* @__PURE__ */ n(
|
|
1669
|
-
|
|
1670
|
-
|
|
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) => {
|
|
1671
2180
|
var W;
|
|
1672
|
-
const
|
|
1673
|
-
return /* @__PURE__ */ n(
|
|
1674
|
-
/* @__PURE__ */
|
|
1675
|
-
/* @__PURE__ */
|
|
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: [
|
|
1676
2185
|
"Item ",
|
|
1677
|
-
|
|
2186
|
+
D + 1
|
|
1678
2187
|
] }),
|
|
1679
|
-
|
|
1680
|
-
|
|
2188
|
+
R && /* @__PURE__ */ m(
|
|
2189
|
+
Ie,
|
|
1681
2190
|
{
|
|
1682
2191
|
type: "button",
|
|
1683
2192
|
color: "red",
|
|
1684
2193
|
variant: "soft",
|
|
1685
|
-
onClick: () =>
|
|
2194
|
+
onClick: () => S(D),
|
|
1686
2195
|
title: "Remove item",
|
|
1687
2196
|
children: [
|
|
1688
|
-
/* @__PURE__ */ n(
|
|
2197
|
+
/* @__PURE__ */ n(Jr, {}),
|
|
1689
2198
|
"Remove"
|
|
1690
2199
|
]
|
|
1691
2200
|
}
|
|
1692
2201
|
)
|
|
1693
2202
|
] }),
|
|
1694
|
-
/* @__PURE__ */ n(
|
|
1695
|
-
|
|
2203
|
+
/* @__PURE__ */ n(I, { children: /* @__PURE__ */ n(
|
|
2204
|
+
ze,
|
|
1696
2205
|
{
|
|
1697
|
-
schema:
|
|
1698
|
-
uischema: ((W =
|
|
2206
|
+
schema: f,
|
|
2207
|
+
uischema: ((W = o.options) == null ? void 0 : W.detail) || (f.type === "object" || f.properties ? {
|
|
1699
2208
|
type: "VerticalLayout",
|
|
1700
|
-
elements: Object.keys(
|
|
2209
|
+
elements: Object.keys(f.properties || {}).map((z) => ({
|
|
1701
2210
|
type: "Control",
|
|
1702
|
-
scope: `#/properties/${
|
|
2211
|
+
scope: `#/properties/${z}`
|
|
1703
2212
|
}))
|
|
1704
2213
|
} : {
|
|
1705
2214
|
type: "Control",
|
|
1706
2215
|
scope: "#"
|
|
1707
2216
|
}),
|
|
1708
|
-
path:
|
|
1709
|
-
enabled:
|
|
2217
|
+
path: $,
|
|
2218
|
+
enabled: u,
|
|
1710
2219
|
renderers: void 0,
|
|
1711
2220
|
cells: void 0
|
|
1712
2221
|
}
|
|
1713
2222
|
) })
|
|
1714
|
-
] }) },
|
|
2223
|
+
] }) }, $);
|
|
1715
2224
|
}),
|
|
1716
|
-
|
|
1717
|
-
/* @__PURE__ */ n(
|
|
2225
|
+
O && /* @__PURE__ */ n(I, { mt: "2", children: /* @__PURE__ */ m(Ie, { type: "button", variant: "surface", onClick: T, children: [
|
|
2226
|
+
/* @__PURE__ */ n(Zr, {}),
|
|
1718
2227
|
"Add Item"
|
|
1719
2228
|
] }) })
|
|
1720
2229
|
] }) });
|
|
1721
|
-
},
|
|
2230
|
+
}, pr = Xr(Xn), Kn = te(3, jr), Gn = ({ uischema: e, visible: t }) => {
|
|
1722
2231
|
const r = e;
|
|
1723
|
-
return t === !1 ? null : /* @__PURE__ */ n(
|
|
1724
|
-
},
|
|
1725
|
-
{ tester:
|
|
1726
|
-
{ tester:
|
|
1727
|
-
{ tester:
|
|
1728
|
-
{ tester:
|
|
1729
|
-
{ tester: ct, renderer: st },
|
|
1730
|
-
{ tester: nt, renderer: ot },
|
|
1731
|
-
{ tester: ft, renderer: ht },
|
|
1732
|
-
{ tester: mt, renderer: pt },
|
|
1733
|
-
{ tester: yt, renderer: gt },
|
|
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 },
|
|
1734
2238
|
{ tester: bt, renderer: vt },
|
|
1735
|
-
{ tester:
|
|
1736
|
-
{ tester: At, renderer:
|
|
1737
|
-
{ tester:
|
|
1738
|
-
{ tester:
|
|
1739
|
-
{ tester:
|
|
1740
|
-
{ tester:
|
|
1741
|
-
{ tester:
|
|
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 },
|
|
2244
|
+
{ tester: Dt, renderer: kt },
|
|
2245
|
+
{ tester: Ft, renderer: Lt },
|
|
2246
|
+
{ tester: wn, renderer: bn },
|
|
2247
|
+
// After SpreadsheetControl on purpose: both testers rank 10, and a tie is
|
|
2248
|
+
// resolved by registration order (see XmlControlTester's comment).
|
|
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 }
|
|
1742
2254
|
];
|
|
1743
2255
|
export {
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
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
|
|
1781
2295
|
};
|