-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathmodule-augmentation.ts
287 lines (262 loc) · 9.56 KB
/
module-augmentation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { SystemStyleObject } from "@chakra-ui/system";
import type { GroupBase, StylesConfig, ThemeConfig } from "react-select";
import type {
ChakraStylesConfig,
SelectedOptionStyle,
SizeProp,
TagVariant,
Variant,
} from "./types";
/**
* Module augmentation is used to add extra props to the existing interfaces
* from `react-select` as per the docs
*
* @see {@link https://react-select.com/typescript#custom-select-props}
*/
declare module "react-select/dist/declarations/src/Select" {
export interface Props<
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
> {
/**
* The size of the base control; matches the sizes of the chakra Input
* component with the exception of `xs`. A [responsive style array/object](https://chakra-ui.com/docs/features/responsive-styles) can
* also be passed.
*
* Options: `sm` | `md` | `lg`
*
* @defaultValue `md`
* @see {@link https://github.com/csandman/chakra-react-select#size--options-responsivevaluesm--md--lg--default-md}
* @see {@link https://chakra-ui.com/docs/components/input#changing-the-size-of-the-input}
*/
size?: SizeProp;
/**
* Determines whether or not to style the input with the invalid border
* color.
*
* If the `aria-invalid` prop is not passed, this prop will also set that
*
* @defaultValue `false`
* @see {@link https://github.com/csandman/chakra-react-select#isinvalid--default-false--isreadonly---default-false}
* @see {@link https://chakra-ui.com/docs/components/input/props}
* @see {@link https://chakra-ui.com/docs/components/form-control/props}
*/
isInvalid?: boolean;
/**
* If `true`, the form control will be `readonly`.
*
* @defaultValue `false`
* @see {@link https://github.com/csandman/chakra-react-select#isinvalid--default-false--isreadonly---default-false}
* @see {@link https://chakra-ui.com/docs/components/input/props}
* @see {@link https://chakra-ui.com/docs/components/form-control/props}
*/
isReadOnly?: boolean;
/**
* If true, the form control will be required. This has 2 side effects:
*
* - The `FormLabel` will show a required indicator
* - The form element (e.g, Input) will have `aria-required` set to true
*
* @see {@link https://chakra-ui.com/docs/components/input/props}
* @see {@link https://chakra-ui.com/docs/components/form-control/props}
*/
isRequired?: boolean;
/**
* A color name that matches a key from your chakra theme and will
* determine the color scheme of your `MultiValue` component.
*
* The styling matches the chakra `Tag` component.
*
* @defaultValue `"gray"`
* @see {@link https://github.com/csandman/chakra-react-select#colorscheme}
* @see {@link https://chakra-ui.com/docs/components/tag/props}
*/
colorScheme?: string;
/**
* The `variant` prop that will be forwarded to your `MultiValue` component
* which is represented by a chakra `Tag`. You can also use any custom
* variants you have added to your theme.
*
* Options: "subtle" | "solid" | "outline"
*
* @defaultValue `subtle`
* @see {@link https://github.com/csandman/chakra-react-select#tagvariant--options-subtle--solid--outline--default-subtle}
* @see {@link https://chakra-ui.com/docs/data-display/tag#props}
*/
tagVariant?: TagVariant;
/**
* Passing `true` for this prop will make the group headers
* `position: sticky` and keep them stuck to the top while their
* corresponding group is in view.
*
* @defaultValue `false`
* @deprecated This prop should probably not have existed and will be
* removed soon.
*/
hasStickyGroupHeaders?: boolean;
/**
* Whether to style a selected option by highlighting it in a solid color
* or adding a check mark next to it like the chakra `Menu` component.
*
* Options: `color` | `check`
*
* @defaultValue `color`
* @see {@link https://github.com/csandman/chakra-react-select#selectedoptionstyle--options-color--check--default-color}
* @see {@link https://chakra-ui.com/docs/components/menu#menu-option-groups}
*/
selectedOptionStyle?: SelectedOptionStyle;
/**
* The color scheme to style an option with when using the
* `selectedOptionStyle="color"` prop. Uses the `500` value in light mode
* and the `300` value in dark mode.
*
* @defaultValue `blue`
* @see {@link https://github.com/csandman/chakra-react-select#selectedoptioncolorscheme--default-blue}
*/
selectedOptionColorScheme?: string;
/**
* @deprecated Replaced by {@link selectedOptionColorScheme}
*/
selectedOptionColor?: string;
/**
* The color value to style the border of the `Control` with when the
* select is focused.
*
* @defaultValue Light mode: `blue.500` | Dark mode: `blue.300`
* @see {@link https://github.com/csandman/chakra-react-select#focusbordercolor--default-blue500--errorbordercolor--default-red500}
* @see {@link https://chakra-ui.com/docs/components/input#changing-the-focus-and-error-border-colors}
*/
focusBorderColor?: string;
/**
* The color value to style the border of the `Control` with when
* `isInvalid` is passed to the select.
*
* @defaultValue Light mode: `red.500` | Dark mode: `red.300`
* @see {@link https://github.com/csandman/chakra-react-select#focusbordercolor--default-blue500--errorbordercolor--default-red500}
* @see {@link https://chakra-ui.com/docs/components/input#changing-the-focus-and-error-border-colors}
*/
errorBorderColor?: string;
/**
* Style transformation methods for each of the rendered components using,
* Chakra's `SystemStyleObject` and the props passed into each component.
*
* @see {@link https://github.com/csandman/chakra-react-select#chakrastyles}
* @see {@link https://react-select.com/styles#style-object}
*/
chakraStyles?: ChakraStylesConfig<Option, IsMulti, Group>;
/**
* If passed, the dropdown indicator will be styled the same as Chakra UI's
* `Select` component.
*
* @defaultValue `false`
* @see {@link https://github.com/csandman/chakra-react-select#usebasicstyles--default-false}
* @see {@link https://chakra-ui.com/docs/components/select}
*/
useBasicStyles?: boolean;
/**
* The main style variant of the `Select` component. This will use styles
* from Chakra's `Input` component and any custom variants you have added to
* your theme may be used.
*
* Options: `outline` | `filled` | `flushed` | `unstyled`
*
* @defaultValue `outline`
* @see {@link https://chakra-ui.com/docs/components/select#changing-the-appearance}
* @see {@link https://github.com/csandman/chakra-react-select#variant--options-outline--filled--flushed--unstyled--default-outline}
*/
variant?: Variant;
/**
* @deprecated This prop is not used in `chakra-react-select`, use
* {@link chakraStyles} instead.
*/
styles: StylesConfig<Option, IsMulti, Group>;
/**
* @deprecated This prop is not used in `chakra-react-select`, all theme
* values are pulled from your Chakra UI theme.
*/
theme?: ThemeConfig;
}
}
declare module "react-select/dist/declarations/src/components/MultiValue" {
export interface MultiValueProps<
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
> {
sx: SystemStyleObject;
}
export interface MultiValueGenericProps<
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
> {
sx: SystemStyleObject;
}
export interface MultiValueRemoveProps<
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
> {
isFocused: boolean;
sx: SystemStyleObject;
}
}
declare module "react-select/dist/declarations/src/components/indicators" {
export interface LoadingIndicatorProps<
Option,
IsMulti extends boolean,
Group extends GroupBase<Option>,
> {
/**
* The color of the filled in area of the spinner.
*
* Defaults to your Chakra theme's text color.
*
* @defaultValue Light mode: `gray.700` | Dark mode: `whiteAlpha.900`
*/
color?: string;
/**
* The color of the empty area in the spinner.
*
* @defaultValue `transparent`
* @see {@link https://chakra-ui.com/docs/components/spinner#spinner-with-empty-area-color}
*/
emptyColor?: string;
/**
* The size prop for the Chakra `<Spinner />` component.
*
* Defaults to one size smaller than the overall Select's size.
*
* @see {@link https://chakra-ui.com/docs/components/spinner#spinner-with-different-size}
*/
spinnerSize?: "xs" | "sm" | "md" | "lg" | "xl";
/**
* The speed of the spinner represented by the time it takes to make one full rotation.
*
* This speed is represented by a
* [CSS `<time>`](https://developer.mozilla.org/en-US/docs/Web/CSS/time)
* variable which uses either seconds or milliseconds.
*
* @defaultValue `0.45s`
* @example
* ```jsx
* <Spinner speed="0.2s"/>
* ```
* @see {@link https://chakra-ui.com/docs/components/spinner/props}
*/
speed?: string;
/**
* The thickness of the spinner.
*
* @defaultValue `2px`
* @example
* ```jsx
* <Spinner thickness="4px"/>
* ```
* @see {@link https://chakra-ui.com/docs/components/spinner/props}
*/
thickness?: string;
}
}