@zendeskgarden/react-dropdowns 9.0.0-next.2 → 9.0.0-next.20
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 +73 -69
- package/dist/esm/context/useComboboxContext.js +18 -0
- package/dist/esm/context/useFieldContext.js +18 -0
- package/dist/esm/context/useItemContext.js +18 -0
- package/dist/esm/context/useItemGroupContext.js +14 -0
- package/dist/esm/context/useMenuContext.js +18 -0
- package/dist/esm/context/useOptionContext.js +18 -0
- package/dist/esm/elements/combobox/Combobox.js +329 -0
- package/dist/esm/elements/combobox/Field.js +74 -0
- package/dist/esm/elements/combobox/Hint.js +56 -0
- package/dist/esm/elements/combobox/Label.js +67 -0
- package/dist/esm/elements/combobox/Listbox.js +154 -0
- package/dist/esm/elements/combobox/Message.js +62 -0
- package/dist/esm/elements/combobox/OptGroup.js +92 -0
- package/dist/esm/elements/combobox/Option.js +136 -0
- package/dist/esm/elements/combobox/OptionMeta.js +54 -0
- package/dist/esm/elements/combobox/Tag.js +97 -0
- package/dist/esm/elements/combobox/TagAvatar.js +13 -0
- package/dist/esm/elements/combobox/TagGroup.js +35 -0
- package/dist/esm/elements/combobox/utils.js +36 -0
- package/dist/esm/elements/menu/Item.js +141 -0
- package/dist/esm/elements/menu/ItemGroup.js +95 -0
- package/dist/esm/elements/menu/ItemMeta.js +54 -0
- package/dist/esm/elements/menu/Menu.js +126 -0
- package/dist/esm/elements/menu/MenuList.js +169 -0
- package/dist/esm/elements/menu/Separator.js +57 -0
- package/dist/esm/elements/menu/utils.js +55 -0
- package/dist/esm/index.js +19 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/check-lg-stroke.svg.js +28 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-left-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-right-stroke.svg.js +25 -0
- package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/plus-stroke.svg.js +26 -0
- package/dist/esm/types/index.js +12 -0
- package/dist/esm/views/combobox/StyledCombobox.js +30 -0
- package/dist/esm/views/combobox/StyledContainer.js +22 -0
- package/dist/esm/views/combobox/StyledField.js +22 -0
- package/dist/esm/views/combobox/StyledFloatingListbox.js +27 -0
- package/dist/esm/views/combobox/StyledHint.js +23 -0
- package/dist/esm/views/combobox/StyledInput.js +47 -0
- package/dist/esm/views/combobox/StyledInputGroup.js +26 -0
- package/dist/esm/views/combobox/StyledInputIcon.js +62 -0
- package/dist/esm/views/combobox/StyledLabel.js +23 -0
- package/dist/esm/views/combobox/StyledListbox.js +31 -0
- package/dist/esm/views/combobox/StyledListboxSeparator.js +37 -0
- package/dist/esm/views/combobox/StyledMessage.js +23 -0
- package/dist/esm/views/combobox/StyledOptGroup.js +22 -0
- package/dist/esm/views/combobox/StyledOption.js +69 -0
- package/dist/esm/views/combobox/StyledOptionContent.js +22 -0
- package/dist/esm/views/combobox/StyledOptionIcon.js +51 -0
- package/dist/esm/views/combobox/StyledOptionMeta.js +39 -0
- package/dist/esm/views/combobox/StyledOptionTypeIcon.js +58 -0
- package/dist/esm/views/combobox/StyledTag.js +27 -0
- package/dist/esm/views/combobox/StyledTagsButton.js +34 -0
- package/dist/esm/views/combobox/StyledTrigger.js +125 -0
- package/dist/esm/views/combobox/StyledValue.js +39 -0
- package/dist/esm/views/menu/StyledFloatingMenu.js +23 -0
- package/dist/esm/views/menu/StyledItem.js +23 -0
- package/dist/esm/views/menu/StyledItemContent.js +23 -0
- package/dist/esm/views/menu/StyledItemGroup.js +23 -0
- package/dist/esm/views/menu/StyledItemIcon.js +23 -0
- package/dist/esm/views/menu/StyledItemMeta.js +23 -0
- package/dist/esm/views/menu/StyledItemTypeIcon.js +24 -0
- package/dist/esm/views/menu/StyledMenu.js +27 -0
- package/dist/esm/views/menu/StyledSeparator.js +23 -0
- package/dist/index.cjs.js +1778 -1761
- package/dist/typings/context/useComboboxContext.d.ts +25 -0
- package/dist/typings/context/useFieldContext.d.ts +32 -0
- package/dist/typings/context/useItemContext.d.ts +14 -0
- package/dist/typings/context/useItemGroupContext.d.ts +15 -0
- package/dist/typings/context/useMenuContext.d.ts +23 -0
- package/dist/typings/context/useOptionContext.d.ts +14 -0
- package/dist/typings/elements/{Combobox → combobox}/Combobox.d.ts +0 -2
- package/dist/typings/elements/{Fields → combobox}/Field.d.ts +8 -1
- package/dist/typings/elements/{Fields → combobox}/Hint.d.ts +2 -0
- package/dist/typings/elements/{Fields → combobox}/Label.d.ts +3 -1
- package/dist/typings/elements/{Menu/Items/MediaBody.d.ts → combobox/Listbox.d.ts} +2 -4
- package/dist/typings/elements/{Fields → combobox}/Message.d.ts +3 -1
- package/dist/typings/elements/{Menu/Items/HeaderItem.d.ts → combobox/OptGroup.d.ts} +2 -2
- package/dist/typings/elements/{Menu/Items/MediaItem.d.ts → combobox/Option.d.ts} +5 -2
- package/dist/typings/elements/{Menu/Items/HeaderIcon.d.ts → combobox/OptionMeta.d.ts} +1 -1
- package/dist/typings/elements/combobox/Tag.d.ts +15 -0
- package/dist/typings/elements/combobox/TagAvatar.d.ts +14 -0
- package/dist/typings/elements/combobox/TagGroup.d.ts +12 -0
- package/dist/typings/elements/combobox/utils.d.ts +30 -0
- package/dist/typings/elements/{Menu/Items → menu}/Item.d.ts +5 -2
- package/dist/typings/elements/{Menu/Items/AddItem.d.ts → menu/ItemGroup.d.ts} +2 -2
- package/dist/typings/elements/{Menu/Items → menu}/ItemMeta.d.ts +2 -2
- package/dist/typings/elements/{Menu → menu}/Menu.d.ts +0 -2
- package/dist/typings/elements/menu/MenuList.d.ts +12 -0
- package/dist/typings/elements/{Menu → menu}/Separator.d.ts +1 -1
- package/dist/typings/elements/menu/utils.d.ts +29 -0
- package/dist/typings/index.d.ts +18 -25
- package/dist/typings/types/index.d.ts +242 -121
- package/dist/typings/{styled/items/StyledItemIcon.d.ts → views/combobox/StyledCombobox.d.ts} +4 -6
- package/dist/typings/{styled/multiselect/StyledMultiselectItemWrapper.d.ts → views/combobox/StyledContainer.d.ts} +1 -1
- package/dist/typings/{styled/select/StyledSelect.d.ts → views/combobox/StyledField.d.ts} +1 -1
- package/dist/typings/views/combobox/StyledFloatingListbox.d.ts +18 -0
- package/dist/typings/views/combobox/StyledHint.d.ts +11 -0
- package/dist/typings/views/combobox/StyledInput.d.ts +20 -0
- package/dist/typings/{styled/items/StyledAddItem.d.ts → views/combobox/StyledInputGroup.d.ts} +2 -4
- package/dist/typings/views/combobox/StyledInputIcon.d.ts +20 -0
- package/dist/typings/views/combobox/StyledLabel.d.ts +11 -0
- package/dist/typings/views/combobox/StyledListbox.d.ts +17 -0
- package/dist/typings/{styled/items/StyledNextItem.d.ts → views/combobox/StyledListboxSeparator.d.ts} +2 -4
- package/dist/typings/views/combobox/StyledMessage.d.ts +11 -0
- package/dist/typings/views/combobox/StyledOptGroup.d.ts +14 -0
- package/dist/typings/views/combobox/StyledOption.d.ts +18 -0
- package/dist/typings/views/combobox/StyledOptionContent.d.ts +10 -0
- package/dist/typings/views/combobox/StyledOptionIcon.d.ts +17 -0
- package/dist/typings/views/combobox/StyledOptionMeta.d.ts +14 -0
- package/dist/typings/views/combobox/StyledOptionTypeIcon.d.ts +17 -0
- package/dist/typings/views/combobox/StyledTag.d.ts +17 -0
- package/dist/typings/views/combobox/StyledTagsButton.d.ts +16 -0
- package/dist/typings/views/combobox/StyledTrigger.d.ts +24 -0
- package/dist/typings/views/combobox/StyledValue.d.ts +21 -0
- package/dist/typings/views/index.d.ts +37 -0
- package/dist/typings/views/menu/StyledFloatingMenu.d.ts +13 -0
- package/dist/typings/{styled/items/StyledPreviousItem.d.ts → views/menu/StyledItem.d.ts} +4 -4
- package/dist/typings/views/menu/StyledItemContent.d.ts +13 -0
- package/dist/typings/views/menu/StyledItemGroup.d.ts +13 -0
- package/dist/typings/views/menu/StyledItemIcon.d.ts +14 -0
- package/dist/typings/{styled/items → views/menu}/StyledItemMeta.d.ts +5 -10
- package/dist/typings/views/menu/StyledItemTypeIcon.d.ts +14 -0
- package/dist/typings/views/menu/StyledMenu.d.ts +19 -0
- package/dist/typings/{styled → views}/menu/StyledSeparator.d.ts +7 -4
- package/package.json +20 -18
- package/dist/index.esm.js +0 -2032
- package/dist/typings/elements/Autocomplete/Autocomplete.d.ts +0 -14
- package/dist/typings/elements/Dropdown/Dropdown.d.ts +0 -26
- package/dist/typings/elements/Menu/Items/MediaFigure.d.ts +0 -11
- package/dist/typings/elements/Menu/Items/NextItem.d.ts +0 -12
- package/dist/typings/elements/Menu/Items/PreviousItem.d.ts +0 -12
- package/dist/typings/elements/Multiselect/Multiselect.d.ts +0 -14
- package/dist/typings/elements/Select/Select.d.ts +0 -14
- package/dist/typings/elements/Trigger/Trigger.d.ts +0 -24
- package/dist/typings/styled/index.d.ts +0 -29
- package/dist/typings/styled/items/StyledItem.d.ts +0 -20
- package/dist/typings/styled/items/StyledNextIcon.d.ts +0 -12
- package/dist/typings/styled/items/StyledPreviousIcon.d.ts +0 -12
- package/dist/typings/styled/items/header/StyledHeaderIcon.d.ts +0 -14
- package/dist/typings/styled/items/header/StyledHeaderItem.d.ts +0 -16
- package/dist/typings/styled/items/media/StyledMediaBody.d.ts +0 -17
- package/dist/typings/styled/items/media/StyledMediaFigure.d.ts +0 -287
- package/dist/typings/styled/items/media/StyledMediaItem.d.ts +0 -13
- package/dist/typings/styled/menu/StyledMenu.d.ts +0 -20
- package/dist/typings/styled/menu/StyledMenuWrapper.d.ts +0 -16
- package/dist/typings/styled/multiselect/StyledMultiselectInput.d.ts +0 -22
- package/dist/typings/styled/multiselect/StyledMultiselectItemsContainer.d.ts +0 -16
- package/dist/typings/styled/multiselect/StyledMultiselectMoreAnchor.d.ts +0 -15
- package/dist/typings/styled/select/StyledFauxInput.d.ts +0 -22
- package/dist/typings/styled/select/StyledInput.d.ts +0 -15
- package/dist/typings/utils/garden-placements.d.ts +0 -26
- package/dist/typings/utils/useDropdownContext.d.ts +0 -28
- package/dist/typings/utils/useFieldContext.d.ts +0 -17
- package/dist/typings/utils/useItemContext.d.ts +0 -16
- package/dist/typings/utils/useMenuContext.d.ts +0 -17
package/dist/index.cjs.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
8
7
|
'use strict';
|
|
9
8
|
|
|
10
9
|
var React = require('react');
|
|
11
10
|
var PropTypes = require('prop-types');
|
|
12
11
|
var styled = require('styled-components');
|
|
13
|
-
var
|
|
14
|
-
var reactPopper = require('react-popper');
|
|
15
|
-
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
12
|
+
var containerCombobox = require('@zendeskgarden/container-combobox');
|
|
16
13
|
var reactTheming = require('@zendeskgarden/react-theming');
|
|
17
|
-
var polished = require('polished');
|
|
18
14
|
var reactForms = require('@zendeskgarden/react-forms');
|
|
15
|
+
var polished = require('polished');
|
|
16
|
+
var reactTags = require('@zendeskgarden/react-tags');
|
|
17
|
+
var reactDom$1 = require('react-dom');
|
|
18
|
+
var reactDom = require('@floating-ui/react-dom');
|
|
19
|
+
var containerUtilities = require('@zendeskgarden/container-utilities');
|
|
20
|
+
var reactTooltips = require('@zendeskgarden/react-tooltips');
|
|
19
21
|
var reactMergeRefs = require('react-merge-refs');
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
+
var containerMenu = require('@zendeskgarden/container-menu');
|
|
23
|
+
var reactButtons = require('@zendeskgarden/react-buttons');
|
|
22
24
|
|
|
23
25
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
26
|
|
|
@@ -43,1687 +45,1400 @@ function _interopNamespace(e) {
|
|
|
43
45
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
44
46
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
45
47
|
var styled__default = /*#__PURE__*/_interopDefault(styled);
|
|
46
|
-
var Downshift__default = /*#__PURE__*/_interopDefault(Downshift);
|
|
47
|
-
|
|
48
|
-
function _extends$5() {
|
|
49
|
-
_extends$5 = Object.assign ? Object.assign.bind() : function (target) {
|
|
50
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
51
|
-
var source = arguments[i];
|
|
52
|
-
for (var key in source) {
|
|
53
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
54
|
-
target[key] = source[key];
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return target;
|
|
59
|
-
};
|
|
60
|
-
return _extends$5.apply(this, arguments);
|
|
61
|
-
}
|
|
62
48
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
var _path$4;
|
|
50
|
+
function _extends$4() { return _extends$4 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$4.apply(null, arguments); }
|
|
51
|
+
var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
|
|
52
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$4({
|
|
53
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
+
width: 16,
|
|
55
|
+
height: 16,
|
|
56
|
+
focusable: "false",
|
|
57
|
+
viewBox: "0 0 16 16",
|
|
58
|
+
"aria-hidden": "true"
|
|
59
|
+
}, props), _path$4 || (_path$4 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
60
|
+
fill: "currentColor",
|
|
61
|
+
d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
|
|
62
|
+
})));
|
|
70
63
|
};
|
|
71
64
|
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
selectedItem,
|
|
78
|
-
selectedItems,
|
|
79
|
-
highlightedIndex,
|
|
80
|
-
inputValue,
|
|
81
|
-
onSelect,
|
|
82
|
-
onStateChange,
|
|
83
|
-
onInputValueChange,
|
|
84
|
-
downshiftProps
|
|
85
|
-
} = props;
|
|
86
|
-
const itemIndexRef = React.useRef(0);
|
|
87
|
-
const previousItemRef = React.useRef(undefined);
|
|
88
|
-
const previousIndexRef = React.useRef(undefined);
|
|
89
|
-
const nextItemsHashRef = React.useRef({});
|
|
90
|
-
const containsMultiselectRef = React.useRef(false);
|
|
91
|
-
const itemSearchRegistry = React.useRef([]);
|
|
92
|
-
const [dropdownType, setDropdownType] = React.useState('');
|
|
93
|
-
const {
|
|
94
|
-
rtl
|
|
95
|
-
} = React.useContext(styled.ThemeContext);
|
|
96
|
-
const hasMenuRef = React.useRef(false);
|
|
97
|
-
const popperReferenceElementRef = React.useRef(null);
|
|
98
|
-
const customGetInputProps = (_ref, downshift) => {
|
|
99
|
-
let {
|
|
100
|
-
onKeyDown,
|
|
101
|
-
...other
|
|
102
|
-
} = _ref;
|
|
103
|
-
return {
|
|
104
|
-
onKeyDown: containerUtilities.composeEventHandlers(onKeyDown, e => {
|
|
105
|
-
const PREVIOUS_KEY = rtl ? containerUtilities.KEY_CODES.RIGHT : containerUtilities.KEY_CODES.LEFT;
|
|
106
|
-
const NEXT_KEY = rtl ? containerUtilities.KEY_CODES.LEFT : containerUtilities.KEY_CODES.RIGHT;
|
|
107
|
-
if (downshift.isOpen) {
|
|
108
|
-
if (e.keyCode === PREVIOUS_KEY && previousIndexRef.current !== null && previousIndexRef.current !== undefined && !downshift.inputValue) {
|
|
109
|
-
e.preventDefault();
|
|
110
|
-
e.stopPropagation();
|
|
111
|
-
downshift.selectItemAtIndex(previousIndexRef.current);
|
|
112
|
-
}
|
|
113
|
-
if (e.keyCode === NEXT_KEY) {
|
|
114
|
-
const nextItemIndexes = Object.values(nextItemsHashRef.current);
|
|
115
|
-
if (nextItemIndexes.includes(downshift.highlightedIndex)) {
|
|
116
|
-
e.preventDefault();
|
|
117
|
-
e.stopPropagation();
|
|
118
|
-
downshift.selectItemAtIndex(downshift.highlightedIndex);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} else if ((e.keyCode === containerUtilities.KEY_CODES.ENTER || e.keyCode === containerUtilities.KEY_CODES.SPACE) && !downshift.isOpen && dropdownType !== 'combobox') {
|
|
122
|
-
e.preventDefault();
|
|
123
|
-
e.stopPropagation();
|
|
124
|
-
downshift.openMenu();
|
|
125
|
-
}
|
|
126
|
-
}),
|
|
127
|
-
...other
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
const transformDownshift = _ref2 => {
|
|
131
|
-
let {
|
|
132
|
-
getInputProps,
|
|
133
|
-
getToggleButtonProps,
|
|
134
|
-
...downshift
|
|
135
|
-
} = _ref2;
|
|
136
|
-
return {
|
|
137
|
-
getInputProps: p => getInputProps(customGetInputProps(p, downshift)),
|
|
138
|
-
getToggleButtonProps: p => getToggleButtonProps({
|
|
139
|
-
'aria-label': undefined,
|
|
140
|
-
...p
|
|
141
|
-
}),
|
|
142
|
-
...downshift
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
return React__namespace.default.createElement(reactPopper.Manager, null, React__namespace.default.createElement(Downshift__default.default, _extends$5({
|
|
146
|
-
suppressRefError: true
|
|
147
|
-
,
|
|
148
|
-
isOpen: isOpen,
|
|
149
|
-
highlightedIndex: highlightedIndex,
|
|
150
|
-
selectedItem: selectedItem || null
|
|
151
|
-
,
|
|
152
|
-
inputValue: inputValue,
|
|
153
|
-
onInputValueChange: (inputVal, stateAndHelpers) => {
|
|
154
|
-
if (onInputValueChange) {
|
|
155
|
-
if (stateAndHelpers.isOpen) {
|
|
156
|
-
onInputValueChange(inputVal, stateAndHelpers);
|
|
157
|
-
} else if (dropdownType === 'multiselect') {
|
|
158
|
-
onInputValueChange('', stateAndHelpers);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
onStateChange: (changes, stateAndHelpers) => {
|
|
163
|
-
if (dropdownType === 'autocomplete' && changes.isOpen === false && !changes.selectedItem) {
|
|
164
|
-
onSelect && onSelect(selectedItem, stateAndHelpers);
|
|
165
|
-
}
|
|
166
|
-
if (Object.prototype.hasOwnProperty.call(changes, 'selectedItem') && changes.selectedItem !== null) {
|
|
167
|
-
if (selectedItems) {
|
|
168
|
-
const {
|
|
169
|
-
itemToString
|
|
170
|
-
} = stateAndHelpers;
|
|
171
|
-
const existingItemIndex = selectedItems.findIndex(item => {
|
|
172
|
-
return itemToString(item) === itemToString(changes.selectedItem);
|
|
173
|
-
});
|
|
174
|
-
const updatedSelectedItems = Array.from(selectedItems);
|
|
175
|
-
if (existingItemIndex === -1) {
|
|
176
|
-
updatedSelectedItems.splice(updatedSelectedItems.length, 0, changes.selectedItem);
|
|
177
|
-
} else {
|
|
178
|
-
updatedSelectedItems.splice(existingItemIndex, 1);
|
|
179
|
-
}
|
|
180
|
-
changes.selectedItems = updatedSelectedItems;
|
|
181
|
-
delete changes.selectedItem;
|
|
182
|
-
onSelect && onSelect(updatedSelectedItems, stateAndHelpers);
|
|
183
|
-
} else {
|
|
184
|
-
onSelect && onSelect(changes.selectedItem, stateAndHelpers);
|
|
185
|
-
}
|
|
186
|
-
if (dropdownType === 'multiselect') {
|
|
187
|
-
stateAndHelpers.setState({
|
|
188
|
-
inputValue: ''
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
onStateChange && onStateChange(changes, stateAndHelpers);
|
|
193
|
-
},
|
|
194
|
-
stateReducer: (_state, changes) => {
|
|
195
|
-
switch (changes.type) {
|
|
196
|
-
case Downshift__default.default.stateChangeTypes.changeInput:
|
|
197
|
-
if (changes.inputValue === '' && dropdownType === 'combobox') {
|
|
198
|
-
return {
|
|
199
|
-
...changes,
|
|
200
|
-
isOpen: false
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return changes;
|
|
204
|
-
default:
|
|
205
|
-
return changes;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}, downshiftProps), downshift => React__namespace.default.createElement(DropdownContext.Provider, {
|
|
209
|
-
value: {
|
|
210
|
-
hasMenuRef,
|
|
211
|
-
itemIndexRef,
|
|
212
|
-
previousItemRef,
|
|
213
|
-
previousIndexRef,
|
|
214
|
-
nextItemsHashRef,
|
|
215
|
-
popperReferenceElementRef,
|
|
216
|
-
selectedItems,
|
|
217
|
-
downshift: transformDownshift(downshift),
|
|
218
|
-
containsMultiselectRef,
|
|
219
|
-
itemSearchRegistry,
|
|
220
|
-
setDropdownType
|
|
221
|
-
}
|
|
222
|
-
}, children)));
|
|
223
|
-
};
|
|
224
|
-
Dropdown.propTypes = {
|
|
225
|
-
isOpen: PropTypes__default.default.bool,
|
|
226
|
-
selectedItem: PropTypes__default.default.any,
|
|
227
|
-
selectedItems: PropTypes__default.default.arrayOf(PropTypes__default.default.any),
|
|
228
|
-
highlightedIndex: PropTypes__default.default.number,
|
|
229
|
-
inputValue: PropTypes__default.default.string,
|
|
230
|
-
onSelect: PropTypes__default.default.func,
|
|
231
|
-
onStateChange: PropTypes__default.default.func,
|
|
232
|
-
downshiftProps: PropTypes__default.default.object
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
function getPopperPlacement(gardenPlacement) {
|
|
236
|
-
switch (gardenPlacement) {
|
|
237
|
-
case 'end':
|
|
238
|
-
return 'right';
|
|
239
|
-
case 'end-top':
|
|
240
|
-
return 'right-start';
|
|
241
|
-
case 'end-bottom':
|
|
242
|
-
return 'right-end';
|
|
243
|
-
case 'start':
|
|
244
|
-
return 'left';
|
|
245
|
-
case 'start-top':
|
|
246
|
-
return 'left-start';
|
|
247
|
-
case 'start-bottom':
|
|
248
|
-
return 'left-end';
|
|
249
|
-
default:
|
|
250
|
-
return gardenPlacement;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function getRtlPopperPlacement(gardenPlacement) {
|
|
254
|
-
const popperPlacement = getPopperPlacement(gardenPlacement);
|
|
255
|
-
switch (popperPlacement) {
|
|
256
|
-
case 'left':
|
|
257
|
-
return 'right';
|
|
258
|
-
case 'left-start':
|
|
259
|
-
return 'right-start';
|
|
260
|
-
case 'left-end':
|
|
261
|
-
return 'right-end';
|
|
262
|
-
case 'top-start':
|
|
263
|
-
return 'top-end';
|
|
264
|
-
case 'top-end':
|
|
265
|
-
return 'top-start';
|
|
266
|
-
case 'right':
|
|
267
|
-
return 'left';
|
|
268
|
-
case 'right-start':
|
|
269
|
-
return 'left-start';
|
|
270
|
-
case 'right-end':
|
|
271
|
-
return 'left-end';
|
|
272
|
-
case 'bottom-start':
|
|
273
|
-
return 'bottom-end';
|
|
274
|
-
case 'bottom-end':
|
|
275
|
-
return 'bottom-start';
|
|
276
|
-
default:
|
|
277
|
-
return popperPlacement;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function getArrowPosition(popperPlacement) {
|
|
281
|
-
const arrowPositionMappings = {
|
|
282
|
-
auto: 'top',
|
|
283
|
-
top: 'bottom',
|
|
284
|
-
'top-start': 'bottom-left',
|
|
285
|
-
'top-end': 'bottom-right',
|
|
286
|
-
right: 'left',
|
|
287
|
-
'right-start': 'left-top',
|
|
288
|
-
'right-end': 'left-bottom',
|
|
289
|
-
bottom: 'top',
|
|
290
|
-
'bottom-start': 'top-left',
|
|
291
|
-
'bottom-end': 'top-right',
|
|
292
|
-
left: 'right',
|
|
293
|
-
'left-start': 'right-top',
|
|
294
|
-
'left-end': 'right-bottom'
|
|
295
|
-
};
|
|
296
|
-
return popperPlacement ? arrowPositionMappings[popperPlacement] : 'top';
|
|
297
|
-
}
|
|
298
|
-
function getMenuPosition(popperPlacement) {
|
|
299
|
-
if (popperPlacement === 'auto') {
|
|
300
|
-
return 'bottom';
|
|
65
|
+
const ComboboxContext = React.createContext(undefined);
|
|
66
|
+
const useComboboxContext = () => {
|
|
67
|
+
const context = React.useContext(ComboboxContext);
|
|
68
|
+
if (!context) {
|
|
69
|
+
throw new Error('Error: this component must be rendered within a <Combobox>.');
|
|
301
70
|
}
|
|
302
|
-
return
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const COMPONENT_ID$m = 'dropdowns.menu';
|
|
306
|
-
const StyledMenu = styled__default.default.ul.attrs(props => ({
|
|
307
|
-
'data-garden-id': COMPONENT_ID$m,
|
|
308
|
-
'data-garden-version': '9.0.0-next.2',
|
|
309
|
-
className: props.isAnimated && 'is-animated'
|
|
310
|
-
})).withConfig({
|
|
311
|
-
displayName: "StyledMenu",
|
|
312
|
-
componentId: "sc-1vpttfd-0"
|
|
313
|
-
})(["position:static !important;max-height:", ";overflow-y:auto;", ";", ";"], props => props.maxHeight, props => props.hasArrow && reactTheming.arrowStyles(getArrowPosition(props.placement), {
|
|
314
|
-
size: `${props.theme.space.base * 2}px`,
|
|
315
|
-
inset: '2px',
|
|
316
|
-
animationModifier: props.isAnimated ? '.is-animated' : undefined
|
|
317
|
-
}), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$m, props));
|
|
318
|
-
StyledMenu.defaultProps = {
|
|
319
|
-
theme: reactTheming.DEFAULT_THEME
|
|
71
|
+
return context;
|
|
320
72
|
};
|
|
321
73
|
|
|
322
|
-
const
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
componentId: "sc-tiwdxz-0"
|
|
330
|
-
})(["", ";", ";"], props => reactTheming.menuStyles(getMenuPosition(props.placement), {
|
|
331
|
-
theme: props.theme,
|
|
332
|
-
hidden: props.isHidden,
|
|
333
|
-
margin: `${props.theme.space.base * (props.hasArrow ? 2 : 1)}px`,
|
|
334
|
-
zIndex: props.zIndex,
|
|
335
|
-
animationModifier: props.isAnimated ? '.is-animated' : undefined
|
|
336
|
-
}), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$l, props));
|
|
337
|
-
StyledMenuWrapper.defaultProps = {
|
|
338
|
-
theme: reactTheming.DEFAULT_THEME
|
|
74
|
+
const FieldContext = React.createContext(undefined);
|
|
75
|
+
const useFieldContext = () => {
|
|
76
|
+
const context = React.useContext(FieldContext);
|
|
77
|
+
if (!context) {
|
|
78
|
+
throw new Error('Error: this component must be rendered within a <Field>.');
|
|
79
|
+
}
|
|
80
|
+
return context;
|
|
339
81
|
};
|
|
340
82
|
|
|
341
|
-
const COMPONENT_ID$
|
|
342
|
-
const
|
|
343
|
-
'data-garden-id': COMPONENT_ID$
|
|
344
|
-
'data-garden-version': '9.0.0-next.
|
|
345
|
-
role: 'separator'
|
|
83
|
+
const COMPONENT_ID$u = 'dropdowns.combobox.label';
|
|
84
|
+
const StyledLabel = styled__default.default(reactForms.Field.Label).attrs({
|
|
85
|
+
'data-garden-id': COMPONENT_ID$u,
|
|
86
|
+
'data-garden-version': '9.0.0-next.20'
|
|
346
87
|
}).withConfig({
|
|
347
|
-
displayName: "
|
|
348
|
-
componentId: "sc-
|
|
349
|
-
})(["
|
|
350
|
-
|
|
88
|
+
displayName: "StyledLabel",
|
|
89
|
+
componentId: "sc-az6now-0"
|
|
90
|
+
})(["vertical-align:revert;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$u, props));
|
|
91
|
+
StyledLabel.defaultProps = {
|
|
351
92
|
theme: reactTheming.DEFAULT_THEME
|
|
352
93
|
};
|
|
353
94
|
|
|
354
|
-
const COMPONENT_ID$
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
let backgroundColor;
|
|
364
|
-
if (props.disabled) {
|
|
365
|
-
foregroundColor = reactTheming.getColor('neutralHue', 400, props.theme);
|
|
366
|
-
} else if (props.isDanger) {
|
|
367
|
-
foregroundColor = reactTheming.getColor('dangerHue', 600, props.theme);
|
|
368
|
-
backgroundColor = props.isFocused ? polished.rgba(foregroundColor, 0.08) : 'inherit';
|
|
369
|
-
} else {
|
|
370
|
-
foregroundColor = props.theme.colors.foreground;
|
|
371
|
-
backgroundColor = props.isFocused ? reactTheming.getColor('primaryHue', 600, props.theme, 0.08) : 'inherit';
|
|
372
|
-
}
|
|
373
|
-
return styled.css(["background-color:", ";color:", ";& a,& a:hover,& a:focus,& a:active{color:inherit;}"], backgroundColor, foregroundColor);
|
|
374
|
-
};
|
|
375
|
-
const StyledItem = styled__default.default.li.attrs(props => ({
|
|
376
|
-
'data-garden-id': COMPONENT_ID$j,
|
|
377
|
-
'data-garden-version': '9.0.0-next.2',
|
|
378
|
-
'aria-disabled': props.disabled
|
|
379
|
-
})).withConfig({
|
|
380
|
-
displayName: "StyledItem",
|
|
381
|
-
componentId: "sc-1xeog7q-0"
|
|
382
|
-
})(["display:block;position:relative;z-index:0;cursor:", ";padding:", " ", "px;text-decoration:none;line-height:", "px;word-wrap:break-word;user-select:none;&:first-child{margin-top:", "px;}&:last-child{margin-bottom:", "px;}&:focus{outline:none;}& a,& a:hover,& a:focus,& a:active{text-decoration:none;}", ";", ";"], props => props.disabled ? 'default' : 'pointer', props => getItemPaddingVertical(props), props => props.theme.space.base * 9, props => props.theme.space.base * 5, props => props.theme.space.base, props => props.theme.space.base, props => getColorStyles(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$j, props));
|
|
383
|
-
StyledItem.defaultProps = {
|
|
95
|
+
const COMPONENT_ID$t = 'dropdowns.combobox.hint';
|
|
96
|
+
const StyledHint = styled__default.default(reactForms.Field.Hint).attrs({
|
|
97
|
+
'data-garden-id': COMPONENT_ID$t,
|
|
98
|
+
'data-garden-version': '9.0.0-next.20'
|
|
99
|
+
}).withConfig({
|
|
100
|
+
displayName: "StyledHint",
|
|
101
|
+
componentId: "sc-106qvqx-0"
|
|
102
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$t, props));
|
|
103
|
+
StyledHint.defaultProps = {
|
|
384
104
|
theme: reactTheming.DEFAULT_THEME
|
|
385
105
|
};
|
|
386
106
|
|
|
387
|
-
const COMPONENT_ID$
|
|
388
|
-
const
|
|
389
|
-
'data-garden-id': COMPONENT_ID$
|
|
390
|
-
'data-garden-version': '9.0.0-next.
|
|
107
|
+
const COMPONENT_ID$s = 'dropdowns.combobox.message';
|
|
108
|
+
const StyledMessage = styled__default.default(reactForms.Field.Message).attrs({
|
|
109
|
+
'data-garden-id': COMPONENT_ID$s,
|
|
110
|
+
'data-garden-version': '9.0.0-next.20'
|
|
391
111
|
}).withConfig({
|
|
392
|
-
displayName: "
|
|
393
|
-
componentId: "sc-
|
|
394
|
-
})(["
|
|
395
|
-
|
|
112
|
+
displayName: "StyledMessage",
|
|
113
|
+
componentId: "sc-jux8m5-0"
|
|
114
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$s, props));
|
|
115
|
+
StyledMessage.defaultProps = {
|
|
396
116
|
theme: reactTheming.DEFAULT_THEME
|
|
397
117
|
};
|
|
398
118
|
|
|
399
|
-
const COMPONENT_ID$
|
|
400
|
-
const
|
|
401
|
-
|
|
402
|
-
|
|
119
|
+
const COMPONENT_ID$r = 'dropdowns.combobox';
|
|
120
|
+
const sizeStyles$a = props => {
|
|
121
|
+
const minWidth = `${props.isCompact ? 100 : 144}px`;
|
|
122
|
+
const marginTop = `${props.theme.space.base * (props.isCompact ? 1 : 2)}px`;
|
|
123
|
+
return styled.css(["min-width:", ";", ":not([hidden]) + &&,", " + &&,", " + &&,&& + ", ",&& + ", "{margin-top:", ";}"], minWidth, StyledLabel, StyledHint, StyledMessage, StyledHint, StyledMessage, marginTop);
|
|
124
|
+
};
|
|
125
|
+
const StyledCombobox = styled__default.default.div.attrs({
|
|
126
|
+
'data-garden-id': COMPONENT_ID$r,
|
|
127
|
+
'data-garden-version': '9.0.0-next.20'
|
|
403
128
|
}).withConfig({
|
|
404
|
-
displayName: "
|
|
405
|
-
componentId: "sc-
|
|
406
|
-
})(["
|
|
407
|
-
|
|
129
|
+
displayName: "StyledCombobox",
|
|
130
|
+
componentId: "sc-13eybg8-0"
|
|
131
|
+
})(["", ";", ";"], sizeStyles$a, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$r, props));
|
|
132
|
+
StyledCombobox.defaultProps = {
|
|
408
133
|
theme: reactTheming.DEFAULT_THEME
|
|
409
134
|
};
|
|
410
135
|
|
|
411
|
-
const COMPONENT_ID$
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const StyledItemIcon = styled__default.default.div.attrs({
|
|
416
|
-
'data-garden-id': COMPONENT_ID$g,
|
|
417
|
-
'data-garden-version': '9.0.0-next.2'
|
|
136
|
+
const COMPONENT_ID$q = 'dropdowns.combobox.container';
|
|
137
|
+
const StyledContainer = styled__default.default.div.attrs({
|
|
138
|
+
'data-garden-id': COMPONENT_ID$q,
|
|
139
|
+
'data-garden-version': '9.0.0-next.20'
|
|
418
140
|
}).withConfig({
|
|
419
|
-
displayName: "
|
|
420
|
-
componentId: "sc-
|
|
421
|
-
})(["display:flex;
|
|
422
|
-
|
|
141
|
+
displayName: "StyledContainer",
|
|
142
|
+
componentId: "sc-14i9jid-0"
|
|
143
|
+
})(["display:flex;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$q, props));
|
|
144
|
+
StyledContainer.defaultProps = {
|
|
423
145
|
theme: reactTheming.DEFAULT_THEME
|
|
424
146
|
};
|
|
425
147
|
|
|
426
|
-
const COMPONENT_ID$
|
|
427
|
-
const
|
|
428
|
-
'data-garden-id': COMPONENT_ID$
|
|
429
|
-
'data-garden-version': '9.0.0-next.
|
|
148
|
+
const COMPONENT_ID$p = 'dropdowns.combobox.field';
|
|
149
|
+
const StyledField = styled__default.default.div.attrs({
|
|
150
|
+
'data-garden-id': COMPONENT_ID$p,
|
|
151
|
+
'data-garden-version': '9.0.0-next.20'
|
|
430
152
|
}).withConfig({
|
|
431
|
-
displayName: "
|
|
432
|
-
componentId: "sc-
|
|
433
|
-
})(["
|
|
434
|
-
|
|
153
|
+
displayName: "StyledField",
|
|
154
|
+
componentId: "sc-zc57xl-0"
|
|
155
|
+
})(["direction:", ";", ";"], props => props.theme.rtl ? 'rtl' : 'ltr', props => reactTheming.retrieveComponentStyles(COMPONENT_ID$p, props));
|
|
156
|
+
StyledField.defaultProps = {
|
|
435
157
|
theme: reactTheming.DEFAULT_THEME
|
|
436
158
|
};
|
|
437
159
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
160
|
+
const COMPONENT_ID$o = 'dropdowns.combobox.floating';
|
|
161
|
+
const StyledFloatingListbox = styled__default.default.div.attrs({
|
|
162
|
+
'data-garden-id': COMPONENT_ID$o,
|
|
163
|
+
'data-garden-version': '9.0.0-next.20'
|
|
164
|
+
}).withConfig({
|
|
165
|
+
displayName: "StyledFloatingListbox",
|
|
166
|
+
componentId: "sc-1cp6spf-0"
|
|
167
|
+
})(["top:0;left:0;", ";", ";"], props => reactTheming.menuStyles(props.position, {
|
|
168
|
+
theme: props.theme,
|
|
169
|
+
hidden: props.isHidden,
|
|
170
|
+
animationModifier: '[data-garden-animate="true"]',
|
|
171
|
+
zIndex: props.zIndex
|
|
172
|
+
}), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$o, props));
|
|
173
|
+
StyledFloatingListbox.defaultProps = {
|
|
174
|
+
theme: reactTheming.DEFAULT_THEME
|
|
452
175
|
};
|
|
453
176
|
|
|
454
|
-
const COMPONENT_ID$
|
|
455
|
-
const
|
|
177
|
+
const COMPONENT_ID$n = 'dropdowns.combobox.input';
|
|
178
|
+
const colorStyles$9 = _ref => {
|
|
456
179
|
let {
|
|
457
|
-
|
|
180
|
+
theme
|
|
458
181
|
} = _ref;
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
className: className
|
|
182
|
+
const placeholderColor = reactTheming.getColor({
|
|
183
|
+
theme,
|
|
184
|
+
variable: 'foreground.disabled'
|
|
463
185
|
});
|
|
186
|
+
return styled.css(["background-color:inherit;color:inherit;&::placeholder{opacity:1;color:", ";}"], placeholderColor);
|
|
464
187
|
};
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
theme: reactTheming.DEFAULT_THEME
|
|
188
|
+
const getHeight = props => {
|
|
189
|
+
if (props.isBare && !props.isMultiselectable) {
|
|
190
|
+
return props.theme.space.base * 5;
|
|
191
|
+
}
|
|
192
|
+
return props.theme.space.base * (props.isCompact ? 5 : 8);
|
|
471
193
|
};
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
194
|
+
const sizeStyles$9 = props => {
|
|
195
|
+
const height = props.theme.space.base * 5;
|
|
196
|
+
const fontSize = props.theme.fontSizes.md;
|
|
197
|
+
const lineHeight = reactTheming.getLineHeight(height, fontSize);
|
|
198
|
+
const margin = polished.math(`${props.theme.shadowWidths.sm} + ${(getHeight(props) - height) / 2}`);
|
|
199
|
+
const minWidth = `${props.theme.space.base * 8}px`;
|
|
200
|
+
return styled.css(["min-width:", ";height:", "px;line-height:", ";font-size:", ";&&{margin-top:", ";margin-bottom:", ";}"], minWidth, height, lineHeight, fontSize, margin, margin);
|
|
201
|
+
};
|
|
202
|
+
const StyledInput = styled__default.default.input.attrs({
|
|
203
|
+
'data-garden-id': COMPONENT_ID$n,
|
|
204
|
+
'data-garden-version': '9.0.0-next.20'
|
|
477
205
|
}).withConfig({
|
|
478
|
-
displayName: "
|
|
479
|
-
componentId: "sc-
|
|
480
|
-
})(["font-
|
|
481
|
-
|
|
206
|
+
displayName: "StyledInput",
|
|
207
|
+
componentId: "sc-1lkqdg-0"
|
|
208
|
+
})(["flex-basis:0;flex-grow:1;border:none;padding:0;font-family:inherit;&:focus{outline:none;}", ";", ";&[hidden]{display:revert;", "}&[aria-hidden='true']{display:none;}", ";"], sizeStyles$9, colorStyles$9, props => props.isEditable && polished.hideVisually(), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$n, props));
|
|
209
|
+
StyledInput.defaultProps = {
|
|
482
210
|
theme: reactTheming.DEFAULT_THEME
|
|
483
211
|
};
|
|
484
212
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
213
|
+
const COMPONENT_ID$m = 'dropdowns.combobox.input_group';
|
|
214
|
+
const sizeStyles$8 = props => {
|
|
215
|
+
const margin = props.theme.shadowWidths.sm;
|
|
216
|
+
return styled.css(["margin:-", ";min-width:0;& > *{margin:", ";}"], margin, margin);
|
|
217
|
+
};
|
|
218
|
+
const StyledInputGroup = styled__default.default.div.attrs({
|
|
219
|
+
'data-garden-id': COMPONENT_ID$m,
|
|
220
|
+
'data-garden-version': '9.0.0-next.20'
|
|
221
|
+
}).withConfig({
|
|
222
|
+
displayName: "StyledInputGroup",
|
|
223
|
+
componentId: "sc-yx3q7u-0"
|
|
224
|
+
})(["display:flex;flex-grow:1;flex-wrap:wrap;", ";", ";"], sizeStyles$8, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$m, props));
|
|
225
|
+
StyledInputGroup.defaultProps = {
|
|
226
|
+
theme: reactTheming.DEFAULT_THEME
|
|
499
227
|
};
|
|
500
228
|
|
|
501
|
-
const COMPONENT_ID$
|
|
502
|
-
const
|
|
229
|
+
const COMPONENT_ID$l = 'dropdowns.combobox.trigger';
|
|
230
|
+
const colorStyles$8 = _ref => {
|
|
503
231
|
let {
|
|
504
|
-
|
|
232
|
+
theme,
|
|
233
|
+
validation,
|
|
234
|
+
isBare,
|
|
235
|
+
isLabelHovered,
|
|
236
|
+
focusInset
|
|
505
237
|
} = _ref;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
238
|
+
const foregroundColor = reactTheming.getColor({
|
|
239
|
+
theme,
|
|
240
|
+
variable: 'foreground.default'
|
|
241
|
+
});
|
|
242
|
+
const backgroundColor = isBare ? 'transparent' : reactTheming.getColor({
|
|
243
|
+
theme,
|
|
244
|
+
variable: 'background.default'
|
|
245
|
+
});
|
|
246
|
+
let borderColor;
|
|
247
|
+
let borderVariable;
|
|
248
|
+
let hoverBorderColor;
|
|
249
|
+
let focusBorderColor;
|
|
250
|
+
if (validation) {
|
|
251
|
+
if (validation === 'success') {
|
|
252
|
+
borderVariable = 'border.successEmphasis';
|
|
253
|
+
} else if (validation === 'warning') {
|
|
254
|
+
borderVariable = 'border.warningEmphasis';
|
|
255
|
+
} else if (validation === 'error') {
|
|
256
|
+
borderVariable = 'border.dangerEmphasis';
|
|
257
|
+
}
|
|
258
|
+
borderColor = reactTheming.getColor({
|
|
259
|
+
theme,
|
|
260
|
+
variable: borderVariable
|
|
261
|
+
});
|
|
262
|
+
hoverBorderColor = borderColor;
|
|
263
|
+
focusBorderColor = borderColor;
|
|
264
|
+
} else {
|
|
265
|
+
borderColor = reactTheming.getColor({
|
|
266
|
+
theme,
|
|
267
|
+
variable: 'border.default',
|
|
268
|
+
dark: {
|
|
269
|
+
offset: -100
|
|
270
|
+
},
|
|
271
|
+
light: {
|
|
272
|
+
offset: 100
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
borderVariable = 'border.primaryEmphasis';
|
|
276
|
+
hoverBorderColor = reactTheming.getColor({
|
|
277
|
+
theme,
|
|
278
|
+
variable: borderVariable
|
|
279
|
+
});
|
|
280
|
+
focusBorderColor = hoverBorderColor;
|
|
281
|
+
}
|
|
282
|
+
const disabledBackgroundColor = isBare ? undefined : reactTheming.getColor({
|
|
283
|
+
theme,
|
|
284
|
+
variable: 'background.disabled'
|
|
285
|
+
});
|
|
286
|
+
const disabledBorderColor = reactTheming.getColor({
|
|
287
|
+
theme,
|
|
288
|
+
variable: 'border.disabled'
|
|
510
289
|
});
|
|
290
|
+
const disabledForegroundColor = reactTheming.getColor({
|
|
291
|
+
theme,
|
|
292
|
+
variable: 'foreground.disabled'
|
|
293
|
+
});
|
|
294
|
+
const focusSelector = `
|
|
295
|
+
&:focus-within:not([aria-disabled='true']),
|
|
296
|
+
&:focus-visible
|
|
297
|
+
`;
|
|
298
|
+
return styled.css(["color-scheme:only ", ";border-color:", ";background-color:", ";color:", ";&:hover{border-color:", ";}", " &[aria-disabled='true']{border-color:", ";background-color:", ";color:", ";}"], theme.colors.base, isLabelHovered ? hoverBorderColor : borderColor, backgroundColor, foregroundColor, hoverBorderColor, reactTheming.focusStyles({
|
|
299
|
+
theme,
|
|
300
|
+
inset: focusInset,
|
|
301
|
+
color: {
|
|
302
|
+
variable: borderVariable
|
|
303
|
+
},
|
|
304
|
+
selector: focusSelector,
|
|
305
|
+
styles: {
|
|
306
|
+
borderColor: focusBorderColor
|
|
307
|
+
},
|
|
308
|
+
condition: !isBare
|
|
309
|
+
}), disabledBorderColor, disabledBackgroundColor, disabledForegroundColor);
|
|
511
310
|
};
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
311
|
+
const sizeStyles$7 = props => {
|
|
312
|
+
const inputHeight = getHeight(props);
|
|
313
|
+
let minHeight;
|
|
314
|
+
let horizontalPadding;
|
|
315
|
+
if (props.isBare) {
|
|
316
|
+
if (props.isMultiselectable) {
|
|
317
|
+
minHeight = polished.math(`${props.theme.shadowWidths.sm} * 2 + ${inputHeight}`);
|
|
318
|
+
horizontalPadding = props.theme.shadowWidths.sm;
|
|
319
|
+
} else {
|
|
320
|
+
minHeight = `${inputHeight}px`;
|
|
321
|
+
horizontalPadding = '0';
|
|
322
|
+
}
|
|
323
|
+
} else {
|
|
324
|
+
minHeight = `${props.theme.space.base * (props.isCompact ? 3 : 2) + inputHeight}px`;
|
|
325
|
+
horizontalPadding = `${props.theme.space.base * 3}px`;
|
|
326
|
+
}
|
|
327
|
+
const maxHeight = props.maxHeight || minHeight;
|
|
328
|
+
const verticalPadding = polished.math(`(${minHeight} - ${inputHeight} - (${props.isBare ? 0 : props.theme.borderWidths.sm} * 2)) / 2`);
|
|
329
|
+
return styled.css(["padding:", " ", ";min-height:", ";max-height:", ";font-size:", ";"], verticalPadding, horizontalPadding, minHeight, maxHeight, props.theme.fontSizes.md);
|
|
518
330
|
};
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
'data-garden-id': COMPONENT_ID$b,
|
|
523
|
-
'data-garden-version': '9.0.0-next.2'
|
|
331
|
+
const StyledTrigger = styled__default.default.div.attrs({
|
|
332
|
+
'data-garden-id': COMPONENT_ID$l,
|
|
333
|
+
'data-garden-version': '9.0.0-next.20'
|
|
524
334
|
}).withConfig({
|
|
525
|
-
displayName: "
|
|
526
|
-
componentId: "sc-
|
|
527
|
-
})(["
|
|
528
|
-
|
|
335
|
+
displayName: "StyledTrigger",
|
|
336
|
+
componentId: "sc-116nftk-0"
|
|
337
|
+
})(["overflow-y:", ";transition:border-color 0.25s ease-in-out,box-shadow 0.1s ease-in-out,background-color 0.25s ease-in-out,color 0.25s ease-in-out;border:", ";border-radius:", ";cursor:", ";box-sizing:border-box;", ";&:focus{outline:none;}", ";&[aria-disabled='true']{cursor:default;}", ";"], props => props.isBare && !props.isMultiselectable ? 'visible' : 'auto', props => props.isBare ? 'none' : props.theme.borders.sm, props => props.isBare ? '0' : props.theme.borderRadii.md, props => !props.isAutocomplete && props.isEditable ? 'text' : 'pointer', sizeStyles$7, colorStyles$8, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$l, props));
|
|
338
|
+
StyledTrigger.defaultProps = {
|
|
529
339
|
theme: reactTheming.DEFAULT_THEME
|
|
530
340
|
};
|
|
531
341
|
|
|
532
|
-
const COMPONENT_ID$
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
342
|
+
const COMPONENT_ID$k = 'dropdowns.combobox.input_icon';
|
|
343
|
+
const colorStyles$7 = _ref => {
|
|
344
|
+
let {
|
|
345
|
+
theme,
|
|
346
|
+
$isLabelHovered
|
|
347
|
+
} = _ref;
|
|
348
|
+
const options = {
|
|
349
|
+
theme,
|
|
350
|
+
variable: 'foreground.subtle'
|
|
351
|
+
};
|
|
352
|
+
const color = reactTheming.getColor(options);
|
|
353
|
+
const focusColor = reactTheming.getColor({
|
|
354
|
+
...options,
|
|
355
|
+
dark: {
|
|
356
|
+
offset: -100
|
|
357
|
+
},
|
|
358
|
+
light: {
|
|
359
|
+
offset: 100
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
const disabledColor = reactTheming.getColor({
|
|
363
|
+
theme,
|
|
364
|
+
variable: 'foreground.disabled'
|
|
365
|
+
});
|
|
366
|
+
return styled.css(["color:", ";", ":hover &&,", ":focus-within &&,", ":focus &&{color:", ";}", "[aria-disabled='true'] &&{color:", ";}"], $isLabelHovered ? focusColor : color, StyledTrigger, StyledTrigger, StyledTrigger, focusColor, StyledTrigger, disabledColor);
|
|
538
367
|
};
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
368
|
+
const sizeStyles$6 = props => {
|
|
369
|
+
const size = props.theme.iconSizes.md;
|
|
370
|
+
const position = polished.math(`(${getHeight(props)} - ${size}) / 2`);
|
|
371
|
+
const margin = `${props.theme.space.base * 2}px`;
|
|
372
|
+
let side;
|
|
373
|
+
if (props.$isEnd) {
|
|
374
|
+
side = props.theme.rtl ? 'right' : 'left';
|
|
375
|
+
} else {
|
|
376
|
+
side = props.theme.rtl ? 'left' : 'right';
|
|
377
|
+
}
|
|
378
|
+
return styled.css(["top:", ";margin-", ":", ";width:", ";height:", ";"], position, side, margin, size, size);
|
|
548
379
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
'data-garden-id': COMPONENT_ID$9,
|
|
553
|
-
'data-garden-version': '9.0.0-next.2'
|
|
380
|
+
const StyledInputIcon = styled__default.default(reactTheming.StyledBaseIcon).attrs({
|
|
381
|
+
'data-garden-id': COMPONENT_ID$k,
|
|
382
|
+
'data-garden-version': '9.0.0-next.20'
|
|
554
383
|
}).withConfig({
|
|
555
|
-
displayName: "
|
|
556
|
-
componentId: "sc-
|
|
557
|
-
})(["
|
|
558
|
-
|
|
384
|
+
displayName: "StyledInputIcon",
|
|
385
|
+
componentId: "sc-gqbs1s-0"
|
|
386
|
+
})(["position:sticky;flex-shrink:0;transform:", ";transition:transform 0.25s ease-in-out,color 0.25s ease-in-out;", ";", ";", ";"], props => props.$isRotated && `rotate(${props.theme.rtl ? '-' : '+'}180deg)`, sizeStyles$6, colorStyles$7, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$k, props));
|
|
387
|
+
StyledInputIcon.defaultProps = {
|
|
559
388
|
theme: reactTheming.DEFAULT_THEME
|
|
560
389
|
};
|
|
561
390
|
|
|
562
|
-
const COMPONENT_ID$
|
|
563
|
-
const
|
|
564
|
-
_ref => {
|
|
391
|
+
const COMPONENT_ID$j = 'dropdowns.combobox.option';
|
|
392
|
+
const colorStyles$6 = _ref => {
|
|
565
393
|
let {
|
|
566
|
-
children,
|
|
567
|
-
isCompact,
|
|
568
394
|
theme,
|
|
569
|
-
|
|
395
|
+
isActive,
|
|
396
|
+
$type
|
|
570
397
|
} = _ref;
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
)
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
398
|
+
let backgroundColor;
|
|
399
|
+
let boxShadow;
|
|
400
|
+
if (isActive && $type !== 'group' && $type !== 'header') {
|
|
401
|
+
const variable = 'background.primaryEmphasis';
|
|
402
|
+
backgroundColor = reactTheming.getColor({
|
|
403
|
+
theme,
|
|
404
|
+
variable,
|
|
405
|
+
transparency: theme.opacity[100]
|
|
406
|
+
});
|
|
407
|
+
boxShadow = `inset ${theme.rtl ? `-${theme.shadowWidths.md}` : theme.shadowWidths.md} 0 ${reactTheming.getColor({
|
|
408
|
+
theme,
|
|
409
|
+
variable
|
|
410
|
+
})}`;
|
|
411
|
+
}
|
|
412
|
+
let foregroundVariable;
|
|
413
|
+
if ($type === 'add') {
|
|
414
|
+
foregroundVariable = 'foreground.primary';
|
|
415
|
+
} else if ($type === 'danger') {
|
|
416
|
+
foregroundVariable = 'foreground.danger';
|
|
417
|
+
} else {
|
|
418
|
+
foregroundVariable = 'foreground.default';
|
|
419
|
+
}
|
|
420
|
+
const foregroundColor = reactTheming.getColor({
|
|
421
|
+
theme,
|
|
422
|
+
variable: foregroundVariable
|
|
423
|
+
});
|
|
424
|
+
const disabledForegroundColor = reactTheming.getColor({
|
|
425
|
+
theme,
|
|
426
|
+
variable: 'foreground.disabled'
|
|
427
|
+
});
|
|
428
|
+
return styled.css(["box-shadow:", ";background-color:", ";color:", ";&[aria-disabled='true']{background-color:transparent;color:", ";}"], boxShadow, backgroundColor, foregroundColor, disabledForegroundColor);
|
|
583
429
|
};
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
'
|
|
430
|
+
const getMinHeight = props => props.theme.space.base * (props.isCompact ? 7 : 9);
|
|
431
|
+
const sizeStyles$5 = props => {
|
|
432
|
+
const lineHeight = props.theme.lineHeights.md;
|
|
433
|
+
const minHeight = getMinHeight(props);
|
|
434
|
+
const paddingHorizontal = props.$type === 'group' ? 0 : `${props.theme.space.base * 9}px`;
|
|
435
|
+
const paddingVertical = props.$type === 'group' ? 0 : polished.math(`(${minHeight} - ${lineHeight}) / 2`);
|
|
436
|
+
return styled.css(["box-sizing:border-box;padding:", " ", ";min-height:", "px;line-height:", ";"], paddingVertical, paddingHorizontal, minHeight, lineHeight);
|
|
437
|
+
};
|
|
438
|
+
const StyledOption = styled__default.default.li.attrs({
|
|
439
|
+
'data-garden-id': COMPONENT_ID$j,
|
|
440
|
+
'data-garden-version': '9.0.0-next.20'
|
|
589
441
|
}).withConfig({
|
|
590
|
-
displayName: "
|
|
591
|
-
componentId: "sc-
|
|
592
|
-
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$
|
|
593
|
-
|
|
442
|
+
displayName: "StyledOption",
|
|
443
|
+
componentId: "sc-jl4wn6-0"
|
|
444
|
+
})(["display:flex;position:relative;transition:color 0.25s ease-in-out;cursor:", ";overflow-wrap:anywhere;font-weight:", ";user-select:none;&:focus{outline:none;}", ";", ";&[aria-disabled='true']{cursor:default;}&[aria-hidden='true']{", ";}", ";"], props => props.$type === 'group' || props.$type === 'header' ? 'default' : 'pointer', props => props.$type === 'header' || props.$type === 'previous' ? props.theme.fontWeights.semibold : props.theme.fontWeights.regular, sizeStyles$5, colorStyles$6, polished.hideVisually(), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$j, props));
|
|
445
|
+
StyledOption.defaultProps = {
|
|
594
446
|
theme: reactTheming.DEFAULT_THEME
|
|
595
447
|
};
|
|
596
448
|
|
|
597
|
-
const COMPONENT_ID$
|
|
598
|
-
const
|
|
599
|
-
'data-garden-id': COMPONENT_ID$
|
|
600
|
-
'data-garden-version': '9.0.0-next.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
})(["cursor:", ";min-width:", "px;", ";"], props => !props.disabled && 'pointer', props => props.theme.space.base * (props.isCompact ? 25 : 36), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
607
|
-
StyledFauxInput.defaultProps = {
|
|
449
|
+
const COMPONENT_ID$i = 'dropdowns.combobox.option.content';
|
|
450
|
+
const StyledOptionContent = styled__default.default.div.attrs({
|
|
451
|
+
'data-garden-id': COMPONENT_ID$i,
|
|
452
|
+
'data-garden-version': '9.0.0-next.20'
|
|
453
|
+
}).withConfig({
|
|
454
|
+
displayName: "StyledOptionContent",
|
|
455
|
+
componentId: "sc-121ujpu-0"
|
|
456
|
+
})(["display:flex;flex-direction:column;flex-grow:1;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$i, props));
|
|
457
|
+
StyledOptionContent.defaultProps = {
|
|
608
458
|
theme: reactTheming.DEFAULT_THEME
|
|
609
459
|
};
|
|
610
460
|
|
|
611
|
-
const COMPONENT_ID$
|
|
612
|
-
const
|
|
613
|
-
|
|
614
|
-
'data-garden-
|
|
615
|
-
'data-garden-version': '9.0.0-next.2',
|
|
616
|
-
isBare: true
|
|
461
|
+
const COMPONENT_ID$h = 'dropdowns.combobox.optgroup';
|
|
462
|
+
const StyledOptGroup = styled__default.default.ul.attrs({
|
|
463
|
+
'data-garden-id': COMPONENT_ID$h,
|
|
464
|
+
'data-garden-version': '9.0.0-next.20'
|
|
617
465
|
}).withConfig({
|
|
618
|
-
displayName: "
|
|
619
|
-
componentId: "sc-
|
|
620
|
-
})(["
|
|
621
|
-
|
|
466
|
+
displayName: "StyledOptGroup",
|
|
467
|
+
componentId: "sc-1kavqsx-0"
|
|
468
|
+
})(["margin:0;padding:0;list-style-type:none;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$h, props));
|
|
469
|
+
StyledOptGroup.defaultProps = {
|
|
622
470
|
theme: reactTheming.DEFAULT_THEME
|
|
623
471
|
};
|
|
624
472
|
|
|
625
|
-
const COMPONENT_ID$
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
473
|
+
const COMPONENT_ID$g = 'dropdowns.combobox.separator';
|
|
474
|
+
const colorStyles$5 = _ref => {
|
|
475
|
+
let {
|
|
476
|
+
theme
|
|
477
|
+
} = _ref;
|
|
478
|
+
const backgroundColor = reactTheming.getColor({
|
|
479
|
+
theme,
|
|
480
|
+
variable: 'border.subtle'
|
|
481
|
+
});
|
|
482
|
+
return styled.css(["background-color:", ";"], backgroundColor);
|
|
483
|
+
};
|
|
484
|
+
const sizeStyles$4 = props => {
|
|
485
|
+
const margin = `${props.theme.space.base}px`;
|
|
486
|
+
const height = props.theme.borderWidths.sm;
|
|
487
|
+
return styled.css(["margin:", " 0;height:", ";"], margin, height);
|
|
488
|
+
};
|
|
489
|
+
const StyledListboxSeparator = styled__default.default.li.attrs({
|
|
490
|
+
'data-garden-id': COMPONENT_ID$g,
|
|
491
|
+
'data-garden-version': '9.0.0-next.20'
|
|
629
492
|
}).withConfig({
|
|
630
|
-
displayName: "
|
|
631
|
-
componentId: "sc-
|
|
632
|
-
})(["
|
|
633
|
-
|
|
493
|
+
displayName: "StyledListboxSeparator",
|
|
494
|
+
componentId: "sc-1p6toh2-0"
|
|
495
|
+
})(["cursor:default;", ";", ";", ";"], sizeStyles$4, colorStyles$5, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$g, props));
|
|
496
|
+
StyledListboxSeparator.defaultProps = {
|
|
634
497
|
theme: reactTheming.DEFAULT_THEME
|
|
635
498
|
};
|
|
636
499
|
|
|
637
|
-
const COMPONENT_ID$
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
if (props.isVisible) {
|
|
643
|
-
height = `${props.theme.space.base * (props.isCompact ? 5 : 8)}px`;
|
|
644
|
-
}
|
|
645
|
-
return styled.css(["opacity:", ";margin:", ";width:", ";min-width:", ";height:", ";"], !props.isVisible && 0, margin, !props.isVisible && 0, minWidth, height);
|
|
500
|
+
const COMPONENT_ID$f = 'dropdowns.combobox.listbox';
|
|
501
|
+
const sizeStyles$3 = props => {
|
|
502
|
+
const padding = props.theme.space.base;
|
|
503
|
+
const minHeight = props.minHeight === undefined ? `${getMinHeight(props) + padding * 2}px` : props.minHeight;
|
|
504
|
+
return styled.css(["min-height:", ";max-height:", ";&&&{padding-top:", "px;padding-bottom:", "px;}"], minHeight, props.maxHeight, padding, padding);
|
|
646
505
|
};
|
|
647
|
-
const
|
|
648
|
-
'data-garden-id': COMPONENT_ID$
|
|
649
|
-
'data-garden-version': '9.0.0-next.
|
|
650
|
-
isBare: true
|
|
506
|
+
const StyledListbox = styled__default.default.ul.attrs({
|
|
507
|
+
'data-garden-id': COMPONENT_ID$f,
|
|
508
|
+
'data-garden-version': '9.0.0-next.20'
|
|
651
509
|
}).withConfig({
|
|
652
|
-
displayName: "
|
|
653
|
-
componentId: "sc-
|
|
654
|
-
})(["
|
|
655
|
-
|
|
510
|
+
displayName: "StyledListbox",
|
|
511
|
+
componentId: "sc-1k13ba7-0"
|
|
512
|
+
})(["overflow-y:auto;list-style-type:none;", ";&&&{display:block;}", ":first-child ", " ", ":first-child ", "[role='none']:first-child{display:none;}"], sizeStyles$3, StyledOption, StyledOptionContent, StyledOptGroup, StyledListboxSeparator);
|
|
513
|
+
StyledListbox.defaultProps = {
|
|
656
514
|
theme: reactTheming.DEFAULT_THEME
|
|
657
515
|
};
|
|
658
516
|
|
|
659
|
-
const COMPONENT_ID$
|
|
660
|
-
const
|
|
661
|
-
let
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
517
|
+
const COMPONENT_ID$e = 'dropdowns.combobox.option.icon';
|
|
518
|
+
const colorStyles$4 = _ref => {
|
|
519
|
+
let {
|
|
520
|
+
theme,
|
|
521
|
+
$isDisabled,
|
|
522
|
+
$type
|
|
523
|
+
} = _ref;
|
|
524
|
+
let variable;
|
|
525
|
+
if ($isDisabled) {
|
|
526
|
+
variable = 'foreground.disabled';
|
|
527
|
+
} else if ($type === 'danger') {
|
|
528
|
+
variable = 'foreground.danger';
|
|
529
|
+
} else if ($type === 'add') {
|
|
530
|
+
variable = 'foreground.primary';
|
|
531
|
+
} else {
|
|
532
|
+
variable = 'foreground.subtle';
|
|
669
533
|
}
|
|
670
|
-
|
|
534
|
+
const color = reactTheming.getColor({
|
|
535
|
+
theme,
|
|
536
|
+
variable
|
|
537
|
+
});
|
|
538
|
+
return styled.css(["color:", ";"], color);
|
|
671
539
|
};
|
|
672
|
-
const
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
componentId: "sc-1jzhet8-0"
|
|
678
|
-
})(["display:inline-flex;flex-grow:1;flex-wrap:wrap;min-width:0;", ";", ";"], props => sizeStyles(props), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
679
|
-
StyledMultiselectItemsContainer.defaultProps = {
|
|
680
|
-
theme: reactTheming.DEFAULT_THEME
|
|
540
|
+
const sizeStyles$2 = props => {
|
|
541
|
+
const size = props.theme.iconSizes.md;
|
|
542
|
+
const marginTop = polished.math(`(${props.theme.lineHeights.md} - ${size}) / 2`);
|
|
543
|
+
const marginHorizontal = `${props.theme.space.base * 2}px`;
|
|
544
|
+
return styled.css(["margin-top:", ";margin-", ":", ";width:", ";height:", ";"], marginTop, props.theme.rtl ? 'left' : 'right', marginHorizontal, size, size);
|
|
681
545
|
};
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
'data-garden-id': COMPONENT_ID$1,
|
|
686
|
-
'data-garden-version': '9.0.0-next.2'
|
|
546
|
+
const StyledOptionIcon = styled__default.default(reactTheming.StyledBaseIcon).attrs({
|
|
547
|
+
'data-garden-id': COMPONENT_ID$e,
|
|
548
|
+
'data-garden-version': '9.0.0-next.20'
|
|
687
549
|
}).withConfig({
|
|
688
|
-
displayName: "
|
|
689
|
-
componentId: "sc-
|
|
690
|
-
})(["
|
|
691
|
-
|
|
550
|
+
displayName: "StyledOptionIcon",
|
|
551
|
+
componentId: "sc-qsab3y-0"
|
|
552
|
+
})(["flex-shrink:0;", ";", ";", ";"], sizeStyles$2, colorStyles$4, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$e, props));
|
|
553
|
+
StyledOptionIcon.defaultProps = {
|
|
692
554
|
theme: reactTheming.DEFAULT_THEME
|
|
693
555
|
};
|
|
694
556
|
|
|
695
|
-
const COMPONENT_ID = 'dropdowns.
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
|
|
557
|
+
const COMPONENT_ID$d = 'dropdowns.combobox.option.meta';
|
|
558
|
+
const colorStyles$3 = _ref => {
|
|
559
|
+
let {
|
|
560
|
+
theme,
|
|
561
|
+
isDisabled
|
|
562
|
+
} = _ref;
|
|
563
|
+
const variable = isDisabled ? 'foreground.disabled' : 'foreground.subtle';
|
|
564
|
+
const color = reactTheming.getColor({
|
|
565
|
+
theme,
|
|
566
|
+
variable
|
|
567
|
+
});
|
|
568
|
+
return styled.css(["color:", ";"], color);
|
|
569
|
+
};
|
|
570
|
+
const sizeStyles$1 = props => {
|
|
571
|
+
const lineHeight = props.theme.lineHeights.sm;
|
|
572
|
+
const fontSize = props.theme.fontSizes.sm;
|
|
573
|
+
return styled.css(["line-height:", ";font-size:", ";"], lineHeight, fontSize);
|
|
574
|
+
};
|
|
575
|
+
const StyledOptionMeta = styled__default.default.div.attrs({
|
|
576
|
+
'data-garden-id': COMPONENT_ID$d,
|
|
577
|
+
'data-garden-version': '9.0.0-next.20'
|
|
699
578
|
}).withConfig({
|
|
700
|
-
displayName: "
|
|
701
|
-
componentId: "sc-
|
|
702
|
-
})(["
|
|
703
|
-
|
|
579
|
+
displayName: "StyledOptionMeta",
|
|
580
|
+
componentId: "sc-j6pu10-0"
|
|
581
|
+
})(["transition:color 0.25s ease-in-out;font-weight:", ";", ";", ";", ";"], props => props.theme.fontWeights.regular, sizeStyles$1, colorStyles$3, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$d, props));
|
|
582
|
+
StyledOptionMeta.defaultProps = {
|
|
704
583
|
theme: reactTheming.DEFAULT_THEME
|
|
705
584
|
};
|
|
706
585
|
|
|
707
|
-
const
|
|
586
|
+
const COMPONENT_ID$c = 'dropdowns.combobox.option.type_icon';
|
|
587
|
+
const colorStyles$2 = _ref => {
|
|
708
588
|
let {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
...triggerProps
|
|
589
|
+
theme,
|
|
590
|
+
$type
|
|
712
591
|
} = _ref;
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
highlightedIndex,
|
|
722
|
-
selectItemAtIndex,
|
|
723
|
-
setHighlightedIndex
|
|
724
|
-
}
|
|
725
|
-
} = useDropdownContext();
|
|
726
|
-
const hiddenInputRef = React.useRef(null);
|
|
727
|
-
const triggerRef = React.useRef(null);
|
|
728
|
-
const previousIsOpenRef = React.useRef(undefined);
|
|
729
|
-
const [searchString, setSearchString] = React.useState('');
|
|
730
|
-
const searchTimeoutRef = React.useRef();
|
|
731
|
-
const currentSearchIndexRef = React.useRef(0);
|
|
732
|
-
React.useEffect(() => {
|
|
733
|
-
if (hiddenInputRef.current && isOpen && !previousIsOpenRef.current) {
|
|
734
|
-
hiddenInputRef.current.focus();
|
|
735
|
-
}
|
|
736
|
-
if (triggerRef.current && !isOpen && previousIsOpenRef.current) {
|
|
737
|
-
triggerRef.current.focus();
|
|
738
|
-
}
|
|
739
|
-
previousIsOpenRef.current = isOpen;
|
|
740
|
-
}, [isOpen, hasMenuRef]);
|
|
741
|
-
React.useEffect(() => {
|
|
742
|
-
if (hasMenuRef.current === false) {
|
|
743
|
-
hasMenuRef.current = true;
|
|
744
|
-
}
|
|
745
|
-
}, [hasMenuRef]);
|
|
746
|
-
React.useEffect(() => {
|
|
747
|
-
if (searchTimeoutRef.current) {
|
|
748
|
-
clearTimeout(searchTimeoutRef.current);
|
|
749
|
-
}
|
|
750
|
-
searchTimeoutRef.current = window.setTimeout(() => {
|
|
751
|
-
setSearchString('');
|
|
752
|
-
}, 500);
|
|
753
|
-
return () => {
|
|
754
|
-
clearTimeout(searchTimeoutRef.current);
|
|
755
|
-
};
|
|
756
|
-
}, [searchString]);
|
|
757
|
-
const searchItems = React.useCallback((searchValue, startIndex, endIndex) => {
|
|
758
|
-
for (let index = startIndex; index < endIndex; index++) {
|
|
759
|
-
const itemTextValue = itemSearchRegistry.current[index];
|
|
760
|
-
if (itemTextValue && itemTextValue.toUpperCase().indexOf(searchValue.toUpperCase()) === 0) {
|
|
761
|
-
return index;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
return undefined;
|
|
765
|
-
}, [itemSearchRegistry]);
|
|
766
|
-
const onInputKeyDown = React.useCallback(e => {
|
|
767
|
-
if (e.keyCode === containerUtilities.KEY_CODES.SPACE) {
|
|
768
|
-
if (searchString) {
|
|
769
|
-
e.preventDefault();
|
|
770
|
-
e.stopPropagation();
|
|
771
|
-
} else if (highlightedIndex !== null && highlightedIndex !== undefined) {
|
|
772
|
-
e.preventDefault();
|
|
773
|
-
e.stopPropagation();
|
|
774
|
-
selectItemAtIndex(highlightedIndex);
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
if ((e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 65 || e.keyCode > 90) && e.keyCode !== containerUtilities.KEY_CODES.SPACE) {
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
const character = String.fromCharCode(e.which || e.keyCode);
|
|
781
|
-
if (!character || character.length === 0) {
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
if (!searchString) {
|
|
785
|
-
if (highlightedIndex === null || highlightedIndex === undefined) {
|
|
786
|
-
currentSearchIndexRef.current = -1;
|
|
787
|
-
} else {
|
|
788
|
-
currentSearchIndexRef.current = highlightedIndex;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
const newSearchString = searchString + character;
|
|
792
|
-
setSearchString(newSearchString);
|
|
793
|
-
let matchingIndex = searchItems(newSearchString, currentSearchIndexRef.current + 1, itemSearchRegistry.current.length);
|
|
794
|
-
if (matchingIndex === undefined) {
|
|
795
|
-
matchingIndex = searchItems(newSearchString, 0, currentSearchIndexRef.current);
|
|
796
|
-
}
|
|
797
|
-
if (matchingIndex !== undefined) {
|
|
798
|
-
setHighlightedIndex(matchingIndex);
|
|
799
|
-
}
|
|
800
|
-
}, [searchString, searchItems, itemSearchRegistry, highlightedIndex, selectItemAtIndex, setHighlightedIndex]);
|
|
801
|
-
const renderChildren = popperRef => {
|
|
802
|
-
const {
|
|
803
|
-
ref: rootPropsRefCallback,
|
|
804
|
-
...rootProps
|
|
805
|
-
} = getRootProps();
|
|
806
|
-
const listboxToggleProps = getToggleButtonProps({
|
|
807
|
-
...rootProps,
|
|
808
|
-
role: null,
|
|
809
|
-
'aria-labelledby': undefined,
|
|
810
|
-
...triggerProps,
|
|
811
|
-
...children.props
|
|
592
|
+
const opacity = $type && $type !== 'danger' ? 1 : 0;
|
|
593
|
+
let color;
|
|
594
|
+
if ($type === 'add') {
|
|
595
|
+
color = 'inherit';
|
|
596
|
+
} else if ($type === 'header' || $type === 'next' || $type === 'previous') {
|
|
597
|
+
color = reactTheming.getColor({
|
|
598
|
+
theme,
|
|
599
|
+
variable: 'foreground.subtle'
|
|
812
600
|
});
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
'aria-owns': null
|
|
818
|
-
};
|
|
819
|
-
const toggleButtonProps = hasMenuRef.current ? menuToggleProps : listboxToggleProps;
|
|
820
|
-
return React__namespace.default.cloneElement(React__namespace.default.Children.only(children), {
|
|
821
|
-
...toggleButtonProps,
|
|
822
|
-
[refKey]: childRef => {
|
|
823
|
-
popperRef(childRef);
|
|
824
|
-
triggerRef.current = childRef;
|
|
825
|
-
rootPropsRefCallback(childRef);
|
|
826
|
-
}
|
|
601
|
+
} else {
|
|
602
|
+
color = reactTheming.getColor({
|
|
603
|
+
theme,
|
|
604
|
+
variable: 'foreground.primary'
|
|
827
605
|
});
|
|
828
|
-
}
|
|
829
|
-
return
|
|
830
|
-
let {
|
|
831
|
-
ref: popperReference
|
|
832
|
-
} = _ref2;
|
|
833
|
-
return React__namespace.default.createElement(React__namespace.default.Fragment, null, renderChildren(popperReference), React__namespace.default.createElement(StyledInput, getInputProps({
|
|
834
|
-
readOnly: true,
|
|
835
|
-
isHidden: true,
|
|
836
|
-
tabIndex: -1,
|
|
837
|
-
ref: hiddenInputRef,
|
|
838
|
-
value: '',
|
|
839
|
-
onClick: e => {
|
|
840
|
-
if (isOpen) {
|
|
841
|
-
e.nativeEvent.preventDownshiftDefault = true;
|
|
842
|
-
}
|
|
843
|
-
},
|
|
844
|
-
onKeyDown: onInputKeyDown
|
|
845
|
-
})));
|
|
846
|
-
});
|
|
606
|
+
}
|
|
607
|
+
return styled.css(["opacity:", ";color:", ";", "[aria-selected='true'] > &{opacity:1;}", "[aria-disabled='true'] > &{color:inherit;}"], opacity, color, StyledOption, StyledOption);
|
|
847
608
|
};
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
609
|
+
const sizeStyles = props => {
|
|
610
|
+
const size = props.theme.iconSizes.md;
|
|
611
|
+
const position = `${props.theme.space.base * 3}px`;
|
|
612
|
+
const top = polished.math(`(${getMinHeight(props)} - ${size}) / 2`);
|
|
613
|
+
let side;
|
|
614
|
+
if (props.$type === 'next') {
|
|
615
|
+
side = props.theme.rtl ? 'left' : 'right';
|
|
616
|
+
} else {
|
|
617
|
+
side = props.theme.rtl ? 'right' : 'left';
|
|
618
|
+
}
|
|
619
|
+
return styled.css(["top:", ";", ":", ";width:", ";height:", ";"], top, side, position, size, size);
|
|
851
620
|
};
|
|
852
|
-
|
|
853
|
-
|
|
621
|
+
const StyledOptionTypeIcon = styled__default.default(reactTheming.StyledBaseIcon).attrs({
|
|
622
|
+
'data-garden-id': COMPONENT_ID$c,
|
|
623
|
+
'data-garden-version': '9.0.0-next.20'
|
|
624
|
+
}).withConfig({
|
|
625
|
+
displayName: "StyledOptionTypeIcon",
|
|
626
|
+
componentId: "sc-xpink2-0"
|
|
627
|
+
})(["position:absolute;transform:", ";transition:opacity 0.1s ease-in-out;", ";", ";", ";"], props => props.theme.rtl && (props.$type === 'next' || props.$type === 'previous') && 'rotate(180deg)', sizeStyles, colorStyles$2, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$c, props));
|
|
628
|
+
StyledOptionTypeIcon.defaultProps = {
|
|
629
|
+
theme: reactTheming.DEFAULT_THEME
|
|
854
630
|
};
|
|
855
631
|
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
})));
|
|
632
|
+
const COMPONENT_ID$b = 'dropdowns.combobox.tag';
|
|
633
|
+
const StyledTag = styled__default.default(reactTags.Tag).attrs({
|
|
634
|
+
'data-garden-id': COMPONENT_ID$b,
|
|
635
|
+
'data-garden-version': '9.0.0-next.20'
|
|
636
|
+
}).withConfig({
|
|
637
|
+
displayName: "StyledTag",
|
|
638
|
+
componentId: "sc-1alam0r-0"
|
|
639
|
+
})(["&[aria-disabled='true']{color:", ";}&[hidden]{display:revert;", "}", ";"], props => props.hue ? undefined : reactTheming.getColor({
|
|
640
|
+
theme: props.theme,
|
|
641
|
+
variable: 'foreground.disabled'
|
|
642
|
+
}), polished.hideVisually(), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$b, props));
|
|
643
|
+
StyledTag.defaultProps = {
|
|
644
|
+
theme: reactTheming.DEFAULT_THEME
|
|
870
645
|
};
|
|
871
646
|
|
|
872
|
-
const
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
647
|
+
const COMPONENT_ID$a = 'dropdowns.combobox.value';
|
|
648
|
+
const colorStyles$1 = _ref => {
|
|
649
|
+
let {
|
|
650
|
+
theme,
|
|
651
|
+
isPlaceholder
|
|
652
|
+
} = _ref;
|
|
653
|
+
const foregroundColor = isPlaceholder && reactTheming.getColor({
|
|
654
|
+
theme,
|
|
655
|
+
variable: 'foreground.disabled'
|
|
656
|
+
});
|
|
657
|
+
return styled.css(["color:", ";"], foregroundColor);
|
|
658
|
+
};
|
|
659
|
+
const StyledValue = styled__default.default.div.attrs({
|
|
660
|
+
'data-garden-id': COMPONENT_ID$a,
|
|
661
|
+
'data-garden-version': '9.0.0-next.20'
|
|
662
|
+
}).withConfig({
|
|
663
|
+
displayName: "StyledValue",
|
|
664
|
+
componentId: "sc-t719sx-0"
|
|
665
|
+
})(["flex-basis:0;flex-grow:1;cursor:", ";overflow:hidden;text-overflow:ellipsis;white-space:pre;user-select:none;", ";", ";&[hidden]{display:none;}", ";"], props => {
|
|
666
|
+
if (props.isDisabled) {
|
|
667
|
+
return 'default';
|
|
877
668
|
}
|
|
878
|
-
return
|
|
669
|
+
return props.isEditable && !props.isAutocomplete ? 'text' : 'pointer';
|
|
670
|
+
}, sizeStyles$9, colorStyles$1, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$a, props));
|
|
671
|
+
StyledValue.defaultProps = {
|
|
672
|
+
theme: reactTheming.DEFAULT_THEME
|
|
879
673
|
};
|
|
880
674
|
|
|
881
|
-
const
|
|
675
|
+
const COMPONENT_ID$9 = 'dropdowns.combobox.tags_button';
|
|
676
|
+
const colorStyles = _ref => {
|
|
882
677
|
let {
|
|
678
|
+
theme
|
|
679
|
+
} = _ref;
|
|
680
|
+
const color = reactTheming.getColor({
|
|
681
|
+
theme,
|
|
682
|
+
variable: 'foreground.primary'
|
|
683
|
+
});
|
|
684
|
+
return styled.css(["color:", ";&:disabled{color:inherit;}"], color);
|
|
685
|
+
};
|
|
686
|
+
const StyledTagsButton = styled__default.default(StyledValue).attrs({
|
|
687
|
+
as: 'button',
|
|
688
|
+
'data-garden-id': COMPONENT_ID$9,
|
|
689
|
+
'data-garden-version': '9.0.0-next.20'
|
|
690
|
+
}).withConfig({
|
|
691
|
+
displayName: "StyledTagsButton",
|
|
692
|
+
componentId: "sc-6q5w33-0"
|
|
693
|
+
})(["display:inline-flex;flex:0 1 auto;align-items:center;border:none;background-color:transparent;cursor:pointer;min-width:auto;font-family:inherit;&:hover{text-decoration:underline;}", ";&:disabled{cursor:default;text-decoration:none;}", ";"], colorStyles, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$9, props));
|
|
694
|
+
StyledTagsButton.defaultProps = {
|
|
695
|
+
theme: reactTheming.DEFAULT_THEME
|
|
696
|
+
};
|
|
697
|
+
|
|
698
|
+
const COMPONENT_ID$8 = 'dropdowns.menu';
|
|
699
|
+
const StyledMenu = styled__default.default(StyledListbox).attrs({
|
|
700
|
+
'data-garden-id': COMPONENT_ID$8,
|
|
701
|
+
'data-garden-version': '9.0.0-next.20'
|
|
702
|
+
}).withConfig({
|
|
703
|
+
displayName: "StyledMenu",
|
|
704
|
+
componentId: "sc-f77ntu-0"
|
|
705
|
+
})(["position:static !important;", ";", ";"], props => props.arrowPosition && reactTheming.arrowStyles(props.arrowPosition, {
|
|
706
|
+
size: `${props.theme.space.base * 2}px`,
|
|
707
|
+
inset: '1.5px',
|
|
708
|
+
animationModifier: '[data-garden-animate-arrow="true"]'
|
|
709
|
+
}), props => reactTheming.retrieveComponentStyles(COMPONENT_ID$8, props));
|
|
710
|
+
StyledMenu.defaultProps = {
|
|
711
|
+
theme: reactTheming.DEFAULT_THEME
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
const COMPONENT_ID$7 = 'dropdowns.menu.floating';
|
|
715
|
+
const StyledFloatingMenu = styled__default.default(StyledFloatingListbox).attrs({
|
|
716
|
+
'data-garden-id': COMPONENT_ID$7,
|
|
717
|
+
'data-garden-version': '9.0.0-next.20'
|
|
718
|
+
}).withConfig({
|
|
719
|
+
displayName: "StyledFloatingMenu",
|
|
720
|
+
componentId: "sc-1rc7ahb-0"
|
|
721
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$7, props));
|
|
722
|
+
StyledFloatingMenu.defaultProps = {
|
|
723
|
+
theme: reactTheming.DEFAULT_THEME
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
const COMPONENT_ID$6 = 'dropdowns.menu.item';
|
|
727
|
+
const StyledItem = styled__default.default(StyledOption).attrs({
|
|
728
|
+
'data-garden-id': COMPONENT_ID$6,
|
|
729
|
+
'data-garden-version': '9.0.0-next.20'
|
|
730
|
+
}).withConfig({
|
|
731
|
+
displayName: "StyledItem",
|
|
732
|
+
componentId: "sc-1jp99dq-0"
|
|
733
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$6, props));
|
|
734
|
+
StyledItem.defaultProps = {
|
|
735
|
+
theme: reactTheming.DEFAULT_THEME
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
const COMPONENT_ID$5 = 'dropdowns.menu.item.content';
|
|
739
|
+
const StyledItemContent = styled__default.default(StyledOptionContent).attrs({
|
|
740
|
+
'data-garden-id': COMPONENT_ID$5,
|
|
741
|
+
'data-garden-version': '9.0.0-next.20'
|
|
742
|
+
}).withConfig({
|
|
743
|
+
displayName: "StyledItemContent",
|
|
744
|
+
componentId: "sc-1opglsb-0"
|
|
745
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$5, props));
|
|
746
|
+
StyledItemContent.defaultProps = {
|
|
747
|
+
theme: reactTheming.DEFAULT_THEME
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
const COMPONENT_ID$4 = 'dropdowns.menu.item_group';
|
|
751
|
+
const StyledItemGroup = styled__default.default(StyledOptGroup).attrs({
|
|
752
|
+
'data-garden-id': COMPONENT_ID$4,
|
|
753
|
+
'data-garden-version': '9.0.0-next.20'
|
|
754
|
+
}).withConfig({
|
|
755
|
+
displayName: "StyledItemGroup",
|
|
756
|
+
componentId: "sc-1umk3cg-0"
|
|
757
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$4, props));
|
|
758
|
+
StyledItemGroup.defaultProps = {
|
|
759
|
+
theme: reactTheming.DEFAULT_THEME
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
const COMPONENT_ID$3 = 'dropdowns.menu.item.icon';
|
|
763
|
+
const StyledItemIcon = styled__default.default(StyledOptionIcon).attrs({
|
|
764
|
+
'data-garden-id': COMPONENT_ID$3,
|
|
765
|
+
'data-garden-version': '9.0.0-next.20'
|
|
766
|
+
}).withConfig({
|
|
767
|
+
displayName: "StyledItemIcon",
|
|
768
|
+
componentId: "sc-w9orqb-0"
|
|
769
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$3, props));
|
|
770
|
+
StyledItemIcon.defaultProps = {
|
|
771
|
+
theme: reactTheming.DEFAULT_THEME
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
const COMPONENT_ID$2 = 'dropdowns.menu.item.meta';
|
|
775
|
+
const StyledItemMeta = styled__default.default(StyledOptionMeta).attrs({
|
|
776
|
+
'data-garden-id': COMPONENT_ID$2,
|
|
777
|
+
'data-garden-version': '9.0.0-next.20'
|
|
778
|
+
}).withConfig({
|
|
779
|
+
displayName: "StyledItemMeta",
|
|
780
|
+
componentId: "sc-1unw3x1-0"
|
|
781
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
|
|
782
|
+
StyledItemMeta.defaultProps = {
|
|
783
|
+
theme: reactTheming.DEFAULT_THEME
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
const COMPONENT_ID$1 = 'dropdowns.menu.item.type_icon';
|
|
787
|
+
const StyledItemTypeIcon = styled__default.default(StyledOptionTypeIcon).attrs({
|
|
788
|
+
'data-garden-id': COMPONENT_ID$1,
|
|
789
|
+
'data-garden-version': '9.0.0-next.20'
|
|
790
|
+
}).withConfig({
|
|
791
|
+
displayName: "StyledItemTypeIcon",
|
|
792
|
+
componentId: "sc-1pll3nu-0"
|
|
793
|
+
})(["", "[aria-checked='true'] > &{opacity:1;}", ";"], StyledItem, props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
|
|
794
|
+
StyledItemTypeIcon.defaultProps = {
|
|
795
|
+
theme: reactTheming.DEFAULT_THEME
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
const COMPONENT_ID = 'dropdowns.menu.separator';
|
|
799
|
+
const StyledSeparator = styled__default.default(StyledListboxSeparator).attrs({
|
|
800
|
+
'data-garden-id': COMPONENT_ID,
|
|
801
|
+
'data-garden-version': '9.0.0-next.20'
|
|
802
|
+
}).withConfig({
|
|
803
|
+
displayName: "StyledSeparator",
|
|
804
|
+
componentId: "sc-8kqwen-0"
|
|
805
|
+
})(["", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID, props));
|
|
806
|
+
StyledSeparator.defaultProps = {
|
|
807
|
+
theme: reactTheming.DEFAULT_THEME
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
const Listbox = React.forwardRef((_ref, ref) => {
|
|
811
|
+
let {
|
|
812
|
+
appendToNode,
|
|
883
813
|
children,
|
|
884
|
-
|
|
885
|
-
|
|
814
|
+
isCompact,
|
|
815
|
+
isExpanded,
|
|
816
|
+
maxHeight,
|
|
817
|
+
minHeight,
|
|
818
|
+
onMouseDown,
|
|
819
|
+
triggerRef,
|
|
820
|
+
zIndex,
|
|
886
821
|
...props
|
|
887
822
|
} = _ref;
|
|
823
|
+
const floatingRef = React.useRef(null);
|
|
824
|
+
const [isVisible, setIsVisible] = React.useState(false);
|
|
825
|
+
const [height, setHeight] = React.useState();
|
|
826
|
+
const [width, setWidth] = React.useState();
|
|
827
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
888
828
|
const {
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
isOpen
|
|
895
|
-
},
|
|
896
|
-
setDropdownType
|
|
897
|
-
} = useDropdownContext();
|
|
898
|
-
const {
|
|
899
|
-
isLabelHovered
|
|
900
|
-
} = useFieldContext();
|
|
901
|
-
const inputRef = React.useRef();
|
|
902
|
-
const triggerRef = React.useRef();
|
|
903
|
-
const previousIsOpenRef = React.useRef(isOpen);
|
|
904
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
905
|
-
const [isFocused, setIsFocused] = React.useState(false);
|
|
906
|
-
React.useEffect(() => {
|
|
907
|
-
if (inputRef.current && isOpen !== previousIsOpenRef.current) {
|
|
908
|
-
inputRef.current.focus();
|
|
829
|
+
refs,
|
|
830
|
+
placement,
|
|
831
|
+
update,
|
|
832
|
+
floatingStyles: {
|
|
833
|
+
transform
|
|
909
834
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
onKeyDown,
|
|
915
|
-
...selectProps
|
|
916
|
-
} = getToggleButtonProps(getRootProps({
|
|
917
|
-
role: null,
|
|
918
|
-
...props,
|
|
919
|
-
onKeyDown: e => {
|
|
920
|
-
if (isOpen) {
|
|
921
|
-
e.nativeEvent.preventDownshiftDefault = true;
|
|
922
|
-
}
|
|
835
|
+
} = reactDom.useFloating({
|
|
836
|
+
elements: {
|
|
837
|
+
reference: triggerRef?.current,
|
|
838
|
+
floating: floatingRef?.current
|
|
923
839
|
},
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
} = _ref2;
|
|
937
|
-
return React__namespace.default.createElement(StyledFauxInput, _extends$5({
|
|
938
|
-
isHovered: isContainerHovered,
|
|
939
|
-
isFocused: isContainerFocused,
|
|
940
|
-
tabIndex: null,
|
|
941
|
-
onKeyDown: onSelectKeyDown
|
|
942
|
-
}, selectProps, {
|
|
943
|
-
ref: selectRef => {
|
|
944
|
-
popperReference(selectRef);
|
|
945
|
-
reactMergeRefs.mergeRefs([triggerRef, ref])(selectRef);
|
|
946
|
-
popperReferenceElementRef.current = selectRef;
|
|
947
|
-
}
|
|
948
|
-
}), start && React__namespace.default.createElement(StyledFauxInput.StartIcon, {
|
|
949
|
-
isHovered: isHovered || isLabelHovered && !isOpen,
|
|
950
|
-
isFocused: isContainerFocused,
|
|
951
|
-
isDisabled: props.disabled
|
|
952
|
-
}, start), !isOpen && React__namespace.default.createElement(StyledSelect, null, children), React__namespace.default.createElement(StyledInput, getInputProps({
|
|
953
|
-
isHidden: !isOpen,
|
|
954
|
-
disabled: props.disabled,
|
|
955
|
-
onFocus: () => {
|
|
956
|
-
setIsFocused(true);
|
|
957
|
-
},
|
|
958
|
-
onBlur: () => {
|
|
959
|
-
setIsFocused(false);
|
|
960
|
-
},
|
|
961
|
-
onClick: e => {
|
|
962
|
-
if (isOpen) {
|
|
963
|
-
e.nativeEvent.preventDownshiftDefault = true;
|
|
840
|
+
placement: 'bottom-start',
|
|
841
|
+
middleware: [reactDom.offset(theme.space.base), reactDom.flip(), reactDom.size({
|
|
842
|
+
apply: _ref2 => {
|
|
843
|
+
let {
|
|
844
|
+
rects,
|
|
845
|
+
availableHeight
|
|
846
|
+
} = _ref2;
|
|
847
|
+
if (rects.reference.width > 0) {
|
|
848
|
+
setWidth(rects.reference.width);
|
|
849
|
+
if (!(minHeight === null || minHeight === 'fit-content') && rects.floating.height > availableHeight) {
|
|
850
|
+
setHeight(availableHeight);
|
|
851
|
+
}
|
|
964
852
|
}
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
ref: reactMergeRefs.mergeRefs([inputRef, controlledInputRef || null])
|
|
968
|
-
})), !props.isBare && React__namespace.default.createElement(StyledFauxInput.EndIcon, {
|
|
969
|
-
isHovered: isHovered || isLabelHovered && !isOpen,
|
|
970
|
-
isFocused: isContainerFocused,
|
|
971
|
-
isDisabled: props.disabled,
|
|
972
|
-
isRotated: isOpen
|
|
973
|
-
}, React__namespace.default.createElement(SvgChevronDownStroke, null)));
|
|
853
|
+
}
|
|
854
|
+
})]
|
|
974
855
|
});
|
|
856
|
+
const handleMouseDown = event => event.preventDefault();
|
|
857
|
+
React.useEffect(() => {
|
|
858
|
+
let cleanup;
|
|
859
|
+
if (isExpanded && refs.reference.current && refs.floating.current) {
|
|
860
|
+
cleanup = reactDom.autoUpdate(refs.reference.current, refs.floating.current, update, {
|
|
861
|
+
elementResize: typeof ResizeObserver === 'function'
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
return () => cleanup && cleanup();
|
|
865
|
+
}, [isExpanded, refs.reference, refs.floating, update]);
|
|
866
|
+
React.useEffect(() => {
|
|
867
|
+
let timeout;
|
|
868
|
+
if (isExpanded) {
|
|
869
|
+
setIsVisible(true);
|
|
870
|
+
} else {
|
|
871
|
+
timeout = setTimeout(() => {
|
|
872
|
+
setIsVisible(false);
|
|
873
|
+
setHeight(undefined);
|
|
874
|
+
}, 200 );
|
|
875
|
+
}
|
|
876
|
+
return () => clearTimeout(timeout);
|
|
877
|
+
}, [isExpanded]);
|
|
878
|
+
React.useEffect(() => {
|
|
879
|
+
if (height) {
|
|
880
|
+
setHeight(undefined);
|
|
881
|
+
update();
|
|
882
|
+
}
|
|
883
|
+
}, [
|
|
884
|
+
children, update]);
|
|
885
|
+
const Node = React__namespace.default.createElement(StyledFloatingListbox, {
|
|
886
|
+
"data-garden-animate": isVisible ? 'true' : 'false',
|
|
887
|
+
isHidden: !isExpanded,
|
|
888
|
+
position: placement === 'bottom-start' ? 'bottom' : 'top',
|
|
889
|
+
style: {
|
|
890
|
+
transform,
|
|
891
|
+
width
|
|
892
|
+
},
|
|
893
|
+
zIndex: zIndex,
|
|
894
|
+
ref: floatingRef
|
|
895
|
+
}, React__namespace.default.createElement(StyledListbox, Object.assign({
|
|
896
|
+
isCompact: isCompact,
|
|
897
|
+
maxHeight: maxHeight,
|
|
898
|
+
minHeight: minHeight,
|
|
899
|
+
onMouseDown: containerUtilities.composeEventHandlers(onMouseDown, handleMouseDown),
|
|
900
|
+
style: {
|
|
901
|
+
height
|
|
902
|
+
}
|
|
903
|
+
}, props, {
|
|
904
|
+
ref: ref
|
|
905
|
+
}), isVisible && children));
|
|
906
|
+
return appendToNode ? reactDom$1.createPortal(Node, appendToNode) : Node;
|
|
975
907
|
});
|
|
976
|
-
|
|
977
|
-
|
|
908
|
+
Listbox.displayName = 'Listbox';
|
|
909
|
+
Listbox.propTypes = {
|
|
910
|
+
appendToNode: PropTypes__default.default.any,
|
|
978
911
|
isCompact: PropTypes__default.default.bool,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
912
|
+
isExpanded: PropTypes__default.default.bool,
|
|
913
|
+
maxHeight: PropTypes__default.default.string,
|
|
914
|
+
triggerRef: PropTypes__default.default.any.isRequired,
|
|
915
|
+
zIndex: PropTypes__default.default.number
|
|
983
916
|
};
|
|
984
917
|
|
|
985
|
-
const
|
|
918
|
+
const TagAvatarComponent = reactTags.Tag.Avatar;
|
|
919
|
+
TagAvatarComponent.displayName = 'Tag.Avatar';
|
|
920
|
+
const TagAvatar = TagAvatarComponent;
|
|
921
|
+
|
|
922
|
+
const TagComponent = React.forwardRef((_ref, ref) => {
|
|
986
923
|
let {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
placeholder,
|
|
992
|
-
validation,
|
|
993
|
-
inputRef: inputRefProp = null,
|
|
994
|
-
start,
|
|
995
|
-
end,
|
|
924
|
+
children,
|
|
925
|
+
option,
|
|
926
|
+
removeLabel,
|
|
927
|
+
tooltipZIndex,
|
|
996
928
|
...props
|
|
997
929
|
} = _ref;
|
|
998
930
|
const {
|
|
999
|
-
|
|
1000
|
-
downshift: {
|
|
1001
|
-
getToggleButtonProps,
|
|
1002
|
-
getInputProps,
|
|
1003
|
-
getRootProps,
|
|
1004
|
-
isOpen
|
|
1005
|
-
},
|
|
1006
|
-
setDropdownType
|
|
1007
|
-
} = useDropdownContext();
|
|
1008
|
-
const wrapperRef = React.useRef();
|
|
1009
|
-
const inputRef = React.useRef();
|
|
1010
|
-
const isOpenRef = React.useRef(isOpen);
|
|
1011
|
-
const wrapperProps = getToggleButtonProps(getRootProps({
|
|
1012
|
-
role: null,
|
|
1013
|
-
type: null,
|
|
1014
|
-
onClick: event => {
|
|
1015
|
-
event.nativeEvent.preventDownshiftDefault = true;
|
|
1016
|
-
},
|
|
1017
|
-
...props,
|
|
1018
|
-
onKeyDown: event => {
|
|
1019
|
-
event.nativeEvent.preventDownshiftDefault = true;
|
|
1020
|
-
}
|
|
1021
|
-
}));
|
|
1022
|
-
const inputProps = getInputProps({
|
|
931
|
+
getTagProps,
|
|
1023
932
|
isCompact,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
onKeyDown: event => {
|
|
1033
|
-
if (event.keyCode === containerUtilities.KEY_CODES.SPACE || !isOpen && [containerUtilities.KEY_CODES.DOWN, containerUtilities.KEY_CODES.UP].includes(event.keyCode)) {
|
|
1034
|
-
event.nativeEvent.preventDownshiftDefault = true;
|
|
1035
|
-
}
|
|
1036
|
-
},
|
|
1037
|
-
onClick: event => {
|
|
1038
|
-
event.nativeEvent.preventDownshiftDefault = true;
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
React.useEffect(() => {
|
|
1042
|
-
if (inputRef.current && isOpen !== isOpenRef.current) {
|
|
1043
|
-
inputRef.current.focus();
|
|
1044
|
-
}
|
|
1045
|
-
isOpenRef.current = isOpen;
|
|
1046
|
-
}, [inputRef, isOpen]);
|
|
1047
|
-
React.useEffect(() => {
|
|
1048
|
-
setDropdownType('combobox');
|
|
1049
|
-
}, [setDropdownType]);
|
|
1050
|
-
return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
|
|
1051
|
-
let {
|
|
1052
|
-
ref: popperReference
|
|
1053
|
-
} = _ref2;
|
|
1054
|
-
const wrapperRefProp = element => {
|
|
1055
|
-
popperReference(element);
|
|
1056
|
-
reactMergeRefs.mergeRefs([wrapperRef, ref])(element);
|
|
1057
|
-
popperReferenceElementRef.current = element;
|
|
1058
|
-
};
|
|
1059
|
-
return React__namespace.default.createElement(reactForms.MediaInput, _extends$5({}, inputProps, {
|
|
1060
|
-
wrapperProps: wrapperProps,
|
|
1061
|
-
wrapperRef: wrapperRefProp,
|
|
1062
|
-
ref: reactMergeRefs.mergeRefs([inputRef, inputRefProp])
|
|
1063
|
-
}));
|
|
933
|
+
removeSelection
|
|
934
|
+
} = useComboboxContext();
|
|
935
|
+
const text = option.label || option.value;
|
|
936
|
+
const ariaLabel = reactTheming.useText(
|
|
937
|
+
Tag, props, 'aria-label', `${text}, press delete or backspace to remove`, !option.disabled);
|
|
938
|
+
const tagProps = getTagProps({
|
|
939
|
+
option,
|
|
940
|
+
'aria-label': ariaLabel
|
|
1064
941
|
});
|
|
942
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
943
|
+
const doc = reactTheming.useDocument(theme);
|
|
944
|
+
const handleClick = () => removeSelection(option.value);
|
|
945
|
+
return React__namespace.default.createElement(StyledTag, Object.assign({
|
|
946
|
+
"aria-disabled": option.disabled,
|
|
947
|
+
tabIndex: option.disabled ? undefined : 0
|
|
948
|
+
}, tagProps, props, {
|
|
949
|
+
size: isCompact ? 'medium' : 'large',
|
|
950
|
+
ref: ref
|
|
951
|
+
}), children || React__namespace.default.createElement("span", null, text), !option.disabled && (removeLabel ?
|
|
952
|
+
React__namespace.default.createElement(reactTooltips.Tooltip, {
|
|
953
|
+
appendToNode: doc?.body,
|
|
954
|
+
content: removeLabel,
|
|
955
|
+
zIndex: tooltipZIndex
|
|
956
|
+
}, React__namespace.default.createElement(StyledTag.Close, {
|
|
957
|
+
"aria-label": removeLabel,
|
|
958
|
+
onClick: handleClick
|
|
959
|
+
})) : React__namespace.default.createElement(StyledTag.Close, {
|
|
960
|
+
onClick: handleClick
|
|
961
|
+
})));
|
|
1065
962
|
});
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
placeholder: PropTypes__default.default.string,
|
|
1073
|
-
validation: PropTypes__default.default.oneOf(reactForms.VALIDATION)
|
|
963
|
+
TagComponent.displayName = 'Tag';
|
|
964
|
+
TagComponent.propTypes = {
|
|
965
|
+
hue: PropTypes__default.default.string,
|
|
966
|
+
isPill: PropTypes__default.default.bool,
|
|
967
|
+
isRegular: PropTypes__default.default.bool,
|
|
968
|
+
removeLabel: PropTypes__default.default.string
|
|
1074
969
|
};
|
|
970
|
+
const Tag = TagComponent;
|
|
971
|
+
Tag.Avatar = TagAvatar;
|
|
1075
972
|
|
|
1076
|
-
const
|
|
973
|
+
const TagGroup = _ref => {
|
|
1077
974
|
let {
|
|
1078
|
-
|
|
975
|
+
children,
|
|
976
|
+
isDisabled,
|
|
977
|
+
isExpanded,
|
|
978
|
+
listboxZIndex,
|
|
979
|
+
maxTags,
|
|
980
|
+
optionTagProps,
|
|
981
|
+
selection
|
|
982
|
+
} = _ref;
|
|
983
|
+
return React__namespace.default.createElement(React__namespace.default.Fragment, null, selection.map((option, index) => {
|
|
984
|
+
const disabled = isDisabled || option.disabled;
|
|
985
|
+
return React__namespace.default.createElement(Tag, Object.assign({
|
|
986
|
+
key: option.value,
|
|
987
|
+
hidden: !isExpanded && index >= maxTags,
|
|
988
|
+
option: {
|
|
989
|
+
...option,
|
|
990
|
+
disabled
|
|
991
|
+
},
|
|
992
|
+
tooltipZIndex: listboxZIndex ? listboxZIndex + 1 : undefined
|
|
993
|
+
}, optionTagProps[option.value]));
|
|
994
|
+
}), children);
|
|
995
|
+
};
|
|
996
|
+
TagGroup.displayName = 'TagGroup';
|
|
997
|
+
|
|
998
|
+
const toOption = props => {
|
|
999
|
+
return {
|
|
1000
|
+
value: props.value,
|
|
1001
|
+
label: props.label,
|
|
1002
|
+
hidden: props.isHidden,
|
|
1003
|
+
disabled: props.isDisabled,
|
|
1004
|
+
selected: props.isSelected
|
|
1005
|
+
};
|
|
1006
|
+
};
|
|
1007
|
+
const toOptions = (children, optionTagProps) => React.Children.toArray(children).reduce((options, option) => {
|
|
1008
|
+
const retVal = options;
|
|
1009
|
+
if ( React.isValidElement(option)) {
|
|
1010
|
+
if ('value' in option.props) {
|
|
1011
|
+
retVal.push(toOption(option.props));
|
|
1012
|
+
optionTagProps[option.props.value] = option.props.tagProps;
|
|
1013
|
+
} else {
|
|
1014
|
+
const props = option.props;
|
|
1015
|
+
const groupOptions = toOptions(props.children, optionTagProps);
|
|
1016
|
+
retVal.push({
|
|
1017
|
+
label: props.legend,
|
|
1018
|
+
options: groupOptions
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return retVal;
|
|
1023
|
+
}, []);
|
|
1024
|
+
|
|
1025
|
+
const MAX_TAGS = 4;
|
|
1026
|
+
const Combobox = React.forwardRef((_ref, ref) => {
|
|
1027
|
+
let {
|
|
1028
|
+
children,
|
|
1029
|
+
activeIndex,
|
|
1030
|
+
defaultActiveIndex,
|
|
1031
|
+
defaultExpanded,
|
|
1032
|
+
endIcon,
|
|
1033
|
+
focusInset,
|
|
1034
|
+
inputProps: _inputProps,
|
|
1035
|
+
inputValue: _inputValue,
|
|
1036
|
+
isAutocomplete,
|
|
1037
|
+
isBare,
|
|
1038
|
+
isCompact,
|
|
1039
|
+
isDisabled,
|
|
1040
|
+
isEditable,
|
|
1041
|
+
isExpanded: _isExpanded,
|
|
1042
|
+
isMultiselectable,
|
|
1043
|
+
listboxAppendToNode,
|
|
1044
|
+
listboxAriaLabel,
|
|
1045
|
+
listboxMaxHeight,
|
|
1046
|
+
listboxMinHeight,
|
|
1047
|
+
listboxZIndex,
|
|
1048
|
+
maxHeight,
|
|
1049
|
+
maxTags = MAX_TAGS,
|
|
1050
|
+
onChange,
|
|
1079
1051
|
placeholder,
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1052
|
+
renderExpandTags,
|
|
1053
|
+
renderValue,
|
|
1054
|
+
selectionValue,
|
|
1055
|
+
startIcon,
|
|
1056
|
+
validation,
|
|
1085
1057
|
...props
|
|
1086
1058
|
} = _ref;
|
|
1087
1059
|
const {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
isOpen,
|
|
1097
|
-
closeMenu,
|
|
1098
|
-
inputValue,
|
|
1099
|
-
setState: setDownshiftState,
|
|
1100
|
-
itemToString
|
|
1101
|
-
},
|
|
1102
|
-
setDropdownType
|
|
1103
|
-
} = useDropdownContext();
|
|
1104
|
-
const {
|
|
1105
|
-
isLabelHovered
|
|
1060
|
+
hasHint,
|
|
1061
|
+
hasMessage,
|
|
1062
|
+
labelProps,
|
|
1063
|
+
setLabelProps,
|
|
1064
|
+
hintProps,
|
|
1065
|
+
setHintProps,
|
|
1066
|
+
messageProps,
|
|
1067
|
+
setMessageProps
|
|
1106
1068
|
} = useFieldContext();
|
|
1107
|
-
const
|
|
1108
|
-
const
|
|
1109
|
-
const
|
|
1110
|
-
const
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
getItemProps
|
|
1120
|
-
} = containerSelection.useSelection({
|
|
1121
|
-
rtl: themeContext.rtl,
|
|
1122
|
-
focusedItem,
|
|
1123
|
-
selectedItem: undefined,
|
|
1124
|
-
onFocus: item => {
|
|
1125
|
-
setFocusedItem(item);
|
|
1126
|
-
}
|
|
1127
|
-
});
|
|
1128
|
-
React.useEffect(() => {
|
|
1129
|
-
containsMultiselectRef.current = true;
|
|
1130
|
-
const tempRef = blurTimeoutRef;
|
|
1131
|
-
return () => {
|
|
1132
|
-
clearTimeout(tempRef.current);
|
|
1133
|
-
};
|
|
1134
|
-
}, []);
|
|
1135
|
-
React.useEffect(() => {
|
|
1136
|
-
if (inputRef.current) {
|
|
1137
|
-
if (isOpen && !previousIsOpenRef.current) {
|
|
1138
|
-
inputRef.current.focus();
|
|
1139
|
-
} else if (isFocused && !previousIsFocusedRef.current && focusedItem === undefined) {
|
|
1140
|
-
inputRef.current.focus();
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
previousIsOpenRef.current = isOpen;
|
|
1144
|
-
previousIsFocusedRef.current = isFocused;
|
|
1145
|
-
}, [isOpen, inputRef, isFocused, focusedItem]);
|
|
1146
|
-
React.useEffect(() => {
|
|
1147
|
-
if (focusedItem !== undefined && isOpen) {
|
|
1148
|
-
closeMenu();
|
|
1069
|
+
const [isInputHidden, setIsInputHidden] = React.useState(true);
|
|
1070
|
+
const [isLabelHovered, setIsLabelHovered] = React.useState(false);
|
|
1071
|
+
const [isTagGroupExpanded, setIsTagGroupExpanded] = React.useState(false);
|
|
1072
|
+
const [optionTagProps, setOptionTagProps] = React.useState({});
|
|
1073
|
+
const options = React.useMemo(() => {
|
|
1074
|
+
const tagProps = {};
|
|
1075
|
+
const retVal = toOptions(children, tagProps);
|
|
1076
|
+
if (isMultiselectable) {
|
|
1077
|
+
setOptionTagProps(value => ({
|
|
1078
|
+
...value,
|
|
1079
|
+
...tagProps
|
|
1080
|
+
}));
|
|
1149
1081
|
}
|
|
1150
|
-
|
|
1082
|
+
return retVal;
|
|
1083
|
+
}, [children, isMultiselectable]);
|
|
1084
|
+
const triggerRef = React.useRef(null);
|
|
1085
|
+
const inputRef = React.useRef(null);
|
|
1086
|
+
const listboxRef = React.useRef(null);
|
|
1087
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
1088
|
+
const environment = reactTheming.useWindow(theme);
|
|
1151
1089
|
const {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1090
|
+
activeValue,
|
|
1091
|
+
inputValue,
|
|
1092
|
+
isExpanded,
|
|
1093
|
+
getTriggerProps,
|
|
1094
|
+
getHintProps,
|
|
1095
|
+
getInputProps,
|
|
1096
|
+
getLabelProps,
|
|
1097
|
+
getListboxProps,
|
|
1098
|
+
getMessageProps,
|
|
1099
|
+
getOptionProps,
|
|
1100
|
+
getOptGroupProps,
|
|
1101
|
+
getTagProps,
|
|
1102
|
+
removeSelection,
|
|
1103
|
+
selection
|
|
1104
|
+
} = containerCombobox.useCombobox({
|
|
1105
|
+
idPrefix: props.id,
|
|
1106
|
+
triggerRef,
|
|
1107
|
+
inputRef,
|
|
1108
|
+
listboxRef,
|
|
1109
|
+
options,
|
|
1110
|
+
environment,
|
|
1111
|
+
hasHint,
|
|
1112
|
+
hasMessage,
|
|
1113
|
+
isAutocomplete,
|
|
1114
|
+
isEditable,
|
|
1115
|
+
isMultiselectable,
|
|
1116
|
+
disabled: isDisabled,
|
|
1117
|
+
inputValue: _inputValue,
|
|
1118
|
+
selectionValue,
|
|
1119
|
+
isExpanded: _isExpanded,
|
|
1120
|
+
defaultExpanded,
|
|
1121
|
+
activeIndex,
|
|
1122
|
+
defaultActiveIndex,
|
|
1123
|
+
onChange
|
|
1124
|
+
});
|
|
1125
|
+
const contextValue = React.useMemo(() => ({
|
|
1126
|
+
activeValue,
|
|
1127
|
+
getOptionProps,
|
|
1128
|
+
getOptGroupProps,
|
|
1129
|
+
getTagProps,
|
|
1130
|
+
isCompact,
|
|
1131
|
+
removeSelection
|
|
1132
|
+
}), [activeValue, getOptionProps, getOptGroupProps, getTagProps, isCompact, removeSelection]);
|
|
1133
|
+
const hasChevron = React.useMemo(() => !isBare && (isAutocomplete || !isEditable), [isAutocomplete, isBare, isEditable]);
|
|
1134
|
+
const expandTags = reactTheming.useText(Combobox, {
|
|
1135
|
+
renderExpandTags
|
|
1136
|
+
}, 'renderExpandTags', '+ {{value}} more', isMultiselectable || false);
|
|
1137
|
+
const _listboxAriaLabel = reactTheming.useText(Combobox, {
|
|
1138
|
+
listboxAriaLabel
|
|
1139
|
+
}, 'listboxAriaLabel', 'Options');
|
|
1140
|
+
const triggerProps = {
|
|
1141
|
+
isAutocomplete,
|
|
1142
|
+
isBare,
|
|
1143
|
+
isCompact,
|
|
1144
|
+
isEditable,
|
|
1145
|
+
isLabelHovered,
|
|
1146
|
+
isMultiselectable,
|
|
1147
|
+
maxHeight,
|
|
1148
|
+
focusInset,
|
|
1149
|
+
validation,
|
|
1150
|
+
...getTriggerProps({
|
|
1151
|
+
onFocus: () => {
|
|
1152
|
+
if (!isDisabled) {
|
|
1153
|
+
if (isEditable) {
|
|
1154
|
+
setIsInputHidden(false);
|
|
1205
1155
|
}
|
|
1206
|
-
if (
|
|
1207
|
-
|
|
1208
|
-
e.preventDefault();
|
|
1209
|
-
}
|
|
1210
|
-
if (e.keyCode === containerUtilities.KEY_CODES.LEFT && index === selectedItems.length - 1) {
|
|
1211
|
-
e.preventDefault();
|
|
1212
|
-
inputRef.current && inputRef.current.focus();
|
|
1213
|
-
}
|
|
1214
|
-
} else {
|
|
1215
|
-
if (e.keyCode === containerUtilities.KEY_CODES.LEFT && index === 0) {
|
|
1216
|
-
e.preventDefault();
|
|
1217
|
-
}
|
|
1218
|
-
if (e.keyCode === containerUtilities.KEY_CODES.RIGHT && index === selectedItems.length - 1) {
|
|
1219
|
-
e.preventDefault();
|
|
1220
|
-
inputRef.current && inputRef.current.focus();
|
|
1221
|
-
}
|
|
1156
|
+
if (isMultiselectable) {
|
|
1157
|
+
setIsTagGroupExpanded(true);
|
|
1222
1158
|
}
|
|
1223
|
-
},
|
|
1224
|
-
onClick: e => {
|
|
1225
|
-
e.nativeEvent.preventDownshiftDefault = true;
|
|
1226
|
-
},
|
|
1227
|
-
tabIndex: -1
|
|
1228
|
-
}),
|
|
1229
|
-
size: props.isCompact ? 'medium' : 'large'
|
|
1230
|
-
});
|
|
1231
|
-
const key = `${itemToString(item)}-${index}`;
|
|
1232
|
-
return React__namespace.default.createElement(StyledMultiselectItemWrapper, {
|
|
1233
|
-
key: key
|
|
1234
|
-
}, clonedChild);
|
|
1235
|
-
}, [getItemProps, inputValue, renderItem, setDownshiftState, itemToString, selectedItems, props, inputRef, themeContext.rtl]);
|
|
1236
|
-
const items = React.useMemo(() => {
|
|
1237
|
-
const itemValues = selectedItems || [];
|
|
1238
|
-
const output = [];
|
|
1239
|
-
for (let x = 0; x < itemValues.length; x++) {
|
|
1240
|
-
const item = itemValues[x];
|
|
1241
|
-
if (x < maxItems) {
|
|
1242
|
-
if (props.disabled) {
|
|
1243
|
-
const renderedItem = React__namespace.default.cloneElement(renderItem({
|
|
1244
|
-
value: item,
|
|
1245
|
-
removeValue: () => {
|
|
1246
|
-
return undefined;
|
|
1247
|
-
}
|
|
1248
|
-
}), {
|
|
1249
|
-
size: props.isCompact ? 'medium' : 'large'
|
|
1250
|
-
});
|
|
1251
|
-
output.push( React__namespace.default.createElement(StyledMultiselectItemWrapper, {
|
|
1252
|
-
key: x
|
|
1253
|
-
}, renderedItem));
|
|
1254
|
-
} else {
|
|
1255
|
-
output.push(renderSelectableItem(item, x));
|
|
1256
|
-
}
|
|
1257
|
-
} else if (!isFocused && !inputValue || props.disabled) {
|
|
1258
|
-
output.push( React__namespace.default.createElement(StyledMultiselectItemWrapper, {
|
|
1259
|
-
key: "more-anchor"
|
|
1260
|
-
}, React__namespace.default.createElement(StyledMultiselectMoreAnchor, {
|
|
1261
|
-
isCompact: props.isCompact,
|
|
1262
|
-
isDisabled: props.disabled
|
|
1263
|
-
}, renderShowMore ? renderShowMore(itemValues.length - x) : `+ ${itemValues.length - x} more`)));
|
|
1264
|
-
break;
|
|
1265
|
-
} else {
|
|
1266
|
-
output.push(renderSelectableItem(item, x));
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
return output;
|
|
1270
|
-
}, [isFocused, props.disabled, renderSelectableItem, selectedItems, renderItem, inputValue, maxItems, renderShowMore, props.isCompact]);
|
|
1271
|
-
const isContainerHovered = isLabelHovered && !isOpen;
|
|
1272
|
-
const isContainerFocused = isOpen || isFocused;
|
|
1273
|
-
React.useEffect(() => {
|
|
1274
|
-
setDropdownType('multiselect');
|
|
1275
|
-
}, [setDropdownType]);
|
|
1276
|
-
return React__namespace.default.createElement(reactPopper.Reference, null, _ref2 => {
|
|
1277
|
-
let {
|
|
1278
|
-
ref: popperReference
|
|
1279
|
-
} = _ref2;
|
|
1280
|
-
return React__namespace.default.createElement(StyledFauxInput, getContainerProps({
|
|
1281
|
-
...selectProps,
|
|
1282
|
-
isHovered: isContainerHovered,
|
|
1283
|
-
isFocused: isContainerFocused,
|
|
1284
|
-
ref: selectRef => {
|
|
1285
|
-
popperReference(selectRef);
|
|
1286
|
-
reactMergeRefs.mergeRefs([triggerRef, popperReferenceElementRef, ref])(selectRef);
|
|
1287
|
-
}
|
|
1288
|
-
}), start && React__namespace.default.createElement(StyledFauxInput.StartIcon, {
|
|
1289
|
-
isHovered: isHovered || isLabelHovered && !isOpen,
|
|
1290
|
-
isFocused: isContainerFocused,
|
|
1291
|
-
isDisabled: props.disabled
|
|
1292
|
-
}, start), React__namespace.default.createElement(StyledMultiselectItemsContainer, {
|
|
1293
|
-
isBare: props.isBare,
|
|
1294
|
-
isCompact: props.isCompact
|
|
1295
|
-
}, items, React__namespace.default.createElement(StyledMultiselectInput, getInputProps({
|
|
1296
|
-
disabled: props.disabled,
|
|
1297
|
-
onFocus: () => {
|
|
1298
|
-
setFocusedItem(undefined);
|
|
1299
|
-
},
|
|
1300
|
-
onClick: e => {
|
|
1301
|
-
if (inputValue && inputValue.length > 0 && isOpen) {
|
|
1302
|
-
e.nativeEvent.preventDownshiftDefault = true;
|
|
1303
1159
|
}
|
|
1304
1160
|
},
|
|
1305
|
-
|
|
1306
|
-
if (!
|
|
1307
|
-
if (
|
|
1308
|
-
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
setDownshiftState({
|
|
1313
|
-
type: REMOVE_ITEM_STATE_TYPE,
|
|
1314
|
-
selectedItem: selectedItems[selectedItems.length - 1]
|
|
1315
|
-
});
|
|
1316
|
-
e.nativeEvent.preventDownshiftDefault = true;
|
|
1317
|
-
e.preventDefault();
|
|
1318
|
-
e.stopPropagation();
|
|
1161
|
+
onBlur: event => {
|
|
1162
|
+
if (event.relatedTarget === null || !triggerRef.current?.contains(event.relatedTarget)) {
|
|
1163
|
+
if (isEditable) {
|
|
1164
|
+
setIsInputHidden(true);
|
|
1165
|
+
}
|
|
1166
|
+
if (isMultiselectable) {
|
|
1167
|
+
setIsTagGroupExpanded(false);
|
|
1319
1168
|
}
|
|
1320
1169
|
}
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1170
|
+
}
|
|
1171
|
+
})
|
|
1172
|
+
};
|
|
1173
|
+
const inputProps = {
|
|
1174
|
+
'aria-invalid': validation === 'error' || validation === 'warning',
|
|
1175
|
+
hidden: isInputHidden,
|
|
1176
|
+
isBare,
|
|
1177
|
+
isCompact,
|
|
1178
|
+
isEditable,
|
|
1179
|
+
isMultiselectable,
|
|
1180
|
+
placeholder,
|
|
1181
|
+
...getInputProps({
|
|
1182
|
+
..._inputProps
|
|
1183
|
+
})
|
|
1184
|
+
};
|
|
1185
|
+
const listboxProps = getListboxProps({
|
|
1186
|
+
'aria-label': _listboxAriaLabel
|
|
1333
1187
|
});
|
|
1334
|
-
});
|
|
1335
|
-
Multiselect.propTypes = {
|
|
1336
|
-
isCompact: PropTypes__default.default.bool,
|
|
1337
|
-
isBare: PropTypes__default.default.bool,
|
|
1338
|
-
disabled: PropTypes__default.default.bool,
|
|
1339
|
-
focusInset: PropTypes__default.default.bool,
|
|
1340
|
-
renderItem: PropTypes__default.default.func.isRequired,
|
|
1341
|
-
maxItems: PropTypes__default.default.number,
|
|
1342
|
-
validation: PropTypes__default.default.oneOf(['success', 'warning', 'error'])
|
|
1343
|
-
};
|
|
1344
|
-
Multiselect.defaultProps = {
|
|
1345
|
-
maxItems: 4
|
|
1346
|
-
};
|
|
1347
|
-
Multiselect.displayName = 'Multiselect';
|
|
1348
|
-
|
|
1349
|
-
const Select = React__namespace.default.forwardRef((_ref, ref) => {
|
|
1350
|
-
let {
|
|
1351
|
-
children,
|
|
1352
|
-
start,
|
|
1353
|
-
...props
|
|
1354
|
-
} = _ref;
|
|
1355
|
-
const {
|
|
1356
|
-
popperReferenceElementRef,
|
|
1357
|
-
itemSearchRegistry,
|
|
1358
|
-
downshift: {
|
|
1359
|
-
getToggleButtonProps,
|
|
1360
|
-
getInputProps,
|
|
1361
|
-
isOpen,
|
|
1362
|
-
highlightedIndex,
|
|
1363
|
-
setHighlightedIndex,
|
|
1364
|
-
selectItemAtIndex,
|
|
1365
|
-
closeMenu
|
|
1366
|
-
}
|
|
1367
|
-
} = useDropdownContext();
|
|
1368
|
-
const {
|
|
1369
|
-
isLabelHovered
|
|
1370
|
-
} = useFieldContext();
|
|
1371
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
1372
|
-
const [isFocused, setIsFocused] = React.useState(false);
|
|
1373
|
-
const hiddenInputRef = React.useRef();
|
|
1374
|
-
const triggerRef = React.useRef();
|
|
1375
|
-
const previousIsOpenRef = React.useRef(undefined);
|
|
1376
|
-
const [searchString, setSearchString] = React.useState('');
|
|
1377
|
-
const searchTimeoutRef = React.useRef();
|
|
1378
|
-
const currentSearchIndexRef = React.useRef(0);
|
|
1379
1188
|
React.useEffect(() => {
|
|
1380
|
-
if (
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1189
|
+
if (!labelProps) {
|
|
1190
|
+
const _labelProps = getLabelProps({
|
|
1191
|
+
onMouseEnter: () => setIsLabelHovered(true),
|
|
1192
|
+
onMouseLeave: () => setIsLabelHovered(false)
|
|
1193
|
+
});
|
|
1194
|
+
setLabelProps(_labelProps);
|
|
1385
1195
|
}
|
|
1386
|
-
|
|
1387
|
-
}, [
|
|
1196
|
+
return () => labelProps && setLabelProps(undefined);
|
|
1197
|
+
}, [getLabelProps, labelProps, setLabelProps]);
|
|
1388
1198
|
React.useEffect(() => {
|
|
1389
|
-
if (
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
searchTimeoutRef.current = window.setTimeout(() => {
|
|
1393
|
-
setSearchString('');
|
|
1394
|
-
}, 500);
|
|
1395
|
-
return () => {
|
|
1396
|
-
clearTimeout(searchTimeoutRef.current);
|
|
1397
|
-
};
|
|
1398
|
-
}, [searchString]);
|
|
1399
|
-
const searchItems = React.useCallback((searchValue, startIndex, endIndex) => {
|
|
1400
|
-
for (let index = startIndex; index < endIndex; index++) {
|
|
1401
|
-
const itemTextValue = itemSearchRegistry.current[index];
|
|
1402
|
-
if (itemTextValue && itemTextValue.toUpperCase().indexOf(searchValue.toUpperCase()) === 0) {
|
|
1403
|
-
return index;
|
|
1404
|
-
}
|
|
1199
|
+
if (!hintProps) {
|
|
1200
|
+
const _hintProps = getHintProps();
|
|
1201
|
+
setHintProps(_hintProps);
|
|
1405
1202
|
}
|
|
1406
|
-
return undefined;
|
|
1407
|
-
}, [
|
|
1408
|
-
|
|
1409
|
-
if (
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
e.stopPropagation();
|
|
1413
|
-
} else if (highlightedIndex !== null && highlightedIndex !== undefined) {
|
|
1414
|
-
e.preventDefault();
|
|
1415
|
-
e.stopPropagation();
|
|
1416
|
-
selectItemAtIndex(highlightedIndex);
|
|
1417
|
-
closeMenu();
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
if ((e.keyCode < 48 || e.keyCode > 57) && (e.keyCode < 65 || e.keyCode > 90) && e.keyCode !== containerUtilities.KEY_CODES.SPACE) {
|
|
1421
|
-
return;
|
|
1422
|
-
}
|
|
1423
|
-
const character = String.fromCharCode(e.which || e.keyCode);
|
|
1424
|
-
if (!character || character.length === 0) {
|
|
1425
|
-
return;
|
|
1426
|
-
}
|
|
1427
|
-
if (!searchString) {
|
|
1428
|
-
if (highlightedIndex === null || highlightedIndex === undefined) {
|
|
1429
|
-
currentSearchIndexRef.current = -1;
|
|
1430
|
-
} else {
|
|
1431
|
-
currentSearchIndexRef.current = highlightedIndex;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
const newSearchString = searchString + character;
|
|
1435
|
-
setSearchString(newSearchString);
|
|
1436
|
-
let matchingIndex = searchItems(newSearchString, currentSearchIndexRef.current + 1, itemSearchRegistry.current.length);
|
|
1437
|
-
if (matchingIndex === undefined) {
|
|
1438
|
-
matchingIndex = searchItems(newSearchString, 0, currentSearchIndexRef.current);
|
|
1439
|
-
}
|
|
1440
|
-
if (matchingIndex !== undefined) {
|
|
1441
|
-
setHighlightedIndex(matchingIndex);
|
|
1203
|
+
return () => hintProps && setHintProps(undefined);
|
|
1204
|
+
}, [getHintProps, hintProps, setHintProps]);
|
|
1205
|
+
React.useEffect(() => {
|
|
1206
|
+
if (!messageProps) {
|
|
1207
|
+
const _messageProps = getMessageProps();
|
|
1208
|
+
setMessageProps(_messageProps);
|
|
1442
1209
|
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1210
|
+
return () => messageProps && setMessageProps(undefined);
|
|
1211
|
+
}, [getMessageProps, messageProps, setMessageProps]);
|
|
1212
|
+
return React__namespace.default.createElement(ComboboxContext.Provider, {
|
|
1213
|
+
value: contextValue
|
|
1214
|
+
}, React__namespace.default.createElement(StyledCombobox, Object.assign({
|
|
1215
|
+
isCompact: isCompact,
|
|
1216
|
+
tabIndex: -1
|
|
1217
|
+
}, props, {
|
|
1218
|
+
ref: ref
|
|
1219
|
+
}), React__namespace.default.createElement(StyledTrigger, triggerProps, React__namespace.default.createElement(StyledContainer, null, startIcon && React__namespace.default.createElement(StyledInputIcon, {
|
|
1220
|
+
$isLabelHovered: isLabelHovered,
|
|
1221
|
+
$isCompact: isCompact
|
|
1222
|
+
}, startIcon), React__namespace.default.createElement(StyledInputGroup, null, isMultiselectable && Array.isArray(selection) && React__namespace.default.createElement(TagGroup, {
|
|
1223
|
+
isDisabled: isDisabled,
|
|
1224
|
+
isExpanded: isTagGroupExpanded,
|
|
1225
|
+
maxTags: maxTags,
|
|
1226
|
+
optionTagProps: optionTagProps,
|
|
1227
|
+
selection: selection
|
|
1228
|
+
}, selection.length > maxTags && React__namespace.default.createElement(StyledTagsButton, {
|
|
1229
|
+
disabled: isDisabled,
|
|
1230
|
+
hidden: isTagGroupExpanded,
|
|
1231
|
+
isCompact: isCompact,
|
|
1232
|
+
tabIndex: -1,
|
|
1233
|
+
type: "button"
|
|
1234
|
+
}, (() => {
|
|
1235
|
+
const value = selection.length - maxTags;
|
|
1236
|
+
return renderExpandTags ? renderExpandTags(value) : expandTags?.replace('{{value}}', value.toString());
|
|
1237
|
+
})())), React__namespace.default.createElement(StyledValue, {
|
|
1238
|
+
hidden: !isInputHidden,
|
|
1239
|
+
isAutocomplete: isAutocomplete,
|
|
1240
|
+
isBare: isBare,
|
|
1241
|
+
isCompact: isCompact,
|
|
1242
|
+
isDisabled: isDisabled,
|
|
1243
|
+
isEditable: isEditable,
|
|
1244
|
+
isMultiselectable: isMultiselectable,
|
|
1245
|
+
isPlaceholder: !(inputValue || renderValue)
|
|
1246
|
+
}, renderValue ? renderValue({
|
|
1247
|
+
selection,
|
|
1248
|
+
inputValue
|
|
1249
|
+
}) : inputValue || placeholder), React__namespace.default.createElement(StyledInput, inputProps)), (hasChevron || endIcon) && React__namespace.default.createElement(StyledInputIcon, {
|
|
1250
|
+
$isCompact: isCompact,
|
|
1251
|
+
$isEnd: true,
|
|
1252
|
+
$isLabelHovered: isLabelHovered,
|
|
1253
|
+
$isRotated: hasChevron && isExpanded
|
|
1254
|
+
}, hasChevron ? React__namespace.default.createElement(SvgChevronDownStroke, null) : endIcon))), React__namespace.default.createElement(Listbox, Object.assign({
|
|
1255
|
+
appendToNode: listboxAppendToNode,
|
|
1256
|
+
isCompact: isCompact,
|
|
1257
|
+
isExpanded: isExpanded,
|
|
1258
|
+
maxHeight: listboxMaxHeight,
|
|
1259
|
+
minHeight: listboxMinHeight,
|
|
1260
|
+
triggerRef: triggerRef,
|
|
1261
|
+
zIndex: listboxZIndex
|
|
1262
|
+
}, listboxProps), children)));
|
|
1493
1263
|
});
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1264
|
+
Combobox.displayName = 'Combobox';
|
|
1265
|
+
Combobox.propTypes = {
|
|
1266
|
+
activeIndex: PropTypes__default.default.number,
|
|
1267
|
+
defaultActiveIndex: PropTypes__default.default.number,
|
|
1268
|
+
defaultExpanded: PropTypes__default.default.bool,
|
|
1269
|
+
endIcon: PropTypes__default.default.any,
|
|
1499
1270
|
focusInset: PropTypes__default.default.bool,
|
|
1500
|
-
|
|
1501
|
-
|
|
1271
|
+
id: PropTypes__default.default.string,
|
|
1272
|
+
inputProps: PropTypes__default.default.object,
|
|
1273
|
+
inputValue: PropTypes__default.default.string,
|
|
1274
|
+
isAutocomplete: PropTypes__default.default.bool,
|
|
1275
|
+
isBare: PropTypes__default.default.bool,
|
|
1276
|
+
isCompact: PropTypes__default.default.bool,
|
|
1277
|
+
isDisabled: PropTypes__default.default.bool,
|
|
1278
|
+
isEditable: PropTypes__default.default.bool,
|
|
1279
|
+
isExpanded: PropTypes__default.default.bool,
|
|
1280
|
+
isMultiselectable: PropTypes__default.default.bool,
|
|
1281
|
+
listboxAppendToNode: PropTypes__default.default.any,
|
|
1282
|
+
listboxAriaLabel: PropTypes__default.default.string,
|
|
1283
|
+
listboxMaxHeight: PropTypes__default.default.string,
|
|
1284
|
+
listboxMinHeight: PropTypes__default.default.string,
|
|
1285
|
+
listboxZIndex: PropTypes__default.default.number,
|
|
1286
|
+
maxHeight: PropTypes__default.default.string,
|
|
1287
|
+
maxTags: PropTypes__default.default.number,
|
|
1288
|
+
onChange: PropTypes__default.default.func,
|
|
1289
|
+
placeholder: PropTypes__default.default.string,
|
|
1290
|
+
renderExpandTags: PropTypes__default.default.func,
|
|
1291
|
+
renderValue: PropTypes__default.default.func,
|
|
1292
|
+
selectionValue: PropTypes__default.default.any,
|
|
1293
|
+
startIcon: PropTypes__default.default.any,
|
|
1294
|
+
validation: PropTypes__default.default.oneOf(reactForms.VALIDATION)
|
|
1295
|
+
};
|
|
1296
|
+
Combobox.defaultProps = {
|
|
1297
|
+
isEditable: true,
|
|
1298
|
+
listboxMaxHeight: '400px',
|
|
1299
|
+
listboxZIndex: 1000,
|
|
1300
|
+
maxTags: MAX_TAGS
|
|
1502
1301
|
};
|
|
1503
1302
|
|
|
1504
|
-
const
|
|
1505
|
-
const {
|
|
1506
|
-
downshift: {
|
|
1507
|
-
getRootProps
|
|
1508
|
-
}
|
|
1509
|
-
} = useDropdownContext();
|
|
1510
|
-
const [isLabelHovered, setIsLabelHovered] = React.useState(false);
|
|
1303
|
+
const Hint = React.forwardRef((props, ref) => {
|
|
1511
1304
|
const {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
}, props)));
|
|
1305
|
+
hintProps,
|
|
1306
|
+
setHasHint
|
|
1307
|
+
} = useFieldContext();
|
|
1308
|
+
React.useEffect(() => {
|
|
1309
|
+
setHasHint(true);
|
|
1310
|
+
return () => setHasHint(false);
|
|
1311
|
+
}, [setHasHint]);
|
|
1312
|
+
return React__namespace.default.createElement(StyledHint, Object.assign({}, hintProps, props, {
|
|
1313
|
+
ref: ref
|
|
1314
|
+
}));
|
|
1523
1315
|
});
|
|
1524
|
-
Field.displayName = 'Field';
|
|
1525
|
-
|
|
1526
|
-
const Hint = React__namespace.default.forwardRef((props, ref) => React__namespace.default.createElement(reactForms.Hint, _extends$5({
|
|
1527
|
-
ref: ref
|
|
1528
|
-
}, props)));
|
|
1529
1316
|
Hint.displayName = 'Hint';
|
|
1530
1317
|
|
|
1531
|
-
const Label =
|
|
1318
|
+
const Label = React.forwardRef((_ref, ref) => {
|
|
1532
1319
|
let {
|
|
1320
|
+
onClick,
|
|
1533
1321
|
onMouseEnter,
|
|
1534
1322
|
onMouseLeave,
|
|
1535
|
-
...
|
|
1323
|
+
...props
|
|
1536
1324
|
} = _ref;
|
|
1537
1325
|
const {
|
|
1538
|
-
|
|
1539
|
-
getLabelProps
|
|
1540
|
-
}
|
|
1541
|
-
} = useDropdownContext();
|
|
1542
|
-
const {
|
|
1543
|
-
setIsLabelHovered
|
|
1326
|
+
labelProps
|
|
1544
1327
|
} = useFieldContext();
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
setIsLabelHovered(false);
|
|
1551
|
-
}),
|
|
1552
|
-
...other
|
|
1553
|
-
});
|
|
1554
|
-
return React__namespace.default.createElement(reactForms.Label, _extends$5({
|
|
1328
|
+
return React__namespace.default.createElement(StyledLabel, Object.assign({}, labelProps, {
|
|
1329
|
+
onClick: containerUtilities.composeEventHandlers(onClick, labelProps?.onClick),
|
|
1330
|
+
onMouseEnter: containerUtilities.composeEventHandlers(onMouseEnter, labelProps?.onMouseEnter),
|
|
1331
|
+
onMouseLeave: containerUtilities.composeEventHandlers(onMouseLeave, labelProps?.onMouseLeave)
|
|
1332
|
+
}, props, {
|
|
1555
1333
|
ref: ref
|
|
1556
|
-
}
|
|
1334
|
+
}));
|
|
1557
1335
|
});
|
|
1558
1336
|
Label.displayName = 'Label';
|
|
1559
1337
|
Label.propTypes = {
|
|
1338
|
+
hidden: PropTypes__default.default.bool,
|
|
1560
1339
|
isRegular: PropTypes__default.default.bool
|
|
1561
1340
|
};
|
|
1562
1341
|
|
|
1563
|
-
const Message =
|
|
1564
|
-
ref: ref
|
|
1565
|
-
}, props)));
|
|
1566
|
-
Message.displayName = 'Message';
|
|
1567
|
-
Message.propTypes = {
|
|
1568
|
-
validation: PropTypes__default.default.oneOf(reactForms.VALIDATION)
|
|
1569
|
-
};
|
|
1570
|
-
|
|
1571
|
-
const SHARED_PLACEMENT = ['auto', 'top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end'];
|
|
1572
|
-
const PLACEMENT = [...SHARED_PLACEMENT, 'end', 'end-top', 'end-bottom', 'start', 'start-top', 'start-bottom'];
|
|
1573
|
-
|
|
1574
|
-
const MenuContext = React__namespace.default.createContext(undefined);
|
|
1575
|
-
const useMenuContext = () => {
|
|
1576
|
-
const menuContext = React.useContext(MenuContext);
|
|
1577
|
-
if (!menuContext) {
|
|
1578
|
-
throw new Error('This component must be rendered within a `Menu` component.');
|
|
1579
|
-
}
|
|
1580
|
-
return menuContext;
|
|
1581
|
-
};
|
|
1582
|
-
|
|
1583
|
-
const Menu = React.forwardRef((props, menuRef) => {
|
|
1584
|
-
const {
|
|
1585
|
-
placement,
|
|
1586
|
-
popperModifiers,
|
|
1587
|
-
eventsEnabled,
|
|
1588
|
-
isAnimated,
|
|
1589
|
-
maxHeight,
|
|
1590
|
-
style: menuStyle,
|
|
1591
|
-
zIndex,
|
|
1592
|
-
isCompact,
|
|
1593
|
-
children,
|
|
1594
|
-
appendToNode,
|
|
1595
|
-
...otherProps
|
|
1596
|
-
} = props;
|
|
1342
|
+
const Message = React.forwardRef((props, ref) => {
|
|
1597
1343
|
const {
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
nextItemsHashRef,
|
|
1602
|
-
popperReferenceElementRef,
|
|
1603
|
-
itemSearchRegistry,
|
|
1604
|
-
downshift: {
|
|
1605
|
-
isOpen,
|
|
1606
|
-
getMenuProps
|
|
1607
|
-
}
|
|
1608
|
-
} = useDropdownContext();
|
|
1609
|
-
const scheduleUpdateRef = React.useRef(undefined);
|
|
1610
|
-
React.useEffect(() => {
|
|
1611
|
-
if (scheduleUpdateRef.current && isOpen) {
|
|
1612
|
-
scheduleUpdateRef.current();
|
|
1613
|
-
}
|
|
1614
|
-
});
|
|
1615
|
-
const [isVisible, setIsVisible] = React.useState(isOpen);
|
|
1344
|
+
messageProps,
|
|
1345
|
+
setHasMessage
|
|
1346
|
+
} = useFieldContext();
|
|
1616
1347
|
React.useEffect(() => {
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
setIsVisible(false);
|
|
1624
|
-
}
|
|
1625
|
-
return () => clearTimeout(timeout);
|
|
1626
|
-
}, [isOpen, isAnimated]);
|
|
1627
|
-
const themeContext = React.useContext(styled.ThemeContext);
|
|
1628
|
-
itemIndexRef.current = 0;
|
|
1629
|
-
nextItemsHashRef.current = {};
|
|
1630
|
-
previousIndexRef.current = undefined;
|
|
1631
|
-
itemSearchRegistry.current = [];
|
|
1632
|
-
const popperPlacement = themeContext.rtl ? getRtlPopperPlacement(placement) : getPopperPlacement(placement);
|
|
1633
|
-
return (
|
|
1634
|
-
React__namespace.default.createElement(MenuContext.Provider, {
|
|
1635
|
-
value: {
|
|
1636
|
-
itemIndexRef,
|
|
1637
|
-
isCompact
|
|
1638
|
-
}
|
|
1639
|
-
}, React__namespace.default.createElement(reactPopper.Popper, {
|
|
1640
|
-
placement: popperPlacement,
|
|
1641
|
-
modifiers: popperModifiers
|
|
1642
|
-
,
|
|
1643
|
-
eventsEnabled: isOpen && eventsEnabled
|
|
1644
|
-
}, _ref => {
|
|
1645
|
-
let {
|
|
1646
|
-
ref,
|
|
1647
|
-
style,
|
|
1648
|
-
scheduleUpdate,
|
|
1649
|
-
placement: currentPlacement
|
|
1650
|
-
} = _ref;
|
|
1651
|
-
let computedStyle = menuStyle;
|
|
1652
|
-
scheduleUpdateRef.current = scheduleUpdate;
|
|
1653
|
-
if ((isOpen || isVisible) && popperReferenceElementRef.current && popperReferenceElementRef.current.getBoundingClientRect) {
|
|
1654
|
-
computedStyle = {
|
|
1655
|
-
width: popperReferenceElementRef.current.getBoundingClientRect().width,
|
|
1656
|
-
...menuStyle
|
|
1657
|
-
};
|
|
1658
|
-
}
|
|
1659
|
-
const menuProps = getMenuProps({
|
|
1660
|
-
role: hasMenuRef.current ? 'menu' : 'listbox',
|
|
1661
|
-
placement: currentPlacement,
|
|
1662
|
-
isAnimated: isAnimated && (isOpen || isVisible),
|
|
1663
|
-
...otherProps
|
|
1664
|
-
});
|
|
1665
|
-
const menu = React__namespace.default.createElement(StyledMenuWrapper, {
|
|
1666
|
-
ref: isOpen ? ref : undefined,
|
|
1667
|
-
hasArrow: menuProps.hasArrow,
|
|
1668
|
-
placement: menuProps.placement,
|
|
1669
|
-
style: style,
|
|
1670
|
-
isHidden: !isOpen,
|
|
1671
|
-
isAnimated: menuProps.isAnimated,
|
|
1672
|
-
zIndex: zIndex
|
|
1673
|
-
}, React__namespace.default.createElement(StyledMenu, _extends$5({
|
|
1674
|
-
ref: menuRef,
|
|
1675
|
-
isCompact: isCompact,
|
|
1676
|
-
maxHeight: maxHeight,
|
|
1677
|
-
style: computedStyle
|
|
1678
|
-
}, menuProps), (isOpen || isVisible) && children));
|
|
1679
|
-
return appendToNode ? reactDom.createPortal(menu, appendToNode) : menu;
|
|
1680
|
-
}))
|
|
1681
|
-
);
|
|
1348
|
+
setHasMessage(true);
|
|
1349
|
+
return () => setHasMessage(false);
|
|
1350
|
+
}, [setHasMessage]);
|
|
1351
|
+
return React__namespace.default.createElement(StyledMessage, Object.assign({}, messageProps, props, {
|
|
1352
|
+
ref: ref
|
|
1353
|
+
}));
|
|
1682
1354
|
});
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
zIndex: PropTypes__default.default.number,
|
|
1688
|
-
style: PropTypes__default.default.object,
|
|
1689
|
-
placement: PropTypes__default.default.oneOf(PLACEMENT),
|
|
1690
|
-
isAnimated: PropTypes__default.default.bool,
|
|
1691
|
-
isCompact: PropTypes__default.default.bool,
|
|
1692
|
-
hasArrow: PropTypes__default.default.bool,
|
|
1693
|
-
maxHeight: PropTypes__default.default.string
|
|
1694
|
-
};
|
|
1695
|
-
Menu.defaultProps = {
|
|
1696
|
-
placement: 'bottom-start',
|
|
1697
|
-
isAnimated: true,
|
|
1698
|
-
eventsEnabled: true,
|
|
1699
|
-
maxHeight: '400px',
|
|
1700
|
-
zIndex: 1000
|
|
1355
|
+
Message.displayName = 'Message';
|
|
1356
|
+
Message.propTypes = {
|
|
1357
|
+
validation: PropTypes__default.default.oneOf(reactForms.VALIDATION),
|
|
1358
|
+
validationLabel: PropTypes__default.default.string
|
|
1701
1359
|
};
|
|
1702
1360
|
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1361
|
+
const FieldComponent = React.forwardRef((props, ref) => {
|
|
1362
|
+
const [labelProps, setLabelProps] = React.useState(undefined);
|
|
1363
|
+
const [hintProps, setHintProps] = React.useState(undefined);
|
|
1364
|
+
const [messageProps, setMessageProps] = React.useState(undefined);
|
|
1365
|
+
const [hasHint, setHasHint] = React.useState(false);
|
|
1366
|
+
const [hasMessage, setHasMessage] = React.useState(false);
|
|
1367
|
+
const contextValue = React.useMemo(() => ({
|
|
1368
|
+
labelProps,
|
|
1369
|
+
setLabelProps,
|
|
1370
|
+
hasHint,
|
|
1371
|
+
setHasHint,
|
|
1372
|
+
hintProps,
|
|
1373
|
+
setHintProps,
|
|
1374
|
+
hasMessage,
|
|
1375
|
+
setHasMessage,
|
|
1376
|
+
messageProps,
|
|
1377
|
+
setMessageProps
|
|
1378
|
+
}), [labelProps, setLabelProps, hasHint, setHasHint, hintProps, setHintProps, hasMessage, setHasMessage, messageProps, setMessageProps]);
|
|
1379
|
+
return React__namespace.default.createElement(FieldContext.Provider, {
|
|
1380
|
+
value: contextValue
|
|
1381
|
+
}, React__namespace.default.createElement(StyledField, Object.assign({}, props, {
|
|
1382
|
+
ref: ref
|
|
1383
|
+
})));
|
|
1384
|
+
});
|
|
1385
|
+
FieldComponent.displayName = 'Field';
|
|
1386
|
+
const Field = FieldComponent;
|
|
1387
|
+
Field.Hint = Hint;
|
|
1388
|
+
Field.Label = Label;
|
|
1389
|
+
Field.Message = Message;
|
|
1707
1390
|
|
|
1708
|
-
var _path$
|
|
1709
|
-
function _extends$
|
|
1391
|
+
var _path$3;
|
|
1392
|
+
function _extends$3() { return _extends$3 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$3.apply(null, arguments); }
|
|
1710
1393
|
var SvgPlusStroke = function SvgPlusStroke(props) {
|
|
1711
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
1394
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$3({
|
|
1712
1395
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1713
1396
|
width: 16,
|
|
1714
1397
|
height: 16,
|
|
1715
1398
|
focusable: "false",
|
|
1716
1399
|
viewBox: "0 0 16 16",
|
|
1717
1400
|
"aria-hidden": "true"
|
|
1718
|
-
}, props), _path$
|
|
1401
|
+
}, props), _path$3 || (_path$3 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
1719
1402
|
stroke: "currentColor",
|
|
1720
1403
|
strokeLinecap: "round",
|
|
1721
1404
|
d: "M7.5 2.5v12m6-6h-12"
|
|
1722
1405
|
})));
|
|
1723
1406
|
};
|
|
1724
1407
|
|
|
1408
|
+
var _path$2;
|
|
1409
|
+
function _extends$2() { return _extends$2 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$2.apply(null, arguments); }
|
|
1410
|
+
var SvgChevronRightStroke = function SvgChevronRightStroke(props) {
|
|
1411
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
|
|
1412
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1413
|
+
width: 16,
|
|
1414
|
+
height: 16,
|
|
1415
|
+
focusable: "false",
|
|
1416
|
+
viewBox: "0 0 16 16",
|
|
1417
|
+
"aria-hidden": "true"
|
|
1418
|
+
}, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
1419
|
+
fill: "currentColor",
|
|
1420
|
+
d: "M5.61 3.312a.5.5 0 01.718-.69l.062.066 4 5a.5.5 0 01.054.542l-.054.082-4 5a.5.5 0 01-.83-.55l.05-.074L9.359 8l-3.75-4.688z"
|
|
1421
|
+
})));
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
var _path$1;
|
|
1425
|
+
function _extends$1() { return _extends$1 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$1.apply(null, arguments); }
|
|
1426
|
+
var SvgChevronLeftStroke = function SvgChevronLeftStroke(props) {
|
|
1427
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
1428
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1429
|
+
width: 16,
|
|
1430
|
+
height: 16,
|
|
1431
|
+
focusable: "false",
|
|
1432
|
+
viewBox: "0 0 16 16",
|
|
1433
|
+
"aria-hidden": "true"
|
|
1434
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
1435
|
+
fill: "currentColor",
|
|
1436
|
+
d: "M10.39 12.688a.5.5 0 01-.718.69l-.062-.066-4-5a.5.5 0 01-.054-.542l.054-.082 4-5a.5.5 0 01.83.55l-.05.074L6.641 8l3.75 4.688z"
|
|
1437
|
+
})));
|
|
1438
|
+
};
|
|
1439
|
+
|
|
1725
1440
|
var _path;
|
|
1726
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (
|
|
1441
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1727
1442
|
var SvgCheckLgStroke = function SvgCheckLgStroke(props) {
|
|
1728
1443
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
1729
1444
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1741,342 +1456,644 @@ var SvgCheckLgStroke = function SvgCheckLgStroke(props) {
|
|
|
1741
1456
|
})));
|
|
1742
1457
|
};
|
|
1743
1458
|
|
|
1744
|
-
const
|
|
1745
|
-
const
|
|
1746
|
-
|
|
1459
|
+
const OPTION_TYPE = ['add', 'danger', 'next', 'previous'];
|
|
1460
|
+
const PLACEMENT = ['auto', ...reactTheming.PLACEMENT];
|
|
1461
|
+
|
|
1462
|
+
const OptionContext = React.createContext(undefined);
|
|
1463
|
+
const useOptionContext = () => {
|
|
1464
|
+
const context = React.useContext(OptionContext);
|
|
1747
1465
|
if (!context) {
|
|
1748
|
-
throw new Error('
|
|
1466
|
+
throw new Error('Error: this component must be rendered within an <Option>.');
|
|
1749
1467
|
}
|
|
1750
1468
|
return context;
|
|
1751
1469
|
};
|
|
1752
1470
|
|
|
1753
|
-
const
|
|
1471
|
+
const OptionMetaComponent = React.forwardRef((props, ref) => {
|
|
1472
|
+
const {
|
|
1473
|
+
isDisabled
|
|
1474
|
+
} = useOptionContext();
|
|
1475
|
+
return React__namespace.default.createElement(StyledOptionMeta, Object.assign({
|
|
1476
|
+
isDisabled: isDisabled
|
|
1477
|
+
}, props, {
|
|
1478
|
+
ref: ref
|
|
1479
|
+
}));
|
|
1480
|
+
});
|
|
1481
|
+
OptionMetaComponent.displayName = 'Option.Meta';
|
|
1482
|
+
const OptionMeta = OptionMetaComponent;
|
|
1483
|
+
|
|
1484
|
+
const OptionComponent = React.forwardRef((_ref, ref) => {
|
|
1754
1485
|
let {
|
|
1755
|
-
value,
|
|
1756
|
-
disabled,
|
|
1757
|
-
isDanger,
|
|
1758
|
-
component = StyledItem,
|
|
1759
|
-
hasIcon,
|
|
1760
1486
|
children,
|
|
1487
|
+
icon,
|
|
1488
|
+
isDisabled,
|
|
1489
|
+
isHidden,
|
|
1490
|
+
isSelected,
|
|
1491
|
+
label,
|
|
1492
|
+
type,
|
|
1493
|
+
value,
|
|
1761
1494
|
...props
|
|
1762
1495
|
} = _ref;
|
|
1496
|
+
const contextValue = React.useMemo(() => ({
|
|
1497
|
+
isDisabled,
|
|
1498
|
+
type
|
|
1499
|
+
}), [isDisabled, type]);
|
|
1763
1500
|
const {
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
itemSearchRegistry,
|
|
1767
|
-
downshift: {
|
|
1768
|
-
isOpen,
|
|
1769
|
-
selectedItem,
|
|
1770
|
-
highlightedIndex,
|
|
1771
|
-
getItemProps,
|
|
1772
|
-
setHighlightedIndex,
|
|
1773
|
-
itemToString
|
|
1774
|
-
}
|
|
1775
|
-
} = useDropdownContext();
|
|
1776
|
-
const {
|
|
1777
|
-
itemIndexRef,
|
|
1501
|
+
activeValue,
|
|
1502
|
+
getOptionProps,
|
|
1778
1503
|
isCompact
|
|
1779
|
-
} =
|
|
1780
|
-
const
|
|
1781
|
-
const
|
|
1782
|
-
if ((value === undefined || value === null) && !disabled) {
|
|
1783
|
-
throw new Error('All Item components require a `value` prop');
|
|
1784
|
-
}
|
|
1785
|
-
const currentIndex = itemIndexRef.current;
|
|
1786
|
-
const isFocused = highlightedIndex === currentIndex;
|
|
1787
|
-
let isSelected;
|
|
1504
|
+
} = useComboboxContext();
|
|
1505
|
+
const isActive = value === activeValue;
|
|
1506
|
+
const optionRef = React.useRef(null);
|
|
1788
1507
|
React.useEffect(() => {
|
|
1789
|
-
if (
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
if (value) {
|
|
1797
|
-
if (selectedItems) {
|
|
1798
|
-
isSelected = selectedItems.some(item => {
|
|
1799
|
-
return itemToString(item) === itemToString(value);
|
|
1508
|
+
if (isActive) {
|
|
1509
|
+
setTimeout(() => {
|
|
1510
|
+
if (optionRef.current && optionRef.current.scrollIntoView) {
|
|
1511
|
+
optionRef.current.scrollIntoView({
|
|
1512
|
+
block: 'nearest'
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1800
1515
|
});
|
|
1801
|
-
} else {
|
|
1802
|
-
isSelected = itemToString(selectedItem) === itemToString(value);
|
|
1803
1516
|
}
|
|
1804
|
-
}
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1517
|
+
}, [isActive]);
|
|
1518
|
+
const renderActionIcon = iconType => {
|
|
1519
|
+
switch (iconType) {
|
|
1520
|
+
case 'add':
|
|
1521
|
+
return React__namespace.default.createElement(SvgPlusStroke, null);
|
|
1522
|
+
case 'next':
|
|
1523
|
+
return React__namespace.default.createElement(SvgChevronRightStroke, null);
|
|
1524
|
+
case 'previous':
|
|
1525
|
+
return React__namespace.default.createElement(SvgChevronLeftStroke, null);
|
|
1526
|
+
default:
|
|
1527
|
+
return React__namespace.default.createElement(SvgCheckLgStroke, null);
|
|
1810
1528
|
}
|
|
1811
|
-
}
|
|
1812
|
-
const
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
}, props), isSelected && !hasIcon && React__namespace.default.createElement(StyledItemIcon, {
|
|
1825
|
-
isCompact: isCompact,
|
|
1826
|
-
isVisible: isSelected,
|
|
1827
|
-
isDisabled: disabled
|
|
1828
|
-
}, React__namespace.default.createElement(SvgCheckLgStroke, null)), children));
|
|
1829
|
-
}
|
|
1830
|
-
itemIndexRef.current++;
|
|
1831
|
-
return React__namespace.default.createElement(ItemContext.Provider, {
|
|
1529
|
+
};
|
|
1530
|
+
const option = toOption({
|
|
1531
|
+
value,
|
|
1532
|
+
label,
|
|
1533
|
+
isDisabled,
|
|
1534
|
+
isHidden,
|
|
1535
|
+
isSelected
|
|
1536
|
+
});
|
|
1537
|
+
const optionProps = getOptionProps({
|
|
1538
|
+
option,
|
|
1539
|
+
ref: reactMergeRefs.mergeRefs([optionRef, ref])
|
|
1540
|
+
});
|
|
1541
|
+
return React__namespace.default.createElement(OptionContext.Provider, {
|
|
1832
1542
|
value: contextValue
|
|
1833
|
-
}, React__namespace.default.createElement(
|
|
1834
|
-
|
|
1835
|
-
isFocused,
|
|
1836
|
-
ref,
|
|
1837
|
-
isCompact,
|
|
1838
|
-
isDanger,
|
|
1839
|
-
...(hasMenuRef.current && {
|
|
1840
|
-
role: 'menuitem',
|
|
1841
|
-
'aria-selected': null
|
|
1842
|
-
}),
|
|
1843
|
-
...props
|
|
1844
|
-
}), isSelected && !hasIcon && React__namespace.default.createElement(StyledItemIcon, {
|
|
1543
|
+
}, React__namespace.default.createElement(StyledOption, Object.assign({
|
|
1544
|
+
isActive: isActive,
|
|
1845
1545
|
isCompact: isCompact,
|
|
1846
|
-
|
|
1847
|
-
}, React__namespace.default.createElement(
|
|
1546
|
+
$type: type
|
|
1547
|
+
}, props, optionProps), React__namespace.default.createElement(StyledOptionTypeIcon, {
|
|
1548
|
+
$isCompact: isCompact,
|
|
1549
|
+
$type: type
|
|
1550
|
+
}, renderActionIcon(type)), icon && React__namespace.default.createElement(StyledOptionIcon, {
|
|
1551
|
+
$isDisabled: isDisabled,
|
|
1552
|
+
$type: type
|
|
1553
|
+
}, icon), React__namespace.default.createElement(StyledOptionContent, null, children || label || value)));
|
|
1848
1554
|
});
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1555
|
+
OptionComponent.displayName = 'Option';
|
|
1556
|
+
OptionComponent.propTypes = {
|
|
1557
|
+
icon: PropTypes__default.default.any,
|
|
1558
|
+
isDisabled: PropTypes__default.default.bool,
|
|
1559
|
+
isSelected: PropTypes__default.default.bool,
|
|
1560
|
+
isHidden: PropTypes__default.default.bool,
|
|
1561
|
+
label: PropTypes__default.default.string,
|
|
1562
|
+
tagProps: PropTypes__default.default.object,
|
|
1563
|
+
type: PropTypes__default.default.oneOf(OPTION_TYPE),
|
|
1564
|
+
value: PropTypes__default.default.string.isRequired
|
|
1853
1565
|
};
|
|
1566
|
+
const Option = OptionComponent;
|
|
1567
|
+
Option.Meta = OptionMeta;
|
|
1854
1568
|
|
|
1855
|
-
const
|
|
1569
|
+
const OptGroup = React.forwardRef((_ref, ref) => {
|
|
1856
1570
|
let {
|
|
1857
1571
|
children,
|
|
1858
|
-
|
|
1572
|
+
content,
|
|
1573
|
+
icon,
|
|
1574
|
+
legend,
|
|
1575
|
+
'aria-label': ariaLabel,
|
|
1576
|
+
onMouseDown,
|
|
1859
1577
|
...props
|
|
1860
1578
|
} = _ref;
|
|
1861
1579
|
const {
|
|
1580
|
+
getOptGroupProps,
|
|
1862
1581
|
isCompact
|
|
1863
|
-
} =
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
},
|
|
1582
|
+
} = useComboboxContext();
|
|
1583
|
+
const handleMouseDown = event => event.preventDefault();
|
|
1584
|
+
const groupAriaLabel = reactTheming.useText(OptGroup, {
|
|
1585
|
+
'aria-label': ariaLabel
|
|
1586
|
+
}, 'aria-label', 'Group', !legend );
|
|
1587
|
+
const optGroupProps = getOptGroupProps({
|
|
1588
|
+
'aria-label': groupAriaLabel || legend
|
|
1589
|
+
});
|
|
1590
|
+
return React__namespace.default.createElement(StyledOption, Object.assign({
|
|
1868
1591
|
isCompact: isCompact,
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
disabled: PropTypes__default.default.bool
|
|
1883
|
-
};
|
|
1884
|
-
|
|
1885
|
-
const HeaderIcon = React__namespace.default.forwardRef((props, ref) => {
|
|
1886
|
-
const {
|
|
1887
|
-
isCompact
|
|
1888
|
-
} = useMenuContext();
|
|
1889
|
-
return React__namespace.default.createElement(StyledHeaderIcon, _extends$5({
|
|
1890
|
-
ref: ref,
|
|
1592
|
+
$type: "group",
|
|
1593
|
+
onMouseDown: containerUtilities.composeEventHandlers(onMouseDown, handleMouseDown),
|
|
1594
|
+
role: "none"
|
|
1595
|
+
}, props, {
|
|
1596
|
+
ref: ref
|
|
1597
|
+
}), React__namespace.default.createElement(StyledOptionContent, null, (content || legend) && React__namespace.default.createElement(StyledOption, {
|
|
1598
|
+
as: "div",
|
|
1599
|
+
isCompact: isCompact,
|
|
1600
|
+
$type: "header"
|
|
1601
|
+
}, icon && React__namespace.default.createElement(StyledOptionTypeIcon, {
|
|
1602
|
+
$isCompact: isCompact,
|
|
1603
|
+
$type: "header"
|
|
1604
|
+
}, icon), content || legend), React__namespace.default.createElement(StyledOptGroup, Object.assign({
|
|
1891
1605
|
isCompact: isCompact
|
|
1892
|
-
},
|
|
1606
|
+
}, optGroupProps), React__namespace.default.createElement(StyledListboxSeparator, {
|
|
1607
|
+
role: "none"
|
|
1608
|
+
}), children)));
|
|
1893
1609
|
});
|
|
1894
|
-
|
|
1610
|
+
OptGroup.displayName = 'OptGroup';
|
|
1611
|
+
OptGroup.propTypes = {
|
|
1612
|
+
content: PropTypes__default.default.any,
|
|
1613
|
+
icon: PropTypes__default.default.any,
|
|
1614
|
+
legend: PropTypes__default.default.string
|
|
1615
|
+
};
|
|
1895
1616
|
|
|
1896
|
-
const
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1617
|
+
const MenuContext = React.createContext(undefined);
|
|
1618
|
+
const useMenuContext = () => {
|
|
1619
|
+
const context = React.useContext(MenuContext);
|
|
1620
|
+
if (!context) {
|
|
1621
|
+
throw new Error('Error: this component must be rendered within a <Menu>.');
|
|
1622
|
+
}
|
|
1623
|
+
return context;
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1626
|
+
const toItem = props => ({
|
|
1627
|
+
value: props.value,
|
|
1628
|
+
label: props.label,
|
|
1629
|
+
...(props.name && {
|
|
1630
|
+
name: props.name
|
|
1631
|
+
}),
|
|
1632
|
+
...(props.isDisabled && {
|
|
1633
|
+
disabled: props.isDisabled
|
|
1634
|
+
}),
|
|
1635
|
+
...(props.isSelected && {
|
|
1636
|
+
selected: props.isSelected
|
|
1637
|
+
}),
|
|
1638
|
+
...(props.selectionType && {
|
|
1639
|
+
type: props.selectionType
|
|
1640
|
+
}),
|
|
1641
|
+
...(props.type === 'next' && {
|
|
1642
|
+
isNext: true
|
|
1643
|
+
}),
|
|
1644
|
+
...(props.type === 'previous' && {
|
|
1645
|
+
isPrevious: true
|
|
1646
|
+
})
|
|
1904
1647
|
});
|
|
1905
|
-
|
|
1648
|
+
const toItems = (children, type) => React.Children.toArray(children).reduce((items, item) => {
|
|
1649
|
+
const retVal = items;
|
|
1650
|
+
if ( React.isValidElement(item)) {
|
|
1651
|
+
if ('value' in item.props) {
|
|
1652
|
+
retVal.push(toItem({
|
|
1653
|
+
...item.props,
|
|
1654
|
+
selectionType: type
|
|
1655
|
+
}));
|
|
1656
|
+
} else {
|
|
1657
|
+
const props = item.props;
|
|
1658
|
+
const groupLabel = props.legend || props['aria-label'];
|
|
1659
|
+
const isSelectableGroup = props.type && ['checkbox', 'radio'].includes(props.type);
|
|
1660
|
+
if (groupLabel || isSelectableGroup) {
|
|
1661
|
+
const groupItems = toItems(props.children, props.type);
|
|
1662
|
+
retVal.push({
|
|
1663
|
+
label: props.legend || props['aria-label'],
|
|
1664
|
+
items: groupItems
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return retVal;
|
|
1670
|
+
}, []);
|
|
1906
1671
|
|
|
1907
|
-
const
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1672
|
+
const PLACEMENT_DEFAULT = 'bottom-start';
|
|
1673
|
+
const MenuList = React.forwardRef((_ref, ref) => {
|
|
1674
|
+
let {
|
|
1675
|
+
appendToNode,
|
|
1676
|
+
hasArrow,
|
|
1677
|
+
isCompact,
|
|
1678
|
+
isExpanded,
|
|
1679
|
+
fallbackPlacements: _fallbackPlacements,
|
|
1680
|
+
maxHeight,
|
|
1681
|
+
minHeight,
|
|
1682
|
+
placement: _placement,
|
|
1683
|
+
triggerRef,
|
|
1684
|
+
zIndex,
|
|
1685
|
+
children,
|
|
1686
|
+
...props
|
|
1687
|
+
} = _ref;
|
|
1688
|
+
const floatingRef = React.useRef(null);
|
|
1689
|
+
const [isVisible, setIsVisible] = React.useState(isExpanded);
|
|
1690
|
+
const [height, setHeight] = React.useState();
|
|
1691
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
1692
|
+
const [floatingPlacement, fallbackPlacements] = reactTheming.getFloatingPlacements(theme, _placement === 'auto' ? PLACEMENT_DEFAULT : _placement, _fallbackPlacements);
|
|
1911
1693
|
const {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1694
|
+
refs,
|
|
1695
|
+
placement,
|
|
1696
|
+
update,
|
|
1697
|
+
floatingStyles: {
|
|
1698
|
+
transform
|
|
1699
|
+
}
|
|
1700
|
+
} = reactDom.useFloating({
|
|
1701
|
+
platform: {
|
|
1702
|
+
...reactDom.platform,
|
|
1703
|
+
isRTL: () => theme.rtl
|
|
1704
|
+
},
|
|
1705
|
+
elements: {
|
|
1706
|
+
reference: triggerRef?.current,
|
|
1707
|
+
floating: floatingRef?.current
|
|
1708
|
+
},
|
|
1709
|
+
placement: floatingPlacement,
|
|
1710
|
+
middleware: [reactDom.offset(theme.space.base * (hasArrow ? 2 : 1)), _placement === 'auto' ? reactDom.autoPlacement() : reactDom.flip({
|
|
1711
|
+
fallbackPlacements
|
|
1712
|
+
}), reactDom.size({
|
|
1713
|
+
apply: _ref2 => {
|
|
1714
|
+
let {
|
|
1715
|
+
rects,
|
|
1716
|
+
availableHeight
|
|
1717
|
+
} = _ref2;
|
|
1718
|
+
if (!(minHeight === null || minHeight === 'fit-content')) {
|
|
1719
|
+
if (rects.floating.height > availableHeight) {
|
|
1720
|
+
setHeight(availableHeight);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
})]
|
|
1725
|
+
});
|
|
1726
|
+
React.useEffect(() => {
|
|
1727
|
+
let cleanup;
|
|
1728
|
+
if (isExpanded && refs.reference.current && refs.floating.current) {
|
|
1729
|
+
cleanup = reactDom.autoUpdate(refs.reference.current, refs.floating.current, update, {
|
|
1730
|
+
elementResize: typeof ResizeObserver === 'function'
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
return () => cleanup && cleanup();
|
|
1734
|
+
}, [isExpanded, refs.reference, refs.floating, update]);
|
|
1735
|
+
React.useEffect(() => {
|
|
1736
|
+
let timeout;
|
|
1737
|
+
if (isExpanded) {
|
|
1738
|
+
setIsVisible(true);
|
|
1739
|
+
} else {
|
|
1740
|
+
timeout = setTimeout(() => {
|
|
1741
|
+
setIsVisible(false);
|
|
1742
|
+
setHeight(undefined);
|
|
1743
|
+
}, 200 );
|
|
1744
|
+
}
|
|
1745
|
+
return () => clearTimeout(timeout);
|
|
1746
|
+
}, [isExpanded]);
|
|
1747
|
+
React.useEffect(() => {
|
|
1748
|
+
if (height) {
|
|
1749
|
+
setHeight(undefined);
|
|
1750
|
+
update();
|
|
1751
|
+
}
|
|
1752
|
+
}, [
|
|
1753
|
+
children, update]);
|
|
1754
|
+
const Node = React__namespace.default.createElement(StyledFloatingMenu, {
|
|
1755
|
+
"data-garden-animate": isVisible,
|
|
1756
|
+
isHidden: !isExpanded,
|
|
1757
|
+
position: reactTheming.getMenuPosition(placement),
|
|
1758
|
+
zIndex: zIndex,
|
|
1759
|
+
style: {
|
|
1760
|
+
transform
|
|
1761
|
+
},
|
|
1762
|
+
ref: floatingRef
|
|
1763
|
+
}, React__namespace.default.createElement(StyledMenu, Object.assign({
|
|
1764
|
+
"data-garden-animate-arrow": isVisible,
|
|
1765
|
+
arrowPosition: hasArrow ? reactTheming.getArrowPosition(theme, placement) : undefined,
|
|
1916
1766
|
isCompact: isCompact,
|
|
1917
|
-
|
|
1918
|
-
|
|
1767
|
+
minHeight: minHeight,
|
|
1768
|
+
maxHeight: maxHeight,
|
|
1769
|
+
style: {
|
|
1770
|
+
height
|
|
1771
|
+
}
|
|
1772
|
+
}, props, {
|
|
1773
|
+
ref: ref
|
|
1774
|
+
}), isVisible && children));
|
|
1775
|
+
return appendToNode ? reactDom$1.createPortal(Node, appendToNode) : Node;
|
|
1919
1776
|
});
|
|
1920
|
-
|
|
1777
|
+
MenuList.displayName = 'MenuList';
|
|
1778
|
+
MenuList.propTypes = {
|
|
1779
|
+
appendToNode: PropTypes__default.default.any,
|
|
1780
|
+
hasArrow: PropTypes__default.default.bool,
|
|
1781
|
+
isCompact: PropTypes__default.default.bool,
|
|
1782
|
+
isExpanded: PropTypes__default.default.bool,
|
|
1783
|
+
maxHeight: PropTypes__default.default.string,
|
|
1784
|
+
minHeight: PropTypes__default.default.string,
|
|
1785
|
+
placement: PropTypes__default.default.oneOf(PLACEMENT),
|
|
1786
|
+
triggerRef: PropTypes__default.default.any,
|
|
1787
|
+
zIndex: PropTypes__default.default.number
|
|
1788
|
+
};
|
|
1789
|
+
MenuList.defaultProps = {
|
|
1790
|
+
maxHeight: '400px',
|
|
1791
|
+
placement: PLACEMENT_DEFAULT,
|
|
1792
|
+
zIndex: 1000
|
|
1793
|
+
};
|
|
1921
1794
|
|
|
1922
|
-
const
|
|
1795
|
+
const Menu = React.forwardRef((_ref, ref) => {
|
|
1796
|
+
let {
|
|
1797
|
+
button,
|
|
1798
|
+
buttonProps: _buttonProps = {},
|
|
1799
|
+
children,
|
|
1800
|
+
isCompact,
|
|
1801
|
+
focusedValue: _focusedValue,
|
|
1802
|
+
defaultFocusedValue,
|
|
1803
|
+
defaultExpanded,
|
|
1804
|
+
isExpanded: _isExpanded,
|
|
1805
|
+
selectedItems,
|
|
1806
|
+
onChange,
|
|
1807
|
+
onMouseLeave,
|
|
1808
|
+
...props
|
|
1809
|
+
} = _ref;
|
|
1810
|
+
const triggerRef = React.useRef(null);
|
|
1811
|
+
const menuRef = React.useRef(null);
|
|
1812
|
+
const items = toItems(children);
|
|
1813
|
+
const theme = React.useContext(styled.ThemeContext) || reactTheming.DEFAULT_THEME;
|
|
1814
|
+
const environment = reactTheming.useWindow(theme);
|
|
1923
1815
|
const {
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1816
|
+
isExpanded,
|
|
1817
|
+
focusedValue,
|
|
1818
|
+
getTriggerProps,
|
|
1819
|
+
getMenuProps,
|
|
1820
|
+
getItemProps,
|
|
1821
|
+
getItemGroupProps,
|
|
1822
|
+
getSeparatorProps
|
|
1823
|
+
} = containerMenu.useMenu({
|
|
1824
|
+
rtl: theme.rtl,
|
|
1825
|
+
environment,
|
|
1826
|
+
defaultFocusedValue,
|
|
1827
|
+
focusedValue: _focusedValue,
|
|
1828
|
+
defaultExpanded,
|
|
1829
|
+
isExpanded: _isExpanded,
|
|
1830
|
+
selectedItems,
|
|
1831
|
+
items,
|
|
1832
|
+
menuRef,
|
|
1833
|
+
triggerRef,
|
|
1834
|
+
onChange
|
|
1835
|
+
});
|
|
1934
1836
|
const {
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
}
|
|
1837
|
+
onClick,
|
|
1838
|
+
onKeyDown,
|
|
1839
|
+
disabled,
|
|
1840
|
+
...buttonProps
|
|
1841
|
+
} = _buttonProps;
|
|
1842
|
+
const triggerProps = {
|
|
1843
|
+
...(isCompact && {
|
|
1844
|
+
size: 'small'
|
|
1845
|
+
}),
|
|
1846
|
+
...buttonProps,
|
|
1847
|
+
...getTriggerProps({
|
|
1848
|
+
type: 'button',
|
|
1849
|
+
onClick,
|
|
1850
|
+
onKeyDown,
|
|
1851
|
+
disabled
|
|
1852
|
+
}),
|
|
1853
|
+
ref: reactMergeRefs.mergeRefs([triggerRef, ref])
|
|
1854
|
+
};
|
|
1855
|
+
const trigger = typeof button === 'function' ? button(triggerProps) : React__namespace.default.createElement(reactButtons.Button, triggerProps, button, React__namespace.default.createElement(reactButtons.Button.EndIcon, {
|
|
1856
|
+
isRotated: isExpanded
|
|
1857
|
+
}, React__namespace.default.createElement(SvgChevronDownStroke, null)));
|
|
1858
|
+
const contextValue = React.useMemo(() => ({
|
|
1859
|
+
isCompact,
|
|
1860
|
+
focusedValue,
|
|
1861
|
+
getItemProps,
|
|
1862
|
+
getItemGroupProps,
|
|
1863
|
+
getSeparatorProps
|
|
1864
|
+
}), [isCompact, focusedValue, getItemProps, getItemGroupProps, getSeparatorProps]);
|
|
1865
|
+
return React__namespace.default.createElement(MenuContext.Provider, {
|
|
1866
|
+
value: contextValue
|
|
1867
|
+
}, trigger, React__namespace.default.createElement(MenuList, Object.assign({}, props, getMenuProps({
|
|
1868
|
+
onMouseLeave
|
|
1869
|
+
}), {
|
|
1870
|
+
ref: reactMergeRefs.mergeRefs([menuRef, ref]),
|
|
1871
|
+
isCompact: isCompact,
|
|
1872
|
+
isExpanded: isExpanded,
|
|
1873
|
+
triggerRef: triggerRef
|
|
1874
|
+
}), children));
|
|
1875
|
+
});
|
|
1876
|
+
Menu.displayName = 'Menu';
|
|
1877
|
+
Menu.propTypes = {
|
|
1878
|
+
appendToNode: PropTypes__default.default.any,
|
|
1879
|
+
button: PropTypes__default.default.any.isRequired,
|
|
1880
|
+
buttonProps: PropTypes__default.default.object,
|
|
1881
|
+
defaultExpanded: PropTypes__default.default.bool,
|
|
1882
|
+
defaultFocusedValue: PropTypes__default.default.string,
|
|
1883
|
+
fallbackPlacements: PropTypes__default.default.arrayOf(PropTypes__default.default.any),
|
|
1884
|
+
focusedValue: PropTypes__default.default.string,
|
|
1885
|
+
hasArrow: PropTypes__default.default.bool,
|
|
1886
|
+
isCompact: PropTypes__default.default.bool,
|
|
1887
|
+
isExpanded: PropTypes__default.default.bool,
|
|
1888
|
+
maxHeight: PropTypes__default.default.string,
|
|
1889
|
+
minHeight: PropTypes__default.default.string,
|
|
1890
|
+
onChange: PropTypes__default.default.func,
|
|
1891
|
+
placement: PropTypes__default.default.oneOf(PLACEMENT),
|
|
1892
|
+
selectedItems: PropTypes__default.default.arrayOf(PropTypes__default.default.any),
|
|
1893
|
+
zIndex: PropTypes__default.default.number
|
|
1894
|
+
};
|
|
1895
|
+
Menu.defaultProps = {
|
|
1896
|
+
maxHeight: '400px',
|
|
1897
|
+
placement: 'bottom-start',
|
|
1898
|
+
zIndex: 1000
|
|
1940
1899
|
};
|
|
1941
1900
|
|
|
1942
|
-
const
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
}, props)));
|
|
1946
|
-
MediaItem.displayName = 'MediaItem';
|
|
1947
|
-
MediaItem.propTypes = {
|
|
1948
|
-
value: PropTypes__default.default.any,
|
|
1949
|
-
disabled: PropTypes__default.default.bool
|
|
1901
|
+
const ItemGroupContext = React.createContext({});
|
|
1902
|
+
const useItemGroupContext = () => {
|
|
1903
|
+
return React.useContext(ItemGroupContext);
|
|
1950
1904
|
};
|
|
1951
1905
|
|
|
1952
|
-
const
|
|
1906
|
+
const ItemGroup = React.forwardRef((_ref, ref) => {
|
|
1953
1907
|
let {
|
|
1954
1908
|
children,
|
|
1955
|
-
|
|
1909
|
+
content,
|
|
1910
|
+
legend,
|
|
1911
|
+
icon,
|
|
1912
|
+
'aria-label': ariaLabel,
|
|
1913
|
+
type,
|
|
1956
1914
|
...props
|
|
1957
1915
|
} = _ref;
|
|
1958
1916
|
const {
|
|
1959
|
-
isCompact
|
|
1917
|
+
isCompact,
|
|
1918
|
+
getItemGroupProps
|
|
1960
1919
|
} = useMenuContext();
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1920
|
+
const groupAriaLabel = reactTheming.useText(ItemGroup, {
|
|
1921
|
+
'aria-label': ariaLabel
|
|
1922
|
+
}, 'aria-label', 'Group', !legend );
|
|
1923
|
+
const groupProps = getItemGroupProps({
|
|
1924
|
+
'aria-label': groupAriaLabel || legend
|
|
1925
|
+
});
|
|
1926
|
+
const contextValue = React.useMemo(() => ({
|
|
1927
|
+
type
|
|
1928
|
+
}), [type]);
|
|
1929
|
+
return React__namespace.default.createElement(ItemGroupContext.Provider, {
|
|
1930
|
+
value: contextValue
|
|
1931
|
+
}, React__namespace.default.createElement(StyledItem, Object.assign({
|
|
1932
|
+
isCompact: isCompact,
|
|
1933
|
+
$type: "group"
|
|
1934
|
+
}, props, {
|
|
1935
|
+
ref: ref
|
|
1936
|
+
}), React__namespace.default.createElement(StyledItemContent, null, (content || legend) && React__namespace.default.createElement(StyledItem, {
|
|
1937
|
+
as: "div",
|
|
1965
1938
|
isCompact: isCompact,
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
})),
|
|
1939
|
+
$type: "header"
|
|
1940
|
+
}, icon && React__namespace.default.createElement(StyledItemTypeIcon, {
|
|
1941
|
+
$isCompact: isCompact,
|
|
1942
|
+
$type: "header"
|
|
1943
|
+
}, icon), content || legend), React__namespace.default.createElement(StyledItemGroup, Object.assign({
|
|
1944
|
+
isCompact: isCompact
|
|
1945
|
+
}, groupProps), React__namespace.default.createElement(StyledSeparator, {
|
|
1946
|
+
role: "none"
|
|
1947
|
+
}), children))));
|
|
1971
1948
|
});
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
itemIndexRef
|
|
1986
|
-
} = useMenuContext();
|
|
1987
|
-
if (!disabled) {
|
|
1988
|
-
nextItemsHashRef.current[itemToString(value)] = itemIndexRef.current;
|
|
1949
|
+
ItemGroup.displayName = 'ItemGroup';
|
|
1950
|
+
ItemGroup.propTypes = {
|
|
1951
|
+
content: PropTypes__default.default.any,
|
|
1952
|
+
icon: PropTypes__default.default.any,
|
|
1953
|
+
legend: PropTypes__default.default.string,
|
|
1954
|
+
type: PropTypes__default.default.oneOf(['checkbox', 'radio', undefined])
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
const ItemContext = React.createContext(undefined);
|
|
1958
|
+
const useItemContext = () => {
|
|
1959
|
+
const context = React.useContext(ItemContext);
|
|
1960
|
+
if (!context) {
|
|
1961
|
+
throw new Error('Error: this component must be rendered within an <Item>.');
|
|
1989
1962
|
}
|
|
1990
|
-
return
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1963
|
+
return context;
|
|
1964
|
+
};
|
|
1965
|
+
|
|
1966
|
+
const ItemMetaComponent = React.forwardRef((props, ref) => {
|
|
1967
|
+
const {
|
|
1968
|
+
isDisabled
|
|
1969
|
+
} = useItemContext();
|
|
1970
|
+
return React__namespace.default.createElement(StyledItemMeta, Object.assign({
|
|
1971
|
+
isDisabled: isDisabled
|
|
1996
1972
|
}, props, {
|
|
1997
|
-
|
|
1973
|
+
ref: ref
|
|
1998
1974
|
}));
|
|
1999
1975
|
});
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
value: PropTypes__default.default.any,
|
|
2003
|
-
disabled: PropTypes__default.default.bool
|
|
2004
|
-
};
|
|
1976
|
+
ItemMetaComponent.displayName = 'Item.Meta';
|
|
1977
|
+
const ItemMeta = ItemMetaComponent;
|
|
2005
1978
|
|
|
2006
|
-
const
|
|
1979
|
+
const ItemComponent = React.forwardRef((_ref, ref) => {
|
|
2007
1980
|
let {
|
|
2008
1981
|
children,
|
|
2009
|
-
|
|
1982
|
+
value,
|
|
1983
|
+
label = value,
|
|
1984
|
+
isSelected,
|
|
1985
|
+
icon,
|
|
1986
|
+
isDisabled,
|
|
1987
|
+
type,
|
|
1988
|
+
name,
|
|
1989
|
+
onClick,
|
|
1990
|
+
onKeyDown,
|
|
1991
|
+
onMouseEnter,
|
|
2010
1992
|
...props
|
|
2011
1993
|
} = _ref;
|
|
2012
1994
|
const {
|
|
1995
|
+
type: selectionType
|
|
1996
|
+
} = useItemGroupContext();
|
|
1997
|
+
const {
|
|
1998
|
+
focusedValue,
|
|
1999
|
+
getItemProps,
|
|
2013
2000
|
isCompact
|
|
2014
2001
|
} = useMenuContext();
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2002
|
+
const item = {
|
|
2003
|
+
...toItem({
|
|
2004
|
+
value,
|
|
2005
|
+
label,
|
|
2006
|
+
name,
|
|
2007
|
+
type,
|
|
2008
|
+
isSelected,
|
|
2009
|
+
isDisabled
|
|
2010
|
+
}),
|
|
2011
|
+
type: selectionType
|
|
2012
|
+
};
|
|
2013
|
+
const {
|
|
2014
|
+
ref: _itemRef,
|
|
2015
|
+
...itemProps
|
|
2016
|
+
} = getItemProps({
|
|
2017
|
+
item,
|
|
2018
|
+
onClick,
|
|
2019
|
+
onKeyDown,
|
|
2020
|
+
onMouseEnter
|
|
2021
|
+
});
|
|
2022
|
+
const isActive = value === focusedValue;
|
|
2023
|
+
const renderActionIcon = iconType => {
|
|
2024
|
+
switch (iconType) {
|
|
2025
|
+
case 'add':
|
|
2026
|
+
return React__namespace.default.createElement(SvgPlusStroke, null);
|
|
2027
|
+
case 'next':
|
|
2028
|
+
return React__namespace.default.createElement(SvgChevronRightStroke, null);
|
|
2029
|
+
case 'previous':
|
|
2030
|
+
return React__namespace.default.createElement(SvgChevronLeftStroke, null);
|
|
2031
|
+
default:
|
|
2032
|
+
return React__namespace.default.createElement(SvgCheckLgStroke, null);
|
|
2033
|
+
}
|
|
2034
|
+
};
|
|
2035
|
+
const contextValue = React.useMemo(() => ({
|
|
2036
|
+
isDisabled,
|
|
2037
|
+
type
|
|
2038
|
+
}), [isDisabled, type]);
|
|
2039
|
+
return React__namespace.default.createElement(ItemContext.Provider, {
|
|
2040
|
+
value: contextValue
|
|
2041
|
+
}, React__namespace.default.createElement(StyledItem, Object.assign({
|
|
2042
|
+
$type: type,
|
|
2019
2043
|
isCompact: isCompact,
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2044
|
+
isActive: isActive
|
|
2045
|
+
}, props, itemProps, {
|
|
2046
|
+
ref: reactMergeRefs.mergeRefs([_itemRef, ref])
|
|
2047
|
+
}), React__namespace.default.createElement(StyledItemTypeIcon, {
|
|
2048
|
+
$isCompact: isCompact,
|
|
2049
|
+
$type: type
|
|
2050
|
+
}, renderActionIcon(type)), icon && React__namespace.default.createElement(StyledItemIcon, {
|
|
2051
|
+
$isDisabled: isDisabled,
|
|
2052
|
+
$type: type
|
|
2053
|
+
}, icon), React__namespace.default.createElement(StyledItemContent, null, children || label)));
|
|
2025
2054
|
});
|
|
2026
|
-
|
|
2055
|
+
ItemComponent.displayName = 'Item';
|
|
2056
|
+
ItemComponent.propTypes = {
|
|
2057
|
+
icon: PropTypes__default.default.any,
|
|
2058
|
+
isDisabled: PropTypes__default.default.bool,
|
|
2059
|
+
isSelected: PropTypes__default.default.bool,
|
|
2060
|
+
label: PropTypes__default.default.string,
|
|
2061
|
+
name: PropTypes__default.default.string,
|
|
2062
|
+
type: PropTypes__default.default.oneOf(OPTION_TYPE),
|
|
2063
|
+
value: PropTypes__default.default.string.isRequired
|
|
2064
|
+
};
|
|
2065
|
+
const Item = ItemComponent;
|
|
2066
|
+
Item.Meta = ItemMeta;
|
|
2067
|
+
|
|
2068
|
+
const Separator = React.forwardRef(
|
|
2069
|
+
(_ref, ref) => {
|
|
2027
2070
|
let {
|
|
2028
|
-
|
|
2029
|
-
disabled,
|
|
2071
|
+
children,
|
|
2030
2072
|
...props
|
|
2031
|
-
} =
|
|
2032
|
-
const {
|
|
2033
|
-
previousIndexRef
|
|
2034
|
-
} = useDropdownContext();
|
|
2073
|
+
} = _ref;
|
|
2035
2074
|
const {
|
|
2036
|
-
|
|
2075
|
+
getSeparatorProps
|
|
2037
2076
|
} = useMenuContext();
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
return React__namespace.default.createElement(Item, _extends$5({
|
|
2042
|
-
component: PreviousItemComponent,
|
|
2043
|
-
"aria-expanded": true,
|
|
2044
|
-
value: value,
|
|
2045
|
-
disabled: disabled
|
|
2046
|
-
}, props, {
|
|
2047
|
-
ref: ref,
|
|
2048
|
-
hasIcon: true
|
|
2077
|
+
const separatorProps = getSeparatorProps();
|
|
2078
|
+
return React__namespace.default.createElement(StyledSeparator, Object.assign({}, props, separatorProps, {
|
|
2079
|
+
ref: ref
|
|
2049
2080
|
}));
|
|
2050
2081
|
});
|
|
2051
|
-
|
|
2052
|
-
PreviousItem.propTypes = {
|
|
2053
|
-
value: PropTypes__default.default.any,
|
|
2054
|
-
disabled: PropTypes__default.default.bool
|
|
2055
|
-
};
|
|
2082
|
+
Separator.displayName = 'Separator';
|
|
2056
2083
|
|
|
2057
|
-
Object.defineProperty(exports, "
|
|
2084
|
+
Object.defineProperty(exports, "VALIDATION", {
|
|
2058
2085
|
enumerable: true,
|
|
2059
|
-
get: function () { return
|
|
2086
|
+
get: function () { return reactForms.VALIDATION; }
|
|
2060
2087
|
});
|
|
2061
|
-
exports.AddItem = AddItem;
|
|
2062
|
-
exports.Autocomplete = Autocomplete;
|
|
2063
2088
|
exports.Combobox = Combobox;
|
|
2064
|
-
exports.Dropdown = Dropdown;
|
|
2065
2089
|
exports.Field = Field;
|
|
2066
|
-
exports.HeaderIcon = HeaderIcon;
|
|
2067
|
-
exports.HeaderItem = HeaderItem;
|
|
2068
2090
|
exports.Hint = Hint;
|
|
2069
2091
|
exports.Item = Item;
|
|
2070
|
-
exports.
|
|
2092
|
+
exports.ItemGroup = ItemGroup;
|
|
2071
2093
|
exports.Label = Label;
|
|
2072
|
-
exports.MediaBody = MediaBody;
|
|
2073
|
-
exports.MediaFigure = MediaFigure;
|
|
2074
|
-
exports.MediaItem = MediaItem;
|
|
2075
2094
|
exports.Menu = Menu;
|
|
2076
2095
|
exports.Message = Message;
|
|
2077
|
-
exports.
|
|
2078
|
-
exports.
|
|
2079
|
-
exports.PreviousItem = PreviousItem;
|
|
2080
|
-
exports.Select = Select;
|
|
2096
|
+
exports.OptGroup = OptGroup;
|
|
2097
|
+
exports.Option = Option;
|
|
2081
2098
|
exports.Separator = Separator;
|
|
2082
|
-
exports.
|
|
2099
|
+
exports.Tag = Tag;
|