@gspa/ui 0.1.4 → 0.3.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/README.md +34 -1
- package/dist/Button.vue_vue_type_script_setup_true_lang-B3TkBTvG.js +205 -0
- package/dist/Button.vue_vue_type_script_setup_true_lang-DZxttvYH.cjs +1 -0
- package/dist/DataTable.css +1 -0
- package/dist/DataTableToolBar.css +1 -0
- package/dist/DatePicker.vue_vue_type_script_setup_true_lang-CIKiZaO1.cjs +1 -0
- package/dist/DatePicker.vue_vue_type_script_setup_true_lang-Dx_9f8DO.js +557 -0
- package/dist/FormField.vue_vue_type_script_setup_true_lang-BljDj5YZ.js +205 -0
- package/dist/FormField.vue_vue_type_script_setup_true_lang-FWitIR3U.cjs +1 -0
- package/dist/Header.css +1 -0
- package/dist/Input.vue_vue_type_script_setup_true_lang-C1OQn24h.cjs +1 -0
- package/dist/Input.vue_vue_type_script_setup_true_lang-CpBoY97r.js +137 -0
- package/dist/Loader.css +1 -0
- package/dist/ReminderConfig.css +1 -0
- package/dist/ReusableForm.css +1 -0
- package/dist/Sidebar.css +1 -0
- package/dist/Toast.css +1 -0
- package/dist/components/AccordionItem.cjs +1 -1
- package/dist/components/AccordionItem.js +5 -5
- package/dist/components/Alert.cjs +1 -1
- package/dist/components/Alert.js +71 -66
- package/dist/components/Button.cjs +1 -1
- package/dist/components/Button.js +2 -188
- package/dist/components/DataTable.cjs +1 -1
- package/dist/components/DataTable.js +1 -1
- package/dist/components/DataTableFilters.cjs +1 -1
- package/dist/components/DataTableFilters.js +19 -19
- package/dist/components/DataTableToolBar.cjs +1 -1
- package/dist/components/DataTableToolBar.js +1 -1
- package/dist/components/DatePicker.cjs +1 -1
- package/dist/components/DatePicker.js +2 -399
- package/dist/components/FormField.cjs +1 -1
- package/dist/components/FormField.js +2 -188
- package/dist/components/GraphFilters.cjs +1 -1
- package/dist/components/GraphFilters.js +29 -29
- package/dist/components/Icon.cjs +1 -1
- package/dist/components/Icon.js +23 -16
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.js +2 -164
- package/dist/components/ReusableForm.cjs +1 -1
- package/dist/components/ReusableForm.js +188 -159
- package/dist/components/ThemeConfigurator.cjs +1 -1
- package/dist/components/ThemeConfigurator.js +51 -28
- package/dist/gspa-ui.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +124 -118
- package/dist/layouts/AuthLayout.cjs +1 -1
- package/dist/layouts/AuthLayout.js +110 -112
- package/dist/lib/form-field.cjs +1 -0
- package/dist/lib/form-field.js +4 -0
- package/dist/lib/icon.cjs +1 -0
- package/dist/lib/icon.js +4 -0
- package/dist/lib/theme.cjs +1 -1
- package/dist/lib/theme.js +73 -63
- package/dist/src/components/Alert.vue.d.ts.map +1 -1
- package/dist/src/components/Button.vue.d.ts +127 -29
- package/dist/src/components/Button.vue.d.ts.map +1 -1
- package/dist/src/components/Calendar.vue.d.ts +4 -4
- package/dist/src/components/Checkbox.vue.d.ts +2 -2
- package/dist/src/components/DataTable.vue.d.ts +1 -1
- package/dist/src/components/DatePicker.vue.d.ts +139 -29
- package/dist/src/components/DatePicker.vue.d.ts.map +1 -1
- package/dist/src/components/FormField.vue.d.ts +106 -38
- package/dist/src/components/FormField.vue.d.ts.map +1 -1
- package/dist/src/components/Icon.vue.d.ts.map +1 -1
- package/dist/src/components/Input.vue.d.ts +137 -33
- package/dist/src/components/Input.vue.d.ts.map +1 -1
- package/dist/src/components/ReusableForm.vue.d.ts +1 -1
- package/dist/src/components/ReusableForm.vue.d.ts.map +1 -1
- package/dist/src/components/ReusableFormModal.vue.d.ts +1 -1
- package/dist/src/components/Textarea.vue.d.ts +2 -2
- package/dist/src/index.d.ts +9 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/layouts/AuthLayout.vue.d.ts +2 -0
- package/dist/src/layouts/AuthLayout.vue.d.ts.map +1 -1
- package/dist/src/lib/form-field.d.ts +2 -0
- package/dist/src/lib/form-field.d.ts.map +1 -0
- package/dist/src/lib/icon.d.ts +2 -0
- package/dist/src/lib/icon.d.ts.map +1 -0
- package/dist/src/lib/theme.d.ts +4 -0
- package/dist/src/lib/theme.d.ts.map +1 -1
- package/dist/src/types.d.ts +47 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/styles/auth-layout.css +1 -0
- package/dist/styles/button.css +1 -0
- package/dist/styles/form-field.css +1 -0
- package/dist/styles/input.css +1 -0
- package/dist/styles/tokens.css +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -3
- package/dist/src/__tests__/Alert.spec.d.ts +0 -2
- package/dist/src/__tests__/Alert.spec.d.ts.map +0 -1
- package/dist/src/__tests__/App.spec.d.ts +0 -2
- package/dist/src/__tests__/App.spec.d.ts.map +0 -1
- package/dist/src/__tests__/AuthLayout.spec.d.ts +0 -2
- package/dist/src/__tests__/AuthLayout.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Badge.spec.d.ts +0 -2
- package/dist/src/__tests__/Badge.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Button.spec.d.ts +0 -2
- package/dist/src/__tests__/Button.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Card.spec.d.ts +0 -2
- package/dist/src/__tests__/Card.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Checkbox.spec.d.ts +0 -2
- package/dist/src/__tests__/Checkbox.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Dropdown.spec.d.ts +0 -2
- package/dist/src/__tests__/Dropdown.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Input.spec.d.ts +0 -2
- package/dist/src/__tests__/Input.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Modal.spec.d.ts +0 -2
- package/dist/src/__tests__/Modal.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Radio.spec.d.ts +0 -2
- package/dist/src/__tests__/Radio.spec.d.ts.map +0 -1
- package/dist/src/__tests__/ReusableForm.spec.d.ts +0 -2
- package/dist/src/__tests__/ReusableForm.spec.d.ts.map +0 -1
- package/dist/src/__tests__/Tabs.spec.d.ts +0 -2
- package/dist/src/__tests__/Tabs.spec.d.ts.map +0 -1
- package/dist/src/__tests__/integration/CardIntegration.spec.d.ts +0 -2
- package/dist/src/__tests__/integration/CardIntegration.spec.d.ts.map +0 -1
- package/dist/src/__tests__/integration/FormIntegration.spec.d.ts +0 -2
- package/dist/src/__tests__/integration/FormIntegration.spec.d.ts.map +0 -1
- package/dist/src/__tests__/integration/ModalIntegration.spec.d.ts +0 -2
- package/dist/src/__tests__/integration/ModalIntegration.spec.d.ts.map +0 -1
- package/dist/src/__tests__/integration/NavigationIntegration.spec.d.ts +0 -2
- package/dist/src/__tests__/integration/NavigationIntegration.spec.d.ts.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ref as h, computed as
|
|
1
|
+
import { ref as h, computed as r, watch as $, createElementBlock as c, openBlock as s, createElementVNode as l, createCommentVNode as m, normalizeClass as o, createVNode as d, withDirectives as T, vModelText as B, withCtx as y, Fragment as D, renderList as E, toDisplayString as b, renderSlot as O, createBlock as C, createTextVNode as w } from "vue";
|
|
2
2
|
import { cva as Q } from "class-variance-authority";
|
|
3
3
|
import { cn as W } from "../utils/cn.js";
|
|
4
|
-
import k from "
|
|
4
|
+
import { _ as k } from "../Button.vue_vue_type_script_setup_true_lang-B3TkBTvG.js";
|
|
5
5
|
import R from "./Select.js";
|
|
6
6
|
import v from "./Icon.js";
|
|
7
7
|
const X = { class: "border-b" }, Y = {
|
|
@@ -13,7 +13,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
13
13
|
}, ae = { class: "relative" }, le = {
|
|
14
14
|
key: 2,
|
|
15
15
|
class: "min-w-40"
|
|
16
|
-
},
|
|
16
|
+
}, se = { class: "relative" }, re = ["value"], oe = {
|
|
17
17
|
key: 3,
|
|
18
18
|
class: "flex items-center gap-2"
|
|
19
19
|
}, ne = { class: "flex items-center gap-3 ml-auto" }, ie = { class: "flex items-center gap-3 flex-wrap" }, ue = ["onClick"], he = {
|
|
@@ -77,7 +77,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
77
77
|
variant: "default",
|
|
78
78
|
padding: "normal"
|
|
79
79
|
}
|
|
80
|
-
}), N =
|
|
80
|
+
}), N = r(() => i.value || u.value || p.value), F = r(() => {
|
|
81
81
|
const a = [];
|
|
82
82
|
if (i.value || u.value) {
|
|
83
83
|
let e = "";
|
|
@@ -98,28 +98,28 @@ const X = { class: "border-b" }, Y = {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
return a;
|
|
101
|
-
}),
|
|
101
|
+
}), _ = r(
|
|
102
102
|
() => W(A({
|
|
103
103
|
variant: g.variant,
|
|
104
104
|
padding: g.padding
|
|
105
105
|
}))
|
|
106
|
-
), S =
|
|
106
|
+
), S = r(
|
|
107
107
|
() => "w-full pl-10 pr-3 py-2 border ui-border-strong rounded-lg focus:outline-none focus:ring-2 focus:ring-(--ui-primary) focus:border-transparent text-sm ui-surface "
|
|
108
|
-
), V =
|
|
108
|
+
), V = r(
|
|
109
109
|
() => "w-full pr-8 appearance-none border ui-border-strong rounded-lg focus:outline-none focus:ring-2 focus:ring-(--ui-primary) focus:border-transparent text-sm py-2 pl-3 ui-surface "
|
|
110
|
-
),
|
|
110
|
+
), L = r(
|
|
111
111
|
() => "ui-text hover:text-(--ui-text) border hover:brightness-105 px-3 py-2 rounded-lg text-sm font-medium transition-all"
|
|
112
|
-
), z =
|
|
112
|
+
), z = r(
|
|
113
113
|
() => "ui-text ui-primary-bg hover:bg-(--ui-primary-strong) border border-(--ui-primary) px-3 py-2 rounded-lg text-sm font-medium transition-all"
|
|
114
|
-
), G =
|
|
114
|
+
), G = r(
|
|
115
115
|
() => "ui-text hover:text-(--ui-text) border hover:brightness-105 px-3 py-2 rounded-lg text-sm font-medium transition-all"
|
|
116
|
-
), I =
|
|
116
|
+
), I = r(
|
|
117
117
|
() => "px-6 py-3 ui-primary-soft border-t border-(--ui-primary-soft)"
|
|
118
|
-
), M =
|
|
118
|
+
), M = r(
|
|
119
119
|
() => "text-sm font-semibold ui-primary"
|
|
120
|
-
), P =
|
|
120
|
+
), P = r(
|
|
121
121
|
() => "flex items-center gap-1.5 ui-surface border border-(--ui-primary-soft) ui-primary px-3 py-1.5 rounded-full text-sm font-medium"
|
|
122
|
-
), j =
|
|
122
|
+
), j = r(
|
|
123
123
|
() => "ui-primary hover:text-(--ui-primary) ml-1 hover:bg-(--ui-primary-soft) rounded-full p-0.5 transition-all"
|
|
124
124
|
), q = (a) => {
|
|
125
125
|
x.value = a.target.value, f("update:chartType", a.target.value);
|
|
@@ -141,11 +141,11 @@ const X = { class: "border-b" }, Y = {
|
|
|
141
141
|
f("update:dateFrom", a);
|
|
142
142
|
}), $(() => u.value, (a) => {
|
|
143
143
|
f("update:dateTo", a);
|
|
144
|
-
}), (a, e) => (
|
|
144
|
+
}), (a, e) => (s(), c("div", X, [
|
|
145
145
|
l("div", {
|
|
146
|
-
class: o(
|
|
146
|
+
class: o(_.value)
|
|
147
147
|
}, [
|
|
148
|
-
n.showDateFilter ? (
|
|
148
|
+
n.showDateFilter ? (s(), c("div", Y, [
|
|
149
149
|
l("div", Z, [
|
|
150
150
|
d(v, {
|
|
151
151
|
icon: "calendar",
|
|
@@ -176,7 +176,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
176
176
|
])
|
|
177
177
|
])
|
|
178
178
|
])) : m("", !0),
|
|
179
|
-
n.showChartTypeFilter ? (
|
|
179
|
+
n.showChartTypeFilter ? (s(), c("div", te, [
|
|
180
180
|
l("div", ae, [
|
|
181
181
|
d(R, {
|
|
182
182
|
modelValue: x.value,
|
|
@@ -197,8 +197,8 @@ const X = { class: "border-b" }, Y = {
|
|
|
197
197
|
})
|
|
198
198
|
])
|
|
199
199
|
])) : m("", !0),
|
|
200
|
-
n.dataSources.length > 0 ? (
|
|
201
|
-
l("div",
|
|
200
|
+
n.dataSources.length > 0 ? (s(), c("div", le, [
|
|
201
|
+
l("div", se, [
|
|
202
202
|
d(R, {
|
|
203
203
|
modelValue: p.value,
|
|
204
204
|
"onUpdate:modelValue": e[3] || (e[3] = (t) => p.value = t),
|
|
@@ -207,10 +207,10 @@ const X = { class: "border-b" }, Y = {
|
|
|
207
207
|
}, {
|
|
208
208
|
default: y(() => [
|
|
209
209
|
e[8] || (e[8] = l("option", { value: "" }, " All Sources ", -1)),
|
|
210
|
-
(
|
|
210
|
+
(s(!0), c(D, null, E(n.dataSources, (t) => (s(), c("option", {
|
|
211
211
|
key: t.value,
|
|
212
212
|
value: t.value
|
|
213
|
-
}, b(t.label), 9,
|
|
213
|
+
}, b(t.label), 9, re))), 128))
|
|
214
214
|
]),
|
|
215
215
|
_: 1
|
|
216
216
|
}, 8, ["modelValue", "class"]),
|
|
@@ -220,13 +220,13 @@ const X = { class: "border-b" }, Y = {
|
|
|
220
220
|
})
|
|
221
221
|
])
|
|
222
222
|
])) : m("", !0),
|
|
223
|
-
a.$slots.filters ? (
|
|
223
|
+
a.$slots.filters ? (s(), c("div", oe, [
|
|
224
224
|
O(a.$slots, "filters")
|
|
225
225
|
])) : m("", !0),
|
|
226
226
|
l("div", ne, [
|
|
227
|
-
N.value ? (
|
|
227
|
+
N.value ? (s(), C(k, {
|
|
228
228
|
key: 0,
|
|
229
|
-
class: o(
|
|
229
|
+
class: o(L.value),
|
|
230
230
|
onClick: J
|
|
231
231
|
}, {
|
|
232
232
|
default: y(() => [
|
|
@@ -238,7 +238,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
238
238
|
]),
|
|
239
239
|
_: 1
|
|
240
240
|
}, 8, ["class"])) : m("", !0),
|
|
241
|
-
n.showExport ? (
|
|
241
|
+
n.showExport ? (s(), C(k, {
|
|
242
242
|
key: 1,
|
|
243
243
|
class: o(z.value),
|
|
244
244
|
onClick: e[4] || (e[4] = (t) => a.$emit("export"))
|
|
@@ -252,7 +252,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
252
252
|
]),
|
|
253
253
|
_: 1
|
|
254
254
|
}, 8, ["class"])) : m("", !0),
|
|
255
|
-
n.showRefresh ? (
|
|
255
|
+
n.showRefresh ? (s(), C(k, {
|
|
256
256
|
key: 2,
|
|
257
257
|
class: o(G.value),
|
|
258
258
|
onClick: e[5] || (e[5] = (t) => a.$emit("refresh"))
|
|
@@ -268,7 +268,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
268
268
|
}, 8, ["class"])) : m("", !0)
|
|
269
269
|
])
|
|
270
270
|
], 2),
|
|
271
|
-
F.value.length > 0 ? (
|
|
271
|
+
F.value.length > 0 ? (s(), c("div", {
|
|
272
272
|
key: 0,
|
|
273
273
|
class: o(I.value)
|
|
274
274
|
}, [
|
|
@@ -276,7 +276,7 @@ const X = { class: "border-b" }, Y = {
|
|
|
276
276
|
l("span", {
|
|
277
277
|
class: o(M.value)
|
|
278
278
|
}, "Active filters:", 2),
|
|
279
|
-
(
|
|
279
|
+
(s(!0), c(D, null, E(F.value, (t) => (s(), c("div", {
|
|
280
280
|
key: t.key,
|
|
281
281
|
class: o(P.value)
|
|
282
282
|
}, [
|
package/dist/components/Icon.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("@fortawesome/vue-fontawesome"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("@fortawesome/vue-fontawesome"),d=require("../lib/icon.cjs"),m={__name:"Icon",props:{icon:{type:String,default:null},name:{type:String,default:null},prefix:{type:String,default:"fa"},size:{type:String,default:"md"},color:String,ariaLabel:String},setup(a){const l=a,n=e.computed(()=>l.icon||l.name),t=e.inject(d.ICON_ADAPTER_KEY,null),r=e.computed(()=>typeof t!="function"||!n.value?null:t({name:n.value,prefix:l.prefix})),o=e.computed(()=>({xs:"xs",sm:"sm",md:"lg",lg:"xl",xl:"2x",xxl:"3x"})[l.size]||"lg"),c=e.computed(()=>l.color?l.color.startsWith("text-")?l.color:`text-${l.color}`:"text-current"),i=e.computed(()=>[c.value,"inline-block"]);return(u,f)=>r.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),{key:0,class:e.normalizeClass(i.value),"aria-hidden":!a.ariaLabel,"aria-label":a.ariaLabel,role:a.ariaLabel?"img":void 0},null,8,["class","aria-hidden","aria-label","role"])):n.value?(e.openBlock(),e.createBlock(e.unref(s.FontAwesomeIcon),{key:1,icon:[a.prefix,n.value],size:o.value,class:e.normalizeClass(i.value),"aria-hidden":!a.ariaLabel,"aria-label":a.ariaLabel,role:a.ariaLabel?"img":void 0},null,8,["icon","size","class","aria-hidden","aria-label","role"])):e.createCommentVNode("",!0)}};exports.default=m;
|
package/dist/components/Icon.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { computed as l, createBlock as
|
|
2
|
-
import { FontAwesomeIcon as
|
|
3
|
-
|
|
1
|
+
import { computed as l, inject as f, createBlock as o, createCommentVNode as x, openBlock as c, resolveDynamicComponent as b, normalizeClass as s, unref as v } from "vue";
|
|
2
|
+
import { FontAwesomeIcon as g } from "@fortawesome/vue-fontawesome";
|
|
3
|
+
import { ICON_ADAPTER_KEY as p } from "../lib/icon.js";
|
|
4
|
+
const h = {
|
|
4
5
|
__name: "Icon",
|
|
5
6
|
props: {
|
|
6
7
|
icon: {
|
|
@@ -22,8 +23,8 @@ const z = {
|
|
|
22
23
|
color: String,
|
|
23
24
|
ariaLabel: String
|
|
24
25
|
},
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
26
|
+
setup(e) {
|
|
27
|
+
const a = e, n = l(() => a.icon || a.name), r = f(p, null), i = l(() => typeof r != "function" || !n.value ? null : r({ name: n.value, prefix: a.prefix })), u = l(() => ({
|
|
27
28
|
xs: "xs",
|
|
28
29
|
sm: "sm",
|
|
29
30
|
md: "lg",
|
|
@@ -31,21 +32,27 @@ const z = {
|
|
|
31
32
|
lg: "xl",
|
|
32
33
|
xl: "2x",
|
|
33
34
|
xxl: "3x"
|
|
34
|
-
})[
|
|
35
|
-
|
|
35
|
+
})[a.size] || "lg"), d = l(() => a.color ? a.color.startsWith("text-") ? a.color : `text-${a.color}` : "text-current"), t = l(() => [
|
|
36
|
+
d.value,
|
|
36
37
|
"inline-block"
|
|
37
38
|
]);
|
|
38
|
-
return (
|
|
39
|
+
return (m, y) => i.value ? (c(), o(b(i.value), {
|
|
39
40
|
key: 0,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
class: s(t.value),
|
|
42
|
+
"aria-hidden": !e.ariaLabel,
|
|
43
|
+
"aria-label": e.ariaLabel,
|
|
44
|
+
role: e.ariaLabel ? "img" : void 0
|
|
45
|
+
}, null, 8, ["class", "aria-hidden", "aria-label", "role"])) : n.value ? (c(), o(v(g), {
|
|
46
|
+
key: 1,
|
|
47
|
+
icon: [e.prefix, n.value],
|
|
48
|
+
size: u.value,
|
|
49
|
+
class: s(t.value),
|
|
50
|
+
"aria-hidden": !e.ariaLabel,
|
|
51
|
+
"aria-label": e.ariaLabel,
|
|
52
|
+
role: e.ariaLabel ? "img" : void 0
|
|
53
|
+
}, null, 8, ["icon", "size", "class", "aria-hidden", "aria-label", "role"])) : x("", !0);
|
|
47
54
|
}
|
|
48
55
|
};
|
|
49
56
|
export {
|
|
50
|
-
|
|
57
|
+
h as default
|
|
51
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../Input.vue_vue_type_script_setup_true_lang-C1OQn24h.cjs");exports.default=e._sfc_main;
|
package/dist/components/Input.js
CHANGED
|
@@ -1,166 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import I from "./Icon.js";
|
|
3
|
-
const q = { class: "relative" }, N = {
|
|
4
|
-
key: 0,
|
|
5
|
-
class: "absolute left-3 top-1/2 transform -translate-y-1/2 pointer-events-none"
|
|
6
|
-
}, E = ["id", "type", "value", "placeholder", "disabled", "readonly", "required", "autocomplete", "aria-describedby", "aria-invalid"], j = {
|
|
7
|
-
key: 1,
|
|
8
|
-
class: "absolute right-3 top-1/2 transform -translate-y-1/2"
|
|
9
|
-
}, D = ["aria-label"], $ = {
|
|
10
|
-
__name: "Input",
|
|
11
|
-
props: {
|
|
12
|
-
modelValue: {
|
|
13
|
-
type: [String, Number],
|
|
14
|
-
default: ""
|
|
15
|
-
},
|
|
16
|
-
type: {
|
|
17
|
-
type: String,
|
|
18
|
-
default: "text",
|
|
19
|
-
validator: (e) => ["text", "email", "password", "number", "tel", "url", "search", "date", "time", "color", "file"].includes(e)
|
|
20
|
-
},
|
|
21
|
-
placeholder: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: ""
|
|
24
|
-
},
|
|
25
|
-
disabled: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
default: !1
|
|
28
|
-
},
|
|
29
|
-
readonly: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: !1
|
|
32
|
-
},
|
|
33
|
-
required: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: !1
|
|
36
|
-
},
|
|
37
|
-
size: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: "md",
|
|
40
|
-
validator: (e) => ["sm", "md", "lg"].includes(e)
|
|
41
|
-
},
|
|
42
|
-
variant: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: "default",
|
|
45
|
-
validator: (e) => ["default", "error", "success"].includes(e)
|
|
46
|
-
},
|
|
47
|
-
iconLeft: {
|
|
48
|
-
type: [String, Object],
|
|
49
|
-
default: null
|
|
50
|
-
},
|
|
51
|
-
iconRight: {
|
|
52
|
-
type: [String, Object],
|
|
53
|
-
default: null
|
|
54
|
-
},
|
|
55
|
-
clearable: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: !1
|
|
58
|
-
},
|
|
59
|
-
clearLabel: {
|
|
60
|
-
type: String,
|
|
61
|
-
default: "Clear input"
|
|
62
|
-
},
|
|
63
|
-
autocomplete: {
|
|
64
|
-
type: String,
|
|
65
|
-
default: null
|
|
66
|
-
},
|
|
67
|
-
error: {
|
|
68
|
-
type: String,
|
|
69
|
-
default: null
|
|
70
|
-
},
|
|
71
|
-
id: {
|
|
72
|
-
type: String,
|
|
73
|
-
default: null
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
emits: ["update:modelValue", "blur", "focus", "clear", "keydown"],
|
|
77
|
-
setup(e, { expose: y, emit: b }) {
|
|
78
|
-
const t = e, r = b, n = z(null), c = a(() => t.id || V()), p = (l) => {
|
|
79
|
-
r("update:modelValue", l.target.value);
|
|
80
|
-
}, v = (l) => {
|
|
81
|
-
r("blur", l);
|
|
82
|
-
}, g = (l) => {
|
|
83
|
-
r("focus", l);
|
|
84
|
-
}, h = (l) => {
|
|
85
|
-
r("keydown", l);
|
|
86
|
-
}, x = () => {
|
|
87
|
-
r("update:modelValue", ""), r("clear"), n.value?.focus();
|
|
88
|
-
}, S = a(() => !!t.error || t.variant === "error"), k = a(() => {
|
|
89
|
-
if (t.error) return `${c.value}-error`;
|
|
90
|
-
}), w = a(() => ({
|
|
91
|
-
sm: "px-3 py-1.5 text-sm",
|
|
92
|
-
md: "px-3 py-2 text-sm",
|
|
93
|
-
lg: "px-4 py-3 text-base"
|
|
94
|
-
})[t.size]), B = a(() => ({
|
|
95
|
-
default: "ui-border-strong focus:border-(--ui-primary) focus:ring-(--ui-primary)",
|
|
96
|
-
error: "border-(--ui-danger-soft) focus:border-(--ui-danger) focus:ring-(--ui-danger)",
|
|
97
|
-
success: "border-(--ui-success-soft) focus:border-(--ui-success) focus:ring-(--ui-success)"
|
|
98
|
-
})[t.variant]), d = a(() => ["ui-text", {
|
|
99
|
-
sm: "w-4 h-4",
|
|
100
|
-
md: "w-4 h-4",
|
|
101
|
-
lg: "w-5 h-5"
|
|
102
|
-
}[t.size]]), C = a(() => [
|
|
103
|
-
"block rounded-lg border ui-surface transition-colors duration-200",
|
|
104
|
-
"focus:outline-none focus:ring-2 focus:ring-offset-0",
|
|
105
|
-
"disabled:bg-(--ui-surface) disabled:text-(--ui-text) disabled:cursor-not-allowed",
|
|
106
|
-
"placeholder:text-(--ui-text-muted)",
|
|
107
|
-
t.type === "color" ? "w-20 h-12 cursor-pointer" : "w-full",
|
|
108
|
-
w.value,
|
|
109
|
-
B.value,
|
|
110
|
-
{
|
|
111
|
-
"pl-10": t.iconLeft,
|
|
112
|
-
"pr-10": t.iconRight || t.clearable
|
|
113
|
-
}
|
|
114
|
-
]);
|
|
115
|
-
return y({
|
|
116
|
-
focus: () => n.value?.focus(),
|
|
117
|
-
blur: () => n.value?.blur(),
|
|
118
|
-
select: () => n.value?.select()
|
|
119
|
-
}), (l, F) => (o(), s("div", q, [
|
|
120
|
-
e.iconLeft ? (o(), s("div", N, [
|
|
121
|
-
(o(), f(m(e.iconLeft), {
|
|
122
|
-
class: i(d.value)
|
|
123
|
-
}, null, 8, ["class"]))
|
|
124
|
-
])) : u("", !0),
|
|
125
|
-
R("input", {
|
|
126
|
-
id: c.value,
|
|
127
|
-
ref_key: "inputRef",
|
|
128
|
-
ref: n,
|
|
129
|
-
type: e.type,
|
|
130
|
-
value: e.modelValue,
|
|
131
|
-
placeholder: e.placeholder,
|
|
132
|
-
disabled: e.disabled,
|
|
133
|
-
readonly: e.readonly,
|
|
134
|
-
required: e.required,
|
|
135
|
-
autocomplete: e.autocomplete,
|
|
136
|
-
class: i(C.value),
|
|
137
|
-
"aria-describedby": k.value,
|
|
138
|
-
"aria-invalid": S.value,
|
|
139
|
-
onInput: p,
|
|
140
|
-
onBlur: v,
|
|
141
|
-
onFocus: g,
|
|
142
|
-
onKeydown: h
|
|
143
|
-
}, null, 42, E),
|
|
144
|
-
e.iconRight || e.clearable ? (o(), s("div", j, [
|
|
145
|
-
e.clearable && e.modelValue && !e.disabled ? (o(), s("button", {
|
|
146
|
-
key: 0,
|
|
147
|
-
class: "ui-text hover:text-(--ui-text) transition-colors",
|
|
148
|
-
type: "button",
|
|
149
|
-
"aria-label": e.clearLabel,
|
|
150
|
-
onClick: x
|
|
151
|
-
}, [
|
|
152
|
-
L(I, {
|
|
153
|
-
name: "x",
|
|
154
|
-
class: "w-5 h-5"
|
|
155
|
-
})
|
|
156
|
-
], 8, D)) : e.iconRight ? (o(), f(m(e.iconRight), {
|
|
157
|
-
key: 1,
|
|
158
|
-
class: i(d.value)
|
|
159
|
-
}, null, 8, ["class"])) : u("", !0)
|
|
160
|
-
])) : u("", !0)
|
|
161
|
-
]));
|
|
162
|
-
}
|
|
163
|
-
};
|
|
1
|
+
import { _ as f } from "../Input.vue_vue_type_script_setup_true_lang-CpBoY97r.js";
|
|
164
2
|
export {
|
|
165
|
-
|
|
3
|
+
f as default
|
|
166
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),ge=require("./Slider.cjs"),J=require("./DatePicker.cjs"),ke=require("./FormField.cjs"),h=require("./Input.cjs"),Be=require("./Textarea.cjs"),G=require("./Select.cjs"),xe=require("./MultiSelect.cjs"),V=require("./Button.cjs"),z=require("./Label.cjs"),K=require("./FileUpload.cjs"),w=require("../lib/toast.cjs"),Ce=require("../_plugin-vue_export-helper-BHFhmbuH.cjs"),Ve={class:"w-full p-2"},we={key:0,class:"mb-6"},Se={class:"text-xl font-semibold ui-text"},_e={key:0,class:"mt-1 text-sm ui-text-muted"},Fe={key:0,class:"mb-4"},Ne={key:0,class:"text-base font-semibold ui-text"},Ee={key:1,class:"mt-1 text-sm ui-text-muted"},Te=["value"],Ue=["title","aria-label","disabled","onClick"],qe={key:2,class:"flex w-full items-center gap-2"},ze={class:"min-w-0 flex-1"},Ae={key:3,class:"flex w-full items-center gap-2"},$e={class:"min-w-0 flex-1"},De={key:5,class:"flex items-center"},Me={key:6,class:"flex items-center"},Le=["id","aria-checked","disabled","onClick"],Pe={key:7,class:"space-y-2"},Re={key:11,class:"space-y-2"},je={class:"flex items-center gap-4"},Oe={class:"min-w-12 text-right text-sm font-medium ui-text"},Ye={key:0,class:"flex justify-end gap-3 pt-6"},Ie={key:0,class:"hidden"},He={__name:"ReusableForm",props:{title:{type:String,default:""},description:{type:String,default:""},entityName:{type:String,default:"Item"},fields:{type:Array,required:!0,validator:y=>Array.isArray(y)&&y.every(B=>B?.name&&B?.label&&B?.type)},sections:{type:Array,default:()=>[]},initialData:{type:Object,default:null},loading:{type:Boolean,default:!1},customValidation:{type:Function,default:null},crossValidate:{type:Function,default:null},submitLabel:{type:String,default:"Submit"},showReset:{type:Boolean,default:!0},showCancel:{type:Boolean,default:!0},showSubmit:{type:Boolean,default:!0},formType:{type:String,default:"create",validator:y=>["create","edit"].includes(y)}},emits:["submit","reset","cancel","form-change"],setup(y,{emit:B}){const v=y,S=B,Q=a.useSlots(),i=a.computed(()=>v.loading),c=a.ref({}),m=a.ref({}),_=a.ref({}),A=a.ref({}),N=a.ref(!1),W=a.computed(()=>Array.isArray(v.sections)&&v.sections.length>0),X=a.computed(()=>!!Q.actions),$=a.computed(()=>W.value?v.sections.map((e,o)=>{const l=e?.id||`section-${o+1}`,n=Array.isArray(e?.fields)?e.fields:(v.fields||[]).filter(t=>t.sectionId===l);return{id:l,title:e?.title||"",description:e?.description||"",icon:e?.icon||"",wrapperClass:e?.wrapperClass||"",gridClass:e?.gridClass||"grid grid-cols-12 gap-4",card:e?.card!==!1,fields:n}}):[{id:"default",title:"",description:"",icon:"",wrapperClass:"",gridClass:"grid grid-cols-12 gap-4",card:!1,fields:v.fields||[]}]),x=a.computed(()=>$.value.flatMap(e=>e.fields||[])),Z=a.computed(()=>Object.keys(m.value).length===0),D=e=>{try{return JSON.stringify(e??{})}catch{return""}},E=(e,o)=>{if(!(!e||!o))return o.split(".").reduce((l,n)=>l?.[n],e)},C=(e,o,l)=>{const n=o.split("."),t=n.pop(),s=n.reduce((p,b)=>((!p[b]||typeof p[b]!="object")&&(p[b]={}),p[b]),e);s[t]=l},T=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||"",M=()=>{const e={};return x.value.forEach(o=>{o.name.includes(".")?C(e,o.name,T(o)):e[o.name]=T(o)}),e},f=e=>{const o={};return x.value.forEach(l=>{const n=l.name.includes(".")?E(e,l.name):e?.[l.name],t=T(l),s=n===void 0?t:n;if(l.name.includes(".")){C(o,l.name,s);return}l.type==="file"?o[l.name]=null:l.type==="multifile"||l.type==="multiselect"?o[l.name]=Array.isArray(s)?s:[]:o[l.name]=s}),o};a.watch(()=>v.initialData,e=>{const o=e?f(e):M();D(o)!==D(c.value)&&(N.value=!0,c.value=o,queueMicrotask(()=>{N.value=!1}))},{immediate:!0}),a.watch(c,e=>{N.value||S("form-change",e)},{deep:!0});const u=e=>e.includes(".")?E(c.value,e):c.value[e],U=e=>{const o=m.value?.[e];return o||(e.includes(".")?E(m.value,e):void 0)},d=(e,o)=>{e.includes(".")?C(c.value,e,o):c.value[e]=o},g=e=>e?.type==="password",F=e=>!!_.value[e.name],ee=e=>g(e)?F(e)?"text":"password":e.type,te=e=>{e?.name&&(_.value={..._.value,[e.name]:!_.value[e.name]})},ae=()=>{if(m.value={},x.value.forEach(e=>{const o=u(e.name);if(e.required&&!e.disabled&&e.type!=="hidden"&&(e.type==="checkbox"||e.type==="switch"?o||(m.value[e.name]=e.errorMessage||`${e.label} is required`):e.type==="multiselect"||e.type==="multifile"?(!Array.isArray(o)||o.length===0)&&(m.value[e.name]=e.errorMessage||`${e.label} is required`):e.type==="number"||e.type==="slider"||e.type==="range"?o===""||o===null||o===void 0?m.value[e.name]=e.errorMessage||`${e.label} is required`:e.min!==void 0&&Number(o)<e.min?m.value[e.name]=`${e.label} must be at least ${e.min}`:e.max!==void 0&&Number(o)>e.max&&(m.value[e.name]=`${e.label} must be at most ${e.max}`):e.type==="email"?!o||!String(o).trim()?m.value[e.name]=e.errorMessage||`${e.label} is required`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(o))||(m.value[e.name]="Please enter a valid email address"):e.type==="url"?!o||!String(o).trim()?m.value[e.name]=e.errorMessage||`${e.label} is required`:/^https?:\/\/.+/.test(String(o))||(m.value[e.name]="Please enter a valid URL"):(o==null||typeof o=="string"&&!o.trim())&&(m.value[e.name]=e.errorMessage||`${e.label} is required`)),typeof e.validate=="function"){const l=e.validate(o,c.value);l&&(m.value[e.name]=l)}}),typeof v.customValidation=="function"){const e=v.customValidation(c.value);e&&typeof e=="object"&&(m.value={...m.value,...e})}if(typeof v.crossValidate=="function"){const e=v.crossValidate(c.value);e&&typeof e=="object"&&(m.value={...m.value,...e})}return Object.keys(m.value).length===0},k=(e,o,l=void 0)=>typeof e=="function"?e(c.value,o):e===void 0?l:e,L=e=>!!e?.actionButton&&e.actionButton.show!==!1,P=e=>{if(!e?.actionButton)return!0;const o=typeof e.actionButton.disabled=="function"?e.actionButton.disabled(c.value,e):e.actionButton.disabled;return!!(i.value||e.disabled||o)},R=e=>e?.actionButton?typeof e.actionButton.loading=="function"?e.actionButton.loading(c.value,e):!!e.actionButton.loading:!1,j=e=>{typeof e?.actionButton?.onClick=="function"&&e.actionButton.onClick(c.value,e)},O=e=>g(e)||!!k(e.trailingIcon,e,null),oe=e=>g(e)?F(e)?"eye-slash":"eye":k(e.trailingIcon,e,null),Y=e=>g(e)?F(e)?"Hide password":"Show password":k(e.trailingIconTitle,e,"Action"),ne=e=>g(e)?F(e)?"Hide password":"Show password":k(e.trailingIconAriaLabel,e,Y(e)),re=e=>k(e.trailingIconClass,e,"w-4 h-4"),q=e=>!!(i.value||e.disabled||k(e.trailingIconDisabled,e,!1)),le=e=>{if(!q(e)){if(g(e)){te(e);return}typeof e?.onTrailingIconClick=="function"&&e.onTrailingIconClick(c.value,e)}},I=async(e,o)=>{if(d(e.name,o),typeof e?.onChange=="function")try{await e.onChange(o,c.value)}catch{w.toast.error("An error occurred while processing the change")}},se=(e,o)=>{if(d(e.name,o),typeof e?.onChange=="function")try{e.onChange(o,c.value)}catch{w.toast.error("An error occurred while processing the change")}},ce=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},ie=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},ue=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},me=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},de=e=>{const o=new FormData;return Object.keys(e).forEach(l=>{const n=e[l];n!=null&&(n instanceof File?o.append(l,n):Array.isArray(n)?n.forEach((t,s)=>{t instanceof File?o.append(`${l}[]`,t):o.append(`${l}[${s}]`,t)}):typeof n=="object"&&!(n instanceof Date)?Object.keys(n).forEach(t=>{o.append(`${l}[${t}]`,n[t])}):o.append(l,n))}),o},pe=()=>{const e={};let o=!1;x.value.forEach(n=>{const t=u(n.name);if(n.type==="number"||n.type==="slider"||n.type==="range"){const p=t===""||t===null||t===void 0?t:Number(t);n.name.includes(".")?C(e,n.name,p):e[n.name]=p;return}if(n.type==="file"){t instanceof File?(o=!0,e[n.name]=t):v.formType==="edit"&&t&&(e[n.name]=t);return}if(n.type==="multifile"){Array.isArray(t)&&t.some(p=>p instanceof File)?(o=!0,e[n.name]=t):v.formType==="edit"&&Array.isArray(t)&&t.length>0&&(e[n.name]=t);return}const s=["text","textarea","date","email","url","tel","search","time","datetime-local","month","week"].includes(n.type)&&typeof t=="string"?t.trim():t;n.name.includes(".")?C(e,n.name,s):e[n.name]=s});let l=e;return o&&(l=de(e),v.formType==="edit"&&l.append("_method","PUT")),{formData:l,hasFiles:o}},H=async()=>{if(x.value.some(l=>l.type!=="multifile"&&(A.value[l.name]||[]).length>0))return w.toast.error("Please wait for all files to finish uploading"),!1;if(!ae())return w.toast.error("Please fix the validation errors before submitting"),!1;const o=pe();return S("submit",{formData:o.formData,formType:v.formType,originalData:v.initialData,hasFiles:o.hasFiles}),!0},be=async()=>{try{await H()}catch{w.toast.error("An error occurred during submission")}},ye=()=>{c.value=M(),m.value={},A.value={},S("reset")},ve=()=>S("cancel");return(e,o)=>{const l=a.resolveComponent("font-awesome-icon");return a.openBlock(),a.createElementBlock("div",Ve,[y.title?(a.openBlock(),a.createElementBlock("div",we,[a.createElementVNode("h2",Se,a.toDisplayString(y.title),1),y.description?(a.openBlock(),a.createElementBlock("p",_e,a.toDisplayString(y.description),1)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("form",{class:"space-y-6",onSubmit:a.withModifiers(be,["prevent"])},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList($.value,n=>(a.openBlock(),a.createElementBlock("div",{key:n.id,class:a.normalizeClass(n.wrapperClass||"")},[a.createElementVNode("div",{class:a.normalizeClass(n.card?"ui-surface border ui-border-strong rounded-xl p-4 sm:p-5":"")},[a.renderSlot(e.$slots,"section-header",{section:n},()=>[n.title||n.description?(a.openBlock(),a.createElementBlock("div",Fe,[n.title?(a.openBlock(),a.createElementBlock("h3",Ne,a.toDisplayString(n.title),1)):a.createCommentVNode("",!0),n.description?(a.openBlock(),a.createElementBlock("p",Ee,a.toDisplayString(n.description),1)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0)],!0),a.createElementVNode("div",{class:a.normalizeClass(n.gridClass)},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.fields,t=>(a.openBlock(),a.createElementBlock("div",{key:t.name,class:a.normalizeClass(t.wrapperClass||"col-span-12")},[t.type==="hidden"?(a.openBlock(),a.createElementBlock("input",{key:0,value:u(t.name),type:"hidden"},null,8,Te)):(a.openBlock(),a.createBlock(ke.default,{key:1,id:`form-${y.entityName}-${t.name}`,label:t.label,required:!!t.required,error:U(t.name),"error-message":U(t.name),"help-text":t.helpText,class:a.normalizeClass(t.labelClass||"")},{default:a.withCtx(({fieldId:s,hasError:p,ariaDescribedBy:b})=>[a.renderSlot(e.$slots,`field-${t.name}`,{field:t,formData:c.value,error:U(t.name),update:r=>d(t.name,r)},()=>[["text","number","password","color","email","tel","url","search"].includes(t.type)?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["relative",O(t)?"has-trailing-icon":""])},[a.createVNode(h.default,{id:s,"model-value":u(t.name),type:ee(t),placeholder:t.placeholder,disabled:i.value||t.disabled,readonly:t.readonly||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","type","placeholder","disabled","readonly","class","aria-describedby","onUpdate:modelValue"]),O(t)?(a.openBlock(),a.createElementBlock("button",{key:0,type:"button",class:a.normalizeClass(["absolute right-3 top-1/2 -translate-y-1/2 ui-text hover:text-(--ui-text) transition-colors",q(t)?"opacity-50 cursor-not-allowed":""]),title:Y(t),"aria-label":ne(t),disabled:q(t),onClick:r=>le(t)},[a.createVNode(l,{icon:oe(t),class:a.normalizeClass(re(t))},null,8,["icon","class"])],10,Ue)):a.createCommentVNode("",!0)],2)):t.type==="textarea"?(a.openBlock(),a.createBlock(Be.default,{key:1,id:s,"model-value":u(t.name),placeholder:t.placeholder,disabled:i.value||t.disabled,readonly:t.readonly||t.disabled,rows:t.rows||3,class:a.normalizeClass(["w-full rounded-md border px-3 py-2 focus:outline-none focus:ring-2 focus:ring-(--ui-primary)",p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","placeholder","disabled","readonly","rows","class","aria-describedby","onUpdate:modelValue"])):t.type==="select"?(a.openBlock(),a.createElementBlock("div",qe,[a.createElementVNode("div",ze,[a.createVNode(G.default,{id:s,"model-value":u(t.name),options:t.options,placeholder:t.placeholder||"Select an option",disabled:i.value||t.disabled,"has-error":p,"aria-describedby":b,"onUpdate:modelValue":r=>I(t,r)},null,8,["id","model-value","options","placeholder","disabled","has-error","aria-describedby","onUpdate:modelValue"])]),L(t)?(a.openBlock(),a.createBlock(V.default,{key:0,type:"button",variant:t.actionButton.variant||"outline",size:t.actionButton.size||"icon",class:a.normalizeClass(t.actionButton.class||""),title:t.actionButton.title||t.actionButton.label||"Action",disabled:P(t),loading:R(t),onClick:r=>j(t)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.actionButton.label||"+"),1)]),_:2},1032,["variant","size","class","title","disabled","loading","onClick"])):a.createCommentVNode("",!0)])):t.type==="multiselect"?(a.openBlock(),a.createElementBlock("div",Ae,[a.createElementVNode("div",$e,[a.createVNode(xe.default,{id:s,"model-value":u(t.name),options:t.options,disabled:i.value||t.disabled,placeholder:t.placeholder||"Select options","has-error":p,"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","options","disabled","placeholder","has-error","aria-describedby","onUpdate:modelValue"])]),L(t)?(a.openBlock(),a.createBlock(V.default,{key:0,type:"button",variant:t.actionButton.variant||"outline",size:t.actionButton.size||"icon",class:a.normalizeClass(t.actionButton.class||""),title:t.actionButton.title||t.actionButton.label||"Action",disabled:P(t),loading:R(t),onClick:r=>j(t)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.actionButton.label||"+"),1)]),_:2},1032,["variant","size","class","title","disabled","loading","onClick"])):a.createCommentVNode("",!0)])):t.type==="combobox"?(a.openBlock(),a.createBlock(G.default,{key:4,id:s,"model-value":u(t.name),options:t.options,placeholder:t.placeholder||"Select or type to add new",disabled:i.value||t.disabled,"has-error":p,"aria-describedby":b,"allow-create":t.allowCreate,"onUpdate:modelValue":r=>I(t,r)},null,8,["id","model-value","options","placeholder","disabled","has-error","aria-describedby","allow-create","onUpdate:modelValue"])):t.type==="checkbox"?(a.openBlock(),a.createElementBlock("div",De,[a.createVNode(h.default,{id:s,"model-value":u(t.name),type:"checkbox",disabled:i.value||t.disabled,class:"h-4 w-4 rounded ui-border-strong","aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","aria-describedby","onUpdate:modelValue"]),a.createVNode(z.default,{for:s,class:"ml-2 text-sm ui-text"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.checkboxLabel||t.label),1)]),_:2},1032,["for"])])):t.type==="switch"?(a.openBlock(),a.createElementBlock("div",Me,[a.createElementVNode("button",{id:s,type:"button",role:"switch","aria-checked":u(t.name),disabled:i.value||t.disabled,class:a.normalizeClass(["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",u(t.name)?"ui-primary-bg border-(--ui-primary)":"ui-surface-soft border-(--ui-border-strong)",i.value||t.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"]),onClick:r=>d(t.name,!u(t.name))},[a.createElementVNode("span",{class:a.normalizeClass(["inline-block h-4 w-4 transform rounded-full ui-surface border ui-border-strong transition-transform",u(t.name)?"translate-x-6":"translate-x-1"])},null,2)],10,Le),a.createVNode(z.default,{for:s,class:"ml-3 text-sm ui-text"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.checkboxLabel||t.label),1)]),_:2},1032,["for"])])):t.type==="radio"?(a.openBlock(),a.createElementBlock("div",Pe,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.options,r=>(a.openBlock(),a.createElementBlock("div",{key:r.value,class:"flex items-center"},[a.createVNode(h.default,{id:`${s}-${r.value}`,"model-value":u(t.name),type:"radio",value:r.value,disabled:i.value||t.disabled,class:"h-4 w-4 ui-border-strong","aria-describedby":b,"onUpdate:modelValue":he=>d(t.name,he)},null,8,["id","model-value","value","disabled","aria-describedby","onUpdate:modelValue"]),a.createVNode(z.default,{for:`${s}-${r.value}`,class:"ml-2 text-sm ui-text"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(r.label),1)]),_:2},1032,["for"])]))),128))])):t.type==="file"?(a.openBlock(),a.createBlock(K.default,{key:8,multiple:!1,accept:t.accept,"max-size":t.maxSize,variant:t.variant||"default",onFilesSelected:r=>ce(t,r),onFileRemoved:r=>ie(t,r)},null,8,["accept","max-size","variant","onFilesSelected","onFileRemoved"])):t.type==="multifile"?(a.openBlock(),a.createBlock(K.default,{key:9,multiple:t.multiple!==!1,accept:t.accept,"max-size":t.maxSize,"max-files":t.maxFiles,variant:t.variant||"default",onFilesSelected:r=>ue(t,r),onFileRemoved:r=>me(t,r)},null,8,["multiple","accept","max-size","max-files","variant","onFilesSelected","onFileRemoved"])):t.type==="slider"?(a.openBlock(),a.createBlock(ge.default,{key:10,"model-value":u(t.name),min:t.min,max:t.max,step:t.step,disabled:i.value||t.disabled,"onUpdate:modelValue":r=>se(t,r)},null,8,["model-value","min","max","step","disabled","onUpdate:modelValue"])):t.type==="range"?(a.openBlock(),a.createElementBlock("div",Re,[a.createElementVNode("div",je,[a.createVNode(h.default,{id:s,"model-value":u(t.name),type:"range",min:t.min,max:t.max,step:t.step||1,disabled:i.value||t.disabled,class:"flex-1","aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","min","max","step","disabled","aria-describedby","onUpdate:modelValue"]),a.createElementVNode("span",Oe,a.toDisplayString(u(t.name)),1)])])):t.type==="date"?(a.openBlock(),a.createBlock(J.default,{key:12,id:s,"model-value":u(t.name),disabled:i.value||t.disabled,required:t.required,min:t.min,max:t.max,placeholder:t.placeholder||"Select date",format:t.format||"DD/MM/YYYY","enable-time":t.enableTime===!0,"minute-interval":t.minuteInterval||1,clearable:t.clearable!==!1,"show-today":t.showToday!==!1,"calendar-position":t.calendarPosition||"left-0 bottom-full","aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","required","min","max","placeholder","format","enable-time","minute-interval","clearable","show-today","calendar-position","aria-describedby","onUpdate:modelValue"])):t.type==="time"?(a.openBlock(),a.createBlock(h.default,{key:13,id:s,"model-value":u(t.name),type:"time",disabled:i.value||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","class","aria-describedby","onUpdate:modelValue"])):t.type==="datetime-local"?(a.openBlock(),a.createBlock(J.default,{key:14,id:s,"model-value":u(t.name),disabled:i.value||t.disabled,required:t.required,min:t.min,max:t.max,placeholder:t.placeholder||"Select date and time",format:t.format||"DD/MM/YYYY","enable-time":!0,"minute-interval":t.minuteInterval||1,clearable:t.clearable!==!1,"show-today":t.showToday!==!1,"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","required","min","max","placeholder","format","minute-interval","clearable","show-today","aria-describedby","onUpdate:modelValue"])):t.type==="month"?(a.openBlock(),a.createBlock(h.default,{key:15,id:s,"model-value":u(t.name),type:"month",disabled:i.value||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","class","aria-describedby","onUpdate:modelValue"])):t.type==="week"?(a.openBlock(),a.createBlock(h.default,{key:16,id:s,"model-value":u(t.name),type:"week",disabled:i.value||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","class","aria-describedby","onUpdate:modelValue"])):a.createCommentVNode("",!0)],!0)]),_:2},1032,["id","label","required","error","error-message","help-text","class"]))],2))),128))],2)],2)],2))),128)),a.renderSlot(e.$slots,"actions",{formData:c.value,isValid:Z.value,submit:H},()=>[y.showSubmit?(a.openBlock(),a.createElementBlock("div",Ye,[y.showReset?(a.openBlock(),a.createBlock(V.default,{key:0,type:"button",variant:"outline",disabled:i.value,onClick:ye},{default:a.withCtx(()=>[...o[0]||(o[0]=[a.createTextVNode(" Reset ",-1)])]),_:1},8,["disabled"])):a.createCommentVNode("",!0),y.showCancel?(a.openBlock(),a.createBlock(V.default,{key:1,type:"button",variant:"outline",disabled:i.value,onClick:ve},{default:a.withCtx(()=>[...o[1]||(o[1]=[a.createTextVNode(" Cancel ",-1)])]),_:1},8,["disabled"])):a.createCommentVNode("",!0),a.createVNode(V.default,{type:"submit",disabled:i.value,loading:i.value,variant:"default"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(y.submitLabel),1)]),_:1},8,["disabled","loading"])])):a.createCommentVNode("",!0)],!0),y.showSubmit&&X.value?(a.openBlock(),a.createElementBlock("div",Ie)):a.createCommentVNode("",!0)],32)])}}},Je=Ce._export_sfc(He,[["__scopeId","data-v-08eb5933"]]);exports.default=Je;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),ge=require("./Slider.cjs"),J=require("../DatePicker.vue_vue_type_script_setup_true_lang-CIKiZaO1.cjs"),ke=require("../FormField.vue_vue_type_script_setup_true_lang-FWitIR3U.cjs"),g=require("../Input.vue_vue_type_script_setup_true_lang-C1OQn24h.cjs"),_e=require("./Textarea.cjs"),G=require("./Select.cjs"),Be=require("./MultiSelect.cjs"),V=require("../Button.vue_vue_type_script_setup_true_lang-DZxttvYH.cjs"),z=require("./Label.cjs"),K=require("./FileUpload.cjs"),w=require("../lib/toast.cjs"),xe=require("../_plugin-vue_export-helper-BHFhmbuH.cjs"),Ce={class:"w-full p-2"},Ve={key:0,class:"mb-6"},we={class:"text-xl font-semibold ui-text"},Se={key:0,class:"mt-1 text-sm ui-text-muted"},Fe={key:0,class:"mb-4"},Ne={key:0,class:"text-base font-semibold ui-text"},Ee={key:1,class:"mt-1 text-sm ui-text-muted"},Te=["value"],Ae=["title","aria-label","disabled","onClick"],Ue={key:0,class:"h-4 w-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","aria-hidden":"true"},ze={key:0,"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M3 3l18 18M10.6 10.7a2 2 0 002.7 2.7M9.9 4.2A10.7 10.7 0 0112 4c5 0 8.7 4.4 9.6 6.5.2.3.2.7 0 1a15 15 0 01-2.2 3.3M6.2 6.2A15.8 15.8 0 002.4 10.5c-.2.3-.2.7 0 1C3.3 13.6 7 18 12 18c1 0 2-.2 2.9-.5"},qe={key:2,class:"flex w-full items-center gap-2"},$e={class:"min-w-0 flex-1"},De={key:3,class:"flex w-full items-center gap-2"},Me={class:"min-w-0 flex-1"},je={key:5,class:"flex items-center"},Le={key:6,class:"flex items-center"},Pe=["id","aria-checked","disabled","onClick"],Re={key:7,class:"space-y-2"},Oe={key:11,class:"space-y-2"},Ye={class:"flex items-center gap-4"},Ie={class:"min-w-12 text-right text-sm font-medium ui-text"},He={key:0,class:"flex justify-end gap-3 pt-6"},Je={key:0,class:"hidden"},Ge={__name:"ReusableForm",props:{title:{type:String,default:""},description:{type:String,default:""},entityName:{type:String,default:"Item"},fields:{type:Array,required:!0,validator:y=>Array.isArray(y)&&y.every(_=>_?.name&&_?.label&&_?.type)},sections:{type:Array,default:()=>[]},initialData:{type:Object,default:null},loading:{type:Boolean,default:!1},customValidation:{type:Function,default:null},crossValidate:{type:Function,default:null},submitLabel:{type:String,default:"Submit"},showReset:{type:Boolean,default:!0},showCancel:{type:Boolean,default:!0},showSubmit:{type:Boolean,default:!0},formType:{type:String,default:"create",validator:y=>["create","edit"].includes(y)}},emits:["submit","reset","cancel","form-change"],setup(y,{emit:_}){const v=y,S=_,Q=a.useSlots(),i=a.computed(()=>v.loading),c=a.ref({}),m=a.ref({}),F=a.ref({}),q=a.ref({}),N=a.ref(!1),W=a.computed(()=>Array.isArray(v.sections)&&v.sections.length>0),X=a.computed(()=>!!Q.actions),$=a.computed(()=>W.value?v.sections.map((e,o)=>{const s=e?.id||`section-${o+1}`,n=Array.isArray(e?.fields)?e.fields:(v.fields||[]).filter(t=>t.sectionId===s);return{id:s,title:e?.title||"",description:e?.description||"",icon:e?.icon||"",wrapperClass:e?.wrapperClass||"",gridClass:e?.gridClass||"grid grid-cols-12 gap-4",card:e?.card!==!1,fields:n}}):[{id:"default",title:"",description:"",icon:"",wrapperClass:"",gridClass:"grid grid-cols-12 gap-4",card:!1,fields:v.fields||[]}]),B=a.computed(()=>$.value.flatMap(e=>e.fields||[])),Z=a.computed(()=>Object.keys(m.value).length===0),D=e=>{try{return JSON.stringify(e??{})}catch{return""}},E=(e,o)=>{if(!(!e||!o))return o.split(".").reduce((s,n)=>s?.[n],e)},x=(e,o,s)=>{const n=o.split("."),t=n.pop(),l=n.reduce((p,b)=>((!p[b]||typeof p[b]!="object")&&(p[b]={}),p[b]),e);l[t]=s},T=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||"",M=()=>{const e={};return B.value.forEach(o=>{o.name.includes(".")?x(e,o.name,T(o)):e[o.name]=T(o)}),e},f=e=>{const o={};return B.value.forEach(s=>{const n=s.name.includes(".")?E(e,s.name):e?.[s.name],t=T(s),l=n===void 0?t:n;if(s.name.includes(".")){x(o,s.name,l);return}s.type==="file"?o[s.name]=null:s.type==="multifile"||s.type==="multiselect"?o[s.name]=Array.isArray(l)?l:[]:o[s.name]=l}),o};a.watch(()=>v.initialData,e=>{const o=e?f(e):M();D(o)!==D(c.value)&&(N.value=!0,c.value=o,queueMicrotask(()=>{N.value=!1}))},{immediate:!0}),a.watch(c,e=>{N.value||S("form-change",e)},{deep:!0});const u=e=>e.includes(".")?E(c.value,e):c.value[e],A=e=>{const o=m.value?.[e];return o||(e.includes(".")?E(m.value,e):void 0)},d=(e,o)=>{e.includes(".")?x(c.value,e,o):c.value[e]=o},h=e=>e?.type==="password",C=e=>!!F.value[e.name],ee=e=>h(e)?C(e)?"text":"password":e.type,te=e=>{e?.name&&(F.value={...F.value,[e.name]:!F.value[e.name]})},ae=()=>{if(m.value={},B.value.forEach(e=>{const o=u(e.name);if(e.required&&!e.disabled&&e.type!=="hidden"&&(e.type==="checkbox"||e.type==="switch"?o||(m.value[e.name]=e.errorMessage||`${e.label} is required`):e.type==="multiselect"||e.type==="multifile"?(!Array.isArray(o)||o.length===0)&&(m.value[e.name]=e.errorMessage||`${e.label} is required`):e.type==="number"||e.type==="slider"||e.type==="range"?o===""||o===null||o===void 0?m.value[e.name]=e.errorMessage||`${e.label} is required`:e.min!==void 0&&Number(o)<e.min?m.value[e.name]=`${e.label} must be at least ${e.min}`:e.max!==void 0&&Number(o)>e.max&&(m.value[e.name]=`${e.label} must be at most ${e.max}`):e.type==="email"?!o||!String(o).trim()?m.value[e.name]=e.errorMessage||`${e.label} is required`:/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(o))||(m.value[e.name]="Please enter a valid email address"):e.type==="url"?!o||!String(o).trim()?m.value[e.name]=e.errorMessage||`${e.label} is required`:/^https?:\/\/.+/.test(String(o))||(m.value[e.name]="Please enter a valid URL"):(o==null||typeof o=="string"&&!o.trim())&&(m.value[e.name]=e.errorMessage||`${e.label} is required`)),typeof e.validate=="function"){const s=e.validate(o,c.value);s&&(m.value[e.name]=s)}}),typeof v.customValidation=="function"){const e=v.customValidation(c.value);e&&typeof e=="object"&&(m.value={...m.value,...e})}if(typeof v.crossValidate=="function"){const e=v.crossValidate(c.value);e&&typeof e=="object"&&(m.value={...m.value,...e})}return Object.keys(m.value).length===0},k=(e,o,s=void 0)=>typeof e=="function"?e(c.value,o):e===void 0?s:e,j=e=>!!e?.actionButton&&e.actionButton.show!==!1,L=e=>{if(!e?.actionButton)return!0;const o=typeof e.actionButton.disabled=="function"?e.actionButton.disabled(c.value,e):e.actionButton.disabled;return!!(i.value||e.disabled||o)},P=e=>e?.actionButton?typeof e.actionButton.loading=="function"?e.actionButton.loading(c.value,e):!!e.actionButton.loading:!1,R=e=>{typeof e?.actionButton?.onClick=="function"&&e.actionButton.onClick(c.value,e)},O=e=>h(e)||!!k(e.trailingIcon,e,null),oe=e=>h(e)?C(e)?"eye-slash":"eye":k(e.trailingIcon,e,null),Y=e=>h(e)?C(e)?"Hide password":"Show password":k(e.trailingIconTitle,e,"Action"),ne=e=>h(e)?C(e)?"Hide password":"Show password":k(e.trailingIconAriaLabel,e,Y(e)),re=e=>k(e.trailingIconClass,e,"w-4 h-4"),U=e=>!!(i.value||e.disabled||k(e.trailingIconDisabled,e,!1)),se=e=>{if(!U(e)){if(h(e)){te(e);return}typeof e?.onTrailingIconClick=="function"&&e.onTrailingIconClick(c.value,e)}},I=async(e,o)=>{if(d(e.name,o),typeof e?.onChange=="function")try{await e.onChange(o,c.value)}catch{w.toast.error("An error occurred while processing the change")}},le=(e,o)=>{if(d(e.name,o),typeof e?.onChange=="function")try{e.onChange(o,c.value)}catch{w.toast.error("An error occurred while processing the change")}},ce=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},ie=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},ue=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},me=(e,o)=>{d(e.name,o),typeof e?.onChange=="function"&&e.onChange(o,c.value)},de=e=>{const o=new FormData;return Object.keys(e).forEach(s=>{const n=e[s];n!=null&&(n instanceof File?o.append(s,n):Array.isArray(n)?n.forEach((t,l)=>{t instanceof File?o.append(`${s}[]`,t):o.append(`${s}[${l}]`,t)}):typeof n=="object"&&!(n instanceof Date)?Object.keys(n).forEach(t=>{o.append(`${s}[${t}]`,n[t])}):o.append(s,n))}),o},pe=()=>{const e={};let o=!1;B.value.forEach(n=>{const t=u(n.name);if(n.type==="number"||n.type==="slider"||n.type==="range"){const p=t===""||t===null||t===void 0?t:Number(t);n.name.includes(".")?x(e,n.name,p):e[n.name]=p;return}if(n.type==="file"){t instanceof File?(o=!0,e[n.name]=t):v.formType==="edit"&&t&&(e[n.name]=t);return}if(n.type==="multifile"){Array.isArray(t)&&t.some(p=>p instanceof File)?(o=!0,e[n.name]=t):v.formType==="edit"&&Array.isArray(t)&&t.length>0&&(e[n.name]=t);return}const l=["text","textarea","date","email","url","tel","search","time","datetime-local","month","week"].includes(n.type)&&typeof t=="string"?t.trim():t;n.name.includes(".")?x(e,n.name,l):e[n.name]=l});let s=e;return o&&(s=de(e),v.formType==="edit"&&s.append("_method","PUT")),{formData:s,hasFiles:o}},H=async()=>{if(B.value.some(s=>s.type!=="multifile"&&(q.value[s.name]||[]).length>0))return w.toast.error("Please wait for all files to finish uploading"),!1;if(!ae())return w.toast.error("Please fix the validation errors before submitting"),!1;const o=pe();return S("submit",{formData:o.formData,formType:v.formType,originalData:v.initialData,hasFiles:o.hasFiles}),!0},be=async()=>{try{await H()}catch{w.toast.error("An error occurred during submission")}},ye=()=>{c.value=M(),m.value={},q.value={},S("reset")},ve=()=>S("cancel");return(e,o)=>{const s=a.resolveComponent("font-awesome-icon");return a.openBlock(),a.createElementBlock("div",Ce,[y.title?(a.openBlock(),a.createElementBlock("div",Ve,[a.createElementVNode("h2",we,a.toDisplayString(y.title),1),y.description?(a.openBlock(),a.createElementBlock("p",Se,a.toDisplayString(y.description),1)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("form",{class:"space-y-6",onSubmit:a.withModifiers(be,["prevent"])},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList($.value,n=>(a.openBlock(),a.createElementBlock("div",{key:n.id,class:a.normalizeClass(n.wrapperClass||"")},[a.createElementVNode("div",{class:a.normalizeClass(n.card?"ui-surface border ui-border-strong rounded-xl p-4 sm:p-5":"")},[a.renderSlot(e.$slots,"section-header",{section:n},()=>[n.title||n.description?(a.openBlock(),a.createElementBlock("div",Fe,[n.title?(a.openBlock(),a.createElementBlock("h3",Ne,a.toDisplayString(n.title),1)):a.createCommentVNode("",!0),n.description?(a.openBlock(),a.createElementBlock("p",Ee,a.toDisplayString(n.description),1)):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0)],!0),a.createElementVNode("div",{class:a.normalizeClass(n.gridClass)},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(n.fields,t=>(a.openBlock(),a.createElementBlock("div",{key:t.name,class:a.normalizeClass(t.wrapperClass||"col-span-12")},[t.type==="hidden"?(a.openBlock(),a.createElementBlock("input",{key:0,value:u(t.name),type:"hidden"},null,8,Te)):(a.openBlock(),a.createBlock(ke._sfc_main,{key:1,id:`form-${y.entityName}-${t.name}`,label:t.label,required:!!t.required,error:A(t.name),"error-message":A(t.name),"help-text":t.helpText,class:a.normalizeClass(t.labelClass||"")},{default:a.withCtx(({fieldId:l,hasError:p,ariaDescribedBy:b})=>[a.renderSlot(e.$slots,`field-${t.name}`,{field:t,formData:c.value,error:A(t.name),update:r=>d(t.name,r)},()=>[["text","number","password","color","email","tel","url","search"].includes(t.type)?(a.openBlock(),a.createElementBlock("div",{key:0,class:a.normalizeClass(["relative",O(t)?"has-trailing-icon":""])},[a.createVNode(g._sfc_main,{id:l,"model-value":u(t.name),type:ee(t),placeholder:t.placeholder,disabled:i.value||t.disabled,readonly:t.readonly||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","type","placeholder","disabled","readonly","class","aria-describedby","onUpdate:modelValue"]),O(t)?(a.openBlock(),a.createElementBlock("button",{key:0,type:"button",class:a.normalizeClass(["absolute right-3 top-1/2 -translate-y-1/2 ui-text hover:text-(--ui-text) transition-colors",U(t)?"opacity-50 cursor-not-allowed":""]),title:Y(t),"aria-label":ne(t),disabled:U(t),onClick:r=>se(t)},[h(t)?(a.openBlock(),a.createElementBlock("svg",Ue,[C(t)?(a.openBlock(),a.createElementBlock("path",ze)):(a.openBlock(),a.createElementBlock(a.Fragment,{key:1},[o[0]||(o[0]=a.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M2.4 10.5C3.3 8.4 7 4 12 4s8.7 4.4 9.6 6.5c.2.3.2.7 0 1C20.7 13.6 17 18 12 18s-8.7-4.4-9.6-6.5a1.1 1.1 0 010-1z"},null,-1)),o[1]||(o[1]=a.createElementVNode("circle",{cx:"12",cy:"11",r:"3","stroke-width":"2"},null,-1))],64))])):(a.openBlock(),a.createBlock(s,{key:1,icon:oe(t),class:a.normalizeClass(re(t))},null,8,["icon","class"]))],10,Ae)):a.createCommentVNode("",!0)],2)):t.type==="textarea"?(a.openBlock(),a.createBlock(_e.default,{key:1,id:l,"model-value":u(t.name),placeholder:t.placeholder,disabled:i.value||t.disabled,readonly:t.readonly||t.disabled,rows:t.rows||3,class:a.normalizeClass(["w-full rounded-md border px-3 py-2 focus:outline-none focus:ring-2 focus:ring-(--ui-primary)",p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","placeholder","disabled","readonly","rows","class","aria-describedby","onUpdate:modelValue"])):t.type==="select"?(a.openBlock(),a.createElementBlock("div",qe,[a.createElementVNode("div",$e,[a.createVNode(G.default,{id:l,"model-value":u(t.name),options:t.options,placeholder:t.placeholder||"Select an option",disabled:i.value||t.disabled,"has-error":p,"aria-describedby":b,"onUpdate:modelValue":r=>I(t,r)},null,8,["id","model-value","options","placeholder","disabled","has-error","aria-describedby","onUpdate:modelValue"])]),j(t)?(a.openBlock(),a.createBlock(V._sfc_main,{key:0,type:"button",variant:t.actionButton.variant||"outline",size:t.actionButton.size||"icon",class:a.normalizeClass(t.actionButton.class||""),title:t.actionButton.title||t.actionButton.label||"Action",disabled:L(t),loading:P(t),onClick:r=>R(t)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.actionButton.label||"+"),1)]),_:2},1032,["variant","size","class","title","disabled","loading","onClick"])):a.createCommentVNode("",!0)])):t.type==="multiselect"?(a.openBlock(),a.createElementBlock("div",De,[a.createElementVNode("div",Me,[a.createVNode(Be.default,{id:l,"model-value":u(t.name),options:t.options,disabled:i.value||t.disabled,placeholder:t.placeholder||"Select options","has-error":p,"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","options","disabled","placeholder","has-error","aria-describedby","onUpdate:modelValue"])]),j(t)?(a.openBlock(),a.createBlock(V._sfc_main,{key:0,type:"button",variant:t.actionButton.variant||"outline",size:t.actionButton.size||"icon",class:a.normalizeClass(t.actionButton.class||""),title:t.actionButton.title||t.actionButton.label||"Action",disabled:L(t),loading:P(t),onClick:r=>R(t)},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.actionButton.label||"+"),1)]),_:2},1032,["variant","size","class","title","disabled","loading","onClick"])):a.createCommentVNode("",!0)])):t.type==="combobox"?(a.openBlock(),a.createBlock(G.default,{key:4,id:l,"model-value":u(t.name),options:t.options,placeholder:t.placeholder||"Select or type to add new",disabled:i.value||t.disabled,"has-error":p,"aria-describedby":b,"allow-create":t.allowCreate,"onUpdate:modelValue":r=>I(t,r)},null,8,["id","model-value","options","placeholder","disabled","has-error","aria-describedby","allow-create","onUpdate:modelValue"])):t.type==="checkbox"?(a.openBlock(),a.createElementBlock("div",je,[a.createVNode(g._sfc_main,{id:l,"model-value":u(t.name),type:"checkbox",disabled:i.value||t.disabled,class:"h-4 w-4 rounded ui-border-strong","aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","aria-describedby","onUpdate:modelValue"]),a.createVNode(z.default,{for:l,class:"ml-2 text-sm ui-text"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.checkboxLabel||t.label),1)]),_:2},1032,["for"])])):t.type==="switch"?(a.openBlock(),a.createElementBlock("div",Le,[a.createElementVNode("button",{id:l,type:"button",role:"switch","aria-checked":u(t.name),disabled:i.value||t.disabled,class:a.normalizeClass(["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",u(t.name)?"ui-primary-bg border-(--ui-primary)":"ui-surface-soft border-(--ui-border-strong)",i.value||t.disabled?"cursor-not-allowed opacity-50":"cursor-pointer"]),onClick:r=>d(t.name,!u(t.name))},[a.createElementVNode("span",{class:a.normalizeClass(["inline-block h-4 w-4 transform rounded-full ui-surface border ui-border-strong transition-transform",u(t.name)?"translate-x-6":"translate-x-1"])},null,2)],10,Pe),a.createVNode(z.default,{for:l,class:"ml-3 text-sm ui-text"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(t.checkboxLabel||t.label),1)]),_:2},1032,["for"])])):t.type==="radio"?(a.openBlock(),a.createElementBlock("div",Re,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(t.options,r=>(a.openBlock(),a.createElementBlock("div",{key:r.value,class:"flex items-center"},[a.createVNode(g._sfc_main,{id:`${l}-${r.value}`,"model-value":u(t.name),type:"radio",value:r.value,disabled:i.value||t.disabled,class:"h-4 w-4 ui-border-strong","aria-describedby":b,"onUpdate:modelValue":he=>d(t.name,he)},null,8,["id","model-value","value","disabled","aria-describedby","onUpdate:modelValue"]),a.createVNode(z.default,{for:`${l}-${r.value}`,class:"ml-2 text-sm ui-text"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(r.label),1)]),_:2},1032,["for"])]))),128))])):t.type==="file"?(a.openBlock(),a.createBlock(K.default,{key:8,multiple:!1,accept:t.accept,"max-size":t.maxSize,variant:t.variant||"default",onFilesSelected:r=>ce(t,r),onFileRemoved:r=>ie(t,r)},null,8,["accept","max-size","variant","onFilesSelected","onFileRemoved"])):t.type==="multifile"?(a.openBlock(),a.createBlock(K.default,{key:9,multiple:t.multiple!==!1,accept:t.accept,"max-size":t.maxSize,"max-files":t.maxFiles,variant:t.variant||"default",onFilesSelected:r=>ue(t,r),onFileRemoved:r=>me(t,r)},null,8,["multiple","accept","max-size","max-files","variant","onFilesSelected","onFileRemoved"])):t.type==="slider"?(a.openBlock(),a.createBlock(ge.default,{key:10,"model-value":u(t.name),min:t.min,max:t.max,step:t.step,disabled:i.value||t.disabled,"onUpdate:modelValue":r=>le(t,r)},null,8,["model-value","min","max","step","disabled","onUpdate:modelValue"])):t.type==="range"?(a.openBlock(),a.createElementBlock("div",Oe,[a.createElementVNode("div",Ye,[a.createVNode(g._sfc_main,{id:l,"model-value":u(t.name),type:"range",min:t.min,max:t.max,step:t.step||1,disabled:i.value||t.disabled,class:"flex-1","aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","min","max","step","disabled","aria-describedby","onUpdate:modelValue"]),a.createElementVNode("span",Ie,a.toDisplayString(u(t.name)),1)])])):t.type==="date"?(a.openBlock(),a.createBlock(J._sfc_main,{key:12,id:l,"model-value":u(t.name),disabled:i.value||t.disabled,required:t.required,min:t.min,max:t.max,placeholder:t.placeholder||"Select date",format:t.format||"DD/MM/YYYY","enable-time":t.enableTime===!0,"minute-interval":t.minuteInterval||1,clearable:t.clearable!==!1,"show-today":t.showToday!==!1,"calendar-position":t.calendarPosition||"left-0 bottom-full","aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","required","min","max","placeholder","format","enable-time","minute-interval","clearable","show-today","calendar-position","aria-describedby","onUpdate:modelValue"])):t.type==="time"?(a.openBlock(),a.createBlock(g._sfc_main,{key:13,id:l,"model-value":u(t.name),type:"time",disabled:i.value||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","class","aria-describedby","onUpdate:modelValue"])):t.type==="datetime-local"?(a.openBlock(),a.createBlock(J._sfc_main,{key:14,id:l,"model-value":u(t.name),disabled:i.value||t.disabled,required:t.required,min:t.min,max:t.max,placeholder:t.placeholder||"Select date and time",format:t.format||"DD/MM/YYYY","enable-time":!0,"minute-interval":t.minuteInterval||1,clearable:t.clearable!==!1,"show-today":t.showToday!==!1,"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","required","min","max","placeholder","format","minute-interval","clearable","show-today","aria-describedby","onUpdate:modelValue"])):t.type==="month"?(a.openBlock(),a.createBlock(g._sfc_main,{key:15,id:l,"model-value":u(t.name),type:"month",disabled:i.value||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","class","aria-describedby","onUpdate:modelValue"])):t.type==="week"?(a.openBlock(),a.createBlock(g._sfc_main,{key:16,id:l,"model-value":u(t.name),type:"week",disabled:i.value||t.disabled,class:a.normalizeClass([p?"border-(--ui-danger)":"ui-border-strong",t.inputClass||""]),"aria-describedby":b,"onUpdate:modelValue":r=>d(t.name,r)},null,8,["id","model-value","disabled","class","aria-describedby","onUpdate:modelValue"])):a.createCommentVNode("",!0)],!0)]),_:2},1032,["id","label","required","error","error-message","help-text","class"]))],2))),128))],2)],2)],2))),128)),a.renderSlot(e.$slots,"actions",{formData:c.value,isValid:Z.value,submit:H},()=>[y.showSubmit?(a.openBlock(),a.createElementBlock("div",He,[y.showReset?(a.openBlock(),a.createBlock(V._sfc_main,{key:0,type:"button",variant:"outline",disabled:i.value,onClick:ye},{default:a.withCtx(()=>[...o[2]||(o[2]=[a.createTextVNode(" Reset ",-1)])]),_:1},8,["disabled"])):a.createCommentVNode("",!0),y.showCancel?(a.openBlock(),a.createBlock(V._sfc_main,{key:1,type:"button",variant:"outline",disabled:i.value,onClick:ve},{default:a.withCtx(()=>[...o[3]||(o[3]=[a.createTextVNode(" Cancel ",-1)])]),_:1},8,["disabled"])):a.createCommentVNode("",!0),a.createVNode(V._sfc_main,{type:"submit",disabled:i.value,loading:i.value,variant:"default"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(y.submitLabel),1)]),_:1},8,["disabled","loading"])])):a.createCommentVNode("",!0)],!0),y.showSubmit&&X.value?(a.openBlock(),a.createElementBlock("div",Je)):a.createCommentVNode("",!0)],32)])}}},Ke=xe._export_sfc(Ge,[["__scopeId","data-v-7f79d2a2"]]);exports.default=Ke;
|