@saas-ui/forms 2.5.4 → 2.6.1

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b110d4a: Fixed select field not accepting multiple prop
8
+
9
+ ## 2.6.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 9fe1899: Improved Select types, value type is now string or string[] depending on the multiple prop
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [e75e99b]
18
+ - Updated dependencies [e75e99b]
19
+ - @saas-ui/core@2.5.0
20
+
3
21
  ## 2.5.4
4
22
 
5
23
  ### Patch Changes
@@ -1164,12 +1182,12 @@
1164
1182
  Add this somewhere in the root of your project.
1165
1183
 
1166
1184
  ```ts
1167
- import { Form } from "@saas-ui/react";
1168
- import { yupResolver, yupFieldResolver } from "@saas-ui/forms/yup"; // yupResolver is exported from here as well for convenience.
1169
- import { AnyObjectSchema } from "yup";
1185
+ import { Form } from '@saas-ui/react'
1186
+ import { yupResolver, yupFieldResolver } from '@saas-ui/forms/yup' // yupResolver is exported from here as well for convenience.
1187
+ import { AnyObjectSchema } from 'yup'
1170
1188
 
1171
- Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema); // @hookform/resolvers
1172
- Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema); // AutoForm field resolver
1189
+ Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema) // @hookform/resolvers
1190
+ Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema) // AutoForm field resolver
1173
1191
  ```
1174
1192
 
1175
1193
  - 9391c44: Fixed peer dependency issues.
package/dist/index.d.mts CHANGED
@@ -65,7 +65,7 @@ interface RadioInputProps extends Omit<RadioGroupProps, 'children'>, RadioInputO
65
65
  }
66
66
  declare const RadioInput: _chakra_ui_react.ComponentWithAs<"div", RadioInputProps>;
67
67
 
