@react-fabric/data 1.0.0-beta.9 → 1.0.1

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 (141) hide show
  1. package/{src/histogram/Histogram.module.css → css/_histogram.css} +16 -13
  2. package/css/styles.css +24 -0
  3. package/dist/cjs/checklist/CheckList.js +59 -33
  4. package/dist/cjs/histogram/Histogram.js +41 -26
  5. package/dist/cjs/hooks/useFilteredList.js +100 -17
  6. package/dist/cjs/hooks/usePagination.js +29 -8
  7. package/dist/cjs/hooks/useSelectableList.js +30 -5
  8. package/dist/cjs/i18n/{ar.json.js → ar/data.json.js} +8 -1
  9. package/dist/cjs/i18n/{en.json.js → en/data.json.js} +8 -1
  10. package/dist/cjs/i18n/index.js +4 -4
  11. package/dist/cjs/index.js +30 -0
  12. package/dist/cjs/json/JsonViewer.js +80 -43
  13. package/dist/cjs/pagination/Pagination.js +24 -15
  14. package/dist/cjs/table/AddColumn.js +5 -5
  15. package/dist/cjs/table/BodyCell.js +20 -13
  16. package/dist/cjs/table/BodyRow.js +41 -28
  17. package/dist/cjs/table/CheckboxCell.js +10 -9
  18. package/dist/cjs/table/ColumnFilters.js +100 -0
  19. package/dist/cjs/table/EmptyCell.js +4 -4
  20. package/dist/cjs/table/HeaderCell.js +79 -53
  21. package/dist/cjs/table/HtmlTable.js +84 -0
  22. package/dist/cjs/table/{Context.js → Provider.js} +8 -10
  23. package/dist/cjs/table/Table.js +99 -33
  24. package/dist/cjs/{tree/types.js → table/context.js} +9 -5
  25. package/dist/cjs/table/types.js +29 -0
  26. package/dist/cjs/table/useResizer.js +10 -10
  27. package/dist/cjs/table/useTableColumns.js +4 -4
  28. package/dist/cjs/table/useVirtualTable.js +129 -22
  29. package/dist/cjs/tree/TreeNode.js +66 -46
  30. package/dist/cjs/tree/TreePanel.js +60 -24
  31. package/dist/cjs/tree/useTree.js +212 -47
  32. package/dist/cjs/tree/utils.js +63 -34
  33. package/dist/cjs/utils/getColor.js +58 -0
  34. package/dist/cjs/virtual/Gallery.js +119 -61
  35. package/dist/cjs/virtual/List.js +116 -55
  36. package/dist/cjs/virtual/Scroller.js +16 -8
  37. package/dist/esm/checklist/CheckList.js +61 -35
  38. package/dist/esm/histogram/Histogram.js +43 -28
  39. package/dist/esm/hooks/useFilteredList.js +101 -18
  40. package/dist/esm/hooks/usePagination.js +29 -8
  41. package/dist/esm/hooks/useSelectableList.js +30 -5
  42. package/dist/esm/i18n/{ar.json.js → ar/data.json.js} +8 -2
  43. package/dist/esm/i18n/{en.json.js → en/data.json.js} +8 -2
  44. package/dist/esm/i18n/index.js +2 -2
  45. package/dist/esm/index.js +31 -0
  46. package/dist/esm/json/JsonViewer.js +82 -45
  47. package/dist/esm/pagination/Pagination.js +25 -16
  48. package/dist/esm/table/AddColumn.js +6 -6
  49. package/dist/esm/table/BodyCell.js +21 -14
  50. package/dist/esm/table/BodyRow.js +41 -28
  51. package/dist/esm/table/CheckboxCell.js +11 -10
  52. package/dist/esm/table/ColumnFilters.js +100 -0
  53. package/dist/esm/table/EmptyCell.js +4 -4
  54. package/dist/esm/table/HeaderCell.js +80 -54
  55. package/dist/esm/table/HtmlTable.js +84 -0
  56. package/dist/esm/table/{Context.js → Provider.js} +11 -12
  57. package/dist/esm/table/Table.js +100 -34
  58. package/dist/esm/{tree/types.js → table/context.js} +8 -4
  59. package/dist/esm/table/types.js +29 -0
  60. package/dist/esm/table/useResizer.js +10 -10
  61. package/dist/esm/table/useTableColumns.js +4 -4
  62. package/dist/esm/table/useVirtualTable.js +131 -24
  63. package/dist/esm/tree/TreeNode.js +69 -49
  64. package/dist/esm/tree/TreePanel.js +62 -26
  65. package/dist/esm/tree/useTree.js +215 -50
  66. package/dist/esm/tree/utils.js +64 -35
  67. package/dist/esm/utils/getColor.js +58 -0
  68. package/dist/esm/virtual/Gallery.js +121 -63
  69. package/dist/esm/virtual/List.js +118 -57
  70. package/dist/esm/virtual/Scroller.js +17 -9
  71. package/dist/types/checklist/CheckList.d.ts +25 -6
  72. package/dist/types/histogram/Histogram.d.ts +28 -6
  73. package/dist/types/hooks/useFilteredList.d.ts +62 -5
  74. package/dist/types/hooks/usePagination.d.ts +18 -2
  75. package/dist/types/hooks/useSelectableList.d.ts +24 -1
  76. package/dist/types/index.d.ts +27 -0
  77. package/dist/types/json/JsonViewer.d.ts +23 -3
  78. package/dist/types/pagination/Pagination.d.ts +8 -2
  79. package/dist/types/table/AddColumn.d.ts +2 -2
  80. package/dist/types/table/BodyCell.d.ts +2 -2
  81. package/dist/types/table/BodyRow.d.ts +9 -9
  82. package/dist/types/table/CheckboxCell.d.ts +3 -3
  83. package/dist/types/table/ColumnFilters.d.ts +12 -0
  84. package/dist/types/table/EmptyCell.d.ts +1 -1
  85. package/dist/types/table/HeaderCell.d.ts +1 -1
  86. package/dist/types/table/HtmlTable.d.ts +21 -0
  87. package/dist/types/table/Provider.d.ts +2 -0
  88. package/dist/types/table/Table.d.ts +10 -1
  89. package/dist/types/table/context.d.ts +7 -0
  90. package/dist/types/table/types.d.ts +52 -10
  91. package/dist/types/table/useResizer.d.ts +1 -1
  92. package/dist/types/table/useTableColumns.d.ts +1 -1
  93. package/dist/types/table/useVirtualTable.d.ts +31 -12
  94. package/dist/types/tree/TreeNode.d.ts +1 -1
  95. package/dist/types/tree/TreePanel.d.ts +36 -1
  96. package/dist/types/tree/types.d.ts +75 -28
  97. package/dist/types/tree/useTree.d.ts +8 -12
  98. package/dist/types/tree/utils.d.ts +15 -8
  99. package/dist/types/utils/getColor.d.ts +43 -0
  100. package/dist/types/virtual/Gallery.d.ts +37 -6
  101. package/dist/types/virtual/List.d.ts +38 -6
  102. package/dist/types/virtual/Scroller.d.ts +1 -1
  103. package/package.json +17 -19
  104. package/src/checklist/CheckList.tsx +68 -71
  105. package/src/histogram/Histogram.tsx +47 -48
  106. package/src/hooks/useFilteredList.tsx +111 -28
  107. package/src/hooks/usePagination.tsx +39 -39
  108. package/src/hooks/useSelectableList.ts +45 -33
  109. package/src/i18n/{ar.json → ar/data.json} +5 -0
  110. package/src/i18n/{en.json → en/data.json} +5 -0
  111. package/src/i18n/index.ts +2 -2
  112. package/src/index.ts +23 -17
  113. package/src/json/JsonViewer.tsx +89 -120
  114. package/src/pagination/Pagination.tsx +104 -105
  115. package/src/table/AddColumn.tsx +6 -15
  116. package/src/table/BodyCell.tsx +27 -36
  117. package/src/table/BodyRow.tsx +36 -59
  118. package/src/table/CheckboxCell.tsx +12 -15
  119. package/src/table/ColumnFilters.tsx +93 -0
  120. package/src/table/EmptyCell.tsx +5 -18
  121. package/src/table/HeaderCell.tsx +72 -53
  122. package/src/table/HtmlTable.tsx +106 -0
  123. package/src/table/{Context.tsx → Provider.tsx} +11 -28
  124. package/src/table/Table.tsx +98 -83
  125. package/src/table/context.ts +33 -0
  126. package/src/table/types.ts +53 -27
  127. package/src/table/useResizer.ts +5 -9
  128. package/src/table/useTableColumns.ts +4 -6
  129. package/src/table/useVirtualTable.ts +136 -37
  130. package/src/tree/TreeNode.tsx +91 -86
  131. package/src/tree/TreePanel.tsx +87 -51
  132. package/src/tree/types.ts +85 -46
  133. package/src/tree/useTree.ts +210 -65
  134. package/src/tree/utils.ts +81 -62
  135. package/src/utils/getColor.ts +55 -0
  136. package/src/virtual/Gallery.tsx +129 -120
  137. package/src/virtual/List.tsx +124 -91
  138. package/src/virtual/Scroller.tsx +25 -9
  139. package/dist/cjs/histogram/Histogram.module.css +0 -1
  140. package/dist/esm/histogram/Histogram.module.css +0 -1
  141. package/dist/types/table/Context.d.ts +0 -8
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { ButtonGroup, Button, CoreIcons } from '@react-fabric/core';
3
+ import { ButtonGroup, Button } from '@react-fabric/core';
4
4
  import { jsxs, jsx } from 'react/jsx-runtime';
