@opennsw/jsonforms-renderers 0.6.0 → 0.7.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 +4 -0
- package/dist/jsonforms-renderers.css +1 -1
- package/dist/renderers.cjs.js +2 -2
- package/dist/renderers.es.js +1064 -860
- package/package.json +1 -1
package/dist/renderers.es.js
CHANGED
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var Pe = (e, t, r) =>
|
|
4
|
-
import { jsx as n, jsxs as
|
|
5
|
-
import { useContext as
|
|
6
|
-
import { rankWith as W, isStringControl as
|
|
7
|
-
import { withJsonFormsControlProps as
|
|
8
|
-
import { Box as C, Flex as
|
|
9
|
-
import { ChevronDownIcon as
|
|
10
|
-
import
|
|
11
|
-
import { read as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
1
|
+
var mr = Object.defineProperty;
|
|
2
|
+
var gr = (e, t, r) => t in e ? mr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var Pe = (e, t, r) => gr(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsx as n, jsxs as g, Fragment as be } from "react/jsx-runtime";
|
|
5
|
+
import { useContext as Ze, createContext as Qe, useMemo as yr, useEffect as fe, useState as F, useRef as de, useCallback as _e } from "react";
|
|
6
|
+
import { rankWith as W, isStringControl as vr, or as Le, isNumberControl as br, isIntegerControl as wr, isBooleanControl as Er, isEnumControl as er, isOneOfControl as rr, schemaMatches as ze, isDateControl as Rr, isDateTimeControl as Cr, isTimeControl as Tr, uiTypeIs as Te, and as Ar, Resolve as Sr, createDefaultValue as Or, isObjectArrayControl as Nr, isPrimitiveArrayControl as Ir } from "@jsonforms/core";
|
|
7
|
+
import { withJsonFormsControlProps as se, JsonFormsDispatch as Ae, useJsonForms as xr, withJsonFormsArrayControlProps as Mr } from "@jsonforms/react";
|
|
8
|
+
import { Box as C, Flex as S, Text as h, TextField as ye, Checkbox as kr, RadioGroup as Ve, Select as Ne, ScrollArea as Lr, Spinner as Me, Button as ke, Tabs as Ie, Heading as tr, Card as nr, IconButton as Ue, Tooltip as We, Table as $ } from "@radix-ui/themes";
|
|
9
|
+
import { ChevronDownIcon as zr, FileTextIcon as Dr, CheckCircledIcon as Fr, Cross2Icon as or, ExclamationTriangleIcon as lr, UploadIcon as He, TrashIcon as Ur, PlusIcon as Hr } from "@radix-ui/react-icons";
|
|
10
|
+
import $r from "dayjs";
|
|
11
|
+
import { read as _r, utils as Pr } from "@e965/xlsx";
|
|
12
|
+
const ir = Qe(null);
|
|
13
|
+
function Nn({
|
|
14
14
|
children: e,
|
|
15
15
|
onUpload: t,
|
|
16
16
|
getDownloadUrl: r
|
|
17
17
|
}) {
|
|
18
|
-
const
|
|
19
|
-
return /* @__PURE__ */ n(
|
|
18
|
+
const i = { onUpload: t, getDownloadUrl: r };
|
|
19
|
+
return /* @__PURE__ */ n(ir.Provider, { value: i, children: e });
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function Vr() {
|
|
22
|
+
return Ze(ir);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
function
|
|
24
|
+
const sr = Qe(null);
|
|
25
|
+
function In({
|
|
26
26
|
children: e,
|
|
27
27
|
services: t
|
|
28
28
|
}) {
|
|
29
|
-
const r =
|
|
30
|
-
return /* @__PURE__ */ n(
|
|
29
|
+
const r = yr(() => t, [t]);
|
|
30
|
+
return /* @__PURE__ */ n(sr.Provider, { value: r, children: e });
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const t =
|
|
32
|
+
function Wr(e) {
|
|
33
|
+
const t = Ze(sr);
|
|
34
34
|
return !t || !e ? null : t[e] ?? null;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
e === !1 && r(t,
|
|
39
|
-
}, [e, t, r,
|
|
40
|
-
},
|
|
36
|
+
const ce = (e, t, r, i = void 0) => {
|
|
37
|
+
fe(() => {
|
|
38
|
+
e === !1 && r(t, i);
|
|
39
|
+
}, [e, t, r, i]);
|
|
40
|
+
}, ae = (e, t) => e ? e.split(`
|
|
41
41
|
`).map((r) => r.trim() === "is a required property" ? `${t || "This field"} is required` : r).join(`
|
|
42
|
-
`) : "",
|
|
42
|
+
`) : "", Br = ({
|
|
43
43
|
data: e,
|
|
44
44
|
handleChange: t,
|
|
45
45
|
path: r,
|
|
46
|
-
label:
|
|
47
|
-
required:
|
|
48
|
-
errors:
|
|
49
|
-
uischema:
|
|
50
|
-
schema:
|
|
46
|
+
label: i,
|
|
47
|
+
required: f,
|
|
48
|
+
errors: s,
|
|
49
|
+
uischema: l,
|
|
50
|
+
schema: a,
|
|
51
51
|
enabled: o,
|
|
52
|
-
visible:
|
|
52
|
+
visible: c = !0
|
|
53
53
|
}) => {
|
|
54
54
|
var y;
|
|
55
|
-
if (
|
|
55
|
+
if (ce(c, r, t), c === !1)
|
|
56
56
|
return null;
|
|
57
|
-
const
|
|
58
|
-
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */
|
|
60
|
-
|
|
57
|
+
const u = s.length === 0;
|
|
58
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
59
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
60
|
+
i,
|
|
61
61
|
" ",
|
|
62
|
-
|
|
62
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
63
63
|
] }),
|
|
64
64
|
/* @__PURE__ */ n(
|
|
65
|
-
|
|
65
|
+
ye.Root,
|
|
66
66
|
{
|
|
67
67
|
value: e || "",
|
|
68
|
-
onChange: (
|
|
68
|
+
onChange: (p) => t(r, p.target.value),
|
|
69
69
|
disabled: !o,
|
|
70
|
-
placeholder: (y =
|
|
71
|
-
color:
|
|
70
|
+
placeholder: (y = l.options) == null ? void 0 : y.placeholder,
|
|
71
|
+
color: u ? void 0 : "red",
|
|
72
72
|
id: r
|
|
73
73
|
}
|
|
74
74
|
),
|
|
75
|
-
!
|
|
76
|
-
|
|
75
|
+
!u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
|
|
76
|
+
a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
|
|
77
77
|
] }) });
|
|
78
|
-
},
|
|
78
|
+
}, Kr = W(1, vr), Gr = se(Br), Xr = ({
|
|
79
79
|
data: e,
|
|
80
80
|
handleChange: t,
|
|
81
81
|
path: r,
|
|
82
|
-
label:
|
|
83
|
-
required:
|
|
84
|
-
errors:
|
|
85
|
-
uischema:
|
|
86
|
-
schema:
|
|
82
|
+
label: i,
|
|
83
|
+
required: f,
|
|
84
|
+
errors: s,
|
|
85
|
+
uischema: l,
|
|
86
|
+
schema: a,
|
|
87
87
|
enabled: o,
|
|
88
|
-
visible:
|
|
88
|
+
visible: c = !0
|
|
89
89
|
}) => {
|
|
90
|
-
var
|
|
91
|
-
if (
|
|
90
|
+
var p;
|
|
91
|
+
if (ce(c, r, t), c === !1)
|
|
92
92
|
return null;
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
93
|
+
const u = s.length === 0, y = (m) => {
|
|
94
|
+
if (m === "") {
|
|
95
95
|
t(r, void 0);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
const v = Number(
|
|
98
|
+
const v = Number(m);
|
|
99
99
|
isNaN(v) || t(r, v);
|
|
100
100
|
};
|
|
101
|
-
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */
|
|
103
|
-
|
|
101
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
102
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
103
|
+
i,
|
|
104
104
|
" ",
|
|
105
|
-
|
|
105
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
106
106
|
] }),
|
|
107
107
|
/* @__PURE__ */ n(
|
|
108
|
-
|
|
108
|
+
ye.Root,
|
|
109
109
|
{
|
|
110
110
|
type: "number",
|
|
111
111
|
value: e ?? "",
|
|
112
|
-
onChange: (
|
|
112
|
+
onChange: (m) => y(m.target.value),
|
|
113
113
|
disabled: !o,
|
|
114
|
-
placeholder: (
|
|
115
|
-
color:
|
|
114
|
+
placeholder: (p = l.options) == null ? void 0 : p.placeholder,
|
|
115
|
+
color: u ? void 0 : "red",
|
|
116
116
|
id: r
|
|
117
117
|
}
|
|
118
118
|
),
|
|
119
|
-
!
|
|
120
|
-
|
|
119
|
+
!u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
|
|
120
|
+
a.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: a.description })
|
|
121
121
|
] }) });
|
|
122
|
-
},
|
|
122
|
+
}, jr = W(2, Le(br, wr)), Yr = se(Xr), Jr = ({
|
|
123
123
|
data: e,
|
|
124
124
|
handleChange: t,
|
|
125
125
|
path: r,
|
|
126
|
-
label:
|
|
127
|
-
required:
|
|
128
|
-
errors:
|
|
129
|
-
schema:
|
|
130
|
-
enabled:
|
|
126
|
+
label: i,
|
|
127
|
+
required: f,
|
|
128
|
+
errors: s,
|
|
129
|
+
schema: l,
|
|
130
|
+
enabled: a,
|
|
131
131
|
visible: o = !0
|
|
132
132
|
}) => {
|
|
133
|
-
if (
|
|
133
|
+
if (ce(o, r, t), o === !1)
|
|
134
134
|
return null;
|
|
135
|
-
const
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
135
|
+
const c = s.length === 0;
|
|
136
|
+
return /* @__PURE__ */ g(C, { mb: "4", children: [
|
|
137
|
+
/* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
|
|
138
138
|
/* @__PURE__ */ n(
|
|
139
|
-
|
|
139
|
+
kr,
|
|
140
140
|
{
|
|
141
141
|
checked: !!e,
|
|
142
|
-
onCheckedChange: (
|
|
143
|
-
disabled: !
|
|
142
|
+
onCheckedChange: (u) => t(r, u === !0),
|
|
143
|
+
disabled: !a,
|
|
144
144
|
id: r
|
|
145
145
|
}
|
|
146
146
|
),
|
|
147
|
-
/* @__PURE__ */
|
|
148
|
-
|
|
147
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
|
|
148
|
+
i,
|
|
149
149
|
" ",
|
|
150
|
-
|
|
150
|
+
f && "*"
|
|
151
151
|
] })
|
|
152
152
|
] }),
|
|
153
|
-
!
|
|
154
|
-
|
|
153
|
+
!c && /* @__PURE__ */ n(h, { color: "red", size: "1", className: "block mt-1", children: ae(s, i) }),
|
|
154
|
+
l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", className: "block mt-1", children: l.description })
|
|
155
155
|
] });
|
|
156
|
-
},
|
|
156
|
+
}, qr = W(2, Er), Zr = se(Jr), Qr = ({
|
|
157
157
|
data: e,
|
|
158
158
|
handleChange: t,
|
|
159
159
|
path: r,
|
|
160
|
-
label:
|
|
161
|
-
required:
|
|
162
|
-
errors:
|
|
163
|
-
schema:
|
|
164
|
-
enabled:
|
|
160
|
+
label: i,
|
|
161
|
+
required: f,
|
|
162
|
+
errors: s,
|
|
163
|
+
schema: l,
|
|
164
|
+
enabled: a,
|
|
165
165
|
visible: o = !0
|
|
166
166
|
}) => {
|
|
167
|
-
if (
|
|
167
|
+
if (ce(o, r, t), o === !1)
|
|
168
168
|
return null;
|
|
169
|
-
const
|
|
170
|
-
let
|
|
171
|
-
|
|
172
|
-
value:
|
|
173
|
-
label:
|
|
169
|
+
const c = s.length === 0;
|
|
170
|
+
let u = [];
|
|
171
|
+
l.enum ? u = l.enum.map((p) => ({ value: p, label: String(p) })) : l.oneOf && (u = l.oneOf.map((p) => ({
|
|
172
|
+
value: p.const,
|
|
173
|
+
label: p.title || String(p.const)
|
|
174
174
|
})));
|
|
175
175
|
const y = e;
|
|
176
|
-
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
|
|
176
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
177
|
+
/* @__PURE__ */ g(h, { as: "div", size: "2", weight: "bold", children: [
|
|
178
|
+
i,
|
|
179
179
|
" ",
|
|
180
|
-
|
|
180
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
181
181
|
] }),
|
|
182
182
|
/* @__PURE__ */ n(
|
|
183
183
|
Ve.Root,
|
|
184
184
|
{
|
|
185
185
|
value: y !== void 0 ? String(y) : "",
|
|
186
|
-
onValueChange: (
|
|
187
|
-
const
|
|
188
|
-
|
|
186
|
+
onValueChange: (p) => {
|
|
187
|
+
const m = u.find((v) => String(v.value) === p);
|
|
188
|
+
m && t(r, m.value);
|
|
189
189
|
},
|
|
190
|
-
disabled: !
|
|
190
|
+
disabled: !a,
|
|
191
191
|
children: /* @__PURE__ */ n(
|
|
192
|
-
|
|
192
|
+
S,
|
|
193
193
|
{
|
|
194
194
|
direction: "row",
|
|
195
195
|
style: {
|
|
@@ -197,209 +197,209 @@ const ue = (e, t, r, d = void 0) => {
|
|
|
197
197
|
columnGap: "clamp(14px, 3vw, 36px)",
|
|
198
198
|
rowGap: "clamp(8px, 1.6vw, 14px)"
|
|
199
199
|
},
|
|
200
|
-
children:
|
|
201
|
-
/* @__PURE__ */ n(Ve.Item, { value: String(
|
|
202
|
-
/* @__PURE__ */ n(
|
|
203
|
-
] }, String(
|
|
200
|
+
children: u.map((p) => /* @__PURE__ */ g(S, { align: "center", gap: "2", style: { minWidth: "max-content" }, children: [
|
|
201
|
+
/* @__PURE__ */ n(Ve.Item, { value: String(p.value) }),
|
|
202
|
+
/* @__PURE__ */ n(h, { size: "2", color: a ? void 0 : "gray", children: p.label })
|
|
203
|
+
] }, String(p.value)))
|
|
204
204
|
}
|
|
205
205
|
)
|
|
206
206
|
}
|
|
207
207
|
),
|
|
208
|
-
!
|
|
209
|
-
|
|
208
|
+
!c && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
|
|
209
|
+
l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
|
|
210
210
|
] }) });
|
|
211
|
-
},
|
|
212
|
-
var
|
|
213
|
-
return
|
|
214
|
-
},
|
|
211
|
+
}, et = (e, t, r) => {
|
|
212
|
+
var f;
|
|
213
|
+
return Le(er, rr)(e, t, r) && ((f = e == null ? void 0 : e.options) == null ? void 0 : f.format) === "radio" ? 3 : -1;
|
|
214
|
+
}, rt = se(Qr), tt = ({
|
|
215
215
|
data: e,
|
|
216
216
|
handleChange: t,
|
|
217
217
|
path: r,
|
|
218
|
-
label:
|
|
219
|
-
required:
|
|
220
|
-
errors:
|
|
221
|
-
schema:
|
|
222
|
-
uischema:
|
|
218
|
+
label: i,
|
|
219
|
+
required: f,
|
|
220
|
+
errors: s,
|
|
221
|
+
schema: l,
|
|
222
|
+
uischema: a,
|
|
223
223
|
enabled: o,
|
|
224
|
-
visible:
|
|
224
|
+
visible: c = !0
|
|
225
225
|
}) => {
|
|
226
|
-
var
|
|
227
|
-
if (
|
|
226
|
+
var m;
|
|
227
|
+
if (ce(c, r, t), c === !1)
|
|
228
228
|
return null;
|
|
229
|
-
const
|
|
229
|
+
const u = s.length === 0;
|
|
230
230
|
let y = [];
|
|
231
|
-
|
|
231
|
+
l.enum ? y = l.enum.map((v) => ({ value: String(v), label: String(v) })) : l.oneOf && (y = l.oneOf.map((v) => ({
|
|
232
232
|
value: String(v.const),
|
|
233
233
|
label: v.title || String(v.const)
|
|
234
234
|
})));
|
|
235
|
-
const
|
|
236
|
-
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
|
|
235
|
+
const p = e !== void 0 ? String(e) : "";
|
|
236
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
237
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
238
|
+
i,
|
|
239
239
|
" ",
|
|
240
|
-
|
|
240
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
241
241
|
] }),
|
|
242
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ g(Ne.Root, { value: p, onValueChange: (v) => t(r, v), disabled: !o, children: [
|
|
243
243
|
/* @__PURE__ */ n(
|
|
244
|
-
|
|
244
|
+
Ne.Trigger,
|
|
245
245
|
{
|
|
246
|
-
placeholder: ((
|
|
247
|
-
color:
|
|
246
|
+
placeholder: ((m = a.options) == null ? void 0 : m.placeholder) || "Select an option",
|
|
247
|
+
color: u ? void 0 : "red",
|
|
248
248
|
id: r
|
|
249
249
|
}
|
|
250
250
|
),
|
|
251
|
-
/* @__PURE__ */ n(
|
|
251
|
+
/* @__PURE__ */ n(Ne.Content, { children: y.map((v) => /* @__PURE__ */ n(Ne.Item, { value: v.value, children: v.label }, v.value)) })
|
|
252
252
|
] }),
|
|
253
|
-
!
|
|
254
|
-
|
|
253
|
+
!u && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
|
|
254
|
+
l.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: l.description })
|
|
255
255
|
] }) });
|
|
256
|
-
},
|
|
256
|
+
}, nt = W(2, Le(er, rr)), ot = se(tt), lt = {
|
|
257
257
|
"small-list": { fetchOnOpen: !0, searchable: !1, paginated: !1 },
|
|
258
258
|
"large-searchable-list": { fetchOnOpen: !0, searchable: !0, paginated: !1 },
|
|
259
259
|
"large-paginated-list": { fetchOnOpen: !1, searchable: !0, paginated: !0 }
|
|
260
|
-
},
|
|
260
|
+
}, it = ({
|
|
261
261
|
data: e,
|
|
262
262
|
handleChange: t,
|
|
263
263
|
path: r,
|
|
264
|
-
label:
|
|
265
|
-
required:
|
|
266
|
-
errors:
|
|
267
|
-
enabled:
|
|
268
|
-
visible:
|
|
264
|
+
label: i,
|
|
265
|
+
required: f,
|
|
266
|
+
errors: s,
|
|
267
|
+
enabled: l,
|
|
268
|
+
visible: a = !0,
|
|
269
269
|
schema: o,
|
|
270
|
-
uischema:
|
|
270
|
+
uischema: c
|
|
271
271
|
}) => {
|
|
272
|
-
var
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
var
|
|
276
|
-
if (!
|
|
277
|
-
|
|
272
|
+
var Re;
|
|
273
|
+
const u = (o == null ? void 0 : o["x-search"]) ?? { service: "" }, y = u.service ?? "", p = u.mode ?? "large-paginated-list", m = lt[p], v = (m == null ? void 0 : m.fetchOnOpen) ?? !1, N = u.params, A = Wr(y), w = o.type === "object", R = w ? typeof e == "string" ? { value: e } : e ?? void 0 : void 0, L = w ? R == null ? void 0 : R.value : e, P = R == null ? void 0 : R.label, I = y ? A ? m ? null : `Invalid x-search.mode "${p}". Expected "small-list", "large-searchable-list", or "large-paginated-list".` : `Search service "${y}" is not registered.` : "Search not configured.", B = l !== !1, j = !s || s.length === 0, [M, O] = F(!1), [D, V] = F(""), [oe, ee] = F([]), [le, Y] = F(!1), [Z, re] = F(!1), [he, ne] = F(!1), [ue, b] = F(null), [k, U] = F(void 0), T = de(void 0), H = de(null), J = de(null), Q = de(null), K = de(void 0);
|
|
274
|
+
fe(() => {
|
|
275
|
+
var E, q;
|
|
276
|
+
if (!L) {
|
|
277
|
+
U(void 0), K.current = void 0;
|
|
278
278
|
return;
|
|
279
279
|
}
|
|
280
|
-
if (((
|
|
281
|
-
if (
|
|
282
|
-
|
|
280
|
+
if (((E = K.current) == null ? void 0 : E.value) === L && ((q = K.current) == null ? void 0 : q.label) === P) return;
|
|
281
|
+
if (K.current = { value: L, label: P }, w && P) {
|
|
282
|
+
U({ id: L, name: P });
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
|
-
if (
|
|
286
|
-
let
|
|
287
|
-
return A.resolve(
|
|
288
|
-
!
|
|
285
|
+
if (U({ id: L, name: P ?? L }), !(A != null && A.resolve)) return;
|
|
286
|
+
let d = !1;
|
|
287
|
+
return A.resolve(L, N).then((te) => {
|
|
288
|
+
!d && te && U(te);
|
|
289
289
|
}).catch(() => {
|
|
290
290
|
}), () => {
|
|
291
|
-
|
|
291
|
+
d = !0;
|
|
292
292
|
};
|
|
293
|
-
}, [
|
|
294
|
-
const
|
|
295
|
-
async (
|
|
296
|
-
var
|
|
293
|
+
}, [L, P, w, A, N]);
|
|
294
|
+
const we = _e(
|
|
295
|
+
async (d, E = !1) => {
|
|
296
|
+
var te;
|
|
297
297
|
if (!A) {
|
|
298
298
|
b("Search service not configured.");
|
|
299
299
|
return;
|
|
300
300
|
}
|
|
301
|
-
(
|
|
302
|
-
const
|
|
303
|
-
|
|
301
|
+
(te = J.current) == null || te.abort();
|
|
302
|
+
const q = new AbortController();
|
|
303
|
+
J.current = q, E ? ne(!0) : (re(!0), ne(!1), b(null));
|
|
304
304
|
try {
|
|
305
|
-
const
|
|
306
|
-
query:
|
|
307
|
-
cursor:
|
|
308
|
-
signal:
|
|
309
|
-
params:
|
|
310
|
-
}),
|
|
311
|
-
|
|
305
|
+
const ie = await A.search({
|
|
306
|
+
query: d,
|
|
307
|
+
cursor: E ? T.current : void 0,
|
|
308
|
+
signal: q.signal,
|
|
309
|
+
params: N
|
|
310
|
+
}), z = ie.options ?? [];
|
|
311
|
+
ee(E ? (pr) => [...pr, ...z] : z), T.current = ie.nextCursor, Y(((m == null ? void 0 : m.paginated) ?? !1) && ie.nextCursor != null);
|
|
312
312
|
} catch {
|
|
313
|
-
if (
|
|
313
|
+
if (q.signal.aborted) return;
|
|
314
314
|
b("Failed to load results. Please try again.");
|
|
315
315
|
} finally {
|
|
316
|
-
|
|
316
|
+
q.signal.aborted || (E ? ne(!1) : re(!1));
|
|
317
317
|
}
|
|
318
318
|
},
|
|
319
|
-
[A,
|
|
319
|
+
[A, m == null ? void 0 : m.paginated, N]
|
|
320
320
|
);
|
|
321
|
-
if (
|
|
322
|
-
if (!
|
|
323
|
-
const
|
|
324
|
-
|
|
321
|
+
if (fe(() => {
|
|
322
|
+
if (!M) return;
|
|
323
|
+
const d = (E) => {
|
|
324
|
+
Q.current && !Q.current.contains(E.target) && O(!1);
|
|
325
325
|
};
|
|
326
|
-
return document.addEventListener("mousedown",
|
|
327
|
-
}, [
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
}, [
|
|
331
|
-
if (!
|
|
332
|
-
if (!
|
|
333
|
-
|
|
326
|
+
return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
|
|
327
|
+
}, [M]), fe(() => {
|
|
328
|
+
var d;
|
|
329
|
+
M || ((d = J.current) == null || d.abort(), V(""), ee([]), Y(!1), b(null), re(!1), ne(!1), T.current = void 0);
|
|
330
|
+
}, [M]), fe(() => {
|
|
331
|
+
if (!M) return;
|
|
332
|
+
if (!D && !v) {
|
|
333
|
+
ee([]), Y(!1), b(null), T.current = void 0;
|
|
334
334
|
return;
|
|
335
335
|
}
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
return
|
|
339
|
-
|
|
340
|
-
},
|
|
341
|
-
|
|
336
|
+
H.current && clearTimeout(H.current);
|
|
337
|
+
const d = D ? 300 : 0;
|
|
338
|
+
return H.current = setTimeout(() => {
|
|
339
|
+
ee([]), Y(!1), T.current = void 0, we(D);
|
|
340
|
+
}, d), () => {
|
|
341
|
+
H.current && clearTimeout(H.current);
|
|
342
342
|
};
|
|
343
|
-
}, [
|
|
343
|
+
}, [D, M, v, we]), ce(a, r, t, w ? void 0 : null), a === !1)
|
|
344
344
|
return null;
|
|
345
345
|
const Ee = () => {
|
|
346
|
-
V(""),
|
|
347
|
-
},
|
|
348
|
-
t(r, w ? { value:
|
|
349
|
-
},
|
|
350
|
-
|
|
351
|
-
},
|
|
352
|
-
(
|
|
353
|
-
},
|
|
354
|
-
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
|
|
346
|
+
V(""), ee([]), Y(!1), b(null), T.current = void 0, O(!0);
|
|
347
|
+
}, De = (d) => {
|
|
348
|
+
t(r, w ? { value: d.id, label: d.name } : d.id), U(d), K.current = { value: d.id, label: w ? d.name : void 0 }, O(!1);
|
|
349
|
+
}, Se = (d) => {
|
|
350
|
+
d.stopPropagation(), t(r, w ? void 0 : null), U(void 0);
|
|
351
|
+
}, Fe = (d) => {
|
|
352
|
+
(d.key === "Enter" || d.key === " ") && Se(d);
|
|
353
|
+
}, Oe = ((Re = c == null ? void 0 : c.options) == null ? void 0 : Re.placeholder) ?? "Select an option";
|
|
354
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
355
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
356
|
+
i,
|
|
357
357
|
" ",
|
|
358
|
-
|
|
358
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
359
359
|
] }),
|
|
360
|
-
/* @__PURE__ */
|
|
360
|
+
/* @__PURE__ */ g("div", { ref: Q, style: { position: "relative" }, children: [
|
|
361
361
|
/* @__PURE__ */ n(
|
|
362
|
-
|
|
362
|
+
ye.Root,
|
|
363
363
|
{
|
|
364
364
|
id: r,
|
|
365
|
-
value:
|
|
366
|
-
placeholder:
|
|
367
|
-
disabled: !
|
|
368
|
-
readOnly:
|
|
369
|
-
style:
|
|
370
|
-
onChange: (
|
|
371
|
-
|
|
365
|
+
value: M ? D : (k == null ? void 0 : k.name) ?? "",
|
|
366
|
+
placeholder: M && (m != null && m.searchable) ? "Search..." : Oe,
|
|
367
|
+
disabled: !B,
|
|
368
|
+
readOnly: M && !(m != null && m.searchable),
|
|
369
|
+
style: j ? void 0 : { outline: "2px solid var(--red-7)", outlineOffset: "-1px" },
|
|
370
|
+
onChange: (d) => {
|
|
371
|
+
m != null && m.searchable && (V(d.target.value), M || Ee());
|
|
372
372
|
},
|
|
373
373
|
onFocus: () => {
|
|
374
|
-
|
|
374
|
+
B && !M && Ee();
|
|
375
375
|
},
|
|
376
|
-
onKeyDown: (
|
|
377
|
-
|
|
376
|
+
onKeyDown: (d) => {
|
|
377
|
+
d.key === "Escape" && O(!1);
|
|
378
378
|
},
|
|
379
|
-
children: /* @__PURE__ */ n(
|
|
380
|
-
|
|
379
|
+
children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
|
|
380
|
+
L && B && /* @__PURE__ */ n(
|
|
381
381
|
"span",
|
|
382
382
|
{
|
|
383
383
|
role: "button",
|
|
384
384
|
tabIndex: 0,
|
|
385
|
-
onMouseDown: (
|
|
386
|
-
onClick:
|
|
387
|
-
onKeyDown:
|
|
385
|
+
onMouseDown: (d) => d.preventDefault(),
|
|
386
|
+
onClick: Se,
|
|
387
|
+
onKeyDown: Fe,
|
|
388
388
|
style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
|
|
389
389
|
"aria-label": "Clear selection",
|
|
390
390
|
children: "×"
|
|
391
391
|
}
|
|
392
392
|
),
|
|
393
393
|
/* @__PURE__ */ n(
|
|
394
|
-
|
|
394
|
+
zr,
|
|
395
395
|
{
|
|
396
|
-
style: { transform:
|
|
396
|
+
style: { transform: M ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
|
|
397
397
|
}
|
|
398
398
|
)
|
|
399
399
|
] }) })
|
|
400
400
|
}
|
|
401
401
|
),
|
|
402
|
-
|
|
402
|
+
M && /* @__PURE__ */ n(
|
|
403
403
|
C,
|
|
404
404
|
{
|
|
405
405
|
style: {
|
|
@@ -414,229 +414,229 @@ const ue = (e, t, r, d = void 0) => {
|
|
|
414
414
|
border: "1px solid var(--gray-a6)",
|
|
415
415
|
overflow: "hidden"
|
|
416
416
|
},
|
|
417
|
-
children:
|
|
418
|
-
|
|
419
|
-
!
|
|
420
|
-
!
|
|
421
|
-
|
|
417
|
+
children: I ? /* @__PURE__ */ n(C, { p: "3", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: I }) }) : /* @__PURE__ */ n(Lr, { style: { maxHeight: 240 }, children: /* @__PURE__ */ g(C, { p: "1", children: [
|
|
418
|
+
Z && /* @__PURE__ */ n(S, { justify: "center", p: "4", children: /* @__PURE__ */ n(Me, {}) }),
|
|
419
|
+
!Z && ue && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "red", children: ue }) }),
|
|
420
|
+
!Z && !ue && oe.length === 0 && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: D || v ? "No results found." : "Type to search…" }) }),
|
|
421
|
+
oe.map((d) => /* @__PURE__ */ n(
|
|
422
422
|
C,
|
|
423
423
|
{
|
|
424
424
|
px: "3",
|
|
425
425
|
py: "2",
|
|
426
|
-
onMouseDown: (
|
|
427
|
-
onClick: () =>
|
|
426
|
+
onMouseDown: (E) => E.preventDefault(),
|
|
427
|
+
onClick: () => De(d),
|
|
428
428
|
style: {
|
|
429
429
|
cursor: "pointer",
|
|
430
430
|
borderRadius: "var(--radius-2)",
|
|
431
|
-
backgroundColor:
|
|
431
|
+
backgroundColor: d.id === L ? "var(--accent-3)" : void 0
|
|
432
432
|
},
|
|
433
433
|
className: "hover:bg-(--gray-3)",
|
|
434
|
-
children: /* @__PURE__ */ n(
|
|
434
|
+
children: /* @__PURE__ */ n(h, { size: "2", children: d.name })
|
|
435
435
|
},
|
|
436
|
-
|
|
436
|
+
d.id
|
|
437
437
|
)),
|
|
438
|
-
(
|
|
439
|
-
|
|
438
|
+
(m == null ? void 0 : m.paginated) && le && !he && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(
|
|
439
|
+
ke,
|
|
440
440
|
{
|
|
441
441
|
variant: "ghost",
|
|
442
442
|
size: "1",
|
|
443
443
|
style: { width: "100%" },
|
|
444
|
-
onMouseDown: (
|
|
445
|
-
onClick: () => void
|
|
444
|
+
onMouseDown: (d) => d.preventDefault(),
|
|
445
|
+
onClick: () => void we(D, !0),
|
|
446
446
|
children: "Load more"
|
|
447
447
|
}
|
|
448
448
|
) }),
|
|
449
|
-
|
|
449
|
+
he && /* @__PURE__ */ n(S, { justify: "center", p: "2", children: /* @__PURE__ */ n(Me, {}) })
|
|
450
450
|
] }) })
|
|
451
451
|
}
|
|
452
452
|
)
|
|
453
453
|
] }),
|
|
454
|
-
!
|
|
455
|
-
o.description && /* @__PURE__ */ n(
|
|
454
|
+
!j && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
|
|
455
|
+
o.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: o.description })
|
|
456
456
|
] }) });
|
|
457
|
-
},
|
|
457
|
+
}, st = se(it), ct = W(
|
|
458
458
|
3,
|
|
459
|
-
|
|
459
|
+
ze((e) => {
|
|
460
460
|
const t = e["x-search"];
|
|
461
461
|
return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
|
|
462
462
|
})
|
|
463
|
-
),
|
|
464
|
-
const
|
|
465
|
-
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */
|
|
466
|
-
/* @__PURE__ */
|
|
463
|
+
), at = (e, t) => $r(`${e}T${t}`).format(), ut = ({ path: e, label: t, required: r, errors: i, description: f, children: s }) => {
|
|
464
|
+
const l = i.length === 0;
|
|
465
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
466
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
|
|
467
467
|
t,
|
|
468
468
|
" ",
|
|
469
|
-
r && /* @__PURE__ */ n(
|
|
469
|
+
r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
470
470
|
] }),
|
|
471
|
-
|
|
472
|
-
!
|
|
473
|
-
|
|
471
|
+
s,
|
|
472
|
+
!l && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(i, t) }),
|
|
473
|
+
f && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f })
|
|
474
474
|
] }) });
|
|
475
|
-
},
|
|
475
|
+
}, dt = ({
|
|
476
476
|
data: e,
|
|
477
477
|
handleChange: t,
|
|
478
478
|
path: r,
|
|
479
|
-
label:
|
|
480
|
-
required:
|
|
481
|
-
errors:
|
|
482
|
-
schema:
|
|
483
|
-
enabled:
|
|
479
|
+
label: i,
|
|
480
|
+
required: f,
|
|
481
|
+
errors: s,
|
|
482
|
+
schema: l,
|
|
483
|
+
enabled: a,
|
|
484
484
|
visible: o = !0
|
|
485
485
|
}) => {
|
|
486
|
-
if (
|
|
486
|
+
if (fe(() => {
|
|
487
487
|
o === !1 && t(r, void 0);
|
|
488
488
|
}, [o, r, t]), o === !1)
|
|
489
489
|
return null;
|
|
490
|
-
const
|
|
491
|
-
if (
|
|
490
|
+
const c = s.length === 0, u = typeof e == "string" ? e : "", y = (w) => /* @__PURE__ */ n(ut, { path: r, label: i, required: f, errors: s, description: l.description, children: w });
|
|
491
|
+
if (l.format === "time")
|
|
492
492
|
return y(
|
|
493
493
|
/* @__PURE__ */ n(
|
|
494
|
-
|
|
494
|
+
ye.Root,
|
|
495
495
|
{
|
|
496
496
|
type: "time",
|
|
497
|
-
value:
|
|
497
|
+
value: u,
|
|
498
498
|
onChange: (w) => t(r, w.target.value),
|
|
499
|
-
disabled: !
|
|
500
|
-
color:
|
|
499
|
+
disabled: !a,
|
|
500
|
+
color: c ? void 0 : "red",
|
|
501
501
|
id: r
|
|
502
502
|
}
|
|
503
503
|
)
|
|
504
504
|
);
|
|
505
|
-
const
|
|
505
|
+
const p = l.format === "date-time", [m = "", v = ""] = u.split("T"), N = v.slice(0, 5), A = (w, R) => {
|
|
506
506
|
if (!w) {
|
|
507
507
|
t(r, void 0);
|
|
508
508
|
return;
|
|
509
509
|
}
|
|
510
|
-
t(r,
|
|
510
|
+
t(r, p ? at(w, R || "00:00") : w);
|
|
511
511
|
};
|
|
512
512
|
return y(
|
|
513
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
|
|
514
514
|
/* @__PURE__ */ n(
|
|
515
|
-
|
|
515
|
+
ye.Root,
|
|
516
516
|
{
|
|
517
517
|
type: "date",
|
|
518
|
-
value:
|
|
519
|
-
disabled: !
|
|
520
|
-
color:
|
|
521
|
-
onChange: (w) => A(w.target.value,
|
|
518
|
+
value: m,
|
|
519
|
+
disabled: !a,
|
|
520
|
+
color: c ? void 0 : "red",
|
|
521
|
+
onChange: (w) => A(w.target.value, N),
|
|
522
522
|
id: r,
|
|
523
523
|
style: { flex: 1 }
|
|
524
524
|
}
|
|
525
525
|
),
|
|
526
|
-
|
|
527
|
-
|
|
526
|
+
p && /* @__PURE__ */ n(
|
|
527
|
+
ye.Root,
|
|
528
528
|
{
|
|
529
529
|
type: "time",
|
|
530
|
-
value:
|
|
531
|
-
disabled: !
|
|
532
|
-
color:
|
|
533
|
-
onChange: (w) => A(
|
|
530
|
+
value: N,
|
|
531
|
+
disabled: !a || !m,
|
|
532
|
+
color: c ? void 0 : "red",
|
|
533
|
+
onChange: (w) => A(m, w.target.value),
|
|
534
534
|
style: { flex: 1 }
|
|
535
535
|
}
|
|
536
536
|
)
|
|
537
537
|
] })
|
|
538
538
|
);
|
|
539
|
-
},
|
|
539
|
+
}, ft = W(2, Le(Rr, Cr, Tr)), ht = se(dt), pt = ({
|
|
540
540
|
uischema: e,
|
|
541
541
|
schema: t,
|
|
542
542
|
path: r,
|
|
543
|
-
renderers:
|
|
544
|
-
cells:
|
|
545
|
-
enabled:
|
|
546
|
-
visible:
|
|
543
|
+
renderers: i,
|
|
544
|
+
cells: f,
|
|
545
|
+
enabled: s,
|
|
546
|
+
visible: l = !0
|
|
547
547
|
}) => {
|
|
548
548
|
const o = e.elements;
|
|
549
|
-
return
|
|
550
|
-
|
|
549
|
+
return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
|
|
550
|
+
Ae,
|
|
551
551
|
{
|
|
552
|
-
uischema:
|
|
552
|
+
uischema: c,
|
|
553
553
|
schema: t,
|
|
554
554
|
path: r,
|
|
555
|
-
renderers:
|
|
556
|
-
cells:
|
|
557
|
-
enabled:
|
|
555
|
+
renderers: i,
|
|
556
|
+
cells: f,
|
|
557
|
+
enabled: s
|
|
558
558
|
},
|
|
559
|
-
`${r}-${
|
|
559
|
+
`${r}-${u}`
|
|
560
560
|
)) });
|
|
561
|
-
},
|
|
561
|
+
}, mt = W(1, Te("VerticalLayout")), gt = ({
|
|
562
562
|
uischema: e,
|
|
563
563
|
schema: t,
|
|
564
564
|
path: r,
|
|
565
|
-
renderers:
|
|
566
|
-
cells:
|
|
567
|
-
enabled:
|
|
568
|
-
visible:
|
|
565
|
+
renderers: i,
|
|
566
|
+
cells: f,
|
|
567
|
+
enabled: s,
|
|
568
|
+
visible: l = !0
|
|
569
569
|
}) => {
|
|
570
570
|
const o = e.elements;
|
|
571
|
-
return
|
|
572
|
-
|
|
571
|
+
return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "row", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(C, { style: { flex: 1 }, children: /* @__PURE__ */ n(
|
|
572
|
+
Ae,
|
|
573
573
|
{
|
|
574
|
-
uischema:
|
|
574
|
+
uischema: c,
|
|
575
575
|
schema: t,
|
|
576
576
|
path: r,
|
|
577
|
-
renderers:
|
|
578
|
-
cells:
|
|
579
|
-
enabled:
|
|
577
|
+
renderers: i,
|
|
578
|
+
cells: f,
|
|
579
|
+
enabled: s
|
|
580
580
|
}
|
|
581
|
-
) }, `${r}-${
|
|
582
|
-
},
|
|
581
|
+
) }, `${r}-${u}`)) });
|
|
582
|
+
}, yt = W(1, Te("HorizontalLayout")), vt = ({
|
|
583
583
|
uischema: e,
|
|
584
584
|
schema: t,
|
|
585
585
|
path: r,
|
|
586
|
-
renderers:
|
|
587
|
-
cells:
|
|
588
|
-
enabled:
|
|
589
|
-
visible:
|
|
586
|
+
renderers: i,
|
|
587
|
+
cells: f,
|
|
588
|
+
enabled: s,
|
|
589
|
+
visible: l = !0
|
|
590
590
|
}) => {
|
|
591
|
-
const
|
|
592
|
-
return
|
|
593
|
-
|
|
594
|
-
/* @__PURE__ */ n(
|
|
595
|
-
|
|
591
|
+
const a = e, o = a.elements;
|
|
592
|
+
return l === !1 ? null : /* @__PURE__ */ g(C, { mb: "6", children: [
|
|
593
|
+
a.label && /* @__PURE__ */ n(tr, { size: "3", mb: "3", className: "text-gray-500 uppercase tracking-wide font-semibold", children: a.label }),
|
|
594
|
+
/* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
|
|
595
|
+
Ae,
|
|
596
596
|
{
|
|
597
|
-
uischema:
|
|
597
|
+
uischema: c,
|
|
598
598
|
schema: t,
|
|
599
599
|
path: r,
|
|
600
|
-
renderers:
|
|
601
|
-
cells:
|
|
602
|
-
enabled:
|
|
600
|
+
renderers: i,
|
|
601
|
+
cells: f,
|
|
602
|
+
enabled: s
|
|
603
603
|
},
|
|
604
|
-
`${r}-${
|
|
604
|
+
`${r}-${u}`
|
|
605
605
|
)) })
|
|
606
606
|
] });
|
|
607
|
-
},
|
|
607
|
+
}, bt = W(1, Te("Group")), wt = ({
|
|
608
608
|
uischema: e,
|
|
609
609
|
schema: t,
|
|
610
610
|
path: r,
|
|
611
|
-
renderers:
|
|
612
|
-
cells:
|
|
613
|
-
enabled:
|
|
614
|
-
visible:
|
|
611
|
+
renderers: i,
|
|
612
|
+
cells: f,
|
|
613
|
+
enabled: s,
|
|
614
|
+
visible: l = !0
|
|
615
615
|
}) => {
|
|
616
|
-
var
|
|
617
|
-
const o = e.elements.filter((
|
|
618
|
-
if (
|
|
619
|
-
const y = o.find((
|
|
620
|
-
return /* @__PURE__ */
|
|
621
|
-
/* @__PURE__ */ n(Ie.List, { children: o.map((
|
|
622
|
-
/* @__PURE__ */ n(C, { pt: "3", children: o.map((
|
|
623
|
-
|
|
616
|
+
var p;
|
|
617
|
+
const o = e.elements.filter((m) => m.type === "Category"), [c, u] = F(((p = o[0]) == null ? void 0 : p.label) || "");
|
|
618
|
+
if (l === !1 || !o.length) return null;
|
|
619
|
+
const y = o.find((m) => m.label === c) ? c : o[0].label;
|
|
620
|
+
return /* @__PURE__ */ g(Ie.Root, { value: y, onValueChange: u, children: [
|
|
621
|
+
/* @__PURE__ */ n(Ie.List, { children: o.map((m, v) => /* @__PURE__ */ n(Ie.Trigger, { value: m.label, children: m.label }, `${r}-${v}`)) }),
|
|
622
|
+
/* @__PURE__ */ n(C, { pt: "3", children: o.map((m, v) => /* @__PURE__ */ n(Ie.Content, { value: m.label, children: /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: m.elements.map((N, A) => /* @__PURE__ */ n(
|
|
623
|
+
Ae,
|
|
624
624
|
{
|
|
625
|
-
uischema:
|
|
625
|
+
uischema: N,
|
|
626
626
|
schema: t,
|
|
627
627
|
path: r,
|
|
628
|
-
renderers:
|
|
629
|
-
cells:
|
|
630
|
-
enabled:
|
|
628
|
+
renderers: i,
|
|
629
|
+
cells: f,
|
|
630
|
+
enabled: s
|
|
631
631
|
},
|
|
632
632
|
`${r}-${v}-${A}`
|
|
633
633
|
)) }) }, `${r}-${v}`)) })
|
|
634
634
|
] });
|
|
635
|
-
},
|
|
635
|
+
}, Et = W(1, Te("Categorization"));
|
|
636
636
|
function me(e) {
|
|
637
637
|
return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function ge(e) {
|
|
640
640
|
return e.split(",").map((t) => {
|
|
641
641
|
if (t = t.trim(), t.endsWith("/*"))
|
|
642
642
|
return t.split("/")[0].toUpperCase() + "S";
|
|
@@ -646,107 +646,107 @@ function ye(e) {
|
|
|
646
646
|
return r ? r.toUpperCase() : t;
|
|
647
647
|
}).join(", ");
|
|
648
648
|
}
|
|
649
|
-
function
|
|
649
|
+
function Rt(e) {
|
|
650
650
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
651
651
|
}
|
|
652
|
-
const
|
|
652
|
+
const Ct = ({
|
|
653
653
|
data: e,
|
|
654
654
|
handleChange: t,
|
|
655
655
|
path: r,
|
|
656
|
-
label:
|
|
657
|
-
required:
|
|
658
|
-
uischema:
|
|
659
|
-
schema:
|
|
660
|
-
enabled:
|
|
656
|
+
label: i,
|
|
657
|
+
required: f,
|
|
658
|
+
uischema: s,
|
|
659
|
+
schema: l,
|
|
660
|
+
enabled: a,
|
|
661
661
|
errors: o,
|
|
662
|
-
visible:
|
|
662
|
+
visible: c = !0
|
|
663
663
|
}) => {
|
|
664
|
-
const
|
|
665
|
-
|
|
666
|
-
const y = !o || o.length === 0,
|
|
667
|
-
|
|
668
|
-
|
|
664
|
+
const u = Vr();
|
|
665
|
+
ce(c, r, t, null);
|
|
666
|
+
const y = !o || o.length === 0, p = (l == null ? void 0 : l["x-file"]) ?? {}, m = (s == null ? void 0 : s.options) ?? {}, v = p.maxFiles ?? m.maxFiles ?? 1, N = p.maxSize ?? m.maxSize ?? 5 * 1024 * 1024, A = p.accept ?? m.accept ?? "image/*,application/pdf", w = v > 1, R = a !== !1, [L, P] = F(!1), [I, B] = F(null), [j, M] = F({}), O = de(/* @__PURE__ */ new Set()), D = de(null), V = Rt(e), oe = V.length >= v;
|
|
667
|
+
fe(() => () => {
|
|
668
|
+
O.current.forEach((b) => URL.revokeObjectURL(b)), O.current.clear();
|
|
669
669
|
}, []);
|
|
670
|
-
const
|
|
670
|
+
const ee = _e(
|
|
671
671
|
async (b) => {
|
|
672
|
-
if (
|
|
673
|
-
|
|
672
|
+
if (B(null), V.length >= v) {
|
|
673
|
+
B(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
|
|
674
674
|
return;
|
|
675
675
|
}
|
|
676
|
-
if (b.size >
|
|
677
|
-
|
|
676
|
+
if (b.size > N) {
|
|
677
|
+
B(`File exceeds the ${me(N)} limit.`);
|
|
678
678
|
return;
|
|
679
679
|
}
|
|
680
|
-
if (!A.split(",").map((
|
|
681
|
-
|
|
680
|
+
if (!A.split(",").map((T) => T.trim()).some((T) => T === "*" || T === "*/*" ? !0 : T.endsWith("/*") ? b.type.startsWith(T.slice(0, -1)) : T.startsWith(".") ? b.name.toLowerCase().endsWith(T.toLowerCase()) : b.type === T)) {
|
|
681
|
+
B(`Invalid type. Accepted: ${ge(A)}`);
|
|
682
682
|
return;
|
|
683
683
|
}
|
|
684
|
-
if (!(
|
|
685
|
-
|
|
684
|
+
if (!(u != null && u.onUpload)) {
|
|
685
|
+
B("Upload service not configured.");
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
688
|
try {
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
const
|
|
694
|
-
t(r, w ?
|
|
689
|
+
const T = await u.onUpload(b), H = URL.createObjectURL(b);
|
|
690
|
+
O.current.add(H);
|
|
691
|
+
const J = { key: T.key, name: T.name ?? b.name, blobUrl: H };
|
|
692
|
+
M((K) => ({ ...K, [T.key]: J }));
|
|
693
|
+
const Q = [...V, T.key];
|
|
694
|
+
t(r, w ? Q : Q[0]);
|
|
695
695
|
} catch {
|
|
696
|
-
|
|
696
|
+
B("Upload failed. Please try again."), D.current && (D.current.value = "");
|
|
697
697
|
}
|
|
698
698
|
},
|
|
699
|
-
[V, v,
|
|
699
|
+
[V, v, N, A, u, r, t, w]
|
|
700
700
|
);
|
|
701
|
-
if (
|
|
701
|
+
if (c === !1)
|
|
702
702
|
return null;
|
|
703
|
-
const
|
|
704
|
-
b.preventDefault(), b.stopPropagation(), !(!
|
|
705
|
-
},
|
|
706
|
-
var
|
|
707
|
-
b.preventDefault(), b.stopPropagation(),
|
|
703
|
+
const le = (b) => {
|
|
704
|
+
b.preventDefault(), b.stopPropagation(), !(!R || oe) && P(b.type === "dragenter" || b.type === "dragover");
|
|
705
|
+
}, Y = (b) => {
|
|
706
|
+
var k;
|
|
707
|
+
b.preventDefault(), b.stopPropagation(), P(!1), !(!R || oe) && (k = b.dataTransfer.files) != null && k[0] && ee(b.dataTransfer.files[0]);
|
|
708
|
+
}, Z = (b) => {
|
|
709
|
+
var k;
|
|
710
|
+
(k = b.target.files) != null && k[0] && (ee(b.target.files[0]), b.target.value = "");
|
|
708
711
|
}, re = (b) => {
|
|
709
|
-
|
|
710
|
-
(
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
var G;
|
|
715
|
-
const R = { ...D }, U = (G = R[b]) == null ? void 0 : G.blobUrl;
|
|
716
|
-
return U && (URL.revokeObjectURL(U), J.current.delete(U)), delete R[b], R;
|
|
712
|
+
if (!R) return;
|
|
713
|
+
M((U) => {
|
|
714
|
+
var J;
|
|
715
|
+
const T = { ...U }, H = (J = T[b]) == null ? void 0 : J.blobUrl;
|
|
716
|
+
return H && (URL.revokeObjectURL(H), O.current.delete(H)), delete T[b], T;
|
|
717
717
|
});
|
|
718
|
-
const
|
|
719
|
-
t(r, w ?
|
|
720
|
-
},
|
|
721
|
-
var
|
|
718
|
+
const k = V.filter((U) => U !== b);
|
|
719
|
+
t(r, w ? k.length > 0 ? k : null : k[0] ?? null);
|
|
720
|
+
}, he = async (b, k) => {
|
|
721
|
+
var H, J, Q;
|
|
722
722
|
b.preventDefault();
|
|
723
|
-
const
|
|
724
|
-
if (
|
|
725
|
-
(
|
|
723
|
+
const U = (H = j[k]) == null ? void 0 : H.blobUrl;
|
|
724
|
+
if (U) {
|
|
725
|
+
(J = window.open(U, "_blank", "noopener,noreferrer")) == null || J.focus();
|
|
726
726
|
return;
|
|
727
727
|
}
|
|
728
|
-
const
|
|
729
|
-
if (
|
|
728
|
+
const T = window.open("", "_blank");
|
|
729
|
+
if (T)
|
|
730
730
|
try {
|
|
731
|
-
const
|
|
732
|
-
|
|
731
|
+
const K = await ((Q = u == null ? void 0 : u.getDownloadUrl) == null ? void 0 : Q.call(u, k));
|
|
732
|
+
K != null && K.url ? T.location.href = K.url : T.close();
|
|
733
733
|
} catch {
|
|
734
|
-
|
|
734
|
+
T.close();
|
|
735
735
|
}
|
|
736
736
|
};
|
|
737
|
-
if (!
|
|
738
|
-
const
|
|
739
|
-
return /* @__PURE__ */
|
|
740
|
-
/* @__PURE__ */
|
|
741
|
-
/* @__PURE__ */
|
|
742
|
-
|
|
743
|
-
|
|
737
|
+
if (!R && V.length === 0) return null;
|
|
738
|
+
const ne = v - V.length, ue = R && !oe;
|
|
739
|
+
return /* @__PURE__ */ g(C, { mb: "4", children: [
|
|
740
|
+
/* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
|
|
741
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
|
|
742
|
+
i,
|
|
743
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
|
|
744
744
|
] }),
|
|
745
|
-
/* @__PURE__ */ n(
|
|
745
|
+
/* @__PURE__ */ n(h, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(N)} each · ${ge(A)}` : `${me(N)} · ${ge(A)}` })
|
|
746
746
|
] }),
|
|
747
747
|
V.map((b) => {
|
|
748
|
-
var
|
|
749
|
-
return /* @__PURE__ */ n(
|
|
748
|
+
var k;
|
|
749
|
+
return /* @__PURE__ */ n(nr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(S, { align: "center", gap: "3", children: [
|
|
750
750
|
/* @__PURE__ */ n(
|
|
751
751
|
C,
|
|
752
752
|
{
|
|
@@ -757,11 +757,11 @@ const ft = ({
|
|
|
757
757
|
color: "var(--blue-9)",
|
|
758
758
|
flexShrink: 0
|
|
759
759
|
},
|
|
760
|
-
children: /* @__PURE__ */ n(
|
|
760
|
+
children: /* @__PURE__ */ n(Dr, { width: "20", height: "20" })
|
|
761
761
|
}
|
|
762
762
|
),
|
|
763
763
|
/* @__PURE__ */ n(C, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
|
|
764
|
-
|
|
764
|
+
h,
|
|
765
765
|
{
|
|
766
766
|
size: "2",
|
|
767
767
|
weight: "bold",
|
|
@@ -771,70 +771,70 @@ const ft = ({
|
|
|
771
771
|
textOverflow: "ellipsis",
|
|
772
772
|
whiteSpace: "nowrap"
|
|
773
773
|
},
|
|
774
|
-
children: ((
|
|
774
|
+
children: ((k = j[b]) == null ? void 0 : k.name) ?? "Uploaded File"
|
|
775
775
|
}
|
|
776
776
|
) }),
|
|
777
|
-
/* @__PURE__ */
|
|
778
|
-
/* @__PURE__ */ n(
|
|
779
|
-
/* @__PURE__ */ n(
|
|
780
|
-
|
|
777
|
+
/* @__PURE__ */ g(S, { align: "center", gap: "2", style: { flexShrink: 0 }, children: [
|
|
778
|
+
/* @__PURE__ */ n(ke, { variant: "soft", color: "blue", size: "1", onClick: (U) => he(U, b), children: "View" }),
|
|
779
|
+
/* @__PURE__ */ n(Fr, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
|
|
780
|
+
R && /* @__PURE__ */ n(Ue, { variant: "ghost", color: "gray", onClick: () => re(b), children: /* @__PURE__ */ n(or, {}) })
|
|
781
781
|
] })
|
|
782
782
|
] }) }, b);
|
|
783
783
|
}),
|
|
784
|
-
|
|
784
|
+
ue && /* @__PURE__ */ g(
|
|
785
785
|
"div",
|
|
786
786
|
{
|
|
787
787
|
role: "button",
|
|
788
788
|
tabIndex: 0,
|
|
789
789
|
onClick: () => {
|
|
790
790
|
var b;
|
|
791
|
-
return (b =
|
|
791
|
+
return (b = D.current) == null ? void 0 : b.click();
|
|
792
792
|
},
|
|
793
793
|
onKeyDown: (b) => {
|
|
794
|
-
var
|
|
795
|
-
(b.key === "Enter" || b.key === " ") && (b.preventDefault(), (
|
|
794
|
+
var k;
|
|
795
|
+
(b.key === "Enter" || b.key === " ") && (b.preventDefault(), (k = D.current) == null || k.click());
|
|
796
796
|
},
|
|
797
|
-
onDragEnter:
|
|
798
|
-
onDragLeave:
|
|
799
|
-
onDragOver:
|
|
800
|
-
onDrop:
|
|
797
|
+
onDragEnter: le,
|
|
798
|
+
onDragLeave: le,
|
|
799
|
+
onDragOver: le,
|
|
800
|
+
onDrop: Y,
|
|
801
801
|
style: { cursor: "pointer" },
|
|
802
802
|
className: [
|
|
803
803
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
804
804
|
"transition-all duration-200 ease-in-out",
|
|
805
|
-
|
|
805
|
+
L ? "border-blue-500 bg-blue-50" : I ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
|
|
806
806
|
].join(" "),
|
|
807
807
|
children: [
|
|
808
|
-
/* @__PURE__ */ n("input", { ref:
|
|
809
|
-
/* @__PURE__ */ n(
|
|
810
|
-
/* @__PURE__ */ n(
|
|
811
|
-
/* @__PURE__ */ n(
|
|
812
|
-
/* @__PURE__ */ n(
|
|
813
|
-
] }) : /* @__PURE__ */
|
|
814
|
-
/* @__PURE__ */ n(
|
|
815
|
-
/* @__PURE__ */ n(
|
|
816
|
-
/* @__PURE__ */
|
|
817
|
-
me(
|
|
808
|
+
/* @__PURE__ */ n("input", { ref: D, type: "file", style: { display: "none" }, accept: A, onChange: Z }),
|
|
809
|
+
/* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: I ? /* @__PURE__ */ g(be, { children: [
|
|
810
|
+
/* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
|
|
811
|
+
/* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: I }),
|
|
812
|
+
/* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
|
|
813
|
+
] }) : /* @__PURE__ */ g(be, { children: [
|
|
814
|
+
/* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
|
|
815
|
+
/* @__PURE__ */ n(h, { size: "2", weight: "medium", children: V.length > 0 ? `Add another file (${ne} remaining)` : "Click to upload or drag and drop" }),
|
|
816
|
+
/* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
|
|
817
|
+
me(N),
|
|
818
818
|
" max · ",
|
|
819
|
-
|
|
819
|
+
ge(A)
|
|
820
820
|
] })
|
|
821
821
|
] }) })
|
|
822
822
|
]
|
|
823
823
|
}
|
|
824
824
|
),
|
|
825
|
-
|
|
825
|
+
R && oe && w && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
|
|
826
826
|
"Maximum ",
|
|
827
827
|
v,
|
|
828
828
|
" files uploaded. Remove one to replace it."
|
|
829
829
|
] }),
|
|
830
|
-
!y && /* @__PURE__ */ n(
|
|
830
|
+
!y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
|
|
831
831
|
] });
|
|
832
|
-
},
|
|
832
|
+
}, Tt = se(Ct), At = W(
|
|
833
833
|
10,
|
|
834
834
|
// high rank to beat default array renderer
|
|
835
|
-
|
|
835
|
+
Ar(
|
|
836
836
|
// Match both single-file (type: string) and multi-file (type: array)
|
|
837
|
-
|
|
837
|
+
ze((e) => {
|
|
838
838
|
if (e.type === "string" && e.format === "file") return !0;
|
|
839
839
|
if (e.type === "array") {
|
|
840
840
|
const t = e.items;
|
|
@@ -844,39 +844,42 @@ const ft = ({
|
|
|
844
844
|
})
|
|
845
845
|
)
|
|
846
846
|
);
|
|
847
|
-
|
|
847
|
+
function St(e, t) {
|
|
848
|
+
return e !== !1 && t !== !0;
|
|
848
849
|
}
|
|
849
|
-
|
|
850
|
-
|
|
850
|
+
class $e extends Error {
|
|
851
|
+
}
|
|
852
|
+
function Ot(e, t) {
|
|
853
|
+
const r = _r(e, { type: "array", cellDates: !0 });
|
|
851
854
|
if (r.SheetNames.length === 0)
|
|
852
|
-
throw new
|
|
853
|
-
const
|
|
854
|
-
if (!
|
|
855
|
-
throw new
|
|
856
|
-
const
|
|
855
|
+
throw new $e("This file has no sheets.");
|
|
856
|
+
const i = t ?? r.SheetNames[0], f = r.Sheets[i];
|
|
857
|
+
if (!f)
|
|
858
|
+
throw new $e(`This file doesn't have a sheet named "${i}".`);
|
|
859
|
+
const s = Pr.sheet_to_json(f, { header: 1, raw: !0, defval: null });
|
|
857
860
|
return {
|
|
858
|
-
sheetName:
|
|
859
|
-
matrix:
|
|
860
|
-
rowCount:
|
|
861
|
-
colCount: Math.max(0, ...
|
|
861
|
+
sheetName: i,
|
|
862
|
+
matrix: s,
|
|
863
|
+
rowCount: s.length,
|
|
864
|
+
colCount: Math.max(0, ...s.map((l) => l.length))
|
|
862
865
|
};
|
|
863
866
|
}
|
|
864
|
-
function
|
|
867
|
+
function Nt(e) {
|
|
865
868
|
let t = e + 1, r = "";
|
|
866
869
|
for (; t > 0; ) {
|
|
867
|
-
const
|
|
868
|
-
r = String.fromCharCode(65 +
|
|
870
|
+
const i = (t - 1) % 26;
|
|
871
|
+
r = String.fromCharCode(65 + i) + r, t = Math.floor((t - 1) / 26);
|
|
869
872
|
}
|
|
870
873
|
return r;
|
|
871
874
|
}
|
|
872
875
|
class X extends Error {
|
|
873
|
-
constructor(r,
|
|
874
|
-
super(
|
|
876
|
+
constructor(r, i) {
|
|
877
|
+
super(i ?? r);
|
|
875
878
|
Pe(this, "code");
|
|
876
879
|
this.code = r, this.name = "FormulaError";
|
|
877
880
|
}
|
|
878
881
|
}
|
|
879
|
-
const
|
|
882
|
+
const It = [
|
|
880
883
|
// Logical
|
|
881
884
|
// IF is excluded here even though its native body is real, non-stub code —
|
|
882
885
|
// see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
|
|
@@ -902,7 +905,7 @@ const yt = [
|
|
|
902
905
|
// DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
|
|
903
906
|
"DATE",
|
|
904
907
|
"TODAY"
|
|
905
|
-
],
|
|
908
|
+
], xt = [
|
|
906
909
|
"MAX",
|
|
907
910
|
"MIN",
|
|
908
911
|
"MAXA",
|
|
@@ -921,7 +924,7 @@ const yt = [
|
|
|
921
924
|
"COUNTA",
|
|
922
925
|
// not present in fast-formula-parser's function table at all.
|
|
923
926
|
"UPPER"
|
|
924
|
-
],
|
|
927
|
+
], Mt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], kt = ["IF"], Lt = [
|
|
925
928
|
"CONCATENATE",
|
|
926
929
|
"CONCAT",
|
|
927
930
|
"LEN",
|
|
@@ -932,115 +935,115 @@ const yt = [
|
|
|
932
935
|
"MID",
|
|
933
936
|
"FIND",
|
|
934
937
|
"SEARCH"
|
|
935
|
-
],
|
|
936
|
-
...
|
|
937
|
-
...
|
|
938
|
-
...
|
|
939
|
-
...
|
|
940
|
-
...
|
|
941
|
-
]),
|
|
942
|
-
function
|
|
943
|
-
const t = e.replace(
|
|
944
|
-
|
|
938
|
+
], zt = /* @__PURE__ */ new Set([
|
|
939
|
+
...It,
|
|
940
|
+
...xt,
|
|
941
|
+
...Mt,
|
|
942
|
+
...Lt,
|
|
943
|
+
...kt
|
|
944
|
+
]), Dt = /"(?:[^"]|"")*"/g, Be = new RegExp("(?<![A-Za-z0-9_.])([A-Za-z_][A-Za-z0-9_.]*)\\s*\\(", "g");
|
|
945
|
+
function Ft(e) {
|
|
946
|
+
const t = e.replace(Dt, (i) => " ".repeat(i.length));
|
|
947
|
+
Be.lastIndex = 0;
|
|
945
948
|
let r;
|
|
946
|
-
for (; (r =
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
949
|
-
throw new X("NAME", `Function ${
|
|
949
|
+
for (; (r = Be.exec(t)) !== null; ) {
|
|
950
|
+
const i = r[1].toUpperCase();
|
|
951
|
+
if (!zt.has(i))
|
|
952
|
+
throw new X("NAME", `Function ${i} is not allowed.`);
|
|
950
953
|
}
|
|
951
954
|
}
|
|
952
|
-
function
|
|
953
|
-
let
|
|
954
|
-
if (
|
|
955
|
-
if (typeof
|
|
956
|
-
if (typeof
|
|
957
|
-
if (typeof
|
|
955
|
+
function Ut(e, t, r) {
|
|
956
|
+
let i = e;
|
|
957
|
+
if (i == null) throw r.NA;
|
|
958
|
+
if (typeof i == "object" && !(i instanceof r) && (i = t.retrieveRef(i)), i instanceof r) throw i;
|
|
959
|
+
if (typeof i == "boolean") return i;
|
|
960
|
+
if (typeof i == "number") return i !== 0;
|
|
958
961
|
throw r.VALUE;
|
|
959
962
|
}
|
|
960
|
-
function
|
|
963
|
+
function cr(e) {
|
|
961
964
|
return e !== null && typeof e == "object" && "value" in e ? e.value : e;
|
|
962
965
|
}
|
|
963
966
|
function pe(e) {
|
|
964
|
-
const t =
|
|
967
|
+
const t = cr(e);
|
|
965
968
|
return Array.isArray(t) ? t.flat(1 / 0) : [t];
|
|
966
969
|
}
|
|
967
|
-
function
|
|
968
|
-
const t =
|
|
970
|
+
function x(e) {
|
|
971
|
+
const t = cr(e);
|
|
969
972
|
return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
|
|
970
973
|
}
|
|
971
974
|
function xe(e) {
|
|
972
|
-
return e === void 0 ? void 0 :
|
|
975
|
+
return e === void 0 ? void 0 : x(e);
|
|
973
976
|
}
|
|
974
|
-
function
|
|
977
|
+
function G(e) {
|
|
975
978
|
return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
976
979
|
}
|
|
977
|
-
function
|
|
980
|
+
function Ht(e, t) {
|
|
978
981
|
return e instanceof t ? e : new t(e.message || "#ERROR!");
|
|
979
982
|
}
|
|
980
|
-
function
|
|
983
|
+
function _(e) {
|
|
981
984
|
return e.find((t) => t instanceof Error);
|
|
982
985
|
}
|
|
983
|
-
function
|
|
984
|
-
const r = (
|
|
985
|
-
throw
|
|
986
|
-
},
|
|
987
|
-
const o =
|
|
988
|
-
if (
|
|
989
|
-
const
|
|
990
|
-
|
|
986
|
+
function $t(e, t) {
|
|
987
|
+
const r = (s) => {
|
|
988
|
+
throw Ht(s, t);
|
|
989
|
+
}, i = (s, { checkArgsForErrors: l = !0 } = {}) => (...a) => {
|
|
990
|
+
const o = a.flatMap(pe);
|
|
991
|
+
if (l) {
|
|
992
|
+
const u = _(o);
|
|
993
|
+
u && r(u);
|
|
991
994
|
}
|
|
992
|
-
const
|
|
993
|
-
return
|
|
994
|
-
},
|
|
995
|
-
const o =
|
|
996
|
-
|
|
997
|
-
const
|
|
998
|
-
return
|
|
995
|
+
const c = s(...o);
|
|
996
|
+
return c instanceof Error ? r(c) : c;
|
|
997
|
+
}, f = (s, { toText: l = !1 } = {}) => (a) => {
|
|
998
|
+
const o = x(a), c = _([o]);
|
|
999
|
+
c && r(c);
|
|
1000
|
+
const u = s(l ? G(o) : o);
|
|
1001
|
+
return u instanceof Error ? r(u) : u;
|
|
999
1002
|
};
|
|
1000
1003
|
return {
|
|
1001
1004
|
// valueIfTrue/valueIfFalse are passed through unretrieved (not
|
|
1002
1005
|
// dereferenced or type-checked here) — that's what makes
|
|
1003
1006
|
// `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
|
|
1004
|
-
IF: (
|
|
1005
|
-
const
|
|
1006
|
-
if (
|
|
1007
|
-
return
|
|
1007
|
+
IF: (s, l, a, o) => {
|
|
1008
|
+
const c = Ut(l, s, t);
|
|
1009
|
+
if (a == null) throw t.NA;
|
|
1010
|
+
return c ? a : o ?? !1;
|
|
1008
1011
|
},
|
|
1009
1012
|
// Empty input -> 0, matching both the hand-rolled engine this replaces
|
|
1010
1013
|
// and formulajs's own convention for MAX/MIN.
|
|
1011
|
-
MAX:
|
|
1012
|
-
MIN:
|
|
1013
|
-
MAXA:
|
|
1014
|
-
MINA:
|
|
1015
|
-
MEDIAN:
|
|
1014
|
+
MAX: i(e.MAX),
|
|
1015
|
+
MIN: i(e.MIN),
|
|
1016
|
+
MAXA: i(e.MAXA),
|
|
1017
|
+
MINA: i(e.MINA),
|
|
1018
|
+
MEDIAN: i(e.MEDIAN),
|
|
1016
1019
|
// COUNTA counts non-blank entries; an error value among the args is
|
|
1017
1020
|
// itself non-blank and gets counted (matching formulajs's own COUNTA,
|
|
1018
1021
|
// which never checks for errors), so this skips the error propagation
|
|
1019
1022
|
// the other aggregates use.
|
|
1020
|
-
COUNTA:
|
|
1021
|
-
LARGE: (
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1024
|
-
const
|
|
1025
|
-
return
|
|
1023
|
+
COUNTA: i(e.COUNTA, { checkArgsForErrors: !1 }),
|
|
1024
|
+
LARGE: (s, l) => {
|
|
1025
|
+
const a = pe(s), o = x(l), c = _([...a, o]);
|
|
1026
|
+
c && r(c);
|
|
1027
|
+
const u = e.LARGE(a, o);
|
|
1028
|
+
return u instanceof Error ? r(u) : u;
|
|
1026
1029
|
},
|
|
1027
|
-
SMALL: (
|
|
1028
|
-
const
|
|
1029
|
-
|
|
1030
|
-
const
|
|
1031
|
-
return
|
|
1030
|
+
SMALL: (s, l) => {
|
|
1031
|
+
const a = pe(s), o = x(l), c = _([...a, o]);
|
|
1032
|
+
c && r(c);
|
|
1033
|
+
const u = e.SMALL(a, o);
|
|
1034
|
+
return u instanceof Error ? r(u) : u;
|
|
1032
1035
|
},
|
|
1033
|
-
PERMUT: (
|
|
1034
|
-
const
|
|
1036
|
+
PERMUT: (s, l) => {
|
|
1037
|
+
const a = [x(s), x(l)], o = _(a);
|
|
1035
1038
|
o && r(o);
|
|
1036
|
-
const
|
|
1037
|
-
return
|
|
1039
|
+
const c = e.PERMUT(a[0], a[1]);
|
|
1040
|
+
return c instanceof Error ? r(c) : c;
|
|
1038
1041
|
},
|
|
1039
|
-
PERMUTATIONA: (
|
|
1040
|
-
const
|
|
1042
|
+
PERMUTATIONA: (s, l) => {
|
|
1043
|
+
const a = [x(s), x(l)], o = _(a);
|
|
1041
1044
|
o && r(o);
|
|
1042
|
-
const
|
|
1043
|
-
return
|
|
1045
|
+
const c = e.PERMUTATIONA(a[0], a[1]);
|
|
1046
|
+
return c instanceof Error ? r(c) : c;
|
|
1044
1047
|
},
|
|
1045
1048
|
// match_type is intentionally ignored and forced to 0 (exact match)
|
|
1046
1049
|
// regardless of what the formula author supplied — approximate/sorted
|
|
@@ -1048,43 +1051,43 @@ function Nt(e, t) {
|
|
|
1048
1051
|
// Excel's own default too) risks silently mis-ranking unsorted
|
|
1049
1052
|
// real-world data. Same scope decision as the hand-rolled engine this
|
|
1050
1053
|
// replaces, carried forward deliberately rather than dropped.
|
|
1051
|
-
MATCH: (
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
const
|
|
1055
|
-
return
|
|
1054
|
+
MATCH: (s, l) => {
|
|
1055
|
+
const a = x(s), o = pe(l), c = _([a, ...o]);
|
|
1056
|
+
c && r(c);
|
|
1057
|
+
const u = e.MATCH(a, o, 0);
|
|
1058
|
+
return u instanceof Error ? r(u) : u;
|
|
1056
1059
|
},
|
|
1057
|
-
SWITCH: (...
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
const o = e.SWITCH(...
|
|
1060
|
+
SWITCH: (...s) => {
|
|
1061
|
+
const l = s.map(x), a = _(l);
|
|
1062
|
+
a && r(a);
|
|
1063
|
+
const o = e.SWITCH(...l);
|
|
1061
1064
|
return o instanceof Error ? r(o) : o;
|
|
1062
1065
|
},
|
|
1063
|
-
SUBSTITUTE: (
|
|
1064
|
-
const
|
|
1065
|
-
o !== void 0 &&
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
const y = e.SUBSTITUTE(...
|
|
1066
|
+
SUBSTITUTE: (s, l, a, o) => {
|
|
1067
|
+
const c = [G(x(s)), G(x(l)), G(x(a))];
|
|
1068
|
+
o !== void 0 && c.push(x(o));
|
|
1069
|
+
const u = _(c);
|
|
1070
|
+
u && r(u);
|
|
1071
|
+
const y = e.SUBSTITUTE(...c);
|
|
1069
1072
|
return y instanceof Error ? r(y) : y;
|
|
1070
1073
|
},
|
|
1071
|
-
TEXTJOIN: (
|
|
1072
|
-
const o =
|
|
1074
|
+
TEXTJOIN: (s, l, ...a) => {
|
|
1075
|
+
const o = G(x(s)), c = x(l), u = a.flatMap(pe).map(G), y = _([o, c]);
|
|
1073
1076
|
y && r(y);
|
|
1074
|
-
const
|
|
1075
|
-
return
|
|
1077
|
+
const p = e.TEXTJOIN(o, c, u);
|
|
1078
|
+
return p instanceof Error ? r(p) : p;
|
|
1076
1079
|
},
|
|
1077
|
-
UPPER:
|
|
1080
|
+
UPPER: f(e.UPPER),
|
|
1078
1081
|
// See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
|
|
1079
1082
|
// fast-formula-parser's own (real, but broken-for-Date-cells) versions.
|
|
1080
|
-
YEAR:
|
|
1081
|
-
MONTH:
|
|
1082
|
-
DAY:
|
|
1083
|
-
WEEKDAY: (
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1086
|
-
const
|
|
1087
|
-
return
|
|
1083
|
+
YEAR: f(e.YEAR),
|
|
1084
|
+
MONTH: f(e.MONTH),
|
|
1085
|
+
DAY: f(e.DAY),
|
|
1086
|
+
WEEKDAY: (s, l) => {
|
|
1087
|
+
const a = x(s), o = x(l), c = _([a]);
|
|
1088
|
+
c && r(c);
|
|
1089
|
+
const u = e.WEEKDAY(a, o);
|
|
1090
|
+
return u instanceof Error ? r(u) : u;
|
|
1088
1091
|
},
|
|
1089
1092
|
// See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
|
|
1090
1093
|
// formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
|
|
@@ -1095,54 +1098,54 @@ function Nt(e, t) {
|
|
|
1095
1098
|
// Flattens every argument (a whole range included) and joins with no
|
|
1096
1099
|
// separator, matching Excel's own range-argument behavior — the native
|
|
1097
1100
|
// implementation instead inserts stray commas for a whole-range argument.
|
|
1098
|
-
CONCATENATE: (...
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
const o = e.CONCATENATE(...
|
|
1101
|
+
CONCATENATE: (...s) => {
|
|
1102
|
+
const l = s.flatMap(pe), a = _(l);
|
|
1103
|
+
a && r(a);
|
|
1104
|
+
const o = e.CONCATENATE(...l.map(G));
|
|
1102
1105
|
return o instanceof Error ? r(o) : o;
|
|
1103
1106
|
},
|
|
1104
|
-
CONCAT: (...
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
const o = e.CONCAT(...
|
|
1107
|
+
CONCAT: (...s) => {
|
|
1108
|
+
const l = s.flatMap(pe), a = _(l);
|
|
1109
|
+
a && r(a);
|
|
1110
|
+
const o = e.CONCAT(...l.map(G));
|
|
1108
1111
|
return o instanceof Error ? r(o) : o;
|
|
1109
1112
|
},
|
|
1110
|
-
LEN:
|
|
1111
|
-
TRIM:
|
|
1112
|
-
LOWER:
|
|
1113
|
-
LEFT: (
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
const
|
|
1117
|
-
return
|
|
1113
|
+
LEN: f(e.LEN, { toText: !0 }),
|
|
1114
|
+
TRIM: f(e.TRIM, { toText: !0 }),
|
|
1115
|
+
LOWER: f(e.LOWER, { toText: !0 }),
|
|
1116
|
+
LEFT: (s, l) => {
|
|
1117
|
+
const a = x(s), o = xe(l), c = _([a]);
|
|
1118
|
+
c && r(c);
|
|
1119
|
+
const u = e.LEFT(G(a), o);
|
|
1120
|
+
return u instanceof Error ? r(u) : u;
|
|
1118
1121
|
},
|
|
1119
|
-
RIGHT: (
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
return
|
|
1122
|
+
RIGHT: (s, l) => {
|
|
1123
|
+
const a = x(s), o = xe(l), c = _([a]);
|
|
1124
|
+
c && r(c);
|
|
1125
|
+
const u = e.RIGHT(G(a), o);
|
|
1126
|
+
return u instanceof Error ? r(u) : u;
|
|
1124
1127
|
},
|
|
1125
|
-
MID: (
|
|
1126
|
-
const o =
|
|
1128
|
+
MID: (s, l, a) => {
|
|
1129
|
+
const o = x(s), c = x(l), u = x(a), y = _([o, c, u]);
|
|
1127
1130
|
y && r(y);
|
|
1128
|
-
const
|
|
1129
|
-
return
|
|
1131
|
+
const p = e.MID(G(o), c, u);
|
|
1132
|
+
return p instanceof Error ? r(p) : p;
|
|
1130
1133
|
},
|
|
1131
|
-
FIND: (
|
|
1132
|
-
const o =
|
|
1134
|
+
FIND: (s, l, a) => {
|
|
1135
|
+
const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
|
|
1133
1136
|
y && r(y);
|
|
1134
|
-
const
|
|
1135
|
-
return
|
|
1137
|
+
const p = e.FIND(G(o), G(c), u);
|
|
1138
|
+
return p instanceof Error ? r(p) : p;
|
|
1136
1139
|
},
|
|
1137
|
-
SEARCH: (
|
|
1138
|
-
const o =
|
|
1140
|
+
SEARCH: (s, l, a) => {
|
|
1141
|
+
const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
|
|
1139
1142
|
y && r(y);
|
|
1140
|
-
const
|
|
1141
|
-
return
|
|
1143
|
+
const p = e.SEARCH(G(o), G(c), u);
|
|
1144
|
+
return p instanceof Error ? r(p) : p;
|
|
1142
1145
|
}
|
|
1143
1146
|
};
|
|
1144
1147
|
}
|
|
1145
|
-
const
|
|
1148
|
+
const _t = {
|
|
1146
1149
|
"#REF!": "REF",
|
|
1147
1150
|
"#VALUE!": "VALUE",
|
|
1148
1151
|
"#DIV/0!": "DIV0",
|
|
@@ -1151,41 +1154,41 @@ const Ot = {
|
|
|
1151
1154
|
"#NUM!": "NUM",
|
|
1152
1155
|
"#NULL!": "NULL"
|
|
1153
1156
|
};
|
|
1154
|
-
function
|
|
1155
|
-
return
|
|
1157
|
+
function Ke(e) {
|
|
1158
|
+
return _t[e.error] ?? "ERROR";
|
|
1156
1159
|
}
|
|
1157
|
-
function
|
|
1160
|
+
function Ge(e, t) {
|
|
1158
1161
|
if (e instanceof X) return e;
|
|
1159
1162
|
if (e instanceof t) {
|
|
1160
1163
|
const r = e.details;
|
|
1161
|
-
return r instanceof X ? r : r instanceof t ? new X(
|
|
1164
|
+
return r instanceof X ? r : r instanceof t ? new X(Ke(r), r.message) : new X(Ke(e), e.message);
|
|
1162
1165
|
}
|
|
1163
1166
|
return new X("ERROR", e instanceof Error ? e.message : void 0);
|
|
1164
1167
|
}
|
|
1165
|
-
function
|
|
1168
|
+
function Pt(e) {
|
|
1166
1169
|
return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
|
|
1167
1170
|
}
|
|
1168
|
-
function
|
|
1171
|
+
function Vt(e) {
|
|
1169
1172
|
return (t) => {
|
|
1170
1173
|
const r = e[t.row - 1];
|
|
1171
1174
|
if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
|
|
1172
1175
|
throw new X("REF");
|
|
1173
|
-
const
|
|
1174
|
-
return
|
|
1176
|
+
const i = r[t.col - 1];
|
|
1177
|
+
return i == null || i === "" ? null : i;
|
|
1175
1178
|
};
|
|
1176
1179
|
}
|
|
1177
|
-
function
|
|
1180
|
+
function Wt(e) {
|
|
1178
1181
|
return (t) => {
|
|
1179
|
-
const r = Math.min(t.from.row, t.to.row),
|
|
1180
|
-
if (r > e.length ||
|
|
1182
|
+
const r = Math.min(t.from.row, t.to.row), i = Math.min(t.from.col, t.to.col), f = Math.max(t.from.row, t.to.row), s = Math.max(t.from.col, t.to.col), l = Pt(e);
|
|
1183
|
+
if (r > e.length || i > l)
|
|
1181
1184
|
throw new X("REF");
|
|
1182
|
-
const
|
|
1183
|
-
for (let
|
|
1184
|
-
const
|
|
1185
|
-
if (
|
|
1186
|
-
const
|
|
1187
|
-
for (let
|
|
1188
|
-
const v =
|
|
1185
|
+
const a = Math.min(f, e.length), o = [];
|
|
1186
|
+
for (let c = r; c <= a; c++) {
|
|
1187
|
+
const u = e[c - 1], y = [];
|
|
1188
|
+
if (u != null) {
|
|
1189
|
+
const p = Math.min(s, u.length);
|
|
1190
|
+
for (let m = i; m <= p; m++) {
|
|
1191
|
+
const v = u[m - 1];
|
|
1189
1192
|
y.push(v == null || v === "" ? null : v);
|
|
1190
1193
|
}
|
|
1191
1194
|
}
|
|
@@ -1194,38 +1197,57 @@ function Lt(e) {
|
|
|
1194
1197
|
return o;
|
|
1195
1198
|
};
|
|
1196
1199
|
}
|
|
1197
|
-
function
|
|
1200
|
+
function Bt(e) {
|
|
1198
1201
|
if (e == null || e === "") return null;
|
|
1199
1202
|
if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
|
|
1200
1203
|
return e;
|
|
1201
1204
|
throw new X("VALUE");
|
|
1202
1205
|
}
|
|
1203
|
-
async function
|
|
1204
|
-
if (typeof
|
|
1205
|
-
const r =
|
|
1206
|
+
async function ar(e, t) {
|
|
1207
|
+
if (typeof e != "string") throw new X("ERROR");
|
|
1208
|
+
const r = e.trim();
|
|
1206
1209
|
if (r === "") throw new X("ERROR");
|
|
1207
|
-
const
|
|
1208
|
-
|
|
1209
|
-
const [
|
|
1210
|
+
const i = r.startsWith("=") ? r.slice(1) : r;
|
|
1211
|
+
Ft(i);
|
|
1212
|
+
const [f, s] = await Promise.all([
|
|
1210
1213
|
import("fast-formula-parser"),
|
|
1211
1214
|
import("@formulajs/formulajs")
|
|
1212
|
-
]),
|
|
1213
|
-
|
|
1214
|
-
onRange: Lt(e),
|
|
1215
|
+
]), l = f.default ?? f, a = l.FormulaError, o = new l({
|
|
1216
|
+
...t,
|
|
1215
1217
|
// 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.
|
|
1216
|
-
functions:
|
|
1218
|
+
functions: $t(s, a)
|
|
1217
1219
|
});
|
|
1218
|
-
let
|
|
1220
|
+
let c;
|
|
1219
1221
|
try {
|
|
1220
|
-
|
|
1221
|
-
} catch (
|
|
1222
|
-
throw
|
|
1222
|
+
c = o.parse(i, { row: 1, col: 1, sheet: "Sheet1" });
|
|
1223
|
+
} catch (u) {
|
|
1224
|
+
throw Ge(u, a);
|
|
1223
1225
|
}
|
|
1224
|
-
if (
|
|
1225
|
-
throw
|
|
1226
|
-
return
|
|
1226
|
+
if (c instanceof a)
|
|
1227
|
+
throw Ge(c, a);
|
|
1228
|
+
return Bt(c);
|
|
1227
1229
|
}
|
|
1228
|
-
|
|
1230
|
+
async function Kt(e, t) {
|
|
1231
|
+
return ar(t, { onCell: Vt(e), onRange: Wt(e) });
|
|
1232
|
+
}
|
|
1233
|
+
const Xe = -1;
|
|
1234
|
+
async function Gt(e, t) {
|
|
1235
|
+
const r = Object.keys(e);
|
|
1236
|
+
return ar(t, {
|
|
1237
|
+
onVariable: (i) => {
|
|
1238
|
+
const f = r.indexOf(i);
|
|
1239
|
+
return f === -1 ? null : { row: Xe, col: f + 1 };
|
|
1240
|
+
},
|
|
1241
|
+
onCell: (i) => {
|
|
1242
|
+
if (i.row === Xe) return e[r[i.col - 1]] ?? null;
|
|
1243
|
+
throw new X("REF");
|
|
1244
|
+
},
|
|
1245
|
+
onRange: () => {
|
|
1246
|
+
throw new X("REF");
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
const ur = {
|
|
1229
1251
|
REF: "#REF!",
|
|
1230
1252
|
VALUE: "#VALUE!",
|
|
1231
1253
|
DIV0: "#DIV/0!",
|
|
@@ -1235,343 +1257,525 @@ const Ke = {
|
|
|
1235
1257
|
NUM: "#NUM!",
|
|
1236
1258
|
NULL: "#NULL!"
|
|
1237
1259
|
};
|
|
1238
|
-
|
|
1239
|
-
|
|
1260
|
+
function dr(e) {
|
|
1261
|
+
const t = e instanceof X ? e.code : "ERROR";
|
|
1262
|
+
return ur[t];
|
|
1263
|
+
}
|
|
1264
|
+
async function Xt(e, t) {
|
|
1265
|
+
return e.length === 0 ? t.map((r) => ({
|
|
1266
|
+
id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
|
|
1267
|
+
label: (r == null ? void 0 : r.label) ?? "(unknown)",
|
|
1268
|
+
value: null,
|
|
1269
|
+
error: ur.ERROR
|
|
1270
|
+
})) : Promise.all(
|
|
1240
1271
|
t.map(async (r) => {
|
|
1241
1272
|
try {
|
|
1242
|
-
if (!r || typeof r.label != "string" || typeof r.expression != "string")
|
|
1273
|
+
if (!r || typeof r.label != "string" || typeof r.expression != "string" || typeof r.id != "string")
|
|
1243
1274
|
throw new X("ERROR");
|
|
1244
|
-
return { label: r.label, value: await
|
|
1245
|
-
} catch (
|
|
1246
|
-
|
|
1247
|
-
|
|
1275
|
+
return { id: r.id, label: r.label, value: await Kt(e, r.expression) };
|
|
1276
|
+
} catch (i) {
|
|
1277
|
+
return {
|
|
1278
|
+
id: typeof (r == null ? void 0 : r.id) == "string" ? r.id : "(unknown)",
|
|
1279
|
+
label: (r == null ? void 0 : r.label) ?? "(unknown)",
|
|
1280
|
+
value: null,
|
|
1281
|
+
error: dr(i)
|
|
1282
|
+
};
|
|
1248
1283
|
}
|
|
1249
1284
|
})
|
|
1250
1285
|
);
|
|
1251
1286
|
}
|
|
1252
|
-
|
|
1287
|
+
function jt(e, t = {}) {
|
|
1288
|
+
if (t.columnHeader && t.rowHeader)
|
|
1289
|
+
throw new Error(
|
|
1290
|
+
"x-spreadsheet: columnHeader and rowHeader cannot both be true — pick one orientation for the persisted sheet shape."
|
|
1291
|
+
);
|
|
1292
|
+
return t.columnHeader ? Yt(e) : t.rowHeader ? Jt(e) : e;
|
|
1293
|
+
}
|
|
1294
|
+
function fr(e) {
|
|
1295
|
+
return e == null || e === "" ? null : e instanceof Date ? e.toISOString() : String(e);
|
|
1296
|
+
}
|
|
1297
|
+
function hr(e, t) {
|
|
1298
|
+
const r = /* @__PURE__ */ new Set();
|
|
1299
|
+
for (const i of e)
|
|
1300
|
+
if (i != null) {
|
|
1301
|
+
if (r.has(i))
|
|
1302
|
+
throw new Error(
|
|
1303
|
+
`x-spreadsheet: duplicate ${t} value "${i}" — every ${t === "columnHeader" ? "column header" : "column-A value"} must be unique to shape as records.`
|
|
1304
|
+
);
|
|
1305
|
+
r.add(i);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
function Yt(e) {
|
|
1309
|
+
const [t, ...r] = e;
|
|
1310
|
+
if (!t) return [];
|
|
1311
|
+
const i = t.map(fr);
|
|
1312
|
+
return hr(i, "columnHeader"), r.map((f) => {
|
|
1313
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
1314
|
+
return i.forEach((l, a) => {
|
|
1315
|
+
l != null && (s[l] = f[a] ?? null);
|
|
1316
|
+
}), s;
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
function Jt(e) {
|
|
1320
|
+
const t = e.map((f) => fr(f[0]));
|
|
1321
|
+
hr(t, "rowHeader");
|
|
1322
|
+
const r = Math.max(0, ...e.map((f) => f.length)), i = Math.max(0, r - 1);
|
|
1323
|
+
return Array.from({ length: i }, (f, s) => {
|
|
1324
|
+
const l = s + 1, a = /* @__PURE__ */ Object.create(null);
|
|
1325
|
+
return t.forEach((o, c) => {
|
|
1326
|
+
o != null && (a[o] = e[c][l] ?? null);
|
|
1327
|
+
}), a;
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1330
|
+
function je(e) {
|
|
1331
|
+
return !Array.isArray(e[0]);
|
|
1332
|
+
}
|
|
1333
|
+
async function qt(e, t, r = {}) {
|
|
1334
|
+
const i = await Xt(e, t), f = /* @__PURE__ */ Object.create(null);
|
|
1335
|
+
for (const { id: s, label: l, value: a, error: o } of i)
|
|
1336
|
+
f[s] = o === void 0 ? { label: l, value: a } : { label: l, value: a, error: o };
|
|
1337
|
+
return r.persistSheet === !1 ? { derivations: f } : { sheet: jt(e, r), derivations: f };
|
|
1338
|
+
}
|
|
1339
|
+
const Zt = ".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv", Qt = 10 * 1024 * 1024, ve = 200, Ye = 50, en = [];
|
|
1253
1340
|
function Ce(e) {
|
|
1254
1341
|
return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1255
1342
|
}
|
|
1256
|
-
const
|
|
1343
|
+
const rn = ({
|
|
1257
1344
|
data: e,
|
|
1258
1345
|
handleChange: t,
|
|
1259
1346
|
path: r,
|
|
1260
|
-
label:
|
|
1261
|
-
required:
|
|
1262
|
-
schema:
|
|
1263
|
-
enabled:
|
|
1264
|
-
|
|
1265
|
-
|
|
1347
|
+
label: i,
|
|
1348
|
+
required: f,
|
|
1349
|
+
schema: s,
|
|
1350
|
+
enabled: l,
|
|
1351
|
+
readonly: a,
|
|
1352
|
+
errors: o,
|
|
1353
|
+
visible: c = !0
|
|
1266
1354
|
}) => {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
), [ee, x] = _(null), [J, F] = _(!1), [V, j] = _(null), K = de(null), $ = V ?? (S == null ? void 0 : S.sheet) ?? null, Q = (S == null ? void 0 : S.derivations) ?? [], re = $ != null || S != null, ie = ke(
|
|
1275
|
-
async (E) => {
|
|
1276
|
-
if (x(null), E.size > v) {
|
|
1277
|
-
x(`File exceeds the ${me(v)} limit.`);
|
|
1355
|
+
ce(c, r, t, null);
|
|
1356
|
+
const u = !o || o.length === 0, y = St(l, a), p = (s == null ? void 0 : s["x-spreadsheet"]) ?? {}, m = (s == null ? void 0 : s["x-evaluate"]) ?? en, v = p.accept ?? Zt, N = p.maxSize ?? Qt, A = p.persistSheet !== !1, w = p.columnHeader === !0, R = p.rowHeader === !0, L = p.showSheet !== !1, P = p.sheetName, I = e ?? null, [B, j] = F(
|
|
1357
|
+
() => I != null && I.sheet || Object.keys((I == null ? void 0 : I.derivations) ?? {}).length > 0 ? "ready" : "empty"
|
|
1358
|
+
), [M, O] = F(null), [D, V] = F(!1), [oe, ee] = F(null), le = de(null), Y = (I == null ? void 0 : I.sheet) ?? null, Z = oe ?? (Y && !je(Y) ? Y : null), re = oe == null && Y && je(Y) ? Y : null, he = (I == null ? void 0 : I.derivations) ?? {}, ne = Z != null || I != null, ue = _e(
|
|
1359
|
+
async (d) => {
|
|
1360
|
+
if (O(null), d.size > N) {
|
|
1361
|
+
O(`File exceeds the ${me(N)} limit.`);
|
|
1278
1362
|
return;
|
|
1279
1363
|
}
|
|
1280
|
-
if (!
|
|
1281
|
-
|
|
1364
|
+
if (!v.split(",").map((z) => z.trim()).some((z) => z === "*" || z === "*/*" ? !0 : z.endsWith("/*") ? d.type.startsWith(z.slice(0, -1)) : z.startsWith(".") ? d.name.toLowerCase().endsWith(z.toLowerCase()) : d.type === z)) {
|
|
1365
|
+
O(`Invalid type. Accepted: ${ge(v)}`);
|
|
1282
1366
|
return;
|
|
1283
1367
|
}
|
|
1284
|
-
|
|
1368
|
+
j("parsing");
|
|
1285
1369
|
let te;
|
|
1286
1370
|
try {
|
|
1287
|
-
const
|
|
1288
|
-
te =
|
|
1289
|
-
} catch (
|
|
1290
|
-
|
|
1291
|
-
|
|
1371
|
+
const z = await d.arrayBuffer();
|
|
1372
|
+
te = Ot(z, P).matrix;
|
|
1373
|
+
} catch (z) {
|
|
1374
|
+
j("error"), O(
|
|
1375
|
+
z instanceof $e ? z.message : "This doesn't look like a valid spreadsheet. Please check the file and try again."
|
|
1292
1376
|
);
|
|
1293
1377
|
return;
|
|
1294
1378
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1379
|
+
ee(te);
|
|
1380
|
+
let ie;
|
|
1381
|
+
try {
|
|
1382
|
+
ie = await qt(te, m, { persistSheet: A, columnHeader: w, rowHeader: R });
|
|
1383
|
+
} catch (z) {
|
|
1384
|
+
j("error"), O(z instanceof Error ? z.message : "Failed to process the uploaded spreadsheet.");
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
t(r, ie), j("ready");
|
|
1301
1388
|
},
|
|
1302
|
-
[
|
|
1389
|
+
[v, N, A, w, R, P, m, r, t]
|
|
1303
1390
|
);
|
|
1304
|
-
if (
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1391
|
+
if (c === !1)
|
|
1392
|
+
return null;
|
|
1393
|
+
if (w && R)
|
|
1394
|
+
return /* @__PURE__ */ g(C, { mb: "4", children: [
|
|
1395
|
+
/* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
|
|
1396
|
+
/* @__PURE__ */ n(h, { size: "2", color: "red", style: { display: "block" }, children: "Invalid x-spreadsheet config: columnHeader and rowHeader cannot both be true — pick one orientation." })
|
|
1397
|
+
] });
|
|
1398
|
+
if (!y && !ne) return null;
|
|
1399
|
+
const b = (d) => {
|
|
1400
|
+
d.preventDefault(), d.stopPropagation(), y && V(d.type === "dragenter" || d.type === "dragover");
|
|
1401
|
+
}, k = (d) => {
|
|
1402
|
+
var E;
|
|
1403
|
+
d.preventDefault(), d.stopPropagation(), V(!1), y && (E = d.dataTransfer.files) != null && E[0] && ue(d.dataTransfer.files[0]);
|
|
1404
|
+
}, U = (d) => {
|
|
1405
|
+
var E;
|
|
1406
|
+
(E = d.target.files) != null && E[0] && (ue(d.target.files[0]), d.target.value = "");
|
|
1407
|
+
}, T = () => {
|
|
1408
|
+
y && (ee(null), O(null), j("empty"), t(r, null));
|
|
1409
|
+
}, H = w ? 1 : 0, J = R ? 1 : 0, Q = Z ? Z.slice(H) : [], K = Q.slice(0, ve), we = Math.min(
|
|
1410
|
+
Ye,
|
|
1411
|
+
Math.max(0, ...K.map((d) => Math.max(0, d.length - J)))
|
|
1412
|
+
), Ee = Array.from({ length: we }, (d, E) => E + J), De = L && Z == null && re == null && I != null, Se = "", Fe = R && !w, Oe = re ? re.slice(0, ve) : [], Re = Array.from(new Set(Oe.flatMap((d) => Object.keys(d)))).slice(0, Ye);
|
|
1413
|
+
return /* @__PURE__ */ g(C, { mb: "4", children: [
|
|
1414
|
+
/* @__PURE__ */ g(S, { align: "center", justify: "between", mb: "2", children: [
|
|
1415
|
+
/* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
|
|
1416
|
+
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
|
|
1417
|
+
i,
|
|
1418
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
|
|
1419
|
+
] }),
|
|
1420
|
+
ne && y && /* @__PURE__ */ g(be, { children: [
|
|
1421
|
+
/* @__PURE__ */ n(We, { content: "Replace spreadsheet", children: /* @__PURE__ */ n(
|
|
1422
|
+
Ue,
|
|
1423
|
+
{
|
|
1424
|
+
variant: "ghost",
|
|
1425
|
+
size: "1",
|
|
1426
|
+
onClick: () => {
|
|
1427
|
+
var d;
|
|
1428
|
+
return (d = le.current) == null ? void 0 : d.click();
|
|
1429
|
+
},
|
|
1430
|
+
"aria-label": "Replace spreadsheet",
|
|
1431
|
+
children: /* @__PURE__ */ n(He, {})
|
|
1432
|
+
}
|
|
1433
|
+
) }),
|
|
1434
|
+
/* @__PURE__ */ n(We, { content: "Remove spreadsheet", children: /* @__PURE__ */ n(
|
|
1435
|
+
Ue,
|
|
1436
|
+
{
|
|
1437
|
+
variant: "ghost",
|
|
1438
|
+
size: "1",
|
|
1439
|
+
color: "gray",
|
|
1440
|
+
onClick: T,
|
|
1441
|
+
"aria-label": "Remove spreadsheet",
|
|
1442
|
+
children: /* @__PURE__ */ n(or, {})
|
|
1443
|
+
}
|
|
1444
|
+
) })
|
|
1445
|
+
] })
|
|
1324
1446
|
] }),
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
me(
|
|
1447
|
+
/* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
|
|
1448
|
+
me(N),
|
|
1327
1449
|
" max · ",
|
|
1328
|
-
|
|
1450
|
+
ge(v)
|
|
1329
1451
|
] })
|
|
1330
1452
|
] }),
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
{
|
|
1335
|
-
style: {
|
|
1336
|
-
background: "var(--blue-3)",
|
|
1337
|
-
padding: 8,
|
|
1338
|
-
borderRadius: 6,
|
|
1339
|
-
color: "var(--blue-9)",
|
|
1340
|
-
flexShrink: 0
|
|
1341
|
-
},
|
|
1342
|
-
children: /* @__PURE__ */ n(Qe, { width: "20", height: "20" })
|
|
1343
|
-
}
|
|
1344
|
-
),
|
|
1345
|
-
/* @__PURE__ */ n(C, { style: { flex: 1 }, children: /* @__PURE__ */ n(f, { size: "2", weight: "bold", children: "Spreadsheet uploaded" }) }),
|
|
1346
|
-
/* @__PURE__ */ n(er, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
|
|
1347
|
-
l && /* @__PURE__ */ n(je, { variant: "ghost", color: "gray", onClick: b, "aria-label": "Remove spreadsheet", children: /* @__PURE__ */ n(rr, {}) })
|
|
1348
|
-
] }) }),
|
|
1349
|
-
l && /* @__PURE__ */ p(
|
|
1453
|
+
ne && M && /* @__PURE__ */ n(h, { size: "2", color: "red", mb: "2", style: { display: "block" }, children: M }),
|
|
1454
|
+
/* @__PURE__ */ n("input", { ref: le, type: "file", style: { display: "none" }, accept: v, onChange: U }),
|
|
1455
|
+
y && !ne && /* @__PURE__ */ n(
|
|
1350
1456
|
"div",
|
|
1351
1457
|
{
|
|
1352
1458
|
role: "button",
|
|
1353
1459
|
tabIndex: 0,
|
|
1354
1460
|
onClick: () => {
|
|
1355
|
-
var
|
|
1356
|
-
return (
|
|
1461
|
+
var d;
|
|
1462
|
+
return (d = le.current) == null ? void 0 : d.click();
|
|
1357
1463
|
},
|
|
1358
|
-
onKeyDown: (
|
|
1359
|
-
var
|
|
1360
|
-
(
|
|
1464
|
+
onKeyDown: (d) => {
|
|
1465
|
+
var E;
|
|
1466
|
+
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), (E = le.current) == null || E.click());
|
|
1361
1467
|
},
|
|
1362
|
-
onDragEnter:
|
|
1363
|
-
onDragLeave:
|
|
1364
|
-
onDragOver:
|
|
1365
|
-
onDrop:
|
|
1468
|
+
onDragEnter: b,
|
|
1469
|
+
onDragLeave: b,
|
|
1470
|
+
onDragOver: b,
|
|
1471
|
+
onDrop: k,
|
|
1366
1472
|
style: { cursor: "pointer" },
|
|
1367
1473
|
className: [
|
|
1368
1474
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
1369
1475
|
"transition-all duration-200 ease-in-out",
|
|
1370
|
-
|
|
1476
|
+
D ? "border-blue-500 bg-blue-50" : M ? "border-red-300 bg-red-50" : "border-gray-300 hover:border-blue-400 hover:bg-gray-50"
|
|
1371
1477
|
].join(" "),
|
|
1372
|
-
children: [
|
|
1373
|
-
/* @__PURE__ */ n(
|
|
1374
|
-
/* @__PURE__ */ n(
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
] })
|
|
1389
|
-
] }) })
|
|
1390
|
-
]
|
|
1478
|
+
children: /* @__PURE__ */ n(S, { direction: "column", align: "center", gap: "2", children: B === "parsing" ? /* @__PURE__ */ g(be, { children: [
|
|
1479
|
+
/* @__PURE__ */ n(Me, { size: "3" }),
|
|
1480
|
+
/* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Parsing spreadsheet…" })
|
|
1481
|
+
] }) : M ? /* @__PURE__ */ g(be, { children: [
|
|
1482
|
+
/* @__PURE__ */ n(lr, { style: { width: 32, height: 32, color: "var(--red-9)" } }),
|
|
1483
|
+
/* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children: M }),
|
|
1484
|
+
/* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
|
|
1485
|
+
] }) : /* @__PURE__ */ g(be, { children: [
|
|
1486
|
+
/* @__PURE__ */ n(He, { style: { width: 32, height: 32, color: "var(--gray-8)" } }),
|
|
1487
|
+
/* @__PURE__ */ n(h, { size: "2", weight: "medium", children: "Click to upload or drag and drop" }),
|
|
1488
|
+
/* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
|
|
1489
|
+
me(N),
|
|
1490
|
+
" max · ",
|
|
1491
|
+
ge(v)
|
|
1492
|
+
] })
|
|
1493
|
+
] }) })
|
|
1391
1494
|
}
|
|
1392
1495
|
),
|
|
1393
|
-
|
|
1394
|
-
/* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */
|
|
1395
|
-
/* @__PURE__ */ n(
|
|
1396
|
-
/* @__PURE__ */ n(
|
|
1397
|
-
|
|
1398
|
-
var
|
|
1399
|
-
return
|
|
1496
|
+
Z && L && /* @__PURE__ */ g(C, { mt: "3", children: [
|
|
1497
|
+
/* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g($.Root, { variant: "surface", size: "1", children: [
|
|
1498
|
+
!Fe && /* @__PURE__ */ n($.Header, { children: /* @__PURE__ */ g($.Row, { children: [
|
|
1499
|
+
/* @__PURE__ */ n($.ColumnHeaderCell, { children: Se }),
|
|
1500
|
+
Ee.map((d) => {
|
|
1501
|
+
var E;
|
|
1502
|
+
return (
|
|
1503
|
+
// This row only renders when rowHeader isn't the sole
|
|
1504
|
+
// flag set (see suppressColumnHeaderRow) — so reaching
|
|
1505
|
+
// here, either columnHeader is true (real labels) or
|
|
1506
|
+
// both are false (columnLetter fallback).
|
|
1507
|
+
/* @__PURE__ */ n($.ColumnHeaderCell, { children: w ? Ce((E = Z[0]) == null ? void 0 : E[d]) : Nt(d) }, d)
|
|
1508
|
+
);
|
|
1400
1509
|
})
|
|
1401
1510
|
] }) }),
|
|
1402
|
-
/* @__PURE__ */ n(
|
|
1511
|
+
/* @__PURE__ */ n($.Body, { children: K.map((d, E) => {
|
|
1403
1512
|
var te;
|
|
1404
|
-
const
|
|
1405
|
-
return /* @__PURE__ */
|
|
1406
|
-
/* @__PURE__ */ n(
|
|
1407
|
-
|
|
1408
|
-
|
|
1513
|
+
const q = H + E;
|
|
1514
|
+
return /* @__PURE__ */ g($.Row, { children: [
|
|
1515
|
+
/* @__PURE__ */ n(
|
|
1516
|
+
$.RowHeaderCell,
|
|
1517
|
+
{
|
|
1518
|
+
style: R ? { fontWeight: 700, background: "var(--gray-a3)" } : void 0,
|
|
1519
|
+
children: R ? Ce((te = Z[q]) == null ? void 0 : te[0]) : w ? "" : q + 1
|
|
1520
|
+
}
|
|
1521
|
+
),
|
|
1522
|
+
Ee.map((ie) => /* @__PURE__ */ n($.Cell, { children: Ce(d[ie]) }, ie))
|
|
1523
|
+
] }, E);
|
|
1409
1524
|
}) })
|
|
1410
1525
|
] }) }),
|
|
1411
|
-
|
|
1526
|
+
Q.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1527
|
+
"Showing first ",
|
|
1528
|
+
ve,
|
|
1529
|
+
" of ",
|
|
1530
|
+
Q.length,
|
|
1531
|
+
" rows"
|
|
1532
|
+
] })
|
|
1533
|
+
] }),
|
|
1534
|
+
re && L && /* @__PURE__ */ g(C, { mt: "3", children: [
|
|
1535
|
+
/* @__PURE__ */ n(C, { style: { overflow: "auto", maxHeight: 420 }, children: /* @__PURE__ */ g($.Root, { variant: "surface", size: "1", children: [
|
|
1536
|
+
/* @__PURE__ */ n($.Header, { children: /* @__PURE__ */ g($.Row, { children: [
|
|
1537
|
+
/* @__PURE__ */ n($.ColumnHeaderCell, {}),
|
|
1538
|
+
Re.map((d) => /* @__PURE__ */ n($.ColumnHeaderCell, { children: d }, d))
|
|
1539
|
+
] }) }),
|
|
1540
|
+
/* @__PURE__ */ n($.Body, { children: Oe.map((d, E) => /* @__PURE__ */ g($.Row, { children: [
|
|
1541
|
+
/* @__PURE__ */ n($.RowHeaderCell, { children: E + 1 }),
|
|
1542
|
+
Re.map((q) => /* @__PURE__ */ n($.Cell, { children: Ce(d[q]) }, q))
|
|
1543
|
+
] }, E)) })
|
|
1544
|
+
] }) }),
|
|
1545
|
+
re.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1412
1546
|
"Showing first ",
|
|
1413
|
-
|
|
1547
|
+
ve,
|
|
1414
1548
|
" of ",
|
|
1415
|
-
|
|
1549
|
+
re.length,
|
|
1416
1550
|
" rows"
|
|
1417
1551
|
] })
|
|
1418
1552
|
] }),
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
/* @__PURE__ */ n(
|
|
1422
|
-
/* @__PURE__ */ n(
|
|
1423
|
-
/* @__PURE__ */ n(
|
|
1424
|
-
E.error ? /* @__PURE__ */ n(
|
|
1553
|
+
De && /* @__PURE__ */ n(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
|
|
1554
|
+
Object.keys(he).length > 0 && /* @__PURE__ */ g(C, { mt: "3", children: [
|
|
1555
|
+
/* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
|
|
1556
|
+
/* @__PURE__ */ n(S, { direction: "column", gap: "1", children: Object.entries(he).map(([d, E]) => /* @__PURE__ */ g(S, { justify: "between", children: [
|
|
1557
|
+
/* @__PURE__ */ n(h, { size: "2", children: E.label }),
|
|
1558
|
+
E.error ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: E.error }) : (
|
|
1425
1559
|
// d.value is CellValue | null now (SUM/AVERAGE aren't the only
|
|
1426
1560
|
// possible results anymore — INDEX/CONCATENATE can return a
|
|
1427
1561
|
// string, a bare comparison can return a boolean, etc.), so
|
|
1428
1562
|
// `.toLocaleString()` would throw for e.g. a boolean result.
|
|
1429
1563
|
// Reuse the same formatCell used for the sheet-preview grid.
|
|
1430
|
-
/* @__PURE__ */ n(
|
|
1564
|
+
/* @__PURE__ */ n(h, { size: "2", children: Ce(E.value) })
|
|
1431
1565
|
)
|
|
1432
|
-
] },
|
|
1566
|
+
] }, d)) })
|
|
1433
1567
|
] }),
|
|
1434
|
-
!
|
|
1568
|
+
!u && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
|
|
1435
1569
|
] });
|
|
1436
|
-
},
|
|
1570
|
+
}, tn = se(rn), nn = W(
|
|
1437
1571
|
10,
|
|
1438
1572
|
// matches FileControlTester's rank — beats the default object/Group renderer
|
|
1439
|
-
|
|
1573
|
+
ze(
|
|
1440
1574
|
(e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
|
|
1441
1575
|
)
|
|
1442
|
-
)
|
|
1576
|
+
);
|
|
1577
|
+
function on(e, t, r) {
|
|
1578
|
+
const i = {};
|
|
1579
|
+
for (const [f, s] of Object.entries(r)) {
|
|
1580
|
+
const { path: l, default: a } = typeof s == "string" ? { path: s, default: void 0 } : s, o = t ? `${t}.${l}` : l, c = Sr.data(e, o);
|
|
1581
|
+
if (c == null) {
|
|
1582
|
+
if (a === void 0) return;
|
|
1583
|
+
i[f] = a;
|
|
1584
|
+
} else
|
|
1585
|
+
i[f] = c;
|
|
1586
|
+
}
|
|
1587
|
+
return i;
|
|
1588
|
+
}
|
|
1589
|
+
async function ln(e, t) {
|
|
1590
|
+
try {
|
|
1591
|
+
return { status: "ok", value: await Gt(e, t) };
|
|
1592
|
+
} catch (r) {
|
|
1593
|
+
return { status: "error", error: dr(r) };
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
function sn(e, t) {
|
|
1597
|
+
return e == null ? "" : typeof e == "number" ? e.toFixed(cn(t)) : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1598
|
+
}
|
|
1599
|
+
function cn(e) {
|
|
1600
|
+
return Number.isFinite(e) ? Math.min(100, Math.max(0, Math.trunc(e))) : 0;
|
|
1601
|
+
}
|
|
1602
|
+
const Je = "{value}", an = 2, un = {}, dn = ({ data: e, handleChange: t, path: r, label: i, schema: f, visible: s = !0 }) => {
|
|
1603
|
+
var B;
|
|
1604
|
+
ce(s, r, t, null);
|
|
1605
|
+
const l = f == null ? void 0 : f["x-computed"], a = (l == null ? void 0 : l.inputs) ?? un, o = (l == null ? void 0 : l.formula) ?? "", c = (l == null ? void 0 : l.format) ?? Je, u = (l == null ? void 0 : l.decimals) ?? an, y = xr(), p = r.split(".").slice(0, -1).join("."), m = on((B = y.core) == null ? void 0 : B.data, p, a), v = m ? JSON.stringify(m) : null, N = y.readonly === !0, [A, w] = F(() => typeof e == "number" ? "ok" : "unavailable"), [R, L] = F(() => typeof e == "number" ? e : null), [P, I] = F(null);
|
|
1606
|
+
return fe(() => {
|
|
1607
|
+
if (!s) return;
|
|
1608
|
+
let j = !1;
|
|
1609
|
+
const M = (O) => {
|
|
1610
|
+
N || O !== (e ?? null) && t(r, O);
|
|
1611
|
+
};
|
|
1612
|
+
if (m === void 0) {
|
|
1613
|
+
w("unavailable"), I(null), L(null), M(null);
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
return w((O) => O === "ok" ? O : "loading"), ln(m, o).then((O) => {
|
|
1617
|
+
if (j) return;
|
|
1618
|
+
const D = O.status === "ok" && typeof O.value == "number" && Number.isFinite(O.value) ? O.value : null;
|
|
1619
|
+
if (D === null) {
|
|
1620
|
+
w("error"), I(
|
|
1621
|
+
O.status === "error" ? O.error ?? "Unable to compute value." : "Computed value must be a number."
|
|
1622
|
+
), L(null), M(null);
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
w("ok"), I(null), L(D), M(D);
|
|
1626
|
+
}), () => {
|
|
1627
|
+
j = !0;
|
|
1628
|
+
};
|
|
1629
|
+
}, [v, o, s, N]), s === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
1630
|
+
/* @__PURE__ */ n(h, { as: "label", size: "2", weight: "bold", children: i }),
|
|
1631
|
+
A === "unavailable" ? /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Not yet available." }) : A === "loading" ? /* @__PURE__ */ g(S, { align: "center", gap: "2", children: [
|
|
1632
|
+
/* @__PURE__ */ n(Me, { size: "1" }),
|
|
1633
|
+
/* @__PURE__ */ n(h, { size: "2", color: "gray", children: "Computing…" })
|
|
1634
|
+
] }) : A === "error" ? /* @__PURE__ */ n(h, { size: "2", color: "red", children: P }) : /* @__PURE__ */ n(h, { size: "2", children: c.split(Je).join(sn(R, u)) }),
|
|
1635
|
+
f.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: f.description })
|
|
1636
|
+
] }) });
|
|
1637
|
+
}, fn = se(dn), hn = W(
|
|
1638
|
+
5,
|
|
1639
|
+
ze((e) => {
|
|
1640
|
+
const t = e["x-computed"];
|
|
1641
|
+
return e.type === "number" && typeof t == "object" && t !== null;
|
|
1642
|
+
})
|
|
1643
|
+
), pn = ({
|
|
1443
1644
|
data: e,
|
|
1444
1645
|
path: t,
|
|
1445
1646
|
schema: r,
|
|
1446
|
-
uischema:
|
|
1447
|
-
enabled:
|
|
1448
|
-
visible:
|
|
1449
|
-
addItem:
|
|
1450
|
-
removeItems:
|
|
1647
|
+
uischema: i,
|
|
1648
|
+
enabled: f,
|
|
1649
|
+
visible: s,
|
|
1650
|
+
addItem: l,
|
|
1651
|
+
removeItems: a,
|
|
1451
1652
|
rootSchema: o,
|
|
1452
|
-
arraySchema:
|
|
1653
|
+
arraySchema: c
|
|
1453
1654
|
}) => {
|
|
1454
|
-
const
|
|
1455
|
-
if (
|
|
1655
|
+
const u = c ? r : r.items, y = c || r;
|
|
1656
|
+
if (s === !1 || !u || typeof u != "object" || Array.isArray(u))
|
|
1456
1657
|
return null;
|
|
1457
|
-
const
|
|
1458
|
-
const w =
|
|
1459
|
-
|
|
1658
|
+
const p = u, m = Array.isArray(e) ? e : [], v = y.title || "Array Items", N = () => {
|
|
1659
|
+
const w = Or(p, o);
|
|
1660
|
+
l && l(t, w)();
|
|
1460
1661
|
}, A = (w) => {
|
|
1461
|
-
if (
|
|
1462
|
-
const
|
|
1463
|
-
|
|
1662
|
+
if (a) {
|
|
1663
|
+
const R = a(t, [w]);
|
|
1664
|
+
R && R();
|
|
1464
1665
|
}
|
|
1465
1666
|
};
|
|
1466
|
-
return /* @__PURE__ */ n(C, { mb: "6", children: /* @__PURE__ */
|
|
1467
|
-
/* @__PURE__ */ n(
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
var
|
|
1471
|
-
const
|
|
1472
|
-
return /* @__PURE__ */ n(
|
|
1473
|
-
/* @__PURE__ */
|
|
1474
|
-
/* @__PURE__ */
|
|
1667
|
+
return /* @__PURE__ */ n(C, { mb: "6", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
|
|
1668
|
+
/* @__PURE__ */ n(h, { as: "div", size: "4", weight: "bold", children: v }),
|
|
1669
|
+
m.length === 0 && /* @__PURE__ */ n(C, { py: "4", px: "4", style: { backgroundColor: "var(--gray-3)", borderRadius: "var(--radius-3)" }, children: /* @__PURE__ */ n(h, { size: "2", color: "gray", children: "No items have been added yet." }) }),
|
|
1670
|
+
m.map((w, R) => {
|
|
1671
|
+
var P;
|
|
1672
|
+
const L = `${t}.${R}`;
|
|
1673
|
+
return /* @__PURE__ */ n(nr, { size: "3", variant: "surface", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
|
|
1674
|
+
/* @__PURE__ */ g(S, { justify: "between", align: "center", children: [
|
|
1675
|
+
/* @__PURE__ */ g(h, { size: "3", weight: "bold", children: [
|
|
1475
1676
|
"Item ",
|
|
1476
|
-
|
|
1677
|
+
R + 1
|
|
1477
1678
|
] }),
|
|
1478
|
-
|
|
1479
|
-
|
|
1679
|
+
f && /* @__PURE__ */ g(
|
|
1680
|
+
ke,
|
|
1480
1681
|
{
|
|
1481
1682
|
type: "button",
|
|
1482
1683
|
color: "red",
|
|
1483
1684
|
variant: "soft",
|
|
1484
|
-
onClick: () => A(
|
|
1685
|
+
onClick: () => A(R),
|
|
1485
1686
|
title: "Remove item",
|
|
1486
1687
|
children: [
|
|
1487
|
-
/* @__PURE__ */ n(
|
|
1688
|
+
/* @__PURE__ */ n(Ur, {}),
|
|
1488
1689
|
"Remove"
|
|
1489
1690
|
]
|
|
1490
1691
|
}
|
|
1491
1692
|
)
|
|
1492
1693
|
] }),
|
|
1493
1694
|
/* @__PURE__ */ n(C, { children: /* @__PURE__ */ n(
|
|
1494
|
-
|
|
1695
|
+
Ae,
|
|
1495
1696
|
{
|
|
1496
|
-
schema:
|
|
1497
|
-
uischema: ((
|
|
1697
|
+
schema: p,
|
|
1698
|
+
uischema: ((P = i.options) == null ? void 0 : P.detail) || (p.type === "object" || p.properties ? {
|
|
1498
1699
|
type: "VerticalLayout",
|
|
1499
|
-
elements: Object.keys(
|
|
1700
|
+
elements: Object.keys(p.properties || {}).map((I) => ({
|
|
1500
1701
|
type: "Control",
|
|
1501
|
-
scope: `#/properties/${
|
|
1702
|
+
scope: `#/properties/${I}`
|
|
1502
1703
|
}))
|
|
1503
1704
|
} : {
|
|
1504
1705
|
type: "Control",
|
|
1505
1706
|
scope: "#"
|
|
1506
1707
|
}),
|
|
1507
|
-
path:
|
|
1508
|
-
enabled:
|
|
1708
|
+
path: L,
|
|
1709
|
+
enabled: f,
|
|
1509
1710
|
renderers: void 0,
|
|
1510
1711
|
cells: void 0
|
|
1511
1712
|
}
|
|
1512
1713
|
) })
|
|
1513
|
-
] }) },
|
|
1714
|
+
] }) }, L);
|
|
1514
1715
|
}),
|
|
1515
|
-
|
|
1516
|
-
/* @__PURE__ */ n(
|
|
1716
|
+
f && /* @__PURE__ */ n(C, { mt: "2", children: /* @__PURE__ */ g(ke, { type: "button", variant: "surface", onClick: N, children: [
|
|
1717
|
+
/* @__PURE__ */ n(Hr, {}),
|
|
1517
1718
|
"Add Item"
|
|
1518
1719
|
] }) })
|
|
1519
1720
|
] }) });
|
|
1520
|
-
},
|
|
1721
|
+
}, qe = Mr(pn), mn = W(3, Nr), gn = ({ uischema: e, visible: t }) => {
|
|
1521
1722
|
const r = e;
|
|
1522
|
-
return t === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ n(
|
|
1523
|
-
},
|
|
1524
|
-
{ tester:
|
|
1525
|
-
{ tester:
|
|
1526
|
-
{ tester: Pr, renderer: Vr },
|
|
1527
|
-
{ tester: Wr, renderer: Br },
|
|
1723
|
+
return t === !1 ? null : /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ n(tr, { size: "4", children: r.text }) });
|
|
1724
|
+
}, yn = W(1, Te("Label")), vn = W(3, Ir), xn = [
|
|
1725
|
+
{ tester: Kr, renderer: Gr },
|
|
1726
|
+
{ tester: jr, renderer: Yr },
|
|
1528
1727
|
{ tester: qr, renderer: Zr },
|
|
1529
|
-
{ tester:
|
|
1530
|
-
{ tester: rt, renderer: tt },
|
|
1531
|
-
{ tester: ot, renderer: nt },
|
|
1532
|
-
{ tester: it, renderer: lt },
|
|
1728
|
+
{ tester: et, renderer: rt },
|
|
1533
1729
|
{ tester: ct, renderer: st },
|
|
1534
|
-
{ tester:
|
|
1535
|
-
{ tester:
|
|
1536
|
-
{ tester:
|
|
1537
|
-
{ tester:
|
|
1538
|
-
{ tester:
|
|
1539
|
-
{ tester:
|
|
1730
|
+
{ tester: nt, renderer: ot },
|
|
1731
|
+
{ tester: ft, renderer: ht },
|
|
1732
|
+
{ tester: mt, renderer: pt },
|
|
1733
|
+
{ tester: yt, renderer: gt },
|
|
1734
|
+
{ tester: bt, renderer: vt },
|
|
1735
|
+
{ tester: Et, renderer: wt },
|
|
1736
|
+
{ tester: At, renderer: Tt },
|
|
1737
|
+
{ tester: nn, renderer: tn },
|
|
1738
|
+
{ tester: hn, renderer: fn },
|
|
1739
|
+
{ tester: mn, renderer: qe },
|
|
1740
|
+
{ tester: vn, renderer: qe },
|
|
1741
|
+
{ tester: yn, renderer: gn }
|
|
1540
1742
|
];
|
|
1541
1743
|
export {
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1744
|
+
qe as ArrayControl,
|
|
1745
|
+
mn as ArrayControlTester,
|
|
1746
|
+
Jr as BooleanControl,
|
|
1747
|
+
qr as BooleanControlTester,
|
|
1748
|
+
wt as CategorizationLayoutRenderer,
|
|
1749
|
+
Et as CategorizationLayoutTester,
|
|
1750
|
+
fn as ComputedControl,
|
|
1751
|
+
hn as ComputedControlTester,
|
|
1752
|
+
dt as DateControl,
|
|
1753
|
+
ft as DateControlTester,
|
|
1754
|
+
Tt as FileControl,
|
|
1755
|
+
At as FileControlTester,
|
|
1756
|
+
vt as GroupLayoutRenderer,
|
|
1757
|
+
bt as GroupLayoutTester,
|
|
1758
|
+
gt as HorizontalLayoutRenderer,
|
|
1759
|
+
yt as HorizontalLayoutTester,
|
|
1760
|
+
gn as LabelRenderer,
|
|
1761
|
+
yn as LabelTester,
|
|
1762
|
+
Xr as NumberControl,
|
|
1763
|
+
jr as NumberControlTester,
|
|
1764
|
+
Qr as RadioControl,
|
|
1765
|
+
et as RadioControlTester,
|
|
1766
|
+
st as SearchSelectControl,
|
|
1767
|
+
ct as SearchSelectControlTester,
|
|
1768
|
+
In as SearchServiceProvider,
|
|
1769
|
+
tt as SelectControl,
|
|
1770
|
+
nt as SelectControlTester,
|
|
1771
|
+
tn as SpreadsheetControl,
|
|
1772
|
+
nn as SpreadsheetControlTester,
|
|
1773
|
+
Br as TextControl,
|
|
1774
|
+
Kr as TextControlTester,
|
|
1775
|
+
Nn as UploadProvider,
|
|
1776
|
+
pt as VerticalLayoutRenderer,
|
|
1777
|
+
mt as VerticalLayoutTester,
|
|
1778
|
+
xn as radixRenderers,
|
|
1779
|
+
Wr as useSearchService,
|
|
1780
|
+
Vr as useUpload
|
|
1577
1781
|
};
|