@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","names":["
|
|
1
|
+
{"version":3,"file":"Context.js","names":["_scrollArea","require","_react","_interopRequireDefault","ListBoxContextProvider","exports","_ref","children","createElement","hideScrollBarsFromScreenReadersContext","Provider","value"],"sources":["../../../src/components/Context.tsx"],"sourcesContent":["import { hideScrollBarsFromScreenReadersContext } from '@semcore/scroll-area';\nimport React from 'react';\n\nexport const ListBoxContextProvider = ({ children }: React.PropsWithChildren) => (\n <hideScrollBarsFromScreenReadersContext.Provider value={true}>\n {children}\n </hideScrollBarsFromScreenReadersContext.Provider>\n);\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,IAAMG,sBAAsB,GAAAC,OAAA,CAAAD,sBAAA,GAAG,SAAzBA,sBAAsBA,CAAAE,IAAA;EAAA,IAAMC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAAA,oBAC/CL,MAAA,YAAAM,aAAA,CAACR,WAAA,CAAAS,sCAAsC,CAACC,QAAQ;IAACC,KAAK,EAAE;EAAK,GAC1DJ,QAC8C,CAAC;AAAA,CACnD","ignoreList":[]}
|
|
@@ -13,28 +13,28 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
14
|
var _core = require("@semcore/core");
|
|
15
15
|
var _baseComponents = require("@semcore/base-components");
|
|
16
|
+
var _scrollArea = _interopRequireDefault(require("@semcore/scroll-area"));
|
|
16
17
|
var _react = _interopRequireDefault(require("react"));
|
|
17
18
|
var _Context = require("./Context");
|
|
18
19
|
/*!__reshadow-styles__:"../style/dropdown-menu.shadow.css"*/
|
|
19
|
-
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
20
|
+
var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___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))}}}", /*__inner_css_end__*/"1ahmt_gg_"),
|
|
20
21
|
/*__reshadow_css_end__*/
|
|
21
22
|
{
|
|
22
|
-
"__SDropdownMenuItemContainer": "
|
|
23
|
-
"_nesting-trigger": "__nesting-
|
|
24
|
-
"__SDropdownMenuNesting": "
|
|
25
|
-
"_size_l": "
|
|
26
|
-
"_size_m": "
|
|
27
|
-
"_highlighted": "
|
|
28
|
-
"__SDropdownNestingItem": "
|
|
29
|
-
"__SItemHint": "
|
|
30
|
-
"__SDropdownMenuList": "
|
|
31
|
-
"__SBar": "
|
|
32
|
-
"__SShadowHorizontal": "
|
|
33
|
-
"__SShadowVertical": "
|
|
34
|
-
"__SItemContent": "
|
|
35
|
-
"__SDropdownMenuItemAddon": "
|
|
36
|
-
"__SItemContentText": "
|
|
37
|
-
"__SScrollContainer": "___SScrollContainer_1d74h_gg_"
|
|
23
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1ahmt_gg_",
|
|
24
|
+
"_nesting-trigger": "__nesting-trigger_1ahmt_gg_",
|
|
25
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1ahmt_gg_",
|
|
26
|
+
"_size_l": "_size_l_1ahmt_gg_",
|
|
27
|
+
"_size_m": "_size_m_1ahmt_gg_",
|
|
28
|
+
"_highlighted": "__highlighted_1ahmt_gg_",
|
|
29
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1ahmt_gg_",
|
|
30
|
+
"__SItemHint": "___SItemHint_1ahmt_gg_",
|
|
31
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1ahmt_gg_",
|
|
32
|
+
"__SBar": "___SBar_1ahmt_gg_",
|
|
33
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1ahmt_gg_",
|
|
34
|
+
"__SShadowVertical": "___SShadowVertical_1ahmt_gg_",
|
|
35
|
+
"__SItemContent": "___SItemContent_1ahmt_gg_",
|
|
36
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1ahmt_gg_",
|
|
37
|
+
"__SItemContentText": "___SItemContentText_1ahmt_gg_"
|
|
38
38
|
});
|
|
39
39
|
var VirtualListRoot = /*#__PURE__*/function (_Component) {
|
|
40
40
|
function VirtualListRoot() {
|
|
@@ -88,8 +88,8 @@ var VirtualListRoot = /*#__PURE__*/function (_Component) {
|
|
|
88
88
|
_ref2,
|
|
89
89
|
_this$listRef$current,
|
|
90
90
|
_this$listRef$current2;
|
|
91
|
-
var SDropdownMenuList =
|
|
92
|
-
var SBar =
|
|
91
|
+
var SDropdownMenuList = _scrollArea["default"];
|
|
92
|
+
var SBar = _scrollArea["default"].Bar;
|
|
93
93
|
var _this$state = this.state,
|
|
94
94
|
scrollDirection = _this$state.scrollDirection,
|
|
95
95
|
scrollTop = _this$state.scrollTop;
|
|
@@ -115,7 +115,7 @@ var VirtualListRoot = /*#__PURE__*/function (_Component) {
|
|
|
115
115
|
"onScroll": this.handleScroll,
|
|
116
116
|
"data-is-virtual": 'true',
|
|
117
117
|
"ref": this.listRef
|
|
118
|
-
}, _ref))), /*#__PURE__*/_react["default"].createElement(
|
|
118
|
+
}, _ref))), /*#__PURE__*/_react["default"].createElement(_scrollArea["default"].Container, {
|
|
119
119
|
ref: this.containerRef,
|
|
120
120
|
tabIndex: undefined,
|
|
121
121
|
h: rows.length * rowHeight
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualList.js","names":["_core","require","_baseComponents","_react","_interopRequireDefault","_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","rowsBuffer","setTimeout","_this2$listRef$curren","_this2$listRef$curren2","_this2$containerRef$c","listHeight","listRef","current","getBoundingClientRect","height","containerRef","scrollTo","top","forceUpdate","render","_ref","_ref2","_this$listRef$current","_this$listRef$current2","SDropdownMenuList","ScrollAreaComponent","SBar","Bar","_this$state","_this$asProps2","rows","styles","RenderRow","renderRow","customData","offsetHeight","prevPrepared","nextPrepared","startIndex","Math","max","floor","lastIndex","min","ceil","rowsToRender","slice","rowMarginTop","rowMarginBottom","createElement","ListBoxContextProvider","cn","_objectSpread2","assignProps","handleScroll","ScrollArea","Container","ref","tabIndex","undefined","h","Box","map","item","row","data","Component","VirtualList","exports","createComponent"],"sources":["../../../src/components/VirtualList.tsx"],"sourcesContent":["import { ScrollArea as ScrollAreaComponent, Box } from '@semcore/base-components';\nimport type { Intergalactic } from '@semcore/core';\nimport { Root, Component, createComponent, sstyled } from '@semcore/core';\nimport React from 'react';\n\nimport { ListBoxContextProvider } from './Context';\nimport style from '../style/dropdown-menu.shadow.css';\n\nexport type RenderRowProps<T, D = never> = {\n index: number;\n row: T;\n data: [D] extends [never] ? undefined : D;\n};\n\ntype VirtualListProps<T, D extends object = never> = {\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} & ([D] extends [never] ? { customData?: undefined } : {\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 = never> extends Component<VirtualListProps<T, D>, [], Readonly<{}>, { rowsBuffer: number; index: number }, State> {\n static displayName = 'VirtualList';\n static style = style;\n\n static defaultProps = {\n rowsBuffer: 6,\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, rowsBuffer } = 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\n if (index <= rowsBuffer) {\n this.forceUpdate(); // we need this for correct render all items with calculated container height\n }\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 = this.listRef.current?.offsetHeight ?? 0;\n const prevPrepared = scrollDirection === 'down' ? rowsBuffer / 2 : rowsBuffer;\n const nextPrepared = scrollDirection === 'up' ? rowsBuffer / 2 : rowsBuffer;\n\n const startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);\n\n const lastIndex = 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 // @ts-ignore\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 = never,\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,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAAmD;AAAA,IAAAK,KAAA,8BAAAN,KAAA,CAAAO,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IA8B7CC,eAAe,0BAAAC,UAAA;EAAA,SAAAD,gBAAA;IAAA,IAAAE,KAAA;IAAA,IAAAC,gBAAA,mBAAAH,eAAA;IAAA,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAAF,IAAA,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAAAP,KAAA,OAAAQ,WAAA,mBAAAV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,SAAU;QAACC,CAAC,EAAE9B,IAAI,CAACnD,MAAM,GAAGyB;MAAU,gBACrGrC,MAAA,YAAAkF,aAAA,CAACnF,eAAA,CAAA+F,GAAG,EAAAxC,KAAA,CAAA8B,EAAA;QAAA,KAAIJ;MAAY,EAAG,CAAC,EACvBF,YAAY,CAACiB,GAAG,CAAC,UAACC,IAAI,EAAE5D,KAAK,EAAK;QACjC;QACA,oBAAOpC,MAAA,YAAAkF,aAAA,CAACjB,SAAS;UAACnC,GAAG,EAAEyC,UAAU,GAAGnC,KAAM;UAAC6D,GAAG,EAAED,IAAK;UAAC5D,KAAK,EAAEmC,UAAU,GAAGnC,KAAM;UAAC8D,IAAI,EAAE/B;QAAW,CAAE,CAAC;MACvG,CAAC,CAAC,eACFnE,MAAA,YAAAkF,aAAA,CAACnF,eAAA,CAAA+F,GAAG,EAAAxC,KAAA,CAAA8B,EAAA;QAAA,KAAIH;MAAe,EAAG,CACG,CAAC,eAChCjF,MAAA,YAAAkF,aAAA,CAACvB,IAAI,EAAAL,KAAA,CAAA8B,EAAA;QAAA,eAAa;MAAY,EAAE,CAAC,eACjCpF,MAAA,YAAAkF,aAAA,CAACvB,IAAI,EAAAL,KAAA,CAAA8B,EAAA;QAAA,eAAa;MAAU,EAAE,CACb,CACG,CAAC;IAE7B;EAAC;AAAA,EAtFiEe,eAAS;AAAA,IAAAjF,gBAAA,aAAvEZ,eAAe,iBACE,aAAa;AAAA,IAAAY,gBAAA,aAD9BZ,eAAe,WAEJH,KAAK;AAAA,IAAAe,gBAAA,aAFhBZ,eAAe,kBAIG;EACpBgC,UAAU,EAAE;AACd,CAAC;AA0FI,IAAM8D,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,IAAAE,qBAAe,EAAChG,eAAe,CAAyB","ignoreList":[]}
|
|
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","rowsBuffer","setTimeout","_this2$listRef$curren","_this2$listRef$curren2","_this2$containerRef$c","listHeight","listRef","current","getBoundingClientRect","height","containerRef","scrollTo","top","forceUpdate","render","_ref","_ref2","_this$listRef$current","_this$listRef$current2","SDropdownMenuList","ScrollAreaComponent","SBar","Bar","_this$state","_this$asProps2","rows","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 = never> = {\n index: number;\n row: T;\n data: [D] extends [never] ? undefined : D;\n};\n\ntype VirtualListProps<T, D extends object = never> = {\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} & ([D] extends [never] ? { customData?: undefined } : {\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 = never> extends Component<VirtualListProps<T, D>, {}, State, [], { rowsBuffer: number; index: number }> {\n static displayName = 'VirtualList';\n static style = style;\n\n static defaultProps = {\n rowsBuffer: 6,\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, rowsBuffer } = 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\n if (index <= rowsBuffer) {\n this.forceUpdate(); // we need this for correct render all items with calculated container height\n }\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 = this.listRef.current?.offsetHeight ?? 0;\n const prevPrepared = scrollDirection === 'down' ? rowsBuffer / 2 : rowsBuffer;\n const nextPrepared = scrollDirection === 'up' ? rowsBuffer / 2 : rowsBuffer;\n\n const startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);\n\n const lastIndex = 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 // @ts-ignore\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 = never,\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,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA,IA8B7CC,eAAe,0BAAAC,UAAA;EAAA,SAAAD,gBAAA;IAAA,IAAAE,KAAA;IAAA,IAAAC,gBAAA,mBAAAH,eAAA;IAAA,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAC,IAAA,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAAF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 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.js","names":[],"sources":["../../src/index.d.ts"],"sourcesContent":["import type {
|
|
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":[]}
|
|
@@ -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/es6/DropdownMenu.js
CHANGED
|
@@ -9,6 +9,10 @@ import _superPropGet from "@babel/runtime/helpers/superPropGet";
|
|
|
9
9
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
10
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
11
|
import { sstyled as _sstyled } from "@semcore/core";
|
|
12
|
+
import { assignProps as _assignProps12 } from "@semcore/core";
|
|
13
|
+
import { assignProps as _assignProps11 } from "@semcore/core";
|
|
14
|
+
import { assignProps as _assignProps10 } from "@semcore/core";
|
|
15
|
+
import { assignProps as _assignProps1 } from "@semcore/core";
|
|
12
16
|
import { assignProps as _assignProps0 } from "@semcore/core";
|
|
13
17
|
import { assignProps as _assignProps9 } from "@semcore/core";
|
|
14
18
|
import { assignProps as _assignProps8 } from "@semcore/core";
|
|
@@ -19,7 +23,6 @@ import { assignProps as _assignProps4 } from "@semcore/core";
|
|
|
19
23
|
import { assignProps as _assignProps3 } from "@semcore/core";
|
|
20
24
|
import { assignProps as _assignProps2 } from "@semcore/core";
|
|
21
25
|
import { assignProps as _assignProps } from "@semcore/core";
|
|
22
|
-
import { Flex, ScrollArea as ScrollAreaComponent, Box } from '@semcore/base-components';
|
|
23
26
|
import ButtonComponent from '@semcore/button';
|
|
24
27
|
import { createComponent, sstyled, Root, lastInteraction } from '@semcore/core';
|
|
25
28
|
import { callAllEventHandlers } from '@semcore/core/lib/utils/assignProps';
|
|
@@ -29,30 +32,31 @@ import { setFocus } from '@semcore/core/lib/utils/focus-lock/setFocus';
|
|
|
29
32
|
import { forkRef } from '@semcore/core/lib/utils/ref';
|
|
30
33
|
import { useUID } from '@semcore/core/lib/utils/uniqueID';
|
|
31
34
|
import Dropdown, { AbstractDropdown, selectedIndexContext, enhance } from '@semcore/dropdown';
|
|
35
|
+
import { Flex, Box } from '@semcore/flex-box';
|
|
36
|
+
import ScrollAreaComponent from '@semcore/scroll-area';
|
|
32
37
|
import { Text } from '@semcore/typography';
|
|
33
38
|
import React from 'react';
|
|
34
39
|
import { ListBoxContextProvider } from './components/Context';
|
|
35
40
|
import { VirtualList } from './components/VirtualList';
|
|
36
41
|
/*!__reshadow-styles__:"./style/dropdown-menu.shadow.css"*/
|
|
37
|
-
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".
|
|
42
|
+
var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___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))}}}", /*__inner_css_end__*/"1ahmt_gg_"),
|
|
38
43
|
/*__reshadow_css_end__*/
|
|
39
44
|
{
|
|
40
|
-
"__SDropdownMenuItemContainer": "
|
|
41
|
-
"_nesting-trigger": "__nesting-
|
|
42
|
-
"__SDropdownMenuNesting": "
|
|
43
|
-
"_size_l": "
|
|
44
|
-
"_size_m": "
|
|
45
|
-
"_highlighted": "
|
|
46
|
-
"__SDropdownNestingItem": "
|
|
47
|
-
"__SItemHint": "
|
|
48
|
-
"__SDropdownMenuList": "
|
|
49
|
-
"__SBar": "
|
|
50
|
-
"__SShadowHorizontal": "
|
|
51
|
-
"__SShadowVertical": "
|
|
52
|
-
"__SItemContent": "
|
|
53
|
-
"__SDropdownMenuItemAddon": "
|
|
54
|
-
"__SItemContentText": "
|
|
55
|
-
"__SScrollContainer": "___SScrollContainer_1d74h_gg_"
|
|
45
|
+
"__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1ahmt_gg_",
|
|
46
|
+
"_nesting-trigger": "__nesting-trigger_1ahmt_gg_",
|
|
47
|
+
"__SDropdownMenuNesting": "___SDropdownMenuNesting_1ahmt_gg_",
|
|
48
|
+
"_size_l": "_size_l_1ahmt_gg_",
|
|
49
|
+
"_size_m": "_size_m_1ahmt_gg_",
|
|
50
|
+
"_highlighted": "__highlighted_1ahmt_gg_",
|
|
51
|
+
"__SDropdownNestingItem": "___SDropdownNestingItem_1ahmt_gg_",
|
|
52
|
+
"__SItemHint": "___SItemHint_1ahmt_gg_",
|
|
53
|
+
"__SDropdownMenuList": "___SDropdownMenuList_1ahmt_gg_",
|
|
54
|
+
"__SBar": "___SBar_1ahmt_gg_",
|
|
55
|
+
"__SShadowHorizontal": "___SShadowHorizontal_1ahmt_gg_",
|
|
56
|
+
"__SShadowVertical": "___SShadowVertical_1ahmt_gg_",
|
|
57
|
+
"__SItemContent": "___SItemContent_1ahmt_gg_",
|
|
58
|
+
"__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1ahmt_gg_",
|
|
59
|
+
"__SItemContentText": "___SItemContentText_1ahmt_gg_"
|
|
56
60
|
});
|
|
57
61
|
import { localizedMessages } from './translations/__intergalactic-dynamic-locales';
|
|
58
62
|
var menuItemContext = /*#__PURE__*/React.createContext({});
|
|
@@ -140,8 +144,6 @@ var DropdownMenuRoot = /*#__PURE__*/function (_AbstractDropdown) {
|
|
|
140
144
|
var _this$menuElements2 = this.menuElements,
|
|
141
145
|
selected = _this$menuElements2.selected,
|
|
142
146
|
options = _this$menuElements2.options;
|
|
143
|
-
var isFocusAlreadyInPopper = isFocusInside(this.popperRef.current);
|
|
144
|
-
if (isFocusAlreadyInPopper) return;
|
|
145
147
|
if (selected && options && !((_this$menuRef$current2 = this.menuRef.current) !== null && _this$menuRef$current2 !== void 0 && _this$menuRef$current2.dataset.isVirtual)) return;
|
|
146
148
|
_superPropGet(DropdownMenuRoot, "afterOpenPopper", this, 3)([]);
|
|
147
149
|
}
|
|
@@ -346,32 +348,31 @@ _defineProperty(DropdownMenuRoot, "nestedMenuInteraction", {
|
|
|
346
348
|
trigger: [['onClick', 'onMouseEnter'], ['onClick', 'onMouseLeave']],
|
|
347
349
|
popper: [['onMouseEnter'], ['onMouseLeave']]
|
|
348
350
|
});
|
|
349
|
-
function List(
|
|
351
|
+
function List(_ref22) {
|
|
350
352
|
var _ref2 = arguments[0],
|
|
351
|
-
|
|
352
|
-
var styles =
|
|
353
|
-
Children =
|
|
353
|
+
_ref13;
|
|
354
|
+
var styles = _ref22.styles,
|
|
355
|
+
Children = _ref22.Children;
|
|
354
356
|
var SDropdownMenuList = ScrollAreaComponent;
|
|
355
357
|
var SBar = ScrollAreaComponent.Bar;
|
|
356
|
-
|
|
357
|
-
return _ref1 = sstyled(styles), /*#__PURE__*/React.createElement(ListBoxContextProvider, _ref1.cn("ListBoxContextProvider", {}), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref1.cn("SDropdownMenuList", _objectSpread({}, _assignProps2({
|
|
358
|
+
return _ref13 = sstyled(styles), /*#__PURE__*/React.createElement(ListBoxContextProvider, _ref13.cn("ListBoxContextProvider", {}), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref13.cn("SDropdownMenuList", _objectSpread({}, _assignProps2({
|
|
358
359
|
"shadow": true,
|
|
359
360
|
"shadowSize": 16,
|
|
360
361
|
"shadowTheme": 'light'
|
|
361
|
-
}, _ref2))), /*#__PURE__*/React.createElement(
|
|
362
|
-
|
|
363
|
-
}
|
|
362
|
+
}, _ref2))), /*#__PURE__*/React.createElement(ScrollAreaComponent.Container, {
|
|
363
|
+
tabIndex: undefined
|
|
364
|
+
}, /*#__PURE__*/React.createElement(Children, _ref13.cn("Children", {}))), /*#__PURE__*/React.createElement(SBar, _ref13.cn("SBar", {
|
|
364
365
|
"orientation": 'horizontal'
|
|
365
|
-
})), /*#__PURE__*/React.createElement(SBar,
|
|
366
|
+
})), /*#__PURE__*/React.createElement(SBar, _ref13.cn("SBar", {
|
|
366
367
|
"orientation": 'vertical'
|
|
367
368
|
}))));
|
|
368
369
|
}
|
|
369
|
-
function Actions(
|
|
370
|
+
function Actions(_ref23) {
|
|
370
371
|
var _ref3 = arguments[0],
|
|
371
|
-
|
|
372
|
-
var styles =
|
|
372
|
+
_ref14;
|
|
373
|
+
var styles = _ref23.styles;
|
|
373
374
|
var SDropdownMenuActions = Flex;
|
|
374
|
-
return
|
|
375
|
+
return _ref14 = sstyled(styles), /*#__PURE__*/React.createElement(SDropdownMenuActions, _ref14.cn("SDropdownMenuActions", _objectSpread({}, _assignProps3({}, _ref3))));
|
|
375
376
|
}
|
|
376
377
|
function Menu(props) {
|
|
377
378
|
var _ref4 = arguments[0];
|
|
@@ -395,18 +396,18 @@ function Menu(props) {
|
|
|
395
396
|
role: null
|
|
396
397
|
}), /*#__PURE__*/React.createElement(DropdownMenu.List, _assignProps4({}, _ref4))));
|
|
397
398
|
}
|
|
398
|
-
function Item(
|
|
399
|
+
function Item(_ref24) {
|
|
399
400
|
var _ref5 = arguments[0],
|
|
400
|
-
|
|
401
|
-
var id =
|
|
402
|
-
styles =
|
|
403
|
-
disabled =
|
|
404
|
-
Children =
|
|
405
|
-
forwardRef =
|
|
406
|
-
role =
|
|
407
|
-
tabIndex =
|
|
408
|
-
actionsRef =
|
|
409
|
-
ariaChecked =
|
|
401
|
+
_ref15;
|
|
402
|
+
var id = _ref24.id,
|
|
403
|
+
styles = _ref24.styles,
|
|
404
|
+
disabled = _ref24.disabled,
|
|
405
|
+
Children = _ref24.Children,
|
|
406
|
+
forwardRef = _ref24.forwardRef,
|
|
407
|
+
role = _ref24.role,
|
|
408
|
+
tabIndex = _ref24.tabIndex,
|
|
409
|
+
actionsRef = _ref24.actionsRef,
|
|
410
|
+
ariaChecked = _ref24['aria-checked'];
|
|
410
411
|
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
411
412
|
var itemRef = React.useRef();
|
|
412
413
|
var _React$useState = React.useState(false),
|
|
@@ -415,8 +416,7 @@ function Item(_ref18) {
|
|
|
415
416
|
setHighlighted = _React$useState2[1];
|
|
416
417
|
var menuItemContextValue = {
|
|
417
418
|
contentId: id,
|
|
418
|
-
ref: itemRef,
|
|
419
|
-
forwardRef: forwardRef,
|
|
419
|
+
ref: forkRef(forwardRef, itemRef),
|
|
420
420
|
role: role,
|
|
421
421
|
tabIndex: tabIndex,
|
|
422
422
|
ariaChecked: ariaChecked,
|
|
@@ -466,32 +466,32 @@ function Item(_ref18) {
|
|
|
466
466
|
capture: true
|
|
467
467
|
});
|
|
468
468
|
};
|
|
469
|
-
});
|
|
470
|
-
return
|
|
469
|
+
}, [itemRef.current]);
|
|
470
|
+
return _ref15 = sstyled(styles), /*#__PURE__*/React.createElement(menuItemContext.Provider, {
|
|
471
471
|
value: menuItemContextValue
|
|
472
|
-
}, /*#__PURE__*/React.createElement(SDropdownMenuItemContainer,
|
|
473
|
-
"ref": advancedMode ? undefined :
|
|
472
|
+
}, /*#__PURE__*/React.createElement(SDropdownMenuItemContainer, _ref15.cn("SDropdownMenuItemContainer", _objectSpread({}, _assignProps5({
|
|
473
|
+
"ref": advancedMode ? undefined : menuItemContextValue.ref,
|
|
474
474
|
"use:highlighted": !disabled && highlighted && lastInteraction.isKeyboard(),
|
|
475
475
|
"use:role": advancedMode ? undefined : role,
|
|
476
476
|
"use:id": advancedMode ? undefined : id,
|
|
477
477
|
"use:tabIndex": advancedMode ? undefined : tabIndex,
|
|
478
478
|
"use:aria-checked": advancedMode ? undefined : ariaChecked
|
|
479
|
-
}, _ref5))), /*#__PURE__*/React.createElement(Children,
|
|
479
|
+
}, _ref5))), /*#__PURE__*/React.createElement(Children, _ref15.cn("Children", {}))));
|
|
480
480
|
}
|
|
481
481
|
function Addon(props) {
|
|
482
482
|
var _ref6 = arguments[0],
|
|
483
|
-
|
|
483
|
+
_ref16;
|
|
484
484
|
var SDropdownMenuItemAddon = Box;
|
|
485
|
-
return
|
|
485
|
+
return _ref16 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItemAddon, _ref16.cn("SDropdownMenuItemAddon", _objectSpread({}, _assignProps6({}, _ref6))));
|
|
486
486
|
}
|
|
487
487
|
function Trigger() {
|
|
488
488
|
var _ref7 = arguments[0];
|
|
489
489
|
return /*#__PURE__*/React.createElement(Dropdown.Trigger, _assignProps7({}, _ref7));
|
|
490
490
|
}
|
|
491
|
-
function ItemContent(
|
|
491
|
+
function ItemContent(_ref25) {
|
|
492
492
|
var _ref8 = arguments[0],
|
|
493
|
-
|
|
494
|
-
var styles =
|
|
493
|
+
_ref17;
|
|
494
|
+
var styles = _ref25.styles;
|
|
495
495
|
var SItemContent = Flex;
|
|
496
496
|
var ref = React.useRef();
|
|
497
497
|
var menuItemCtxValue = React.useContext(menuItemContext);
|
|
@@ -513,11 +513,11 @@ function ItemContent(_ref19) {
|
|
|
513
513
|
});
|
|
514
514
|
}
|
|
515
515
|
}, [menuItemCtxValue.ariaDescribes]);
|
|
516
|
-
return
|
|
516
|
+
return _ref17 = sstyled(styles), /*#__PURE__*/React.createElement(SItemContent, _ref17.cn("SItemContent", _objectSpread({}, _assignProps8({
|
|
517
517
|
"role": menuItemCtxValue.role,
|
|
518
518
|
"id": menuItemCtxValue.contentId,
|
|
519
519
|
"tabIndex": menuItemCtxValue.tabIndex,
|
|
520
|
-
"ref": forkRef(menuItemCtxValue.ref,
|
|
520
|
+
"ref": forkRef(menuItemCtxValue.ref, ref),
|
|
521
521
|
"use:aria-describedby": _toConsumableArray(describedby).join(' '),
|
|
522
522
|
"aria-haspopup": menuItemCtxValue.hasSubMenu ? 'true' : undefined,
|
|
523
523
|
"aria-expanded": subMenu,
|
|
@@ -527,32 +527,72 @@ function ItemContent(_ref19) {
|
|
|
527
527
|
"disabled": menuItemCtxValue.disabled
|
|
528
528
|
}, _ref8))));
|
|
529
529
|
}
|
|
530
|
-
function ItemContentText(
|
|
530
|
+
function ItemContentText(_ref26) {
|
|
531
531
|
var _ref9 = arguments[0],
|
|
532
|
-
|
|
533
|
-
var styles =
|
|
534
|
-
_ref20$ellipsis = _ref20.ellipsis,
|
|
535
|
-
ellipsis = _ref20$ellipsis === void 0 ? false : _ref20$ellipsis;
|
|
532
|
+
_ref18;
|
|
533
|
+
var styles = _ref26.styles;
|
|
536
534
|
var SItemContentText = Text;
|
|
537
|
-
|
|
538
|
-
return _ref14 = sstyled(styles), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SItemContentText, _ref14.cn("SItemContentText", _objectSpread({}, _assignProps9({
|
|
539
|
-
"ellipsis": ellipsis,
|
|
540
|
-
"hint:triggerRef": menuItemCtxValue.ref,
|
|
541
|
-
"hint:placement": 'right'
|
|
542
|
-
}, _ref9)))));
|
|
535
|
+
return _ref18 = sstyled(styles), /*#__PURE__*/React.createElement(SItemContentText, _ref18.cn("SItemContentText", _objectSpread({}, _assignProps9({}, _ref9))));
|
|
543
536
|
}
|
|
544
|
-
function ItemHint(
|
|
537
|
+
function ItemHint(_ref27) {
|
|
545
538
|
var _ref0 = arguments[0],
|
|
546
|
-
|
|
547
|
-
var styles =
|
|
539
|
+
_ref19;
|
|
540
|
+
var styles = _ref27.styles;
|
|
548
541
|
var SItemHint = Flex;
|
|
549
542
|
var _React$useContext = React.useContext(menuItemContext),
|
|
550
543
|
hintId = _React$useContext.hintId;
|
|
551
|
-
return
|
|
544
|
+
return _ref19 = sstyled(styles), /*#__PURE__*/React.createElement(SItemHint, _ref19.cn("SItemHint", _objectSpread({}, _assignProps0({
|
|
552
545
|
"id": hintId,
|
|
553
546
|
"aria-hidden": 'true'
|
|
554
547
|
}, _ref0))));
|
|
555
548
|
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* @deprecated Use Item hint
|
|
552
|
+
*/
|
|
553
|
+
function Hint(props) {
|
|
554
|
+
var _ref1 = arguments[0],
|
|
555
|
+
_ref20;
|
|
556
|
+
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
557
|
+
return _ref20 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItemContainer, _ref20.cn("SDropdownMenuItemContainer", _objectSpread({}, _assignProps1({
|
|
558
|
+
"variant": 'hint'
|
|
559
|
+
}, _ref1))));
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* @deprecated Use Group with title prop
|
|
563
|
+
*/
|
|
564
|
+
function Title(props) {
|
|
565
|
+
var _ref10 = arguments[0],
|
|
566
|
+
_ref21;
|
|
567
|
+
var SDropdownMenuItemContainer = Dropdown.Item;
|
|
568
|
+
return _ref21 = sstyled(props.styles), /*#__PURE__*/React.createElement(SDropdownMenuItemContainer, _ref21.cn("SDropdownMenuItemContainer", _objectSpread({}, _assignProps10({
|
|
569
|
+
"variant": 'title'
|
|
570
|
+
}, _ref10))));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @deprecated
|
|
575
|
+
*/
|
|
576
|
+
function Nesting(_ref28) {
|
|
577
|
+
var _ref11 = arguments[0];
|
|
578
|
+
var forwardRef = _ref28.forwardRef;
|
|
579
|
+
return /*#__PURE__*/React.createElement(DropdownMenu.Item, _assignProps11({
|
|
580
|
+
"ref": forwardRef
|
|
581
|
+
}, _ref11));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* @deprecated
|
|
586
|
+
*/
|
|
587
|
+
function NestingTrigger(_ref29) {
|
|
588
|
+
var _ref12 = arguments[0];
|
|
589
|
+
var forwardRef = _ref29.forwardRef;
|
|
590
|
+
return /*#__PURE__*/React.createElement(DropdownMenu.Item.Content, _assignProps12({
|
|
591
|
+
"tag": DropdownMenu.Trigger,
|
|
592
|
+
"ref": forwardRef,
|
|
593
|
+
"use:role": 'menuitem'
|
|
594
|
+
}, _ref12));
|
|
595
|
+
}
|
|
556
596
|
var DropdownMenu = createComponent(DropdownMenuRoot, {
|
|
557
597
|
Trigger: Trigger,
|
|
558
598
|
Popper: Dropdown.Popper,
|
|
@@ -566,6 +606,15 @@ var DropdownMenu = createComponent(DropdownMenuRoot, {
|
|
|
566
606
|
Text: ItemContentText,
|
|
567
607
|
Hint: ItemHint
|
|
568
608
|
}],
|
|
609
|
+
/**
|
|
610
|
+
* @deprecated. Use just Item. See examples on
|
|
611
|
+
*/
|
|
612
|
+
Nesting: [Nesting, {
|
|
613
|
+
Trigger: NestingTrigger,
|
|
614
|
+
Addon: Addon
|
|
615
|
+
}],
|
|
616
|
+
ItemTitle: Title,
|
|
617
|
+
ItemHint: Hint,
|
|
569
618
|
Group: Dropdown.Group
|
|
570
619
|
}, {
|
|
571
620
|
parent: [Dropdown]
|