@khanacademy/wonder-blocks-dropdown 8.0.2 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +932 -882
- package/LICENSE +21 -0
- package/dist/components/dropdown-core.d.ts +2 -2
- package/dist/components/dropdown-opener.d.ts +5 -1
- package/dist/components/multi-select.d.ts +13 -10
- package/dist/components/select-opener.d.ts +5 -1
- package/dist/components/single-select.d.ts +15 -10
- package/dist/es/index.js +74 -61
- package/dist/index.d.ts +3 -3
- package/dist/index.js +122 -123
- package/dist/util/constants.d.ts +0 -11
- package/package.json +18 -20
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
6
4
|
var React = require('react');
|
|
7
5
|
var aphrodite = require('aphrodite');
|
|
@@ -28,10 +26,7 @@ var wonderBlocksForm = require('@khanacademy/wonder-blocks-form');
|
|
|
28
26
|
var IconButton = require('@khanacademy/wonder-blocks-icon-button');
|
|
29
27
|
var Pill = require('@khanacademy/wonder-blocks-pill');
|
|
30
28
|
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
function _interopNamespace(e) {
|
|
34
|
-
if (e && e.__esModule) return e;
|
|
29
|
+
function _interopNamespaceDefault(e) {
|
|
35
30
|
var n = Object.create(null);
|
|
36
31
|
if (e) {
|
|
37
32
|
Object.keys(e).forEach(function (k) {
|
|
@@ -44,29 +39,13 @@ function _interopNamespace(e) {
|
|
|
44
39
|
}
|
|
45
40
|
});
|
|
46
41
|
}
|
|
47
|
-
n
|
|
42
|
+
n.default = e;
|
|
48
43
|
return Object.freeze(n);
|
|
49
44
|
}
|
|
50
45
|
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
54
|
-
var checkIcon__default = /*#__PURE__*/_interopDefaultLegacy(checkIcon);
|
|
55
|
-
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
56
|
-
var SearchField__default = /*#__PURE__*/_interopDefaultLegacy(SearchField);
|
|
57
|
-
var caretDownIcon__default = /*#__PURE__*/_interopDefaultLegacy(caretDownIcon);
|
|
58
|
-
var caretDownIcon__default$1 = /*#__PURE__*/_interopDefaultLegacy(caretDownIcon$1);
|
|
59
|
-
var xIcon__default = /*#__PURE__*/_interopDefaultLegacy(xIcon);
|
|
60
|
-
var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
|
|
61
|
-
var Pill__default = /*#__PURE__*/_interopDefaultLegacy(Pill);
|
|
46
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
47
|
+
var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
|
|
62
48
|
|
|
63
|
-
const keys = {
|
|
64
|
-
escape: "Escape",
|
|
65
|
-
tab: "Tab",
|
|
66
|
-
space: " ",
|
|
67
|
-
up: "ArrowUp",
|
|
68
|
-
down: "ArrowDown"
|
|
69
|
-
};
|
|
70
49
|
const selectDropdownStyle = {
|
|
71
50
|
marginTop: wonderBlocksTokens.spacing.xSmall_8,
|
|
72
51
|
marginBottom: wonderBlocksTokens.spacing.xSmall_8
|
|
@@ -138,10 +117,10 @@ class ActionItem extends React__namespace.Component {
|
|
|
138
117
|
const labelComponent = typeof label === "string" ? React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
|
|
139
118
|
lang: lang,
|
|
140
119
|
style: styles$c.label
|
|
141
|
-
}, label) : React__namespace.cloneElement(label,
|
|
120
|
+
}, label) : (React__namespace.cloneElement(label, _extends({
|
|
142
121
|
lang,
|
|
143
122
|
style: styles$c.label
|
|
144
|
-
}, label.props));
|
|
123
|
+
}, label.props)));
|
|
145
124
|
return React__namespace.createElement(wonderBlocksCell.CompactCell, {
|
|
146
125
|
disabled: disabled,
|
|
147
126
|
horizontalRule: horizontalRule,
|
|
@@ -207,7 +186,7 @@ const Check = function Check(props) {
|
|
|
207
186
|
selected
|
|
208
187
|
} = props;
|
|
209
188
|
return React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
210
|
-
icon:
|
|
189
|
+
icon: checkIcon,
|
|
211
190
|
size: "small",
|
|
212
191
|
style: [styles$b.bounds, !selected && styles$b.hide]
|
|
213
192
|
});
|
|
@@ -238,7 +217,7 @@ const Checkbox = function Checkbox(props) {
|
|
|
238
217
|
className: "checkbox",
|
|
239
218
|
style: [styles$a.checkbox, selected && !disabled && styles$a.noBorder, disabled && styles$a.disabledCheckbox]
|
|
240
219
|
}, selected && React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
241
|
-
icon:
|
|
220
|
+
icon: checkIcon,
|
|
242
221
|
size: "small",
|
|
243
222
|
className: "check",
|
|
244
223
|
style: [{
|
|
@@ -274,7 +253,7 @@ const styles$a = aphrodite.StyleSheet.create({
|
|
|
274
253
|
});
|
|
275
254
|
|
|
276
255
|
const _excluded$5 = ["disabled", "label", "selected", "testId", "leftAccessory", "horizontalRule", "parentComponent", "rightAccessory", "style", "subtitle1", "subtitle2", "value", "onClick", "onToggle", "variant", "role"];
|
|
277
|
-
const
|
|
256
|
+
const StyledLi = wonderBlocksCore.addStyle("li");
|
|
278
257
|
class OptionItem extends React__namespace.Component {
|
|
279
258
|
constructor(...args) {
|
|
280
259
|
super(...args);
|
|
@@ -316,10 +295,10 @@ class OptionItem extends React__namespace.Component {
|
|
|
316
295
|
subtitle2,
|
|
317
296
|
role
|
|
318
297
|
} = _this$props,
|
|
319
|
-
sharedProps =
|
|
298
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$5);
|
|
320
299
|
const CheckComponent = this.getCheckComponent();
|
|
321
300
|
const defaultStyle = [styles$9.item, style];
|
|
322
|
-
return React__namespace.createElement(wonderBlocksCell.DetailCell,
|
|
301
|
+
return React__namespace.createElement(wonderBlocksCell.DetailCell, _extends({
|
|
323
302
|
disabled: disabled,
|
|
324
303
|
horizontalRule: horizontalRule,
|
|
325
304
|
rootStyle: parentComponent === "listbox" ? styles$9.listboxItem : defaultStyle,
|
|
@@ -362,7 +341,7 @@ class OptionItem extends React__namespace.Component {
|
|
|
362
341
|
selected
|
|
363
342
|
} = this.props;
|
|
364
343
|
if (parentComponent === "listbox") {
|
|
365
|
-
return React__namespace.createElement(
|
|
344
|
+
return React__namespace.createElement(StyledLi, {
|
|
366
345
|
onMouseDown: e => {
|
|
367
346
|
e.preventDefault();
|
|
368
347
|
},
|
|
@@ -382,7 +361,7 @@ OptionItem.defaultProps = {
|
|
|
382
361
|
disabled: false,
|
|
383
362
|
focused: false,
|
|
384
363
|
horizontalRule: "none",
|
|
385
|
-
onToggle: () =>
|
|
364
|
+
onToggle: () => undefined,
|
|
386
365
|
role: "option",
|
|
387
366
|
selected: false
|
|
388
367
|
};
|
|
@@ -497,10 +476,11 @@ class SeparatorItem extends React__namespace.Component {
|
|
|
497
476
|
return instance && instance.type && instance.type.__IS_SEPARATOR_ITEM__;
|
|
498
477
|
}
|
|
499
478
|
render() {
|
|
500
|
-
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
479
|
+
return (React__namespace.createElement(wonderBlocksCore.View, {
|
|
480
|
+
style: [styles$8.separator, this.props.style],
|
|
481
|
+
"aria-hidden": "true"
|
|
482
|
+
})
|
|
483
|
+
);
|
|
504
484
|
}
|
|
505
485
|
}
|
|
506
486
|
SeparatorItem.__IS_SEPARATOR_ITEM__ = true;
|
|
@@ -522,6 +502,7 @@ class DropdownOpener extends React__namespace.Component {
|
|
|
522
502
|
};
|
|
523
503
|
}
|
|
524
504
|
renderAnchorChildren(eventState, clickableChildrenProps) {
|
|
505
|
+
var _childrenProps$ariaL;
|
|
525
506
|
const {
|
|
526
507
|
disabled,
|
|
527
508
|
testId,
|
|
@@ -531,18 +512,22 @@ class DropdownOpener extends React__namespace.Component {
|
|
|
531
512
|
"aria-haspopup": ariaHasPopUp,
|
|
532
513
|
"aria-required": ariaRequired,
|
|
533
514
|
id,
|
|
515
|
+
role,
|
|
534
516
|
onBlur
|
|
535
517
|
} = this.props;
|
|
536
|
-
const renderedChildren = this.props.children(
|
|
518
|
+
const renderedChildren = this.props.children(_extends({}, eventState, {
|
|
537
519
|
text,
|
|
538
520
|
opened
|
|
539
521
|
}));
|
|
540
522
|
const childrenProps = renderedChildren.props;
|
|
541
523
|
const childrenTestId = this.getTestIdFromProps(childrenProps);
|
|
542
|
-
|
|
524
|
+
const renderedAriaLabel = (_childrenProps$ariaL = childrenProps["aria-label"]) != null ? _childrenProps$ariaL : this.props["aria-label"];
|
|
525
|
+
return React__namespace.cloneElement(renderedChildren, _extends({}, clickableChildrenProps, {
|
|
526
|
+
"aria-label": renderedAriaLabel != null ? renderedAriaLabel : undefined,
|
|
543
527
|
"aria-invalid": this.props.error,
|
|
544
528
|
disabled,
|
|
545
529
|
"aria-controls": ariaControls,
|
|
530
|
+
role,
|
|
546
531
|
id,
|
|
547
532
|
"aria-expanded": opened ? "true" : "false",
|
|
548
533
|
"aria-haspopup": ariaHasPopUp,
|
|
@@ -587,7 +572,7 @@ class DropdownVirtualizedItem extends React__namespace.Component {
|
|
|
587
572
|
role,
|
|
588
573
|
ref
|
|
589
574
|
} = item;
|
|
590
|
-
return React__namespace.cloneElement(component,
|
|
575
|
+
return React__namespace.cloneElement(component, _extends({
|
|
591
576
|
style
|
|
592
577
|
}, populatedProps, {
|
|
593
578
|
key: index,
|
|
@@ -647,7 +632,7 @@ class DropdownCoreVirtualized extends React__namespace.Component {
|
|
|
647
632
|
}
|
|
648
633
|
setWidth() {
|
|
649
634
|
const rootNode = ReactDOM__namespace.findDOMNode(this);
|
|
650
|
-
const parentNode = rootNode == null ?
|
|
635
|
+
const parentNode = rootNode == null ? undefined : rootNode.parentElement;
|
|
651
636
|
if (parentNode) {
|
|
652
637
|
const width = parentNode.getBoundingClientRect().width;
|
|
653
638
|
this.setState({
|
|
@@ -727,7 +712,7 @@ function modifyMaxHeight({
|
|
|
727
712
|
const [basePlacement] = state.placement.split("-");
|
|
728
713
|
const heightProp = basePlacement === "top" ? "top" : "bottom";
|
|
729
714
|
const maxHeight = height - overflow[heightProp] - y;
|
|
730
|
-
state.styles.popper =
|
|
715
|
+
state.styles.popper = _extends({}, state.styles.popper, {
|
|
731
716
|
maxHeight: `${maxHeight}px`,
|
|
732
717
|
["--popper-max-height"]: `${maxHeight}px`
|
|
733
718
|
});
|
|
@@ -864,10 +849,10 @@ class DropdownCore extends React__namespace.Component {
|
|
|
864
849
|
}
|
|
865
850
|
constructor(props) {
|
|
866
851
|
super(props);
|
|
867
|
-
this.popperElement =
|
|
868
|
-
this.virtualizedListRef =
|
|
869
|
-
this.handleKeyDownDebounced =
|
|
870
|
-
this.textSuggestion =
|
|
852
|
+
this.popperElement = undefined;
|
|
853
|
+
this.virtualizedListRef = undefined;
|
|
854
|
+
this.handleKeyDownDebounced = undefined;
|
|
855
|
+
this.textSuggestion = undefined;
|
|
871
856
|
this.focusedIndex = -1;
|
|
872
857
|
this.focusedOriginalIndex = -1;
|
|
873
858
|
this.itemsClicked = false;
|
|
@@ -897,7 +882,7 @@ class DropdownCore extends React__namespace.Component {
|
|
|
897
882
|
this.handleKeyDownDebounced(this.textSuggestion);
|
|
898
883
|
}
|
|
899
884
|
if (!open) {
|
|
900
|
-
if (key === keys.down) {
|
|
885
|
+
if (key === wonderBlocksCore.keys.down) {
|
|
901
886
|
event.preventDefault();
|
|
902
887
|
onOpenChanged(true);
|
|
903
888
|
return;
|
|
@@ -905,24 +890,24 @@ class DropdownCore extends React__namespace.Component {
|
|
|
905
890
|
return;
|
|
906
891
|
}
|
|
907
892
|
switch (key) {
|
|
908
|
-
case keys.tab:
|
|
893
|
+
case wonderBlocksCore.keys.tab:
|
|
909
894
|
if (this.isSearchFieldFocused() && searchText) {
|
|
910
895
|
return;
|
|
911
896
|
}
|
|
912
897
|
this.restoreTabOrder();
|
|
913
898
|
onOpenChanged(false);
|
|
914
899
|
return;
|
|
915
|
-
case keys.space:
|
|
900
|
+
case wonderBlocksCore.keys.space:
|
|
916
901
|
if (this.isSearchFieldFocused()) {
|
|
917
902
|
return;
|
|
918
903
|
}
|
|
919
904
|
event.preventDefault();
|
|
920
905
|
return;
|
|
921
|
-
case keys.up:
|
|
906
|
+
case wonderBlocksCore.keys.up:
|
|
922
907
|
event.preventDefault();
|
|
923
908
|
this.focusPreviousItem();
|
|
924
909
|
return;
|
|
925
|
-
case keys.down:
|
|
910
|
+
case wonderBlocksCore.keys.down:
|
|
926
911
|
event.preventDefault();
|
|
927
912
|
this.focusNextItem();
|
|
928
913
|
return;
|
|
@@ -935,13 +920,13 @@ class DropdownCore extends React__namespace.Component {
|
|
|
935
920
|
} = this.props;
|
|
936
921
|
const key = event.key;
|
|
937
922
|
switch (key) {
|
|
938
|
-
case keys.space:
|
|
923
|
+
case wonderBlocksCore.keys.space:
|
|
939
924
|
if (this.isSearchFieldFocused()) {
|
|
940
925
|
return;
|
|
941
926
|
}
|
|
942
927
|
event.preventDefault();
|
|
943
928
|
return;
|
|
944
|
-
case keys.escape:
|
|
929
|
+
case wonderBlocksCore.keys.escape:
|
|
945
930
|
if (open) {
|
|
946
931
|
event.stopPropagation();
|
|
947
932
|
this.restoreTabOrder();
|
|
@@ -1012,7 +997,7 @@ class DropdownCore extends React__namespace.Component {
|
|
|
1012
997
|
prevItems: this.props.items,
|
|
1013
998
|
itemRefs: [],
|
|
1014
999
|
sameItemsFocusable: false,
|
|
1015
|
-
labels:
|
|
1000
|
+
labels: _extends({
|
|
1016
1001
|
noResults: defaultLabels.noResults,
|
|
1017
1002
|
someResults: defaultLabels.someSelected
|
|
1018
1003
|
}, props.labels)
|
|
@@ -1052,7 +1037,7 @@ class DropdownCore extends React__namespace.Component {
|
|
|
1052
1037
|
}
|
|
1053
1038
|
if (this.props.labels !== prevProps.labels) {
|
|
1054
1039
|
this.setState({
|
|
1055
|
-
labels:
|
|
1040
|
+
labels: _extends({}, this.state.labels, this.props.labels)
|
|
1056
1041
|
});
|
|
1057
1042
|
}
|
|
1058
1043
|
}
|
|
@@ -1234,7 +1219,7 @@ class DropdownCore extends React__namespace.Component {
|
|
|
1234
1219
|
}
|
|
1235
1220
|
const focusIndex = focusCounter - 1;
|
|
1236
1221
|
const currentRef = this.state.itemRefs[focusIndex] ? this.state.itemRefs[focusIndex].ref : null;
|
|
1237
|
-
return React__namespace.cloneElement(component,
|
|
1222
|
+
return React__namespace.cloneElement(component, _extends({}, populatedProps, {
|
|
1238
1223
|
key: index,
|
|
1239
1224
|
onClick: () => {
|
|
1240
1225
|
this.handleItemClick(focusIndex, item);
|
|
@@ -1255,7 +1240,7 @@ class DropdownCore extends React__namespace.Component {
|
|
|
1255
1240
|
focusCounter += 1;
|
|
1256
1241
|
}
|
|
1257
1242
|
const focusIndex = focusCounter - 1;
|
|
1258
|
-
return
|
|
1243
|
+
return _extends({}, item, {
|
|
1259
1244
|
role: populatedProps.role || itemRole,
|
|
1260
1245
|
ref: item.focusable && this.state.itemRefs[focusIndex] ? this.state.itemRefs[focusIndex].ref : null,
|
|
1261
1246
|
onClick: () => {
|
|
@@ -1278,7 +1263,7 @@ class DropdownCore extends React__namespace.Component {
|
|
|
1278
1263
|
const {
|
|
1279
1264
|
labels
|
|
1280
1265
|
} = this.state;
|
|
1281
|
-
return React__namespace.createElement(
|
|
1266
|
+
return React__namespace.createElement(SearchField, {
|
|
1282
1267
|
clearAriaLabel: labels.clearSearch,
|
|
1283
1268
|
onChange: this.handleSearchTextChanged,
|
|
1284
1269
|
placeholder: labels.filter,
|
|
@@ -1431,7 +1416,7 @@ class ActionMenuOpenerCore extends React__namespace.Component {
|
|
|
1431
1416
|
opened,
|
|
1432
1417
|
"aria-label": ariaLabel
|
|
1433
1418
|
} = _this$props,
|
|
1434
|
-
restProps =
|
|
1419
|
+
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
|
|
1435
1420
|
const buttonColor = wonderBlocksTokens.color.blue;
|
|
1436
1421
|
const buttonStyles = _generateStyles$1(buttonColor);
|
|
1437
1422
|
const disabled = disabledProp;
|
|
@@ -1439,7 +1424,7 @@ class ActionMenuOpenerCore extends React__namespace.Component {
|
|
|
1439
1424
|
const label = React__namespace.createElement(wonderBlocksTypography.LabelLarge, {
|
|
1440
1425
|
style: sharedStyles.text
|
|
1441
1426
|
}, children);
|
|
1442
|
-
return React__namespace.createElement(StyledButton$1,
|
|
1427
|
+
return React__namespace.createElement(StyledButton$1, _extends({
|
|
1443
1428
|
"aria-expanded": opened ? "true" : "false",
|
|
1444
1429
|
"aria-haspopup": "menu",
|
|
1445
1430
|
"aria-label": ariaLabel,
|
|
@@ -1455,7 +1440,7 @@ class ActionMenuOpenerCore extends React__namespace.Component {
|
|
|
1455
1440
|
}), React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
1456
1441
|
size: "small",
|
|
1457
1442
|
color: "currentColor",
|
|
1458
|
-
icon:
|
|
1443
|
+
icon: caretDownIcon,
|
|
1459
1444
|
"aria-hidden": "true"
|
|
1460
1445
|
}));
|
|
1461
1446
|
}
|
|
@@ -1546,7 +1531,7 @@ const _excluded$3 = ["text", "opened"];
|
|
|
1546
1531
|
class ActionMenu extends React__namespace.Component {
|
|
1547
1532
|
constructor(...args) {
|
|
1548
1533
|
super(...args);
|
|
1549
|
-
this.openerElement =
|
|
1534
|
+
this.openerElement = undefined;
|
|
1550
1535
|
this.state = {
|
|
1551
1536
|
opened: false
|
|
1552
1537
|
};
|
|
@@ -1611,7 +1596,7 @@ class ActionMenu extends React__namespace.Component {
|
|
|
1611
1596
|
populatedProps: {}
|
|
1612
1597
|
};
|
|
1613
1598
|
if (ActionItem.isClassOf(item)) {
|
|
1614
|
-
return
|
|
1599
|
+
return _extends({}, itemObject, {
|
|
1615
1600
|
populatedProps: {
|
|
1616
1601
|
indent: isOptionItemIncluded,
|
|
1617
1602
|
onClick: this.handleItemSelected
|
|
@@ -1619,7 +1604,7 @@ class ActionMenu extends React__namespace.Component {
|
|
|
1619
1604
|
});
|
|
1620
1605
|
} else if (OptionItem.isClassOf(item)) {
|
|
1621
1606
|
const selected = selectedValues ? selectedValues.includes(value) : false;
|
|
1622
|
-
return
|
|
1607
|
+
return _extends({}, itemObject, {
|
|
1623
1608
|
populatedProps: {
|
|
1624
1609
|
onToggle: this.handleOptionSelected,
|
|
1625
1610
|
selected,
|
|
@@ -1653,13 +1638,14 @@ class ActionMenu extends React__namespace.Component {
|
|
|
1653
1638
|
text: menuText,
|
|
1654
1639
|
ref: this.handleOpenerRef,
|
|
1655
1640
|
testId: opener ? undefined : testId,
|
|
1656
|
-
opened: this.state.opened
|
|
1641
|
+
opened: this.state.opened,
|
|
1642
|
+
role: "button"
|
|
1657
1643
|
}, opener ? opener : openerProps => {
|
|
1658
1644
|
const {
|
|
1659
1645
|
opened
|
|
1660
1646
|
} = openerProps,
|
|
1661
|
-
eventState =
|
|
1662
|
-
return React__namespace.createElement(ActionMenuOpenerCore,
|
|
1647
|
+
eventState = _objectWithoutPropertiesLoose(openerProps, _excluded$3);
|
|
1648
|
+
return React__namespace.createElement(ActionMenuOpenerCore, _extends({}, eventState, {
|
|
1663
1649
|
disabled: disabled,
|
|
1664
1650
|
opened: !!opened,
|
|
1665
1651
|
testId: testId
|
|
@@ -1711,7 +1697,7 @@ const styles$5 = aphrodite.StyleSheet.create({
|
|
|
1711
1697
|
}
|
|
1712
1698
|
});
|
|
1713
1699
|
|
|
1714
|
-
const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-required", "onBlur", "onOpenChanged"];
|
|
1700
|
+
const _excluded$2 = ["children", "disabled", "error", "id", "isPlaceholder", "open", "testId", "aria-label", "aria-required", "onBlur", "onOpenChanged"];
|
|
1715
1701
|
const StyledButton = wonderBlocksCore.addStyle("button");
|
|
1716
1702
|
class SelectOpener extends React__namespace.Component {
|
|
1717
1703
|
constructor(props) {
|
|
@@ -1723,8 +1709,8 @@ class SelectOpener extends React__namespace.Component {
|
|
|
1723
1709
|
this.props.onOpenChanged(!open);
|
|
1724
1710
|
};
|
|
1725
1711
|
this.handleKeyDown = e => {
|
|
1726
|
-
const
|
|
1727
|
-
if (
|
|
1712
|
+
const keyName = e.key;
|
|
1713
|
+
if (keyName === wonderBlocksCore.keys.enter || keyName === wonderBlocksCore.keys.space) {
|
|
1728
1714
|
this.setState({
|
|
1729
1715
|
pressed: true
|
|
1730
1716
|
});
|
|
@@ -1732,8 +1718,8 @@ class SelectOpener extends React__namespace.Component {
|
|
|
1732
1718
|
}
|
|
1733
1719
|
};
|
|
1734
1720
|
this.handleKeyUp = e => {
|
|
1735
|
-
const
|
|
1736
|
-
if (
|
|
1721
|
+
const keyName = e.key;
|
|
1722
|
+
if (keyName === wonderBlocksCore.keys.enter || keyName === wonderBlocksCore.keys.space) {
|
|
1737
1723
|
this.setState({
|
|
1738
1724
|
pressed: false
|
|
1739
1725
|
});
|
|
@@ -1754,31 +1740,36 @@ class SelectOpener extends React__namespace.Component {
|
|
|
1754
1740
|
isPlaceholder,
|
|
1755
1741
|
open,
|
|
1756
1742
|
testId,
|
|
1743
|
+
"aria-label": ariaLabel,
|
|
1757
1744
|
"aria-required": ariaRequired,
|
|
1758
1745
|
onBlur
|
|
1759
1746
|
} = _this$props,
|
|
1760
|
-
sharedProps =
|
|
1747
|
+
sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$2);
|
|
1761
1748
|
const stateStyles = _generateStyles(isPlaceholder, error);
|
|
1762
1749
|
const iconColor = disabled ? wonderBlocksTokens.semanticColor.action.disabled.default : wonderBlocksTokens.semanticColor.icon.primary;
|
|
1763
1750
|
const style = [styles$4.shared, stateStyles.default, disabled && stateStyles.disabled, !disabled && this.state.pressed && stateStyles.press];
|
|
1764
|
-
return React__namespace.createElement(StyledButton,
|
|
1751
|
+
return React__namespace.createElement(StyledButton, _extends({}, sharedProps, {
|
|
1765
1752
|
"aria-disabled": disabled,
|
|
1766
1753
|
"aria-expanded": open ? "true" : "false",
|
|
1767
1754
|
"aria-invalid": error,
|
|
1755
|
+
"aria-label": ariaLabel != null ? ariaLabel : undefined,
|
|
1768
1756
|
"aria-required": ariaRequired,
|
|
1769
1757
|
"aria-haspopup": "listbox",
|
|
1770
1758
|
"data-testid": testId,
|
|
1771
1759
|
id: id,
|
|
1772
|
-
|
|
1760
|
+
role: "combobox",
|
|
1773
1761
|
type: "button",
|
|
1762
|
+
style: style,
|
|
1774
1763
|
onClick: !disabled ? this.handleClick : undefined,
|
|
1775
1764
|
onKeyDown: !disabled ? this.handleKeyDown : undefined,
|
|
1776
1765
|
onKeyUp: !disabled ? this.handleKeyUp : undefined,
|
|
1777
1766
|
onBlur: onBlur
|
|
1778
1767
|
}), React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
|
|
1779
1768
|
style: styles$4.text
|
|
1780
|
-
}, children ||
|
|
1781
|
-
|
|
1769
|
+
}, children || React__namespace.createElement("span", {
|
|
1770
|
+
"aria-hidden": "true"
|
|
1771
|
+
}, "\xA0")), React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
1772
|
+
icon: caretDownIcon,
|
|
1782
1773
|
color: iconColor,
|
|
1783
1774
|
size: "small",
|
|
1784
1775
|
style: styles$4.caret,
|
|
@@ -1851,10 +1842,10 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1851
1842
|
outlineStyle: "solid",
|
|
1852
1843
|
outlineWidth: wonderBlocksTokens.border.width.thin
|
|
1853
1844
|
};
|
|
1854
|
-
const focusHoverStyling =
|
|
1845
|
+
const focusHoverStyling = _extends({
|
|
1855
1846
|
outlineColor: action.hover.border
|
|
1856
1847
|
}, sharedOutlineStyling);
|
|
1857
|
-
const pressStyling =
|
|
1848
|
+
const pressStyling = _extends({
|
|
1858
1849
|
background: action.press.background,
|
|
1859
1850
|
color: placeholder ? error ? wonderBlocksTokens.semanticColor.text.secondary : wonderBlocksTokens.semanticColor.action.outlined.progressive.press.foreground : wonderBlocksTokens.semanticColor.text.primary,
|
|
1860
1851
|
outlineColor: action.press.border
|
|
@@ -1883,7 +1874,7 @@ const _generateStyles = (placeholder, error) => {
|
|
|
1883
1874
|
borderColor: states.disabled.border,
|
|
1884
1875
|
color: states.disabled.foreground,
|
|
1885
1876
|
cursor: "not-allowed",
|
|
1886
|
-
":focus-visible":
|
|
1877
|
+
":focus-visible": _extends({
|
|
1887
1878
|
outlineColor: wonderBlocksTokens.semanticColor.action.disabled.default
|
|
1888
1879
|
}, sharedOutlineStyling)
|
|
1889
1880
|
},
|
|
@@ -1962,7 +1953,7 @@ function useSelectValidation({
|
|
|
1962
1953
|
};
|
|
1963
1954
|
}
|
|
1964
1955
|
|
|
1965
|
-
const _excluded$1 = ["children", "error", "id", "opener", "placeholder", "selectedValue", "testId", "alignment", "autoFocus", "dropdownStyle", "enableTypeAhead", "isFilterable", "labels", "onChange", "onToggle", "opened", "style", "className", "aria-invalid", "aria-required", "disabled", "dropdownId", "validate", "onValidate", "required", "showOpenerLabelAsText"];
|
|
1956
|
+
const _excluded$1 = ["children", "error", "id", "opener", "placeholder", "selectedValue", "testId", "alignment", "autoFocus", "dropdownStyle", "enableTypeAhead", "isFilterable", "labels", "onChange", "onToggle", "opened", "style", "className", "aria-label", "aria-invalid", "aria-required", "disabled", "dropdownId", "validate", "onValidate", "required", "showOpenerLabelAsText"];
|
|
1966
1957
|
const SingleSelect = props => {
|
|
1967
1958
|
const selectedIndex = React__namespace.useRef(0);
|
|
1968
1959
|
const {
|
|
@@ -1989,6 +1980,7 @@ const SingleSelect = props => {
|
|
|
1989
1980
|
opened,
|
|
1990
1981
|
style,
|
|
1991
1982
|
className,
|
|
1983
|
+
"aria-label": ariaLabel,
|
|
1992
1984
|
"aria-invalid": ariaInvalid,
|
|
1993
1985
|
"aria-required": ariaRequired,
|
|
1994
1986
|
disabled = false,
|
|
@@ -1998,7 +1990,7 @@ const SingleSelect = props => {
|
|
|
1998
1990
|
required,
|
|
1999
1991
|
showOpenerLabelAsText = true
|
|
2000
1992
|
} = props,
|
|
2001
|
-
sharedProps =
|
|
1993
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
2002
1994
|
const [open, setOpen] = React__namespace.useState(false);
|
|
2003
1995
|
const [searchText, setSearchText] = React__namespace.useState("");
|
|
2004
1996
|
const [openerElement, setOpenerElement] = React__namespace.useState();
|
|
@@ -2100,16 +2092,19 @@ const SingleSelect = props => {
|
|
|
2100
2092
|
}, uniqueOpenerId => {
|
|
2101
2093
|
return opener ? React__namespace.createElement(DropdownOpener, {
|
|
2102
2094
|
id: uniqueOpenerId,
|
|
2095
|
+
"aria-label": ariaLabel,
|
|
2103
2096
|
"aria-controls": dropdownId,
|
|
2104
2097
|
"aria-haspopup": "listbox",
|
|
2105
2098
|
onClick: handleClick,
|
|
2106
2099
|
disabled: isDisabled,
|
|
2107
2100
|
ref: handleOpenerRef,
|
|
2101
|
+
role: "combobox",
|
|
2108
2102
|
text: menuText,
|
|
2109
2103
|
opened: open,
|
|
2110
2104
|
error: hasError,
|
|
2111
2105
|
onBlur: onOpenerBlurValidation
|
|
2112
|
-
}, opener) : React__namespace.createElement(SelectOpener,
|
|
2106
|
+
}, opener) : React__namespace.createElement(SelectOpener, _extends({}, sharedProps, {
|
|
2107
|
+
"aria-label": ariaLabel,
|
|
2113
2108
|
"aria-controls": dropdownId,
|
|
2114
2109
|
disabled: isDisabled,
|
|
2115
2110
|
id: uniqueOpenerId,
|
|
@@ -2156,7 +2151,7 @@ const SingleSelect = props => {
|
|
|
2156
2151
|
}));
|
|
2157
2152
|
};
|
|
2158
2153
|
|
|
2159
|
-
const _excluded = ["id", "opener", "testId", "alignment", "dropdownStyle", "implicitAllEnabled", "isFilterable", "labels", "onChange", "onToggle", "opened", "selectedValues", "shortcuts", "style", "className", "aria-invalid", "aria-required", "disabled", "error", "children", "dropdownId", "showOpenerLabelAsText", "validate", "onValidate", "required"];
|
|
2154
|
+
const _excluded = ["id", "opener", "testId", "alignment", "dropdownStyle", "implicitAllEnabled", "isFilterable", "labels", "onChange", "onToggle", "opened", "selectedValues", "shortcuts", "style", "className", "aria-label", "aria-invalid", "aria-required", "disabled", "error", "children", "dropdownId", "showOpenerLabelAsText", "validate", "onValidate", "required"];
|
|
2160
2155
|
const MultiSelect = props => {
|
|
2161
2156
|
const {
|
|
2162
2157
|
id,
|
|
@@ -2174,6 +2169,7 @@ const MultiSelect = props => {
|
|
|
2174
2169
|
shortcuts = false,
|
|
2175
2170
|
style,
|
|
2176
2171
|
className,
|
|
2172
|
+
"aria-label": ariaLabel,
|
|
2177
2173
|
"aria-invalid": ariaInvalid,
|
|
2178
2174
|
"aria-required": ariaRequired,
|
|
2179
2175
|
disabled = false,
|
|
@@ -2185,8 +2181,8 @@ const MultiSelect = props => {
|
|
|
2185
2181
|
onValidate,
|
|
2186
2182
|
required
|
|
2187
2183
|
} = props,
|
|
2188
|
-
sharedProps =
|
|
2189
|
-
const labels =
|
|
2184
|
+
sharedProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
2185
|
+
const labels = _extends({}, defaultLabels, propLabels);
|
|
2190
2186
|
const [open, setOpen] = React__namespace.useState(false);
|
|
2191
2187
|
const [searchText, setSearchText] = React__namespace.useState("");
|
|
2192
2188
|
const [lastSelectedValues, setLastSelectedValues] = React__namespace.useState([]);
|
|
@@ -2248,7 +2244,7 @@ const MultiSelect = props => {
|
|
|
2248
2244
|
onChange([]);
|
|
2249
2245
|
onSelectedValuesChangeValidation();
|
|
2250
2246
|
};
|
|
2251
|
-
const
|
|
2247
|
+
const getMenuTextOrNode = children => {
|
|
2252
2248
|
const {
|
|
2253
2249
|
noneSelected,
|
|
2254
2250
|
someSelected,
|
|
@@ -2262,7 +2258,7 @@ const MultiSelect = props => {
|
|
|
2262
2258
|
case 1:
|
|
2263
2259
|
const selectedItem = children.find(option => option.props.value === selectedValues[0]);
|
|
2264
2260
|
if (selectedItem) {
|
|
2265
|
-
const selectedLabel = getSelectOpenerLabel(showOpenerLabelAsText, selectedItem == null ?
|
|
2261
|
+
const selectedLabel = getSelectOpenerLabel(showOpenerLabelAsText, selectedItem == null ? undefined : selectedItem.props);
|
|
2266
2262
|
if (selectedLabel) {
|
|
2267
2263
|
return selectedLabel;
|
|
2268
2264
|
} else {
|
|
@@ -2374,33 +2370,36 @@ const MultiSelect = props => {
|
|
|
2374
2370
|
const {
|
|
2375
2371
|
noneSelected
|
|
2376
2372
|
} = labels;
|
|
2377
|
-
const
|
|
2373
|
+
const menuContent = getMenuTextOrNode(allChildren);
|
|
2378
2374
|
const dropdownOpener = React__namespace.createElement(wonderBlocksCore.Id, {
|
|
2379
2375
|
id: id
|
|
2380
2376
|
}, uniqueOpenerId => {
|
|
2381
2377
|
return opener ? React__namespace.createElement(DropdownOpener, {
|
|
2382
2378
|
id: uniqueOpenerId,
|
|
2383
2379
|
error: hasError,
|
|
2380
|
+
"aria-label": ariaLabel,
|
|
2384
2381
|
"aria-controls": dropdownId,
|
|
2385
2382
|
"aria-haspopup": "listbox",
|
|
2386
2383
|
onClick: handleClick,
|
|
2387
2384
|
onBlur: onOpenerBlurValidation,
|
|
2388
2385
|
disabled: isDisabled,
|
|
2389
2386
|
ref: handleOpenerRef,
|
|
2390
|
-
|
|
2387
|
+
role: "combobox",
|
|
2388
|
+
text: menuContent,
|
|
2391
2389
|
opened: open
|
|
2392
|
-
}, opener) : React__namespace.createElement(SelectOpener,
|
|
2390
|
+
}, opener) : React__namespace.createElement(SelectOpener, _extends({}, sharedProps, {
|
|
2393
2391
|
error: hasError,
|
|
2394
2392
|
disabled: isDisabled,
|
|
2395
2393
|
id: uniqueOpenerId,
|
|
2394
|
+
"aria-label": ariaLabel,
|
|
2396
2395
|
"aria-controls": dropdownId,
|
|
2397
|
-
isPlaceholder:
|
|
2396
|
+
isPlaceholder: menuContent === noneSelected,
|
|
2398
2397
|
onOpenChanged: handleOpenChanged,
|
|
2399
2398
|
onBlur: onOpenerBlurValidation,
|
|
2400
2399
|
open: open,
|
|
2401
2400
|
ref: handleOpenerRef,
|
|
2402
2401
|
testId: testId
|
|
2403
|
-
}),
|
|
2402
|
+
}), menuContent);
|
|
2404
2403
|
});
|
|
2405
2404
|
return dropdownOpener;
|
|
2406
2405
|
};
|
|
@@ -2567,7 +2566,7 @@ function useListbox({
|
|
|
2567
2566
|
const renderList = React__namespace.useMemo(() => {
|
|
2568
2567
|
return options.map((component, index) => {
|
|
2569
2568
|
const isSingleSelection = selectionType === "single" && typeof selected === "string";
|
|
2570
|
-
const isSelected = (isSingleSelection ? selected === component.props.value : selected == null ?
|
|
2569
|
+
const isSelected = (isSingleSelection ? selected === component.props.value : selected == null ? undefined : selected.includes(component.props.value)) || false;
|
|
2571
2570
|
const optionId = id ? `${id}-option-${index}` : `option-${index}`;
|
|
2572
2571
|
return React__namespace.cloneElement(component, {
|
|
2573
2572
|
key: index,
|
|
@@ -2614,19 +2613,19 @@ function useMultipleSelection({
|
|
|
2614
2613
|
if (key === "ArrowLeft") {
|
|
2615
2614
|
setFocusedMultiSelectIndex(prev => {
|
|
2616
2615
|
const newIndex = prev - 1;
|
|
2617
|
-
return newIndex < 0 ? (selected == null ?
|
|
2616
|
+
return newIndex < 0 ? (selected == null ? undefined : selected.length) - 1 : newIndex;
|
|
2618
2617
|
});
|
|
2619
2618
|
}
|
|
2620
2619
|
if (key === "ArrowRight") {
|
|
2621
2620
|
setFocusedMultiSelectIndex(prev => {
|
|
2622
2621
|
const newIndex = prev + 1;
|
|
2623
|
-
return newIndex >= (selected == null ?
|
|
2622
|
+
return newIndex >= (selected == null ? undefined : selected.length) ? 0 : newIndex;
|
|
2624
2623
|
});
|
|
2625
2624
|
}
|
|
2626
2625
|
if (inputValue === "" && key === "Backspace") {
|
|
2627
2626
|
let newSelected = [];
|
|
2628
2627
|
if (focusedMultiSelectIndex < 0) {
|
|
2629
|
-
newSelected = selected == null ?
|
|
2628
|
+
newSelected = selected == null ? undefined : selected.slice(0, -1);
|
|
2630
2629
|
} else {
|
|
2631
2630
|
newSelected = selected.filter((_, index) => index !== focusedMultiSelectIndex);
|
|
2632
2631
|
}
|
|
@@ -2634,7 +2633,7 @@ function useMultipleSelection({
|
|
|
2634
2633
|
setFocusedMultiSelectIndex(-1);
|
|
2635
2634
|
}
|
|
2636
2635
|
if (focusedMultiSelectIndex >= 0 && key === "Enter") {
|
|
2637
|
-
const newSelected = selected == null ?
|
|
2636
|
+
const newSelected = selected == null ? undefined : selected.filter((_, index) => index !== focusedMultiSelectIndex);
|
|
2638
2637
|
setSelected(newSelected);
|
|
2639
2638
|
setFocusedMultiSelectIndex(-1);
|
|
2640
2639
|
}
|
|
@@ -2675,11 +2674,11 @@ function ComboboxLiveRegion({
|
|
|
2675
2674
|
const lastSelectedValue = React__namespace.useRef(null);
|
|
2676
2675
|
const [message, setMessage] = React__namespace.useState("");
|
|
2677
2676
|
React__namespace.useEffect(() => {
|
|
2678
|
-
if (selected && selected !== (lastSelectedValue == null ?
|
|
2677
|
+
if (selected && selected !== (lastSelectedValue == null ? undefined : lastSelectedValue.current)) {
|
|
2679
2678
|
var _lastSelectedValue$cu, _lastSelectedValue$cu2, _selected$length;
|
|
2680
2679
|
let newMessage = "";
|
|
2681
|
-
const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null
|
|
2682
|
-
const selectedLength = (_selected$length = selected == null ?
|
|
2680
|
+
const lastSelectedLength = (_lastSelectedValue$cu = lastSelectedValue == null || (_lastSelectedValue$cu2 = lastSelectedValue.current) == null ? undefined : _lastSelectedValue$cu2.length) != null ? _lastSelectedValue$cu : 0;
|
|
2681
|
+
const selectedLength = (_selected$length = selected == null ? undefined : selected.length) != null ? _selected$length : 0;
|
|
2683
2682
|
if (Array.isArray(selected) && selected.length > 0) {
|
|
2684
2683
|
const currentLabels = selectedLabels.join(", ");
|
|
2685
2684
|
const selectedState = selectedLength > lastSelectedLength ? labels.selected(currentLabels) : labels.unselected(currentLabels);
|
|
@@ -2765,7 +2764,7 @@ const MultipleSelection = React__namespace.memo(function SelectedPills({
|
|
|
2765
2764
|
const label = labels[index];
|
|
2766
2765
|
const focused = index === focusedMultiSelectIndex;
|
|
2767
2766
|
const uniqueId = id + index;
|
|
2768
|
-
return React__namespace.createElement(
|
|
2767
|
+
return React__namespace.createElement(Pill, {
|
|
2769
2768
|
id: uniqueId,
|
|
2770
2769
|
key: uniqueId,
|
|
2771
2770
|
testId: testId ? `${testId}-pill-${index}` : undefined,
|
|
@@ -2776,7 +2775,7 @@ const MultipleSelection = React__namespace.memo(function SelectedPills({
|
|
|
2776
2775
|
tabIndex: -1,
|
|
2777
2776
|
onClick: () => onRemove(value)
|
|
2778
2777
|
}, React__namespace.createElement(React__namespace.Fragment, null, label, !disabled && React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
2779
|
-
icon:
|
|
2778
|
+
icon: xIcon,
|
|
2780
2779
|
size: "small"
|
|
2781
2780
|
})));
|
|
2782
2781
|
}));
|
|
@@ -2833,7 +2832,7 @@ function StandaloneListbox(props) {
|
|
|
2833
2832
|
});
|
|
2834
2833
|
React__namespace.useEffect(() => {
|
|
2835
2834
|
if (selected && selected !== value) {
|
|
2836
|
-
onChange == null
|
|
2835
|
+
onChange == null || onChange(selected);
|
|
2837
2836
|
}
|
|
2838
2837
|
}, [onChange, selected, value]);
|
|
2839
2838
|
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
@@ -2905,7 +2904,7 @@ function Combobox({
|
|
|
2905
2904
|
testId,
|
|
2906
2905
|
value = ""
|
|
2907
2906
|
}) {
|
|
2908
|
-
var _renderList$find, _renderList$focusedIn
|
|
2907
|
+
var _renderList$find, _renderList$focusedIn;
|
|
2909
2908
|
const generatedUniqueId = React.useId();
|
|
2910
2909
|
const uniqueId = id != null ? id : generatedUniqueId;
|
|
2911
2910
|
const comboboxRef = React__namespace.useRef(null);
|
|
@@ -2936,7 +2935,7 @@ function Combobox({
|
|
|
2936
2935
|
disableSpaceSelection: true,
|
|
2937
2936
|
selectionType
|
|
2938
2937
|
});
|
|
2939
|
-
const itemFromSelected = (_renderList$find = renderList.find(item => item.props.value === selected)) == null ?
|
|
2938
|
+
const itemFromSelected = (_renderList$find = renderList.find(item => item.props.value === selected)) == null ? undefined : _renderList$find.props;
|
|
2940
2939
|
const labelFromSelected = itemFromSelected ? getLabel(itemFromSelected) : "";
|
|
2941
2940
|
const initialValue = typeof value === "string" ? labelFromSelected : "";
|
|
2942
2941
|
const [inputValue, setInputValue] = React__namespace.useState(initialValue);
|
|
@@ -2964,16 +2963,16 @@ function Combobox({
|
|
|
2964
2963
|
}
|
|
2965
2964
|
setCurrentOptions(children);
|
|
2966
2965
|
}
|
|
2967
|
-
onToggle == null
|
|
2966
|
+
onToggle == null || onToggle(newState);
|
|
2968
2967
|
}, [children, disabled, isControlled, labelFromSelected, onToggle, openState, selectionType, setFocusedIndex]);
|
|
2969
2968
|
const handleChange = React__namespace.useCallback(value => {
|
|
2970
2969
|
if (value !== valueState) {
|
|
2971
2970
|
setSelectedValue(value);
|
|
2972
|
-
onChange == null
|
|
2971
|
+
onChange == null || onChange(value);
|
|
2973
2972
|
}
|
|
2974
2973
|
if (selectionType === "single" && typeof value === "string") {
|
|
2975
2974
|
var _renderList$find2;
|
|
2976
|
-
const itemFromSelected = (_renderList$find2 = renderList.find(item => item.props.value === value)) == null ?
|
|
2975
|
+
const itemFromSelected = (_renderList$find2 = renderList.find(item => item.props.value === value)) == null ? undefined : _renderList$find2.props;
|
|
2977
2976
|
const labelFromSelected = itemFromSelected ? getLabel(itemFromSelected) : "";
|
|
2978
2977
|
updateOpenState(false, labelFromSelected);
|
|
2979
2978
|
} else if (Array.isArray(value)) {
|
|
@@ -3027,20 +3026,20 @@ function Combobox({
|
|
|
3027
3026
|
e.stopPropagation();
|
|
3028
3027
|
setInputValue("");
|
|
3029
3028
|
setSelected("");
|
|
3030
|
-
onChange == null
|
|
3031
|
-
(_comboboxRef$current = comboboxRef.current) == null
|
|
3029
|
+
onChange == null || onChange("");
|
|
3030
|
+
(_comboboxRef$current = comboboxRef.current) == null || _comboboxRef$current.focus();
|
|
3032
3031
|
}, [onChange, setSelected]);
|
|
3033
3032
|
React__namespace.useEffect(() => {
|
|
3034
3033
|
if (openState) {
|
|
3035
3034
|
var _comboboxRef$current2;
|
|
3036
|
-
(_comboboxRef$current2 = comboboxRef.current) == null
|
|
3035
|
+
(_comboboxRef$current2 = comboboxRef.current) == null || _comboboxRef$current2.focus();
|
|
3037
3036
|
}
|
|
3038
3037
|
}, [openState]);
|
|
3039
3038
|
const selectedLabels = React__namespace.useMemo(() => {
|
|
3040
3039
|
if (Array.isArray(selected)) {
|
|
3041
3040
|
return selected.map(value => {
|
|
3042
3041
|
const item = children.find(item => item.props.value === value);
|
|
3043
|
-
return item ? getLabel(item == null ?
|
|
3042
|
+
return item ? getLabel(item == null ? undefined : item.props) : "";
|
|
3044
3043
|
});
|
|
3045
3044
|
}
|
|
3046
3045
|
return [labelFromSelected];
|
|
@@ -3050,7 +3049,7 @@ function Combobox({
|
|
|
3050
3049
|
if (!startIcon) {
|
|
3051
3050
|
return null;
|
|
3052
3051
|
}
|
|
3053
|
-
const startIconElement = React__namespace.cloneElement(startIcon,
|
|
3052
|
+
const startIconElement = React__namespace.cloneElement(startIcon, _extends({
|
|
3054
3053
|
size: "small"
|
|
3055
3054
|
}, startIcon.props, {
|
|
3056
3055
|
color: disabled ? wonderBlocksTokens.color.offBlack32 : (_startIcon$props$colo = startIcon.props.color) != null ? _startIcon$props$colo : wonderBlocksTokens.semanticColor.icon.primary
|
|
@@ -3061,7 +3060,7 @@ function Combobox({
|
|
|
3061
3060
|
};
|
|
3062
3061
|
const pillIdPrefix = `${uniqueId}-pill-`;
|
|
3063
3062
|
const textFieldId = React.useId();
|
|
3064
|
-
const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null
|
|
3063
|
+
const currentActiveDescendant = !openState ? undefined : focusedIndex >= 0 ? (_renderList$focusedIn = renderList[focusedIndex]) == null || (_renderList$focusedIn = _renderList$focusedIn.props) == null ? undefined : _renderList$focusedIn.id : pillIdPrefix + focusedMultiSelectIndex;
|
|
3065
3064
|
const controlledWidget = !openState ? undefined : focusedIndex >= 0 ? uniqueId : pillIdPrefix;
|
|
3066
3065
|
return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(wonderBlocksCore.View, {
|
|
3067
3066
|
onClick: () => {
|
|
@@ -3113,17 +3112,17 @@ function Combobox({
|
|
|
3113
3112
|
ref: comboboxRef,
|
|
3114
3113
|
autoComplete: "off",
|
|
3115
3114
|
role: "combobox"
|
|
3116
|
-
}), inputValue && !disabled && React__namespace.createElement(
|
|
3117
|
-
icon:
|
|
3115
|
+
}), inputValue && !disabled && React__namespace.createElement(IconButton, {
|
|
3116
|
+
icon: xIcon,
|
|
3118
3117
|
onClick: handleClearClick,
|
|
3119
3118
|
kind: "tertiary",
|
|
3120
3119
|
size: "small",
|
|
3121
3120
|
style: [styles.button, styles.clearButton],
|
|
3122
3121
|
"aria-label": labels.clearSelection,
|
|
3123
3122
|
testId: testId ? `${testId}-clear` : undefined
|
|
3124
|
-
}), React__namespace.createElement(
|
|
3123
|
+
}), React__namespace.createElement(IconButton, {
|
|
3125
3124
|
disabled: disabled,
|
|
3126
|
-
icon:
|
|
3125
|
+
icon: caretDownIcon$1,
|
|
3127
3126
|
onClick: e => {
|
|
3128
3127
|
e.stopPropagation();
|
|
3129
3128
|
updateOpenState(!openState);
|
|
@@ -3140,13 +3139,13 @@ function Combobox({
|
|
|
3140
3139
|
"aria-label": labels.comboboxButton
|
|
3141
3140
|
})), openState && React__namespace.createElement(DropdownPopper, {
|
|
3142
3141
|
alignment: "left",
|
|
3143
|
-
referenceElement: rootNodeRef == null ?
|
|
3142
|
+
referenceElement: rootNodeRef == null ? undefined : rootNodeRef.current
|
|
3144
3143
|
}, isReferenceHidden => {
|
|
3145
3144
|
var _rootNodeRef$current, _rootNodeRef$current2;
|
|
3146
3145
|
return React__namespace.createElement(React__namespace.Fragment, null, renderList.length === 0 ? React__namespace.createElement(wonderBlocksCell.DetailCell, {
|
|
3147
3146
|
title: labels.noItems,
|
|
3148
3147
|
style: [styles.listbox, {
|
|
3149
|
-
minWidth: rootNodeRef == null
|
|
3148
|
+
minWidth: rootNodeRef == null || (_rootNodeRef$current = rootNodeRef.current) == null ? undefined : _rootNodeRef$current.offsetWidth
|
|
3150
3149
|
}],
|
|
3151
3150
|
horizontalRule: "none"
|
|
3152
3151
|
}) : React__namespace.createElement(Listbox, {
|
|
@@ -3154,7 +3153,7 @@ function Combobox({
|
|
|
3154
3153
|
tabIndex: -1,
|
|
3155
3154
|
selectionType: selectionType,
|
|
3156
3155
|
style: [styles.listbox, isReferenceHidden && styles.hidden, {
|
|
3157
|
-
minWidth: rootNodeRef == null
|
|
3156
|
+
minWidth: rootNodeRef == null || (_rootNodeRef$current2 = rootNodeRef.current) == null ? undefined : _rootNodeRef$current2.offsetWidth
|
|
3158
3157
|
}],
|
|
3159
3158
|
testId: testId ? `${testId}-listbox` : undefined,
|
|
3160
3159
|
"aria-label": labels.listbox,
|