@react-fabric/data 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  3. package/dist/cjs/histogram/Histogram.js +89 -0
  4. package/dist/cjs/histogram/Histogram.module.css +1 -0
  5. package/dist/cjs/hooks/useFilteredList.js +56 -0
  6. package/dist/cjs/hooks/usePagination.js +85 -0
  7. package/dist/cjs/i18n/ar.json.js +56 -0
  8. package/dist/cjs/i18n/en.json.js +56 -0
  9. package/dist/cjs/i18n/index.js +33 -0
  10. package/dist/cjs/index.js +24 -0
  11. package/dist/cjs/json/JsonViewer.js +246 -0
  12. package/dist/cjs/pagination/Pagination.js +100 -0
  13. package/dist/cjs/table/BodyCell.js +47 -0
  14. package/dist/cjs/table/HeaderCell.js +79 -0
  15. package/dist/cjs/table/Table.js +133 -0
  16. package/dist/cjs/table/useTableColumns.js +26 -0
  17. package/dist/cjs/table/useVirtualTable.js +56 -0
  18. package/dist/cjs/tree/TreeNode.js +107 -0
  19. package/dist/cjs/tree/TreePanel.js +136 -0
  20. package/dist/cjs/tree/types.js +30 -0
  21. package/dist/cjs/tree/useTree.js +181 -0
  22. package/dist/cjs/tree/utils.js +145 -0
  23. package/dist/cjs/virtual/Gallery.js +229 -0
  24. package/dist/cjs/virtual/List.js +218 -0
  25. package/dist/cjs/virtual/Scroller.js +77 -0
  26. package/dist/esm/histogram/Histogram.js +89 -0
  27. package/dist/esm/histogram/Histogram.module.css +1 -0
  28. package/dist/esm/hooks/useFilteredList.js +56 -0
  29. package/dist/esm/hooks/usePagination.js +85 -0
  30. package/dist/esm/i18n/ar.json.js +47 -0
  31. package/dist/esm/i18n/en.json.js +47 -0
  32. package/dist/esm/i18n/index.js +33 -0
  33. package/dist/esm/index.js +12 -0
  34. package/dist/esm/json/JsonViewer.js +246 -0
  35. package/dist/esm/pagination/Pagination.js +100 -0
  36. package/dist/esm/table/BodyCell.js +47 -0
  37. package/dist/esm/table/HeaderCell.js +79 -0
  38. package/dist/esm/table/Table.js +133 -0
  39. package/dist/esm/table/useTableColumns.js +26 -0
  40. package/dist/esm/table/useVirtualTable.js +56 -0
  41. package/dist/esm/tree/TreeNode.js +107 -0
  42. package/dist/esm/tree/TreePanel.js +136 -0
  43. package/dist/esm/tree/types.js +29 -0
  44. package/dist/esm/tree/useTree.js +181 -0
  45. package/dist/esm/tree/utils.js +140 -0
  46. package/dist/esm/virtual/Gallery.js +229 -0
  47. package/dist/esm/virtual/List.js +218 -0
  48. package/dist/esm/virtual/Scroller.js +77 -0
  49. package/dist/types/histogram/Histogram.d.ts +41 -0
  50. package/dist/types/hooks/useFilteredList.d.ts +7 -0
  51. package/dist/types/hooks/usePagination.d.ts +25 -0
  52. package/dist/types/i18n/index.d.ts +1 -0
  53. package/dist/types/index.d.ts +10 -0
  54. package/dist/types/json/JsonViewer.d.ts +59 -0
  55. package/dist/types/pagination/Pagination.d.ts +24 -0
  56. package/dist/types/table/BodyCell.d.ts +5 -0
  57. package/dist/types/table/HeaderCell.d.ts +2 -0
  58. package/dist/types/table/Table.d.ts +2 -0
  59. package/dist/types/table/types.d.ts +26 -0
  60. package/dist/types/table/useTableColumns.d.ts +8 -0
  61. package/dist/types/table/useVirtualTable.d.ts +8 -0
  62. package/dist/types/tree/TreeNode.d.ts +2 -0
  63. package/dist/types/tree/TreePanel.d.ts +2 -0
  64. package/dist/types/tree/types.d.ts +138 -0
  65. package/dist/types/tree/useTree.d.ts +20 -0
  66. package/dist/types/tree/utils.d.ts +10 -0
  67. package/dist/types/virtual/Gallery.d.ts +55 -0
  68. package/dist/types/virtual/List.d.ts +59 -0
  69. package/dist/types/virtual/Scroller.d.ts +8 -0
  70. package/package.json +55 -0
  71. package/src/histogram/Histogram.module.css +57 -0
  72. package/src/histogram/Histogram.tsx +176 -0
  73. package/src/hooks/useFilteredList.tsx +78 -0
  74. package/src/hooks/usePagination.tsx +135 -0
  75. package/src/i18n/ar.json +36 -0
  76. package/src/i18n/en.json +36 -0
  77. package/src/i18n/index.ts +28 -0
  78. package/src/index.ts +35 -0
  79. package/src/json/JsonViewer.tsx +381 -0
  80. package/src/pagination/Pagination.tsx +157 -0
  81. package/src/table/BodyCell.tsx +54 -0
  82. package/src/table/HeaderCell.tsx +70 -0
  83. package/src/table/Table.tsx +143 -0
  84. package/src/table/types.ts +65 -0
  85. package/src/table/useTableColumns.ts +52 -0
  86. package/src/table/useVirtualTable.ts +54 -0
  87. package/src/tree/TreeNode.tsx +163 -0
  88. package/src/tree/TreePanel.tsx +157 -0
  89. package/src/tree/types.ts +181 -0
  90. package/src/tree/useTree.ts +227 -0
  91. package/src/tree/utils.ts +185 -0
  92. package/src/virtual/Gallery.tsx +349 -0
  93. package/src/virtual/List.tsx +351 -0
  94. package/src/virtual/Scroller.tsx +81 -0
