@react-fabric/data 1.0.0-beta.5 → 1.0.0-beta.51
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/{src/histogram/Histogram.module.css → css/_histogram.css} +16 -13
- package/css/styles.css +24 -0
- package/dist/cjs/checklist/CheckList.js +25 -16
- package/dist/cjs/histogram/Histogram.js +20 -10
- package/dist/cjs/hooks/usePagination.js +7 -4
- package/dist/cjs/json/JsonViewer.js +40 -27
- package/dist/cjs/table/AddColumn.js +1 -1
- package/dist/cjs/table/BodyCell.js +38 -5
- package/dist/cjs/table/BodyRow.js +107 -0
- package/dist/cjs/table/CheckboxCell.js +1 -1
- package/dist/cjs/table/ColumnFilters.js +97 -0
- package/dist/cjs/table/HeaderCell.js +70 -37
- package/dist/cjs/table/Table.js +113 -71
- package/dist/cjs/table/useResizer.js +4 -4
- package/dist/cjs/table/useVirtualTable.js +122 -18
- package/dist/cjs/tree/TreeNode.js +45 -25
- package/dist/cjs/tree/TreePanel.js +28 -10
- package/dist/cjs/tree/useTree.js +97 -15
- package/dist/cjs/tree/utils.js +20 -5
- package/dist/cjs/virtual/Gallery.js +51 -35
- package/dist/cjs/virtual/List.js +44 -31
- package/dist/esm/checklist/CheckList.js +27 -18
- package/dist/esm/histogram/Histogram.js +21 -11
- package/dist/esm/hooks/usePagination.js +7 -4
- package/dist/esm/json/JsonViewer.js +41 -28
- package/dist/esm/table/AddColumn.js +1 -1
- package/dist/esm/table/BodyCell.js +38 -5
- package/dist/esm/table/BodyRow.js +107 -0
- package/dist/esm/table/CheckboxCell.js +1 -1
- package/dist/esm/table/ColumnFilters.js +97 -0
- package/dist/esm/table/HeaderCell.js +71 -38
- package/dist/esm/table/Table.js +115 -73
- package/dist/esm/table/useResizer.js +4 -4
- package/dist/esm/table/useVirtualTable.js +124 -20
- package/dist/esm/tree/TreeNode.js +47 -27
- package/dist/esm/tree/TreePanel.js +28 -10
- package/dist/esm/tree/useTree.js +99 -17
- package/dist/esm/tree/utils.js +20 -5
- package/dist/esm/virtual/Gallery.js +51 -35
- package/dist/esm/virtual/List.js +44 -31
- package/dist/types/checklist/CheckList.d.ts +2 -2
- package/dist/types/histogram/Histogram.d.ts +3 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/json/JsonViewer.d.ts +0 -1
- package/dist/types/table/AddColumn.d.ts +2 -2
- package/dist/types/table/BodyCell.d.ts +4 -3
- package/dist/types/table/BodyRow.d.ts +20 -0
- package/dist/types/table/ColumnFilters.d.ts +9 -0
- package/dist/types/table/EmptyCell.d.ts +2 -2
- package/dist/types/table/HeaderCell.d.ts +2 -2
- package/dist/types/table/Table.d.ts +1 -1
- package/dist/types/table/types.d.ts +20 -7
- package/dist/types/table/useTableColumns.d.ts +6 -6
- package/dist/types/table/useVirtualTable.d.ts +23 -7
- package/dist/types/tree/TreeNode.d.ts +1 -1
- package/dist/types/tree/TreePanel.d.ts +1 -1
- package/dist/types/tree/types.d.ts +25 -5
- package/dist/types/tree/useTree.d.ts +2 -9
- package/dist/types/tree/utils.d.ts +4 -1
- package/dist/types/virtual/Gallery.d.ts +12 -4
- package/dist/types/virtual/List.d.ts +8 -4
- package/package.json +13 -10
- package/src/checklist/CheckList.tsx +81 -77
- package/src/histogram/Histogram.tsx +17 -11
- package/src/hooks/usePagination.tsx +13 -7
- package/src/index.ts +1 -1
- package/src/json/JsonViewer.tsx +45 -35
- package/src/table/AddColumn.tsx +3 -3
- package/src/table/BodyCell.tsx +34 -5
- package/src/table/BodyRow.tsx +143 -0
- package/src/table/CheckboxCell.tsx +1 -1
- package/src/table/ColumnFilters.tsx +105 -0
- package/src/table/EmptyCell.tsx +2 -2
- package/src/table/HeaderCell.tsx +72 -14
- package/src/table/Table.tsx +164 -77
- package/src/table/types.ts +24 -6
- package/src/table/useResizer.ts +5 -3
- package/src/table/useTableColumns.ts +7 -7
- package/src/table/useVirtualTable.ts +146 -24
- package/src/tree/TreeNode.tsx +98 -56
- package/src/tree/TreePanel.tsx +23 -3
- package/src/tree/types.ts +32 -4
- package/src/tree/useTree.ts +109 -26
- package/src/tree/utils.ts +23 -8
- package/src/virtual/Gallery.tsx +63 -42
- package/src/virtual/List.tsx +44 -32
- package/dist/cjs/histogram/Histogram.module.css +0 -1
- package/dist/esm/histogram/Histogram.module.css +0 -1
package/dist/esm/virtual/List.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
4
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
6
|
import { useDebounce, Skeleton } from '@react-fabric/core';
|
|
5
7
|
import { debounce } from '@react-fabric/utilities';
|
|
6
8
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
@@ -10,14 +12,21 @@ import { useDeferredValue, useMemo, useRef, useEffect, useCallback, useState, us
|
|
|
10
12
|
import { Scroller } from './Scroller.js';
|
|
11
13
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
14
|
|
|
15
|
+
var _excluded = ["items", "total", "children", "fullWidth", "maxWidth", "minWidth", "padding", "orientation", "defaultHeight", "defaultWidth", "hideScroller", "initialScroll", "loading", "onLoadMore", "onScroll", "listRef"];
|
|
16
|
+
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; }
|
|
17
|
+
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; }
|
|
13
18
|
var createItemList = memoizeOne(function (items) {
|
|
14
19
|
return items;
|
|
15
20
|
});
|
|
16
21
|
var _VirtualList = function _VirtualList(_ref) {
|
|
17
22
|
var _virtualItems$3, _virtualItems$4;
|
|
18
23
|
var items = _ref.items,
|
|
24
|
+
_ref$total = _ref.total,
|
|
25
|
+
total = _ref$total === void 0 ? 0 : _ref$total,
|
|
19
26
|
children = _ref.children,
|
|
20
27
|
fullWidth = _ref.fullWidth,
|
|
28
|
+
maxWidth = _ref.maxWidth,
|
|
29
|
+
minWidth = _ref.minWidth,
|
|
21
30
|
_ref$padding = _ref.padding,
|
|
22
31
|
padding = _ref$padding === void 0 ? "md" : _ref$padding,
|
|
23
32
|
_ref$orientation = _ref.orientation,
|
|
@@ -31,21 +40,23 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
31
40
|
loading = _ref.loading,
|
|
32
41
|
onLoadMore = _ref.onLoadMore,
|
|
33
42
|
onScroll = _ref.onScroll,
|
|
34
|
-
listRef = _ref.listRef
|
|
43
|
+
listRef = _ref.listRef,
|
|
44
|
+
aria = _objectWithoutProperties(_ref, _excluded);
|
|
35
45
|
var count = useDeferredValue(items.length);
|
|
36
46
|
var extraSize = useMemo(function () {
|
|
37
|
-
return onLoadMore ?
|
|
47
|
+
return onLoadMore ? 8 : 0;
|
|
38
48
|
}, [onLoadMore]);
|
|
39
|
-
var itemList = createItemList(items.map(function (item,
|
|
49
|
+
var itemList = createItemList(items.map(function (item, index) {
|
|
40
50
|
return {
|
|
41
|
-
index:
|
|
42
|
-
|
|
43
|
-
isLast:
|
|
51
|
+
index: index,
|
|
52
|
+
item: item,
|
|
53
|
+
isLast: index + 1 === items.length
|
|
44
54
|
};
|
|
45
55
|
}));
|
|
46
56
|
var scrollerRef = useRef(null);
|
|
47
57
|
var virtualizer = useVirtualizer({
|
|
48
58
|
count: count,
|
|
59
|
+
overscan: 2,
|
|
49
60
|
horizontal: orientation === "horizontal",
|
|
50
61
|
getScrollElement: function getScrollElement() {
|
|
51
62
|
return scrollerRef.current;
|
|
@@ -103,26 +114,23 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
103
114
|
setScrollActive(calculateActiveScroll());
|
|
104
115
|
}, [itemList, calculateActiveScroll]);
|
|
105
116
|
useEffect(function () {
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return db.cancel();
|
|
113
|
-
};
|
|
114
|
-
}, [onLoadMore, loading, itemList, virtualItems, count]);
|
|
115
|
-
useEffect(function () {
|
|
116
|
-
var _virtualItems$2;
|
|
117
|
-
var firstItem = (_virtualItems$2 = virtualItems[0]) === null || _virtualItems$2 === void 0 ? void 0 : _virtualItems$2.index;
|
|
118
|
-
if (onLoadMore && firstItem !== undefined && items[firstItem] === null) {
|
|
117
|
+
if (onLoadMore) {
|
|
118
|
+
var _virtualItems$2, _virtualItems$slice$p;
|
|
119
|
+
var firstItem = (_virtualItems$2 = virtualItems[0]) === null || _virtualItems$2 === void 0 ? void 0 : _virtualItems$2.index;
|
|
120
|
+
var lastItem = virtualItems === null || virtualItems === void 0 || (_virtualItems$slice$p = virtualItems.slice(-1).pop()) === null || _virtualItems$slice$p === void 0 ? void 0 : _virtualItems$slice$p.index;
|
|
121
|
+
var canLoadPrevPage = firstItem !== undefined && items[firstItem] === null;
|
|
122
|
+
var canLoadNextPage = lastItem !== undefined && lastItem === count - 1 && count < total;
|
|
119
123
|
var db = debounce(onLoadMore);
|
|
120
|
-
|
|
124
|
+
if (canLoadPrevPage) {
|
|
125
|
+
db(firstItem);
|
|
126
|
+
} else if (!loading && canLoadNextPage) {
|
|
127
|
+
db(lastItem + 1);
|
|
128
|
+
}
|
|
121
129
|
return function () {
|
|
122
130
|
return db.cancel();
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
|
-
}, [onLoadMore,
|
|
133
|
+
}, [onLoadMore, virtualItems]);
|
|
126
134
|
useLayoutEffect(function () {
|
|
127
135
|
setTimeout(function () {
|
|
128
136
|
initialScroll && virtualizer.scrollToIndex(initialScroll, {
|
|
@@ -134,14 +142,14 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
134
142
|
return {
|
|
135
143
|
scrollToItem: function scrollToItem(index) {
|
|
136
144
|
virtualizer.scrollToIndex(index, {
|
|
137
|
-
align: "
|
|
145
|
+
align: "auto"
|
|
138
146
|
});
|
|
139
147
|
},
|
|
140
148
|
hilight: function hilight(index) {
|
|
141
149
|
var _scrollerRef$current2;
|
|
142
150
|
(_scrollerRef$current2 = scrollerRef.current) === null || _scrollerRef$current2 === void 0 || (_scrollerRef$current2 = _scrollerRef$current2.querySelector(".hilight")) === null || _scrollerRef$current2 === void 0 || _scrollerRef$current2.classList.remove("hilight", "ring-1");
|
|
143
151
|
virtualizer.scrollToIndex(Math.floor(index), {
|
|
144
|
-
align: "
|
|
152
|
+
align: "auto"
|
|
145
153
|
});
|
|
146
154
|
setTimeout(function () {
|
|
147
155
|
var _scrollerRef$current3;
|
|
@@ -154,19 +162,24 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
154
162
|
}
|
|
155
163
|
};
|
|
156
164
|
}, [virtualizer]);
|
|
157
|
-
return /*#__PURE__*/jsx("div", {
|
|
165
|
+
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
158
166
|
ref: scrollerRef,
|
|
159
167
|
onScroll: handleScroll,
|
|
160
|
-
className: classNames("area-content bg-base overflow-auto
|
|
168
|
+
className: classNames("area-content bg-base overflow-auto")
|
|
169
|
+
}, aria), {}, {
|
|
161
170
|
children: /*#__PURE__*/jsxs("div", {
|
|
162
171
|
className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
|
|
163
172
|
children: [/*#__PURE__*/jsxs("div", {
|
|
164
173
|
className: classNames("box-content inline-flex flex-nowrap", orientation === "vertical" && "flex-col", orientation === "horizontal" && "flex-row", fullWidth && "flex-1", padding === "sm" && "p-1", padding === "md" && "p-2", padding === "lg" && "p-4"),
|
|
174
|
+
style: {
|
|
175
|
+
minWidth: minWidth,
|
|
176
|
+
maxWidth: maxWidth
|
|
177
|
+
},
|
|
165
178
|
children: [/*#__PURE__*/jsxs("div", {
|
|
166
179
|
style: orientation === "vertical" ? {
|
|
167
|
-
height: virtualizer.getTotalSize()
|
|
180
|
+
height: virtualizer.getTotalSize() + extraSize
|
|
168
181
|
} : {
|
|
169
|
-
width: virtualizer.getTotalSize()
|
|
182
|
+
width: virtualizer.getTotalSize() + extraSize
|
|
170
183
|
},
|
|
171
184
|
children: [/*#__PURE__*/jsx("div", {
|
|
172
185
|
style: orientation === "vertical" ? {
|
|
@@ -185,9 +198,9 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
185
198
|
children: children(itemList[index])
|
|
186
199
|
}, key);
|
|
187
200
|
})]
|
|
188
|
-
}),
|
|
189
|
-
className: orientation === "horizontal" ? "min-w-16" : "
|
|
190
|
-
children:
|
|
201
|
+
}), loading && /*#__PURE__*/jsx("div", {
|
|
202
|
+
className: orientation === "horizontal" ? "min-w-16" : "",
|
|
203
|
+
children: /*#__PURE__*/jsx(Skeleton, {})
|
|
191
204
|
})]
|
|
192
205
|
}), !hideScroller && /*#__PURE__*/jsx("div", {
|
|
193
206
|
className: classNames(orientation === "vertical" && "self-end sticky bottom-2", orientation === "horizontal" && "self-end sticky end-2"),
|
|
@@ -209,7 +222,7 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
209
222
|
})
|
|
210
223
|
})]
|
|
211
224
|
})
|
|
212
|
-
});
|
|
225
|
+
}));
|
|
213
226
|
};
|
|
214
227
|
_VirtualList.displayName = "VirtualList";
|
|
215
228
|
var GenericMemo = memo;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BadgeType } from "@react-fabric/core/dist/types/types";
|
|
1
|
+
import { type BadgeType, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
2
2
|
import { type FC } from "react";
|
|
3
3
|
import { type SelectableProps } from "../hooks/useSelectableList";
|
|
4
4
|
export interface CheckListItem extends KeyValue {
|
|
@@ -8,7 +8,7 @@ export interface CheckListItem extends KeyValue {
|
|
|
8
8
|
badge?: BadgeType;
|
|
9
9
|
isDisabled?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export interface CheckListProps extends SelectableProps {
|
|
11
|
+
export interface CheckListProps extends SelectableProps, TestProps {
|
|
12
12
|
/**
|
|
13
13
|
* list items
|
|
14
14
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { type ColorType, type PaletteType } from "@react-fabric/core/dist/types/types";
|
|
1
|
+
import { type ColorType, type PaletteType, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
2
|
interface HistogramItem {
|
|
4
3
|
id: string;
|
|
5
4
|
label: string;
|
|
@@ -7,7 +6,7 @@ interface HistogramItem {
|
|
|
7
6
|
total?: number;
|
|
8
7
|
disabled?: boolean;
|
|
9
8
|
}
|
|
10
|
-
export interface HistogramProps {
|
|
9
|
+
export interface HistogramProps extends TestProps {
|
|
11
10
|
/**
|
|
12
11
|
* histogram items list
|
|
13
12
|
*/
|
|
@@ -37,5 +36,5 @@ export interface HistogramProps {
|
|
|
37
36
|
*/
|
|
38
37
|
onClick?: (id: string, negative?: true) => void;
|
|
39
38
|
}
|
|
40
|
-
export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, ...aria }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
40
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { Histogram } from "./histogram/Histogram";
|
|
|
4
4
|
export { JsonViewer } from "./json/JsonViewer";
|
|
5
5
|
export { Pagination } from "./pagination/Pagination";
|
|
6
6
|
export { Table } from "./table/Table";
|
|
7
|
-
export { type TableRef } from "./table/types";
|
|
7
|
+
export { type TableColumn, type TableRef } from "./table/types";
|
|
8
8
|
export { TreePanel } from "./tree/TreePanel";
|
|
9
9
|
export { type TreeNodeType as TreeNode } from "./tree/types";
|
|
10
10
|
export { VirtualGallery, type VirtualGalleryRef } from "./virtual/Gallery";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type TableColumn } from "./types";
|
|
2
2
|
export declare const AddColumn: ({ columns, onClick, }: {
|
|
3
|
-
columns:
|
|
3
|
+
columns: TableColumn[];
|
|
4
4
|
onClick: (id: string) => void;
|
|
5
5
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const BodyCell: ({ column, item, }: {
|
|
3
|
-
column:
|
|
1
|
+
import { type TableColumn } from "./types";
|
|
2
|
+
export declare const BodyCell: ({ column, item, index, }: {
|
|
3
|
+
column: TableColumn;
|
|
4
4
|
item: KeyValue;
|
|
5
|
+
index: number;
|
|
5
6
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type TableColumn } from "./types";
|
|
2
|
+
export declare const BodyRow: ({ rowKey, index, data, keyProperty, measureElement, state, hideableColumns, wrapperStart, wrapperEnd, onRowClick, checkableRows, checked, toggleChecked, canExpand, expanded, toggleExpand, expandRow, }: {
|
|
3
|
+
rowKey: Key;
|
|
4
|
+
index: number;
|
|
5
|
+
data: KeyValue;
|
|
6
|
+
keyProperty?: Key;
|
|
7
|
+
measureElement: AnyObject;
|
|
8
|
+
state: KeyValue<TableColumn[]>;
|
|
9
|
+
hideableColumns?: boolean;
|
|
10
|
+
wrapperStart: string;
|
|
11
|
+
wrapperEnd: string;
|
|
12
|
+
checkableRows?: boolean;
|
|
13
|
+
checked: 0 | 1;
|
|
14
|
+
onRowClick?: AnyObject;
|
|
15
|
+
canExpand?: AnyObject;
|
|
16
|
+
expandRow?: AnyObject;
|
|
17
|
+
expanded: boolean;
|
|
18
|
+
toggleExpand: (key: Key) => void;
|
|
19
|
+
toggleChecked: (key: Key) => void;
|
|
20
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TableColumn } from "./types";
|
|
2
|
+
interface FilterProps {
|
|
3
|
+
type: TableColumn["dataType"];
|
|
4
|
+
onFilter: (value: AnyObject) => void;
|
|
5
|
+
list?: AnyObject[];
|
|
6
|
+
filter: AnyObject;
|
|
7
|
+
}
|
|
8
|
+
export declare const ColumnFilters: ({ type, list, filter, onFilter, }: FilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const EmptyCell: ({ id, width: _width, maxWidth, minWidth, }:
|
|
1
|
+
import { type TableColumn } from "./types";
|
|
2
|
+
export declare const EmptyCell: ({ id, width: _width, maxWidth, minWidth, }: TableColumn) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const HeaderCell: ({ id, label, icon, iconBg, iconColor, rtlFlip, actions, locked, sortable, resizable, width: _width, maxWidth, minWidth, sort, onSort, }:
|
|
1
|
+
import { type TableColumn, type TableProps } from "./types";
|
|
2
|
+
export declare const HeaderCell: ({ id, dataType, label, icon, iconBg, iconColor, rtlFlip, 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,2 +1,2 @@
|
|
|
1
1
|
import { type TableProps } from "./types";
|
|
2
|
-
export declare const Table: <T extends KeyValue<any> = KeyValue<any>>({ ref, data, columns, keyProperty, checkableRows, hideableColumns, sort, loading, onSort, onRowClick, onCheckedChanged, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Table: <T extends KeyValue<any> = KeyValue<any>>({ ref, data, columns, keyProperty, groupProperty, checkableRows, initialScroll, hideableColumns, sort, loading, checked, emptyDisplay, groupRenderer, canExpand, children, onSort, onFilter, onScroll, onRowClick, onCheckedChanged, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import { type CssProp, type IconProps, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
1
|
+
import { type CssProp, type Elements, type IconProps, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
2
2
|
import { type ReactElement } from "react";
|
|
3
3
|
export declare const COL_MIN_WIDTH = "3rem";
|
|
4
4
|
export declare const COL_MAX_WIDTH = "64rem";
|
|
5
5
|
export declare const COL_DEFAULT_WIDTH = "12rem";
|
|
6
|
-
export interface
|
|
6
|
+
export interface TableColumn<T = KeyValue> extends CssProp, IconProps, TestProps {
|
|
7
7
|
id: keyof T | string;
|
|
8
8
|
label?: string;
|
|
9
|
-
|
|
9
|
+
tooltip?: string;
|
|
10
|
+
actions?: ReactElement[];
|
|
10
11
|
align?: "start" | "center" | "end";
|
|
11
12
|
locked?: "start" | "end";
|
|
12
13
|
hidden?: boolean;
|
|
14
|
+
truncate?: boolean;
|
|
13
15
|
hideable?: boolean;
|
|
14
16
|
resizable?: boolean;
|
|
15
17
|
sortable?: boolean;
|
|
16
18
|
filterable?: boolean;
|
|
17
|
-
|
|
19
|
+
filter?: AnyObject;
|
|
20
|
+
filterOptions?: AnyObject[];
|
|
18
21
|
width?: string | number;
|
|
19
22
|
minWidth?: string | number;
|
|
20
23
|
maxWidth?: string | number;
|
|
21
24
|
dataType?: "string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown";
|
|
22
25
|
format?: string;
|
|
23
|
-
|
|
26
|
+
valueMap?: KeyValue;
|
|
27
|
+
renderer?: (value: AnyObject, data: T, index: number) => Elements<AnyObject>;
|
|
24
28
|
}
|
|
25
29
|
export interface TableRef {
|
|
26
30
|
hilight: (row: number) => void;
|
|
@@ -28,14 +32,18 @@ export interface TableRef {
|
|
|
28
32
|
scrollTo: (row: number) => void;
|
|
29
33
|
}
|
|
30
34
|
export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
|
|
31
|
-
columns: Array<
|
|
35
|
+
columns: Array<TableColumn<T>>;
|
|
32
36
|
data: T[];
|
|
33
37
|
keyProperty?: keyof T;
|
|
38
|
+
groupProperty?: keyof T;
|
|
39
|
+
groupRenderer?: (key: AnyObject) => ReactElement;
|
|
40
|
+
emptyDisplay?: ReactElement;
|
|
34
41
|
/**
|
|
35
42
|
* checkable rows
|
|
36
43
|
*/
|
|
44
|
+
checked?: AnyObject[];
|
|
37
45
|
checkableRows?: boolean;
|
|
38
|
-
onCheckedChanged?: (rows:
|
|
46
|
+
onCheckedChanged?: (rows: AnyObject[]) => void;
|
|
39
47
|
/**
|
|
40
48
|
* sorting
|
|
41
49
|
*/
|
|
@@ -50,4 +58,9 @@ export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
|
|
|
50
58
|
loading?: boolean;
|
|
51
59
|
hideableColumns?: boolean;
|
|
52
60
|
onRowClick?: (data: T) => void;
|
|
61
|
+
initialScroll?: number;
|
|
62
|
+
onScroll?: (firstItem: number) => void;
|
|
63
|
+
canExpand?: (record: T) => boolean;
|
|
64
|
+
children?: (record: T) => Elements<AnyObject>;
|
|
65
|
+
onFilter?: (id: keyof T | string, value?: AnyObject) => void;
|
|
53
66
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare const useTableColumns: (columns:
|
|
1
|
+
import { type TableColumn } from "./types";
|
|
2
|
+
export declare const useTableColumns: (columns: TableColumn[]) => {
|
|
3
3
|
state: {
|
|
4
|
-
start:
|
|
5
|
-
end:
|
|
6
|
-
cols:
|
|
7
|
-
columns:
|
|
4
|
+
start: TableColumn<KeyValue<any>>[];
|
|
5
|
+
end: TableColumn<KeyValue<any>>[];
|
|
6
|
+
cols: TableColumn<KeyValue<any>>[];
|
|
7
|
+
columns: TableColumn[];
|
|
8
8
|
};
|
|
9
9
|
onHide: (id: string) => void;
|
|
10
10
|
};
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
interface DataState {
|
|
3
|
-
|
|
2
|
+
interface DataState<T = KeyValue> {
|
|
3
|
+
data: T[];
|
|
4
|
+
items: T[];
|
|
5
|
+
grouped: KeyValue<T[]>;
|
|
6
|
+
groups: AnyObject[];
|
|
7
|
+
expanded: AnyObject[];
|
|
8
|
+
checked: AnyObject[];
|
|
4
9
|
allChecked: 0 | 1 | 2;
|
|
5
10
|
}
|
|
6
|
-
export declare const useVirtualTable:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
export declare const useVirtualTable: <T extends KeyValue<any> = KeyValue<any>>(data: T[], options: {
|
|
12
|
+
checked?: AnyObject[];
|
|
13
|
+
keyProperty: keyof T;
|
|
14
|
+
groupProperty?: keyof T;
|
|
15
|
+
onCheckChanged?: (checked: AnyObject[]) => void;
|
|
16
|
+
}) => {
|
|
17
|
+
scrollerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
18
|
+
items: import("@tanstack/virtual-core").VirtualItem[];
|
|
19
|
+
checkState: DataState<T>;
|
|
20
|
+
getData: (index: number) => T;
|
|
21
|
+
virtualizer: import("@tanstack/virtual-core").Virtualizer<HTMLDivElement, Element>;
|
|
22
|
+
hasActiveSticky: boolean;
|
|
23
|
+
isActiveSticky: (index: number) => boolean;
|
|
24
|
+
top: number | undefined;
|
|
11
25
|
totalSize: () => number;
|
|
12
26
|
measureElement: (node: Element | null | undefined) => void;
|
|
27
|
+
toggleGroupExpand: (key: Key) => void;
|
|
28
|
+
toggleExpand: (key: Key) => void;
|
|
13
29
|
toggleChecked: (key: Key) => void;
|
|
14
30
|
toggleAllChecked: () => void;
|
|
15
31
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type TreeNodeProps } from "./types";
|
|
2
|
-
export declare const TreeNode: ({ node, noLines, expanders, checkable, selectable, defaultLeafIcon, defaultNodeIcon, onToggle, onSelect, onChecked, children, }: TreeNodeProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const TreeNode: ({ node, noLines, expanders, checkable, selectable, defaultLeafIcon, defaultNodeIcon, onToggle, onClick, onSelect, onChecked, children, leafClassName, nodeClassName, }: TreeNodeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type TreePanelProps } from "./types";
|
|
2
|
-
export declare const TreePanel: <T extends KeyValue<any>>({ ref, items, selected, checked, checkable, noLines, renderer, searchable, selectable, matcher, filterPlaceholder, defaultLeafIcon, defaultNodeIcon, expander, onChecked, onLoad, onSelect, ...aria }: TreePanelProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const TreePanel: <T extends KeyValue<any>>({ ref, items, selected, checked, checkable, noLines, renderer, searchable, selectable, matcher, filterPlaceholder, defaultLeafIcon, defaultNodeIcon, expander, onChecked, onLoad, onQuery, onSelect, onClick, sorter, makeLabel, makeIcon, defaultExpanded, onExpandToggle, leafClassName, nodeClassName, ...aria }: TreePanelProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { type BadgeType, type ChildProp, type CssProp, type Elements, type IconProps, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
|
-
|
|
2
|
+
import { type ElementType } from "react";
|
|
3
|
+
interface TreeBaseNode<T> extends Omit<IconProps, "icon">, CssProp, TestProps {
|
|
4
4
|
id: string;
|
|
5
5
|
/**
|
|
6
6
|
* display label
|
|
@@ -23,17 +23,18 @@ interface TreeBaseNode<T> extends IconProps, CssProp, TestProps {
|
|
|
23
23
|
*/
|
|
24
24
|
disabled?: boolean;
|
|
25
25
|
data?: T;
|
|
26
|
+
icon?: ElementType<IconProps> | string;
|
|
26
27
|
}
|
|
27
28
|
export type TreeNodeType<T extends KeyValue = KeyValue> = TreeBaseNode<T> & ({
|
|
28
29
|
leaf: true;
|
|
29
30
|
children?: never;
|
|
30
31
|
} | {
|
|
31
|
-
leaf?:
|
|
32
|
+
leaf?: boolean;
|
|
32
33
|
children?: Array<TreeNodeType<T>>;
|
|
33
34
|
open?: boolean;
|
|
34
35
|
iconOpen?: string;
|
|
35
36
|
});
|
|
36
|
-
export interface InternalNode extends IconProps, CssProp, TestProps {
|
|
37
|
+
export interface InternalNode extends Omit<IconProps, "icon">, CssProp, TestProps {
|
|
37
38
|
id: string;
|
|
38
39
|
label: Elements<JSX.Element>;
|
|
39
40
|
queryable?: string;
|
|
@@ -50,6 +51,7 @@ export interface InternalNode extends IconProps, CssProp, TestProps {
|
|
|
50
51
|
loaded: boolean;
|
|
51
52
|
parent?: string;
|
|
52
53
|
empty?: boolean;
|
|
54
|
+
icon?: ElementType<IconProps> | string;
|
|
53
55
|
errored?: string;
|
|
54
56
|
selected?: true;
|
|
55
57
|
childSelected?: true;
|
|
@@ -66,9 +68,12 @@ export interface TreeNodeProps extends ChildProp {
|
|
|
66
68
|
noLines?: boolean;
|
|
67
69
|
selectable?: true | "leafOnly";
|
|
68
70
|
checkable?: true | "leafOnly";
|
|
71
|
+
leafClassName?: string;
|
|
72
|
+
nodeClassName?: string;
|
|
69
73
|
onToggle: (id: string) => void;
|
|
70
74
|
onSelect: (id: string) => void;
|
|
71
75
|
onChecked: (id: string) => void;
|
|
76
|
+
onClick?: (id: string, node: any) => void;
|
|
72
77
|
}
|
|
73
78
|
export interface TreeRef {
|
|
74
79
|
select: (id: string) => void;
|
|
@@ -120,10 +125,18 @@ export interface TreePanelProps<T extends KeyValue = KeyValue> extends TestProps
|
|
|
120
125
|
* callback for lazy loading tree items
|
|
121
126
|
*/
|
|
122
127
|
onLoad?: (id: string) => Promise<Array<TreeNodeType<T>> | undefined> | Array<TreeNodeType<T>> | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* callback to load tree using search query
|
|
130
|
+
*/
|
|
131
|
+
onQuery?: (query: string) => void;
|
|
132
|
+
/**
|
|
133
|
+
* callback on click of tree node
|
|
134
|
+
*/
|
|
135
|
+
onClick?: (id: string, data: T) => void;
|
|
123
136
|
/**
|
|
124
137
|
* callback on selection of tree node
|
|
125
138
|
*/
|
|
126
|
-
onSelect?: (id: string) => void;
|
|
139
|
+
onSelect?: (id: string, data: T) => void;
|
|
127
140
|
/**
|
|
128
141
|
* callback on change of checked list
|
|
129
142
|
*/
|
|
@@ -136,6 +149,13 @@ export interface TreePanelProps<T extends KeyValue = KeyValue> extends TestProps
|
|
|
136
149
|
* item filter matcher
|
|
137
150
|
*/
|
|
138
151
|
matcher?: (data: T, query: string) => boolean;
|
|
152
|
+
sorter?: false | ((a: T, b: T) => number);
|
|
153
|
+
makeLabel?: (node: T) => string;
|
|
154
|
+
makeIcon?: (node: T) => string;
|
|
155
|
+
defaultExpanded?: string[];
|
|
156
|
+
onExpandToggle?: (id: string[]) => void;
|
|
157
|
+
leafClassName?: string;
|
|
158
|
+
nodeClassName?: string;
|
|
139
159
|
}
|
|
140
160
|
export declare const iconExpandAll = "M12.984 9v6h3l-3.984 3.984-3.984-3.984h3v-6h-3l3.984-3.984 3.984 3.984h-3zM3.984 2.016h16.031v1.969h-16.031v-1.969zM3.984 20.016h16.031v1.969h-16.031v-1.969z";
|
|
141
161
|
export declare const iconCollapseAll = "M3.984 11.016h16.031v1.969h-16.031v-1.969zM15.984 5.016l-3.984 3.984-3.984-3.984h3v-4.031h1.969v4.031h3zM8.016 18.984l3.984-3.984 3.984 3.984h-3v4.031h-1.969v-4.031h-3z";
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { type InternalNode, type
|
|
2
|
-
export declare const useTree: <T extends KeyValue<any>>({ items, checked, selected, matcher, onSelect, onChecked, }: {
|
|
3
|
-
items?: Array<TreeNodeType<T>>;
|
|
4
|
-
selected?: string;
|
|
5
|
-
checked?: string[];
|
|
6
|
-
onSelect?: (id: string) => void;
|
|
7
|
-
onChecked?: (leafs: string[], nodes: string[]) => void;
|
|
8
|
-
matcher?: (data: T, query: string) => boolean;
|
|
9
|
-
}) => {
|
|
1
|
+
import { type InternalNode, type TreePanelProps } from "./types";
|
|
2
|
+
export declare const useTree: <T extends KeyValue<any>>({ items, checked, selected, sorter, matcher, onLoad, onQuery, onSelect, onChecked, defaultExpanded, onExpandToggle, }: Partial<TreePanelProps<T>>) => {
|
|
10
3
|
tree: InternalNode[];
|
|
11
4
|
toggleExpand: (id: string) => void;
|
|
12
5
|
expandAll: () => void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type InternalNode, type TreeNodeType } from "./types";
|
|
2
|
-
export declare const refactorTree: (nodes: TreeNodeType[],
|
|
2
|
+
export declare const refactorTree: (nodes: TreeNodeType[], { sorter, defaultExpanded, }: {
|
|
3
|
+
sorter?: any;
|
|
4
|
+
defaultExpanded?: string[];
|
|
5
|
+
}, options?: {
|
|
3
6
|
level: number;
|
|
4
7
|
parent?: string;
|
|
5
8
|
}) => InternalNode[];
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { type TestProps } from "@react-fabric/core/dist/types/types";
|
|
1
2
|
import { type ReactElement, type Ref } from "react";
|
|
2
3
|
export interface VirtualGalleryRef {
|
|
3
4
|
scrollToItem: (index: number) => void;
|
|
4
5
|
hilight: (index: number) => void;
|
|
5
6
|
unhilight: () => void;
|
|
6
7
|
}
|
|
7
|
-
export interface VirtualGalleryProps<T> {
|
|
8
|
+
export interface VirtualGalleryProps<T> extends TestProps {
|
|
8
9
|
children: (props: {
|
|
9
|
-
|
|
10
|
+
item: T;
|
|
10
11
|
index: number;
|
|
11
12
|
isLast: boolean;
|
|
12
13
|
}) => ReactElement;
|
|
@@ -23,6 +24,12 @@ export interface VirtualGalleryProps<T> {
|
|
|
23
24
|
* default item width
|
|
24
25
|
*/
|
|
25
26
|
defaultWidth?: number;
|
|
27
|
+
/**
|
|
28
|
+
* full width list
|
|
29
|
+
*/
|
|
30
|
+
fullWidth?: boolean;
|
|
31
|
+
maxWidth?: string | number;
|
|
32
|
+
minWidth?: string | number;
|
|
26
33
|
/**
|
|
27
34
|
* padding
|
|
28
35
|
*/
|
|
@@ -31,6 +38,7 @@ export interface VirtualGalleryProps<T> {
|
|
|
31
38
|
* data list
|
|
32
39
|
*/
|
|
33
40
|
items: T[];
|
|
41
|
+
total?: number;
|
|
34
42
|
/**
|
|
35
43
|
* loading state
|
|
36
44
|
*/
|
|
@@ -43,13 +51,13 @@ export interface VirtualGalleryProps<T> {
|
|
|
43
51
|
/**
|
|
44
52
|
* load more callback
|
|
45
53
|
*/
|
|
46
|
-
onLoadMore?: () => void;
|
|
54
|
+
onLoadMore?: (lastIndex?: number) => void;
|
|
47
55
|
/**
|
|
48
56
|
* scroll handler
|
|
49
57
|
*/
|
|
50
58
|
onScroll?: (top: number) => void;
|
|
51
59
|
}
|
|
52
60
|
export declare const VirtualGallery: {
|
|
53
|
-
<T extends
|
|
61
|
+
<T extends unknown>({ items, children, columns, fullWidth, maxWidth, minWidth, total, padding, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, galleryRef, ...aria }: VirtualGalleryProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
54
62
|
displayName: string;
|
|
55
63
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { type TestProps } from "@react-fabric/core/dist/types/types";
|
|
1
2
|
import { type ReactElement, type Ref } from "react";
|
|
2
3
|
export interface VirtualListRef {
|
|
3
4
|
scrollToItem: (index: number) => void;
|
|
4
5
|
hilight: (index: number) => void;
|
|
5
6
|
unhilight: () => void;
|
|
6
7
|
}
|
|
7
|
-
export interface VirtualListProps<T> {
|
|
8
|
+
export interface VirtualListProps<T> extends TestProps {
|
|
8
9
|
children: (props: {
|
|
9
|
-
|
|
10
|
+
item: T;
|
|
10
11
|
index: number;
|
|
11
12
|
isLast: boolean;
|
|
12
13
|
}) => ReactElement;
|
|
@@ -23,6 +24,8 @@ export interface VirtualListProps<T> {
|
|
|
23
24
|
* full width list
|
|
24
25
|
*/
|
|
25
26
|
fullWidth?: boolean;
|
|
27
|
+
maxWidth?: string | number;
|
|
28
|
+
minWidth?: string | number;
|
|
26
29
|
/**
|
|
27
30
|
* padding
|
|
28
31
|
*/
|
|
@@ -35,6 +38,7 @@ export interface VirtualListProps<T> {
|
|
|
35
38
|
* data list
|
|
36
39
|
*/
|
|
37
40
|
items: T[];
|
|
41
|
+
total?: number;
|
|
38
42
|
initialScroll?: number;
|
|
39
43
|
/**
|
|
40
44
|
* loading state
|
|
@@ -47,13 +51,13 @@ export interface VirtualListProps<T> {
|
|
|
47
51
|
/**
|
|
48
52
|
* load more callback
|
|
49
53
|
*/
|
|
50
|
-
onLoadMore?: (
|
|
54
|
+
onLoadMore?: (lastIndex?: number) => void;
|
|
51
55
|
/**
|
|
52
56
|
* scroll handler
|
|
53
57
|
*/
|
|
54
58
|
onScroll?: (top: number) => void;
|
|
55
59
|
}
|
|
56
60
|
export declare const VirtualList: {
|
|
57
|
-
<T extends
|
|
61
|
+
<T extends unknown>({ items, total, children, fullWidth, maxWidth, minWidth, padding, orientation, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, listRef, ...aria }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
58
62
|
displayName: string;
|
|
59
63
|
};
|