@appmax_npm/ds-prime 1.0.0-alpha.104 → 1.0.0-alpha.105

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/amform/index.d.ts CHANGED
@@ -1,15 +1,48 @@
1
- import { AllowedComponentProps, Component, DefineComponent, VNode } from 'vue';
1
+ import type { FormFieldState, FormSubmitEvent } from '@primevue/forms';
2
+ import type { DefineComponent, VNode } from 'vue';
2
3
  import type { ZodObject } from 'zod';
3
4
 
4
5
  export interface AmFormProps {
5
6
  schema: ZodObject;
7
+ debug?: boolean;
8
+ modelValue?: Record<string, unknown>;
6
9
  }
7
10
 
8
11
  export interface AmFormSlots {
9
- default: () => VNode[];
12
+ default: (
13
+ scope: {
14
+ /**
15
+ * Registers a form field for validation and tracking.
16
+ * @param field - The name of the form field to register.
17
+ * @param options - Configuration options for the field, such as validation rules.
18
+ * @returns - Returns an object or value representing the registered field.
19
+ */
20
+ register: (field: string, options: any) => any;
21
+ /**
22
+ * Resets the entire form state, clearing values and validation statuses.
23
+ */
24
+ reset: () => void;
25
+ /**
26
+ * Indicates whether the form is valid, returning `true` if all fields pass validation.
27
+ */
28
+ valid: boolean;
29
+ /**
30
+ * Each value from the form fields.
31
+ */
32
+ values: Record<string, unknown>;
33
+ } & {
34
+ /**
35
+ * Stores the state of each form field, with the field name as the key and its state as the value.
36
+ */
37
+ [key: string]: FormFieldState;
38
+ }
39
+ ) => VNode[];
10
40
  }
11
41
 
12
- export interface AmFormEmits {}
42
+ export interface AmFormEmits {
43
+ submit: (event: FormSubmitEvent) => void;
44
+ 'update:modelValue': (value: Record<string, unknown>) => void;
45
+ }
13
46
 
14
47
  /**
15
48
  * **DS Prime - AmForm**
package/amform/index.js CHANGED
@@ -1,40 +1,42 @@
1
- import { defineComponent as v, mergeModels as p, ref as n, useModel as _, computed as h, watch as f, nextTick as m, openBlock as k, createBlock as w, unref as c, withCtx as y, renderSlot as R, normalizeProps as V, guardReactiveProps as g } from "vue";
2
- import { Form as x } from "@primevue/forms";
1
+ import { defineComponent as p, mergeModels as g, ref as n, useModel as V, computed as b, watch as d, nextTick as f, openBlock as h, createBlock as y, unref as c, withCtx as k, renderSlot as x, normalizeProps as R, guardReactiveProps as w } from "vue";
2
+ import { Form as B } from "@primevue/forms";
3
3
  import { zodResolver as M } from "@primevue/forms/resolvers/zod";
4
- const b = { name: "AmForm" }, C = /* @__PURE__ */ v({
5
- ...b,
6
- props: /* @__PURE__ */ p({
7
- schema: {}
4
+ const _ = { name: "AmForm" }, F = /* @__PURE__ */ p({
5
+ ..._,
6
+ props: /* @__PURE__ */ g({
7
+ schema: {},
8
+ debug: { type: Boolean },
9
+ modelValue: {}
8
10
  }, {
9
11
  modelValue: { type: Object, default: () => ({}) },
10
12
  modelModifiers: {}
11
13
  }),
12
14
  emits: ["update:modelValue"],
13
- setup(s) {
14
- const d = M(s.schema), r = n(), l = _(s, "modelValue"), t = n(!1), i = h(() => {
15
- var o;
16
- const e = (o = r.value) == null ? void 0 : o.states;
17
- return e ? Object.keys(e).reduce((a, u) => (a[u] = e[u].value, a), {}) : {};
15
+ setup(l, { expose: m }) {
16
+ const i = M(l.schema), t = n(), o = V(l, "modelValue"), a = n(!1), v = b(() => {
17
+ var r;
18
+ const e = (r = t.value) == null ? void 0 : r.states;
19
+ return e ? Object.keys(e).reduce((u, s) => (u[s] = e[s].value, u), {}) : {};
18
20
  });
19
- return f(
20
- () => l.value,
21
+ return d(
22
+ () => o.value,
21
23
  async (e) => {
22
- !r.value || t.value || (t.value = !0, r.value.setValues(e), await m(), t.value = !1);
24
+ !t.value || a.value || (a.value = !0, t.value.setValues(e), l.debug && console.log("Values updated: down", e), await f(), a.value = !1);
23
25
  }
24
- ), f(i, async (e) => {
25
- t.value || (t.value = !0, l.value = e, await m(), t.value = !1);
26
- }), (e, o) => (k(), w(c(x), {
26
+ ), d(v, async (e) => {
27
+ a.value || (a.value = !0, o.value = e, l.debug && console.log("Values updated: up", e), await f(), a.value = !1);
28
+ }), m({ ...t.value, values: o }), (e, r) => (h(), y(c(B), {
27
29
  ref_key: "formRef",
28
- ref: r,
29
- resolver: c(d)
30
+ ref: t,
31
+ resolver: c(i)
30
32
  }, {
31
- default: y((a) => [
32
- R(e.$slots, "default", V(g(a)))
33
+ default: k((u) => [
34
+ x(e.$slots, "default", R(w({ ...u, values: o.value })))
33
35
  ]),
34
36
  _: 3
35
37
  }, 8, ["resolver"]));
36
38
  }
37
39
  });
38
40
  export {
39
- C as default
41
+ F as default
40
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appmax_npm/ds-prime",
3
- "version": "1.0.0-alpha.104",
3
+ "version": "1.0.0-alpha.105",
4
4
  "description": "Design System da Appmax baseado no Primevue",
5
5
  "author": "Appmax",
6
6
  "exports": {