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