@react-fabric/data 1.0.0-beta.5 → 1.0.0-beta.52
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 +48 -16
- package/dist/cjs/histogram/Histogram.js +48 -10
- package/dist/cjs/hooks/useFilteredList.js +20 -0
- package/dist/cjs/hooks/usePagination.js +27 -4
- package/dist/cjs/hooks/useSelectableList.js +29 -0
- package/dist/cjs/i18n/ar.json.js +8 -1
- package/dist/cjs/i18n/en.json.js +8 -1
- package/dist/cjs/json/JsonViewer.js +67 -27
- package/dist/cjs/pagination/Pagination.js +10 -0
- 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/types.js +29 -0
- 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 +84 -35
- package/dist/cjs/virtual/List.js +82 -32
- package/dist/esm/checklist/CheckList.js +50 -18
- package/dist/esm/histogram/Histogram.js +49 -11
- package/dist/esm/hooks/useFilteredList.js +20 -0
- package/dist/esm/hooks/usePagination.js +27 -4
- package/dist/esm/hooks/useSelectableList.js +29 -0
- package/dist/esm/i18n/ar.json.js +8 -2
- package/dist/esm/i18n/en.json.js +8 -2
- package/dist/esm/json/JsonViewer.js +68 -28
- package/dist/esm/pagination/Pagination.js +10 -0
- 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/types.js +29 -0
- 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 +84 -35
- package/dist/esm/virtual/List.js +82 -32
- package/dist/types/checklist/CheckList.d.ts +24 -2
- package/dist/types/histogram/Histogram.d.ts +31 -4
- package/dist/types/hooks/useFilteredList.d.ts +20 -2
- package/dist/types/hooks/usePagination.d.ts +19 -0
- package/dist/types/hooks/useSelectableList.d.ts +29 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/json/JsonViewer.d.ts +27 -2
- package/dist/types/pagination/Pagination.d.ts +10 -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 +14 -1
- package/dist/types/table/types.d.ts +48 -7
- package/dist/types/table/useTableColumns.d.ts +6 -6
- package/dist/types/table/useVirtualTable.d.ts +23 -8
- package/dist/types/tree/TreeNode.d.ts +1 -1
- package/dist/types/tree/TreePanel.d.ts +42 -1
- package/dist/types/tree/types.d.ts +25 -5
- package/dist/types/tree/useTree.d.ts +3 -10
- package/dist/types/tree/utils.d.ts +4 -1
- package/dist/types/virtual/Gallery.d.ts +44 -4
- package/dist/types/virtual/List.d.ts +44 -4
- package/package.json +13 -10
- package/src/checklist/CheckList.tsx +103 -77
- package/src/histogram/Histogram.tsx +45 -11
- package/src/hooks/useFilteredList.tsx +19 -0
- package/src/hooks/usePagination.tsx +32 -7
- package/src/hooks/useSelectableList.ts +29 -0
- package/src/i18n/ar.json +5 -0
- package/src/i18n/en.json +5 -0
- package/src/index.ts +1 -1
- package/src/json/JsonViewer.tsx +71 -35
- package/src/pagination/Pagination.tsx +10 -0
- 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 +177 -77
- package/src/table/types.ts +52 -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 +64 -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 +96 -42
- package/src/virtual/List.tsx +82 -33
- package/dist/cjs/histogram/Histogram.module.css +0 -1
- package/dist/esm/histogram/Histogram.module.css +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export interface PaginationProps {
|
|
3
2
|
/**
|
|
4
3
|
* currrent page number
|
|
@@ -21,4 +20,14 @@ export interface PaginationProps {
|
|
|
21
20
|
*/
|
|
22
21
|
onPageChange: (page: number) => void;
|
|
23
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Pagination component to navigate through pages of data.
|
|
25
|
+
* It displays buttons for navigating to the first, previous, next, and last pages,
|
|
26
|
+
* as well as buttons for specific page numbers based on the provided ranges.
|
|
27
|
+
* The component supports a minimal view that shows the current page and total pages.
|
|
28
|
+
* It uses memoization to optimize rendering performance.
|
|
29
|
+
*
|
|
30
|
+
* @param {PaginationProps} props - The properties for the Pagination component.
|
|
31
|
+
* @returns {JSX.Element} The rendered Pagination component.
|
|
32
|
+
*/
|
|
24
33
|
export declare const Pagination: import("react").MemoExoticComponent<({ page, ranges, totalPages, minimal, onPageChange }: PaginationProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -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,15 @@
|
|
|
1
1
|
import { type TableProps } from "./types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Table component for displaying data in a tabular format with features like sorting, filtering, and virtual scrolling.
|
|
4
|
+
* It supports expandable rows, checkable rows, and customizable columns.
|
|
5
|
+
* The component is designed to handle large datasets efficiently by rendering only the visible rows.
|
|
6
|
+
* It also provides a way to manage column visibility and allows for custom rendering of group headers.
|
|
7
|
+
* Uses TanStack's `useVirtual` for virtualization and React's `useMemo` for performance optimization.
|
|
8
|
+
*
|
|
9
|
+
* @param {TableProps<T>} props - The properties for the Table component.
|
|
10
|
+
* @returns {JSX.Element} The rendered Table component.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/data-table--table}
|
|
13
|
+
* @see {@link https://tanstack.com/table/v8/docs/api/virtual}
|
|
14
|
+
*/
|
|
15
|
+
export declare const Table: <T extends KeyValue = KeyValue>({ 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,58 @@
|
|
|
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
|
-
|
|
6
|
+
/**
|
|
7
|
+
* TableColumn interface defines the structure of a column in a table.
|
|
8
|
+
* It includes properties for column identification, display options, alignment,
|
|
9
|
+
* visibility, resizing, sorting, filtering, and rendering.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The type of data the column will represent, defaulting to KeyValue.
|
|
12
|
+
* @property {keyof T | string} id - Unique identifier for the column.
|
|
13
|
+
* @property {"string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown"} [dataType] - Data type of the column values.
|
|
14
|
+
* @property {string} [label] - Display label for the column header.
|
|
15
|
+
* @property {string} [tooltip] - Tooltip text for the column header.
|
|
16
|
+
* @property {string} [format] - Format string for displaying the column values.
|
|
17
|
+
* @property {"start" | "center" | "end"} [align] - Text alignment within the column.
|
|
18
|
+
* @property {"start" | "end"} [locked] - Indicates if the column is locked at the start or end.
|
|
19
|
+
* @property {boolean} [hidden] - Whether the column is hidden.
|
|
20
|
+
* @property {boolean} [truncate] - Whether to truncate the text in the column.
|
|
21
|
+
* @property {boolean} [hideable] - Whether the column can be hidden by the user.
|
|
22
|
+
* @property {boolean} [resizable] - Whether the column can be resized by the user.
|
|
23
|
+
* @property {boolean} [sortable] - Whether the column can be sorted.
|
|
24
|
+
* @property {boolean} [filterable] - Whether the column can be filtered.
|
|
25
|
+
* @property {AnyObject} [filter] - Filter criteria for the column.
|
|
26
|
+
* @property {ReactElement[]} [actions] - Array of action elements to be displayed in the column.
|
|
27
|
+
* @property {AnyObject[]} [filterOptions] - Options for filtering the column.
|
|
28
|
+
* @property {string | number} [width] - Width of the column.
|
|
29
|
+
* @property {string | number} [minWidth] - Minimum width of the column.
|
|
30
|
+
* @property {string | number} [maxWidth] - Maximum width of the column.
|
|
31
|
+
* @property {KeyValue} [valueMap] - Mapping of values for the column.
|
|
32
|
+
* @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
|
|
33
|
+
*/
|
|
34
|
+
export interface TableColumn<T = KeyValue> extends CssProp, IconProps, TestProps {
|
|
7
35
|
id: keyof T | string;
|
|
8
36
|
label?: string;
|
|
9
|
-
|
|
37
|
+
tooltip?: string;
|
|
38
|
+
actions?: ReactElement[];
|
|
10
39
|
align?: "start" | "center" | "end";
|
|
11
40
|
locked?: "start" | "end";
|
|
12
41
|
hidden?: boolean;
|
|
42
|
+
truncate?: boolean;
|
|
13
43
|
hideable?: boolean;
|
|
14
44
|
resizable?: boolean;
|
|
15
45
|
sortable?: boolean;
|
|
16
46
|
filterable?: boolean;
|
|
17
|
-
|
|
47
|
+
filter?: AnyObject;
|
|
48
|
+
filterOptions?: AnyObject[];
|
|
18
49
|
width?: string | number;
|
|
19
50
|
minWidth?: string | number;
|
|
20
51
|
maxWidth?: string | number;
|
|
21
52
|
dataType?: "string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown";
|
|
22
53
|
format?: string;
|
|
23
|
-
|
|
54
|
+
valueMap?: KeyValue;
|
|
55
|
+
renderer?: (value: AnyObject, data: T, index: number) => Elements<AnyObject>;
|
|
24
56
|
}
|
|
25
57
|
export interface TableRef {
|
|
26
58
|
hilight: (row: number) => void;
|
|
@@ -28,14 +60,18 @@ export interface TableRef {
|
|
|
28
60
|
scrollTo: (row: number) => void;
|
|
29
61
|
}
|
|
30
62
|
export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
|
|
31
|
-
columns: Array<
|
|
63
|
+
columns: Array<TableColumn<T>>;
|
|
32
64
|
data: T[];
|
|
33
65
|
keyProperty?: keyof T;
|
|
66
|
+
groupProperty?: keyof T;
|
|
67
|
+
groupRenderer?: (key: AnyObject) => ReactElement;
|
|
68
|
+
emptyDisplay?: ReactElement;
|
|
34
69
|
/**
|
|
35
70
|
* checkable rows
|
|
36
71
|
*/
|
|
72
|
+
checked?: AnyObject[];
|
|
37
73
|
checkableRows?: boolean;
|
|
38
|
-
onCheckedChanged?: (rows:
|
|
74
|
+
onCheckedChanged?: (rows: AnyObject[]) => void;
|
|
39
75
|
/**
|
|
40
76
|
* sorting
|
|
41
77
|
*/
|
|
@@ -50,4 +86,9 @@ export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
|
|
|
50
86
|
loading?: boolean;
|
|
51
87
|
hideableColumns?: boolean;
|
|
52
88
|
onRowClick?: (data: T) => void;
|
|
89
|
+
initialScroll?: number;
|
|
90
|
+
onScroll?: (firstItem: number) => void;
|
|
91
|
+
canExpand?: (record: T) => boolean;
|
|
92
|
+
children?: (record: T) => Elements<AnyObject>;
|
|
93
|
+
onFilter?: (id: keyof T | string, value?: AnyObject) => void;
|
|
53
94
|
}
|
|
@@ -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,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface DataState<T = KeyValue> {
|
|
2
|
+
data: T[];
|
|
3
|
+
items: T[];
|
|
4
|
+
grouped: KeyValue<T[]>;
|
|
5
|
+
groups: AnyObject[];
|
|
6
|
+
expanded: AnyObject[];
|
|
7
|
+
checked: AnyObject[];
|
|
4
8
|
allChecked: 0 | 1 | 2;
|
|
5
9
|
}
|
|
6
|
-
export declare const useVirtualTable:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export declare const useVirtualTable: <T extends KeyValue = KeyValue>(data: T[], options: {
|
|
11
|
+
checked?: AnyObject[];
|
|
12
|
+
keyProperty: keyof T;
|
|
13
|
+
groupProperty?: keyof T;
|
|
14
|
+
onCheckChanged?: (checked: AnyObject[]) => void;
|
|
15
|
+
}) => {
|
|
16
|
+
scrollerRef: import("react").RefObject<HTMLDivElement | null>;
|
|
17
|
+
items: import("@tanstack/virtual-core").VirtualItem[];
|
|
18
|
+
checkState: DataState<T>;
|
|
19
|
+
getData: (index: number) => T;
|
|
20
|
+
virtualizer: import("@tanstack/virtual-core").Virtualizer<HTMLDivElement, Element>;
|
|
21
|
+
hasActiveSticky: boolean;
|
|
22
|
+
isActiveSticky: (index: number) => boolean;
|
|
23
|
+
top: number | undefined;
|
|
11
24
|
totalSize: () => number;
|
|
12
25
|
measureElement: (node: Element | null | undefined) => void;
|
|
26
|
+
toggleGroupExpand: (key: Key) => void;
|
|
27
|
+
toggleExpand: (key: Key) => void;
|
|
13
28
|
toggleChecked: (key: Key) => void;
|
|
14
29
|
toggleAllChecked: () => void;
|
|
15
30
|
};
|
|
@@ -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,43 @@
|
|
|
1
1
|
import { type TreePanelProps } from "./types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* TreePanel component renders a virtualized tree structure with support for
|
|
4
|
+
* selection, expansion, and filtering. It allows for custom rendering of tree
|
|
5
|
+
* nodes and supports checkable nodes.
|
|
6
|
+
*
|
|
7
|
+
* @param {TreePanelProps<T>} props - The properties for the TreePanel component.
|
|
8
|
+
* @returns {JSX.Element} The rendered TreePanel component.
|
|
9
|
+
* @template T - The type of items in the tree, extending KeyValue.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```jsx
|
|
13
|
+
* <TreePanel
|
|
14
|
+
* items={items}
|
|
15
|
+
* selected={selectedItem}
|
|
16
|
+
* checked={checkedItems}
|
|
17
|
+
* checkable={true}
|
|
18
|
+
* renderer={(item) => <span>{item.name}</span>}
|
|
19
|
+
* searchable={true}
|
|
20
|
+
* selectable={true}
|
|
21
|
+
* matcher={(item, query) => item.name.toLowerCase().includes(query.toLowerCase())}
|
|
22
|
+
* filterPlaceholder="Search..."
|
|
23
|
+
* defaultLeafIcon={<Icon icon={CoreIcons.file} />}
|
|
24
|
+
* defaultNodeIcon={<Icon icon={CoreIcons.folder} />}
|
|
25
|
+
* expander="caret"
|
|
26
|
+
* onChecked={(checkedItems) => console.log(checkedItems)}
|
|
27
|
+
* onLoad={(id) => console.log(`Load children for ${id}`)}
|
|
28
|
+
* onQuery={(query) => console.log(`Query: ${query}`)}
|
|
29
|
+
* onSelect={(selectedItem) => console.log(selectedItem)}
|
|
30
|
+
* onClick={(item) => console.log(`Clicked on ${item.id}`)}
|
|
31
|
+
* sorter={(a, b) => a.label.localeCompare(b.label)}
|
|
32
|
+
* makeLabel={(item) => item.name}
|
|
33
|
+
* makeIcon={(item) => item.icon ? <Icon icon={item.icon} /> : null}
|
|
34
|
+
* defaultExpanded={["root"]}
|
|
35
|
+
* onExpandToggle={(id, expanded) => console.log(`Toggle expand for ${id}: ${expanded}`)}
|
|
36
|
+
* leafClassName="leaf-node"
|
|
37
|
+
* nodeClassName="tree-node"
|
|
38
|
+
* />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-treepanel--docs}
|
|
42
|
+
*/
|
|
43
|
+
export declare const TreePanel: <T extends KeyValue>({ 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
|
|
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>({ 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;
|
|
@@ -15,7 +8,7 @@ export declare const useTree: <T extends KeyValue<any>>({ items, checked, select
|
|
|
15
8
|
select: (id: string) => void;
|
|
16
9
|
expand: (id: string) => void;
|
|
17
10
|
onFilter: {
|
|
18
|
-
(...args:
|
|
11
|
+
(...args: AnyObject): void;
|
|
19
12
|
cancel(): void;
|
|
20
13
|
};
|
|
21
14
|
};
|
|
@@ -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,45 @@ 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
|
}
|
|
60
|
+
/**
|
|
61
|
+
* VirtualGallery component provides a virtualized gallery view for displaying a large list of items efficiently.
|
|
62
|
+
* It supports features like fixed columns, loading states, and customizable item rendering.
|
|
63
|
+
* The component uses virtualization to render only the visible items, improving performance for large datasets.
|
|
64
|
+
* It also provides a scroller for easy navigation through the items.
|
|
65
|
+
*
|
|
66
|
+
* @param {VirtualGalleryProps<T>} props - The properties for the VirtualGallery component.
|
|
67
|
+
* @returns {JSX.Element} The rendered VirtualGallery component.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```jsx
|
|
71
|
+
* <VirtualGallery
|
|
72
|
+
* items={items}
|
|
73
|
+
* columns={3}
|
|
74
|
+
* defaultHeight={100}
|
|
75
|
+
* defaultWidth={100}
|
|
76
|
+
* fullWidth={true}
|
|
77
|
+
* onLoadMore={(lastIndex) => console.log("Load more items from index:", lastIndex)}
|
|
78
|
+
* onScroll={(top) => console.log("Scrolled to top:", top)}
|
|
79
|
+
* >
|
|
80
|
+
* {({ item, index, isLast }) => (
|
|
81
|
+
* <div className="gallery-item" key={item.id}>
|
|
82
|
+
* <img src={item.image} alt={item.label} />
|
|
83
|
+
* <p>{item.label}</p>
|
|
84
|
+
* </div>
|
|
85
|
+
* )}
|
|
86
|
+
* </VirtualGallery>
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-virtualgallery--docs}
|
|
90
|
+
* @see {@link https://tanstack.com/docs/react-virtual/latest/overview}
|
|
91
|
+
*/
|
|
52
92
|
export declare const VirtualGallery: {
|
|
53
|
-
<T extends
|
|
93
|
+
<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
94
|
displayName: string;
|
|
55
95
|
};
|
|
@@ -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,49 @@ 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
|
}
|
|
60
|
+
/**
|
|
61
|
+
* VirtualList component for rendering large lists efficiently using virtualization.
|
|
62
|
+
* It supports horizontal and vertical orientations, custom item heights and widths,
|
|
63
|
+
* and provides a scroller for navigating through the list.
|
|
64
|
+
* It also supports loading more items on scroll and provides a way to hilight items.
|
|
65
|
+
* It can be used with a ref to control scrolling and hilighting of items.
|
|
66
|
+
*
|
|
67
|
+
* @param {VirtualListProps<T>} props - The properties for the VirtualList component.
|
|
68
|
+
* @returns {JSX.Element} The rendered VirtualList component.
|
|
69
|
+
* @template T - The type of items in the list, extending AnyObject.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```jsx
|
|
73
|
+
* <VirtualList
|
|
74
|
+
* items={items}
|
|
75
|
+
* children={({ item, index, isLast }) => (
|
|
76
|
+
* <div key={index} className="item">
|
|
77
|
+
* {item.label}
|
|
78
|
+
* </div>
|
|
79
|
+
* )}
|
|
80
|
+
* fullWidth={true}
|
|
81
|
+
* orientation="vertical"
|
|
82
|
+
* defaultHeight={50}
|
|
83
|
+
* onLoadMore={(lastIndex) => console.log("Load more items from index:", lastIndex)}
|
|
84
|
+
* onScroll={(top) => console.log("Scrolled to top:", top)}
|
|
85
|
+
* listRef={virtualListRef}
|
|
86
|
+
* >
|
|
87
|
+
* {({ item, index, isLast }) => (
|
|
88
|
+
* <div className="gallery-item" key={item.id}>
|
|
89
|
+
* <img src={item.image} alt={item.label} />
|
|
90
|
+
* <p>{item.label}</p>
|
|
91
|
+
* </div>
|
|
92
|
+
* )}
|
|
93
|
+
* </VirtualList>
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
56
96
|
export declare const VirtualList: {
|
|
57
|
-
<T extends
|
|
97
|
+
<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
98
|
displayName: string;
|
|
59
99
|
};
|
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.52",
|
|
4
4
|
"description": "RUF: Data package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
"types": "dist/types/index.d.ts",
|
|
12
12
|
"directories": {
|
|
13
13
|
"src": "src",
|
|
14
|
+
"styles": "css",
|
|
14
15
|
"test": "tests"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
18
|
+
"css",
|
|
17
19
|
"src",
|
|
18
20
|
"dist"
|
|
19
21
|
],
|
|
@@ -33,23 +35,24 @@
|
|
|
33
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
34
36
|
},
|
|
35
37
|
"dependencies": {
|
|
36
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
37
|
-
"@react-fabric/
|
|
38
|
-
"@react-fabric/
|
|
39
|
-
"@
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.52",
|
|
39
|
+
"@react-fabric/date": "^1.0.0-beta.52",
|
|
40
|
+
"@react-fabric/form": "^1.0.0-beta.52",
|
|
41
|
+
"@react-fabric/utilities": "^1.0.0-beta.52",
|
|
42
|
+
"@tanstack/react-virtual": "^3.13.9",
|
|
40
43
|
"classnames": "^2.5.1",
|
|
41
44
|
"color": "^4.2.3",
|
|
42
45
|
"memoize-one": "^6.0.0"
|
|
43
46
|
},
|
|
44
47
|
"peerDependencies": {
|
|
45
|
-
"i18next": "^
|
|
46
|
-
"react": "
|
|
47
|
-
"react-dom": "
|
|
48
|
-
"react-i18next": "^15.
|
|
48
|
+
"i18next": "^25.2.1",
|
|
49
|
+
"react": "^19.0.0",
|
|
50
|
+
"react-dom": "^19.0.0",
|
|
51
|
+
"react-i18next": "^15.5.2"
|
|
49
52
|
},
|
|
50
53
|
"engines": {
|
|
51
54
|
"node": ">=18.12.0",
|
|
52
55
|
"npm": ">=8.19.0"
|
|
53
56
|
},
|
|
54
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "0eabb9d88d91af93d657bcc209b226fd576e8260"
|
|
55
58
|
}
|