@react-fabric/data 1.0.0-beta.0 → 1.0.0-beta.11
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 +14 -5
- package/dist/cjs/hooks/useSelectableList.js +54 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/table/AddColumn.js +56 -0
- package/dist/cjs/table/BodyCell.js +47 -6
- package/dist/cjs/table/BodyRow.js +107 -0
- package/dist/cjs/table/CheckboxCell.js +44 -0
- package/dist/cjs/table/Context.js +43 -0
- package/dist/cjs/table/EmptyCell.js +52 -0
- package/dist/cjs/table/HeaderCell.js +78 -32
- package/dist/cjs/table/Table.js +173 -96
- package/dist/cjs/table/types.js +32 -0
- package/dist/cjs/table/useResizer.js +65 -0
- package/dist/cjs/table/useTableColumns.js +45 -8
- package/dist/cjs/table/useVirtualTable.js +56 -25
- package/dist/cjs/tree/TreePanel.js +14 -2
- package/dist/cjs/tree/useTree.js +7 -0
- package/dist/cjs/virtual/Gallery.js +11 -4
- package/dist/cjs/virtual/List.js +11 -4
- package/dist/esm/checklist/CheckList.js +143 -0
- package/dist/esm/histogram/Histogram.js +14 -5
- package/dist/esm/hooks/useSelectableList.js +54 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/table/AddColumn.js +56 -0
- package/dist/esm/table/BodyCell.js +47 -6
- package/dist/esm/table/BodyRow.js +107 -0
- package/dist/esm/table/CheckboxCell.js +44 -0
- package/dist/esm/table/Context.js +42 -0
- package/dist/esm/table/EmptyCell.js +52 -0
- package/dist/esm/table/HeaderCell.js +80 -34
- package/dist/esm/table/Table.js +174 -97
- package/dist/esm/table/types.js +30 -0
- package/dist/esm/table/useResizer.js +65 -0
- package/dist/esm/table/useTableColumns.js +46 -9
- package/dist/esm/table/useVirtualTable.js +57 -26
- package/dist/esm/tree/TreePanel.js +15 -3
- package/dist/esm/tree/useTree.js +7 -0
- package/dist/esm/virtual/Gallery.js +11 -4
- package/dist/esm/virtual/List.js +11 -4
- 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 +3 -0
- package/dist/types/table/AddColumn.d.ts +5 -0
- package/dist/types/table/BodyCell.d.ts +4 -3
- package/dist/types/table/BodyRow.d.ts +20 -0
- package/dist/types/table/CheckboxCell.d.ts +4 -0
- package/dist/types/table/Context.d.ts +8 -0
- package/dist/types/table/EmptyCell.d.ts +2 -0
- 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 +41 -7
- package/dist/types/table/useResizer.d.ts +1 -0
- package/dist/types/table/useTableColumns.d.ts +8 -6
- package/dist/types/table/useVirtualTable.d.ts +13 -1
- package/dist/types/tree/TreePanel.d.ts +1 -1
- package/dist/types/tree/types.d.ts +6 -2
- package/dist/types/tree/useTree.d.ts +1 -0
- package/dist/types/virtual/Gallery.d.ts +3 -2
- package/dist/types/virtual/List.d.ts +3 -2
- package/package.json +6 -5
- package/src/checklist/CheckList.tsx +222 -0
- package/src/histogram/Histogram.tsx +7 -2
- package/src/hooks/useSelectableList.ts +94 -0
- package/src/index.ts +3 -0
- package/src/table/AddColumn.tsx +55 -0
- package/src/table/BodyCell.tsx +47 -6
- package/src/table/BodyRow.tsx +142 -0
- package/src/table/CheckboxCell.tsx +48 -0
- package/src/table/Context.tsx +70 -0
- package/src/table/EmptyCell.tsx +57 -0
- package/src/table/HeaderCell.tsx +93 -25
- package/src/table/Table.tsx +194 -87
- package/src/table/types.ts +42 -6
- package/src/table/useResizer.ts +66 -0
- package/src/table/useTableColumns.ts +52 -19
- package/src/table/useVirtualTable.ts +61 -2
- package/src/tree/TreePanel.tsx +12 -1
- package/src/tree/types.ts +8 -1
- package/src/tree/useTree.ts +5 -0
- package/src/virtual/Gallery.tsx +4 -1
- package/src/virtual/List.tsx +4 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@react-fabric/core');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var Context = require('./Context.js');
|
|
6
|
+
var types = require('./types.js');
|
|
4
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
8
|
|
|
6
9
|
/*
|
|
@@ -27,51 +30,94 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
27
30
|
*/
|
|
28
31
|
|
|
29
32
|
var HeaderCell = function HeaderCell(_ref) {
|
|
30
|
-
var
|
|
33
|
+
var id = _ref.id,
|
|
34
|
+
label = _ref.label,
|
|
31
35
|
icon = _ref.icon,
|
|
32
36
|
iconBg = _ref.iconBg,
|
|
33
37
|
iconColor = _ref.iconColor,
|
|
34
38
|
rtlFlip = _ref.rtlFlip;
|
|
35
39
|
_ref.actions;
|
|
36
40
|
_ref.locked;
|
|
37
|
-
var
|
|
38
|
-
|
|
41
|
+
var tooltip = _ref.tooltip,
|
|
42
|
+
sortable = _ref.sortable,
|
|
43
|
+
resizable = _ref.resizable,
|
|
44
|
+
_width = _ref.width,
|
|
39
45
|
maxWidth = _ref.maxWidth,
|
|
40
|
-
minWidth = _ref.minWidth
|
|
46
|
+
minWidth = _ref.minWidth,
|
|
47
|
+
sort = _ref.sort,
|
|
48
|
+
onSort = _ref.onSort;
|
|
49
|
+
var _useTableContext = Context.useTableContext(),
|
|
50
|
+
startResize = _useTableContext.startResize,
|
|
51
|
+
widths = _useTableContext.widths;
|
|
52
|
+
var width = react.useMemo(function () {
|
|
53
|
+
var _widths$get;
|
|
54
|
+
return (_widths$get = widths.get(id.toString())) !== null && _widths$get !== void 0 ? _widths$get : _width;
|
|
55
|
+
}, [widths, _width, id]);
|
|
56
|
+
var handleSort = react.useCallback(function () {
|
|
57
|
+
sortable && (onSort === null || onSort === void 0 ? void 0 : onSort({
|
|
58
|
+
id: id.toString(),
|
|
59
|
+
order: (sort === null || sort === void 0 ? void 0 : sort.id) === id && sort.order === "asc" ? "desc" : "asc"
|
|
60
|
+
}));
|
|
61
|
+
}, [onSort, name, sort, sortable]);
|
|
62
|
+
var menus = react.useMemo(function () {
|
|
63
|
+
var ret = [];
|
|
64
|
+
if (sortable) {
|
|
65
|
+
ret.push( /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
|
|
66
|
+
label: "Sort ascending",
|
|
67
|
+
icon: core.CoreIcons.sortAsc
|
|
68
|
+
}, "sort-asc"), /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
|
|
69
|
+
label: "Sort descending",
|
|
70
|
+
icon: core.CoreIcons.sortDesc
|
|
71
|
+
}, "sort-desc"));
|
|
72
|
+
}
|
|
73
|
+
return ret;
|
|
74
|
+
}, [sortable]);
|
|
41
75
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
42
|
-
|
|
76
|
+
role: "none",
|
|
77
|
+
"data-id": id,
|
|
78
|
+
onClick: handleSort,
|
|
79
|
+
className: "group font-medium border-e flex flex-nowrap text-start items-center table-header-cell",
|
|
43
80
|
style: {
|
|
44
|
-
width: width !== null && width !== void 0 ? width :
|
|
45
|
-
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth :
|
|
46
|
-
maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth :
|
|
81
|
+
width: width !== null && width !== void 0 ? width : types.COL_DEFAULT_WIDTH,
|
|
82
|
+
minWidth: minWidth !== null && minWidth !== void 0 ? minWidth : types.COL_MIN_WIDTH,
|
|
83
|
+
maxWidth: maxWidth !== null && maxWidth !== void 0 ? maxWidth : types.COL_MAX_WIDTH
|
|
47
84
|
},
|
|
48
|
-
children: [/*#__PURE__*/jsxRuntime.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
61
|
-
icon: core.CoreIcons.caretDown,
|
|
62
|
-
className: "outline bg-base me-0.5 flex-content hidden group-hover:inline-block data-[dropdown-open]:inline-block"
|
|
63
|
-
}), /*#__PURE__*/jsxRuntime.jsxs(core.Menu, {
|
|
64
|
-
className: "text-sm",
|
|
65
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
|
|
66
|
-
label: "Sort ascending",
|
|
67
|
-
icon: core.CoreIcons.sortAsc
|
|
68
|
-
}), /*#__PURE__*/jsxRuntime.jsx(core.MenuItem, {
|
|
69
|
-
label: "Sort descending",
|
|
70
|
-
icon: core.CoreIcons.sortDesc
|
|
85
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(core.Tooltip, {
|
|
86
|
+
content: tooltip !== null && tooltip !== void 0 ? tooltip : label,
|
|
87
|
+
disabled: !(tooltip !== null && tooltip !== void 0 ? tooltip : label),
|
|
88
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
89
|
+
className: "flex-initial px-2 py-1 text-sm truncate sticky start-0",
|
|
90
|
+
children: [icon && /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
|
|
91
|
+
icon: icon,
|
|
92
|
+
bg: iconBg,
|
|
93
|
+
color: iconColor,
|
|
94
|
+
rtlFlip: rtlFlip
|
|
95
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
96
|
+
children: label !== null && label !== void 0 ? label : " "
|
|
71
97
|
})]
|
|
98
|
+
})
|
|
99
|
+
}), sortable && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
100
|
+
className: "text-sm text-tint-300",
|
|
101
|
+
children: [(sort === null || sort === void 0 ? void 0 : sort.id) === id && (sort === null || sort === void 0 ? void 0 : sort.order) === "desc" && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
102
|
+
children: "\u25BC"
|
|
103
|
+
}), (sort === null || sort === void 0 ? void 0 : sort.id) === id && (sort === null || sort === void 0 ? void 0 : sort.order) === "asc" && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
104
|
+
children: "\u25B2"
|
|
72
105
|
})]
|
|
106
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
107
|
+
className: "flex-1"
|
|
108
|
+
}), menus.length > 0 && /*#__PURE__*/jsxRuntime.jsx(core.DropdownTool, {
|
|
109
|
+
groupHover: true,
|
|
110
|
+
placement: "bottom-end",
|
|
111
|
+
children: /*#__PURE__*/jsxRuntime.jsx(core.Menu, {
|
|
112
|
+
className: "text-sm",
|
|
113
|
+
children: menus
|
|
114
|
+
})
|
|
73
115
|
}), resizable && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
74
|
-
|
|
116
|
+
role: "none",
|
|
117
|
+
className: "cursor-col-resize border-e bg-transparent border-tint-200 w-[5px] self-stretch",
|
|
118
|
+
onMouseDown: function onMouseDown(e) {
|
|
119
|
+
return e.currentTarget.parentElement && startResize(e.currentTarget.parentElement);
|
|
120
|
+
}
|
|
75
121
|
})]
|
|
76
122
|
});
|
|
77
123
|
};
|
package/dist/cjs/table/Table.js
CHANGED
|
@@ -1,132 +1,209 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var core = require('@react-fabric/core');
|
|
5
|
+
var utilities = require('@react-fabric/utilities');
|
|
4
6
|
var react = require('react');
|
|
5
|
-
var
|
|
7
|
+
var reactI18next = require('react-i18next');
|
|
8
|
+
var AddColumn = require('./AddColumn.js');
|
|
9
|
+
var BodyRow = require('./BodyRow.js');
|
|
10
|
+
var CheckboxCell = require('./CheckboxCell.js');
|
|
11
|
+
var Context = require('./Context.js');
|
|
12
|
+
var EmptyCell = require('./EmptyCell.js');
|
|
6
13
|
var HeaderCell = require('./HeaderCell.js');
|
|
7
14
|
var useTableColumns = require('./useTableColumns.js');
|
|
8
15
|
var useVirtualTable = require('./useVirtualTable.js');
|
|
9
|
-
var classNames = require('classnames');
|
|
10
16
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
17
|
|
|
12
18
|
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; }
|
|
13
19
|
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; }
|
|
14
20
|
var Table = function Table(_ref) {
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
21
|
+
var _state$start, _state$cols, _state$end, _items$, _state$start2, _state$cols2, _state$end2;
|
|
22
|
+
var ref = _ref.ref,
|
|
23
|
+
data = _ref.data,
|
|
24
|
+
columns = _ref.columns,
|
|
25
|
+
keyProperty = _ref.keyProperty,
|
|
26
|
+
checkableRows = _ref.checkableRows,
|
|
27
|
+
initialScroll = _ref.initialScroll,
|
|
28
|
+
hideableColumns = _ref.hideableColumns,
|
|
29
|
+
sort = _ref.sort,
|
|
30
|
+
loading = _ref.loading,
|
|
31
|
+
emptyDisplay = _ref.emptyDisplay,
|
|
32
|
+
canExpand = _ref.canExpand,
|
|
33
|
+
children = _ref.children,
|
|
34
|
+
onSort = _ref.onSort,
|
|
35
|
+
onScroll = _ref.onScroll,
|
|
36
|
+
onRowClick = _ref.onRowClick,
|
|
37
|
+
onCheckedChanged = _ref.onCheckedChanged;
|
|
38
|
+
var _useTranslation = reactI18next.useTranslation("data"),
|
|
39
|
+
t = _useTranslation.t;
|
|
40
|
+
var fireCheckChanged = core.useDebounce(function (checkedIds) {
|
|
41
|
+
return onCheckedChanged === null || onCheckedChanged === void 0 ? void 0 : onCheckedChanged(checkedIds);
|
|
42
|
+
}, []);
|
|
18
43
|
var _useTableColumns = useTableColumns.useTableColumns(columns),
|
|
19
|
-
|
|
20
|
-
|
|
44
|
+
state = _useTableColumns.state,
|
|
45
|
+
onHide = _useTableColumns.onHide;
|
|
46
|
+
var _useVirtualTable = useVirtualTable.useVirtualTable(data, keyProperty, fireCheckChanged),
|
|
21
47
|
scrollerRef = _useVirtualTable.scrollerRef,
|
|
22
48
|
items = _useVirtualTable.items,
|
|
49
|
+
top = _useVirtualTable.top,
|
|
50
|
+
checkState = _useVirtualTable.checkState,
|
|
51
|
+
virtualizer = _useVirtualTable.virtualizer,
|
|
52
|
+
toggleExpand = _useVirtualTable.toggleExpand,
|
|
53
|
+
toggleChecked = _useVirtualTable.toggleChecked,
|
|
54
|
+
toggleAllChecked = _useVirtualTable.toggleAllChecked,
|
|
23
55
|
getData = _useVirtualTable.getData,
|
|
24
56
|
totalSize = _useVirtualTable.totalSize,
|
|
25
57
|
measureElement = _useVirtualTable.measureElement;
|
|
58
|
+
var refBody = react.useRef(null);
|
|
26
59
|
var wrapperStart = react.useMemo(function () {
|
|
27
60
|
return "bg-inherit sticky start-0 flex flex-nowrap z-1";
|
|
28
61
|
}, []);
|
|
29
62
|
var wrapperEnd = react.useMemo(function () {
|
|
30
63
|
return "bg-inherit sticky end-0 flex flex-nowrap z-1 border-s -ms-px";
|
|
31
64
|
}, []);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
65
|
+
react.useLayoutEffect(function () {
|
|
66
|
+
setTimeout(function () {
|
|
67
|
+
initialScroll && virtualizer.scrollToIndex(initialScroll, {
|
|
68
|
+
align: "start"
|
|
69
|
+
});
|
|
70
|
+
}, 100);
|
|
71
|
+
}, []);
|
|
72
|
+
react.useImperativeHandle(ref, function () {
|
|
73
|
+
return {
|
|
74
|
+
scrollTo: function scrollTo(row) {
|
|
75
|
+
virtualizer.scrollToIndex(row, {
|
|
76
|
+
align: "start"
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
hilight: function hilight(row) {
|
|
80
|
+
var _scrollerRef$current;
|
|
81
|
+
(_scrollerRef$current = scrollerRef.current) === null || _scrollerRef$current === void 0 || (_scrollerRef$current = _scrollerRef$current.querySelector(".hilight")) === null || _scrollerRef$current === void 0 || _scrollerRef$current.classList.remove("hilight", "ring-1");
|
|
82
|
+
virtualizer.scrollToIndex(Math.floor(row), {
|
|
83
|
+
align: "start"
|
|
84
|
+
});
|
|
85
|
+
setTimeout(function () {
|
|
86
|
+
var _scrollerRef$current2;
|
|
87
|
+
(_scrollerRef$current2 = scrollerRef.current) === null || _scrollerRef$current2 === void 0 || (_scrollerRef$current2 = _scrollerRef$current2.querySelector("[data-index=\"".concat(row, "\"]"))) === null || _scrollerRef$current2 === void 0 || _scrollerRef$current2.classList.add("hilight", "ring-1");
|
|
88
|
+
}, 100);
|
|
89
|
+
},
|
|
90
|
+
unhilight: function unhilight() {
|
|
91
|
+
var _scrollerRef$current3;
|
|
92
|
+
(_scrollerRef$current3 = scrollerRef.current) === null || _scrollerRef$current3 === void 0 || (_scrollerRef$current3 = _scrollerRef$current3.querySelector(".hilight")) === null || _scrollerRef$current3 === void 0 || _scrollerRef$current3.classList.remove("hilight", "ring-1");
|
|
40
93
|
}
|
|
41
|
-
}
|
|
94
|
+
};
|
|
42
95
|
}, []);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
}), (_columnMap$cols = columnMap.cols) === null || _columnMap$cols === void 0 ? void 0 : _columnMap$cols.map(function (col, idx) {
|
|
57
|
-
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread({}, col), idx);
|
|
58
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
59
|
-
className: wrapperEnd,
|
|
60
|
-
children: (_columnMap$end = columnMap.end) === null || _columnMap$end === void 0 ? void 0 : _columnMap$end.map(function (col, idx) {
|
|
61
|
-
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread({}, col), idx);
|
|
62
|
-
})
|
|
63
|
-
})]
|
|
64
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
65
|
-
className: "area-content flex flex-col flex-nowrap",
|
|
96
|
+
react.useEffect(function () {
|
|
97
|
+
var handle = utilities.debounce(function (top) {
|
|
98
|
+
onScroll === null || onScroll === void 0 || onScroll(top !== null && top !== void 0 ? top : 0);
|
|
99
|
+
});
|
|
100
|
+
handle(top);
|
|
101
|
+
return function () {
|
|
102
|
+
handle.cancel();
|
|
103
|
+
};
|
|
104
|
+
}, [top]);
|
|
105
|
+
return /*#__PURE__*/jsxRuntime.jsx(Context.TableProvider, {
|
|
106
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
107
|
+
className: "grid area-content overflow-auto relative",
|
|
66
108
|
style: {
|
|
67
|
-
|
|
109
|
+
gridTemplate: "\"head\" auto \"loader\" auto \"content\" 1fr \"foot\" auto/1fr"
|
|
68
110
|
},
|
|
69
|
-
|
|
111
|
+
ref: scrollerRef,
|
|
112
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
113
|
+
className: "bg-base font-medium sticky top-0 area-head border-b select-none flex flex-nowrap z-2",
|
|
114
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
115
|
+
className: wrapperStart,
|
|
116
|
+
children: [canExpand && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
117
|
+
className: "w-6"
|
|
118
|
+
}), checkableRows && /*#__PURE__*/jsxRuntime.jsx(CheckboxCell.CheckboxCell, {
|
|
119
|
+
state: checkState.allChecked,
|
|
120
|
+
onClick: toggleAllChecked
|
|
121
|
+
}), (_state$start = state.start) === null || _state$start === void 0 ? void 0 : _state$start.map(function (col, idx) {
|
|
122
|
+
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread(_objectSpread({}, col), {}, {
|
|
123
|
+
sort: sort,
|
|
124
|
+
onSort: onSort
|
|
125
|
+
}), idx);
|
|
126
|
+
})]
|
|
127
|
+
}), (_state$cols = state.cols) === null || _state$cols === void 0 ? void 0 : _state$cols.map(function (col, idx) {
|
|
128
|
+
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread(_objectSpread({}, col), {}, {
|
|
129
|
+
sort: sort,
|
|
130
|
+
onSort: onSort
|
|
131
|
+
}), idx);
|
|
132
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
133
|
+
className: wrapperEnd,
|
|
134
|
+
children: [(_state$end = state.end) === null || _state$end === void 0 ? void 0 : _state$end.map(function (col, idx) {
|
|
135
|
+
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread(_objectSpread({}, col), {}, {
|
|
136
|
+
sort: sort,
|
|
137
|
+
onSort: onSort
|
|
138
|
+
}), idx);
|
|
139
|
+
}), hideableColumns && /*#__PURE__*/jsxRuntime.jsx(AddColumn.AddColumn, {
|
|
140
|
+
onClick: onHide,
|
|
141
|
+
columns: state.columns.filter(function (col) {
|
|
142
|
+
return col.hideable !== false;
|
|
143
|
+
})
|
|
144
|
+
})]
|
|
145
|
+
})]
|
|
146
|
+
}), loading && /*#__PURE__*/jsxRuntime.jsx(core.Loading, {}), data.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
147
|
+
className: "area-content flex flex-col flex-nowrap",
|
|
70
148
|
style: {
|
|
71
|
-
height: (
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
149
|
+
height: totalSize()
|
|
150
|
+
},
|
|
151
|
+
ref: refBody,
|
|
152
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
153
|
+
style: {
|
|
154
|
+
height: (_items$ = items[0]) === null || _items$ === void 0 ? void 0 : _items$.start
|
|
155
|
+
}
|
|
156
|
+
}), items.map(function (_ref2) {
|
|
157
|
+
var index = _ref2.index,
|
|
158
|
+
key = _ref2.key;
|
|
159
|
+
var data = getData(index);
|
|
160
|
+
return /*#__PURE__*/jsxRuntime.jsx(BodyRow.BodyRow, {
|
|
161
|
+
rowKey: key,
|
|
162
|
+
index: index,
|
|
163
|
+
checkableRows: checkableRows,
|
|
164
|
+
checked: keyProperty && checkState.checked.includes(data[keyProperty]) ? 1 : 0,
|
|
165
|
+
expanded: !!keyProperty && checkState.expanded.includes(data[keyProperty]),
|
|
166
|
+
data: data,
|
|
167
|
+
hideableColumns: hideableColumns,
|
|
168
|
+
keyProperty: keyProperty,
|
|
169
|
+
measureElement: measureElement,
|
|
170
|
+
onRowClick: onRowClick,
|
|
171
|
+
state: state,
|
|
172
|
+
canExpand: canExpand,
|
|
173
|
+
toggleExpand: toggleExpand,
|
|
174
|
+
expandRow: children,
|
|
175
|
+
toggleChecked: toggleChecked,
|
|
176
|
+
wrapperEnd: wrapperEnd,
|
|
177
|
+
wrapperStart: wrapperStart
|
|
178
|
+
}, key);
|
|
179
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
180
|
+
className: "flex-1 flex flex-nowrap",
|
|
181
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
82
182
|
className: wrapperStart,
|
|
83
|
-
children:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, "".concat(key, ":").concat(idc));
|
|
94
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
183
|
+
children: [canExpand && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
184
|
+
className: "w-6"
|
|
185
|
+
}), checkableRows && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
186
|
+
className: "w-6"
|
|
187
|
+
}), (_state$start2 = state.start) === null || _state$start2 === void 0 ? void 0 : _state$start2.map(function (col) {
|
|
188
|
+
return /*#__PURE__*/jsxRuntime.jsx(EmptyCell.EmptyCell, _objectSpread({}, col), String(col.id));
|
|
189
|
+
})]
|
|
190
|
+
}), (_state$cols2 = state.cols) === null || _state$cols2 === void 0 ? void 0 : _state$cols2.map(function (col) {
|
|
191
|
+
return /*#__PURE__*/jsxRuntime.jsx(EmptyCell.EmptyCell, _objectSpread({}, col), String(col.id));
|
|
192
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
95
193
|
className: wrapperEnd,
|
|
96
|
-
children: (
|
|
97
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
})
|
|
194
|
+
children: [(_state$end2 = state.end) === null || _state$end2 === void 0 ? void 0 : _state$end2.map(function (col) {
|
|
195
|
+
return /*#__PURE__*/jsxRuntime.jsx(EmptyCell.EmptyCell, _objectSpread({}, col), String(col.id));
|
|
196
|
+
}), hideableColumns && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
197
|
+
className: "w-6"
|
|
198
|
+
})]
|
|
102
199
|
})]
|
|
103
|
-
}, key);
|
|
104
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
105
|
-
className: "flex-1 flex flex-nowrap",
|
|
106
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
107
|
-
className: wrapperStart,
|
|
108
|
-
children: (_columnMap$start3 = columnMap.start) === null || _columnMap$start3 === void 0 ? void 0 : _columnMap$start3.map(emptyCol)
|
|
109
|
-
}), (_columnMap$cols3 = columnMap.cols) === null || _columnMap$cols3 === void 0 ? void 0 : _columnMap$cols3.map(emptyCol), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
110
|
-
className: wrapperEnd,
|
|
111
|
-
children: (_columnMap$end3 = columnMap.end) === null || _columnMap$end3 === void 0 ? void 0 : _columnMap$end3.map(emptyCol)
|
|
112
200
|
})]
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread({}, col), idx);
|
|
120
|
-
})
|
|
121
|
-
}), (_columnMap$cols4 = columnMap.cols) === null || _columnMap$cols4 === void 0 ? void 0 : _columnMap$cols4.map(function (col, idx) {
|
|
122
|
-
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread({}, col), idx);
|
|
123
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
124
|
-
className: wrapperEnd,
|
|
125
|
-
children: (_columnMap$end4 = columnMap.end) === null || _columnMap$end4 === void 0 ? void 0 : _columnMap$end4.map(function (col, idx) {
|
|
126
|
-
return /*#__PURE__*/jsxRuntime.jsx(HeaderCell.HeaderCell, _objectSpread({}, col), idx);
|
|
127
|
-
})
|
|
128
|
-
})]
|
|
129
|
-
})]
|
|
201
|
+
}), !loading && data.length === 0 && (emptyDisplay !== null && emptyDisplay !== void 0 ? emptyDisplay : /*#__PURE__*/jsxRuntime.jsx(core.EmptyContent, {
|
|
202
|
+
size: "sm",
|
|
203
|
+
className: "bg-dimmed",
|
|
204
|
+
message: t("datagrid.empty")
|
|
205
|
+
}))]
|
|
206
|
+
})
|
|
130
207
|
});
|
|
131
208
|
};
|
|
132
209
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* React Fabric
|
|
5
|
+
* @version: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
14
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
* subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
18
|
+
* portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
21
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
var COL_MIN_WIDTH = "3rem";
|
|
27
|
+
var COL_MAX_WIDTH = "64rem";
|
|
28
|
+
var COL_DEFAULT_WIDTH = "12rem";
|
|
29
|
+
|
|
30
|
+
exports.COL_DEFAULT_WIDTH = COL_DEFAULT_WIDTH;
|
|
31
|
+
exports.COL_MAX_WIDTH = COL_MAX_WIDTH;
|
|
32
|
+
exports.COL_MIN_WIDTH = COL_MIN_WIDTH;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* React Fabric
|
|
5
|
+
* @version: 1.0.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
* Copyright (c) 2024 Adarsh Pastakia
|
|
10
|
+
*
|
|
11
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
12
|
+
* and associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
13
|
+
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
14
|
+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
15
|
+
* subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
18
|
+
* portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
21
|
+
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
22
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
23
|
+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
var useResizer = function useResizer(colEl, ghostEl, callback) {
|
|
27
|
+
var placeholder = ghostEl.firstElementChild;
|
|
28
|
+
var isRtl = getComputedStyle(colEl).direction === "rtl";
|
|
29
|
+
var onResize = function onResize(evt) {
|
|
30
|
+
/** ***************** check if reverse enabled of RTL *******************/
|
|
31
|
+
var box = colEl.getBoundingClientRect();
|
|
32
|
+
var x = isRtl ? box.left - evt.clientX : evt.clientX - box.right;
|
|
33
|
+
placeholder.style.width = "".concat(colEl.offsetWidth + x, "px");
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** ***************** dettach handlers on mouseup *******************/
|
|
37
|
+
var onResizeEnd = function onResizeEnd() {
|
|
38
|
+
callback(placeholder.offsetWidth);
|
|
39
|
+
ghostEl.style.display = "none";
|
|
40
|
+
document.removeEventListener("mousemove", onResize);
|
|
41
|
+
document.removeEventListener("mouseup", onResizeEnd);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** ***************** attach handlers *******************/
|
|
45
|
+
var box = colEl.getBoundingClientRect();
|
|
46
|
+
if (colEl.parentElement != null) {
|
|
47
|
+
var _colEl$parentElement;
|
|
48
|
+
var parentBox = (_colEl$parentElement = colEl.parentElement) === null || _colEl$parentElement === void 0 ? void 0 : _colEl$parentElement.getBoundingClientRect();
|
|
49
|
+
if (isRtl) {
|
|
50
|
+
placeholder.style.left = "unset";
|
|
51
|
+
placeholder.style.right = "".concat(box.right - parentBox.right, "px");
|
|
52
|
+
} else {
|
|
53
|
+
placeholder.style.right = "unset";
|
|
54
|
+
placeholder.style.left = "".concat(box.left - parentBox.left, "px");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
placeholder.style.width = "".concat(colEl.offsetWidth, "px");
|
|
58
|
+
placeholder.style.minWidth = colEl.style.minWidth || "48px";
|
|
59
|
+
placeholder.style.maxWidth = colEl.style.maxWidth || "75vw";
|
|
60
|
+
ghostEl.style.display = "block";
|
|
61
|
+
document.addEventListener("mousemove", onResize);
|
|
62
|
+
document.addEventListener("mouseup", onResizeEnd);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.useResizer = useResizer;
|
|
@@ -1,25 +1,62 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
3
4
|
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
4
5
|
var utilities = require('@react-fabric/utilities');
|
|
5
6
|
var react = require('react');
|
|
6
7
|
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
7
10
|
var useTableColumns = function useTableColumns(columns) {
|
|
8
|
-
var
|
|
11
|
+
var _useReducer = react.useReducer(function (state, action) {
|
|
12
|
+
if (action.type === "columns") {
|
|
13
|
+
state.columns = action.columns;
|
|
14
|
+
}
|
|
15
|
+
if (action.type === "hide") {
|
|
16
|
+
var col = state.columns.find(function (col) {
|
|
17
|
+
return col.id === action.id;
|
|
18
|
+
});
|
|
19
|
+
col && state.columns.splice(state.columns.indexOf(col), 1, _objectSpread(_objectSpread({}, col), {}, {
|
|
20
|
+
hidden: col.hidden !== true
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
var _groupBy = utilities.groupBy(state.columns.filter(function (col) {
|
|
24
|
+
return col.hidden !== true;
|
|
25
|
+
}), "locked", "cols"),
|
|
26
|
+
_groupBy$start = _groupBy.start,
|
|
27
|
+
start = _groupBy$start === void 0 ? [] : _groupBy$start,
|
|
28
|
+
_groupBy$end = _groupBy.end,
|
|
29
|
+
end = _groupBy$end === void 0 ? [] : _groupBy$end,
|
|
30
|
+
_groupBy$cols = _groupBy.cols,
|
|
31
|
+
cols = _groupBy$cols === void 0 ? [] : _groupBy$cols;
|
|
32
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
33
|
+
start: start,
|
|
34
|
+
end: end,
|
|
35
|
+
cols: cols
|
|
36
|
+
});
|
|
37
|
+
}, {
|
|
38
|
+
columns: [],
|
|
9
39
|
start: [],
|
|
10
40
|
end: [],
|
|
11
41
|
cols: []
|
|
12
42
|
}),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
43
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
44
|
+
state = _useReducer2[0],
|
|
45
|
+
dispatch = _useReducer2[1];
|
|
16
46
|
react.useEffect(function () {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
47
|
+
dispatch({
|
|
48
|
+
type: "columns",
|
|
49
|
+
columns: columns
|
|
50
|
+
});
|
|
20
51
|
}, [columns]);
|
|
21
52
|
return {
|
|
22
|
-
|
|
53
|
+
state: state,
|
|
54
|
+
onHide: function onHide(id) {
|
|
55
|
+
return dispatch({
|
|
56
|
+
type: "hide",
|
|
57
|
+
id: id
|
|
58
|
+
});
|
|
59
|
+
}
|
|
23
60
|
};
|
|
24
61
|
};
|
|
25
62
|
|