@atlaskit/react-select 0.0.2
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 +9 -0
- package/LICENSE.md +11 -0
- package/README.md +10 -0
- package/async/package.json +15 -0
- package/base/package.json +15 -0
- package/creatable/package.json +15 -0
- package/dist/cjs/accessibility/helpers.js +34 -0
- package/dist/cjs/accessibility/index.js +74 -0
- package/dist/cjs/async-creatable.js +27 -0
- package/dist/cjs/async.js +30 -0
- package/dist/cjs/builtins.js +18 -0
- package/dist/cjs/components/containers.js +100 -0
- package/dist/cjs/components/control.js +67 -0
- package/dist/cjs/components/group.js +79 -0
- package/dist/cjs/components/index.js +53 -0
- package/dist/cjs/components/indicators.js +214 -0
- package/dist/cjs/components/input.js +93 -0
- package/dist/cjs/components/internal/a11y-text.js +34 -0
- package/dist/cjs/components/internal/dummy-input.js +43 -0
- package/dist/cjs/components/internal/index.js +34 -0
- package/dist/cjs/components/internal/required-input.js +43 -0
- package/dist/cjs/components/internal/scroll-manager.js +57 -0
- package/dist/cjs/components/internal/use-scroll-capture.js +132 -0
- package/dist/cjs/components/internal/use-scroll-lock.js +149 -0
- package/dist/cjs/components/live-region.js +153 -0
- package/dist/cjs/components/menu.js +464 -0
- package/dist/cjs/components/multi-value.js +129 -0
- package/dist/cjs/components/option.js +62 -0
- package/dist/cjs/components/placeholder.js +39 -0
- package/dist/cjs/components/single-value.js +46 -0
- package/dist/cjs/creatable.js +30 -0
- package/dist/cjs/diacritics.js +274 -0
- package/dist/cjs/filters.js +50 -0
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/nonce-provider.js +30 -0
- package/dist/cjs/select.js +1803 -0
- package/dist/cjs/state-manager.js +31 -0
- package/dist/cjs/styles.js +66 -0
- package/dist/cjs/theme.js +42 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/use-async.js +156 -0
- package/dist/cjs/use-creatable.js +114 -0
- package/dist/cjs/use-state-manager.js +83 -0
- package/dist/cjs/utils.js +357 -0
- package/dist/es2019/accessibility/helpers.js +24 -0
- package/dist/es2019/accessibility/index.js +72 -0
- package/dist/es2019/async-creatable.js +17 -0
- package/dist/es2019/async.js +16 -0
- package/dist/es2019/builtins.js +4 -0
- package/dist/es2019/components/containers.js +100 -0
- package/dist/es2019/components/control.js +62 -0
- package/dist/es2019/components/group.js +74 -0
- package/dist/es2019/components/index.js +41 -0
- package/dist/es2019/components/indicators.js +211 -0
- package/dist/es2019/components/input.js +88 -0
- package/dist/es2019/components/internal/a11y-text.js +25 -0
- package/dist/es2019/components/internal/dummy-input.js +36 -0
- package/dist/es2019/components/internal/index.js +4 -0
- package/dist/es2019/components/internal/required-input.js +35 -0
- package/dist/es2019/components/internal/scroll-manager.js +49 -0
- package/dist/es2019/components/internal/use-scroll-capture.js +128 -0
- package/dist/es2019/components/internal/use-scroll-lock.js +143 -0
- package/dist/es2019/components/live-region.js +151 -0
- package/dist/es2019/components/menu.js +466 -0
- package/dist/es2019/components/multi-value.js +134 -0
- package/dist/es2019/components/option.js +57 -0
- package/dist/es2019/components/placeholder.js +34 -0
- package/dist/es2019/components/single-value.js +41 -0
- package/dist/es2019/creatable.js +15 -0
- package/dist/es2019/diacritics.js +264 -0
- package/dist/es2019/filters.js +36 -0
- package/dist/es2019/index.js +8 -0
- package/dist/es2019/nonce-provider.js +19 -0
- package/dist/es2019/select.js +1766 -0
- package/dist/es2019/state-manager.js +22 -0
- package/dist/es2019/styles.js +56 -0
- package/dist/es2019/theme.js +36 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/use-async.js +117 -0
- package/dist/es2019/use-creatable.js +81 -0
- package/dist/es2019/use-state-manager.js +60 -0
- package/dist/es2019/utils.js +309 -0
- package/dist/esm/accessibility/helpers.js +24 -0
- package/dist/esm/accessibility/index.js +68 -0
- package/dist/esm/async-creatable.js +17 -0
- package/dist/esm/async.js +16 -0
- package/dist/esm/builtins.js +12 -0
- package/dist/esm/components/containers.js +96 -0
- package/dist/esm/components/control.js +62 -0
- package/dist/esm/components/group.js +74 -0
- package/dist/esm/components/index.js +43 -0
- package/dist/esm/components/indicators.js +209 -0
- package/dist/esm/components/input.js +88 -0
- package/dist/esm/components/internal/a11y-text.js +27 -0
- package/dist/esm/components/internal/dummy-input.js +37 -0
- package/dist/esm/components/internal/index.js +4 -0
- package/dist/esm/components/internal/required-input.js +36 -0
- package/dist/esm/components/internal/scroll-manager.js +49 -0
- package/dist/esm/components/internal/use-scroll-capture.js +126 -0
- package/dist/esm/components/internal/use-scroll-lock.js +143 -0
- package/dist/esm/components/live-region.js +148 -0
- package/dist/esm/components/menu.js +460 -0
- package/dist/esm/components/multi-value.js +122 -0
- package/dist/esm/components/option.js +57 -0
- package/dist/esm/components/placeholder.js +34 -0
- package/dist/esm/components/single-value.js +41 -0
- package/dist/esm/creatable.js +15 -0
- package/dist/esm/diacritics.js +268 -0
- package/dist/esm/filters.js +43 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/nonce-provider.js +20 -0
- package/dist/esm/select.js +1794 -0
- package/dist/esm/state-manager.js +22 -0
- package/dist/esm/styles.js +58 -0
- package/dist/esm/theme.js +36 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/use-async.js +149 -0
- package/dist/esm/use-creatable.js +107 -0
- package/dist/esm/use-state-manager.js +76 -0
- package/dist/esm/utils.js +328 -0
- package/dist/types/accessibility/helpers.d.ts +5 -0
- package/dist/types/accessibility/index.d.ts +125 -0
- package/dist/types/async-creatable.d.ts +10 -0
- package/dist/types/async.d.ts +9 -0
- package/dist/types/builtins.d.ts +5 -0
- package/dist/types/components/containers.d.ts +50 -0
- package/dist/types/components/control.d.ts +33 -0
- package/dist/types/components/group.d.ts +53 -0
- package/dist/types/components/index.d.ts +73 -0
- package/dist/types/components/indicators.d.ts +72 -0
- package/dist/types/components/input.d.ts +33 -0
- package/dist/types/components/internal/a11y-text.d.ts +8 -0
- package/dist/types/components/internal/dummy-input.d.ts +9 -0
- package/dist/types/components/internal/index.d.ts +4 -0
- package/dist/types/components/internal/required-input.d.ts +10 -0
- package/dist/types/components/internal/scroll-manager.d.ts +17 -0
- package/dist/types/components/internal/use-scroll-capture.d.ts +12 -0
- package/dist/types/components/internal/use-scroll-lock.d.ts +9 -0
- package/dist/types/components/live-region.d.ts +24 -0
- package/dist/types/components/menu.d.ts +130 -0
- package/dist/types/components/multi-value.d.ts +47 -0
- package/dist/types/components/option.d.ts +49 -0
- package/dist/types/components/placeholder.d.ts +22 -0
- package/dist/types/components/single-value.d.ts +28 -0
- package/dist/types/creatable.d.ts +10 -0
- package/dist/types/diacritics.d.ts +1 -0
- package/dist/types/filters.d.ts +15 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/nonce-provider.d.ts +8 -0
- package/dist/types/select.d.ts +616 -0
- package/dist/types/state-manager.d.ts +17 -0
- package/dist/types/styles.d.ts +68 -0
- package/dist/types/theme.d.ts +27 -0
- package/dist/types/types.d.ts +134 -0
- package/dist/types/use-async.d.ts +31 -0
- package/dist/types/use-creatable.d.ts +46 -0
- package/dist/types/use-state-manager.d.ts +15 -0
- package/dist/types/utils.d.ts +44 -0
- package/dist/types-ts4.5/accessibility/helpers.d.ts +5 -0
- package/dist/types-ts4.5/accessibility/index.d.ts +125 -0
- package/dist/types-ts4.5/async-creatable.d.ts +10 -0
- package/dist/types-ts4.5/async.d.ts +9 -0
- package/dist/types-ts4.5/builtins.d.ts +5 -0
- package/dist/types-ts4.5/components/containers.d.ts +50 -0
- package/dist/types-ts4.5/components/control.d.ts +33 -0
- package/dist/types-ts4.5/components/group.d.ts +53 -0
- package/dist/types-ts4.5/components/index.d.ts +73 -0
- package/dist/types-ts4.5/components/indicators.d.ts +72 -0
- package/dist/types-ts4.5/components/input.d.ts +33 -0
- package/dist/types-ts4.5/components/internal/a11y-text.d.ts +8 -0
- package/dist/types-ts4.5/components/internal/dummy-input.d.ts +9 -0
- package/dist/types-ts4.5/components/internal/index.d.ts +4 -0
- package/dist/types-ts4.5/components/internal/required-input.d.ts +10 -0
- package/dist/types-ts4.5/components/internal/scroll-manager.d.ts +17 -0
- package/dist/types-ts4.5/components/internal/use-scroll-capture.d.ts +12 -0
- package/dist/types-ts4.5/components/internal/use-scroll-lock.d.ts +9 -0
- package/dist/types-ts4.5/components/live-region.d.ts +24 -0
- package/dist/types-ts4.5/components/menu.d.ts +130 -0
- package/dist/types-ts4.5/components/multi-value.d.ts +47 -0
- package/dist/types-ts4.5/components/option.d.ts +49 -0
- package/dist/types-ts4.5/components/placeholder.d.ts +22 -0
- package/dist/types-ts4.5/components/single-value.d.ts +28 -0
- package/dist/types-ts4.5/creatable.d.ts +10 -0
- package/dist/types-ts4.5/diacritics.d.ts +1 -0
- package/dist/types-ts4.5/filters.d.ts +15 -0
- package/dist/types-ts4.5/index.d.ts +28 -0
- package/dist/types-ts4.5/nonce-provider.d.ts +8 -0
- package/dist/types-ts4.5/select.d.ts +616 -0
- package/dist/types-ts4.5/state-manager.d.ts +17 -0
- package/dist/types-ts4.5/styles.d.ts +68 -0
- package/dist/types-ts4.5/theme.d.ts +27 -0
- package/dist/types-ts4.5/types.d.ts +134 -0
- package/dist/types-ts4.5/use-async.d.ts +31 -0
- package/dist/types-ts4.5/use-creatable.d.ts +46 -0
- package/dist/types-ts4.5/use-state-manager.d.ts +15 -0
- package/dist/types-ts4.5/utils.d.ts +44 -0
- package/package.json +83 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ContainerProps, type IndicatorsContainerProps, type ValueContainerProps } from './components/containers';
|
|
2
|
+
import { type ControlProps } from './components/control';
|
|
3
|
+
import { type GroupHeadingProps, type GroupProps } from './components/group';
|
|
4
|
+
import { type ClearIndicatorProps, type DropdownIndicatorProps, type IndicatorSeparatorProps, type LoadingIndicatorProps } from './components/indicators';
|
|
5
|
+
import { type InputProps } from './components/input';
|
|
6
|
+
import { type MenuListProps, type MenuProps, type NoticeProps, type PortalStyleArgs } from './components/menu';
|
|
7
|
+
import { type MultiValueProps } from './components/multi-value';
|
|
8
|
+
import { type OptionProps } from './components/option';
|
|
9
|
+
import { type PlaceholderProps } from './components/placeholder';
|
|
10
|
+
import { type SingleValueProps } from './components/single-value';
|
|
11
|
+
import { type CSSObjectWithLabel, type GroupBase } from './types';
|
|
12
|
+
export interface StylesProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> {
|
|
13
|
+
clearIndicator: ClearIndicatorProps<Option, IsMulti, Group>;
|
|
14
|
+
container: ContainerProps<Option, IsMulti, Group>;
|
|
15
|
+
control: ControlProps<Option, IsMulti, Group>;
|
|
16
|
+
dropdownIndicator: DropdownIndicatorProps<Option, IsMulti, Group>;
|
|
17
|
+
group: GroupProps<Option, IsMulti, Group>;
|
|
18
|
+
groupHeading: GroupHeadingProps<Option, IsMulti, Group>;
|
|
19
|
+
indicatorsContainer: IndicatorsContainerProps<Option, IsMulti, Group>;
|
|
20
|
+
indicatorSeparator: IndicatorSeparatorProps<Option, IsMulti, Group>;
|
|
21
|
+
input: InputProps<Option, IsMulti, Group>;
|
|
22
|
+
loadingIndicator: LoadingIndicatorProps<Option, IsMulti, Group>;
|
|
23
|
+
loadingMessage: NoticeProps<Option, IsMulti, Group>;
|
|
24
|
+
menu: MenuProps<Option, IsMulti, Group>;
|
|
25
|
+
menuList: MenuListProps<Option, IsMulti, Group>;
|
|
26
|
+
menuPortal: PortalStyleArgs;
|
|
27
|
+
multiValue: MultiValueProps<Option, IsMulti, Group>;
|
|
28
|
+
multiValueLabel: MultiValueProps<Option, IsMulti, Group>;
|
|
29
|
+
multiValueRemove: MultiValueProps<Option, IsMulti, Group>;
|
|
30
|
+
noOptionsMessage: NoticeProps<Option, IsMulti, Group>;
|
|
31
|
+
option: OptionProps<Option, IsMulti, Group>;
|
|
32
|
+
placeholder: PlaceholderProps<Option, IsMulti, Group>;
|
|
33
|
+
singleValue: SingleValueProps<Option, IsMulti, Group>;
|
|
34
|
+
valueContainer: ValueContainerProps<Option, IsMulti, Group>;
|
|
35
|
+
}
|
|
36
|
+
export declare const defaultStyles: {
|
|
37
|
+
[K in keyof StylesProps<any, any, any>]: (props: StylesProps<unknown, boolean, GroupBase<unknown>>[K], unstyled: boolean) => CSSObjectWithLabel;
|
|
38
|
+
};
|
|
39
|
+
export type StylesConfig<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = {
|
|
40
|
+
[K in keyof StylesProps<Option, IsMulti, Group>]?: (base: CSSObjectWithLabel, props: StylesProps<Option, IsMulti, Group>[K]) => CSSObjectWithLabel;
|
|
41
|
+
};
|
|
42
|
+
export type ClassNamesConfig<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = {
|
|
43
|
+
[K in keyof StylesProps<Option, IsMulti, Group>]?: (props: StylesProps<Option, IsMulti, Group>[K]) => string;
|
|
44
|
+
};
|
|
45
|
+
export declare function mergeStyles<Option, IsMulti extends boolean, Group extends GroupBase<Option>>(source: StylesConfig<Option, IsMulti, Group>, target?: StylesConfig<Option, IsMulti, Group>): {
|
|
46
|
+
clearIndicator?: ((base: CSSObjectWithLabel, props: ClearIndicatorProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
47
|
+
container?: ((base: CSSObjectWithLabel, props: ContainerProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
48
|
+
control?: ((base: CSSObjectWithLabel, props: ControlProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
49
|
+
dropdownIndicator?: ((base: CSSObjectWithLabel, props: DropdownIndicatorProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
50
|
+
group?: ((base: CSSObjectWithLabel, props: GroupProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
51
|
+
groupHeading?: ((base: CSSObjectWithLabel, props: GroupHeadingProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
52
|
+
indicatorsContainer?: ((base: CSSObjectWithLabel, props: IndicatorsContainerProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
53
|
+
indicatorSeparator?: ((base: CSSObjectWithLabel, props: IndicatorSeparatorProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
54
|
+
input?: ((base: CSSObjectWithLabel, props: InputProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
55
|
+
loadingIndicator?: ((base: CSSObjectWithLabel, props: LoadingIndicatorProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
56
|
+
loadingMessage?: ((base: CSSObjectWithLabel, props: NoticeProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
57
|
+
menu?: ((base: CSSObjectWithLabel, props: MenuProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
58
|
+
menuList?: ((base: CSSObjectWithLabel, props: MenuListProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
59
|
+
menuPortal?: ((base: CSSObjectWithLabel, props: PortalStyleArgs) => CSSObjectWithLabel) | undefined;
|
|
60
|
+
multiValue?: ((base: CSSObjectWithLabel, props: MultiValueProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
61
|
+
multiValueLabel?: ((base: CSSObjectWithLabel, props: MultiValueProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
62
|
+
multiValueRemove?: ((base: CSSObjectWithLabel, props: MultiValueProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
63
|
+
noOptionsMessage?: ((base: CSSObjectWithLabel, props: NoticeProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
64
|
+
option?: ((base: CSSObjectWithLabel, props: OptionProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
65
|
+
placeholder?: ((base: CSSObjectWithLabel, props: PlaceholderProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
66
|
+
singleValue?: ((base: CSSObjectWithLabel, props: SingleValueProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
67
|
+
valueContainer?: ((base: CSSObjectWithLabel, props: ValueContainerProps<Option, IsMulti, Group>) => CSSObjectWithLabel) | undefined;
|
|
68
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Theme } from './types';
|
|
2
|
+
export declare const colors: {
|
|
3
|
+
primary: string;
|
|
4
|
+
primary75: string;
|
|
5
|
+
primary50: string;
|
|
6
|
+
primary25: string;
|
|
7
|
+
danger: string;
|
|
8
|
+
dangerLight: string;
|
|
9
|
+
neutral0: string;
|
|
10
|
+
neutral5: string;
|
|
11
|
+
neutral10: string;
|
|
12
|
+
neutral20: string;
|
|
13
|
+
neutral30: string;
|
|
14
|
+
neutral40: string;
|
|
15
|
+
neutral50: string;
|
|
16
|
+
neutral60: string;
|
|
17
|
+
neutral70: string;
|
|
18
|
+
neutral80: string;
|
|
19
|
+
neutral90: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const spacing: {
|
|
22
|
+
baseUnit: number;
|
|
23
|
+
controlHeight: number;
|
|
24
|
+
menuGutter: number;
|
|
25
|
+
};
|
|
26
|
+
export declare const defaultTheme: Theme;
|
|
27
|
+
export type ThemeConfig = Theme | ((theme: Theme) => Theme);
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type CSSObject } from '@emotion/react';
|
|
2
|
+
import { type SelectProps } from './select';
|
|
3
|
+
import { type StylesProps } from './styles';
|
|
4
|
+
export interface GroupBase<Option> {
|
|
5
|
+
readonly options: readonly Option[];
|
|
6
|
+
readonly label?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Option {
|
|
9
|
+
label: string;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
export type OptionsOrGroups<Option, Group extends GroupBase<Option>> = readonly (Option | Group)[];
|
|
13
|
+
export type Options<Option> = readonly Option[];
|
|
14
|
+
export type SingleValue<Option> = Option | null;
|
|
15
|
+
export type MultiValue<Option> = readonly Option[];
|
|
16
|
+
export type PropsValue<Option> = MultiValue<Option> | SingleValue<Option>;
|
|
17
|
+
export type OnChangeValue<Option, IsMulti extends boolean> = IsMulti extends true ? MultiValue<Option> : SingleValue<Option>;
|
|
18
|
+
export interface Colors {
|
|
19
|
+
primary: string;
|
|
20
|
+
primary75: string;
|
|
21
|
+
primary50: string;
|
|
22
|
+
primary25: string;
|
|
23
|
+
danger: string;
|
|
24
|
+
dangerLight: string;
|
|
25
|
+
neutral0: string;
|
|
26
|
+
neutral5: string;
|
|
27
|
+
neutral10: string;
|
|
28
|
+
neutral20: string;
|
|
29
|
+
neutral30: string;
|
|
30
|
+
neutral40: string;
|
|
31
|
+
neutral50: string;
|
|
32
|
+
neutral60: string;
|
|
33
|
+
neutral70: string;
|
|
34
|
+
neutral80: string;
|
|
35
|
+
neutral90: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ThemeSpacing {
|
|
38
|
+
baseUnit: number;
|
|
39
|
+
controlHeight: number;
|
|
40
|
+
menuGutter: number;
|
|
41
|
+
}
|
|
42
|
+
export interface Theme {
|
|
43
|
+
borderRadius: number;
|
|
44
|
+
colors: Colors;
|
|
45
|
+
spacing: ThemeSpacing;
|
|
46
|
+
}
|
|
47
|
+
export type ClassNamesState = {
|
|
48
|
+
[key: string]: boolean;
|
|
49
|
+
};
|
|
50
|
+
export type CX = (state: ClassNamesState, ...classNames: (string | undefined)[]) => string;
|
|
51
|
+
export type GetStyles<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = <Key extends keyof StylesProps<Option, IsMulti, Group>>(propertyName: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => CSSObjectWithLabel;
|
|
52
|
+
export interface CommonProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> {
|
|
53
|
+
clearValue: () => void;
|
|
54
|
+
cx: CX;
|
|
55
|
+
/**
|
|
56
|
+
* Get the styles of a particular part of the select. Pass in the name of the
|
|
57
|
+
* property as the first argument, and the current props as the second argument.
|
|
58
|
+
* See the `styles` object for the properties available.
|
|
59
|
+
*/
|
|
60
|
+
getStyles: GetStyles<Option, IsMulti, Group>;
|
|
61
|
+
getClassNames: <Key extends keyof StylesProps<Option, IsMulti, Group>>(propertyName: Key, props: StylesProps<Option, IsMulti, Group>[Key]) => string | undefined;
|
|
62
|
+
getValue: () => Options<Option>;
|
|
63
|
+
hasValue: boolean;
|
|
64
|
+
isMulti: boolean;
|
|
65
|
+
isRtl: boolean;
|
|
66
|
+
options: OptionsOrGroups<Option, Group>;
|
|
67
|
+
selectOption: (newValue: Option) => void;
|
|
68
|
+
selectProps: SelectProps<Option, IsMulti, Group>;
|
|
69
|
+
setValue: (newValue: OnChangeValue<Option, IsMulti>, action: SetValueAction, option?: Option) => void;
|
|
70
|
+
theme: Theme;
|
|
71
|
+
}
|
|
72
|
+
export interface CommonPropsAndClassName<Option, IsMulti extends boolean, Group extends GroupBase<Option>> extends CommonProps<Option, IsMulti, Group> {
|
|
73
|
+
className?: string | undefined;
|
|
74
|
+
}
|
|
75
|
+
export interface ActionMetaBase<Option> {
|
|
76
|
+
option?: Option | undefined;
|
|
77
|
+
removedValue?: Option;
|
|
78
|
+
removedValues?: Options<Option>;
|
|
79
|
+
name?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface SelectOptionActionMeta<Option> extends ActionMetaBase<Option> {
|
|
82
|
+
action: 'select-option';
|
|
83
|
+
option: Option | undefined;
|
|
84
|
+
name?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface DeselectOptionActionMeta<Option> extends ActionMetaBase<Option> {
|
|
87
|
+
action: 'deselect-option';
|
|
88
|
+
option: Option | undefined;
|
|
89
|
+
name?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface RemoveValueActionMeta<Option> extends ActionMetaBase<Option> {
|
|
92
|
+
action: 'remove-value';
|
|
93
|
+
removedValue: Option;
|
|
94
|
+
name?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface PopValueActionMeta<Option> extends ActionMetaBase<Option> {
|
|
97
|
+
action: 'pop-value';
|
|
98
|
+
removedValue: Option;
|
|
99
|
+
name?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ClearActionMeta<Option> extends ActionMetaBase<Option> {
|
|
102
|
+
action: 'clear';
|
|
103
|
+
removedValues: Options<Option>;
|
|
104
|
+
name?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface CreateOptionActionMeta<Option> extends ActionMetaBase<Option> {
|
|
107
|
+
action: 'create-option';
|
|
108
|
+
name?: string;
|
|
109
|
+
option: Option;
|
|
110
|
+
}
|
|
111
|
+
export interface InitialInputFocusedActionMeta<Option, IsMulti extends boolean> extends ActionMetaBase<Option> {
|
|
112
|
+
action: 'initial-input-focus';
|
|
113
|
+
value: OnChangeValue<Option, IsMulti>;
|
|
114
|
+
options?: Options<Option>;
|
|
115
|
+
}
|
|
116
|
+
export type ActionMeta<Option> = SelectOptionActionMeta<Option> | DeselectOptionActionMeta<Option> | RemoveValueActionMeta<Option> | PopValueActionMeta<Option> | ClearActionMeta<Option> | CreateOptionActionMeta<Option>;
|
|
117
|
+
export type SetValueAction = 'select-option' | 'deselect-option';
|
|
118
|
+
export type InputAction = 'set-value' | 'input-change' | 'input-blur' | 'menu-close';
|
|
119
|
+
export interface InputActionMeta {
|
|
120
|
+
action: InputAction;
|
|
121
|
+
/**
|
|
122
|
+
* The previous value of the search input.
|
|
123
|
+
*/
|
|
124
|
+
prevInputValue: string;
|
|
125
|
+
}
|
|
126
|
+
export type MenuPlacement = 'auto' | 'bottom' | 'top';
|
|
127
|
+
export type CoercedMenuPlacement = 'bottom' | 'top';
|
|
128
|
+
export type MenuPosition = 'absolute' | 'fixed';
|
|
129
|
+
export type FocusDirection = 'up' | 'down' | 'pageup' | 'pagedown' | 'first' | 'last';
|
|
130
|
+
export type GetOptionLabel<Option> = (option: Option) => string;
|
|
131
|
+
export type GetOptionValue<Option> = (option: Option) => string;
|
|
132
|
+
export type CSSObjectWithLabel = CSSObject & {
|
|
133
|
+
label?: string;
|
|
134
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type GroupBase, type OptionsOrGroups } from './types';
|
|
2
|
+
import { type StateManagerProps } from './use-state-manager';
|
|
3
|
+
type AsyncManagedPropKeys = 'options' | 'isLoading' | 'onInputChange' | 'filterOption';
|
|
4
|
+
export interface AsyncAdditionalProps<Option, Group extends GroupBase<Option>> {
|
|
5
|
+
/**
|
|
6
|
+
* The default set of options to show before the user starts searching. When
|
|
7
|
+
* set to `true`, the results for loadOptions('') will be autoloaded.
|
|
8
|
+
*/
|
|
9
|
+
defaultOptions?: OptionsOrGroups<Option, Group> | boolean;
|
|
10
|
+
/**
|
|
11
|
+
* If cacheOptions is truthy, then the loaded data will be cached. The cache
|
|
12
|
+
* will remain until `cacheOptions` changes value.
|
|
13
|
+
*/
|
|
14
|
+
cacheOptions?: any;
|
|
15
|
+
/**
|
|
16
|
+
* Function that returns a promise, which is the set of options to be used
|
|
17
|
+
* once the promise resolves.
|
|
18
|
+
*/
|
|
19
|
+
loadOptions?: (inputValue: string, callback: (options: OptionsOrGroups<Option, Group>) => void) => Promise<OptionsOrGroups<Option, Group>> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Will cause the select to be displayed in the loading state, even if the
|
|
22
|
+
* Async select is not currently waiting for loadOptions to resolve
|
|
23
|
+
*/
|
|
24
|
+
isLoading?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type AsyncProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = StateManagerProps<Option, IsMulti, Group> & AsyncAdditionalProps<Option, Group>;
|
|
27
|
+
/**
|
|
28
|
+
* {description}.
|
|
29
|
+
*/
|
|
30
|
+
export default function useAsync<Option, IsMulti extends boolean, Group extends GroupBase<Option>, AdditionalProps>({ defaultOptions: propsDefaultOptions, cacheOptions, loadOptions: propsLoadOptions, options: propsOptions, isLoading: propsIsLoading, onInputChange: propsOnInputChange, filterOption, ...restSelectProps }: AsyncProps<Option, IsMulti, Group> & AdditionalProps): StateManagerProps<Option, IsMulti, Group> & Omit<AdditionalProps, keyof AsyncAdditionalProps<Option, Group> | AsyncManagedPropKeys>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type PublicBaseSelectProps } from './select';
|
|
3
|
+
import { type GetOptionLabel, type GetOptionValue, type GroupBase, type Options, type OptionsOrGroups } from './types';
|
|
4
|
+
export interface Accessors<Option> {
|
|
5
|
+
getOptionValue: GetOptionValue<Option>;
|
|
6
|
+
getOptionLabel: GetOptionLabel<Option>;
|
|
7
|
+
}
|
|
8
|
+
export interface CreatableAdditionalProps<Option, Group extends GroupBase<Option>> {
|
|
9
|
+
/**
|
|
10
|
+
* Allow options to be created while the `isLoading` prop is true. Useful to
|
|
11
|
+
* prevent the "create new ..." option being displayed while async results are
|
|
12
|
+
* still being loaded.
|
|
13
|
+
*/
|
|
14
|
+
allowCreateWhileLoading?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the position of the createOption element in your options list. Defaults to 'last'
|
|
17
|
+
*/
|
|
18
|
+
createOptionPosition?: 'first' | 'last';
|
|
19
|
+
/**
|
|
20
|
+
* Gets the label for the "create new ..." option in the menu. Is given the
|
|
21
|
+
* current input value.
|
|
22
|
+
*/
|
|
23
|
+
formatCreateLabel?: (inputValue: string) => ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Determines whether the "create new ..." option should be displayed based on
|
|
26
|
+
* the current input value, select value and options array.
|
|
27
|
+
*/
|
|
28
|
+
isValidNewOption?: (inputValue: string, value: Options<Option>, options: OptionsOrGroups<Option, Group>, accessors: Accessors<Option>) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the data for the new option when it is created. Used to display the
|
|
31
|
+
* value, and is passed to `onChange`.
|
|
32
|
+
*/
|
|
33
|
+
getNewOptionData?: (inputValue: string, optionLabel: ReactNode) => Option;
|
|
34
|
+
/**
|
|
35
|
+
* If provided, this will be called with the input value when a new option is
|
|
36
|
+
* created, and `onChange` will **not** be called. Use this when you need more
|
|
37
|
+
* control over what happens when new options are created.
|
|
38
|
+
*/
|
|
39
|
+
onCreateOption?: (inputValue: string) => void;
|
|
40
|
+
}
|
|
41
|
+
type BaseCreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = PublicBaseSelectProps<Option, IsMulti, Group> & CreatableAdditionalProps<Option, Group>;
|
|
42
|
+
/**
|
|
43
|
+
* {description}.
|
|
44
|
+
*/
|
|
45
|
+
export default function useCreatable<Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ allowCreateWhileLoading, createOptionPosition, formatCreateLabel, isValidNewOption, getNewOptionData, onCreateOption, options: propsOptions, onChange: propsOnChange, ...restSelectProps }: BaseCreatableProps<Option, IsMulti, Group>): PublicBaseSelectProps<Option, IsMulti, Group>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PublicBaseSelectProps } from './select';
|
|
2
|
+
import { type GroupBase, type PropsValue } from './types';
|
|
3
|
+
type StateManagedPropKeys = 'inputValue' | 'menuIsOpen' | 'onChange' | 'onInputChange' | 'onMenuClose' | 'onMenuOpen' | 'value';
|
|
4
|
+
type SelectPropsWithOptionalStateManagedProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = Omit<PublicBaseSelectProps<Option, IsMulti, Group>, StateManagedPropKeys> & Partial<PublicBaseSelectProps<Option, IsMulti, Group>>;
|
|
5
|
+
export interface StateManagerAdditionalProps<Option> {
|
|
6
|
+
defaultInputValue?: string;
|
|
7
|
+
defaultMenuIsOpen?: boolean;
|
|
8
|
+
defaultValue?: PropsValue<Option>;
|
|
9
|
+
}
|
|
10
|
+
export type StateManagerProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> = SelectPropsWithOptionalStateManagedProps<Option, IsMulti, Group> & StateManagerAdditionalProps<Option>;
|
|
11
|
+
/**
|
|
12
|
+
* {description}.
|
|
13
|
+
*/
|
|
14
|
+
export default function useStateManager<Option, IsMulti extends boolean, Group extends GroupBase<Option>, AdditionalProps>({ defaultInputValue, defaultMenuIsOpen, defaultValue, inputValue: propsInputValue, menuIsOpen: propsMenuIsOpen, onChange: propsOnChange, onInputChange: propsOnInputChange, onMenuClose: propsOnMenuClose, onMenuOpen: propsOnMenuOpen, value: propsValue, ...restSelectProps }: StateManagerProps<Option, IsMulti, Group> & AdditionalProps): PublicBaseSelectProps<Option, IsMulti, Group> & Omit<AdditionalProps, keyof StateManagerAdditionalProps<Option> | StateManagedPropKeys>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { StylesProps } from './styles';
|
|
2
|
+
import type { ClassNamesState, CommonPropsAndClassName, GroupBase, InputActionMeta, MultiValue, OnChangeValue, Option, Options, PropsValue, SingleValue } from './types';
|
|
3
|
+
export declare const noop: () => void;
|
|
4
|
+
export declare const emptyString: () => string;
|
|
5
|
+
export declare function classNames(prefix?: string | null, state?: ClassNamesState, ...classNameList: string[]): string;
|
|
6
|
+
export declare const cleanValue: (value: PropsValue<Option>) => Options<Option>;
|
|
7
|
+
export declare const cleanCommonProps: <Option, IsMulti extends boolean, Group extends GroupBase<Option>, AdditionalProps>(props: Partial<CommonPropsAndClassName<Option, IsMulti, Group>> & AdditionalProps) => Omit<AdditionalProps, keyof CommonPropsAndClassName<Option, IsMulti, Group>>;
|
|
8
|
+
export declare const getStyleProps: <Option, IsMulti extends boolean, Group extends GroupBase<Option>, Key extends keyof StylesProps<Option, IsMulti, Group>>(props: Pick<CommonPropsAndClassName<Option, IsMulti, Group>, 'cx' | 'getStyles' | 'getClassNames' | 'className'> & StylesProps<Option, IsMulti, Group>[Key], name: Key, classNamesState?: ClassNamesState) => {
|
|
9
|
+
css: import("./types").CSSObjectWithLabel;
|
|
10
|
+
className: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function handleInputChange(inputValue: string, actionMeta: InputActionMeta, onInputChange?: (newValue: string, actionMeta: InputActionMeta) => string | void): string;
|
|
13
|
+
export declare function isDocumentElement(el: HTMLElement | typeof window): el is typeof window;
|
|
14
|
+
export declare function normalizedHeight(el: HTMLElement | typeof window): number;
|
|
15
|
+
export declare function getScrollTop(el: HTMLElement | typeof window): number;
|
|
16
|
+
export declare function scrollTo(el: HTMLElement | typeof window, top: number): void;
|
|
17
|
+
export declare function getScrollParent(element: HTMLElement): HTMLElement;
|
|
18
|
+
export declare function animatedScrollTo(element: HTMLElement | typeof window, to: number, duration?: number, callback?: (element: HTMLElement | typeof window) => void): void;
|
|
19
|
+
export declare function scrollIntoView(menuEl: HTMLElement, focusedEl: HTMLElement): void;
|
|
20
|
+
export declare function getBoundingClientObj(element: HTMLElement): {
|
|
21
|
+
bottom: number;
|
|
22
|
+
height: number;
|
|
23
|
+
left: number;
|
|
24
|
+
right: number;
|
|
25
|
+
top: number;
|
|
26
|
+
width: number;
|
|
27
|
+
};
|
|
28
|
+
export interface Rect {
|
|
29
|
+
left: number;
|
|
30
|
+
right: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
height: number;
|
|
33
|
+
width: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function toKey(str: string): string;
|
|
36
|
+
export declare function isTouchCapable(): boolean;
|
|
37
|
+
export declare function isMobileDevice(): boolean;
|
|
38
|
+
export declare const supportsPassiveEvents: boolean;
|
|
39
|
+
export declare function notNullish<T>(item: T | null | undefined): item is T;
|
|
40
|
+
export declare function isArray<T>(arg: unknown): arg is readonly T[];
|
|
41
|
+
export declare function valueTernary<Option, IsMulti extends boolean>(isMulti: IsMulti | undefined, multiValue: MultiValue<Option>, singleValue: SingleValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
42
|
+
export declare function singleValueAsValue<Option, IsMulti extends boolean>(singleValue: SingleValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
43
|
+
export declare function multiValueAsValue<Option, IsMulti extends boolean>(multiValue: MultiValue<Option>): OnChangeValue<Option, IsMulti>;
|
|
44
|
+
export declare const removeProps: <Props extends object, K extends string[]>(propsObj: Props, ...properties: K) => Omit<Props, K[number]>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { AriaAttributes } from 'react';
|
|
2
|
+
import { type ActionMeta, type GroupBase, type InitialInputFocusedActionMeta, type OnChangeValue, type Options, type OptionsOrGroups } from '../types';
|
|
3
|
+
export type OptionContext = 'menu' | 'value';
|
|
4
|
+
export type GuidanceContext = 'menu' | 'input' | 'value';
|
|
5
|
+
export type AriaSelection<Option, IsMulti extends boolean> = InitialInputFocusedActionMeta<Option, IsMulti> | (ActionMeta<Option> & {
|
|
6
|
+
value: OnChangeValue<Option, IsMulti>;
|
|
7
|
+
option?: Option;
|
|
8
|
+
options?: Options<Option>;
|
|
9
|
+
});
|
|
10
|
+
export interface AriaGuidanceProps {
|
|
11
|
+
/**
|
|
12
|
+
* String value of selectProp aria-label
|
|
13
|
+
*/
|
|
14
|
+
'aria-label': AriaAttributes['aria-label'];
|
|
15
|
+
/**
|
|
16
|
+
* String indicating user's current context and available keyboard interactivity
|
|
17
|
+
*/
|
|
18
|
+
context: GuidanceContext;
|
|
19
|
+
/**
|
|
20
|
+
* Boolean value of selectProp isSearchable
|
|
21
|
+
*/
|
|
22
|
+
isSearchable: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Boolean value of selectProp isMulti
|
|
25
|
+
*/
|
|
26
|
+
isMulti: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Boolean value of selectProp isDisabled
|
|
29
|
+
*/
|
|
30
|
+
isDisabled: boolean | null;
|
|
31
|
+
/**
|
|
32
|
+
* Boolean value of selectProp tabSelectsValue
|
|
33
|
+
*/
|
|
34
|
+
tabSelectsValue: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Boolean value indicating if user focused the input for the first time
|
|
37
|
+
*/
|
|
38
|
+
isInitialFocus: boolean;
|
|
39
|
+
}
|
|
40
|
+
export type AriaOnChangeProps<Option, IsMulti extends boolean> = AriaSelection<Option, IsMulti> & {
|
|
41
|
+
/**
|
|
42
|
+
* String derived label from selected or removed option/value
|
|
43
|
+
*/
|
|
44
|
+
label: string;
|
|
45
|
+
/**
|
|
46
|
+
* Array of labels derived from multiple selected or cleared options
|
|
47
|
+
*/
|
|
48
|
+
labels: string[];
|
|
49
|
+
/**
|
|
50
|
+
* Boolean indicating if the selected menu option is disabled
|
|
51
|
+
*/
|
|
52
|
+
isDisabled: boolean | null;
|
|
53
|
+
};
|
|
54
|
+
export interface AriaOnFilterProps {
|
|
55
|
+
/**
|
|
56
|
+
* String indicating current inputValue of the input
|
|
57
|
+
*/
|
|
58
|
+
inputValue: string;
|
|
59
|
+
/**
|
|
60
|
+
* String derived from selectProp screenReaderStatus
|
|
61
|
+
*/
|
|
62
|
+
resultsMessage: string;
|
|
63
|
+
}
|
|
64
|
+
export interface AriaOnFocusProps<Option, Group extends GroupBase<Option>> {
|
|
65
|
+
/**
|
|
66
|
+
* String indicating whether the option was focused in the menu or as (multi-) value
|
|
67
|
+
*/
|
|
68
|
+
context: OptionContext;
|
|
69
|
+
/**
|
|
70
|
+
* Option that is being focused
|
|
71
|
+
*/
|
|
72
|
+
focused: Option;
|
|
73
|
+
/**
|
|
74
|
+
* Boolean indicating whether focused menu option has been disabled
|
|
75
|
+
*/
|
|
76
|
+
isDisabled: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Boolean indicating whether focused menu option is an already selected option
|
|
79
|
+
*/
|
|
80
|
+
isSelected: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* String derived label from focused option/value
|
|
83
|
+
*/
|
|
84
|
+
label: string;
|
|
85
|
+
/**
|
|
86
|
+
* Options provided as props to Select used to determine indexing
|
|
87
|
+
*/
|
|
88
|
+
options: OptionsOrGroups<Option, Group>;
|
|
89
|
+
/**
|
|
90
|
+
* selected option(s) of the Select
|
|
91
|
+
*/
|
|
92
|
+
selectValue: Options<Option>;
|
|
93
|
+
/**
|
|
94
|
+
* Boolean indicating whether user uses Apple device
|
|
95
|
+
*/
|
|
96
|
+
isAppleDevice: boolean;
|
|
97
|
+
}
|
|
98
|
+
export type AriaGuidance = (props: AriaGuidanceProps) => string;
|
|
99
|
+
export type AriaOnChange<Option, IsMulti extends boolean> = (props: AriaOnChangeProps<Option, IsMulti>) => string;
|
|
100
|
+
export type AriaOnFilter = (props: AriaOnFilterProps) => string;
|
|
101
|
+
export type AriaOnFocus<Option, Group extends GroupBase<Option> = GroupBase<Option>> = (props: AriaOnFocusProps<Option, Group>) => string;
|
|
102
|
+
export interface AriaLiveMessages<Option, IsMulti extends boolean, Group extends GroupBase<Option>> {
|
|
103
|
+
/**
|
|
104
|
+
* Guidance message used to convey component state and specific keyboard interactivity
|
|
105
|
+
*/
|
|
106
|
+
guidance?: (props: AriaGuidanceProps) => string;
|
|
107
|
+
/**
|
|
108
|
+
* OnChange message used to convey changes to value but also called when user selects disabled option
|
|
109
|
+
*/
|
|
110
|
+
onChange?: (props: AriaOnChangeProps<Option, IsMulti>) => string;
|
|
111
|
+
/**
|
|
112
|
+
* OnFilter message used to convey information about filtered results displayed in the menu
|
|
113
|
+
*/
|
|
114
|
+
onFilter?: (props: AriaOnFilterProps) => string;
|
|
115
|
+
/**
|
|
116
|
+
* OnFocus message used to convey information about the currently focused option or value
|
|
117
|
+
*/
|
|
118
|
+
onFocus?: (props: AriaOnFocusProps<Option, Group>) => string;
|
|
119
|
+
}
|
|
120
|
+
export declare const defaultAriaLiveMessages: {
|
|
121
|
+
guidance: (props: AriaGuidanceProps) => string;
|
|
122
|
+
onChange: <Option, IsMulti extends boolean>(props: AriaOnChangeProps<Option, IsMulti>) => string;
|
|
123
|
+
onFocus: <Option_1, Group extends GroupBase<Option_1>>(props: AriaOnFocusProps<Option_1, Group>) => string;
|
|
124
|
+
onFilter: (props: AriaOnFilterProps) => string;
|
|
125
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactElement, type RefAttributes } from 'react';
|
|
2
|
+
import Select from './select';
|
|
3
|
+
import { type GroupBase } from './types';
|
|
4
|
+
import { type AsyncAdditionalProps } from './use-async';
|
|
5
|
+
import { type CreatableAdditionalProps } from './use-creatable';
|
|
6
|
+
import { type StateManagerProps } from './use-state-manager';
|
|
7
|
+
export type AsyncCreatableProps<Option, IsMulti extends boolean, Group extends GroupBase<Option>> = StateManagerProps<Option, IsMulti, Group> & CreatableAdditionalProps<Option, Group> & AsyncAdditionalProps<Option, Group>;
|
|
8
|
+
type AsyncCreatableSelect = <Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: AsyncCreatableProps<Option, IsMulti, Group> & RefAttributes<Select<Option, IsMulti, Group>>) => ReactElement;
|
|
9
|
+
declare const AsyncCreatableSelect: AsyncCreatableSelect;
|
|
10
|
+
export default AsyncCreatableSelect;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactElement, type RefAttributes } from 'react';
|
|
2
|
+
import Select from './select';
|
|
3
|
+
import { type GroupBase } from './types';
|
|
4
|
+
import useAsync, { type AsyncProps } from './use-async';
|
|
5
|
+
export type { AsyncProps };
|
|
6
|
+
type AsyncSelect = <Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: AsyncProps<Option, IsMulti, Group> & RefAttributes<Select<Option, IsMulti, Group>>) => ReactElement;
|
|
7
|
+
declare const AsyncSelect: AsyncSelect;
|
|
8
|
+
export { useAsync };
|
|
9
|
+
export default AsyncSelect;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type GroupBase, type Option } from './types';
|
|
2
|
+
export declare const formatGroupLabel: <Option, Group extends GroupBase<Option>>(group: Group) => string;
|
|
3
|
+
export declare const getOptionLabel: (option: Option) => string;
|
|
4
|
+
export declare const getOptionValue: (option: Option) => string;
|
|
5
|
+
export declare const isOptionDisabled: (option: Option) => boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
6
|
+
import { jsx } from '@emotion/react';
|
|
7
|
+
import { type CommonPropsAndClassName, type CSSObjectWithLabel, type GroupBase } from '../types';
|
|
8
|
+
export interface ContainerProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> extends CommonPropsAndClassName<Option, IsMulti, Group> {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the select is disabled.
|
|
11
|
+
*/
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
isFocused: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The children to be rendered.
|
|
16
|
+
*/
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Inner props to be passed down to the container.
|
|
20
|
+
*/
|
|
21
|
+
innerProps: JSX.IntrinsicElements['div'];
|
|
22
|
+
}
|
|
23
|
+
export declare const containerCSS: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ isDisabled, isRtl, }: ContainerProps<Option, IsMulti, Group>) => CSSObjectWithLabel;
|
|
24
|
+
export declare const SelectContainer: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(props: ContainerProps<Option, IsMulti, Group>) => jsx.JSX.Element;
|
|
25
|
+
export interface ValueContainerProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> extends CommonPropsAndClassName<Option, IsMulti, Group> {
|
|
26
|
+
/**
|
|
27
|
+
* Props to be passed to the value container element.
|
|
28
|
+
*/
|
|
29
|
+
innerProps?: JSX.IntrinsicElements['div'];
|
|
30
|
+
/**
|
|
31
|
+
* The children to be rendered.
|
|
32
|
+
*/
|
|
33
|
+
children: ReactNode;
|
|
34
|
+
isDisabled: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare const valueContainerCSS: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ theme: { spacing }, isMulti, hasValue, selectProps: { controlShouldRenderValue }, }: ValueContainerProps<Option, IsMulti, Group>, unstyled: boolean) => CSSObjectWithLabel;
|
|
37
|
+
export declare const ValueContainer: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(props: ValueContainerProps<Option, IsMulti, Group>) => jsx.JSX.Element;
|
|
38
|
+
export interface IndicatorsContainerProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> extends CommonPropsAndClassName<Option, IsMulti, Group> {
|
|
39
|
+
isDisabled: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The children to be rendered.
|
|
42
|
+
*/
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Props to be passed to the indicators container element.
|
|
46
|
+
*/
|
|
47
|
+
innerProps?: {};
|
|
48
|
+
}
|
|
49
|
+
export declare const indicatorsContainerCSS: () => CSSObjectWithLabel;
|
|
50
|
+
export declare const IndicatorsContainer: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(props: IndicatorsContainerProps<Option, IsMulti, Group>) => jsx.JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode, type Ref } from 'react';
|
|
6
|
+
import { jsx } from '@emotion/react';
|
|
7
|
+
import { type CommonPropsAndClassName, type CSSObjectWithLabel, type GroupBase } from '../types';
|
|
8
|
+
export interface ControlProps<Option = unknown, IsMulti extends boolean = boolean, Group extends GroupBase<Option> = GroupBase<Option>> extends CommonPropsAndClassName<Option, IsMulti, Group> {
|
|
9
|
+
/**
|
|
10
|
+
* Children to render.
|
|
11
|
+
*/
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
innerRef: Ref<HTMLDivElement>;
|
|
14
|
+
/**
|
|
15
|
+
* The mouse down event and the innerRef to pass down to the controller element.
|
|
16
|
+
*/
|
|
17
|
+
innerProps: JSX.IntrinsicElements['div'];
|
|
18
|
+
/**
|
|
19
|
+
* Whether the select is disabled.
|
|
20
|
+
*/
|
|
21
|
+
isDisabled: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the select is focused.
|
|
24
|
+
*/
|
|
25
|
+
isFocused: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether the select is expanded.
|
|
28
|
+
*/
|
|
29
|
+
menuIsOpen: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare const css: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>({ isDisabled, isFocused, theme: { colors, borderRadius, spacing }, }: ControlProps<Option, IsMulti, Group>, unstyled: boolean) => CSSObjectWithLabel;
|
|
32
|
+
declare const Control: <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(props: ControlProps<Option, IsMulti, Group>) => jsx.JSX.Element;
|
|
33
|
+
export default Control;
|