@react-fabric/data 1.0.0-beta.51 → 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/dist/cjs/checklist/CheckList.js +23 -0
- package/dist/cjs/histogram/Histogram.js +28 -0
- package/dist/cjs/hooks/useFilteredList.js +20 -0
- package/dist/cjs/hooks/usePagination.js +20 -0
- 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 +27 -0
- package/dist/cjs/pagination/Pagination.js +10 -0
- package/dist/cjs/table/Table.js +2 -2
- package/dist/cjs/table/types.js +29 -0
- package/dist/cjs/virtual/Gallery.js +35 -2
- package/dist/cjs/virtual/List.js +38 -1
- package/dist/esm/checklist/CheckList.js +23 -0
- package/dist/esm/histogram/Histogram.js +28 -0
- package/dist/esm/hooks/useFilteredList.js +20 -0
- package/dist/esm/hooks/usePagination.js +20 -0
- 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 +27 -0
- package/dist/esm/pagination/Pagination.js +10 -0
- package/dist/esm/table/Table.js +2 -2
- package/dist/esm/table/types.js +29 -0
- package/dist/esm/virtual/Gallery.js +35 -2
- package/dist/esm/virtual/List.js +38 -1
- package/dist/types/checklist/CheckList.d.ts +22 -0
- package/dist/types/histogram/Histogram.d.ts +28 -0
- 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/json/JsonViewer.d.ts +27 -1
- package/dist/types/pagination/Pagination.d.ts +10 -1
- package/dist/types/table/Table.d.ts +14 -1
- package/dist/types/table/types.d.ts +28 -0
- package/dist/types/table/useVirtualTable.d.ts +1 -2
- package/dist/types/tree/TreePanel.d.ts +42 -1
- package/dist/types/tree/useTree.d.ts +2 -2
- package/dist/types/virtual/Gallery.d.ts +32 -0
- package/dist/types/virtual/List.d.ts +36 -0
- package/package.json +6 -6
- package/src/checklist/CheckList.tsx +22 -0
- package/src/histogram/Histogram.tsx +28 -0
- package/src/hooks/useFilteredList.tsx +19 -0
- package/src/hooks/usePagination.tsx +19 -0
- package/src/hooks/useSelectableList.ts +29 -0
- package/src/i18n/ar.json +5 -0
- package/src/i18n/en.json +5 -0
- package/src/json/JsonViewer.tsx +26 -0
- package/src/pagination/Pagination.tsx +10 -0
- package/src/table/Table.tsx +15 -2
- package/src/table/types.ts +28 -0
- package/src/tree/TreePanel.tsx +41 -0
- package/src/virtual/Gallery.tsx +35 -2
- package/src/virtual/List.tsx +38 -1
|
@@ -215,6 +215,33 @@ var JsonEntry = function JsonEntry(_ref3) {
|
|
|
215
215
|
}))]
|
|
216
216
|
});
|
|
217
217
|
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* JsonViewer component to display JSON data in a structured format.
|
|
221
|
+
* It supports inline display, property filtering, and custom formatting.
|
|
222
|
+
* The component can handle nested objects and arrays, displaying them in a tree-like structure.
|
|
223
|
+
* It also provides options for copying values and filtering properties.
|
|
224
|
+
*
|
|
225
|
+
* @param {JsonViewProps<T>} props - The properties for the JsonViewer component.
|
|
226
|
+
* @returns {JSX.Element} The rendered JsonViewer component.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```jsx
|
|
230
|
+
* <JsonViewer
|
|
231
|
+
* json={{ name: "John", age: 30, address: { city: "New York", zip: "10001" } }}
|
|
232
|
+
* copy={true}
|
|
233
|
+
* filters={true}
|
|
234
|
+
* propertyScheme={{ date: ["createdAt"], phone: ["contact"] }}
|
|
235
|
+
* inline={true}
|
|
236
|
+
* labelWidth="25%"
|
|
237
|
+
* formatter={(path, value) => (path === "age" ? `${value} years` : value)}
|
|
238
|
+
* labeler={(path) => path.replace(/_/g, " ").toUpperCase()}
|
|
239
|
+
* onFilter={(path, value, negate) => console.log(`Filter ${negate ? "negate" : ""} on ${path}:`, value)}
|
|
240
|
+
* />
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-jsonviewer--docs}
|
|
244
|
+
*/
|
|
218
245
|
var JsonViewer = function JsonViewer(_ref5) {
|
|
219
246
|
var className = _ref5.className,
|
|
220
247
|
json = _ref5.json,
|
|
@@ -6,6 +6,16 @@ import classNames from 'classnames';
|
|
|
6
6
|
import { memo, useMemo, Fragment } from 'react';
|
|
7
7
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Pagination component to navigate through pages of data.
|
|
11
|
+
* It displays buttons for navigating to the first, previous, next, and last pages,
|
|
12
|
+
* as well as buttons for specific page numbers based on the provided ranges.
|
|
13
|
+
* The component supports a minimal view that shows the current page and total pages.
|
|
14
|
+
* It uses memoization to optimize rendering performance.
|
|
15
|
+
*
|
|
16
|
+
* @param {PaginationProps} props - The properties for the Pagination component.
|
|
17
|
+
* @returns {JSX.Element} The rendered Pagination component.
|
|
18
|
+
*/
|
|
9
19
|
var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
10
20
|
var page = _ref.page,
|
|
11
21
|
ranges = _ref.ranges,
|
package/dist/esm/table/Table.js
CHANGED
|
@@ -126,7 +126,7 @@ var Table = function Table(_ref) {
|
|
|
126
126
|
ref: scrollerRef,
|
|
127
127
|
children: [/*#__PURE__*/jsxs("div", {
|
|
128
128
|
"data-ref": "tableHeader",
|
|
129
|
-
className: "bg-base font-medium sticky top-0 h-8 area-head border-b select-none flex flex-nowrap z-
|
|
129
|
+
className: "bg-base font-medium sticky top-0 h-8 area-head border-b select-none flex flex-nowrap z-2",
|
|
130
130
|
children: [/*#__PURE__*/jsxs("div", {
|
|
131
131
|
className: wrapperStart,
|
|
132
132
|
children: [canExpand && /*#__PURE__*/jsx("div", {
|
|
@@ -180,7 +180,7 @@ var Table = function Table(_ref) {
|
|
|
180
180
|
return "__GROUP__" in data ? /*#__PURE__*/jsxs("div", {
|
|
181
181
|
ref: measureElement,
|
|
182
182
|
"data-index": index,
|
|
183
|
-
className: classNames("px-2 py-1 text-md bg-base border-y border-tint-100 cursor-pointer flex items-center gap-1 z-
|
|
183
|
+
className: classNames("px-2 py-1 text-md bg-base border-y border-tint-100 cursor-pointer flex items-center gap-1 z-1", isActiveSticky(index) && "sticky top-8"),
|
|
184
184
|
role: "none",
|
|
185
185
|
onClick: function onClick() {
|
|
186
186
|
return toggleGroupExpand(data.key);
|
package/dist/esm/table/types.js
CHANGED
|
@@ -27,4 +27,33 @@ var COL_MIN_WIDTH = "3rem";
|
|
|
27
27
|
var COL_MAX_WIDTH = "64rem";
|
|
28
28
|
var COL_DEFAULT_WIDTH = "12rem";
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* TableColumn interface defines the structure of a column in a table.
|
|
32
|
+
* It includes properties for column identification, display options, alignment,
|
|
33
|
+
* visibility, resizing, sorting, filtering, and rendering.
|
|
34
|
+
*
|
|
35
|
+
* @template T - The type of data the column will represent, defaulting to KeyValue.
|
|
36
|
+
* @property {keyof T | string} id - Unique identifier for the column.
|
|
37
|
+
* @property {"string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown"} [dataType] - Data type of the column values.
|
|
38
|
+
* @property {string} [label] - Display label for the column header.
|
|
39
|
+
* @property {string} [tooltip] - Tooltip text for the column header.
|
|
40
|
+
* @property {string} [format] - Format string for displaying the column values.
|
|
41
|
+
* @property {"start" | "center" | "end"} [align] - Text alignment within the column.
|
|
42
|
+
* @property {"start" | "end"} [locked] - Indicates if the column is locked at the start or end.
|
|
43
|
+
* @property {boolean} [hidden] - Whether the column is hidden.
|
|
44
|
+
* @property {boolean} [truncate] - Whether to truncate the text in the column.
|
|
45
|
+
* @property {boolean} [hideable] - Whether the column can be hidden by the user.
|
|
46
|
+
* @property {boolean} [resizable] - Whether the column can be resized by the user.
|
|
47
|
+
* @property {boolean} [sortable] - Whether the column can be sorted.
|
|
48
|
+
* @property {boolean} [filterable] - Whether the column can be filtered.
|
|
49
|
+
* @property {AnyObject} [filter] - Filter criteria for the column.
|
|
50
|
+
* @property {ReactElement[]} [actions] - Array of action elements to be displayed in the column.
|
|
51
|
+
* @property {AnyObject[]} [filterOptions] - Options for filtering the column.
|
|
52
|
+
* @property {string | number} [width] - Width of the column.
|
|
53
|
+
* @property {string | number} [minWidth] - Minimum width of the column.
|
|
54
|
+
* @property {string | number} [maxWidth] - Maximum width of the column.
|
|
55
|
+
* @property {KeyValue} [valueMap] - Mapping of values for the column.
|
|
56
|
+
* @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
|
|
57
|
+
*/
|
|
58
|
+
|
|
30
59
|
export { COL_DEFAULT_WIDTH, COL_MAX_WIDTH, COL_MIN_WIDTH };
|
|
@@ -181,7 +181,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
181
181
|
className: classNames("area-content bg-base overflow-auto")
|
|
182
182
|
}, aria), {}, {
|
|
183
183
|
children: /*#__PURE__*/jsxs("div", {
|
|
184
|
-
className: classNames("
|
|
184
|
+
className: classNames("flex flex-nowrap justify-center gap-2 min-h-full"),
|
|
185
185
|
children: [/*#__PURE__*/jsx("div", {
|
|
186
186
|
className: classNames("box-content", fullWidth && "flex-1", padding === "sm" && "p-1", padding === "md" && "p-2", padding === "lg" && "p-4"),
|
|
187
187
|
style: {
|
|
@@ -200,7 +200,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
200
200
|
var key = _ref3.key,
|
|
201
201
|
index = _ref3.index;
|
|
202
202
|
return /*#__PURE__*/jsx("div", {
|
|
203
|
-
className: "flex
|
|
203
|
+
className: "flex",
|
|
204
204
|
"data-index": index,
|
|
205
205
|
ref: virtualizer.measureElement,
|
|
206
206
|
children: columnMap.map(function (col) {
|
|
@@ -240,6 +240,39 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
|
|
|
240
240
|
};
|
|
241
241
|
_VirtualGallery.displayName = "VirtualGallery";
|
|
242
242
|
var GenericMemo = memo;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* VirtualGallery component provides a virtualized gallery view for displaying a large list of items efficiently.
|
|
246
|
+
* It supports features like fixed columns, loading states, and customizable item rendering.
|
|
247
|
+
* The component uses virtualization to render only the visible items, improving performance for large datasets.
|
|
248
|
+
* It also provides a scroller for easy navigation through the items.
|
|
249
|
+
*
|
|
250
|
+
* @param {VirtualGalleryProps<T>} props - The properties for the VirtualGallery component.
|
|
251
|
+
* @returns {JSX.Element} The rendered VirtualGallery component.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```jsx
|
|
255
|
+
* <VirtualGallery
|
|
256
|
+
* items={items}
|
|
257
|
+
* columns={3}
|
|
258
|
+
* defaultHeight={100}
|
|
259
|
+
* defaultWidth={100}
|
|
260
|
+
* fullWidth={true}
|
|
261
|
+
* onLoadMore={(lastIndex) => console.log("Load more items from index:", lastIndex)}
|
|
262
|
+
* onScroll={(top) => console.log("Scrolled to top:", top)}
|
|
263
|
+
* >
|
|
264
|
+
* {({ item, index, isLast }) => (
|
|
265
|
+
* <div className="gallery-item" key={item.id}>
|
|
266
|
+
* <img src={item.image} alt={item.label} />
|
|
267
|
+
* <p>{item.label}</p>
|
|
268
|
+
* </div>
|
|
269
|
+
* )}
|
|
270
|
+
* </VirtualGallery>
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-virtualgallery--docs}
|
|
274
|
+
* @see {@link https://tanstack.com/docs/react-virtual/latest/overview}
|
|
275
|
+
*/
|
|
243
276
|
var VirtualGallery = GenericMemo(_VirtualGallery);
|
|
244
277
|
|
|
245
278
|
export { VirtualGallery };
|
package/dist/esm/virtual/List.js
CHANGED
|
@@ -168,7 +168,7 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
168
168
|
className: classNames("area-content bg-base overflow-auto")
|
|
169
169
|
}, aria), {}, {
|
|
170
170
|
children: /*#__PURE__*/jsxs("div", {
|
|
171
|
-
className: classNames("
|
|
171
|
+
className: classNames("flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
|
|
172
172
|
children: [/*#__PURE__*/jsxs("div", {
|
|
173
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
174
|
style: {
|
|
@@ -226,6 +226,43 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
226
226
|
};
|
|
227
227
|
_VirtualList.displayName = "VirtualList";
|
|
228
228
|
var GenericMemo = memo;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* VirtualList component for rendering large lists efficiently using virtualization.
|
|
232
|
+
* It supports horizontal and vertical orientations, custom item heights and widths,
|
|
233
|
+
* and provides a scroller for navigating through the list.
|
|
234
|
+
* It also supports loading more items on scroll and provides a way to hilight items.
|
|
235
|
+
* It can be used with a ref to control scrolling and hilighting of items.
|
|
236
|
+
*
|
|
237
|
+
* @param {VirtualListProps<T>} props - The properties for the VirtualList component.
|
|
238
|
+
* @returns {JSX.Element} The rendered VirtualList component.
|
|
239
|
+
* @template T - The type of items in the list, extending AnyObject.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```jsx
|
|
243
|
+
* <VirtualList
|
|
244
|
+
* items={items}
|
|
245
|
+
* children={({ item, index, isLast }) => (
|
|
246
|
+
* <div key={index} className="item">
|
|
247
|
+
* {item.label}
|
|
248
|
+
* </div>
|
|
249
|
+
* )}
|
|
250
|
+
* fullWidth={true}
|
|
251
|
+
* orientation="vertical"
|
|
252
|
+
* defaultHeight={50}
|
|
253
|
+
* onLoadMore={(lastIndex) => console.log("Load more items from index:", lastIndex)}
|
|
254
|
+
* onScroll={(top) => console.log("Scrolled to top:", top)}
|
|
255
|
+
* listRef={virtualListRef}
|
|
256
|
+
* >
|
|
257
|
+
* {({ item, index, isLast }) => (
|
|
258
|
+
* <div className="gallery-item" key={item.id}>
|
|
259
|
+
* <img src={item.image} alt={item.label} />
|
|
260
|
+
* <p>{item.label}</p>
|
|
261
|
+
* </div>
|
|
262
|
+
* )}
|
|
263
|
+
* </VirtualList>
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
229
266
|
var VirtualList = GenericMemo(_VirtualList);
|
|
230
267
|
|
|
231
268
|
export { VirtualList };
|
|
@@ -27,4 +27,26 @@ export interface CheckListProps extends SelectableProps, TestProps {
|
|
|
27
27
|
emptyMessage?: string;
|
|
28
28
|
sortItems?: boolean;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* CheckList component to display a list of selectable items with checkboxes.
|
|
32
|
+
* It supports selection, deselection, and allows for negative selections.
|
|
33
|
+
*
|
|
34
|
+
* @param {CheckListProps} props - The properties for the CheckList component.
|
|
35
|
+
* @returns {JSX.Element} The rendered CheckList component.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```jsx
|
|
39
|
+
* <CheckList
|
|
40
|
+
* items={[
|
|
41
|
+
* { id: "1", label: "Item 1", icon: "icon1" },
|
|
42
|
+
* { id: "2", label: "Item 2", icon: "icon2", badge: { text: "New" } },
|
|
43
|
+
* ]}
|
|
44
|
+
* maxCount={5}
|
|
45
|
+
* allowNegative={true}
|
|
46
|
+
* emptyMessage="No items available"
|
|
47
|
+
* onChange={(selectedItems) => console.log(selectedItems)}
|
|
48
|
+
* onClick={(itemId, isNegative) => console.log(itemId, isNegative)}
|
|
49
|
+
* />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
30
52
|
export declare const CheckList: FC<CheckListProps>;
|
|
@@ -36,5 +36,33 @@ export interface HistogramProps extends TestProps {
|
|
|
36
36
|
*/
|
|
37
37
|
onClick?: (id: string, negative?: true) => void;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Histogram component displays a bar chart of items with counts.
|
|
41
|
+
* It allows users to visualize the distribution of counts across different items.
|
|
42
|
+
* The component supports sorting, custom colors, and click handling for each item.
|
|
43
|
+
* It also provides an empty state when there are no items to display.
|
|
44
|
+
*
|
|
45
|
+
* @param {HistogramProps} props - The properties for the Histogram component.
|
|
46
|
+
* @returns {JSX.Element} - The rendered Histogram component.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```jsx
|
|
50
|
+
* <Histogram
|
|
51
|
+
* items={[
|
|
52
|
+
* { id: "1", label: "Item 1", count: 10 },
|
|
53
|
+
* { id: "2", label: "Item 2", count: 20 },
|
|
54
|
+
* { id: "3", label: "Item 3", count: 5, disabled: true },
|
|
55
|
+
* ]}
|
|
56
|
+
* total={30}
|
|
57
|
+
* color="primary-500"
|
|
58
|
+
* sortBy="count"
|
|
59
|
+
* emptyTitle="No Data Available"
|
|
60
|
+
* emptyMessage="Please check back later."
|
|
61
|
+
* onClick={(id, negative) => console.log(`Clicked on ${id}`, negative ? "Negative" : "Positive")}
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-histogram--docs}
|
|
66
|
+
*/
|
|
39
67
|
export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, ...aria }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
68
|
export {};
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to filter a list of items based on a query.
|
|
3
|
+
* It provides a way to search through the items and returns the filtered list.
|
|
4
|
+
* The hook uses a deferred value to optimize performance during transitions.
|
|
5
|
+
* It also allows for a custom matcher function to define how items should be matched against the query.
|
|
6
|
+
*
|
|
7
|
+
* @param items - The list of items to filter.
|
|
8
|
+
* @param matcher - An optional function to match items against the query.
|
|
9
|
+
* @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```jsx
|
|
13
|
+
* useFilteredList(items, (item, query) => {
|
|
14
|
+
* return item.name.includes(query);
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
|
|
19
|
+
*/
|
|
20
|
+
export declare const useFilteredList: <T extends AnyObject = KeyValue, Q extends AnyObject = string>(items: T[], matcher?: (item: T, query: Q) => boolean) => {
|
|
3
21
|
onSearch: import("react").Dispatch<import("react").SetStateAction<Q | undefined>>;
|
|
4
22
|
query: Q | undefined;
|
|
5
23
|
filteredList: T[];
|
|
@@ -16,6 +16,25 @@ export interface PaginationOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
onChange?: (page: number) => void;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Custom hook to manage pagination state and logic.
|
|
21
|
+
* It calculates the total number of pages, generates page ranges,
|
|
22
|
+
* and provides a way to change the current page.
|
|
23
|
+
* It also handles the transition of page changes to optimize performance.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The pagination options including total records, current page, records per page, and change handler.
|
|
26
|
+
* @returns An object containing the current page, total pages, head label, ranges for pagination pills, and a function to change the page.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```jsx
|
|
30
|
+
* const { page, totalPages, headLabel, ranges, onPageChange } = usePagination({
|
|
31
|
+
* totalRecords: 100,
|
|
32
|
+
* currentPage: 0,
|
|
33
|
+
* perPage: 10,
|
|
34
|
+
* onChange: (newPage) => console.log("Page changed to:", newPage),
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
19
38
|
export declare const usePagination: ({ totalRecords, currentPage, perPage, onChange, }: PaginationOptions) => {
|
|
20
39
|
page: number;
|
|
21
40
|
totalPages: number;
|
|
@@ -22,6 +22,35 @@ export interface SelectableProps {
|
|
|
22
22
|
*/
|
|
23
23
|
onClick?: (id: string, isNegative: boolean) => void;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Custom hook to manage selection of items in a list.
|
|
27
|
+
* It allows toggling selection state of items, handling both selected and non-selected states.
|
|
28
|
+
* The hook maintains a selection state and provides a function to toggle the selection of items.
|
|
29
|
+
* It also supports callbacks for when the selection changes or when an item is clicked.
|
|
30
|
+
*
|
|
31
|
+
* @param items - The list of items to manage selection for.
|
|
32
|
+
* @param selected - An array of item IDs that are currently selected.
|
|
33
|
+
* @param nonselected - An array of item IDs that are currently non-selected.
|
|
34
|
+
* @param onChange - Callback function that is called when the selection changes.
|
|
35
|
+
* @param onClick - Callback function that is called when an item is clicked.
|
|
36
|
+
* @returns An object containing the current selection state and a function to toggle selection of items.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```jsx
|
|
40
|
+
* const { selection, toggleSelection } = useSelectableList({
|
|
41
|
+
* items: [{ id: '1', label: 'Item 1' }, { id: '2', label: 'Item 2' }],
|
|
42
|
+
* selected: ['1'],
|
|
43
|
+
* nonselected: ['2'],
|
|
44
|
+
* onChange: (selectedIds, nonSelectedIds) => {
|
|
45
|
+
* console.log('Selected:', selectedIds);
|
|
46
|
+
* console.log('Non-selected:', nonSelectedIds);
|
|
47
|
+
* },
|
|
48
|
+
* onClick: (id, isNegative) => {
|
|
49
|
+
* console.log(`Item ${id} clicked, isNegative: ${isNegative}`);
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
25
54
|
export declare const useSelectableList: ({ items, selected, nonselected, onChange, onClick, }: SelectableProps) => {
|
|
26
55
|
selection: KeyValue<number>;
|
|
27
56
|
toggleSelection: (id: string, isNegative?: boolean) => void;
|
|
@@ -55,4 +55,30 @@ export interface JsonViewProps<T> extends CssProp {
|
|
|
55
55
|
*/
|
|
56
56
|
formatter?: (path?: string, value?: AnyObject) => string | JSX.Element | undefined;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* JsonViewer component to display JSON data in a structured format.
|
|
60
|
+
* It supports inline display, property filtering, and custom formatting.
|
|
61
|
+
* The component can handle nested objects and arrays, displaying them in a tree-like structure.
|
|
62
|
+
* It also provides options for copying values and filtering properties.
|
|
63
|
+
*
|
|
64
|
+
* @param {JsonViewProps<T>} props - The properties for the JsonViewer component.
|
|
65
|
+
* @returns {JSX.Element} The rendered JsonViewer component.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```jsx
|
|
69
|
+
* <JsonViewer
|
|
70
|
+
* json={{ name: "John", age: 30, address: { city: "New York", zip: "10001" } }}
|
|
71
|
+
* copy={true}
|
|
72
|
+
* filters={true}
|
|
73
|
+
* propertyScheme={{ date: ["createdAt"], phone: ["contact"] }}
|
|
74
|
+
* inline={true}
|
|
75
|
+
* labelWidth="25%"
|
|
76
|
+
* formatter={(path, value) => (path === "age" ? `${value} years` : value)}
|
|
77
|
+
* labeler={(path) => path.replace(/_/g, " ").toUpperCase()}
|
|
78
|
+
* onFilter={(path, value, negate) => console.log(`Filter ${negate ? "negate" : ""} on ${path}:`, value)}
|
|
79
|
+
* />
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-jsonviewer--docs}
|
|
83
|
+
*/
|
|
84
|
+
export declare const JsonViewer: <T extends KeyValue = KeyValue>({ className, json, copy, propertyScheme, filters, inline, labelWidth, formatter, labeler, onFilter, emptyMessage, showPropertyTree, ...rest }: JsonViewProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -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,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;
|
|
@@ -3,6 +3,34 @@ 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
|
+
/**
|
|
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
|
+
*/
|
|
6
34
|
export interface TableColumn<T = KeyValue> extends CssProp, IconProps, TestProps {
|
|
7
35
|
id: keyof T | string;
|
|
8
36
|
label?: string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
interface DataState<T = KeyValue> {
|
|
3
2
|
data: T[];
|
|
4
3
|
items: T[];
|
|
@@ -8,7 +7,7 @@ interface DataState<T = KeyValue> {
|
|
|
8
7
|
checked: AnyObject[];
|
|
9
8
|
allChecked: 0 | 1 | 2;
|
|
10
9
|
}
|
|
11
|
-
export declare const useVirtualTable: <T extends KeyValue
|
|
10
|
+
export declare const useVirtualTable: <T extends KeyValue = KeyValue>(data: T[], options: {
|
|
12
11
|
checked?: AnyObject[];
|
|
13
12
|
keyProperty: keyof T;
|
|
14
13
|
groupProperty?: keyof T;
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { type InternalNode, type TreePanelProps } from "./types";
|
|
2
|
-
export declare const useTree: <T extends KeyValue
|
|
2
|
+
export declare const useTree: <T extends KeyValue>({ items, checked, selected, sorter, matcher, onLoad, onQuery, onSelect, onChecked, defaultExpanded, onExpandToggle, }: Partial<TreePanelProps<T>>) => {
|
|
3
3
|
tree: InternalNode[];
|
|
4
4
|
toggleExpand: (id: string) => void;
|
|
5
5
|
expandAll: () => void;
|
|
@@ -8,7 +8,7 @@ export declare const useTree: <T extends KeyValue<any>>({ items, checked, select
|
|
|
8
8
|
select: (id: string) => void;
|
|
9
9
|
expand: (id: string) => void;
|
|
10
10
|
onFilter: {
|
|
11
|
-
(...args:
|
|
11
|
+
(...args: AnyObject): void;
|
|
12
12
|
cancel(): void;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -57,6 +57,38 @@ export interface VirtualGalleryProps<T> extends TestProps {
|
|
|
57
57
|
*/
|
|
58
58
|
onScroll?: (top: number) => void;
|
|
59
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
|
+
*/
|
|
60
92
|
export declare const VirtualGallery: {
|
|
61
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;
|
|
62
94
|
displayName: string;
|
|
@@ -57,6 +57,42 @@ export interface VirtualListProps<T> extends TestProps {
|
|
|
57
57
|
*/
|
|
58
58
|
onScroll?: (top: number) => void;
|
|
59
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
|
+
*/
|
|
60
96
|
export declare const VirtualList: {
|
|
61
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;
|
|
62
98
|
displayName: string;
|