@connect-soft/form-generator 1.0.0 → 1.1.0-alpha10

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.
Files changed (34) hide show
  1. package/README.md +956 -188
  2. package/dist/index.js +4400 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.mjs +4329 -0
  5. package/dist/index.mjs.map +1 -0
  6. package/dist/types/components/form/array-field-renderer.d.ts +39 -0
  7. package/dist/types/components/form/array-field-renderer.d.ts.map +1 -0
  8. package/dist/types/components/form/create-template-fields.d.ts +3 -0
  9. package/dist/types/components/form/create-template-fields.d.ts.map +1 -0
  10. package/dist/types/components/form/field-renderer.d.ts +7 -0
  11. package/dist/types/components/form/field-renderer.d.ts.map +1 -0
  12. package/dist/types/components/form/fields-context.d.ts +26 -0
  13. package/dist/types/components/form/fields-context.d.ts.map +1 -0
  14. package/dist/types/components/form/form-generator-typed.d.ts +47 -0
  15. package/dist/types/components/form/form-generator-typed.d.ts.map +1 -0
  16. package/dist/types/components/form/form-generator.d.ts +51 -0
  17. package/dist/types/components/form/form-generator.d.ts.map +1 -0
  18. package/dist/types/components/form/form-utils.d.ts +47 -0
  19. package/dist/types/components/form/form-utils.d.ts.map +1 -0
  20. package/dist/types/components/form/index.d.ts +7 -0
  21. package/dist/types/components/form/index.d.ts.map +1 -0
  22. package/dist/types/index.d.ts +22 -0
  23. package/dist/types/index.d.ts.map +1 -0
  24. package/dist/types/lib/field-registry.d.ts +74 -0
  25. package/dist/types/lib/field-registry.d.ts.map +1 -0
  26. package/dist/types/lib/field-types.d.ts +151 -0
  27. package/dist/types/lib/field-types.d.ts.map +1 -0
  28. package/dist/types/lib/index.d.ts +7 -0
  29. package/dist/types/lib/index.d.ts.map +1 -0
  30. package/dist/types/lib/template-types.d.ts +55 -0
  31. package/dist/types/lib/template-types.d.ts.map +1 -0
  32. package/dist/types/setupTests.d.ts +2 -0
  33. package/dist/types/setupTests.d.ts.map +1 -0
  34. package/package.json +40 -131
