@middag-io/react 0.42.0 → 0.43.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-x0Ot_z_i.js → DateField-lPZsiWfC.js} +5 -5
- package/dist-lib/{DateRangeField-DbWZ2f92.js → DateRangeField-B7zWB48D.js} +12 -8
- package/dist-lib/{DocumentField-fwq79IWM.js → DocumentField-DutGscEM.js} +3 -3
- package/dist-lib/{FormField-BDWkyFcl.js → FormField-ChfKYVSc.js} +3735 -2633
- package/dist-lib/{FormPanelBlock-mIvZ0IFE.js → FormPanelBlock-Cu2ATcpu.js} +71 -71
- package/dist-lib/{PhoneField-DZQc97Eo.js → PhoneField-CP13cgq1.js} +2867 -2870
- package/dist-lib/base/form/fields/EntityPickerField.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/EditablePanelProvider.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/EditablePanelProvider.js +55 -54
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +345 -343
- package/dist-lib/base/shell/partials/PageActionButton.js +2 -1
- package/dist-lib/base/utils/time.js +26 -26
- package/dist-lib/{button-CxyXN3nw.js → button-PJdZDEA8.js} +4 -4
- package/dist-lib/{calendar-BStHDcu3.js → calendar-CFrEYtPR.js} +22 -21
- package/dist-lib/{chevron-right-t5ALKicc.js → chevron-right-Dt7yZRj6.js} +1 -1
- package/dist-lib/chunks/{subpath-BhcZoWUz.js → subpath-BYl-9lKg.js} +1 -1
- package/dist-lib/{combobox-RfE54yDL.js → combobox-Dk1Mr_PH.js} +1055 -1058
- package/dist-lib/{dist-tanBwm1t.js → dist-CJ4YN5HQ.js} +5 -5
- package/dist-lib/{dist-BUns-jcX.js → dist-Cwj39GRS.js} +1 -1
- package/dist-lib/{dist-axU0pUop.js → dist-CyQnd0TP.js} +4 -4
- package/dist-lib/{dist-EdxoDTPy.js → dist-DUhG8dAI.js} +2 -2
- package/dist-lib/{document-validation-BSjTDZhG.js → document-validation-D1y_WEv5.js} +4 -4
- package/dist-lib/{floating-ui.react-dom-CNntavPo.js → floating-ui.react-dom-BASAHo_L.js} +3 -3
- package/dist-lib/i18n/I18nProvider.js +1 -1
- package/dist-lib/i18n/instance.js +1 -1
- package/dist-lib/i18n/register-strings.js +1 -1
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/{input-DpHIBsEp.js → input-D1w5GXsE.js} +1 -1
- package/dist-lib/lib/host-pending.d.ts +32 -0
- package/dist-lib/lib/host-pending.d.ts.map +1 -0
- package/dist-lib/lib/host-pending.js +35 -0
- package/dist-lib/middag-react.js +21378 -7913
- package/dist-lib/{popover-CD3HfW3f.js → popover-7VNShhWQ.js} +6 -6
- package/dist-lib/primitives/reui/chart.js +12 -12
- package/dist-lib/primitives/reui/data-grid/data-grid-column-header.js +2 -2
- package/dist-lib/primitives/reui/data-grid/data-grid-pagination.js +28 -28
- package/dist-lib/primitives/reui/data-grid/data-grid-scroll-area.js +2 -2
- package/dist-lib/primitives/reui/data-grid/data-grid-table-dnd-rows.js +1 -1
- package/dist-lib/primitives/reui/data-grid/data-grid-table-dnd.js +2 -2
- package/dist-lib/primitives/reui/data-grid/data-grid-table-virtual.js +1 -1
- package/dist-lib/primitives/reui/data-grid/data-grid-table.js +5 -5
- package/dist-lib/primitives/reui/data-grid-pagination.js +28 -28
- package/dist-lib/primitives/reui/date-selector.js +5 -1
- package/dist-lib/primitives/reui/filters.js +24 -24
- package/dist-lib/primitives/reui/scrollspy.js +3 -1
- package/dist-lib/primitives/reui/stepper.js +23 -23
- package/dist-lib/primitives/reui/tree.js +7 -7
- package/dist-lib/{chunk-DeC0fbbY.js → rolldown-runtime-CWhphoD1.js} +1 -1
- package/dist-lib/{scroll-area-C_NPU_rI.js → scroll-area-CcAvV3Hh.js} +14 -8
- package/dist-lib/{skeleton-DXDJbb2L.js → skeleton-DP7igcN6.js} +1 -1
- package/dist-lib/{use-mobile-B18-3oTE.js → use-mobile-CqtqNcAV.js} +5 -5
- package/dist-lib/{utils-CpaZ5_iF.js → utils-DXlQmFY8.js} +2 -2
- package/package.json +4 -1
- package/dist-lib/MarkdownContent-DgypTiL-.js +0 -13507
- /package/dist-lib/{HugeiconsIcon-CKqc2W1S.js → HugeiconsIcon-C9KGSkIu.js} +0 -0
- /package/dist-lib/chunks/{subpath-B9beWkb2.js → subpath-AeMdleNB.js} +0 -0
- /package/dist-lib/chunks/{subpath-55YUOrvG.js → subpath-CJyJeTlw.js} +0 -0
- /package/dist-lib/chunks/{subpath--GXsYu-v.js → subpath-DjkzcIPp.js} +0 -0
- /package/dist-lib/chunks/{subpath-B30yU5uo.js → subpath-DoiyWIYV.js} +0 -0
- /package/dist-lib/chunks/{subpath-7b9-j7in.js → subpath-YbXSVoyF.js} +0 -0
- /package/dist-lib/chunks/{subpath-52vC0Fzu.js → subpath-oMCFwhdB.js} +0 -0
- /package/dist-lib/{dist-3F0-lo64.js → dist-BxFR7CYi.js} +0 -0
- /package/dist-lib/{useTranslation-D-tjJhTn.js → useTranslation-u1Lygbup.js} +0 -0
|
@@ -12,46 +12,47 @@ import { Select as y, SelectContent as b, SelectItem as x, SelectTrigger as S, S
|
|
|
12
12
|
import { Skeleton as w } from "../../../primitives/reui/skeleton.js";
|
|
13
13
|
import { Label as T } from "../../../primitives/reui/label.js";
|
|
14
14
|
import { Switch as E } from "../../../primitives/reui/switch.js";
|
|
15
|
-
import { InputOTP as D, InputOTPGroup as O, InputOTPSeparator as
|
|
16
|
-
import { NativeSelect as
|
|
17
|
-
import { NumberField as
|
|
18
|
-
import { RadioGroup as
|
|
19
|
-
import { Rating as
|
|
20
|
-
import { Slider as
|
|
15
|
+
import { InputOTP as D, InputOTPGroup as O, InputOTPSeparator as ee, InputOTPSlot as k } from "../../../primitives/reui/input-otp.js";
|
|
16
|
+
import { NativeSelect as A, NativeSelectOption as j } from "../../../primitives/reui/native-select.js";
|
|
17
|
+
import { NumberField as te, NumberFieldDecrement as M, NumberFieldGroup as ne, NumberFieldIncrement as N, NumberFieldInput as P } from "../../../primitives/reui/number-field.js";
|
|
18
|
+
import { RadioGroup as F, RadioGroupItem as re } from "../../../primitives/reui/radio-group.js";
|
|
19
|
+
import { Rating as I } from "../../../primitives/reui/rating.js";
|
|
20
|
+
import { Slider as L } from "../../../primitives/reui/slider.js";
|
|
21
21
|
import { useTranslation as R } from "../../../i18n/useTranslation.js";
|
|
22
22
|
import { useEditablePanel as ie } from "./EditablePanelContext.js";
|
|
23
|
+
import { beginPending as ae, trackedFetch as oe } from "../../../lib/host-pending.js";
|
|
23
24
|
import { evaluateCondition as z } from "../../utils/conditions.js";
|
|
24
|
-
import { formatBytes as
|
|
25
|
-
import { Fragment as
|
|
26
|
-
import { Fragment as
|
|
27
|
-
import { HugeiconsIcon as
|
|
28
|
-
import { Cancel01Icon as
|
|
29
|
-
import { REGEXP_ONLY_DIGITS as
|
|
30
|
-
import { z as
|
|
25
|
+
import { formatBytes as se, useFileUpload as ce } from "../../../lib/hooks/use-file-upload.js";
|
|
26
|
+
import { Fragment as le, Suspense as B, lazy as V, useCallback as H, useEffect as U, useId as ue, useMemo as W, useRef as G, useState as K } from "react";
|
|
27
|
+
import { Fragment as de, jsx as q, jsxs as J } from "react/jsx-runtime";
|
|
28
|
+
import { HugeiconsIcon as Y } from "@hugeicons/react";
|
|
29
|
+
import { Cancel01Icon as fe, FileEmpty02Icon as pe, Upload01Icon as me, ViewIcon as he, ViewOffIcon as ge } from "@hugeicons/core-free-icons";
|
|
30
|
+
import { REGEXP_ONLY_DIGITS as _e, REGEXP_ONLY_DIGITS_AND_CHARS as ve } from "input-otp";
|
|
31
|
+
import { z as X } from "zod";
|
|
31
32
|
//#region src/base/form/form-utils.ts
|
|
32
|
-
function
|
|
33
|
+
function ye(e) {
|
|
33
34
|
let t = [];
|
|
34
|
-
for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...
|
|
35
|
+
for (let n of e) n.kind === "field" ? t.push(n) : (n.kind === "section" || n.kind === "group") && t.push(...ye(n.children));
|
|
35
36
|
return t;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function be(e, t) {
|
|
38
39
|
if (e.component === "header") return !0;
|
|
39
40
|
let { props: n } = e;
|
|
40
41
|
return !(n.hidden_when && z(n.hidden_when, t) || n.visible_when && !z(n.visible_when, t));
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
+
function xe(e, t) {
|
|
43
44
|
if (e.component === "header") return !1;
|
|
44
45
|
let { props: n } = e;
|
|
45
46
|
return !!(n.disabled || n.disabled_when && z(n.disabled_when, t));
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
if (e.component === "header" ||
|
|
48
|
+
function Se(e, t) {
|
|
49
|
+
if (e.component === "header" || xe(e, t)) return !1;
|
|
49
50
|
let { props: n } = e;
|
|
50
51
|
return !!(n.required || n.required_when && z(n.required_when, t));
|
|
51
52
|
}
|
|
52
53
|
//#endregion
|
|
53
54
|
//#region src/base/form/form-schema-builder.ts
|
|
54
|
-
function
|
|
55
|
+
function Ce(e, t, n) {
|
|
55
56
|
let { component: r, props: i } = e, a = i.validation, o = n;
|
|
56
57
|
switch (r) {
|
|
57
58
|
case "text":
|
|
@@ -59,77 +60,77 @@ function Se(e, t, n) {
|
|
|
59
60
|
case "password":
|
|
60
61
|
case "slug":
|
|
61
62
|
case "color": {
|
|
62
|
-
let e =
|
|
63
|
-
return o && (e = e.min(1, t("middag.ui.validation.required"))), a?.minLength && (e = e.min(a.minLength, t("middag.ui.validation.min_length", { min: a.minLength }))), a?.maxLength && (e = e.max(a.maxLength, t("middag.ui.validation.max_length", { max: a.maxLength }))), a?.pattern && (e = e.regex(new RegExp(a.pattern), a.patternMessage ?? t("middag.ui.validation.pattern"))), o ? e : e.or(
|
|
63
|
+
let e = X.string();
|
|
64
|
+
return o && (e = e.min(1, t("middag.ui.validation.required"))), a?.minLength && (e = e.min(a.minLength, t("middag.ui.validation.min_length", { min: a.minLength }))), a?.maxLength && (e = e.max(a.maxLength, t("middag.ui.validation.max_length", { max: a.maxLength }))), a?.pattern && (e = e.regex(new RegExp(a.pattern), a.patternMessage ?? t("middag.ui.validation.pattern"))), o ? e : e.or(X.literal(""));
|
|
64
65
|
}
|
|
65
66
|
case "email": {
|
|
66
|
-
let e =
|
|
67
|
+
let e = X.string();
|
|
67
68
|
if (o) e = e.min(1, t("middag.ui.validation.required")).email(t("middag.ui.validation.email"));
|
|
68
|
-
else return e.email(t("middag.ui.validation.email")).or(
|
|
69
|
+
else return e.email(t("middag.ui.validation.email")).or(X.literal(""));
|
|
69
70
|
return e;
|
|
70
71
|
}
|
|
71
72
|
case "url": {
|
|
72
|
-
let e =
|
|
73
|
+
let e = X.string();
|
|
73
74
|
if (o) e = e.min(1, t("middag.ui.validation.required")).url(t("middag.ui.validation.url"));
|
|
74
|
-
else return e.url(t("middag.ui.validation.url")).or(
|
|
75
|
+
else return e.url(t("middag.ui.validation.url")).or(X.literal(""));
|
|
75
76
|
return e;
|
|
76
77
|
}
|
|
77
78
|
case "int": {
|
|
78
|
-
let e =
|
|
79
|
+
let e = X.number({ message: t("middag.ui.validation.integer") }).int(t("middag.ui.validation.integer"));
|
|
79
80
|
return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
|
|
80
81
|
}
|
|
81
82
|
case "float": {
|
|
82
|
-
let e =
|
|
83
|
+
let e = X.number();
|
|
83
84
|
return i.min != null && (e = e.min(i.min, t("middag.ui.validation.min_value", { min: i.min }))), i.max != null && (e = e.max(i.max, t("middag.ui.validation.max_value", { max: i.max }))), o ? e : e.nullable();
|
|
84
85
|
}
|
|
85
86
|
case "currency": {
|
|
86
|
-
let e =
|
|
87
|
+
let e = X.number();
|
|
87
88
|
return o ? e : e.nullable();
|
|
88
89
|
}
|
|
89
90
|
case "select":
|
|
90
91
|
case "radio":
|
|
91
92
|
case "entity_picker": {
|
|
92
|
-
let e =
|
|
93
|
+
let e = X.string();
|
|
93
94
|
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
94
95
|
}
|
|
95
96
|
case "multiselect":
|
|
96
97
|
case "tags": {
|
|
97
|
-
let e =
|
|
98
|
+
let e = X.array(X.string());
|
|
98
99
|
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
99
100
|
}
|
|
100
101
|
case "checkbox":
|
|
101
|
-
case "switch": return
|
|
102
|
+
case "switch": return X.boolean();
|
|
102
103
|
case "date":
|
|
103
104
|
case "datetime": {
|
|
104
|
-
let e =
|
|
105
|
+
let e = X.string();
|
|
105
106
|
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
106
107
|
}
|
|
107
108
|
case "phone": {
|
|
108
|
-
let e =
|
|
109
|
+
let e = X.string();
|
|
109
110
|
return o ? e.min(1, t("middag.ui.validation.required")) : e;
|
|
110
111
|
}
|
|
111
112
|
case "document": {
|
|
112
|
-
let e = i.documentType ?? "generic", n = i.documentScope ?? "any", r =
|
|
113
|
-
let { isValidDocument: r } = await import("../../../chunks/subpath-
|
|
113
|
+
let e = i.documentType ?? "generic", n = i.documentScope ?? "any", r = X.string(), a = async (t) => {
|
|
114
|
+
let { isValidDocument: r } = await import("../../../chunks/subpath-YbXSVoyF.js");
|
|
114
115
|
return r(t, e, n);
|
|
115
116
|
};
|
|
116
117
|
return o ? r.min(1, t("middag.ui.validation.required")).refine(a, t("middag.ui.validation.document_invalid")) : r.refine(async (e) => e === "" || await a(e), t("middag.ui.validation.document_invalid"));
|
|
117
118
|
}
|
|
118
|
-
default: return
|
|
119
|
+
default: return X.any();
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
function
|
|
122
|
-
let r =
|
|
123
|
-
for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" ||
|
|
124
|
-
return
|
|
122
|
+
function we(e, t, n) {
|
|
123
|
+
let r = ye(e), i = {};
|
|
124
|
+
for (let e of r) e.component === "header" || e.component === "hidden" || e.component === "static" || be(e, t) && (i[e.key] = Ce(e, n, Se(e, t)));
|
|
125
|
+
return X.object(i);
|
|
125
126
|
}
|
|
126
127
|
//#endregion
|
|
127
128
|
//#region src/base/form/fields/CheckboxField.tsx
|
|
128
|
-
function
|
|
129
|
+
function Te({ id: e, value: t, onChange: n, label: r, disabled: i, required: a, error: s, helpTextId: c, errorId: l }) {
|
|
129
130
|
let u = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
130
|
-
return /* @__PURE__ */
|
|
131
|
+
return /* @__PURE__ */ J("div", {
|
|
131
132
|
className: "flex items-center gap-2",
|
|
132
|
-
children: [/* @__PURE__ */
|
|
133
|
+
children: [/* @__PURE__ */ q(o, {
|
|
133
134
|
id: e,
|
|
134
135
|
checked: !!t,
|
|
135
136
|
onCheckedChange: (e) => n(e === !0),
|
|
@@ -137,7 +138,7 @@ function we({ id: e, value: t, onChange: n, label: r, disabled: i, required: a,
|
|
|
137
138
|
"aria-invalid": s ? !0 : void 0,
|
|
138
139
|
"aria-required": a || void 0,
|
|
139
140
|
"aria-describedby": u
|
|
140
|
-
}), r && /* @__PURE__ */
|
|
141
|
+
}), r && /* @__PURE__ */ q(T, {
|
|
141
142
|
htmlFor: e,
|
|
142
143
|
className: "text-sm font-normal",
|
|
143
144
|
children: r
|
|
@@ -146,22 +147,22 @@ function we({ id: e, value: t, onChange: n, label: r, disabled: i, required: a,
|
|
|
146
147
|
}
|
|
147
148
|
//#endregion
|
|
148
149
|
//#region src/base/form/fields/ColorField.tsx
|
|
149
|
-
function
|
|
150
|
-
let u = [o ? l : void 0, c].filter(Boolean).join(" ") || void 0, d =
|
|
150
|
+
function Ee({ id: e, value: t, onChange: n, placeholder: r, disabled: i, required: a, error: o, helpTextId: c, errorId: l }) {
|
|
151
|
+
let u = [o ? l : void 0, c].filter(Boolean).join(" ") || void 0, d = H((e) => {
|
|
151
152
|
n(e.target.value);
|
|
152
|
-
}, [n]), f =
|
|
153
|
+
}, [n]), f = H((e) => {
|
|
153
154
|
n(e.target.value);
|
|
154
155
|
}, [n]);
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
+
return /* @__PURE__ */ J("div", {
|
|
156
157
|
className: "flex items-center gap-2",
|
|
157
|
-
children: [/* @__PURE__ */
|
|
158
|
+
children: [/* @__PURE__ */ q("input", {
|
|
158
159
|
type: "color",
|
|
159
160
|
value: t || "#000000",
|
|
160
161
|
onChange: f,
|
|
161
162
|
disabled: i,
|
|
162
163
|
className: "border-input h-9 w-9 shrink-0 cursor-pointer rounded-md border p-0.5",
|
|
163
164
|
"aria-label": "Color picker"
|
|
164
|
-
}), /* @__PURE__ */
|
|
165
|
+
}), /* @__PURE__ */ q(s, {
|
|
165
166
|
id: e,
|
|
166
167
|
type: "text",
|
|
167
168
|
value: t ?? "",
|
|
@@ -178,7 +179,7 @@ function Te({ id: e, value: t, onChange: n, placeholder: r, disabled: i, require
|
|
|
178
179
|
}
|
|
179
180
|
//#endregion
|
|
180
181
|
//#region src/base/form/fields/CurrencyField.tsx
|
|
181
|
-
var
|
|
182
|
+
var De = {
|
|
182
183
|
BRL: "R$",
|
|
183
184
|
USD: "$",
|
|
184
185
|
EUR: "€",
|
|
@@ -193,10 +194,10 @@ var Ee = {
|
|
|
193
194
|
COP: "$",
|
|
194
195
|
PEN: "S/"
|
|
195
196
|
};
|
|
196
|
-
function
|
|
197
|
-
let { t: g, formatCurrency: _ } = R(), [v, y] =
|
|
197
|
+
function Oe({ 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 }) {
|
|
198
|
+
let { t: g, formatCurrency: _ } = R(), [v, y] = K(!1), [b, x] = K(""), S = [s ? p : void 0, c].filter(Boolean).join(" ") || void 0, C = v ? b : t == null ? "" : _(t, r), w = De[r] ?? r, T = H(() => {
|
|
198
199
|
y(!0), x(t == null ? "" : String(t));
|
|
199
|
-
}, [t]), E =
|
|
200
|
+
}, [t]), E = H(() => {
|
|
200
201
|
y(!1);
|
|
201
202
|
let e = parseFloat(b.replace(/,/g, "."));
|
|
202
203
|
n(Number.isNaN(e) ? null : Math.round((m !== void 0 && e < m ? m : h !== void 0 && e > h ? h : e) * 100) / 100);
|
|
@@ -205,15 +206,15 @@ function De({ id: e, value: t, onChange: n, currency: r = "BRL", placeholder: i,
|
|
|
205
206
|
n,
|
|
206
207
|
m,
|
|
207
208
|
h
|
|
208
|
-
]), D =
|
|
209
|
+
]), D = H((e) => {
|
|
209
210
|
x(e.target.value);
|
|
210
211
|
}, []);
|
|
211
|
-
return /* @__PURE__ */
|
|
212
|
+
return /* @__PURE__ */ J(l, {
|
|
212
213
|
"data-disabled": a || void 0,
|
|
213
|
-
children: [/* @__PURE__ */
|
|
214
|
+
children: [/* @__PURE__ */ q(u, {
|
|
214
215
|
align: "inline-start",
|
|
215
|
-
children: /* @__PURE__ */
|
|
216
|
-
}), /* @__PURE__ */
|
|
216
|
+
children: /* @__PURE__ */ q(f, { children: w })
|
|
217
|
+
}), /* @__PURE__ */ q(d, {
|
|
217
218
|
id: e,
|
|
218
219
|
inputMode: "decimal",
|
|
219
220
|
value: v ? b : t == null ? "" : C.replace(w, "").trim(),
|
|
@@ -230,94 +231,97 @@ function De({ id: e, value: t, onChange: n, currency: r = "BRL", placeholder: i,
|
|
|
230
231
|
}
|
|
231
232
|
//#endregion
|
|
232
233
|
//#region src/base/form/fields/EntityPickerField.tsx
|
|
233
|
-
function
|
|
234
|
+
function ke(e) {
|
|
234
235
|
return e.split(/\s+/).slice(0, 2).map((e) => e[0]?.toUpperCase() ?? "").join("");
|
|
235
236
|
}
|
|
236
|
-
function
|
|
237
|
-
let { t: w } = R(), [T, E] =
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
237
|
+
function Ae({ 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 }) {
|
|
238
|
+
let { t: w } = R(), [T, E] = K(s && t && s.value === t ? s.label : ""), [D, O] = K([]), [ee, k] = K(!1), A = G(void 0), j = !!c, te = [x ? C : void 0, S].filter(Boolean).join(" ") || void 0, M = W(() => [], []), ne = W(() => o ?? M, [o, M]);
|
|
239
|
+
U(() => {
|
|
240
|
+
if (!j) return;
|
|
241
|
+
if (A.current && clearTimeout(A.current), T.length < l) return A.current = setTimeout(() => O([]), 0), () => {
|
|
242
|
+
A.current && clearTimeout(A.current);
|
|
243
|
+
};
|
|
244
|
+
let e = ae();
|
|
245
|
+
return A.current = setTimeout(async () => {
|
|
246
|
+
k(!0);
|
|
243
247
|
try {
|
|
244
248
|
let e = new URL(c, window.location.origin);
|
|
245
249
|
e.searchParams.set("q", T);
|
|
246
|
-
let t = await
|
|
250
|
+
let t = await oe(e.toString());
|
|
247
251
|
if (t.ok) {
|
|
248
|
-
let e = await t.json()
|
|
249
|
-
O((e.items ?? e.data ?? e).map((e) => ({
|
|
252
|
+
let e = await t.json(), n = (e.items ?? e.data ?? e).map((e) => ({
|
|
250
253
|
value: String(e.value ?? e.id),
|
|
251
254
|
label: String(e.label ?? e.name ?? e.title ?? ""),
|
|
252
255
|
subtitle: d ? String(e[d] ?? "") : void 0,
|
|
253
256
|
avatarUrl: u ? String(e[u] ?? "") : void 0
|
|
254
|
-
}))
|
|
257
|
+
}));
|
|
258
|
+
O(n);
|
|
255
259
|
}
|
|
256
260
|
} catch {} finally {
|
|
257
|
-
|
|
261
|
+
k(!1), e();
|
|
258
262
|
}
|
|
259
263
|
}, 300), () => {
|
|
260
|
-
|
|
261
|
-
}
|
|
264
|
+
A.current && clearTimeout(A.current), e();
|
|
265
|
+
};
|
|
262
266
|
}, [
|
|
263
267
|
T,
|
|
264
|
-
|
|
268
|
+
j,
|
|
265
269
|
c,
|
|
266
270
|
l,
|
|
267
271
|
d,
|
|
268
272
|
u
|
|
269
273
|
]);
|
|
270
|
-
let
|
|
271
|
-
|
|
274
|
+
let N = j ? D : ne, P = W(() => s && t && s.value === t && !N.some((e) => e.value === t) ? [s, ...N] : N, [
|
|
275
|
+
N,
|
|
272
276
|
s,
|
|
273
277
|
t
|
|
274
|
-
]),
|
|
275
|
-
if (
|
|
278
|
+
]), F = W(() => {
|
|
279
|
+
if (j || !T) return P;
|
|
276
280
|
let e = T.toLowerCase();
|
|
277
|
-
return
|
|
281
|
+
return P.filter((t) => t.label.toLowerCase().includes(e) || t.subtitle?.toLowerCase().includes(e));
|
|
278
282
|
}, [
|
|
279
|
-
|
|
283
|
+
P,
|
|
280
284
|
T,
|
|
281
|
-
|
|
282
|
-
]),
|
|
285
|
+
j
|
|
286
|
+
]), re = H((e) => {
|
|
283
287
|
a(e ?? "");
|
|
284
|
-
}, [a]),
|
|
285
|
-
return /* @__PURE__ */
|
|
286
|
-
items:
|
|
288
|
+
}, [a]), I = ee ? w("middag.ui.form.entity_loading") : T.length < l && j ? w("middag.ui.form.entity_min_chars").replace("{min}", String(l)) : w("middag.ui.form.entity_no_results"), L = !!u || P.some((e) => e.avatarUrl);
|
|
289
|
+
return /* @__PURE__ */ J(p, {
|
|
290
|
+
items: F,
|
|
287
291
|
value: t || null,
|
|
288
|
-
onValueChange:
|
|
289
|
-
children: [/* @__PURE__ */
|
|
292
|
+
onValueChange: re,
|
|
293
|
+
children: [/* @__PURE__ */ q(g, {
|
|
290
294
|
id: e,
|
|
291
295
|
placeholder: f ?? w("middag.ui.form.entity_search"),
|
|
292
296
|
disabled: y,
|
|
293
297
|
"aria-invalid": x ? !0 : void 0,
|
|
294
298
|
"aria-required": b || void 0,
|
|
295
|
-
"aria-describedby":
|
|
299
|
+
"aria-describedby": te,
|
|
296
300
|
showClear: !!t,
|
|
297
301
|
showTrigger: !0,
|
|
298
302
|
value: T,
|
|
299
303
|
onChange: (e) => E(e.target.value)
|
|
300
|
-
}), /* @__PURE__ */
|
|
304
|
+
}), /* @__PURE__ */ J(m, { children: [/* @__PURE__ */ q(h, {
|
|
301
305
|
className: "px-4 py-3 text-sm",
|
|
302
|
-
children:
|
|
303
|
-
}), /* @__PURE__ */
|
|
306
|
+
children: I
|
|
307
|
+
}), /* @__PURE__ */ q(v, { children: F.map((e) => /* @__PURE__ */ J(_, {
|
|
304
308
|
value: e.value,
|
|
305
309
|
className: "flex items-center gap-2.5 px-3 py-2",
|
|
306
|
-
children: [
|
|
310
|
+
children: [L && /* @__PURE__ */ J(n, {
|
|
307
311
|
className: "h-7 w-7 shrink-0",
|
|
308
|
-
children: [e.avatarUrl && /* @__PURE__ */
|
|
312
|
+
children: [e.avatarUrl && /* @__PURE__ */ q(i, {
|
|
309
313
|
src: e.avatarUrl,
|
|
310
314
|
alt: e.label
|
|
311
|
-
}), /* @__PURE__ */
|
|
315
|
+
}), /* @__PURE__ */ q(r, {
|
|
312
316
|
className: "text-[10px]",
|
|
313
|
-
children:
|
|
317
|
+
children: ke(e.label)
|
|
314
318
|
})]
|
|
315
|
-
}), /* @__PURE__ */
|
|
319
|
+
}), /* @__PURE__ */ J("div", {
|
|
316
320
|
className: "min-w-0 flex-1",
|
|
317
|
-
children: [/* @__PURE__ */
|
|
321
|
+
children: [/* @__PURE__ */ q("div", {
|
|
318
322
|
className: "truncate text-sm",
|
|
319
323
|
children: e.label
|
|
320
|
-
}), e.subtitle && /* @__PURE__ */
|
|
324
|
+
}), e.subtitle && /* @__PURE__ */ q("div", {
|
|
321
325
|
className: "text-muted-foreground truncate text-xs",
|
|
322
326
|
children: e.subtitle
|
|
323
327
|
})]
|
|
@@ -327,21 +331,21 @@ function ke({ id: e, value: t, onChange: a, options: o, initialOption: s, autoco
|
|
|
327
331
|
}
|
|
328
332
|
//#endregion
|
|
329
333
|
//#region src/base/form/fields/FileUploadField.tsx
|
|
330
|
-
function
|
|
334
|
+
function je(e) {
|
|
331
335
|
let t = e.split(/[?#]/)[0], n = t.split("/");
|
|
332
336
|
return n[n.length - 1] || t;
|
|
333
337
|
}
|
|
334
|
-
function
|
|
338
|
+
function Me(e) {
|
|
335
339
|
if (e == null || e === "") return null;
|
|
336
340
|
if (typeof e == "string") return {
|
|
337
|
-
name:
|
|
341
|
+
name: je(e),
|
|
338
342
|
size: 0,
|
|
339
343
|
type: "",
|
|
340
344
|
url: e,
|
|
341
345
|
id: e
|
|
342
346
|
};
|
|
343
347
|
if (typeof e == "object" && !(e instanceof File)) {
|
|
344
|
-
let t = e, n = typeof t.url == "string" ? t.url : "", r = typeof t.name == "string" ? t.name : n ?
|
|
348
|
+
let t = e, n = typeof t.url == "string" ? t.url : "", r = typeof t.name == "string" ? t.name : n ? je(n) : "";
|
|
345
349
|
return !n && !r ? null : {
|
|
346
350
|
name: r,
|
|
347
351
|
size: typeof t.size == "number" ? t.size : 0,
|
|
@@ -352,11 +356,11 @@ function je(e) {
|
|
|
352
356
|
}
|
|
353
357
|
return null;
|
|
354
358
|
}
|
|
355
|
-
function
|
|
356
|
-
return (Array.isArray(e) ? e : [e]).map(
|
|
359
|
+
function Ne(e) {
|
|
360
|
+
return (Array.isArray(e) ? e : [e]).map(Me).filter((e) => e !== null);
|
|
357
361
|
}
|
|
358
|
-
function
|
|
359
|
-
let { t: m } = R(), [h] =
|
|
362
|
+
function Pe({ 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 }) {
|
|
363
|
+
let { t: m } = R(), [h] = K(() => Ne(r)), [{ files: g, isDragging: _, errors: v }, { removeFile: y, handleDragEnter: b, handleDragLeave: x, handleDragOver: S, handleDrop: C, openFileDialog: w, getInputProps: T }] = ce({
|
|
360
364
|
maxFiles: o ? s : 1,
|
|
361
365
|
maxSize: c,
|
|
362
366
|
accept: a,
|
|
@@ -367,13 +371,13 @@ function Ne({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
367
371
|
i(o ? t : t[0] ?? null);
|
|
368
372
|
}
|
|
369
373
|
}), E = [d ? p : void 0, f].filter(Boolean).join(" ") || void 0, D = (e) => e.type.startsWith("image/");
|
|
370
|
-
return /* @__PURE__ */
|
|
374
|
+
return /* @__PURE__ */ J("div", { children: [/* @__PURE__ */ J("div", {
|
|
371
375
|
className: e("rounded-lg border border-dashed p-4 transition-colors", _ ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/50", l && "pointer-events-none opacity-50"),
|
|
372
376
|
onDragEnter: b,
|
|
373
377
|
onDragLeave: x,
|
|
374
378
|
onDragOver: S,
|
|
375
379
|
onDrop: C,
|
|
376
|
-
children: [/* @__PURE__ */
|
|
380
|
+
children: [/* @__PURE__ */ q("input", {
|
|
377
381
|
...T(),
|
|
378
382
|
id: n,
|
|
379
383
|
className: "sr-only",
|
|
@@ -381,18 +385,18 @@ function Ne({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
381
385
|
"aria-invalid": d ? !0 : void 0,
|
|
382
386
|
"aria-required": u || void 0,
|
|
383
387
|
"aria-describedby": E
|
|
384
|
-
}), g.length === 0 ? /* @__PURE__ */
|
|
388
|
+
}), g.length === 0 ? /* @__PURE__ */ J("div", {
|
|
385
389
|
className: "flex flex-col items-center gap-2 py-4",
|
|
386
390
|
children: [
|
|
387
|
-
/* @__PURE__ */
|
|
388
|
-
icon:
|
|
391
|
+
/* @__PURE__ */ q(Y, {
|
|
392
|
+
icon: me,
|
|
389
393
|
className: e("size-8", _ ? "text-primary" : "text-muted-foreground")
|
|
390
394
|
}),
|
|
391
|
-
/* @__PURE__ */
|
|
395
|
+
/* @__PURE__ */ q("p", {
|
|
392
396
|
className: "text-muted-foreground text-sm",
|
|
393
397
|
children: m("middag.ui.form.file_drop_hint")
|
|
394
398
|
}),
|
|
395
|
-
/* @__PURE__ */
|
|
399
|
+
/* @__PURE__ */ q(t, {
|
|
396
400
|
type: "button",
|
|
397
401
|
variant: "outline",
|
|
398
402
|
size: "sm",
|
|
@@ -400,54 +404,54 @@ function Ne({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
400
404
|
disabled: l,
|
|
401
405
|
children: m("middag.ui.form.file_browse")
|
|
402
406
|
}),
|
|
403
|
-
/* @__PURE__ */
|
|
407
|
+
/* @__PURE__ */ J("p", {
|
|
404
408
|
className: "text-muted-foreground text-xs",
|
|
405
409
|
children: [
|
|
406
410
|
m("middag.ui.form.file_max_size"),
|
|
407
411
|
" ",
|
|
408
|
-
|
|
412
|
+
se(c)
|
|
409
413
|
]
|
|
410
414
|
})
|
|
411
415
|
]
|
|
412
|
-
}) : /* @__PURE__ */
|
|
416
|
+
}) : /* @__PURE__ */ J("div", {
|
|
413
417
|
className: "space-y-2",
|
|
414
|
-
children: [g.map((e) => /* @__PURE__ */
|
|
418
|
+
children: [g.map((e) => /* @__PURE__ */ J("div", {
|
|
415
419
|
className: "bg-muted/50 flex items-center gap-3 rounded-md px-3 py-2",
|
|
416
420
|
children: [
|
|
417
|
-
D(e.file) && e.preview ? /* @__PURE__ */
|
|
421
|
+
D(e.file) && e.preview ? /* @__PURE__ */ q("img", {
|
|
418
422
|
src: e.preview,
|
|
419
423
|
alt: e.file.name,
|
|
420
424
|
className: "size-10 shrink-0 rounded border object-cover"
|
|
421
|
-
}) : /* @__PURE__ */
|
|
425
|
+
}) : /* @__PURE__ */ q("div", {
|
|
422
426
|
className: "bg-muted flex size-10 shrink-0 items-center justify-center rounded border",
|
|
423
|
-
children: /* @__PURE__ */
|
|
424
|
-
icon:
|
|
427
|
+
children: /* @__PURE__ */ q(Y, {
|
|
428
|
+
icon: pe,
|
|
425
429
|
className: "text-muted-foreground size-5"
|
|
426
430
|
})
|
|
427
431
|
}),
|
|
428
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ J("div", {
|
|
429
433
|
className: "min-w-0 flex-1",
|
|
430
|
-
children: [/* @__PURE__ */
|
|
434
|
+
children: [/* @__PURE__ */ q("p", {
|
|
431
435
|
className: "truncate text-sm font-medium",
|
|
432
436
|
children: e.file.name
|
|
433
|
-
}), /* @__PURE__ */
|
|
437
|
+
}), /* @__PURE__ */ q("p", {
|
|
434
438
|
className: "text-muted-foreground text-xs",
|
|
435
|
-
children:
|
|
439
|
+
children: se(e.file.size)
|
|
436
440
|
})]
|
|
437
441
|
}),
|
|
438
|
-
/* @__PURE__ */
|
|
442
|
+
/* @__PURE__ */ q(t, {
|
|
439
443
|
type: "button",
|
|
440
444
|
variant: "ghost",
|
|
441
445
|
size: "icon-xs",
|
|
442
446
|
onClick: () => y(e.id),
|
|
443
447
|
disabled: l,
|
|
444
|
-
children: /* @__PURE__ */
|
|
445
|
-
icon:
|
|
448
|
+
children: /* @__PURE__ */ q(Y, {
|
|
449
|
+
icon: fe,
|
|
446
450
|
className: "size-3.5"
|
|
447
451
|
})
|
|
448
452
|
})
|
|
449
453
|
]
|
|
450
|
-
}, e.id)), o && g.length < s && /* @__PURE__ */
|
|
454
|
+
}, e.id)), o && g.length < s && /* @__PURE__ */ q(t, {
|
|
451
455
|
type: "button",
|
|
452
456
|
variant: "outline",
|
|
453
457
|
size: "sm",
|
|
@@ -456,9 +460,9 @@ function Ne({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
456
460
|
children: m("middag.ui.form.file_add_more")
|
|
457
461
|
})]
|
|
458
462
|
})]
|
|
459
|
-
}), v.length > 0 && /* @__PURE__ */
|
|
463
|
+
}), v.length > 0 && /* @__PURE__ */ q("div", {
|
|
460
464
|
className: "mt-1.5 space-y-0.5",
|
|
461
|
-
children: v.map((e, t) => /* @__PURE__ */
|
|
465
|
+
children: v.map((e, t) => /* @__PURE__ */ q("p", {
|
|
462
466
|
className: "text-destructive text-xs",
|
|
463
467
|
children: e
|
|
464
468
|
}, t))
|
|
@@ -466,10 +470,10 @@ function Ne({ id: n, value: r, onChange: i, accept: a = "*", multiple: o = !1, m
|
|
|
466
470
|
}
|
|
467
471
|
//#endregion
|
|
468
472
|
//#region src/base/form/fields/MultiSelectField.tsx
|
|
469
|
-
var
|
|
470
|
-
function
|
|
473
|
+
var Fe = 8;
|
|
474
|
+
function Ie({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: l, variant: u = "auto" }) {
|
|
471
475
|
let { t: d } = R(), f = t ?? [], p = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
472
|
-
return u === "checkbox" || u === "auto" && r.length <=
|
|
476
|
+
return u === "checkbox" || u === "auto" && r.length <= Fe ? /* @__PURE__ */ q(Le, {
|
|
473
477
|
id: e,
|
|
474
478
|
options: r,
|
|
475
479
|
selected: f,
|
|
@@ -479,7 +483,7 @@ function Fe({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
479
483
|
error: s,
|
|
480
484
|
describedBy: p,
|
|
481
485
|
t: d
|
|
482
|
-
}) : /* @__PURE__ */
|
|
486
|
+
}) : /* @__PURE__ */ q(Re, {
|
|
483
487
|
id: e,
|
|
484
488
|
options: r,
|
|
485
489
|
selected: f,
|
|
@@ -492,37 +496,37 @@ function Fe({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
492
496
|
t: d
|
|
493
497
|
});
|
|
494
498
|
}
|
|
495
|
-
function
|
|
499
|
+
function Le({ id: e, options: t, selected: n, onChange: r, disabled: i, required: a, error: s, describedBy: c, t: l }) {
|
|
496
500
|
let u = (e) => {
|
|
497
501
|
n.includes(e) ? r(n.filter((t) => t !== e)) : r([...n, e]);
|
|
498
502
|
};
|
|
499
|
-
return /* @__PURE__ */
|
|
503
|
+
return /* @__PURE__ */ J("div", {
|
|
500
504
|
id: e,
|
|
501
505
|
role: "group",
|
|
502
506
|
"aria-invalid": s ? !0 : void 0,
|
|
503
507
|
"aria-required": a || void 0,
|
|
504
508
|
"aria-describedby": c,
|
|
505
509
|
className: "border-input max-h-48 space-y-2 overflow-y-auto rounded-md border p-3",
|
|
506
|
-
children: [t.map((t) => /* @__PURE__ */
|
|
510
|
+
children: [t.map((t) => /* @__PURE__ */ J("div", {
|
|
507
511
|
className: "flex items-center gap-2",
|
|
508
|
-
children: [/* @__PURE__ */
|
|
512
|
+
children: [/* @__PURE__ */ q(o, {
|
|
509
513
|
id: `${e}-${t.value}`,
|
|
510
514
|
checked: n.includes(t.value),
|
|
511
515
|
onCheckedChange: () => u(t.value),
|
|
512
516
|
disabled: i
|
|
513
|
-
}), /* @__PURE__ */
|
|
517
|
+
}), /* @__PURE__ */ q(T, {
|
|
514
518
|
htmlFor: `${e}-${t.value}`,
|
|
515
519
|
className: "text-sm font-normal",
|
|
516
520
|
children: t.label
|
|
517
521
|
})]
|
|
518
|
-
}, t.value)), t.length === 0 && /* @__PURE__ */
|
|
522
|
+
}, t.value)), t.length === 0 && /* @__PURE__ */ q("p", {
|
|
519
523
|
className: "text-muted-foreground text-sm",
|
|
520
524
|
children: l("middag.ui.multiselect.no_options")
|
|
521
525
|
})]
|
|
522
526
|
});
|
|
523
527
|
}
|
|
524
|
-
function
|
|
525
|
-
let [f, y] =
|
|
528
|
+
function Re({ id: e, options: t, selected: n, onChange: r, placeholder: i, disabled: s, required: c, error: l, describedBy: u, t: d }) {
|
|
529
|
+
let [f, y] = K(""), b = W(() => {
|
|
526
530
|
if (!f) return t;
|
|
527
531
|
let e = f.toLowerCase();
|
|
528
532
|
return t.filter((t) => t.label.toLowerCase().includes(e));
|
|
@@ -532,39 +536,39 @@ function Le({ id: e, options: t, selected: n, onChange: r, placeholder: i, disab
|
|
|
532
536
|
value: t,
|
|
533
537
|
label: e.get(t) ?? t
|
|
534
538
|
}));
|
|
535
|
-
}, [n, t]), S =
|
|
539
|
+
}, [n, t]), S = H((e) => {
|
|
536
540
|
r(n.filter((t) => t !== e));
|
|
537
|
-
}, [n, r]), C =
|
|
541
|
+
}, [n, r]), C = H((e) => {
|
|
538
542
|
e && (n.includes(e) ? r(n.filter((t) => t !== e)) : r([...n, e]));
|
|
539
543
|
}, [n, r]);
|
|
540
|
-
return /* @__PURE__ */
|
|
544
|
+
return /* @__PURE__ */ J("div", {
|
|
541
545
|
id: e,
|
|
542
546
|
"aria-invalid": l ? !0 : void 0,
|
|
543
547
|
"aria-required": c || void 0,
|
|
544
548
|
"aria-describedby": u,
|
|
545
549
|
className: "space-y-2",
|
|
546
|
-
children: [x.length > 0 && /* @__PURE__ */
|
|
550
|
+
children: [x.length > 0 && /* @__PURE__ */ q("div", {
|
|
547
551
|
className: "flex flex-wrap gap-1.5",
|
|
548
|
-
children: x.map((e) => /* @__PURE__ */
|
|
552
|
+
children: x.map((e) => /* @__PURE__ */ J(a, {
|
|
549
553
|
variant: "secondary",
|
|
550
554
|
className: "gap-1 pr-1",
|
|
551
|
-
children: [e.label, /* @__PURE__ */
|
|
555
|
+
children: [e.label, /* @__PURE__ */ q("button", {
|
|
552
556
|
type: "button",
|
|
553
557
|
onClick: () => S(e.value),
|
|
554
558
|
className: "text-muted-foreground hover:text-foreground ml-0.5 rounded-full",
|
|
555
559
|
"aria-label": d("middag.ui.form.multiselect_remove", { label: e.label }),
|
|
556
|
-
children: /* @__PURE__ */
|
|
560
|
+
children: /* @__PURE__ */ J("svg", {
|
|
557
561
|
viewBox: "0 0 24 24",
|
|
558
562
|
fill: "none",
|
|
559
563
|
stroke: "currentColor",
|
|
560
564
|
strokeWidth: 2,
|
|
561
565
|
className: "h-3 w-3",
|
|
562
|
-
children: [/* @__PURE__ */
|
|
566
|
+
children: [/* @__PURE__ */ q("line", {
|
|
563
567
|
x1: "18",
|
|
564
568
|
y1: "6",
|
|
565
569
|
x2: "6",
|
|
566
570
|
y2: "18"
|
|
567
|
-
}), /* @__PURE__ */
|
|
571
|
+
}), /* @__PURE__ */ q("line", {
|
|
568
572
|
x1: "6",
|
|
569
573
|
y1: "6",
|
|
570
574
|
x2: "18",
|
|
@@ -573,28 +577,28 @@ function Le({ id: e, options: t, selected: n, onChange: r, placeholder: i, disab
|
|
|
573
577
|
})
|
|
574
578
|
})]
|
|
575
579
|
}, e.value))
|
|
576
|
-
}), /* @__PURE__ */
|
|
580
|
+
}), /* @__PURE__ */ J(p, {
|
|
577
581
|
items: b,
|
|
578
582
|
value: null,
|
|
579
583
|
onValueChange: C,
|
|
580
584
|
filter: null,
|
|
581
|
-
children: [/* @__PURE__ */
|
|
585
|
+
children: [/* @__PURE__ */ q(g, {
|
|
582
586
|
placeholder: i ?? d("middag.ui.form.multiselect_search"),
|
|
583
587
|
disabled: s,
|
|
584
588
|
showTrigger: !0,
|
|
585
589
|
value: f,
|
|
586
590
|
onChange: (e) => y(e.target.value)
|
|
587
|
-
}), /* @__PURE__ */
|
|
591
|
+
}), /* @__PURE__ */ J(m, { children: [/* @__PURE__ */ q(h, {
|
|
588
592
|
className: "px-4 py-3 text-sm",
|
|
589
593
|
children: d("middag.ui.form.entity_no_results")
|
|
590
|
-
}), /* @__PURE__ */
|
|
594
|
+
}), /* @__PURE__ */ q(v, { children: b.map((e) => /* @__PURE__ */ J(_, {
|
|
591
595
|
value: e.value,
|
|
592
596
|
className: "flex items-center gap-2",
|
|
593
|
-
children: [/* @__PURE__ */
|
|
597
|
+
children: [/* @__PURE__ */ q(o, {
|
|
594
598
|
checked: n.includes(e.value),
|
|
595
599
|
tabIndex: -1,
|
|
596
600
|
className: "pointer-events-none"
|
|
597
|
-
}), /* @__PURE__ */
|
|
601
|
+
}), /* @__PURE__ */ q("span", {
|
|
598
602
|
className: "text-sm",
|
|
599
603
|
children: e.label
|
|
600
604
|
})]
|
|
@@ -604,11 +608,11 @@ function Le({ id: e, options: t, selected: n, onChange: r, placeholder: i, disab
|
|
|
604
608
|
}
|
|
605
609
|
//#endregion
|
|
606
610
|
//#region src/base/form/fields/NativeSelectField.tsx
|
|
607
|
-
function
|
|
611
|
+
function ze({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: l }) {
|
|
608
612
|
let { t: u } = R(), d = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
609
|
-
return /* @__PURE__ */
|
|
613
|
+
return /* @__PURE__ */ q("div", {
|
|
610
614
|
className: "w-full [&>div]:w-full",
|
|
611
|
-
children: /* @__PURE__ */
|
|
615
|
+
children: /* @__PURE__ */ J(A, {
|
|
612
616
|
id: e,
|
|
613
617
|
value: t ?? "",
|
|
614
618
|
onChange: (e) => n(e.target.value),
|
|
@@ -617,11 +621,11 @@ function Re({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
617
621
|
"aria-required": o || void 0,
|
|
618
622
|
"aria-invalid": s ? !0 : void 0,
|
|
619
623
|
"aria-describedby": d,
|
|
620
|
-
children: [/* @__PURE__ */
|
|
624
|
+
children: [/* @__PURE__ */ q(j, {
|
|
621
625
|
value: "",
|
|
622
626
|
disabled: o,
|
|
623
627
|
children: i ?? u("middag.ui.form.select_placeholder")
|
|
624
|
-
}), r.map((e) => /* @__PURE__ */
|
|
628
|
+
}), r.map((e) => /* @__PURE__ */ q(j, {
|
|
625
629
|
value: e.value,
|
|
626
630
|
children: e.label
|
|
627
631
|
}, e.value))]
|
|
@@ -630,9 +634,9 @@ function Re({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
630
634
|
}
|
|
631
635
|
//#endregion
|
|
632
636
|
//#region src/base/form/fields/NumberField.tsx
|
|
633
|
-
function
|
|
637
|
+
function Be({ id: e, value: t, onChange: n, min: r, max: i, step: a = 1, disabled: o, required: s, error: c, helpTextId: l, errorId: u }) {
|
|
634
638
|
let d = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0;
|
|
635
|
-
return /* @__PURE__ */
|
|
639
|
+
return /* @__PURE__ */ q(te, {
|
|
636
640
|
id: e,
|
|
637
641
|
value: t ?? void 0,
|
|
638
642
|
onValueChange: (e) => n(e ?? null),
|
|
@@ -643,24 +647,24 @@ function X({ id: e, value: t, onChange: n, min: r, max: i, step: a = 1, disabled
|
|
|
643
647
|
"aria-invalid": c ? !0 : void 0,
|
|
644
648
|
"aria-required": s || void 0,
|
|
645
649
|
"aria-describedby": d,
|
|
646
|
-
children: /* @__PURE__ */
|
|
647
|
-
/* @__PURE__ */
|
|
648
|
-
/* @__PURE__ */
|
|
649
|
-
/* @__PURE__ */
|
|
650
|
+
children: /* @__PURE__ */ J(ne, { children: [
|
|
651
|
+
/* @__PURE__ */ q(M, {}),
|
|
652
|
+
/* @__PURE__ */ q(P, {}),
|
|
653
|
+
/* @__PURE__ */ q(N, {})
|
|
650
654
|
] })
|
|
651
655
|
});
|
|
652
656
|
}
|
|
653
657
|
//#endregion
|
|
654
658
|
//#region src/base/form/fields/OtpField.tsx
|
|
655
|
-
function
|
|
659
|
+
function Ve(e, t) {
|
|
656
660
|
if (!t || t >= e) return [Array.from({ length: e }, (e, t) => t)];
|
|
657
661
|
let n = [];
|
|
658
662
|
for (let r = 0; r < e; r += t) n.push(Array.from({ length: Math.min(t, e - r) }, (e, t) => r + t));
|
|
659
663
|
return n;
|
|
660
664
|
}
|
|
661
|
-
function
|
|
662
|
-
let d = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0, f = i === "alphanumeric" ?
|
|
663
|
-
return /* @__PURE__ */
|
|
665
|
+
function He({ id: e, value: t, onChange: n, maxLength: r = 6, pattern: i = "digits", groupSize: a, disabled: o, required: s, error: c, helpTextId: l, errorId: u }) {
|
|
666
|
+
let d = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0, f = i === "alphanumeric" ? ve : _e, p = Ve(r, a);
|
|
667
|
+
return /* @__PURE__ */ q(D, {
|
|
664
668
|
id: e,
|
|
665
669
|
maxLength: r,
|
|
666
670
|
value: t ?? "",
|
|
@@ -670,19 +674,19 @@ function Be({ id: e, value: t, onChange: n, maxLength: r = 6, pattern: i = "digi
|
|
|
670
674
|
"aria-invalid": c ? !0 : void 0,
|
|
671
675
|
"aria-required": s || void 0,
|
|
672
676
|
"aria-describedby": d,
|
|
673
|
-
children: p.map((e, t) => /* @__PURE__ */
|
|
677
|
+
children: p.map((e, t) => /* @__PURE__ */ J(le, { children: [/* @__PURE__ */ q(O, { children: e.map((e) => /* @__PURE__ */ q(k, {
|
|
674
678
|
index: e,
|
|
675
679
|
"aria-invalid": c ? !0 : void 0
|
|
676
|
-
}, e)) }), t < p.length - 1 && /* @__PURE__ */
|
|
680
|
+
}, e)) }), t < p.length - 1 && /* @__PURE__ */ q(ee, {})] }, e[0]))
|
|
677
681
|
});
|
|
678
682
|
}
|
|
679
683
|
//#endregion
|
|
680
684
|
//#region src/base/form/fields/PasswordField.tsx
|
|
681
|
-
function
|
|
682
|
-
let [d, f] =
|
|
683
|
-
return /* @__PURE__ */
|
|
685
|
+
function Ue({ id: e, value: n, onChange: r, placeholder: i, disabled: a, required: o, error: c, helpTextId: l, errorId: u }) {
|
|
686
|
+
let [d, f] = K(!1), p = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0;
|
|
687
|
+
return /* @__PURE__ */ J("div", {
|
|
684
688
|
className: "relative",
|
|
685
|
-
children: [/* @__PURE__ */
|
|
689
|
+
children: [/* @__PURE__ */ q(s, {
|
|
686
690
|
id: e,
|
|
687
691
|
type: d ? "text" : "password",
|
|
688
692
|
value: n ?? "",
|
|
@@ -693,7 +697,7 @@ function Ve({ id: e, value: n, onChange: r, placeholder: i, disabled: a, require
|
|
|
693
697
|
"aria-invalid": c ? !0 : void 0,
|
|
694
698
|
"aria-required": o || void 0,
|
|
695
699
|
"aria-describedby": p
|
|
696
|
-
}), /* @__PURE__ */
|
|
700
|
+
}), /* @__PURE__ */ q(t, {
|
|
697
701
|
type: "button",
|
|
698
702
|
variant: "ghost",
|
|
699
703
|
size: "icon",
|
|
@@ -701,8 +705,8 @@ function Ve({ id: e, value: n, onChange: r, placeholder: i, disabled: a, require
|
|
|
701
705
|
onClick: () => f(!d),
|
|
702
706
|
tabIndex: -1,
|
|
703
707
|
"aria-label": d ? "Hide password" : "Show password",
|
|
704
|
-
children: /* @__PURE__ */
|
|
705
|
-
icon: d ?
|
|
708
|
+
children: /* @__PURE__ */ q(Y, {
|
|
709
|
+
icon: d ? ge : he,
|
|
706
710
|
size: 16,
|
|
707
711
|
strokeWidth: 2
|
|
708
712
|
})
|
|
@@ -711,9 +715,9 @@ function Ve({ id: e, value: n, onChange: r, placeholder: i, disabled: a, require
|
|
|
711
715
|
}
|
|
712
716
|
//#endregion
|
|
713
717
|
//#region src/base/form/fields/RadioField.tsx
|
|
714
|
-
function
|
|
718
|
+
function We({ id: e, value: t, onChange: n, options: r, disabled: i, required: a, error: o, helpTextId: s, errorId: c }) {
|
|
715
719
|
let l = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0;
|
|
716
|
-
return /* @__PURE__ */
|
|
720
|
+
return /* @__PURE__ */ q(F, {
|
|
717
721
|
id: e,
|
|
718
722
|
value: t ?? "",
|
|
719
723
|
onValueChange: n,
|
|
@@ -723,12 +727,12 @@ function He({ id: e, value: t, onChange: n, options: r, disabled: i, required: a
|
|
|
723
727
|
"aria-describedby": l,
|
|
724
728
|
children: r.map((t) => {
|
|
725
729
|
let n = `${e}-${t.value}`;
|
|
726
|
-
return /* @__PURE__ */
|
|
730
|
+
return /* @__PURE__ */ J("div", {
|
|
727
731
|
className: "flex items-center gap-2",
|
|
728
|
-
children: [/* @__PURE__ */
|
|
732
|
+
children: [/* @__PURE__ */ q(re, {
|
|
729
733
|
value: t.value,
|
|
730
734
|
id: n
|
|
731
|
-
}), /* @__PURE__ */
|
|
735
|
+
}), /* @__PURE__ */ q(T, {
|
|
732
736
|
htmlFor: n,
|
|
733
737
|
className: "text-sm font-normal",
|
|
734
738
|
children: t.label
|
|
@@ -739,15 +743,15 @@ function He({ id: e, value: t, onChange: n, options: r, disabled: i, required: a
|
|
|
739
743
|
}
|
|
740
744
|
//#endregion
|
|
741
745
|
//#region src/base/form/fields/RatingField.tsx
|
|
742
|
-
function
|
|
746
|
+
function Ge({ id: e, value: t, onChange: n, maxRating: r = 5, disabled: i, required: a, error: o, helpTextId: s, errorId: c }) {
|
|
743
747
|
let l = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0;
|
|
744
|
-
return /* @__PURE__ */
|
|
748
|
+
return /* @__PURE__ */ q("div", {
|
|
745
749
|
id: e,
|
|
746
750
|
role: "radiogroup",
|
|
747
751
|
"aria-required": a || void 0,
|
|
748
752
|
"aria-invalid": o ? !0 : void 0,
|
|
749
753
|
"aria-describedby": l,
|
|
750
|
-
children: /* @__PURE__ */
|
|
754
|
+
children: /* @__PURE__ */ q(I, {
|
|
751
755
|
rating: t ?? 0,
|
|
752
756
|
maxRating: r,
|
|
753
757
|
editable: !i,
|
|
@@ -758,26 +762,26 @@ function Ue({ id: e, value: t, onChange: n, maxRating: r = 5, disabled: i, requi
|
|
|
758
762
|
}
|
|
759
763
|
//#endregion
|
|
760
764
|
//#region src/base/form/fields/SelectField.tsx
|
|
761
|
-
function
|
|
765
|
+
function Ke({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: l }) {
|
|
762
766
|
let { t: u } = R(), d = [s ? l : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
763
|
-
return /* @__PURE__ */
|
|
767
|
+
return /* @__PURE__ */ J(y, {
|
|
764
768
|
value: t ?? "",
|
|
765
769
|
onValueChange: n,
|
|
766
770
|
disabled: a,
|
|
767
771
|
required: o,
|
|
768
|
-
children: [/* @__PURE__ */
|
|
772
|
+
children: [/* @__PURE__ */ q(S, {
|
|
769
773
|
id: e,
|
|
770
774
|
className: "w-full",
|
|
771
775
|
"aria-invalid": s ? !0 : void 0,
|
|
772
776
|
"aria-required": o || void 0,
|
|
773
777
|
"aria-describedby": d,
|
|
774
|
-
children: /* @__PURE__ */
|
|
775
|
-
}), /* @__PURE__ */
|
|
778
|
+
children: /* @__PURE__ */ q(C, { placeholder: i ?? u("middag.ui.form.select_placeholder") })
|
|
779
|
+
}), /* @__PURE__ */ q(b, {
|
|
776
780
|
position: "popper",
|
|
777
781
|
sideOffset: 4,
|
|
778
782
|
align: "start",
|
|
779
783
|
className: "w-full",
|
|
780
|
-
children: r.map((e) => /* @__PURE__ */
|
|
784
|
+
children: r.map((e) => /* @__PURE__ */ q(x, {
|
|
781
785
|
value: e.value,
|
|
782
786
|
children: e.label
|
|
783
787
|
}, e.value))
|
|
@@ -786,11 +790,11 @@ function We({ id: e, value: t, onChange: n, options: r, placeholder: i, disabled
|
|
|
786
790
|
}
|
|
787
791
|
//#endregion
|
|
788
792
|
//#region src/base/form/fields/SliderField.tsx
|
|
789
|
-
function
|
|
793
|
+
function qe({ 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 }) {
|
|
790
794
|
let f = [l ? d : void 0, u].filter(Boolean).join(" ") || void 0, p = Array.isArray(t) ? t : t == null ? o ? [r, i] : [r] : [t], m = o ? p.join(" – ") : String(p[0] ?? r);
|
|
791
|
-
return /* @__PURE__ */
|
|
795
|
+
return /* @__PURE__ */ J("div", {
|
|
792
796
|
className: "flex items-center gap-4",
|
|
793
|
-
children: [/* @__PURE__ */
|
|
797
|
+
children: [/* @__PURE__ */ q(L, {
|
|
794
798
|
id: e,
|
|
795
799
|
value: p,
|
|
796
800
|
min: r,
|
|
@@ -801,7 +805,7 @@ function Ge({ id: e, value: t, onChange: n, min: r = 0, max: i = 100, step: a =
|
|
|
801
805
|
"aria-invalid": l ? !0 : void 0,
|
|
802
806
|
"aria-required": c || void 0,
|
|
803
807
|
"aria-describedby": f
|
|
804
|
-
}), /* @__PURE__ */
|
|
808
|
+
}), /* @__PURE__ */ q("span", {
|
|
805
809
|
"aria-hidden": "true",
|
|
806
810
|
className: "text-muted-foreground min-w-12 text-right text-sm tabular-nums",
|
|
807
811
|
children: m
|
|
@@ -810,14 +814,14 @@ function Ge({ id: e, value: t, onChange: n, min: r = 0, max: i = 100, step: a =
|
|
|
810
814
|
}
|
|
811
815
|
//#endregion
|
|
812
816
|
//#region src/base/form/fields/SlugField.tsx
|
|
813
|
-
function
|
|
817
|
+
function Je(e) {
|
|
814
818
|
return e.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
|
|
815
819
|
}
|
|
816
|
-
function
|
|
817
|
-
let [h, g] =
|
|
818
|
-
|
|
820
|
+
function Ye({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disabled: a, required: o, error: s, helpTextId: c, errorId: p, prefix: m }) {
|
|
821
|
+
let [h, g] = K(!1), _ = [s ? p : void 0, c].filter(Boolean).join(" ") || void 0;
|
|
822
|
+
U(() => {
|
|
819
823
|
if (!h && r !== void 0) {
|
|
820
|
-
let e =
|
|
824
|
+
let e = Je(r);
|
|
821
825
|
e !== t && n(e);
|
|
822
826
|
}
|
|
823
827
|
}, [
|
|
@@ -826,15 +830,15 @@ function qe({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disa
|
|
|
826
830
|
n,
|
|
827
831
|
t
|
|
828
832
|
]);
|
|
829
|
-
let v =
|
|
830
|
-
g(!0), n(
|
|
833
|
+
let v = H((e) => {
|
|
834
|
+
g(!0), n(Je(e.target.value));
|
|
831
835
|
}, [n]);
|
|
832
|
-
return m ? /* @__PURE__ */
|
|
836
|
+
return m ? /* @__PURE__ */ J(l, {
|
|
833
837
|
"data-disabled": a || void 0,
|
|
834
|
-
children: [/* @__PURE__ */
|
|
838
|
+
children: [/* @__PURE__ */ q(u, {
|
|
835
839
|
align: "inline-start",
|
|
836
|
-
children: /* @__PURE__ */
|
|
837
|
-
}), /* @__PURE__ */
|
|
840
|
+
children: /* @__PURE__ */ q(f, { children: m })
|
|
841
|
+
}), /* @__PURE__ */ q(d, {
|
|
838
842
|
id: e,
|
|
839
843
|
type: "text",
|
|
840
844
|
value: t ?? "",
|
|
@@ -845,9 +849,9 @@ function qe({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disa
|
|
|
845
849
|
"aria-required": o || void 0,
|
|
846
850
|
"aria-describedby": _
|
|
847
851
|
})]
|
|
848
|
-
}) : /* @__PURE__ */
|
|
852
|
+
}) : /* @__PURE__ */ q(l, {
|
|
849
853
|
"data-disabled": a || void 0,
|
|
850
|
-
children: /* @__PURE__ */
|
|
854
|
+
children: /* @__PURE__ */ q(d, {
|
|
851
855
|
id: e,
|
|
852
856
|
type: "text",
|
|
853
857
|
value: t ?? "",
|
|
@@ -862,8 +866,8 @@ function qe({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disa
|
|
|
862
866
|
}
|
|
863
867
|
//#endregion
|
|
864
868
|
//#region src/base/form/fields/StaticField.tsx
|
|
865
|
-
function
|
|
866
|
-
return /* @__PURE__ */
|
|
869
|
+
function Xe({ id: e, value: t }) {
|
|
870
|
+
return /* @__PURE__ */ q("p", {
|
|
867
871
|
id: e,
|
|
868
872
|
className: "border-input bg-muted/50 text-foreground rounded-md border px-3 py-2 text-sm",
|
|
869
873
|
children: t == null ? "—" : String(t)
|
|
@@ -871,11 +875,11 @@ function Je({ id: e, value: t }) {
|
|
|
871
875
|
}
|
|
872
876
|
//#endregion
|
|
873
877
|
//#region src/base/form/fields/SwitchField.tsx
|
|
874
|
-
function
|
|
878
|
+
function Ze({ id: e, value: t, onChange: n, label: r, disabled: i, required: a, error: o, helpTextId: s, errorId: c }) {
|
|
875
879
|
let l = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0;
|
|
876
|
-
return /* @__PURE__ */
|
|
880
|
+
return /* @__PURE__ */ J("div", {
|
|
877
881
|
className: "flex items-center gap-2",
|
|
878
|
-
children: [/* @__PURE__ */
|
|
882
|
+
children: [/* @__PURE__ */ q(E, {
|
|
879
883
|
id: e,
|
|
880
884
|
checked: !!t,
|
|
881
885
|
onCheckedChange: n,
|
|
@@ -883,7 +887,7 @@ function Ye({ id: e, value: t, onChange: n, label: r, disabled: i, required: a,
|
|
|
883
887
|
"aria-invalid": o ? !0 : void 0,
|
|
884
888
|
"aria-required": a || void 0,
|
|
885
889
|
"aria-describedby": l
|
|
886
|
-
}), r && /* @__PURE__ */
|
|
890
|
+
}), r && /* @__PURE__ */ q(T, {
|
|
887
891
|
htmlFor: e,
|
|
888
892
|
className: "text-sm font-normal",
|
|
889
893
|
children: r
|
|
@@ -892,17 +896,17 @@ function Ye({ id: e, value: t, onChange: n, label: r, disabled: i, required: a,
|
|
|
892
896
|
}
|
|
893
897
|
//#endregion
|
|
894
898
|
//#region src/base/form/fields/TagsField.tsx
|
|
895
|
-
function
|
|
896
|
-
let { t: u } = R(), [d, f] =
|
|
899
|
+
function Qe({ id: e, value: t, onChange: n, placeholder: r, disabled: i, required: a, error: o, helpTextId: s, errorId: c, maxTags: l }) {
|
|
900
|
+
let { t: u } = R(), [d, f] = K(""), p = G(null), m = W(() => t ?? [], [t]), h = [o ? c : void 0, s].filter(Boolean).join(" ") || void 0, g = H((e) => {
|
|
897
901
|
let t = e.trim();
|
|
898
902
|
t && (m.includes(t) || l && m.length >= l || (n([...m, t]), f("")));
|
|
899
903
|
}, [
|
|
900
904
|
m,
|
|
901
905
|
n,
|
|
902
906
|
l
|
|
903
|
-
]), _ =
|
|
907
|
+
]), _ = H((e) => {
|
|
904
908
|
n(m.filter((t, n) => n !== e));
|
|
905
|
-
}, [m, n]), v =
|
|
909
|
+
}, [m, n]), v = H((e) => {
|
|
906
910
|
e.key === "Enter" || e.key === "," ? (e.preventDefault(), g(d)) : e.key === "Backspace" && !d && m.length > 0 && _(m.length - 1);
|
|
907
911
|
}, [
|
|
908
912
|
d,
|
|
@@ -910,12 +914,12 @@ function Xe({ id: e, value: t, onChange: n, placeholder: r, disabled: i, require
|
|
|
910
914
|
g,
|
|
911
915
|
_
|
|
912
916
|
]);
|
|
913
|
-
return /* @__PURE__ */
|
|
917
|
+
return /* @__PURE__ */ J("div", {
|
|
914
918
|
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" : ""}`,
|
|
915
919
|
onClick: () => p.current?.focus(),
|
|
916
|
-
children: [m.map((e, t) => /* @__PURE__ */
|
|
920
|
+
children: [m.map((e, t) => /* @__PURE__ */ J("span", {
|
|
917
921
|
className: "bg-secondary text-secondary-foreground inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-medium",
|
|
918
|
-
children: [e, !i && /* @__PURE__ */
|
|
922
|
+
children: [e, !i && /* @__PURE__ */ q("button", {
|
|
919
923
|
type: "button",
|
|
920
924
|
onClick: (e) => {
|
|
921
925
|
e.stopPropagation(), _(t);
|
|
@@ -924,7 +928,7 @@ function Xe({ id: e, value: t, onChange: n, placeholder: r, disabled: i, require
|
|
|
924
928
|
"aria-label": `${u("middag.ui.form.tags_remove")} ${e}`,
|
|
925
929
|
children: "×"
|
|
926
930
|
})]
|
|
927
|
-
}, `${e}-${t}`)), /* @__PURE__ */
|
|
931
|
+
}, `${e}-${t}`)), /* @__PURE__ */ q("input", {
|
|
928
932
|
ref: p,
|
|
929
933
|
id: e,
|
|
930
934
|
type: "text",
|
|
@@ -943,9 +947,9 @@ function Xe({ id: e, value: t, onChange: n, placeholder: r, disabled: i, require
|
|
|
943
947
|
}
|
|
944
948
|
//#endregion
|
|
945
949
|
//#region src/base/form/fields/TextareaField.tsx
|
|
946
|
-
function
|
|
950
|
+
function $e({ id: e, value: t, onChange: n, placeholder: r, rows: i = 4, disabled: a, readOnly: o, required: s, error: l, helpTextId: u, errorId: d }) {
|
|
947
951
|
let f = [l ? d : void 0, u].filter(Boolean).join(" ") || void 0;
|
|
948
|
-
return /* @__PURE__ */
|
|
952
|
+
return /* @__PURE__ */ q(c, {
|
|
949
953
|
id: e,
|
|
950
954
|
value: t ?? "",
|
|
951
955
|
onChange: (e) => n(e.target.value),
|
|
@@ -962,7 +966,7 @@ function Ze({ id: e, value: t, onChange: n, placeholder: r, rows: i = 4, disable
|
|
|
962
966
|
//#region src/base/form/fields/TextField.tsx
|
|
963
967
|
function Z({ id: e, value: t, onChange: n, type: r = "text", placeholder: i, disabled: a, readOnly: o, required: c, error: l, helpTextId: u, errorId: d }) {
|
|
964
968
|
let f = [l ? d : void 0, u].filter(Boolean).join(" ") || void 0;
|
|
965
|
-
return /* @__PURE__ */
|
|
969
|
+
return /* @__PURE__ */ q(s, {
|
|
966
970
|
id: e,
|
|
967
971
|
type: r,
|
|
968
972
|
value: t ?? "",
|
|
@@ -977,51 +981,51 @@ function Z({ id: e, value: t, onChange: n, type: r = "text", placeholder: i, dis
|
|
|
977
981
|
}
|
|
978
982
|
//#endregion
|
|
979
983
|
//#region src/base/form/FormField.tsx
|
|
980
|
-
var
|
|
984
|
+
var et = V(() => import("../../../chunks/subpath-CJyJeTlw.js").then((e) => ({ default: e.PhoneField }))), tt = V(() => import("../../../chunks/subpath-DjkzcIPp.js").then((e) => ({ default: e.DateField }))), nt = V(() => import("../../../chunks/subpath-BYl-9lKg.js").then((e) => ({ default: e.DocumentField }))), rt = V(() => import("../../../chunks/subpath-DoiyWIYV.js").then((e) => ({ default: e.DateRangeField })));
|
|
981
985
|
function Q() {
|
|
982
|
-
return /* @__PURE__ */
|
|
986
|
+
return /* @__PURE__ */ q(w, { className: "h-9 w-full rounded-md" });
|
|
983
987
|
}
|
|
984
|
-
function
|
|
985
|
-
return /* @__PURE__ */
|
|
988
|
+
function it({ label: e }) {
|
|
989
|
+
return /* @__PURE__ */ q("div", {
|
|
986
990
|
className: "pt-4 pb-1",
|
|
987
|
-
children: /* @__PURE__ */
|
|
991
|
+
children: /* @__PURE__ */ q("h4", {
|
|
988
992
|
className: "text-foreground text-sm font-semibold",
|
|
989
993
|
children: e
|
|
990
994
|
})
|
|
991
995
|
});
|
|
992
996
|
}
|
|
993
|
-
function
|
|
994
|
-
return /* @__PURE__ */
|
|
997
|
+
function at({ id: e, value: t }) {
|
|
998
|
+
return /* @__PURE__ */ q("input", {
|
|
995
999
|
type: "hidden",
|
|
996
1000
|
id: e,
|
|
997
1001
|
value: String(t ?? "")
|
|
998
1002
|
});
|
|
999
1003
|
}
|
|
1000
|
-
function
|
|
1001
|
-
let { t: a } = R(), o =
|
|
1002
|
-
if (u === "header") return /* @__PURE__ */
|
|
1003
|
-
if (u === "hidden") return /* @__PURE__ */
|
|
1004
|
+
function ot({ field: e, value: t, onChange: n, error: r, sourceValues: i = {} }) {
|
|
1005
|
+
let { t: a } = R(), o = ue(), s = `field-${e.key}-${o}`, c = `${s}-help`, l = `${s}-error`, { component: u, props: d } = e;
|
|
1006
|
+
if (u === "header") return /* @__PURE__ */ q(it, { label: d.label });
|
|
1007
|
+
if (u === "hidden") return /* @__PURE__ */ q(at, {
|
|
1004
1008
|
id: s,
|
|
1005
1009
|
value: t
|
|
1006
1010
|
});
|
|
1007
|
-
let f =
|
|
1008
|
-
return /* @__PURE__ */
|
|
1011
|
+
let f = xe(e, i), p = Se(e, i), m = u === "checkbox" || u === "switch", h = st(u, s, t, n, d, r, c, l, a, i, f, p);
|
|
1012
|
+
return /* @__PURE__ */ J("div", {
|
|
1009
1013
|
className: "space-y-1.5",
|
|
1010
1014
|
children: [
|
|
1011
|
-
!m && /* @__PURE__ */
|
|
1015
|
+
!m && /* @__PURE__ */ J(T, {
|
|
1012
1016
|
htmlFor: s,
|
|
1013
|
-
children: [d.label, p && /* @__PURE__ */
|
|
1017
|
+
children: [d.label, p && /* @__PURE__ */ q("span", {
|
|
1014
1018
|
className: "text-destructive ml-0.5",
|
|
1015
1019
|
children: "*"
|
|
1016
1020
|
})]
|
|
1017
1021
|
}),
|
|
1018
|
-
d.helpText && /* @__PURE__ */
|
|
1022
|
+
d.helpText && /* @__PURE__ */ q("p", {
|
|
1019
1023
|
id: c,
|
|
1020
1024
|
className: "text-muted-foreground text-xs",
|
|
1021
1025
|
children: d.helpText
|
|
1022
1026
|
}),
|
|
1023
1027
|
h,
|
|
1024
|
-
r && /* @__PURE__ */
|
|
1028
|
+
r && /* @__PURE__ */ q("p", {
|
|
1025
1029
|
id: l,
|
|
1026
1030
|
className: "text-destructive text-xs",
|
|
1027
1031
|
"aria-live": "polite",
|
|
@@ -1030,7 +1034,7 @@ function it({ field: e, value: t, onChange: n, error: r, sourceValues: i = {} })
|
|
|
1030
1034
|
]
|
|
1031
1035
|
});
|
|
1032
1036
|
}
|
|
1033
|
-
function
|
|
1037
|
+
function st(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
1034
1038
|
let f = {
|
|
1035
1039
|
id: t,
|
|
1036
1040
|
error: a,
|
|
@@ -1040,7 +1044,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1040
1044
|
required: d
|
|
1041
1045
|
};
|
|
1042
1046
|
switch (e) {
|
|
1043
|
-
case "text": return /* @__PURE__ */
|
|
1047
|
+
case "text": return /* @__PURE__ */ q(Z, {
|
|
1044
1048
|
...f,
|
|
1045
1049
|
type: "text",
|
|
1046
1050
|
value: n,
|
|
@@ -1048,7 +1052,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1048
1052
|
placeholder: i.placeholder,
|
|
1049
1053
|
readOnly: i.readOnly
|
|
1050
1054
|
});
|
|
1051
|
-
case "email": return /* @__PURE__ */
|
|
1055
|
+
case "email": return /* @__PURE__ */ q(Z, {
|
|
1052
1056
|
...f,
|
|
1053
1057
|
type: "email",
|
|
1054
1058
|
value: n,
|
|
@@ -1056,7 +1060,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1056
1060
|
placeholder: i.placeholder,
|
|
1057
1061
|
readOnly: i.readOnly
|
|
1058
1062
|
});
|
|
1059
|
-
case "url": return /* @__PURE__ */
|
|
1063
|
+
case "url": return /* @__PURE__ */ q(Z, {
|
|
1060
1064
|
...f,
|
|
1061
1065
|
type: "url",
|
|
1062
1066
|
value: n,
|
|
@@ -1064,7 +1068,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1064
1068
|
placeholder: i.placeholder,
|
|
1065
1069
|
readOnly: i.readOnly
|
|
1066
1070
|
});
|
|
1067
|
-
case "textarea": return /* @__PURE__ */
|
|
1071
|
+
case "textarea": return /* @__PURE__ */ q($e, {
|
|
1068
1072
|
...f,
|
|
1069
1073
|
value: n,
|
|
1070
1074
|
onChange: r,
|
|
@@ -1072,13 +1076,13 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1072
1076
|
rows: i.rows,
|
|
1073
1077
|
readOnly: i.readOnly
|
|
1074
1078
|
});
|
|
1075
|
-
case "password": return /* @__PURE__ */
|
|
1079
|
+
case "password": return /* @__PURE__ */ q(Ue, {
|
|
1076
1080
|
...f,
|
|
1077
1081
|
value: n,
|
|
1078
1082
|
onChange: r,
|
|
1079
1083
|
placeholder: i.placeholder
|
|
1080
1084
|
});
|
|
1081
|
-
case "otp": return /* @__PURE__ */
|
|
1085
|
+
case "otp": return /* @__PURE__ */ q(He, {
|
|
1082
1086
|
...f,
|
|
1083
1087
|
value: n,
|
|
1084
1088
|
onChange: r,
|
|
@@ -1086,21 +1090,21 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1086
1090
|
pattern: i.pattern,
|
|
1087
1091
|
groupSize: i.groupSize
|
|
1088
1092
|
});
|
|
1089
|
-
case "select": return /* @__PURE__ */
|
|
1093
|
+
case "select": return /* @__PURE__ */ q(Ke, {
|
|
1090
1094
|
...f,
|
|
1091
1095
|
value: n,
|
|
1092
1096
|
onChange: r,
|
|
1093
1097
|
options: i.options ?? [],
|
|
1094
1098
|
placeholder: i.placeholder
|
|
1095
1099
|
});
|
|
1096
|
-
case "native_select": return /* @__PURE__ */
|
|
1100
|
+
case "native_select": return /* @__PURE__ */ q(ze, {
|
|
1097
1101
|
...f,
|
|
1098
1102
|
value: n,
|
|
1099
1103
|
onChange: r,
|
|
1100
1104
|
options: i.options ?? [],
|
|
1101
1105
|
placeholder: i.placeholder
|
|
1102
1106
|
});
|
|
1103
|
-
case "multiselect": return /* @__PURE__ */
|
|
1107
|
+
case "multiselect": return /* @__PURE__ */ q(Ie, {
|
|
1104
1108
|
...f,
|
|
1105
1109
|
value: n,
|
|
1106
1110
|
onChange: r,
|
|
@@ -1108,13 +1112,13 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1108
1112
|
placeholder: i.placeholder,
|
|
1109
1113
|
variant: i.variant
|
|
1110
1114
|
});
|
|
1111
|
-
case "radio": return /* @__PURE__ */
|
|
1115
|
+
case "radio": return /* @__PURE__ */ q(We, {
|
|
1112
1116
|
...f,
|
|
1113
1117
|
value: n,
|
|
1114
1118
|
onChange: r,
|
|
1115
1119
|
options: i.options ?? []
|
|
1116
1120
|
});
|
|
1117
|
-
case "int": return /* @__PURE__ */
|
|
1121
|
+
case "int": return /* @__PURE__ */ q(Be, {
|
|
1118
1122
|
...f,
|
|
1119
1123
|
value: n,
|
|
1120
1124
|
onChange: r,
|
|
@@ -1122,7 +1126,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1122
1126
|
max: i.max,
|
|
1123
1127
|
step: 1
|
|
1124
1128
|
});
|
|
1125
|
-
case "float": return /* @__PURE__ */
|
|
1129
|
+
case "float": return /* @__PURE__ */ q(Be, {
|
|
1126
1130
|
...f,
|
|
1127
1131
|
value: n,
|
|
1128
1132
|
onChange: r,
|
|
@@ -1130,7 +1134,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1130
1134
|
max: i.max,
|
|
1131
1135
|
step: i.step ?? .1
|
|
1132
1136
|
});
|
|
1133
|
-
case "slider": return /* @__PURE__ */
|
|
1137
|
+
case "slider": return /* @__PURE__ */ q(qe, {
|
|
1134
1138
|
...f,
|
|
1135
1139
|
value: n,
|
|
1136
1140
|
onChange: r,
|
|
@@ -1139,21 +1143,21 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1139
1143
|
step: i.step,
|
|
1140
1144
|
multiple: i.multiple
|
|
1141
1145
|
});
|
|
1142
|
-
case "checkbox": return /* @__PURE__ */
|
|
1146
|
+
case "checkbox": return /* @__PURE__ */ q(Te, {
|
|
1143
1147
|
...f,
|
|
1144
1148
|
value: n,
|
|
1145
1149
|
onChange: r,
|
|
1146
1150
|
label: i.label
|
|
1147
1151
|
});
|
|
1148
|
-
case "switch": return /* @__PURE__ */
|
|
1152
|
+
case "switch": return /* @__PURE__ */ q(Ze, {
|
|
1149
1153
|
...f,
|
|
1150
1154
|
value: n,
|
|
1151
1155
|
onChange: r,
|
|
1152
1156
|
label: i.label
|
|
1153
1157
|
});
|
|
1154
|
-
case "date": return /* @__PURE__ */
|
|
1155
|
-
fallback: /* @__PURE__ */
|
|
1156
|
-
children: /* @__PURE__ */
|
|
1158
|
+
case "date": return /* @__PURE__ */ q(B, {
|
|
1159
|
+
fallback: /* @__PURE__ */ q(Q, {}),
|
|
1160
|
+
children: /* @__PURE__ */ q(tt, {
|
|
1157
1161
|
...f,
|
|
1158
1162
|
mode: "date",
|
|
1159
1163
|
value: n,
|
|
@@ -1161,9 +1165,9 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1161
1165
|
placeholder: i.placeholder
|
|
1162
1166
|
})
|
|
1163
1167
|
});
|
|
1164
|
-
case "datetime": return /* @__PURE__ */
|
|
1165
|
-
fallback: /* @__PURE__ */
|
|
1166
|
-
children: /* @__PURE__ */
|
|
1168
|
+
case "datetime": return /* @__PURE__ */ q(B, {
|
|
1169
|
+
fallback: /* @__PURE__ */ q(Q, {}),
|
|
1170
|
+
children: /* @__PURE__ */ q(tt, {
|
|
1167
1171
|
...f,
|
|
1168
1172
|
mode: "datetime",
|
|
1169
1173
|
value: n,
|
|
@@ -1171,7 +1175,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1171
1175
|
placeholder: i.placeholder
|
|
1172
1176
|
})
|
|
1173
1177
|
});
|
|
1174
|
-
case "file": return /* @__PURE__ */
|
|
1178
|
+
case "file": return /* @__PURE__ */ q(Pe, {
|
|
1175
1179
|
...f,
|
|
1176
1180
|
value: n,
|
|
1177
1181
|
onChange: r,
|
|
@@ -1180,7 +1184,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1180
1184
|
maxFiles: i.maxFiles,
|
|
1181
1185
|
maxSize: i.maxSize
|
|
1182
1186
|
});
|
|
1183
|
-
case "entity_picker": return /* @__PURE__ */
|
|
1187
|
+
case "entity_picker": return /* @__PURE__ */ q(Ae, {
|
|
1184
1188
|
...f,
|
|
1185
1189
|
value: n,
|
|
1186
1190
|
onChange: r,
|
|
@@ -1192,13 +1196,13 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1192
1196
|
entitySubtitleField: i.entitySubtitleField,
|
|
1193
1197
|
placeholder: i.placeholder
|
|
1194
1198
|
});
|
|
1195
|
-
case "static": return /* @__PURE__ */
|
|
1199
|
+
case "static": return /* @__PURE__ */ q(Xe, {
|
|
1196
1200
|
id: t,
|
|
1197
1201
|
value: n
|
|
1198
1202
|
});
|
|
1199
|
-
case "phone": return /* @__PURE__ */
|
|
1200
|
-
fallback: /* @__PURE__ */
|
|
1201
|
-
children: /* @__PURE__ */
|
|
1203
|
+
case "phone": return /* @__PURE__ */ q(B, {
|
|
1204
|
+
fallback: /* @__PURE__ */ q(Q, {}),
|
|
1205
|
+
children: /* @__PURE__ */ q(et, {
|
|
1202
1206
|
...f,
|
|
1203
1207
|
value: n,
|
|
1204
1208
|
onChange: r,
|
|
@@ -1207,9 +1211,9 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1207
1211
|
fixedCountry: i.fixedCountry
|
|
1208
1212
|
})
|
|
1209
1213
|
});
|
|
1210
|
-
case "document": return /* @__PURE__ */
|
|
1211
|
-
fallback: /* @__PURE__ */
|
|
1212
|
-
children: /* @__PURE__ */
|
|
1214
|
+
case "document": return /* @__PURE__ */ q(B, {
|
|
1215
|
+
fallback: /* @__PURE__ */ q(Q, {}),
|
|
1216
|
+
children: /* @__PURE__ */ q(nt, {
|
|
1213
1217
|
...f,
|
|
1214
1218
|
value: n,
|
|
1215
1219
|
onChange: r,
|
|
@@ -1219,7 +1223,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1219
1223
|
placeholder: i.placeholder
|
|
1220
1224
|
})
|
|
1221
1225
|
});
|
|
1222
|
-
case "currency": return /* @__PURE__ */
|
|
1226
|
+
case "currency": return /* @__PURE__ */ q(Oe, {
|
|
1223
1227
|
...f,
|
|
1224
1228
|
value: n,
|
|
1225
1229
|
onChange: r,
|
|
@@ -1228,13 +1232,13 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1228
1232
|
min: i.min,
|
|
1229
1233
|
max: i.max
|
|
1230
1234
|
});
|
|
1231
|
-
case "color": return /* @__PURE__ */
|
|
1235
|
+
case "color": return /* @__PURE__ */ q(Ee, {
|
|
1232
1236
|
...f,
|
|
1233
1237
|
value: n,
|
|
1234
1238
|
onChange: r,
|
|
1235
1239
|
placeholder: i.placeholder
|
|
1236
1240
|
});
|
|
1237
|
-
case "slug": return /* @__PURE__ */
|
|
1241
|
+
case "slug": return /* @__PURE__ */ q(Ye, {
|
|
1238
1242
|
...f,
|
|
1239
1243
|
value: n,
|
|
1240
1244
|
onChange: r,
|
|
@@ -1242,29 +1246,29 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1242
1246
|
prefix: i.prefix,
|
|
1243
1247
|
placeholder: i.placeholder
|
|
1244
1248
|
});
|
|
1245
|
-
case "tags": return /* @__PURE__ */
|
|
1249
|
+
case "tags": return /* @__PURE__ */ q(Qe, {
|
|
1246
1250
|
...f,
|
|
1247
1251
|
value: n,
|
|
1248
1252
|
onChange: r,
|
|
1249
1253
|
placeholder: i.placeholder,
|
|
1250
1254
|
maxTags: i.maxTags
|
|
1251
1255
|
});
|
|
1252
|
-
case "date_range": return /* @__PURE__ */
|
|
1253
|
-
fallback: /* @__PURE__ */
|
|
1254
|
-
children: /* @__PURE__ */
|
|
1256
|
+
case "date_range": return /* @__PURE__ */ q(B, {
|
|
1257
|
+
fallback: /* @__PURE__ */ q(Q, {}),
|
|
1258
|
+
children: /* @__PURE__ */ q(rt, {
|
|
1255
1259
|
...f,
|
|
1256
1260
|
value: n,
|
|
1257
1261
|
onChange: r,
|
|
1258
1262
|
operator: i.operator
|
|
1259
1263
|
})
|
|
1260
1264
|
});
|
|
1261
|
-
case "rating": return /* @__PURE__ */
|
|
1265
|
+
case "rating": return /* @__PURE__ */ q(Ge, {
|
|
1262
1266
|
...f,
|
|
1263
1267
|
value: n,
|
|
1264
1268
|
onChange: r,
|
|
1265
1269
|
maxRating: i.maxRating
|
|
1266
1270
|
});
|
|
1267
|
-
default: return /* @__PURE__ */
|
|
1271
|
+
default: return /* @__PURE__ */ J("p", {
|
|
1268
1272
|
className: "text-destructive text-xs",
|
|
1269
1273
|
children: ["Unknown field component: ", e]
|
|
1270
1274
|
});
|
|
@@ -1272,7 +1276,7 @@ function at(e, t, n, r, i, a, o, s, c, l, u, d) {
|
|
|
1272
1276
|
}
|
|
1273
1277
|
//#endregion
|
|
1274
1278
|
//#region src/base/shell/partials/InlineEditablePanel.tsx
|
|
1275
|
-
function
|
|
1279
|
+
function ct(e) {
|
|
1276
1280
|
switch (e.component) {
|
|
1277
1281
|
case "int":
|
|
1278
1282
|
case "float":
|
|
@@ -1286,31 +1290,31 @@ function ot(e) {
|
|
|
1286
1290
|
default: return "";
|
|
1287
1291
|
}
|
|
1288
1292
|
}
|
|
1289
|
-
function
|
|
1290
|
-
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] :
|
|
1293
|
+
function lt(e, t) {
|
|
1294
|
+
return Object.prototype.hasOwnProperty.call(t, e.key) ? t[e.key] : ct(e);
|
|
1291
1295
|
}
|
|
1292
1296
|
function $(t, n, r, i) {
|
|
1293
1297
|
return t.map((t, a) => {
|
|
1294
1298
|
switch (t.kind) {
|
|
1295
|
-
case "field": return
|
|
1299
|
+
case "field": return be(t, n) ? /* @__PURE__ */ q(ot, {
|
|
1296
1300
|
field: t,
|
|
1297
|
-
value:
|
|
1301
|
+
value: lt(t, n),
|
|
1298
1302
|
onChange: (e) => i(t.key, e),
|
|
1299
1303
|
error: r[t.key],
|
|
1300
1304
|
sourceValues: n
|
|
1301
1305
|
}, t.key) : null;
|
|
1302
|
-
case "header": return /* @__PURE__ */
|
|
1306
|
+
case "header": return /* @__PURE__ */ q("h4", {
|
|
1303
1307
|
className: "text-foreground pt-2 text-sm font-semibold",
|
|
1304
1308
|
children: t.label
|
|
1305
1309
|
}, `header-${a}`);
|
|
1306
|
-
case "section": return /* @__PURE__ */
|
|
1310
|
+
case "section": return /* @__PURE__ */ J("section", {
|
|
1307
1311
|
className: "space-y-3",
|
|
1308
|
-
children: [/* @__PURE__ */
|
|
1312
|
+
children: [/* @__PURE__ */ q("div", {
|
|
1309
1313
|
className: "text-muted-foreground text-[11px] font-medium tracking-[0.04em] uppercase",
|
|
1310
1314
|
children: t.label
|
|
1311
1315
|
}), $(t.children, n, r, i)]
|
|
1312
1316
|
}, t.id);
|
|
1313
|
-
case "group": return /* @__PURE__ */
|
|
1317
|
+
case "group": return /* @__PURE__ */ q("div", {
|
|
1314
1318
|
className: e(t.columns === 2 ? "grid grid-cols-2 gap-3" : "space-y-3"),
|
|
1315
1319
|
children: $(t.children, n, r, i)
|
|
1316
1320
|
}, t.id);
|
|
@@ -1318,10 +1322,10 @@ function $(t, n, r, i) {
|
|
|
1318
1322
|
}
|
|
1319
1323
|
});
|
|
1320
1324
|
}
|
|
1321
|
-
function
|
|
1322
|
-
let { t: e } = R(), { enabled: n, selectedId: r, descriptor: i, loading: a, saving: o, submit: s, close: c, width: l } = ie(), [u, d] =
|
|
1325
|
+
function ut() {
|
|
1326
|
+
let { t: e } = R(), { enabled: n, selectedId: r, descriptor: i, loading: a, saving: o, submit: s, close: c, width: l } = ie(), [u, d] = K(() => i?.values ? { ...i.values } : {}), [f, p] = K({}), [m, h] = K(i);
|
|
1323
1327
|
i !== m && (h(i), d(i?.values ? { ...i.values } : {}), p({}));
|
|
1324
|
-
let [g, _] =
|
|
1328
|
+
let [g, _] = K(null), v = g ?? l, y = W(() => (e, t) => {
|
|
1325
1329
|
d((n) => ({
|
|
1326
1330
|
...n,
|
|
1327
1331
|
[e]: t
|
|
@@ -1331,90 +1335,88 @@ function ct() {
|
|
|
1331
1335
|
return delete n[e], n;
|
|
1332
1336
|
});
|
|
1333
1337
|
}, []);
|
|
1334
|
-
|
|
1335
|
-
let b = (e) => {
|
|
1336
|
-
e.preventDefault();
|
|
1337
|
-
let t = e.clientX, n = v, r = (e) => {
|
|
1338
|
-
_(Math.min(720, Math.max(320, n + (t - e.clientX))));
|
|
1339
|
-
}, i = () => {
|
|
1340
|
-
window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", i);
|
|
1341
|
-
};
|
|
1342
|
-
window.addEventListener("pointermove", r), window.addEventListener("pointerup", i);
|
|
1343
|
-
}, x = () => {
|
|
1344
|
-
if (!i) return;
|
|
1345
|
-
let t = Ce(i.schema, u, e).safeParse(u);
|
|
1346
|
-
if (!t.success) {
|
|
1347
|
-
let e = {};
|
|
1348
|
-
for (let n of t.error.issues) {
|
|
1349
|
-
let t = String(n.path[0] ?? "");
|
|
1350
|
-
t && !e[t] && (e[t] = n.message);
|
|
1351
|
-
}
|
|
1352
|
-
p(e);
|
|
1353
|
-
return;
|
|
1354
|
-
}
|
|
1355
|
-
s(t.data);
|
|
1356
|
-
};
|
|
1357
|
-
return /* @__PURE__ */ q(ue, { children: [/* @__PURE__ */ K("div", {
|
|
1338
|
+
return !n || r === null ? null : /* @__PURE__ */ J(de, { children: [/* @__PURE__ */ q("div", {
|
|
1358
1339
|
className: "fixed inset-0 z-40 bg-black/40",
|
|
1359
1340
|
onClick: c,
|
|
1360
1341
|
"aria-hidden": !0
|
|
1361
|
-
}), /* @__PURE__ */
|
|
1342
|
+
}), /* @__PURE__ */ J("div", {
|
|
1362
1343
|
role: "dialog",
|
|
1363
1344
|
"aria-modal": "true",
|
|
1364
1345
|
className: "bg-background fixed top-0 right-0 bottom-0 z-50 flex flex-col overflow-hidden border-l shadow-2xl",
|
|
1365
1346
|
style: { width: v },
|
|
1366
1347
|
children: [
|
|
1367
|
-
/* @__PURE__ */
|
|
1368
|
-
onPointerDown:
|
|
1348
|
+
/* @__PURE__ */ q("div", {
|
|
1349
|
+
onPointerDown: (e) => {
|
|
1350
|
+
e.preventDefault();
|
|
1351
|
+
let t = e.clientX, n = v, r = (e) => {
|
|
1352
|
+
_(Math.min(720, Math.max(320, n + (t - e.clientX))));
|
|
1353
|
+
}, i = () => {
|
|
1354
|
+
window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", i);
|
|
1355
|
+
};
|
|
1356
|
+
window.addEventListener("pointermove", r), window.addEventListener("pointerup", i);
|
|
1357
|
+
},
|
|
1369
1358
|
className: "hover:bg-primary/30 absolute top-0 bottom-0 left-0 z-10 w-1.5 cursor-col-resize",
|
|
1370
1359
|
"aria-hidden": !0
|
|
1371
1360
|
}),
|
|
1372
|
-
/* @__PURE__ */
|
|
1361
|
+
/* @__PURE__ */ J("div", {
|
|
1373
1362
|
className: "border-border/60 flex items-start gap-2 border-b px-4 pt-3 pb-2.5",
|
|
1374
|
-
children: [/* @__PURE__ */
|
|
1363
|
+
children: [/* @__PURE__ */ J("div", {
|
|
1375
1364
|
className: "min-w-0 flex-1",
|
|
1376
|
-
children: [i?.subtitle && /* @__PURE__ */
|
|
1365
|
+
children: [i?.subtitle && /* @__PURE__ */ q("div", {
|
|
1377
1366
|
className: "text-muted-foreground mb-0.5 font-mono text-[11px] font-semibold tracking-wide uppercase",
|
|
1378
1367
|
children: i.subtitle
|
|
1379
|
-
}), /* @__PURE__ */
|
|
1368
|
+
}), /* @__PURE__ */ q("h3", {
|
|
1380
1369
|
className: "text-foreground truncate text-base leading-snug font-semibold",
|
|
1381
1370
|
children: i?.title ?? e("middag.ui.loading")
|
|
1382
1371
|
})]
|
|
1383
|
-
}), /* @__PURE__ */
|
|
1372
|
+
}), /* @__PURE__ */ q("button", {
|
|
1384
1373
|
type: "button",
|
|
1385
1374
|
onClick: c,
|
|
1386
1375
|
"aria-label": e("middag.ui.editable_panel.close"),
|
|
1387
1376
|
className: "text-muted-foreground hover:text-foreground hover:bg-muted rounded p-1 transition-colors",
|
|
1388
|
-
children: /* @__PURE__ */
|
|
1377
|
+
children: /* @__PURE__ */ q("span", {
|
|
1389
1378
|
"aria-hidden": !0,
|
|
1390
1379
|
className: "text-sm leading-none",
|
|
1391
1380
|
children: "✕"
|
|
1392
1381
|
})
|
|
1393
1382
|
})]
|
|
1394
1383
|
}),
|
|
1395
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ q("div", {
|
|
1396
1385
|
className: "min-h-0 flex-1 overflow-y-auto p-4",
|
|
1397
|
-
children: a || !i ? /* @__PURE__ */
|
|
1386
|
+
children: a || !i ? /* @__PURE__ */ q("div", {
|
|
1398
1387
|
className: "flex items-center justify-center p-8",
|
|
1399
|
-
children: /* @__PURE__ */
|
|
1400
|
-
}) : /* @__PURE__ */
|
|
1388
|
+
children: /* @__PURE__ */ q("div", { className: "border-primary h-6 w-6 animate-spin rounded-full border-2 border-t-transparent" })
|
|
1389
|
+
}) : /* @__PURE__ */ q("div", {
|
|
1401
1390
|
className: "space-y-3.5",
|
|
1402
1391
|
children: $(i.schema, u, f, y)
|
|
1403
1392
|
})
|
|
1404
1393
|
}),
|
|
1405
|
-
i && !a && /* @__PURE__ */
|
|
1394
|
+
i && !a && /* @__PURE__ */ J("div", {
|
|
1406
1395
|
className: "flex justify-end gap-2 border-t p-3",
|
|
1407
|
-
children: [/* @__PURE__ */
|
|
1396
|
+
children: [/* @__PURE__ */ q(t, {
|
|
1408
1397
|
type: "button",
|
|
1409
1398
|
variant: "outline",
|
|
1410
1399
|
size: "sm",
|
|
1411
1400
|
onClick: c,
|
|
1412
1401
|
disabled: o,
|
|
1413
1402
|
children: i.cancelLabel ?? e("middag.ui.cancel")
|
|
1414
|
-
}), /* @__PURE__ */
|
|
1403
|
+
}), /* @__PURE__ */ q(t, {
|
|
1415
1404
|
type: "button",
|
|
1416
1405
|
size: "sm",
|
|
1417
|
-
onClick:
|
|
1406
|
+
onClick: () => {
|
|
1407
|
+
if (!i) return;
|
|
1408
|
+
let t = we(i.schema, u, e).safeParse(u);
|
|
1409
|
+
if (!t.success) {
|
|
1410
|
+
let e = {};
|
|
1411
|
+
for (let n of t.error.issues) {
|
|
1412
|
+
let t = String(n.path[0] ?? "");
|
|
1413
|
+
t && !e[t] && (e[t] = n.message);
|
|
1414
|
+
}
|
|
1415
|
+
p(e);
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
s(t.data);
|
|
1419
|
+
},
|
|
1418
1420
|
disabled: o,
|
|
1419
1421
|
children: i.submitLabel ?? e("middag.ui.form.save")
|
|
1420
1422
|
})]
|
|
@@ -1423,4 +1425,4 @@ function ct() {
|
|
|
1423
1425
|
})] });
|
|
1424
1426
|
}
|
|
1425
1427
|
//#endregion
|
|
1426
|
-
export {
|
|
1428
|
+
export { ut as InlineEditablePanel };
|