@react-fabric/data 1.0.0-beta.5 → 1.0.0-beta.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) 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 +48 -16
  4. package/dist/cjs/histogram/Histogram.js +48 -10
  5. package/dist/cjs/hooks/useFilteredList.js +20 -0
  6. package/dist/cjs/hooks/usePagination.js +27 -4
  7. package/dist/cjs/hooks/useSelectableList.js +29 -0
  8. package/dist/cjs/i18n/ar.json.js +8 -1
  9. package/dist/cjs/i18n/en.json.js +8 -1
  10. package/dist/cjs/json/JsonViewer.js +67 -27
  11. package/dist/cjs/pagination/Pagination.js +10 -0
  12. package/dist/cjs/table/AddColumn.js +1 -1
  13. package/dist/cjs/table/BodyCell.js +38 -5
  14. package/dist/cjs/table/BodyRow.js +107 -0
  15. package/dist/cjs/table/CheckboxCell.js +1 -1
  16. package/dist/cjs/table/ColumnFilters.js +97 -0
  17. package/dist/cjs/table/HeaderCell.js +70 -37
  18. package/dist/cjs/table/Table.js +113 -71
  19. package/dist/cjs/table/types.js +29 -0
  20. package/dist/cjs/table/useResizer.js +4 -4
  21. package/dist/cjs/table/useVirtualTable.js +122 -18
  22. package/dist/cjs/tree/TreeNode.js +45 -25
  23. package/dist/cjs/tree/TreePanel.js +28 -10
  24. package/dist/cjs/tree/useTree.js +97 -15
  25. package/dist/cjs/tree/utils.js +20 -5
  26. package/dist/cjs/virtual/Gallery.js +84 -35
  27. package/dist/cjs/virtual/List.js +82 -32
  28. package/dist/esm/checklist/CheckList.js +50 -18
  29. package/dist/esm/histogram/Histogram.js +49 -11
  30. package/dist/esm/hooks/useFilteredList.js +20 -0
  31. package/dist/esm/hooks/usePagination.js +27 -4
  32. package/dist/esm/hooks/useSelectableList.js +29 -0
  33. package/dist/esm/i18n/ar.json.js +8 -2
  34. package/dist/esm/i18n/en.json.js +8 -2
  35. package/dist/esm/json/JsonViewer.js +68 -28
  36. package/dist/esm/pagination/Pagination.js +10 -0
  37. package/dist/esm/table/AddColumn.js +1 -1
  38. package/dist/esm/table/BodyCell.js +38 -5
  39. package/dist/esm/table/BodyRow.js +107 -0
  40. package/dist/esm/table/CheckboxCell.js +1 -1
  41. package/dist/esm/table/ColumnFilters.js +97 -0
  42. package/dist/esm/table/HeaderCell.js +71 -38
  43. package/dist/esm/table/Table.js +115 -73
  44. package/dist/esm/table/types.js +29 -0
  45. package/dist/esm/table/useResizer.js +4 -4
  46. package/dist/esm/table/useVirtualTable.js +124 -20
  47. package/dist/esm/tree/TreeNode.js +47 -27
  48. package/dist/esm/tree/TreePanel.js +28 -10
  49. package/dist/esm/tree/useTree.js +99 -17
  50. package/dist/esm/tree/utils.js +20 -5
  51. package/dist/esm/virtual/Gallery.js +84 -35
  52. package/dist/esm/virtual/List.js +82 -32
  53. package/dist/types/checklist/CheckList.d.ts +24 -2
  54. package/dist/types/histogram/Histogram.d.ts +31 -4
  55. package/dist/types/hooks/useFilteredList.d.ts +20 -2
  56. package/dist/types/hooks/usePagination.d.ts +19 -0
  57. package/dist/types/hooks/useSelectableList.d.ts +29 -0
  58. package/dist/types/index.d.ts +1 -1
  59. package/dist/types/json/JsonViewer.d.ts +27 -2
  60. package/dist/types/pagination/Pagination.d.ts +10 -1
  61. package/dist/types/table/AddColumn.d.ts +2 -2
  62. package/dist/types/table/BodyCell.d.ts +4 -3
  63. package/dist/types/table/BodyRow.d.ts +20 -0
  64. package/dist/types/table/ColumnFilters.d.ts +9 -0
  65. package/dist/types/table/EmptyCell.d.ts +2 -2
  66. package/dist/types/table/HeaderCell.d.ts +2 -2
  67. package/dist/types/table/Table.d.ts +14 -1
  68. package/dist/types/table/types.d.ts +48 -7
  69. package/dist/types/table/useTableColumns.d.ts +6 -6
  70. package/dist/types/table/useVirtualTable.d.ts +23 -8
  71. package/dist/types/tree/TreeNode.d.ts +1 -1
  72. package/dist/types/tree/TreePanel.d.ts +42 -1
  73. package/dist/types/tree/types.d.ts +25 -5
  74. package/dist/types/tree/useTree.d.ts +3 -10
  75. package/dist/types/tree/utils.d.ts +4 -1
  76. package/dist/types/virtual/Gallery.d.ts +44 -4
  77. package/dist/types/virtual/List.d.ts +44 -4
  78. package/package.json +13 -10
  79. package/src/checklist/CheckList.tsx +103 -77
  80. package/src/histogram/Histogram.tsx +45 -11
  81. package/src/hooks/useFilteredList.tsx +19 -0
  82. package/src/hooks/usePagination.tsx +32 -7
  83. package/src/hooks/useSelectableList.ts +29 -0
  84. package/src/i18n/ar.json +5 -0
  85. package/src/i18n/en.json +5 -0
  86. package/src/index.ts +1 -1
  87. package/src/json/JsonViewer.tsx +71 -35
  88. package/src/pagination/Pagination.tsx +10 -0
  89. package/src/table/AddColumn.tsx +3 -3
  90. package/src/table/BodyCell.tsx +34 -5
  91. package/src/table/BodyRow.tsx +143 -0
  92. package/src/table/CheckboxCell.tsx +1 -1
  93. package/src/table/ColumnFilters.tsx +105 -0
  94. package/src/table/EmptyCell.tsx +2 -2
  95. package/src/table/HeaderCell.tsx +72 -14
  96. package/src/table/Table.tsx +177 -77
  97. package/src/table/types.ts +52 -6
  98. package/src/table/useResizer.ts +5 -3
  99. package/src/table/useTableColumns.ts +7 -7
  100. package/src/table/useVirtualTable.ts +146 -24
  101. package/src/tree/TreeNode.tsx +98 -56
  102. package/src/tree/TreePanel.tsx +64 -3
  103. package/src/tree/types.ts +32 -4
  104. package/src/tree/useTree.ts +109 -26
  105. package/src/tree/utils.ts +23 -8
  106. package/src/virtual/Gallery.tsx +96 -42
  107. package/src/virtual/List.tsx +82 -33
  108. package/dist/cjs/histogram/Histogram.module.css +0 -1
  109. package/dist/esm/histogram/Histogram.module.css +0 -1
