@react-fabric/data 1.0.0-beta.57 → 1.0.0-beta.59
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/dist/cjs/table/HeaderCell.js +4 -9
- package/dist/cjs/tree/TreeNode.js +4 -7
- package/dist/cjs/virtual/Gallery.js +21 -10
- package/dist/cjs/virtual/List.js +21 -10
- package/dist/cjs/virtual/Scroller.js +16 -8
- package/dist/esm/table/HeaderCell.js +5 -10
- package/dist/esm/tree/TreeNode.js +5 -8
- package/dist/esm/virtual/Gallery.js +21 -10
- package/dist/esm/virtual/List.js +21 -10
- package/dist/esm/virtual/Scroller.js +16 -8
- package/dist/types/table/HeaderCell.d.ts +1 -1
- package/dist/types/table/types.d.ts +4 -2
- package/dist/types/tree/types.d.ts +9 -5
- package/package.json +14 -14
- package/src/table/HeaderCell.tsx +2 -6
- package/src/table/types.ts +3 -5
- package/src/tree/TreeNode.tsx +9 -10
- package/src/tree/types.ts +8 -9
- package/src/virtual/Gallery.tsx +21 -12
- package/src/virtual/List.tsx +22 -8
- package/src/virtual/Scroller.tsx +16 -8
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
3
4
|
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
4
5
|
var core = require('@react-fabric/core');
|
|
5
6
|
var utilities = require('@react-fabric/utilities');
|
|
@@ -9,15 +10,14 @@ var Context = require('./Context.js');
|
|
|
9
10
|
var types = require('./types.js');
|
|
10
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
12
|
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
15
|
var HeaderCell = function HeaderCell(_ref) {
|
|
13
16
|
var id = _ref.id,
|
|
14
17
|
field = _ref.field,
|
|
15
18
|
dataType = _ref.dataType,
|
|
16
19
|
label = _ref.label,
|
|
17
20
|
icon = _ref.icon,
|
|
18
|
-
iconBg = _ref.iconBg,
|
|
19
|
-
iconColor = _ref.iconColor,
|
|
20
|
-
rtlFlip = _ref.rtlFlip,
|
|
21
21
|
actions = _ref.actions;
|
|
22
22
|
_ref.locked;
|
|
23
23
|
var filter = _ref.filter,
|
|
@@ -111,12 +111,7 @@ var HeaderCell = function HeaderCell(_ref) {
|
|
|
111
111
|
disabled: !(tooltip !== null && tooltip !== void 0 ? tooltip : label),
|
|
112
112
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
113
113
|
className: "flex-initial px-2 py-1 text-sm truncate sticky start-0",
|
|
114
|
-
children: [icon && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
115
|
-
icon: icon,
|
|
116
|
-
bg: iconBg,
|
|
117
|
-
color: iconColor,
|
|
118
|
-
rtlFlip: rtlFlip
|
|
119
|
-
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
114
|
+
children: [icon && /*#__PURE__*/jsxRuntime.jsx(core.Icon, _objectSpread({}, core.getIconProps(icon))), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
120
115
|
children: label !== null && label !== void 0 ? label : " "
|
|
121
116
|
})]
|
|
122
117
|
})
|
|
@@ -52,7 +52,9 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
52
52
|
}, [noLines, node.lines]);
|
|
53
53
|
var nodeIcon = react.useMemo(function () {
|
|
54
54
|
if (node.icon) return node.icon;
|
|
55
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
icon: node.leaf ? defaultLeafIcon : defaultNodeIcon
|
|
57
|
+
};
|
|
56
58
|
}, [defaultLeafIcon, defaultNodeIcon, node.icon]);
|
|
57
59
|
var canCheck = react.useMemo(function () {
|
|
58
60
|
return checkable === true || checkable === "leafOnly" && node.leaf;
|
|
@@ -102,12 +104,7 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
102
104
|
},
|
|
103
105
|
children: [nodeIcon && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
104
106
|
className: "flex-content max-w-6 me-1 self-center leading-none",
|
|
105
|
-
children: [/*#__PURE__*/react.isValidElement(nodeIcon) && nodeIcon, utilities.isString(nodeIcon) && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
106
|
-
icon: nodeIcon,
|
|
107
|
-
bg: node.iconBg,
|
|
108
|
-
color: node.iconColor,
|
|
109
|
-
rtlFlip: node.rtlFlip
|
|
110
|
-
})]
|
|
107
|
+
children: [/*#__PURE__*/react.isValidElement(nodeIcon) && nodeIcon, utilities.isString(nodeIcon) && /*#__PURE__*/jsxRuntime.jsx(core.Icon, _objectSpread({}, core.getIconProps(nodeIcon)))]
|
|
111
108
|
}), node.childSelected && !node.open && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
112
109
|
className: " flex-content text-primary-500",
|
|
113
110
|
children: "\u2022"
|
|
@@ -87,13 +87,13 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
87
87
|
estimateSize: function estimateSize() {
|
|
88
88
|
return height;
|
|
89
89
|
},
|
|
90
|
-
overscan:
|
|
90
|
+
overscan: 0
|
|
91
91
|
});
|
|
92
92
|
var virtualItems = virtualizer.getVirtualItems();
|
|
93
93
|
var currentIndex = react.useRef(0);
|
|
94
94
|
react.useEffect(function () {
|
|
95
|
-
var _virtualItems$
|
|
96
|
-
currentIndex.current = (_virtualItems$
|
|
95
|
+
var _virtualItems$0$index, _virtualItems$;
|
|
96
|
+
currentIndex.current = (_virtualItems$0$index = (_virtualItems$ = virtualItems[0]) === null || _virtualItems$ === void 0 ? void 0 : _virtualItems$.index) !== null && _virtualItems$0$index !== void 0 ? _virtualItems$0$index : 0;
|
|
97
97
|
if (scrollerRef.current && virtualItems[0] && scrollerRef.current.scrollTop < virtualItems[0].size) currentIndex.current = 0;
|
|
98
98
|
}, [virtualItems]);
|
|
99
99
|
var calculateActiveScroll = react.useCallback(function () {
|
|
@@ -144,13 +144,17 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
}, [onLoadMore, virtualItems]);
|
|
147
|
+
var isRenderedRef = react.useRef(false);
|
|
147
148
|
react.useLayoutEffect(function () {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
if (!isRenderedRef.current && itemList.length > 0) {
|
|
150
|
+
isRenderedRef.current = true;
|
|
151
|
+
initialScroll && setTimeout(function () {
|
|
152
|
+
virtualizer.scrollToIndex(Math.floor(initialScroll / columnCount), {
|
|
153
|
+
align: "start"
|
|
154
|
+
});
|
|
155
|
+
}, 200);
|
|
156
|
+
}
|
|
157
|
+
}, [columnCount, initialScroll, itemList]);
|
|
154
158
|
react.useImperativeHandle(galleryRef, function () {
|
|
155
159
|
return {
|
|
156
160
|
scrollToItem: function scrollToItem(index) {
|
|
@@ -204,10 +208,17 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
204
208
|
"data-index": index,
|
|
205
209
|
ref: virtualizer.measureElement,
|
|
206
210
|
children: columnMap.map(function (col) {
|
|
211
|
+
var _itemList;
|
|
207
212
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
208
213
|
"data-index": index * columnCount + col,
|
|
209
214
|
className: classNames("grid rounded-capped"),
|
|
210
|
-
|
|
215
|
+
style: {
|
|
216
|
+
minWidth: width,
|
|
217
|
+
minHeight: height
|
|
218
|
+
},
|
|
219
|
+
children: (_itemList = itemList[index * columnCount + col]) !== null && _itemList !== void 0 && _itemList.item ? children(itemList[index * columnCount + col]) : /*#__PURE__*/jsxRuntime.jsx(core.Skeleton, {
|
|
220
|
+
className: "p-2"
|
|
221
|
+
})
|
|
211
222
|
}, "".concat(key, ":").concat(col));
|
|
212
223
|
})
|
|
213
224
|
}, key);
|
package/dist/cjs/virtual/List.js
CHANGED
|
@@ -56,7 +56,7 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
56
56
|
var scrollerRef = react.useRef(null);
|
|
57
57
|
var virtualizer = reactVirtual.useVirtualizer({
|
|
58
58
|
count: count,
|
|
59
|
-
overscan:
|
|
59
|
+
overscan: 0,
|
|
60
60
|
horizontal: orientation === "horizontal",
|
|
61
61
|
getScrollElement: function getScrollElement() {
|
|
62
62
|
return scrollerRef.current;
|
|
@@ -68,8 +68,8 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
68
68
|
var virtualItems = virtualizer.getVirtualItems();
|
|
69
69
|
var currentIndex = react.useRef(0);
|
|
70
70
|
react.useEffect(function () {
|
|
71
|
-
var _virtualItems$
|
|
72
|
-
currentIndex.current = (_virtualItems$
|
|
71
|
+
var _virtualItems$0$index, _virtualItems$;
|
|
72
|
+
currentIndex.current = (_virtualItems$0$index = (_virtualItems$ = virtualItems[0]) === null || _virtualItems$ === void 0 ? void 0 : _virtualItems$.index) !== null && _virtualItems$0$index !== void 0 ? _virtualItems$0$index : 0;
|
|
73
73
|
if (scrollerRef.current && virtualItems[0] && scrollerRef.current.scrollTop < virtualItems[0].size) currentIndex.current = 0;
|
|
74
74
|
}, [virtualItems]);
|
|
75
75
|
var calculateActiveScroll = react.useCallback(function () {
|
|
@@ -131,13 +131,17 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
}, [onLoadMore, virtualItems]);
|
|
134
|
+
var isRenderedRef = react.useRef(false);
|
|
134
135
|
react.useLayoutEffect(function () {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
if (!isRenderedRef.current && itemList.length > 0) {
|
|
137
|
+
isRenderedRef.current = true;
|
|
138
|
+
initialScroll && setTimeout(function () {
|
|
139
|
+
virtualizer.scrollToIndex(Math.floor(initialScroll), {
|
|
140
|
+
align: "start"
|
|
141
|
+
});
|
|
142
|
+
}, 200);
|
|
143
|
+
}
|
|
144
|
+
}, [itemList, initialScroll]);
|
|
141
145
|
react.useImperativeHandle(listRef, function () {
|
|
142
146
|
return {
|
|
143
147
|
scrollToItem: function scrollToItem(index) {
|
|
@@ -189,13 +193,20 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
189
193
|
display: "inline-block"
|
|
190
194
|
}
|
|
191
195
|
}), virtualItems.map(function (_ref3) {
|
|
196
|
+
var _itemList$index;
|
|
192
197
|
var key = _ref3.key,
|
|
193
198
|
index = _ref3.index;
|
|
194
199
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
195
200
|
"data-index": index,
|
|
196
201
|
ref: virtualizer.measureElement,
|
|
197
202
|
className: classNames("rounded-capped", orientation === "horizontal" ? "inline-grid" : "grid"),
|
|
198
|
-
|
|
203
|
+
style: {
|
|
204
|
+
minWidth: width,
|
|
205
|
+
minHeight: height
|
|
206
|
+
},
|
|
207
|
+
children: (_itemList$index = itemList[index]) !== null && _itemList$index !== void 0 && _itemList$index.item ? children(itemList[index]) : /*#__PURE__*/jsxRuntime.jsx(core.Skeleton, {
|
|
208
|
+
className: "p-2"
|
|
209
|
+
})
|
|
199
210
|
}, key);
|
|
200
211
|
})]
|
|
201
212
|
}), loading && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -39,35 +39,43 @@ var Scroller = function Scroller(_ref) {
|
|
|
39
39
|
variant: "link",
|
|
40
40
|
className: "outline",
|
|
41
41
|
children: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
42
|
-
rtlFlip: true,
|
|
43
42
|
size: "sm",
|
|
44
43
|
variant: "link",
|
|
45
44
|
"aria-label": "scroll to top",
|
|
46
|
-
icon:
|
|
45
|
+
icon: {
|
|
46
|
+
icon: vertical ? core.CoreIcons.chevronsUp : core.CoreIcons.chevronsLeft,
|
|
47
|
+
rtlFlip: true
|
|
48
|
+
},
|
|
47
49
|
disabled: (scrollActive & 2) === 0,
|
|
48
50
|
onClick: onStart
|
|
49
51
|
}), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
50
|
-
rtlFlip: true,
|
|
51
52
|
size: "sm",
|
|
52
53
|
variant: "link",
|
|
53
54
|
"aria-label": "scroll up",
|
|
54
|
-
icon:
|
|
55
|
+
icon: {
|
|
56
|
+
icon: vertical ? core.CoreIcons.chevronUp : core.CoreIcons.chevronLeft,
|
|
57
|
+
rtlFlip: true
|
|
58
|
+
},
|
|
55
59
|
disabled: (scrollActive & 2) === 0,
|
|
56
60
|
onClick: onPrevious
|
|
57
61
|
}), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
58
|
-
rtlFlip: true,
|
|
59
62
|
size: "sm",
|
|
60
63
|
variant: "link",
|
|
61
64
|
"aria-label": "scroll down",
|
|
62
|
-
icon:
|
|
65
|
+
icon: {
|
|
66
|
+
icon: vertical ? core.CoreIcons.chevronDown : core.CoreIcons.chevronRight,
|
|
67
|
+
rtlFlip: true
|
|
68
|
+
},
|
|
63
69
|
disabled: scrollActive % 2 === 0,
|
|
64
70
|
onClick: onNext
|
|
65
71
|
}), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
66
|
-
rtlFlip: true,
|
|
67
72
|
size: "sm",
|
|
68
73
|
variant: "link",
|
|
69
74
|
"aria-label": "scroll to bottom",
|
|
70
|
-
icon:
|
|
75
|
+
icon: {
|
|
76
|
+
icon: vertical ? core.CoreIcons.chevronsDown : core.CoreIcons.chevronsRight,
|
|
77
|
+
rtlFlip: true
|
|
78
|
+
},
|
|
71
79
|
disabled: scrollActive % 2 === 0,
|
|
72
80
|
onClick: onEnd
|
|
73
81
|
})]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
4
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
4
|
-
import { Menu, CoreIcons, MenuItem, Divider, Tooltip, Icon, DropdownTool, Button } from '@react-fabric/core';
|
|
5
|
+
import { Menu, CoreIcons, MenuItem, Divider, Tooltip, Icon, getIconProps, DropdownTool, Button } from '@react-fabric/core';
|
|
5
6
|
import { isEmpty } from '@react-fabric/utilities';
|
|
6
7
|
import { useMemo, useCallback } from 'react';
|
|
7
8
|
import { ColumnFilters } from './ColumnFilters.js';
|
|
@@ -9,15 +10,14 @@ import { useTableContext } from './Context.js';
|
|
|
9
10
|
import { COL_DEFAULT_WIDTH, COL_MIN_WIDTH, COL_MAX_WIDTH } from './types.js';
|
|
10
11
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
11
12
|
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
15
|
var HeaderCell = function HeaderCell(_ref) {
|
|
13
16
|
var id = _ref.id,
|
|
14
17
|
field = _ref.field,
|
|
15
18
|
dataType = _ref.dataType,
|
|
16
19
|
label = _ref.label,
|
|
17
20
|
icon = _ref.icon,
|
|
18
|
-
iconBg = _ref.iconBg,
|
|
19
|
-
iconColor = _ref.iconColor,
|
|
20
|
-
rtlFlip = _ref.rtlFlip,
|
|
21
21
|
actions = _ref.actions;
|
|
22
22
|
_ref.locked;
|
|
23
23
|
var filter = _ref.filter,
|
|
@@ -111,12 +111,7 @@ var HeaderCell = function HeaderCell(_ref) {
|
|
|
111
111
|
disabled: !(tooltip !== null && tooltip !== void 0 ? tooltip : label),
|
|
112
112
|
children: /*#__PURE__*/jsxs("div", {
|
|
113
113
|
className: "flex-initial px-2 py-1 text-sm truncate sticky start-0",
|
|
114
|
-
children: [icon && /*#__PURE__*/jsx(Icon, {
|
|
115
|
-
icon: icon,
|
|
116
|
-
bg: iconBg,
|
|
117
|
-
color: iconColor,
|
|
118
|
-
rtlFlip: rtlFlip
|
|
119
|
-
}), /*#__PURE__*/jsx("span", {
|
|
114
|
+
children: [icon && /*#__PURE__*/jsx(Icon, _objectSpread({}, getIconProps(icon))), /*#__PURE__*/jsx("span", {
|
|
120
115
|
children: label !== null && label !== void 0 ? label : " "
|
|
121
116
|
})]
|
|
122
117
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import { getBadgeProps, Icon, CoreIcons, Badge } from '@react-fabric/core';
|
|
4
|
+
import { getBadgeProps, Icon, CoreIcons, getIconProps, Badge } from '@react-fabric/core';
|
|
5
5
|
import { isString, isEmpty } from '@react-fabric/utilities';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { useMemo, isValidElement } from 'react';
|
|
@@ -52,7 +52,9 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
52
52
|
}, [noLines, node.lines]);
|
|
53
53
|
var nodeIcon = useMemo(function () {
|
|
54
54
|
if (node.icon) return node.icon;
|
|
55
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
icon: node.leaf ? defaultLeafIcon : defaultNodeIcon
|
|
57
|
+
};
|
|
56
58
|
}, [defaultLeafIcon, defaultNodeIcon, node.icon]);
|
|
57
59
|
var canCheck = useMemo(function () {
|
|
58
60
|
return checkable === true || checkable === "leafOnly" && node.leaf;
|
|
@@ -102,12 +104,7 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
102
104
|
},
|
|
103
105
|
children: [nodeIcon && /*#__PURE__*/jsxs("div", {
|
|
104
106
|
className: "flex-content max-w-6 me-1 self-center leading-none",
|
|
105
|
-
children: [/*#__PURE__*/isValidElement(nodeIcon) && nodeIcon, isString(nodeIcon) && /*#__PURE__*/jsx(Icon, {
|
|
106
|
-
icon: nodeIcon,
|
|
107
|
-
bg: node.iconBg,
|
|
108
|
-
color: node.iconColor,
|
|
109
|
-
rtlFlip: node.rtlFlip
|
|
110
|
-
})]
|
|
107
|
+
children: [/*#__PURE__*/isValidElement(nodeIcon) && nodeIcon, isString(nodeIcon) && /*#__PURE__*/jsx(Icon, _objectSpread({}, getIconProps(nodeIcon)))]
|
|
111
108
|
}), node.childSelected && !node.open && /*#__PURE__*/jsx("span", {
|
|
112
109
|
className: " flex-content text-primary-500",
|
|
113
110
|
children: "\u2022"
|
|
@@ -87,13 +87,13 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
87
87
|
estimateSize: function estimateSize() {
|
|
88
88
|
return height;
|
|
89
89
|
},
|
|
90
|
-
overscan:
|
|
90
|
+
overscan: 0
|
|
91
91
|
});
|
|
92
92
|
var virtualItems = virtualizer.getVirtualItems();
|
|
93
93
|
var currentIndex = useRef(0);
|
|
94
94
|
useEffect(function () {
|
|
95
|
-
var _virtualItems$
|
|
96
|
-
currentIndex.current = (_virtualItems$
|
|
95
|
+
var _virtualItems$0$index, _virtualItems$;
|
|
96
|
+
currentIndex.current = (_virtualItems$0$index = (_virtualItems$ = virtualItems[0]) === null || _virtualItems$ === void 0 ? void 0 : _virtualItems$.index) !== null && _virtualItems$0$index !== void 0 ? _virtualItems$0$index : 0;
|
|
97
97
|
if (scrollerRef.current && virtualItems[0] && scrollerRef.current.scrollTop < virtualItems[0].size) currentIndex.current = 0;
|
|
98
98
|
}, [virtualItems]);
|
|
99
99
|
var calculateActiveScroll = useCallback(function () {
|
|
@@ -144,13 +144,17 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
}, [onLoadMore, virtualItems]);
|
|
147
|
+
var isRenderedRef = useRef(false);
|
|
147
148
|
useLayoutEffect(function () {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
if (!isRenderedRef.current && itemList.length > 0) {
|
|
150
|
+
isRenderedRef.current = true;
|
|
151
|
+
initialScroll && setTimeout(function () {
|
|
152
|
+
virtualizer.scrollToIndex(Math.floor(initialScroll / columnCount), {
|
|
153
|
+
align: "start"
|
|
154
|
+
});
|
|
155
|
+
}, 200);
|
|
156
|
+
}
|
|
157
|
+
}, [columnCount, initialScroll, itemList]);
|
|
154
158
|
useImperativeHandle(galleryRef, function () {
|
|
155
159
|
return {
|
|
156
160
|
scrollToItem: function scrollToItem(index) {
|
|
@@ -204,10 +208,17 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
204
208
|
"data-index": index,
|
|
205
209
|
ref: virtualizer.measureElement,
|
|
206
210
|
children: columnMap.map(function (col) {
|
|
211
|
+
var _itemList;
|
|
207
212
|
return /*#__PURE__*/jsx("div", {
|
|
208
213
|
"data-index": index * columnCount + col,
|
|
209
214
|
className: classNames("grid rounded-capped"),
|
|
210
|
-
|
|
215
|
+
style: {
|
|
216
|
+
minWidth: width,
|
|
217
|
+
minHeight: height
|
|
218
|
+
},
|
|
219
|
+
children: (_itemList = itemList[index * columnCount + col]) !== null && _itemList !== void 0 && _itemList.item ? children(itemList[index * columnCount + col]) : /*#__PURE__*/jsx(Skeleton, {
|
|
220
|
+
className: "p-2"
|
|
221
|
+
})
|
|
211
222
|
}, "".concat(key, ":").concat(col));
|
|
212
223
|
})
|
|
213
224
|
}, key);
|
package/dist/esm/virtual/List.js
CHANGED
|
@@ -56,7 +56,7 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
56
56
|
var scrollerRef = useRef(null);
|
|
57
57
|
var virtualizer = useVirtualizer({
|
|
58
58
|
count: count,
|
|
59
|
-
overscan:
|
|
59
|
+
overscan: 0,
|
|
60
60
|
horizontal: orientation === "horizontal",
|
|
61
61
|
getScrollElement: function getScrollElement() {
|
|
62
62
|
return scrollerRef.current;
|
|
@@ -68,8 +68,8 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
68
68
|
var virtualItems = virtualizer.getVirtualItems();
|
|
69
69
|
var currentIndex = useRef(0);
|
|
70
70
|
useEffect(function () {
|
|
71
|
-
var _virtualItems$
|
|
72
|
-
currentIndex.current = (_virtualItems$
|
|
71
|
+
var _virtualItems$0$index, _virtualItems$;
|
|
72
|
+
currentIndex.current = (_virtualItems$0$index = (_virtualItems$ = virtualItems[0]) === null || _virtualItems$ === void 0 ? void 0 : _virtualItems$.index) !== null && _virtualItems$0$index !== void 0 ? _virtualItems$0$index : 0;
|
|
73
73
|
if (scrollerRef.current && virtualItems[0] && scrollerRef.current.scrollTop < virtualItems[0].size) currentIndex.current = 0;
|
|
74
74
|
}, [virtualItems]);
|
|
75
75
|
var calculateActiveScroll = useCallback(function () {
|
|
@@ -131,13 +131,17 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
133
|
}, [onLoadMore, virtualItems]);
|
|
134
|
+
var isRenderedRef = useRef(false);
|
|
134
135
|
useLayoutEffect(function () {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
if (!isRenderedRef.current && itemList.length > 0) {
|
|
137
|
+
isRenderedRef.current = true;
|
|
138
|
+
initialScroll && setTimeout(function () {
|
|
139
|
+
virtualizer.scrollToIndex(Math.floor(initialScroll), {
|
|
140
|
+
align: "start"
|
|
141
|
+
});
|
|
142
|
+
}, 200);
|
|
143
|
+
}
|
|
144
|
+
}, [itemList, initialScroll]);
|
|
141
145
|
useImperativeHandle(listRef, function () {
|
|
142
146
|
return {
|
|
143
147
|
scrollToItem: function scrollToItem(index) {
|
|
@@ -189,13 +193,20 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
189
193
|
display: "inline-block"
|
|
190
194
|
}
|
|
191
195
|
}), virtualItems.map(function (_ref3) {
|
|
196
|
+
var _itemList$index;
|
|
192
197
|
var key = _ref3.key,
|
|
193
198
|
index = _ref3.index;
|
|
194
199
|
return /*#__PURE__*/jsx("div", {
|
|
195
200
|
"data-index": index,
|
|
196
201
|
ref: virtualizer.measureElement,
|
|
197
202
|
className: classNames("rounded-capped", orientation === "horizontal" ? "inline-grid" : "grid"),
|
|
198
|
-
|
|
203
|
+
style: {
|
|
204
|
+
minWidth: width,
|
|
205
|
+
minHeight: height
|
|
206
|
+
},
|
|
207
|
+
children: (_itemList$index = itemList[index]) !== null && _itemList$index !== void 0 && _itemList$index.item ? children(itemList[index]) : /*#__PURE__*/jsx(Skeleton, {
|
|
208
|
+
className: "p-2"
|
|
209
|
+
})
|
|
199
210
|
}, key);
|
|
200
211
|
})]
|
|
201
212
|
}), loading && /*#__PURE__*/jsx("div", {
|
|
@@ -39,35 +39,43 @@ var Scroller = function Scroller(_ref) {
|
|
|
39
39
|
variant: "link",
|
|
40
40
|
className: "outline",
|
|
41
41
|
children: [/*#__PURE__*/jsx(Button, {
|
|
42
|
-
rtlFlip: true,
|
|
43
42
|
size: "sm",
|
|
44
43
|
variant: "link",
|
|
45
44
|
"aria-label": "scroll to top",
|
|
46
|
-
icon:
|
|
45
|
+
icon: {
|
|
46
|
+
icon: vertical ? CoreIcons.chevronsUp : CoreIcons.chevronsLeft,
|
|
47
|
+
rtlFlip: true
|
|
48
|
+
},
|
|
47
49
|
disabled: (scrollActive & 2) === 0,
|
|
48
50
|
onClick: onStart
|
|
49
51
|
}), /*#__PURE__*/jsx(Button, {
|
|
50
|
-
rtlFlip: true,
|
|
51
52
|
size: "sm",
|
|
52
53
|
variant: "link",
|
|
53
54
|
"aria-label": "scroll up",
|
|
54
|
-
icon:
|
|
55
|
+
icon: {
|
|
56
|
+
icon: vertical ? CoreIcons.chevronUp : CoreIcons.chevronLeft,
|
|
57
|
+
rtlFlip: true
|
|
58
|
+
},
|
|
55
59
|
disabled: (scrollActive & 2) === 0,
|
|
56
60
|
onClick: onPrevious
|
|
57
61
|
}), /*#__PURE__*/jsx(Button, {
|
|
58
|
-
rtlFlip: true,
|
|
59
62
|
size: "sm",
|
|
60
63
|
variant: "link",
|
|
61
64
|
"aria-label": "scroll down",
|
|
62
|
-
icon:
|
|
65
|
+
icon: {
|
|
66
|
+
icon: vertical ? CoreIcons.chevronDown : CoreIcons.chevronRight,
|
|
67
|
+
rtlFlip: true
|
|
68
|
+
},
|
|
63
69
|
disabled: scrollActive % 2 === 0,
|
|
64
70
|
onClick: onNext
|
|
65
71
|
}), /*#__PURE__*/jsx(Button, {
|
|
66
|
-
rtlFlip: true,
|
|
67
72
|
size: "sm",
|
|
68
73
|
variant: "link",
|
|
69
74
|
"aria-label": "scroll to bottom",
|
|
70
|
-
icon:
|
|
75
|
+
icon: {
|
|
76
|
+
icon: vertical ? CoreIcons.chevronsDown : CoreIcons.chevronsRight,
|
|
77
|
+
rtlFlip: true
|
|
78
|
+
},
|
|
71
79
|
disabled: scrollActive % 2 === 0,
|
|
72
80
|
onClick: onEnd
|
|
73
81
|
})]
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type TableColumn, type TableProps } from "./types";
|
|
2
|
-
export declare const HeaderCell: ({ id, field, dataType, label, icon,
|
|
2
|
+
export declare const HeaderCell: ({ id, field, dataType, label, icon, actions, locked, filter, filterable, filterOptions, tooltip, sortable, resizable, width: _width, maxWidth, minWidth, sort, onSort, onFilter, }: TableColumn & Pick<TableProps, "sort" | "onSort" | "onFilter">) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IconProps } from "@react-fabric/core/dist/types/components/icon/Icon";
|
|
2
|
+
import { type CssProp, type Elements, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
2
3
|
import { type ReactElement } from "react";
|
|
3
4
|
export declare const COL_MIN_WIDTH = "3rem";
|
|
4
5
|
export declare const COL_MAX_WIDTH = "64rem";
|
|
@@ -31,11 +32,12 @@ export declare const COL_DEFAULT_WIDTH = "12rem";
|
|
|
31
32
|
* @property {KeyValue} [valueMap] - Mapping of values for the column.
|
|
32
33
|
* @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
|
|
33
34
|
*/
|
|
34
|
-
export interface TableColumn<T = KeyValue> extends CssProp,
|
|
35
|
+
export interface TableColumn<T = KeyValue> extends CssProp, TestProps {
|
|
35
36
|
id: keyof T | string;
|
|
36
37
|
field?: string;
|
|
37
38
|
label?: string;
|
|
38
39
|
tooltip?: string;
|
|
40
|
+
icon?: IconProps;
|
|
39
41
|
actions?: ReactElement[];
|
|
40
42
|
align?: "start" | "center" | "end";
|
|
41
43
|
locked?: "start" | "end";
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { IconProps } from "@react-fabric/core/dist/types/components/icon/Icon";
|
|
2
|
+
import { type BadgeType, type ChildProp, type CssProp, type Elements, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
|
+
interface TreeBaseNode<T> extends CssProp, TestProps {
|
|
3
4
|
id: string;
|
|
4
5
|
/**
|
|
5
6
|
* display label
|
|
6
7
|
*/
|
|
7
8
|
label: Elements<JSX.Element>;
|
|
9
|
+
/**
|
|
10
|
+
* icon path or props
|
|
11
|
+
*/
|
|
12
|
+
icon?: IconProps;
|
|
8
13
|
/**
|
|
9
14
|
* full text to be used for querying purposes
|
|
10
15
|
*/
|
|
@@ -22,7 +27,6 @@ interface TreeBaseNode<T> extends Omit<IconProps, "icon">, CssProp, TestProps {
|
|
|
22
27
|
*/
|
|
23
28
|
disabled?: boolean;
|
|
24
29
|
data?: T;
|
|
25
|
-
icon?: Elements<JSX.Element>;
|
|
26
30
|
}
|
|
27
31
|
export type TreeNodeType<T extends KeyValue = KeyValue> = TreeBaseNode<T> & ({
|
|
28
32
|
leaf: true;
|
|
@@ -33,7 +37,7 @@ export type TreeNodeType<T extends KeyValue = KeyValue> = TreeBaseNode<T> & ({
|
|
|
33
37
|
open?: boolean;
|
|
34
38
|
iconOpen?: string;
|
|
35
39
|
});
|
|
36
|
-
export interface InternalNode extends
|
|
40
|
+
export interface InternalNode extends CssProp, TestProps {
|
|
37
41
|
id: string;
|
|
38
42
|
label: Elements<JSX.Element>;
|
|
39
43
|
queryable?: string;
|
|
@@ -50,7 +54,7 @@ export interface InternalNode extends Omit<IconProps, "icon">, CssProp, TestProp
|
|
|
50
54
|
loaded: boolean;
|
|
51
55
|
parent?: string;
|
|
52
56
|
empty?: boolean;
|
|
53
|
-
icon?:
|
|
57
|
+
icon?: IconProps;
|
|
54
58
|
errored?: string;
|
|
55
59
|
selected?: true;
|
|
56
60
|
childSelected?: true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/data",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.59",
|
|
4
4
|
"description": "RUF: Data package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,24 +35,24 @@
|
|
|
35
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
39
|
-
"@react-fabric/date": "^1.0.0-beta.
|
|
40
|
-
"@react-fabric/form": "^1.0.0-beta.
|
|
41
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
42
|
-
"@tanstack/react-virtual": "
|
|
43
|
-
"classnames": "
|
|
44
|
-
"color": "
|
|
45
|
-
"memoize-one": "
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.59",
|
|
39
|
+
"@react-fabric/date": "^1.0.0-beta.59",
|
|
40
|
+
"@react-fabric/form": "^1.0.0-beta.59",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.0-beta.59",
|
|
42
|
+
"@tanstack/react-virtual": "~3.13.12",
|
|
43
|
+
"classnames": "~2.5.1",
|
|
44
|
+
"color": "~5.0.2",
|
|
45
|
+
"memoize-one": "~6.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"i18next": "
|
|
49
|
-
"react": "
|
|
50
|
-
"react-dom": "
|
|
51
|
-
"react-i18next": "
|
|
48
|
+
"i18next": "~25.6.0",
|
|
49
|
+
"react": "~19.2.0",
|
|
50
|
+
"react-dom": "~19.2.0",
|
|
51
|
+
"react-i18next": "~16.2.1"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=18.12.0",
|
|
55
55
|
"npm": ">=8.19.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "74efd06c9c5ac629b6ef5cdc6d53ecb1c356f2eb"
|
|
58
58
|
}
|
package/src/table/HeaderCell.tsx
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
CoreIcons,
|
|
27
27
|
Divider,
|
|
28
28
|
DropdownTool,
|
|
29
|
+
getIconProps,
|
|
29
30
|
Icon,
|
|
30
31
|
Menu,
|
|
31
32
|
MenuItem,
|
|
@@ -49,9 +50,6 @@ export const HeaderCell = ({
|
|
|
49
50
|
dataType,
|
|
50
51
|
label,
|
|
51
52
|
icon,
|
|
52
|
-
iconBg,
|
|
53
|
-
iconColor,
|
|
54
|
-
rtlFlip,
|
|
55
53
|
actions,
|
|
56
54
|
locked,
|
|
57
55
|
filter,
|
|
@@ -153,9 +151,7 @@ export const HeaderCell = ({
|
|
|
153
151
|
>
|
|
154
152
|
<Tooltip content={tooltip ?? label} disabled={!(tooltip ?? label)}>
|
|
155
153
|
<div className="flex-initial px-2 py-1 text-sm truncate sticky start-0">
|
|
156
|
-
{icon && (
|
|
157
|
-
<Icon icon={icon} bg={iconBg} color={iconColor} rtlFlip={rtlFlip} />
|
|
158
|
-
)}
|
|
154
|
+
{icon && <Icon {...getIconProps(icon)} />}
|
|
159
155
|
<span>{label ?? " "}</span>
|
|
160
156
|
</div>
|
|
161
157
|
</Tooltip>
|
package/src/table/types.ts
CHANGED
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { IconProps } from "@react-fabric/core/dist/types/components/icon/Icon";
|
|
24
25
|
import {
|
|
25
26
|
type CssProp,
|
|
26
27
|
type Elements,
|
|
27
|
-
type IconProps,
|
|
28
28
|
type RefProp,
|
|
29
29
|
type TestProps,
|
|
30
30
|
} from "@react-fabric/core/dist/types/types";
|
|
@@ -62,14 +62,12 @@ export const COL_DEFAULT_WIDTH = "12rem";
|
|
|
62
62
|
* @property {KeyValue} [valueMap] - Mapping of values for the column.
|
|
63
63
|
* @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
|
|
64
64
|
*/
|
|
65
|
-
export interface TableColumn<T = KeyValue>
|
|
66
|
-
extends CssProp,
|
|
67
|
-
IconProps,
|
|
68
|
-
TestProps {
|
|
65
|
+
export interface TableColumn<T = KeyValue> extends CssProp, TestProps {
|
|
69
66
|
id: keyof T | string;
|
|
70
67
|
field?: string;
|
|
71
68
|
label?: string;
|
|
72
69
|
tooltip?: string;
|
|
70
|
+
icon?: IconProps;
|
|
73
71
|
actions?: ReactElement[];
|
|
74
72
|
align?: "start" | "center" | "end";
|
|
75
73
|
locked?: "start" | "end";
|
package/src/tree/TreeNode.tsx
CHANGED
|
@@ -21,7 +21,13 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
Badge,
|
|
26
|
+
CoreIcons,
|
|
27
|
+
getBadgeProps,
|
|
28
|
+
getIconProps,
|
|
29
|
+
Icon,
|
|
30
|
+
} from "@react-fabric/core";
|
|
25
31
|
import { isEmpty, isString } from "@react-fabric/utilities";
|
|
26
32
|
import classNames from "classnames";
|
|
27
33
|
import { isValidElement, useMemo } from "react";
|
|
@@ -79,7 +85,7 @@ export const TreeNode = ({
|
|
|
79
85
|
|
|
80
86
|
const nodeIcon = useMemo(() => {
|
|
81
87
|
if (node.icon) return node.icon;
|
|
82
|
-
return node.leaf ? defaultLeafIcon : defaultNodeIcon;
|
|
88
|
+
return { icon: node.leaf ? defaultLeafIcon : defaultNodeIcon };
|
|
83
89
|
}, [defaultLeafIcon, defaultNodeIcon, node.icon]);
|
|
84
90
|
|
|
85
91
|
const canCheck = useMemo(() => {
|
|
@@ -167,14 +173,7 @@ export const TreeNode = ({
|
|
|
167
173
|
{nodeIcon && (
|
|
168
174
|
<div className="flex-content max-w-6 me-1 self-center leading-none">
|
|
169
175
|
{isValidElement(nodeIcon) && nodeIcon}
|
|
170
|
-
{isString(nodeIcon) && (
|
|
171
|
-
<Icon
|
|
172
|
-
icon={nodeIcon}
|
|
173
|
-
bg={node.iconBg}
|
|
174
|
-
color={node.iconColor}
|
|
175
|
-
rtlFlip={node.rtlFlip}
|
|
176
|
-
/>
|
|
177
|
-
)}
|
|
176
|
+
{isString(nodeIcon) && <Icon {...getIconProps(nodeIcon)} />}
|
|
178
177
|
</div>
|
|
179
178
|
)}
|
|
180
179
|
{node.childSelected && !node.open && (
|
package/src/tree/types.ts
CHANGED
|
@@ -21,22 +21,26 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
+
import { IconProps } from "@react-fabric/core/dist/types/components/icon/Icon";
|
|
24
25
|
import {
|
|
25
26
|
type BadgeType,
|
|
26
27
|
type ChildProp,
|
|
27
28
|
type CssProp,
|
|
28
29
|
type Elements,
|
|
29
|
-
type IconProps,
|
|
30
30
|
type RefProp,
|
|
31
31
|
type TestProps,
|
|
32
32
|
} from "@react-fabric/core/dist/types/types";
|
|
33
33
|
|
|
34
|
-
interface TreeBaseNode<T> extends
|
|
34
|
+
interface TreeBaseNode<T> extends CssProp, TestProps {
|
|
35
35
|
id: string;
|
|
36
36
|
/**
|
|
37
37
|
* display label
|
|
38
38
|
*/
|
|
39
39
|
label: Elements<JSX.Element>;
|
|
40
|
+
/**
|
|
41
|
+
* icon path or props
|
|
42
|
+
*/
|
|
43
|
+
icon?: IconProps;
|
|
40
44
|
/**
|
|
41
45
|
* full text to be used for querying purposes
|
|
42
46
|
*/
|
|
@@ -54,8 +58,6 @@ interface TreeBaseNode<T> extends Omit<IconProps, "icon">, CssProp, TestProps {
|
|
|
54
58
|
*/
|
|
55
59
|
disabled?: boolean;
|
|
56
60
|
data?: T;
|
|
57
|
-
|
|
58
|
-
icon?: Elements<JSX.Element>;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
export type TreeNodeType<T extends KeyValue = KeyValue> = TreeBaseNode<T> &
|
|
@@ -69,10 +71,7 @@ export type TreeNodeType<T extends KeyValue = KeyValue> = TreeBaseNode<T> &
|
|
|
69
71
|
}
|
|
70
72
|
);
|
|
71
73
|
|
|
72
|
-
export interface InternalNode
|
|
73
|
-
extends Omit<IconProps, "icon">,
|
|
74
|
-
CssProp,
|
|
75
|
-
TestProps {
|
|
74
|
+
export interface InternalNode extends CssProp, TestProps {
|
|
76
75
|
id: string;
|
|
77
76
|
label: Elements<JSX.Element>;
|
|
78
77
|
queryable?: string;
|
|
@@ -89,7 +88,7 @@ export interface InternalNode
|
|
|
89
88
|
loaded: boolean;
|
|
90
89
|
parent?: string;
|
|
91
90
|
empty?: boolean;
|
|
92
|
-
icon?:
|
|
91
|
+
icon?: IconProps;
|
|
93
92
|
errored?: string;
|
|
94
93
|
selected?: true;
|
|
95
94
|
childSelected?: true;
|
package/src/virtual/Gallery.tsx
CHANGED
|
@@ -182,14 +182,14 @@ const _VirtualGallery = <T extends AnyObject>({
|
|
|
182
182
|
count: Math.ceil(count / columnCount),
|
|
183
183
|
getScrollElement: () => scrollerRef.current,
|
|
184
184
|
estimateSize: () => height,
|
|
185
|
-
overscan:
|
|
185
|
+
overscan: 0,
|
|
186
186
|
});
|
|
187
187
|
|
|
188
188
|
const virtualItems = virtualizer.getVirtualItems();
|
|
189
189
|
|
|
190
190
|
const currentIndex = useRef(0);
|
|
191
191
|
useEffect(() => {
|
|
192
|
-
currentIndex.current = virtualItems[
|
|
192
|
+
currentIndex.current = virtualItems[0]?.index ?? 0;
|
|
193
193
|
if (
|
|
194
194
|
scrollerRef.current &&
|
|
195
195
|
virtualItems[0] &&
|
|
@@ -246,14 +246,18 @@ const _VirtualGallery = <T extends AnyObject>({
|
|
|
246
246
|
}
|
|
247
247
|
}, [onLoadMore, virtualItems]);
|
|
248
248
|
|
|
249
|
+
const isRenderedRef = useRef(false);
|
|
249
250
|
useLayoutEffect(() => {
|
|
250
|
-
|
|
251
|
+
if (!isRenderedRef.current && itemList.length > 0) {
|
|
252
|
+
isRenderedRef.current = true;
|
|
251
253
|
initialScroll &&
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
setTimeout(() => {
|
|
255
|
+
virtualizer.scrollToIndex(Math.floor(initialScroll / columnCount), {
|
|
256
|
+
align: "start",
|
|
257
|
+
});
|
|
258
|
+
}, 200);
|
|
259
|
+
}
|
|
260
|
+
}, [columnCount, initialScroll, itemList]);
|
|
257
261
|
|
|
258
262
|
useImperativeHandle(
|
|
259
263
|
galleryRef,
|
|
@@ -328,11 +332,16 @@ const _VirtualGallery = <T extends AnyObject>({
|
|
|
328
332
|
key={`${key}:${col}`}
|
|
329
333
|
data-index={index * columnCount + col}
|
|
330
334
|
className={classNames("grid rounded-capped")}
|
|
335
|
+
style={{
|
|
336
|
+
minWidth: width,
|
|
337
|
+
minHeight: height,
|
|
338
|
+
}}
|
|
331
339
|
>
|
|
332
|
-
{itemList[index * columnCount + col]
|
|
333
|
-
children(
|
|
334
|
-
|
|
335
|
-
|
|
340
|
+
{itemList[index * columnCount + col]?.item ? (
|
|
341
|
+
children(itemList[index * columnCount + col] as AnyObject)
|
|
342
|
+
) : (
|
|
343
|
+
<Skeleton className="p-2" />
|
|
344
|
+
)}
|
|
336
345
|
</div>
|
|
337
346
|
))}
|
|
338
347
|
</div>
|
package/src/virtual/List.tsx
CHANGED
|
@@ -133,7 +133,7 @@ const _VirtualList = <T extends AnyObject>({
|
|
|
133
133
|
const extraSize = useMemo(() => (onLoadMore ? 8 : 0), [onLoadMore]);
|
|
134
134
|
const itemList: Array<{
|
|
135
135
|
index: number;
|
|
136
|
-
|
|
136
|
+
item: T;
|
|
137
137
|
isLast: boolean;
|
|
138
138
|
isSticky: boolean;
|
|
139
139
|
}> = createItemList(
|
|
@@ -149,7 +149,7 @@ const _VirtualList = <T extends AnyObject>({
|
|
|
149
149
|
const scrollerRef = useRef<HTMLDivElement>(null);
|
|
150
150
|
const virtualizer = useVirtualizer({
|
|
151
151
|
count,
|
|
152
|
-
overscan:
|
|
152
|
+
overscan: 0,
|
|
153
153
|
horizontal: orientation === "horizontal",
|
|
154
154
|
getScrollElement: () => scrollerRef.current,
|
|
155
155
|
estimateSize: () => (orientation === "horizontal" ? width : height),
|
|
@@ -159,7 +159,7 @@ const _VirtualList = <T extends AnyObject>({
|
|
|
159
159
|
|
|
160
160
|
const currentIndex = useRef(0);
|
|
161
161
|
useEffect(() => {
|
|
162
|
-
currentIndex.current = virtualItems[
|
|
162
|
+
currentIndex.current = virtualItems[0]?.index ?? 0;
|
|
163
163
|
if (
|
|
164
164
|
scrollerRef.current &&
|
|
165
165
|
virtualItems[0] &&
|
|
@@ -225,12 +225,18 @@ const _VirtualList = <T extends AnyObject>({
|
|
|
225
225
|
}
|
|
226
226
|
}, [onLoadMore, virtualItems]);
|
|
227
227
|
|
|
228
|
+
const isRenderedRef = useRef(false);
|
|
228
229
|
useLayoutEffect(() => {
|
|
229
|
-
|
|
230
|
+
if (!isRenderedRef.current && itemList.length > 0) {
|
|
231
|
+
isRenderedRef.current = true;
|
|
230
232
|
initialScroll &&
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
virtualizer.scrollToIndex(Math.floor(initialScroll), {
|
|
235
|
+
align: "start",
|
|
236
|
+
});
|
|
237
|
+
}, 200);
|
|
238
|
+
}
|
|
239
|
+
}, [itemList, initialScroll]);
|
|
234
240
|
|
|
235
241
|
useImperativeHandle(
|
|
236
242
|
listRef,
|
|
@@ -311,8 +317,16 @@ const _VirtualList = <T extends AnyObject>({
|
|
|
311
317
|
"rounded-capped",
|
|
312
318
|
orientation === "horizontal" ? "inline-grid" : "grid",
|
|
313
319
|
)}
|
|
320
|
+
style={{
|
|
321
|
+
minWidth: width,
|
|
322
|
+
minHeight: height,
|
|
323
|
+
}}
|
|
314
324
|
>
|
|
315
|
-
{
|
|
325
|
+
{itemList[index]?.item ? (
|
|
326
|
+
children(itemList[index] as AnyObject)
|
|
327
|
+
) : (
|
|
328
|
+
<Skeleton className="p-2" />
|
|
329
|
+
)}
|
|
316
330
|
</div>
|
|
317
331
|
))}
|
|
318
332
|
</div>
|
package/src/virtual/Scroller.tsx
CHANGED
|
@@ -41,38 +41,46 @@ export const Scroller = ({
|
|
|
41
41
|
return (
|
|
42
42
|
<ButtonGroup vertical={vertical} variant="link" className="outline">
|
|
43
43
|
<Button
|
|
44
|
-
rtlFlip
|
|
45
44
|
size="sm"
|
|
46
45
|
variant="link"
|
|
47
46
|
aria-label="scroll to top"
|
|
48
|
-
icon={
|
|
47
|
+
icon={{
|
|
48
|
+
icon: vertical ? CoreIcons.chevronsUp : CoreIcons.chevronsLeft,
|
|
49
|
+
rtlFlip: true,
|
|
50
|
+
}}
|
|
49
51
|
disabled={(scrollActive & 2) === 0}
|
|
50
52
|
onClick={onStart}
|
|
51
53
|
/>
|
|
52
54
|
<Button
|
|
53
|
-
rtlFlip
|
|
54
55
|
size="sm"
|
|
55
56
|
variant="link"
|
|
56
57
|
aria-label="scroll up"
|
|
57
|
-
icon={
|
|
58
|
+
icon={{
|
|
59
|
+
icon: vertical ? CoreIcons.chevronUp : CoreIcons.chevronLeft,
|
|
60
|
+
rtlFlip: true,
|
|
61
|
+
}}
|
|
58
62
|
disabled={(scrollActive & 2) === 0}
|
|
59
63
|
onClick={onPrevious}
|
|
60
64
|
/>
|
|
61
65
|
<Button
|
|
62
|
-
rtlFlip
|
|
63
66
|
size="sm"
|
|
64
67
|
variant="link"
|
|
65
68
|
aria-label="scroll down"
|
|
66
|
-
icon={
|
|
69
|
+
icon={{
|
|
70
|
+
icon: vertical ? CoreIcons.chevronDown : CoreIcons.chevronRight,
|
|
71
|
+
rtlFlip: true,
|
|
72
|
+
}}
|
|
67
73
|
disabled={scrollActive % 2 === 0}
|
|
68
74
|
onClick={onNext}
|
|
69
75
|
/>
|
|
70
76
|
<Button
|
|
71
|
-
rtlFlip
|
|
72
77
|
size="sm"
|
|
73
78
|
variant="link"
|
|
74
79
|
aria-label="scroll to bottom"
|
|
75
|
-
icon={
|
|
80
|
+
icon={{
|
|
81
|
+
icon: vertical ? CoreIcons.chevronsDown : CoreIcons.chevronsRight,
|
|
82
|
+
rtlFlip: true,
|
|
83
|
+
}}
|
|
76
84
|
disabled={scrollActive % 2 === 0}
|
|
77
85
|
onClick={onEnd}
|
|
78
86
|
/>
|