@middag-io/react 0.51.0 → 0.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/{DateField-lPZsiWfC.js → DateField-CduB6lUv.js} +21 -23
- package/dist-lib/{DateRangeField-B7zWB48D.js → DateRangeField-DlA_9i4w.js} +17 -13
- package/dist-lib/{FormField-BGqAQLtX.js → FormField-CDdY7-md.js} +2090 -2054
- package/dist-lib/{FormPanelBlock-CGgA83Mu.js → FormPanelBlock-zo8tCgtS.js} +1 -2
- package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/EmptyStateBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/MetricCardBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts +8 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/DateField.d.ts +1 -1
- package/dist-lib/base/form/fields/DateField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/DateRangeField.d.ts +3 -1
- package/dist-lib/base/form/fields/DateRangeField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/MultiSelectField.d.ts +3 -1
- package/dist-lib/base/form/fields/MultiSelectField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/RadioField.d.ts +3 -1
- package/dist-lib/base/form/fields/RadioField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/RatingField.d.ts +3 -1
- package/dist-lib/base/form/fields/RatingField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/SliderField.d.ts +3 -1
- package/dist-lib/base/form/fields/SliderField.d.ts.map +1 -1
- package/dist-lib/base/form/fields/TagsField.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/cell-renderers.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/types.d.ts +2 -2
- package/dist-lib/base/partials/DataTable/types.d.ts.map +1 -1
- package/dist-lib/base/partials/EmptyPlaceholder/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.d.ts +12 -1
- package/dist-lib/base/shell/BasicShell.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +126 -111
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +193 -176
- package/dist-lib/base/shell/partials/InspectorContext.js +1 -1
- package/dist-lib/base/theme/tailwind-theme.css +13 -5
- package/dist-lib/base/theme/theme-bridge.css +8 -0
- package/dist-lib/base/theme/themes/classic.css +15 -11
- package/dist-lib/base/theme/tokens.css +36 -10
- package/dist-lib/base/utils/php-wire.d.ts +33 -0
- package/dist-lib/base/utils/php-wire.d.ts.map +1 -0
- package/dist-lib/base/utils/php-wire.js +19 -0
- package/dist-lib/chunks/{subpath-DjkzcIPp.js → subpath-Bb5vw3A_.js} +21 -23
- package/dist-lib/chunks/{subpath-fEhy6n_U.js → subpath-CZB5_RY7.js} +2 -0
- package/dist-lib/chunks/subpath-DVHs9lfh.js +29 -0
- package/dist-lib/contracts/block-data/data-display.d.ts +12 -287
- package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
- package/dist-lib/contracts/block-data/interactive.d.ts +14 -22
- package/dist-lib/contracts/block-data/interactive.d.ts.map +1 -1
- package/dist-lib/contracts/block-data/shared.d.ts +2 -17
- package/dist-lib/contracts/block-data/shared.d.ts.map +1 -1
- package/dist-lib/contracts/generated/index.d.ts +2 -2
- package/dist-lib/contracts/generated/schemas.d.ts +1584 -192
- package/dist-lib/contracts/generated/schemas.d.ts.map +1 -1
- package/dist-lib/contracts/generated/types.d.ts +288 -8
- package/dist-lib/contracts/generated/types.d.ts.map +1 -1
- package/dist-lib/contracts/page-contract-schema.d.ts +15 -0
- package/dist-lib/contracts/page-contract-schema.d.ts.map +1 -1
- package/dist-lib/i18n/I18nProvider.js +1 -1
- package/dist-lib/i18n/instance.js +1 -1
- package/dist-lib/i18n/locales/en/ui.json +1 -0
- package/dist-lib/i18n/locales/pt-BR/ui.json +1 -0
- package/dist-lib/i18n/register-strings.js +1 -1
- package/dist-lib/index.d.ts +2 -2
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/lib/hooks/use-prefers-reduced-motion.d.ts +6 -0
- package/dist-lib/lib/hooks/use-prefers-reduced-motion.d.ts.map +1 -0
- package/dist-lib/lib/hooks/use-prefers-reduced-motion.js +21 -0
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +10423 -10010
- package/dist-lib/primitives/reui/badge.d.ts +5 -0
- package/dist-lib/primitives/reui/badge.d.ts.map +1 -1
- package/dist-lib/primitives/reui/badge.js +14 -14
- package/dist-lib/primitives/reui/sidebar.d.ts.map +1 -1
- package/dist-lib/primitives/reui/sidebar.js +46 -34
- package/docs/public/schemas/fragment.json +1258 -19
- package/docs/public/schemas/page-contract.json +1258 -19
- package/docs/public/schemas/shared-props.json +1258 -19
- package/package.json +6 -1
- package/src/base/blocks/CardGridBlock.tsx +10 -2
- package/src/base/blocks/DenseTableBlock.tsx +45 -14
- package/src/base/blocks/DetailPanelBlock.tsx +1 -1
- package/src/base/blocks/EmptyStateBlock.tsx +5 -1
- package/src/base/blocks/FormPanelBlock.tsx +0 -1
- package/src/base/blocks/MetricCardBlock.tsx +9 -2
- package/src/base/form/FormField.tsx +40 -7
- package/src/base/form/fields/DateField.tsx +3 -3
- package/src/base/form/fields/DateRangeField.tsx +19 -14
- package/src/base/form/fields/MultiSelectField.tsx +9 -8
- package/src/base/form/fields/RadioField.tsx +4 -0
- package/src/base/form/fields/RatingField.tsx +4 -0
- package/src/base/form/fields/SliderField.tsx +4 -1
- package/src/base/form/fields/TagsField.tsx +3 -0
- package/src/base/partials/DataTable/cell-renderers.tsx +23 -12
- package/src/base/partials/DataTable/index.tsx +5 -2
- package/src/base/partials/DataTable/types.ts +2 -5
- package/src/base/partials/DetailSection/index.tsx +2 -2
- package/src/base/partials/EmptyPlaceholder/index.tsx +7 -3
- package/src/base/partials/MarkdownContent/index.tsx +1 -1
- package/src/base/shell/BasicShell.tsx +47 -8
- package/src/base/shell/partials/InspectorContext.tsx +1 -1
- package/src/base/theme/tailwind-theme.css +13 -5
- package/src/base/theme/theme-bridge.css +8 -0
- package/src/base/theme/themes/classic.css +15 -11
- package/src/base/theme/tokens.css +36 -10
- package/src/base/utils/php-wire.ts +54 -0
- package/src/contracts/block-data/data-display.ts +46 -337
- package/src/contracts/block-data/interactive.ts +18 -23
- package/src/contracts/block-data/shared.ts +2 -14
- package/src/contracts/generated/index.ts +2 -2
- package/src/contracts/generated/schemas.ts +312 -9
- package/src/contracts/generated/types.ts +314 -8
- package/src/i18n/locales/en/ui.json +1 -0
- package/src/i18n/locales/pt-BR/ui.json +1 -0
- package/src/lib/hooks/use-prefers-reduced-motion.ts +32 -0
- package/src/primitives/reui/badge.tsx +19 -14
- package/src/primitives/reui/sidebar.tsx +30 -3
- package/src/theme.css +11 -5
- package/dist-lib/chunks/subpath-DoiyWIYV.js +0 -25
|
@@ -14,19 +14,19 @@ import { Label as T } from "../../../primitives/reui/label.js";
|
|
|
14
14
|
import { Switch as E } from "../../../primitives/reui/switch.js";
|
|
15
15
|
import { InputOTP as D, InputOTPGroup as O, InputOTPSeparator as k, InputOTPSlot as A } from "../../../primitives/reui/input-otp.js";
|
|
16
16
|
import { NativeSelect as j, NativeSelectOption as M } from "../../../primitives/reui/native-select.js";
|
|
17
|
-
import { NumberField as ee, NumberFieldDecrement as N, NumberFieldGroup as
|
|
18
|
-
import { RadioGroup as
|
|
19
|
-
import { Rating as
|
|
20
|
-
import { Slider as
|
|
21
|
-
import { renderLabel as
|
|
22
|
-
import { useTranslation as
|
|
23
|
-
import { fieldTestId as
|
|
24
|
-
import { useEditablePanel as
|
|
25
|
-
import { beginPending as
|
|
26
|
-
import { evaluateCondition as
|
|
27
|
-
import { formatBytes as
|
|
28
|
-
import { Fragment as
|
|
29
|
-
import { Fragment as
|
|
17
|
+
import { NumberField as ee, NumberFieldDecrement as N, NumberFieldGroup as te, NumberFieldIncrement as P, NumberFieldInput as F } from "../../../primitives/reui/number-field.js";
|
|
18
|
+
import { RadioGroup as I, RadioGroupItem as ne } from "../../../primitives/reui/radio-group.js";
|
|
19
|
+
import { Rating as re } from "../../../primitives/reui/rating.js";
|
|
20
|
+
import { Slider as ie } from "../../../primitives/reui/slider.js";
|
|
21
|
+
import { renderLabel as ae } from "../../../i18n/render-label.js";
|
|
22
|
+
import { useTranslation as L } from "../../../i18n/useTranslation.js";
|
|
23
|
+
import { fieldTestId as oe } from "../../../lib/test-ids.js";
|
|
24
|
+
import { useEditablePanel as se } from "./EditablePanelContext.js";
|
|
25
|
+
import { beginPending as ce, trackedFetch as le } from "../../../lib/host-pending.js";
|
|
26
|
+
import { evaluateCondition as R } from "../../utils/conditions.js";
|
|
27
|
+
import { formatBytes as z, useFileUpload as ue } from "../../../lib/hooks/use-file-upload.js";
|
|
28
|
+
import { Fragment as de, Suspense as B, lazy as V, useCallback as H, useEffect as fe, useId as pe, useMemo as U, useRef as me, useState as W } from "react";
|
|
29
|
+
import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
|
|
30
30
|
import { HugeiconsIcon as J } from "@hugeicons/react";
|
|
31
31
|
import { Cancel01Icon as he, FileEmpty02Icon as ge, Upload01Icon as _e, ViewIcon as ve, ViewOffIcon as ye } from "@hugeicons/core-free-icons";
|
|
32
32
|
import { REGEXP_ONLY_DIGITS as be, REGEXP_ONLY_DIGITS_AND_CHARS as xe } from "input-otp";
|
|
@@ -40,17 +40,17 @@ function Se(e) {
|
|
|
40
40
|
function Ce(e, t) {
|
|
41
41
|
if (e.component === "header") return !0;
|
|
42
42
|
let { props: n } = e;
|
|
43
|
-
return !(n.hidden_when &&
|
|
43
|
+
return !(n.hidden_when && R(n.hidden_when, t) || n.visible_when && !R(n.visible_when, t));
|
|
44
44
|
}
|
|
45
45
|
function we(e, t) {
|
|
46
46
|
if (e.component === "header") return !1;
|
|
47
47
|
let { props: n } = e;
|
|
48
|
-
return !!(n.disabled || n.disabled_when &&
|
|
48
|
+
return !!(n.disabled || n.disabled_when && R(n.disabled_when, t));
|
|
49
49
|
}
|
|
50
50
|
function Te(e, t) {
|
|
51
51
|
if (e.component === "header" || we(e, t)) return !1;
|
|
52
52
|
let { props: n } = e;
|
|
53
|
-
return !!(n.required || n.required_when &&
|
|
53
|
+
return !!(n.required || n.required_when && R(n.required_when, t));
|
|
54
54
|
}
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/base/form/form-schema-builder.ts
|
|
@@ -150,9 +150,9 @@ function Oe({ id: e, value: t, onChange: n, label: r, disabled: i, required: a,
|
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/base/form/fields/ColorField.tsx
|
|
152
152
|
function ke({ id: e, value: t, onChange: n, placeholder: r, disabled: i, required: a, error: o, helpTextId: c, errorId: l }) {
|
|
153
|
-
let u = [o ? l : void 0, c].filter(Boolean).join(" ") || void 0, d =
|
|
153
|
+
let u = [o ? l : void 0, c].filter(Boolean).join(" ") || void 0, d = H((e) => {
|
|
154
154
|
n(e.target.value);
|
|
155
|
-
}, [n]), f =
|
|
155
|
+
}, [n]), f = H((e) => {
|
|
156
156
|
n(e.target.value);
|
|
157
157
|
}, [n]);
|
|
158
158
|
return /* @__PURE__ */ q("div", {
|
|
@@ -197,9 +197,9 @@ var Ae = {
|
|
|
197
197
|
PEN: "S/"
|
|
198
198
|
};
|
|
199
199
|
function je({ id: e, value: t, onChange: n, currency: r = "BRL", placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: p, min: m, max: h }) {
|
|
200
|
-
let { t: g, formatCurrency: _ } =
|
|
200
|
+
let { t: g, formatCurrency: _ } = L(), [v, y] = W(!1), [b, x] = W(""), S = [s ? p : void 0, c].filter(Boolean).join(" ") || void 0, C = v ? b : t == null ? "" : _(t, r), w = Ae[r] ?? r, T = H(() => {
|
|
201
201
|
y(!0), x(t == null ? "" : String(t));
|
|
202
|
-
}, [t]), E =
|
|
202
|
+
}, [t]), E = H(() => {
|
|
203
203
|
y(!1);
|
|
204
204
|
let e = parseFloat(b.replace(/,/g, "."));
|
|
205
205
|
n(Number.isNaN(e) ? null : Math.round((m !== void 0 && e < m ? m : h !== void 0 && e > h ? h : e) * 100) / 100);
|
|
@@ -208,7 +208,7 @@ function je({ id: e, value: t, onChange: n, currency: r = "BRL", placeholder: i,
|
|
|
208
208
|
n,
|
|
209
209
|
m,
|
|
210
210
|
h
|
|
211
|
-
]), D =
|
|
211
|
+
]), D = H((e) => {
|
|
212
212
|
x(e.target.value);
|
|
213
213
|
}, []);
|
|
214
214
|
return /* @__PURE__ */ q(l, {
|
|
@@ -237,19 +237,19 @@ function Me(e) {
|
|
|
237
237
|
return e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
|
|
238
238
|
}
|
|
239
239
|
function Ne({ id: e, value: t, onChange: a, options: o, initialOption: s, autocompleteHref: c, autocompleteMinChars: l = 2, entityAvatarField: u, entitySubtitleField: d, placeholder: f, disabled: y, required: b, error: x, helpTextId: S, errorId: C }) {
|
|
240
|
-
let { t: w } =
|
|
241
|
-
|
|
240
|
+
let { t: w } = L(), [T, E] = W(s && t && s.value === t ? s.label : ""), [D, O] = W([]), [k, A] = W(!1), j = me(void 0), M = !!c, ee = [x ? C : void 0, S].filter(Boolean).join(" ") || void 0, N = U(() => [], []), te = U(() => o ?? N, [o, N]);
|
|
241
|
+
fe(() => {
|
|
242
242
|
if (!M) return;
|
|
243
243
|
if (j.current && clearTimeout(j.current), T.length < l) return j.current = setTimeout(() => O([]), 0), () => {
|
|
244
244
|
j.current && clearTimeout(j.current);
|
|
245
245
|
};
|
|
246
|
-
let e =
|
|
246
|
+
let e = ce();
|
|
247
247
|
return j.current = setTimeout(async () => {
|
|
248
248
|
A(!0);
|
|
249
249
|
try {
|
|
250
250
|
let e = new URL(c, window.location.origin);
|
|
251
251
|
e.searchParams.set("q", T);
|
|
252
|
-
let t = await
|
|
252
|
+
let t = await le(e.toString());
|
|
253
253
|
if (t.ok) {
|
|
254
254
|
let e = await t.json(), n = (e.items ?? e.data ?? e).map((e) => ({
|
|
255
255
|
value: String(e.value ?? e.id),
|
|
@@ -273,25 +273,25 @@ function Ne({ id: e, value: t, onChange: a, options: o, initialOption: s, autoco
|
|
|
273
273
|
d,
|
|
274
274
|
u
|
|
275
275
|
]);
|
|
276
|
-
let
|
|
277
|
-
|
|
276
|
+
let P = M ? D : te, F = U(() => s && t && s.value === t && !P.some((e) => e.value === t) ? [s, ...P] : P, [
|
|
277
|
+
P,
|
|
278
278
|
s,
|
|
279
279
|
t
|
|
280
|
-
]),
|
|
281
|
-
if (M || !T) return
|
|
280
|
+
]), I = U(() => {
|
|
281
|
+
if (M || !T) return F;
|
|
282
282
|
let e = T.toLowerCase();
|
|
283
|
-
return
|
|
283
|
+
return F.filter((t) => t.label.toLowerCase().includes(e) || t.subtitle?.toLowerCase().includes(e));
|
|
284
284
|
}, [
|
|
285
|
-
|
|
285
|
+
F,
|
|
286
286
|
T,
|
|
287
287
|
M
|
|
288
|
-
]),
|
|
288
|
+
]), ne = H((e) => {
|
|
289
289
|
a(e ?? "");
|
|
290
|
-
}, [a]),
|
|
290
|
+
}, [a]), re = k ? w("middag.ui.form.entity_loading") : T.length < l && M ? w("middag.ui.form.entity_min_chars").replace("{min}", String(l)) : w("middag.ui.form.entity_no_results"), ie = !!u || F.some((e) => e.avatarUrl);
|
|
291
291
|
return /* @__PURE__ */ q(p, {
|
|
292
|
-
items:
|
|
292
|
+
items: I,
|
|
293
293
|
value: t || null,
|
|
294
|
-
onValueChange:
|
|
294
|
+
onValueChange: ne,
|
|
295
295
|
children: [/* @__PURE__ */ K(g, {
|
|
296
296
|
id: e,
|
|
297
297
|
placeholder: f ?? w("middag.ui.form.entity_search"),
|
|
@@ -305,11 +305,11 @@ function Ne({ id: e, value: t, onChange: a, options: o, initialOption: s, autoco
|
|
|
305
305
|
onChange: (e) => E(e.target.value)
|
|
306
306
|
}), /* @__PURE__ */ q(m, { children: [/* @__PURE__ */ K(h, {
|
|
307
307
|
className: "px-4 py-3 text-sm",
|
|
308
|
-
children:
|
|
309
|
-
}), /* @__PURE__ */ K(v, { children:
|
|
308
|
+
children: re
|
|
309
|
+
}), /* @__PURE__ */ K(v, { children: I.map((e) => /* @__PURE__ */ q(_, {
|
|
310
310
|
value: e.value,
|
|
311
311
|
className: "flex items-center gap-2.5 px-3 py-2",
|
|
312
|
-
children: [
|
|
312
|
+
children: [ie && /* @__PURE__ */ q(n, {
|
|
313
313
|
className: "h-7 w-7 shrink-0",
|
|
314
314
|
children: [e.avatarUrl && /* @__PURE__ */ K(i, {
|
|
315
315
|
src: e.avatarUrl,
|
|
@@ -333,21 +333,21 @@ function Ne({ id: e, value: t, onChange: a, options: o, initialOption: s, autoco
|
|
|
333
333
|
}
|
|
334
334
|
//#endregion
|
|
335
335
|
//#region src/base/form/fields/FileUploadField.tsx
|
|
336
|
-
function
|
|
336
|
+
function X(e) {
|
|
337
337
|
let t = e.split(/[?#]/)[0], n = t.split("/");
|
|
338
338
|
return n[n.length - 1] || t;
|
|
339
339
|
}
|
|
340
|
-
function
|
|
340
|
+
function Pe(e) {
|
|
341
341
|
if (e == null || e === "") return null;
|
|
342
342
|
if (typeof e == "string") return {
|
|
343
|
-
name:
|
|
343
|
+
name: X(e),
|
|
344
344
|
size: 0,
|
|
345
345
|
type: "",
|
|
346
346
|
url: e,
|
|
347
347
|
id: e
|
|
348
348
|
};
|
|
349
349
|
if (typeof e == "object" && !(e instanceof File)) {
|
|
350
|
-
let t = e, n = typeof t.url == "string" ? t.url : "", r = typeof t.name == "string" ? t.name : n ?
|
|
350
|
+
let t = e, n = typeof t.url == "string" ? t.url : "", r = typeof t.name == "string" ? t.name : n ? X(n) : "";
|
|
351
351
|
return !n && !r ? null : {
|
|
352
352
|
name: r,
|
|
353
353
|
size: typeof t.size == "number" ? t.size : 0,
|
|
@@ -358,11 +358,11 @@ function Fe(e) {
|
|
|
358
358
|
}
|
|
359
359
|
return null;
|
|
360
360
|
}
|
|
361
|
-
function
|
|
362
|
-
return (Array.isArray(e) ? e : [e]).map(
|
|
361
|
+
function Fe(e) {
|
|
362
|
+
return (Array.isArray(e) ? e : [e]).map(Pe).filter((e) => e !== null);
|
|
363
363
|
}
|
|
364
|
-
function
|
|
365
|
-
let { t: m } =
|
|
364
|
+
function Ie({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, maxFiles: s = 10, maxSize: c = 10 * 1024 * 1024, disabled: l, required: u, error: d, helpTextId: f, errorId: p }) {
|
|
365
|
+
let { t: m } = L(), [h] = W(() => Fe(r)), [{ files: g, isDragging: _, errors: v }, { removeFile: y, handleDragEnter: b, handleDragLeave: x, handleDragOver: S, handleDrop: C, openFileDialog: w, getInputProps: T }] = ue({
|
|
366
366
|
maxFiles: o ? s : 1,
|
|
367
367
|
maxSize: c,
|
|
368
368
|
accept: a,
|
|
@@ -411,7 +411,7 @@ function Le({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
411
411
|
children: [
|
|
412
412
|
m("middag.ui.form.file_max_size"),
|
|
413
413
|
" ",
|
|
414
|
-
|
|
414
|
+
z(c)
|
|
415
415
|
]
|
|
416
416
|
})
|
|
417
417
|
]
|
|
@@ -438,7 +438,7 @@ function Le({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
438
438
|
children: e.file.name
|
|
439
439
|
}), /* @__PURE__ */ K("p", {
|
|
440
440
|
className: "text-muted-foreground text-xs",
|
|
441
|
-
children:
|
|
441
|
+
children: z(e.file.size)
|
|
442
442
|
})]
|
|
443
443
|
}),
|
|
444
444
|
/* @__PURE__ */ K(t, {
|
|
@@ -472,49 +472,47 @@ function Le({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
472
472
|
}
|
|
473
473
|
//#endregion
|
|
474
474
|
//#region src/base/form/fields/MultiSelectField.tsx
|
|
475
|
-
var
|
|
476
|
-
function
|
|
477
|
-
let { t:
|
|
478
|
-
return
|
|
475
|
+
var Le = 8;
|
|
476
|
+
function Re({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: l, labelId: u, variant: d = "auto" }) {
|
|
477
|
+
let { t: f } = L(), p = t ?? [], m = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
478
|
+
return d === "checkbox" || d === "auto" && r.length <= Le ? /* @__PURE__ */ K(ze, {
|
|
479
479
|
id: e,
|
|
480
480
|
options: r,
|
|
481
|
-
selected:
|
|
481
|
+
selected: p,
|
|
482
482
|
onChange: n,
|
|
483
483
|
disabled: a,
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}) : /* @__PURE__ */ K(Ve, {
|
|
484
|
+
labelId: u,
|
|
485
|
+
describedBy: m,
|
|
486
|
+
t: f
|
|
487
|
+
}) : /* @__PURE__ */ K(Be, {
|
|
489
488
|
id: e,
|
|
490
489
|
options: r,
|
|
491
|
-
selected:
|
|
490
|
+
selected: p,
|
|
492
491
|
onChange: n,
|
|
493
492
|
placeholder: i,
|
|
494
493
|
disabled: a,
|
|
495
494
|
required: o,
|
|
496
495
|
error: s,
|
|
497
|
-
describedBy:
|
|
498
|
-
t:
|
|
496
|
+
describedBy: m,
|
|
497
|
+
t: f
|
|
499
498
|
});
|
|
500
499
|
}
|
|
501
|
-
function
|
|
502
|
-
let
|
|
500
|
+
function ze({ id: e, options: t, selected: n, onChange: r, disabled: i, labelId: a, describedBy: s, t: c }) {
|
|
501
|
+
let l = (e) => {
|
|
503
502
|
n.includes(e) ? r(n.filter((t) => t !== e)) : r([...n, e]);
|
|
504
503
|
};
|
|
505
504
|
return /* @__PURE__ */ q("div", {
|
|
506
505
|
id: e,
|
|
507
506
|
role: "group",
|
|
508
|
-
"aria-
|
|
509
|
-
"aria-
|
|
510
|
-
"aria-describedby": c,
|
|
507
|
+
"aria-labelledby": a,
|
|
508
|
+
"aria-describedby": s,
|
|
511
509
|
className: "border-input max-h-48 space-y-2 overflow-y-auto rounded-md border p-3",
|
|
512
510
|
children: [t.map((t) => /* @__PURE__ */ q("div", {
|
|
513
511
|
className: "flex items-center gap-2",
|
|
514
512
|
children: [/* @__PURE__ */ K(o, {
|
|
515
513
|
id: `${e}-${t.value}`,
|
|
516
514
|
checked: n.includes(t.value),
|
|
517
|
-
onCheckedChange: () =>
|
|
515
|
+
onCheckedChange: () => l(t.value),
|
|
518
516
|
disabled: i
|
|
519
517
|
}), /* @__PURE__ */ K(T, {
|
|
520
518
|
htmlFor: `${e}-${t.value}`,
|
|
@@ -523,24 +521,24 @@ function Be({ id: e, options: t, selected: n, onChange: r, disabled: i, required
|
|
|
523
521
|
})]
|
|
524
522
|
}, t.value)), t.length === 0 && /* @__PURE__ */ K("p", {
|
|
525
523
|
className: "text-muted-foreground text-sm",
|
|
526
|
-
children:
|
|
524
|
+
children: c("middag.ui.multiselect.no_options")
|
|
527
525
|
})]
|
|
528
526
|
});
|
|
529
527
|
}
|
|
530
|
-
function
|
|
531
|
-
let [f, y] =
|
|
528
|
+
function Be({ id: e, options: t, selected: n, onChange: r, placeholder: i, disabled: s, required: c, error: l, describedBy: u, t: d }) {
|
|
529
|
+
let [f, y] = W(""), b = U(() => {
|
|
532
530
|
if (!f) return t;
|
|
533
531
|
let e = f.toLowerCase();
|
|
534
532
|
return t.filter((t) => t.label.toLowerCase().includes(e));
|
|
535
|
-
}, [t, f]), x =
|
|
533
|
+
}, [t, f]), x = U(() => {
|
|
536
534
|
let e = new Map(t.map((e) => [e.value, e.label]));
|
|
537
535
|
return n.map((t) => ({
|
|
538
536
|
value: t,
|
|
539
537
|
label: e.get(t) ?? t
|
|
540
538
|
}));
|
|
541
|
-
}, [n, t]), S =
|
|
539
|
+
}, [n, t]), S = H((e) => {
|
|
542
540
|
r(n.filter((t) => t !== e));
|
|
543
|
-
}, [n, r]), C =
|
|
541
|
+
}, [n, r]), C = H((e) => {
|
|
544
542
|
e && (n.includes(e) ? r(n.filter((t) => t !== e)) : r([...n, e]));
|
|
545
543
|
}, [n, r]);
|
|
546
544
|
return /* @__PURE__ */ q("div", {
|
|
@@ -610,8 +608,8 @@ function Ve({ id: e, options: t, selected: n, onChange: r, placeholder: i, disab
|
|
|
610
608
|
}
|
|
611
609
|
//#endregion
|
|
612
610
|
//#region src/base/form/fields/NativeSelectField.tsx
|
|
613
|
-
function
|
|
614
|
-
let { t: u } =
|
|
611
|
+
function Ve({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: l }) {
|
|
612
|
+
let { t: u } = L(), d = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
615
613
|
return /* @__PURE__ */ K("div", {
|
|
616
614
|
className: "w-full [&>div]:w-full",
|
|
617
615
|
children: /* @__PURE__ */ q(j, {
|
|
@@ -636,7 +634,7 @@ function He({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
636
634
|
}
|
|
637
635
|
//#endregion
|
|
638
636
|
//#region src/base/form/fields/NumberField.tsx
|
|
639
|
-
function
|
|
637
|
+
function He({ id: e, value: t, onChange: n, min: r, max: i, step: a = 1, disabled: o, required: s, error: c, helpTextId: l, errorId: u }) {
|
|
640
638
|
let d = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0;
|
|
641
639
|
return /* @__PURE__ */ K(ee, {
|
|
642
640
|
id: e,
|
|
@@ -649,10 +647,10 @@ function X({ id: e, value: t, onChange: n, min: r, max: i, step: a = 1, disabled
|
|
|
649
647
|
"aria-invalid": c ? !0 : void 0,
|
|
650
648
|
"aria-required": s || void 0,
|
|
651
649
|
"aria-describedby": d,
|
|
652
|
-
children: /* @__PURE__ */ q(
|
|
650
|
+
children: /* @__PURE__ */ q(te, { children: [
|
|
653
651
|
/* @__PURE__ */ K(N, {}),
|
|
654
|
-
/* @__PURE__ */ K(
|
|
655
|
-
/* @__PURE__ */ K(
|
|
652
|
+
/* @__PURE__ */ K(F, {}),
|
|
653
|
+
/* @__PURE__ */ K(P, {})
|
|
656
654
|
] })
|
|
657
655
|
});
|
|
658
656
|
}
|
|
@@ -676,7 +674,7 @@ function We({ id: e, value: t, onChange: n, maxLength: r = 6, pattern: i = "digi
|
|
|
676
674
|
"aria-invalid": c ? !0 : void 0,
|
|
677
675
|
"aria-required": s || void 0,
|
|
678
676
|
"aria-describedby": d,
|
|
679
|
-
children: p.map((e, t) => /* @__PURE__ */ q(
|
|
677
|
+
children: p.map((e, t) => /* @__PURE__ */ q(de, { children: [/* @__PURE__ */ K(O, { children: e.map((e) => /* @__PURE__ */ K(A, {
|
|
680
678
|
index: e,
|
|
681
679
|
"aria-invalid": c ? !0 : void 0
|
|
682
680
|
}, e)) }), t < p.length - 1 && /* @__PURE__ */ K(k, {})] }, e[0]))
|
|
@@ -685,7 +683,7 @@ function We({ id: e, value: t, onChange: n, maxLength: r = 6, pattern: i = "digi
|
|
|
685
683
|
//#endregion
|
|
686
684
|
//#region src/base/form/fields/PasswordField.tsx
|
|
687
685
|
function Ge({ id: e, value: n, onChange: r, placeholder: i, disabled: a, required: o, error: c, helpTextId: l, errorId: u }) {
|
|
688
|
-
let [d, f] =
|
|
686
|
+
let [d, f] = W(!1), p = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0;
|
|
689
687
|
return /* @__PURE__ */ q("div", {
|
|
690
688
|
className: "relative",
|
|
691
689
|
children: [/* @__PURE__ */ K(s, {
|
|
@@ -717,21 +715,22 @@ function Ge({ id: e, value: n, onChange: r, placeholder: i, disabled: a, require
|
|
|
717
715
|
}
|
|
718
716
|
//#endregion
|
|
719
717
|
//#region src/base/form/fields/RadioField.tsx
|
|
720
|
-
function Ke({ id: e, value: t, onChange: n, options: r, disabled: i, required: a, error: o, helpTextId: s, errorId: c }) {
|
|
721
|
-
let
|
|
722
|
-
return /* @__PURE__ */ K(
|
|
718
|
+
function Ke({ id: e, value: t, onChange: n, options: r, disabled: i, required: a, error: o, helpTextId: s, errorId: c, labelId: l }) {
|
|
719
|
+
let u = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0;
|
|
720
|
+
return /* @__PURE__ */ K(I, {
|
|
723
721
|
id: e,
|
|
724
722
|
value: t ?? "",
|
|
725
723
|
onValueChange: n,
|
|
726
724
|
disabled: i,
|
|
727
725
|
"aria-invalid": o ? !0 : void 0,
|
|
728
726
|
"aria-required": a || void 0,
|
|
729
|
-
"aria-
|
|
727
|
+
"aria-labelledby": l,
|
|
728
|
+
"aria-describedby": u,
|
|
730
729
|
children: r.map((t) => {
|
|
731
730
|
let n = `${e}-${t.value}`;
|
|
732
731
|
return /* @__PURE__ */ q("div", {
|
|
733
732
|
className: "flex items-center gap-2",
|
|
734
|
-
children: [/* @__PURE__ */ K(
|
|
733
|
+
children: [/* @__PURE__ */ K(ne, {
|
|
735
734
|
value: t.value,
|
|
736
735
|
id: n
|
|
737
736
|
}), /* @__PURE__ */ K(T, {
|
|
@@ -745,15 +744,16 @@ function Ke({ id: e, value: t, onChange: n, options: r, disabled: i, required: a
|
|
|
745
744
|
}
|
|
746
745
|
//#endregion
|
|
747
746
|
//#region src/base/form/fields/RatingField.tsx
|
|
748
|
-
function qe({ id: e, value: t, onChange: n, maxRating: r = 5, disabled: i, required: a, error: o, helpTextId: s, errorId: c }) {
|
|
749
|
-
let
|
|
747
|
+
function qe({ id: e, value: t, onChange: n, maxRating: r = 5, disabled: i, required: a, error: o, helpTextId: s, errorId: c, labelId: l }) {
|
|
748
|
+
let u = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0;
|
|
750
749
|
return /* @__PURE__ */ K("div", {
|
|
751
750
|
id: e,
|
|
752
751
|
role: "radiogroup",
|
|
752
|
+
"aria-labelledby": l,
|
|
753
753
|
"aria-required": a || void 0,
|
|
754
754
|
"aria-invalid": o ? !0 : void 0,
|
|
755
|
-
"aria-describedby":
|
|
756
|
-
children: /* @__PURE__ */ K(
|
|
755
|
+
"aria-describedby": u,
|
|
756
|
+
children: /* @__PURE__ */ K(re, {
|
|
757
757
|
rating: t ?? 0,
|
|
758
758
|
maxRating: r,
|
|
759
759
|
editable: !i,
|
|
@@ -765,7 +765,7 @@ function qe({ id: e, value: t, onChange: n, maxRating: r = 5, disabled: i, requi
|
|
|
765
765
|
//#endregion
|
|
766
766
|
//#region src/base/form/fields/SelectField.tsx
|
|
767
767
|
function Je({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: l }) {
|
|
768
|
-
let { t: u } =
|
|
768
|
+
let { t: u } = L(), d = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
769
769
|
return /* @__PURE__ */ q(y, {
|
|
770
770
|
value: t ?? "",
|
|
771
771
|
onValueChange: n,
|
|
@@ -792,13 +792,15 @@ function Je({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
792
792
|
}
|
|
793
793
|
//#endregion
|
|
794
794
|
//#region src/base/form/fields/SliderField.tsx
|
|
795
|
-
function Ye({ id: e, value: t, onChange: n, min: r = 0, max: i = 100, step: a = 1, multiple: o = !1, disabled: s, required: c, error: l, helpTextId: u, errorId: d }) {
|
|
796
|
-
let
|
|
795
|
+
function Ye({ id: e, value: t, onChange: n, min: r = 0, max: i = 100, step: a = 1, multiple: o = !1, disabled: s, required: c, error: l, helpTextId: u, errorId: d, labelId: f }) {
|
|
796
|
+
let p = [l ? d : void 0, u].filter(Boolean).join(" ") || void 0, m = Array.isArray(t) ? t : t == null ? o ? [r, i] : [r] : [t], h = o ? m.join(" – ") : String(m[0] ?? r);
|
|
797
797
|
return /* @__PURE__ */ q("div", {
|
|
798
|
+
role: "group",
|
|
799
|
+
"aria-labelledby": f,
|
|
798
800
|
className: "flex items-center gap-4",
|
|
799
|
-
children: [/* @__PURE__ */ K(
|
|
801
|
+
children: [/* @__PURE__ */ K(ie, {
|
|
800
802
|
id: e,
|
|
801
|
-
value:
|
|
803
|
+
value: m,
|
|
802
804
|
min: r,
|
|
803
805
|
max: i,
|
|
804
806
|
step: a,
|
|
@@ -806,11 +808,11 @@ function Ye({ id: e, value: t, onChange: n, min: r = 0, max: i = 100, step: a =
|
|
|
806
808
|
onValueChange: (e) => n(o ? e : e[0] ?? r),
|
|
807
809
|
"aria-invalid": l ? !0 : void 0,
|
|
808
810
|
"aria-required": c || void 0,
|
|
809
|
-
"aria-describedby":
|
|
811
|
+
"aria-describedby": p
|
|
810
812
|
}), /* @__PURE__ */ K("span", {
|
|
811
813
|
"aria-hidden": "true",
|
|
812
814
|
className: "text-muted-foreground min-w-12 text-right text-sm tabular-nums",
|
|
813
|
-
children:
|
|
815
|
+
children: h
|
|
814
816
|
})]
|
|
815
817
|
});
|
|
816
818
|
}
|
|
@@ -820,8 +822,8 @@ function Xe(e) {
|
|
|
820
822
|
return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
|
|
821
823
|
}
|
|
822
824
|
function Ze({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: p, prefix: m }) {
|
|
823
|
-
let [h, g] =
|
|
824
|
-
|
|
825
|
+
let [h, g] = W(!1), _ = [s ? p : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
826
|
+
fe(() => {
|
|
825
827
|
if (!h && r !== void 0) {
|
|
826
828
|
let e = Xe(r);
|
|
827
829
|
e !== t && n(e);
|
|
@@ -832,7 +834,7 @@ function Ze({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disa
|
|
|
832
834
|
n,
|
|
833
835
|
t
|
|
834
836
|
]);
|
|
835
|
-
let v =
|
|
837
|
+
let v = H((e) => {
|
|
836
838
|
g(!0), n(Xe(e.target.value));
|
|
837
839
|
}, [n]);
|
|
838
840
|
return m ? /* @__PURE__ */ q(l, {
|
|
@@ -899,16 +901,16 @@ function $e({ id: e, value: t, onChange: n, label: r, disabled: i, required: a,
|
|
|
899
901
|
//#endregion
|
|
900
902
|
//#region src/base/form/fields/TagsField.tsx
|
|
901
903
|
function et({ id: e, value: t, onChange: n, placeholder: r, disabled: i, required: a, error: o, helpTextId: s, errorId: c, maxTags: l }) {
|
|
902
|
-
let { t: u } =
|
|
904
|
+
let { t: u } = L(), [d, f] = W(""), p = me(null), m = U(() => t ?? [], [t]), h = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0, g = H((e) => {
|
|
903
905
|
let t = e.trim();
|
|
904
906
|
t && (m.includes(t) || l && m.length >= l || (n([...m, t]), f("")));
|
|
905
907
|
}, [
|
|
906
908
|
m,
|
|
907
909
|
n,
|
|
908
910
|
l
|
|
909
|
-
]), _ =
|
|
911
|
+
]), _ = H((e) => {
|
|
910
912
|
n(m.filter((t, n) => n !== e));
|
|
911
|
-
}, [m, n]), v =
|
|
913
|
+
}, [m, n]), v = H((e) => {
|
|
912
914
|
e.key === "Enter" || e.key === "," ? (e.preventDefault(), g(d)) : e.key === "Backspace" && !d && m.length > 0 && _(m.length - 1);
|
|
913
915
|
}, [
|
|
914
916
|
d,
|
|
@@ -918,6 +920,7 @@ function et({ id: e, value: t, onChange: n, placeholder: r, disabled: i, require
|
|
|
918
920
|
]);
|
|
919
921
|
return /* @__PURE__ */ q("div", {
|
|
920
922
|
className: `focus-within:ring-ring flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-md border px-2 py-1.5 text-sm transition-colors focus-within:ring-1 ${o ? "border-destructive" : "border-input"} ${i ? "opacity-50" : ""}`,
|
|
923
|
+
role: "presentation",
|
|
921
924
|
onClick: () => p.current?.focus(),
|
|
922
925
|
children: [m.map((e, t) => /* @__PURE__ */ q("span", {
|
|
923
926
|
className: "bg-secondary text-secondary-foreground inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",
|
|
@@ -989,51 +992,60 @@ function rt(e) {
|
|
|
989
992
|
}
|
|
990
993
|
//#endregion
|
|
991
994
|
//#region src/base/form/FormField.tsx
|
|
992
|
-
var it =
|
|
995
|
+
var it = V(() => import("../../../chunks/subpath-CJyJeTlw.js").then((e) => ({ default: e.PhoneField }))), at = V(() => import("../../../chunks/subpath-Bb5vw3A_.js").then((e) => ({ default: e.DateField }))), ot = V(() => import("../../../chunks/subpath-BYl-9lKg.js").then((e) => ({ default: e.DocumentField }))), st = V(() => import("../../../chunks/subpath-DVHs9lfh.js").then((e) => ({ default: e.DateRangeField })));
|
|
993
996
|
function Q() {
|
|
994
997
|
return /* @__PURE__ */ K(w, { className: "h-9 w-full rounded-md" });
|
|
995
998
|
}
|
|
996
|
-
|
|
999
|
+
var ct = 4;
|
|
1000
|
+
function lt({ label: e, level: t }) {
|
|
997
1001
|
return /* @__PURE__ */ K("div", {
|
|
998
1002
|
className: "pt-4 pb-1",
|
|
999
|
-
children: /* @__PURE__ */ K(
|
|
1003
|
+
children: /* @__PURE__ */ K(`h${t}`, {
|
|
1000
1004
|
className: "text-foreground text-sm font-semibold",
|
|
1001
1005
|
children: e
|
|
1002
1006
|
})
|
|
1003
1007
|
});
|
|
1004
1008
|
}
|
|
1005
|
-
function
|
|
1009
|
+
function ut({ id: e, value: t }) {
|
|
1006
1010
|
return /* @__PURE__ */ K("input", {
|
|
1007
1011
|
type: "hidden",
|
|
1008
1012
|
id: e,
|
|
1009
1013
|
value: String(t ?? "")
|
|
1010
1014
|
});
|
|
1011
1015
|
}
|
|
1012
|
-
function
|
|
1013
|
-
let { t:
|
|
1014
|
-
if (
|
|
1015
|
-
|
|
1016
|
-
|
|
1016
|
+
function dt({ field: e, value: t, onChange: n, error: r, sourceValues: i = {}, headingLevel: a = ct }) {
|
|
1017
|
+
let { t: o } = L(), s = pe(), c = `field-${e.key}-${s}`, l = `${c}-error`, u = `${c}-label`, { component: d, props: f } = e;
|
|
1018
|
+
if (d === "header") return /* @__PURE__ */ K(lt, {
|
|
1019
|
+
label: f.label,
|
|
1020
|
+
level: a
|
|
1021
|
+
});
|
|
1022
|
+
if (d === "hidden") return /* @__PURE__ */ K(ut, {
|
|
1023
|
+
id: c,
|
|
1017
1024
|
value: t
|
|
1018
1025
|
});
|
|
1019
|
-
let f = we(e, i),
|
|
1026
|
+
let p = f.helpText ? `${c}-help` : void 0, m = we(e, i), h = Te(e, i), g = d === "checkbox" || d === "switch", _ = ft(d, c, t, n, f, r, p, l, u, o, i, m, h);
|
|
1020
1027
|
return /* @__PURE__ */ q("div", {
|
|
1021
1028
|
className: "space-y-1.5",
|
|
1022
|
-
"data-testid":
|
|
1029
|
+
"data-testid": oe(e.key),
|
|
1023
1030
|
children: [
|
|
1024
|
-
!
|
|
1025
|
-
|
|
1026
|
-
|
|
1031
|
+
!g && /* @__PURE__ */ q(T, {
|
|
1032
|
+
id: u,
|
|
1033
|
+
htmlFor: c,
|
|
1034
|
+
children: [f.label, h && /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("span", {
|
|
1027
1035
|
className: "text-destructive ml-0.5",
|
|
1036
|
+
"aria-hidden": "true",
|
|
1028
1037
|
children: "*"
|
|
1029
|
-
})
|
|
1038
|
+
}), /* @__PURE__ */ K("span", {
|
|
1039
|
+
className: "sr-only",
|
|
1040
|
+
children: ` ${o("middag.ui.form.required_hint")}`
|
|
1041
|
+
})] })]
|
|
1030
1042
|
}),
|
|
1031
|
-
|
|
1032
|
-
id:
|
|
1043
|
+
f.helpText && /* @__PURE__ */ K("p", {
|
|
1044
|
+
id: p,
|
|
1033
1045
|
className: "text-muted-foreground text-xs",
|
|
1034
|
-
children:
|
|
1046
|
+
children: f.helpText
|
|
1035
1047
|
}),
|
|
1036
|
-
|
|
1048
|
+
_,
|
|
1037
1049
|
r && /* @__PURE__ */ K("p", {
|
|
1038
1050
|
id: l,
|
|
1039
1051
|
className: "text-destructive text-xs",
|
|
@@ -1043,18 +1055,18 @@ function ut({ field: e, value: t, onChange: n, error: r, sourceValues: i = {} })
|
|
|
1043
1055
|
]
|
|
1044
1056
|
});
|
|
1045
1057
|
}
|
|
1046
|
-
function
|
|
1047
|
-
let
|
|
1058
|
+
function ft(e, t, n, r, i, a, o, s, c, l, u, d, f) {
|
|
1059
|
+
let p = {
|
|
1048
1060
|
id: t,
|
|
1049
1061
|
error: a,
|
|
1050
1062
|
helpTextId: o,
|
|
1051
1063
|
errorId: s,
|
|
1052
|
-
disabled:
|
|
1053
|
-
required:
|
|
1064
|
+
disabled: d,
|
|
1065
|
+
required: f
|
|
1054
1066
|
};
|
|
1055
1067
|
switch (e) {
|
|
1056
1068
|
case "text": return /* @__PURE__ */ K(Z, {
|
|
1057
|
-
...
|
|
1069
|
+
...p,
|
|
1058
1070
|
type: "text",
|
|
1059
1071
|
value: n,
|
|
1060
1072
|
onChange: r,
|
|
@@ -1062,7 +1074,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1062
1074
|
readOnly: i.readOnly
|
|
1063
1075
|
});
|
|
1064
1076
|
case "email": return /* @__PURE__ */ K(Z, {
|
|
1065
|
-
...
|
|
1077
|
+
...p,
|
|
1066
1078
|
type: "email",
|
|
1067
1079
|
value: n,
|
|
1068
1080
|
onChange: r,
|
|
@@ -1070,7 +1082,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1070
1082
|
readOnly: i.readOnly
|
|
1071
1083
|
});
|
|
1072
1084
|
case "url": return /* @__PURE__ */ K(Z, {
|
|
1073
|
-
...
|
|
1085
|
+
...p,
|
|
1074
1086
|
type: "url",
|
|
1075
1087
|
value: n,
|
|
1076
1088
|
onChange: r,
|
|
@@ -1078,7 +1090,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1078
1090
|
readOnly: i.readOnly
|
|
1079
1091
|
});
|
|
1080
1092
|
case "textarea": return /* @__PURE__ */ K(tt, {
|
|
1081
|
-
...
|
|
1093
|
+
...p,
|
|
1082
1094
|
value: n,
|
|
1083
1095
|
onChange: r,
|
|
1084
1096
|
placeholder: i.placeholder,
|
|
@@ -1086,13 +1098,13 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1086
1098
|
readOnly: i.readOnly
|
|
1087
1099
|
});
|
|
1088
1100
|
case "password": return /* @__PURE__ */ K(Ge, {
|
|
1089
|
-
...
|
|
1101
|
+
...p,
|
|
1090
1102
|
value: n,
|
|
1091
1103
|
onChange: r,
|
|
1092
1104
|
placeholder: i.placeholder
|
|
1093
1105
|
});
|
|
1094
1106
|
case "otp": return /* @__PURE__ */ K(We, {
|
|
1095
|
-
...
|
|
1107
|
+
...p,
|
|
1096
1108
|
value: n,
|
|
1097
1109
|
onChange: r,
|
|
1098
1110
|
maxLength: i.maxLength,
|
|
@@ -1100,21 +1112,22 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1100
1112
|
groupSize: i.groupSize
|
|
1101
1113
|
});
|
|
1102
1114
|
case "select": return /* @__PURE__ */ K(Je, {
|
|
1103
|
-
...
|
|
1115
|
+
...p,
|
|
1104
1116
|
value: n,
|
|
1105
1117
|
onChange: r,
|
|
1106
1118
|
options: i.options ?? [],
|
|
1107
1119
|
placeholder: i.placeholder
|
|
1108
1120
|
});
|
|
1109
|
-
case "native_select": return /* @__PURE__ */ K(
|
|
1110
|
-
...
|
|
1121
|
+
case "native_select": return /* @__PURE__ */ K(Ve, {
|
|
1122
|
+
...p,
|
|
1111
1123
|
value: n,
|
|
1112
1124
|
onChange: r,
|
|
1113
1125
|
options: i.options ?? [],
|
|
1114
1126
|
placeholder: i.placeholder
|
|
1115
1127
|
});
|
|
1116
|
-
case "multiselect": return /* @__PURE__ */ K(
|
|
1117
|
-
...
|
|
1128
|
+
case "multiselect": return /* @__PURE__ */ K(Re, {
|
|
1129
|
+
...p,
|
|
1130
|
+
labelId: c,
|
|
1118
1131
|
value: n,
|
|
1119
1132
|
onChange: r,
|
|
1120
1133
|
options: i.options ?? [],
|
|
@@ -1122,21 +1135,22 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1122
1135
|
variant: i.variant
|
|
1123
1136
|
});
|
|
1124
1137
|
case "radio": return /* @__PURE__ */ K(Ke, {
|
|
1125
|
-
...
|
|
1138
|
+
...p,
|
|
1139
|
+
labelId: c,
|
|
1126
1140
|
value: n,
|
|
1127
1141
|
onChange: r,
|
|
1128
1142
|
options: i.options ?? []
|
|
1129
1143
|
});
|
|
1130
|
-
case "int": return /* @__PURE__ */ K(
|
|
1131
|
-
...
|
|
1144
|
+
case "int": return /* @__PURE__ */ K(He, {
|
|
1145
|
+
...p,
|
|
1132
1146
|
value: n,
|
|
1133
1147
|
onChange: r,
|
|
1134
1148
|
min: i.min,
|
|
1135
1149
|
max: i.max,
|
|
1136
1150
|
step: 1
|
|
1137
1151
|
});
|
|
1138
|
-
case "float": return /* @__PURE__ */ K(
|
|
1139
|
-
...
|
|
1152
|
+
case "float": return /* @__PURE__ */ K(He, {
|
|
1153
|
+
...p,
|
|
1140
1154
|
value: n,
|
|
1141
1155
|
onChange: r,
|
|
1142
1156
|
min: i.min,
|
|
@@ -1144,7 +1158,8 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1144
1158
|
step: i.step ?? .1
|
|
1145
1159
|
});
|
|
1146
1160
|
case "slider": return /* @__PURE__ */ K(Ye, {
|
|
1147
|
-
...
|
|
1161
|
+
...p,
|
|
1162
|
+
labelId: c,
|
|
1148
1163
|
value: n,
|
|
1149
1164
|
onChange: r,
|
|
1150
1165
|
min: i.min,
|
|
@@ -1153,39 +1168,39 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1153
1168
|
multiple: i.multiple
|
|
1154
1169
|
});
|
|
1155
1170
|
case "checkbox": return /* @__PURE__ */ K(Oe, {
|
|
1156
|
-
...
|
|
1171
|
+
...p,
|
|
1157
1172
|
value: n,
|
|
1158
1173
|
onChange: r,
|
|
1159
1174
|
label: i.label
|
|
1160
1175
|
});
|
|
1161
1176
|
case "switch": return /* @__PURE__ */ K($e, {
|
|
1162
|
-
...
|
|
1177
|
+
...p,
|
|
1163
1178
|
value: n,
|
|
1164
1179
|
onChange: r,
|
|
1165
1180
|
label: i.label
|
|
1166
1181
|
});
|
|
1167
|
-
case "date": return /* @__PURE__ */ K(
|
|
1182
|
+
case "date": return /* @__PURE__ */ K(B, {
|
|
1168
1183
|
fallback: /* @__PURE__ */ K(Q, {}),
|
|
1169
1184
|
children: /* @__PURE__ */ K(at, {
|
|
1170
|
-
...
|
|
1185
|
+
...p,
|
|
1171
1186
|
mode: "date",
|
|
1172
1187
|
value: n,
|
|
1173
1188
|
onChange: r,
|
|
1174
1189
|
placeholder: i.placeholder
|
|
1175
1190
|
})
|
|
1176
1191
|
});
|
|
1177
|
-
case "datetime": return /* @__PURE__ */ K(
|
|
1192
|
+
case "datetime": return /* @__PURE__ */ K(B, {
|
|
1178
1193
|
fallback: /* @__PURE__ */ K(Q, {}),
|
|
1179
1194
|
children: /* @__PURE__ */ K(at, {
|
|
1180
|
-
...
|
|
1195
|
+
...p,
|
|
1181
1196
|
mode: "datetime",
|
|
1182
1197
|
value: n,
|
|
1183
1198
|
onChange: r,
|
|
1184
1199
|
placeholder: i.placeholder
|
|
1185
1200
|
})
|
|
1186
1201
|
});
|
|
1187
|
-
case "file": return /* @__PURE__ */ K(
|
|
1188
|
-
...
|
|
1202
|
+
case "file": return /* @__PURE__ */ K(Ie, {
|
|
1203
|
+
...p,
|
|
1189
1204
|
value: n,
|
|
1190
1205
|
onChange: r,
|
|
1191
1206
|
accept: i.accept,
|
|
@@ -1194,7 +1209,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1194
1209
|
maxSize: i.maxSize
|
|
1195
1210
|
});
|
|
1196
1211
|
case "entity_picker": return /* @__PURE__ */ K(Ne, {
|
|
1197
|
-
...
|
|
1212
|
+
...p,
|
|
1198
1213
|
value: n,
|
|
1199
1214
|
onChange: r,
|
|
1200
1215
|
options: i.options,
|
|
@@ -1209,10 +1224,10 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1209
1224
|
id: t,
|
|
1210
1225
|
value: n
|
|
1211
1226
|
});
|
|
1212
|
-
case "phone": return /* @__PURE__ */ K(
|
|
1227
|
+
case "phone": return /* @__PURE__ */ K(B, {
|
|
1213
1228
|
fallback: /* @__PURE__ */ K(Q, {}),
|
|
1214
1229
|
children: /* @__PURE__ */ K(it, {
|
|
1215
|
-
...
|
|
1230
|
+
...p,
|
|
1216
1231
|
value: n,
|
|
1217
1232
|
onChange: r,
|
|
1218
1233
|
placeholder: i.placeholder,
|
|
@@ -1220,10 +1235,10 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1220
1235
|
fixedCountry: i.fixedCountry
|
|
1221
1236
|
})
|
|
1222
1237
|
});
|
|
1223
|
-
case "document": return /* @__PURE__ */ K(
|
|
1238
|
+
case "document": return /* @__PURE__ */ K(B, {
|
|
1224
1239
|
fallback: /* @__PURE__ */ K(Q, {}),
|
|
1225
1240
|
children: /* @__PURE__ */ K(ot, {
|
|
1226
|
-
...
|
|
1241
|
+
...p,
|
|
1227
1242
|
value: n,
|
|
1228
1243
|
onChange: r,
|
|
1229
1244
|
documentType: i.documentType,
|
|
@@ -1233,7 +1248,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1233
1248
|
})
|
|
1234
1249
|
});
|
|
1235
1250
|
case "currency": return /* @__PURE__ */ K(je, {
|
|
1236
|
-
...
|
|
1251
|
+
...p,
|
|
1237
1252
|
value: n,
|
|
1238
1253
|
onChange: r,
|
|
1239
1254
|
currency: i.currency,
|
|
@@ -1242,37 +1257,39 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1242
1257
|
max: i.max
|
|
1243
1258
|
});
|
|
1244
1259
|
case "color": return /* @__PURE__ */ K(ke, {
|
|
1245
|
-
...
|
|
1260
|
+
...p,
|
|
1246
1261
|
value: n,
|
|
1247
1262
|
onChange: r,
|
|
1248
1263
|
placeholder: i.placeholder
|
|
1249
1264
|
});
|
|
1250
1265
|
case "slug": return /* @__PURE__ */ K(Ze, {
|
|
1251
|
-
...
|
|
1266
|
+
...p,
|
|
1252
1267
|
value: n,
|
|
1253
1268
|
onChange: r,
|
|
1254
|
-
sourceValue: i.sourceField === void 0 ? void 0 : String(
|
|
1269
|
+
sourceValue: i.sourceField === void 0 ? void 0 : String(u[i.sourceField] ?? ""),
|
|
1255
1270
|
prefix: i.prefix,
|
|
1256
1271
|
placeholder: i.placeholder
|
|
1257
1272
|
});
|
|
1258
1273
|
case "tags": return /* @__PURE__ */ K(et, {
|
|
1259
|
-
...
|
|
1274
|
+
...p,
|
|
1260
1275
|
value: n,
|
|
1261
1276
|
onChange: r,
|
|
1262
1277
|
placeholder: i.placeholder,
|
|
1263
1278
|
maxTags: i.maxTags
|
|
1264
1279
|
});
|
|
1265
|
-
case "date_range": return /* @__PURE__ */ K(
|
|
1280
|
+
case "date_range": return /* @__PURE__ */ K(B, {
|
|
1266
1281
|
fallback: /* @__PURE__ */ K(Q, {}),
|
|
1267
1282
|
children: /* @__PURE__ */ K(st, {
|
|
1268
|
-
...
|
|
1283
|
+
...p,
|
|
1284
|
+
labelId: c,
|
|
1269
1285
|
value: n,
|
|
1270
1286
|
onChange: r,
|
|
1271
1287
|
operator: i.operator
|
|
1272
1288
|
})
|
|
1273
1289
|
});
|
|
1274
1290
|
case "rating": return /* @__PURE__ */ K(qe, {
|
|
1275
|
-
...
|
|
1291
|
+
...p,
|
|
1292
|
+
labelId: c,
|
|
1276
1293
|
value: n,
|
|
1277
1294
|
onChange: r,
|
|
1278
1295
|
maxRating: i.maxRating
|
|
@@ -1280,7 +1297,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1280
1297
|
default: {
|
|
1281
1298
|
let t = rt(e);
|
|
1282
1299
|
return t ? /* @__PURE__ */ K(t, {
|
|
1283
|
-
...
|
|
1300
|
+
...p,
|
|
1284
1301
|
value: n,
|
|
1285
1302
|
onChange: r,
|
|
1286
1303
|
fieldProps: i
|
|
@@ -1293,7 +1310,7 @@ function dt(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1293
1310
|
}
|
|
1294
1311
|
//#endregion
|
|
1295
1312
|
//#region src/base/shell/partials/InlineEditablePanel.tsx
|
|
1296
|
-
function
|
|
1313
|
+
function pt(e) {
|
|
1297
1314
|
switch (e.component) {
|
|
1298
1315
|
case "int":
|
|
1299
1316
|
case "float":
|
|
@@ -1307,15 +1324,15 @@ function ft(e) {
|
|
|
1307
1324
|
default: return "";
|
|
1308
1325
|
}
|
|
1309
1326
|
}
|
|
1310
|
-
function
|
|
1311
|
-
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] :
|
|
1327
|
+
function mt(e, t) {
|
|
1328
|
+
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : pt(e);
|
|
1312
1329
|
}
|
|
1313
1330
|
function $(t, n, r, i, a) {
|
|
1314
1331
|
return t.map((t, o) => {
|
|
1315
1332
|
switch (t.kind) {
|
|
1316
|
-
case "field": return Ce(t, n) ? /* @__PURE__ */ K(
|
|
1333
|
+
case "field": return Ce(t, n) ? /* @__PURE__ */ K(dt, {
|
|
1317
1334
|
field: t,
|
|
1318
|
-
value:
|
|
1335
|
+
value: mt(t, n),
|
|
1319
1336
|
onChange: (e) => i(t.key, e),
|
|
1320
1337
|
error: r[t.key],
|
|
1321
1338
|
sourceValues: n
|
|
@@ -1325,7 +1342,7 @@ function $(t, n, r, i, a) {
|
|
|
1325
1342
|
children: t.label
|
|
1326
1343
|
}, `header-${o}`);
|
|
1327
1344
|
case "section": {
|
|
1328
|
-
let e =
|
|
1345
|
+
let e = ae(t.label, a);
|
|
1329
1346
|
return /* @__PURE__ */ q("section", {
|
|
1330
1347
|
className: "space-y-3",
|
|
1331
1348
|
children: [e && /* @__PURE__ */ K("div", {
|
|
@@ -1342,10 +1359,10 @@ function $(t, n, r, i, a) {
|
|
|
1342
1359
|
}
|
|
1343
1360
|
});
|
|
1344
1361
|
}
|
|
1345
|
-
function
|
|
1346
|
-
let { t: e } =
|
|
1362
|
+
function ht() {
|
|
1363
|
+
let { t: e } = L(), { enabled: n, selectedId: r, descriptor: i, loading: a, saving: o, submit: s, close: c, width: l } = se(), [u, d] = W(() => i?.values ? { ...i.values } : {}), [f, p] = W({}), [m, h] = W(i);
|
|
1347
1364
|
i !== m && (h(i), d(i?.values ? { ...i.values } : {}), p({}));
|
|
1348
|
-
let [g, _] =
|
|
1365
|
+
let [g, _] = W(null), v = g ?? l, y = U(() => (e, t) => {
|
|
1349
1366
|
d((n) => ({
|
|
1350
1367
|
...n,
|
|
1351
1368
|
[e]: t
|
|
@@ -1355,7 +1372,7 @@ function mt() {
|
|
|
1355
1372
|
return delete n[e], n;
|
|
1356
1373
|
});
|
|
1357
1374
|
}, []);
|
|
1358
|
-
return !n || r === null ? null : /* @__PURE__ */ q(
|
|
1375
|
+
return !n || r === null ? null : /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K("div", {
|
|
1359
1376
|
className: "fixed inset-0 z-40 bg-black/40",
|
|
1360
1377
|
onClick: c,
|
|
1361
1378
|
"aria-hidden": !0
|
|
@@ -1445,4 +1462,4 @@ function mt() {
|
|
|
1445
1462
|
})] });
|
|
1446
1463
|
}
|
|
1447
1464
|
//#endregion
|
|
1448
|
-
export {
|
|
1465
|
+
export { ht as InlineEditablePanel };
|