@@ -21,14 +21,9 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- @layer comp {
25
- .histogram {
26
- .histoLabel {
27
- --tw-gradient-from: var(--color) var(--tw-gradient-from-position);
28
- --tw-gradient-to: color-mix(in lab, var(--color) 20%, var(--fabric-bg))
29
- var(--tw-gradient-to-position);
30
- --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
31
-
24
+ @layer components {
25
+ .fabric-histogram {
26
+ .fabric-histoLabel {
32
27
  background-color: color(from var(--color) srgb r g b / 5%);
33
28
 
34
29
  &:hover {
@@ -36,21 +31,29 @@
36
31
  }
37
32
 
38
33
  &[data-disabled="true"] {
39
- --color: theme(colors.tint.300);
34
+ --color: var(--color-tint-300);
40
35
 
41
- color: theme(colors.tint.600);
36
+ color: var(--color-tint-600);
42
37
  }
43
38
  }
44
39
 
45
- .histoBar {
40
+ .fabric-histoBar {
41
+ --tw-gradient-stops: var(
42
+ --tw-gradient-via-stops,
43
+ var(--tw-gradient-position)
44
+ ),
45
+ var(--color) var(--tw-gradient-from-position),
46
+ color-mix(in lab, var(--color) 20%, var(--fabric-bg))
47
+ var(--tw-gradient-to-position);
48
+
46
49
  box-shadow: -2px 0 0 var(--color) inset;
47
50
 
48
- :global([dir="rtl"]) & {
51
+ @variant rtl {
49
52
  box-shadow: 2px 0 0 var(--color) inset;
50
53
  }
51
54
  }
52
55
 
53
- .histoBadge {
56
+ .fabric-histoBadge {
54
57
  background-color: color(from var(--color) srgb r g b / 15%);
55
58
  }
56
59
  }
package/css/styles.css ADDED
@@ -0,0 +1,24 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2025 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ @import "./_histogram.css";
@@ -2,8 +2,8 @@
2
2
 
3
3
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
4
4
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
5
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
5
  var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
7
  var core = require('@react-fabric/core');
8
8
  var utilities = require('@react-fabric/utilities');
9
9
  var react = require('react');
@@ -11,10 +11,11 @@ var reactI18next = require('react-i18next');
11
11
  var useSelectableList = require('../hooks/useSelectableList.js');
12
12
  var jsxRuntime = require('react/jsx-runtime');
13
13
 
14
- var _excluded = ["items", "maxCount", "allowNegative", "emptyMessage", "sortItems"];
14
+ var _excluded = ["id", "allowNegative", "selected", "icon", "label", "isDisabled", "onClick", "badge"],
15
+ _excluded2 = ["items", "maxCount", "allowNegative", "emptyMessage", "sortItems", "selected", "nonselected", "onChange", "onClick"];
15
16
  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; }
16
17
  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; }
17
- var CheckItem = /*#__PURE__*/react.memo(function (_ref) {
18
+ var CheckItem = function CheckItem(_ref) {
18
19
  var id = _ref.id,
19
20
  allowNegative = _ref.allowNegative,
20
21
  selected = _ref.selected,
@@ -22,8 +23,9 @@ var CheckItem = /*#__PURE__*/react.memo(function (_ref) {
22
23
  label = _ref.label,
23
24
  isDisabled = _ref.isDisabled,
24
25
  _onClick = _ref.onClick,
25
- badge = _ref.badge;
26
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
26
+ badge = _ref.badge,
27
+ aria = _objectWithoutProperties(_ref, _excluded);
28
+ return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
27
29
  role: "none",
28
30
  className: "ax-checkList__item",
29
31
  "data-disabled": isDisabled,
@@ -32,7 +34,8 @@ var CheckItem = /*#__PURE__*/react.memo(function (_ref) {
32
34
  },
33
35
  onContextMenu: function onContextMenu(e) {
34
36
  return [allowNegative && _onClick(id, true), e.preventDefault()];
35
- },
37
+ }
38
+ }, aria), {}, {
36
39
  children: [!allowNegative && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
37
40
  "data-type": "checkbox",
38
41
  className: "ax-checkList__checkbox",
@@ -67,9 +70,31 @@ var CheckItem = /*#__PURE__*/react.memo(function (_ref) {
67
70
  }), /*#__PURE__*/jsxRuntime.jsx("label", {
68
71
  children: label
69
72
  }), /*#__PURE__*/jsxRuntime.jsx(core.Badge, _objectSpread({}, badge))]
70
- });
71
- });
72
- CheckItem.displayName = "CheckItem";
73
+ }));
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
+ */
73
98
  var CheckList = function CheckList(_ref2) {
74
99
  var _ref2$items = _ref2.items,
75
100
  items = _ref2$items === void 0 ? [] : _ref2$items,
@@ -79,12 +104,20 @@ var CheckList = function CheckList(_ref2) {
79
104
  emptyMessage = _ref2.emptyMessage,
80
105
  _ref2$sortItems = _ref2.sortItems,
81
106
  sortItems = _ref2$sortItems === void 0 ? true : _ref2$sortItems,
82
- props = _objectWithoutProperties(_ref2, _excluded);
107
+ selected = _ref2.selected,
108
+ nonselected = _ref2.nonselected,
109
+ onChange = _ref2.onChange,
110
+ onClick = _ref2.onClick,
111
+ aria = _objectWithoutProperties(_ref2, _excluded2);
83
112
  var _useTranslation = reactI18next.useTranslation("data"),
84
113
  t = _useTranslation.t;
85
- var _useSelectableList = useSelectableList.useSelectableList(_objectSpread({
86
- items: items
87
- }, props)),
114
+ var _useSelectableList = useSelectableList.useSelectableList({
115
+ items: items,
116
+ selected: selected,
117
+ nonselected: nonselected,
118
+ onChange: onChange,
119
+ onClick: onClick
120
+ }),
88
121
  selection = _useSelectableList.selection,
89
122
  toggleSelection = _useSelectableList.toggleSelection;
90
123
  var _useState = react.useState(false),
@@ -105,8 +138,7 @@ var CheckList = function CheckList(_ref2) {
105
138
  return 0;
106
139
  }).slice(0, !showMore && maxCount > 0 ? maxCount : undefined);
107
140
  }, [items, selection, maxCount, showMore, sortItems]);
108
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
109
- className: "ax-checkList",
141
+ return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({}, aria), {}, {
110
142
  children: [listItems.map(function (item, index) {
111
143
  return /*#__PURE__*/react.createElement(CheckItem, _objectSpread(_objectSpread({}, item), {}, {
112
144
  key: index,
@@ -128,7 +160,7 @@ var CheckList = function CheckList(_ref2) {
128
160
  className: "text-sm",
129
161
  message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("checkList.empty")
130
162
  })]
131
- });
163
+ }));
132
164
  };
