@infinite-table/infinite-react 4.4.0 → 4.4.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.
Files changed (6) hide show
  1. package/index.d.ts +32 -23
  2. package/index.dev.js +270 -200
  3. package/index.dev.mjs +269 -200
  4. package/index.js +270 -200
  5. package/index.mjs +269 -200
  6. package/package.json +2 -2
package/index.mjs CHANGED
@@ -12910,6 +12910,203 @@ function getRowInfoArray(getState) {
12910
12910
  return getState().dataArray;
12911
12911
  }
12912
12912
 
12913
+ // src/components/DataSource/BooleanCollectionState.ts
12914
+ var BooleanCollectionState = class {
12915
+ constructor(state) {
12916
+ const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? (
12917
+ //@ts-ignore
12918
+ state.getState()
12919
+ ) : state;
12920
+ const positiveItems = this.getPositiveFromState(stateObject);
12921
+ const negativeItems = this.getNegativeFromState(stateObject);
12922
+ this.update({
12923
+ negativeItems,
12924
+ positiveItems
12925
+ });
12926
+ }
12927
+ getInitialState() {
12928
+ return this.initialState;
12929
+ }
12930
+ // protected getState(): BooleanCollectionStateObject<KeyType> {
12931
+ // return {
12932
+ // positiveItems: this.allPositive
12933
+ // ? true
12934
+ // : this.positiveMap?.topDownKeys() ?? [],
12935
+ // negativeItems: this.allNegative
12936
+ // ? true
12937
+ // : this.negativeMap?.topDownKeys() ?? [],
12938
+ // };
12939
+ // }
12940
+ destroy() {
12941
+ var _a, _b;
12942
+ (_a = this.positiveMap) == null ? void 0 : _a.clear();
12943
+ (_b = this.negativeMap) == null ? void 0 : _b.clear();
12944
+ delete this.positiveMap;
12945
+ delete this.negativeMap;
12946
+ }
12947
+ update(state) {
12948
+ const { positiveItems, negativeItems } = state;
12949
+ this.allNegative = negativeItems === true;
12950
+ this.allPositive = positiveItems === true;
12951
+ if (this.allNegative && this.allPositive) {
12952
+ throw `Cannot have both negativeItems and positiveItems be true!`;
12953
+ }
12954
+ if (negativeItems && negativeItems !== true) {
12955
+ if (!this.negativeMap) {
12956
+ this.negativeMap = /* @__PURE__ */ new Map();
12957
+ }
12958
+ this.negativeMap.clear();
12959
+ for (let k of negativeItems) {
12960
+ this.negativeMap.set(k, true);
12961
+ }
12962
+ if (this.positiveMap) {
12963
+ this.positiveMap.clear();
12964
+ }
12965
+ }
12966
+ if (positiveItems && positiveItems !== true) {
12967
+ if (!this.positiveMap) {
12968
+ this.positiveMap = /* @__PURE__ */ new Map();
12969
+ }
12970
+ this.positiveMap.clear();
12971
+ for (let k of positiveItems) {
12972
+ this.positiveMap.set(k, true);
12973
+ }
12974
+ if (this.negativeMap) {
12975
+ this.negativeMap.clear();
12976
+ }
12977
+ }
12978
+ }
12979
+ isDefaultNegativeSelection() {
12980
+ return this.allNegative;
12981
+ }
12982
+ isDefaultPositiveSelection() {
12983
+ return this.allPositive;
12984
+ }
12985
+ areAllNegative() {
12986
+ return this.allNegative && (this.positiveMap ? this.positiveMap.size === 0 : true);
12987
+ }
12988
+ areAllPositive() {
12989
+ return this.allPositive && (this.negativeMap ? this.negativeMap.size === 0 : true);
12990
+ }
12991
+ makeAllNegative() {
12992
+ this.update({
12993
+ negativeItems: true,
12994
+ positiveItems: []
12995
+ });
12996
+ }
12997
+ makeAllPositive() {
12998
+ this.update({
12999
+ positiveItems: true,
13000
+ negativeItems: []
13001
+ });
13002
+ }
13003
+ isItemPositive(key) {
13004
+ var _a, _b;
13005
+ if (this.allPositive === true) {
13006
+ if (this.allNegative === true) {
13007
+ throw 'Cannot have both positiveItems and negativeItems be "true"';
13008
+ }
13009
+ return !((_a = this.negativeMap) == null ? void 0 : _a.has(key));
13010
+ }
13011
+ return !!((_b = this.positiveMap) == null ? void 0 : _b.has(key));
13012
+ }
13013
+ isItemNegative(key) {
13014
+ return !this.isItemPositive(key);
13015
+ }
13016
+ setItemValue(key, shouldMakePositive) {
13017
+ var _a;
13018
+ if (shouldMakePositive === this.isItemPositive(key)) {
13019
+ return;
13020
+ }
13021
+ if (shouldMakePositive) {
13022
+ if (this.allNegative === true) {
13023
+ if (!this.positiveMap) {
13024
+ throw `No positiveMap found when trying to set item ${key} be positive`;
13025
+ }
13026
+ this.positiveMap.set(key, true);
13027
+ } else if (this.allPositive === true) {
13028
+ if (!this.negativeMap) {
13029
+ throw `No negativeMap found when trying to set item ${key} be positive`;
13030
+ }
13031
+ this.negativeMap.delete(key);
13032
+ }
13033
+ } else {
13034
+ if (this.allPositive === true) {
13035
+ if (!this.negativeMap) {
13036
+ throw `No negativeMap found when trying to set item ${key} be negative`;
13037
+ }
13038
+ this.negativeMap.set(key, true);
13039
+ } else if (this.allNegative === true) {
13040
+ if (!this.positiveMap) {
13041
+ throw `No positiveMap found when trying to set item ${key} be negative`;
13042
+ }
13043
+ (_a = this.positiveMap) == null ? void 0 : _a.delete(key);
13044
+ }
13045
+ }
13046
+ }
13047
+ makeItemNegative(key) {
13048
+ this.setItemValue(key, false);
13049
+ }
13050
+ makeItemPositive(key) {
13051
+ this.setItemValue(key, true);
13052
+ }
13053
+ toggleItem(key) {
13054
+ this.setItemValue(key, !this.isItemPositive(key));
13055
+ }
13056
+ };
13057
+
13058
+ // src/components/DataSource/RowDisabledState.ts
13059
+ var RowDisabledState = class extends BooleanCollectionState {
13060
+ constructor(state) {
13061
+ super(state);
13062
+ this.isRowEnabled = (key) => {
13063
+ return !!this.isItemPositive(key);
13064
+ };
13065
+ }
13066
+ getState() {
13067
+ var _a, _b, _c, _d;
13068
+ const enabledRows = this.allPositive ? true : [...(_b = (_a = this.positiveMap) == null ? void 0 : _a.keys()) != null ? _b : []];
13069
+ const disabledRows = this.allNegative ? true : [...(_d = (_c = this.negativeMap) == null ? void 0 : _c.keys()) != null ? _d : []];
13070
+ return {
13071
+ enabledRows,
13072
+ disabledRows
13073
+ };
13074
+ }
13075
+ getPositiveFromState(state) {
13076
+ return state.enabledRows;
13077
+ }
13078
+ getNegativeFromState(state) {
13079
+ return state.disabledRows;
13080
+ }
13081
+ areAllDisabled() {
13082
+ return this.areAllNegative();
13083
+ }
13084
+ areAllEnabled() {
13085
+ return this.areAllPositive();
13086
+ }
13087
+ disableAll() {
13088
+ this.makeAllNegative();
13089
+ }
13090
+ enableAll() {
13091
+ this.makeAllPositive();
13092
+ }
13093
+ isRowDisabled(key) {
13094
+ return !this.isRowEnabled(key);
13095
+ }
13096
+ setRowEnabled(key, enabled) {
13097
+ return this.setItemValue(key, enabled);
13098
+ }
13099
+ disableRow(key) {
13100
+ this.setRowEnabled(key, false);
13101
+ }
13102
+ enableRow(key) {
13103
+ this.setRowEnabled(key, true);
13104
+ }
13105
+ toggleRow(key) {
13106
+ this.toggleItem(key);
13107
+ }
13108
+ };
13109
+
12913
13110
  // src/components/DataSource/getDataSourceApi.ts