68
- interface SelectOptions {
68
+ interface SelectOptions<Multiple extends boolean = false, Value = Multiple extends true ? string[] : string> {
69
69
  /**
70
70
  * The name of the input field in a native form.
71
71
  */
@@ -73,16 +73,16 @@ interface SelectOptions {
73
73
  /**
74
74
  * The value of the select field.
75
75
  */
76
- value?: string | string[];
76
+ value?: Value;
77
77
  /**
78
78
  * The initial value of the select field.
79
79
  */
80
- defaultValue?: string | string[];
80
+ defaultValue?: Value;
81
81
  /**
82
82
  * The callback invoked when the value of the select field changes.
83
83
  * @param value The value of the select field.
84
84
  */
85
- onChange?: (value: string | string[]) => void;
85
+ onChange?: (value: Value) => void;
86
86
  /**
87
87
  * The placeholder text when there's no value.
88
88
  */
@@ -99,16 +99,17 @@ interface SelectOptions {
99
99
  /**
100
100
  * Enable multiple select.
101
101
  */
102
- multiple?: boolean;
102
+ multiple?: Multiple;
103
103
  /**
104
104
  * The function used to render the value of the select field.
105
105
  * @param value The value of the select field.
106
106
  * @returns The rendered value.
107
107
  */
108
- renderValue?: (value: string | string[]) => React__default.ReactNode;
108
+ renderValue?: (value: Value) => React__default.ReactNode;
109
109
  }
110
110
 
111
- interface SelectProps extends Omit<MenuProps, 'children' | 'variant' | 'size'>, ThemingProps<'SuiSelect'>, SelectOptions {
111
+ interface SelectProps<Multiple extends boolean = false, Value = Multiple extends true ? string[] : string> extends Omit<MenuProps, 'children' | 'variant' | 'size'>, ThemingProps<'SuiSelect'>, SelectOptions<Multiple, Value> {
112
+ children: React$1.ReactNode;
112
113
  }
113
114
  interface SelectButtonProps extends Omit<ButtonProps, 'size' | 'variant'> {
114
115
  }
@@ -123,7 +124,11 @@ declare const SelectButton: _chakra_ui_react.ComponentWithAs<"button", SelectBut
123
124
  *
124
125
  * @see https://saas-ui.dev/docs/components/forms/select
125
126
  */
126
- declare const Select: _chakra_ui_react.ComponentWithAs<"select", SelectProps>;
127
+ declare const Select: (<Multiple extends boolean = false>(props: SelectProps<Multiple> & {
128
+ ref?: React$1.ForwardedRef<HTMLFormElement>;
129
+ }) => React$1.ReactElement) & {
130
+ displayName?: string | undefined;
131
+ };
127
132
  interface SelectListProps extends MenuListProps {
128
133
  }
129
134
  /**
@@ -169,7 +174,7 @@ declare const TextareaField: React$1.FC<Omit<src.BaseFieldProps<react_hook_form.
169
174
  interface SwitchFieldProps extends SwitchProps {
170
175
  }
171
176
  declare const SwitchField: React$1.FC<Omit<src.BaseFieldProps<react_hook_form.FieldValues, string>, keyof SwitchFieldProps> & SwitchFieldProps>;
172
- interface SelectFieldProps extends SelectProps {
177
+ interface SelectFieldProps extends SelectProps<boolean> {
173
178
  buttonProps?: SelectButtonProps;
174
179
  listProps?: SelectListProps;
175
180
  }
package/dist/index.d.ts CHANGED
@@ -65,7 +65,7 @@ interface RadioInputProps extends Omit<RadioGroupProps, 'children'>, RadioInputO
65
65
  }
66
66
  declare const RadioInput: _chakra_ui_react.ComponentWithAs<"div", RadioInputProps>;
67
67
 
68
- interface SelectOptions {
68
+ interface SelectOptions<Multiple extends boolean = false, Value = Multiple extends true ? string[] : string> {
69
69
  /**
70
70
  * The name of the input field in a native form.
71
71
  */
@@ -73,16 +73,16 @@ interface SelectOptions {
73
73
  /**
74
74
  * The value of the select field.
75
75
  */
76
- value?: string | string[];
76
+ value?: Value;
77
77
  /**
78
78
  * The initial value of the select field.
79
79
  */
80
- defaultValue?: string | string[];
80
+ defaultValue?: Value;
81
81
  /**
82
82
  * The callback invoked when the value of the select field changes.
83
83
  * @param value The value of the select field.
84
84
  */
85
- onChange?: (value: string | string[]) => void;
85
+ onChange?: (value: Value) => void;
86
86
  /**
87
87
  * The placeholder text when there's no value.
88
88
  */
@@ -99,16 +99,17 @@ interface SelectOptions {
99
99
  /**
100
100
  * Enable multiple select.
101
101
  */
102
- multiple?: boolean;
102
+ multiple?: Multiple;
103
103
  /**
104
104
  * The function used to render the value of the select field.
105
105
  * @param value The value of the select field.
106
106
  * @returns The rendered value.
107
107
  */
108
- renderValue?: (value: string | string[]) => React__default.ReactNode;
108
+ renderValue?: (value: Value) => React__default.ReactNode;
109
109
  }
110
110
 
111
- interface SelectProps extends Omit<MenuProps, 'children' | 'variant' | 'size'>, ThemingProps<'SuiSelect'>, SelectOptions {
111
+ interface SelectProps<Multiple extends boolean = false, Value = Multiple extends true ? string[] : string> extends Omit<MenuProps, 'children' | 'variant' | 'size'>, ThemingProps<'SuiSelect'>, SelectOptions<Multiple, Value> {
112
+ children: React$1.ReactNode;
112
113
  }
113
114
  interface SelectButtonProps extends Omit<ButtonProps, 'size' | 'variant'> {
114
115
  }
@@ -123,7 +124,11 @@ declare const SelectButton: _chakra_ui_react.ComponentWithAs<"button", SelectBut
123
124
  *
124
125
  * @see https://saas-ui.dev/docs/components/forms/select
125
126
  */
126
- declare const Select: _chakra_ui_react.ComponentWithAs<"select", SelectProps>;
127
+ declare const Select: (<Multiple extends boolean = false>(props: SelectProps<Multiple> & {
128
+ ref?: React$1.ForwardedRef<HTMLFormElement>;
129
+ }) => React$1.ReactElement) & {
130
+ displayName?: string | undefined;
131
+ };
127
132
  interface SelectListProps extends MenuListProps {
128
133
  }
129
134
  /**
@@ -169,7 +174,7 @@ declare const TextareaField: React$1.FC<Omit<src.BaseFieldProps<react_hook_form.
169
174
  interface SwitchFieldProps extends SwitchProps {
170
175
  }
171
176
  declare const SwitchField: React$1.FC<Omit<src.BaseFieldProps<react_hook_form.FieldValues, string>, keyof SwitchFieldProps> & SwitchFieldProps>;
172
- interface SelectFieldProps extends SelectProps {
177
+ interface SelectFieldProps extends SelectProps<boolean> {
173
178
  buttonProps?: SelectButtonProps;
174
179
  listProps?: SelectListProps;
175
180
  }