@foormjs/vue 0.1.0 → 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,42 +1,45 @@
1
- import { defineComponent as U, mergeModels as F, useModel as T, inject as z, ref as k, computed as p, watch as I, onUnmounted as L, getCurrentInstance as O, renderSlot as D, unref as n, provide as R, openBlock as b, createElementBlock as E, withModifiers as W, nextTick as G, createBlock as B, withCtx as M, toDisplayString as g, createCommentVNode as H, Fragment as J, renderList as K, mergeProps as N, normalizeProps as Q, guardReactiveProps as X, resolveDynamicComponent as P, normalizeClass as Y, createElementVNode as w, withDirectives as Z, vModelDynamic as ee } from "vue";
2
- function $(i, o, t) {
3
- if (typeof i == "function") {
4
- if (i.__deserialized)
5
- return i(o);
6
- {
7
- const r = t ? [o.v, o.data, o.context, o.entry] : [o.data, o.context, o.entry];
8
- return i(...r);
9
- }
10
- }
11
- return i;
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;
12
7
  }
13
- function j(i, o) {
14
- if (typeof i == "object" && i !== null) {
15
- const t = {};
16
- for (const [r, l] of Object.entries(i))
17
- t[r] = $(l, o, !0);
18
- return t;
19
- }
20
- return $(i, o, !0);
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);
17
+ }
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;
21
24
  }
