@saas-ui/forms 2.5.4 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9fe1899: Improved Select types, value type is now string or string[] depending on the multiple prop
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [e75e99b]
12
+ - Updated dependencies [e75e99b]
13
+ - @saas-ui/core@2.5.0
14
+
3
15
  ## 2.5.4
4
16
 
5
17
  ### Patch Changes
@@ -1164,12 +1176,12 @@
1164
1176
  Add this somewhere in the root of your project.
1165
1177
 
1166
1178
  ```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";
1179
+ import { Form } from '@saas-ui/react'
1180
+ import { yupResolver, yupFieldResolver } from '@saas-ui/forms/yup' // yupResolver is exported from here as well for convenience.
1181
+ import { AnyObjectSchema } from 'yup'
1170
1182
 
1171
- Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema); // @hookform/resolvers
1172
- Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema); // AutoForm field resolver
1183
+ Form.getResolver = (schema: AnyObjectSchema) => yupResolver(schema) // @hookform/resolvers
1184
+ Form.getFieldResolver = (schema: AnyObjectSchema) => yupFieldResolver(schema) // AutoForm field resolver
1173
1185
  ```
1174
1186
 
1175
1187
  - 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
  /**
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
  /**