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