@economic/taco 2.45.0-alpha.18 → 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 +7 -34
- package/dist/components/SearchInput2/SearchInput2.d.ts +2 -0
- package/dist/components/Table3/Table3.d.ts +10 -34
- 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 +2 -3
- 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 +1 -4
- 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 +626 -271
- 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);
|
@@ -17125,9 +17253,8 @@ function TableGrid(props) {
|
|
17125
17253
|
}, footerRows) : null)))));
|
17126
17254
|
}
|
17127
17255
|
|
17128
|
-
|
17129
|
-
|
17130
|
-
}
|
17256
|
+
const Column$1 = () => null;
|
17257
|
+
Column$1.displayName = 'Table3Column';
|
17131
17258
|
function Group$4(_) {
|
17132
17259
|
return null;
|
17133
17260
|
}
|
@@ -18770,18 +18897,21 @@ function useTableEditingListener(table, tableRef, scrollToIndex) {
|
|
18770
18897
|
document.addEventListener('click', onClickOutside);
|
18771
18898
|
return () => document.removeEventListener('click', onClickOutside);
|
18772
18899
|
}, [tableMeta.editing.isEditing, tableMeta.editing.saveChanges]);
|
18773
|
-
|
18774
|
-
|
18775
|
-
|
18776
|
-
|
18777
|
-
|
18778
|
-
|
18779
|
-
|
18780
|
-
|
18781
|
-
|
18782
|
-
|
18783
|
-
|
18784
|
-
|
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
|
+
*/
|
18785
18915
|
// shortcuts
|
18786
18916
|
useGlobalKeyDown(tableMeta.editing.isEnabled ? shortcut : undefined, event => {
|
18787
18917
|
event.preventDefault();
|
@@ -18809,6 +18939,7 @@ function reducer$2(state, action) {
|
|
18809
18939
|
{
|
18810
18940
|
const {
|
18811
18941
|
columnId,
|
18942
|
+
index,
|
18812
18943
|
row,
|
18813
18944
|
value
|
18814
18945
|
} = payload;
|
@@ -18818,7 +18949,8 @@ function reducer$2(state, action) {
|
|
18818
18949
|
...state.changes,
|
18819
18950
|
rows: setWith(state.changes.rows, `${rowId}.${columnId}`, value, Object),
|
18820
18951
|
originals: setWith(state.changes.originals, rowId, row, Object)
|
18821
|
-
}
|
18952
|
+
},
|
18953
|
+
indexes: setWith(state.indexes, rowId, index, Object)
|
18822
18954
|
};
|
18823
18955
|
}
|
18824
18956
|
case 'removeCellValue':
|
@@ -18852,6 +18984,7 @@ function reducer$2(state, action) {
|
|
18852
18984
|
{
|
18853
18985
|
const {
|
18854
18986
|
cellErrors,
|
18987
|
+
index,
|
18855
18988
|
moveReasons,
|
18856
18989
|
original,
|
18857
18990
|
value
|
@@ -18861,12 +18994,13 @@ function reducer$2(state, action) {
|
|
18861
18994
|
changes: {
|
18862
18995
|
...state.changes,
|
18863
18996
|
rows: setWith(state.changes.rows, rowId, value, Object),
|
18864
|
-
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),
|
18865
18998
|
originals: setWith(state.changes.originals, rowId, original !== null && original !== void 0 ? original : state.changes.originals[rowId], Object),
|
18866
18999
|
moveReasons: setWith(state.changes.moveReasons, rowId, moveReasons !== null && moveReasons !== void 0 ? moveReasons : state.changes.moveReasons[rowId], Object),
|
18867
19000
|
// status can be undefined, so don't use ??
|
18868
19001
|
status: setWith(state.changes.status, rowId, undefined, Object)
|
18869
|
-
}
|
19002
|
+
},
|
19003
|
+
indexes: setWith(state.indexes, rowId, index, Object)
|
18870
19004
|
};
|
18871
19005
|
}
|
18872
19006
|
case 'removeRow':
|
@@ -18884,6 +19018,7 @@ function reducer$2(state, action) {
|
|
18884
19018
|
originals: omit(state.changes.originals, rowId),
|
18885
19019
|
status: omit(state.changes.status, rowId)
|
18886
19020
|
},
|
19021
|
+
indexes: omit(state.indexes, rowId),
|
18887
19022
|
temporaryRows: state.temporaryRows.filter(row => row[rowIdentityAccessor] !== rowId)
|
18888
19023
|
};
|
18889
19024
|
}
|
@@ -18916,6 +19051,7 @@ function reducer$2(state, action) {
|
|
18916
19051
|
case 'insertTemporaryRow':
|
18917
19052
|
{
|
18918
19053
|
const {
|
19054
|
+
index,
|
18919
19055
|
value
|
18920
19056
|
} = payload;
|
18921
19057
|
return {
|
@@ -18925,14 +19061,36 @@ function reducer$2(state, action) {
|
|
18925
19061
|
...state.changes,
|
18926
19062
|
rows: setWith(state.changes.rows, rowId, value, Object),
|
18927
19063
|
originals: setWith(state.changes.originals, rowId, value, Object)
|
18928
|
-
}
|
19064
|
+
},
|
19065
|
+
indexes: setWith(state.indexes, rowId, index, Object)
|
18929
19066
|
};
|
18930
19067
|
}
|
18931
19068
|
default:
|
18932
19069
|
return state;
|
18933
19070
|
}
|
18934
19071
|
}
|
18935
|
-
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
|
+
};
|
18936
19094
|
const saveChanges = function (table, rowId = undefined) {
|
18937
19095
|
try {
|
18938
19096
|
let _exit = false;
|
@@ -18945,19 +19103,20 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18945
19103
|
[rowId]: state.changes.rows[rowId]
|
18946
19104
|
} : state.changes.rows;
|
18947
19105
|
let completed = true;
|
18948
|
-
const
|
19106
|
+
const _temp7 = _forOf(Object.keys(changes), function (rowId) {
|
18949
19107
|
const status = getRowStatus(rowId);
|
18950
19108
|
return _catch(function () {
|
18951
19109
|
var _changes$rowId;
|
18952
|
-
function
|
19110
|
+
function _temp6(_result) {
|
18953
19111
|
return _exit ? _result : Promise.resolve(handleSave(changeSet)).then(function () {
|
18954
19112
|
// cleanup changes, we don't need them after saving
|
18955
|
-
discardChanges(rowId, table)
|
18956
|
-
|
18957
|
-
|
18958
|
-
|
18959
|
-
|
18960
|
-
|
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
|
+
});
|
18961
19120
|
});
|
18962
19121
|
}
|
18963
19122
|
const rowChanges = (_changes$rowId = changes[rowId]) !== null && _changes$rowId !== void 0 ? _changes$rowId : {};
|
@@ -18975,7 +19134,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18975
19134
|
delete changeSet[rowIdentityAccessor];
|
18976
19135
|
}
|
18977
19136
|
// re-run validation, maybe a cell is already invalid but has never been blurred
|
18978
|
-
const
|
19137
|
+
const _temp5 = function () {
|
18979
19138
|
if (validator) {
|
18980
19139
|
return Promise.resolve(validator(changeSet)).then(function (errors) {
|
18981
19140
|
if (errors && Object.keys(errors).length) {
|
@@ -18984,7 +19143,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
18984
19143
|
});
|
18985
19144
|
}
|
18986
19145
|
}();
|
18987
|
-
return
|
19146
|
+
return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5); // send new data to the server
|
18988
19147
|
}, function (error) {
|
18989
19148
|
var _error$response;
|
18990
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) {
|
@@ -19024,18 +19183,18 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19024
19183
|
}, function () {
|
19025
19184
|
return _exit;
|
19026
19185
|
});
|
19027
|
-
return Promise.resolve(
|
19186
|
+
return Promise.resolve(_temp7 && _temp7.then ? _temp7.then(function (_result3) {
|
19028
19187
|
return _exit ? _result3 : completed;
|
19029
|
-
}) : _exit ?
|
19188
|
+
}) : _exit ? _temp7 : completed);
|
19030
19189
|
} catch (e) {
|
19031
19190
|
return Promise.reject(e);
|
19032
19191
|
}
|
19033
19192
|
};
|
19034
19193
|
const onCellChanged = function (cell, rowIndex, nextValue, shouldRunUpdaters = true) {
|
19035
19194
|
try {
|
19036
|
-
function
|
19195
|
+
function _temp4() {
|
19037
19196
|
var _state$changes$errors11;
|
19038
|
-
function
|
19197
|
+
function _temp2() {
|
19039
19198
|
// only set errors and move reasons for the cells we're currently acting on
|
19040
19199
|
// why? because the UX is not good if we set them for cells the user hasn't touched yet
|
19041
19200
|
const cellsToActOn = [cell.column.id, ...Object.keys(updatesForOtherCells)];
|
@@ -19066,6 +19225,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19066
19225
|
rowId: cell.row.id,
|
19067
19226
|
payload: {
|
19068
19227
|
cellErrors: nextCellErrors,
|
19228
|
+
index: rowIndex,
|
19069
19229
|
moveReasons: nextMoveReasons,
|
19070
19230
|
value: nextChanges
|
19071
19231
|
}
|
@@ -19084,7 +19244,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19084
19244
|
};
|
19085
19245
|
// run validation - if there are changes, and if there is an original stored
|
19086
19246
|
let validationErrors = {};
|
19087
|
-
const
|
19247
|
+
const _temp = function () {
|
19088
19248
|
if (validator && Object.keys(nextChanges).length && state.changes.originals[cell.row.id]) {
|
19089
19249
|
// merge with the original so we get a full row
|
19090
19250
|
const nextRowValue = {
|
@@ -19092,12 +19252,12 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19092
19252
|
...changes,
|
19093
19253
|
...updatesForOtherCells
|
19094
19254
|
};
|
19095
|
-
return Promise.resolve(validator(nextRowValue)).then(function (
|
19096
|
-
validationErrors =
|
19255
|
+
return Promise.resolve(validator(nextRowValue)).then(function (_validator) {
|
19256
|
+
validationErrors = _validator !== null && _validator !== void 0 ? _validator : {};
|
19097
19257
|
});
|
19098
19258
|
}
|
19099
19259
|
}();
|
19100
|
-
return
|
19260
|
+
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp);
|
19101
19261
|
}
|
19102
19262
|
const changes = nextValue !== undefined ? {
|
19103
19263
|
...state.changes.rows[cell.row.id],
|
@@ -19110,7 +19270,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19110
19270
|
}
|
19111
19271
|
let updatesForOtherCells = {};
|
19112
19272
|
// run the updater handler if there is one, to see if there are any other cells to update
|
19113
|
-
const
|
19273
|
+
const _temp3 = function () {
|
19114
19274
|
if (typeof handleChange === 'function' && shouldRunUpdaters) {
|
19115
19275
|
const previousRowValue = {
|
19116
19276
|
...state.changes.originals[cell.row.id]
|
@@ -19124,42 +19284,11 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19124
19284
|
});
|
19125
19285
|
}
|
19126
19286
|
}();
|
19127
|
-
return Promise.resolve(
|
19287
|
+
return Promise.resolve(_temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3));
|
19128
19288
|
} catch (e) {
|
19129
19289
|
return Promise.reject(e);
|
19130
19290
|
}
|
19131
19291
|
}; // general
|
19132
|
-
// rows
|
19133
|
-
const setRowValue = function (rowId, original, value) {
|
19134
|
-
try {
|
19135
|
-
function _temp2() {
|
19136
|
-
dispatch({
|
19137
|
-
type: 'updateRow',
|
19138
|
-
rowId,
|
19139
|
-
payload: {
|
19140
|
-
cellErrors,
|
19141
|
-
original,
|
19142
|
-
value
|
19143
|
-
}
|
19144
|
-
});
|
19145
|
-
}
|
19146
|
-
let cellErrors;
|
19147
|
-
const _temp = function () {
|
19148
|
-
if (validator) {
|
19149
|
-
const row = {
|
19150
|
-
...original,
|
19151
|
-
...value
|
19152
|
-
};
|
19153
|
-
return Promise.resolve(validator(row)).then(function (_validator) {
|
19154
|
-
cellErrors = _validator !== null && _validator !== void 0 ? _validator : {};
|
19155
|
-
});
|
19156
|
-
}
|
19157
|
-
}();
|
19158
|
-
return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
|
19159
|
-
} catch (e) {
|
19160
|
-
return Promise.reject(e);
|
19161
|
-
}
|
19162
|
-
};
|
19163
19292
|
const localization = useLocalization();
|
19164
19293
|
const [state, dispatch] = React__default.useReducer(reducer$2, {
|
19165
19294
|
changes: {
|
@@ -19169,8 +19298,10 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19169
19298
|
originals: {},
|
19170
19299
|
status: {}
|
19171
19300
|
},
|
19301
|
+
indexes: {},
|
19172
19302
|
temporaryRows: []
|
19173
19303
|
});
|
19304
|
+
// rows
|
19174
19305
|
function getRowValue(rowId) {
|
19175
19306
|
var _state$changes$rows$r, _state$changes$rows;
|
19176
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;
|
@@ -19208,7 +19339,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19208
19339
|
}
|
19209
19340
|
});
|
19210
19341
|
}
|
19211
|
-
function insertTemporaryRow(data) {
|
19342
|
+
function insertTemporaryRow(data, rowIndex) {
|
19212
19343
|
const newRowId = `${TEMPORARY_ROW_ID_PREFIX}${uuid.v4()}`;
|
19213
19344
|
const value = {
|
19214
19345
|
...data,
|
@@ -19218,13 +19349,14 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19218
19349
|
type: 'insertTemporaryRow',
|
19219
19350
|
rowId: newRowId,
|
19220
19351
|
payload: {
|
19352
|
+
index: rowIndex,
|
19221
19353
|
value
|
19222
19354
|
}
|
19223
19355
|
});
|
19224
19356
|
return newRowId;
|
19225
19357
|
}
|
19226
19358
|
// cells
|
19227
|
-
function setCellValue(cell, value) {
|
19359
|
+
function setCellValue(cell, rowIndex, value) {
|
19228
19360
|
const rowId = cell.row.id;
|
19229
19361
|
const columnId = cell.column.id;
|
19230
19362
|
// update if the change is different to the original value
|
@@ -19234,6 +19366,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19234
19366
|
rowId,
|
19235
19367
|
payload: {
|
19236
19368
|
columnId,
|
19369
|
+
index: rowIndex,
|
19237
19370
|
row: cell.row.original,
|
19238
19371
|
value
|
19239
19372
|
}
|
@@ -19266,6 +19399,7 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19266
19399
|
}
|
19267
19400
|
return rowsWithErrors.filter(hasRowErrorsShownInAlert).map(rowId => ({
|
19268
19401
|
rowId,
|
19402
|
+
index: state.indexes[rowId],
|
19269
19403
|
changes: state.changes.rows[rowId],
|
19270
19404
|
errors: state.changes.errors[rowId]
|
19271
19405
|
}));
|
@@ -19276,20 +19410,8 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19276
19410
|
function hasChanges(rowId) {
|
19277
19411
|
return rowId ? !!state.changes.rows[rowId] : !!Object.keys(state.changes.rows).length;
|
19278
19412
|
}
|
19279
|
-
function discardChanges(rowId, table) {
|
19280
|
-
// remove any new rows from pinned state before discarding them
|
19281
|
-
table.resetRowPinning(true);
|
19282
|
-
dispatch({
|
19283
|
-
type: 'removeRow',
|
19284
|
-
rowId,
|
19285
|
-
payload: {
|
19286
|
-
rowIdentityAccessor
|
19287
|
-
}
|
19288
|
-
});
|
19289
|
-
}
|
19290
19413
|
return {
|
19291
19414
|
// row
|
19292
|
-
setRowValue,
|
19293
19415
|
getRowValue,
|
19294
19416
|
getRowMoveReason,
|
19295
19417
|
hasRowErrors,
|
@@ -19314,8 +19436,8 @@ function usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, v
|
|
19314
19436
|
};
|
19315
19437
|
}
|
19316
19438
|
|
19317
|
-
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, rowIdentityAccessor, validator) {
|
19318
|
-
const createRow = function (table,
|
19439
|
+
function useTableEditing(isEnabled = false, handleSave, handleChange, handleCreate, handleDiscard, rowIdentityAccessor, validator) {
|
19440
|
+
const createRow = function (table, row) {
|
19319
19441
|
try {
|
19320
19442
|
let _exit = false;
|
19321
19443
|
function _temp2(_result) {
|
@@ -19323,23 +19445,28 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19323
19445
|
const changeset = row !== null && row !== void 0 ? row : handleCreate();
|
19324
19446
|
try {
|
19325
19447
|
if (changeset) {
|
19326
|
-
const newRowId = pendingChangesFns.insertTemporaryRow(changeset);
|
19327
|
-
// reset before changing row otherwise the cell changes and validation might run
|
19328
|
-
setLastFocusedCellIndex(undefined);
|
19329
19448
|
// set the active row to the new row before toggling editing on
|
19330
19449
|
const temporaryRows = tableMeta.editing.temporaryRows;
|
19331
19450
|
const nextRowIndex = temporaryRows.length ? tableMeta.length + 1 : tableMeta.length;
|
19332
|
-
|
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);
|
19333
19463
|
// wait until set states have run
|
19334
19464
|
requestAnimationFrame(() => {
|
19335
|
-
|
19336
|
-
table.
|
19337
|
-
|
19338
|
-
|
19339
|
-
|
19340
|
-
bottom: (_ref = (_currentState$bottom = currentState.bottom) !== null && _currentState$bottom !== void 0 ? _currentState$bottom : []) === null || _ref === void 0 ? void 0 : _ref.concat(newRowId)
|
19341
|
-
};
|
19342
|
-
});
|
19465
|
+
tableMeta.rowActive.setRowActiveIndex(nextRowIndex);
|
19466
|
+
table.resetRowSelection();
|
19467
|
+
if (!tableMeta.editing.isEditing) {
|
19468
|
+
setEditing(true);
|
19469
|
+
}
|
19343
19470
|
});
|
19344
19471
|
}
|
19345
19472
|
} catch (error) {
|
@@ -19352,8 +19479,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19352
19479
|
const tableMeta = table.options.meta;
|
19353
19480
|
const _temp = function () {
|
19354
19481
|
if (tableMeta.rowActive.rowActiveIndex !== undefined) {
|
19355
|
-
|
19356
|
-
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) {
|
19357
19483
|
if (!saved) {
|
19358
19484
|
_exit = true;
|
19359
19485
|
}
|
@@ -19373,13 +19499,14 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19373
19499
|
const createRowButtonRef = React__default.useRef(null);
|
19374
19500
|
// store the last focused cell, so that up/down arrow key navigation remains in the same column
|
19375
19501
|
const [lastFocusedCellIndex, setLastFocusedCellIndex] = React__default.useState(undefined);
|
19376
|
-
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, rowIdentityAccessor, validator);
|
19377
|
-
function toggleEditing(enabled, table, scrollToIndex
|
19502
|
+
const pendingChangesFns = usePendingChangesState(handleSave, handleChange, handleDiscard, rowIdentityAccessor, validator);
|
19503
|
+
function toggleEditing(enabled, table, scrollToIndex) {
|
19378
19504
|
const tableMeta = table.options.meta;
|
19379
19505
|
if (enabled) {
|
19380
19506
|
var _tableMeta$rowActive$, _table$getRowModel$ro;
|
19381
19507
|
const index = (_tableMeta$rowActive$ = tableMeta.rowActive.rowActiveIndex) !== null && _tableMeta$rowActive$ !== void 0 ? _tableMeta$rowActive$ : 0;
|
19382
19508
|
if (tableMeta.rowActive.rowActiveIndex === undefined) {
|
19509
|
+
console.log('edit toggle active', index);
|
19383
19510
|
tableMeta.rowActive.setRowActiveIndex(index);
|
19384
19511
|
}
|
19385
19512
|
if (!isTemporaryRow((_table$getRowModel$ro = table.getRowModel().rows[index]) === null || _table$getRowModel$ro === void 0 ? void 0 : _table$getRowModel$ro.id)) {
|
@@ -19392,9 +19519,7 @@ function useTableEditing(isEnabled = false, handleSave, handleChange, handleCrea
|
|
19392
19519
|
setLastFocusedCellIndex(undefined);
|
19393
19520
|
}
|
19394
19521
|
setEditing(enabled);
|
19395
|
-
|
19396
|
-
pendingChangesFns.saveChanges(table);
|
19397
|
-
}
|
19522
|
+
pendingChangesFns.saveChanges(table);
|
19398
19523
|
}
|
19399
19524
|
return {
|
19400
19525
|
isEnabled,
|
@@ -19663,7 +19788,7 @@ function EditingControlCell(props) {
|
|
19663
19788
|
}, [cellRef.current]);
|
19664
19789
|
const handleChange = React__default.useCallback(nextValue => {
|
19665
19790
|
if (nextValue !== value) {
|
19666
|
-
tableMeta.editing.setCellValue(cell, nextValue);
|
19791
|
+
tableMeta.editing.setCellValue(cell, rowIndex, nextValue);
|
19667
19792
|
if (hasNonTextControl) {
|
19668
19793
|
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
19669
19794
|
}
|
@@ -19832,11 +19957,21 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
|
|
19832
19957
|
props.onChange(newDate);
|
19833
19958
|
}
|
19834
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
|
+
};
|
19835
19970
|
return /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, commonProps, {
|
19836
19971
|
invalid: invalid,
|
19837
19972
|
onChange: handleChange,
|
19838
19973
|
onFocus: handleFocus,
|
19839
|
-
onKeyDown:
|
19974
|
+
onKeyDown: handleDatepickerInputKeyDown,
|
19840
19975
|
ref: controlRef,
|
19841
19976
|
value: valueAsDate
|
19842
19977
|
}));
|
@@ -20088,7 +20223,7 @@ const RENDERERS$1 = {
|
|
20088
20223
|
cell: Cell$5
|
20089
20224
|
};
|
20090
20225
|
function useTable3(props, ref) {
|
20091
|
-
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);
|
20092
20227
|
const creationEnabled = editing.isEnabled && !!props.onEditingCreate;
|
20093
20228
|
// this gives me the performance heeby jeebies, but can't think of a better way to internalise the state
|
20094
20229
|
const data = React__default.useMemo(() => {
|
@@ -20141,7 +20276,7 @@ function useTable3(props, ref) {
|
|
20141
20276
|
if (table.ref.current) {
|
20142
20277
|
table.ref.current.instance.toggleEditing = enabled => table.meta.editing.toggleEditing(enabled !== null && enabled !== void 0 ? enabled : editing => !editing, table.instance, table.renderer.scrollToIndex);
|
20143
20278
|
if (props.onEditingCreate) {
|
20144
|
-
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);
|
20145
20280
|
}
|
20146
20281
|
}
|
20147
20282
|
}, [table.ref.current]);
|
@@ -20185,20 +20320,22 @@ function Alert$1(props) {
|
|
20185
20320
|
// table.getColumn(columName) throw error in strict dev mode. Related thread: https://github.com/TanStack/table/discussions/5505
|
20186
20321
|
table.getAllColumns().find(x => x.id === String(tableMeta.rowIdentityAccessor)) : undefined;
|
20187
20322
|
pendingChangesWithErrors.forEach((pendingChangeWithError, index) => {
|
20323
|
+
var _row;
|
20188
20324
|
// if appropriate, concatenate the item with the text "and"
|
20189
20325
|
if (pendingChangesWithErrors.length > 1 && index === pendingChangesWithErrors.length - 1) {
|
20190
20326
|
// Add space before and after `messageAnd` text
|
20191
20327
|
links.push(` ${validationTexts.alert.messageAnd} `);
|
20192
20328
|
}
|
20193
|
-
|
20329
|
+
// note: if this row click functionality is removed, indexes can be removed from useEditingState
|
20194
20330
|
const handleClick = () => {
|
20195
20331
|
// if row is visible
|
20196
|
-
if (
|
20197
|
-
scrollToRow(
|
20332
|
+
if (pendingChangeWithError.index > -1) {
|
20333
|
+
scrollToRow(pendingChangeWithError.index);
|
20334
|
+
tableMeta.rowActive.setRowActiveIndex(pendingChangeWithError.index);
|
20198
20335
|
}
|
20199
20336
|
// if row is filtered out
|
20200
20337
|
else {
|
20201
|
-
setShowFilterResetDialog(pendingChangeWithError.
|
20338
|
+
setShowFilterResetDialog(pendingChangeWithError.index);
|
20202
20339
|
}
|
20203
20340
|
};
|
20204
20341
|
let tooltip;
|
@@ -20210,7 +20347,12 @@ function Alert$1(props) {
|
|
20210
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;
|
20211
20348
|
tooltip = `${columnName}: ${pendingChangeWithError.errors.cells[firstCellErrorColumnId]}`;
|
20212
20349
|
}
|
20213
|
-
|
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
|
+
}
|
20214
20356
|
links.push(/*#__PURE__*/React__default.createElement(Tooltip, {
|
20215
20357
|
key: pendingChangeWithError.rowId,
|
20216
20358
|
title: tooltip
|
@@ -20218,7 +20360,7 @@ function Alert$1(props) {
|
|
20218
20360
|
className: "text-blue",
|
20219
20361
|
onClick: handleClick,
|
20220
20362
|
role: "button"
|
20221
|
-
}, rowIdentityColumn ? row[rowIdentityColumn.id] :
|
20363
|
+
}, rowIdentityColumn ? (_row = row) === null || _row === void 0 ? void 0 : _row[rowIdentityColumn.id] : pendingChangeWithError.index + 1)));
|
20222
20364
|
// if appropriate, concatenate the item with the text ","
|
20223
20365
|
if (pendingChangesWithErrors.length > 2 && index < pendingChangesWithErrors.length - 2) {
|
20224
20366
|
links.push(', ');
|
@@ -20239,9 +20381,8 @@ function Alert$1(props) {
|
|
20239
20381
|
table.resetGlobalFilter();
|
20240
20382
|
table.resetColumnFilters();
|
20241
20383
|
requestAnimationFrame(() => {
|
20242
|
-
|
20243
|
-
|
20244
|
-
scrollToRow(rowIndex);
|
20384
|
+
if (showFilterResetDialog && showFilterResetDialog > -1) {
|
20385
|
+
scrollToRow(showFilterResetDialog);
|
20245
20386
|
}
|
20246
20387
|
setShowFilterResetDialog(false);
|
20247
20388
|
});
|
@@ -20306,7 +20447,6 @@ function CreateNewRow(props) {
|
|
20306
20447
|
const {
|
20307
20448
|
buttonRef,
|
20308
20449
|
isScrolled,
|
20309
|
-
scrollToIndex,
|
20310
20450
|
table,
|
20311
20451
|
tableMeta
|
20312
20452
|
} = props;
|
@@ -20322,7 +20462,7 @@ function CreateNewRow(props) {
|
|
20322
20462
|
if (isDisabled) {
|
20323
20463
|
return Promise.resolve();
|
20324
20464
|
}
|
20325
|
-
return Promise.resolve(tableMeta.editing.createRow(table
|
20465
|
+
return Promise.resolve(tableMeta.editing.createRow(table)).then(function () {});
|
20326
20466
|
} catch (e) {
|
20327
20467
|
return Promise.reject(e);
|
20328
20468
|
}
|
@@ -20341,7 +20481,7 @@ function CreateNewRow(props) {
|
|
20341
20481
|
keys: shortcut
|
20342
20482
|
});
|
20343
20483
|
}
|
20344
|
-
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', {
|
20345
20485
|
'bottom-10': tableMeta.footer.isEnabled,
|
20346
20486
|
'bottom-0': !tableMeta.footer.isEnabled,
|
20347
20487
|
'border-b': !isScrolled
|
@@ -20431,7 +20571,7 @@ function TemporaryRow(props) {
|
|
20431
20571
|
}
|
20432
20572
|
}
|
20433
20573
|
};
|
20434
|
-
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', {
|
20435
20575
|
'bottom-[calc(5rem_+_2px)] data-[row-editing-move]:bottom-[calc(5rem_+_2px)]': tableMeta.footer.isEnabled,
|
20436
20576
|
'bottom-[calc(2.5rem_+_2px)] data-[row-editing-move]:bottom-[calc(2.5rem_+_2px)]': !tableMeta.footer.isEnabled,
|
20437
20577
|
'border-t-2 shadow-[0px_-5px_20px_0px_rgba(0,0,0,0.1)] [&>td]:!border-b-0': isScrolled
|
@@ -20448,13 +20588,12 @@ function TemporaryRow(props) {
|
|
20448
20588
|
onKeyDown: handleKeyDown,
|
20449
20589
|
onKeyDownCapture: handleKeyDownCapture,
|
20450
20590
|
hideInternalColumns: true,
|
20451
|
-
hideRowActions: !tableMeta.editing.isEditing
|
20591
|
+
hideRowActions: !tableMeta.editing.isEditing,
|
20592
|
+
skipPageLoading: true
|
20452
20593
|
}))));
|
20453
20594
|
}
|
20454
20595
|
|
20455
|
-
|
20456
|
-
return null;
|
20457
|
-
}
|
20596
|
+
const Column$3 = () => null;
|
20458
20597
|
Column$3.displayName = 'Table3Column';
|
20459
20598
|
function Group$5(_) {
|
20460
20599
|
return null;
|
@@ -20475,7 +20614,6 @@ const BaseTable3 = /*#__PURE__*/fixedForwardRef(function BaseTable3(props, ref)
|
|
20475
20614
|
createWorkflow = /*#__PURE__*/React__default.createElement(CreateNewRow, {
|
20476
20615
|
buttonRef: table3.meta.editing.createRowButtonRef,
|
20477
20616
|
isScrolled: isScrolled,
|
20478
|
-
scrollToIndex: table3.renderer.scrollToIndex,
|
20479
20617
|
table: table3.instance,
|
20480
20618
|
tableMeta: table3.meta
|
20481
20619
|
});
|
@@ -22237,6 +22375,222 @@ Navigation2.Link = Link$3;
|
|
22237
22375
|
Navigation2.Section = Section;
|
22238
22376
|
Navigation2.Content = Content$a;
|
22239
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
|
+
|
22240
22594
|
const useBoundaryOverflowDetection = (ref, dependencies = []) => {
|
22241
22595
|
const [boundaryIndex, setBoundaryIndex] = React__default.useState();
|
22242
22596
|
const dimensions = useBoundingClientRectListener(ref, dependencies);
|
@@ -22376,6 +22730,7 @@ exports.useOnClickOutside = useOnClickOutside;
|
|
22376
22730
|
exports.usePagination = usePagination;
|
22377
22731
|
exports.useRadioGroup = useRadioGroup;
|
22378
22732
|
exports.useTableDataLoader = useTableDataLoader;
|
22733
|
+
exports.useTableDataLoader2 = useTableDataLoader2;
|
22379
22734
|
exports.useTableRowCreation = useTableRowCreation;
|
22380
22735
|
exports.useToast = useToast;
|
22381
22736
|
//# sourceMappingURL=taco.cjs.development.js.map
|