@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.
Files changed (55) hide show
  1. package/dist/cjs/checklist/CheckList.js +23 -0
  2. package/dist/cjs/histogram/Histogram.js +28 -0
  3. package/dist/cjs/hooks/useFilteredList.js +20 -0
  4. package/dist/cjs/hooks/usePagination.js +20 -0
  5. package/dist/cjs/hooks/useSelectableList.js +29 -0
  6. package/dist/cjs/i18n/ar.json.js +8 -1
  7. package/dist/cjs/i18n/en.json.js +8 -1
  8. package/dist/cjs/json/JsonViewer.js +27 -0
  9. package/dist/cjs/pagination/Pagination.js +10 -0
  10. package/dist/cjs/table/Table.js +2 -2
  11. package/dist/cjs/table/types.js +29 -0
  12. package/dist/cjs/virtual/Gallery.js +35 -2
  13. package/dist/cjs/virtual/List.js +38 -1
  14. package/dist/esm/checklist/CheckList.js +23 -0
  15. package/dist/esm/histogram/Histogram.js +28 -0
  16. package/dist/esm/hooks/useFilteredList.js +20 -0
  17. package/dist/esm/hooks/usePagination.js +20 -0
  18. package/dist/esm/hooks/useSelectableList.js +29 -0
  19. package/dist/esm/i18n/ar.json.js +8 -2
  20. package/dist/esm/i18n/en.json.js +8 -2
  21. package/dist/esm/json/JsonViewer.js +27 -0
  22. package/dist/esm/pagination/Pagination.js +10 -0
  23. package/dist/esm/table/Table.js +2 -2
  24. package/dist/esm/table/types.js +29 -0
  25. package/dist/esm/virtual/Gallery.js +35 -2
  26. package/dist/esm/virtual/List.js +38 -1
  27. package/dist/types/checklist/CheckList.d.ts +22 -0
  28. package/dist/types/histogram/Histogram.d.ts +28 -0
  29. package/dist/types/hooks/useFilteredList.d.ts +20 -2
  30. package/dist/types/hooks/usePagination.d.ts +19 -0
  31. package/dist/types/hooks/useSelectableList.d.ts +29 -0
  32. package/dist/types/json/JsonViewer.d.ts +27 -1
  33. package/dist/types/pagination/Pagination.d.ts +10 -1
  34. package/dist/types/table/Table.d.ts +14 -1
  35. package/dist/types/table/types.d.ts +28 -0
  36. package/dist/types/table/useVirtualTable.d.ts +1 -2
  37. package/dist/types/tree/TreePanel.d.ts +42 -1
  38. package/dist/types/tree/useTree.d.ts +2 -2
  39. package/dist/types/virtual/Gallery.d.ts +32 -0
  40. package/dist/types/virtual/List.d.ts +36 -0
  41. package/package.json +6 -6
  42. package/src/checklist/CheckList.tsx +22 -0
  43. package/src/histogram/Histogram.tsx +28 -0
  44. package/src/hooks/useFilteredList.tsx +19 -0
  45. package/src/hooks/usePagination.tsx +19 -0
  46. package/src/hooks/useSelectableList.ts +29 -0
  47. package/src/i18n/ar.json +5 -0
  48. package/src/i18n/en.json +5 -0
  49. package/src/json/JsonViewer.tsx +26 -0
  50. package/src/pagination/Pagination.tsx +10 -0
  51. package/src/table/Table.tsx +15 -2
  52. package/src/table/types.ts +28 -0
  53. package/src/tree/TreePanel.tsx +41 -0
  54. package/src/virtual/Gallery.tsx +35 -2
  55. package/src/virtual/List.tsx +38 -1
@@ -72,6 +72,29 @@ var CheckItem = function CheckItem(_ref) {
72
72
  }), /*#__PURE__*/jsxRuntime.jsx(core.Badge, _objectSpread({}, badge))]
73
73
  }));
74
74
  };
