@formkit/zod 0.17.0-ce03a54 → 0.18.0-e33e50b

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.cjs CHANGED
@@ -63,10 +63,10 @@ function createZodPlugin(zodSchema, submitCallback) {
63
63
  start = now;
64
64
  performZodValidation(payload, node);
65
65
  }
66
- // also perform after 200ms of no commits
66
+ // also perform after 150ms of no commits
67
67
  commitTimout = setTimeout(() => {
68
68
  performZodValidation(payload, node);
69
- }, 200);
69
+ }, 150);
70
70
  });
71
71
  node.on('message-added', (message) => {
72
72
  if (message.payload.type === 'state' &&
@@ -79,29 +79,19 @@ function createZodPlugin(zodSchema, submitCallback) {
79
79
  return false;
80
80
  };
81
81
  function performZodValidation(payload, node) {
82
- // block submission while validation is running
83
- node.store.set(core.createMessage({
84
- type: 'state',
85
- blocking: true,
86
- visible: false,
87
- value: true,
88
- key: 'validating:zod',
89
- }));
90
82
  const zodResults = zodSchema.safeParse(payload);
91
83
  if (!zodResults.success) {
92
84
  setFormValidations(zodResults.error, node);
93
85
  }
94
86
  else {
95
87
  zodValidationSet.forEach((node) => {
96
- node.store.remove(`zod`);
88
+ node.store.remove(`${node.address.slice(1).join('.')}:zod`);
97
89
  const receipt = zodValidationListeners.get(node);
98
90
  node.off(receipt);
99
91
  zodValidationListeners.delete(node);
100
92
  });
101
93
  zodValidationSet.clear();
102
94
  }
103
- // unblock submission
104
- node.store.remove('validating:zod');
105
95
  }
106
96
  // The submit handler — validates the payload against the zod schema
107
97
  // and then passes the data to the user's submit callback.
package/dist/index.d.ts CHANGED
@@ -22,4 +22,13 @@ import { z } from 'zod';
22
22
  */
23
23
  export declare function createZodPlugin<Z extends z.ZodTypeAny>(zodSchema: Z, submitCallback: (payload: z.infer<typeof zodSchema>, node: FormKitNode | undefined) => void | Promise<void>): [FormKitPlugin, (payload: any, node: FormKitNode | undefined) => void];
24
24
 
25
- export { }
25
+
26
+ /**
27
+ * Extend FormKitNode with setZodErrors.
28
+ */
29
+ declare module '@formkit/core' {
30
+ interface FormKitNodeExtensions {
31
+ setZodErrors(zodError: z.ZodError | undefined): FormKitNode
32
+ }
33
+ }
34
+
package/dist/index.mjs CHANGED
@@ -59,10 +59,10 @@ function createZodPlugin(zodSchema, submitCallback) {
59
59
  start = now;
60
60
  performZodValidation(payload, node);
61
61
  }
62
- // also perform after 200ms of no commits
62
+ // also perform after 150ms of no commits
63
63
  commitTimout = setTimeout(() => {
64
64
  performZodValidation(payload, node);
65
- }, 200);
65
+ }, 150);
66
66
  });
67
67
  node.on('message-added', (message) => {
68
68
  if (message.payload.type === 'state' &&
@@ -75,29 +75,19 @@ function createZodPlugin(zodSchema, submitCallback) {
75
75
  return false;
76
76
  };
77
77
  function performZodValidation(payload, node) {
78
- // block submission while validation is running
79
- node.store.set(createMessage({
80
- type: 'state',
81
- blocking: true,
82
- visible: false,
83
- value: true,
84
- key: 'validating:zod',
85
- }));
86
78
  const zodResults = zodSchema.safeParse(payload);
87
79
  if (!zodResults.success) {
88
80
  setFormValidations(zodResults.error, node);
89
81
  }
90
82
  else {
91
83
  zodValidationSet.forEach((node) => {
92
- node.store.remove(`zod`);
84
+ node.store.remove(`${node.address.slice(1).join('.')}:zod`);
93
85
  const receipt = zodValidationListeners.get(node);
94
86
  node.off(receipt);
95
87
  zodValidationListeners.delete(node);
96
88
  });
97
89
  zodValidationSet.clear();
98
90
  }
99
- // unblock submission
100
- node.store.remove('validating:zod');
101
91
  }
102
92
  // The submit handler — validates the payload against the zod schema
103
93
  // and then passes the data to the user's submit callback.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formkit/zod",
3
- "version": "0.17.0-ce03a54",
3
+ "version": "0.18.0-e33e50b",
4
4
  "type": "module",
5
5
  "description": "Zod validation for FormKit.",
6
6
  "main": "dist/index.cjs",
@@ -34,7 +34,7 @@
34
34
  "test": "jest"
35
35
  },
36
36
  "dependencies": {
37
- "@formkit/core": "0.17.0-ce03a54"
37
+ "@formkit/core": "0.18.0-e33e50b"
38
38
  },
39
39
  "devDependencies": {},
40
40
  "peerDependencies": {