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