@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.
Files changed (197) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE.md +11 -0
  3. package/README.md +10 -0
  4. package/async/package.json +15 -0
  5. package/base/package.json +15 -0
  6. package/creatable/package.json +15 -0
  7. package/dist/cjs/accessibility/helpers.js +34 -0
  8. package/dist/cjs/accessibility/index.js +74 -0
  9. package/dist/cjs/async-creatable.js +27 -0
  10. package/dist/cjs/async.js +30 -0
  11. package/dist/cjs/builtins.js +18 -0
  12. package/dist/cjs/components/containers.js +100 -0
  13. package/dist/cjs/components/control.js +67 -0
  14. package/dist/cjs/components/group.js +79 -0
  15. package/dist/cjs/components/index.js +53 -0
  16. package/dist/cjs/components/indicators.js +214 -0
  17. package/dist/cjs/components/input.js +93 -0
  18. package/dist/cjs/components/internal/a11y-text.js +34 -0
  19. package/dist/cjs/components/internal/dummy-input.js +43 -0
  20. package/dist/cjs/components/internal/index.js +34 -0
  21. package/dist/cjs/components/internal/required-input.js +43 -0
  22. package/dist/cjs/components/internal/scroll-manager.js +57 -0
  23. package/dist/cjs/components/internal/use-scroll-capture.js +132 -0
  24. package/dist/cjs/components/internal/use-scroll-lock.js +149 -0
  25. package/dist/cjs/components/live-region.js +153 -0
  26. package/dist/cjs/components/menu.js +464 -0
  27. package/dist/cjs/components/multi-value.js +129 -0
  28. package/dist/cjs/components/option.js +62 -0
  29. package/dist/cjs/components/placeholder.js +39 -0
  30. package/dist/cjs/components/single-value.js +46 -0
  31. package/dist/cjs/creatable.js +30 -0
  32. package/dist/cjs/diacritics.js +274 -0
  33. package/dist/cjs/filters.js +50 -0
  34. package/dist/cjs/index.js +55 -0
  35. package/dist/cjs/nonce-provider.js +30 -0
  36. package/dist/cjs/select.js +1803 -0
  37. package/dist/cjs/state-manager.js +31 -0
  38. package/dist/cjs/styles.js +66 -0
  39. package/dist/cjs/theme.js +42 -0
  40. package/dist/cjs/types.js +5 -0
  41. package/dist/cjs/use-async.js +156 -0
  42. package/dist/cjs/use-creatable.js +114 -0
  43. package/dist/cjs/use-state-manager.js +83 -0
  44. package/dist/cjs/utils.js +357 -0
  45. package/dist/es2019/accessibility/helpers.js +24 -0
  46. package/dist/es2019/accessibility/index.js +72 -0
  47. package/dist/es2019/async-creatable.js +17 -0
  48. package/dist/es2019/async.js +16 -0
  49. package/dist/es2019/builtins.js +4 -0
  50. package/dist/es2019/components/containers.js +100 -0
  51. package/dist/es2019/components/control.js +62 -0
  52. package/dist/es2019/components/group.js +74 -0
  53. package/dist/es2019/components/index.js +41 -0
  54. package/dist/es2019/components/indicators.js +211 -0
  55. package/dist/es2019/components/input.js +88 -0
  56. package/dist/es2019/components/internal/a11y-text.js +25 -0
  57. package/dist/es2019/components/internal/dummy-input.js +36 -0
  58. package/dist/es2019/components/internal/index.js +4 -0
  59. package/dist/es2019/components/internal/required-input.js +35 -0
  60. package/dist/es2019/components/internal/scroll-manager.js +49 -0
  61. package/dist/es2019/components/internal/use-scroll-capture.js +128 -0
  62. package/dist/es2019/components/internal/use-scroll-lock.js +143 -0
  63. package/dist/es2019/components/live-region.js +151 -0
  64. package/dist/es2019/components/menu.js +466 -0
  65. package/dist/es2019/components/multi-value.js +134 -0
  66. package/dist/es2019/components/option.js +57 -0
  67. package/dist/es2019/components/placeholder.js +34 -0
  68. package/dist/es2019/components/single-value.js +41 -0
  69. package/dist/es2019/creatable.js +15 -0
  70. package/dist/es2019/diacritics.js +264 -0
  71. package/dist/es2019/filters.js +36 -0
  72. package/dist/es2019/index.js +8 -0
  73. package/dist/es2019/nonce-provider.js +19 -0
  74. package/dist/es2019/select.js +1766 -0
  75. package/dist/es2019/state-manager.js +22 -0
  76. package/dist/es2019/styles.js +56 -0
  77. package/dist/es2019/theme.js +36 -0
  78. package/dist/es2019/types.js +1 -0
  79. package/dist/es2019/use-async.js +117 -0
  80. package/dist/es2019/use-creatable.js +81 -0
  81. package/dist/es2019/use-state-manager.js +60 -0
  82. package/dist/es2019/utils.js +309 -0
  83. package/dist/esm/accessibility/helpers.js +24 -0
  84. package/dist/esm/accessibility/index.js +68 -0
  85. package/dist/esm/async-creatable.js +17 -0
  86. package/dist/esm/async.js +16 -0
  87. package/dist/esm/builtins.js +12 -0
  88. package/dist/esm/components/containers.js +96 -0
  89. package/dist/esm/components/control.js +62 -0
  90. package/dist/esm/components/group.js +74 -0
  91. package/dist/esm/components/index.js +43 -0
  92. package/dist/esm/components/indicators.js +209 -0
  93. package/dist/esm/components/input.js +88 -0
  94. package/dist/esm/components/internal/a11y-text.js +27 -0
  95. package/dist/esm/components/internal/dummy-input.js +37 -0
  96. package/dist/esm/components/internal/index.js +4 -0
  97. package/dist/esm/components/internal/required-input.js +36 -0
  98. package/dist/esm/components/internal/scroll-manager.js +49 -0
  99. package/dist/esm/components/internal/use-scroll-capture.js +126 -0
  100. package/dist/esm/components/internal/use-scroll-lock.js +143 -0
  101. package/dist/esm/components/live-region.js +148 -0
  102. package/dist/esm/components/menu.js +460 -0
  103. package/dist/esm/components/multi-value.js +122 -0
  104. package/dist/esm/components/option.js +57 -0
  105. package/dist/esm/components/placeholder.js +34 -0
  106. package/dist/esm/components/single-value.js +41 -0
  107. package/dist/esm/creatable.js +15 -0
  108. package/dist/esm/diacritics.js +268 -0
  109. package/dist/esm/filters.js +43 -0
  110. package/dist/esm/index.js +8 -0
  111. package/dist/esm/nonce-provider.js +20 -0
  112. package/dist/esm/select.js +1794 -0
  113. package/dist/esm/state-manager.js +22 -0
  114. package/dist/esm/styles.js +58 -0
  115. package/dist/esm/theme.js +36 -0
  116. package/dist/esm/types.js +1 -0
  117. package/dist/esm/use-async.js +149 -0
  118. package/dist/esm/use-creatable.js +107 -0
  119. package/dist/esm/use-state-manager.js +76 -0
  120. package/dist/esm/utils.js +328 -0
  121. package/dist/types/accessibility/helpers.d.ts +5 -0
  122. package/dist/types/accessibility/index.d.ts +125 -0
  123. package/dist/types/async-creatable.d.ts +10 -0
  124. package/dist/types/async.d.ts +9 -0
  125. package/dist/types/builtins.d.ts +5 -0
  126. package/dist/types/components/containers.d.ts +50 -0
  127. package/dist/types/components/control.d.ts +33 -0
  128. package/dist/types/components/group.d.ts +53 -0
  129. package/dist/types/components/index.d.ts +73 -0
  130. package/dist/types/components/indicators.d.ts +72 -0
  131. package/dist/types/components/input.d.ts +33 -0
  132. package/dist/types/components/internal/a11y-text.d.ts +8 -0
  133. package/dist/types/components/internal/dummy-input.d.ts +9 -0
  134. package/dist/types/components/internal/index.d.ts +4 -0
  135. package/dist/types/components/internal/required-input.d.ts +10 -0
  136. package/dist/types/components/internal/scroll-manager.d.ts +17 -0
  137. package/dist/types/components/internal/use-scroll-capture.d.ts +12 -0
  138. package/dist/types/components/internal/use-scroll-lock.d.ts +9 -0
  139. package/dist/types/components/live-region.d.ts +24 -0
  140. package/dist/types/components/menu.d.ts +130 -0
  141. package/dist/types/components/multi-value.d.ts +47 -0
  142. package/dist/types/components/option.d.ts +49 -0
  143. package/dist/types/components/placeholder.d.ts +22 -0
  144. package/dist/types/components/single-value.d.ts +28 -0
  145. package/dist/types/creatable.d.ts +10 -0
  146. package/dist/types/diacritics.d.ts +1 -0
  147. package/dist/types/filters.d.ts +15 -0
  148. package/dist/types/index.d.ts +28 -0
  149. package/dist/types/nonce-provider.d.ts +8 -0
  150. package/dist/types/select.d.ts +616 -0
  151. package/dist/types/state-manager.d.ts +17 -0
  152. package/dist/types/styles.d.ts +68 -0
  153. package/dist/types/theme.d.ts +27 -0
  154. package/dist/types/types.d.ts +134 -0
  155. package/dist/types/use-async.d.ts +31 -0
  156. package/dist/types/use-creatable.d.ts +46 -0
  157. package/dist/types/use-state-manager.d.ts +15 -0
  158. package/dist/types/utils.d.ts +44 -0
  159. package/dist/types-ts4.5/accessibility/helpers.d.ts +5 -0
  160. package/dist/types-ts4.5/accessibility/index.d.ts +125 -0
  161. package/dist/types-ts4.5/async-creatable.d.ts +10 -0
  162. package/dist/types-ts4.5/async.d.ts +9 -0
  163. package/dist/types-ts4.5/builtins.d.ts +5 -0
  164. package/dist/types-ts4.5/components/containers.d.ts +50 -0
  165. package/dist/types-ts4.5/components/control.d.ts +33 -0
  166. package/dist/types-ts4.5/components/group.d.ts +53 -0
  167. package/dist/types-ts4.5/components/index.d.ts +73 -0
  168. package/dist/types-ts4.5/components/indicators.d.ts +72 -0
  169. package/dist/types-ts4.5/components/input.d.ts +33 -0
  170. package/dist/types-ts4.5/components/internal/a11y-text.d.ts +8 -0
  171. package/dist/types-ts4.5/components/internal/dummy-input.d.ts +9 -0
  172. package/dist/types-ts4.5/components/internal/index.d.ts +4 -0
  173. package/dist/types-ts4.5/components/internal/required-input.d.ts +10 -0
  174. package/dist/types-ts4.5/components/internal/scroll-manager.d.ts +17 -0
  175. package/dist/types-ts4.5/components/internal/use-scroll-capture.d.ts +12 -0
  176. package/dist/types-ts4.5/components/internal/use-scroll-lock.d.ts +9 -0
  177. package/dist/types-ts4.5/components/live-region.d.ts +24 -0
  178. package/dist/types-ts4.5/components/menu.d.ts +130 -0
  179. package/dist/types-ts4.5/components/multi-value.d.ts +47 -0
  180. package/dist/types-ts4.5/components/option.d.ts +49 -0
  181. package/dist/types-ts4.5/components/placeholder.d.ts +22 -0
  182. package/dist/types-ts4.5/components/single-value.d.ts +28 -0
  183. package/dist/types-ts4.5/creatable.d.ts +10 -0
  184. package/dist/types-ts4.5/diacritics.d.ts +1 -0
  185. package/dist/types-ts4.5/filters.d.ts +15 -0
  186. package/dist/types-ts4.5/index.d.ts +28 -0
  187. package/dist/types-ts4.5/nonce-provider.d.ts +8 -0
  188. package/dist/types-ts4.5/select.d.ts +616 -0
  189. package/dist/types-ts4.5/state-manager.d.ts +17 -0
  190. package/dist/types-ts4.5/styles.d.ts +68 -0
  191. package/dist/types-ts4.5/theme.d.ts +27 -0
  192. package/dist/types-ts4.5/types.d.ts +134 -0
  193. package/dist/types-ts4.5/use-async.d.ts +31 -0
  194. package/dist/types-ts4.5/use-creatable.d.ts +46 -0
  195. package/dist/types-ts4.5/use-state-manager.d.ts +15 -0
  196. package/dist/types-ts4.5/utils.d.ts +44 -0
  197. package/package.json +83 -0
