@servicetitan/table 29.0.1 → 29.1.0

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 (104) hide show
  1. package/dist/demo/column-hiding/table.js +2 -2
  2. package/dist/demo/column-hiding/table.js.map +1 -1
  3. package/dist/demo/filters/table.store.js +24 -30
  4. package/dist/demo/filters/table.store.js.map +1 -1
  5. package/dist/demo/master-detail/detail-table.js +1 -1
  6. package/dist/demo/master-detail/detail-table.js.map +1 -1
  7. package/dist/demo/master-detail/detail-table.store.js +12 -23
  8. package/dist/demo/master-detail/detail-table.store.js.map +1 -1
  9. package/dist/demo/overview/actions-cell.js +4 -13
  10. package/dist/demo/overview/actions-cell.js.map +1 -1
  11. package/dist/demo/overview/table.d.ts +1 -1
  12. package/dist/demo/overview/table.d.ts.map +1 -1
  13. package/dist/demo/overview/table.js +1 -1
  14. package/dist/demo/overview/table.js.map +1 -1
  15. package/dist/editable-cell/boolean-editable-cell.d.ts +1 -1
  16. package/dist/editable-cell/boolean-editable-cell.d.ts.map +1 -1
  17. package/dist/editable-cell/get-action-cell.d.ts.map +1 -1
  18. package/dist/editable-cell/get-action-cell.js +3 -3
  19. package/dist/editable-cell/get-action-cell.js.map +1 -1
  20. package/dist/editable-cell/get-editable-cell.d.ts.map +1 -1
  21. package/dist/editable-cell/get-editable-cell.js +3 -3
  22. package/dist/editable-cell/get-editable-cell.js.map +1 -1
  23. package/dist/editable-cell/get-select-editable-cell.d.ts +1 -1
  24. package/dist/editable-cell/get-select-editable-cell.d.ts.map +1 -1
  25. package/dist/editable-cell/text-editable-cell.d.ts +2 -2
  26. package/dist/editable-cell/text-editable-cell.d.ts.map +1 -1
  27. package/dist/filters/async-select/async-select-filter.d.ts +1 -1
  28. package/dist/filters/async-select/async-select-filter.d.ts.map +1 -1
  29. package/dist/filters/async-select/async-select-filter.js +4 -25
  30. package/dist/filters/async-select/async-select-filter.js.map +1 -1
  31. package/dist/filters/column-menu-filters.d.ts.map +1 -1
  32. package/dist/filters/column-menu-filters.js +6 -4
  33. package/dist/filters/column-menu-filters.js.map +1 -1
  34. package/dist/filters/datetime-filter/datetime-filter.d.ts +1 -1
  35. package/dist/filters/datetime-filter/datetime-filter.d.ts.map +1 -1
  36. package/dist/filters/field-values-filter.d.ts +1 -1
  37. package/dist/filters/field-values-filter.d.ts.map +1 -1
  38. package/dist/filters/field-values-filter.js +9 -20
  39. package/dist/filters/field-values-filter.js.map +1 -1
  40. package/dist/filters/multiselect-filter/multiselect-filter.d.ts +3 -3
  41. package/dist/filters/multiselect-filter/multiselect-filter.d.ts.map +1 -1
  42. package/dist/filters/numeric-filter-extended/numeric-extended-operators.d.ts.map +1 -1
  43. package/dist/filters/numeric-filter-extended/numeric-filter-extended.js +3 -15
  44. package/dist/filters/numeric-filter-extended/numeric-filter-extended.js.map +1 -1
  45. package/dist/filters/range-filter/range-filter.d.ts +4 -4
  46. package/dist/filters/range-filter/range-filter.d.ts.map +1 -1
  47. package/dist/filters/range-filter/range-filter.js +1 -1
  48. package/dist/filters/range-filter/range-filter.js.map +1 -1
  49. package/dist/filters/select-filter/__tests__/object-search.test.d.ts +2 -0
  50. package/dist/filters/select-filter/__tests__/object-search.test.d.ts.map +1 -0
  51. package/dist/filters/select-filter/__tests__/object-search.test.js +28 -0
  52. package/dist/filters/select-filter/__tests__/object-search.test.js.map +1 -0
  53. package/dist/filters/select-filter/object-search.d.ts.map +1 -1
  54. package/dist/filters/select-filter/operators.d.ts +1 -1
  55. package/dist/filters/select-filter/operators.d.ts.map +1 -1
  56. package/dist/filters/select-filter/select-filter.d.ts +1 -1
  57. package/dist/filters/select-filter/select-filter.d.ts.map +1 -1
  58. package/dist/filters/select-filter/select-filter.js +23 -42
  59. package/dist/filters/select-filter/select-filter.js.map +1 -1
  60. package/dist/filters/select-filter/value-getter.d.ts.map +1 -1
  61. package/dist/filters/single-select/single-select-filter.d.ts +1 -1
  62. package/dist/filters/single-select/single-select-filter.d.ts.map +1 -1
  63. package/dist/filters/single-select/single-select-filter.js +5 -14
  64. package/dist/filters/single-select/single-select-filter.js.map +1 -1
  65. package/dist/filters/standard-filter-with-multiselect/multiselect-operators.d.ts.map +1 -1
  66. package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.d.ts.map +1 -1
  67. package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.js +12 -4
  68. package/dist/filters/standard-filter-with-multiselect/standard-filter-with-multiselect.js.map +1 -1
  69. package/dist/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.js +5 -2
  70. package/dist/filters/standard-filter-with-multiselect/table-column-menu-filter-ext.js.map +1 -1
  71. package/dist/filters/time-filter/time-filter.d.ts +1 -1
  72. package/dist/filters/time-filter/time-filter.d.ts.map +1 -1
  73. package/dist/select-cell/select-cell.js +2 -14
  74. package/dist/select-cell/select-cell.js.map +1 -1
  75. package/dist/table-state.d.ts +1 -1
  76. package/dist/table-state.d.ts.map +1 -1
  77. package/dist/table-state.js +217 -249
  78. package/dist/table-state.js.map +1 -1
  79. package/dist/table.d.ts +1 -1
  80. package/dist/table.d.ts.map +1 -1
  81. package/dist/table.js +8 -19
  82. package/dist/table.js.map +1 -1
  83. package/dist/table.stories.d.ts +11 -0
  84. package/dist/table.stories.d.ts.map +1 -0
  85. package/dist/table.stories.js +12 -0
  86. package/dist/table.stories.js.map +1 -0
  87. package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.js +4 -1
  88. package/dist/use-observing-table-state/demo/stores/use-observing-table-state-demo.store.js.map +1 -1
  89. package/dist/use-observing-table-state/use-observing-table-state.d.ts.map +1 -1
  90. package/dist/utils/__tests__/filters.test.d.ts +2 -0
  91. package/dist/utils/__tests__/filters.test.d.ts.map +1 -0
  92. package/dist/utils/__tests__/filters.test.js +24 -0
  93. package/dist/utils/__tests__/filters.test.js.map +1 -0
  94. package/dist/utils/filters.d.ts +2 -2
  95. package/dist/utils/filters.d.ts.map +1 -1
  96. package/dist/utils/filters.js.map +1 -1
  97. package/package.json +9 -9
  98. package/src/filters/async-select/async-select-filter.tsx +1 -1
  99. package/src/filters/column-menu-filters.tsx +3 -1
  100. package/src/filters/select-filter/select-filter.tsx +2 -2
  101. package/src/table-state.ts +5 -5
  102. package/src/table.tsx +4 -4
  103. package/src/use-observing-table-state/use-observing-table-state.ts +1 -1
  104. package/src/utils/filters.ts +9 -6
