@semcore/dropdown-menu 16.2.2-prerelease.4 → 17.0.0-prerelease.17
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 +6 -0
- package/lib/cjs/DropdownMenu.js +394 -467
- package/lib/cjs/DropdownMenu.js.map +1 -1
- package/lib/cjs/components/Context.js +8 -8
- package/lib/cjs/components/Context.js.map +1 -1
- package/lib/cjs/components/VirtualList.js +98 -115
- package/lib/cjs/components/VirtualList.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/cjs/style/dropdown-menu.shadow.css +1 -1
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/DropdownMenu.js +378 -455
- package/lib/es6/DropdownMenu.js.map +1 -1
- package/lib/es6/components/Context.js +6 -7
- package/lib/es6/components/Context.js.map +1 -1
- package/lib/es6/components/VirtualList.js +95 -112
- package/lib/es6/components/VirtualList.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/dropdown-menu.shadow.css +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/DropdownMenu.mjs +363 -374
- package/lib/esm/components/Context.mjs +6 -7
- package/lib/esm/components/VirtualList.mjs +97 -99
- package/lib/esm/style/dropdown-menu.shadow.css +1 -1
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/types/index.d.ts +3 -79
- package/package.json +11 -13
package/lib/cjs/DropdownMenu.js
CHANGED
|
@@ -1,68 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports
|
|
9
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
8
|
+
exports.default = void 0;
|
|
11
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
16
|
-
var _superPropGet2 = _interopRequireDefault(require("@babel/runtime/helpers/superPropGet"));
|
|
17
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
18
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
11
|
var _core = require("@semcore/core");
|
|
12
|
+
var _baseComponents = require("@semcore/base-components");
|
|
20
13
|
var _button = _interopRequireDefault(require("@semcore/button"));
|
|
21
|
-
var
|
|
14
|
+
var _assignProps1 = require("@semcore/core/lib/utils/assignProps");
|
|
22
15
|
var _findComponent = require("@semcore/core/lib/utils/findComponent");
|
|
23
16
|
var _isFocusInside = require("@semcore/core/lib/utils/focus-lock/isFocusInside");
|
|
24
17
|
var _setFocus = require("@semcore/core/lib/utils/focus-lock/setFocus");
|
|
25
|
-
var
|
|
18
|
+
var _ref16 = require("@semcore/core/lib/utils/ref");
|
|
26
19
|
var _uniqueID = require("@semcore/core/lib/utils/uniqueID");
|
|
27
20
|
var _dropdown = _interopRequireWildcard(require("@semcore/dropdown"));
|
|
28
|
-
var _flexBox = require("@semcore/flex-box");
|
|
29
|
-
var _scrollArea = _interopRequireDefault(require("@semcore/scroll-area"));
|
|
30
21
|
var _typography = require("@semcore/typography");
|
|
31
22
|
var _react = _interopRequireDefault(require("react"));
|
|
32
23
|
var _Context = require("./components/Context");
|
|
33
24
|
var _VirtualList = require("./components/VirtualList");
|
|
34
25
|
var _intergalacticDynamicLocales = require("./translations/__intergalactic-dynamic-locales");
|
|
35
26
|
/*!__reshadow-styles__:"./style/dropdown-menu.shadow.css"*/
|
|
36
|
-
|
|
27
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SDropdownMenuList_1r615_gg_{max-height:240px;padding:var(--intergalactic-spacing-1x, 4px)0;position:relative;min-height:26px;min-width:32px;box-sizing:content-box;z-index:0;color:var(--intergalactic-text-primary, #191b23)}.___SDropdownMenuList_1r615_gg_ .___SBar_1r615_gg_{z-index:3}.___SDropdownMenuList_1r615_gg_ .___SShadowHorizontal_1r615_gg_:after,.___SDropdownMenuList_1r615_gg_ .___SShadowHorizontal_1r615_gg_:before,.___SDropdownMenuList_1r615_gg_ .___SShadowVertical_1r615_gg_:after,.___SDropdownMenuList_1r615_gg_ .___SShadowVertical_1r615_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1r615_gg_ .___SItemContent_1r615_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1r615_gg_.__nesting-trigger_1r615_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1r615_gg_,.___SItemContentText_1r615_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1r615_gg_:first-child,.___SItemContentText_1r615_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1r615_gg_:last-child,.___SItemContentText_1r615_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1r615_gg_,.___SDropdownMenuNesting_1r615_gg_._size_l_1r615_gg_,.___SDropdownMenuNesting_1r615_gg_._size_m_1r615_gg_{padding:0}.___SDropdownMenuNesting_1r615_gg_.__highlighted_1r615_gg_{z-index:1;outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:-2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}.___SDropdownNestingItem_1r615_gg_._size_l_1r615_gg_,.___SDropdownNestingItem_1r615_gg_._size_m_1r615_gg_{padding-right:0}.___SDropdownNestingItem_1r615_gg_ .___SDropdownMenuItemContainer_1r615_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1r615_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}", /*__inner_css_end__*/"1r615_gg_"),
|
|
37
28
|
/*__reshadow_css_end__*/
|
|
38
29
|
{
|
|
39
|
-
"__SDropdownMenuItemContainer": "
|
|
40
|
-
"_nesting-trigger": "__nesting-
|
|
41
|
-
"__SDropdownMenuNesting": "
|
|
42
|
-
"_size_l": "
|
|
43
|
-
"_size_m": "
|
|
44
|
-
"_highlighted": "
|
|
45
|
-
"__SDropdownNestingItem": "
|
|
46
|
-
"__SItemHint": "
|
|
47
|
-
"__SDropdownMenuList": "
|
|
48
|
-
"__SBar": "
|
|
49
|
-
"__SShadowHorizontal": "
|
|
50
|
-
"__SShadowVertical": "
|
|
51
|
-
"__SItemContent": "
|
|
52
|
-
"__SDropdownMenuItemAddon": "
|
|
53
|
-
"__SItemContentText": "
|
|
30
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1r615_gg_",
|
|
31
|
+
"_nesting-trigger": "__nesting-trigger_1r615_gg_",
|
|
32
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1r615_gg_",
|
|
33
|
+
"_size_l": "_size_l_1r615_gg_",
|
|
34
|
+
"_size_m": "_size_m_1r615_gg_",
|
|
35
|
+
"_highlighted": "__highlighted_1r615_gg_",
|
|
36
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1r615_gg_",
|
|
37
|
+
"__SItemHint": "___SItemHint_1r615_gg_",
|
|
38
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1r615_gg_",
|
|
39
|
+
"__SBar": "___SBar_1r615_gg_",
|
|
40
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1r615_gg_",
|
|
41
|
+
"__SShadowVertical": "___SShadowVertical_1r615_gg_",
|
|
42
|
+
"__SItemContent": "___SItemContent_1r615_gg_",
|
|
43
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1r615_gg_",
|
|
44
|
+
"__SItemContentText": "___SItemContentText_1r615_gg_"
|
|
54
45
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(0,
|
|
60
|
-
|
|
61
|
-
args[_key] = arguments[_key];
|
|
62
|
-
}
|
|
63
|
-
_this = (0, _callSuper2["default"])(this, DropdownMenuRoot, [].concat(args));
|
|
64
|
-
(0, _defineProperty2["default"])(_this, "actionsRef", /*#__PURE__*/_react["default"].createRef());
|
|
65
|
-
(0, _defineProperty2["default"])(_this, "role", 'menu');
|
|
46
|
+
const menuItemContext = /*#__PURE__*/_react.default.createContext({});
|
|
47
|
+
class DropdownMenuRoot extends _dropdown.AbstractDropdown {
|
|
48
|
+
constructor(...args) {
|
|
49
|
+
super(...args);
|
|
50
|
+
(0, _defineProperty2.default)(this, "actionsRef", /*#__PURE__*/_react.default.createRef());
|
|
51
|
+
(0, _defineProperty2.default)(this, "role", 'menu');
|
|
66
52
|
/**
|
|
67
53
|
* TODO: It needs to be reconsidered in a future implementation so that component accepts items as a prop instead of JSX.
|
|
68
54
|
* Tab index recalculation flag.
|
|
@@ -71,261 +57,231 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
71
57
|
* to the next available focusable item. This flag ensures the focus lock
|
|
72
58
|
* remains within proper boundaries during the initial render cycle.
|
|
73
59
|
*/
|
|
74
|
-
(0, _defineProperty2
|
|
75
|
-
return _this;
|
|
60
|
+
(0, _defineProperty2.default)(this, "shouldRecalculateItemTabIndex", false);
|
|
76
61
|
}
|
|
77
|
-
(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}, {
|
|
95
|
-
key: "menuElements",
|
|
96
|
-
get: function get() {
|
|
97
|
-
var menuElement = this.menuRef.current;
|
|
98
|
-
if (!menuElement) {
|
|
99
|
-
return {
|
|
100
|
-
selected: null,
|
|
101
|
-
options: null
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
var options = menuElement.querySelectorAll('[role="menuitemcheckbox"], [role="menuitemradio"]');
|
|
105
|
-
var selected = menuElement.querySelector('[aria-checked="true"]:not([disabled])');
|
|
62
|
+
uncontrolledProps() {
|
|
63
|
+
return {
|
|
64
|
+
...super.uncontrolledProps(),
|
|
65
|
+
visible: [null, visible => {
|
|
66
|
+
if (visible === true) {
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
this.focusAndScrollToSelected();
|
|
69
|
+
// for some reason, Google Chrome optimizes this timeout with 0 value with previous render (when we set aria-selected)
|
|
70
|
+
// and that's why its skip scrollToNodes. We selected the appropriate timeout manually.
|
|
71
|
+
}, 50);
|
|
72
|
+
}
|
|
73
|
+
}]
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
get menuElements() {
|
|
77
|
+
const menuElement = this.menuRef.current;
|
|
78
|
+
if (!menuElement) {
|
|
106
79
|
return {
|
|
107
|
-
selected:
|
|
108
|
-
options:
|
|
80
|
+
selected: null,
|
|
81
|
+
options: null
|
|
109
82
|
};
|
|
110
83
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.handlers.highlightedIndex(selectedIndex);
|
|
84
|
+
const options = menuElement.querySelectorAll('[role="menuitemcheckbox"], [role="menuitemradio"]');
|
|
85
|
+
const selected = menuElement.querySelector('[aria-checked="true"]:not([disabled])');
|
|
86
|
+
return {
|
|
87
|
+
selected,
|
|
88
|
+
options
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
focusAndScrollToSelected() {
|
|
92
|
+
let {
|
|
93
|
+
selected,
|
|
94
|
+
options
|
|
95
|
+
} = this.menuElements;
|
|
96
|
+
const isFocusAlreadyInPopper = (0, _isFocusInside.isFocusInside)(this.popperRef.current);
|
|
97
|
+
if (!selected || !options || this.menuRef.current?.dataset.isVirtual || isFocusAlreadyInPopper) return;
|
|
98
|
+
this.scrollToNodeAsync(selected, true).then(() => {
|
|
99
|
+
if (this.asProps.visible) {
|
|
100
|
+
selected.focus({
|
|
101
|
+
preventScroll: true
|
|
102
|
+
});
|
|
131
103
|
}
|
|
104
|
+
});
|
|
105
|
+
const selectedIndex = Array.from(options).indexOf(selected);
|
|
106
|
+
if (selectedIndex !== -1) {
|
|
107
|
+
this.handlers.highlightedIndex(selectedIndex);
|
|
132
108
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
(0, _superPropGet2["default"])(DropdownMenuRoot, "itemRef", this, 3)([props, index, node]);
|
|
147
|
-
if (node === document.activeElement) {
|
|
148
|
-
(0, _superPropGet2["default"])(DropdownMenuRoot, "scrollToNode", this, 3)([node]);
|
|
149
|
-
}
|
|
109
|
+
}
|
|
110
|
+
afterOpenPopper() {
|
|
111
|
+
const {
|
|
112
|
+
selected,
|
|
113
|
+
options
|
|
114
|
+
} = this.menuElements;
|
|
115
|
+
if (selected && options && !this.menuRef.current?.dataset.isVirtual) return;
|
|
116
|
+
super.afterOpenPopper();
|
|
117
|
+
}
|
|
118
|
+
itemRef(props, index, node) {
|
|
119
|
+
super.itemRef(props, index, node);
|
|
120
|
+
if (node === document.activeElement) {
|
|
121
|
+
super.scrollToNode(node);
|
|
150
122
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
123
|
+
}
|
|
124
|
+
getTriggerProps() {
|
|
125
|
+
const {
|
|
126
|
+
Children,
|
|
127
|
+
uid,
|
|
128
|
+
visible
|
|
129
|
+
} = this.asProps;
|
|
130
|
+
const hasMenu = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.Menu.displayName]);
|
|
131
|
+
const ariaControls = hasMenu ? `igc-${uid}-list` : `igc-${uid}-popper`;
|
|
132
|
+
return {
|
|
133
|
+
...super.getTriggerProps(),
|
|
134
|
+
'onKeyDown': (0, _assignProps1.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleKeyDownForMenu('trigger')),
|
|
135
|
+
'aria-controls': visible ? ariaControls : undefined,
|
|
136
|
+
'aria-haspopup': hasMenu ? 'true' : 'dialog'
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
getListProps() {
|
|
140
|
+
return {
|
|
141
|
+
...super.getListProps(),
|
|
142
|
+
onKeyDown: (0, _assignProps1.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
getVirtualListProps() {
|
|
146
|
+
return {
|
|
147
|
+
...super.getListProps(),
|
|
148
|
+
onKeyDown: (0, _assignProps1.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
getPopperProps() {
|
|
152
|
+
return {
|
|
153
|
+
...super.getPopperProps(),
|
|
154
|
+
onKeyDown: (0, _assignProps1.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this))
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
getActionsProps() {
|
|
158
|
+
return {
|
|
159
|
+
...this.getListProps(),
|
|
160
|
+
ref: this.actionsRef,
|
|
161
|
+
onKeyDown: (0, _assignProps1.callAllEventHandlers)(this.handlePreventTabOnActions.bind(this), this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
getItemTabIndex(props, itemIndex) {
|
|
165
|
+
const {
|
|
166
|
+
disabled,
|
|
167
|
+
index
|
|
168
|
+
} = props;
|
|
169
|
+
const {
|
|
170
|
+
highlightedIndex,
|
|
171
|
+
visible
|
|
172
|
+
} = this.asProps;
|
|
173
|
+
if (!visible) return -1;
|
|
174
|
+
const isHighlighted = (index ?? itemIndex) === highlightedIndex;
|
|
175
|
+
if (isHighlighted && !disabled) {
|
|
176
|
+
return 0;
|
|
165
177
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
value: function getListProps() {
|
|
169
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _superPropGet2["default"])(DropdownMenuRoot, "getListProps", this, 3)([])), {}, {
|
|
170
|
-
onKeyDown: (0, _assignProps13.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
171
|
-
});
|
|
178
|
+
if (disabled && isHighlighted) {
|
|
179
|
+
this.shouldRecalculateItemTabIndex = true;
|
|
172
180
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _superPropGet2["default"])(DropdownMenuRoot, "getListProps", this, 3)([])), {}, {
|
|
177
|
-
onKeyDown: (0, _assignProps13.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
178
|
-
});
|
|
181
|
+
if (!isHighlighted && !disabled && this.shouldRecalculateItemTabIndex) {
|
|
182
|
+
this.shouldRecalculateItemTabIndex = false;
|
|
183
|
+
return 0;
|
|
179
184
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
return -1;
|
|
186
|
+
}
|
|
187
|
+
getItemProps(props, index) {
|
|
188
|
+
const realIndex = props.index ?? index;
|
|
189
|
+
const itemProps = {
|
|
190
|
+
...super.getItemProps(props, realIndex),
|
|
191
|
+
tabIndex: this.getItemTabIndex(props, index),
|
|
192
|
+
ref: node => this.itemRef(props, realIndex, node),
|
|
193
|
+
actionsRef: this.actionsRef
|
|
194
|
+
};
|
|
195
|
+
if (props.tag === _button.default) {
|
|
196
|
+
itemProps.use = props.use ?? 'tertiary';
|
|
197
|
+
itemProps.theme = props.theme ?? 'muted';
|
|
198
|
+
itemProps.size = props.size ?? 's';
|
|
199
|
+
itemProps.innerOutline = false;
|
|
186
200
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
value: function getActionsProps() {
|
|
190
|
-
return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, this.getListProps()), {}, {
|
|
191
|
-
ref: this.actionsRef,
|
|
192
|
-
onKeyDown: (0, _assignProps13.callAllEventHandlers)(this.handlePreventTabOnActions.bind(this), this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
193
|
-
});
|
|
201
|
+
if (props.selected) {
|
|
202
|
+
itemProps['aria-checked'] = true;
|
|
194
203
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
index = props.index;
|
|
200
|
-
var _this$asProps2 = this.asProps,
|
|
201
|
-
highlightedIndex = _this$asProps2.highlightedIndex,
|
|
202
|
-
visible = _this$asProps2.visible;
|
|
203
|
-
if (!visible) return -1;
|
|
204
|
-
var isHighlighted = (index !== null && index !== void 0 ? index : itemIndex) === highlightedIndex;
|
|
205
|
-
if (isHighlighted && !disabled) {
|
|
206
|
-
return 0;
|
|
207
|
-
}
|
|
208
|
-
if (disabled && isHighlighted) {
|
|
209
|
-
this.shouldRecalculateItemTabIndex = true;
|
|
210
|
-
}
|
|
211
|
-
if (!isHighlighted && !disabled && this.shouldRecalculateItemTabIndex) {
|
|
212
|
-
this.shouldRecalculateItemTabIndex = false;
|
|
213
|
-
return 0;
|
|
214
|
-
}
|
|
215
|
-
return -1;
|
|
204
|
+
if (super.childRole === 'menuitemradio') {
|
|
205
|
+
itemProps.onClick = () => {
|
|
206
|
+
this.handlers.visible(false);
|
|
207
|
+
};
|
|
216
208
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
var _props$use, _props$theme, _props$size;
|
|
232
|
-
itemProps.use = (_props$use = props.use) !== null && _props$use !== void 0 ? _props$use : 'tertiary';
|
|
233
|
-
itemProps.theme = (_props$theme = props.theme) !== null && _props$theme !== void 0 ? _props$theme : 'muted';
|
|
234
|
-
itemProps.size = (_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : 's';
|
|
235
|
-
itemProps.innerOutline = false;
|
|
236
|
-
}
|
|
237
|
-
if (props.selected) {
|
|
238
|
-
itemProps['aria-checked'] = true;
|
|
209
|
+
return itemProps;
|
|
210
|
+
}
|
|
211
|
+
handleKeyDownForMenu(place) {
|
|
212
|
+
return e => {
|
|
213
|
+
const {
|
|
214
|
+
visible,
|
|
215
|
+
placement,
|
|
216
|
+
inlineActions
|
|
217
|
+
} = this.asProps;
|
|
218
|
+
|
|
219
|
+
// stop propagation keyboard events if it calls not on DropdownMenu.Items
|
|
220
|
+
if (place === 'list' && !this.menuRef.current?.contains(e.target) && !inlineActions) {
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
return false;
|
|
239
223
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
224
|
+
const show = e.key === 'ArrowRight' && placement?.startsWith('right') || e.key === 'ArrowLeft' && placement?.startsWith('left') || (e.key === 'Enter' || e.key === ' ') && !inlineActions;
|
|
225
|
+
const hide = e.key === 'ArrowLeft' && placement?.startsWith('right') || e.key === 'ArrowRight' && placement?.startsWith('left') || e.key === 'Escape';
|
|
226
|
+
const isMenuItem = e.target.getAttribute('role')?.startsWith(super.childRole);
|
|
227
|
+
if (place === 'trigger' && show && isMenuItem) {
|
|
228
|
+
this.handlers.visible(true);
|
|
229
|
+
this.handlers.highlightedIndex(0);
|
|
230
|
+
setTimeout(() => {
|
|
231
|
+
let {
|
|
232
|
+
highlightedIndex
|
|
233
|
+
} = this.asProps;
|
|
234
|
+
const highlightedIndexProps = this.itemProps[highlightedIndex];
|
|
235
|
+
if (highlightedIndexProps?.disabled) {
|
|
236
|
+
highlightedIndex = this.itemProps.findIndex(p => !p.disabled);
|
|
237
|
+
}
|
|
238
|
+
if (highlightedIndex === -1) return;
|
|
239
|
+
this.itemRefs[highlightedIndex]?.focus();
|
|
240
|
+
}, 0);
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
e.stopPropagation();
|
|
243
|
+
return false;
|
|
244
244
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return function (e) {
|
|
252
|
-
var _this5$menuRef$curren, _e$target$getAttribut;
|
|
253
|
-
var _this5$asProps = _this5.asProps,
|
|
254
|
-
visible = _this5$asProps.visible,
|
|
255
|
-
placement = _this5$asProps.placement,
|
|
256
|
-
inlineActions = _this5$asProps.inlineActions;
|
|
257
|
-
|
|
258
|
-
// stop propagation keyboard events if it calls not on DropdownMenu.Items
|
|
259
|
-
if (place === 'list' && !((_this5$menuRef$curren = _this5.menuRef.current) !== null && _this5$menuRef$curren !== void 0 && _this5$menuRef$curren.contains(e.target)) && !inlineActions) {
|
|
260
|
-
e.stopPropagation();
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
var show = e.key === 'ArrowRight' && (placement === null || placement === void 0 ? void 0 : placement.startsWith('right')) || e.key === 'ArrowLeft' && (placement === null || placement === void 0 ? void 0 : placement.startsWith('left')) || (e.key === 'Enter' || e.key === ' ') && !inlineActions;
|
|
264
|
-
var hide = e.key === 'ArrowLeft' && (placement === null || placement === void 0 ? void 0 : placement.startsWith('right')) || e.key === 'ArrowRight' && (placement === null || placement === void 0 ? void 0 : placement.startsWith('left')) || e.key === 'Escape';
|
|
265
|
-
var isMenuItem = (_e$target$getAttribut = e.target.getAttribute('role')) === null || _e$target$getAttribut === void 0 ? void 0 : _e$target$getAttribut.startsWith((0, _superPropGet2["default"])(DropdownMenuRoot, "childRole", _this5, 1));
|
|
266
|
-
if (place === 'trigger' && show && isMenuItem) {
|
|
267
|
-
_this5.handlers.visible(true);
|
|
268
|
-
_this5.handlers.highlightedIndex(0);
|
|
269
|
-
setTimeout(function () {
|
|
270
|
-
var _this5$itemRefs$highl;
|
|
271
|
-
var highlightedIndex = _this5.asProps.highlightedIndex;
|
|
272
|
-
var highlightedIndexProps = _this5.itemProps[highlightedIndex];
|
|
273
|
-
if (highlightedIndexProps !== null && highlightedIndexProps !== void 0 && highlightedIndexProps.disabled) {
|
|
274
|
-
highlightedIndex = _this5.itemProps.findIndex(function (p) {
|
|
275
|
-
return !p.disabled;
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
if (highlightedIndex === -1) return;
|
|
279
|
-
(_this5$itemRefs$highl = _this5.itemRefs[highlightedIndex]) === null || _this5$itemRefs$highl === void 0 || _this5$itemRefs$highl.focus();
|
|
280
|
-
}, 0);
|
|
245
|
+
if (place === 'list' && visible && hide && isMenuItem) {
|
|
246
|
+
if (!inlineActions || inlineActions && (e.key === 'Escape' || this.asProps.highlightedIndex === 0)) {
|
|
247
|
+
this.handlers.visible(false);
|
|
248
|
+
if (this.triggerRef.current) {
|
|
249
|
+
(0, _setFocus.setFocus)(this.triggerRef.current);
|
|
250
|
+
}
|
|
281
251
|
e.preventDefault();
|
|
282
252
|
e.stopPropagation();
|
|
283
253
|
return false;
|
|
284
254
|
}
|
|
285
|
-
if (place === 'list' && visible && hide && isMenuItem) {
|
|
286
|
-
if (!inlineActions || inlineActions && (e.key === 'Escape' || _this5.asProps.highlightedIndex === 0)) {
|
|
287
|
-
_this5.handlers.visible(false);
|
|
288
|
-
if (_this5.triggerRef.current) {
|
|
289
|
-
(0, _setFocus.setFocus)(_this5.triggerRef.current);
|
|
290
|
-
}
|
|
291
|
-
e.preventDefault();
|
|
292
|
-
e.stopPropagation();
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
}, {
|
|
299
|
-
key: "handlePreventTabOnActions",
|
|
300
|
-
value: function handlePreventTabOnActions(e) {
|
|
301
|
-
if (e.key === 'Tab') {
|
|
302
|
-
e.stopPropagation();
|
|
303
|
-
e.preventDefault();
|
|
304
|
-
return false;
|
|
305
255
|
}
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
handlePreventTabOnActions(e) {
|
|
259
|
+
if (e.key === 'Tab') {
|
|
260
|
+
e.stopPropagation();
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
return false;
|
|
306
263
|
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
(0, _defineProperty2
|
|
326
|
-
(0, _defineProperty2
|
|
327
|
-
(0, _defineProperty2
|
|
328
|
-
(0, _defineProperty2["default"])(DropdownMenuRoot, "defaultProps", {
|
|
264
|
+
}
|
|
265
|
+
render() {
|
|
266
|
+
var _ref = this.asProps;
|
|
267
|
+
const {
|
|
268
|
+
Children,
|
|
269
|
+
selectedIndex,
|
|
270
|
+
interaction,
|
|
271
|
+
timeout
|
|
272
|
+
} = this.asProps;
|
|
273
|
+
this.itemProps = [];
|
|
274
|
+
return /*#__PURE__*/_react.default.createElement(_dropdown.selectedIndexContext.Provider, {
|
|
275
|
+
value: selectedIndex
|
|
276
|
+
}, /*#__PURE__*/_react.default.createElement(_dropdown.default, (0, _core.assignProps)({
|
|
277
|
+
"timeout": timeout || (interaction === 'hover' ? [0, 100] : undefined)
|
|
278
|
+
}, _ref), /*#__PURE__*/_react.default.createElement(Children, null)));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
(0, _defineProperty2.default)(DropdownMenuRoot, "displayName", 'DropdownMenu');
|
|
282
|
+
(0, _defineProperty2.default)(DropdownMenuRoot, "style", style);
|
|
283
|
+
(0, _defineProperty2.default)(DropdownMenuRoot, "enhance", Object.values(_dropdown.enhance));
|
|
284
|
+
(0, _defineProperty2.default)(DropdownMenuRoot, "defaultProps", {
|
|
329
285
|
size: 'm',
|
|
330
286
|
defaultVisible: false,
|
|
331
287
|
defaultHighlightedIndex: 0,
|
|
@@ -337,90 +293,97 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
337
293
|
placement: 'bottom-start',
|
|
338
294
|
timeout: 0
|
|
339
295
|
});
|
|
340
|
-
(0, _defineProperty2
|
|
296
|
+
(0, _defineProperty2.default)(DropdownMenuRoot, "nestedMenuInteraction", {
|
|
341
297
|
trigger: [['onClick', 'onMouseEnter'], ['onClick', 'onMouseLeave']],
|
|
342
298
|
popper: [['onMouseEnter'], ['onMouseLeave']]
|
|
343
299
|
});
|
|
344
|
-
function List(
|
|
300
|
+
function List({
|
|
301
|
+
styles,
|
|
302
|
+
Children
|
|
303
|
+
}) {
|
|
345
304
|
var _ref2 = arguments[0],
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
305
|
+
_ref1;
|
|
306
|
+
const SDropdownMenuList = _baseComponents.ScrollArea;
|
|
307
|
+
const SBar = _baseComponents.ScrollArea.Bar;
|
|
308
|
+
return _ref1 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(_Context.ListBoxContextProvider, _ref1.cn("ListBoxContextProvider", {}), /*#__PURE__*/_react.default.createElement(SDropdownMenuList, _ref1.cn("SDropdownMenuList", {
|
|
309
|
+
...(0, _core.assignProps)({
|
|
310
|
+
"shadow": true,
|
|
311
|
+
"shadowSize": 16,
|
|
312
|
+
"shadowTheme": 'light'
|
|
313
|
+
}, _ref2)
|
|
314
|
+
}), /*#__PURE__*/_react.default.createElement(_baseComponents.ScrollArea.Container, {
|
|
356
315
|
tabIndex: undefined
|
|
357
|
-
}, /*#__PURE__*/_react
|
|
316
|
+
}, /*#__PURE__*/_react.default.createElement(Children, _ref1.cn("Children", {}))), /*#__PURE__*/_react.default.createElement(SBar, _ref1.cn("SBar", {
|
|
358
317
|
"orientation": 'horizontal'
|
|
359
|
-
})), /*#__PURE__*/_react
|
|
318
|
+
})), /*#__PURE__*/_react.default.createElement(SBar, _ref1.cn("SBar", {
|
|
360
319
|
"orientation": 'vertical'
|
|
361
320
|
}))));
|
|
362
321
|
}
|
|
363
|
-
function Actions(
|
|
322
|
+
function Actions({
|
|
323
|
+
styles
|
|
324
|
+
}) {
|
|
364
325
|
var _ref3 = arguments[0],
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
326
|
+
_ref10;
|
|
327
|
+
const SDropdownMenuActions = _baseComponents.Flex;
|
|
328
|
+
return _ref10 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SDropdownMenuActions, _ref10.cn("SDropdownMenuActions", {
|
|
329
|
+
...(0, _core.assignProps)({}, _ref3)
|
|
330
|
+
}));
|
|
369
331
|
}
|
|
370
332
|
function Menu(props) {
|
|
371
333
|
var _ref4 = arguments[0];
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
334
|
+
const {
|
|
335
|
+
visible,
|
|
336
|
+
disablePortal,
|
|
337
|
+
ignorePortalsStacking,
|
|
338
|
+
disableEnforceFocus,
|
|
339
|
+
interaction,
|
|
340
|
+
autoFocus,
|
|
341
|
+
animationsDisabled
|
|
342
|
+
} = props;
|
|
343
|
+
const popperProps = {
|
|
344
|
+
visible,
|
|
345
|
+
disablePortal,
|
|
346
|
+
ignorePortalsStacking,
|
|
347
|
+
disableEnforceFocus,
|
|
348
|
+
interaction,
|
|
349
|
+
autoFocus,
|
|
350
|
+
animationsDisabled
|
|
387
351
|
};
|
|
388
|
-
return /*#__PURE__*/_react
|
|
352
|
+
return /*#__PURE__*/_react.default.createElement(_Context.ListBoxContextProvider, null, /*#__PURE__*/_react.default.createElement(DropdownMenu.Popper, (0, _extends2.default)({}, popperProps, {
|
|
389
353
|
role: null
|
|
390
|
-
}), /*#__PURE__*/_react
|
|
354
|
+
}), /*#__PURE__*/_react.default.createElement(DropdownMenu.List, (0, _core.assignProps)({}, _ref4))));
|
|
391
355
|
}
|
|
392
|
-
function Item(
|
|
356
|
+
function Item({
|
|
357
|
+
id,
|
|
358
|
+
styles,
|
|
359
|
+
disabled,
|
|
360
|
+
Children,
|
|
361
|
+
forwardRef,
|
|
362
|
+
role,
|
|
363
|
+
tabIndex,
|
|
364
|
+
actionsRef,
|
|
365
|
+
'aria-checked': ariaChecked
|
|
366
|
+
}) {
|
|
393
367
|
var _ref5 = arguments[0],
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
forwardRef = _ref24.forwardRef,
|
|
400
|
-
role = _ref24.role,
|
|
401
|
-
tabIndex = _ref24.tabIndex,
|
|
402
|
-
actionsRef = _ref24.actionsRef,
|
|
403
|
-
ariaChecked = _ref24['aria-checked'];
|
|
404
|
-
var SDropdownMenuItemContainer = _dropdown["default"].Item;
|
|
405
|
-
var itemRef = _react["default"].useRef();
|
|
406
|
-
var _React$useState = _react["default"].useState(false),
|
|
407
|
-
_React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
|
|
408
|
-
highlighted = _React$useState2[0],
|
|
409
|
-
setHighlighted = _React$useState2[1];
|
|
410
|
-
var menuItemContextValue = {
|
|
368
|
+
_ref11;
|
|
369
|
+
const SDropdownMenuItemContainer = _dropdown.default.Item;
|
|
370
|
+
const itemRef = _react.default.useRef();
|
|
371
|
+
const [highlighted, setHighlighted] = _react.default.useState(false);
|
|
372
|
+
const menuItemContextValue = {
|
|
411
373
|
contentId: id,
|
|
412
|
-
ref:
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
374
|
+
ref: itemRef,
|
|
375
|
+
forwardRef,
|
|
376
|
+
role,
|
|
377
|
+
tabIndex,
|
|
378
|
+
ariaChecked,
|
|
379
|
+
disabled
|
|
417
380
|
};
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
381
|
+
const ariaDescribes = [];
|
|
382
|
+
const hasSubMenu = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.displayName], true);
|
|
383
|
+
const hasHint = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.Item.Hint.displayName], true);
|
|
384
|
+
const advancedMode = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.Item.Content.displayName], true) || hasSubMenu || hasHint;
|
|
422
385
|
if (hasHint) {
|
|
423
|
-
|
|
386
|
+
const hintId = `igc-${(0, _uniqueID.useUID)()}-option-hint`;
|
|
424
387
|
menuItemContextValue.hintId = hintId;
|
|
425
388
|
ariaDescribes.push(hintId);
|
|
426
389
|
}
|
|
@@ -428,8 +391,8 @@ function Item(_ref24) {
|
|
|
428
391
|
menuItemContextValue.hasSubMenu = true;
|
|
429
392
|
}
|
|
430
393
|
menuItemContextValue.ariaDescribes = ariaDescribes;
|
|
431
|
-
_react
|
|
432
|
-
|
|
394
|
+
_react.default.useEffect(() => {
|
|
395
|
+
const onFocus = e => {
|
|
433
396
|
if (e.target === itemRef.current) {
|
|
434
397
|
setHighlighted(true);
|
|
435
398
|
if (hasSubMenu) {
|
|
@@ -437,7 +400,7 @@ function Item(_ref24) {
|
|
|
437
400
|
}
|
|
438
401
|
}
|
|
439
402
|
};
|
|
440
|
-
|
|
403
|
+
const onBlur = e => {
|
|
441
404
|
if (e.target === itemRef.current) {
|
|
442
405
|
setHighlighted(false);
|
|
443
406
|
if (actionsRef.current) {
|
|
@@ -451,7 +414,7 @@ function Item(_ref24) {
|
|
|
451
414
|
document.addEventListener('blur', onBlur, {
|
|
452
415
|
capture: true
|
|
453
416
|
});
|
|
454
|
-
return
|
|
417
|
+
return () => {
|
|
455
418
|
document.removeEventListener('focus', onFocus, {
|
|
456
419
|
capture: true
|
|
457
420
|
});
|
|
@@ -459,159 +422,123 @@ function Item(_ref24) {
|
|
|
459
422
|
capture: true
|
|
460
423
|
});
|
|
461
424
|
};
|
|
462
|
-
}
|
|
463
|
-
return
|
|
425
|
+
});
|
|
426
|
+
return _ref11 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(menuItemContext.Provider, {
|
|
464
427
|
value: menuItemContextValue
|
|
465
|
-
}, /*#__PURE__*/_react
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
428
|
+
}, /*#__PURE__*/_react.default.createElement(SDropdownMenuItemContainer, _ref11.cn("SDropdownMenuItemContainer", {
|
|
429
|
+
...(0, _core.assignProps)({
|
|
430
|
+
"ref": advancedMode ? undefined : (0, _ref16.forkRef)(itemRef, forwardRef),
|
|
431
|
+
"use:highlighted": !disabled && highlighted && _core.lastInteraction.isKeyboard(),
|
|
432
|
+
"use:role": advancedMode ? undefined : role,
|
|
433
|
+
"use:id": advancedMode ? undefined : id,
|
|
434
|
+
"use:tabIndex": advancedMode ? undefined : tabIndex,
|
|
435
|
+
"use:aria-checked": advancedMode ? undefined : ariaChecked
|
|
436
|
+
}, _ref5)
|
|
437
|
+
}), /*#__PURE__*/_react.default.createElement(Children, _ref11.cn("Children", {}))));
|
|
473
438
|
}
|
|
474
439
|
function Addon(props) {
|
|
475
440
|
var _ref6 = arguments[0],
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
return
|
|
441
|
+
_ref12;
|
|
442
|
+
const SDropdownMenuItemAddon = _baseComponents.Box;
|
|
443
|
+
return _ref12 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react.default.createElement(SDropdownMenuItemAddon, _ref12.cn("SDropdownMenuItemAddon", {
|
|
444
|
+
...(0, _core.assignProps)({}, _ref6)
|
|
445
|
+
}));
|
|
479
446
|
}
|
|
480
447
|
function Trigger() {
|
|
481
448
|
var _ref7 = arguments[0];
|
|
482
|
-
return /*#__PURE__*/_react
|
|
449
|
+
return /*#__PURE__*/_react.default.createElement(_dropdown.default.Trigger, (0, _core.assignProps)({}, _ref7));
|
|
483
450
|
}
|
|
484
|
-
function ItemContent(
|
|
451
|
+
function ItemContent({
|
|
452
|
+
styles
|
|
453
|
+
}) {
|
|
485
454
|
var _ref8 = arguments[0],
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
var subMenu = undefined;
|
|
455
|
+
_ref13;
|
|
456
|
+
const SItemContent = _baseComponents.Flex;
|
|
457
|
+
const ref = _react.default.useRef();
|
|
458
|
+
const menuItemCtxValue = _react.default.useContext(menuItemContext);
|
|
459
|
+
let subMenu = undefined;
|
|
492
460
|
if (menuItemCtxValue.hasSubMenu) {
|
|
493
461
|
subMenu = 'true';
|
|
494
462
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
_react["default"].useEffect(function () {
|
|
500
|
-
var element = ref.current;
|
|
501
|
-
var parent = element === null || element === void 0 ? void 0 : element.parentElement;
|
|
463
|
+
const [describedby, setDescribedby] = _react.default.useState(new Set(menuItemCtxValue.ariaDescribes));
|
|
464
|
+
_react.default.useEffect(() => {
|
|
465
|
+
const element = ref.current;
|
|
466
|
+
const parent = element?.parentElement;
|
|
502
467
|
if (parent.getAttribute('aria-haspopup') === 'true' && parent.getAttribute('aria-describedby')) {
|
|
503
|
-
setDescribedby(
|
|
468
|
+
setDescribedby(prev => {
|
|
504
469
|
prev.add(parent.getAttribute('aria-describedby'));
|
|
505
470
|
return new Set(prev);
|
|
506
471
|
});
|
|
507
472
|
}
|
|
508
473
|
}, [menuItemCtxValue.ariaDescribes]);
|
|
509
|
-
return
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
474
|
+
return _ref13 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SItemContent, _ref13.cn("SItemContent", {
|
|
475
|
+
...(0, _core.assignProps)({
|
|
476
|
+
"role": menuItemCtxValue.role,
|
|
477
|
+
"id": menuItemCtxValue.contentId,
|
|
478
|
+
"tabIndex": menuItemCtxValue.tabIndex,
|
|
479
|
+
"ref": (0, _ref16.forkRef)(menuItemCtxValue.ref, menuItemCtxValue.forwardRef, ref),
|
|
480
|
+
"use:aria-describedby": [...describedby].join(' '),
|
|
481
|
+
"aria-haspopup": menuItemCtxValue.hasSubMenu ? 'true' : undefined,
|
|
482
|
+
"aria-expanded": subMenu,
|
|
483
|
+
"aria-checked": menuItemCtxValue.ariaChecked,
|
|
484
|
+
"alignItems": 'center',
|
|
485
|
+
"justifyContent": menuItemCtxValue.hasSubMenu ? 'space-between' : undefined,
|
|
486
|
+
"disabled": menuItemCtxValue.disabled
|
|
487
|
+
}, _ref8)
|
|
488
|
+
}));
|
|
522
489
|
}
|
|
523
|
-
function ItemContentText(
|
|
490
|
+
function ItemContentText({
|
|
491
|
+
styles,
|
|
492
|
+
ellipsis = false,
|
|
493
|
+
hintProps = {}
|
|
494
|
+
}) {
|
|
524
495
|
var _ref9 = arguments[0],
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
496
|
+
_ref14;
|
|
497
|
+
const SItemContentText = _typography.Text;
|
|
498
|
+
const menuItemCtxValue = _react.default.useContext(menuItemContext);
|
|
499
|
+
if (menuItemCtxValue.ref) {
|
|
500
|
+
hintProps.triggerRef = menuItemCtxValue.ref;
|
|
501
|
+
}
|
|
502
|
+
return _ref14 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(SItemContentText, _ref14.cn("SItemContentText", {
|
|
503
|
+
...(0, _core.assignProps)({
|
|
504
|
+
"ellipsis": ellipsis,
|
|
505
|
+
"hintProps": hintProps
|
|
506
|
+
}, _ref9)
|
|
507
|
+
})));
|
|
529
508
|
}
|
|
530
|
-
function ItemHint(
|
|
509
|
+
function ItemHint({
|
|
510
|
+
styles
|
|
511
|
+
}) {
|
|
531
512
|
var _ref0 = arguments[0],
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* @deprecated Use Item hint
|
|
545
|
-
*/
|
|
546
|
-
function Hint(props) {
|
|
547
|
-
var _ref1 = arguments[0],
|
|
548
|
-
_ref20;
|
|
549
|
-
var SDropdownMenuItemContainer = _dropdown["default"].Item;
|
|
550
|
-
return _ref20 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SDropdownMenuItemContainer, _ref20.cn("SDropdownMenuItemContainer", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
551
|
-
"variant": 'hint'
|
|
552
|
-
}, _ref1))));
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* @deprecated Use Group with title prop
|
|
556
|
-
*/
|
|
557
|
-
function Title(props) {
|
|
558
|
-
var _ref10 = arguments[0],
|
|
559
|
-
_ref21;
|
|
560
|
-
var SDropdownMenuItemContainer = _dropdown["default"].Item;
|
|
561
|
-
return _ref21 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SDropdownMenuItemContainer, _ref21.cn("SDropdownMenuItemContainer", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
562
|
-
"variant": 'title'
|
|
563
|
-
}, _ref10))));
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* @deprecated
|
|
568
|
-
*/
|
|
569
|
-
function Nesting(_ref28) {
|
|
570
|
-
var _ref11 = arguments[0];
|
|
571
|
-
var forwardRef = _ref28.forwardRef;
|
|
572
|
-
return /*#__PURE__*/_react["default"].createElement(DropdownMenu.Item, (0, _core.assignProps)({
|
|
573
|
-
"ref": forwardRef
|
|
574
|
-
}, _ref11));
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* @deprecated
|
|
579
|
-
*/
|
|
580
|
-
function NestingTrigger(_ref29) {
|
|
581
|
-
var _ref12 = arguments[0];
|
|
582
|
-
var forwardRef = _ref29.forwardRef;
|
|
583
|
-
return /*#__PURE__*/_react["default"].createElement(DropdownMenu.Item.Content, (0, _core.assignProps)({
|
|
584
|
-
"tag": DropdownMenu.Trigger,
|
|
585
|
-
"ref": forwardRef,
|
|
586
|
-
"use:role": 'menuitem'
|
|
587
|
-
}, _ref12));
|
|
513
|
+
_ref15;
|
|
514
|
+
const SItemHint = _baseComponents.Flex;
|
|
515
|
+
const {
|
|
516
|
+
hintId
|
|
517
|
+
} = _react.default.useContext(menuItemContext);
|
|
518
|
+
return _ref15 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(SItemHint, _ref15.cn("SItemHint", {
|
|
519
|
+
...(0, _core.assignProps)({
|
|
520
|
+
"id": hintId,
|
|
521
|
+
"aria-hidden": 'true'
|
|
522
|
+
}, _ref0)
|
|
523
|
+
}));
|
|
588
524
|
}
|
|
589
|
-
|
|
590
|
-
Trigger
|
|
591
|
-
Popper: _dropdown
|
|
592
|
-
List
|
|
525
|
+
const DropdownMenu = (0, _core.createComponent)(DropdownMenuRoot, {
|
|
526
|
+
Trigger,
|
|
527
|
+
Popper: _dropdown.default.Popper,
|
|
528
|
+
List,
|
|
593
529
|
VirtualList: _VirtualList.VirtualList,
|
|
594
|
-
Actions
|
|
595
|
-
Menu
|
|
530
|
+
Actions,
|
|
531
|
+
Menu,
|
|
596
532
|
Item: [Item, {
|
|
597
|
-
Addon
|
|
533
|
+
Addon,
|
|
598
534
|
Content: ItemContent,
|
|
599
535
|
Text: ItemContentText,
|
|
600
536
|
Hint: ItemHint
|
|
601
537
|
}],
|
|
602
|
-
|
|
603
|
-
* @deprecated. Use just Item. See examples on
|
|
604
|
-
*/
|
|
605
|
-
Nesting: [Nesting, {
|
|
606
|
-
Trigger: NestingTrigger,
|
|
607
|
-
Addon: Addon
|
|
608
|
-
}],
|
|
609
|
-
ItemTitle: Title,
|
|
610
|
-
ItemHint: Hint,
|
|
611
|
-
Group: _dropdown["default"].Group
|
|
538
|
+
Group: _dropdown.default.Group
|
|
612
539
|
}, {
|
|
613
|
-
parent: [_dropdown
|
|
540
|
+
parent: [_dropdown.default]
|
|
614
541
|
});
|
|
615
542
|
DropdownMenu.selectedIndexContext = _dropdown.selectedIndexContext;
|
|
616
|
-
var _default = exports
|
|
543
|
+
var _default = exports.default = DropdownMenu;
|
|
617
544
|
//# sourceMappingURL=DropdownMenu.js.map
|