@qualtrics/ui-react 2.11.0 → 2.12.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/__shared/cjs/index-1a8585e7.js +13058 -0
  3. package/dist/__shared/cjs/{index-30148ada.js → index-def941fc.js} +3 -3
  4. package/dist/components/Accordion/Accordion2.js +3 -3
  5. package/dist/components/Button/Button2.js +3 -3
  6. package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
  7. package/dist/components/Checkbox/Checkbox2.js +3 -3
  8. package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
  9. package/dist/components/ColorPicker/ColorPicker2.js +3 -3
  10. package/dist/components/Combobox/Combobox2.js +3 -3
  11. package/dist/components/ConfigPane/ConfigPane2.js +3 -3
  12. package/dist/components/Divider/Divider2.js +3 -3
  13. package/dist/components/Dropdown/Dropdown2.js +3 -3
  14. package/dist/components/FilePicker/FilePicker2.js +3 -3
  15. package/dist/components/FormField/Caption.js +3 -3
  16. package/dist/components/FormField/FormField2.js +3 -3
  17. package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
  18. package/dist/components/IconButton/IconButton2.js +3 -3
  19. package/dist/components/InlineInput/InlineInput2.js +3 -3
  20. package/dist/components/Input/Input2.js +3 -3
  21. package/dist/components/InputGroup/InputGroup2.js +3 -3
  22. package/dist/components/Label/Label2.js +3 -3
  23. package/dist/components/Link/Link2.js +3 -3
  24. package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
  25. package/dist/components/LogicEditor/LogicEditor2.js +3 -3
  26. package/dist/components/Modal/Modal2.js +3 -3
  27. package/dist/components/NewMenu/BaseMenu.js +0 -1
  28. package/dist/components/NewMenu/NewMenu.js +3 -3
  29. package/dist/components/NewMenu/parts/ArrowNav/ArrowNav.js +5 -9
  30. package/dist/components/NumberStepper/NumberStepper2.js +3 -3
  31. package/dist/components/PageLayout/PageLayout.js +3 -3
  32. package/dist/components/Pagination/Pagination2.js +3 -3
  33. package/dist/components/Popover/Popover2.js +3 -3
  34. package/dist/components/QuickSearch/QuickSearch2.js +3 -3
  35. package/dist/components/Radio/Radio2.js +3 -3
  36. package/dist/components/SearchInput/SearchInput2.js +3 -3
  37. package/dist/components/SidebarNav/SidebarNav2.js +3 -3
  38. package/dist/components/Slider/Slider2.js +3 -3
  39. package/dist/components/Switch/Switch2.js +3 -3
  40. package/dist/components/Table/Table2.js +3 -3
  41. package/dist/components/Tabs/Tabs2.js +3 -3
  42. package/dist/components/Tooltip/Tooltip2.js +3 -3
  43. package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
  44. package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
  45. package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
  46. package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
  47. package/dist/hooks/useOverlay/useOverlay2.js +3 -3
  48. package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
  49. package/dist/icons/Icon.js +3 -3
  50. package/dist/icons/index.js +1 -1
  51. package/dist/index.es.js +1 -1
  52. package/dist/index.js +83 -8442
  53. package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
  54. package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
  55. package/dist/next/Combobox/Combobox2.js +3 -3
  56. package/dist/next/Combobox/ComboboxInput.js +3 -1
  57. package/dist/next/Combobox/ComboboxOption.js +1 -0
  58. package/dist/next/Drawer/Drawer2.js +3 -3
  59. package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
  60. package/dist/next/Input/Input2.js +3 -3
  61. package/dist/next/Menu/Menu2.js +3 -3
  62. package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
  63. package/dist/next/SplitButton/SplitButton2.js +3 -3
  64. package/dist/next/TimePicker/TimeDropdown.js +78 -0
  65. package/dist/next/TimePicker/TimeInput.js +87 -0
  66. package/dist/next/TimePicker/TimePicker.js +247 -0
  67. package/dist/next/TimePicker/TimePicker2.js +8 -0
  68. package/dist/next/TimePicker/TimePickerIcon.js +36 -0
  69. package/dist/next/TimePicker/index.js +1 -0
  70. package/dist/next/TimePicker/utils.js +229 -0
  71. package/dist/next/index.d.ts +20 -0
  72. package/dist/next/index.es.js +2 -0
  73. package/dist/next/index.js +807 -163
  74. package/dist/utils/Flyout/Flyout2.js +3 -3
  75. package/dist/utils/keyboardUser/keyboardUser.js +1 -1
  76. package/package.json +2 -2
  77. package/dist/__shared/cjs/index-bb7befc3.js +0 -4656