5
5
 
6
6
  /*
@@ -39,35 +39,43 @@ var Scroller = function Scroller(_ref) {
39
39
  variant: "link",
40
40
  className: "outline",
41
41
  children: [/*#__PURE__*/jsx(Button, {
42
- rtlFlip: true,
43
42
  size: "sm",
44
43
  variant: "link",
45
44
  "aria-label": "scroll to top",
46
- icon: vertical ? CoreIcons.chevronsUp : CoreIcons.chevronsLeft,
45
+ icon: {
46
+ icon: vertical ? "icon-[mdi--chevron-double-up]" : "icon-[mdi--chevron-double-left]",
47
+ rtlFlip: true
48
+ },
47
49
  disabled: (scrollActive & 2) === 0,
48
50
  onClick: onStart
49
51
  }), /*#__PURE__*/jsx(Button, {
50
- rtlFlip: true,
51
52
  size: "sm",
52
53
  variant: "link",
53
54
  "aria-label": "scroll up",
54
- icon: vertical ? CoreIcons.chevronUp : CoreIcons.chevronLeft,
55
+ icon: {
56
+ icon: vertical ? "icon-[mdi--chevron-up]" : "icon-[mdi--chevron-left]",
57
+ rtlFlip: true
58
+ },
55
59
  disabled: (scrollActive & 2) === 0,
56
60
  onClick: onPrevious
57
61
  }), /*#__PURE__*/jsx(Button, {
58
- rtlFlip: true,
59
62
  size: "sm",
60
63
  variant: "link",
61
64
  "aria-label": "scroll down",
62
- icon: vertical ? CoreIcons.chevronDown : CoreIcons.chevronRight,
65
+ icon: {
66
+ icon: vertical ? "icon-[mdi--chevron-down]" : "icon-[mdi--chevron-right]",
67
+ rtlFlip: true
68
+ },
63
69
  disabled: scrollActive % 2 === 0,
64
70
  onClick: onNext
65
71
  }), /*#__PURE__*/jsx(Button, {
66
- rtlFlip: true,
67
72
  size: "sm",
68
73
  variant: "link",
69
74
  "aria-label": "scroll to bottom",
70
- icon: vertical ? CoreIcons.chevronsDown : CoreIcons.chevronsRight,
75
+ icon: {
76
+ icon: vertical ? "icon-[mdi--chevron-double-down]" : "icon-[mdi--chevron-double-right]",
77
+ rtlFlip: true
78
+ },
71
79
  disabled: scrollActive % 2 === 0,
72
80
  onClick: onEnd
73
81
  })]