@@ -7,15 +7,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12
- return new (P || (P = Promise))(function (resolve, reject) {
13
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
14
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
15
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
16
- step((generator = generator.apply(thisArg, _arguments || [])).next());
17
- });
18
- };
19
10
  import { action, computed, observable, runInAction, makeObservable } from 'mobx';
20
11
  import { fromPromise } from 'mobx-utils';
21
12
  import { formStateToJS } from '@servicetitan/form';
@@ -24,7 +15,10 @@ export function isGroupItem(item, groups) {
24
15
  return !!field && groups.some(g => g.field === field);
25
16
  }
26
17
  function addAggregatesToGroups(groups, aggregates) {
27
- return groups.map(group => (Object.assign(Object.assign({}, group), { aggregates })));
18
+ return groups.map(group => ({
19
+ ...group,
20
+ aggregates,
21
+ }));
28
22
  }
29
23
  export class TableState {
30
24
  get dataSource() {
@@ -252,11 +246,11 @@ export class TableState {
252
246
  enumerable: true,
253
247
  configurable: true,
254
248
  writable: true,
255
- value: () => __awaiter(this, void 0, void 0, function* () {
249
+ value: async () => {
256
250
  if (!this.dataSource) {
257
251
  return;
258
252
  }
259
- const initial = (yield this.dataSource.getData({
253
+ const initial = (await this.dataSource.getData({
260
254
  skip: this.skip,
261
255
  take: this.pageSize,
262
256
  filter: this.filter,
@@ -271,7 +265,7 @@ export class TableState {
271
265
  this.unselectableCount = this.originalData.filter(this.isRowUnselectable).length;
272
266
  this.addPropertiesToRows(this.data);
273
267
  });
274
- })
268
+ }
275
269
  });
276
270
  Object.defineProperty(this, "handleFilterChange", {
277
271
  enumerable: true,
@@ -360,9 +354,9 @@ export class TableState {
360
354
  enumerable: true,
361
355
  configurable: true,
362
356
  writable: true,
363
- value: (...args_1) => __awaiter(this, [...args_1], void 0, function* ({ newSkip, newSort, newFilter, newAggregates, newGroup, } = {}) {
357
+ value: async ({ newSkip, newSort, newFilter, newAggregates, newGroup, } = {}) => {
364
358
  const sort = newSort !== null && newSort !== void 0 ? newSort : [...this.sort];
365
- const filter = newFilter === null ? undefined : newFilter !== null && newFilter !== void 0 ? newFilter : this.filter;
359
+ const filter = newFilter === null ? undefined : (newFilter !== null && newFilter !== void 0 ? newFilter : this.filter);
366
360
  const aggregates = newAggregates !== null && newAggregates !== void 0 ? newAggregates : this.aggregates;
367
361
  const group = addAggregatesToGroups(newGroup !== null && newGroup !== void 0 ? newGroup : this.group, aggregates);
368
362
  const skip = newSort || newFilter !== undefined || newGroup
@@ -379,7 +373,7 @@ export class TableState {
379
373
  });
380
374
  return;
381
375
  }
382
- const newData = (yield this.dataSource.getData({
376
+ const newData = (await this.dataSource.getData({
383
377
  skip,
384
378
  sort,
385
379
  filter,
@@ -425,7 +419,7 @@ export class TableState {
425
419
  this.skip = skip;
426
420
  this.addPropertiesToRows(this.data);
427
421
  });
428
- })
422
+ }
429
423
  });
430
424
  Object.defineProperty(this, "isRowSelectable", {
431
425
  enumerable: true,
@@ -452,22 +446,22 @@ export class TableState {
452
446
  enumerable: true,
453
447
  configurable: true,
454
448
  writable: true,
455
- value: () => __awaiter(this, void 0, void 0, function* () {
449
+ value: async () => {
456
450
  if (this.dataSource && this.tablePdfExport) {
457
- const { data } = yield this.dataSource.getData({}); // fetch all data
451
+ const { data } = await this.dataSource.getData({}); // fetch all data
458
452
  this.tablePdfExport.save(data);
459
453
  }
460
- })
454
+ }
461
455
  });
462
456
  Object.defineProperty(this, "exportExcel", {
463
457
  enumerable: true,
464
458
  configurable: true,
465
459
  writable: true,
466
- value: (data, columns) => __awaiter(this, void 0, void 0, function* () {
460
+ value: async (data, columns) => {
467
461
  if (this.tableExcelExport) {
468
- this.tableExcelExport.save(data !== null && data !== void 0 ? data : (yield this.filteredSortedUnpaginatedData()).data, columns);
462
+ this.tableExcelExport.save(data !== null && data !== void 0 ? data : (await this.filteredSortedUnpaginatedData()).data, columns);
469
463
  }
470
- })
464
+ }
471
465
  });
472
466
  Object.defineProperty(this, "filteredSortedUnpaginatedData", {
473
467
  enumerable: true,
@@ -531,149 +525,133 @@ export class TableState {
531
525
  this.editAll();
532
526
  }
533
527
  }
534
- addToDataSource(row, select, index) {
535
- return __awaiter(this, void 0, void 0, function* () {
536
- if (!this.dataSource) {
537
- return;
528
+ async addToDataSource(row, select, index) {
529
+ if (!this.dataSource) {
530
+ return;
531
+ }
532
+ if (!this.dataSource.addData) {
533
+ throw 'missing addData in the data source';
534
+ }
535
+ await this.dataSource.addData(row, index);
536
+ runInAction(() => {
537
+ this.totalCount += 1;
538
+ if (select) {
539
+ if (!this.dataSource.idSelector) {
540
+ throw 'missing idSelector in the data source';
541
+ }
542
+ this.selectedIds.add(this.dataSource.idSelector(row));
543
+ this.selectedCount += 1;
538
544
  }
539
- if (!this.dataSource.addData) {
540
- throw 'missing addData in the data source';
545
+ if (this.alwaysEditable) {
546
+ this.edit(row);
541
547
  }
542
- yield this.dataSource.addData(row, index);
543
- runInAction(() => {
544
- this.totalCount += 1;
545
- if (select) {
546
- if (!this.dataSource.idSelector) {
547
- throw 'missing idSelector in the data source';
548
- }
549
- this.selectedIds.add(this.dataSource.idSelector(row));
550
- this.selectedCount += 1;
551
- }
552
- if (this.alwaysEditable) {
553
- this.edit(row);
554
- }
555
- });
556
- yield this.fetchData();
557
548
  });
549
+ await this.fetchData();
558
550
  }
559
- removeFromDataSource(id) {
560
- return __awaiter(this, void 0, void 0, function* () {
561
- if (!this.dataSource) {
562
- return;
551
+ async removeFromDataSource(id) {
552
+ if (!this.dataSource) {
553
+ return;
554
+ }
555
+ if (!this.dataSource.removeData) {
556
+ throw 'missing removeData in the data source';
557
+ }
558
+ const row = (await this.dataSource.removeData(id));
559
+ if (!row) {
560
+ return;
561
+ }
562
+ runInAction(() => {
563
+ this.totalCount -= 1;
564
+ // Updating filteredCount here to force Table rerender after this action
565
+ this.filteredCount -= 1;
566
+ if (this.selectedIds.has(id)) {
567
+ this.selectedIds.delete(id);
568
+ this.selectedCount -= 1;
563
569
  }
564
- if (!this.dataSource.removeData) {
565
- throw 'missing removeData in the data source';
570
+ if (this.inEdit.has(id)) {
571
+ this.inEdit.delete(id);
566
572
  }
567
- const row = (yield this.dataSource.removeData(id));
568
- if (!row) {
569
- return;
573
+ if (this.expandedIds.has(id)) {
574
+ this.expandedIds.delete(id);
575
+ }
576
+ });
577
+ // If the current page has only one row and it's removed, fetch the previous page if it exists
578
+ if (this.data.length === 1 && this.pageSize && this.skip >= this.pageSize) {
579
+ await this.fetchData({ newSkip: this.skip - this.pageSize });
580
+ }
581
+ else {
582
+ await this.fetchData();
583
+ }
584
+ return row;
585
+ }
586
+ async setRowsSelection(rows, value, { ignoreUnselectable = true, recursive = true } = {}) {
587
+ if (!this.dataSource) {
588
+ return;
589
+ }
590
+ if (!this.dataSource.idSelector) {
591
+ throw 'missing idSelector in the data source';
592
+ }
593
+ for (const row of rows) {
594
+ if (ignoreUnselectable && this.isRowUnselectable(row)) {
595
+ continue;
570
596
  }
571
597
  runInAction(() => {
572
- this.totalCount -= 1;
573
- // Updating filteredCount here to force Table rerender after this action
574
- this.filteredCount -= 1;
575
- if (this.selectedIds.has(id)) {
576
- this.selectedIds.delete(id);
577
- this.selectedCount -= 1;
598
+ if (!value) {
599
+ this.selectedIds.delete(this.dataSource.idSelector(row));
578
600
  }
579
- if (this.inEdit.has(id)) {
580
- this.inEdit.delete(id);
581
- }
582
- if (this.expandedIds.has(id)) {
583
- this.expandedIds.delete(id);
601
+ else if (this.selectedCount < this.selectionLimit) {
602
+ this.selectedIds.add(this.dataSource.idSelector(row));
584
603
  }
585
604
  });
586
- // If the current page has only one row and it's removed, fetch the previous page if it exists
587
- if (this.data.length === 1 && this.pageSize && this.skip >= this.pageSize) {
588
- yield this.fetchData({ newSkip: this.skip - this.pageSize });
589
- }
590
- else {
591
- yield this.fetchData();
592
- }
593
- return row;
594
- });
595
- }
596
- setRowsSelection(rows_1, value_1) {
597
- return __awaiter(this, arguments, void 0, function* (rows, value, { ignoreUnselectable = true, recursive = true } = {}) {
598
- if (!this.dataSource) {
599
- return;
600
- }
601
- if (!this.dataSource.idSelector) {
602
- throw 'missing idSelector in the data source';
603
- }
604
- for (const row of rows) {
605
- if (ignoreUnselectable && this.isRowUnselectable(row)) {
606
- continue;
605
+ // update children selection
606
+ if (recursive && this.getDetailTableState) {
607
+ const detail = this.getDetailTableState(row);
608
+ if (detail === null || detail === void 0 ? void 0 : detail.selectableCount) {
609
+ // eslint-disable-next-line no-await-in-loop
610
+ await detail.setAllSelection(value);
607
611
  }
608
- runInAction(() => {
609
- if (!value) {
610
- this.selectedIds.delete(this.dataSource.idSelector(row));
611
- }
612
- else if (this.selectedCount < this.selectionLimit) {
613
- this.selectedIds.add(this.dataSource.idSelector(row));
614
- }
612
+ }
613
+ }
614
+ // update parent selection
615
+ if (this.parent) {
616
+ if (this.isAllPageRowsSelected) {
617
+ await this.parent.tableState.setRowsSelection([this.parent.row], true, {
618
+ recursive: false,
615
619
  });
616
- // update children selection
617
- if (recursive && this.getDetailTableState) {
618
- const detail = this.getDetailTableState(row);
619
- if (detail === null || detail === void 0 ? void 0 : detail.selectableCount) {
620
- // eslint-disable-next-line no-await-in-loop
621
- yield detail.setAllSelection(value);
622
- }
623
- }
624
620
  }
625
- // update parent selection
626
- if (this.parent) {
627
- if (this.isAllPageRowsSelected) {
628
- yield this.parent.tableState.setRowsSelection([this.parent.row], true, {
629
- recursive: false,
630
- });
631
- }
632
- else {
633
- yield this.parent.tableState.setRowsSelection([this.parent.row], false, {
634
- recursive: false,
635
- });
636
- }
621
+ else {
622
+ await this.parent.tableState.setRowsSelection([this.parent.row], false, {
623
+ recursive: false,
624
+ });
637
625
  }
638
- runInAction(() => {
639
- this.selectedCount = this.selectedIds.size;
640
- this.data = this.data.slice();
641
- });
626
+ }
627
+ runInAction(() => {
628
+ this.selectedCount = this.selectedIds.size;
629
+ this.data = this.data.slice();
642
630
  });
643
631
  }
644
- selectPage(options) {
645
- return __awaiter(this, void 0, void 0, function* () {
646
- yield this.setRowsSelection(this.originalData, true, options);
647
- });
632
+ async selectPage(options) {
633
+ await this.setRowsSelection(this.originalData, true, options);
648
634
  }
649
- deselectPage(options) {
650
- return __awaiter(this, void 0, void 0, function* () {
651
- yield this.setRowsSelection(this.originalData, false, options);
652
- });
635
+ async deselectPage(options) {
636
+ await this.setRowsSelection(this.originalData, false, options);
653
637
  }
654
- setAllSelection(value, options) {
655
- return __awaiter(this, void 0, void 0, function* () {
656
- if (!this.dataSource) {
657
- return;
658
- }
659
- const filteredData = yield this.dataSource.getData({
660
- filter: this.filter,
661
- });
662
- yield this.setRowsSelection(filteredData.data, value, options);
638
+ async setAllSelection(value, options) {
639
+ if (!this.dataSource) {
640
+ return;
641
+ }
642
+ const filteredData = await this.dataSource.getData({
643
+ filter: this.filter,
663
644
  });
645
+ await this.setRowsSelection(filteredData.data, value, options);
664
646
  }
665
- selectAll(options) {
666
- return __awaiter(this, void 0, void 0, function* () {
667
- if (this.selectionLimit !== Infinity) {
668
- throw "selectAll isn't supported for limited selection";
669
- }
670
- yield this.setAllSelection(true, options);
671
- });
647
+ async selectAll(options) {
648
+ if (this.selectionLimit !== Infinity) {
649
+ throw "selectAll isn't supported for limited selection";
650
+ }
651
+ await this.setAllSelection(true, options);
672
652
  }
673
- deselectAll(options) {
674
- return __awaiter(this, void 0, void 0, function* () {
675
- yield this.setAllSelection(false, options);
676
- });
653
+ async deselectAll(options) {
654
+ await this.setAllSelection(false, options);
677
655
  }
678
656
  edit(row, field) {
679
657
  if (!this.dataSource) {
@@ -691,35 +669,33 @@ export class TableState {
691
669
  });
692
670
  this.data = this.data.slice();
693
671
  }
694
- saveEdit(row, beforeSave) {
695
- return __awaiter(this, void 0, void 0, function* () {
696
- if (!this.dataSource) {
697
- return;
698
- }
699
- if (!this.dataSource.idSelector) {
700
- throw 'missing idSelector in the data source';
701
- }
702
- if (!this.dataSource.updateData) {
703
- throw 'missing updateData in the data source';
704
- }
705
- const id = this.dataSource.idSelector(row);
706
- const editingForm = this.inEdit.get(id);
707
- if (!editingForm) {
708
- return;
709
- }
710
- const { form, field } = editingForm;
711
- const changed = formStateToJS(form); // FIXME: incompatible types
712
- if (beforeSave) {
713
- yield beforeSave(changed, field);
714
- }
715
- yield this.dataSource.updateData(id, changed);
716
- if (!this.alwaysEditable) {
717
- runInAction(() => {
718
- this.inEdit.delete(id);
719
- });
720
- }
721
- yield this.fetchData();
722
- });
672
+ async saveEdit(row, beforeSave) {
673
+ if (!this.dataSource) {
674
+ return;
675
+ }
676
+ if (!this.dataSource.idSelector) {
677
+ throw 'missing idSelector in the data source';
678
+ }
679
+ if (!this.dataSource.updateData) {
680
+ throw 'missing updateData in the data source';
681
+ }
682
+ const id = this.dataSource.idSelector(row);
683
+ const editingForm = this.inEdit.get(id);
684
+ if (!editingForm) {
685
+ return;
686
+ }
687
+ const { form, field } = editingForm;
688
+ const changed = formStateToJS(form); // FIXME: incompatible types
689
+ if (beforeSave) {
690
+ await beforeSave(changed, field);
691
+ }
692
+ await this.dataSource.updateData(id, changed);
693
+ if (!this.alwaysEditable) {
694
+ runInAction(() => {
695
+ this.inEdit.delete(id);
696
+ });
697
+ }
698
+ await this.fetchData();
723
699
  }
724
700
  cancelEdit(row) {
725
701
  if (!this.dataSource) {
@@ -734,55 +710,51 @@ export class TableState {
734
710
  this.inEdit.delete(this.dataSource.idSelector(row));
735
711
  this.data = this.data.slice();
736
712
  }
737
- editAll() {
738
- return __awaiter(this, void 0, void 0, function* () {
739
- if (!this.dataSource) {
740
- return;
741
- }
742
- if (!this.dataSource.idSelector) {
743
- throw 'missing idSelector in the data source';
744
- }
745
- if (!this.getFormState) {
746
- throw 'missing getFormState';
747
- }
748
- const rows = (yield this.dataSource.getData({
749
- filter: this.filter,
750
- })).data;
751
- runInAction(() => {
752
- this.inEdit = new Map(rows.map(row => [
753
- this.dataSource.idSelector(row),
754
- { form: this.getFormState(row) },
755
- ]));
756
- this.data = this.data.slice();
757
- });
713
+ async editAll() {
714
+ if (!this.dataSource) {
715
+ return;
716
+ }
717
+ if (!this.dataSource.idSelector) {
718
+ throw 'missing idSelector in the data source';
719
+ }
720
+ if (!this.getFormState) {
721
+ throw 'missing getFormState';
722
+ }
723
+ const rows = (await this.dataSource.getData({
724
+ filter: this.filter,
725
+ })).data;
726
+ runInAction(() => {
727
+ this.inEdit = new Map(rows.map(row => [
728
+ this.dataSource.idSelector(row),
729
+ { form: this.getFormState(row) },
730
+ ]));
731
+ this.data = this.data.slice();
758
732
  });
759
733
  }
760
- saveEditAll(beforeSave) {
761
- return __awaiter(this, void 0, void 0, function* () {
762
- if (!this.dataSource) {
763
- return;
764
- }
765
- if (!this.dataSource.updateData) {
766
- throw 'missing updateData in the data source';
767
- }
768
- const changes = Array.from(this.inEdit).map(([id, { form }]) => ({
769
- id,
770
- changed: formStateToJS(form), // FIXME: incompatible types
771
- }));
772
- if (beforeSave) {
773
- yield beforeSave(changes.map(change => change.changed));
774
- }
775
- for (const { id, changed } of changes) {
776
- // eslint-disable-next-line no-await-in-loop
777
- yield this.dataSource.updateData(id, changed);
778
- }
779
- if (!this.alwaysEditable) {
780
- runInAction(() => {
781
- this.inEdit = new Map();
782
- });
783
- }
784
- yield this.fetchData();
785
- });
734
+ async saveEditAll(beforeSave) {
735
+ if (!this.dataSource) {
736
+ return;
737
+ }
738
+ if (!this.dataSource.updateData) {
739
+ throw 'missing updateData in the data source';
740
+ }
741
+ const changes = Array.from(this.inEdit).map(([id, { form }]) => ({
742
+ id,
743
+ changed: formStateToJS(form), // FIXME: incompatible types
744
+ }));
745
+ if (beforeSave) {
746
+ await beforeSave(changes.map(change => change.changed));
747
+ }
748
+ for (const { id, changed } of changes) {
749
+ // eslint-disable-next-line no-await-in-loop
750
+ await this.dataSource.updateData(id, changed);
751
+ }
752
+ if (!this.alwaysEditable) {
753
+ runInAction(() => {
754
+ this.inEdit = new Map();
755
+ });
756
+ }
757
+ await this.fetchData();
786
758
  }
787
759
  cancelEditAll() {
788
760
  if (!this.dataSource) {
@@ -809,25 +781,23 @@ export class TableState {
809
781
  this.aggregates = [];
810
782
  this.innerGroup = [];
811
783
  }
812
- setDataSource(dataSource, setDataSourceParams) {
813
- return __awaiter(this, void 0, void 0, function* () {
814
- this.innerDataSource = dataSource;
815
- this.skip = 0;
816
- const reset = typeof setDataSourceParams === 'boolean'
817
- ? setDataSourceParams
818
- : setDataSourceParams === null || setDataSourceParams === void 0 ? void 0 : setDataSourceParams.reset;
819
- const config = setDataSourceParams;
820
- if (reset) {
821
- this.reset();
822
- }
823
- if (config === null || config === void 0 ? void 0 : config.initialState) {
824
- this.importState(config.initialState);
825
- }
826
- yield this.fetchInitialData();
827
- if (this.alwaysEditable) {
828
- yield this.editAll();
829
- }
830
- });
784
+ async setDataSource(dataSource, setDataSourceParams) {
785
+ this.innerDataSource = dataSource;
786
+ this.skip = 0;
787
+ const reset = typeof setDataSourceParams === 'boolean'
788
+ ? setDataSourceParams
789
+ : setDataSourceParams === null || setDataSourceParams === void 0 ? void 0 : setDataSourceParams.reset;
790
+ const config = setDataSourceParams;
791
+ if (reset) {
792
+ this.reset();
793
+ }
794
+ if (config === null || config === void 0 ? void 0 : config.initialState) {
795
+ this.importState(config.initialState);
796
+ }
797
+ await this.fetchInitialData();
798
+ if (this.alwaysEditable) {
799
+ await this.editAll();
800
+ }
831
801
  }
832
802
  addPropertiesToRows(data) {
833
803
  this.traverse(data, item => {
@@ -877,16 +847,14 @@ export class TableState {
877
847
  }
878
848
  });
879
849
  }
880
- toggleRowSelection(row, options) {
881
- return __awaiter(this, void 0, void 0, function* () {
882
- if (!this.dataSource) {
883
- return;
884
- }
885
- if (!this.dataSource.idSelector) {
886
- throw 'missing idSelector in the data source';
887
- }
888
- yield this.setRowsSelection([row], !this.selectedIds.has(this.dataSource.idSelector(row)), options);
889
- });
850
+ async toggleRowSelection(row, options) {
851
+ if (!this.dataSource) {
852
+ return;
853
+ }
854
+ if (!this.dataSource.idSelector) {
855
+ throw 'missing idSelector in the data source';
856
+ }
857
+ await this.setRowsSelection([row], !this.selectedIds.has(this.dataSource.idSelector(row)), options);
890
858
  }
891
859
  get isAllPageRowsSelected() {
892
860
  return (this.originalData.some(row => row.selected) &&