75
+
76
+ /**
77
+ * CheckList component to display a list of selectable items with checkboxes.
78
+ * It supports selection, deselection, and allows for negative selections.
79
+ *
80
+ * @param {CheckListProps} props - The properties for the CheckList component.
81
+ * @returns {JSX.Element} The rendered CheckList component.
82
+ *
83
+ * @example
84
+ * ```jsx
85
+ * <CheckList
86
+ * items={[
87
+ * { id: "1", label: "Item 1", icon: "icon1" },
88
+ * { id: "2", label: "Item 2", icon: "icon2", badge: { text: "New" } },
89
+ * ]}
90
+ * maxCount={5}
91
+ * allowNegative={true}
92
+ * emptyMessage="No items available"
93
+ * onChange={(selectedItems) => console.log(selectedItems)}
94
+ * onClick={(itemId, isNegative) => console.log(itemId, isNegative)}
95
+ * />
96
+ * ```
97
+ */
75
98
  var CheckList = function CheckList(_ref2) {
76
99
  var _ref2$items = _ref2.items,
77
100
  items = _ref2$items === void 0 ? [] : _ref2$items,
@@ -14,6 +14,34 @@ var _excluded = ["items", "total", "color", "sortBy", "emptyTitle", "emptyMessag
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var emptyIcon = "M20.84 22.73L11.11 13H3V11H9.11L6.11 8H3V6H4.11L1.11 3L2.39 1.73L22.11 21.46L20.84 22.73M15 11H14.2L15 11.8V11M21 8V6H9.2L11.2 8H21M3 18H9V16H3V18Z";
17
+ /**
18
+ * Histogram component displays a bar chart of items with counts.
19
+ * It allows users to visualize the distribution of counts across different items.
20
+ * The component supports sorting, custom colors, and click handling for each item.
21
+ * It also provides an empty state when there are no items to display.
22
+ *
23
+ * @param {HistogramProps} props - The properties for the Histogram component.
24
+ * @returns {JSX.Element} - The rendered Histogram component.
25
+ *
26
+ * @example
27
+ * ```jsx
28
+ * <Histogram
29
+ * items={[
30
+ * { id: "1", label: "Item 1", count: 10 },
31
+ * { id: "2", label: "Item 2", count: 20 },
32
+ * { id: "3", label: "Item 3", count: 5, disabled: true },
33
+ * ]}
34
+ * total={30}
35
+ * color="primary-500"
36
+ * sortBy="count"
37
+ * emptyTitle="No Data Available"
38
+ * emptyMessage="Please check back later."
39
+ * onClick={(id, negative) => console.log(`Clicked on ${id}`, negative ? "Negative" : "Positive")}
40
+ * />
41
+ * ```
42
+ *
43
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-histogram--docs}
44
+ */
17
45
  var Histogram = function Histogram(_ref) {
18
46
  var _ref$items = _ref.items,
19
47
  items = _ref$items === void 0 ? [] : _ref$items,
@@ -23,6 +23,26 @@ var filterList = function filterList(items) {
23
23
  });
24
24
  return newList;
25
25
  };
26
+
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
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
45
+ */
26
46
  var useFilteredList = function useFilteredList(items, matcher) {
27
47
  var _useState = react.useState(),
28
48
  _useState2 = _slicedToArray(_useState, 2),
@@ -15,6 +15,26 @@ var makeRange = function makeRange(start, end) {
15
15
  return idx + start;
16
16
  });
17
17
  };
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
+ */
18
38
  var usePagination = function usePagination(_ref) {
19
39
  var totalRecords = _ref.totalRecords,
20
40
  _ref$currentPage = _ref.currentPage,
@@ -6,6 +6,35 @@ var react = require('react');
6
6
 
7
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ /**
10
+ * Custom hook to manage selection of items in a list.
11
+ * It allows toggling selection state of items, handling both selected and non-selected states.
12
+ * The hook maintains a selection state and provides a function to toggle the selection of items.
13
+ * It also supports callbacks for when the selection changes or when an item is clicked.
14
+ *
15
+ * @param items - The list of items to manage selection for.
16
+ * @param selected - An array of item IDs that are currently selected.
17
+ * @param nonselected - An array of item IDs that are currently non-selected.
18
+ * @param onChange - Callback function that is called when the selection changes.
19
+ * @param onClick - Callback function that is called when an item is clicked.
20
+ * @returns An object containing the current selection state and a function to toggle selection of items.
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * const { selection, toggleSelection } = useSelectableList({
25
+ * items: [{ id: '1', label: 'Item 1' }, { id: '2', label: 'Item 2' }],
26
+ * selected: ['1'],
27
+ * nonselected: ['2'],
28
+ * onChange: (selectedIds, nonSelectedIds) => {
29
+ * console.log('Selected:', selectedIds);
30
+ * console.log('Non-selected:', nonSelectedIds);
31
+ * },
32
+ * onClick: (id, isNegative) => {
33
+ * console.log(`Item ${id} clicked, isNegative: ${isNegative}`);
34
+ * },
35
+ * });
36
+ * ```
37
+ */
9
38
  var useSelectableList = function useSelectableList(_ref) {
10
39
  var items = _ref.items,
11
40
  selected = _ref.selected,
@@ -36,6 +36,11 @@ var action = {
36
36
  addFilter: "أضف عامل تصفية",
37
37
  addFilterNot: "إضافة لا تصفية"
38
38
  };
39
+ var data = {
40
+ tree: {
41
+ noItems: "لا توجد عناصر شجرة متوفرة"
42
+ }
43
+ };
39
44
  var ar = {
40
45
  label: label,
41
46
  tree: tree,
@@ -43,11 +48,13 @@ var ar = {
43
48
  json: json,
44
49
  checkList: checkList,
45
50
  histogram: histogram,
46
- action: action
51
+ action: action,
52
+ data: data
47
53
  };
48
54
 
49
55
  exports.action = action;
50
56
  exports.checkList = checkList;
57
+ exports.data = data;
51
58
  exports.datagrid = datagrid;
52
59
  exports.default = ar;
53
60
  exports.histogram = histogram;
@@ -36,6 +36,11 @@ var action = {
36
36
  addFilter: "Add Filter",
37
37
  addFilterNot: "Add not Filter"
38
38
  };
39
+ var data = {
40
+ tree: {
41
+ noItems: "No tree items available"
42
+ }
43
+ };
39
44
  var en = {
40
45
  label: label,
41
46
  tree: tree,
@@ -43,11 +48,13 @@ var en = {
43
48
  json: json,
44
49
  checkList: checkList,
45
50
  histogram: histogram,
46
- action: action
51
+ action: action,
52
+ data: data
47
53
  };
48
54
 
49
55
  exports.action = action;
50
56
  exports.checkList = checkList;
57
+ exports.data = data;
51
58
  exports.datagrid = datagrid;
52
59
  exports.default = en;
53
60
  exports.histogram = histogram;
@@ -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 @@ var classNames = require('classnames');
6
6
  var react = require('react');
7
7
  var jsxRuntime = require('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__*/react.memo(function (_ref) {
10
20
  var page = _ref.page,
11
21
  ranges = _ref.ranges,
@@ -126,7 +126,7 @@ var Table = function Table(_ref) {
126
126
  ref: scrollerRef,
127
127
  children: [/*#__PURE__*/jsxRuntime.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-5",
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__*/jsxRuntime.jsxs("div", {
131
131
  className: wrapperStart,
132
132
  children: [canExpand && /*#__PURE__*/jsxRuntime.jsx("div", {
@@ -180,7 +180,7 @@ var Table = function Table(_ref) {
180
180
  return "__GROUP__" in data ? /*#__PURE__*/jsxRuntime.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-3", isActiveSticky(index) && "sticky top-8"),
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);
@@ -27,6 +27,35 @@ 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
  exports.COL_DEFAULT_WIDTH = COL_DEFAULT_WIDTH;
31
60
  exports.COL_MAX_WIDTH = COL_MAX_WIDTH;
32
61
  exports.COL_MIN_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__*/jsxRuntime.jsxs("div", {
184
- className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full"),
184
+ className: classNames("flex flex-nowrap justify-center gap-2 min-h-full"),
185
185
  children: [/*#__PURE__*/jsxRuntime.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__*/jsxRuntime.jsx("div", {
203
- className: "flex justify-center",
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 = react.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
  exports.VirtualGallery = VirtualGallery;
@@ -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__*/jsxRuntime.jsxs("div", {
171
- className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
171
+ className: classNames("flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
172
172
  children: [/*#__PURE__*/jsxRuntime.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 = react.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
  exports.VirtualList = VirtualList;
@@ -72,6 +72,29 @@ var CheckItem = function CheckItem(_ref) {
72
72
  }), /*#__PURE__*/jsx(Badge, _objectSpread({}, badge))]
73
73
  }));
74
74
  };
75
+
76
+ /**
77
+ * CheckList component to display a list of selectable items with checkboxes.
78
+ * It supports selection, deselection, and allows for negative selections.
79
+ *
80
+ * @param {CheckListProps} props - The properties for the CheckList component.
81
+ * @returns {JSX.Element} The rendered CheckList component.
82
+ *
83
+ * @example
84
+ * ```jsx
85
+ * <CheckList
86
+ * items={[
87
+ * { id: "1", label: "Item 1", icon: "icon1" },
88
+ * { id: "2", label: "Item 2", icon: "icon2", badge: { text: "New" } },
89
+ * ]}
90
+ * maxCount={5}
91
+ * allowNegative={true}
92
+ * emptyMessage="No items available"
93
+ * onChange={(selectedItems) => console.log(selectedItems)}
94
+ * onClick={(itemId, isNegative) => console.log(itemId, isNegative)}
95
+ * />
96
+ * ```
97
+ */
75
98
  var CheckList = function CheckList(_ref2) {
76
99
  var _ref2$items = _ref2.items,
77
100
  items = _ref2$items === void 0 ? [] : _ref2$items,
@@ -14,6 +14,34 @@ var _excluded = ["items", "total", "color", "sortBy", "emptyTitle", "emptyMessag
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var emptyIcon = "M20.84 22.73L11.11 13H3V11H9.11L6.11 8H3V6H4.11L1.11 3L2.39 1.73L22.11 21.46L20.84 22.73M15 11H14.2L15 11.8V11M21 8V6H9.2L11.2 8H21M3 18H9V16H3V18Z";
17
+ /**
18
+ * Histogram component displays a bar chart of items with counts.
19
+ * It allows users to visualize the distribution of counts across different items.
20
+ * The component supports sorting, custom colors, and click handling for each item.
21
+ * It also provides an empty state when there are no items to display.
22
+ *
23
+ * @param {HistogramProps} props - The properties for the Histogram component.
24
+ * @returns {JSX.Element} - The rendered Histogram component.
25
+ *
26
+ * @example
27
+ * ```jsx
28
+ * <Histogram
29
+ * items={[
30
+ * { id: "1", label: "Item 1", count: 10 },
31
+ * { id: "2", label: "Item 2", count: 20 },
32
+ * { id: "3", label: "Item 3", count: 5, disabled: true },
33
+ * ]}
34
+ * total={30}
35
+ * color="primary-500"
36
+ * sortBy="count"
37
+ * emptyTitle="No Data Available"
38
+ * emptyMessage="Please check back later."
39
+ * onClick={(id, negative) => console.log(`Clicked on ${id}`, negative ? "Negative" : "Positive")}
40
+ * />
41
+ * ```
42
+ *
43
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-histogram--docs}
44
+ */
17
45
  var Histogram = function Histogram(_ref) {
18
46
  var _ref$items = _ref.items,
19
47
  items = _ref$items === void 0 ? [] : _ref$items,
@@ -23,6 +23,26 @@ var filterList = function filterList(items) {
23
23
  });
24
24
  return newList;
25
25
  };
26
+
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
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
45
+ */
26
46
  var useFilteredList = function useFilteredList(items, matcher) {
27
47
  var _useState = useState(),
28
48
  _useState2 = _slicedToArray(_useState, 2),
@@ -15,6 +15,26 @@ var makeRange = function makeRange(start, end) {
15
15
  return idx + start;
16
16
  });
17
17
  };
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
+ */
18
38
  var usePagination = function usePagination(_ref) {
19
39
  var totalRecords = _ref.totalRecords,
20
40
  _ref$currentPage = _ref.currentPage,
@@ -6,6 +6,35 @@ import { useRef, useState, useTransition, useEffect, useCallback } from 'react';
6
6
 
7
7
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
8
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ /**
10
+ * Custom hook to manage selection of items in a list.
11
+ * It allows toggling selection state of items, handling both selected and non-selected states.
12
+ * The hook maintains a selection state and provides a function to toggle the selection of items.
13
+ * It also supports callbacks for when the selection changes or when an item is clicked.
14
+ *
15
+ * @param items - The list of items to manage selection for.
16
+ * @param selected - An array of item IDs that are currently selected.
17
+ * @param nonselected - An array of item IDs that are currently non-selected.
18
+ * @param onChange - Callback function that is called when the selection changes.
19
+ * @param onClick - Callback function that is called when an item is clicked.
20
+ * @returns An object containing the current selection state and a function to toggle selection of items.
21
+ *
22
+ * @example
23
+ * ```jsx
24
+ * const { selection, toggleSelection } = useSelectableList({
25
+ * items: [{ id: '1', label: 'Item 1' }, { id: '2', label: 'Item 2' }],
26
+ * selected: ['1'],
27
+ * nonselected: ['2'],
28
+ * onChange: (selectedIds, nonSelectedIds) => {
29
+ * console.log('Selected:', selectedIds);
30
+ * console.log('Non-selected:', nonSelectedIds);
31
+ * },
32
+ * onClick: (id, isNegative) => {
33
+ * console.log(`Item ${id} clicked, isNegative: ${isNegative}`);
34
+ * },
35
+ * });
36
+ * ```
37
+ */
9
38
  var useSelectableList = function useSelectableList(_ref) {
10
39
  var items = _ref.items,
11
40
  selected = _ref.selected,
@@ -34,6 +34,11 @@ var action = {
34
34
  addFilter: "أضف عامل تصفية",
35
35
  addFilterNot: "إضافة لا تصفية"
36
36
  };
37
+ var data = {
38
+ tree: {
39
+ noItems: "لا توجد عناصر شجرة متوفرة"
40
+ }
41
+ };
37
42
  var ar = {
38
43
  label: label,
39
44
  tree: tree,
@@ -41,7 +46,8 @@ var ar = {
41
46
  json: json,
42
47
  checkList: checkList,
43
48
  histogram: histogram,
44
- action: action
49
+ action: action,
50
+ data: data
45
51
  };
46
52
 
47
- export { action, checkList, datagrid, ar as default, histogram, json, label, tree };
53
+ export { action, checkList, data, datagrid, ar as default, histogram, json, label, tree };
@@ -34,6 +34,11 @@ var action = {
34
34
  addFilter: "Add Filter",
35
35
  addFilterNot: "Add not Filter"
36
36
  };
37
+ var data = {
38
+ tree: {
39
+ noItems: "No tree items available"
40
+ }
41
+ };
37
42
  var en = {
38
43
  label: label,
39
44
  tree: tree,
@@ -41,7 +46,8 @@ var en = {
41
46
  json: json,
42
47
  checkList: checkList,
43
48
  histogram: histogram,
44
- action: action
49
+ action: action,
50
+ data: data
45
51
  };
46
52
 
47
- export { action, checkList, datagrid, en as default, histogram, json, label, tree };
53
+ export { action, checkList, data, datagrid, en as default, histogram, json, label, tree };