@semcore/dropdown-menu 16.3.0 → 16.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/lib/cjs/DropdownMenu.js +132 -87
- package/lib/cjs/DropdownMenu.js.map +1 -1
- package/lib/cjs/components/Context.js +2 -2
- package/lib/cjs/components/Context.js.map +1 -1
- package/lib/cjs/components/VirtualList.js +20 -20
- package/lib/cjs/components/VirtualList.js.map +1 -1
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/cjs/style/dropdown-menu.shadow.css +12 -18
- package/lib/es6/DropdownMenu.js +123 -74
- package/lib/es6/DropdownMenu.js.map +1 -1
- package/lib/es6/components/Context.js +1 -1
- package/lib/es6/components/Context.js.map +1 -1
- package/lib/es6/components/VirtualList.js +18 -18
- package/lib/es6/components/VirtualList.js.map +1 -1
- package/lib/es6/index.d.js.map +1 -1
- package/lib/es6/style/dropdown-menu.shadow.css +12 -18
- package/lib/esm/DropdownMenu.mjs +98 -68
- package/lib/esm/components/Context.mjs +1 -1
- package/lib/esm/components/VirtualList.mjs +23 -23
- package/lib/esm/style/dropdown-menu.shadow.css +12 -18
- package/lib/types/index.d.ts +79 -3
- package/package.json +11 -11
package/lib/esm/DropdownMenu.mjs
CHANGED
|
@@ -8,8 +8,7 @@ import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
|
8
8
|
import _superPropGet from "@babel/runtime/helpers/esm/superPropGet";
|
|
9
9
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
-
import { sstyled, assignProps, lastInteraction
|
|
12
|
-
import { ScrollArea, Flex, Box } from "@semcore/base-components";
|
|
11
|
+
import { sstyled, createComponent, assignProps, lastInteraction } from "@semcore/core";
|
|
13
12
|
import ButtonComponent from "@semcore/button";
|
|
14
13
|
import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
15
14
|
import { isAdvanceMode } from "@semcore/core/lib/utils/findComponent";
|
|
@@ -17,7 +16,9 @@ import { isFocusInside } from "@semcore/core/lib/utils/focus-lock/isFocusInside"
|
|
|
17
16
|
import { setFocus } from "@semcore/core/lib/utils/focus-lock/setFocus";
|
|
18
17
|
import { forkRef } from "@semcore/core/lib/utils/ref";
|
|
19
18
|
import { useUID } from "@semcore/core/lib/utils/uniqueID";
|
|
20
|
-
import Dropdown, { selectedIndexContext, AbstractDropdown
|
|
19
|
+
import Dropdown, { enhance, selectedIndexContext, AbstractDropdown } from "@semcore/dropdown";
|
|
20
|
+
import { Box, Flex } from "@semcore/flex-box";
|
|
21
|
+
import ScrollAreaComponent from "@semcore/scroll-area";
|
|
21
22
|
import { Text } from "@semcore/typography";
|
|
22
23
|
import React from "react";
|
|
23
24
|
import { ListBoxContextProvider } from "./components/Context.mjs";
|
|
@@ -28,27 +29,26 @@ var style = (
|
|
|
28
29
|
/*__reshadow_css_start__*/
|
|
29
30
|
(sstyled.insert(
|
|
30
31
|
/*__inner_css_start__*/
|
|
31
|
-
|
|
32
|
+
".___SDropdownMenuList_1ahmt_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, rgba(1, 5, 0, 0.899))}.___SDropdownMenuList_1ahmt_gg_ .___SBar_1ahmt_gg_{z-index:3}.___SDropdownMenuList_1ahmt_gg_ .___SShadowHorizontal_1ahmt_gg_:after,.___SDropdownMenuList_1ahmt_gg_ .___SShadowHorizontal_1ahmt_gg_:before,.___SDropdownMenuList_1ahmt_gg_ .___SShadowVertical_1ahmt_gg_:after,.___SDropdownMenuList_1ahmt_gg_ .___SShadowVertical_1ahmt_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1ahmt_gg_ .___SItemContent_1ahmt_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1ahmt_gg_.__nesting-trigger_1ahmt_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1ahmt_gg_,.___SItemContentText_1ahmt_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1ahmt_gg_:first-child,.___SItemContentText_1ahmt_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1ahmt_gg_:last-child,.___SItemContentText_1ahmt_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1ahmt_gg_,.___SDropdownMenuNesting_1ahmt_gg_._size_l_1ahmt_gg_,.___SDropdownMenuNesting_1ahmt_gg_._size_m_1ahmt_gg_{padding:0}.___SDropdownMenuNesting_1ahmt_gg_.__highlighted_1ahmt_gg_{z-index:1;outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469));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}@supports (color:color(display-p3 0 0 0%)){.___SDropdownMenuNesting_1ahmt_gg_.__highlighted_1ahmt_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469))}@media (color-gamut:p3){.___SDropdownMenuNesting_1ahmt_gg_.__highlighted_1ahmt_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, color(display-p3 0.03256 0.12227 0.83249 / 0.469))}}}.___SDropdownNestingItem_1ahmt_gg_._size_l_1ahmt_gg_,.___SDropdownNestingItem_1ahmt_gg_._size_m_1ahmt_gg_{padding-right:0}.___SDropdownNestingItem_1ahmt_gg_ .___SDropdownMenuItemContainer_1ahmt_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1ahmt_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@supports (color:color(display-p3 0 0 0%)){.___SItemHint_1ahmt_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SItemHint_1ahmt_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}",
|
|
32
33
|
/*__inner_css_end__*/
|
|
33
|
-
"
|
|
34
|
+
"1ahmt_gg_"
|
|
34
35
|
), /*__reshadow_css_end__*/
|
|
35
36
|
{
|
|
36
|
-
"__SDropdownMenuItemContainer": "
|
|
37
|
-
"_nesting-trigger": "__nesting-
|
|
38
|
-
"__SDropdownMenuNesting": "
|
|
39
|
-
"_size_l": "
|
|
40
|
-
"_size_m": "
|
|
41
|
-
"_highlighted": "
|
|
42
|
-
"__SDropdownNestingItem": "
|
|
43
|
-
"__SItemHint": "
|
|
44
|
-
"__SDropdownMenuList": "
|
|
45
|
-
"__SBar": "
|
|
46
|
-
"__SShadowHorizontal": "
|
|
47
|
-
"__SShadowVertical": "
|
|
48
|
-
"__SItemContent": "
|
|
49
|
-
"__SDropdownMenuItemAddon": "
|
|
50
|
-
"__SItemContentText": "
|
|
51
|
-
"__SScrollContainer": "___SScrollContainer_1d74h_gg_"
|
|
37
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1ahmt_gg_",
|
|
38
|
+
"_nesting-trigger": "__nesting-trigger_1ahmt_gg_",
|
|
39
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1ahmt_gg_",
|
|
40
|
+
"_size_l": "_size_l_1ahmt_gg_",
|
|
41
|
+
"_size_m": "_size_m_1ahmt_gg_",
|
|
42
|
+
"_highlighted": "__highlighted_1ahmt_gg_",
|
|
43
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1ahmt_gg_",
|
|
44
|
+
"__SItemHint": "___SItemHint_1ahmt_gg_",
|
|
45
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1ahmt_gg_",
|
|
46
|
+
"__SBar": "___SBar_1ahmt_gg_",
|
|
47
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1ahmt_gg_",
|
|
48
|
+
"__SShadowVertical": "___SShadowVertical_1ahmt_gg_",
|
|
49
|
+
"__SItemContent": "___SItemContent_1ahmt_gg_",
|
|
50
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1ahmt_gg_",
|
|
51
|
+
"__SItemContentText": "___SItemContentText_1ahmt_gg_"
|
|
52
52
|
})
|
|
53
53
|
);
|
|
54
54
|
var menuItemContext = /* @__PURE__ */ React.createContext({});
|
|
@@ -121,8 +121,6 @@ var DropdownMenuRoot = /* @__PURE__ */ (function(_AbstractDropdown) {
|
|
|
121
121
|
value: function afterOpenPopper() {
|
|
122
122
|
var _this$menuRef$current2;
|
|
123
123
|
var _this$menuElements2 = this.menuElements, selected = _this$menuElements2.selected, options = _this$menuElements2.options;
|
|
124
|
-
var isFocusAlreadyInPopper = isFocusInside(this.popperRef.current);
|
|
125
|
-
if (isFocusAlreadyInPopper) return;
|
|
126
124
|
if (selected && options && !((_this$menuRef$current2 = this.menuRef.current) !== null && _this$menuRef$current2 !== void 0 && _this$menuRef$current2.dataset.isVirtual)) return;
|
|
127
125
|
_superPropGet(DropdownMenuRoot2, "afterOpenPopper", this, 3)([]);
|
|
128
126
|
}
|
|
@@ -311,29 +309,28 @@ _defineProperty(DropdownMenuRoot, "nestedMenuInteraction", {
|
|
|
311
309
|
trigger: [["onClick", "onMouseEnter"], ["onClick", "onMouseLeave"]],
|
|
312
310
|
popper: [["onMouseEnter"], ["onMouseLeave"]]
|
|
313
311
|
});
|
|
314
|
-
function List(
|
|
315
|
-
var _ref2 = arguments[0],
|
|
316
|
-
var styles =
|
|
317
|
-
var SDropdownMenuList =
|
|
318
|
-
var SBar =
|
|
319
|
-
|
|
320
|
-
return _ref1 = sstyled(styles), /* @__PURE__ */ React.createElement(ListBoxContextProvider, _ref1.cn("ListBoxContextProvider", {}), /* @__PURE__ */ React.createElement(SDropdownMenuList, _ref1.cn("SDropdownMenuList", _objectSpread({}, assignProps({
|
|
312
|
+
function List(_ref22) {
|
|
313
|
+
var _ref2 = arguments[0], _ref13;
|
|
314
|
+
var styles = _ref22.styles, Children = _ref22.Children;
|
|
315
|
+
var SDropdownMenuList = ScrollAreaComponent;
|
|
316
|
+
var SBar = ScrollAreaComponent.Bar;
|
|
317
|
+
return _ref13 = sstyled(styles), /* @__PURE__ */ React.createElement(ListBoxContextProvider, _ref13.cn("ListBoxContextProvider", {}), /* @__PURE__ */ React.createElement(SDropdownMenuList, _ref13.cn("SDropdownMenuList", _objectSpread({}, assignProps({
|
|
321
318
|
"shadow": true,
|
|
322
319
|
"shadowSize": 16,
|
|
323
320
|
"shadowTheme": "light"
|
|
324
|
-
}, _ref2))), /* @__PURE__ */ React.createElement(
|
|
325
|
-
|
|
326
|
-
}
|
|
321
|
+
}, _ref2))), /* @__PURE__ */ React.createElement(ScrollAreaComponent.Container, {
|
|
322
|
+
tabIndex: void 0
|
|
323
|
+
}, /* @__PURE__ */ React.createElement(Children, _ref13.cn("Children", {}))), /* @__PURE__ */ React.createElement(SBar, _ref13.cn("SBar", {
|
|
327
324
|
"orientation": "horizontal"
|
|
328
|
-
})), /* @__PURE__ */ React.createElement(SBar,
|
|
325
|
+
})), /* @__PURE__ */ React.createElement(SBar, _ref13.cn("SBar", {
|
|
329
326
|
"orientation": "vertical"
|
|
330
327
|
}))));
|
|
331
328
|
}
|
|
332
|
-
function Actions(
|
|
333
|
-
var _ref3 = arguments[0],
|
|
334
|
-
var styles =
|
|
329
|
+
function Actions(_ref23) {
|
|
330
|
+
var _ref3 = arguments[0], _ref14;
|
|
331
|
+
var styles = _ref23.styles;
|
|
335
332
|
var SDropdownMenuActions = Flex;
|
|
336
|
-
return
|
|
333
|
+
return _ref14 = sstyled(styles), /* @__PURE__ */ React.createElement(SDropdownMenuActions, _ref14.cn("SDropdownMenuActions", _objectSpread({}, assignProps({}, _ref3))));
|
|
337
334
|
}
|
|
338
335
|
function Menu(props) {
|
|
339
336
|
var _ref4 = arguments[0];
|
|
@@ -351,16 +348,15 @@ function Menu(props) {
|
|
|
351
348
|
role: null
|
|
352
349
|
}), /* @__PURE__ */ React.createElement(DropdownMenu.List, assignProps({}, _ref4))));
|
|
353
350
|
}
|
|
354
|
-
function Item(
|
|
355
|
-
var _ref5 = arguments[0],
|
|
356
|
-
var id =
|
|
351
|
+
function Item(_ref24) {
|
|
352
|
+
var _ref5 = arguments[0], _ref15;
|
|
353
|
+
var id = _ref24.id, styles = _ref24.styles, disabled = _ref24.disabled, Children = _ref24.Children, forwardRef = _ref24.forwardRef, role = _ref24.role, tabIndex = _ref24.tabIndex, actionsRef = _ref24.actionsRef, ariaChecked = _ref24["aria-checked"];
|
|
357
354
|
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
358
355
|
var itemRef = React.useRef();
|
|
359
356
|
var _React$useState = React.useState(false), _React$useState2 = _slicedToArray(_React$useState, 2), highlighted = _React$useState2[0], setHighlighted = _React$useState2[1];
|
|
360
357
|
var menuItemContextValue = {
|
|
361
358
|
contentId: id,
|
|
362
|
-
ref: itemRef,
|
|
363
|
-
forwardRef,
|
|
359
|
+
ref: forkRef(forwardRef, itemRef),
|
|
364
360
|
role,
|
|
365
361
|
tabIndex,
|
|
366
362
|
ariaChecked,
|
|
@@ -410,30 +406,30 @@ function Item(_ref18) {
|
|
|
410
406
|
capture: true
|
|
411
407
|
});
|
|
412
408
|
};
|
|
413
|
-
});
|
|
414
|
-
return
|
|
409
|
+
}, [itemRef.current]);
|
|
410
|
+
return _ref15 = sstyled(styles), /* @__PURE__ */ React.createElement(menuItemContext.Provider, {
|
|
415
411
|
value: menuItemContextValue
|
|
416
|
-
}, /* @__PURE__ */ React.createElement(SDropdownMenuItemContainer,
|
|
417
|
-
"ref": advancedMode ? void 0 :
|
|
412
|
+
}, /* @__PURE__ */ React.createElement(SDropdownMenuItemContainer, _ref15.cn("SDropdownMenuItemContainer", _objectSpread({}, assignProps({
|
|
413
|
+
"ref": advancedMode ? void 0 : menuItemContextValue.ref,
|
|
418
414
|
"use:highlighted": !disabled && highlighted && lastInteraction.isKeyboard(),
|
|
419
415
|
"use:role": advancedMode ? void 0 : role,
|
|
420
416
|
"use:id": advancedMode ? void 0 : id,
|
|
421
417
|
"use:tabIndex": advancedMode ? void 0 : tabIndex,
|
|
422
418
|
"use:aria-checked": advancedMode ? void 0 : ariaChecked
|
|
423
|
-
}, _ref5))), /* @__PURE__ */ React.createElement(Children,
|
|
419
|
+
}, _ref5))), /* @__PURE__ */ React.createElement(Children, _ref15.cn("Children", {}))));
|
|
424
420
|
}
|
|
425
421
|
function Addon(props) {
|
|
426
|
-
var _ref6 = arguments[0],
|
|
422
|
+
var _ref6 = arguments[0], _ref16;
|
|
427
423
|
var SDropdownMenuItemAddon = Box;
|
|
428
|
-
return
|
|
424
|
+
return _ref16 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SDropdownMenuItemAddon, _ref16.cn("SDropdownMenuItemAddon", _objectSpread({}, assignProps({}, _ref6))));
|
|
429
425
|
}
|
|
430
426
|
function Trigger() {
|
|
431
427
|
var _ref7 = arguments[0];
|
|
432
428
|
return /* @__PURE__ */ React.createElement(Dropdown.Trigger, assignProps({}, _ref7));
|
|
433
429
|
}
|
|
434
|
-
function ItemContent(
|
|
435
|
-
var _ref8 = arguments[0],
|
|
436
|
-
var styles =
|
|
430
|
+
function ItemContent(_ref25) {
|
|
431
|
+
var _ref8 = arguments[0], _ref17;
|
|
432
|
+
var styles = _ref25.styles;
|
|
437
433
|
var SItemContent = Flex;
|
|
438
434
|
var ref = React.useRef();
|
|
439
435
|
var menuItemCtxValue = React.useContext(menuItemContext);
|
|
@@ -452,11 +448,11 @@ function ItemContent(_ref19) {
|
|
|
452
448
|
});
|
|
453
449
|
}
|
|
454
450
|
}, [menuItemCtxValue.ariaDescribes]);
|
|
455
|
-
return
|
|
451
|
+
return _ref17 = sstyled(styles), /* @__PURE__ */ React.createElement(SItemContent, _ref17.cn("SItemContent", _objectSpread({}, assignProps({
|
|
456
452
|
"role": menuItemCtxValue.role,
|
|
457
453
|
"id": menuItemCtxValue.contentId,
|
|
458
454
|
"tabIndex": menuItemCtxValue.tabIndex,
|
|
459
|
-
"ref": forkRef(menuItemCtxValue.ref,
|
|
455
|
+
"ref": forkRef(menuItemCtxValue.ref, ref),
|
|
460
456
|
"use:aria-describedby": _toConsumableArray(describedby).join(" "),
|
|
461
457
|
"aria-haspopup": menuItemCtxValue.hasSubMenu ? "true" : void 0,
|
|
462
458
|
"aria-expanded": subMenu,
|
|
@@ -466,27 +462,52 @@ function ItemContent(_ref19) {
|
|
|
466
462
|
"disabled": menuItemCtxValue.disabled
|
|
467
463
|
}, _ref8))));
|
|
468
464
|
}
|
|
469
|
-
function ItemContentText(
|
|
470
|
-
var _ref9 = arguments[0],
|
|
471
|
-
var styles =
|
|
465
|
+
function ItemContentText(_ref26) {
|
|
466
|
+
var _ref9 = arguments[0], _ref18;
|
|
467
|
+
var styles = _ref26.styles;
|
|
472
468
|
var SItemContentText = Text;
|
|
473
|
-
|
|
474
|
-
return _ref14 = sstyled(styles), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SItemContentText, _ref14.cn("SItemContentText", _objectSpread({}, assignProps({
|
|
475
|
-
"ellipsis": ellipsis,
|
|
476
|
-
"hint:triggerRef": menuItemCtxValue.ref,
|
|
477
|
-
"hint:placement": "right"
|
|
478
|
-
}, _ref9)))));
|
|
469
|
+
return _ref18 = sstyled(styles), /* @__PURE__ */ React.createElement(SItemContentText, _ref18.cn("SItemContentText", _objectSpread({}, assignProps({}, _ref9))));
|
|
479
470
|
}
|
|
480
|
-
function ItemHint(
|
|
481
|
-
var _ref0 = arguments[0],
|
|
482
|
-
var styles =
|
|
471
|
+
function ItemHint(_ref27) {
|
|
472
|
+
var _ref0 = arguments[0], _ref19;
|
|
473
|
+
var styles = _ref27.styles;
|
|
483
474
|
var SItemHint = Flex;
|
|
484
475
|
var _React$useContext = React.useContext(menuItemContext), hintId = _React$useContext.hintId;
|
|
485
|
-
return
|
|
476
|
+
return _ref19 = sstyled(styles), /* @__PURE__ */ React.createElement(SItemHint, _ref19.cn("SItemHint", _objectSpread({}, assignProps({
|
|
486
477
|
"id": hintId,
|
|
487
478
|
"aria-hidden": "true"
|
|
488
479
|
}, _ref0))));
|
|
489
480
|
}
|
|
481
|
+
function Hint(props) {
|
|
482
|
+
var _ref1 = arguments[0], _ref20;
|
|
483
|
+
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
484
|
+
return _ref20 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SDropdownMenuItemContainer, _ref20.cn("SDropdownMenuItemContainer", _objectSpread({}, assignProps({
|
|
485
|
+
"variant": "hint"
|
|
486
|
+
}, _ref1))));
|
|
487
|
+
}
|
|
488
|
+
function Title(props) {
|
|
489
|
+
var _ref10 = arguments[0], _ref21;
|
|
490
|
+
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
491
|
+
return _ref21 = sstyled(props.styles), /* @__PURE__ */ React.createElement(SDropdownMenuItemContainer, _ref21.cn("SDropdownMenuItemContainer", _objectSpread({}, assignProps({
|
|
492
|
+
"variant": "title"
|
|
493
|
+
}, _ref10))));
|
|
494
|
+
}
|
|
495
|
+
function Nesting(_ref28) {
|
|
496
|
+
var _ref11 = arguments[0];
|
|
497
|
+
var forwardRef = _ref28.forwardRef;
|
|
498
|
+
return /* @__PURE__ */ React.createElement(DropdownMenu.Item, assignProps({
|
|
499
|
+
"ref": forwardRef
|
|
500
|
+
}, _ref11));
|
|
501
|
+
}
|
|
502
|
+
function NestingTrigger(_ref29) {
|
|
503
|
+
var _ref12 = arguments[0];
|
|
504
|
+
var forwardRef = _ref29.forwardRef;
|
|
505
|
+
return /* @__PURE__ */ React.createElement(DropdownMenu.Item.Content, assignProps({
|
|
506
|
+
"tag": DropdownMenu.Trigger,
|
|
507
|
+
"ref": forwardRef,
|
|
508
|
+
"use:role": "menuitem"
|
|
509
|
+
}, _ref12));
|
|
510
|
+
}
|
|
490
511
|
var DropdownMenu = createComponent(DropdownMenuRoot, {
|
|
491
512
|
Trigger,
|
|
492
513
|
Popper: Dropdown.Popper,
|
|
@@ -500,6 +521,15 @@ var DropdownMenu = createComponent(DropdownMenuRoot, {
|
|
|
500
521
|
Text: ItemContentText,
|
|
501
522
|
Hint: ItemHint
|
|
502
523
|
}],
|
|
524
|
+
/**
|
|
525
|
+
* @deprecated. Use just Item. See examples on
|
|
526
|
+
*/
|
|
527
|
+
Nesting: [Nesting, {
|
|
528
|
+
Trigger: NestingTrigger,
|
|
529
|
+
Addon
|
|
530
|
+
}],
|
|
531
|
+
ItemTitle: Title,
|
|
532
|
+
ItemHint: Hint,
|
|
503
533
|
Group: Dropdown.Group
|
|
504
534
|
}, {
|
|
505
535
|
parent: [Dropdown]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hideScrollBarsFromScreenReadersContext } from "@semcore/
|
|
1
|
+
import { hideScrollBarsFromScreenReadersContext } from "@semcore/scroll-area";
|
|
2
2
|
import React from "react";
|
|
3
3
|
var ListBoxContextProvider = function ListBoxContextProvider2(_ref) {
|
|
4
4
|
var children = _ref.children;
|
|
@@ -4,8 +4,9 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
4
4
|
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
5
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
6
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import { sstyled, assignProps, Component
|
|
8
|
-
import {
|
|
7
|
+
import { createComponent, sstyled, assignProps, Component } from "@semcore/core";
|
|
8
|
+
import { Box } from "@semcore/base-components";
|
|
9
|
+
import ScrollAreaComponent from "@semcore/scroll-area";
|
|
9
10
|
import React from "react";
|
|
10
11
|
import { ListBoxContextProvider } from "./Context.mjs";
|
|
11
12
|
/*!__reshadow-styles__:"../style/dropdown-menu.shadow.css"*/
|
|
@@ -13,27 +14,26 @@ var style = (
|
|
|
13
14
|
/*__reshadow_css_start__*/
|
|
14
15
|
(sstyled.insert(
|
|
15
16
|
/*__inner_css_start__*/
|
|
16
|
-
|
|
17
|
+
".___SDropdownMenuList_1ahmt_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, rgba(1, 5, 0, 0.899))}.___SDropdownMenuList_1ahmt_gg_ .___SBar_1ahmt_gg_{z-index:3}.___SDropdownMenuList_1ahmt_gg_ .___SShadowHorizontal_1ahmt_gg_:after,.___SDropdownMenuList_1ahmt_gg_ .___SShadowHorizontal_1ahmt_gg_:before,.___SDropdownMenuList_1ahmt_gg_ .___SShadowVertical_1ahmt_gg_:after,.___SDropdownMenuList_1ahmt_gg_ .___SShadowVertical_1ahmt_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1ahmt_gg_ .___SItemContent_1ahmt_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1ahmt_gg_.__nesting-trigger_1ahmt_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1ahmt_gg_,.___SItemContentText_1ahmt_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1ahmt_gg_:first-child,.___SItemContentText_1ahmt_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1ahmt_gg_:last-child,.___SItemContentText_1ahmt_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1ahmt_gg_,.___SDropdownMenuNesting_1ahmt_gg_._size_l_1ahmt_gg_,.___SDropdownMenuNesting_1ahmt_gg_._size_m_1ahmt_gg_{padding:0}.___SDropdownMenuNesting_1ahmt_gg_.__highlighted_1ahmt_gg_{z-index:1;outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469));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}@supports (color:color(display-p3 0 0 0%)){.___SDropdownMenuNesting_1ahmt_gg_.__highlighted_1ahmt_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469))}@media (color-gamut:p3){.___SDropdownMenuNesting_1ahmt_gg_.__highlighted_1ahmt_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, color(display-p3 0.03256 0.12227 0.83249 / 0.469))}}}.___SDropdownNestingItem_1ahmt_gg_._size_l_1ahmt_gg_,.___SDropdownNestingItem_1ahmt_gg_._size_m_1ahmt_gg_{padding-right:0}.___SDropdownNestingItem_1ahmt_gg_ .___SDropdownMenuItemContainer_1ahmt_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1ahmt_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@supports (color:color(display-p3 0 0 0%)){.___SItemHint_1ahmt_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SItemHint_1ahmt_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}",
|
|
17
18
|
/*__inner_css_end__*/
|
|
18
|
-
"
|
|
19
|
+
"1ahmt_gg_"
|
|
19
20
|
), /*__reshadow_css_end__*/
|
|
20
21
|
{
|
|
21
|
-
"__SDropdownMenuItemContainer": "
|
|
22
|
-
"_nesting-trigger": "__nesting-
|
|
23
|
-
"__SDropdownMenuNesting": "
|
|
24
|
-
"_size_l": "
|
|
25
|
-
"_size_m": "
|
|
26
|
-
"_highlighted": "
|
|
27
|
-
"__SDropdownNestingItem": "
|
|
28
|
-
"__SItemHint": "
|
|
29
|
-
"__SDropdownMenuList": "
|
|
30
|
-
"__SBar": "
|
|
31
|
-
"__SShadowHorizontal": "
|
|
32
|
-
"__SShadowVertical": "
|
|
33
|
-
"__SItemContent": "
|
|
34
|
-
"__SDropdownMenuItemAddon": "
|
|
35
|
-
"__SItemContentText": "
|
|
36
|
-
"__SScrollContainer": "___SScrollContainer_1d74h_gg_"
|
|
22
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1ahmt_gg_",
|
|
23
|
+
"_nesting-trigger": "__nesting-trigger_1ahmt_gg_",
|
|
24
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1ahmt_gg_",
|
|
25
|
+
"_size_l": "_size_l_1ahmt_gg_",
|
|
26
|
+
"_size_m": "_size_m_1ahmt_gg_",
|
|
27
|
+
"_highlighted": "__highlighted_1ahmt_gg_",
|
|
28
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1ahmt_gg_",
|
|
29
|
+
"__SItemHint": "___SItemHint_1ahmt_gg_",
|
|
30
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1ahmt_gg_",
|
|
31
|
+
"__SBar": "___SBar_1ahmt_gg_",
|
|
32
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1ahmt_gg_",
|
|
33
|
+
"__SShadowVertical": "___SShadowVertical_1ahmt_gg_",
|
|
34
|
+
"__SItemContent": "___SItemContent_1ahmt_gg_",
|
|
35
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1ahmt_gg_",
|
|
36
|
+
"__SItemContentText": "___SItemContentText_1ahmt_gg_"
|
|
37
37
|
})
|
|
38
38
|
);
|
|
39
39
|
var VirtualListRoot = /* @__PURE__ */ (function(_Component) {
|
|
@@ -82,8 +82,8 @@ var VirtualListRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
82
82
|
key: "render",
|
|
83
83
|
value: function render() {
|
|
84
84
|
var _ref = this.asProps, _ref2, _this$listRef$current, _this$listRef$current2;
|
|
85
|
-
var SDropdownMenuList =
|
|
86
|
-
var SBar =
|
|
85
|
+
var SDropdownMenuList = ScrollAreaComponent;
|
|
86
|
+
var SBar = ScrollAreaComponent.Bar;
|
|
87
87
|
var _this$state = this.state, scrollDirection = _this$state.scrollDirection, scrollTop = _this$state.scrollTop;
|
|
88
88
|
var _this$asProps2 = this.asProps, rows = _this$asProps2.rows, rowHeight = _this$asProps2.rowHeight, rowsBuffer = _this$asProps2.rowsBuffer, styles = _this$asProps2.styles, RenderRow = _this$asProps2.renderRow, customData = _this$asProps2.customData;
|
|
89
89
|
var offsetHeight = (_this$listRef$current = (_this$listRef$current2 = this.listRef.current) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.offsetHeight) !== null && _this$listRef$current !== void 0 ? _this$listRef$current : 0;
|
|
@@ -101,7 +101,7 @@ var VirtualListRoot = /* @__PURE__ */ (function(_Component) {
|
|
|
101
101
|
"onScroll": this.handleScroll,
|
|
102
102
|
"data-is-virtual": "true",
|
|
103
103
|
"ref": this.listRef
|
|
104
|
-
}, _ref))), /* @__PURE__ */ React.createElement(
|
|
104
|
+
}, _ref))), /* @__PURE__ */ React.createElement(ScrollAreaComponent.Container, {
|
|
105
105
|
ref: this.containerRef,
|
|
106
106
|
tabIndex: void 0,
|
|
107
107
|
h: rows.length * rowHeight
|
|
@@ -12,19 +12,19 @@ SDropdownMenuList {
|
|
|
12
12
|
z-index: 3;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
SShadowHorizontal {
|
|
16
|
+
|
|
17
|
+
&:before,
|
|
18
|
+
&:after {
|
|
19
|
+
border-radius: var(--intergalactic-control-rounded, 6px);
|
|
21
20
|
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
SShadowVertical {
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
border-radius: var(--intergalactic-control-rounded, 6px);
|
|
27
|
-
}
|
|
25
|
+
&:before,
|
|
26
|
+
&:after {
|
|
27
|
+
border-radius: var(--intergalactic-control-rounded, 6px);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -41,7 +41,7 @@ SDropdownMenuItemContainer[nesting-trigger] {
|
|
|
41
41
|
|
|
42
42
|
SDropdownMenuItemAddon,
|
|
43
43
|
SItemContentText {
|
|
44
|
-
display: inline-flex;
|
|
44
|
+
display: inline-flex;
|
|
45
45
|
margin-left: var(--intergalactic-spacing-1x, 4px);
|
|
46
46
|
margin-right: var(--intergalactic-spacing-1x, 4px);
|
|
47
47
|
|
|
@@ -81,9 +81,3 @@ SDropdownNestingItem SDropdownMenuItemContainer {
|
|
|
81
81
|
SItemHint {
|
|
82
82
|
color: var(--intergalactic-text-secondary, oklch(0.088 0.026 147.7 / 0.583));
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
SScrollContainer {
|
|
86
|
-
&:has([data-ui-name="DropdownMenu.Group"][data-sticky="true"]) {
|
|
87
|
-
overscroll-behavior: none;
|
|
88
|
-
}
|
|
89
|
-
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PropGetterFn, Intergalactic } from '@semcore/core';
|
|
1
|
+
import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';
|
|
3
2
|
import type {
|
|
4
3
|
DropdownContext,
|
|
5
4
|
DropdownProps,
|
|
@@ -8,12 +7,17 @@ import type {
|
|
|
8
7
|
DropdownPopperAriaProps,
|
|
9
8
|
} from '@semcore/dropdown';
|
|
10
9
|
import type Dropdown from '@semcore/dropdown';
|
|
10
|
+
import type { Box, BoxProps, FlexProps, Flex } from '@semcore/flex-box';
|
|
11
|
+
import type { eventInteraction } from '@semcore/popper';
|
|
12
|
+
import type { ScrollAreaProps } from '@semcore/scroll-area';
|
|
11
13
|
import type { Text } from '@semcore/typography';
|
|
12
14
|
|
|
13
15
|
import type { VirtualList, RenderRowProps } from './components/VirtualList';
|
|
14
16
|
|
|
15
17
|
export type DropdownMenuSize = 'm' | 'l';
|
|
16
18
|
|
|
19
|
+
/** @deprecated */
|
|
20
|
+
export interface IDropdownMenuProps extends DropdownMenuProps, UnknownProperties {}
|
|
17
21
|
export type DropdownMenuProps = DropdownProps & {
|
|
18
22
|
/**
|
|
19
23
|
* Set role `menuitemradio` (or `menuitemcheckbox` if `multiselect`) for Dropdown.Item
|
|
@@ -54,6 +58,8 @@ export type DropdownMenuProps = DropdownProps & {
|
|
|
54
58
|
itemsCount?: number;
|
|
55
59
|
};
|
|
56
60
|
|
|
61
|
+
/** @deprecated */
|
|
62
|
+
export interface IDropdownMenuListProps extends DropdownMenuListProps, UnknownProperties {}
|
|
57
63
|
export type DropdownMenuListProps = BoxProps &
|
|
58
64
|
ScrollAreaProps & {
|
|
59
65
|
/**
|
|
@@ -63,8 +69,12 @@ export type DropdownMenuListProps = BoxProps &
|
|
|
63
69
|
size?: DropdownMenuSize;
|
|
64
70
|
};
|
|
65
71
|
|
|
72
|
+
/** @deprecated */
|
|
73
|
+
export interface IDropdownMenuMenuProps extends DropdownMenuMenuProps, UnknownProperties {}
|
|
66
74
|
export type DropdownMenuMenuProps = DropdownMenuListProps & {};
|
|
67
75
|
|
|
76
|
+
/** @deprecated */
|
|
77
|
+
export interface IDropdownMenuItemProps extends DropdownMenuItemProps, UnknownProperties {}
|
|
68
78
|
export type DropdownMenuItemProps = FlexProps & {
|
|
69
79
|
/**
|
|
70
80
|
* Enables selected state. For selectable dropdowns only.
|
|
@@ -74,6 +84,16 @@ export type DropdownMenuItemProps = FlexProps & {
|
|
|
74
84
|
* Disables item
|
|
75
85
|
*/
|
|
76
86
|
disabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Adds focus styles around
|
|
89
|
+
* @deprecated set focus manually by `.focus()` method to the same behaviour
|
|
90
|
+
*/
|
|
91
|
+
highlighted?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Disables hover state
|
|
94
|
+
* @deprecated use `disabled` instead
|
|
95
|
+
*/
|
|
96
|
+
notInteractive?: boolean;
|
|
77
97
|
/**
|
|
78
98
|
* Size of the component
|
|
79
99
|
* @default m
|
|
@@ -85,6 +105,30 @@ export type DropdownMenuItemProps = FlexProps & {
|
|
|
85
105
|
index?: number;
|
|
86
106
|
};
|
|
87
107
|
|
|
108
|
+
/** @deprecated */
|
|
109
|
+
export interface IDropdownMenuItemHintProps extends DropdownMenuItemHintProps, UnknownProperties {}
|
|
110
|
+
export type DropdownMenuItemHintProps = FlexProps & {
|
|
111
|
+
/**
|
|
112
|
+
* Size of the component
|
|
113
|
+
* @default m
|
|
114
|
+
*/
|
|
115
|
+
size?: DropdownMenuSize;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** @deprecated */
|
|
119
|
+
export interface IDropdownMenuItemTitleProps
|
|
120
|
+
extends DropdownMenuItemTitleProps,
|
|
121
|
+
UnknownProperties {}
|
|
122
|
+
export type DropdownMenuItemTitleProps = FlexProps & {
|
|
123
|
+
/**
|
|
124
|
+
* Size of the component
|
|
125
|
+
* @default m
|
|
126
|
+
*/
|
|
127
|
+
size?: DropdownMenuSize;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** @deprecated */
|
|
131
|
+
export interface IDropdownMenuContext extends DropdownMenuContext, UnknownProperties {}
|
|
88
132
|
export type DropdownMenuContext = DropdownContext & {
|
|
89
133
|
/**
|
|
90
134
|
* Tracks which menu item is currently highlighted/focused for keyboard navigation
|
|
@@ -108,6 +152,8 @@ export type DropdownMenuContext = DropdownContext & {
|
|
|
108
152
|
getItemTitleProps: PropGetterFn;
|
|
109
153
|
};
|
|
110
154
|
|
|
155
|
+
/** @deprecated */
|
|
156
|
+
export interface IDropdownMenuHandlers extends DropdownMenuHandlers, UnknownProperties {}
|
|
111
157
|
export type DropdownMenuHandlers = DropdownHandlers & {
|
|
112
158
|
highlightedIndex: (index: number) => void;
|
|
113
159
|
};
|
|
@@ -151,11 +197,41 @@ declare const DropdownMenu: Intergalactic.Component<
|
|
|
151
197
|
Text: typeof Text;
|
|
152
198
|
Hint: typeof Flex;
|
|
153
199
|
};
|
|
154
|
-
|
|
200
|
+
/**
|
|
201
|
+
* @deprecated Use Group with title prop
|
|
202
|
+
*/
|
|
203
|
+
ItemTitle: Intergalactic.Component<'div', DropdownMenuItemTitleProps>;
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated Use prop subTitle on Group or Item component
|
|
206
|
+
*/
|
|
207
|
+
ItemHint: Intergalactic.Component<'div', DropdownMenuItemHintProps>;
|
|
155
208
|
Group: typeof Dropdown.Group;
|
|
156
209
|
|
|
157
210
|
VirtualList: typeof VirtualList;
|
|
158
211
|
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated Use Item instead of Nesting
|
|
214
|
+
*/
|
|
215
|
+
Nesting: Intergalactic.Component<
|
|
216
|
+
'div',
|
|
217
|
+
DropdownMenuItemProps,
|
|
218
|
+
DropdownMenuContext,
|
|
219
|
+
[handlers: DropdownMenuHandlers]
|
|
220
|
+
> & {
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated Use Item instead of Nesting
|
|
223
|
+
*/
|
|
224
|
+
Trigger: Intergalactic.Component<'div', DropdownMenuItemProps>;
|
|
225
|
+
/**
|
|
226
|
+
* @deprecated Use Item instead of Nesting
|
|
227
|
+
*/
|
|
228
|
+
Item: Intergalactic.Component<'div', DropdownMenuItemProps>;
|
|
229
|
+
/**
|
|
230
|
+
* @deprecated Use Item instead of Nesting
|
|
231
|
+
*/
|
|
232
|
+
Addon: typeof Box;
|
|
233
|
+
};
|
|
234
|
+
|
|
159
235
|
selectedIndexContext: React.Context<number>;
|
|
160
236
|
nestedMenuInteraction: eventInteraction;
|
|
161
237
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semcore/dropdown-menu",
|
|
3
3
|
"description": "Semrush DropdownMenu Component",
|
|
4
|
-
"version": "16.3.
|
|
4
|
+
"version": "16.3.1",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es6/index.js",
|
|
7
7
|
"typings": "lib/types/index.d.ts",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"types": "./lib/types/index.d.ts"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@semcore/button": "16.1.
|
|
18
|
-
"@semcore/dropdown": "16.2.
|
|
19
|
-
"@semcore/icon": "16.8.
|
|
20
|
-
"@semcore/typography": "16.4.
|
|
21
|
-
"@semcore/popper": "16.1.
|
|
22
|
-
"@semcore/flex-box": "16.1.
|
|
23
|
-
"@semcore/scroll-area": "16.1.
|
|
17
|
+
"@semcore/button": "16.1.1",
|
|
18
|
+
"@semcore/dropdown": "16.2.1",
|
|
19
|
+
"@semcore/icon": "16.8.1",
|
|
20
|
+
"@semcore/typography": "16.4.1",
|
|
21
|
+
"@semcore/popper": "16.1.1",
|
|
22
|
+
"@semcore/flex-box": "16.1.1",
|
|
23
|
+
"@semcore/scroll-area": "16.1.1",
|
|
24
24
|
"classnames": "2.2.6"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"@types/classnames": "2.2.6",
|
|
36
36
|
"@semcore/core": "16.6.0",
|
|
37
37
|
"@semcore/testing-utils": "1.0.0",
|
|
38
|
-
"@semcore/
|
|
39
|
-
"@semcore/
|
|
40
|
-
"@semcore/icon": "16.8.
|
|
38
|
+
"@semcore/base-trigger": "16.5.1",
|
|
39
|
+
"@semcore/button": "16.1.1",
|
|
40
|
+
"@semcore/icon": "16.8.1"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "pnpm semcore-builder --source=js,ts && pnpm vite build"
|