133
165
 
134
166
  exports.CheckList = CheckList;
@@ -1,26 +1,59 @@
1
1
  'use strict';
2
2
 
3
+ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
3
4
  var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
5
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
4
6
  var core = require('@react-fabric/core');
5
7
  var utilities = require('@react-fabric/utilities');
6
8
  var classNames = require('classnames');
7
9
  var react = require('react');
8
10
  var reactI18next = require('react-i18next');
9
- var Histogram_module = require('./Histogram.module.css');
10
11
  var jsxRuntime = require('react/jsx-runtime');
11
12
 
13
+ var _excluded = ["items", "total", "color", "sortBy", "emptyTitle", "emptyMessage", "onClick"];
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
+ 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; }
12
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
+ */
13
45
  var Histogram = function Histogram(_ref) {
14
46
  var _ref$items = _ref.items,
15
47
  items = _ref$items === void 0 ? [] : _ref$items,
16
48
  total = _ref.total,
17
49
  _ref$color = _ref.color,
18
- color = _ref$color === void 0 ? "primary" : _ref$color,
50
+ color = _ref$color === void 0 ? "primary-500" : _ref$color,
19
51
  _ref$sortBy = _ref.sortBy,
20
52
  sortBy = _ref$sortBy === void 0 ? "count" : _ref$sortBy,
21
53
  emptyTitle = _ref.emptyTitle,
22
54
  emptyMessage = _ref.emptyMessage,
23
- _onClick = _ref.onClick;
55
+ _onClick = _ref.onClick,
56
+ aria = _objectWithoutProperties(_ref, _excluded);
24
57
  var _useTranslation = reactI18next.useTranslation("data"),
25
58
  t = _useTranslation.t;
26
59
  var maxTotal = react.useMemo(function () {
@@ -32,10 +65,11 @@ var Histogram = function Histogram(_ref) {
32
65
  var sorted = react.useMemo(function () {
33
66
  return items.sort(utilities.compareValues(sortBy === "label" ? "asc" : "desc", sortBy));
34
67
  }, [items, sortBy]);
35
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
36
- className: Histogram_module.histogram,
68
+ return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
69
+ className: "fabric-histogram from-0% to-100%"
70
+ }, aria), {}, {
37
71
  style: {
38
- "--color": "var(--".concat(color, ")")
72
+ "--color": utilities.isColor(color) ? color : "var(--color-".concat(color, ")")
39
73
  },
40
74
  children: [sorted.length === 0 && /*#__PURE__*/jsxRuntime.jsx(core.EmptyContent, {
41
75
  icon: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
@@ -45,15 +79,17 @@ var Histogram = function Histogram(_ref) {
45
79
  title: emptyTitle,
46
80
  message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("histogram.empty")
47
81
  }), sorted === null || sorted === void 0 ? void 0 : sorted.map(function (item) {
82
+ var _item$total;
48
83
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
49
84
  role: "none",
50
85
  "data-disabled": item.count === 0 || item.disabled,
51
- className: classNames("relative cursor-pointer flex flex-nowrap items-center select-none overflow-hidden min-h-6 my-px", Histogram_module.histoLabel, (item.count === 0 || item.disabled) && "pointer-events-none"),
86
+ className: classNames("relative cursor-pointer flex flex-nowrap items-center select-none overflow-hidden min-h-6 my-px", "fabric-histoLabel", (((_item$total = item.total) !== null && _item$total !== void 0 ? _item$total : item.count) === 0 || item.disabled) && "pointer-events-none"),
87
+ "data-testid": item.id,
52
88
  onClick: function onClick(e) {
53
89
  return [_onClick === null || _onClick === void 0 ? void 0 : _onClick(item.id), e.stopPropagation()];
54
90
  },
55
91
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
56
- className: classNames("absolute z-0 inset-0 opacity-50 min-w-2 ltr:bg-gradient-to-r rtl:bg-gradient-to-l from-0% to-100%", Histogram_module.histoBar),
92
+ className: classNames("absolute z-0 inset-0 opacity-50 min-w-2 ltr:bg-gradient-to-r rtl:bg-gradient-to-l", "fabric-histoBar"),
57
93
  style: {
58
94
  width: "".concat(Math.min(item.count / maxTotal, 1) * 100, "%")
59
95
  }
@@ -62,6 +98,7 @@ var Histogram = function Histogram(_ref) {
62
98
  actions: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
63
99
  color: "danger",
64
100
  size: "sm",
101
+ stopPropagation: true,
65
102
  icon: core.CoreIcons.funnelMinus,
66
103
  "aria-label": "Filter Negative",
67
104
  onClick: function onClick() {
@@ -70,6 +107,7 @@ var Histogram = function Histogram(_ref) {
70
107
  }, "negative"), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
71
108
  color: "primary",
72
109
  size: "sm",
110
+ stopPropagation: true,
73
111
  icon: core.CoreIcons.funnelPlus,
74
112
  "aria-label": "Filter",
75
113
  onClick: function onClick() {
@@ -78,12 +116,12 @@ var Histogram = function Histogram(_ref) {
78
116
  }, "positive")],
79
117
  children: item.label
80
118
  }), /*#__PURE__*/jsxRuntime.jsx("span", {
81
- className: classNames("z-1 rounded-full text-xs font-medium px-2 py-1 leading-none", Histogram_module.histoBadge),
119
+ className: classNames("z-1 rounded-full text-xs font-medium px-2 py-1 leading-none", "fabric-histoBadge"),
82
120
  children: utilities.Format.number(item.count)
83
121
  })]
84
122
  }, item.id);
85
123
  })]
