@idem.agency/form-builder 0.0.10 → 0.0.11
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/CHANGELOG.md +1 -33
- package/dist/index.cjs +325 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +86 -0
- package/dist/index.d.mts +86 -0
- package/dist/index.mjs +292 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +8 -4
- package/{index.html → public/index.html} +1 -2
- package/public/main.tsx +90 -0
- package/src/app/debug.tsx +0 -89
- package/src/app/index.tsx +51 -40
- package/src/{widgets/form → entity/inputs}/ui/group/index.tsx +4 -3
- package/src/{widgets/form → entity/inputs}/ui/input/index.tsx +5 -3
- package/src/index.ts +2 -2
- package/src/shared/lib/validation/core.ts +3 -3
- package/src/shared/lib/validation/rules/confirm.ts +2 -2
- package/src/shared/lib/validation/rules/email.ts +1 -1
- package/src/shared/lib/validation/rules/require.ts +1 -1
- package/src/shared/model/builder/createContext.tsx +40 -0
- package/src/shared/model/builder/index.ts +6 -0
- package/src/shared/model/index.ts +0 -1
- package/src/shared/model/store/createStoreContext.tsx +74 -0
- package/src/shared/model/store/index.ts +46 -0
- package/src/shared/model/store/store.ts +27 -0
- package/src/shared/types/common.ts +1 -1
- package/src/widgets/dynamicBuilder/element.tsx +31 -0
- package/src/widgets/dynamicBuilder/index.tsx +28 -58
- package/tsconfig.json +22 -5
- package/tsdown.config.ts +10 -0
- package/vite.config.ts +7 -16
- package/src/main.tsx +0 -9
- package/src/shared/model/store.tsx +0 -52
- package/tsconfig.app.json +0 -26
- package/tsconfig.node.json +0 -24
- package/vite-env.d.ts +0 -1
- /package/src/{widgets/form → entity/inputs}/index.ts +0 -0
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type {FormData} from "../types/common";
|
|
2
|
-
import {
|
|
3
|
-
type ActionDispatch,
|
|
4
|
-
createContext,
|
|
5
|
-
type SetStateAction,
|
|
6
|
-
useContext,
|
|
7
|
-
} from "react";
|
|
8
|
-
import {updateNestedValue} from "../utils";
|
|
9
|
-
|
|
10
|
-
const initState: {
|
|
11
|
-
formData: FormData
|
|
12
|
-
errors: Record<string, any>
|
|
13
|
-
} = {
|
|
14
|
-
formData: {},
|
|
15
|
-
errors: {}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const StoreContext = createContext<{
|
|
19
|
-
state: typeof initState;
|
|
20
|
-
dispatch: ActionDispatch<SetStateAction<any>>;
|
|
21
|
-
}>(null!);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export function storeReducer(state: any, action: SetStateAction<any>): any {
|
|
25
|
-
const newData = {...state};
|
|
26
|
-
|
|
27
|
-
switch (action.type){
|
|
28
|
-
case 'setValue':
|
|
29
|
-
newData.formData = updateNestedValue(newData.formData, action.payload.path, action.payload.value);
|
|
30
|
-
break;
|
|
31
|
-
case 'setError':
|
|
32
|
-
newData.errors = updateNestedValue(newData.errors, action.payload.path, action.payload.value);
|
|
33
|
-
break;
|
|
34
|
-
case 'reset':
|
|
35
|
-
newData.formData = {};
|
|
36
|
-
newData.errors = {};
|
|
37
|
-
break;
|
|
38
|
-
case 'setErrors':
|
|
39
|
-
newData.errors = {...action.payload.errors};
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return newData;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const useStore = () => {
|
|
47
|
-
const context = useContext(StoreContext);
|
|
48
|
-
if (context === undefined) {
|
|
49
|
-
throw new Error('useStore must be used within a StoreProvider');
|
|
50
|
-
}
|
|
51
|
-
return context;
|
|
52
|
-
};
|
package/tsconfig.app.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"verbatimModuleSyntax": true,
|
|
13
|
-
"moduleDetection": "force",
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "react-jsx",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"erasableSyntaxOnly": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noUncheckedSideEffectImports": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["src"]
|
|
26
|
-
}
|
package/tsconfig.node.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2023",
|
|
4
|
-
"lib": ["ES2023"],
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"skipLibCheck": true,
|
|
7
|
-
|
|
8
|
-
/* Bundler mode */
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"allowImportingTsExtensions": true,
|
|
11
|
-
"verbatimModuleSyntax": true,
|
|
12
|
-
"moduleDetection": "force",
|
|
13
|
-
"noEmit": true,
|
|
14
|
-
|
|
15
|
-
/* Linting */
|
|
16
|
-
"strict": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noUnusedParameters": true,
|
|
19
|
-
"erasableSyntaxOnly": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"noUncheckedSideEffectImports": true
|
|
22
|
-
},
|
|
23
|
-
"include": ["vite.config.ts"]
|
|
24
|
-
}
|
package/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
File without changes
|