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