@saas-ui/forms 3.0.0-alpha.2 → 3.0.0-alpha.21
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +169 -0
- package/dist/index.d.mts +25 -12
- package/dist/index.d.ts +25 -12
- package/dist/index.js +111 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -71
- package/dist/index.mjs.map +1 -1
- package/dist/yup/index.d.mts +4 -4
- package/dist/yup/index.d.ts +4 -4
- package/dist/yup/index.js.map +1 -1
- package/dist/yup/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,174 @@
|
|
1
1
|
# @saas-ui/forms
|
2
2
|
|
3
|
+
## 3.0.0-alpha.21
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [6f9f04d]
|
8
|
+
- @saas-ui/react@3.0.0-alpha.21
|
9
|
+
- @saas-ui/core@3.0.0-alpha.7
|
10
|
+
|
11
|
+
## 3.0.0-alpha.20
|
12
|
+
|
13
|
+
### Patch Changes
|
14
|
+
|
15
|
+
- Updated dependencies [f85d493]
|
16
|
+
- Updated dependencies [f85d493]
|
17
|
+
- @saas-ui/react@3.0.0-alpha.20
|
18
|
+
- @saas-ui/core@3.0.0-alpha.6
|
19
|
+
|
20
|
+
## 3.0.0-alpha.19
|
21
|
+
|
22
|
+
### Patch Changes
|
23
|
+
|
24
|
+
- 38082d4: Improved horizontal field styles
|
25
|
+
- Updated dependencies [ba3b566]
|
26
|
+
- Updated dependencies [38082d4]
|
27
|
+
- Updated dependencies [ba3b566]
|
28
|
+
- Updated dependencies [ba3b566]
|
29
|
+
- Updated dependencies [3a73bc8]
|
30
|
+
- Updated dependencies [ba3b566]
|
31
|
+
- Updated dependencies [727b902]
|
32
|
+
- @saas-ui/react@3.0.0-alpha.19
|
33
|
+
|
34
|
+
## 3.0.0-alpha.18
|
35
|
+
|
36
|
+
### Patch Changes
|
37
|
+
|
38
|
+
- Updated dependencies [eb02362]
|
39
|
+
- Updated dependencies [e7fe684]
|
40
|
+
- Updated dependencies [eb02362]
|
41
|
+
- Updated dependencies [eb02362]
|
42
|
+
- @saas-ui/react@3.0.0-alpha.18
|
43
|
+
- @saas-ui/core@3.0.0-alpha.5
|
44
|
+
|
45
|
+
## 3.0.0-alpha.17
|
46
|
+
|
47
|
+
### Patch Changes
|
48
|
+
|
49
|
+
- Updated dependencies [a2ef175]
|
50
|
+
- @saas-ui/react@3.0.0-alpha.17
|
51
|
+
|
52
|
+
## 3.0.0-alpha.16
|
53
|
+
|
54
|
+
### Patch Changes
|
55
|
+
|
56
|
+
- Updated dependencies [205580d]
|
57
|
+
- Updated dependencies [205580d]
|
58
|
+
- @saas-ui/react@3.0.0-alpha.16
|
59
|
+
|
60
|
+
## 3.0.0-alpha.15
|
61
|
+
|
62
|
+
### Patch Changes
|
63
|
+
|
64
|
+
- Updated dependencies [2285040]
|
65
|
+
- Updated dependencies [2285040]
|
66
|
+
- @saas-ui/react@3.0.0-alpha.15
|
67
|
+
|
68
|
+
## 3.0.0-alpha.14
|
69
|
+
|
70
|
+
### Patch Changes
|
71
|
+
|
72
|
+
- Updated dependencies [0067207]
|
73
|
+
- Updated dependencies [0067207]
|
74
|
+
- @saas-ui/react@3.0.0-alpha.14
|
75
|
+
|
76
|
+
## 3.0.0-alpha.13
|
77
|
+
|
78
|
+
### Major Changes
|
79
|
+
|
80
|
+
- b51aff9: BREAKING: getBaseField should now return props and Component
|
81
|
+
|
82
|
+
### Patch Changes
|
83
|
+
|
84
|
+
- b51aff9: Improved prop handling of base field
|
85
|
+
- Updated dependencies [b51aff9]
|
86
|
+
- Updated dependencies [b51aff9]
|
87
|
+
- @saas-ui/react@3.0.0-alpha.13
|
88
|
+
|
89
|
+
## 3.0.0-alpha.12
|
90
|
+
|
91
|
+
### Patch Changes
|
92
|
+
|
93
|
+
- Updated dependencies [61ce1b5]
|
94
|
+
- @saas-ui/react@3.0.0-alpha.12
|
95
|
+
|
96
|
+
## 3.0.0-alpha.11
|
97
|
+
|
98
|
+
### Patch Changes
|
99
|
+
|
100
|
+
- Updated dependencies [19309d4]
|
101
|
+
- Updated dependencies [19309d4]
|
102
|
+
- @saas-ui/react@3.0.0-alpha.11
|
103
|
+
|
104
|
+
## 3.0.0-alpha.10
|
105
|
+
|
106
|
+
### Patch Changes
|
107
|
+
|
108
|
+
- Updated dependencies [212a7e6]
|
109
|
+
- Updated dependencies [942e9a0]
|
110
|
+
- Updated dependencies [212a7e6]
|
111
|
+
- Updated dependencies [65fac53]
|
112
|
+
- @saas-ui/react@3.0.0-alpha.10
|
113
|
+
|
114
|
+
## 3.0.0-alpha.9
|
115
|
+
|
116
|
+
### Patch Changes
|
117
|
+
|
118
|
+
- Updated dependencies [f0f5ab0]
|
119
|
+
- @saas-ui/react@3.0.0-alpha.9
|
120
|
+
|
121
|
+
## 3.0.0-alpha.8
|
122
|
+
|
123
|
+
### Patch Changes
|
124
|
+
|
125
|
+
- Updated dependencies [64e680e]
|
126
|
+
- Updated dependencies [64e680e]
|
127
|
+
- @saas-ui/react@3.0.0-alpha.8
|
128
|
+
|
129
|
+
## 3.0.0-alpha.7
|
130
|
+
|
131
|
+
### Patch Changes
|
132
|
+
|
133
|
+
- Updated dependencies [8e760c5]
|
134
|
+
- @saas-ui/react@3.0.0-alpha.7
|
135
|
+
|
136
|
+
## 3.0.0-alpha.6
|
137
|
+
|
138
|
+
### Minor Changes
|
139
|
+
|
140
|
+
- 95c8652: Update to Chakra UI 3.2.1
|
141
|
+
|
142
|
+
### Patch Changes
|
143
|
+
|
144
|
+
- Updated dependencies [95c8652]
|
145
|
+
- @saas-ui/react@3.0.0-alpha.6
|
146
|
+
- @saas-ui/core@3.0.0-alpha.4
|
147
|
+
|
148
|
+
## 3.0.0-alpha.5
|
149
|
+
|
150
|
+
### Patch Changes
|
151
|
+
|
152
|
+
- Updated dependencies [e9fec88]
|
153
|
+
- Updated dependencies [f62c3d6]
|
154
|
+
- @saas-ui/react@3.0.0-alpha.5
|
155
|
+
|
156
|
+
## 3.0.0-alpha.4
|
157
|
+
|
158
|
+
### Patch Changes
|
159
|
+
|
160
|
+
- Updated dependencies [7808a76]
|
161
|
+
- @saas-ui/react@3.0.0-alpha.4
|
162
|
+
|
163
|
+
## 3.0.0-alpha.3
|
164
|
+
|
165
|
+
### Patch Changes
|
166
|
+
|
167
|
+
- cee2e9c: Removed chakra ui dependency of core package
|
168
|
+
- Updated dependencies [cee2e9c]
|
169
|
+
- @saas-ui/core@3.0.0-alpha.3
|
170
|
+
- @saas-ui/react@3.0.0-alpha.3
|
171
|
+
|
3
172
|
## 3.0.0-alpha.2
|
4
173
|
|
5
174
|
### Minor Changes
|
package/dist/index.d.mts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React$1 from 'react';
|
2
2
|
import React__default, { ForwardRefRenderFunction, PropsWithoutRef } from 'react';
|
3
|
-
import { RecipeProps,
|
3
|
+
import { RecipeProps, SimpleGridProps, InputProps, TextareaProps, SystemStyleObject, Field as Field$1, HTMLChakraProps, ButtonProps as ButtonProps$1 } from '@chakra-ui/react';
|
4
4
|
import { MaybeRenderProp } from '@saas-ui/core/utils';
|
5
5
|
import * as react_hook_form from 'react-hook-form';
|
6
6
|
import { FieldValues, FieldPath, UseFormReturn as UseFormReturn$1, UseFieldArrayReturn, UseFormProps, WatchObserver, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, RegisterOptions, FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
|
@@ -19,13 +19,13 @@ interface FormLayoutOptions {
|
|
19
19
|
columns?: SimpleGridProps['columns'];
|
20
20
|
gap?: SimpleGridProps['gap'];
|
21
21
|
}
|
22
|
-
interface FormLayoutProps extends RecipeProps<'
|
22
|
+
interface FormLayoutProps extends RecipeProps<'suiFormLayout'>, SimpleGridProps {
|
23
23
|
}
|
24
24
|
/**
|
25
25
|
* Create consistent field spacing and positioning.
|
26
26
|
*
|
27
27
|
* Renders form items in a `SimpleGrid`
|
28
|
-
* @see https://chakra-ui.com/docs/
|
28
|
+
* @see https://chakra-ui.com/docs/components/simple-grid
|
29
29
|
*
|
30
30
|
* @see https://saas-ui.dev/docs/components/forms/form
|
31
31
|
*/
|
@@ -46,7 +46,10 @@ declare const TextareaField: React__default.FC<Omit<BaseFieldProps<react_hook_fo
|
|
46
46
|
interface SwitchFieldProps extends SwitchProps {
|
47
47
|
type: 'switch';
|
48
48
|
}
|
49
|
-
interface SelectFieldProps extends Omit<Select.RootProps<FieldOption>, 'collection'> {
|
49
|
+
interface SelectFieldProps<Multiple extends boolean = boolean> extends Omit<Select.RootProps<FieldOption>, 'collection' | 'value' | 'multiple' | 'onChange' | 'onValueChange'> {
|
50
|
+
multiple?: Multiple;
|
51
|
+
value?: Multiple extends true ? Array<string> : string;
|
52
|
+
onChange?: (value: Multiple extends true ? Array<string> : string) => void;
|
50
53
|
options: FieldOptions;
|
51
54
|
placeholder?: string;
|
52
55
|
triggerProps?: Select.TriggerProps;
|
@@ -80,7 +83,7 @@ declare const defaultFieldTypes: {
|
|
80
83
|
checkbox: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof CheckboxFieldProps> & CheckboxFieldProps>;
|
81
84
|
radio: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof RadioFieldProps> & RadioFieldProps>;
|
82
85
|
password: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof PasswordInputProps> & PasswordInputProps>;
|
83
|
-
select: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SelectFieldProps
|
86
|
+
select: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SelectFieldProps<boolean>> & SelectFieldProps<boolean>>;
|
84
87
|
switch: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SwitchFieldProps> & SwitchFieldProps>;
|
85
88
|
textarea: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof TextareaFieldProps> & TextareaFieldProps>;
|
86
89
|
};
|
@@ -336,8 +339,14 @@ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName e
|
|
336
339
|
children?: React.ReactNode;
|
337
340
|
}
|
338
341
|
type GetBaseField<TProps extends object = object> = () => {
|
339
|
-
|
340
|
-
|
342
|
+
/**
|
343
|
+
* Extra props to pass to the component
|
344
|
+
*/
|
345
|
+
props: Array<Extract<keyof TProps, string>>;
|
346
|
+
/**
|
347
|
+
* The component to render
|
348
|
+
*/
|
349
|
+
Component: React.FC<Omit<BaseFieldProps, 'name'> & {
|
341
350
|
name: string;
|
342
351
|
children: React.ReactNode;
|
343
352
|
} & TProps>;
|
@@ -529,9 +538,9 @@ interface FieldsProps<TSchema = any> {
|
|
529
538
|
}
|
530
539
|
declare const AutoFields: React$1.FC<FieldsProps>;
|
531
540
|
|
532
|
-
interface FieldsContextValue {
|
533
|
-
fields: Record<string, React__default.FC<
|
534
|
-
getBaseField?: GetBaseField<
|
541
|
+
interface FieldsContextValue<TFields = any, TBaseFieldProps extends object = object> {
|
542
|
+
fields: Record<string, React__default.FC<TFields>>;
|
543
|
+
getBaseField?: GetBaseField<TBaseFieldProps>;
|
535
544
|
}
|
536
545
|
declare const FieldsProvider: React__default.FC<{
|
537
546
|
value: FieldsContextValue;
|
@@ -581,17 +590,21 @@ interface WatchFieldProps<Value = unknown, TFieldValues extends FieldValues = Fi
|
|
581
590
|
declare const WatchField: <Value = unknown, TFieldValues extends FieldValues = FieldValues, TContext extends object = object>(props: WatchFieldProps<Value, TFieldValues, TContext>) => React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>> | null;
|
582
591
|
|
583
592
|
declare const useBaseField: (props: BaseFieldProps) => {
|
584
|
-
|
593
|
+
rootProps: Omit<BaseFieldProps<react_hook_form.FieldValues, string>, "name" | "label" | "hideLabel" | "help" | "rules" | "type" | "placeholder" | "children">;
|
585
594
|
error: any;
|
586
595
|
touched: any;
|
587
596
|
name: string;
|
588
597
|
label?: string | undefined;
|
589
598
|
hideLabel?: boolean | undefined;
|
590
599
|
help?: string | undefined;
|
600
|
+
rules?: Omit<react_hook_form.RegisterOptions<react_hook_form.FieldValues, string>, "disabled" | "setValueAs" | "valueAsNumber" | "valueAsDate"> | undefined;
|
601
|
+
type?: string | undefined;
|
602
|
+
placeholder?: string | undefined;
|
603
|
+
children?: React$1.ReactNode;
|
591
604
|
};
|
592
605
|
/**
|
593
606
|
* The default BaseField component
|
594
|
-
* Composes the Chakra UI
|
607
|
+
* Composes the Chakra UI Field component, with Label, HelperText and ErrorText.
|
595
608
|
*/
|
596
609
|
declare const BaseField: React$1.FC<BaseFieldProps>;
|
597
610
|
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React$1 from 'react';
|
2
2
|
import React__default, { ForwardRefRenderFunction, PropsWithoutRef } from 'react';
|
3
|
-
import { RecipeProps,
|
3
|
+
import { RecipeProps, SimpleGridProps, InputProps, TextareaProps, SystemStyleObject, Field as Field$1, HTMLChakraProps, ButtonProps as ButtonProps$1 } from '@chakra-ui/react';
|
4
4
|
import { MaybeRenderProp } from '@saas-ui/core/utils';
|
5
5
|
import * as react_hook_form from 'react-hook-form';
|
6
6
|
import { FieldValues, FieldPath, UseFormReturn as UseFormReturn$1, UseFieldArrayReturn, UseFormProps, WatchObserver, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, RegisterOptions, FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
|
@@ -19,13 +19,13 @@ interface FormLayoutOptions {
|
|
19
19
|
columns?: SimpleGridProps['columns'];
|
20
20
|
gap?: SimpleGridProps['gap'];
|
21
21
|
}
|
22
|
-
interface FormLayoutProps extends RecipeProps<'
|
22
|
+
interface FormLayoutProps extends RecipeProps<'suiFormLayout'>, SimpleGridProps {
|
23
23
|
}
|
24
24
|
/**
|
25
25
|
* Create consistent field spacing and positioning.
|
26
26
|
*
|
27
27
|
* Renders form items in a `SimpleGrid`
|
28
|
-
* @see https://chakra-ui.com/docs/
|
28
|
+
* @see https://chakra-ui.com/docs/components/simple-grid
|
29
29
|
*
|
30
30
|
* @see https://saas-ui.dev/docs/components/forms/form
|
31
31
|
*/
|
@@ -46,7 +46,10 @@ declare const TextareaField: React__default.FC<Omit<BaseFieldProps<react_hook_fo
|
|
46
46
|
interface SwitchFieldProps extends SwitchProps {
|
47
47
|
type: 'switch';
|
48
48
|
}
|
49
|
-
interface SelectFieldProps extends Omit<Select.RootProps<FieldOption>, 'collection'> {
|
49
|
+
interface SelectFieldProps<Multiple extends boolean = boolean> extends Omit<Select.RootProps<FieldOption>, 'collection' | 'value' | 'multiple' | 'onChange' | 'onValueChange'> {
|
50
|
+
multiple?: Multiple;
|
51
|
+
value?: Multiple extends true ? Array<string> : string;
|
52
|
+
onChange?: (value: Multiple extends true ? Array<string> : string) => void;
|
50
53
|
options: FieldOptions;
|
51
54
|
placeholder?: string;
|
52
55
|
triggerProps?: Select.TriggerProps;
|
@@ -80,7 +83,7 @@ declare const defaultFieldTypes: {
|
|
80
83
|
checkbox: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof CheckboxFieldProps> & CheckboxFieldProps>;
|
81
84
|
radio: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof RadioFieldProps> & RadioFieldProps>;
|
82
85
|
password: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof PasswordInputProps> & PasswordInputProps>;
|
83
|
-
select: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SelectFieldProps
|
86
|
+
select: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SelectFieldProps<boolean>> & SelectFieldProps<boolean>>;
|
84
87
|
switch: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof SwitchFieldProps> & SwitchFieldProps>;
|
85
88
|
textarea: React__default.FC<Omit<BaseFieldProps<react_hook_form.FieldValues, string>, keyof TextareaFieldProps> & TextareaFieldProps>;
|
86
89
|
};
|
@@ -336,8 +339,14 @@ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName e
|
|
336
339
|
children?: React.ReactNode;
|
337
340
|
}
|
338
341
|
type GetBaseField<TProps extends object = object> = () => {
|
339
|
-
|
340
|
-
|
342
|
+
/**
|
343
|
+
* Extra props to pass to the component
|
344
|
+
*/
|
345
|
+
props: Array<Extract<keyof TProps, string>>;
|
346
|
+
/**
|
347
|
+
* The component to render
|
348
|
+
*/
|
349
|
+
Component: React.FC<Omit<BaseFieldProps, 'name'> & {
|
341
350
|
name: string;
|
342
351
|
children: React.ReactNode;
|
343
352
|
} & TProps>;
|
@@ -529,9 +538,9 @@ interface FieldsProps<TSchema = any> {
|
|
529
538
|
}
|
530
539
|
declare const AutoFields: React$1.FC<FieldsProps>;
|
531
540
|
|
532
|
-
interface FieldsContextValue {
|
533
|
-
fields: Record<string, React__default.FC<
|
534
|
-
getBaseField?: GetBaseField<
|
541
|
+
interface FieldsContextValue<TFields = any, TBaseFieldProps extends object = object> {
|
542
|
+
fields: Record<string, React__default.FC<TFields>>;
|
543
|
+
getBaseField?: GetBaseField<TBaseFieldProps>;
|
535
544
|
}
|
536
545
|
declare const FieldsProvider: React__default.FC<{
|
537
546
|
value: FieldsContextValue;
|
@@ -581,17 +590,21 @@ interface WatchFieldProps<Value = unknown, TFieldValues extends FieldValues = Fi
|
|
581
590
|
declare const WatchField: <Value = unknown, TFieldValues extends FieldValues = FieldValues, TContext extends object = object>(props: WatchFieldProps<Value, TFieldValues, TContext>) => React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>> | null;
|
582
591
|
|
583
592
|
declare const useBaseField: (props: BaseFieldProps) => {
|
584
|
-
|
593
|
+
rootProps: Omit<BaseFieldProps<react_hook_form.FieldValues, string>, "name" | "label" | "hideLabel" | "help" | "rules" | "type" | "placeholder" | "children">;
|
585
594
|
error: any;
|
586
595
|
touched: any;
|
587
596
|
name: string;
|
588
597
|
label?: string | undefined;
|
589
598
|
hideLabel?: boolean | undefined;
|
590
599
|
help?: string | undefined;
|
600
|
+
rules?: Omit<react_hook_form.RegisterOptions<react_hook_form.FieldValues, string>, "disabled" | "setValueAs" | "valueAsNumber" | "valueAsDate"> | undefined;
|
601
|
+
type?: string | undefined;
|
602
|
+
placeholder?: string | undefined;
|
603
|
+
children?: React$1.ReactNode;
|
591
604
|
};
|
592
605
|
/**
|
593
606
|
* The default BaseField component
|
594
|
-
* Composes the Chakra UI
|
607
|
+
* Composes the Chakra UI Field component, with Label, HelperText and ErrorText.
|
595
608
|
*/
|
596
609
|
declare const BaseField: React$1.FC<BaseFieldProps>;
|
597
610
|
|