@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/dist/index.js CHANGED
@@ -1,22 +1,30 @@
1
- import { defineComponent as q, mergeModels as I, useModel as L, inject as O, ref as k, computed as i, watch as R, onUnmounted as T, getCurrentInstance as N, renderSlot as _, unref as x, provide as W, openBlock as p, createElementBlock as V, withModifiers as G, nextTick as J, createBlock as B, withCtx as w, toDisplayString as h, createCommentVNode as j, Fragment as K, renderList as Q, normalizeProps as A, guardReactiveProps as M, resolveDynamicComponent as F, mergeProps as H, normalizeClass as X, createElementVNode as $, withDirectives as Y, vModelDynamic as Z } from "vue";
2
- function C(n, r) {
3
- return U(n) ? n(r) : n;
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 S(n, r) {
6
- if (typeof n == "object" && n !== null) {
7
- const o = {};
8
- for (const [t, m] of Object.entries(n))
9
- o[t] = C(m, r);
10
- return o;
11
- }
12
- return U(n) ? n(r) : n;
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 U(n) {
15
- return typeof n == "function";
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 ee = /* @__PURE__ */ q({
25
+ const ce = /* @__PURE__ */ T({
18
26
  __name: "VuilessField",
19
- props: /* @__PURE__ */ I({
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 r = n, o = L(n, "modelValue"), t = O("vuiless"), m = k(), d = k(!1), b = k(!1), v = i(() => {
28
- var a;
29
- if ((a = t == null ? void 0 : t.value) != null && a.firstValidation)
30
- switch (t.value.firstValidation) {
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 t.value.firstSubmitHappened || d.value;
40
+ return r.value.firstSubmitHappened || d.value;
33
41
  case "touched-on-blur":
34
- return t.value.firstSubmitHappened || b.value && d.value;
42
+ return r.value.firstSubmitHappened || v.value && d.value;
35
43
  case "on-blur":
36
- return t.value.firstSubmitHappened || b.value;
44
+ return r.value.firstSubmitHappened || v.value;
37
45
  case "on-submit":
38
- return t.value.firstSubmitHappened;
46
+ return r.value.firstSubmitHappened;
39
47
  case "none":
40
48
  return !1;
41
49
  }
42
50
  return !1;
43
- }), y = i(() => {
44
- if (v.value || m.value)
45
- return l();
51
+ }), g = m(() => {
52
+ if (f.value || a.value)
53
+ return V();
46
54
  });
47
- R([o], () => {
48
- m.value = void 0, d.value = !0;
49
- }), T(() => {
50
- var a;
51
- (a = t == null ? void 0 : t.value) == null || a.unregister(N());
52
- }), t != null && t.value && t.value.register(N(), {
53
- validate: () => (m.value = l(), m.value || !0),
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, b.value = !1, m.value = void 0;
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 l() {
62
- var a, e, f;
63
- if ((a = r.rules) != null && a.length)
64
- for (const g of r.rules) {
65
- const u = g(
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
- (e = t == null ? void 0 : t.value) == null ? void 0 : e.formData,
68
- (f = t == null ? void 0 : t.value) == null ? void 0 : f.formContext
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 (u !== !0)
71
- return u || "Wrong value";
78
+ if (e !== !0)
79
+ return e || "Wrong value";
72
80
  }
73
81
  }
74
- function c() {
75
- b.value = !0;
82
+ function i() {
83
+ v.value = !0;
76
84
  }
77
85
  const s = {
78
- v: i({
86
+ v: m({
79
87
  get: () => o.value,
80
- set: (a) => o.value = a
88
+ set: (c) => o.value = c
81
89
  })
82
90
  };
83
- return (a, e) => {
84
- var f, g;
85
- return _(a.$slots, "default", {
86
- onBlur: c,
87
- error: y.value,
88
- formData: (f = x(t)) == null ? void 0 : f.formData,
89
- formContext: (g = x(t)) == null ? void 0 : g.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
- }), te = /* @__PURE__ */ q({
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: r }) {
103
- const o = n, t = r, m = /* @__PURE__ */ new Map(), d = k(!1), b = i(() => ({
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: (c, s) => {
107
- m.set(c, s);
114
+ register: (i, s) => {
115
+ a.set(i, s);
108
116
  },
109
- unregister: (c) => m.delete(c),
117
+ unregister: (i) => a.delete(i),
110
118
  formData: o.formData,
111
119
  formContext: o.formContext
112
120
  }));
113
- W("vuiless", b);
114
- function v() {
121
+ K("vuiless", v);
122
+ function f() {
115
123
  d.value = !1;
116
- for (const { clearErrors: c } of m.values())
117
- c();
124
+ for (const { clearErrors: i } of a.values())
125
+ i();
118
126
  }
119
- async function y() {
120
- for (const { reset: c } of m.values())
121
- c();
122
- await J(), v();
127
+ async function g() {
128
+ for (const { reset: i } of a.values())
129
+ i();
130
+ await ee(), f();
123
131
  }
124
- function l() {
132
+ function V() {
125
133
  d.value = !0;
126
- let c = !1;
134
+ let i = !1;
127
135
  if (o.firstValidation !== "none")
128
- for (const { validate: s } of m.values())
129
- s() !== !0 && (c = !0);
130
- c || t("submit", o.formData);
136
+ for (const { validate: s } of a.values())
137
+ s() !== !0 && (i = !0);
138
+ i || r("submit", o.formData);
131
139
  }
132
- return (c, s) => (p(), V("form", {
133
- onSubmit: G(l, ["prevent"])
140
+ return (i, s) => (x(), E("form", {
141
+ onSubmit: Z(V, ["prevent"])
134
142
  }, [
135
- _(c.$slots, "default", {
136
- clearErrors: v,
137
- reset: y
143
+ A(i.$slots, "default", {
144
+ clearErrors: f,
145
+ reset: g
138
146
  })
139
147
  ], 32));
140
148
  }
141
- }), oe = /* @__PURE__ */ q({
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
- value: {},
157
- options: {},
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
- optional: { type: Boolean },
160
- disabled: { type: Boolean },
161
- hidden: { type: Boolean },
162
- length: {},
163
- validators: {}
170
+ value: {},
171
+ validators: {},
172
+ maxLength: {},
173
+ minLength: {},
174
+ min: {},
175
+ max: {},
176
+ error: {}
164
177
  },
165
178
  setup(n) {
166
- const r = n, o = O(
179
+ const t = n, o = P(
167
180
  "vuiless"
168
- ), t = i(
169
- () => ({
170
- v: o.value.formData[r.field],
171
- data: o == null ? void 0 : o.value.formData,
172
- context: o == null ? void 0 : o.value.formContext,
173
- entry: r
174
- })
175
- ), m = i(() => C(r.label, t.value)), d = i(() => C(r.description, t.value)), b = i(() => C(r.hint, t.value)), v = i(() => C(r.placeholder, t.value)), y = i(() => C(r.optional, t.value)), l = i(() => C(r.disabled, t.value)), c = i(() => C(r.hidden, t.value)), s = i(() => C(r.options, t.value)), a = i(() => {
176
- const u = S(r.classes, t.value);
177
- return typeof u == "string" ? {
178
- [u]: !0,
179
- disabled: l.value,
180
- // error: !validation.value.passed,
181
- required: !y.value
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
- ...u || {},
184
- disabled: l.value,
185
- // error: !validation.value.passed,
186
- required: !y.value
203
+ ...C || {},
204
+ disabled: d.value,
205
+ required: !a.value
187
206
  };
188
- }), e = i(
189
- () => S(r.styles, t.value)
190
- ), f = i(() => S(r.attrs, t.value)), g = i(() => {
191
- var u;
192
- return (u = r.validators) == null ? void 0 : u.map(
193
- (E) => (D, P, z) => E({
194
- v: D,
195
- data: P,
196
- context: z,
197
- entry: r
198
- })
199
- );
200
- });
201
- return (u, E) => (p(), B(x(ee), {
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: w((D) => [
207
- _(u.$slots, "default", {
208
- onBlur: D.onBlur,
209
- error: D.error,
210
- model: D.model,
211
- formData: x(o).formData,
212
- formContext: x(o).formContext,
213
- label: m.value,
214
- description: d.value,
215
- hint: b.value,
216
- placeholder: v.value,
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
- ...a.value,
219
- error: !!D.error
234
+ ...l.value,
235
+ error: !!n.error || !!h.error
220
236
  },
221
- styles: e.value,
222
- optional: y.value,
223
- disabled: l.value,
224
- hidden: c.value,
225
- type: u.type,
226
- altAction: u.altAction,
227
- component: u.component,
228
- vName: u.name,
229
- field: u.field,
230
- options: s.value,
231
- length: u.length,
232
- required: !y.value,
233
- autocomplete: u.autocomplete,
234
- attrs: f.value
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
- }), re = { key: 0 }, ae = { key: 1 }, ne = { key: 0 }, le = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type"], se = { class: "oo-error-slot" }, ue = { key: 4 }, ie = { key: 5 }, ce = ["disabled"], pe = /* @__PURE__ */ q({
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: r }) {
252
- const o = n, t = i(() => o.form.executable()), m = i(
253
- () => ({
254
- v: void 0,
255
- data: b.value,
256
- context: o.formContext,
257
- entry: o
258
- })
259
- ), d = k({}), b = i(() => o.formData || d.value), v = i(
260
- () => C(t.value.submit.disabled, m.value)
261
- ), y = r;
262
- return (l, c) => (p(), B(x(te), {
263
- "first-validation": l.firstValidation,
264
- onSubmit: c[0] || (c[0] = (s) => y("submit", s)),
265
- "form-data": b.value,
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: w((s) => [
269
- _(l.$slots, "form.header", {
270
- clearErrors: s.clearErrors,
271
- reset: s.reset,
272
- title: t.value.title,
273
- formContext: l.formContext,
274
- disabled: v.value
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
- t.value.title ? (p(), V("h2", re, h(t.value.title), 1)) : j("", !0)
292
+ v.value ? (x(), E("h2", pe, F(v.value), 1)) : H("", !0)
277
293
  ]),
278
- _(l.$slots, "form.before", {
279
- clearErrors: s.clearErrors,
280
- reset: s.reset
294
+ A(s.$slots, "form.before", {
295
+ clearErrors: l.clearErrors,
296
+ reset: l.reset
281
297
  }),
282
- (p(!0), V(K, null, Q(t.value.entries, (a) => (p(), B(oe, A(M(a)), {
283
- default: w((e) => [
284
- _(l.$slots, `field:${e.type}`, A(M(e)), () => {
285
- var f, g, u;
286
- return [
287
- a.component && ((f = o.components) != null && f[a.component]) ? (p(), B(F(o.components[a.component]), H({
288
- key: 0,
289
- "on-blur": e.onBlur,
290
- error: e.error,
291
- model: e.model,
292
- "form-data": e.formData,
293
- "form-context": e.formContext,
294
- label: e.label,
295
- description: e.description,
296
- hint: e.hint,
297
- placeholder: e.placeholder,
298
- class: e.classes,
299
- style: e.styles,
300
- optional: e.optional,
301
- required: !e.required,
302
- disabled: e.disabled,
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
- type: e.type
348
- }, null, 40, le), [
349
- [Z, e.model.value]
350
- ]),
351
- $("div", se, h(e.error || e.hint), 1)
352
- ], 2)) : e.type === "paragraph" ? (p(), V("p", ue, h(e.description), 1)) : (p(), V("div", ie, " [" + h(e.label) + '] Not supported field type "' + h(e.type) + '" ' + h(e.component), 1))
353
- ];
354
- })
355
- ]),
356
- _: 2
357
- }, 1040))), 256)),
358
- _(l.$slots, "form.after", {
359
- clearErrors: s.clearErrors,
360
- reset: s.reset,
361
- disabled: v.value,
362
- formContext: l.formContext
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
- _(l.$slots, "form.submit", {
365
- disabled: v.value,
366
- clearErrors: s.clearErrors,
367
- reset: s.reset,
368
- formContext: l.formContext
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
- $("button", { disabled: v.value }, h(t.value.submit.text), 9, ce)
402
+ M("button", { disabled: g.value }, F(f.value), 9, xe)
371
403
  ]),
372
- _(l.$slots, "form.footer", {
373
- disabled: v.value,
374
- clearErrors: s.clearErrors,
375
- reset: s.reset,
376
- formContext: l.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
- oe as OoField,
385
- pe as OoForm
615
+ de as OoField,
616
+ Ee as OoForm,
617
+ Be as useFoorm
386
618
  };