@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.
@@ -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
- var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SDropdownMenuList_1ulzv_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_1ulzv_gg_ .___SBar_1ulzv_gg_{z-index:3}.___SDropdownMenuList_1ulzv_gg_ .___SShadowHorizontal_1ulzv_gg_:after,.___SDropdownMenuList_1ulzv_gg_ .___SShadowHorizontal_1ulzv_gg_:before,.___SDropdownMenuList_1ulzv_gg_ .___SShadowVertical_1ulzv_gg_:after,.___SDropdownMenuList_1ulzv_gg_ .___SShadowVertical_1ulzv_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1ulzv_gg_ .___SItemContent_1ulzv_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1ulzv_gg_.__nesting-trigger_1ulzv_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1ulzv_gg_,.___SItemContentText_1ulzv_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1ulzv_gg_:first-child,.___SItemContentText_1ulzv_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1ulzv_gg_:last-child,.___SItemContentText_1ulzv_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1ulzv_gg_,.___SDropdownMenuNesting_1ulzv_gg_._size_l_1ulzv_gg_,.___SDropdownMenuNesting_1ulzv_gg_._size_m_1ulzv_gg_{padding:0}.___SDropdownMenuNesting_1ulzv_gg_.__highlighted_1ulzv_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_1ulzv_gg_._size_l_1ulzv_gg_,.___SDropdownNestingItem_1ulzv_gg_._size_m_1ulzv_gg_{padding-right:0}.___SDropdownNestingItem_1ulzv_gg_ .___SDropdownMenuItemContainer_1ulzv_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1ulzv_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}", /*__inner_css_end__*/"1ulzv_gg_"),
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": "___SDropdownMenuItemContainer_1ulzv_gg_",
46
- "_nesting-trigger": "__nesting-trigger_1ulzv_gg_",
47
- "__SDropdownMenuNesting": "___SDropdownMenuNesting_1ulzv_gg_",
48
- "_size_l": "_size_l_1ulzv_gg_",
49
- "_size_m": "_size_m_1ulzv_gg_",
50
- "_highlighted": "__highlighted_1ulzv_gg_",
51
- "__SDropdownNestingItem": "___SDropdownNestingItem_1ulzv_gg_",
52
- "__SItemHint": "___SItemHint_1ulzv_gg_",
53
- "__SDropdownMenuList": "___SDropdownMenuList_1ulzv_gg_",
54
- "__SBar": "___SBar_1ulzv_gg_",
55
- "__SShadowHorizontal": "___SShadowHorizontal_1ulzv_gg_",
56
- "__SShadowVertical": "___SShadowVertical_1ulzv_gg_",
57
- "__SItemContent": "___SItemContent_1ulzv_gg_",
58
- "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1ulzv_gg_",
59
- "__SItemContentText": "___SItemContentText_1ulzv_gg_"
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
- var menuItemContext = /*#__PURE__*/React.createContext({});
63
- var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
64
- function DropdownMenuRoot() {
65
- var _this;
66
- _classCallCheck(this, DropdownMenuRoot);
67
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
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(_this, "shouldRecalculateItemTabIndex", false);
82
- return _this;
63
+ _defineProperty(this, "shouldRecalculateItemTabIndex", false);
83
64
  }
