@economic/taco 2.45.0-alpha.17 → 2.45.0-alpha.19
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/components/Listbox/util.d.ts +1 -1
- package/dist/components/Report/Report.d.ts +2 -2
- package/dist/components/SearchInput2/SearchInput2.d.ts +2 -0
- package/dist/components/Table3/Table3.d.ts +5 -2
- package/dist/components/Table3/components/Row/Editing/CreateNewRow.d.ts +0 -1
- package/dist/components/Table3/features/useEditingState.d.ts +23 -18
- package/dist/components/Table3/features/useTableEditing.d.ts +24 -20
- package/dist/components/Table3/types.d.ts +2 -0
- package/dist/esm/index.css +6 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/DonutChart.js.map +1 -1
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -1
- package/dist/esm/packages/taco/src/charts/components/Legend.js +1 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -1
- package/dist/esm/packages/taco/src/charts/components/Tooltip.js.map +1 -1
- package/dist/esm/packages/taco/src/charts/utils/color.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Accordion/Accordion.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Combobox/useCombobox.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js +13 -0
- package/dist/esm/packages/taco/src/components/Datepicker/Datepicker.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js +1 -1
- package/dist/esm/packages/taco/src/components/Dialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js +2 -2
- package/dist/esm/packages/taco/src/components/Drawer/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Listbox/util.js.map +1 -1
- package/dist/esm/packages/taco/src/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js +4 -1
- package/dist/esm/packages/taco/src/components/Report/Report.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +6 -3
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Create.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowSelect.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +12 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +15 -9
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +2 -3
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js +3 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/TemporaryRow.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js +62 -70
- package/dist/esm/packages/taco/src/components/Table3/features/useEditingState.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +24 -21
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js +15 -12
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Tag/Tag.js +1 -1
- package/dist/esm/packages/taco/src/components/Tag/Tag.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -0
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js +5 -3
- package/dist/esm/packages/taco/src/primitives/Collection/components/Root.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +7 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js +7 -6
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +24 -22
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +41 -4
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js +26 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +40 -13
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +13 -12
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js +223 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +6 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableDataListener.js +3 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableDataListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +14 -13
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js +7 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js +4 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +8 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/hooks/useLazyDebouncedEffect.d.ts +2 -0
- package/dist/index.css +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Row/Row.d.ts +2 -0
- package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
- package/dist/primitives/Table/types.d.ts +10 -6
- package/dist/primitives/Table/useTableDataLoader.d.ts +2 -2
- package/dist/primitives/Table/useTableDataLoader2.d.ts +23 -0
- package/dist/primitives/Table/useTableManager/features/useTableSearch.d.ts +4 -2
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +4 -1
- package/dist/primitives/Table/useTableManager/listeners/useTableDataListener.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/listeners/useTableSearchListener.d.ts +1 -2
- package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -1
- package/dist/taco.cjs.development.js +630 -267
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/dist/utils/dom.d.ts +2 -2
- package/package.json +4 -4
@@ -31,12 +31,12 @@ var reactPortal = require('@radix-ui/react-portal');
|
|
31
31
|
var reactTable = require('@tanstack/react-table');
|
32
32
|
var get = _interopDefault(require('lodash/get'));
|
33
33
|
var reactVirtual = require('@tanstack/react-virtual');
|
34
|
-
var reactIntersectionObserver = require('react-intersection-observer');
|
35
34
|
var core = require('@dnd-kit/core');
|
36
35
|
var modifiers = require('@dnd-kit/modifiers');
|
37
36
|
var SortablePrimitive = require('@dnd-kit/sortable');
|
38
37
|
var utilities = require('@dnd-kit/utilities');
|
39
38
|
var reactTable$1 = require('react-table');
|
39
|
+
var reactIntersectionObserver = require('react-intersection-observer');
|
40
40
|
var reactWindow = require('react-window');
|
41
41
|
var InfiniteLoader = _interopDefault(require('react-window-infinite-loader'));
|
42
42
|
var set = _interopDefault(require('lodash/set'));
|
@@ -6611,11 +6611,24 @@ const Datepicker = /*#__PURE__*/React.forwardRef(function Datepicker(props, ref)
|
|
6611
6611
|
e.preventDefault();
|
6612
6612
|
(_input$ref$current = input.ref.current) === null || _input$ref$current === void 0 ? void 0 : _input$ref$current.focus();
|
6613
6613
|
}, [input.ref]);
|
6614
|
+
// Allow preventing default keyDown behaviour if consumer (in our internal case it's Table3) wants to handle it.
|
6615
|
+
// We need to have this option for the situations, when Datepicker is used as inline edititng control in Table3,
|
6616
|
+
// without it, datepicker cannot be set into detailed editing mode by pressing "Enter",
|
6617
|
+
// because input.onKeydown is triggering 'focusout', which resets the detailed edititng mode.
|
6618
|
+
const handleInputKeyDown = event => {
|
6619
|
+
var _props$onKeyDown;
|
6620
|
+
(_props$onKeyDown = props.onKeyDown) === null || _props$onKeyDown === void 0 ? void 0 : _props$onKeyDown.call(props, event);
|
6621
|
+
if (!event.defaultPrevented) {
|
6622
|
+
var _input$onKeyDown;
|
6623
|
+
(_input$onKeyDown = input.onKeyDown) === null || _input$onKeyDown === void 0 ? void 0 : _input$onKeyDown.call(input, event);
|
6624
|
+
}
|
6625
|
+
};
|
6614
6626
|
return /*#__PURE__*/React.createElement("span", {
|
6615
6627
|
className: className,
|
6616
6628
|
"data-taco": "datepicker",
|
6617
6629
|
style: style
|
6618
6630
|
}, /*#__PURE__*/React.createElement(Input, Object.assign({}, input, {
|
6631
|
+
onKeyDown: handleInputKeyDown,
|
6619
6632
|
button: input.readOnly ? undefined : (/*#__PURE__*/React.createElement(IconButton, {
|
6620
6633
|
"aria-label": texts.datepicker.expand,
|
6621
6634
|
disabled: input.disabled || input.readOnly,
|
@@ -6795,7 +6808,7 @@ const Content$4 = /*#__PURE__*/React.forwardRef(function DialogContent(props, re
|
|
6795
6808
|
texts
|
6796
6809
|
} = useLocalization();
|
6797
6810
|
const className = cn('relative bg-white animate-[fade-in_150ms] rounded', getDialogPositionClassnames(), getDialogSizeClassnames(dialog.size), 'print:w-full print:h-full print:m-0 print:overflow-visible');
|
6798
|
-
const containerClassName = cn('bg-white p-6 rounded relative z-10 shadow print:p-0 print:overflow-visible print:h-full', {
|
6811
|
+
const containerClassName = cn('bg-white p-6 rounded relative z-10 shadow print:p-0', 'print:overflow-visible print:h-full print:!transform-none print:!fixed print:!inset-0 print:!m-0', {
|
6799
6812
|
'rounded-b-none': !!dialog.elements.extra
|
6800
6813
|
}, props.className);
|
6801
6814
|
const handleEscapeKeyDown = event => {
|
@@ -7324,7 +7337,7 @@ const DrawerContent = /*#__PURE__*/React__default.forwardRef(function Content(pr
|
|
7324
7337
|
ref: contentRef,
|
7325
7338
|
"data-taco": "drawer",
|
7326
7339
|
className: containerClassName
|
7327
|
-
}, output, /*#__PURE__*/React__default.createElement("div", Object.assign({
|
7340
|
+
}, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, output, /*#__PURE__*/React__default.createElement("div", Object.assign({
|
7328
7341
|
className: dragHandlerClassName
|
7329
7342
|
}, dragHandleProps, {
|
7330
7343
|
"data-testid": "resize-handler",
|
@@ -7337,7 +7350,7 @@ const DrawerContent = /*#__PURE__*/React__default.forwardRef(function Content(pr
|
|
7337
7350
|
"aria-label": texts.drawer.close,
|
7338
7351
|
className: "absolute right-0 top-0 mr-2 mt-4",
|
7339
7352
|
icon: "close"
|
7340
|
-
}))) : null);
|
7353
|
+
}))) : null));
|
7341
7354
|
const styleProp = {
|
7342
7355
|
...style,
|
7343
7356
|
...{
|
@@ -10325,6 +10338,9 @@ function unfreezeAllExternalColumns(leftPinnedState) {
|
|
10325
10338
|
function freezeUptoExternalColumn(index, columns) {
|
10326
10339
|
return columns.slice(0, index + 1);
|
10327
10340
|
}
|
10341
|
+
function getHiddenColumns(columnVisibility = {}) {
|
10342
|
+
return Object.keys(columnVisibility).filter(c => columnVisibility[c] === false);
|
10343
|
+
}
|
10328
10344
|
|
10329
10345
|
function getSettings(table) {
|
10330
10346
|
const meta = table.options.meta;
|
@@ -10582,7 +10598,6 @@ function configureReactTableOptions(options, props, localization) {
|
|
10582
10598
|
enableGrouping: true,
|
10583
10599
|
enableHiding: (_options$enableColumn2 = options.enableColumnHiding) !== null && _options$enableColumn2 !== void 0 ? _options$enableColumn2 : false,
|
10584
10600
|
enablePinning: (_options$enableColumn3 = options.enableColumnFreezing) !== null && _options$enableColumn3 !== void 0 ? _options$enableColumn3 : false,
|
10585
|
-
keepPinnedRows: false,
|
10586
10601
|
enableRowPinning: true,
|
10587
10602
|
enableRowSelection: reactTableEnableRowSelection !== null && reactTableEnableRowSelection !== void 0 ? reactTableEnableRowSelection : false,
|
10588
10603
|
enableSorting: (_options$enableSortin = options.enableSorting) !== null && _options$enableSortin !== void 0 ? _options$enableSortin : false,
|
@@ -10590,7 +10605,8 @@ function configureReactTableOptions(options, props, localization) {
|
|
10590
10605
|
getExpandedRowModel: reactTable.getExpandedRowModel(),
|
10591
10606
|
getGroupedRowModel: reactTable.getGroupedRowModel(),
|
10592
10607
|
getRowId,
|
10593
|
-
groupedColumnMode: false
|
10608
|
+
groupedColumnMode: false,
|
10609
|
+
keepPinnedRows: false
|
10594
10610
|
};
|
10595
10611
|
if (tableOptions.enableColumnResizing) {
|
10596
10612
|
tableOptions.columnResizeMode = 'onChange';
|
@@ -10612,6 +10628,12 @@ function configureReactTableOptions(options, props, localization) {
|
|
10612
10628
|
var _column$columnDef$met;
|
10613
10629
|
return ((_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.enableSearch) !== false && column.getIsVisible();
|
10614
10630
|
};
|
10631
|
+
// enter controlled search mode (controlled could be local state, but usually the server)
|
10632
|
+
if (props.onChangeSearch) {
|
10633
|
+
if (props._experimentalDataLoader2) {
|
10634
|
+
tableOptions.manualFiltering = true;
|
10635
|
+
}
|
10636
|
+
}
|
10615
10637
|
}
|
10616
10638
|
if (tableOptions.enableSorting) {
|
10617
10639
|
// enter controlled sort mode (controlled could be local state, but usually the server)
|
@@ -10995,7 +11017,7 @@ function useTableRowActive(isEnabled = false, initialRowActiveIndex) {
|
|
10995
11017
|
return index;
|
10996
11018
|
});
|
10997
11019
|
}
|
10998
|
-
}, [rowActiveIndex,
|
11020
|
+
}, [rowActiveIndex, isEnabled]);
|
10999
11021
|
return {
|
11000
11022
|
isEnabled,
|
11001
11023
|
rowActiveIndex,
|
@@ -11111,7 +11133,7 @@ function useTableRowSelection(isEnabled = false) {
|
|
11111
11133
|
- Highlighting search results, this is custom and only uses the state part of globalFilter (to store the search query)
|
11112
11134
|
- Filtering of results, this is essentially the built in filtering, and relies on enableGlobalFilter being on or off
|
11113
11135
|
*/
|
11114
|
-
function useTableSearch(isEnabled = false, defaultEnableGlobalFilter = false) {
|
11136
|
+
function useTableSearch(isEnabled = false, onChangeSearch, defaultEnableGlobalFilter = false) {
|
11115
11137
|
const [enableGlobalFilter, _setEnableGlobalFilter] = React__default.useState(defaultEnableGlobalFilter);
|
11116
11138
|
function setEnableGlobalFilter(enabled, instance) {
|
11117
11139
|
_setEnableGlobalFilter(enabled);
|
@@ -11136,7 +11158,8 @@ function useTableSearch(isEnabled = false, defaultEnableGlobalFilter = false) {
|
|
11136
11158
|
highlightedColumnIndexes,
|
11137
11159
|
setHighlightedColumnIndexes,
|
11138
11160
|
currentHighlightColumnIndex,
|
11139
|
-
setCurrentHighlightColumnIndex
|
11161
|
+
setCurrentHighlightColumnIndex,
|
11162
|
+
handleSearch: isEnabled && typeof onChangeSearch === 'function' ? onChangeSearch : undefined
|
11140
11163
|
};
|
11141
11164
|
}
|
11142
11165
|
|
@@ -11346,9 +11369,10 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11346
11369
|
const _lastUsedSorting = React__default.useRef([]);
|
11347
11370
|
const _lastUsedFilters = React__default.useRef([]);
|
11348
11371
|
const _lastUsedSearch = React__default.useRef();
|
11372
|
+
const _lastUsedHiddenColumns = React__default.useRef([]);
|
11349
11373
|
const _lastUsedPageIndex = React__default.useRef();
|
11350
11374
|
const _forceReset = React__default.useRef(false);
|
11351
|
-
const loadPage = function (pageIndex, sorting, filters) {
|
11375
|
+
const loadPage = function (pageIndex, sorting, filters, hiddenColumns) {
|
11352
11376
|
try {
|
11353
11377
|
let reset = false;
|
11354
11378
|
// sorting or filters changed, reset everything
|
@@ -11370,9 +11394,10 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11370
11394
|
_lastUsedSorting.current = sorting;
|
11371
11395
|
// set the filters so we can track if it changed between loads
|
11372
11396
|
_lastUsedFilters.current = filters;
|
11397
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
11373
11398
|
const _temp = _finallyRethrows(function () {
|
11374
11399
|
return _catch(function () {
|
11375
|
-
return Promise.resolve(fetchPage(pageIndex, pageSize, sorting, filters)).then(function (response) {
|
11400
|
+
return Promise.resolve(fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns)).then(function (response) {
|
11376
11401
|
// update state, here we do some "magic" to support "load in place"
|
11377
11402
|
setData(currentData => {
|
11378
11403
|
let nextData;
|
@@ -11401,14 +11426,15 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11401
11426
|
return Promise.reject(e);
|
11402
11427
|
}
|
11403
11428
|
};
|
11404
|
-
const loadAll = function (sorting, filters) {
|
11429
|
+
const loadAll = function (sorting, filters, hiddenColumns) {
|
11405
11430
|
try {
|
11406
11431
|
// set the sorting so we can track if it changed between loads
|
11407
11432
|
_lastUsedSorting.current = sorting;
|
11408
11433
|
// set the filters so we can track if it changed between loads
|
11409
11434
|
_lastUsedFilters.current = filters;
|
11435
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
11410
11436
|
const _temp2 = _catch(function () {
|
11411
|
-
return Promise.resolve(fetchAll(sorting, filters)).then(function (response) {
|
11437
|
+
return Promise.resolve(fetchAll(sorting, filters, hiddenColumns)).then(function (response) {
|
11412
11438
|
length.current = response.length;
|
11413
11439
|
setData(() => {
|
11414
11440
|
let nextData;
|
@@ -11433,11 +11459,11 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11433
11459
|
_forceReset.current = true;
|
11434
11460
|
if (_lastUsedSearch.current) {
|
11435
11461
|
// we're searching, which means we need to refetch all with the correct sorting applied
|
11436
|
-
return loadAll(_lastUsedSorting.current, _lastUsedFilters.current);
|
11462
|
+
return loadAll(_lastUsedSorting.current, _lastUsedFilters.current, _lastUsedHiddenColumns.current);
|
11437
11463
|
} else {
|
11438
11464
|
var _lastUsedPageIndex$cu;
|
11439
11465
|
// load the last page that we scrolled to
|
11440
|
-
return loadPage((_lastUsedPageIndex$cu = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu !== void 0 ? _lastUsedPageIndex$cu : 0, _lastUsedSorting.current, _lastUsedFilters.current);
|
11466
|
+
return loadPage((_lastUsedPageIndex$cu = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu !== void 0 ? _lastUsedPageIndex$cu : 0, _lastUsedSorting.current, _lastUsedFilters.current, _lastUsedHiddenColumns.current);
|
11441
11467
|
}
|
11442
11468
|
} catch (e) {
|
11443
11469
|
return Promise.reject(e);
|
@@ -11449,13 +11475,12 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11449
11475
|
try {
|
11450
11476
|
if (_lastUsedSearch.current) {
|
11451
11477
|
// we're searching, which means we need to refetch all with the correct sorting applied
|
11452
|
-
loadAll(sorting, _lastUsedFilters.current);
|
11478
|
+
return loadAll(sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);
|
11453
11479
|
} else {
|
11454
11480
|
var _lastUsedPageIndex$cu2;
|
11455
11481
|
// load the last page that we scrolled to
|
11456
|
-
loadPage((_lastUsedPageIndex$cu2 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu2 !== void 0 ? _lastUsedPageIndex$cu2 : 0, sorting, _lastUsedFilters.current);
|
11482
|
+
return loadPage((_lastUsedPageIndex$cu2 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu2 !== void 0 ? _lastUsedPageIndex$cu2 : 0, sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current);
|
11457
11483
|
}
|
11458
|
-
return Promise.resolve();
|
11459
11484
|
} catch (e) {
|
11460
11485
|
return Promise.reject(e);
|
11461
11486
|
}
|
@@ -11464,13 +11489,12 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11464
11489
|
try {
|
11465
11490
|
if (_lastUsedSearch.current) {
|
11466
11491
|
// we're searching, which means we need to refetch all with the correct sorting applied
|
11467
|
-
loadAll(_lastUsedSorting.current, filters);
|
11492
|
+
return loadAll(_lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);
|
11468
11493
|
} else {
|
11469
11494
|
var _lastUsedPageIndex$cu3;
|
11470
11495
|
// load the last page that we scrolled to
|
11471
|
-
loadPage((_lastUsedPageIndex$cu3 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu3 !== void 0 ? _lastUsedPageIndex$cu3 : 0, _lastUsedSorting.current, filters);
|
11496
|
+
return loadPage((_lastUsedPageIndex$cu3 = _lastUsedPageIndex.current) !== null && _lastUsedPageIndex$cu3 !== void 0 ? _lastUsedPageIndex$cu3 : 0, _lastUsedSorting.current, filters, _lastUsedHiddenColumns.current);
|
11472
11497
|
}
|
11473
|
-
return Promise.resolve();
|
11474
11498
|
} catch (e) {
|
11475
11499
|
return Promise.reject(e);
|
11476
11500
|
}
|
@@ -11498,7 +11522,7 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
11498
11522
|
}, invalidate];
|
11499
11523
|
}
|
11500
11524
|
|
11501
|
-
function useTableServerLoading(length, data, loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
11525
|
+
function useTableServerLoading(length, data, loadPage, loadAll, pages, pageSize = DEFAULT_PAGE_SIZE, _experimentalDataLoader2 = false) {
|
11502
11526
|
const isEnabled = !!loadPage && !!loadAll;
|
11503
11527
|
const [isReady, setReady] = React__default.useState(false);
|
11504
11528
|
const [loading, setLoading] = React__default.useState(false);
|
@@ -11559,14 +11583,18 @@ function useTableServerLoading(length, data, loadPage, loadAll, pageSize = DEFAU
|
|
11559
11583
|
}
|
11560
11584
|
};
|
11561
11585
|
}
|
11586
|
+
const pageCount = Math.ceil(length / pageSize);
|
11562
11587
|
return {
|
11588
|
+
pages,
|
11563
11589
|
isEnabled,
|
11564
11590
|
isReady,
|
11565
11591
|
loadPage: _loadPage,
|
11566
11592
|
loadAll: _loadAll,
|
11567
11593
|
loadAllIfNeeded: _loadAllIfNeeded,
|
11568
11594
|
loading,
|
11569
|
-
pageSize
|
11595
|
+
pageSize,
|
11596
|
+
pageCount,
|
11597
|
+
_experimentalDataLoader2
|
11570
11598
|
};
|
11571
11599
|
}
|
11572
11600
|
|
@@ -11645,15 +11673,14 @@ function useLazyEffect(effect, deps) {
|
|
11645
11673
|
}, deps);
|
11646
11674
|
}
|
11647
11675
|
|
11648
|
-
function useTableDataListener(table) {
|
11676
|
+
function useTableDataListener(table, length) {
|
11649
11677
|
const meta = table.options.meta;
|
11650
|
-
const rows = table.getRowModel().rows;
|
11651
11678
|
useLazyEffect(() => {
|
11652
11679
|
const rowActiveIndex = meta.rowActive.rowActiveIndex;
|
11653
|
-
if (rowActiveIndex !== undefined && rowActiveIndex >
|
11680
|
+
if (rowActiveIndex !== undefined && rowActiveIndex > length) {
|
11654
11681
|
meta.rowActive.setRowActiveIndex(0);
|
11655
11682
|
}
|
11656
|
-
}, [
|
11683
|
+
}, [length]);
|
11657
11684
|
}
|
11658
11685
|
|
11659
11686
|
// we use a listener, and not the internal "controlled" change handlers because we don't actually want consumers
|
@@ -11663,7 +11690,8 @@ function useTableFilterListener(table, onFilter) {
|
|
11663
11690
|
const columnFilters = table.getState().columnFilters;
|
11664
11691
|
useLazyEffect(() => {
|
11665
11692
|
if (table.options.enableColumnFilters && typeof onFilter === 'function') {
|
11666
|
-
|
11693
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
11694
|
+
onFilter(columnFilters, hiddenColumns);
|
11667
11695
|
if (table.options.enableRowSelection) {
|
11668
11696
|
table.resetRowSelection();
|
11669
11697
|
}
|
@@ -11722,11 +11750,12 @@ function useTableRowHeightListener(table) {
|
|
11722
11750
|
}
|
11723
11751
|
|
11724
11752
|
function useTableRowSelectionListener(table, onRowSelect) {
|
11753
|
+
// note that the selected row model may not contain all rows in state when using server loading
|
11725
11754
|
const rows = table.getSelectedRowModel().flatRows;
|
11726
|
-
const
|
11755
|
+
const state = table.getState().rowSelection;
|
11727
11756
|
useLazyEffect(() => {
|
11728
11757
|
if (table.options.enableRowSelection && typeof onRowSelect === 'function') {
|
11729
|
-
onRowSelect(
|
11758
|
+
onRowSelect(rows.map(row => row.original), Object.keys(state));
|
11730
11759
|
}
|
11731
11760
|
/**
|
11732
11761
|
* Casting to a boolean, since enableRowSelection can be a function,
|
@@ -11734,33 +11763,33 @@ function useTableRowSelectionListener(table, onRowSelect) {
|
|
11734
11763
|
* we only need to know if selection was enabled or disabled, because enableRowSelection function
|
11735
11764
|
* will be applied directly to particular rows.
|
11736
11765
|
*/
|
11737
|
-
}, [!!table.options.enableRowSelection, JSON.stringify(
|
11766
|
+
}, [!!table.options.enableRowSelection, JSON.stringify(state)]);
|
11738
11767
|
}
|
11739
11768
|
|
11740
|
-
function useTableSearchListener(table
|
11769
|
+
function useTableSearchListener(table) {
|
11741
11770
|
const meta = table.options.meta;
|
11742
11771
|
const localization = useLocalization();
|
11743
|
-
const
|
11772
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
11773
|
+
const query = table.getState().globalFilter;
|
11744
11774
|
// Need to re-run search when columns are getting shown/hidden.
|
11745
|
-
|
11746
|
-
if (meta.search.isEnabled
|
11747
|
-
const currentFilter =
|
11775
|
+
useLazyEffect(() => {
|
11776
|
+
if (meta.search.isEnabled) {
|
11777
|
+
const currentFilter = query;
|
11748
11778
|
requestAnimationFrame(() => {
|
11749
11779
|
table.resetGlobalFilter();
|
11750
11780
|
table.setGlobalFilter(currentFilter);
|
11751
11781
|
});
|
11782
|
+
if (meta.search.handleSearch && meta.search.enableGlobalFilter && query) {
|
11783
|
+
meta.search.handleSearch(query, hiddenColumns);
|
11784
|
+
}
|
11752
11785
|
}
|
11753
|
-
}, [
|
11786
|
+
}, [hiddenColumns.length]);
|
11754
11787
|
// recalculates highlighted indexes whenever something important changes
|
11755
|
-
|
11788
|
+
useLazyEffect(() => {
|
11756
11789
|
if (meta.search.isEnabled) {
|
11757
|
-
const query = table.getState().globalFilter;
|
11758
11790
|
resetHighlightedColumnIndexes(query, table, localization);
|
11759
|
-
if (typeof onChangeSearch === 'function') {
|
11760
|
-
onChangeSearch(query);
|
11761
|
-
}
|
11762
11791
|
}
|
11763
|
-
}, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length,
|
11792
|
+
}, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, query, JSON.stringify(table.getState().sorting)]);
|
11764
11793
|
}
|
11765
11794
|
|
11766
11795
|
function useTableSettingsListener(table, onChangeSettings) {
|
@@ -11844,12 +11873,15 @@ function useTableSortingListener(table, onSort) {
|
|
11844
11873
|
}
|
11845
11874
|
|
11846
11875
|
function useTableServerLoadingListener(table, loadPage) {
|
11847
|
-
const
|
11848
|
-
const columnFilters = table.getState().columnFilters;
|
11876
|
+
const meta = table.options.meta;
|
11849
11877
|
// trigger load of the first page on mount
|
11850
11878
|
React__default.useEffect(() => {
|
11851
11879
|
if (loadPage) {
|
11852
|
-
|
11880
|
+
const sorting = table.getState().sorting;
|
11881
|
+
const columnFilters = table.getState().columnFilters;
|
11882
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
11883
|
+
const search = meta.search.enableGlobalFilter ? table.getState().globalFilter : undefined;
|
11884
|
+
loadPage(0, sorting, columnFilters, hiddenColumns, search);
|
11853
11885
|
}
|
11854
11886
|
}, []);
|
11855
11887
|
}
|
@@ -11901,8 +11933,8 @@ function useTableManager(props, meta, internalColumns) {
|
|
11901
11933
|
const rowGroups = useTableRowGroups(props.rowActionsForGroup);
|
11902
11934
|
const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
|
11903
11935
|
const rowSelection = useTableRowSelection(!!options.enableRowSelection);
|
11904
|
-
const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
|
11905
|
-
const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pageSize);
|
11936
|
+
const search = useTableSearch(options.enableSearch, props.onChangeSearch, settings.excludeUnmatchedRecordsInSearch);
|
11937
|
+
const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pages, props.pageSize, props._experimentalDataLoader2);
|
11906
11938
|
// TODO: memoise
|
11907
11939
|
// convert jsx column components into valid table columns
|
11908
11940
|
const {
|
@@ -11948,12 +11980,12 @@ function useTableManager(props, meta, internalColumns) {
|
|
11948
11980
|
}
|
11949
11981
|
});
|
11950
11982
|
// state listeners - we have these so that we don't have to control state outside the table
|
11951
|
-
useTableDataListener(instance);
|
11983
|
+
useTableDataListener(instance, length);
|
11952
11984
|
useTableFilterListener(instance, props.onChangeFilter);
|
11953
11985
|
useTableFontSizeListener(instance);
|
11954
11986
|
useTableRowHeightListener(instance);
|
11955
11987
|
useTableRowSelectionListener(instance, props.onRowSelect);
|
11956
|
-
useTableSearchListener(instance
|
11988
|
+
useTableSearchListener(instance);
|
11957
11989
|
useTableServerLoadingListener(instance, server.loadPage);
|
11958
11990
|
useTableSettingsListener(instance, setSettings);
|
11959
11991
|
useTableShortcutsListener(instance, props.shortcuts);
|
@@ -12179,7 +12211,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
|
|
12179
12211
|
if (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current) || isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current)) {
|
12180
12212
|
return;
|
12181
12213
|
}
|
12182
|
-
tableMeta.rowActive.handleKeyDown(event,
|
12214
|
+
tableMeta.rowActive.handleKeyDown(event, tableMeta.length, scrollToIndex);
|
12183
12215
|
tableMeta.rowSelection.handleKeyDown(event, table);
|
12184
12216
|
if (tableMeta.rowActive.rowActiveIndex !== undefined) {
|
12185
12217
|
var _rows$tableMeta$rowAc;
|
@@ -12192,7 +12224,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
|
|
12192
12224
|
};
|
12193
12225
|
},
|
12194
12226
|
// scrollToIndex function changes when row count changes, so it is important to update handlers
|
12195
|
-
[tableRef.current, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
|
12227
|
+
[tableRef.current, tableMeta.length, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
|
12196
12228
|
}
|
12197
12229
|
|
12198
12230
|
function useTableRef(table, ref) {
|
@@ -12215,57 +12247,131 @@ const ROW_HEIGHT_ESTIMATES = {
|
|
12215
12247
|
'extra-tall': 57
|
12216
12248
|
};
|
12217
12249
|
|
12250
|
+
const RowContext = /*#__PURE__*/React__default.createContext({
|
12251
|
+
hideInternalColumns: false,
|
12252
|
+
hideRowActions: false,
|
12253
|
+
isHovered: false,
|
12254
|
+
rowIndex: -1
|
12255
|
+
});
|
12256
|
+
|
12257
|
+
const DELAY_BEFORE_LOAD_MS = 250;
|
12258
|
+
/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */
|
12259
|
+
function Row(props) {
|
12260
|
+
const {
|
12261
|
+
renderer: RowRenderer,
|
12262
|
+
cellRenderer: CellRenderer,
|
12263
|
+
hideInternalColumns = false,
|
12264
|
+
hideRowActions = false,
|
12265
|
+
scrollDirection,
|
12266
|
+
skipPageLoading = false,
|
12267
|
+
...displayRowProps
|
12268
|
+
} = props;
|
12269
|
+
const tableMeta = props.table.options.meta;
|
12270
|
+
const isHovered = tableMeta.rowActive.rowHoverIndex === props.index;
|
12271
|
+
// context - it must be here for cells to read it, since they render alongside the row inside DisplayRow
|
12272
|
+
const contextValue = React__default.useMemo(() => ({
|
12273
|
+
isHovered,
|
12274
|
+
rowIndex: props.index,
|
12275
|
+
hideInternalColumns,
|
12276
|
+
hideRowActions
|
12277
|
+
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
12278
|
+
React__default.useEffect(() => {
|
12279
|
+
let timeout;
|
12280
|
+
if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 && !skipPageLoading) {
|
12281
|
+
const pageIndex = Math.floor(props.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
12282
|
+
const sorting = props.table.getState().sorting;
|
12283
|
+
const filters = props.table.getState().columnFilters;
|
12284
|
+
const search = props.table.getState().globalFilter;
|
12285
|
+
const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
|
12286
|
+
const pageIndexesToFetch = [];
|
12287
|
+
// if there's no direction, it means the scroll bar got dropped un unloaded pages,
|
12288
|
+
// in that case, load forward and backward pages to prevent skeletons
|
12289
|
+
if (scrollDirection === 'backward' || !scrollDirection) {
|
12290
|
+
const backIndex = pageIndex - 1;
|
12291
|
+
if (backIndex > -1) {
|
12292
|
+
pageIndexesToFetch.push(backIndex);
|
12293
|
+
}
|
12294
|
+
}
|
12295
|
+
// always load the next page
|
12296
|
+
if ((scrollDirection === 'forward' || !scrollDirection) && pageIndex + 2 < tableMeta.server.pageCount) {
|
12297
|
+
pageIndexesToFetch.push(pageIndex + 1);
|
12298
|
+
}
|
12299
|
+
if (pageIndexesToFetch.length) {
|
12300
|
+
// the virtualiser fetches a page ahead, so this won't get called in most cases
|
12301
|
+
// but it provides a fallback for some edge cases
|
12302
|
+
timeout = setTimeout(() => {
|
12303
|
+
pageIndexesToFetch.forEach(index => {
|
12304
|
+
var _tableMeta$server$loa, _tableMeta$server;
|
12305
|
+
// this can be called by every row within the current page, but loadPage returns early if a pending request exists
|
12306
|
+
(_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, index, sorting, filters, hiddenColumns, tableMeta.search.enableGlobalFilter ? search : undefined);
|
12307
|
+
});
|
12308
|
+
}, DELAY_BEFORE_LOAD_MS);
|
12309
|
+
}
|
12310
|
+
}
|
12311
|
+
return () => {
|
12312
|
+
clearTimeout(timeout);
|
12313
|
+
};
|
12314
|
+
}, [tableMeta.server.pages]);
|
12315
|
+
return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
|
12316
|
+
value: contextValue
|
12317
|
+
}, /*#__PURE__*/React__default.createElement(RowRenderer, Object.assign({}, displayRowProps, {
|
12318
|
+
cellRenderer: CellRenderer
|
12319
|
+
})));
|
12320
|
+
}
|
12321
|
+
|
12322
|
+
const DELAY_BEFORE_LOAD_MS$1 = 150;
|
12218
12323
|
function SkeletonRow(props) {
|
12219
12324
|
const {
|
12220
12325
|
index,
|
12221
|
-
row,
|
12222
12326
|
table
|
12223
12327
|
} = props;
|
12224
12328
|
const tableMeta = table.options.meta;
|
12225
12329
|
if (tableMeta.server.isEnabled) {
|
12226
|
-
return /*#__PURE__*/React__default.createElement(RowWithServerLoading, Object.assign({}, props
|
12227
|
-
index: index
|
12228
|
-
}));
|
12330
|
+
return /*#__PURE__*/React__default.createElement(RowWithServerLoading, Object.assign({}, props));
|
12229
12331
|
}
|
12230
12332
|
return /*#__PURE__*/React__default.createElement(Skeleton, {
|
12231
|
-
cellsCount:
|
12333
|
+
cellsCount: table.getVisibleFlatColumns().length,
|
12334
|
+
index: index
|
12232
12335
|
});
|
12233
12336
|
}
|
12234
12337
|
function RowWithServerLoading(props) {
|
12235
12338
|
var _table$getState$group, _table$getState;
|
12236
12339
|
const {
|
12237
12340
|
index,
|
12238
|
-
row,
|
12239
12341
|
table
|
12240
12342
|
} = props;
|
12241
12343
|
const tableMeta = table.options.meta;
|
12242
12344
|
const pageIndex = Math.floor(index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
12243
|
-
const {
|
12244
|
-
ref,
|
12245
|
-
inView
|
12246
|
-
} = reactIntersectionObserver.useInView({
|
12247
|
-
threshold: 0,
|
12248
|
-
triggerOnce: true,
|
12249
|
-
initialInView: pageIndex === 0
|
12250
|
-
});
|
12251
12345
|
React__default.useEffect(() => {
|
12252
|
-
|
12253
|
-
|
12254
|
-
|
12346
|
+
let timeout;
|
12347
|
+
if (tableMeta.server.isEnabled) {
|
12348
|
+
const sorting = props.table.getState().sorting;
|
12349
|
+
const filters = props.table.getState().columnFilters;
|
12350
|
+
const search = props.table.getState().globalFilter;
|
12351
|
+
const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
|
12352
|
+
timeout = setTimeout(() => {
|
12353
|
+
var _tableMeta$server$loa, _tableMeta$server;
|
12354
|
+
(_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, pageIndex, sorting, filters, hiddenColumns, tableMeta.search.enableGlobalFilter ? search : undefined);
|
12355
|
+
}, DELAY_BEFORE_LOAD_MS$1);
|
12255
12356
|
}
|
12256
|
-
|
12357
|
+
return () => {
|
12358
|
+
clearTimeout(timeout);
|
12359
|
+
};
|
12360
|
+
}, []);
|
12257
12361
|
const groupedCellCount = (_table$getState$group = (_table$getState = table.getState()) === null || _table$getState === void 0 ? void 0 : _table$getState.grouping.length) !== null && _table$getState$group !== void 0 ? _table$getState$group : 0;
|
12258
|
-
const ungroupedCellCount =
|
12362
|
+
const ungroupedCellCount = table.getVisibleFlatColumns().length - groupedCellCount;
|
12259
12363
|
return /*#__PURE__*/React__default.createElement(Skeleton, {
|
12260
12364
|
cellsCount: ungroupedCellCount,
|
12261
|
-
|
12365
|
+
index: index
|
12262
12366
|
});
|
12263
12367
|
}
|
12264
12368
|
const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props, ref) {
|
12265
12369
|
const {
|
12266
|
-
cellsCount
|
12370
|
+
cellsCount,
|
12371
|
+
index
|
12267
12372
|
} = props;
|
12268
12373
|
return /*#__PURE__*/React__default.createElement("tr", {
|
12374
|
+
"data-row-index": index,
|
12269
12375
|
ref: ref
|
12270
12376
|
}, Array(cellsCount).fill(null).map((_, index) => (/*#__PURE__*/React__default.createElement("td", {
|
12271
12377
|
key: index
|
@@ -12274,41 +12380,6 @@ const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props,
|
|
12274
12380
|
})))));
|
12275
12381
|
});
|
12276
12382
|
|
12277
|
-
const RowContext = /*#__PURE__*/React__default.createContext({
|
12278
|
-
hideInternalColumns: false,
|
12279
|
-
hideRowActions: false,
|
12280
|
-
isHovered: false,
|
12281
|
-
rowIndex: -1
|
12282
|
-
});
|
12283
|
-
|
12284
|
-
/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */
|
12285
|
-
function Row(props) {
|
12286
|
-
const {
|
12287
|
-
renderer: RowRenderer,
|
12288
|
-
cellRenderer: CellRenderer,
|
12289
|
-
hideInternalColumns = false,
|
12290
|
-
hideRowActions = false,
|
12291
|
-
...displayRowProps
|
12292
|
-
} = props;
|
12293
|
-
const tableMeta = props.table.options.meta;
|
12294
|
-
const isHovered = tableMeta.rowActive.rowHoverIndex === props.index;
|
12295
|
-
// context - it must be here for cells to read it, since they render alongside the row inside DisplayRow
|
12296
|
-
const contextValue = React__default.useMemo(() => ({
|
12297
|
-
isHovered,
|
12298
|
-
rowIndex: props.index,
|
12299
|
-
hideInternalColumns,
|
12300
|
-
hideRowActions
|
12301
|
-
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
12302
|
-
if (props.row.original === undefined) {
|
12303
|
-
return /*#__PURE__*/React__default.createElement(SkeletonRow, Object.assign({}, props));
|
12304
|
-
}
|
12305
|
-
return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
|
12306
|
-
value: contextValue
|
12307
|
-
}, /*#__PURE__*/React__default.createElement(RowRenderer, Object.assign({}, displayRowProps, {
|
12308
|
-
cellRenderer: CellRenderer
|
12309
|
-
})));
|
12310
|
-
}
|
12311
|
-
|
12312
12383
|
// scroll padding end is designed to always show half of the next row
|
12313
12384
|
function getScrollPaddingEndOffset(table) {
|
12314
12385
|
const tableMeta = table.options.meta;
|
@@ -12333,8 +12404,8 @@ function getPaddingEndOffset(table, options) {
|
|
12333
12404
|
const bottomRows = (_table$getBottomRows = table.getBottomRows()) !== null && _table$getBottomRows !== void 0 ? _table$getBottomRows : [];
|
12334
12405
|
return ROW_HEIGHT_ESTIMATES.medium * ((_options$virtualiserP = options === null || options === void 0 ? void 0 : options.virtualiserPaddingEndOffset) !== null && _options$virtualiserP !== void 0 ? _options$virtualiserP : 1) * bottomRows.length;
|
12335
12406
|
}
|
12336
|
-
function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, options) {
|
12337
|
-
var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3,
|
12407
|
+
function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIndex, options) {
|
12408
|
+
var _table$getState$group, _table$getCenterRows, _virtualItems$padding, _virtualItems$padding2, _virtualItems$padding3, _virtualItems$end, _virtualItems;
|
12338
12409
|
const tableMeta = table.options.meta;
|
12339
12410
|
const isTableRowGrouped = !!((_table$getState$group = table.getState().grouping) !== null && _table$getState$group !== void 0 && _table$getState$group.length);
|
12340
12411
|
const rows = (_table$getCenterRows = table.getCenterRows()) !== null && _table$getCenterRows !== void 0 ? _table$getCenterRows : [];
|
@@ -12347,11 +12418,12 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
|
|
12347
12418
|
const rangeExtractor = useRowGroupVirtualisation(table);
|
12348
12419
|
// account for thead and tfoot in the scroll area - both are always medium row height
|
12349
12420
|
const scrollPaddingStart = ROW_HEIGHT_ESTIMATES.medium;
|
12421
|
+
const count = tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 ? length : rows.length;
|
12350
12422
|
const virtualiser = reactVirtual.useVirtualizer({
|
12351
|
-
count
|
12423
|
+
count,
|
12352
12424
|
estimateSize,
|
12353
12425
|
getScrollElement: () => tableRef.current,
|
12354
|
-
overscan: tableMeta.printing.isPrinting ?
|
12426
|
+
overscan: tableMeta.printing.isPrinting ? count : undefined,
|
12355
12427
|
rangeExtractor,
|
12356
12428
|
// correctly sets the scroll padding offset, e.g. when keyboard navigating rows in the list
|
12357
12429
|
scrollPaddingStart,
|
@@ -12371,19 +12443,19 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
|
|
12371
12443
|
if (tableRef.current) {
|
12372
12444
|
if (index === 0) {
|
12373
12445
|
virtualiser.scrollToOffset(0, notSmooth);
|
12374
|
-
} else if (index ===
|
12446
|
+
} else if (index === count - 1) {
|
12375
12447
|
// sometimes the last row doesn't fully show, so we just force scroll to the bottom
|
12376
12448
|
tableRef.current.scrollTop = tableRef.current.scrollHeight;
|
12377
12449
|
} else {
|
12378
12450
|
virtualiser.scrollToIndex(index, options);
|
12379
12451
|
}
|
12380
12452
|
}
|
12381
|
-
}, [virtualItems.length, tableRef.current, totalSize,
|
12453
|
+
}, [virtualItems.length, tableRef.current, totalSize, count]);
|
12382
12454
|
// use row 1 not 0, because 0 might be sticky in grouped tables and it's start value will always be 0
|
12383
|
-
const paddingStartIndex = isTableRowGrouped &&
|
12455
|
+
const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;
|
12384
12456
|
const startValue = isTableRowGrouped ? ((_virtualItems$padding = virtualItems[paddingStartIndex]) === null || _virtualItems$padding === void 0 ? void 0 : _virtualItems$padding.start) - ((_virtualItems$padding2 = virtualItems[paddingStartIndex]) === null || _virtualItems$padding2 === void 0 ? void 0 : _virtualItems$padding2.size) : (_virtualItems$padding3 = virtualItems[paddingStartIndex]) === null || _virtualItems$padding3 === void 0 ? void 0 : _virtualItems$padding3.start;
|
12385
12457
|
// styling for offsetting rows - this "is" the virtualisation
|
12386
|
-
const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue !== null && startValue !== void 0 ? startValue : 0), Math.max(0,
|
12458
|
+
const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue !== null && startValue !== void 0 ? startValue : 0), Math.max(0, totalSize - ((_virtualItems$end = (_virtualItems = virtualItems[virtualItems.length - 1]) === null || _virtualItems === void 0 ? void 0 : _virtualItems.end) !== null && _virtualItems$end !== void 0 ? _virtualItems$end : 0))] : [0, 0];
|
12387
12459
|
// ensure default active rows are scrolled to
|
12388
12460
|
React__default.useEffect(() => {
|
12389
12461
|
if (defaultRowActiveIndex) {
|
@@ -12397,26 +12469,51 @@ function useTableRenderer(renderers, table, tableRef, defaultRowActiveIndex, opt
|
|
12397
12469
|
let style = {};
|
12398
12470
|
let content = null;
|
12399
12471
|
// bottom rows aren't virtualised (they're sticky) but we need to set the height
|
12400
|
-
if (
|
12472
|
+
if (count || table.getBottomRows().length) {
|
12401
12473
|
style = {
|
12402
12474
|
height: totalSize,
|
12403
|
-
paddingBottom,
|
12404
|
-
paddingTop
|
12475
|
+
paddingBottom: isNaN(paddingBottom) ? 0 : paddingBottom,
|
12476
|
+
paddingTop: isNaN(paddingTop) ? 0 : paddingTop
|
12405
12477
|
};
|
12406
12478
|
}
|
12407
12479
|
// only render non sticky rows
|
12408
|
-
if (
|
12480
|
+
if (count) {
|
12409
12481
|
content = virtualItems.map(virtualRow => {
|
12482
|
+
var _row, _virtualiser$scrollDi2;
|
12410
12483
|
// there appears to be a react-virtual bug where it inserts a single `undefined` item at the end of the row, which crashes here
|
12411
12484
|
if (!virtualRow) {
|
12412
12485
|
return null;
|
12413
12486
|
}
|
12414
|
-
|
12487
|
+
let row;
|
12488
|
+
if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2) {
|
12489
|
+
var _tableMeta$server$pag, _tableMeta$server$pag2;
|
12490
|
+
const currentPageIndex = Math.floor(virtualRow.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
12491
|
+
const pagePosition = (_tableMeta$server$pag = (_tableMeta$server$pag2 = tableMeta.server.pages) === null || _tableMeta$server$pag2 === void 0 ? void 0 : _tableMeta$server$pag2.indexOf(currentPageIndex)) !== null && _tableMeta$server$pag !== void 0 ? _tableMeta$server$pag : -1;
|
12492
|
+
if (pagePosition > -1) {
|
12493
|
+
// "flatten" row indexes down into the dataloader2 dataset size
|
12494
|
+
// for example, with a page size of 100...
|
12495
|
+
// row index 14267 is actually one of index 67, 167, 267 etc within the dataset (depending on number of pages stored)
|
12496
|
+
const fakeIndex = pagePosition * tableMeta.server.pageSize + virtualRow.index % tableMeta.server.pageSize;
|
12497
|
+
row = rows[fakeIndex];
|
12498
|
+
}
|
12499
|
+
} else {
|
12500
|
+
row = rows[virtualRow.index];
|
12501
|
+
}
|
12502
|
+
if (!((_row = row) !== null && _row !== void 0 && _row.original)) {
|
12503
|
+
var _virtualiser$scrollDi;
|
12504
|
+
return /*#__PURE__*/React__default.createElement(SkeletonRow, {
|
12505
|
+
key: virtualRow.index,
|
12506
|
+
index: virtualRow.index,
|
12507
|
+
scrollDirection: (_virtualiser$scrollDi = virtualiser.scrollDirection) !== null && _virtualiser$scrollDi !== void 0 ? _virtualiser$scrollDi : undefined,
|
12508
|
+
table: table
|
12509
|
+
});
|
12510
|
+
}
|
12415
12511
|
const measureRow = createRowMeasurer(virtualiser.resizeItem, virtualRow);
|
12416
12512
|
return /*#__PURE__*/React__default.createElement(Row, {
|
12417
12513
|
key: row.id,
|
12418
12514
|
row: row,
|
12419
12515
|
index: virtualRow.index,
|
12516
|
+
scrollDirection: (_virtualiser$scrollDi2 = virtualiser.scrollDirection) !== null && _virtualiser$scrollDi2 !== void 0 ? _virtualiser$scrollDi2 : undefined,
|
12420
12517
|
table: table,
|
12421
12518
|
measureRow: measureRow,
|
12422
12519
|
renderer: renderers.row,
|
@@ -12723,8 +12820,9 @@ function Header$4(context) {
|
|
12723
12820
|
}
|
12724
12821
|
const _temp = function () {
|
12725
12822
|
if (tableMeta.server.loadAllIfNeeded) {
|
12823
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
12726
12824
|
// don't pass the search query because we need all data - not filtered data
|
12727
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
12825
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns, tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : undefined)).then(function () {});
|
12728
12826
|
}
|
12729
12827
|
}();
|
12730
12828
|
// load all data if that is possible
|
@@ -12783,6 +12881,7 @@ function Cell$3(context) {
|
|
12783
12881
|
if (event.shiftKey) {
|
12784
12882
|
var _tableMeta$rowSelecti;
|
12785
12883
|
function _temp4() {
|
12884
|
+
const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);
|
12786
12885
|
table.setRowSelection(currentRowSelection => ({
|
12787
12886
|
...currentRowSelection,
|
12788
12887
|
...selectedRows.filter(row => row.getCanSelect()).reduce((state, row) => ({
|
@@ -12792,11 +12891,11 @@ function Cell$3(context) {
|
|
12792
12891
|
}));
|
12793
12892
|
}
|
12794
12893
|
const [fromIndex, toIndex] = toggleBetween((_tableMeta$rowSelecti = tableMeta.rowSelection.lastSelectedRowIndex.current) !== null && _tableMeta$rowSelecti !== void 0 ? _tableMeta$rowSelecti : 0, rowIndex);
|
12795
|
-
const selectedRows = table.getRowModel().rows.slice(fromIndex, toIndex + 1);
|
12796
12894
|
const _temp3 = function () {
|
12797
|
-
if (tableMeta.server.loadAllIfNeeded
|
12895
|
+
if (tableMeta.server.loadAllIfNeeded) {
|
12896
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
12798
12897
|
// don't pass the search query because we need all data - not filtered data
|
12799
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
12898
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns, tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : undefined)).then(function () {});
|
12800
12899
|
}
|
12801
12900
|
}();
|
12802
12901
|
return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
|
@@ -12854,7 +12953,7 @@ function useTable(props, externalRef, renderers, meta, options) {
|
|
12854
12953
|
// configure the table
|
12855
12954
|
const manager = useTableManager(props, meta, INTERNAL_RENDERERS);
|
12856
12955
|
// configure the virtualised renderer
|
12857
|
-
const renderer = useTableRenderer(renderers, manager.instance, ref, props.defaultRowActiveIndex, options);
|
12956
|
+
const renderer = useTableRenderer(renderers, manager.instance, ref, manager.meta.length, props.defaultRowActiveIndex, options);
|
12858
12957
|
// configure dynamic styling
|
12859
12958
|
const {
|
12860
12959
|
style,
|
@@ -13924,21 +14023,22 @@ function Summary(props) {
|
|
13924
14023
|
locale,
|
13925
14024
|
texts
|
13926
14025
|
} = useLocalization();
|
13927
|
-
const
|
14026
|
+
const tableMeta = table.options.meta;
|
14027
|
+
const length = tableMeta.length;
|
13928
14028
|
const currentLength = table.getRowModel().rows.length;
|
13929
14029
|
let label;
|
13930
14030
|
let count;
|
13931
14031
|
// row selection
|
13932
|
-
|
14032
|
+
// use table state and not the selected row model because of the way server loading works
|
14033
|
+
const rowsSelectedLength = Object.keys(table.getState().rowSelection).length;
|
13933
14034
|
if (rowsSelectedLength > 0) {
|
13934
14035
|
label = texts.table.footer.summary.selected;
|
13935
14036
|
count = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(rowsSelectedLength)), "\u00A0", texts.table.footer.summary.count, "\u00A0", /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
|
13936
|
-
} else if ((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length ||
|
14037
|
+
} else if (!tableMeta.server.isEnabled && ((_table$getState$colum = table.getState().columnFilters) !== null && _table$getState$colum !== void 0 && _table$getState$colum.length ||
|
13937
14038
|
// filtered data
|
13938
|
-
!!table.getState().globalFilter && table.options.enableGlobalFilter
|
13939
|
-
) {
|
14039
|
+
!!table.getState().globalFilter && table.options.enableGlobalFilter)) {
|
13940
14040
|
label = texts.table.footer.summary.records;
|
13941
|
-
count = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("strong", null, currentLength), "\u00A0", texts.table.footer.summary.count, "\u00A0", /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
|
14041
|
+
count = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(currentLength)), "\u00A0", texts.table.footer.summary.count, "\u00A0", /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length)));
|
13942
14042
|
} else {
|
13943
14043
|
label = texts.table.footer.summary.records;
|
13944
14044
|
count = /*#__PURE__*/React__default.createElement("strong", null, new Intl.NumberFormat(locale).format(length));
|
@@ -14045,6 +14145,7 @@ const SearchInput2 = /*#__PURE__*/React__default.forwardRef(function SearchInput
|
|
14045
14145
|
onClickFindPrevious: handleClickFindPrevious,
|
14046
14146
|
settingsContent,
|
14047
14147
|
shortcut,
|
14148
|
+
showTotal = true,
|
14048
14149
|
value,
|
14049
14150
|
...attributes
|
14050
14151
|
} = props;
|
@@ -14123,10 +14224,12 @@ const SearchInput2 = /*#__PURE__*/React__default.forwardRef(function SearchInput
|
|
14123
14224
|
}
|
14124
14225
|
if (hasFind && isActive) {
|
14125
14226
|
postfix = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
|
14126
|
-
className: "text-grey-700 flex h-4 items-center
|
14127
|
-
}, loading ? /*#__PURE__*/React__default.createElement(Spinner, {
|
14227
|
+
className: "text-grey-700 flex h-4 items-center"
|
14228
|
+
}, loading ? (/*#__PURE__*/React__default.createElement(Spinner, {
|
14128
14229
|
className: "h-4 w-4"
|
14129
|
-
}) :
|
14230
|
+
})) : showTotal ? (/*#__PURE__*/React__default.createElement("span", {
|
14231
|
+
className: "border-r border-black/[0.25] pr-2"
|
14232
|
+
}, `${findCurrent !== null && findCurrent !== void 0 ? findCurrent : 0}/${findTotal !== null && findTotal !== void 0 ? findTotal : 0}`)) : null), findCurrent ? (/*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(IconButton, {
|
14130
14233
|
"aria-label": texts.searchInput.findPrevious,
|
14131
14234
|
className: "scale-75 !bg-transparent hover:!bg-black/[0.08] [&>svg]:scale-125",
|
14132
14235
|
icon: "chevron-up",
|
@@ -14230,6 +14333,7 @@ function Search$1(props) {
|
|
14230
14333
|
const scrollTo = rowIndex => scrollToIndex(rowIndex, {
|
14231
14334
|
align: 'center'
|
14232
14335
|
});
|
14336
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
14233
14337
|
React__default.useEffect(() => {
|
14234
14338
|
if (tableMeta.search.highlightedColumnIndexes.length) {
|
14235
14339
|
scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);
|
@@ -14238,9 +14342,11 @@ function Search$1(props) {
|
|
14238
14342
|
const handleFocus = function () {
|
14239
14343
|
try {
|
14240
14344
|
const _temp = function () {
|
14241
|
-
if (tableMeta.server.loadAllIfNeeded) {
|
14345
|
+
if (tableMeta.server.loadAllIfNeeded && !tableMeta.server._experimentalDataLoader2) {
|
14242
14346
|
// don't pass the search query because we need all data - not filtered data
|
14243
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters
|
14347
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns,
|
14348
|
+
// the old data loader doesn't have server side search
|
14349
|
+
undefined)).then(function () {});
|
14244
14350
|
}
|
14245
14351
|
}();
|
14246
14352
|
// load all data if that is possible
|
@@ -14249,8 +14355,20 @@ function Search$1(props) {
|
|
14249
14355
|
return Promise.reject(e);
|
14250
14356
|
}
|
14251
14357
|
};
|
14358
|
+
const [loading, setLoading] = React__default.useState(false);
|
14359
|
+
const searchTimeoutRef = React__default.useRef();
|
14252
14360
|
const handleChange = query => {
|
14253
14361
|
table.setGlobalFilter(String(query !== null && query !== void 0 ? query : ''));
|
14362
|
+
if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
|
14363
|
+
clearTimeout(searchTimeoutRef.current);
|
14364
|
+
searchTimeoutRef.current = setTimeout(() => {
|
14365
|
+
var _tableMeta$search$han, _tableMeta$search;
|
14366
|
+
setLoading(true);
|
14367
|
+
(_tableMeta$search$han = (_tableMeta$search = tableMeta.search).handleSearch) === null || _tableMeta$search$han === void 0 ? void 0 : _tableMeta$search$han.call(_tableMeta$search, query, hiddenColumns).then(() => {
|
14368
|
+
setLoading(false);
|
14369
|
+
});
|
14370
|
+
}, 150);
|
14371
|
+
}
|
14254
14372
|
};
|
14255
14373
|
const handleToggleExcludeUnmatchedResults = enabled => {
|
14256
14374
|
tableMeta.search.setEnableGlobalFilter(enabled, table);
|
@@ -14258,6 +14376,12 @@ function Search$1(props) {
|
|
14258
14376
|
var _ref$current;
|
14259
14377
|
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
14260
14378
|
});
|
14379
|
+
if (tableMeta.search.handleSearch) {
|
14380
|
+
setLoading(true);
|
14381
|
+
tableMeta.search.handleSearch(enabled ? query : undefined, hiddenColumns).then(() => {
|
14382
|
+
setLoading(false);
|
14383
|
+
});
|
14384
|
+
}
|
14261
14385
|
};
|
14262
14386
|
const handleNextResult = () => {
|
14263
14387
|
if (!tableMeta.search.highlightedColumnIndexes.length) {
|
@@ -14301,7 +14425,7 @@ function Search$1(props) {
|
|
14301
14425
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SearchInput2, {
|
14302
14426
|
findCurrent: tableMeta.search.currentHighlightColumnIndex !== undefined ? tableMeta.search.currentHighlightColumnIndex + 1 : null,
|
14303
14427
|
findTotal: (_tableMeta$search$hig = (_tableMeta$search$hig2 = tableMeta.search.highlightedColumnIndexes) === null || _tableMeta$search$hig2 === void 0 ? void 0 : _tableMeta$search$hig2.length) !== null && _tableMeta$search$hig !== void 0 ? _tableMeta$search$hig : null,
|
14304
|
-
loading: tableMeta.server.loading,
|
14428
|
+
loading: tableMeta.server._experimentalDataLoader2 ? loading : tableMeta.server.loading,
|
14305
14429
|
name: "table-search",
|
14306
14430
|
onClickFindPrevious: handlePreviousResult,
|
14307
14431
|
onClickFindNext: handleNextResult,
|
@@ -14316,6 +14440,7 @@ function Search$1(props) {
|
|
14316
14440
|
meta: true,
|
14317
14441
|
shift: false
|
14318
14442
|
},
|
14443
|
+
showTotal: !tableMeta.server._experimentalDataLoader2,
|
14319
14444
|
value: query
|
14320
14445
|
}));
|
14321
14446
|
}
|
@@ -14669,9 +14794,11 @@ const Root = /*#__PURE__*/React__default.forwardRef(function CollectionRoot(prop
|
|
14669
14794
|
var _collection$querySele;
|
14670
14795
|
(_collection$querySele = collection.querySelector(`[aria-current]`)) === null || _collection$querySele === void 0 ? void 0 : _collection$querySele.removeAttribute('aria-current');
|
14671
14796
|
option.setAttribute('aria-current', 'true');
|
14672
|
-
|
14673
|
-
|
14674
|
-
|
14797
|
+
if (!props['aria-multiselectable']) {
|
14798
|
+
option.scrollIntoView({
|
14799
|
+
block: 'nearest'
|
14800
|
+
});
|
14801
|
+
}
|
14675
14802
|
setActiveIndex(index);
|
14676
14803
|
};
|
14677
14804
|
const setActiveIndexByElement = React__default.useCallback(option => {
|
@@ -14999,7 +15126,7 @@ const Tag$1 = /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
|
14999
15126
|
name: icon,
|
15000
15127
|
className: "-ml-1 mr-1 !h-5 !w-5"
|
15001
15128
|
})) : (/*#__PURE__*/React__default.cloneElement(icon, {
|
15002
|
-
className: 'mr-1 -ml-1
|
15129
|
+
className: cn(icon.props.className, 'mr-1 -ml-1')
|
15003
15130
|
})) : null, /*#__PURE__*/React__default.createElement("span", {
|
15004
15131
|
className: "truncate"
|
15005
15132
|
}, children)), onDelete ? (/*#__PURE__*/React__default.createElement(Icon, {
|
@@ -16400,8 +16527,9 @@ function Print$1(props) {
|
|
16400
16527
|
const toastRef = toast.loading(texts.table.print.loading);
|
16401
16528
|
const _temp2 = function () {
|
16402
16529
|
if (tableMeta.server.isEnabled && tableMeta.server.loadAllIfNeeded) {
|
16530
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
16403
16531
|
const _temp = _catch(function () {
|
16404
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
16532
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns, tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : undefined)).then(function () {});
|
16405
16533
|
}, function (error) {
|
16406
16534
|
const errorMessage = `${texts.table.print.error}: ${error}`;
|
16407
16535
|
console.error(errorMessage);
|
@@ -17126,7 +17254,10 @@ function TableGrid(props) {
|
|
17126
17254
|
}
|
17127
17255
|
|
17128
17256
|
const Column$1 = () => null;
|
17129
|
-
|
17257
|
+
Column$1.displayName = 'Table3Column';
|
17258
|
+
function Group$4(_) {
|
17259
|
+
return null;
|
17260
|
+
}
|
17130
17261
|
const BaseReport = /*#__PURE__*/fixedForwardRef(function BaseReport(props, ref) {
|
17131
17262
|
const report = useReport(props, ref);
|
17132
17263
|
return /*#__PURE__*/React__default.createElement(Table, null, /*#__PURE__*/React__default.createElement(Table.Toolbar, {
|
@@ -18766,18 +18897,21 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
18766
18897
|
document.addEventListener('click', onClickOutside);
|
18767
18898
|
return () => document.removeEventListener('click', onClickOutside);
|
18768
18899
|
}, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
|
18769
|
-
|
18770
|
-
|
18771
|
-
|
18772
|
-
|
18773
|
-
|
18774
|
-
|
18775
|
-
|
18776
|
-
|
18777
|
-
|
18778
|
-
|
18779
|
-
|
18780
|
-
|
18900
|
+
/*
|
18901
|
+
const rows = table.getRowModel().rows;
|
18902
|
+
// make sure pending changes are removed for rows that no longer exist
|
18903
|
+
useLazyEffect(() => {
|
18904
|
+
const pendingChanges = tableMeta.editing.getErrorsShownInAlert();
|
18905
|
+
pendingChanges.forEach(pendingChange => {
|
18906
|
+
try {
|
18907
|
+
table.getRow(pendingChange.rowId);
|
18908
|
+
} catch {
|
18909
|
+
// TODO: this has the potential to remove changes for "unloaded" rows in server loading
|
18910
|
+
//tableMeta.editing.discardChanges(pendingChange.rowId, table);
|
18911
|
+
}
|
18912
|
+
});
|
18913
|
+
}, [rows.length]);
|
18914
|
+
*/
|
18781
18915
|
// shortcuts
|
18782
18916
|
useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : undefined, event => {
|
18783
18917
|
event.preventDefault();
|
@@ -18805,6 +18939,7 @@ function reducer$2(state, action) {
|
|
18805
18939
|
{
|
18806
18940
|
const {
|
18807
18941
|
columnId,
|
18942
|
+
index,
|
18808
18943
|
row,
|
18809
18944
|
value
|
18810
18945
|
} = payload;
|
@@ -18814,7 +18949,8 @@ function reducer$2(state, action) {
|
|
18814
18949
|
...state.changes,
|
18815
18950
|
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
18816
18951
|
originals: setWith(state.changes.originals, rowId, row, Object)
|
18817
|
-
}
|
18952
|
+
},
|
18953
|
+
indexes: setWith(state.indexes, rowId, index, Object)
|
18818
18954
|
};
|
18819
18955
|
}
|
18820
18956
|
case 'removeCellValue':
|
@@ -18848,6 +18984,7 @@ function reducer$2(state, action) {
|
|
18848
18984
|
{
|
18849
18985
|
const {
|
18850
18986
|
cellErrors,
|
18987
|
+
index,
|
18851
18988
|
moveReasons,
|
18852
18989
|
original,
|
18853
18990
|
value
|
@@ -18857,12 +18994,13 @@ function reducer$2(state, action) {
|
|
18857
18994
|
changes: {
|
18858
18995
|
...state.changes,
|
18859
18996
|
rows: setWith(state.changes.rows, rowId, value, Object),
|
18860
|
-
errors: setWith(state.changes.errors, `${rowId}.cells`, cellErrors !== null && cellErrors !== void 0 ? cellErrors : state.changes.errors
|
18997
|
+
errors: setWith(state.changes.errors, `${rowId}.cells`, cellErrors !== null && cellErrors !== void 0 ? cellErrors : state.changes.errors[rowId], Object),
|
18861
18998
|
originals: setWith(state.changes.originals, rowId, original !== null && original !== void 0 ? original : state.changes.originals[rowId], Object),
|
18862
18999
|
moveReasons: setWith(state.changes.moveReasons, rowId, moveReasons !== null && moveReasons !== void 0 ? moveReasons : state.changes.moveReasons[rowId], Object),
|
18863
19000
|
// status can be undefined, so don't use ??
|
18864
19001
|
status: setWith(state.changes.status, rowId, undefined, Object)
|
18865
|
-
}
|
19002
|
+
},
|
19003
|
+
indexes: setWith(state.indexes, rowId, index, Object)
|
18866
19004
|
};
|
18867
19005
|
}
|
18868
19006
|
case 'removeRow':
|
@@ -18880,6 +19018,7 @@ function reducer$2(state, action) {
|
|
18880
19018
|
originals: omit(state.changes.originals, rowId),
|
18881
19019
|
status: omit(state.changes.status, rowId)
|
18882
19020
|
},
|
19021
|
+
indexes: omit(state.indexes, rowId),
|
18883
19022
|
temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId)
|
18884
19023
|
};
|
18885
19024
|
}
|
@@ -18912,6 +19051,7 @@ function reducer$2(state, action) {
|
|
18912
19051
|
case 'insertTemporaryRow':
|
18913
19052
|
{
|
18914
19053
|
const {
|
19054
|
+
index,
|
18915
19055
|
value
|
18916
19056
|
} = payload;
|
18917
19057
|
return {
|
@@ -18921,14 +19061,36 @@ function reducer$2(state, action) {
|
|
18921
19061
|
...state.changes,
|
18922
19062
|
rows: setWith(state.changes.rows, rowId, value, Object),
|
18923
19063
|
originals: setWith(state.changes.originals, rowId, value, Object)
|
18924
|
-
}
|
19064
|
+
},
|
19065
|
+
indexes: setWith(state.indexes, rowId, index, Object)
|
18925
19066
|
};
|
18926
19067
|
}
|
18927
19068
|
default:
|
18928
19069
|
return state;
|
18929
19070
|
}
|
18930
19071
|
}
|
18931
|
-
function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator) {
|
19072
|
+
function usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator) {
|
19073
|
+
const discardChanges = function (rowId, table) {
|
19074
|
+
try {
|
19075
|
+
// remove any new rows from pinned state before discarding them
|
19076
|
+
table.resetRowPinning(true);
|
19077
|
+
dispatch({
|
19078
|
+
type: 'removeRow',
|
19079
|
+
rowId,
|
19080
|
+
payload: {
|
19081
|
+
rowIdentityAccessor
|
19082
|
+
}
|
19083
|
+
});
|
19084
|
+
const _temp8 = function () {
|
19085
|
+
if (typeof handleDiscard === 'function') {
|
19086
|
+
return Promise.resolve(handleDiscard()).then(function () {});
|
19087
|
+
}
|
19088
|
+
}();
|
19089
|
+
return Promise.resolve(_temp8 && _temp8.then ? _temp8.then(function () {}) : void 0);
|
19090
|
+
} catch (e) {
|
19091
|
+
return Promise.reject(e);
|
19092
|
+
}
|
19093
|
+
};
|
18932
19094
|
const saveChanges = function (table, rowId = undefined) {
|
18933
19095
|
try {
|
18934
19096
|
let _exit = false;
|
@@ -18941,19 +19103,20 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18941
19103
|
[rowId]: state.changes.rows[rowId]
|
18942
19104
|
} : state.changes.rows;
|
18943
19105
|
let completed = true;
|
18944
|
-
const
|
19106
|
+
const _temp7 = _forOf(Object.keys(changes), function (rowId) {
|
18945
19107
|
const status = getRowStatus(rowId);
|
18946
19108
|
return _catch(function () {
|
18947
19109
|
var _changes$rowId;
|
18948
|
-
function
|
19110
|
+
function _temp6(_result) {
|
18949
19111
|
return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
|
18950
19112
|
// cleanup changes, we don't need them after saving
|
18951
|
-
discardChanges(rowId, table)
|
18952
|
-
|
18953
|
-
|
18954
|
-
|
18955
|
-
|
18956
|
-
|
19113
|
+
return Promise.resolve(discardChanges(rowId, table)).then(function () {
|
19114
|
+
// show the saved status, then remove it after a delay
|
19115
|
+
setRowStatus(rowId, 'saved');
|
19116
|
+
setTimeout(() => {
|
19117
|
+
setRowStatus(rowId, undefined);
|
19118
|
+
}, DELAY_BEFORE_REMOVING_SAVE_STATUS);
|
19119
|
+
});
|
18957
19120
|
});
|
18958
19121
|
}
|
18959
19122
|
const rowChanges = (_changes$rowId = changes[rowId]) !== null && _changes$rowId !== void 0 ? _changes$rowId : {};
|
@@ -18971,7 +19134,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18971
19134
|
delete changeSet[rowIdentityAccessor];
|
18972
19135
|
}
|
18973
19136
|
// re-run validation, maybe a cell is already invalid but has never been blurred
|
18974
|
-
const
|
19137
|
+
const _temp5 = function () {
|
18975
19138
|
if (validator) {
|
18976
19139
|
return Promise.resolve(validator(changeSet)).then(function (errors) {
|
18977
19140
|
if (errors && Object.keys(errors).length) {
|
@@ -18980,7 +19143,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18980
19143
|
});
|
18981
19144
|
}
|
18982
19145
|
}();
|
18983
|
-
return
|
19146
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5); // send new data to the server
|
18984
19147
|
}, function (error) {
|
18985
19148
|
var _error$response;
|
18986
19149
|
if (error instanceof ReferenceError || error instanceof TypeError || (error === null || error === void 0 ? void 0 : (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) >= 500) {
|
@@ -19020,18 +19183,18 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19020
19183
|
}, function () {
|
19021
19184
|
return _exit;
|
19022
19185
|
});
|
19023
|
-
return Promise.resolve(
|
19186
|
+
return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function (_result3) {
|
19024
19187
|
return _exit ? _result3 : completed;
|
19025
|
-
}) : _exit ?
|
19188
|
+
}) : _exit ? _temp7 : completed);
|
19026
19189
|
} catch (e) {
|
19027
19190
|
return Promise.reject(e);
|
19028
19191
|
}
|
19029
19192
|
};
|
19030
19193
|
const onCellChanged = function (cell, rowIndex, nextValue, shouldRunUpdaters = true) {
|
19031
19194
|
try {
|
19032
|
-
function
|
19195
|
+
function _temp4() {
|
19033
19196
|
var _state$changes$errors11;
|
19034
|
-
function
|
19197
|
+
function _temp2() {
|
19035
19198
|
// only set errors and move reasons for the cells we're currently acting on
|
19036
19199
|
// why? because the UX is not good if we set them for cells the user hasn't touched yet
|
19037
19200
|
const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];
|
@@ -19062,6 +19225,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19062
19225
|
rowId: cell.row.id,
|
19063
19226
|
payload: {
|
19064
19227
|
cellErrors: nextCellErrors,
|
19228
|
+
index: rowIndex,
|
19065
19229
|
moveReasons: nextMoveReasons,
|
19066
19230
|
value: nextChanges
|
19067
19231
|
}
|
@@ -19080,7 +19244,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19080
19244
|
};
|
19081
19245
|
// run validation - if there are changes, and if there is an original stored
|
19082
19246
|
let validationErrors = {};
|
19083
|
-
const
|
19247
|
+
const _temp = function () {
|
19084
19248
|
if (validator && Object.keys(nextChanges).length && state.changes.originals[cell.row.id]) {
|
19085
19249
|
// merge with the original so we get a full row
|
19086
19250
|
const nextRowValue = {
|
@@ -19088,12 +19252,12 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19088
19252
|
...changes,
|
19089
19253
|
...updatesForOtherCells
|
19090
19254
|
};
|
19091
|
-
return Promise.resolve(validator(nextRowValue)).then(function (
|
19092
|
-
validationErrors =
|
19255
|
+
return Promise.resolve(validator(nextRowValue)).then(function (_validator) {
|
19256
|
+
validationErrors = _validator !== null && _validator !== void 0 ? _validator : {};
|
19093
19257
|
});
|
19094
19258
|
}
|
19095
19259
|
}();
|
19096
|
-
return
|
19260
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
19097
19261
|
}
|
19098
19262
|
const changes = nextValue !== undefined ? {
|
19099
19263
|
...state.changes.rows[cell.row.id],
|
@@ -19106,7 +19270,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19106
19270
|
}
|
19107
19271
|
let updatesForOtherCells = {};
|
19108
19272
|
// run the updater handler if there is one, to see if there are any other cells to update
|
19109
|
-
const
|
19273
|
+
const _temp3 = function () {
|
19110
19274
|
if (typeof handleChange === 'function' && shouldRunUpdaters) {
|
19111
19275
|
const previousRowValue = {
|
19112
19276
|
...state.changes.originals[cell.row.id]
|
@@ -19120,42 +19284,11 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19120
19284
|
});
|
19121
19285
|
}
|
19122
19286
|
}();
|
19123
|
-
return Promise.resolve(
|
19287
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
|
19124
19288
|
} catch (e) {
|
19125
19289
|
return Promise.reject(e);
|
19126
19290
|
}
|
19127
19291
|
}; // general
|
19128
|
-
// rows
|
19129
|
-
const setRowValue = function (rowId, original, value) {
|
19130
|
-
try {
|
19131
|
-
function _temp2() {
|
19132
|
-
dispatch({
|
19133
|
-
type: 'updateRow',
|
19134
|
-
rowId,
|
19135
|
-
payload: {
|
19136
|
-
cellErrors,
|
19137
|
-
original,
|
19138
|
-
value
|
19139
|
-
}
|
19140
|
-
});
|
19141
|
-
}
|
19142
|
-
let cellErrors;
|
19143
|
-
const _temp = function () {
|
19144
|
-
if (validator) {
|
19145
|
-
const row = {
|
19146
|
-
...original,
|
19147
|
-
...value
|
19148
|
-
};
|
19149
|
-
return Promise.resolve(validator(row)).then(function (_validator) {
|
19150
|
-
cellErrors = _validator !== null && _validator !== void 0 ? _validator : {};
|
19151
|
-
});
|
19152
|
-
}
|
19153
|
-
}();
|
19154
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
19155
|
-
} catch (e) {
|
19156
|
-
return Promise.reject(e);
|
19157
|
-
}
|
19158
|
-
};
|
19159
19292
|
const localization = useLocalization();
|
19160
19293
|
const [state, dispatch] = React__default.useReducer(reducer$2, {
|
19161
19294
|
changes: {
|
@@ -19165,8 +19298,10 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19165
19298
|
originals: {},
|
19166
19299
|
status: {}
|
19167
19300
|
},
|
19301
|
+
indexes: {},
|
19168
19302
|
temporaryRows: []
|
19169
19303
|
});
|
19304
|
+
// rows
|
19170
19305
|
function getRowValue(rowId) {
|
19171
19306
|
var _state$changes$rows$r, _state$changes$rows;
|
19172
19307
|
return (_state$changes$rows$r = (_state$changes$rows = state.changes.rows) === null || _state$changes$rows === void 0 ? void 0 : _state$changes$rows[rowId]) !== null && _state$changes$rows$r !== void 0 ? _state$changes$rows$r : undefined;
|
@@ -19204,7 +19339,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19204
19339
|
}
|
19205
19340
|
});
|
19206
19341
|
}
|
19207
|
-
function insertTemporaryRow(data) {
|
19342
|
+
function insertTemporaryRow(data, rowIndex) {
|
19208
19343
|
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
|
19209
19344
|
const value = {
|
19210
19345
|
...data,
|
@@ -19214,13 +19349,14 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19214
19349
|
type: 'insertTemporaryRow',
|
19215
19350
|
rowId: newRowId,
|
19216
19351
|
payload: {
|
19352
|
+
index: rowIndex,
|
19217
19353
|
value
|
19218
19354
|
}
|
19219
19355
|
});
|
19220
19356
|
return newRowId;
|
19221
19357
|
}
|
19222
19358
|
// cells
|
19223
|
-
function setCellValue(cell, value) {
|
19359
|
+
function setCellValue(cell, rowIndex, value) {
|
19224
19360
|
const rowId = cell.row.id;
|
19225
19361
|
const columnId = cell.column.id;
|
19226
19362
|
// update if the change is different to the original value
|
@@ -19230,6 +19366,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19230
19366
|
rowId,
|
19231
19367
|
payload: {
|
19232
19368
|
columnId,
|
19369
|
+
index: rowIndex,
|
19233
19370
|
row: cell.row.original,
|
19234
19371
|
value
|
19235
19372
|
}
|
@@ -19262,6 +19399,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19262
19399
|
}
|
19263
19400
|
return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({
|
19264
19401
|
rowId,
|
19402
|
+
index: state.indexes[rowId],
|
19265
19403
|
changes: state.changes.rows[rowId],
|
19266
19404
|
errors: state.changes.errors[rowId]
|
19267
19405
|
}));
|
@@ -19272,20 +19410,8 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19272
19410
|
function hasChanges(rowId) {
|
19273
19411
|
return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
|
19274
19412
|
}
|
19275
|
-
function discardChanges(rowId, table) {
|
19276
|
-
// remove any new rows from pinned state before discarding them
|
19277
|
-
table.resetRowPinning(true);
|
19278
|
-
dispatch({
|
19279
|
-
type: 'removeRow',
|
19280
|
-
rowId,
|
19281
|
-
payload: {
|
19282
|
-
rowIdentityAccessor
|
19283
|
-
}
|
19284
|
-
});
|
19285
|
-
}
|
19286
19413
|
return {
|
19287
19414
|
// row
|
19288
|
-
setRowValue,
|
19289
19415
|
getRowValue,
|
19290
19416
|
getRowMoveReason,
|
19291
19417
|
hasRowErrors,
|
@@ -19310,8 +19436,8 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19310
19436
|
};
|
19311
19437
|
}
|
19312
19438
|
|
19313
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
|
19314
|
-
const createRow = function (table,
|
19439
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator) {
|
19440
|
+
const createRow = function (table, row) {
|
19315
19441
|
try {
|
19316
19442
|
let _exit = false;
|
19317
19443
|
function _temp2(_result) {
|
@@ -19319,23 +19445,28 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19319
19445
|
const changeset = row !== null && row !== void 0 ? row : handleCreate();
|
19320
19446
|
try {
|
19321
19447
|
if (changeset) {
|
19322
|
-
const newRowId = pendingChangesFns.insertTemporaryRow(changeset);
|
19323
|
-
// reset before changing row otherwise the cell changes and validation might run
|
19324
|
-
setLastFocusedCellIndex(undefined);
|
19325
19448
|
// set the active row to the new row before toggling editing on
|
19326
19449
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
19327
19450
|
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
19328
|
-
|
19451
|
+
const newRowId = pendingChangesFns.insertTemporaryRow(changeset, nextRowIndex);
|
19452
|
+
// prep the row
|
19453
|
+
table.setRowPinning(currentState => {
|
19454
|
+
var _ref, _currentState$bottom;
|
19455
|
+
return {
|
19456
|
+
...currentState,
|
19457
|
+
bottom: (_ref = (_currentState$bottom = currentState.bottom) !== null && _currentState$bottom !== void 0 ? _currentState$bottom : []) === null || _ref === void 0 ? void 0 : _ref.concat(newRowId)
|
19458
|
+
};
|
19459
|
+
});
|
19460
|
+
// prep editing mode
|
19461
|
+
toggleDetailedMode(false);
|
19462
|
+
setLastFocusedCellIndex(undefined);
|
19329
19463
|
// wait until set states have run
|
19330
19464
|
requestAnimationFrame(() => {
|
19331
|
-
|
19332
|
-
table.
|
19333
|
-
|
19334
|
-
|
19335
|
-
|
19336
|
-
bottom: (_ref = (_currentState$bottom = currentState.bottom) !== null && _currentState$bottom !== void 0 ? _currentState$bottom : []) === null || _ref === void 0 ? void 0 : _ref.concat(newRowId)
|
19337
|
-
};
|
19338
|
-
});
|
19465
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
19466
|
+
table.resetRowSelection();
|
19467
|
+
if (!tableMeta.editing.isEditing) {
|
19468
|
+
setEditing(true);
|
19469
|
+
}
|
19339
19470
|
});
|
19340
19471
|
}
|
19341
19472
|
} catch (error) {
|
@@ -19348,8 +19479,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19348
19479
|
const tableMeta = table.options.meta;
|
19349
19480
|
const _temp = function () {
|
19350
19481
|
if (tableMeta.rowActive.rowActiveIndex !== undefined) {
|
19351
|
-
|
19352
|
-
return Promise.resolve(tableMeta.editing.saveChanges(table, (_table$getRowModel$ro2 = table.getRowModel().rows[tableMeta.rowActive.rowActiveIndex]) === null || _table$getRowModel$ro2 === void 0 ? void 0 : _table$getRowModel$ro2.id)).then(function (saved) {
|
19482
|
+
return Promise.resolve(tableMeta.editing.saveChanges(table)).then(function (saved) {
|
19353
19483
|
if (!saved) {
|
19354
19484
|
_exit = true;
|
19355
19485
|
}
|
@@ -19369,13 +19499,14 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19369
19499
|
const createRowButtonRef = React__default.useRef(null);
|
19370
19500
|
// store the last focused cell, so that up/down arrow key navigation remains in the same column
|
19371
19501
|
const [lastFocusedCellIndex, setLastFocusedCellIndex] = React__default.useState(undefined);
|
19372
|
-
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator);
|
19373
|
-
function toggleEditing(enabled, table, scrollToIndex
|
19502
|
+
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator);
|
19503
|
+
function toggleEditing(enabled, table, scrollToIndex) {
|
19374
19504
|
const tableMeta = table.options.meta;
|
19375
19505
|
if (enabled) {
|
19376
19506
|
var _tableMeta$rowActive$, _table$getRowModel$ro;
|
19377
19507
|
const index = (_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0;
|
19378
19508
|
if (tableMeta.rowActive.rowActiveIndex === undefined) {
|
19509
|
+
console.log('edit toggle active', index);
|
19379
19510
|
tableMeta.rowActive.setRowActiveIndex(index);
|
19380
19511
|
}
|
19381
19512
|
if (!isTemporaryRow((_table$getRowModel$ro = table.getRowModel().rows[index]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id)) {
|
@@ -19388,9 +19519,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19388
19519
|
setLastFocusedCellIndex(undefined);
|
19389
19520
|
}
|
19390
19521
|
setEditing(enabled);
|
19391
|
-
|
19392
|
-
pendingChangesFns.saveChanges(table);
|
19393
|
-
}
|
19522
|
+
pendingChangesFns.saveChanges(table);
|
19394
19523
|
}
|
19395
19524
|
return {
|
19396
19525
|
isEnabled,
|
@@ -19659,7 +19788,7 @@ function EditingControlCell(props) {
|
|
19659
19788
|
}, [cellRef.current]);
|
19660
19789
|
const handleChange = React__default.useCallback(nextValue => {
|
19661
19790
|
if (nextValue !== value) {
|
19662
|
-
tableMeta.editing.setCellValue(cell, nextValue);
|
19791
|
+
tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
|
19663
19792
|
if (hasNonTextControl) {
|
19664
19793
|
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
19665
19794
|
}
|
@@ -19828,11 +19957,21 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19828
19957
|
props.onChange(newDate);
|
19829
19958
|
}
|
19830
19959
|
};
|
19960
|
+
const handleDatepickerInputKeyDown = event => {
|
19961
|
+
// When in detailed mode, we want to handle the change, when 'Enter' is pressed.
|
19962
|
+
// To make it possible, we just need to prevent handleInputKeyDown from being executed, and give the full control to Datepicker,
|
19963
|
+
// by doing this, Datepicker will exit "detailed mode" by itself when a valid date change event is triggered.
|
19964
|
+
// In any other cases we'll just execute the "handleInputKeyDown" handler.
|
19965
|
+
if (isDetailedMode && event.key === 'Enter' && event.target.value !== '') {
|
19966
|
+
return;
|
19967
|
+
}
|
19968
|
+
handleInputKeyDown(event);
|
19969
|
+
};
|
19831
19970
|
return /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, commonProps, {
|
19832
19971
|
invalid: invalid,
|
19833
19972
|
onChange: handleChange,
|
19834
19973
|
onFocus: handleFocus,
|
19835
|
-
onKeyDown:
|
19974
|
+
onKeyDown: handleDatepickerInputKeyDown,
|
19836
19975
|
ref: controlRef,
|
19837
19976
|
value: valueAsDate
|
19838
19977
|
}));
|
@@ -20084,7 +20223,7 @@ const RENDERERS$1 = {
|
|
20084
20223
|
cell: Cell$5
|
20085
20224
|
};
|
20086
20225
|
function useTable3(props, ref) {
|
20087
|
-
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.rowIdentityAccessor, props.validator);
|
20226
|
+
const editing = useTableEditing(props.enableEditing, props.onEditingSave, props.onEditingChange, props.onEditingCreate, props.onEditingDiscard, props.rowIdentityAccessor, props.validator);
|
20088
20227
|
const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
|
20089
20228
|
// this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
|
20090
20229
|
const data = React__default.useMemo(() => {
|
@@ -20137,7 +20276,7 @@ function useTable3(props, ref) {
|
|
20137
20276
|
if (table.ref.current) {
|
20138
20277
|
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
|
20139
20278
|
if (props.onEditingCreate) {
|
20140
|
-
table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance,
|
20279
|
+
table.ref.current.instance.createRow = row => table.meta.editing.createRow(table.instance, row);
|
20141
20280
|
}
|
20142
20281
|
}
|
20143
20282
|
}, [table.ref.current]);
|
@@ -20181,20 +20320,22 @@ function Alert$1(props) {
|
|
20181
20320
|
// table.getColumn(columName) throw error in strict dev mode. Related thread: https://github.com/TanStack/table/discussions/5505
|
20182
20321
|
table.getAllColumns().find(x => x.id === String(tableMeta.rowIdentityAccessor)) : undefined;
|
20183
20322
|
pendingChangesWithErrors.forEach((pendingChangeWithError, index) => {
|
20323
|
+
var _row;
|
20184
20324
|
// if appropriate, concatenate the item with the text "and"
|
20185
20325
|
if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
|
20186
20326
|
// Add space before and after `messageAnd` text
|
20187
20327
|
links.push(` ${validationTexts.alert.messageAnd} `);
|
20188
20328
|
}
|
20189
|
-
|
20329
|
+
// note: if this row click functionality is removed, indexes can be removed from useEditingState
|
20190
20330
|
const handleClick = () => {
|
20191
20331
|
// if row is visible
|
20192
|
-
if (
|
20193
|
-
scrollToRow(
|
20332
|
+
if (pendingChangeWithError.index > -1) {
|
20333
|
+
scrollToRow(pendingChangeWithError.index);
|
20334
|
+
tableMeta.rowActive.setRowActiveIndex(pendingChangeWithError.index);
|
20194
20335
|
}
|
20195
20336
|
// if row is filtered out
|
20196
20337
|
else {
|
20197
|
-
setShowFilterResetDialog(pendingChangeWithError.
|
20338
|
+
setShowFilterResetDialog(pendingChangeWithError.index);
|
20198
20339
|
}
|
20199
20340
|
};
|
20200
20341
|
let tooltip;
|
@@ -20206,7 +20347,12 @@ function Alert$1(props) {
|
|
20206
20347
|
const columnName = (_table$getAllColumns$ = table.getAllColumns().find(column => column.id === firstCellErrorColumnId)) === null || _table$getAllColumns$ === void 0 ? void 0 : (_table$getAllColumns$2 = _table$getAllColumns$.columnDef.meta) === null || _table$getAllColumns$2 === void 0 ? void 0 : _table$getAllColumns$2.header;
|
20207
20348
|
tooltip = `${columnName}: ${pendingChangeWithError.errors.cells[firstCellErrorColumnId]}`;
|
20208
20349
|
}
|
20209
|
-
|
20350
|
+
let row = undefined;
|
20351
|
+
try {
|
20352
|
+
row = table.getRow(pendingChangeWithError.rowId).original;
|
20353
|
+
} catch {
|
20354
|
+
// because of server loading, some rows may not be accessible
|
20355
|
+
}
|
20210
20356
|
links.push(/*#__PURE__*/React__default.createElement(Tooltip, {
|
20211
20357
|
key: pendingChangeWithError.rowId,
|
20212
20358
|
title: tooltip
|
@@ -20214,7 +20360,7 @@ function Alert$1(props) {
|
|
20214
20360
|
className: "text-blue",
|
20215
20361
|
onClick: handleClick,
|
20216
20362
|
role: "button"
|
20217
|
-
}, rowIdentityColumn ? row[rowIdentityColumn.id] :
|
20363
|
+
}, rowIdentityColumn ? (_row = row) === null || _row === void 0 ? void 0 : _row[rowIdentityColumn.id] : pendingChangeWithError.index + 1)));
|
20218
20364
|
// if appropriate, concatenate the item with the text ","
|
20219
20365
|
if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
|
20220
20366
|
links.push(', ');
|
@@ -20235,9 +20381,8 @@ function Alert$1(props) {
|
|
20235
20381
|
table.resetGlobalFilter();
|
20236
20382
|
table.resetColumnFilters();
|
20237
20383
|
requestAnimationFrame(() => {
|
20238
|
-
|
20239
|
-
|
20240
|
-
scrollToRow(rowIndex);
|
20384
|
+
if (showFilterResetDialog && showFilterResetDialog > -1) {
|
20385
|
+
scrollToRow(showFilterResetDialog);
|
20241
20386
|
}
|
20242
20387
|
setShowFilterResetDialog(false);
|
20243
20388
|
});
|
@@ -20302,7 +20447,6 @@ function CreateNewRow(props) {
|
|
20302
20447
|
const {
|
20303
20448
|
buttonRef,
|
20304
20449
|
isScrolled,
|
20305
|
-
scrollToIndex,
|
20306
20450
|
table,
|
20307
20451
|
tableMeta
|
20308
20452
|
} = props;
|
@@ -20318,7 +20462,7 @@ function CreateNewRow(props) {
|
|
20318
20462
|
if (isDisabled) {
|
20319
20463
|
return Promise.resolve();
|
20320
20464
|
}
|
20321
|
-
return Promise.resolve(tableMeta.editing.createRow(table
|
20465
|
+
return Promise.resolve(tableMeta.editing.createRow(table)).then(function () {});
|
20322
20466
|
} catch (e) {
|
20323
20467
|
return Promise.reject(e);
|
20324
20468
|
}
|
@@ -20337,7 +20481,7 @@ function CreateNewRow(props) {
|
|
20337
20481
|
keys: shortcut
|
20338
20482
|
});
|
20339
20483
|
}
|
20340
|
-
const className = cn('group/row border-grey-300 !sticky z-[21]', {
|
20484
|
+
const className = cn('group/row border-grey-300 !sticky z-[21] print:hidden', {
|
20341
20485
|
'bottom-10': tableMeta.footer.isEnabled,
|
20342
20486
|
'bottom-0': !tableMeta.footer.isEnabled,
|
20343
20487
|
'border-b': !isScrolled
|
@@ -20427,7 +20571,7 @@ function TemporaryRow(props) {
|
|
20427
20571
|
}
|
20428
20572
|
}
|
20429
20573
|
};
|
20430
|
-
const className = cn('group/row border-grey-300 !sticky z-[22]', {
|
20574
|
+
const className = cn('group/row border-grey-300 !sticky z-[22] print:hidden', {
|
20431
20575
|
'bottom-[calc(5rem_+_2px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,
|
20432
20576
|
'bottom-[calc(2.5rem_+_2px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,
|
20433
20577
|
'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled
|
@@ -20444,13 +20588,16 @@ function TemporaryRow(props) {
|
|
20444
20588
|
onKeyDown: handleKeyDown,
|
20445
20589
|
onKeyDownCapture: handleKeyDownCapture,
|
20446
20590
|
hideInternalColumns: true,
|
20447
|
-
hideRowActions: !tableMeta.editing.isEditing
|
20591
|
+
hideRowActions: !tableMeta.editing.isEditing,
|
20592
|
+
skipPageLoading: true
|
20448
20593
|
}))));
|
20449
20594
|
}
|
20450
20595
|
|
20451
20596
|
const Column$3 = () => null;
|
20452
20597
|
Column$3.displayName = 'Table3Column';
|
20453
|
-
|
20598
|
+
function Group$5(_) {
|
20599
|
+
return null;
|
20600
|
+
}
|
20454
20601
|
Group$5.displayName = 'Table3Group';
|
20455
20602
|
const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref) {
|
20456
20603
|
var _table3$meta$editing, _table3$meta$editing2;
|
@@ -20467,7 +20614,6 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
20467
20614
|
createWorkflow = /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
20468
20615
|
buttonRef: table3.meta.editing.createRowButtonRef,
|
20469
20616
|
isScrolled: isScrolled,
|
20470
|
-
scrollToIndex: table3.renderer.scrollToIndex,
|
20471
20617
|
table: table3.instance,
|
20472
20618
|
tableMeta: table3.meta
|
20473
20619
|
});
|
@@ -22229,6 +22375,222 @@ Navigation2.Link = Link$3;
|
|
22229
22375
|
Navigation2.Section = Section;
|
22230
22376
|
Navigation2.Content = Content$a;
|
22231
22377
|
|
22378
|
+
const DATASET_SIZE_MULTIPLIER = 15;
|
22379
|
+
function useTableDataLoader2(fetchPage, fetchAll, options = {
|
22380
|
+
pageSize: DEFAULT_PAGE_SIZE
|
22381
|
+
}) {
|
22382
|
+
const loadPage = function (pageIndex, sorting, filters, hiddenColumns, search, reset = false) {
|
22383
|
+
try {
|
22384
|
+
// if a request is already pending for this page (and it's not a reset), skip it
|
22385
|
+
if (_pendingPageRequests.current[pageIndex] && !reset) {
|
22386
|
+
return Promise.resolve();
|
22387
|
+
}
|
22388
|
+
const hasChangedData = JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current) || search !== _lastUsedSearch.current;
|
22389
|
+
// if the page is already loaded and has actual rows, abort
|
22390
|
+
if (data.cache[pageIndex] && data.cache[pageIndex][0] && !hasChangedData && !reset) {
|
22391
|
+
return Promise.resolve();
|
22392
|
+
}
|
22393
|
+
// create an id to track the update
|
22394
|
+
const requestId = uuid.v4();
|
22395
|
+
// set the page as loading, so that subsequent requests don't retrigger it
|
22396
|
+
_pendingPageRequests.current[pageIndex] = true;
|
22397
|
+
const _temp2 = _catch(function () {
|
22398
|
+
_lastRequestId.current = requestId;
|
22399
|
+
return Promise.resolve(fetchPage(pageIndex, pageSize, sorting, filters, hiddenColumns, search)).then(function (response) {
|
22400
|
+
length.current = response.length;
|
22401
|
+
// update state, here we do some "magic" to support "load in place"
|
22402
|
+
setData(currentData => {
|
22403
|
+
// if this request wasn't the last one, just return the current state to prevent weird updates
|
22404
|
+
if (_lastRequestId.current !== requestId) {
|
22405
|
+
return currentData;
|
22406
|
+
}
|
22407
|
+
const direction = getDirection(pageIndex, currentData.pages);
|
22408
|
+
const nextPages = getPages(pageIndex, currentData.lastFetchedPage, reset ? [] : currentData.pages, direction);
|
22409
|
+
// set values so we can track if they changed between loads
|
22410
|
+
_lastUsedSorting.current = sorting;
|
22411
|
+
_lastUsedFilters.current = filters;
|
22412
|
+
_lastUsedSearch.current = search;
|
22413
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
22414
|
+
// cache data as an object to prevent any duplicates for pages
|
22415
|
+
let nextCache;
|
22416
|
+
if (reset || hasChangedData || !direction) {
|
22417
|
+
nextCache = nextPages.reduce((acc, p) => ({
|
22418
|
+
...acc,
|
22419
|
+
[p]: Array(pageSize).fill(undefined)
|
22420
|
+
}), {});
|
22421
|
+
} else {
|
22422
|
+
nextCache = {
|
22423
|
+
...currentData.cache
|
22424
|
+
};
|
22425
|
+
}
|
22426
|
+
nextCache[pageIndex] = response.data;
|
22427
|
+
// cleanup "unloaded" pages
|
22428
|
+
if (direction === 'forward' && currentData.rows.length >= DATASET_SIZE) {
|
22429
|
+
delete nextCache[currentData.pages[0]];
|
22430
|
+
} else if (direction === 'backward' && currentData.rows.length >= DATASET_SIZE) {
|
22431
|
+
delete nextCache[currentData.pages[currentData.pages.length - 1]];
|
22432
|
+
}
|
22433
|
+
// remap rows from the cached data - do it here and not in render to save some performance
|
22434
|
+
const rows = Object.values(nextCache).reduce((acc, p) => acc.concat(p), []);
|
22435
|
+
return {
|
22436
|
+
cache: nextCache,
|
22437
|
+
pages: nextPages,
|
22438
|
+
rows: rows,
|
22439
|
+
lastFetchedPage: pageIndex
|
22440
|
+
};
|
22441
|
+
});
|
22442
|
+
// reset pending requests
|
22443
|
+
delete _pendingPageRequests.current[pageIndex];
|
22444
|
+
});
|
22445
|
+
}, function () {});
|
22446
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
22447
|
+
} catch (e) {
|
22448
|
+
return Promise.reject(e);
|
22449
|
+
}
|
22450
|
+
};
|
22451
|
+
const {
|
22452
|
+
pageSize
|
22453
|
+
} = options;
|
22454
|
+
const DATASET_SIZE = DATASET_SIZE_MULTIPLIER * pageSize;
|
22455
|
+
// track the data length, we don't know it until the first request
|
22456
|
+
const length = React__default.useRef(0);
|
22457
|
+
// data will be filled after the first request
|
22458
|
+
const [data, setData] = React__default.useState({
|
22459
|
+
rows: [],
|
22460
|
+
pages: [],
|
22461
|
+
cache: {},
|
22462
|
+
lastFetchedPage: undefined
|
22463
|
+
});
|
22464
|
+
// track which pages have been loaded to dedupe requests
|
22465
|
+
const _pendingPageRequests = React__default.useRef({});
|
22466
|
+
// it's possible to spam updates, e.g. sort, so we don't set state if the last request wasn't the current oen
|
22467
|
+
const _lastRequestId = React__default.useRef();
|
22468
|
+
// store last used properties
|
22469
|
+
const _lastUsedSorting = React__default.useRef([]);
|
22470
|
+
const _lastUsedFilters = React__default.useRef([]);
|
22471
|
+
const _lastUsedSearch = React__default.useRef();
|
22472
|
+
const _lastUsedHiddenColumns = React__default.useRef([]);
|
22473
|
+
const loadAll = function (sorting, filters, hiddenColumns, search) {
|
22474
|
+
try {
|
22475
|
+
// set values so we can track if they changed between loads
|
22476
|
+
_lastUsedSorting.current = sorting;
|
22477
|
+
_lastUsedFilters.current = filters;
|
22478
|
+
_lastUsedSearch.current = search;
|
22479
|
+
_lastUsedHiddenColumns.current = hiddenColumns;
|
22480
|
+
const _temp = _finallyRethrows(function () {
|
22481
|
+
return _catch(function () {
|
22482
|
+
return Promise.resolve(fetchAll(sorting, filters, hiddenColumns, search)).then(function (response) {
|
22483
|
+
length.current = response.length;
|
22484
|
+
const pages = [];
|
22485
|
+
const cache = {};
|
22486
|
+
Array.from(Array(response.length / pageSize).keys()).forEach(index => {
|
22487
|
+
pages.push(index);
|
22488
|
+
const startIndex = index * pageSize;
|
22489
|
+
cache[index] = response.data.slice(startIndex, startIndex + pageSize);
|
22490
|
+
});
|
22491
|
+
setData({
|
22492
|
+
cache,
|
22493
|
+
pages,
|
22494
|
+
rows: response.data,
|
22495
|
+
lastFetchedPage: undefined
|
22496
|
+
});
|
22497
|
+
});
|
22498
|
+
}, function () {});
|
22499
|
+
}, function (_wasThrown, _result) {
|
22500
|
+
// reset pending requests
|
22501
|
+
_pendingPageRequests.current = {};
|
22502
|
+
if (_wasThrown) throw _result;
|
22503
|
+
return _result;
|
22504
|
+
});
|
22505
|
+
return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
|
22506
|
+
} catch (e) {
|
22507
|
+
return Promise.reject(e);
|
22508
|
+
}
|
22509
|
+
};
|
22510
|
+
const invalidate = function () {
|
22511
|
+
try {
|
22512
|
+
// reset stuff
|
22513
|
+
_pendingPageRequests.current = {};
|
22514
|
+
// load the current page again
|
22515
|
+
return loadPage(getCurrentPage(data.pages), _lastUsedSorting.current, _lastUsedFilters.current, _lastUsedHiddenColumns.current, _lastUsedSearch.current, true);
|
22516
|
+
} catch (e) {
|
22517
|
+
return Promise.reject(e);
|
22518
|
+
}
|
22519
|
+
};
|
22520
|
+
const handleSort = function (sorting) {
|
22521
|
+
try {
|
22522
|
+
// reset before loading the current page
|
22523
|
+
_pendingPageRequests.current = {};
|
22524
|
+
return loadPage(getCurrentPage(data.pages), sorting, _lastUsedFilters.current, _lastUsedHiddenColumns.current, _lastUsedSearch.current, true);
|
22525
|
+
} catch (e) {
|
22526
|
+
return Promise.reject(e);
|
22527
|
+
}
|
22528
|
+
};
|
22529
|
+
const handleFilter = function (filters, hiddenColumns) {
|
22530
|
+
try {
|
22531
|
+
// reset before loading the current page
|
22532
|
+
_pendingPageRequests.current = {};
|
22533
|
+
return loadPage(0, _lastUsedSorting.current, filters, hiddenColumns, _lastUsedSearch.current, true);
|
22534
|
+
} catch (e) {
|
22535
|
+
return Promise.reject(e);
|
22536
|
+
}
|
22537
|
+
};
|
22538
|
+
const handleSearch = function (search, hiddenColumns) {
|
22539
|
+
try {
|
22540
|
+
// reset before loading the current page
|
22541
|
+
_pendingPageRequests.current = {};
|
22542
|
+
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, hiddenColumns, search, true);
|
22543
|
+
} catch (e) {
|
22544
|
+
return Promise.reject(e);
|
22545
|
+
}
|
22546
|
+
};
|
22547
|
+
return [{
|
22548
|
+
data: data.rows,
|
22549
|
+
pages: data.pages,
|
22550
|
+
length: length.current,
|
22551
|
+
loadAll,
|
22552
|
+
loadPage,
|
22553
|
+
onChangeFilter: handleFilter,
|
22554
|
+
onChangeSearch: handleSearch,
|
22555
|
+
onChangeSort: handleSort,
|
22556
|
+
pageSize,
|
22557
|
+
_experimentalDataLoader2: true
|
22558
|
+
}, invalidate];
|
22559
|
+
}
|
22560
|
+
function getCurrentPage(currentPages) {
|
22561
|
+
if (currentPages.length <= 2) {
|
22562
|
+
return currentPages[0];
|
22563
|
+
}
|
22564
|
+
// for even page lengths we can't know which is the current visible page - it could even be both
|
22565
|
+
// so we load one of them and rely on the "load next/previous page" functionality in row
|
22566
|
+
const middle = Math.floor(currentPages.length / 2);
|
22567
|
+
return currentPages[middle];
|
22568
|
+
}
|
22569
|
+
function getDirection(pageIndex, currentPages) {
|
22570
|
+
if (currentPages.length) {
|
22571
|
+
if (pageIndex === currentPages[currentPages.length - 1] + 1) {
|
22572
|
+
return 'forward';
|
22573
|
+
} else if (pageIndex === currentPages[0] - 1 || currentPages.length === 2 && currentPages[0] !== 0 && pageIndex === currentPages[0]) {
|
22574
|
+
return 'backward';
|
22575
|
+
}
|
22576
|
+
}
|
22577
|
+
return undefined;
|
22578
|
+
}
|
22579
|
+
function getPages(pageIndex, lastUsedPageIndex, currentPages, direction) {
|
22580
|
+
if (currentPages.length && (pageIndex === lastUsedPageIndex || currentPages.includes(pageIndex))) {
|
22581
|
+
return currentPages;
|
22582
|
+
}
|
22583
|
+
if (direction === 'forward') {
|
22584
|
+
const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(1) : currentPages;
|
22585
|
+
return nextPages.concat(pageIndex);
|
22586
|
+
}
|
22587
|
+
if (direction === 'backward') {
|
22588
|
+
const nextPages = currentPages.length === DATASET_SIZE_MULTIPLIER ? currentPages.slice(0, -1) : currentPages;
|
22589
|
+
return [pageIndex].concat(nextPages);
|
22590
|
+
}
|
22591
|
+
return [pageIndex];
|
22592
|
+
}
|
22593
|
+
|
22232
22594
|
const useBoundaryOverflowDetection = (ref, dependencies = []) => {
|
22233
22595
|
const [boundaryIndex, setBoundaryIndex] = React__default.useState();
|
22234
22596
|
const dimensions = useBoundingClientRectListener(ref, dependencies);
|
@@ -22368,6 +22730,7 @@ exports.useOnClickOutside = useOnClickOutside;
|
|
22368
22730
|
exports.usePagination = usePagination;
|
22369
22731
|
exports.useRadioGroup = useRadioGroup;
|
22370
22732
|
exports.useTableDataLoader = useTableDataLoader;
|
22733
|
+
exports.useTableDataLoader2 = useTableDataLoader2;
|
22371
22734
|
exports.useTableRowCreation = useTableRowCreation;
|
22372
22735
|
exports.useToast = useToast;
|
22373
22736
|
//# sourceMappingURL=taco.cjs.development.js.map
|