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