kosmio 0.1.2 → 0.1.3
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/README.md +30 -0
- package/dist/OfflineSyncContext-DWQu0vg_.js +40 -0
- package/dist/app.js +68 -57
- package/dist/context.js +1 -1
- package/dist/core.js +30 -28
- package/dist/formRegistry-CjW2-z6G.js +3622 -0
- package/dist/index.js +136 -133
- package/dist/{localizedRouter-BjT5yIzl.js → localizedRouter-CNO61cBH.js} +1 -1
- package/dist/offlineWriteQueue-BIJHFYuO.js +352 -0
- package/dist/styles.css +1 -1
- package/dist/ui.js +52 -51
- package/package.json +1 -1
- package/types/app.d.ts +7 -1
- package/types/context.d.ts +3 -2
- package/types/core.d.ts +7 -3
- package/types/ui.d.ts +15 -1
- package/dist/OfflineSyncContext-CRwPM5kh.js +0 -34
- package/dist/formRegistry-C5VIE7xu.js +0 -3469
- package/dist/offlineWriteQueue-C31IjyB_.js +0 -275
|
@@ -0,0 +1,3622 @@
|
|
|
1
|
+
import { jsx as a, jsxs as V, Fragment as yt } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as de, useContext as Je, createContext as Ze, Children as vt, isValidElement as et, useState as Z, useId as Ve, useRef as ae, useEffect as K, cloneElement as xt, useMemo as oe, useCallback as U, Fragment as Pt } from "react";
|
|
3
|
+
import { c as X } from "./classNames-CcykAxZN.js";
|
|
4
|
+
import { useTranslation as be } from "react-i18next";
|
|
5
|
+
import { b as tt, u as Nt, e as kt, d as Mt, c as ot } from "./ViewportContext-z-ZwlTIZ.js";
|
|
6
|
+
import { createPortal as nt } from "react-dom";
|
|
7
|
+
import { r as Rt, d as Bt, s as Vt } from "./shortcuts-n31uRPcv.js";
|
|
8
|
+
import { b as je } from "./offlineWriteQueue-BIJHFYuO.js";
|
|
9
|
+
const ze = {
|
|
10
|
+
start: "kosmio-text-align-start",
|
|
11
|
+
center: "kosmio-text-align-center",
|
|
12
|
+
end: "kosmio-text-align-end",
|
|
13
|
+
left: "kosmio-text-align-left",
|
|
14
|
+
right: "kosmio-text-align-right",
|
|
15
|
+
justify: "kosmio-text-align-justify"
|
|
16
|
+
}, _t = {
|
|
17
|
+
1: "t-color-1",
|
|
18
|
+
2: "t-color-2",
|
|
19
|
+
3: "t-color-3"
|
|
20
|
+
}, qt = {
|
|
21
|
+
1: "t-color-d1",
|
|
22
|
+
2: "t-color-d2",
|
|
23
|
+
3: "t-color-d3"
|
|
24
|
+
}, Ht = {
|
|
25
|
+
xxxl: "text-xxxl",
|
|
26
|
+
xxl: "text-xxl",
|
|
27
|
+
xl: "text-xl",
|
|
28
|
+
lg: "text-lg",
|
|
29
|
+
md: "text-md",
|
|
30
|
+
sm: "text-sm",
|
|
31
|
+
xs: "text-xs",
|
|
32
|
+
xxs: "text-xxs"
|
|
33
|
+
}, Yt = {
|
|
34
|
+
default: "text-font-default",
|
|
35
|
+
main: "text-font-main",
|
|
36
|
+
mono: "text-font-mono"
|
|
37
|
+
}, jt = {
|
|
38
|
+
regular: "text-weight-regular",
|
|
39
|
+
medium: "text-weight-medium",
|
|
40
|
+
semibold: "text-weight-semibold",
|
|
41
|
+
bold: "text-weight-bold"
|
|
42
|
+
}, Gt = {
|
|
43
|
+
none: "text-leading-none",
|
|
44
|
+
tight: "text-leading-tight",
|
|
45
|
+
normal: "text-leading-normal",
|
|
46
|
+
relaxed: "text-leading-relaxed"
|
|
47
|
+
};
|
|
48
|
+
function Xt(e, t) {
|
|
49
|
+
if (t == null || t === "") return;
|
|
50
|
+
const n = String(t);
|
|
51
|
+
return n.startsWith("var(") ? n : n.startsWith("--") ? `var(${n})` : `var(--kosmio-${e}-${n})`;
|
|
52
|
+
}
|
|
53
|
+
function Wt(e) {
|
|
54
|
+
return typeof e == "string" && (e.startsWith("var(") || e.startsWith("--"));
|
|
55
|
+
}
|
|
56
|
+
function Le(e, t, n = "") {
|
|
57
|
+
if (e == null || e === "") return "";
|
|
58
|
+
const r = t[e];
|
|
59
|
+
return r || (typeof e == "string" && n && e.startsWith(n) ? e : "");
|
|
60
|
+
}
|
|
61
|
+
function Qt(e) {
|
|
62
|
+
return e ? Le(e, ze, "kosmio-text-align-") : "";
|
|
63
|
+
}
|
|
64
|
+
function Kt({ left: e, center: t, right: n }) {
|
|
65
|
+
return t ? ze.center : n ? ze.right : e ? ze.left : "";
|
|
66
|
+
}
|
|
67
|
+
function Ct(e, t, n, r) {
|
|
68
|
+
return X(
|
|
69
|
+
Le(e, Yt, "text-font-"),
|
|
70
|
+
Le(t, jt, "text-weight-"),
|
|
71
|
+
Le(n, Ht, "text-"),
|
|
72
|
+
Le(r, Gt, "text-leading-")
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
function lt(e, t, n, r) {
|
|
76
|
+
const {
|
|
77
|
+
font: o = "default",
|
|
78
|
+
fontSize: s,
|
|
79
|
+
fontColor: l,
|
|
80
|
+
weight: i,
|
|
81
|
+
lineHeight: d,
|
|
82
|
+
as: c
|
|
83
|
+
} = e ?? {}, m = t ?? c, h = n ?? l, u = Ct(o, i, s, d), g = de(function({
|
|
84
|
+
className: v,
|
|
85
|
+
...b
|
|
86
|
+
}, k) {
|
|
87
|
+
return /* @__PURE__ */ a(
|
|
88
|
+
G,
|
|
89
|
+
{
|
|
90
|
+
ref: k,
|
|
91
|
+
as: m,
|
|
92
|
+
color: h,
|
|
93
|
+
...b,
|
|
94
|
+
className: X(u, r, v)
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
return g.defaultPropsConfig = {
|
|
99
|
+
typoStyle: e,
|
|
100
|
+
as: m,
|
|
101
|
+
color: h,
|
|
102
|
+
className: r
|
|
103
|
+
}, g;
|
|
104
|
+
}
|
|
105
|
+
function Mr(e = []) {
|
|
106
|
+
return e.map((t) => {
|
|
107
|
+
if (Array.isArray(t)) {
|
|
108
|
+
const [n, r, o] = t;
|
|
109
|
+
return lt(n, void 0, r, o);
|
|
110
|
+
}
|
|
111
|
+
return lt(t);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function Ut(e, t) {
|
|
115
|
+
if (e == null || Wt(e)) return "";
|
|
116
|
+
const r = (t ? qt : _t)[e];
|
|
117
|
+
return r || (t && typeof e == "string" && e.startsWith("t-color-") && !e.startsWith("t-color-d") ? e.replace("t-color-", "t-color-d") : typeof e == "string" && e.startsWith("t-color-") ? e : "");
|
|
118
|
+
}
|
|
119
|
+
const G = de(function({
|
|
120
|
+
as: t = "p",
|
|
121
|
+
color: n,
|
|
122
|
+
dynamic: r = !1,
|
|
123
|
+
size: o = "",
|
|
124
|
+
font: s = "",
|
|
125
|
+
weight: l,
|
|
126
|
+
lineHeight: i = "",
|
|
127
|
+
align: d,
|
|
128
|
+
left: c = !1,
|
|
129
|
+
center: m = !1,
|
|
130
|
+
right: h = !1,
|
|
131
|
+
inline: u = !1,
|
|
132
|
+
ellipsis: g = !1,
|
|
133
|
+
elipsis: y = !1,
|
|
134
|
+
className: v = "",
|
|
135
|
+
style: b,
|
|
136
|
+
children: k,
|
|
137
|
+
...C
|
|
138
|
+
}, L) {
|
|
139
|
+
const x = t, N = Ct(s, l, o, i), f = Qt(d), p = Ut(n, r), E = p ? void 0 : Xt("color", n), S = g || y, w = d ? "" : Kt({ left: c, center: m, right: h }), H = {
|
|
140
|
+
...E ? { "--kosmio-text-color": E } : {}
|
|
141
|
+
};
|
|
142
|
+
return /* @__PURE__ */ a(
|
|
143
|
+
x,
|
|
144
|
+
{
|
|
145
|
+
ref: L,
|
|
146
|
+
className: X(
|
|
147
|
+
"kosmio-text text",
|
|
148
|
+
N,
|
|
149
|
+
f,
|
|
150
|
+
p,
|
|
151
|
+
E && "kosmio-text-colored",
|
|
152
|
+
w,
|
|
153
|
+
u && "kosmio-text-inline text-inline",
|
|
154
|
+
S && "kosmio-text-ellipsis text-elipsis",
|
|
155
|
+
v
|
|
156
|
+
),
|
|
157
|
+
style: {
|
|
158
|
+
...H,
|
|
159
|
+
...b
|
|
160
|
+
},
|
|
161
|
+
...C,
|
|
162
|
+
children: k
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}), Jt = {
|
|
166
|
+
plain: "",
|
|
167
|
+
primary: "kosmio-button-primary primary",
|
|
168
|
+
searchFilter: "searchbar-filter",
|
|
169
|
+
searchAdd: "kosmio-button-primary primary searchbar-add"
|
|
170
|
+
}, at = (e) => e === "a", Zt = de(function({
|
|
171
|
+
as: t = "button",
|
|
172
|
+
variant: n = "plain",
|
|
173
|
+
danger: r = !1,
|
|
174
|
+
active: o = !0,
|
|
175
|
+
showTooltip: s = !1,
|
|
176
|
+
tooltipText: l = "",
|
|
177
|
+
tooltipDirection: i = "right",
|
|
178
|
+
className: d = "",
|
|
179
|
+
type: c,
|
|
180
|
+
disabled: m = !1,
|
|
181
|
+
onClick: h,
|
|
182
|
+
...u
|
|
183
|
+
}, g) {
|
|
184
|
+
const y = t, v = Jt[n] ?? n, b = i === "left" ? "left" : "right", k = l || (typeof u["aria-label"] == "string" ? u["aria-label"] : ""), C = X(
|
|
185
|
+
"kosmio-button custom-button",
|
|
186
|
+
v,
|
|
187
|
+
r && "kosmio-button-danger danger",
|
|
188
|
+
o && "kosmio-button-active active",
|
|
189
|
+
s && `kosmio-button-tooltip tooltip tooltip-${b}`,
|
|
190
|
+
d
|
|
191
|
+
);
|
|
192
|
+
return /* @__PURE__ */ a(
|
|
193
|
+
y,
|
|
194
|
+
{
|
|
195
|
+
ref: g,
|
|
196
|
+
className: C,
|
|
197
|
+
onClick: (x) => {
|
|
198
|
+
if (m && at(t)) {
|
|
199
|
+
x.preventDefault();
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
h?.(x);
|
|
203
|
+
},
|
|
204
|
+
...s ? { "data-tooltip": k } : {},
|
|
205
|
+
...at(t) ? {
|
|
206
|
+
"aria-disabled": m || void 0,
|
|
207
|
+
tabIndex: m ? -1 : u.tabIndex
|
|
208
|
+
} : {
|
|
209
|
+
type: c ?? "button",
|
|
210
|
+
disabled: m
|
|
211
|
+
},
|
|
212
|
+
...u
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
function Rr({
|
|
217
|
+
variant: e = "plain",
|
|
218
|
+
text: t,
|
|
219
|
+
icon: n,
|
|
220
|
+
iconPosition: r = "start",
|
|
221
|
+
onClick: o,
|
|
222
|
+
tooltipText: s,
|
|
223
|
+
className: l = "",
|
|
224
|
+
danger: i = !1,
|
|
225
|
+
...d
|
|
226
|
+
}) {
|
|
227
|
+
const c = d["aria-label"] ?? (typeof t == "string" ? t : void 0), m = n ? /* @__PURE__ */ a("span", { className: "kosmio-action-button-icon", children: n }) : null;
|
|
228
|
+
return /* @__PURE__ */ V(
|
|
229
|
+
Zt,
|
|
230
|
+
{
|
|
231
|
+
variant: e,
|
|
232
|
+
onClick: o,
|
|
233
|
+
"aria-label": c,
|
|
234
|
+
showTooltip: !!s,
|
|
235
|
+
tooltipText: s,
|
|
236
|
+
className: `kosmio-action-button ${l}`.trim(),
|
|
237
|
+
danger: i,
|
|
238
|
+
...d,
|
|
239
|
+
children: [
|
|
240
|
+
r === "start" ? m : null,
|
|
241
|
+
t ? /* @__PURE__ */ a(G, { as: "span", size: "sm", children: t }) : null,
|
|
242
|
+
r === "end" ? m : null
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
const en = {
|
|
248
|
+
default: "kosmio-icon icon dynamic-theme",
|
|
249
|
+
static: "kosmio-icon icon static-theme",
|
|
250
|
+
reversed: "kosmio-icon icon reversed-theme",
|
|
251
|
+
reversedDynamic: "kosmio-icon icon reversed-dynamic-theme",
|
|
252
|
+
accent: "kosmio-icon icon accent-theme",
|
|
253
|
+
invalid: "kosmio-icon icon invalid"
|
|
254
|
+
}, tn = {
|
|
255
|
+
xs: "kosmio-icon-size-xs icon-size-xs",
|
|
256
|
+
sm: "kosmio-icon-size-sm icon-size-sm",
|
|
257
|
+
md: "kosmio-icon-size-md icon-size-md",
|
|
258
|
+
xmd: "kosmio-icon-size-xmd icon-size-xmd",
|
|
259
|
+
lg: "kosmio-icon-size-lg icon-size-lg",
|
|
260
|
+
xl: "kosmio-icon-size-xl icon-size-xl",
|
|
261
|
+
xxl: "kosmio-icon-size-xxl icon-size-xxl",
|
|
262
|
+
xxxl: "kosmio-icon-size-xxxl icon-size-xxxl"
|
|
263
|
+
}, Te = de(function({
|
|
264
|
+
src: t,
|
|
265
|
+
variant: n = "default",
|
|
266
|
+
size: r,
|
|
267
|
+
className: o = "",
|
|
268
|
+
alt: s = "",
|
|
269
|
+
decorative: l = !1,
|
|
270
|
+
style: i,
|
|
271
|
+
...d
|
|
272
|
+
}, c) {
|
|
273
|
+
const m = en[n] ?? n, h = tn[r];
|
|
274
|
+
return typeof t == "string" && t.endsWith(".svg") && n !== "static" ? /* @__PURE__ */ a(
|
|
275
|
+
"span",
|
|
276
|
+
{
|
|
277
|
+
ref: c,
|
|
278
|
+
className: X(m, h, "kosmio-icon-mask icon-mask", o),
|
|
279
|
+
role: l ? void 0 : "img",
|
|
280
|
+
"aria-label": l ? void 0 : s,
|
|
281
|
+
"aria-hidden": l || void 0,
|
|
282
|
+
style: {
|
|
283
|
+
"--kosmio-icon-url": `url("${t}")`,
|
|
284
|
+
"--icon-url": `url("${t}")`,
|
|
285
|
+
...i
|
|
286
|
+
},
|
|
287
|
+
...d
|
|
288
|
+
}
|
|
289
|
+
) : /* @__PURE__ */ a(
|
|
290
|
+
"img",
|
|
291
|
+
{
|
|
292
|
+
ref: c,
|
|
293
|
+
className: X(m, h, o),
|
|
294
|
+
src: t,
|
|
295
|
+
alt: l ? "" : s,
|
|
296
|
+
"aria-hidden": l || void 0,
|
|
297
|
+
style: i,
|
|
298
|
+
...d
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}), St = Ze({
|
|
302
|
+
icons: {},
|
|
303
|
+
defaultVariant: "default"
|
|
304
|
+
});
|
|
305
|
+
function nn(e, t, n) {
|
|
306
|
+
return t ?? (e.alt != null ? e.alt : e.altKey ? n(e.altKey) : "");
|
|
307
|
+
}
|
|
308
|
+
function Br({ icons: e = {}, defaultVariant: t = "default", children: n }) {
|
|
309
|
+
return /* @__PURE__ */ a(St.Provider, { value: { icons: e, defaultVariant: t }, children: n });
|
|
310
|
+
}
|
|
311
|
+
function rn() {
|
|
312
|
+
return Je(St);
|
|
313
|
+
}
|
|
314
|
+
function wt({
|
|
315
|
+
name: e,
|
|
316
|
+
size: t,
|
|
317
|
+
variant: n,
|
|
318
|
+
alt: r,
|
|
319
|
+
decorative: o = !1,
|
|
320
|
+
...s
|
|
321
|
+
}) {
|
|
322
|
+
const { t: l } = be(), { icons: i, defaultVariant: d } = rn(), c = i?.[e];
|
|
323
|
+
return c ? /* @__PURE__ */ a(
|
|
324
|
+
Te,
|
|
325
|
+
{
|
|
326
|
+
src: c.src,
|
|
327
|
+
size: t ?? c.size,
|
|
328
|
+
variant: n ?? c.variant ?? d,
|
|
329
|
+
alt: o ? "" : nn(c, r, l),
|
|
330
|
+
decorative: o,
|
|
331
|
+
...s
|
|
332
|
+
}
|
|
333
|
+
) : null;
|
|
334
|
+
}
|
|
335
|
+
function Vr({
|
|
336
|
+
id: e,
|
|
337
|
+
title: t = "forms.shared.actionFormTitle",
|
|
338
|
+
picture: n = null,
|
|
339
|
+
type: r = "short-form",
|
|
340
|
+
buildActions: o = null,
|
|
341
|
+
actions: s = []
|
|
342
|
+
}) {
|
|
343
|
+
return {
|
|
344
|
+
id: e,
|
|
345
|
+
title: t,
|
|
346
|
+
picture: n,
|
|
347
|
+
type: r,
|
|
348
|
+
buildActions: o,
|
|
349
|
+
actions: s
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function sn(e, t, n) {
|
|
353
|
+
return e ? typeof e.buildActions == "function" ? e.buildActions(t, n) ?? [] : Array.isArray(e.actions) && e.actions.length > 0 ? e.actions : Array.isArray(t?.actions) ? t.actions : [] : [];
|
|
354
|
+
}
|
|
355
|
+
function _r(e = null, t = []) {
|
|
356
|
+
return {
|
|
357
|
+
context: e,
|
|
358
|
+
actions: t
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function qr({
|
|
362
|
+
actions: e,
|
|
363
|
+
context: t,
|
|
364
|
+
formName: n,
|
|
365
|
+
getForm: r,
|
|
366
|
+
resolveActions: o = sn
|
|
367
|
+
}) {
|
|
368
|
+
const { t: s } = be(), { form: l, formAction: i, formObject: d, openForm: c, setAdvancedForm: m, closeForm: h } = tt(), g = typeof r == "function" ? r(n ?? l, i) : null, y = d ?? null, v = t ?? y?.context ?? y ?? null, b = Array.isArray(e) ? e : o(g, y, {
|
|
369
|
+
openForm: c,
|
|
370
|
+
setAdvancedForm: m,
|
|
371
|
+
closeForm: h,
|
|
372
|
+
context: v,
|
|
373
|
+
t: s
|
|
374
|
+
});
|
|
375
|
+
return /* @__PURE__ */ a("form", { className: "full-view column-left actions-form", children: /* @__PURE__ */ a("div", { className: "full-view column-left", children: b.map((k, C) => {
|
|
376
|
+
const {
|
|
377
|
+
label: L,
|
|
378
|
+
icon: x,
|
|
379
|
+
iconName: N,
|
|
380
|
+
iconVariant: f,
|
|
381
|
+
onClick: p,
|
|
382
|
+
color: E,
|
|
383
|
+
disabled: S
|
|
384
|
+
} = k ?? {}, w = typeof L == "function" ? L(v) : L, H = typeof S == "function" ? S(v) : !!S, M = s(w);
|
|
385
|
+
return M ? /* @__PURE__ */ V(
|
|
386
|
+
"button",
|
|
387
|
+
{
|
|
388
|
+
className: `actions-form-option ${E || ""}`.trim(),
|
|
389
|
+
disabled: H,
|
|
390
|
+
onClick: (F) => {
|
|
391
|
+
F.preventDefault(), !H && p?.(v);
|
|
392
|
+
},
|
|
393
|
+
children: [
|
|
394
|
+
N ? /* @__PURE__ */ a(wt, { name: N, alt: M }) : null,
|
|
395
|
+
!N && x ? /* @__PURE__ */ a(Te, { src: x, alt: M, variant: f ?? "reversedDynamic" }) : null,
|
|
396
|
+
/* @__PURE__ */ a(G, { as: "p", size: "xs", dynamic: !0, color: 2, className: "select-sheet-label", children: M })
|
|
397
|
+
]
|
|
398
|
+
},
|
|
399
|
+
`${w}-${C}`
|
|
400
|
+
) : null;
|
|
401
|
+
}) }) });
|
|
402
|
+
}
|
|
403
|
+
function on({ className: e = "", label: t = "", onClick: n, style: r, ...o }) {
|
|
404
|
+
return /* @__PURE__ */ a(
|
|
405
|
+
"button",
|
|
406
|
+
{
|
|
407
|
+
type: "button",
|
|
408
|
+
className: X("kosmio-backdrop", e),
|
|
409
|
+
"aria-hidden": t ? void 0 : "true",
|
|
410
|
+
"aria-label": t || void 0,
|
|
411
|
+
onClick: n,
|
|
412
|
+
style: r,
|
|
413
|
+
tabIndex: t ? void 0 : -1,
|
|
414
|
+
...o
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
function Hr({ children: e, className: t = "", ...n }) {
|
|
419
|
+
return /* @__PURE__ */ a("div", { className: X("kosmio-card card", t), ...n, children: e });
|
|
420
|
+
}
|
|
421
|
+
function ln(e = 0) {
|
|
422
|
+
const t = e * 45;
|
|
423
|
+
return {
|
|
424
|
+
"--motion-row-delay": `${t}ms`,
|
|
425
|
+
opacity: 0,
|
|
426
|
+
animationName: "motion-row-appear",
|
|
427
|
+
animationDuration: "360ms",
|
|
428
|
+
animationDelay: `${t}ms`,
|
|
429
|
+
animationTimingFunction: "cubic-bezier(0.22, 1, 0.36, 1)",
|
|
430
|
+
animationFillMode: "forwards",
|
|
431
|
+
willChange: "transform, opacity"
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
function Yr({ children: e }) {
|
|
435
|
+
return vt.map(e, (t, n) => et(t) ? /* @__PURE__ */ a("div", { className: "full-w", style: ln(n), children: t }, t.key ?? n) : t);
|
|
436
|
+
}
|
|
437
|
+
const an = {
|
|
438
|
+
plain: "",
|
|
439
|
+
custom: "customCheckbox-input"
|
|
440
|
+
}, cn = de(function({
|
|
441
|
+
variant: t = "plain",
|
|
442
|
+
className: n = "",
|
|
443
|
+
containerClassName: r = "",
|
|
444
|
+
labelClassName: o = "",
|
|
445
|
+
markClassName: s = "",
|
|
446
|
+
textClassName: l = "",
|
|
447
|
+
label: i,
|
|
448
|
+
checked: d,
|
|
449
|
+
onChange: c,
|
|
450
|
+
onCheckedChange: m,
|
|
451
|
+
...h
|
|
452
|
+
}, u) {
|
|
453
|
+
const g = an[t] ?? t, y = (v) => {
|
|
454
|
+
c?.(v), m?.(v.target.checked, v);
|
|
455
|
+
};
|
|
456
|
+
return /* @__PURE__ */ V(G, { className: X(r, o), as: "label", children: [
|
|
457
|
+
/* @__PURE__ */ a("input", { ref: u, type: "checkbox", className: X(g, n), checked: d, onChange: y, ...h }),
|
|
458
|
+
s ? /* @__PURE__ */ a("span", { className: s }) : null,
|
|
459
|
+
i ? /* @__PURE__ */ a(G, { className: l, as: "span", children: i }) : null
|
|
460
|
+
] });
|
|
461
|
+
}), un = de(function({ className: t = "", type: n = "button", disabled: r = !1, children: o, ...s }, l) {
|
|
462
|
+
return /* @__PURE__ */ a(
|
|
463
|
+
"button",
|
|
464
|
+
{
|
|
465
|
+
ref: l,
|
|
466
|
+
type: n,
|
|
467
|
+
className: X("kosmio-clickable", t),
|
|
468
|
+
disabled: r,
|
|
469
|
+
...s,
|
|
470
|
+
children: o
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
});
|
|
474
|
+
function jr({ titleBox: e, children: t, className: n = "", defaultExpanded: r = !0 }) {
|
|
475
|
+
const [o, s] = Z(r), l = Ve(), i = typeof e == "function" ? e(o) : e;
|
|
476
|
+
return /* @__PURE__ */ V("div", { className: `collapsible-box full-w ${o ? "is-expanded" : "is-collapsed"} ${n}`.trim(), children: [
|
|
477
|
+
/* @__PURE__ */ a(
|
|
478
|
+
un,
|
|
479
|
+
{
|
|
480
|
+
type: "button",
|
|
481
|
+
className: "flex full-w row-left collapsible-box-trigger",
|
|
482
|
+
onClick: () => s((d) => !d),
|
|
483
|
+
"aria-expanded": o,
|
|
484
|
+
"aria-controls": l,
|
|
485
|
+
children: i
|
|
486
|
+
}
|
|
487
|
+
),
|
|
488
|
+
/* @__PURE__ */ a("div", { id: l, className: "collapsible-box-content flex full-w column-left", children: t })
|
|
489
|
+
] });
|
|
490
|
+
}
|
|
491
|
+
function Gr({ title: e, children: t, className: n = "", defaultExpanded: r = !0 }) {
|
|
492
|
+
const [o, s] = Z(r), l = Ve();
|
|
493
|
+
return /* @__PURE__ */ V("div", { className: `collapsible-card ${o ? "is-expanded" : "is-collapsed"} ${n}`.trim(), children: [
|
|
494
|
+
/* @__PURE__ */ V(
|
|
495
|
+
"button",
|
|
496
|
+
{
|
|
497
|
+
type: "button",
|
|
498
|
+
className: "card-title spaced collapsible-card-trigger",
|
|
499
|
+
onClick: () => s((i) => !i),
|
|
500
|
+
"aria-expanded": o,
|
|
501
|
+
"aria-controls": l,
|
|
502
|
+
children: [
|
|
503
|
+
/* @__PURE__ */ a(G, { as: "span", size: "xs", color: 3, children: e }),
|
|
504
|
+
/* @__PURE__ */ a("span", { className: "collapsible-card-chevron", "aria-hidden": "true" })
|
|
505
|
+
]
|
|
506
|
+
}
|
|
507
|
+
),
|
|
508
|
+
/* @__PURE__ */ V("div", { id: l, className: "collapsible-card-content flex full-w column-left", children: [
|
|
509
|
+
/* @__PURE__ */ a("span", { className: "card-divider full-w divider" }),
|
|
510
|
+
/* @__PURE__ */ a("div", { className: "card-content full-w", children: t })
|
|
511
|
+
] })
|
|
512
|
+
] });
|
|
513
|
+
}
|
|
514
|
+
function dn(e) {
|
|
515
|
+
if (e)
|
|
516
|
+
return e.size === "0px" ? "none" : `${e.size} solid ${e.color}`;
|
|
517
|
+
}
|
|
518
|
+
function fn(e, t) {
|
|
519
|
+
if (t == null || t === "") return;
|
|
520
|
+
const n = String(t);
|
|
521
|
+
return n.startsWith("var(") ? n : n.startsWith("--") ? `var(${n})` : `var(--kosmio-${e}-${n})`;
|
|
522
|
+
}
|
|
523
|
+
function mn(e, t) {
|
|
524
|
+
if (!e) return t;
|
|
525
|
+
const n = {
|
|
526
|
+
"--kosmio-container-background": e.backgroundColor,
|
|
527
|
+
"--kosmio-container-border": dn(e.borderStyle),
|
|
528
|
+
"--kosmio-container-padding": e.padding,
|
|
529
|
+
"--kosmio-container-radius": e.radii,
|
|
530
|
+
"--kosmio-container-color": fn("color", e.typoStyle?.fontColor),
|
|
531
|
+
...t
|
|
532
|
+
};
|
|
533
|
+
return Object.keys(n).forEach((r) => {
|
|
534
|
+
(n[r] == null || n[r] === "") && delete n[r];
|
|
535
|
+
}), n;
|
|
536
|
+
}
|
|
537
|
+
const hn = de(function({
|
|
538
|
+
as: t,
|
|
539
|
+
containerStyle: n,
|
|
540
|
+
children: r,
|
|
541
|
+
className: o = "",
|
|
542
|
+
style: s,
|
|
543
|
+
...l
|
|
544
|
+
}, i) {
|
|
545
|
+
const d = t ?? n?.typoStyle?.as ?? "div";
|
|
546
|
+
return /* @__PURE__ */ a(
|
|
547
|
+
d,
|
|
548
|
+
{
|
|
549
|
+
ref: i,
|
|
550
|
+
className: X("kosmio-container kosmio-card card", o),
|
|
551
|
+
style: mn(n, s),
|
|
552
|
+
...l,
|
|
553
|
+
children: r
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
});
|
|
557
|
+
function it(e, t, n) {
|
|
558
|
+
const r = t ?? e?.typoStyle?.as ?? "div", o = de(function({
|
|
559
|
+
className: l,
|
|
560
|
+
...i
|
|
561
|
+
}, d) {
|
|
562
|
+
return /* @__PURE__ */ a(
|
|
563
|
+
hn,
|
|
564
|
+
{
|
|
565
|
+
ref: d,
|
|
566
|
+
as: r,
|
|
567
|
+
containerStyle: e,
|
|
568
|
+
className: X(n, l),
|
|
569
|
+
...i
|
|
570
|
+
}
|
|
571
|
+
);
|
|
572
|
+
});
|
|
573
|
+
return o.defaultPropsConfig = { containerStyle: e, as: r, className: n }, o;
|
|
574
|
+
}
|
|
575
|
+
function Xr(e = []) {
|
|
576
|
+
return e.map((t) => {
|
|
577
|
+
if (Array.isArray(t)) {
|
|
578
|
+
const [n, r, o] = t;
|
|
579
|
+
return it(n, r, o);
|
|
580
|
+
}
|
|
581
|
+
return it(t);
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
const Wr = de(function({
|
|
585
|
+
icon: t,
|
|
586
|
+
label: n,
|
|
587
|
+
compact: r = !1,
|
|
588
|
+
className: o = "",
|
|
589
|
+
type: s = "button",
|
|
590
|
+
children: l,
|
|
591
|
+
...i
|
|
592
|
+
}, d) {
|
|
593
|
+
return /* @__PURE__ */ a(
|
|
594
|
+
"button",
|
|
595
|
+
{
|
|
596
|
+
ref: d,
|
|
597
|
+
type: s,
|
|
598
|
+
className: X("kosmio-floating-action-button", r && "is-compact", o),
|
|
599
|
+
"aria-label": n,
|
|
600
|
+
title: n,
|
|
601
|
+
...i,
|
|
602
|
+
children: t ? /* @__PURE__ */ a("span", { className: "kosmio-floating-action-button-icon", children: t }) : l
|
|
603
|
+
}
|
|
604
|
+
);
|
|
605
|
+
}), Qr = de(function({
|
|
606
|
+
icon: t,
|
|
607
|
+
title: n,
|
|
608
|
+
subtitle: r,
|
|
609
|
+
selectedLabel: o,
|
|
610
|
+
isSelectable: s = !0,
|
|
611
|
+
isSelected: l = !1,
|
|
612
|
+
className: i = "",
|
|
613
|
+
disabled: d = !1,
|
|
614
|
+
onClick: c,
|
|
615
|
+
...m
|
|
616
|
+
}, h) {
|
|
617
|
+
const u = d || !s || !c;
|
|
618
|
+
return /* @__PURE__ */ V(
|
|
619
|
+
"button",
|
|
620
|
+
{
|
|
621
|
+
ref: h,
|
|
622
|
+
type: "button",
|
|
623
|
+
className: X(
|
|
624
|
+
"kosmio-selection-button selection-button",
|
|
625
|
+
l && "is-selected",
|
|
626
|
+
!s && "is-not-selectable",
|
|
627
|
+
i
|
|
628
|
+
),
|
|
629
|
+
"aria-current": l ? "true" : void 0,
|
|
630
|
+
disabled: u,
|
|
631
|
+
onClick: u ? void 0 : c,
|
|
632
|
+
...m,
|
|
633
|
+
children: [
|
|
634
|
+
t ? /* @__PURE__ */ a("span", { className: "flex-center", children: t }) : null,
|
|
635
|
+
/* @__PURE__ */ V("span", { className: "column-left", children: [
|
|
636
|
+
/* @__PURE__ */ a(G, { as: "span", size: "xs", elipsis: !0, left: !0, children: n }),
|
|
637
|
+
r ? /* @__PURE__ */ a(G, { as: "span", size: "xxs", color: 3, left: !0, dynamic: !0, elipsis: !0, children: r }) : null
|
|
638
|
+
] }),
|
|
639
|
+
l && o ? /* @__PURE__ */ a(G, { as: "span", size: "xxs", color: 3, left: !0, dynamic: !0, children: o }) : null
|
|
640
|
+
]
|
|
641
|
+
}
|
|
642
|
+
);
|
|
643
|
+
});
|
|
644
|
+
function Kr({
|
|
645
|
+
children: e,
|
|
646
|
+
minColumnWidth: t = 150,
|
|
647
|
+
maxColumns: n,
|
|
648
|
+
gap: r = 10,
|
|
649
|
+
padding: o = 10,
|
|
650
|
+
className: s = "",
|
|
651
|
+
staggerMs: l = 50,
|
|
652
|
+
maxStaggerMs: i = 1e3,
|
|
653
|
+
...d
|
|
654
|
+
}) {
|
|
655
|
+
const c = ae(null), [m, h] = Z(null);
|
|
656
|
+
K(() => {
|
|
657
|
+
const g = () => {
|
|
658
|
+
if (!c.current) return;
|
|
659
|
+
const y = c.current.offsetWidth;
|
|
660
|
+
let v = Math.floor((y + r) / (t + r));
|
|
661
|
+
n && (v = Math.min(v, n)), h(Math.max(v, 1));
|
|
662
|
+
};
|
|
663
|
+
return g(), window.addEventListener("resize", g), () => window.removeEventListener("resize", g);
|
|
664
|
+
}, [t, n, r]);
|
|
665
|
+
const u = {
|
|
666
|
+
gridTemplateColumns: `repeat(${m ?? 1}, 1fr)`,
|
|
667
|
+
gap: `${r}px`,
|
|
668
|
+
padding: `${o}px`
|
|
669
|
+
};
|
|
670
|
+
return /* @__PURE__ */ a("div", { ref: c, className: `kosmio-grid ${s}`.trim(), style: u, ...d, children: m == null ? null : vt.map(e, (g, y) => {
|
|
671
|
+
if (!et(g)) return g;
|
|
672
|
+
const v = y % m, b = Math.floor(y / m), k = Math.min((b + v) * l, i), C = g.props?.style || {};
|
|
673
|
+
return xt(g, {
|
|
674
|
+
"data-grid-index": y,
|
|
675
|
+
"data-grid-columns": m,
|
|
676
|
+
style: {
|
|
677
|
+
...C,
|
|
678
|
+
"--kosmio-motion-delay": `${k}ms`
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}) });
|
|
682
|
+
}
|
|
683
|
+
const ct = {
|
|
684
|
+
xxs: { closed: "-2px", open: "-1px", size: "xs" },
|
|
685
|
+
xs: { closed: "-2px", open: "-1px" },
|
|
686
|
+
sm: { closed: "-2px", open: "-1px" },
|
|
687
|
+
md: { closed: "-2px", open: "-1px" },
|
|
688
|
+
xmd: { closed: "-3px", open: "-1px" },
|
|
689
|
+
lg: { closed: "-3px", open: "-1px" },
|
|
690
|
+
xl: { closed: "-4px", open: "-2px" },
|
|
691
|
+
xxl: { closed: "-5px", open: "-2px" },
|
|
692
|
+
xxxl: { closed: "-8px", open: "-4px" }
|
|
693
|
+
};
|
|
694
|
+
function pn({ colored: e = !1, size: t = "xs", isOpen: n = !1, className: r = "", style: o = {}, ...s }) {
|
|
695
|
+
const l = ct[t] ?? ct.xs, i = l.size ?? t;
|
|
696
|
+
return /* @__PURE__ */ a(
|
|
697
|
+
"span",
|
|
698
|
+
{
|
|
699
|
+
className: X(
|
|
700
|
+
"kosmio-icon-chevron icon-chevron",
|
|
701
|
+
`kosmio-icon-size-${i}`,
|
|
702
|
+
`icon-size-${i}`,
|
|
703
|
+
n && "is-open",
|
|
704
|
+
e && "colored",
|
|
705
|
+
r
|
|
706
|
+
),
|
|
707
|
+
style: {
|
|
708
|
+
"--kosmio-icon-chevron-closed-shift": l.closed,
|
|
709
|
+
"--kosmio-icon-chevron-open-shift": l.open,
|
|
710
|
+
"--icon-chevron-closed-shift": l.closed,
|
|
711
|
+
"--icon-chevron-open-shift": l.open,
|
|
712
|
+
...o
|
|
713
|
+
},
|
|
714
|
+
"aria-hidden": "true",
|
|
715
|
+
...s
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
const gn = {
|
|
720
|
+
plain: "",
|
|
721
|
+
custom: "customInput",
|
|
722
|
+
search: "searchbar-input"
|
|
723
|
+
}, bn = de(function({
|
|
724
|
+
variant: t = "plain",
|
|
725
|
+
className: n = "",
|
|
726
|
+
format: r,
|
|
727
|
+
isValid: o,
|
|
728
|
+
onChange: s,
|
|
729
|
+
onValueChange: l,
|
|
730
|
+
...i
|
|
731
|
+
}, d) {
|
|
732
|
+
const c = gn[t] ?? t, m = (u) => {
|
|
733
|
+
if (!r || u === "")
|
|
734
|
+
return !0;
|
|
735
|
+
if (r instanceof RegExp)
|
|
736
|
+
return r.lastIndex = 0, r.test(u);
|
|
737
|
+
try {
|
|
738
|
+
return new RegExp(r).test(u);
|
|
739
|
+
} catch {
|
|
740
|
+
return !0;
|
|
741
|
+
}
|
|
742
|
+
}, h = (u) => {
|
|
743
|
+
const g = u.target.value;
|
|
744
|
+
m(g) && (typeof o == "function" && !o(g, u) || (s?.(u), l?.(g, u)));
|
|
745
|
+
};
|
|
746
|
+
return /* @__PURE__ */ a(
|
|
747
|
+
"input",
|
|
748
|
+
{
|
|
749
|
+
ref: d,
|
|
750
|
+
className: `${X(c, n)} form-field`,
|
|
751
|
+
onChange: h,
|
|
752
|
+
...i
|
|
753
|
+
}
|
|
754
|
+
);
|
|
755
|
+
});
|
|
756
|
+
function yn({
|
|
757
|
+
option: e,
|
|
758
|
+
selected: t = !1,
|
|
759
|
+
onSelect: n,
|
|
760
|
+
renderIcon: r,
|
|
761
|
+
className: o = ""
|
|
762
|
+
}) {
|
|
763
|
+
const s = e?.label ?? e?.value ?? "", l = e?.icon, i = e?.iconName, d = e?.iconVariant ?? "default", c = e?.iconSize ?? "xl", m = e?.className ?? "", h = (y) => {
|
|
764
|
+
n?.(e, y);
|
|
765
|
+
}, u = r?.(e);
|
|
766
|
+
return /* @__PURE__ */ V("button", { type: "button", className: X("card column gap20 enum-option", !!!(u || !i && l) && "enum-option--text-only", t && "is-selected", m, o), "aria-pressed": t, onClick: h, children: [
|
|
767
|
+
u ?? (!i && l ? /* @__PURE__ */ a(Te, { src: l, alt: s, variant: d, size: c }) : null),
|
|
768
|
+
/* @__PURE__ */ a(G, { className: "enum-option-label", as: "span", size: "sm", children: s })
|
|
769
|
+
] });
|
|
770
|
+
}
|
|
771
|
+
const vn = (e) => typeof e == "string" || typeof e == "number", ut = (e) => vn(e) ? { value: e } : e && typeof e == "object" && "value" in e ? e : null;
|
|
772
|
+
function xn(e) {
|
|
773
|
+
return Array.isArray(e) ? e.map(ut).filter(Boolean) : !e || typeof e != "object" ? [] : Object.values(e).map(ut).filter(Boolean);
|
|
774
|
+
}
|
|
775
|
+
function dt(e, t, n) {
|
|
776
|
+
const r = e(t);
|
|
777
|
+
return r === t ? n : r;
|
|
778
|
+
}
|
|
779
|
+
function Nn({
|
|
780
|
+
enumValues: e = [],
|
|
781
|
+
selectedValue: t = null,
|
|
782
|
+
onValueChange: n,
|
|
783
|
+
translationKeyPrefix: r = "",
|
|
784
|
+
getIcon: o,
|
|
785
|
+
getLabel: s,
|
|
786
|
+
renderIcon: l,
|
|
787
|
+
translate: i,
|
|
788
|
+
isOptionVisible: d = () => !0,
|
|
789
|
+
className: c = "",
|
|
790
|
+
optionClassName: m = "",
|
|
791
|
+
ariaLabel: h
|
|
792
|
+
}) {
|
|
793
|
+
const { t: u } = be(), g = oe(() => {
|
|
794
|
+
const y = i ?? u;
|
|
795
|
+
return xn(e).filter((b) => d(b.value, b)).map((b) => {
|
|
796
|
+
const k = String(b.label ?? b.value), C = typeof s == "function" ? s(b.value, y, b) : b.labelKey ? dt(y, b.labelKey, k) : b.label != null ? b.label : r ? dt(y, `${r}.${b.value}`, k) : k;
|
|
797
|
+
return {
|
|
798
|
+
...b,
|
|
799
|
+
value: b.value,
|
|
800
|
+
label: C,
|
|
801
|
+
icon: b.icon ?? (typeof o == "function" ? o(b.value, b) : void 0),
|
|
802
|
+
iconName: b.iconName
|
|
803
|
+
};
|
|
804
|
+
});
|
|
805
|
+
}, [e, o, s, u, d, i, r]);
|
|
806
|
+
return /* @__PURE__ */ a("div", { className: X("enum-selector-grid", c), role: "radiogroup", "aria-label": h, children: g.map((y) => /* @__PURE__ */ a(
|
|
807
|
+
yn,
|
|
808
|
+
{
|
|
809
|
+
option: y,
|
|
810
|
+
selected: String(t) === String(y.value),
|
|
811
|
+
onSelect: () => n?.(y.value, y),
|
|
812
|
+
renderIcon: l,
|
|
813
|
+
className: m
|
|
814
|
+
},
|
|
815
|
+
String(y.value)
|
|
816
|
+
)) });
|
|
817
|
+
}
|
|
818
|
+
function Ur({
|
|
819
|
+
label: e,
|
|
820
|
+
checked: t = !1,
|
|
821
|
+
onChange: n,
|
|
822
|
+
required: r = !1,
|
|
823
|
+
className: o = "",
|
|
824
|
+
labelClassName: s = "",
|
|
825
|
+
fieldClassName: l = "",
|
|
826
|
+
disabled: i = !1,
|
|
827
|
+
requiredLabel: d
|
|
828
|
+
}) {
|
|
829
|
+
const { t: c } = be(), m = d ?? c("forms.shared.required", { defaultValue: "Required" });
|
|
830
|
+
return /* @__PURE__ */ a("div", { className: `form-field customCheckbox ${o}`, children: /* @__PURE__ */ a(cn, { variant: "custom", checked: t, onCheckedChange: n, required: r, disabled: i, className: l, containerClassName: `gap5 center ${s}`, markClassName: "", label: e ? /* @__PURE__ */ V(yt, { children: [
|
|
831
|
+
e,
|
|
832
|
+
r && /* @__PURE__ */ a(G, { className: "form-field-required-text", as: "span", children: m })
|
|
833
|
+
] }) : null }) });
|
|
834
|
+
}
|
|
835
|
+
const kn = de(function({
|
|
836
|
+
label: t,
|
|
837
|
+
placeholder: n = "",
|
|
838
|
+
value: r,
|
|
839
|
+
onChange: o,
|
|
840
|
+
type: s = "text",
|
|
841
|
+
required: l,
|
|
842
|
+
validations: i = {},
|
|
843
|
+
className: d = "",
|
|
844
|
+
labelClassName: c = "",
|
|
845
|
+
fieldClassName: m = "",
|
|
846
|
+
invalid: h = !1,
|
|
847
|
+
invalidLabel: u = "",
|
|
848
|
+
requiredLabel: g,
|
|
849
|
+
format: y,
|
|
850
|
+
isValid: v,
|
|
851
|
+
onKeyDown: b,
|
|
852
|
+
...k
|
|
853
|
+
}, C) {
|
|
854
|
+
const { t: L } = be(), x = g ?? L("forms.shared.required", { defaultValue: "Required" }), N = i.required ?? l, f = {
|
|
855
|
+
...i,
|
|
856
|
+
required: N
|
|
857
|
+
}, p = r == null || String(r).trim().length === 0;
|
|
858
|
+
return /* @__PURE__ */ V("div", { className: `form-field-container gap5 ${h ? "invalid" : ""} ${d}`, children: [
|
|
859
|
+
t && /* @__PURE__ */ V(G, { className: `form-field-label row-left ${c}`.trim(), as: "label", size: "xxs", children: [
|
|
860
|
+
t,
|
|
861
|
+
N && /* @__PURE__ */ a(G, { className: X("form-field-required-text", p && "empty"), as: "span", children: x })
|
|
862
|
+
] }),
|
|
863
|
+
/* @__PURE__ */ a(bn, { ref: C, variant: "custom", type: s, placeholder: n, value: r, onValueChange: o, onKeyDown: b, "aria-invalid": h, format: y, isValid: v, ...f, ...k, className: `${m}` }),
|
|
864
|
+
h && u ? /* @__PURE__ */ a(G, { as: "p", size: "xxs", className: "form-field-warning-text", left: !0, children: u }) : null
|
|
865
|
+
] });
|
|
866
|
+
}), Et = Ze(null);
|
|
867
|
+
function _e() {
|
|
868
|
+
const e = Je(Et);
|
|
869
|
+
if (!e)
|
|
870
|
+
throw new Error("Select components must be used inside SelectRoot");
|
|
871
|
+
return e;
|
|
872
|
+
}
|
|
873
|
+
function Cn() {
|
|
874
|
+
const {
|
|
875
|
+
variantClass: e,
|
|
876
|
+
className: t,
|
|
877
|
+
disabled: n,
|
|
878
|
+
required: r,
|
|
879
|
+
isOpen: o,
|
|
880
|
+
hasValue: s,
|
|
881
|
+
displayLabel: l,
|
|
882
|
+
displaySubtitle: i,
|
|
883
|
+
triggerRef: d,
|
|
884
|
+
forwardedRef: c,
|
|
885
|
+
toggleOpen: m,
|
|
886
|
+
open: h
|
|
887
|
+
} = _e();
|
|
888
|
+
return /* @__PURE__ */ V(
|
|
889
|
+
"button",
|
|
890
|
+
{
|
|
891
|
+
ref: (g) => {
|
|
892
|
+
if (d.current = g, typeof c == "function") {
|
|
893
|
+
c(g);
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
c && (c.current = g);
|
|
897
|
+
},
|
|
898
|
+
type: "button",
|
|
899
|
+
className: X(
|
|
900
|
+
e,
|
|
901
|
+
t,
|
|
902
|
+
"form-field",
|
|
903
|
+
"select-trigger",
|
|
904
|
+
i && "has-subtitle",
|
|
905
|
+
!s && "placeholder"
|
|
906
|
+
),
|
|
907
|
+
onClick: () => {
|
|
908
|
+
n || m();
|
|
909
|
+
},
|
|
910
|
+
onKeyDown: (g) => {
|
|
911
|
+
n || ((g.key === "Enter" || g.key === " ") && (g.preventDefault(), m()), g.key === "ArrowDown" && (g.preventDefault(), h()));
|
|
912
|
+
},
|
|
913
|
+
"aria-expanded": o,
|
|
914
|
+
"aria-haspopup": "listbox",
|
|
915
|
+
"aria-controls": "select-overlay-listbox",
|
|
916
|
+
"aria-disabled": n,
|
|
917
|
+
"aria-required": r,
|
|
918
|
+
"aria-placeholder": s ? void 0 : l,
|
|
919
|
+
disabled: n,
|
|
920
|
+
children: [
|
|
921
|
+
/* @__PURE__ */ V("span", { className: "select-trigger-label", children: [
|
|
922
|
+
/* @__PURE__ */ a("span", { className: "select-trigger-option-label", children: l }),
|
|
923
|
+
i ? /* @__PURE__ */ a("span", { className: "select-trigger-option-subtitle", children: i }) : null
|
|
924
|
+
] }),
|
|
925
|
+
/* @__PURE__ */ a(pn, { size: "xs", isOpen: o })
|
|
926
|
+
]
|
|
927
|
+
}
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
function Tt({
|
|
931
|
+
label: e,
|
|
932
|
+
subtitle: t = null,
|
|
933
|
+
selected: n = !1,
|
|
934
|
+
className: r = "",
|
|
935
|
+
mobile: o = !1,
|
|
936
|
+
onClick: s
|
|
937
|
+
}) {
|
|
938
|
+
return /* @__PURE__ */ a(
|
|
939
|
+
"button",
|
|
940
|
+
{
|
|
941
|
+
type: "button",
|
|
942
|
+
role: "option",
|
|
943
|
+
"aria-selected": n,
|
|
944
|
+
className: X(
|
|
945
|
+
o ? "sheet-option" : "select-option",
|
|
946
|
+
n && "is-selected",
|
|
947
|
+
r
|
|
948
|
+
),
|
|
949
|
+
onClick: s,
|
|
950
|
+
children: /* @__PURE__ */ V("span", { className: "select-option-content", children: [
|
|
951
|
+
/* @__PURE__ */ a(
|
|
952
|
+
G,
|
|
953
|
+
{
|
|
954
|
+
as: "span",
|
|
955
|
+
size: "sm",
|
|
956
|
+
className: "select-option-label",
|
|
957
|
+
dynamic: !0,
|
|
958
|
+
color: n ? 1 : 3,
|
|
959
|
+
children: e
|
|
960
|
+
}
|
|
961
|
+
),
|
|
962
|
+
t ? /* @__PURE__ */ a(G, { as: "span", size: "xxs", className: "select-option-subtitle", dynamic: !0, color: 3, children: t }) : null
|
|
963
|
+
] })
|
|
964
|
+
}
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
function Sn() {
|
|
968
|
+
const {
|
|
969
|
+
listboxId: e,
|
|
970
|
+
position: t,
|
|
971
|
+
options: n,
|
|
972
|
+
overlayRef: r,
|
|
973
|
+
currentValue: o,
|
|
974
|
+
handleSelect: s,
|
|
975
|
+
searchable: l,
|
|
976
|
+
searchTerm: i,
|
|
977
|
+
setSearchTerm: d,
|
|
978
|
+
searchIcon: c,
|
|
979
|
+
searchLabel: m,
|
|
980
|
+
emptyLabel: h
|
|
981
|
+
} = _e();
|
|
982
|
+
return /* @__PURE__ */ a(
|
|
983
|
+
"div",
|
|
984
|
+
{
|
|
985
|
+
ref: r,
|
|
986
|
+
className: X("select-dropdown", "is-open", t.placement === "top" && "is-top"),
|
|
987
|
+
style: {
|
|
988
|
+
left: `${t.left}px`,
|
|
989
|
+
top: `${t.top}px`,
|
|
990
|
+
width: `${t.width}px`
|
|
991
|
+
},
|
|
992
|
+
children: /* @__PURE__ */ V("div", { className: "select-dropdown-panel", children: [
|
|
993
|
+
l ? /* @__PURE__ */ a("div", { className: "select-searchbar-wrap", children: /* @__PURE__ */ V("div", { className: "select-searchbar", children: [
|
|
994
|
+
/* @__PURE__ */ a(
|
|
995
|
+
"input",
|
|
996
|
+
{
|
|
997
|
+
type: "text",
|
|
998
|
+
className: "searchbar-input form-field",
|
|
999
|
+
value: i,
|
|
1000
|
+
onChange: (u) => d(u.target.value),
|
|
1001
|
+
placeholder: m
|
|
1002
|
+
}
|
|
1003
|
+
),
|
|
1004
|
+
c ? /* @__PURE__ */ a("span", { className: "select-search-icon", children: c }) : null
|
|
1005
|
+
] }) }) : null,
|
|
1006
|
+
/* @__PURE__ */ a("div", { className: "select-dropdown-list", role: "listbox", id: e, children: n.length === 0 ? /* @__PURE__ */ a(G, { as: "p", size: "xs", center: !0, className: "select-empty-state", dynamic: !0, color: 3, children: h }) : n.map((u) => {
|
|
1007
|
+
const g = String(u.value) === String(o);
|
|
1008
|
+
return /* @__PURE__ */ a(
|
|
1009
|
+
Tt,
|
|
1010
|
+
{
|
|
1011
|
+
label: u.label,
|
|
1012
|
+
subtitle: u.subtitle,
|
|
1013
|
+
selected: g,
|
|
1014
|
+
className: u.className,
|
|
1015
|
+
onClick: () => s(u.value)
|
|
1016
|
+
},
|
|
1017
|
+
String(u.value)
|
|
1018
|
+
);
|
|
1019
|
+
}) })
|
|
1020
|
+
] })
|
|
1021
|
+
}
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function wn(e) {
|
|
1025
|
+
return e ? Array.from(
|
|
1026
|
+
e.querySelectorAll(
|
|
1027
|
+
'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
1028
|
+
)
|
|
1029
|
+
).filter((t) => !t.hasAttribute("disabled") && t.getAttribute("aria-hidden") !== "true") : [];
|
|
1030
|
+
}
|
|
1031
|
+
function En({
|
|
1032
|
+
enabled: e = !0,
|
|
1033
|
+
initialFocusRef: t,
|
|
1034
|
+
onEnterKeyDown: n,
|
|
1035
|
+
onEscapeKeyDown: r,
|
|
1036
|
+
restoreFocus: o = !0,
|
|
1037
|
+
rootRef: s,
|
|
1038
|
+
trapFocus: l = !1,
|
|
1039
|
+
useCapture: i = !1
|
|
1040
|
+
} = {}) {
|
|
1041
|
+
K(() => {
|
|
1042
|
+
if (!e || typeof document > "u") return;
|
|
1043
|
+
const d = document.activeElement, c = s?.current, m = t?.current;
|
|
1044
|
+
requestAnimationFrame(() => {
|
|
1045
|
+
if (m?.focus) {
|
|
1046
|
+
m.focus();
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
c?.focus?.();
|
|
1050
|
+
});
|
|
1051
|
+
const h = (u) => {
|
|
1052
|
+
if (u.key === "Escape") {
|
|
1053
|
+
r?.(u);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (u.key === "Enter") {
|
|
1057
|
+
n?.(u);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if (!l || u.key !== "Tab") return;
|
|
1061
|
+
const g = wn(s?.current);
|
|
1062
|
+
if (g.length === 0) {
|
|
1063
|
+
u.preventDefault(), s?.current?.focus?.();
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
const y = g[0], v = g[g.length - 1], b = document.activeElement;
|
|
1067
|
+
if (u.shiftKey && b === y) {
|
|
1068
|
+
u.preventDefault(), v.focus();
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
!u.shiftKey && b === v && (u.preventDefault(), y.focus());
|
|
1072
|
+
};
|
|
1073
|
+
return document.addEventListener("keydown", h, i), () => {
|
|
1074
|
+
document.removeEventListener("keydown", h, i), o && d?.focus && d.focus();
|
|
1075
|
+
};
|
|
1076
|
+
}, [e, t, n, r, o, s, l, i]);
|
|
1077
|
+
}
|
|
1078
|
+
function At({
|
|
1079
|
+
className: e = "",
|
|
1080
|
+
backdropLabel: t = "",
|
|
1081
|
+
backdropStyle: n,
|
|
1082
|
+
closing: r = !1,
|
|
1083
|
+
centerContent: o = !0,
|
|
1084
|
+
initialFocusRef: s,
|
|
1085
|
+
onBackdropClick: l,
|
|
1086
|
+
onEnterKeyDown: i,
|
|
1087
|
+
onEscapeKeyDown: d,
|
|
1088
|
+
portal: c = !1,
|
|
1089
|
+
portalTarget: m,
|
|
1090
|
+
restoreFocus: h = !0,
|
|
1091
|
+
trapFocus: u = !1,
|
|
1092
|
+
useKeyboardCapture: g = !1,
|
|
1093
|
+
children: y,
|
|
1094
|
+
...v
|
|
1095
|
+
}) {
|
|
1096
|
+
const b = ae(null);
|
|
1097
|
+
En({
|
|
1098
|
+
initialFocusRef: s,
|
|
1099
|
+
onEnterKeyDown: i,
|
|
1100
|
+
onEscapeKeyDown: d,
|
|
1101
|
+
rootRef: b,
|
|
1102
|
+
restoreFocus: h,
|
|
1103
|
+
trapFocus: u,
|
|
1104
|
+
useCapture: g
|
|
1105
|
+
});
|
|
1106
|
+
const k = /* @__PURE__ */ V(
|
|
1107
|
+
"div",
|
|
1108
|
+
{
|
|
1109
|
+
ref: b,
|
|
1110
|
+
className: X("kosmio-overlay", r && "is-closing", o && "kosmio-overlay-centered", e),
|
|
1111
|
+
tabIndex: -1,
|
|
1112
|
+
...v,
|
|
1113
|
+
children: [
|
|
1114
|
+
/* @__PURE__ */ a(on, { className: "kosmio-backdrop-animated", label: t, onClick: l, style: n }),
|
|
1115
|
+
/* @__PURE__ */ a("div", { className: X("kosmio-overlay-content", o && "kosmio-overlay-content-centered"), children: y })
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
);
|
|
1119
|
+
if (!c) return k;
|
|
1120
|
+
const C = m ?? (typeof document > "u" ? null : document.body);
|
|
1121
|
+
return C ? nt(k, C) : null;
|
|
1122
|
+
}
|
|
1123
|
+
const Tn = '[data-no-form-drag="true"]', Ee = {
|
|
1124
|
+
backdropFade: 0.55,
|
|
1125
|
+
backdropMinOpacity: 0.18,
|
|
1126
|
+
closeDistance: 140,
|
|
1127
|
+
closeOffset: 48,
|
|
1128
|
+
closeVelocity: 0.55
|
|
1129
|
+
}, Ie = {
|
|
1130
|
+
active: !1,
|
|
1131
|
+
engaged: !1,
|
|
1132
|
+
mode: null,
|
|
1133
|
+
source: null,
|
|
1134
|
+
pointerId: null,
|
|
1135
|
+
startX: 0,
|
|
1136
|
+
startY: 0,
|
|
1137
|
+
startTime: 0
|
|
1138
|
+
};
|
|
1139
|
+
function An(e) {
|
|
1140
|
+
if (!(e instanceof HTMLElement)) return !1;
|
|
1141
|
+
const { overflowY: t } = window.getComputedStyle(e);
|
|
1142
|
+
return ["auto", "scroll", "overlay"].includes(t) && e.scrollHeight > e.clientHeight + 1;
|
|
1143
|
+
}
|
|
1144
|
+
function Ln(e, t) {
|
|
1145
|
+
if (!(e instanceof HTMLElement) || !(t instanceof HTMLElement) || e.closest(Tn)) return !1;
|
|
1146
|
+
let n = e;
|
|
1147
|
+
for (; n && n !== t; ) {
|
|
1148
|
+
if (An(n) && n.scrollTop > 0) return !1;
|
|
1149
|
+
n = n.parentElement;
|
|
1150
|
+
}
|
|
1151
|
+
return !0;
|
|
1152
|
+
}
|
|
1153
|
+
function De(e) {
|
|
1154
|
+
return e?.[0] ?? null;
|
|
1155
|
+
}
|
|
1156
|
+
function Ae(e, t, n) {
|
|
1157
|
+
const r = Number.parseFloat(e.getPropertyValue(t));
|
|
1158
|
+
return Number.isFinite(r) ? r : n;
|
|
1159
|
+
}
|
|
1160
|
+
function ft(e) {
|
|
1161
|
+
if (!(e instanceof HTMLElement)) return Ee;
|
|
1162
|
+
const t = window.getComputedStyle(e);
|
|
1163
|
+
return {
|
|
1164
|
+
backdropFade: Ae(t, "--kosmio-sheet-backdrop-drag-fade", Ee.backdropFade),
|
|
1165
|
+
backdropMinOpacity: Ae(t, "--kosmio-sheet-backdrop-min-opacity", Ee.backdropMinOpacity),
|
|
1166
|
+
closeDistance: Ae(t, "--kosmio-sheet-close-distance", Ee.closeDistance),
|
|
1167
|
+
closeOffset: Ae(t, "--kosmio-sheet-close-offset", Ee.closeOffset),
|
|
1168
|
+
closeVelocity: Ae(t, "--kosmio-sheet-close-velocity", Ee.closeVelocity)
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
function In({
|
|
1172
|
+
canStartContentDrag: e = Ln,
|
|
1173
|
+
closing: t = !1,
|
|
1174
|
+
containerRef: n,
|
|
1175
|
+
dragZoneRef: r,
|
|
1176
|
+
enableContentDrag: o = !0,
|
|
1177
|
+
isMobile: s = !1,
|
|
1178
|
+
onDragDismiss: l,
|
|
1179
|
+
onRequestClose: i,
|
|
1180
|
+
scrollRef: d,
|
|
1181
|
+
showDragHandle: c = !0
|
|
1182
|
+
} = {}) {
|
|
1183
|
+
const [m, h] = Z(0), [u, g] = Z(!1), [y, v] = Z(!1), [b, k] = Z(!1), C = ae(Ie), L = U(() => {
|
|
1184
|
+
C.current = Ie, g(!1), v(!1), k(!1), h(0);
|
|
1185
|
+
}, []), x = U(({ clientX: A, clientY: O, pointerId: R = null, mode: q, target: I, source: D }) => {
|
|
1186
|
+
!s || t || b || D === "content" && (!o || !e(I, n.current)) || (C.current = {
|
|
1187
|
+
active: !0,
|
|
1188
|
+
engaged: D === "handle",
|
|
1189
|
+
mode: q,
|
|
1190
|
+
source: D,
|
|
1191
|
+
pointerId: R,
|
|
1192
|
+
startX: A,
|
|
1193
|
+
startY: O,
|
|
1194
|
+
startTime: performance.now()
|
|
1195
|
+
}, q === "pointer" && R != null && n.current?.setPointerCapture?.(R), g(D === "handle"), v(!1), k(!1));
|
|
1196
|
+
}, [e, t, n, o, b, s]), N = U(({ clientX: A, clientY: O, preventDefault: R }) => {
|
|
1197
|
+
const q = C.current;
|
|
1198
|
+
if (!q.active || t || b) return;
|
|
1199
|
+
const I = O - q.startY, D = A - q.startX;
|
|
1200
|
+
if (!q.engaged) {
|
|
1201
|
+
if (q.source !== "handle") {
|
|
1202
|
+
if (I < -6 || Math.abs(D) > Math.abs(I)) {
|
|
1203
|
+
C.current = Ie, g(!1);
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1206
|
+
if (I <= 6) return;
|
|
1207
|
+
}
|
|
1208
|
+
C.current = {
|
|
1209
|
+
...q,
|
|
1210
|
+
engaged: !0
|
|
1211
|
+
}, g(!0);
|
|
1212
|
+
}
|
|
1213
|
+
if (R?.(), I <= 0) {
|
|
1214
|
+
h(0);
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
Math.abs(D) > I || h(I);
|
|
1218
|
+
}, [t, b]), f = U(({ clientY: A, pointerId: O = null }) => {
|
|
1219
|
+
const R = C.current;
|
|
1220
|
+
if (!R.active || R.mode === "pointer" && R.pointerId !== O) return;
|
|
1221
|
+
R.mode === "pointer" && O != null && n.current?.releasePointerCapture?.(O), C.current = Ie, g(!1);
|
|
1222
|
+
const q = Math.max(0, A - R.startY), I = Math.max(performance.now() - R.startTime, 1), D = q / I, P = ft(n.current);
|
|
1223
|
+
if (q >= P.closeDistance || D >= P.closeVelocity) {
|
|
1224
|
+
k(!0), v(!1), h((n.current?.offsetHeight ?? q) + P.closeOffset);
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
v(!0), h(0);
|
|
1228
|
+
}, [n]), p = U((A, O) => {
|
|
1229
|
+
A.pointerType !== "touch" && x({
|
|
1230
|
+
clientX: A.clientX,
|
|
1231
|
+
clientY: A.clientY,
|
|
1232
|
+
pointerId: A.pointerId,
|
|
1233
|
+
mode: "pointer",
|
|
1234
|
+
target: A.target,
|
|
1235
|
+
source: O
|
|
1236
|
+
});
|
|
1237
|
+
}, [x]), E = U((A) => {
|
|
1238
|
+
const O = C.current;
|
|
1239
|
+
O.mode !== "pointer" || O.pointerId !== A.pointerId || N({
|
|
1240
|
+
clientX: A.clientX,
|
|
1241
|
+
clientY: A.clientY,
|
|
1242
|
+
preventDefault: A.cancelable ? () => A.preventDefault() : void 0
|
|
1243
|
+
});
|
|
1244
|
+
}, [N]), S = U((A) => {
|
|
1245
|
+
f({
|
|
1246
|
+
clientY: A.clientY,
|
|
1247
|
+
pointerId: A.pointerId
|
|
1248
|
+
});
|
|
1249
|
+
}, [f]), w = U(() => {
|
|
1250
|
+
if (b) {
|
|
1251
|
+
L(), (l ?? i)?.();
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
y && v(!1);
|
|
1255
|
+
}, [y, b, l, i, L]);
|
|
1256
|
+
K(() => {
|
|
1257
|
+
(t || !s) && L();
|
|
1258
|
+
}, [t, s, L]), K(() => {
|
|
1259
|
+
if (!s) return;
|
|
1260
|
+
const A = r.current, O = d.current, R = n.current;
|
|
1261
|
+
if (!A && c || !O || !R) return;
|
|
1262
|
+
const q = (T) => {
|
|
1263
|
+
const _ = De(T.touches);
|
|
1264
|
+
_ && x({
|
|
1265
|
+
clientX: _.clientX,
|
|
1266
|
+
clientY: _.clientY,
|
|
1267
|
+
mode: "touch",
|
|
1268
|
+
target: T.target,
|
|
1269
|
+
source: "handle"
|
|
1270
|
+
});
|
|
1271
|
+
}, I = (T) => {
|
|
1272
|
+
const _ = De(T.touches);
|
|
1273
|
+
_ && x({
|
|
1274
|
+
clientX: _.clientX,
|
|
1275
|
+
clientY: _.clientY,
|
|
1276
|
+
mode: "touch",
|
|
1277
|
+
target: T.target,
|
|
1278
|
+
source: "content"
|
|
1279
|
+
});
|
|
1280
|
+
}, D = (T) => {
|
|
1281
|
+
if (C.current.mode !== "touch") return;
|
|
1282
|
+
const W = De(T.touches);
|
|
1283
|
+
W && N({
|
|
1284
|
+
clientX: W.clientX,
|
|
1285
|
+
clientY: W.clientY,
|
|
1286
|
+
preventDefault: T.cancelable ? () => T.preventDefault() : void 0
|
|
1287
|
+
});
|
|
1288
|
+
}, P = (T) => {
|
|
1289
|
+
const _ = C.current;
|
|
1290
|
+
if (_.mode !== "touch") return;
|
|
1291
|
+
const W = De(T.changedTouches);
|
|
1292
|
+
f({
|
|
1293
|
+
clientY: W?.clientY ?? _.startY
|
|
1294
|
+
});
|
|
1295
|
+
};
|
|
1296
|
+
return c && A?.addEventListener("touchstart", q, { passive: !0 }), O.addEventListener("touchstart", I, { passive: !0 }), R.addEventListener("touchmove", D, { passive: !1 }), R.addEventListener("touchend", P), R.addEventListener("touchcancel", P), () => {
|
|
1297
|
+
c && A?.removeEventListener("touchstart", q), O.removeEventListener("touchstart", I), R.removeEventListener("touchmove", D), R.removeEventListener("touchend", P), R.removeEventListener("touchcancel", P);
|
|
1298
|
+
};
|
|
1299
|
+
}, [
|
|
1300
|
+
x,
|
|
1301
|
+
t,
|
|
1302
|
+
n,
|
|
1303
|
+
r,
|
|
1304
|
+
f,
|
|
1305
|
+
s,
|
|
1306
|
+
d,
|
|
1307
|
+
c,
|
|
1308
|
+
N
|
|
1309
|
+
]);
|
|
1310
|
+
const H = n.current?.offsetHeight ?? 1, M = ft(n.current), F = s ? Math.min(m / H, 1) : 0, J = s && (u || y || b) ? {
|
|
1311
|
+
"--kosmio-overlay-backdrop-opacity": Math.max(M.backdropMinOpacity, 1 - F * M.backdropFade)
|
|
1312
|
+
} : void 0, B = s && (u || y || b || m > 0) ? {
|
|
1313
|
+
transform: `translate3d(0, ${m}px, 0)`,
|
|
1314
|
+
transition: u ? "none" : "transform var(--kosmio-sheet-drag-settle-duration) ease-out"
|
|
1315
|
+
} : void 0;
|
|
1316
|
+
return {
|
|
1317
|
+
backdropStyle: J,
|
|
1318
|
+
dragging: u,
|
|
1319
|
+
gestureClosing: b,
|
|
1320
|
+
handlePointerDown: p,
|
|
1321
|
+
handlePointerEnd: S,
|
|
1322
|
+
handlePointerMove: E,
|
|
1323
|
+
handleTransitionEnd: w,
|
|
1324
|
+
sheetStyle: B
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
const Dn = "transform", On = "kosmio-slide-up";
|
|
1328
|
+
function zn(e, t) {
|
|
1329
|
+
if (e) {
|
|
1330
|
+
if (typeof e == "function") {
|
|
1331
|
+
e(t);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
e.current = t;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
const $n = de(function({
|
|
1338
|
+
isMobile: t = !1,
|
|
1339
|
+
closing: n = !1,
|
|
1340
|
+
className: r = "",
|
|
1341
|
+
backdropLabel: o = "",
|
|
1342
|
+
feedbackState: s = "",
|
|
1343
|
+
beforeScrollContent: l = null,
|
|
1344
|
+
showDragHandle: i = !0,
|
|
1345
|
+
enableContentDrag: d = !0,
|
|
1346
|
+
canStartContentDrag: c,
|
|
1347
|
+
initialFocusRef: m,
|
|
1348
|
+
onRequestClose: h,
|
|
1349
|
+
onDragDismiss: u,
|
|
1350
|
+
onAnimationEnd: g,
|
|
1351
|
+
onEscapeKeyDown: y,
|
|
1352
|
+
onTransitionEnd: v,
|
|
1353
|
+
portal: b = !1,
|
|
1354
|
+
portalTarget: k,
|
|
1355
|
+
restoreFocus: C,
|
|
1356
|
+
trapFocus: L,
|
|
1357
|
+
children: x,
|
|
1358
|
+
...N
|
|
1359
|
+
}, f) {
|
|
1360
|
+
const [p, E] = Z(!0), S = ae(null), w = ae(null), H = ae(null), {
|
|
1361
|
+
backdropStyle: M,
|
|
1362
|
+
dragging: F,
|
|
1363
|
+
gestureClosing: J,
|
|
1364
|
+
handlePointerDown: B,
|
|
1365
|
+
handlePointerEnd: A,
|
|
1366
|
+
handlePointerMove: O,
|
|
1367
|
+
handleTransitionEnd: R,
|
|
1368
|
+
sheetStyle: q
|
|
1369
|
+
} = In({
|
|
1370
|
+
canStartContentDrag: c,
|
|
1371
|
+
closing: n,
|
|
1372
|
+
containerRef: S,
|
|
1373
|
+
dragZoneRef: w,
|
|
1374
|
+
enableContentDrag: d,
|
|
1375
|
+
isMobile: t,
|
|
1376
|
+
onDragDismiss: u,
|
|
1377
|
+
onRequestClose: h,
|
|
1378
|
+
scrollRef: H,
|
|
1379
|
+
showDragHandle: i
|
|
1380
|
+
}), I = (T) => {
|
|
1381
|
+
S.current = T, zn(f, T);
|
|
1382
|
+
}, D = (T) => {
|
|
1383
|
+
if (T.target !== T.currentTarget || T.propertyName !== Dn) {
|
|
1384
|
+
v?.(T);
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
R(), v?.(T);
|
|
1388
|
+
}, P = (T) => {
|
|
1389
|
+
T.target === T.currentTarget && T.animationName === On && E(!1), g?.(T);
|
|
1390
|
+
};
|
|
1391
|
+
return K(() => {
|
|
1392
|
+
n || E(!0);
|
|
1393
|
+
}, [n]), K(() => {
|
|
1394
|
+
F && E(!1);
|
|
1395
|
+
}, [F]), /* @__PURE__ */ a(
|
|
1396
|
+
At,
|
|
1397
|
+
{
|
|
1398
|
+
className: "kosmio-sheet-layer",
|
|
1399
|
+
closing: n || J,
|
|
1400
|
+
backdropLabel: o,
|
|
1401
|
+
backdropStyle: M,
|
|
1402
|
+
centerContent: !1,
|
|
1403
|
+
initialFocusRef: m,
|
|
1404
|
+
onBackdropClick: h,
|
|
1405
|
+
onEscapeKeyDown: y,
|
|
1406
|
+
portal: b,
|
|
1407
|
+
portalTarget: k,
|
|
1408
|
+
restoreFocus: C,
|
|
1409
|
+
trapFocus: L,
|
|
1410
|
+
children: /* @__PURE__ */ V(
|
|
1411
|
+
"div",
|
|
1412
|
+
{
|
|
1413
|
+
...N,
|
|
1414
|
+
ref: I,
|
|
1415
|
+
className: X(
|
|
1416
|
+
"kosmio-sheet",
|
|
1417
|
+
r,
|
|
1418
|
+
p && "is-entering",
|
|
1419
|
+
F && "is-dragging",
|
|
1420
|
+
J && "is-gesture-closing",
|
|
1421
|
+
s && `is-feedback-${s}`
|
|
1422
|
+
),
|
|
1423
|
+
onClick: (T) => T.stopPropagation(),
|
|
1424
|
+
onAnimationEnd: P,
|
|
1425
|
+
onTransitionEnd: D,
|
|
1426
|
+
onPointerMove: O,
|
|
1427
|
+
onPointerUp: A,
|
|
1428
|
+
onPointerCancel: A,
|
|
1429
|
+
style: q,
|
|
1430
|
+
children: [
|
|
1431
|
+
s ? /* @__PURE__ */ a("div", { className: X("kosmio-sheet-feedback", `is-${s}`), "aria-hidden": "true" }) : null,
|
|
1432
|
+
l,
|
|
1433
|
+
i && t ? /* @__PURE__ */ a(
|
|
1434
|
+
"div",
|
|
1435
|
+
{
|
|
1436
|
+
className: "kosmio-sheet-drag-zone",
|
|
1437
|
+
onPointerDown: (T) => B(T, "handle"),
|
|
1438
|
+
ref: w,
|
|
1439
|
+
role: "presentation",
|
|
1440
|
+
children: /* @__PURE__ */ a("div", { className: "kosmio-sheet-drag-handle", "aria-hidden": "true" })
|
|
1441
|
+
}
|
|
1442
|
+
) : null,
|
|
1443
|
+
/* @__PURE__ */ a("div", { className: "kosmio-sheet-scroll", onPointerDown: (T) => B(T, "content"), ref: H, children: x })
|
|
1444
|
+
]
|
|
1445
|
+
}
|
|
1446
|
+
)
|
|
1447
|
+
}
|
|
1448
|
+
);
|
|
1449
|
+
});
|
|
1450
|
+
function Fn() {
|
|
1451
|
+
const {
|
|
1452
|
+
isClosing: e,
|
|
1453
|
+
isMobile: t,
|
|
1454
|
+
listboxId: n,
|
|
1455
|
+
closeImmediately: r,
|
|
1456
|
+
requestClose: o,
|
|
1457
|
+
options: s,
|
|
1458
|
+
overlayRef: l,
|
|
1459
|
+
currentValue: i,
|
|
1460
|
+
handleSelect: d,
|
|
1461
|
+
placeholder: c,
|
|
1462
|
+
displayLabel: m,
|
|
1463
|
+
searchable: h,
|
|
1464
|
+
searchTerm: u,
|
|
1465
|
+
setSearchTerm: g,
|
|
1466
|
+
searchIcon: y,
|
|
1467
|
+
searchLabel: v,
|
|
1468
|
+
emptyLabel: b,
|
|
1469
|
+
closeLabel: k
|
|
1470
|
+
} = _e(), C = c ?? m;
|
|
1471
|
+
return /* @__PURE__ */ a(
|
|
1472
|
+
$n,
|
|
1473
|
+
{
|
|
1474
|
+
ref: l,
|
|
1475
|
+
isMobile: t,
|
|
1476
|
+
closing: e,
|
|
1477
|
+
className: "select-sheet",
|
|
1478
|
+
backdropLabel: k,
|
|
1479
|
+
onRequestClose: o,
|
|
1480
|
+
onDragDismiss: r,
|
|
1481
|
+
portal: !0,
|
|
1482
|
+
role: "dialog",
|
|
1483
|
+
"aria-modal": "true",
|
|
1484
|
+
"aria-labelledby": `${n}-title`,
|
|
1485
|
+
trapFocus: !0,
|
|
1486
|
+
children: /* @__PURE__ */ V("div", { className: "select-sheet-body", children: [
|
|
1487
|
+
/* @__PURE__ */ a("div", { className: "select-sheet-header", children: /* @__PURE__ */ a(G, { as: "p", size: "sm", dynamic: !0, color: 1, id: `${n}-title`, children: C }) }),
|
|
1488
|
+
h ? /* @__PURE__ */ a("div", { className: "select-searchbar-wrap select-sheet-searchbar-wrap", children: /* @__PURE__ */ V("div", { className: "select-searchbar", children: [
|
|
1489
|
+
/* @__PURE__ */ a(
|
|
1490
|
+
"input",
|
|
1491
|
+
{
|
|
1492
|
+
type: "text",
|
|
1493
|
+
className: "searchbar-input form-field",
|
|
1494
|
+
value: u,
|
|
1495
|
+
onChange: (L) => g(L.target.value),
|
|
1496
|
+
placeholder: v
|
|
1497
|
+
}
|
|
1498
|
+
),
|
|
1499
|
+
y ? /* @__PURE__ */ a("span", { className: "select-search-icon", children: y }) : null
|
|
1500
|
+
] }) }) : null,
|
|
1501
|
+
/* @__PURE__ */ a("div", { className: "select-sheet-list", role: "listbox", id: n, children: s.length === 0 ? /* @__PURE__ */ a(G, { as: "p", size: "xs", center: !0, className: "select-empty-state", dynamic: !0, color: 3, children: b }) : s.map((L) => {
|
|
1502
|
+
const x = String(L.value) === String(i);
|
|
1503
|
+
return /* @__PURE__ */ a(
|
|
1504
|
+
Tt,
|
|
1505
|
+
{
|
|
1506
|
+
label: L.label,
|
|
1507
|
+
subtitle: L.subtitle,
|
|
1508
|
+
selected: x,
|
|
1509
|
+
className: L.className,
|
|
1510
|
+
mobile: !0,
|
|
1511
|
+
onClick: () => d(L.value)
|
|
1512
|
+
},
|
|
1513
|
+
String(L.value)
|
|
1514
|
+
);
|
|
1515
|
+
}) })
|
|
1516
|
+
] })
|
|
1517
|
+
}
|
|
1518
|
+
);
|
|
1519
|
+
}
|
|
1520
|
+
function Pn() {
|
|
1521
|
+
const { isOpen: e, isMobile: t } = _e();
|
|
1522
|
+
return e ? t ? /* @__PURE__ */ a(Fn, {}) : typeof document > "u" ? null : nt(/* @__PURE__ */ a(Sn, {}), document.body) : null;
|
|
1523
|
+
}
|
|
1524
|
+
const Mn = {
|
|
1525
|
+
plain: "",
|
|
1526
|
+
custom: "customSelect"
|
|
1527
|
+
}, Rn = "(max-width: 768px)", Oe = 5, mt = 12, Ge = 230, Bn = 150;
|
|
1528
|
+
function Vn(e) {
|
|
1529
|
+
return typeof e == "object" && e !== null ? {
|
|
1530
|
+
value: e.value,
|
|
1531
|
+
label: e.label,
|
|
1532
|
+
subtitle: e.subtitle ?? null,
|
|
1533
|
+
className: e.className ?? ""
|
|
1534
|
+
} : {
|
|
1535
|
+
value: e,
|
|
1536
|
+
label: e,
|
|
1537
|
+
subtitle: null,
|
|
1538
|
+
className: ""
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
const _n = de(function({
|
|
1542
|
+
variant: t = "plain",
|
|
1543
|
+
className: n = "",
|
|
1544
|
+
options: r = [],
|
|
1545
|
+
searchable: o = !1,
|
|
1546
|
+
placeholder: s,
|
|
1547
|
+
value: l,
|
|
1548
|
+
defaultValue: i = "",
|
|
1549
|
+
disabled: d = !1,
|
|
1550
|
+
required: c = !1,
|
|
1551
|
+
onChange: m,
|
|
1552
|
+
onValueChange: h,
|
|
1553
|
+
name: u,
|
|
1554
|
+
searchIcon: g = null,
|
|
1555
|
+
searchLabel: y,
|
|
1556
|
+
emptyLabel: v,
|
|
1557
|
+
closeLabel: b,
|
|
1558
|
+
selectOptionLabel: k
|
|
1559
|
+
}, C) {
|
|
1560
|
+
const { t: L } = be(), x = y ?? L("common.actions.search", { defaultValue: "Search" }), N = v ?? L("common.messages.info.noResultMessage", { defaultValue: "No results" }), f = b ?? L("common.actions.close", { defaultValue: "Close" }), p = k ?? L("forms.shared.selectOption", { defaultValue: "Select option" }), E = Mn[t] ?? t, S = ae(null), w = l !== void 0, [H, M] = Z(i), [F, J] = Z(!1), [B, A] = Z(!1), [O, R] = Z(!1), [q, I] = Z({
|
|
1561
|
+
left: 0,
|
|
1562
|
+
top: 0,
|
|
1563
|
+
width: 0,
|
|
1564
|
+
placement: "bottom",
|
|
1565
|
+
maxHeight: Ge
|
|
1566
|
+
}), [D, P] = Z(""), T = Ve(), _ = ae(null), W = ae(null), le = oe(() => r.map(Vn), [r]), Q = oe(() => {
|
|
1567
|
+
const j = D.trim().toLowerCase();
|
|
1568
|
+
return !o || j.length === 0 ? le : le.filter(
|
|
1569
|
+
(re) => String(re.label).toLowerCase().includes(j)
|
|
1570
|
+
);
|
|
1571
|
+
}, [le, D, o]), te = w ? l : H, ye = s != null && String(s).trim() !== "" ? s : p, he = le.find(
|
|
1572
|
+
(j) => String(j.value) === String(te)
|
|
1573
|
+
), xe = he?.label ?? ye, ie = !!he || te != null && String(te).trim() !== "", Se = ie ? he?.subtitle ?? null : null;
|
|
1574
|
+
K(() => () => {
|
|
1575
|
+
W.current && window.clearTimeout(W.current);
|
|
1576
|
+
}, []), K(() => {
|
|
1577
|
+
const j = window.matchMedia(Rn), re = () => R(j.matches);
|
|
1578
|
+
return re(), typeof j.addEventListener == "function" ? (j.addEventListener("change", re), () => j.removeEventListener("change", re)) : (j.addListener(re), () => j.removeListener(re));
|
|
1579
|
+
}, []), K(() => {
|
|
1580
|
+
if (!F || O)
|
|
1581
|
+
return;
|
|
1582
|
+
const j = () => {
|
|
1583
|
+
const fe = (S.current?.closest(".kosmio-full-searchbar")?.querySelector(".searchbar-select") ?? S.current)?.getBoundingClientRect();
|
|
1584
|
+
if (!fe)
|
|
1585
|
+
return;
|
|
1586
|
+
const Ne = window.innerHeight, ke = Math.max(0, fe.top - mt - Oe), pe = Math.max(
|
|
1587
|
+
0,
|
|
1588
|
+
Ne - fe.bottom - mt - Oe
|
|
1589
|
+
), we = pe < Ge && ke > pe, qe = we ? "top" : "bottom", He = Math.max(
|
|
1590
|
+
120,
|
|
1591
|
+
Math.min(Ge, we ? ke : pe)
|
|
1592
|
+
);
|
|
1593
|
+
I({
|
|
1594
|
+
left: fe.left,
|
|
1595
|
+
top: we ? fe.top - Oe : fe.bottom + Oe,
|
|
1596
|
+
width: fe.width,
|
|
1597
|
+
placement: qe,
|
|
1598
|
+
maxHeight: He
|
|
1599
|
+
});
|
|
1600
|
+
};
|
|
1601
|
+
return j(), window.addEventListener("resize", j), window.addEventListener("scroll", j, !0), () => {
|
|
1602
|
+
window.removeEventListener("resize", j), window.removeEventListener("scroll", j, !0);
|
|
1603
|
+
};
|
|
1604
|
+
}, [O, F]), K(() => {
|
|
1605
|
+
if (!F || B) {
|
|
1606
|
+
P("");
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
const j = (fe) => {
|
|
1610
|
+
const Ne = fe.target, ke = S.current?.closest(".searchbar-select");
|
|
1611
|
+
O && Ne instanceof Element && Ne.closest(".select-sheet") || S.current?.contains(Ne) || ke?.contains(Ne) || _.current?.contains(fe.target) || ue();
|
|
1612
|
+
}, re = (fe) => {
|
|
1613
|
+
fe.key === "Escape" && (ue(), S.current?.focus());
|
|
1614
|
+
};
|
|
1615
|
+
return document.addEventListener("pointerdown", j, !0), document.addEventListener("keydown", re), () => {
|
|
1616
|
+
document.removeEventListener("pointerdown", j, !0), document.removeEventListener("keydown", re);
|
|
1617
|
+
};
|
|
1618
|
+
}, [B, O, F, T]);
|
|
1619
|
+
const ve = (j) => {
|
|
1620
|
+
w || M(j);
|
|
1621
|
+
const re = {
|
|
1622
|
+
target: { name: u, value: j },
|
|
1623
|
+
currentTarget: { name: u, value: j }
|
|
1624
|
+
};
|
|
1625
|
+
m?.(re), h?.(j, re);
|
|
1626
|
+
}, ce = () => {
|
|
1627
|
+
W.current && (window.clearTimeout(W.current), W.current = null), A(!1), J(!1);
|
|
1628
|
+
}, ue = () => {
|
|
1629
|
+
if (!(!F || B)) {
|
|
1630
|
+
if (!O) {
|
|
1631
|
+
ce();
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
A(!0), W.current = window.setTimeout(() => {
|
|
1635
|
+
W.current = null, ce();
|
|
1636
|
+
}, Bn);
|
|
1637
|
+
}
|
|
1638
|
+
}, Ce = () => {
|
|
1639
|
+
W.current && (window.clearTimeout(W.current), W.current = null), A(!1), J(!0);
|
|
1640
|
+
}, me = {
|
|
1641
|
+
className: n,
|
|
1642
|
+
closeImmediately: ce,
|
|
1643
|
+
currentValue: te,
|
|
1644
|
+
disabled: d,
|
|
1645
|
+
displayLabel: xe,
|
|
1646
|
+
displaySubtitle: Se,
|
|
1647
|
+
filteredOptions: Q,
|
|
1648
|
+
forwardedRef: C,
|
|
1649
|
+
handleSelect: (j) => {
|
|
1650
|
+
ve(j), ue(), S.current?.focus();
|
|
1651
|
+
},
|
|
1652
|
+
hasValue: ie,
|
|
1653
|
+
isClosing: B,
|
|
1654
|
+
isMobile: O,
|
|
1655
|
+
isOpen: F,
|
|
1656
|
+
listboxId: T,
|
|
1657
|
+
open: Ce,
|
|
1658
|
+
options: Q,
|
|
1659
|
+
overlayRef: _,
|
|
1660
|
+
placeholder: ye,
|
|
1661
|
+
position: q,
|
|
1662
|
+
requestClose: ue,
|
|
1663
|
+
required: c,
|
|
1664
|
+
searchIcon: g,
|
|
1665
|
+
searchLabel: x,
|
|
1666
|
+
searchable: o,
|
|
1667
|
+
searchTerm: D,
|
|
1668
|
+
setSearchTerm: P,
|
|
1669
|
+
emptyLabel: N,
|
|
1670
|
+
closeLabel: f,
|
|
1671
|
+
toggleOpen: () => {
|
|
1672
|
+
if (F) {
|
|
1673
|
+
ue();
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
Ce();
|
|
1677
|
+
},
|
|
1678
|
+
triggerRef: S,
|
|
1679
|
+
variantClass: E
|
|
1680
|
+
};
|
|
1681
|
+
return /* @__PURE__ */ a(Et.Provider, { value: me, children: /* @__PURE__ */ V("div", { className: X("select-field", F && "is-open", O && "is-mobile"), children: [
|
|
1682
|
+
/* @__PURE__ */ a(Cn, {}),
|
|
1683
|
+
/* @__PURE__ */ a(Pn, {})
|
|
1684
|
+
] }) });
|
|
1685
|
+
});
|
|
1686
|
+
function Ke({
|
|
1687
|
+
label: e,
|
|
1688
|
+
placeholder: t,
|
|
1689
|
+
value: n,
|
|
1690
|
+
defaultValue: r = "",
|
|
1691
|
+
onChange: o,
|
|
1692
|
+
options: s = [],
|
|
1693
|
+
searchable: l = !1,
|
|
1694
|
+
required: i = !1,
|
|
1695
|
+
className: d = "",
|
|
1696
|
+
labelClassName: c = "",
|
|
1697
|
+
fieldClassName: m = "",
|
|
1698
|
+
requiredLabel: h,
|
|
1699
|
+
selectOptionLabel: u,
|
|
1700
|
+
searchIcon: g = null,
|
|
1701
|
+
searchLabel: y,
|
|
1702
|
+
emptyLabel: v,
|
|
1703
|
+
closeLabel: b
|
|
1704
|
+
}) {
|
|
1705
|
+
const { t: k } = be(), C = h ?? k("forms.shared.required", { defaultValue: "Required" }), L = u ?? k("forms.shared.selectOption", { defaultValue: "Select option" }), x = y ?? k("common.actions.search", { defaultValue: "Search" }), N = v ?? k("common.messages.info.noResultMessage", { defaultValue: "No results" }), f = b ?? k("common.actions.close", { defaultValue: "Close" }), p = n ?? r, E = t ?? L, S = p == null || String(p).trim().length === 0, w = s.some((M) => {
|
|
1706
|
+
const F = typeof M == "object" && M !== null ? M.value : M;
|
|
1707
|
+
return F != null && String(F) === String(p);
|
|
1708
|
+
}), H = S && !w;
|
|
1709
|
+
return /* @__PURE__ */ V("div", { className: `form-field-container ${d}`.trim(), children: [
|
|
1710
|
+
e && /* @__PURE__ */ V(G, { className: `form-field-label ${c}`.trim(), as: "label", size: "xxs", children: [
|
|
1711
|
+
e,
|
|
1712
|
+
i && /* @__PURE__ */ a(G, { className: X("form-field-required-text", S && "empty"), as: "span", children: C })
|
|
1713
|
+
] }),
|
|
1714
|
+
/* @__PURE__ */ a(_n, { variant: "custom", value: p, onValueChange: o, required: i, placeholder: E, options: s, searchable: l, className: `${m} ${H ? "placeholder" : ""}`, searchIcon: g, searchLabel: x, emptyLabel: N, closeLabel: f, selectOptionLabel: L })
|
|
1715
|
+
] });
|
|
1716
|
+
}
|
|
1717
|
+
function Lt({ children: e, text: t, color: n, className: r = "", ...o }) {
|
|
1718
|
+
const s = e ?? t;
|
|
1719
|
+
return /* @__PURE__ */ a(
|
|
1720
|
+
G,
|
|
1721
|
+
{
|
|
1722
|
+
as: "span",
|
|
1723
|
+
className: `kosmio-tag tag ${r}`.trim(),
|
|
1724
|
+
size: "xxs",
|
|
1725
|
+
style: n ? { "--kosmio-tag-color": n, "--tag-color": n } : void 0,
|
|
1726
|
+
...o,
|
|
1727
|
+
children: s
|
|
1728
|
+
}
|
|
1729
|
+
);
|
|
1730
|
+
}
|
|
1731
|
+
function Jr({ children: e, text: t, color: n = "#5a95ad", className: r = "", ...o }) {
|
|
1732
|
+
return /* @__PURE__ */ a(Lt, { color: n, className: `color-tag text-inline ${r}`.trim(), ...o, children: e ?? t });
|
|
1733
|
+
}
|
|
1734
|
+
const qn = (e) => /* @__PURE__ */ a(G, { className: "tag generatorInput-chip", as: "p", size: "sm", children: e }), Hn = (e) => e === "Backspace" || e === "Delete", ht = (e, t, n) => typeof e == "function" ? e(t, n) : et(e) ? xt(e, {
|
|
1735
|
+
text: t,
|
|
1736
|
+
index: n
|
|
1737
|
+
}) : qn(t);
|
|
1738
|
+
function Yn({
|
|
1739
|
+
label: e,
|
|
1740
|
+
placeholder: t = "",
|
|
1741
|
+
value: n,
|
|
1742
|
+
defaultValue: r = [],
|
|
1743
|
+
onChange: o,
|
|
1744
|
+
onGeneratedChange: s,
|
|
1745
|
+
component: l = /* @__PURE__ */ a(Lt, {}),
|
|
1746
|
+
className: i = "",
|
|
1747
|
+
labelClassName: d = "",
|
|
1748
|
+
fieldClassName: c = "",
|
|
1749
|
+
inputClassName: m = "",
|
|
1750
|
+
disabled: h = !1,
|
|
1751
|
+
onKeyDown: u,
|
|
1752
|
+
...g
|
|
1753
|
+
}) {
|
|
1754
|
+
const [y, v] = Z(""), [b, k] = Z(() => Array.isArray(r) ? r : []), C = ae(null), L = Array.isArray(n), x = L ? n : b, N = (w) => {
|
|
1755
|
+
L || k(w), o?.(w), s?.({
|
|
1756
|
+
texts: w,
|
|
1757
|
+
components: w.map((H, M) => ht(l, H, M))
|
|
1758
|
+
});
|
|
1759
|
+
}, f = () => {
|
|
1760
|
+
if (h) return;
|
|
1761
|
+
const w = y.trim();
|
|
1762
|
+
w && (N([...x, w]), v(""));
|
|
1763
|
+
}, p = () => {
|
|
1764
|
+
h || x.length === 0 || N(x.slice(0, -1));
|
|
1765
|
+
}, E = oe(() => x.map((w, H) => {
|
|
1766
|
+
const M = ht(l, w, H), F = `${w}-${H}`;
|
|
1767
|
+
return typeof M == "string" || typeof M == "number" ? /* @__PURE__ */ a(G, { className: "tag generatorInput-chip", as: "span", size: "xxs", children: String(M) }, F) : /* @__PURE__ */ a(Pt, { children: M }, F);
|
|
1768
|
+
}), [x, l]), S = (w) => {
|
|
1769
|
+
w.key === "Enter" ? (w.preventDefault(), f()) : Hn(w.key) && y.length === 0 && (w.preventDefault(), p()), u?.(w);
|
|
1770
|
+
};
|
|
1771
|
+
return /* @__PURE__ */ V("div", { className: X("form-field-container gap5", i), children: [
|
|
1772
|
+
e && /* @__PURE__ */ a(G, { className: X("form-field-label row-left", d), as: "label", size: "xxs", children: e }),
|
|
1773
|
+
/* @__PURE__ */ V("div", { className: X("generatorInput-container form-field", c, h && "generatorInput-disabled"), onMouseDown: (w) => {
|
|
1774
|
+
w.target !== C.current && w.preventDefault(), C.current?.focus();
|
|
1775
|
+
}, children: [
|
|
1776
|
+
E,
|
|
1777
|
+
/* @__PURE__ */ a("input", { ref: C, type: "text", value: y, placeholder: x.length === 0 ? t : "", onChange: (w) => v(w.target.value), onKeyDown: S, className: X("generatorInput-input", m), disabled: h, ...g })
|
|
1778
|
+
] })
|
|
1779
|
+
] });
|
|
1780
|
+
}
|
|
1781
|
+
const Me = "__default_group__";
|
|
1782
|
+
function pt(e) {
|
|
1783
|
+
return String(e ?? "").toLowerCase().trim();
|
|
1784
|
+
}
|
|
1785
|
+
function Ue(e, t) {
|
|
1786
|
+
const n = Number(e);
|
|
1787
|
+
return Number.isFinite(n) ? n : t;
|
|
1788
|
+
}
|
|
1789
|
+
function Re(e = {}) {
|
|
1790
|
+
return e?.params && typeof e.params == "object" ? e.params : e?.param && typeof e.param == "object" ? e.param : {};
|
|
1791
|
+
}
|
|
1792
|
+
function jn(e = {}, t = Number.MAX_SAFE_INTEGER) {
|
|
1793
|
+
const n = Re(e), r = n.group ?? e.group;
|
|
1794
|
+
if (typeof r == "string" && r.trim())
|
|
1795
|
+
return {
|
|
1796
|
+
name: r.trim(),
|
|
1797
|
+
order: Ue(n.groupIndex ?? e.groupIndex, t)
|
|
1798
|
+
};
|
|
1799
|
+
if (r && typeof r == "object") {
|
|
1800
|
+
const o = r.name ?? r.key ?? r.id;
|
|
1801
|
+
return {
|
|
1802
|
+
name: typeof o == "string" && o.trim() ? o.trim() : Me,
|
|
1803
|
+
order: Ue(r.index, t)
|
|
1804
|
+
};
|
|
1805
|
+
}
|
|
1806
|
+
return {
|
|
1807
|
+
name: Me,
|
|
1808
|
+
order: t
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
function Gn(e) {
|
|
1812
|
+
if (e == null || e === "") return "";
|
|
1813
|
+
if (typeof e == "string") {
|
|
1814
|
+
const t = e.trim();
|
|
1815
|
+
if (!t) return "";
|
|
1816
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(t)) return t.slice(0, 10);
|
|
1817
|
+
const n = new Date(t);
|
|
1818
|
+
return Number.isNaN(n.getTime()) ? t : [
|
|
1819
|
+
n.getFullYear(),
|
|
1820
|
+
String(n.getMonth() + 1).padStart(2, "0"),
|
|
1821
|
+
String(n.getDate()).padStart(2, "0")
|
|
1822
|
+
].join("-");
|
|
1823
|
+
}
|
|
1824
|
+
return e instanceof Date && !Number.isNaN(e.getTime()) ? [
|
|
1825
|
+
e.getFullYear(),
|
|
1826
|
+
String(e.getMonth() + 1).padStart(2, "0"),
|
|
1827
|
+
String(e.getDate()).padStart(2, "0")
|
|
1828
|
+
].join("-") : "";
|
|
1829
|
+
}
|
|
1830
|
+
function Xn(e = {}) {
|
|
1831
|
+
const t = Re(e);
|
|
1832
|
+
return {
|
|
1833
|
+
values: t.enum ?? e.enum ?? [],
|
|
1834
|
+
i18nPath: t.enumI18nPath ?? e.enumI18nPath ?? t.enumPath ?? e.enumPath ?? null
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
function Wn(e, t) {
|
|
1838
|
+
return Array.isArray(e.values) ? e.values.map((n) => {
|
|
1839
|
+
if (n && typeof n == "object") {
|
|
1840
|
+
const l = n.value ?? n.id ?? n.key;
|
|
1841
|
+
if (l == null) return null;
|
|
1842
|
+
const i = e.i18nPath && n.label == null ? t(`${e.i18nPath}.${l}`) : null;
|
|
1843
|
+
return {
|
|
1844
|
+
...n,
|
|
1845
|
+
value: String(l),
|
|
1846
|
+
label: n.label ?? (i === `${e.i18nPath}.${l}` ? String(l) : i)
|
|
1847
|
+
};
|
|
1848
|
+
}
|
|
1849
|
+
const r = String(n ?? "");
|
|
1850
|
+
if (!r) return null;
|
|
1851
|
+
const o = e.i18nPath != null ? t(`${e.i18nPath}.${r}`) : r, s = `${e.i18nPath}.${r}`;
|
|
1852
|
+
return {
|
|
1853
|
+
value: r,
|
|
1854
|
+
label: o === s ? r : o
|
|
1855
|
+
};
|
|
1856
|
+
}).filter(Boolean) : [];
|
|
1857
|
+
}
|
|
1858
|
+
function Zr({
|
|
1859
|
+
modelProperties: e,
|
|
1860
|
+
form: t,
|
|
1861
|
+
onChange: n,
|
|
1862
|
+
optionsMap: r = {},
|
|
1863
|
+
customRenderers: o = {},
|
|
1864
|
+
onlyFields: s = null,
|
|
1865
|
+
mode: l = "create",
|
|
1866
|
+
i18nPath: i = null,
|
|
1867
|
+
groupI18nPath: d = null
|
|
1868
|
+
}) {
|
|
1869
|
+
const { t: c } = be(), m = e?.fields ?? {}, h = {
|
|
1870
|
+
requiredLabel: c("forms.shared.required"),
|
|
1871
|
+
selectOptionLabel: c("forms.shared.selectOption"),
|
|
1872
|
+
searchLabel: c("common.actions.search"),
|
|
1873
|
+
emptyLabel: c("common.messages.info.noResultMessage"),
|
|
1874
|
+
closeLabel: c("common.actions.close")
|
|
1875
|
+
}, u = (f) => l === "edit" ? f.editable : f.writable, g = (f) => {
|
|
1876
|
+
if (!i) return f;
|
|
1877
|
+
const p = `${i}.${f}`, E = c(p);
|
|
1878
|
+
return E === p ? f : E;
|
|
1879
|
+
}, y = (f) => {
|
|
1880
|
+
if (!f || f === Me) return null;
|
|
1881
|
+
if (!d) return f;
|
|
1882
|
+
const p = `${d}.${f}`, E = c(p);
|
|
1883
|
+
return E === p ? f : E;
|
|
1884
|
+
}, v = (f, p, E) => {
|
|
1885
|
+
const S = pt(E);
|
|
1886
|
+
if (S === "number") {
|
|
1887
|
+
const w = p === "" || p == null ? null : Number(p);
|
|
1888
|
+
n(f, Number.isNaN(w) ? null : w);
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
if (S === "boolean" || S === "bool") {
|
|
1892
|
+
n(f, !!p);
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
n(f, p);
|
|
1896
|
+
}, b = (f) => f.iconName ? /* @__PURE__ */ a(wt, { name: f.iconName, alt: f.label, variant: f.iconVariant, size: f.iconSize ?? "xl" }) : null, k = Object.entries(m).map(([f, p], E) => ({
|
|
1897
|
+
name: f,
|
|
1898
|
+
meta: p,
|
|
1899
|
+
position: E
|
|
1900
|
+
})).filter(({ name: f, meta: p }) => !(!u(p) || s && !s.includes(f))).map((f) => {
|
|
1901
|
+
const p = Re(f.meta), E = jn(f.meta, f.position);
|
|
1902
|
+
return {
|
|
1903
|
+
...f,
|
|
1904
|
+
fieldIndex: Ue(p.index ?? f.meta?.index, f.position),
|
|
1905
|
+
groupName: E.name,
|
|
1906
|
+
groupIndex: E.order
|
|
1907
|
+
};
|
|
1908
|
+
}).sort((f, p) => f.groupIndex !== p.groupIndex ? f.groupIndex - p.groupIndex : f.groupName !== p.groupName ? String(f.groupName).localeCompare(String(p.groupName)) : f.fieldIndex !== p.fieldIndex ? f.fieldIndex - p.fieldIndex : f.position - p.position), C = [], L = /* @__PURE__ */ new Map();
|
|
1909
|
+
for (const f of k) {
|
|
1910
|
+
const p = String(f.groupName);
|
|
1911
|
+
if (!L.has(p)) {
|
|
1912
|
+
const S = {
|
|
1913
|
+
key: p,
|
|
1914
|
+
name: f.groupName,
|
|
1915
|
+
index: f.groupIndex,
|
|
1916
|
+
fields: []
|
|
1917
|
+
};
|
|
1918
|
+
L.set(p, S), C.push(S);
|
|
1919
|
+
}
|
|
1920
|
+
const E = L.get(p);
|
|
1921
|
+
E.index = Math.min(E.index, f.groupIndex), E.fields.push(f);
|
|
1922
|
+
}
|
|
1923
|
+
const x = C.some((f) => f.name !== Me), N = ({ name: f, meta: p }) => {
|
|
1924
|
+
const E = t?.[f], S = pt(p?.type), w = g(f), H = Re(p), M = Xn(p), F = Wn(M, c), J = Array.isArray(r[f]) && r[f].length > 0 ? r[f] : F;
|
|
1925
|
+
if (o[f])
|
|
1926
|
+
return /* @__PURE__ */ a("div", { children: o[f]({
|
|
1927
|
+
value: E,
|
|
1928
|
+
onChange: (B) => n(f, B),
|
|
1929
|
+
meta: p,
|
|
1930
|
+
name: f,
|
|
1931
|
+
label: w,
|
|
1932
|
+
form: t,
|
|
1933
|
+
onChangeField: n
|
|
1934
|
+
}) }, f);
|
|
1935
|
+
if (S === "string" || S === "number" || S === "date") {
|
|
1936
|
+
const B = H.min ?? p.min, A = H.maxField ?? p.maxField, O = A ? t?.[A] : H.max ?? p.max, R = H.step ?? p.step, q = S !== "number" || ((I) => {
|
|
1937
|
+
if (I === "") return !0;
|
|
1938
|
+
const D = Number(I);
|
|
1939
|
+
return Number.isFinite(D) && (B == null || D >= Number(B)) && (O == null || D <= Number(O));
|
|
1940
|
+
});
|
|
1941
|
+
return /* @__PURE__ */ a(
|
|
1942
|
+
kn,
|
|
1943
|
+
{
|
|
1944
|
+
label: w,
|
|
1945
|
+
placeholder: w,
|
|
1946
|
+
type: S === "string" ? void 0 : S,
|
|
1947
|
+
value: S === "date" ? Gn(E) : E ?? "",
|
|
1948
|
+
required: p.required,
|
|
1949
|
+
requiredLabel: h.requiredLabel,
|
|
1950
|
+
min: B,
|
|
1951
|
+
max: O,
|
|
1952
|
+
step: R,
|
|
1953
|
+
isValid: q,
|
|
1954
|
+
onChange: (I) => v(f, I, S)
|
|
1955
|
+
},
|
|
1956
|
+
f
|
|
1957
|
+
);
|
|
1958
|
+
}
|
|
1959
|
+
return S === "boolean" || S === "bool" ? /* @__PURE__ */ V(G, { className: "row-left", as: "label", children: [
|
|
1960
|
+
/* @__PURE__ */ a("input", { type: "checkbox", checked: !!E, onChange: (B) => v(f, B.target.checked, S) }),
|
|
1961
|
+
w
|
|
1962
|
+
] }, f) : S.endsWith("[]") ? /* @__PURE__ */ a(
|
|
1963
|
+
Yn,
|
|
1964
|
+
{
|
|
1965
|
+
label: w,
|
|
1966
|
+
placeholder: w,
|
|
1967
|
+
value: Array.isArray(E) ? E : [],
|
|
1968
|
+
onChange: (B) => n(f, B),
|
|
1969
|
+
component: (B, A) => /* @__PURE__ */ a(G, { className: "tag", as: "p", children: B }, `${B}-${A}`)
|
|
1970
|
+
},
|
|
1971
|
+
f
|
|
1972
|
+
) : S === "object" ? /* @__PURE__ */ a(
|
|
1973
|
+
Ke,
|
|
1974
|
+
{
|
|
1975
|
+
label: w,
|
|
1976
|
+
placeholder: w,
|
|
1977
|
+
options: r[f] || [],
|
|
1978
|
+
value: E ?? "",
|
|
1979
|
+
required: p.required,
|
|
1980
|
+
onChange: (B) => n(f, B),
|
|
1981
|
+
searchable: !0,
|
|
1982
|
+
...h
|
|
1983
|
+
},
|
|
1984
|
+
f
|
|
1985
|
+
) : S === "enum" ? F.length > 6 ? /* @__PURE__ */ a(
|
|
1986
|
+
Ke,
|
|
1987
|
+
{
|
|
1988
|
+
label: w,
|
|
1989
|
+
placeholder: w,
|
|
1990
|
+
options: F,
|
|
1991
|
+
value: E ?? "",
|
|
1992
|
+
required: p.required,
|
|
1993
|
+
onChange: (B) => n(f, B),
|
|
1994
|
+
searchable: !0,
|
|
1995
|
+
...h
|
|
1996
|
+
},
|
|
1997
|
+
f
|
|
1998
|
+
) : /* @__PURE__ */ V("div", { className: "column-left gap5", children: [
|
|
1999
|
+
w && /* @__PURE__ */ V(G, { className: "form-field-label row-left", as: "label", size: "xxs", children: [
|
|
2000
|
+
w,
|
|
2001
|
+
p.required && /* @__PURE__ */ a(G, { className: "form-field-required-text", as: "span", children: c("forms.shared.required") })
|
|
2002
|
+
] }),
|
|
2003
|
+
/* @__PURE__ */ a(
|
|
2004
|
+
Nn,
|
|
2005
|
+
{
|
|
2006
|
+
enumValues: J,
|
|
2007
|
+
selectedValue: E ?? "",
|
|
2008
|
+
onValueChange: (B) => n(f, B),
|
|
2009
|
+
ariaLabel: w,
|
|
2010
|
+
className: "form-enum-selector",
|
|
2011
|
+
renderIcon: b
|
|
2012
|
+
}
|
|
2013
|
+
)
|
|
2014
|
+
] }, f) : null;
|
|
2015
|
+
};
|
|
2016
|
+
return x ? /* @__PURE__ */ a("div", { className: "full-view column-left gap20", children: C.map((f) => {
|
|
2017
|
+
const p = y(f.name);
|
|
2018
|
+
return /* @__PURE__ */ V("div", { className: "form-section", children: [
|
|
2019
|
+
p && /* @__PURE__ */ a(G, { as: "p", size: "xxs", children: p }),
|
|
2020
|
+
/* @__PURE__ */ a("div", { className: "section-fields", children: f.fields.map(N) })
|
|
2021
|
+
] }, f.key);
|
|
2022
|
+
}) }) : /* @__PURE__ */ a("div", { className: "column-left gap10 form-section", children: k.map(N) });
|
|
2023
|
+
}
|
|
2024
|
+
function es({ className: e = "", ...t }) {
|
|
2025
|
+
return /* @__PURE__ */ a("div", { className: `kosmio-loader ${e}`.trim(), role: "status", ...t });
|
|
2026
|
+
}
|
|
2027
|
+
function ts({
|
|
2028
|
+
children: e,
|
|
2029
|
+
restoreFocus: t = !0,
|
|
2030
|
+
role: n = "dialog",
|
|
2031
|
+
trapFocus: r = !0,
|
|
2032
|
+
...o
|
|
2033
|
+
}) {
|
|
2034
|
+
return /* @__PURE__ */ a(At, { ...o, "aria-modal": "true", restoreFocus: t, role: n, trapFocus: r, children: e });
|
|
2035
|
+
}
|
|
2036
|
+
function Qn({
|
|
2037
|
+
as: e = "div",
|
|
2038
|
+
children: t,
|
|
2039
|
+
className: n = "",
|
|
2040
|
+
fullsize: r = !1,
|
|
2041
|
+
showContentCard: o = !0,
|
|
2042
|
+
...s
|
|
2043
|
+
}) {
|
|
2044
|
+
return /* @__PURE__ */ a(
|
|
2045
|
+
e,
|
|
2046
|
+
{
|
|
2047
|
+
className: X(e === "main" ? "page page-container" : "", r && "fullsize", o && "page-content", n),
|
|
2048
|
+
...s,
|
|
2049
|
+
children: t
|
|
2050
|
+
}
|
|
2051
|
+
);
|
|
2052
|
+
}
|
|
2053
|
+
function ns({
|
|
2054
|
+
children: e,
|
|
2055
|
+
className: t = "full-view flex column-left gap20",
|
|
2056
|
+
formLauncher: n,
|
|
2057
|
+
showOperationsShortcut: r = !1,
|
|
2058
|
+
showContentCard: o = !0,
|
|
2059
|
+
fullsize: s = !1
|
|
2060
|
+
}) {
|
|
2061
|
+
const { clearFormLauncher: l, setFormLauncher: i, setShowOperationsShortcut: d } = Nt();
|
|
2062
|
+
return K(() => {
|
|
2063
|
+
if (n !== void 0)
|
|
2064
|
+
return n ? i(n) : l(), () => l();
|
|
2065
|
+
}, [l, n, i]), K(() => (d(r), () => d(!1)), [d, r]), /* @__PURE__ */ a(Qn, { as: "main", className: t, fullsize: s, showContentCard: o, children: e });
|
|
2066
|
+
}
|
|
2067
|
+
const Kn = {
|
|
2068
|
+
plain: "searchbar",
|
|
2069
|
+
full: "full-w searchbar"
|
|
2070
|
+
}, Un = de(function({
|
|
2071
|
+
variant: t = "full",
|
|
2072
|
+
className: n = "",
|
|
2073
|
+
placeholder: r,
|
|
2074
|
+
value: o,
|
|
2075
|
+
onChange: s,
|
|
2076
|
+
onValueChange: l,
|
|
2077
|
+
onSearch: i,
|
|
2078
|
+
onKeyDown: d,
|
|
2079
|
+
searchButtonType: c = "button",
|
|
2080
|
+
searchButtonLabel: m,
|
|
2081
|
+
searchIcon: h = null,
|
|
2082
|
+
inputRef: u,
|
|
2083
|
+
...g
|
|
2084
|
+
}, y) {
|
|
2085
|
+
const { t: v } = be(), b = r ?? v("common.actions.search", { defaultValue: "Search" }), k = Kn[t] ?? t, C = (x) => {
|
|
2086
|
+
s?.(x), l?.(x.target.value, x);
|
|
2087
|
+
}, L = () => {
|
|
2088
|
+
i?.(o ?? "");
|
|
2089
|
+
};
|
|
2090
|
+
return /* @__PURE__ */ V("div", { ref: y, className: X(k, n, "pointer"), children: [
|
|
2091
|
+
/* @__PURE__ */ a(
|
|
2092
|
+
"input",
|
|
2093
|
+
{
|
|
2094
|
+
ref: u,
|
|
2095
|
+
type: "text",
|
|
2096
|
+
className: "searchbar-input form-field",
|
|
2097
|
+
placeholder: b,
|
|
2098
|
+
value: o,
|
|
2099
|
+
onChange: C,
|
|
2100
|
+
onKeyDown: (x) => {
|
|
2101
|
+
x.key === "Enter" && (x.preventDefault(), i?.(x.currentTarget.value)), d?.(x);
|
|
2102
|
+
},
|
|
2103
|
+
...g
|
|
2104
|
+
}
|
|
2105
|
+
),
|
|
2106
|
+
/* @__PURE__ */ a(
|
|
2107
|
+
"button",
|
|
2108
|
+
{
|
|
2109
|
+
type: c,
|
|
2110
|
+
className: "searchbar-button",
|
|
2111
|
+
onClick: L,
|
|
2112
|
+
"aria-label": m || b,
|
|
2113
|
+
children: h
|
|
2114
|
+
}
|
|
2115
|
+
)
|
|
2116
|
+
] });
|
|
2117
|
+
});
|
|
2118
|
+
function Xe(e = "") {
|
|
2119
|
+
if (!e) return "/";
|
|
2120
|
+
const t = e.trim();
|
|
2121
|
+
return t === "/" ? "/" : t.replace(/\/+$/, "") || "/";
|
|
2122
|
+
}
|
|
2123
|
+
class Be {
|
|
2124
|
+
constructor({
|
|
2125
|
+
id: t,
|
|
2126
|
+
name: n,
|
|
2127
|
+
label: r,
|
|
2128
|
+
url: o,
|
|
2129
|
+
to: s,
|
|
2130
|
+
path: l,
|
|
2131
|
+
routeKey: i,
|
|
2132
|
+
activeRoutes: d,
|
|
2133
|
+
icon: c,
|
|
2134
|
+
iconSelected: m,
|
|
2135
|
+
iconName: h,
|
|
2136
|
+
iconSelectedName: u,
|
|
2137
|
+
badge: g,
|
|
2138
|
+
className: y,
|
|
2139
|
+
active: v,
|
|
2140
|
+
isActive: b,
|
|
2141
|
+
onClick: k
|
|
2142
|
+
} = {}) {
|
|
2143
|
+
this.id = t ?? s ?? o ?? l ?? i ?? n, this.name = n, this.label = r ?? n, this.url = o, this.to = s ?? o, this.path = l, this.routeKey = i, this.activeRoutes = d ?? (i ? [i] : []), this.icon = c, this.iconSelected = m, this.iconName = h, this.iconSelectedName = u, this.badge = g, this.className = y, this.active = v, this.isActive = b, this.onClick = k;
|
|
2144
|
+
}
|
|
2145
|
+
matches(t) {
|
|
2146
|
+
return typeof this.active == "boolean" ? this.active : typeof this.isActive == "function" ? !!this.isActive(Xe(t), this) : this.path ? Xe(this.path) === Xe(t) : !1;
|
|
2147
|
+
}
|
|
2148
|
+
static from(t = {}) {
|
|
2149
|
+
return t instanceof Be ? t : new Be(t);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
function Jn(e = "") {
|
|
2153
|
+
if (!e) return "/";
|
|
2154
|
+
const t = e.trim();
|
|
2155
|
+
return t === "/" ? "/" : t.replace(/\/+$/, "") || "/";
|
|
2156
|
+
}
|
|
2157
|
+
function Zn(e) {
|
|
2158
|
+
return e || (typeof globalThis < "u" && globalThis.location?.pathname ? globalThis.location.pathname : "/");
|
|
2159
|
+
}
|
|
2160
|
+
function rs({
|
|
2161
|
+
navItems: e = [],
|
|
2162
|
+
NavItemComponent: t,
|
|
2163
|
+
className: n = "",
|
|
2164
|
+
pathname: r
|
|
2165
|
+
}) {
|
|
2166
|
+
const o = Jn(Zn(r));
|
|
2167
|
+
return t ? /* @__PURE__ */ a("nav", { className: n, children: e.map((s, l) => {
|
|
2168
|
+
const i = Be.from(s), d = i.matches(o);
|
|
2169
|
+
return /* @__PURE__ */ a("div", { className: "full-w", children: /* @__PURE__ */ a(t, { navItem: i, active: d }) }, i.id ?? l);
|
|
2170
|
+
}) }) : null;
|
|
2171
|
+
}
|
|
2172
|
+
function ss(e, t) {
|
|
2173
|
+
return { color: e, size: t };
|
|
2174
|
+
}
|
|
2175
|
+
function os(e, t, n, r, o) {
|
|
2176
|
+
return { fontSize: e, fontColor: t, weight: n, lineHeight: r, as: o };
|
|
2177
|
+
}
|
|
2178
|
+
function ls(e, t, n, r, o) {
|
|
2179
|
+
return {
|
|
2180
|
+
borderStyle: e,
|
|
2181
|
+
typoStyle: t,
|
|
2182
|
+
backgroundColor: n,
|
|
2183
|
+
padding: r,
|
|
2184
|
+
radii: o
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
function er({ active: e, direction: t, sortAscIcon: n, sortDescIcon: r }) {
|
|
2188
|
+
return e ? t === "asc" ? n ?? /* @__PURE__ */ a("span", { className: "sort-icon sort-icon-asc", "aria-hidden": "true" }) : r ?? /* @__PURE__ */ a("span", { className: "sort-icon sort-icon-desc", "aria-hidden": "true" }) : null;
|
|
2189
|
+
}
|
|
2190
|
+
function tr({ columns: e, sortConfig: t, requestSort: n, sortAscIcon: r, sortDescIcon: o }) {
|
|
2191
|
+
return /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: e.map((s) => {
|
|
2192
|
+
const l = t.key === s.key, i = s.headerClassName ?? s.className ?? "";
|
|
2193
|
+
return /* @__PURE__ */ a(
|
|
2194
|
+
"th",
|
|
2195
|
+
{
|
|
2196
|
+
onClick: () => n(s.key, s.sortable),
|
|
2197
|
+
className: `${s.sortable ? "th-sortable" : ""} ${i}`.trim(),
|
|
2198
|
+
style: {
|
|
2199
|
+
cursor: s.sortable ? "pointer" : "default",
|
|
2200
|
+
width: s.width || "auto"
|
|
2201
|
+
},
|
|
2202
|
+
children: /* @__PURE__ */ V(G, { size: "md", className: "row gap5", as: "span", color: 1, dynamic: !1, children: [
|
|
2203
|
+
s.header,
|
|
2204
|
+
/* @__PURE__ */ a(
|
|
2205
|
+
er,
|
|
2206
|
+
{
|
|
2207
|
+
active: l,
|
|
2208
|
+
direction: t.direction,
|
|
2209
|
+
sortAscIcon: r,
|
|
2210
|
+
sortDescIcon: o
|
|
2211
|
+
}
|
|
2212
|
+
)
|
|
2213
|
+
] })
|
|
2214
|
+
},
|
|
2215
|
+
s.key
|
|
2216
|
+
);
|
|
2217
|
+
}) }) });
|
|
2218
|
+
}
|
|
2219
|
+
function It({ icon: e = null }) {
|
|
2220
|
+
return /* @__PURE__ */ a("div", { className: "flex-center", children: e ?? /* @__PURE__ */ a("span", { className: "table-empty-cell-icon", "aria-hidden": "true" }) });
|
|
2221
|
+
}
|
|
2222
|
+
function nr({ row: e, getValue: t, renderEmpty: n = /* @__PURE__ */ a(It, {}) }) {
|
|
2223
|
+
const r = t(e);
|
|
2224
|
+
return r == null || r === "" ? n : /* @__PURE__ */ a("div", { className: "full-w flex-center gap10 overflow-x-none", children: /* @__PURE__ */ a(G, { as: "p", size: "sm", color: 1, dynamic: !0, className: "text-inline", children: r }) });
|
|
2225
|
+
}
|
|
2226
|
+
function as({ row: e, getIconName: t, getIconSrc: n, getAlt: r, getValue: o, renderIcon: s, size: l = "xmd" }) {
|
|
2227
|
+
const i = t?.(e), d = i ? null : n?.(e), c = r?.(e) ?? "";
|
|
2228
|
+
return /* @__PURE__ */ V("div", { className: "full-w flex gap10", children: [
|
|
2229
|
+
i && typeof s == "function" ? s({ name: i, alt: c, size: l, row: e }) : null,
|
|
2230
|
+
!i && d ? /* @__PURE__ */ a(Te, { src: d, alt: c, size: l }) : null,
|
|
2231
|
+
/* @__PURE__ */ a(G, { as: "p", size: "xs", color: 2, dynamic: !0, className: "text-inline", children: o(e) })
|
|
2232
|
+
] });
|
|
2233
|
+
}
|
|
2234
|
+
function rr({ col: e, row: t }) {
|
|
2235
|
+
return e.cell ? e.cell(t) ?? /* @__PURE__ */ a(It, {}) : /* @__PURE__ */ a(
|
|
2236
|
+
nr,
|
|
2237
|
+
{
|
|
2238
|
+
row: t,
|
|
2239
|
+
getValue: (n) => {
|
|
2240
|
+
const r = e.accessor ? e.accessor(n) : n[e.key];
|
|
2241
|
+
return Array.isArray(r) && r.length === 0 ? null : r;
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
);
|
|
2245
|
+
}
|
|
2246
|
+
function sr({
|
|
2247
|
+
row: e,
|
|
2248
|
+
rowKey: t,
|
|
2249
|
+
idx: n,
|
|
2250
|
+
columns: r,
|
|
2251
|
+
striped: o,
|
|
2252
|
+
isSelected: s,
|
|
2253
|
+
conditionalRowClassName: l,
|
|
2254
|
+
hasInteractiveRows: i,
|
|
2255
|
+
rowHandlers: d
|
|
2256
|
+
}) {
|
|
2257
|
+
const c = o && n % 2 === 0 ? "row-even" : "row-odd", m = typeof l == "function" && l(e, n) || "";
|
|
2258
|
+
return /* @__PURE__ */ a(
|
|
2259
|
+
"tr",
|
|
2260
|
+
{
|
|
2261
|
+
className: `${c} ${s ? "row-selected" : ""} ${m}`,
|
|
2262
|
+
style: {
|
|
2263
|
+
cursor: i ? "pointer" : "default",
|
|
2264
|
+
...Rt({ index: n })
|
|
2265
|
+
},
|
|
2266
|
+
onClick: d.onClick,
|
|
2267
|
+
onDoubleClick: d.onDoubleClick,
|
|
2268
|
+
onContextMenu: d.onContextMenu,
|
|
2269
|
+
children: r.map((h) => {
|
|
2270
|
+
const u = h.cellClassName ?? h.className ?? "";
|
|
2271
|
+
return /* @__PURE__ */ a(
|
|
2272
|
+
"td",
|
|
2273
|
+
{
|
|
2274
|
+
className: u,
|
|
2275
|
+
style: { width: h.width || "auto" },
|
|
2276
|
+
children: rr({ col: h, row: e })
|
|
2277
|
+
},
|
|
2278
|
+
h.key
|
|
2279
|
+
);
|
|
2280
|
+
})
|
|
2281
|
+
},
|
|
2282
|
+
t
|
|
2283
|
+
);
|
|
2284
|
+
}
|
|
2285
|
+
function or({
|
|
2286
|
+
sortedData: e,
|
|
2287
|
+
columns: t,
|
|
2288
|
+
getRowKey: n,
|
|
2289
|
+
striped: r,
|
|
2290
|
+
conditionalRowClassName: o,
|
|
2291
|
+
getRowHandlers: s,
|
|
2292
|
+
hasInteractiveRows: l
|
|
2293
|
+
}) {
|
|
2294
|
+
return /* @__PURE__ */ a("tbody", { children: e.map((i, d) => {
|
|
2295
|
+
const c = n(i, d), m = s(i, c);
|
|
2296
|
+
return /* @__PURE__ */ a(
|
|
2297
|
+
sr,
|
|
2298
|
+
{
|
|
2299
|
+
row: i,
|
|
2300
|
+
rowKey: c,
|
|
2301
|
+
idx: d,
|
|
2302
|
+
columns: t,
|
|
2303
|
+
striped: r,
|
|
2304
|
+
isSelected: m.isSelected,
|
|
2305
|
+
conditionalRowClassName: o,
|
|
2306
|
+
hasInteractiveRows: l,
|
|
2307
|
+
rowHandlers: m
|
|
2308
|
+
},
|
|
2309
|
+
c
|
|
2310
|
+
);
|
|
2311
|
+
}) });
|
|
2312
|
+
}
|
|
2313
|
+
function lr({ data: e, columns: t, initialSort: n }) {
|
|
2314
|
+
const [r, o] = Z(n), s = (i, d) => {
|
|
2315
|
+
d && o((c) => ({
|
|
2316
|
+
key: i,
|
|
2317
|
+
direction: c.key === i && c.direction === "asc" ? "desc" : "asc"
|
|
2318
|
+
}));
|
|
2319
|
+
}, l = oe(() => {
|
|
2320
|
+
if (!r.key) return e;
|
|
2321
|
+
const i = t.find((c) => c.key === r.key);
|
|
2322
|
+
if (!i) return e;
|
|
2323
|
+
const d = (c) => i.accessor ? i.accessor(c) : c[i.key];
|
|
2324
|
+
return [...e].sort((c, m) => {
|
|
2325
|
+
const h = d(c), u = d(m);
|
|
2326
|
+
return h == null && u != null ? -1 : h != null && u == null ? 1 : h == null && u == null ? 0 : h < u ? r.direction === "asc" ? -1 : 1 : h > u ? r.direction === "asc" ? 1 : -1 : 0;
|
|
2327
|
+
});
|
|
2328
|
+
}, [t, e, r]);
|
|
2329
|
+
return {
|
|
2330
|
+
sortConfig: r,
|
|
2331
|
+
requestSort: s,
|
|
2332
|
+
sortedData: l
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
function ar({
|
|
2336
|
+
sortedData: e,
|
|
2337
|
+
getRowKey: t,
|
|
2338
|
+
tableRef: n,
|
|
2339
|
+
onRowClick: r,
|
|
2340
|
+
onSelectedClick: o,
|
|
2341
|
+
onDeselect: s,
|
|
2342
|
+
onSelectionChange: l,
|
|
2343
|
+
onRowRightClick: i,
|
|
2344
|
+
onEnterRow: d,
|
|
2345
|
+
selectOnRightClick: c = !0,
|
|
2346
|
+
enableKeyboardNav: m = !0,
|
|
2347
|
+
rowShortcuts: h = []
|
|
2348
|
+
}) {
|
|
2349
|
+
const [u, g] = Z(null), y = ae(null), v = ae(!1), b = typeof d == "function";
|
|
2350
|
+
K(() => {
|
|
2351
|
+
const x = (N) => {
|
|
2352
|
+
n.current && (N.target.closest(".floating-row-menu") || N.target.closest(".mobile-form-launcher") || n.current.contains(N.target) || (g(null), l?.(null, null), s?.()));
|
|
2353
|
+
};
|
|
2354
|
+
return document.addEventListener("mousedown", x), () => document.removeEventListener("mousedown", x);
|
|
2355
|
+
}, [s, l, n]), K(() => () => clearTimeout(y.current), []), K(() => {
|
|
2356
|
+
u == null || e.some((N, f) => t(N, f) === u) || (g(null), l?.(null, null), s?.());
|
|
2357
|
+
}, [t, s, l, u, e]);
|
|
2358
|
+
const k = U(
|
|
2359
|
+
(x) => {
|
|
2360
|
+
if (x == null) return -1;
|
|
2361
|
+
for (let N = 0; N < e.length; N += 1)
|
|
2362
|
+
if (t(e[N], N) === x) return N;
|
|
2363
|
+
return -1;
|
|
2364
|
+
},
|
|
2365
|
+
[t, e]
|
|
2366
|
+
), C = U(
|
|
2367
|
+
(x) => {
|
|
2368
|
+
if (!e.length) return;
|
|
2369
|
+
const N = Math.max(0, Math.min(x, e.length - 1)), f = e[N], p = t(f, N);
|
|
2370
|
+
g(p), l?.(f, p), r?.(f);
|
|
2371
|
+
},
|
|
2372
|
+
[t, r, l, e]
|
|
2373
|
+
);
|
|
2374
|
+
return K(() => {
|
|
2375
|
+
if (!m) return;
|
|
2376
|
+
const x = (N) => {
|
|
2377
|
+
if (Bt(N.target)) return;
|
|
2378
|
+
if (N.key === "ArrowDown") {
|
|
2379
|
+
if (!e.length) return;
|
|
2380
|
+
if (N.preventDefault(), u == null) {
|
|
2381
|
+
C(0);
|
|
2382
|
+
return;
|
|
2383
|
+
}
|
|
2384
|
+
const S = k(u);
|
|
2385
|
+
C(S < 0 ? 0 : S + 1);
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
if (N.key === "ArrowUp") {
|
|
2389
|
+
if (!e.length) return;
|
|
2390
|
+
if (N.preventDefault(), u == null) {
|
|
2391
|
+
C(e.length - 1);
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
const S = k(u);
|
|
2395
|
+
C(S < 0 ? e.length - 1 : S - 1);
|
|
2396
|
+
return;
|
|
2397
|
+
}
|
|
2398
|
+
if (N.key === "Enter") {
|
|
2399
|
+
if (!b || u == null) return;
|
|
2400
|
+
N.preventDefault();
|
|
2401
|
+
const S = k(u), w = e[S];
|
|
2402
|
+
if (!w) return;
|
|
2403
|
+
d(w, N);
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
if (u == null || !Array.isArray(h) || h.length === 0)
|
|
2407
|
+
return;
|
|
2408
|
+
const f = k(u), p = e[f];
|
|
2409
|
+
if (!p) return;
|
|
2410
|
+
const E = h.find((S) => S?.enabled === !1 ? !1 : Vt(N, S));
|
|
2411
|
+
E && (E.preventDefault !== !1 && N.preventDefault(), E.stopPropagation && N.stopPropagation(), E.onTrigger?.(p, N));
|
|
2412
|
+
};
|
|
2413
|
+
return window.addEventListener("keydown", x), () => window.removeEventListener("keydown", x);
|
|
2414
|
+
}, [
|
|
2415
|
+
m,
|
|
2416
|
+
b,
|
|
2417
|
+
k,
|
|
2418
|
+
d,
|
|
2419
|
+
h,
|
|
2420
|
+
C,
|
|
2421
|
+
u,
|
|
2422
|
+
e
|
|
2423
|
+
]), {
|
|
2424
|
+
selectedKey: u,
|
|
2425
|
+
getRowHandlers: (x, N) => {
|
|
2426
|
+
const f = u === N;
|
|
2427
|
+
return {
|
|
2428
|
+
isSelected: f,
|
|
2429
|
+
onClick: (p) => {
|
|
2430
|
+
if (v.current) {
|
|
2431
|
+
v.current = !1;
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
if (f) {
|
|
2435
|
+
if (!b) {
|
|
2436
|
+
o?.(x, p);
|
|
2437
|
+
return;
|
|
2438
|
+
}
|
|
2439
|
+
clearTimeout(y.current);
|
|
2440
|
+
const E = { clientX: p.clientX, clientY: p.clientY };
|
|
2441
|
+
y.current = setTimeout(() => {
|
|
2442
|
+
o?.(x, E);
|
|
2443
|
+
}, 200);
|
|
2444
|
+
return;
|
|
2445
|
+
}
|
|
2446
|
+
g(N), l?.(x, N), r?.(x, p);
|
|
2447
|
+
},
|
|
2448
|
+
onDoubleClick: (p) => {
|
|
2449
|
+
p.preventDefault(), p.stopPropagation(), clearTimeout(y.current), v.current = !0, d?.(x, p);
|
|
2450
|
+
},
|
|
2451
|
+
onContextMenu: (p) => {
|
|
2452
|
+
p.preventDefault(), c && !f && (g(N), l?.(x, N)), i?.(x, p);
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2458
|
+
function ir({
|
|
2459
|
+
data: e = [],
|
|
2460
|
+
columns: t = [],
|
|
2461
|
+
initialSort: n = {
|
|
2462
|
+
key: null,
|
|
2463
|
+
direction: "asc"
|
|
2464
|
+
},
|
|
2465
|
+
getRowKey: r = (p, E) => E,
|
|
2466
|
+
striped: o = !0,
|
|
2467
|
+
className: s = "",
|
|
2468
|
+
conditionalRowClassName: l,
|
|
2469
|
+
onRowClick: i,
|
|
2470
|
+
onSelectedClick: d,
|
|
2471
|
+
onDeselect: c,
|
|
2472
|
+
onSelectionChange: m,
|
|
2473
|
+
onRowRightClick: h,
|
|
2474
|
+
selectOnRightClick: u = !0,
|
|
2475
|
+
onEnterRow: g,
|
|
2476
|
+
enableKeyboardNav: y = !0,
|
|
2477
|
+
hasActiveSearch: v = !1,
|
|
2478
|
+
isLoading: b = !1,
|
|
2479
|
+
sourceDataCount: k = null,
|
|
2480
|
+
rowShortcuts: C = [],
|
|
2481
|
+
sortAscIcon: L,
|
|
2482
|
+
sortDescIcon: x,
|
|
2483
|
+
emptyState: N = null,
|
|
2484
|
+
noResultsState: f = null
|
|
2485
|
+
}) {
|
|
2486
|
+
const p = ae(null), { sortConfig: E, requestSort: S, sortedData: w } = lr({
|
|
2487
|
+
data: e,
|
|
2488
|
+
columns: t,
|
|
2489
|
+
initialSort: n
|
|
2490
|
+
}), { getRowHandlers: H } = ar({
|
|
2491
|
+
sortedData: w,
|
|
2492
|
+
getRowKey: r,
|
|
2493
|
+
tableRef: p,
|
|
2494
|
+
onRowClick: i,
|
|
2495
|
+
onSelectedClick: d,
|
|
2496
|
+
onDeselect: c,
|
|
2497
|
+
onSelectionChange: m,
|
|
2498
|
+
onRowRightClick: h,
|
|
2499
|
+
onEnterRow: g,
|
|
2500
|
+
selectOnRightClick: u,
|
|
2501
|
+
enableKeyboardNav: y,
|
|
2502
|
+
rowShortcuts: C
|
|
2503
|
+
}), M = typeof k == "number" ? k > 0 : null, F = !b && !e.length, J = F && (M === !0 || !!v), B = F && !J, A = !!(i || d), O = {
|
|
2504
|
+
className: s,
|
|
2505
|
+
columns: t,
|
|
2506
|
+
data: e,
|
|
2507
|
+
hasActiveSearch: v,
|
|
2508
|
+
sourceDataCount: k
|
|
2509
|
+
}, R = (q) => typeof q == "function" ? q(O) : q;
|
|
2510
|
+
return /* @__PURE__ */ a("div", { className: `full-w table-shell ${s}`.trim(), ref: p, children: b ? null : J ? R(f) : B ? R(N) : /* @__PURE__ */ a("div", { className: "table-scroll full-w", children: /* @__PURE__ */ V("table", { className: "table", children: [
|
|
2511
|
+
/* @__PURE__ */ a(
|
|
2512
|
+
tr,
|
|
2513
|
+
{
|
|
2514
|
+
columns: t,
|
|
2515
|
+
sortConfig: E,
|
|
2516
|
+
requestSort: S,
|
|
2517
|
+
sortAscIcon: L,
|
|
2518
|
+
sortDescIcon: x
|
|
2519
|
+
}
|
|
2520
|
+
),
|
|
2521
|
+
/* @__PURE__ */ a(
|
|
2522
|
+
or,
|
|
2523
|
+
{
|
|
2524
|
+
sortedData: w,
|
|
2525
|
+
columns: t,
|
|
2526
|
+
getRowKey: r,
|
|
2527
|
+
striped: o,
|
|
2528
|
+
conditionalRowClassName: l,
|
|
2529
|
+
getRowHandlers: H,
|
|
2530
|
+
hasInteractiveRows: A
|
|
2531
|
+
}
|
|
2532
|
+
)
|
|
2533
|
+
] }) }) });
|
|
2534
|
+
}
|
|
2535
|
+
function gt(e, t = 300) {
|
|
2536
|
+
const [n, r] = Z(e);
|
|
2537
|
+
return K(() => {
|
|
2538
|
+
const o = setTimeout(() => r(e), t);
|
|
2539
|
+
return () => clearTimeout(o);
|
|
2540
|
+
}, [e, t]), n;
|
|
2541
|
+
}
|
|
2542
|
+
const $e = "default", Dt = "global", Ot = Ze(null);
|
|
2543
|
+
function Fe(e = "", t = e) {
|
|
2544
|
+
return { query: e, debouncedQuery: t };
|
|
2545
|
+
}
|
|
2546
|
+
function is({ children: e, resetKey: t }) {
|
|
2547
|
+
const [n, r] = Z({});
|
|
2548
|
+
K(() => {
|
|
2549
|
+
r({});
|
|
2550
|
+
}, [t]);
|
|
2551
|
+
const o = U((d = $e, c) => {
|
|
2552
|
+
r((m) => {
|
|
2553
|
+
const h = m[d] ?? Fe();
|
|
2554
|
+
return h.query === c ? m : {
|
|
2555
|
+
...m,
|
|
2556
|
+
[d]: {
|
|
2557
|
+
...h,
|
|
2558
|
+
query: c
|
|
2559
|
+
}
|
|
2560
|
+
};
|
|
2561
|
+
});
|
|
2562
|
+
}, []), s = U((d = $e, c) => {
|
|
2563
|
+
r((m) => {
|
|
2564
|
+
const h = m[d] ?? Fe();
|
|
2565
|
+
return h.debouncedQuery === c ? m : {
|
|
2566
|
+
...m,
|
|
2567
|
+
[d]: {
|
|
2568
|
+
...h,
|
|
2569
|
+
debouncedQuery: c
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
});
|
|
2573
|
+
}, []), l = U((d = $e) => {
|
|
2574
|
+
r((c) => ({
|
|
2575
|
+
...c,
|
|
2576
|
+
[d]: Fe()
|
|
2577
|
+
}));
|
|
2578
|
+
}, []), i = oe(
|
|
2579
|
+
() => ({
|
|
2580
|
+
searchByScope: n,
|
|
2581
|
+
setQuery: o,
|
|
2582
|
+
setDebouncedQuery: s,
|
|
2583
|
+
clearQuery: l
|
|
2584
|
+
}),
|
|
2585
|
+
[l, n, s, o]
|
|
2586
|
+
);
|
|
2587
|
+
return /* @__PURE__ */ a(Ot.Provider, { value: i, children: e });
|
|
2588
|
+
}
|
|
2589
|
+
function zt(e = $e, { debounceMs: t = 250 } = {}) {
|
|
2590
|
+
const n = Je(Ot), [r, o] = Z(""), s = gt(r, t), l = n?.searchByScope?.[e] ?? Fe(), i = n ? l.query : r, d = n ? l.debouncedQuery : s, c = gt(i, t);
|
|
2591
|
+
K(() => {
|
|
2592
|
+
n && n.setDebouncedQuery(e, c);
|
|
2593
|
+
}, [n, c, e]);
|
|
2594
|
+
const m = U(
|
|
2595
|
+
(u) => {
|
|
2596
|
+
if (n) {
|
|
2597
|
+
n.setQuery(e, u);
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
o(u);
|
|
2601
|
+
},
|
|
2602
|
+
[n, e]
|
|
2603
|
+
), h = U(() => {
|
|
2604
|
+
if (n) {
|
|
2605
|
+
n.clearQuery(e);
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2608
|
+
o("");
|
|
2609
|
+
}, [n, e]);
|
|
2610
|
+
return {
|
|
2611
|
+
query: i,
|
|
2612
|
+
debouncedQuery: d,
|
|
2613
|
+
setQuery: m,
|
|
2614
|
+
clearQuery: h
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
function cr({ text: e, onClick: t, className: n, ariaLabel: r }) {
|
|
2618
|
+
return /* @__PURE__ */ a("button", { type: "button", className: n, onClick: t, "aria-label": r, children: e });
|
|
2619
|
+
}
|
|
2620
|
+
function ur({
|
|
2621
|
+
options: e = [],
|
|
2622
|
+
selectedOption: t,
|
|
2623
|
+
onChangeOption: n,
|
|
2624
|
+
setData: r,
|
|
2625
|
+
onQueryChange: o,
|
|
2626
|
+
initialQuery: s = "",
|
|
2627
|
+
placeholder: l,
|
|
2628
|
+
ariaLabel: i,
|
|
2629
|
+
filterLabel: d,
|
|
2630
|
+
className: c = "",
|
|
2631
|
+
filters: m = !0,
|
|
2632
|
+
addButton: h = !0,
|
|
2633
|
+
buttonName: u = "common.actions.add",
|
|
2634
|
+
enableCtrlF: g = !1,
|
|
2635
|
+
translate: y,
|
|
2636
|
+
isMobile: v = !1,
|
|
2637
|
+
onAdd: b,
|
|
2638
|
+
searchIcon: k = null,
|
|
2639
|
+
showSearchIcon: C = !0,
|
|
2640
|
+
showSearchInput: L = !0,
|
|
2641
|
+
searchSuggestions: x = [],
|
|
2642
|
+
getSearchSuggestionText: N = (A) => A?.label ?? "",
|
|
2643
|
+
getSearchSuggestionValue: f = (A) => A?.id ?? A?.value,
|
|
2644
|
+
renderSearchSuggestion: p,
|
|
2645
|
+
selectedSearchSuggestionLabel: E = "",
|
|
2646
|
+
selectedSearchValue: S,
|
|
2647
|
+
onSearchSuggestionSelect: w,
|
|
2648
|
+
onClearSearchSelection: H,
|
|
2649
|
+
clearSearchLabel: M,
|
|
2650
|
+
searchSuggestionEmptyState: F,
|
|
2651
|
+
renderActionButton: J = cr,
|
|
2652
|
+
searchScope: B
|
|
2653
|
+
}) {
|
|
2654
|
+
const { t: A } = be(), O = ae(null), R = ae(null), q = ae(null), I = Ve(), [D, P] = Z(!1), [T, _] = Z(-1), [W, le] = Z(null), Q = y ?? A, te = oe(() => e.find(($) => $.value === t) ?? e[0] ?? null, [e, t]), ye = te?.value ?? "", he = te?.data ?? [], xe = B ?? ye, { query: ie, debouncedQuery: Se, setQuery: ve } = zt(xe), ce = oe(() => {
|
|
2655
|
+
const z = ie.trim().toLocaleLowerCase();
|
|
2656
|
+
return x.filter(($) => !z || String(N($) ?? "").toLocaleLowerCase().includes(z));
|
|
2657
|
+
}, [N, ie, x]), ue = U(() => {
|
|
2658
|
+
const z = R.current?.getBoundingClientRect();
|
|
2659
|
+
if (!z) return;
|
|
2660
|
+
const $ = window.innerHeight - z.bottom - 16, ee = z.top - 16, se = $ < 180 && ee > $, ge = Math.max(80, Math.min(280, se ? ee : $));
|
|
2661
|
+
le({
|
|
2662
|
+
left: z.left,
|
|
2663
|
+
top: se ? z.top - ge - 6 : z.bottom + 6,
|
|
2664
|
+
width: z.width,
|
|
2665
|
+
maxHeight: ge
|
|
2666
|
+
});
|
|
2667
|
+
}, []);
|
|
2668
|
+
K(() => {
|
|
2669
|
+
if (!D) return;
|
|
2670
|
+
const z = (ee) => {
|
|
2671
|
+
const se = ee.target;
|
|
2672
|
+
q.current?.contains(se) || R.current?.contains(se) && !se.closest?.(".searchbar-select") || (ve(""), P(!1), _(-1), le(null));
|
|
2673
|
+
};
|
|
2674
|
+
ue();
|
|
2675
|
+
const $ = new ResizeObserver(ue);
|
|
2676
|
+
return R.current && $.observe(R.current), window.addEventListener("resize", ue), window.addEventListener("scroll", ue, !0), document.addEventListener("pointerdown", z, !0), () => {
|
|
2677
|
+
window.removeEventListener("resize", ue), window.removeEventListener("scroll", ue, !0), document.removeEventListener("pointerdown", z, !0), $.disconnect();
|
|
2678
|
+
};
|
|
2679
|
+
}, [D, ue]), K(() => {
|
|
2680
|
+
T >= ce.length && _(ce.length - 1);
|
|
2681
|
+
}, [T, ce.length]);
|
|
2682
|
+
const Ce = oe(() => te ? te.searchKeys?.length ? te.searchKeys : ["name", "label"] : ["name", "label"], [te]), Y = U(
|
|
2683
|
+
(z, $) => {
|
|
2684
|
+
if (!$) return !0;
|
|
2685
|
+
const ee = $.toLowerCase();
|
|
2686
|
+
for (const se of Ce) {
|
|
2687
|
+
const ge = z?.[se];
|
|
2688
|
+
if (ge != null && String(ge).toLowerCase().includes(ee)) return !0;
|
|
2689
|
+
}
|
|
2690
|
+
for (const se of Object.values(z || {}))
|
|
2691
|
+
if (typeof se == "string" && se.toLowerCase().includes(ee)) return !0;
|
|
2692
|
+
return !1;
|
|
2693
|
+
},
|
|
2694
|
+
[Ce]
|
|
2695
|
+
), ne = ae({ key: "", query: "", length: -1 }), me = U(
|
|
2696
|
+
(z) => {
|
|
2697
|
+
if (!te || typeof r != "function") return;
|
|
2698
|
+
const $ = (z ?? "").trim(), ee = Array.isArray(he) ? he : [], se = $ ? ee.filter((Ft) => Y(Ft, $)) : ee, ge = { key: ye, query: $, length: se.length }, Ye = ne.current;
|
|
2699
|
+
Ye.key === ge.key && Ye.query === ge.query && Ye.length === ge.length || (ne.current = ge, r(se));
|
|
2700
|
+
},
|
|
2701
|
+
[te, he, ye, Y, r]
|
|
2702
|
+
), j = U(() => {
|
|
2703
|
+
typeof b == "function" && b(te);
|
|
2704
|
+
}, [te, b]);
|
|
2705
|
+
K(() => {
|
|
2706
|
+
s && ve(s);
|
|
2707
|
+
}, [s, ve]), K(() => {
|
|
2708
|
+
if (!te || typeof r != "function" || ie.trim() !== "") return;
|
|
2709
|
+
const z = Array.isArray(he) ? he : [], $ = { key: ye, query: "", length: z.length }, ee = ne.current;
|
|
2710
|
+
ee.key === $.key && ee.query === $.query && ee.length === $.length || (ne.current = $, r(z));
|
|
2711
|
+
}, [ie, te, he, ye, r]), K(() => {
|
|
2712
|
+
me(Se);
|
|
2713
|
+
}, [Se, ye, me]), K(() => {
|
|
2714
|
+
o?.(ie);
|
|
2715
|
+
}, [ie, o]), K(() => {
|
|
2716
|
+
if (!g) return;
|
|
2717
|
+
const z = ($) => {
|
|
2718
|
+
const ee = $.target, se = ee?.tagName?.toLowerCase(), ge = se === "input" || se === "textarea" || se === "select" || ee?.isContentEditable;
|
|
2719
|
+
if (($.ctrlKey || $.metaKey) && $.key.toLowerCase() === "f") {
|
|
2720
|
+
$.preventDefault(), O.current?.focus(), O.current?.select();
|
|
2721
|
+
return;
|
|
2722
|
+
}
|
|
2723
|
+
!ge && $.key.toLowerCase() === "n" && ($.preventDefault(), j());
|
|
2724
|
+
};
|
|
2725
|
+
return window.addEventListener("keydown", z), () => window.removeEventListener("keydown", z);
|
|
2726
|
+
}, [g, j]);
|
|
2727
|
+
const re = Q("common.shortcuts.add"), fe = Q("common.shortcuts.filters"), Ne = te?.addFormName && h ? J({
|
|
2728
|
+
variant: "primary",
|
|
2729
|
+
text: Q(u),
|
|
2730
|
+
iconName: "actionAdd",
|
|
2731
|
+
alt: Q("common.messages.addIconAlt"),
|
|
2732
|
+
onClick: j,
|
|
2733
|
+
ariaLabel: Q(u),
|
|
2734
|
+
tooltipDirection: "left",
|
|
2735
|
+
tooltipText: Q("common.shortcuts.tooltip", {
|
|
2736
|
+
label: Q(u),
|
|
2737
|
+
shortcut: re
|
|
2738
|
+
}),
|
|
2739
|
+
className: v ? "full-w" : "searchbar-add"
|
|
2740
|
+
}) : null, ke = e.length > 1, pe = L && typeof w == "function", we = (z) => {
|
|
2741
|
+
w?.(z), ve(""), P(!1), _(-1), le(null);
|
|
2742
|
+
}, qe = (z) => {
|
|
2743
|
+
z.key === "ArrowDown" ? (z.preventDefault(), P(!0), _(($) => Math.min($ + 1, ce.length - 1))) : z.key === "ArrowUp" ? (z.preventDefault(), P(!0), _(($) => $ <= 0 ? ce.length - 1 : $ - 1)) : z.key === "Enter" && D && ce.length ? (z.preventDefault(), we(ce[T >= 0 ? T : 0])) : z.key === "Escape" && D && (z.preventDefault(), ve(""), P(!1), _(-1), le(null));
|
|
2744
|
+
}, He = () => {
|
|
2745
|
+
H?.(), ve(""), P(!1), _(-1), le(null);
|
|
2746
|
+
}, rt = /* @__PURE__ */ V(
|
|
2747
|
+
"div",
|
|
2748
|
+
{
|
|
2749
|
+
onClick: ke ? (z) => {
|
|
2750
|
+
const $ = z.target;
|
|
2751
|
+
if (!($ instanceof Element)) return;
|
|
2752
|
+
const ee = $.closest(".searchbar-select");
|
|
2753
|
+
!ee || $.closest(".select-trigger") || ee.querySelector(".select-trigger")?.click();
|
|
2754
|
+
} : void 0,
|
|
2755
|
+
ref: R,
|
|
2756
|
+
className: X(
|
|
2757
|
+
"searchbar-container kosmio-full-searchbar",
|
|
2758
|
+
c,
|
|
2759
|
+
!L && "is-filter-only",
|
|
2760
|
+
ke && "has-dataset",
|
|
2761
|
+
m && "has-filter-action",
|
|
2762
|
+
C && "has-search-icon"
|
|
2763
|
+
),
|
|
2764
|
+
children: [
|
|
2765
|
+
L && /* @__PURE__ */ a(
|
|
2766
|
+
Un,
|
|
2767
|
+
{
|
|
2768
|
+
variant: "full",
|
|
2769
|
+
className: "searchbar-main",
|
|
2770
|
+
value: D ? ie : ie || E,
|
|
2771
|
+
placeholder: l ?? Q("common.actions.search"),
|
|
2772
|
+
searchButtonLabel: i ?? l ?? Q("common.actions.search"),
|
|
2773
|
+
searchIcon: k,
|
|
2774
|
+
onValueChange: ve,
|
|
2775
|
+
onFocus: () => pe && P(!0),
|
|
2776
|
+
onKeyDown: pe ? qe : void 0,
|
|
2777
|
+
onSearch: me,
|
|
2778
|
+
inputRef: O,
|
|
2779
|
+
"aria-label": i ?? l ?? Q("common.actions.search"),
|
|
2780
|
+
role: pe ? "combobox" : void 0,
|
|
2781
|
+
"aria-autocomplete": pe ? "list" : void 0,
|
|
2782
|
+
"aria-expanded": pe ? D : void 0,
|
|
2783
|
+
"aria-controls": pe ? I : void 0,
|
|
2784
|
+
"aria-activedescendant": pe && T >= 0 ? `${I}-${T}` : void 0
|
|
2785
|
+
}
|
|
2786
|
+
),
|
|
2787
|
+
S != null && String(S) !== "" && H && !D && /* @__PURE__ */ a(
|
|
2788
|
+
"button",
|
|
2789
|
+
{
|
|
2790
|
+
type: "button",
|
|
2791
|
+
className: "kosmio-search-clear",
|
|
2792
|
+
"aria-label": M ?? Q("forms.operations.search.clearSelection", { animal: E }),
|
|
2793
|
+
onClick: He,
|
|
2794
|
+
children: "×"
|
|
2795
|
+
}
|
|
2796
|
+
),
|
|
2797
|
+
ke && /* @__PURE__ */ a(
|
|
2798
|
+
Ke,
|
|
2799
|
+
{
|
|
2800
|
+
value: te?.value || "",
|
|
2801
|
+
onChange: (z) => n?.(z),
|
|
2802
|
+
options: e.map(({ value: z, label: $ }) => ({ value: z, label: $ })),
|
|
2803
|
+
placeholder: Q("common.messages.selectDataset"),
|
|
2804
|
+
label: d,
|
|
2805
|
+
requiredLabel: Q("forms.shared.required"),
|
|
2806
|
+
selectOptionLabel: Q("forms.shared.selectOption"),
|
|
2807
|
+
className: "searchbar-select"
|
|
2808
|
+
}
|
|
2809
|
+
),
|
|
2810
|
+
m ? J({
|
|
2811
|
+
text: Q("common.actions.filters"),
|
|
2812
|
+
iconName: "actionFilter",
|
|
2813
|
+
alt: Q("common.messages.filterIconAlt"),
|
|
2814
|
+
ariaLabel: Q("common.actions.filters"),
|
|
2815
|
+
tooltipDirection: "left",
|
|
2816
|
+
tooltipText: Q("common.shortcuts.tooltip", {
|
|
2817
|
+
label: Q("common.actions.filters"),
|
|
2818
|
+
shortcut: fe
|
|
2819
|
+
}),
|
|
2820
|
+
className: "searchbar-filter"
|
|
2821
|
+
}) : null
|
|
2822
|
+
]
|
|
2823
|
+
}
|
|
2824
|
+
), st = pe && D && W ? nt(
|
|
2825
|
+
/* @__PURE__ */ a("div", { className: "kosmio-search-suggestions", style: W, ref: q, children: /* @__PURE__ */ a("div", { className: "kosmio-search-suggestion-list", id: I, role: "listbox", children: ce.length ? ce.map((z, $) => {
|
|
2826
|
+
const ee = f(z), se = S != null && String(ee) === String(S);
|
|
2827
|
+
return /* @__PURE__ */ a(
|
|
2828
|
+
"button",
|
|
2829
|
+
{
|
|
2830
|
+
type: "button",
|
|
2831
|
+
role: "option",
|
|
2832
|
+
"aria-selected": se,
|
|
2833
|
+
"aria-current": $ === T ? "true" : void 0,
|
|
2834
|
+
id: `${I}-${$}`,
|
|
2835
|
+
className: X("kosmio-search-suggestion", $ === T && "is-active", se && "is-selected"),
|
|
2836
|
+
onPointerMove: () => _($),
|
|
2837
|
+
onClick: () => we(z),
|
|
2838
|
+
children: p?.(z) ?? N(z)
|
|
2839
|
+
},
|
|
2840
|
+
String(ee ?? $)
|
|
2841
|
+
);
|
|
2842
|
+
}) : F ? /* @__PURE__ */ a(G, { className: "kosmio-search-suggestion-empty", as: "p", size: "sm", children: F }) : null }) }),
|
|
2843
|
+
document.body
|
|
2844
|
+
) : null;
|
|
2845
|
+
return v ? /* @__PURE__ */ V("div", { className: "full-w flex column gap5", children: [
|
|
2846
|
+
rt,
|
|
2847
|
+
st,
|
|
2848
|
+
Ne
|
|
2849
|
+
] }) : /* @__PURE__ */ V(yt, { children: [
|
|
2850
|
+
rt,
|
|
2851
|
+
st
|
|
2852
|
+
] });
|
|
2853
|
+
}
|
|
2854
|
+
function dr({ x: e, y: t, row: n, actions: r = [], onClose: o }) {
|
|
2855
|
+
if (!n) return null;
|
|
2856
|
+
const s = (d) => {
|
|
2857
|
+
d.stopPropagation();
|
|
2858
|
+
}, l = e > window.innerWidth / 2 ? "100%" : "0%", i = t > window.innerHeight / 2 ? "100%" : "0%";
|
|
2859
|
+
return /* @__PURE__ */ a("div", { className: "floating-row-menu", onClick: s, style: {
|
|
2860
|
+
position: "fixed",
|
|
2861
|
+
top: t + 4,
|
|
2862
|
+
left: e + 4,
|
|
2863
|
+
"--origin-x": l,
|
|
2864
|
+
"--origin-y": i
|
|
2865
|
+
}, children: /* @__PURE__ */ a("div", { className: "floating-row-menu-card", children: r.map(({
|
|
2866
|
+
label: d,
|
|
2867
|
+
icon: c,
|
|
2868
|
+
iconName: m,
|
|
2869
|
+
renderIcon: h,
|
|
2870
|
+
onClick: u,
|
|
2871
|
+
color: g,
|
|
2872
|
+
shortcut: y,
|
|
2873
|
+
disabled: v
|
|
2874
|
+
}, b) => {
|
|
2875
|
+
const k = typeof d == "function" ? d(n) : d, C = typeof v == "function" ? v(n) : !!v;
|
|
2876
|
+
return k ? /* @__PURE__ */ V("button", { type: "button", className: `menu-item ${g || ""}`, disabled: C, onClick: () => {
|
|
2877
|
+
C || (u?.(n), o?.());
|
|
2878
|
+
}, children: [
|
|
2879
|
+
/* @__PURE__ */ a(G, { as: "p", className: "full-w", children: k }),
|
|
2880
|
+
typeof h == "function" ? h({ icon: c, iconName: m, row: n }) : null,
|
|
2881
|
+
!h && c ? /* @__PURE__ */ a(Te, { src: c, decorative: !0 }) : null,
|
|
2882
|
+
y && /* @__PURE__ */ a("div", { className: "shortcut", children: /* @__PURE__ */ a(G, { as: "p", children: y }) })
|
|
2883
|
+
] }, k || b) : null;
|
|
2884
|
+
}) }) });
|
|
2885
|
+
}
|
|
2886
|
+
function fr({ text: e, onClick: t, className: n, ariaLabel: r }) {
|
|
2887
|
+
return /* @__PURE__ */ a("button", { type: "button", className: n, onClick: t, "aria-label": r, children: e });
|
|
2888
|
+
}
|
|
2889
|
+
function mr({
|
|
2890
|
+
id: e,
|
|
2891
|
+
table_name: t = null,
|
|
2892
|
+
addFormName: n,
|
|
2893
|
+
searchKeys: r,
|
|
2894
|
+
columns: o,
|
|
2895
|
+
initialData: s = [],
|
|
2896
|
+
isLoading: l = !1,
|
|
2897
|
+
buttonName: i = "common.actions.add",
|
|
2898
|
+
onRowClick: d,
|
|
2899
|
+
onRowRightClick: c,
|
|
2900
|
+
onSelectedClick: m,
|
|
2901
|
+
onDeselect: h,
|
|
2902
|
+
onSelectionChange: u,
|
|
2903
|
+
onEnterRow: g,
|
|
2904
|
+
rowShortcuts: y = [],
|
|
2905
|
+
includeHeader: v = !0,
|
|
2906
|
+
emptyState: b,
|
|
2907
|
+
noResultsState: k,
|
|
2908
|
+
conditionalRowClassName: C,
|
|
2909
|
+
translate: L,
|
|
2910
|
+
renderActionButton: x = fr,
|
|
2911
|
+
searchIcon: N = null,
|
|
2912
|
+
searchScope: f,
|
|
2913
|
+
includePageSearchbar: p = !1,
|
|
2914
|
+
useGlobalSearch: E = !1
|
|
2915
|
+
}) {
|
|
2916
|
+
const { t: S } = be(), { openForm: w } = tt(), { isMobile: H } = kt(), M = L ?? S, F = E ? Dt : f ?? e, { debouncedQuery: J } = zt(F), B = v && !p && !E, A = J ?? "", O = [
|
|
2917
|
+
{
|
|
2918
|
+
value: e,
|
|
2919
|
+
label: M(t),
|
|
2920
|
+
data: s || [],
|
|
2921
|
+
addFormName: n,
|
|
2922
|
+
searchKeys: r
|
|
2923
|
+
}
|
|
2924
|
+
], R = () => {
|
|
2925
|
+
n && w(n, "add");
|
|
2926
|
+
}, q = M("common.shortcuts.add"), I = oe(() => r?.length ? r : ["name", "label"], [r]), D = oe(() => {
|
|
2927
|
+
const P = Array.isArray(s) ? s : [], T = A.trim().toLowerCase();
|
|
2928
|
+
return T ? P.filter((_) => {
|
|
2929
|
+
for (const W of I) {
|
|
2930
|
+
const le = _?.[W];
|
|
2931
|
+
if (le != null && String(le).toLowerCase().includes(T)) return !0;
|
|
2932
|
+
}
|
|
2933
|
+
for (const W of Object.values(_ || {}))
|
|
2934
|
+
if (typeof W == "string" && W.toLowerCase().includes(T)) return !0;
|
|
2935
|
+
return !1;
|
|
2936
|
+
}) : P;
|
|
2937
|
+
}, [s, I, A]);
|
|
2938
|
+
return /* @__PURE__ */ V("div", { className: "full-view flex column-left gap10 table-crud", children: [
|
|
2939
|
+
B && /* @__PURE__ */ a(
|
|
2940
|
+
ur,
|
|
2941
|
+
{
|
|
2942
|
+
options: O,
|
|
2943
|
+
buttonName: i,
|
|
2944
|
+
enableCtrlF: !0,
|
|
2945
|
+
filters: !1,
|
|
2946
|
+
isMobile: H,
|
|
2947
|
+
onAdd: R,
|
|
2948
|
+
searchIcon: N,
|
|
2949
|
+
renderActionButton: x,
|
|
2950
|
+
searchScope: F
|
|
2951
|
+
}
|
|
2952
|
+
),
|
|
2953
|
+
/* @__PURE__ */ V("div", { className: "table-crud-content column-left full-view gap20", children: [
|
|
2954
|
+
v && !H && /* @__PURE__ */ V("div", { className: "flex row full-w", children: [
|
|
2955
|
+
t && /* @__PURE__ */ a(G, { size: "xl", children: M(t) }),
|
|
2956
|
+
/* @__PURE__ */ a("div", { className: "full-w row-right", children: n ? x({
|
|
2957
|
+
variant: "primary",
|
|
2958
|
+
text: M(i),
|
|
2959
|
+
iconName: "actionAdd",
|
|
2960
|
+
alt: M("common.messages.addIconAlt"),
|
|
2961
|
+
onClick: R,
|
|
2962
|
+
ariaLabel: M(i),
|
|
2963
|
+
tooltipDirection: "left",
|
|
2964
|
+
tooltipText: M("common.shortcuts.tooltip", {
|
|
2965
|
+
label: M(i),
|
|
2966
|
+
shortcut: q
|
|
2967
|
+
}),
|
|
2968
|
+
className: "searchbar-add"
|
|
2969
|
+
}) : null })
|
|
2970
|
+
] }),
|
|
2971
|
+
/* @__PURE__ */ a(
|
|
2972
|
+
ir,
|
|
2973
|
+
{
|
|
2974
|
+
data: D,
|
|
2975
|
+
columns: o.filter(Boolean),
|
|
2976
|
+
isLoading: l,
|
|
2977
|
+
onRowClick: d,
|
|
2978
|
+
onRowRightClick: c,
|
|
2979
|
+
onSelectedClick: m,
|
|
2980
|
+
onDeselect: h,
|
|
2981
|
+
onSelectionChange: u,
|
|
2982
|
+
conditionalRowClassName: C,
|
|
2983
|
+
onEnterRow: g,
|
|
2984
|
+
hasActiveSearch: !!A.trim(),
|
|
2985
|
+
sourceDataCount: Array.isArray(s) ? s.length : 0,
|
|
2986
|
+
rowShortcuts: y,
|
|
2987
|
+
emptyState: b,
|
|
2988
|
+
noResultsState: k
|
|
2989
|
+
}
|
|
2990
|
+
)
|
|
2991
|
+
] })
|
|
2992
|
+
] });
|
|
2993
|
+
}
|
|
2994
|
+
const We = (e) => e != null && Object.prototype.hasOwnProperty.call(e, "archived") && !!e?.archived;
|
|
2995
|
+
function hr({
|
|
2996
|
+
id: e,
|
|
2997
|
+
table_name: t,
|
|
2998
|
+
addFormName: n,
|
|
2999
|
+
optionsFormName: r,
|
|
3000
|
+
searchKeys: o,
|
|
3001
|
+
columns: s,
|
|
3002
|
+
initialData: l = [],
|
|
3003
|
+
isLoading: i = !1,
|
|
3004
|
+
buttonName: d = "common.actions.add",
|
|
3005
|
+
mainAction: c,
|
|
3006
|
+
desktopMenuActions: m = [],
|
|
3007
|
+
onEditRow: h,
|
|
3008
|
+
onToggleArchiveRow: u,
|
|
3009
|
+
onDeleteRow: g,
|
|
3010
|
+
allowArchive: y = !0,
|
|
3011
|
+
allowDelete: v = !0,
|
|
3012
|
+
openMobileMenu: b,
|
|
3013
|
+
conditionalRowClassName: k,
|
|
3014
|
+
rowShortcuts: C = [],
|
|
3015
|
+
fillAvailableHeight: L = !1,
|
|
3016
|
+
includeHeader: x = !0,
|
|
3017
|
+
translate: N,
|
|
3018
|
+
createActionsPayload: f = (B, A) => ({ row: B, actions: A }),
|
|
3019
|
+
TableCRUDComponent: p = mr,
|
|
3020
|
+
renderActionButton: E,
|
|
3021
|
+
searchIcon: S = null,
|
|
3022
|
+
emptyState: w,
|
|
3023
|
+
noResultsState: H,
|
|
3024
|
+
searchScope: M,
|
|
3025
|
+
includePageSearchbar: F = !1,
|
|
3026
|
+
useGlobalSearch: J = !1
|
|
3027
|
+
}) {
|
|
3028
|
+
const { t: B } = be(), { isMobile: A } = kt(), { openConfirm: O } = Mt(), { openFormLauncher: R, setFormLauncher: q } = Nt(), I = N ?? B, [D, P] = Z({
|
|
3029
|
+
visible: !1,
|
|
3030
|
+
x: 0,
|
|
3031
|
+
y: 0,
|
|
3032
|
+
row: null
|
|
3033
|
+
}), T = () => P({ visible: !1, x: 0, y: 0, row: null }), _ = U(
|
|
3034
|
+
(Y) => {
|
|
3035
|
+
if (!y || typeof u != "function") return;
|
|
3036
|
+
const me = We(Y);
|
|
3037
|
+
if (!v) {
|
|
3038
|
+
O?.({
|
|
3039
|
+
title: I("common.messages.confirm.title"),
|
|
3040
|
+
message: I(me ? "common.messages.confirm.unarchiveItem" : "common.messages.confirm.archiveItem"),
|
|
3041
|
+
confirmText: I(me ? "common.actions.unarchive" : "common.actions.archive"),
|
|
3042
|
+
cancelText: I("common.actions.cancel"),
|
|
3043
|
+
danger: !1,
|
|
3044
|
+
onConfirm: () => u(Y)
|
|
3045
|
+
});
|
|
3046
|
+
return;
|
|
3047
|
+
}
|
|
3048
|
+
u(Y);
|
|
3049
|
+
},
|
|
3050
|
+
[y, v, u, O, I]
|
|
3051
|
+
), W = U(
|
|
3052
|
+
(Y) => {
|
|
3053
|
+
!v || typeof g != "function" || O?.({
|
|
3054
|
+
title: I("common.messages.confirm.title"),
|
|
3055
|
+
message: I("common.messages.confirm.deleteItem"),
|
|
3056
|
+
confirmText: I("common.actions.delete"),
|
|
3057
|
+
cancelText: I("common.actions.cancel"),
|
|
3058
|
+
danger: !0,
|
|
3059
|
+
onConfirm: () => g(Y)
|
|
3060
|
+
});
|
|
3061
|
+
},
|
|
3062
|
+
[v, g, O, I]
|
|
3063
|
+
), le = oe(() => {
|
|
3064
|
+
const Y = [];
|
|
3065
|
+
return typeof h == "function" && Y.push({
|
|
3066
|
+
label: I("common.actions.edit"),
|
|
3067
|
+
onClick: h,
|
|
3068
|
+
shortcut: "E"
|
|
3069
|
+
}), y && typeof u == "function" && Y.push({
|
|
3070
|
+
label: (ne) => We(ne) ? I("common.actions.unarchive") : I("common.actions.archive"),
|
|
3071
|
+
onClick: _,
|
|
3072
|
+
shortcut: "T"
|
|
3073
|
+
}), v && typeof g == "function" && Y.push({
|
|
3074
|
+
label: I("common.actions.delete"),
|
|
3075
|
+
onClick: W,
|
|
3076
|
+
shortcut: "Del"
|
|
3077
|
+
}), Y;
|
|
3078
|
+
}, [
|
|
3079
|
+
y,
|
|
3080
|
+
v,
|
|
3081
|
+
g,
|
|
3082
|
+
h,
|
|
3083
|
+
u,
|
|
3084
|
+
_,
|
|
3085
|
+
W,
|
|
3086
|
+
I
|
|
3087
|
+
]), Q = oe(
|
|
3088
|
+
() => [...m, ...le],
|
|
3089
|
+
[m, le]
|
|
3090
|
+
), te = oe(() => {
|
|
3091
|
+
const Y = [];
|
|
3092
|
+
return typeof h == "function" && Y.push({ keys: "e", onTrigger: h }), y && typeof u == "function" && Y.push({ keys: "t", onTrigger: _ }), v && typeof g == "function" && Y.push({ keys: ["delete", "backspace"], onTrigger: W }), Y;
|
|
3093
|
+
}, [
|
|
3094
|
+
y,
|
|
3095
|
+
v,
|
|
3096
|
+
g,
|
|
3097
|
+
h,
|
|
3098
|
+
u,
|
|
3099
|
+
_,
|
|
3100
|
+
W
|
|
3101
|
+
]), ye = oe(
|
|
3102
|
+
() => C.length > 0 ? C : te,
|
|
3103
|
+
[C, te]
|
|
3104
|
+
), he = oe(() => (Y, ne) => {
|
|
3105
|
+
const me = typeof k == "function" && k(Y, ne) || "", j = We(Y) ? "row-archived" : "";
|
|
3106
|
+
return [me, j].filter(Boolean).join(" ");
|
|
3107
|
+
}, [k]);
|
|
3108
|
+
K(() => {
|
|
3109
|
+
T();
|
|
3110
|
+
}, [l]);
|
|
3111
|
+
const xe = oe(() => n ? ot({
|
|
3112
|
+
group: n,
|
|
3113
|
+
action: "add",
|
|
3114
|
+
iconName: "actionAddFill",
|
|
3115
|
+
labelKey: d
|
|
3116
|
+
}) : null, [n, d]), ie = U(
|
|
3117
|
+
(Y) => !Y || !r || Q.length === 0 ? xe : ot({
|
|
3118
|
+
group: r,
|
|
3119
|
+
action: "options",
|
|
3120
|
+
payload: f(Y, Q),
|
|
3121
|
+
iconName: "actionMenuFill",
|
|
3122
|
+
labelKey: "common.actions.menu",
|
|
3123
|
+
variant: "options"
|
|
3124
|
+
}),
|
|
3125
|
+
[f, xe, r, Q]
|
|
3126
|
+
);
|
|
3127
|
+
K(() => {
|
|
3128
|
+
q(xe);
|
|
3129
|
+
}, [xe, q]);
|
|
3130
|
+
const Se = () => {
|
|
3131
|
+
D.visible && T();
|
|
3132
|
+
}, ve = (Y, ne) => {
|
|
3133
|
+
if (D.visible && D.row?.id === Y?.id) {
|
|
3134
|
+
T();
|
|
3135
|
+
return;
|
|
3136
|
+
}
|
|
3137
|
+
if (D.visible && T(), A) {
|
|
3138
|
+
c?.(Y, ne);
|
|
3139
|
+
return;
|
|
3140
|
+
}
|
|
3141
|
+
if (!Q.length) return;
|
|
3142
|
+
const j = Math.min(ne.clientX, window.innerWidth - 240), re = Math.min(ne.clientY, window.innerHeight - 200);
|
|
3143
|
+
P({ visible: !0, x: j, y: re, row: Y });
|
|
3144
|
+
}, ce = (Y, ne) => {
|
|
3145
|
+
if (ne.preventDefault(), D.visible && T(), A) {
|
|
3146
|
+
const re = ie(Y);
|
|
3147
|
+
if (re?.type === "options") {
|
|
3148
|
+
R(re);
|
|
3149
|
+
return;
|
|
3150
|
+
}
|
|
3151
|
+
b?.(Y, ne);
|
|
3152
|
+
return;
|
|
3153
|
+
}
|
|
3154
|
+
if (!Q.length) return;
|
|
3155
|
+
const me = Math.min(ne.clientX, window.innerWidth - 240), j = Math.min(ne.clientY, window.innerHeight - 200);
|
|
3156
|
+
P({ visible: !0, x: me, y: j, row: Y });
|
|
3157
|
+
}, ue = (Y, ne) => {
|
|
3158
|
+
D.visible && T(), c?.(Y, ne);
|
|
3159
|
+
}, Ce = U(
|
|
3160
|
+
(Y) => {
|
|
3161
|
+
q(ie(Y));
|
|
3162
|
+
},
|
|
3163
|
+
[ie, q]
|
|
3164
|
+
);
|
|
3165
|
+
return /* @__PURE__ */ V(
|
|
3166
|
+
"div",
|
|
3167
|
+
{
|
|
3168
|
+
className: `full-view column-left responsive-table ${L ? "table-fill-available" : ""}`.trim(),
|
|
3169
|
+
style: { position: "relative" },
|
|
3170
|
+
children: [
|
|
3171
|
+
/* @__PURE__ */ a(
|
|
3172
|
+
p,
|
|
3173
|
+
{
|
|
3174
|
+
id: e,
|
|
3175
|
+
table_name: t,
|
|
3176
|
+
addFormName: n,
|
|
3177
|
+
searchKeys: o,
|
|
3178
|
+
columns: s,
|
|
3179
|
+
initialData: l,
|
|
3180
|
+
isLoading: i,
|
|
3181
|
+
buttonName: d,
|
|
3182
|
+
onRowClick: Se,
|
|
3183
|
+
onSelectedClick: ve,
|
|
3184
|
+
onDeselect: T,
|
|
3185
|
+
onSelectionChange: Ce,
|
|
3186
|
+
onRowRightClick: ce,
|
|
3187
|
+
onEnterRow: ue,
|
|
3188
|
+
rowShortcuts: ye,
|
|
3189
|
+
includeHeader: x,
|
|
3190
|
+
conditionalRowClassName: he,
|
|
3191
|
+
renderActionButton: E,
|
|
3192
|
+
searchIcon: S,
|
|
3193
|
+
emptyState: w,
|
|
3194
|
+
noResultsState: H,
|
|
3195
|
+
searchScope: J ? Dt : M ?? e,
|
|
3196
|
+
includePageSearchbar: F || J,
|
|
3197
|
+
useGlobalSearch: J
|
|
3198
|
+
}
|
|
3199
|
+
),
|
|
3200
|
+
!A && D.visible && D.row && Q.length > 0 && /* @__PURE__ */ a(
|
|
3201
|
+
dr,
|
|
3202
|
+
{
|
|
3203
|
+
x: D.x,
|
|
3204
|
+
y: D.y,
|
|
3205
|
+
row: D.row,
|
|
3206
|
+
actions: Q,
|
|
3207
|
+
onClose: T
|
|
3208
|
+
}
|
|
3209
|
+
)
|
|
3210
|
+
]
|
|
3211
|
+
}
|
|
3212
|
+
);
|
|
3213
|
+
}
|
|
3214
|
+
const pr = { data: [], isLoading: !1, error: null, refetch: null }, gr = { archived: "all" }, br = (e) => e && typeof e.toJSON == "function" ? e.toJSON() : e, yr = (e) => e, vr = (e) => e?.id, xr = (e) => e ?? null, Nr = (e) => !!e;
|
|
3215
|
+
function kr({
|
|
3216
|
+
crud: e,
|
|
3217
|
+
permissionScope: t,
|
|
3218
|
+
formGroupName: n,
|
|
3219
|
+
setFormObject: r,
|
|
3220
|
+
setAdvancedForm: o,
|
|
3221
|
+
staticData: s,
|
|
3222
|
+
listArchivedReq: l = gr,
|
|
3223
|
+
normalizeItem: i = br,
|
|
3224
|
+
transformData: d = yr,
|
|
3225
|
+
getRowId: c = vr,
|
|
3226
|
+
disableMutations: m = !1,
|
|
3227
|
+
resolveFormGroupName: h = xr,
|
|
3228
|
+
hasForm: u = Nr
|
|
3229
|
+
}) {
|
|
3230
|
+
const g = !!t?.create, y = !!t?.edit, v = !!t?.archive, b = !!t?.unarchive, k = !!t?.listArchived, C = !!t?.delete, L = Array.isArray(s), x = h(n), N = u(x, "add") ? x : null, f = u(x, "edit") ? x : null, p = u(x, "options") ? x : null, E = oe(() => {
|
|
3231
|
+
if (k)
|
|
3232
|
+
return l;
|
|
3233
|
+
}, [k, l]), S = L || !e?.useList ? pr : e.useList(E), { data: w = [], isLoading: H = !1, error: M = null, refetch: F = null } = S, J = e?.useDelete ? e.useDelete() : null, B = e?.useArchive ? e.useArchive() : null, A = e?.useUnarchive ? e.useUnarchive() : null, O = oe(() => {
|
|
3234
|
+
const P = L ? s : w, T = Array.isArray(P) ? P.map((_) => i(_)) : [];
|
|
3235
|
+
return d(T);
|
|
3236
|
+
}, [L, w, s, i, d]), R = U(
|
|
3237
|
+
(P) => {
|
|
3238
|
+
!y || !f || (r?.(P), o?.(f, "edit", P));
|
|
3239
|
+
},
|
|
3240
|
+
[y, f, o, r]
|
|
3241
|
+
), q = U(
|
|
3242
|
+
(P) => {
|
|
3243
|
+
if (!(!p && !f)) {
|
|
3244
|
+
if (r?.(P), p) {
|
|
3245
|
+
o?.(p, "options", P);
|
|
3246
|
+
return;
|
|
3247
|
+
}
|
|
3248
|
+
o?.(f, "edit", P);
|
|
3249
|
+
}
|
|
3250
|
+
},
|
|
3251
|
+
[f, p, o, r]
|
|
3252
|
+
), I = U(
|
|
3253
|
+
(P) => {
|
|
3254
|
+
if (m) return;
|
|
3255
|
+
const T = c(P);
|
|
3256
|
+
if (T) {
|
|
3257
|
+
if (P?.archived) {
|
|
3258
|
+
if (!b) return;
|
|
3259
|
+
A?.mutate(
|
|
3260
|
+
{ pathParams: { id: T } },
|
|
3261
|
+
{ onSuccess: (_) => {
|
|
3262
|
+
je(_) || F?.();
|
|
3263
|
+
} }
|
|
3264
|
+
);
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
v && B?.mutate(
|
|
3268
|
+
{ pathParams: { id: T } },
|
|
3269
|
+
{ onSuccess: (_) => {
|
|
3270
|
+
je(_) || F?.();
|
|
3271
|
+
} }
|
|
3272
|
+
);
|
|
3273
|
+
}
|
|
3274
|
+
},
|
|
3275
|
+
[
|
|
3276
|
+
B,
|
|
3277
|
+
v,
|
|
3278
|
+
b,
|
|
3279
|
+
m,
|
|
3280
|
+
c,
|
|
3281
|
+
F,
|
|
3282
|
+
A
|
|
3283
|
+
]
|
|
3284
|
+
), D = U(
|
|
3285
|
+
(P) => {
|
|
3286
|
+
if (m || !C) return;
|
|
3287
|
+
const T = c(P);
|
|
3288
|
+
T && J?.mutate(
|
|
3289
|
+
{ pathParams: { id: T } },
|
|
3290
|
+
{ onSuccess: (_) => {
|
|
3291
|
+
je(_) || F?.();
|
|
3292
|
+
} }
|
|
3293
|
+
);
|
|
3294
|
+
},
|
|
3295
|
+
[C, J, m, c, F]
|
|
3296
|
+
);
|
|
3297
|
+
return {
|
|
3298
|
+
data: O,
|
|
3299
|
+
isLoading: H,
|
|
3300
|
+
error: M,
|
|
3301
|
+
addFormName: g ? N : null,
|
|
3302
|
+
optionFormName: p,
|
|
3303
|
+
openMobileMenu: q,
|
|
3304
|
+
onEditRow: y ? R : void 0,
|
|
3305
|
+
onToggleArchiveRow: v || b ? I : void 0,
|
|
3306
|
+
onDeleteRow: C ? D : void 0,
|
|
3307
|
+
allowArchive: v || b,
|
|
3308
|
+
allowDelete: C,
|
|
3309
|
+
permissions: {
|
|
3310
|
+
canCreate: g,
|
|
3311
|
+
canEdit: y,
|
|
3312
|
+
canArchive: v,
|
|
3313
|
+
canUnarchive: b,
|
|
3314
|
+
canListArchived: k,
|
|
3315
|
+
canDelete: C
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3319
|
+
function cs({
|
|
3320
|
+
id: e,
|
|
3321
|
+
tableName: t,
|
|
3322
|
+
crud: n,
|
|
3323
|
+
permissionScope: r,
|
|
3324
|
+
formGroupName: o,
|
|
3325
|
+
columns: s,
|
|
3326
|
+
searchKeys: l,
|
|
3327
|
+
buttonName: i = "common.actions.add",
|
|
3328
|
+
mainAction: d,
|
|
3329
|
+
desktopMenuActions: c = [],
|
|
3330
|
+
listArchivedReq: m,
|
|
3331
|
+
normalizeItem: h,
|
|
3332
|
+
transformData: u,
|
|
3333
|
+
getRowId: g,
|
|
3334
|
+
staticData: y,
|
|
3335
|
+
disableMutations: v = !1,
|
|
3336
|
+
fillAvailableHeight: b = !1,
|
|
3337
|
+
useGlobalSearch: k = !0,
|
|
3338
|
+
useEntityTableActions: C = kr,
|
|
3339
|
+
ResponsiveTableComponent: L = hr,
|
|
3340
|
+
resolveFormGroupName: x,
|
|
3341
|
+
hasForm: N,
|
|
3342
|
+
addFormName: f,
|
|
3343
|
+
optionsFormName: p,
|
|
3344
|
+
openMobileMenu: E,
|
|
3345
|
+
onEditRow: S,
|
|
3346
|
+
onToggleArchiveRow: w,
|
|
3347
|
+
onDeleteRow: H,
|
|
3348
|
+
allowArchive: M,
|
|
3349
|
+
allowDelete: F,
|
|
3350
|
+
...J
|
|
3351
|
+
}) {
|
|
3352
|
+
const { setAdvancedForm: B, setFormObject: A } = tt();
|
|
3353
|
+
if (typeof C != "function")
|
|
3354
|
+
throw new Error("EntityTable requires a useEntityTableActions hook.");
|
|
3355
|
+
const {
|
|
3356
|
+
data: O,
|
|
3357
|
+
isLoading: R,
|
|
3358
|
+
addFormName: q,
|
|
3359
|
+
optionFormName: I,
|
|
3360
|
+
openMobileMenu: D,
|
|
3361
|
+
onEditRow: P,
|
|
3362
|
+
onToggleArchiveRow: T,
|
|
3363
|
+
onDeleteRow: _,
|
|
3364
|
+
allowArchive: W,
|
|
3365
|
+
allowDelete: le
|
|
3366
|
+
} = C({
|
|
3367
|
+
crud: n,
|
|
3368
|
+
permissionScope: r,
|
|
3369
|
+
formGroupName: o,
|
|
3370
|
+
setFormObject: A,
|
|
3371
|
+
setAdvancedForm: B,
|
|
3372
|
+
staticData: y,
|
|
3373
|
+
listArchivedReq: m,
|
|
3374
|
+
normalizeItem: h,
|
|
3375
|
+
transformData: u,
|
|
3376
|
+
getRowId: g,
|
|
3377
|
+
disableMutations: v,
|
|
3378
|
+
resolveFormGroupName: x,
|
|
3379
|
+
hasForm: N
|
|
3380
|
+
});
|
|
3381
|
+
return /* @__PURE__ */ a("div", { className: "full-w column-left", children: /* @__PURE__ */ a(
|
|
3382
|
+
L,
|
|
3383
|
+
{
|
|
3384
|
+
...J,
|
|
3385
|
+
id: e,
|
|
3386
|
+
table_name: t,
|
|
3387
|
+
addFormName: f ?? q,
|
|
3388
|
+
optionsFormName: p ?? I,
|
|
3389
|
+
buttonName: i,
|
|
3390
|
+
searchKeys: l,
|
|
3391
|
+
columns: s,
|
|
3392
|
+
initialData: O,
|
|
3393
|
+
isLoading: R,
|
|
3394
|
+
openMobileMenu: E ?? D,
|
|
3395
|
+
onEditRow: S ?? P,
|
|
3396
|
+
onToggleArchiveRow: w ?? T,
|
|
3397
|
+
onDeleteRow: H ?? _,
|
|
3398
|
+
allowArchive: M ?? W,
|
|
3399
|
+
allowDelete: F ?? le,
|
|
3400
|
+
mainAction: d,
|
|
3401
|
+
desktopMenuActions: c,
|
|
3402
|
+
fillAvailableHeight: b,
|
|
3403
|
+
useGlobalSearch: k
|
|
3404
|
+
}
|
|
3405
|
+
) });
|
|
3406
|
+
}
|
|
3407
|
+
function Cr(e, t, n) {
|
|
3408
|
+
return t ?? (e.alt != null ? e.alt : e.altKey && n ? n(e.altKey) : e.altKey ?? "");
|
|
3409
|
+
}
|
|
3410
|
+
function us(e, t) {
|
|
3411
|
+
return function({ name: r, size: o, variant: s, alt: l, decorative: i = !1, translateAlt: d, ...c }) {
|
|
3412
|
+
const m = e[r];
|
|
3413
|
+
return m ? /* @__PURE__ */ a(
|
|
3414
|
+
Te,
|
|
3415
|
+
{
|
|
3416
|
+
src: m.src,
|
|
3417
|
+
size: o ?? m.size,
|
|
3418
|
+
variant: s ?? m.variant ?? t,
|
|
3419
|
+
alt: i ? "" : Cr(m, l, d),
|
|
3420
|
+
decorative: i,
|
|
3421
|
+
...c
|
|
3422
|
+
}
|
|
3423
|
+
) : null;
|
|
3424
|
+
};
|
|
3425
|
+
}
|
|
3426
|
+
const $t = "formDrafts", Pe = (e) => e != null && typeof e == "object" && !Array.isArray(e), Qe = () => {
|
|
3427
|
+
if (typeof window > "u") return {};
|
|
3428
|
+
try {
|
|
3429
|
+
const e = window.localStorage.getItem($t);
|
|
3430
|
+
if (!e) return {};
|
|
3431
|
+
const t = JSON.parse(e);
|
|
3432
|
+
return Pe(t) ? t : {};
|
|
3433
|
+
} catch {
|
|
3434
|
+
return {};
|
|
3435
|
+
}
|
|
3436
|
+
}, bt = (e) => {
|
|
3437
|
+
if (!(typeof window > "u"))
|
|
3438
|
+
try {
|
|
3439
|
+
window.localStorage.setItem($t, JSON.stringify(e));
|
|
3440
|
+
} catch {
|
|
3441
|
+
}
|
|
3442
|
+
};
|
|
3443
|
+
function ds(e, t) {
|
|
3444
|
+
const [n, r] = Z(() => {
|
|
3445
|
+
const s = typeof t == "function" ? t() : t;
|
|
3446
|
+
if (!e) return s;
|
|
3447
|
+
const i = Qe()?.[e];
|
|
3448
|
+
return !Pe(s) || !Pe(i) ? s : { ...s, ...i };
|
|
3449
|
+
});
|
|
3450
|
+
K(() => {
|
|
3451
|
+
if (!e || !Pe(n)) return;
|
|
3452
|
+
const s = Qe();
|
|
3453
|
+
bt({
|
|
3454
|
+
...s,
|
|
3455
|
+
[e]: n
|
|
3456
|
+
});
|
|
3457
|
+
}, [e, n]);
|
|
3458
|
+
const o = U(() => {
|
|
3459
|
+
if (!e) return;
|
|
3460
|
+
const s = Qe();
|
|
3461
|
+
e in s && (delete s[e], bt(s));
|
|
3462
|
+
}, [e]);
|
|
3463
|
+
return { form: n, setForm: r, clearDraft: o };
|
|
3464
|
+
}
|
|
3465
|
+
function Sr(e) {
|
|
3466
|
+
if (e == null || e === "") return null;
|
|
3467
|
+
if (typeof e != "object") return String(e);
|
|
3468
|
+
const t = e.id ?? e.value ?? e.ids?.[0] ?? null;
|
|
3469
|
+
return t == null || t === "" ? null : String(t);
|
|
3470
|
+
}
|
|
3471
|
+
function wr(e = {}) {
|
|
3472
|
+
return String(e?.type ?? "").toLowerCase() === "object";
|
|
3473
|
+
}
|
|
3474
|
+
function Er(e) {
|
|
3475
|
+
return e == null ? !1 : typeof e == "string" ? e.trim().length > 0 : !0;
|
|
3476
|
+
}
|
|
3477
|
+
function Tr(e, t, n = {}) {
|
|
3478
|
+
const r = new e(n).toJSON(), o = t?.fields ?? {};
|
|
3479
|
+
for (const [s, l] of Object.entries(o))
|
|
3480
|
+
wr(l) && (r[s] = Sr(r[s]));
|
|
3481
|
+
return r;
|
|
3482
|
+
}
|
|
3483
|
+
function fs(e, t, n = {}) {
|
|
3484
|
+
const r = {};
|
|
3485
|
+
for (const [o, s] of Object.entries(n ?? {}))
|
|
3486
|
+
Er(s) && (r[o] = s);
|
|
3487
|
+
return Tr(e, t, r);
|
|
3488
|
+
}
|
|
3489
|
+
function ms({
|
|
3490
|
+
id: e,
|
|
3491
|
+
form: t = null,
|
|
3492
|
+
title: n,
|
|
3493
|
+
iconName: r = null,
|
|
3494
|
+
picture: o = null,
|
|
3495
|
+
type: s = "short-form",
|
|
3496
|
+
...l
|
|
3497
|
+
}) {
|
|
3498
|
+
return {
|
|
3499
|
+
id: e,
|
|
3500
|
+
form: t,
|
|
3501
|
+
title: n,
|
|
3502
|
+
iconName: r,
|
|
3503
|
+
picture: o,
|
|
3504
|
+
type: s,
|
|
3505
|
+
...l
|
|
3506
|
+
};
|
|
3507
|
+
}
|
|
3508
|
+
function hs(e = {}) {
|
|
3509
|
+
return e;
|
|
3510
|
+
}
|
|
3511
|
+
function ps({
|
|
3512
|
+
id: e,
|
|
3513
|
+
form: t = null,
|
|
3514
|
+
title: n = "forms.shared.actionFormTitle",
|
|
3515
|
+
picture: r = null,
|
|
3516
|
+
type: o = "short-form",
|
|
3517
|
+
buildActions: s = null,
|
|
3518
|
+
actions: l = [],
|
|
3519
|
+
...i
|
|
3520
|
+
}) {
|
|
3521
|
+
return {
|
|
3522
|
+
id: e,
|
|
3523
|
+
form: t,
|
|
3524
|
+
title: n,
|
|
3525
|
+
picture: r,
|
|
3526
|
+
type: o,
|
|
3527
|
+
buildActions: s,
|
|
3528
|
+
actions: l,
|
|
3529
|
+
...i
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3532
|
+
function gs(e = {}) {
|
|
3533
|
+
return {
|
|
3534
|
+
forms: e,
|
|
3535
|
+
getForm: (s, l = "default") => !s || s === "none" || !l || l === "none" ? null : e?.[s]?.[l] ?? null,
|
|
3536
|
+
getFormGroup: (s) => !s || s === "none" ? null : e?.[s] ?? null,
|
|
3537
|
+
getFormID: (s, l = "default") => !s || s === "none" || !l || l === "none" ? null : e?.[s]?.[l]?.id ?? null,
|
|
3538
|
+
getFormGroupActions: (s) => !s || s === "none" ? [] : Object.keys(e?.[s] ?? {})
|
|
3539
|
+
};
|
|
3540
|
+
}
|
|
3541
|
+
export {
|
|
3542
|
+
nr as $,
|
|
3543
|
+
Rr as A,
|
|
3544
|
+
on as B,
|
|
3545
|
+
Hr as C,
|
|
3546
|
+
ts as D,
|
|
3547
|
+
It as E,
|
|
3548
|
+
Wr as F,
|
|
3549
|
+
Dt as G,
|
|
3550
|
+
Qn as H,
|
|
3551
|
+
Te as I,
|
|
3552
|
+
_n as J,
|
|
3553
|
+
Qr as K,
|
|
3554
|
+
es as L,
|
|
3555
|
+
$n as M,
|
|
3556
|
+
Be as N,
|
|
3557
|
+
At as O,
|
|
3558
|
+
ns as P,
|
|
3559
|
+
rs as Q,
|
|
3560
|
+
hr as R,
|
|
3561
|
+
Un as S,
|
|
3562
|
+
ir as T,
|
|
3563
|
+
or as U,
|
|
3564
|
+
mr as V,
|
|
3565
|
+
tr as W,
|
|
3566
|
+
sr as X,
|
|
3567
|
+
is as Y,
|
|
3568
|
+
Lt as Z,
|
|
3569
|
+
G as _,
|
|
3570
|
+
qr as a,
|
|
3571
|
+
os as a0,
|
|
3572
|
+
Zr as a1,
|
|
3573
|
+
Vr as a2,
|
|
3574
|
+
fs as a3,
|
|
3575
|
+
_r as a4,
|
|
3576
|
+
it as a5,
|
|
3577
|
+
Xr as a6,
|
|
3578
|
+
gs as a7,
|
|
3579
|
+
us as a8,
|
|
3580
|
+
Ct as a9,
|
|
3581
|
+
lt as aa,
|
|
3582
|
+
Mr as ab,
|
|
3583
|
+
ps as ac,
|
|
3584
|
+
ms as ad,
|
|
3585
|
+
hs as ae,
|
|
3586
|
+
Tr as af,
|
|
3587
|
+
sn as ag,
|
|
3588
|
+
gt as ah,
|
|
3589
|
+
kr as ai,
|
|
3590
|
+
ds as aj,
|
|
3591
|
+
rn as ak,
|
|
3592
|
+
En as al,
|
|
3593
|
+
In as am,
|
|
3594
|
+
zt as an,
|
|
3595
|
+
ar as ao,
|
|
3596
|
+
lr as ap,
|
|
3597
|
+
Yr as b,
|
|
3598
|
+
ss as c,
|
|
3599
|
+
Zt as d,
|
|
3600
|
+
cn as e,
|
|
3601
|
+
un as f,
|
|
3602
|
+
jr as g,
|
|
3603
|
+
Gr as h,
|
|
3604
|
+
Jr as i,
|
|
3605
|
+
hn as j,
|
|
3606
|
+
ls as k,
|
|
3607
|
+
cs as l,
|
|
3608
|
+
yn as m,
|
|
3609
|
+
Nn as n,
|
|
3610
|
+
dr as o,
|
|
3611
|
+
Ur as p,
|
|
3612
|
+
kn as q,
|
|
3613
|
+
Ke as r,
|
|
3614
|
+
ur as s,
|
|
3615
|
+
Yn as t,
|
|
3616
|
+
Kr as u,
|
|
3617
|
+
pn as v,
|
|
3618
|
+
wt as w,
|
|
3619
|
+
Br as x,
|
|
3620
|
+
as as y,
|
|
3621
|
+
bn as z
|
|
3622
|
+
};
|