@splunk/react-ui 4.1.0 → 4.4.1
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/Accordion.js +4 -4
- package/Anchor.js +2 -2
- package/Animation.js +26 -35
- package/AnimationToggle.js +2 -2
- package/Box.js +2 -2
- package/Button.js +22 -22
- package/ButtonGroup.js +2 -2
- package/ButtonSimple.js +12 -6
- package/CHANGELOG.md +69 -2
- package/Calendar.js +23 -23
- package/Card.js +15 -15
- package/CardLayout.js +2 -2
- package/Chip.js +13 -13
- package/Clickable.js +4 -4
- package/CloseButton.js +8 -8
- package/Code.js +1279 -1120
- package/CollapsiblePanel.js +11 -11
- package/Color.js +111 -172
- package/ColumnLayout.js +6 -6
- package/ComboBox.js +63 -30
- package/Concertina.js +2 -2
- package/ControlGroup.js +61 -20
- package/Date.js +66 -29
- package/DefinitionList.js +2 -2
- package/Dropdown.js +6 -6
- package/FetchOptions.js +8 -8
- package/File.js +87 -72
- package/FormRows.js +219 -331
- package/Heading.js +2 -2
- package/Image.js +15 -15
- package/JSONTree.js +63 -20
- package/Layer.js +8 -8
- package/Link.js +13 -13
- package/List.js +2 -2
- package/Markdown.js +19 -19
- package/Menu.js +315 -230
- package/Message.js +19 -19
- package/Modal.js +22 -11
- package/ModalLayer.js +25 -11
- package/Monogram.js +7 -7
- package/Multiselect.js +1931 -1057
- package/Number.js +40 -27
- package/Paginator.js +67 -49
- package/Paragraph.js +2 -2
- package/Popover.js +62 -35
- package/Progress.js +9 -21
- package/RadioBar.js +6 -6
- package/RadioList.js +2 -2
- package/ResultsMenu.js +18 -10
- package/ScreenReaderContent.js +2 -2
- package/Scroll.js +37 -19
- package/ScrollContainerContext.js +2 -2
- package/Select.js +1309 -562
- package/SidePanel.js +22 -17
- package/Slider.js +8 -8
- package/SlidingPanels.js +63 -47
- package/StaticContent.js +2 -2
- package/StepBar.js +8 -8
- package/Switch.js +20 -11
- package/TabBar.js +54 -40
- package/TabLayout.js +4 -4
- package/Table.js +148 -85
- package/Text.js +474 -356
- package/Tooltip.js +6 -6
- package/TransitionOpen.js +26 -24
- package/WaitSpinner.js +4 -4
- package/package.json +8 -7
- package/stubs-splunkui.d.ts +1 -0
- package/types/src/Accordion/Accordion.d.ts +2 -2
- package/types/src/Animation/Animation.d.ts +6 -5
- package/types/src/Button/Button.d.ts +2 -2
- package/types/src/ButtonSimple/ButtonSimple.d.ts +5 -5
- package/types/src/Calendar/DateTable.d.ts +1 -0
- package/types/src/Calendar/MonthHeader.d.ts +2 -2
- package/types/src/CollapsiblePanel/CollapsiblePanel.d.ts +1 -2
- package/types/src/Color/Color.d.ts +5 -4
- package/types/src/Color/Swatch.d.ts +4 -15
- package/types/src/ComboBox/ComboBox.d.ts +2 -2
- package/types/src/ControlGroup/ControlGroup.d.ts +7 -2
- package/types/src/ControlGroup/ControlGroupContext.d.ts +15 -0
- package/types/src/Date/Date.d.ts +7 -5
- package/types/src/Date/Icon.d.ts +1 -0
- package/types/src/Dropdown/Dropdown.d.ts +1 -1
- package/types/src/File/File.d.ts +2 -2
- package/types/src/File/FileContext.d.ts +9 -0
- package/types/src/File/Icon.d.ts +1 -0
- package/types/src/File/IconCloud.d.ts +1 -0
- package/types/src/File/Item.d.ts +5 -10
- package/types/src/File/PaperClip.d.ts +1 -0
- package/types/src/File/Retry.d.ts +1 -0
- package/types/src/File/Trash.d.ts +1 -0
- package/types/src/FormRows/FormRows.d.ts +11 -69
- package/types/src/FormRows/FormRowsContext.d.ts +9 -0
- package/types/src/FormRows/Row.d.ts +7 -20
- package/types/src/JSONTree/JSONTree.d.ts +14 -2
- package/types/src/JSONTree/TreeNode.d.ts +4 -1
- package/types/src/Menu/Divider.d.ts +1 -0
- package/types/src/Menu/Heading.d.ts +3 -1
- package/types/src/Menu/Item.d.ts +22 -6
- package/types/src/Menu/Menu.d.ts +17 -18
- package/types/src/Menu/MenuContext.d.ts +6 -0
- package/types/src/Menu/index.d.ts +1 -0
- package/types/src/Multiselect/Compact.d.ts +7 -26
- package/types/src/Multiselect/Multiselect.d.ts +7 -2
- package/types/src/Multiselect/Normal.d.ts +8 -2
- package/types/src/Multiselect/Option.d.ts +4 -1
- package/types/src/Number/IncrementIcon.d.ts +1 -0
- package/types/src/Number/Number.d.ts +4 -4
- package/types/src/Paginator/PageSeparator.d.ts +3 -0
- package/types/src/Popover/Popover.d.ts +5 -5
- package/types/src/Popover/PopoverContext.d.ts +6 -0
- package/types/src/Popover/index.d.ts +1 -0
- package/types/src/RadioBar/RadioBar.d.ts +5 -5
- package/types/src/RadioList/RadioListContext.d.ts +1 -0
- package/types/src/ResultsMenu/ResultsMenu.d.ts +4 -0
- package/types/src/Scroll/Inner.d.ts +4 -3
- package/types/src/Scroll/Scroll.d.ts +1 -1
- package/types/src/Select/Option.d.ts +2 -5
- package/types/src/Select/OptionBase.d.ts +94 -0
- package/types/src/Select/Select.d.ts +12 -37
- package/types/src/Select/SelectBase.d.ts +221 -0
- package/types/src/SidePanel/SidePanel.d.ts +4 -0
- package/types/src/Slider/Slider.d.ts +4 -4
- package/types/src/SlidingPanels/SlidingPanels.d.ts +0 -1
- package/types/src/Switch/CheckIcon.d.ts +1 -0
- package/types/src/Switch/Switch.d.ts +3 -7
- package/types/src/TabBar/Tab.d.ts +4 -1
- package/types/src/TabLayout/TabLayout.d.ts +2 -2
- package/types/src/Table/DragHandle.d.ts +1 -0
- package/types/src/Table/Head.d.ts +2 -0
- package/types/src/Table/HeadCell.d.ts +2 -2
- package/types/src/Table/HeadDropdownCell.d.ts +1 -1
- package/types/src/Table/HeadExpandRowsIcon.d.ts +1 -0
- package/types/src/Table/HeadInner.d.ts +3 -3
- package/types/src/Table/Table.d.ts +7 -3
- package/types/src/Table/Toggle.d.ts +1 -0
- package/types/src/Text/IconOutlinedHide.d.ts +1 -0
- package/types/src/Text/IconOutlinedView.d.ts +1 -0
- package/types/src/Text/Text.d.ts +28 -12
- package/types/src/Tooltip/InfoIcon.d.ts +1 -0
- package/types/src/Tooltip/Tooltip.d.ts +3 -3
- package/types/src/icons/Alert.d.ts +1 -0
- package/types/src/icons/AlertFilled.d.ts +1 -0
- package/types/src/icons/CaretDown.d.ts +1 -0
- package/types/src/icons/CaretRight.d.ts +1 -0
- package/types/src/icons/Check.d.ts +1 -0
- package/types/src/icons/ChevronDown.d.ts +1 -0
- package/types/src/icons/ChevronLeft.d.ts +1 -0
- package/types/src/icons/ChevronRight.d.ts +1 -0
- package/types/src/icons/CrossMark.d.ts +1 -0
- package/types/src/icons/External.d.ts +1 -0
- package/types/src/icons/InfoFilled.d.ts +1 -0
- package/types/src/icons/More.d.ts +1 -0
- package/types/src/icons/MoreVertical.d.ts +1 -0
- package/types/src/icons/Plus.d.ts +1 -0
- package/types/src/icons/SVG.d.ts +1 -0
- package/types/src/icons/Search.d.ts +1 -0
- package/types/src/icons/SortedDown.d.ts +1 -0
- package/types/src/icons/SortedUp.d.ts +1 -0
- package/types/src/icons/Success.d.ts +1 -0
- package/types/src/icons/SuccessFilled.d.ts +1 -0
- package/types/src/icons/WarningFilled.d.ts +1 -0
- package/types/src/utils/types.d.ts +1 -0
package/Select.js
CHANGED
|
@@ -82,7 +82,7 @@ module.exports =
|
|
|
82
82
|
/******/
|
|
83
83
|
/******/
|
|
84
84
|
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
85
|
+
/******/ return __webpack_require__(__webpack_require__.s = 153);
|
|
86
86
|
/******/ })
|
|
87
87
|
/************************************************************************/
|
|
88
88
|
/******/ ({
|
|
@@ -108,7 +108,14 @@ module.exports = require("@splunk/ui-utils/id");
|
|
|
108
108
|
|
|
109
109
|
/***/ }),
|
|
110
110
|
|
|
111
|
-
/***/
|
|
111
|
+
/***/ 13:
|
|
112
|
+
/***/ (function(module, exports) {
|
|
113
|
+
|
|
114
|
+
module.exports = require("@splunk/react-ui/Menu");
|
|
115
|
+
|
|
116
|
+
/***/ }),
|
|
117
|
+
|
|
118
|
+
/***/ 153:
|
|
112
119
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
113
120
|
|
|
114
121
|
"use strict";
|
|
@@ -117,8 +124,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
117
124
|
|
|
118
125
|
// EXPORTS
|
|
119
126
|
__webpack_require__.d(__webpack_exports__, "default", function() { return /* reexport */ src_Select_Select; });
|
|
120
|
-
__webpack_require__.d(__webpack_exports__, "Divider", function() { return /* reexport */
|
|
121
|
-
__webpack_require__.d(__webpack_exports__, "Heading", function() { return /* reexport */
|
|
127
|
+
__webpack_require__.d(__webpack_exports__, "Divider", function() { return /* reexport */ SelectBase["a" /* Divider */]; });
|
|
128
|
+
__webpack_require__.d(__webpack_exports__, "Heading", function() { return /* reexport */ SelectBase["b" /* Heading */]; });
|
|
122
129
|
__webpack_require__.d(__webpack_exports__, "Option", function() { return /* reexport */ Select_Option; });
|
|
123
130
|
|
|
124
131
|
// EXTERNAL MODULE: external "react"
|
|
@@ -132,39 +139,14 @@ var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_pr
|
|
|
132
139
|
// EXTERNAL MODULE: external "lodash"
|
|
133
140
|
var external_lodash_ = __webpack_require__(4);
|
|
134
141
|
|
|
135
|
-
// EXTERNAL MODULE: external "@splunk/ui-utils/filter"
|
|
136
|
-
var filter_ = __webpack_require__(22);
|
|
137
|
-
|
|
138
142
|
// EXTERNAL MODULE: external "@splunk/ui-utils/i18n"
|
|
139
143
|
var i18n_ = __webpack_require__(5);
|
|
140
144
|
|
|
141
|
-
// EXTERNAL MODULE:
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
// EXTERNAL MODULE: external "@splunk/ui-utils/id"
|
|
145
|
-
var id_ = __webpack_require__(10);
|
|
146
|
-
|
|
147
|
-
// EXTERNAL MODULE: external "@splunk/react-ui/Dropdown"
|
|
148
|
-
var Dropdown_ = __webpack_require__(16);
|
|
149
|
-
var Dropdown_default = /*#__PURE__*/__webpack_require__.n(Dropdown_);
|
|
150
|
-
|
|
151
|
-
// EXTERNAL MODULE: external "@splunk/react-ui/Link"
|
|
152
|
-
var Link_ = __webpack_require__(32);
|
|
153
|
-
var Link_default = /*#__PURE__*/__webpack_require__.n(Link_);
|
|
154
|
-
|
|
155
|
-
// EXTERNAL MODULE: external "@splunk/react-ui/Menu"
|
|
156
|
-
var Menu_ = __webpack_require__(13);
|
|
157
|
-
|
|
158
|
-
// EXTERNAL MODULE: external "@splunk/react-ui/ResultsMenu"
|
|
159
|
-
var ResultsMenu_ = __webpack_require__(35);
|
|
160
|
-
var ResultsMenu_default = /*#__PURE__*/__webpack_require__.n(ResultsMenu_);
|
|
161
|
-
|
|
162
|
-
// EXTERNAL MODULE: external "@splunk/react-ui/Text"
|
|
163
|
-
var Text_ = __webpack_require__(24);
|
|
164
|
-
var Text_default = /*#__PURE__*/__webpack_require__.n(Text_);
|
|
145
|
+
// EXTERNAL MODULE: ./src/Select/SelectBase.tsx + 1 modules
|
|
146
|
+
var SelectBase = __webpack_require__(42);
|
|
165
147
|
|
|
166
|
-
// EXTERNAL MODULE: ./src/
|
|
167
|
-
var
|
|
148
|
+
// EXTERNAL MODULE: ./src/Select/OptionBase.tsx
|
|
149
|
+
var OptionBase = __webpack_require__(28);
|
|
168
150
|
|
|
169
151
|
// CONCATENATED MODULE: ./src/Select/Option.tsx
|
|
170
152
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
@@ -196,7 +178,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
196
178
|
|
|
197
179
|
|
|
198
180
|
|
|
199
|
-
|
|
200
181
|
var propTypes = {
|
|
201
182
|
/** @private */
|
|
202
183
|
active: external_prop_types_default.a.bool,
|
|
@@ -252,19 +233,6 @@ var Option_Option = /*#__PURE__*/function (_PureComponent) {
|
|
|
252
233
|
|
|
253
234
|
_defineProperty(_assertThisInitialized(_this), "c", null);
|
|
254
235
|
|
|
255
|
-
_defineProperty(_assertThisInitialized(_this), "handleClick", function (e) {
|
|
256
|
-
var _this$props = _this.props,
|
|
257
|
-
onClick = _this$props.onClick,
|
|
258
|
-
value = _this$props.value,
|
|
259
|
-
disabled = _this$props.disabled;
|
|
260
|
-
|
|
261
|
-
if (!disabled) {
|
|
262
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(e, {
|
|
263
|
-
value: value
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
|
|
268
236
|
_defineProperty(_assertThisInitialized(_this), "handleMount", function (c) {
|
|
269
237
|
_this.c = c;
|
|
270
238
|
});
|
|
@@ -293,16 +261,9 @@ var Option_Option = /*#__PURE__*/function (_PureComponent) {
|
|
|
293
261
|
}, {
|
|
294
262
|
key: "render",
|
|
295
263
|
value: function render() {
|
|
296
|
-
return /*#__PURE__*/external_react_default.a.createElement(
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
ref: this.handleMount,
|
|
300
|
-
selectable: true,
|
|
301
|
-
value: this.props.value.toString()
|
|
302
|
-
}, Object(external_lodash_["omit"])(this.props, ['label', 'value']), {
|
|
303
|
-
"aria-selected": this.props.selected,
|
|
304
|
-
onClick: this.handleClick,
|
|
305
|
-
role: "option"
|
|
264
|
+
return /*#__PURE__*/external_react_default.a.createElement(OptionBase["a" /* default */], _extends({}, this.props, {
|
|
265
|
+
multiple: false,
|
|
266
|
+
ref: this.handleMount
|
|
306
267
|
}), this.props.children || this.props.label);
|
|
307
268
|
}
|
|
308
269
|
}]);
|
|
@@ -315,61 +276,14 @@ _defineProperty(Option_Option, "propTypes", propTypes);
|
|
|
315
276
|
_defineProperty(Option_Option, "defaultProps", defaultProps);
|
|
316
277
|
|
|
317
278
|
/* harmony default export */ var Select_Option = (Option_Option);
|
|
318
|
-
// EXTERNAL MODULE: external "styled-components"
|
|
319
|
-
var external_styled_components_ = __webpack_require__(3);
|
|
320
|
-
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
321
|
-
|
|
322
|
-
// EXTERNAL MODULE: external "@splunk/react-ui/Button"
|
|
323
|
-
var Button_ = __webpack_require__(17);
|
|
324
|
-
var Button_default = /*#__PURE__*/__webpack_require__.n(Button_);
|
|
325
|
-
|
|
326
|
-
// EXTERNAL MODULE: external "@splunk/themes"
|
|
327
|
-
var themes_ = __webpack_require__(0);
|
|
328
|
-
|
|
329
|
-
// CONCATENATED MODULE: ./src/Select/SelectStyles.ts
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
var StyledButtonToggle = external_styled_components_default()(Button_default.a).withConfig({
|
|
334
|
-
displayName: "SelectStyles__StyledButtonToggle",
|
|
335
|
-
componentId: "sc-1cn19n4-0"
|
|
336
|
-
})(["flex-grow:0;"]);
|
|
337
|
-
var StyledFilter = external_styled_components_default.a.div.withConfig({
|
|
338
|
-
displayName: "SelectStyles__StyledFilter",
|
|
339
|
-
componentId: "sc-1cn19n4-1"
|
|
340
|
-
})(["padding:8px;min-width:160px;", ""], Object(themes_["pick"])({
|
|
341
|
-
enterprise: Object(external_styled_components_["css"])(["&:first-child{border-bottom:", ";}&:last-child{border-top:", ";}"], themes_["variables"].border, themes_["variables"].border),
|
|
342
|
-
prisma: Object(external_styled_components_["css"])(["&:first-child{border-bottom:1px solid ", ";}&:last-child{border-top:1px solid ", ";}"], themes_["variables"].neutral200, themes_["variables"].neutral200)
|
|
343
|
-
}));
|
|
344
|
-
var StyledLinkIcon = external_styled_components_default.a.span.withConfig({
|
|
345
|
-
displayName: "SelectStyles__StyledLinkIcon",
|
|
346
|
-
componentId: "sc-1cn19n4-2"
|
|
347
|
-
})(["padding-right:2px;"]);
|
|
348
|
-
var StyledLinkCaret = external_styled_components_default.a.span.withConfig({
|
|
349
|
-
displayName: "SelectStyles__StyledLinkCaret",
|
|
350
|
-
componentId: "sc-1cn19n4-3"
|
|
351
|
-
})(["padding-left:2px;"]);
|
|
352
|
-
|
|
353
279
|
// CONCATENATED MODULE: ./src/Select/Select.tsx
|
|
354
280
|
function Select_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { Select_typeof = function _typeof(obj) { return typeof obj; }; } else { Select_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return Select_typeof(obj); }
|
|
355
281
|
|
|
356
|
-
function
|
|
357
|
-
|
|
358
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Select_defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
359
|
-
|
|
360
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
361
|
-
|
|
362
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
363
|
-
|
|
364
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
365
|
-
|
|
366
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
367
|
-
|
|
368
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
282
|
+
function Select_extends() { Select_extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return Select_extends.apply(this, arguments); }
|
|
369
283
|
|
|
370
|
-
function
|
|
284
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
371
285
|
|
|
372
|
-
function
|
|
286
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
373
287
|
|
|
374
288
|
function Select_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
375
289
|
|
|
@@ -393,20 +307,14 @@ function Select_getPrototypeOf(o) { Select_getPrototypeOf = Object.setPrototypeO
|
|
|
393
307
|
|
|
394
308
|
function Select_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
395
309
|
|
|
310
|
+
/* eslint-disable max-classes-per-file */
|
|
396
311
|
|
|
397
312
|
|
|
398
313
|
|
|
399
314
|
|
|
400
315
|
|
|
401
316
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
317
|
+
/** @public */
|
|
410
318
|
|
|
411
319
|
var Select_propTypes = {
|
|
412
320
|
animateLoading: external_prop_types_default.a.bool,
|
|
@@ -463,518 +371,306 @@ var Select_Select = /*#__PURE__*/function (_Component) {
|
|
|
463
371
|
|
|
464
372
|
var _super = Select_createSuper(Select);
|
|
465
373
|
|
|
466
|
-
|
|
467
|
-
key: "validateAppearance",
|
|
468
|
-
// @docs-props-type SelectPropsBase
|
|
469
|
-
value: function validateAppearance(props) {
|
|
470
|
-
if (false) {}
|
|
471
|
-
}
|
|
472
|
-
}]);
|
|
473
|
-
|
|
374
|
+
// @docs-props-type SelectPropsBase
|
|
474
375
|
function Select(props) {
|
|
475
376
|
var _this;
|
|
476
377
|
|
|
477
378
|
Select_classCallCheck(this, Select);
|
|
478
379
|
|
|
479
380
|
_this = _super.call(this, props);
|
|
381
|
+
var state = {}; // wrap defaultValue in an array once to avoid failing <SelectBase>'s defaultValues comparison check
|
|
382
|
+
// using "has" to make sure that pre-4.3 behavior is preserved if a user explicitly passes "null" or "undefined"
|
|
383
|
+
|
|
384
|
+
if (Object(external_lodash_["has"])(props, 'defaultValue')) {
|
|
385
|
+
if (props.defaultValue != null) {
|
|
386
|
+
state.defaultValues = [props.defaultValue];
|
|
387
|
+
} else {
|
|
388
|
+
state.defaultValues = [];
|
|
389
|
+
}
|
|
390
|
+
}
|
|
480
391
|
|
|
481
|
-
|
|
392
|
+
_this.state = state;
|
|
393
|
+
return _this;
|
|
394
|
+
}
|
|
482
395
|
|
|
483
|
-
|
|
396
|
+
Select_createClass(Select, [{
|
|
397
|
+
key: "componentDidUpdate",
|
|
398
|
+
value: function componentDidUpdate(prevProps) {
|
|
399
|
+
if (false) {}
|
|
400
|
+
}
|
|
401
|
+
}, {
|
|
402
|
+
key: "render",
|
|
403
|
+
value: function render() {
|
|
404
|
+
var _this$props = this.props,
|
|
405
|
+
defaultValue = _this$props.defaultValue,
|
|
406
|
+
_onChange = _this$props.onChange,
|
|
407
|
+
value = _this$props.value,
|
|
408
|
+
otherProps = _objectWithoutProperties(_this$props, ["defaultValue", "onChange", "value"]);
|
|
409
|
+
|
|
410
|
+
var convertedProps = {
|
|
411
|
+
onChange: function onChange(e, _ref) {
|
|
412
|
+
var name = _ref.name,
|
|
413
|
+
values = _ref.values;
|
|
414
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(e, {
|
|
415
|
+
name: name,
|
|
416
|
+
value: values[0]
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}; // using "has" as opposed to a null check to match SelectBase
|
|
484
420
|
|
|
485
|
-
|
|
421
|
+
if (Object(external_lodash_["has"])(this.props, 'value')) {
|
|
422
|
+
if (value != null) {
|
|
423
|
+
convertedProps.values = [value];
|
|
424
|
+
} else {
|
|
425
|
+
convertedProps.values = [];
|
|
426
|
+
}
|
|
427
|
+
} else if (this.state.defaultValues != null) {
|
|
428
|
+
// using defaultValues from state in order to avoid wrapping defaultValue here
|
|
429
|
+
convertedProps.defaultValues = this.state.defaultValues;
|
|
430
|
+
}
|
|
486
431
|
|
|
487
|
-
|
|
432
|
+
return /*#__PURE__*/external_react_default.a.createElement(SelectBase["c" /* default */], Select_extends({}, otherProps, convertedProps, {
|
|
433
|
+
multiple: false
|
|
434
|
+
}));
|
|
435
|
+
}
|
|
436
|
+
}]);
|
|
488
437
|
|
|
489
|
-
|
|
438
|
+
return Select;
|
|
439
|
+
}(external_react_["Component"]);
|
|
490
440
|
|
|
491
|
-
|
|
441
|
+
Select_defineProperty(Select_Select, "propTypes", Select_propTypes);
|
|
492
442
|
|
|
493
|
-
|
|
443
|
+
Select_defineProperty(Select_Select, "defaultProps", Select_defaultProps);
|
|
494
444
|
|
|
495
|
-
|
|
445
|
+
Select_defineProperty(Select_Select, "Option", Select_Option);
|
|
496
446
|
|
|
497
|
-
|
|
498
|
-
if (comp) {
|
|
499
|
-
comp.scrollIntoViewIfNeeded();
|
|
500
|
-
}
|
|
501
|
-
});
|
|
447
|
+
Select_defineProperty(Select_Select, "Heading", SelectBase["b" /* Heading */]);
|
|
502
448
|
|
|
503
|
-
|
|
504
|
-
if (Object(keyboard_["keycode"])(e.nativeEvent) === 'tab') {
|
|
505
|
-
e.preventDefault();
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
449
|
+
Select_defineProperty(Select_Select, "Divider", SelectBase["a" /* Divider */]);
|
|
508
450
|
|
|
509
|
-
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
451
|
+
/* harmony default export */ var src_Select_Select = (Select_Select);
|
|
512
452
|
|
|
513
|
-
|
|
514
|
-
e.preventDefault();
|
|
453
|
+
// CONCATENATED MODULE: ./src/Select/index.ts
|
|
515
454
|
|
|
516
|
-
_this.setState(function (state) {
|
|
517
|
-
var _state$activeIndex;
|
|
518
455
|
|
|
519
|
-
return {
|
|
520
|
-
activeIndex: Math.min(((_state$activeIndex = state.activeIndex) !== null && _state$activeIndex !== void 0 ? _state$activeIndex : 0) + 1, _this.availableOptionCount - 1)
|
|
521
|
-
};
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
456
|
|
|
525
|
-
|
|
526
|
-
e.preventDefault();
|
|
457
|
+
/***/ }),
|
|
527
458
|
|
|
528
|
-
|
|
529
|
-
|
|
459
|
+
/***/ 16:
|
|
460
|
+
/***/ (function(module, exports) {
|
|
530
461
|
|
|
531
|
-
|
|
532
|
-
activeIndex: Math.max(((_state$activeIndex2 = state.activeIndex) !== null && _state$activeIndex2 !== void 0 ? _state$activeIndex2 : 0) - 1, 0)
|
|
533
|
-
};
|
|
534
|
-
});
|
|
535
|
-
}
|
|
462
|
+
module.exports = require("@splunk/react-ui/Button");
|
|
536
463
|
|
|
537
|
-
|
|
538
|
-
e.preventDefault();
|
|
464
|
+
/***/ }),
|
|
539
465
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
});
|
|
466
|
+
/***/ 19:
|
|
467
|
+
/***/ (function(module, exports) {
|
|
545
468
|
|
|
546
|
-
|
|
547
|
-
var _this$props$onFilterC, _this$props;
|
|
469
|
+
module.exports = require("@splunk/react-ui/Dropdown");
|
|
548
470
|
|
|
549
|
-
|
|
471
|
+
/***/ }),
|
|
550
472
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
filterKeyword: data.value,
|
|
554
|
-
open: true
|
|
555
|
-
});
|
|
473
|
+
/***/ 2:
|
|
474
|
+
/***/ (function(module, exports) {
|
|
556
475
|
|
|
557
|
-
|
|
558
|
-
keyword: data.value
|
|
559
|
-
});
|
|
560
|
-
});
|
|
476
|
+
module.exports = require("react");
|
|
561
477
|
|
|
562
|
-
|
|
563
|
-
if (Object(keyboard_["keycode"])(e.nativeEvent) === 'tab') {
|
|
564
|
-
e.preventDefault();
|
|
565
|
-
}
|
|
566
|
-
});
|
|
478
|
+
/***/ }),
|
|
567
479
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
});
|
|
480
|
+
/***/ 23:
|
|
481
|
+
/***/ (function(module, exports) {
|
|
571
482
|
|
|
572
|
-
|
|
573
|
-
var value = _ref.value;
|
|
483
|
+
module.exports = require("@splunk/ui-utils/filter");
|
|
574
484
|
|
|
575
|
-
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
485
|
+
/***/ }),
|
|
578
486
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
});
|
|
582
|
-
});
|
|
487
|
+
/***/ 26:
|
|
488
|
+
/***/ (function(module, exports) {
|
|
583
489
|
|
|
584
|
-
|
|
585
|
-
_this.setState({
|
|
586
|
-
open: true
|
|
587
|
-
}, function () {
|
|
588
|
-
var _this$props$onOpen, _this$props2;
|
|
490
|
+
module.exports = require("@splunk/react-ui/Text");
|
|
589
491
|
|
|
590
|
-
|
|
492
|
+
/***/ }),
|
|
591
493
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
} else if (_this.props.filter) {
|
|
595
|
-
_this.setState({
|
|
596
|
-
activeIndex: _this.selectedOptionIndex
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
});
|
|
494
|
+
/***/ 28:
|
|
495
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
601
496
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
497
|
+
"use strict";
|
|
498
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
|
|
499
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
500
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
|
|
501
|
+
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_1__);
|
|
502
|
+
/* harmony import */ var _splunk_react_ui_Menu__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
|
|
503
|
+
/* harmony import */ var _splunk_react_ui_Menu__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_splunk_react_ui_Menu__WEBPACK_IMPORTED_MODULE_2__);
|
|
504
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
608
505
|
|
|
609
|
-
|
|
610
|
-
});
|
|
611
|
-
});
|
|
506
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
612
507
|
|
|
613
|
-
|
|
614
|
-
if (_this.state.open && !_this.props.isLoadingOptions) {
|
|
615
|
-
var _this$props$onScrollB, _this$props4;
|
|
508
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
616
509
|
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
});
|
|
510
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
620
511
|
|
|
621
|
-
|
|
622
|
-
_this.availableOptionCount = 0;
|
|
623
|
-
_this.state = {
|
|
624
|
-
activeIndex: undefined,
|
|
625
|
-
filterKeyword: _this.props.filter ? '' : undefined,
|
|
626
|
-
open: false,
|
|
627
|
-
value: Object(external_lodash_["has"])(props, 'defaultValue') ? props.defaultValue : ''
|
|
628
|
-
};
|
|
512
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
629
513
|
|
|
630
|
-
|
|
514
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
631
515
|
|
|
632
|
-
|
|
516
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
633
517
|
|
|
634
|
-
|
|
635
|
-
_this.menuId = Object(id_["createDOMID"])('menu');
|
|
636
|
-
_this.activeItemId = Object(id_["createDOMID"])('active-item');
|
|
637
|
-
return _this;
|
|
638
|
-
}
|
|
518
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
639
519
|
|
|
640
|
-
|
|
641
|
-
key: "componentDidUpdate",
|
|
642
|
-
value: function componentDidUpdate(prevProps) {
|
|
643
|
-
if (false) {}
|
|
520
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
644
521
|
|
|
645
|
-
|
|
522
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
646
523
|
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
}, {
|
|
650
|
-
key: "getCurrentValue",
|
|
651
|
-
value: function getCurrentValue() {
|
|
652
|
-
return this.isControlled() ? this.props.value : this.state.value;
|
|
653
|
-
}
|
|
654
|
-
}, {
|
|
655
|
-
key: "selectValue",
|
|
656
|
-
value: function selectValue(e, _ref2) {
|
|
657
|
-
var value = _ref2.value;
|
|
658
|
-
var name = this.props.name;
|
|
524
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
659
525
|
|
|
660
|
-
|
|
661
|
-
this.setState({
|
|
662
|
-
value: value
|
|
663
|
-
});
|
|
664
|
-
}
|
|
526
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
665
527
|
|
|
666
|
-
|
|
667
|
-
this.focus();
|
|
528
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
668
529
|
|
|
669
|
-
|
|
670
|
-
var _this$props$onChange, _this$props5;
|
|
530
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
671
531
|
|
|
672
|
-
|
|
673
|
-
value: value,
|
|
674
|
-
name: name
|
|
675
|
-
});
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}, {
|
|
679
|
-
key: "isControlled",
|
|
680
|
-
value: function isControlled() {
|
|
681
|
-
return this.controlledExternally;
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Place focus on the toggle.
|
|
685
|
-
*/
|
|
532
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
686
533
|
|
|
687
|
-
}, {
|
|
688
|
-
key: "focus",
|
|
689
|
-
value: function focus() {
|
|
690
|
-
var _this$dropdown;
|
|
691
|
-
|
|
692
|
-
(_this$dropdown = this.dropdown) === null || _this$dropdown === void 0 ? void 0 : _this$dropdown.focus();
|
|
693
|
-
} // Setup Filter
|
|
694
|
-
|
|
695
|
-
}, {
|
|
696
|
-
key: "renderFilter",
|
|
697
|
-
value: function renderFilter() {
|
|
698
|
-
/* eslint-disable jsx-a11y/tabindex-no-positive */
|
|
699
|
-
return this.props.filter ? /*#__PURE__*/external_react_default.a.createElement(StyledFilter, {
|
|
700
|
-
key: "filter"
|
|
701
|
-
}, /*#__PURE__*/external_react_default.a.createElement(Text_default.a, {
|
|
702
|
-
value: this.state.filterKeyword,
|
|
703
|
-
appearance: "search",
|
|
704
|
-
autoCapitalize: "off",
|
|
705
|
-
autoComplete: "off",
|
|
706
|
-
autoCorrect: "off",
|
|
707
|
-
spellCheck: false,
|
|
708
|
-
onChange: this.handleTextChange,
|
|
709
|
-
onKeyDown: this.handleTextKeyDown,
|
|
710
|
-
onKeyUp: this.handleTextKeyUp,
|
|
711
|
-
placeholder: Object(i18n_["_"])('filter'),
|
|
712
|
-
tabIndex: 1,
|
|
713
|
-
role: "combobox",
|
|
714
|
-
"aria-activedescendant": this.activeItemId,
|
|
715
|
-
"aria-expanded": "true",
|
|
716
|
-
"aria-controls": this.menuId,
|
|
717
|
-
"aria-label": Object(i18n_["_"])('Filter'),
|
|
718
|
-
inputId: this.props.inputId
|
|
719
|
-
})) : null;
|
|
720
|
-
/* eslint-enable jsx-a11y/tabindex-no-positive */
|
|
721
|
-
}
|
|
722
|
-
}, {
|
|
723
|
-
key: "render",
|
|
724
|
-
value: function render() {
|
|
725
|
-
var _this2 = this;
|
|
726
|
-
|
|
727
|
-
var _this$props6 = this.props,
|
|
728
|
-
appearance = _this$props6.appearance,
|
|
729
|
-
children = _this$props6.children,
|
|
730
|
-
defaultPlacement = _this$props6.defaultPlacement,
|
|
731
|
-
describedBy = _this$props6.describedBy,
|
|
732
|
-
disabled = _this$props6.disabled,
|
|
733
|
-
elementRef = _this$props6.elementRef,
|
|
734
|
-
error = _this$props6.error,
|
|
735
|
-
filter = _this$props6.filter,
|
|
736
|
-
inputId = _this$props6.inputId,
|
|
737
|
-
isLoadingOptions = _this$props6.isLoadingOptions,
|
|
738
|
-
labelledBy = _this$props6.labelledBy,
|
|
739
|
-
labelText = _this$props6.labelText,
|
|
740
|
-
menuStyle = _this$props6.menuStyle,
|
|
741
|
-
onScrollBottom = _this$props6.onScrollBottom,
|
|
742
|
-
placeholder = _this$props6.placeholder;
|
|
743
|
-
var _this$state = this.state,
|
|
744
|
-
filterKeyword = _this$state.filterKeyword,
|
|
745
|
-
open = _this$state.open;
|
|
746
|
-
var label;
|
|
747
|
-
var icon;
|
|
748
|
-
var keywords = Object(filter_["stringToKeywords"])(filterKeyword);
|
|
749
|
-
|
|
750
|
-
function isOption(child) {
|
|
751
|
-
return Object(external_lodash_["has"])(child, ['props', 'value']);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
var isAnyValueSelected = false;
|
|
755
|
-
var filteredChildren = external_react_["Children"].toArray(children).filter(external_react_["isValidElement"]);
|
|
756
|
-
var childrenCloned = filteredChildren.map(function (item) {
|
|
757
|
-
if (!isOption(item)) {
|
|
758
|
-
// ignore Headings and Dividers
|
|
759
|
-
return item;
|
|
760
|
-
}
|
|
761
534
|
|
|
762
|
-
var selected = item.props.value === _this2.getCurrentValue();
|
|
763
535
|
|
|
764
|
-
var stringLabel = Object(external_lodash_["has"])(item.props, 'label') ? item.props.label : item.props.value; // If selected, set up the label and icon for the toggle button.
|
|
765
536
|
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
537
|
+
var propTypes = {
|
|
538
|
+
/** @private */
|
|
539
|
+
active: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,
|
|
540
|
+
children: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.node,
|
|
541
|
+
description: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string,
|
|
542
|
+
descriptionPosition: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOf(['right', 'bottom']),
|
|
543
|
+
disabled: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,
|
|
544
|
+
hidden: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,
|
|
545
|
+
icon: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.node,
|
|
546
|
+
label: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string.isRequired,
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* @private Passed down from <BaseSelect>
|
|
550
|
+
*/
|
|
551
|
+
multiple: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,
|
|
552
|
+
matchRanges: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.arrayOf(prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.shape({
|
|
553
|
+
start: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.number.isRequired,
|
|
554
|
+
end: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.number.isRequired
|
|
555
|
+
})),
|
|
783
556
|
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
ref: selected ? _this2.handleSelectedItemMount : undefined
|
|
787
|
-
});
|
|
788
|
-
}).filter(function (item) {
|
|
789
|
-
if (item !== null && isOption(item) && filter === true) {
|
|
790
|
-
return Object(filter_["testPhrase"])(item.props.label, keywords);
|
|
791
|
-
}
|
|
557
|
+
/** @private */
|
|
558
|
+
onClick: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.func,
|
|
792
559
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
560
|
+
/** @private */
|
|
561
|
+
selected: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,
|
|
562
|
+
truncate: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool,
|
|
563
|
+
value: prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.oneOfType([prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.string, prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.number, prop_types__WEBPACK_IMPORTED_MODULE_1___default.a.bool]).isRequired
|
|
564
|
+
};
|
|
565
|
+
var defaultProps = {
|
|
566
|
+
descriptionPosition: 'bottom',
|
|
567
|
+
disabled: false,
|
|
568
|
+
multiple: false,
|
|
569
|
+
selected: false,
|
|
570
|
+
truncate: false
|
|
571
|
+
};
|
|
797
572
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
573
|
+
/**
|
|
574
|
+
* An option within a `Multiselect`. This inherits from
|
|
575
|
+
* [PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)
|
|
576
|
+
* so any elements passed to it must also be pure.
|
|
577
|
+
*/
|
|
578
|
+
var Option = /*#__PURE__*/function (_PureComponent) {
|
|
579
|
+
_inherits(Option, _PureComponent);
|
|
801
580
|
|
|
802
|
-
|
|
803
|
-
props.matchRanges = Object(filter_["keywordLocations"])(item.props.label, keywords) || undefined;
|
|
804
|
-
}
|
|
581
|
+
var _super = _createSuper(Option);
|
|
805
582
|
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
/* Highlight Active Option
|
|
809
|
-
* The active option is shown as highlighted when focused in the filter.
|
|
810
|
-
* Pressing enter selects the active option, just as if the user clicked it.
|
|
811
|
-
* Up and down arrows shifts the active option to the previous or next.
|
|
812
|
-
*/
|
|
813
|
-
// availableOptionCount defines the max value for this.state.activeIndex.
|
|
583
|
+
function Option() {
|
|
584
|
+
var _this;
|
|
814
585
|
|
|
815
|
-
|
|
586
|
+
_classCallCheck(this, Option);
|
|
816
587
|
|
|
817
|
-
|
|
588
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
589
|
+
args[_key] = arguments[_key];
|
|
590
|
+
}
|
|
818
591
|
|
|
819
|
-
|
|
592
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
820
593
|
|
|
821
|
-
|
|
822
|
-
if (!isOption(item)) {
|
|
823
|
-
// ignore Headings and Dividers
|
|
824
|
-
return item;
|
|
825
|
-
}
|
|
594
|
+
_defineProperty(_assertThisInitialized(_this), "c", null);
|
|
826
595
|
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
596
|
+
_defineProperty(_assertThisInitialized(_this), "handleClick", function (e) {
|
|
597
|
+
var _this$props = _this.props,
|
|
598
|
+
onClick = _this$props.onClick,
|
|
599
|
+
value = _this$props.value,
|
|
600
|
+
disabled = _this$props.disabled;
|
|
830
601
|
|
|
831
|
-
|
|
832
|
-
|
|
602
|
+
if (!disabled) {
|
|
603
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e, {
|
|
604
|
+
value: value
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
});
|
|
833
608
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
609
|
+
_defineProperty(_assertThisInitialized(_this), "handleMount", function (c) {
|
|
610
|
+
_this.c = c;
|
|
611
|
+
});
|
|
837
612
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
}
|
|
613
|
+
return _this;
|
|
614
|
+
}
|
|
841
615
|
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
});
|
|
847
|
-
};
|
|
616
|
+
_createClass(Option, [{
|
|
617
|
+
key: "scrollIntoViewIfNeeded",
|
|
618
|
+
value: function scrollIntoViewIfNeeded() {
|
|
619
|
+
var _this$c;
|
|
848
620
|
|
|
849
|
-
|
|
850
|
-
|
|
621
|
+
(_this$c = this.c) === null || _this$c === void 0 ? void 0 : _this$c.scrollIntoViewIfNeeded();
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Place focus on the button.
|
|
625
|
+
*/
|
|
851
626
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
"data-select-appearance": "link",
|
|
857
|
-
"data-test-value": this.getCurrentValue(),
|
|
858
|
-
"data-test": "select",
|
|
859
|
-
disabled: disabled,
|
|
860
|
-
elementRef: elementRef
|
|
861
|
-
}, Object(external_lodash_["omit"])(this.props, Object(external_lodash_["keys"])(Select.propTypes))), !!icon && /*#__PURE__*/external_react_default.a.createElement(StyledLinkIcon, null, icon), label || placeholder, /*#__PURE__*/external_react_default.a.createElement(StyledLinkCaret, null, /*#__PURE__*/external_react_default.a.createElement(CaretDown["a" /* default */], {
|
|
862
|
-
enterpriseSize: 0.5,
|
|
863
|
-
prismaSize: "small"
|
|
864
|
-
}))) : /*#__PURE__*/external_react_default.a.createElement(StyledButtonToggle, Select_extends({
|
|
865
|
-
appearance: this.props.appearance // handled above
|
|
866
|
-
,
|
|
867
|
-
"aria-describedby": describedBy,
|
|
868
|
-
"aria-label": ariaLabel,
|
|
869
|
-
"aria-labelledby": labelText ? undefined : labelledBy,
|
|
870
|
-
"data-select-appearance": this.props.appearance,
|
|
871
|
-
"data-test-value": this.getCurrentValue(),
|
|
872
|
-
"data-test": "select",
|
|
873
|
-
error: error,
|
|
874
|
-
icon: icon,
|
|
875
|
-
isMenu: true,
|
|
876
|
-
label: label || placeholder // @ts-expect-error - accept inconsistency with Button
|
|
877
|
-
,
|
|
878
|
-
onClick: this.props.onClick
|
|
879
|
-
}, Object(external_lodash_["omit"])(this.props, [].concat(_toConsumableArray(Object(external_lodash_["keys"])(Select.propTypes)), ['onClick'])), Object(external_lodash_["pick"])(this.props, 'append', 'disabled', 'elementRef', 'inline', 'prepend')));
|
|
880
|
-
|
|
881
|
-
var createMenu = function createMenu(_ref3) {
|
|
882
|
-
var anchorWidth = _ref3.anchorWidth,
|
|
883
|
-
maxHeight = _ref3.maxHeight,
|
|
884
|
-
placement = _ref3.placement;
|
|
885
|
-
return /*#__PURE__*/external_react_default.a.createElement(ResultsMenu_default.a, Select_extends({
|
|
886
|
-
childrenStart: _this2.renderFilter(),
|
|
887
|
-
maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : undefined,
|
|
888
|
-
onScrollBottom: onScrollBottom ? _this2.handleScrollBottom : undefined,
|
|
889
|
-
placement: placement !== null && placement !== void 0 ? placement : undefined,
|
|
890
|
-
isLoading: isLoadingOptions,
|
|
891
|
-
id: _this2.menuId
|
|
892
|
-
}, Object(external_lodash_["pick"])(_this2.props, 'noOptionsMessage', 'footerMessage', 'animateLoading', 'loadingMessage'), {
|
|
893
|
-
style: _objectSpread({
|
|
894
|
-
minWidth: anchorWidth !== null && anchorWidth !== void 0 ? anchorWidth : undefined,
|
|
895
|
-
maxWidth: Math.max(anchorWidth !== null && anchorWidth !== void 0 ? anchorWidth : 0, 300)
|
|
896
|
-
}, menuStyle)
|
|
897
|
-
}), finalChildren);
|
|
898
|
-
};
|
|
627
|
+
}, {
|
|
628
|
+
key: "focus",
|
|
629
|
+
value: function focus() {
|
|
630
|
+
var _this$c2;
|
|
899
631
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
632
|
+
(_this$c2 = this.c) === null || _this$c2 === void 0 ? void 0 : _this$c2.focus();
|
|
633
|
+
}
|
|
634
|
+
}, {
|
|
635
|
+
key: "render",
|
|
636
|
+
value: function render() {
|
|
637
|
+
var _this$props2 = this.props,
|
|
638
|
+
value = _this$props2.value,
|
|
639
|
+
children = _this$props2.children,
|
|
640
|
+
label = _this$props2.label,
|
|
641
|
+
multiple = _this$props2.multiple,
|
|
642
|
+
otherProps = _objectWithoutProperties(_this$props2, ["value", "children", "label", "multiple"]);
|
|
643
|
+
|
|
644
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement(_splunk_react_ui_Menu__WEBPACK_IMPORTED_MODULE_2__["Item"], _extends({
|
|
645
|
+
"aria-selected": this.props.selected,
|
|
646
|
+
"data-test-value": value,
|
|
647
|
+
"data-test": "option",
|
|
648
|
+
ref: this.handleMount
|
|
649
|
+
}, otherProps, {
|
|
650
|
+
selectable: true,
|
|
651
|
+
selectableAppearance: multiple ? 'checkbox' : undefined,
|
|
652
|
+
onClick: this.handleClick,
|
|
653
|
+
role: "option",
|
|
654
|
+
value: value.toString()
|
|
655
|
+
}), children || label);
|
|
915
656
|
}
|
|
916
657
|
}]);
|
|
917
658
|
|
|
918
|
-
return
|
|
919
|
-
}(
|
|
920
|
-
|
|
921
|
-
Select_defineProperty(Select_Select, "propTypes", Select_propTypes);
|
|
922
|
-
|
|
923
|
-
Select_defineProperty(Select_Select, "defaultProps", Select_defaultProps);
|
|
924
|
-
|
|
925
|
-
Select_defineProperty(Select_Select, "Option", Select_Option);
|
|
926
|
-
|
|
927
|
-
Select_defineProperty(Select_Select, "Divider", Menu_["Divider"]);
|
|
928
|
-
|
|
929
|
-
Select_defineProperty(Select_Select, "Heading", Menu_["Heading"]);
|
|
930
|
-
|
|
931
|
-
/* harmony default export */ var src_Select_Select = (Select_Select);
|
|
932
|
-
|
|
933
|
-
// CONCATENATED MODULE: ./src/Select/index.ts
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
/***/ }),
|
|
938
|
-
|
|
939
|
-
/***/ 13:
|
|
940
|
-
/***/ (function(module, exports) {
|
|
941
|
-
|
|
942
|
-
module.exports = require("@splunk/react-ui/Menu");
|
|
943
|
-
|
|
944
|
-
/***/ }),
|
|
945
|
-
|
|
946
|
-
/***/ 16:
|
|
947
|
-
/***/ (function(module, exports) {
|
|
948
|
-
|
|
949
|
-
module.exports = require("@splunk/react-ui/Dropdown");
|
|
950
|
-
|
|
951
|
-
/***/ }),
|
|
952
|
-
|
|
953
|
-
/***/ 17:
|
|
954
|
-
/***/ (function(module, exports) {
|
|
955
|
-
|
|
956
|
-
module.exports = require("@splunk/react-ui/Button");
|
|
957
|
-
|
|
958
|
-
/***/ }),
|
|
959
|
-
|
|
960
|
-
/***/ 2:
|
|
961
|
-
/***/ (function(module, exports) {
|
|
962
|
-
|
|
963
|
-
module.exports = require("react");
|
|
659
|
+
return Option;
|
|
660
|
+
}(react__WEBPACK_IMPORTED_MODULE_0__["PureComponent"]);
|
|
964
661
|
|
|
965
|
-
|
|
662
|
+
_defineProperty(Option, "propTypes", propTypes);
|
|
966
663
|
|
|
967
|
-
|
|
968
|
-
/***/ (function(module, exports) {
|
|
664
|
+
_defineProperty(Option, "defaultProps", defaultProps);
|
|
969
665
|
|
|
970
|
-
|
|
666
|
+
/* harmony default export */ __webpack_exports__["a"] = (Option);
|
|
971
667
|
|
|
972
668
|
/***/ }),
|
|
973
669
|
|
|
974
|
-
/***/
|
|
670
|
+
/***/ 29:
|
|
975
671
|
/***/ (function(module, exports) {
|
|
976
672
|
|
|
977
|
-
module.exports = require("@splunk/react-ui/
|
|
673
|
+
module.exports = require("@splunk/react-ui/Link");
|
|
978
674
|
|
|
979
675
|
/***/ }),
|
|
980
676
|
|
|
@@ -985,28 +681,14 @@ module.exports = require("styled-components");
|
|
|
985
681
|
|
|
986
682
|
/***/ }),
|
|
987
683
|
|
|
988
|
-
/***/
|
|
989
|
-
/***/ (function(module, exports) {
|
|
990
|
-
|
|
991
|
-
module.exports = require("@splunk/react-ui/Link");
|
|
992
|
-
|
|
993
|
-
/***/ }),
|
|
994
|
-
|
|
995
|
-
/***/ 35:
|
|
996
|
-
/***/ (function(module, exports) {
|
|
997
|
-
|
|
998
|
-
module.exports = require("@splunk/react-ui/ResultsMenu");
|
|
999
|
-
|
|
1000
|
-
/***/ }),
|
|
1001
|
-
|
|
1002
|
-
/***/ 39:
|
|
684
|
+
/***/ 36:
|
|
1003
685
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
1004
686
|
|
|
1005
687
|
"use strict";
|
|
1006
688
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CaretDown; });
|
|
1007
689
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
|
|
1008
690
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
1009
|
-
/* harmony import */ var _splunk_react_icons_Caret__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(
|
|
691
|
+
/* harmony import */ var _splunk_react_icons_Caret__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(37);
|
|
1010
692
|
/* harmony import */ var _splunk_react_icons_Caret__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_splunk_react_icons_Caret__WEBPACK_IMPORTED_MODULE_1__);
|
|
1011
693
|
/* harmony import */ var _ThemedIcon__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
|
|
1012
694
|
/* harmony import */ var _SVG__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6);
|
|
@@ -1037,6 +719,20 @@ function CaretDown(props) {
|
|
|
1037
719
|
|
|
1038
720
|
/***/ }),
|
|
1039
721
|
|
|
722
|
+
/***/ 37:
|
|
723
|
+
/***/ (function(module, exports) {
|
|
724
|
+
|
|
725
|
+
module.exports = require("@splunk/react-icons/Caret");
|
|
726
|
+
|
|
727
|
+
/***/ }),
|
|
728
|
+
|
|
729
|
+
/***/ 39:
|
|
730
|
+
/***/ (function(module, exports) {
|
|
731
|
+
|
|
732
|
+
module.exports = require("@splunk/react-ui/ResultsMenu");
|
|
733
|
+
|
|
734
|
+
/***/ }),
|
|
735
|
+
|
|
1040
736
|
/***/ 4:
|
|
1041
737
|
/***/ (function(module, exports) {
|
|
1042
738
|
|
|
@@ -1044,10 +740,1061 @@ module.exports = require("lodash");
|
|
|
1044
740
|
|
|
1045
741
|
/***/ }),
|
|
1046
742
|
|
|
1047
|
-
/***/
|
|
1048
|
-
/***/ (function(module,
|
|
743
|
+
/***/ 42:
|
|
744
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
745
|
+
|
|
746
|
+
"use strict";
|
|
747
|
+
|
|
748
|
+
// EXPORTS
|
|
749
|
+
__webpack_require__.d(__webpack_exports__, "a", function() { return /* reexport */ Menu_["Divider"]; });
|
|
750
|
+
__webpack_require__.d(__webpack_exports__, "b", function() { return /* reexport */ Menu_["Heading"]; });
|
|
751
|
+
__webpack_require__.d(__webpack_exports__, "d", function() { return /* binding */ isOption; });
|
|
752
|
+
|
|
753
|
+
// UNUSED EXPORTS: Option
|
|
754
|
+
|
|
755
|
+
// EXTERNAL MODULE: external "react"
|
|
756
|
+
var external_react_ = __webpack_require__(2);
|
|
757
|
+
var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
|
|
758
|
+
|
|
759
|
+
// EXTERNAL MODULE: external "prop-types"
|
|
760
|
+
var external_prop_types_ = __webpack_require__(1);
|
|
761
|
+
var external_prop_types_default = /*#__PURE__*/__webpack_require__.n(external_prop_types_);
|
|
762
|
+
|
|
763
|
+
// EXTERNAL MODULE: external "lodash"
|
|
764
|
+
var external_lodash_ = __webpack_require__(4);
|
|
765
|
+
|
|
766
|
+
// EXTERNAL MODULE: external "@splunk/ui-utils/filter"
|
|
767
|
+
var filter_ = __webpack_require__(23);
|
|
768
|
+
|
|
769
|
+
// EXTERNAL MODULE: external "@splunk/ui-utils/id"
|
|
770
|
+
var id_ = __webpack_require__(10);
|
|
771
|
+
|
|
772
|
+
// EXTERNAL MODULE: external "@splunk/ui-utils/i18n"
|
|
773
|
+
var i18n_ = __webpack_require__(5);
|
|
774
|
+
|
|
775
|
+
// EXTERNAL MODULE: external "@splunk/ui-utils/keyboard"
|
|
776
|
+
var keyboard_ = __webpack_require__(9);
|
|
777
|
+
|
|
778
|
+
// EXTERNAL MODULE: external "@splunk/react-ui/Dropdown"
|
|
779
|
+
var Dropdown_ = __webpack_require__(19);
|
|
780
|
+
var Dropdown_default = /*#__PURE__*/__webpack_require__.n(Dropdown_);
|
|
781
|
+
|
|
782
|
+
// EXTERNAL MODULE: external "@splunk/react-ui/Link"
|
|
783
|
+
var Link_ = __webpack_require__(29);
|
|
784
|
+
var Link_default = /*#__PURE__*/__webpack_require__.n(Link_);
|
|
785
|
+
|
|
786
|
+
// EXTERNAL MODULE: external "@splunk/react-ui/Menu"
|
|
787
|
+
var Menu_ = __webpack_require__(13);
|
|
788
|
+
|
|
789
|
+
// EXTERNAL MODULE: external "@splunk/react-ui/ResultsMenu"
|
|
790
|
+
var ResultsMenu_ = __webpack_require__(39);
|
|
791
|
+
var ResultsMenu_default = /*#__PURE__*/__webpack_require__.n(ResultsMenu_);
|
|
792
|
+
|
|
793
|
+
// EXTERNAL MODULE: external "@splunk/react-ui/Text"
|
|
794
|
+
var Text_ = __webpack_require__(26);
|
|
795
|
+
var Text_default = /*#__PURE__*/__webpack_require__.n(Text_);
|
|
796
|
+
|
|
797
|
+
// EXTERNAL MODULE: ./src/icons/CaretDown.tsx
|
|
798
|
+
var CaretDown = __webpack_require__(36);
|
|
799
|
+
|
|
800
|
+
// EXTERNAL MODULE: ./src/Select/OptionBase.tsx
|
|
801
|
+
var OptionBase = __webpack_require__(28);
|
|
802
|
+
|
|
803
|
+
// EXTERNAL MODULE: external "styled-components"
|
|
804
|
+
var external_styled_components_ = __webpack_require__(3);
|
|
805
|
+
var external_styled_components_default = /*#__PURE__*/__webpack_require__.n(external_styled_components_);
|
|
806
|
+
|
|
807
|
+
// EXTERNAL MODULE: external "@splunk/react-ui/Button"
|
|
808
|
+
var Button_ = __webpack_require__(16);
|
|
809
|
+
var Button_default = /*#__PURE__*/__webpack_require__.n(Button_);
|
|
810
|
+
|
|
811
|
+
// EXTERNAL MODULE: external "@splunk/themes"
|
|
812
|
+
var themes_ = __webpack_require__(0);
|
|
813
|
+
|
|
814
|
+
// CONCATENATED MODULE: ./src/Select/SelectBaseStyles.ts
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
var StyledButton = external_styled_components_default()(Button_default.a).withConfig({
|
|
820
|
+
displayName: "SelectBaseStyles__StyledButton",
|
|
821
|
+
componentId: "sc-16cj7sk-0"
|
|
822
|
+
})(["&[data-inline]{width:", ";}", ""], function (_ref) {
|
|
823
|
+
var $multiple = _ref.$multiple;
|
|
824
|
+
return $multiple ? '400px' : 'auto';
|
|
825
|
+
}, function (_ref2) {
|
|
826
|
+
var $multiple = _ref2.$multiple;
|
|
827
|
+
return !$multiple && 'flex-grow: 0;';
|
|
828
|
+
});
|
|
829
|
+
var StyledLinkIcon = external_styled_components_default.a.span.withConfig({
|
|
830
|
+
displayName: "SelectBaseStyles__StyledLinkIcon",
|
|
831
|
+
componentId: "sc-16cj7sk-1"
|
|
832
|
+
})(["padding-right:2px;"]);
|
|
833
|
+
var StyledLinkCaret = external_styled_components_default.a.span.withConfig({
|
|
834
|
+
displayName: "SelectBaseStyles__StyledLinkCaret",
|
|
835
|
+
componentId: "sc-16cj7sk-2"
|
|
836
|
+
})(["padding-left:2px;"]);
|
|
837
|
+
var StyledFilter = external_styled_components_default.a.div.withConfig({
|
|
838
|
+
displayName: "SelectBaseStyles__StyledFilter",
|
|
839
|
+
componentId: "sc-16cj7sk-3"
|
|
840
|
+
})(["padding:", ";min-width:160px;"], Object(themes_["pick"])({
|
|
841
|
+
enterprise: '8px',
|
|
842
|
+
prisma: '10px 16px'
|
|
843
|
+
}));
|
|
844
|
+
var StyledCount = external_styled_components_default.a.span.withConfig({
|
|
845
|
+
displayName: "SelectBaseStyles__StyledCount",
|
|
846
|
+
componentId: "sc-16cj7sk-4"
|
|
847
|
+
})(["padding-right:", ";"], Object(themes_["pick"])({
|
|
848
|
+
enterprise: themes_["variables"].spacingQuarter,
|
|
849
|
+
prisma: themes_["variables"].spacingXSmall
|
|
850
|
+
}));
|
|
851
|
+
var StyledControlsLink = external_styled_components_default()(Link_default.a).withConfig({
|
|
852
|
+
displayName: "SelectBaseStyles__StyledControlsLink",
|
|
853
|
+
componentId: "sc-16cj7sk-5"
|
|
854
|
+
})(["", ";"], function (_ref3) {
|
|
855
|
+
var $disabled = _ref3.$disabled;
|
|
856
|
+
return $disabled && Object(external_styled_components_["css"])(["color:", ";"], themes_["variables"].contentColorDisabled);
|
|
857
|
+
});
|
|
858
|
+
var StyledToggleAllControls = external_styled_components_default.a.div.withConfig({
|
|
859
|
+
displayName: "SelectBaseStyles__StyledToggleAllControls",
|
|
860
|
+
componentId: "sc-16cj7sk-6"
|
|
861
|
+
})(["padding:", ";", ""], Object(themes_["pick"])({
|
|
862
|
+
enterprise: "5px 8px",
|
|
863
|
+
prisma: '10px 16px'
|
|
864
|
+
}), Object(themes_["pickVariant"])('$placement', {
|
|
865
|
+
above: {
|
|
866
|
+
enterprise: Object(external_styled_components_["css"])(["border-top:", ";"], themes_["variables"].border),
|
|
867
|
+
prisma: Object(external_styled_components_["css"])(["border-top:1px solid ", ";"], themes_["variables"].neutral200)
|
|
868
|
+
},
|
|
869
|
+
below: {
|
|
870
|
+
enterprise: Object(external_styled_components_["css"])(["border-bottom:", ";"], themes_["variables"].border),
|
|
871
|
+
prisma: Object(external_styled_components_["css"])(["border-bottom:1px solid ", ";"], themes_["variables"].neutral200)
|
|
872
|
+
}
|
|
873
|
+
}));
|
|
874
|
+
|
|
875
|
+
// CONCATENATED MODULE: ./src/Select/SelectBase.tsx
|
|
876
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
877
|
+
|
|
878
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
879
|
+
|
|
880
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
881
|
+
|
|
882
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
883
|
+
|
|
884
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
885
|
+
|
|
886
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
887
|
+
|
|
888
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
889
|
+
|
|
890
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
891
|
+
|
|
892
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
893
|
+
|
|
894
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
895
|
+
|
|
896
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
897
|
+
|
|
898
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
899
|
+
|
|
900
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
901
|
+
|
|
902
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
903
|
+
|
|
904
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
905
|
+
|
|
906
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
907
|
+
|
|
908
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
909
|
+
|
|
910
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
911
|
+
|
|
912
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
913
|
+
|
|
914
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
915
|
+
|
|
916
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
917
|
+
|
|
918
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
919
|
+
|
|
920
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
921
|
+
|
|
922
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
923
|
+
|
|
924
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
|
|
941
|
+
var propTypes = {
|
|
942
|
+
allowNewValues: external_prop_types_default.a.bool,
|
|
943
|
+
animateLoading: external_prop_types_default.a.bool,
|
|
944
|
+
appearance: external_prop_types_default.a.oneOf(['default', 'link', 'primary', 'pill', 'toggle', 'flat']),
|
|
945
|
+
append: external_prop_types_default.a.bool,
|
|
946
|
+
children: external_prop_types_default.a.node,
|
|
947
|
+
defaultPlacement: external_prop_types_default.a.oneOf(['above', 'below', 'vertical']),
|
|
948
|
+
defaultValues: external_prop_types_default.a.array,
|
|
949
|
+
describedBy: external_prop_types_default.a.string,
|
|
950
|
+
disabled: external_prop_types_default.a.bool,
|
|
951
|
+
elementRef: external_prop_types_default.a.oneOfType([external_prop_types_default.a.func, external_prop_types_default.a.object]),
|
|
952
|
+
error: external_prop_types_default.a.bool,
|
|
953
|
+
filter: external_prop_types_default.a.oneOf([false, true, 'controlled']),
|
|
954
|
+
footerMessage: external_prop_types_default.a.node,
|
|
955
|
+
inline: external_prop_types_default.a.bool,
|
|
956
|
+
inputId: external_prop_types_default.a.string,
|
|
957
|
+
inputRef: external_prop_types_default.a.oneOfType([external_prop_types_default.a.func, external_prop_types_default.a.object]),
|
|
958
|
+
isLoadingOptions: external_prop_types_default.a.bool,
|
|
959
|
+
labelledBy: external_prop_types_default.a.string,
|
|
960
|
+
labelText: external_prop_types_default.a.string,
|
|
961
|
+
loadingMessage: external_prop_types_default.a.node,
|
|
962
|
+
menuStyle: external_prop_types_default.a.object,
|
|
963
|
+
multiple: external_prop_types_default.a.bool,
|
|
964
|
+
name: external_prop_types_default.a.string,
|
|
965
|
+
noOptionsMessage: external_prop_types_default.a.node,
|
|
966
|
+
onChange: external_prop_types_default.a.func,
|
|
967
|
+
onClose: external_prop_types_default.a.func,
|
|
968
|
+
onFilterChange: external_prop_types_default.a.func,
|
|
969
|
+
onOpen: external_prop_types_default.a.func,
|
|
970
|
+
onScrollBottom: external_prop_types_default.a.func,
|
|
971
|
+
placeholder: external_prop_types_default.a.string,
|
|
972
|
+
prefixLabel: external_prop_types_default.a.string,
|
|
973
|
+
prepend: external_prop_types_default.a.bool,
|
|
974
|
+
suffixLabel: external_prop_types_default.a.string,
|
|
975
|
+
tabConfirmsNewValue: external_prop_types_default.a.bool,
|
|
976
|
+
values: external_prop_types_default.a.array
|
|
977
|
+
};
|
|
978
|
+
var defaultProps = {
|
|
979
|
+
allowNewValues: false,
|
|
980
|
+
animateLoading: false,
|
|
981
|
+
appearance: 'toggle',
|
|
982
|
+
append: false,
|
|
983
|
+
defaultPlacement: 'vertical',
|
|
984
|
+
disabled: false,
|
|
985
|
+
filter: false,
|
|
986
|
+
inline: false,
|
|
987
|
+
isLoadingOptions: false,
|
|
988
|
+
menuStyle: {},
|
|
989
|
+
multiple: false,
|
|
990
|
+
noOptionsMessage: Object(i18n_["_"])('No matches'),
|
|
991
|
+
placeholder: Object(i18n_["_"])('Select...'),
|
|
992
|
+
prepend: false,
|
|
993
|
+
tabConfirmsNewValue: false
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
function isOption(child) {
|
|
997
|
+
return child && Object(external_lodash_["has"])(child.props, 'value');
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
var SelectBase_SelectBase = /*#__PURE__*/function (_Component) {
|
|
1001
|
+
_inherits(SelectBase, _Component);
|
|
1002
|
+
|
|
1003
|
+
var _super = _createSuper(SelectBase);
|
|
1004
|
+
|
|
1005
|
+
_createClass(SelectBase, null, [{
|
|
1006
|
+
key: "validateAppearance",
|
|
1007
|
+
// @docs-props-type CompactPropsBase
|
|
1008
|
+
value: function validateAppearance(props) {
|
|
1009
|
+
if (false) {}
|
|
1010
|
+
}
|
|
1011
|
+
}]);
|
|
1012
|
+
|
|
1013
|
+
function SelectBase(props) {
|
|
1014
|
+
var _this;
|
|
1015
|
+
|
|
1016
|
+
_classCallCheck(this, SelectBase);
|
|
1017
|
+
|
|
1018
|
+
_this = _super.call(this, props);
|
|
1019
|
+
|
|
1020
|
+
_defineProperty(_assertThisInitialized(_this), "activeItemId", void 0);
|
|
1021
|
+
|
|
1022
|
+
_defineProperty(_assertThisInitialized(_this), "activeValue", void 0);
|
|
1023
|
+
|
|
1024
|
+
_defineProperty(_assertThisInitialized(_this), "availableOptionCount", void 0);
|
|
1025
|
+
|
|
1026
|
+
_defineProperty(_assertThisInitialized(_this), "controlledExternally", void 0);
|
|
1027
|
+
|
|
1028
|
+
_defineProperty(_assertThisInitialized(_this), "displayedValues", void 0);
|
|
1029
|
+
|
|
1030
|
+
_defineProperty(_assertThisInitialized(_this), "dropdown", null);
|
|
1031
|
+
|
|
1032
|
+
_defineProperty(_assertThisInitialized(_this), "firstSelectedOption", null);
|
|
1033
|
+
|
|
1034
|
+
_defineProperty(_assertThisInitialized(_this), "firstSelectedOptionIndex", void 0);
|
|
1035
|
+
|
|
1036
|
+
_defineProperty(_assertThisInitialized(_this), "menuId", void 0);
|
|
1037
|
+
|
|
1038
|
+
_defineProperty(_assertThisInitialized(_this), "selectedOptionCount", void 0);
|
|
1039
|
+
|
|
1040
|
+
_defineProperty(_assertThisInitialized(_this), "handleSelectAll", function (e) {
|
|
1041
|
+
var _this$getCurrentValue, _this$props$onChange, _this$props2;
|
|
1042
|
+
|
|
1043
|
+
var _this$props = _this.props,
|
|
1044
|
+
name = _this$props.name,
|
|
1045
|
+
children = _this$props.children,
|
|
1046
|
+
multiple = _this$props.multiple; // this doesn't make sense if we can't select multiple values
|
|
1047
|
+
|
|
1048
|
+
if (!multiple) {
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
var values = Object(external_lodash_["uniq"])(((_this$getCurrentValue = _this.getCurrentValues()) !== null && _this$getCurrentValue !== void 0 ? _this$getCurrentValue : []).concat(_this.displayedValues));
|
|
1053
|
+
|
|
1054
|
+
if (!_this.isControlled()) {
|
|
1055
|
+
values = external_react_default.a.Children.toArray(children).filter(function (child) {
|
|
1056
|
+
return isOption(child) && Object(external_lodash_["includes"])(values, child.props.value) && !child.props.disabled;
|
|
1057
|
+
}).map(function (child) {
|
|
1058
|
+
return child.props.value;
|
|
1059
|
+
});
|
|
1060
|
+
|
|
1061
|
+
_this.setState({
|
|
1062
|
+
values: values
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
(_this$props$onChange = (_this$props2 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props2, e, {
|
|
1067
|
+
values: values,
|
|
1068
|
+
name: name
|
|
1069
|
+
});
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
_defineProperty(_assertThisInitialized(_this), "handleClearAll", function (e) {
|
|
1073
|
+
var _this$props$onChange2, _this$props3;
|
|
1074
|
+
|
|
1075
|
+
// this doesn't make sense if we can't select multiple values
|
|
1076
|
+
if (!_this.props.multiple) {
|
|
1077
|
+
return;
|
|
1078
|
+
} // Clear the filtered items, items when filtering. Else clear all the items.
|
|
1079
|
+
|
|
1080
|
+
|
|
1081
|
+
var values = _this.state.filterKeyword ? external_lodash_["without"].apply(void 0, [_this.getCurrentValues()].concat(_toConsumableArray(_this.displayedValues))) : [];
|
|
1082
|
+
var name = _this.props.name;
|
|
1083
|
+
|
|
1084
|
+
if (!_this.isControlled()) {
|
|
1085
|
+
_this.setState({
|
|
1086
|
+
values: values
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
(_this$props$onChange2 = (_this$props3 = _this.props).onChange) === null || _this$props$onChange2 === void 0 ? void 0 : _this$props$onChange2.call(_this$props3, e, {
|
|
1091
|
+
values: values,
|
|
1092
|
+
name: name
|
|
1093
|
+
});
|
|
1094
|
+
});
|
|
1095
|
+
|
|
1096
|
+
_defineProperty(_assertThisInitialized(_this), "handleTextKeyDown", function (e) {
|
|
1097
|
+
var _this$props4 = _this.props,
|
|
1098
|
+
children = _this$props4.children,
|
|
1099
|
+
onScrollBottom = _this$props4.onScrollBottom,
|
|
1100
|
+
tabConfirmsNewValue = _this$props4.tabConfirmsNewValue;
|
|
1101
|
+
var eventKeyCode = Object(keyboard_["keycode"])(e.nativeEvent);
|
|
1102
|
+
|
|
1103
|
+
if (eventKeyCode === 'tab') {
|
|
1104
|
+
if (tabConfirmsNewValue && !Object(external_lodash_["isUndefined"])(_this.activeValue) && _this.availableOptionCount <= 1) {
|
|
1105
|
+
e.preventDefault();
|
|
1106
|
+
|
|
1107
|
+
_this.toggleValue(e, _this.activeValue);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (e.shiftKey || e.metaKey || e.ctrlKey) {
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
if (eventKeyCode === 'down') {
|
|
1116
|
+
e.preventDefault();
|
|
1117
|
+
|
|
1118
|
+
_this.setState(function (state) {
|
|
1119
|
+
return {
|
|
1120
|
+
activeIndex: Math.min(state.activeIndex + 1, _this.availableOptionCount - 1)
|
|
1121
|
+
};
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
if (children && onScrollBottom) {
|
|
1125
|
+
var _this$getCurrentValue2;
|
|
1126
|
+
|
|
1127
|
+
var beforeLastChild = external_react_["Children"].toArray(children).length - (2 + ((_this$getCurrentValue2 = _this.getCurrentValues()) !== null && _this$getCurrentValue2 !== void 0 ? _this$getCurrentValue2 : []).length);
|
|
1128
|
+
|
|
1129
|
+
if (_this.state.activeIndex === beforeLastChild) {
|
|
1130
|
+
onScrollBottom();
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
if (eventKeyCode === 'up') {
|
|
1136
|
+
e.preventDefault();
|
|
1137
|
+
|
|
1138
|
+
_this.setState(function (state) {
|
|
1139
|
+
return {
|
|
1140
|
+
activeIndex: Math.max(state.activeIndex - 1, 0)
|
|
1141
|
+
};
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
if (eventKeyCode === 'enter' && !Object(external_lodash_["isUndefined"])(_this.activeValue) && _this.state.open) {
|
|
1146
|
+
e.preventDefault();
|
|
1147
|
+
|
|
1148
|
+
_this.toggleValue(e, _this.activeValue);
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
_defineProperty(_assertThisInitialized(_this), "handleMenuOptionClick", function (e, _ref) {
|
|
1153
|
+
var value = _ref.value;
|
|
1154
|
+
e.preventDefault();
|
|
1155
|
+
|
|
1156
|
+
_this.toggleValue(e, value);
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
_defineProperty(_assertThisInitialized(_this), "handleTextChange", function (e, _ref2) {
|
|
1160
|
+
var _this$props$onFilterC, _this$props5;
|
|
1161
|
+
|
|
1162
|
+
var value = _ref2.value;
|
|
1163
|
+
|
|
1164
|
+
_this.setState({
|
|
1165
|
+
filterKeyword: value,
|
|
1166
|
+
open: true,
|
|
1167
|
+
activeIndex: 0
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
(_this$props$onFilterC = (_this$props5 = _this.props).onFilterChange) === null || _this$props$onFilterC === void 0 ? void 0 : _this$props$onFilterC.call(_this$props5, e, {
|
|
1171
|
+
keyword: value
|
|
1172
|
+
});
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1175
|
+
_defineProperty(_assertThisInitialized(_this), "handleTextFocus", function () {
|
|
1176
|
+
_this.setState({
|
|
1177
|
+
textHasFocus: true
|
|
1178
|
+
});
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
_defineProperty(_assertThisInitialized(_this), "handleTextBlur", function () {
|
|
1182
|
+
_this.setState({
|
|
1183
|
+
textHasFocus: false
|
|
1184
|
+
});
|
|
1185
|
+
});
|
|
1186
|
+
|
|
1187
|
+
_defineProperty(_assertThisInitialized(_this), "handleRequestOpen", function (e) {
|
|
1188
|
+
var _this$getCurrentValue3, _this$props$onFilterC2, _this$props7;
|
|
1189
|
+
|
|
1190
|
+
var multiple = _this.props.multiple;
|
|
1191
|
+
|
|
1192
|
+
_this.setState({
|
|
1193
|
+
open: true,
|
|
1194
|
+
// in non-multiple mode, don't move values to the top of the list
|
|
1195
|
+
topValues: multiple ? (_this$getCurrentValue3 = _this.getCurrentValues()) !== null && _this$getCurrentValue3 !== void 0 ? _this$getCurrentValue3 : [] : []
|
|
1196
|
+
}, function () {
|
|
1197
|
+
var _this$props$onOpen, _this$props6;
|
|
1198
|
+
|
|
1199
|
+
(_this$props$onOpen = (_this$props6 = _this.props).onOpen) === null || _this$props$onOpen === void 0 ? void 0 : _this$props$onOpen.call(_this$props6);
|
|
1200
|
+
|
|
1201
|
+
if (_this.firstSelectedOption && !_this.hasFilter()) {
|
|
1202
|
+
_this.firstSelectedOption.focus();
|
|
1203
|
+
} else {
|
|
1204
|
+
var _this$firstSelectedOp;
|
|
1205
|
+
|
|
1206
|
+
_this.setState({
|
|
1207
|
+
activeIndex: (_this$firstSelectedOp = _this.firstSelectedOptionIndex) !== null && _this$firstSelectedOp !== void 0 ? _this$firstSelectedOp : 0
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
|
|
1212
|
+
(_this$props$onFilterC2 = (_this$props7 = _this.props).onFilterChange) === null || _this$props$onFilterC2 === void 0 ? void 0 : _this$props$onFilterC2.call(_this$props7, e, {
|
|
1213
|
+
keyword: ''
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
_defineProperty(_assertThisInitialized(_this), "handleRequestClose", function () {
|
|
1218
|
+
_this.setState({
|
|
1219
|
+
open: false,
|
|
1220
|
+
activeIndex: 0
|
|
1221
|
+
}, function () {
|
|
1222
|
+
var _this$props$onClose, _this$props8;
|
|
1223
|
+
|
|
1224
|
+
(_this$props$onClose = (_this$props8 = _this.props).onClose) === null || _this$props$onClose === void 0 ? void 0 : _this$props$onClose.call(_this$props8);
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
_defineProperty(_assertThisInitialized(_this), "handleScrollBottom", function () {
|
|
1229
|
+
if (_this.state.open && !_this.props.isLoadingOptions) {
|
|
1230
|
+
var _this$props$onScrollB, _this$props9;
|
|
1231
|
+
|
|
1232
|
+
(_this$props$onScrollB = (_this$props9 = _this.props).onScrollBottom) === null || _this$props$onScrollB === void 0 ? void 0 : _this$props$onScrollB.call(_this$props9);
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
_defineProperty(_assertThisInitialized(_this), "handleActiveOptionMount", function (c) {
|
|
1237
|
+
c === null || c === void 0 ? void 0 : c.scrollIntoViewIfNeeded();
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
_defineProperty(_assertThisInitialized(_this), "handleSelectedItemMount", function (c) {
|
|
1241
|
+
_this.firstSelectedOption = c;
|
|
1242
|
+
});
|
|
1243
|
+
|
|
1244
|
+
_defineProperty(_assertThisInitialized(_this), "createChildren", function () {
|
|
1245
|
+
var _this$state = _this.state,
|
|
1246
|
+
filterKeyword = _this$state.filterKeyword,
|
|
1247
|
+
textHasFocus = _this$state.textHasFocus,
|
|
1248
|
+
topValues = _this$state.topValues;
|
|
1249
|
+
var _this$props10 = _this.props,
|
|
1250
|
+
allowNewValues = _this$props10.allowNewValues,
|
|
1251
|
+
filter = _this$props10.filter,
|
|
1252
|
+
multiple = _this$props10.multiple;
|
|
1253
|
+
|
|
1254
|
+
var currentValues = _this.getCurrentValues();
|
|
1255
|
+
|
|
1256
|
+
_this.availableOptionCount = 0;
|
|
1257
|
+
_this.firstSelectedOptionIndex = undefined;
|
|
1258
|
+
_this.selectedOptionCount = 0;
|
|
1259
|
+
_this.activeValue = undefined;
|
|
1260
|
+
var foundExactMatch;
|
|
1261
|
+
var childrenTopCount = 0;
|
|
1262
|
+
var hasDivider = false; // used to avoid overwriting the selected item ref in multiple mode
|
|
1263
|
+
|
|
1264
|
+
var foundSelected;
|
|
1265
|
+
var children = external_react_["Children"].toArray(_this.props.children).reduce(function (acc, item, i) {
|
|
1266
|
+
// ignore Headings and Dividers
|
|
1267
|
+
if (!isOption(item)) {
|
|
1268
|
+
acc.push(item);
|
|
1269
|
+
return acc;
|
|
1270
|
+
} // Find out if the search string exactly matches a value
|
|
1271
|
+
|
|
1272
|
+
|
|
1273
|
+
if (item.props.value === _this.state.filterKeyword) {
|
|
1274
|
+
foundExactMatch = true;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
var selected = currentValues && currentValues.indexOf(item.props.value) >= 0; // Format the Menu.Item
|
|
1278
|
+
|
|
1279
|
+
var clonedItem = /*#__PURE__*/Object(external_react_["cloneElement"])(item, {
|
|
1280
|
+
key: item.key || i,
|
|
1281
|
+
onClick: _this.handleMenuOptionClick,
|
|
1282
|
+
selected: selected,
|
|
1283
|
+
multiple: multiple,
|
|
1284
|
+
role: 'option',
|
|
1285
|
+
ref: selected && !foundSelected ? _this.handleSelectedItemMount : undefined
|
|
1286
|
+
});
|
|
1287
|
+
|
|
1288
|
+
if (selected) {
|
|
1289
|
+
foundSelected = true;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
if (topValues && topValues.indexOf(item.props.value) >= 0) {
|
|
1293
|
+
if (childrenTopCount === 0) {
|
|
1294
|
+
acc.splice(childrenTopCount, 0, /*#__PURE__*/external_react_default.a.createElement(Menu_["Divider"], {
|
|
1295
|
+
key: "topDivider"
|
|
1296
|
+
}));
|
|
1297
|
+
hasDivider = true;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
acc.splice(childrenTopCount, 0, clonedItem);
|
|
1301
|
+
childrenTopCount += 1;
|
|
1302
|
+
} else {
|
|
1303
|
+
acc.push(clonedItem);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
return acc;
|
|
1307
|
+
}, []); // In multiple mode, add missing items
|
|
1308
|
+
|
|
1309
|
+
if (multiple) {
|
|
1310
|
+
Object(external_lodash_["forEachRight"])(currentValues, function (value) {
|
|
1311
|
+
var matchedItem = Object(external_lodash_["find"])(children, function (item) {
|
|
1312
|
+
return isOption(item) && item.props && item.props.value === value;
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
if (!matchedItem) {
|
|
1316
|
+
if (value === _this.state.filterKeyword) {
|
|
1317
|
+
foundExactMatch = true;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
var isTopValue = topValues && topValues.indexOf(value) >= 0;
|
|
1321
|
+
var topLength = topValues.length;
|
|
1322
|
+
|
|
1323
|
+
if (childrenTopCount === 0) {
|
|
1324
|
+
children.splice(0, 0, /*#__PURE__*/external_react_default.a.createElement(Menu_["Divider"], {
|
|
1325
|
+
key: "topDivider"
|
|
1326
|
+
}));
|
|
1327
|
+
childrenTopCount += 1;
|
|
1328
|
+
hasDivider = true;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
children.splice(isTopValue ? 0 : topLength + 1, 0, /*#__PURE__*/external_react_default.a.createElement(OptionBase["a" /* default */], {
|
|
1332
|
+
label: String(value),
|
|
1333
|
+
value: value,
|
|
1334
|
+
key: "missing-value-".concat(value),
|
|
1335
|
+
onClick: _this.handleMenuOptionClick,
|
|
1336
|
+
multiple: multiple,
|
|
1337
|
+
selected: true
|
|
1338
|
+
}));
|
|
1339
|
+
|
|
1340
|
+
if (isTopValue) {
|
|
1341
|
+
childrenTopCount += 1;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
var controlledFilter = filter === 'controlled'; // Filter the items
|
|
1348
|
+
|
|
1349
|
+
var keywords = Object(filter_["stringToKeywords"])(filterKeyword);
|
|
1350
|
+
children = controlledFilter ? children : children.filter(function (option) {
|
|
1351
|
+
if (isOption(option)) {
|
|
1352
|
+
return Object(filter_["testPhrase"])(option.props.label, keywords);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
return true; // Keep all headers and non-interactive options
|
|
1356
|
+
}) // highlight the matched text
|
|
1357
|
+
.map(function (option) {
|
|
1358
|
+
if (!isOption(option)) {
|
|
1359
|
+
return option;
|
|
1360
|
+
} // highlight matched text
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
var matchRanges = keywords && Object(filter_["keywordLocations"])(option.props.label, keywords);
|
|
1364
|
+
return /*#__PURE__*/Object(external_react_["cloneElement"])(option, {
|
|
1365
|
+
matchRanges: matchRanges || undefined
|
|
1366
|
+
});
|
|
1367
|
+
}); // Add the option to add the new value
|
|
1368
|
+
|
|
1369
|
+
if (allowNewValues && !foundExactMatch && filterKeyword) {
|
|
1370
|
+
var insertIndex = hasDivider ? childrenTopCount + 1 : childrenTopCount;
|
|
1371
|
+
children.splice(insertIndex, 0, /*#__PURE__*/external_react_default.a.createElement(OptionBase["a" /* default */], {
|
|
1372
|
+
label: "".concat(filterKeyword, " (new value)"),
|
|
1373
|
+
value: filterKeyword,
|
|
1374
|
+
key: "newValue",
|
|
1375
|
+
multiple: multiple,
|
|
1376
|
+
onClick: _this.handleMenuOptionClick
|
|
1377
|
+
}));
|
|
1378
|
+
} // Highlight the selected Items and remove hidden
|
|
1379
|
+
|
|
1380
|
+
|
|
1381
|
+
children = children.reduce(function (acc, item) {
|
|
1382
|
+
// ignore Dividers & Headings
|
|
1383
|
+
if (!isOption(item)) {
|
|
1384
|
+
acc.push(item);
|
|
1385
|
+
return acc;
|
|
1386
|
+
} // Ignore any hidden items
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
if (item.props && item.props.hidden) {
|
|
1390
|
+
return acc;
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
if (item.props.selected && !item.props.disabled && _this.firstSelectedOptionIndex == null) {
|
|
1394
|
+
_this.firstSelectedOptionIndex = _this.availableOptionCount;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
var active = _this.availableOptionCount === _this.state.activeIndex;
|
|
1398
|
+
_this.availableOptionCount += 1;
|
|
1399
|
+
_this.selectedOptionCount += item.props.selected ? 1 : 0;
|
|
1400
|
+
|
|
1401
|
+
if (!active || !textHasFocus) {
|
|
1402
|
+
acc.push(item);
|
|
1403
|
+
return acc;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
if (!item.props.disabled) {
|
|
1407
|
+
_this.activeValue = item.props.value;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
var clonedItem = /*#__PURE__*/Object(external_react_["cloneElement"])(item, {
|
|
1411
|
+
active: active,
|
|
1412
|
+
id: _this.activeItemId,
|
|
1413
|
+
ref: _this.handleActiveOptionMount
|
|
1414
|
+
});
|
|
1415
|
+
acc.push(clonedItem);
|
|
1416
|
+
return acc;
|
|
1417
|
+
}, []);
|
|
1418
|
+
_this.displayedValues = children.reduce(function (acc, item) {
|
|
1419
|
+
if (isOption(item)) {
|
|
1420
|
+
acc.push(item.props.value);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
return acc;
|
|
1424
|
+
}, []);
|
|
1425
|
+
return children;
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
_defineProperty(_assertThisInitialized(_this), "wrapLabel", function (_ref3) {
|
|
1429
|
+
var prefixLabel = _ref3.prefixLabel,
|
|
1430
|
+
label = _ref3.label,
|
|
1431
|
+
suffixLabel = _ref3.suffixLabel;
|
|
1432
|
+
var wrappedLabel = label;
|
|
1433
|
+
|
|
1434
|
+
if (prefixLabel) {
|
|
1435
|
+
wrappedLabel = ["".concat(prefixLabel, ": ")].concat(wrappedLabel);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
if (suffixLabel) {
|
|
1439
|
+
wrappedLabel = Object(external_lodash_["castArray"])(wrappedLabel).concat(" ".concat(suffixLabel));
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
return wrappedLabel;
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
_this.state = {
|
|
1446
|
+
activeIndex: 0,
|
|
1447
|
+
filterKeyword: '',
|
|
1448
|
+
open: false,
|
|
1449
|
+
textHasFocus: false,
|
|
1450
|
+
topValues: [],
|
|
1451
|
+
values: props.defaultValues || []
|
|
1452
|
+
};
|
|
1453
|
+
_this.controlledExternally = Object(external_lodash_["has"])(props, 'values');
|
|
1454
|
+
_this.displayedValues = [];
|
|
1455
|
+
_this.availableOptionCount = 0;
|
|
1456
|
+
_this.firstSelectedOptionIndex = undefined;
|
|
1457
|
+
_this.selectedOptionCount = 0;
|
|
1458
|
+
|
|
1459
|
+
if (false) {}
|
|
1460
|
+
|
|
1461
|
+
if (false) {}
|
|
1462
|
+
|
|
1463
|
+
SelectBase.validateAppearance(props);
|
|
1464
|
+
_this.menuId = Object(id_["createDOMID"])('menu');
|
|
1465
|
+
_this.activeItemId = Object(id_["createDOMID"])('active-item');
|
|
1466
|
+
return _this;
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
_createClass(SelectBase, [{
|
|
1470
|
+
key: "componentDidUpdate",
|
|
1471
|
+
value: function componentDidUpdate(prevProps) {
|
|
1472
|
+
if (false) {}
|
|
1473
|
+
|
|
1474
|
+
if (false) {}
|
|
1475
|
+
|
|
1476
|
+
SelectBase.validateAppearance(this.props);
|
|
1477
|
+
}
|
|
1478
|
+
}, {
|
|
1479
|
+
key: "getCurrentValues",
|
|
1480
|
+
value: function getCurrentValues() {
|
|
1481
|
+
var values = this.isControlled() ? this.props.values : this.state.values;
|
|
1482
|
+
return this.props.multiple || values == null ? values : values.slice(0, 1);
|
|
1483
|
+
}
|
|
1484
|
+
}, {
|
|
1485
|
+
key: "isControlled",
|
|
1486
|
+
value: function isControlled() {
|
|
1487
|
+
return this.controlledExternally;
|
|
1488
|
+
}
|
|
1489
|
+
}, {
|
|
1490
|
+
key: "hasFilter",
|
|
1491
|
+
value: function hasFilter() {
|
|
1492
|
+
return !!this.props.filter;
|
|
1493
|
+
}
|
|
1494
|
+
}, {
|
|
1495
|
+
key: "toggleValue",
|
|
1496
|
+
value: function toggleValue(e, value) {
|
|
1497
|
+
var _this$getCurrentValue4, _this$props$onChange3, _this$props12;
|
|
1498
|
+
|
|
1499
|
+
var values = (_this$getCurrentValue4 = this.getCurrentValues()) !== null && _this$getCurrentValue4 !== void 0 ? _this$getCurrentValue4 : [];
|
|
1500
|
+
var currentIndex = values.indexOf(value);
|
|
1501
|
+
var _this$props11 = this.props,
|
|
1502
|
+
name = _this$props11.name,
|
|
1503
|
+
multiple = _this$props11.multiple;
|
|
1504
|
+
var newValues;
|
|
1505
|
+
|
|
1506
|
+
if (multiple) {
|
|
1507
|
+
if (currentIndex >= 0) {
|
|
1508
|
+
newValues = [].concat(_toConsumableArray(values.slice(0, currentIndex)), _toConsumableArray(values.slice(currentIndex + 1)));
|
|
1509
|
+
} else {
|
|
1510
|
+
newValues = values.concat([value]);
|
|
1511
|
+
}
|
|
1512
|
+
} else {
|
|
1513
|
+
// non-multiple mode must always have a value
|
|
1514
|
+
newValues = [value];
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
var uncontrolled = !this.isControlled();
|
|
1518
|
+
|
|
1519
|
+
if (uncontrolled) {
|
|
1520
|
+
this.setState({
|
|
1521
|
+
values: newValues
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
if (multiple) {
|
|
1526
|
+
// in uncontrolled multiple mode, keep the menu open
|
|
1527
|
+
if (uncontrolled) {
|
|
1528
|
+
this.setState({
|
|
1529
|
+
open: true
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
} else {
|
|
1533
|
+
// non-multiple mode only supports a single selection
|
|
1534
|
+
// so close the menu once a selection is made
|
|
1535
|
+
this.handleRequestClose({
|
|
1536
|
+
reason: 'contentClick'
|
|
1537
|
+
});
|
|
1538
|
+
this.focus();
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
(_this$props$onChange3 = (_this$props12 = this.props).onChange) === null || _this$props$onChange3 === void 0 ? void 0 : _this$props$onChange3.call(_this$props12, e, {
|
|
1542
|
+
values: newValues,
|
|
1543
|
+
name: name
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Place focus on the toggle.
|
|
1548
|
+
*/
|
|
1549
|
+
|
|
1550
|
+
}, {
|
|
1551
|
+
key: "focus",
|
|
1552
|
+
value: function focus() {
|
|
1553
|
+
var _this$dropdown;
|
|
1554
|
+
|
|
1555
|
+
(_this$dropdown = this.dropdown) === null || _this$dropdown === void 0 ? void 0 : _this$dropdown.focus();
|
|
1556
|
+
}
|
|
1557
|
+
}, {
|
|
1558
|
+
key: "renderControls",
|
|
1559
|
+
value: function renderControls(_ref4) {
|
|
1560
|
+
var hasChildren = _ref4.hasChildren,
|
|
1561
|
+
placement = _ref4.placement;
|
|
1562
|
+
var filterKeyword = this.state.filterKeyword;
|
|
1563
|
+
var _this$props13 = this.props,
|
|
1564
|
+
inputId = _this$props13.inputId,
|
|
1565
|
+
inputRef = _this$props13.inputRef,
|
|
1566
|
+
multiple = _this$props13.multiple; // only visually disable these as opposed to fully disabling to avoid losing keyboard focus - see SUI-2731
|
|
1567
|
+
|
|
1568
|
+
var selectControls = /*#__PURE__*/external_react_default.a.createElement(StyledToggleAllControls, {
|
|
1569
|
+
$placement: placement,
|
|
1570
|
+
key: "selectAll"
|
|
1571
|
+
}, /*#__PURE__*/external_react_default.a.createElement(StyledControlsLink, {
|
|
1572
|
+
$disabled: !(this.availableOptionCount - this.selectedOptionCount),
|
|
1573
|
+
onClick: this.handleSelectAll,
|
|
1574
|
+
"data-test": "select-all",
|
|
1575
|
+
style: {
|
|
1576
|
+
marginRight: 20
|
|
1577
|
+
}
|
|
1578
|
+
}, filterKeyword ? Object(i18n_["_"])('Select All Matches') : Object(i18n_["_"])('Select All')), /*#__PURE__*/external_react_default.a.createElement(StyledControlsLink, {
|
|
1579
|
+
$disabled: !this.selectedOptionCount,
|
|
1580
|
+
onClick: this.handleClearAll,
|
|
1581
|
+
"data-test": "clear-all"
|
|
1582
|
+
}, filterKeyword ? Object(i18n_["_"])('Clear All Matches') : Object(i18n_["_"])('Clear All')));
|
|
1583
|
+
return this.hasFilter() && /*#__PURE__*/external_react_default.a.createElement("div", {
|
|
1584
|
+
key: "controls"
|
|
1585
|
+
}, /*#__PURE__*/external_react_default.a.createElement(StyledFilter, {
|
|
1586
|
+
key: "filter",
|
|
1587
|
+
"data-test": "filter"
|
|
1588
|
+
}, /*#__PURE__*/external_react_default.a.createElement(Text_default.a, {
|
|
1589
|
+
value: filterKeyword,
|
|
1590
|
+
appearance: "search",
|
|
1591
|
+
autoCapitalize: "off",
|
|
1592
|
+
autoComplete: "off",
|
|
1593
|
+
autoCorrect: "off",
|
|
1594
|
+
spellCheck: false,
|
|
1595
|
+
onChange: this.handleTextChange,
|
|
1596
|
+
onKeyDown: this.handleTextKeyDown,
|
|
1597
|
+
onFocus: this.handleTextFocus,
|
|
1598
|
+
onBlur: this.handleTextBlur,
|
|
1599
|
+
placeholder: Object(i18n_["_"])('filter'),
|
|
1600
|
+
role: "combobox",
|
|
1601
|
+
"aria-expanded": "true",
|
|
1602
|
+
"aria-label": Object(i18n_["_"])('Filter'),
|
|
1603
|
+
"aria-activedescendant": this.activeItemId,
|
|
1604
|
+
"aria-controls": this.menuId,
|
|
1605
|
+
inputRef: inputRef,
|
|
1606
|
+
inputId: inputId
|
|
1607
|
+
})), multiple && hasChildren && selectControls);
|
|
1608
|
+
}
|
|
1609
|
+
}, {
|
|
1610
|
+
key: "render",
|
|
1611
|
+
value: function render() {
|
|
1612
|
+
var _this$getCurrentValue5,
|
|
1613
|
+
_this2 = this;
|
|
1614
|
+
|
|
1615
|
+
var _this$props14 = this.props,
|
|
1616
|
+
appearance = _this$props14.appearance,
|
|
1617
|
+
children = _this$props14.children,
|
|
1618
|
+
defaultPlacement = _this$props14.defaultPlacement,
|
|
1619
|
+
describedBy = _this$props14.describedBy,
|
|
1620
|
+
disabled = _this$props14.disabled,
|
|
1621
|
+
elementRef = _this$props14.elementRef,
|
|
1622
|
+
error = _this$props14.error,
|
|
1623
|
+
inline = _this$props14.inline,
|
|
1624
|
+
inputId = _this$props14.inputId,
|
|
1625
|
+
labelledBy = _this$props14.labelledBy,
|
|
1626
|
+
labelText = _this$props14.labelText,
|
|
1627
|
+
multiple = _this$props14.multiple,
|
|
1628
|
+
placeholder = _this$props14.placeholder,
|
|
1629
|
+
prefixLabel = _this$props14.prefixLabel,
|
|
1630
|
+
suffixLabel = _this$props14.suffixLabel;
|
|
1631
|
+
var icon;
|
|
1632
|
+
var label;
|
|
1633
|
+
var filterEnabled = this.hasFilter();
|
|
1634
|
+
var isAnyValueSelected = false; // Generate buttonLabels
|
|
1635
|
+
|
|
1636
|
+
var childrenArray = external_react_["Children"].toArray(children);
|
|
1637
|
+
var currentValues = (_this$getCurrentValue5 = this.getCurrentValues()) !== null && _this$getCurrentValue5 !== void 0 ? _this$getCurrentValue5 : [];
|
|
1638
|
+
var valuesLabel = currentValues.reduce(function (acc, value, index, orig) {
|
|
1639
|
+
var matchedItem = Object(external_lodash_["find"])(childrenArray, function (item) {
|
|
1640
|
+
return isOption(item) && item.props.value === value;
|
|
1641
|
+
});
|
|
1642
|
+
|
|
1643
|
+
if (matchedItem) {
|
|
1644
|
+
acc.push(matchedItem.props.children || matchedItem.props.label); // if not in multiple mode, add the icon
|
|
1645
|
+
|
|
1646
|
+
if (!multiple && currentValues.length === 1) {
|
|
1647
|
+
icon = matchedItem.props.icon;
|
|
1648
|
+
}
|
|
1649
|
+
} else if (multiple) {
|
|
1650
|
+
// only add values that don't match an option in "multiple" mode to preserve old behaviour
|
|
1651
|
+
acc.push(value);
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
if (index < orig.length - 1) {
|
|
1655
|
+
acc.push(Object(i18n_["_"])(', '));
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
return acc;
|
|
1659
|
+
}, []);
|
|
1660
|
+
label = valuesLabel; // only apply prefix / suffix if the label is not empty
|
|
1661
|
+
|
|
1662
|
+
if (label.length > 0) {
|
|
1663
|
+
isAnyValueSelected = true;
|
|
1664
|
+
label = this.wrapLabel({
|
|
1665
|
+
prefixLabel: prefixLabel,
|
|
1666
|
+
label: label,
|
|
1667
|
+
suffixLabel: suffixLabel
|
|
1668
|
+
});
|
|
1669
|
+
} // single <Select> behaviour is to show the placeholder if all parts of the the label
|
|
1670
|
+
// are empty strings so we replicate this behaviour here
|
|
1671
|
+
|
|
1672
|
+
|
|
1673
|
+
if (label.length === 0 || !multiple && label.every(function (labelNode) {
|
|
1674
|
+
return labelNode === '';
|
|
1675
|
+
})) {
|
|
1676
|
+
label = [placeholder];
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
var ariaLabel = label; // If there's more than one item selected, read out the selected total
|
|
1680
|
+
// rather than reading out each selected item
|
|
1681
|
+
|
|
1682
|
+
if (label.length > 1) {
|
|
1683
|
+
ariaLabel = this.wrapLabel({
|
|
1684
|
+
prefixLabel: prefixLabel,
|
|
1685
|
+
label: ["".concat(currentValues.length, " items selected")],
|
|
1686
|
+
suffixLabel: suffixLabel
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
var finalChildren = this.createChildren();
|
|
1691
|
+
|
|
1692
|
+
var commonProps = _objectSpread({
|
|
1693
|
+
'aria-describedby': describedBy,
|
|
1694
|
+
'aria-label': "".concat(labelText ? "".concat(labelText, ", ") : '').concat(ariaLabel),
|
|
1695
|
+
'aria-labelledby': labelText ? undefined : labelledBy,
|
|
1696
|
+
'aria-multiselectable': multiple,
|
|
1697
|
+
'data-select-appearance': appearance,
|
|
1698
|
+
'data-test': multiple ? 'multiselect' : 'select',
|
|
1699
|
+
disabled: disabled,
|
|
1700
|
+
elementRef: elementRef,
|
|
1701
|
+
error: error
|
|
1702
|
+
}, Object(external_lodash_["omit"])(this.props, Object(external_lodash_["keys"])(SelectBase.propTypes)));
|
|
1703
|
+
|
|
1704
|
+
if (multiple) {
|
|
1705
|
+
commonProps['data-test-values'] = JSON.stringify(currentValues);
|
|
1706
|
+
} else {
|
|
1707
|
+
var _currentValues = _slicedToArray(currentValues, 1),
|
|
1708
|
+
dataTestValue = _currentValues[0];
|
|
1709
|
+
|
|
1710
|
+
commonProps['data-test-value'] = dataTestValue;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
var toggle = appearance === 'link' ? /*#__PURE__*/external_react_default.a.createElement(Link_default.a, _extends({}, commonProps, {
|
|
1714
|
+
"data-select-appearance": "link"
|
|
1715
|
+
}), !!icon && /*#__PURE__*/external_react_default.a.createElement(StyledLinkIcon, null, icon), label || placeholder, /*#__PURE__*/external_react_default.a.createElement(StyledLinkCaret, null, /*#__PURE__*/external_react_default.a.createElement(CaretDown["a" /* default */], {
|
|
1716
|
+
enterpriseSize: 0.5,
|
|
1717
|
+
prismaSize: "small"
|
|
1718
|
+
}))) : /*#__PURE__*/external_react_default.a.createElement(StyledButton, _extends({}, commonProps, {
|
|
1719
|
+
$multiple: multiple,
|
|
1720
|
+
appearance: appearance,
|
|
1721
|
+
label: label,
|
|
1722
|
+
error: error,
|
|
1723
|
+
icon: icon,
|
|
1724
|
+
inline: inline,
|
|
1725
|
+
isMenu: true,
|
|
1726
|
+
role: "listbox" // @ts-expect-error - accept inconsistency with Button
|
|
1727
|
+
,
|
|
1728
|
+
onClick: this.props.onClick
|
|
1729
|
+
}, Object(external_lodash_["pick"])(this.props, SelectBase.invalidLinkAppearanceProps)), !!currentValues.length && multiple && /*#__PURE__*/external_react_default.a.createElement(StyledCount, {
|
|
1730
|
+
"data-role": "count"
|
|
1731
|
+
}, "(", currentValues.length, ")"));
|
|
1732
|
+
|
|
1733
|
+
var createMenu = function createMenu(_ref5) {
|
|
1734
|
+
var anchorWidth = _ref5.anchorWidth,
|
|
1735
|
+
maxHeight = _ref5.maxHeight,
|
|
1736
|
+
placement = _ref5.placement;
|
|
1737
|
+
// preserve separate widths for single vs. multi mode
|
|
1738
|
+
var internalMenuStyle = _this2.props.multiple ? {
|
|
1739
|
+
width: Math.max(anchorWidth !== null && anchorWidth !== void 0 ? anchorWidth : 0, 200)
|
|
1740
|
+
} : {
|
|
1741
|
+
minWidth: anchorWidth !== null && anchorWidth !== void 0 ? anchorWidth : undefined,
|
|
1742
|
+
maxWidth: Math.max(anchorWidth !== null && anchorWidth !== void 0 ? anchorWidth : 0, 300)
|
|
1743
|
+
};
|
|
1744
|
+
return /*#__PURE__*/external_react_default.a.createElement(ResultsMenu_default.a, _extends({
|
|
1745
|
+
"aria-multiselectable": multiple,
|
|
1746
|
+
childrenStart: _this2.renderControls({
|
|
1747
|
+
placement: placement,
|
|
1748
|
+
hasChildren: !!finalChildren.length
|
|
1749
|
+
}),
|
|
1750
|
+
controlledExternally: _this2.hasFilter(),
|
|
1751
|
+
placement: placement !== null && placement !== void 0 ? placement : undefined,
|
|
1752
|
+
maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : undefined,
|
|
1753
|
+
onScrollBottom: _this2.props.onScrollBottom ? _this2.handleScrollBottom : undefined,
|
|
1754
|
+
"data-test": "results-menu",
|
|
1755
|
+
isLoading: _this2.props.isLoadingOptions,
|
|
1756
|
+
id: _this2.menuId
|
|
1757
|
+
}, Object(external_lodash_["pick"])(_this2.props, 'noOptionsMessage', 'footerMessage', 'animateLoading', 'loadingMessage'), {
|
|
1758
|
+
style: _objectSpread(_objectSpread({}, internalMenuStyle), _this2.props.menuStyle)
|
|
1759
|
+
}), finalChildren);
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
return /*#__PURE__*/external_react_default.a.createElement(Dropdown_default.a, {
|
|
1763
|
+
closeReasons: ['clickAway', 'escapeKey', 'offScreen', 'tabKey', 'toggleClick'],
|
|
1764
|
+
inputId: inputId,
|
|
1765
|
+
toggle: toggle,
|
|
1766
|
+
onRequestOpen: this.handleRequestOpen,
|
|
1767
|
+
onRequestClose: this.handleRequestClose,
|
|
1768
|
+
open: this.state.open,
|
|
1769
|
+
repositionMode: "flip",
|
|
1770
|
+
defaultPlacement: filterEnabled ? defaultPlacement : undefined,
|
|
1771
|
+
canCoverAnchor: window.innerHeight < 500,
|
|
1772
|
+
ref: function ref(c) {
|
|
1773
|
+
_this2.dropdown = c;
|
|
1774
|
+
},
|
|
1775
|
+
retainFocus: false,
|
|
1776
|
+
takeFocus: !isAnyValueSelected || !!filterEnabled
|
|
1777
|
+
}, createMenu);
|
|
1778
|
+
}
|
|
1779
|
+
}]);
|
|
1780
|
+
|
|
1781
|
+
return SelectBase;
|
|
1782
|
+
}(external_react_["Component"]);
|
|
1783
|
+
|
|
1784
|
+
_defineProperty(SelectBase_SelectBase, "propTypes", propTypes);
|
|
1785
|
+
|
|
1786
|
+
_defineProperty(SelectBase_SelectBase, "defaultProps", defaultProps);
|
|
1787
|
+
|
|
1788
|
+
_defineProperty(SelectBase_SelectBase, "Option", OptionBase["a" /* default */]);
|
|
1789
|
+
|
|
1790
|
+
_defineProperty(SelectBase_SelectBase, "Divider", Menu_["Divider"]);
|
|
1791
|
+
|
|
1792
|
+
_defineProperty(SelectBase_SelectBase, "Heading", Menu_["Heading"]);
|
|
1793
|
+
|
|
1794
|
+
_defineProperty(SelectBase_SelectBase, "invalidLinkAppearanceProps", ['append', 'error', 'prepend']);
|
|
1795
|
+
|
|
1796
|
+
/* harmony default export */ var Select_SelectBase = __webpack_exports__["c"] = (SelectBase_SelectBase);
|
|
1049
1797
|
|
|
1050
|
-
module.exports = require("@splunk/react-icons/Caret");
|
|
1051
1798
|
|
|
1052
1799
|
/***/ }),
|
|
1053
1800
|
|