@neovici/cosmoz-form 2.1.1 → 2.2.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/async-rule.d.ts +83 -0
- package/dist/async-rule.d.ts.map +1 -0
- package/dist/async-rule.js +20 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -5
- package/dist/make-debounce-runner.d.ts +4 -0
- package/dist/make-debounce-runner.d.ts.map +1 -0
- package/dist/make-debounce-runner.js +50 -0
- package/dist/make-take-latest-runner.d.ts +4 -0
- package/dist/make-take-latest-runner.d.ts.map +1 -0
- package/dist/make-take-latest-runner.js +27 -0
- package/dist/test/make-debounce-runner.test.d.ts +2 -0
- package/dist/test/make-debounce-runner.test.d.ts.map +1 -0
- package/dist/test/make-debounce-runner.test.js +123 -0
- package/dist/test/make-take-latest-runner.test.d.ts +2 -0
- package/dist/test/make-take-latest-runner.test.d.ts.map +1 -0
- package/dist/test/make-take-latest-runner.test.js +110 -0
- package/dist/test/use-async-form-core.test.d.ts +2 -0
- package/dist/test/use-async-form-core.test.d.ts.map +1 -0
- package/dist/test/use-async-form-core.test.js +238 -0
- package/dist/test/use-async-rules.test.d.ts +2 -0
- package/dist/test/use-async-rules.test.d.ts.map +1 -0
- package/dist/test/use-async-rules.test.js +180 -0
- package/dist/use-async-form-core.d.ts +21 -0
- package/dist/use-async-form-core.d.ts.map +1 -0
- package/dist/use-async-form-core.js +71 -0
- package/dist/use-items/use-async-rules.d.ts +17 -0
- package/dist/use-items/use-async-rules.d.ts.map +1 -0
- package/dist/use-items/use-async-rules.js +78 -0
- package/dist/use-items/use-items.d.ts.map +1 -1
- package/dist/use-items/use-items.js +2 -2
- package/dist/use-validated-form$.d.ts +4 -1
- package/dist/use-validated-form$.d.ts.map +1 -1
- package/dist/use-validated-form$.js +4 -1
- package/package.json +6 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ItemRule } from '.';
|
|
2
|
+
import type { AsyncItemRule } from './async-rule';
|
|
2
3
|
import type { Fields } from './types';
|
|
3
4
|
import { UseValidatedForm } from './use-validated-form';
|
|
4
5
|
export type ProgressValue = string | number;
|
|
@@ -7,17 +8,19 @@ export interface Props<T extends object> {
|
|
|
7
8
|
fields: Fields<T>;
|
|
8
9
|
initial: T;
|
|
9
10
|
rules?: ItemRule<T>[];
|
|
11
|
+
asyncRules?: readonly AsyncItemRule<T>[];
|
|
10
12
|
onSave?: (values: T, initial: T, setProgress?: (p: Progress) => void) => PromiseLike<unknown>;
|
|
11
13
|
allowEmpty?: boolean;
|
|
12
14
|
}
|
|
13
15
|
interface Opts {
|
|
14
16
|
disabled: boolean;
|
|
17
|
+
processing: boolean;
|
|
15
18
|
progress?: Progress;
|
|
16
19
|
save$?: PromiseLike<unknown>;
|
|
17
20
|
onSave: () => void;
|
|
18
21
|
}
|
|
19
22
|
export interface UseValidatedForm$<T extends object> extends UseValidatedForm<T>, Opts {
|
|
20
23
|
}
|
|
21
|
-
declare function useValidatedForm$<T extends object>({ fields, initial, rules, onSave, allowEmpty, }: Props<T>): UseValidatedForm$<T>;
|
|
24
|
+
declare function useValidatedForm$<T extends object>({ fields, initial, rules, asyncRules, onSave, allowEmpty, }: Props<T>): UseValidatedForm$<T>;
|
|
22
25
|
export { useValidatedForm$ };
|
|
23
26
|
//# sourceMappingURL=use-validated-form$.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-validated-form$.d.ts","sourceRoot":"","sources":["../src/use-validated-form$.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"use-validated-form$.d.ts","sourceRoot":"","sources":["../src/use-validated-form$.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAC7B,OAAO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AC,CAAC,CAAC,CAqBjC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useCallback, useState } from '@pionjs/pion';
|
|
2
|
+
import { useAsyncFormCore } from './use-async-form-core';
|
|
2
3
|
import { useValidatedForm } from './use-validated-form';
|
|
3
|
-
function useValidatedForm$({ fields, initial, rules, onSave, allowEmpty, }) {
|
|
4
|
+
function useValidatedForm$({ fields, initial, rules, asyncRules, onSave, allowEmpty, }) {
|
|
4
5
|
const form = useValidatedForm({ fields, initial, rules });
|
|
6
|
+
const { processing } = useAsyncFormCore(form, asyncRules);
|
|
5
7
|
const { values, invalid } = form;
|
|
6
8
|
const [save$, setSave$] = useState();
|
|
7
9
|
const [progress, setProgress] = useState();
|
|
@@ -12,6 +14,7 @@ function useValidatedForm$({ fields, initial, rules, onSave, allowEmpty, }) {
|
|
|
12
14
|
save$,
|
|
13
15
|
onSave: useCallback(() => setSave$(onSave?.(values, initial, setProgress)), [onSave, values, initial]),
|
|
14
16
|
disabled,
|
|
17
|
+
processing,
|
|
15
18
|
progress,
|
|
16
19
|
};
|
|
17
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-form",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A pionjs component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components",
|
|
@@ -76,20 +76,21 @@
|
|
|
76
76
|
"@commitlint/cli": "^20.0.0",
|
|
77
77
|
"@commitlint/config-conventional": "^20.0.0",
|
|
78
78
|
"@neovici/cfg": "^2.8.0",
|
|
79
|
-
"lint-staged": "^15.4.3",
|
|
80
79
|
"@neovici/testing": "^2.0.0",
|
|
81
80
|
"@open-wc/testing": "^4.0.0",
|
|
82
81
|
"@open-wc/testing-helpers": "^3.0.1",
|
|
83
82
|
"@semantic-release/changelog": "^6.0.0",
|
|
84
83
|
"@semantic-release/git": "^10.0.0",
|
|
85
|
-
"@storybook/addon-
|
|
86
|
-
"@storybook/
|
|
87
|
-
"@storybook/web-components
|
|
84
|
+
"@storybook/addon-docs": "^10.2.17",
|
|
85
|
+
"@storybook/addon-links": "^10.2.17",
|
|
86
|
+
"@storybook/web-components": "^10.2.17",
|
|
87
|
+
"@storybook/web-components-vite": "^10.2.17",
|
|
88
88
|
"@types/mocha": "^10.0.0",
|
|
89
89
|
"@types/node": "^24.0.0",
|
|
90
90
|
"esbuild": "^0.27.0",
|
|
91
91
|
"http-server": "^14.1.1",
|
|
92
92
|
"husky": "^9.0.11",
|
|
93
|
+
"lint-staged": "^15.4.3",
|
|
93
94
|
"semantic-release": "^25.0.0",
|
|
94
95
|
"sinon": "^19.0.0",
|
|
95
96
|
"storybook": "^10.0.0"
|