@foormjs/vue 0.0.3 → 0.2.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/LICENSE +21 -0
- package/README.md +367 -17
- package/dist/index.d.ts +26 -15
- package/dist/index.js +510 -278
- package/dist/index.umd.cjs +3 -1
- package/package.json +30 -19
package/dist/index.js
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var X = Object.defineProperty;
|
|
2
|
+
var Q = (n, t, o) => t in n ? X(n, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[t] = o;
|
|
3
|
+
var N = (n, t, o) => Q(n, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { defineComponent as T, useModel as R, inject as P, ref as w, computed as m, watch as W, onUnmounted as Y, getCurrentInstance as U, renderSlot as A, unref as B, mergeModels as J, provide as K, openBlock as x, createElementBlock as E, withModifiers as Z, nextTick as ee, createBlock as q, withCtx as O, toDisplayString as F, createCommentVNode as H, Fragment as te, renderList as oe, mergeProps as $, resolveDynamicComponent as z, normalizeClass as ne, createElementVNode as M, withDirectives as le, vModelDynamic as re, reactive as ae } from "vue";
|
|
5
|
+
function b(n, t) {
|
|
6
|
+
return typeof n == "function" ? n(t) : n;
|
|
4
7
|
}
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
function ue(n) {
|
|
9
|
+
var t;
|
|
10
|
+
const o = {};
|
|
11
|
+
for (const r of n)
|
|
12
|
+
r.type !== "action" && (o[r.field] = (t = r.value) !== null && t !== void 0 ? t : void 0);
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
function se(n, t) {
|
|
16
|
+
return n.fields.some((o) => o.altAction === t);
|
|
13
17
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
18
|
+
function ie(n, t) {
|
|
19
|
+
if (!n) return;
|
|
20
|
+
const o = {};
|
|
21
|
+
for (const [r, a] of Object.entries(n))
|
|
22
|
+
o[r] = b(a, t);
|
|
23
|
+
return o;
|
|
16
24
|
}
|
|
17
|
-
const
|
|
25
|
+
const ce = /* @__PURE__ */ T({
|
|
18
26
|
__name: "VuilessField",
|
|
19
|
-
props: /* @__PURE__ */
|
|
27
|
+
props: /* @__PURE__ */ J({
|
|
20
28
|
rules: {}
|
|
21
29
|
}, {
|
|
22
30
|
modelValue: {},
|
|
@@ -24,74 +32,74 @@ const ee = /* @__PURE__ */ q({
|
|
|
24
32
|
}),
|
|
25
33
|
emits: ["update:modelValue"],
|
|
26
34
|
setup(n) {
|
|
27
|
-
const
|
|
28
|
-
var
|
|
29
|
-
if ((
|
|
30
|
-
switch (
|
|
35
|
+
const t = n, o = R(n, "modelValue"), r = P("vuiless"), a = w(), d = w(!1), v = w(!1), f = m(() => {
|
|
36
|
+
var c;
|
|
37
|
+
if ((c = r == null ? void 0 : r.value) != null && c.firstValidation)
|
|
38
|
+
switch (r.value.firstValidation) {
|
|
31
39
|
case "on-change":
|
|
32
|
-
return
|
|
40
|
+
return r.value.firstSubmitHappened || d.value;
|
|
33
41
|
case "touched-on-blur":
|
|
34
|
-
return
|
|
42
|
+
return r.value.firstSubmitHappened || v.value && d.value;
|
|
35
43
|
case "on-blur":
|
|
36
|
-
return
|
|
44
|
+
return r.value.firstSubmitHappened || v.value;
|
|
37
45
|
case "on-submit":
|
|
38
|
-
return
|
|
46
|
+
return r.value.firstSubmitHappened;
|
|
39
47
|
case "none":
|
|
40
48
|
return !1;
|
|
41
49
|
}
|
|
42
50
|
return !1;
|
|
43
|
-
}),
|
|
44
|
-
if (
|
|
45
|
-
return
|
|
51
|
+
}), g = m(() => {
|
|
52
|
+
if (f.value || a.value)
|
|
53
|
+
return V();
|
|
46
54
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
var
|
|
51
|
-
(
|
|
52
|
-
}),
|
|
53
|
-
validate: () => (
|
|
55
|
+
W([o], () => {
|
|
56
|
+
a.value = void 0, d.value = !0;
|
|
57
|
+
}), Y(() => {
|
|
58
|
+
var c;
|
|
59
|
+
(c = r == null ? void 0 : r.value) == null || c.unregister(U());
|
|
60
|
+
}), r != null && r.value && r.value.register(U(), {
|
|
61
|
+
validate: () => (a.value = V(), a.value || !0),
|
|
54
62
|
clearErrors: () => {
|
|
55
|
-
d.value = !1,
|
|
63
|
+
d.value = !1, v.value = !1, a.value = void 0;
|
|
56
64
|
},
|
|
57
65
|
reset: () => {
|
|
58
66
|
o.value = "";
|
|
59
67
|
}
|
|
60
68
|
});
|
|
61
|
-
function
|
|
62
|
-
var
|
|
63
|
-
if ((
|
|
64
|
-
for (const
|
|
65
|
-
const
|
|
69
|
+
function V() {
|
|
70
|
+
var c, l, u;
|
|
71
|
+
if ((c = t.rules) != null && c.length)
|
|
72
|
+
for (const y of t.rules) {
|
|
73
|
+
const e = y(
|
|
66
74
|
o.value,
|
|
67
|
-
(
|
|
68
|
-
(
|
|
75
|
+
(l = r == null ? void 0 : r.value) == null ? void 0 : l.formData,
|
|
76
|
+
(u = r == null ? void 0 : r.value) == null ? void 0 : u.formContext
|
|
69
77
|
);
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
78
|
+
if (e !== !0)
|
|
79
|
+
return e || "Wrong value";
|
|
72
80
|
}
|
|
73
81
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
82
|
+
function i() {
|
|
83
|
+
v.value = !0;
|
|
76
84
|
}
|
|
77
85
|
const s = {
|
|
78
|
-
v:
|
|
86
|
+
v: m({
|
|
79
87
|
get: () => o.value,
|
|
80
|
-
set: (
|
|
88
|
+
set: (c) => o.value = c
|
|
81
89
|
})
|
|
82
90
|
};
|
|
83
|
-
return (
|
|
84
|
-
var
|
|
85
|
-
return
|
|
86
|
-
onBlur:
|
|
87
|
-
error:
|
|
88
|
-
formData: (
|
|
89
|
-
formContext: (
|
|
91
|
+
return (c, l) => {
|
|
92
|
+
var u, y;
|
|
93
|
+
return A(c.$slots, "default", {
|
|
94
|
+
onBlur: i,
|
|
95
|
+
error: g.value,
|
|
96
|
+
formData: (u = B(r)) == null ? void 0 : u.formData,
|
|
97
|
+
formContext: (y = B(r)) == null ? void 0 : y.formContext,
|
|
90
98
|
model: s.v
|
|
91
99
|
});
|
|
92
100
|
};
|
|
93
101
|
}
|
|
94
|
-
}),
|
|
102
|
+
}), me = /* @__PURE__ */ T({
|
|
95
103
|
__name: "VuilessForm",
|
|
96
104
|
props: {
|
|
97
105
|
formData: {},
|
|
@@ -99,145 +107,153 @@ const ee = /* @__PURE__ */ q({
|
|
|
99
107
|
firstValidation: { default: "on-change" }
|
|
100
108
|
},
|
|
101
109
|
emits: ["submit"],
|
|
102
|
-
setup(n, { emit:
|
|
103
|
-
const o = n,
|
|
110
|
+
setup(n, { emit: t }) {
|
|
111
|
+
const o = n, r = t, a = /* @__PURE__ */ new Map(), d = w(!1), v = m(() => ({
|
|
104
112
|
firstSubmitHappened: d.value,
|
|
105
113
|
firstValidation: o.firstValidation,
|
|
106
|
-
register: (
|
|
107
|
-
|
|
114
|
+
register: (i, s) => {
|
|
115
|
+
a.set(i, s);
|
|
108
116
|
},
|
|
109
|
-
unregister: (
|
|
117
|
+
unregister: (i) => a.delete(i),
|
|
110
118
|
formData: o.formData,
|
|
111
119
|
formContext: o.formContext
|
|
112
120
|
}));
|
|
113
|
-
|
|
114
|
-
function
|
|
121
|
+
K("vuiless", v);
|
|
122
|
+
function f() {
|
|
115
123
|
d.value = !1;
|
|
116
|
-
for (const { clearErrors:
|
|
117
|
-
|
|
124
|
+
for (const { clearErrors: i } of a.values())
|
|
125
|
+
i();
|
|
118
126
|
}
|
|
119
|
-
async function
|
|
120
|
-
for (const { reset:
|
|
121
|
-
|
|
122
|
-
await
|
|
127
|
+
async function g() {
|
|
128
|
+
for (const { reset: i } of a.values())
|
|
129
|
+
i();
|
|
130
|
+
await ee(), f();
|
|
123
131
|
}
|
|
124
|
-
function
|
|
132
|
+
function V() {
|
|
125
133
|
d.value = !0;
|
|
126
|
-
let
|
|
134
|
+
let i = !1;
|
|
127
135
|
if (o.firstValidation !== "none")
|
|
128
|
-
for (const { validate: s } of
|
|
129
|
-
s() !== !0 && (
|
|
130
|
-
|
|
136
|
+
for (const { validate: s } of a.values())
|
|
137
|
+
s() !== !0 && (i = !0);
|
|
138
|
+
i || r("submit", o.formData);
|
|
131
139
|
}
|
|
132
|
-
return (
|
|
133
|
-
onSubmit:
|
|
140
|
+
return (i, s) => (x(), E("form", {
|
|
141
|
+
onSubmit: Z(V, ["prevent"])
|
|
134
142
|
}, [
|
|
135
|
-
|
|
136
|
-
clearErrors:
|
|
137
|
-
reset:
|
|
143
|
+
A(i.$slots, "default", {
|
|
144
|
+
clearErrors: f,
|
|
145
|
+
reset: g
|
|
138
146
|
})
|
|
139
147
|
], 32));
|
|
140
148
|
}
|
|
141
|
-
}),
|
|
149
|
+
}), de = /* @__PURE__ */ T({
|
|
142
150
|
__name: "oo-field",
|
|
143
151
|
props: {
|
|
144
152
|
field: {},
|
|
145
|
-
altAction: {},
|
|
146
|
-
label: {},
|
|
147
|
-
description: {},
|
|
148
|
-
hint: {},
|
|
149
|
-
placeholder: {},
|
|
150
|
-
classes: {},
|
|
151
|
-
styles: {},
|
|
152
153
|
type: {},
|
|
153
154
|
component: {},
|
|
154
155
|
autocomplete: {},
|
|
156
|
+
altAction: {},
|
|
157
|
+
order: {},
|
|
155
158
|
name: {},
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
label: { type: [String, Function] },
|
|
160
|
+
description: { type: [String, Function] },
|
|
161
|
+
hint: { type: [String, Function] },
|
|
162
|
+
placeholder: { type: [String, Function] },
|
|
163
|
+
optional: { type: [Boolean, Function] },
|
|
164
|
+
disabled: { type: [Boolean, Function] },
|
|
165
|
+
hidden: { type: [Boolean, Function] },
|
|
166
|
+
classes: { type: [String, Object, Function] },
|
|
167
|
+
styles: { type: [String, Object, Function] },
|
|
168
|
+
options: { type: [Array, Function] },
|
|
158
169
|
attrs: {},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
value: {},
|
|
171
|
+
validators: {},
|
|
172
|
+
maxLength: {},
|
|
173
|
+
minLength: {},
|
|
174
|
+
min: {},
|
|
175
|
+
max: {},
|
|
176
|
+
error: {}
|
|
164
177
|
},
|
|
165
178
|
setup(n) {
|
|
166
|
-
const
|
|
179
|
+
const t = n, o = P(
|
|
167
180
|
"vuiless"
|
|
168
|
-
),
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
disabled:
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
), r = m(() => ({
|
|
182
|
+
v: o.value.formData[t.field],
|
|
183
|
+
data: o.value.formData,
|
|
184
|
+
context: o.value.formContext ?? {}
|
|
185
|
+
})), a = m(() => b(t.optional, r.value)), d = m(() => b(t.disabled, r.value)), v = m(() => b(t.hidden, r.value)), f = m(() => ({
|
|
186
|
+
...r.value,
|
|
187
|
+
entry: {
|
|
188
|
+
field: t.field,
|
|
189
|
+
type: t.type,
|
|
190
|
+
component: t.component,
|
|
191
|
+
name: t.name || t.field,
|
|
192
|
+
disabled: d.value,
|
|
193
|
+
optional: a.value,
|
|
194
|
+
hidden: v.value
|
|
195
|
+
}
|
|
196
|
+
})), g = m(() => b(t.label, f.value)), V = m(() => b(t.description, f.value)), i = m(() => b(t.hint, f.value)), s = m(() => b(t.placeholder, f.value)), c = m(() => b(t.options, f.value)), l = m(() => {
|
|
197
|
+
const C = b(t.classes, f.value);
|
|
198
|
+
return typeof C == "string" ? {
|
|
199
|
+
[C]: !0,
|
|
200
|
+
disabled: d.value,
|
|
201
|
+
required: !a.value
|
|
182
202
|
} : {
|
|
183
|
-
...
|
|
184
|
-
disabled:
|
|
185
|
-
|
|
186
|
-
required: !y.value
|
|
203
|
+
...C || {},
|
|
204
|
+
disabled: d.value,
|
|
205
|
+
required: !a.value
|
|
187
206
|
};
|
|
188
|
-
}),
|
|
189
|
-
() =>
|
|
190
|
-
),
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
modelValue: x(o).formData[r.field],
|
|
203
|
-
"onUpdate:modelValue": E[0] || (E[0] = (D) => x(o).formData[r.field] = D),
|
|
204
|
-
rules: g.value
|
|
207
|
+
}), u = m(
|
|
208
|
+
() => b(t.styles, f.value)
|
|
209
|
+
), y = m(() => ie(t.attrs, f.value)), e = m(() => t.validators.map(
|
|
210
|
+
(C) => (D, h, _) => C({
|
|
211
|
+
v: D,
|
|
212
|
+
data: h,
|
|
213
|
+
context: _ ?? {},
|
|
214
|
+
entry: f.value.entry
|
|
215
|
+
})
|
|
216
|
+
));
|
|
217
|
+
return (C, D) => (x(), q(B(ce), {
|
|
218
|
+
modelValue: B(o).formData[t.field],
|
|
219
|
+
"onUpdate:modelValue": D[0] || (D[0] = (h) => B(o).formData[t.field] = h),
|
|
220
|
+
rules: e.value
|
|
205
221
|
}, {
|
|
206
|
-
default:
|
|
207
|
-
|
|
208
|
-
onBlur:
|
|
209
|
-
error:
|
|
210
|
-
model:
|
|
211
|
-
formData:
|
|
212
|
-
formContext:
|
|
213
|
-
label:
|
|
214
|
-
description:
|
|
215
|
-
hint:
|
|
216
|
-
placeholder:
|
|
222
|
+
default: O((h) => [
|
|
223
|
+
A(C.$slots, "default", {
|
|
224
|
+
onBlur: h.onBlur,
|
|
225
|
+
error: n.error || h.error,
|
|
226
|
+
model: h.model,
|
|
227
|
+
formData: B(o).formData,
|
|
228
|
+
formContext: B(o).formContext,
|
|
229
|
+
label: g.value,
|
|
230
|
+
description: V.value,
|
|
231
|
+
hint: i.value,
|
|
232
|
+
placeholder: s.value,
|
|
217
233
|
classes: {
|
|
218
|
-
...
|
|
219
|
-
error: !!
|
|
234
|
+
...l.value,
|
|
235
|
+
error: !!n.error || !!h.error
|
|
220
236
|
},
|
|
221
|
-
styles:
|
|
222
|
-
optional:
|
|
223
|
-
disabled:
|
|
224
|
-
hidden:
|
|
225
|
-
type:
|
|
226
|
-
altAction:
|
|
227
|
-
component:
|
|
228
|
-
vName:
|
|
229
|
-
field:
|
|
230
|
-
options:
|
|
231
|
-
|
|
232
|
-
required: !
|
|
233
|
-
autocomplete:
|
|
234
|
-
attrs:
|
|
237
|
+
styles: u.value,
|
|
238
|
+
optional: a.value,
|
|
239
|
+
disabled: d.value,
|
|
240
|
+
hidden: v.value,
|
|
241
|
+
type: n.type,
|
|
242
|
+
altAction: n.altAction,
|
|
243
|
+
component: n.component,
|
|
244
|
+
vName: n.name,
|
|
245
|
+
field: n.field,
|
|
246
|
+
options: c.value,
|
|
247
|
+
maxLength: n.maxLength,
|
|
248
|
+
required: !a.value,
|
|
249
|
+
autocomplete: n.autocomplete,
|
|
250
|
+
attrs: y.value
|
|
235
251
|
})
|
|
236
252
|
]),
|
|
237
253
|
_: 3
|
|
238
254
|
}, 8, ["modelValue", "rules"]));
|
|
239
255
|
}
|
|
240
|
-
}),
|
|
256
|
+
}), pe = { key: 0 }, fe = { key: 1 }, ve = { key: 0 }, he = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type"], be = { class: "oo-error-slot" }, ge = { key: 4 }, ye = { key: 5 }, xe = ["disabled"], Ee = /* @__PURE__ */ T({
|
|
241
257
|
__name: "oo-form",
|
|
242
258
|
props: {
|
|
243
259
|
form: {},
|
|
@@ -245,142 +261,358 @@ const ee = /* @__PURE__ */ q({
|
|
|
245
261
|
formContext: {},
|
|
246
262
|
firstValidation: {},
|
|
247
263
|
components: {},
|
|
248
|
-
types: {}
|
|
264
|
+
types: {},
|
|
265
|
+
errors: {}
|
|
249
266
|
},
|
|
250
|
-
emits: ["submit"],
|
|
251
|
-
setup(n, { emit:
|
|
252
|
-
const o = n,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
),
|
|
262
|
-
|
|
263
|
-
"
|
|
264
|
-
|
|
265
|
-
"form-
|
|
266
|
-
"form-context": l.formContext
|
|
267
|
+
emits: ["submit", "action", "unsupported-action"],
|
|
268
|
+
setup(n, { emit: t }) {
|
|
269
|
+
const o = n, r = w({}), a = m(() => o.formData || r.value), d = m(() => ({
|
|
270
|
+
v: void 0,
|
|
271
|
+
data: a.value,
|
|
272
|
+
context: o.formContext ?? {}
|
|
273
|
+
})), v = m(() => b(o.form.title, d.value)), f = m(() => b(o.form.submit.text, d.value)), g = m(() => b(o.form.submit.disabled, d.value));
|
|
274
|
+
function V(s) {
|
|
275
|
+
se(o.form, s) ? i("action", s, a.value) : i("unsupported-action", s, a.value);
|
|
276
|
+
}
|
|
277
|
+
const i = t;
|
|
278
|
+
return (s, c) => (x(), q(B(me), {
|
|
279
|
+
"first-validation": n.firstValidation,
|
|
280
|
+
onSubmit: c[0] || (c[0] = (l) => i("submit", l)),
|
|
281
|
+
"form-data": a.value,
|
|
282
|
+
"form-context": n.formContext
|
|
267
283
|
}, {
|
|
268
|
-
default:
|
|
269
|
-
|
|
270
|
-
clearErrors:
|
|
271
|
-
reset:
|
|
272
|
-
title:
|
|
273
|
-
formContext:
|
|
274
|
-
disabled:
|
|
284
|
+
default: O((l) => [
|
|
285
|
+
A(s.$slots, "form.header", {
|
|
286
|
+
clearErrors: l.clearErrors,
|
|
287
|
+
reset: l.reset,
|
|
288
|
+
title: v.value,
|
|
289
|
+
formContext: n.formContext,
|
|
290
|
+
disabled: g.value
|
|
275
291
|
}, () => [
|
|
276
|
-
|
|
292
|
+
v.value ? (x(), E("h2", pe, F(v.value), 1)) : H("", !0)
|
|
277
293
|
]),
|
|
278
|
-
|
|
279
|
-
clearErrors:
|
|
280
|
-
reset:
|
|
294
|
+
A(s.$slots, "form.before", {
|
|
295
|
+
clearErrors: l.clearErrors,
|
|
296
|
+
reset: l.reset
|
|
281
297
|
}),
|
|
282
|
-
(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
hidden: e.hidden,
|
|
304
|
-
type: e.type,
|
|
305
|
-
"alt-action": e.altAction,
|
|
306
|
-
name: e.vName,
|
|
307
|
-
field: e,
|
|
308
|
-
options: e.options,
|
|
309
|
-
length: e.length,
|
|
310
|
-
autocomplete: e.autocomplete
|
|
311
|
-
}, e.attrs), 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", "length", "autocomplete"])) : a.component && !((g = o.components) != null && g[a.component]) ? (p(), V("div", ae, " [" + h(e.label) + '] Component "' + h(e.component) + '" not supplied ', 1)) : (u = o.types) != null && u[a.type] ? (p(), B(F(o.types[a.type]), H({
|
|
312
|
-
key: 2,
|
|
313
|
-
"on-blur": e.onBlur,
|
|
314
|
-
error: e.error,
|
|
315
|
-
model: e.model,
|
|
316
|
-
"form-data": e.formData,
|
|
317
|
-
"form-context": e.formContext,
|
|
318
|
-
label: e.label,
|
|
319
|
-
description: e.description,
|
|
320
|
-
hint: e.hint,
|
|
321
|
-
placeholder: e.placeholder,
|
|
322
|
-
class: e.classes,
|
|
323
|
-
style: e.styles,
|
|
324
|
-
optional: e.optional,
|
|
325
|
-
required: !e.required,
|
|
326
|
-
disabled: e.disabled,
|
|
327
|
-
hidden: e.hidden,
|
|
328
|
-
type: e.type,
|
|
329
|
-
"alt-action": e.altAction,
|
|
330
|
-
name: e.vName,
|
|
331
|
-
field: e,
|
|
332
|
-
options: e.options,
|
|
333
|
-
length: e.length,
|
|
334
|
-
autocomplete: e.autocomplete
|
|
335
|
-
}, e.attrs), 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", "length", "autocomplete"])) : ["text", "password", "number"].includes(e.type) ? (p(), V("div", {
|
|
336
|
-
key: 3,
|
|
337
|
-
class: X(["oo-default-field", e.classes])
|
|
338
|
-
}, [
|
|
339
|
-
$("label", null, h(e.label), 1),
|
|
340
|
-
e.description ? (p(), V("span", ne, h(e.description), 1)) : j("", !0),
|
|
341
|
-
Y($("input", {
|
|
342
|
-
"onUpdate:modelValue": (E) => e.model.value = E,
|
|
343
|
-
onBlur: e.onBlur,
|
|
298
|
+
(x(!0), E(te, null, oe(o.form.fields, (u) => {
|
|
299
|
+
var y;
|
|
300
|
+
return x(), q(de, $({
|
|
301
|
+
key: u.field
|
|
302
|
+
}, { ref_for: !0 }, u, {
|
|
303
|
+
error: (y = n.errors) == null ? void 0 : y[u.field]
|
|
304
|
+
}), {
|
|
305
|
+
default: O((e) => [
|
|
306
|
+
A(s.$slots, `field:${e.type}`, $({ ref_for: !0 }, e), () => {
|
|
307
|
+
var C, D, h;
|
|
308
|
+
return [
|
|
309
|
+
u.component && ((C = o.components) != null && C[u.component]) ? (x(), q(z(o.components[u.component]), $({
|
|
310
|
+
key: 0,
|
|
311
|
+
"on-blur": e.onBlur,
|
|
312
|
+
error: e.error,
|
|
313
|
+
model: e.model,
|
|
314
|
+
"form-data": e.formData,
|
|
315
|
+
"form-context": e.formContext,
|
|
316
|
+
label: e.label,
|
|
317
|
+
description: e.description,
|
|
318
|
+
hint: e.hint,
|
|
344
319
|
placeholder: e.placeholder,
|
|
320
|
+
class: e.classes,
|
|
321
|
+
style: e.styles,
|
|
322
|
+
optional: e.optional,
|
|
323
|
+
required: !e.required,
|
|
324
|
+
disabled: e.disabled,
|
|
325
|
+
hidden: e.hidden,
|
|
326
|
+
type: e.type,
|
|
327
|
+
"alt-action": e.altAction,
|
|
328
|
+
name: e.vName,
|
|
329
|
+
field: e,
|
|
330
|
+
options: e.options,
|
|
331
|
+
"max-length": e.maxLength,
|
|
345
332
|
autocomplete: e.autocomplete,
|
|
333
|
+
onAction: V
|
|
334
|
+
}, { ref_for: !0 }, e.attrs, {
|
|
335
|
+
modelValue: e.model.value,
|
|
336
|
+
"onUpdate:modelValue": (_) => e.model.value = _
|
|
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"])) : u.component && !((D = o.components) != null && D[u.component]) ? (x(), E("div", fe, " [" + F(e.label) + '] Component "' + F(e.component) + '" not supplied ', 1)) : (h = o.types) != null && h[u.type] ? (x(), q(z(o.types[u.type]), $({
|
|
338
|
+
key: 2,
|
|
339
|
+
"on-blur": e.onBlur,
|
|
340
|
+
error: e.error,
|
|
341
|
+
model: e.model,
|
|
342
|
+
"form-data": e.formData,
|
|
343
|
+
"form-context": e.formContext,
|
|
344
|
+
label: e.label,
|
|
345
|
+
description: e.description,
|
|
346
|
+
hint: e.hint,
|
|
347
|
+
placeholder: e.placeholder,
|
|
348
|
+
class: e.classes,
|
|
349
|
+
style: e.styles,
|
|
350
|
+
optional: e.optional,
|
|
351
|
+
required: !e.required,
|
|
352
|
+
disabled: e.disabled,
|
|
353
|
+
hidden: e.hidden,
|
|
354
|
+
type: e.type,
|
|
355
|
+
"alt-action": e.altAction,
|
|
346
356
|
name: e.vName,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
357
|
+
field: e,
|
|
358
|
+
options: e.options,
|
|
359
|
+
"max-length": e.maxLength,
|
|
360
|
+
autocomplete: e.autocomplete,
|
|
361
|
+
onAction: V
|
|
362
|
+
}, { ref_for: !0 }, e.attrs, {
|
|
363
|
+
modelValue: e.model.value,
|
|
364
|
+
"onUpdate:modelValue": (_) => e.model.value = _
|
|
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) ? (x(), E("div", {
|
|
366
|
+
key: 3,
|
|
367
|
+
class: ne(["oo-default-field", e.classes])
|
|
368
|
+
}, [
|
|
369
|
+
M("label", null, F(e.label), 1),
|
|
370
|
+
e.description ? (x(), E("span", ve, F(e.description), 1)) : H("", !0),
|
|
371
|
+
le(M("input", {
|
|
372
|
+
"onUpdate:modelValue": (_) => e.model.value = _,
|
|
373
|
+
onBlur: e.onBlur,
|
|
374
|
+
placeholder: e.placeholder,
|
|
375
|
+
autocomplete: e.autocomplete,
|
|
376
|
+
name: e.vName,
|
|
377
|
+
type: e.type
|
|
378
|
+
}, null, 40, he), [
|
|
379
|
+
[re, e.model.value]
|
|
380
|
+
]),
|
|
381
|
+
M("div", be, F(e.error || e.hint), 1)
|
|
382
|
+
], 2)) : e.type === "paragraph" ? (x(), E("p", ge, F(e.description), 1)) : (x(), E("div", ye, " [" + F(e.label) + '] Not supported field type "' + F(e.type) + '" ' + F(e.component), 1))
|
|
383
|
+
];
|
|
384
|
+
})
|
|
385
|
+
]),
|
|
386
|
+
_: 2
|
|
387
|
+
}, 1040, ["error"]);
|
|
388
|
+
}), 128)),
|
|
389
|
+
A(s.$slots, "form.after", {
|
|
390
|
+
clearErrors: l.clearErrors,
|
|
391
|
+
reset: l.reset,
|
|
392
|
+
disabled: g.value,
|
|
393
|
+
formContext: n.formContext
|
|
363
394
|
}),
|
|
364
|
-
|
|
365
|
-
disabled:
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
395
|
+
A(s.$slots, "form.submit", {
|
|
396
|
+
disabled: g.value,
|
|
397
|
+
text: f.value,
|
|
398
|
+
clearErrors: l.clearErrors,
|
|
399
|
+
reset: l.reset,
|
|
400
|
+
formContext: n.formContext
|
|
369
401
|
}, () => [
|
|
370
|
-
|
|
402
|
+
M("button", { disabled: g.value }, F(f.value), 9, xe)
|
|
371
403
|
]),
|
|
372
|
-
|
|
373
|
-
disabled:
|
|
374
|
-
clearErrors:
|
|
375
|
-
reset:
|
|
376
|
-
formContext:
|
|
404
|
+
A(s.$slots, "form.footer", {
|
|
405
|
+
disabled: g.value,
|
|
406
|
+
clearErrors: l.clearErrors,
|
|
407
|
+
reset: l.reset,
|
|
408
|
+
formContext: n.formContext
|
|
377
409
|
})
|
|
378
410
|
]),
|
|
379
411
|
_: 3
|
|
380
412
|
}, 8, ["first-validation", "form-data", "form-context"]));
|
|
381
413
|
}
|
|
382
|
-
})
|
|
414
|
+
}), Ce = {
|
|
415
|
+
// Node.js Globals
|
|
416
|
+
global: null,
|
|
417
|
+
process: null,
|
|
418
|
+
Buffer: null,
|
|
419
|
+
require: null,
|
|
420
|
+
__filename: null,
|
|
421
|
+
__dirname: null,
|
|
422
|
+
exports: null,
|
|
423
|
+
module: null,
|
|
424
|
+
setImmediate: null,
|
|
425
|
+
clearImmediate: null,
|
|
426
|
+
setTimeout: null,
|
|
427
|
+
clearTimeout: null,
|
|
428
|
+
setInterval: null,
|
|
429
|
+
clearInterval: null,
|
|
430
|
+
queueMicrotask: null,
|
|
431
|
+
queueGlobalMicrotask: null,
|
|
432
|
+
globalThis: null,
|
|
433
|
+
// GlobalThis (Introduced in ECMAScript 2020)
|
|
434
|
+
// Browser Globals
|
|
435
|
+
window: null,
|
|
436
|
+
self: null,
|
|
437
|
+
document: null,
|
|
438
|
+
localStorage: null,
|
|
439
|
+
sessionStorage: null,
|
|
440
|
+
indexedDB: null,
|
|
441
|
+
caches: null,
|
|
442
|
+
console: null,
|
|
443
|
+
performance: null,
|
|
444
|
+
fetch: null,
|
|
445
|
+
XMLHttpRequest: null,
|
|
446
|
+
Image: null,
|
|
447
|
+
Audio: null,
|
|
448
|
+
navigator: null,
|
|
449
|
+
navigation: null,
|
|
450
|
+
location: null,
|
|
451
|
+
history: null,
|
|
452
|
+
screen: null,
|
|
453
|
+
requestAnimationFrame: null,
|
|
454
|
+
cancelAnimationFrame: null,
|
|
455
|
+
cancelIdleCallback: null,
|
|
456
|
+
captureEvents: null,
|
|
457
|
+
chrome: null,
|
|
458
|
+
clientInformation: null,
|
|
459
|
+
addEventListener: null,
|
|
460
|
+
removeEventListener: null,
|
|
461
|
+
blur: null,
|
|
462
|
+
close: null,
|
|
463
|
+
closed: null,
|
|
464
|
+
confirm: null,
|
|
465
|
+
alert: null,
|
|
466
|
+
customElements: null,
|
|
467
|
+
dispatchEvent: null,
|
|
468
|
+
debug: null,
|
|
469
|
+
focus: null,
|
|
470
|
+
find: null,
|
|
471
|
+
frames: null,
|
|
472
|
+
getSelection: null,
|
|
473
|
+
getScreenDetails: null,
|
|
474
|
+
getEventListeners: null,
|
|
475
|
+
keys: null,
|
|
476
|
+
launchQueue: null,
|
|
477
|
+
parent: null,
|
|
478
|
+
postMessage: null,
|
|
479
|
+
print: null,
|
|
480
|
+
profile: null,
|
|
481
|
+
profileEnd: null,
|
|
482
|
+
prompt: null,
|
|
483
|
+
queryLocalFonts: null,
|
|
484
|
+
queryObjects: null,
|
|
485
|
+
releaseEvents: null,
|
|
486
|
+
reportError: null,
|
|
487
|
+
resizeBy: null,
|
|
488
|
+
resizeTo: null,
|
|
489
|
+
scheduler: null,
|
|
490
|
+
stop: null,
|
|
491
|
+
scroll: null,
|
|
492
|
+
scrollBy: null,
|
|
493
|
+
scrollTo: null,
|
|
494
|
+
scrollY: null,
|
|
495
|
+
scrollX: null,
|
|
496
|
+
top: null,
|
|
497
|
+
// other
|
|
498
|
+
eval: null,
|
|
499
|
+
__ctx__: null
|
|
500
|
+
};
|
|
501
|
+
class _e {
|
|
502
|
+
constructor() {
|
|
503
|
+
N(this, "cache", /* @__PURE__ */ new Map());
|
|
504
|
+
}
|
|
505
|
+
call(t, o) {
|
|
506
|
+
return this.getFn(t)(o);
|
|
507
|
+
}
|
|
508
|
+
getFn(t) {
|
|
509
|
+
let o = this.cache.get(t);
|
|
510
|
+
return o || (o = Ve(t), this.cache.set(t, o)), o;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function Ve(n) {
|
|
514
|
+
const t = `with(__ctx__){
|
|
515
|
+
${n}
|
|
516
|
+
}`, o = new Function("__ctx__", t);
|
|
517
|
+
return (r) => {
|
|
518
|
+
const a = Object.freeze(Object.assign({}, Ce, r));
|
|
519
|
+
return o(a);
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
const j = new _e();
|
|
523
|
+
function S(n) {
|
|
524
|
+
const t = `return (${n})(v, data, context, entry)`;
|
|
525
|
+
return j.getFn(t);
|
|
526
|
+
}
|
|
527
|
+
function I(n) {
|
|
528
|
+
const t = `return (${n})(data, context)`;
|
|
529
|
+
return j.getFn(t);
|
|
530
|
+
}
|
|
531
|
+
function Fe(n) {
|
|
532
|
+
const t = `return (${n})(v, data, context)`;
|
|
533
|
+
return j.getFn(t);
|
|
534
|
+
}
|
|
535
|
+
function k(n, t, o, r, a) {
|
|
536
|
+
const d = o.get(t);
|
|
537
|
+
if (typeof d == "string")
|
|
538
|
+
return r(d);
|
|
539
|
+
const v = o.get(n);
|
|
540
|
+
return v !== void 0 ? v : a;
|
|
541
|
+
}
|
|
542
|
+
function Se(n) {
|
|
543
|
+
var t, o, r;
|
|
544
|
+
const a = n.metadata, d = n.type.props, v = k("foorm.title", "foorm.fn.title", a, I, ""), f = k("foorm.submit.text", "foorm.fn.submit.text", a, I, "Submit"), g = (() => {
|
|
545
|
+
const s = a.get("foorm.fn.submit.disabled");
|
|
546
|
+
return typeof s == "string" ? I(s) : !1;
|
|
547
|
+
})(), V = { text: f, disabled: g }, i = [];
|
|
548
|
+
for (const [s, c] of d.entries()) {
|
|
549
|
+
const l = c.metadata, u = (t = c.type) === null || t === void 0 ? void 0 : t.tags, y = l.get("foorm.type"), e = (o = u == null ? void 0 : u.has("action")) !== null && o !== void 0 ? o : !1, C = (r = u == null ? void 0 : u.has("paragraph")) !== null && r !== void 0 ? r : !1, D = y ?? (e ? "action" : C ? "paragraph" : "text"), h = [], _ = l.get("foorm.validate");
|
|
550
|
+
if (_) {
|
|
551
|
+
const p = Array.isArray(_) ? _ : [_];
|
|
552
|
+
for (const L of p)
|
|
553
|
+
typeof L == "string" && h.push(Fe(L));
|
|
554
|
+
}
|
|
555
|
+
const G = {
|
|
556
|
+
field: s,
|
|
557
|
+
type: D,
|
|
558
|
+
component: l.get("foorm.component"),
|
|
559
|
+
autocomplete: l.get("foorm.autocomplete"),
|
|
560
|
+
altAction: l.get("foorm.altAction"),
|
|
561
|
+
order: l.get("foorm.order"),
|
|
562
|
+
name: s,
|
|
563
|
+
label: k("meta.label", "foorm.fn.label", l, S, s),
|
|
564
|
+
description: k("meta.description", "foorm.fn.description", l, S, ""),
|
|
565
|
+
hint: k("meta.hint", "foorm.fn.hint", l, S, ""),
|
|
566
|
+
placeholder: k("meta.placeholder", "foorm.fn.placeholder", l, S, ""),
|
|
567
|
+
optional: (() => {
|
|
568
|
+
var p;
|
|
569
|
+
const L = l.get("foorm.fn.optional");
|
|
570
|
+
return typeof L == "string" ? S(L) : (p = c.optional) !== null && p !== void 0 ? p : !1;
|
|
571
|
+
})(),
|
|
572
|
+
disabled: (() => {
|
|
573
|
+
const p = l.get("foorm.fn.disabled");
|
|
574
|
+
return typeof p == "string" ? S(p) : l.get("foorm.disabled") !== void 0;
|
|
575
|
+
})(),
|
|
576
|
+
hidden: (() => {
|
|
577
|
+
const p = l.get("foorm.fn.hidden");
|
|
578
|
+
return typeof p == "string" ? S(p) : l.get("foorm.hidden") !== void 0;
|
|
579
|
+
})(),
|
|
580
|
+
classes: (() => {
|
|
581
|
+
const p = l.get("foorm.fn.classes");
|
|
582
|
+
if (typeof p == "string")
|
|
583
|
+
return S(p);
|
|
584
|
+
})(),
|
|
585
|
+
styles: (() => {
|
|
586
|
+
const p = l.get("foorm.fn.styles");
|
|
587
|
+
if (typeof p == "string")
|
|
588
|
+
return S(p);
|
|
589
|
+
})(),
|
|
590
|
+
options: (() => {
|
|
591
|
+
const p = l.get("foorm.fn.options");
|
|
592
|
+
if (typeof p == "string")
|
|
593
|
+
return S(p);
|
|
594
|
+
})(),
|
|
595
|
+
value: l.get("foorm.value"),
|
|
596
|
+
validators: h,
|
|
597
|
+
// ATScript @expect constraints
|
|
598
|
+
maxLength: l.get("expect.maxLength"),
|
|
599
|
+
minLength: l.get("expect.minLength"),
|
|
600
|
+
min: l.get("expect.min"),
|
|
601
|
+
max: l.get("expect.max")
|
|
602
|
+
};
|
|
603
|
+
i.push(G);
|
|
604
|
+
}
|
|
605
|
+
return i.sort((s, c) => {
|
|
606
|
+
var l, u;
|
|
607
|
+
return ((l = s.order) !== null && l !== void 0 ? l : 1 / 0) - ((u = c.order) !== null && u !== void 0 ? u : 1 / 0);
|
|
608
|
+
}), { title: v, submit: V, fields: i };
|
|
609
|
+
}
|
|
610
|
+
function Be(n) {
|
|
611
|
+
const t = Se(n), o = ae(ue(t.fields));
|
|
612
|
+
return { form: t, formData: o };
|
|
613
|
+
}
|
|
383
614
|
export {
|
|
384
|
-
|
|
385
|
-
|
|
615
|
+
de as OoField,
|
|
616
|
+
Ee as OoForm,
|
|
617
|
+
Be as useFoorm
|
|
386
618
|
};
|