@gspa/ui 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.cjs +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
- package/dist/components/Accordion.cjs +1 -0
- package/dist/components/Accordion.js +192 -0
- package/dist/components/AccordionItem.cjs +1 -0
- package/dist/components/AccordionItem.js +109 -0
- package/dist/components/AddReminderModal.cjs +1 -0
- package/dist/components/AddReminderModal.js +107 -0
- package/dist/components/Alert.cjs +1 -0
- package/dist/components/Alert.js +222 -0
- package/dist/components/Avatar.cjs +1 -0
- package/dist/components/Avatar.js +86 -0
- package/dist/components/Badge.cjs +1 -0
- package/dist/components/Badge.js +109 -0
- package/dist/components/Breadcrumb.cjs +1 -0
- package/dist/components/Breadcrumb.js +72 -0
- package/dist/components/Button.cjs +1 -0
- package/dist/components/Button.js +190 -0
- package/dist/components/ButtonGroup.cjs +1 -0
- package/dist/components/ButtonGroup.js +46 -0
- package/dist/components/Calendar.cjs +1 -0
- package/dist/components/Calendar.js +341 -0
- package/dist/components/Card.cjs +1 -0
- package/dist/components/Card.js +316 -0
- package/dist/components/CardBody.cjs +1 -0
- package/dist/components/CardBody.js +34 -0
- package/dist/components/CardContent.cjs +1 -0
- package/dist/components/CardContent.js +17 -0
- package/dist/components/CardFooter.cjs +1 -0
- package/dist/components/CardFooter.js +34 -0
- package/dist/components/CardHeader.cjs +1 -0
- package/dist/components/CardHeader.js +91 -0
- package/dist/components/CardTitle.cjs +1 -0
- package/dist/components/CardTitle.js +17 -0
- package/dist/components/Checkbox.cjs +1 -0
- package/dist/components/Checkbox.js +185 -0
- package/dist/components/CircularProgress.cjs +1 -0
- package/dist/components/CircularProgress.js +141 -0
- package/dist/components/DataTable.cjs +1 -0
- package/dist/components/DataTable.js +863 -0
- package/dist/components/DataTableCell.cjs +1 -0
- package/dist/components/DataTableCell.js +95 -0
- package/dist/components/DataTableFilters.cjs +1 -0
- package/dist/components/DataTableFilters.js +519 -0
- package/dist/components/DataTableHeader.cjs +1 -0
- package/dist/components/DataTableHeader.js +116 -0
- package/dist/components/DataTablePagination.cjs +1 -0
- package/dist/components/DataTablePagination.js +290 -0
- package/dist/components/DataTableRow.cjs +1 -0
- package/dist/components/DataTableRow.js +199 -0
- package/dist/components/DataTableToolBar.cjs +1 -0
- package/dist/components/DataTableToolBar.js +477 -0
- package/dist/components/DatePicker.cjs +1 -0
- package/dist/components/DatePicker.js +401 -0
- package/dist/components/Divider.cjs +1 -0
- package/dist/components/Divider.js +103 -0
- package/dist/components/Dropdown.cjs +1 -0
- package/dist/components/Dropdown.js +104 -0
- package/dist/components/DropdownItem.cjs +1 -0
- package/dist/components/DropdownItem.js +60 -0
- package/dist/components/EventsCalendar.cjs +1 -0
- package/dist/components/EventsCalendar.js +863 -0
- package/dist/components/FileUpload.cjs +1 -0
- package/dist/components/FileUpload.js +195 -0
- package/dist/components/FilterDrawer.cjs +1 -0
- package/dist/components/FilterDrawer.js +412 -0
- package/dist/components/Footer.cjs +1 -0
- package/dist/components/Footer.js +157 -0
- package/dist/components/FormField.cjs +1 -0
- package/dist/components/FormField.js +190 -0
- package/dist/components/Graph.cjs +1 -0
- package/dist/components/Graph.js +164 -0
- package/dist/components/GraphFilters.cjs +1 -0
- package/dist/components/GraphFilters.js +305 -0
- package/dist/components/Header.cjs +1 -0
- package/dist/components/Header.js +674 -0
- package/dist/components/Icon.cjs +1 -0
- package/dist/components/Icon.js +51 -0
- package/dist/components/Image.cjs +1 -0
- package/dist/components/Image.js +112 -0
- package/dist/components/Input.cjs +1 -0
- package/dist/components/Input.js +166 -0
- package/dist/components/InputGroup.cjs +1 -0
- package/dist/components/InputGroup.js +45 -0
- package/dist/components/Label.cjs +1 -0
- package/dist/components/Label.js +46 -0
- package/dist/components/Link.cjs +1 -0
- package/dist/components/Link.js +119 -0
- package/dist/components/ListItem.cjs +1 -0
- package/dist/components/ListItem.js +89 -0
- package/dist/components/Loader.cjs +1 -0
- package/dist/components/Loader.js +154 -0
- package/dist/components/Logo.cjs +1 -0
- package/dist/components/Logo.js +67 -0
- package/dist/components/MenuItem.cjs +1 -0
- package/dist/components/MenuItem.js +66 -0
- package/dist/components/Modal.cjs +1 -0
- package/dist/components/Modal.js +110 -0
- package/dist/components/ModalBody.cjs +1 -0
- package/dist/components/ModalBody.js +33 -0
- package/dist/components/ModalFooter.cjs +1 -0
- package/dist/components/ModalFooter.js +33 -0
- package/dist/components/ModalHeader.cjs +1 -0
- package/dist/components/ModalHeader.js +24 -0
- package/dist/components/MultiSelect.cjs +1 -0
- package/dist/components/MultiSelect.js +211 -0
- package/dist/components/Notification.cjs +1 -0
- package/dist/components/Notification.js +121 -0
- package/dist/components/Option.cjs +1 -0
- package/dist/components/Option.js +44 -0
- package/dist/components/Progress.cjs +1 -0
- package/dist/components/Progress.js +77 -0
- package/dist/components/ProgressBar.cjs +1 -0
- package/dist/components/ProgressBar.js +101 -0
- package/dist/components/Radio.cjs +1 -0
- package/dist/components/Radio.js +81 -0
- package/dist/components/RailNav.cjs +1 -0
- package/dist/components/RailNav.js +124 -0
- package/dist/components/ReminderConfig.cjs +1 -0
- package/dist/components/ReminderConfig.js +375 -0
- package/dist/components/ReusableForm.cjs +1 -0
- package/dist/components/ReusableForm.js +657 -0
- package/dist/components/ReusableFormModal.cjs +1 -0
- package/dist/components/ReusableFormModal.js +112 -0
- package/dist/components/RightDrawer.cjs +1 -0
- package/dist/components/RightDrawer.js +143 -0
- package/dist/components/Search.cjs +1 -0
- package/dist/components/Search.js +252 -0
- package/dist/components/Select.cjs +1 -0
- package/dist/components/Select.js +243 -0
- package/dist/components/Sidebar.cjs +1 -0
- package/dist/components/Sidebar.js +372 -0
- package/dist/components/Slider.cjs +1 -0
- package/dist/components/Slider.js +42 -0
- package/dist/components/Spinner.cjs +1 -0
- package/dist/components/Spinner.js +87 -0
- package/dist/components/Stepper.cjs +1 -0
- package/dist/components/Stepper.js +12 -0
- package/dist/components/StepperItem.cjs +1 -0
- package/dist/components/StepperItem.js +33 -0
- package/dist/components/Switch.cjs +1 -0
- package/dist/components/Switch.js +112 -0
- package/dist/components/Tab.cjs +1 -0
- package/dist/components/Tab.js +134 -0
- package/dist/components/TabPanel.cjs +1 -0
- package/dist/components/TabPanel.js +49 -0
- package/dist/components/Text.cjs +1 -0
- package/dist/components/Text.js +84 -0
- package/dist/components/Textarea.cjs +1 -0
- package/dist/components/Textarea.js +102 -0
- package/dist/components/ThemeConfigurator.cjs +1 -0
- package/dist/components/ThemeConfigurator.js +50 -0
- package/dist/components/Timeline.cjs +1 -0
- package/dist/components/Timeline.js +24 -0
- package/dist/components/TimelineItem.cjs +1 -0
- package/dist/components/TimelineItem.js +63 -0
- package/dist/components/Toast.cjs +1 -0
- package/dist/components/Toast.js +231 -0
- package/dist/components/Tooltip.cjs +1 -0
- package/dist/components/Tooltip.js +124 -0
- package/dist/components/Typography.cjs +1 -0
- package/dist/components/Typography.js +267 -0
- package/dist/components/charts/BarChart.cjs +1 -0
- package/dist/components/charts/BarChart.js +323 -0
- package/dist/components/charts/LineChart.cjs +1 -0
- package/dist/components/charts/LineChart.js +322 -0
- package/dist/components/charts/PieChart.cjs +1 -0
- package/dist/components/charts/PieChart.js +311 -0
- package/dist/components/charts/StackedBarChart.cjs +1 -0
- package/dist/components/charts/StackedBarChart.js +348 -0
- package/dist/components/widgets/DashboardWidget.cjs +1 -0
- package/dist/components/widgets/DashboardWidget.js +309 -0
- package/dist/directives/tooltip.cjs +47 -0
- package/dist/directives/tooltip.js +115 -0
- package/dist/index.cjs +1 -0
- package/dist/index.esm.js +311 -19548
- package/dist/layouts/AuthLayout.cjs +1 -0
- package/dist/layouts/AuthLayout.js +190 -0
- package/dist/layouts/DashboardLayout.cjs +1 -0
- package/dist/layouts/DashboardLayout.js +244 -0
- package/dist/layouts/DefaultLayout.cjs +1 -0
- package/dist/layouts/DefaultLayout.js +94 -0
- package/dist/layouts/ErrorLayout.cjs +1 -0
- package/dist/layouts/ErrorLayout.js +452 -0
- package/dist/lib/auth.cjs +1 -0
- package/dist/lib/auth.js +4 -0
- package/dist/lib/theme.cjs +1 -0
- package/dist/lib/theme.js +135 -0
- package/dist/lib/toast.cjs +1 -0
- package/dist/lib/toast.js +81 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/cn.cjs +1 -0
- package/dist/utils/cn.js +7 -0
- package/package.json +37 -7
- package/dist/index.js +0 -605
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
import { useSlots as De, computed as A, ref as D, watch as re, resolveComponent as Me, createElementBlock as u, openBlock as r, createCommentVNode as w, createElementVNode as C, toDisplayString as k, withModifiers as ze, renderSlot as N, Fragment as H, renderList as J, normalizeClass as v, createBlock as x, withCtx as V, createVNode as _, createTextVNode as F } from "vue";
|
|
2
|
+
import Re from "./Slider.js";
|
|
3
|
+
import le from "./DatePicker.js";
|
|
4
|
+
import Pe from "./FormField.js";
|
|
5
|
+
import S from "./Input.js";
|
|
6
|
+
import je from "./Textarea.js";
|
|
7
|
+
import ie from "./Select.js";
|
|
8
|
+
import Le from "./MultiSelect.js";
|
|
9
|
+
import M from "./Button.js";
|
|
10
|
+
import G from "./Label.js";
|
|
11
|
+
import ue from "./FileUpload.js";
|
|
12
|
+
import { toast as z } from "../lib/toast.js";
|
|
13
|
+
import { _ as Oe } from "../_plugin-vue_export-helper-CHgC5LLL.js";
|
|
14
|
+
const Ye = { class: "w-full p-2" }, Ee = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "mb-6"
|
|
17
|
+
}, Ie = { class: "text-xl font-semibold ui-text" }, Ne = {
|
|
18
|
+
key: 0,
|
|
19
|
+
class: "mt-1 text-sm ui-text-muted"
|
|
20
|
+
}, He = {
|
|
21
|
+
key: 0,
|
|
22
|
+
class: "mb-4"
|
|
23
|
+
}, Je = {
|
|
24
|
+
key: 0,
|
|
25
|
+
class: "text-base font-semibold ui-text"
|
|
26
|
+
}, Ge = {
|
|
27
|
+
key: 1,
|
|
28
|
+
class: "mt-1 text-sm ui-text-muted"
|
|
29
|
+
}, Ke = ["value"], Qe = ["title", "aria-label", "disabled", "onClick"], We = {
|
|
30
|
+
key: 2,
|
|
31
|
+
class: "flex w-full items-center gap-2"
|
|
32
|
+
}, Xe = { class: "min-w-0 flex-1" }, Ze = {
|
|
33
|
+
key: 3,
|
|
34
|
+
class: "flex w-full items-center gap-2"
|
|
35
|
+
}, fe = { class: "min-w-0 flex-1" }, ea = {
|
|
36
|
+
key: 5,
|
|
37
|
+
class: "flex items-center"
|
|
38
|
+
}, aa = {
|
|
39
|
+
key: 6,
|
|
40
|
+
class: "flex items-center"
|
|
41
|
+
}, ta = ["id", "aria-checked", "disabled", "onClick"], na = {
|
|
42
|
+
key: 7,
|
|
43
|
+
class: "space-y-2"
|
|
44
|
+
}, oa = {
|
|
45
|
+
key: 11,
|
|
46
|
+
class: "space-y-2"
|
|
47
|
+
}, sa = { class: "flex items-center gap-4" }, ra = { class: "min-w-12 text-right text-sm font-medium ui-text" }, la = {
|
|
48
|
+
key: 0,
|
|
49
|
+
class: "flex justify-end gap-3 pt-6"
|
|
50
|
+
}, ia = {
|
|
51
|
+
key: 0,
|
|
52
|
+
class: "hidden"
|
|
53
|
+
}, ua = {
|
|
54
|
+
__name: "ReusableForm",
|
|
55
|
+
props: {
|
|
56
|
+
title: { type: String, default: "" },
|
|
57
|
+
description: { type: String, default: "" },
|
|
58
|
+
entityName: { type: String, default: "Item" },
|
|
59
|
+
fields: {
|
|
60
|
+
type: Array,
|
|
61
|
+
required: !0,
|
|
62
|
+
validator: (h) => Array.isArray(h) && h.every((B) => B?.name && B?.label && B?.type)
|
|
63
|
+
},
|
|
64
|
+
sections: { type: Array, default: () => [] },
|
|
65
|
+
initialData: { type: Object, default: null },
|
|
66
|
+
loading: { type: Boolean, default: !1 },
|
|
67
|
+
customValidation: { type: Function, default: null },
|
|
68
|
+
crossValidate: { type: Function, default: null },
|
|
69
|
+
submitLabel: { type: String, default: "Submit" },
|
|
70
|
+
showReset: { type: Boolean, default: !0 },
|
|
71
|
+
showCancel: { type: Boolean, default: !0 },
|
|
72
|
+
showSubmit: { type: Boolean, default: !0 },
|
|
73
|
+
formType: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: "create",
|
|
76
|
+
validator: (h) => ["create", "edit"].includes(h)
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
emits: ["submit", "reset", "cancel", "form-change"],
|
|
80
|
+
setup(h, { emit: B }) {
|
|
81
|
+
const g = h, R = B, ce = De(), c = A(() => g.loading), i = D({}), d = D({}), P = D({}), K = D({}), L = D(!1), me = A(() => Array.isArray(g.sections) && g.sections.length > 0), de = A(() => !!ce.actions), Q = A(() => me.value ? g.sections.map((e, t) => {
|
|
82
|
+
const s = e?.id || `section-${t + 1}`, n = Array.isArray(e?.fields) ? e.fields : (g.fields || []).filter((a) => a.sectionId === s);
|
|
83
|
+
return {
|
|
84
|
+
id: s,
|
|
85
|
+
title: e?.title || "",
|
|
86
|
+
description: e?.description || "",
|
|
87
|
+
icon: e?.icon || "",
|
|
88
|
+
wrapperClass: e?.wrapperClass || "",
|
|
89
|
+
gridClass: e?.gridClass || "grid grid-cols-12 gap-4",
|
|
90
|
+
card: e?.card !== !1,
|
|
91
|
+
fields: n
|
|
92
|
+
};
|
|
93
|
+
}) : [{
|
|
94
|
+
id: "default",
|
|
95
|
+
title: "",
|
|
96
|
+
description: "",
|
|
97
|
+
icon: "",
|
|
98
|
+
wrapperClass: "",
|
|
99
|
+
gridClass: "grid grid-cols-12 gap-4",
|
|
100
|
+
card: !1,
|
|
101
|
+
fields: g.fields || []
|
|
102
|
+
}]), T = A(() => Q.value.flatMap((e) => e.fields || [])), pe = A(() => Object.keys(d.value).length === 0), W = (e) => {
|
|
103
|
+
try {
|
|
104
|
+
return JSON.stringify(e ?? {});
|
|
105
|
+
} catch {
|
|
106
|
+
return "";
|
|
107
|
+
}
|
|
108
|
+
}, O = (e, t) => {
|
|
109
|
+
if (!(!e || !t))
|
|
110
|
+
return t.split(".").reduce((s, n) => s?.[n], e);
|
|
111
|
+
}, q = (e, t, s) => {
|
|
112
|
+
const n = t.split("."), a = n.pop(), l = n.reduce((b, y) => ((!b[y] || typeof b[y] != "object") && (b[y] = {}), b[y]), e);
|
|
113
|
+
l[a] = s;
|
|
114
|
+
}, Y = (e) => e.type === "checkbox" || e.type === "switch" ? !1 : e.type === "number" || e.type === "slider" || e.type === "range" ? e.min ?? 0 : e.type === "file" ? null : e.type === "multifile" || e.type === "multiselect" ? [] : e.type === "radio" && e.options?.[0]?.value || "", X = () => {
|
|
115
|
+
const e = {};
|
|
116
|
+
return T.value.forEach((t) => {
|
|
117
|
+
t.name.includes(".") ? q(e, t.name, Y(t)) : e[t.name] = Y(t);
|
|
118
|
+
}), e;
|
|
119
|
+
}, be = (e) => {
|
|
120
|
+
const t = {};
|
|
121
|
+
return T.value.forEach((s) => {
|
|
122
|
+
const n = s.name.includes(".") ? O(e, s.name) : e?.[s.name], a = Y(s), l = n === void 0 ? a : n;
|
|
123
|
+
if (s.name.includes(".")) {
|
|
124
|
+
q(t, s.name, l);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
s.type === "file" ? t[s.name] = null : s.type === "multifile" || s.type === "multiselect" ? t[s.name] = Array.isArray(l) ? l : [] : t[s.name] = l;
|
|
128
|
+
}), t;
|
|
129
|
+
};
|
|
130
|
+
re(
|
|
131
|
+
() => g.initialData,
|
|
132
|
+
(e) => {
|
|
133
|
+
const t = e ? be(e) : X();
|
|
134
|
+
W(t) !== W(i.value) && (L.value = !0, i.value = t, queueMicrotask(() => {
|
|
135
|
+
L.value = !1;
|
|
136
|
+
}));
|
|
137
|
+
},
|
|
138
|
+
{ immediate: !0 }
|
|
139
|
+
), re(
|
|
140
|
+
i,
|
|
141
|
+
(e) => {
|
|
142
|
+
L.value || R("form-change", e);
|
|
143
|
+
},
|
|
144
|
+
{ deep: !0 }
|
|
145
|
+
);
|
|
146
|
+
const m = (e) => e.includes(".") ? O(i.value, e) : i.value[e], E = (e) => {
|
|
147
|
+
const t = d.value?.[e];
|
|
148
|
+
return t || (e.includes(".") ? O(d.value, e) : void 0);
|
|
149
|
+
}, p = (e, t) => {
|
|
150
|
+
e.includes(".") ? q(i.value, e, t) : i.value[e] = t;
|
|
151
|
+
}, $ = (e) => e?.type === "password", j = (e) => !!P.value[e.name], ye = (e) => $(e) ? j(e) ? "text" : "password" : e.type, ve = (e) => {
|
|
152
|
+
e?.name && (P.value = {
|
|
153
|
+
...P.value,
|
|
154
|
+
[e.name]: !P.value[e.name]
|
|
155
|
+
});
|
|
156
|
+
}, he = () => {
|
|
157
|
+
if (d.value = {}, T.value.forEach((e) => {
|
|
158
|
+
const t = m(e.name);
|
|
159
|
+
if (e.required && !e.disabled && e.type !== "hidden" && (e.type === "checkbox" || e.type === "switch" ? t || (d.value[e.name] = e.errorMessage || `${e.label} is required`) : e.type === "multiselect" || e.type === "multifile" ? (!Array.isArray(t) || t.length === 0) && (d.value[e.name] = e.errorMessage || `${e.label} is required`) : e.type === "number" || e.type === "slider" || e.type === "range" ? t === "" || t === null || t === void 0 ? d.value[e.name] = e.errorMessage || `${e.label} is required` : e.min !== void 0 && Number(t) < e.min ? d.value[e.name] = `${e.label} must be at least ${e.min}` : e.max !== void 0 && Number(t) > e.max && (d.value[e.name] = `${e.label} must be at most ${e.max}`) : e.type === "email" ? !t || !String(t).trim() ? d.value[e.name] = e.errorMessage || `${e.label} is required` : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(t)) || (d.value[e.name] = "Please enter a valid email address") : e.type === "url" ? !t || !String(t).trim() ? d.value[e.name] = e.errorMessage || `${e.label} is required` : /^https?:\/\/.+/.test(String(t)) || (d.value[e.name] = "Please enter a valid URL") : (t == null || typeof t == "string" && !t.trim()) && (d.value[e.name] = e.errorMessage || `${e.label} is required`)), typeof e.validate == "function") {
|
|
160
|
+
const s = e.validate(t, i.value);
|
|
161
|
+
s && (d.value[e.name] = s);
|
|
162
|
+
}
|
|
163
|
+
}), typeof g.customValidation == "function") {
|
|
164
|
+
const e = g.customValidation(i.value);
|
|
165
|
+
e && typeof e == "object" && (d.value = { ...d.value, ...e });
|
|
166
|
+
}
|
|
167
|
+
if (typeof g.crossValidate == "function") {
|
|
168
|
+
const e = g.crossValidate(i.value);
|
|
169
|
+
e && typeof e == "object" && (d.value = { ...d.value, ...e });
|
|
170
|
+
}
|
|
171
|
+
return Object.keys(d.value).length === 0;
|
|
172
|
+
}, U = (e, t, s = void 0) => typeof e == "function" ? e(i.value, t) : e === void 0 ? s : e, Z = (e) => !!e?.actionButton && e.actionButton.show !== !1, f = (e) => {
|
|
173
|
+
if (!e?.actionButton) return !0;
|
|
174
|
+
const t = typeof e.actionButton.disabled == "function" ? e.actionButton.disabled(i.value, e) : e.actionButton.disabled;
|
|
175
|
+
return !!(c.value || e.disabled || t);
|
|
176
|
+
}, ee = (e) => e?.actionButton ? typeof e.actionButton.loading == "function" ? e.actionButton.loading(i.value, e) : !!e.actionButton.loading : !1, ae = (e) => {
|
|
177
|
+
typeof e?.actionButton?.onClick == "function" && e.actionButton.onClick(i.value, e);
|
|
178
|
+
}, te = (e) => $(e) || !!U(e.trailingIcon, e, null), ge = (e) => $(e) ? j(e) ? "eye-slash" : "eye" : U(e.trailingIcon, e, null), ne = (e) => $(e) ? j(e) ? "Hide password" : "Show password" : U(e.trailingIconTitle, e, "Action"), xe = (e) => $(e) ? j(e) ? "Hide password" : "Show password" : U(e.trailingIconAriaLabel, e, ne(e)), we = (e) => U(e.trailingIconClass, e, "w-4 h-4"), I = (e) => !!(c.value || e.disabled || U(e.trailingIconDisabled, e, !1)), ke = (e) => {
|
|
179
|
+
if (!I(e)) {
|
|
180
|
+
if ($(e)) {
|
|
181
|
+
ve(e);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
typeof e?.onTrailingIconClick == "function" && e.onTrailingIconClick(i.value, e);
|
|
185
|
+
}
|
|
186
|
+
}, oe = async (e, t) => {
|
|
187
|
+
if (p(e.name, t), typeof e?.onChange == "function")
|
|
188
|
+
try {
|
|
189
|
+
await e.onChange(t, i.value);
|
|
190
|
+
} catch {
|
|
191
|
+
z.error("An error occurred while processing the change");
|
|
192
|
+
}
|
|
193
|
+
}, _e = (e, t) => {
|
|
194
|
+
if (p(e.name, t), typeof e?.onChange == "function")
|
|
195
|
+
try {
|
|
196
|
+
e.onChange(t, i.value);
|
|
197
|
+
} catch {
|
|
198
|
+
z.error("An error occurred while processing the change");
|
|
199
|
+
}
|
|
200
|
+
}, Ce = (e, t) => {
|
|
201
|
+
p(e.name, t), typeof e?.onChange == "function" && e.onChange(t, i.value);
|
|
202
|
+
}, Ve = (e, t) => {
|
|
203
|
+
p(e.name, t), typeof e?.onChange == "function" && e.onChange(t, i.value);
|
|
204
|
+
}, Fe = (e, t) => {
|
|
205
|
+
p(e.name, t), typeof e?.onChange == "function" && e.onChange(t, i.value);
|
|
206
|
+
}, Se = (e, t) => {
|
|
207
|
+
p(e.name, t), typeof e?.onChange == "function" && e.onChange(t, i.value);
|
|
208
|
+
}, $e = (e) => {
|
|
209
|
+
const t = new FormData();
|
|
210
|
+
return Object.keys(e).forEach((s) => {
|
|
211
|
+
const n = e[s];
|
|
212
|
+
n != null && (n instanceof File ? t.append(s, n) : Array.isArray(n) ? n.forEach((a, l) => {
|
|
213
|
+
a instanceof File ? t.append(`${s}[]`, a) : t.append(`${s}[${l}]`, a);
|
|
214
|
+
}) : typeof n == "object" && !(n instanceof Date) ? Object.keys(n).forEach((a) => {
|
|
215
|
+
t.append(`${s}[${a}]`, n[a]);
|
|
216
|
+
}) : t.append(s, n));
|
|
217
|
+
}), t;
|
|
218
|
+
}, Ue = () => {
|
|
219
|
+
const e = {};
|
|
220
|
+
let t = !1;
|
|
221
|
+
T.value.forEach((n) => {
|
|
222
|
+
const a = m(n.name);
|
|
223
|
+
if (n.type === "number" || n.type === "slider" || n.type === "range") {
|
|
224
|
+
const b = a === "" || a === null || a === void 0 ? a : Number(a);
|
|
225
|
+
n.name.includes(".") ? q(e, n.name, b) : e[n.name] = b;
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (n.type === "file") {
|
|
229
|
+
a instanceof File ? (t = !0, e[n.name] = a) : g.formType === "edit" && a && (e[n.name] = a);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (n.type === "multifile") {
|
|
233
|
+
Array.isArray(a) && a.some((b) => b instanceof File) ? (t = !0, e[n.name] = a) : g.formType === "edit" && Array.isArray(a) && a.length > 0 && (e[n.name] = a);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const l = ["text", "textarea", "date", "email", "url", "tel", "search", "time", "datetime-local", "month", "week"].includes(n.type) && typeof a == "string" ? a.trim() : a;
|
|
237
|
+
n.name.includes(".") ? q(e, n.name, l) : e[n.name] = l;
|
|
238
|
+
});
|
|
239
|
+
let s = e;
|
|
240
|
+
return t && (s = $e(e), g.formType === "edit" && s.append("_method", "PUT")), { formData: s, hasFiles: t };
|
|
241
|
+
}, se = async () => {
|
|
242
|
+
if (T.value.some(
|
|
243
|
+
(s) => s.type !== "multifile" && (K.value[s.name] || []).length > 0
|
|
244
|
+
))
|
|
245
|
+
return z.error("Please wait for all files to finish uploading"), !1;
|
|
246
|
+
if (!he())
|
|
247
|
+
return z.error("Please fix the validation errors before submitting"), !1;
|
|
248
|
+
const t = Ue();
|
|
249
|
+
return R("submit", {
|
|
250
|
+
formData: t.formData,
|
|
251
|
+
formType: g.formType,
|
|
252
|
+
originalData: g.initialData,
|
|
253
|
+
hasFiles: t.hasFiles
|
|
254
|
+
}), !0;
|
|
255
|
+
}, Ae = async () => {
|
|
256
|
+
try {
|
|
257
|
+
await se();
|
|
258
|
+
} catch {
|
|
259
|
+
z.error("An error occurred during submission");
|
|
260
|
+
}
|
|
261
|
+
}, Be = () => {
|
|
262
|
+
i.value = X(), d.value = {}, K.value = {}, R("reset");
|
|
263
|
+
}, Te = () => R("cancel");
|
|
264
|
+
return (e, t) => {
|
|
265
|
+
const s = Me("font-awesome-icon");
|
|
266
|
+
return r(), u("div", Ye, [
|
|
267
|
+
h.title ? (r(), u("div", Ee, [
|
|
268
|
+
C("h2", Ie, k(h.title), 1),
|
|
269
|
+
h.description ? (r(), u("p", Ne, k(h.description), 1)) : w("", !0)
|
|
270
|
+
])) : w("", !0),
|
|
271
|
+
C("form", {
|
|
272
|
+
class: "space-y-6",
|
|
273
|
+
onSubmit: ze(Ae, ["prevent"])
|
|
274
|
+
}, [
|
|
275
|
+
(r(!0), u(H, null, J(Q.value, (n) => (r(), u("div", {
|
|
276
|
+
key: n.id,
|
|
277
|
+
class: v(n.wrapperClass || "")
|
|
278
|
+
}, [
|
|
279
|
+
C("div", {
|
|
280
|
+
class: v(n.card ? "ui-surface border ui-border-strong rounded-xl p-4 sm:p-5" : "")
|
|
281
|
+
}, [
|
|
282
|
+
N(e.$slots, "section-header", { section: n }, () => [
|
|
283
|
+
n.title || n.description ? (r(), u("div", He, [
|
|
284
|
+
n.title ? (r(), u("h3", Je, k(n.title), 1)) : w("", !0),
|
|
285
|
+
n.description ? (r(), u("p", Ge, k(n.description), 1)) : w("", !0)
|
|
286
|
+
])) : w("", !0)
|
|
287
|
+
], !0),
|
|
288
|
+
C("div", {
|
|
289
|
+
class: v(n.gridClass)
|
|
290
|
+
}, [
|
|
291
|
+
(r(!0), u(H, null, J(n.fields, (a) => (r(), u("div", {
|
|
292
|
+
key: a.name,
|
|
293
|
+
class: v(a.wrapperClass || "col-span-12")
|
|
294
|
+
}, [
|
|
295
|
+
a.type === "hidden" ? (r(), u("input", {
|
|
296
|
+
key: 0,
|
|
297
|
+
value: m(a.name),
|
|
298
|
+
type: "hidden"
|
|
299
|
+
}, null, 8, Ke)) : (r(), x(Pe, {
|
|
300
|
+
key: 1,
|
|
301
|
+
id: `form-${h.entityName}-${a.name}`,
|
|
302
|
+
label: a.label,
|
|
303
|
+
required: !!a.required,
|
|
304
|
+
error: E(a.name),
|
|
305
|
+
"error-message": E(a.name),
|
|
306
|
+
"help-text": a.helpText,
|
|
307
|
+
class: v(a.labelClass || "")
|
|
308
|
+
}, {
|
|
309
|
+
default: V(({ fieldId: l, hasError: b, ariaDescribedBy: y }) => [
|
|
310
|
+
N(e.$slots, `field-${a.name}`, {
|
|
311
|
+
field: a,
|
|
312
|
+
formData: i.value,
|
|
313
|
+
error: E(a.name),
|
|
314
|
+
update: (o) => p(a.name, o)
|
|
315
|
+
}, () => [
|
|
316
|
+
["text", "number", "password", "color", "email", "tel", "url", "search"].includes(a.type) ? (r(), u("div", {
|
|
317
|
+
key: 0,
|
|
318
|
+
class: v(["relative", te(a) ? "has-trailing-icon" : ""])
|
|
319
|
+
}, [
|
|
320
|
+
_(S, {
|
|
321
|
+
id: l,
|
|
322
|
+
"model-value": m(a.name),
|
|
323
|
+
type: ye(a),
|
|
324
|
+
placeholder: a.placeholder,
|
|
325
|
+
disabled: c.value || a.disabled,
|
|
326
|
+
readonly: a.readonly || a.disabled,
|
|
327
|
+
class: v([b ? "border-(--ui-danger)" : "ui-border-strong", a.inputClass || ""]),
|
|
328
|
+
"aria-describedby": y,
|
|
329
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
330
|
+
}, null, 8, ["id", "model-value", "type", "placeholder", "disabled", "readonly", "class", "aria-describedby", "onUpdate:modelValue"]),
|
|
331
|
+
te(a) ? (r(), u("button", {
|
|
332
|
+
key: 0,
|
|
333
|
+
type: "button",
|
|
334
|
+
class: v(["absolute right-3 top-1/2 -translate-y-1/2 ui-text hover:text-(--ui-text) transition-colors", I(a) ? "opacity-50 cursor-not-allowed" : ""]),
|
|
335
|
+
title: ne(a),
|
|
336
|
+
"aria-label": xe(a),
|
|
337
|
+
disabled: I(a),
|
|
338
|
+
onClick: (o) => ke(a)
|
|
339
|
+
}, [
|
|
340
|
+
_(s, {
|
|
341
|
+
icon: ge(a),
|
|
342
|
+
class: v(we(a))
|
|
343
|
+
}, null, 8, ["icon", "class"])
|
|
344
|
+
], 10, Qe)) : w("", !0)
|
|
345
|
+
], 2)) : a.type === "textarea" ? (r(), x(je, {
|
|
346
|
+
key: 1,
|
|
347
|
+
id: l,
|
|
348
|
+
"model-value": m(a.name),
|
|
349
|
+
placeholder: a.placeholder,
|
|
350
|
+
disabled: c.value || a.disabled,
|
|
351
|
+
readonly: a.readonly || a.disabled,
|
|
352
|
+
rows: a.rows || 3,
|
|
353
|
+
class: v(["w-full rounded-md border px-3 py-2 focus:outline-none focus:ring-2 focus:ring-(--ui-primary)", b ? "border-(--ui-danger)" : "ui-border-strong", a.inputClass || ""]),
|
|
354
|
+
"aria-describedby": y,
|
|
355
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
356
|
+
}, null, 8, ["id", "model-value", "placeholder", "disabled", "readonly", "rows", "class", "aria-describedby", "onUpdate:modelValue"])) : a.type === "select" ? (r(), u("div", We, [
|
|
357
|
+
C("div", Xe, [
|
|
358
|
+
_(ie, {
|
|
359
|
+
id: l,
|
|
360
|
+
"model-value": m(a.name),
|
|
361
|
+
options: a.options,
|
|
362
|
+
placeholder: a.placeholder || "Select an option",
|
|
363
|
+
disabled: c.value || a.disabled,
|
|
364
|
+
"has-error": b,
|
|
365
|
+
"aria-describedby": y,
|
|
366
|
+
"onUpdate:modelValue": (o) => oe(a, o)
|
|
367
|
+
}, null, 8, ["id", "model-value", "options", "placeholder", "disabled", "has-error", "aria-describedby", "onUpdate:modelValue"])
|
|
368
|
+
]),
|
|
369
|
+
Z(a) ? (r(), x(M, {
|
|
370
|
+
key: 0,
|
|
371
|
+
type: "button",
|
|
372
|
+
variant: a.actionButton.variant || "outline",
|
|
373
|
+
size: a.actionButton.size || "icon",
|
|
374
|
+
class: v(a.actionButton.class || ""),
|
|
375
|
+
title: a.actionButton.title || a.actionButton.label || "Action",
|
|
376
|
+
disabled: f(a),
|
|
377
|
+
loading: ee(a),
|
|
378
|
+
onClick: (o) => ae(a)
|
|
379
|
+
}, {
|
|
380
|
+
default: V(() => [
|
|
381
|
+
F(k(a.actionButton.label || "+"), 1)
|
|
382
|
+
]),
|
|
383
|
+
_: 2
|
|
384
|
+
}, 1032, ["variant", "size", "class", "title", "disabled", "loading", "onClick"])) : w("", !0)
|
|
385
|
+
])) : a.type === "multiselect" ? (r(), u("div", Ze, [
|
|
386
|
+
C("div", fe, [
|
|
387
|
+
_(Le, {
|
|
388
|
+
id: l,
|
|
389
|
+
"model-value": m(a.name),
|
|
390
|
+
options: a.options,
|
|
391
|
+
disabled: c.value || a.disabled,
|
|
392
|
+
placeholder: a.placeholder || "Select options",
|
|
393
|
+
"has-error": b,
|
|
394
|
+
"aria-describedby": y,
|
|
395
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
396
|
+
}, null, 8, ["id", "model-value", "options", "disabled", "placeholder", "has-error", "aria-describedby", "onUpdate:modelValue"])
|
|
397
|
+
]),
|
|
398
|
+
Z(a) ? (r(), x(M, {
|
|
399
|
+
key: 0,
|
|
400
|
+
type: "button",
|
|
401
|
+
variant: a.actionButton.variant || "outline",
|
|
402
|
+
size: a.actionButton.size || "icon",
|
|
403
|
+
class: v(a.actionButton.class || ""),
|
|
404
|
+
title: a.actionButton.title || a.actionButton.label || "Action",
|
|
405
|
+
disabled: f(a),
|
|
406
|
+
loading: ee(a),
|
|
407
|
+
onClick: (o) => ae(a)
|
|
408
|
+
}, {
|
|
409
|
+
default: V(() => [
|
|
410
|
+
F(k(a.actionButton.label || "+"), 1)
|
|
411
|
+
]),
|
|
412
|
+
_: 2
|
|
413
|
+
}, 1032, ["variant", "size", "class", "title", "disabled", "loading", "onClick"])) : w("", !0)
|
|
414
|
+
])) : a.type === "combobox" ? (r(), x(ie, {
|
|
415
|
+
key: 4,
|
|
416
|
+
id: l,
|
|
417
|
+
"model-value": m(a.name),
|
|
418
|
+
options: a.options,
|
|
419
|
+
placeholder: a.placeholder || "Select or type to add new",
|
|
420
|
+
disabled: c.value || a.disabled,
|
|
421
|
+
"has-error": b,
|
|
422
|
+
"aria-describedby": y,
|
|
423
|
+
"allow-create": a.allowCreate,
|
|
424
|
+
"onUpdate:modelValue": (o) => oe(a, o)
|
|
425
|
+
}, null, 8, ["id", "model-value", "options", "placeholder", "disabled", "has-error", "aria-describedby", "allow-create", "onUpdate:modelValue"])) : a.type === "checkbox" ? (r(), u("div", ea, [
|
|
426
|
+
_(S, {
|
|
427
|
+
id: l,
|
|
428
|
+
"model-value": m(a.name),
|
|
429
|
+
type: "checkbox",
|
|
430
|
+
disabled: c.value || a.disabled,
|
|
431
|
+
class: "h-4 w-4 rounded ui-border-strong",
|
|
432
|
+
"aria-describedby": y,
|
|
433
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
434
|
+
}, null, 8, ["id", "model-value", "disabled", "aria-describedby", "onUpdate:modelValue"]),
|
|
435
|
+
_(G, {
|
|
436
|
+
for: l,
|
|
437
|
+
class: "ml-2 text-sm ui-text"
|
|
438
|
+
}, {
|
|
439
|
+
default: V(() => [
|
|
440
|
+
F(k(a.checkboxLabel || a.label), 1)
|
|
441
|
+
]),
|
|
442
|
+
_: 2
|
|
443
|
+
}, 1032, ["for"])
|
|
444
|
+
])) : a.type === "switch" ? (r(), u("div", aa, [
|
|
445
|
+
C("button", {
|
|
446
|
+
id: l,
|
|
447
|
+
type: "button",
|
|
448
|
+
role: "switch",
|
|
449
|
+
"aria-checked": m(a.name),
|
|
450
|
+
disabled: c.value || a.disabled,
|
|
451
|
+
class: v([
|
|
452
|
+
"relative inline-flex h-6 w-11 items-center rounded-full border-2 transition-colors focus:outline-none focus:ring-2 focus:ring-(--ui-primary) focus:ring-offset-2",
|
|
453
|
+
m(a.name) ? "ui-primary-bg border-(--ui-primary)" : "ui-surface-soft border-(--ui-border-strong)",
|
|
454
|
+
c.value || a.disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
|
|
455
|
+
]),
|
|
456
|
+
onClick: (o) => p(a.name, !m(a.name))
|
|
457
|
+
}, [
|
|
458
|
+
C("span", {
|
|
459
|
+
class: v(["inline-block h-4 w-4 transform rounded-full ui-surface border ui-border-strong transition-transform", m(a.name) ? "translate-x-6" : "translate-x-1"])
|
|
460
|
+
}, null, 2)
|
|
461
|
+
], 10, ta),
|
|
462
|
+
_(G, {
|
|
463
|
+
for: l,
|
|
464
|
+
class: "ml-3 text-sm ui-text"
|
|
465
|
+
}, {
|
|
466
|
+
default: V(() => [
|
|
467
|
+
F(k(a.checkboxLabel || a.label), 1)
|
|
468
|
+
]),
|
|
469
|
+
_: 2
|
|
470
|
+
}, 1032, ["for"])
|
|
471
|
+
])) : a.type === "radio" ? (r(), u("div", na, [
|
|
472
|
+
(r(!0), u(H, null, J(a.options, (o) => (r(), u("div", {
|
|
473
|
+
key: o.value,
|
|
474
|
+
class: "flex items-center"
|
|
475
|
+
}, [
|
|
476
|
+
_(S, {
|
|
477
|
+
id: `${l}-${o.value}`,
|
|
478
|
+
"model-value": m(a.name),
|
|
479
|
+
type: "radio",
|
|
480
|
+
value: o.value,
|
|
481
|
+
disabled: c.value || a.disabled,
|
|
482
|
+
class: "h-4 w-4 ui-border-strong",
|
|
483
|
+
"aria-describedby": y,
|
|
484
|
+
"onUpdate:modelValue": (qe) => p(a.name, qe)
|
|
485
|
+
}, null, 8, ["id", "model-value", "value", "disabled", "aria-describedby", "onUpdate:modelValue"]),
|
|
486
|
+
_(G, {
|
|
487
|
+
for: `${l}-${o.value}`,
|
|
488
|
+
class: "ml-2 text-sm ui-text"
|
|
489
|
+
}, {
|
|
490
|
+
default: V(() => [
|
|
491
|
+
F(k(o.label), 1)
|
|
492
|
+
]),
|
|
493
|
+
_: 2
|
|
494
|
+
}, 1032, ["for"])
|
|
495
|
+
]))), 128))
|
|
496
|
+
])) : a.type === "file" ? (r(), x(ue, {
|
|
497
|
+
key: 8,
|
|
498
|
+
multiple: !1,
|
|
499
|
+
accept: a.accept,
|
|
500
|
+
"max-size": a.maxSize,
|
|
501
|
+
variant: a.variant || "default",
|
|
502
|
+
onFilesSelected: (o) => Ce(a, o),
|
|
503
|
+
onFileRemoved: (o) => Ve(a, o)
|
|
504
|
+
}, null, 8, ["accept", "max-size", "variant", "onFilesSelected", "onFileRemoved"])) : a.type === "multifile" ? (r(), x(ue, {
|
|
505
|
+
key: 9,
|
|
506
|
+
multiple: a.multiple !== !1,
|
|
507
|
+
accept: a.accept,
|
|
508
|
+
"max-size": a.maxSize,
|
|
509
|
+
"max-files": a.maxFiles,
|
|
510
|
+
variant: a.variant || "default",
|
|
511
|
+
onFilesSelected: (o) => Fe(a, o),
|
|
512
|
+
onFileRemoved: (o) => Se(a, o)
|
|
513
|
+
}, null, 8, ["multiple", "accept", "max-size", "max-files", "variant", "onFilesSelected", "onFileRemoved"])) : a.type === "slider" ? (r(), x(Re, {
|
|
514
|
+
key: 10,
|
|
515
|
+
"model-value": m(a.name),
|
|
516
|
+
min: a.min,
|
|
517
|
+
max: a.max,
|
|
518
|
+
step: a.step,
|
|
519
|
+
disabled: c.value || a.disabled,
|
|
520
|
+
"onUpdate:modelValue": (o) => _e(a, o)
|
|
521
|
+
}, null, 8, ["model-value", "min", "max", "step", "disabled", "onUpdate:modelValue"])) : a.type === "range" ? (r(), u("div", oa, [
|
|
522
|
+
C("div", sa, [
|
|
523
|
+
_(S, {
|
|
524
|
+
id: l,
|
|
525
|
+
"model-value": m(a.name),
|
|
526
|
+
type: "range",
|
|
527
|
+
min: a.min,
|
|
528
|
+
max: a.max,
|
|
529
|
+
step: a.step || 1,
|
|
530
|
+
disabled: c.value || a.disabled,
|
|
531
|
+
class: "flex-1",
|
|
532
|
+
"aria-describedby": y,
|
|
533
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
534
|
+
}, null, 8, ["id", "model-value", "min", "max", "step", "disabled", "aria-describedby", "onUpdate:modelValue"]),
|
|
535
|
+
C("span", ra, k(m(a.name)), 1)
|
|
536
|
+
])
|
|
537
|
+
])) : a.type === "date" ? (r(), x(le, {
|
|
538
|
+
key: 12,
|
|
539
|
+
id: l,
|
|
540
|
+
"model-value": m(a.name),
|
|
541
|
+
disabled: c.value || a.disabled,
|
|
542
|
+
required: a.required,
|
|
543
|
+
min: a.min,
|
|
544
|
+
max: a.max,
|
|
545
|
+
placeholder: a.placeholder || "Select date",
|
|
546
|
+
format: a.format || "DD/MM/YYYY",
|
|
547
|
+
"enable-time": a.enableTime === !0,
|
|
548
|
+
"minute-interval": a.minuteInterval || 1,
|
|
549
|
+
clearable: a.clearable !== !1,
|
|
550
|
+
"show-today": a.showToday !== !1,
|
|
551
|
+
"calendar-position": a.calendarPosition || "left-0 bottom-full",
|
|
552
|
+
"aria-describedby": y,
|
|
553
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
554
|
+
}, null, 8, ["id", "model-value", "disabled", "required", "min", "max", "placeholder", "format", "enable-time", "minute-interval", "clearable", "show-today", "calendar-position", "aria-describedby", "onUpdate:modelValue"])) : a.type === "time" ? (r(), x(S, {
|
|
555
|
+
key: 13,
|
|
556
|
+
id: l,
|
|
557
|
+
"model-value": m(a.name),
|
|
558
|
+
type: "time",
|
|
559
|
+
disabled: c.value || a.disabled,
|
|
560
|
+
class: v([b ? "border-(--ui-danger)" : "ui-border-strong", a.inputClass || ""]),
|
|
561
|
+
"aria-describedby": y,
|
|
562
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
563
|
+
}, null, 8, ["id", "model-value", "disabled", "class", "aria-describedby", "onUpdate:modelValue"])) : a.type === "datetime-local" ? (r(), x(le, {
|
|
564
|
+
key: 14,
|
|
565
|
+
id: l,
|
|
566
|
+
"model-value": m(a.name),
|
|
567
|
+
disabled: c.value || a.disabled,
|
|
568
|
+
required: a.required,
|
|
569
|
+
min: a.min,
|
|
570
|
+
max: a.max,
|
|
571
|
+
placeholder: a.placeholder || "Select date and time",
|
|
572
|
+
format: a.format || "DD/MM/YYYY",
|
|
573
|
+
"enable-time": !0,
|
|
574
|
+
"minute-interval": a.minuteInterval || 1,
|
|
575
|
+
clearable: a.clearable !== !1,
|
|
576
|
+
"show-today": a.showToday !== !1,
|
|
577
|
+
"aria-describedby": y,
|
|
578
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
579
|
+
}, null, 8, ["id", "model-value", "disabled", "required", "min", "max", "placeholder", "format", "minute-interval", "clearable", "show-today", "aria-describedby", "onUpdate:modelValue"])) : a.type === "month" ? (r(), x(S, {
|
|
580
|
+
key: 15,
|
|
581
|
+
id: l,
|
|
582
|
+
"model-value": m(a.name),
|
|
583
|
+
type: "month",
|
|
584
|
+
disabled: c.value || a.disabled,
|
|
585
|
+
class: v([b ? "border-(--ui-danger)" : "ui-border-strong", a.inputClass || ""]),
|
|
586
|
+
"aria-describedby": y,
|
|
587
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
588
|
+
}, null, 8, ["id", "model-value", "disabled", "class", "aria-describedby", "onUpdate:modelValue"])) : a.type === "week" ? (r(), x(S, {
|
|
589
|
+
key: 16,
|
|
590
|
+
id: l,
|
|
591
|
+
"model-value": m(a.name),
|
|
592
|
+
type: "week",
|
|
593
|
+
disabled: c.value || a.disabled,
|
|
594
|
+
class: v([b ? "border-(--ui-danger)" : "ui-border-strong", a.inputClass || ""]),
|
|
595
|
+
"aria-describedby": y,
|
|
596
|
+
"onUpdate:modelValue": (o) => p(a.name, o)
|
|
597
|
+
}, null, 8, ["id", "model-value", "disabled", "class", "aria-describedby", "onUpdate:modelValue"])) : w("", !0)
|
|
598
|
+
], !0)
|
|
599
|
+
]),
|
|
600
|
+
_: 2
|
|
601
|
+
}, 1032, ["id", "label", "required", "error", "error-message", "help-text", "class"]))
|
|
602
|
+
], 2))), 128))
|
|
603
|
+
], 2)
|
|
604
|
+
], 2)
|
|
605
|
+
], 2))), 128)),
|
|
606
|
+
N(e.$slots, "actions", {
|
|
607
|
+
formData: i.value,
|
|
608
|
+
isValid: pe.value,
|
|
609
|
+
submit: se
|
|
610
|
+
}, () => [
|
|
611
|
+
h.showSubmit ? (r(), u("div", la, [
|
|
612
|
+
h.showReset ? (r(), x(M, {
|
|
613
|
+
key: 0,
|
|
614
|
+
type: "button",
|
|
615
|
+
variant: "outline",
|
|
616
|
+
disabled: c.value,
|
|
617
|
+
onClick: Be
|
|
618
|
+
}, {
|
|
619
|
+
default: V(() => [...t[0] || (t[0] = [
|
|
620
|
+
F(" Reset ", -1)
|
|
621
|
+
])]),
|
|
622
|
+
_: 1
|
|
623
|
+
}, 8, ["disabled"])) : w("", !0),
|
|
624
|
+
h.showCancel ? (r(), x(M, {
|
|
625
|
+
key: 1,
|
|
626
|
+
type: "button",
|
|
627
|
+
variant: "outline",
|
|
628
|
+
disabled: c.value,
|
|
629
|
+
onClick: Te
|
|
630
|
+
}, {
|
|
631
|
+
default: V(() => [...t[1] || (t[1] = [
|
|
632
|
+
F(" Cancel ", -1)
|
|
633
|
+
])]),
|
|
634
|
+
_: 1
|
|
635
|
+
}, 8, ["disabled"])) : w("", !0),
|
|
636
|
+
_(M, {
|
|
637
|
+
type: "submit",
|
|
638
|
+
disabled: c.value,
|
|
639
|
+
loading: c.value,
|
|
640
|
+
variant: "default"
|
|
641
|
+
}, {
|
|
642
|
+
default: V(() => [
|
|
643
|
+
F(k(h.submitLabel), 1)
|
|
644
|
+
]),
|
|
645
|
+
_: 1
|
|
646
|
+
}, 8, ["disabled", "loading"])
|
|
647
|
+
])) : w("", !0)
|
|
648
|
+
], !0),
|
|
649
|
+
h.showSubmit && de.value ? (r(), u("div", ia)) : w("", !0)
|
|
650
|
+
], 32)
|
|
651
|
+
]);
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
}, Ca = /* @__PURE__ */ Oe(ua, [["__scopeId", "data-v-08eb5933"]]);
|
|
655
|
+
export {
|
|
656
|
+
Ca as default
|
|
657
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),w=require("./Modal.cjs"),v=require("./ReusableForm.cjs"),S={__name:"ReusableFormModal",props:{modelValue:{type:Boolean,default:!1},modalType:{type:String,required:!0,validator:t=>["create","edit"].includes(t)},entityName:{type:String,default:"Item"},fields:{type:Array,required:!0},sections:{type:Array,default:()=>[]},initialData:{type:Object,default:null},loading:{type:Boolean,default:!1},customValidation:{type:Function,default:null},crossValidate:{type:Function,default:null},showSubmit:{type:Boolean,default:!0},submitLabel:{type:String,default:""},showReset:{type:Boolean,default:!1},showCancel:{type:Boolean,default:!0},modalSize:{type:String,default:"4xl",validator:t=>["sm","md","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl","full"].includes(t)},modalHeight:{type:String,default:"auto"},modalResizable:{type:Boolean,default:!1}},emits:["update:modelValue","submit","close","form-change"],setup(t,{emit:r}){const a=t,n=r,s=e.useSlots(),d=e.computed({get:()=>a.modelValue,set:l=>n("update:modelValue",l)}),m=e.computed(()=>a.submitLabel?a.submitLabel:a.modalType==="create"?`Create ${a.entityName}`:`Update ${a.entityName}`),c=e.computed(()=>a.modalType==="create"?`Add New ${a.entityName}`:`Edit ${a.entityName}`),f=e.computed(()=>a.modalType==="create"?`Fill in the details to create a new ${a.entityName.toLowerCase()}.`:`Update the ${a.entityName.toLowerCase()} information below.`),y=e.computed(()=>{if(Array.isArray(a.sections)&&a.sections.length>0){const l=a.sections.flatMap(i=>Array.isArray(i?.fields)?i.fields:[]);if(l.length>0)return l}return a.fields||[]}),b=e.computed(()=>y.value.map(l=>l?.name).filter(l=>typeof l=="string"&&!!l&&!!s[`field-${l}`])),u=()=>{d.value=!1,n("close")},h=()=>{u()},p=l=>{n("submit",{...l,modalType:a.modalType,originalData:a.initialData})};return(l,i)=>(e.openBlock(),e.createBlock(w.default,{modelValue:d.value,"onUpdate:modelValue":i[1]||(i[1]=o=>d.value=o),"show-close":!0,"close-on-backdrop":!0,size:t.modalSize,class:e.normalizeClass(t.modalHeight==="auto"?"":t.modalHeight),resizable:t.modalResizable,onClose:u},{default:e.withCtx(()=>[e.createVNode(v.default,{title:c.value,description:f.value,"entity-name":t.entityName,fields:t.fields,sections:t.sections,"initial-data":t.initialData,loading:t.loading,"custom-validation":t.customValidation,"cross-validate":t.crossValidate,"submit-label":m.value,"show-reset":t.showReset,"show-cancel":t.showCancel,"show-submit":t.showSubmit,"form-type":t.modalType,onSubmit:p,onCancel:h,onFormChange:i[0]||(i[0]=o=>n("form-change",o))},e.createSlots({_:2},[e.unref(s)["section-header"]?{name:"section-header",fn:e.withCtx(o=>[e.renderSlot(l.$slots,"section-header",e.normalizeProps(e.guardReactiveProps(o)))]),key:"0"}:void 0,e.renderList(b.value,o=>({name:`field-${o}`,fn:e.withCtx(g=>[e.renderSlot(l.$slots,`field-${o}`,e.normalizeProps(e.guardReactiveProps(g)))])})),e.unref(s).actions?{name:"actions",fn:e.withCtx(o=>[e.renderSlot(l.$slots,"actions",e.normalizeProps(e.guardReactiveProps(o)))]),key:"1"}:void 0]),1032,["title","description","entity-name","fields","sections","initial-data","loading","custom-validation","cross-validate","submit-label","show-reset","show-cancel","show-submit","form-type"])]),_:3},8,["modelValue","size","class","resizable"]))}};exports.default=S;
|