@semcore/dropdown-menu 16.2.2 → 17.0.0-prerelease.18

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,68 +1,54 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
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["default"] = void 0;
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 _assignProps13 = require("@semcore/core/lib/utils/assignProps");
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 _ref30 = require("@semcore/core/lib/utils/ref");
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
- var style = (/*__reshadow_css_start__*/_core.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_"),
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": "___SDropdownMenuItemContainer_1ulzv_gg_",
40
- "_nesting-trigger": "__nesting-trigger_1ulzv_gg_",
41
- "__SDropdownMenuNesting": "___SDropdownMenuNesting_1ulzv_gg_",
42
- "_size_l": "_size_l_1ulzv_gg_",
43
- "_size_m": "_size_m_1ulzv_gg_",
44
- "_highlighted": "__highlighted_1ulzv_gg_",
45
- "__SDropdownNestingItem": "___SDropdownNestingItem_1ulzv_gg_",
46
- "__SItemHint": "___SItemHint_1ulzv_gg_",
47
- "__SDropdownMenuList": "___SDropdownMenuList_1ulzv_gg_",
48
- "__SBar": "___SBar_1ulzv_gg_",
49
- "__SShadowHorizontal": "___SShadowHorizontal_1ulzv_gg_",
50
- "__SShadowVertical": "___SShadowVertical_1ulzv_gg_",
51
- "__SItemContent": "___SItemContent_1ulzv_gg_",
52
- "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1ulzv_gg_",
53
- "__SItemContentText": "___SItemContentText_1ulzv_gg_"
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
- var menuItemContext = /*#__PURE__*/_react["default"].createContext({});
56
- var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
57
- function DropdownMenuRoot() {
58
- var _this;
59
- (0, _classCallCheck2["default"])(this, DropdownMenuRoot);
60
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
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["default"])(_this, "shouldRecalculateItemTabIndex", false);
75
- return _this;
60
+ (0, _defineProperty2.default)(this, "shouldRecalculateItemTabIndex", false);
76
61
  }
