gform-react 1.5.1 → 1.9.3

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 (31) hide show
  1. package/README.md +2 -1
  2. package/dist/cjs/gform-react.development.js +48 -28
  3. package/dist/cjs/gform-react.development.js.map +1 -1
  4. package/dist/cjs/gform-react.production.js +1 -1
  5. package/dist/cjs/gform-react.production.js.map +1 -1
  6. package/dist/esm/GForm.production.js +1 -1
  7. package/dist/esm/GForm.production.js.map +1 -1
  8. package/dist/esm/GInput.production.js +1 -1
  9. package/dist/esm/GInput.production.js.map +1 -1
  10. package/dist/esm/index.development.js +48 -28
  11. package/dist/esm/index.development.js.map +1 -1
  12. package/dist/esm/shared.production.js +1 -1
  13. package/dist/esm/shared.production.js.map +1 -1
  14. package/dist/index.d.ts +28 -11
  15. package/native/dist/cjs/gform-react-native.development.js +471 -0
  16. package/native/dist/cjs/gform-react-native.development.js.map +1 -0
  17. package/native/dist/cjs/gform-react-native.production.js +2 -0
  18. package/native/dist/cjs/gform-react-native.production.js.map +1 -0
  19. package/native/dist/cjs/index.js +7 -0
  20. package/native/dist/esm/RNGForm.production.js +2 -0
  21. package/native/dist/esm/RNGForm.production.js.map +1 -0
  22. package/native/dist/esm/RNGInput.production.js +2 -0
  23. package/native/dist/esm/RNGInput.production.js.map +1 -0
  24. package/native/dist/esm/index.development.js +461 -0
  25. package/native/dist/esm/index.development.js.map +1 -0
  26. package/native/dist/esm/index.js +2 -0
  27. package/native/dist/esm/shared.production.js +2 -0
  28. package/native/dist/esm/shared.production.js.map +1 -0
  29. package/native/dist/index.d.ts +77 -0
  30. package/native/package.json +15 -0
  31. package/package.json +33 -22
@@ -0,0 +1,77 @@
1
+ import type { Dispatch, MutableRefObject, ReactNode, SetStateAction, FC } from "react";
2
+ import type {TextInputProps, View, ViewProps} from 'react-native';
3
+ import type {BaseGenericFieldProps, GInputState, GInputStateMutable, GValidators, IForm, PartialForm, RawData, ToRawDataOptions, ToURLSearchParamsOptions} from '../../dist';
4
+
5
+ type RNGInputElementHandler<T> = (input: GInputStateMutable<T>, props: TextInputProps) => JSX.Element;
6
+
7
+ export type RNGInputProps = BaseGenericFieldProps & TextInputProps & {
8
+ defaultValue?: string | number;
9
+ /**a function that gets called once the input has initialized and may have deps (see `fetchDeps`) */
10
+ fetch?: (state: GInputStateMutable, fields: IForm & { [key: string]: GInputStateMutable }) => void | Partial<GInputStateMutable> | Promise<void | Partial<GInputStateMutable>>;
11
+ /**an array of input keys that once one the values have changed `fetch` will re-run */
12
+ fetchDeps?: string[];
13
+ /**
14
+ * specify the debounce amount for validations in milliseconds
15
+ * @default 300
16
+ * */
17
+ debounce?: number;
18
+ } & ({
19
+ type?: 'text' | 'email' | 'tel' | 'url' | 'search';
20
+ minLength?: number;
21
+ maxLength?: number;
22
+ pattern?: string;
23
+ value?: string;
24
+ defaultValue?: string;
25
+ /**a handler fer rendering the input
26
+ * @param input the current state of the input
27
+ * @param props the props of the input should be spread to the dom element
28
+ * @example <input {...props} /> //native
29
+ * <InputText {...props} /> //Prime React
30
+ * <TextField inputProps={props} /> //MUI
31
+ */
32
+ element?: RNGInputElementHandler<string>;
33
+ });
34
+
35
+ export declare const RNGInput: FC<RNGInputProps & {ref?: MutableRefObject<any | null>}>;
36
+
37
+ export type RNGFormState<T> = IForm<T>
38
+ &
39
+ {
40
+ /**indicates whether the form is valid */
41
+ isValid: boolean;
42
+ /**indicates whether the form is invalid */
43
+ isInvalid: boolean;
44
+ /**returns the loading state */
45
+ loading: boolean;
46
+ /**returns an object with key value pairs represents the form*/
47
+ toRawData(options?: ToRawDataOptions<T>): RawData<T>;
48
+ /**returns `URLSearchParams` instance represents the form*/
49
+ toURLSearchParams(options?: ToURLSearchParamsOptions<T>): URLSearchParams;
50
+ /**update the loading state */
51
+ setLoading: Dispatch<SetStateAction<boolean>>;
52
+ /**update the validity state (invokes all defined validators) */
53
+ checkValidity(): boolean;
54
+ /**manually dispatch any changes to input(s) */
55
+ dispatchChanges: (changes: PartialForm<T> & { [key: string]: Partial<GInputState<any>> }) => void;
56
+ };
57
+
58
+ export type RNGFormProps<T> = Omit<ViewProps, 'children'> & {
59
+ children?: ReactNode | ReactNode[] | ((state: RNGFormState<T>) => ReactNode | ReactNode[]);
60
+ /** @param loader - a component to display while loading (optional). */
61
+ loader?: ReactNode;
62
+ /** @param stateRef - pass a ref which will points to the current state of the form (optional). */
63
+ stateRef?: MutableRefObject<RNGFormState<T> | undefined>;
64
+ /** @param validators - an object for handling validations (optional). */
65
+ validators?: GValidators<T>;
66
+ /** @param onInit - execute a handler once the form has initialized (optional). */
67
+ onInit?: (state: RNGFormState<T>) => void | PartialForm<T> | Promise<void | PartialForm<T>>;
68
+ el: FC<ViewProps>;
69
+ ref?: MutableRefObject<View | null>;
70
+ };
71
+
72
+ /**
73
+ * build dynamic forms with validations.
74
+ * @link Docs - https://gform-react.onrender.com
75
+ * @link Npm - https://www.npmjs.com/package/gform-react
76
+ */
77
+ export const RNGForm: <T extends any>({loader,stateRef,children,validators,onInit,...rest}: RNGFormProps<T>) => JSX.Element;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "gform-react/native",
3
+ "private": true,
4
+ "types": "./dist/index.d.ts",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/esm/index.js",
7
+ "exports": {
8
+ "require": "./dist/cjs/index.js",
9
+ "import": {
10
+ "production": "./dist/esm/index.js",
11
+ "development": "./dist/esm/index.development.js"
12
+ },
13
+ "default": "./dist/esm/index.js"
14
+ }
15
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "gform-react",
3
- "version": "1.5.1",
3
+ "version": "1.9.3",
4
4
  "description": "build generic forms with validations for react-based applications",
