@infinite-table/infinite-react 9.1.0 → 9.1.1
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.dev.js +103 -39
- package/index.dev.mjs +103 -39
- package/index.js +8 -8
- package/index.mjs +8 -8
- package/package.json +2 -2
package/index.dev.js
CHANGED
|
@@ -22491,6 +22491,40 @@ function lazyLoadRange(options, cache) {
|
|
|
22491
22491
|
}, initialPromise);
|
|
22492
22492
|
}
|
|
22493
22493
|
|
|
22494
|
+
// src/components/InfiniteTable/utils/getEditingCellContext.ts
|
|
22495
|
+
function resolveEditingCellRowIndex(context, editingCell) {
|
|
22496
|
+
const { rowIndex, primaryKey } = editingCell;
|
|
22497
|
+
const { dataArray } = context.getDataSourceState();
|
|
22498
|
+
if (primaryKey !== void 0) {
|
|
22499
|
+
const indexByKey = context.dataSourceApi.getIndexByPrimaryKey(primaryKey);
|
|
22500
|
+
if (indexByKey !== -1) {
|
|
22501
|
+
return indexByKey;
|
|
22502
|
+
}
|
|
22503
|
+
if (dataArray[rowIndex]?.id !== primaryKey) {
|
|
22504
|
+
return -1;
|
|
22505
|
+
}
|
|
22506
|
+
}
|
|
22507
|
+
return dataArray[rowIndex] ? rowIndex : -1;
|
|
22508
|
+
}
|
|
22509
|
+
function getEditingCellContext(context, editingCell) {
|
|
22510
|
+
const rowIndex = resolveEditingCellRowIndex(context, editingCell);
|
|
22511
|
+
if (rowIndex === -1) {
|
|
22512
|
+
return null;
|
|
22513
|
+
}
|
|
22514
|
+
return getCellContext({
|
|
22515
|
+
...context,
|
|
22516
|
+
rowIndex,
|
|
22517
|
+
columnId: editingCell.columnId
|
|
22518
|
+
});
|
|
22519
|
+
}
|
|
22520
|
+
function warnEditedRowGone(callbackName, editingCell) {
|
|
22521
|
+
console.warn(
|
|
22522
|
+
`Skipping "${callbackName}": the edited row (primaryKey: ${String(
|
|
22523
|
+
editingCell.primaryKey
|
|
22524
|
+
)}, rowIndex: ${editingCell.rowIndex}) is no longer in the data array.`
|
|
22525
|
+
);
|
|
22526
|
+
}
|
|
22527
|
+
|
|
22494
22528
|
// src/components/InfiniteTable/api/realignColumnContextMenu.ts
|
|
22495
22529
|
function realignColumnContextMenu(param) {
|
|
22496
22530
|
const { getComputed, getState, actions } = param;
|
|
@@ -23367,9 +23401,28 @@ var InfiniteTableApiImpl = class {
|
|
|
23367
23401
|
waiting: "persist"
|
|
23368
23402
|
};
|
|
23369
23403
|
}
|
|
23404
|
+
const rowIndex = resolveEditingCellRowIndex(
|
|
23405
|
+
{ ...this.context, api: this },
|
|
23406
|
+
editingCell
|
|
23407
|
+
);
|
|
23408
|
+
if (rowIndex === -1) {
|
|
23409
|
+
const error4 = new Error(
|
|
23410
|
+
`Cannot persist edit: the edited row (primaryKey: ${String(
|
|
23411
|
+
editingCell.primaryKey
|
|
23412
|
+
)}, rowIndex: ${editingCell.rowIndex}) is no longer in the data array.`
|
|
23413
|
+
);
|
|
23414
|
+
this.actions.editingCell = {
|
|
23415
|
+
...editingCell,
|
|
23416
|
+
active: false,
|
|
23417
|
+
accepted: false,
|
|
23418
|
+
waiting: false,
|
|
23419
|
+
persisted: error4
|
|
23420
|
+
};
|
|
23421
|
+
return Promise.resolve(error4);
|
|
23422
|
+
}
|
|
23370
23423
|
const params = {
|
|
23371
23424
|
...getCellContext({
|
|
23372
|
-
rowIndex
|
|
23425
|
+
rowIndex,
|
|
23373
23426
|
columnId: editingCell.columnId,
|
|
23374
23427
|
...this.context,
|
|
23375
23428
|
api: this
|
|
@@ -27758,7 +27811,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
27758
27811
|
}
|
|
27759
27812
|
let valid2 = isValidLicense(licenseKey, {
|
|
27760
27813
|
publishedAt: 1624970570587,
|
|
27761
|
-
version: "9.1.
|
|
27814
|
+
version: "9.1.1"
|
|
27762
27815
|
});
|
|
27763
27816
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
27764
27817
|
return true;
|
|
@@ -30403,15 +30456,19 @@ function useOnEditCancelled() {
|
|
|
30403
30456
|
const cancelled = editingCell && !editingCell.active ? editingCell.cancelled : void 0;
|
|
30404
30457
|
(0, import_react61.useEffect)(() => {
|
|
30405
30458
|
if (cancelled) {
|
|
30406
|
-
const { rowIndex, columnId, initialValue } = getState().editingCell;
|
|
30407
30459
|
const { onEditCancelled } = getState();
|
|
30408
|
-
|
|
30409
|
-
|
|
30410
|
-
|
|
30411
|
-
|
|
30412
|
-
|
|
30413
|
-
|
|
30414
|
-
|
|
30460
|
+
const editingCell2 = getState().editingCell;
|
|
30461
|
+
if (!onEditCancelled) {
|
|
30462
|
+
return;
|
|
30463
|
+
}
|
|
30464
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30465
|
+
if (!cellContext) {
|
|
30466
|
+
warnEditedRowGone("onEditCancelled", editingCell2);
|
|
30467
|
+
return;
|
|
30468
|
+
}
|
|
30469
|
+
onEditCancelled({
|
|
30470
|
+
...cellContext,
|
|
30471
|
+
initialValue: editingCell2.initialValue
|
|
30415
30472
|
});
|
|
30416
30473
|
}
|
|
30417
30474
|
}, [cancelled]);
|
|
@@ -30427,17 +30484,21 @@ function useOnEditRejected() {
|
|
|
30427
30484
|
const rejected = editingCell && !editingCell.active && editingCell.accepted instanceof Error ? editingCell.accepted : void 0;
|
|
30428
30485
|
(0, import_react61.useEffect)(() => {
|
|
30429
30486
|
if (rejected) {
|
|
30430
|
-
const { rowIndex, columnId, value, initialValue } = getState().editingCell;
|
|
30431
30487
|
const { onEditRejected } = getState();
|
|
30432
|
-
|
|
30433
|
-
|
|
30434
|
-
|
|
30435
|
-
|
|
30436
|
-
|
|
30437
|
-
|
|
30438
|
-
|
|
30488
|
+
const editingCell2 = getState().editingCell;
|
|
30489
|
+
if (!onEditRejected) {
|
|
30490
|
+
return;
|
|
30491
|
+
}
|
|
30492
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30493
|
+
if (!cellContext) {
|
|
30494
|
+
warnEditedRowGone("onEditRejected", editingCell2);
|
|
30495
|
+
return;
|
|
30496
|
+
}
|
|
30497
|
+
onEditRejected({
|
|
30498
|
+
...cellContext,
|
|
30499
|
+
value: editingCell2.value,
|
|
30439
30500
|
error: rejected,
|
|
30440
|
-
initialValue
|
|
30501
|
+
initialValue: editingCell2.initialValue
|
|
30441
30502
|
});
|
|
30442
30503
|
}
|
|
30443
30504
|
}, [rejected]);
|
|
@@ -30468,18 +30529,17 @@ function useOnEditAccepted() {
|
|
|
30468
30529
|
const accepted = editingCell && !editingCell.active && !editingCell.cancelled && editingCell.accepted === true;
|
|
30469
30530
|
(0, import_react61.useEffect)(() => {
|
|
30470
30531
|
if (accepted) {
|
|
30471
|
-
const {
|
|
30472
|
-
const
|
|
30473
|
-
const
|
|
30474
|
-
|
|
30475
|
-
|
|
30476
|
-
|
|
30477
|
-
...
|
|
30478
|
-
}
|
|
30479
|
-
|
|
30480
|
-
|
|
30481
|
-
}
|
|
30482
|
-
getState().onEditAccepted?.(editParams);
|
|
30532
|
+
const { onEditAccepted } = getState();
|
|
30533
|
+
const editingCell2 = getState().editingCell;
|
|
30534
|
+
const { value, initialValue } = editingCell2;
|
|
30535
|
+
if (onEditAccepted) {
|
|
30536
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30537
|
+
if (cellContext) {
|
|
30538
|
+
onEditAccepted({ ...cellContext, value, initialValue });
|
|
30539
|
+
} else {
|
|
30540
|
+
warnEditedRowGone("onEditAccepted", editingCell2);
|
|
30541
|
+
}
|
|
30542
|
+
}
|
|
30483
30543
|
context.api.persistEdit({ value });
|
|
30484
30544
|
}
|
|
30485
30545
|
}, [accepted]);
|
|
@@ -30499,15 +30559,19 @@ function useOnEditPersisted() {
|
|
|
30499
30559
|
if (!editingCell2) {
|
|
30500
30560
|
return;
|
|
30501
30561
|
}
|
|
30502
|
-
const
|
|
30562
|
+
const callbackName = persisted instanceof Error ? "onEditPersistError" : "onEditPersistSuccess";
|
|
30563
|
+
if (!getState()[callbackName]) {
|
|
30564
|
+
return;
|
|
30565
|
+
}
|
|
30566
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30567
|
+
if (!cellContext) {
|
|
30568
|
+
warnEditedRowGone(callbackName, editingCell2);
|
|
30569
|
+
return;
|
|
30570
|
+
}
|
|
30503
30571
|
const params = {
|
|
30504
|
-
...
|
|
30505
|
-
|
|
30506
|
-
|
|
30507
|
-
...context
|
|
30508
|
-
}),
|
|
30509
|
-
value,
|
|
30510
|
-
initialValue
|
|
30572
|
+
...cellContext,
|
|
30573
|
+
value: editingCell2.value,
|
|
30574
|
+
initialValue: editingCell2.initialValue
|
|
30511
30575
|
};
|
|
30512
30576
|
if (persisted instanceof Error) {
|
|
30513
30577
|
onEditPersistError?.({ ...params, error: persisted });
|
package/index.dev.mjs
CHANGED
|
@@ -22425,6 +22425,40 @@ function lazyLoadRange(options, cache) {
|
|
|
22425
22425
|
}, initialPromise);
|
|
22426
22426
|
}
|
|
22427
22427
|
|
|
22428
|
+
// src/components/InfiniteTable/utils/getEditingCellContext.ts
|
|
22429
|
+
function resolveEditingCellRowIndex(context, editingCell) {
|
|
22430
|
+
const { rowIndex, primaryKey } = editingCell;
|
|
22431
|
+
const { dataArray } = context.getDataSourceState();
|
|
22432
|
+
if (primaryKey !== void 0) {
|
|
22433
|
+
const indexByKey = context.dataSourceApi.getIndexByPrimaryKey(primaryKey);
|
|
22434
|
+
if (indexByKey !== -1) {
|
|
22435
|
+
return indexByKey;
|
|
22436
|
+
}
|
|
22437
|
+
if (dataArray[rowIndex]?.id !== primaryKey) {
|
|
22438
|
+
return -1;
|
|
22439
|
+
}
|
|
22440
|
+
}
|
|
22441
|
+
return dataArray[rowIndex] ? rowIndex : -1;
|
|
22442
|
+
}
|
|
22443
|
+
function getEditingCellContext(context, editingCell) {
|
|
22444
|
+
const rowIndex = resolveEditingCellRowIndex(context, editingCell);
|
|
22445
|
+
if (rowIndex === -1) {
|
|
22446
|
+
return null;
|
|
22447
|
+
}
|
|
22448
|
+
return getCellContext({
|
|
22449
|
+
...context,
|
|
22450
|
+
rowIndex,
|
|
22451
|
+
columnId: editingCell.columnId
|
|
22452
|
+
});
|
|
22453
|
+
}
|
|
22454
|
+
function warnEditedRowGone(callbackName, editingCell) {
|
|
22455
|
+
console.warn(
|
|
22456
|
+
`Skipping "${callbackName}": the edited row (primaryKey: ${String(
|
|
22457
|
+
editingCell.primaryKey
|
|
22458
|
+
)}, rowIndex: ${editingCell.rowIndex}) is no longer in the data array.`
|
|
22459
|
+
);
|
|
22460
|
+
}
|
|
22461
|
+
|
|
22428
22462
|
// src/components/InfiniteTable/api/realignColumnContextMenu.ts
|
|
22429
22463
|
function realignColumnContextMenu(param) {
|
|
22430
22464
|
const { getComputed, getState, actions } = param;
|
|
@@ -23301,9 +23335,28 @@ var InfiniteTableApiImpl = class {
|
|
|
23301
23335
|
waiting: "persist"
|
|
23302
23336
|
};
|
|
23303
23337
|
}
|
|
23338
|
+
const rowIndex = resolveEditingCellRowIndex(
|
|
23339
|
+
{ ...this.context, api: this },
|
|
23340
|
+
editingCell
|
|
23341
|
+
);
|
|
23342
|
+
if (rowIndex === -1) {
|
|
23343
|
+
const error4 = new Error(
|
|
23344
|
+
`Cannot persist edit: the edited row (primaryKey: ${String(
|
|
23345
|
+
editingCell.primaryKey
|
|
23346
|
+
)}, rowIndex: ${editingCell.rowIndex}) is no longer in the data array.`
|
|
23347
|
+
);
|
|
23348
|
+
this.actions.editingCell = {
|
|
23349
|
+
...editingCell,
|
|
23350
|
+
active: false,
|
|
23351
|
+
accepted: false,
|
|
23352
|
+
waiting: false,
|
|
23353
|
+
persisted: error4
|
|
23354
|
+
};
|
|
23355
|
+
return Promise.resolve(error4);
|
|
23356
|
+
}
|
|
23304
23357
|
const params = {
|
|
23305
23358
|
...getCellContext({
|
|
23306
|
-
rowIndex
|
|
23359
|
+
rowIndex,
|
|
23307
23360
|
columnId: editingCell.columnId,
|
|
23308
23361
|
...this.context,
|
|
23309
23362
|
api: this
|
|
@@ -27697,7 +27750,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
27697
27750
|
}
|
|
27698
27751
|
let valid2 = isValidLicense(licenseKey, {
|
|
27699
27752
|
publishedAt: 1624970570587,
|
|
27700
|
-
version: "9.1.
|
|
27753
|
+
version: "9.1.1"
|
|
27701
27754
|
});
|
|
27702
27755
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
27703
27756
|
return true;
|
|
@@ -30352,15 +30405,19 @@ function useOnEditCancelled() {
|
|
|
30352
30405
|
const cancelled = editingCell && !editingCell.active ? editingCell.cancelled : void 0;
|
|
30353
30406
|
useEffect33(() => {
|
|
30354
30407
|
if (cancelled) {
|
|
30355
|
-
const { rowIndex, columnId, initialValue } = getState().editingCell;
|
|
30356
30408
|
const { onEditCancelled } = getState();
|
|
30357
|
-
|
|
30358
|
-
|
|
30359
|
-
|
|
30360
|
-
|
|
30361
|
-
|
|
30362
|
-
|
|
30363
|
-
|
|
30409
|
+
const editingCell2 = getState().editingCell;
|
|
30410
|
+
if (!onEditCancelled) {
|
|
30411
|
+
return;
|
|
30412
|
+
}
|
|
30413
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30414
|
+
if (!cellContext) {
|
|
30415
|
+
warnEditedRowGone("onEditCancelled", editingCell2);
|
|
30416
|
+
return;
|
|
30417
|
+
}
|
|
30418
|
+
onEditCancelled({
|
|
30419
|
+
...cellContext,
|
|
30420
|
+
initialValue: editingCell2.initialValue
|
|
30364
30421
|
});
|
|
30365
30422
|
}
|
|
30366
30423
|
}, [cancelled]);
|
|
@@ -30376,17 +30433,21 @@ function useOnEditRejected() {
|
|
|
30376
30433
|
const rejected = editingCell && !editingCell.active && editingCell.accepted instanceof Error ? editingCell.accepted : void 0;
|
|
30377
30434
|
useEffect33(() => {
|
|
30378
30435
|
if (rejected) {
|
|
30379
|
-
const { rowIndex, columnId, value, initialValue } = getState().editingCell;
|
|
30380
30436
|
const { onEditRejected } = getState();
|
|
30381
|
-
|
|
30382
|
-
|
|
30383
|
-
|
|
30384
|
-
|
|
30385
|
-
|
|
30386
|
-
|
|
30387
|
-
|
|
30437
|
+
const editingCell2 = getState().editingCell;
|
|
30438
|
+
if (!onEditRejected) {
|
|
30439
|
+
return;
|
|
30440
|
+
}
|
|
30441
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30442
|
+
if (!cellContext) {
|
|
30443
|
+
warnEditedRowGone("onEditRejected", editingCell2);
|
|
30444
|
+
return;
|
|
30445
|
+
}
|
|
30446
|
+
onEditRejected({
|
|
30447
|
+
...cellContext,
|
|
30448
|
+
value: editingCell2.value,
|
|
30388
30449
|
error: rejected,
|
|
30389
|
-
initialValue
|
|
30450
|
+
initialValue: editingCell2.initialValue
|
|
30390
30451
|
});
|
|
30391
30452
|
}
|
|
30392
30453
|
}, [rejected]);
|
|
@@ -30417,18 +30478,17 @@ function useOnEditAccepted() {
|
|
|
30417
30478
|
const accepted = editingCell && !editingCell.active && !editingCell.cancelled && editingCell.accepted === true;
|
|
30418
30479
|
useEffect33(() => {
|
|
30419
30480
|
if (accepted) {
|
|
30420
|
-
const {
|
|
30421
|
-
const
|
|
30422
|
-
const
|
|
30423
|
-
|
|
30424
|
-
|
|
30425
|
-
|
|
30426
|
-
...
|
|
30427
|
-
}
|
|
30428
|
-
|
|
30429
|
-
|
|
30430
|
-
}
|
|
30431
|
-
getState().onEditAccepted?.(editParams);
|
|
30481
|
+
const { onEditAccepted } = getState();
|
|
30482
|
+
const editingCell2 = getState().editingCell;
|
|
30483
|
+
const { value, initialValue } = editingCell2;
|
|
30484
|
+
if (onEditAccepted) {
|
|
30485
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30486
|
+
if (cellContext) {
|
|
30487
|
+
onEditAccepted({ ...cellContext, value, initialValue });
|
|
30488
|
+
} else {
|
|
30489
|
+
warnEditedRowGone("onEditAccepted", editingCell2);
|
|
30490
|
+
}
|
|
30491
|
+
}
|
|
30432
30492
|
context.api.persistEdit({ value });
|
|
30433
30493
|
}
|
|
30434
30494
|
}, [accepted]);
|
|
@@ -30448,15 +30508,19 @@ function useOnEditPersisted() {
|
|
|
30448
30508
|
if (!editingCell2) {
|
|
30449
30509
|
return;
|
|
30450
30510
|
}
|
|
30451
|
-
const
|
|
30511
|
+
const callbackName = persisted instanceof Error ? "onEditPersistError" : "onEditPersistSuccess";
|
|
30512
|
+
if (!getState()[callbackName]) {
|
|
30513
|
+
return;
|
|
30514
|
+
}
|
|
30515
|
+
const cellContext = getEditingCellContext(context, editingCell2);
|
|
30516
|
+
if (!cellContext) {
|
|
30517
|
+
warnEditedRowGone(callbackName, editingCell2);
|
|
30518
|
+
return;
|
|
30519
|
+
}
|
|
30452
30520
|
const params = {
|
|
30453
|
-
...
|
|
30454
|
-
|
|
30455
|
-
|
|
30456
|
-
...context
|
|
30457
|
-
}),
|
|
30458
|
-
value,
|
|
30459
|
-
initialValue
|
|
30521
|
+
...cellContext,
|
|
30522
|
+
value: editingCell2.value,
|
|
30523
|
+
initialValue: editingCell2.initialValue
|
|
30460
30524
|
};
|
|
30461
30525
|
if (persisted instanceof Error) {
|
|
30462
30526
|
onEditPersistError?.({ ...params, error: persisted });
|