widenarrow-ui 1.1.65 → 1.1.66
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/lib/components/SortableTable/SortableTable.types.d.ts +3 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.esm.js +18 -13
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +18 -13
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SortableTable/SortableTable.tsx +28 -12
- package/src/components/SortableTable/SortableTable.types.ts +3 -1
|
@@ -31,13 +31,15 @@ export interface SortableTableProps {
|
|
|
31
31
|
className?: string;
|
|
32
32
|
rowClassName?: string;
|
|
33
33
|
headerClassName?: string;
|
|
34
|
+
bodyClassName?: string;
|
|
35
|
+
spinnerClassName?: string;
|
|
34
36
|
caption?: string;
|
|
35
37
|
loading?: boolean;
|
|
36
38
|
skeletonRows?: number;
|
|
37
39
|
withStickyHeader?: boolean;
|
|
38
40
|
withIntersectionObserver?: boolean;
|
|
39
41
|
minWidth?: string;
|
|
40
|
-
onSortCallback?: (keyName: string) => void;
|
|
42
|
+
onSortCallback?: (keyName: string, ascending: boolean) => void;
|
|
41
43
|
pagination?: SearchResultInterface;
|
|
42
44
|
noDataMessage?: {
|
|
43
45
|
title?: string;
|
package/lib/index.d.ts
CHANGED
|
@@ -961,13 +961,15 @@ interface SortableTableProps {
|
|
|
961
961
|
className?: string;
|
|
962
962
|
rowClassName?: string;
|
|
963
963
|
headerClassName?: string;
|
|
964
|
+
bodyClassName?: string;
|
|
965
|
+
spinnerClassName?: string;
|
|
964
966
|
caption?: string;
|
|
965
967
|
loading?: boolean;
|
|
966
968
|
skeletonRows?: number;
|
|
967
969
|
withStickyHeader?: boolean;
|
|
968
970
|
withIntersectionObserver?: boolean;
|
|
969
971
|
minWidth?: string;
|
|
970
|
-
onSortCallback?: (keyName: string) => void;
|
|
972
|
+
onSortCallback?: (keyName: string, ascending: boolean) => void;
|
|
971
973
|
pagination?: SearchResultInterface;
|
|
972
974
|
noDataMessage?: {
|
|
973
975
|
title?: string;
|
package/lib/index.esm.js
CHANGED
|
@@ -3400,16 +3400,18 @@ var SortableTableRow = function (_a) {
|
|
|
3400
3400
|
return (jsx("tr", { ref: ref, className: s$3('row', (_b = { row_notInView: withIntersectionObserver && !inView }, _b[rowClassName] = !!rowClassName, _b)), children: !withIntersectionObserver || inView ? (children) : (jsx("div", { className: s$3('cell', { cell_fullWidth: true }), children: jsx("span", { className: s$3('cellData') }) })) }));
|
|
3401
3401
|
};
|
|
3402
3402
|
var SortableTable = function (_a) {
|
|
3403
|
-
var _b, _c;
|
|
3404
|
-
var cells = _a.cells, data = _a.data,
|
|
3405
|
-
var
|
|
3403
|
+
var _b, _c, _d, _e;
|
|
3404
|
+
var cells = _a.cells, data = _a.data, _f = _a.sortBy, sortBy = _f === void 0 ? [{ keyName: 'name', ascending: true }] : _f, _g = _a.skeletonRows, skeletonRows = _g === void 0 ? 6 : _g, loading = _a.loading, caption = _a.caption, className = _a.className, headerClassName = _a.headerClassName, rowClassName = _a.rowClassName, bodyClassName = _a.bodyClassName, spinnerClassName = _a.spinnerClassName, withStickyHeader = _a.withStickyHeader, withIntersectionObserver = _a.withIntersectionObserver, noDataMessage = _a.noDataMessage, minWidth = _a.minWidth, onSortCallback = _a.onSortCallback;
|
|
3405
|
+
var _h = useState(!is(Function, onSortCallback) ? sortBy : null), sortByLocalState = _h[0], setSortByLocalState = _h[1];
|
|
3406
3406
|
var noData = !loading && isArrayWithContent(data) === false;
|
|
3407
3407
|
var getTableHeaderCell = function (cell) {
|
|
3408
3408
|
if (cell.customHeaderCellComponent && is(Function, cell.customHeaderCellComponent)) {
|
|
3409
3409
|
return cell.customHeaderCellComponent(cell);
|
|
3410
3410
|
}
|
|
3411
|
-
|
|
3412
|
-
var
|
|
3411
|
+
// Use sortBy directly when onSortCallback is provided
|
|
3412
|
+
var currentSortState = is(Function, onSortCallback) ? sortBy : sortByLocalState;
|
|
3413
|
+
var optionIsActive = tableColumnIsActive({ state: currentSortState, cellKey: cell.key });
|
|
3414
|
+
var arrowIsAscending = optionIsActive && isSortingAscending(currentSortState);
|
|
3413
3415
|
var optionIsPrimaryColor = function () {
|
|
3414
3416
|
if (!isArrayWithContent(data) || !optionIsActive) {
|
|
3415
3417
|
return false;
|
|
@@ -3420,14 +3422,15 @@ var SortableTable = function (_a) {
|
|
|
3420
3422
|
return (jsx(Heading, { type: 'h6', marginBottom: '0', withEllipsis: true, children: cell.title }));
|
|
3421
3423
|
}
|
|
3422
3424
|
return (jsx(InlineButton, { className: s$3('headerButton'), toolTip: cell.toolTip ? cell.toolTip : cell.title, text: cell.icon ? '' : cell.title, type: optionIsPrimaryColor() ? HierarchyTypes.PRIMARY : HierarchyTypes.SECONDARY, onClickCallback: function () {
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3425
|
+
var isAscending = optionIsActive ? !arrowIsAscending : true;
|
|
3426
|
+
if (is(Function, onSortCallback)) {
|
|
3427
|
+
onSortCallback(cell.key, isAscending);
|
|
3428
|
+
}
|
|
3429
|
+
else if (sortByLocalState) {
|
|
3430
|
+
var newSortOption = { keyName: cell.key };
|
|
3427
3431
|
var newState = getSortableTableState(sortByLocalState, newSortOption);
|
|
3428
|
-
|
|
3432
|
+
setSortByLocalState(newState);
|
|
3429
3433
|
}
|
|
3430
|
-
is(Function, onSortCallback) && onSortCallback(cell.key);
|
|
3431
3434
|
}, icon: optionIsActive && !cell.disableSort ? IconTypes.CHEVRON_DOWN : undefined, rotateIcon: optionIsActive && arrowIsAscending, withIconRight: !cell.alignRight, size: SizeTypes.SMALL, disabled: noData || loading }));
|
|
3432
3435
|
};
|
|
3433
3436
|
var getCellValue = function (value) {
|
|
@@ -3482,11 +3485,13 @@ var SortableTable = function (_a) {
|
|
|
3482
3485
|
}
|
|
3483
3486
|
return null;
|
|
3484
3487
|
};
|
|
3485
|
-
return (jsxs("div", { className: s$3('container', (_b = {}, _b[className] = className, _b.container_withMinWidth = !!minWidth, _b)), children: [loading ? jsx(SolidSpinner, { className: s$3('spinner'), type: HierarchyTypes.PRIMARY, size: SizeTypes.MEDIUM }) : null, jsxs("table", { className: s$3('table', { table_loading: loading }), style: { minWidth: minWidth || 'auto' }, children: [jsx("caption", { children: caption }), jsx("thead", { children: jsx("tr", { className: s$3('row', (
|
|
3488
|
+
return (jsxs("div", { className: s$3('container', (_b = {}, _b[className] = className, _b.container_withMinWidth = !!minWidth, _b)), children: [loading ? (jsx(SolidSpinner, { className: s$3('spinner', (_c = {}, _c[spinnerClassName] = spinnerClassName, _c)), type: HierarchyTypes.PRIMARY, size: SizeTypes.MEDIUM })) : null, jsxs("table", { className: s$3('table', { table_loading: loading }), style: { minWidth: minWidth || 'auto' }, children: [jsx("caption", { children: caption }), jsx("thead", { children: jsx("tr", { className: s$3('row', (_d = { row_header: true, row_stickyHeader: withStickyHeader }, _d[headerClassName] = headerClassName, _d)), children: cells.map(function (cell, i) { return (jsx("th", { className: s$3('cell', {
|
|
3486
3489
|
cell_alignRight: cell.alignRight,
|
|
3487
3490
|
cell_alignCenter: cell.alignCenter,
|
|
3488
3491
|
cell_header: true
|
|
3489
|
-
}), style: { width: cell.width }, children: getTableHeaderCell(cell) }, i)); }) }) }), jsx("tbody", {
|
|
3492
|
+
}), style: { width: cell.width }, children: getTableHeaderCell(cell) }, i)); }) }) }), jsx("tbody", { className: s$3((_e = {},
|
|
3493
|
+
_e[bodyClassName] = bodyClassName,
|
|
3494
|
+
_e)), children: getTableContent() })] }), getNoDataMessage()] }));
|
|
3490
3495
|
};
|
|
3491
3496
|
|
|
3492
3497
|
var styles$2 = {"body":"SwitchButton-module_BSiKOl","container":"SwitchButton-module_-PGMDB","disabled":"SwitchButton-module_rKEoCC","label":"SwitchButton-module_9KVBdB","notChecked":"SwitchButton-module_CYvDs9","line":"SwitchButton-module_Eo7WUJ","circle":"SwitchButton-module_mXNj6-","checked":"SwitchButton-module_hyzBhV","container_withInlineLabel":"SwitchButton-module_92nx60","container_marginBottom":"SwitchButton-module_reV59e","button":"SwitchButton-module_rWRqQV","button_alignCenter":"SwitchButton-module_7wItwm","button_right":"SwitchButton-module_z7K2PJ","input":"SwitchButton-module_NDqU17","label_disabled":"SwitchButton-module_EYRA5X","label_hidden":"SwitchButton-module_sbDjVv","label_withInlineLabel":"SwitchButton-module_Pcd4mV","label_alignCenter":"SwitchButton-module_Ir2644"};
|