@react-fabric/data 1.0.0-beta.3 → 1.0.0-beta.31
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/dist/cjs/checklist/CheckList.js +143 -0
- package/dist/cjs/histogram/Histogram.js +16 -5
- package/dist/cjs/hooks/usePagination.js +7 -4
- package/dist/cjs/hooks/useSelectableList.js +54 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/json/JsonViewer.js +30 -23
- 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 +104 -66
- 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 +143 -0
- package/dist/esm/histogram/Histogram.js +16 -5
- package/dist/esm/hooks/usePagination.js +7 -4
- package/dist/esm/hooks/useSelectableList.js +54 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/json/JsonViewer.js +31 -24
- 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 +106 -68
- 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 +30 -0
- package/dist/types/histogram/Histogram.d.ts +3 -3
- package/dist/types/hooks/useSelectableList.d.ts +28 -0
- package/dist/types/index.d.ts +2 -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 +19 -8
- 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 +11 -3
- package/dist/types/virtual/List.d.ts +7 -3
- package/package.json +8 -7
- package/src/checklist/CheckList.tsx +222 -0
- package/src/histogram/Histogram.tsx +9 -2
- package/src/hooks/usePagination.tsx +13 -7
- package/src/hooks/useSelectableList.ts +94 -0
- package/src/index.ts +2 -1
- package/src/json/JsonViewer.tsx +31 -31
- 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 +22 -7
- package/src/table/useResizer.ts +5 -3
- package/src/table/useTableColumns.ts +7 -7
- package/src/table/useVirtualTable.ts +142 -27
- 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 +45 -34
- package/src/virtual/List.tsx +40 -27
package/dist/cjs/virtual/List.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
3
4
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
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 reactVirtual = require('@tanstack/react-virtual');
|
|
@@ -10,14 +12,21 @@ var react = require('react');
|
|
|
10
12
|
var Scroller = require('./Scroller.js');
|
|
11
13
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
14
|
|
|
15
|
+
var _excluded = ["items", "total", "children", "fullWidth", "maxWidth", "minWidth", "padding", "orientation", "defaultHeight", "defaultWidth", "hideScroller", "initialScroll", "loading", "onLoadMore", "onScroll", "listRef"];
|
|
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; }
|
|
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; }
|
|
13
18
|
var createItemList = memoizeOne(function (items) {
|
|
14
19
|
return items;
|
|
15
20
|
});
|
|
16
21
|
var _VirtualList = function _VirtualList(_ref) {
|
|
17
22
|
var _virtualItems$3, _virtualItems$4;
|
|
18
23
|
var items = _ref.items,
|
|
24
|
+
_ref$total = _ref.total,
|
|
25
|
+
total = _ref$total === void 0 ? 0 : _ref$total,
|
|
19
26
|
children = _ref.children,
|
|
20
27
|
fullWidth = _ref.fullWidth,
|
|
28
|
+
maxWidth = _ref.maxWidth,
|
|
29
|
+
minWidth = _ref.minWidth,
|
|
21
30
|
_ref$padding = _ref.padding,
|
|
22
31
|
padding = _ref$padding === void 0 ? "md" : _ref$padding,
|
|
23
32
|
_ref$orientation = _ref.orientation,
|
|
@@ -31,16 +40,17 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
31
40
|
loading = _ref.loading,
|
|
32
41
|
onLoadMore = _ref.onLoadMore,
|
|
33
42
|
onScroll = _ref.onScroll,
|
|
34
|
-
listRef = _ref.listRef
|
|
43
|
+
listRef = _ref.listRef,
|
|
44
|
+
aria = _objectWithoutProperties(_ref, _excluded);
|
|
35
45
|
var count = react.useDeferredValue(items.length);
|
|
36
46
|
var extraSize = react.useMemo(function () {
|
|
37
|
-
return onLoadMore ?
|
|
47
|
+
return onLoadMore ? 8 : 0;
|
|
38
48
|
}, [onLoadMore]);
|
|
39
|
-
var itemList = createItemList(items.map(function (item,
|
|
49
|
+
var itemList = createItemList(items.map(function (item, index) {
|
|
40
50
|
return {
|
|
41
|
-
index:
|
|
42
|
-
|
|
43
|
-
isLast:
|
|
51
|
+
index: index,
|
|
52
|
+
item: item,
|
|
53
|
+
isLast: index + 1 === items.length
|
|
44
54
|
};
|
|
45
55
|
}));
|
|
46
56
|
var scrollerRef = react.useRef(null);
|
|
@@ -103,26 +113,23 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
103
113
|
setScrollActive(calculateActiveScroll());
|
|
104
114
|
}, [itemList, calculateActiveScroll]);
|
|
105
115
|
react.useEffect(function () {
|
|
106
|
-
|
|
107
|
-
var
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return db.cancel();
|
|
113
|
-
};
|
|
114
|
-
}, [onLoadMore, loading, itemList, virtualItems, count]);
|
|
115
|
-
react.useEffect(function () {
|
|
116
|
-
var _virtualItems$2;
|
|
117
|
-
var firstItem = (_virtualItems$2 = virtualItems[0]) === null || _virtualItems$2 === void 0 ? void 0 : _virtualItems$2.index;
|
|
118
|
-
if (onLoadMore && firstItem !== undefined && items[firstItem] === null) {
|
|
116
|
+
if (onLoadMore) {
|
|
117
|
+
var _virtualItems$2, _virtualItems$slice$p;
|
|
118
|
+
var firstItem = (_virtualItems$2 = virtualItems[0]) === null || _virtualItems$2 === void 0 ? void 0 : _virtualItems$2.index;
|
|
119
|
+
var lastItem = virtualItems === null || virtualItems === void 0 || (_virtualItems$slice$p = virtualItems.slice(-1).pop()) === null || _virtualItems$slice$p === void 0 ? void 0 : _virtualItems$slice$p.index;
|
|
120
|
+
var canLoadPrevPage = firstItem !== undefined && items[firstItem] === null;
|
|
121
|
+
var canLoadNextPage = lastItem !== undefined && lastItem === count - 1 && count < total;
|
|
119
122
|
var db = utilities.debounce(onLoadMore);
|
|
120
|
-
|
|
123
|
+
if (canLoadPrevPage) {
|
|
124
|
+
db(firstItem);
|
|
125
|
+
} else if (!loading && canLoadNextPage) {
|
|
126
|
+
db(lastItem + 1);
|
|
127
|
+
}
|
|
121
128
|
return function () {
|
|
122
129
|
return db.cancel();
|
|
123
130
|
};
|
|
124
131
|
}
|
|
125
|
-
}, [onLoadMore,
|
|
132
|
+
}, [onLoadMore, virtualItems]);
|
|
126
133
|
react.useLayoutEffect(function () {
|
|
127
134
|
setTimeout(function () {
|
|
128
135
|
initialScroll && virtualizer.scrollToIndex(initialScroll, {
|
|
@@ -134,14 +141,14 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
134
141
|
return {
|
|
135
142
|
scrollToItem: function scrollToItem(index) {
|
|
136
143
|
virtualizer.scrollToIndex(index, {
|
|
137
|
-
align: "
|
|
144
|
+
align: "auto"
|
|
138
145
|
});
|
|
139
146
|
},
|
|
140
147
|
hilight: function hilight(index) {
|
|
141
148
|
var _scrollerRef$current2;
|
|
142
149
|
(_scrollerRef$current2 = scrollerRef.current) === null || _scrollerRef$current2 === void 0 || (_scrollerRef$current2 = _scrollerRef$current2.querySelector(".hilight")) === null || _scrollerRef$current2 === void 0 || _scrollerRef$current2.classList.remove("hilight", "ring-1");
|
|
143
150
|
virtualizer.scrollToIndex(Math.floor(index), {
|
|
144
|
-
align: "
|
|
151
|
+
align: "auto"
|
|
145
152
|
});
|
|
146
153
|
setTimeout(function () {
|
|
147
154
|
var _scrollerRef$current3;
|
|
@@ -154,19 +161,24 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
154
161
|
}
|
|
155
162
|
};
|
|
156
163
|
}, [virtualizer]);
|
|
157
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
164
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
|
|
158
165
|
ref: scrollerRef,
|
|
159
166
|
onScroll: handleScroll,
|
|
160
|
-
className: classNames("area-content bg-base overflow-auto contain-strict")
|
|
167
|
+
className: classNames("area-content bg-base overflow-auto contain-strict")
|
|
168
|
+
}, aria), {}, {
|
|
161
169
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
162
170
|
className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
|
|
163
171
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
164
172
|
className: classNames("box-content inline-flex flex-nowrap", orientation === "vertical" && "flex-col", orientation === "horizontal" && "flex-row", fullWidth && "flex-1", padding === "sm" && "p-1", padding === "md" && "p-2", padding === "lg" && "p-4"),
|
|
173
|
+
style: {
|
|
174
|
+
minWidth: minWidth,
|
|
175
|
+
maxWidth: maxWidth
|
|
176
|
+
},
|
|
165
177
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
166
178
|
style: orientation === "vertical" ? {
|
|
167
|
-
height: virtualizer.getTotalSize()
|
|
179
|
+
height: virtualizer.getTotalSize() + extraSize
|
|
168
180
|
} : {
|
|
169
|
-
width: virtualizer.getTotalSize()
|
|
181
|
+
width: virtualizer.getTotalSize() + extraSize
|
|
170
182
|
},
|
|
171
183
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
172
184
|
style: orientation === "vertical" ? {
|
|
@@ -185,9 +197,9 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
185
197
|
children: children(itemList[index])
|
|
186
198
|
}, key);
|
|
187
199
|
})]
|
|
188
|
-
}),
|
|
189
|
-
className: orientation === "horizontal" ? "min-w-16" : "
|
|
190
|
-
children:
|
|
200
|
+
}), loading && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
201
|
+
className: orientation === "horizontal" ? "min-w-16" : "",
|
|
202
|
+
children: /*#__PURE__*/jsxRuntime.jsx(core.Skeleton, {})
|
|
191
203
|
})]
|
|
192
204
|
}), !hideScroller && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
193
205
|
className: classNames(orientation === "vertical" && "self-end sticky bottom-2", orientation === "horizontal" && "self-end sticky end-2"),
|
|
@@ -209,7 +221,7 @@ var _VirtualList = function _VirtualList(_ref) {
|
|
|
209
221
|
})
|
|
210
222
|
})]
|
|
211
223
|
})
|
|
212
|
-
});
|
|
224
|
+
}));
|
|
213
225
|
};
|
|
214
226
|
_VirtualList.displayName = "VirtualList";
|
|
215
227
|
var GenericMemo = react.memo;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
6
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
7
|
+
import { EmptyContent, Icon, CoreIcons, Badge } from '@react-fabric/core';
|
|
8
|
+
import { isString } from '@react-fabric/utilities';
|
|
9
|
+
import { useState, useEffect, useMemo, createElement, Fragment, isValidElement } from 'react';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import { useSelectableList } from '../hooks/useSelectableList.js';
|
|
12
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
var _excluded = ["id", "allowNegative", "selected", "icon", "label", "isDisabled", "onClick", "badge"],
|
|
15
|
+
_excluded2 = ["items", "maxCount", "allowNegative", "emptyMessage", "sortItems", "selected", "nonselected", "onChange", "onClick"];
|
|
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; }
|
|
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; }
|
|
18
|
+
var CheckItem = function CheckItem(_ref) {
|
|
19
|
+
var id = _ref.id,
|
|
20
|
+
allowNegative = _ref.allowNegative,
|
|
21
|
+
selected = _ref.selected,
|
|
22
|
+
icon = _ref.icon,
|
|
23
|
+
label = _ref.label,
|
|
24
|
+
isDisabled = _ref.isDisabled,
|
|
25
|
+
_onClick = _ref.onClick,
|
|
26
|
+
badge = _ref.badge,
|
|
27
|
+
aria = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
29
|
+
role: "none",
|
|
30
|
+
className: "ax-checkList__item",
|
|
31
|
+
"data-disabled": isDisabled,
|
|
32
|
+
onClick: function onClick() {
|
|
33
|
+
return _onClick(id, false);
|
|
34
|
+
},
|
|
35
|
+
onContextMenu: function onContextMenu(e) {
|
|
36
|
+
return [allowNegative && _onClick(id, true), e.preventDefault()];
|
|
37
|
+
}
|
|
38
|
+
}, aria), {}, {
|
|
39
|
+
children: [!allowNegative && /*#__PURE__*/jsx(Icon, {
|
|
40
|
+
"data-type": "checkbox",
|
|
41
|
+
className: "ax-checkList__checkbox",
|
|
42
|
+
"data-selected": selected === 1,
|
|
43
|
+
icon: selected ? CoreIcons.checkboxInt : CoreIcons.checkboxOff
|
|
44
|
+
}), allowNegative && /*#__PURE__*/jsxs(Fragment, {
|
|
45
|
+
children: [/*#__PURE__*/jsx(Icon, {
|
|
46
|
+
"data-type": "multiple",
|
|
47
|
+
className: "ax-checkList__checkbox",
|
|
48
|
+
icon: selected === 1 ? CoreIcons.expand : selected === -1 ? CoreIcons.collapse : CoreIcons.checkboxOff,
|
|
49
|
+
"data-selected": selected
|
|
50
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
51
|
+
className: "ax-checkList__checkbox",
|
|
52
|
+
children: [/*#__PURE__*/jsx(Icon, {
|
|
53
|
+
"data-type": "positive",
|
|
54
|
+
onClick: function onClick(e) {
|
|
55
|
+
return [(_onClick(id, false), e.stopPropagation())];
|
|
56
|
+
},
|
|
57
|
+
icon: selected === 1 ? CoreIcons.expandActive : CoreIcons.expand,
|
|
58
|
+
"data-selected": selected === 1
|
|
59
|
+
}), /*#__PURE__*/jsx(Icon, {
|
|
60
|
+
"data-type": "negative",
|
|
61
|
+
onClick: function onClick(e) {
|
|
62
|
+
return [(_onClick(id, true), e.stopPropagation())];
|
|
63
|
+
},
|
|
64
|
+
icon: selected === -1 ? CoreIcons.collapseActive : CoreIcons.collapse,
|
|
65
|
+
"data-selected": selected === -1
|
|
66
|
+
})]
|
|
67
|
+
})]
|
|
68
|
+
}), /*#__PURE__*/isValidElement(icon) && icon, isString(icon) && /*#__PURE__*/jsx(Icon, {
|
|
69
|
+
icon: icon
|
|
70
|
+
}), /*#__PURE__*/jsx("label", {
|
|
71
|
+
children: label
|
|
72
|
+
}), /*#__PURE__*/jsx(Badge, _objectSpread({}, badge))]
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
var CheckList = function CheckList(_ref2) {
|
|
76
|
+
var _ref2$items = _ref2.items,
|
|
77
|
+
items = _ref2$items === void 0 ? [] : _ref2$items,
|
|
78
|
+
_ref2$maxCount = _ref2.maxCount,
|
|
79
|
+
maxCount = _ref2$maxCount === void 0 ? 0 : _ref2$maxCount,
|
|
80
|
+
allowNegative = _ref2.allowNegative,
|
|
81
|
+
emptyMessage = _ref2.emptyMessage,
|
|
82
|
+
_ref2$sortItems = _ref2.sortItems,
|
|
83
|
+
sortItems = _ref2$sortItems === void 0 ? true : _ref2$sortItems,
|
|
84
|
+
selected = _ref2.selected,
|
|
85
|
+
nonselected = _ref2.nonselected,
|
|
86
|
+
onChange = _ref2.onChange,
|
|
87
|
+
onClick = _ref2.onClick,
|
|
88
|
+
aria = _objectWithoutProperties(_ref2, _excluded2);
|
|
89
|
+
var _useTranslation = useTranslation("data"),
|
|
90
|
+
t = _useTranslation.t;
|
|
91
|
+
var _useSelectableList = useSelectableList({
|
|
92
|
+
items: items,
|
|
93
|
+
selected: selected,
|
|
94
|
+
nonselected: nonselected,
|
|
95
|
+
onChange: onChange,
|
|
96
|
+
onClick: onClick
|
|
97
|
+
}),
|
|
98
|
+
selection = _useSelectableList.selection,
|
|
99
|
+
toggleSelection = _useSelectableList.toggleSelection;
|
|
100
|
+
var _useState = useState(false),
|
|
101
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
102
|
+
showMore = _useState2[0],
|
|
103
|
+
setShowMore = _useState2[1];
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
setShowMore(false);
|
|
106
|
+
}, [items]);
|
|
107
|
+
var listItems = useMemo(function () {
|
|
108
|
+
return _toConsumableArray(items).sort(function (a, b) {
|
|
109
|
+
if (sortItems && selection[a.id] !== selection[b.id]) {
|
|
110
|
+
if (selection[a.id] === 1) return -1;
|
|
111
|
+
if (selection[b.id] === 1) return 1;
|
|
112
|
+
if (selection[a.id] === -1) return -1;
|
|
113
|
+
if (selection[b.id] === -1) return 1;
|
|
114
|
+
}
|
|
115
|
+
return 0;
|
|
116
|
+
}).slice(0, !showMore && maxCount > 0 ? maxCount : undefined);
|
|
117
|
+
}, [items, selection, maxCount, showMore, sortItems]);
|
|
118
|
+
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, aria), {}, {
|
|
119
|
+
children: [listItems.map(function (item, index) {
|
|
120
|
+
return /*#__PURE__*/createElement(CheckItem, _objectSpread(_objectSpread({}, item), {}, {
|
|
121
|
+
key: index,
|
|
122
|
+
onClick: toggleSelection,
|
|
123
|
+
allowNegative: allowNegative,
|
|
124
|
+
selected: selection[item.id]
|
|
125
|
+
}));
|
|
126
|
+
}), maxCount > 0 && items.length > maxCount && /*#__PURE__*/jsx("div", {
|
|
127
|
+
className: "ax-moreLink",
|
|
128
|
+
children: /*#__PURE__*/jsxs("span", {
|
|
129
|
+
role: "none",
|
|
130
|
+
className: "link",
|
|
131
|
+
onClick: function onClick() {
|
|
132
|
+
return setShowMore(!showMore);
|
|
133
|
+
},
|
|
134
|
+
children: ["...", t("core:action.".concat(showMore ? "less" : "more"))]
|
|
135
|
+
})
|
|
136
|
+
}), listItems.length === 0 && /*#__PURE__*/jsx(EmptyContent, {
|
|
137
|
+
className: "text-sm",
|
|
138
|
+
message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("checkList.empty")
|
|
139
|
+
})]
|
|
140
|
+
}));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export { CheckList };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
4
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
5
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
4
6
|
import { EmptyContent, Icon, ActionLabel, Button, CoreIcons } from '@react-fabric/core';
|
|
5
7
|
import { compareValues, Format } from '@react-fabric/utilities';
|
|
6
8
|
import classNames from 'classnames';
|
|
@@ -9,6 +11,9 @@ import { useTranslation } from 'react-i18next';
|
|
|
9
11
|
import classes from './Histogram.module.css';
|
|
10
12
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
13
|
|
|
14
|
+
var _excluded = ["items", "total", "color", "sortBy", "emptyTitle", "emptyMessage", "onClick"];
|
|
15
|
+
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
|
+
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
17
|
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
18
|
var Histogram = function Histogram(_ref) {
|
|
14
19
|
var _ref$items = _ref.items,
|
|
@@ -20,7 +25,8 @@ var Histogram = function Histogram(_ref) {
|
|
|
20
25
|
sortBy = _ref$sortBy === void 0 ? "count" : _ref$sortBy,
|
|
21
26
|
emptyTitle = _ref.emptyTitle,
|
|
22
27
|
emptyMessage = _ref.emptyMessage,
|
|
23
|
-
_onClick = _ref.onClick
|
|
28
|
+
_onClick = _ref.onClick,
|
|
29
|
+
aria = _objectWithoutProperties(_ref, _excluded);
|
|
24
30
|
var _useTranslation = useTranslation("data"),
|
|
25
31
|
t = _useTranslation.t;
|
|
26
32
|
var maxTotal = useMemo(function () {
|
|
@@ -32,8 +38,9 @@ var Histogram = function Histogram(_ref) {
|
|
|
32
38
|
var sorted = useMemo(function () {
|
|
33
39
|
return items.sort(compareValues(sortBy === "label" ? "asc" : "desc", sortBy));
|
|
34
40
|
}, [items, sortBy]);
|
|
35
|
-
return /*#__PURE__*/jsxs("div", {
|
|
36
|
-
className: classes.histogram
|
|
41
|
+
return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
|
|
42
|
+
className: classes.histogram
|
|
43
|
+
}, aria), {}, {
|
|
37
44
|
style: {
|
|
38
45
|
"--color": "var(--".concat(color, ")")
|
|
39
46
|
},
|
|
@@ -45,10 +52,12 @@ var Histogram = function Histogram(_ref) {
|
|
|
45
52
|
title: emptyTitle,
|
|
46
53
|
message: emptyMessage !== null && emptyMessage !== void 0 ? emptyMessage : t("histogram.empty")
|
|
47
54
|
}), sorted === null || sorted === void 0 ? void 0 : sorted.map(function (item) {
|
|
55
|
+
var _item$total;
|
|
48
56
|
return /*#__PURE__*/jsxs("div", {
|
|
49
57
|
role: "none",
|
|
50
58
|
"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", classes.histoLabel, (item.count === 0 || item.disabled) && "pointer-events-none"),
|
|
59
|
+
className: classNames("relative cursor-pointer flex flex-nowrap items-center select-none overflow-hidden min-h-6 my-px", classes.histoLabel, (((_item$total = item.total) !== null && _item$total !== void 0 ? _item$total : item.count) === 0 || item.disabled) && "pointer-events-none"),
|
|
60
|
+
"data-testid": item.id,
|
|
52
61
|
onClick: function onClick(e) {
|
|
53
62
|
return [_onClick === null || _onClick === void 0 ? void 0 : _onClick(item.id), e.stopPropagation()];
|
|
54
63
|
},
|
|
@@ -62,6 +71,7 @@ var Histogram = function Histogram(_ref) {
|
|
|
62
71
|
actions: [/*#__PURE__*/jsx(Button, {
|
|
63
72
|
color: "danger",
|
|
64
73
|
size: "sm",
|
|
74
|
+
stopPropagation: true,
|
|
65
75
|
icon: CoreIcons.funnelMinus,
|
|
66
76
|
"aria-label": "Filter Negative",
|
|
67
77
|
onClick: function onClick() {
|
|
@@ -70,6 +80,7 @@ var Histogram = function Histogram(_ref) {
|
|
|
70
80
|
}, "negative"), /*#__PURE__*/jsx(Button, {
|
|
71
81
|
color: "primary",
|
|
72
82
|
size: "sm",
|
|
83
|
+
stopPropagation: true,
|
|
73
84
|
icon: CoreIcons.funnelPlus,
|
|
74
85
|
"aria-label": "Filter",
|
|
75
86
|
onClick: function onClick() {
|
|
@@ -83,7 +94,7 @@ var Histogram = function Histogram(_ref) {
|
|
|
83
94
|
})]
|
|
84
95
|
}, item.id);
|
|
85
96
|
})]
|
|
86
|
-
});
|
|
97
|
+
}));
|
|
87
98
|
};
|
|
88
99
|
|
|
89
100
|
export { Histogram };
|
|
@@ -58,9 +58,12 @@ var usePagination = function usePagination(_ref) {
|
|
|
58
58
|
|
|
59
59
|
/** ***************** set page *******************/
|
|
60
60
|
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 = useMemo(function () {
|
|
65
68
|
return /*#__PURE__*/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,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import { useRef, useState, useTransition, useEffect, useCallback } from 'react';
|
|
6
|
+
|
|
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
|
+
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
|
+
var useSelectableList = function useSelectableList(_ref) {
|
|
10
|
+
var items = _ref.items,
|
|
11
|
+
selected = _ref.selected,
|
|
12
|
+
nonselected = _ref.nonselected,
|
|
13
|
+
onChange = _ref.onChange,
|
|
14
|
+
onClick = _ref.onClick;
|
|
15
|
+
var selectionRef = useRef({});
|
|
16
|
+
var _useState = useState({}),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
selection = _useState2[0],
|
|
19
|
+
setSelection = _useState2[1];
|
|
20
|
+
var _useTransition = useTransition(),
|
|
21
|
+
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
22
|
+
startTransition = _useTransition2[1];
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
selectionRef.current = items.reduce(function (ret, _ref2) {
|
|
25
|
+
var _selected$includes, _nonselected$includes;
|
|
26
|
+
var id = _ref2.id;
|
|
27
|
+
return _objectSpread(_objectSpread({}, ret), {}, _defineProperty({}, id, selected !== null && selected !== void 0 && (_selected$includes = selected.includes) !== null && _selected$includes !== void 0 && _selected$includes.call(selected, id) ? 1 : nonselected !== null && nonselected !== void 0 && (_nonselected$includes = nonselected.includes) !== null && _nonselected$includes !== void 0 && _nonselected$includes.call(nonselected, id) ? -1 : 0));
|
|
28
|
+
}, {});
|
|
29
|
+
setSelection(_objectSpread({}, selectionRef.current));
|
|
30
|
+
}, [items, selected, nonselected]);
|
|
31
|
+
var toggleSelection = useCallback(function (id) {
|
|
32
|
+
var isNegative = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
33
|
+
var check = isNegative ? -1 : 1;
|
|
34
|
+
if (selectionRef.current[id] !== check) selectionRef.current[id] = check;else if (selectionRef.current[id] === check) selectionRef.current[id] = 0;
|
|
35
|
+
var change = [[], []];
|
|
36
|
+
Object.entries(selectionRef.current).forEach(function (_ref3) {
|
|
37
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
38
|
+
id = _ref4[0],
|
|
39
|
+
select = _ref4[1];
|
|
40
|
+
return select === 1 ? change[0].push(id) : select === -1 ? change[1].push(id) : undefined;
|
|
41
|
+
});
|
|
42
|
+
setSelection(_objectSpread({}, selectionRef.current));
|
|
43
|
+
startTransition(function () {
|
|
44
|
+
onClick === null || onClick === void 0 || onClick(id, isNegative);
|
|
45
|
+
onChange === null || onChange === void 0 || onChange(change[0], change[1]);
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
return {
|
|
49
|
+
selection: selection,
|
|
50
|
+
toggleSelection: toggleSelection
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { useSelectableList };
|
package/dist/esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
6
6
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
|
-
import { EmptyContent, Text, Meter,
|
|
7
|
+
import { EmptyContent, Text, Meter, Button, CoreIcons, Icon, Copy } from '@react-fabric/core';
|
|
8
8
|
import { isEmpty, isArray, isObject, isNil, Format, isBoolean, isTrue } from '@react-fabric/utilities';
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import { useMemo, useState, Fragment } from 'react';
|
|
@@ -99,6 +99,11 @@ var JsonEntry = function JsonEntry(_ref3) {
|
|
|
99
99
|
clamp: 3,
|
|
100
100
|
children: ret
|
|
101
101
|
});
|
|
102
|
+
} else {
|
|
103
|
+
ret = /*#__PURE__*/jsx("div", {
|
|
104
|
+
className: "break-words",
|
|
105
|
+
children: ret
|
|
106
|
+
});
|
|
102
107
|
}
|
|
103
108
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
104
109
|
children: [ret, isObject(value) && value._score_ > 0 && /*#__PURE__*/jsx(Meter, {
|
|
@@ -120,28 +125,30 @@ var JsonEntry = function JsonEntry(_ref3) {
|
|
|
120
125
|
}, [filters, path, pathWithoutOrdinal]);
|
|
121
126
|
var labelDisplay = useMemo(function () {
|
|
122
127
|
var _labeler;
|
|
123
|
-
return /*#__PURE__*/
|
|
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__*/jsxs("div", {
|
|
129
|
+
className: classNames("text-dimmed text-sm px-2 flex-1 group", inline ? "truncate" : "break-words"),
|
|
130
|
+
children: [!canExpand && canFilter && /*#__PURE__*/jsxs("div", {
|
|
131
|
+
className: "hidden pe-1 group-hover:inline-block",
|
|
132
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
133
|
+
color: "danger",
|
|
134
|
+
size: "xs",
|
|
135
|
+
variant: "link",
|
|
136
|
+
icon: 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__*/jsx(Button, {
|
|
142
|
+
color: "primary",
|
|
143
|
+
size: "xs",
|
|
144
|
+
variant: "link",
|
|
145
|
+
icon: 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__*/jsxs(Fragment, {
|
|
@@ -223,7 +230,7 @@ var JsonViewer = function JsonViewer(_ref5) {
|
|
|
223
230
|
return reduceObject(json);
|
|
224
231
|
}, [json]);
|
|
225
232
|
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({}, rest), {}, {
|
|
226
|
-
className: classNames(className, "
|
|
233
|
+
className: classNames(className, "bg-alternate"),
|
|
227
234
|
children: !isEmpty(json) ? list.map(function (item) {
|
|
228
235
|
return /*#__PURE__*/jsx(JsonEntry, _objectSpread(_objectSpread({}, item), {}, {
|
|
229
236
|
copy: copy,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { DateDisplay } from '@react-fabric/date';
|
|
4
|
+
import { getByPath, isTrue, Format } from '@react-fabric/utilities';
|
|
3
5
|
import classNames from 'classnames';
|
|
4
6
|
import { useMemo } from 'react';
|
|
5
7
|
import { useTableContext } from './Context.js';
|
|
@@ -30,25 +32,56 @@ import { jsx } from '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 = useTableContext(),
|
|
37
40
|
widths = _useTableContext.widths;
|
|
38
41
|
var width = 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 = useMemo(function () {
|
|
46
|
+
var _column$dataType;
|
|
47
|
+
var value = 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(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__*/jsx(DateDisplay, {
|
|
66
|
+
date: value,
|
|
67
|
+
format: column.format
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (column.dataType === "number") {
|
|
71
|
+
return Format.number(value, column.format);
|
|
72
|
+
}
|
|
73
|
+
return value !== null && value !== void 0 ? value : "";
|
|
74
|
+
}, [item, column]);
|
|
42
75
|
return /*#__PURE__*/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 : COL_DEFAULT_WIDTH,
|
|
46
79
|
minWidth: (_column$minWidth = column.minWidth) !== null && _column$minWidth !== void 0 ? _column$minWidth : COL_MIN_WIDTH,
|
|
47
80
|
maxWidth: (_column$maxWidth = column.maxWidth) !== null && _column$maxWidth !== void 0 ? _column$maxWidth : COL_MAX_WIDTH
|
|
48
81
|
},
|
|
49
82
|
children: /*#__PURE__*/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
|
};
|