slickgrid-react 9.13.0 → 10.0.0-beta.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.
- package/README.md +3 -2
- package/dist/components/slickgrid-react.d.ts +7 -6
- package/dist/components/slickgrid-react.js +32 -54
- package/dist/components/slickgrid-react.js.map +1 -1
- package/dist/global-grid-options.d.ts +1 -3
- package/dist/global-grid-options.js +4 -287
- package/dist/global-grid-options.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/package.json +10 -11
- package/src/components/slickgrid-react.tsx +42 -65
- package/src/global-grid-options.ts +4 -288
- package/src/index.ts +11 -3
- package/src/services/index.ts +1 -0
- package/dist/extensions/slickRowDetailView.d.ts +0 -82
- package/dist/extensions/slickRowDetailView.js +0 -334
- package/dist/extensions/slickRowDetailView.js.map +0 -1
- package/src/extensions/slickRowDetailView.ts +0 -421
package/README.md
CHANGED
|
@@ -89,8 +89,9 @@ export default function Example() {
|
|
|
89
89
|
|
|
90
90
|
| Slickgrid-React | React | Migration Guide | Notes | Date |
|
|
91
91
|
|:---------------:| --------- | --------------- | ----- | ---- |
|
|
92
|
-
|
|
|
93
|
-
|
|
|
92
|
+
| 10.x | React >=19.0 | [Migration 10.x](https://ghiscoding.gitbook.io/slickgrid-react/migrations/migration-to-10.x) | Smaller code, requires Slickgrid-Universal [10.x](https://github.com/ghiscoding/slickgrid-universal/releases/tag/v10.0.0) | TBD |
|
|
93
|
+
| 9.x | React >=19.0 | [Migration 9.x](https://ghiscoding.gitbook.io/slickgrid-react/migrations/migration-to-9.x) | ESM-Only, requires Slickgrid-Universal [9.x](https://github.com/ghiscoding/slickgrid-universal/releases/tag/v9.0.0) | 2025-05-10 |
|
|
94
|
+
| 5.x | React >=18.0 | [Migration 5.x](https://ghiscoding.gitbook.io/slickgrid-react/migrations/migration-to-5.x) | Modern UI / Dark Mode, requires Slickgrid-Universal [5.x](https://github.com/ghiscoding/slickgrid-universal/releases/tag/v5.0.0) | 2024-05-10 |
|
|
94
95
|
| 4.x | | [Migration 4.x](https://ghiscoding.gitbook.io/slickgrid-react/migrations/migration-to-4.x) | merge SlickGrid into Slickgrid-Universal,<br> requires Slickgrid-Universal [4.x](https://github.com/ghiscoding/slickgrid-universal/releases/tag/v4.0.2) | 2023-12-15 |
|
|
95
96
|
| 3.x | | [Migration 3.x](https://ghiscoding.gitbook.io/slickgrid-react/migrations/migration-to-3.x) | removal of jQuery (now uses browser native code),<br> requires Slickgrid-Universal [3.x](https://github.com/ghiscoding/slickgrid-universal/releases/tag/v3.0.0) | 2023-05-29 |
|
|
96
97
|
| 2.x | React 18+ | [Migration 2.x](https://ghiscoding.gitbook.io/slickgrid-react/migrations/migration-to-2.x) | removal of jQueryUI, requires Slickgrid-Universal [2.x](https://github.com/ghiscoding/slickgrid-universal/releases/tag/v2.0.0) | 2022-12-08 |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackendUtilityService, CollectionService, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, HeaderGroupingService, PaginationService, ResizerService, SharedService, SlickDataView, SlickEventHandler, SlickGrid, SlickGroupItemMetadataProvider, SortService, TreeDataService, type BackendService, type BackendServiceApi, type BasePaginationComponent, type Column, type EventSubscription, type ExtensionList, type ExternalResource, type Metrics, type Pagination, type PaginationMetadata, type RxJsFacade } from '@slickgrid-universal/common';
|
|
1
|
+
import { BackendUtilityService, CollectionService, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, HeaderGroupingService, PaginationService, ResizerService, SharedService, SlickDataView, SlickEventHandler, SlickGrid, SlickGroupItemMetadataProvider, SortService, TreeDataService, type BackendService, type BackendServiceApi, type BasePaginationComponent, type Column, type EventSubscription, type ExtensionList, type ExternalResource, type ExternalResourceConstructor, type Metrics, type Pagination, type PaginationMetadata, type RxJsFacade } from '@slickgrid-universal/common';
|
|
2
2
|
import { SlickFooterComponent } from '@slickgrid-universal/custom-footer-component';
|
|
3
3
|
import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-component';
|
|
4
4
|
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
@@ -38,7 +38,7 @@ export declare class SlickgridReact<TData = any> extends React.Component<Slickgr
|
|
|
38
38
|
protected _isPaginationInitialized: boolean;
|
|
39
39
|
protected _isLocalGrid: boolean;
|
|
40
40
|
protected _paginationOptions: Pagination | undefined;
|
|
41
|
-
protected _registeredResources: ExternalResource
|
|
41
|
+
protected _registeredResources: Array<ExternalResource | ExternalResourceConstructor>;
|
|
42
42
|
protected _scrollEndCalled: boolean;
|
|
43
43
|
protected get options(): GridOption;
|
|
44
44
|
protected set options(options: GridOption);
|
|
@@ -92,7 +92,7 @@ export declare class SlickgridReact<TData = any> extends React.Component<Slickgr
|
|
|
92
92
|
get isDatasetInitialized(): boolean;
|
|
93
93
|
set isDatasetInitialized(isInitialized: boolean);
|
|
94
94
|
set isDatasetHierarchicalInitialized(isInitialized: boolean);
|
|
95
|
-
get registeredResources(): ExternalResource
|
|
95
|
+
get registeredResources(): Array<ExternalResource | ExternalResourceConstructor>;
|
|
96
96
|
componentDidMount(): void;
|
|
97
97
|
initialization(eventHandler: SlickEventHandler): void;
|
|
98
98
|
componentWillUnmount(shouldEmptyDomElementContainer?: boolean): void;
|
|
@@ -164,7 +164,6 @@ export declare class SlickgridReact<TData = any> extends React.Component<Slickgr
|
|
|
164
164
|
protected renderPagination(showPagination?: boolean): Promise<void>;
|
|
165
165
|
/** Load the Editor Collection asynchronously and replace the "collection" property when Promise resolves */
|
|
166
166
|
protected loadEditorCollectionAsync(column: Column): void;
|
|
167
|
-
protected insertDynamicPresetColumns(columnId: string, gridPresetColumns: Column<TData>[]): void;
|
|
168
167
|
/** Load any possible Columns Grid Presets */
|
|
169
168
|
protected loadColumnPresetsWhenDatasetInitialized(): void;
|
|
170
169
|
/** Load any possible Filters Grid Presets */
|
|
@@ -180,11 +179,13 @@ export declare class SlickgridReact<TData = any> extends React.Component<Slickgr
|
|
|
180
179
|
hasBackendInfiniteScroll(gridOptions?: GridOption): boolean;
|
|
181
180
|
protected mergeGridOptions(gridOptions: GridOption): GridOption;
|
|
182
181
|
/** Add a register a new external resource, user could also optional dispose all previous resources before pushing any new resources to the resources array list. */
|
|
183
|
-
registerExternalResources(resources: ExternalResource
|
|
182
|
+
registerExternalResources(resources: Array<ExternalResource | ExternalResourceConstructor>, disposePreviousResources?: boolean): void;
|
|
184
183
|
resetExternalResources(): void;
|
|
185
184
|
/** Pre-Register any Resource that don't require SlickGrid to be instantiated (for example RxJS Resource & RowDetail) */
|
|
186
185
|
protected preRegisterResources(): void;
|
|
187
|
-
|
|
186
|
+
/** initialized & auto-enable external registered resources, e.g. if user registers `ExcelExportService` then let's auto-enable `enableExcelExport:true` */
|
|
187
|
+
protected autoEnableInitializedResources(resource: ExternalResource | ExternalResourceConstructor): void;
|
|
188
|
+
protected initializeExternalResources(resources: Array<ExternalResource | ExternalResourceConstructor>): void;
|
|
188
189
|
protected registerResources(): void;
|
|
189
190
|
/** Register the RxJS Resource in all necessary services which uses */
|
|
190
191
|
protected registerRxJsResource(resource: RxJsFacade): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { autoAddEditorFormatterToColumnsWithEditor, BackendUtilityService, collectionObserver, CollectionService, emptyElement,
|
|
2
|
+
import { autoAddEditorFormatterToColumnsWithEditor, BackendUtilityService, collectionObserver, CollectionService, emptyElement, ExtensionService, ExtensionUtility, FilterFactory, FilterService, GridEventService, GridService, GridStateService, HeaderGroupingService, isColumnDateType, PaginationService, PluginFlagMappings, ResizerService, SharedService, SlickDataView, SlickEventHandler, SlickGrid, SlickgridConfig, SlickGroupItemMetadataProvider, SortService, TreeDataService, } from '@slickgrid-universal/common';
|
|
3
3
|
import { SlickFooterComponent } from '@slickgrid-universal/custom-footer-component';
|
|
4
4
|
import { SlickEmptyWarningComponent } from '@slickgrid-universal/empty-warning-component';
|
|
5
5
|
import { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
@@ -183,7 +183,7 @@ export class SlickgridReact extends React.Component {
|
|
|
183
183
|
this._options = this.mergeGridOptions(props.options || {});
|
|
184
184
|
// initialize and assign all Service Dependencies
|
|
185
185
|
this._eventPubSubService = new EventPubSubService();
|
|
186
|
-
this._eventPubSubService.eventNamingStyle =
|
|
186
|
+
this._eventPubSubService.eventNamingStyle = 'camelCase';
|
|
187
187
|
this.backendUtilityService = new BackendUtilityService();
|
|
188
188
|
this.gridEventService = new GridEventService();
|
|
189
189
|
this.sharedService = new SharedService();
|
|
@@ -313,7 +313,7 @@ export class SlickgridReact extends React.Component {
|
|
|
313
313
|
this._options.enableMouseWheelScrollHandler === undefined) {
|
|
314
314
|
this._options.enableMouseWheelScrollHandler = true;
|
|
315
315
|
}
|
|
316
|
-
this._eventPubSubService.eventNamingStyle = this._options?.eventNamingStyle ??
|
|
316
|
+
this._eventPubSubService.eventNamingStyle = this._options?.eventNamingStyle ?? 'camelCase';
|
|
317
317
|
this._eventPubSubService.publish(`onBeforeGridCreate`, true);
|
|
318
318
|
// make sure the dataset is initialized (if not it will throw an error that it cannot getLength of null)
|
|
319
319
|
this._dataset ||= this.props.dataset || [];
|
|
@@ -362,7 +362,6 @@ export class SlickgridReact extends React.Component {
|
|
|
362
362
|
}
|
|
363
363
|
// save reference for all columns before they optionally become hidden/visible
|
|
364
364
|
this.sharedService.allColumns = this._columns;
|
|
365
|
-
this.sharedService.visibleColumns = this._columns;
|
|
366
365
|
// after subscribing to potential columns changed, we are ready to create these optional extensions
|
|
367
366
|
// when we did find some to create (RowMove, RowDetail, RowSelections), it will automatically modify column definitions (by previous subscribe)
|
|
368
367
|
this.extensionService.createExtensionsBeforeGridCreation(this._columns, this._options);
|
|
@@ -378,12 +377,12 @@ export class SlickgridReact extends React.Component {
|
|
|
378
377
|
if (this.groupItemMetadataProvider) {
|
|
379
378
|
this.grid.registerPlugin(this.groupItemMetadataProvider); // register GroupItemMetadataProvider when Grouping is enabled
|
|
380
379
|
}
|
|
380
|
+
// get any possible Services that user want to register
|
|
381
|
+
this.registerResources();
|
|
381
382
|
this.extensionService.bindDifferentExtensions();
|
|
382
383
|
this.bindDifferentHooks(this.grid, this._options, this.dataView);
|
|
383
384
|
// 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
|
|
384
385
|
this.sharedService.frozenVisibleColumnId = this.grid.getFrozenColumnId();
|
|
385
|
-
// get any possible Services that user want to register
|
|
386
|
-
this.registerResources();
|
|
387
386
|
// initialize the SlickGrid grid
|
|
388
387
|
this.grid.init();
|
|
389
388
|
// initialized the resizer service only after SlickGrid is initialized
|
|
@@ -425,8 +424,7 @@ export class SlickgridReact extends React.Component {
|
|
|
425
424
|
}
|
|
426
425
|
}
|
|
427
426
|
if (this._dataset.length > 0) {
|
|
428
|
-
if (!this._isDatasetInitialized &&
|
|
429
|
-
(this._options.enableCheckboxSelector || this._options.enableRowSelection || this._options.enableHybridSelection)) {
|
|
427
|
+
if (!this._isDatasetInitialized && (this._options.enableCheckboxSelector || this._options.enableSelection)) {
|
|
430
428
|
this.loadRowSelectionPresetWhenExists();
|
|
431
429
|
}
|
|
432
430
|
this.loadFilterPresetsWhenDatasetInitialized();
|
|
@@ -550,7 +548,7 @@ export class SlickgridReact extends React.Component {
|
|
|
550
548
|
if (Array.isArray(this._registeredResources)) {
|
|
551
549
|
while (this._registeredResources.length > 0) {
|
|
552
550
|
const res = this._registeredResources.pop();
|
|
553
|
-
if (res?.dispose) {
|
|
551
|
+
if (typeof res?.dispose === 'function') {
|
|
554
552
|
res.dispose();
|
|
555
553
|
}
|
|
556
554
|
}
|
|
@@ -666,10 +664,9 @@ export class SlickgridReact extends React.Component {
|
|
|
666
664
|
this.filterService.bindLocalOnFilter(grid);
|
|
667
665
|
}
|
|
668
666
|
}
|
|
669
|
-
// when column are reordered, we need to update
|
|
670
|
-
this._eventHandler.subscribe(grid.onColumnsReordered, (
|
|
667
|
+
// when column are reordered, we need to update SharedService flag
|
|
668
|
+
this._eventHandler.subscribe(grid.onColumnsReordered, () => {
|
|
671
669
|
this.sharedService.hasColumnsReordered = true;
|
|
672
|
-
this.sharedService.visibleColumns = args.impactedColumns;
|
|
673
670
|
});
|
|
674
671
|
this._eventHandler.subscribe(grid.onSetOptions, (_e, args) => {
|
|
675
672
|
// add/remove dark mode CSS class when enabled
|
|
@@ -861,7 +858,7 @@ export class SlickgridReact extends React.Component {
|
|
|
861
858
|
if (this.grid &&
|
|
862
859
|
!isSyncGridSelectionEnabled &&
|
|
863
860
|
this.options?.backendServiceApi &&
|
|
864
|
-
(this.options.
|
|
861
|
+
(this.options.enableSelection || this.options.enableCheckboxSelector)) {
|
|
865
862
|
this.grid.setSelectedRows([]);
|
|
866
863
|
}
|
|
867
864
|
const { pageNumber, pageSize } = pagination;
|
|
@@ -992,9 +989,7 @@ export class SlickgridReact extends React.Component {
|
|
|
992
989
|
if (this._options.enableTranslate) {
|
|
993
990
|
this.extensionService.translateColumnHeaders(undefined, newColumns);
|
|
994
991
|
}
|
|
995
|
-
|
|
996
|
-
this.extensionService.renderColumnHeaders(newColumns, true);
|
|
997
|
-
}
|
|
992
|
+
this.extensionService.renderColumnHeaders(newColumns, true);
|
|
998
993
|
if (this._options?.enableAutoSizeColumns) {
|
|
999
994
|
this.grid.autosizeColumns();
|
|
1000
995
|
}
|
|
@@ -1125,43 +1120,13 @@ export class SlickgridReact extends React.Component {
|
|
|
1125
1120
|
}
|
|
1126
1121
|
}
|
|
1127
1122
|
}
|
|
1128
|
-
insertDynamicPresetColumns(columnId, gridPresetColumns) {
|
|
1129
|
-
if (this._columns) {
|
|
1130
|
-
const columnPosition = this._columns.findIndex((c) => c.id === columnId);
|
|
1131
|
-
if (columnPosition >= 0) {
|
|
1132
|
-
const dynColumn = this._columns[columnPosition];
|
|
1133
|
-
if (dynColumn?.id === columnId && !gridPresetColumns.some((c) => c.id === columnId)) {
|
|
1134
|
-
columnPosition > 0 ? gridPresetColumns.splice(columnPosition, 0, dynColumn) : gridPresetColumns.unshift(dynColumn);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
1123
|
/** Load any possible Columns Grid Presets */
|
|
1140
1124
|
loadColumnPresetsWhenDatasetInitialized() {
|
|
1141
1125
|
// if user entered some Columns "presets", we need to reflect them all in the grid
|
|
1142
1126
|
if (this.grid && this.options.presets && Array.isArray(this.options.presets.columns) && this.options.presets.columns.length > 0) {
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
if (this.options.enableRowMoveManager) {
|
|
1147
|
-
const rmmColId = this.options?.rowMoveManager?.columnId ?? '_move';
|
|
1148
|
-
this.insertDynamicPresetColumns(rmmColId, gridPresetColumns);
|
|
1149
|
-
}
|
|
1150
|
-
if (this.options.enableCheckboxSelector) {
|
|
1151
|
-
const chkColId = this.options?.checkboxSelector?.columnId ?? '_checkbox_selector';
|
|
1152
|
-
this.insertDynamicPresetColumns(chkColId, gridPresetColumns);
|
|
1153
|
-
}
|
|
1154
|
-
if (this.options.enableRowDetailView) {
|
|
1155
|
-
const rdvColId = this.options?.rowDetailView?.columnId ?? '_detail_selector';
|
|
1156
|
-
this.insertDynamicPresetColumns(rdvColId, gridPresetColumns);
|
|
1157
|
-
}
|
|
1158
|
-
// keep copy the original optional `width` properties optionally provided by the user.
|
|
1159
|
-
// We will use this when doing a resize by cell content, if user provided a `width` it won't override it.
|
|
1160
|
-
gridPresetColumns.forEach((col) => (col.originalWidth = col.width));
|
|
1161
|
-
// finally set the new presets columns (including checkbox selector if need be)
|
|
1162
|
-
this.grid.setColumns(gridPresetColumns);
|
|
1163
|
-
this.sharedService.visibleColumns = gridPresetColumns;
|
|
1164
|
-
}
|
|
1127
|
+
// delegate to GridStateService for centralized column arrangement logic
|
|
1128
|
+
// we pass `false` for triggerAutoSizeColumns to maintain original behavior on preset load
|
|
1129
|
+
this.gridStateService.changeColumnsArrangement(this.options.presets.columns, false);
|
|
1165
1130
|
}
|
|
1166
1131
|
}
|
|
1167
1132
|
/** Load any possible Filters Grid Presets */
|
|
@@ -1197,7 +1162,7 @@ export class SlickgridReact extends React.Component {
|
|
|
1197
1162
|
loadRowSelectionPresetWhenExists() {
|
|
1198
1163
|
// if user entered some Row Selections "presets"
|
|
1199
1164
|
const presets = this._options?.presets;
|
|
1200
|
-
const enableRowSelection = this._options && (this._options.enableCheckboxSelector || this._options.
|
|
1165
|
+
const enableRowSelection = this._options && (this._options.enableCheckboxSelector || this._options.enableSelection);
|
|
1201
1166
|
if (enableRowSelection &&
|
|
1202
1167
|
this.grid?.getSelectionModel() &&
|
|
1203
1168
|
presets?.rowSelection &&
|
|
@@ -1271,18 +1236,31 @@ export class SlickgridReact extends React.Component {
|
|
|
1271
1236
|
// register all services by executing their init method and providing them with the Grid object
|
|
1272
1237
|
if (Array.isArray(this._registeredResources)) {
|
|
1273
1238
|
for (const resource of this._registeredResources) {
|
|
1274
|
-
if (resource?.
|
|
1239
|
+
if (resource?.pluginName === 'RxJsResource') {
|
|
1275
1240
|
this.registerRxJsResource(resource);
|
|
1276
1241
|
}
|
|
1277
1242
|
}
|
|
1278
1243
|
}
|
|
1279
1244
|
}
|
|
1245
|
+
/** initialized & auto-enable external registered resources, e.g. if user registers `ExcelExportService` then let's auto-enable `enableExcelExport:true` */
|
|
1246
|
+
autoEnableInitializedResources(resource) {
|
|
1247
|
+
if (this.grid && typeof resource.init === 'function') {
|
|
1248
|
+
resource.init(this.grid, this.props.containerService);
|
|
1249
|
+
}
|
|
1250
|
+
// auto-enable unless the flag was specifically disabled by the end user
|
|
1251
|
+
if ('pluginName' in resource) {
|
|
1252
|
+
const pluginFlagName = PluginFlagMappings.get(resource.pluginName);
|
|
1253
|
+
if (pluginFlagName && this.options[pluginFlagName] !== false) {
|
|
1254
|
+
this.options[pluginFlagName] = true;
|
|
1255
|
+
this.grid?.setOptions({ [pluginFlagName]: true });
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1280
1259
|
initializeExternalResources(resources) {
|
|
1260
|
+
PluginFlagMappings.set('ReactSlickRowDetailView', 'enableRowDetailView');
|
|
1281
1261
|
if (Array.isArray(resources)) {
|
|
1282
1262
|
for (const resource of resources) {
|
|
1283
|
-
|
|
1284
|
-
resource.init(this.grid, this.props.containerService);
|
|
1285
|
-
}
|
|
1263
|
+
this.autoEnableInitializedResources(resource);
|
|
1286
1264
|
}
|
|
1287
1265
|
}
|
|
1288
1266
|
}
|