@@ -0,0 +1,17 @@
1
+ import { type ReactElement, type RefAttributes } from 'react';
2
+ import Select from './select';
3
+ import { type GroupBase } from './types';
4
+ import { type StateManagerProps } from './use-state-manager';
5
+ export type { StateManagerProps };
6
+ /**
7
+ * __StateManagedSelect__
8
+ *
9
+ * A state managed select {description}.
10
+ *
11
+ * - [Examples](https://atlassian.design/components/{packageName}/examples)
12
+ * - [Code](https://atlassian.design/components/{packageName}/code)
13
+ * - [Usage](https://atlassian.design/components/{packageName}/usage)
14
+ */
15
+ type StateManagedSelect = <Option = unknown, IsMulti extends boolean = false, Group extends GroupBase<Option> = GroupBase<Option>>(props: StateManagerProps<Option, IsMulti, Group> & RefAttributes<Select<Option, IsMulti, Group>>) => ReactElement;
16
+ declare const StateManagedSelect: StateManagedSelect;
17
+ export default StateManagedSelect;
@@ -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]>;
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@atlaskit/react-select",
3
+ "version": "0.0.2",
4
+ "description": "A forked version of react-select to only be used in atlaskit/select",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Design System Team",
12
+ "inPublicMirror": false,
13
+ "releaseModel": "continuous"
14
+ },
15
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
16
+ "main": "dist/cjs/index.js",
17
+ "module": "dist/esm/index.js",
18
+ "module:es2019": "dist/es2019/index.js",
19
+ "types": "dist/types/index.d.ts",
20
+ "sideEffects": false,
21
+ "atlaskit:src": "src/index.tsx",
22
+ "af:exports": {
23
+ ".": "./src/index.tsx",
24
+ "./base": "./src/select.tsx",
25
+ "./async": "./src/async.tsx",
26
+ "./creatable": "./src/creatable.tsx"
27
+ },
28
+ "dependencies": {
29
+ "@atlaskit/ds-lib": "^2.5.0",
30
+ "@babel/runtime": "^7.0.0",
31
+ "@emotion/cache": "^11.10.0",
32
+ "@emotion/react": "^11.7.1",
33
+ "@floating-ui/dom": "^1.0.1",
34
+ "memoize-one": "^6.0.0",
35
+ "react-dom": "^16.8.0",
36
+ "use-isomorphic-layout-effect": "^1.1.2"
37
+ },
38
+ "peerDependencies": {
39
+ "react": "^16.8.0"
40
+ },
41
+ "devDependencies": {
42
+ "@af/integration-testing": "*",
43
+ "@af/visual-regression": "*",
44
+ "@atlaskit/ssr": "*",
45
+ "@atlaskit/visual-regression": "*",
46
+ "@testing-library/react": "^12.1.5",
47
+ "@testing-library/user-event": "^14.4.3",
48
+ "jest-in-case": "^1.0.2",
49
+ "typescript": "~5.4.2",
50
+ "user-agent-data-types": "^0.4.2",
51
+ "wait-for-expect": "^1.2.0"
52
+ },
53
+ "techstack": {
54
+ "@atlassian/frontend": {
55
+ "import-structure": [
56
+ "atlassian-conventions"
57
+ ],
58
+ "circular-dependencies": "file-and-folder-level"
59
+ },
60
+ "@repo/internal": {
61
+ "design-system": "v1",
62
+ "dom-events": "use-bind-event-listener",
63
+ "analytics": "analytics-next",
64
+ "ui-components": [
65
+ "lite-mode"
66
+ ],
67
+ "deprecation": "no-deprecated-imports",
68
+ "styling": [
69
+ "static",
70
+ "emotion"
71
+ ]
72
+ }
73
+ },
74
+ "homepage": "https://atlassian.design/components",
75
+ "typesVersions": {
76
+ ">=4.5 <4.9": {
77
+ "*": [
78
+ "dist/types-ts4.5/*",
79
+ "dist/types-ts4.5/index.d.ts"
80
+ ]
81
+ }
82
+ }
83
+ }