77
- (0, _inherits2["default"])(DropdownMenuRoot, _AbstractDropdown);
78
- return (0, _createClass2["default"])(DropdownMenuRoot, [{
79
- key: "uncontrolledProps",
80
- value: function uncontrolledProps() {
81
- var _this2 = this;
82
- return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _superPropGet2["default"])(DropdownMenuRoot, "uncontrolledProps", this, 3)([])), {}, {
83
- visible: [null, function (visible) {
84
- if (visible === true) {
85
- setTimeout(function () {
86
- _this2.focusAndScrollToSelected();
87
- // for some reason, Google Chrome optimizes this timeout with 0 value with previous render (when we set aria-selected)
88
- // and that's why its skip scrollToNodes. We selected the appropriate timeout manually.
89
- }, 50);
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: selected,
108
- options: options
80
+ selected: null,
81
+ options: null
109
82
  };
110
83
  }
111
- }, {
112
- key: "focusAndScrollToSelected",
113
- value: function focusAndScrollToSelected() {
114
- var _this$menuRef$current,
115
- _this3 = this;
116
- var _this$menuElements = this.menuElements,
117
- selected = _this$menuElements.selected,
118
- options = _this$menuElements.options;
119
- var isFocusAlreadyInPopper = (0, _isFocusInside.isFocusInside)(this.popperRef.current);
120
- if (!selected || !options || (_this$menuRef$current = this.menuRef.current) !== null && _this$menuRef$current !== void 0 && _this$menuRef$current.dataset.isVirtual || isFocusAlreadyInPopper) return;
121
- this.scrollToNodeAsync(selected, true).then(function () {
122
- if (_this3.asProps.visible) {
123
- selected.focus({
124
- preventScroll: true
125
- });
126
- }
127
- });
128
- var selectedIndex = Array.from(options).indexOf(selected);
129
- if (selectedIndex !== -1) {
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
- key: "afterOpenPopper",
135
- value: function afterOpenPopper() {
136
- var _this$menuRef$current2;
137
- var _this$menuElements2 = this.menuElements,
138
- selected = _this$menuElements2.selected,
139
- options = _this$menuElements2.options;
140
- if (selected && options && !((_this$menuRef$current2 = this.menuRef.current) !== null && _this$menuRef$current2 !== void 0 && _this$menuRef$current2.dataset.isVirtual)) return;
141
- (0, _superPropGet2["default"])(DropdownMenuRoot, "afterOpenPopper", this, 3)([]);
142
- }
143
- }, {
144
- key: "itemRef",
145
- value: function itemRef(props, index, node) {
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
- key: "getTriggerProps",
153
- value: function getTriggerProps() {
154
- var _this$asProps = this.asProps,
155
- Children = _this$asProps.Children,
156
- uid = _this$asProps.uid,
157
- visible = _this$asProps.visible;
158
- var hasMenu = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.Menu.displayName]);
159
- var ariaControls = hasMenu ? "igc-".concat(uid, "-list") : "igc-".concat(uid, "-popper");
160
- return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _superPropGet2["default"])(DropdownMenuRoot, "getTriggerProps", this, 3)([])), {}, {
161
- 'onKeyDown': (0, _assignProps13.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handleOpenKeyDown.bind(this), this.handleKeyDownForMenu('trigger')),
162
- 'aria-controls': visible ? ariaControls : undefined,
163
- 'aria-haspopup': hasMenu ? 'true' : 'dialog'
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
- key: "getListProps",
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
- key: "getVirtualListProps",
175
- value: function getVirtualListProps() {
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
- key: "getPopperProps",
182
- value: function getPopperProps() {
183
- return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _superPropGet2["default"])(DropdownMenuRoot, "getPopperProps", this, 3)([])), {}, {
184
- onKeyDown: (0, _assignProps13.callAllEventHandlers)(this.handlePreventCommonKeyDown.bind(this), this.handlePreventPopperKeyDown.bind(this))
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
- key: "getActionsProps",
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
- key: "getItemTabIndex",
197
- value: function getItemTabIndex(props, itemIndex) {
198
- var disabled = props.disabled,
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
- key: "getItemProps",
219
- value: function getItemProps(props, index) {
220
- var _props$index,
221
- _this4 = this;
222
- var realIndex = (_props$index = props.index) !== null && _props$index !== void 0 ? _props$index : index;
223
- var itemProps = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, (0, _superPropGet2["default"])(DropdownMenuRoot, "getItemProps", this, 3)([props, realIndex])), {}, {
224
- tabIndex: this.getItemTabIndex(props, index),
225
- ref: function ref(node) {
226
- return _this4.itemRef(props, realIndex, node);
227
- },
228
- actionsRef: this.actionsRef
229
- });
230
- if (props.tag === _button["default"]) {
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
- if ((0, _superPropGet2["default"])(DropdownMenuRoot, "childRole", this, 1) === 'menuitemradio') {
241
- itemProps.onClick = function () {
242
- _this4.handlers.visible(false);
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
- return itemProps;
246
- }
247
- }, {
248
- key: "handleKeyDownForMenu",
249
- value: function handleKeyDownForMenu(place) {
250
- var _this5 = this;
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
- key: "render",
309
- value: function render() {
310
- var _ref = this.asProps;
311
- var _this$asProps3 = this.asProps,
312
- Children = _this$asProps3.Children,
313
- selectedIndex = _this$asProps3.selectedIndex,
314
- interaction = _this$asProps3.interaction,
315
- timeout = _this$asProps3.timeout;
316
- this.itemProps = [];
317
- return /*#__PURE__*/_react["default"].createElement(_dropdown.selectedIndexContext.Provider, {
318
- value: selectedIndex
319
- }, /*#__PURE__*/_react["default"].createElement(_dropdown["default"], (0, _core.assignProps)({
320
- "timeout": timeout || (interaction === 'hover' ? [0, 100] : undefined)
321
- }, _ref), /*#__PURE__*/_react["default"].createElement(Children, null)));
322
- }
323
- }]);
324
- }(_dropdown.AbstractDropdown);
325
- (0, _defineProperty2["default"])(DropdownMenuRoot, "displayName", 'DropdownMenu');
326
- (0, _defineProperty2["default"])(DropdownMenuRoot, "style", style);
327
- (0, _defineProperty2["default"])(DropdownMenuRoot, "enhance", Object.values(_dropdown.enhance));
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["default"])(DropdownMenuRoot, "nestedMenuInteraction", {
296
+ (0, _defineProperty2.default)(DropdownMenuRoot, "nestedMenuInteraction", {
341
297
  trigger: [['onClick', 'onMouseEnter'], ['onClick', 'onMouseLeave']],
342
298
  popper: [['onMouseEnter'], ['onMouseLeave']]
343
299
  });
344
- function List(_ref22) {
300
+ function List({
301
+ styles,
302
+ Children
303
+ }) {
345
304
  var _ref2 = arguments[0],
346
- _ref13;
347
- var styles = _ref22.styles,
348
- Children = _ref22.Children;
349
- var SDropdownMenuList = _scrollArea["default"];
350
- var SBar = _scrollArea["default"].Bar;
351
- return _ref13 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_Context.ListBoxContextProvider, _ref13.cn("ListBoxContextProvider", {}), /*#__PURE__*/_react["default"].createElement(SDropdownMenuList, _ref13.cn("SDropdownMenuList", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
352
- "shadow": true,
353
- "shadowSize": 16,
354
- "shadowTheme": 'light'
355
- }, _ref2))), /*#__PURE__*/_react["default"].createElement(_scrollArea["default"].Container, {
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["default"].createElement(Children, _ref13.cn("Children", {}))), /*#__PURE__*/_react["default"].createElement(SBar, _ref13.cn("SBar", {
316
+ }, /*#__PURE__*/_react.default.createElement(Children, _ref1.cn("Children", {}))), /*#__PURE__*/_react.default.createElement(SBar, _ref1.cn("SBar", {
358
317
  "orientation": 'horizontal'
359
- })), /*#__PURE__*/_react["default"].createElement(SBar, _ref13.cn("SBar", {
318
+ })), /*#__PURE__*/_react.default.createElement(SBar, _ref1.cn("SBar", {
360
319
  "orientation": 'vertical'
361
320
  }))));
362
321
  }
363
- function Actions(_ref23) {
322
+ function Actions({
323
+ styles
324
+ }) {
364
325
  var _ref3 = arguments[0],
365
- _ref14;
366
- var styles = _ref23.styles;
367
- var SDropdownMenuActions = _flexBox.Flex;
368
- return _ref14 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SDropdownMenuActions, _ref14.cn("SDropdownMenuActions", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref3))));
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
- var visible = props.visible,
373
- disablePortal = props.disablePortal,
374
- ignorePortalsStacking = props.ignorePortalsStacking,
375
- disableEnforceFocus = props.disableEnforceFocus,
376
- interaction = props.interaction,
377
- autoFocus = props.autoFocus,
378
- animationsDisabled = props.animationsDisabled;
379
- var popperProps = {
380
- visible: visible,
381
- disablePortal: disablePortal,
382
- ignorePortalsStacking: ignorePortalsStacking,
383
- disableEnforceFocus: disableEnforceFocus,
384
- interaction: interaction,
385
- autoFocus: autoFocus,
386
- animationsDisabled: animationsDisabled
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["default"].createElement(_Context.ListBoxContextProvider, null, /*#__PURE__*/_react["default"].createElement(DropdownMenu.Popper, (0, _extends2["default"])({}, popperProps, {
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["default"].createElement(DropdownMenu.List, (0, _core.assignProps)({}, _ref4))));
354
+ }), /*#__PURE__*/_react.default.createElement(DropdownMenu.List, (0, _core.assignProps)({}, _ref4))));
391
355
  }
392
- function Item(_ref24) {
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
- _ref15;
395
- var id = _ref24.id,
396
- styles = _ref24.styles,
397
- disabled = _ref24.disabled,
398
- Children = _ref24.Children,
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: (0, _ref30.forkRef)(forwardRef, itemRef),
413
- role: role,
414
- tabIndex: tabIndex,
415
- ariaChecked: ariaChecked,
416
- disabled: disabled
374
+ ref: itemRef,
375
+ forwardRef,
376
+ role,
377
+ tabIndex,
378
+ ariaChecked,
379
+ disabled
417
380
  };
418
- var ariaDescribes = [];
419
- var hasSubMenu = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.displayName], true);
420
- var hasHint = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.Item.Hint.displayName], true);
421
- var advancedMode = (0, _findComponent.isAdvanceMode)(Children, [DropdownMenu.Item.Content.displayName], true) || hasSubMenu || hasHint;
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
- var hintId = "igc-".concat((0, _uniqueID.useUID)(), "-option-hint");
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["default"].useEffect(function () {
432
- var onFocus = function onFocus(e) {
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
- var onBlur = function onBlur(e) {
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 function () {
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
- }, [itemRef.current]);
463
- return _ref15 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(menuItemContext.Provider, {
425
+ });
426
+ return _ref11 = (0, _core.sstyled)(styles), /*#__PURE__*/_react.default.createElement(menuItemContext.Provider, {
464
427
  value: menuItemContextValue
465
- }, /*#__PURE__*/_react["default"].createElement(SDropdownMenuItemContainer, _ref15.cn("SDropdownMenuItemContainer", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
466
- "ref": advancedMode ? undefined : menuItemContextValue.ref,
467
- "use:highlighted": !disabled && highlighted && _core.lastInteraction.isKeyboard(),
468
- "use:role": advancedMode ? undefined : role,
469
- "use:id": advancedMode ? undefined : id,
470
- "use:tabIndex": advancedMode ? undefined : tabIndex,
471
- "use:aria-checked": advancedMode ? undefined : ariaChecked
472
- }, _ref5))), /*#__PURE__*/_react["default"].createElement(Children, _ref15.cn("Children", {}))));
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
- _ref16;
477
- var SDropdownMenuItemAddon = _flexBox.Box;
478
- return _ref16 = (0, _core.sstyled)(props.styles), /*#__PURE__*/_react["default"].createElement(SDropdownMenuItemAddon, _ref16.cn("SDropdownMenuItemAddon", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref6))));
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["default"].createElement(_dropdown["default"].Trigger, (0, _core.assignProps)({}, _ref7));
449
+ return /*#__PURE__*/_react.default.createElement(_dropdown.default.Trigger, (0, _core.assignProps)({}, _ref7));
483
450
  }