86
- });
124
+ }));
87
125
  };
88
126
 
89
127
  exports.Histogram = Histogram;
@@ -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,
@@ -58,9 +78,12 @@ var usePagination = function usePagination(_ref) {
58
78
 
59
79
  /** ***************** set page *******************/
60
80
  react.useEffect(function () {
61
- setPage(Math.min(currentPage, totalPages - 1));
62
- onChange === null || onChange === void 0 || onChange(Math.min(currentPage, totalPages - 1));
63
- }, [currentPage, totalPages]);
81
+ if (totalRecords > -1) {
82
+ var actual = Math.min(currentPage, totalPages - 1);
83
+ setPage(actual);
84
+ actual !== currentPage && (onChange === null || onChange === void 0 ? void 0 : onChange(actual));
85
+ }
86
+ }, [currentPage, totalRecords, totalPages]);
64
87
  var headLabel = react.useMemo(function () {
65
88
  return /*#__PURE__*/jsxRuntime.jsxs("span", {
66
89
  className: "text-muted",
@@ -72,7 +95,7 @@ var usePagination = function usePagination(_ref) {
72
95
  startTransition(function () {
73
96
  return onChange === null || onChange === void 0 ? void 0 : onChange(page);
74
97
  });
75
- }, []);
98
+ }, [onChange]);
76
99
  return {
77
100
  page: page,
78
101
  totalPages: totalPages,
@@ -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;
@@ -99,6 +99,11 @@ var JsonEntry = function JsonEntry(_ref3) {
99
99
  clamp: 3,
100
100
  children: ret
101
101
  });
102
+ } else {
103
+ ret = /*#__PURE__*/jsxRuntime.jsx("div", {
104
+ className: "break-words",
105
+ children: ret
106
+ });
102
107
  }
