@saas-ui/forms 2.3.10 → 2.3.12
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -5
- package/dist/index.d.ts +2 -8
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -5
- package/dist/index.mjs.map +1 -1
- package/dist/yup/index.d.ts +0 -6
- package/dist/zod/index.d.ts +0 -6
- package/package.json +8 -8
- package/src/submit-button.tsx +17 -14
package/dist/zod/index.d.ts
CHANGED
@@ -170,16 +170,10 @@ type DefaultFields = typeof defaultFieldTypes;
|
|
170
170
|
interface SubmitButtonProps extends ButtonProps {
|
171
171
|
/**
|
172
172
|
* Disable the submit button if the form is untouched.
|
173
|
-
*
|
174
|
-
* Change the default behavior by updating
|
175
|
-
* `SubmitButton.defaultProps.disableIfUntouched`
|
176
173
|
*/
|
177
174
|
disableIfUntouched?: boolean;
|
178
175
|
/**
|
179
176
|
* Disable the submit button if the form is invalid.
|
180
|
-
*
|
181
|
-
* Change the default behavior by updating
|
182
|
-
* `SubmitButton.defaultProps.disableIfInvalid`
|
183
177
|
*/
|
184
178
|
disableIfInvalid?: boolean;
|
185
179
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@saas-ui/forms",
|
3
|
-
"version": "2.3.
|
3
|
+
"version": "2.3.12",
|
4
4
|
"description": "Fully functional forms for Chakra UI.",
|
5
5
|
"source": "src/index.ts",
|
6
6
|
"exports": {
|
@@ -103,9 +103,9 @@
|
|
103
103
|
"dependencies": {
|
104
104
|
"@chakra-ui/react-utils": "^2.0.12",
|
105
105
|
"@chakra-ui/utils": "^2.0.15",
|
106
|
-
"@hookform/resolvers": "^3.3.
|
107
|
-
"@saas-ui/core": "2.3.
|
108
|
-
"react-hook-form": "^7.
|
106
|
+
"@hookform/resolvers": "^3.3.4",
|
107
|
+
"@saas-ui/core": "2.3.6",
|
108
|
+
"react-hook-form": "^7.50.1"
|
109
109
|
},
|
110
110
|
"peerDependencies": {
|
111
111
|
"@chakra-ui/react": ">=2.4.9",
|
@@ -116,13 +116,13 @@
|
|
116
116
|
"react-dom": ">=18.0.0"
|
117
117
|
},
|
118
118
|
"devDependencies": {
|
119
|
-
"@types/json-schema": "^7.0.
|
119
|
+
"@types/json-schema": "^7.0.15",
|
120
120
|
"ajv": "^8.12.0",
|
121
121
|
"ajv-errors": "^3.0.0",
|
122
|
-
"json-schema-to-ts": "^2.
|
122
|
+
"json-schema-to-ts": "^2.12.0",
|
123
123
|
"tsd": "^0.28.1",
|
124
|
-
"yup": "^1.
|
125
|
-
"zod": "^3.22.
|
124
|
+
"yup": "^1.3.3",
|
125
|
+
"zod": "^3.22.4"
|
126
126
|
},
|
127
127
|
"tsd": {
|
128
128
|
"directory": "tests"
|
package/src/submit-button.tsx
CHANGED
@@ -8,16 +8,10 @@ import { useFieldProps } from './form-context'
|
|
8
8
|
export interface SubmitButtonProps extends ButtonProps {
|
9
9
|
/**
|
10
10
|
* Disable the submit button if the form is untouched.
|
11
|
-
*
|
12
|
-
* Change the default behavior by updating
|
13
|
-
* `SubmitButton.defaultProps.disableIfUntouched`
|
14
11
|
*/
|
15
12
|
disableIfUntouched?: boolean
|
16
13
|
/**
|
17
14
|
* Disable the submit button if the form is invalid.
|
18
|
-
*
|
19
|
-
* Change the default behavior by updating
|
20
|
-
* `SubmitButton.defaultProps.disableIfInvalid`
|
21
15
|
*/
|
22
16
|
disableIfInvalid?: boolean
|
23
17
|
}
|
@@ -31,21 +25,31 @@ export const SubmitButton = forwardRef<SubmitButtonProps, 'button'>(
|
|
31
25
|
const {
|
32
26
|
variant = 'primary',
|
33
27
|
children = 'Submit',
|
34
|
-
disableIfUntouched = false,
|
35
|
-
disableIfInvalid = false,
|
28
|
+
disableIfUntouched: disableIfUntouchedProp = false,
|
29
|
+
disableIfInvalid: disableIfInvalidProp = false,
|
36
30
|
isDisabled: isDisabledProp,
|
37
31
|
isLoading,
|
38
32
|
...rest
|
39
33
|
} = props
|
40
34
|
const { formState } = useFormContext()
|
41
35
|
|
36
|
+
const field = useFieldProps('submit') as SubmitButtonProps
|
37
|
+
|
38
|
+
const {
|
39
|
+
disableIfUntouched: disableIfUntouchedOverride,
|
40
|
+
disableIfInvalid: disableIfInvalidOverride,
|
41
|
+
...fieldProps
|
42
|
+
} = field
|
43
|
+
|
44
|
+
const disableIfUntouched =
|
45
|
+
disableIfUntouchedOverride ?? disableIfUntouchedProp
|
46
|
+
const disableIfInvalid = disableIfInvalidOverride ?? disableIfInvalidProp
|
47
|
+
|
42
48
|
const isDisabled =
|
43
49
|
(disableIfUntouched && !formState.isDirty) ||
|
44
50
|
(disableIfInvalid && !formState.isValid) ||
|
45
51
|
isDisabledProp
|
46
52
|
|
47
|
-
const field = useFieldProps('submit') as any
|
48
|
-
|
49
53
|
return (
|
50
54
|
<Button
|
51
55
|
ref={ref}
|
@@ -53,11 +57,10 @@ export const SubmitButton = forwardRef<SubmitButtonProps, 'button'>(
|
|
53
57
|
type="submit"
|
54
58
|
isLoading={formState.isSubmitting || isLoading}
|
55
59
|
isDisabled={isDisabled}
|
60
|
+
children={children}
|
56
61
|
{...rest}
|
57
|
-
{...
|
58
|
-
|
59
|
-
{children}
|
60
|
-
</Button>
|
62
|
+
{...fieldProps}
|
63
|
+
/>
|
61
64
|
)
|
62
65
|
}
|
63
66
|
)
|