@react-fabric/data 1.0.0-beta.60 → 1.0.0-beta.62
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 +4 -4
- package/dist/cjs/histogram/Histogram.js +2 -2
- package/dist/cjs/i18n/index.js +4 -4
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/json/JsonViewer.js +3 -3
- package/dist/cjs/pagination/Pagination.js +11 -11
- package/dist/cjs/table/AddColumn.js +2 -2
- package/dist/cjs/table/BodyCell.js +11 -4
- package/dist/cjs/table/BodyRow.js +2 -2
- package/dist/cjs/table/CheckboxCell.js +1 -1
- package/dist/cjs/table/HeaderCell.js +4 -4
- package/dist/cjs/table/HtmlTable.js +78 -0
- package/dist/cjs/table/Table.js +17 -14
- package/dist/cjs/tree/TreeNode.js +4 -4
- package/dist/cjs/tree/TreePanel.js +7 -8
- package/dist/cjs/virtual/Scroller.js +4 -4
- package/dist/esm/checklist/CheckList.js +5 -5
- package/dist/esm/histogram/Histogram.js +3 -3
- package/dist/esm/i18n/index.js +2 -2
- package/dist/esm/index.js +1 -0
- package/dist/esm/json/JsonViewer.js +4 -4
- package/dist/esm/pagination/Pagination.js +12 -12
- package/dist/esm/table/AddColumn.js +3 -3
- package/dist/esm/table/BodyCell.js +12 -5
- package/dist/esm/table/BodyRow.js +2 -2
- package/dist/esm/table/CheckboxCell.js +2 -2
- package/dist/esm/table/HeaderCell.js +5 -5
- package/dist/esm/table/HtmlTable.js +78 -0
- package/dist/esm/table/Table.js +18 -15
- package/dist/esm/tree/TreeNode.js +6 -6
- package/dist/esm/tree/TreePanel.js +8 -9
- package/dist/esm/virtual/Scroller.js +5 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/table/HtmlTable.d.ts +21 -0
- package/dist/types/table/types.d.ts +5 -5
- package/dist/types/tree/TreePanel.d.ts +2 -2
- package/dist/types/tree/types.d.ts +0 -2
- package/package.json +6 -6
- package/src/checklist/CheckList.tsx +17 -7
- package/src/histogram/Histogram.tsx +3 -9
- package/src/i18n/index.ts +2 -2
- package/src/index.ts +1 -0
- package/src/json/JsonViewer.tsx +7 -4
- package/src/pagination/Pagination.tsx +12 -12
- package/src/table/AddColumn.tsx +3 -3
- package/src/table/BodyCell.tsx +18 -3
- package/src/table/BodyRow.tsx +4 -2
- package/src/table/CheckboxCell.tsx +4 -4
- package/src/table/HeaderCell.tsx +4 -5
- package/src/table/HtmlTable.tsx +128 -0
- package/src/table/Table.tsx +24 -17
- package/src/table/types.ts +5 -4
- package/src/tree/TreeNode.tsx +7 -13
- package/src/tree/TreePanel.tsx +13 -18
- package/src/tree/types.ts +0 -5
- package/src/virtual/Scroller.tsx +13 -5
- package/dist/cjs/tree/types.js +0 -30
- package/dist/esm/tree/types.js +0 -29
- /package/dist/cjs/i18n/{ar.json.js → ar/data.json.js} +0 -0
- /package/dist/cjs/i18n/{en.json.js → en/data.json.js} +0 -0
- /package/dist/esm/i18n/{ar.json.js → ar/data.json.js} +0 -0
- /package/dist/esm/i18n/{en.json.js → en/data.json.js} +0 -0
- /package/src/i18n/{ar.json → ar/data.json} +0 -0
- /package/src/i18n/{en.json → en/data.json} +0 -0
package/dist/esm/i18n/index.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { CheckList } from './checklist/CheckList.js';
|
|
|
5
5
|
export { Histogram } from './histogram/Histogram.js';
|
|
6
6
|
export { JsonViewer } from './json/JsonViewer.js';
|
|
7
7
|
export { Pagination } from './pagination/Pagination.js';
|
|
8
|
+
export { HtmlTable } from './table/HtmlTable.js';
|
|
8
9
|
export { Table } from './table/Table.js';
|
|
9
10
|
export { TreePanel } from './tree/TreePanel.js';
|
|
10
11
|
export { VirtualGallery } from './virtual/Gallery.js';
|
|
@@ -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, Button,
|
|
7
|
+
import { EmptyContent, Text, Meter, Button, 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';
|
|
@@ -133,7 +133,7 @@ var JsonEntry = function JsonEntry(_ref3) {
|
|
|
133
133
|
color: "danger",
|
|
134
134
|
size: "xs",
|
|
135
135
|
variant: "link",
|
|
136
|
-
icon:
|
|
136
|
+
icon: "icon-[mdi--filter-minus]",
|
|
137
137
|
"aria-label": "Filter Negative",
|
|
138
138
|
onClick: function onClick() {
|
|
139
139
|
return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue, true);
|
|
@@ -142,7 +142,7 @@ var JsonEntry = function JsonEntry(_ref3) {
|
|
|
142
142
|
color: "primary",
|
|
143
143
|
size: "xs",
|
|
144
144
|
variant: "link",
|
|
145
|
-
icon:
|
|
145
|
+
icon: "icon-[mdi--filter-plus]",
|
|
146
146
|
"aria-label": "Filter",
|
|
147
147
|
onClick: function onClick() {
|
|
148
148
|
return onFilter === null || onFilter === void 0 ? void 0 : onFilter(pathWithoutOrdinal, actualValue);
|
|
@@ -168,7 +168,7 @@ var JsonEntry = function JsonEntry(_ref3) {
|
|
|
168
168
|
},
|
|
169
169
|
children: [canExpand && /*#__PURE__*/jsx(Icon, {
|
|
170
170
|
rtlFlip: true,
|
|
171
|
-
icon: expanded ?
|
|
171
|
+
icon: expanded ? "icon-[mdi--chevron-down]" : "icon-[mdi--chevron-right]"
|
|
172
172
|
}), labelDisplay]
|
|
173
173
|
}), display && /*#__PURE__*/jsxs("div", {
|
|
174
174
|
className: classNames("px-2 flex flex-nowrap overflow-hidden", inline && "flex-1"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import { Icon
|
|
4
|
+
import { Icon } from '@react-fabric/core';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { memo, useMemo, Fragment } from 'react';
|
|
7
7
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -33,7 +33,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
|
33
33
|
onClick: function onClick() {
|
|
34
34
|
return onPageChange(pg);
|
|
35
35
|
},
|
|
36
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
36
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
37
37
|
children: pg + 1
|
|
38
38
|
}, pg);
|
|
39
39
|
}), mid && /*#__PURE__*/jsx("span", {
|
|
@@ -44,7 +44,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
|
44
44
|
onClick: function onClick() {
|
|
45
45
|
return onPageChange(pg);
|
|
46
46
|
},
|
|
47
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
47
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
48
48
|
children: pg + 1
|
|
49
49
|
}, pg);
|
|
50
50
|
}), last && /*#__PURE__*/jsx("span", {
|
|
@@ -55,7 +55,7 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
|
55
55
|
onClick: function onClick() {
|
|
56
56
|
return onPageChange(pg);
|
|
57
57
|
},
|
|
58
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
58
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === pg && "bg-primary-500 text-white pointer-events-none"),
|
|
59
59
|
children: pg + 1
|
|
60
60
|
}, pg);
|
|
61
61
|
})]
|
|
@@ -67,18 +67,18 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
|
67
67
|
onClick: function onClick() {
|
|
68
68
|
return onPageChange(0);
|
|
69
69
|
},
|
|
70
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
|
|
70
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === 0 && "pointer-events-none text-tint-300"),
|
|
71
71
|
children: /*#__PURE__*/jsx(Icon, {
|
|
72
|
-
icon:
|
|
72
|
+
icon: "icon-[mdi--chevron-double-left]",
|
|
73
73
|
rtlFlip: true
|
|
74
74
|
})
|
|
75
75
|
}), /*#__PURE__*/jsx("button", {
|
|
76
76
|
onClick: function onClick() {
|
|
77
77
|
return onPageChange(page - 1);
|
|
78
78
|
},
|
|
79
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page === 0 && "pointer-events-none text-tint-300"),
|
|
79
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page === 0 && "pointer-events-none text-tint-300"),
|
|
80
80
|
children: /*#__PURE__*/jsx(Icon, {
|
|
81
|
-
icon:
|
|
81
|
+
icon: "icon-[mdi--chevron-left]",
|
|
82
82
|
rtlFlip: true
|
|
83
83
|
})
|
|
84
84
|
}), !minimal && pageBody, minimal && /*#__PURE__*/jsxs("label", {
|
|
@@ -88,18 +88,18 @@ var Pagination = /*#__PURE__*/memo(function (_ref) {
|
|
|
88
88
|
onClick: function onClick() {
|
|
89
89
|
return onPageChange(page + 1);
|
|
90
90
|
},
|
|
91
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
|
|
91
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
|
|
92
92
|
children: /*#__PURE__*/jsx(Icon, {
|
|
93
|
-
icon:
|
|
93
|
+
icon: "icon-[mdi--chevron-right]",
|
|
94
94
|
rtlFlip: true
|
|
95
95
|
})
|
|
96
96
|
}), /*#__PURE__*/jsx("button", {
|
|
97
97
|
onClick: function onClick() {
|
|
98
98
|
return onPageChange(totalPages - 1);
|
|
99
99
|
},
|
|
100
|
-
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
|
|
100
|
+
className: classNames("leading-none text-sm hover:bg-primary-200 w-8 h-6 rounded-full cursor-pointer", page + 1 >= totalPages && "pointer-events-none text-tint-300"),
|
|
101
101
|
children: /*#__PURE__*/jsx(Icon, {
|
|
102
|
-
icon:
|
|
102
|
+
icon: "icon-[mdi--chevron-double-right]",
|
|
103
103
|
rtlFlip: true
|
|
104
104
|
})
|
|
105
105
|
})]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Dropdown, Icon,
|
|
3
|
+
import { Dropdown, Icon, Menu, MenuItem } from '@react-fabric/core';
|
|
4
4
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
/*
|
|
@@ -34,7 +34,7 @@ var AddColumn = function AddColumn(_ref) {
|
|
|
34
34
|
children: /*#__PURE__*/jsxs(Dropdown, {
|
|
35
35
|
placement: "bottom-end",
|
|
36
36
|
children: [/*#__PURE__*/jsx(Icon, {
|
|
37
|
-
icon:
|
|
37
|
+
icon: "icon-[mdi--plus-circle-outline]",
|
|
38
38
|
className: "p-1 rounded-t rounded-b-none hover:outline"
|
|
39
39
|
}), /*#__PURE__*/jsx(Menu, {
|
|
40
40
|
className: "text-sm",
|
|
@@ -45,7 +45,7 @@ var AddColumn = function AddColumn(_ref) {
|
|
|
45
45
|
id: String(col.id),
|
|
46
46
|
"data-dropdown-dismiss": "false",
|
|
47
47
|
label: "".concat((_col$label = col.label) !== null && _col$label !== void 0 ? _col$label : String(col.id)),
|
|
48
|
-
icon: !col.hidden ?
|
|
48
|
+
icon: !col.hidden ? "icon-[mdi--check]" : ""
|
|
49
49
|
}, String(col.id));
|
|
50
50
|
})
|
|
51
51
|
})]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { DateDisplay } from '@react-fabric/date';
|
|
4
|
-
import { getByPath, isTrue, Format } from '@react-fabric/utilities';
|
|
4
|
+
import { getByPath, isTrue, Format, isObject, isArray } from '@react-fabric/utilities';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
import { useTableContext } from './Context.js';
|
|
@@ -43,7 +43,7 @@ var BodyCell = function BodyCell(_ref) {
|
|
|
43
43
|
return (_widths$get = widths.get(column.id.toString())) !== null && _widths$get !== void 0 ? _widths$get : column.width;
|
|
44
44
|
}, [widths, column]);
|
|
45
45
|
var content = useMemo(function () {
|
|
46
|
-
var _column$
|
|
46
|
+
var _column$dataType2;
|
|
47
47
|
var value = getByPath(item, column.id.toString());
|
|
48
48
|
if (column.renderer != null) {
|
|
49
49
|
return column.renderer(value, item, index);
|
|
@@ -52,16 +52,17 @@ var BodyCell = function BodyCell(_ref) {
|
|
|
52
52
|
var _column$valueMap;
|
|
53
53
|
var map = (_column$valueMap = column.valueMap) !== null && _column$valueMap !== void 0 ? _column$valueMap : {
|
|
54
54
|
"true": "Yes",
|
|
55
|
-
"false": "
|
|
55
|
+
"false": "No"
|
|
56
56
|
};
|
|
57
57
|
return map["".concat(isTrue(value) ? "true" : "false")];
|
|
58
58
|
}
|
|
59
59
|
if (column.valueMap != null) {
|
|
60
|
-
|
|
60
|
+
var _column$dataType;
|
|
61
|
+
if (["number", "string"].includes((_column$dataType = column.dataType) !== null && _column$dataType !== void 0 ? _column$dataType : "string") && value in column.valueMap) {
|
|
61
62
|
return column.valueMap[value];
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
if (["date", "time", "datetime"].includes((_column$
|
|
65
|
+
if (["date", "time", "datetime"].includes((_column$dataType2 = column.dataType) !== null && _column$dataType2 !== void 0 ? _column$dataType2 : "")) {
|
|
65
66
|
return /*#__PURE__*/jsx(DateDisplay, {
|
|
66
67
|
date: value,
|
|
67
68
|
format: column.format
|
|
@@ -70,6 +71,12 @@ var BodyCell = function BodyCell(_ref) {
|
|
|
70
71
|
if (column.dataType === "number") {
|
|
71
72
|
return Format.number(value, column.format);
|
|
72
73
|
}
|
|
74
|
+
if (isObject(value)) {
|
|
75
|
+
return JSON.stringify(value);
|
|
76
|
+
}
|
|
77
|
+
if (isArray(value)) {
|
|
78
|
+
return value.join(", ");
|
|
79
|
+
}
|
|
73
80
|
return value !== null && value !== void 0 ? value : "";
|
|
74
81
|
}, [item, column]);
|
|
75
82
|
return /*#__PURE__*/jsx("div", {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { Icon } from '@react-fabric/core';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
5
|
import { BodyCell } from './BodyCell.js';
|
|
5
6
|
import { CheckboxCell } from './CheckboxCell.js';
|
|
6
|
-
import { Icon, CoreIcons } from '@react-fabric/core';
|
|
7
7
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
/*
|
|
@@ -65,7 +65,7 @@ var BodyRow = function BodyRow(_ref) {
|
|
|
65
65
|
className: classNames("group font-medium w-6 flex flex-nowrap text-start py-1", !canExpand(data) && "pointer-events-none opacity-35"),
|
|
66
66
|
children: /*#__PURE__*/jsx(Icon, {
|
|
67
67
|
className: "p-1 text-tint-700 hover:text-primary-600",
|
|
68
|
-
icon: expanded ?
|
|
68
|
+
icon: expanded ? "icon-[mdi--minus-box]" : "icon-[mdi--plus-box]",
|
|
69
69
|
onClick: function onClick(e) {
|
|
70
70
|
return [keyProperty && toggleExpand(data[keyProperty]), e.stopPropagation()];
|
|
71
71
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Icon
|
|
3
|
+
import { Icon } from '@react-fabric/core';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
/*
|
|
@@ -32,7 +32,7 @@ var CheckboxCell = function CheckboxCell(_ref) {
|
|
|
32
32
|
return /*#__PURE__*/jsx("div", {
|
|
33
33
|
className: "group font-medium border-e w-6 flex flex-nowrap text-start py-1",
|
|
34
34
|
children: /*#__PURE__*/jsx(Icon, {
|
|
35
|
-
icon: state === 2 ?
|
|
35
|
+
icon: state === 2 ? "icon-[mdi--checkbox-intermediate]" : state === 1 ? "icon-[mdi--checkbox-marked]" : "icon-[mdi--checkbox-blank-outline]",
|
|
36
36
|
className: "p-1 text-tint-700 hover:text-primary-600",
|
|
37
37
|
onClick: function onClick(e) {
|
|
38
38
|
return [_onClick === null || _onClick === void 0 ? void 0 : _onClick(), e.stopPropagation()];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
5
|
-
import { Menu,
|
|
5
|
+
import { Menu, MenuItem, Divider, Tooltip, Icon, getIconProps, DropdownTool, Button } from '@react-fabric/core';
|
|
6
6
|
import { isEmpty } from '@react-fabric/utilities';
|
|
7
7
|
import { useMemo, useCallback } from 'react';
|
|
8
8
|
import { ColumnFilters } from './ColumnFilters.js';
|
|
@@ -50,7 +50,7 @@ var HeaderCell = function HeaderCell(_ref) {
|
|
|
50
50
|
if (filterable && (dataType !== null && dataType !== void 0 ? dataType : filterOptions)) {
|
|
51
51
|
ret.push( /*#__PURE__*/jsx(Menu, {
|
|
52
52
|
label: "Filter",
|
|
53
|
-
icon: filter ?
|
|
53
|
+
icon: filter ? "icon-[mdi--check]" : "",
|
|
54
54
|
trigger: "click",
|
|
55
55
|
children: /*#__PURE__*/jsx(ColumnFilters, {
|
|
56
56
|
type: dataType,
|
|
@@ -65,13 +65,13 @@ var HeaderCell = function HeaderCell(_ref) {
|
|
|
65
65
|
if (sortable) {
|
|
66
66
|
ret.push( /*#__PURE__*/jsx(MenuItem, {
|
|
67
67
|
label: "Sort ascending",
|
|
68
|
-
icon:
|
|
68
|
+
icon: "icon-[mdi--sort-ascending]",
|
|
69
69
|
onClick: function onClick() {
|
|
70
70
|
return handleSort("asc");
|
|
71
71
|
}
|
|
72
72
|
}, "sort-asc"), /*#__PURE__*/jsx(MenuItem, {
|
|
73
73
|
label: "Sort descending",
|
|
74
|
-
icon:
|
|
74
|
+
icon: "icon-[mdi--sort-descending]",
|
|
75
75
|
onClick: function onClick() {
|
|
76
76
|
return handleSort("desc");
|
|
77
77
|
}
|
|
@@ -136,7 +136,7 @@ var HeaderCell = function HeaderCell(_ref) {
|
|
|
136
136
|
variant: "link",
|
|
137
137
|
"aria-label": "clear filter",
|
|
138
138
|
stopPropagation: true,
|
|
139
|
-
icon:
|
|
139
|
+
icon: "icon-[mdi--filter-remove]",
|
|
140
140
|
onClick: function onClick() {
|
|
141
141
|
return _onFilter === null || _onFilter === void 0 ? void 0 : _onFilter(id);
|
|
142
142
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import { Footer } from '@react-fabric/core';
|
|
5
|
+
import { getByPath } from '@react-fabric/utilities';
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
import { usePagination } from '../hooks/usePagination.js';
|
|
9
|
+
import { Pagination } from '../pagination/Pagination.js';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
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
|
+
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
|
+
var HtmlTable = function HtmlTable(_ref) {
|
|
15
|
+
var data = _ref.data,
|
|
16
|
+
columns = _ref.columns,
|
|
17
|
+
_ref$paginationSize = _ref.paginationSize,
|
|
18
|
+
paginationSize = _ref$paginationSize === void 0 ? 25 : _ref$paginationSize,
|
|
19
|
+
className = _ref.className;
|
|
20
|
+
var paginator = usePagination({
|
|
21
|
+
totalRecords: data.length,
|
|
22
|
+
perPage: paginationSize
|
|
23
|
+
});
|
|
24
|
+
var startIndex = useMemo(function () {
|
|
25
|
+
return paginator.page * paginationSize;
|
|
26
|
+
}, [paginator.page, paginationSize]);
|
|
27
|
+
var dataPage = useMemo(function () {
|
|
28
|
+
return paginationSize > 0 ? data.slice(startIndex, startIndex + paginationSize) : data;
|
|
29
|
+
}, [data, paginationSize, startIndex]);
|
|
30
|
+
return /*#__PURE__*/jsxs("div", {
|
|
31
|
+
className: className,
|
|
32
|
+
children: [/*#__PURE__*/jsxs("table", {
|
|
33
|
+
className: "table-fixed border-spacing-1 border-separate w-full text-sm",
|
|
34
|
+
children: [/*#__PURE__*/jsx("thead", {
|
|
35
|
+
className: "sticky top-0 z-1",
|
|
36
|
+
children: /*#__PURE__*/jsx("tr", {
|
|
37
|
+
children: columns.map(function (col, idx) {
|
|
38
|
+
var _ref2, _col$headRenderer;
|
|
39
|
+
return /*#__PURE__*/jsx("th", {
|
|
40
|
+
className: "text-start truncate bg-accent-100 px-2 py-1 font-medium text-accent-800",
|
|
41
|
+
style: {
|
|
42
|
+
width: col.width,
|
|
43
|
+
maxWidth: col.maxWidth
|
|
44
|
+
},
|
|
45
|
+
children: (_ref2 = (_col$headRenderer = col.headRenderer) !== null && _col$headRenderer !== void 0 ? _col$headRenderer : col.label) !== null && _ref2 !== void 0 ? _ref2 : " "
|
|
46
|
+
}, idx);
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
}), /*#__PURE__*/jsx("tbody", {
|
|
50
|
+
className: "bg-alternate",
|
|
51
|
+
children: dataPage.map(function (row, idx) {
|
|
52
|
+
return /*#__PURE__*/jsx("tr", {
|
|
53
|
+
children: columns.map(function (col, cidx) {
|
|
54
|
+
var _col$renderer, _col$renderer2;
|
|
55
|
+
return /*#__PURE__*/jsx("td", {
|
|
56
|
+
className: classNames("px-2 py-1 truncate", col.align === "center" && "text-center", col.align === "end" && "text-end", col.className),
|
|
57
|
+
style: {
|
|
58
|
+
width: col.width,
|
|
59
|
+
maxWidth: col.maxWidth
|
|
60
|
+
},
|
|
61
|
+
children: (_col$renderer = (_col$renderer2 = col.renderer) === null || _col$renderer2 === void 0 ? void 0 : _col$renderer2.call(col, getByPath(row, col.id.toString()), row, startIndex + idx)) !== null && _col$renderer !== void 0 ? _col$renderer : getByPath(row, col.id.toString())
|
|
62
|
+
}, "".concat(idx, "-").concat(cidx));
|
|
63
|
+
})
|
|
64
|
+
}, idx);
|
|
65
|
+
})
|
|
66
|
+
})]
|
|
67
|
+
}), paginationSize > 0 && /*#__PURE__*/jsx(Footer, {
|
|
68
|
+
flex: true,
|
|
69
|
+
justify: "end",
|
|
70
|
+
className: "px-2 py-1 sticky bottom-0 bg-tint-50",
|
|
71
|
+
children: /*#__PURE__*/jsx(Pagination, _objectSpread({
|
|
72
|
+
minimal: true
|
|
73
|
+
}, paginator))
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export { HtmlTable };
|
package/dist/esm/table/Table.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import { useDebounce,
|
|
4
|
+
import { useDebounce, LoadingLine, Icon, EmptyContent } from '@react-fabric/core';
|
|
5
5
|
import { debounce } from '@react-fabric/utilities';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { useRef, useMemo, useLayoutEffect, useImperativeHandle, useEffect } from 'react';
|
|
@@ -168,7 +168,7 @@ var Table = function Table(_ref) {
|
|
|
168
168
|
})
|
|
169
169
|
})]
|
|
170
170
|
})]
|
|
171
|
-
}), loading && /*#__PURE__*/jsx(
|
|
171
|
+
}), loading && /*#__PURE__*/jsx(LoadingLine, {}), data.length > 0 && /*#__PURE__*/jsxs("div", {
|
|
172
172
|
className: "area-content flex flex-col flex-nowrap min-h-full",
|
|
173
173
|
style: {
|
|
174
174
|
height: totalSize()
|
|
@@ -183,26 +183,29 @@ var Table = function Table(_ref) {
|
|
|
183
183
|
var index = _ref2.index,
|
|
184
184
|
key = _ref2.key;
|
|
185
185
|
var data = getData(index);
|
|
186
|
-
return "__GROUP__" in data ? /*#__PURE__*/
|
|
186
|
+
return "__GROUP__" in data ? /*#__PURE__*/jsx("div", {
|
|
187
187
|
ref: measureElement,
|
|
188
188
|
"data-index": index,
|
|
189
|
-
className: classNames("
|
|
189
|
+
className: classNames("text-md bg-base border-y border-tint-100 border-t-0 cursor-pointer flex items-center justify-start gap-1 z-2", isActiveSticky(index) && "sticky top-8"),
|
|
190
190
|
role: "none",
|
|
191
191
|
onClick: function onClick() {
|
|
192
192
|
return toggleGroupExpand(data.key);
|
|
193
193
|
},
|
|
194
|
-
children:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
195
|
+
className: classNames("px-2 py-1 flex items-center gap-1 z-2 sticky start-0"),
|
|
196
|
+
children: [/*#__PURE__*/jsx(Icon, {
|
|
197
|
+
rtlFlip: true,
|
|
198
|
+
icon: data.open ? "icon-[mdi--chevron-down]" : "icon-[mdi--chevron-right]"
|
|
199
|
+
}), (_groupRenderer = groupRenderer === null || groupRenderer === void 0 ? void 0 : groupRenderer(data)) !== null && _groupRenderer !== void 0 ? _groupRenderer : /*#__PURE__*/jsxs("div", {
|
|
200
|
+
className: "flex gap-1 items-center",
|
|
201
|
+
children: [/*#__PURE__*/jsx("span", {
|
|
202
|
+
children: data.key
|
|
203
|
+
}), /*#__PURE__*/jsxs("span", {
|
|
204
|
+
className: "text-sm",
|
|
205
|
+
children: ["(", data.itemCount, ")"]
|
|
206
|
+
})]
|
|
204
207
|
})]
|
|
205
|
-
})
|
|
208
|
+
})
|
|
206
209
|
}, key) : /*#__PURE__*/jsx(BodyRow, {
|
|
207
210
|
rowKey: key.toString(),
|
|
208
211
|
index: index,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import { getBadgeProps, Icon,
|
|
5
|
-
import { isString, isEmpty } from '@react-fabric/utilities';
|
|
4
|
+
import { getBadgeProps, Icon, getIconProps, Badge } from '@react-fabric/core';
|
|
5
|
+
import { isTrue, isString, isEmpty } from '@react-fabric/utilities';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { useMemo, isValidElement } from 'react';
|
|
8
8
|
import { useTranslation } from 'react-i18next';
|
|
@@ -57,7 +57,7 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
57
57
|
};
|
|
58
58
|
}, [defaultLeafIcon, defaultNodeIcon, node.icon]);
|
|
59
59
|
var canCheck = useMemo(function () {
|
|
60
|
-
return checkable
|
|
60
|
+
return isTrue(checkable) || checkable === "leafOnly" && node.leaf;
|
|
61
61
|
}, [node.leaf, checkable]);
|
|
62
62
|
var canSelect = useMemo(function () {
|
|
63
63
|
return !node.disabled && (selectable === true || selectable === "leafOnly" && node.leaf);
|
|
@@ -72,8 +72,8 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
72
72
|
children: [filler, node.loading && /*#__PURE__*/jsx("div", {
|
|
73
73
|
className: "flex-initial w-6",
|
|
74
74
|
children: /*#__PURE__*/jsx(Icon, {
|
|
75
|
-
icon:
|
|
76
|
-
className: "
|
|
75
|
+
icon: "icon-[svg-spinners--eclipse]",
|
|
76
|
+
className: "text-muted"
|
|
77
77
|
})
|
|
78
78
|
}), !node.leaf && !node.childFiltered && !node.loading && /*#__PURE__*/jsx("div", {
|
|
79
79
|
className: "flex-initial w-6",
|
|
@@ -91,7 +91,7 @@ var TreeNode = function TreeNode(_ref) {
|
|
|
91
91
|
onClick: function onClick() {
|
|
92
92
|
return !node.disabled && onChecked(node.id);
|
|
93
93
|
},
|
|
94
|
-
icon: node.checked === 2 ?
|
|
94
|
+
icon: node.checked === 2 ? "icon-[mdi--checkbox-intermediate]" : node.checked === 1 ? "icon-[mdi--checkbox-marked]" : "icon-[mdi--checkbox-blank-outline]",
|
|
95
95
|
className: classNames(node.disabled ? "text-muted" : "text-primary-500 hover:text-primary-600")
|
|
96
96
|
})
|
|
97
97
|
}), !node.empty && /*#__PURE__*/jsxs("div", {
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
4
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
-
import {
|
|
5
|
+
import { Section, Header, Icon, ButtonGroup, Button } from '@react-fabric/core';
|
|
6
6
|
import { Search } from '@react-fabric/form';
|
|
7
7
|
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
8
8
|
import { useRef, useMemo, useImperativeHandle, useEffect } from 'react';
|
|
9
9
|
import { TreeNode } from './TreeNode.js';
|
|
10
|
-
import { iconExpandAll, iconCollapseAll } from './types.js';
|
|
11
10
|
import { useTree } from './useTree.js';
|
|
12
11
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
13
12
|
|
|
@@ -81,10 +80,10 @@ var TreePanel = function TreePanel(_ref) {
|
|
|
81
80
|
});
|
|
82
81
|
var virtualItems = virtualizer.getVirtualItems();
|
|
83
82
|
var expanders = useMemo(function () {
|
|
84
|
-
if (expander === "caret") return [
|
|
85
|
-
if (expander === "chevron") return [
|
|
86
|
-
if (expander === "folder") return [
|
|
87
|
-
return [
|
|
83
|
+
if (expander === "caret") return ["icon-[mdi--menu-right]", "icon-[mdi--menu-down]"];
|
|
84
|
+
if (expander === "chevron") return ["icon-[mdi--chevron-right]", "icon-[mdi--chevron-down]"];
|
|
85
|
+
if (expander === "folder") return ["icon-[mdi--folder-outline]", "icon-[mdi--folder-open-outline]"];
|
|
86
|
+
return ["icon-[mdi--plus-box-outline]", "icon-[mdi--minus-box-outline]"];
|
|
88
87
|
}, [expander]);
|
|
89
88
|
useImperativeHandle(ref, function () {
|
|
90
89
|
return {
|
|
@@ -118,7 +117,7 @@ var TreePanel = function TreePanel(_ref) {
|
|
|
118
117
|
placeholder: filterPlaceholder,
|
|
119
118
|
noBorder: true,
|
|
120
119
|
decorateStart: /*#__PURE__*/jsx(Icon, {
|
|
121
|
-
icon:
|
|
120
|
+
icon: "icon-[mdi--filter-variant]",
|
|
122
121
|
className: "p-1"
|
|
123
122
|
})
|
|
124
123
|
}), /*#__PURE__*/jsxs(ButtonGroup, {
|
|
@@ -127,12 +126,12 @@ var TreePanel = function TreePanel(_ref) {
|
|
|
127
126
|
children: [/*#__PURE__*/jsx(Button, {
|
|
128
127
|
size: "sm",
|
|
129
128
|
"aria-label": "expand all",
|
|
130
|
-
icon:
|
|
129
|
+
icon: "icon-[mdi--arrow-expand-vertical]",
|
|
131
130
|
onClick: expandAll
|
|
132
131
|
}), /*#__PURE__*/jsx(Button, {
|
|
133
132
|
size: "sm",
|
|
134
133
|
"aria-label": "collapse all",
|
|
135
|
-
icon:
|
|
134
|
+
icon: "icon-[mdi--arrow-collapse-vertical]",
|
|
136
135
|
onClick: collapseAll
|
|
137
136
|
})]
|
|
138
137
|
})]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { ButtonGroup, Button
|
|
3
|
+
import { ButtonGroup, Button } from '@react-fabric/core';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
6
6
|
/*
|
|
@@ -43,7 +43,7 @@ var Scroller = function Scroller(_ref) {
|
|
|
43
43
|
variant: "link",
|
|
44
44
|
"aria-label": "scroll to top",
|
|
45
45
|
icon: {
|
|
46
|
-
icon: vertical ?
|
|
46
|
+
icon: vertical ? "icon-[mdi--chevron-double-up]" : "icon-[mdi--chevron-double-left]",
|
|
47
47
|
rtlFlip: true
|
|
48
48
|
},
|
|
49
49
|
disabled: (scrollActive & 2) === 0,
|
|
@@ -53,7 +53,7 @@ var Scroller = function Scroller(_ref) {
|
|
|
53
53
|
variant: "link",
|
|
54
54
|
"aria-label": "scroll up",
|
|
55
55
|
icon: {
|
|
56
|
-
icon: vertical ?
|
|
56
|
+
icon: vertical ? "icon-[mdi--chevron-up]" : "icon-[mdi--chevron-left]",
|
|
57
57
|
rtlFlip: true
|
|
58
58
|
},
|
|
59
59
|
disabled: (scrollActive & 2) === 0,
|
|
@@ -63,7 +63,7 @@ var Scroller = function Scroller(_ref) {
|
|
|
63
63
|
variant: "link",
|
|
64
64
|
"aria-label": "scroll down",
|
|
65
65
|
icon: {
|
|
66
|
-
icon: vertical ?
|
|
66
|
+
icon: vertical ? "icon-[mdi--chevron-down]" : "icon-[mdi--chevron-right]",
|
|
67
67
|
rtlFlip: true
|
|
68
68
|
},
|
|
69
69
|
disabled: scrollActive % 2 === 0,
|
|
@@ -73,7 +73,7 @@ var Scroller = function Scroller(_ref) {
|
|
|
73
73
|
variant: "link",
|
|
74
74
|
"aria-label": "scroll to bottom",
|
|
75
75
|
icon: {
|
|
76
|
-
icon: vertical ?
|
|
76
|
+
icon: vertical ? "icon-[mdi--chevron-double-down]" : "icon-[mdi--chevron-double-right]",
|
|
77
77
|
rtlFlip: true
|
|
78
78
|
},
|
|
79
79
|
disabled: scrollActive % 2 === 0,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { CheckList } from "./checklist/CheckList";
|
|
|
3
3
|
export { Histogram } from "./histogram/Histogram";
|
|
4
4
|
export { JsonViewer } from "./json/JsonViewer";
|
|
5
5
|
export { Pagination } from "./pagination/Pagination";
|
|
6
|
+
export { HtmlTable } from "./table/HtmlTable";
|
|
6
7
|
export { Table } from "./table/Table";
|
|
7
8
|
export { type TableColumn, type TableRef } from "./table/types";
|
|
8
9
|
export { TreePanel } from "./tree/TreePanel";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface Props<T = KeyValue> {
|
|
2
|
+
data: T[];
|
|
3
|
+
columns: Array<{
|
|
4
|
+
id: keyof T;
|
|
5
|
+
label?: string;
|
|
6
|
+
width?: number | string;
|
|
7
|
+
maxWidth?: number | string;
|
|
8
|
+
align?: "start" | "center" | "end";
|
|
9
|
+
className?: string;
|
|
10
|
+
headRenderer?: React.ReactNode;
|
|
11
|
+
renderer?: (value: any, row: T, index: number) => React.ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Number of pagination buttons to show, default is 25
|
|
15
|
+
* If set to 0, pagination will be hidden
|
|
16
|
+
*/
|
|
17
|
+
paginationSize?: number;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const HtmlTable: <T extends KeyValue = KeyValue>({ data, columns, paginationSize, className, }: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IconProps } from "@react-fabric/core/dist/types/components/icon/Icon";
|
|
2
|
-
import { type CssProp, type Elements, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
2
|
+
import { type CssProp, type Elements, type NestedKeys, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
|
|
3
3
|
import { type ReactElement } from "react";
|
|
4
4
|
export declare const COL_MIN_WIDTH = "3rem";
|
|
5
5
|
export declare const COL_MAX_WIDTH = "64rem";
|
|
@@ -33,7 +33,7 @@ export declare const COL_DEFAULT_WIDTH = "12rem";
|
|
|
33
33
|
* @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
|
|
34
34
|
*/
|
|
35
35
|
export interface TableColumn<T = KeyValue> extends CssProp, TestProps {
|
|
36
|
-
id:
|
|
36
|
+
id: NestedKeys<T>;
|
|
37
37
|
field?: string;
|
|
38
38
|
label?: string;
|
|
39
39
|
tooltip?: string;
|
|
@@ -65,8 +65,8 @@ export interface TableRef {
|
|
|
65
65
|
export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
|
|
66
66
|
columns: Array<TableColumn<T>>;
|
|
67
67
|
data: T[];
|
|
68
|
-
keyProperty?:
|
|
69
|
-
groupProperty?:
|
|
68
|
+
keyProperty?: NestedKeys<T>;
|
|
69
|
+
groupProperty?: NestedKeys<T>;
|
|
70
70
|
groupRenderer?: (key: AnyObject) => ReactElement;
|
|
71
71
|
emptyDisplay?: ReactElement;
|
|
72
72
|
/**
|
|
@@ -93,7 +93,7 @@ export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
|
|
|
93
93
|
onScroll?: (firstItem: number) => void;
|
|
94
94
|
canExpand?: (record: T) => boolean;
|
|
95
95
|
children?: (record: T) => Elements<AnyObject>;
|
|
96
|
-
onFilter?: (id:
|
|
96
|
+
onFilter?: (id: NestedKeys<T> | string, value?: AnyObject) => void;
|
|
97
97
|
total?: number;
|
|
98
98
|
onLoadMore?: (lastIndex?: number) => void;
|
|
99
99
|
}
|