@instructure/ui-drilldown 10.16.1-snapshot-0 → 10.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/es/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +448 -325
- package/es/Drilldown/DrilldownGroup/index.js +0 -1
- package/es/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +422 -309
- package/es/Drilldown/DrilldownOption/index.js +0 -1
- package/es/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +201 -147
- package/es/Drilldown/DrilldownPage/index.js +0 -1
- package/es/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +22 -17
- package/es/Drilldown/DrilldownSeparator/index.js +0 -1
- package/es/Drilldown/__examples__/Drilldown.examples.js +99 -82
- package/es/Drilldown/__new-tests__/Drilldown.test.js +533 -352
- package/es/Drilldown/index.js +144 -126
- package/lib/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.js +463 -340
- package/lib/Drilldown/DrilldownGroup/index.js +0 -1
- package/lib/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.js +448 -336
- package/lib/Drilldown/DrilldownOption/index.js +0 -1
- package/lib/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.js +221 -167
- package/lib/Drilldown/DrilldownPage/index.js +0 -2
- package/lib/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.js +25 -21
- package/lib/Drilldown/DrilldownSeparator/index.js +0 -1
- package/lib/Drilldown/__examples__/Drilldown.examples.js +99 -83
- package/lib/Drilldown/__new-tests__/Drilldown.test.js +568 -387
- package/lib/Drilldown/index.js +143 -126
- package/package.json +21 -21
- package/src/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.tsx +0 -1
- package/src/Drilldown/DrilldownGroup/index.tsx +0 -1
- package/src/Drilldown/DrilldownOption/__new-tests__/DrilldownOption.test.tsx +1 -1
- package/src/Drilldown/DrilldownOption/index.tsx +0 -1
- package/src/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.tsx +0 -1
- package/src/Drilldown/DrilldownPage/index.tsx +0 -1
- package/src/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.tsx +0 -1
- package/src/Drilldown/DrilldownSeparator/index.tsx +0 -1
- package/src/Drilldown/__examples__/Drilldown.examples.tsx +0 -2
- package/src/Drilldown/__new-tests__/Drilldown.test.tsx +0 -1
- package/src/Drilldown/index.tsx +4 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Drilldown/DrilldownGroup/__new-tests__/DrilldownGroup.test.d.ts.map +1 -1
- package/types/Drilldown/DrilldownGroup/index.d.ts +0 -1
- package/types/Drilldown/DrilldownGroup/index.d.ts.map +1 -1
- package/types/Drilldown/DrilldownOption/index.d.ts +0 -1
- package/types/Drilldown/DrilldownOption/index.d.ts.map +1 -1
- package/types/Drilldown/DrilldownPage/__new-tests__/DrilldownPage.test.d.ts.map +1 -1
- package/types/Drilldown/DrilldownPage/index.d.ts +0 -1
- package/types/Drilldown/DrilldownPage/index.d.ts.map +1 -1
- package/types/Drilldown/DrilldownSeparator/__new-tests__/DrilldownSeparator.test.d.ts.map +1 -1
- package/types/Drilldown/DrilldownSeparator/index.d.ts +0 -1
- package/types/Drilldown/DrilldownSeparator/index.d.ts.map +1 -1
- package/types/Drilldown/__examples__/Drilldown.examples.d.ts.map +1 -1
- package/types/Drilldown/__new-tests__/Drilldown.test.d.ts.map +1 -1
- package/types/Drilldown/index.d.ts +7 -10
- package/types/Drilldown/index.d.ts.map +1 -1
package/lib/Drilldown/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.Drilldown = void 0;
|
|
9
8
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
-
var _react =
|
|
9
|
+
var _react = require("react");
|
|
11
10
|
var _console = require("@instructure/console");
|
|
12
11
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
13
12
|
var _contains = require("@instructure/ui-dom-utils/lib/contains.js");
|
|
@@ -32,6 +31,8 @@ var _DrilldownPage = require("./DrilldownPage");
|
|
|
32
31
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
33
32
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
34
33
|
var _props = require("./props");
|
|
34
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
35
|
+
var _react2 = require("@emotion/react");
|
|
35
36
|
const _excluded = ["groupProps"],
|
|
36
37
|
_excluded2 = ["groupProps"],
|
|
37
38
|
_excluded3 = ["id", "themeOverride"];
|
|
@@ -59,8 +60,6 @@ var _dec, _dec2, _dec3, _class, _Drilldown, _IconArrowOpenEndSoli, _IconArrowOpe
|
|
|
59
60
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
60
61
|
* SOFTWARE.
|
|
61
62
|
*/
|
|
62
|
-
/** @jsx jsx */
|
|
63
|
-
/** @jsxFrag React.Fragment */
|
|
64
63
|
// Additional data we need to track on the Options,
|
|
65
64
|
// but shouldn't be settable via props
|
|
66
65
|
// Contains the Option ComponentElement and the extra data we need track on it,
|
|
@@ -416,7 +415,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
416
415
|
}
|
|
417
416
|
get pages() {
|
|
418
417
|
const children = this.props.children;
|
|
419
|
-
return _react.
|
|
418
|
+
return _react.Children.toArray(children || []);
|
|
420
419
|
}
|
|
421
420
|
get pageMap() {
|
|
422
421
|
const children = this.props.children;
|
|
@@ -429,7 +428,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
429
428
|
const children = props.children;
|
|
430
429
|
map[props.id] = {
|
|
431
430
|
...props,
|
|
432
|
-
children: _react.
|
|
431
|
+
children: _react.Children.toArray(children || [])
|
|
433
432
|
};
|
|
434
433
|
});
|
|
435
434
|
return map;
|
|
@@ -559,27 +558,31 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
559
558
|
if (this.previousPage) {
|
|
560
559
|
const prevPageTitle = (0, _callRenderProp.callRenderProp)(this.previousPage.renderTitle);
|
|
561
560
|
const backButtonLabel = (0, _callRenderProp.callRenderProp)(renderBackButtonLabel, prevPageTitle);
|
|
562
|
-
headerChildren.push((0,
|
|
561
|
+
headerChildren.push((0, _jsxRuntime.jsx)(_DrilldownOption.DrilldownOption, {
|
|
563
562
|
id: this._headerBackId,
|
|
564
|
-
onOptionClick: this.handleBackButtonClick
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
563
|
+
onOptionClick: this.handleBackButtonClick,
|
|
564
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
565
|
+
css: styles === null || styles === void 0 ? void 0 : styles.headerBack,
|
|
566
|
+
role: "presentation",
|
|
567
|
+
children: backButtonLabel
|
|
568
|
+
})
|
|
569
|
+
}));
|
|
569
570
|
}
|
|
570
571
|
|
|
571
572
|
// Header title
|
|
572
573
|
if (renderTitle) {
|
|
573
574
|
const title = (0, _callRenderProp.callRenderProp)(renderTitle);
|
|
574
575
|
if (title) {
|
|
575
|
-
headerChildren.push((0,
|
|
576
|
+
headerChildren.push((0, _jsxRuntime.jsx)(_DrilldownOption.DrilldownOption, {
|
|
576
577
|
id: this._headerTitleId,
|
|
577
578
|
role: "presentation",
|
|
578
|
-
"aria-hidden": "true"
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
579
|
+
"aria-hidden": "true",
|
|
580
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
581
|
+
css: styles === null || styles === void 0 ? void 0 : styles.headerTitle,
|
|
582
|
+
id: this._headerTitleLabelId,
|
|
583
|
+
children: title
|
|
584
|
+
})
|
|
585
|
+
}));
|
|
583
586
|
}
|
|
584
587
|
}
|
|
585
588
|
|
|
@@ -587,7 +590,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
587
590
|
if (renderActionLabel) {
|
|
588
591
|
const actionLabel = (0, _callRenderProp.callRenderProp)(renderActionLabel);
|
|
589
592
|
if (actionLabel) {
|
|
590
|
-
headerChildren.push((0,
|
|
593
|
+
headerChildren.push((0, _jsxRuntime.jsx)(_DrilldownOption.DrilldownOption, {
|
|
591
594
|
id: this._headerActionId,
|
|
592
595
|
themeOverride: {
|
|
593
596
|
color: styles === null || styles === void 0 ? void 0 : styles.headerActionColor
|
|
@@ -596,14 +599,15 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
596
599
|
if (typeof onHeaderActionClicked === 'function') {
|
|
597
600
|
onHeaderActionClicked(event);
|
|
598
601
|
}
|
|
599
|
-
}
|
|
600
|
-
|
|
602
|
+
},
|
|
603
|
+
children: actionLabel
|
|
604
|
+
}));
|
|
601
605
|
}
|
|
602
606
|
}
|
|
603
607
|
|
|
604
608
|
// header separator
|
|
605
609
|
if (headerChildren.length > 0 && children.length > 0 && !withoutHeaderSeparator) {
|
|
606
|
-
headerChildren.push((0,
|
|
610
|
+
headerChildren.push((0, _jsxRuntime.jsx)(_DrilldownSeparator.DrilldownSeparator, {
|
|
607
611
|
id: deterministicId('DrilldownHeader-Separator')
|
|
608
612
|
}));
|
|
609
613
|
}
|
|
@@ -763,14 +767,15 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
763
767
|
id = _separator$props.id,
|
|
764
768
|
themeOverride = _separator$props.themeOverride,
|
|
765
769
|
props = (0, _objectWithoutProperties2.default)(_separator$props, _excluded3);
|
|
766
|
-
return (0,
|
|
770
|
+
return (0, _react2.createElement)(_Options.Options.Separator, {
|
|
771
|
+
...props,
|
|
767
772
|
id: id,
|
|
768
773
|
key: id,
|
|
769
774
|
role: "separator"
|
|
770
775
|
// we pass the themeOverride to Options.Separator
|
|
771
776
|
,
|
|
772
777
|
themeOverride: themeOverride
|
|
773
|
-
})
|
|
778
|
+
});
|
|
774
779
|
}
|
|
775
780
|
renderOption(option, getOptionProps, getDisabledOptionProps, groupProps) {
|
|
776
781
|
var _this$currentPage2, _optionProps$renderBe, _optionProps$renderBe2, _optionProps$renderAf, _optionProps$renderAf2;
|
|
@@ -859,13 +864,13 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
859
864
|
// we set a few manually on Options.Item,
|
|
860
865
|
// the rest are passed directly
|
|
861
866
|
if (subPageId) {
|
|
862
|
-
optionProps.renderAfterLabel = _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0,
|
|
867
|
+
optionProps.renderAfterLabel = _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _jsxRuntime.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, {}));
|
|
863
868
|
optionProps['aria-haspopup'] = true;
|
|
864
869
|
optionProps.role = customRole || 'button';
|
|
865
870
|
(0, _console.warn)(!renderAfterLabel, `The prop "renderAfterLabel" is reserved on item with id: "${id}". When it has "subPageId" provided, a navigation arrow will render after the label.`);
|
|
866
871
|
}
|
|
867
872
|
if (id === this._headerBackId) {
|
|
868
|
-
optionProps.renderBeforeLabel = _IconArrowOpenStartSo || (_IconArrowOpenStartSo = (0,
|
|
873
|
+
optionProps.renderBeforeLabel = _IconArrowOpenStartSo || (_IconArrowOpenStartSo = (0, _jsxRuntime.jsx)(_IconArrowOpenStartSolid.IconArrowOpenStartSolid, {}));
|
|
869
874
|
}
|
|
870
875
|
const isOptionControlled = typeof option.props.selected === 'boolean';
|
|
871
876
|
if ((groupProps !== null && groupProps !== void 0 && groupProps.selectableType || isOptionControlled) && groupProps) {
|
|
@@ -876,7 +881,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
876
881
|
isSelected = Boolean(option.props.selected);
|
|
877
882
|
}
|
|
878
883
|
optionProps['aria-checked'] = isSelected;
|
|
879
|
-
optionProps.renderBeforeLabel = (0,
|
|
884
|
+
optionProps.renderBeforeLabel = (0, _jsxRuntime.jsx)(_IconCheckSolid.IconCheckSolid, {
|
|
880
885
|
style: {
|
|
881
886
|
opacity: isSelected ? 1 : 0
|
|
882
887
|
}
|
|
@@ -941,26 +946,31 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
941
946
|
const infoAriaId = `${id}__info`;
|
|
942
947
|
const labelledby = option.props['aria-labelledby'] || labelAriaId;
|
|
943
948
|
const describedby = option.props['aria-describedby'] || (labelInfo ? infoAriaId : void 0);
|
|
944
|
-
return (0,
|
|
949
|
+
return (0, _react2.createElement)(_Options.Options.Item, {
|
|
950
|
+
...optionProps,
|
|
945
951
|
key: id,
|
|
946
952
|
"aria-labelledby": labelledby,
|
|
947
953
|
"aria-describedby": describedby
|
|
948
|
-
}
|
|
954
|
+
}, (0, _jsxRuntime.jsxs)("div", {
|
|
949
955
|
css: styles === null || styles === void 0 ? void 0 : styles.optionContainer,
|
|
950
|
-
role: "none"
|
|
951
|
-
}, (0, _emotion.jsx)("span", {
|
|
952
|
-
css: styles === null || styles === void 0 ? void 0 : styles.optionContent,
|
|
953
956
|
role: "none",
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
957
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
958
|
+
css: styles === null || styles === void 0 ? void 0 : styles.optionContent,
|
|
959
|
+
role: "none",
|
|
960
|
+
id: labelAriaId,
|
|
961
|
+
children: optionLabel
|
|
962
|
+
}), labelInfo ? (0, _jsxRuntime.jsx)("span", {
|
|
963
|
+
css: styles === null || styles === void 0 ? void 0 : styles.optionLabelInfo,
|
|
964
|
+
role: "presentation",
|
|
965
|
+
style: {
|
|
966
|
+
alignSelf: vAlignMap[afterLabelContentVAlign]
|
|
967
|
+
},
|
|
968
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
969
|
+
id: infoAriaId,
|
|
970
|
+
children: labelInfo
|
|
971
|
+
})
|
|
972
|
+
}) : null]
|
|
973
|
+
}));
|
|
964
974
|
}
|
|
965
975
|
renderGroup(group, getOptionProps, getDisabledOptionProps, needsFirstSeparator, needsLastSeparator) {
|
|
966
976
|
const _group$props = group.props,
|
|
@@ -978,34 +988,34 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
978
988
|
|
|
979
989
|
// add a separator above
|
|
980
990
|
if (needsFirstSeparator) {
|
|
981
|
-
groupChildren.push(_Options$Separator || (_Options$Separator = (0,
|
|
991
|
+
groupChildren.push(_Options$Separator || (_Options$Separator = (0, _jsxRuntime.jsx)(_Options.Options.Separator, {})));
|
|
982
992
|
}
|
|
983
993
|
|
|
984
994
|
// create a sublist as a group
|
|
985
995
|
// (a wrapping list item will be created by Options)
|
|
986
|
-
groupChildren.push((0,
|
|
996
|
+
groupChildren.push((0, _jsxRuntime.jsx)(_Options.Options, {
|
|
987
997
|
id: id,
|
|
988
|
-
key: id,
|
|
989
998
|
role: role,
|
|
990
999
|
as: as || this.props.as,
|
|
991
1000
|
renderLabel: renderGroupTitle,
|
|
992
1001
|
elementRef: elementRef
|
|
993
1002
|
// we pass the themeOverride to Options
|
|
994
1003
|
,
|
|
995
|
-
themeOverride: themeOverride
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1004
|
+
themeOverride: themeOverride,
|
|
1005
|
+
children: this.getChildrenArray(children).map(child => {
|
|
1006
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_DrilldownSeparator.DrilldownSeparator])) {
|
|
1007
|
+
return this.renderSeparator(child);
|
|
1008
|
+
} else if ((0, _matchComponentTypes.matchComponentTypes)(child, [_DrilldownOption.DrilldownOption])) {
|
|
1009
|
+
return this.renderOption(child, getOptionProps, getDisabledOptionProps, group.props);
|
|
1010
|
+
} else {
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
})
|
|
1014
|
+
}, id));
|
|
1005
1015
|
|
|
1006
1016
|
// add a separator below
|
|
1007
1017
|
if (needsLastSeparator) {
|
|
1008
|
-
groupChildren.push(_Options$Separator2 || (_Options$Separator2 = (0,
|
|
1018
|
+
groupChildren.push(_Options$Separator2 || (_Options$Separator2 = (0, _jsxRuntime.jsx)(_Options.Options.Separator, {})));
|
|
1009
1019
|
}
|
|
1010
1020
|
return groupChildren;
|
|
1011
1021
|
}
|
|
@@ -1026,7 +1036,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
1026
1036
|
if (!this.currentPage) {
|
|
1027
1037
|
return null;
|
|
1028
1038
|
}
|
|
1029
|
-
return (0,
|
|
1039
|
+
return (0, _jsxRuntime.jsx)(_Selectable.Selectable, {
|
|
1030
1040
|
isShowingOptions: this.shown,
|
|
1031
1041
|
highlightedOptionId: this.state.highlightedOptionId,
|
|
1032
1042
|
selectedOptionId: this.selectedGroupOptionIdsArray,
|
|
@@ -1045,73 +1055,79 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
1045
1055
|
this.handleOptionHighlight(event, {
|
|
1046
1056
|
id: lastOptionId
|
|
1047
1057
|
});
|
|
1048
|
-
}
|
|
1049
|
-
}, ({
|
|
1050
|
-
// TODO: figure out what other Selectable props we need, if we want to add a Select version for drilldown:
|
|
1051
|
-
// getRootProps, - we probably don't need this
|
|
1052
|
-
// getLabelProps, - do we need label?
|
|
1053
|
-
// getDescriptionProps, - might be nice for assistiveText like in Select
|
|
1054
|
-
// getInputProps, - hidden input for a11y? role="combobox" might be needed
|
|
1055
|
-
getTriggerProps,
|
|
1056
|
-
getListProps,
|
|
1057
|
-
getOptionProps,
|
|
1058
|
-
getDisabledOptionProps
|
|
1059
|
-
}) => (0, _emotion.jsx)(_View.View, Object.assign({
|
|
1060
|
-
borderWidth: "small",
|
|
1061
|
-
as: "div",
|
|
1062
|
-
elementRef: this.handleDrilldownRef,
|
|
1063
|
-
tabIndex: 0,
|
|
1064
|
-
css: styles === null || styles === void 0 ? void 0 : styles.drilldown,
|
|
1065
|
-
position: "relative",
|
|
1066
|
-
borderRadius: "small",
|
|
1067
|
-
width: width,
|
|
1068
|
-
minWidth: maxWidth,
|
|
1069
|
-
maxWidth: maxWidth,
|
|
1070
|
-
role: role,
|
|
1071
|
-
"aria-label": label,
|
|
1072
|
-
"aria-labelledby": this.currentPageAriaLabel
|
|
1073
|
-
}, getTriggerProps({
|
|
1074
|
-
id: this._id,
|
|
1075
|
-
// We need to override these aria attributes added by Selectable,
|
|
1076
|
-
// since Drilldown is not a combobox and has no popup
|
|
1077
|
-
'aria-haspopup': false,
|
|
1078
|
-
'aria-expanded': void 0,
|
|
1079
|
-
onKeyDown: this.handleKeyDown,
|
|
1080
|
-
onBlur: event => {
|
|
1081
|
-
const target = event.currentTarget;
|
|
1082
|
-
const related = event.relatedTarget;
|
|
1083
|
-
const containsRelated = (0, _contains.contains)(target, related);
|
|
1084
|
-
if (!related || related === this._drilldownRef || related !== target && !containsRelated) {
|
|
1085
|
-
this.setState({
|
|
1086
|
-
highlightedOptionId: void 0
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
1058
|
},
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1059
|
+
children: ({
|
|
1060
|
+
// TODO: figure out what other Selectable props we need, if we want to add a Select version for drilldown:
|
|
1061
|
+
// getRootProps, - we probably don't need this
|
|
1062
|
+
// getLabelProps, - do we need label?
|
|
1063
|
+
// getDescriptionProps, - might be nice for assistiveText like in Select
|
|
1064
|
+
// getInputProps, - hidden input for a11y? role="combobox" might be needed
|
|
1065
|
+
getTriggerProps,
|
|
1066
|
+
getListProps,
|
|
1067
|
+
getOptionProps,
|
|
1068
|
+
getDisabledOptionProps
|
|
1069
|
+
}) => (0, _jsxRuntime.jsx)(_View.View, {
|
|
1070
|
+
borderWidth: "small",
|
|
1071
|
+
as: "div",
|
|
1072
|
+
elementRef: this.handleDrilldownRef,
|
|
1073
|
+
tabIndex: 0,
|
|
1074
|
+
css: styles === null || styles === void 0 ? void 0 : styles.drilldown,
|
|
1075
|
+
position: "relative",
|
|
1076
|
+
borderRadius: "small",
|
|
1077
|
+
width: width,
|
|
1078
|
+
minWidth: maxWidth,
|
|
1079
|
+
maxWidth: maxWidth,
|
|
1080
|
+
role: role,
|
|
1081
|
+
"aria-label": label,
|
|
1082
|
+
"aria-labelledby": this.currentPageAriaLabel,
|
|
1083
|
+
...getTriggerProps({
|
|
1084
|
+
id: this._id,
|
|
1085
|
+
// We need to override these aria attributes added by Selectable,
|
|
1086
|
+
// since Drilldown is not a combobox and has no popup
|
|
1087
|
+
'aria-haspopup': false,
|
|
1088
|
+
'aria-expanded': void 0,
|
|
1089
|
+
onKeyDown: this.handleKeyDown,
|
|
1090
|
+
onBlur: event => {
|
|
1091
|
+
const target = event.currentTarget;
|
|
1092
|
+
const related = event.relatedTarget;
|
|
1093
|
+
const containsRelated = (0, _contains.contains)(target, related);
|
|
1094
|
+
if (!related || related === this._drilldownRef || related !== target && !containsRelated) {
|
|
1095
|
+
this.setState({
|
|
1096
|
+
highlightedOptionId: void 0
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
1100
|
+
onMouseLeave: () => {
|
|
1101
|
+
this.setState({
|
|
1102
|
+
highlightedOptionId: void 0
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
}),
|
|
1106
|
+
children: (0, _jsxRuntime.jsx)(_View.View, {
|
|
1107
|
+
as: "div",
|
|
1108
|
+
overflowY: overflowY,
|
|
1109
|
+
overflowX: overflowX,
|
|
1110
|
+
height: height,
|
|
1111
|
+
width: width,
|
|
1112
|
+
minHeight: minHeight,
|
|
1113
|
+
minWidth: minWidth,
|
|
1114
|
+
maxHeight: maxHeight,
|
|
1115
|
+
maxWidth: maxWidth,
|
|
1116
|
+
css: styles === null || styles === void 0 ? void 0 : styles.container,
|
|
1117
|
+
borderRadius: "small",
|
|
1118
|
+
role: "presentation",
|
|
1119
|
+
elementRef: element => {
|
|
1120
|
+
this._containerElement = element;
|
|
1121
|
+
},
|
|
1122
|
+
children: (0, _jsxRuntime.jsx)(_Options.Options, {
|
|
1123
|
+
...getListProps(),
|
|
1124
|
+
role: "presentation",
|
|
1125
|
+
as: as,
|
|
1126
|
+
children: this.renderList(getOptionProps, getDisabledOptionProps)
|
|
1127
|
+
})
|
|
1128
|
+
})
|
|
1129
|
+
})
|
|
1130
|
+
});
|
|
1115
1131
|
}
|
|
1116
1132
|
render() {
|
|
1117
1133
|
// clear temporary option store
|
|
@@ -1135,7 +1151,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
1135
1151
|
onMouseOver = _this$props6.onMouseOver,
|
|
1136
1152
|
offsetX = _this$props6.offsetX,
|
|
1137
1153
|
offsetY = _this$props6.offsetY;
|
|
1138
|
-
return trigger ? (0,
|
|
1154
|
+
return trigger ? (0, _jsxRuntime.jsx)(_Popover.Popover, {
|
|
1139
1155
|
isShowingContent: show,
|
|
1140
1156
|
defaultIsShowingContent: defaultShow,
|
|
1141
1157
|
shouldCloseOnDocumentClick: true,
|
|
@@ -1182,8 +1198,9 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
1182
1198
|
id: this._triggerId,
|
|
1183
1199
|
disabled: !!(trigger.props.disabled || disabled),
|
|
1184
1200
|
'aria-disabled': trigger.props.disabled || disabled ? 'true' : void 0
|
|
1185
|
-
})
|
|
1186
|
-
|
|
1201
|
+
}),
|
|
1202
|
+
children: this.renderPage()
|
|
1203
|
+
}) : this.renderPage();
|
|
1187
1204
|
}
|
|
1188
1205
|
}, _Drilldown.displayName = "Drilldown", _Drilldown.componentId = 'Drilldown', _Drilldown.propTypes = _props.propTypes, _Drilldown.allowedProps = _props.allowedProps, _Drilldown.defaultProps = {
|
|
1189
1206
|
disabled: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-drilldown",
|
|
3
|
-
"version": "10.16.1
|
|
3
|
+
"version": "10.16.1",
|
|
4
4
|
"description": "A drilldown menu component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,29 +24,29 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/console": "10.16.1
|
|
28
|
-
"@instructure/emotion": "10.16.1
|
|
29
|
-
"@instructure/shared-types": "10.16.1
|
|
30
|
-
"@instructure/ui-dom-utils": "10.16.1
|
|
31
|
-
"@instructure/ui-icons": "10.16.1
|
|
32
|
-
"@instructure/ui-options": "10.16.1
|
|
33
|
-
"@instructure/ui-popover": "10.16.1
|
|
34
|
-
"@instructure/ui-position": "10.16.1
|
|
35
|
-
"@instructure/ui-prop-types": "10.16.1
|
|
36
|
-
"@instructure/ui-react-utils": "10.16.1
|
|
37
|
-
"@instructure/ui-selectable": "10.16.1
|
|
38
|
-
"@instructure/ui-testable": "10.16.1
|
|
39
|
-
"@instructure/ui-utils": "10.16.1
|
|
40
|
-
"@instructure/ui-view": "10.16.1
|
|
27
|
+
"@instructure/console": "10.16.1",
|
|
28
|
+
"@instructure/emotion": "10.16.1",
|
|
29
|
+
"@instructure/shared-types": "10.16.1",
|
|
30
|
+
"@instructure/ui-dom-utils": "10.16.1",
|
|
31
|
+
"@instructure/ui-icons": "10.16.1",
|
|
32
|
+
"@instructure/ui-options": "10.16.1",
|
|
33
|
+
"@instructure/ui-popover": "10.16.1",
|
|
34
|
+
"@instructure/ui-position": "10.16.1",
|
|
35
|
+
"@instructure/ui-prop-types": "10.16.1",
|
|
36
|
+
"@instructure/ui-react-utils": "10.16.1",
|
|
37
|
+
"@instructure/ui-selectable": "10.16.1",
|
|
38
|
+
"@instructure/ui-testable": "10.16.1",
|
|
39
|
+
"@instructure/ui-utils": "10.16.1",
|
|
40
|
+
"@instructure/ui-view": "10.16.1",
|
|
41
41
|
"prop-types": "^15.8.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@instructure/ui-axe-check": "10.16.1
|
|
45
|
-
"@instructure/ui-babel-preset": "10.16.1
|
|
46
|
-
"@instructure/ui-color-utils": "10.16.1
|
|
47
|
-
"@instructure/ui-scripts": "10.16.1
|
|
48
|
-
"@instructure/ui-test-utils": "10.16.1
|
|
49
|
-
"@instructure/ui-themes": "10.16.1
|
|
44
|
+
"@instructure/ui-axe-check": "10.16.1",
|
|
45
|
+
"@instructure/ui-babel-preset": "10.16.1",
|
|
46
|
+
"@instructure/ui-color-utils": "10.16.1",
|
|
47
|
+
"@instructure/ui-scripts": "10.16.1",
|
|
48
|
+
"@instructure/ui-test-utils": "10.16.1",
|
|
49
|
+
"@instructure/ui-themes": "10.16.1",
|
|
50
50
|
"@testing-library/jest-dom": "^6.6.3",
|
|
51
51
|
"@testing-library/react": "^16.0.1",
|
|
52
52
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
import { render, screen, waitFor } from '@testing-library/react'
|
|
26
26
|
import { vi } from 'vitest'
|
|
27
27
|
import userEvent from '@testing-library/user-event'
|
package/src/Drilldown/index.tsx
CHANGED
|
@@ -22,9 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
/** @jsxFrag React.Fragment */
|
|
27
|
-
import React, { Component, ReactElement, ReactNode } from 'react'
|
|
25
|
+
import { Children, Component, ReactElement, ReactNode } from 'react'
|
|
28
26
|
|
|
29
27
|
import { warn, error } from '@instructure/console'
|
|
30
28
|
import { testable } from '@instructure/ui-testable'
|
|
@@ -53,7 +51,7 @@ import {
|
|
|
53
51
|
IconCheckSolid
|
|
54
52
|
} from '@instructure/ui-icons'
|
|
55
53
|
|
|
56
|
-
import { withStyle
|
|
54
|
+
import { withStyle } from '@instructure/emotion'
|
|
57
55
|
|
|
58
56
|
import { DrilldownSeparator } from './DrilldownSeparator'
|
|
59
57
|
import { DrilldownOption } from './DrilldownOption'
|
|
@@ -260,7 +258,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
260
258
|
|
|
261
259
|
get pages(): PageChild[] {
|
|
262
260
|
const { children } = this.props
|
|
263
|
-
return
|
|
261
|
+
return Children.toArray(children || []) as PageChild[]
|
|
264
262
|
}
|
|
265
263
|
|
|
266
264
|
get pageMap(): PageMap | undefined {
|
|
@@ -278,7 +276,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
278
276
|
|
|
279
277
|
map[props.id] = {
|
|
280
278
|
...props,
|
|
281
|
-
children:
|
|
279
|
+
children: Children.toArray(children || []) as PageChildren[]
|
|
282
280
|
}
|
|
283
281
|
})
|
|
284
282
|
|