5
5
  "author": "Tal Maman, Arkady Birko",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "clean": "rimraf ./dist",
8
+ "clean": "rimraf ./dist && rimraf ./native",
9
9
  "build:prod": "rollup -c --environment build:production",
10
10
  "build:dev": "rollup -c --environment build:development",
11
11
  "build": "npm run tscheck && npm run lint && npm run security:check && npm run clean && npm run build:dev && npm run build:prod",
@@ -19,46 +19,57 @@
19
19
  "main": "dist/cjs/index.js",
20
20
  "module": "dist/esm/index.js",
21
21
  "exports": {
22
- "require": "./dist/cjs/index.js",
23
- "import": {
24
- "production": "./dist/esm/index.js",
25
- "development": "./dist/esm/index.development.js"
22
+ ".": {
23
+ "require": "./dist/cjs/index.js",
24
+ "import": {
25
+ "production": "./dist/esm/index.js",
26
+ "development": "./dist/esm/index.development.js"
27
+ },
28
+ "default": "./dist/esm/index.js"
29
+ },
30
+ "./native": {
31
+ "require": "./native/dist/cjs/index.js",
32
+ "import": {
33
+ "production": "./native/dist/esm/index.js",
34
+ "development": "./native/dist/esm/index.development.js"
35
+ },
36
+ "default": "./native/dist/esm/index.js"
26
37
  }
27
38
  },
28
39
  "sideEffects": false,
29
40
  "files": [
30
- "dist/"
41
+ "dist",
42
+ "native"
31
43
  ],
32
44
  "peerDependencies": {
33
45
  "react": ">=16.8.0",
34
46
  "react-dom": ">=16.8.0"
35
47
  },
36
48
  "devDependencies": {
37
- "@babel/core": "^7.22.5",
38
- "@babel/plugin-transform-runtime": "^7.22.5",
39
- "@babel/preset-env": "^7.22.5",
40
- "@babel/preset-react": "^7.22.5",
41
- "@babel/preset-typescript": "^7.18.6",
49
+ "@babel/core": "^7.23.9",
50
+ "@babel/plugin-transform-runtime": "^7.23.9",
51
+ "@babel/preset-env": "^7.23.9",
52
+ "@babel/preset-react": "^7.23.3",
53
+ "@babel/preset-typescript": "^7.23.3",
42
54
  "@emotion/react": "^11.10.0",
43
55
  "@emotion/styled": "^11.10.0",
44
56
  "@mui/material": "^5.10.2",
45
- "@rollup/plugin-babel": "^6.0.3",
46
- "@rollup/plugin-commonjs": "^25.0.0",
47
- "@rollup/plugin-node-resolve": "^15.1.0",
48
- "@rollup/plugin-replace": "^5.0.2",
49
- "@rollup/plugin-terser": "^0.4.3",
50
- "@types/react": "18.0.26",
51
- "@types/react-dom": "18.0.10",
57
+ "@rollup/plugin-babel": "^6.0.4",
58
+ "@rollup/plugin-commonjs": "^25.0.7",
59
+ "@rollup/plugin-node-resolve": "^15.2.3",
60
+ "@rollup/plugin-replace": "^5.0.5",
61
+ "@rollup/plugin-terser": "^0.4.4",
62
+ "@types/react": "18.2.55",
63
+ "@types/react-dom": "18.2.19",
52
64
  "@typescript-eslint/eslint-plugin": "^5.59.5",
53
65
  "@typescript-eslint/parser": "^5.59.5",
54
66
  "eslint": "^8.12.0",
55
67
  "primeicons": "^6.0.1",
56
68
  "primereact": "^8.7.3",
69
+ "react-native": "0.73.4",
57
70
  "rimraf": "^5.0.1",
58
- "rollup": "^3.23.0",
71
+ "rollup": "^3.29.4",
59
72
  "rollup-plugin-copy": "^3.4.0",
60
- "rollup-plugin-dts": "^5.3.0",
61
- "rollup-plugin-typescript2": "^0.34.1",
62
73
  "typescript": "^5.0.4"
63
74
  },
64
75
  "keywords": [