22
- const te = /* @__PURE__ */ U({
25
+ const ce = /* @__PURE__ */ T({
23
26
  __name: "VuilessField",
24
- props: /* @__PURE__ */ F({
27
+ props: /* @__PURE__ */ J({
25
28
  rules: {}
26
29
  }, {
27
30
  modelValue: {},
28
31
  modelModifiers: {}
29
32
  }),
30
33
  emits: ["update:modelValue"],
31
- setup(i) {
32
- const o = i, t = T(i, "modelValue"), r = z("vuiless"), l = k(), h = k(!1), v = k(!1), _ = p(() => {
34
+ setup(n) {
35
+ const t = n, o = R(n, "modelValue"), r = P("vuiless"), a = w(), d = w(!1), v = w(!1), f = m(() => {
33
36
  var c;
34
37
  if ((c = r == null ? void 0 : r.value) != null && c.firstValidation)
35
38
  switch (r.value.firstValidation) {
36
39
  case "on-change":
37
- return r.value.firstSubmitHappened || h.value;
40
+ return r.value.firstSubmitHappened || d.value;
38
41
  case "touched-on-blur":
39
- return r.value.firstSubmitHappened || v.value && h.value;
42
+ return r.value.firstSubmitHappened || v.value && d.value;
40
43
  case "on-blur":
41
44
  return r.value.firstSubmitHappened || v.value;
42
45
  case "on-submit":
@@ -45,58 +48,58 @@ const te = /* @__PURE__ */ U({
45
48
  return !1;
46
49
  }
47
50
  return !1;
48
- }), y = p(() => {
49
- if (_.value || l.value)
50
- return f();
51
+ }), g = m(() => {
52
+ if (f.value || a.value)
53
+ return V();
51
54
  });
52
- I([t], () => {
53
- l.value = void 0, h.value = !0;
54
- }), L(() => {
55
+ W([o], () => {
56
+ a.value = void 0, d.value = !0;
57
+ }), Y(() => {
55
58
  var c;
56
- (c = r == null ? void 0 : r.value) == null || c.unregister(O());
57
- }), r != null && r.value && r.value.register(O(), {
58
- validate: () => (l.value = f(), l.value || !0),
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),
59
62
  clearErrors: () => {
60
- h.value = !1, v.value = !1, l.value = void 0;
63
+ d.value = !1, v.value = !1, a.value = void 0;
61
64
  },
62
65
  reset: () => {
63
- t.value = "";
66
+ o.value = "";
64
67
  }
65
68
  });
66
- function f() {
67
- var c, a, x;
68
- if ((c = o.rules) != null && c.length)
69
- for (const m of o.rules) {
70
- const d = m(
71
- t.value,
72
- (a = r == null ? void 0 : r.value) == null ? void 0 : a.formData,
73
- (x = r == null ? void 0 : r.value) == null ? void 0 : x.formContext
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(
74
+ o.value,
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
74
77
  );
75
- if (d !== !0)
76
- return d || "Wrong value";
78
+ if (e !== !0)
79
+ return e || "Wrong value";
77
80
  }
78
81
  }
79
- function u() {
82
+ function i() {
80
83
  v.value = !0;
81
84
  }
82
- const C = {
83
- v: p({
84
- get: () => t.value,
85
- set: (c) => t.value = c
85
+ const s = {
86
+ v: m({
87
+ get: () => o.value,
88
+ set: (c) => o.value = c
86
89
  })
87
90
  };
88
- return (c, a) => {
89
- var x, m;
90
- return D(c.$slots, "default", {
91
- onBlur: u,
92
- error: y.value,
93
- formData: (x = n(r)) == null ? void 0 : x.formData,
94
- formContext: (m = n(r)) == null ? void 0 : m.formContext,
95
- model: C.v
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,
98
+ model: s.v
96
99
  });
97
100
  };
98
101
  }
99
- }), oe = /* @__PURE__ */ U({
102
+ }), me = /* @__PURE__ */ T({
100
103
  __name: "VuilessForm",
101
104
  props: {
102
105
  formData: {},
@@ -104,152 +107,153 @@ const te = /* @__PURE__ */ U({
104
107
  firstValidation: { default: "on-change" }
105
108
  },
106
109
  emits: ["submit"],
107
- setup(i, { emit: o }) {
108
- const t = i, r = o, l = /* @__PURE__ */ new Map(), h = k(!1), v = p(() => ({
109
- firstSubmitHappened: h.value,
110
- firstValidation: t.firstValidation,
111
- register: (u, C) => {
112
- l.set(u, C);
110
+ setup(n, { emit: t }) {
111
+ const o = n, r = t, a = /* @__PURE__ */ new Map(), d = w(!1), v = m(() => ({
112
+ firstSubmitHappened: d.value,
113
+ firstValidation: o.firstValidation,
114
+ register: (i, s) => {
115
+ a.set(i, s);
113
116
  },
114
- unregister: (u) => l.delete(u),
115
- formData: t.formData,
116
- formContext: t.formContext
117
+ unregister: (i) => a.delete(i),
118
+ formData: o.formData,
119
+ formContext: o.formContext
117
120
  }));
118
- R("vuiless", v);
119
- function _() {
120
- h.value = !1;
121
- for (const { clearErrors: u } of l.values())
122
- u();
121
+ K("vuiless", v);
122
+ function f() {
123
+ d.value = !1;
124
+ for (const { clearErrors: i } of a.values())
125
+ i();
123
126
  }
124
- async function y() {
125
- for (const { reset: u } of l.values())
126
- u();
127
- await G(), _();
127
+ async function g() {
128
+ for (const { reset: i } of a.values())
129
+ i();
130
+ await ee(), f();
128
131
  }
129
- function f() {
130
- h.value = !0;
131
- let u = !1;
132
- if (t.firstValidation !== "none")
133
- for (const { validate: C } of l.values())
134
- C() !== !0 && (u = !0);
135
- u || r("submit", t.formData);
132
+ function V() {
133
+ d.value = !0;
134
+ let i = !1;
135
+ if (o.firstValidation !== "none")
136
+ for (const { validate: s } of a.values())
137
+ s() !== !0 && (i = !0);
138
+ i || r("submit", o.formData);
136
139
  }
137
- return (u, C) => (b(), E("form", {
138
- onSubmit: W(f, ["prevent"])
140
+ return (i, s) => (x(), E("form", {
141
+ onSubmit: Z(V, ["prevent"])
139
142
  }, [
140
- D(u.$slots, "default", {
141
- clearErrors: _,
142
- reset: y
143
+ A(i.$slots, "default", {
144
+ clearErrors: f,
145
+ reset: g
143
146
  })
144
147
  ], 32));
145
148
  }
146
- }), re = /* @__PURE__ */ U({
149
+ }), de = /* @__PURE__ */ T({
147
150
  __name: "oo-field",
148
151
  props: {
149
152
  field: {},
150
- altAction: {},
151
- label: {},
152
- description: {},
153
- hint: {},
154
- placeholder: {},
155
- classes: {},
156
- styles: {},
157
153
  type: {},
158
154
  component: {},
159
155
  autocomplete: {},
156
+ altAction: {},
157
+ order: {},
160
158
  name: {},
161
- value: {},
162
- 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] },
163
169
  attrs: {},
164
- optional: {},
165
- disabled: {},
166
- hidden: {},
167
- length: {},
170
+ value: {},
168
171
  validators: {},
172
+ maxLength: {},
173
+ minLength: {},
174
+ min: {},
175
+ max: {},
169
176
  error: {}
170
177
  },
171
- setup(i) {
172
- const o = i, t = z(
178
+ setup(n) {
179
+ const t = n, o = P(
173
180
  "vuiless"
174
- ), r = p(
175
- () => ({
176
- v: t.value.formData[o.field],
177
- data: t == null ? void 0 : t.value.formData,
178
- context: t == null ? void 0 : t.value.formContext,
179
- entry: o
180
- })
181
- );
182
- function l(s) {
183
- return typeof s == "function" ? p(() => $(s, r.value, !0)) : k(s);
184
- }
185
- const h = l(o.label), v = l(o.description), _ = l(o.hint), y = l(o.placeholder), f = l(o.optional), u = l(o.disabled), C = l(o.hidden), c = l(o.options), a = p(() => {
186
- const s = j(o.classes, r.value);
187
- return typeof s == "string" ? {
188
- [s]: !0,
189
- disabled: u.value,
190
- required: !f.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
191
202
  } : {
192
- ...s || {},
193
- disabled: u.value,
194
- required: !f.value
203
+ ...C || {},
204
+ disabled: d.value,
205
+ required: !a.value
195
206
  };
196
- }), x = p(
197
- () => j(o.styles, r.value)
198
- ), m = p(() => j(o.attrs, r.value)), d = p(() => {
199
- var s;
200
- return (s = o.validators) == null ? void 0 : s.map(
201
- (e) => (V, q, S) => $(
202
- e,
203
- {
204
- v: V,
205
- data: q,
206
- context: S,
207
- entry: o
208
- },
209
- !0
210
- )
211
- );
212
- });
213
- return (s, e) => (b(), B(n(te), {
214
- modelValue: n(t).formData[o.field],
215
- "onUpdate:modelValue": e[0] || (e[0] = (V) => n(t).formData[o.field] = V),
216
- rules: d.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
217
221
  }, {
218
- default: M((V) => [
219
- D(s.$slots, "default", {
220
- onBlur: V.onBlur,
221
- error: s.error || V.error,
222
- model: V.model,
223
- formData: n(t).formData,
224
- formContext: n(t).formContext,
225
- label: n(h),
226
- description: n(v),
227
- hint: n(_),
228
- placeholder: n(y),
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,
229
233
  classes: {
230
- ...a.value,
231
- error: !!s.error || !!V.error
234
+ ...l.value,
235
+ error: !!n.error || !!h.error
232
236
  },
233
- styles: x.value,
234
- optional: n(f),
235
- disabled: n(u),
236
- hidden: n(C),
237
- type: s.type,
238
- altAction: s.altAction,
239
- component: s.component,
240
- vName: s.name,
241
- field: s.field,
242
- options: n(c),
243
- length: s.length,
244
- required: !n(f),
245
- autocomplete: s.autocomplete,
246
- attrs: m.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
247
251
  })
248
252
  ]),
249
253
  _: 3
250
254
  }, 8, ["modelValue", "rules"]));
251
255
  }
252
- }), ae = { key: 0 }, ne = { key: 1 }, le = { key: 0 }, se = ["onUpdate:modelValue", "onBlur", "placeholder", "autocomplete", "name", "type"], ue = { class: "oo-error-slot" }, ie = { key: 4 }, me = { key: 5 }, ce = ["disabled"], pe = /* @__PURE__ */ U({
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({
253
257
  __name: "oo-form",
254
258
  props: {
255
259
  form: {},
@@ -261,53 +265,48 @@ const te = /* @__PURE__ */ U({
261
265
  errors: {}
262
266
  },
263
267
  emits: ["submit", "action", "unsupported-action"],
264
- setup(i, { emit: o }) {
265
- const t = i, r = p(() => t.form.executable()), l = p(
266
- () => ({
267
- v: void 0,
268
- data: v.value,
269
- context: t.formContext,
270
- entry: t
271
- })
272
- ), h = k({}), v = p(() => t.formData || h.value);
273
- function _(a) {
274
- return typeof a == "function" ? p(() => $(a, l.value)) : k(a);
275
- }
276
- const y = _(r.value.submit.disabled), f = _(r.value.submit.text), u = _(r.value.title);
277
- function C(a) {
278
- t.form.supportsAltAction(a) ? c("action", a, v.value) : c("unsupported-action", a, v.value);
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);
279
276
  }
280
- const c = o;
281
- return (a, x) => (b(), B(n(oe), {
282
- "first-validation": a.firstValidation,
283
- onSubmit: x[0] || (x[0] = (m) => c("submit", m)),
284
- "form-data": v.value,
285
- "form-context": a.formContext
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
286
283
  }, {
287
- default: M((m) => [
288
- D(a.$slots, "form.header", {
289
- clearErrors: m.clearErrors,
290
- reset: m.reset,
291
- title: n(u),
292
- formContext: a.formContext,
293
- disabled: n(y)
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
294
291
  }, () => [
295
- n(u) ? (b(), E("h2", ae, g(n(u)), 1)) : H("", !0)
292
+ v.value ? (x(), E("h2", pe, F(v.value), 1)) : H("", !0)
296
293
  ]),
297
- D(a.$slots, "form.before", {
298
- clearErrors: m.clearErrors,
299
- reset: m.reset
294
+ A(s.$slots, "form.before", {
295
+ clearErrors: l.clearErrors,
296
+ reset: l.reset
300
297
  }),
301
- (b(!0), E(J, null, K(r.value.entries, (d) => {
302
- var s;
303
- return b(), B(re, N(d, {
304
- error: (s = a.errors) == null ? void 0 : s[d.field]
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]
305
304
  }), {
306
- default: M((e) => [
307
- D(a.$slots, `field:${e.type}`, Q(X(e)), () => {
308
- var V, q, S;
305
+ default: O((e) => [
306
+ A(s.$slots, `field:${e.type}`, $({ ref_for: !0 }, e), () => {
307
+ var C, D, h;
309
308
  return [
310
- d.component && ((V = t.components) != null && V[d.component]) ? (b(), B(P(t.components[d.component]), N({
309
+ u.component && ((C = o.components) != null && C[u.component]) ? (x(), q(z(o.components[u.component]), $({
311
310
  key: 0,
312
311
  "on-blur": e.onBlur,
313
312
  error: e.error,
@@ -329,13 +328,13 @@ const te = /* @__PURE__ */ U({
329
328
  name: e.vName,
330
329
  field: e,
331
330
  options: e.options,
332
- length: e.length,
331
+ "max-length": e.maxLength,
333
332
  autocomplete: e.autocomplete,
334
- onAction: C
335
- }, e.attrs, {
333
+ onAction: V
334
+ }, { ref_for: !0 }, e.attrs, {
336
335
  modelValue: e.model.value,
337
- "onUpdate:modelValue": (A) => e.model.value = A
338
- }), 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", "modelValue", "onUpdate:modelValue"])) : d.component && !((q = t.components) != null && q[d.component]) ? (b(), E("div", ne, " [" + g(e.label) + '] Component "' + g(e.component) + '" not supplied ', 1)) : (S = t.types) != null && S[d.type] ? (b(), B(P(t.types[d.type]), N({
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]), $({
339
338
  key: 2,
340
339
  "on-blur": e.onBlur,
341
340
  error: e.error,
@@ -357,63 +356,263 @@ const te = /* @__PURE__ */ U({
357
356
  name: e.vName,
358
357
  field: e,
359
358
  options: e.options,
360
- length: e.length,
359
+ "max-length": e.maxLength,
361
360
  autocomplete: e.autocomplete,
362
- onAction: C
363
- }, e.attrs, {
361
+ onAction: V
362
+ }, { ref_for: !0 }, e.attrs, {
364
363
  modelValue: e.model.value,
365
- "onUpdate:modelValue": (A) => e.model.value = A
366
- }), 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", "modelValue", "onUpdate:modelValue"])) : ["text", "password", "number"].includes(e.type) ? (b(), E("div", {
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", {
367
366
  key: 3,
368
- class: Y(["oo-default-field", e.classes])
367
+ class: ne(["oo-default-field", e.classes])
369
368
  }, [
370
- w("label", null, g(e.label), 1),
371
- e.description ? (b(), E("span", le, g(e.description), 1)) : H("", !0),
372
- Z(w("input", {
373
- "onUpdate:modelValue": (A) => e.model.value = A,
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 = _,
374
373
  onBlur: e.onBlur,
375
374
  placeholder: e.placeholder,
376
375
  autocomplete: e.autocomplete,
377
376
  name: e.vName,
378
377
  type: e.type
379
- }, null, 40, se), [
380
- [ee, e.model.value]
378
+ }, null, 40, he), [
379
+ [re, e.model.value]
381
380
  ]),
382
- w("div", ue, g(e.error || e.hint), 1)
383
- ], 2)) : e.type === "paragraph" ? (b(), E("p", ie, g(e.description), 1)) : (b(), E("div", me, " [" + g(e.label) + '] Not supported field type "' + g(e.type) + '" ' + g(e.component), 1))
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))
384
383
  ];
385
384
  })
386
385
  ]),
387
386
  _: 2
388
387
  }, 1040, ["error"]);
389
- }), 256)),
390
- D(a.$slots, "form.after", {
391
- clearErrors: m.clearErrors,
392
- reset: m.reset,
393
- disabled: n(y),
394
- formContext: a.formContext
388
+ }), 128)),
389
+ A(s.$slots, "form.after", {
390
+ clearErrors: l.clearErrors,
391
+ reset: l.reset,
392
+ disabled: g.value,
393
+ formContext: n.formContext
395
394
  }),
396
- D(a.$slots, "form.submit", {
397
- disabled: n(y),
398
- text: n(f),
399
- clearErrors: m.clearErrors,
400
- reset: m.reset,
401
- formContext: a.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
402
401
  }, () => [
403
- w("button", { disabled: n(y) }, g(n(f)), 9, ce)
402
+ M("button", { disabled: g.value }, F(f.value), 9, xe)
404
403
  ]),
405
- D(a.$slots, "form.footer", {
406
- disabled: n(y),
407
- clearErrors: m.clearErrors,
408
- reset: m.reset,
409
- formContext: a.formContext
404
+ A(s.$slots, "form.footer", {
405
+ disabled: g.value,
406
+ clearErrors: l.clearErrors,
407
+ reset: l.reset,
408
+ formContext: n.formContext
410
409
  })
411
410
  ]),
412
411
  _: 3
413
412
  }, 8, ["first-validation", "form-data", "form-context"]));
414
413
  }
415
- });
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
+ }
416
614
  export {
417
- re as OoField,
418
- pe as OoForm
615
+ de as OoField,
616
+ Ee as OoForm,
617
+ Be as useFoorm
419
618
  };