@semcore/dropdown-menu 4.49.0-prerelease.5 → 4.49.0-prerelease.7

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.
Files changed (72) hide show
  1. package/lib/cjs/DropdownMenu.js +236 -257
  2. package/lib/cjs/DropdownMenu.js.map +1 -1
  3. package/lib/cjs/index.d.js.map +1 -1
  4. package/lib/cjs/index.js +1 -1
  5. package/lib/cjs/index.js.map +1 -1
  6. package/lib/cjs/style/dropdown-menu.shadow.css +84 -27
  7. package/lib/cjs/translations/__intergalactic-dynamic-locales.js +5 -4
  8. package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
  9. package/lib/cjs/translations/de.json +3 -1
  10. package/lib/cjs/translations/es.json +3 -1
  11. package/lib/cjs/translations/fr.json +3 -1
  12. package/lib/cjs/translations/it.json +3 -1
  13. package/lib/cjs/translations/ja.json +3 -1
  14. package/lib/cjs/translations/ko.json +3 -1
  15. package/lib/cjs/translations/nl.json +3 -1
  16. package/lib/cjs/translations/pl.json +3 -1
  17. package/lib/cjs/translations/pt.json +3 -1
  18. package/lib/cjs/translations/sv.json +3 -1
  19. package/lib/cjs/translations/tr.json +3 -1
  20. package/lib/cjs/translations/vi.json +3 -1
  21. package/lib/cjs/translations/zh.json +3 -1
  22. package/lib/es6/DropdownMenu.js +228 -248
  23. package/lib/es6/DropdownMenu.js.map +1 -1
  24. package/lib/es6/index.d.js.map +1 -1
  25. package/lib/es6/index.js.map +1 -1
  26. package/lib/es6/style/dropdown-menu.shadow.css +84 -27
  27. package/lib/es6/translations/__intergalactic-dynamic-locales.js +2 -2
  28. package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
  29. package/lib/es6/translations/de.json +3 -1
  30. package/lib/es6/translations/es.json +3 -1
  31. package/lib/es6/translations/fr.json +3 -1
  32. package/lib/es6/translations/it.json +3 -1
  33. package/lib/es6/translations/ja.json +3 -1
  34. package/lib/es6/translations/ko.json +3 -1
  35. package/lib/es6/translations/nl.json +3 -1
  36. package/lib/es6/translations/pl.json +3 -1
  37. package/lib/es6/translations/pt.json +3 -1
  38. package/lib/es6/translations/sv.json +3 -1
  39. package/lib/es6/translations/tr.json +3 -1
  40. package/lib/es6/translations/vi.json +3 -1
  41. package/lib/es6/translations/zh.json +3 -1
  42. package/lib/esm/DropdownMenu.mjs +188 -215
  43. package/lib/esm/style/dropdown-menu.shadow.css +84 -27
  44. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +2 -2
  45. package/lib/esm/translations/de.json.mjs +6 -2
  46. package/lib/esm/translations/es.json.mjs +6 -2
  47. package/lib/esm/translations/fr.json.mjs +6 -2
  48. package/lib/esm/translations/it.json.mjs +6 -2
  49. package/lib/esm/translations/ja.json.mjs +6 -2
  50. package/lib/esm/translations/ko.json.mjs +6 -2
  51. package/lib/esm/translations/nl.json.mjs +6 -2
  52. package/lib/esm/translations/pl.json.mjs +6 -2
  53. package/lib/esm/translations/pt.json.mjs +6 -2
  54. package/lib/esm/translations/sv.json.mjs +6 -2
  55. package/lib/esm/translations/tr.json.mjs +6 -2
  56. package/lib/esm/translations/vi.json.mjs +6 -2
  57. package/lib/esm/translations/zh.json.mjs +6 -2
  58. package/lib/types/index.d.ts +79 -30
  59. package/package.json +12 -12
  60. package/lib/cjs/components/Context.js +0 -16
  61. package/lib/cjs/components/Context.js.map +0 -1
  62. package/lib/cjs/components/VirtualList.js +0 -148
  63. package/lib/cjs/components/VirtualList.js.map +0 -1
  64. package/lib/es6/components/Context.js +0 -9
  65. package/lib/es6/components/Context.js.map +0 -1
  66. package/lib/es6/components/VirtualList.js +0 -143
  67. package/lib/es6/components/VirtualList.js.map +0 -1
  68. package/lib/esm/components/Context.mjs +0 -11
  69. package/lib/esm/components/VirtualList.mjs +0 -135
  70. package/lib/types/components/Context.d.ts +0 -2
  71. package/lib/types/components/VirtualList.d.ts +0 -28
  72. package/lib/types/translations/__intergalactic-dynamic-locales.d.ts +0 -16
