@foormjs/vue 0.0.2 → 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,13 +67,16 @@ export declare const OoField: <TFormData, TFormContext>(__VLS_props: any, __VLS_
64
67
  emit: any;
65
68
  }>) => any;
66
69
 
67
- export declare const OoFoorm: <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>> & {
71
74
  "form.header"?(_: {
72
75
  clearErrors: any;
73
76
  reset: any;
77
+ title: any;
78
+ formContext: any;
79
+ disabled: any;
74
80
  }): any;
75
81
  "form.before"?(_: {
76
82
  clearErrors: any;
@@ -79,15 +85,21 @@ export declare const OoFoorm: <TFormData extends object, TFormContext extends ob
79
85
  "form.after"?(_: {
80
86
  clearErrors: any;
81
87
  reset: any;
88
+ disabled: any;
89
+ formContext: any;
82
90
  }): any;
83
91
  "form.submit"?(_: {
84
92
  disabled: any;
93
+ text: any;
85
94
  clearErrors: any;
86
95
  reset: any;
96
+ formContext: any;
87
97
  }): any;
88
98
  "form.footer"?(_: {
99
+ disabled: any;
89
100
  clearErrors: any;
90
101
  reset: any;
102
+ formContext: any;
91
103
  }): any;
92
104
  };
93
105
  }, __VLS_expose?: (exposed: any) => void, __VLS_setup?: Promise<{
@@ -98,6 +110,9 @@ export declare const OoFoorm: <TFormData extends object, TFormContext extends ob
98
110
  "form.header"?(_: {
99
111
  clearErrors: any;
100
112
  reset: any;
113
+ title: any;
114
+ formContext: any;
115
+ disabled: any;
101
116
  }): any;
102
117
  "form.before"?(_: {
103
118
  clearErrors: any;
@@ -106,25 +121,31 @@ export declare const OoFoorm: <TFormData extends object, TFormContext extends ob
106
121
  "form.after"?(_: {
107
122
  clearErrors: any;
108
123
  reset: any;
124
+ disabled: any;
125
+ formContext: any;
109
126
  }): any;
110
127
  "form.submit"?(_: {
111
128
  disabled: any;
129
+ text: any;
112
130
  clearErrors: any;
113
131
  reset: any;
132
+ formContext: any;
114
133
  }): any;
115
134
  "form.footer"?(_: {
135
+ disabled: any;
116
136
  clearErrors: any;
117
137
  reset: any;
138
+ formContext: any;
118
139
  }): any;
119
140
  };
120
141
  emit: any;
121
142
  }>) => any;
122
143
 
123
- export declare interface TFoormComponentProps<T, TFormData, TFormContext> {
144
+ export declare interface TFoormComponentProps<V, TFormData, TFormContext> {
124
145
  onBlur: Function;
125
146
  error?: string;
126
147
  model: {
127
- value: T;
148
+ value: V;
128
149
  };
129
150
  formData: TFormData;
130
151
  formContext?: TFormContext;
@@ -132,16 +153,16 @@ export declare interface TFoormComponentProps<T, TFormData, TFormContext> {
132
153
  description?: string;
133
154
  hint?: string;
134
155
  placeholder?: string;
135
- class?: Record<string, boolean>;
136
- style?: Record<string, string>;
137
- optional: boolean;
138
- required: boolean;
139
- disabled?: boolean;
140
- 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;
141
162
  type: string;
142
163
  altAction?: string;
143
164
  name?: string;
144
- field?: string;
165
+ field?: TFoormEntry<V, TFormData, TFormContext, TFoormEntryOptions>;
145
166
  options?: unknown[];
146
167
  length?: number;
147
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 u, watch as R, onUnmounted as T, getCurrentInstance as N, renderSlot as D, unref as x, provide as W, openBlock as m, createElementBlock as C, withModifiers as G, nextTick as J, createBlock as B, withCtx as w, toDisplayString as b, 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 f(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, c] of Object.entries(n))
9
- o[t] = f(c, 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"), c = k(), d = k(!1), v = k(!1), _ = u(() => {
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 || v.value && d.value;
39
+ return r.value.firstSubmitHappened || v.value && h.value;
35
40
  case "on-blur":
36
- return t.value.firstSubmitHappened || v.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
- }), h = u(() => {
44
- if (_.value || c.value)
45
- return p();
48
+ }), y = p(() => {
49
+ if (_.value || l.value)
50
+ return f();
46
51
  });
47
- R([o], () => {
48
- c.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: () => (c.value = p(), c.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, v.value = !1, c.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 p() {
62
- var a, e, y;
63
- if ((a = r.rules) != null && a.length)
64
- for (const g of r.rules) {
65
- const s = g(
66
- o.value,
67
- (e = t == null ? void 0 : t.value) == null ? void 0 : e.formData,
68
- (y = t == null ? void 0 : t.value) == null ? void 0 : y.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 (s !== !0)
71
- return s || "Wrong value";
75
+ if (d !== !0)
76
+ return d || "Wrong value";
72
77
  }
73
78
  }
74
- function i() {
79
+ function u() {
75
80
  v.value = !0;
76
81
  }
77
- const l = {
78
- v: u({
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 y, g;
85
- return D(a.$slots, "default", {
86
- onBlur: i,
87
- error: h.value,
88
- formData: (y = x(t)) == null ? void 0 : y.formData,
89
- formContext: (g = x(t)) == null ? void 0 : g.formContext,
90
- model: l.v
88
+ return (c, a) => {
89
+ var x, m;
90
+ return D(c.$slots, "default", {
91
+ onBlur: u,
92
+ error: y.value,
93
+ formData: (x = n(r)) == null ? void 0 : x.formData,
94
+ formContext: (m = n(r)) == null ? void 0 : m.formContext,
95
+ model: C.v
91
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, c = /* @__PURE__ */ new Map(), d = k(!1), v = u(() => ({
104
- firstSubmitHappened: d.value,
105
- firstValidation: o.firstValidation,
106
- register: (i, l) => {
107
- c.set(i, l);
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: (i) => c.delete(i),
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", v);
118
+ R("vuiless", v);
114
119
  function _() {
115
- d.value = !1;
116
- for (const { clearErrors: i } of c.values())
117
- i();
120
+ h.value = !1;
121
+ for (const { clearErrors: u } of l.values())
122
+ u();
118
123
  }
119
- async function h() {
120
- for (const { reset: i } of c.values())
121
- i();
122
- await J(), _();
124
+ async function y() {
125
+ for (const { reset: u } of l.values())
126
+ u();
127
+ await G(), _();
123
128
  }
124
- function p() {
125
- d.value = !0;
126
- let i = !1;
127
- if (o.firstValidation !== "none")
128
- for (const { validate: l } of c.values())
129
- l() !== !0 && (i = !0);
130
- i || 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 (i, l) => (m(), C("form", {
133
- onSubmit: G(p, ["prevent"])
137
+ return (u, C) => (b(), E("form", {
138
+ onSubmit: W(f, ["prevent"])
134
139
  }, [
135
- D(i.$slots, "default", {
140
+ D(u.$slots, "default", {
136
141
  clearErrors: _,
137
- reset: h
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 = u(
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
- ), c = u(() => f(r.label, t.value)), d = u(() => f(r.description, t.value)), v = u(() => f(r.hint, t.value)), _ = u(() => f(r.placeholder, t.value)), h = u(() => f(r.optional, t.value)), p = u(() => f(r.disabled, t.value)), i = u(() => f(r.hidden, t.value)), l = u(() => f(r.options, t.value)), a = u(() => {
176
- const s = S(r.classes, t.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);
177
187
  return typeof s == "string" ? {
178
188
  [s]: !0,
179
- disabled: p.value,
180
- // error: !validation.value.passed,
181
- required: !h.value
189
+ disabled: u.value,
190
+ required: !f.value
182
191
  } : {
183
192
  ...s || {},
184
- disabled: p.value,
185
- // error: !validation.value.passed,
186
- required: !h.value
193
+ disabled: u.value,
194
+ required: !f.value
187
195
  };
188
- }), e = u(
189
- () => S(r.styles, t.value)
190
- ), y = u(() => S(r.attrs, t.value)), g = u(() => {
196
+ }), x = p(
197
+ () => j(o.styles, r.value)
198
+ ), m = p(() => j(o.attrs, r.value)), d = p(() => {
191
199
  var s;
192
- return (s = r.validators) == null ? void 0 : s.map(
193
- (E) => (V, P, z) => E({
194
- v: V,
195
- data: P,
196
- context: z,
197
- entry: r
198
- })
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 (s, E) => (m(), B(x(ee), {
202
- modelValue: x(o).formData[r.field],
203
- "onUpdate:modelValue": E[0] || (E[0] = (V) => x(o).formData[r.field] = V),
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((V) => [
218
+ default: M((V) => [
207
219
  D(s.$slots, "default", {
208
220
  onBlur: V.onBlur,
209
- error: V.error,
221
+ error: s.error || V.error,
210
222
  model: V.model,
211
- formData: x(o).formData,
212
- formContext: x(o).formContext,
213
- label: c.value,
214
- description: d.value,
215
- hint: v.value,
216
- placeholder: _.value,
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: !!V.error
231
+ error: !!s.error || !!V.error
220
232
  },
221
- styles: e.value,
222
- optional: h.value,
223
- disabled: p.value,
224
- hidden: i.value,
233
+ styles: x.value,
234
+ optional: n(f),
235
+ disabled: n(u),
236
+ hidden: n(C),
225
237
  type: s.type,
226
238
  altAction: s.altAction,
227
239
  component: s.component,
228
240
  vName: s.name,
229
241
  field: s.field,
230
- options: l.value,
242
+ options: n(c),
231
243
  length: s.length,
232
- required: !h.value,
244
+ required: !n(f),
233
245
  autocomplete: s.autocomplete,
234
- attrs: y.value
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"], me = /* @__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,127 +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 = u(() => o.form.executable()), c = u(
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
268
  data: v.value,
256
- context: o.formContext,
257
- entry: o
269
+ context: t.formContext,
270
+ entry: t
258
271
  })
259
- ), d = k({}), v = u(() => o.formData || d.value), _ = u(
260
- () => f(t.value.submit.disabled, c.value)
261
- ), h = r;
262
- return (p, i) => (m(), B(x(te), {
263
- "first-validation": p.firstValidation,
264
- onSubmit: i[0] || (i[0] = (l) => h("submit", l)),
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)),
265
284
  "form-data": v.value,
266
- "form-context": p.formContext
285
+ "form-context": a.formContext
267
286
  }, {
268
- default: w((l) => [
269
- D(p.$slots, "form.header", {
270
- clearErrors: l.clearErrors,
271
- reset: l.reset
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)
272
294
  }, () => [
273
- t.value.title ? (m(), C("h2", re, b(t.value.title), 1)) : j("", !0)
295
+ n(u) ? (b(), E("h2", ae, g(n(u)), 1)) : H("", !0)
274
296
  ]),
275
- D(p.$slots, "form.before", {
276
- clearErrors: l.clearErrors,
277
- reset: l.reset
297
+ D(a.$slots, "form.before", {
298
+ clearErrors: m.clearErrors,
299
+ reset: m.reset
278
300
  }),
279
- (m(!0), C(K, null, Q(t.value.entries, (a) => (m(), B(oe, A(M(a)), {
280
- default: w((e) => [
281
- D(p.$slots, `field:${e.type}`, A(M(e)), () => {
282
- var y, g, s;
283
- return [
284
- a.component && ((y = o.components) != null && y[a.component]) ? (m(), B(F(o.components[a.component]), H({
285
- key: 0,
286
- "on-blur": e.onBlur,
287
- error: e.error,
288
- model: e.model,
289
- "form-data": e.formData,
290
- "form-context": e.formContext,
291
- label: e.label,
292
- description: e.description,
293
- hint: e.hint,
294
- placeholder: e.placeholder,
295
- class: e.classes,
296
- style: e.styles,
297
- optional: e.optional,
298
- required: !e.required,
299
- disabled: e.disabled,
300
- hidden: e.hidden,
301
- type: e.type,
302
- "alt-action": e.altAction,
303
- name: e.vName,
304
- field: e,
305
- options: e.options,
306
- length: e.length,
307
- autocomplete: e.autocomplete
308
- }, 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]) ? (m(), C("div", ae, " [" + b(e.label) + '] Component "' + b(e.component) + '" not supplied ', 1)) : (s = o.types) != null && s[a.type] ? (m(), B(F(o.types[a.type]), H({
309
- key: 2,
310
- "on-blur": e.onBlur,
311
- error: e.error,
312
- model: e.model,
313
- "form-data": e.formData,
314
- "form-context": e.formContext,
315
- label: e.label,
316
- description: e.description,
317
- hint: e.hint,
318
- placeholder: e.placeholder,
319
- class: e.classes,
320
- style: e.styles,
321
- optional: e.optional,
322
- required: !e.required,
323
- disabled: e.disabled,
324
- hidden: e.hidden,
325
- type: e.type,
326
- "alt-action": e.altAction,
327
- name: e.vName,
328
- field: e,
329
- options: e.options,
330
- length: e.length,
331
- autocomplete: e.autocomplete
332
- }, 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) ? (m(), C("div", {
333
- key: 3,
334
- class: X(["oo-default-field", e.classes])
335
- }, [
336
- $("label", null, b(e.label), 1),
337
- e.description ? (m(), C("span", ne, b(e.description), 1)) : j("", !0),
338
- Y($("input", {
339
- "onUpdate:modelValue": (E) => e.model.value = E,
340
- 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,
341
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,
342
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,
343
357
  name: e.vName,
344
- type: e.type
345
- }, null, 40, le), [
346
- [Z, e.model.value]
347
- ]),
348
- $("div", se, b(e.error || e.hint), 1)
349
- ], 2)) : e.type === "paragraph" ? (m(), C("p", ue, b(e.description), 1)) : (m(), C("div", ie, " [" + b(e.label) + '] Not supported field type "' + b(e.type) + '" ' + b(e.component), 1))
350
- ];
351
- })
352
- ]),
353
- _: 2
354
- }, 1040))), 256)),
355
- D(p.$slots, "form.after", {
356
- clearErrors: l.clearErrors,
357
- reset: l.reset
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
358
395
  }),
359
- D(p.$slots, "form.submit", {
360
- disabled: _.value,
361
- clearErrors: l.clearErrors,
362
- reset: l.reset
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
363
402
  }, () => [
364
- $("button", { disabled: _.value }, b(t.value.submit.text), 9, ce)
403
+ w("button", { disabled: n(y) }, g(n(f)), 9, ce)
365
404
  ]),
366
- D(p.$slots, "form.footer", {
367
- clearErrors: l.clearErrors,
368
- reset: l.reset
405
+ D(a.$slots, "form.footer", {
406
+ disabled: n(y),
407
+ clearErrors: m.clearErrors,
408
+ reset: m.reset,
409
+ formContext: a.formContext
369
410
  })
370
411
  ]),
371
412
  _: 3
@@ -373,6 +414,6 @@ const ee = /* @__PURE__ */ q({
373
414
  }
374
415
  });
375
416
  export {
376
- oe as OoField,
377
- me as OoFoorm
417
+ re as OoField,
418
+ pe as OoForm
378
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 f(l,n){return S(l)?l(n):l}function C(l,n){if(typeof l=="object"&&l!==null){const r={};for(const[o,p]of Object.entries(l))r[o]=f(p,n);return r}return S(l)?l(n):l}function S(l){return typeof l=="function"}const V=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"),p=e.ref(),d=e.ref(!1),u=e.ref(!1),h=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||u.value&&d.value;case"on-blur":return o.value.firstSubmitHappened||u.value;case"on-submit":return o.value.firstSubmitHappened;case"none":return!1}return!1}),y=e.computed(()=>{if(h.value||p.value)return m()});e.watch([r],()=>{p.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:()=>(p.value=m(),p.value||!0),clearErrors:()=>{d.value=!1,u.value=!1,p.value=void 0},reset:()=>{r.value=""}});function m(){var a,t,b;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,(b=o==null?void 0:o.value)==null?void 0:b.formContext);if(c!==!0)return c||"Wrong value"}}function i(){u.value=!0}const s={v:e.computed({get:()=>r.value,set:a=>r.value=a})};return(a,t)=>{var b,g;return e.renderSlot(a.$slots,"default",{onBlur:i,error:y.value,formData:(b=e.unref(o))==null?void 0:b.formData,formContext:(g=e.unref(o))==null?void 0:g.formContext,model:s.v})}}}),E=e.defineComponent({__name:"VuilessForm",props:{formData:{},formContext:{},firstValidation:{default:"on-change"}},emits:["submit"],setup(l,{emit:n}){const r=l,o=n,p=new Map,d=e.ref(!1),u=e.computed(()=>({firstSubmitHappened:d.value,firstValidation:r.firstValidation,register:(i,s)=>{p.set(i,s)},unregister:i=>p.delete(i),formData:r.formData,formContext:r.formContext}));e.provide("vuiless",u);function h(){d.value=!1;for(const{clearErrors:i}of p.values())i()}async function y(){for(const{reset:i}of p.values())i();await e.nextTick(),h()}function m(){d.value=!0;let i=!1;if(r.firstValidation!=="none")for(const{validate:s}of p.values())s()!==!0&&(i=!0);i||o("submit",r.formData)}return(i,s)=>(e.openBlock(),e.createElementBlock("form",{onSubmit:e.withModifiers(m,["prevent"])},[e.renderSlot(i.$slots,"default",{clearErrors:h,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:{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})),p=e.computed(()=>f(n.label,o.value)),d=e.computed(()=>f(n.description,o.value)),u=e.computed(()=>f(n.hint,o.value)),h=e.computed(()=>f(n.placeholder,o.value)),y=e.computed(()=>f(n.optional,o.value)),m=e.computed(()=>f(n.disabled,o.value)),i=e.computed(()=>f(n.hidden,o.value)),s=e.computed(()=>f(n.options,o.value)),a=e.computed(()=>{const c=C(n.classes,o.value);return typeof c=="string"?{[c]:!0,disabled:m.value,required:!y.value}:{...c||{},disabled:m.value,required:!y.value}}),t=e.computed(()=>C(n.styles,o.value)),b=e.computed(()=>C(n.attrs,o.value)),g=e.computed(()=>{var c;return(c=n.validators)==null?void 0:c.map(D=>(k,F,H)=>D({v:k,data:F,context:H,entry:n}))});return(c,D)=>(e.openBlock(),e.createBlock(e.unref(V),{modelValue:e.unref(r).formData[n.field],"onUpdate:modelValue":D[0]||(D[0]=k=>e.unref(r).formData[n.field]=k),rules:g.value},{default:e.withCtx(k=>[e.renderSlot(c.$slots,"default",{onBlur:k.onBlur,error:k.error,model:k.model,formData:e.unref(r).formData,formContext:e.unref(r).formContext,label:p.value,description:d.value,hint:u.value,placeholder:h.value,classes:{...a.value,error:!!k.error},styles:t.value,optional:y.value,disabled:m.value,hidden:i.value,type:c.type,altAction:c.altAction,component:c.component,vName:c.name,field:c.field,options:s.value,length:c.length,required:!y.value,autocomplete:c.autocomplete,attrs:b.value})]),_:3},8,["modelValue","rules"]))}}),x={key:0},N={key:1},$={key:0},q=["onUpdate:modelValue","onBlur","placeholder","autocomplete","name","type"],w={class:"oo-error-slot"},j={key:4},M={key:5},P=["disabled"],A=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()),p=e.computed(()=>({v:void 0,data:u.value,context:r.formContext,entry:r})),d=e.ref({}),u=e.computed(()=>r.formData||d.value),h=e.computed(()=>f(o.value.submit.disabled,p.value)),y=n;return(m,i)=>(e.openBlock(),e.createBlock(e.unref(E),{"first-validation":m.firstValidation,onSubmit:i[0]||(i[0]=s=>y("submit",s)),"form-data":u.value,"form-context":m.formContext},{default:e.withCtx(s=>[e.renderSlot(m.$slots,"form.header",{clearErrors:s.clearErrors,reset:s.reset},()=>[o.value.title?(e.openBlock(),e.createElementBlock("h2",x,e.toDisplayString(o.value.title),1)):e.createCommentVNode("",!0)]),e.renderSlot(m.$slots,"form.before",{clearErrors:s.clearErrors,reset:s.reset}),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value.entries,a=>(e.openBlock(),e.createBlock(_,e.normalizeProps(e.guardReactiveProps(a)),{default:e.withCtx(t=>[e.renderSlot(m.$slots,`field:${t.type}`,e.normalizeProps(e.guardReactiveProps(t)),()=>{var b,g,c;return[a.component&&((b=r.components)!=null&&b[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":D=>t.model.value=D,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",M," ["+e.toDisplayString(t.label)+'] Not supported field type "'+e.toDisplayString(t.type)+'" '+e.toDisplayString(t.component),1))]})]),_:2},1040))),256)),e.renderSlot(m.$slots,"form.after",{clearErrors:s.clearErrors,reset:s.reset}),e.renderSlot(m.$slots,"form.submit",{disabled:h.value,clearErrors:s.clearErrors,reset:s.reset},()=>[e.createElementVNode("button",{disabled:h.value},e.toDisplayString(o.value.submit.text),9,P)]),e.renderSlot(m.$slots,"form.footer",{clearErrors:s.clearErrors,reset:s.reset})]),_:3},8,["first-validation","form-data","form-context"]))}});B.OoField=_,B.OoFoorm=A,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.2",
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.2",
50
+ "foorm": "0.1.0",
51
51
  "vue": "^3.3.9",
52
52
  "vuiless-forms": "^0.0.3"
53
53
  },