@@ -1,4656 +0,0 @@
1
- 'use strict';
2
-
3
- var _extends = require('@babel/runtime-corejs3/helpers/extends');
4
- var React = require('react');
5
- var classNames = require('classnames');
6
- var icons_index = require('./index-30148ada.js');
7
- var _includesInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/includes');
8
- var reactPopper = require('react-popper');
9
- var core = require('@popperjs/core');
10
- var ReactFocusLock = require('react-focus-lock');
11
- var ReactDOM = require('react-dom');
12
- var uuid = require('uuid');
13
- var useResizeObserver$1 = require('@react-hook/resize-observer');
14
-
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
-
17
- var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
18
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
- var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
20
- var _includesInstanceProperty__default = /*#__PURE__*/_interopDefaultLegacy(_includesInstanceProperty);
21
- var ReactFocusLock__default = /*#__PURE__*/_interopDefaultLegacy(ReactFocusLock);
22
- var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
23
- var useResizeObserver__default = /*#__PURE__*/_interopDefaultLegacy(useResizeObserver$1);
24
-
25
- /**
26
- * Determinines if DOM functions are available. Typically used to determine if rendering is happening client-side or server-side.
27
- * @returns A boolean indicating if the DOM is available.
28
- */
29
- function canUseDOM() {
30
- return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
31
- }
32
-
33
- /**
34
- * Returns a string of ids where each id is separated by a space.
35
- * @param ids - A list of element ids (each id is a parameter).
36
- * @returns A string of space separated ids, or undefined.
37
- */
38
- function concatIds() {
39
- for (var _len = arguments.length, ids = new Array(_len), _key = 0; _key < _len; _key++) {
40
- ids[_key] = arguments[_key];
41
- }
42
-
43
- return ids.filter(id => typeof id === 'string').join(' ') || undefined;
44
- }
45
-
46
- /* eslint-disable no-underscore-dangle */
47
-
48
- function _filterChildren(children) {
49
- let queries = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
50
- let matchesList = arguments.length > 2 ? arguments[2] : undefined;
51
-
52
- // TODO: Add `React.isValidElement` check here and then update types in helper functions to be `ReactElement` instead of `ReactNode`. This likely will require some sort of change in `Combobox` v1.
53
- // Single ReactChild
54
- if (React__default["default"].Children.count(children) === 1 && !Array.isArray(children)) {
55
- return _findMatch(children, queries, matchesList);
56
- } // Array of ReactChild
57
-
58
-
59
- return React__default["default"].Children.map(children, child => _findMatch(child, queries, matchesList));
60
- } // Returns ReactChild
61
-
62
-
63
- function _findMatch(child, queries, matchesList) {
64
- var _newChild, _newChild$props;
65
-
66
- let newChild = child;
67
- let foundMatch = false;
68
- let i;
69
-
70
- for (i = 0; i < queries.length; i += 1) {
71
- const {
72
- matcher,
73
- modifier = c => c
74
- } = queries[i];
75
-
76
- if (matcher(child)) {
77
- newChild = modifier(child, matchesList[i].length, matchesList);
78
- foundMatch = true;
79
- break;
80
- }
81
- }
82
-
83
- if ((_newChild = newChild) !== null && _newChild !== void 0 && (_newChild$props = _newChild.props) !== null && _newChild$props !== void 0 && _newChild$props.children) {
84
- const modifiedChildren = _filterChildren(newChild.props.children, queries, matchesList);
85
-
86
- newChild = /*#__PURE__*/React__default["default"].cloneElement(newChild, {
87
- children: modifiedChildren
88
- });
89
- }
90
-
91
- if (foundMatch && newChild) {
92
- matchesList[i].push(newChild);
93
- }
94
-
95
- return newChild;
96
- } // [ReactNode[], ReactNode[][]]
97
-
98
-
99
- function filterChildren(children, queries) {
100
- const matchesList = queries.map(() => []);
101
- return [_filterChildren(children, queries, matchesList), matchesList];
102
- }
103
-
104
- var css_248z$g = "._lXomS{background-color:#fff;border-radius:4px;border:4px solid transparent;border-right:none;border-left:none;box-shadow:0 0 0 1px #eee,0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;max-width:500px;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._31gh3{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;cursor:pointer;font-size:14px;color:#32363a;word-break:break-word;outline:none}._31gh3._1wLfG,._31gh3._2c_7I._31gh3:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._31gh3._9DVzX{background-color:#ebf3fb;font-weight:500;font-family:\"72Duplex\",\"72\",\"Helvetica Neue\",Helvetica,Arial,sans-serif}._31gh3._9DVzX._1wLfG,._31gh3._9DVzX._2c_7I._31gh3._9DVzX:hover{background-color:#e4effa}._31gh3:active:not(._9DVzX):not([aria-disabled=true]){background-color:#e8e9e9}._1jjmm ._25Ccz{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;font-size:12px;color:#32363a;font-weight:700;word-break:break-word}._1jjmm ._3dU_a{display:none}._1jjmm:not(:first-child) ._3dU_a{display:block;margin:3.5px 0}._3HRjg{width:100%;height:40px}";
105
- var styles$c = {"flyout":"_lXomS","flyoutOption":"_31gh3","highlighted":"_1wLfG","hoverHighlight":"_2c_7I","selected":"_9DVzX","flyoutHeader":"_1jjmm","headerContent":"_25Ccz","headerDivider":"_3dU_a","flyoutSpinner":"_3HRjg"};
106
- var stylesheet$g="._lXomS{background-color:#fff;border-radius:4px;border:4px solid transparent;border-right:none;border-left:none;box-shadow:0 0 0 1px #eee,0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000;max-width:500px;overflow-x:hidden;overflow-y:auto;overflow:hidden auto}._31gh3{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;cursor:pointer;font-size:14px;color:#32363a;word-break:break-word;outline:none}._31gh3._1wLfG,._31gh3._2c_7I._31gh3:hover{background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._31gh3._9DVzX{background-color:#ebf3fb;font-weight:500;font-family:\"72Duplex\",\"72\",\"Helvetica Neue\",Helvetica,Arial,sans-serif}._31gh3._9DVzX._1wLfG,._31gh3._9DVzX._2c_7I._31gh3._9DVzX:hover{background-color:#e4effa}._31gh3:active:not(._9DVzX):not([aria-disabled=true]){background-color:#e8e9e9}._1jjmm ._25Ccz{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;font-size:12px;color:#32363a;font-weight:700;word-break:break-word}._1jjmm ._3dU_a{display:none}._1jjmm:not(:first-child) ._3dU_a{display:block;margin:3.5px 0}._3HRjg{width:100%;height:40px}";
107
- icons_index.styleInject(css_248z$g);
108
-
109
- var css_248z$f = "._NZO0D{position:relative;display:inline-block}._NZO0D._1cnLN{min-height:20px;min-width:20px}._NZO0D._2pVbV{min-height:25px;min-width:25px}._NZO0D._2iReD{min-height:40px;min-width:40px}._NZO0D._2aYWA{min-height:64px;min-width:64px}._NZO0D ._3p5Vt{display:inline-block;background-color:transparent;position:absolute;z-index:10;width:0;height:0;left:50%;bottom:50%;pointer-events:none}._NZO0D ._3p5Vt._19aZg{visibility:hidden}._NZO0D ._3p5Vt div{position:absolute;transform:rotate(20deg)}._NZO0D ._3p5Vt div div:nth-child(-n+9){background-color:#fff;transform-origin:0 0;-webkit-animation:_3p5Vt .8s linear infinite;animation:_3p5Vt .8s linear infinite}._NZO0D ._3p5Vt div div:nth-child(-n+9):after{content:\" \";display:block;position:absolute;top:5px;left:-1px;width:2px;height:10px;border-radius:20%;background:#000}._NZO0D ._3p5Vt div div:first-child{transform:rotate(20deg);-webkit-animation-delay:-.8s;animation-delay:-.8s}._NZO0D ._3p5Vt div div:nth-child(2){transform:rotate(60deg);-webkit-animation-delay:-.7s;animation-delay:-.7s}._NZO0D ._3p5Vt div div:nth-child(3){transform:rotate(100deg);-webkit-animation-delay:-.6s;animation-delay:-.6s}._NZO0D ._3p5Vt div div:nth-child(4){transform:rotate(140deg);-webkit-animation-delay:-.5s;animation-delay:-.5s}._NZO0D ._3p5Vt div div:nth-child(5){transform:rotate(180deg);-webkit-animation-delay:-.4s;animation-delay:-.4s}._NZO0D ._3p5Vt div div:nth-child(6){transform:rotate(220deg);-webkit-animation-delay:-.3s;animation-delay:-.3s}._NZO0D ._3p5Vt div div:nth-child(7){transform:rotate(260deg);-webkit-animation-delay:-.2s;animation-delay:-.2s}._NZO0D ._3p5Vt div div:nth-child(8){transform:rotate(300deg);-webkit-animation-delay:-.1s;animation-delay:-.1s}._NZO0D ._3p5Vt div div:nth-child(9){transform:rotate(340deg);-webkit-animation-delay:0s;animation-delay:0s}._NZO0D ._2aYWA div div:nth-child(-n+9):after{top:10px;left:-2px;width:4px;height:18px}._NZO0D ._1cnLN div div:nth-child(-n+9):after{top:2px;left:-1px;width:1.5px;height:6px}._NZO0D ._2pVbV div div:nth-child(-n+9):after{top:4px;left:-1px;width:2px;height:7px}._NZO0D ._3OCI7 div div:nth-child(-n+9):after{background:#fff}._NZO0D ._1ICH1{width:100%;height:100%}._NZO0D ._1ICH1._2YWx8{pointer-events:none}._NZO0D ._1ICH1._19aZg{opacity:0}._NZO0D ._1ICH1._37bLj{opacity:.5}@-webkit-keyframes _3p5Vt{0%{opacity:1}to{opacity:0}}@keyframes _3p5Vt{0%{opacity:1}to{opacity:0}}";
110
- var styles$b = {"spinnerContainer":"_NZO0D","xs":"_1cnLN","small":"_2pVbV","medium":"_2iReD","large":"_2aYWA","spinnerComponent":"_3p5Vt","hide":"_19aZg","inverted":"_3OCI7","spinnerContent":"_1ICH1","disablePointerEvents":"_2YWx8","fade":"_37bLj"};
111
- var stylesheet$f="._NZO0D{position:relative;display:inline-block}._NZO0D._1cnLN{min-height:20px;min-width:20px}._NZO0D._2pVbV{min-height:25px;min-width:25px}._NZO0D._2iReD{min-height:40px;min-width:40px}._NZO0D._2aYWA{min-height:64px;min-width:64px}._NZO0D ._3p5Vt{display:inline-block;background-color:transparent;position:absolute;z-index:10;width:0;height:0;left:50%;bottom:50%;pointer-events:none}._NZO0D ._3p5Vt._19aZg{visibility:hidden}._NZO0D ._3p5Vt div{position:absolute;transform:rotate(20deg)}._NZO0D ._3p5Vt div div:nth-child(-n+9){background-color:#fff;transform-origin:0 0;-webkit-animation:_3p5Vt .8s linear infinite;animation:_3p5Vt .8s linear infinite}._NZO0D ._3p5Vt div div:nth-child(-n+9):after{content:\" \";display:block;position:absolute;top:5px;left:-1px;width:2px;height:10px;border-radius:20%;background:#000}._NZO0D ._3p5Vt div div:first-child{transform:rotate(20deg);-webkit-animation-delay:-.8s;animation-delay:-.8s}._NZO0D ._3p5Vt div div:nth-child(2){transform:rotate(60deg);-webkit-animation-delay:-.7s;animation-delay:-.7s}._NZO0D ._3p5Vt div div:nth-child(3){transform:rotate(100deg);-webkit-animation-delay:-.6s;animation-delay:-.6s}._NZO0D ._3p5Vt div div:nth-child(4){transform:rotate(140deg);-webkit-animation-delay:-.5s;animation-delay:-.5s}._NZO0D ._3p5Vt div div:nth-child(5){transform:rotate(180deg);-webkit-animation-delay:-.4s;animation-delay:-.4s}._NZO0D ._3p5Vt div div:nth-child(6){transform:rotate(220deg);-webkit-animation-delay:-.3s;animation-delay:-.3s}._NZO0D ._3p5Vt div div:nth-child(7){transform:rotate(260deg);-webkit-animation-delay:-.2s;animation-delay:-.2s}._NZO0D ._3p5Vt div div:nth-child(8){transform:rotate(300deg);-webkit-animation-delay:-.1s;animation-delay:-.1s}._NZO0D ._3p5Vt div div:nth-child(9){transform:rotate(340deg);-webkit-animation-delay:0s;animation-delay:0s}._NZO0D ._2aYWA div div:nth-child(-n+9):after{top:10px;left:-2px;width:4px;height:18px}._NZO0D ._1cnLN div div:nth-child(-n+9):after{top:2px;left:-1px;width:1.5px;height:6px}._NZO0D ._2pVbV div div:nth-child(-n+9):after{top:4px;left:-1px;width:2px;height:7px}._NZO0D ._3OCI7 div div:nth-child(-n+9):after{background:#fff}._NZO0D ._1ICH1{width:100%;height:100%}._NZO0D ._1ICH1._2YWx8{pointer-events:none}._NZO0D ._1ICH1._19aZg{opacity:0}._NZO0D ._1ICH1._37bLj{opacity:.5}@-webkit-keyframes _3p5Vt{0%{opacity:1}to{opacity:0}}@keyframes _3p5Vt{0%{opacity:1}to{opacity:0}}";
112
- icons_index.styleInject(css_248z$f);
113
-
114
- /* DO NOT MODIFY - THIS IS AN AUTO-GENERATED FILE */
115
- var FALLBACK_LOCALIZED_TEXT = {
116
- "filePicker.single": "Choose file",
117
- "filePicker.multiple": "Choose files",
118
- "logicEditor.all": "All of the following are true",
119
- "logicEditor.any": "Any of the following are true",
120
- "logicEditor.insertConditionBelow": "Insert condition below",
121
- "logicEditor.insertSetBelow": "Insert condition set below",
122
- "logicEditor.delete": "Delete",
123
- "logicEditor.conditionActions": "Condition actions",
124
- "menu.noItemsToDisplay": "No items to display",
125
- "pagination": "{{currentPage}} of {{numPages}}",
126
- "previousPage": "Previous Page",
127
- "nextPage": "Next Page",
128
- "searchText": "Search...",
129
- "clearSearchInput": "Clear search input",
130
- "noMatchesFound": "No matches found",
131
- "close": "Close",
132
- "configPane.showPanel": "Show panel",
133
- "configPane.hidePanel": "Hide panel",
134
- "configPane.pinPanel": "Pin panel",
135
- "configPane.unpinPanel": "Unpin panel",
136
- "increment": "Increment",
137
- "decrement": "Decrement",
138
- "collapsibleSearchInput.openSearchField": "Open Search Field",
139
- "toolbar.showToolbar": "Show Toolbar",
140
- "toolbar.hideToolbar": "Hide Toolbar",
141
- "showPanel": "Show Panel",
142
- "hidePanel": "Hide Panel",
143
- "showLabels": "Show Labels",
144
- "hideLabels": "Hide Labels",
145
- "loading": "Loading",
146
- "colorPickerAnchorDesc": "Open color customization menu. Current color: {{colorName}} {{colorHex}}",
147
- "saturation": "saturation",
148
- "slider2D": "2-dimensional slider",
149
- "saturationPercent": "saturation: {{hsvSaturation}}%",
150
- "valuePercent": "value: {{hsvValue}}%",
151
- "hue": "hue",
152
- "degrees": "{{hue}} degrees",
153
- "alpha": "opacity",
154
- "hex": "hex",
155
- "redChannel": "red channel",
156
- "greenChannel": "green channel",
157
- "blueChannel": "blue channel",
158
- "alphaChannel": "alpha channel",
159
- "palette": "color palette",
160
- "selectColor": "select color",
161
- "checked": "checked",
162
- "unchecked": "unchecked",
163
- "mixed": "mixed",
164
- "advancedTable.arrowKeyDescription": "To navigate between rows and cells, use the arrow keys.",
165
- "advancedTable.rowActionDescription": "To select a row, click or press enter.",
166
- "advancedTable.rowCheckboxDescription": "To check or uncheck a row for bulk actions, press space.",
167
- "advancedTable.pinColumn": "Pin column",
168
- "advancedTable.unpinColumn": "Unpin column",
169
- "advancedTable.moveColumnLeft": "Move column left",
170
- "advancedTable.moveColumnRight": "Move column right",
171
- "advancedTable.expandRow": "Expand row",
172
- "advancedTable.collapseRow": "Collapse row",
173
- "readOnly": "Read only",
174
- "newOptionsLoading": "New options loading.",
175
- "newOptionsLoaded": "New options loaded.",
176
- "locked": "Locked"
177
- };
178
-
179
- function createContextUtilities(defaultValue) {
180
- const context = /*#__PURE__*/React.createContext(defaultValue);
181
-
182
- const useContextWrapper = () => {
183
- const value = React.useContext(context);
184
-
185
- if (value === undefined) {
186
- throw new Error('useContext must be called inside a provider or be initialized with a default value');
187
- }
188
-
189
- return value;
190
- };
191
-
192
- return {
193
- Provider: context.Provider,
194
- // asserting so `undefined` can't be passed to provider
195
- useContext: useContextWrapper
196
- };
197
- }
198
-
199
- const fallbackLocalizedText = FALLBACK_LOCALIZED_TEXT;
200
- const {
201
- Provider: TranslationContextProvider,
202
- useContext: useTranslationContext
203
- } = createContextUtilities({
204
- localizedText: {}
205
- });
206
-
207
- const TranslationProvider = _ref => {
208
- let {
209
- localizedText,
210
- children
211
- } = _ref;
212
- const translationContext = React.useMemo(() => ({
213
- localizedText
214
- }), [localizedText]);
215
- return /*#__PURE__*/React__default["default"].createElement(TranslationContextProvider, {
216
- value: translationContext
217
- }, children);
218
- };
219
-
220
- function insertPlaceholders(message, placeholders) {
221
- const PLACEHOLDER_REGEX = /({{[a-zA-Z0-9]+}})/g;
222
- const parts = message.split(PLACEHOLDER_REGEX).filter(Boolean);
223
- return parts.map(part => {
224
- if (part.match(PLACEHOLDER_REGEX)) {
225
- const key = part.replace(/[{}]+/g, '');
226
- return placeholders[key];
227
- }
228
-
229
- return part;
230
- });
231
- }
232
-
233
- function isClassComponent(component) {
234
- return !!(typeof component === 'function' && !!component.prototype.isReactComponent);
235
- }
236
-
237
- function isFunctionComponent(component) {
238
- var _context;
239
-
240
- return !!(typeof component === 'function' && _includesInstanceProperty__default["default"](_context = String(component)).call(_context, 'return React.createElement'));
241
- }
242
-
243
- function isReactComponent(component) {
244
- return !!(isClassComponent(component) || isFunctionComponent(component));
245
- }
246
- /**
247
- * Indicates if one or more translation placeholders are a React component or element.
248
- * @param placeholders - The translation string placeholders.
249
- * @returns - True if at least one placeholder is a React component or element; otherwise false.
250
- */
251
-
252
-
253
- function containsComponentOrElement(placeholders) {
254
- return Object.keys(placeholders).some(key => isReactComponent(placeholders[key]) || /*#__PURE__*/React.isValidElement(placeholders[key]));
255
- }
256
-
257
- /* eslint-disable babel/no-unused-expressions */
258
-
259
- const NO_LOCALIZED_TEXT_FOR_KEY = key => "There is no localized text for KEY: ".concat(key, ". Defaulting to fallback text");
260
-
261
- const NO_LOCALIZED_OR_FALLBACK_TEXT_FOR_KEY = key => "There is no localized or fallback text for KEY: ".concat(key, ". \n Please refer to https://designsystem.qualtrics.com/localization for more information about localizing Qualtrics ui-react components");
262
-
263
- const USETRANSLATION_PLACEHOLDER_CONTAINS_ELEMENT = 'The useTranslation function cannot include React elements as placeholders.';
264
- const HAS_ERROR_BEEN_LOGGED_FOR_KEY = new Set();
265
- /**
266
- * Returns a translate function.
267
- * @returns A translate function.
268
- */
269
-
270
- const useTranslation = () => {
271
- const {
272
- localizedText
273
- } = useTranslationContext();
274
- /**
275
- * Returns a translated string given a key and placeholders.
276
- * @param key - The key of the translated string.
277
- * @param placeholders - A map of parameters to replace in the translated string. The string is searched for each key in the map wrapped by {{}} and then replaced with the corresponding value. *Placeholders can't be components. To use a component placeholder, use the `Translate` component.*
278
- * @returns The translated string if found; otherwise `##${translation-key}##`.
279
- */
280
-
281
- const translate = React.useCallback((key, placeholders) => {
282
- const translatedText = localizedText === null || localizedText === void 0 ? void 0 : localizedText[key];
283
- const fallbackText = fallbackLocalizedText[key];
284
-
285
- if (!translatedText && !HAS_ERROR_BEEN_LOGGED_FOR_KEY.has(key)) {
286
- HAS_ERROR_BEEN_LOGGED_FOR_KEY.add(key);
287
- fallbackText ? console.warn(NO_LOCALIZED_TEXT_FOR_KEY(key)) : console.warn(NO_LOCALIZED_OR_FALLBACK_TEXT_FOR_KEY(key));
288
- }
289
-
290
- const text = translatedText || fallbackText;
291
-
292
- if (text && placeholders) {
293
- if (containsComponentOrElement(placeholders)) {
294
- console.warn(USETRANSLATION_PLACEHOLDER_CONTAINS_ELEMENT);
295
- return '';
296
- }
297
-
298
- const compiledMessage = insertPlaceholders(text, placeholders);
299
- return compiledMessage.join('');
300
- }
301
-
302
- return text || "##".concat(key, "##");
303
- }, [localizedText]);
304
- return {
305
- translate
306
- };
307
- };
308
-
309
- /**
310
- * Gets the translated version of the given key.
311
- *
312
- * @param messageKey - The key to target from locale.
313
- * @param placeholders - A map of parameters to replace in the translated string. The string is searched for each key in the map wrapped by {{}} and then replaced with the corresponding value. If the value is a component, it must specify a key.
314
- * @return An array of components if `placeholders` contains a component. Otherwise a translated string.
315
- *
316
- * @example
317
- *
318
- * const translations = {
319
- * pagination: '{{currentPage}} of {{numPages}}'
320
- * }
321
- *
322
- * <Translate
323
- * messageKey="pagination"
324
- * placeholders={{ currentPage: 2, numPages: 5 }}
325
- * />
326
- *
327
- * Result:
328
- *
329
- * '2 of 5'
330
- *
331
- * @example
332
- *
333
- * const translations = {
334
- * pagination: '{{currentPage}} of {{numPages}}'
335
- * }
336
- *
337
- * <Translate
338
- * messageKey="pagination"
339
- * placeholders={{
340
- * currentPage: <span key="currentPage">2</span>,
341
- * numPages: 5
342
- * }}
343
- * />
344
- *
345
- * Result:
346
- *
347
- * [<span>2</span>, ' of ', '5']
348
- */
349
- const Translate = _ref => {
350
- let {
351
- messageKey,
352
- placeholders
353
- } = _ref;
354
- const {
355
- translate
356
- } = useTranslation();
357
- const text = translate(messageKey);
358
-
359
- if (placeholders) {
360
- const compiledMessage = insertPlaceholders(text, placeholders);
361
-
362
- if (containsComponentOrElement(placeholders)) {
363
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, insertPlaceholders(text, placeholders));
364
- }
365
-
366
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, compiledMessage.join(''));
367
- }
368
-
369
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, text);
370
- };
371
-
372
- const LoadingSpinner = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
373
- let {
374
- background = 'fade',
375
- children,
376
- className,
377
- inverted = false,
378
- show = false,
379
- size = 'medium',
380
- role = 'progressbar',
381
- 'aria-label': ariaLabel,
382
- 'aria-labelledby': ariaLabelledby,
383
- 'aria-live': ariaLive = 'polite',
384
- 'aria-hidden': ariaHidden,
385
- ...rest
386
- } = _ref;
387
- const {
388
- translate
389
- } = useTranslation();
390
- const defaultAriaLabel = translate('loading');
391
- return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
392
- ref: ref,
393
- className: classNames__default["default"](className, styles$b.spinnerContainer, {
394
- [styles$b[size]]: !children
395
- })
396
- }), /*#__PURE__*/React__default["default"].createElement("div", {
397
- className: classNames__default["default"](styles$b.spinnerComponent, styles$b[size], {
398
- [styles$b.inverted]: inverted,
399
- [styles$b.hide]: !show
400
- }),
401
- "data-loadingspinner": show || undefined,
402
- role: role,
403
- "aria-label": (ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : !ariaLabelledby) ? defaultAriaLabel : undefined,
404
- "aria-labelledby": ariaLabelledby,
405
- "aria-live": ariaLive,
406
- "aria-hidden": ariaHidden
407
- }, /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null), /*#__PURE__*/React__default["default"].createElement("div", null))), /*#__PURE__*/React__default["default"].createElement("div", {
408
- className: classNames__default["default"](styles$b.spinnerContent, {
409
- [styles$b[background]]: show,
410
- [styles$b.disablePointerEvents]: show
411
- })
412
- }, children));
413
- });
414
-
415
- // These default breakpoints are in ems, px equivalents are when font size is at default 16px
416
- const DEFAULT_BREAKPOINTS = {
417
- xs: 0,
418
- // 0px
419
- sm: 30,
420
- // 480px
421
- md: 48,
422
- // 768px
423
- lg: 64,
424
- // 1024px
425
- xl: 90 // 1440px
426
-
427
- };
428
- const POPPER_PLACEMENTS = ['top-start', 'top', 'top-end', 'right-start', 'right', 'right-end', 'bottom-start', 'bottom', 'bottom-end', 'left-start', 'left', 'left-end'];
429
- /* Popper offset documentation: https://popper.js.org/docs/v2/modifiers/offset/
430
- * Reminder that the 'placement' prop influences the direction of skidding and distance
431
- */
432
-
433
- const SUBMENU_POPPER_OFFSET = [0, 0];
434
- const FLYOUT_POPPER_OFFSET = [0, 6];
435
- const TOOLTIP_POPPER_OFFSET = [0, 12]; // Distance of 12 is 6px for the half of the arrow's hypotenuse + 6px for the actual distance
436
-
437
- const FOCUS_RING_WIDTH = 4;
438
-
439
- const Flyout = /*#__PURE__*/React.forwardRef((_ref, ref) => {
440
- let {
441
- children,
442
- anchorRef,
443
- className,
444
- isLoading = false,
445
- style,
446
- id,
447
- ...rest
448
- } = _ref;
449
- const {
450
- translate
451
- } = useTranslation();
452
- let content;
453
-
454
- if (isLoading) {
455
- content = /*#__PURE__*/React__default["default"].createElement("div", {
456
- id: "".concat(id, "-loading-spinner") // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
457
- ,
458
- role: "option" // `aria-selected` is omitted because this option is not selectable
459
-
460
- }, /*#__PURE__*/React__default["default"].createElement(LoadingSpinner, {
461
- "aria-label": translate('loading'),
462
- className: styles$c.flyoutSpinner,
463
- show: true,
464
- size: "small"
465
- }));
466
- } else {
467
- content = children;
468
- }
469
-
470
- return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
471
- id: id,
472
- className: classNames__default["default"](className, {
473
- [styles$c.flyout]: !!content
474
- }),
475
- ref: ref,
476
- role: "listbox",
477
- style: {
478
- // This logic is located here instead of DropdownList.js/ComboboxList.js so the maxHeight will update with screen resizing (Popper has a resize listener that causes this to rerender)
479
- maxHeight: Math.min(350, // half of window height - flyout popper offset - half of anchor height (fallback to default 18px)
480
- document.documentElement.clientHeight / 2 - FLYOUT_POPPER_OFFSET[1] - (anchorRef.current ? anchorRef.current.offsetHeight / 2 : 18)),
481
- ...style
482
- }
483
- }), content);
484
- });
485
-
486
- const FlyoutHeader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
487
- let {
488
- children,
489
- title,
490
- className,
491
- ...rest
492
- } = _ref;
493
- return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
494
- ref: ref,
495
- className: classNames__default["default"](className, styles$c.flyoutHeader),
496
- role: "group",
497
- "aria-label": title
498
- }), /*#__PURE__*/React__default["default"].createElement("div", {
499
- "aria-hidden": "true",
500
- className: styles$c.headerContent
501
- }, title), children);
502
- });
503
-
504
- const FlyoutOption = /*#__PURE__*/React.forwardRef((_ref, ref) => {
505
- let {
506
- children,
507
- className,
508
- isSelected = false,
509
- isHighlightedOnHover = false,
510
- isHighlighted = false,
511
- ...rest
512
- } = _ref;
513
- return (
514
- /*#__PURE__*/
515
- // eslint-disable-next-line jsx-a11y/interactive-supports-focus
516
- React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
517
- ref: ref,
518
- className: classNames__default["default"](className, styles$c.flyoutOption, {
519
- [styles$c.hoverHighlight]: isHighlightedOnHover,
520
- [styles$c.highlighted]: isHighlighted,
521
- [styles$c.selected]: isSelected
522
- }),
523
- role: "option",
524
- "aria-selected": isSelected
525
- }), children)
526
- );
527
- });
528
-
529
- /**
530
- * Generates a `data-testid` for a subcomponent given the parent's `data-testid` and the child's suffix.
531
- * @param dataTestId - The parent `data-testid`.
532
- * @param suffix - The string to be appended to the parent `data-testid` (with a `-` separator).
533
- * @returns The concatenated `data-testid`
534
- */
535
- function getSubDataTestId(dataTestId, suffix) {
536
- if (dataTestId) {
537
- return "".concat(dataTestId, "-").concat(suffix);
538
- }
539
-
540
- return undefined;
541
- }
542
-
543
- /* eslint-disable no-param-reassign */
544
-
545
- /**
546
- * Assigns the value from a callback ref to provided ref objects or passes the value to provided callback refs.
547
- * @param refs - A list of ref objects and/or ref callbacks to be assigned/called where each ref is an individual argument.
548
- */
549
- function mergeRefs() {
550
- for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
551
- refs[_key] = arguments[_key];
552
- }
553
-
554
- return value => {
555
- refs.forEach(ref => {
556
- if (typeof ref === 'function') {
557
- // Handles a callback ref
558
- ref(value);
559
- } else if (ref) {
560
- try {
561
- ref.current = value;
562
- } catch (error) {
563
- throw new Error("Cannot assign value \"".concat(value, "\" to ref \"").concat(ref, "\": ").concat(error));
564
- }
565
- }
566
- });
567
- };
568
- }
569
-
570
- var css_248z$e = "[data-popper-reference-hidden=true]{opacity:0;pointer-events:none}";
571
- var Popper$1 = {};
572
- var stylesheet$e="[data-popper-reference-hidden=true]{opacity:0;pointer-events:none}";
573
- icons_index.styleInject(css_248z$e);
574
-
575
- const {
576
- Provider,
577
- useContext: usePortalTarget
578
- } = createContextUtilities(typeof window !== 'undefined' ? document.body : null);
579
-
580
- const PortalTargetProvider = _ref => {
581
- let {
582
- target = null,
583
- children
584
- } = _ref;
585
- return /*#__PURE__*/React__default["default"].createElement(Provider, {
586
- value: target
587
- }, children);
588
- };
589
-
590
- const Portal = _ref => {
591
- let {
592
- children,
593
- portalTarget
594
- } = _ref;
595
- const [container, setContainer] = React.useState();
596
- const globalPortalTarget = usePortalTarget();
597
- React.useEffect(() => {
598
- const element = document.createElement('div');
599
- const target = portalTarget || globalPortalTarget || document.body;
600
- target.appendChild(element);
601
- setContainer(element);
602
- return () => {
603
- target.removeChild(element);
604
- };
605
- }, [portalTarget, globalPortalTarget]); // only render children once parent has been appended to DOM
606
-
607
- return container ? /*#__PURE__*/ReactDOM__default["default"].createPortal(children, container) : null;
608
- };
609
-
610
- const {
611
- Provider: PopperContextProvider,
612
- useContext: usePopperContext
613
- } = createContextUtilities({
614
- isParentAnchorHidden: false
615
- });
616
-
617
- var _process$env;
618
-
619
- function useMockedPopper(_, popperElement, _ref) {
620
- let {
621
- onFirstUpdate
622
- } = _ref;
623
- React.useEffect(() => {
624
- onFirstUpdate === null || onFirstUpdate === void 0 ? void 0 : onFirstUpdate();
625
- }, [onFirstUpdate, popperElement]);
626
- return {
627
- styles: {
628
- popper: {},
629
- arrow: {}
630
- },
631
- attributes: {
632
- popper: {}
633
- }
634
- };
635
- }
636
-
637
- const usePopper = typeof process !== 'undefined' && ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.NODE_ENV) === 'test' ? useMockedPopper : reactPopper.usePopper;
638
-
639
- function useResizeObserver(_ref2) {
640
- let {
641
- element,
642
- handleResize,
643
- isDisabled
644
- } = _ref2;
645
- React.useEffect(() => {
646
- if (typeof window.ResizeObserver !== 'undefined' && element && !isDisabled) {
647
- // eslint-disable-next-line compat/compat
648
- const resizeObserver = new ResizeObserver(handleResize);
649
- resizeObserver.observe(element);
650
- return () => {
651
- resizeObserver.disconnect();
652
- };
653
- }
654
- }, [handleResize, element, isDisabled]);
655
- }
656
-
657
- function useScroll(_ref3) {
658
- let {
659
- element,
660
- handleScroll,
661
- isDisabled
662
- } = _ref3;
663
- React.useEffect(() => {
664
- if (element && !isDisabled) {
665
- document.addEventListener('scroll', handleScroll, true); // useCapture needed since scroll events don't bubble to the document
666
-
667
- return () => {
668
- document.removeEventListener('scroll', handleScroll, true);
669
- };
670
- }
671
- }, [handleScroll, element, isDisabled]);
672
- }
673
-
674
- const Popper = _ref4 => {
675
- let {
676
- open = false,
677
- placement = core.bottom,
678
- anchor: anchorElement,
679
- popper: popperElement,
680
- arrow: arrowElement,
681
- anchorNode: externalAnchorNode,
682
- portalTarget,
683
- modifiers: externalModifiers = [],
684
- isDisabled = false,
685
- isFocusLocked = false,
686
- focusLockProps
687
- } = _ref4;
688
- const [anchorNode, setAnchorNode] = React.useState(externalAnchorNode);
689
- const [popperNode, setPopperNode] = React.useState();
690
- const [arrowNode, setArrowNode] = React.useState();
691
- const [isReady, setIsReady] = React.useState(false);
692
- React.useEffect(() => {
693
- if (externalAnchorNode) {
694
- setAnchorNode(externalAnchorNode);
695
- }
696
- }, [externalAnchorNode]);
697
- React.useEffect(() => {
698
- if (!open) {
699
- setIsReady(false);
700
- }
701
- }, [open]);
702
- const modifiers = [{
703
- name: 'arrow',
704
- enabled: !!arrowNode,
705
- options: {
706
- element: arrowNode,
707
- padding: 6
708
- }
709
- }, {
710
- name: 'eventListeners',
711
- enabled: open && !isDisabled
712
- }, {
713
- name: 'computeStyles',
714
- options: {
715
- gpuAcceleration: false
716
- }
717
- }, {
718
- name: 'preventOverflow',
719
- options: {
720
- padding: 8
721
- }
722
- }, ...externalModifiers]; // Must be memoized to avoid infinite loop
723
-
724
- const onFirstUpdate = React.useCallback(() => {
725
- setIsReady(true);
726
- }, [setIsReady]);
727
- const {
728
- styles,
729
- attributes,
730
- update
731
- } = usePopper(anchorNode, popperNode, {
732
- modifiers,
733
- placement,
734
- onFirstUpdate
735
- });
736
- const handleUpdate = React.useCallback(() => {
737
- update === null || update === void 0 ? void 0 : update();
738
- }, [update]); // Tell popper.js to update the positioning when the popper element changes size since it only listens for window resizing out of the box.
739
- // See CFE-1295
740
-
741
- useResizeObserver({
742
- element: popperNode,
743
- handleResize: handleUpdate,
744
- isDisabled: !isReady
745
- }); // Tell popper.js to update the positioning when a scroll event occurs
746
- // Needed due to https://github.com/floating-ui/floating-ui/issues/1267. See CFE-843
747
-
748
- useScroll({
749
- element: popperNode,
750
- handleScroll: handleUpdate,
751
- isDisabled: !isReady
752
- });
753
- const {
754
- isParentAnchorHidden
755
- } = usePopperContext();
756
- /*
757
- * If the parent anchor is hidden via CSS opacity, Popper will not consider it to be hidden.
758
- * To get around this issue, we set `data-popper-reference-hidden` to `true` for all child Popper elements if any ancestor Popper has `data-popper-reference-hidden` set to `true`.
759
- */
760
-
761
- const isAnchorHidden = React.useMemo(() => {
762
- var _attributes$popper;
763
-
764
- return isParentAnchorHidden || !!(attributes !== null && attributes !== void 0 && (_attributes$popper = attributes.popper) !== null && _attributes$popper !== void 0 && _attributes$popper['data-popper-reference-hidden']);
765
- }, [isParentAnchorHidden, attributes]);
766
- const context = React.useMemo(() => ({
767
- isParentAnchorHidden: isAnchorHidden
768
- }), [isAnchorHidden]);
769
- const popperElementWithArrow = /*#__PURE__*/React__default["default"].cloneElement(popperElement, {
770
- ref: mergeRefs(setPopperNode, popperElement.ref),
771
- style: { ...styles.popper,
772
- ...popperElement.props.style
773
- },
774
- ...attributes.popper,
775
- 'data-popper-reference-hidden': isAnchorHidden,
776
- 'data-popper-ready': isReady,
777
- children: arrowElement ? [popperElement.props.children, /*#__PURE__*/React__default["default"].cloneElement(arrowElement, {
778
- key: 'arrow',
779
- 'aria-hidden': true,
780
- ref: mergeRefs(setArrowNode, arrowElement.ref),
781
- style: { ...styles.arrow,
782
- ...arrowElement.props.style
783
- }
784
- })] : popperElement.props.children
785
- });
786
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, anchorElement && /*#__PURE__*/React__default["default"].cloneElement(anchorElement, {
787
- ref: mergeRefs(setAnchorNode, anchorElement.ref)
788
- }), /*#__PURE__*/React__default["default"].createElement(PopperContextProvider, {
789
- value: context
790
- }, /*#__PURE__*/React__default["default"].createElement(Portal, {
791
- portalTarget: portalTarget
792
- }, open ? isFocusLocked ? /*#__PURE__*/React__default["default"].createElement(ReactFocusLock__default["default"], _extends__default["default"]({}, focusLockProps, {
793
- disabled: isReady ? focusLockProps === null || focusLockProps === void 0 ? void 0 : focusLockProps.disabled : true // Prevents unintended page scroll when popper element is not yet positioned
794
-
795
- }), popperElementWithArrow) : popperElementWithArrow : null)));
796
- };
797
-
798
- /**
799
- * In JavaScript, % is the remainder operator, rather than modulo. This functon performs the remainder calculation.
800
- * @see See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder
801
- * @param a - Numerator
802
- * @param n - Denominator
803
- * @returns The remainder.
804
- */
805
- function mod(a, n) {
806
- return (a % n + n) % n;
807
- }
808
- /**
809
- * Restricts a number between [`min`, `max`] by wrapping it around the range.
810
- * @param value - The current number.
811
- * @param min - The minimum number.
812
- * @param max - The maximum number.
813
- * @returns - A number within the range [`min`, `max`] that corresponds to the provided `value`.
814
- */
815
-
816
-
817
- function wrapAround(value, min, max) {
818
- return min + mod(value - min, max + 1 - min);
819
- }
820
-
821
- /* eslint-disable consistent-return */
822
-
823
- /* eslint-disable babel/no-unused-expressions */
824
-
825
- /**
826
- * Does not call `ourHandler` if the event's `defaultPrevented` property is `true`.
827
- * @param theirHandler - The handler to always be called.
828
- * @param ourHandler - The handler to only be called when the event's `defaultPrevented` property is `false`.
829
- */
830
- function wrapEvent(theirHandler, ourHandler) {
831
- return event => {
832
- theirHandler === null || theirHandler === void 0 ? void 0 : theirHandler(event);
833
-
834
- if (!event.defaultPrevented) {
835
- return ourHandler === null || ourHandler === void 0 ? void 0 : ourHandler(event);
836
- }
837
- };
838
- }
839
-
840
- const KEYBOARD_USER_CLASS = 'keyboard-user';
841
- function getIsKeyboardUser() {
842
- return canUseDOM() && document.body.classList.contains(KEYBOARD_USER_CLASS);
843
- }
844
- function setIsKeyboardUser(newIsKeyboardUser) {
845
- if (!canUseDOM()) {
846
- return;
847
- }
848
-
849
- if (newIsKeyboardUser) {
850
- document.body.classList.add(KEYBOARD_USER_CLASS);
851
- } else {
852
- document.body.classList.remove(KEYBOARD_USER_CLASS);
853
- }
854
- }
855
- function enableKeyboardUserClass() {
856
- if (canUseDOM() && !window.keyboardUserListenersAdded) {
857
- window.keyboardUserListenersAdded = true;
858
- document.addEventListener('mousedown', () => setIsKeyboardUser(false));
859
- document.addEventListener('keydown', e => {
860
- if (e.keyCode === 9) {
861
- setIsKeyboardUser(true);
862
- }
863
- });
864
- }
865
- }
866
-
867
- var css_248z$d = "._36jxV{position:absolute;z-index:2000;max-width:240px;padding:8px 16px;color:#fff;text-align:center;text-decoration:none;background-color:#222;border-radius:4px;box-shadow:0 3px 4px 0 rgba(0,0,0,.05),0 6px 10px 0 rgba(0,0,0,.05);font-size:14px;opacity:0;pointer-events:none;overflow-wrap:break-word;border:1px solid #898989}._36jxV._3whsD{color:#32363a;background-color:#fff}._2ucdF{opacity:1;pointer-events:all}._1GYk9,._1GYk9>div{position:absolute;width:8px;height:8px;background:inherit}._1GYk9{visibility:hidden;z-index:2000}._1GYk9>div{visibility:visible;border:1px solid #898989;transform:rotate(45deg)}[data-popper-placement^=top]>._1GYk9{bottom:-4px}[data-popper-placement^=top]>._1GYk9>div{border-top-color:transparent;border-left-color:transparent}[data-popper-placement^=right]>._1GYk9{left:-5px}[data-popper-placement^=right]>._1GYk9>div{border-top-color:transparent;border-right-color:transparent}[data-popper-placement^=bottom]>._1GYk9{top:-5px}[data-popper-placement^=bottom]>._1GYk9>div{border-bottom-color:transparent;border-right-color:transparent}[data-popper-placement^=left]>._1GYk9{right:-4px}[data-popper-placement^=left]>._1GYk9>div{border-bottom-color:transparent;border-left-color:transparent}._1USlN{position:absolute}[data-popper-placement^=top]>._1USlN{bottom:-13px;left:0;width:100%;height:17px}[data-popper-placement^=right]>._1USlN{top:0;left:-13px;width:17px;height:100%}[data-popper-placement^=bottom]>._1USlN{top:-13px;left:0;width:100%;height:17px}[data-popper-placement^=left]>._1USlN{top:0;right:-13px;width:17px;height:100%}";
868
- var styles$a = {"tooltip":"_36jxV","lightTheme":"_3whsD","visible":"_2ucdF","arrow":"_1GYk9","offsetBackplate":"_1USlN"};
869
- var stylesheet$d="._36jxV{position:absolute;z-index:2000;max-width:240px;padding:8px 16px;color:#fff;text-align:center;text-decoration:none;background-color:#222;border-radius:4px;box-shadow:0 3px 4px 0 rgba(0,0,0,.05),0 6px 10px 0 rgba(0,0,0,.05);font-size:14px;opacity:0;pointer-events:none;overflow-wrap:break-word;border:1px solid #898989}._36jxV._3whsD{color:#32363a;background-color:#fff}._2ucdF{opacity:1;pointer-events:all}._1GYk9,._1GYk9>div{position:absolute;width:8px;height:8px;background:inherit}._1GYk9{visibility:hidden;z-index:2000}._1GYk9>div{visibility:visible;border:1px solid #898989;transform:rotate(45deg)}[data-popper-placement^=top]>._1GYk9{bottom:-4px}[data-popper-placement^=top]>._1GYk9>div{border-top-color:transparent;border-left-color:transparent}[data-popper-placement^=right]>._1GYk9{left:-5px}[data-popper-placement^=right]>._1GYk9>div{border-top-color:transparent;border-right-color:transparent}[data-popper-placement^=bottom]>._1GYk9{top:-5px}[data-popper-placement^=bottom]>._1GYk9>div{border-bottom-color:transparent;border-right-color:transparent}[data-popper-placement^=left]>._1GYk9{right:-4px}[data-popper-placement^=left]>._1GYk9>div{border-bottom-color:transparent;border-left-color:transparent}._1USlN{position:absolute}[data-popper-placement^=top]>._1USlN{bottom:-13px;left:0;width:100%;height:17px}[data-popper-placement^=right]>._1USlN{top:0;left:-13px;width:17px;height:100%}[data-popper-placement^=bottom]>._1USlN{top:-13px;left:0;width:100%;height:17px}[data-popper-placement^=left]>._1USlN{top:0;right:-13px;width:17px;height:100%}";
870
- icons_index.styleInject(css_248z$d);
871
-
872
- const useSSRLayoutEffect = function () {
873
- const effectFunc = React.useMemo(() => canUseDOM() ? React.useLayoutEffect : React.useEffect, []);
874
- return effectFunc(...arguments);
875
- };
876
-
877
- /**
878
- * An abstraction on top of `useCallback` that does not trigger a re-render when the function parameter changes.
879
- * @param fn - The function to memoize.
880
- * @returns A memoized version of the function that never changes.
881
- * @see https://github.com/facebook/react/issues/14099#issuecomment-440013892
882
- */
883
- function useEventCallback(fn) {
884
- const fnRef = React.useRef(fn);
885
- useSSRLayoutEffect(() => {
886
- fnRef.current = fn;
887
- });
888
- return React.useCallback(event => // eslint-disable-next-line @typescript-eslint/ban-ts-comment
889
- // @ts-ignore: Left side of comma operator is unused and has no side effects. See https://stackoverflow.com/questions/11541134/javascript-syntax-0-fnargs
890
- (0, fnRef.current)(event), []);
891
- }
892
-
893
- function isEventTarget(target) {
894
- return !!target.addEventListener;
895
- }
896
-
897
- /**
898
- * Adds and cleans up event listener from the specified target
899
- * @param targetOrRef - An event target or ref pointing to one.
900
- * @param event - Event to listen for.
901
- * @param handler - Handler to call when event is fired.
902
- * @param options.isCaptureEvent - Whether to run the event in the capture phase,
903
- * defaults to false (i.e. run in bubbling phase)
904
- * @param options.enabled - Whether event is enabled, defaults to true
905
- * @param options.additionalDependencies - additional dependencies to add to the use effect
906
- * should be a static list of values, defaults to []
907
- */
908
- function useEventListener(targetOrRef, event, handler) {
909
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
910
- const listener = useEventCallback(handler);
911
- const {
912
- isCaptureEvent = false,
913
- isDisabled = false,
914
- additionalDependencies = []
915
- } = options;
916
- React.useEffect(() => {
917
- const target = isEventTarget(targetOrRef) ? targetOrRef : targetOrRef.current;
918
-
919
- if (target !== null && target !== void 0 && target.addEventListener && !isDisabled) {
920
- target.addEventListener(event, listener, isCaptureEvent);
921
- return () => target.removeEventListener(event, listener, isCaptureEvent);
922
- }
923
-
924
- return undefined;
925
- }, [targetOrRef, event, listener, isCaptureEvent, isDisabled, ...additionalDependencies]);
926
- }
927
-
928
- /* eslint-disable babel/no-unused-expressions */
929
- /**
930
- * Listens for a `mousedown` or `touchstart` event that exists outside of the given ref element(s).
931
- * @param refs - The ref elements to ignore events on.
932
- * @param onClickOutside - An observer that is called when an outside click or touch occurs.
933
- */
934
-
935
- function useClickOutside(refs, onClickOutside) {
936
- const allRefs = React.useMemo(() => Array.isArray(refs) ? refs : [refs], [refs]);
937
-
938
- const handler = event => {
939
- const isInside = allRefs.some(ref => {
940
- var _el$contains;
941
-
942
- const {
943
- current: el
944
- } = ref;
945
- return el === null || el === void 0 ? void 0 : (_el$contains = el.contains) === null || _el$contains === void 0 ? void 0 : _el$contains.call(el, event.target);
946
- });
947
-
948
- if (!isInside) {
949
- onClickOutside(event);
950
- }
951
- };
952
-
953
- useEventListener(document, 'mousedown', handler);
954
- useEventListener(document, 'touchstart', handler);
955
- }
956
-
957
- /* eslint-disable consistent-return */
958
- /**
959
- * Listens for `click` event. The returned function is used to ignore the given `click` event.
960
- * @param onClickOutside - An observer that is called when an outside click occurs.
961
- * @param options.disabled - Indicates if the hook is disabled (i.e. won't call the observer)
962
- * @returns A function that, when called, ignores the current outside click if one exists.
963
- */
964
-
965
- function useClickOutsidePortals(onClickOutside) {
966
- let {
967
- disabled = false
968
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
969
- const wasClickedInside = React.useRef(false);
970
-
971
- const handleClick = e => {
972
- if (!wasClickedInside.current) {
973
- onClickOutside(e);
974
- } // should reset clicked state after each click
975
-
976
-
977
- wasClickedInside.current = false;
978
- };
979
-
980
- useEventListener(document, 'mouseup', handleClick, {
981
- isDisabled: disabled
982
- });
983
- const preventClickOutside = React.useCallback(() => {
984
- wasClickedInside.current = true;
985
- }, []);
986
- return preventClickOutside;
987
- }
988
-
989
- /**
990
- * An abstraction on top of `useRef` that keeps track of the latest value. Use the ref returned by this hook to ensure that a change in value does not trigger a re-render.
991
- * @param value - The latest value.
992
- * @returns A mutable ref object whose current property is the value passed in to the hook.
993
- */
994
-
995
- function useLatest(value) {
996
- const valueRef = React.useRef(value);
997
- React.useEffect(() => {
998
- valueRef.current = value;
999
- }, [value]);
1000
- return valueRef;
1001
- }
1002
-
1003
- /* eslint-disable @typescript-eslint/no-use-before-define */
1004
- const BECAME_CONTROLLED_WARNING = 'WARNING: A component is changing from being uncontrolled to controlled. Components should not switch from being uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled component for the lifetime of the component. More info: https://fb.me/react-controlled-components';
1005
- const BECAME_UNCONTROLLED_WARNING = 'WARNING: A component is changing from being controlled to uncontrolled. Components should not switch from being controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled component for the lifetime of the component. More info: https://fb.me/react-controlled-components';
1006
- /**
1007
- * An abstraction on top of useState that allows for state to either be controlled internally or externally.
1008
- * @param initialState - The state to begin with.
1009
- * @param onChange - An observer that is called when the state changes.
1010
- * @param externalState - State used to override the internal state.
1011
- * @returns An array where the first item is the current state and the second item is the state updater.
1012
- */
1013
-
1014
- function useControllableState(initialState, onChange, externalState) {
1015
- const [state, replaceState] = React.useState(initialState);
1016
- const onChangeRef = useLatest(onChange);
1017
- const externalStateRef = useLatest(externalState);
1018
- const internalStateRef = useLatest(state);
1019
- useControlledTransitionWarning(externalState);
1020
- /**
1021
- * The following useEffect is necessary in order to make transitions
1022
- * from using external state, to using internal state seamless and
1023
- * follows the behavior of React's native controllable input component
1024
- */
1025
-
1026
- React.useEffect(() => {
1027
- if (externalState !== undefined) {
1028
- replaceState(externalState);
1029
- }
1030
- }, [externalState]);
1031
- /**
1032
- * TODO: replace the effect above with this effect
1033
- *
1034
- * Unfortunately, this change breaks various Menu tests because
1035
- * the submenu code in BaseMenu is dependant on this extra render.
1036
- * Once the submenu issue is fixed, we can use the following effect.
1037
- * There is already a test for this in useControllableState.test.js
1038
- * that will need to be uncommented out
1039
- */
1040
- // const prevExternalState = usePrevious(externalState);
1041
- // useEffect(() => {
1042
- // if (prevExternalState !== undefined && externalState === undefined) {
1043
- // replaceState(prevExternalState);
1044
- // }
1045
- // }, [externalState, prevExternalState]);
1046
-
1047
- const setState = React.useCallback(function (input) {
1048
- const currentState = externalStateRef.current !== undefined ? externalStateRef.current : internalStateRef.current;
1049
- const nextState = typeof input === 'function' ? input(currentState) : input;
1050
-
1051
- if (externalStateRef.current === undefined) {
1052
- replaceState(nextState);
1053
- }
1054
-
1055
- if (nextState !== currentState) {
1056
- var _onChangeRef$current;
1057
-
1058
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1059
- args[_key - 1] = arguments[_key];
1060
- }
1061
-
1062
- (_onChangeRef$current = onChangeRef.current) === null || _onChangeRef$current === void 0 ? void 0 : _onChangeRef$current.call(onChangeRef, nextState, ...args);
1063
- }
1064
- }, [onChangeRef, externalStateRef, internalStateRef]);
1065
- const actualState = externalState === undefined ? state : externalState;
1066
- return [actualState, setState];
1067
- }
1068
- /**
1069
- * Logs a warning if the state switches from controlled to uncontrolled (or vice versa)
1070
- * @param externalState - The state being controlled externally.
1071
- */
1072
-
1073
-
1074
- function useControlledTransitionWarning(externalState) {
1075
- const isControlled = externalState !== undefined;
1076
- const isControlledRef = React.useRef(isControlled);
1077
- React.useEffect(() => {
1078
- if (isControlled !== isControlledRef.current) {
1079
- if (isControlled) {
1080
- // eslint-disable-next-line no-console
1081
- console.warn(BECAME_CONTROLLED_WARNING);
1082
- } else {
1083
- // eslint-disable-next-line no-console
1084
- console.warn(BECAME_UNCONTROLLED_WARNING);
1085
- }
1086
- }
1087
- }, [isControlled]);
1088
- }
1089
-
1090
- /* eslint-disable @typescript-eslint/no-use-before-define */
1091
-
1092
- /**
1093
- * A utility for programmatically moving focus within a group of linear elements
1094
- * @returns Utilities for registering and focusing elements
1095
- */
1096
- function useFocusSequence() {
1097
- const nodesMap = React.useRef(new Set());
1098
- /**
1099
- * Registers element to be included in the focus sequence
1100
- * @param newNode - Element to register
1101
- */
1102
-
1103
- const registerNode = React.useCallback(newNode => {
1104
- if (!newNode) {
1105
- throw new Error('registerNode called without any parameters! Pass in "newNode" as parameter');
1106
- }
1107
-
1108
- nodesMap.current.add(newNode);
1109
- }, []);
1110
- /**
1111
- * Removes node from focus sequence
1112
- * @param node - Element to be removed
1113
- */
1114
-
1115
- const deregisterNode = React.useCallback(node => {
1116
- nodesMap.current.delete(node);
1117
- }, []);
1118
- /**
1119
- * Focuses next element in registered sequence
1120
- * @param config - Optional parameter for configuring settings
1121
- * @param config.wrap - Allows focus to loop from last element to first
1122
- */
1123
-
1124
- const focusNext = React.useCallback(function () {
1125
- let {
1126
- wrap = true
1127
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1128
- const sorted = sortNodes(nodesMap.current.values());
1129
- const focusedNodeIndex = sorted.findIndex(n => n === document.activeElement);
1130
- const nextIndex = getNextIndex(focusedNodeIndex, sorted.length, {
1131
- wrap
1132
- });
1133
- sorted[nextIndex].focus();
1134
- }, []);
1135
- /**
1136
- * Focuses previous element in registered sequence
1137
- * @param config - Optional parameter for configuring settings
1138
- * @param config.wrap - Allows focus to loop from first element to last
1139
- */
1140
-
1141
- const focusPrevious = React.useCallback(function () {
1142
- let {
1143
- wrap = true
1144
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1145
- const sorted = sortNodes(nodesMap.current.values());
1146
- const focusedNodeIndex = sorted.findIndex(n => n === document.activeElement);
1147
- const previousIndex = getPreviousIndex(focusedNodeIndex, sorted.length, {
1148
- wrap
1149
- });
1150
- sorted[previousIndex].focus();
1151
- }, []);
1152
- /**
1153
- * Focuses first element in registered sequence
1154
- */
1155
-
1156
- const focusFirst = React.useCallback(() => {
1157
- const sorted = sortNodes(nodesMap.current.values());
1158
- sorted[0].focus();
1159
- }, []);
1160
- /**
1161
- * Focuses last element in registered sequence
1162
- */
1163
-
1164
- const focusLast = React.useCallback(() => {
1165
- const sorted = sortNodes(nodesMap.current.values());
1166
- sorted[sorted.length - 1].focus();
1167
- }, []);
1168
- return {
1169
- registerNode,
1170
- deregisterNode,
1171
- focusNext,
1172
- focusPrevious,
1173
- focusFirst,
1174
- focusLast
1175
- };
1176
- }
1177
-
1178
- function sortNodes(nodes) {
1179
- const copy = Array.from(nodes);
1180
- copy.sort((a, b) => // eslint-disable-next-line no-bitwise
1181
- a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1);
1182
- return copy;
1183
- }
1184
-
1185
- function getNextIndex(index, numItems) {
1186
- let {
1187
- wrap = true
1188
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1189
-
1190
- if (index === -1) {
1191
- return 0;
1192
- }
1193
-
1194
- if (wrap) {
1195
- return (index + 1) % numItems;
1196
- }
1197
-
1198
- return index < numItems - 1 ? index + 1 : numItems - 1;
1199
- }
1200
-
1201
- function getPreviousIndex(index, numItems) {
1202
- let {
1203
- wrap = true
1204
- } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1205
-
1206
- if (index === -1) {
1207
- return numItems - 1;
1208
- }
1209
-
1210
- if (wrap) {
1211
- return (index + numItems - 1) % numItems;
1212
- }
1213
-
1214
- return index > 0 ? index - 1 : 0;
1215
- }
1216
-
1217
- /**
1218
- * Returns an ID that is stable across renders.
1219
- * @param defaultExternalId - ID to be used instead of a randomly generated ID. This ID is only considered on mount, so changes to this ID are ignored.
1220
- * @returns If an external ID is passed in, the external ID. Otherwise, a randomly generated ID.
1221
- */
1222
-
1223
- function useId(defaultExternalId) {
1224
- const [currentId] = React.useState(() => defaultExternalId !== null && defaultExternalId !== void 0 ? defaultExternalId : uuid.v4());
1225
- return currentId;
1226
- }
1227
-
1228
- /**
1229
- * Keeps track of the mounted state of the component.
1230
- * @returns A boolean indicating if the component is mounted.
1231
- */
1232
-
1233
- function useMounted() {
1234
- const mounted = React.useRef(false);
1235
- useSSRLayoutEffect(() => {
1236
- mounted.current = true;
1237
- return () => {
1238
- mounted.current = false;
1239
- };
1240
- }, []);
1241
- return mounted;
1242
- }
1243
-
1244
- /**
1245
- * Pushes event updates as a mouse is clicked and dragged. The event updates begin once the returned function is called. The event updates end on mouseup.
1246
- * @param handleChange - An observer that is called either when the returned function is called mousemove event occurs.
1247
- * @returns A function that needs to be called on mousedown.
1248
- */
1249
-
1250
- function useMouseDrag(handleChange) {
1251
- const [isMouseDown, setIsMouseDown] = React.useState(false);
1252
-
1253
- function handleMouseDown(e) {
1254
- handleChange(e);
1255
- setIsMouseDown(true);
1256
- }
1257
-
1258
- function handleMouseUp() {
1259
- setIsMouseDown(false);
1260
- }
1261
-
1262
- const isDisabled = !isMouseDown;
1263
- useEventListener(window, 'mousemove', handleChange, {
1264
- isDisabled
1265
- });
1266
- useEventListener(window, 'mouseup', handleMouseUp, {
1267
- isDisabled
1268
- });
1269
- return handleMouseDown;
1270
- }
1271
-
1272
- /**
1273
- * An abstraction on top of `useRef` that keeps track of the previous value.
1274
- * @param value - The current value.
1275
- * @returns The previous value.
1276
- */
1277
-
1278
- function usePrevious(value) {
1279
- const ref = React.useRef();
1280
- React.useEffect(() => {
1281
- ref.current = value;
1282
- }, [value]);
1283
- return ref.current;
1284
- }
1285
-
1286
- var css_248z$c = "._3pyKj{position:absolute;top:-10000px;left:-10000px}";
1287
- var classes = {"ariaLiveElement":"_3pyKj"};
1288
- var stylesheet$c="._3pyKj{position:absolute;top:-10000px;left:-10000px}";
1289
- icons_index.styleInject(css_248z$c);
1290
-
1291
- /**
1292
- * Sets up a live region in order to make screen reader announcements.
1293
- * @param politeness - Sets the politeness level for `aria-live`.
1294
- * @returns - A function used to send an announcement to the screen reader.
1295
- */
1296
-
1297
- function useScreenReaderAnnouncement(politeness) {
1298
- const ariaLiveElementRef = React.useRef();
1299
- const [messageQueue, setMessageQueue] = React.useState([]); // An array of messages where the first item in the array is the oldest message
1300
-
1301
- const [isAnnouncingMessage, setIsAnnouncingMessage] = React.useState(false);
1302
- const delayTimer = React.useRef(); // Creates the live region element
1303
-
1304
- React.useEffect(() => {
1305
- ariaLiveElementRef.current = document.createElement('span');
1306
- ariaLiveElementRef.current.classList.add(classes.ariaLiveElement);
1307
- document.body.appendChild(ariaLiveElementRef.current);
1308
- return () => {
1309
- if (ariaLiveElementRef.current !== undefined) document.body.removeChild(ariaLiveElementRef.current);
1310
- };
1311
- }, []); // Sets the politeness of `aria-live`
1312
-
1313
- React.useEffect(() => {
1314
- var _ariaLiveElementRef$c;
1315
-
1316
- if (politeness !== undefined) (_ariaLiveElementRef$c = ariaLiveElementRef.current) === null || _ariaLiveElementRef$c === void 0 ? void 0 : _ariaLiveElementRef$c.setAttribute('aria-live', politeness);
1317
- }, [politeness]); // Announces oldest message in the queue
1318
-
1319
- React.useEffect(() => {
1320
- if (!isAnnouncingMessage && messageQueue.length > 0) {
1321
- var _ariaLiveElementRef$c2;
1322
-
1323
- setIsAnnouncingMessage(true);
1324
- const oldestMessage = messageQueue[0];
1325
- let delay;
1326
-
1327
- if (((_ariaLiveElementRef$c2 = ariaLiveElementRef.current) === null || _ariaLiveElementRef$c2 === void 0 ? void 0 : _ariaLiveElementRef$c2.textContent) === oldestMessage) {
1328
- /*
1329
- * If the message to be announced is the same as the previous message, the message needs to be reset.
1330
- * The screen reader won't read the change unless the text has changed.
1331
- */
1332
- ariaLiveElementRef.current.textContent = '';
1333
- delay = 200; // Gives the screen reader time to detect the new message (this number was chosen arbitrarily)
1334
- } else {
1335
- // If the message to be announced is different from the previous message, there is no need for a delay
1336
- delay = 0;
1337
- }
1338
-
1339
- delayTimer.current = setTimeout(() => {
1340
- if (ariaLiveElementRef.current !== undefined) ariaLiveElementRef.current.textContent = oldestMessage;
1341
- setMessageQueue(currentMessageQueue => currentMessageQueue.slice(1)); // Removes the oldest message (i.e. first item) from the message queue since it was just announced
1342
-
1343
- setIsAnnouncingMessage(false);
1344
- }, delay);
1345
- }
1346
- }, [isAnnouncingMessage, messageQueue]); // Cleanup timeout to avoid memory leaks
1347
-
1348
- React.useEffect(() => () => {
1349
- if (delayTimer.current) clearTimeout(delayTimer.current);
1350
- }, []);
1351
- /**
1352
- * Sends a message for the screen reader to read.
1353
- * @param message - The message that the screen reader will read.
1354
- */
1355
-
1356
- const announceToScreenReader = React.useCallback(message => {
1357
- setMessageQueue(currentMessageQueue => [...currentMessageQueue, message]);
1358
- }, []);
1359
- return announceToScreenReader;
1360
- }
1361
-
1362
- const useDidUpdateBase = (useEffectFunction, func, deps) => {
1363
- const isFirstRenderRef = React.useRef(true);
1364
- useEffectFunction(() => {
1365
- if (isFirstRenderRef.current) {
1366
- isFirstRenderRef.current = false;
1367
- return undefined;
1368
- }
1369
-
1370
- return func();
1371
- }, deps);
1372
- };
1373
- /**
1374
- * Wrapper around useEffect that runs on dependency updates only, not on initial render.
1375
- * @param func - The effect function to run when dependencies have been updated.
1376
- * @param deps - The list of dependencies to watch for changes.
1377
- */
1378
-
1379
-
1380
- const useDidUpdate = (func, deps) => useDidUpdateBase(React.useEffect, func, deps);
1381
- /**
1382
- * Wrapper around useSSRLayoutEffect that runs on dependency updates only, not on initial render.
1383
- * @param func - The effect function to run when dependencies have been updated.
1384
- * @param deps - The list of dependencies to watch for changes.
1385
- */
1386
-
1387
- const useEnhancedDidUpdate = (func, deps) => useDidUpdateBase(useSSRLayoutEffect, func, deps);
1388
-
1389
- /**
1390
- * Tracks focused state on element that `ref` is registered with
1391
- * @returns `ref` to pass to element and `isFocused` state
1392
- */
1393
-
1394
- function useIsFocused() {
1395
- const [isFocused, setIsFocused] = React.useState(false);
1396
- const ref = React.useRef(null);
1397
- useEventListener(ref, 'focus', () => setIsFocused(true));
1398
- useEventListener(ref, 'blur', () => setIsFocused(false));
1399
- return [ref, isFocused];
1400
- }
1401
-
1402
- /**
1403
- * Tracks hovered state on element that `ref` is registered with
1404
- * @returns `ref` to pass to element and `isFocused` state
1405
- */
1406
-
1407
- function useIsHovered() {
1408
- const [isHovered, setIsHovered] = React.useState(false);
1409
- const ref = React.useRef(null);
1410
- useEventListener(ref, 'mouseenter', () => setIsHovered(true));
1411
- useEventListener(ref, 'mouseleave', () => setIsHovered(false));
1412
- return [ref, isHovered];
1413
- }
1414
-
1415
- /*
1416
-
1417
- Due to rounding, `scrollWidth` and `clientWidth` do not always accurately represent whether overflow has occurred.
1418
- Reproduction: https://codesandbox.io/s/determined-cartwright-9j21gm?file=/src/App.js
1419
- Issue: https://github.com/w3c/csswg-drafts/issues/4123
1420
-
1421
- */
1422
-
1423
- const useIsTruncated = target => {
1424
- const [isTruncated, setIsTruncated] = React.useState(false);
1425
- React.useLayoutEffect(() => {
1426
- const {
1427
- clientWidth,
1428
- scrollWidth
1429
- } = target.current; // set initial value
1430
-
1431
- setIsTruncated(clientWidth < scrollWidth);
1432
- }, [target]);
1433
- useResizeObserver__default["default"](target, entry => {
1434
- const {
1435
- clientWidth,
1436
- scrollWidth
1437
- } = entry.target; // update value on resize
1438
-
1439
- setIsTruncated(clientWidth < scrollWidth);
1440
- });
1441
- return isTruncated;
1442
- };
1443
-
1444
- const map = new Map();
1445
-
1446
- function noop$1() {}
1447
-
1448
- function subscribe(query, callback) {
1449
- if (typeof document === 'undefined') {
1450
- // don't do anything when Server Side Rendering
1451
- return noop$1;
1452
- }
1453
-
1454
- if (!map.has(query)) {
1455
- const subscribers = new Set();
1456
-
1457
- const globalListener = event => {
1458
- subscribers.forEach(cb => cb(event));
1459
- };
1460
-
1461
- const mediaQueryList = window.matchMedia(query);
1462
-
1463
- if (mediaQueryList.addListener) {
1464
- mediaQueryList.addListener(globalListener);
1465
- } else {
1466
- mediaQueryList.addEventListener('change', globalListener);
1467
- }
1468
-
1469
- map.set(query, {
1470
- mediaQueryList,
1471
- globalListener,
1472
- subscribers
1473
- });
1474
- }
1475
-
1476
- const entry = map.get(query);
1477
- entry === null || entry === void 0 ? void 0 : entry.subscribers.add(callback);
1478
- return entry ? function unsubscribe() {
1479
- entry.subscribers.delete(callback);
1480
-
1481
- if (entry.subscribers.size === 0) {
1482
- // if there are no more subscribers
1483
- if (entry.mediaQueryList.removeListener) {
1484
- entry.mediaQueryList.removeListener(entry.globalListener);
1485
- } else {
1486
- entry.mediaQueryList.removeEventListener('change', entry.globalListener);
1487
- }
1488
-
1489
- map.delete(query);
1490
- }
1491
- } : noop$1;
1492
- }
1493
- function getMediaQueryValue(query) {
1494
- if (typeof document === 'undefined') {
1495
- // default to false when Server Side Rendering
1496
- return false;
1497
- }
1498
-
1499
- return window.matchMedia(query).matches;
1500
- }
1501
-
1502
- function getMinWidthQuery(length, unit) {
1503
- return "(min-width: ".concat(length).concat(unit, ")");
1504
- }
1505
-
1506
- function getInitialValues(breakpointsConfig, unit) {
1507
- const initialValues = {};
1508
- Object.entries(breakpointsConfig).forEach(_ref => {
1509
- let [breakpointName, breakpointValue] = _ref;
1510
- const query = getMinWidthQuery(breakpointValue, unit);
1511
- initialValues[breakpointName] = getMediaQueryValue(query);
1512
- });
1513
- return initialValues;
1514
- }
1515
-
1516
- function useBreakpoints() {
1517
- let breakpoints = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BREAKPOINTS;
1518
- let unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'em';
1519
- const [matches, setMatches] = React.useState(() => getInitialValues(breakpoints, unit));
1520
- const breakpointsRef = useLatest(breakpoints);
1521
- const unitRef = useLatest(unit);
1522
- React.useEffect(() => {
1523
- const unsubscribeFns = [];
1524
- Object.entries(breakpointsRef.current).forEach(_ref2 => {
1525
- let [breakpointName, breakpointValue] = _ref2;
1526
- const query = getMinWidthQuery(breakpointValue, unitRef.current);
1527
- const unsubscribe = subscribe(query, event => {
1528
- setMatches(prevValue => ({ ...prevValue,
1529
- [breakpointName]: event.matches
1530
- }));
1531
- });
1532
- unsubscribeFns.push(unsubscribe);
1533
- });
1534
- return () => {
1535
- unsubscribeFns.forEach(fn => fn());
1536
- };
1537
- }, [breakpointsRef, unitRef]);
1538
- return matches;
1539
- }
1540
-
1541
- function useResponsiveValue(values) {
1542
- var _values$returnKey;
1543
-
1544
- let breakpoints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_BREAKPOINTS;
1545
- let unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'em';
1546
- const matches = useBreakpoints(breakpoints, unit);
1547
- const returnKey = Object.keys(values).reduce((acc, k) => {
1548
- if (matches[k] && (typeof acc === 'undefined' || breakpoints[acc] < breakpoints[k])) {
1549
- return k;
1550
- }
1551
-
1552
- return acc;
1553
- }, undefined);
1554
- return (_values$returnKey = values[returnKey]) !== null && _values$returnKey !== void 0 ? _values$returnKey : null;
1555
- }
1556
-
1557
- const Tooltip = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
1558
- var _children$ref;
1559
-
1560
- let {
1561
- content,
1562
- unstable_contentKey: contentKey,
1563
- placement = 'top',
1564
- children,
1565
- disabled = false,
1566
- delayMs = 0,
1567
- zIndex = 1000,
1568
- className,
1569
- portalTarget,
1570
- isArrowRemoved,
1571
- style = {},
1572
- id,
1573
- lightTheme = false,
1574
- show: externalShow,
1575
- onShowChange,
1576
- 'aria-hidden': ariaHidden,
1577
- ...rest
1578
- } = _ref;
1579
- const componentIsControlled = externalShow !== undefined;
1580
- const [show, setShow] = useControllableState(externalShow, onShowChange, externalShow);
1581
- const [isInDOM, setIsInDOM] = React.useState(false);
1582
- const [isVisible, setIsVisible] = React.useState(false);
1583
- const [isMouseHoveringComponent, setIsMouseHoveringComponent] = React.useState(false);
1584
- const anchorRef = React.useRef(null);
1585
- const flyoutRef = React.useRef(null);
1586
- const flyoutOffsetBackplateRef = React.useRef(null);
1587
- const timer = React.useRef();
1588
- const flyoutContainerId = useId(id);
1589
-
1590
- const getIsAnchorKeyboardFocused = () => document.activeElement === anchorRef.current && getIsKeyboardUser();
1591
-
1592
- const triggerShowTooltip = () => {
1593
- const showTooltip = () => {
1594
- setIsInDOM(true); // Renders the flyout before the deley so that screen readers can read out the tooltip content
1595
-
1596
- clearTimeout(timer.current);
1597
- timer.current = window.setTimeout(() => setIsVisible(true), delayMs);
1598
- };
1599
-
1600
- if (!disabled) {
1601
- if (!show) {
1602
- setShow(true);
1603
-
1604
- if (componentIsControlled) {
1605
- return;
1606
- }
1607
- }
1608
-
1609
- showTooltip();
1610
- }
1611
- };
1612
-
1613
- const triggerHideTooltip = () => {
1614
- const hideTooltip = () => {
1615
- clearTimeout(timer.current);
1616
- setIsVisible(false);
1617
- setIsInDOM(false);
1618
- };
1619
-
1620
- if (show) {
1621
- setShow(false);
1622
-
1623
- if (componentIsControlled) {
1624
- return;
1625
- }
1626
- }
1627
-
1628
- hideTooltip();
1629
- };
1630
-
1631
- React.useEffect(() => {
1632
- if (externalShow) {
1633
- triggerShowTooltip();
1634
- } else {
1635
- triggerHideTooltip();
1636
- }
1637
- }, [externalShow]);
1638
-
1639
- const handleMouseEnter = () => {
1640
- triggerShowTooltip();
1641
- setIsMouseHoveringComponent(true);
1642
- };
1643
-
1644
- const handleMouseLeave = event => {
1645
- const isMouseEnteringAnchorOrTooltip = event.relatedTarget === anchorRef.current || event.relatedTarget === flyoutRef.current || event.relatedTarget === flyoutOffsetBackplateRef.current;
1646
- /*
1647
- * Prevents the tooltip from hiding when at least one of the following conditions are met:
1648
- * A keyboard user exists and the anchor element is focused, but that same user is using a mouse to enter and leave the flyout or anchor, or
1649
- * A user is moving the mouse between the anchor and the flyout
1650
- */
1651
-
1652
- if (!isMouseEnteringAnchorOrTooltip) {
1653
- setIsMouseHoveringComponent(false);
1654
-
1655
- if (!getIsAnchorKeyboardFocused()) {
1656
- triggerHideTooltip();
1657
- }
1658
- }
1659
- };
1660
-
1661
- const handleFocus = () => {
1662
- // Prevents the tooltip from showing for mouse users when the tooltip's anchor element is programmatically focused
1663
- if (getIsKeyboardUser()) {
1664
- triggerShowTooltip();
1665
- }
1666
- };
1667
-
1668
- const handleBlur = () => {
1669
- /*
1670
- * Prevents the tooltip from hiding when the cursor is hovering over the anchor or flyout.
1671
- * This allows a user to keyboard focus the anchor and then highlight/select content inside of the flyout using a mouse.
1672
- */
1673
- if (!isMouseHoveringComponent) {
1674
- triggerHideTooltip();
1675
- }
1676
- };
1677
-
1678
- const handleKeyDown = event => {
1679
- if (event.key === 'Escape') {
1680
- if (isVisible) {
1681
- event.stopPropagation(); // prevent event from closing modals or popovers
1682
- }
1683
-
1684
- triggerHideTooltip();
1685
- }
1686
- };
1687
-
1688
- React.useEffect(() => {
1689
- if (disabled) {
1690
- triggerHideTooltip();
1691
- } else if (isMouseHoveringComponent || getIsAnchorKeyboardFocused()) {
1692
- triggerShowTooltip();
1693
- }
1694
- }, // the hide/show functionality of the tooltip based on hover and focus
1695
- // are handled else where and thus don't need to be included here
1696
- // eslint-disable-next-line react-hooks/exhaustive-deps
1697
- [disabled]);
1698
- React.useEffect(() => () => {
1699
- clearTimeout(timer.current);
1700
- }, []); // Allows the user to press the `Escape` key to close the flyout even if the anchor element is not focused
1701
- // handle in capture so that it runs before modal or popover event handlers
1702
-
1703
- useEventListener(document, 'keydown', handleKeyDown, {
1704
- isCaptureEvent: true
1705
- });
1706
- useEventListener(anchorRef, 'mouseenter', handleMouseEnter);
1707
- useEventListener(anchorRef, 'mouseleave', handleMouseLeave);
1708
- useEventListener(anchorRef, 'focus', handleFocus);
1709
- useEventListener(anchorRef, 'blur', handleBlur); // `isInDOM` is added as a dependency because the `flyoutRef` won't be in the DOM until `isInDOM` is `true`
1710
-
1711
- const commonFlyoutListenerOptions = {
1712
- additionalDependencies: [isInDOM, contentKey]
1713
- };
1714
- useEventListener(flyoutRef, 'mouseenter', handleMouseEnter, commonFlyoutListenerOptions);
1715
- useEventListener(flyoutRef, 'mouseleave', handleMouseLeave, commonFlyoutListenerOptions);
1716
-
1717
- const getAnchorAriaDescribedBy = () => {
1718
- var _children$props;
1719
-
1720
- const anchorAriaDescribedByFromProps = children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props['aria-describedby'];
1721
-
1722
- if (ariaHidden === true || ariaHidden === 'true') {
1723
- return anchorAriaDescribedByFromProps;
1724
- }
1725
-
1726
- const tooltipId = isInDOM ? flyoutContainerId : undefined;
1727
-
1728
- if (anchorAriaDescribedByFromProps !== undefined && tooltipId !== undefined) {
1729
- return "".concat(anchorAriaDescribedByFromProps, " ").concat(tooltipId);
1730
- }
1731
-
1732
- if (anchorAriaDescribedByFromProps !== undefined) {
1733
- return anchorAriaDescribedByFromProps;
1734
- } // `tooltipId` might still return `undefined`
1735
-
1736
-
1737
- return tooltipId;
1738
- };
1739
-
1740
- return /*#__PURE__*/React__default["default"].createElement(Popper, {
1741
- open: isInDOM,
1742
- placement: placement,
1743
- anchor: /*#__PURE__*/React__default["default"].cloneElement(children, {
1744
- ref: mergeRefs(anchorRef, (_children$ref = children.ref) !== null && _children$ref !== void 0 ? _children$ref : null),
1745
- 'aria-describedby': getAnchorAriaDescribedBy()
1746
- }),
1747
- popper: /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
1748
- id: flyoutContainerId,
1749
- key: contentKey,
1750
- ref: mergeRefs(ref, flyoutRef),
1751
- className: classNames__default["default"](className, styles$a.tooltip, {
1752
- [styles$a.visible]: isVisible,
1753
- [styles$a.lightTheme]: lightTheme
1754
- }),
1755
- style: {
1756
- zIndex,
1757
- ...style
1758
- },
1759
- role: "tooltip",
1760
- "aria-hidden": ariaHidden
1761
- }), content, /*#__PURE__*/React__default["default"].createElement("div", {
1762
- "aria-hidden": true,
1763
- className: styles$a.offsetBackplate,
1764
- ref: flyoutOffsetBackplateRef
1765
- })),
1766
- modifiers: [{
1767
- name: 'offset',
1768
- options: {
1769
- offset: TOOLTIP_POPPER_OFFSET
1770
- }
1771
- }, {
1772
- name: 'flip',
1773
- options: {
1774
- flipVariations: false
1775
- }
1776
- }],
1777
- arrow: isArrowRemoved ? undefined : /*#__PURE__*/React__default["default"].createElement("div", {
1778
- className: styles$a.arrow
1779
- }, /*#__PURE__*/React__default["default"].createElement("div", null)),
1780
- portalTarget: portalTarget
1781
- });
1782
- });
1783
-
1784
- /*
1785
- Limitations of this utility
1786
-
1787
- 1. Due to rounding, `scrollWidth` and `clientWidth` do not always accurately represent whether overflow has occurred.
1788
- Reproduction: https://codesandbox.io/s/determined-cartwright-9j21gm?file=/src/App.js
1789
- Issue: https://github.com/w3c/csswg-drafts/issues/4123
1790
-
1791
- 2. It does not listen for resizing.
1792
- */
1793
-
1794
- /**
1795
- * Displays a tooltip containing the overflowing text if the text does not fit inside the bounds of its container.
1796
- */
1797
- const TextOverflowTooltip = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
1798
- var _textParentHTMLElemen;
1799
-
1800
- let {
1801
- lightTheme = false,
1802
- delayMs = 500,
1803
- children
1804
- } = _ref;
1805
- const [isTextOverflowing, setIsTextOverflowing] = React.useState(false);
1806
- const textParentHTMLElementRef = React.useRef(null);
1807
- const textParentReactElement = /*#__PURE__*/React.cloneElement(children, {
1808
- ref: mergeRefs(children.ref, textParentHTMLElementRef)
1809
- }); // Updates the disabled state whevever the text parent element changes
1810
-
1811
- React.useEffect(() => {
1812
- const textParentHTMLElement = textParentHTMLElementRef.current;
1813
- setIsTextOverflowing(textParentHTMLElement ? textParentHTMLElement.scrollWidth > textParentHTMLElement.clientWidth : false);
1814
- }, [textParentReactElement // Any time the React child changes, its width needs to be checked via its ref
1815
- ]);
1816
- return /*#__PURE__*/React__default["default"].createElement(Tooltip, {
1817
- content: (_textParentHTMLElemen = textParentHTMLElementRef.current) === null || _textParentHTMLElemen === void 0 ? void 0 : _textParentHTMLElemen.textContent,
1818
- disabled: !isTextOverflowing,
1819
- lightTheme: lightTheme,
1820
- delayMs: delayMs,
1821
- "aria-hidden": true,
1822
- ref: ref
1823
- }, textParentReactElement);
1824
- });
1825
-
1826
- const Text = /*#__PURE__*/React.forwardRef((_ref, ref) => {
1827
- let {
1828
- children,
1829
- lightTheme,
1830
- delayMs = 500,
1831
- className,
1832
- asChild = false,
1833
- ...rest
1834
- } = _ref;
1835
- const internalRef = React.useRef(null);
1836
- const isTruncated = useIsTruncated(internalRef);
1837
- const willClone = asChild && /*#__PURE__*/React__default["default"].isValidElement(children) && typeof children !== 'string' && typeof children !== 'number';
1838
- return /*#__PURE__*/React__default["default"].createElement(Tooltip, {
1839
- content: willClone ? children.props.children : children,
1840
- disabled: !isTruncated,
1841
- lightTheme: lightTheme,
1842
- delayMs: delayMs,
1843
- "aria-hidden": true
1844
- }, willClone ? /*#__PURE__*/React__default["default"].cloneElement(children, {
1845
- className: classNames__default["default"](className, children.props.className),
1846
- ref: mergeRefs(children.ref, ref, internalRef)
1847
- }) : /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({
1848
- className: className,
1849
- ref: mergeRefs(ref, internalRef)
1850
- }, rest), children));
1851
- });
1852
-
1853
- var css_248z$b = "._1JJ_T{padding:0 16px;font-size:14px;line-height:14px;color:#fff;fill:#fff;background-color:#fff;border:1px solid #fff;border-radius:4px;height:36px;min-height:36px;cursor:pointer;position:relative;display:inline-flex;justify-content:center;align-items:center;text-decoration:none;overflow:hidden;transition:border .2s,background .2s,color .2s}._1JJ_T._1OgYH{padding:0 8px;height:26px;min-height:26px}._1JJ_T._2dzps{display:block;width:100%}._1JJ_T._1hXS2{cursor:not-allowed}._1JJ_T:active:focus,._1JJ_T:focus{outline:none}._1JJ_T._y7V1A{background-color:#fff;border-color:#515559;color:#515559;fill:#515559}._1JJ_T._y7V1A:hover:not(._1hXS2){background-color:#eee}._1JJ_T._y7V1A:active:not(._1hXS2){background-color:#e5e5e5}._1JJ_T._y7V1A._1hXS2{color:rgba(81,85,89,.4);fill:rgba(81,85,89,.4);background-color:hsla(0,0%,100%,.4);border:1px solid rgba(81,85,89,.4)}._1JJ_T._1RyTE{background-color:#0b6ed0;border-color:#0b6ed0;color:#fff;fill:#fff}._1JJ_T._1RyTE:hover:not(._1hXS2){background-color:#085caf;border-color:#085caf}._1JJ_T._1RyTE:active:not(._1hXS2){background-color:#0854a1;border-color:#0854a1}._1JJ_T._1RyTE._1hXS2{background-color:rgba(11,110,208,.4);border-color:transparent;fill:hsla(0,0%,100%,.4)}._1JJ_T._1ea7y{background-color:#fff;border-color:#0b6ed0;color:#0b6ed0;fill:#0b6ed0}._1JJ_T._1ea7y:hover:not(._1hXS2){background-color:#eef5fc}._1JJ_T._1ea7y:active:not(._1hXS2){background-color:#e1edf9}._1JJ_T._1ea7y._1hXS2{background-color:hsla(0,0%,100%,.4);border-color:rgba(11,110,208,.4);color:rgba(11,110,208,.4);fill:rgba(11,110,208,.4)}._1JJ_T._31cTN{background-color:#fff;border-color:#fff;color:#0b6ed0;fill:#0b6ed0}._1JJ_T._31cTN:hover:not(._1hXS2){background-color:#eef5fc;border-color:#eef5fc}._1JJ_T._31cTN:active:not(._1hXS2){background-color:#e1edf9;border-color:#e1edf9}._1JJ_T._31cTN._1hXS2{background-color:hsla(0,0%,100%,.4);border-color:hsla(0,0%,100%,.4);color:rgba(11,110,208,.4);fill:rgba(11,110,208,.4)}._1JJ_T._1W_EG{color:#0b6ed0;fill:#0b6ed0;padding:0}._1JJ_T._1W_EG:hover:not(._1hXS2){color:#085caf}._1JJ_T._1W_EG:active:not(._1hXS2){color:#0854a1}._1JJ_T._1W_EG._1hXS2{color:rgba(11,110,208,.4);fill:rgba(11,110,208,.4)}._1JJ_T._2ear0{background-color:#fff;border-color:#b00;color:#b00;fill:#b00}._1JJ_T._2ear0:hover:not(._1hXS2){background-color:#ffecec}._1JJ_T._2ear0:active:not(._1hXS2){background-color:#ffdbdb}._1JJ_T._2ear0._1hXS2{background-color:hsla(0,0%,100%,.4);border-color:rgba(187,0,0,.4);color:rgba(187,0,0,.4);fill:rgba(187,0,0,.4)}._1hDoy,body.keyboard-user ._1JJ_T:active:focus,body.keyboard-user ._1JJ_T:focus{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
1854
- var buttonStyles = {"btn":"_1JJ_T","small":"_1OgYH","full":"_2dzps","disabled":"_1hXS2","default":"_y7V1A","primary":"_1RyTE","secondary":"_1ea7y","tertiary":"_31cTN","link":"_1W_EG","danger":"_2ear0","keyboardFocused":"_1hDoy"};
1855
- var stylesheet$b="._1JJ_T{padding:0 16px;font-size:14px;line-height:14px;color:#fff;fill:#fff;background-color:#fff;border:1px solid #fff;border-radius:4px;height:36px;min-height:36px;cursor:pointer;position:relative;display:inline-flex;justify-content:center;align-items:center;text-decoration:none;overflow:hidden;transition:border .2s,background .2s,color .2s}._1JJ_T._1OgYH{padding:0 8px;height:26px;min-height:26px}._1JJ_T._2dzps{display:block;width:100%}._1JJ_T._1hXS2{cursor:not-allowed}._1JJ_T:active:focus,._1JJ_T:focus{outline:none}._1JJ_T._y7V1A{background-color:#fff;border-color:#515559;color:#515559;fill:#515559}._1JJ_T._y7V1A:hover:not(._1hXS2){background-color:#eee}._1JJ_T._y7V1A:active:not(._1hXS2){background-color:#e5e5e5}._1JJ_T._y7V1A._1hXS2{color:rgba(81,85,89,.4);fill:rgba(81,85,89,.4);background-color:hsla(0,0%,100%,.4);border:1px solid rgba(81,85,89,.4)}._1JJ_T._1RyTE{background-color:#0b6ed0;border-color:#0b6ed0;color:#fff;fill:#fff}._1JJ_T._1RyTE:hover:not(._1hXS2){background-color:#085caf;border-color:#085caf}._1JJ_T._1RyTE:active:not(._1hXS2){background-color:#0854a1;border-color:#0854a1}._1JJ_T._1RyTE._1hXS2{background-color:rgba(11,110,208,.4);border-color:transparent;fill:hsla(0,0%,100%,.4)}._1JJ_T._1ea7y{background-color:#fff;border-color:#0b6ed0;color:#0b6ed0;fill:#0b6ed0}._1JJ_T._1ea7y:hover:not(._1hXS2){background-color:#eef5fc}._1JJ_T._1ea7y:active:not(._1hXS2){background-color:#e1edf9}._1JJ_T._1ea7y._1hXS2{background-color:hsla(0,0%,100%,.4);border-color:rgba(11,110,208,.4);color:rgba(11,110,208,.4);fill:rgba(11,110,208,.4)}._1JJ_T._31cTN{background-color:#fff;border-color:#fff;color:#0b6ed0;fill:#0b6ed0}._1JJ_T._31cTN:hover:not(._1hXS2){background-color:#eef5fc;border-color:#eef5fc}._1JJ_T._31cTN:active:not(._1hXS2){background-color:#e1edf9;border-color:#e1edf9}._1JJ_T._31cTN._1hXS2{background-color:hsla(0,0%,100%,.4);border-color:hsla(0,0%,100%,.4);color:rgba(11,110,208,.4);fill:rgba(11,110,208,.4)}._1JJ_T._1W_EG{color:#0b6ed0;fill:#0b6ed0;padding:0}._1JJ_T._1W_EG:hover:not(._1hXS2){color:#085caf}._1JJ_T._1W_EG:active:not(._1hXS2){color:#0854a1}._1JJ_T._1W_EG._1hXS2{color:rgba(11,110,208,.4);fill:rgba(11,110,208,.4)}._1JJ_T._2ear0{background-color:#fff;border-color:#b00;color:#b00;fill:#b00}._1JJ_T._2ear0:hover:not(._1hXS2){background-color:#ffecec}._1JJ_T._2ear0:active:not(._1hXS2){background-color:#ffdbdb}._1JJ_T._2ear0._1hXS2{background-color:hsla(0,0%,100%,.4);border-color:rgba(187,0,0,.4);color:rgba(187,0,0,.4);fill:rgba(187,0,0,.4)}._1hDoy,body.keyboard-user ._1JJ_T:active:focus,body.keyboard-user ._1JJ_T:focus{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
1856
- icons_index.styleInject(css_248z$b);
1857
-
1858
- function createContextValue(value) {
1859
- return {
1860
- className: value.className,
1861
- inputClassName: value.inputClassName,
1862
- applySmall: small => value.small || small,
1863
- applyFull: full => {
1864
- if (value.overrideFull) {
1865
- return false;
1866
- }
1867
-
1868
- return full;
1869
- }
1870
- };
1871
- }
1872
-
1873
- const {
1874
- Provider: InputGroupContextProvider,
1875
- useContext: useInputGroupContext
1876
- } = createContextUtilities(createContextValue({}));
1877
- const InputGroupProvider = _ref => {
1878
- let {
1879
- children,
1880
- value
1881
- } = _ref;
1882
- const context = createContextValue(value);
1883
- return /*#__PURE__*/React__default["default"].createElement(InputGroupContextProvider, {
1884
- value: context
1885
- }, children);
1886
- };
1887
-
1888
- const Button = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
1889
- let {
1890
- children,
1891
- kind = 'default',
1892
- disabled = false,
1893
- small = false,
1894
- full = false,
1895
- className = '',
1896
- type = 'button',
1897
- onClick,
1898
- onKeyDown,
1899
- 'aria-disabled': ariaDisabled,
1900
- ...rest
1901
- } = _ref;
1902
- const inputGroupContext = useInputGroupContext();
1903
- const classes = classNames__default["default"](className, buttonStyles.btn, inputGroupContext.className, {
1904
- [buttonStyles[kind]]: kind,
1905
- [buttonStyles.disabled]: disabled,
1906
- [buttonStyles.small]: inputGroupContext.applySmall(small),
1907
- [buttonStyles.full]: inputGroupContext.applyFull(full)
1908
- });
1909
-
1910
- const clickHandler = e => {
1911
- if (disabled) {
1912
- // stops form submission for type="submit"
1913
- return e.preventDefault();
1914
- }
1915
-
1916
- onClick === null || onClick === void 0 ? void 0 : onClick(e);
1917
- };
1918
-
1919
- const keyDownHandler = disabled ? undefined : onKeyDown;
1920
- return (
1921
- /*#__PURE__*/
1922
-
1923
- /* eslint-disable react/button-has-type */
1924
- React__default["default"].createElement("button", _extends__default["default"]({}, rest, {
1925
- "aria-disabled": ariaDisabled !== null && ariaDisabled !== void 0 ? ariaDisabled : disabled,
1926
- type: type,
1927
- className: classes,
1928
- ref: ref,
1929
- onClick: clickHandler,
1930
- onKeyDown: keyDownHandler
1931
- }), children)
1932
- /* eslint-disable react/button-has-type */
1933
-
1934
- );
1935
- });
1936
-
1937
- var css_248z$a = "._1gqCL{display:inline-flex;position:relative;margin-top:6px;margin-bottom:6px}._1gqCL,._3O0I6{cursor:pointer;height:16px;width:16px}._3O0I6{position:absolute;opacity:0;z-index:10}._3O0I6:checked~._Fn9K_>._ZKA7b{fill-opacity:1}._3O0I6:checked:enabled~._Fn9K_{border-color:transparent;background-color:#0b6ed0}._3O0I6:checked:enabled~._Fn9K_>._ZKA7b{fill:#fff}._3O0I6:checked:enabled:hover~._Fn9K_{background-color:#085caf}._3O0I6:not(:checked):enabled:hover~._Fn9K_{border-color:#0b6ed0}._3O0I6:disabled{cursor:not-allowed}._3O0I6:disabled~._Fn9K_{opacity:.4}._2LD3f{color:#32363a;display:flex;align-items:center;cursor:pointer}._1LxSf{cursor:auto;color:hsla(0,0%,53.7%,.4)}._3nbQg{margin-right:12px;flex-shrink:0}._Fn9K_{display:flex;align-items:center;justify-content:center;position:absolute;top:0;left:0;height:16px;width:16px;background-color:#fff;border-radius:4px;border:1px solid #898989;z-index:0}._ZKA7b{fill:#0b6ed0;fill-opacity:0}body.keyboard-user ._3O0I6:active:focus~._Fn9K_,body.keyboard-user ._3O0I6:focus~._Fn9K_{border-color:#0b6ed0;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
1938
- var styles$9 = {"checkbox":"_1gqCL","input":"_3O0I6","check":"_Fn9K_","checkIcon":"_ZKA7b","label":"_2LD3f","labelDisabled":"_1LxSf","wrappedInput":"_3nbQg"};
1939
- var stylesheet$a="._1gqCL{display:inline-flex;position:relative;margin-top:6px;margin-bottom:6px}._1gqCL,._3O0I6{cursor:pointer;height:16px;width:16px}._3O0I6{position:absolute;opacity:0;z-index:10}._3O0I6:checked~._Fn9K_>._ZKA7b{fill-opacity:1}._3O0I6:checked:enabled~._Fn9K_{border-color:transparent;background-color:#0b6ed0}._3O0I6:checked:enabled~._Fn9K_>._ZKA7b{fill:#fff}._3O0I6:checked:enabled:hover~._Fn9K_{background-color:#085caf}._3O0I6:not(:checked):enabled:hover~._Fn9K_{border-color:#0b6ed0}._3O0I6:disabled{cursor:not-allowed}._3O0I6:disabled~._Fn9K_{opacity:.4}._2LD3f{color:#32363a;display:flex;align-items:center;cursor:pointer}._1LxSf{cursor:auto;color:hsla(0,0%,53.7%,.4)}._3nbQg{margin-right:12px;flex-shrink:0}._Fn9K_{display:flex;align-items:center;justify-content:center;position:absolute;top:0;left:0;height:16px;width:16px;background-color:#fff;border-radius:4px;border:1px solid #898989;z-index:0}._ZKA7b{fill:#0b6ed0;fill-opacity:0}body.keyboard-user ._3O0I6:active:focus~._Fn9K_,body.keyboard-user ._3O0I6:focus~._Fn9K_{border-color:#0b6ed0;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
1940
- icons_index.styleInject(css_248z$a);
1941
-
1942
- const Check = props => /*#__PURE__*/React__default["default"].createElement("svg", _extends__default["default"]({}, props, {
1943
- width: "16",
1944
- height: "16",
1945
- focusable: "false",
1946
- "aria-hidden": "true",
1947
- viewBox: "0 0 16 16",
1948
- xmlns: "http://www.w3.org/2000/svg",
1949
- "data-icontype": "Check"
1950
- }), /*#__PURE__*/React__default["default"].createElement("path", {
1951
- fillRule: "evenodd",
1952
- clipRule: "evenodd",
1953
- d: "M12.7206 4.65576C13.1211 5.09851 13.087 5.78216 12.6442 6.18273L6.96856 11.3179C6.56187 11.6858 5.9441 11.6909 5.53136 11.3298L3.3692 9.4379C2.91986 9.04474 2.87433 8.36175 3.2675 7.91241C3.66067 7.46308 4.34365 7.41755 4.79299 7.81072L6.23123 9.06918L11.1936 4.57942C11.6363 4.17884 12.32 4.21302 12.7206 4.65576Z"
1954
- }));
1955
-
1956
- const {
1957
- Provider: FormFieldProvider,
1958
- useContext: useFormFieldContext
1959
- } = createContextUtilities({});
1960
-
1961
- const useFormFieldControl = () => {
1962
- const context = useFormFieldContext();
1963
- const {
1964
- setHasControl
1965
- } = context;
1966
- React.useEffect(() => {
1967
- setHasControl === null || setHasControl === void 0 ? void 0 : setHasControl(true);
1968
- }, [setHasControl]);
1969
- return context;
1970
- };
1971
-
1972
- const useFormFieldLabel = () => {
1973
- const context = useFormFieldContext();
1974
- const {
1975
- setHasLabel
1976
- } = context;
1977
- React.useEffect(() => {
1978
- setHasLabel === null || setHasLabel === void 0 ? void 0 : setHasLabel(true);
1979
- }, [setHasLabel]);
1980
- return context;
1981
- };
1982
-
1983
- const useFormFieldType = type => {
1984
- const context = useFormFieldContext();
1985
- const {
1986
- setFormFieldType
1987
- } = context;
1988
- React.useEffect(() => {
1989
- setFormFieldType === null || setFormFieldType === void 0 ? void 0 : setFormFieldType(type);
1990
- }, [setFormFieldType, type]);
1991
- return context;
1992
- };
1993
-
1994
- const Checkbox = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
1995
- let {
1996
- id,
1997
- className,
1998
- checked,
1999
- defaultChecked,
2000
- disabled = false,
2001
- onChange,
2002
- value,
2003
- name,
2004
- inputProps,
2005
- 'aria-label': externalAriaLabel,
2006
- 'aria-labelledby': externalAriaLabelledBy,
2007
- 'aria-describedby': externalAriaDescribedBy,
2008
- ...rest
2009
- } = _ref;
2010
- const {
2011
- helperTextId: formFieldHelperTextId,
2012
- errorTextId: formFieldErrorTextId
2013
- } = useFormFieldContext();
2014
- const internalAriaDescribedby = concatIds(externalAriaDescribedBy, formFieldHelperTextId, formFieldErrorTextId, inputProps === null || inputProps === void 0 ? void 0 : inputProps['aria-describedby']);
2015
- return /*#__PURE__*/React__default["default"].createElement("span", _extends__default["default"]({}, rest, {
2016
- ref: ref,
2017
- className: classNames__default["default"](className, styles$9.checkbox)
2018
- }), /*#__PURE__*/React__default["default"].createElement("input", _extends__default["default"]({}, inputProps, {
2019
- name: name !== null && name !== void 0 ? name : inputProps === null || inputProps === void 0 ? void 0 : inputProps.name,
2020
- className: classNames__default["default"](styles$9.input, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
2021
- type: "checkbox",
2022
- id: id !== null && id !== void 0 ? id : inputProps === null || inputProps === void 0 ? void 0 : inputProps.id,
2023
- checked: checked !== null && checked !== void 0 ? checked : inputProps === null || inputProps === void 0 ? void 0 : inputProps.checked,
2024
- defaultChecked: defaultChecked !== null && defaultChecked !== void 0 ? defaultChecked : inputProps === null || inputProps === void 0 ? void 0 : inputProps.defaultChecked,
2025
- disabled: disabled !== null && disabled !== void 0 ? disabled : inputProps === null || inputProps === void 0 ? void 0 : inputProps.disabled,
2026
- onChange: disabled ? undefined : onChange !== null && onChange !== void 0 ? onChange : inputProps === null || inputProps === void 0 ? void 0 : inputProps.onChange,
2027
- value: value !== null && value !== void 0 ? value : inputProps === null || inputProps === void 0 ? void 0 : inputProps.value,
2028
- "aria-label": externalAriaLabel !== null && externalAriaLabel !== void 0 ? externalAriaLabel : inputProps === null || inputProps === void 0 ? void 0 : inputProps['aria-label'],
2029
- "aria-labelledby": externalAriaLabelledBy !== null && externalAriaLabelledBy !== void 0 ? externalAriaLabelledBy : inputProps === null || inputProps === void 0 ? void 0 : inputProps['aria-labelledby'],
2030
- "aria-describedby": internalAriaDescribedby
2031
- })), /*#__PURE__*/React__default["default"].createElement("span", {
2032
- className: styles$9.check
2033
- }, /*#__PURE__*/React__default["default"].createElement(Check, {
2034
- className: styles$9.checkIcon
2035
- })));
2036
- });
2037
-
2038
- var css_248z$9 = "._gLS3L{font-size:14px}._24TVg{color:#6a6d70;line-height:20px;display:inline-flex;flex-direction:column;align-items:flex-start}._12gAL{color:#0b6ed0}";
2039
- var styles$8 = {"label":"_gLS3L","control":"_24TVg","focused":"_12gAL"};
2040
- var stylesheet$9="._gLS3L{font-size:14px}._24TVg{color:#6a6d70;line-height:20px;display:inline-flex;flex-direction:column;align-items:flex-start}._12gAL{color:#0b6ed0}";
2041
- icons_index.styleInject(css_248z$9);
2042
-
2043
- const Label = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2044
- let {
2045
- children,
2046
- className,
2047
- ...rest
2048
- } = _ref;
2049
- const {
2050
- isFocused,
2051
- hasControl
2052
- } = useFormFieldLabel();
2053
- const classes = classNames__default["default"](styles$8.label, className, {
2054
- [styles$8.control]: hasControl,
2055
- [styles$8.focused]: isFocused
2056
- });
2057
- return /*#__PURE__*/React__default["default"].createElement("label", _extends__default["default"]({}, rest, {
2058
- ref: ref,
2059
- className: classes
2060
- }), children);
2061
- });
2062
-
2063
- var css_248z$8 = "._2xnfm{display:inline-block;height:36px;min-height:36px;padding:8px 12px;line-height:20px;font-size:14px;color:#32363a;caret-color:#32363a;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._2xnfm::-moz-placeholder{color:#515559;opacity:1}._2xnfm::placeholder{color:#515559;opacity:1}._2xnfm:hover{cursor:pointer;background-color:#f5f5f5}._2xnfm:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa;cursor:text;outline:none;border-color:transparent}._2xnfm._23vXv{border-color:#b00}._2xnfm._23vXv:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._2xnfm:disabled{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._2xnfm:disabled::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2xnfm:disabled::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2xnfm._3nQbr{height:auto}._2xnfm._3nQbr::-webkit-resizer{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOCIgaGVpZ2h0PSI4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03IDF2M2EzIDMgMCAwMS0zIDNIMSIgc3Ryb2tlPSIjOTI5MjkyIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==);background-size:8px 8px;background-repeat:no-repeat;background-position:50%}._2xnfm._PYPdA{display:block;width:100%}._2xnfm._3GPDR{padding:4px 8px}input._2xnfm._3GPDR{height:26px;min-height:26px}[type=number]._2xnfm{-moz-appearance:textfield}[type=number]._2xnfm::-webkit-inner-spin-button,[type=number]._2xnfm::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._1SETD{line-height:20px;color:#6a6d70;display:flex;flex-direction:column;align-items:flex-start}._1SETD:hover{cursor:pointer}._1SETD._2z_Xc{color:#0b6ed0}._3O5wL{margin-top:4px}";
2064
- var styles$7 = {"input":"_2xnfm","invalid":"_23vXv","multiline":"_3nQbr","full":"_PYPdA","small":"_3GPDR","label":"_1SETD","focused":"_2z_Xc","wrappedInput":"_3O5wL"};
2065
- var stylesheet$8="._2xnfm{display:inline-block;height:36px;min-height:36px;padding:8px 12px;line-height:20px;font-size:14px;color:#32363a;caret-color:#32363a;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._2xnfm::-moz-placeholder{color:#515559;opacity:1}._2xnfm::placeholder{color:#515559;opacity:1}._2xnfm:hover{cursor:pointer;background-color:#f5f5f5}._2xnfm:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa;cursor:text;outline:none;border-color:transparent}._2xnfm._23vXv{border-color:#b00}._2xnfm._23vXv:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._2xnfm:disabled{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._2xnfm:disabled::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2xnfm:disabled::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2xnfm._3nQbr{height:auto}._2xnfm._3nQbr::-webkit-resizer{background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOCIgaGVpZ2h0PSI4IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03IDF2M2EzIDMgMCAwMS0zIDNIMSIgc3Ryb2tlPSIjOTI5MjkyIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjwvc3ZnPg==);background-size:8px 8px;background-repeat:no-repeat;background-position:50%}._2xnfm._PYPdA{display:block;width:100%}._2xnfm._3GPDR{padding:4px 8px}input._2xnfm._3GPDR{height:26px;min-height:26px}[type=number]._2xnfm{-moz-appearance:textfield}[type=number]._2xnfm::-webkit-inner-spin-button,[type=number]._2xnfm::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._1SETD{line-height:20px;color:#6a6d70;display:flex;flex-direction:column;align-items:flex-start}._1SETD:hover{cursor:pointer}._1SETD._2z_Xc{color:#0b6ed0}._3O5wL{margin-top:4px}";
2066
- icons_index.styleInject(css_248z$8);
2067
-
2068
- const Input$1 = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2069
- let {
2070
- className,
2071
- value,
2072
- defaultValue,
2073
- disabled = false,
2074
- full = false,
2075
- invalid = false,
2076
- multiline,
2077
- onChange,
2078
- rows = 2,
2079
- small = false,
2080
- type = 'text',
2081
- 'aria-describedby': externalAriaDescribedBy,
2082
- readOnly,
2083
- ...rest
2084
- } = _ref;
2085
- const inputGroupContext = useInputGroupContext();
2086
- const {
2087
- helperTextId: formFieldHelperTextId,
2088
- errorTextId: formFieldErrorTextId,
2089
- isReadOnly: formFieldIsReadOnly
2090
- } = useFormFieldContext();
2091
- const internalAriaDescribedby = concatIds(externalAriaDescribedBy, formFieldHelperTextId, formFieldErrorTextId);
2092
- const classes = classNames__default["default"](styles$7.input, inputGroupContext.className, inputGroupContext.inputClassName, {
2093
- [styles$7.full]: inputGroupContext.applyFull(full),
2094
- [styles$7.invalid]: invalid,
2095
- [styles$7.small]: inputGroupContext.applySmall(small),
2096
- [styles$7.multiline]: multiline
2097
- }, className);
2098
- const commonProps = { ...rest,
2099
- ref,
2100
- className: classes,
2101
- disabled,
2102
- defaultValue,
2103
- 'aria-invalid': invalid,
2104
- onChange: disabled ? null : onChange,
2105
- value,
2106
- 'aria-describedby': internalAriaDescribedby,
2107
- readOnly: readOnly !== null && readOnly !== void 0 ? readOnly : formFieldIsReadOnly
2108
- };
2109
- return multiline ? /*#__PURE__*/React__default["default"].createElement("textarea", _extends__default["default"]({}, commonProps, {
2110
- rows: rows
2111
- })) : /*#__PURE__*/React__default["default"].createElement("input", _extends__default["default"]({}, commonProps, {
2112
- type: type
2113
- }));
2114
- });
2115
-
2116
- const InputField = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2117
- let {
2118
- label,
2119
- className,
2120
- style = {},
2121
- 'data-testid': dataTestId,
2122
- id,
2123
- onFocus,
2124
- onBlur,
2125
- labelProps = {},
2126
- inputProps = {},
2127
- ...rest
2128
- } = _ref;
2129
- const {
2130
- className: labelClassName,
2131
- ...labelPropsWithoutClass
2132
- } = labelProps;
2133
- const {
2134
- className: inputClassName,
2135
- ...inputPropsWithoutClass
2136
- } = inputProps;
2137
- const [focused, setFocused] = React.useState(false);
2138
- useFormFieldType('input');
2139
-
2140
- function handleFocus(e) {
2141
- setFocused(true);
2142
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
2143
- }
2144
-
2145
- function handleBlur(e) {
2146
- setFocused(false);
2147
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
2148
- }
2149
-
2150
- return /*#__PURE__*/React__default["default"].createElement(Label, _extends__default["default"]({
2151
- htmlFor: id,
2152
- "data-testid": dataTestId,
2153
- className: classNames__default["default"](className, styles$7.label, labelClassName, {
2154
- [styles$7.focused]: focused
2155
- }),
2156
- style: style
2157
- }, labelPropsWithoutClass), label, /*#__PURE__*/React__default["default"].createElement(Input$1, _extends__default["default"]({
2158
- id: id,
2159
- ref: ref,
2160
- className: classNames__default["default"](styles$7.wrappedInput, inputClassName),
2161
- onBlur: handleBlur,
2162
- onFocus: handleFocus
2163
- }, rest, inputPropsWithoutClass)));
2164
- });
2165
-
2166
- var css_248z$7 = "._OE8Po{border-radius:4px;border:none;height:36px;width:36px;display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;padding:0;cursor:pointer;fill:#515559;background-color:transparent;transition:background .2s,color .2s}._OE8Po:focus{outline:none}._OE8Po:hover:not(._3NRZx){background-color:rgba(50,54,58,.08)}._OE8Po:active:not(._3NRZx){background-color:rgba(50,54,58,.11);stroke-width:2}._OE8Po._3NRZx{cursor:not-allowed;fill:rgba(81,85,89,.6)}body.keyboard-user ._OE8Po:focus{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
2167
- var styles$6 = {"button":"_OE8Po","disabled":"_3NRZx"};
2168
- var stylesheet$7="._OE8Po{border-radius:4px;border:none;height:36px;width:36px;display:inline-flex;flex-shrink:0;align-items:center;justify-content:center;padding:0;cursor:pointer;fill:#515559;background-color:transparent;transition:background .2s,color .2s}._OE8Po:focus{outline:none}._OE8Po:hover:not(._3NRZx){background-color:rgba(50,54,58,.08)}._OE8Po:active:not(._3NRZx){background-color:rgba(50,54,58,.11);stroke-width:2}._OE8Po._3NRZx{cursor:not-allowed;fill:rgba(81,85,89,.6)}body.keyboard-user ._OE8Po:focus{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}";
2169
- icons_index.styleInject(css_248z$7);
2170
-
2171
- const sizePropInIconErrorMessage = 'Warning: The `Icon` prop `size` is invalid when used as a child of `IconButton`.';
2172
- const IconButton = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2173
- let {
2174
- children,
2175
- disabled = false,
2176
- 'aria-disabled': ariaDisabled = disabled,
2177
- className = '',
2178
- type = 'button',
2179
- tooltipContent,
2180
- tooltipPlacement,
2181
- isTooltipADescription = false,
2182
- onClick,
2183
- onKeyDown,
2184
- ...rest
2185
- } = _ref;
2186
- const classes = classNames__default["default"](className, styles$6.button, {
2187
- [styles$6.disabled]: disabled
2188
- });
2189
-
2190
- if (children.props.size) {
2191
- // eslint-disable-next-line no-console
2192
- console.error(sizePropInIconErrorMessage);
2193
- }
2194
-
2195
- const iconButtonComponent =
2196
- /*#__PURE__*/
2197
-
2198
- /* eslint-disable react/button-has-type */
2199
- React__default["default"].createElement("button", _extends__default["default"]({}, rest, {
2200
- type: type,
2201
- className: classes,
2202
- "aria-disabled": ariaDisabled,
2203
- ref: ref,
2204
- onClick: disabled ? undefined : onClick,
2205
- onKeyDown: disabled ? undefined : onKeyDown
2206
- }), /*#__PURE__*/React__default["default"].cloneElement(children, {
2207
- size: 'medium',
2208
- 'aria-hidden': true
2209
- }))
2210
- /* eslint-enable react/button-has-type */
2211
- ;
2212
-
2213
- if (tooltipContent) {
2214
- return /*#__PURE__*/React__default["default"].createElement(Tooltip, {
2215
- content: tooltipContent,
2216
- placement: tooltipPlacement,
2217
- delayMs: 500,
2218
- "aria-hidden": isTooltipADescription ? undefined : true
2219
- }, iconButtonComponent);
2220
- }
2221
-
2222
- return iconButtonComponent;
2223
- });
2224
-
2225
- /* eslint-disable import/prefer-default-export */
2226
-
2227
- var css_248z$6 = "._38mvY{border:none;height:1px;margin:0;flex-shrink:0;background-color:#e5e5e5}";
2228
- var styles$5 = {"divider":"_38mvY"};
2229
- var stylesheet$6="._38mvY{border:none;height:1px;margin:0;flex-shrink:0;background-color:#e5e5e5}";
2230
- icons_index.styleInject(css_248z$6);
2231
-
2232
- const Divider = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2233
- let {
2234
- className,
2235
- ...rest
2236
- } = _ref;
2237
- return /*#__PURE__*/React__default["default"].createElement("hr", _extends__default["default"]({
2238
- ref: ref,
2239
- className: classNames__default["default"](className, styles$5.divider)
2240
- }, rest));
2241
- });
2242
-
2243
- var css_248z$5 = "._2Nf7j{max-width:100%;position:relative;display:inline-block}._2AZjQ{display:inline-flex;justify-content:space-between;align-items:center;background-color:#fafafa;border:1px solid #898989;border-radius:4px;height:36px;color:#515559;outline:none;cursor:pointer}._2AZjQ:hover:not([aria-disabled=true]){cursor:pointer;background-color:#f5f5f5}._2AZjQ:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa}._2AZjQ:disabled,._2AZjQ[aria-disabled=true]{color:#74777a;border-color:#e5e5e5;cursor:not-allowed}._2AZjQ._2IRto{border-color:#b00}._2AZjQ._2IRto:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000}._2AZjQ._1ak4_{min-width:120px;padding:0 4px 0 12px}._2AZjQ._I3-sf{margin-top:4px}._2AZjQ._M346s:not([aria-disabled=true]):not(:disabled){color:#32363a}._2AZjQ ._2z4RJ{display:inline-flex;align-items:center;min-height:10px}._2AZjQ ._2z4RJ._3JA_s{line-height:20px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._2AZjQ ._6UAJ2{height:24px;width:24px;border-radius:4px;fill:#515559;flex-shrink:0;cursor:pointer}._2AZjQ ._6UAJ2._NRV7F{border-color:#e5e5e5;fill:#9d9fa1;opacity:.4;cursor:not-allowed}._2AZjQ ._6UAJ2._2sB1w{transform:rotate(-180deg)}._3VRUv[aria-disabled=true]{cursor:not-allowed;color:rgba(81,85,89,.65);fill:#9d9fa1}._1qr7x{position:-webkit-sticky;position:sticky;top:0;z-index:20;padding:4px 8px 8px!important;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;background-color:#fff!important}._1IFVq{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._UVl50{fill:#515559}._odytm{margin:2px 12px 2px 0}._odytm._1X-F3>svg{border-color:#0b6ed0}._1eZeF{width:100%}";
2244
- var styles$4 = {"container":"_2Nf7j","button":"_2AZjQ","invalid":"_2IRto","hasText":"_1ak4_","labelled":"_I3-sf","selected":"_M346s","buttonLabel":"_2z4RJ","isString":"_3JA_s","icon":"_6UAJ2","disabled":"_NRV7F","open":"_2sB1w","option":"_3VRUv","search":"_1qr7x","emptyOption":"_1IFVq","searchIcon":"_UVl50","checkbox":"_odytm","highlighted":"_1X-F3","searchInput":"_1eZeF"};
2245
- var stylesheet$5="._2Nf7j{max-width:100%;position:relative;display:inline-block}._2AZjQ{display:inline-flex;justify-content:space-between;align-items:center;background-color:#fafafa;border:1px solid #898989;border-radius:4px;height:36px;color:#515559;outline:none;cursor:pointer}._2AZjQ:hover:not([aria-disabled=true]){cursor:pointer;background-color:#f5f5f5}._2AZjQ:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;background-color:#fafafa}._2AZjQ:disabled,._2AZjQ[aria-disabled=true]{color:#74777a;border-color:#e5e5e5;cursor:not-allowed}._2AZjQ._2IRto{border-color:#b00}._2AZjQ._2IRto:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000}._2AZjQ._1ak4_{min-width:120px;padding:0 4px 0 12px}._2AZjQ._I3-sf{margin-top:4px}._2AZjQ._M346s:not([aria-disabled=true]):not(:disabled){color:#32363a}._2AZjQ ._2z4RJ{display:inline-flex;align-items:center;min-height:10px}._2AZjQ ._2z4RJ._3JA_s{line-height:20px;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._2AZjQ ._6UAJ2{height:24px;width:24px;border-radius:4px;fill:#515559;flex-shrink:0;cursor:pointer}._2AZjQ ._6UAJ2._NRV7F{border-color:#e5e5e5;fill:#9d9fa1;opacity:.4;cursor:not-allowed}._2AZjQ ._6UAJ2._2sB1w{transform:rotate(-180deg)}._3VRUv[aria-disabled=true]{cursor:not-allowed;color:rgba(81,85,89,.65);fill:#9d9fa1}._1qr7x{position:-webkit-sticky;position:sticky;top:0;z-index:20;padding:4px 8px 8px!important;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;background-color:#fff!important}._1IFVq{min-height:40px;padding:10px 12px;display:flex;flex-direction:row;align-items:center;background-color:#fff;font-size:14px;color:#32363a;word-break:break-word}._UVl50{fill:#515559}._odytm{margin:2px 12px 2px 0}._odytm._1X-F3>svg{border-color:#0b6ed0}._1eZeF{width:100%}";
2246
- icons_index.styleInject(css_248z$5);
2247
-
2248
- const {
2249
- useContext: useDropdownContext,
2250
- Provider: DropdownContextProvider
2251
- } = createContextUtilities({});
2252
-
2253
- const DropdownButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
2254
- var _ref2, _children$props$aria, _children$props, _ref3, _children$props$aria2, _children$props2, _ref4, _children$props$aria3, _children$props3, _children$props$tabIn, _children$props4, _children$props7, _children$props8;
2255
-
2256
- let {
2257
- children,
2258
- className,
2259
- disabled,
2260
- isInvalid: isInvalidProp,
2261
- defaultLabel = '',
2262
- label: externalLabel,
2263
- onLabelChange,
2264
- onKeyDown,
2265
- onClick,
2266
- onFocus,
2267
- onBlur,
2268
- 'aria-labelledby': externalAriaLabelledBy,
2269
- 'aria-label': externalAriaLabel,
2270
- 'aria-describedby': externalAriaDescribedBy,
2271
- 'data-testid': dataTestId,
2272
- ...rest
2273
- } = _ref;
2274
- const buttonRef = React.useRef(null);
2275
- const {
2276
- isOpen,
2277
- options,
2278
- setMinWidth,
2279
- setIsOpen,
2280
- disabled: dropdownAriaDisabled,
2281
- isInvalid: dropdownIsInvalid,
2282
- buttonRef: dropdownButtonRef,
2283
- onKeyDownButton,
2284
- selectedIndex,
2285
- setHighlightedIndex,
2286
- listId,
2287
- buttonId,
2288
- ariaLabelledBy: dropdownAriaLabelledBy,
2289
- ariaLabel: dropdownAriaLabel,
2290
- ariaDescribedby: dropdownAriaDescribedby,
2291
- dataTestId: contextDataTestId
2292
- } = useDropdownContext();
2293
- const [label, setLabel] = useControllableState(defaultLabel, // will get updated in effect
2294
- onLabelChange, externalLabel);
2295
- const [isOptionSelected, setIsOptionSelected] = React.useState(false);
2296
- const {
2297
- hasLabel: hasFormLabel,
2298
- helperTextId: formFieldHelperTextId,
2299
- errorTextId: formFieldErrorTextId
2300
- } = useFormFieldControl();
2301
- const ariaLabelledBy = (_ref2 = (_children$props$aria = children === null || children === void 0 ? void 0 : (_children$props = children.props) === null || _children$props === void 0 ? void 0 : _children$props['aria-labelledby']) !== null && _children$props$aria !== void 0 ? _children$props$aria : externalAriaLabelledBy) !== null && _ref2 !== void 0 ? _ref2 : dropdownAriaLabelledBy ? "".concat(dropdownAriaLabelledBy, " ").concat(buttonId) : undefined;
2302
- const ariaLabel = (_ref3 = (_children$props$aria2 = children === null || children === void 0 ? void 0 : (_children$props2 = children.props) === null || _children$props2 === void 0 ? void 0 : _children$props2['aria-label']) !== null && _children$props$aria2 !== void 0 ? _children$props$aria2 : externalAriaLabel) !== null && _ref3 !== void 0 ? _ref3 : dropdownAriaLabel && typeof label === 'string' ? "".concat(dropdownAriaLabel, " ").concat(label) : dropdownAriaLabel;
2303
- const ariaDescribedby = concatIds((_ref4 = (_children$props$aria3 = children === null || children === void 0 ? void 0 : (_children$props3 = children.props) === null || _children$props3 === void 0 ? void 0 : _children$props3['aria-describedby']) !== null && _children$props$aria3 !== void 0 ? _children$props$aria3 : externalAriaDescribedBy) !== null && _ref4 !== void 0 ? _ref4 : dropdownAriaDescribedby, formFieldHelperTextId, formFieldErrorTextId);
2304
- React.useEffect(() => {
2305
- const selectedLabels = [];
2306
- options.forEach(option => {
2307
- if (option.isSelected) {
2308
- selectedLabels.push(option.label);
2309
- }
2310
- });
2311
- setIsOptionSelected(selectedLabels.length > 0);
2312
- setLabel(selectedLabels.length > 0 ? selectedLabels.join(', ') : defaultLabel);
2313
- }, [setLabel, options, defaultLabel]);
2314
- React.useEffect(() => {
2315
- var _buttonRef$current;
2316
-
2317
- setMinWidth(buttonRef === null || buttonRef === void 0 ? void 0 : (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.offsetWidth);
2318
- });
2319
- const isInvalid = isInvalidProp !== undefined ? isInvalidProp : dropdownIsInvalid;
2320
-
2321
- const handleClick = e => {
2322
- if (disabled !== null && disabled !== void 0 ? disabled : dropdownAriaDisabled) return;
2323
- onClick === null || onClick === void 0 ? void 0 : onClick(e); // Needed because some browsers don't focus on click
2324
-
2325
- e.currentTarget.focus();
2326
- setIsOpen(currentIsOpen => {
2327
- setHighlightedIndex(currentIsOpen ? -1 : selectedIndex);
2328
- return !currentIsOpen;
2329
- });
2330
- };
2331
-
2332
- const handleKeyDown = e => {
2333
- if (disabled !== null && disabled !== void 0 ? disabled : dropdownAriaDisabled) return;
2334
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
2335
- onKeyDownButton(e);
2336
- };
2337
-
2338
- return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, children ? /*#__PURE__*/React__default["default"].cloneElement(children, {
2339
- ref: mergeRefs(ref, children === null || children === void 0 ? void 0 : children.ref, buttonRef, dropdownButtonRef),
2340
- disabled: disabled || dropdownAriaDisabled,
2341
- 'aria-disabled': dropdownAriaDisabled,
2342
- tabIndex: (_children$props$tabIn = (_children$props4 = children.props) === null || _children$props4 === void 0 ? void 0 : _children$props4.tabIndex) !== null && _children$props$tabIn !== void 0 ? _children$props$tabIn : 0,
2343
- role: 'button',
2344
- 'aria-expanded': isOpen,
2345
- 'aria-haspopup': 'listbox',
2346
- 'aria-controls': listId,
2347
- 'aria-labelledby': ariaLabelledBy,
2348
- 'aria-label': ariaLabel,
2349
- 'aria-describedby': ariaDescribedby,
2350
- id: buttonId,
2351
- onFocus: e => {
2352
- var _children$props5, _children$props5$onFo;
2353
-
2354
- (_children$props5 = children.props) === null || _children$props5 === void 0 ? void 0 : (_children$props5$onFo = _children$props5.onFocus) === null || _children$props5$onFo === void 0 ? void 0 : _children$props5$onFo.call(_children$props5, e);
2355
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
2356
- },
2357
- onBlur: e => {
2358
- var _children$props6, _children$props6$onBl;
2359
-
2360
- (_children$props6 = children.props) === null || _children$props6 === void 0 ? void 0 : (_children$props6$onBl = _children$props6.onBlur) === null || _children$props6$onBl === void 0 ? void 0 : _children$props6$onBl.call(_children$props6, e);
2361
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
2362
- },
2363
- onKeyDown: wrapEvent((_children$props7 = children.props) === null || _children$props7 === void 0 ? void 0 : _children$props7.onKeyDown, handleKeyDown),
2364
- onClick: wrapEvent((_children$props8 = children.props) === null || _children$props8 === void 0 ? void 0 : _children$props8.onClick, handleClick)
2365
- }) : /*#__PURE__*/React__default["default"].createElement("button", _extends__default["default"]({}, rest, {
2366
- ref: mergeRefs(ref, buttonRef, dropdownButtonRef),
2367
- type: "button",
2368
- disabled: disabled || dropdownAriaDisabled,
2369
- "aria-disabled": dropdownAriaDisabled,
2370
- "aria-expanded": isOpen,
2371
- "aria-haspopup": "listbox",
2372
- "aria-controls": listId,
2373
- "aria-labelledby": ariaLabelledBy,
2374
- "aria-label": ariaLabel,
2375
- "aria-describedby": ariaDescribedby,
2376
- id: buttonId,
2377
- className: classNames__default["default"](className, styles$4.button, {
2378
- [styles$4.hasText]: !!label,
2379
- [styles$4.invalid]: isInvalid,
2380
- [styles$4.labelled]: hasFormLabel,
2381
- [styles$4.selected]: externalLabel !== null && externalLabel !== void 0 ? externalLabel : isOptionSelected // defaultLabel has lighter text color
2382
-
2383
- }),
2384
- onFocus: onFocus,
2385
- onBlur: onBlur,
2386
- onKeyDown: handleKeyDown,
2387
- onClick: handleClick,
2388
- "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : getSubDataTestId(contextDataTestId, 'button')
2389
- }), /*#__PURE__*/React__default["default"].createElement("span", {
2390
- className: classNames__default["default"](styles$4.buttonLabel, {
2391
- [styles$4.isString]: typeof label === 'string'
2392
- })
2393
- }, label), /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronDownIcon, {
2394
- size: "medium",
2395
- className: classNames__default["default"](styles$4.icon, {
2396
- [styles$4.open]: isOpen,
2397
- [styles$4.disabled]: disabled !== null && disabled !== void 0 ? disabled : dropdownAriaDisabled
2398
- }),
2399
- "aria-hidden": "true"
2400
- })));
2401
- });
2402
-
2403
- /* eslint-disable @typescript-eslint/no-shadow */
2404
-
2405
- /**
2406
- * This hook registers our descendant by passing it into an array. We can then
2407
- * search that array by to find its index when registering it in the component.
2408
- * We use this for focus management, keyboard navigation, and typeahead
2409
- * functionality for some components.
2410
- *
2411
- * The hook accepts the element node and (optionally) a key. The key is useful
2412
- * if multiple descendants have identical text values and we need to
2413
- * differentiate siblings for some reason.
2414
- *
2415
- * Our main goals with this are:
2416
- * 1) maximum composability,
2417
- * 2) minimal API friction
2418
- * 3) SSR compatibility*
2419
- * 4) concurrent safe
2420
- * 5) index always up-to-date with the tree despite changes
2421
- * 6) works with memoization of any component in the tree (hopefully)
2422
- *
2423
- * * As for SSR, the good news is that we don't actually need the index on the
2424
- * server for most use-cases, as we are only using it to determine the order of
2425
- * composed descendants for keyboard navigation. However, in the few cases where
2426
- * this is not the case, we can require an explicit index from the app.
2427
- */
2428
- function useDescendant(descendant, context, indexProp) {
2429
- const [, forceUpdate] = React.useState({});
2430
- const {
2431
- registerDescendant,
2432
- unregisterDescendant,
2433
- descendants
2434
- } = React.useContext(context); // This will initially return -1 because we haven't registered the descendant
2435
- // on the first render. After we register, this will then return the correct
2436
- // index on the following render and we will re-register descendants
2437
- // so that everything is up-to-date before the user interacts with a
2438
- // collection.
2439
-
2440
- const index = indexProp !== null && indexProp !== void 0 ? indexProp : descendants.findIndex(item => item.element === descendant.element);
2441
- const previousDescendants = usePrevious(descendants); // We also need to re-register descendants any time ANY of the other
2442
- // descendants have changed. My brain was melting when I wrote this and it
2443
- // feels a little off, but checking in render and using the result in the
2444
- // effect's dependency array works well enough.
2445
-
2446
- const someDescendantsHaveChanged = descendants.some((descendant, index) => {
2447
- var _previousDescendants$;
2448
-
2449
- return descendant.element !== (previousDescendants === null || previousDescendants === void 0 ? void 0 : (_previousDescendants$ = previousDescendants[index]) === null || _previousDescendants$ === void 0 ? void 0 : _previousDescendants$.element);
2450
- }); // Prevent any flashing
2451
-
2452
- useSSRLayoutEffect(() => {
2453
- if (!descendant.element) forceUpdate({});
2454
- registerDescendant({ ...descendant,
2455
- index
2456
- });
2457
- return () => unregisterDescendant(descendant.element); // eslint-disable-next-line react-hooks/exhaustive-deps
2458
- }, [registerDescendant, unregisterDescendant, index, someDescendantsHaveChanged, // eslint-disable-next-line react-hooks/exhaustive-deps
2459
- ...Object.values(descendant)]);
2460
- return index;
2461
- }
2462
- function useDescendants(ctx) {
2463
- return React.useContext(ctx).descendants;
2464
- }
2465
- function DescendantProvider(_ref) {
2466
- let {
2467
- context: Ctx,
2468
- children,
2469
- items,
2470
- set
2471
- } = _ref;
2472
- const registerDescendant = React.useCallback(_ref2 => {
2473
- let {
2474
- element,
2475
- index: explicitIndex,
2476
- ...rest
2477
- } = _ref2;
2478
-
2479
- if (!element) {
2480
- return;
2481
- } // eslint-disable-next-line no-shadow
2482
-
2483
-
2484
- set(items => {
2485
- let newItems;
2486
-
2487
- if (explicitIndex != null) {
2488
- newItems = [...items, { ...rest,
2489
- element,
2490
- index: explicitIndex
2491
- }];
2492
- } else if (items.length === 0) {
2493
- // If there are no items, register at index 0 and bail.
2494
- newItems = [...items, { ...rest,
2495
- element,
2496
- index: 0
2497
- }];
2498
- } else if (items.find(item => item.element === element)) {
2499
- // If the element is already registered, just use the same array
2500
- newItems = items;
2501
- } else {
2502
- // When registering a descendant, we need to make sure we insert in
2503
- // into the array in the same order that it appears in the DOM. So as
2504
- // new descendants are added or maybe some are removed, we always know
2505
- // that the array is up-to-date and correct.
2506
- //
2507
- // So here we look at our registered descendants and see if the new
2508
- // element we are adding appears earlier than an existing descendant's
2509
- // DOM node via `node.compareDocumentPosition`. If it does, we insert
2510
- // the new element at this index. Because `registerDescendant` will be
2511
- // called in an effect every time the descendants state value changes,
2512
- // we should be sure that this index is accurate when descendent
2513
- // elements come or go from our component.
2514
- const index = items.findIndex(item => {
2515
- if (!item.element || !element) {
2516
- return false;
2517
- } // Does this element's DOM node appear before another item in the
2518
- // array in our DOM tree? If so, return true to grab the index at
2519
- // this point in the array so we know where to insert the new
2520
- // element.
2521
-
2522
-
2523
- return Boolean( // eslint-disable-next-line no-bitwise
2524
- item.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING);
2525
- });
2526
- const newItem = { ...rest,
2527
- element,
2528
- index
2529
- }; // If an index is not found we will push the element to the end.
2530
-
2531
- if (index === -1) {
2532
- newItems = [...items, newItem];
2533
- } else {
2534
- newItems = [...items.slice(0, index), newItem, ...items.slice(index)];
2535
- }
2536
- }
2537
-
2538
- return newItems.map((item, index) => ({ ...item,
2539
- index
2540
- }));
2541
- });
2542
- }, // set is a state setter initialized by the useDescendants hook.
2543
- // We can safely ignore the lint warning here because it will not change
2544
- // between renders.
2545
- // eslint-disable-next-line react-hooks/exhaustive-deps
2546
- []);
2547
- const unregisterDescendant = React.useCallback(element => {
2548
- if (!element) {
2549
- return;
2550
- } // eslint-disable-next-line no-shadow
2551
-
2552
-
2553
- set(items => items.filter(item => element !== item.element));
2554
- }, // set is a state setter initialized by the useDescendants hook.
2555
- // We can safely ignore the lint warning here because it will not change
2556
- // between renders.
2557
- // eslint-disable-next-line react-hooks/exhaustive-deps
2558
- []);
2559
- return /*#__PURE__*/React__default["default"].createElement(Ctx.Provider, {
2560
- value: React.useMemo(() => ({
2561
- descendants: items,
2562
- registerDescendant,
2563
- unregisterDescendant
2564
- }), [items, registerDescendant, unregisterDescendant])
2565
- }, children);
2566
- }
2567
-
2568
- const noop = param => {}; // eslint-disable-line @typescript-eslint/no-unused-vars
2569
-
2570
-
2571
- const ChildIndexContext = /*#__PURE__*/React.createContext({
2572
- descendants: [],
2573
- registerDescendant: noop,
2574
- unregisterDescendant: noop
2575
- });
2576
- const ChildIndexProvider = _ref => {
2577
- let {
2578
- items,
2579
- setItems,
2580
- children
2581
- } = _ref;
2582
- return /*#__PURE__*/React__default["default"].createElement(DescendantProvider, {
2583
- context: ChildIndexContext,
2584
- items: items,
2585
- set: setItems
2586
- }, children);
2587
- };
2588
- function useChildIndex(_ref2) {
2589
- let {
2590
- element,
2591
- ...rest
2592
- } = _ref2;
2593
- return useDescendant({
2594
- element,
2595
- ...rest
2596
- }, ChildIndexContext);
2597
- }
2598
-
2599
- var css_248z$4 = "._2Dsdy{position:relative;display:inline-block;height:36px}._2u7bu{width:100%;height:100%;padding:8px 12px;color:#32363a;caret-color:#32363a;font-size:14px;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._2u7bu:hover{cursor:pointer;background-color:#f5f5f5}._2u7bu:focus{background-color:#fafafa;cursor:text;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;outline:none;border-color:transparent}._2u7bu:disabled,._2u7bu[aria-disabled=true]{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._2u7bu:disabled::-moz-placeholder,._2u7bu[aria-disabled=true]::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2u7bu:disabled::placeholder,._2u7bu[aria-disabled=true]::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2u7bu:invalid,._2u7bu[aria-invalid=true]{border-color:#b00}._2u7bu:invalid:focus,._2u7bu[aria-invalid=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._2u7bu[type=number]{-moz-appearance:textfield}._2u7bu[type=number]::-webkit-inner-spin-button,._2u7bu[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._2u7bu::-moz-placeholder{color:#515559;opacity:1}._2u7bu::placeholder{color:#515559;opacity:1}._1NcJv{pointer-events:none;color:#515559;fill:#515559}._-uEgv{display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._2HMrz{color:#515559;font-size:16px}._HofLi{left:0;margin-left:6px}._HofLi,._Ovac2{pointer-events:none;color:#515559;fill:#515559;display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._Ovac2{right:0;margin-right:6px}";
2600
- var inputClasses = {"container":"_2Dsdy","input":"_2u7bu","addOn":"_1NcJv","addOnVerticalCenter":"_-uEgv","addOnTextNode":"_2HMrz","leftAddOn":"_HofLi","rightAddOn":"_Ovac2"};
2601
- var stylesheet$4="._2Dsdy{position:relative;display:inline-block;height:36px}._2u7bu{width:100%;height:100%;padding:8px 12px;color:#32363a;caret-color:#32363a;font-size:14px;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._2u7bu:hover{cursor:pointer;background-color:#f5f5f5}._2u7bu:focus{background-color:#fafafa;cursor:text;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;outline:none;border-color:transparent}._2u7bu:disabled,._2u7bu[aria-disabled=true]{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._2u7bu:disabled::-moz-placeholder,._2u7bu[aria-disabled=true]::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2u7bu:disabled::placeholder,._2u7bu[aria-disabled=true]::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._2u7bu:invalid,._2u7bu[aria-invalid=true]{border-color:#b00}._2u7bu:invalid:focus,._2u7bu[aria-invalid=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._2u7bu[type=number]{-moz-appearance:textfield}._2u7bu[type=number]::-webkit-inner-spin-button,._2u7bu[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._2u7bu::-moz-placeholder{color:#515559;opacity:1}._2u7bu::placeholder{color:#515559;opacity:1}._1NcJv{pointer-events:none;color:#515559;fill:#515559}._-uEgv{display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._2HMrz{color:#515559;font-size:16px}._HofLi{left:0;margin-left:6px}._HofLi,._Ovac2{pointer-events:none;color:#515559;fill:#515559;display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._Ovac2{right:0;margin-right:6px}";
2602
- icons_index.styleInject(css_248z$4);
2603
-
2604
- const getAddOnComponent = (addOn, containerClassName, containerRef) => {
2605
- if (!addOn) {
2606
- return null;
2607
- }
2608
-
2609
- const isAddOnAStringOrNumber = typeof addOn === 'string' || typeof addOn === 'number';
2610
- return /*#__PURE__*/React__default["default"].createElement("span", {
2611
- className: classNames__default["default"](containerClassName, {
2612
- [inputClasses.addOnTextNode]: isAddOnAStringOrNumber
2613
- }),
2614
- "aria-hidden": isAddOnAStringOrNumber,
2615
- ref: containerRef
2616
- }, addOn);
2617
- };
2618
-
2619
- const Input = /*#__PURE__*/React.forwardRef((_ref, ref) => {
2620
- let {
2621
- type = 'text',
2622
- initialValue,
2623
- value,
2624
- onChange,
2625
- leftAddOn,
2626
- rightAddOn,
2627
- className: externalClassName,
2628
- style,
2629
- ...rest
2630
- } = _ref;
2631
- const leftAddOnRef = React.useRef(null);
2632
- const rightAddOnRef = React.useRef(null);
2633
- const [addOnWidths, setAddOnWidths] = React.useState({
2634
- leftAddOnWidth: 0,
2635
- rightAddOnWidth: 0
2636
- });
2637
- const ADD_ON_HORIZONTAL_PADDING = 12;
2638
- useSSRLayoutEffect(() => {
2639
- let leftAddOnWidth = 0;
2640
- let rightAddOnWidth = 0;
2641
-
2642
- if (leftAddOnRef.current) {
2643
- leftAddOnWidth = leftAddOnRef.current.getBoundingClientRect().width;
2644
- }
2645
-
2646
- if (rightAddOnRef.current) {
2647
- rightAddOnWidth = rightAddOnRef.current.getBoundingClientRect().width;
2648
- }
2649
-
2650
- setAddOnWidths({
2651
- leftAddOnWidth,
2652
- rightAddOnWidth
2653
- });
2654
- }, [leftAddOn, // Re-runs effect when the left add-on changes
2655
- rightAddOn // Re-runs effect when the right add-on changes
2656
- ]);
2657
- return /*#__PURE__*/React__default["default"].createElement("span", {
2658
- className: classNames__default["default"](inputClasses.container, externalClassName),
2659
- style: style
2660
- }, getAddOnComponent(leftAddOn, inputClasses.leftAddOn, leftAddOnRef), /*#__PURE__*/React__default["default"].createElement("input", _extends__default["default"]({}, rest, {
2661
- type: type,
2662
- defaultValue: initialValue,
2663
- value: value,
2664
- onChange: onChange,
2665
- className: inputClasses.input,
2666
- style: {
2667
- paddingLeft: "".concat(addOnWidths.leftAddOnWidth + ADD_ON_HORIZONTAL_PADDING, "px"),
2668
- paddingRight: "".concat(addOnWidths.rightAddOnWidth + ADD_ON_HORIZONTAL_PADDING, "px")
2669
- },
2670
- ref: ref
2671
- })), getAddOnComponent(rightAddOn, inputClasses.rightAddOn, rightAddOnRef));
2672
- });
2673
-
2674
- const DropdownSearch = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
2675
- const {
2676
- translate
2677
- } = useTranslation();
2678
- const searchText = translate('searchText');
2679
- const internalRef = React.useRef(null);
2680
- const inputRef = React.useRef(null);
2681
- const {
2682
- isOpen,
2683
- highlightedIndex,
2684
- setIsKeyboardUser,
2685
- setHighlightedIndex,
2686
- searchValue,
2687
- setSearchValue,
2688
- isKeyboardUser,
2689
- setSearchHeight,
2690
- dataTestId
2691
- } = useDropdownContext();
2692
-
2693
- const handleSelect = () => {
2694
- var _inputRef$current;
2695
-
2696
- return (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
2697
- };
2698
-
2699
- const myIndex = useChildIndex({
2700
- element: internalRef.current,
2701
- isVisible: true
2702
- });
2703
- const isHighlighted = React.useMemo(() => highlightedIndex === myIndex && myIndex !== -1, [highlightedIndex, myIndex]);
2704
- React.useEffect(() => {
2705
- // for keyboard navigation
2706
- if (isHighlighted && isKeyboardUser) {
2707
- var _inputRef$current2;
2708
-
2709
- (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.focus();
2710
- }
2711
- }, [isHighlighted, isKeyboardUser]);
2712
- React.useEffect(() => {
2713
- // for initial open with mouse
2714
- if (isHighlighted && isOpen) {
2715
- var _inputRef$current3;
2716
-
2717
- (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.focus();
2718
- } // Omitted `isHighlighted` because we don't want to focus the input on mouse enter.
2719
- // eslint-disable-next-line react-hooks/exhaustive-deps
2720
-
2721
- }, [isOpen]);
2722
- React.useEffect(() => {
2723
- if (isOpen) {
2724
- var _internalRef$current;
2725
-
2726
- setSearchHeight((_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.offsetHeight);
2727
- }
2728
- }, [isOpen, setSearchHeight]);
2729
-
2730
- const handleKeyDown = e => {
2731
- const keysToAllow = ['ArrowDown', 'Escape', 'Tab', 'PageUp', 'Home', 'PageDown', 'End'];
2732
-
2733
- if (!_includesInstanceProperty__default["default"](keysToAllow).call(keysToAllow, e.key)) {
2734
- // `Dropdown` component listens for keystrokes to highlight options with matching labels. We want the focus to remain in the search bar.
2735
- e.stopPropagation();
2736
- }
2737
- };
2738
-
2739
- const handleSearch = e => {
2740
- const searchVal = e.currentTarget.value;
2741
- setSearchValue(searchVal);
2742
- };
2743
-
2744
- const handleMouseEnter = () => {
2745
- setHighlightedIndex(myIndex);
2746
- setIsKeyboardUser(false);
2747
- };
2748
-
2749
- const handleMouseLeave = () => {
2750
- setHighlightedIndex(-1);
2751
- };
2752
-
2753
- return isOpen ? /*#__PURE__*/React__default["default"].createElement(FlyoutOption, {
2754
- className: styles$4.search,
2755
- ref: mergeRefs(internalRef, ref),
2756
- tabIndex: -1,
2757
- onMouseEnter: handleMouseEnter,
2758
- onMouseLeave: handleMouseLeave,
2759
- onSelect: handleSelect
2760
- }, /*#__PURE__*/React__default["default"].createElement(Input, {
2761
- className: styles$4.searchInput,
2762
- onKeyDown: handleKeyDown,
2763
- onChange: handleSearch,
2764
- ref: inputRef,
2765
- placeholder: searchText,
2766
- leftAddOn: /*#__PURE__*/React__default["default"].createElement(icons_index.SearchIcon, {
2767
- className: styles$4.searchIcon,
2768
- "aria-hidden": true
2769
- }),
2770
- role: "searchbox",
2771
- "aria-label": searchText,
2772
- value: searchValue,
2773
- "data-testid": getSubDataTestId(dataTestId, 'search')
2774
- })) : /*#__PURE__*/React__default["default"].createElement("div", {
2775
- ref: internalRef
2776
- });
2777
- });
2778
-
2779
- const DropdownList = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2780
- let {
2781
- children,
2782
- placement = 'bottom-start',
2783
- onKeyDown,
2784
- portalTarget,
2785
- private_offset: offset = FLYOUT_POPPER_OFFSET,
2786
- // TODO: Delete or stabilize since no longer used by AdvancedTable
2787
- style = {},
2788
- 'aria-labelledby': externalAriaLabelledBy,
2789
- 'data-testid': dataTestId,
2790
- ...rest
2791
- } = _ref;
2792
- const {
2793
- isOpen,
2794
- buttonRef,
2795
- buttonId,
2796
- minWidth,
2797
- listRef,
2798
- listId,
2799
- onKeyDownList,
2800
- isMultiSelect,
2801
- isSearchable,
2802
- options,
2803
- dataTestId: contextDataTestId
2804
- } = useDropdownContext();
2805
- const {
2806
- translate
2807
- } = useTranslation();
2808
- const noMatchesText = React.useMemo(() => isSearchable && translate('noMatchesFound'), [isSearchable, translate]);
2809
- const ariaLabelledby = externalAriaLabelledBy !== null && externalAriaLabelledBy !== void 0 ? externalAriaLabelledBy : buttonId;
2810
- const announceToScreenReader = useScreenReaderAnnouncement('assertive');
2811
- const showNoResults = React.useMemo(() => options.filter(option => option.isVisible).length === 1, // 1 to include the search box entry
2812
- [options]);
2813
- useDidUpdate(() => {
2814
- if (showNoResults && isSearchable) {
2815
- announceToScreenReader(noMatchesText);
2816
- }
2817
- }, [showNoResults, announceToScreenReader, noMatchesText, isSearchable]);
2818
- return /*#__PURE__*/React__default["default"].createElement(Popper, {
2819
- open: true,
2820
- isDisabled: !isOpen,
2821
- placement: placement,
2822
- anchorNode: buttonRef.current,
2823
- portalTarget: portalTarget,
2824
- modifiers: [{
2825
- name: 'offset',
2826
- options: {
2827
- offset
2828
- }
2829
- }],
2830
- popper: /*#__PURE__*/React__default["default"].createElement(Flyout, _extends__default["default"]({}, rest, {
2831
- ref: mergeRefs(ref, listRef),
2832
- anchorRef: buttonRef,
2833
- id: listId,
2834
- role: "listbox",
2835
- "aria-multiselectable": isMultiSelect || undefined,
2836
- "aria-labelledby": ariaLabelledby,
2837
- hidden: !isOpen,
2838
- onKeyDown: e => {
2839
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
2840
- onKeyDownList(e);
2841
- },
2842
- style: {
2843
- minWidth,
2844
- ...style
2845
- },
2846
- "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : getSubDataTestId(contextDataTestId, 'flyout')
2847
- }), isSearchable && /*#__PURE__*/React__default["default"].createElement(DropdownSearch, null), children, isSearchable && showNoResults && /*#__PURE__*/React__default["default"].createElement("div", {
2848
- className: styles$4.emptyOption // eslint-disable-next-line jsx-a11y/role-has-required-aria-props
2849
- ,
2850
- role: "option" // `aria-selected` is omitted because this option is not selectable
2851
-
2852
- }, noMatchesText))
2853
- });
2854
- });
2855
-
2856
- const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
2857
- var _ref2, _dropdownButton$props, _dropdownButton$props2, _dropdownButton$props3, _dropdownList$props$i, _dropdownList$props;
2858
-
2859
- let {
2860
- className,
2861
- children,
2862
- disabled = false,
2863
- isInvalid = false,
2864
- isOpen: externalIsOpen,
2865
- private_highlightedIndex: externalHighlightedIndex,
2866
- // TODO: Delete or stabilize since no longer used by AdvancedTable
2867
- isMultiSelect = false,
2868
- onIsOpenChange,
2869
- private_onHighlightedIndexChange: onHighlightedIndexChange,
2870
- // TODO: Delete or stabilize since no longer used by AdvancedTable
2871
- defaultValue,
2872
- value: externalValue,
2873
- onChange,
2874
- id,
2875
- 'aria-labelledby': ariaLabelledBy,
2876
- 'aria-label': ariaLabel,
2877
- 'aria-describedby': ariaDescribedby,
2878
- isSearchable,
2879
- searchValue: externalSearchValue,
2880
- onSearchValueChange,
2881
- isSearchFilteringDisabled,
2882
- 'data-testid': dataTestId,
2883
- ...rest
2884
- } = _ref;
2885
- const buttonRef = React.useRef(null);
2886
- const listRef = React.useRef(null);
2887
- let dropdownButton = /*#__PURE__*/React__default["default"].createElement(DropdownButton, null);
2888
- let dropdownList = /*#__PURE__*/React__default["default"].createElement(DropdownList, null);
2889
- const [searchValue, setSearchValue] = useControllableState('', onSearchValueChange, externalSearchValue);
2890
- const [searchHeight, setSearchHeight] = React.useState();
2891
- React__default["default"].Children.forEach(children, child => {
2892
- if ( /*#__PURE__*/React__default["default"].isValidElement(child)) {
2893
- switch (child === null || child === void 0 ? void 0 : child.type) {
2894
- case DropdownButton:
2895
- dropdownButton = child;
2896
- break;
2897
-
2898
- case DropdownList:
2899
- dropdownList = child;
2900
- break;
2901
-
2902
- default:
2903
- break;
2904
- }
2905
- }
2906
- });
2907
- const containerId = useId(id);
2908
- const buttonId = (_ref2 = (_dropdownButton$props = (_dropdownButton$props2 = dropdownButton.props.children) === null || _dropdownButton$props2 === void 0 ? void 0 : (_dropdownButton$props3 = _dropdownButton$props2.props) === null || _dropdownButton$props3 === void 0 ? void 0 : _dropdownButton$props3.id) !== null && _dropdownButton$props !== void 0 ? _dropdownButton$props : dropdownButton.props.id) !== null && _ref2 !== void 0 ? _ref2 : "".concat(containerId, "-button");
2909
- const listId = (_dropdownList$props$i = (_dropdownList$props = dropdownList.props) === null || _dropdownList$props === void 0 ? void 0 : _dropdownList$props.id) !== null && _dropdownList$props$i !== void 0 ? _dropdownList$props$i : "".concat(containerId, "-list");
2910
- const [isOpen, setIsOpen] = useControllableState(false, onIsOpenChange, externalIsOpen);
2911
- const [value, setValue] = useControllableState(defaultValue, onChange, externalValue);
2912
- const [isKeyboardUser, setIsKeyboardUser] = React.useState(false);
2913
- const [selectedIndex, setSelectedIndex] = React.useState(0);
2914
- const [highlightedIndex, setHighlightedIndex] = useControllableState(-1, onHighlightedIndexChange, externalHighlightedIndex);
2915
- const [minWidth, setMinWidth] = React.useState();
2916
- const [options, setOptions] = React.useState([]);
2917
- useDidUpdate(() => {
2918
- if (!isOpen) {
2919
- setSearchValue('');
2920
- }
2921
- }, [isOpen, setSearchValue]);
2922
- const handleClose = React.useCallback(() => {
2923
- setIsOpen(false);
2924
- setHighlightedIndex(-1);
2925
- }, [setIsOpen, setHighlightedIndex]);
2926
-
2927
- const findOptionAndHighlight = char => {
2928
- const lowerCaseChar = char.toLowerCase();
2929
- let index = -1;
2930
- let currentIndex = (highlightedIndex + 1) % options.length; // start at next index
2931
-
2932
- let count = 0;
2933
-
2934
- while (count < options.length) {
2935
- var _option$label;
2936
-
2937
- const option = options[currentIndex];
2938
-
2939
- if ((_option$label = option.label) !== null && _option$label !== void 0 && _option$label.toLowerCase().startsWith(lowerCaseChar)) {
2940
- index = currentIndex;
2941
- break;
2942
- } // increment currentIndex (wrap)
2943
-
2944
-
2945
- currentIndex = (currentIndex + 1) % options.length;
2946
- count += 1;
2947
- }
2948
-
2949
- if (index !== -1) {
2950
- setHighlightedIndex(index);
2951
- }
2952
- };
2953
-
2954
- const selectHighlightedItem = e => {
2955
- var _option$handleSelect;
2956
-
2957
- const option = options[highlightedIndex];
2958
- option === null || option === void 0 ? void 0 : (_option$handleSelect = option.handleSelect) === null || _option$handleSelect === void 0 ? void 0 : _option$handleSelect.call(option, e);
2959
- };
2960
-
2961
- useClickOutside([buttonRef, listRef], handleClose);
2962
- React.useEffect(() => {
2963
- const newSelectedIndex = Math.max(options.findIndex(option => option.isSelected), 0);
2964
- setSelectedIndex(newSelectedIndex);
2965
- }, [options, value]);
2966
- const onOptionSelected = React.useCallback(newValue => {
2967
- if (isMultiSelect) {
2968
- setValue(prevValue => {
2969
- const valueArray = prevValue || prevValue === 0 ? [].concat(prevValue) : [];
2970
- const i = valueArray.findIndex(v => v === newValue);
2971
-
2972
- if (i !== -1) {
2973
- valueArray.splice(i, 1);
2974
- } else {
2975
- valueArray.push(newValue);
2976
- }
2977
-
2978
- return valueArray;
2979
- });
2980
- } else {
2981
- var _buttonRef$current;
2982
-
2983
- setValue(newValue);
2984
- handleClose();
2985
- (_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.focus();
2986
- }
2987
- }, [isMultiSelect, handleClose, setValue]);
2988
-
2989
- const onKeyDownButton = e => {
2990
- setIsKeyboardUser(true);
2991
- let newHighlightedIndex;
2992
- if (disabled) return;
2993
-
2994
- switch (e.key) {
2995
- case 'Enter':
2996
- case ' ':
2997
- // Open and focus selected option
2998
- setIsOpen(true);
2999
- setHighlightedIndex(selectedIndex);
3000
- e.preventDefault(); // prevent scroll
3001
-
3002
- break;
3003
-
3004
- case 'ArrowDown':
3005
- // Open and focus first option. This will either be the search input, or the unfiltered first option.
3006
- setIsOpen(true);
3007
- setHighlightedIndex(0);
3008
- e.preventDefault(); // prevent scroll
3009
-
3010
- break;
3011
-
3012
- case 'ArrowUp':
3013
- // Open and focus last option
3014
- setIsOpen(true);
3015
- newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true);
3016
-
3017
- if (newHighlightedIndex !== -1) {
3018
- setHighlightedIndex(newHighlightedIndex);
3019
- }
3020
-
3021
- e.preventDefault(); // prevent scroll
3022
-
3023
- break;
3024
-
3025
- case 'Escape':
3026
- case 'Tab':
3027
- // close
3028
- handleClose();
3029
- break;
3030
-
3031
- default:
3032
- break;
3033
- }
3034
- };
3035
-
3036
- const onKeyDownList = e => {
3037
- var _buttonRef$current2, _buttonRef$current3;
3038
-
3039
- setIsKeyboardUser(true);
3040
- let newHighlightedIndex;
3041
- if (disabled) return;
3042
-
3043
- switch (e.key) {
3044
- case 'Enter':
3045
- case ' ':
3046
- // select option
3047
- selectHighlightedItem(e);
3048
- e.preventDefault(); // prevent scroll/button click
3049
-
3050
- break;
3051
-
3052
- case 'ArrowDown':
3053
- // highlight next option
3054
- newHighlightedIndex = options.map(element => element.isVisible).indexOf(true, highlightedIndex + 1);
3055
-
3056
- if (newHighlightedIndex !== -1) {
3057
- setHighlightedIndex(newHighlightedIndex);
3058
- }
3059
-
3060
- if (newHighlightedIndex !== highlightedIndex) {
3061
- e.preventDefault(); // prevent scroll
3062
- }
3063
-
3064
- break;
3065
-
3066
- case 'ArrowUp':
3067
- // highlight previous option
3068
- newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true, Math.max(highlightedIndex - 1, 0));
3069
-
3070
- if (newHighlightedIndex !== -1) {
3071
- setHighlightedIndex(newHighlightedIndex);
3072
- } // scrolls first-item headers into view
3073
-
3074
-
3075
- if (newHighlightedIndex === 0 && listRef.current) {
3076
- listRef.current.scrollTop = 0;
3077
- }
3078
-
3079
- if (newHighlightedIndex !== highlightedIndex) {
3080
- e.preventDefault(); // prevent scroll
3081
- }
3082
-
3083
- break;
3084
-
3085
- case 'Escape':
3086
- // close, focus button, and don't let event bubble up
3087
- e.stopPropagation();
3088
- handleClose();
3089
- (_buttonRef$current2 = buttonRef.current) === null || _buttonRef$current2 === void 0 ? void 0 : _buttonRef$current2.focus();
3090
- break;
3091
-
3092
- case 'Tab':
3093
- // close and focus next focusable element
3094
- handleClose();
3095
- (_buttonRef$current3 = buttonRef.current) === null || _buttonRef$current3 === void 0 ? void 0 : _buttonRef$current3.focus();
3096
- break;
3097
-
3098
- case 'PageUp':
3099
- case 'Home':
3100
- // highlight first option. This will either be the search input, or the unfiltered first option.
3101
- setHighlightedIndex(0); // scrolls first-item headers into view
3102
-
3103
- if (listRef.current) {
3104
- listRef.current.scrollTop = 0;
3105
- }
3106
-
3107
- e.preventDefault(); // prevent scroll
3108
-
3109
- break;
3110
-
3111
- case 'PageDown':
3112
- case 'End':
3113
- newHighlightedIndex = options.map(element => element.isVisible).lastIndexOf(true); // highlight last option
3114
-
3115
- if (newHighlightedIndex !== -1) {
3116
- setHighlightedIndex(newHighlightedIndex);
3117
- }
3118
-
3119
- e.preventDefault(); // prevent scroll
3120
-
3121
- break;
3122
-
3123
- default:
3124
- findOptionAndHighlight(e.key);
3125
- break;
3126
- }
3127
- };
3128
-
3129
- return /*#__PURE__*/React__default["default"].createElement(DropdownContextProvider, {
3130
- value: {
3131
- value,
3132
- isOpen,
3133
- buttonRef,
3134
- buttonId,
3135
- options,
3136
- isMultiSelect,
3137
- highlightedIndex,
3138
- selectedIndex,
3139
- minWidth,
3140
- setMinWidth,
3141
- setHighlightedIndex,
3142
- setIsOpen,
3143
- disabled,
3144
- isInvalid,
3145
- onKeyDownButton,
3146
- onKeyDownList,
3147
- onOptionSelected,
3148
- listRef,
3149
- listId,
3150
- ariaLabelledBy,
3151
- ariaLabel,
3152
- ariaDescribedby,
3153
- isKeyboardUser,
3154
- setIsKeyboardUser,
3155
- isSearchable,
3156
- isSearchFilteringDisabled,
3157
- searchValue,
3158
- setSearchValue,
3159
- searchHeight,
3160
- setSearchHeight,
3161
- dataTestId
3162
- }
3163
- }, /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
3164
- id: id,
3165
- ref: ref,
3166
- className: classNames__default["default"](className, styles$4.container),
3167
- "data-testid": dataTestId
3168
- }), dropdownButton, /*#__PURE__*/React__default["default"].createElement(ChildIndexProvider, {
3169
- items: options,
3170
- setItems: setOptions
3171
- }, dropdownList)));
3172
- });
3173
-
3174
- const {
3175
- useContext: useDropdownHeaderContext,
3176
- Provider: DropdownHeaderContextProvider
3177
- } = createContextUtilities({});
3178
-
3179
- const DropdownHeader = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3180
- let {
3181
- title,
3182
- children,
3183
- ...rest
3184
- } = _ref;
3185
- const commonProps = { ...rest,
3186
- ref
3187
- };
3188
- const {
3189
- searchValue
3190
- } = useDropdownContext();
3191
- const [visibleChildIds, setVisibleChildIds] = React.useState(new Set());
3192
- const isVisible = React.useMemo(() => !searchValue || searchValue && visibleChildIds.size > 0, [visibleChildIds, searchValue]);
3193
- return /*#__PURE__*/React__default["default"].createElement(DropdownHeaderContextProvider, {
3194
- value: {
3195
- setVisibleChildIds
3196
- }
3197
- }, isVisible ? /*#__PURE__*/React__default["default"].createElement(FlyoutHeader, _extends__default["default"]({
3198
- title: title
3199
- }, commonProps), children) : /*#__PURE__*/React__default["default"].createElement("div", commonProps, children));
3200
- });
3201
-
3202
- var css_248z$3 = "._3Jb5w{display:inline-flex;position:relative}._3Jb5w,._XLM_M{cursor:pointer;height:16px;width:16px}._XLM_M{position:absolute;opacity:0;z-index:10}._XLM_M._1_bgh~._2-kfW>._dEl1r{fill-opacity:1}._XLM_M._1_bgh~._2-kfW{border-color:transparent;background-color:#0b6ed0}._XLM_M._1_bgh~._2-kfW>._dEl1r{fill:#fff}._XLM_M._1_bgh:hover~._2-kfW{background-color:#085caf}._XLM_M:not(._1_bgh):hover~._2-kfW{border-color:#0b6ed0}._XLM_M._2TrM2{cursor:not-allowed}._XLM_M._2TrM2~._2-kfW{opacity:.4}._2-kfW{display:flex;align-items:center;justify-content:center;position:absolute;top:0;left:0;height:16px;width:16px;background-color:#fff;border-radius:4px;border:1px solid #898989;z-index:0}._dEl1r{fill:#0b6ed0;fill-opacity:0}";
3203
- var styles$3 = {"checkbox":"_3Jb5w","input":"_XLM_M","checked":"_1_bgh","check":"_2-kfW","checkIcon":"_dEl1r","disabled":"_2TrM2"};
3204
- var stylesheet$3="._3Jb5w{display:inline-flex;position:relative}._3Jb5w,._XLM_M{cursor:pointer;height:16px;width:16px}._XLM_M{position:absolute;opacity:0;z-index:10}._XLM_M._1_bgh~._2-kfW>._dEl1r{fill-opacity:1}._XLM_M._1_bgh~._2-kfW{border-color:transparent;background-color:#0b6ed0}._XLM_M._1_bgh~._2-kfW>._dEl1r{fill:#fff}._XLM_M._1_bgh:hover~._2-kfW{background-color:#085caf}._XLM_M:not(._1_bgh):hover~._2-kfW{border-color:#0b6ed0}._XLM_M._2TrM2{cursor:not-allowed}._XLM_M._2TrM2~._2-kfW{opacity:.4}._2-kfW{display:flex;align-items:center;justify-content:center;position:absolute;top:0;left:0;height:16px;width:16px;background-color:#fff;border-radius:4px;border:1px solid #898989;z-index:0}._dEl1r{fill:#0b6ed0;fill-opacity:0}";
3205
- icons_index.styleInject(css_248z$3);
3206
-
3207
- // input elements cannot be inside an option role for accessibility reasons,
3208
- // so this component reflects our Checkbox styles for DropdownOption and
3209
- // MenuItem without using an actual input.
3210
-
3211
- const VisualCheckbox = _ref => {
3212
- let {
3213
- className,
3214
- checked,
3215
- disabled
3216
- } = _ref;
3217
- return /*#__PURE__*/React__default["default"].createElement("span", {
3218
- className: classNames__default["default"](className, styles$3.checkbox),
3219
- "aria-hidden": true
3220
- }, /*#__PURE__*/React__default["default"].createElement("div", {
3221
- className: classNames__default["default"](styles$3.input, {
3222
- [styles$3.checked]: checked,
3223
- [styles$3.disabled]: disabled
3224
- })
3225
- }), /*#__PURE__*/React__default["default"].createElement("span", {
3226
- className: styles$3.check
3227
- }, /*#__PURE__*/React__default["default"].createElement(Check, {
3228
- className: styles$3.checkIcon
3229
- })));
3230
- };
3231
-
3232
- const DropdownOption = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3233
- let {
3234
- children,
3235
- value,
3236
- label,
3237
- onSelect,
3238
- onMouseDown,
3239
- onMouseEnter,
3240
- onMouseLeave,
3241
- disabled,
3242
- className,
3243
- ...rest
3244
- } = _ref;
3245
- const internalRef = React.useRef(null);
3246
- const {
3247
- isOpen,
3248
- isMultiSelect,
3249
- highlightedIndex,
3250
- value: selectedValue,
3251
- onOptionSelected,
3252
- setHighlightedIndex,
3253
- listRef,
3254
- isKeyboardUser,
3255
- setIsKeyboardUser,
3256
- searchValue,
3257
- isSearchFilteringDisabled,
3258
- isSearchable,
3259
- searchHeight
3260
- } = useDropdownContext();
3261
- const {
3262
- setVisibleChildIds
3263
- } = useDropdownHeaderContext();
3264
- const isVisible = React.useMemo(() => {
3265
- var _context;
3266
-
3267
- return isSearchFilteringDisabled || !label || !searchValue || typeof label === 'string' && _includesInstanceProperty__default["default"](_context = label.toLowerCase()).call(_context, searchValue.toLowerCase());
3268
- }, [isSearchFilteringDisabled, label, searchValue]);
3269
- React.useEffect(() => {
3270
- setVisibleChildIds === null || setVisibleChildIds === void 0 ? void 0 : setVisibleChildIds(visibleChildIds => {
3271
- const duplicateSet = new Set(visibleChildIds);
3272
-
3273
- if (isVisible) {
3274
- return duplicateSet.add(value);
3275
- }
3276
-
3277
- duplicateSet.delete(value);
3278
- return duplicateSet;
3279
- });
3280
- }, [setVisibleChildIds, isVisible, value]);
3281
- const isSelected = Array.isArray(selectedValue) ? _includesInstanceProperty__default["default"](selectedValue).call(selectedValue, value) : value === selectedValue;
3282
- const handleSelect = React.useCallback(e => {
3283
- if (!disabled) {
3284
- const handler = wrapEvent(onSelect, () => onOptionSelected(value));
3285
- handler(e);
3286
- }
3287
- }, [value, disabled, onSelect, onOptionSelected]);
3288
- const myIndex = useChildIndex({
3289
- element: internalRef.current,
3290
- value,
3291
- label,
3292
- isSelected,
3293
- handleSelect,
3294
- isVisible
3295
- });
3296
- const isHighlighted = highlightedIndex === myIndex && myIndex !== -1;
3297
- React.useEffect(() => {
3298
- if (isHighlighted) {
3299
- var _listRef$current, _listRef$current2, _internalRef$current;
3300
-
3301
- if (isKeyboardUser && isOpen && internalRef !== null && internalRef !== void 0 && internalRef.current && listRef !== null && listRef !== void 0 && listRef.current && ((_listRef$current = listRef.current) === null || _listRef$current === void 0 ? void 0 : _listRef$current.scrollHeight) > ((_listRef$current2 = listRef.current) === null || _listRef$current2 === void 0 ? void 0 : _listRef$current2.clientHeight)) {
3302
- const scrollBottom = listRef.current.clientHeight + listRef.current.scrollTop;
3303
- const elementBottom = internalRef.current.offsetTop + internalRef.current.offsetHeight;
3304
-
3305
- if (elementBottom > scrollBottom) {
3306
- listRef.current.scrollTop = elementBottom - listRef.current.clientHeight;
3307
- } else if (internalRef.current.offsetTop < listRef.current.scrollTop + (isSearchable ? searchHeight : 0)) {
3308
- listRef.current.scrollTop = internalRef.current.offsetTop - (isSearchable ? searchHeight : 0);
3309
- }
3310
- }
3311
-
3312
- (_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.focus({
3313
- preventScroll: true
3314
- });
3315
- }
3316
- }, [isHighlighted, isKeyboardUser, isOpen, listRef, isSearchable, searchHeight]);
3317
- return isOpen && isVisible ? /*#__PURE__*/React__default["default"].createElement(FlyoutOption, _extends__default["default"]({}, rest, {
3318
- className: classNames__default["default"](className, styles$4.option),
3319
- ref: mergeRefs(internalRef, ref),
3320
- onClick: handleSelect,
3321
- tabIndex: -1,
3322
- isHighlighted: isHighlighted,
3323
- isSelected: isSelected,
3324
- "aria-disabled": disabled,
3325
- onMouseDown: wrapEvent(onMouseDown, e => e.preventDefault()),
3326
- onMouseEnter: wrapEvent(onMouseEnter, () => {
3327
- setIsKeyboardUser(false);
3328
- setHighlightedIndex(myIndex);
3329
- }),
3330
- onMouseLeave: wrapEvent(onMouseLeave, () => setHighlightedIndex(-1))
3331
- }), children || /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, isMultiSelect && /*#__PURE__*/React__default["default"].createElement(VisualCheckbox, {
3332
- className: classNames__default["default"](styles$4.checkbox, {
3333
- [styles$4.highlighted]: isHighlighted && !isSelected
3334
- }),
3335
- checked: isSelected,
3336
- disabled: disabled
3337
- }), label)) : /*#__PURE__*/React__default["default"].createElement("div", {
3338
- ref: internalRef
3339
- });
3340
- });
3341
-
3342
- var css_248z$2 = "._3dYCE._3dYCE{min-width:0;max-width:100%;padding:0 4px 0 12px;white-space:nowrap;line-height:20px;font-size:14px;cursor:pointer;justify-content:space-between;text-align:left;outline:none;background-color:#fafafa;border:none;box-shadow:inset 0 0 0 1px #898989;border-radius:4px;height:36px;color:#515559;fill:#515559}._3dYCE._3dYCE,._3dYCE._3dYCE ._20J5Q{display:inline-flex;align-items:center}._3dYCE._3dYCE ._20J5Q{overflow:hidden;text-overflow:ellipsis}._3dYCE._3dYCE._3qlG8{min-height:26px;height:26px}._3dYCE._3dYCE._hIF-b{color:#32363a}._3dYCE._3dYCE:hover:not([aria-disabled=true]){background-color:#f5f5f5}._3dYCE._3dYCE:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._3dYCE._3dYCE[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._3dYCE._3dYCE[aria-disabled=true]>svg{fill:#515559;opacity:.4}._3dYCE._3dYCE[aria-disabled=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._3dYCE._3dYCE._3Wv33{padding-left:0}._3dYCE._3dYCE._1-XB5{margin-top:4px}._3dYCE._3dYCE ._32AdW{fill:#515559}._3dYCE._3dYCE ._32AdW._3qlG8{top:0}._3dYCE._3dYCE ._32AdW._1z4_W{transform:rotate(-180deg)}._2txLW{overflow-x:hidden;overflow-y:auto;overflow:hidden auto;position:relative}._2ZUkd{margin:0;padding:4px 0;font-size:14px;color:#32363a;fill:#32363a;list-style:none;min-width:160px;max-width:350px;min-height:10px;max-height:99%;background:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000}._2ZUkd::-webkit-scrollbar,._2ZUkd::-webkit-scrollbar-thumb{visibility:hidden;width:8px;border-radius:4px}._2ZUkd::-webkit-scrollbar{background-color:rgba(0,0,0,.06)}._2ZUkd::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.4)}._2ZUkd:hover::-webkit-scrollbar,._2ZUkd:hover::-webkit-scrollbar-thumb,._2ZUkd[focus-within]::-webkit-scrollbar,._2ZUkd[focus-within]::-webkit-scrollbar-thumb{visibility:visible}._2ZUkd:focus-within::-webkit-scrollbar,._2ZUkd:focus-within::-webkit-scrollbar-thumb,._2ZUkd:hover::-webkit-scrollbar,._2ZUkd:hover::-webkit-scrollbar-thumb{visibility:visible}._2yaAP{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word}._2yaAP[aria-disabled=true]{cursor:not-allowed;color:rgba(50,54,58,.65);fill:rgba(50,54,58,.65)}._2yaAP._3tpcR{background-color:#efefef}._2yaAP._3M1Pl{box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._2yaAP._hIF-b{background-color:#ebf3fb;font-weight:500;font-family:\"72Duplex\",\"72\",\"Helvetica Neue\",Helvetica,Arial,sans-serif}._2yaAP._hIF-b._3tpcR{background-color:#e4effa}._2yaAP._8m8Iz{cursor:default}._2yaAP:active:not(._1M9DF):not(._hIF-b):not([aria-disabled=true]):not(._8m8Iz){background-color:#e8e9e9}._1M9DF{padding-right:32px}._1M9DF ._32AdW{position:absolute;top:8px;right:3px;fill:#515559}._3uMn7{padding:8px;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;margin-top:-4px}._13GZY{position:absolute;top:13px;left:13px}._337AF._337AF{padding-left:32px}._2KQaR{margin:2px 12px 2px 0;flex-shrink:0}._2KQaR._2cXoJ>svg{border-color:#0b6ed0}._3wO-L{display:flex;justify-self:center;margin:8px}";
3343
- var styles$2 = {"menuBtn":"_3dYCE","menuBtnLabel":"_20J5Q","small":"_3qlG8","selected":"_hIF-b","unlabelledButton":"_3Wv33","formLabelled":"_1-XB5","rightIcon":"_32AdW","open":"_1z4_W","menuItemContainer":"_2txLW","contentPane":"_2ZUkd","menuItem":"_2yaAP","active":"_3tpcR","focus":"_3M1Pl","noMenuItems":"_8m8Iz","subMenu":"_1M9DF","searchBox":"_3uMn7","searchBoxIcon":"_13GZY","searchBoxInput":"_337AF","checkbox":"_2KQaR","highlighted":"_2cXoJ","menuSpinner":"_3wO-L"};
3344
- var stylesheet$2="._3dYCE._3dYCE{min-width:0;max-width:100%;padding:0 4px 0 12px;white-space:nowrap;line-height:20px;font-size:14px;cursor:pointer;justify-content:space-between;text-align:left;outline:none;background-color:#fafafa;border:none;box-shadow:inset 0 0 0 1px #898989;border-radius:4px;height:36px;color:#515559;fill:#515559}._3dYCE._3dYCE,._3dYCE._3dYCE ._20J5Q{display:inline-flex;align-items:center}._3dYCE._3dYCE ._20J5Q{overflow:hidden;text-overflow:ellipsis}._3dYCE._3dYCE._3qlG8{min-height:26px;height:26px}._3dYCE._3dYCE._hIF-b{color:#32363a}._3dYCE._3dYCE:hover:not([aria-disabled=true]){background-color:#f5f5f5}._3dYCE._3dYCE:focus{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._3dYCE._3dYCE[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._3dYCE._3dYCE[aria-disabled=true]>svg{fill:#515559;opacity:.4}._3dYCE._3dYCE[aria-disabled=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._3dYCE._3dYCE._3Wv33{padding-left:0}._3dYCE._3dYCE._1-XB5{margin-top:4px}._3dYCE._3dYCE ._32AdW{fill:#515559}._3dYCE._3dYCE ._32AdW._3qlG8{top:0}._3dYCE._3dYCE ._32AdW._1z4_W{transform:rotate(-180deg)}._2txLW{overflow-x:hidden;overflow-y:auto;overflow:hidden auto;position:relative}._2ZUkd{margin:0;padding:4px 0;font-size:14px;color:#32363a;fill:#32363a;list-style:none;min-width:160px;max-width:350px;min-height:10px;max-height:99%;background:#fff;border:1px solid #eee;border-radius:4px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);z-index:1000}._2ZUkd::-webkit-scrollbar,._2ZUkd::-webkit-scrollbar-thumb{visibility:hidden;width:8px;border-radius:4px}._2ZUkd::-webkit-scrollbar{background-color:rgba(0,0,0,.06)}._2ZUkd::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.4)}._2ZUkd:hover::-webkit-scrollbar,._2ZUkd:hover::-webkit-scrollbar-thumb,._2ZUkd[focus-within]::-webkit-scrollbar,._2ZUkd[focus-within]::-webkit-scrollbar-thumb{visibility:visible}._2ZUkd:focus-within::-webkit-scrollbar,._2ZUkd:focus-within::-webkit-scrollbar-thumb,._2ZUkd:hover::-webkit-scrollbar,._2ZUkd:hover::-webkit-scrollbar-thumb{visibility:visible}._2yaAP{position:relative;padding:10px 12px;min-height:40px;display:flex;flex-direction:row;align-items:center;cursor:pointer;outline:none;word-break:break-word}._2yaAP[aria-disabled=true]{cursor:not-allowed;color:rgba(50,54,58,.65);fill:rgba(50,54,58,.65)}._2yaAP._3tpcR{background-color:#efefef}._2yaAP._3M1Pl{box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._2yaAP._hIF-b{background-color:#ebf3fb;font-weight:500;font-family:\"72Duplex\",\"72\",\"Helvetica Neue\",Helvetica,Arial,sans-serif}._2yaAP._hIF-b._3tpcR{background-color:#e4effa}._2yaAP._8m8Iz{cursor:default}._2yaAP:active:not(._1M9DF):not(._hIF-b):not([aria-disabled=true]):not(._8m8Iz){background-color:#e8e9e9}._1M9DF{padding-right:32px}._1M9DF ._32AdW{position:absolute;top:8px;right:3px;fill:#515559}._3uMn7{padding:8px;border-bottom:1px solid #e8e8e8;border-radius:4px 4px 0 0;margin-top:-4px}._13GZY{position:absolute;top:13px;left:13px}._337AF._337AF{padding-left:32px}._2KQaR{margin:2px 12px 2px 0;flex-shrink:0}._2KQaR._2cXoJ>svg{border-color:#0b6ed0}._3wO-L{display:flex;justify-self:center;margin:8px}";
3345
- icons_index.styleInject(css_248z$2);
3346
-
3347
- const MenuItem = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3348
- let {
3349
- role,
3350
- tabIndex = -1,
3351
- children: label,
3352
- className,
3353
- disabled,
3354
- onSelect,
3355
- onKeyDown,
3356
- onClick,
3357
- isSelected = false,
3358
- isHighlighted = false,
3359
- isFocused = isHighlighted,
3360
- isMultiSelect = false,
3361
- isSelectable = false,
3362
- ...rest
3363
- } = _ref;
3364
- const defaultRole = isSelectable ? isMultiSelect ? 'menuitemcheckbox' : 'menuitemradio' : 'menuitem';
3365
-
3366
- const handleSelect = e => {
3367
- if (typeof onSelect === 'function' && !disabled) {
3368
- onSelect(e);
3369
- }
3370
- };
3371
-
3372
- return (
3373
- /*#__PURE__*/
3374
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
3375
- React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
3376
- ref: ref,
3377
- role: role !== null && role !== void 0 ? role : defaultRole,
3378
- tabIndex: tabIndex,
3379
- "aria-disabled": disabled,
3380
- "aria-checked": isSelectable ? isSelected : undefined,
3381
- className: classNames__default["default"](className, styles$2.menuItem, {
3382
- [styles$2.active]: isHighlighted,
3383
- [styles$2.focus]: isFocused,
3384
- [styles$2.selected]: isSelected
3385
- }),
3386
- onKeyDown: wrapEvent(onKeyDown, e => {
3387
- if (e.key === ' ' || e.key === 'Enter') {
3388
- handleSelect(e);
3389
- e.preventDefault(); // prevent scroll
3390
- }
3391
- }),
3392
- onClick: wrapEvent(onClick, handleSelect)
3393
- }), isMultiSelect && /*#__PURE__*/React__default["default"].createElement(VisualCheckbox, {
3394
- className: classNames__default["default"](styles$2.checkbox, {
3395
- [styles$2.highlighted]: isHighlighted && !isSelected
3396
- }),
3397
- checked: isSelected,
3398
- disabled: disabled
3399
- }), label)
3400
- );
3401
- });
3402
-
3403
- const MenuAnchor = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3404
- let {
3405
- label,
3406
- className,
3407
- small,
3408
- isOpen,
3409
- disabled,
3410
- onClick,
3411
- onKeyDown,
3412
- 'aria-describedby': externalAriaDescribedBy,
3413
- ...rest
3414
- } = _ref;
3415
- const inputGroupContext = useInputGroupContext();
3416
- const {
3417
- hasLabel: hasFormLabel,
3418
- helperTextId: formFieldHelperTextId,
3419
- errorTextId: formFieldErrorTextId
3420
- } = useFormFieldControl();
3421
- const internalAriaDescribedby = concatIds(externalAriaDescribedBy, formFieldHelperTextId, formFieldErrorTextId);
3422
- return /*#__PURE__*/React__default["default"].createElement("button", _extends__default["default"]({}, rest, {
3423
- ref: ref,
3424
- type: "button",
3425
- className: classNames__default["default"](className, styles$2.menuBtn, inputGroupContext.className, {
3426
- [styles$2.unlabelledButton]: !label && label !== 0,
3427
- [styles$2.small]: inputGroupContext.applySmall(small),
3428
- [styles$2.formLabelled]: hasFormLabel
3429
- }),
3430
- "aria-haspopup": "menu",
3431
- "aria-disabled": disabled,
3432
- "aria-describedby": internalAriaDescribedby,
3433
- onClick: disabled ? undefined : onClick,
3434
- onKeyDown: disabled ? undefined : onKeyDown
3435
- }), /*#__PURE__*/React__default["default"].createElement("span", {
3436
- className: styles$2.menuBtnLabel
3437
- }, label), /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronDownIcon, {
3438
- className: classNames__default["default"](styles$2.rightIcon, {
3439
- [styles$2.small]: inputGroupContext.applySmall(small),
3440
- [styles$2.open]: isOpen
3441
- }),
3442
- "aria-hidden": "true"
3443
- }));
3444
- });
3445
-
3446
- const {
3447
- Provider: MenuContextProvider,
3448
- useContext: useMenuContext
3449
- } = createContextUtilities(null);
3450
-
3451
- const MenuSearchBox = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3452
- let { ...rest
3453
- } = _ref;
3454
- const {
3455
- translate
3456
- } = useTranslation();
3457
- const searchText = translate('searchText');
3458
- return /*#__PURE__*/React__default["default"].createElement("div", {
3459
- className: styles$2.searchBox
3460
- }, /*#__PURE__*/React__default["default"].createElement(icons_index.SearchIcon, {
3461
- className: styles$2.searchBoxIcon,
3462
- "aria-hidden": "true"
3463
- }), /*#__PURE__*/React__default["default"].createElement(Input$1, _extends__default["default"]({
3464
- ref: ref,
3465
- role: "searchbox",
3466
- "aria-label": searchText,
3467
- placeholder: searchText,
3468
- className: styles$2.searchBoxInput,
3469
- full: true
3470
- }, rest)));
3471
- });
3472
-
3473
- const MenuSpinner = /*#__PURE__*/React__default["default"].forwardRef((_, ref) => /*#__PURE__*/React__default["default"].createElement(LoadingSpinner, {
3474
- ref: ref,
3475
- className: styles$2.menuSpinner,
3476
- show: true,
3477
- size: "small"
3478
- }));
3479
-
3480
- const SubmenuAnchor = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3481
- let {
3482
- label,
3483
- className,
3484
- ...rest
3485
- } = _ref;
3486
- return /*#__PURE__*/React__default["default"].createElement(MenuItem, _extends__default["default"]({
3487
- "aria-haspopup": "menu",
3488
- className: classNames__default["default"](className, styles$2.subMenu),
3489
- ref: ref
3490
- }, rest), label, /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronRightIcon, {
3491
- className: styles$2.rightIcon,
3492
- "aria-hidden": "true"
3493
- }));
3494
- });
3495
-
3496
- function useChildrenRefs(children, getAdditionalProps, isNavItem, searchable) {
3497
- const refs = React.useRef({}); // eslint-disable-next-line no-return-assign
3498
-
3499
- const createRefCallback = index => node => refs.current[index] = node;
3500
-
3501
- let refIndex = searchable ? 1 : 0;
3502
- const allChildren = React__default["default"].Children.map(children, child => {
3503
- if (isNavItem(child)) {
3504
- const myIndex = refIndex;
3505
- refIndex += 1;
3506
- const additionalProps = getAdditionalProps(child, myIndex);
3507
- return /*#__PURE__*/React__default["default"].cloneElement(child, {
3508
- ref: mergeRefs(createRefCallback(myIndex), child.ref),
3509
- ...additionalProps
3510
- });
3511
- }
3512
-
3513
- return child;
3514
- });
3515
- refs.current.length = refIndex;
3516
- return [refs, allChildren];
3517
- }
3518
-
3519
- const ArrowNav = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3520
- let {
3521
- role,
3522
- tabIndex = -1,
3523
- highlightedIndex,
3524
- onHighlightedIndexChange,
3525
- children,
3526
- searchBoxRef,
3527
- anchorRef,
3528
- isSubmenu,
3529
- onKeyDown,
3530
- isNavItem = () => true,
3531
- maxHeight,
3532
- minWidth,
3533
- searchable,
3534
- menuItemContainerClass,
3535
- searchTerm,
3536
- setSearchTerm,
3537
- 'data-popper-ready': isPopperReady,
3538
- // comes from Popper.js where ArrowNav is cloned
3539
- style,
3540
- 'aria-labelledby': ariaLabelledBy,
3541
- ...rest
3542
- } = _ref;
3543
- const [isKeyboardUser, setIsKeyboardUser] = React.useState(false);
3544
- const containerRef = React.useRef(null);
3545
- const menuItemContainerRef = React.useRef(null);
3546
- const menuId = useId();
3547
- const [refs, allChildren] = useChildrenRefs(children, (child, index) => ({
3548
- tabIndex: -1,
3549
- onMouseEnter: wrapEvent(child.props.onMouseEnter, () => {
3550
- setIsKeyboardUser(false);
3551
- onHighlightedIndexChange(index);
3552
- })
3553
- }), isNavItem, searchable);
3554
- const isKeyboardUserRef = useLatest(isKeyboardUser); // Update the focused menu item when the highlighted index changes
3555
-
3556
- React.useEffect(() => {
3557
- if (isPopperReady) {
3558
- if (refs.current[highlightedIndex]) {
3559
- // Scroll the item into view when navigating with a keyboard
3560
- const element = refs.current[highlightedIndex];
3561
-
3562
- if (isKeyboardUserRef.current && menuItemContainerRef.current) {
3563
- const scrollBottom = menuItemContainerRef.current.clientHeight + menuItemContainerRef.current.scrollTop;
3564
- const elementBottom = element.offsetTop + element.offsetHeight;
3565
-
3566
- if (elementBottom > scrollBottom) {
3567
- menuItemContainerRef.current.scrollTop = elementBottom - menuItemContainerRef.current.clientHeight;
3568
- } else if (element.offsetTop < menuItemContainerRef.current.scrollTop) {
3569
- menuItemContainerRef.current.scrollTop = element.offsetTop;
3570
- }
3571
- }
3572
- /* preventScroll isn't strictly needed.
3573
- * For keyboard users it makes no difference since the item is already in view when .focus() is called.
3574
- * For mouse users, it prevents scrolling from occurring when hovering over a menu item that is partially out of view.
3575
- */
3576
-
3577
-
3578
- element.focus({
3579
- preventScroll: true
3580
- });
3581
- } else if (highlightedIndex === 0 && searchable) {
3582
- searchBoxRef === null || searchBoxRef === void 0 ? void 0 : searchBoxRef.current.focus();
3583
- } else {
3584
- var _anchorRef$current;
3585
-
3586
- anchorRef === null || anchorRef === void 0 ? void 0 : (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.focus();
3587
- }
3588
- }
3589
- }, [highlightedIndex, refs, searchable, allChildren.length, // Needed to prevent QuickSearch from losing focus in some cases when items are loaded asynchronously while the user is navigating
3590
- isPopperReady, isKeyboardUserRef, searchBoxRef, anchorRef]);
3591
- const numChildren = refs.current.length;
3592
-
3593
- const handleKeyDown = e => {
3594
- setIsKeyboardUser(true);
3595
-
3596
- if (e.key === 'ArrowDown') {
3597
- e.preventDefault(); // prevent scroll
3598
-
3599
- if (highlightedIndex !== -1) {
3600
- onHighlightedIndexChange((highlightedIndex + 1) % numChildren);
3601
- }
3602
- } else if (e.key === 'ArrowUp') {
3603
- e.preventDefault(); // prevent scroll
3604
-
3605
- if (highlightedIndex !== -1) {
3606
- onHighlightedIndexChange((highlightedIndex - 1 + numChildren) % numChildren);
3607
- }
3608
- } else if (e.key === 'PageUp' || e.key === 'Home') {
3609
- var _containerRef$current;
3610
-
3611
- // Only call the highlighted index change handler for the current nav list (i.e. if the event bubbles up to a parent nav list, don't call the highlighted index change handler on the parent nav list)
3612
- if ((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 && _containerRef$current.contains(e.target)) {
3613
- e.preventDefault();
3614
- onHighlightedIndexChange(0);
3615
- }
3616
- } else if (e.key === 'PageDown' || e.key === 'End') {
3617
- var _containerRef$current2;
3618
-
3619
- // Only call the highlighted index change handler for the current nav list (i.e. if the event bubbles up to a parent nav list, don't call the highlighted index change handler on the parent nav list)
3620
- if ((_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 && _containerRef$current2.contains(e.target)) {
3621
- e.preventDefault();
3622
- const lastIndex = numChildren - 1;
3623
- onHighlightedIndexChange(lastIndex);
3624
- }
3625
- }
3626
- };
3627
-
3628
- return (
3629
- /*#__PURE__*/
3630
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
3631
- React__default["default"].createElement("div", _extends__default["default"]({
3632
- ref: mergeRefs(containerRef, ref),
3633
- tabIndex: tabIndex,
3634
- onKeyDown: wrapEvent(onKeyDown, handleKeyDown),
3635
- "data-popper-ready": isPopperReady,
3636
- style: { ...style,
3637
- minWidth
3638
- }
3639
- }, rest), searchable && /*#__PURE__*/React__default["default"].createElement(MenuSearchBox, {
3640
- "aria-controls": menuId,
3641
- value: searchTerm,
3642
- ref: searchBoxRef,
3643
- onChange: e => {
3644
- setSearchTerm === null || setSearchTerm === void 0 ? void 0 : setSearchTerm(e.target.value);
3645
- },
3646
- onFocus: () => onHighlightedIndexChange(0)
3647
- }), /*#__PURE__*/React__default["default"].createElement("div", {
3648
- id: menuId,
3649
- role: role,
3650
- "aria-labelledby": ariaLabelledBy,
3651
- style: {
3652
- maxHeight: maxHeight !== null && maxHeight !== void 0 ? maxHeight : // This logic is located here instead of BaseMenu.js so the maxHeight will update with screen resizing (Popper has a resize listener that causes this to rerender)
3653
- Math.min(350, (isSubmenu ? // Submenus: window height - submenu popper offset - 8px of container padding - half of anchor height (fallback to default 18px))
3654
- document.documentElement.clientHeight - SUBMENU_POPPER_OFFSET[0] : // Menus: half of window height - menu popper offset - 8px of container padding - half of anchor height (fallback to default 18px)
3655
- document.documentElement.clientHeight / 2 - FLYOUT_POPPER_OFFSET[1]) - 8 - (anchorRef !== null && anchorRef !== void 0 && anchorRef.current ? anchorRef.current.offsetHeight / 2 : 18))
3656
- },
3657
- className: menuItemContainerClass,
3658
- ref: menuItemContainerRef
3659
- }, allChildren))
3660
- );
3661
- });
3662
-
3663
- const BaseMenu = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
3664
- var _externalAnchor$props, _externalAnchor$props2, _useMenuContext, _externalAnchor$props3, _externalAnchor$props4, _externalAnchor$props5, _externalAnchor$props6, _externalAnchor$props7, _externalAnchor$props8, _externalAnchor$props9, _anchorRef$current;
3665
-
3666
- let {
3667
- anchor: externalAnchor,
3668
- 'aria-label': externalAriaLabel,
3669
- 'aria-labelledby': externalAriaLabelledBy,
3670
- children,
3671
- className,
3672
- flyoutClassName,
3673
- defaultLabel,
3674
- defaultValue = null,
3675
- disabled,
3676
- highlightedIndex: externalHighlightedIndex,
3677
- id: externalId,
3678
- label,
3679
- maxHeight,
3680
- menuType,
3681
- onClick,
3682
- onClickAway,
3683
- onHighlightedIndexChange,
3684
- onKeyDown,
3685
- onIsOpenChange,
3686
- onSelectedValueChange,
3687
- isOpen: externalIsOpen,
3688
- placement = 'bottom-start',
3689
- portalTarget,
3690
- searchable = false,
3691
- isSearchFilteringDisabled = false,
3692
- searchValue: externalSearchValue,
3693
- onSearchValueChange: externalOnSearchValueChange,
3694
- selectable = false,
3695
- selectedValue: externalSelectedValue,
3696
- unstable_isLoading = false,
3697
- unstable_isMultiSelect = false,
3698
- // isMultiSelect prop added 8/28/20
3699
- isMultiSelect = unstable_isMultiSelect,
3700
- zIndex = 1000,
3701
- maxFlyoutWidth,
3702
- private_isClosedMenuOpenedOnAnchorClick = true,
3703
- private_isFirstElementHighlightedOnUserActivatedOpen = true,
3704
- ...rest
3705
- } = _ref;
3706
- const anchorId = useId((_externalAnchor$props = externalAnchor === null || externalAnchor === void 0 ? void 0 : (_externalAnchor$props2 = externalAnchor.props) === null || _externalAnchor$props2 === void 0 ? void 0 : _externalAnchor$props2.id) !== null && _externalAnchor$props !== void 0 ? _externalAnchor$props : externalId);
3707
- const arrowNavId = "".concat(anchorId, "-menu");
3708
- const parentCloseAndFocusAnchor = (_useMenuContext = useMenuContext()) === null || _useMenuContext === void 0 ? void 0 : _useMenuContext.closeAndFocusAnchor;
3709
- const isSubmenu = Boolean(parentCloseAndFocusAnchor);
3710
- const {
3711
- translate
3712
- } = useTranslation();
3713
- const noMenuItemsToDisplayText = translate('menu.noItemsToDisplay');
3714
- const anchorRef = React.useRef(null);
3715
- const [isOpen, setIsOpen] = useControllableState(false, onIsOpenChange, externalIsOpen);
3716
- const [highlightedIndex, setHighlightedIndex] = useControllableState(-1, onHighlightedIndexChange, externalHighlightedIndex);
3717
- const [selectedValue, setSelectedValue] = useControllableState(defaultValue, onSelectedValueChange, externalSelectedValue);
3718
- const [searchTerm, setSearchTerm] = useControllableState('', externalOnSearchValueChange, externalSearchValue);
3719
- const [submenuHighlightedIndex, setSubmenuHighlightedIndex] = React.useState(-1); // These effects are needed for onIsOpenChange to work for submenus since the isOpen state is always controlled by the parent menu
3720
-
3721
- const onIsOpenChangeRef = useLatest(onIsOpenChange);
3722
- const externalIsOpenRef = useLatest(externalIsOpen); // Call onIsOpenChange whenever externalIsOpen changes
3723
-
3724
- useDidUpdate(() => {
3725
- if (isSubmenu) {
3726
- var _onIsOpenChangeRef$cu;
3727
-
3728
- (_onIsOpenChangeRef$cu = onIsOpenChangeRef.current) === null || _onIsOpenChangeRef$cu === void 0 ? void 0 : _onIsOpenChangeRef$cu.call(onIsOpenChangeRef, externalIsOpen);
3729
- }
3730
- }, [externalIsOpen, onIsOpenChangeRef, isSubmenu]); // Call onIsOpenChange if open on mount or on unmount
3731
-
3732
- React.useEffect(() => {
3733
- if (isSubmenu) {
3734
- if (externalIsOpenRef.current) {
3735
- var _onIsOpenChangeRef$cu2;
3736
-
3737
- (_onIsOpenChangeRef$cu2 = onIsOpenChangeRef.current) === null || _onIsOpenChangeRef$cu2 === void 0 ? void 0 : _onIsOpenChangeRef$cu2.call(onIsOpenChangeRef, true);
3738
- }
3739
-
3740
- return () => {
3741
- // eslint-disable-next-line react-hooks/exhaustive-deps
3742
- if (externalIsOpenRef.current) {
3743
- var _onIsOpenChangeRef$cu3;
3744
-
3745
- // eslint-disable-next-line react-hooks/exhaustive-deps
3746
- (_onIsOpenChangeRef$cu3 = onIsOpenChangeRef.current) === null || _onIsOpenChangeRef$cu3 === void 0 ? void 0 : _onIsOpenChangeRef$cu3.call(onIsOpenChangeRef, false);
3747
- }
3748
- };
3749
- } // eslint-disable-next-line react-hooks/exhaustive-deps
3750
-
3751
- }, []);
3752
- const closeMenu = React.useCallback(() => {
3753
- setIsOpen(false);
3754
- setHighlightedIndex(-1);
3755
- setSubmenuHighlightedIndex(-1);
3756
- setSearchTerm('');
3757
- }, [setHighlightedIndex, setIsOpen, setSearchTerm]);
3758
-
3759
- const handleMultiSelectChange = item => {
3760
- let arr = selectedValue || selectedValue === 0 ? [].concat(selectedValue) : [];
3761
- const i = arr.findIndex(v => {
3762
- var _item$props;
3763
-
3764
- return v === (item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.value);
3765
- });
3766
-
3767
- if (i !== -1) {
3768
- arr.splice(i, 1);
3769
- } else {
3770
- var _item$props2;
3771
-
3772
- arr = union(arr, item === null || item === void 0 ? void 0 : (_item$props2 = item.props) === null || _item$props2 === void 0 ? void 0 : _item$props2.value);
3773
- }
3774
-
3775
- setSelectedValue(arr, getLabelFromValue(children, arr), item);
3776
- };
3777
-
3778
- const handleSubmenuOnSelectedValueChange = (value, label, item) => {
3779
- if (!selectable) return;
3780
-
3781
- if (isMultiSelect) {
3782
- handleMultiSelectChange(item);
3783
- return;
3784
- }
3785
-
3786
- setSelectedValue(value, getLabelFromValue(children, value), item);
3787
- };
3788
-
3789
- const handleItemSelected = item => {
3790
- var _item$props3;
3791
-
3792
- if (!selectable) {
3793
- closeAndFocusAnchor();
3794
- return;
3795
- }
3796
-
3797
- const value = item === null || item === void 0 ? void 0 : (_item$props3 = item.props) === null || _item$props3 === void 0 ? void 0 : _item$props3.value;
3798
-
3799
- if (!value && value !== 0) {
3800
- // eslint-disable-next-line no-console
3801
- console.warn('<MenuItem> should have a "value" prop when used in a <SelectMenu>', item);
3802
- }
3803
-
3804
- if (isMultiSelect) {
3805
- handleMultiSelectChange(item);
3806
- return;
3807
- }
3808
-
3809
- setSelectedValue(value, getLabelFromValue(children, value), item);
3810
- closeAndFocusAnchor();
3811
- };
3812
-
3813
- const handleClickAway = React.useCallback(wrapEvent(onClickAway, closeMenu), []);
3814
- const preventClickOutside = useClickOutsidePortals(handleClickAway, {
3815
- disabled: isSubmenu
3816
- });
3817
-
3818
- const handleAnchorClick = () => {
3819
- if (isOpen) {
3820
- setIsOpen(false);
3821
- } else if (private_isClosedMenuOpenedOnAnchorClick) {
3822
- setIsOpen(true);
3823
- setHighlightedIndex(private_isFirstElementHighlightedOnUserActivatedOpen ? 0 : -1);
3824
- }
3825
- };
3826
-
3827
- const handleAnchorKeyDown = e => {
3828
- if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
3829
- e.preventDefault(); // prevent scroll
3830
-
3831
- setIsOpen(true);
3832
- setHighlightedIndex(private_isFirstElementHighlightedOnUserActivatedOpen ? 0 : -1);
3833
- } else if (e.key === 'ArrowUp') {
3834
- e.preventDefault(); // prevent scroll
3835
-
3836
- const lastIndex = React__default["default"].Children.count(children) - (searchable ? 0 : 1);
3837
- setIsOpen(true);
3838
- setHighlightedIndex(lastIndex);
3839
- } else if (e.key === 'Tab') {
3840
- closeMenu();
3841
- }
3842
- };
3843
-
3844
- let menuItemIndex = searchable ? 1 : 0;
3845
-
3846
- const generateMenuItems = () => React__default["default"].Children.map(filterItems(isSearchFilteringDisabled ? null : searchTerm, React__default["default"].Children.toArray(children)), child => {
3847
- const actualIndex = menuItemIndex;
3848
-
3849
- if (isType(child, menuType)) {
3850
- menuItemIndex += 1;
3851
- return /*#__PURE__*/React__default["default"].cloneElement(child, {
3852
- isOpen: actualIndex === highlightedIndex,
3853
- isHighlighted: actualIndex === highlightedIndex,
3854
- isFocused: actualIndex === highlightedIndex && submenuHighlightedIndex === -1,
3855
- placement: 'right-start',
3856
- onKeyDown: e => {
3857
- if (e.key === 'ArrowRight' || e.key === 'Enter' || e.key === ' ') {
3858
- setSubmenuHighlightedIndex(0);
3859
- e.preventDefault(); // prevent scroll
3860
- }
3861
- },
3862
- onClick: () => {
3863
- setSubmenuHighlightedIndex(0);
3864
- },
3865
- highlightedIndex: submenuHighlightedIndex,
3866
- isMultiSelect,
3867
- defaultValue,
3868
- selectedValue,
3869
- onHighlightedIndexChange: setSubmenuHighlightedIndex,
3870
- onSelectedValueChange: handleSubmenuOnSelectedValueChange
3871
- });
3872
- }
3873
-
3874
- if ((child === null || child === void 0 ? void 0 : child.type) === MenuItem) {
3875
- var _context, _child$props, _child$props2;
3876
-
3877
- menuItemIndex += 1;
3878
- return /*#__PURE__*/React__default["default"].cloneElement(child, {
3879
- isHighlighted: actualIndex === highlightedIndex,
3880
- isSelected: selectable && typeof selectedValue !== 'undefined' && Array.isArray(selectedValue) ? _includesInstanceProperty__default["default"](_context = selectedValue).call(_context, child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.value) : (child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.value) === selectedValue,
3881
- onSelect: wrapEvent(child.props.onSelect, () => {
3882
- handleItemSelected(child);
3883
- }),
3884
- isMultiSelect,
3885
- isSelectable: selectable
3886
- });
3887
- }
3888
-
3889
- return child;
3890
- });
3891
-
3892
- const anchorLabel = label !== null && label !== void 0 ? label : getLabelFromValue(children, selectedValue);
3893
- const menuAnchorLabel = anchorLabel !== null && anchorLabel !== void 0 ? anchorLabel : defaultLabel;
3894
- const announceToScreenReader = useScreenReaderAnnouncement('assertive');
3895
- const ariaLabelledBy = (_externalAnchor$props3 = externalAnchor === null || externalAnchor === void 0 ? void 0 : (_externalAnchor$props4 = externalAnchor.props) === null || _externalAnchor$props4 === void 0 ? void 0 : _externalAnchor$props4['aria-labelledby']) !== null && _externalAnchor$props3 !== void 0 ? _externalAnchor$props3 : externalAriaLabelledBy ? "".concat(externalAriaLabelledBy, " ").concat(anchorId) : undefined;
3896
- const ariaLabel = (_externalAnchor$props5 = externalAnchor === null || externalAnchor === void 0 ? void 0 : (_externalAnchor$props6 = externalAnchor.props) === null || _externalAnchor$props6 === void 0 ? void 0 : _externalAnchor$props6['aria-label']) !== null && _externalAnchor$props5 !== void 0 ? _externalAnchor$props5 : externalAriaLabel && typeof menuAnchorLabel === 'string' ? "".concat(externalAriaLabel, " ").concat(menuAnchorLabel) : externalAriaLabel;
3897
- const ariaExpanded = (externalAnchor === null || externalAnchor === void 0 ? void 0 : externalAnchor.props['aria-expanded']) !== undefined ? externalAnchor.props['aria-expanded'] : isOpen ? true : undefined;
3898
- const actualAnchor = externalAnchor !== undefined ? /*#__PURE__*/React__default["default"].cloneElement(externalAnchor, {
3899
- ref: mergeRefs(ref, anchorRef, externalAnchor.ref),
3900
- tabIndex: (_externalAnchor$props7 = externalAnchor.props.tabIndex) !== null && _externalAnchor$props7 !== void 0 ? _externalAnchor$props7 : 0,
3901
- role: (_externalAnchor$props8 = externalAnchor.props.role) !== null && _externalAnchor$props8 !== void 0 ? _externalAnchor$props8 : 'button',
3902
- id: anchorId,
3903
- 'aria-controls': isOpen ? arrowNavId : undefined,
3904
- 'aria-expanded': ariaExpanded,
3905
- 'aria-haspopup': 'menu',
3906
- 'aria-disabled': (_externalAnchor$props9 = externalAnchor.props['aria-disabled']) !== null && _externalAnchor$props9 !== void 0 ? _externalAnchor$props9 : disabled,
3907
- 'aria-labelledby': ariaLabelledBy,
3908
- 'aria-label': ariaLabel,
3909
- onMouseDown: preventClickOutside,
3910
- onClick: wrapEvent(externalAnchor.props.onClick, handleAnchorClick),
3911
- onKeyDown: wrapEvent(externalAnchor.props.onKeyDown, handleAnchorKeyDown)
3912
- }) : isSubmenu ? /*#__PURE__*/React__default["default"].createElement(SubmenuAnchor, _extends__default["default"]({
3913
- ref: mergeRefs(ref, anchorRef),
3914
- label: label,
3915
- id: anchorId,
3916
- "aria-controls": isOpen ? arrowNavId : undefined,
3917
- "aria-expanded": isOpen ? true : undefined,
3918
- onClick: onClick,
3919
- onKeyDown: onKeyDown,
3920
- disabled: disabled,
3921
- className: className
3922
- }, rest)) : /*#__PURE__*/React__default["default"].createElement(MenuAnchor, _extends__default["default"]({}, rest, {
3923
- id: anchorId,
3924
- "aria-controls": isOpen ? arrowNavId : undefined,
3925
- "aria-expanded": isOpen ? true : undefined,
3926
- "aria-labelledby": ariaLabelledBy,
3927
- "aria-label": ariaLabel,
3928
- ref: mergeRefs(ref, anchorRef),
3929
- disabled: disabled,
3930
- label: menuAnchorLabel,
3931
- onMouseDown: preventClickOutside,
3932
- onClick: wrapEvent(onClick, handleAnchorClick),
3933
- onKeyDown: wrapEvent(onKeyDown, handleAnchorKeyDown),
3934
- isOpen: isOpen,
3935
- className: classNames__default["default"](className, {
3936
- [styles$2.selected]: anchorLabel
3937
- })
3938
- }));
3939
- const closeAndFocusAnchor = React.useCallback(() => {
3940
- closeMenu();
3941
- anchorRef.current && anchorRef.current.focus();
3942
- parentCloseAndFocusAnchor && parentCloseAndFocusAnchor();
3943
- }, [closeMenu, parentCloseAndFocusAnchor]);
3944
- const menuItems = unstable_isLoading ? [/*#__PURE__*/React__default["default"].createElement(MenuSpinner, {
3945
- key: "menu-loading"
3946
- })] : generateMenuItems();
3947
- let noResults = false;
3948
- const listItems = menuItems || [];
3949
- const popperIsOpen = !disabled && isOpen;
3950
-
3951
- if (!listItems.length) {
3952
- noResults = true;
3953
- listItems.push( /*#__PURE__*/React__default["default"].createElement("div", {
3954
- key: "no-list-items",
3955
- className: classNames__default["default"](styles$2.menuItem, styles$2.noMenuItems)
3956
- }, noMenuItemsToDisplayText));
3957
- }
3958
-
3959
- useDidUpdate(() => {
3960
- if (popperIsOpen && noResults) {
3961
- announceToScreenReader(noMenuItemsToDisplayText);
3962
- }
3963
- }, [noResults, popperIsOpen, announceToScreenReader, noMenuItemsToDisplayText]);
3964
- const searchBoxRef = React.useRef();
3965
- const arrowNavRef = React.useRef(null);
3966
- return /*#__PURE__*/React__default["default"].createElement(MenuContextProvider, {
3967
- value: {
3968
- closeAndFocusAnchor,
3969
- setIsOpen,
3970
- isOpen,
3971
- anchorRef,
3972
- setHighlightedIndex
3973
- }
3974
- }, /*#__PURE__*/React__default["default"].createElement(Popper, {
3975
- open: !disabled && isOpen,
3976
- placement: placement,
3977
- portalTarget: portalTarget,
3978
- anchor: actualAnchor,
3979
- modifiers: [{
3980
- name: 'offset',
3981
- options: {
3982
- offset: isSubmenu ? SUBMENU_POPPER_OFFSET : FLYOUT_POPPER_OFFSET
3983
- }
3984
- }],
3985
- popper: /*#__PURE__*/React__default["default"].createElement(ArrowNav, {
3986
- id: arrowNavId,
3987
- role: "menu",
3988
- "aria-labelledby": anchorId,
3989
- isNavItem: child => (child === null || child === void 0 ? void 0 : child.type) === MenuItem || (child === null || child === void 0 ? void 0 : child.type) === MenuSearchBox || isType(child, menuType),
3990
- style: {
3991
- zIndex,
3992
- maxWidth: maxFlyoutWidth !== null && maxFlyoutWidth !== void 0 ? maxFlyoutWidth : undefined,
3993
- width: maxFlyoutWidth !== null && maxFlyoutWidth !== void 0 ? maxFlyoutWidth : undefined
3994
- },
3995
- menuItemContainerClass: styles$2.menuItemContainer,
3996
- onMouseDown: preventClickOutside,
3997
- className: classNames__default["default"](styles$2.contentPane, flyoutClassName),
3998
- highlightedIndex: highlightedIndex,
3999
- maxHeight: maxHeight,
4000
- minWidth: isSubmenu ? undefined : Math.min(350, Math.max(160, anchorRef === null || anchorRef === void 0 ? void 0 : (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 ? void 0 : _anchorRef$current.offsetWidth)),
4001
- searchable: searchable,
4002
- onHighlightedIndexChange: i => setHighlightedIndex(i),
4003
- searchTerm: searchTerm,
4004
- setSearchTerm: setSearchTerm,
4005
- onKeyDown: e => {
4006
- if (e.key === 'Escape') {
4007
- e.stopPropagation(); // Prevent Escape key event from bubbling up
4008
-
4009
- if (isSubmenu) {
4010
- // Only update the highlighted index for the current menu
4011
- setHighlightedIndex(-1);
4012
- } else {
4013
- closeAndFocusAnchor();
4014
- }
4015
- } else if (e.key === 'Tab') {
4016
- // For Tab, focus should be moved relative to anchor
4017
- // (not menu container) so we focus anchor before browser moves focus
4018
- closeAndFocusAnchor();
4019
- } else if (e.key === 'ArrowLeft' && isSubmenu) {
4020
- var _arrowNavRef$current;
4021
-
4022
- // Only update the highlighted index for the current menu (i.e. if the event bubbles up to a parent menu, don't update the highlighted index for the parent menu)
4023
- if ((_arrowNavRef$current = arrowNavRef.current) !== null && _arrowNavRef$current !== void 0 && _arrowNavRef$current.contains(e.target) && e.target !== searchBoxRef.current) {
4024
- setHighlightedIndex(-1);
4025
- }
4026
- }
4027
- },
4028
- isSubmenu: isSubmenu,
4029
- searchBoxRef: searchBoxRef,
4030
- anchorRef: anchorRef,
4031
- ref: arrowNavRef
4032
- }, listItems)
4033
- }));
4034
- });
4035
-
4036
- function filterItems(valueToFilterBy, items) {
4037
- if (!valueToFilterBy) {
4038
- return items;
4039
- }
4040
-
4041
- const result = items.filter(item => {
4042
- const searchTermLowerCase = valueToFilterBy.toLowerCase();
4043
-
4044
- if (typeof item.props.label === 'string') {
4045
- var _context2;
4046
-
4047
- return _includesInstanceProperty__default["default"](_context2 = item.props.label.toLowerCase()).call(_context2, searchTermLowerCase);
4048
- }
4049
-
4050
- if (typeof item.props.children === 'string') {
4051
- var _context3;
4052
-
4053
- return _includesInstanceProperty__default["default"](_context3 = item.props.children.toLowerCase()).call(_context3, searchTermLowerCase);
4054
- } // eslint-disable-next-line no-console
4055
-
4056
-
4057
- console.warn("<MenuItem> not included in search results!\n Ensure prop \"children\" is of type \"string\" or provide a \"label\" prop!", item);
4058
- return false;
4059
- });
4060
- return result;
4061
- }
4062
-
4063
- function getLabelFromValue(children, value) {
4064
- if (!value && value !== 0) return undefined;
4065
-
4066
- if (Array.isArray(value)) {
4067
- if (value.length === 0) return undefined;
4068
- return [].concat(value).map(v => getLabel(getDescendent(children, v))).filter(label => label || label === 0).join(', ');
4069
- }
4070
-
4071
- return getLabel(getDescendent(children, value));
4072
- } // Mega-hack to make nested defaultValue prop work
4073
-
4074
-
4075
- function getDescendent(children, value) {
4076
- if (value === undefined) return null;
4077
- const childArray = React__default["default"].Children.toArray(children);
4078
-
4079
- for (let i = 0; i < childArray.length; i += 1) {
4080
- var _child$props3, _child$props4;
4081
-
4082
- const child = childArray[i];
4083
-
4084
- if ((child === null || child === void 0 ? void 0 : child.type) === MenuItem && (child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.value) === value) {
4085
- return child;
4086
- }
4087
-
4088
- if ((child === null || child === void 0 ? void 0 : child.type) !== MenuItem && child !== null && child !== void 0 && (_child$props4 = child.props) !== null && _child$props4 !== void 0 && _child$props4.children) {
4089
- const descendent = getDescendent(child.props.children, value);
4090
-
4091
- if (descendent) {
4092
- return descendent;
4093
- }
4094
- }
4095
- }
4096
-
4097
- return null;
4098
- }
4099
-
4100
- function getLabel(menuOptionNode) {
4101
- var _menuOptionNode$props;
4102
-
4103
- if ( /*#__PURE__*/React.isValidElement(menuOptionNode)) return getLabel(menuOptionNode === null || menuOptionNode === void 0 ? void 0 : (_menuOptionNode$props = menuOptionNode.props) === null || _menuOptionNode$props === void 0 ? void 0 : _menuOptionNode$props.children);
4104
- return menuOptionNode;
4105
- }
4106
-
4107
- function union(arr1, arr2) {
4108
- return [].concat(arr1).concat(arr2).reduce((result, current) => {
4109
- if (!_includesInstanceProperty__default["default"](result).call(result, current)) {
4110
- result.push(current);
4111
- }
4112
-
4113
- return result;
4114
- }, []);
4115
- }
4116
-
4117
- function isType(element, type) {
4118
- return element && element.type && element.type.render === type;
4119
- }
4120
-
4121
- const Menu = /*#__PURE__*/React__default["default"].forwardRef(function Menu(_ref, ref) {
4122
- let {
4123
- selectable,
4124
- defaultLabel,
4125
- defaultValue,
4126
- selectedValue: externalSelectedValue,
4127
- onSelectedValueChange,
4128
- unstable_isMultiSelect,
4129
- // Throw away since it's only part of SelectMenu
4130
- isMultiSelect,
4131
- // Throw away since it's only part of SelectMenu
4132
- ...rest
4133
- } = _ref;
4134
- return /*#__PURE__*/React__default["default"].createElement(BaseMenu, _extends__default["default"]({
4135
- ref: ref,
4136
- menuType: Menu
4137
- }, rest));
4138
- });
4139
-
4140
- const SelectMenu = /*#__PURE__*/React__default["default"].forwardRef(function SelectMenu(_ref, ref) {
4141
- let {
4142
- selectable,
4143
- // eslint-disable-line @typescript-eslint/no-unused-vars
4144
- onSelectedValueChange,
4145
- onChange,
4146
- ...rest
4147
- } = _ref;
4148
- return /*#__PURE__*/React__default["default"].createElement(BaseMenu, _extends__default["default"]({
4149
- ref: ref,
4150
- menuType: SelectMenu,
4151
- selectable: true,
4152
- onSelectedValueChange: function (value) {
4153
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4154
- args[_key - 1] = arguments[_key];
4155
- }
4156
-
4157
- onSelectedValueChange === null || onSelectedValueChange === void 0 ? void 0 : onSelectedValueChange(value, ...args);
4158
- onChange === null || onChange === void 0 ? void 0 : onChange(value);
4159
- }
4160
- }, rest));
4161
- });
4162
-
4163
- var css_248z$1 = "._kQh1Y{display:flex;align-items:center;justify-content:center;font-size:14px;white-space:pre}._yZkDq{margin-right:8px}._RUpRQ{margin-left:8px}._2_FEL{margin:-10px -15px}._2OdeK{width:100%;text-align:center}";
4164
- var styles$1 = {"pagination":"_kQh1Y","previousButton":"_yZkDq","nextButton":"_RUpRQ","btnIcon":"_2_FEL","input":"_2OdeK"};
4165
- var stylesheet$1="._kQh1Y{display:flex;align-items:center;justify-content:center;font-size:14px;white-space:pre}._yZkDq{margin-right:8px}._RUpRQ{margin-left:8px}._2_FEL{margin:-10px -15px}._2OdeK{width:100%;text-align:center}";
4166
- icons_index.styleInject(css_248z$1);
4167
-
4168
- const {
4169
- Provider: PaginationContextProvider,
4170
- useContext: usePaginationContext
4171
- } = createContextUtilities({});
4172
-
4173
- /**
4174
- * Renders the PaginationPrevioudButton.
4175
- * Either `Pagination` renders this component automatically or the consumer renders this component explicitly.
4176
- */
4177
- const PaginationPreviousButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
4178
- let {
4179
- 'data-testid': dataTestIdFromProps,
4180
- disabled,
4181
- onClick,
4182
- className,
4183
- ...rest
4184
- } = _ref;
4185
- const {
4186
- translate
4187
- } = useTranslation();
4188
- const buttonLabel = translate('previousPage'); // Context for Pagination
4189
-
4190
- const {
4191
- pageInputValue,
4192
- dataTestId,
4193
- handlePageChange,
4194
- setPageInputValue
4195
- } = usePaginationContext();
4196
- /**
4197
- * Decrements the `pageInputValue`.
4198
- * Calls `handlePageChange` in order to call the `onPageChange` prop.
4199
- */
4200
-
4201
- const decrement = () => {
4202
- const newPage = pageInputValue - 1;
4203
- setPageInputValue === null || setPageInputValue === void 0 ? void 0 : setPageInputValue(newPage);
4204
- handlePageChange === null || handlePageChange === void 0 ? void 0 : handlePageChange(newPage);
4205
- };
4206
-
4207
- return /*#__PURE__*/React__default["default"].createElement(Button, _extends__default["default"]({}, rest, {
4208
- disabled: disabled !== null && disabled !== void 0 ? disabled : pageInputValue === 1,
4209
- ref: ref,
4210
- kind: "tertiary",
4211
- onClick: e => {
4212
- onClick === null || onClick === void 0 ? void 0 : onClick(e);
4213
- decrement();
4214
- },
4215
- className: classNames__default["default"](className, styles$1.previousButton),
4216
- "data-testid": dataTestIdFromProps !== null && dataTestIdFromProps !== void 0 ? dataTestIdFromProps : getSubDataTestId(dataTestId, 'PreviousButton'),
4217
- "aria-label": buttonLabel
4218
- }), /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronLeftIcon, {
4219
- className: styles$1.btnIcon,
4220
- size: "large",
4221
- "aria-hidden": "true"
4222
- }));
4223
- });
4224
-
4225
- /**
4226
- * Renders the PaginationNextButton.
4227
- * Either `Pagination` renders this component automatically or the consumer renders this component explicitly.
4228
- */
4229
- const PaginationNextButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
4230
- let {
4231
- 'data-testid': dataTestIdFromProps,
4232
- disabled,
4233
- onClick,
4234
- className,
4235
- ...rest
4236
- } = _ref;
4237
- const {
4238
- translate
4239
- } = useTranslation();
4240
- const buttonLabel = translate('nextPage'); // Context for Pagination
4241
-
4242
- const {
4243
- numPages,
4244
- pageInputValue,
4245
- dataTestId,
4246
- handlePageChange,
4247
- setPageInputValue
4248
- } = usePaginationContext();
4249
- /**
4250
- * Increments the `pageInputValue`.
4251
- * Calls `handlePageChange` in order to call the `onPageChange` prop.
4252
- */
4253
-
4254
- const increment = () => {
4255
- const newPage = pageInputValue + 1;
4256
- setPageInputValue === null || setPageInputValue === void 0 ? void 0 : setPageInputValue(newPage);
4257
- handlePageChange === null || handlePageChange === void 0 ? void 0 : handlePageChange(newPage);
4258
- };
4259
-
4260
- return /*#__PURE__*/React__default["default"].createElement(Button, _extends__default["default"]({}, rest, {
4261
- disabled: disabled !== null && disabled !== void 0 ? disabled : pageInputValue === numPages,
4262
- ref: ref,
4263
- kind: "tertiary",
4264
- onClick: e => {
4265
- onClick === null || onClick === void 0 ? void 0 : onClick(e);
4266
- increment();
4267
- },
4268
- className: classNames__default["default"](className, styles$1.nextButton),
4269
- "data-testid": dataTestIdFromProps !== null && dataTestIdFromProps !== void 0 ? dataTestIdFromProps : getSubDataTestId(dataTestId, 'NextButton'),
4270
- "aria-label": buttonLabel
4271
- }), /*#__PURE__*/React__default["default"].createElement(icons_index.ChevronRightIcon, {
4272
- className: styles$1.btnIcon,
4273
- size: "large",
4274
- "aria-hidden": "true"
4275
- }));
4276
- });
4277
-
4278
- /**
4279
- * Renders the PaginationPageInput.
4280
- * Either `Pagination` renders this component automatically or the consumer renders this component explicitly.
4281
- */
4282
- const PaginationPageInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
4283
- let {
4284
- 'data-testid': dataTestIdFromProps,
4285
- 'aria-label': ariaLabelFromProps,
4286
- 'aria-labelledby': ariaLabelledByFromProps,
4287
- 'aria-describedby': ariaDescribedByFromProps,
4288
- onChange,
4289
- onBlur,
4290
- onFocus,
4291
- className,
4292
- style,
4293
- ...rest
4294
- } = _ref;
4295
- // Element reference to the input
4296
- const inputRef = React.useRef(null); // Context for Pagination
4297
-
4298
- const {
4299
- numPages,
4300
- pageInputValue,
4301
- currentPage,
4302
- dataTestId,
4303
- ariaLabel,
4304
- ariaLabelledBy,
4305
- ariaDescribedBy,
4306
- handlePageChange,
4307
- setPageInputValue
4308
- } = usePaginationContext();
4309
- /**
4310
- * Computes the width of the input based on the number of characters entered
4311
- */
4312
-
4313
- const inputWidth = React.useMemo(() => {
4314
- var _currentPage$toString;
4315
-
4316
- const numDigits = (_currentPage$toString = currentPage === null || currentPage === void 0 ? void 0 : currentPage.toString().length) !== null && _currentPage$toString !== void 0 ? _currentPage$toString : 0;
4317
- const minWidth = 36;
4318
- return numDigits > 2 ? 9 * (numDigits - 2) + minWidth : minWidth;
4319
- }, [currentPage]);
4320
- /**
4321
- * Sets the `pageInputValue` to `currentPage` if there is a discrepancy
4322
- */
4323
-
4324
- const handleBlur = () => {
4325
- if (pageInputValue !== currentPage && currentPage !== undefined) {
4326
- setPageInputValue === null || setPageInputValue === void 0 ? void 0 : setPageInputValue(currentPage);
4327
- }
4328
- };
4329
- /**
4330
- * Updates the `pageInputValue`.
4331
- * Calls `handlePageChange` in order to call the `onPageChange` prop (only if the input is an integer).
4332
- * @param {String | Number} newValue - The value entered into the input
4333
- */
4334
-
4335
-
4336
- const handleInputChange = newValue => {
4337
- if (newValue === '' || !Number.isInteger(Number(newValue))) {
4338
- setPageInputValue === null || setPageInputValue === void 0 ? void 0 : setPageInputValue(newValue);
4339
- } else {
4340
- const newPage = Math.min(Math.max(1, newValue), numPages || Number.MAX_SAFE_INTEGER);
4341
- setPageInputValue === null || setPageInputValue === void 0 ? void 0 : setPageInputValue(newPage);
4342
- handlePageChange === null || handlePageChange === void 0 ? void 0 : handlePageChange(newPage);
4343
- }
4344
- };
4345
- /**
4346
- * If there is a ref to the input, selects all text within the input
4347
- */
4348
-
4349
-
4350
- const handleFocus = () => {
4351
- var _inputRef$current;
4352
-
4353
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.select();
4354
- };
4355
-
4356
- return /*#__PURE__*/React__default["default"].createElement(Translate, {
4357
- messageKey: "pagination",
4358
- placeholders: {
4359
- currentPage: /*#__PURE__*/React__default["default"].createElement(Input$1, _extends__default["default"]({}, rest, {
4360
- "data-testid": dataTestIdFromProps || getSubDataTestId(dataTestId, 'PageInput'),
4361
- ref: mergeRefs(ref, inputRef),
4362
- key: "currentPage",
4363
- "aria-label": ariaLabelFromProps || ariaLabel,
4364
- "aria-labelledby": ariaLabelledByFromProps || ariaLabelledBy,
4365
- "aria-describedby": ariaDescribedByFromProps || ariaDescribedBy,
4366
- small: true,
4367
- type: "number",
4368
- min: 1,
4369
- max: numPages,
4370
- value: pageInputValue,
4371
- onChange: e => {
4372
- onChange === null || onChange === void 0 ? void 0 : onChange(e);
4373
- handleInputChange(e.target.value);
4374
- },
4375
- onBlur: e => {
4376
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e);
4377
- handleBlur();
4378
- },
4379
- onFocus: e => {
4380
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(e);
4381
- handleFocus();
4382
- },
4383
- style: { ...style,
4384
- width: inputWidth
4385
- },
4386
- className: classNames__default["default"](className, styles$1.input)
4387
- })),
4388
- numPages
4389
- }
4390
- });
4391
- });
4392
-
4393
- /**
4394
- * Renders the Pagination component.
4395
- * This component is offered as a "default" (aka simple) component or an "advanced" (aka composite) component.
4396
- */
4397
- const Pagination = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) => {
4398
- let {
4399
- 'data-testid': dataTestId,
4400
- numPages,
4401
- currentPage = 1,
4402
- onPageChange,
4403
- className,
4404
- children,
4405
- 'aria-label': ariaLabel,
4406
- 'aria-labelledby': ariaLabelledBy,
4407
- 'aria-describedby': ariaDescribedBy,
4408
- ...rest
4409
- } = _ref;
4410
- const {
4411
- translate
4412
- } = useTranslation(); // The current page (the consumer holds a current page that might be different)
4413
-
4414
- const [pageInputValue, setPageInputValue] = React.useState(currentPage);
4415
- const announceToScreenReader = useScreenReaderAnnouncement('assertive'); // Announces the new page info to the screen reader when the page info changes, but not when the component first mounts
4416
-
4417
- useDidUpdate(() => {
4418
- if (numPages) {
4419
- announceToScreenReader(translate('pagination', {
4420
- currentPage,
4421
- numPages: Number(numPages)
4422
- }));
4423
- }
4424
- }, [announceToScreenReader, translate, currentPage, numPages]); // Updates the `pageInputValue` to be `currentPage` when the `currentPage` prop changes
4425
-
4426
- React.useEffect(() => {
4427
- setPageInputValue(currentPage);
4428
- }, [currentPage]);
4429
- /**
4430
- * Calls `onPageChange` if the function was passed in as a prop
4431
- * @param {Number} newPage - The value entered into the input
4432
- */
4433
-
4434
- const handlePageChange = React.useCallback(newPage => {
4435
- onPageChange === null || onPageChange === void 0 ? void 0 : onPageChange({
4436
- page: newPage
4437
- });
4438
- }, [onPageChange]); // Context for the composite components
4439
-
4440
- const context = React.useMemo(() => ({
4441
- numPages,
4442
- pageInputValue,
4443
- currentPage,
4444
- dataTestId,
4445
- ariaLabel,
4446
- ariaLabelledBy,
4447
- ariaDescribedBy,
4448
- handlePageChange,
4449
- setPageInputValue
4450
- }), [numPages, pageInputValue, currentPage, dataTestId, ariaLabel, ariaLabelledBy, ariaDescribedBy, handlePageChange, setPageInputValue]);
4451
- return /*#__PURE__*/React__default["default"].createElement("div", _extends__default["default"]({}, rest, {
4452
- "data-testid": dataTestId,
4453
- ref: ref,
4454
- className: classNames__default["default"](className, styles$1.pagination)
4455
- }), /*#__PURE__*/React__default["default"].createElement(PaginationContextProvider, {
4456
- value: context
4457
- }, children || /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(PaginationPreviousButton, null), Number(numPages) > 0 ? /*#__PURE__*/React__default["default"].createElement(PaginationPageInput, null) : null, /*#__PURE__*/React__default["default"].createElement(PaginationNextButton, null))));
4458
- });
4459
-
4460
- var css_248z = "._10m02{display:inline-block;position:relative}._2yUpm._2yUpm{padding-left:36px;padding-right:36px;width:100%}._2yUpm._2yUpm:disabled+._1NmhS{fill-opacity:.6}._1NmhS{position:absolute;top:50%;left:0;transform:translateY(-50%);margin-left:6px;fill:#515559;pointer-events:none}._1NmhS._3kOrk{z-index:20}._Jum5h{position:absolute;top:0;right:0;width:36px;height:100%;background-color:transparent;line-height:0;border:none;border-radius:4px}._Jum5h:hover{cursor:pointer}._Jum5h:hover>._2SkTJ{fill:#32363a}._Jum5h:focus{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._2SkTJ{fill:#515559}";
4461
- var styles = {"searchInput":"_10m02","searchInputInput":"_2yUpm","searchInputSearchIcon":"_1NmhS","usedWithinInputGroup":"_3kOrk","searchInputClearButton":"_Jum5h","searchInputClearButtonIcon":"_2SkTJ"};
4462
- var stylesheet="._10m02{display:inline-block;position:relative}._2yUpm._2yUpm{padding-left:36px;padding-right:36px;width:100%}._2yUpm._2yUpm:disabled+._1NmhS{fill-opacity:.6}._1NmhS{position:absolute;top:50%;left:0;transform:translateY(-50%);margin-left:6px;fill:#515559;pointer-events:none}._1NmhS._3kOrk{z-index:20}._Jum5h{position:absolute;top:0;right:0;width:36px;height:100%;background-color:transparent;line-height:0;border:none;border-radius:4px}._Jum5h:hover{cursor:pointer}._Jum5h:hover>._2SkTJ{fill:#32363a}._Jum5h:focus{outline:none;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._2SkTJ{fill:#515559}";
4463
- icons_index.styleInject(css_248z);
4464
-
4465
- const SearchInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
4466
- let {
4467
- defaultValue = '',
4468
- value,
4469
- onChange,
4470
- onKeyDown,
4471
- placeholder,
4472
- 'aria-label': ariaLabel,
4473
- 'aria-labelledby': ariaLabelledby,
4474
- 'aria-describedby': ariaDescribedby,
4475
- isDisabled = false,
4476
- onFocus,
4477
- onBlur,
4478
- className,
4479
- style,
4480
- id,
4481
- 'data-testid': dataTestId
4482
- } = _ref;
4483
- const [inputValue, setInputValue] = useControllableState(defaultValue, onChange, value);
4484
- const [wasInputValueCleared, setWasInputValueCleared] = React.useState(false);
4485
- const inputRef = React.useRef(null);
4486
- const {
4487
- translate
4488
- } = useTranslation();
4489
- const clearButtonLabel = translate('clearSearchInput');
4490
- const isClearButtonHidden = !inputValue || isDisabled;
4491
- const usedWithinInputGroup = !!useInputGroupContext().className; // Focuses the input after the input value is cleared so that screen readers see that the input doesn't have a value
4492
-
4493
- React.useEffect(() => {
4494
- if (wasInputValueCleared) {
4495
- var _inputRef$current;
4496
-
4497
- (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
4498
- setWasInputValueCleared(false);
4499
- }
4500
- }, [wasInputValueCleared]);
4501
-
4502
- const clearInputText = () => {
4503
- setInputValue('');
4504
- setWasInputValueCleared(true);
4505
- };
4506
-
4507
- const handleInputChange = e => {
4508
- setInputValue(e.target.value);
4509
- };
4510
-
4511
- const handleInputKeyDown = e => {
4512
- if (e.key === 'Escape') {
4513
- if (inputValue) {
4514
- e.stopPropagation(); // prevent event from closing modals or popovers
4515
- }
4516
-
4517
- clearInputText();
4518
- }
4519
-
4520
- onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
4521
- };
4522
-
4523
- return /*#__PURE__*/React__default["default"].createElement("span", {
4524
- className: classNames__default["default"](styles.searchInput, className),
4525
- style: style
4526
- }, /*#__PURE__*/React__default["default"].createElement(Input$1, {
4527
- role: "searchbox",
4528
- id: id,
4529
- className: styles.searchInputInput,
4530
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : translate('searchText'),
4531
- value: inputValue,
4532
- onChange: handleInputChange,
4533
- onKeyDown: handleInputKeyDown,
4534
- disabled: isDisabled,
4535
- onFocus: onFocus,
4536
- onBlur: onBlur,
4537
- "aria-label": ariaLabel,
4538
- "aria-labelledby": ariaLabelledby,
4539
- "aria-describedby": ariaDescribedby,
4540
- "data-testid": dataTestId,
4541
- ref: mergeRefs(inputRef, ref)
4542
- }), /*#__PURE__*/React__default["default"].createElement(icons_index.SearchIcon, {
4543
- className: classNames__default["default"](styles.searchInputSearchIcon, {
4544
- [styles.usedWithinInputGroup]: usedWithinInputGroup
4545
- }),
4546
- size: "medium",
4547
- "aria-hidden": "true"
4548
- }), /*#__PURE__*/React__default["default"].createElement("button", {
4549
- type: "button",
4550
- className: styles.searchInputClearButton,
4551
- disabled: isDisabled,
4552
- onClick: clearInputText,
4553
- "aria-label": clearButtonLabel,
4554
- style: {
4555
- opacity: isClearButtonHidden ? 0 : 1
4556
- },
4557
- "aria-hidden": isClearButtonHidden,
4558
- tabIndex: isClearButtonHidden ? -1 : 0
4559
- }, /*#__PURE__*/React__default["default"].createElement(icons_index.CloseIcon, {
4560
- className: styles.searchInputClearButtonIcon,
4561
- size: "small",
4562
- "aria-hidden": "true"
4563
- })));
4564
- });
4565
-
4566
- /* eslint-disable import/prefer-default-export */
4567
-
4568
- const UIProvider = _ref => {
4569
- let {
4570
- children,
4571
- portalTarget,
4572
- config = {}
4573
- } = _ref;
4574
- return /*#__PURE__*/React__default["default"].createElement(TranslationProvider, {
4575
- localizedText: config === null || config === void 0 ? void 0 : config.localizedText
4576
- }, /*#__PURE__*/React__default["default"].createElement(PortalTargetProvider, {
4577
- target: portalTarget !== null && portalTarget !== void 0 ? portalTarget : null
4578
- }, children));
4579
- };
4580
-
4581
- exports.Button = Button;
4582
- exports.Checkbox = Checkbox;
4583
- exports.ChildIndexProvider = ChildIndexProvider;
4584
- exports.DEFAULT_BREAKPOINTS = DEFAULT_BREAKPOINTS;
4585
- exports.Divider = Divider;
4586
- exports.Dropdown = Dropdown;
4587
- exports.DropdownButton = DropdownButton;
4588
- exports.DropdownHeader = DropdownHeader;
4589
- exports.DropdownList = DropdownList;
4590
- exports.DropdownOption = DropdownOption;
4591
- exports.FLYOUT_POPPER_OFFSET = FLYOUT_POPPER_OFFSET;
4592
- exports.FOCUS_RING_WIDTH = FOCUS_RING_WIDTH;
4593
- exports.Flyout = Flyout;
4594
- exports.FlyoutHeader = FlyoutHeader;
4595
- exports.FlyoutOption = FlyoutOption;
4596
- exports.FormFieldProvider = FormFieldProvider;
4597
- exports.IconButton = IconButton;
4598
- exports.Input = Input$1;
4599
- exports.Input$1 = Input;
4600
- exports.InputField = InputField;
4601
- exports.InputGroupProvider = InputGroupProvider;
4602
- exports.Label = Label;
4603
- exports.LoadingSpinner = LoadingSpinner;
4604
- exports.Menu = Menu;
4605
- exports.MenuItem = MenuItem;
4606
- exports.Pagination = Pagination;
4607
- exports.PaginationNextButton = PaginationNextButton;
4608
- exports.PaginationPageInput = PaginationPageInput;
4609
- exports.PaginationPreviousButton = PaginationPreviousButton;
4610
- exports.Popper = Popper;
4611
- exports.Portal = Portal;
4612
- exports.PortalTargetProvider = PortalTargetProvider;
4613
- exports.SearchInput = SearchInput;
4614
- exports.SelectMenu = SelectMenu;
4615
- exports.Text = Text;
4616
- exports.TextOverflowTooltip = TextOverflowTooltip;
4617
- exports.Tooltip = Tooltip;
4618
- exports.UIProvider = UIProvider;
4619
- exports.buttonStyles = buttonStyles;
4620
- exports.concatIds = concatIds;
4621
- exports.createContextUtilities = createContextUtilities;
4622
- exports.enableKeyboardUserClass = enableKeyboardUserClass;
4623
- exports.filterChildren = filterChildren;
4624
- exports.getIsKeyboardUser = getIsKeyboardUser;
4625
- exports.getSubDataTestId = getSubDataTestId;
4626
- exports.mergeRefs = mergeRefs;
4627
- exports.setIsKeyboardUser = setIsKeyboardUser;
4628
- exports.styles = styles$9;
4629
- exports.useBreakpoints = useBreakpoints;
4630
- exports.useChildIndex = useChildIndex;
4631
- exports.useClickOutside = useClickOutside;
4632
- exports.useClickOutsidePortals = useClickOutsidePortals;
4633
- exports.useControllableState = useControllableState;
4634
- exports.useDidUpdate = useDidUpdate;
4635
- exports.useEnhancedDidUpdate = useEnhancedDidUpdate;
4636
- exports.useEventCallback = useEventCallback;
4637
- exports.useEventListener = useEventListener;
4638
- exports.useFocusSequence = useFocusSequence;
4639
- exports.useFormFieldContext = useFormFieldContext;
4640
- exports.useFormFieldControl = useFormFieldControl;
4641
- exports.useId = useId;
4642
- exports.useInputGroupContext = useInputGroupContext;
4643
- exports.useIsFocused = useIsFocused;
4644
- exports.useIsHovered = useIsHovered;
4645
- exports.useLatest = useLatest;
4646
- exports.useMenuContext = useMenuContext;
4647
- exports.useMounted = useMounted;
4648
- exports.useMouseDrag = useMouseDrag;
4649
- exports.usePortalTarget = usePortalTarget;
4650
- exports.usePrevious = usePrevious;
4651
- exports.useResponsiveValue = useResponsiveValue;
4652
- exports.useSSRLayoutEffect = useSSRLayoutEffect;
4653
- exports.useScreenReaderAnnouncement = useScreenReaderAnnouncement;
4654
- exports.useTranslation = useTranslation;
4655
- exports.wrapAround = wrapAround;
4656
- exports.wrapEvent = wrapEvent;