glints-aries 4.0.239 → 4.0.240
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 +20 -1
- package/es/@next/Input/InputStyle.d.ts +1 -2
- package/es/@next/Input/InputStyle.js +3 -1
- package/es/@next/Menu/components/MenuOption.js +5 -6
- package/es/@next/Select/Select.d.ts +4 -2
- package/es/@next/Select/Select.js +68 -45
- package/es/@next/Select/Select.stories.d.ts +1 -0
- package/es/@next/Select/components/Activator/ActivatorSelect.d.ts +5 -2
- package/es/@next/Select/components/Activator/ActivatorSelect.js +9 -10
- package/es/@next/Select/components/Activator/ActivatorTextInput.d.ts +16 -2
- package/es/@next/Select/components/Activator/ActivatorTextInput.js +57 -13
- package/es/@next/Select/components/OptionList/OptionList.d.ts +6 -2
- package/es/@next/Select/components/OptionList/OptionList.js +20 -7
- package/es/@next/Select/components/SearchableSelectInput/ClearSelected.d.ts +9 -0
- package/es/@next/Select/components/SearchableSelectInput/ClearSelected.js +22 -0
- package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInput.d.ts +36 -0
- package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInput.js +121 -0
- package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInputStyle.d.ts +4 -0
- package/es/@next/Select/components/SearchableSelectInput/SearchableSelectInputStyle.js +30 -0
- package/es/@next/Select/selectStoryHelper/Searchable.js +2 -25
- package/es/@next/Select/selectStoryHelper/SearchableSingleSelect.d.ts +7 -0
- package/es/@next/Select/selectStoryHelper/SearchableSingleSelect.js +24 -0
- package/lib/@next/Input/InputStyle.d.ts +1 -2
- package/lib/@next/Input/InputStyle.js +3 -1
- package/lib/@next/Menu/components/MenuOption.js +5 -6
- package/lib/@next/Select/Select.d.ts +4 -2
- package/lib/@next/Select/Select.js +67 -44
- package/lib/@next/Select/Select.stories.d.ts +1 -0
- package/lib/@next/Select/components/Activator/ActivatorSelect.d.ts +5 -2
- package/lib/@next/Select/components/Activator/ActivatorSelect.js +9 -10
- package/lib/@next/Select/components/Activator/ActivatorTextInput.d.ts +16 -2
- package/lib/@next/Select/components/Activator/ActivatorTextInput.js +56 -12
- package/lib/@next/Select/components/OptionList/OptionList.d.ts +6 -2
- package/lib/@next/Select/components/OptionList/OptionList.js +22 -8
- package/lib/@next/Select/components/SearchableSelectInput/ClearSelected.d.ts +9 -0
- package/lib/@next/Select/components/SearchableSelectInput/ClearSelected.js +28 -0
- package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInput.d.ts +36 -0
- package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInput.js +129 -0
- package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInputStyle.d.ts +4 -0
- package/lib/@next/Select/components/SearchableSelectInput/SearchableSelectInputStyle.js +41 -0
- package/lib/@next/Select/selectStoryHelper/Searchable.js +1 -24
- package/lib/@next/Select/selectStoryHelper/SearchableSingleSelect.d.ts +7 -0
- package/lib/@next/Select/selectStoryHelper/SearchableSingleSelect.js +32 -0
- package/package.json +1 -1
- package/es/@next/Select/components/Activator/ActivatorContext.d.ts +0 -17
- package/es/@next/Select/components/Activator/ActivatorContext.js +0 -17
- package/lib/@next/Select/components/Activator/ActivatorContext.d.ts +0 -17
- package/lib/@next/Select/components/Activator/ActivatorContext.js +0 -25
package/README.md
CHANGED
|
@@ -28,11 +28,30 @@ import { GlintsContainer } from 'glints-aries';
|
|
|
28
28
|
|
|
29
29
|
### Development
|
|
30
30
|
|
|
31
|
+
Before that, make sure you already have git, node (version >= 14), and yarn installed.
|
|
32
|
+
|
|
33
|
+
1. Clone the repository
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
git clone https://github.com/glints-dev/glints-aries.git
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Install the project dependencies (preferably use yarn here), then build the project
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn
|
|
43
|
+
yarn build
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
3. Start the application
|
|
47
|
+
|
|
31
48
|
```bash
|
|
32
49
|
yarn storybook
|
|
33
50
|
```
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
4. Open your browser on (port 6006)[http://localhost:6006].
|
|
53
|
+
|
|
54
|
+
Note: For Windows user, please use [WSL2 Linux](https://learn.microsoft.com/en-us/windows/wsl/install) to execute all the commands above. Make sure that the repository is cloned on the linux folder, not on your C drive.
|
|
36
55
|
|
|
37
56
|
### How to test local changes in glints-aries in your project
|
|
38
57
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InputProps } from './Input';
|
|
2
|
-
interface PreffixSuffixWidthProps {
|
|
2
|
+
export interface PreffixSuffixWidthProps {
|
|
3
3
|
prefixWidth: number;
|
|
4
4
|
suffixWidth: number;
|
|
5
5
|
}
|
|
@@ -7,4 +7,3 @@ export declare const StyledContainer: import("styled-components").StyledComponen
|
|
|
7
7
|
export declare const StyledPrefixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
8
|
export declare const StyledSuffixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
9
|
export declare const StyledInput: import("styled-components").StyledComponent<"input", any, InputProps, never>;
|
|
10
|
-
export {};
|
|
@@ -2,6 +2,8 @@ import styled from 'styled-components';
|
|
|
2
2
|
import * as Breakpoints from '../utilities/breakpoints';
|
|
3
3
|
import { Neutral, Red } from '../utilities/colors';
|
|
4
4
|
import { space12, space4, space8 } from '../utilities/spacing';
|
|
5
|
+
import { NotoSans } from '../utilities/fonts';
|
|
6
|
+
import { borderRadius4 } from '../utilities/borderRadius';
|
|
5
7
|
export var StyledContainer = styled.div.withConfig({
|
|
6
8
|
displayName: "InputStyle__StyledContainer",
|
|
7
9
|
componentId: "sc-15z2mnd-0"
|
|
@@ -21,4 +23,4 @@ export var StyledSuffixContainer = styled(StyledPrefixContainer).withConfig({
|
|
|
21
23
|
export var StyledInput = styled.input.withConfig({
|
|
22
24
|
displayName: "InputStyle__StyledInput",
|
|
23
25
|
componentId: "sc-15z2mnd-3"
|
|
24
|
-
})(["background:", ";box-sizing:border-box;border:1px solid ", ";border-radius:
|
|
26
|
+
})(["background:", ";box-sizing:border-box;border:1px solid ", ";border-radius:", ";padding:0 12px;font-family:", ",sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;color:", ";flex:none;order:1;align-self:stretch;flex-grow:0;height:36px;&::placeholder{color:", ";}&:focus{outline:none;box-shadow:0px 0px 0px 1px ", ",0px 0px 0px 3px #6ac9ec;}@media (max-width:", "){font-size:14px;}"], Neutral.B100, Neutral.B68, borderRadius4, NotoSans, Neutral.B18, Neutral.B40, Neutral.B100, Breakpoints.large);
|
|
@@ -7,18 +7,17 @@ export var MenuOption = function MenuOption(_ref) {
|
|
|
7
7
|
onClick = _ref.onClick,
|
|
8
8
|
value = _ref.value,
|
|
9
9
|
allowMultiple = _ref.allowMultiple;
|
|
10
|
-
var handleClick = function handleClick(
|
|
10
|
+
var handleClick = function handleClick(event) {
|
|
11
|
+
event.stopPropagation();
|
|
11
12
|
onClick({
|
|
12
|
-
value: value
|
|
13
|
+
value: event.currentTarget.dataset.value
|
|
13
14
|
});
|
|
14
15
|
};
|
|
15
16
|
return /*#__PURE__*/React.createElement(ListContainer, null, /*#__PURE__*/React.createElement("li", {
|
|
16
17
|
"aria-disabled": disabled,
|
|
17
18
|
"data-active": isSelected,
|
|
18
19
|
"data-multiple": allowMultiple,
|
|
19
|
-
value: value,
|
|
20
|
-
onClick:
|
|
21
|
-
return handleClick(value);
|
|
22
|
-
}
|
|
20
|
+
"data-value": value,
|
|
21
|
+
onClick: handleClick
|
|
23
22
|
}, children));
|
|
24
23
|
};
|
|
@@ -24,7 +24,9 @@ export interface SelectProps {
|
|
|
24
24
|
options?: Option[];
|
|
25
25
|
placeholder?: string;
|
|
26
26
|
prefix?: React.ReactNode;
|
|
27
|
-
/** sets whether
|
|
27
|
+
/** sets whether Select is searchable */
|
|
28
|
+
searchable?: boolean;
|
|
29
|
+
/** props used for searchable Select */
|
|
28
30
|
searchableProps?: SearchableProps;
|
|
29
31
|
/** true = Allow vertical scroll, default by 6 options. */
|
|
30
32
|
scrollable?: boolean;
|
|
@@ -33,5 +35,5 @@ export interface SelectProps {
|
|
|
33
35
|
/** sets a width for the Select component*/
|
|
34
36
|
width: string;
|
|
35
37
|
}
|
|
36
|
-
export declare const Select: ({ allowMultiple, disabled, hasError, helpText, label, onClose, onRemoveTag, onSelect, options, placeholder, listHeight, prefix, searchableProps, scrollable, sections, selectedValues, width, }: SelectProps) => JSX.Element;
|
|
38
|
+
export declare const Select: ({ allowMultiple, disabled, hasError, helpText, label, onClose, onRemoveTag, onSelect, options, placeholder, listHeight, prefix, searchable, searchableProps, scrollable, sections, selectedValues, width, }: SelectProps) => JSX.Element;
|
|
37
39
|
export {};
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Popover } from '../Popover';
|
|
3
3
|
import { Typography } from '../Typography';
|
|
4
4
|
import { Neutral } from '../utilities/colors';
|
|
5
5
|
import { ActivatorTextInput, OptionList } from './components';
|
|
6
|
-
import { ActivatorSelectContext, ActivatorTextInputContext } from './components/Activator/ActivatorContext';
|
|
7
6
|
import { ActivatorSelect } from './components/Activator/ActivatorSelect';
|
|
8
7
|
import { Label } from './components/Label/Label';
|
|
9
8
|
import { ActivatorWrapper, HelpTextContainer } from './SelectStyle';
|
|
10
9
|
export var Select = function Select(_ref) {
|
|
11
10
|
var _ref$allowMultiple = _ref.allowMultiple,
|
|
12
11
|
allowMultiple = _ref$allowMultiple === void 0 ? false : _ref$allowMultiple,
|
|
13
|
-
disabled = _ref.disabled,
|
|
14
|
-
|
|
12
|
+
_ref$disabled = _ref.disabled,
|
|
13
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
14
|
+
_ref$hasError = _ref.hasError,
|
|
15
|
+
hasError = _ref$hasError === void 0 ? false : _ref$hasError,
|
|
15
16
|
helpText = _ref.helpText,
|
|
16
17
|
label = _ref.label,
|
|
17
18
|
onClose = _ref.onClose,
|
|
18
19
|
onRemoveTag = _ref.onRemoveTag,
|
|
19
20
|
onSelect = _ref.onSelect,
|
|
20
|
-
options = _ref.options,
|
|
21
|
+
_ref$options = _ref.options,
|
|
22
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
21
23
|
placeholder = _ref.placeholder,
|
|
22
24
|
listHeight = _ref.listHeight,
|
|
23
25
|
prefix = _ref.prefix,
|
|
26
|
+
_ref$searchable = _ref.searchable,
|
|
27
|
+
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
24
28
|
searchableProps = _ref.searchableProps,
|
|
25
|
-
scrollable = _ref.scrollable,
|
|
29
|
+
_ref$scrollable = _ref.scrollable,
|
|
30
|
+
scrollable = _ref$scrollable === void 0 ? false : _ref$scrollable,
|
|
26
31
|
sections = _ref.sections,
|
|
27
32
|
selectedValues = _ref.selectedValues,
|
|
28
33
|
width = _ref.width;
|
|
@@ -32,34 +37,38 @@ export var Select = function Select(_ref) {
|
|
|
32
37
|
var _useState2 = useState(''),
|
|
33
38
|
optionListHeight = _useState2[0],
|
|
34
39
|
setOptionListHeight = _useState2[1];
|
|
35
|
-
var
|
|
40
|
+
var _useState3 = useState(options),
|
|
41
|
+
menuOptions = _useState3[0],
|
|
42
|
+
setMenuOptions = _useState3[1];
|
|
43
|
+
var _useState4 = useState((searchableProps == null ? void 0 : searchableProps.inputValue) || ''),
|
|
44
|
+
inputValue = _useState4[0],
|
|
45
|
+
setInputValue = _useState4[1];
|
|
46
|
+
var _useState5 = useState({
|
|
47
|
+
showSelected: false,
|
|
48
|
+
showInput: true,
|
|
49
|
+
showPlaceholder: true
|
|
50
|
+
}),
|
|
51
|
+
searchableSelectState = _useState5[0],
|
|
52
|
+
setSearchableSelectState = _useState5[1];
|
|
53
|
+
var _updateSearchableSelectState = function updateSearchableSelectState(newState) {
|
|
54
|
+
setSearchableSelectState(newState);
|
|
55
|
+
};
|
|
56
|
+
var updateInputValue = function updateInputValue(newValue) {
|
|
57
|
+
setInputValue(newValue);
|
|
58
|
+
};
|
|
59
|
+
var updateMenuOptions = function updateMenuOptions(newState) {
|
|
60
|
+
setMenuOptions(newState);
|
|
61
|
+
};
|
|
62
|
+
var handleClose = function handleClose() {
|
|
36
63
|
setPopoverActive(false);
|
|
37
64
|
onClose == null ? void 0 : onClose();
|
|
38
|
-
}
|
|
65
|
+
};
|
|
39
66
|
var handleFocus = function handleFocus() {
|
|
40
67
|
setPopoverActive(true);
|
|
41
68
|
};
|
|
42
|
-
var handleBlur = function handleBlur() {
|
|
43
|
-
if (popoverActive) {
|
|
44
|
-
handleClose();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
69
|
var handleSelectClick = function handleSelectClick() {
|
|
48
70
|
setPopoverActive(!popoverActive);
|
|
49
71
|
};
|
|
50
|
-
var activatorSelectContextValue = {
|
|
51
|
-
allowMultiple: allowMultiple,
|
|
52
|
-
disabled: disabled,
|
|
53
|
-
hasError: hasError,
|
|
54
|
-
onSelectClick: handleSelectClick,
|
|
55
|
-
selectedValues: selectedValues
|
|
56
|
-
};
|
|
57
|
-
var activatorTextInputContextValue = {
|
|
58
|
-
disabled: disabled,
|
|
59
|
-
hasError: hasError,
|
|
60
|
-
onFocus: handleFocus,
|
|
61
|
-
onBlur: handleBlur
|
|
62
|
-
};
|
|
63
72
|
useEffect(function () {
|
|
64
73
|
if (listHeight) {
|
|
65
74
|
setOptionListHeight(listHeight + 24 + "px");
|
|
@@ -71,28 +80,38 @@ export var Select = function Select(_ref) {
|
|
|
71
80
|
}
|
|
72
81
|
}, [listHeight, scrollable]);
|
|
73
82
|
var activator = function activator() {
|
|
74
|
-
if (searchableProps) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
value: inputValue,
|
|
81
|
-
onChange: _onInputChange,
|
|
83
|
+
if (searchable || searchableProps) {
|
|
84
|
+
return /*#__PURE__*/React.createElement(ActivatorTextInput, {
|
|
85
|
+
allowMultiple: allowMultiple,
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
hasError: hasError,
|
|
88
|
+
onChange: searchableProps == null ? void 0 : searchableProps.onInputChange,
|
|
82
89
|
placeholder: placeholder != null ? placeholder : 'Search',
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
width: width,
|
|
91
|
+
selectedValues: selectedValues,
|
|
92
|
+
onSelect: onSelect,
|
|
93
|
+
onFocus: handleFocus,
|
|
94
|
+
inputValue: inputValue,
|
|
95
|
+
updateInputValue: updateInputValue,
|
|
96
|
+
searchableSelectState: searchableSelectState,
|
|
97
|
+
updateSearchableSelectState: function updateSearchableSelectState(newState) {
|
|
98
|
+
return _updateSearchableSelectState(newState);
|
|
99
|
+
},
|
|
100
|
+
options: options,
|
|
101
|
+
updateMenuOptions: updateMenuOptions,
|
|
102
|
+
prefix: prefix
|
|
103
|
+
});
|
|
86
104
|
}
|
|
87
|
-
return /*#__PURE__*/React.createElement(
|
|
88
|
-
|
|
89
|
-
}, /*#__PURE__*/React.createElement(ActivatorSelect, {
|
|
105
|
+
return /*#__PURE__*/React.createElement(ActivatorSelect, {
|
|
106
|
+
allowMultiple: allowMultiple,
|
|
90
107
|
disabled: disabled,
|
|
108
|
+
hasError: hasError,
|
|
91
109
|
placeholder: "Placeholder",
|
|
92
110
|
onRemoveTag: onRemoveTag,
|
|
111
|
+
onSelectClick: handleSelectClick,
|
|
93
112
|
width: width,
|
|
94
|
-
|
|
95
|
-
})
|
|
113
|
+
selectedValues: selectedValues
|
|
114
|
+
});
|
|
96
115
|
};
|
|
97
116
|
return /*#__PURE__*/React.createElement(Popover, {
|
|
98
117
|
active: popoverActive,
|
|
@@ -107,14 +126,18 @@ export var Select = function Select(_ref) {
|
|
|
107
126
|
autofocusTarget: "none",
|
|
108
127
|
preventFocusOnClose: true,
|
|
109
128
|
fullWidth: true
|
|
110
|
-
}, /*#__PURE__*/React.createElement(Popover.Pane, {
|
|
129
|
+
}, !disabled && /*#__PURE__*/React.createElement(Popover.Pane, {
|
|
111
130
|
height: optionListHeight
|
|
112
131
|
}, /*#__PURE__*/React.createElement(OptionList, {
|
|
132
|
+
menuOptions: menuOptions,
|
|
113
133
|
allowMultiple: allowMultiple,
|
|
114
134
|
onSelect: onSelect,
|
|
115
|
-
options: options,
|
|
116
135
|
sections: sections,
|
|
117
136
|
selectedValues: selectedValues,
|
|
118
|
-
width: width
|
|
137
|
+
width: width,
|
|
138
|
+
onMenuClose: handleClose,
|
|
139
|
+
updateSearchableSelectState: function updateSearchableSelectState(newState) {
|
|
140
|
+
return _updateSearchableSelectState(newState);
|
|
141
|
+
}
|
|
119
142
|
})));
|
|
120
143
|
};
|
|
@@ -6,6 +6,7 @@ export declare const NonSearchableMultipleSelect: any;
|
|
|
6
6
|
export declare const WithErrorNonSearchable: any;
|
|
7
7
|
export declare const NonSearchableDisabled: any;
|
|
8
8
|
export declare const SearchableMultiSelect: any;
|
|
9
|
+
export declare const SearchableSingleSelect: any;
|
|
9
10
|
export declare const MultiSelectScrollable: any;
|
|
10
11
|
export declare const WithInlineError: any;
|
|
11
12
|
export declare const SearchableDisabled: any;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ActivatorSelectProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
-
|
|
3
|
+
allowMultiple?: boolean;
|
|
4
|
+
hasError?: boolean;
|
|
5
|
+
selectedValues?: string[];
|
|
4
6
|
placeholder?: string;
|
|
5
7
|
onRemoveTag?({ option }: {
|
|
6
8
|
option: string;
|
|
7
9
|
}): void;
|
|
10
|
+
onSelectClick?(): void;
|
|
8
11
|
width?: string;
|
|
9
12
|
}
|
|
10
|
-
export declare const ActivatorSelect: ({ placeholder,
|
|
13
|
+
export declare const ActivatorSelect: ({ placeholder, selectedValues, onClick, onRemoveTag, width, allowMultiple, disabled, onSelectClick, hasError, ...props }: ActivatorSelectProps) => JSX.Element;
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["placeholder", "
|
|
3
|
+
var _excluded = ["placeholder", "selectedValues", "onClick", "onRemoveTag", "width", "allowMultiple", "disabled", "onSelectClick", "hasError"];
|
|
4
4
|
import React, { useRef } from 'react';
|
|
5
5
|
import { Icon } from '../../../Icon';
|
|
6
6
|
import { Typography } from '../../../Typography';
|
|
7
7
|
import { Blue, Neutral } from '../../../utilities/colors';
|
|
8
|
-
import { useActivatorSelect } from './ActivatorContext';
|
|
9
8
|
import { StyledSelect, StyledTag, TagsContainer } from './ActivatorStyle';
|
|
10
9
|
export var ActivatorSelect = function ActivatorSelect(_ref) {
|
|
11
10
|
var placeholder = _ref.placeholder,
|
|
12
|
-
|
|
11
|
+
selectedValues = _ref.selectedValues,
|
|
13
12
|
onClick = _ref.onClick,
|
|
14
13
|
onRemoveTag = _ref.onRemoveTag,
|
|
15
14
|
width = _ref.width,
|
|
15
|
+
_ref$allowMultiple = _ref.allowMultiple,
|
|
16
|
+
allowMultiple = _ref$allowMultiple === void 0 ? false : _ref$allowMultiple,
|
|
17
|
+
disabled = _ref.disabled,
|
|
18
|
+
onSelectClick = _ref.onSelectClick,
|
|
19
|
+
_ref$hasError = _ref.hasError,
|
|
20
|
+
hasError = _ref$hasError === void 0 ? false : _ref$hasError,
|
|
16
21
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
17
22
|
var activatorRef = useRef(null);
|
|
18
|
-
var filteredValues =
|
|
23
|
+
var filteredValues = selectedValues == null ? void 0 : selectedValues.filter(function (value) {
|
|
19
24
|
return value != '';
|
|
20
25
|
});
|
|
21
26
|
var hasValue = filteredValues.length > 0;
|
|
22
|
-
var activatorContext = useActivatorSelect();
|
|
23
|
-
var allowMultiple = activatorContext.allowMultiple,
|
|
24
|
-
disabled = activatorContext.disabled,
|
|
25
|
-
onSelectClick = activatorContext.onSelectClick,
|
|
26
|
-
hasError = activatorContext.hasError,
|
|
27
|
-
selectedValues = activatorContext.selectedValues;
|
|
28
27
|
var handleClick = function handleClick(e) {
|
|
29
28
|
e.preventDefault();
|
|
30
29
|
e.stopPropagation();
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Option } from '../../../Menu';
|
|
2
3
|
import { TextInputProps } from '../../../TextInput';
|
|
3
|
-
|
|
4
|
+
import { SearchableSelectState } from '../SearchableSelectInput/SearchableSelectInput';
|
|
5
|
+
export interface ActivatorTextInputProps extends Omit<TextInputProps, 'onChange' | 'onSelect'> {
|
|
6
|
+
allowMultiple?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
4
8
|
hasError?: boolean;
|
|
5
9
|
onChange?(value: string): void;
|
|
10
|
+
onSelect?({ value }: {
|
|
11
|
+
value: string;
|
|
12
|
+
}): void;
|
|
13
|
+
selectedValues?: string[];
|
|
6
14
|
width?: string;
|
|
15
|
+
inputValue?: string;
|
|
16
|
+
updateInputValue?: (newValue: string) => void;
|
|
17
|
+
searchableSelectState?: SearchableSelectState;
|
|
18
|
+
updateSearchableSelectState?: (newState: SearchableSelectState) => void;
|
|
19
|
+
options?: Option[];
|
|
20
|
+
updateMenuOptions?: (newState: Option[]) => void;
|
|
7
21
|
}
|
|
8
|
-
export declare const ActivatorTextInput: ({ onChange, prefix,
|
|
22
|
+
export declare const ActivatorTextInput: ({ allowMultiple, disabled, hasError, onChange, onFocus, onSelect, prefix, selectedValues, width, inputValue, updateInputValue, options, updateMenuOptions, ...props }: ActivatorTextInputProps) => JSX.Element;
|
|
@@ -1,32 +1,62 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["onChange", "prefix", "
|
|
4
|
-
import React, { useRef } from 'react';
|
|
3
|
+
var _excluded = ["allowMultiple", "disabled", "hasError", "onChange", "onFocus", "onSelect", "prefix", "selectedValues", "width", "inputValue", "updateInputValue", "options", "updateMenuOptions"];
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { Icon } from '../../../Icon';
|
|
6
|
-
import {
|
|
6
|
+
import { SearchableSelectInput } from '../SearchableSelectInput/SearchableSelectInput';
|
|
7
7
|
import { StyledTextInput } from './ActivatorStyle';
|
|
8
8
|
export var ActivatorTextInput = function ActivatorTextInput(_ref) {
|
|
9
|
-
var
|
|
9
|
+
var allowMultiple = _ref.allowMultiple,
|
|
10
|
+
_ref$disabled = _ref.disabled,
|
|
11
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
12
|
+
_ref$hasError = _ref.hasError,
|
|
13
|
+
hasError = _ref$hasError === void 0 ? false : _ref$hasError,
|
|
14
|
+
onChange = _ref.onChange,
|
|
15
|
+
onFocus = _ref.onFocus,
|
|
16
|
+
onSelect = _ref.onSelect,
|
|
10
17
|
_ref$prefix = _ref.prefix,
|
|
11
18
|
prefix = _ref$prefix === void 0 ? /*#__PURE__*/React.createElement(Icon, {
|
|
12
19
|
name: "ri-search"
|
|
13
20
|
}) : _ref$prefix,
|
|
14
|
-
|
|
21
|
+
selectedValues = _ref.selectedValues,
|
|
15
22
|
width = _ref.width,
|
|
23
|
+
inputValue = _ref.inputValue,
|
|
24
|
+
updateInputValue = _ref.updateInputValue,
|
|
25
|
+
options = _ref.options,
|
|
26
|
+
updateMenuOptions = _ref.updateMenuOptions,
|
|
16
27
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
17
28
|
var activatorRef = useRef(null);
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
var _useState = useState(false),
|
|
30
|
+
hasSelectedValues = _useState[0],
|
|
31
|
+
setHasSelectedValues = _useState[1];
|
|
32
|
+
var filterOptions = function filterOptions(str) {
|
|
33
|
+
if (str === '') {
|
|
34
|
+
updateMenuOptions(options);
|
|
35
|
+
return options;
|
|
36
|
+
}
|
|
37
|
+
var filterRegex = new RegExp(str, 'i');
|
|
38
|
+
var filterOptions = options.filter(function (option) {
|
|
39
|
+
return option.label.match(filterRegex);
|
|
40
|
+
});
|
|
41
|
+
return filterOptions;
|
|
42
|
+
};
|
|
22
43
|
var handleChange = function handleChange(_ref2) {
|
|
23
44
|
var value = _ref2.value;
|
|
24
|
-
if (onChange)
|
|
45
|
+
if (onChange) {
|
|
46
|
+
onChange(value);
|
|
47
|
+
var filteredOptions = filterOptions(value);
|
|
48
|
+
updateMenuOptions(filteredOptions);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
25
51
|
};
|
|
26
|
-
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
setHasSelectedValues(selectedValues.filter(function (v) {
|
|
54
|
+
return v != '';
|
|
55
|
+
}).length > 0);
|
|
56
|
+
}, [selectedValues]);
|
|
57
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, allowMultiple ? /*#__PURE__*/React.createElement(StyledTextInput, _extends({}, props, {
|
|
27
58
|
ref: activatorRef,
|
|
28
59
|
prefix: prefix,
|
|
29
|
-
value: value,
|
|
30
60
|
onChange: function onChange(value) {
|
|
31
61
|
return handleChange({
|
|
32
62
|
value: value
|
|
@@ -36,5 +66,19 @@ export var ActivatorTextInput = function ActivatorTextInput(_ref) {
|
|
|
36
66
|
error: hasError,
|
|
37
67
|
disabled: disabled,
|
|
38
68
|
width: width
|
|
39
|
-
}))
|
|
69
|
+
})) : /*#__PURE__*/React.createElement(SearchableSelectInput, _extends({}, props, {
|
|
70
|
+
ref: activatorRef,
|
|
71
|
+
prefix: prefix,
|
|
72
|
+
filterOptions: filterOptions,
|
|
73
|
+
onFocus: onFocus,
|
|
74
|
+
onSelect: onSelect,
|
|
75
|
+
error: hasError,
|
|
76
|
+
disabled: disabled,
|
|
77
|
+
selectedValue: hasSelectedValues ? selectedValues[0] : null,
|
|
78
|
+
width: width,
|
|
79
|
+
inputValue: inputValue,
|
|
80
|
+
updateInputValue: updateInputValue,
|
|
81
|
+
options: options,
|
|
82
|
+
updateMenuOptions: updateMenuOptions
|
|
83
|
+
})));
|
|
40
84
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MenuProps } from '../../../Menu';
|
|
2
|
+
import { MenuProps, Option } from '../../../Menu';
|
|
3
|
+
import { SearchableSelectState } from '../SearchableSelectInput/SearchableSelectInput';
|
|
3
4
|
export interface OptionListProps extends MenuProps {
|
|
4
5
|
isEmpty?: boolean;
|
|
5
6
|
noOptionsMessage?: React.ReactNode;
|
|
7
|
+
onMenuClose?: () => void;
|
|
6
8
|
onSelect?({ value }: {
|
|
7
9
|
value: string;
|
|
8
10
|
}): void;
|
|
9
11
|
width?: string;
|
|
12
|
+
updateSearchableSelectState?: (newState: SearchableSelectState) => void;
|
|
13
|
+
menuOptions?: Option[];
|
|
10
14
|
}
|
|
11
15
|
export interface NoOptionListProps {
|
|
12
16
|
noOptionsMessage?: React.ReactNode;
|
|
13
17
|
}
|
|
14
18
|
export declare const NoOptionList: ({ noOptionsMessage, }: NoOptionListProps) => JSX.Element;
|
|
15
|
-
export declare const OptionList: ({ allowMultiple, noOptionsMessage,
|
|
19
|
+
export declare const OptionList: ({ allowMultiple, noOptionsMessage, onMenuClose, onSelect, sections, selectedValues, title, updateSearchableSelectState, width, menuOptions, }: OptionListProps) => JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Menu } from '../../../Menu';
|
|
3
3
|
import { Typography } from '../../../Typography';
|
|
4
4
|
import { Neutral } from '../../../utilities/colors';
|
|
@@ -15,27 +15,40 @@ export var NoOptionList = function NoOptionList(_ref) {
|
|
|
15
15
|
export var OptionList = function OptionList(_ref2) {
|
|
16
16
|
var allowMultiple = _ref2.allowMultiple,
|
|
17
17
|
noOptionsMessage = _ref2.noOptionsMessage,
|
|
18
|
+
onMenuClose = _ref2.onMenuClose,
|
|
18
19
|
onSelect = _ref2.onSelect,
|
|
19
|
-
options = _ref2.options,
|
|
20
20
|
sections = _ref2.sections,
|
|
21
21
|
selectedValues = _ref2.selectedValues,
|
|
22
22
|
title = _ref2.title,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
updateSearchableSelectState = _ref2.updateSearchableSelectState,
|
|
24
|
+
width = _ref2.width,
|
|
25
|
+
menuOptions = _ref2.menuOptions;
|
|
26
|
+
var _useState = useState(false),
|
|
27
|
+
hasMenuOptions = _useState[0],
|
|
28
|
+
setHasMenuOptions = _useState[1];
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
setHasMenuOptions((menuOptions == null ? void 0 : menuOptions.length) > 0);
|
|
31
|
+
}, [menuOptions]);
|
|
25
32
|
var onOptionSelect = function onOptionSelect(_ref3) {
|
|
26
33
|
var value = _ref3.value;
|
|
27
34
|
if (onSelect) {
|
|
28
35
|
onSelect({
|
|
29
36
|
value: value
|
|
30
37
|
});
|
|
31
|
-
return;
|
|
38
|
+
if (allowMultiple) return;
|
|
39
|
+
updateSearchableSelectState({
|
|
40
|
+
showSelected: true,
|
|
41
|
+
showInput: false,
|
|
42
|
+
showPlaceholder: false
|
|
43
|
+
});
|
|
44
|
+
onMenuClose();
|
|
32
45
|
}
|
|
33
46
|
};
|
|
34
47
|
return /*#__PURE__*/React.createElement(OptionListContainer, {
|
|
35
48
|
width: width
|
|
36
|
-
},
|
|
49
|
+
}, hasMenuOptions ? /*#__PURE__*/React.createElement(Menu, {
|
|
37
50
|
allowMultiple: allowMultiple,
|
|
38
|
-
options:
|
|
51
|
+
options: menuOptions,
|
|
39
52
|
onClick: onOptionSelect,
|
|
40
53
|
sections: sections,
|
|
41
54
|
selectedValues: selectedValues,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ClearSelectedProps {
|
|
3
|
+
onSelect?({ value }: {
|
|
4
|
+
value: string;
|
|
5
|
+
}): void;
|
|
6
|
+
handleClearIconClick?: () => void;
|
|
7
|
+
updateInputValue?(newValue: string): void;
|
|
8
|
+
}
|
|
9
|
+
export declare const ClearSelected: ({ onSelect, handleClearIconClick, updateInputValue, }: ClearSelectedProps) => JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon } from '../../../Icon';
|
|
3
|
+
import { ClearSelectedContainer } from './SearchableSelectInputStyle';
|
|
4
|
+
export var ClearSelected = function ClearSelected(_ref) {
|
|
5
|
+
var onSelect = _ref.onSelect,
|
|
6
|
+
handleClearIconClick = _ref.handleClearIconClick,
|
|
7
|
+
updateInputValue = _ref.updateInputValue;
|
|
8
|
+
var onClearIconClick = function onClearIconClick() {
|
|
9
|
+
updateInputValue('');
|
|
10
|
+
onSelect({
|
|
11
|
+
value: ''
|
|
12
|
+
});
|
|
13
|
+
handleClearIconClick();
|
|
14
|
+
};
|
|
15
|
+
return /*#__PURE__*/React.createElement(ClearSelectedContainer, null, /*#__PURE__*/React.createElement(Icon, {
|
|
16
|
+
name: "ri-close-circle-fill",
|
|
17
|
+
style: {
|
|
18
|
+
cursor: 'pointer'
|
|
19
|
+
},
|
|
20
|
+
onClick: onClearIconClick
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputProps } from '../../../Input/Input';
|
|
3
|
+
import { Option } from '../../../Menu';
|
|
4
|
+
export interface SearchableSelectState {
|
|
5
|
+
showSelected: boolean;
|
|
6
|
+
showInput: boolean;
|
|
7
|
+
showPlaceholder: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare type SearchableSelectInputProps = Omit<InputProps, 'type' | 'onChange' | 'onSelect'> & {
|
|
10
|
+
canClear?: boolean;
|
|
11
|
+
filterOptions?: (str: string) => Option[];
|
|
12
|
+
onSelect?({ value }: {
|
|
13
|
+
value: string;
|
|
14
|
+
}): void;
|
|
15
|
+
selectedValue?: string;
|
|
16
|
+
inputValue?: string;
|
|
17
|
+
updateInputValue?: (newValue: string) => void;
|
|
18
|
+
searchableSelectState?: SearchableSelectState;
|
|
19
|
+
updateSearchableSelectState?: (newState: SearchableSelectState) => void;
|
|
20
|
+
options?: Option[];
|
|
21
|
+
updateMenuOptions?: (newState: Option[]) => void;
|
|
22
|
+
};
|
|
23
|
+
export declare const SearchableSelectInput: React.ForwardRefExoticComponent<Omit<InputProps, "type" | "onChange" | "onSelect"> & {
|
|
24
|
+
canClear?: boolean;
|
|
25
|
+
filterOptions?: (str: string) => Option[];
|
|
26
|
+
onSelect?({ value }: {
|
|
27
|
+
value: string;
|
|
28
|
+
}): void;
|
|
29
|
+
selectedValue?: string;
|
|
30
|
+
inputValue?: string;
|
|
31
|
+
updateInputValue?: (newValue: string) => void;
|
|
32
|
+
searchableSelectState?: SearchableSelectState;
|
|
33
|
+
updateSearchableSelectState?: (newState: SearchableSelectState) => void;
|
|
34
|
+
options?: Option[];
|
|
35
|
+
updateMenuOptions?: (newState: Option[]) => void;
|
|
36
|
+
} & React.RefAttributes<HTMLInputElement>>;
|