@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.js CHANGED
@@ -139,6 +139,7 @@ __export(src_exports, {
139
139
  Menu: () => Menu,
140
140
  RowDetailCache: () => RowDetailCache,
141
141
  RowDetailState: () => RowDetailState,
142
+ RowDisabledState: () => RowDisabledState,
142
143
  RowSelectionState: () => RowSelectionState,
143
144
  WeakFixedSizeSet: () => WeakFixedSizeSet,
144
145
  components: () => components,
@@ -12947,6 +12948,203 @@ function getRowInfoArray(getState) {
12947
12948
  return getState().dataArray;
12948
12949
  }
12949
12950
 
12951
+ // src/components/DataSource/BooleanCollectionState.ts
12952
+ var BooleanCollectionState = class {
12953
+ constructor(state) {
12954
+ const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? (
12955
+ //@ts-ignore
12956
+ state.getState()
12957
+ ) : state;
12958
+ const positiveItems = this.getPositiveFromState(stateObject);
12959
+ const negativeItems = this.getNegativeFromState(stateObject);
12960
+ this.update({
12961
+ negativeItems,
12962
+ positiveItems
12963
+ });
12964
+ }
12965
+ getInitialState() {
12966
+ return this.initialState;
12967
+ }
12968
+ // protected getState(): BooleanCollectionStateObject<KeyType> {
12969
+ // return {
12970
+ // positiveItems: this.allPositive
12971
+ // ? true
12972
+ // : this.positiveMap?.topDownKeys() ?? [],
12973
+ // negativeItems: this.allNegative
12974
+ // ? true
12975
+ // : this.negativeMap?.topDownKeys() ?? [],
12976
+ // };
12977
+ // }
12978
+ destroy() {
12979
+ var _a, _b;
12980
+ (_a = this.positiveMap) == null ? void 0 : _a.clear();
12981
+ (_b = this.negativeMap) == null ? void 0 : _b.clear();
12982
+ delete this.positiveMap;
12983
+ delete this.negativeMap;
12984
+ }
12985
+ update(state) {
12986
+ const { positiveItems, negativeItems } = state;
12987
+ this.allNegative = negativeItems === true;
12988
+ this.allPositive = positiveItems === true;
12989
+ if (this.allNegative && this.allPositive) {
12990
+ throw `Cannot have both negativeItems and positiveItems be true!`;
12991
+ }
12992
+ if (negativeItems && negativeItems !== true) {
12993
+ if (!this.negativeMap) {
12994
+ this.negativeMap = /* @__PURE__ */ new Map();
12995
+ }
12996
+ this.negativeMap.clear();
12997
+ for (let k of negativeItems) {
12998
+ this.negativeMap.set(k, true);
12999
+ }
13000
+ if (this.positiveMap) {
13001
+ this.positiveMap.clear();
13002
+ }
13003
+ }
13004
+ if (positiveItems && positiveItems !== true) {
13005
+ if (!this.positiveMap) {
13006
+ this.positiveMap = /* @__PURE__ */ new Map();
13007
+ }
13008
+ this.positiveMap.clear();
13009
+ for (let k of positiveItems) {
13010
+ this.positiveMap.set(k, true);
13011
+ }
13012
+ if (this.negativeMap) {
13013
+ this.negativeMap.clear();
13014
+ }
13015
+ }
13016
+ }
13017
+ isDefaultNegativeSelection() {
13018
+ return this.allNegative;
13019
+ }
13020
+ isDefaultPositiveSelection() {
13021
+ return this.allPositive;
13022
+ }
13023
+ areAllNegative() {
13024
+ return this.allNegative && (this.positiveMap ? this.positiveMap.size === 0 : true);
13025
+ }
13026
+ areAllPositive() {
13027
+ return this.allPositive && (this.negativeMap ? this.negativeMap.size === 0 : true);
13028
+ }
13029
+ makeAllNegative() {
13030
+ this.update({
13031
+ negativeItems: true,
13032
+ positiveItems: []
13033
+ });
13034
+ }
13035
+ makeAllPositive() {
13036
+ this.update({
13037
+ positiveItems: true,
13038
+ negativeItems: []
13039
+ });
13040
+ }
13041
+ isItemPositive(key) {
13042
+ var _a, _b;
13043
+ if (this.allPositive === true) {
13044
+ if (this.allNegative === true) {
13045
+ throw 'Cannot have both positiveItems and negativeItems be "true"';
13046
+ }
13047
+ return !((_a = this.negativeMap) == null ? void 0 : _a.has(key));
13048
+ }
13049
+ return !!((_b = this.positiveMap) == null ? void 0 : _b.has(key));
13050
+ }
13051
+ isItemNegative(key) {
13052
+ return !this.isItemPositive(key);
13053
+ }
13054
+ setItemValue(key, shouldMakePositive) {
13055
+ var _a;
13056
+ if (shouldMakePositive === this.isItemPositive(key)) {
13057
+ return;
13058
+ }
13059
+ if (shouldMakePositive) {
13060
+ if (this.allNegative === true) {
13061
+ if (!this.positiveMap) {
13062
+ throw `No positiveMap found when trying to set item ${key} be positive`;
13063
+ }
13064
+ this.positiveMap.set(key, true);
13065
+ } else if (this.allPositive === true) {
13066
+ if (!this.negativeMap) {
13067
+ throw `No negativeMap found when trying to set item ${key} be positive`;
13068
+ }
13069
+ this.negativeMap.delete(key);
13070
+ }
13071
+ } else {
13072
+ if (this.allPositive === true) {
13073
+ if (!this.negativeMap) {
13074
+ throw `No negativeMap found when trying to set item ${key} be negative`;
13075
+ }
13076
+ this.negativeMap.set(key, true);
13077
+ } else if (this.allNegative === true) {
13078
+ if (!this.positiveMap) {
13079
+ throw `No positiveMap found when trying to set item ${key} be negative`;
13080
+ }
13081
+ (_a = this.positiveMap) == null ? void 0 : _a.delete(key);
13082
+ }
13083
+ }
13084
+ }
13085
+ makeItemNegative(key) {
13086
+ this.setItemValue(key, false);
13087
+ }
13088
+ makeItemPositive(key) {
13089
+ this.setItemValue(key, true);
13090
+ }
13091
+ toggleItem(key) {
13092
+ this.setItemValue(key, !this.isItemPositive(key));
13093
+ }
13094
+ };
13095
+
13096
+ // src/components/DataSource/RowDisabledState.ts
13097
+ var RowDisabledState = class extends BooleanCollectionState {
13098
+ constructor(state) {
13099
+ super(state);
13100
+ this.isRowEnabled = (key) => {
13101
+ return !!this.isItemPositive(key);
13102
+ };
13103
+ }
13104
+ getState() {
13105
+ var _a, _b, _c, _d;
13106
+ const enabledRows = this.allPositive ? true : [...(_b = (_a = this.positiveMap) == null ? void 0 : _a.keys()) != null ? _b : []];
13107
+ const disabledRows = this.allNegative ? true : [...(_d = (_c = this.negativeMap) == null ? void 0 : _c.keys()) != null ? _d : []];
13108
+ return {
13109
+ enabledRows,
13110
+ disabledRows
13111
+ };
13112
+ }
13113
+ getPositiveFromState(state) {
13114
+ return state.enabledRows;
13115
+ }
13116
+ getNegativeFromState(state) {
13117
+ return state.disabledRows;
13118
+ }
13119
+ areAllDisabled() {
13120
+ return this.areAllNegative();
13121
+ }
13122
+ areAllEnabled() {
13123
+ return this.areAllPositive();
13124
+ }
13125
+ disableAll() {
13126
+ this.makeAllNegative();
13127
+ }
13128
+ enableAll() {
13129
+ this.makeAllPositive();
13130
+ }
13131
+ isRowDisabled(key) {
13132
+ return !this.isRowEnabled(key);
13133
+ }
13134
+ setRowEnabled(key, enabled) {
13135
+ return this.setItemValue(key, enabled);
13136
+ }
13137
+ disableRow(key) {
13138
+ this.setRowEnabled(key, false);
13139
+ }
13140
+ enableRow(key) {
13141
+ this.setRowEnabled(key, true);
13142
+ }
13143
+ toggleRow(key) {
13144
+ this.toggleItem(key);
13145
+ }
13146
+ };
13147
+
12950
13148
  // src/components/DataSource/getDataSourceApi.ts
12951
13149
  function getDataSourceApi(param) {
12952
13150
  return new DataSourceApiImpl(param);
@@ -13100,6 +13298,70 @@ var DataSourceApiImpl = class {
13100
13298
  this.actions.sortInfo = sortInfo;
13101
13299
  return;
13102
13300
  };
13301
+ this.isRowDisabledAt = (rowIndex) => {
13302
+ var _a;
13303
+ const rowInfo = this.getRowInfoByIndex(rowIndex);
13304
+ return (_a = rowInfo == null ? void 0 : rowInfo.rowDisabled) != null ? _a : false;
13305
+ };
13306
+ this.isRowDisabled = (primaryKey) => {
13307
+ var _a;
13308
+ const rowInfo = this.getRowInfoByPrimaryKey(primaryKey);
13309
+ return (_a = rowInfo == null ? void 0 : rowInfo.rowDisabled) != null ? _a : false;
13310
+ };
13311
+ this.setRowEnabledAt = (rowIndex, enabled) => {
13312
+ const currentRowDisabledState = this.getState().rowDisabledState;
13313
+ const rowDisabledState = currentRowDisabledState ? new RowDisabledState(currentRowDisabledState) : new RowDisabledState({
13314
+ enabledRows: true,
13315
+ disabledRows: []
13316
+ });
13317
+ const rowInfo = this.getRowInfoByIndex(rowIndex);
13318
+ if (!rowInfo) {
13319
+ return;
13320
+ }
13321
+ rowDisabledState.setRowEnabled(rowInfo.id, enabled);
13322
+ this.actions.rowDisabledState = rowDisabledState;
13323
+ };
13324
+ this.setRowEnabled = (primaryKey, enabled) => {
13325
+ const rowInfo = this.getRowInfoByPrimaryKey(primaryKey);
13326
+ if (!rowInfo) {
13327
+ return;
13328
+ }
13329
+ this.setRowEnabledAt(rowInfo.indexInAll, enabled);
13330
+ };
13331
+ this.enableAllRows = () => {
13332
+ const currentRowDisabledState = this.getState().rowDisabledState;
13333
+ if (!currentRowDisabledState) {
13334
+ this.actions.rowDisabledState = new RowDisabledState({
13335
+ enabledRows: true,
13336
+ disabledRows: []
13337
+ });
13338
+ return;
13339
+ }
13340
+ const rowDisabledState = new RowDisabledState(currentRowDisabledState);
13341
+ rowDisabledState.enableAll();
13342
+ this.actions.rowDisabledState = rowDisabledState;
13343
+ };
13344
+ this.disableAllRows = () => {
13345
+ const currentRowDisabledState = this.getState().rowDisabledState;
13346
+ if (!currentRowDisabledState) {
13347
+ this.actions.rowDisabledState = new RowDisabledState({
13348
+ disabledRows: true,
13349
+ enabledRows: []
13350
+ });
13351
+ return;
13352
+ }
13353
+ const rowDisabledState = new RowDisabledState(currentRowDisabledState);
13354
+ rowDisabledState.disableAll();
13355
+ this.actions.rowDisabledState = rowDisabledState;
13356
+ };
13357
+ this.areAllRowsEnabled = () => {
13358
+ const rowDisabledState = this.getState().rowDisabledState;
13359
+ return rowDisabledState ? rowDisabledState.areAllEnabled() : true;
13360
+ };
13361
+ this.areAllRowsDisabled = () => {
13362
+ const rowDisabledState = this.getState().rowDisabledState;
13363
+ return rowDisabledState ? rowDisabledState.areAllDisabled() : false;
13364
+ };
13103
13365
  this.getState = param.getState;
13104
13366
  this.actions = param.actions;
13105
13367
  }
@@ -13505,6 +13767,10 @@ function concludeReducer(params) {
13505
13767
  const groupBy = state.groupBy;
13506
13768
  const pivotBy = state.pivotBy;
13507
13769
  const shouldGroup = groupBy.length > 0 || !!pivotBy;
13770
+ const rowDisabledStateDepsChanged = haveDepsChanged(previousState, state, [
13771
+ "rowDisabledState",
13772
+ "isRowDisabled"
13773
+ ]);
13508
13774
  const selectionDepsChanged = haveDepsChanged(previousState, state, [
13509
13775
  "rowSelection",
13510
13776
  "cellSelection",
@@ -13526,7 +13792,7 @@ function concludeReducer(params) {
13526
13792
  const rowInfoReducersChanged = haveDepsChanged(previousState, state, [
13527
13793
  "rowInfoReducers"
13528
13794
  ]);
13529
- const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray || cacheAffectedParts.groupBy) || selectionDepsChanged || rowInfoReducersChanged;
13795
+ const shouldGroupAgain = shouldGroup && (groupsDepsChanged || !state.lastGroupDataArray || cacheAffectedParts.groupBy) || selectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged;
13530
13796
  const now = Date.now();
13531
13797
  let dataArray = state.originalDataArray;
13532
13798
  if (!shouldFilter) {
@@ -13671,7 +13937,7 @@ function concludeReducer(params) {
13671
13937
  state.pivotColumns = void 0;
13672
13938
  state.groupRowsIndexesInDataArray = void 0;
13673
13939
  const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
13674
- if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged || rowInfoReducersChanged) {
13940
+ if (arrayDifferentAfterSortStep || groupsDepsChanged || selectionDepsChanged || rowDisabledStateDepsChanged || rowInfoReducersChanged) {
13675
13941
  const rowInfoReducerKeys = Object.keys(
13676
13942
  rowInfoReducers || {}
13677
13943
  );
@@ -14423,203 +14689,6 @@ var normalizeSortInfo = (initialSortInfo, weakMap3) => {
14423
14689
  return result;
14424
14690
  };
14425
14691
 
14426
- // src/components/DataSource/BooleanCollectionState.ts
14427
- var BooleanCollectionState = class {
14428
- constructor(state) {
14429
- const stateObject = state instanceof Object.getPrototypeOf(this).constructor ? (
14430
- //@ts-ignore
14431
- state.getState()
14432
- ) : state;
14433
- const positiveItems = this.getPositiveFromState(stateObject);
14434
- const negativeItems = this.getNegativeFromState(stateObject);
14435
- this.update({
14436
- negativeItems,
14437
- positiveItems
14438
- });
14439
- }
14440
- getInitialState() {
14441
- return this.initialState;
14442
- }
14443
- // protected getState(): BooleanCollectionStateObject<KeyType> {
14444
- // return {
14445
- // positiveItems: this.allPositive
14446
- // ? true
14447
- // : this.positiveMap?.topDownKeys() ?? [],
14448
- // negativeItems: this.allNegative
14449
- // ? true
14450
- // : this.negativeMap?.topDownKeys() ?? [],
14451
- // };
14452
- // }
14453
- destroy() {
14454
- var _a, _b;
14455
- (_a = this.positiveMap) == null ? void 0 : _a.clear();
14456
- (_b = this.negativeMap) == null ? void 0 : _b.clear();
14457
- delete this.positiveMap;
14458
- delete this.negativeMap;
14459
- }
14460
- update(state) {
14461
- const { positiveItems, negativeItems } = state;
14462
- this.allNegative = negativeItems === true;
14463
- this.allPositive = positiveItems === true;
14464
- if (this.allNegative && this.allPositive) {
14465
- throw `Cannot have both negativeItems and positiveItems be true!`;
14466
- }
14467
- if (negativeItems && negativeItems !== true) {
14468
- if (!this.negativeMap) {
14469
- this.negativeMap = /* @__PURE__ */ new Map();
14470
- }
14471
- this.negativeMap.clear();
14472
- for (let k of negativeItems) {
14473
- this.negativeMap.set(k, true);
14474
- }
14475
- if (this.positiveMap) {
14476
- this.positiveMap.clear();
14477
- }
14478
- }
14479
- if (positiveItems && positiveItems !== true) {
14480
- if (!this.positiveMap) {
14481
- this.positiveMap = /* @__PURE__ */ new Map();
14482
- }
14483
- this.positiveMap.clear();
14484
- for (let k of positiveItems) {
14485
- this.positiveMap.set(k, true);
14486
- }
14487
- if (this.negativeMap) {
14488
- this.negativeMap.clear();
14489
- }
14490
- }
14491
- }
14492
- isDefaultNegativeSelection() {
14493
- return this.allNegative;
14494
- }
14495
- isDefaultPositiveSelection() {
14496
- return this.allPositive;
14497
- }
14498
- areAllNegative() {
14499
- return this.allNegative && (this.positiveMap ? this.positiveMap.size === 0 : true);
14500
- }
14501
- areAllPositive() {
14502
- return this.allPositive && (this.negativeMap ? this.negativeMap.size === 0 : true);
14503
- }
14504
- makeAllNegative() {
14505
- this.update({
14506
- negativeItems: true,
14507
- positiveItems: []
14508
- });
14509
- }
14510
- makeAllPositive() {
14511
- this.update({
14512
- positiveItems: true,
14513
- negativeItems: []
14514
- });
14515
- }
14516
- isItemPositive(key) {
14517
- var _a, _b;
14518
- if (this.allPositive === true) {
14519
- if (this.allNegative === true) {
14520
- throw 'Cannot have both positiveItems and negativeItems be "true"';
14521
- }
14522
- return !((_a = this.negativeMap) == null ? void 0 : _a.has(key));
14523
- }
14524
- return !!((_b = this.positiveMap) == null ? void 0 : _b.has(key));
14525
- }
14526
- isItemNegative(key) {
14527
- return !this.isItemPositive(key);
14528
- }
14529
- setItemValue(key, shouldMakePositive) {
14530
- var _a;
14531
- if (shouldMakePositive === this.isItemPositive(key)) {
14532
- return;
14533
- }
14534
- if (shouldMakePositive) {
14535
- if (this.allNegative === true) {
14536
- if (!this.positiveMap) {
14537
- throw `No positiveMap found when trying to set item ${key} be positive`;
14538
- }
14539
- this.positiveMap.set(key, true);
14540
- } else if (this.allPositive === true) {
14541
- if (!this.negativeMap) {
14542
- throw `No negativeMap found when trying to set item ${key} be positive`;
14543
- }
14544
- this.negativeMap.delete(key);
14545
- }
14546
- } else {
14547
- if (this.allPositive === true) {
14548
- if (!this.negativeMap) {
14549
- throw `No negativeMap found when trying to set item ${key} be negative`;
14550
- }
14551
- this.negativeMap.set(key, true);
14552
- } else if (this.allNegative === true) {
14553
- if (!this.positiveMap) {
14554
- throw `No positiveMap found when trying to set item ${key} be negative`;
14555
- }
14556
- (_a = this.positiveMap) == null ? void 0 : _a.delete(key);
14557
- }
14558
- }
14559
- }
14560
- makeItemNegative(key) {
14561
- this.setItemValue(key, false);
14562
- }
14563
- makeItemPositive(key) {
14564
- this.setItemValue(key, true);
14565
- }
14566
- toggleItem(key) {
14567
- this.setItemValue(key, !this.isItemPositive(key));
14568
- }
14569
- };
14570
-
14571
- // src/components/DataSource/RowDisabledState.ts
14572
- var RowDisabledState = class extends BooleanCollectionState {
14573
- constructor(state) {
14574
- super(state);
14575
- this.isRowEnabled = (key) => {
14576
- return !!this.isItemPositive(key);
14577
- };
14578
- }
14579
- getState() {
14580
- var _a, _b, _c, _d;
14581
- const enabledRows = this.allPositive ? true : [...(_b = (_a = this.positiveMap) == null ? void 0 : _a.keys()) != null ? _b : []];
14582
- const disabledRows = this.allNegative ? true : [...(_d = (_c = this.negativeMap) == null ? void 0 : _c.keys()) != null ? _d : []];
14583
- return {
14584
- enabledRows,
14585
- disabledRows
14586
- };
14587
- }
14588
- getPositiveFromState(state) {
14589
- return state.enabledRows;
14590
- }
14591
- getNegativeFromState(state) {
14592
- return state.disabledRows;
14593
- }
14594
- areAllDisabled() {
14595
- return this.areAllNegative();
14596
- }
14597
- areAllEnabled() {
14598
- return this.areAllPositive();
14599
- }
14600
- disableAll() {
14601
- this.makeAllNegative();
14602
- }
14603
- enableAll() {
14604
- this.makeAllPositive();
14605
- }
14606
- isRowDisabled(key) {
14607
- return !this.isRowEnabled(key);
14608
- }
14609
- setRowEnabled(key, shouldExpand) {
14610
- return this.setItemValue(key, shouldExpand);
14611
- }
14612
- disableRow(key) {
14613
- this.setRowEnabled(key, false);
14614
- }
14615
- enableRow(key) {
14616
- this.setRowEnabled(key, true);
14617
- }
14618
- toggleRow(key) {
14619
- this.toggleItem(key);
14620
- }
14621
- };
14622
-
14623
14692
  // src/components/DataSource/state/getInitialState.ts
14624
14693
  var DataSourceLogger = dbg("DataSource");
14625
14694
  var defaultCursorId = Symbol("cursorId");
@@ -19080,7 +19149,7 @@ var useLicense = (licenseKey = "") => {
19080
19149
  }
19081
19150
  let valid2 = isValidLicense(licenseKey, {
19082
19151
  publishedAt: 1624970570587,
19083
- version: "4.4.0"
19152
+ version: "4.4.1"
19084
19153
  });
19085
19154
  if (!licenseKey && !valid2 && isInsidePlayground) {
19086
19155
  return true;
@@ -23540,6 +23609,7 @@ var components = {
23540
23609
  Menu,
23541
23610
  RowDetailCache,
23542
23611
  RowDetailState,
23612
+ RowDisabledState,
23543
23613
  RowSelectionState,
23544
23614
  WeakFixedSizeSet,
23545
23615
  components,