@foormjs/vue 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,167 +1,16 @@
1
- var re = Object.defineProperty;
2
- var se = (o, e, t) => e in o ? re(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var Y = (o, e, t) => se(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { defineComponent as I, useModel as ae, inject as te, ref as q, computed as _, watch as oe, onUnmounted as le, getCurrentInstance as Q, renderSlot as w, unref as x, mergeModels as ie, provide as ue, openBlock as y, createElementBlock as b, withModifiers as ce, nextTick as pe, createBlock as U, withCtx as K, toDisplayString as g, createCommentVNode as P, Fragment as H, renderList as R, mergeProps as L, resolveDynamicComponent as J, withDirectives as T, normalizeClass as O, createElementVNode as V, vModelDynamic as de, vShow as N, vModelSelect as me, vModelRadio as fe, createTextVNode as Z, vModelCheckbox as he, reactive as ye } from "vue";
5
- function M(o, e) {
6
- return typeof o == "function" ? o(e) : o;
7
- }
8
- const ge = /* @__PURE__ */ new Set(["action", "paragraph"]);
9
- function ve(o) {
10
- var e;
11
- const t = {};
12
- for (const r of o)
13
- if (!ge.has(r.type)) {
14
- const s = {
15
- v: void 0,
16
- data: t,
17
- context: {},
18
- entry: {
19
- field: r.field,
20
- type: r.type,
21
- component: r.component,
22
- name: r.name || r.field
23
- }
24
- };
25
- t[r.field] = (e = M(r.value, s)) !== null && e !== void 0 ? e : void 0;
26
- }
27
- return t;
28
- }
29
- function be(o, e) {
30
- return o.fields.some((t) => t.altAction === e);
31
- }
32
- function xe(o, e) {
33
- if (!o)
1
+ import { defineComponent as G, inject as I, computed as h, watch as J, openBlock as r, createBlock as N, unref as d, withCtx as z, renderSlot as A, ref as Q, createElementBlock as u, toDisplayString as n, createCommentVNode as U, Fragment as R, renderList as T, mergeProps as B, resolveDynamicComponent as K, withDirectives as D, normalizeClass as S, createElementVNode as p, vModelDynamic as W, vShow as O, vModelSelect as X, vModelRadio as Y, createTextVNode as P, vModelCheckbox as Z, reactive as ee } from "vue";
2
+ import { evalComputed as M, supportsAltAction as oe, createFormData as te } from "foorm";
3
+ import { VuilessField as ae, VuilessForm as ne } from "vuiless-forms";
4
+ import { createFoorm as re } from "@foormjs/atscript";
5
+ function le(a, o) {
6
+ if (!a)
34
7
  return;
35
8
  const t = {};
36
- for (const [r, s] of Object.entries(o))
37
- t[r] = M(s, e);
9
+ for (const [y, i] of Object.entries(a))
10
+ t[y] = M(i, o);
38
11
  return t;
39
12
  }
40
- const ke = /* @__PURE__ */ I({
41
- __name: "VuilessField",
42
- props: /* @__PURE__ */ ie({
43
- rules: {}
44
- }, {
45
- modelValue: {},
46
- modelModifiers: {}
47
- }),
48
- emits: ["update:modelValue"],
49
- setup(o) {
50
- const e = o, t = ae(o, "modelValue"), r = te("vuiless"), s = q(), a = q(!1), l = q(!1), c = _(() => {
51
- var u;
52
- if ((u = r == null ? void 0 : r.value) != null && u.firstValidation)
53
- switch (r.value.firstValidation) {
54
- case "on-change":
55
- return r.value.firstSubmitHappened || a.value;
56
- case "touched-on-blur":
57
- return r.value.firstSubmitHappened || l.value && a.value;
58
- case "on-blur":
59
- return r.value.firstSubmitHappened || l.value;
60
- case "on-submit":
61
- return r.value.firstSubmitHappened;
62
- case "none":
63
- return !1;
64
- }
65
- return !1;
66
- }), m = _(() => {
67
- if (c.value || s.value)
68
- return p();
69
- });
70
- oe([t], () => {
71
- s.value = void 0, a.value = !0;
72
- }), le(() => {
73
- var u;
74
- (u = r == null ? void 0 : r.value) == null || u.unregister(Q());
75
- }), r != null && r.value && r.value.register(Q(), {
76
- validate: () => (s.value = p(), s.value || !0),
77
- clearErrors: () => {
78
- a.value = !1, l.value = !1, s.value = void 0;
79
- },
80
- reset: () => {
81
- t.value = "";
82
- }
83
- });
84
- function p() {
85
- var u, d, A;
86
- if ((u = e.rules) != null && u.length)
87
- for (const v of e.rules) {
88
- const E = v(
89
- t.value,
90
- (d = r == null ? void 0 : r.value) == null ? void 0 : d.formData,
91
- (A = r == null ? void 0 : r.value) == null ? void 0 : A.formContext
92
- );
93
- if (E !== !0)
94
- return E || "Wrong value";
95
- }
96
- }
97
- function f() {
98
- l.value = !0;
99
- }
100
- const h = {
101
- v: _({
102
- get: () => t.value,
103
- set: (u) => t.value = u
104
- })
105
- };
106
- return (u, d) => {
107
- var A, v;
108
- return w(u.$slots, "default", {
109
- onBlur: f,
110
- error: m.value,
111
- formData: (A = x(r)) == null ? void 0 : A.formData,
112
- formContext: (v = x(r)) == null ? void 0 : v.formContext,
113
- model: h.v
114
- });
115
- };
116
- }
117
- }), Ee = /* @__PURE__ */ I({
118
- __name: "VuilessForm",
119
- props: {
120
- formData: {},
121
- formContext: {},
122
- firstValidation: { default: "on-change" }
123
- },
124
- emits: ["submit"],
125
- setup(o, { emit: e }) {
126
- const t = o, r = e, s = /* @__PURE__ */ new Map(), a = q(!1), l = _(() => ({
127
- firstSubmitHappened: a.value,
128
- firstValidation: t.firstValidation,
129
- register: (f, h) => {
130
- s.set(f, h);
131
- },
132
- unregister: (f) => s.delete(f),
133
- formData: t.formData,
134
- formContext: t.formContext
135
- }));
136
- ue("vuiless", l);
137
- function c() {
138
- a.value = !1;
139
- for (const { clearErrors: f } of s.values())
140
- f();
141
- }
142
- async function m() {
143
- for (const { reset: f } of s.values())
144
- f();
145
- await pe(), c();
146
- }
147
- function p() {
148
- a.value = !0;
149
- let f = !1;
150
- if (t.firstValidation !== "none")
151
- for (const { validate: h } of s.values())
152
- h() !== !0 && (f = !0);
153
- f || r("submit", t.formData);
154
- }
155
- return (f, h) => (y(), b("form", {
156
- onSubmit: ce(p, ["prevent"])
157
- }, [
158
- w(f.$slots, "default", {
159
- clearErrors: c,
160
- reset: m
161
- })
162
- ], 32));
163
- }
164
- }), _e = /* @__PURE__ */ I({
13
+ const se = /* @__PURE__ */ G({
165
14
  __name: "oo-field",
166
15
  props: {
167
16
  field: {},
@@ -171,6 +20,7 @@ const ke = /* @__PURE__ */ I({
171
20
  altAction: {},
172
21
  order: {},
173
22
  name: {},
23
+ phantom: { type: Boolean },
174
24
  label: { type: [String, Function] },
175
25
  description: { type: [String, Function] },
176
26
  hint: { type: [String, Function] },
@@ -191,112 +41,113 @@ const ke = /* @__PURE__ */ I({
191
41
  max: {},
192
42
  error: {}
193
43
  },
194
- setup(o) {
195
- const e = o, t = te(
44
+ setup(a) {
45
+ const o = a, t = I(
196
46
  "vuiless"
197
47
  );
198
- function r(i, k, S) {
199
- return typeof i == "function" ? _(() => i(k.value)) : i ?? S;
48
+ function y(l, x, k) {
49
+ return typeof l == "function" ? h(() => l(x.value)) : l ?? k;
200
50
  }
201
- const s = (i) => typeof i == "object" && i !== null && "value" in i ? i.value : i, a = _(() => ({
202
- v: t.value.formData[e.field],
51
+ const i = (l) => typeof l == "object" && l !== null && "value" in l ? l.value : l, V = h(() => ({
52
+ v: t.value.formData[o.field],
203
53
  data: t.value.formData,
204
54
  context: t.value.formContext ?? {},
205
55
  entry: void 0
206
- })), l = r(e.optional, a, !1), c = r(e.disabled, a, !1), m = r(e.hidden, a, !1), p = r(e.readonly, a, !1), f = _(() => !s(l)), h = _(() => ({
207
- v: t.value.formData[e.field],
56
+ })), C = y(o.optional, V, !1), F = y(o.disabled, V, !1), _ = y(o.hidden, V, !1), g = y(o.readonly, V, !1), E = o.phantom ? void 0 : h(() => !i(C)), m = h(() => ({
57
+ v: t.value.formData[o.field],
208
58
  data: t.value.formData,
209
59
  context: t.value.formContext ?? {},
210
60
  entry: {
211
- field: e.field,
212
- type: e.type,
213
- component: e.component,
214
- name: e.name || e.field,
215
- optional: s(l),
216
- disabled: s(c),
217
- hidden: s(m),
218
- readonly: s(p)
61
+ field: o.field,
62
+ type: o.type,
63
+ component: o.component,
64
+ name: o.name || o.field,
65
+ optional: i(C),
66
+ disabled: i(F),
67
+ hidden: i(_),
68
+ readonly: i(g)
219
69
  }
220
- })), u = r(e.label, h, void 0), d = r(e.description, h, void 0), A = r(e.hint, h, void 0), v = r(e.placeholder, h, void 0), E = r(e.options, h, void 0), C = r(e.styles, h, void 0), n = _(() => {
221
- const i = typeof e.classes == "function" ? e.classes(h.value) : e.classes;
222
- return typeof i == "string" ? {
223
- [i]: !0,
224
- disabled: s(c),
225
- required: !s(l)
70
+ })), f = y(o.label, m, void 0), s = y(o.description, m, void 0), q = y(o.hint, m, void 0), v = y(o.placeholder, m, void 0), b = y(o.options, m, void 0), $ = y(o.styles, m, void 0), e = h(() => {
71
+ const l = typeof o.classes == "function" ? o.classes(m.value) : o.classes;
72
+ return typeof l == "string" ? {
73
+ [l]: !0,
74
+ disabled: i(F),
75
+ required: !i(C)
226
76
  } : {
227
- ...i,
228
- disabled: s(c),
229
- required: !s(l)
77
+ ...l,
78
+ disabled: i(F),
79
+ required: !i(C)
230
80
  };
231
81
  });
232
- function F(i, k) {
82
+ function L(l, x) {
233
83
  return {
234
- ...n.value,
235
- error: !!i || !!k
84
+ ...e.value,
85
+ error: !!l || !!x
236
86
  };
237
87
  }
238
- const D = _(() => xe(e.attrs, h.value));
239
- if (typeof e.value == "function") {
240
- const i = _(() => {
241
- if (s(p))
242
- return e.value(h.value);
88
+ const j = h(() => le(o.attrs, m.value)), w = o.phantom ? h(() => typeof o.value == "function" ? o.value(m.value) : o.value) : void 0;
89
+ if (typeof o.value == "function" && !o.phantom) {
90
+ const l = h(() => {
91
+ if (i(g))
92
+ return o.value(m.value);
243
93
  });
244
- oe(
245
- i,
246
- (k) => {
247
- k !== void 0 && s(p) && (t.value.formData[e.field] = k);
94
+ J(
95
+ l,
96
+ (x) => {
97
+ x !== void 0 && i(g) && (t.value.formData[o.field] = x);
248
98
  },
249
99
  { immediate: !0 }
250
100
  );
251
101
  }
252
- const j = e.validators.map((i) => (k, S, X) => i({
253
- v: k,
254
- data: S,
255
- context: X ?? {},
256
- entry: h.value.entry
102
+ const c = o.validators.map((l) => (x, k, H) => l({
103
+ v: x,
104
+ data: k,
105
+ context: H ?? {},
106
+ entry: m.value.entry
257
107
  }));
258
- return (i, k) => (y(), U(x(ke), {
259
- modelValue: x(t).formData[e.field],
260
- "onUpdate:modelValue": k[0] || (k[0] = (S) => x(t).formData[e.field] = S),
261
- rules: x(j)
108
+ return (l, x) => (r(), N(d(ae), {
109
+ modelValue: d(t).formData[o.field],
110
+ "onUpdate:modelValue": x[0] || (x[0] = (k) => d(t).formData[o.field] = k),
111
+ rules: d(c)
262
112
  }, {
263
- default: K((S) => [
264
- w(i.$slots, "default", {
265
- onBlur: S.onBlur,
266
- error: o.error || S.error,
267
- model: S.model,
268
- formData: x(t).formData,
269
- formContext: x(t).formContext,
270
- label: x(u),
271
- description: x(d),
272
- hint: x(A),
273
- placeholder: x(v),
274
- classes: F(o.error, S.error),
275
- styles: x(C),
276
- optional: x(l),
277
- disabled: x(c),
278
- hidden: x(m),
279
- readonly: x(p),
280
- type: o.type,
281
- altAction: o.altAction,
282
- component: o.component,
283
- vName: o.name,
284
- field: o.field,
285
- options: x(E),
286
- maxLength: o.maxLength,
287
- required: f.value,
288
- autocomplete: o.autocomplete,
289
- attrs: D.value
113
+ default: z((k) => [
114
+ A(l.$slots, "default", {
115
+ onBlur: k.onBlur,
116
+ error: a.error || k.error,
117
+ model: k.model,
118
+ formData: d(t).formData,
119
+ formContext: d(t).formContext,
120
+ label: d(f),
121
+ description: d(s),
122
+ hint: d(q),
123
+ placeholder: d(v),
124
+ value: d(w),
125
+ classes: L(a.error, k.error),
126
+ styles: d($),
127
+ optional: d(C),
128
+ disabled: d(F),
129
+ hidden: d(_),
130
+ readonly: d(g),
131
+ type: a.type,
132
+ altAction: a.altAction,
133
+ component: a.component,
134
+ vName: a.name,
135
+ field: a.field,
136
+ options: d(b),
137
+ maxLength: a.maxLength,
138
+ required: d(E),
139
+ autocomplete: a.autocomplete,
140
+ attrs: j.value
290
141
  })
291
142
  ]),
292
143
  _: 3
293
144
  }, 8, ["modelValue", "rules"]));
294
145
  }
295
- }), Ve = { key: 0 }, $e = { key: 1 }, Ae = { key: 0 }, Se = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type", "disabled", "readonly"], we = { class: "oo-error-slot" }, Ce = { key: 4 }, Le = { key: 0 }, Te = ["onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], Be = {
146
+ }), ce = { key: 0 }, ue = { key: 1 }, de = { key: 0 }, ie = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type", "disabled", "readonly"], me = { class: "oo-error-slot" }, pe = { key: 4 }, ye = { key: 0 }, ve = ["onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], he = {
296
147
  key: 0,
297
148
  value: "",
298
149
  disabled: ""
299
- }, Fe = ["value"], De = { class: "oo-error-slot" }, je = { class: "oo-field-label" }, Pe = { key: 0 }, Oe = { class: "oo-radio-group" }, Ue = ["value", "onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], qe = { class: "oo-error-slot" }, Me = ["onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], Ne = { key: 0 }, Ie = { class: "oo-error-slot" }, ze = ["onClick"], He = { key: 9 }, Re = ["disabled"], ut = /* @__PURE__ */ I({
150
+ }, be = ["value"], xe = { class: "oo-error-slot" }, ke = { class: "oo-field-label" }, Ce = { key: 0 }, Ve = { class: "oo-radio-group" }, _e = ["value", "onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], ge = { class: "oo-error-slot" }, Be = ["onUpdate:modelValue", "onBlur", "name", "disabled", "readonly"], De = { key: 0 }, Fe = { class: "oo-error-slot" }, Ae = ["onClick"], Ue = { key: 9 }, Ee = ["disabled"], $e = /* @__PURE__ */ G({
300
151
  __name: "oo-form",
301
152
  props: {
302
153
  form: {},
@@ -308,788 +159,250 @@ const ke = /* @__PURE__ */ I({
308
159
  errors: {}
309
160
  },
310
161
  emits: ["submit", "action", "unsupported-action"],
311
- setup(o, { emit: e }) {
312
- const t = o, r = q({}), s = _(() => t.formData || r.value), a = _(() => ({
162
+ setup(a, { emit: o }) {
163
+ const t = a, y = Q({}), i = h(() => t.formData || y.value), V = h(() => ({
313
164
  v: void 0,
314
- data: s.value,
165
+ data: i.value,
315
166
  context: t.formContext ?? {},
316
167
  entry: void 0
317
- })), l = _(() => M(t.form.title, a.value)), c = _(() => M(t.form.submit.text, a.value)), m = _(() => M(t.form.submit.disabled, a.value));
318
- function p(d) {
319
- be(t.form, d) ? f("action", d, s.value) : f("unsupported-action", d, s.value);
168
+ })), C = h(() => M(t.form.title, V.value)), F = h(() => M(t.form.submit.text, V.value)), _ = h(() => M(t.form.submit.disabled, V.value));
169
+ function g(s) {
170
+ oe(t.form, s) ? E("action", s, i.value) : E("unsupported-action", s, i.value);
320
171
  }
321
- const f = e;
322
- function h(d) {
323
- return typeof d == "string" ? d : d.key;
172
+ const E = o;
173
+ function m(s) {
174
+ return typeof s == "string" ? s : s.key;
324
175
  }
325
- function u(d) {
326
- return typeof d == "string" ? d : d.label;
176
+ function f(s) {
177
+ return typeof s == "string" ? s : s.label;
327
178
  }
328
- return (d, A) => (y(), U(x(Ee), {
329
- "first-validation": o.firstValidation,
330
- onSubmit: A[0] || (A[0] = (v) => f("submit", v)),
331
- "form-data": s.value,
332
- "form-context": o.formContext
179
+ return (s, q) => (r(), N(d(ne), {
180
+ "first-validation": a.firstValidation,
181
+ onSubmit: q[0] || (q[0] = (v) => E("submit", v)),
182
+ "form-data": i.value,
183
+ "form-context": a.formContext
333
184
  }, {
334
- default: K((v) => [
335
- w(d.$slots, "form.header", {
185
+ default: z((v) => [
186
+ A(s.$slots, "form.header", {
336
187
  clearErrors: v.clearErrors,
337
188
  reset: v.reset,
338
- title: l.value,
339
- formContext: o.formContext,
340
- disabled: m.value
189
+ title: C.value,
190
+ formContext: a.formContext,
191
+ disabled: _.value
341
192
  }, () => [
342
- l.value ? (y(), b("h2", Ve, g(l.value), 1)) : P("", !0)
193
+ C.value ? (r(), u("h2", ce, n(C.value), 1)) : U("", !0)
343
194
  ]),
344
- w(d.$slots, "form.before", {
195
+ A(s.$slots, "form.before", {
345
196
  clearErrors: v.clearErrors,
346
197
  reset: v.reset
347
198
  }),
348
- (y(!0), b(H, null, R(t.form.fields, (E) => {
349
- var C;
350
- return y(), U(_e, L({
351
- key: E.field
352
- }, { ref_for: !0 }, E, {
353
- error: (C = o.errors) == null ? void 0 : C[E.field]
199
+ (r(!0), u(R, null, T(t.form.fields, (b) => {
200
+ var $;
201
+ return r(), N(se, B({
202
+ key: b.field
203
+ }, { ref_for: !0 }, b, {
204
+ error: ($ = a.errors) == null ? void 0 : $[b.field]
354
205
  }), {
355
- default: K((n) => [
356
- w(d.$slots, `field:${n.type}`, L({ ref_for: !0 }, n), () => {
357
- var F, D, j;
206
+ default: z((e) => [
207
+ A(s.$slots, `field:${e.type}`, B({ ref_for: !0 }, e), () => {
208
+ var L, j, w;
358
209
  return [
359
- E.component && ((F = t.components) != null && F[E.component]) ? (y(), U(J(t.components[E.component]), L({
210
+ b.component && ((L = t.components) != null && L[b.component]) ? (r(), N(K(t.components[b.component]), B({
360
211
  key: 0,
361
- "on-blur": n.onBlur,
362
- error: n.error,
363
- model: n.model,
364
- "form-data": n.formData,
365
- "form-context": n.formContext,
366
- label: n.label,
367
- description: n.description,
368
- hint: n.hint,
369
- placeholder: n.placeholder,
370
- class: n.classes,
371
- style: n.styles,
372
- optional: n.optional,
373
- required: !n.required,
374
- disabled: n.disabled,
375
- hidden: n.hidden,
376
- type: n.type,
377
- "alt-action": n.altAction,
378
- name: n.vName,
379
- field: n,
380
- options: n.options,
381
- "max-length": n.maxLength,
382
- autocomplete: n.autocomplete,
383
- onAction: p
384
- }, { ref_for: !0 }, n.attrs, {
385
- modelValue: n.model.value,
386
- "onUpdate:modelValue": (i) => n.model.value = i
387
- }), 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"])) : E.component && !((D = t.components) != null && D[E.component]) ? (y(), b("div", $e, " [" + g(n.label) + '] Component "' + g(n.component) + '" not supplied ', 1)) : (j = t.types) != null && j[E.type] ? (y(), U(J(t.types[E.type]), L({
212
+ "on-blur": e.onBlur,
213
+ error: e.error,
214
+ model: e.model,
215
+ "form-data": e.formData,
216
+ "form-context": e.formContext,
217
+ label: e.label,
218
+ description: e.description,
219
+ hint: e.hint,
220
+ placeholder: e.placeholder,
221
+ class: e.classes,
222
+ style: e.styles,
223
+ optional: e.optional,
224
+ required: !e.required,
225
+ disabled: e.disabled,
226
+ hidden: e.hidden,
227
+ type: e.type,
228
+ "alt-action": e.altAction,
229
+ name: e.vName,
230
+ field: e,
231
+ options: e.options,
232
+ "max-length": e.maxLength,
233
+ autocomplete: e.autocomplete,
234
+ onAction: g
235
+ }, { ref_for: !0 }, e.attrs, {
236
+ modelValue: e.model.value,
237
+ "onUpdate:modelValue": (c) => e.model.value = c
238
+ }), 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 && !((j = t.components) != null && j[b.component]) ? (r(), u("div", ue, " [" + n(e.label) + '] Component "' + n(e.component) + '" not supplied ', 1)) : (w = t.types) != null && w[b.type] ? (r(), N(K(t.types[b.type]), B({
388
239
  key: 2,
389
- "on-blur": n.onBlur,
390
- error: n.error,
391
- model: n.model,
392
- "form-data": n.formData,
393
- "form-context": n.formContext,
394
- label: n.label,
395
- description: n.description,
396
- hint: n.hint,
397
- placeholder: n.placeholder,
398
- class: n.classes,
399
- style: n.styles,
400
- optional: n.optional,
401
- required: !n.required,
402
- disabled: n.disabled,
403
- hidden: n.hidden,
404
- type: n.type,
405
- "alt-action": n.altAction,
406
- name: n.vName,
407
- field: n,
408
- options: n.options,
409
- "max-length": n.maxLength,
410
- autocomplete: n.autocomplete,
411
- onAction: p
412
- }, { ref_for: !0 }, n.attrs, {
413
- modelValue: n.model.value,
414
- "onUpdate:modelValue": (i) => n.model.value = i
415
- }), 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(n.type) ? T((y(), b("div", {
240
+ "on-blur": e.onBlur,
241
+ error: e.error,
242
+ model: e.model,
243
+ "form-data": e.formData,
244
+ "form-context": e.formContext,
245
+ label: e.label,
246
+ description: e.description,
247
+ hint: e.hint,
248
+ placeholder: e.placeholder,
249
+ class: e.classes,
250
+ style: e.styles,
251
+ optional: e.optional,
252
+ required: !e.required,
253
+ disabled: e.disabled,
254
+ hidden: e.hidden,
255
+ type: e.type,
256
+ "alt-action": e.altAction,
257
+ name: e.vName,
258
+ field: e,
259
+ options: e.options,
260
+ "max-length": e.maxLength,
261
+ autocomplete: e.autocomplete,
262
+ onAction: g
263
+ }, { ref_for: !0 }, e.attrs, {
264
+ modelValue: e.model.value,
265
+ "onUpdate:modelValue": (c) => e.model.value = c
266
+ }), 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) ? D((r(), u("div", {
416
267
  key: 3,
417
- class: O(["oo-default-field", n.classes])
268
+ class: S(["oo-default-field", e.classes])
418
269
  }, [
419
- V("label", null, g(n.label), 1),
420
- n.description ? (y(), b("span", Ae, g(n.description), 1)) : P("", !0),
421
- T(V("input", L({
422
- "onUpdate:modelValue": (i) => n.model.value = i,
423
- onBlur: n.onBlur,
424
- placeholder: n.placeholder,
425
- autocomplete: n.autocomplete,
426
- name: n.vName,
427
- type: n.type,
428
- disabled: n.disabled,
429
- readonly: n.readonly
430
- }, { ref_for: !0 }, n.attrs), null, 16, Se), [
431
- [de, n.model.value]
270
+ p("label", null, n(e.label), 1),
271
+ e.description ? (r(), u("span", de, n(e.description), 1)) : U("", !0),
272
+ D(p("input", B({
273
+ "onUpdate:modelValue": (c) => e.model.value = c,
274
+ onBlur: e.onBlur,
275
+ placeholder: e.placeholder,
276
+ autocomplete: e.autocomplete,
277
+ name: e.vName,
278
+ type: e.type,
279
+ disabled: e.disabled,
280
+ readonly: e.readonly
281
+ }, { ref_for: !0 }, e.attrs), null, 16, ie), [
282
+ [W, e.model.value]
432
283
  ]),
433
- V("div", we, g(n.error || n.hint), 1)
284
+ p("div", me, n(e.error || e.hint), 1)
434
285
  ], 2)), [
435
- [N, !n.hidden]
436
- ]) : n.type === "paragraph" ? (y(), b("p", Ce, g(n.description), 1)) : n.type === "select" ? T((y(), b("div", {
286
+ [O, !e.hidden]
287
+ ]) : e.type === "paragraph" ? (r(), u("p", pe, n(e.value), 1)) : e.type === "select" ? D((r(), u("div", {
437
288
  key: 5,
438
- class: O(["oo-default-field", n.classes])
289
+ class: S(["oo-default-field", e.classes])
439
290
  }, [
440
- V("label", null, g(n.label), 1),
441
- n.description ? (y(), b("span", Le, g(n.description), 1)) : P("", !0),
442
- T(V("select", L({
443
- "onUpdate:modelValue": (i) => n.model.value = i,
444
- onBlur: n.onBlur,
445
- name: n.vName,
446
- disabled: n.disabled,
447
- readonly: n.readonly
448
- }, { ref_for: !0 }, n.attrs), [
449
- n.placeholder ? (y(), b("option", Be, g(n.placeholder), 1)) : P("", !0),
450
- (y(!0), b(H, null, R(n.options, (i) => (y(), b("option", {
451
- key: h(i),
452
- value: h(i)
453
- }, g(u(i)), 9, Fe))), 128))
454
- ], 16, Te), [
455
- [me, n.model.value]
291
+ p("label", null, n(e.label), 1),
292
+ e.description ? (r(), u("span", ye, n(e.description), 1)) : U("", !0),
293
+ D(p("select", B({
294
+ "onUpdate:modelValue": (c) => e.model.value = c,
295
+ onBlur: e.onBlur,
296
+ name: e.vName,
297
+ disabled: e.disabled,
298
+ readonly: e.readonly
299
+ }, { ref_for: !0 }, e.attrs), [
300
+ e.placeholder ? (r(), u("option", he, n(e.placeholder), 1)) : U("", !0),
301
+ (r(!0), u(R, null, T(e.options, (c) => (r(), u("option", {
302
+ key: m(c),
303
+ value: m(c)
304
+ }, n(f(c)), 9, be))), 128))
305
+ ], 16, ve), [
306
+ [X, e.model.value]
456
307
  ]),
457
- V("div", De, g(n.error || n.hint), 1)
308
+ p("div", xe, n(e.error || e.hint), 1)
458
309
  ], 2)), [
459
- [N, !n.hidden]
460
- ]) : n.type === "radio" ? T((y(), b("div", {
310
+ [O, !e.hidden]
311
+ ]) : e.type === "radio" ? D((r(), u("div", {
461
312
  key: 6,
462
- class: O(["oo-default-field oo-radio-field", n.classes])
313
+ class: S(["oo-default-field oo-radio-field", e.classes])
463
314
  }, [
464
- V("span", je, g(n.label), 1),
465
- n.description ? (y(), b("span", Pe, g(n.description), 1)) : P("", !0),
466
- V("div", Oe, [
467
- (y(!0), b(H, null, R(n.options, (i) => (y(), b("label", {
468
- key: h(i)
315
+ p("span", ke, n(e.label), 1),
316
+ e.description ? (r(), u("span", Ce, n(e.description), 1)) : U("", !0),
317
+ p("div", Ve, [
318
+ (r(!0), u(R, null, T(e.options, (c) => (r(), u("label", {
319
+ key: m(c)
469
320
  }, [
470
- T(V("input", L({
321
+ D(p("input", B({
471
322
  type: "radio",
472
- value: h(i),
473
- "onUpdate:modelValue": (k) => n.model.value = k,
474
- onBlur: n.onBlur,
475
- name: n.vName,
476
- disabled: n.disabled,
477
- readonly: n.readonly
478
- }, { ref_for: !0 }, n.attrs), null, 16, Ue), [
479
- [fe, n.model.value]
323
+ value: m(c),
324
+ "onUpdate:modelValue": (l) => e.model.value = l,
325
+ onBlur: e.onBlur,
326
+ name: e.vName,
327
+ disabled: e.disabled,
328
+ readonly: e.readonly
329
+ }, { ref_for: !0 }, e.attrs), null, 16, _e), [
330
+ [Y, e.model.value]
480
331
  ]),
481
- Z(" " + g(u(i)), 1)
332
+ P(" " + n(f(c)), 1)
482
333
  ]))), 128))
483
334
  ]),
484
- V("div", qe, g(n.error || n.hint), 1)
335
+ p("div", ge, n(e.error || e.hint), 1)
485
336
  ], 2)), [
486
- [N, !n.hidden]
487
- ]) : n.type === "checkbox" ? T((y(), b("div", {
337
+ [O, !e.hidden]
338
+ ]) : e.type === "checkbox" ? D((r(), u("div", {
488
339
  key: 7,
489
- class: O(["oo-default-field oo-checkbox-field", n.classes])
340
+ class: S(["oo-default-field oo-checkbox-field", e.classes])
490
341
  }, [
491
- V("label", null, [
492
- T(V("input", L({
342
+ p("label", null, [
343
+ D(p("input", B({
493
344
  type: "checkbox",
494
- "onUpdate:modelValue": (i) => n.model.value = i,
495
- onBlur: n.onBlur,
496
- name: n.vName,
497
- disabled: n.disabled,
498
- readonly: n.readonly
499
- }, { ref_for: !0 }, n.attrs), null, 16, Me), [
500
- [he, n.model.value]
345
+ "onUpdate:modelValue": (c) => e.model.value = c,
346
+ onBlur: e.onBlur,
347
+ name: e.vName,
348
+ disabled: e.disabled,
349
+ readonly: e.readonly
350
+ }, { ref_for: !0 }, e.attrs), null, 16, Be), [
351
+ [Z, e.model.value]
501
352
  ]),
502
- Z(" " + g(n.label), 1)
353
+ P(" " + n(e.label), 1)
503
354
  ]),
504
- n.description ? (y(), b("span", Ne, g(n.description), 1)) : P("", !0),
505
- V("div", Ie, g(n.error || n.hint), 1)
355
+ e.description ? (r(), u("span", De, n(e.description), 1)) : U("", !0),
356
+ p("div", Fe, n(e.error || e.hint), 1)
506
357
  ], 2)), [
507
- [N, !n.hidden]
508
- ]) : n.type === "action" ? (y(), b("div", {
358
+ [O, !e.hidden]
359
+ ]) : e.type === "action" ? (r(), u("div", {
509
360
  key: 8,
510
- class: O(["oo-default-field oo-action-field", n.classes])
361
+ class: S(["oo-default-field oo-action-field", e.classes])
511
362
  }, [
512
- V("button", {
363
+ p("button", {
513
364
  type: "button",
514
- onClick: (i) => p(n.altAction)
515
- }, g(n.label), 9, ze)
516
- ], 2)) : (y(), b("div", He, " [" + g(n.label) + '] Not supported field type "' + g(n.type) + '" ' + g(n.component), 1))
365
+ onClick: (c) => g(e.altAction)
366
+ }, n(e.label), 9, Ae)
367
+ ], 2)) : (r(), u("div", Ue, " [" + n(e.label) + '] Not supported field type "' + n(e.type) + '" ' + n(e.component), 1))
517
368
  ];
518
369
  })
519
370
  ]),
520
371
  _: 2
521
372
  }, 1040, ["error"]);
522
373
  }), 128)),
523
- w(d.$slots, "form.after", {
374
+ A(s.$slots, "form.after", {
524
375
  clearErrors: v.clearErrors,
525
376
  reset: v.reset,
526
- disabled: m.value,
527
- formContext: o.formContext
377
+ disabled: _.value,
378
+ formContext: a.formContext
528
379
  }),
529
- w(d.$slots, "form.submit", {
530
- disabled: m.value,
531
- text: c.value,
380
+ A(s.$slots, "form.submit", {
381
+ disabled: _.value,
382
+ text: F.value,
532
383
  clearErrors: v.clearErrors,
533
384
  reset: v.reset,
534
- formContext: o.formContext
385
+ formContext: a.formContext
535
386
  }, () => [
536
- V("button", { disabled: m.value }, g(c.value), 9, Re)
387
+ p("button", { disabled: _.value }, n(F.value), 9, Ee)
537
388
  ]),
538
- w(d.$slots, "form.footer", {
539
- disabled: m.value,
389
+ A(s.$slots, "form.footer", {
390
+ disabled: _.value,
540
391
  clearErrors: v.clearErrors,
541
392
  reset: v.reset,
542
- formContext: o.formContext
393
+ formContext: a.formContext
543
394
  })
544
395
  ]),
545
396
  _: 3
546
397
  }, 8, ["first-validation", "form-data", "form-context"]));
547
398
  }
548
- }), Ge = {
549
- // Node.js Globals
550
- global: null,
551
- process: null,
552
- Buffer: null,
553
- require: null,
554
- __filename: null,
555
- __dirname: null,
556
- exports: null,
557
- module: null,
558
- setImmediate: null,
559
- clearImmediate: null,
560
- setTimeout: null,
561
- clearTimeout: null,
562
- setInterval: null,
563
- clearInterval: null,
564
- queueMicrotask: null,
565
- queueGlobalMicrotask: null,
566
- globalThis: null,
567
- // GlobalThis (Introduced in ECMAScript 2020)
568
- // Browser Globals
569
- window: null,
570
- self: null,
571
- document: null,
572
- localStorage: null,
573
- sessionStorage: null,
574
- indexedDB: null,
575
- caches: null,
576
- console: null,
577
- performance: null,
578
- fetch: null,
579
- XMLHttpRequest: null,
580
- Image: null,
581
- Audio: null,
582
- navigator: null,
583
- navigation: null,
584
- location: null,
585
- history: null,
586
- screen: null,
587
- requestAnimationFrame: null,
588
- cancelAnimationFrame: null,
589
- cancelIdleCallback: null,
590
- captureEvents: null,
591
- chrome: null,
592
- clientInformation: null,
593
- addEventListener: null,
594
- removeEventListener: null,
595
- blur: null,
596
- close: null,
597
- closed: null,
598
- confirm: null,
599
- alert: null,
600
- customElements: null,
601
- dispatchEvent: null,
602
- debug: null,
603
- focus: null,
604
- find: null,
605
- frames: null,
606
- getSelection: null,
607
- getScreenDetails: null,
608
- getEventListeners: null,
609
- keys: null,
610
- launchQueue: null,
611
- parent: null,
612
- postMessage: null,
613
- print: null,
614
- profile: null,
615
- profileEnd: null,
616
- prompt: null,
617
- queryLocalFonts: null,
618
- queryObjects: null,
619
- releaseEvents: null,
620
- reportError: null,
621
- resizeBy: null,
622
- resizeTo: null,
623
- scheduler: null,
624
- stop: null,
625
- scroll: null,
626
- scrollBy: null,
627
- scrollTo: null,
628
- scrollY: null,
629
- scrollX: null,
630
- top: null,
631
- // other
632
- eval: null,
633
- __ctx__: null
634
- };
635
- class Ke {
636
- constructor() {
637
- Y(this, "cache", /* @__PURE__ */ new Map());
638
- }
639
- call(e, t) {
640
- return this.getFn(e)(t);
641
- }
642
- getFn(e) {
643
- let t = this.cache.get(e);
644
- return t || (t = We(e), this.cache.set(e, t)), t;
645
- }
646
- }
647
- function We(o) {
648
- const e = `with(__ctx__){
649
- ${o}
650
- }`, t = new Function("__ctx__", e);
651
- return (r) => {
652
- const s = Object.freeze(Object.assign({}, Ge, r));
653
- return t(s);
654
- };
655
- }
656
- const W = new Ke();
657
- function ne(o) {
658
- const e = `return (${o})(v, data, context, entry)`;
659
- return W.getFn(e);
660
- }
661
- function G(o) {
662
- const e = `return (${o})(data, context)`;
663
- return W.getFn(e);
664
- }
665
- function Xe(o) {
666
- const e = `return (${o})(v, data, context, entry)`;
667
- return W.getFn(e);
668
- }
669
- function Ye(o, e) {
670
- switch (o.type.kind) {
671
- case "": {
672
- const t = o;
673
- return e.phantom && t.type.designType === "phantom" ? e.phantom(t) : e.final(t);
674
- }
675
- case "object":
676
- return e.object(o);
677
- case "array":
678
- return e.array(o);
679
- case "union":
680
- return e.union(o);
681
- case "intersection":
682
- return e.intersection(o);
683
- case "tuple":
684
- return e.tuple(o);
685
- default:
686
- throw new Error(`Unknown type kind "${o.type.kind}"`);
687
- }
688
- }
689
- function B(o, e, t) {
690
- return e in o ? Object.defineProperty(o, e, {
691
- value: t,
692
- enumerable: !0,
693
- configurable: !0,
694
- writable: !0
695
- }) : o[e] = t, o;
696
- }
697
- const ee = /* @__PURE__ */ new Map();
698
- var Qe = class {
699
- isLimitExceeded() {
700
- return this.stackErrors.length > 0 ? this.stackErrors[this.stackErrors.length - 1].length >= this.opts.errorLimit : this.errors.length >= this.opts.errorLimit;
701
- }
702
- push(o) {
703
- this.stackPath.push(o), this.stackErrors.push([]);
704
- }
705
- pop(o) {
706
- this.stackPath.pop();
707
- const e = this.stackErrors.pop();
708
- return o && (e != null && e.length) && e.forEach((t) => {
709
- this.error(t.message, t.path, t.details);
710
- }), e;
711
- }
712
- clear() {
713
- this.stackErrors[this.stackErrors.length - 1] = [];
714
- }
715
- error(o, e, t) {
716
- const r = this.stackErrors[this.stackErrors.length - 1] || this.errors, s = {
717
- path: e || this.path,
718
- message: o
719
- };
720
- t != null && t.length && (s.details = t), r.push(s);
721
- }
722
- throw() {
723
- throw new Je(this.errors);
724
- }
725
- /**
726
- * Validates a value against the type definition.
727
- *
728
- * Acts as a TypeScript type guard — when it returns `true`, the value
729
- * is narrowed to `DataType`.
730
- *
731
- * @param value - The value to validate.
732
- * @param safe - If `true`, returns `false` on failure instead of throwing.
733
- * @returns `true` if the value matches the type definition.
734
- * @throws {ValidatorError} When validation fails and `safe` is not `true`.
735
- */
736
- validate(o, e) {
737
- this.push(""), this.errors = [], this.stackErrors = [];
738
- const t = this.validateSafe(this.def, o);
739
- if (this.pop(!t), !t) {
740
- if (e) return !1;
741
- this.throw();
742
- }
743
- return !0;
744
- }
745
- validateSafe(o, e) {
746
- if (this.isLimitExceeded()) return !1;
747
- if (!Ze(o)) throw new Error("Can not validate not-annotated type");
748
- if (typeof this.opts.replace == "function" && (o = this.opts.replace(o, this.path)), o.optional && e === void 0) return !0;
749
- for (const t of this.opts.plugins) {
750
- const r = t(this, o, e);
751
- if (r === !1 || r === !0) return r;
752
- }
753
- return this.validateAnnotatedType(o, e);
754
- }
755
- get path() {
756
- return this.stackPath.slice(1).join(".");
757
- }
758
- validateAnnotatedType(o, e) {
759
- return Ye(o, {
760
- final: (t) => this.validatePrimitive(t, e),
761
- phantom: () => !0,
762
- object: (t) => this.validateObject(t, e),
763
- array: (t) => this.validateArray(t, e),
764
- union: (t) => this.validateUnion(t, e),
765
- intersection: (t) => this.validateIntersection(t, e),
766
- tuple: (t) => this.validateTuple(t, e)
767
- });
768
- }
769
- validateUnion(o, e) {
770
- let t = 0;
771
- const r = [];
772
- for (const a of o.type.items) {
773
- if (this.push(`[${a.type.kind || a.type.designType}(${t})]`), this.validateSafe(a, e))
774
- return this.pop(!1), !0;
775
- const l = this.pop(!1);
776
- l && r.push(...l), t++;
777
- }
778
- this.clear();
779
- const s = o.type.items.map((a, l) => `[${a.type.kind || a.type.designType}(${l})]`).join(", ");
780
- return this.error(`Value does not match any of the allowed types: ${s}`, void 0, r), !1;
781
- }
782
- validateIntersection(o, e) {
783
- for (const t of o.type.items) if (!this.validateSafe(t, e)) return !1;
784
- return !0;
785
- }
786
- validateTuple(o, e) {
787
- if (!Array.isArray(e) || e.length !== o.type.items.length)
788
- return this.error(`Expected array of length ${o.type.items.length}`), !1;
789
- let t = 0;
790
- for (const r of o.type.items) {
791
- if (this.push(`[${t}]`), !this.validateSafe(r, e[t]))
792
- return this.pop(!0), !1;
793
- this.pop(!1), t++;
794
- }
795
- return !0;
796
- }
797
- validateArray(o, e) {
798
- if (!Array.isArray(e))
799
- return this.error("Expected array"), !1;
800
- const t = o.metadata.get("expect.minLength");
801
- if (t) {
802
- const l = typeof t == "number" ? t : t.length;
803
- if (e.length < l) {
804
- const c = typeof t == "object" && t.message ? t.message : `Expected minimum length of ${l} items, got ${e.length} items`;
805
- return this.error(c), !1;
806
- }
807
- }
808
- const r = o.metadata.get("expect.maxLength");
809
- if (r) {
810
- const l = typeof r == "number" ? r : r.length;
811
- if (e.length > l) {
812
- const c = typeof r == "object" && r.message ? r.message : `Expected maximum length of ${l} items, got ${e.length} items`;
813
- return this.error(c), !1;
814
- }
815
- }
816
- let s = 0, a = !0;
817
- for (const l of e) {
818
- if (this.push(`[${s}]`), this.validateSafe(o.type.of, l))
819
- this.pop(!1);
820
- else if (a = !1, this.pop(!0), this.isLimitExceeded()) return !1;
821
- s++;
822
- }
823
- return a;
824
- }
825
- validateObject(o, e) {
826
- if (typeof e != "object" || e === null || Array.isArray(e))
827
- return this.error("Expected object"), !1;
828
- let t = !0;
829
- const r = new Set(Object.keys(e)), s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
830
- if (this.opts.skipList) {
831
- const c = this.stackPath.length > 1 ? `${this.path}.` : "";
832
- this.opts.skipList.forEach((m) => {
833
- if (m.startsWith(c)) {
834
- const p = m.slice(c.length);
835
- a.add(p), r.delete(p);
836
- }
837
- });
838
- }
839
- let l = !1;
840
- typeof this.opts.partial == "function" && (l = this.opts.partial(o, this.path));
841
- for (const [c, m] of o.type.props.entries())
842
- if (!(a.has(c) || et(m)) && (s.add(c), !(e[c] === void 0 && (l || this.opts.partial === "deep" || this.opts.partial === !0 && this.stackPath.length <= 1)))) {
843
- if (this.push(c), this.validateSafe(m, e[c])) this.pop(!1);
844
- else if (t = !1, this.pop(!0), this.isLimitExceeded()) return !1;
845
- }
846
- for (const c of r)
847
- if (!s.has(c)) {
848
- const m = [];
849
- for (const { pattern: p, def: f } of o.type.propsPatterns) p.test(c) && m.push({
850
- pattern: p,
851
- def: f
852
- });
853
- if (m.length) {
854
- let p = !1;
855
- for (const { def: f } of m) if (this.validateSafe(f, e[c])) {
856
- this.pop(!1), p = !0;
857
- break;
858
- }
859
- if (!p && (this.push(c), this.validateSafe(m[0].def, e[c]), this.pop(!0), t = !1, this.isLimitExceeded()))
860
- return !1;
861
- } else if (this.opts.unknwonProps !== "ignore")
862
- if (this.opts.unknwonProps === "error") {
863
- if (this.push(c), this.error("Unexpected property"), this.pop(!0), this.isLimitExceeded()) return !1;
864
- t = !1;
865
- } else this.opts.unknwonProps === "strip" && delete e[c];
866
- }
867
- return t;
868
- }
869
- validatePrimitive(o, e) {
870
- if (typeof o.type.value < "u")
871
- return e !== o.type.value ? (this.error(`Expected ${o.type.value}, got ${e}`), !1) : !0;
872
- const t = Array.isArray(e) ? "array" : typeof e;
873
- switch (o.type.designType) {
874
- case "never":
875
- return this.error("This type is impossible, must be an internal problem"), !1;
876
- case "any":
877
- return !0;
878
- case "string":
879
- return t !== o.type.designType ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : this.validateString(o, e);
880
- case "number":
881
- return t !== o.type.designType ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : this.validateNumber(o, e);
882
- case "boolean":
883
- return t !== o.type.designType ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : !0;
884
- case "undefined":
885
- return e !== void 0 ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : !0;
886
- case "null":
887
- return e !== null ? (this.error(`Expected ${o.type.designType}, got ${t}`), !1) : !0;
888
- default:
889
- throw new Error(`Unknown type "${o.type.designType}"`);
890
- }
891
- }
892
- validateString(o, e) {
893
- const t = o.metadata.get("expect.minLength");
894
- if (t) {
895
- const a = typeof t == "number" ? t : t.length;
896
- if (e.length < a) {
897
- const l = typeof t == "object" && t.message ? t.message : `Expected minimum length of ${a} characters, got ${e.length} characters`;
898
- return this.error(l), !1;
899
- }
900
- }
901
- const r = o.metadata.get("expect.maxLength");
902
- if (r) {
903
- const a = typeof r == "number" ? r : r.length;
904
- if (e.length > a) {
905
- const l = typeof r == "object" && r.message ? r.message : `Expected maximum length of ${a} characters, got ${e.length} characters`;
906
- return this.error(l), !1;
907
- }
908
- }
909
- const s = o.metadata.get("expect.pattern");
910
- for (const { pattern: a, flags: l, message: c } of s || []) {
911
- if (!a) continue;
912
- const m = `${a}//${l || ""}`;
913
- let p = ee.get(m);
914
- if (p || (p = new RegExp(a, l), ee.set(m, p)), !p.test(e))
915
- return this.error(c || `Value is expected to match pattern "${a}"`), !1;
916
- }
917
- return !0;
918
- }
919
- validateNumber(o, e) {
920
- const t = o.metadata.get("expect.int");
921
- if (t && e % 1 !== 0) {
922
- const a = typeof t == "object" && t.message ? t.message : `Expected integer, got ${e}`;
923
- return this.error(a), !1;
924
- }
925
- const r = o.metadata.get("expect.min");
926
- if (r) {
927
- const a = typeof r == "number" ? r : r.minValue;
928
- if (e < a) {
929
- const l = typeof r == "object" && r.message ? r.message : `Expected minimum ${a}, got ${e}`;
930
- return this.error(l), !1;
931
- }
932
- }
933
- const s = o.metadata.get("expect.max");
934
- if (s) {
935
- const a = typeof s == "number" ? s : s.maxValue;
936
- if (e > a) {
937
- const l = typeof s == "object" && s.message ? s.message : `Expected maximum ${a}, got ${e}`;
938
- return this.error(l), !1;
939
- }
940
- }
941
- return !0;
942
- }
943
- constructor(o, e) {
944
- B(this, "def", void 0), B(this, "opts", void 0), B(this, "errors", void 0), B(this, "stackErrors", void 0), B(this, "stackPath", void 0), this.def = o, this.errors = [], this.stackErrors = [], this.stackPath = [], this.opts = {
945
- partial: !1,
946
- unknwonProps: "error",
947
- errorLimit: 10,
948
- ...e,
949
- plugins: (e == null ? void 0 : e.plugins) || []
950
- };
951
- }
952
- }, Je = class extends Error {
953
- constructor(o) {
954
- super(`${o[0].path ? o[0].path + ": " : ""}${o[0].message}`), B(this, "errors", void 0), B(this, "name", void 0), this.errors = o, this.name = "Validation Error";
955
- }
956
- };
957
- function Ze(o) {
958
- return o && o.__is_atscript_annotated_type;
959
- }
960
- function et(o) {
961
- return o.type.kind === "" && o.type.designType === "phantom";
962
- }
963
- const tt = /* @__PURE__ */ new Set(["action", "paragraph", "select", "radio", "checkbox"]);
964
- function ot(o) {
965
- return (Array.isArray(o) ? o : [o]).map((t) => {
966
- if (typeof t == "object" && t !== null && "label" in t) {
967
- const { label: r, value: s } = t;
968
- return s !== void 0 ? { key: s, label: r } : r;
969
- }
970
- return String(t);
971
- });
972
- }
973
- function $(o, e, t, r) {
974
- const { transform: s, defaultValue: a, staticAsBoolean: l = !1, compiler: c = ne } = r ?? {}, m = t.get(o);
975
- if (typeof m == "string")
976
- return c(m);
977
- if (e !== void 0) {
978
- const p = t.get(e);
979
- if (p !== void 0)
980
- return l ? !0 : s ? s(p) : p;
981
- }
982
- return a;
983
- }
984
- function nt(o, e) {
985
- var t, r, s, a;
986
- return {
987
- optional: (t = $("foorm.fn.optional", void 0, o)) !== null && t !== void 0 ? t : e ?? !1,
988
- disabled: (r = $("foorm.fn.disabled", "foorm.disabled", o, {
989
- staticAsBoolean: !0
990
- })) !== null && r !== void 0 ? r : !1,
991
- hidden: (s = $("foorm.fn.hidden", "foorm.hidden", o, {
992
- staticAsBoolean: !0
993
- })) !== null && s !== void 0 ? s : !1,
994
- readonly: (a = $("foorm.fn.readonly", "foorm.readonly", o, {
995
- staticAsBoolean: !0
996
- })) !== null && a !== void 0 ? a : !1
997
- };
998
- }
999
- function rt(o, e) {
1000
- return {
1001
- label: $("foorm.fn.label", "meta.label", o, {
1002
- defaultValue: e
1003
- }),
1004
- description: $("foorm.fn.description", "meta.description", o),
1005
- hint: $("foorm.fn.hint", "meta.hint", o),
1006
- placeholder: $("foorm.fn.placeholder", "meta.placeholder", o)
1007
- };
1008
- }
1009
- function st(o) {
1010
- const e = o.get("foorm.attr"), t = o.get("foorm.fn.attr");
1011
- if (!e && !t)
1012
- return;
1013
- const r = {};
1014
- if (e) {
1015
- const s = Array.isArray(e) ? e : [e];
1016
- for (const a of s)
1017
- if (typeof a == "object" && a !== null && "name" in a && "value" in a) {
1018
- const { name: l, value: c } = a;
1019
- r[l] = c;
1020
- }
1021
- }
1022
- if (t) {
1023
- const s = Array.isArray(t) ? t : [t];
1024
- for (const a of s)
1025
- if (typeof a == "object" && a !== null && "name" in a && "fn" in a) {
1026
- const { name: l, fn: c } = a;
1027
- r[l] = ne(c);
1028
- }
1029
- }
1030
- return Object.keys(r).length > 0 ? r : void 0;
1031
- }
1032
- function at(o) {
1033
- var e, t;
1034
- const r = o.metadata, s = o.type.props, a = $("foorm.fn.title", "foorm.title", r, {
1035
- compiler: G,
1036
- defaultValue: ""
1037
- }), l = $("foorm.fn.submit.text", "foorm.submit.text", r, {
1038
- compiler: G,
1039
- defaultValue: "Submit"
1040
- }), c = $("foorm.fn.submit.disabled", "foorm.submit.disabled", r, {
1041
- compiler: G,
1042
- defaultValue: !1
1043
- }), m = { text: l, disabled: c }, p = [];
1044
- for (const [f, h] of s.entries()) {
1045
- const u = h.metadata, d = (e = h.type) === null || e === void 0 ? void 0 : e.tags, A = u.get("foorm.type"), v = d ? [...d].find((i) => tt.has(i)) : void 0, E = (t = A ?? v) !== null && t !== void 0 ? t : "text", C = [], n = u.get("foorm.validate");
1046
- if (n) {
1047
- const i = Array.isArray(n) ? n : [n];
1048
- for (const k of i)
1049
- typeof k == "string" && C.push(Xe(k));
1050
- }
1051
- const F = u.get("expect.pattern") !== void 0 || u.get("expect.min") !== void 0 || u.get("expect.max") !== void 0 || u.get("expect.minLength") !== void 0 || u.get("expect.maxLength") !== void 0 || u.get("expect.int") !== void 0, D = d && d.size > 0;
1052
- if (F || D) {
1053
- const i = new Qe(h);
1054
- C.push((k) => {
1055
- var S;
1056
- if (i.validate(k.v, !0))
1057
- return !0;
1058
- const z = (S = i.errors) === null || S === void 0 ? void 0 : S[0];
1059
- return (z == null ? void 0 : z.message) || "Validation failed";
1060
- });
1061
- }
1062
- const j = Object.assign(Object.assign(Object.assign({ field: f, type: E, component: u.get("foorm.component"), autocomplete: u.get("foorm.autocomplete"), altAction: u.get("foorm.altAction"), order: u.get("foorm.order"), name: f }, rt(u, f)), nt(u, h.optional)), {
1063
- // Appearance - truly optional
1064
- classes: $("foorm.fn.classes", void 0, u),
1065
- styles: $("foorm.fn.styles", void 0, u),
1066
- // Data properties - truly optional
1067
- options: $("foorm.fn.options", "foorm.options", u, {
1068
- transform: ot
1069
- }),
1070
- value: $("foorm.fn.value", "foorm.value", u),
1071
- validators: C,
1072
- // Custom attributes/props
1073
- attrs: st(u),
1074
- // ATScript @expect constraints
1075
- maxLength: u.get("expect.maxLength"),
1076
- minLength: u.get("expect.minLength"),
1077
- min: u.get("expect.min"),
1078
- max: u.get("expect.max")
1079
- });
1080
- p.push(j);
1081
- }
1082
- return p.sort((f, h) => {
1083
- var u, d;
1084
- return ((u = f.order) !== null && u !== void 0 ? u : 1 / 0) - ((d = h.order) !== null && d !== void 0 ? d : 1 / 0);
1085
- }), { title: a, submit: m, fields: p };
1086
- }
1087
- function ct(o) {
1088
- const e = at(o), t = ye(ve(e.fields));
1089
- return { form: e, formData: t };
399
+ });
400
+ function Le(a) {
401
+ const o = re(a), t = ee(te(o.fields));
402
+ return { form: o, formData: t };
1090
403
  }
1091
404
  export {
1092
- _e as OoField,
1093
- ut as OoForm,
1094
- ct as useFoorm
405
+ se as OoField,
406
+ $e as OoForm,
407
+ Le as useFoorm
1095
408
  };