484
- function ItemContent(_ref25) {
451
+ function ItemContent({
452
+ styles
453
+ }) {
485
454
  var _ref8 = arguments[0],
486
- _ref17;
487
- var styles = _ref25.styles;
488
- var SItemContent = _flexBox.Flex;
489
- var ref = _react["default"].useRef();
490
- var menuItemCtxValue = _react["default"].useContext(menuItemContext);
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
- var _React$useState3 = _react["default"].useState(new Set(menuItemCtxValue.ariaDescribes)),
496
- _React$useState4 = (0, _slicedToArray2["default"])(_React$useState3, 2),
497
- describedby = _React$useState4[0],
498
- setDescribedby = _React$useState4[1];
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(function (prev) {
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 _ref17 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SItemContent, _ref17.cn("SItemContent", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
510
- "role": menuItemCtxValue.role,
511
- "id": menuItemCtxValue.contentId,
512
- "tabIndex": menuItemCtxValue.tabIndex,
513
- "ref": (0, _ref30.forkRef)(menuItemCtxValue.ref, ref),
514
- "use:aria-describedby": (0, _toConsumableArray2["default"])(describedby).join(' '),
515
- "aria-haspopup": menuItemCtxValue.hasSubMenu ? 'true' : undefined,
516
- "aria-expanded": subMenu,
517
- "aria-checked": menuItemCtxValue.ariaChecked,
518
- "alignItems": 'center',
519
- "justifyContent": menuItemCtxValue.hasSubMenu ? 'space-between' : undefined,
520
- "disabled": menuItemCtxValue.disabled
521
- }, _ref8))));
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(_ref26) {
490
+ function ItemContentText({
491
+ styles,
492
+ ellipsis = false,
493
+ hintProps = {}
494
+ }) {
524
495
  var _ref9 = arguments[0],
525
- _ref18;
526
- var styles = _ref26.styles;
527
- var SItemContentText = _typography.Text;
528
- return _ref18 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SItemContentText, _ref18.cn("SItemContentText", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({}, _ref9))));
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(_ref27) {
509
+ function ItemHint({
510
+ styles
511
+ }) {
531
512
  var _ref0 = arguments[0],
532
- _ref19;
533
- var styles = _ref27.styles;
534
- var SItemHint = _flexBox.Flex;
535
- var _React$useContext = _react["default"].useContext(menuItemContext),
536
- hintId = _React$useContext.hintId;
537
- return _ref19 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(SItemHint, _ref19.cn("SItemHint", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
538
- "id": hintId,
539
- "aria-hidden": 'true'
540
- }, _ref0))));
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
- var DropdownMenu = (0, _core.createComponent)(DropdownMenuRoot, {
590
- Trigger: Trigger,
591
- Popper: _dropdown["default"].Popper,
592
- List: List,
525
+ const DropdownMenu = (0, _core.createComponent)(DropdownMenuRoot, {
526
+ Trigger,
527
+ Popper: _dropdown.default.Popper,
528
+ List,
593
529
  VirtualList: _VirtualList.VirtualList,
594
- Actions: Actions,
595
- Menu: Menu,
530
+ Actions,
531
+ Menu,
596
532
  Item: [Item, {
597
- Addon: 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["default"]]
540
+ parent: [_dropdown.default]
614
541
  });
615
542
  DropdownMenu.selectedIndexContext = _dropdown.selectedIndexContext;
616
- var _default = exports["default"] = DropdownMenu;
543
+ var _default = exports.default = DropdownMenu;
617
544
  //# sourceMappingURL=DropdownMenu.js.map