@@ -0,0 +1,218 @@
1
+ 'use client';
2
+
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
+ import { useDebounce, Skeleton } from '@react-fabric/core';
5
+ import { debounce } from '@react-fabric/utilities';
6
+ import { useVirtualizer } from '@tanstack/react-virtual';
7
+ import classNames from 'classnames';
8
+ import memoizeOne from 'memoize-one';
9
+ import { useDeferredValue, useMemo, useRef, useEffect, useCallback, useState, useLayoutEffect, useImperativeHandle, memo } from 'react';
10
+ import { Scroller } from './Scroller.js';
11
+ import { jsx, jsxs } from 'react/jsx-runtime';
12
+
13
+ var createItemList = memoizeOne(function (items) {
14
+ return items;
15
+ });
16
+ var _VirtualList = function _VirtualList(_ref) {
17
+ var _virtualItems$3, _virtualItems$4;
18
+ var items = _ref.items,
19
+ children = _ref.children,
20
+ fullWidth = _ref.fullWidth,
21
+ _ref$padding = _ref.padding,
22
+ padding = _ref$padding === void 0 ? "md" : _ref$padding,
23
+ _ref$orientation = _ref.orientation,
24
+ orientation = _ref$orientation === void 0 ? "vertical" : _ref$orientation,
25
+ _ref$defaultHeight = _ref.defaultHeight,
26
+ height = _ref$defaultHeight === void 0 ? 48 : _ref$defaultHeight,
27
+ _ref$defaultWidth = _ref.defaultWidth,
28
+ width = _ref$defaultWidth === void 0 ? 48 : _ref$defaultWidth,
29
+ hideScroller = _ref.hideScroller,
30
+ initialScroll = _ref.initialScroll,
31
+ loading = _ref.loading,
32
+ onLoadMore = _ref.onLoadMore,
33
+ onScroll = _ref.onScroll,
34
+ listRef = _ref.listRef;
35
+ var count = useDeferredValue(items.length);
36
+ var extraSize = useMemo(function () {
37
+ return onLoadMore ? 64 : 0;
38
+ }, [onLoadMore]);
39
+ var itemList = createItemList(items.map(function (item, idx) {
40
+ return {
41
+ index: idx,
42
+ data: item,
43
+ isLast: idx + 1 === items.length
44
+ };
45
+ }));
46
+ var scrollerRef = useRef(null);
47
+ var virtualizer = useVirtualizer({
48
+ count: count,
49
+ horizontal: orientation === "horizontal",
50
+ getScrollElement: function getScrollElement() {
51
+ return scrollerRef.current;
52
+ },
53
+ estimateSize: function estimateSize() {
54
+ return orientation === "horizontal" ? width : height;
55
+ }
56
+ });
57
+ var virtualItems = virtualizer.getVirtualItems();
58
+ var currentIndex = useRef(0);
59
+ useEffect(function () {
60
+ var _virtualItems$1$index, _virtualItems$;
61
+ currentIndex.current = (_virtualItems$1$index = (_virtualItems$ = virtualItems[1]) === null || _virtualItems$ === void 0 ? void 0 : _virtualItems$.index) !== null && _virtualItems$1$index !== void 0 ? _virtualItems$1$index : 0;
62
+ if (scrollerRef.current && virtualItems[0] && scrollerRef.current.scrollTop < virtualItems[0].size) currentIndex.current = 0;
63
+ }, [virtualItems]);
64
+ var calculateActiveScroll = useCallback(function () {
65
+ var _scrollerRef$current;
66
+ var _ref2 = (_scrollerRef$current = scrollerRef.current) !== null && _scrollerRef$current !== void 0 ? _scrollerRef$current : {},
67
+ _ref2$scrollTop = _ref2.scrollTop,
68
+ scrollTop = _ref2$scrollTop === void 0 ? 0 : _ref2$scrollTop,
69
+ _ref2$scrollLeft = _ref2.scrollLeft,
70
+ scrollLeft = _ref2$scrollLeft === void 0 ? 0 : _ref2$scrollLeft,
71
+ _ref2$scrollWidth = _ref2.scrollWidth,
72
+ scrollWidth = _ref2$scrollWidth === void 0 ? 0 : _ref2$scrollWidth,
73
+ _ref2$scrollHeight = _ref2.scrollHeight,
74
+ scrollHeight = _ref2$scrollHeight === void 0 ? 0 : _ref2$scrollHeight,
75
+ _ref2$offsetWidth = _ref2.offsetWidth,
76
+ offsetWidth = _ref2$offsetWidth === void 0 ? 0 : _ref2$offsetWidth,
77
+ _ref2$offsetHeight = _ref2.offsetHeight,
78
+ offsetHeight = _ref2$offsetHeight === void 0 ? 0 : _ref2$offsetHeight;
79
+ if (orientation === "vertical") {
80
+ if (scrollHeight === offsetHeight) return 0;
81
+ if (scrollTop === 0) return 1;
82
+ if (scrollTop >= scrollHeight - offsetHeight - extraSize * 2) return 2;
83
+ }
84
+ if (orientation === "horizontal") {
85
+ if (scrollWidth === offsetWidth) return 0;
86
+ if (Math.abs(scrollLeft) === 0) return 1;
87
+ if (Math.abs(scrollLeft) >= scrollWidth - offsetWidth - extraSize * 2) return 2;
88
+ }
89
+ return 3;
90
+ }, [orientation]);
91
+ var _useState = useState(0),
92
+ _useState2 = _slicedToArray(_useState, 2),
93
+ scrollActive = _useState2[0],
94
+ setScrollActive = _useState2[1];
95
+ var fireScrollEvent = useDebounce(function () {
96
+ return onScroll === null || onScroll === void 0 ? void 0 : onScroll(currentIndex.current);
97
+ }, [onScroll]);
98
+ var handleScroll = useCallback(function () {
99
+ setScrollActive(calculateActiveScroll());
100
+ fireScrollEvent();
101
+ }, [orientation, onLoadMore]);
102
+ useEffect(function () {
103
+ setScrollActive(calculateActiveScroll());
104
+ }, [itemList, calculateActiveScroll]);
105
+ useEffect(function () {
106
+ var db = debounce(function () {
107
+ var lastItem = virtualItems === null || virtualItems === void 0 ? void 0 : virtualItems.slice(-1).pop();
108
+ if (lastItem && !loading && lastItem.index === count - 1) onLoadMore === null || onLoadMore === void 0 || onLoadMore();
109
+ });
110
+ db();
111
+ return function () {
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) {
119
+ var db = debounce(onLoadMore);
120
+ db(firstItem);
121
+ return function () {
122
+ return db.cancel();
123
+ };
124
+ }
125
+ }, [onLoadMore, items, virtualItems, count]);
126
+ useLayoutEffect(function () {
127
+ setTimeout(function () {
128
+ initialScroll && virtualizer.scrollToIndex(initialScroll, {
129
+ align: "start"
130
+ });
131
+ }, 100);
132
+ }, []);
133
+ useImperativeHandle(listRef, function () {
134
+ return {
135
+ scrollToItem: function scrollToItem(index) {
136
+ virtualizer.scrollToIndex(index, {
137
+ align: "start"
138
+ });
139
+ },
140
+ hilight: function hilight(index) {
141
+ var _scrollerRef$current2;
142
+ (_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
+ virtualizer.scrollToIndex(Math.floor(index), {
144
+ align: "start"
145
+ });
146
+ setTimeout(function () {
147
+ var _scrollerRef$current3;
148
+ (_scrollerRef$current3 = scrollerRef.current) === null || _scrollerRef$current3 === void 0 || (_scrollerRef$current3 = _scrollerRef$current3.querySelector("[data-index=\"".concat(index, "\"]"))) === null || _scrollerRef$current3 === void 0 || _scrollerRef$current3.classList.add("hilight", "ring-1");
149
+ }, 100);
150
+ },
151
+ unhilight: function unhilight() {
152
+ var _scrollerRef$current4;
153
+ (_scrollerRef$current4 = scrollerRef.current) === null || _scrollerRef$current4 === void 0 || (_scrollerRef$current4 = _scrollerRef$current4.querySelector(".hilight")) === null || _scrollerRef$current4 === void 0 || _scrollerRef$current4.classList.remove("hilight", "ring-1");
154
+ }
155
+ };
156
+ }, [virtualizer]);
157
+ return /*#__PURE__*/jsx("div", {
158
+ ref: scrollerRef,
159
+ onScroll: handleScroll,
160
+ className: classNames("area-content bg-base overflow-auto contain-strict"),
161
+ children: /*#__PURE__*/jsxs("div", {
162
+ className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
163
+ children: [/*#__PURE__*/jsxs("div", {
164
+ 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"),
165
+ children: [/*#__PURE__*/jsxs("div", {
166
+ style: orientation === "vertical" ? {
167
+ height: virtualizer.getTotalSize()
168
+ } : {
169
+ width: virtualizer.getTotalSize()
170
+ },
171
+ children: [/*#__PURE__*/jsx("div", {
172
+ style: orientation === "vertical" ? {
173
+ height: (_virtualItems$3 = virtualItems[0]) === null || _virtualItems$3 === void 0 ? void 0 : _virtualItems$3.start
174
+ } : {
175
+ width: (_virtualItems$4 = virtualItems[0]) === null || _virtualItems$4 === void 0 ? void 0 : _virtualItems$4.start,
176
+ display: "inline-block"
177
+ }
178
+ }), virtualItems.map(function (_ref3) {
179
+ var key = _ref3.key,
180
+ index = _ref3.index;
181
+ return /*#__PURE__*/jsx("div", {
182
+ "data-index": index,
183
+ ref: virtualizer.measureElement,
184
+ className: classNames("rounded-capped", orientation === "horizontal" ? "inline-grid" : "grid"),
185
+ children: children(itemList[index])
186
+ }, key);
187
+ })]
188
+ }), onLoadMore && /*#__PURE__*/jsx("div", {
189
+ className: orientation === "horizontal" ? "min-w-16" : "h-16",
190
+ children: loading && /*#__PURE__*/jsx(Skeleton, {})
191
+ })]
192
+ }), !hideScroller && /*#__PURE__*/jsx("div", {
193
+ className: classNames(orientation === "vertical" && "self-end sticky bottom-2", orientation === "horizontal" && "self-end sticky end-2"),
194
+ children: /*#__PURE__*/jsx(Scroller, {
195
+ vertical: orientation === "vertical",
196
+ scrollActive: scrollActive,
197
+ onStart: function onStart() {
198
+ return virtualizer.scrollToIndex(0);
199
+ },
200
+ onPrevious: function onPrevious() {
201
+ return scrollerRef.current && virtualizer.scrollBy(-(orientation === "vertical" ? scrollerRef.current.offsetHeight : scrollerRef.current.offsetWidth));
202
+ },
203
+ onNext: function onNext() {
204
+ return scrollerRef.current && virtualizer.scrollBy(orientation === "vertical" ? scrollerRef.current.offsetHeight : scrollerRef.current.offsetWidth);
205
+ },
206
+ onEnd: function onEnd() {
207
+ return virtualizer.scrollToIndex(count - 1);
208
+ }
209
+ })
210
+ })]
211
+ })
212
+ });
213
+ };
214
+ _VirtualList.displayName = "VirtualList";
215
+ var GenericMemo = memo;
216
+ var VirtualList = GenericMemo(_VirtualList);
217
+
218
+ export { VirtualList };
@@ -0,0 +1,77 @@
1
+ 'use client';
2
+
3
+ import { ButtonGroup, Button, CoreIcons } from '@react-fabric/core';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ /*
7
+ * React Fabric
8
+ * @version: 1.0.0
9
+ *
10
+ *
11
+ * The MIT License (MIT)
12
+ * Copyright (c) 2024 Adarsh Pastakia
13
+ *
14
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
15
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
16
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
18
+ * subject to the following conditions:
19
+ *
20
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
21
+ * portions of the Software.
22
+ *
23
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
24
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ */
28
+
29
+ var Scroller = function Scroller(_ref) {
30
+ var _ref$vertical = _ref.vertical,
31
+ vertical = _ref$vertical === void 0 ? true : _ref$vertical,
32
+ scrollActive = _ref.scrollActive,
33
+ onStart = _ref.onStart,
34
+ onEnd = _ref.onEnd,
35
+ onPrevious = _ref.onPrevious,
36
+ onNext = _ref.onNext;
37
+ return /*#__PURE__*/jsxs(ButtonGroup, {
38
+ vertical: vertical,
39
+ variant: "link",
40
+ className: "outline",
41
+ children: [/*#__PURE__*/jsx(Button, {
42
+ rtlFlip: true,
43
+ size: "sm",
44
+ variant: "link",
45
+ "aria-label": "scroll to top",
46
+ icon: vertical ? CoreIcons.chevronsUp : CoreIcons.chevronsLeft,
47
+ disabled: (scrollActive & 2) === 0,
48
+ onClick: onStart
49
+ }), /*#__PURE__*/jsx(Button, {
50
+ rtlFlip: true,
51
+ size: "sm",
52
+ variant: "link",
53
+ "aria-label": "scroll up",
54
+ icon: vertical ? CoreIcons.chevronUp : CoreIcons.chevronLeft,
55
+ disabled: (scrollActive & 2) === 0,
56
+ onClick: onPrevious
57
+ }), /*#__PURE__*/jsx(Button, {
58
+ rtlFlip: true,
59
+ size: "sm",
60
+ variant: "link",
61
+ "aria-label": "scroll down",
62
+ icon: vertical ? CoreIcons.chevronDown : CoreIcons.chevronRight,
63
+ disabled: scrollActive % 2 === 0,
64
+ onClick: onNext
65
+ }), /*#__PURE__*/jsx(Button, {
66
+ rtlFlip: true,
67
+ size: "sm",
68
+ variant: "link",
69
+ "aria-label": "scroll to bottom",
70
+ icon: vertical ? CoreIcons.chevronsDown : CoreIcons.chevronsRight,
71
+ disabled: scrollActive % 2 === 0,
72
+ onClick: onEnd
73
+ })]
74
+ });
75
+ };
76
+
77
+ export { Scroller };
@@ -0,0 +1,41 @@
1
+ /// <reference types="react" />
2
+ import { type ColorType, type PaletteType } from "@react-fabric/core/dist/types/types";
3
+ interface HistogramItem {
4
+ id: string;
5
+ label: string;
6
+ count: number;
7
+ total?: number;
8
+ disabled?: boolean;
9
+ }
10
+ export interface HistogramProps {
11
+ /**
12
+ * histogram items list
13
+ */
14
+ items: HistogramItem[];
15
+ /**
16
+ * total count
17
+ */
18
+ total?: number;
19
+ /**
20
+ * histogram bar color
21
+ */
22
+ color?: ColorType | PaletteType;
23
+ /**
24
+ * sorted list
25
+ */
26
+ sortBy?: "label" | "count";
27
+ /**
28
+ * title when histo list is empty
29
+ */
30
+ emptyTitle?: string | JSX.Element;
31
+ /**
32
+ * message when histo list is empty
33
+ */
34
+ emptyMessage?: string | JSX.Element;
35
+ /**
36
+ * handle histo click
37
+ */
38
+ onClick?: (id: string, negative?: true) => void;
39
+ }
40
+ export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
41
+ export {};
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare const useFilteredList: <T extends unknown = KeyValue<any>, Q extends unknown = string>(items: T[], matcher?: (item: T, query: Q) => boolean) => {
3
+ onSearch: import("react").Dispatch<import("react").SetStateAction<Q | undefined>>;
4
+ query: Q | undefined;
5
+ filteredList: T[];
6
+ isSearching: boolean;
7
+ };
@@ -0,0 +1,25 @@
1
+ export interface PaginationOptions {
2
+ /**
3
+ * total record count
4
+ */
5
+ totalRecords: number;
6
+ /**
7
+ * current page (default 0)
8
+ */
9
+ currentPage?: number;
10
+ /**
11
+ * records per page
12
+ */
13
+ perPage?: number;
14
+ /**
15
+ * pagination change handler
16
+ */
17
+ onChange?: (page: number) => void;
18
+ }
19
+ export declare const usePagination: ({ totalRecords, currentPage, perPage, onChange, }: PaginationOptions) => {
20
+ page: number;
21
+ totalPages: number;
22
+ headLabel: import("react/jsx-runtime").JSX.Element;
23
+ ranges: number[][];
24
+ onPageChange: (page: number) => void;
25
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import "./i18n";
2
+ export { Histogram } from "./histogram/Histogram";
3
+ export { JsonViewer } from "./json/JsonViewer";
4
+ export { Pagination } from "./pagination/Pagination";
5
+ export { Table } from "./table/Table";
6
+ export { TreePanel } from "./tree/TreePanel";
7
+ export { VirtualGallery, type VirtualGalleryRef } from "./virtual/Gallery";
8
+ export { VirtualList, type VirtualListRef } from "./virtual/List";
9
+ export * from "./hooks/useFilteredList";
10
+ export * from "./hooks/usePagination";
@@ -0,0 +1,59 @@
1
+ /// <reference types="react" />
2
+ import { type CssProp } from "@react-fabric/core/dist/types/types";
3
+ export interface JsonViewProps<T> extends CssProp {
4
+ /**
5
+ * json value
6
+ */
7
+ json: T;
8
+ /**
9
+ * display inline
10
+ */
11
+ inline?: boolean;
12
+ /**
13
+ * label fixed width when using inline
14
+ */
15
+ labelWidth?: number | string;
16
+ /**
17
+ * display object properties as tree
18
+ * @default true
19
+ */
20
+ showPropertyTree?: boolean;
21
+ /**
22
+ * properties to format as dates
23
+ * (default format applied to property name containing `date` | `time`)
24
+ */
25
+ propertyScheme?: {
26
+ boolean?: string[];
27
+ date?: string[];
28
+ time?: string[];
29
+ number?: string[];
30
+ bytes?: string[];
31
+ percent?: string[];
32
+ phone?: string[];
33
+ };
34
+ /**
35
+ * enable value copy
36
+ */
37
+ copy?: true | string[];
38
+ /**
39
+ * enable filter callbacks
40
+ */
41
+ filters?: true | string[];
42
+ /**
43
+ * message for empty json
44
+ */
45
+ emptyMessage?: string;
46
+ /**
47
+ * on filter callback
48
+ */
49
+ onFilter?: (path: string, value: AnyObject, negate: boolean) => void;
50
+ /**
51
+ * render function for custom label display
52
+ */
53
+ labeler?: (path: string) => string | undefined;
54
+ /**
55
+ * render function for custom value display
56
+ */
57
+ formatter?: (path?: string, value?: AnyObject) => string | JSX.Element | undefined;
58
+ }
59
+ export declare const JsonViewer: <T extends KeyValue<any> = KeyValue<any>>({ className, json, copy, propertyScheme, filters, inline, labelWidth, formatter, labeler, onFilter, emptyMessage, showPropertyTree, ...rest }: JsonViewProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ export interface PaginationProps {
3
+ /**
4
+ * currrent page number
5
+ */
6
+ page: number;
7
+ /**
8
+ * total page count
9
+ */
10
+ totalPages: number;
11
+ /**
12
+ * pagination sections [start, mid, end]
13
+ */
14
+ ranges: number[][];
15
+ /**
16
+ * minimal view
17
+ */
18
+ minimal?: boolean;
19
+ /**
20
+ * page change handler
21
+ */
22
+ onPageChange: (page: number) => void;
23
+ }
24
+ export declare const Pagination: import("react").MemoExoticComponent<({ page, ranges, totalPages, minimal, onPageChange }: PaginationProps) => import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1,5 @@
1
+ import { type ColumnType } from "./types";
2
+ export declare const BodyCell: ({ column, item, }: {
3
+ column: ColumnType;
4
+ item: KeyValue;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { type ColumnType } from "./types";
2
+ export declare const HeaderCell: ({ label, icon, iconBg, iconColor, rtlFlip, actions, locked, resizable, width, maxWidth, minWidth, }: ColumnType) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { type TableProps } from "./types";
2
+ export declare const Table: <T extends KeyValue<any> = KeyValue<any>>({ data, columns, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { type CssProp, type IconProps, type TestProps } from "@react-fabric/core/dist/types/types";
2
+ import { type ReactElement } from "react";
3
+ export interface ColumnType<T = KeyValue> extends CssProp, IconProps, TestProps {
4
+ id: keyof T;
5
+ label?: string;
6
+ actions?: ReactElement;
7
+ align?: "start" | "center" | "end";
8
+ locked?: "start" | "end";
9
+ hidden?: boolean;
10
+ hideable?: boolean;
11
+ resizable?: boolean;
12
+ sortable?: boolean;
13
+ filterable?: boolean;
14
+ filterList?: AnyObject[];
15
+ width?: string | number;
16
+ minWidth?: string | number;
17
+ maxWidth?: string | number;
18
+ dataType?: "string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown";
19
+ format?: string;
20
+ renderer?: (value: AnyObject, data: T) => void;
21
+ }
22
+ export interface TableProps<T = KeyValue> {
23
+ columns: Array<ColumnType<T>>;
24
+ data: T[];
25
+ autoColumns?: boolean;
26
+ }
@@ -0,0 +1,8 @@
1
+ import { type ColumnType } from "./types";
2
+ export declare const useTableColumns: (columns: ColumnType[]) => {
3
+ columnMap: {
4
+ start: ColumnType[];
5
+ end: ColumnType[];
6
+ cols: ColumnType[];
7
+ };
8
+ };
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export declare const useVirtualTable: (data: KeyValue[]) => {
3
+ scrollerRef: import("react").RefObject<HTMLDivElement>;
4
+ items: import("@tanstack/virtual-core").VirtualItem<Element>[];
5
+ getData: (index: number) => KeyValue<any>;
6
+ totalSize: () => number;
7
+ measureElement: (node: Element | null | undefined) => void;
8
+ };
@@ -0,0 +1,2 @@
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;
@@ -0,0 +1,2 @@
1
+ import { type TreePanelProps } from "./types";
2
+ export declare const TreePanel: <T extends KeyValue<any>>({ 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;
@@ -0,0 +1,138 @@
1
+ /// <reference types="react" />
2
+ import { type BadgeType, type ChildProp, type CssProp, type Elements, type IconProps, type TestProps } from "@react-fabric/core/dist/types/types";
3
+ interface TreeBaseNode<T> extends IconProps, CssProp, TestProps {
4
+ id: string;
5
+ /**
6
+ * display label
7
+ */
8
+ label: Elements<JSX.Element>;
9
+ /**
10
+ * full text to be used for querying purposes
11
+ */
12
+ queryable?: string;
13
+ /**
14
+ * element badge
15
+ */
16
+ badge?: string | number | BadgeType;
17
+ /**
18
+ * is element `node` or `leaf`
19
+ */
20
+ leaf?: boolean;
21
+ /**
22
+ * disable selection
23
+ */
24
+ disabled?: boolean;
25
+ data?: T;
26
+ }
27
+ export type TreeNodeType<T extends KeyValue = KeyValue> = TreeBaseNode<T> & ({
28
+ leaf: true;
29
+ children?: never;
30
+ } | {
31
+ leaf?: false;
32
+ children?: Array<TreeNodeType<T>>;
33
+ open?: boolean;
34
+ iconOpen?: string;
35
+ });
36
+ export interface InternalNode extends IconProps, CssProp, TestProps {
37
+ id: string;
38
+ label: Elements<JSX.Element>;
39
+ queryable?: string;
40
+ badge?: string | number | BadgeType;
41
+ disabled?: boolean;
42
+ leaf: boolean;
43
+ open: boolean;
44
+ children?: InternalNode[];
45
+ level: number;
46
+ loading: boolean;
47
+ filtered: boolean;
48
+ childFiltered?: boolean;
49
+ parentFiltered?: boolean;
50
+ loaded: boolean;
51
+ parent?: string;
52
+ empty?: boolean;
53
+ errored?: string;
54
+ selected?: true;
55
+ childSelected?: true;
56
+ checked: 0 | 1 | 2;
57
+ data?: AnyObject;
58
+ last?: boolean;
59
+ lines: Array<0 | 1 | 2 | 3>;
60
+ }
61
+ export interface TreeNodeProps extends ChildProp {
62
+ node: InternalNode;
63
+ expanders: [string, string];
64
+ defaultNodeIcon?: string;
65
+ defaultLeafIcon?: string;
66
+ noLines?: boolean;
67
+ selectable?: true | "leafOnly";
68
+ checkable?: true | "leafOnly";
69
+ onToggle: (id: string) => void;
70
+ onSelect: (id: string) => void;
71
+ onChecked: (id: string) => void;
72
+ }
73
+ export interface TreePanelProps<T extends KeyValue = KeyValue> extends TestProps {
74
+ items?: Array<TreeNodeType<T>>;
75
+ /**
76
+ * make tree searchable
77
+ */
78
+ searchable?: boolean;
79
+ /**
80
+ * filter input placeholder
81
+ */
82
+ filterPlaceholder?: string;
83
+ /**
84
+ * enable select
85
+ */
86
+ selectable?: true | "leafOnly";
87
+ /**
88
+ * enable checkable
89
+ */
90
+ checkable?: true | "leafOnly";
91
+ /**
92
+ * selected item id
93
+ */
94
+ selected?: string;
95
+ /**
96
+ * checked items
97
+ */
98
+ checked?: string[];
99
+ /**
100
+ * default node icon
101
+ */
102
+ defaultNodeIcon?: string;
103
+ /**
104
+ * default leaf icon
105
+ */
106
+ defaultLeafIcon?: string;
107
+ /**
108
+ * hide level indicator lines
109
+ */
110
+ noLines?: boolean;
111
+ /**
112
+ * expander icons
113
+ */
114
+ expander?: "box" | "caret" | "chevron" | "folder";
115
+ /**
116
+ * callback for lazy loading tree items
117
+ */
118
+ onLoad?: (id: string) => Promise<Array<TreeNodeType<T>> | undefined> | Array<TreeNodeType<T>> | undefined;
119
+ /**
120
+ * callback on selection of tree node
121
+ */
122
+ onSelect?: (id: string) => void;
123
+ /**
124
+ * callback on change of checked list
125
+ */
126
+ onChecked?: (leafs: string[], nodes: string[]) => void;
127
+ /**
128
+ * item label renderer
129
+ */
130
+ renderer?: (data: T) => JSX.Element;
131
+ /**
132
+ * item filter matcher
133
+ */
134
+ matcher?: (data: T, query: string) => boolean;
135
+ }
136
+ 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";
137
+ 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";
138
+ export {};