12914
13111
  function getDataSourceApi(param) {
12915
13112
  return new DataSourceApiImpl(param);
@@ -13063,6 +13260,70 @@ var DataSourceApiImpl = class {
13063
13260
  this.actions.sortInfo = sortInfo;
13064
13261
  return;
13065
13262
  };
13263
+ this.isRowDisabledAt = (rowIndex) => {
13264
+ var _a;
13265
+ const rowInfo = this.getRowInfoByIndex(rowIndex);
13266
+ return (_a = rowInfo == null ? void 0 : rowInfo.rowDisabled) != null ? _a : false;
13267
+ };
13268
+ this.isRowDisabled = (primaryKey) => {
13269
+ var _a;
13270
+ const rowInfo = this.getRowInfoByPrimaryKey(primaryKey);
13271
+ return (_a = rowInfo == null ? void 0 : rowInfo.rowDisabled) != null ? _a : false;
13272
+ };
13273
+ this.setRowEnabledAt = (rowIndex, enabled) => {
13274
+ const currentRowDisabledState = this.getState().rowDisabledState;
13275
+ const rowDisabledState = currentRowDisabledState ? new RowDisabledState(currentRowDisabledState) : new RowDisabledState({
13276
+ enabledRows: true,
13277
+ disabledRows: []
13278
+ });
13279
+ const rowInfo = this.getRowInfoByIndex(rowIndex);
13280
+ if (!rowInfo) {
13281
+ return;
13282
+ }
13283
+ rowDisabledState.setRowEnabled(rowInfo.id, enabled);
13284
+ this.actions.rowDisabledState = rowDisabledState;
13285
+ };
13286
+ this.setRowEnabled = (primaryKey, enabled) => {
13287
+ const rowInfo = this.getRowInfoByPrimaryKey(primaryKey);
13288
+ if (!rowInfo) {
13289
+ return;
13290
+ }
13291
+ this.setRowEnabledAt(rowInfo.indexInAll, enabled);
13292
+ };
13293
+ this.enableAllRows = () => {
13294
+ const currentRowDisabledState = this.getState().rowDisabledState;
13295
+ if (!currentRowDisabledState) {
13296
+ this.actions.rowDisabledState = new RowDisabledState({
13297
+ enabledRows: true,
13298
+ disabledRows: []
13299
+ });
13300
+ return;
13301
+ }
13302
+ const rowDisabledState = new RowDisabledState(currentRowDisabledState);
13303
+ rowDisabledState.enableAll();
13304
+ this.actions.rowDisabledState = rowDisabledState;
13305
+ };
13306
+ this.disableAllRows = () => {
13307
+ const currentRowDisabledState = this.getState().rowDisabledState;
13308
+ if (!currentRowDisabledState) {
13309
+ this.actions.rowDisabledState = new RowDisabledState({
13310
+ disabledRows: true,
13311
+ enabledRows: []
13312
+ });
13313
+ return;
13314
+ }
13315
+ const rowDisabledState = new RowDisabledState(currentRowDisabledState);
13316
+ rowDisabledState.disableAll();
13317
+ this.actions.rowDisabledState = rowDisabledState;
13318
+ };
13319
+ this.areAllRowsEnabled = () => {
13320
+ const rowDisabledState = this.getState().rowDisabledState;
13321
+ return rowDisabledState ? rowDisabledState.areAllEnabled() : true;
13322
+ };
13323
+ this.areAllRowsDisabled = () => {
13324
+ const rowDisabledState = this.getState().rowDisabledState;
13325
+ return rowDisabledState ? rowDisabledState.areAllDisabled() : false;
13326
+ };
13066
13327
  this.getState = param.getState;
13067
13328
  this.actions = param.actions;
13068
13329
  }
