slickgrid-react 9.13.0 → 10.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.
@@ -1,334 +0,0 @@
1
- import { addToArrayWhenNotExists, createDomElement, SlickEventData, SlickHybridSelectionModel, SlickRowSelectionModel, unsubscribeAll, } from '@slickgrid-universal/common';
2
- import { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';
3
- import { createReactComponentDynamically } from '../services/reactUtils.js';
4
- const ROW_DETAIL_CONTAINER_PREFIX = 'container_';
5
- const PRELOAD_CONTAINER_PREFIX = 'container_loading';
6
- // interface SRDV extends React.Component<Props, State>, UniversalSlickRowDetailView {}s
7
- export class SlickRowDetailView extends UniversalSlickRowDetailView {
8
- eventPubSubService;
9
- _component;
10
- _preloadComponent;
11
- _preloadRoot;
12
- _views = [];
13
- _subscriptions = [];
14
- _userProcessFn;
15
- gridContainerElement;
16
- _root;
17
- constructor(eventPubSubService) {
18
- super(eventPubSubService);
19
- this.eventPubSubService = eventPubSubService;
20
- }
21
- get addonOptions() {
22
- return this.getOptions();
23
- }
24
- get datasetIdPropName() {
25
- return this.gridOptions.datasetIdPropertyName || 'id';
26
- }
27
- get gridOptions() {
28
- return (this._grid?.getOptions() || {});
29
- }
30
- get rowDetailViewOptions() {
31
- return this.gridOptions.rowDetailView;
32
- }
33
- /** Dispose of the RowDetailView Extension */
34
- dispose() {
35
- this.disposeAllViewComponents();
36
- unsubscribeAll(this._subscriptions);
37
- super.dispose();
38
- }
39
- /** Dispose of all the opened Row Detail Panels Components */
40
- disposeAllViewComponents() {
41
- do {
42
- const view = this._views.pop();
43
- if (view) {
44
- this.disposeViewByItem(view);
45
- }
46
- } while (this._views.length > 0);
47
- }
48
- /** Get the instance of the SlickGrid addon (control or plugin). */
49
- getAddonInstance() {
50
- return this;
51
- }
52
- init(grid) {
53
- this._grid = grid;
54
- super.init(grid);
55
- this.gridContainerElement = grid.getContainerNode();
56
- this.register(grid.getSelectionModel());
57
- }
58
- /**
59
- * Create the plugin before the Grid creation, else it will behave oddly.
60
- * Mostly because the column definitions might change after the grid creation
61
- */
62
- register(rowSelectionPlugin) {
63
- if (typeof this.gridOptions.rowDetailView?.process === 'function') {
64
- // we need to keep the user "process" method and replace it with our own execution method
65
- // we do this because when we get the item detail, we need to call "onAsyncResponse.notify" for the plugin to work
66
- this._userProcessFn = this.gridOptions.rowDetailView.process; // keep user's process method
67
- this.addonOptions.process = (item) => this.onProcessing(item); // replace process method & run our internal one
68
- }
69
- else {
70
- throw new Error('[Slickgrid-React] You need to provide a "process" function for the Row Detail Extension to work properly');
71
- }
72
- if (this._grid && this.gridOptions?.rowDetailView) {
73
- // load the Preload & RowDetail Templates (could be straight HTML or React Components)
74
- // when those are React Components, we need to create View Component & provide the html containers to the Plugin (preTemplate/postTemplate methods)
75
- if (!this.gridOptions.rowDetailView.preTemplate) {
76
- this._preloadComponent = this.gridOptions.rowDetailView.preloadComponent;
77
- this.addonOptions.preTemplate = () => createDomElement('div', { className: `${PRELOAD_CONTAINER_PREFIX}` });
78
- }
79
- if (!this.gridOptions.rowDetailView.postTemplate) {
80
- this._component = this.gridOptions.rowDetailView.viewComponent;
81
- this.addonOptions.postTemplate = (itemDetail) => createDomElement('div', { className: `${ROW_DETAIL_CONTAINER_PREFIX}${itemDetail[this.datasetIdPropName]}` });
82
- }
83
- if (this._grid && this.gridOptions) {
84
- // this also requires the Row Selection Model to be registered as well
85
- if (!rowSelectionPlugin || !this._grid.getSelectionModel()) {
86
- const SelectionModelClass = this.gridOptions.enableHybridSelection ? SlickHybridSelectionModel : SlickRowSelectionModel;
87
- rowSelectionPlugin = new SelectionModelClass(this.gridOptions.selectionOptions ?? this.gridOptions.rowSelectionOptions ?? { selectActiveRow: true });
88
- this._grid.setSelectionModel(rowSelectionPlugin);
89
- }
90
- // hook all events
91
- if (this._grid && this.rowDetailViewOptions) {
92
- if (this.rowDetailViewOptions.onExtensionRegistered) {
93
- this.rowDetailViewOptions.onExtensionRegistered(this);
94
- }
95
- this._eventHandler.subscribe(this.onAsyncResponse, (event, args) => {
96
- if (typeof this.rowDetailViewOptions?.onAsyncResponse === 'function') {
97
- this.rowDetailViewOptions.onAsyncResponse(event, args);
98
- }
99
- });
100
- this._eventHandler.subscribe(this.onAsyncEndUpdate, async (event, args) => {
101
- // dispose preload if exists
102
- this._preloadRoot?.unmount();
103
- // triggers after backend called "onAsyncResponse.notify()"
104
- // because of the preload destroy above, we need a small delay to make sure the DOM element is ready to render the Row Detail
105
- queueMicrotask(() => {
106
- this.renderViewModel(args?.item);
107
- if (typeof this.rowDetailViewOptions?.onAsyncEndUpdate === 'function') {
108
- this.rowDetailViewOptions.onAsyncEndUpdate(event, args);
109
- }
110
- });
111
- });
112
- this._eventHandler.subscribe(this.onAfterRowDetailToggle, async (event, args) => {
113
- // display preload template & re-render all the other Detail Views after toggling
114
- // the preload View will eventually go away once the data gets loaded after the "onAsyncEndUpdate" event
115
- this.renderPreloadView(args.item);
116
- if (typeof this.rowDetailViewOptions?.onAfterRowDetailToggle === 'function') {
117
- this.rowDetailViewOptions.onAfterRowDetailToggle(event, args);
118
- }
119
- });
120
- this._eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {
121
- // before toggling row detail, we need to create View Component if it doesn't exist
122
- this.handleOnBeforeRowDetailToggle(event, args);
123
- if (typeof this.rowDetailViewOptions?.onBeforeRowDetailToggle === 'function') {
124
- return this.rowDetailViewOptions.onBeforeRowDetailToggle(event, args);
125
- }
126
- return true;
127
- });
128
- this._eventHandler.subscribe(this.onRowBackToViewportRange, async (event, args) => {
129
- // when row is back to viewport range, we will re-render the View Component(s)
130
- this.handleOnRowBackToViewportRange(event, args);
131
- if (typeof this.rowDetailViewOptions?.onRowBackToViewportRange === 'function') {
132
- this.rowDetailViewOptions.onRowBackToViewportRange(event, args);
133
- }
134
- });
135
- this._eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {
136
- if (typeof this.rowDetailViewOptions?.onBeforeRowOutOfViewportRange === 'function') {
137
- this.rowDetailViewOptions.onBeforeRowOutOfViewportRange(event, args);
138
- }
139
- this.disposeViewByItem(args.item);
140
- });
141
- this._eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => {
142
- if (typeof this.rowDetailViewOptions?.onRowOutOfViewportRange === 'function') {
143
- this.rowDetailViewOptions.onRowOutOfViewportRange(event, args);
144
- }
145
- });
146
- // --
147
- // hook some events needed by the Plugin itself
148
- // we need to redraw the open detail views if we change column position (column reorder)
149
- this.eventHandler.subscribe(this._grid.onColumnsReordered, () => this.redrawAllViewComponents(false));
150
- // on row selection changed, we also need to redraw
151
- if (this.gridOptions.enableRowSelection || this.gridOptions.enableHybridSelection || this.gridOptions.enableCheckboxSelector) {
152
- this._eventHandler.subscribe(this._grid.onSelectedRowsChanged, () => this.redrawAllViewComponents(false));
153
- }
154
- // on column sort/reorder, all row detail are collapsed so we can dispose of all the Views as well
155
- this._eventHandler.subscribe(this._grid.onSort, this.disposeAllViewComponents.bind(this));
156
- // on filter changed, we need to re-render all Views
157
- this._subscriptions.push(this.eventPubSubService?.subscribe([
158
- 'onFilterChanged',
159
- 'onGridMenuColumnsChanged',
160
- 'onColumnPickerColumnsChanged',
161
- 'onGridMenuClearAllFilters',
162
- 'onGridMenuClearAllSorting',
163
- ], () => this.redrawAllViewComponents(true)));
164
- }
165
- }
166
- }
167
- return this;
168
- }
169
- /** Redraw (re-render) all the expanded row detail View Components */
170
- async redrawAllViewComponents(forceRedraw = false) {
171
- setTimeout(() => {
172
- this.resetRenderedRows();
173
- this._views.forEach((view) => {
174
- if (!view.rendered || forceRedraw) {
175
- forceRedraw && this.disposeViewComponent(view);
176
- this.redrawViewComponent(view);
177
- }
178
- });
179
- });
180
- }
181
- /** Render all the expanded row detail View Components */
182
- async renderAllViewModels() {
183
- this._views.filter((x) => x?.dataContext).forEach((x) => this.renderViewModel(x.dataContext));
184
- }
185
- /** Redraw the necessary View Component */
186
- redrawViewComponent(view) {
187
- const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${view.id}`);
188
- if (containerElement) {
189
- this.renderViewModel(view.dataContext);
190
- }
191
- }
192
- /** Render (or re-render) the View Component (Row Detail) */
193
- renderPreloadView(item) {
194
- const containerElement = this.gridContainerElement.querySelector(`.${PRELOAD_CONTAINER_PREFIX}`);
195
- if (this._preloadComponent && containerElement) {
196
- // render row detail
197
- const bindableData = {
198
- model: item,
199
- addon: this,
200
- grid: this._grid,
201
- dataView: this.dataView,
202
- parentRef: this.rowDetailViewOptions?.parentRef,
203
- };
204
- const detailContainer = document.createElement('section');
205
- containerElement.appendChild(detailContainer);
206
- const { root } = createReactComponentDynamically(this._preloadComponent, detailContainer, bindableData);
207
- this._preloadRoot = root;
208
- }
209
- }
210
- /** Render (or re-render) the View Component (Row Detail) */
211
- renderViewModel(item) {
212
- const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`);
213
- if (this._component && containerElement) {
214
- const bindableData = {
215
- model: item,
216
- addon: this,
217
- grid: this._grid,
218
- dataView: this.dataView,
219
- parentRef: this.rowDetailViewOptions?.parentRef,
220
- };
221
- // load our Row Detail React Component dynamically, typically we would want to use `root.render()` after the preload component (last argument below)
222
- // BUT the root render doesn't seem to work and shows a blank element, so we'll use `createRoot()` every time even though it shows a console log in Dev
223
- // that is the only way I got it working so let's use it anyway and console warnings are removed in production anyway
224
- const viewObj = this._views.find((obj) => obj.id === item[this.datasetIdPropName]);
225
- const { root } = createReactComponentDynamically(this._component, containerElement, bindableData);
226
- if (viewObj) {
227
- viewObj.root = root;
228
- viewObj.rendered = true;
229
- }
230
- else {
231
- this.upsertViewRefs(item, root);
232
- }
233
- }
234
- }
235
- // --
236
- // protected functions
237
- // ------------------
238
- upsertViewRefs(item, root) {
239
- const viewIdx = this._views.findIndex((obj) => obj.id === item[this.datasetIdPropName]);
240
- const viewInfo = {
241
- id: item[this.datasetIdPropName],
242
- dataContext: item,
243
- root,
244
- rendered: !!root,
245
- };
246
- if (viewIdx >= 0) {
247
- this._views[viewIdx] = viewInfo;
248
- }
249
- else {
250
- this._views.push(viewInfo);
251
- }
252
- addToArrayWhenNotExists(this._views, viewInfo, this.datasetIdPropName);
253
- }
254
- disposeViewByItem(item, removeFromArray = false) {
255
- const foundViewIdx = this._views.findIndex((view) => view.id === item[this.datasetIdPropName]);
256
- if (foundViewIdx >= 0) {
257
- this.disposeViewComponent(this._views[foundViewIdx]);
258
- if (removeFromArray) {
259
- this._views.splice(foundViewIdx, 1);
260
- }
261
- }
262
- }
263
- disposeViewComponent(expandedView) {
264
- expandedView.rendered = false;
265
- if (expandedView?.root) {
266
- const container = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${expandedView.id}`);
267
- if (container) {
268
- expandedView.root.unmount();
269
- container.textContent = '';
270
- return expandedView;
271
- }
272
- }
273
- }
274
- /**
275
- * Just before the row get expanded or collapsed we will do the following
276
- * First determine if the row is expanding or collapsing,
277
- * if it's expanding we will add it to our View Components reference array,
278
- * if we don't already have it or if it's collapsing we will remove it from our View Components reference array
279
- */
280
- handleOnBeforeRowDetailToggle(_e, args) {
281
- // expanding
282
- if (args?.item?.__collapsed) {
283
- // expanding row detail
284
- this.upsertViewRefs(args.item, null);
285
- }
286
- else {
287
- // collapsing, so dispose of the View
288
- this.disposeViewByItem(args.item, true);
289
- }
290
- }
291
- /** When Row comes back to Viewport Range, we need to redraw the View */
292
- async handleOnRowBackToViewportRange(_e, args) {
293
- const viewModel = this._views.find((x) => x.id === args.rowId);
294
- if (viewModel && !viewModel.rendered) {
295
- this.redrawViewComponent(viewModel);
296
- }
297
- }
298
- /**
299
- * notify the onAsyncResponse with the "args.item" (required property)
300
- * the plugin will then use item to populate the row detail panel with the "postTemplate"
301
- * @param item
302
- */
303
- notifyTemplate(item) {
304
- this.onAsyncResponse.notify({ item }, new SlickEventData(), this);
305
- }
306
- /**
307
- * On Processing, we will notify the plugin with the new item detail once backend server call completes
308
- * @param item
309
- */
310
- async onProcessing(item) {
311
- if (item && typeof this._userProcessFn === 'function') {
312
- let awaitedItemDetail;
313
- const userProcessFn = this._userProcessFn(item);
314
- // wait for the "userProcessFn", once resolved we will save it into the "collection"
315
- const response = await userProcessFn;
316
- if (response.hasOwnProperty(this.datasetIdPropName)) {
317
- awaitedItemDetail = response; // from Promise
318
- }
319
- else if (response instanceof Response && typeof response['json'] === 'function') {
320
- awaitedItemDetail = await response['json'](); // from Fetch
321
- }
322
- else if (response && response['content']) {
323
- awaitedItemDetail = response['content']; // from http-client
324
- }
325
- if (!awaitedItemDetail || !awaitedItemDetail.hasOwnProperty(this.datasetIdPropName)) {
326
- throw new Error('[Slickgrid-React] could not process the Row Detail, please make sure that your "process" callback ' +
327
- `returns an item object that has an "${this.datasetIdPropName}" property`);
328
- }
329
- // notify the plugin with the new item details
330
- this.notifyTemplate(awaitedItemDetail || {});
331
- }
332
- }
333
- }
334
- //# sourceMappingURL=slickRowDetailView.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slickRowDetailView.js","sourceRoot":"","sources":["../../src/extensions/slickRowDetailView.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,cAAc,GAMf,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,kBAAkB,IAAI,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAGhH,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,MAAM,2BAA2B,GAAG,YAAY,CAAC;AACjD,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAQrD,wFAAwF;AAExF,MAAM,OAAO,kBAAmB,SAAQ,2BAA2B;IAUpC;IATnB,UAAU,CAAO;IACjB,iBAAiB,CAAO;IACxB,YAAY,CAAQ;IACpB,MAAM,GAAkB,EAAE,CAAC;I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iBAAsB,CAAC;YAC3B,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAEhD,oFAAoF;YACpF,MAAM,QAAQ,GAAgB,MAAM,aAAa,CAAC;YAElD,IAAI,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACpD,iBAAiB,GAAG,QAAQ,CAAC,CAAC,eAAe;YAC/C,CAAC;iBAAM,IAAI,QAAQ,YAAY,QAAQ,IAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC;gBAClF,iBAAiB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,aAAa;YAC7D,CAAC;iBAAM,IAAI,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC3C,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,mBAAmB;YAC9D,CAAC;YAED,IAAI,CAAC,iBAAiB,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACpF,MAAM,IAAI,KAAK,CACb,oGAAoG;oBAClG,uCAAuC,IAAI,CAAC,iBAAiB,YAAY,CAC5E,CAAC;YACJ,CAAC;YAED,8CAA8C;YAC9C,IAAI,CAAC,cAAc,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;CACF","sourcesContent":["import {\n addToArrayWhenNotExists,\n createDomElement,\n SlickEventData,\n SlickHybridSelectionModel,\n SlickRowSelectionModel,\n unsubscribeAll,\n type EventSubscription,\n type OnBeforeRowDetailToggleArgs,\n type OnRowBackOrOutOfViewportRangeArgs,\n type SelectionModel,\n type SlickGrid,\n} from '@slickgrid-universal/common';\nimport { type EventPubSubService } from '@slickgrid-universal/event-pub-sub';\nimport { SlickRowDetailView as UniversalSlickRowDetailView } from '@slickgrid-universal/row-detail-view-plugin';\nimport type { Root } from 'react-dom/client';\nimport type { GridOption, RowDetailView, ViewModelBindableInputData } from '../models/index.js';\nimport { createReactComponentDynamically } from '../services/reactUtils.js';\n\nconst ROW_DETAIL_CONTAINER_PREFIX = 'container_';\nconst PRELOAD_CONTAINER_PREFIX = 'container_loading';\n\nexport interface CreatedView {\n id: string | number;\n dataContext: any;\n root: Root | null;\n rendered?: boolean;\n}\n// interface SRDV extends React.Component<Props, State>, UniversalSlickRowDetailView {}s\n\nexport class SlickRowDetailView extends UniversalSlickRowDetailView {\n protected _component?: any;\n protected _preloadComponent?: any;\n protected _preloadRoot?: Root;\n protected _views: CreatedView[] = [];\n protected _subscriptions: EventSubscription[] = [];\n protected _userProcessFn?: (item: any) => Promise<any>;\n protected gridContainerElement!: HTMLElement;\n _root?: Root;\n\n constructor(private readonly eventPubSubService: EventPubSubService) {\n super(eventPubSubService);\n }\n\n get addonOptions() {\n return this.getOptions();\n }\n\n protected get datasetIdPropName(): string {\n return this.gridOptions.datasetIdPropertyName || 'id';\n }\n\n get gridOptions(): GridOption {\n return (this._grid?.getOptions() || {}) as GridOption;\n }\n\n get rowDetailViewOptions(): RowDetailView | undefined {\n return this.gridOptions.rowDetailView;\n }\n\n /** Dispose of the RowDetailView Extension */\n dispose() {\n this.disposeAllViewComponents();\n unsubscribeAll(this._subscriptions);\n super.dispose();\n }\n\n /** Dispose of all the opened Row Detail Panels Components */\n disposeAllViewComponents() {\n do {\n const view = this._views.pop();\n if (view) {\n this.disposeViewByItem(view);\n }\n } while (this._views.length > 0);\n }\n\n /** Get the instance of the SlickGrid addon (control or plugin). */\n getAddonInstance(): SlickRowDetailView | null {\n return this;\n }\n\n init(grid: SlickGrid) {\n this._grid = grid;\n super.init(grid);\n this.gridContainerElement = grid.getContainerNode();\n this.register(grid.getSelectionModel());\n }\n\n /**\n * Create the plugin before the Grid creation, else it will behave oddly.\n * Mostly because the column definitions might change after the grid creation\n */\n register(rowSelectionPlugin?: SelectionModel) {\n if (typeof this.gridOptions.rowDetailView?.process === 'function') {\n // we need to keep the user \"process\" method and replace it with our own execution method\n // we do this because when we get the item detail, we need to call \"onAsyncResponse.notify\" for the plugin to work\n this._userProcessFn = this.gridOptions.rowDetailView.process as (item: any) => Promise<any>; // keep user's process method\n this.addonOptions.process = (item) => this.onProcessing(item); // replace process method & run our internal one\n } else {\n throw new Error('[Slickgrid-React] You need to provide a \"process\" function for the Row Detail Extension to work properly');\n }\n\n if (this._grid && this.gridOptions?.rowDetailView) {\n // load the Preload & RowDetail Templates (could be straight HTML or React Components)\n // when those are React Components, we need to create View Component & provide the html containers to the Plugin (preTemplate/postTemplate methods)\n if (!this.gridOptions.rowDetailView.preTemplate) {\n this._preloadComponent = this.gridOptions.rowDetailView.preloadComponent;\n this.addonOptions.preTemplate = () => createDomElement('div', { className: `${PRELOAD_CONTAINER_PREFIX}` });\n }\n if (!this.gridOptions.rowDetailView.postTemplate) {\n this._component = this.gridOptions.rowDetailView.viewComponent;\n this.addonOptions.postTemplate = (itemDetail: any) =>\n createDomElement('div', { className: `${ROW_DETAIL_CONTAINER_PREFIX}${itemDetail[this.datasetIdPropName]}` });\n }\n\n if (this._grid && this.gridOptions) {\n // this also requires the Row Selection Model to be registered as well\n if (!rowSelectionPlugin || !this._grid.getSelectionModel()) {\n const SelectionModelClass = this.gridOptions.enableHybridSelection ? SlickHybridSelectionModel : SlickRowSelectionModel;\n rowSelectionPlugin = new SelectionModelClass(\n this.gridOptions.selectionOptions ?? this.gridOptions.rowSelectionOptions ?? { selectActiveRow: true }\n );\n this._grid.setSelectionModel(rowSelectionPlugin);\n }\n\n // hook all events\n if (this._grid && this.rowDetailViewOptions) {\n if (this.rowDetailViewOptions.onExtensionRegistered) {\n this.rowDetailViewOptions.onExtensionRegistered(this);\n }\n\n this._eventHandler.subscribe(this.onAsyncResponse, (event, args) => {\n if (typeof this.rowDetailViewOptions?.onAsyncResponse === 'function') {\n this.rowDetailViewOptions.onAsyncResponse(event, args);\n }\n });\n\n this._eventHandler.subscribe(this.onAsyncEndUpdate, async (event, args) => {\n // dispose preload if exists\n this._preloadRoot?.unmount();\n\n // triggers after backend called \"onAsyncResponse.notify()\"\n // because of the preload destroy above, we need a small delay to make sure the DOM element is ready to render the Row Detail\n queueMicrotask(() => {\n this.renderViewModel(args?.item);\n\n if (typeof this.rowDetailViewOptions?.onAsyncEndUpdate === 'function') {\n this.rowDetailViewOptions.onAsyncEndUpdate(event, args);\n }\n });\n });\n\n this._eventHandler.subscribe(this.onAfterRowDetailToggle, async (event, args) => {\n // display preload template & re-render all the other Detail Views after toggling\n // the preload View will eventually go away once the data gets loaded after the \"onAsyncEndUpdate\" event\n this.renderPreloadView(args.item);\n\n if (typeof this.rowDetailViewOptions?.onAfterRowDetailToggle === 'function') {\n this.rowDetailViewOptions.onAfterRowDetailToggle(event, args);\n }\n });\n\n this._eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {\n // before toggling row detail, we need to create View Component if it doesn't exist\n this.handleOnBeforeRowDetailToggle(event, args);\n\n if (typeof this.rowDetailViewOptions?.onBeforeRowDetailToggle === 'function') {\n return this.rowDetailViewOptions.onBeforeRowDetailToggle(event, args);\n }\n return true;\n });\n\n this._eventHandler.subscribe(this.onRowBackToViewportRange, async (event, args) => {\n // when row is back to viewport range, we will re-render the View Component(s)\n this.handleOnRowBackToViewportRange(event, args);\n\n if (typeof this.rowDetailViewOptions?.onRowBackToViewportRange === 'function') {\n this.rowDetailViewOptions.onRowBackToViewportRange(event, args);\n }\n });\n\n this._eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {\n if (typeof this.rowDetailViewOptions?.onBeforeRowOutOfViewportRange === 'function') {\n this.rowDetailViewOptions.onBeforeRowOutOfViewportRange(event, args);\n }\n this.disposeViewByItem(args.item);\n });\n\n this._eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => {\n if (typeof this.rowDetailViewOptions?.onRowOutOfViewportRange === 'function') {\n this.rowDetailViewOptions.onRowOutOfViewportRange(event, args);\n }\n });\n\n // --\n // hook some events needed by the Plugin itself\n\n // we need to redraw the open detail views if we change column position (column reorder)\n this.eventHandler.subscribe(this._grid.onColumnsReordered, () => this.redrawAllViewComponents(false));\n\n // on row selection changed, we also need to redraw\n if (this.gridOptions.enableRowSelection || this.gridOptions.enableHybridSelection || this.gridOptions.enableCheckboxSelector) {\n this._eventHandler.subscribe(this._grid.onSelectedRowsChanged, () => this.redrawAllViewComponents(false));\n }\n\n // on column sort/reorder, all row detail are collapsed so we can dispose of all the Views as well\n this._eventHandler.subscribe(this._grid.onSort, this.disposeAllViewComponents.bind(this));\n\n // on filter changed, we need to re-render all Views\n this._subscriptions.push(\n this.eventPubSubService?.subscribe(\n [\n 'onFilterChanged',\n 'onGridMenuColumnsChanged',\n 'onColumnPickerColumnsChanged',\n 'onGridMenuClearAllFilters',\n 'onGridMenuClearAllSorting',\n ],\n () => this.redrawAllViewComponents(true)\n )\n );\n }\n }\n }\n\n return this;\n }\n\n /** Redraw (re-render) all the expanded row detail View Components */\n async redrawAllViewComponents(forceRedraw = false) {\n setTimeout(() => {\n this.resetRenderedRows();\n this._views.forEach((view) => {\n if (!view.rendered || forceRedraw) {\n forceRedraw && this.disposeViewComponent(view);\n this.redrawViewComponent(view);\n }\n });\n });\n }\n\n /** Render all the expanded row detail View Components */\n async renderAllViewModels() {\n this._views.filter((x) => x?.dataContext).forEach((x) => this.renderViewModel(x.dataContext));\n }\n\n /** Redraw the necessary View Component */\n redrawViewComponent(view: CreatedView) {\n const containerElement = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${view.id}`);\n if (containerElement) {\n this.renderViewModel(view.dataContext);\n }\n }\n\n /** Render (or re-render) the View Component (Row Detail) */\n renderPreloadView(item: any) {\n const containerElement = this.gridContainerElement.querySelector(`.${PRELOAD_CONTAINER_PREFIX}`);\n if (this._preloadComponent && containerElement) {\n // render row detail\n const bindableData = {\n model: item,\n addon: this,\n grid: this._grid,\n dataView: this.dataView,\n parentRef: this.rowDetailViewOptions?.parentRef,\n } as ViewModelBindableInputData;\n const detailContainer = document.createElement('section');\n containerElement.appendChild(detailContainer);\n\n const { root } = createReactComponentDynamically(this._preloadComponent, detailContainer, bindableData);\n this._preloadRoot = root;\n }\n }\n\n /** Render (or re-render) the View Component (Row Detail) */\n renderViewModel(item: any) {\n const containerElement = this.gridContainerElement.querySelector<HTMLElement>(\n `.${ROW_DETAIL_CONTAINER_PREFIX}${item[this.datasetIdPropName]}`\n );\n if (this._component && containerElement) {\n const bindableData = {\n model: item,\n addon: this,\n grid: this._grid,\n dataView: this.dataView,\n parentRef: this.rowDetailViewOptions?.parentRef,\n } as ViewModelBindableInputData;\n\n // load our Row Detail React Component dynamically, typically we would want to use `root.render()` after the preload component (last argument below)\n // BUT the root render doesn't seem to work and shows a blank element, so we'll use `createRoot()` every time even though it shows a console log in Dev\n // that is the only way I got it working so let's use it anyway and console warnings are removed in production anyway\n const viewObj = this._views.find((obj) => obj.id === item[this.datasetIdPropName]);\n const { root } = createReactComponentDynamically(this._component, containerElement, bindableData);\n if (viewObj) {\n viewObj.root = root;\n viewObj.rendered = true;\n } else {\n this.upsertViewRefs(item, root);\n }\n }\n }\n\n // --\n // protected functions\n // ------------------\n\n protected upsertViewRefs(item: any, root: Root | null) {\n const viewIdx = this._views.findIndex((obj) => obj.id === item[this.datasetIdPropName]);\n const viewInfo: CreatedView = {\n id: item[this.datasetIdPropName],\n dataContext: item,\n root,\n rendered: !!root,\n };\n if (viewIdx >= 0) {\n this._views[viewIdx] = viewInfo;\n } else {\n this._views.push(viewInfo);\n }\n addToArrayWhenNotExists(this._views, viewInfo, this.datasetIdPropName);\n }\n\n protected disposeViewByItem(item: any, removeFromArray = false): void {\n const foundViewIdx = this._views.findIndex((view: CreatedView) => view.id === item[this.datasetIdPropName]);\n if (foundViewIdx >= 0) {\n this.disposeViewComponent(this._views[foundViewIdx]);\n if (removeFromArray) {\n this._views.splice(foundViewIdx, 1);\n }\n }\n }\n\n protected disposeViewComponent(expandedView: CreatedView): CreatedView | void {\n expandedView.rendered = false;\n if (expandedView?.root) {\n const container = this.gridContainerElement.querySelector(`.${ROW_DETAIL_CONTAINER_PREFIX}${expandedView.id}`);\n if (container) {\n expandedView.root.unmount();\n container.textContent = '';\n return expandedView;\n }\n }\n }\n\n /**\n * Just before the row get expanded or collapsed we will do the following\n * First determine if the row is expanding or collapsing,\n * if it's expanding we will add it to our View Components reference array,\n * if we don't already have it or if it's collapsing we will remove it from our View Components reference array\n */\n protected handleOnBeforeRowDetailToggle(_e: SlickEventData<OnBeforeRowDetailToggleArgs>, args: { grid: SlickGrid; item: any }) {\n // expanding\n if (args?.item?.__collapsed) {\n // expanding row detail\n this.upsertViewRefs(args.item, null);\n } else {\n // collapsing, so dispose of the View\n this.disposeViewByItem(args.item, true);\n }\n }\n\n /** When Row comes back to Viewport Range, we need to redraw the View */\n protected async handleOnRowBackToViewportRange(\n _e: SlickEventData<OnRowBackOrOutOfViewportRangeArgs>,\n args: {\n item: any;\n rowId: string | number;\n rowIndex: number;\n expandedRows: (string | number)[];\n rowIdsOutOfViewport: (string | number)[];\n grid: SlickGrid;\n }\n ) {\n const viewModel = this._views.find((x) => x.id === args.rowId);\n if (viewModel && !viewModel.rendered) {\n this.redrawViewComponent(viewModel);\n }\n }\n\n /**\n * notify the onAsyncResponse with the \"args.item\" (required property)\n * the plugin will then use item to populate the row detail panel with the \"postTemplate\"\n * @param item\n */\n protected notifyTemplate(item: any) {\n this.onAsyncResponse.notify({ item }, new SlickEventData(), this);\n }\n\n /**\n * On Processing, we will notify the plugin with the new item detail once backend server call completes\n * @param item\n */\n protected async onProcessing(item: any) {\n if (item && typeof this._userProcessFn === 'function') {\n let awaitedItemDetail: any;\n const userProcessFn = this._userProcessFn(item);\n\n // wait for the \"userProcessFn\", once resolved we will save it into the \"collection\"\n const response: any | any[] = await userProcessFn;\n\n if (response.hasOwnProperty(this.datasetIdPropName)) {\n awaitedItemDetail = response; // from Promise\n } else if (response instanceof Response && typeof response['json'] === 'function') {\n awaitedItemDetail = await response['json'](); // from Fetch\n } else if (response && response['content']) {\n awaitedItemDetail = response['content']; // from http-client\n }\n\n if (!awaitedItemDetail || !awaitedItemDetail.hasOwnProperty(this.datasetIdPropName)) {\n throw new Error(\n '[Slickgrid-React] could not process the Row Detail, please make sure that your \"process\" callback ' +\n `returns an item object that has an \"${this.datasetIdPropName}\" property`\n );\n }\n\n // notify the plugin with the new item details\n this.notifyTemplate(awaitedItemDetail || {});\n }\n }\n}\n"]}