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
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["disabled", "error", "filterOptions", "onSelect", "placeholder", "prefix", "selectedValue", "width", "inputValue", "updateInputValue", "onFocus", "searchableSelectState", "updateSearchableSelectState", "options", "updateMenuOptions"];
|
|
4
|
+
import React, { forwardRef, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { StyledInput, StyledPrefixContainer } from '../../../Input/InputStyle';
|
|
6
|
+
import { ClearSelected } from './ClearSelected';
|
|
7
|
+
import { InputContainer, StyledContainer, StyledSelectedValue } from './SearchableSelectInputStyle';
|
|
8
|
+
export var SearchableSelectInput = /*#__PURE__*/forwardRef(function SearchableSelectInput(_ref, ref) {
|
|
9
|
+
var _ref$disabled = _ref.disabled,
|
|
10
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
11
|
+
error = _ref.error,
|
|
12
|
+
filterOptions = _ref.filterOptions,
|
|
13
|
+
onSelect = _ref.onSelect,
|
|
14
|
+
placeholder = _ref.placeholder,
|
|
15
|
+
prefix = _ref.prefix,
|
|
16
|
+
selectedValue = _ref.selectedValue,
|
|
17
|
+
width = _ref.width,
|
|
18
|
+
inputValue = _ref.inputValue,
|
|
19
|
+
updateInputValue = _ref.updateInputValue,
|
|
20
|
+
onFocus = _ref.onFocus,
|
|
21
|
+
_ref$searchableSelect = _ref.searchableSelectState,
|
|
22
|
+
showInput = _ref$searchableSelect.showInput,
|
|
23
|
+
showPlaceholder = _ref$searchableSelect.showPlaceholder,
|
|
24
|
+
showSelected = _ref$searchableSelect.showSelected,
|
|
25
|
+
updateSearchableSelectState = _ref.updateSearchableSelectState,
|
|
26
|
+
options = _ref.options,
|
|
27
|
+
updateMenuOptions = _ref.updateMenuOptions,
|
|
28
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
29
|
+
var inputRef = useRef(null);
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
showClear = _useState[0],
|
|
32
|
+
setShowClear = _useState[1];
|
|
33
|
+
var _useState2 = useState(false),
|
|
34
|
+
isSelectedClicked = _useState2[0],
|
|
35
|
+
setIsSelectedClicked = _useState2[1];
|
|
36
|
+
var handleFocus = function handleFocus(e) {
|
|
37
|
+
setIsSelectedClicked(false);
|
|
38
|
+
setShowClear(false);
|
|
39
|
+
onFocus(e);
|
|
40
|
+
};
|
|
41
|
+
var handleClearIconClick = function handleClearIconClick() {
|
|
42
|
+
setShowClear(false);
|
|
43
|
+
updateSearchableSelectState({
|
|
44
|
+
showSelected: false,
|
|
45
|
+
showPlaceholder: true,
|
|
46
|
+
showInput: true
|
|
47
|
+
});
|
|
48
|
+
updateMenuOptions(options);
|
|
49
|
+
};
|
|
50
|
+
var handleInputChange = function handleInputChange(e) {
|
|
51
|
+
var str = e.currentTarget.value;
|
|
52
|
+
updateInputValue(str);
|
|
53
|
+
var filteredOptions = filterOptions(str);
|
|
54
|
+
updateMenuOptions(filteredOptions);
|
|
55
|
+
updateSearchableSelectState({
|
|
56
|
+
showSelected: false,
|
|
57
|
+
showInput: true,
|
|
58
|
+
showPlaceholder: false
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
var handleSelectedClick = function handleSelectedClick(e) {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
setIsSelectedClicked(true);
|
|
64
|
+
updateSearchableSelectState({
|
|
65
|
+
showSelected: true,
|
|
66
|
+
showInput: true,
|
|
67
|
+
showPlaceholder: false
|
|
68
|
+
});
|
|
69
|
+
updateInputValue('');
|
|
70
|
+
updateMenuOptions(options);
|
|
71
|
+
};
|
|
72
|
+
var handleInputBlur = function handleInputBlur() {
|
|
73
|
+
setIsSelectedClicked(false);
|
|
74
|
+
if (selectedValue) {
|
|
75
|
+
// allow onClick event handler in Menu before onBlur of input
|
|
76
|
+
setTimeout(function () {
|
|
77
|
+
setShowClear(true);
|
|
78
|
+
updateSearchableSelectState({
|
|
79
|
+
showSelected: true,
|
|
80
|
+
showInput: false,
|
|
81
|
+
showPlaceholder: false
|
|
82
|
+
});
|
|
83
|
+
}, 100);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
useEffect(function () {
|
|
87
|
+
if (isSelectedClicked && showInput) {
|
|
88
|
+
inputRef.current.focus();
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}, [isSelectedClicked, showInput]);
|
|
92
|
+
useEffect(function () {
|
|
93
|
+
if (selectedValue) {
|
|
94
|
+
setShowClear(true);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
setShowClear(false);
|
|
98
|
+
}, [selectedValue]);
|
|
99
|
+
return /*#__PURE__*/React.createElement(StyledContainer, {
|
|
100
|
+
ref: ref,
|
|
101
|
+
"data-error": error,
|
|
102
|
+
"data-disabled": disabled,
|
|
103
|
+
prefixWidth: 37,
|
|
104
|
+
suffixWidth: 33,
|
|
105
|
+
width: width
|
|
106
|
+
}, /*#__PURE__*/React.createElement(StyledPrefixContainer, null, prefix), showSelected && /*#__PURE__*/React.createElement(StyledSelectedValue, {
|
|
107
|
+
className: "searchable-select",
|
|
108
|
+
onClick: handleSelectedClick
|
|
109
|
+
}, selectedValue), showInput && /*#__PURE__*/React.createElement(InputContainer, null, /*#__PURE__*/React.createElement(StyledInput, _extends({
|
|
110
|
+
ref: inputRef,
|
|
111
|
+
onChange: handleInputChange,
|
|
112
|
+
placeholder: showPlaceholder ? placeholder : null,
|
|
113
|
+
value: inputValue,
|
|
114
|
+
onBlur: handleInputBlur,
|
|
115
|
+
onFocus: handleFocus
|
|
116
|
+
}, props))), showClear && /*#__PURE__*/React.createElement(ClearSelected, {
|
|
117
|
+
onSelect: onSelect,
|
|
118
|
+
handleClearIconClick: handleClearIconClick,
|
|
119
|
+
updateInputValue: updateInputValue
|
|
120
|
+
}));
|
|
121
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const StyledContainer: import("styled-components").StyledComponent<"div", any, import("../../../Input/Input").InputProps & import("../../../Input/InputStyle").PreffixSuffixWidthProps, never>;
|
|
2
|
+
export declare const StyledSelectedValue: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const InputContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const ClearSelectedContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import * as Breakpoints from '../../../utilities/breakpoints';
|
|
3
|
+
import { Neutral, Red } from '../../../utilities/colors';
|
|
4
|
+
import { NotoSans } from '../../../utilities/fonts';
|
|
5
|
+
import { StyledContainer as StyledInputContainer, StyledSuffixContainer } from '../../../Input/InputStyle';
|
|
6
|
+
import { borderRadius4 } from '../../../utilities/borderRadius';
|
|
7
|
+
export var StyledContainer = styled(StyledInputContainer).withConfig({
|
|
8
|
+
displayName: "SearchableSelectInputStyle__StyledContainer",
|
|
9
|
+
componentId: "sc-1oj168h-0"
|
|
10
|
+
})(["position:relative;height:36px;width:", ";background:", ";box-shadow:0px 1px 0px rgba(0,0,0,0.05);box-sizing:border-box;display:grid;input{background:transparent;z-index:1;width:", ";}&:has(> div > input:focus) > .searchable-select{color:", ";}.searchable-select,input{padding-left:", "px;padding-right:", "px;}&[data-error='true'] .searchable-select{border:1px solid ", ";}&[data-error='true'] .searchable-select:focus{box-shadow:none;}&[data-disabled='true'] .searchable-select{border:1px solid ", ";background:", ";color:", ";}"], function (props) {
|
|
11
|
+
return props.width;
|
|
12
|
+
}, Neutral.B100, function (props) {
|
|
13
|
+
return props.width;
|
|
14
|
+
}, Neutral.B40, function (props) {
|
|
15
|
+
return props.prefixWidth;
|
|
16
|
+
}, function (props) {
|
|
17
|
+
return props.suffixWidth;
|
|
18
|
+
}, Red.B93, Neutral.B85, Neutral.B95, Neutral.B85);
|
|
19
|
+
export var StyledSelectedValue = styled.div.withConfig({
|
|
20
|
+
displayName: "SearchableSelectInputStyle__StyledSelectedValue",
|
|
21
|
+
componentId: "sc-1oj168h-1"
|
|
22
|
+
})(["border:1px solid ", ";border-radius:", ";background:transparent;box-sizing:border-box;padding:0 12px;height:36px;display:flex;align-items:center;grid-column:1 / 1;grid-row:1 / 1;font-family:", ",sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;color:", ";@media (max-width:", "){font-size:14px;}"], Neutral.B68, borderRadius4, NotoSans, Neutral.B18, Breakpoints.large);
|
|
23
|
+
export var InputContainer = styled.div.withConfig({
|
|
24
|
+
displayName: "SearchableSelectInputStyle__InputContainer",
|
|
25
|
+
componentId: "sc-1oj168h-2"
|
|
26
|
+
})(["grid-column:1 / 1;grid-row:1 / 1;"]);
|
|
27
|
+
export var ClearSelectedContainer = styled(StyledSuffixContainer).withConfig({
|
|
28
|
+
displayName: "SearchableSelectInputStyle__ClearSelectedContainer",
|
|
29
|
+
componentId: "sc-1oj168h-3"
|
|
30
|
+
})(["z-index:2;"]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
3
|
var _excluded = ["data"];
|
|
4
|
-
import React, {
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
5
|
import { Blue } from '../../utilities/colors';
|
|
6
6
|
import { space8 } from '../../utilities/spacing';
|
|
7
7
|
import { Select } from '../Select';
|
|
@@ -15,23 +15,8 @@ export var SearchableSelect = function SearchableSelect(_ref) {
|
|
|
15
15
|
var _useState2 = useState([]),
|
|
16
16
|
selectedOptions = _useState2[0],
|
|
17
17
|
setSelectedOptions = _useState2[1];
|
|
18
|
-
var _useState3 = useState(false),
|
|
19
|
-
isSearchEmpty = _useState3[0],
|
|
20
|
-
setIsSearchEmpty = _useState3[1];
|
|
21
|
-
var _useState4 = useState(data),
|
|
22
|
-
options = _useState4[0],
|
|
23
|
-
setOptions = _useState4[1];
|
|
24
18
|
var handleInputChange = function handleInputChange(value) {
|
|
25
19
|
setInputValue(value);
|
|
26
|
-
if (value === '') {
|
|
27
|
-
setOptions(data);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
var filterRegex = new RegExp(value, 'i');
|
|
31
|
-
var filterOptions = options.filter(function (option) {
|
|
32
|
-
return option.label.match(filterRegex);
|
|
33
|
-
});
|
|
34
|
-
setOptions(filterOptions);
|
|
35
20
|
};
|
|
36
21
|
var handleSelect = function handleSelect(_ref2) {
|
|
37
22
|
var value = _ref2.value;
|
|
@@ -57,17 +42,9 @@ export var SearchableSelect = function SearchableSelect(_ref) {
|
|
|
57
42
|
textColor: Blue.S99
|
|
58
43
|
}, option);
|
|
59
44
|
});
|
|
60
|
-
useEffect(function () {
|
|
61
|
-
if (options.length === 0) {
|
|
62
|
-
setIsSearchEmpty(true);
|
|
63
|
-
}
|
|
64
|
-
if (options.length > 0 && isSearchEmpty === true) {
|
|
65
|
-
setIsSearchEmpty(false);
|
|
66
|
-
}
|
|
67
|
-
}, [isSearchEmpty, options]);
|
|
68
45
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Select, _extends({}, args, {
|
|
69
46
|
onSelect: handleSelect,
|
|
70
|
-
options:
|
|
47
|
+
options: data,
|
|
71
48
|
selectedValues: selectedOptions,
|
|
72
49
|
width: "600px",
|
|
73
50
|
searchableProps: {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["data"];
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { Select } from '../Select';
|
|
6
|
+
export var SearchableSingle = function SearchableSingle(_ref) {
|
|
7
|
+
var data = _ref.data,
|
|
8
|
+
args = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
9
|
+
var _useState = useState(''),
|
|
10
|
+
selected = _useState[0],
|
|
11
|
+
setSelected = _useState[1];
|
|
12
|
+
var handleSelect = function handleSelect(_ref2) {
|
|
13
|
+
var value = _ref2.value;
|
|
14
|
+
setSelected(value);
|
|
15
|
+
};
|
|
16
|
+
return /*#__PURE__*/React.createElement(Select, _extends({}, args, {
|
|
17
|
+
onSelect: handleSelect,
|
|
18
|
+
options: data,
|
|
19
|
+
selectedValues: [selected],
|
|
20
|
+
width: "600px",
|
|
21
|
+
searchable: true,
|
|
22
|
+
label: "Label"
|
|
23
|
+
}));
|
|
24
|
+
};
|
|
@@ -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 {};
|
|
@@ -7,6 +7,8 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
7
7
|
var Breakpoints = _interopRequireWildcard(require("../utilities/breakpoints"));
|
|
8
8
|
var _colors = require("../utilities/colors");
|
|
9
9
|
var _spacing = require("../utilities/spacing");
|
|
10
|
+
var _fonts = require("../utilities/fonts");
|
|
11
|
+
var _borderRadius = require("../utilities/borderRadius");
|
|
10
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
14
|
var StyledContainer = _styledComponents["default"].div.withConfig({
|
|
@@ -31,5 +33,5 @@ exports.StyledSuffixContainer = StyledSuffixContainer;
|
|
|
31
33
|
var StyledInput = _styledComponents["default"].input.withConfig({
|
|
32
34
|
displayName: "InputStyle__StyledInput",
|
|
33
35
|
componentId: "sc-15z2mnd-3"
|
|
34
|
-
})(["background:", ";box-sizing:border-box;border:1px solid ", ";border-radius:
|
|
36
|
+
})(["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;}"], _colors.Neutral.B100, _colors.Neutral.B68, _borderRadius.borderRadius4, _fonts.NotoSans, _colors.Neutral.B18, _colors.Neutral.B40, _colors.Neutral.B100, Breakpoints.large);
|
|
35
37
|
exports.StyledInput = StyledInput;
|
|
@@ -12,19 +12,18 @@ var MenuOption = function MenuOption(_ref) {
|
|
|
12
12
|
onClick = _ref.onClick,
|
|
13
13
|
value = _ref.value,
|
|
14
14
|
allowMultiple = _ref.allowMultiple;
|
|
15
|
-
var handleClick = function handleClick(
|
|
15
|
+
var handleClick = function handleClick(event) {
|
|
16
|
+
event.stopPropagation();
|
|
16
17
|
onClick({
|
|
17
|
-
value: value
|
|
18
|
+
value: event.currentTarget.dataset.value
|
|
18
19
|
});
|
|
19
20
|
};
|
|
20
21
|
return /*#__PURE__*/_react["default"].createElement(_MenuStyle.ListContainer, null, /*#__PURE__*/_react["default"].createElement("li", {
|
|
21
22
|
"aria-disabled": disabled,
|
|
22
23
|
"data-active": isSelected,
|
|
23
24
|
"data-multiple": allowMultiple,
|
|
24
|
-
value: value,
|
|
25
|
-
onClick:
|
|
26
|
-
return handleClick(value);
|
|
27
|
-
}
|
|
25
|
+
"data-value": value,
|
|
26
|
+
onClick: handleClick
|
|
28
27
|
}, children));
|
|
29
28
|
};
|
|
30
29
|
exports.MenuOption = MenuOption;
|
|
@@ -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 {};
|
|
@@ -7,7 +7,6 @@ var _Popover = require("../Popover");
|
|
|
7
7
|
var _Typography = require("../Typography");
|
|
8
8
|
var _colors = require("../utilities/colors");
|
|
9
9
|
var _components = require("./components");
|
|
10
|
-
var _ActivatorContext = require("./components/Activator/ActivatorContext");
|
|
11
10
|
var _ActivatorSelect = require("./components/Activator/ActivatorSelect");
|
|
12
11
|
var _Label = require("./components/Label/Label");
|
|
13
12
|
var _SelectStyle = require("./SelectStyle");
|
|
@@ -16,19 +15,25 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
16
15
|
var Select = function Select(_ref) {
|
|
17
16
|
var _ref$allowMultiple = _ref.allowMultiple,
|
|
18
17
|
allowMultiple = _ref$allowMultiple === void 0 ? false : _ref$allowMultiple,
|
|
19
|
-
disabled = _ref.disabled,
|
|
20
|
-
|
|
18
|
+
_ref$disabled = _ref.disabled,
|
|
19
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
20
|
+
_ref$hasError = _ref.hasError,
|
|
21
|
+
hasError = _ref$hasError === void 0 ? false : _ref$hasError,
|
|
21
22
|
helpText = _ref.helpText,
|
|
22
23
|
label = _ref.label,
|
|
23
24
|
onClose = _ref.onClose,
|
|
24
25
|
onRemoveTag = _ref.onRemoveTag,
|
|
25
26
|
onSelect = _ref.onSelect,
|
|
26
|
-
options = _ref.options,
|
|
27
|
+
_ref$options = _ref.options,
|
|
28
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
27
29
|
placeholder = _ref.placeholder,
|
|
28
30
|
listHeight = _ref.listHeight,
|
|
29
31
|
prefix = _ref.prefix,
|
|
32
|
+
_ref$searchable = _ref.searchable,
|
|
33
|
+
searchable = _ref$searchable === void 0 ? false : _ref$searchable,
|
|
30
34
|
searchableProps = _ref.searchableProps,
|
|
31
|
-
scrollable = _ref.scrollable,
|
|
35
|
+
_ref$scrollable = _ref.scrollable,
|
|
36
|
+
scrollable = _ref$scrollable === void 0 ? false : _ref$scrollable,
|
|
32
37
|
sections = _ref.sections,
|
|
33
38
|
selectedValues = _ref.selectedValues,
|
|
34
39
|
width = _ref.width;
|
|
@@ -38,34 +43,38 @@ var Select = function Select(_ref) {
|
|
|
38
43
|
var _useState2 = (0, _react.useState)(''),
|
|
39
44
|
optionListHeight = _useState2[0],
|
|
40
45
|
setOptionListHeight = _useState2[1];
|
|
41
|
-
var
|
|
46
|
+
var _useState3 = (0, _react.useState)(options),
|
|
47
|
+
menuOptions = _useState3[0],
|
|
48
|
+
setMenuOptions = _useState3[1];
|
|
49
|
+
var _useState4 = (0, _react.useState)((searchableProps == null ? void 0 : searchableProps.inputValue) || ''),
|
|
50
|
+
inputValue = _useState4[0],
|
|
51
|
+
setInputValue = _useState4[1];
|
|
52
|
+
var _useState5 = (0, _react.useState)({
|
|
53
|
+
showSelected: false,
|
|
54
|
+
showInput: true,
|
|
55
|
+
showPlaceholder: true
|
|
56
|
+
}),
|
|
57
|
+
searchableSelectState = _useState5[0],
|
|
58
|
+
setSearchableSelectState = _useState5[1];
|
|
59
|
+
var _updateSearchableSelectState = function updateSearchableSelectState(newState) {
|
|
60
|
+
setSearchableSelectState(newState);
|
|
61
|
+
};
|
|
62
|
+
var updateInputValue = function updateInputValue(newValue) {
|
|
63
|
+
setInputValue(newValue);
|
|
64
|
+
};
|
|
65
|
+
var updateMenuOptions = function updateMenuOptions(newState) {
|
|
66
|
+
setMenuOptions(newState);
|
|
67
|
+
};
|
|
68
|
+
var handleClose = function handleClose() {
|
|
42
69
|
setPopoverActive(false);
|
|
43
70
|
onClose == null ? void 0 : onClose();
|
|
44
|
-
}
|
|
71
|
+
};
|
|
45
72
|
var handleFocus = function handleFocus() {
|
|
46
73
|
setPopoverActive(true);
|
|
47
74
|
};
|
|
48
|
-
var handleBlur = function handleBlur() {
|
|
49
|
-
if (popoverActive) {
|
|
50
|
-
handleClose();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
75
|
var handleSelectClick = function handleSelectClick() {
|
|
54
76
|
setPopoverActive(!popoverActive);
|
|
55
77
|
};
|
|
56
|
-
var activatorSelectContextValue = {
|
|
57
|
-
allowMultiple: allowMultiple,
|
|
58
|
-
disabled: disabled,
|
|
59
|
-
hasError: hasError,
|
|
60
|
-
onSelectClick: handleSelectClick,
|
|
61
|
-
selectedValues: selectedValues
|
|
62
|
-
};
|
|
63
|
-
var activatorTextInputContextValue = {
|
|
64
|
-
disabled: disabled,
|
|
65
|
-
hasError: hasError,
|
|
66
|
-
onFocus: handleFocus,
|
|
67
|
-
onBlur: handleBlur
|
|
68
|
-
};
|
|
69
78
|
(0, _react.useEffect)(function () {
|
|
70
79
|
if (listHeight) {
|
|
71
80
|
setOptionListHeight(listHeight + 24 + "px");
|
|
@@ -77,28 +86,38 @@ var Select = function Select(_ref) {
|
|
|
77
86
|
}
|
|
78
87
|
}, [listHeight, scrollable]);
|
|
79
88
|
var activator = function activator() {
|
|
80
|
-
if (searchableProps) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
value: inputValue,
|
|
87
|
-
onChange: _onInputChange,
|
|
89
|
+
if (searchable || searchableProps) {
|
|
90
|
+
return /*#__PURE__*/_react["default"].createElement(_components.ActivatorTextInput, {
|
|
91
|
+
allowMultiple: allowMultiple,
|
|
92
|
+
disabled: disabled,
|
|
93
|
+
hasError: hasError,
|
|
94
|
+
onChange: searchableProps == null ? void 0 : searchableProps.onInputChange,
|
|
88
95
|
placeholder: placeholder != null ? placeholder : 'Search',
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
width: width,
|
|
97
|
+
selectedValues: selectedValues,
|
|
98
|
+
onSelect: onSelect,
|
|
99
|
+
onFocus: handleFocus,
|
|
100
|
+
inputValue: inputValue,
|
|
101
|
+
updateInputValue: updateInputValue,
|
|
102
|
+
searchableSelectState: searchableSelectState,
|
|
103
|
+
updateSearchableSelectState: function updateSearchableSelectState(newState) {
|
|
104
|
+
return _updateSearchableSelectState(newState);
|
|
105
|
+
},
|
|
106
|
+
options: options,
|
|
107
|
+
updateMenuOptions: updateMenuOptions,
|
|
108
|
+
prefix: prefix
|
|
109
|
+
});
|
|
92
110
|
}
|
|
93
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
94
|
-
|
|
95
|
-
}, /*#__PURE__*/_react["default"].createElement(_ActivatorSelect.ActivatorSelect, {
|
|
111
|
+
return /*#__PURE__*/_react["default"].createElement(_ActivatorSelect.ActivatorSelect, {
|
|
112
|
+
allowMultiple: allowMultiple,
|
|
96
113
|
disabled: disabled,
|
|
114
|
+
hasError: hasError,
|
|
97
115
|
placeholder: "Placeholder",
|
|
98
116
|
onRemoveTag: onRemoveTag,
|
|
117
|
+
onSelectClick: handleSelectClick,
|
|
99
118
|
width: width,
|
|
100
|
-
|
|
101
|
-
})
|
|
119
|
+
selectedValues: selectedValues
|
|
120
|
+
});
|
|
102
121
|
};
|
|
103
122
|
return /*#__PURE__*/_react["default"].createElement(_Popover.Popover, {
|
|
104
123
|
active: popoverActive,
|
|
@@ -113,15 +132,19 @@ var Select = function Select(_ref) {
|
|
|
113
132
|
autofocusTarget: "none",
|
|
114
133
|
preventFocusOnClose: true,
|
|
115
134
|
fullWidth: true
|
|
116
|
-
}, /*#__PURE__*/_react["default"].createElement(_Popover.Popover.Pane, {
|
|
135
|
+
}, !disabled && /*#__PURE__*/_react["default"].createElement(_Popover.Popover.Pane, {
|
|
117
136
|
height: optionListHeight
|
|
118
137
|
}, /*#__PURE__*/_react["default"].createElement(_components.OptionList, {
|
|
138
|
+
menuOptions: menuOptions,
|
|
119
139
|
allowMultiple: allowMultiple,
|
|
120
140
|
onSelect: onSelect,
|
|
121
|
-
options: options,
|
|
122
141
|
sections: sections,
|
|
123
142
|
selectedValues: selectedValues,
|
|
124
|
-
width: width
|
|
143
|
+
width: width,
|
|
144
|
+
onMenuClose: handleClose,
|
|
145
|
+
updateSearchableSelectState: function updateSearchableSelectState(newState) {
|
|
146
|
+
return _updateSearchableSelectState(newState);
|
|
147
|
+
}
|
|
125
148
|
})));
|
|
126
149
|
};
|
|
127
150
|
exports.Select = Select;
|
|
@@ -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;
|
|
@@ -9,29 +9,28 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _Icon = require("../../../Icon");
|
|
10
10
|
var _Typography = require("../../../Typography");
|
|
11
11
|
var _colors = require("../../../utilities/colors");
|
|
12
|
-
var _ActivatorContext = require("./ActivatorContext");
|
|
13
12
|
var _ActivatorStyle = require("./ActivatorStyle");
|
|
14
|
-
var _excluded = ["placeholder", "
|
|
13
|
+
var _excluded = ["placeholder", "selectedValues", "onClick", "onRemoveTag", "width", "allowMultiple", "disabled", "onSelectClick", "hasError"];
|
|
15
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
16
|
var ActivatorSelect = function ActivatorSelect(_ref) {
|
|
18
17
|
var placeholder = _ref.placeholder,
|
|
19
|
-
|
|
18
|
+
selectedValues = _ref.selectedValues,
|
|
20
19
|
onClick = _ref.onClick,
|
|
21
20
|
onRemoveTag = _ref.onRemoveTag,
|
|
22
21
|
width = _ref.width,
|
|
22
|
+
_ref$allowMultiple = _ref.allowMultiple,
|
|
23
|
+
allowMultiple = _ref$allowMultiple === void 0 ? false : _ref$allowMultiple,
|
|
24
|
+
disabled = _ref.disabled,
|
|
25
|
+
onSelectClick = _ref.onSelectClick,
|
|
26
|
+
_ref$hasError = _ref.hasError,
|
|
27
|
+
hasError = _ref$hasError === void 0 ? false : _ref$hasError,
|
|
23
28
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
24
29
|
var activatorRef = (0, _react.useRef)(null);
|
|
25
|
-
var filteredValues =
|
|
30
|
+
var filteredValues = selectedValues == null ? void 0 : selectedValues.filter(function (value) {
|
|
26
31
|
return value != '';
|
|
27
32
|
});
|
|
28
33
|
var hasValue = filteredValues.length > 0;
|
|
29
|
-
var activatorContext = (0, _ActivatorContext.useActivatorSelect)();
|
|
30
|
-
var allowMultiple = activatorContext.allowMultiple,
|
|
31
|
-
disabled = activatorContext.disabled,
|
|
32
|
-
onSelectClick = activatorContext.onSelectClick,
|
|
33
|
-
hasError = activatorContext.hasError,
|
|
34
|
-
selectedValues = activatorContext.selectedValues;
|
|
35
34
|
var handleClick = function handleClick(e) {
|
|
36
35
|
e.preventDefault();
|
|
37
36
|
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;
|