@foormjs/vue 0.2.0 → 0.2.1
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 +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +377 -245
- package/dist/index.umd.cjs +2 -2
- package/dist/style.css +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -297,6 +297,7 @@ Every field slot (`#field:text`, `#field:select`, etc.) receives:
|
|
|
297
297
|
| `styles` | `string \| Record` | Inline styles |
|
|
298
298
|
| `disabled` | `boolean` | Evaluated disabled state |
|
|
299
299
|
| `hidden` | `boolean` | Evaluated hidden state |
|
|
300
|
+
| `readonly` | `boolean` | Evaluated readonly state |
|
|
300
301
|
| `optional` | `boolean` | Evaluated optional state |
|
|
301
302
|
| `required` | `boolean` | Inverse of optional |
|
|
302
303
|
| `type` | `string` | Field type |
|
|
@@ -307,7 +308,7 @@ Every field slot (`#field:text`, `#field:select`, etc.) receives:
|
|
|
307
308
|
| `maxLength` | `number` | Max length constraint |
|
|
308
309
|
| `formData` | `object` | Full form data |
|
|
309
310
|
| `formContext` | `object` | Form context |
|
|
310
|
-
| `attrs` | `Record` |
|
|
311
|
+
| `attrs` | `Record` | Custom attributes (evaluated, can be used with `v-bind`) |
|
|
311
312
|
|
|
312
313
|
### `OoField`
|
|
313
314
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TAtscriptAnnotatedType } from '@atscript/typescript/utils';
|
|
2
|
+
import { TAtscriptTypeObject } from '@atscript/typescript/utils';
|
|
2
3
|
import { TFoormEntryOptions } from 'foorm';
|
|
3
4
|
import { TFoormField } from 'foorm';
|
|
4
5
|
|
|
@@ -169,7 +170,7 @@ export declare interface TFoormComponentProps<V, TFormData, TFormContext> {
|
|
|
169
170
|
autocomplete?: string;
|
|
170
171
|
}
|
|
171
172
|
|
|
172
|
-
export declare function useFoorm<T
|
|
173
|
+
export declare function useFoorm<T extends TAtscriptAnnotatedType<TAtscriptTypeObject<any, any>>>(type: T): {
|
|
173
174
|
form: any;
|
|
174
175
|
formData: any;
|
|
175
176
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
function
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
|
+
var Z = (n, t, o) => t in n ? J(n, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[t] = o;
|
|
3
|
+
var R = (n, t, o) => Z(n, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { defineComponent as j, useModel as ee, inject as Q, ref as N, computed as v, watch as te, onUnmounted as oe, getCurrentInstance as X, renderSlot as E, unref as w, mergeModels as ne, provide as le, openBlock as d, createElementBlock as h, withModifiers as re, nextTick as ae, createBlock as O, withCtx as G, toDisplayString as m, createCommentVNode as T, Fragment as I, renderList as H, mergeProps as L, resolveDynamicComponent as Y, withDirectives as q, normalizeClass as M, createElementVNode as _, vModelDynamic as se, vShow as U, vModelSelect as ue, vModelRadio as ie, createTextVNode as K, vModelCheckbox as ce, reactive as de } from "vue";
|
|
5
|
+
function C(n, t) {
|
|
6
6
|
return typeof n == "function" ? n(t) : n;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const me = /* @__PURE__ */ new Set(["action", "paragraph"]);
|
|
9
|
+
function pe(n) {
|
|
9
10
|
var t;
|
|
10
11
|
const o = {};
|
|
11
|
-
for (const
|
|
12
|
-
|
|
12
|
+
for (const l of n)
|
|
13
|
+
me.has(l.type) || (o[l.field] = (t = l.value) !== null && t !== void 0 ? t : void 0);
|
|
13
14
|
return o;
|
|
14
15
|
}
|
|
15
|
-
function
|
|
16
|
+
function ve(n, t) {
|
|
16
17
|
return n.fields.some((o) => o.altAction === t);
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
if (!n)
|
|
19
|
+
function fe(n, t) {
|
|
20
|
+
if (!n)
|
|
21
|
+
return;
|
|
20
22
|
const o = {};
|
|
21
|
-
for (const [
|
|
22
|
-
o[
|
|
23
|
+
for (const [l, a] of Object.entries(n))
|
|
24
|
+
o[l] = C(a, t);
|
|
23
25
|
return o;
|
|
24
26
|
}
|
|
25
|
-
const
|
|
27
|
+
const be = /* @__PURE__ */ j({
|
|
26
28
|
__name: "VuilessField",
|
|
27
|
-
props: /* @__PURE__ */
|
|
29
|
+
props: /* @__PURE__ */ ne({
|
|
28
30
|
rules: {}
|
|
29
31
|
}, {
|
|
30
32
|
modelValue: {},
|
|
@@ -32,74 +34,74 @@ const ce = /* @__PURE__ */ T({
|
|
|
32
34
|
}),
|
|
33
35
|
emits: ["update:modelValue"],
|
|
34
36
|
setup(n) {
|
|
35
|
-
const t = n, o =
|
|
36
|
-
var
|
|
37
|
-
if ((
|
|
38
|
-
switch (
|
|
37
|
+
const t = n, o = ee(n, "modelValue"), l = Q("vuiless"), a = N(), s = N(!1), f = N(!1), p = v(() => {
|
|
38
|
+
var r;
|
|
39
|
+
if ((r = l == null ? void 0 : l.value) != null && r.firstValidation)
|
|
40
|
+
switch (l.value.firstValidation) {
|
|
39
41
|
case "on-change":
|
|
40
|
-
return
|
|
42
|
+
return l.value.firstSubmitHappened || s.value;
|
|
41
43
|
case "touched-on-blur":
|
|
42
|
-
return
|
|
44
|
+
return l.value.firstSubmitHappened || f.value && s.value;
|
|
43
45
|
case "on-blur":
|
|
44
|
-
return
|
|
46
|
+
return l.value.firstSubmitHappened || f.value;
|
|
45
47
|
case "on-submit":
|
|
46
|
-
return
|
|
48
|
+
return l.value.firstSubmitHappened;
|
|
47
49
|
case "none":
|
|
48
50
|
return !1;
|
|
49
51
|
}
|
|
50
52
|
return !1;
|
|
51
|
-
}),
|
|
52
|
-
if (
|
|
53
|
+
}), S = v(() => {
|
|
54
|
+
if (p.value || a.value)
|
|
53
55
|
return V();
|
|
54
56
|
});
|
|
55
|
-
|
|
56
|
-
a.value = void 0,
|
|
57
|
-
}),
|
|
58
|
-
var
|
|
59
|
-
(
|
|
60
|
-
}),
|
|
57
|
+
te([o], () => {
|
|
58
|
+
a.value = void 0, s.value = !0;
|
|
59
|
+
}), oe(() => {
|
|
60
|
+
var r;
|
|
61
|
+
(r = l == null ? void 0 : l.value) == null || r.unregister(X());
|
|
62
|
+
}), l != null && l.value && l.value.register(X(), {
|
|
61
63
|
validate: () => (a.value = V(), a.value || !0),
|
|
62
64
|
clearErrors: () => {
|
|
63
|
-
|
|
65
|
+
s.value = !1, f.value = !1, a.value = void 0;
|
|
64
66
|
},
|
|
65
67
|
reset: () => {
|
|
66
68
|
o.value = "";
|
|
67
69
|
}
|
|
68
70
|
});
|
|
69
71
|
function V() {
|
|
70
|
-
var
|
|
71
|
-
if ((
|
|
72
|
-
for (const
|
|
73
|
-
const
|
|
72
|
+
var r, u, k;
|
|
73
|
+
if ((r = t.rules) != null && r.length)
|
|
74
|
+
for (const b of t.rules) {
|
|
75
|
+
const x = b(
|
|
74
76
|
o.value,
|
|
75
|
-
(
|
|
76
|
-
(
|
|
77
|
+
(u = l == null ? void 0 : l.value) == null ? void 0 : u.formData,
|
|
78
|
+
(k = l == null ? void 0 : l.value) == null ? void 0 : k.formContext
|
|
77
79
|
);
|
|
78
|
-
if (
|
|
79
|
-
return
|
|
80
|
+
if (x !== !0)
|
|
81
|
+
return x || "Wrong value";
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
function i() {
|
|
83
|
-
|
|
85
|
+
f.value = !0;
|
|
84
86
|
}
|
|
85
|
-
const
|
|
86
|
-
v:
|
|
87
|
+
const y = {
|
|
88
|
+
v: v({
|
|
87
89
|
get: () => o.value,
|
|
88
|
-
set: (
|
|
90
|
+
set: (r) => o.value = r
|
|
89
91
|
})
|
|
90
92
|
};
|
|
91
|
-
return (
|
|
92
|
-
var
|
|
93
|
-
return
|
|
93
|
+
return (r, u) => {
|
|
94
|
+
var k, b;
|
|
95
|
+
return E(r.$slots, "default", {
|
|
94
96
|
onBlur: i,
|
|
95
|
-
error:
|
|
96
|
-
formData: (
|
|
97
|
-
formContext: (
|
|
98
|
-
model:
|
|
97
|
+
error: S.value,
|
|
98
|
+
formData: (k = w(l)) == null ? void 0 : k.formData,
|
|
99
|
+
formContext: (b = w(l)) == null ? void 0 : b.formContext,
|
|
100
|
+
model: y.v
|
|
99
101
|
});
|
|
100
102
|
};
|
|
101
103
|
}
|
|
102
|
-
}),
|
|
104
|
+
}), he = /* @__PURE__ */ j({
|
|
103
105
|
__name: "VuilessForm",
|
|
104
106
|
props: {
|
|
105
107
|
formData: {},
|
|
@@ -108,45 +110,45 @@ const ce = /* @__PURE__ */ T({
|
|
|
108
110
|
},
|
|
109
111
|
emits: ["submit"],
|
|
110
112
|
setup(n, { emit: t }) {
|
|
111
|
-
const o = n,
|
|
112
|
-
firstSubmitHappened:
|
|
113
|
+
const o = n, l = t, a = /* @__PURE__ */ new Map(), s = N(!1), f = v(() => ({
|
|
114
|
+
firstSubmitHappened: s.value,
|
|
113
115
|
firstValidation: o.firstValidation,
|
|
114
|
-
register: (i,
|
|
115
|
-
a.set(i,
|
|
116
|
+
register: (i, y) => {
|
|
117
|
+
a.set(i, y);
|
|
116
118
|
},
|
|
117
119
|
unregister: (i) => a.delete(i),
|
|
118
120
|
formData: o.formData,
|
|
119
121
|
formContext: o.formContext
|
|
120
122
|
}));
|
|
121
|
-
|
|
122
|
-
function
|
|
123
|
-
|
|
123
|
+
le("vuiless", f);
|
|
124
|
+
function p() {
|
|
125
|
+
s.value = !1;
|
|
124
126
|
for (const { clearErrors: i } of a.values())
|
|
125
127
|
i();
|
|
126
128
|
}
|
|
127
|
-
async function
|
|
129
|
+
async function S() {
|
|
128
130
|
for (const { reset: i } of a.values())
|
|
129
131
|
i();
|
|
130
|
-
await
|
|
132
|
+
await ae(), p();
|
|
131
133
|
}
|
|
132
134
|
function V() {
|
|
133
|
-
|
|
135
|
+
s.value = !0;
|
|
134
136
|
let i = !1;
|
|
135
137
|
if (o.firstValidation !== "none")
|
|
136
|
-
for (const { validate:
|
|
137
|
-
|
|
138
|
-
i ||
|
|
138
|
+
for (const { validate: y } of a.values())
|
|
139
|
+
y() !== !0 && (i = !0);
|
|
140
|
+
i || l("submit", o.formData);
|
|
139
141
|
}
|
|
140
|
-
return (i,
|
|
141
|
-
onSubmit:
|
|
142
|
+
return (i, y) => (d(), h("form", {
|
|
143
|
+
onSubmit: re(V, ["prevent"])
|
|
142
144
|
}, [
|
|
143
|
-
|
|
144
|
-
clearErrors:
|
|
145
|
-
reset:
|
|
145
|
+
E(i.$slots, "default", {
|
|
146
|
+
clearErrors: p,
|
|
147
|
+
reset: S
|
|
146
148
|
})
|
|
147
149
|
], 32));
|
|
148
150
|
}
|
|
149
|
-
}),
|
|
151
|
+
}), ye = /* @__PURE__ */ j({
|
|
150
152
|
__name: "oo-field",
|
|
151
153
|
props: {
|
|
152
154
|
field: {},
|
|
@@ -176,84 +178,89 @@ const ce = /* @__PURE__ */ T({
|
|
|
176
178
|
error: {}
|
|
177
179
|
},
|
|
178
180
|
setup(n) {
|
|
179
|
-
const t = n, o =
|
|
181
|
+
const t = n, o = Q(
|
|
180
182
|
"vuiless"
|
|
181
|
-
),
|
|
183
|
+
), l = v(() => ({
|
|
182
184
|
v: o.value.formData[t.field],
|
|
183
185
|
data: o.value.formData,
|
|
184
|
-
context: o.value.formContext ?? {}
|
|
185
|
-
|
|
186
|
-
|
|
186
|
+
context: o.value.formContext ?? {},
|
|
187
|
+
entry: void 0
|
|
188
|
+
})), a = v(() => C(t.optional, l.value)), s = v(() => C(t.disabled, l.value)), f = v(() => C(t.hidden, l.value)), p = v(() => ({
|
|
189
|
+
...l.value,
|
|
187
190
|
entry: {
|
|
188
191
|
field: t.field,
|
|
189
192
|
type: t.type,
|
|
190
193
|
component: t.component,
|
|
191
194
|
name: t.name || t.field,
|
|
192
|
-
disabled:
|
|
195
|
+
disabled: s.value,
|
|
193
196
|
optional: a.value,
|
|
194
|
-
hidden:
|
|
197
|
+
hidden: f.value
|
|
195
198
|
}
|
|
196
|
-
})),
|
|
197
|
-
const
|
|
198
|
-
return typeof
|
|
199
|
-
[
|
|
200
|
-
disabled:
|
|
199
|
+
})), S = v(() => C(t.label, p.value)), V = v(() => C(t.description, p.value)), i = v(() => C(t.hint, p.value)), y = v(() => C(t.placeholder, p.value)), r = v(() => C(t.options, p.value)), u = v(() => {
|
|
200
|
+
const A = C(t.classes, p.value);
|
|
201
|
+
return typeof A == "string" ? {
|
|
202
|
+
[A]: !0,
|
|
203
|
+
disabled: s.value,
|
|
201
204
|
required: !a.value
|
|
202
205
|
} : {
|
|
203
|
-
...
|
|
204
|
-
disabled:
|
|
206
|
+
...A,
|
|
207
|
+
disabled: s.value,
|
|
205
208
|
required: !a.value
|
|
206
209
|
};
|
|
207
|
-
}),
|
|
208
|
-
() =>
|
|
209
|
-
),
|
|
210
|
-
(
|
|
211
|
-
v:
|
|
212
|
-
data:
|
|
213
|
-
context:
|
|
214
|
-
entry:
|
|
210
|
+
}), k = v(
|
|
211
|
+
() => C(t.styles, p.value)
|
|
212
|
+
), b = v(() => fe(t.attrs, p.value)), x = v(() => t.validators.map(
|
|
213
|
+
(A) => (e, F, c) => A({
|
|
214
|
+
v: e,
|
|
215
|
+
data: F,
|
|
216
|
+
context: c ?? {},
|
|
217
|
+
entry: p.value.entry
|
|
215
218
|
})
|
|
216
219
|
));
|
|
217
|
-
return (
|
|
218
|
-
modelValue:
|
|
219
|
-
"onUpdate:modelValue":
|
|
220
|
-
rules:
|
|
220
|
+
return (A, e) => (d(), O(w(be), {
|
|
221
|
+
modelValue: w(o).formData[t.field],
|
|
222
|
+
"onUpdate:modelValue": e[0] || (e[0] = (F) => w(o).formData[t.field] = F),
|
|
223
|
+
rules: x.value
|
|
221
224
|
}, {
|
|
222
|
-
default:
|
|
223
|
-
A
|
|
224
|
-
onBlur:
|
|
225
|
-
error: n.error ||
|
|
226
|
-
model:
|
|
227
|
-
formData:
|
|
228
|
-
formContext:
|
|
229
|
-
label:
|
|
225
|
+
default: G((F) => [
|
|
226
|
+
E(A.$slots, "default", {
|
|
227
|
+
onBlur: F.onBlur,
|
|
228
|
+
error: n.error || F.error,
|
|
229
|
+
model: F.model,
|
|
230
|
+
formData: w(o).formData,
|
|
231
|
+
formContext: w(o).formContext,
|
|
232
|
+
label: S.value,
|
|
230
233
|
description: V.value,
|
|
231
234
|
hint: i.value,
|
|
232
|
-
placeholder:
|
|
235
|
+
placeholder: y.value,
|
|
233
236
|
classes: {
|
|
234
|
-
...
|
|
235
|
-
error: !!n.error || !!
|
|
237
|
+
...u.value,
|
|
238
|
+
error: !!n.error || !!F.error
|
|
236
239
|
},
|
|
237
|
-
styles:
|
|
240
|
+
styles: k.value,
|
|
238
241
|
optional: a.value,
|
|
239
|
-
disabled:
|
|
240
|
-
hidden:
|
|
242
|
+
disabled: s.value,
|
|
243
|
+
hidden: f.value,
|
|
241
244
|
type: n.type,
|
|
242
245
|
altAction: n.altAction,
|
|
243
246
|
component: n.component,
|
|
244
247
|
vName: n.name,
|
|
245
248
|
field: n.field,
|
|
246
|
-
options:
|
|
249
|
+
options: r.value,
|
|
247
250
|
maxLength: n.maxLength,
|
|
248
251
|
required: !a.value,
|
|
249
252
|
autocomplete: n.autocomplete,
|
|
250
|
-
attrs:
|
|
253
|
+
attrs: b.value
|
|
251
254
|
})
|
|
252
255
|
]),
|
|
253
256
|
_: 3
|
|
254
257
|
}, 8, ["modelValue", "rules"]));
|
|
255
258
|
}
|
|
256
|
-
}),
|
|
259
|
+
}), ge = { key: 0 }, xe = { key: 1 }, _e = { key: 0 }, Ve = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type", "disabled"], ke = { class: "oo-error-slot" }, Ce = { key: 4 }, Se = { key: 0 }, Ae = ["onUpdate:modelValue", "onBlur", "name", "disabled"], Fe = {
|
|
260
|
+
key: 0,
|
|
261
|
+
value: "",
|
|
262
|
+
disabled: ""
|
|
263
|
+
}, Be = ["value"], De = { class: "oo-error-slot" }, Ee = { class: "oo-field-label" }, Le = { key: 0 }, qe = { class: "oo-radio-group" }, we = ["value", "onUpdate:modelValue", "onBlur", "name", "disabled"], Te = { class: "oo-error-slot" }, $e = ["onUpdate:modelValue", "onBlur", "name", "disabled"], Me = { key: 0 }, Oe = { class: "oo-error-slot" }, Ne = ["onClick"], Ue = { key: 9 }, je = ["disabled"], We = /* @__PURE__ */ j({
|
|
257
264
|
__name: "oo-form",
|
|
258
265
|
props: {
|
|
259
266
|
form: {},
|
|
@@ -266,47 +273,54 @@ const ce = /* @__PURE__ */ T({
|
|
|
266
273
|
},
|
|
267
274
|
emits: ["submit", "action", "unsupported-action"],
|
|
268
275
|
setup(n, { emit: t }) {
|
|
269
|
-
const o = n,
|
|
276
|
+
const o = n, l = N({}), a = v(() => o.formData || l.value), s = v(() => ({
|
|
270
277
|
v: void 0,
|
|
271
278
|
data: a.value,
|
|
272
|
-
context: o.formContext ?? {}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
context: o.formContext ?? {},
|
|
280
|
+
entry: void 0
|
|
281
|
+
})), f = v(() => C(o.form.title, s.value)), p = v(() => C(o.form.submit.text, s.value)), S = v(() => C(o.form.submit.disabled, s.value));
|
|
282
|
+
function V(u) {
|
|
283
|
+
ve(o.form, u) ? i("action", u, a.value) : i("unsupported-action", u, a.value);
|
|
276
284
|
}
|
|
277
285
|
const i = t;
|
|
278
|
-
|
|
286
|
+
function y(u) {
|
|
287
|
+
return typeof u == "string" ? u : u.key;
|
|
288
|
+
}
|
|
289
|
+
function r(u) {
|
|
290
|
+
return typeof u == "string" ? u : u.label;
|
|
291
|
+
}
|
|
292
|
+
return (u, k) => (d(), O(w(he), {
|
|
279
293
|
"first-validation": n.firstValidation,
|
|
280
|
-
onSubmit:
|
|
294
|
+
onSubmit: k[0] || (k[0] = (b) => i("submit", b)),
|
|
281
295
|
"form-data": a.value,
|
|
282
296
|
"form-context": n.formContext
|
|
283
297
|
}, {
|
|
284
|
-
default:
|
|
285
|
-
|
|
286
|
-
clearErrors:
|
|
287
|
-
reset:
|
|
288
|
-
title:
|
|
298
|
+
default: G((b) => [
|
|
299
|
+
E(u.$slots, "form.header", {
|
|
300
|
+
clearErrors: b.clearErrors,
|
|
301
|
+
reset: b.reset,
|
|
302
|
+
title: f.value,
|
|
289
303
|
formContext: n.formContext,
|
|
290
|
-
disabled:
|
|
304
|
+
disabled: S.value
|
|
291
305
|
}, () => [
|
|
292
|
-
|
|
306
|
+
f.value ? (d(), h("h2", ge, m(f.value), 1)) : T("", !0)
|
|
293
307
|
]),
|
|
294
|
-
|
|
295
|
-
clearErrors:
|
|
296
|
-
reset:
|
|
308
|
+
E(u.$slots, "form.before", {
|
|
309
|
+
clearErrors: b.clearErrors,
|
|
310
|
+
reset: b.reset
|
|
297
311
|
}),
|
|
298
|
-
(
|
|
299
|
-
var
|
|
300
|
-
return
|
|
301
|
-
key:
|
|
302
|
-
}, { ref_for: !0 },
|
|
303
|
-
error: (
|
|
312
|
+
(d(!0), h(I, null, H(o.form.fields, (x) => {
|
|
313
|
+
var A;
|
|
314
|
+
return d(), O(ye, L({
|
|
315
|
+
key: x.field
|
|
316
|
+
}, { ref_for: !0 }, x, {
|
|
317
|
+
error: (A = n.errors) == null ? void 0 : A[x.field]
|
|
304
318
|
}), {
|
|
305
|
-
default:
|
|
306
|
-
|
|
307
|
-
var
|
|
319
|
+
default: G((e) => [
|
|
320
|
+
E(u.$slots, `field:${e.type}`, L({ ref_for: !0 }, e), () => {
|
|
321
|
+
var F, c, B;
|
|
308
322
|
return [
|
|
309
|
-
|
|
323
|
+
x.component && ((F = o.components) != null && F[x.component]) ? (d(), O(Y(o.components[x.component]), L({
|
|
310
324
|
key: 0,
|
|
311
325
|
"on-blur": e.onBlur,
|
|
312
326
|
error: e.error,
|
|
@@ -333,8 +347,8 @@ const ce = /* @__PURE__ */ T({
|
|
|
333
347
|
onAction: V
|
|
334
348
|
}, { ref_for: !0 }, e.attrs, {
|
|
335
349
|
modelValue: e.model.value,
|
|
336
|
-
"onUpdate:modelValue": (
|
|
337
|
-
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) :
|
|
350
|
+
"onUpdate:modelValue": (g) => e.model.value = g
|
|
351
|
+
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) : x.component && !((c = o.components) != null && c[x.component]) ? (d(), h("div", xe, " [" + m(e.label) + '] Component "' + m(e.component) + '" not supplied ', 1)) : (B = o.types) != null && B[x.type] ? (d(), O(Y(o.types[x.type]), L({
|
|
338
352
|
key: 2,
|
|
339
353
|
"on-blur": e.onBlur,
|
|
340
354
|
error: e.error,
|
|
@@ -361,57 +375,137 @@ const ce = /* @__PURE__ */ T({
|
|
|
361
375
|
onAction: V
|
|
362
376
|
}, { ref_for: !0 }, e.attrs, {
|
|
363
377
|
modelValue: e.model.value,
|
|
364
|
-
"onUpdate:modelValue": (
|
|
365
|
-
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) : ["text", "password", "number"].includes(e.type) ? (
|
|
378
|
+
"onUpdate:modelValue": (g) => e.model.value = g
|
|
379
|
+
}), null, 16, ["on-blur", "error", "model", "form-data", "form-context", "label", "description", "hint", "placeholder", "class", "style", "optional", "required", "disabled", "hidden", "type", "alt-action", "name", "field", "options", "max-length", "autocomplete", "modelValue", "onUpdate:modelValue"])) : ["text", "password", "number"].includes(e.type) ? q((d(), h("div", {
|
|
366
380
|
key: 3,
|
|
367
|
-
class:
|
|
381
|
+
class: M(["oo-default-field", e.classes])
|
|
368
382
|
}, [
|
|
369
|
-
|
|
370
|
-
e.description ? (
|
|
371
|
-
|
|
372
|
-
"onUpdate:modelValue": (
|
|
383
|
+
_("label", null, m(e.label), 1),
|
|
384
|
+
e.description ? (d(), h("span", _e, m(e.description), 1)) : T("", !0),
|
|
385
|
+
q(_("input", L({
|
|
386
|
+
"onUpdate:modelValue": (g) => e.model.value = g,
|
|
373
387
|
onBlur: e.onBlur,
|
|
374
388
|
placeholder: e.placeholder,
|
|
375
389
|
autocomplete: e.autocomplete,
|
|
376
390
|
name: e.vName,
|
|
377
|
-
type: e.type
|
|
378
|
-
|
|
379
|
-
|
|
391
|
+
type: e.type,
|
|
392
|
+
disabled: e.disabled
|
|
393
|
+
}, { ref_for: !0 }, e.attrs), null, 16, Ve), [
|
|
394
|
+
[se, e.model.value]
|
|
395
|
+
]),
|
|
396
|
+
_("div", ke, m(e.error || e.hint), 1)
|
|
397
|
+
], 2)), [
|
|
398
|
+
[U, !e.hidden]
|
|
399
|
+
]) : e.type === "paragraph" ? (d(), h("p", Ce, m(e.description), 1)) : e.type === "select" ? q((d(), h("div", {
|
|
400
|
+
key: 5,
|
|
401
|
+
class: M(["oo-default-field", e.classes])
|
|
402
|
+
}, [
|
|
403
|
+
_("label", null, m(e.label), 1),
|
|
404
|
+
e.description ? (d(), h("span", Se, m(e.description), 1)) : T("", !0),
|
|
405
|
+
q(_("select", L({
|
|
406
|
+
"onUpdate:modelValue": (g) => e.model.value = g,
|
|
407
|
+
onBlur: e.onBlur,
|
|
408
|
+
name: e.vName,
|
|
409
|
+
disabled: e.disabled
|
|
410
|
+
}, { ref_for: !0 }, e.attrs), [
|
|
411
|
+
e.placeholder ? (d(), h("option", Fe, m(e.placeholder), 1)) : T("", !0),
|
|
412
|
+
(d(!0), h(I, null, H(e.options, (g) => (d(), h("option", {
|
|
413
|
+
key: y(g),
|
|
414
|
+
value: y(g)
|
|
415
|
+
}, m(r(g)), 9, Be))), 128))
|
|
416
|
+
], 16, Ae), [
|
|
417
|
+
[ue, e.model.value]
|
|
418
|
+
]),
|
|
419
|
+
_("div", De, m(e.error || e.hint), 1)
|
|
420
|
+
], 2)), [
|
|
421
|
+
[U, !e.hidden]
|
|
422
|
+
]) : e.type === "radio" ? q((d(), h("div", {
|
|
423
|
+
key: 6,
|
|
424
|
+
class: M(["oo-default-field oo-radio-field", e.classes])
|
|
425
|
+
}, [
|
|
426
|
+
_("span", Ee, m(e.label), 1),
|
|
427
|
+
e.description ? (d(), h("span", Le, m(e.description), 1)) : T("", !0),
|
|
428
|
+
_("div", qe, [
|
|
429
|
+
(d(!0), h(I, null, H(e.options, (g) => (d(), h("label", {
|
|
430
|
+
key: y(g)
|
|
431
|
+
}, [
|
|
432
|
+
q(_("input", L({
|
|
433
|
+
type: "radio",
|
|
434
|
+
value: y(g),
|
|
435
|
+
"onUpdate:modelValue": (W) => e.model.value = W,
|
|
436
|
+
onBlur: e.onBlur,
|
|
437
|
+
name: e.vName,
|
|
438
|
+
disabled: e.disabled
|
|
439
|
+
}, { ref_for: !0 }, e.attrs), null, 16, we), [
|
|
440
|
+
[ie, e.model.value]
|
|
441
|
+
]),
|
|
442
|
+
K(" " + m(r(g)), 1)
|
|
443
|
+
]))), 128))
|
|
444
|
+
]),
|
|
445
|
+
_("div", Te, m(e.error || e.hint), 1)
|
|
446
|
+
], 2)), [
|
|
447
|
+
[U, !e.hidden]
|
|
448
|
+
]) : e.type === "checkbox" ? q((d(), h("div", {
|
|
449
|
+
key: 7,
|
|
450
|
+
class: M(["oo-default-field oo-checkbox-field", e.classes])
|
|
451
|
+
}, [
|
|
452
|
+
_("label", null, [
|
|
453
|
+
q(_("input", L({
|
|
454
|
+
type: "checkbox",
|
|
455
|
+
"onUpdate:modelValue": (g) => e.model.value = g,
|
|
456
|
+
onBlur: e.onBlur,
|
|
457
|
+
name: e.vName,
|
|
458
|
+
disabled: e.disabled
|
|
459
|
+
}, { ref_for: !0 }, e.attrs), null, 16, $e), [
|
|
460
|
+
[ce, e.model.value]
|
|
461
|
+
]),
|
|
462
|
+
K(" " + m(e.label), 1)
|
|
380
463
|
]),
|
|
381
|
-
|
|
382
|
-
|
|
464
|
+
e.description ? (d(), h("span", Me, m(e.description), 1)) : T("", !0),
|
|
465
|
+
_("div", Oe, m(e.error || e.hint), 1)
|
|
466
|
+
], 2)), [
|
|
467
|
+
[U, !e.hidden]
|
|
468
|
+
]) : e.type === "action" ? (d(), h("div", {
|
|
469
|
+
key: 8,
|
|
470
|
+
class: M(["oo-default-field oo-action-field", e.classes])
|
|
471
|
+
}, [
|
|
472
|
+
_("button", {
|
|
473
|
+
type: "button",
|
|
474
|
+
onClick: (g) => V(e.altAction)
|
|
475
|
+
}, m(e.label), 9, Ne)
|
|
476
|
+
], 2)) : (d(), h("div", Ue, " [" + m(e.label) + '] Not supported field type "' + m(e.type) + '" ' + m(e.component), 1))
|
|
383
477
|
];
|
|
384
478
|
})
|
|
385
479
|
]),
|
|
386
480
|
_: 2
|
|
387
481
|
}, 1040, ["error"]);
|
|
388
482
|
}), 128)),
|
|
389
|
-
|
|
390
|
-
clearErrors:
|
|
391
|
-
reset:
|
|
392
|
-
disabled:
|
|
483
|
+
E(u.$slots, "form.after", {
|
|
484
|
+
clearErrors: b.clearErrors,
|
|
485
|
+
reset: b.reset,
|
|
486
|
+
disabled: S.value,
|
|
393
487
|
formContext: n.formContext
|
|
394
488
|
}),
|
|
395
|
-
|
|
396
|
-
disabled:
|
|
397
|
-
text:
|
|
398
|
-
clearErrors:
|
|
399
|
-
reset:
|
|
489
|
+
E(u.$slots, "form.submit", {
|
|
490
|
+
disabled: S.value,
|
|
491
|
+
text: p.value,
|
|
492
|
+
clearErrors: b.clearErrors,
|
|
493
|
+
reset: b.reset,
|
|
400
494
|
formContext: n.formContext
|
|
401
495
|
}, () => [
|
|
402
|
-
|
|
496
|
+
_("button", { disabled: S.value }, m(p.value), 9, je)
|
|
403
497
|
]),
|
|
404
|
-
|
|
405
|
-
disabled:
|
|
406
|
-
clearErrors:
|
|
407
|
-
reset:
|
|
498
|
+
E(u.$slots, "form.footer", {
|
|
499
|
+
disabled: S.value,
|
|
500
|
+
clearErrors: b.clearErrors,
|
|
501
|
+
reset: b.reset,
|
|
408
502
|
formContext: n.formContext
|
|
409
503
|
})
|
|
410
504
|
]),
|
|
411
505
|
_: 3
|
|
412
506
|
}, 8, ["first-validation", "form-data", "form-context"]));
|
|
413
507
|
}
|
|
414
|
-
}),
|
|
508
|
+
}), Ie = {
|
|
415
509
|
// Node.js Globals
|
|
416
510
|
global: null,
|
|
417
511
|
process: null,
|
|
@@ -498,121 +592,159 @@ const ce = /* @__PURE__ */ T({
|
|
|
498
592
|
eval: null,
|
|
499
593
|
__ctx__: null
|
|
500
594
|
};
|
|
501
|
-
class
|
|
595
|
+
class He {
|
|
502
596
|
constructor() {
|
|
503
|
-
|
|
597
|
+
R(this, "cache", /* @__PURE__ */ new Map());
|
|
504
598
|
}
|
|
505
599
|
call(t, o) {
|
|
506
600
|
return this.getFn(t)(o);
|
|
507
601
|
}
|
|
508
602
|
getFn(t) {
|
|
509
603
|
let o = this.cache.get(t);
|
|
510
|
-
return o || (o =
|
|
604
|
+
return o || (o = ze(t), this.cache.set(t, o)), o;
|
|
511
605
|
}
|
|
512
606
|
}
|
|
513
|
-
function
|
|
607
|
+
function ze(n) {
|
|
514
608
|
const t = `with(__ctx__){
|
|
515
609
|
${n}
|
|
516
610
|
}`, o = new Function("__ctx__", t);
|
|
517
|
-
return (
|
|
518
|
-
const a = Object.freeze(Object.assign({},
|
|
611
|
+
return (l) => {
|
|
612
|
+
const a = Object.freeze(Object.assign({}, Ie, l));
|
|
519
613
|
return o(a);
|
|
520
614
|
};
|
|
521
615
|
}
|
|
522
|
-
const
|
|
523
|
-
function
|
|
616
|
+
const P = new He();
|
|
617
|
+
function D(n) {
|
|
524
618
|
const t = `return (${n})(v, data, context, entry)`;
|
|
525
|
-
return
|
|
619
|
+
return P.getFn(t);
|
|
526
620
|
}
|
|
527
|
-
function
|
|
621
|
+
function z(n) {
|
|
528
622
|
const t = `return (${n})(data, context)`;
|
|
529
|
-
return
|
|
623
|
+
return P.getFn(t);
|
|
530
624
|
}
|
|
531
|
-
function
|
|
625
|
+
function Ge(n) {
|
|
532
626
|
const t = `return (${n})(v, data, context)`;
|
|
533
|
-
return
|
|
627
|
+
return P.getFn(t);
|
|
628
|
+
}
|
|
629
|
+
const Pe = /* @__PURE__ */ new Set(["action", "paragraph", "select", "radio", "checkbox"]);
|
|
630
|
+
function Re(n) {
|
|
631
|
+
return (Array.isArray(n) ? n : [n]).map((o) => {
|
|
632
|
+
if (typeof o == "object" && o !== null && "label" in o) {
|
|
633
|
+
const { label: l, value: a } = o;
|
|
634
|
+
return a !== void 0 ? { key: a, label: l } : l;
|
|
635
|
+
}
|
|
636
|
+
return String(o);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
function $(n, t, o, l, a) {
|
|
640
|
+
const s = o.get(t);
|
|
641
|
+
if (typeof s == "string")
|
|
642
|
+
return l(s);
|
|
643
|
+
const f = o.get(n);
|
|
644
|
+
return f !== void 0 ? f : a;
|
|
534
645
|
}
|
|
535
|
-
function
|
|
536
|
-
const
|
|
537
|
-
if (
|
|
538
|
-
return
|
|
539
|
-
const
|
|
540
|
-
|
|
646
|
+
function Xe(n) {
|
|
647
|
+
const t = n.get("foorm.attr"), o = n.get("foorm.fn.attr");
|
|
648
|
+
if (!t && !o)
|
|
649
|
+
return;
|
|
650
|
+
const l = {};
|
|
651
|
+
if (t) {
|
|
652
|
+
const a = Array.isArray(t) ? t : [t];
|
|
653
|
+
for (const s of a)
|
|
654
|
+
if (typeof s == "object" && s !== null && "name" in s && "value" in s) {
|
|
655
|
+
const { name: f, value: p } = s;
|
|
656
|
+
l[f] = p;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (o) {
|
|
660
|
+
const a = Array.isArray(o) ? o : [o];
|
|
661
|
+
for (const s of a)
|
|
662
|
+
if (typeof s == "object" && s !== null && "name" in s && "fn" in s) {
|
|
663
|
+
const { name: f, fn: p } = s;
|
|
664
|
+
l[f] = D(p);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return Object.keys(l).length > 0 ? l : void 0;
|
|
541
668
|
}
|
|
542
|
-
function
|
|
543
|
-
var t, o
|
|
544
|
-
const
|
|
545
|
-
const
|
|
546
|
-
return typeof
|
|
547
|
-
})(),
|
|
548
|
-
for (const [
|
|
549
|
-
const
|
|
550
|
-
if (
|
|
551
|
-
const
|
|
552
|
-
for (const
|
|
553
|
-
typeof
|
|
669
|
+
function Ye(n) {
|
|
670
|
+
var t, o;
|
|
671
|
+
const l = n.metadata, a = n.type.props, s = $("foorm.title", "foorm.fn.title", l, z, ""), f = $("foorm.submit.text", "foorm.fn.submit.text", l, z, "Submit"), p = (() => {
|
|
672
|
+
const i = l.get("foorm.fn.submit.disabled");
|
|
673
|
+
return typeof i == "string" ? z(i) : !1;
|
|
674
|
+
})(), S = { text: f, disabled: p }, V = [];
|
|
675
|
+
for (const [i, y] of a.entries()) {
|
|
676
|
+
const r = y.metadata, u = (t = y.type) === null || t === void 0 ? void 0 : t.tags, k = r.get("foorm.type"), b = u ? [...u].find((c) => Pe.has(c)) : void 0, x = (o = k ?? b) !== null && o !== void 0 ? o : "text", A = [], e = r.get("foorm.validate");
|
|
677
|
+
if (e) {
|
|
678
|
+
const c = Array.isArray(e) ? e : [e];
|
|
679
|
+
for (const B of c)
|
|
680
|
+
typeof B == "string" && A.push(Ge(B));
|
|
554
681
|
}
|
|
555
|
-
const
|
|
556
|
-
field:
|
|
557
|
-
type:
|
|
558
|
-
component:
|
|
559
|
-
autocomplete:
|
|
560
|
-
altAction:
|
|
561
|
-
order:
|
|
562
|
-
name:
|
|
563
|
-
label:
|
|
564
|
-
description:
|
|
565
|
-
hint:
|
|
566
|
-
placeholder:
|
|
682
|
+
const F = {
|
|
683
|
+
field: i,
|
|
684
|
+
type: x,
|
|
685
|
+
component: r.get("foorm.component"),
|
|
686
|
+
autocomplete: r.get("foorm.autocomplete"),
|
|
687
|
+
altAction: r.get("foorm.altAction"),
|
|
688
|
+
order: r.get("foorm.order"),
|
|
689
|
+
name: i,
|
|
690
|
+
label: $("meta.label", "foorm.fn.label", r, D, i),
|
|
691
|
+
description: $("meta.description", "foorm.fn.description", r, D, ""),
|
|
692
|
+
hint: $("meta.hint", "foorm.fn.hint", r, D, ""),
|
|
693
|
+
placeholder: $("meta.placeholder", "foorm.fn.placeholder", r, D, ""),
|
|
567
694
|
optional: (() => {
|
|
568
|
-
var
|
|
569
|
-
const
|
|
570
|
-
return typeof
|
|
695
|
+
var c;
|
|
696
|
+
const B = r.get("foorm.fn.optional");
|
|
697
|
+
return typeof B == "string" ? D(B) : (c = y.optional) !== null && c !== void 0 ? c : !1;
|
|
571
698
|
})(),
|
|
572
699
|
disabled: (() => {
|
|
573
|
-
const
|
|
574
|
-
return typeof
|
|
700
|
+
const c = r.get("foorm.fn.disabled");
|
|
701
|
+
return typeof c == "string" ? D(c) : r.get("foorm.disabled") !== void 0;
|
|
575
702
|
})(),
|
|
576
703
|
hidden: (() => {
|
|
577
|
-
const
|
|
578
|
-
return typeof
|
|
704
|
+
const c = r.get("foorm.fn.hidden");
|
|
705
|
+
return typeof c == "string" ? D(c) : r.get("foorm.hidden") !== void 0;
|
|
579
706
|
})(),
|
|
580
707
|
classes: (() => {
|
|
581
|
-
const
|
|
582
|
-
if (typeof
|
|
583
|
-
return
|
|
708
|
+
const c = r.get("foorm.fn.classes");
|
|
709
|
+
if (typeof c == "string")
|
|
710
|
+
return D(c);
|
|
584
711
|
})(),
|
|
585
712
|
styles: (() => {
|
|
586
|
-
const
|
|
587
|
-
if (typeof
|
|
588
|
-
return
|
|
713
|
+
const c = r.get("foorm.fn.styles");
|
|
714
|
+
if (typeof c == "string")
|
|
715
|
+
return D(c);
|
|
589
716
|
})(),
|
|
590
717
|
options: (() => {
|
|
591
|
-
const
|
|
592
|
-
if (typeof
|
|
593
|
-
return
|
|
718
|
+
const c = r.get("foorm.fn.options");
|
|
719
|
+
if (typeof c == "string")
|
|
720
|
+
return D(c);
|
|
721
|
+
const B = r.get("foorm.options");
|
|
722
|
+
if (B)
|
|
723
|
+
return Re(B);
|
|
594
724
|
})(),
|
|
595
|
-
value:
|
|
596
|
-
validators:
|
|
725
|
+
value: r.get("foorm.value"),
|
|
726
|
+
validators: A,
|
|
727
|
+
// Custom attributes/props
|
|
728
|
+
attrs: Xe(r),
|
|
597
729
|
// ATScript @expect constraints
|
|
598
|
-
maxLength:
|
|
599
|
-
minLength:
|
|
600
|
-
min:
|
|
601
|
-
max:
|
|
730
|
+
maxLength: r.get("expect.maxLength"),
|
|
731
|
+
minLength: r.get("expect.minLength"),
|
|
732
|
+
min: r.get("expect.min"),
|
|
733
|
+
max: r.get("expect.max")
|
|
602
734
|
};
|
|
603
|
-
|
|
735
|
+
V.push(F);
|
|
604
736
|
}
|
|
605
|
-
return
|
|
606
|
-
var
|
|
607
|
-
return ((
|
|
608
|
-
}), { title:
|
|
737
|
+
return V.sort((i, y) => {
|
|
738
|
+
var r, u;
|
|
739
|
+
return ((r = i.order) !== null && r !== void 0 ? r : 1 / 0) - ((u = y.order) !== null && u !== void 0 ? u : 1 / 0);
|
|
740
|
+
}), { title: s, submit: S, fields: V };
|
|
609
741
|
}
|
|
610
|
-
function
|
|
611
|
-
const t =
|
|
742
|
+
function Je(n) {
|
|
743
|
+
const t = Ye(n), o = de(pe(t.fields));
|
|
612
744
|
return { form: t, formData: o };
|
|
613
745
|
}
|
|
614
746
|
export {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
747
|
+
ye as OoField,
|
|
748
|
+
We as OoForm,
|
|
749
|
+
Je as useFoorm
|
|
618
750
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(h,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(h=typeof globalThis<"u"?globalThis:h||self,e(h.index={},h.Vue))})(this,function(h,e){"use strict";var Z=Object.defineProperty;var ee=(h,e,f)=>e in h?Z(h,e,{enumerable:!0,configurable:!0,writable:!0,value:f}):h[e]=f;var L=(h,e,f)=>ee(h,typeof e!="symbol"?e+"":e,f);function f(l,o){return typeof l=="function"?l(o):l}function q(l){var o;const n={};for(const a of l)a.type!=="action"&&(n[a.field]=(o=a.value)!==null&&o!==void 0?o:void 0);return n}function w(l,o){return l.fields.some(n=>n.altAction===o)}function $(l,o){if(!l)return;const n={};for(const[a,s]of Object.entries(l))n[a]=f(s,o);return n}const T=e.defineComponent({__name:"VuilessField",props:e.mergeModels({rules:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(l){const o=l,n=e.useModel(l,"modelValue"),a=e.inject("vuiless"),s=e.ref(),d=e.ref(!1),y=e.ref(!1),g=e.computed(()=>{var m;if((m=a==null?void 0:a.value)!=null&&m.firstValidation)switch(a.value.firstValidation){case"on-change":return a.value.firstSubmitHappened||d.value;case"touched-on-blur":return a.value.firstSubmitHappened||y.value&&d.value;case"on-blur":return a.value.firstSubmitHappened||y.value;case"on-submit":return a.value.firstSubmitHappened;case"none":return!1}return!1}),x=e.computed(()=>{if(g.value||s.value)return B()});e.watch([n],()=>{s.value=void 0,d.value=!0}),e.onUnmounted(()=>{var m;(m=a==null?void 0:a.value)==null||m.unregister(e.getCurrentInstance())}),a!=null&&a.value&&a.value.register(e.getCurrentInstance(),{validate:()=>(s.value=B(),s.value||!0),clearErrors:()=>{d.value=!1,y.value=!1,s.value=void 0},reset:()=>{n.value=""}});function B(){var m,r,i;if((m=o.rules)!=null&&m.length)for(const v of o.rules){const t=v(n.value,(r=a==null?void 0:a.value)==null?void 0:r.formData,(i=a==null?void 0:a.value)==null?void 0:i.formContext);if(t!==!0)return t||"Wrong value"}}function u(){y.value=!0}const c={v:e.computed({get:()=>n.value,set:m=>n.value=m})};return(m,r)=>{var i,v;return e.renderSlot(m.$slots,"default",{onBlur:u,error:x.value,formData:(i=e.unref(a))==null?void 0:i.formData,formContext:(v=e.unref(a))==null?void 0:v.formContext,model:c.v})}}}),M=e.defineComponent({__name:"VuilessForm",props:{formData:{},formContext:{},firstValidation:{default:"on-change"}},emits:["submit"],setup(l,{emit:o}){const n=l,a=o,s=new Map,d=e.ref(!1),y=e.computed(()=>({firstSubmitHappened:d.value,firstValidation:n.firstValidation,register:(u,c)=>{s.set(u,c)},unregister:u=>s.delete(u),formData:n.formData,formContext:n.formContext}));e.provide("vuiless",y);function g(){d.value=!1;for(const{clearErrors:u}of s.values())u()}async function x(){for(const{reset:u}of s.values())u();await e.nextTick(),g()}function B(){d.value=!0;let u=!1;if(n.firstValidation!=="none")for(const{validate:c}of s.values())c()!==!0&&(u=!0);u||a("submit",n.formData)}return(u,c)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(B,["prevent"])},[e.renderSlot(u.$slots,"default",{clearErrors:g,reset:x})],32))}}),A=e.defineComponent({__name:"oo-field",props:{field:{},type:{},component:{},autocomplete:{},altAction:{},order:{},name:{},label:{type:[String,Function]},description:{type:[String,Function]},hint:{type:[String,Function]},placeholder:{type:[String,Function]},optional:{type:[Boolean,Function]},disabled:{type:[Boolean,Function]},hidden:{type:[Boolean,Function]},classes:{type:[String,Object,Function]},styles:{type:[String,Object,Function]},options:{type:[Array,Function]},attrs:{},value:{},validators:{},maxLength:{},minLength:{},min:{},max:{},error:{}},setup(l){const o=l,n=e.inject("vuiless"),a=e.computed(()=>({v:n.value.formData[o.field],data:n.value.formData,context:n.value.formContext??{}})),s=e.computed(()=>f(o.optional,a.value)),d=e.computed(()=>f(o.disabled,a.value)),y=e.computed(()=>f(o.hidden,a.value)),g=e.computed(()=>({...a.value,entry:{field:o.field,type:o.type,component:o.component,name:o.name||o.field,disabled:d.value,optional:s.value,hidden:y.value}})),x=e.computed(()=>f(o.label,g.value)),B=e.computed(()=>f(o.description,g.value)),u=e.computed(()=>f(o.hint,g.value)),c=e.computed(()=>f(o.placeholder,g.value)),m=e.computed(()=>f(o.options,g.value)),r=e.computed(()=>{const S=f(o.classes,g.value);return typeof S=="string"?{[S]:!0,disabled:d.value,required:!s.value}:{...S||{},disabled:d.value,required:!s.value}}),i=e.computed(()=>f(o.styles,g.value)),v=e.computed(()=>$(o.attrs,g.value)),t=e.computed(()=>o.validators.map(S=>(D,b,C)=>S({v:D,data:b,context:C??{},entry:g.value.entry})));return(S,D)=>(e.openBlock(),e.createBlock(e.unref(T),{modelValue:e.unref(n).formData[o.field],"onUpdate:modelValue":D[0]||(D[0]=b=>e.unref(n).formData[o.field]=b),rules:t.value},{default:e.withCtx(b=>[e.renderSlot(S.$slots,"default",{onBlur:b.onBlur,error:l.error||b.error,model:b.model,formData:e.unref(n).formData,formContext:e.unref(n).formContext,label:x.value,description:B.value,hint:u.value,placeholder:c.value,classes:{...r.value,error:!!l.error||!!b.error},styles:i.value,optional:s.value,disabled:d.value,hidden:y.value,type:l.type,altAction:l.altAction,component:l.component,vName:l.name,field:l.field,options:m.value,maxLength:l.maxLength,required:!s.value,autocomplete:l.autocomplete,attrs:v.value})]),_:3},8,["modelValue","rules"]))}}),N={key:0},j={key:1},I={key:0},O=["onUpdate:modelValue","onBlur","placeholder","autocomplete","name","type"],U={class:"oo-error-slot"},P={key:4},H={key:5},z=["disabled"],G=e.defineComponent({__name:"oo-form",props:{form:{},formData:{},formContext:{},firstValidation:{},components:{},types:{},errors:{}},emits:["submit","action","unsupported-action"],setup(l,{emit:o}){const n=l,a=e.ref({}),s=e.computed(()=>n.formData||a.value),d=e.computed(()=>({v:void 0,data:s.value,context:n.formContext??{}})),y=e.computed(()=>f(n.form.title,d.value)),g=e.computed(()=>f(n.form.submit.text,d.value)),x=e.computed(()=>f(n.form.submit.disabled,d.value));function B(c){w(n.form,c)?u("action",c,s.value):u("unsupported-action",c,s.value)}const u=o;return(c,m)=>(e.openBlock(),e.createBlock(e.unref(M),{"first-validation":l.firstValidation,onSubmit:m[0]||(m[0]=r=>u("submit",r)),"form-data":s.value,"form-context":l.formContext},{default:e.withCtx(r=>[e.renderSlot(c.$slots,"form.header",{clearErrors:r.clearErrors,reset:r.reset,title:y.value,formContext:l.formContext,disabled:x.value},()=>[y.value?(e.openBlock(),e.createElementBlock("h2",N,e.toDisplayString(y.value),1)):e.createCommentVNode("",!0)]),e.renderSlot(c.$slots,"form.before",{clearErrors:r.clearErrors,reset:r.reset}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.form.fields,i=>{var v;return e.openBlock(),e.createBlock(A,e.mergeProps({key:i.field},{ref_for:!0},i,{error:(v=l.errors)==null?void 0:v[i.field]}),{default:e.withCtx(t=>[e.renderSlot(c.$slots,`field:${t.type}`,e.mergeProps({ref_for:!0},t),()=>{var S,D,b;return[i.component&&((S=n.components)!=null&&S[i.component])?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.components[i.component]),e.mergeProps({key:0,"on-blur":t.onBlur,error:t.error,model:t.model,"form-data":t.formData,"form-context":t.formContext,label:t.label,description:t.description,hint:t.hint,placeholder:t.placeholder,class:t.classes,style:t.styles,optional:t.optional,required:!t.required,disabled:t.disabled,hidden:t.hidden,type:t.type,"alt-action":t.altAction,name:t.vName,field:t,options:t.options,"max-length":t.maxLength,autocomplete:t.autocomplete,onAction:B},{ref_for:!0},t.attrs,{modelValue:t.model.value,"onUpdate:modelValue":C=>t.model.value=C}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):i.component&&!((D=n.components)!=null&&D[i.component])?(e.openBlock(),e.createElementBlock("div",j," ["+e.toDisplayString(t.label)+'] Component "'+e.toDisplayString(t.component)+'" not supplied ',1)):(b=n.types)!=null&&b[i.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.types[i.type]),e.mergeProps({key:2,"on-blur":t.onBlur,error:t.error,model:t.model,"form-data":t.formData,"form-context":t.formContext,label:t.label,description:t.description,hint:t.hint,placeholder:t.placeholder,class:t.classes,style:t.styles,optional:t.optional,required:!t.required,disabled:t.disabled,hidden:t.hidden,type:t.type,"alt-action":t.altAction,name:t.vName,field:t,options:t.options,"max-length":t.maxLength,autocomplete:t.autocomplete,onAction:B},{ref_for:!0},t.attrs,{modelValue:t.model.value,"onUpdate:modelValue":C=>t.model.value=C}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):["text","password","number"].includes(t.type)?(e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["oo-default-field",t.classes])},[e.createElementVNode("label",null,e.toDisplayString(t.label),1),t.description?(e.openBlock(),e.createElementBlock("span",I,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C=>t.model.value=C,onBlur:t.onBlur,placeholder:t.placeholder,autocomplete:t.autocomplete,name:t.vName,type:t.type},null,40,O),[[e.vModelDynamic,t.model.value]]),e.createElementVNode("div",U,e.toDisplayString(t.error||t.hint),1)],2)):t.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",P,e.toDisplayString(t.description),1)):(e.openBlock(),e.createElementBlock("div",H," ["+e.toDisplayString(t.label)+'] Not supported field type "'+e.toDisplayString(t.type)+'" '+e.toDisplayString(t.component),1))]})]),_:2},1040,["error"])}),128)),e.renderSlot(c.$slots,"form.after",{clearErrors:r.clearErrors,reset:r.reset,disabled:x.value,formContext:l.formContext}),e.renderSlot(c.$slots,"form.submit",{disabled:x.value,text:g.value,clearErrors:r.clearErrors,reset:r.reset,formContext:l.formContext},()=>[e.createElementVNode("button",{disabled:x.value},e.toDisplayString(g.value),9,z)]),e.renderSlot(c.$slots,"form.footer",{disabled:x.value,clearErrors:r.clearErrors,reset:r.reset,formContext:l.formContext})]),_:3},8,["first-validation","form-data","form-context"]))}}),X={global:null,process:null,Buffer:null,require:null,__filename:null,__dirname:null,exports:null,module:null,setImmediate:null,clearImmediate:null,setTimeout:null,clearTimeout:null,setInterval:null,clearInterval:null,queueMicrotask:null,queueGlobalMicrotask:null,globalThis:null,window:null,self:null,document:null,localStorage:null,sessionStorage:null,indexedDB:null,caches:null,console:null,performance:null,fetch:null,XMLHttpRequest:null,Image:null,Audio:null,navigator:null,navigation:null,location:null,history:null,screen:null,requestAnimationFrame:null,cancelAnimationFrame:null,cancelIdleCallback:null,captureEvents:null,chrome:null,clientInformation:null,addEventListener:null,removeEventListener:null,blur:null,close:null,closed:null,confirm:null,alert:null,customElements:null,dispatchEvent:null,debug:null,focus:null,find:null,frames:null,getSelection:null,getScreenDetails:null,getEventListeners:null,keys:null,launchQueue:null,parent:null,postMessage:null,print:null,profile:null,profileEnd:null,prompt:null,queryLocalFonts:null,queryObjects:null,releaseEvents:null,reportError:null,resizeBy:null,resizeTo:null,scheduler:null,stop:null,scroll:null,scrollBy:null,scrollTo:null,scrollY:null,scrollX:null,top:null,eval:null,__ctx__:null};class Q{constructor(){L(this,"cache",new Map)}call(o,n){return this.getFn(o)(n)}getFn(o){let n=this.cache.get(o);return n||(n=R(o),this.cache.set(o,n)),n}}function R(l){const o=`with(__ctx__){
|
|
1
|
+
(function(k,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(k=typeof globalThis<"u"?globalThis:k||self,e(k.index={},k.Vue))})(this,function(k,e){"use strict";var ge=Object.defineProperty;var be=(k,e,y)=>e in k?ge(k,e,{enumerable:!0,configurable:!0,writable:!0,value:y}):k[e]=y;var w=(k,e,y)=>be(k,typeof e!="symbol"?e+"":e,y);function y(l,n){return typeof l=="function"?l(n):l}const v=new Set(["action","paragraph"]);function L(l){var n;const o={};for(const r of l)v.has(r.type)||(o[r.field]=(n=r.value)!==null&&n!==void 0?n:void 0);return o}function T(l,n){return l.fields.some(o=>o.altAction===n)}function q(l,n){if(!l)return;const o={};for(const[r,s]of Object.entries(l))o[r]=y(s,n);return o}const M=e.defineComponent({__name:"VuilessField",props:e.mergeModels({rules:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(l){const n=l,o=e.useModel(l,"modelValue"),r=e.inject("vuiless"),s=e.ref(),c=e.ref(!1),p=e.ref(!1),u=e.computed(()=>{var a;if((a=r==null?void 0:r.value)!=null&&a.firstValidation)switch(r.value.firstValidation){case"on-change":return r.value.firstSubmitHappened||c.value;case"touched-on-blur":return r.value.firstSubmitHappened||p.value&&c.value;case"on-blur":return r.value.firstSubmitHappened||p.value;case"on-submit":return r.value.firstSubmitHappened;case"none":return!1}return!1}),S=e.computed(()=>{if(u.value||s.value)return x()});e.watch([o],()=>{s.value=void 0,c.value=!0}),e.onUnmounted(()=>{var a;(a=r==null?void 0:r.value)==null||a.unregister(e.getCurrentInstance())}),r!=null&&r.value&&r.value.register(e.getCurrentInstance(),{validate:()=>(s.value=x(),s.value||!0),clearErrors:()=>{c.value=!1,p.value=!1,s.value=void 0},reset:()=>{o.value=""}});function x(){var a,i,B;if((a=n.rules)!=null&&a.length)for(const f of n.rules){const b=f(o.value,(i=r==null?void 0:r.value)==null?void 0:i.formData,(B=r==null?void 0:r.value)==null?void 0:B.formContext);if(b!==!0)return b||"Wrong value"}}function m(){p.value=!0}const h={v:e.computed({get:()=>o.value,set:a=>o.value=a})};return(a,i)=>{var B,f;return e.renderSlot(a.$slots,"default",{onBlur:m,error:S.value,formData:(B=e.unref(r))==null?void 0:B.formData,formContext:(f=e.unref(r))==null?void 0:f.formContext,model:h.v})}}}),O=e.defineComponent({__name:"VuilessForm",props:{formData:{},formContext:{},firstValidation:{default:"on-change"}},emits:["submit"],setup(l,{emit:n}){const o=l,r=n,s=new Map,c=e.ref(!1),p=e.computed(()=>({firstSubmitHappened:c.value,firstValidation:o.firstValidation,register:(m,h)=>{s.set(m,h)},unregister:m=>s.delete(m),formData:o.formData,formContext:o.formContext}));e.provide("vuiless",p);function u(){c.value=!1;for(const{clearErrors:m}of s.values())m()}async function S(){for(const{reset:m}of s.values())m();await e.nextTick(),u()}function x(){c.value=!0;let m=!1;if(o.firstValidation!=="none")for(const{validate:h}of s.values())h()!==!0&&(m=!0);m||r("submit",o.formData)}return(m,h)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(x,["prevent"])},[e.renderSlot(m.$slots,"default",{clearErrors:u,reset:S})],32))}}),N=e.defineComponent({__name:"oo-field",props:{field:{},type:{},component:{},autocomplete:{},altAction:{},order:{},name:{},label:{type:[String,Function]},description:{type:[String,Function]},hint:{type:[String,Function]},placeholder:{type:[String,Function]},optional:{type:[Boolean,Function]},disabled:{type:[Boolean,Function]},hidden:{type:[Boolean,Function]},classes:{type:[String,Object,Function]},styles:{type:[String,Object,Function]},options:{type:[Array,Function]},attrs:{},value:{},validators:{},maxLength:{},minLength:{},min:{},max:{},error:{}},setup(l){const n=l,o=e.inject("vuiless"),r=e.computed(()=>({v:o.value.formData[n.field],data:o.value.formData,context:o.value.formContext??{},entry:void 0})),s=e.computed(()=>y(n.optional,r.value)),c=e.computed(()=>y(n.disabled,r.value)),p=e.computed(()=>y(n.hidden,r.value)),u=e.computed(()=>({...r.value,entry:{field:n.field,type:n.type,component:n.component,name:n.name||n.field,disabled:c.value,optional:s.value,hidden:p.value}})),S=e.computed(()=>y(n.label,u.value)),x=e.computed(()=>y(n.description,u.value)),m=e.computed(()=>y(n.hint,u.value)),h=e.computed(()=>y(n.placeholder,u.value)),a=e.computed(()=>y(n.options,u.value)),i=e.computed(()=>{const _=y(n.classes,u.value);return typeof _=="string"?{[_]:!0,disabled:c.value,required:!s.value}:{..._,disabled:c.value,required:!s.value}}),B=e.computed(()=>y(n.styles,u.value)),f=e.computed(()=>q(n.attrs,u.value)),b=e.computed(()=>n.validators.map(_=>(t,V,d)=>_({v:t,data:V,context:d??{},entry:u.value.entry})));return(_,t)=>(e.openBlock(),e.createBlock(e.unref(M),{modelValue:e.unref(o).formData[n.field],"onUpdate:modelValue":t[0]||(t[0]=V=>e.unref(o).formData[n.field]=V),rules:b.value},{default:e.withCtx(V=>[e.renderSlot(_.$slots,"default",{onBlur:V.onBlur,error:l.error||V.error,model:V.model,formData:e.unref(o).formData,formContext:e.unref(o).formContext,label:S.value,description:x.value,hint:m.value,placeholder:h.value,classes:{...i.value,error:!!l.error||!!V.error},styles:B.value,optional:s.value,disabled:c.value,hidden:p.value,type:l.type,altAction:l.altAction,component:l.component,vName:l.name,field:l.field,options:a.value,maxLength:l.maxLength,required:!s.value,autocomplete:l.autocomplete,attrs:f.value})]),_:3},8,["modelValue","rules"]))}}),$={key:0},j={key:1},U={key:0},I=["onUpdate:modelValue","onBlur","placeholder","autocomplete","name","type","disabled"],P={class:"oo-error-slot"},z={key:4},H={key:0},G=["onUpdate:modelValue","onBlur","name","disabled"],R={key:0,value:"",disabled:""},X=["value"],Y={class:"oo-error-slot"},K={class:"oo-field-label"},Q={key:0},W={class:"oo-radio-group"},J=["value","onUpdate:modelValue","onBlur","name","disabled"],Z={class:"oo-error-slot"},ee=["onUpdate:modelValue","onBlur","name","disabled"],te={key:0},oe={class:"oo-error-slot"},ne=["onClick"],le={key:9},re=["disabled"],ae=e.defineComponent({__name:"oo-form",props:{form:{},formData:{},formContext:{},firstValidation:{},components:{},types:{},errors:{}},emits:["submit","action","unsupported-action"],setup(l,{emit:n}){const o=l,r=e.ref({}),s=e.computed(()=>o.formData||r.value),c=e.computed(()=>({v:void 0,data:s.value,context:o.formContext??{},entry:void 0})),p=e.computed(()=>y(o.form.title,c.value)),u=e.computed(()=>y(o.form.submit.text,c.value)),S=e.computed(()=>y(o.form.submit.disabled,c.value));function x(i){T(o.form,i)?m("action",i,s.value):m("unsupported-action",i,s.value)}const m=n;function h(i){return typeof i=="string"?i:i.key}function a(i){return typeof i=="string"?i:i.label}return(i,B)=>(e.openBlock(),e.createBlock(e.unref(O),{"first-validation":l.firstValidation,onSubmit:B[0]||(B[0]=f=>m("submit",f)),"form-data":s.value,"form-context":l.formContext},{default:e.withCtx(f=>[e.renderSlot(i.$slots,"form.header",{clearErrors:f.clearErrors,reset:f.reset,title:p.value,formContext:l.formContext,disabled:S.value},()=>[p.value?(e.openBlock(),e.createElementBlock("h2",$,e.toDisplayString(p.value),1)):e.createCommentVNode("",!0)]),e.renderSlot(i.$slots,"form.before",{clearErrors:f.clearErrors,reset:f.reset}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.form.fields,b=>{var _;return e.openBlock(),e.createBlock(N,e.mergeProps({key:b.field},{ref_for:!0},b,{error:(_=l.errors)==null?void 0:_[b.field]}),{default:e.withCtx(t=>[e.renderSlot(i.$slots,`field:${t.type}`,e.mergeProps({ref_for:!0},t),()=>{var V,d,E;return[b.component&&((V=o.components)!=null&&V[b.component])?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.components[b.component]),e.mergeProps({key:0,"on-blur":t.onBlur,error:t.error,model:t.model,"form-data":t.formData,"form-context":t.formContext,label:t.label,description:t.description,hint:t.hint,placeholder:t.placeholder,class:t.classes,style:t.styles,optional:t.optional,required:!t.required,disabled:t.disabled,hidden:t.hidden,type:t.type,"alt-action":t.altAction,name:t.vName,field:t,options:t.options,"max-length":t.maxLength,autocomplete:t.autocomplete,onAction:x},{ref_for:!0},t.attrs,{modelValue:t.model.value,"onUpdate:modelValue":g=>t.model.value=g}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):b.component&&!((d=o.components)!=null&&d[b.component])?(e.openBlock(),e.createElementBlock("div",j," ["+e.toDisplayString(t.label)+'] Component "'+e.toDisplayString(t.component)+'" not supplied ',1)):(E=o.types)!=null&&E[b.type]?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.types[b.type]),e.mergeProps({key:2,"on-blur":t.onBlur,error:t.error,model:t.model,"form-data":t.formData,"form-context":t.formContext,label:t.label,description:t.description,hint:t.hint,placeholder:t.placeholder,class:t.classes,style:t.styles,optional:t.optional,required:!t.required,disabled:t.disabled,hidden:t.hidden,type:t.type,"alt-action":t.altAction,name:t.vName,field:t,options:t.options,"max-length":t.maxLength,autocomplete:t.autocomplete,onAction:x},{ref_for:!0},t.attrs,{modelValue:t.model.value,"onUpdate:modelValue":g=>t.model.value=g}),null,16,["on-blur","error","model","form-data","form-context","label","description","hint","placeholder","class","style","optional","required","disabled","hidden","type","alt-action","name","field","options","max-length","autocomplete","modelValue","onUpdate:modelValue"])):["text","password","number"].includes(t.type)?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:3,class:e.normalizeClass(["oo-default-field",t.classes])},[e.createElementVNode("label",null,e.toDisplayString(t.label),1),t.description?(e.openBlock(),e.createElementBlock("span",U,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({"onUpdate:modelValue":g=>t.model.value=g,onBlur:t.onBlur,placeholder:t.placeholder,autocomplete:t.autocomplete,name:t.vName,type:t.type,disabled:t.disabled},{ref_for:!0},t.attrs),null,16,I),[[e.vModelDynamic,t.model.value]]),e.createElementVNode("div",P,e.toDisplayString(t.error||t.hint),1)],2)),[[e.vShow,!t.hidden]]):t.type==="paragraph"?(e.openBlock(),e.createElementBlock("p",z,e.toDisplayString(t.description),1)):t.type==="select"?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:5,class:e.normalizeClass(["oo-default-field",t.classes])},[e.createElementVNode("label",null,e.toDisplayString(t.label),1),t.description?(e.openBlock(),e.createElementBlock("span",H,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({"onUpdate:modelValue":g=>t.model.value=g,onBlur:t.onBlur,name:t.vName,disabled:t.disabled},{ref_for:!0},t.attrs),[t.placeholder?(e.openBlock(),e.createElementBlock("option",R,e.toDisplayString(t.placeholder),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,g=>(e.openBlock(),e.createElementBlock("option",{key:h(g),value:h(g)},e.toDisplayString(a(g)),9,X))),128))],16,G),[[e.vModelSelect,t.model.value]]),e.createElementVNode("div",Y,e.toDisplayString(t.error||t.hint),1)],2)),[[e.vShow,!t.hidden]]):t.type==="radio"?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:6,class:e.normalizeClass(["oo-default-field oo-radio-field",t.classes])},[e.createElementVNode("span",K,e.toDisplayString(t.label),1),t.description?(e.openBlock(),e.createElementBlock("span",Q,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),e.createElementVNode("div",W,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,g=>(e.openBlock(),e.createElementBlock("label",{key:h(g)},[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"radio",value:h(g),"onUpdate:modelValue":he=>t.model.value=he,onBlur:t.onBlur,name:t.vName,disabled:t.disabled},{ref_for:!0},t.attrs),null,16,J),[[e.vModelRadio,t.model.value]]),e.createTextVNode(" "+e.toDisplayString(a(g)),1)]))),128))]),e.createElementVNode("div",Z,e.toDisplayString(t.error||t.hint),1)],2)),[[e.vShow,!t.hidden]]):t.type==="checkbox"?e.withDirectives((e.openBlock(),e.createElementBlock("div",{key:7,class:e.normalizeClass(["oo-default-field oo-checkbox-field",t.classes])},[e.createElementVNode("label",null,[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"checkbox","onUpdate:modelValue":g=>t.model.value=g,onBlur:t.onBlur,name:t.vName,disabled:t.disabled},{ref_for:!0},t.attrs),null,16,ee),[[e.vModelCheckbox,t.model.value]]),e.createTextVNode(" "+e.toDisplayString(t.label),1)]),t.description?(e.openBlock(),e.createElementBlock("span",te,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),e.createElementVNode("div",oe,e.toDisplayString(t.error||t.hint),1)],2)),[[e.vShow,!t.hidden]]):t.type==="action"?(e.openBlock(),e.createElementBlock("div",{key:8,class:e.normalizeClass(["oo-default-field oo-action-field",t.classes])},[e.createElementVNode("button",{type:"button",onClick:g=>x(t.altAction)},e.toDisplayString(t.label),9,ne)],2)):(e.openBlock(),e.createElementBlock("div",le," ["+e.toDisplayString(t.label)+'] Not supported field type "'+e.toDisplayString(t.type)+'" '+e.toDisplayString(t.component),1))]})]),_:2},1040,["error"])}),128)),e.renderSlot(i.$slots,"form.after",{clearErrors:f.clearErrors,reset:f.reset,disabled:S.value,formContext:l.formContext}),e.renderSlot(i.$slots,"form.submit",{disabled:S.value,text:u.value,clearErrors:f.clearErrors,reset:f.reset,formContext:l.formContext},()=>[e.createElementVNode("button",{disabled:S.value},e.toDisplayString(u.value),9,re)]),e.renderSlot(i.$slots,"form.footer",{disabled:S.value,clearErrors:f.clearErrors,reset:f.reset,formContext:l.formContext})]),_:3},8,["first-validation","form-data","form-context"]))}}),se={global:null,process:null,Buffer:null,require:null,__filename:null,__dirname:null,exports:null,module:null,setImmediate:null,clearImmediate:null,setTimeout:null,clearTimeout:null,setInterval:null,clearInterval:null,queueMicrotask:null,queueGlobalMicrotask:null,globalThis:null,window:null,self:null,document:null,localStorage:null,sessionStorage:null,indexedDB:null,caches:null,console:null,performance:null,fetch:null,XMLHttpRequest:null,Image:null,Audio:null,navigator:null,navigation:null,location:null,history:null,screen:null,requestAnimationFrame:null,cancelAnimationFrame:null,cancelIdleCallback:null,captureEvents:null,chrome:null,clientInformation:null,addEventListener:null,removeEventListener:null,blur:null,close:null,closed:null,confirm:null,alert:null,customElements:null,dispatchEvent:null,debug:null,focus:null,find:null,frames:null,getSelection:null,getScreenDetails:null,getEventListeners:null,keys:null,launchQueue:null,parent:null,postMessage:null,print:null,profile:null,profileEnd:null,prompt:null,queryLocalFonts:null,queryObjects:null,releaseEvents:null,reportError:null,resizeBy:null,resizeTo:null,scheduler:null,stop:null,scroll:null,scrollBy:null,scrollTo:null,scrollY:null,scrollX:null,top:null,eval:null,__ctx__:null};class ce{constructor(){w(this,"cache",new Map)}call(n,o){return this.getFn(n)(o)}getFn(n){let o=this.cache.get(n);return o||(o=ie(n),this.cache.set(n,o)),o}}function ie(l){const n=`with(__ctx__){
|
|
2
2
|
${l}
|
|
3
|
-
}`,
|
|
3
|
+
}`,o=new Function("__ctx__",n);return r=>{const s=Object.freeze(Object.assign({},se,r));return o(s)}}const A=new ce;function D(l){const n=`return (${l})(v, data, context, entry)`;return A.getFn(n)}function F(l){const n=`return (${l})(data, context)`;return A.getFn(n)}function me(l){const n=`return (${l})(v, data, context)`;return A.getFn(n)}const de=new Set(["action","paragraph","select","radio","checkbox"]);function ue(l){return(Array.isArray(l)?l:[l]).map(o=>{if(typeof o=="object"&&o!==null&&"label"in o){const{label:r,value:s}=o;return s!==void 0?{key:s,label:r}:r}return String(o)})}function C(l,n,o,r,s){const c=o.get(n);if(typeof c=="string")return r(c);const p=o.get(l);return p!==void 0?p:s}function pe(l){const n=l.get("foorm.attr"),o=l.get("foorm.fn.attr");if(!n&&!o)return;const r={};if(n){const s=Array.isArray(n)?n:[n];for(const c of s)if(typeof c=="object"&&c!==null&&"name"in c&&"value"in c){const{name:p,value:u}=c;r[p]=u}}if(o){const s=Array.isArray(o)?o:[o];for(const c of s)if(typeof c=="object"&&c!==null&&"name"in c&&"fn"in c){const{name:p,fn:u}=c;r[p]=D(u)}}return Object.keys(r).length>0?r:void 0}function fe(l){var n,o;const r=l.metadata,s=l.type.props,c=C("foorm.title","foorm.fn.title",r,F,""),p=C("foorm.submit.text","foorm.fn.submit.text",r,F,"Submit"),u=(()=>{const m=r.get("foorm.fn.submit.disabled");return typeof m=="string"?F(m):!1})(),S={text:p,disabled:u},x=[];for(const[m,h]of s.entries()){const a=h.metadata,i=(n=h.type)===null||n===void 0?void 0:n.tags,B=a.get("foorm.type"),f=i?[...i].find(d=>de.has(d)):void 0,b=(o=B??f)!==null&&o!==void 0?o:"text",_=[],t=a.get("foorm.validate");if(t){const d=Array.isArray(t)?t:[t];for(const E of d)typeof E=="string"&&_.push(me(E))}const V={field:m,type:b,component:a.get("foorm.component"),autocomplete:a.get("foorm.autocomplete"),altAction:a.get("foorm.altAction"),order:a.get("foorm.order"),name:m,label:C("meta.label","foorm.fn.label",a,D,m),description:C("meta.description","foorm.fn.description",a,D,""),hint:C("meta.hint","foorm.fn.hint",a,D,""),placeholder:C("meta.placeholder","foorm.fn.placeholder",a,D,""),optional:(()=>{var d;const E=a.get("foorm.fn.optional");return typeof E=="string"?D(E):(d=h.optional)!==null&&d!==void 0?d:!1})(),disabled:(()=>{const d=a.get("foorm.fn.disabled");return typeof d=="string"?D(d):a.get("foorm.disabled")!==void 0})(),hidden:(()=>{const d=a.get("foorm.fn.hidden");return typeof d=="string"?D(d):a.get("foorm.hidden")!==void 0})(),classes:(()=>{const d=a.get("foorm.fn.classes");if(typeof d=="string")return D(d)})(),styles:(()=>{const d=a.get("foorm.fn.styles");if(typeof d=="string")return D(d)})(),options:(()=>{const d=a.get("foorm.fn.options");if(typeof d=="string")return D(d);const E=a.get("foorm.options");if(E)return ue(E)})(),value:a.get("foorm.value"),validators:_,attrs:pe(a),maxLength:a.get("expect.maxLength"),minLength:a.get("expect.minLength"),min:a.get("expect.min"),max:a.get("expect.max")};x.push(V)}return x.sort((m,h)=>{var a,i;return((a=m.order)!==null&&a!==void 0?a:1/0)-((i=h.order)!==null&&i!==void 0?i:1/0)}),{title:c,submit:S,fields:x}}function ye(l){const n=fe(l),o=e.reactive(L(n.fields));return{form:n,formData:o}}k.OoField=N,k.OoForm=ae,k.useFoorm=ye,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.oo-default-field{display:flex;flex-direction:column;gap:4px}.oo-default-field.required label:after{content:" *";color:
|
|
1
|
+
.oo-default-field{display:flex;flex-direction:column;gap:4px;margin-bottom:4px}.oo-default-field label{font-size:13px;font-weight:600;color:#374151}.oo-default-field.required label:after{content:" *";color:#ef4444}.oo-default-field span{font-size:12px;color:#6b7280}.oo-default-field input,.oo-default-field select{padding:8px 12px;border:1px solid #d1d5db;border-radius:6px;font-size:14px;color:#1d1d1f;background:#fff;transition:border-color .15s,box-shadow .15s;outline:none}.oo-default-field input::placeholder{color:#9ca3af}.oo-default-field input:focus,.oo-default-field select:focus{border-color:#6366f1;box-shadow:0 0 0 3px #6366f126}.oo-default-field input:disabled,.oo-default-field select:disabled{background:#f3f4f6;color:#9ca3af;cursor:not-allowed}.oo-default-field.error input,.oo-default-field.error select{border-color:#ef4444}.oo-default-field.error input:focus,.oo-default-field.error select:focus{box-shadow:0 0 0 3px #ef444426}.oo-default-field .oo-field-label{font-size:13px;font-weight:600;color:#374151}.oo-radio-group{display:flex;flex-direction:column;gap:6px}.oo-radio-group label{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:400;color:#1d1d1f;cursor:pointer}.oo-radio-group input[type=radio]{padding:0;border:none;box-shadow:none}.oo-checkbox-field>label{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:400;color:#1d1d1f;cursor:pointer}.oo-checkbox-field>label input[type=checkbox]{padding:0;border:none;box-shadow:none}.oo-default-field .oo-error-slot{min-height:16px;line-height:16px;font-size:12px;color:#6b7280}.oo-default-field.error .oo-error-slot{color:#ef4444}.oo-default-field.oo-action-field button{padding:8px 16px;border:1px solid #d1d5db;border-radius:6px;background:#fff;font-size:13px;font-weight:500;color:#374151;cursor:pointer;transition:background .15s,border-color .15s}.oo-default-field.oo-action-field button:hover{background:#f9fafb;border-color:#9ca3af}h2{margin:0 0 8px;font-size:20px;font-weight:700;color:#111827}p{margin:0 0 4px;font-size:14px;color:#6b7280}button[type=submit],button:not([type]){margin-top:8px;padding:10px 20px;border:none;border-radius:6px;background:#6366f1;color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s}button[type=submit]:hover,button:not([type]):hover{background:#4f46e5}button[type=submit]:disabled,button:not([type]):disabled{background:#c7d2fe;cursor:not-allowed}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foormjs/vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "@foormjs/vue",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -42,16 +42,16 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"vue": "^3.5.28",
|
|
44
44
|
"vuiless-forms": "^0.0.3",
|
|
45
|
-
"@foormjs/atscript": "^0.2.
|
|
46
|
-
"foorm": "^0.2.
|
|
45
|
+
"@foormjs/atscript": "^0.2.1",
|
|
46
|
+
"foorm": "^0.2.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@atscript/core": "^0.1.
|
|
50
|
-
"@atscript/typescript": "^0.1.
|
|
49
|
+
"@atscript/core": "^0.1.7",
|
|
50
|
+
"@atscript/typescript": "^0.1.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@atscript/core": "^0.1.
|
|
54
|
-
"@atscript/typescript": "^0.1.
|
|
53
|
+
"@atscript/core": "^0.1.7",
|
|
54
|
+
"@atscript/typescript": "^0.1.7",
|
|
55
55
|
"@playwright/test": "^1.58.2",
|
|
56
56
|
"@tsconfig/node20": "^20.1.9",
|
|
57
57
|
"@types/node": "^20.19.33",
|