@react-fabric/data 1.0.0-beta.6 → 1.0.0-beta.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src/histogram/Histogram.module.css → css/_histogram.css} +16 -13
- package/{dist/esm/tree/types.js → css/styles.css} +2 -7
- package/dist/cjs/checklist/CheckList.js +27 -4
- package/dist/cjs/histogram/Histogram.js +39 -9
- package/dist/cjs/hooks/useFilteredList.js +88 -10
- package/dist/cjs/hooks/usePagination.js +27 -4
- package/dist/cjs/hooks/useSelectableList.js +29 -0
- package/dist/cjs/i18n/ar.json.js +8 -1
- package/dist/cjs/i18n/en.json.js +8 -1
- package/dist/cjs/json/JsonViewer.js +68 -28
- package/dist/cjs/pagination/Pagination.js +14 -4
- package/dist/cjs/table/AddColumn.js +3 -3
- package/dist/cjs/table/BodyCell.js +14 -6
- package/dist/cjs/table/BodyRow.js +4 -4
- package/dist/cjs/table/CheckboxCell.js +2 -2
- package/dist/cjs/table/ColumnFilters.js +97 -0
- package/dist/cjs/table/HeaderCell.js +71 -43
- package/dist/cjs/table/Table.js +62 -13
- package/dist/cjs/table/types.js +29 -0
- package/dist/cjs/table/useResizer.js +4 -4
- package/dist/cjs/table/useVirtualTable.js +127 -19
- package/dist/cjs/tree/TreeNode.js +50 -32
- package/dist/cjs/tree/TreePanel.js +52 -19
- package/dist/cjs/tree/useTree.js +199 -38
- package/dist/cjs/tree/utils.js +39 -12
- package/dist/cjs/virtual/Gallery.js +97 -45
- package/dist/cjs/virtual/List.js +93 -39
- package/dist/cjs/virtual/Scroller.js +16 -8
- package/dist/esm/checklist/CheckList.js +28 -5
- package/dist/esm/histogram/Histogram.js +41 -11
- package/dist/esm/hooks/useFilteredList.js +89 -11
- package/dist/esm/hooks/usePagination.js +27 -4
- package/dist/esm/hooks/useSelectableList.js +29 -0
- package/dist/esm/i18n/ar.json.js +8 -2
- package/dist/esm/i18n/en.json.js +8 -2
- package/dist/esm/json/JsonViewer.js +69 -29
- package/dist/esm/pagination/Pagination.js +15 -5
- package/dist/esm/table/AddColumn.js +4 -4
- package/dist/esm/table/BodyCell.js +15 -7
- package/dist/esm/table/BodyRow.js +4 -4
- package/dist/esm/table/CheckboxCell.js +3 -3
- package/dist/esm/table/ColumnFilters.js +97 -0
- package/dist/esm/table/HeaderCell.js +72 -44
- package/dist/esm/table/Table.js +63 -14
- package/dist/esm/table/types.js +29 -0
- package/dist/esm/table/useResizer.js +4 -4
- package/dist/esm/table/useVirtualTable.js +129 -21
- package/dist/esm/tree/TreeNode.js +53 -35
- package/dist/esm/tree/TreePanel.js +54 -21
- package/dist/esm/tree/useTree.js +202 -41
- package/dist/esm/tree/utils.js +40 -13
- package/dist/esm/virtual/Gallery.js +97 -45
- package/dist/esm/virtual/List.js +93 -39
- package/dist/esm/virtual/Scroller.js +17 -9
- package/dist/types/checklist/CheckList.d.ts +22 -0
- package/dist/types/histogram/Histogram.d.ts +28 -1
- package/dist/types/hooks/useFilteredList.d.ts +66 -5
- package/dist/types/hooks/usePagination.d.ts +19 -0
- package/dist/types/hooks/useSelectableList.d.ts +29 -0
- package/dist/types/json/JsonViewer.d.ts +27 -2
- package/dist/types/pagination/Pagination.d.ts +10 -1
- package/dist/types/table/ColumnFilters.d.ts +9 -0
- package/dist/types/table/HeaderCell.d.ts +1 -1
- package/dist/types/table/Table.d.ts +14 -1
- package/dist/types/table/types.d.ts +46 -7
- package/dist/types/table/useVirtualTable.d.ts +23 -9
- package/dist/types/tree/TreeNode.d.ts +1 -1
- package/dist/types/tree/TreePanel.d.ts +42 -1
- package/dist/types/tree/types.d.ts +65 -21
- package/dist/types/tree/useTree.d.ts +9 -10
- package/dist/types/tree/utils.d.ts +10 -3
- package/dist/types/virtual/Gallery.d.ts +42 -3
- package/dist/types/virtual/List.d.ts +42 -3
- package/package.json +16 -14
- package/src/checklist/CheckList.tsx +39 -7
- package/src/histogram/Histogram.tsx +43 -19
- package/src/hooks/useFilteredList.tsx +109 -9
- package/src/hooks/usePagination.tsx +32 -7
- package/src/hooks/useSelectableList.ts +29 -0
- package/src/i18n/ar.json +5 -0
- package/src/i18n/en.json +5 -0
- package/src/json/JsonViewer.tsx +76 -37
- package/src/pagination/Pagination.tsx +15 -5
- package/src/table/AddColumn.tsx +4 -4
- package/src/table/BodyCell.tsx +24 -7
- package/src/table/BodyRow.tsx +7 -4
- package/src/table/CheckboxCell.tsx +5 -5
- package/src/table/ColumnFilters.tsx +105 -0
- package/src/table/HeaderCell.tsx +74 -21
- package/src/table/Table.tsx +107 -12
- package/src/table/types.ts +49 -10
- package/src/table/useResizer.ts +5 -3
- package/src/table/useVirtualTable.ts +158 -27
- package/src/tree/TreeNode.tsx +96 -62
- package/src/tree/TreePanel.tsx +88 -22
- package/src/tree/types.ts +73 -23
- package/src/tree/useTree.ts +220 -44
- package/src/tree/utils.ts +58 -20
- package/src/virtual/Gallery.tsx +118 -54
- package/src/virtual/List.tsx +99 -39
- package/src/virtual/Scroller.tsx +25 -9
- package/dist/cjs/histogram/Histogram.module.css +0 -1
- package/dist/cjs/tree/types.js +0 -30
- 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
|
|
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:
|
|
34
|
+
--color: var(--color-tint-300);
|
|
40
35
|
|
|
41
|
-
color:
|
|
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
|
-
|
|
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
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
1
|
/*
|
|
4
2
|
* React Fabric
|
|
5
3
|
* @version: 1.0.0
|
|
6
4
|
*
|
|
7
5
|
*
|
|
8
6
|
* The MIT License (MIT)
|
|
9
|
-
* Copyright (c)
|
|
7
|
+
* Copyright (c) 2025 Adarsh Pastakia
|
|
10
8
|
*
|
|
11
9
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
10
|
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
@@ -23,7 +21,4 @@
|
|
|
23
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
22
|
*/
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
var iconCollapseAll = "M3.984 11.016h16.031v1.969h-16.031v-1.969zM15.984 5.016l-3.984 3.984-3.984-3.984h3v-4.031h1.969v4.031h3zM8.016 18.984l3.984-3.984 3.984 3.984h-3v4.031h-1.969v-4.031h-3z";
|
|
28
|
-
|
|
29
|
-
export { iconCollapseAll, iconExpandAll };
|
|
24
|
+
@import "./_histogram.css";
|
|
@@ -40,12 +40,12 @@ var CheckItem = function CheckItem(_ref) {
|
|
|
40
40
|
"data-type": "checkbox",
|
|
41
41
|
className: "ax-checkList__checkbox",
|
|
42
42
|
"data-selected": selected === 1,
|
|
43
|
-
icon: selected ?
|
|
43
|
+
icon: selected ? "icon-[mdi--checkbox-marked]" : "icon-[mdi--checkbox-blank-outline]"
|
|
44
44
|
}), allowNegative && /*#__PURE__*/jsxRuntime.jsxs(react.Fragment, {
|
|
45
45
|
children: [/*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
46
46
|
"data-type": "multiple",
|
|
47
47
|
className: "ax-checkList__checkbox",
|
|
48
|
-
icon: selected === 1 ?
|
|
48
|
+
icon: selected === 1 ? "icon-[mdi--plus-box-outline]" : selected === -1 ? "icon-[mdi--minus-box-outline]" : "icon-[mdi--checkbox-blank-outline]",
|
|
49
49
|
"data-selected": selected
|
|
50
50
|
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
51
51
|
className: "ax-checkList__checkbox",
|
|
@@ -54,14 +54,14 @@ var CheckItem = function CheckItem(_ref) {
|
|
|
54
54
|
onClick: function onClick(e) {
|
|
55
55
|
return [(_onClick(id, false), e.stopPropagation())];
|
|
56
56
|
},
|
|
57
|
-
icon: selected === 1 ?
|
|
57
|
+
icon: selected === 1 ? "icon-[mdi--plus-box]" : "icon-[mdi--plus-box-outline]",
|
|
58
58
|
"data-selected": selected === 1
|
|
59
59
|
}), /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
60
60
|
"data-type": "negative",
|
|
61
61
|
onClick: function onClick(e) {
|
|
62
62
|
return [(_onClick(id, true), e.stopPropagation())];
|
|
63
63
|
},
|
|
64
|
-
icon: selected === -1 ?
|
|
64
|
+
icon: selected === -1 ? "icon-[mdi--minus-box]" : "icon-[mdi--minus-box-outline]",
|
|
65
65
|
"data-selected": selected === -1
|
|
66
66
|
})]
|
|
67
67
|
})]
|
|
@@ -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,
|
|
@@ -8,19 +8,46 @@ var utilities = require('@react-fabric/utilities');
|
|
|
8
8
|
var classNames = require('classnames');
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var reactI18next = require('react-i18next');
|
|
11
|
-
var Histogram_module = require('./Histogram.module.css');
|
|
12
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
12
|
|
|
14
13
|
var _excluded = ["items", "total", "color", "sortBy", "emptyTitle", "emptyMessage", "onClick"];
|
|
15
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; }
|
|
16
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; }
|
|
17
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
|
+
*/
|
|
18
45
|
var Histogram = function Histogram(_ref) {
|
|
19
46
|
var _ref$items = _ref.items,
|
|
20
47
|
items = _ref$items === void 0 ? [] : _ref$items,
|
|
21
48
|
total = _ref.total,
|
|
22
49
|
_ref$color = _ref.color,
|
|
23
|
-
color = _ref$color === void 0 ? "primary" : _ref$color,
|
|
50
|
+
color = _ref$color === void 0 ? "primary-500" : _ref$color,
|
|
24
51
|
_ref$sortBy = _ref.sortBy,
|
|
25
52
|
sortBy = _ref$sortBy === void 0 ? "count" : _ref$sortBy,
|
|
26
53
|
emptyTitle = _ref.emptyTitle,
|
|
@@ -39,10 +66,10 @@ var Histogram = function Histogram(_ref) {
|
|
|
39
66
|
return items.sort(utilities.compareValues(sortBy === "label" ? "asc" : "desc", sortBy));
|
|
40
67
|
}, [items, sortBy]);
|
|
41
68
|
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
|
|
42
|
-
className:
|
|
69
|
+
className: "fabric-histogram from-0% to-100%"
|
|
43
70
|
}, aria), {}, {
|
|
44
71
|
style: {
|
|
45
|
-
"--color": "var(--".concat(color, ")")
|
|
72
|
+
"--color": utilities.isColor(color) ? color : "var(--color-".concat(color, ")")
|
|
46
73
|
},
|
|
47
74
|
children: [sorted.length === 0 && /*#__PURE__*/jsxRuntime.jsx(core.EmptyContent, {
|
|
48
75
|
icon: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
@@ -52,16 +79,17 @@ var Histogram = function Histogram(_ref) {
|
|
|
52
79
|
title: emptyTitle,
|
|
53
80
|
message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("histogram.empty")
|
|
54
81
|
}), sorted === null || sorted === void 0 ? void 0 : sorted.map(function (item) {
|
|
82
|
+
var _item$total;
|
|
55
83
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
56
84
|
role: "none",
|
|
57
85
|
"data-disabled": item.count === 0 || item.disabled,
|
|
58
|
-
className: classNames("relative cursor-pointer flex flex-nowrap items-center select-none overflow-hidden min-h-6 my-px",
|
|
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"),
|
|
59
87
|
"data-testid": item.id,
|
|
60
88
|
onClick: function onClick(e) {
|
|
61
89
|
return [_onClick === null || _onClick === void 0 ? void 0 : _onClick(item.id), e.stopPropagation()];
|
|
62
90
|
},
|
|
63
91
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
64
|
-
className: classNames("absolute z-0 inset-0 opacity-50 min-w-2 ltr:bg-
|
|
92
|
+
className: classNames("absolute z-0 inset-0 opacity-50 min-w-2 ltr:bg-linear-to-r rtl:bg-linear-to-l", "fabric-histoBar"),
|
|
65
93
|
style: {
|
|
66
94
|
width: "".concat(Math.min(item.count / maxTotal, 1) * 100, "%")
|
|
67
95
|
}
|
|
@@ -70,7 +98,8 @@ var Histogram = function Histogram(_ref) {
|
|
|
70
98
|
actions: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
71
99
|
color: "danger",
|
|
72
100
|
size: "sm",
|
|
73
|
-
|
|
101
|
+
stopPropagation: true,
|
|
102
|
+
icon: "icon-[mdi--filter-minus]",
|
|
74
103
|
"aria-label": "Filter Negative",
|
|
75
104
|
onClick: function onClick() {
|
|
76
105
|
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(item.id, true);
|
|
@@ -78,7 +107,8 @@ var Histogram = function Histogram(_ref) {
|
|
|
78
107
|
}, "negative"), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
79
108
|
color: "primary",
|
|
80
109
|
size: "sm",
|
|
81
|
-
|
|
110
|
+
stopPropagation: true,
|
|
111
|
+
icon: "icon-[mdi--filter-plus]",
|
|
82
112
|
"aria-label": "Filter",
|
|
83
113
|
onClick: function onClick() {
|
|
84
114
|
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(item.id);
|
|
@@ -86,7 +116,7 @@ var Histogram = function Histogram(_ref) {
|
|
|
86
116
|
}, "positive")],
|
|
87
117
|
children: item.label
|
|
88
118
|
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
89
|
-
className: classNames("z-1 rounded-full text-xs font-medium px-2 py-1 leading-none",
|
|
119
|
+
className: classNames("z-1 rounded-full text-xs font-medium px-2 py-1 leading-none", "fabric-histoBadge"),
|
|
90
120
|
children: utilities.Format.number(item.count)
|
|
91
121
|
})]
|
|
92
122
|
}, item.id);
|
|
@@ -6,15 +6,29 @@ var react = require('react');
|
|
|
6
6
|
|
|
7
7
|
var filterList = function filterList(items) {
|
|
8
8
|
var query = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
9
|
-
var
|
|
9
|
+
var matchAll = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
10
|
+
var matcher = arguments.length > 3 ? arguments[3] : undefined;
|
|
10
11
|
var newList = [];
|
|
11
12
|
items.forEach(function (item) {
|
|
12
13
|
if (matcher) {
|
|
13
14
|
return (matcher === null || matcher === void 0 ? void 0 : matcher(item, query)) && newList.push(item);
|
|
14
15
|
}
|
|
15
|
-
if (query && utilities.
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (query && utilities.isArray(query) && query.length > 0) {
|
|
17
|
+
if (matchAll && query.every(function (q) {
|
|
18
|
+
var _item$label;
|
|
19
|
+
return utilities.matchString((_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : item.toString(), q);
|
|
20
|
+
})) {
|
|
21
|
+
return newList.push(item);
|
|
22
|
+
}
|
|
23
|
+
if (!matchAll && query.some(function (q) {
|
|
24
|
+
var _item$label2;
|
|
25
|
+
return utilities.matchString((_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : item.toString(), q);
|
|
26
|
+
})) {
|
|
27
|
+
return newList.push(item);
|
|
28
|
+
}
|
|
29
|
+
} else if (query && utilities.isString(query)) {
|
|
30
|
+
var _item$label3;
|
|
31
|
+
if (utilities.matchString((_item$label3 = item.label) !== null && _item$label3 !== void 0 ? _item$label3 : item.toString(), query)) {
|
|
18
32
|
return newList.push(item);
|
|
19
33
|
}
|
|
20
34
|
} else {
|
|
@@ -23,7 +37,69 @@ var filterList = function filterList(items) {
|
|
|
23
37
|
});
|
|
24
38
|
return newList;
|
|
25
39
|
};
|
|
26
|
-
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Custom hook to filter a list of items based on a query.
|
|
43
|
+
* It provides a way to search through the items and returns the filtered list.
|
|
44
|
+
* The hook uses a deferred value to optimize performance during transitions.
|
|
45
|
+
* It also allows for a custom matcher function to define how items should be matched against the query.
|
|
46
|
+
*
|
|
47
|
+
* @param items - The list of items to filter.
|
|
48
|
+
* @param matchAll - Match all phrases in the query list against the items.
|
|
49
|
+
* @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```jsx
|
|
53
|
+
* useFilteredList(items, (item, query) => {
|
|
54
|
+
* return item.name.includes(query);
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Custom hook to filter a list of items based on a query.
|
|
63
|
+
* It provides a way to search through the items and returns the filtered list.
|
|
64
|
+
* The hook uses a deferred value to optimize performance during transitions.
|
|
65
|
+
* It also allows for a custom matcher function to define how items should be matched against the query.
|
|
66
|
+
*
|
|
67
|
+
* @param items - The list of items to filter.
|
|
68
|
+
* @param matcher - An optional function to match items against the query.
|
|
69
|
+
* @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```jsx
|
|
73
|
+
* useFilteredList(items, (item, query) => {
|
|
74
|
+
* return item.name.includes(query);
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Custom hook to filter a list of items based on a query.
|
|
83
|
+
* It provides a way to search through the items and returns the filtered list.
|
|
84
|
+
* The hook uses a deferred value to optimize performance during transitions.
|
|
85
|
+
* It also allows for a custom matcher function to define how items should be matched against the query.
|
|
86
|
+
*
|
|
87
|
+
* @param items - The list of items to filter.
|
|
88
|
+
* @param matchAll - Match all phrases in the query list against the items.
|
|
89
|
+
* @param matcher - An optional function to match items against the query.
|
|
90
|
+
* @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```jsx
|
|
94
|
+
* useFilteredList(items, (item, query) => {
|
|
95
|
+
* return item.name.includes(query);
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
function useFilteredList(items, matchAll, matcher) {
|
|
27
103
|
var _useState = react.useState(),
|
|
28
104
|
_useState2 = _slicedToArray(_useState, 2),
|
|
29
105
|
query = _useState2[0],
|
|
@@ -37,20 +113,22 @@ var useFilteredList = function useFilteredList(items, matcher) {
|
|
|
37
113
|
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
38
114
|
isSearching = _useTransition2[0],
|
|
39
115
|
startTransition = _useTransition2[1];
|
|
40
|
-
var
|
|
116
|
+
var matchingAll = typeof matchAll === "boolean" ? matchAll : true;
|
|
117
|
+
var matcherFn = typeof matchAll === "function" ? matchAll : matcher;
|
|
118
|
+
var filterItems = react.useCallback(function (items, query, matchingAll) {
|
|
41
119
|
return startTransition(function () {
|
|
42
|
-
return setFilteredList(filterList(items, query,
|
|
120
|
+
return setFilteredList(filterList(items, query, matchingAll, matcherFn));
|
|
43
121
|
});
|
|
44
122
|
}, []);
|
|
45
123
|
react.useEffect(function () {
|
|
46
|
-
if (query) filterItems(_items, query);else setFilteredList(items);
|
|
47
|
-
}, [query, _items]);
|
|
124
|
+
if (query) filterItems(_items, query, matchingAll);else setFilteredList(items);
|
|
125
|
+
}, [query, matchingAll, _items]);
|
|
48
126
|
return {
|
|
49
127
|
onSearch: setQuery,
|
|
50
128
|
query: query,
|
|
51
129
|
filteredList: filteredList,
|
|
52
130
|
isSearching: isSearching
|
|
53
131
|
};
|
|
54
|
-
}
|
|
132
|
+
}
|
|
55
133
|
|
|
56
134
|
exports.useFilteredList = useFilteredList;
|
|
@@ -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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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,
|
package/dist/cjs/i18n/ar.json.js
CHANGED
|
@@ -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;
|
package/dist/cjs/i18n/en.json.js
CHANGED
|
@@ -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;
|