@react-fabric/data 1.0.0-beta.4 → 1.0.0-beta.41
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/css/styles.css +24 -0
- package/dist/cjs/checklist/CheckList.js +25 -16
- package/dist/cjs/histogram/Histogram.js +20 -10
- package/dist/cjs/hooks/usePagination.js +7 -4
- package/dist/cjs/json/JsonViewer.js +40 -27
- package/dist/cjs/table/BodyCell.js +38 -5
- package/dist/cjs/table/BodyRow.js +107 -0
- package/dist/cjs/table/CheckboxCell.js +1 -1
- package/dist/cjs/table/HeaderCell.js +29 -36
- package/dist/cjs/table/Table.js +105 -67
- package/dist/cjs/table/useResizer.js +4 -4
- package/dist/cjs/table/useVirtualTable.js +118 -17
- package/dist/cjs/tree/TreeNode.js +44 -24
- package/dist/cjs/tree/TreePanel.js +28 -10
- package/dist/cjs/tree/useTree.js +96 -14
- package/dist/cjs/tree/utils.js +20 -5
- package/dist/cjs/virtual/Gallery.js +43 -29
- package/dist/cjs/virtual/List.js +43 -31
- package/dist/esm/checklist/CheckList.js +27 -18
- package/dist/esm/histogram/Histogram.js +21 -11
- package/dist/esm/hooks/usePagination.js +7 -4
- package/dist/esm/json/JsonViewer.js +41 -28
- package/dist/esm/table/BodyCell.js +38 -5
- package/dist/esm/table/BodyRow.js +107 -0
- package/dist/esm/table/CheckboxCell.js +1 -1
- package/dist/esm/table/HeaderCell.js +30 -37
- package/dist/esm/table/Table.js +107 -69
- package/dist/esm/table/useResizer.js +4 -4
- package/dist/esm/table/useVirtualTable.js +120 -19
- package/dist/esm/tree/TreeNode.js +46 -26
- package/dist/esm/tree/TreePanel.js +28 -10
- package/dist/esm/tree/useTree.js +98 -16
- package/dist/esm/tree/utils.js +20 -5
- package/dist/esm/virtual/Gallery.js +43 -29
- package/dist/esm/virtual/List.js +43 -31
- package/dist/types/checklist/CheckList.d.ts +2 -2
- package/dist/types/histogram/Histogram.d.ts +3 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/table/AddColumn.d.ts +2 -2
- package/dist/types/table/BodyCell.d.ts +4 -3
- package/dist/types/table/BodyRow.d.ts +20 -0
- package/dist/types/table/EmptyCell.d.ts +2 -2
- package/dist/types/table/HeaderCell.d.ts +2 -2
- package/dist/types/table/Table.d.ts +1 -1
- package/dist/types/table/types.d.ts +17 -6
- package/dist/types/table/useTableColumns.d.ts +6 -6
- package/dist/types/table/useVirtualTable.d.ts +20 -5
- package/dist/types/tree/TreeNode.d.ts +1 -1
- package/dist/types/tree/TreePanel.d.ts +1 -1
- package/dist/types/tree/types.d.ts +25 -5
- package/dist/types/tree/useTree.d.ts +2 -9
- package/dist/types/tree/utils.d.ts +4 -1
- package/dist/types/virtual/Gallery.d.ts +12 -4
- package/dist/types/virtual/List.d.ts +7 -3
- package/package.json +10 -7
- package/src/checklist/CheckList.tsx +81 -77
- package/src/histogram/Histogram.tsx +17 -11
- package/src/hooks/usePagination.tsx +13 -7
- package/src/index.ts +1 -1
- package/src/json/JsonViewer.tsx +45 -35
- package/src/table/AddColumn.tsx +2 -2
- package/src/table/BodyCell.tsx +34 -5
- package/src/table/BodyRow.tsx +143 -0
- package/src/table/CheckboxCell.tsx +1 -1
- package/src/table/EmptyCell.tsx +2 -2
- package/src/table/HeaderCell.tsx +27 -13
- package/src/table/Table.tsx +141 -73
- package/src/table/types.ts +20 -5
- package/src/table/useResizer.ts +5 -3
- package/src/table/useTableColumns.ts +7 -7
- package/src/table/useVirtualTable.ts +143 -28
- package/src/tree/TreeNode.tsx +90 -56
- package/src/tree/TreePanel.tsx +23 -3
- package/src/tree/types.ts +32 -4
- package/src/tree/useTree.ts +102 -23
- package/src/tree/utils.ts +23 -8
- package/src/virtual/Gallery.tsx +46 -35
- package/src/virtual/List.tsx +40 -27
- package/dist/cjs/histogram/Histogram.module.css +0 -1
- 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
|
}
|
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 = ["
|
|
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 =
|
|
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
|
-
|
|
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,8 @@ 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
|
+
};
|
|
73
75
|
var CheckList = function CheckList(_ref2) {
|
|
74
76
|
var _ref2$items = _ref2.items,
|
|
75
77
|
items = _ref2$items === void 0 ? [] : _ref2$items,
|
|
@@ -79,12 +81,20 @@ var CheckList = function CheckList(_ref2) {
|
|
|
79
81
|
emptyMessage = _ref2.emptyMessage,
|
|
80
82
|
_ref2$sortItems = _ref2.sortItems,
|
|
81
83
|
sortItems = _ref2$sortItems === void 0 ? true : _ref2$sortItems,
|
|
82
|
-
|
|
84
|
+
selected = _ref2.selected,
|
|
85
|
+
nonselected = _ref2.nonselected,
|
|
86
|
+
onChange = _ref2.onChange,
|
|
87
|
+
onClick = _ref2.onClick,
|
|
88
|
+
aria = _objectWithoutProperties(_ref2, _excluded2);
|
|
83
89
|
var _useTranslation = reactI18next.useTranslation("data"),
|
|
84
90
|
t = _useTranslation.t;
|
|
85
|
-
var _useSelectableList = useSelectableList.useSelectableList(
|
|
86
|
-
items: items
|
|
87
|
-
|
|
91
|
+
var _useSelectableList = useSelectableList.useSelectableList({
|
|
92
|
+
items: items,
|
|
93
|
+
selected: selected,
|
|
94
|
+
nonselected: nonselected,
|
|
95
|
+
onChange: onChange,
|
|
96
|
+
onClick: onClick
|
|
97
|
+
}),
|
|
88
98
|
selection = _useSelectableList.selection,
|
|
89
99
|
toggleSelection = _useSelectableList.toggleSelection;
|
|
90
100
|
var _useState = react.useState(false),
|
|
@@ -105,8 +115,7 @@ var CheckList = function CheckList(_ref2) {
|
|
|
105
115
|
return 0;
|
|
106
116
|
}).slice(0, !showMore && maxCount > 0 ? maxCount : undefined);
|
|
107
117
|
}, [items, selection, maxCount, showMore, sortItems]);
|
|
108
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
109
|
-
className: "ax-checkList",
|
|
118
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({}, aria), {}, {
|
|
110
119
|
children: [listItems.map(function (item, index) {
|
|
111
120
|
return /*#__PURE__*/react.createElement(CheckItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
112
121
|
key: index,
|
|
@@ -128,7 +137,7 @@ var CheckList = function CheckList(_ref2) {
|
|
|
128
137
|
className: "text-sm",
|
|
129
138
|
message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("checkList.empty")
|
|
130
139
|
})]
|
|
131
|
-
});
|
|
140
|
+
}));
|
|
132
141
|
};
|
|
133
142
|
|
|
134
143
|
exports.CheckList = CheckList;
|
|
@@ -1,26 +1,31 @@
|
|
|
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";
|
|
13
17
|
var Histogram = function Histogram(_ref) {
|
|
14
18
|
var _ref$items = _ref.items,
|
|
15
19
|
items = _ref$items === void 0 ? [] : _ref$items,
|
|
16
20
|
total = _ref.total,
|
|
17
21
|
_ref$color = _ref.color,
|
|
18
|
-
color = _ref$color === void 0 ? "primary" : _ref$color,
|
|
22
|
+
color = _ref$color === void 0 ? "primary-500" : _ref$color,
|
|
19
23
|
_ref$sortBy = _ref.sortBy,
|
|
20
24
|
sortBy = _ref$sortBy === void 0 ? "count" : _ref$sortBy,
|
|
21
25
|
emptyTitle = _ref.emptyTitle,
|
|
22
26
|
emptyMessage = _ref.emptyMessage,
|
|
23
|
-
_onClick = _ref.onClick
|
|
27
|
+
_onClick = _ref.onClick,
|
|
28
|
+
aria = _objectWithoutProperties(_ref, _excluded);
|
|
24
29
|
var _useTranslation = reactI18next.useTranslation("data"),
|
|
25
30
|
t = _useTranslation.t;
|
|
26
31
|
var maxTotal = react.useMemo(function () {
|
|
@@ -32,10 +37,11 @@ var Histogram = function Histogram(_ref) {
|
|
|
32
37
|
var sorted = react.useMemo(function () {
|
|
33
38
|
return items.sort(utilities.compareValues(sortBy === "label" ? "asc" : "desc", sortBy));
|
|
34
39
|
}, [items, sortBy]);
|
|
35
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
36
|
-
className:
|
|
40
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({
|
|
41
|
+
className: "fabric-histogram from-0% to-100%"
|
|
42
|
+
}, aria), {}, {
|
|
37
43
|
style: {
|
|
38
|
-
"--color": "var(--".concat(color, ")")
|
|
44
|
+
"--color": utilities.isColor(color) ? color : "var(--color-".concat(color, ")")
|
|
39
45
|
},
|
|
40
46
|
children: [sorted.length === 0 && /*#__PURE__*/jsxRuntime.jsx(core.EmptyContent, {
|
|
41
47
|
icon: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
@@ -45,15 +51,17 @@ var Histogram = function Histogram(_ref) {
|
|
|
45
51
|
title: emptyTitle,
|
|
46
52
|
message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("histogram.empty")
|
|
47
53
|
}), sorted === null || sorted === void 0 ? void 0 : sorted.map(function (item) {
|
|
54
|
+
var _item$total;
|
|
48
55
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
49
56
|
role: "none",
|
|
50
57
|
"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",
|
|
58
|
+
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
|
+
"data-testid": item.id,
|
|
52
60
|
onClick: function onClick(e) {
|
|
53
61
|
return [_onClick === null || _onClick === void 0 ? void 0 : _onClick(item.id), e.stopPropagation()];
|
|
54
62
|
},
|
|
55
63
|
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
|
|
64
|
+
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
65
|
style: {
|
|
58
66
|
width: "".concat(Math.min(item.count / maxTotal, 1) * 100, "%")
|
|
59
67
|
}
|
|
@@ -62,6 +70,7 @@ var Histogram = function Histogram(_ref) {
|
|
|
62
70
|
actions: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
63
71
|
color: "danger",
|
|
64
72
|
size: "sm",
|
|
73
|
+
stopPropagation: true,
|
|
65
74
|
icon: core.CoreIcons.funnelMinus,
|
|
66
75
|
"aria-label": "Filter Negative",
|
|
67
76
|
onClick: function onClick() {
|
|
@@ -70,6 +79,7 @@ var Histogram = function Histogram(_ref) {
|
|
|
70
79
|
}, "negative"), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
|
|
71
80
|
color: "primary",
|
|
72
81
|
size: "sm",
|
|
82
|
+
stopPropagation: true,
|
|
73
83
|
icon: core.CoreIcons.funnelPlus,
|
|
74
84
|
"aria-label": "Filter",
|
|
75
85
|
onClick: function onClick() {
|
|
@@ -78,12 +88,12 @@ var Histogram = function Histogram(_ref) {
|
|
|
78
88
|
}, "positive")],
|
|
79
89
|
children: item.label
|
|
80
90
|
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
81
|
-
className: classNames("z-1 rounded-full text-xs font-medium px-2 py-1 leading-none",
|
|
91
|
+
className: classNames("z-1 rounded-full text-xs font-medium px-2 py-1 leading-none", "fabric-histoBadge"),
|
|
82
92
|
children: utilities.Format.number(item.count)
|
|
83
93
|
})]
|
|
84
94
|
}, item.id);
|
|
85
95
|
})]
|
|
86
|
-
});
|
|
96
|
+
}));
|
|
87
97
|
};
|
|
88
98
|
|
|
89
99
|
exports.Histogram = Histogram;
|
|
@@ -58,9 +58,12 @@ var usePagination = function usePagination(_ref) {
|
|
|
58
58
|
|
|
59
59
|
/** ***************** set page *******************/
|
|
60
60
|
react.useEffect(function () {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
if (totalRecords > -1) {
|
|
62
|
+
var actual = Math.min(currentPage, totalPages - 1);
|
|
63
|
+
setPage(actual);
|
|
64
|
+
actual !== currentPage && (onChange === null || onChange === void 0 ? void 0 : onChange(actual));
|
|
65
|
+
}
|
|
66
|
+
}, [currentPage, totalRecords, totalPages]);
|
|
64
67
|
var headLabel = react.useMemo(function () {
|
|
65
68
|
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
66
69
|
className: "text-muted",
|
|
@@ -72,7 +75,7 @@ var usePagination = function usePagination(_ref) {
|
|
|
72
75
|
startTransition(function () {
|
|
73
76
|
return onChange === null || onChange === void 0 ? void 0 : onChange(page);
|
|
74
77
|
});
|
|
75
|
-
}, []);
|
|
78
|
+
}, [onChange]);
|
|
76
79
|
return {
|
|
77
80
|
page: page,
|
|
78
81
|
totalPages: totalPages,
|
|
@@ -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.
|
|
124
|
-
className: "text-dimmed text-sm px-2 flex-1 truncate",
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
}),
|
|
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
|
-
}),
|
|
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), {}, {
|
|
@@ -223,7 +236,7 @@ var JsonViewer = function JsonViewer(_ref5) {
|
|
|
223
236
|
return reduceObject(json);
|
|
224
237
|
}, [json]);
|
|
225
238
|
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
226
|
-
className: classNames(className, "
|
|
239
|
+
className: classNames(className, "bg-alternate"),
|
|
227
240
|
children: !utilities.isEmpty(json) ? list.map(function (item) {
|
|
228
241
|
return /*#__PURE__*/jsxRuntime.jsx(JsonEntry, _objectSpread(_objectSpread({}, item), {}, {
|
|
229
242
|
copy: copy,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var date = require('@react-fabric/date');
|
|
4
|
+
var utilities = require('@react-fabric/utilities');
|
|
3
5
|
var classNames = require('classnames');
|
|
4
6
|
var react = require('react');
|
|
5
7
|
var Context = require('./Context.js');
|
|
@@ -30,25 +32,56 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
30
32
|
*/
|
|
31
33
|
|
|
32
34
|
var BodyCell = function BodyCell(_ref) {
|
|
33
|
-
var _column$minWidth, _column$maxWidth
|
|
35
|
+
var _column$minWidth, _column$maxWidth;
|
|
34
36
|
var column = _ref.column,
|
|
35
|
-
item = _ref.item
|
|
37
|
+
item = _ref.item,
|
|
38
|
+
index = _ref.index;
|
|
36
39
|
var _useTableContext = Context.useTableContext(),
|
|
37
40
|
widths = _useTableContext.widths;
|
|
38
41
|
var width = react.useMemo(function () {
|
|
39
42
|
var _widths$get;
|
|
40
43
|
return (_widths$get = widths.get(column.id.toString())) !== null && _widths$get !== void 0 ? _widths$get : column.width;
|
|
41
44
|
}, [widths, column]);
|
|
45
|
+
var content = react.useMemo(function () {
|
|
46
|
+
var _column$dataType;
|
|
47
|
+
var value = utilities.getByPath(item, column.id.toString());
|
|
48
|
+
if (column.renderer != null) {
|
|
49
|
+
return column.renderer(item[column.id], item, index);
|
|
50
|
+
}
|
|
51
|
+
if (column.dataType === "boolean") {
|
|
52
|
+
var _column$valueMap;
|
|
53
|
+
var map = (_column$valueMap = column.valueMap) !== null && _column$valueMap !== void 0 ? _column$valueMap : {
|
|
54
|
+
"true": "Yes",
|
|
55
|
+
"false": "no"
|
|
56
|
+
};
|
|
57
|
+
return map["".concat(utilities.isTrue(value) ? "true" : "false")];
|
|
58
|
+
}
|
|
59
|
+
if (column.valueMap != null) {
|
|
60
|
+
if (column.dataType === "string" && value in column.valueMap) {
|
|
61
|
+
return column.valueMap[value];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (["date", "time", "datetime"].includes((_column$dataType = column.dataType) !== null && _column$dataType !== void 0 ? _column$dataType : "")) {
|
|
65
|
+
return /*#__PURE__*/jsxRuntime.jsx(date.DateDisplay, {
|
|
66
|
+
date: value,
|
|
67
|
+
format: column.format
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (column.dataType === "number") {
|
|
71
|
+
return utilities.Format.number(value, column.format);
|
|
72
|
+
}
|
|
73
|
+
return value !== null && value !== void 0 ? value : "";
|
|
74
|
+
}, [item, column]);
|
|
42
75
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
43
|
-
className: "overflow-hidden bg-inherit start-0",
|
|
76
|
+
className: "overflow-hidden bg-inherit start-0 border-e",
|
|
44
77
|
style: {
|
|
45
78
|
width: width !== null && width !== void 0 ? width : types.COL_DEFAULT_WIDTH,
|
|
46
79
|
minWidth: (_column$minWidth = column.minWidth) !== null && _column$minWidth !== void 0 ? _column$minWidth : types.COL_MIN_WIDTH,
|
|
47
80
|
maxWidth: (_column$maxWidth = column.maxWidth) !== null && _column$maxWidth !== void 0 ? _column$maxWidth : types.COL_MAX_WIDTH
|
|
48
81
|
},
|
|
49
82
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
50
|
-
className: classNames("px-2 py-1
|
|
51
|
-
children:
|
|
83
|
+
className: classNames("px-2 py-1", column.className, column.truncate && "truncate", column.align === "center" && "text-center", column.align === "end" && "text-end"),
|
|
84
|
+
children: content
|
|
52
85
|
})
|
|
53
86
|
});
|
|
54
87
|
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var classNames = require('classnames');
|
|
4
|
+
var BodyCell = require('./BodyCell.js');
|
|
5
|
+
var CheckboxCell = require('./CheckboxCell.js');
|
|
6
|
+
var core = require('@react-fabric/core');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* React Fabric
|
|
11
|
+
* @version: 1.0.0
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* The MIT License (MIT)
|
|
15
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
18
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
19
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
20
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
21
|
+
* subject to the following conditions:
|
|
22
|
+
*
|
|
23
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
24
|
+
* portions of the Software.
|
|
25
|
+
*
|
|
26
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
27
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
28
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
29
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
var BodyRow = function BodyRow(_ref) {
|
|
33
|
+
var _state$start, _state$cols, _state$end;
|
|
34
|
+
var rowKey = _ref.rowKey,
|
|
35
|
+
index = _ref.index,
|
|
36
|
+
data = _ref.data,
|
|
37
|
+
keyProperty = _ref.keyProperty,
|
|
38
|
+
measureElement = _ref.measureElement,
|
|
39
|
+
state = _ref.state,
|
|
40
|
+
hideableColumns = _ref.hideableColumns,
|
|
41
|
+
wrapperStart = _ref.wrapperStart,
|
|
42
|
+
wrapperEnd = _ref.wrapperEnd,
|
|
43
|
+
onRowClick = _ref.onRowClick,
|
|
44
|
+
checkableRows = _ref.checkableRows,
|
|
45
|
+
checked = _ref.checked,
|
|
46
|
+
toggleChecked = _ref.toggleChecked,
|
|
47
|
+
canExpand = _ref.canExpand,
|
|
48
|
+
expanded = _ref.expanded,
|
|
49
|
+
toggleExpand = _ref.toggleExpand,
|
|
50
|
+
expandRow = _ref.expandRow;
|
|
51
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
52
|
+
ref: measureElement,
|
|
53
|
+
"data-index": index,
|
|
54
|
+
className: index % 2 ? "bg-even" : "bg-odd",
|
|
55
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
56
|
+
role: "none",
|
|
57
|
+
"data-row": index,
|
|
58
|
+
className: classNames("flex flex-nowrap datatable-row data-[hilight]:outline-1 -outline-offset-1 outline-primary-500", onRowClick && "hover:bg-primary-50 active:bg-primary-100", index % 2 ? "bg-even" : "bg-odd"),
|
|
59
|
+
onClick: function onClick() {
|
|
60
|
+
return checkableRows && keyProperty && !onRowClick ? toggleChecked(data[keyProperty]) : onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(data);
|
|
61
|
+
},
|
|
62
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
63
|
+
className: wrapperStart,
|
|
64
|
+
children: [!!canExpand && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
65
|
+
className: classNames("group font-medium w-6 flex flex-nowrap text-start py-1", !canExpand(data) && "pointer-events-none opacity-35"),
|
|
66
|
+
children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
67
|
+
className: "p-1 text-tint-700 hover:text-primary-600",
|
|
68
|
+
icon: expanded ? core.CoreIcons.collapse : core.CoreIcons.expand,
|
|
69
|
+
onClick: function onClick(e) {
|
|
70
|
+
return [keyProperty && toggleExpand(data[keyProperty]), e.stopPropagation()];
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}), checkableRows && keyProperty && /*#__PURE__*/jsxRuntime.jsx(CheckboxCell.CheckboxCell, {
|
|
74
|
+
onClick: function onClick() {
|
|
75
|
+
return toggleChecked(data[keyProperty]);
|
|
76
|
+
},
|
|
77
|
+
state: checked
|
|
78
|
+
}), (_state$start = state.start) === null || _state$start === void 0 ? void 0 : _state$start.map(function (col, ids) {
|
|
79
|
+
return /*#__PURE__*/jsxRuntime.jsx(BodyCell.BodyCell, {
|
|
80
|
+
column: col,
|
|
81
|
+
item: data,
|
|
82
|
+
index: ids
|
|
83
|
+
}, "".concat(String(rowKey), ":").concat(ids));
|
|
84
|
+
})]
|
|
85
|
+
}), (_state$cols = state.cols) === null || _state$cols === void 0 ? void 0 : _state$cols.map(function (col, idc) {
|
|
86
|
+
return /*#__PURE__*/jsxRuntime.jsx(BodyCell.BodyCell, {
|
|
87
|
+
column: col,
|
|
88
|
+
item: data,
|
|
89
|
+
index: idc
|
|
90
|
+
}, "".concat(String(rowKey), ":").concat(idc));
|
|
91
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
92
|
+
className: wrapperEnd,
|
|
93
|
+
children: [(_state$end = state.end) === null || _state$end === void 0 ? void 0 : _state$end.map(function (col, ide) {
|
|
94
|
+
return /*#__PURE__*/jsxRuntime.jsx(BodyCell.BodyCell, {
|
|
95
|
+
column: col,
|
|
96
|
+
item: data,
|
|
97
|
+
index: ide
|
|
98
|
+
}, "".concat(String(rowKey), ":").concat(ide));
|
|
99
|
+
}), hideableColumns && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
100
|
+
className: "w-6"
|
|
101
|
+
})]
|
|
102
|
+
})]
|
|
103
|
+
}), expanded && expandRow(data)]
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
exports.BodyRow = BodyRow;
|
|
@@ -30,7 +30,7 @@ var CheckboxCell = function CheckboxCell(_ref) {
|
|
|
30
30
|
var state = _ref.state,
|
|
31
31
|
_onClick = _ref.onClick;
|
|
32
32
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
33
|
-
className: "group font-medium border-e w-6 flex flex-nowrap text-start
|
|
33
|
+
className: "group font-medium border-e w-6 flex flex-nowrap text-start py-1",
|
|
34
34
|
children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
35
35
|
icon: state === 2 ? core.CoreIcons.checkboxInt : state === 1 ? core.CoreIcons.checkboxOn : core.CoreIcons.checkboxOff,
|
|
36
36
|
className: "p-1 text-tint-700 hover:text-primary-600",
|