@slickgrid-universal/vanilla-bundle 5.13.4 → 9.0.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 (52) hide show
  1. package/README.md +0 -3
  2. package/dist/{types/components → components}/slick-vanilla-grid-bundle.d.ts +5 -5
  3. package/dist/components/slick-vanilla-grid-bundle.d.ts.map +1 -0
  4. package/dist/{esm/components → components}/slick-vanilla-grid-bundle.js +41 -83
  5. package/dist/components/slick-vanilla-grid-bundle.js.map +1 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/interfaces/index.d.ts.map +1 -0
  9. package/dist/{cjs/interfaces → interfaces}/index.js.map +1 -1
  10. package/dist/{types/interfaces → interfaces}/slickerGridInstance.interface.d.ts +0 -2
  11. package/dist/interfaces/slickerGridInstance.interface.d.ts.map +1 -0
  12. package/dist/interfaces/slickerGridInstance.interface.js.map +1 -0
  13. package/dist/services/index.d.ts.map +1 -0
  14. package/dist/services/index.js.map +1 -0
  15. package/dist/services/universalContainer.service.d.ts.map +1 -0
  16. package/dist/services/universalContainer.service.js.map +1 -0
  17. package/package.json +15 -18
  18. package/src/components/slick-vanilla-grid-bundle.ts +45 -93
  19. package/src/interfaces/slickerGridInstance.interface.ts +0 -3
  20. package/dist/cjs/components/slick-vanilla-grid-bundle.js +0 -1335
  21. package/dist/cjs/components/slick-vanilla-grid-bundle.js.map +0 -1
  22. package/dist/cjs/index.js +0 -55
  23. package/dist/cjs/index.js.map +0 -1
  24. package/dist/cjs/interfaces/index.js +0 -3
  25. package/dist/cjs/interfaces/slickerGridInstance.interface.js +0 -3
  26. package/dist/cjs/interfaces/slickerGridInstance.interface.js.map +0 -1
  27. package/dist/cjs/services/index.js +0 -18
  28. package/dist/cjs/services/index.js.map +0 -1
  29. package/dist/cjs/services/universalContainer.service.js +0 -26
  30. package/dist/cjs/services/universalContainer.service.js.map +0 -1
  31. package/dist/esm/components/slick-vanilla-grid-bundle.js.map +0 -1
  32. package/dist/esm/index.js.map +0 -1
  33. package/dist/esm/interfaces/index.js.map +0 -1
  34. package/dist/esm/interfaces/slickerGridInstance.interface.js.map +0 -1
  35. package/dist/esm/services/index.js.map +0 -1
  36. package/dist/esm/services/universalContainer.service.js.map +0 -1
  37. package/dist/tsconfig.tsbuildinfo +0 -1
  38. package/dist/types/components/slick-vanilla-grid-bundle.d.ts.map +0 -1
  39. package/dist/types/index.d.ts.map +0 -1
  40. package/dist/types/interfaces/index.d.ts.map +0 -1
  41. package/dist/types/interfaces/slickerGridInstance.interface.d.ts.map +0 -1
  42. package/dist/types/services/index.d.ts.map +0 -1
  43. package/dist/types/services/universalContainer.service.d.ts.map +0 -1
  44. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  45. /package/dist/{esm/index.js → index.js} +0 -0
  46. /package/dist/{types/interfaces → interfaces}/index.d.ts +0 -0
  47. /package/dist/{esm/interfaces → interfaces}/index.js +0 -0
  48. /package/dist/{esm/interfaces → interfaces}/slickerGridInstance.interface.js +0 -0
  49. /package/dist/{types/services → services}/index.d.ts +0 -0
  50. /package/dist/{esm/services → services}/index.js +0 -0
  51. /package/dist/{types/services → services}/universalContainer.service.d.ts +0 -0
  52. /package/dist/{esm/services → services}/universalContainer.service.js +0 -0