103
108
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
104
109
  children: [ret, utilities.isObject(value) && value._score_ > 0 && /*#__PURE__*/jsxRuntime.jsx(core.Meter, {
@@ -120,28 +125,30 @@ var JsonEntry = function JsonEntry(_ref3) {
120
125
  }, [filters, path, pathWithoutOrdinal]);
121
126
  var labelDisplay = react.useMemo(function () {
122
127
  var _labeler;
123
- return /*#__PURE__*/jsxRuntime.jsx(core.ActionLabel, {
124
- className: "text-dimmed text-sm px-2 flex-1 truncate",
125
- actions: !canExpand && canFilter ? [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
126
- color: "danger",
127
- size: "sm",
128
- variant: "link",
129
- icon: core.CoreIcons.funnelMinus,
130
- "aria-label": "Filter Negative",
131
- onClick: function onClick() {
132
- return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue, true);
133
- }
134
- }, "negative"), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
135
- color: "primary",
136
- size: "sm",
137
- variant: "link",
138
- icon: core.CoreIcons.funnelPlus,
139
- "aria-label": "Filter",
140
- onClick: function onClick() {
141
- return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue);
142
- }
143
- }, "positive")] : [],
144
- children: (_labeler = labeler === null || labeler === void 0 ? void 0 : labeler(path)) !== null && _labeler !== void 0 ? _labeler : field
128
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
129
+ className: classNames("text-dimmed text-sm px-2 flex-1 group", inline ? "truncate" : "break-words"),
130
+ children: [!canExpand && canFilter && /*#__PURE__*/jsxRuntime.jsxs("div", {
131
+ className: "hidden pe-1 group-hover:inline-block",
132
+ children: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
133
+ color: "danger",
134
+ size: "xs",
135
+ variant: "link",
136
+ icon: core.CoreIcons.funnelMinus,
137
+ "aria-label": "Filter Negative",
138
+ onClick: function onClick() {
139
+ return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue, true);
140
+ }
141
+ }, "negative"), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
142
+ color: "primary",
143
+ size: "xs",
144
+ variant: "link",
145
+ icon: core.CoreIcons.funnelPlus,
146
+ "aria-label": "Filter",
147
+ onClick: function onClick() {
148
+ return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue);
149
+ }
150
+ }, "positive")]
151
+ }), (_labeler = labeler === null || labeler === void 0 ? void 0 : labeler(path)) !== null && _labeler !== void 0 ? _labeler : field]
145
152
  });