@@ -1,12 +1,12 @@
1
- import { type BadgeType, type TestProps } from "@react-fabric/core/dist/types/types";
2
- import { type FC } from "react";
1
+ import type { BadgeType } from "@react-fabric/core/dist/types/components/badge/Badge";
2
+ import { type TestProps } from "@react-fabric/core/dist/types/types";
3
3
  import { type SelectableProps } from "../hooks/useSelectableList";
4
- export interface CheckListItem extends KeyValue {
4
+ export interface CheckListItem {
5
5
  id: string;
6
6
  label: string;
7
- icon?: string;
7
+ icon?: string | React.ReactElement;
8
8
  badge?: BadgeType;
9
- isDisabled?: boolean;
9
+ disabled?: boolean;
10
10
  }
11
11
  export interface CheckListProps extends SelectableProps, TestProps {
12
12
  /**
@@ -27,4 +27,23 @@ export interface CheckListProps extends SelectableProps, TestProps {
27
27
  emptyMessage?: string;
28
28
  sortItems?: boolean;
29
29
  }
30
- export declare const CheckList: FC<CheckListProps>;
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
+ * @example
35
+ * ```jsx
36
+ * <CheckList
37
+ * items={[
38
+ * { id: "1", label: "Item 1", icon: "icon1" },
39
+ * { id: "2", label: "Item 2", icon: "icon2", badge: { text: "New" } },
40
+ * ]}
41
+ * maxCount={5}
42
+ * allowNegative={true}
43
+ * emptyMessage="No items available"
44
+ * onChange={(selectedItems) => console.log(selectedItems)}
45
+ * onClick={(itemId, isNegative) => console.log(itemId, isNegative)}
46
+ * />
47
+ * ```
48
+ */
49
+ export declare function CheckList({ items, maxCount, allowNegative, emptyMessage, sortItems, selected, nonselected, onChange, onClick, ...aria }: CheckListProps): import("react").JSX.Element;
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import { type ColorType, type PaletteType, type TestProps } from "@react-fabric/core/dist/types/types";
1
+ import type { CustomColors, TestProps } from "@react-fabric/core/dist/types/types";
3
2
  interface HistogramItem {
4
3
  id: string;
5
4
  label: string;
@@ -19,7 +18,7 @@ export interface HistogramProps extends TestProps {
19
18
  /**
20
19
  * histogram bar color
21
20
  */
22
- color?: ColorType | PaletteType;
21
+ color?: CustomColors;
23
22
  /**
24
23
  * sorted list
25
24
  */
@@ -27,15 +26,38 @@ export interface HistogramProps extends TestProps {
27
26
  /**
28
27
  * title when histo list is empty
29
28
  */
30
- emptyTitle?: string | JSX.Element;
29
+ emptyTitle?: string | React.ReactElement;
31
30
  /**
32
31
  * message when histo list is empty
33
32
  */
34
- emptyMessage?: string | JSX.Element;
33
+ emptyMessage?: string | React.ReactElement;
35
34
  /**
36
35
  * handle histo click
37
36
  */
38
37
  onClick?: (id: string, negative?: true) => void;
39
38
  }
40
- export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, ...aria }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
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
+ * @example
46
+ * ```jsx
47
+ * <Histogram
48
+ * items={[
49
+ * { id: "1", label: "Item 1", count: 10 },
50
+ * { id: "2", label: "Item 2", count: 20 },
51
+ * { id: "3", label: "Item 3", count: 5, disabled: true },
52
+ * ]}
53
+ * total={30}
54
+ * color="primary-500"
55
+ * sortBy="count"
56
+ * emptyTitle="No Data Available"
57
+ * emptyMessage="Please check back later."
58
+ * onClick={(id, negative) => console.log(`Clicked on ${id}`, negative ? "Negative" : "Positive")}
59
+ * />
60
+ * ```
61
+ */
62
+ export declare function Histogram({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, }: HistogramProps): import("react").JSX.Element;
41
63
  export {};
@@ -1,7 +1,64 @@
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;
1
+ interface RetType<T, Q> {
2
+ onSearch: (query?: Q) => void;
3
+ query: Q;
5
4
  filteredList: T[];
6
5
  isSearching: boolean;
7
- };
6
+ }
7
+ /**
8
+ * Custom hook to filter a list of items based on a query.
9
+ * It provides a way to search through the items and returns the filtered list.
10
+ * The hook uses a deferred value to optimize performance during transitions.
11
+ * It also allows for a custom matcher function to define how items should be matched against the query.
12
+ *
13
+ * @param items - The list of items to filter.
14
+ * @param matchAll - Match all phrases in the query list against the items.
15
+ * @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
16
+ *
17
+ * @example
18
+ * ```jsx
19
+ * useFilteredList(items, (item, query) => {
20
+ * return item.name.includes(query);
21
+ * });
22
+ * ```
23
+ *
24
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
25
+ */
26
+ export declare function useFilteredList<T extends AnyObject = KeyValue, Q extends AnyObject = string>(items: T[], matchAll?: boolean): RetType<T, Q>;
27
+ /**
28
+ * Custom hook to filter a list of items based on a query.
29
+ * It provides a way to search through the items and returns the filtered list.
30
+ * The hook uses a deferred value to optimize performance during transitions.
31
+ * It also allows for a custom matcher function to define how items should be matched against the query.
32
+ *
33
+ * @param items - The list of items to filter.
34
+ * @param matcher - An optional function to match items against the query.
35
+ * @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
36
+ *
37
+ * @example
38
+ * ```jsx
39
+ * useFilteredList(items, (item, query) => {
40
+ * return item.name.includes(query);
41
+ * });
42
+ * ```
43
+ */
44
+ export declare function useFilteredList<T extends AnyObject = KeyValue, Q extends AnyObject = string>(items: T[], matcher?: (item: T, query: Q) => boolean): RetType<T, Q>;
45
+ /**
46
+ * Custom hook to filter a list of items based on a query.
47
+ * It provides a way to search through the items and returns the filtered list.
48
+ * The hook uses a deferred value to optimize performance during transitions.
49
+ * It also allows for a custom matcher function to define how items should be matched against the query.
50
+ *
51
+ * @param items - The list of items to filter.
52
+ * @param matchAll - Match all phrases in the query list against the items.
53
+ * @param matcher - An optional function to match items against the query.
54
+ * @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
55
+ *
56
+ * @example
57
+ * ```jsx
58
+ * useFilteredList(items, (item, query) => {
59
+ * return item.name.includes(query);
60
+ * });
61
+ * ```
62
+ */
63
+ export declare function useFilteredList<T extends AnyObject = KeyValue, Q extends AnyObject = string>(items: T[], matchAll?: boolean, matcher?: (item: T, query: Q) => boolean): RetType<T, Q>;
64
+ export {};
@@ -16,10 +16,26 @@ export interface PaginationOptions {
16
16
  */
17
17
  onChange?: (page: number) => void;
18
18
  }
19
- export declare const usePagination: ({ totalRecords, currentPage, perPage, onChange, }: PaginationOptions) => {
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
+ * @example
26
+ * ```jsx
27
+ * const { page, totalPages, headLabel, ranges, onPageChange } = usePagination({
28
+ * totalRecords: 100,
29
+ * currentPage: 0,
30
+ * perPage: 10,
31
+ * onChange: (newPage) => console.log("Page changed to:", newPage),
32
+ * });
33
+ * ```
34
+ */
35
+ export declare function usePagination({ totalRecords, currentPage, perPage, onChange }: PaginationOptions): {
20
36
  page: number;
21
37
  totalPages: number;
22
- headLabel: import("react/jsx-runtime").JSX.Element;
38
+ headLabel: import("react").JSX.Element;
23
39
  ranges: number[][];
24
40
  onPageChange: (page: number) => void;
25
41
  };
@@ -4,6 +4,7 @@ export interface SelectableProps {
4
4
  */
5
5
  items: Array<{
6
6
  label: string;
7
+ id: string;
7
8
  } & KeyValue>;
8
9
  /**
9
10
  * selected item ids
@@ -22,7 +23,29 @@ export interface SelectableProps {
22
23
  */
23
24
  onClick?: (id: string, isNegative: boolean) => void;
24
25
  }
25
- export declare const useSelectableList: ({ items, selected, nonselected, onChange, onClick, }: SelectableProps) => {
26
+ /**
27
+ * Custom hook to manage selection of items in a list.
28
+ * It allows toggling selection state of items, handling both selected and non-selected states.
29
+ * The hook maintains a selection state and provides a function to toggle the selection of items.
30
+ * It also supports callbacks for when the selection changes or when an item is clicked.
31
+ *
32
+ * @example
33
+ * ```jsx
34
+ * const { selection, toggleSelection } = useSelectableList({
35
+ * items: [{ id: '1', label: 'Item 1' }, { id: '2', label: 'Item 2' }],
36
+ * selected: ['1'],
37
+ * nonselected: ['2'],
38
+ * onChange: (selectedIds, nonSelectedIds) => {
39
+ * console.log('Selected:', selectedIds);
40
+ * console.log('Non-selected:', nonSelectedIds);
41
+ * },
42
+ * onClick: (id, isNegative) => {
43
+ * console.log(`Item ${id} clicked, isNegative: ${isNegative}`);
44
+ * },
45
+ * });
46
+ * ```
47
+ */
48
+ export declare function useSelectableList({ items, selected, nonselected, onChange, onClick }: SelectableProps): {
26
49
  selection: KeyValue<number>;
27
50
  toggleSelection: (id: string, isNegative?: boolean) => void;
28
51
  };
@@ -1,8 +1,35 @@
1
+ /**
2
+ * React Fabric
3
+ * @version 1.0.0
4
+ * @license MIT
5
+ * @copyright 2024 Adarsh Pastakia
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+ export declare const DATA_PACKAGE = "@react-fabric/data";
26
+ export declare const DATA_VERSION = "1.0.0";
1
27
  import "./i18n";
2
28
  export { CheckList } from "./checklist/CheckList";
3
29
  export { Histogram } from "./histogram/Histogram";
4
30
  export { JsonViewer } from "./json/JsonViewer";
5
31
  export { Pagination } from "./pagination/Pagination";
32
+ export { HtmlTable } from "./table/HtmlTable";
6
33
  export { Table } from "./table/Table";
7
34
  export { type TableColumn, type TableRef } from "./table/types";
8
35
  export { TreePanel } from "./tree/TreePanel";
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { type CssProp } from "@react-fabric/core/dist/types/types";
3
2
  export interface JsonViewProps<T> extends CssProp {
4
3
  /**
@@ -54,6 +53,27 @@ export interface JsonViewProps<T> extends CssProp {
54
53
  /**
55
54
  * render function for custom value display
56
55
  */
57
- formatter?: (path?: string, value?: AnyObject) => string | JSX.Element | undefined;
56
+ formatter?: (path?: string, value?: AnyObject) => string | React.ReactElement | undefined;
58
57
  }
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;
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
+ * @example
65
+ * ```jsx
66
+ * <JsonViewer
67
+ * json={{ name: "John", age: 30, address: { city: "New York", zip: "10001" } }}
68
+ * copy={true}
69
+ * filters={true}
70
+ * propertyScheme={{ date: ["createdAt"], phone: ["contact"] }}
71
+ * inline={true}
72
+ * labelWidth="25%"
73
+ * formatter={(path, value) => (path === "age" ? `${value} years` : value)}
74
+ * labeler={(path) => path.replace(/_/g, " ").toUpperCase()}
75
+ * onFilter={(path, value, negate) => console.log(`Filter ${negate ? "negate" : ""} on ${path}:`, value)}
76
+ * />
77
+ * ```
78
+ */
79
+ export declare function JsonViewer<T extends KeyValue = KeyValue>({ className, json, copy, propertyScheme, filters, inline, labelWidth, formatter, labeler, onFilter, emptyMessage, showPropertyTree, ...rest }: JsonViewProps<T>): import("react").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,11 @@ export interface PaginationProps {
21
20
  */
22
21
  onPageChange: (page: number) => void;
23
22
  }
24
- export declare const Pagination: import("react").MemoExoticComponent<({ page, ranges, totalPages, minimal, onPageChange }: PaginationProps) => import("react/jsx-runtime").JSX.Element>;
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
+ export declare const Pagination: import("react").MemoExoticComponent<({ page, ranges, totalPages, minimal, onPageChange }: PaginationProps) => import("react").JSX.Element>;
@@ -1,5 +1,5 @@
1
1
  import { type TableColumn } from "./types";
2
- export declare const AddColumn: ({ columns, onClick, }: {
2
+ export declare function AddColumn({ columns, onClick }: {
3
3
  columns: TableColumn[];
4
4
  onClick: (id: string) => void;
5
- }) => import("react/jsx-runtime").JSX.Element;
5
+ }): import("react").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { type TableColumn } from "./types";
2
- export declare const BodyCell: ({ column, item, index, }: {
2
+ export declare function BodyCell({ column, item, index }: {
3
3
  column: TableColumn;
4
4
  item: KeyValue;
5
5
  index: number;
6
- }) => import("react/jsx-runtime").JSX.Element;
6
+ }): import("react").JSX.Element;
@@ -1,20 +1,20 @@
1
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;
2
+ export declare function BodyRow<T extends KeyValue = KeyValue>({ rowKey, index, data, keyProperty, measureElement, state, hideableColumns, wrapperStart, wrapperEnd, onRowClick, checkableRows, checked, toggleChecked, canExpand, expanded, toggleExpand, expandRow, }: {
3
+ rowKey: keyof T;
4
4
  index: number;
5
- data: KeyValue;
6
- keyProperty?: Key;
7
- measureElement: AnyObject;
5
+ data: T;
6
+ keyProperty?: keyof T;
8
7
  state: KeyValue<TableColumn[]>;
9
8
  hideableColumns?: boolean;
10
9
  wrapperStart: string;
11
10
  wrapperEnd: string;
12
11
  checkableRows?: boolean;
13
12
  checked: 0 | 1;
14
- onRowClick?: AnyObject;
15
- canExpand?: AnyObject;
16
- expandRow?: AnyObject;
17
13
  expanded: boolean;
14
+ measureElement: (el: HTMLDivElement) => void;
15
+ expandRow?: (data: T) => React.ReactElement<unknown>;
16
+ canExpand?: (data: T) => boolean;
17
+ onRowClick?: (data: T) => void;
18
18
  toggleExpand: (key: Key) => void;
19
19
  toggleChecked: (key: Key) => void;
20
- }) => import("react/jsx-runtime").JSX.Element;
20
+ }): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- export declare const CheckboxCell: ({ state, onClick, }: {
2
- state: 0 | 1 | 2;
1
+ export declare function CheckboxCell({ state, onClick }: {
2
+ state: number;
3
3
  onClick?: () => void;
4
- }) => import("react/jsx-runtime").JSX.Element;
4
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { type TableColumn } from "./types";
2
+ interface FilterProps {
3
+ type: TableColumn["dataType"];
4
+ onFilter: (value: AnyObject) => void;
5
+ list?: Array<string | {
6
+ id: string;
7
+ label: string;
8
+ }>;
9
+ filter?: string | string[];
10
+ }
11
+ export declare function ColumnFilters({ type, list, filter, onFilter }: FilterProps): import("react").JSX.Element;
12
+ export {};
@@ -1,2 +1,2 @@
1
1
  import { type TableColumn } from "./types";
2
- export declare const EmptyCell: ({ id, width: _width, maxWidth, minWidth, }: TableColumn) => import("react/jsx-runtime").JSX.Element;
2
+ export declare function EmptyCell({ id, width: _width, maxWidth, minWidth }: TableColumn): import("react").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { type TableColumn, type TableProps } from "./types";
2
- export declare const HeaderCell: ({ id, label, icon, iconBg, iconColor, rtlFlip, actions, locked, tooltip, sortable, resizable, width: _width, maxWidth, minWidth, sort, onSort, }: TableColumn & Pick<TableProps, "sort" | "onSort">) => import("react/jsx-runtime").JSX.Element;
2
+ export declare function HeaderCell({ id, field, dataType, label, icon, actions, filter, filterable, filterOptions, tooltip, sortable, resizable, width: _width, maxWidth, minWidth, sort, onSort, onFilter, }: TableColumn & Pick<TableProps, "sort" | "onSort" | "onFilter">): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ interface Props<T = KeyValue> {
2
+ data: T[];
3
+ columns: Array<{
4
+ id: keyof T;
5
+ label?: string;
6
+ width?: number | string;
7
+ maxWidth?: number | string;
8
+ align?: "start" | "center" | "end";
9
+ className?: string;
10
+ headRenderer?: React.ReactNode;
11
+ renderer?: (value: AnyObject, row: T, index: number) => React.ReactNode;
12
+ }>;
13
+ /**
14
+ * Number of pagination buttons to show, default is 25
15
+ * If set to 0, pagination will be hidden
16
+ */
17
+ paginationSize?: number;
18
+ className?: string;
19
+ }
20
+ export declare function HtmlTable<T extends KeyValue = KeyValue>({ data, columns, paginationSize, className }: Props<T>): import("react").JSX.Element;
21
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type ChildrenProp } from "@react-fabric/core/dist/types/types";
2
+ export declare function TableProvider({ children }: ChildrenProp): import("react").JSX.Element;
@@ -1,2 +1,11 @@
1
1
  import { type TableProps } from "./types";
2
- export declare const Table: <T extends KeyValue<any> = KeyValue<any>>({ ref, data, columns, keyProperty, checkableRows, initialScroll, hideableColumns, sort, loading, emptyDisplay, canExpand, children, onSort, onScroll, onRowClick, onCheckedChanged, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
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
+ * @see {@link https://tanstack.com/table/v8/docs/api/virtual}
10
+ */
11
+ export declare function 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, total, onLoadMore, }: TableProps<T>): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ interface Context {
2
+ widths: Map<string, number>;
3
+ startResize: (col: HTMLElement) => void;
4
+ }
5
+ export declare const TableContext: import("react").Context<Context>;
6
+ export declare const useTableContext: () => Context;
7
+ export {};
@@ -1,28 +1,64 @@
1
- import { type CssProp, type Elements, type IconProps, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
1
+ import { type IconProps } from "@react-fabric/core/dist/types/components/icon/Icon";
2
+ import { type CssProp, type NestedKeys, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
2
3
  import { type ReactElement } from "react";
3
4
  export declare const COL_MIN_WIDTH = "3rem";
4
5
  export declare const COL_MAX_WIDTH = "64rem";
5
6
  export declare const COL_DEFAULT_WIDTH = "12rem";
6
- export interface TableColumn<T = KeyValue> extends CssProp, IconProps, TestProps {
7
- id: keyof T | string;
7
+ /**
8
+ * TableColumn interface defines the structure of a column in a table.
9
+ * It includes properties for column identification, display options, alignment,
10
+ * visibility, resizing, sorting, filtering, and rendering.
11
+ *
12
+ * @template T - The type of data the column will represent, defaulting to KeyValue.
13
+ * @property {keyof T | string} id - Unique identifier for the column.
14
+ * @property {"string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown"} [dataType] - Data type of the column values.
15
+ * @property {string} [label] - Display label for the column header.
16
+ * @property {string} [tooltip] - Tooltip text for the column header.
17
+ * @property {string} [format] - Format string for displaying the column values.
18
+ * @property {"start" | "center" | "end"} [align] - Text alignment within the column.
19
+ * @property {"start" | "end"} [locked] - Indicates if the column is locked at the start or end.
20
+ * @property {boolean} [hidden] - Whether the column is hidden.
21
+ * @property {boolean} [truncate] - Whether to truncate the text in the column.
22
+ * @property {boolean} [hideable] - Whether the column can be hidden by the user.
23
+ * @property {boolean} [resizable] - Whether the column can be resized by the user.
24
+ * @property {boolean} [sortable] - Whether the column can be sorted.
25
+ * @property {boolean} [filterable] - Whether the column can be filtered.
26
+ * @property {AnyObject} [filter] - Filter criteria for the column.
27
+ * @property {ReactElement[]} [actions] - Array of action elements to be displayed in the column.
28
+ * @property {AnyObject[]} [filterOptions] - Options for filtering the column.
29
+ * @property {string | number} [width] - Width of the column.
30
+ * @property {string | number} [minWidth] - Minimum width of the column.
31
+ * @property {string | number} [maxWidth] - Maximum width of the column.
32
+ * @property {KeyValue} [valueMap] - Mapping of values for the column.
33
+ * @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
34
+ */
35
+ export interface TableColumn<T = KeyValue> extends CssProp, TestProps {
36
+ id: NestedKeys<T>;
37
+ field?: string;
8
38
  label?: string;
9
39
  tooltip?: string;
10
- actions?: ReactElement;
40
+ icon?: IconProps;
41
+ actions?: ReactElement[];
11
42
  align?: "start" | "center" | "end";
12
43
  locked?: "start" | "end";
13
44
  hidden?: boolean;
45
+ truncate?: boolean;
14
46
  hideable?: boolean;
15
47
  resizable?: boolean;
16
48
  sortable?: boolean;
17
49
  filterable?: boolean;
18
- filterList?: AnyObject[];
50
+ filter?: string | string[];
51
+ filterOptions?: Array<string | {
52
+ id: string;
53
+ label: string;
54
+ }>;
19
55
  width?: string | number;
20
56
  minWidth?: string | number;
21
57
  maxWidth?: string | number;
22
58
  dataType?: "string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown";
23
59
  format?: string;
24
- valueMap?: KeyValue;
25
- renderer?: (value: AnyObject, data: T, index: number) => Elements<AnyObject>;
60
+ valueMap?: KeyValue<string>;
61
+ renderer?: (value: AnyObject, data: T, index: number) => React.ReactElement<unknown>;
26
62
  }
27
63
  export interface TableRef {
28
64
  hilight: (row: number) => void;
@@ -32,13 +68,16 @@ export interface TableRef {
32
68
  export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
33
69
  columns: Array<TableColumn<T>>;
34
70
  data: T[];
35
- keyProperty?: keyof T;
71
+ keyProperty?: NestedKeys<T>;
72
+ groupProperty?: NestedKeys<T>;
73
+ groupRenderer?: (key: AnyObject) => ReactElement;
36
74
  emptyDisplay?: ReactElement;
37
75
  /**
38
76
  * checkable rows
39
77
  */
78
+ checked?: AnyObject[];
40
79
  checkableRows?: boolean;
41
- onCheckedChanged?: (rows: Array<keyof T>) => void;
80
+ onCheckedChanged?: (rows: AnyObject[]) => void;
42
81
  /**
43
82
  * sorting
44
83
  */
@@ -56,5 +95,8 @@ export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
56
95
  initialScroll?: number;
57
96
  onScroll?: (firstItem: number) => void;
58
97
  canExpand?: (record: T) => boolean;
59
- children?: (record: T) => Elements<AnyObject>;
98
+ children?: (record: T) => React.ReactElement<unknown>;
99
+ onFilter?: (id: NestedKeys<T> | string, value?: AnyObject) => void;
100
+ total?: number;
101
+ onLoadMore?: (lastIndex?: number) => void;
60
102
  }
@@ -1 +1 @@
1
- export declare const useResizer: (colEl: HTMLElement, ghostEl: HTMLElement, callback: (width: number) => void) => void;
1
+ export declare function startResizer(colEl: HTMLElement, ghostEl: HTMLElement, callback: (width: number) => void): void;
@@ -1,5 +1,5 @@
1
1
  import { type TableColumn } from "./types";
2
- export declare const useTableColumns: (columns: TableColumn[]) => {
2
+ export declare function useTableColumns(columns: TableColumn[]): {
3
3
  state: {
4
4
  start: TableColumn<KeyValue<any>>[];
5
5
  end: TableColumn<KeyValue<any>>[];