@leafygreen-ui/combobox 0.9.0
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/README.md +126 -0
- package/dist/Chip.d.ts +4 -0
- package/dist/Chip.d.ts.map +1 -0
- package/dist/Combobox.d.ts +7 -0
- package/dist/Combobox.d.ts.map +1 -0
- package/dist/Combobox.styles.d.ts +44 -0
- package/dist/Combobox.styles.d.ts.map +1 -0
- package/dist/Combobox.types.d.ts +230 -0
- package/dist/Combobox.types.d.ts.map +1 -0
- package/dist/ComboboxContext.d.ts +15 -0
- package/dist/ComboboxContext.d.ts.map +1 -0
- package/dist/ComboboxGroup.d.ts +9 -0
- package/dist/ComboboxGroup.d.ts.map +1 -0
- package/dist/ComboboxOption.d.ts +13 -0
- package/dist/ComboboxOption.d.ts.map +1 -0
- package/dist/ComboboxTestUtils.d.ts +126 -0
- package/dist/ComboboxTestUtils.d.ts.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/util.d.ts +53 -0
- package/dist/util.d.ts.map +1 -0
- package/package.json +32 -0
- package/src/Chip.tsx +223 -0
- package/src/Combobox.spec.tsx +1136 -0
- package/src/Combobox.story.tsx +248 -0
- package/src/Combobox.styles.ts +354 -0
- package/src/Combobox.tsx +1180 -0
- package/src/Combobox.types.ts +293 -0
- package/src/ComboboxContext.tsx +21 -0
- package/src/ComboboxGroup.tsx +61 -0
- package/src/ComboboxOption.tsx +200 -0
- package/src/ComboboxTestUtils.tsx +287 -0
- package/src/index.ts +3 -0
- package/src/util.tsx +117 -0
- package/tsconfig.json +47 -0
- package/tsconfig.tsbuildinfo +3889 -0
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Combobox
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
#### [View on MongoDB.design](https://www.mongodb.design/component/combobox/example/)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Yarn
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
yarn add @leafygreen-ui/combobox
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### NPM
|
|
16
|
+
|
|
17
|
+
```shell
|
|
18
|
+
npm install @leafygreen-ui/combobox
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
<Combobox
|
|
25
|
+
label="Choose a fruit"
|
|
26
|
+
description="Please pick one"
|
|
27
|
+
placeholder="Select fruit"
|
|
28
|
+
>
|
|
29
|
+
<ComboboxOption value="apple" />
|
|
30
|
+
<ComboboxOption value="banana" />
|
|
31
|
+
<ComboboxOption value="carrot" />
|
|
32
|
+
<ComboboxOption value="dragonfruit" />
|
|
33
|
+
<ComboboxGroup label="Peppers">
|
|
34
|
+
<ComboboxOption value="cayenne" />
|
|
35
|
+
<ComboboxOption value="habanero" />
|
|
36
|
+
<ComboboxOption value="jalapeno" displayName="Jalapeño" />
|
|
37
|
+
</ComboboxGroup>
|
|
38
|
+
</Combobox>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Output HTML**
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<div>
|
|
45
|
+
<div>
|
|
46
|
+
<label id="combobox-label-1" for="combobox-input-1"> Choose a fruit </label>
|
|
47
|
+
<p>Please pick one</p>
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<div
|
|
51
|
+
role="combobox"
|
|
52
|
+
aria-expanded="true"
|
|
53
|
+
aria-controls="combobox-menu-1"
|
|
54
|
+
aria-owns="combobox-menu-1"
|
|
55
|
+
tabindex="-1"
|
|
56
|
+
data-disabled="false"
|
|
57
|
+
data-state="none"
|
|
58
|
+
>
|
|
59
|
+
<div>
|
|
60
|
+
<input
|
|
61
|
+
aria-label="Choose a fruit"
|
|
62
|
+
aria-autocomplete="list"
|
|
63
|
+
aria-controls="combobox-menu-1"
|
|
64
|
+
aria-labelledby="combobox-label-1"
|
|
65
|
+
id="combobox-input-1"
|
|
66
|
+
placeholder="Select fruit"
|
|
67
|
+
value=""
|
|
68
|
+
/>
|
|
69
|
+
</div>
|
|
70
|
+
<svg aria-label="Caret Down Icon">...</svg>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Properties
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Description | Default |
|
|
79
|
+
| ---------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
|
|
80
|
+
| children | <ComboboxOption>, <ComboboxGroup> | Define the Combobox Options by passing children | |
|
|
81
|
+
| multiselect | boolean | Defines whether a user can select multiple options, or only a single option. When using TypeScript, `multiselect` affects the valid values of `initialValue`, `value`, and `onChange` | false |
|
|
82
|
+
| initialValue | Array<string>, string | The initial selection. Must be a string for a single-select, or an array of strings for multiselect. Changing the `initialValue` after initial render will not change the selection. | |
|
|
83
|
+
| value | Array<string>, string | The controlled value of the Combobox. Must be a string for a single-select, or an array of strings for multiselect. Changing `value` after initial render _will_ affect the selection. | |
|
|
84
|
+
| onChange | (Array<string>) => void, (string) => void | A callback called when the selection changes. Callback recieves a single argument that is the new selection, either string, or string array | |
|
|
85
|
+
| overflow | 'expand-y', 'expand-x', 'scroll-x' | Defines the overflow behavior of a multiselect combobox. **expand-y**: Combobox has fixed width, and additional selections will cause the element to grow in the block direction. **expand-x**: Combobox has fixed height, and additional selections will cause the elemenet to grow in the inline direction. **scroll-x**: Combobox has fixed height and width, and additional selections will cause the element to be scrollable in the x (horizontal) direction. | 'expand-y' |
|
|
86
|
+
| label | string | An accessible label for the input, rendered in a `<label>` to the DOM | |
|
|
87
|
+
| aria-label | string | An accessible label for the input, used only for screen-readers | |
|
|
88
|
+
| description | string | A description for the input | |
|
|
89
|
+
| placeholder | string | A placeholder for the input element. Uses the native `placeholder` attribute. | 'Select' |
|
|
90
|
+
| disabled | boolean | Disables all interaction with the component | false |
|
|
91
|
+
| size | 'default' | Defines the visual size of the component | 'default' |
|
|
92
|
+
| darkMode | boolean | Toggles dark mode | false |
|
|
93
|
+
| state | 'error', 'none' | The error state of the component. Defines whether the error message is displayed. | 'none' |
|
|
94
|
+
| errorMessage | string | The message shown below the input when `state` is `error` | |
|
|
95
|
+
| onFilter | (value: string) => void | A callback called when the search input changes. Recieves a single argument that is the current input value. Use this callback to set `searchState` and/or `filteredOptions` appropriately | |
|
|
96
|
+
| searchState | 'unset', 'error', 'loading' | The state of search results. Toggles search messages within the menu. | 'unset' |
|
|
97
|
+
| searchErrorMessage | string | A message shown within the menu when `searchState` is `error` | 'Could not get results!' |
|
|
98
|
+
| searchLoadingMessage | string | A message shown within the menu when `searchState` is `loading` | 'Loading results...' |
|
|
99
|
+
| searchEmptyMessage | string | A message shown within the menu when there are no options passed in as children, or `filteredOptions` is an empty array | 'No results found' |
|
|
100
|
+
| clearable | boolean | Defines whether the Clear button appears to the right of the input | |
|
|
101
|
+
| onClear | (e: MouseEvent) => void | A callback fired when the Clear button is pressed. Fired _after_ `onChange`, and _before_ `onFilter` | |
|
|
102
|
+
| filteredOptions | Array<string>, null | An array used to define which options are displayed. Do not remove Options from the JSX children, as this will affect the selected options | |
|
|
103
|
+
| chipTruncationLocation | 'start', 'middle', 'end', 'none' | Defines where the ellipses appear in a Chip when the length exceeds the `chipCharacterLimit` | 'none' |
|
|
104
|
+
| chipCharacterLimit | number | Defined the character limit of a multiselect Chip before they start truncating. Note: the three ellipses dots are included in the character limit. | 12 |
|
|
105
|
+
| className | string | Styling prop | |
|
|
106
|
+
|
|
107
|
+
# ComboboxOption
|
|
108
|
+
|
|
109
|
+
## Props
|
|
110
|
+
|
|
111
|
+
| Prop | Type | Description | Default |
|
|
112
|
+
| ----------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
113
|
+
| value | string | The internal value of the option. Used as the identifier in Combobox `initialValue`, `value` and `filteredOptions`. When undefined, this is set to `_.kebabCase(displayName)` | |
|
|
114
|
+
| displayName | string | The display value of the option. Used as the rendered string within the menu and chips. When undefined, this is set to `value` | |
|
|
115
|
+
| glyph | <Icon/> | The icon to display to the left of the option in the menu. | |
|
|
116
|
+
| className | string | Styling prop | |
|
|
117
|
+
|
|
118
|
+
# ComboboxGroup
|
|
119
|
+
|
|
120
|
+
## Props
|
|
121
|
+
|
|
122
|
+
| Prop | Type | Description | Default |
|
|
123
|
+
| --------- | ---------------- | ------------------------------ | ------- |
|
|
124
|
+
| label | string | Label for the group of options | |
|
|
125
|
+
| children | <ComboboxOption> | Options in the group | |
|
|
126
|
+
| className | string | Styling prop | |
|
package/dist/Chip.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../src/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,SAAS,EAAgB,MAAM,kBAAkB,CAAC;AAmG3D,eAAO,MAAM,IAAI,mFAyHhB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxProps } from './Combobox.types';
|
|
3
|
+
/**
|
|
4
|
+
* Component
|
|
5
|
+
*/
|
|
6
|
+
export default function Combobox<M extends boolean>({ children, label, description, placeholder, 'aria-label': ariaLabel, disabled, size, darkMode, state, errorMessage, searchState, searchEmptyMessage, searchErrorMessage, searchLoadingMessage, filteredOptions, onFilter, clearable, onClear, overflow, multiselect, initialValue, onChange, value, chipTruncationLocation, chipCharacterLimit, className, ...rest }: ComboboxProps<M>): JSX.Element;
|
|
7
|
+
//# sourceMappingURL=Combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../src/Combobox.tsx"],"names":[],"mappings":";AAuBA,OAAO,EACL,aAAa,EAId,MAAM,kBAAkB,CAAC;AAuB1B;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,EAClD,QAAQ,EACR,KAAK,EACL,WAAW,EACX,WAAsB,EACtB,YAAY,EAAE,SAAS,EACvB,QAAgB,EAChB,IAAgB,EAChB,QAAgB,EAChB,KAAc,EACd,YAAY,EACZ,WAAqB,EACrB,kBAAuC,EACvC,kBAA6C,EAC7C,oBAA2C,EAC3C,eAAe,EACf,QAAQ,EACR,SAAgB,EAChB,OAAO,EACP,QAAqB,EACrB,WAAwB,EACxB,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,sBAAsB,EACtB,kBAAuB,EACvB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,aAAa,CAAC,CAAC,CAAC,eAykClB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles
|
|
3
|
+
*/
|
|
4
|
+
import { ComboboxSize, Overflow, State } from './Combobox.types';
|
|
5
|
+
export declare const comboboxParentStyle: ({ darkMode, size, overflow, }: {
|
|
6
|
+
darkMode: boolean;
|
|
7
|
+
size: ComboboxSize;
|
|
8
|
+
overflow: Overflow;
|
|
9
|
+
}) => string;
|
|
10
|
+
export declare const comboboxStyle: string;
|
|
11
|
+
export declare const interactionRingStyle: string;
|
|
12
|
+
export declare const interactionRingColor: ({ state, darkMode, }: {
|
|
13
|
+
state: State;
|
|
14
|
+
darkMode: boolean;
|
|
15
|
+
}) => {
|
|
16
|
+
hovered: "#8F221B" | undefined;
|
|
17
|
+
} | {
|
|
18
|
+
hovered: "#FCEBE2" | undefined;
|
|
19
|
+
};
|
|
20
|
+
export declare const inputWrapperStyle: ({ overflow, isOpen, selection, value, }: {
|
|
21
|
+
overflow: Overflow;
|
|
22
|
+
isOpen: boolean;
|
|
23
|
+
selection: string | Array<string> | null;
|
|
24
|
+
value?: string | undefined;
|
|
25
|
+
}) => string;
|
|
26
|
+
export declare const inputElementStyle: string;
|
|
27
|
+
export declare const clearButton: string;
|
|
28
|
+
export declare const errorMessageStyle: string;
|
|
29
|
+
export declare const endIcon: string;
|
|
30
|
+
export declare const loadingIconStyle: string;
|
|
31
|
+
/**
|
|
32
|
+
* Menu styles
|
|
33
|
+
*/
|
|
34
|
+
export declare const menuWrapperStyle: ({ darkMode, size, width, }: {
|
|
35
|
+
darkMode: boolean;
|
|
36
|
+
size: ComboboxSize;
|
|
37
|
+
width?: number | undefined;
|
|
38
|
+
}) => string;
|
|
39
|
+
export declare const menuStyle: ({ maxHeight }: {
|
|
40
|
+
maxHeight: number;
|
|
41
|
+
}) => string;
|
|
42
|
+
export declare const menuList: string;
|
|
43
|
+
export declare const menuMessage: string;
|
|
44
|
+
//# sourceMappingURL=Combobox.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.styles.d.ts","sourceRoot":"","sources":["../src/Combobox.styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEjE,eAAO,MAAM,mBAAmB;cAKpB,OAAO;UACX,YAAY;cACR,QAAQ;YAoDnB,CAAC;AAEF,eAAO,MAAM,aAAa,QAgCzB,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAEhC,CAAC;AAEF,eAAO,MAAM,oBAAoB;WAIxB,KAAK;cACF,OAAO;;;;;CAWlB,CAAC;AAEF,eAAO,MAAM,iBAAiB;cAMlB,QAAQ;YACV,OAAO;eACJ,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,IAAI;;YA8EzC,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAmB7B,CAAC;AAEF,eAAO,MAAM,WAAW,QAGvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAK7B,CAAC;AAEF,eAAO,MAAM,OAAO,QAEnB,CAAC;AAUF,eAAO,MAAM,gBAAgB,QAE5B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;cAKjB,OAAO;UACX,YAAY;;YA4CnB,CAAC;AAEF,eAAO,MAAM,SAAS;eAAgC,MAAM;YAc3D,CAAC;AAEF,eAAO,MAAM,QAAQ,QAIpB,CAAC;AAEF,eAAO,MAAM,WAAW,QAYvB,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { Either } from '@leafygreen-ui/lib';
|
|
3
|
+
/**
|
|
4
|
+
* Prop Enums & Types
|
|
5
|
+
*/
|
|
6
|
+
export declare const ComboboxSize: {
|
|
7
|
+
readonly default: "default";
|
|
8
|
+
};
|
|
9
|
+
export declare type ComboboxSize = typeof ComboboxSize[keyof typeof ComboboxSize];
|
|
10
|
+
export declare const TrunctationLocation: {
|
|
11
|
+
readonly start: "start";
|
|
12
|
+
readonly middle: "middle";
|
|
13
|
+
readonly end: "end";
|
|
14
|
+
readonly none: "none";
|
|
15
|
+
};
|
|
16
|
+
export declare type TrunctationLocation = typeof TrunctationLocation[keyof typeof TrunctationLocation];
|
|
17
|
+
export declare const Overflow: {
|
|
18
|
+
readonly expandY: "expand-y";
|
|
19
|
+
readonly expandX: "expand-x";
|
|
20
|
+
readonly scrollY: "scroll-x";
|
|
21
|
+
};
|
|
22
|
+
export declare type Overflow = typeof Overflow[keyof typeof Overflow];
|
|
23
|
+
export declare const State: {
|
|
24
|
+
readonly error: "error";
|
|
25
|
+
readonly none: "none";
|
|
26
|
+
};
|
|
27
|
+
export declare type State = typeof State[keyof typeof State];
|
|
28
|
+
export declare const SearchState: {
|
|
29
|
+
readonly unset: "unset";
|
|
30
|
+
readonly error: "error";
|
|
31
|
+
readonly loading: "loading";
|
|
32
|
+
};
|
|
33
|
+
export declare type SearchState = typeof SearchState[keyof typeof SearchState];
|
|
34
|
+
/**
|
|
35
|
+
* Generic Typing
|
|
36
|
+
*/
|
|
37
|
+
export declare type SelectValueType<M extends boolean> = M extends true ? Array<string> : string | null;
|
|
38
|
+
export declare type onChangeType<M extends boolean> = M extends true ? (value: SelectValueType<true>) => void : (value: SelectValueType<false>) => void;
|
|
39
|
+
export declare function getNullSelection<M extends boolean>(multiselect: M): SelectValueType<M>;
|
|
40
|
+
/**
|
|
41
|
+
* Combobox Props
|
|
42
|
+
*/
|
|
43
|
+
export interface ComboboxMultiselectProps<M extends boolean> {
|
|
44
|
+
/**
|
|
45
|
+
* Defines whether a user can select multiple options, or only a single option.
|
|
46
|
+
* When using TypeScript, `multiselect` affects the valid values of `initialValue`, `value`, and `onChange`
|
|
47
|
+
*/
|
|
48
|
+
multiselect?: M;
|
|
49
|
+
/**
|
|
50
|
+
* The initial selection.
|
|
51
|
+
* Must be a string for a single-select, or an array of strings for multiselect.
|
|
52
|
+
* Changing the initialValue after initial render will not change the selection.
|
|
53
|
+
*/
|
|
54
|
+
initialValue?: SelectValueType<M>;
|
|
55
|
+
/**
|
|
56
|
+
* A callback called when the selection changes.
|
|
57
|
+
* Callback recieves a single argument that is the new selection, either string, or string array
|
|
58
|
+
*/
|
|
59
|
+
onChange?: onChangeType<M>;
|
|
60
|
+
/**
|
|
61
|
+
* The controlled value of the Combobox.
|
|
62
|
+
* Must be a string for a single-select, or an array of strings for multiselect.
|
|
63
|
+
* Changing value after initial render will affect the selection.
|
|
64
|
+
*/
|
|
65
|
+
value?: SelectValueType<M>;
|
|
66
|
+
/**
|
|
67
|
+
* Defines the overflow behavior of a multiselect combobox.
|
|
68
|
+
*
|
|
69
|
+
* `expand-y`: Combobox has fixed width, and additional selections will cause the element to grow in the block direction.
|
|
70
|
+
*
|
|
71
|
+
* `expand-x`: Combobox has fixed height, and additional selections will cause the elemenet to grow in the inline direction.
|
|
72
|
+
*
|
|
73
|
+
* `scroll-x`: Combobox has fixed height and width, and additional selections will cause the element to be scrollable in the x (horizontal) direction.
|
|
74
|
+
*/
|
|
75
|
+
overflow?: M extends true ? Overflow : undefined;
|
|
76
|
+
}
|
|
77
|
+
export interface BaseComboboxProps {
|
|
78
|
+
/**
|
|
79
|
+
* Defines the Combobox Options by passing children. Must be `ComboboxOption` or `ComboboxGroup`
|
|
80
|
+
*/
|
|
81
|
+
children?: ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* An accessible label for the input, rendered in a <label> to the DOM
|
|
84
|
+
*/
|
|
85
|
+
label?: string;
|
|
86
|
+
/**
|
|
87
|
+
* An accessible label for the input, used only for screen-readers
|
|
88
|
+
*/
|
|
89
|
+
'aria-label'?: string;
|
|
90
|
+
/**
|
|
91
|
+
* A description for the input
|
|
92
|
+
*/
|
|
93
|
+
description?: string;
|
|
94
|
+
/**
|
|
95
|
+
* A placeholder for the input element. Uses the native `placeholder` attribute.
|
|
96
|
+
*/
|
|
97
|
+
placeholder?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Disables all interaction with the component
|
|
100
|
+
*/
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Defines the visual size of the component
|
|
104
|
+
*/
|
|
105
|
+
size?: ComboboxSize;
|
|
106
|
+
/**
|
|
107
|
+
* Toggles Dark Mode
|
|
108
|
+
*/
|
|
109
|
+
darkMode?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* The error state of the component. Defines whether the error message is displayed.
|
|
112
|
+
*/
|
|
113
|
+
state?: State;
|
|
114
|
+
/**
|
|
115
|
+
* The message shown below the input when state is `error`
|
|
116
|
+
*/
|
|
117
|
+
errorMessage?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The state of search results. Toggles search messages within the menu.
|
|
120
|
+
*/
|
|
121
|
+
searchState?: SearchState;
|
|
122
|
+
/**
|
|
123
|
+
* A message shown within the menu when there are no options passed in as children, or `filteredOptions` is an empty array
|
|
124
|
+
*/
|
|
125
|
+
searchEmptyMessage?: string;
|
|
126
|
+
/**
|
|
127
|
+
* A message shown within the menu when searchState is `error`
|
|
128
|
+
*/
|
|
129
|
+
searchErrorMessage?: string;
|
|
130
|
+
/**
|
|
131
|
+
* A message shown within the menu when searchState is `loading`
|
|
132
|
+
*/
|
|
133
|
+
searchLoadingMessage?: string;
|
|
134
|
+
/**
|
|
135
|
+
* A callback called when the search input changes.
|
|
136
|
+
* Recieves a single argument that is the current input value.
|
|
137
|
+
* Use this callback to set `searchState` and/or `filteredOptions` appropriately
|
|
138
|
+
*/
|
|
139
|
+
onFilter?: (value: string) => void;
|
|
140
|
+
/**
|
|
141
|
+
* Defines whether the Clear button appears to the right of the input.
|
|
142
|
+
*/
|
|
143
|
+
clearable?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* A callback fired when the Clear button is pressed.
|
|
146
|
+
* Fired _after_ `onChange`, and _before_ `onFilter`
|
|
147
|
+
*/
|
|
148
|
+
onClear?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
149
|
+
/**
|
|
150
|
+
* An array used to define which options are displayed.
|
|
151
|
+
* Do not remove options from the JSX children, as this will affect the selected options
|
|
152
|
+
*/
|
|
153
|
+
filteredOptions?: Array<string>;
|
|
154
|
+
/**
|
|
155
|
+
* Defines where the ellipses appear in a Chip when the length exceeds the `chipCharacterLimit`
|
|
156
|
+
*/
|
|
157
|
+
chipTruncationLocation?: TrunctationLocation;
|
|
158
|
+
/**
|
|
159
|
+
* Defined the character limit of a multiselect Chip before they start truncating.
|
|
160
|
+
* Note: the three ellipses dots are included in the character limit.
|
|
161
|
+
*/
|
|
162
|
+
chipCharacterLimit?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Styling prop
|
|
165
|
+
*/
|
|
166
|
+
className?: string;
|
|
167
|
+
}
|
|
168
|
+
export declare type ComboboxProps<M extends boolean> = Either<BaseComboboxProps & ComboboxMultiselectProps<M>, 'label' | 'aria-label'>;
|
|
169
|
+
/**
|
|
170
|
+
* Combobox Option Props
|
|
171
|
+
*/
|
|
172
|
+
interface BaseComboboxOptionProps {
|
|
173
|
+
/**
|
|
174
|
+
* The internal value of the option. Used as the identifier in Combobox `initialValue`, value and filteredOptions.
|
|
175
|
+
* When undefined, this is set to `_.kebabCase(displayName)`
|
|
176
|
+
*/
|
|
177
|
+
value?: string;
|
|
178
|
+
/**
|
|
179
|
+
* The display value of the option. Used as the rendered string within the menu and chips.
|
|
180
|
+
* When undefined, this is set to `value`
|
|
181
|
+
*/
|
|
182
|
+
displayName?: string;
|
|
183
|
+
/**
|
|
184
|
+
* The icon to display to the left of the option in the menu.
|
|
185
|
+
*/
|
|
186
|
+
glyph?: ReactElement;
|
|
187
|
+
/**
|
|
188
|
+
* Styling Prop
|
|
189
|
+
*/
|
|
190
|
+
className?: string;
|
|
191
|
+
}
|
|
192
|
+
export declare type ComboboxOptionProps = Either<BaseComboboxOptionProps, 'value' | 'displayName'>;
|
|
193
|
+
export interface InternalComboboxOptionProps {
|
|
194
|
+
value: string;
|
|
195
|
+
displayName: string;
|
|
196
|
+
isSelected: boolean;
|
|
197
|
+
isFocused: boolean;
|
|
198
|
+
setSelected: () => void;
|
|
199
|
+
glyph?: ReactElement;
|
|
200
|
+
className?: string;
|
|
201
|
+
index: number;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Combobox Group Props
|
|
205
|
+
*/
|
|
206
|
+
export interface ComboboxGroupProps {
|
|
207
|
+
/**
|
|
208
|
+
* Label for the group of options
|
|
209
|
+
*/
|
|
210
|
+
label: string;
|
|
211
|
+
/**
|
|
212
|
+
* Options in the group. Must be one or more `ComboboxOption` components
|
|
213
|
+
*/
|
|
214
|
+
children: React.ReactNode;
|
|
215
|
+
/**
|
|
216
|
+
* Styling prop
|
|
217
|
+
*/
|
|
218
|
+
className?: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Combobox Chip
|
|
222
|
+
*/
|
|
223
|
+
export interface ChipProps {
|
|
224
|
+
displayName: string;
|
|
225
|
+
isFocused: boolean;
|
|
226
|
+
onRemove: () => void;
|
|
227
|
+
onFocus: () => void;
|
|
228
|
+
}
|
|
229
|
+
export {};
|
|
230
|
+
//# sourceMappingURL=Combobox.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Combobox.types.d.ts","sourceRoot":"","sources":["../src/Combobox.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;GAEG;AAEH,eAAO,MAAM,YAAY;;CAEf,CAAC;AACX,oBAAY,YAAY,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE1E,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AACX,oBAAY,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC;AAE/F,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AACX,oBAAY,QAAQ,GAAG,OAAO,QAAQ,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AAE9D,eAAO,MAAM,KAAK;;;CAGR,CAAC;AACX,oBAAY,KAAK,GAAG,OAAO,KAAK,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC;AAErD,eAAO,MAAM,WAAW;;;;CAId,CAAC;AACX,oBAAY,WAAW,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE;;GAEG;AAEH,oBAAY,eAAe,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GAC3D,KAAK,CAAC,MAAM,CAAC,GACb,MAAM,GAAG,IAAI,CAAC;AAElB,oBAAY,YAAY,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,SAAS,IAAI,GACxD,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,KAAK,IAAI,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,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AAEH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxSize, TrunctationLocation } from './Combobox.types';
|
|
3
|
+
interface ComboboxData {
|
|
4
|
+
multiselect: boolean;
|
|
5
|
+
darkMode: boolean;
|
|
6
|
+
size: keyof typeof ComboboxSize;
|
|
7
|
+
withIcons: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
chipTruncationLocation?: TrunctationLocation;
|
|
10
|
+
chipCharacterLimit?: number;
|
|
11
|
+
inputValue?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const ComboboxContext: import("react").Context<ComboboxData>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=ComboboxContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboboxContext.d.ts","sourceRoot":"","sources":["../src/ComboboxContext.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAErE,UAAU,YAAY;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,OAAO,YAAY,CAAC;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,sBAAsB,CAAC,EAAE,mBAAmB,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,uCAM1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComboboxGroupProps } from './Combobox.types';
|
|
3
|
+
export declare function InternalComboboxGroup({ label, className, children, }: ComboboxGroupProps): JSX.Element;
|
|
4
|
+
declare function ComboboxGroup(_: ComboboxGroupProps): JSX.Element;
|
|
5
|
+
declare namespace ComboboxGroup {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
export default ComboboxGroup;
|
|
9
|
+
//# sourceMappingURL=ComboboxGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboboxGroup.d.ts","sourceRoot":"","sources":["../src/ComboboxGroup.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AA4BtD,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,SAAS,EACT,QAAQ,GACT,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAkBlC;AAID,iBAAwB,aAAa,CAAC,CAAC,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAExE;kBAFuB,aAAa;;;eAAb,aAAa"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComboboxOptionProps, InternalComboboxOptionProps } from './Combobox.types';
|
|
3
|
+
/**
|
|
4
|
+
* Component
|
|
5
|
+
*/
|
|
6
|
+
declare const InternalComboboxOption: React.ForwardRefExoticComponent<InternalComboboxOptionProps & React.RefAttributes<HTMLLIElement>>;
|
|
7
|
+
export { InternalComboboxOption };
|
|
8
|
+
declare function ComboboxOption(_: ComboboxOptionProps): JSX.Element;
|
|
9
|
+
declare namespace ComboboxOption {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export default ComboboxOption;
|
|
13
|
+
//# sourceMappingURL=ComboboxOption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboboxOption.d.ts","sourceRoot":"","sources":["../src/ComboboxOption.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAMhE,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,kBAAkB,CAAC;AA4D1B;;GAEG;AAEH,QAAA,MAAM,sBAAsB,mGAsH3B,CAAC;AAGF,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAClC,iBAAwB,cAAc,CAAC,CAAC,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAE1E;kBAFuB,cAAc;;;eAAd,cAAc"}
|