@opennsw/jsonforms-renderers 0.5.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 +6 -1
- package/dist/jsonforms-renderers.css +1 -1
- package/dist/renderers.cjs.js +2 -2
- package/dist/renderers.es.js +1060 -849
- package/package.json +1 -1
package/dist/renderers.es.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as n, jsxs as g, Fragment as
|
|
5
|
-
import { useContext as
|
|
6
|
-
import { rankWith as W, isStringControl as
|
|
7
|
-
import { withJsonFormsControlProps as
|
|
8
|
-
import { Box 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(
|
|
57
|
+
const u = s.length === 0;
|
|
58
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
59
59
|
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
60
|
-
|
|
60
|
+
i,
|
|
61
61
|
" ",
|
|
62
|
-
|
|
62
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
63
63
|
] }),
|
|
64
64
|
/* @__PURE__ */ n(
|
|
65
65
|
ye.Root,
|
|
@@ -67,129 +67,129 @@ const fe = (e, t, r, d = void 0) => {
|
|
|
67
67
|
value: e || "",
|
|
68
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
90
|
var p;
|
|
91
|
-
if (
|
|
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(
|
|
101
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
102
102
|
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
103
|
-
|
|
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: (p =
|
|
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__ */ g(
|
|
137
|
-
/* @__PURE__ */ g(
|
|
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
147
|
/* @__PURE__ */ g(h, { as: "label", size: "2", htmlFor: r, children: [
|
|
148
|
-
|
|
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
|
-
|
|
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
172
|
value: p.const,
|
|
173
173
|
label: p.title || String(p.const)
|
|
174
174
|
})));
|
|
175
175
|
const y = e;
|
|
176
|
-
return /* @__PURE__ */ n(
|
|
176
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
177
177
|
/* @__PURE__ */ g(h, { as: "div", size: "2", weight: "bold", children: [
|
|
178
|
-
|
|
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
186
|
onValueChange: (p) => {
|
|
187
|
-
const
|
|
188
|
-
|
|
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,203 +197,210 @@ const fe = (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(
|
|
202
|
-
/* @__PURE__ */ n(h, { size: "2", color:
|
|
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
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
235
|
const p = e !== void 0 ? String(e) : "";
|
|
236
|
-
return /* @__PURE__ */ n(
|
|
236
|
+
return /* @__PURE__ */ n(C, { mb: "4", children: /* @__PURE__ */ g(S, { direction: "column", gap: "1", children: [
|
|
237
237
|
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
238
|
-
|
|
238
|
+
i,
|
|
239
239
|
" ",
|
|
240
|
-
|
|
240
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
241
241
|
] }),
|
|
242
|
-
/* @__PURE__ */ g(
|
|
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
|
-
|
|
276
|
-
|
|
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
|
+
return;
|
|
279
|
+
}
|
|
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 });
|
|
277
283
|
return;
|
|
278
284
|
}
|
|
279
|
-
if (
|
|
280
|
-
let
|
|
281
|
-
return
|
|
282
|
-
!
|
|
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);
|
|
283
289
|
}).catch(() => {
|
|
284
290
|
}), () => {
|
|
285
|
-
|
|
291
|
+
d = !0;
|
|
286
292
|
};
|
|
287
|
-
}, [
|
|
288
|
-
const
|
|
289
|
-
async (
|
|
290
|
-
var
|
|
291
|
-
if (!
|
|
292
|
-
|
|
293
|
+
}, [L, P, w, A, N]);
|
|
294
|
+
const we = _e(
|
|
295
|
+
async (d, E = !1) => {
|
|
296
|
+
var te;
|
|
297
|
+
if (!A) {
|
|
298
|
+
b("Search service not configured.");
|
|
293
299
|
return;
|
|
294
300
|
}
|
|
295
|
-
(
|
|
296
|
-
const
|
|
297
|
-
|
|
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));
|
|
298
304
|
try {
|
|
299
|
-
const
|
|
300
|
-
query:
|
|
301
|
-
cursor:
|
|
302
|
-
signal:
|
|
303
|
-
|
|
304
|
-
|
|
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);
|
|
305
312
|
} catch {
|
|
306
|
-
if (
|
|
307
|
-
|
|
313
|
+
if (q.signal.aborted) return;
|
|
314
|
+
b("Failed to load results. Please try again.");
|
|
308
315
|
} finally {
|
|
309
|
-
|
|
316
|
+
q.signal.aborted || (E ? ne(!1) : re(!1));
|
|
310
317
|
}
|
|
311
318
|
},
|
|
312
|
-
[
|
|
319
|
+
[A, m == null ? void 0 : m.paginated, N]
|
|
313
320
|
);
|
|
314
|
-
if (
|
|
315
|
-
if (!
|
|
316
|
-
const
|
|
317
|
-
|
|
321
|
+
if (fe(() => {
|
|
322
|
+
if (!M) return;
|
|
323
|
+
const d = (E) => {
|
|
324
|
+
Q.current && !Q.current.contains(E.target) && O(!1);
|
|
318
325
|
};
|
|
319
|
-
return document.addEventListener("mousedown",
|
|
320
|
-
}, [
|
|
321
|
-
var
|
|
322
|
-
|
|
323
|
-
}, [
|
|
324
|
-
if (!
|
|
325
|
-
if (!
|
|
326
|
-
|
|
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;
|
|
327
334
|
return;
|
|
328
335
|
}
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
return
|
|
332
|
-
|
|
333
|
-
},
|
|
334
|
-
|
|
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);
|
|
335
342
|
};
|
|
336
|
-
}, [
|
|
343
|
+
}, [D, M, v, we]), ce(a, r, t, w ? void 0 : null), a === !1)
|
|
337
344
|
return null;
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
},
|
|
341
|
-
t(r,
|
|
342
|
-
},
|
|
343
|
-
|
|
344
|
-
},
|
|
345
|
-
(
|
|
346
|
-
}, Oe = ((
|
|
347
|
-
return /* @__PURE__ */ n(
|
|
345
|
+
const Ee = () => {
|
|
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: [
|
|
348
355
|
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: r, children: [
|
|
349
|
-
|
|
356
|
+
i,
|
|
350
357
|
" ",
|
|
351
|
-
|
|
358
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
352
359
|
] }),
|
|
353
|
-
/* @__PURE__ */ g("div", { ref:
|
|
360
|
+
/* @__PURE__ */ g("div", { ref: Q, style: { position: "relative" }, children: [
|
|
354
361
|
/* @__PURE__ */ n(
|
|
355
362
|
ye.Root,
|
|
356
363
|
{
|
|
357
364
|
id: r,
|
|
358
|
-
value:
|
|
359
|
-
placeholder:
|
|
360
|
-
disabled: !
|
|
361
|
-
readOnly:
|
|
362
|
-
style:
|
|
363
|
-
onChange: (
|
|
364
|
-
|
|
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());
|
|
365
372
|
},
|
|
366
373
|
onFocus: () => {
|
|
367
|
-
|
|
374
|
+
B && !M && Ee();
|
|
368
375
|
},
|
|
369
|
-
onKeyDown: (
|
|
370
|
-
|
|
376
|
+
onKeyDown: (d) => {
|
|
377
|
+
d.key === "Escape" && O(!1);
|
|
371
378
|
},
|
|
372
|
-
children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(
|
|
373
|
-
|
|
379
|
+
children: /* @__PURE__ */ n(ye.Slot, { side: "right", children: /* @__PURE__ */ g(S, { align: "center", gap: "1", children: [
|
|
380
|
+
L && B && /* @__PURE__ */ n(
|
|
374
381
|
"span",
|
|
375
382
|
{
|
|
376
383
|
role: "button",
|
|
377
384
|
tabIndex: 0,
|
|
378
|
-
onMouseDown: (
|
|
379
|
-
onClick:
|
|
380
|
-
onKeyDown:
|
|
385
|
+
onMouseDown: (d) => d.preventDefault(),
|
|
386
|
+
onClick: Se,
|
|
387
|
+
onKeyDown: Fe,
|
|
381
388
|
style: { lineHeight: 1, color: "var(--gray-9)", padding: "0 2px", cursor: "pointer" },
|
|
382
389
|
"aria-label": "Clear selection",
|
|
383
390
|
children: "×"
|
|
384
391
|
}
|
|
385
392
|
),
|
|
386
393
|
/* @__PURE__ */ n(
|
|
387
|
-
|
|
394
|
+
zr,
|
|
388
395
|
{
|
|
389
|
-
style: { transform:
|
|
396
|
+
style: { transform: M ? "rotate(180deg)" : void 0, transition: "transform 150ms" }
|
|
390
397
|
}
|
|
391
398
|
)
|
|
392
399
|
] }) })
|
|
393
400
|
}
|
|
394
401
|
),
|
|
395
|
-
|
|
396
|
-
|
|
402
|
+
M && /* @__PURE__ */ n(
|
|
403
|
+
C,
|
|
397
404
|
{
|
|
398
405
|
style: {
|
|
399
406
|
position: "absolute",
|
|
@@ -407,111 +414,111 @@ const fe = (e, t, r, d = void 0) => {
|
|
|
407
414
|
border: "1px solid var(--gray-a6)",
|
|
408
415
|
overflow: "hidden"
|
|
409
416
|
},
|
|
410
|
-
children:
|
|
411
|
-
|
|
412
|
-
!
|
|
413
|
-
!
|
|
414
|
-
|
|
415
|
-
|
|
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
|
+
C,
|
|
416
423
|
{
|
|
417
424
|
px: "3",
|
|
418
425
|
py: "2",
|
|
419
|
-
onMouseDown: (
|
|
420
|
-
onClick: () =>
|
|
426
|
+
onMouseDown: (E) => E.preventDefault(),
|
|
427
|
+
onClick: () => De(d),
|
|
421
428
|
style: {
|
|
422
429
|
cursor: "pointer",
|
|
423
430
|
borderRadius: "var(--radius-2)",
|
|
424
|
-
backgroundColor:
|
|
431
|
+
backgroundColor: d.id === L ? "var(--accent-3)" : void 0
|
|
425
432
|
},
|
|
426
433
|
className: "hover:bg-(--gray-3)",
|
|
427
|
-
children: /* @__PURE__ */ n(h, { size: "2", children:
|
|
434
|
+
children: /* @__PURE__ */ n(h, { size: "2", children: d.name })
|
|
428
435
|
},
|
|
429
|
-
|
|
436
|
+
d.id
|
|
430
437
|
)),
|
|
431
|
-
(
|
|
432
|
-
|
|
438
|
+
(m == null ? void 0 : m.paginated) && le && !he && /* @__PURE__ */ n(C, { px: "3", py: "2", children: /* @__PURE__ */ n(
|
|
439
|
+
ke,
|
|
433
440
|
{
|
|
434
441
|
variant: "ghost",
|
|
435
442
|
size: "1",
|
|
436
443
|
style: { width: "100%" },
|
|
437
|
-
onMouseDown: (
|
|
438
|
-
onClick: () => void
|
|
444
|
+
onMouseDown: (d) => d.preventDefault(),
|
|
445
|
+
onClick: () => void we(D, !0),
|
|
439
446
|
children: "Load more"
|
|
440
447
|
}
|
|
441
448
|
) }),
|
|
442
|
-
|
|
449
|
+
he && /* @__PURE__ */ n(S, { justify: "center", p: "2", children: /* @__PURE__ */ n(Me, {}) })
|
|
443
450
|
] }) })
|
|
444
451
|
}
|
|
445
452
|
)
|
|
446
453
|
] }),
|
|
447
|
-
!
|
|
454
|
+
!j && /* @__PURE__ */ n(h, { color: "red", size: "1", children: ae(s, i) }),
|
|
448
455
|
o.description && /* @__PURE__ */ n(h, { size: "1", color: "gray", children: o.description })
|
|
449
456
|
] }) });
|
|
450
|
-
},
|
|
457
|
+
}, st = se(it), ct = W(
|
|
451
458
|
3,
|
|
452
|
-
|
|
459
|
+
ze((e) => {
|
|
453
460
|
const t = e["x-search"];
|
|
454
|
-
return e.type === "string" && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
|
|
461
|
+
return (e.type === "string" || e.type === "object") && typeof (t == null ? void 0 : t.service) == "string" && t.service !== "";
|
|
455
462
|
})
|
|
456
|
-
),
|
|
457
|
-
const
|
|
458
|
-
return /* @__PURE__ */ n(
|
|
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: [
|
|
459
466
|
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", htmlFor: e, children: [
|
|
460
467
|
t,
|
|
461
468
|
" ",
|
|
462
469
|
r && /* @__PURE__ */ n(h, { color: "red", children: "*" })
|
|
463
470
|
] }),
|
|
464
|
-
|
|
465
|
-
!
|
|
466
|
-
|
|
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 })
|
|
467
474
|
] }) });
|
|
468
|
-
},
|
|
475
|
+
}, dt = ({
|
|
469
476
|
data: e,
|
|
470
477
|
handleChange: t,
|
|
471
478
|
path: r,
|
|
472
|
-
label:
|
|
473
|
-
required:
|
|
474
|
-
errors:
|
|
475
|
-
schema:
|
|
476
|
-
enabled:
|
|
479
|
+
label: i,
|
|
480
|
+
required: f,
|
|
481
|
+
errors: s,
|
|
482
|
+
schema: l,
|
|
483
|
+
enabled: a,
|
|
477
484
|
visible: o = !0
|
|
478
485
|
}) => {
|
|
479
|
-
if (
|
|
486
|
+
if (fe(() => {
|
|
480
487
|
o === !1 && t(r, void 0);
|
|
481
488
|
}, [o, r, t]), o === !1)
|
|
482
489
|
return null;
|
|
483
|
-
const
|
|
484
|
-
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")
|
|
485
492
|
return y(
|
|
486
493
|
/* @__PURE__ */ n(
|
|
487
494
|
ye.Root,
|
|
488
495
|
{
|
|
489
496
|
type: "time",
|
|
490
|
-
value:
|
|
491
|
-
onChange: (
|
|
492
|
-
disabled: !
|
|
493
|
-
color:
|
|
497
|
+
value: u,
|
|
498
|
+
onChange: (w) => t(r, w.target.value),
|
|
499
|
+
disabled: !a,
|
|
500
|
+
color: c ? void 0 : "red",
|
|
494
501
|
id: r
|
|
495
502
|
}
|
|
496
503
|
)
|
|
497
504
|
);
|
|
498
|
-
const p =
|
|
499
|
-
if (!
|
|
505
|
+
const p = l.format === "date-time", [m = "", v = ""] = u.split("T"), N = v.slice(0, 5), A = (w, R) => {
|
|
506
|
+
if (!w) {
|
|
500
507
|
t(r, void 0);
|
|
501
508
|
return;
|
|
502
509
|
}
|
|
503
|
-
t(r, p ?
|
|
510
|
+
t(r, p ? at(w, R || "00:00") : w);
|
|
504
511
|
};
|
|
505
512
|
return y(
|
|
506
|
-
/* @__PURE__ */ g(
|
|
513
|
+
/* @__PURE__ */ g(S, { gap: "2", align: "center", children: [
|
|
507
514
|
/* @__PURE__ */ n(
|
|
508
515
|
ye.Root,
|
|
509
516
|
{
|
|
510
517
|
type: "date",
|
|
511
|
-
value:
|
|
512
|
-
disabled: !
|
|
513
|
-
color:
|
|
514
|
-
onChange: (
|
|
518
|
+
value: m,
|
|
519
|
+
disabled: !a,
|
|
520
|
+
color: c ? void 0 : "red",
|
|
521
|
+
onChange: (w) => A(w.target.value, N),
|
|
515
522
|
id: r,
|
|
516
523
|
style: { flex: 1 }
|
|
517
524
|
}
|
|
@@ -520,116 +527,116 @@ const fe = (e, t, r, d = void 0) => {
|
|
|
520
527
|
ye.Root,
|
|
521
528
|
{
|
|
522
529
|
type: "time",
|
|
523
|
-
value:
|
|
524
|
-
disabled: !
|
|
525
|
-
color:
|
|
526
|
-
onChange: (
|
|
530
|
+
value: N,
|
|
531
|
+
disabled: !a || !m,
|
|
532
|
+
color: c ? void 0 : "red",
|
|
533
|
+
onChange: (w) => A(m, w.target.value),
|
|
527
534
|
style: { flex: 1 }
|
|
528
535
|
}
|
|
529
536
|
)
|
|
530
537
|
] })
|
|
531
538
|
);
|
|
532
|
-
},
|
|
539
|
+
}, ft = W(2, Le(Rr, Cr, Tr)), ht = se(dt), pt = ({
|
|
533
540
|
uischema: e,
|
|
534
541
|
schema: t,
|
|
535
542
|
path: r,
|
|
536
|
-
renderers:
|
|
537
|
-
cells:
|
|
538
|
-
enabled:
|
|
539
|
-
visible:
|
|
543
|
+
renderers: i,
|
|
544
|
+
cells: f,
|
|
545
|
+
enabled: s,
|
|
546
|
+
visible: l = !0
|
|
540
547
|
}) => {
|
|
541
548
|
const o = e.elements;
|
|
542
|
-
return
|
|
543
|
-
|
|
549
|
+
return l === !1 ? null : /* @__PURE__ */ n(S, { direction: "column", gap: "4", children: o.map((c, u) => /* @__PURE__ */ n(
|
|
550
|
+
Ae,
|
|
544
551
|
{
|
|
545
|
-
uischema:
|
|
552
|
+
uischema: c,
|
|
546
553
|
schema: t,
|
|
547
554
|
path: r,
|
|
548
|
-
renderers:
|
|
549
|
-
cells:
|
|
550
|
-
enabled:
|
|
555
|
+
renderers: i,
|
|
556
|
+
cells: f,
|
|
557
|
+
enabled: s
|
|
551
558
|
},
|
|
552
|
-
`${r}-${
|
|
559
|
+
`${r}-${u}`
|
|
553
560
|
)) });
|
|
554
|
-
},
|
|
561
|
+
}, mt = W(1, Te("VerticalLayout")), gt = ({
|
|
555
562
|
uischema: e,
|
|
556
563
|
schema: t,
|
|
557
564
|
path: r,
|
|
558
|
-
renderers:
|
|
559
|
-
cells:
|
|
560
|
-
enabled:
|
|
561
|
-
visible:
|
|
565
|
+
renderers: i,
|
|
566
|
+
cells: f,
|
|
567
|
+
enabled: s,
|
|
568
|
+
visible: l = !0
|
|
562
569
|
}) => {
|
|
563
570
|
const o = e.elements;
|
|
564
|
-
return
|
|
565
|
-
|
|
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,
|
|
566
573
|
{
|
|
567
|
-
uischema:
|
|
574
|
+
uischema: c,
|
|
568
575
|
schema: t,
|
|
569
576
|
path: r,
|
|
570
|
-
renderers:
|
|
571
|
-
cells:
|
|
572
|
-
enabled:
|
|
577
|
+
renderers: i,
|
|
578
|
+
cells: f,
|
|
579
|
+
enabled: s
|
|
573
580
|
}
|
|
574
|
-
) }, `${r}-${
|
|
575
|
-
},
|
|
581
|
+
) }, `${r}-${u}`)) });
|
|
582
|
+
}, yt = W(1, Te("HorizontalLayout")), vt = ({
|
|
576
583
|
uischema: e,
|
|
577
584
|
schema: t,
|
|
578
585
|
path: r,
|
|
579
|
-
renderers:
|
|
580
|
-
cells:
|
|
581
|
-
enabled:
|
|
582
|
-
visible:
|
|
586
|
+
renderers: i,
|
|
587
|
+
cells: f,
|
|
588
|
+
enabled: s,
|
|
589
|
+
visible: l = !0
|
|
583
590
|
}) => {
|
|
584
|
-
const
|
|
585
|
-
return
|
|
586
|
-
|
|
587
|
-
/* @__PURE__ */ n(
|
|
588
|
-
|
|
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,
|
|
589
596
|
{
|
|
590
|
-
uischema:
|
|
597
|
+
uischema: c,
|
|
591
598
|
schema: t,
|
|
592
599
|
path: r,
|
|
593
|
-
renderers:
|
|
594
|
-
cells:
|
|
595
|
-
enabled:
|
|
600
|
+
renderers: i,
|
|
601
|
+
cells: f,
|
|
602
|
+
enabled: s
|
|
596
603
|
},
|
|
597
|
-
`${r}-${
|
|
604
|
+
`${r}-${u}`
|
|
598
605
|
)) })
|
|
599
606
|
] });
|
|
600
|
-
},
|
|
607
|
+
}, bt = W(1, Te("Group")), wt = ({
|
|
601
608
|
uischema: e,
|
|
602
609
|
schema: t,
|
|
603
610
|
path: r,
|
|
604
|
-
renderers:
|
|
605
|
-
cells:
|
|
606
|
-
enabled:
|
|
607
|
-
visible:
|
|
611
|
+
renderers: i,
|
|
612
|
+
cells: f,
|
|
613
|
+
enabled: s,
|
|
614
|
+
visible: l = !0
|
|
608
615
|
}) => {
|
|
609
616
|
var p;
|
|
610
|
-
const o = e.elements.filter((
|
|
611
|
-
if (
|
|
612
|
-
const y = o.find((
|
|
613
|
-
return /* @__PURE__ */ g(
|
|
614
|
-
/* @__PURE__ */ n(
|
|
615
|
-
/* @__PURE__ */ n(
|
|
616
|
-
|
|
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,
|
|
617
624
|
{
|
|
618
|
-
uischema:
|
|
625
|
+
uischema: N,
|
|
619
626
|
schema: t,
|
|
620
627
|
path: r,
|
|
621
|
-
renderers:
|
|
622
|
-
cells:
|
|
623
|
-
enabled:
|
|
628
|
+
renderers: i,
|
|
629
|
+
cells: f,
|
|
630
|
+
enabled: s
|
|
624
631
|
},
|
|
625
|
-
`${r}-${v}-${
|
|
632
|
+
`${r}-${v}-${A}`
|
|
626
633
|
)) }) }, `${r}-${v}`)) })
|
|
627
634
|
] });
|
|
628
|
-
},
|
|
629
|
-
function
|
|
635
|
+
}, Et = W(1, Te("Categorization"));
|
|
636
|
+
function me(e) {
|
|
630
637
|
return e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(0)} MB` : e >= 1024 ? `${(e / 1024).toFixed(0)} KB` : `${e} B`;
|
|
631
638
|
}
|
|
632
|
-
function
|
|
639
|
+
function ge(e) {
|
|
633
640
|
return e.split(",").map((t) => {
|
|
634
641
|
if (t = t.trim(), t.endsWith("/*"))
|
|
635
642
|
return t.split("/")[0].toUpperCase() + "S";
|
|
@@ -639,109 +646,109 @@ function me(e) {
|
|
|
639
646
|
return r ? r.toUpperCase() : t;
|
|
640
647
|
}).join(", ");
|
|
641
648
|
}
|
|
642
|
-
function
|
|
649
|
+
function Rt(e) {
|
|
643
650
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
644
651
|
}
|
|
645
|
-
const
|
|
652
|
+
const Ct = ({
|
|
646
653
|
data: e,
|
|
647
654
|
handleChange: t,
|
|
648
655
|
path: r,
|
|
649
|
-
label:
|
|
650
|
-
required:
|
|
651
|
-
uischema:
|
|
652
|
-
schema:
|
|
653
|
-
enabled:
|
|
656
|
+
label: i,
|
|
657
|
+
required: f,
|
|
658
|
+
uischema: s,
|
|
659
|
+
schema: l,
|
|
660
|
+
enabled: a,
|
|
654
661
|
errors: o,
|
|
655
|
-
visible:
|
|
662
|
+
visible: c = !0
|
|
656
663
|
}) => {
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
const y = !o || o.length === 0, p = (
|
|
660
|
-
|
|
661
|
-
|
|
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();
|
|
662
669
|
}, []);
|
|
663
|
-
const
|
|
670
|
+
const ee = _e(
|
|
664
671
|
async (b) => {
|
|
665
|
-
if (
|
|
666
|
-
|
|
672
|
+
if (B(null), V.length >= v) {
|
|
673
|
+
B(`Maximum ${v} file${v > 1 ? "s" : ""} allowed.`);
|
|
667
674
|
return;
|
|
668
675
|
}
|
|
669
|
-
if (b.size >
|
|
670
|
-
|
|
676
|
+
if (b.size > N) {
|
|
677
|
+
B(`File exceeds the ${me(N)} limit.`);
|
|
671
678
|
return;
|
|
672
679
|
}
|
|
673
|
-
if (!
|
|
674
|
-
|
|
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)}`);
|
|
675
682
|
return;
|
|
676
683
|
}
|
|
677
|
-
if (!(
|
|
678
|
-
|
|
684
|
+
if (!(u != null && u.onUpload)) {
|
|
685
|
+
B("Upload service not configured.");
|
|
679
686
|
return;
|
|
680
687
|
}
|
|
681
688
|
try {
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
const J = { key:
|
|
685
|
-
|
|
686
|
-
const
|
|
687
|
-
t(r,
|
|
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]);
|
|
688
695
|
} catch {
|
|
689
|
-
|
|
696
|
+
B("Upload failed. Please try again."), D.current && (D.current.value = "");
|
|
690
697
|
}
|
|
691
698
|
},
|
|
692
|
-
[
|
|
699
|
+
[V, v, N, A, u, r, t, w]
|
|
693
700
|
);
|
|
694
|
-
if (
|
|
701
|
+
if (c === !1)
|
|
695
702
|
return null;
|
|
696
|
-
const
|
|
697
|
-
b.preventDefault(), b.stopPropagation(), !(!
|
|
698
|
-
},
|
|
699
|
-
var
|
|
700
|
-
b.preventDefault(), b.stopPropagation(),
|
|
701
|
-
},
|
|
702
|
-
var
|
|
703
|
-
(
|
|
704
|
-
},
|
|
705
|
-
if (!
|
|
706
|
-
|
|
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 = "");
|
|
711
|
+
}, re = (b) => {
|
|
712
|
+
if (!R) return;
|
|
713
|
+
M((U) => {
|
|
707
714
|
var J;
|
|
708
|
-
const
|
|
709
|
-
return
|
|
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;
|
|
710
717
|
});
|
|
711
|
-
const
|
|
712
|
-
t(r,
|
|
713
|
-
},
|
|
714
|
-
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;
|
|
715
722
|
b.preventDefault();
|
|
716
|
-
const
|
|
717
|
-
if (
|
|
718
|
-
(J = window.open(
|
|
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();
|
|
719
726
|
return;
|
|
720
727
|
}
|
|
721
|
-
const
|
|
722
|
-
if (
|
|
728
|
+
const T = window.open("", "_blank");
|
|
729
|
+
if (T)
|
|
723
730
|
try {
|
|
724
|
-
const
|
|
725
|
-
|
|
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();
|
|
726
733
|
} catch {
|
|
727
|
-
|
|
734
|
+
T.close();
|
|
728
735
|
}
|
|
729
736
|
};
|
|
730
|
-
if (!
|
|
731
|
-
const
|
|
732
|
-
return /* @__PURE__ */ g(
|
|
733
|
-
/* @__PURE__ */ g(
|
|
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: [
|
|
734
741
|
/* @__PURE__ */ g(h, { as: "label", size: "2", weight: "bold", children: [
|
|
735
|
-
|
|
736
|
-
|
|
742
|
+
i,
|
|
743
|
+
f && /* @__PURE__ */ n(h, { color: "red", children: " *" })
|
|
737
744
|
] }),
|
|
738
|
-
/* @__PURE__ */ n(h, { size: "1", color: "gray", children:
|
|
745
|
+
/* @__PURE__ */ n(h, { size: "1", color: "gray", children: w ? `Up to ${v} files · ${me(N)} each · ${ge(A)}` : `${me(N)} · ${ge(A)}` })
|
|
739
746
|
] }),
|
|
740
|
-
|
|
741
|
-
var
|
|
742
|
-
return /* @__PURE__ */ n(
|
|
747
|
+
V.map((b) => {
|
|
748
|
+
var k;
|
|
749
|
+
return /* @__PURE__ */ n(nr, { size: "2", variant: "surface", mb: "2", children: /* @__PURE__ */ g(S, { align: "center", gap: "3", children: [
|
|
743
750
|
/* @__PURE__ */ n(
|
|
744
|
-
|
|
751
|
+
C,
|
|
745
752
|
{
|
|
746
753
|
style: {
|
|
747
754
|
background: "var(--blue-3)",
|
|
@@ -750,10 +757,10 @@ const st = ({
|
|
|
750
757
|
color: "var(--blue-9)",
|
|
751
758
|
flexShrink: 0
|
|
752
759
|
},
|
|
753
|
-
children: /* @__PURE__ */ n(
|
|
760
|
+
children: /* @__PURE__ */ n(Dr, { width: "20", height: "20" })
|
|
754
761
|
}
|
|
755
762
|
),
|
|
756
|
-
/* @__PURE__ */ n(
|
|
763
|
+
/* @__PURE__ */ n(C, { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ n(
|
|
757
764
|
h,
|
|
758
765
|
{
|
|
759
766
|
size: "2",
|
|
@@ -764,70 +771,70 @@ const st = ({
|
|
|
764
771
|
textOverflow: "ellipsis",
|
|
765
772
|
whiteSpace: "nowrap"
|
|
766
773
|
},
|
|
767
|
-
children: ((
|
|
774
|
+
children: ((k = j[b]) == null ? void 0 : k.name) ?? "Uploaded File"
|
|
768
775
|
}
|
|
769
776
|
) }),
|
|
770
|
-
/* @__PURE__ */ g(
|
|
771
|
-
/* @__PURE__ */ n(
|
|
772
|
-
/* @__PURE__ */ n(
|
|
773
|
-
|
|
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, {}) })
|
|
774
781
|
] })
|
|
775
782
|
] }) }, b);
|
|
776
783
|
}),
|
|
777
|
-
|
|
784
|
+
ue && /* @__PURE__ */ g(
|
|
778
785
|
"div",
|
|
779
786
|
{
|
|
780
787
|
role: "button",
|
|
781
788
|
tabIndex: 0,
|
|
782
789
|
onClick: () => {
|
|
783
790
|
var b;
|
|
784
|
-
return (b =
|
|
791
|
+
return (b = D.current) == null ? void 0 : b.click();
|
|
785
792
|
},
|
|
786
793
|
onKeyDown: (b) => {
|
|
787
|
-
var
|
|
788
|
-
(b.key === "Enter" || b.key === " ") && (b.preventDefault(), (
|
|
794
|
+
var k;
|
|
795
|
+
(b.key === "Enter" || b.key === " ") && (b.preventDefault(), (k = D.current) == null || k.click());
|
|
789
796
|
},
|
|
790
|
-
onDragEnter:
|
|
791
|
-
onDragLeave:
|
|
792
|
-
onDragOver:
|
|
793
|
-
onDrop:
|
|
797
|
+
onDragEnter: le,
|
|
798
|
+
onDragLeave: le,
|
|
799
|
+
onDragOver: le,
|
|
800
|
+
onDrop: Y,
|
|
794
801
|
style: { cursor: "pointer" },
|
|
795
802
|
className: [
|
|
796
803
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
797
804
|
"transition-all duration-200 ease-in-out",
|
|
798
|
-
L ? "border-blue-500 bg-blue-50" :
|
|
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"
|
|
799
806
|
].join(" "),
|
|
800
807
|
children: [
|
|
801
|
-
/* @__PURE__ */ n("input", { ref:
|
|
802
|
-
/* @__PURE__ */ n(
|
|
803
|
-
/* @__PURE__ */ n(
|
|
804
|
-
/* @__PURE__ */ n(h, { size: "2", color: "red", weight: "medium", children:
|
|
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 }),
|
|
805
812
|
/* @__PURE__ */ n(h, { size: "1", color: "gray", children: "Click to try again" })
|
|
806
|
-
] }) : /* @__PURE__ */ g(
|
|
807
|
-
/* @__PURE__ */ n(
|
|
808
|
-
/* @__PURE__ */ n(h, { size: "2", weight: "medium", children:
|
|
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" }),
|
|
809
816
|
/* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
|
|
810
|
-
|
|
817
|
+
me(N),
|
|
811
818
|
" max · ",
|
|
812
|
-
|
|
819
|
+
ge(A)
|
|
813
820
|
] })
|
|
814
821
|
] }) })
|
|
815
822
|
]
|
|
816
823
|
}
|
|
817
824
|
),
|
|
818
|
-
|
|
825
|
+
R && oe && w && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block", textAlign: "center" }, children: [
|
|
819
826
|
"Maximum ",
|
|
820
827
|
v,
|
|
821
828
|
" files uploaded. Remove one to replace it."
|
|
822
829
|
] }),
|
|
823
|
-
!y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children:
|
|
830
|
+
!y && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
|
|
824
831
|
] });
|
|
825
|
-
},
|
|
832
|
+
}, Tt = se(Ct), At = W(
|
|
826
833
|
10,
|
|
827
834
|
// high rank to beat default array renderer
|
|
828
|
-
|
|
835
|
+
Ar(
|
|
829
836
|
// Match both single-file (type: string) and multi-file (type: array)
|
|
830
|
-
|
|
837
|
+
ze((e) => {
|
|
831
838
|
if (e.type === "string" && e.format === "file") return !0;
|
|
832
839
|
if (e.type === "array") {
|
|
833
840
|
const t = e.items;
|
|
@@ -837,39 +844,42 @@ const st = ({
|
|
|
837
844
|
})
|
|
838
845
|
)
|
|
839
846
|
);
|
|
840
|
-
|
|
847
|
+
function St(e, t) {
|
|
848
|
+
return e !== !1 && t !== !0;
|
|
849
|
+
}
|
|
850
|
+
class $e extends Error {
|
|
841
851
|
}
|
|
842
|
-
function
|
|
843
|
-
const r =
|
|
852
|
+
function Ot(e, t) {
|
|
853
|
+
const r = _r(e, { type: "array", cellDates: !0 });
|
|
844
854
|
if (r.SheetNames.length === 0)
|
|
845
|
-
throw new
|
|
846
|
-
const
|
|
847
|
-
if (!
|
|
848
|
-
throw new
|
|
849
|
-
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 });
|
|
850
860
|
return {
|
|
851
|
-
sheetName:
|
|
852
|
-
matrix:
|
|
853
|
-
rowCount:
|
|
854
|
-
colCount: Math.max(0, ...
|
|
861
|
+
sheetName: i,
|
|
862
|
+
matrix: s,
|
|
863
|
+
rowCount: s.length,
|
|
864
|
+
colCount: Math.max(0, ...s.map((l) => l.length))
|
|
855
865
|
};
|
|
856
866
|
}
|
|
857
|
-
function
|
|
867
|
+
function Nt(e) {
|
|
858
868
|
let t = e + 1, r = "";
|
|
859
869
|
for (; t > 0; ) {
|
|
860
|
-
const
|
|
861
|
-
r = String.fromCharCode(65 +
|
|
870
|
+
const i = (t - 1) % 26;
|
|
871
|
+
r = String.fromCharCode(65 + i) + r, t = Math.floor((t - 1) / 26);
|
|
862
872
|
}
|
|
863
873
|
return r;
|
|
864
874
|
}
|
|
865
|
-
class
|
|
866
|
-
constructor(r,
|
|
867
|
-
super(
|
|
868
|
-
|
|
875
|
+
class X extends Error {
|
|
876
|
+
constructor(r, i) {
|
|
877
|
+
super(i ?? r);
|
|
878
|
+
Pe(this, "code");
|
|
869
879
|
this.code = r, this.name = "FormulaError";
|
|
870
880
|
}
|
|
871
881
|
}
|
|
872
|
-
const
|
|
882
|
+
const It = [
|
|
873
883
|
// Logical
|
|
874
884
|
// IF is excluded here even though its native body is real, non-stub code —
|
|
875
885
|
// see LOGICAL_FUNCTIONS_WITH_BROKEN_CONDITION_COERCION below for why it's
|
|
@@ -895,7 +905,7 @@ const ft = [
|
|
|
895
905
|
// DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL.
|
|
896
906
|
"DATE",
|
|
897
907
|
"TODAY"
|
|
898
|
-
],
|
|
908
|
+
], xt = [
|
|
899
909
|
"MAX",
|
|
900
910
|
"MIN",
|
|
901
911
|
"MAXA",
|
|
@@ -914,7 +924,7 @@ const ft = [
|
|
|
914
924
|
"COUNTA",
|
|
915
925
|
// not present in fast-formula-parser's function table at all.
|
|
916
926
|
"UPPER"
|
|
917
|
-
],
|
|
927
|
+
], Mt = ["YEAR", "MONTH", "DAY", "WEEKDAY"], kt = ["IF"], Lt = [
|
|
918
928
|
"CONCATENATE",
|
|
919
929
|
"CONCAT",
|
|
920
930
|
"LEN",
|
|
@@ -925,115 +935,115 @@ const ft = [
|
|
|
925
935
|
"MID",
|
|
926
936
|
"FIND",
|
|
927
937
|
"SEARCH"
|
|
928
|
-
],
|
|
929
|
-
...
|
|
930
|
-
...
|
|
931
|
-
...
|
|
932
|
-
...
|
|
933
|
-
...
|
|
934
|
-
]),
|
|
935
|
-
function
|
|
936
|
-
const t = e.replace(
|
|
937
|
-
|
|
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;
|
|
938
948
|
let r;
|
|
939
|
-
for (; (r =
|
|
940
|
-
const
|
|
941
|
-
if (!
|
|
942
|
-
throw new
|
|
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.`);
|
|
943
953
|
}
|
|
944
954
|
}
|
|
945
|
-
function
|
|
946
|
-
let
|
|
947
|
-
if (
|
|
948
|
-
if (typeof
|
|
949
|
-
if (typeof
|
|
950
|
-
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;
|
|
951
961
|
throw r.VALUE;
|
|
952
962
|
}
|
|
953
|
-
function
|
|
963
|
+
function cr(e) {
|
|
954
964
|
return e !== null && typeof e == "object" && "value" in e ? e.value : e;
|
|
955
965
|
}
|
|
956
|
-
function
|
|
957
|
-
const t =
|
|
966
|
+
function pe(e) {
|
|
967
|
+
const t = cr(e);
|
|
958
968
|
return Array.isArray(t) ? t.flat(1 / 0) : [t];
|
|
959
969
|
}
|
|
960
|
-
function
|
|
961
|
-
const t =
|
|
970
|
+
function x(e) {
|
|
971
|
+
const t = cr(e);
|
|
962
972
|
return Array.isArray(t) ? t.flat(1 / 0)[0] : t;
|
|
963
973
|
}
|
|
964
|
-
function
|
|
965
|
-
return e === void 0 ? void 0 :
|
|
974
|
+
function xe(e) {
|
|
975
|
+
return e === void 0 ? void 0 : x(e);
|
|
966
976
|
}
|
|
967
|
-
function
|
|
977
|
+
function G(e) {
|
|
968
978
|
return e == null || e === "" ? "" : typeof e == "boolean" ? e ? "TRUE" : "FALSE" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
969
979
|
}
|
|
970
|
-
function
|
|
980
|
+
function Ht(e, t) {
|
|
971
981
|
return e instanceof t ? e : new t(e.message || "#ERROR!");
|
|
972
982
|
}
|
|
973
|
-
function
|
|
983
|
+
function _(e) {
|
|
974
984
|
return e.find((t) => t instanceof Error);
|
|
975
985
|
}
|
|
976
|
-
function
|
|
977
|
-
const r = (
|
|
978
|
-
throw
|
|
979
|
-
},
|
|
980
|
-
const o =
|
|
981
|
-
if (
|
|
982
|
-
const
|
|
983
|
-
|
|
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);
|
|
984
994
|
}
|
|
985
|
-
const
|
|
986
|
-
return
|
|
987
|
-
},
|
|
988
|
-
const o =
|
|
989
|
-
|
|
990
|
-
const
|
|
991
|
-
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;
|
|
992
1002
|
};
|
|
993
1003
|
return {
|
|
994
1004
|
// valueIfTrue/valueIfFalse are passed through unretrieved (not
|
|
995
1005
|
// dereferenced or type-checked here) — that's what makes
|
|
996
1006
|
// `IF(FALSE, B100, 99)` a genuine short-circuit rather than a lookup.
|
|
997
|
-
IF: (
|
|
998
|
-
const
|
|
999
|
-
if (
|
|
1000
|
-
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;
|
|
1001
1011
|
},
|
|
1002
1012
|
// Empty input -> 0, matching both the hand-rolled engine this replaces
|
|
1003
1013
|
// and formulajs's own convention for MAX/MIN.
|
|
1004
|
-
MAX:
|
|
1005
|
-
MIN:
|
|
1006
|
-
MAXA:
|
|
1007
|
-
MINA:
|
|
1008
|
-
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),
|
|
1009
1019
|
// COUNTA counts non-blank entries; an error value among the args is
|
|
1010
1020
|
// itself non-blank and gets counted (matching formulajs's own COUNTA,
|
|
1011
1021
|
// which never checks for errors), so this skips the error propagation
|
|
1012
1022
|
// the other aggregates use.
|
|
1013
|
-
COUNTA:
|
|
1014
|
-
LARGE: (
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
const
|
|
1018
|
-
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;
|
|
1019
1029
|
},
|
|
1020
|
-
SMALL: (
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
const
|
|
1024
|
-
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;
|
|
1025
1035
|
},
|
|
1026
|
-
PERMUT: (
|
|
1027
|
-
const
|
|
1036
|
+
PERMUT: (s, l) => {
|
|
1037
|
+
const a = [x(s), x(l)], o = _(a);
|
|
1028
1038
|
o && r(o);
|
|
1029
|
-
const
|
|
1030
|
-
return
|
|
1039
|
+
const c = e.PERMUT(a[0], a[1]);
|
|
1040
|
+
return c instanceof Error ? r(c) : c;
|
|
1031
1041
|
},
|
|
1032
|
-
PERMUTATIONA: (
|
|
1033
|
-
const
|
|
1042
|
+
PERMUTATIONA: (s, l) => {
|
|
1043
|
+
const a = [x(s), x(l)], o = _(a);
|
|
1034
1044
|
o && r(o);
|
|
1035
|
-
const
|
|
1036
|
-
return
|
|
1045
|
+
const c = e.PERMUTATIONA(a[0], a[1]);
|
|
1046
|
+
return c instanceof Error ? r(c) : c;
|
|
1037
1047
|
},
|
|
1038
1048
|
// match_type is intentionally ignored and forced to 0 (exact match)
|
|
1039
1049
|
// regardless of what the formula author supplied — approximate/sorted
|
|
@@ -1041,43 +1051,43 @@ function Rt(e, t) {
|
|
|
1041
1051
|
// Excel's own default too) risks silently mis-ranking unsorted
|
|
1042
1052
|
// real-world data. Same scope decision as the hand-rolled engine this
|
|
1043
1053
|
// replaces, carried forward deliberately rather than dropped.
|
|
1044
|
-
MATCH: (
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1047
|
-
const
|
|
1048
|
-
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;
|
|
1049
1059
|
},
|
|
1050
|
-
SWITCH: (...
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
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);
|
|
1054
1064
|
return o instanceof Error ? r(o) : o;
|
|
1055
1065
|
},
|
|
1056
|
-
SUBSTITUTE: (
|
|
1057
|
-
const
|
|
1058
|
-
o !== void 0 &&
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
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);
|
|
1062
1072
|
return y instanceof Error ? r(y) : y;
|
|
1063
1073
|
},
|
|
1064
|
-
TEXTJOIN: (
|
|
1065
|
-
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]);
|
|
1066
1076
|
y && r(y);
|
|
1067
|
-
const p = e.TEXTJOIN(o,
|
|
1077
|
+
const p = e.TEXTJOIN(o, c, u);
|
|
1068
1078
|
return p instanceof Error ? r(p) : p;
|
|
1069
1079
|
},
|
|
1070
|
-
UPPER:
|
|
1080
|
+
UPPER: f(e.UPPER),
|
|
1071
1081
|
// See DATE_FUNCTIONS_WITH_BROKEN_NATIVE_IMPL above for why these override
|
|
1072
1082
|
// fast-formula-parser's own (real, but broken-for-Date-cells) versions.
|
|
1073
|
-
YEAR:
|
|
1074
|
-
MONTH:
|
|
1075
|
-
DAY:
|
|
1076
|
-
WEEKDAY: (
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
const
|
|
1080
|
-
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;
|
|
1081
1091
|
},
|
|
1082
1092
|
// See TEXT_FUNCTIONS_BROKEN_FOR_BLANK_CELLS above: these override fast-
|
|
1083
1093
|
// formula-parser's own (real, but broken-for-a-bare-blank-cell) versions.
|
|
@@ -1088,54 +1098,54 @@ function Rt(e, t) {
|
|
|
1088
1098
|
// Flattens every argument (a whole range included) and joins with no
|
|
1089
1099
|
// separator, matching Excel's own range-argument behavior — the native
|
|
1090
1100
|
// implementation instead inserts stray commas for a whole-range argument.
|
|
1091
|
-
CONCATENATE: (...
|
|
1092
|
-
const
|
|
1093
|
-
|
|
1094
|
-
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));
|
|
1095
1105
|
return o instanceof Error ? r(o) : o;
|
|
1096
1106
|
},
|
|
1097
|
-
CONCAT: (...
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
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));
|
|
1101
1111
|
return o instanceof Error ? r(o) : o;
|
|
1102
1112
|
},
|
|
1103
|
-
LEN:
|
|
1104
|
-
TRIM:
|
|
1105
|
-
LOWER:
|
|
1106
|
-
LEFT: (
|
|
1107
|
-
const
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1110
|
-
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;
|
|
1111
1121
|
},
|
|
1112
|
-
RIGHT: (
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
const
|
|
1116
|
-
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;
|
|
1117
1127
|
},
|
|
1118
|
-
MID: (
|
|
1119
|
-
const o =
|
|
1128
|
+
MID: (s, l, a) => {
|
|
1129
|
+
const o = x(s), c = x(l), u = x(a), y = _([o, c, u]);
|
|
1120
1130
|
y && r(y);
|
|
1121
|
-
const p = e.MID(
|
|
1131
|
+
const p = e.MID(G(o), c, u);
|
|
1122
1132
|
return p instanceof Error ? r(p) : p;
|
|
1123
1133
|
},
|
|
1124
|
-
FIND: (
|
|
1125
|
-
const o =
|
|
1134
|
+
FIND: (s, l, a) => {
|
|
1135
|
+
const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
|
|
1126
1136
|
y && r(y);
|
|
1127
|
-
const p = e.FIND(
|
|
1137
|
+
const p = e.FIND(G(o), G(c), u);
|
|
1128
1138
|
return p instanceof Error ? r(p) : p;
|
|
1129
1139
|
},
|
|
1130
|
-
SEARCH: (
|
|
1131
|
-
const o =
|
|
1140
|
+
SEARCH: (s, l, a) => {
|
|
1141
|
+
const o = x(s), c = x(l), u = xe(a), y = _([o, c]);
|
|
1132
1142
|
y && r(y);
|
|
1133
|
-
const p = e.SEARCH(
|
|
1143
|
+
const p = e.SEARCH(G(o), G(c), u);
|
|
1134
1144
|
return p instanceof Error ? r(p) : p;
|
|
1135
1145
|
}
|
|
1136
1146
|
};
|
|
1137
1147
|
}
|
|
1138
|
-
const
|
|
1148
|
+
const _t = {
|
|
1139
1149
|
"#REF!": "REF",
|
|
1140
1150
|
"#VALUE!": "VALUE",
|
|
1141
1151
|
"#DIV/0!": "DIV0",
|
|
@@ -1144,41 +1154,41 @@ const Ct = {
|
|
|
1144
1154
|
"#NUM!": "NUM",
|
|
1145
1155
|
"#NULL!": "NULL"
|
|
1146
1156
|
};
|
|
1147
|
-
function
|
|
1148
|
-
return
|
|
1157
|
+
function Ke(e) {
|
|
1158
|
+
return _t[e.error] ?? "ERROR";
|
|
1149
1159
|
}
|
|
1150
|
-
function
|
|
1151
|
-
if (e instanceof
|
|
1160
|
+
function Ge(e, t) {
|
|
1161
|
+
if (e instanceof X) return e;
|
|
1152
1162
|
if (e instanceof t) {
|
|
1153
1163
|
const r = e.details;
|
|
1154
|
-
return r instanceof
|
|
1164
|
+
return r instanceof X ? r : r instanceof t ? new X(Ke(r), r.message) : new X(Ke(e), e.message);
|
|
1155
1165
|
}
|
|
1156
|
-
return new
|
|
1166
|
+
return new X("ERROR", e instanceof Error ? e.message : void 0);
|
|
1157
1167
|
}
|
|
1158
|
-
function
|
|
1168
|
+
function Pt(e) {
|
|
1159
1169
|
return Math.max(0, ...e.map((t) => (t == null ? void 0 : t.length) ?? 0));
|
|
1160
1170
|
}
|
|
1161
|
-
function
|
|
1171
|
+
function Vt(e) {
|
|
1162
1172
|
return (t) => {
|
|
1163
1173
|
const r = e[t.row - 1];
|
|
1164
1174
|
if (t.row < 1 || t.col < 1 || r == null || t.col - 1 >= r.length)
|
|
1165
|
-
throw new
|
|
1166
|
-
const
|
|
1167
|
-
return
|
|
1175
|
+
throw new X("REF");
|
|
1176
|
+
const i = r[t.col - 1];
|
|
1177
|
+
return i == null || i === "" ? null : i;
|
|
1168
1178
|
};
|
|
1169
1179
|
}
|
|
1170
|
-
function
|
|
1180
|
+
function Wt(e) {
|
|
1171
1181
|
return (t) => {
|
|
1172
|
-
const r = Math.min(t.from.row, t.to.row),
|
|
1173
|
-
if (r > e.length ||
|
|
1174
|
-
throw new
|
|
1175
|
-
const
|
|
1176
|
-
for (let
|
|
1177
|
-
const
|
|
1178
|
-
if (
|
|
1179
|
-
const p = Math.min(
|
|
1180
|
-
for (let
|
|
1181
|
-
const v =
|
|
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)
|
|
1184
|
+
throw new X("REF");
|
|
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];
|
|
1182
1192
|
y.push(v == null || v === "" ? null : v);
|
|
1183
1193
|
}
|
|
1184
1194
|
}
|
|
@@ -1187,38 +1197,57 @@ function St(e) {
|
|
|
1187
1197
|
return o;
|
|
1188
1198
|
};
|
|
1189
1199
|
}
|
|
1190
|
-
function
|
|
1200
|
+
function Bt(e) {
|
|
1191
1201
|
if (e == null || e === "") return null;
|
|
1192
1202
|
if (typeof e == "number" || typeof e == "string" || typeof e == "boolean" || e instanceof Date)
|
|
1193
1203
|
return e;
|
|
1194
|
-
throw new
|
|
1204
|
+
throw new X("VALUE");
|
|
1195
1205
|
}
|
|
1196
|
-
async function
|
|
1197
|
-
if (typeof
|
|
1198
|
-
const r =
|
|
1199
|
-
if (r === "") throw new
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1202
|
-
const [
|
|
1206
|
+
async function ar(e, t) {
|
|
1207
|
+
if (typeof e != "string") throw new X("ERROR");
|
|
1208
|
+
const r = e.trim();
|
|
1209
|
+
if (r === "") throw new X("ERROR");
|
|
1210
|
+
const i = r.startsWith("=") ? r.slice(1) : r;
|
|
1211
|
+
Ft(i);
|
|
1212
|
+
const [f, s] = await Promise.all([
|
|
1203
1213
|
import("fast-formula-parser"),
|
|
1204
1214
|
import("@formulajs/formulajs")
|
|
1205
|
-
]),
|
|
1206
|
-
|
|
1207
|
-
onRange: St(e),
|
|
1215
|
+
]), l = f.default ?? f, a = l.FormulaError, o = new l({
|
|
1216
|
+
...t,
|
|
1208
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.
|
|
1209
|
-
functions:
|
|
1218
|
+
functions: $t(s, a)
|
|
1210
1219
|
});
|
|
1211
|
-
let
|
|
1220
|
+
let c;
|
|
1212
1221
|
try {
|
|
1213
|
-
|
|
1214
|
-
} catch (
|
|
1215
|
-
throw
|
|
1222
|
+
c = o.parse(i, { row: 1, col: 1, sheet: "Sheet1" });
|
|
1223
|
+
} catch (u) {
|
|
1224
|
+
throw Ge(u, a);
|
|
1216
1225
|
}
|
|
1217
|
-
if (
|
|
1218
|
-
throw
|
|
1219
|
-
return
|
|
1226
|
+
if (c instanceof a)
|
|
1227
|
+
throw Ge(c, a);
|
|
1228
|
+
return Bt(c);
|
|
1229
|
+
}
|
|
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
|
+
});
|
|
1220
1249
|
}
|
|
1221
|
-
const
|
|
1250
|
+
const ur = {
|
|
1222
1251
|
REF: "#REF!",
|
|
1223
1252
|
VALUE: "#VALUE!",
|
|
1224
1253
|
DIV0: "#DIV/0!",
|
|
@@ -1228,343 +1257,525 @@ const Pe = {
|
|
|
1228
1257
|
NUM: "#NUM!",
|
|
1229
1258
|
NULL: "#NULL!"
|
|
1230
1259
|
};
|
|
1231
|
-
|
|
1232
|
-
|
|
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(
|
|
1233
1271
|
t.map(async (r) => {
|
|
1234
1272
|
try {
|
|
1235
|
-
if (!r || typeof r.label != "string" || typeof r.expression != "string")
|
|
1236
|
-
throw new
|
|
1237
|
-
return { label: r.label, value: await
|
|
1238
|
-
} catch (
|
|
1239
|
-
|
|
1240
|
-
|
|
1273
|
+
if (!r || typeof r.label != "string" || typeof r.expression != "string" || typeof r.id != "string")
|
|
1274
|
+
throw new X("ERROR");
|
|
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
|
+
};
|
|
1241
1283
|
}
|
|
1242
1284
|
})
|
|
1243
1285
|
);
|
|
1244
1286
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
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 = [];
|
|
1340
|
+
function Ce(e) {
|
|
1247
1341
|
return e == null || e === "" ? "" : e instanceof Date ? e.toLocaleDateString() : String(e);
|
|
1248
1342
|
}
|
|
1249
|
-
const
|
|
1343
|
+
const rn = ({
|
|
1250
1344
|
data: e,
|
|
1251
1345
|
handleChange: t,
|
|
1252
1346
|
path: r,
|
|
1253
|
-
label:
|
|
1254
|
-
required:
|
|
1255
|
-
schema:
|
|
1256
|
-
enabled:
|
|
1257
|
-
|
|
1258
|
-
|
|
1347
|
+
label: i,
|
|
1348
|
+
required: f,
|
|
1349
|
+
schema: s,
|
|
1350
|
+
enabled: l,
|
|
1351
|
+
readonly: a,
|
|
1352
|
+
errors: o,
|
|
1353
|
+
visible: c = !0
|
|
1259
1354
|
}) => {
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
), [re, _] = k(null), [se, B] = k(!1), [P, X] = k(null), te = ue(null), D = P ?? (O == null ? void 0 : O.sheet) ?? null, ce = (O == null ? void 0 : O.derivations) ?? [], G = D != null || O != null, ae = De(
|
|
1268
|
-
async (u) => {
|
|
1269
|
-
if (_(null), u.size > v) {
|
|
1270
|
-
_(`File exceeds the ${ge(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.`);
|
|
1271
1362
|
return;
|
|
1272
1363
|
}
|
|
1273
|
-
if (!
|
|
1274
|
-
|
|
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)}`);
|
|
1275
1366
|
return;
|
|
1276
1367
|
}
|
|
1277
|
-
|
|
1278
|
-
let
|
|
1368
|
+
j("parsing");
|
|
1369
|
+
let te;
|
|
1279
1370
|
try {
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
} catch (
|
|
1283
|
-
|
|
1284
|
-
|
|
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."
|
|
1285
1376
|
);
|
|
1286
1377
|
return;
|
|
1287
1378
|
}
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
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");
|
|
1294
1388
|
},
|
|
1295
|
-
[
|
|
1389
|
+
[v, N, A, w, R, P, m, r, t]
|
|
1296
1390
|
);
|
|
1297
|
-
if (
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
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
|
+
] })
|
|
1317
1446
|
] }),
|
|
1318
1447
|
/* @__PURE__ */ g(h, { size: "1", color: "gray", children: [
|
|
1319
|
-
|
|
1448
|
+
me(N),
|
|
1320
1449
|
" max · ",
|
|
1321
|
-
|
|
1450
|
+
ge(v)
|
|
1322
1451
|
] })
|
|
1323
1452
|
] }),
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
{
|
|
1328
|
-
style: {
|
|
1329
|
-
background: "var(--blue-3)",
|
|
1330
|
-
padding: 8,
|
|
1331
|
-
borderRadius: 6,
|
|
1332
|
-
color: "var(--blue-9)",
|
|
1333
|
-
flexShrink: 0
|
|
1334
|
-
},
|
|
1335
|
-
children: /* @__PURE__ */ n(Ye, { width: "20", height: "20" })
|
|
1336
|
-
}
|
|
1337
|
-
),
|
|
1338
|
-
/* @__PURE__ */ n(R, { style: { flex: 1 }, children: /* @__PURE__ */ n(h, { size: "2", weight: "bold", children: "Spreadsheet uploaded" }) }),
|
|
1339
|
-
/* @__PURE__ */ n(Je, { style: { color: "var(--green-9)", width: 18, height: 18 } }),
|
|
1340
|
-
l && /* @__PURE__ */ n(Xe, { variant: "ghost", color: "gray", onClick: b, "aria-label": "Remove spreadsheet", children: /* @__PURE__ */ n(Ze, {}) })
|
|
1341
|
-
] }) }),
|
|
1342
|
-
l && /* @__PURE__ */ g(
|
|
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(
|
|
1343
1456
|
"div",
|
|
1344
1457
|
{
|
|
1345
1458
|
role: "button",
|
|
1346
1459
|
tabIndex: 0,
|
|
1347
1460
|
onClick: () => {
|
|
1348
|
-
var
|
|
1349
|
-
return (
|
|
1461
|
+
var d;
|
|
1462
|
+
return (d = le.current) == null ? void 0 : d.click();
|
|
1350
1463
|
},
|
|
1351
|
-
onKeyDown: (
|
|
1352
|
-
var
|
|
1353
|
-
(
|
|
1464
|
+
onKeyDown: (d) => {
|
|
1465
|
+
var E;
|
|
1466
|
+
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), (E = le.current) == null || E.click());
|
|
1354
1467
|
},
|
|
1355
|
-
onDragEnter:
|
|
1356
|
-
onDragLeave:
|
|
1357
|
-
onDragOver:
|
|
1358
|
-
onDrop:
|
|
1468
|
+
onDragEnter: b,
|
|
1469
|
+
onDragLeave: b,
|
|
1470
|
+
onDragOver: b,
|
|
1471
|
+
onDrop: k,
|
|
1359
1472
|
style: { cursor: "pointer" },
|
|
1360
1473
|
className: [
|
|
1361
1474
|
"border-2 border-dashed rounded-lg p-6 text-center",
|
|
1362
1475
|
"transition-all duration-200 ease-in-out",
|
|
1363
|
-
|
|
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"
|
|
1364
1477
|
].join(" "),
|
|
1365
|
-
children: [
|
|
1366
|
-
/* @__PURE__ */ n(
|
|
1367
|
-
/* @__PURE__ */ n(
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
] })
|
|
1382
|
-
] }) })
|
|
1383
|
-
]
|
|
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
|
+
] }) })
|
|
1384
1494
|
}
|
|
1385
1495
|
),
|
|
1386
|
-
|
|
1387
|
-
/* @__PURE__ */ n(
|
|
1388
|
-
/* @__PURE__ */ n(
|
|
1389
|
-
/* @__PURE__ */ n(
|
|
1390
|
-
|
|
1391
|
-
var
|
|
1392
|
-
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
|
+
);
|
|
1393
1509
|
})
|
|
1394
1510
|
] }) }),
|
|
1395
|
-
/* @__PURE__ */ n(
|
|
1396
|
-
var
|
|
1397
|
-
const
|
|
1398
|
-
return /* @__PURE__ */ g(
|
|
1399
|
-
/* @__PURE__ */ n(
|
|
1400
|
-
|
|
1401
|
-
|
|
1511
|
+
/* @__PURE__ */ n($.Body, { children: K.map((d, E) => {
|
|
1512
|
+
var te;
|
|
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);
|
|
1402
1524
|
}) })
|
|
1403
1525
|
] }) }),
|
|
1404
|
-
|
|
1526
|
+
Q.length > ve && /* @__PURE__ */ g(h, { size: "1", color: "gray", mt: "1", style: { display: "block" }, children: [
|
|
1405
1527
|
"Showing first ",
|
|
1406
|
-
|
|
1528
|
+
ve,
|
|
1407
1529
|
" of ",
|
|
1408
|
-
|
|
1530
|
+
Q.length,
|
|
1409
1531
|
" rows"
|
|
1410
1532
|
] })
|
|
1411
1533
|
] }),
|
|
1412
|
-
|
|
1413
|
-
|
|
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: [
|
|
1546
|
+
"Showing first ",
|
|
1547
|
+
ve,
|
|
1548
|
+
" of ",
|
|
1549
|
+
re.length,
|
|
1550
|
+
" rows"
|
|
1551
|
+
] })
|
|
1552
|
+
] }),
|
|
1553
|
+
De && /* @__PURE__ */ n(h, { size: "2", color: "gray", mt: "3", style: { display: "block" }, children: "Sheet preview not stored for this field — re-upload to view contents." }),
|
|
1554
|
+
Object.keys(he).length > 0 && /* @__PURE__ */ g(C, { mt: "3", children: [
|
|
1414
1555
|
/* @__PURE__ */ n(h, { size: "2", weight: "bold", as: "div", mb: "1", children: "Computed values" }),
|
|
1415
|
-
/* @__PURE__ */ n(
|
|
1416
|
-
/* @__PURE__ */ n(h, { size: "2", children:
|
|
1417
|
-
|
|
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 }) : (
|
|
1418
1559
|
// d.value is CellValue | null now (SUM/AVERAGE aren't the only
|
|
1419
1560
|
// possible results anymore — INDEX/CONCATENATE can return a
|
|
1420
1561
|
// string, a bare comparison can return a boolean, etc.), so
|
|
1421
1562
|
// `.toLocaleString()` would throw for e.g. a boolean result.
|
|
1422
1563
|
// Reuse the same formatCell used for the sheet-preview grid.
|
|
1423
|
-
/* @__PURE__ */ n(h, { size: "2", children:
|
|
1564
|
+
/* @__PURE__ */ n(h, { size: "2", children: Ce(E.value) })
|
|
1424
1565
|
)
|
|
1425
|
-
] },
|
|
1566
|
+
] }, d)) })
|
|
1426
1567
|
] }),
|
|
1427
|
-
!
|
|
1568
|
+
!u && /* @__PURE__ */ n(h, { color: "red", size: "1", mt: "2", style: { display: "block" }, children: ae(o, i) })
|
|
1428
1569
|
] });
|
|
1429
|
-
},
|
|
1570
|
+
}, tn = se(rn), nn = W(
|
|
1430
1571
|
10,
|
|
1431
1572
|
// matches FileControlTester's rank — beats the default object/Group renderer
|
|
1432
|
-
|
|
1573
|
+
ze(
|
|
1433
1574
|
(e) => e.type === "object" && typeof e["x-spreadsheet"] == "object"
|
|
1434
1575
|
)
|
|
1435
|
-
)
|
|
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 = ({
|
|
1436
1644
|
data: e,
|
|
1437
1645
|
path: t,
|
|
1438
1646
|
schema: r,
|
|
1439
|
-
uischema:
|
|
1440
|
-
enabled:
|
|
1441
|
-
visible:
|
|
1442
|
-
addItem:
|
|
1443
|
-
removeItems:
|
|
1647
|
+
uischema: i,
|
|
1648
|
+
enabled: f,
|
|
1649
|
+
visible: s,
|
|
1650
|
+
addItem: l,
|
|
1651
|
+
removeItems: a,
|
|
1444
1652
|
rootSchema: o,
|
|
1445
|
-
arraySchema:
|
|
1653
|
+
arraySchema: c
|
|
1446
1654
|
}) => {
|
|
1447
|
-
const
|
|
1448
|
-
if (
|
|
1655
|
+
const u = c ? r : r.items, y = c || r;
|
|
1656
|
+
if (s === !1 || !u || typeof u != "object" || Array.isArray(u))
|
|
1449
1657
|
return null;
|
|
1450
|
-
const p =
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
},
|
|
1454
|
-
if (
|
|
1455
|
-
const
|
|
1456
|
-
|
|
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)();
|
|
1661
|
+
}, A = (w) => {
|
|
1662
|
+
if (a) {
|
|
1663
|
+
const R = a(t, [w]);
|
|
1664
|
+
R && R();
|
|
1457
1665
|
}
|
|
1458
1666
|
};
|
|
1459
|
-
return /* @__PURE__ */ n(
|
|
1667
|
+
return /* @__PURE__ */ n(C, { mb: "6", children: /* @__PURE__ */ g(S, { direction: "column", gap: "4", children: [
|
|
1460
1668
|
/* @__PURE__ */ n(h, { as: "div", size: "4", weight: "bold", children: v }),
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
var
|
|
1464
|
-
const L = `${t}.${
|
|
1465
|
-
return /* @__PURE__ */ n(
|
|
1466
|
-
/* @__PURE__ */ g(
|
|
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: [
|
|
1467
1675
|
/* @__PURE__ */ g(h, { size: "3", weight: "bold", children: [
|
|
1468
1676
|
"Item ",
|
|
1469
|
-
|
|
1677
|
+
R + 1
|
|
1470
1678
|
] }),
|
|
1471
|
-
|
|
1472
|
-
|
|
1679
|
+
f && /* @__PURE__ */ g(
|
|
1680
|
+
ke,
|
|
1473
1681
|
{
|
|
1474
1682
|
type: "button",
|
|
1475
1683
|
color: "red",
|
|
1476
1684
|
variant: "soft",
|
|
1477
|
-
onClick: () =>
|
|
1685
|
+
onClick: () => A(R),
|
|
1478
1686
|
title: "Remove item",
|
|
1479
1687
|
children: [
|
|
1480
|
-
/* @__PURE__ */ n(
|
|
1688
|
+
/* @__PURE__ */ n(Ur, {}),
|
|
1481
1689
|
"Remove"
|
|
1482
1690
|
]
|
|
1483
1691
|
}
|
|
1484
1692
|
)
|
|
1485
1693
|
] }),
|
|
1486
|
-
/* @__PURE__ */ n(
|
|
1487
|
-
|
|
1694
|
+
/* @__PURE__ */ n(C, { children: /* @__PURE__ */ n(
|
|
1695
|
+
Ae,
|
|
1488
1696
|
{
|
|
1489
1697
|
schema: p,
|
|
1490
|
-
uischema: ((
|
|
1698
|
+
uischema: ((P = i.options) == null ? void 0 : P.detail) || (p.type === "object" || p.properties ? {
|
|
1491
1699
|
type: "VerticalLayout",
|
|
1492
|
-
elements: Object.keys(p.properties || {}).map((
|
|
1700
|
+
elements: Object.keys(p.properties || {}).map((I) => ({
|
|
1493
1701
|
type: "Control",
|
|
1494
|
-
scope: `#/properties/${
|
|
1702
|
+
scope: `#/properties/${I}`
|
|
1495
1703
|
}))
|
|
1496
1704
|
} : {
|
|
1497
1705
|
type: "Control",
|
|
1498
1706
|
scope: "#"
|
|
1499
1707
|
}),
|
|
1500
1708
|
path: L,
|
|
1501
|
-
enabled:
|
|
1709
|
+
enabled: f,
|
|
1502
1710
|
renderers: void 0,
|
|
1503
1711
|
cells: void 0
|
|
1504
1712
|
}
|
|
1505
1713
|
) })
|
|
1506
1714
|
] }) }, L);
|
|
1507
1715
|
}),
|
|
1508
|
-
|
|
1509
|
-
/* @__PURE__ */ n(
|
|
1716
|
+
f && /* @__PURE__ */ n(C, { mt: "2", children: /* @__PURE__ */ g(ke, { type: "button", variant: "surface", onClick: N, children: [
|
|
1717
|
+
/* @__PURE__ */ n(Hr, {}),
|
|
1510
1718
|
"Add Item"
|
|
1511
1719
|
] }) })
|
|
1512
1720
|
] }) });
|
|
1513
|
-
},
|
|
1721
|
+
}, qe = Mr(pn), mn = W(3, Nr), gn = ({ uischema: e, visible: t }) => {
|
|
1514
1722
|
const r = e;
|
|
1515
|
-
return t === !1 ? null : /* @__PURE__ */ n(
|
|
1516
|
-
},
|
|
1517
|
-
{ tester:
|
|
1518
|
-
{ tester:
|
|
1519
|
-
{ tester:
|
|
1520
|
-
{ tester:
|
|
1521
|
-
{ tester:
|
|
1522
|
-
{ tester:
|
|
1523
|
-
{ tester:
|
|
1524
|
-
{ tester:
|
|
1525
|
-
{ tester:
|
|
1526
|
-
{ tester:
|
|
1527
|
-
{ tester:
|
|
1528
|
-
{ tester:
|
|
1529
|
-
{ tester:
|
|
1530
|
-
{ tester:
|
|
1531
|
-
{ tester:
|
|
1532
|
-
{ tester:
|
|
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 },
|
|
1727
|
+
{ tester: qr, renderer: Zr },
|
|
1728
|
+
{ tester: et, renderer: rt },
|
|
1729
|
+
{ tester: ct, renderer: st },
|
|
1730
|
+
{ tester: nt, renderer: ot },
|
|
1731
|
+
{ tester: ft, renderer: ht },
|
|
1732
|
+
{ tester: mt, renderer: pt },
|
|
1733
|
+
{ tester: yt, renderer: gt },
|
|
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 }
|
|
1533
1742
|
];
|
|
1534
1743
|
export {
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
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
|
-
|
|
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
|
|
1570
1781
|
};
|