@@ -13468,6 +13729,10 @@ function concludeReducer(params) {
13468
13729
  const groupBy = state.groupBy;
13469
13730
  const pivotBy = state.pivotBy;
13470
13731
  const shouldGroup = groupBy.length > 0 || !!pivotBy;
13732
+ const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
13733
+ "rowDisabledState",
13734
+ "isRowDisabled"
13735
+ ]);
13471
13736
  const selectionDepsChanged = haveDepsChanged(previousState, state, [
13472
13737
  "rowSelection",
13473
13738
  "cellSelection",
@@ -13489,7 +13754,7 @@ function concludeReducer(params) {
13489
13754
  const rowInfoReducersChanged = haveDepsChanged(previousState, state, [
13490
13755
  "rowInfoReducers"
13491
13756
  ]);
13492
- const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray || cacheAffectedParts.groupBy) || selectionDepsChanged || rowInfoReducersChanged;
13757
+ const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray || cacheAffectedParts.groupBy) || selectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged;
13493
13758
  const now = Date.now();
13494
13759
  let dataArray = state.originalDataArray;
13495
13760
  if (!shouldFilter) {
@@ -13634,7 +13899,7 @@ function concludeReducer(params) {
13634
13899
  state.pivotColumns = void 0;
13635
13900
  state.groupRowsIndexesInDataArray = void 0;
13636
13901
  const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
13637
- if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged || rowInfoReducersChanged) {
13902
+ if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged) {
13638
13903
  const rowInfoReducerKeys = Object.keys(
13639
13904
  rowInfoReducers || {}
13640
13905
  );
@@ -14386,203 +14651,6 @@ var normalizeSortInfo = (initialSortInfo, weakMap3) => {
14386
14651
  return result;
14387
14652
  };
14388
14653
 
14389
- // src/components/DataSource/BooleanCollectionState.ts
14390
- var BooleanCollectionState = class {
14391
- constructor(state) {
14392
- const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? (
14393
- //@ts-ignore
14394
- state.getState()
14395
- ) : state;
14396
- const positiveItems = this.getPositiveFromState(stateObject);
14397
- const negativeItems = this.getNegativeFromState(stateObject);
14398
- this.update({
14399
- negativeItems,
14400
- positiveItems
14401
- });
14402
- }
14403
- getInitialState() {
14404
- return this.initialState;
14405
- }
14406
- // protected getState(): BooleanCollectionStateObject<KeyType> {
14407
- // return {
14408
- // positiveItems: this.allPositive
14409
- // ? true
14410
- // : this.positiveMap?.topDownKeys() ?? [],
14411
- // negativeItems: this.allNegative
14412
- // ? true
14413
- // : this.negativeMap?.topDownKeys() ?? [],
14414
- // };
14415
- // }
14416
- destroy() {
14417
- var _a, _b;
14418
- (_a = this.positiveMap) == null ? void 0 : _a.clear();
14419
- (_b = this.negativeMap) == null ? void 0 : _b.clear();
14420
- delete this.positiveMap;
14421
- delete this.negativeMap;
14422
- }
14423
- update(state) {
14424
- const { positiveItems, negativeItems } = state;
14425
- this.allNegative = negativeItems === true;
14426
- this.allPositive = positiveItems === true;
14427
- if (this.allNegative && this.allPositive) {
14428
- throw `Cannot have both negativeItems and positiveItems be true!`;
14429
- }
14430
- if (negativeItems && negativeItems !== true) {
14431
- if (!this.negativeMap) {
14432
- this.negativeMap = /* @__PURE__ */ new Map();
14433
- }
14434
- this.negativeMap.clear();
14435
- for (let k of negativeItems) {
14436
- this.negativeMap.set(k, true);
14437
- }
14438
- if (this.positiveMap) {
14439
- this.positiveMap.clear();
14440
- }
14441
- }
14442
- if (positiveItems && positiveItems !== true) {
14443
- if (!this.positiveMap) {
14444
- this.positiveMap = /* @__PURE__ */ new Map();
14445
- }
14446
- this.positiveMap.clear();
14447
- for (let k of positiveItems) {
14448
- this.positiveMap.set(k, true);
14449
- }
14450
- if (this.negativeMap) {
14451
- this.negativeMap.clear();
14452
- }
14453
- }
14454
- }
14455
- isDefaultNegativeSelection() {
14456
- return this.allNegative;
14457
- }
14458
- isDefaultPositiveSelection() {
14459
- return this.allPositive;
14460
- }
14461
- areAllNegative() {
14462
- return this.allNegative && (this.positiveMap ? this.positiveMap.size === 0 : true);
14463
- }
14464
- areAllPositive() {
14465
- return this.allPositive && (this.negativeMap ? this.negativeMap.size === 0 : true);
14466
- }
14467
- makeAllNegative() {
14468
- this.update({
14469
- negativeItems: true,
14470
- positiveItems: []
14471
- });
14472
- }
14473
- makeAllPositive() {
14474
- this.update({
14475
- positiveItems: true,
14476
- negativeItems: []
14477
- });
14478
- }
14479
- isItemPositive(key) {
14480
- var _a, _b;
14481
- if (this.allPositive === true) {
14482
- if (this.allNegative === true) {
14483
- throw 'Cannot have both positiveItems and negativeItems be "true"';
14484
- }
14485
- return !((_a = this.negativeMap) == null ? void 0 : _a.has(key));
14486
- }
14487
- return !!((_b = this.positiveMap) == null ? void 0 : _b.has(key));
14488
- }
14489
- isItemNegative(key) {
14490
- return !this.isItemPositive(key);
14491
- }
14492
- setItemValue(key, shouldMakePositive) {
14493
- var _a;
14494
- if (shouldMakePositive === this.isItemPositive(key)) {
14495
- return;
14496
- }
14497
- if (shouldMakePositive) {
14498
- if (this.allNegative === true) {
14499
- if (!this.positiveMap) {
14500
- throw `No positiveMap found when trying to set item ${key} be positive`;
14501
- }
14502
- this.positiveMap.set(key, true);
14503
- } else if (this.allPositive === true) {
14504
- if (!this.negativeMap) {
14505
- throw `No negativeMap found when trying to set item ${key} be positive`;
14506
- }
14507
- this.negativeMap.delete(key);
14508
- }
14509
- } else {
14510
- if (this.allPositive === true) {
14511
- if (!this.negativeMap) {
14512
- throw `No negativeMap found when trying to set item ${key} be negative`;
14513
- }
14514
- this.negativeMap.set(key, true);
14515
- } else if (this.allNegative === true) {
14516
- if (!this.positiveMap) {
14517
- throw `No positiveMap found when trying to set item ${key} be negative`;
14518
- }
14519
- (_a = this.positiveMap) == null ? void 0 : _a.delete(key);
14520
- }
14521
- }
14522
- }
14523
- makeItemNegative(key) {
14524
- this.setItemValue(key, false);
14525
- }
14526
- makeItemPositive(key) {
14527
- this.setItemValue(key, true);
14528
- }
14529
- toggleItem(key) {
14530
- this.setItemValue(key, !this.isItemPositive(key));
14531
- }
14532
- };
14533
-
14534
- // src/components/DataSource/RowDisabledState.ts
14535
- var RowDisabledState = class extends BooleanCollectionState {
14536
- constructor(state) {
14537
- super(state);
14538
- this.isRowEnabled = (key) => {
14539
- return !!this.isItemPositive(key);
14540
- };
14541
- }
14542
- getState() {
14543
- var _a, _b, _c, _d;
14544
- const enabledRows = this.allPositive ? true : [...(_b = (_a = this.positiveMap) == null ? void 0 : _a.keys()) != null ? _b : []];
14545
- const disabledRows = this.allNegative ? true : [...(_d = (_c = this.negativeMap) == null ? void 0 : _c.keys()) != null ? _d : []];
14546
- return {
14547
- enabledRows,
14548
- disabledRows
14549
- };
14550
- }
14551
- getPositiveFromState(state) {
14552
- return state.enabledRows;
14553
- }
14554
- getNegativeFromState(state) {
14555
- return state.disabledRows;
14556
- }
14557
- areAllDisabled() {
14558
- return this.areAllNegative();
14559
- }
14560
- areAllEnabled() {
14561
- return this.areAllPositive();
14562
- }
14563
- disableAll() {
14564
- this.makeAllNegative();
14565
- }
14566
- enableAll() {
14567
- this.makeAllPositive();
14568
- }
14569
- isRowDisabled(key) {
14570
- return !this.isRowEnabled(key);
14571
- }
14572
- setRowEnabled(key, shouldExpand) {
14573
- return this.setItemValue(key, shouldExpand);
14574
- }
14575
- disableRow(key) {
14576
- this.setRowEnabled(key, false);
14577
- }
14578
- enableRow(key) {
14579
- this.setRowEnabled(key, true);
14580
- }
14581
- toggleRow(key) {
14582
- this.toggleItem(key);
14583
- }
14584
- };
14585
-
14586
14654
  // src/components/DataSource/state/getInitialState.ts
14587
14655
  var DataSourceLogger = dbg("DataSource");
14588
14656
  var defaultCursorId = Symbol("cursorId");
@@ -19052,7 +19120,7 @@ var useLicense = (licenseKey = "") => {
19052
19120
  }
19053
19121
  let valid2 = isValidLicense(licenseKey, {
19054
19122
  publishedAt: 1624970570587,
19055
- version: "4.4.0"
19123
+ version: "4.4.1"
19056
19124
  });
19057
19125
  if (!licenseKey && !valid2 && isInsidePlayground) {
19058
19126
  return true;
@@ -23521,6 +23589,7 @@ export {
23521
23589
  Menu,
23522
23590
  RowDetailCache,
23523
23591
  RowDetailState,
23592
+ RowDisabledState,
23524
23593
  RowSelectionState,
23525
23594
  WeakFixedSizeSet,
23526
23595
  components,
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "bugs": {
26
26
  "url": "https://github.com/infinite-table/infinite-react/issues"
27
27
  },
28
- "version": "4.4.0",
28
+ "version": "4.4.1",
29
29
  "main": "index.js",
30
30
  "module": "index.mjs",
31
31
  "typings": "index.d.ts",
@@ -34,5 +34,5 @@
34
34
  },
35
35
  "license": "Commercial & Open Source",
36
36
  "//": "will be updated at build time",
37
- "publishedAt": 1724675913899
37
+ "publishedAt": 1724754659215
38
38
  }