slickgrid-react 5.5.2 → 5.7.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 +12 -0
- package/dist/cjs/components/slickgrid-react.js +21 -53
- package/dist/cjs/components/slickgrid-react.js.map +1 -1
- package/dist/esm/components/slickgrid-react.js +21 -53
- package/dist/esm/components/slickgrid-react.js.map +1 -1
- package/dist/types/components/slickgrid-react.d.ts.map +1 -1
- package/dist/types/components/slickgridReactProps.d.ts +1 -20
- package/dist/types/components/slickgridReactProps.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/slickgrid-react/components/slickgrid-react.tsx +21 -57
- package/src/slickgrid-react/components/slickgridReactProps.ts +0 -34
|
@@ -76,12 +76,6 @@ interface State {
|
|
|
76
76
|
paginationService: PaginationService;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
class CustomEventPubSubService extends EventPubSubService {
|
|
80
|
-
set elementSource(value: Element) {
|
|
81
|
-
this._elementSource = value;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
79
|
export class SlickgridReact<TData = any> extends React.Component<SlickgridReactProps, State> {
|
|
86
80
|
protected _mounted = false;
|
|
87
81
|
protected setStateValue(key: string, value: any, callback?: () => void): void {
|
|
@@ -268,22 +262,22 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
|
|
|
268
262
|
this._gridOptions = this.mergeGridOptions(props.gridOptions || {});
|
|
269
263
|
|
|
270
264
|
// initialize and assign all Service Dependencies
|
|
271
|
-
this._eventPubSubService =
|
|
265
|
+
this._eventPubSubService = new EventPubSubService();
|
|
272
266
|
this._eventPubSubService.eventNamingStyle = EventNamingStyle.camelCase;
|
|
273
267
|
|
|
274
|
-
this.backendUtilityService =
|
|
275
|
-
this.gridEventService =
|
|
276
|
-
this.sharedService =
|
|
277
|
-
this.collectionService =
|
|
278
|
-
this.extensionUtility =
|
|
268
|
+
this.backendUtilityService = new BackendUtilityService();
|
|
269
|
+
this.gridEventService = new GridEventService();
|
|
270
|
+
this.sharedService = new SharedService();
|
|
271
|
+
this.collectionService = new CollectionService(this.props.translaterService);
|
|
272
|
+
this.extensionUtility = new ExtensionUtility(this.sharedService, this.backendUtilityService, this.props.translaterService);
|
|
279
273
|
this.filterFactory = new FilterFactory(slickgridConfig, this.props.translaterService, this.collectionService);
|
|
280
|
-
this.filterService =
|
|
281
|
-
this.resizerService =
|
|
282
|
-
this.sortService =
|
|
283
|
-
this.treeDataService =
|
|
284
|
-
this.paginationService =
|
|
274
|
+
this.filterService = new FilterService(this.filterFactory as any, this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
275
|
+
this.resizerService = new ResizerService(this._eventPubSubService);
|
|
276
|
+
this.sortService = new SortService(this.sharedService, this._eventPubSubService, this.backendUtilityService);
|
|
277
|
+
this.treeDataService = new TreeDataService(this._eventPubSubService, this.sharedService, this.sortService);
|
|
278
|
+
this.paginationService = new PaginationService(this._eventPubSubService, this.sharedService, this.backendUtilityService);
|
|
285
279
|
|
|
286
|
-
this.extensionService =
|
|
280
|
+
this.extensionService = new ExtensionService(
|
|
287
281
|
this.extensionUtility,
|
|
288
282
|
this.filterService,
|
|
289
283
|
this._eventPubSubService,
|
|
@@ -294,9 +288,9 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
|
|
|
294
288
|
() => this.gridService
|
|
295
289
|
);
|
|
296
290
|
|
|
297
|
-
this.gridStateService =
|
|
298
|
-
this.gridService =
|
|
299
|
-
this.groupingService =
|
|
291
|
+
this.gridStateService = new GridStateService(this.extensionService, this.filterService, this._eventPubSubService, this.sharedService, this.sortService, this.treeDataService);
|
|
292
|
+
this.gridService = new GridService(this.gridStateService, this.filterService, this._eventPubSubService, this.paginationService, this.sharedService, this.sortService, this.treeDataService);
|
|
293
|
+
this.groupingService = new GroupingAndColspanService(this.extensionUtility, this._eventPubSubService);
|
|
300
294
|
|
|
301
295
|
this.serviceList = [
|
|
302
296
|
this.extensionService,
|
|
@@ -358,13 +352,13 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
|
|
|
358
352
|
|
|
359
353
|
componentDidMount() {
|
|
360
354
|
this._mounted = true;
|
|
361
|
-
if (this._elm && this._eventPubSubService instanceof
|
|
362
|
-
|
|
355
|
+
if (this._elm && this._eventPubSubService instanceof EventPubSubService) {
|
|
356
|
+
this._eventPubSubService.elementSource = this._elm;
|
|
363
357
|
|
|
364
358
|
// React doesn't play well with Custom Events & also the render is called after the constructor which brings a second problem
|
|
365
359
|
// to fix both issues, we need to do the following:
|
|
366
|
-
// loop through all component and subscribe to
|
|
367
|
-
// and call their
|
|
360
|
+
// loop through all component props and subscribe to the ones that startsWith "on", we'll assume that it's the custom events
|
|
361
|
+
// we'll and call their listeners when events are dispatching
|
|
368
362
|
for (const prop in this.props) {
|
|
369
363
|
if (prop.startsWith('on')) {
|
|
370
364
|
this.subscriptions.push(
|
|
@@ -450,7 +444,7 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
|
|
|
450
444
|
this.sharedService.groupItemMetadataProvider = this.groupItemMetadataProvider;
|
|
451
445
|
dataViewOptions = { ...dataViewOptions, groupItemMetadataProvider: this.groupItemMetadataProvider };
|
|
452
446
|
}
|
|
453
|
-
this.dataView = new SlickDataView<TData>(dataViewOptions as Partial<DataViewOption
|
|
447
|
+
this.dataView = new SlickDataView<TData>(dataViewOptions as Partial<DataViewOption>, this._eventPubSubService);
|
|
454
448
|
this._eventPubSubService.publish('onDataviewCreated', this.dataView);
|
|
455
449
|
}
|
|
456
450
|
|
|
@@ -480,7 +474,7 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
|
|
|
480
474
|
}
|
|
481
475
|
|
|
482
476
|
// build SlickGrid Grid, also user might optionally pass a custom dataview (e.g. remote model)
|
|
483
|
-
this.grid = new SlickGrid(`#${this.props.gridId}`, this.props.customDataView || this.dataView, this._columnDefinitions, this._gridOptions);
|
|
477
|
+
this.grid = new SlickGrid(`#${this.props.gridId}`, this.props.customDataView || this.dataView, this._columnDefinitions, this._gridOptions, this._eventPubSubService);
|
|
484
478
|
this.sharedService.dataView = this.dataView;
|
|
485
479
|
this.sharedService.slickGrid = this.grid;
|
|
486
480
|
this.sharedService.gridContainerElement = this._elm as HTMLDivElement;
|
|
@@ -780,36 +774,6 @@ export class SlickgridReact<TData = any> extends React.Component<SlickgridReactP
|
|
|
780
774
|
}
|
|
781
775
|
|
|
782
776
|
if (dataView && grid) {
|
|
783
|
-
const slickgridEventPrefix = '';
|
|
784
|
-
|
|
785
|
-
// expose all Slick Grid Events through dispatch
|
|
786
|
-
for (const prop in grid) {
|
|
787
|
-
if (grid.hasOwnProperty(prop) && prop.startsWith('on')) {
|
|
788
|
-
const gridEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix);
|
|
789
|
-
this._eventHandler.subscribe((grid as any)[prop], (event, args: any) => {
|
|
790
|
-
if (this.props.hasOwnProperty(prop)) {
|
|
791
|
-
const callback = this.props[prop as keyof SlickgridReactProps];
|
|
792
|
-
return typeof callback === 'function' && callback(new CustomEvent(gridEventName, { detail: { eventData: event, args } }));
|
|
793
|
-
}
|
|
794
|
-
return true;
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
// expose all Slick DataView Events through dispatch
|
|
800
|
-
for (const prop in dataView) {
|
|
801
|
-
if (dataView.hasOwnProperty(prop) && prop.startsWith('on')) {
|
|
802
|
-
this._eventHandler.subscribe((dataView as any)[prop], (event, args: any) => {
|
|
803
|
-
const dataViewEventName = this._eventPubSubService.getEventNameByNamingConvention(prop, slickgridEventPrefix);
|
|
804
|
-
if (this.props.hasOwnProperty(prop)) {
|
|
805
|
-
const callback = this.props[prop as keyof SlickgridReactProps];
|
|
806
|
-
return typeof callback === 'function' && callback(new CustomEvent(dataViewEventName, { detail: { eventData: event, args } }));
|
|
807
|
-
}
|
|
808
|
-
return true;
|
|
809
|
-
});
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
|
|
813
777
|
// on cell click, mainly used with the columnDef.action callback
|
|
814
778
|
this.gridEventService.bindOnBeforeEditCell(grid);
|
|
815
779
|
this.gridEventService.bindOnCellChange(grid);
|
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
BackendUtilityService,
|
|
3
|
-
CollectionService,
|
|
4
2
|
Column,
|
|
5
3
|
ContainerService,
|
|
6
4
|
ExtensionList,
|
|
7
|
-
ExtensionService,
|
|
8
|
-
ExtensionUtility,
|
|
9
|
-
FilterService,
|
|
10
5
|
GridOption,
|
|
11
|
-
GridEventService,
|
|
12
|
-
GridService,
|
|
13
|
-
GridStateService,
|
|
14
|
-
GroupingAndColspanService,
|
|
15
6
|
Pagination,
|
|
16
|
-
PaginationService,
|
|
17
|
-
ResizerService,
|
|
18
|
-
RxJsFacade,
|
|
19
|
-
SharedService,
|
|
20
7
|
SlickControlList,
|
|
21
8
|
SlickDataView,
|
|
22
9
|
SlickPluginList,
|
|
23
|
-
SortService,
|
|
24
10
|
TranslaterService,
|
|
25
|
-
TreeDataService,
|
|
26
11
|
OnActiveCellChangedEventArgs,
|
|
27
12
|
DragRowMove,
|
|
28
13
|
OnAddNewRowEventArgs,
|
|
@@ -68,7 +53,6 @@ import type {
|
|
|
68
53
|
PagingInfo,
|
|
69
54
|
SlickGrid,
|
|
70
55
|
} from '@slickgrid-universal/common';
|
|
71
|
-
import type { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
72
56
|
import type { SlickgridReactInstance } from '../models';
|
|
73
57
|
import type { ReactUtilService } from '../services';
|
|
74
58
|
|
|
@@ -78,24 +62,6 @@ export interface SlickgridReactProps {
|
|
|
78
62
|
reactUtilService: ReactUtilService;
|
|
79
63
|
containerService: ContainerService;
|
|
80
64
|
translaterService: TranslaterService;
|
|
81
|
-
externalServices?: {
|
|
82
|
-
backendUtilityService?: BackendUtilityService,
|
|
83
|
-
collectionService?: CollectionService,
|
|
84
|
-
eventPubSubService?: EventPubSubService,
|
|
85
|
-
extensionService?: ExtensionService,
|
|
86
|
-
extensionUtility?: ExtensionUtility,
|
|
87
|
-
filterService?: FilterService,
|
|
88
|
-
gridEventService?: GridEventService,
|
|
89
|
-
gridService?: GridService,
|
|
90
|
-
gridStateService?: GridStateService,
|
|
91
|
-
groupingAndColspanService?: GroupingAndColspanService,
|
|
92
|
-
paginationService?: PaginationService,
|
|
93
|
-
resizerService?: ResizerService,
|
|
94
|
-
rxjs?: RxJsFacade,
|
|
95
|
-
sharedService?: SharedService,
|
|
96
|
-
sortService?: SortService,
|
|
97
|
-
treeDataService?: TreeDataService,
|
|
98
|
-
}
|
|
99
65
|
customDataView?: SlickDataView;
|
|
100
66
|
dataset: any[];
|
|
101
67
|
datasetHierarchical?: any[] | null;
|