slickgrid-react 4.5.0 → 4.6.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.
@@ -8,7 +8,6 @@ import {
8
8
  BackendServiceApi,
9
9
  BackendServiceOption,
10
10
  Column,
11
- ColumnEditor,
12
11
  DataViewOption,
13
12
  EventSubscription,
14
13
  ExtensionList,
@@ -1246,34 +1245,36 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
1246
1245
 
1247
1246
  /** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
1248
1247
  protected loadEditorCollectionAsync(column: Column) {
1249
- const collectionAsync = (column?.editor as ColumnEditor).collectionAsync;
1250
- (column?.editor as ColumnEditor).disabled = true; // disable the Editor DOM element, we'll re-enable it after receiving the collection with "updateEditorCollection()"
1251
-
1252
- if (collectionAsync instanceof Promise) {
1253
- // wait for the "collectionAsync", once resolved we will save it into the "collection"
1254
- // the collectionAsync can be of 3 types HttpClient, HttpFetch or a Promise
1255
- collectionAsync.then((response: any | any[]) => {
1256
- if (Array.isArray(response)) {
1257
- this.updateEditorCollection(column, response); // from Promise
1258
- } else if (response instanceof Response && typeof response.json === 'function') {
1259
- if (response.bodyUsed) {
1260
- console.warn(`[SlickGrid-React] The response body passed to collectionAsync was already read.`
1261
- + `Either pass the dataset from the Response or clone the response first using response.clone()`);
1262
- } else {
1263
- // from Fetch
1264
- (response as Response).json().then(data => this.updateEditorCollection(column, data));
1248
+ if (column?.editor) {
1249
+ const collectionAsync = column.editor.collectionAsync;
1250
+ column.editor.disabled = true; // disable the Editor DOM element, we'll re-enable it after receiving the collection with "updateEditorCollection()"
1251
+
1252
+ if (collectionAsync instanceof Promise) {
1253
+ // wait for the "collectionAsync", once resolved we will save it into the "collection"
1254
+ // the collectionAsync can be of 3 types HttpClient, HttpFetch or a Promise
1255
+ collectionAsync.then((response: any | any[]) => {
1256
+ if (Array.isArray(response)) {
1257
+ this.updateEditorCollection(column, response); // from Promise
1258
+ } else if (response instanceof Response && typeof response.json === 'function') {
1259
+ if (response.bodyUsed) {
1260
+ console.warn(`[SlickGrid-React] The response body passed to collectionAsync was already read.`
1261
+ + `Either pass the dataset from the Response or clone the response first using response.clone()`);
1262
+ } else {
1263
+ // from Fetch
1264
+ (response as Response).json().then(data => this.updateEditorCollection(column, data));
1265
+ }
1266
+ } else if (response?.content) {
1267
+ this.updateEditorCollection(column, response.content); // from http-client
1265
1268
  }
1266
- } else if (response?.content) {
1267
- this.updateEditorCollection(column, response.content); // from http-client
1268
- }
1269
- });
1270
- } else if (this.rxjs?.isObservable(collectionAsync)) {
1271
- // wrap this inside a setTimeout to avoid timing issue since updateEditorCollection requires to call SlickGrid getColumns() method
1272
- setTimeout(() => {
1273
- this.subscriptions.push(
1274
- (collectionAsync as Observable<any>).subscribe((resolvedCollection) => this.updateEditorCollection(column, resolvedCollection))
1275
- );
1276
- });
1269
+ });
1270
+ } else if (this.rxjs?.isObservable(collectionAsync)) {
1271
+ // wrap this inside a setTimeout to avoid timing issue since updateEditorCollection requires to call SlickGrid getColumns() method
1272
+ setTimeout(() => {
1273
+ this.subscriptions.push(
1274
+ (collectionAsync as Observable<any>).subscribe((resolvedCollection) => this.updateEditorCollection(column, resolvedCollection))
1275
+ );
1276
+ });
1277
+ }
1277
1278
  }
1278
1279
  }
1279
1280
 
@@ -1553,7 +1554,7 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
1553
1554
 
1554
1555
  return {
1555
1556
  ...column,
1556
- editor: column.editor?.model,
1557
+ editorClass: column.editor?.model,
1557
1558
  internalColumnEditor: { ...column.editor }
1558
1559
  };
1559
1560
  }
@@ -1566,23 +1567,25 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
1566
1567
  * Once we found the new pointer, we will reassign the "editor" and "collection" to the "internalColumnEditor" so it has newest collection
1567
1568
  */
1568
1569
  protected updateEditorCollection<U extends TData = any>(column: Column<U>, newCollection: U[]) {
1569
- (column.editor as ColumnEditor).collection = newCollection;
1570
- (column.editor as ColumnEditor).disabled = false;
1571
-
1572
- // find the new column reference pointer & re-assign the new editor to the internalColumnEditor
1573
- if (Array.isArray(this._columnDefinitions)) {
1574
- const columnRef = this._columnDefinitions.find((col: Column) => col.id === column.id);
1575
- if (columnRef) {
1576
- columnRef.internalColumnEditor = column.editor as ColumnEditor;
1570
+ if (this.grid && column.editor) {
1571
+ column.editor.collection = newCollection;
1572
+ column.editor.disabled = false;
1573
+
1574
+ // find the new column reference pointer & re-assign the new editor to the internalColumnEditor
1575
+ if (Array.isArray(this._columnDefinitions)) {
1576
+ const columnRef = this._columnDefinitions.find((col: Column) => col.id === column.id);
1577
+ if (columnRef) {
1578
+ columnRef.internalColumnEditor = column.editor;
1579
+ }
1577
1580
  }
1578
- }
1579
1581
 
1580
- // get current Editor, remove it from the DOM then re-enable it and re-render it with the new collection.
1581
- const currentEditor = this.grid.getCellEditor() as AutocompleterEditor | SelectEditor;
1582
- if (currentEditor?.disable && currentEditor?.renderDomElement) {
1583
- currentEditor.destroy();
1584
- currentEditor.disable(false);
1585
- currentEditor.renderDomElement(newCollection);
1582
+ // get current Editor, remove it from the DOM then re-enable it and re-render it with the new collection.
1583
+ const currentEditor = this.grid.getCellEditor() as AutocompleterEditor | SelectEditor;
1584
+ if (currentEditor?.disable && currentEditor?.renderDomElement) {
1585
+ currentEditor.destroy();
1586
+ currentEditor.disable(false);
1587
+ currentEditor.renderDomElement(newCollection);
1588
+ }
1586
1589
  }
1587
1590
  }
1588
1591
 
@@ -61,6 +61,7 @@ export class Constants {
61
61
  TEXT_SORT_ASCENDING: 'Sort Ascending',
62
62
  TEXT_SORT_DESCENDING: 'Sort Descending',
63
63
  TEXT_STARTS_WITH: 'Starts With',
64
+ TEXT_TOGGLE_DARK_MODE: 'Toggle Dark Mode',
64
65
  TEXT_TOGGLE_FILTER_ROW: 'Toggle Filter Row',
65
66
  TEXT_TOGGLE_PRE_HEADER_ROW: 'Toggle Pre-Header Row',
66
67
  TEXT_X_OF_Y_SELECTED: '# of % selected',
@@ -169,6 +169,7 @@ export const GlobalGridOptions: Partial<GridOption> = {
169
169
  exportExcelCommandKey: 'EXPORT_TO_EXCEL',
170
170
  exportTextDelimitedCommandKey: 'EXPORT_TO_TAB_DELIMITED',
171
171
  refreshDatasetCommandKey: 'REFRESH_DATASET',
172
+ toggleDarkModeCommandKey: 'TOGGLE_DARK_MODE',
172
173
  toggleFilterCommandKey: 'TOGGLE_FILTER_ROW',
173
174
  togglePreHeaderCommandKey: 'TOGGLE_PRE_HEADER_ROW',
174
175
  },
@@ -181,6 +182,7 @@ export const GlobalGridOptions: Partial<GridOption> = {
181
182
  hideForceFitButton: false,
182
183
  hideRefreshDatasetCommand: false,
183
184
  hideSyncResizeButton: true,
185
+ hideToggleDarkModeCommand: true,
184
186
  hideToggleFilterCommand: false,
185
187
  hideTogglePreHeaderCommand: false,
186
188
  iconCssClass: 'fa fa-bars',
@@ -191,6 +193,7 @@ export const GlobalGridOptions: Partial<GridOption> = {
191
193
  iconExportExcelCommand: 'fa fa-file-excel-o',
192
194
  iconExportTextDelimitedCommand: 'fa fa-download',
193
195
  iconRefreshDatasetCommand: 'fa fa-refresh',
196
+ iconToggleDarkModeCommand: 'fa fa-moon-o mdi mdi-brightness-4',
194
197
  iconToggleFilterCommand: 'fa fa-random',
195
198
  iconTogglePreHeaderCommand: 'fa fa-random',
196
199
  menuWidth: 16,