@@ -1,148 +0,0 @@
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 _react = _interopRequireDefault(require("react"));
17
- var _Context = require("./Context");
18
- /*!__reshadow-styles__:"../style/dropdown-menu.shadow.css"*/
19
- var style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SDropdownMenuList_1d74h_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_1d74h_gg_ .___SBar_1d74h_gg_{z-index:3}.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowHorizontal_1d74h_gg_:after,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowHorizontal_1d74h_gg_:before,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowVertical_1d74h_gg_:after,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowVertical_1d74h_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1d74h_gg_ .___SItemContent_1d74h_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1d74h_gg_.__nesting-trigger_1d74h_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1d74h_gg_,.___SItemContentText_1d74h_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1d74h_gg_:first-child,.___SItemContentText_1d74h_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1d74h_gg_:last-child,.___SItemContentText_1d74h_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1d74h_gg_,.___SDropdownMenuNesting_1d74h_gg_._size_l_1d74h_gg_,.___SDropdownMenuNesting_1d74h_gg_._size_m_1d74h_gg_{padding:0}.___SDropdownMenuNesting_1d74h_gg_.__highlighted_1d74h_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_1d74h_gg_.__highlighted_1d74h_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469))}@media (color-gamut:p3){.___SDropdownMenuNesting_1d74h_gg_.__highlighted_1d74h_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, color(display-p3 0.03256 0.12227 0.83249 / 0.469))}}}.___SDropdownNestingItem_1d74h_gg_._size_l_1d74h_gg_,.___SDropdownNestingItem_1d74h_gg_._size_m_1d74h_gg_{padding-right:0}.___SDropdownNestingItem_1d74h_gg_ .___SDropdownMenuItemContainer_1d74h_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@supports (color:color(display-p3 0 0 0%)){.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SScrollContainer_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true]){overscroll-behavior:none}", /*__inner_css_end__*/"1d74h_gg_"),
20
- /*__reshadow_css_end__*/
21
- {
22
- "__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1d74h_gg_",
23
- "_nesting-trigger": "__nesting-trigger_1d74h_gg_",
24
- "__SDropdownMenuNesting": "___SDropdownMenuNesting_1d74h_gg_",
25
- "_size_l": "_size_l_1d74h_gg_",
26
- "_size_m": "_size_m_1d74h_gg_",
27
- "_highlighted": "__highlighted_1d74h_gg_",
28
- "__SDropdownNestingItem": "___SDropdownNestingItem_1d74h_gg_",
29
- "__SItemHint": "___SItemHint_1d74h_gg_",
30
- "__SDropdownMenuList": "___SDropdownMenuList_1d74h_gg_",
31
- "__SBar": "___SBar_1d74h_gg_",
32
- "__SShadowHorizontal": "___SShadowHorizontal_1d74h_gg_",
33
- "__SShadowVertical": "___SShadowVertical_1d74h_gg_",
34
- "__SItemContent": "___SItemContent_1d74h_gg_",
35
- "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1d74h_gg_",
36
- "__SItemContentText": "___SItemContentText_1d74h_gg_",
37
- "__SScrollContainer": "___SScrollContainer_1d74h_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
- rowsBuffer = _this$asProps.rowsBuffer;
73
- setTimeout(function () {
74
- var _this2$listRef$curren, _this2$listRef$curren2, _this2$containerRef$c;
75
- 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;
76
- (_this2$containerRef$c = _this2.containerRef.current) === null || _this2$containerRef$c === void 0 || _this2$containerRef$c.scrollTo({
77
- top: index * rowHeight - listHeight + rowHeight / 2
78
- });
79
- if (index <= rowsBuffer) {
80
- _this2.forceUpdate(); // we need this for correct render all items with calculated container height
81
- }
82
- }, 10); // 10 for correct work in safari
83
- }
84
- }, {
85
- key: "render",
86
- value: function render() {
87
- var _ref = this.asProps,
88
- _ref2,
89
- _this$listRef$current,
90
- _this$listRef$current2;
91
- var SDropdownMenuList = _baseComponents.ScrollArea;
92
- var SBar = _baseComponents.ScrollArea.Bar;
93
- var _this$state = this.state,
94
- scrollDirection = _this$state.scrollDirection,
95
- scrollTop = _this$state.scrollTop;
96
- var _this$asProps2 = this.asProps,
97
- rows = _this$asProps2.rows,
98
- rowHeight = _this$asProps2.rowHeight,
99
- rowsBuffer = _this$asProps2.rowsBuffer,
100
- styles = _this$asProps2.styles,
101
- RenderRow = _this$asProps2.renderRow,
102
- customData = _this$asProps2.customData;
103
- var offsetHeight = (_this$listRef$current = (_this$listRef$current2 = this.listRef.current) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.offsetHeight) !== null && _this$listRef$current !== void 0 ? _this$listRef$current : 0;
104
- var prevPrepared = scrollDirection === 'down' ? rowsBuffer / 2 : rowsBuffer;
105
- var nextPrepared = scrollDirection === 'up' ? rowsBuffer / 2 : rowsBuffer;
106
- var startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);
107
- var lastIndex = Math.min(Math.ceil((scrollTop + offsetHeight) / rowHeight) + nextPrepared, rows.length);
108
- var rowsToRender = rows.slice(startIndex, lastIndex);
109
- var rowMarginTop = rowHeight * startIndex;
110
- var rowMarginBottom = rowHeight * (rows.length - lastIndex);
111
- 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)({
112
- "shadow": true,
113
- "shadowSize": 16,
114
- "shadowTheme": 'light',
115
- "onScroll": this.handleScroll,
116
- "data-is-virtual": 'true',
117
- "ref": this.listRef
118
- }, _ref))), /*#__PURE__*/_react["default"].createElement(_baseComponents.ScrollArea.Container, {
119
- ref: this.containerRef,
120
- tabIndex: undefined,
121
- h: rows.length * rowHeight
122
- }, /*#__PURE__*/_react["default"].createElement(_baseComponents.Box, _ref2.cn("Box", {
123
- "h": rowMarginTop
124
- })), rowsToRender.map(function (item, index) {
125
- // @ts-ignore
126
- return /*#__PURE__*/_react["default"].createElement(RenderRow, {
127
- key: startIndex + index,
128
- row: item,
129
- index: startIndex + index,
130
- data: customData
131
- });
132
- }), /*#__PURE__*/_react["default"].createElement(_baseComponents.Box, _ref2.cn("Box", {
133
- "h": rowMarginBottom
134
- }))), /*#__PURE__*/_react["default"].createElement(SBar, _ref2.cn("SBar", {
135
- "orientation": 'horizontal'
136
- })), /*#__PURE__*/_react["default"].createElement(SBar, _ref2.cn("SBar", {
137
- "orientation": 'vertical'
138
- }))));
139
- }
140
- }]);
141
- }(_core.Component);
142
- (0, _defineProperty2["default"])(VirtualListRoot, "displayName", 'VirtualList');
143
- (0, _defineProperty2["default"])(VirtualListRoot, "style", style);
144
- (0, _defineProperty2["default"])(VirtualListRoot, "defaultProps", {
145
- rowsBuffer: 6
146
- });
147
- var VirtualList = exports.VirtualList = (0, _core.createComponent)(VirtualListRoot);
148
- //# sourceMappingURL=VirtualList.js.map
@@ -1 +0,0 @@
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,eAAA,KAAAW,MAAA,CAAAJ,IAAA;IAAA,IAAAK,gBAAA,aAAAV,KAAA,+BAQJW,iBAAK,CAACC,SAAS,CAAiB,CAAC;IAAA,IAAAF,gBAAA,aAAAV,KAAA,0BACtCW,iBAAK,CAACC,SAAS,CAAiB,CAAC;IAAA,IAAAF,gBAAA,aAAAV,KAAA,WAE5B;MACba,SAAS,EAAE,CAAC;MACZC,eAAe,EAAE;IACnB,CAAC;IAAA,IAAAJ,gBAAA,aAAAV,KAAA,kBAec,UAACe,CAAuC,EAAK;MAC1D,IAAIA,CAAC,CAACC,MAAM,YAAYC,WAAW,EAAE;QACnC,IAAMH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nC,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,9 +0,0 @@
1
- import { hideScrollBarsFromScreenReadersContext } from '@semcore/base-components';
2
- import React from 'react';
3
- export var ListBoxContextProvider = function ListBoxContextProvider(_ref) {
4
- var children = _ref.children;
5
- return /*#__PURE__*/React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
6
- value: true
7
- }, children);
8
- };
9
- //# sourceMappingURL=Context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Context.js","names":["hideScrollBarsFromScreenReadersContext","React","ListBoxContextProvider","_ref","children","createElement","Provider","value"],"sources":["../../../src/components/Context.tsx"],"sourcesContent":["import { hideScrollBarsFromScreenReadersContext } from '@semcore/base-components';\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,SAASA,sCAAsC,QAAQ,0BAA0B;AACjF,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAO,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAAAC,IAAA;EAAA,IAAMC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;EAAA,oBAC/CH,KAAA,CAAAI,aAAA,CAACL,sCAAsC,CAACM,QAAQ;IAACC,KAAK,EAAE;EAAK,GAC1DH,QAC8C,CAAC;AAAA,CACnD","ignoreList":[]}
@@ -1,143 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _callSuper from "@babel/runtime/helpers/callSuper";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- import { sstyled as _sstyled } from "@semcore/core";
8
- import { assignProps as _assignProps } from "@semcore/core";
9
- import { ScrollArea as ScrollAreaComponent, Box } from '@semcore/base-components';
10
- import { Root, Component, createComponent, sstyled } from '@semcore/core';
11
- import React from 'react';
12
- import { ListBoxContextProvider } from './Context';
13
- /*!__reshadow-styles__:"../style/dropdown-menu.shadow.css"*/
14
- var style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SDropdownMenuList_1d74h_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_1d74h_gg_ .___SBar_1d74h_gg_{z-index:3}.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowHorizontal_1d74h_gg_:after,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowHorizontal_1d74h_gg_:before,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowVertical_1d74h_gg_:after,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true])) .___SShadowVertical_1d74h_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1d74h_gg_ .___SItemContent_1d74h_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1d74h_gg_.__nesting-trigger_1d74h_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1d74h_gg_,.___SItemContentText_1d74h_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1d74h_gg_:first-child,.___SItemContentText_1d74h_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1d74h_gg_:last-child,.___SItemContentText_1d74h_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1d74h_gg_,.___SDropdownMenuNesting_1d74h_gg_._size_l_1d74h_gg_,.___SDropdownMenuNesting_1d74h_gg_._size_m_1d74h_gg_{padding:0}.___SDropdownMenuNesting_1d74h_gg_.__highlighted_1d74h_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_1d74h_gg_.__highlighted_1d74h_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469))}@media (color-gamut:p3){.___SDropdownMenuNesting_1d74h_gg_.__highlighted_1d74h_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, color(display-p3 0.03256 0.12227 0.83249 / 0.469))}}}.___SDropdownNestingItem_1d74h_gg_._size_l_1d74h_gg_,.___SDropdownNestingItem_1d74h_gg_._size_m_1d74h_gg_{padding-right:0}.___SDropdownNestingItem_1d74h_gg_ .___SDropdownMenuItemContainer_1d74h_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@supports (color:color(display-p3 0 0 0%)){.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SScrollContainer_1d74h_gg_:has([data-ui-name=\"DropdownMenu.Group\"][data-sticky=true]){overscroll-behavior:none}", /*__inner_css_end__*/"1d74h_gg_"),
15
- /*__reshadow_css_end__*/
16
- {
17
- "__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1d74h_gg_",
18
- "_nesting-trigger": "__nesting-trigger_1d74h_gg_",
19
- "__SDropdownMenuNesting": "___SDropdownMenuNesting_1d74h_gg_",
20
- "_size_l": "_size_l_1d74h_gg_",
21
- "_size_m": "_size_m_1d74h_gg_",
22
- "_highlighted": "__highlighted_1d74h_gg_",
23
- "__SDropdownNestingItem": "___SDropdownNestingItem_1d74h_gg_",
24
- "__SItemHint": "___SItemHint_1d74h_gg_",
25
- "__SDropdownMenuList": "___SDropdownMenuList_1d74h_gg_",
26
- "__SBar": "___SBar_1d74h_gg_",
27
- "__SShadowHorizontal": "___SShadowHorizontal_1d74h_gg_",
28
- "__SShadowVertical": "___SShadowVertical_1d74h_gg_",
29
- "__SItemContent": "___SItemContent_1d74h_gg_",
30
- "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1d74h_gg_",
31
- "__SItemContentText": "___SItemContentText_1d74h_gg_",
32
- "__SScrollContainer": "___SScrollContainer_1d74h_gg_"
33
- });
34
- var VirtualListRoot = /*#__PURE__*/function (_Component) {
35
- function VirtualListRoot() {
36
- var _this;
37
- _classCallCheck(this, VirtualListRoot);
38
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
39
- args[_key] = arguments[_key];
40
- }
41
- _this = _callSuper(this, VirtualListRoot, [].concat(args));
42
- _defineProperty(_this, "containerRef", /*#__PURE__*/React.createRef());
43
- _defineProperty(_this, "listRef", /*#__PURE__*/React.createRef());
44
- _defineProperty(_this, "state", {
45
- scrollTop: 0,
46
- scrollDirection: 'down'
47
- });
48
- _defineProperty(_this, "handleScroll", function (e) {
49
- if (e.target instanceof HTMLElement) {
50
- var scrollDirection = e.target.scrollTop > _this.state.scrollTop ? 'down' : 'up';
51
- _this.setState({
52
- scrollDirection: scrollDirection,
53
- scrollTop: e.target.scrollTop
54
- });
55
- }
56
- });
57
- return _this;
58
- }
59
- _inherits(VirtualListRoot, _Component);
60
- return _createClass(VirtualListRoot, [{
61
- key: "componentDidMount",
62
- value: function componentDidMount() {
63
- var _this2 = this;
64
- var _this$asProps = this.asProps,
65
- index = _this$asProps.index,
66
- rowHeight = _this$asProps.rowHeight,
67
- rowsBuffer = _this$asProps.rowsBuffer;
68
- setTimeout(function () {
69
- var _this2$listRef$curren, _this2$listRef$curren2, _this2$containerRef$c;
70
- 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;
71
- (_this2$containerRef$c = _this2.containerRef.current) === null || _this2$containerRef$c === void 0 || _this2$containerRef$c.scrollTo({
72
- top: index * rowHeight - listHeight + rowHeight / 2
73
- });
74
- if (index <= rowsBuffer) {
75
- _this2.forceUpdate(); // we need this for correct render all items with calculated container height
76
- }
77
- }, 10); // 10 for correct work in safari
78
- }
79
- }, {
80
- key: "render",
81
- value: function render() {
82
- var _ref = this.asProps,
83
- _ref2,
84
- _this$listRef$current,
85
- _this$listRef$current2;
86
- var SDropdownMenuList = ScrollAreaComponent;
87
- var SBar = ScrollAreaComponent.Bar;
88
- var _this$state = this.state,
89
- scrollDirection = _this$state.scrollDirection,
90
- scrollTop = _this$state.scrollTop;
91
- var _this$asProps2 = this.asProps,
92
- rows = _this$asProps2.rows,
93
- rowHeight = _this$asProps2.rowHeight,
94
- rowsBuffer = _this$asProps2.rowsBuffer,
95
- styles = _this$asProps2.styles,
96
- RenderRow = _this$asProps2.renderRow,
97
- customData = _this$asProps2.customData;
98
- var offsetHeight = (_this$listRef$current = (_this$listRef$current2 = this.listRef.current) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.offsetHeight) !== null && _this$listRef$current !== void 0 ? _this$listRef$current : 0;
99
- var prevPrepared = scrollDirection === 'down' ? rowsBuffer / 2 : rowsBuffer;
100
- var nextPrepared = scrollDirection === 'up' ? rowsBuffer / 2 : rowsBuffer;
101
- var startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);
102
- var lastIndex = Math.min(Math.ceil((scrollTop + offsetHeight) / rowHeight) + nextPrepared, rows.length);
103
- var rowsToRender = rows.slice(startIndex, lastIndex);
104
- var rowMarginTop = rowHeight * startIndex;
105
- var rowMarginBottom = rowHeight * (rows.length - lastIndex);
106
- return _ref2 = sstyled(styles), /*#__PURE__*/React.createElement(ListBoxContextProvider, _ref2.cn("ListBoxContextProvider", {}), /*#__PURE__*/React.createElement(SDropdownMenuList, _ref2.cn("SDropdownMenuList", _objectSpread({}, _assignProps({
107
- "shadow": true,
108
- "shadowSize": 16,
109
- "shadowTheme": 'light',
110
- "onScroll": this.handleScroll,
111
- "data-is-virtual": 'true',
112
- "ref": this.listRef
113
- }, _ref))), /*#__PURE__*/React.createElement(ScrollAreaComponent.Container, {
114
- ref: this.containerRef,
115
- tabIndex: undefined,
116
- h: rows.length * rowHeight
117
- }, /*#__PURE__*/React.createElement(Box, _ref2.cn("Box", {
118
- "h": rowMarginTop
119
- })), rowsToRender.map(function (item, index) {
120
- // @ts-ignore
121
- return /*#__PURE__*/React.createElement(RenderRow, {
122
- key: startIndex + index,
123
- row: item,
124
- index: startIndex + index,
125
- data: customData
126
- });
127
- }), /*#__PURE__*/React.createElement(Box, _ref2.cn("Box", {
128
- "h": rowMarginBottom
129
- }))), /*#__PURE__*/React.createElement(SBar, _ref2.cn("SBar", {
130
- "orientation": 'horizontal'
131
- })), /*#__PURE__*/React.createElement(SBar, _ref2.cn("SBar", {
132
- "orientation": 'vertical'
133
- }))));
134
- }
135
- }]);
136
- }(Component);
137
- _defineProperty(VirtualListRoot, "displayName", 'VirtualList');
138
- _defineProperty(VirtualListRoot, "style", style);
139
- _defineProperty(VirtualListRoot, "defaultProps", {
140
- rowsBuffer: 6
141
- });
142
- export var VirtualList = createComponent(VirtualListRoot);
143
- //# sourceMappingURL=VirtualList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VirtualList.js","names":["ScrollArea","ScrollAreaComponent","Box","Root","Component","createComponent","sstyled","React","ListBoxContextProvider","style","_sstyled","insert","VirtualListRoot","_Component","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","createRef","scrollTop","scrollDirection","e","target","HTMLElement","state","setState","_inherits","_createClass","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","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","cn","_objectSpread","_assignProps","handleScroll","Container","ref","tabIndex","undefined","h","map","item","row","data","VirtualList"],"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.ComponentA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CAAA4B,EAAA;QAAA,KAAIF;MAAe,EAAG,CACG,CAAC,eAChC9E,KAAA,CAAA+E,aAAA,CAACvB,IAAI,EAAAJ,KAAA,CAAA4B,EAAA;QAAA,eAAa;MAAY,EAAE,CAAC,eACjChF,KAAA,CAAA+E,aAAA,CAACvB,IAAI,EAAAJ,KAAA,CAAA4B,EAAA;QAAA,eAAa;MAAU,EAAE,CACb,CACG,CAAC;IAE7B;EAAC;AAAA,EAtFiEnF,SAAS;AAAAoB,eAAA,CAAvEZ,eAAe,iBACE,aAAa;AAAAY,eAAA,CAD9BZ,eAAe,WAEJH,KAAK;AAAAe,eAAA,CAFhBZ,eAAe,kBAIG;EACpB+B,UAAU,EAAE;AACd,CAAC;AA0FH,OAAO,IAAMyD,WAAW,GAAG/F,eAAe,CAACO,eAAe,CAAyB","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- import { hideScrollBarsFromScreenReadersContext } from "@semcore/base-components";
2
- import React from "react";
3
- var ListBoxContextProvider = function ListBoxContextProvider2(_ref) {
4
- var children = _ref.children;
5
- return /* @__PURE__ */ React.createElement(hideScrollBarsFromScreenReadersContext.Provider, {
6
- value: true
7
- }, children);
8
- };
9
- export {
10
- ListBoxContextProvider
11
- };
@@ -1,135 +0,0 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/esm/createClass";
4
- import _callSuper from "@babel/runtime/helpers/esm/callSuper";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import { sstyled, assignProps, Component, createComponent } from "@semcore/core";
8
- import { ScrollArea, Box } from "@semcore/base-components";
9
- import React from "react";
10
- import { ListBoxContextProvider } from "./Context.mjs";
11
- /*!__reshadow-styles__:"../style/dropdown-menu.shadow.css"*/
12
- var style = (
13
- /*__reshadow_css_start__*/
14
- (sstyled.insert(
15
- /*__inner_css_start__*/
16
- '.___SDropdownMenuList_1d74h_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_1d74h_gg_ .___SBar_1d74h_gg_{z-index:3}.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name="DropdownMenu.Group"][data-sticky=true])) .___SShadowHorizontal_1d74h_gg_:after,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name="DropdownMenu.Group"][data-sticky=true])) .___SShadowHorizontal_1d74h_gg_:before,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name="DropdownMenu.Group"][data-sticky=true])) .___SShadowVertical_1d74h_gg_:after,.___SDropdownMenuList_1d74h_gg_:not(.___SDropdownMenuList_1d74h_gg_:has([data-ui-name="DropdownMenu.Group"][data-sticky=true])) .___SShadowVertical_1d74h_gg_:before{border-radius:var(--intergalactic-control-rounded, 6px)}.___SDropdownMenuItemContainer_1d74h_gg_ .___SItemContent_1d74h_gg_:focus-visible{outline:0}.___SDropdownMenuItemContainer_1d74h_gg_.__nesting-trigger_1d74h_gg_{justify-content:space-between}.___SDropdownMenuItemAddon_1d74h_gg_,.___SItemContentText_1d74h_gg_{display:inline-flex;margin-left:var(--intergalactic-spacing-1x, 4px);margin-right:var(--intergalactic-spacing-1x, 4px)}.___SDropdownMenuItemAddon_1d74h_gg_:first-child,.___SItemContentText_1d74h_gg_:first-child{margin-left:0}.___SDropdownMenuItemAddon_1d74h_gg_:last-child,.___SItemContentText_1d74h_gg_:last-child{margin-right:0}.___SDropdownMenuNesting_1d74h_gg_,.___SDropdownMenuNesting_1d74h_gg_._size_l_1d74h_gg_,.___SDropdownMenuNesting_1d74h_gg_._size_m_1d74h_gg_{padding:0}.___SDropdownMenuNesting_1d74h_gg_.__highlighted_1d74h_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_1d74h_gg_.__highlighted_1d74h_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, rgba(0, 32, 221, 0.469))}@media (color-gamut:p3){.___SDropdownMenuNesting_1d74h_gg_.__highlighted_1d74h_gg_{outline-color:var(--intergalactic-keyboard-focus-outline, color(display-p3 0.03256 0.12227 0.83249 / 0.469))}}}.___SDropdownNestingItem_1d74h_gg_._size_l_1d74h_gg_,.___SDropdownNestingItem_1d74h_gg_._size_m_1d74h_gg_{padding-right:0}.___SDropdownNestingItem_1d74h_gg_ .___SDropdownMenuItemContainer_1d74h_gg_{width:auto;padding-top:0;padding-bottom:0;padding-left:0;min-height:auto}.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@supports (color:color(display-p3 0 0 0%)){.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, rgba(0, 3, 0, 0.583))}@media (color-gamut:p3){.___SItemHint_1d74h_gg_{color:var(--intergalactic-text-secondary, color(display-p3 0.00228 0.01289 0.00252 / 0.583))}}}.___SScrollContainer_1d74h_gg_:has([data-ui-name="DropdownMenu.Group"][data-sticky=true]){overscroll-behavior:none}',
17
- /*__inner_css_end__*/
18
- "1d74h_gg_"
19
- ), /*__reshadow_css_end__*/
20
- {
21
- "__SDropdownMenuItemContainer": "___SDropdownMenuItemContainer_1d74h_gg_",
22
- "_nesting-trigger": "__nesting-trigger_1d74h_gg_",
23
- "__SDropdownMenuNesting": "___SDropdownMenuNesting_1d74h_gg_",
24
- "_size_l": "_size_l_1d74h_gg_",
25
- "_size_m": "_size_m_1d74h_gg_",
26
- "_highlighted": "__highlighted_1d74h_gg_",
27
- "__SDropdownNestingItem": "___SDropdownNestingItem_1d74h_gg_",
28
- "__SItemHint": "___SItemHint_1d74h_gg_",
29
- "__SDropdownMenuList": "___SDropdownMenuList_1d74h_gg_",
30
- "__SBar": "___SBar_1d74h_gg_",
31
- "__SShadowHorizontal": "___SShadowHorizontal_1d74h_gg_",
32
- "__SShadowVertical": "___SShadowVertical_1d74h_gg_",
33
- "__SItemContent": "___SItemContent_1d74h_gg_",
34
- "__SDropdownMenuItemAddon": "___SDropdownMenuItemAddon_1d74h_gg_",
35
- "__SItemContentText": "___SItemContentText_1d74h_gg_",
36
- "__SScrollContainer": "___SScrollContainer_1d74h_gg_"
37
- })
38
- );
39
- var VirtualListRoot = /* @__PURE__ */ (function(_Component) {
40
- function VirtualListRoot2() {
41
- var _this;
42
- _classCallCheck(this, VirtualListRoot2);
43
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
44
- args[_key] = arguments[_key];
45
- }
46
- _this = _callSuper(this, VirtualListRoot2, [].concat(args));
47
- _defineProperty(_this, "containerRef", /* @__PURE__ */ React.createRef());
48
- _defineProperty(_this, "listRef", /* @__PURE__ */ React.createRef());
49
- _defineProperty(_this, "state", {
50
- scrollTop: 0,
51
- scrollDirection: "down"
52
- });
53
- _defineProperty(_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,
58
- scrollTop: e.target.scrollTop
59
- });
60
- }
61
- });
62
- return _this;
63
- }
64
- _inherits(VirtualListRoot2, _Component);
65
- return _createClass(VirtualListRoot2, [{
66
- key: "componentDidMount",
67
- value: function componentDidMount() {
68
- var _this2 = this;
69
- var _this$asProps = this.asProps, index = _this$asProps.index, rowHeight = _this$asProps.rowHeight, rowsBuffer = _this$asProps.rowsBuffer;
70
- setTimeout(function() {
71
- var _this2$listRef$curren, _this2$listRef$curren2, _this2$containerRef$c;
72
- 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;
73
- (_this2$containerRef$c = _this2.containerRef.current) === null || _this2$containerRef$c === void 0 || _this2$containerRef$c.scrollTo({
74
- top: index * rowHeight - listHeight + rowHeight / 2
75
- });
76
- if (index <= rowsBuffer) {
77
- _this2.forceUpdate();
78
- }
79
- }, 10);
80
- }
81
- }, {
82
- key: "render",
83
- value: function render() {
84
- var _ref = this.asProps, _ref2, _this$listRef$current, _this$listRef$current2;
85
- var SDropdownMenuList = ScrollArea;
86
- var SBar = ScrollArea.Bar;
87
- var _this$state = this.state, scrollDirection = _this$state.scrollDirection, scrollTop = _this$state.scrollTop;
88
- var _this$asProps2 = this.asProps, rows = _this$asProps2.rows, rowHeight = _this$asProps2.rowHeight, rowsBuffer = _this$asProps2.rowsBuffer, styles = _this$asProps2.styles, RenderRow = _this$asProps2.renderRow, customData = _this$asProps2.customData;
89
- var offsetHeight = (_this$listRef$current = (_this$listRef$current2 = this.listRef.current) === null || _this$listRef$current2 === void 0 ? void 0 : _this$listRef$current2.offsetHeight) !== null && _this$listRef$current !== void 0 ? _this$listRef$current : 0;
90
- var prevPrepared = scrollDirection === "down" ? rowsBuffer / 2 : rowsBuffer;
91
- var nextPrepared = scrollDirection === "up" ? rowsBuffer / 2 : rowsBuffer;
92
- var startIndex = Math.max(Math.floor(scrollTop / rowHeight) - prevPrepared, 0);
93
- var lastIndex = Math.min(Math.ceil((scrollTop + offsetHeight) / rowHeight) + nextPrepared, rows.length);
94
- var rowsToRender = rows.slice(startIndex, lastIndex);
95
- var rowMarginTop = rowHeight * startIndex;
96
- var rowMarginBottom = rowHeight * (rows.length - lastIndex);
97
- return _ref2 = sstyled(styles), /* @__PURE__ */ React.createElement(ListBoxContextProvider, _ref2.cn("ListBoxContextProvider", {}), /* @__PURE__ */ React.createElement(SDropdownMenuList, _ref2.cn("SDropdownMenuList", _objectSpread({}, assignProps({
98
- "shadow": true,
99
- "shadowSize": 16,
100
- "shadowTheme": "light",
101
- "onScroll": this.handleScroll,
102
- "data-is-virtual": "true",
103
- "ref": this.listRef
104
- }, _ref))), /* @__PURE__ */ React.createElement(ScrollArea.Container, {
105
- ref: this.containerRef,
106
- tabIndex: void 0,
107
- h: rows.length * rowHeight
108
- }, /* @__PURE__ */ React.createElement(Box, _ref2.cn("Box", {
109
- "h": rowMarginTop
110
- })), rowsToRender.map(function(item, index) {
111
- return /* @__PURE__ */ React.createElement(RenderRow, {
112
- key: startIndex + index,
113
- row: item,
114
- index: startIndex + index,
115
- data: customData
116
- });
117
- }), /* @__PURE__ */ React.createElement(Box, _ref2.cn("Box", {
118
- "h": rowMarginBottom
119
- }))), /* @__PURE__ */ React.createElement(SBar, _ref2.cn("SBar", {
120
- "orientation": "horizontal"
121
- })), /* @__PURE__ */ React.createElement(SBar, _ref2.cn("SBar", {
122
- "orientation": "vertical"
123
- }))));
124
- }
125
- }]);
126
- })(Component);
127
- _defineProperty(VirtualListRoot, "displayName", "VirtualList");
128
- _defineProperty(VirtualListRoot, "style", style);
129
- _defineProperty(VirtualListRoot, "defaultProps", {
130
- rowsBuffer: 6
131
- });
132
- var VirtualList = createComponent(VirtualListRoot);
133
- export {
134
- VirtualList
135
- };
@@ -1,2 +0,0 @@
1
- import React from 'react';
2
- export declare const ListBoxContextProvider: ({ children }: React.PropsWithChildren) => React.JSX.Element;
@@ -1,28 +0,0 @@
1
- import { Box } from '@semcore/base-components';
2
- import type { Intergalactic } from '@semcore/core';
3
- import React from 'react';
4
- export type RenderRowProps<T, D = never> = {
5
- index: number;
6
- row: T;
7
- data: [D] extends [never] ? undefined : D;
8
- };
9
- type VirtualListProps<T, D extends object = never> = {
10
- /** List of all rows in ddMenu */
11
- rows: T[];
12
- /** Method for render row, it's better to wrap it via React.memo */
13
- renderRow: (props: RenderRowProps<T, D>) => React.ReactNode;
14
- /** The height of row. For now, you should calculate it on your side. */
15
- rowHeight: number;
16
- /** The buffer of rows out of visible rows
17
- * @default 10
18
- */
19
- rowsBuffer?: number;
20
- } & ([D] extends [never] ? {
21
- customData?: undefined;
22
- } : {
23
- /** Some custom data for each renderRow function */
24
- customData: D;
25
- });
26
- export type VirtualListComponent = (<T = string, D extends object = never>(props: Intergalactic.InternalTypings.EfficientOmit<Intergalactic.InternalTypings.ComponentProps<typeof Box, 'div', VirtualListProps<T, D>>, 'tag' | 'children'>) => Intergalactic.InternalTypings.ComponentRenderingResults) & Intergalactic.InternalTypings.ComponentAdditive<typeof Box, 'div', VirtualListProps<any, any>>;
27
- export declare const VirtualList: VirtualListComponent;
28
- export {};
@@ -1,16 +0,0 @@
1
- export declare const localizedMessages: {
2
- de: {};
3
- en: {};
4
- es: {};
5
- fr: {};
6
- it: {};
7
- ja: {};
8
- ko: {};
9
- nl: {};
10
- pt: {};
11
- tr: {};
12
- vi: {};
13
- zh: {};
14
- pl: {};
15
- sv: {};
16
- };