@infinite-table/infinite-react 3.0.3 → 3.0.5
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/index.d.ts +6 -2
- package/index.dev.js +119 -112
- package/index.dev.mjs +119 -112
- package/index.js +5 -5
- package/index.mjs +5 -5
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1376,7 +1376,7 @@ declare type CellPositionOptions = {
|
|
|
1376
1376
|
colId?: never;
|
|
1377
1377
|
};
|
|
1378
1378
|
|
|
1379
|
-
declare type InfiniteTableCellSelectionApi = {
|
|
1379
|
+
declare type InfiniteTableCellSelectionApi<T> = {
|
|
1380
1380
|
isCellSelected(cellPosition: CellPositionOptions): boolean;
|
|
1381
1381
|
selectCell(cellPosition: CellPositionOptions & {
|
|
1382
1382
|
clear?: boolean;
|
|
@@ -1395,6 +1395,10 @@ declare type InfiniteTableCellSelectionApi = {
|
|
|
1395
1395
|
columnIds: string[];
|
|
1396
1396
|
positions: (CellSelectionPosition | null)[][];
|
|
1397
1397
|
};
|
|
1398
|
+
getMappedCellSelectionPositions<SELECTED_VALUE, EMPTY_VALUE>(fn: (rowInfo: InfiniteTableRowInfo<T>, colId: string) => SELECTED_VALUE, emptyValue: EMPTY_VALUE): {
|
|
1399
|
+
columnIds: string[];
|
|
1400
|
+
positions: (SELECTED_VALUE | EMPTY_VALUE)[][];
|
|
1401
|
+
};
|
|
1398
1402
|
};
|
|
1399
1403
|
|
|
1400
1404
|
declare type ArrayOfIds = Pick<InfiniteTable_RowInfoBase<any>, 'id'>[];
|
|
@@ -2564,7 +2568,7 @@ declare type MultiSortBehaviorOptions = {
|
|
|
2564
2568
|
};
|
|
2565
2569
|
interface InfiniteTableApi<T> {
|
|
2566
2570
|
get rowSelectionApi(): InfiniteTableRowSelectionApi;
|
|
2567
|
-
get cellSelectionApi(): InfiniteTableCellSelectionApi
|
|
2571
|
+
get cellSelectionApi(): InfiniteTableCellSelectionApi<T>;
|
|
2568
2572
|
setColumnOrder: (columnOrder: InfiniteTablePropColumnOrder) => void;
|
|
2569
2573
|
setColumnVisibility: (columnVisibility: InfiniteTablePropColumnVisibility) => void;
|
|
2570
2574
|
isDestroyed: () => boolean;
|
package/index.dev.js
CHANGED
|
@@ -13112,7 +13112,7 @@ function concludeReducer(params) {
|
|
|
13112
13112
|
}
|
|
13113
13113
|
if (cache) {
|
|
13114
13114
|
cache.clear();
|
|
13115
|
-
state.cache =
|
|
13115
|
+
state.cache = void 0;
|
|
13116
13116
|
}
|
|
13117
13117
|
const { filterFunction, filterValue, filterTypes, operatorsByFilterType } = state;
|
|
13118
13118
|
const shouldFilter = !!filterFunction || Array.isArray(filterValue) && filterValue.length;
|
|
@@ -13365,7 +13365,7 @@ function concludeReducer(params) {
|
|
|
13365
13365
|
if (originalDataArrayChanged) {
|
|
13366
13366
|
state.originalDataArrayChangedInfo = {
|
|
13367
13367
|
timestamp: now,
|
|
13368
|
-
mutations
|
|
13368
|
+
mutations: (mutations == null ? void 0 : mutations.size) ? mutations : void 0
|
|
13369
13369
|
};
|
|
13370
13370
|
}
|
|
13371
13371
|
return state;
|
|
@@ -13975,7 +13975,7 @@ var Indexer = class {
|
|
|
13975
13975
|
};
|
|
13976
13976
|
this.indexArray = (arr, options) => {
|
|
13977
13977
|
const { cache, toPrimaryKey } = options;
|
|
13978
|
-
if (cache) {
|
|
13978
|
+
if (cache && !cache.isEmpty()) {
|
|
13979
13979
|
arr = arr.concat();
|
|
13980
13980
|
}
|
|
13981
13981
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -14448,7 +14448,7 @@ function DataSourceCmp({ children }) {
|
|
|
14448
14448
|
componentState.originalDataArray,
|
|
14449
14449
|
componentState.originalDataArrayChangedInfo
|
|
14450
14450
|
);
|
|
14451
|
-
if (componentState.onDataMutations && componentState.originalDataArrayChangedInfo.mutations) {
|
|
14451
|
+
if (componentState.onDataMutations && componentState.originalDataArrayChangedInfo.mutations && componentState.originalDataArrayChangedInfo.mutations.size) {
|
|
14452
14452
|
componentState.onDataMutations({
|
|
14453
14453
|
primaryKeyField: typeof componentState.primaryKey === "string" ? componentState.primaryKey : void 0,
|
|
14454
14454
|
dataArray: componentState.originalDataArray,
|
|
@@ -14538,31 +14538,67 @@ function ensureMinMaxCellPositionByIndex(start, end) {
|
|
|
14538
14538
|
{ rowIndex: rowEnd, colIndex: colEnd }
|
|
14539
14539
|
];
|
|
14540
14540
|
}
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
const
|
|
14558
|
-
const
|
|
14541
|
+
var InfiniteTableCellSelectionApiImpl = class {
|
|
14542
|
+
constructor(param) {
|
|
14543
|
+
this.getCellSelectionPosition = (options) => {
|
|
14544
|
+
var _a, _b, _c;
|
|
14545
|
+
const rowId = (_b = options.rowId) != null ? _b : (_a = getRowInfoAt(options.rowIndex, this.getDataSourceState)) == null ? void 0 : _a.id;
|
|
14546
|
+
const colId = (_c = options.colId) != null ? _c : this.getComputed().computedVisibleColumns[options.colIndex].id;
|
|
14547
|
+
return [rowId, colId];
|
|
14548
|
+
};
|
|
14549
|
+
this.setRangeSelected = (startOptions, endOptions, selected) => {
|
|
14550
|
+
const dataSourceState = this.getDataSourceState();
|
|
14551
|
+
const cellSelection = dataSourceState.cellSelection;
|
|
14552
|
+
if (!cellSelection) {
|
|
14553
|
+
return;
|
|
14554
|
+
}
|
|
14555
|
+
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14556
|
+
const [startRowId, startColId] = this.getCellSelectionPosition(startOptions);
|
|
14557
|
+
const [endRowId, endColId] = this.getCellSelectionPosition(endOptions);
|
|
14558
|
+
const startCol = this.getComputed().computedVisibleColumnsMap.get(startColId);
|
|
14559
|
+
const endCol = this.getComputed().computedVisibleColumnsMap.get(endColId);
|
|
14560
|
+
if (!startCol || !endCol) {
|
|
14561
|
+
return;
|
|
14562
|
+
}
|
|
14563
|
+
const startColIndex = startCol.computedVisibleIndex;
|
|
14564
|
+
const endColIndex = endCol.computedVisibleIndex;
|
|
14565
|
+
const startRowInfo = getRowInfoAt(startRowId, this.getDataSourceState);
|
|
14566
|
+
const endRowInfo = getRowInfoAt(endRowId, this.getDataSourceState);
|
|
14567
|
+
if (!startRowInfo || !endRowInfo) {
|
|
14568
|
+
return;
|
|
14569
|
+
}
|
|
14570
|
+
const startRowIndex = startRowInfo.indexInAll;
|
|
14571
|
+
const endRowIndex = endRowInfo.indexInAll;
|
|
14572
|
+
const [start, end] = ensureMinMaxCellPositionByIndex(
|
|
14573
|
+
{ rowIndex: startRowIndex, colIndex: startColIndex },
|
|
14574
|
+
{ rowIndex: endRowIndex, colIndex: endColIndex }
|
|
14575
|
+
);
|
|
14576
|
+
for (let i = start.rowIndex; i <= end.rowIndex; i++) {
|
|
14577
|
+
for (let j = start.colIndex; j <= end.colIndex; j++) {
|
|
14578
|
+
const pos = {
|
|
14579
|
+
rowIndex: i,
|
|
14580
|
+
colIndex: j
|
|
14581
|
+
};
|
|
14582
|
+
const [pk, colId] = this.getCellSelectionPosition(pos);
|
|
14583
|
+
if (selected) {
|
|
14584
|
+
newCellSelection.selectCell(pk, colId);
|
|
14585
|
+
} else {
|
|
14586
|
+
newCellSelection.deselectCell(pk, colId);
|
|
14587
|
+
}
|
|
14588
|
+
}
|
|
14589
|
+
}
|
|
14590
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14591
|
+
};
|
|
14592
|
+
this.getCellSelectionPositionsWithFn = (fn, emptyValue) => {
|
|
14593
|
+
const dataArray = getRowInfoArray(this.getDataSourceState);
|
|
14594
|
+
const { computedVisibleColumns } = this.getComputed();
|
|
14559
14595
|
const computedVisibleColumnsIds = computedVisibleColumns.map((x) => x.id);
|
|
14560
14596
|
const colsInSelection = /* @__PURE__ */ new Set();
|
|
14561
14597
|
const rowsInSelection = [];
|
|
14562
14598
|
const rowIdsInSelection = /* @__PURE__ */ new Set();
|
|
14563
14599
|
dataArray.filter((rowInfo) => {
|
|
14564
14600
|
computedVisibleColumns.forEach((col) => {
|
|
14565
|
-
if (
|
|
14601
|
+
if (this.isCellSelected({
|
|
14566
14602
|
rowId: rowInfo.id,
|
|
14567
14603
|
colId: col.id
|
|
14568
14604
|
})) {
|
|
@@ -14582,136 +14618,107 @@ function getCellSelectionApi(param) {
|
|
|
14582
14618
|
);
|
|
14583
14619
|
const positions = rowsInSelection.map((rowInfo) => {
|
|
14584
14620
|
return columnIds.map((colId) => {
|
|
14585
|
-
if (
|
|
14586
|
-
return
|
|
14621
|
+
if (this.isCellSelected({ rowId: rowInfo.id, colId })) {
|
|
14622
|
+
return fn(rowInfo, colId);
|
|
14587
14623
|
}
|
|
14588
|
-
return
|
|
14624
|
+
return emptyValue;
|
|
14589
14625
|
});
|
|
14590
14626
|
});
|
|
14591
14627
|
return {
|
|
14592
14628
|
columnIds,
|
|
14593
14629
|
positions
|
|
14594
14630
|
};
|
|
14595
|
-
}
|
|
14596
|
-
|
|
14597
|
-
|
|
14631
|
+
};
|
|
14632
|
+
this.getAllCellSelectionPositions = () => {
|
|
14633
|
+
return this.getCellSelectionPositionsWithFn((rowInfo, colId) => {
|
|
14634
|
+
return [rowInfo.id, colId];
|
|
14635
|
+
}, null);
|
|
14636
|
+
};
|
|
14637
|
+
this.getMappedCellSelectionPositions = (fn, emptyValue) => {
|
|
14638
|
+
return this.getCellSelectionPositionsWithFn(fn, emptyValue);
|
|
14639
|
+
};
|
|
14640
|
+
this.deselectAll = () => {
|
|
14641
|
+
const dataSourceState = this.getDataSourceState();
|
|
14598
14642
|
const cellSelection = dataSourceState.cellSelection;
|
|
14599
14643
|
if (!cellSelection) {
|
|
14600
14644
|
return;
|
|
14601
14645
|
}
|
|
14602
14646
|
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14603
14647
|
newCellSelection.deselectAll();
|
|
14604
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14605
|
-
}
|
|
14606
|
-
clear
|
|
14607
|
-
|
|
14608
|
-
}
|
|
14609
|
-
selectAll
|
|
14610
|
-
const dataSourceState = getDataSourceState();
|
|
14648
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14649
|
+
};
|
|
14650
|
+
this.clear = () => {
|
|
14651
|
+
this.deselectAll();
|
|
14652
|
+
};
|
|
14653
|
+
this.selectAll = () => {
|
|
14654
|
+
const dataSourceState = this.getDataSourceState();
|
|
14611
14655
|
const cellSelection = dataSourceState.cellSelection;
|
|
14612
14656
|
if (!cellSelection) {
|
|
14613
14657
|
return;
|
|
14614
14658
|
}
|
|
14615
14659
|
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14616
14660
|
newCellSelection.selectAll();
|
|
14617
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14618
|
-
}
|
|
14619
|
-
selectRange
|
|
14620
|
-
|
|
14621
|
-
}
|
|
14622
|
-
deselectRange
|
|
14623
|
-
|
|
14624
|
-
}
|
|
14625
|
-
|
|
14626
|
-
const dataSourceState = getDataSourceState();
|
|
14627
|
-
const cellSelection = dataSourceState.cellSelection;
|
|
14628
|
-
if (!cellSelection) {
|
|
14629
|
-
return;
|
|
14630
|
-
}
|
|
14631
|
-
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14632
|
-
const [startRowId, startColId] = getCellSelectionPosition(startOptions);
|
|
14633
|
-
const [endRowId, endColId] = getCellSelectionPosition(endOptions);
|
|
14634
|
-
const startCol = getComputed().computedVisibleColumnsMap.get(startColId);
|
|
14635
|
-
const endCol = getComputed().computedVisibleColumnsMap.get(endColId);
|
|
14636
|
-
if (!startCol || !endCol) {
|
|
14637
|
-
return;
|
|
14638
|
-
}
|
|
14639
|
-
const startColIndex = startCol.computedVisibleIndex;
|
|
14640
|
-
const endColIndex = endCol.computedVisibleIndex;
|
|
14641
|
-
const startRowInfo = getRowInfoAt(startRowId, getDataSourceState);
|
|
14642
|
-
const endRowInfo = getRowInfoAt(endRowId, getDataSourceState);
|
|
14643
|
-
if (!startRowInfo || !endRowInfo) {
|
|
14644
|
-
return;
|
|
14645
|
-
}
|
|
14646
|
-
const startRowIndex = startRowInfo.indexInAll;
|
|
14647
|
-
const endRowIndex = endRowInfo.indexInAll;
|
|
14648
|
-
const [start, end] = ensureMinMaxCellPositionByIndex(
|
|
14649
|
-
{ rowIndex: startRowIndex, colIndex: startColIndex },
|
|
14650
|
-
{ rowIndex: endRowIndex, colIndex: endColIndex }
|
|
14651
|
-
);
|
|
14652
|
-
for (let i = start.rowIndex; i <= end.rowIndex; i++) {
|
|
14653
|
-
for (let j = start.colIndex; j <= end.colIndex; j++) {
|
|
14654
|
-
const pos = {
|
|
14655
|
-
rowIndex: i,
|
|
14656
|
-
colIndex: j
|
|
14657
|
-
};
|
|
14658
|
-
const [pk, colId] = getCellSelectionPosition(pos);
|
|
14659
|
-
if (selected) {
|
|
14660
|
-
newCellSelection.selectCell(pk, colId);
|
|
14661
|
-
} else {
|
|
14662
|
-
newCellSelection.deselectCell(pk, colId);
|
|
14663
|
-
}
|
|
14664
|
-
}
|
|
14665
|
-
}
|
|
14666
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14667
|
-
},
|
|
14668
|
-
isCellSelected: (options) => {
|
|
14661
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14662
|
+
};
|
|
14663
|
+
this.selectRange = (startOptions, endOptions) => {
|
|
14664
|
+
this.setRangeSelected(startOptions, endOptions, true);
|
|
14665
|
+
};
|
|
14666
|
+
this.deselectRange = (startOptions, endOptions) => {
|
|
14667
|
+
this.setRangeSelected(startOptions, endOptions, false);
|
|
14668
|
+
};
|
|
14669
|
+
this.isCellSelected = (options) => {
|
|
14669
14670
|
var _a, _b;
|
|
14670
|
-
const [pk, colId] = getCellSelectionPosition(options);
|
|
14671
|
-
return (_b = (_a = getDataSourceState().cellSelection) == null ? void 0 : _a.isCellSelected(pk, colId)) != null ? _b : false;
|
|
14672
|
-
}
|
|
14673
|
-
selectCell
|
|
14674
|
-
const cellSelection = getDataSourceState().cellSelection;
|
|
14671
|
+
const [pk, colId] = this.getCellSelectionPosition(options);
|
|
14672
|
+
return (_b = (_a = this.getDataSourceState().cellSelection) == null ? void 0 : _a.isCellSelected(pk, colId)) != null ? _b : false;
|
|
14673
|
+
};
|
|
14674
|
+
this.selectCell = (options) => {
|
|
14675
|
+
const cellSelection = this.getDataSourceState().cellSelection;
|
|
14675
14676
|
if (!cellSelection) {
|
|
14676
14677
|
return;
|
|
14677
14678
|
}
|
|
14678
|
-
const [pk, colId] = getCellSelectionPosition(options);
|
|
14679
|
+
const [pk, colId] = this.getCellSelectionPosition(options);
|
|
14679
14680
|
const newCellSelection = options.clear ? new CellSelectionState() : new CellSelectionState(cellSelection);
|
|
14680
14681
|
newCellSelection.selectCell(pk, colId);
|
|
14681
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14682
|
-
}
|
|
14683
|
-
deselectCell
|
|
14684
|
-
const cellSelection = getDataSourceState().cellSelection;
|
|
14682
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14683
|
+
};
|
|
14684
|
+
this.deselectCell = (options) => {
|
|
14685
|
+
const cellSelection = this.getDataSourceState().cellSelection;
|
|
14685
14686
|
if (!cellSelection) {
|
|
14686
14687
|
return;
|
|
14687
14688
|
}
|
|
14688
|
-
const [pk, colId] = getCellSelectionPosition(options);
|
|
14689
|
+
const [pk, colId] = this.getCellSelectionPosition(options);
|
|
14689
14690
|
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14690
14691
|
newCellSelection.deselectCell(pk, colId);
|
|
14691
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14692
|
-
}
|
|
14693
|
-
selectColumn
|
|
14692
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14693
|
+
};
|
|
14694
|
+
this.selectColumn = (colId, options) => {
|
|
14694
14695
|
if (options == null ? void 0 : options.clear) {
|
|
14695
|
-
|
|
14696
|
+
this.deselectAll();
|
|
14696
14697
|
}
|
|
14697
|
-
const cellSelection = getDataSourceState().cellSelection;
|
|
14698
|
+
const cellSelection = this.getDataSourceState().cellSelection;
|
|
14698
14699
|
if (!cellSelection) {
|
|
14699
14700
|
return;
|
|
14700
14701
|
}
|
|
14701
14702
|
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14702
14703
|
newCellSelection.selectColumn(colId);
|
|
14703
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14704
|
-
}
|
|
14705
|
-
deselectColumn
|
|
14706
|
-
const cellSelection = getDataSourceState().cellSelection;
|
|
14704
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14705
|
+
};
|
|
14706
|
+
this.deselectColumn = (colId) => {
|
|
14707
|
+
const cellSelection = this.getDataSourceState().cellSelection;
|
|
14707
14708
|
if (!cellSelection) {
|
|
14708
14709
|
return;
|
|
14709
14710
|
}
|
|
14710
14711
|
const newCellSelection = new CellSelectionState(cellSelection);
|
|
14711
14712
|
newCellSelection.deselectColumn(colId);
|
|
14712
|
-
dataSourceActions.cellSelection = newCellSelection;
|
|
14713
|
-
}
|
|
14714
|
-
|
|
14713
|
+
this.dataSourceActions.cellSelection = newCellSelection;
|
|
14714
|
+
};
|
|
14715
|
+
this.getComputed = param.getComputed;
|
|
14716
|
+
this.getDataSourceState = param.getDataSourceState;
|
|
14717
|
+
this.dataSourceActions = param.dataSourceActions;
|
|
14718
|
+
}
|
|
14719
|
+
};
|
|
14720
|
+
function getCellSelectionApi(param) {
|
|
14721
|
+
const cellSelectionApi = new InfiniteTableCellSelectionApiImpl(param);
|
|
14715
14722
|
if (false) {
|
|
14716
14723
|
globalThis.cellSelectionApi = cellSelectionApi;
|
|
14717
14724
|
}
|
|
@@ -17583,7 +17590,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
17583
17590
|
const valid = (0, import_react49.useMemo)(() => {
|
|
17584
17591
|
let valid2 = isValidLicense(licenseKey, {
|
|
17585
17592
|
publishedAt: 1624970570587,
|
|
17586
|
-
version: "3.0.
|
|
17593
|
+
version: "3.0.5"
|
|
17587
17594
|
});
|
|
17588
17595
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
17589
17596
|
return true;
|