84
- _inherits(DropdownMenuRoot, _AbstractDropdown);
85
- return _createClass(DropdownMenuRoot, [{
86
- key: "uncontrolledProps",
87
- value: function uncontrolledProps() {
88
- var _this2 = this;
89
- return _objectSpread(_objectSpread({}, _superPropGet(DropdownMenuRoot, "uncontrolledProps", this, 3)([])), {}, {
90
- visible: [null, function (visible) {
91
- if (visible === true) {
92
- setTimeout(function () {
93
- _this2.focusAndScrollToSelected();
94
- // for some reason, Google Chrome optimizes this timeout with 0 value with previous render (when we set aria-selected)
95
- // and that's why its skip scrollToNodes. We selected the appropriate timeout manually.
96
- }, 50);
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: selected,
115
- options: options
83
+ selected: null,
84
+ options: null
116
85
  };
117
86
  }
118
- }, {
119
- key: "focusAndScrollToSelected",
120
- value: function focusAndScrollToSelected() {
121
- var _this$menuRef$current,
122
- _this3 = this;
123
- var _this$menuElements = this.menuElements,
124
- selected = _this$menuElements.selected,
125
- options = _this$menuElements.options;
126
- var isFocusAlreadyInPopper = isFocusInside(this.popperRef.current);
127
- if (!selected || !options || (_this$menuRef$current = this.menuRef.current) !== null && _this$menuRef$current !== void 0 && _this$menuRef$current.dataset.isVirtual || isFocusAlreadyInPopper) return;
128
- this.scrollToNodeAsync(selected, true).then(function () {
129
- if (_this3.asProps.visible) {
130
- selected.focus({
131
- preventScroll: true
132
- });
133
- }
134
- });
135
- var selectedIndex = Array.from(options).indexOf(selected);
136
- if (selectedIndex !== -1) {
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
- key: "afterOpenPopper",
142
- value: function afterOpenPopper() {
143
- var _this$menuRef$current2;
144
- var _this$menuElements2 = this.menuElements,
145
- selected = _this$menuElements2.selected,
146
- options = _this$menuElements2.options;
147
- if (selected && options && !((_this$menuRef$current2 = this.menuRef.current) !== null && _this$menuRef$current2 !== void 0 && _this$menuRef$current2.dataset.isVirtual)) return;
148
- _superPropGet(DropdownMenuRoot, "afterOpenPopper", this, 3)([]);
149
- }
150
- }, {
151
- key: "itemRef",
152
- value: function itemRef(props, index, node) {
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
- key: "getTriggerProps",
160
- value: function getTriggerProps() {
161
- var _this$asProps = this.asProps,
162
- Children = _this$asProps.Children,
163
- uid = _this$asProps.uid,
164
- visible = _this$asProps.visible;
165
- var hasMenu = isAdvanceMode(Children, [DropdownMenu.Menu.displayName]);
166
- var ariaControls = hasMenu ? "igc-".concat(uid, "-list") : "igc-".concat(uid, "-popper");
167
- return _objectSpread(_objectSpread({}, _superPropGet(DropdownMenuRoot, "getTriggerProps", this, 3)([])), {}, {
168
- 'onKeyDown': callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleKeyDownForMenu('trigger')),
169
- 'aria-controls': visible ? ariaControls : undefined,
170
- 'aria-haspopup': hasMenu ? 'true' : 'dialog'
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
- key: "getListProps",
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
- key: "getVirtualListProps",
182
- value: function getVirtualListProps() {
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
- key: "getPopperProps",
189
- value: function getPopperProps() {
190
- return _objectSpread(_objectSpread({}, _superPropGet(DropdownMenuRoot, "getPopperProps", this, 3)([])), {}, {
191
- onKeyDown: callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this))
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
- key: "getActionsProps",
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
- key: "getItemTabIndex",
204
- value: function getItemTabIndex(props, itemIndex) {
205
- var disabled = props.disabled,
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
- key: "getItemProps",
226
- value: function getItemProps(props, index) {
227
- var _props$index,
228
- _this4 = this;
229
- var realIndex = (_props$index = props.index) !== null && _props$index !== void 0 ? _props$index : index;
230
- var itemProps = _objectSpread(_objectSpread({}, _superPropGet(DropdownMenuRoot, "getItemProps", this, 3)([props, realIndex])), {}, {
231
- tabIndex: this.getItemTabIndex(props, index),
232
- ref: function ref(node) {
233
- return _this4.itemRef(props, realIndex, node);
234
- },
235
- actionsRef: this.actionsRef
236
- });
237
- if (props.tag === ButtonComponent) {
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
- if (_superPropGet(DropdownMenuRoot, "childRole", this, 1) === 'menuitemradio') {
248
- itemProps.onClick = function () {
249
- _this4.handlers.visible(false);
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
- return itemProps;
253
- }
254
- }, {
255
- key: "handleKeyDownForMenu",
256
- value: function handleKeyDownForMenu(place) {
257
- var _this5 = this;
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
- key: "render",
316
- value: function render() {
317
- var _ref = this.asProps;
318
- var _this$asProps3 = this.asProps,
319
- Children = _this$asProps3.Children,
320
- selectedIndex = _this$asProps3.selectedIndex,
321
- interaction = _this$asProps3.interaction,
322
- timeout = _this$asProps3.timeout;
323
- this.itemProps = [];
324
- return /*#__PURE__*/React.createElement(selectedIndexContext.Provider, {
325
- value: selectedIndex
326
- }, /*#__PURE__*/React.createElement(Dropdown, _assignProps({
327
- "timeout": timeout || (interaction === 'hover' ? [0, 100] : undefined)
328
- }, _ref), /*#__PURE__*/React.createElement(Children, null)));
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(_ref22) {
303
+ function List({
304
+ styles,
305
+ Children
306
+ }) {
352
307
  var _ref2 = arguments[0],
353
- _ref13;
354
- var styles = _ref22.styles,
355
- Children = _ref22.Children;
356
- var SDropdownMenuList = ScrollAreaComponent;
357
- var SBar = ScrollAreaComponent.Bar;
358
- return _ref13 = sstyled(styles), /*#__PURE__*/React.createElement(ListBoxContextProvider, _ref13.cn("ListBoxContextProvider", {}), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref13.cn("SDropdownMenuList", _objectSpread({}, _assignProps2({
359
- "shadow": true,
360
- "shadowSize": 16,
361
- "shadowTheme": 'light'
362
- }, _ref2))), /*#__PURE__*/React.createElement(ScrollAreaComponent.Container, {
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, _ref13.cn("Children", {}))), /*#__PURE__*/React.createElement(SBar, _ref13.cn("SBar", {
319
+ }, /*#__PURE__*/React.createElement(Children, _ref1.cn("Children", {}))), /*#__PURE__*/React.createElement(SBar, _ref1.cn("SBar", {
365
320
  "orientation": 'horizontal'
366
- })), /*#__PURE__*/React.createElement(SBar, _ref13.cn("SBar", {
321
+ })), /*#__PURE__*/React.createElement(SBar, _ref1.cn("SBar", {
367
322
  "orientation": 'vertical'
368
323
  }))));
369
324
  }
370
- function Actions(_ref23) {
325
+ function Actions({
326
+ styles
327
+ }) {
371
328
  var _ref3 = arguments[0],
372
- _ref14;
373
- var styles = _ref23.styles;
374
- var SDropdownMenuActions = Flex;
375
- return _ref14 = sstyled(styles), /*#__PURE__*/React.createElement(SDropdownMenuActions, _ref14.cn("SDropdownMenuActions", _objectSpread({}, _assignProps3({}, _ref3))));
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
- var visible = props.visible,
380
- disablePortal = props.disablePortal,
381
- ignorePortalsStacking = props.ignorePortalsStacking,
382
- disableEnforceFocus = props.disableEnforceFocus,
383
- interaction = props.interaction,
384
- autoFocus = props.autoFocus,
385
- animationsDisabled = props.animationsDisabled;
386
- var popperProps = {
387
- visible: visible,
388
- disablePortal: disablePortal,
389
- ignorePortalsStacking: ignorePortalsStacking,
390
- disableEnforceFocus: disableEnforceFocus,
391
- interaction: interaction,
392
- autoFocus: autoFocus,
393
- animationsDisabled: animationsDisabled
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(_ref24) {
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
- _ref15;
402
- var id = _ref24.id,
403
- styles = _ref24.styles,
404
- disabled = _ref24.disabled,
405
- Children = _ref24.Children,
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: forkRef(forwardRef, itemRef),
420
- role: role,
421
- tabIndex: tabIndex,
422
- ariaChecked: ariaChecked,
423
- disabled: disabled
377
+ ref: itemRef,
378
+ forwardRef,
379
+ role,
380
+ tabIndex,
381
+ ariaChecked,
382
+ disabled
424
383
  };
425
- var ariaDescribes = [];
426
- var hasSubMenu = isAdvanceMode(Children, [DropdownMenu.displayName], true);
427
- var hasHint = isAdvanceMode(Children, [DropdownMenu.Item.Hint.displayName], true);
428
- var advancedMode = isAdvanceMode(Children, [DropdownMenu.Item.Content.displayName], true) || hasSubMenu || hasHint;
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
- var hintId = "igc-".concat(useUID(), "-option-hint");
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(function () {
439
- var onFocus = function onFocus(e) {
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
- var onBlur = function onBlur(e) {
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 function () {
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
- }, [itemRef.current]);
470
- return _ref15 = sstyled(styles), /*#__PURE__*/React.createElement(menuItemContext.Provider, {
428
+ });
429
+ return _ref11 = sstyled(styles), /*#__PURE__*/React.createElement(menuItemContext.Provider, {
471
430
  value: menuItemContextValue
472
- }, /*#__PURE__*/React.createElement(SDropdownMenuItemContainer, _ref15.cn("SDropdownMenuItemContainer", _objectSpread({}, _assignProps5({
473
- "ref": advancedMode ? undefined : menuItemContextValue.ref,
474
- "use:highlighted": !disabled && highlighted && lastInteraction.isKeyboard(),
475
- "use:role": advancedMode ? undefined : role,
476
- "use:id": advancedMode ? undefined : id,
477
- "use:tabIndex": advancedMode ? undefined : tabIndex,
478
- "use:aria-checked": advancedMode ? undefined : ariaChecked
479
- }, _ref5))), /*#__PURE__*/React.createElement(Children, _ref15.cn("Children", {}))));
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
- _ref16;
484
- var SDropdownMenuItemAddon = Box;
485
- return _ref16 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItemAddon, _ref16.cn("SDropdownMenuItemAddon", _objectSpread({}, _assignProps6({}, _ref6))));
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(_ref25) {
454
+ function ItemContent({
455
+ styles
456
+ }) {
492
457
  var _ref8 = arguments[0],
493
- _ref17;
494
- var styles = _ref25.styles;
495
- var SItemContent = Flex;
496
- var ref = React.useRef();
497
- var menuItemCtxValue = React.useContext(menuItemContext);
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
- var _React$useState3 = React.useState(new Set(menuItemCtxValue.ariaDescribes)),
503
- _React$useState4 = _slicedToArray(_React$useState3, 2),
504
- describedby = _React$useState4[0],
505
- setDescribedby = _React$useState4[1];
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(function (prev) {
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 _ref17 = sstyled(styles), /*#__PURE__*/React.createElement(SItemContent, _ref17.cn("SItemContent", _objectSpread({}, _assignProps8({
517
- "role": menuItemCtxValue.role,
518
- "id": menuItemCtxValue.contentId,
519
- "tabIndex": menuItemCtxValue.tabIndex,
520
- "ref": forkRef(menuItemCtxValue.ref, ref),
521
- "use:aria-describedby": _toConsumableArray(describedby).join(' '),
522
- "aria-haspopup": menuItemCtxValue.hasSubMenu ? 'true' : undefined,
523
- "aria-expanded": subMenu,
524
- "aria-checked": menuItemCtxValue.ariaChecked,
525
- "alignItems": 'center',
526
- "justifyContent": menuItemCtxValue.hasSubMenu ? 'space-between' : undefined,
527
- "disabled": menuItemCtxValue.disabled
528
- }, _ref8))));
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(_ref26) {
493
+ function ItemContentText({
494
+ styles,
495
+ ellipsis = false,
496
+ hintProps = {}
497
+ }) {
531
498
  var _ref9 = arguments[0],
532
- _ref18;
533
- var styles = _ref26.styles;
534
- var SItemContentText = Text;
535
- return _ref18 = sstyled(styles), /*#__PURE__*/React.createElement(SItemContentText, _ref18.cn("SItemContentText", _objectSpread({}, _assignProps9({}, _ref9))));
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(_ref27) {
512
+ function ItemHint({
513
+ styles
514
+ }) {
538
515
  var _ref0 = arguments[0],
539
- _ref19;
540
- var styles = _ref27.styles;
541
- var SItemHint = Flex;
542
- var _React$useContext = React.useContext(menuItemContext),
543
- hintId = _React$useContext.hintId;
544
- return _ref19 = sstyled(styles), /*#__PURE__*/React.createElement(SItemHint, _ref19.cn("SItemHint", _objectSpread({}, _assignProps0({
545
- "id": hintId,
546
- "aria-hidden": 'true'
547
- }, _ref0))));
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
- var DropdownMenu = createComponent(DropdownMenuRoot, {
597
- Trigger: Trigger,
528
+ const DropdownMenu = createComponent(DropdownMenuRoot, {
529
+ Trigger,
598
530
  Popper: Dropdown.Popper,
599
- List: List,
600
- VirtualList: VirtualList,
601
- Actions: Actions,
602
- Menu: Menu,
531
+ List,
532
+ VirtualList,
533
+ Actions,
534
+ Menu,
603
535
  Item: [Item, {
604
- Addon: 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]