@@ -21,7 +21,6 @@ import {
21
21
  autoAddEditorFormatterToColumnsWithEditor,
22
22
  type AutocompleterEditor,
23
23
  GlobalGridOptions,
24
- GridStateType,
25
24
  SlickGroupItemMetadataProvider,
26
25
 
27
26
  // services
@@ -47,6 +46,7 @@ import {
47
46
 
48
47
  // utilities
49
48
  emptyElement,
49
+ fetchAsPromise,
50
50
  isColumnDateType,
51
51
  SlickEventHandler,
52
52
  SlickDataView,
@@ -69,7 +69,7 @@ export class SlickVanillaGridBundle<TData = any> {
69
69
  protected _eventPubSubService!: EventPubSubService;
70
70
  protected _darkMode = false;
71
71
  protected _collectionObservers: Array<null | { disconnect: () => void }> = [];
72
- protected _columnDefinitions?: Column<TData>[];
72
+ protected _columns?: Column<TData>[];
73
73
  protected _gridOptions: GridOption = {};
74
74
  protected _gridContainerElm!: HTMLElement;
75
75
  protected _gridParentContainerElm!: HTMLElement;
@@ -139,10 +139,10 @@ export class SlickVanillaGridBundle<TData = any> {
139
139
  }
140
140
 
141
141
  get columnDefinitions(): Column<TData>[] {
142
- return this._columnDefinitions || [];
142
+ return this._columns || [];
143
143
  }
144
- set columnDefinitions(columnDefinitions: Column<TData>[]) {
145
- this.columnDefinitionsChanged(columnDefinitions);
144
+ set columnDefinitions(columns: Column<TData>[]) {
145
+ this.columnDefinitionsChanged(columns);
146
146
  }
147
147
 
148
148
  get dataset(): TData[] {
@@ -333,9 +333,9 @@ export class SlickVanillaGridBundle<TData = any> {
333
333
  // we only want to do this check once in the constructor
334
334
  this._hideHeaderRowAfterPageLoad = options?.showHeaderRow === false;
335
335
 
336
- this._columnDefinitions = columnDefs || [];
337
- if (this._columnDefinitions.length > 0) {
338
- this.copyColumnWidthsReference(this._columnDefinitions);
336
+ this._columns = columnDefs || [];
337
+ if (this._columns.length > 0) {
338
+ this.copyColumnWidthsReference(this._columns);
339
339
  }
340
340
 
341
341
  // save resource refs to register before the grid options are merged and possibly deep copied
@@ -486,7 +486,7 @@ export class SlickVanillaGridBundle<TData = any> {
486
486
  (this.sharedService as any)[prop] = null;
487
487
  }
488
488
  this.datasetHierarchical = undefined;
489
- this._columnDefinitions = [];
489
+ this._columns = [];
490
490
 
491
491
  // we could optionally also empty the content of the grid container DOM element
492
492
  if (shouldEmptyDomElementContainer) {
@@ -555,16 +555,16 @@ export class SlickVanillaGridBundle<TData = any> {
555
555
  this.preRegisterResources();
556
556
 
557
557
  // prepare and load all SlickGrid editors, if an async editor is found then we'll also execute it.
558
- this._columnDefinitions = this.loadSlickGridEditors(this._columnDefinitions || []);
558
+ this._columns = this.loadSlickGridEditors(this._columns || []);
559
559
 
560
560
  // if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
561
561
  if (this._gridOptions?.autoAddCustomEditorFormatter) {
562
- autoAddEditorFormatterToColumnsWithEditor(this._columnDefinitions, this._gridOptions.autoAddCustomEditorFormatter);
562
+ autoAddEditorFormatterToColumnsWithEditor(this._columns, this._gridOptions.autoAddCustomEditorFormatter);
563
563
  }
564
564
 
565
565
  // save reference for all columns before they optionally become hidden/visible
566
- this.sharedService.allColumns = this._columnDefinitions;
567
- this.sharedService.visibleColumns = this._columnDefinitions;
566
+ this.sharedService.allColumns = this._columns;
567
+ this.sharedService.visibleColumns = this._columns;
568
568
 
569
569
  // TODO: revisit later, this is conflicting with Grid State & Presets
570
570
  // before certain extentions/plugins potentially adds extra columns not created by the user itself (RowMove, RowDetail, RowSelections)
@@ -577,7 +577,7 @@ export class SlickVanillaGridBundle<TData = any> {
577
577
 
578
578
  // after subscribing to potential columns changed, we are ready to create these optional extensions
579
579
  // when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
580
- this.extensionService.createExtensionsBeforeGridCreation(this._columnDefinitions, this._gridOptions);
580
+ this.extensionService.createExtensionsBeforeGridCreation(this._columns, this._gridOptions);
581
581
 
582
582
  // if user entered some Pinning/Frozen "presets", we need to apply them in the grid options
583
583
  if (this.gridOptions.presets?.pinning) {
@@ -587,7 +587,7 @@ export class SlickVanillaGridBundle<TData = any> {
587
587
  this.slickGrid = new SlickGrid<TData, Column<TData>, GridOption<Column<TData>>>(
588
588
  gridContainerElm,
589
589
  this.dataView as SlickDataView<TData>,
590
- this._columnDefinitions,
590
+ this._columns,
591
591
  this._gridOptions,
592
592
  this._eventPubSubService
593
593
  );
@@ -604,8 +604,8 @@ export class SlickVanillaGridBundle<TData = any> {
604
604
 
605
605
  // when it's a frozen grid, we need to keep the frozen column id for reference if we ever show/hide column from ColumnPicker/GridMenu afterward
606
606
  const frozenColumnIndex = this._gridOptions?.frozenColumn ?? -1;
607
- if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columnDefinitions.length && this._columnDefinitions.length > 0) {
608
- this.sharedService.frozenVisibleColumnId = this._columnDefinitions[frozenColumnIndex]?.id ?? '';
607
+ if (frozenColumnIndex >= 0 && frozenColumnIndex <= this._columns.length && this._columns.length > 0) {
608
+ this.sharedService.frozenVisibleColumnId = this._columns[frozenColumnIndex]?.id ?? '';
609
609
  }
610
610
 
611
611
  // get any possible Services that user want to register
@@ -730,7 +730,6 @@ export class SlickVanillaGridBundle<TData = any> {
730
730
  gridEventService: this.gridEventService,
731
731
  gridStateService: this.gridStateService,
732
732
  gridService: this.gridService,
733
- groupingService: this.headerGroupingService,
734
733
  headerGroupingService: this.headerGroupingService,
735
734
  extensionService: this.extensionService,
736
735
  extensionUtility: this.extensionUtility,
@@ -803,13 +802,13 @@ export class SlickVanillaGridBundle<TData = any> {
803
802
  backendApi.internalPostProcess = (processResult: any) => {
804
803
  // prettier-ignore
805
804
  const datasetName = (backendApi && backendApiService && typeof backendApiService.getDatasetName === 'function') ? backendApiService.getDatasetName() : '';
806
- if (processResult && processResult.data && processResult.data[datasetName]) {
805
+ if (processResult?.data?.[datasetName]) {
807
806
  const data = processResult.data[datasetName].hasOwnProperty('nodes')
808
- ? (processResult as any).data[datasetName].nodes
809
- : (processResult as any).data[datasetName];
807
+ ? processResult.data[datasetName].nodes
808
+ : processResult.data[datasetName];
810
809
  const totalCount = processResult.data[datasetName].hasOwnProperty('totalCount')
811
- ? (processResult as any).data[datasetName].totalCount
812
- : (processResult as any).data[datasetName].length;
810
+ ? processResult.data[datasetName].totalCount
811
+ : processResult.data[datasetName].length;
813
812
  this.refreshGridData(data, totalCount || 0);
814
813
  }
815
814
  };
@@ -834,10 +833,7 @@ export class SlickVanillaGridBundle<TData = any> {
834
833
  this._eventPubSubService.subscribe('onLanguageChange', (args: { language: string }) => {
835
834
  if (gridOptions.enableTranslate) {
836
835
  this.extensionService.translateAllExtensions(args.language);
837
- if (
838
- (gridOptions.createPreHeaderPanel && gridOptions.createTopHeaderPanel) ||
839
- (gridOptions.createPreHeaderPanel && !gridOptions.enableDraggableGrouping)
840
- ) {
836
+ if (gridOptions.createPreHeaderPanel && (gridOptions.createTopHeaderPanel || !gridOptions.enableDraggableGrouping)) {
841
837
  this.headerGroupingService.translateHeaderGrouping();
842
838
  }
843
839
  }
@@ -930,18 +926,6 @@ export class SlickVanillaGridBundle<TData = any> {
930
926
  this.loadColumnPresetsWhenDatasetInitialized();
931
927
  this.loadFilterPresetsWhenDatasetInitialized();
932
928
  }
933
-
934
- // @deprecated @use `dataview.globalItemMetadataProvider.getRowMetadata`
935
- // did the user add a colspan callback? If so, hook it into the DataView getItemMetadata
936
- if (gridOptions?.colspanCallback && dataView?.getItem && dataView?.getItemMetadata) {
937
- dataView.getItemMetadata = (rowNumber: number) => {
938
- let callbackResult = null;
939
- if (gridOptions.colspanCallback) {
940
- callbackResult = gridOptions.colspanCallback(dataView.getItem(rowNumber));
941
- }
942
- return callbackResult;
943
- };
944
- }
945
929
  }
946
930
 
947
931
  bindBackendCallbackFunctions(gridOptions: GridOption): void {
@@ -989,9 +973,7 @@ export class SlickVanillaGridBundle<TData = any> {
989
973
  const startTime = new Date();
990
974
 
991
975
  // run any pre-process, if defined, for example a spinner
992
- if (backendApi.preProcess) {
993
- backendApi.preProcess();
994
- }
976
+ backendApi.preProcess?.();
995
977
 
996
978
  // the processes can be a Promise (like Http)
997
979
  const totalItems = this.gridOptions?.pagination?.totalItems ?? 0;
@@ -1130,7 +1112,7 @@ export class SlickVanillaGridBundle<TData = any> {
1130
1112
  this.sharedService.currentPagination = { pageNumber, pageSize };
1131
1113
  }
1132
1114
  this._eventPubSubService.publish('onGridStateChanged', {
1133
- change: { newValues: { pageNumber, pageSize }, type: GridStateType.pagination },
1115
+ change: { newValues: { pageNumber, pageSize }, type: 'pagination' },
1134
1116
  gridState: this.gridStateService.getCurrentGridState(),
1135
1117
  });
1136
1118
  }
@@ -1158,7 +1140,6 @@ export class SlickVanillaGridBundle<TData = any> {
1158
1140
  if (dataset.length > 0) {
1159
1141
  if (!this._isDatasetInitialized) {
1160
1142
  this.loadFilterPresetsWhenDatasetInitialized();
1161
-
1162
1143
  if (this._gridOptions.enableCheckboxSelector) {
1163
1144
  this.loadRowSelectionPresetWhenExists();
1164
1145
  }
@@ -1208,20 +1189,20 @@ export class SlickVanillaGridBundle<TData = any> {
1208
1189
  * We will re-render the grid so that the new header and data shows up correctly.
1209
1190
  * If using translater, we also need to trigger a re-translate of the column headers
1210
1191
  */
1211
- updateColumnDefinitionsList(newColumnDefinitions: Column<TData>[]): void {
1212
- if (this.slickGrid && this._gridOptions && Array.isArray(newColumnDefinitions)) {
1192
+ updateColumnDefinitionsList(newColumns: Column<TData>[]): void {
1193
+ if (this.slickGrid && this._gridOptions && Array.isArray(newColumns)) {
1213
1194
  // map the Editor model to editorClass and load editor collectionAsync
1214
- newColumnDefinitions = this.loadSlickGridEditors(newColumnDefinitions);
1195
+ newColumns = this.loadSlickGridEditors(newColumns);
1215
1196
 
1216
1197
  // if the user wants to automatically add a Custom Editor Formatter, we need to call the auto add function again
1217
1198
  if (this._gridOptions.autoAddCustomEditorFormatter) {
1218
- autoAddEditorFormatterToColumnsWithEditor(newColumnDefinitions, this._gridOptions.autoAddCustomEditorFormatter);
1199
+ autoAddEditorFormatterToColumnsWithEditor(newColumns, this._gridOptions.autoAddCustomEditorFormatter);
1219
1200
  }
1220
1201
 
1221
1202
  if (this._gridOptions.enableTranslate) {
1222
- this.extensionService.translateColumnHeaders(undefined, newColumnDefinitions);
1203
+ this.extensionService.translateColumnHeaders(undefined, newColumns);
1223
1204
  } else {
1224
- this.extensionService.renderColumnHeaders(newColumnDefinitions, true);
1205
+ this.extensionService.renderColumnHeaders(newColumns, true);
1225
1206
  }
1226
1207
 
1227
1208
  if (this.slickGrid && this._gridOptions?.enableAutoSizeColumns) {
@@ -1284,8 +1265,8 @@ export class SlickVanillaGridBundle<TData = any> {
1284
1265
  * Loop through all column definitions and copy the original optional `width` properties optionally provided by the user.
1285
1266
  * We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
1286
1267
  */
1287
- protected copyColumnWidthsReference(columnDefinitions: Column<TData>[]): void {
1288
- columnDefinitions.forEach((col) => (col.originalWidth = col.width));
1268
+ protected copyColumnWidthsReference(columns: Column<TData>[]): void {
1269
+ columns.forEach((col) => (col.originalWidth = col.width));
1289
1270
  }
1290
1271
 
1291
1272
  protected displayEmptyDataWarning(showWarning = true): void {
@@ -1348,9 +1329,9 @@ export class SlickVanillaGridBundle<TData = any> {
1348
1329
  }
1349
1330
 
1350
1331
  /** handler for when column definitions changes */
1351
- protected columnDefinitionsChanged(columnDefinitions?: Column[]): void {
1352
- if (columnDefinitions) {
1353
- this._columnDefinitions = columnDefinitions;
1332
+ protected columnDefinitionsChanged(columns?: Column[]): void {
1333
+ if (columns) {
1334
+ this._columns = columns;
1354
1335
  }
1355
1336
  if (this._isGridInitialized) {
1356
1337
  this.updateColumnDefinitionsList(this.columnDefinitions);
@@ -1390,45 +1371,19 @@ export class SlickVanillaGridBundle<TData = any> {
1390
1371
  /** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
1391
1372
  protected loadEditorCollectionAsync(column: Column<TData>): void {
1392
1373
  if (column?.editor) {
1393
- const collectionAsync = column.editor.collectionAsync;
1394
1374
  column.editor.disabled = true; // disable the Editor DOM element, we'll re-enable it after receiving the collection with "updateEditorCollection()"
1395
1375
 
1396
- if (collectionAsync instanceof Promise) {
1397
- // wait for the "collectionAsync", once resolved we will save it into the "collection"
1398
- // the collectionAsync can be of 3 types HttpClient, HttpFetch or a Promise
1399
- collectionAsync.then((response: any | any[]) => {
1400
- if (Array.isArray(response)) {
1401
- this.updateEditorCollection(column, response); // from Promise
1402
- } else if (response?.status >= 200 && response.status < 300 && typeof response.json === 'function') {
1403
- if (response.bodyUsed) {
1404
- console.warn(
1405
- `[SlickGrid-Universal] The response body passed to collectionAsync was already read.` +
1406
- `Either pass the dataset from the Response or clone the response first using response.clone()`
1407
- );
1408
- } else {
1409
- // from Fetch
1410
- (response as Response).json().then((data) => this.updateEditorCollection(column, data));
1411
- }
1412
- } else if (response?.content) {
1413
- this.updateEditorCollection(column, response['content']); // from http-client
1414
- }
1415
- });
1416
- } else if (this.rxjs?.isObservable(collectionAsync)) {
1417
- // wrap this inside a microtask at the end of the task to avoid timing issue since updateEditorCollection requires to call SlickGrid getColumns() method after columns are available
1418
- queueMicrotask(() => {
1419
- this.subscriptions.push(
1420
- (collectionAsync as Observable<any>).subscribe((resolvedCollection) => this.updateEditorCollection(column, resolvedCollection))
1421
- );
1422
- });
1423
- }
1376
+ fetchAsPromise(column.editor.collectionAsync, this.rxjs).then((resolvedCollection) => {
1377
+ this.updateEditorCollection(column, resolvedCollection);
1378
+ });
1424
1379
  }
1425
1380
  }
1426
1381
 
1427
1382
  protected insertDynamicPresetColumns(columnId: string, gridPresetColumns: Column<TData>[]): void {
1428
- if (this._columnDefinitions) {
1429
- const columnPosition = this._columnDefinitions.findIndex((c) => c.id === columnId);
1383
+ if (this._columns) {
1384
+ const columnPosition = this._columns.findIndex((c) => c.id === columnId);
1430
1385
  if (columnPosition >= 0) {
1431
- const dynColumn = this._columnDefinitions[columnPosition];
1386
+ const dynColumn = this._columns[columnPosition];
1432
1387
  if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
1433
1388
  columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
1434
1389
  }
@@ -1449,7 +1404,7 @@ export class SlickVanillaGridBundle<TData = any> {
1449
1404
  this.slickGrid,
1450
1405
  this.gridOptions.presets.columns
1451
1406
  );
1452
- if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columnDefinitions)) {
1407
+ if (gridPresetColumns && Array.isArray(gridPresetColumns) && gridPresetColumns.length > 0 && Array.isArray(this._columns)) {
1453
1408
  // make sure that the dynamic columns are included in presets (1.Row Move, 2. Row Selection, 3. Row Detail)
1454
1409
  if (this.gridOptions.enableRowMoveManager) {
1455
1410
  const rmmColId = this.gridOptions?.rowMoveManager?.columnId ?? '_move';
@@ -1592,10 +1547,7 @@ export class SlickVanillaGridBundle<TData = any> {
1592
1547
  this._registeredResources.push(this.gridService, this.gridStateService);
1593
1548
 
1594
1549
  // when using Grouping/DraggableGrouping/Colspan register its Service
1595
- if (
1596
- (this.gridOptions.createPreHeaderPanel && this.gridOptions.createTopHeaderPanel) ||
1597
- (this.gridOptions.createPreHeaderPanel && !this.gridOptions.enableDraggableGrouping)
1598
- ) {
1550
+ if (this.gridOptions.createPreHeaderPanel && (this.gridOptions.createTopHeaderPanel || !this.gridOptions.enableDraggableGrouping)) {
1599
1551
  this._registeredResources.push(this.headerGroupingService);
1600
1552
  }
1601
1553
 
@@ -1648,7 +1600,7 @@ export class SlickVanillaGridBundle<TData = any> {
1648
1600
  // we'll also add props, by mutation, required by the TreeDataService on the flat array like `__hasChildren`, `parentId` and anything else to work properly
1649
1601
  sortedDatasetResult = this.treeDataService.convertFlatParentChildToTreeDatasetAndSort(
1650
1602
  flatDatasetInput,
1651
- this._columnDefinitions || [],
1603
+ this._columns || [],
1652
1604
  this.gridOptions
1653
1605
  );
1654
1606
  this.sharedService.hierarchicalDataset = sortedDatasetResult.hierarchical;
@@ -56,9 +56,6 @@ export interface SlickerGridInstance<TData = any> {
56
56
  /** Grid State Service */
57
57
  gridStateService: GridStateService;
58
58
 
59
- /** @deprecated @use `headerGroupingService` */
60
- groupingService: HeaderGroupingService;
61
-
62
59
  /** Grouping (and colspan) Service */
63
60
  headerGroupingService: HeaderGroupingService;
64
61