@semcore/dropdown-menu 16.1.14-prerelease.1 → 16.2.0-prerelease.0
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 +10 -0
- package/lib/cjs/DropdownMenu.js +107 -67
- package/lib/cjs/DropdownMenu.js.map +1 -1
- package/lib/cjs/components/Context.js +16 -0
- package/lib/cjs/components/Context.js.map +1 -0
- package/lib/cjs/components/VirtualList.js +141 -0
- package/lib/cjs/components/VirtualList.js.map +1 -0
- package/lib/cjs/index.d.js.map +1 -1
- package/lib/es6/DropdownMenu.js +102 -62
- package/lib/es6/DropdownMenu.js.map +1 -1
- package/lib/es6/components/Context.js +9 -0
- package/lib/es6/components/Context.js.map +1 -0
- package/lib/es6/components/VirtualList.js +136 -0
- package/lib/es6/components/VirtualList.js.map +1 -0
- package/lib/es6/index.d.js.map +1 -1
- package/lib/esm/DropdownMenu.mjs +82 -50
- package/lib/esm/components/Context.mjs +11 -0
- package/lib/esm/components/VirtualList.mjs +132 -0
- package/lib/types/components/Context.d.ts +2 -0
- package/lib/types/components/VirtualList.d.ts +25 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +42 -0
- package/package.json +11 -11
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.VirtualList = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
var _core = require("@semcore/core");
|
|
15
|
+
var _baseComponents = require("@semcore/base-components");
|
|
16
|
+
var _scrollArea = _interopRequireDefault(require("@semcore/scroll-area"));
|
|
17
|
+
var _react = _interopRequireDefault(require("react"));
|
|
18
|
+
var _Context = require("./Context");
|
|
19
|
+
/*!__reshadow-styles__:"../style/dropdown-menu.shadow.css"*/
|
|
20
|
+
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SDropdownMenuList_1d1ud_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_1d1ud_gg_ .___SBar_1d1ud_gg_{z-index:3}.___SDropdownMenuList_1d1ud_gg_ .___SShadowHorizontal_1d1ud_gg_:after,.___SDropdownMenuList_1d1ud_gg_ .___SShadowHorizontal_1d1ud_gg_:before,.___SDropdownMenuList_1d1ud_gg_ .___SShadowVertical_1d1ud_gg_:after,.___SDropdownMenuList_1d1ud_gg_ .___SShadowVertical_1d1ud_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1d1ud_gg_ .___SItemContent_1d1ud_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1d1ud_gg_.__nesting-trigger_1d1ud_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1d1ud_gg_,.___SItemContentText_1d1ud_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1d1ud_gg_:first-child,.___SItemContentText_1d1ud_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1d1ud_gg_:last-child,.___SItemContentText_1d1ud_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1d1ud_gg_,.___SDropdownMenuNesting_1d1ud_gg_._size_l_1d1ud_gg_,.___SDropdownMenuNesting_1d1ud_gg_._size_m_1d1ud_gg_{padding:0}.___SDropdownMenuNesting_1d1ud_gg_.__highlighted_1d1ud_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_1d1ud_gg_._size_l_1d1ud_gg_,.___SDropdownNestingItem_1d1ud_gg_._size_m_1d1ud_gg_{padding-right:0}.___SDropdownNestingItem_1d1ud_gg_ .___SDropdownMenuItemContainer_1d1ud_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1d1ud_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}", /*__inner_css_end__*/"1d1ud_gg_"),
|
|
21
|
+
/*__reshadow_css_end__*/
|
|
22
|
+
{
|
|
23
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1d1ud_gg_",
|
|
24
|
+
"_nesting-trigger": "__nesting-trigger_1d1ud_gg_",
|
|
25
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1d1ud_gg_",
|
|
26
|
+
"_size_l": "_size_l_1d1ud_gg_",
|
|
27
|
+
"_size_m": "_size_m_1d1ud_gg_",
|
|
28
|
+
"_highlighted": "__highlighted_1d1ud_gg_",
|
|
29
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1d1ud_gg_",
|
|
30
|
+
"__SItemHint": "___SItemHint_1d1ud_gg_",
|
|
31
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1d1ud_gg_",
|
|
32
|
+
"__SBar": "___SBar_1d1ud_gg_",
|
|
33
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1d1ud_gg_",
|
|
34
|
+
"__SShadowVertical": "___SShadowVertical_1d1ud_gg_",
|
|
35
|
+
"__SItemContent": "___SItemContent_1d1ud_gg_",
|
|
36
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1d1ud_gg_",
|
|
37
|
+
"__SItemContentText": "___SItemContentText_1d1ud_gg_"
|
|
38
|
+
});
|
|
39
|
+
var VirtualListRoot = /*#__PURE__*/function (_Component) {
|
|
40
|
+
function VirtualListRoot() {
|
|
41
|
+
var _this;
|
|
42
|
+
(0, _classCallCheck2["default"])(this, VirtualListRoot);
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
44
|
+
args[_key] = arguments[_key];
|
|
45
|
+
}
|
|
46
|
+
_this = (0, _callSuper2["default"])(this, VirtualListRoot, [].concat(args));
|
|
47
|
+
(0, _defineProperty2["default"])(_this, "containerRef", /*#__PURE__*/_react["default"].createRef());
|
|
48
|
+
(0, _defineProperty2["default"])(_this, "listRef", /*#__PURE__*/_react["default"].createRef());
|
|
49
|
+
(0, _defineProperty2["default"])(_this, "state", {
|
|
50
|
+
scrollTop: 0,
|
|
51
|
+
scrollDirection: 'down'
|
|
52
|
+
});
|
|
53
|
+
(0, _defineProperty2["default"])(_this, "handleScroll", function (e) {
|
|
54
|
+
if (e.target instanceof HTMLElement) {
|
|
55
|
+
var scrollDirection = e.target.scrollTop > _this.state.scrollTop ? 'down' : 'up';
|
|
56
|
+
_this.setState({
|
|
57
|
+
scrollDirection: scrollDirection,
|
|
58
|
+
scrollTop: e.target.scrollTop
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return _this;
|
|
63
|
+
}
|
|
64
|
+
(0, _inherits2["default"])(VirtualListRoot, _Component);
|
|
65
|
+
return (0, _createClass2["default"])(VirtualListRoot, [{
|
|
66
|
+
key: "componentDidMount",
|
|
67
|
+
value: function componentDidMount() {
|
|
68
|
+
var _this2 = this;
|
|
69
|
+
var _this$asProps = this.asProps,
|
|
70
|
+
index = _this$asProps.index,
|
|
71
|
+
rowHeight = _this$asProps.rowHeight;
|
|
72
|
+
setTimeout(function () {
|
|
73
|
+
var _this2$listRef$curren, _this2$listRef$curren2, _this2$containerRef$c;
|
|
74
|
+
var listHeight = ((_this2$listRef$curren = (_this2$listRef$curren2 = _this2.listRef.current) === null || _this2$listRef$curren2 === void 0 ? void 0 : _this2$listRef$curren2.getBoundingClientRect().height) !== null && _this2$listRef$curren !== void 0 ? _this2$listRef$curren : 0) / 2;
|
|
75
|
+
(_this2$containerRef$c = _this2.containerRef.current) === null || _this2$containerRef$c === void 0 || _this2$containerRef$c.scrollTo({
|
|
76
|
+
top: index * rowHeight - listHeight + rowHeight / 2
|
|
77
|
+
});
|
|
78
|
+
}, 10); // 10 for correct work in safari
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "render",
|
|
82
|
+
value: function render() {
|
|
83
|
+
var _ref = this.asProps,
|
|
84
|
+
_ref2;
|
|
85
|
+
var SDropdownMenuList = _scrollArea["default"];
|
|
86
|
+
var SBar = _scrollArea["default"].Bar;
|
|
87
|
+
var _this$state = this.state,
|
|
88
|
+
scrollDirection = _this$state.scrollDirection,
|
|
89
|
+
scrollTop = _this$state.scrollTop;
|
|
90
|
+
var _this$asProps2 = this.asProps,
|
|
91
|
+
rows = _this$asProps2.rows,
|
|
92
|
+
rowHeight = _this$asProps2.rowHeight,
|
|
93
|
+
rowsBuffer = _this$asProps2.rowsBuffer,
|
|
94
|
+
styles = _this$asProps2.styles,
|
|
95
|
+
RenderRow = _this$asProps2.renderRow,
|
|
96
|
+
customData = _this$asProps2.customData;
|
|
97
|
+
var offsetHeight = 0;
|
|
98
|
+
var prevPrepared = scrollDirection === 'up' ? rowsBuffer : 6;
|
|
99
|
+
var nextPrepared = scrollDirection === 'up' ? 6 : rowsBuffer;
|
|
100
|
+
var startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);
|
|
101
|
+
var lastIndex = scrollDirection === 'up' && scrollTop === 0 ? rowsBuffer : Math.min(Math.ceil((scrollTop + offsetHeight) / rowHeight) + nextPrepared, rows.length);
|
|
102
|
+
var rowsToRender = rows.slice(startIndex, lastIndex);
|
|
103
|
+
var rowMarginTop = rowHeight * startIndex;
|
|
104
|
+
var rowMarginBottom = rowHeight * (rows.length - lastIndex);
|
|
105
|
+
return _ref2 = (0, _core.sstyled)(styles), /*#__PURE__*/_react["default"].createElement(_Context.ListBoxContextProvider, _ref2.cn("ListBoxContextProvider", {}), /*#__PURE__*/_react["default"].createElement(SDropdownMenuList, _ref2.cn("SDropdownMenuList", (0, _objectSpread2["default"])({}, (0, _core.assignProps)({
|
|
106
|
+
"shadow": true,
|
|
107
|
+
"shadowSize": 16,
|
|
108
|
+
"shadowTheme": 'light',
|
|
109
|
+
"onScroll": this.handleScroll,
|
|
110
|
+
"data-is-virtual": 'true',
|
|
111
|
+
"ref": this.listRef
|
|
112
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement(_scrollArea["default"].Container, {
|
|
113
|
+
ref: this.containerRef,
|
|
114
|
+
tabIndex: undefined,
|
|
115
|
+
h: rows.length * rowHeight
|
|
116
|
+
}, /*#__PURE__*/_react["default"].createElement(_baseComponents.Box, _ref2.cn("Box", {
|
|
117
|
+
"h": rowMarginTop
|
|
118
|
+
})), rowsToRender.map(function (item, index) {
|
|
119
|
+
return /*#__PURE__*/_react["default"].createElement(RenderRow, {
|
|
120
|
+
key: startIndex + index,
|
|
121
|
+
row: item,
|
|
122
|
+
index: startIndex + index,
|
|
123
|
+
data: customData
|
|
124
|
+
});
|
|
125
|
+
}), /*#__PURE__*/_react["default"].createElement(_baseComponents.Box, _ref2.cn("Box", {
|
|
126
|
+
"h": rowMarginBottom
|
|
127
|
+
}))), /*#__PURE__*/_react["default"].createElement(SBar, _ref2.cn("SBar", {
|
|
128
|
+
"orientation": 'horizontal'
|
|
129
|
+
})), /*#__PURE__*/_react["default"].createElement(SBar, _ref2.cn("SBar", {
|
|
130
|
+
"orientation": 'vertical'
|
|
131
|
+
}))));
|
|
132
|
+
}
|
|
133
|
+
}]);
|
|
134
|
+
}(_core.Component);
|
|
135
|
+
(0, _defineProperty2["default"])(VirtualListRoot, "displayName", 'VirtualList');
|
|
136
|
+
(0, _defineProperty2["default"])(VirtualListRoot, "style", style);
|
|
137
|
+
(0, _defineProperty2["default"])(VirtualListRoot, "defaultProps", {
|
|
138
|
+
rowsBuffer: 10
|
|
139
|
+
});
|
|
140
|
+
var VirtualList = exports.VirtualList = (0, _core.createComponent)(VirtualListRoot);
|
|
141
|
+
//# sourceMappingURL=VirtualList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualList.js","names":["_core","require","_baseComponents","_scrollArea","_interopRequireDefault","_react","_Context","style","sstyled","insert","VirtualListRoot","_Component","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","React","createRef","scrollTop","scrollDirection","e","target","HTMLElement","state","setState","_inherits2","_createClass2","key","value","componentDidMount","_this2","_this$asProps","asProps","index","rowHeight","setTimeout","_this2$listRef$curren","_this2$listRef$curren2","_this2$containerRef$c","listHeight","listRef","current","getBoundingClientRect","height","containerRef","scrollTo","top","render","_ref","_ref2","SDropdownMenuList","ScrollAreaComponent","SBar","Bar","_this$state","_this$asProps2","rows","rowsBuffer","styles","RenderRow","renderRow","customData","offsetHeight","prevPrepared","nextPrepared","startIndex","Math","max","floor","lastIndex","min","ceil","rowsToRender","slice","rowMarginTop","rowMarginBottom","createElement","ListBoxContextProvider","cn","_objectSpread2","assignProps","handleScroll","Container","ref","tabIndex","undefined","h","Box","map","item","row","data","Component","VirtualList","exports","createComponent"],"sources":["../../../src/components/VirtualList.tsx"],"sourcesContent":["import { Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { Root, Component, createComponent, sstyled } from '@semcore/core';\nimport ScrollAreaComponent from '@semcore/scroll-area';\nimport React from 'react';\n\nimport { ListBoxContextProvider } from './Context';\nimport style from '../style/dropdown-menu.shadow.css';\n\nexport type RenderRowProps<T, D> = {\n index: number;\n row: T;\n data: D;\n};\n\ntype VirtualListProps<T, D extends object> = {\n /** List of all rows in ddMenu */\n rows: T[];\n /** Method for render row, it's better to wrap it via React.memo */\n renderRow: (props: RenderRowProps<T, D>) => React.ReactNode;\n /** The height of row. For now, you should calculate it on your side. */\n rowHeight: number;\n /** The buffer of rows out of visible rows\n * @default 10\n */\n rowsBuffer?: number;\n /** Some custom data for each renderRow function */\n customData: D;\n};\n\ntype State = {\n scrollTop: number;\n scrollDirection: 'up' | 'down';\n};\n\nclass VirtualListRoot<T = string, D extends object = {}> extends Component<VirtualListProps<T, D>, {}, State, [], { rowsBuffer: number; index: number }> {\n static displayName = 'VirtualList';\n static style = style;\n\n static defaultProps = {\n rowsBuffer: 10,\n };\n\n containerRef = React.createRef<HTMLDivElement>();\n listRef = React.createRef<HTMLDivElement>();\n\n state: State = {\n scrollTop: 0,\n scrollDirection: 'down',\n };\n\n componentDidMount() {\n const { index, rowHeight } = this.asProps;\n\n setTimeout(() => {\n const listHeight = (this.listRef.current?.getBoundingClientRect().height ?? 0) / 2;\n this.containerRef.current?.scrollTo({ top: index * rowHeight - listHeight + rowHeight / 2 });\n }, 10); // 10 for correct work in safari\n }\n\n handleScroll = (e: React.SyntheticEvent<HTMLDivElement>) => {\n if (e.target instanceof HTMLElement) {\n const scrollDirection = e.target.scrollTop > this.state.scrollTop ? 'down' : 'up';\n\n this.setState({\n scrollDirection,\n scrollTop: e.target.scrollTop,\n });\n }\n };\n\n render() {\n const SDropdownMenuList = Root;\n const SBar = ScrollAreaComponent.Bar;\n\n const { scrollDirection, scrollTop } = this.state;\n const { rows, rowHeight, rowsBuffer, styles, renderRow: RenderRow, customData } = this.asProps;\n\n const offsetHeight = 0;\n const prevPrepared = scrollDirection === 'up' ? rowsBuffer : 6;\n const nextPrepared = scrollDirection === 'up' ? 6 : rowsBuffer;\n\n const startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);\n\n const lastIndex = scrollDirection === 'up' && scrollTop === 0\n ? rowsBuffer\n : Math.min(\n Math.ceil((scrollTop + offsetHeight) / rowHeight) + nextPrepared,\n rows.length,\n );\n\n const rowsToRender = rows.slice(startIndex, lastIndex);\n const rowMarginTop = rowHeight * startIndex;\n const rowMarginBottom = rowHeight * (rows.length - lastIndex);\n\n return sstyled(styles)(\n <ListBoxContextProvider>\n <SDropdownMenuList\n render={ScrollAreaComponent}\n shadow={true}\n shadowSize={16}\n shadowTheme='light'\n onScroll={this.handleScroll}\n data-is-virtual='true'\n ref={this.listRef}\n >\n <ScrollAreaComponent.Container ref={this.containerRef} tabIndex={undefined} h={rows.length * rowHeight}>\n <Box h={rowMarginTop} />\n {rowsToRender.map((item, index) => {\n return <RenderRow key={startIndex + index} row={item} index={startIndex + index} data={customData} />;\n })}\n <Box h={rowMarginBottom} />\n </ScrollAreaComponent.Container>\n <SBar orientation='horizontal' />\n <SBar orientation='vertical' />\n </SDropdownMenuList>\n </ListBoxContextProvider>,\n );\n }\n}\n\nexport type VirtualListComponent = (<\n T = string,\n D extends object = {},\n>(\n props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<typeof Box, 'div', VirtualListProps<T, D>>, 'tag' | 'children'>\n) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<typeof Box, 'div', VirtualListProps<any, any>>;\n\nexport const VirtualList = createComponent(VirtualListRoot) as VirtualListComponent;\n"],"mappings":";;;;;;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAFA,IAAAC,eAAA,GAAAD,OAAA;AAGA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AAAmD;AAAA,IAAAM,KAAA,8BAAAP,KAAA,CAAAQ,O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CAAAD,WAAA,GAAG,IAAAE,qBAAe,EAAC5F,eAAe,CAAyB","ignoreList":[]}
|
package/lib/cjs/index.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport type {\n DropdownContext,\n DropdownProps,\n DropdownHandlers,\n DropdownTriggerProps,\n DropdownPopperAriaProps,\n} from '@semcore/dropdown';\nimport type Dropdown from '@semcore/dropdown';\nimport type { Box, BoxProps, FlexProps, Flex } from '@semcore/flex-box';\nimport type { eventInteraction } from '@semcore/popper';\nimport type { ScrollAreaProps } from '@semcore/scroll-area';\nimport type { Text } from '@semcore/typography';\n\nexport type DropdownMenuSize = 'm' | 'l';\n\n/** @deprecated */\nexport interface IDropdownMenuProps extends DropdownMenuProps, UnknownProperties {}\nexport type DropdownMenuProps = DropdownProps & {\n /**\n * Set role `menuitemradio` (or `menuitemcheckbox` if `multiselect`) for Dropdown.Item\n */\n selectable?: boolean;\n /**\n * Multiple select\n */\n multiselect?: boolean;\n /**\n * Size of the menu\n * @default m\n */\n size?: DropdownMenuSize;\n /**\n * Index of the element selected by default\n */\n defaultHighlightedIndex?: number | null;\n /**\n * Index of the selected item\n */\n highlightedIndex?: number | null;\n /**\n * Callback for highlightedIndex change\n * highlightedIndex - Index of the selected item\n */\n onHighlightedIndexChange?: (highlightedIndex: number | null) => void;\n /** Specifies the locale for i18n support */\n locale?: string;\n /**\n * Flag for menu that using as actions on DropdownMenu.Item\n */\n inlineActions?: boolean;\n\n /**\n * Count of menu items (for virtual lists only)\n */\n itemsCount?: number;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuListProps extends DropdownMenuListProps, UnknownProperties {}\nexport type DropdownMenuListProps = BoxProps &\n ScrollAreaProps & {\n /**\n * Size of the menu\n * @default m\n */\n size?: DropdownMenuSize;\n };\n\n/** @deprecated */\nexport interface IDropdownMenuMenuProps extends DropdownMenuMenuProps, UnknownProperties {}\nexport type DropdownMenuMenuProps = DropdownMenuListProps & {};\n\n/** @deprecated */\nexport interface IDropdownMenuItemProps extends DropdownMenuItemProps, UnknownProperties {}\nexport type DropdownMenuItemProps = FlexProps & {\n /**\n * Enables selected state. For selectable dropdowns only.\n */\n selected?: boolean;\n /**\n * Disables item\n */\n disabled?: boolean;\n /**\n * Adds focus styles around\n * @deprecated set focus manually by `.focus()` method to the same behaviour\n */\n highlighted?: boolean;\n /**\n * Disables hover state\n * @deprecated use `disabled` instead\n */\n notInteractive?: boolean;\n /**\n * Size of the component\n * @default m\n */\n size?: DropdownMenuSize;\n /**\n * Index of item (used in virtualized lists)\n */\n index?: number;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuItemHintProps extends DropdownMenuItemHintProps, UnknownProperties {}\nexport type DropdownMenuItemHintProps = FlexProps & {\n /**\n * Size of the component\n * @default m\n */\n size?: DropdownMenuSize;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuItemTitleProps\n extends DropdownMenuItemTitleProps,\n UnknownProperties {}\nexport type DropdownMenuItemTitleProps = FlexProps & {\n /**\n * Size of the component\n * @default m\n */\n size?: DropdownMenuSize;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuContext extends DropdownMenuContext, UnknownProperties {}\nexport type DropdownMenuContext = DropdownContext & {\n /**\n * Tracks which menu item is currently highlighted/focused for keyboard navigation\n **/\n highlightedIndex?: number;\n /**\n * Returns props for the menu list container\n **/\n getListProps: PropGetterFn;\n /**\n * Returns props for individual menu items\n **/\n getItemProps: PropGetterFn;\n /**\n * Returns props for item hint/description elements\n **/\n getItemHintProps: PropGetterFn;\n /**\n * Returns props for item title elements\n **/\n getItemTitleProps: PropGetterFn;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuHandlers extends DropdownMenuHandlers, UnknownProperties {}\nexport type DropdownMenuHandlers = DropdownHandlers & {\n highlightedIndex: (index: number) => void;\n};\n\nexport type DropdownMenuTriggerProps = DropdownTriggerProps;\n\ndeclare const DropdownMenu: Intergalactic.Component<\n 'div',\n DropdownMenuProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n> & {\n Trigger: typeof Dropdown.Trigger;\n Popper: Intergalactic.Component<'div', DropdownMenuProps & DropdownPopperAriaProps>;\n List: Intergalactic.Component<\n 'div',\n DropdownMenuListProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n >;\n Actions: Intergalactic.Component<\n typeof Flex,\n DropdownMenuListProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n >;\n Menu: Intergalactic.Component<\n 'div',\n DropdownMenuMenuProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n >;\n Item: Intergalactic.Component<\n typeof Dropdown.Item,\n DropdownMenuItemProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n > & {\n Addon: typeof Box;\n Content: typeof Flex;\n Text: typeof Text;\n Hint: typeof Flex;\n };\n /**\n * @deprecated Use Group with title prop\n */\n ItemTitle: Intergalactic.Component<'div', DropdownMenuItemTitleProps>;\n /**\n * @deprecated Use prop subTitle on Group or Item component\n */\n ItemHint: Intergalactic.Component<'div', DropdownMenuItemHintProps>;\n Group: typeof Dropdown.Group;\n /**\n * @deprecated Use Item instead of Nesting\n */\n Nesting: Intergalactic.Component<\n 'div',\n DropdownMenuItemProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n > & {\n /**\n * @deprecated Use Item instead of Nesting\n */\n Trigger: Intergalactic.Component<'div', DropdownMenuItemProps>;\n /**\n * @deprecated Use Item instead of Nesting\n */\n Item: Intergalactic.Component<'div', DropdownMenuItemProps>;\n /**\n * @deprecated Use Item instead of Nesting\n */\n Addon: typeof Box;\n };\n\n selectedIndexContext: React.Context<number>;\n nestedMenuInteraction: eventInteraction;\n};\n\nexport default DropdownMenu;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type { PropGetterFn, UnknownProperties, Intergalactic } from '@semcore/core';\nimport type {\n DropdownContext,\n DropdownProps,\n DropdownHandlers,\n DropdownTriggerProps,\n DropdownPopperAriaProps,\n} from '@semcore/dropdown';\nimport type Dropdown from '@semcore/dropdown';\nimport type { Box, BoxProps, FlexProps, Flex } from '@semcore/flex-box';\nimport type { eventInteraction } from '@semcore/popper';\nimport type { ScrollAreaProps } from '@semcore/scroll-area';\nimport type { Text } from '@semcore/typography';\n\nimport type { VirtualList, RenderRowProps } from './components/VirtualList';\n\nexport type DropdownMenuSize = 'm' | 'l';\n\n/** @deprecated */\nexport interface IDropdownMenuProps extends DropdownMenuProps, UnknownProperties {}\nexport type DropdownMenuProps = DropdownProps & {\n /**\n * Set role `menuitemradio` (or `menuitemcheckbox` if `multiselect`) for Dropdown.Item\n */\n selectable?: boolean;\n /**\n * Multiple select\n */\n multiselect?: boolean;\n /**\n * Size of the menu\n * @default m\n */\n size?: DropdownMenuSize;\n /**\n * Index of the element selected by default\n */\n defaultHighlightedIndex?: number | null;\n /**\n * Index of the selected item\n */\n highlightedIndex?: number | null;\n /**\n * Callback for highlightedIndex change\n * highlightedIndex - Index of the selected item\n */\n onHighlightedIndexChange?: (highlightedIndex: number | null) => void;\n /** Specifies the locale for i18n support */\n locale?: string;\n /**\n * Flag for menu that using as actions on DropdownMenu.Item\n */\n inlineActions?: boolean;\n\n /**\n * Count of menu items (for virtual lists only)\n */\n itemsCount?: number;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuListProps extends DropdownMenuListProps, UnknownProperties {}\nexport type DropdownMenuListProps = BoxProps &\n ScrollAreaProps & {\n /**\n * Size of the menu\n * @default m\n */\n size?: DropdownMenuSize;\n };\n\n/** @deprecated */\nexport interface IDropdownMenuMenuProps extends DropdownMenuMenuProps, UnknownProperties {}\nexport type DropdownMenuMenuProps = DropdownMenuListProps & {};\n\n/** @deprecated */\nexport interface IDropdownMenuItemProps extends DropdownMenuItemProps, UnknownProperties {}\nexport type DropdownMenuItemProps = FlexProps & {\n /**\n * Enables selected state. For selectable dropdowns only.\n */\n selected?: boolean;\n /**\n * Disables item\n */\n disabled?: boolean;\n /**\n * Adds focus styles around\n * @deprecated set focus manually by `.focus()` method to the same behaviour\n */\n highlighted?: boolean;\n /**\n * Disables hover state\n * @deprecated use `disabled` instead\n */\n notInteractive?: boolean;\n /**\n * Size of the component\n * @default m\n */\n size?: DropdownMenuSize;\n /**\n * Index of item (used in virtualized lists)\n */\n index?: number;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuItemHintProps extends DropdownMenuItemHintProps, UnknownProperties {}\nexport type DropdownMenuItemHintProps = FlexProps & {\n /**\n * Size of the component\n * @default m\n */\n size?: DropdownMenuSize;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuItemTitleProps\n extends DropdownMenuItemTitleProps,\n UnknownProperties {}\nexport type DropdownMenuItemTitleProps = FlexProps & {\n /**\n * Size of the component\n * @default m\n */\n size?: DropdownMenuSize;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuContext extends DropdownMenuContext, UnknownProperties {}\nexport type DropdownMenuContext = DropdownContext & {\n /**\n * Tracks which menu item is currently highlighted/focused for keyboard navigation\n **/\n highlightedIndex?: number;\n /**\n * Returns props for the menu list container\n **/\n getListProps: PropGetterFn;\n /**\n * Returns props for individual menu items\n **/\n getItemProps: PropGetterFn;\n /**\n * Returns props for item hint/description elements\n **/\n getItemHintProps: PropGetterFn;\n /**\n * Returns props for item title elements\n **/\n getItemTitleProps: PropGetterFn;\n};\n\n/** @deprecated */\nexport interface IDropdownMenuHandlers extends DropdownMenuHandlers, UnknownProperties {}\nexport type DropdownMenuHandlers = DropdownHandlers & {\n highlightedIndex: (index: number) => void;\n};\n\nexport type DropdownMenuTriggerProps = DropdownTriggerProps;\n\ndeclare const DropdownMenu: Intergalactic.Component<\n 'div',\n DropdownMenuProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n> & {\n Trigger: typeof Dropdown.Trigger;\n Popper: Intergalactic.Component<'div', DropdownMenuProps & DropdownPopperAriaProps>;\n List: Intergalactic.Component<\n 'div',\n DropdownMenuListProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n >;\n Actions: Intergalactic.Component<\n typeof Flex,\n DropdownMenuListProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n >;\n Menu: Intergalactic.Component<\n 'div',\n DropdownMenuMenuProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n >;\n Item: Intergalactic.Component<\n typeof Dropdown.Item,\n DropdownMenuItemProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n > & {\n Addon: typeof Box;\n Content: typeof Flex;\n Text: typeof Text;\n Hint: typeof Flex;\n };\n /**\n * @deprecated Use Group with title prop\n */\n ItemTitle: Intergalactic.Component<'div', DropdownMenuItemTitleProps>;\n /**\n * @deprecated Use prop subTitle on Group or Item component\n */\n ItemHint: Intergalactic.Component<'div', DropdownMenuItemHintProps>;\n Group: typeof Dropdown.Group;\n\n VirtualList: typeof VirtualList;\n\n /**\n * @deprecated Use Item instead of Nesting\n */\n Nesting: Intergalactic.Component<\n 'div',\n DropdownMenuItemProps,\n DropdownMenuContext,\n [handlers: DropdownMenuHandlers]\n > & {\n /**\n * @deprecated Use Item instead of Nesting\n */\n Trigger: Intergalactic.Component<'div', DropdownMenuItemProps>;\n /**\n * @deprecated Use Item instead of Nesting\n */\n Item: Intergalactic.Component<'div', DropdownMenuItemProps>;\n /**\n * @deprecated Use Item instead of Nesting\n */\n Addon: typeof Box;\n };\n\n selectedIndexContext: React.Context<number>;\n nestedMenuInteraction: eventInteraction;\n};\n\nexport default DropdownMenu;\n\nexport {\n RenderRowProps,\n};\n"],"mappings":"","ignoreList":[]}
|
package/lib/es6/DropdownMenu.js
CHANGED
|
@@ -33,36 +33,32 @@ import { forkRef } from '@semcore/core/lib/utils/ref';
|
|
|
33
33
|
import { useUID } from '@semcore/core/lib/utils/uniqueID';
|
|
34
34
|
import Dropdown, { AbstractDropdown, selectedIndexContext, enhance } from '@semcore/dropdown';
|
|
35
35
|
import { Flex, Box } from '@semcore/flex-box';
|
|
36
|
-
import ScrollAreaComponent
|
|
36
|
+
import ScrollAreaComponent from '@semcore/scroll-area';
|
|
37
37
|
import { Text } from '@semcore/typography';
|
|
38
38
|
import React from 'react';
|
|
39
|
+
import { ListBoxContextProvider } from './components/Context';
|
|
40
|
+
import { VirtualList } from './components/VirtualList';
|
|
39
41
|
/*!__reshadow-styles__:"./style/dropdown-menu.shadow.css"*/
|
|
40
|
-
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
42
|
+
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SDropdownMenuList_1d1ud_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_1d1ud_gg_ .___SBar_1d1ud_gg_{z-index:3}.___SDropdownMenuList_1d1ud_gg_ .___SShadowHorizontal_1d1ud_gg_:after,.___SDropdownMenuList_1d1ud_gg_ .___SShadowHorizontal_1d1ud_gg_:before,.___SDropdownMenuList_1d1ud_gg_ .___SShadowVertical_1d1ud_gg_:after,.___SDropdownMenuList_1d1ud_gg_ .___SShadowVertical_1d1ud_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1d1ud_gg_ .___SItemContent_1d1ud_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1d1ud_gg_.__nesting-trigger_1d1ud_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1d1ud_gg_,.___SItemContentText_1d1ud_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1d1ud_gg_:first-child,.___SItemContentText_1d1ud_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1d1ud_gg_:last-child,.___SItemContentText_1d1ud_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1d1ud_gg_,.___SDropdownMenuNesting_1d1ud_gg_._size_l_1d1ud_gg_,.___SDropdownMenuNesting_1d1ud_gg_._size_m_1d1ud_gg_{padding:0}.___SDropdownMenuNesting_1d1ud_gg_.__highlighted_1d1ud_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_1d1ud_gg_._size_l_1d1ud_gg_,.___SDropdownNestingItem_1d1ud_gg_._size_m_1d1ud_gg_{padding-right:0}.___SDropdownNestingItem_1d1ud_gg_ .___SDropdownMenuItemContainer_1d1ud_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1d1ud_gg_{color:var(--intergalactic-text-secondary, #6c6e79)}", /*__inner_css_end__*/"1d1ud_gg_"),
|
|
41
43
|
/*__reshadow_css_end__*/
|
|
42
44
|
{
|
|
43
|
-
"__SDropdownMenuItemContainer": "
|
|
44
|
-
"_nesting-trigger": "__nesting-
|
|
45
|
-
"__SDropdownMenuNesting": "
|
|
46
|
-
"_size_l": "
|
|
47
|
-
"_size_m": "
|
|
48
|
-
"_highlighted": "
|
|
49
|
-
"__SDropdownNestingItem": "
|
|
50
|
-
"__SItemHint": "
|
|
51
|
-
"__SDropdownMenuList": "
|
|
52
|
-
"__SBar": "
|
|
53
|
-
"__SShadowHorizontal": "
|
|
54
|
-
"__SShadowVertical": "
|
|
55
|
-
"__SItemContent": "
|
|
56
|
-
"__SDropdownMenuItemAddon": "
|
|
57
|
-
"__SItemContentText": "
|
|
45
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1d1ud_gg_",
|
|
46
|
+
"_nesting-trigger": "__nesting-trigger_1d1ud_gg_",
|
|
47
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1d1ud_gg_",
|
|
48
|
+
"_size_l": "_size_l_1d1ud_gg_",
|
|
49
|
+
"_size_m": "_size_m_1d1ud_gg_",
|
|
50
|
+
"_highlighted": "__highlighted_1d1ud_gg_",
|
|
51
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1d1ud_gg_",
|
|
52
|
+
"__SItemHint": "___SItemHint_1d1ud_gg_",
|
|
53
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1d1ud_gg_",
|
|
54
|
+
"__SBar": "___SBar_1d1ud_gg_",
|
|
55
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1d1ud_gg_",
|
|
56
|
+
"__SShadowVertical": "___SShadowVertical_1d1ud_gg_",
|
|
57
|
+
"__SItemContent": "___SItemContent_1d1ud_gg_",
|
|
58
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1d1ud_gg_",
|
|
59
|
+
"__SItemContentText": "___SItemContentText_1d1ud_gg_"
|
|
58
60
|
});
|
|
59
61
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
60
|
-
var ListBoxContextProvider = function ListBoxContextProvider(_ref22) {
|
|
61
|
-
var children = _ref22.children;
|
|
62
|
-
return /*#__PURE__*/React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
|
|
63
|
-
value: true
|
|
64
|
-
}, children);
|
|
65
|
-
};
|
|
66
62
|
var menuItemContext = /*#__PURE__*/React.createContext({});
|
|
67
63
|
var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
68
64
|
function DropdownMenuRoot() {
|
|
@@ -74,6 +70,15 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
74
70
|
_this = _callSuper(this, DropdownMenuRoot, [].concat(args));
|
|
75
71
|
_defineProperty(_this, "actionsRef", /*#__PURE__*/React.createRef());
|
|
76
72
|
_defineProperty(_this, "role", 'menu');
|
|
73
|
+
/**
|
|
74
|
+
* TODO: It needs to be reconsidered in a future implementation so that component accepts items as a prop instead of JSX.
|
|
75
|
+
* Tab index recalculation flag.
|
|
76
|
+
*
|
|
77
|
+
* When an item becomes disabled while highlighted, we need to transfer focus
|
|
78
|
+
* to the next available focusable item. This flag ensures the focus lock
|
|
79
|
+
* remains within proper boundaries during the initial render cycle.
|
|
80
|
+
*/
|
|
81
|
+
_defineProperty(_this, "shouldRecalculateItemTabIndex", false);
|
|
77
82
|
return _this;
|
|
78
83
|
}
|
|
79
84
|
_inherits(DropdownMenuRoot, _AbstractDropdown);
|
|
@@ -88,7 +93,7 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
88
93
|
_this2.focusAndScrollToSelected();
|
|
89
94
|
// for some reason, Google Chrome optimizes this timeout with 0 value with previous render (when we set aria-selected)
|
|
90
95
|
// and that's why its skip scrollToNodes. We selected the appropriate timeout manually.
|
|
91
|
-
},
|
|
96
|
+
}, 50);
|
|
92
97
|
}
|
|
93
98
|
}]
|
|
94
99
|
});
|
|
@@ -104,7 +109,7 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
104
109
|
};
|
|
105
110
|
}
|
|
106
111
|
var options = menuElement.querySelectorAll('[role="menuitemcheckbox"], [role="menuitemradio"]');
|
|
107
|
-
var selected = menuElement.querySelector('[aria-checked="true"]');
|
|
112
|
+
var selected = menuElement.querySelector('[aria-checked="true"]:not([disabled])');
|
|
108
113
|
return {
|
|
109
114
|
selected: selected,
|
|
110
115
|
options: options
|
|
@@ -113,12 +118,13 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
113
118
|
}, {
|
|
114
119
|
key: "focusAndScrollToSelected",
|
|
115
120
|
value: function focusAndScrollToSelected() {
|
|
116
|
-
var
|
|
121
|
+
var _this$menuRef$current,
|
|
122
|
+
_this3 = this;
|
|
117
123
|
var _this$menuElements = this.menuElements,
|
|
118
124
|
selected = _this$menuElements.selected,
|
|
119
125
|
options = _this$menuElements.options;
|
|
120
126
|
var isFocusAlreadyInPopper = isFocusInside(this.popperRef.current);
|
|
121
|
-
if (!selected || !options || this.
|
|
127
|
+
if (!selected || !options || (_this$menuRef$current = this.menuRef.current) !== null && _this$menuRef$current !== void 0 && _this$menuRef$current.dataset.isVirtual || isFocusAlreadyInPopper) return;
|
|
122
128
|
this.scrollToNodeAsync(selected, true).then(function () {
|
|
123
129
|
if (_this3.asProps.visible) {
|
|
124
130
|
selected.focus({
|
|
@@ -134,12 +140,11 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
134
140
|
}, {
|
|
135
141
|
key: "afterOpenPopper",
|
|
136
142
|
value: function afterOpenPopper() {
|
|
143
|
+
var _this$menuRef$current2;
|
|
137
144
|
var _this$menuElements2 = this.menuElements,
|
|
138
145
|
selected = _this$menuElements2.selected,
|
|
139
146
|
options = _this$menuElements2.options;
|
|
140
|
-
|
|
141
|
-
// this case is handled slightly differently on line 63.
|
|
142
|
-
if (selected && options && this.asProps.itemsCount === undefined) return;
|
|
147
|
+
if (selected && options && !((_this$menuRef$current2 = this.menuRef.current) !== null && _this$menuRef$current2 !== void 0 && _this$menuRef$current2.dataset.isVirtual)) return;
|
|
143
148
|
_superPropGet(DropdownMenuRoot, "afterOpenPopper", this, 3)([]);
|
|
144
149
|
}
|
|
145
150
|
}, {
|
|
@@ -172,6 +177,13 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
172
177
|
onKeyDown: callAllEventHandlers(this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
173
178
|
});
|
|
174
179
|
}
|
|
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
|
+
});
|
|
186
|
+
}
|
|
175
187
|
}, {
|
|
176
188
|
key: "getPopperProps",
|
|
177
189
|
value: function getPopperProps() {
|
|
@@ -187,18 +199,36 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
187
199
|
onKeyDown: callAllEventHandlers(this.handlePreventTabOnActions.bind(this), this.handlePreventCommonKeyDown.bind(this), this.handleKeyDownForMenu('list'), this.handleArrowKeyDown.bind(this))
|
|
188
200
|
});
|
|
189
201
|
}
|
|
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;
|
|
223
|
+
}
|
|
190
224
|
}, {
|
|
191
225
|
key: "getItemProps",
|
|
192
226
|
value: function getItemProps(props, index) {
|
|
193
227
|
var _props$index,
|
|
194
228
|
_this4 = this;
|
|
195
|
-
var _this$asProps2 = this.asProps,
|
|
196
|
-
highlightedIndex = _this$asProps2.highlightedIndex,
|
|
197
|
-
visible = _this$asProps2.visible;
|
|
198
229
|
var realIndex = (_props$index = props.index) !== null && _props$index !== void 0 ? _props$index : index;
|
|
199
|
-
var isHighlighted = realIndex === highlightedIndex;
|
|
200
230
|
var itemProps = _objectSpread(_objectSpread({}, _superPropGet(DropdownMenuRoot, "getItemProps", this, 3)([props, realIndex])), {}, {
|
|
201
|
-
tabIndex:
|
|
231
|
+
tabIndex: this.getItemTabIndex(props, index),
|
|
202
232
|
ref: function ref(node) {
|
|
203
233
|
return _this4.itemRef(props, realIndex, node);
|
|
204
234
|
},
|
|
@@ -246,6 +276,13 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
246
276
|
setTimeout(function () {
|
|
247
277
|
var _this5$itemRefs$highl;
|
|
248
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;
|
|
249
286
|
(_this5$itemRefs$highl = _this5.itemRefs[highlightedIndex]) === null || _this5$itemRefs$highl === void 0 || _this5$itemRefs$highl.focus();
|
|
250
287
|
}, 0);
|
|
251
288
|
e.preventDefault();
|
|
@@ -311,11 +348,11 @@ _defineProperty(DropdownMenuRoot, "nestedMenuInteraction", {
|
|
|
311
348
|
trigger: [['onClick', 'onMouseEnter'], ['onClick', 'onMouseLeave']],
|
|
312
349
|
popper: [['onMouseEnter'], ['onMouseLeave']]
|
|
313
350
|
});
|
|
314
|
-
function List(
|
|
351
|
+
function List(_ref22) {
|
|
315
352
|
var _ref2 = arguments[0],
|
|
316
353
|
_ref13;
|
|
317
|
-
var styles =
|
|
318
|
-
Children =
|
|
354
|
+
var styles = _ref22.styles,
|
|
355
|
+
Children = _ref22.Children;
|
|
319
356
|
var SDropdownMenuList = ScrollAreaComponent;
|
|
320
357
|
var SBar = ScrollAreaComponent.Bar;
|
|
321
358
|
return _ref13 = sstyled(styles), /*#__PURE__*/React.createElement(ListBoxContextProvider, _ref13.cn("ListBoxContextProvider", {}), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref13.cn("SDropdownMenuList", _objectSpread({}, _assignProps2({
|
|
@@ -330,10 +367,10 @@ function List(_ref23) {
|
|
|
330
367
|
"orientation": 'vertical'
|
|
331
368
|
}))));
|
|
332
369
|
}
|
|
333
|
-
function Actions(
|
|
370
|
+
function Actions(_ref23) {
|
|
334
371
|
var _ref3 = arguments[0],
|
|
335
372
|
_ref14;
|
|
336
|
-
var styles =
|
|
373
|
+
var styles = _ref23.styles;
|
|
337
374
|
var SDropdownMenuActions = Flex;
|
|
338
375
|
return _ref14 = sstyled(styles), /*#__PURE__*/React.createElement(SDropdownMenuActions, _ref14.cn("SDropdownMenuActions", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
339
376
|
}
|
|
@@ -359,18 +396,18 @@ function Menu(props) {
|
|
|
359
396
|
role: null
|
|
360
397
|
}), /*#__PURE__*/React.createElement(DropdownMenu.List, _assignProps4({}, _ref4))));
|
|
361
398
|
}
|
|
362
|
-
function Item(
|
|
399
|
+
function Item(_ref24) {
|
|
363
400
|
var _ref5 = arguments[0],
|
|
364
401
|
_ref15;
|
|
365
|
-
var id =
|
|
366
|
-
styles =
|
|
367
|
-
disabled =
|
|
368
|
-
Children =
|
|
369
|
-
forwardRef =
|
|
370
|
-
role =
|
|
371
|
-
tabIndex =
|
|
372
|
-
actionsRef =
|
|
373
|
-
ariaChecked =
|
|
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'];
|
|
374
411
|
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
375
412
|
var itemRef = React.useRef();
|
|
376
413
|
var _React$useState = React.useState(false),
|
|
@@ -382,7 +419,8 @@ function Item(_ref25) {
|
|
|
382
419
|
ref: forkRef(forwardRef, itemRef),
|
|
383
420
|
role: role,
|
|
384
421
|
tabIndex: tabIndex,
|
|
385
|
-
ariaChecked: ariaChecked
|
|
422
|
+
ariaChecked: ariaChecked,
|
|
423
|
+
disabled: disabled
|
|
386
424
|
};
|
|
387
425
|
var ariaDescribes = [];
|
|
388
426
|
var hasSubMenu = isAdvanceMode(Children, [DropdownMenu.displayName], true);
|
|
@@ -450,10 +488,10 @@ function Trigger() {
|
|
|
450
488
|
var _ref7 = arguments[0];
|
|
451
489
|
return /*#__PURE__*/React.createElement(Dropdown.Trigger, _assignProps7({}, _ref7));
|
|
452
490
|
}
|
|
453
|
-
function ItemContent(
|
|
491
|
+
function ItemContent(_ref25) {
|
|
454
492
|
var _ref8 = arguments[0],
|
|
455
493
|
_ref17;
|
|
456
|
-
var styles =
|
|
494
|
+
var styles = _ref25.styles;
|
|
457
495
|
var SItemContent = Flex;
|
|
458
496
|
var ref = React.useRef();
|
|
459
497
|
var menuItemCtxValue = React.useContext(menuItemContext);
|
|
@@ -485,20 +523,21 @@ function ItemContent(_ref26) {
|
|
|
485
523
|
"aria-expanded": subMenu,
|
|
486
524
|
"aria-checked": menuItemCtxValue.ariaChecked,
|
|
487
525
|
"alignItems": 'center',
|
|
488
|
-
"justifyContent": menuItemCtxValue.hasSubMenu ? 'space-between' : undefined
|
|
526
|
+
"justifyContent": menuItemCtxValue.hasSubMenu ? 'space-between' : undefined,
|
|
527
|
+
"disabled": menuItemCtxValue.disabled
|
|
489
528
|
}, _ref8))));
|
|
490
529
|
}
|
|
491
|
-
function ItemContentText(
|
|
530
|
+
function ItemContentText(_ref26) {
|
|
492
531
|
var _ref9 = arguments[0],
|
|
493
532
|
_ref18;
|
|
494
|
-
var styles =
|
|
533
|
+
var styles = _ref26.styles;
|
|
495
534
|
var SItemContentText = Text;
|
|
496
535
|
return _ref18 = sstyled(styles), /*#__PURE__*/React.createElement(SItemContentText, _ref18.cn("SItemContentText", _objectSpread({}, _assignProps9({}, _ref9))));
|
|
497
536
|
}
|
|
498
|
-
function ItemHint(
|
|
537
|
+
function ItemHint(_ref27) {
|
|
499
538
|
var _ref0 = arguments[0],
|
|
500
539
|
_ref19;
|
|
501
|
-
var styles =
|
|
540
|
+
var styles = _ref27.styles;
|
|
502
541
|
var SItemHint = Flex;
|
|
503
542
|
var _React$useContext = React.useContext(menuItemContext),
|
|
504
543
|
hintId = _React$useContext.hintId;
|
|
@@ -534,9 +573,9 @@ function Title(props) {
|
|
|
534
573
|
/**
|
|
535
574
|
* @deprecated
|
|
536
575
|
*/
|
|
537
|
-
function Nesting(
|
|
576
|
+
function Nesting(_ref28) {
|
|
538
577
|
var _ref11 = arguments[0];
|
|
539
|
-
var forwardRef =
|
|
578
|
+
var forwardRef = _ref28.forwardRef;
|
|
540
579
|
return /*#__PURE__*/React.createElement(DropdownMenu.Item, _assignProps11({
|
|
541
580
|
"ref": forwardRef
|
|
542
581
|
}, _ref11));
|
|
@@ -545,9 +584,9 @@ function Nesting(_ref29) {
|
|
|
545
584
|
/**
|
|
546
585
|
* @deprecated
|
|
547
586
|
*/
|
|
548
|
-
function NestingTrigger(
|
|
587
|
+
function NestingTrigger(_ref29) {
|
|
549
588
|
var _ref12 = arguments[0];
|
|
550
|
-
var forwardRef =
|
|
589
|
+
var forwardRef = _ref29.forwardRef;
|
|
551
590
|
return /*#__PURE__*/React.createElement(DropdownMenu.Item.Content, _assignProps12({
|
|
552
591
|
"tag": DropdownMenu.Trigger,
|
|
553
592
|
"ref": forwardRef,
|
|
@@ -558,6 +597,7 @@ var DropdownMenu = createComponent(DropdownMenuRoot, {
|
|
|
558
597
|
Trigger: Trigger,
|
|
559
598
|
Popper: Dropdown.Popper,
|
|
560
599
|
List: List,
|
|
600
|
+
VirtualList: VirtualList,
|
|
561
601
|
Actions: Actions,
|
|
562
602
|
Menu: Menu,
|
|
563
603
|
Item: [Item, {
|