146
153
  }, [field, labeler, pathWithoutOrdinal, actualValue, canExpand, canFilter]);
147
154
  return /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
@@ -164,11 +171,14 @@ var JsonEntry = function JsonEntry(_ref3) {
164
171
  icon: expanded ? core.CoreIcons.chevronDown : core.CoreIcons.chevronRight
165
172
  }), labelDisplay]
166
173
  }), display && /*#__PURE__*/jsxRuntime.jsxs("div", {
167
- className: classNames("px-2", inline && "flex-1"),
174
+ className: classNames("px-2 flex flex-nowrap overflow-hidden", inline && "flex-1"),
168
175
  children: [canCopy && /*#__PURE__*/jsxRuntime.jsx(core.Copy, {
169
176
  size: "xs",
170
177
  text: actualValue
171
- }), display]
178
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
179
+ className: "flex-1",
180
+ children: display
181
+ })]
172
182
  })]
173
183
  }), !showPropertyTree && !children && /*#__PURE__*/jsxRuntime.jsxs("div", {
174
184
  className: classNames("py-2", inline && "flex flex-nowrap items-center"),
@@ -180,11 +190,14 @@ var JsonEntry = function JsonEntry(_ref3) {
180
190
  },
181
191
  children: labelDisplay
182
192
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
183
- className: classNames("px-2", inline && "flex-1"),
193
+ className: classNames("px-2 flex flex-nowrap overflow-hidden", inline && "flex-1"),
184
194
  children: [canCopy && /*#__PURE__*/jsxRuntime.jsx(core.Copy, {
185
195
  size: "xs",
186
196
  text: value
187
- }), display]
197
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
198
+ className: "flex-1",
199
+ children: display
200
+ })]
188
201
  })]
189
202
  }), expanded && (children === null || children === void 0 ? void 0 : children.map(function (item) {
190
203
  return /*#__PURE__*/jsxRuntime.jsx(JsonEntry, _objectSpread(_objectSpread({}, item), {}, {
@@ -202,6 +215,33 @@ var JsonEntry = function JsonEntry(_ref3) {
202
215
  }))]
203
216
  });
204
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
+ */
205
245
  var JsonViewer = function JsonViewer(_ref5) {
206
246
  var className = _ref5.className,
207
247
  json = _ref5.json,
@@ -223,7 +263,7 @@ var JsonViewer = function JsonViewer(_ref5) {
223
263
  return reduceObject(json);
224
264
  }, [json]);
225
265
  return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, rest), {}, {
226
- className: classNames(className, "p-4 bg-alternate"),
266
+ className: classNames(className, "bg-alternate"),
227
267
  children: !utilities.isEmpty(json) ? list.map(function (item) {
228
268
  return /*#__PURE__*/jsxRuntime.jsx(JsonEntry, _objectSpread(_objectSpread({}, item), {}, {
229
269
  copy: copy,
@@ -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,