@foormjs/vue 0.2.0 → 0.2.1

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