@@ -0,0 +1,55 @@
1
+ import type { FieldWrapperProps, FieldsWrapperProps } from './field-registry';
2
+ import type { ArrayField, BaseField } from './field-types';
3
+ import type { ComponentType, ReactElement } from 'react';
4
+ import type { FieldValues, UseFormReturn } from 'react-hook-form';
5
+ export interface FieldRenderOptions {
6
+ className?: string;
7
+ namePrefix?: string;
8
+ }
9
+ export interface TemplateFieldsUtils {
10
+ all: ReactElement[];
11
+ remaining: ReactElement[];
12
+ names: string[];
13
+ has(name: string): boolean;
14
+ render(...names: string[]): ReactElement[];
15
+ }
16
+ export type TemplateFields = TemplateFieldsUtils & {
17
+ [fieldName: string]: ReactElement;
18
+ };
19
+ export interface TemplateButtons {
20
+ submit: ReactElement;
21
+ reset?: ReactElement;
22
+ }
23
+ export interface TemplateArrayItem {
24
+ id: string;
25
+ index: number;
26
+ remove: () => void;
27
+ move: (toIndex: number) => void;
28
+ fields: Record<string, ReactElement>;
29
+ fieldNames: string[];
30
+ namePrefix: string;
31
+ }
32
+ export interface TemplateArrayField {
33
+ field: ArrayField;
34
+ }
35
+ export interface TemplateRenderProps<TValues extends FieldValues = FieldValues> {
36
+ fields: TemplateFields;
37
+ arrays: Record<string, TemplateArrayField>;
38
+ buttons: TemplateButtons;
39
+ title?: string;
40
+ description?: string;
41
+ form: UseFormReturn<TValues>;
42
+ isSubmitting: boolean;
43
+ isValid: boolean;
44
+ isDirty: boolean;
45
+ renderField: (field: BaseField, options?: FieldRenderOptions) => ReactElement;
46
+ FieldWrapper: ComponentType<FieldWrapperProps>;
47
+ FieldsWrapper: ComponentType<FieldsWrapperProps>;
48
+ }
49
+ export type TemplateRenderFn<TValues extends FieldValues = FieldValues> = (props: TemplateRenderProps<TValues>) => ReactElement | null;
50
+ export interface FieldEntry {
51
+ field: BaseField;
52
+ element: ReactElement;
53
+ accessed: boolean;
54
+ }
55
+ //# sourceMappingURL=template-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-types.d.ts","sourceRoot":"","sources":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W,kBAAkB;IAE/B,KAAK,EAAE,UAAU,CAAC;CACrB;AAKD,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW;IAE1E,MAAM,EAAE,cAAc,CAAC;IAGvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAG3C,OAAO,EAAE,eAAe,CAAC;IAGzB,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAG7B,YAAY,EAAE,OAAO,CAAC;IAGtB,OAAO,EAAE,OAAO,CAAC;IAGjB,OAAO,EAAE,OAAO,CAAC;IAGjB,WAAW,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,kBAAkB,KAAK,YAAY,CAAC;IAG9E,YAAY,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAG/C,aAAa,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CACpD;AAKD,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,IAAI,CACtE,KAAK,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAClC,YAAY,GAAG,IAAI,CAAC;AAKzB,MAAM,WAAW,UAAU;IAEvB,KAAK,EAAE,SAAS,CAAC;IAEjB,OAAO,EAAE,YAAY,CAAC;IAEtB,QAAQ,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=setupTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../../src/setupTests.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,18 +1,27 @@
1
1
  {
2
2
  "name": "@connect-soft/form-generator",
3
- "version": "1.0.0",
3
+ "version": "1.1.0-alpha10",
4
+ "description": "Headless, type-safe form generator with react-hook-form and Zod validation",
4
5
  "author": "Lukáš Černý <lukas.cerny@connect-soft.cz>",
5
- "description": "Type-safe form generator with Radix UI, Tailwind CSS, and react-hook-form",
6
6
  "license": "ISC",
7
7
  "main": "dist/index.js",
8
- "module": "dist/index.m.js",
9
- "unpkg": "dist/index.umd.js",
10
- "umd:main": "dist/index.umd.js",
8
+ "module": "dist/index.mjs",
9
+ "types": "dist/types/index.d.ts",
10
+ "sideEffects": false,
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
11
22
  "keywords": [
12
23
  "react",
13
- "radix-ui",
14
- "tailwind",
15
- "shadcn",
24
+ "headless",
16
25
  "form",
17
26
  "forms",
18
27
  "form-generator",
@@ -20,80 +29,27 @@
20
29
  "validation",
21
30
  "typescript",
22
31
  "react-hooks",
23
- "react-hook-form"
32
+ "react-hook-form",
33
+ "zod",
34
+ "type-safe"
24
35
  ],
25
- "source": "packages/form-generator/src/index.ts",
26
- "types": "dist/types/index.d.ts",
27
- "sideEffects": false,
28
- "exports": {
29
- ".": {
30
- "types": "./dist/types/index.d.ts",
31
- "import": "./dist/index.m.js",
32
- "require": "./dist/index.js"
33
- },
34
- "./package.json": "./package.json"
35
- },
36
- "files": [
37
- "dist"
38
- ],
39
- "engines": {
40
- "node": ">=18.18.0"
41
- },
42
- "browserslist": {
43
- "production": [
44
- ">0.2%",
45
- "not dead",
46
- "not op_mini all"
47
- ],
48
- "development": [
49
- "last 1 chrome version",
50
- "last 1 firefox version",
51
- "last 1 safari version"
52
- ]
53
- },
54
- "publishConfig": {
55
- "access": "public"
56
- },
57
- "repository": {
58
- "type": "git",
59
- "url": "git+https://gitlab.com/connect-soft/components/form-generator.git"
36
+ "peerDependencies": {
37
+ "react": "^19.0.0",
38
+ "react-dom": "^19.0.0",
39
+ "zod": "^4.0.0"
60
40
  },
61
- "bugs": {
62
- "url": "https://gitlab.com/connect-soft/components/form-generator/issues"
41
+ "dependencies": {
42
+ "@hookform/resolvers": "^5.2.1",
43
+ "react-hook-form": "^7.55.0"
63
44
  },
64
- "homepage": "https://gitlab.com/connect-soft/components/form-generator#readme",
65
- "dependencies": {},
66
45
  "devDependencies": {
67
- "@babel/core": "7.28.5",
68
- "@babel/preset-react": "7.28.5",
69
- "@babel/preset-typescript": "7.28.5",
70
- "@rollup/plugin-babel": "6.1.0",
71
- "@rollup/plugin-commonjs": "^28.0.6",
72
- "@rollup/plugin-node-resolve": "^16.0.1",
73
- "@rollup/plugin-typescript": "^12.1.4",
74
- "@storybook/addon-a11y": "^10.1.11",
75
- "@storybook/addon-docs": "^10.1.11",
76
- "@storybook/addon-links": "^10.1.11",
77
- "@storybook/react-vite": "^10.1.11",
78
- "@swc/core": "^1.3.102",
79
- "@swc/jest": "^0.2.29",
80
- "@testing-library/dom": "^10.4.1",
81
- "@testing-library/jest-dom": "6.9.1",
46
+ "@testing-library/jest-dom": "^6.9.1",
82
47
  "@testing-library/react": "^16.3.0",
83
- "@types/jest": "^30.0.0",
84
- "@types/node": "^20.0.0",
48
+ "@types/jest": "^29.5.0",
85
49
  "@types/react": "^19.0.0",
86
50
  "@types/react-dom": "^19.0.0",
87
- "@types/react-transition-group": "4.4.12",
88
- "@types/react-window": "^2.0.0",
89
- "@types/rollup-plugin-peer-deps-external": "^2",
90
51
  "@typescript-eslint/eslint-plugin": "^6.0.0",
91
52
  "@typescript-eslint/parser": "^6.0.0",
92
- "@vitejs/plugin-react": "5.1.2",
93
- "@vitejs/plugin-react-swc": "^3.5.0",
94
- "babel-plugin-react-compiler": "1.0.0",
95
- "classnames": "^2.5.1",
96
- "dayjs": "^1.11.19",
97
53
  "eslint": "^8.56.0",
98
54
  "eslint-config-airbnb-typescript": "^17.1.0",
99
55
  "eslint-config-prettier": "^9.1.0",
@@ -102,75 +58,28 @@
102
58
  "eslint-plugin-import": "^2.29.1",
103
59
  "eslint-plugin-jest": "^27.6.2",
104
60
  "eslint-plugin-jsx-a11y": "^6.8.0",
105
- "eslint-plugin-local-rules": "^3.0.2",
106
61
  "eslint-plugin-prettier": "^5.1.3",
107
62
  "eslint-plugin-react": "^7.33.2",
108
63
  "eslint-plugin-react-hooks": "^4.6.0",
109
- "eslint-plugin-storybook": "^10.1.11",
110
64
  "eslint-plugin-testing-library": "^6.2.0",
111
65
  "jest": "^29.7.0",
112
- "jest-canvas-mock": "^2.5.2",
113
66
  "jest-environment-jsdom": "^29.7.0",
114
- "jest-preview": "^0.3.1",
115
- "jest-serializer-html": "^7.1.0",
116
- "postcss": "8.5.6",
117
67
  "prettier": "^3.0.0",
118
- "react": "^19.0.0",
119
- "react-colorful": "^5.6.1",
120
- "react-dom": "^19.0.0",
121
- "react-transition-group": "^4.4.5",
122
- "require-json5": "^1.3.0",
123
- "rimraf": "6.1.2",
124
- "rollup": "^4.45.1",
125
- "rollup-plugin-peer-deps-external": "^2.2.4",
126
- "storybook": "^10.1.11",
127
- "@tailwindcss/postcss": "^4.1.18",
128
- "@tailwindcss/vite": "^4.1.18",
129
- "tailwindcss": "^4.1.18",
130
- "ts-jest": "^29.1.1",
131
- "ts-jest-resolver": "^2.0.1",
132
- "ts-node": "^10.9.2",
133
- "tsc-alias": "^1.8.16",
134
- "tsconfig": "^7.0.0",
135
- "typescript": "^5.8.3",
136
- "usehooks-ts": "^3.1.1",
137
- "vite": "^5.0.0",
138
- "vite-plugin-svgr": "^4.2.0",
139
- "zod": "^4.0.15"
140
- },
141
- "peerDependencies": {
142
- "dayjs": "^1.11.19",
143
- "react": "^19.0.0",
144
- "react-dom": "^19.0.0",
145
- "zod": "^4.0.15"
146
- },
147
- "resolutions": {
148
- "jackspeak": "2.1.1",
149
- "eslint-plugin-import": "^2.25.3"
68
+ "ts-jest": "^29.1.0",
69
+ "typescript": "^5.8.3"
150
70
  },
151
71
  "scripts": {
152
72
  "clean": "rimraf dist",
153
73
  "prebuild": "pnpm clean",
154
- "build": "rollup --config rollup.config.cjs && tsc-alias -p tsconfig.build.json",
155
- "bundle:analyze": "rollup --config rollup.config.cjs --environment ANALYZE",
156
- "bundle:size": "pnpm build && du -sh dist/*.js && gzip-size dist/index.m.js",
157
- "prettier:fix": "prettier --config .prettierrc --write \"**/*.{js,ts,tsx,css}\"",
74
+ "build": "rollup --config rollup.config.cjs && tsc -p tsconfig.build.json",
158
75
  "type": "tsc --noEmit -p tsconfig.build.json",
159
- "jest-preview": "jest-preview",
160
- "test:coverage": "pnpm test -- --coverage",
161
- "test:watch": "pnpm test -- --onlyChanged --watch",
162
- "test": "TZ=UTC jest",
163
- "test:type": "tsd src/__typetest__",
164
- "postversion": "git push && git push origin v$npm_package_version",
165
- "prepublishonly": "pnpm install && pnpm lint:fix && pnpm type && pnpm test",
166
- "bundlewatch": "pnpm build && bundlewatch",
167
- "start": "pnpm build && pnpm --dir ./example install && pnpm --dir ./example run dev",
168
- "link": "(pnpm unlink | pnpm link) && pnpm link \"@connect-soft/react-file-upload\"",
169
- "verify": "pnpm format && pnpm lint && pnpm type",
170
- "reinstall": "rm -rf 'pnpm.lock' 'node_modules' && pnpm",
171
- "release": "pnpm build && pnpm release:only",
172
- "release:only": "pnpm publish",
173
- "storybook": "storybook dev -p 6006",
174
- "build-storybook": "storybook build"
76
+ "test": "jest",
77
+ "test:watch": "jest --watch",
78
+ "test:coverage": "jest --coverage",
79
+ "lint": "eslint --ext .ts,.tsx src/",
80
+ "lint:fix": "eslint --ext .ts,.tsx src/ --fix",
81
+ "format": "prettier --check \"src/**/*.{ts,tsx}\"",
82
+ "format:fix": "prettier --write \"src/**/*.{ts,tsx}\"",
83
+ "verify": "pnpm format && pnpm lint && pnpm type"
175
84
  }
176
85
  }