@slickgrid-universal/svelte-row-detail-plugin 0.0.0-stage → 11.1.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/LICENSE +25 -0
- package/README.md +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/svelteRowDetailView.d.ts +51 -0
- package/dist/svelteRowDetailView.js +248 -0
- package/dist/svelteRowDetailView.js.map +1 -0
- package/package.json +36 -4
- package/src/index.ts +1 -0
- package/src/svelteRowDetailView.ts +289 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Copyright (c) 2020-present, Ghislain B.
|
|
2
|
+
https://github.com/ghiscoding/slickgrid-universal
|
|
3
|
+
|
|
4
|
+
and the original author of SlickGrid
|
|
5
|
+
Michael Leibman, michael{dot}leibman{at}gmail{dot}com
|
|
6
|
+
http://github.com/mleibman/slickgrid
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
|
+
a copy of this software and associated documentation files (the
|
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
14
|
+
the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be
|
|
17
|
+
included in all copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
22
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
23
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
24
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
25
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Svelte Row Detail Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install this package with `slickgrid-svelte` and add `SvelteRowDetailView` to grid `externalResources`. Enable `enableRowDetailView` and configure a `rowDetailView` with `process`, `panelRows`, and optional `preloadComponent` and `viewComponent` Svelte components. Components receive `model`, `addon`, `grid`, `dataView`, and `parentRef` props. The plugin creates and destroys views as rows expand, collapse, and move in and out of the viewport. `keepComponentAlive` retains component state while a row is outside the viewport.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './svelteRowDetailView.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './svelteRowDetailView.js';\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type EventSubscription, type RowDetailView, type SlickGrid } from '@slickgrid-universal/common';
|
|
2
|
+
import type { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
3
|
+
import { SlickRowDetailView } from '@slickgrid-universal/row-detail-plugin';
|
|
4
|
+
import { type Component } from 'svelte';
|
|
5
|
+
export interface SvelteRowDetailViewOptions extends RowDetailView {
|
|
6
|
+
preloadComponent?: Component<any>;
|
|
7
|
+
viewComponent?: Component<any>;
|
|
8
|
+
parentRef?: any;
|
|
9
|
+
keepComponentAlive?: boolean;
|
|
10
|
+
}
|
|
11
|
+
interface MountedView {
|
|
12
|
+
item: any;
|
|
13
|
+
element: HTMLElement;
|
|
14
|
+
component?: Record<string, any>;
|
|
15
|
+
rendered: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Mount Svelte components in the universal row-detail plugin's virtualized panels. */
|
|
18
|
+
export declare class SvelteRowDetailView extends SlickRowDetailView {
|
|
19
|
+
static readonly pluginName = "SvelteRowDetailView";
|
|
20
|
+
protected _views: Map<string | number, MountedView>;
|
|
21
|
+
protected _subscriptions: EventSubscription[];
|
|
22
|
+
protected _userProcess?: (item: any) => Promise<any>;
|
|
23
|
+
protected _renderTimer?: ReturnType<typeof setTimeout>;
|
|
24
|
+
protected _forceRedrawPending: boolean;
|
|
25
|
+
protected _pubSub: EventPubSubService;
|
|
26
|
+
protected _disposed: boolean;
|
|
27
|
+
constructor(pubSub: EventPubSubService);
|
|
28
|
+
protected get rowOptions(): SvelteRowDetailViewOptions;
|
|
29
|
+
protected get itemIdField(): string;
|
|
30
|
+
init(grid: SlickGrid): void;
|
|
31
|
+
protected beforeDetailViewRender(item: any): void;
|
|
32
|
+
protected renderDetailView(item: any): void;
|
|
33
|
+
protected processItem(item: any): Promise<void>;
|
|
34
|
+
protected renderComponent(item: any, component: Component<any>, flush?: boolean): void;
|
|
35
|
+
protected disposeView(item: any, destroy: boolean, removeFromMap?: boolean): void;
|
|
36
|
+
protected detachViewFromDom(item: any): void;
|
|
37
|
+
protected reattachView(view: MountedView, container?: HTMLElement): boolean;
|
|
38
|
+
protected disposeAll(): void;
|
|
39
|
+
protected redrawView(item: any, flush?: boolean): void;
|
|
40
|
+
protected redrawAll(forceRedraw: boolean): void;
|
|
41
|
+
protected redrawDetached(): void;
|
|
42
|
+
/** Dispose of an individual mounted view while leaving the row-detail plugin active. */
|
|
43
|
+
disposeViewByItem(item: any, removeFromArray?: boolean): void;
|
|
44
|
+
disposeAllViewComponents(): void;
|
|
45
|
+
/** Redraw the expanded row detail components, `forceRedraw` also re-creates the ones that are currently rendered. */
|
|
46
|
+
redrawAllViewComponents(forceRedraw?: boolean): void;
|
|
47
|
+
getAddonInstance(): SvelteRowDetailView;
|
|
48
|
+
collapseDetailView(itemId: number | string, isMultipleCollapsing?: boolean): void;
|
|
49
|
+
dispose(): void;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { SlickEventData } from '@slickgrid-universal/common';
|
|
2
|
+
import { SlickRowDetailView } from '@slickgrid-universal/row-detail-plugin';
|
|
3
|
+
import { flushSync, mount, unmount } from 'svelte';
|
|
4
|
+
/** Mount Svelte components in the universal row-detail plugin's virtualized panels. */
|
|
5
|
+
export class SvelteRowDetailView extends SlickRowDetailView {
|
|
6
|
+
static pluginName = 'SvelteRowDetailView';
|
|
7
|
+
_views = new Map();
|
|
8
|
+
_subscriptions = [];
|
|
9
|
+
_userProcess;
|
|
10
|
+
_renderTimer;
|
|
11
|
+
_forceRedrawPending = false;
|
|
12
|
+
_pubSub;
|
|
13
|
+
_disposed = false;
|
|
14
|
+
constructor(pubSub) {
|
|
15
|
+
super(pubSub);
|
|
16
|
+
this._pubSub = pubSub;
|
|
17
|
+
}
|
|
18
|
+
get rowOptions() {
|
|
19
|
+
return this.getOptions();
|
|
20
|
+
}
|
|
21
|
+
get itemIdField() {
|
|
22
|
+
return this.gridOptions.datasetIdPropertyName || 'id';
|
|
23
|
+
}
|
|
24
|
+
init(grid) {
|
|
25
|
+
super.init(grid);
|
|
26
|
+
const options = this.rowOptions;
|
|
27
|
+
if (typeof options.process !== 'function') {
|
|
28
|
+
throw new Error('[Slickgrid-Svelte] Row detail requires a process function.');
|
|
29
|
+
}
|
|
30
|
+
this._userProcess = options.process;
|
|
31
|
+
options.process = (item) => this.processItem(item);
|
|
32
|
+
if (!options.preTemplate) {
|
|
33
|
+
options.preTemplate = () => '';
|
|
34
|
+
}
|
|
35
|
+
if (!options.postTemplate) {
|
|
36
|
+
options.postTemplate = () => '';
|
|
37
|
+
}
|
|
38
|
+
options.onExtensionRegistered?.(this);
|
|
39
|
+
this.eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {
|
|
40
|
+
if (!args.item?.[`${this._keyPrefix}collapsed`]) {
|
|
41
|
+
this.disposeView(args.item, true);
|
|
42
|
+
}
|
|
43
|
+
return this.rowOptions.onBeforeRowDetailToggle?.(event, args);
|
|
44
|
+
});
|
|
45
|
+
this.eventHandler.subscribe(this.onAfterRowDetailToggle, (event, args) => {
|
|
46
|
+
const currentOptions = this.rowOptions;
|
|
47
|
+
if (!args.item?.[`${this._keyPrefix}detailViewLoaded`] && currentOptions.preloadComponent) {
|
|
48
|
+
this.renderComponent(args.item, currentOptions.preloadComponent);
|
|
49
|
+
}
|
|
50
|
+
currentOptions.onAfterRowDetailToggle?.(event, args);
|
|
51
|
+
});
|
|
52
|
+
this.eventHandler.subscribe(this.onAsyncResponse, (event, args) => this.rowOptions.onAsyncResponse?.(event, args));
|
|
53
|
+
this.eventHandler.subscribe(this.onAsyncEndUpdate, (event, args) => this.rowOptions.onAsyncEndUpdate?.(event, args));
|
|
54
|
+
this.eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {
|
|
55
|
+
const currentOptions = this.rowOptions;
|
|
56
|
+
currentOptions.onBeforeRowOutOfViewportRange?.(event, args);
|
|
57
|
+
if (currentOptions.keepComponentAlive) {
|
|
58
|
+
this.detachViewFromDom(args.item);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Keep a placeholder so onRendered can recreate the component if SlickGrid
|
|
62
|
+
// replaces the detail panel while the row is being reflowed.
|
|
63
|
+
this.disposeView(args.item, true, false);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => this.rowOptions.onRowOutOfViewportRange?.(event, args));
|
|
67
|
+
this.eventHandler.subscribe(this.onRowBackToViewportRange, (event, args) => {
|
|
68
|
+
const view = this._views.get(args.rowId);
|
|
69
|
+
if (!view || !view.rendered || !view.element.isConnected) {
|
|
70
|
+
this.redrawView(args.item);
|
|
71
|
+
}
|
|
72
|
+
this.rowOptions.onRowBackToViewportRange?.(event, args);
|
|
73
|
+
});
|
|
74
|
+
this.eventHandler.subscribe(grid.onColumnsReordered, () => this.redrawAll(false));
|
|
75
|
+
if (this.gridOptions.enableSelection || this.gridOptions.enableCheckboxSelector) {
|
|
76
|
+
this.eventHandler.subscribe(grid.onSelectedRowsChanged, () => this.redrawAll(false));
|
|
77
|
+
}
|
|
78
|
+
this.eventHandler.subscribe(grid.onSort, () => this.disposeAll());
|
|
79
|
+
this.eventHandler.subscribe(grid.onRendered, () => this.redrawDetached());
|
|
80
|
+
this._subscriptions.push(this._pubSub.subscribe([
|
|
81
|
+
'onFilterChanged',
|
|
82
|
+
'onGridMenuColumnsChanged',
|
|
83
|
+
'onColumnPickerColumnsChanged',
|
|
84
|
+
'onGridMenuClearAllFilters',
|
|
85
|
+
'onGridMenuClearAllSorting',
|
|
86
|
+
], () => this.redrawAll(true)));
|
|
87
|
+
}
|
|
88
|
+
beforeDetailViewRender(item) {
|
|
89
|
+
this.disposeView(item, true);
|
|
90
|
+
}
|
|
91
|
+
renderDetailView(item) {
|
|
92
|
+
if (this.rowOptions.viewComponent) {
|
|
93
|
+
this.renderComponent(item, this.rowOptions.viewComponent);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async processItem(item) {
|
|
97
|
+
const response = await this._userProcess(item);
|
|
98
|
+
const detail = response instanceof Response ? await response.json() : response;
|
|
99
|
+
if (!detail || !(this.itemIdField in detail)) {
|
|
100
|
+
throw new Error(`[Slickgrid-Svelte] Row detail process must return an item containing "${this.itemIdField}".`);
|
|
101
|
+
}
|
|
102
|
+
if (!this._disposed) {
|
|
103
|
+
this.onAsyncResponse.notify({ item: detail }, new SlickEventData(), this);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
renderComponent(item, component, flush = true) {
|
|
107
|
+
const id = item?.[this.itemIdField];
|
|
108
|
+
const container = this._grid.getContainerNode().getElementsByClassName(`row-detail-${id}`)[0];
|
|
109
|
+
if (!container) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const existing = this._views.get(id);
|
|
113
|
+
if (existing?.component && this.rowOptions.keepComponentAlive && existing.item === item && this.reattachView(existing, container)) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (existing) {
|
|
117
|
+
this.disposeView(item, true);
|
|
118
|
+
}
|
|
119
|
+
const element = document.createElement('div');
|
|
120
|
+
container.appendChild(element);
|
|
121
|
+
const view = mount(component, {
|
|
122
|
+
target: element,
|
|
123
|
+
props: { model: item, addon: this, grid: this._grid, dataView: this.dataView, parentRef: this.rowOptions.parentRef },
|
|
124
|
+
});
|
|
125
|
+
// effects (e.g. onMount) only run on flush, batched callers flush once after rendering all their views
|
|
126
|
+
if (flush) {
|
|
127
|
+
flushSync();
|
|
128
|
+
}
|
|
129
|
+
this._views.set(id, { item, element, component: view, rendered: true });
|
|
130
|
+
}
|
|
131
|
+
disposeView(item, destroy, removeFromMap = destroy) {
|
|
132
|
+
const id = item?.[this.itemIdField];
|
|
133
|
+
const view = this._views.get(id);
|
|
134
|
+
if (!view) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (destroy) {
|
|
138
|
+
if (view.component) {
|
|
139
|
+
void unmount(view.component);
|
|
140
|
+
view.component = undefined;
|
|
141
|
+
}
|
|
142
|
+
if (removeFromMap) {
|
|
143
|
+
this._views.delete(id);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
view.rendered = false;
|
|
147
|
+
view.element.remove();
|
|
148
|
+
}
|
|
149
|
+
detachViewFromDom(item) {
|
|
150
|
+
this.disposeView(item, false);
|
|
151
|
+
}
|
|
152
|
+
reattachView(view, container) {
|
|
153
|
+
const target = container ??
|
|
154
|
+
this._grid.getContainerNode().getElementsByClassName(`row-detail-${view.item[this.itemIdField]}`)[0];
|
|
155
|
+
if (!target) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (view.element.parentElement !== target) {
|
|
159
|
+
target.appendChild(view.element);
|
|
160
|
+
}
|
|
161
|
+
view.rendered = true;
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
disposeAll() {
|
|
165
|
+
for (const view of Array.from(this._views.values())) {
|
|
166
|
+
this.disposeView(view.item, true);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
redrawView(item, flush = true) {
|
|
170
|
+
const view = this._views.get(item?.[this.itemIdField]);
|
|
171
|
+
const component = item?.[`${this._keyPrefix}detailViewLoaded`] ? this.rowOptions.viewComponent : this.rowOptions.preloadComponent;
|
|
172
|
+
if (view?.component && this.rowOptions.keepComponentAlive && view.item === item && this.reattachView(view)) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
else if (component) {
|
|
176
|
+
this.renderComponent(item, component, flush);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
redrawAll(forceRedraw) {
|
|
180
|
+
this._forceRedrawPending ||= forceRedraw;
|
|
181
|
+
clearTimeout(this._renderTimer);
|
|
182
|
+
this._renderTimer = setTimeout(() => {
|
|
183
|
+
const forcePendingRedraw = this._forceRedrawPending;
|
|
184
|
+
this._forceRedrawPending = false;
|
|
185
|
+
this.resetRenderedRows();
|
|
186
|
+
for (const view of Array.from(this._views.values())) {
|
|
187
|
+
if (forcePendingRedraw || !view.rendered || !view.element.isConnected) {
|
|
188
|
+
// keep a placeholder so the view is re-created when its panel is back in the DOM
|
|
189
|
+
forcePendingRedraw && this.disposeView(view.item, true, false);
|
|
190
|
+
this.redrawView(view.item, false);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
flushSync();
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
redrawDetached() {
|
|
197
|
+
const renderedRange = this._views.size ? this._grid.getRenderedRange() : undefined;
|
|
198
|
+
if (!renderedRange) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
let hasRedrawn = false;
|
|
202
|
+
for (const view of Array.from(this._views.values())) {
|
|
203
|
+
const itemId = view.item?.[this.itemIdField];
|
|
204
|
+
if (!this._renderedViewportRowIds.has(itemId) || (view.rendered && view.element.isConnected)) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const rowIndex = this.dataView.getRowById(itemId);
|
|
208
|
+
if (rowIndex === undefined || rowIndex < renderedRange.top || rowIndex > renderedRange.bottom) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
this.redrawView(view.item, false);
|
|
212
|
+
hasRedrawn = true;
|
|
213
|
+
}
|
|
214
|
+
if (hasRedrawn) {
|
|
215
|
+
flushSync();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/** Dispose of an individual mounted view while leaving the row-detail plugin active. */
|
|
219
|
+
disposeViewByItem(item, removeFromArray = false) {
|
|
220
|
+
this.disposeView(item, true, removeFromArray);
|
|
221
|
+
}
|
|
222
|
+
disposeAllViewComponents() {
|
|
223
|
+
this.disposeAll();
|
|
224
|
+
}
|
|
225
|
+
/** Redraw the expanded row detail components, `forceRedraw` also re-creates the ones that are currently rendered. */
|
|
226
|
+
redrawAllViewComponents(forceRedraw = false) {
|
|
227
|
+
this.redrawAll(forceRedraw);
|
|
228
|
+
}
|
|
229
|
+
getAddonInstance() {
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
collapseDetailView(itemId, isMultipleCollapsing = false) {
|
|
233
|
+
const item = this.dataView.getItemById(itemId);
|
|
234
|
+
if (item) {
|
|
235
|
+
this.disposeView(item, true);
|
|
236
|
+
}
|
|
237
|
+
super.collapseDetailView(itemId, isMultipleCollapsing);
|
|
238
|
+
}
|
|
239
|
+
dispose() {
|
|
240
|
+
this._disposed = true;
|
|
241
|
+
clearTimeout(this._renderTimer);
|
|
242
|
+
this._forceRedrawPending = false;
|
|
243
|
+
this._subscriptions.forEach((subscription) => subscription.unsubscribe?.());
|
|
244
|
+
this.disposeAll();
|
|
245
|
+
super.dispose();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=svelteRowDetailView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelteRowDetailView.js","sourceRoot":"","sources":["../src/svelteRowDetailView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA8D,MAAM,6BAA6B,CAAC;AAEzH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAkB,MAAM,QAAQ,CAAC;AAgBnE,uFAAuF;AACvF,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IACzD,MAAM,CAAU,UAAU,GAAG,qBAAqB,CAAC;IACzC,MAAM,GAAG,IAAI,GAAG,EAAgC,CAAC;IACjD,cAAc,GAAwB,EAAE,CAAC;IACzC,YAAY,CAA+B;IAC3C,YAAY,CAAiC;IAC7C,mBAAmB,GAAG,KAAK,CAAC;IAC5B,OAAO,CAAqB;IAC5B,SAAS,GAAG,KAAK,CAAC;IAE5B,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,IAAc,UAAU;QACtB,OAAO,IAAI,CAAC,UAAU,EAAgC,CAAC;IACzD,CAAC;IAED,IAAc,WAAW;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC,qBAAqB,IAAI,IAAI,CAAC;IACxD,CAAC;IAEQ,IAAI,CAAC,IAAe;QAC3B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC;QAChC,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,OAAsC,CAAC;QACnE,OAA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;QACd,CAAC;IACH,CAAC;IAED,wFAAwF;IACxF,iBAAiB,CAAC,IAAS,EAAE,eAAe,GAAG,KAAK;QAClD,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC;IAChD,CAAC;IAED,wBAAwB;QACtB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,qHAAqH;IACrH,uBAAuB,CAAC,WAAW,GAAG,KAAK;QACzC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,kBAAkB,CAAC,MAAuB,EAAE,oBAAoB,GAAG,KAAK;QAC/E,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,CAAC,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACzD,CAAC;IAEQ,OAAO;QACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAChC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;QACjC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5E,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC","sourcesContent":["import { SlickEventData, type EventSubscription, type RowDetailView, type SlickGrid } from '@slickgrid-universal/common';\nimport type { EventPubSubService } from '@slickgrid-universal/event-pub-sub';\nimport { SlickRowDetailView } from '@slickgrid-universal/row-detail-plugin';\nimport { flushSync, mount, unmount, type Component } from 'svelte';\n\nexport interface SvelteRowDetailViewOptions extends RowDetailView {\n preloadComponent?: Component<any>;\n viewComponent?: Component<any>;\n parentRef?: any;\n keepComponentAlive?: boolean;\n}\n\ninterface MountedView {\n item: any;\n element: HTMLElement;\n component?: Record<string, any>;\n rendered: boolean;\n}\n\n/** Mount Svelte components in the universal row-detail plugin's virtualized panels. */\nexport class SvelteRowDetailView extends SlickRowDetailView {\n static readonly pluginName = 'SvelteRowDetailView';\n protected _views = new Map<string | number, MountedView>();\n protected _subscriptions: EventSubscription[] = [];\n protected _userProcess?: (item: any) => Promise<any>;\n protected _renderTimer?: ReturnType<typeof setTimeout>;\n protected _forceRedrawPending = false;\n protected _pubSub: EventPubSubService;\n protected _disposed = false;\n\n constructor(pubSub: EventPubSubService) {\n super(pubSub);\n this._pubSub = pubSub;\n }\n\n protected get rowOptions(): SvelteRowDetailViewOptions {\n return this.getOptions() as SvelteRowDetailViewOptions;\n }\n\n protected get itemIdField(): string {\n return this.gridOptions.datasetIdPropertyName || 'id';\n }\n\n override init(grid: SlickGrid): void {\n super.init(grid);\n const options = this.rowOptions;\n if (typeof options.process !== 'function') {\n throw new Error('[Slickgrid-Svelte] Row detail requires a process function.');\n }\n this._userProcess = options.process as (item: any) => Promise<any>;\n options.process = (item: any) => this.processItem(item);\n if (!options.preTemplate) {\n options.preTemplate = () => '';\n }\n if (!options.postTemplate) {\n options.postTemplate = () => '';\n }\n options.onExtensionRegistered?.(this);\n\n this.eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {\n if (!args.item?.[`${this._keyPrefix}collapsed`]) {\n this.disposeView(args.item, true);\n }\n return this.rowOptions.onBeforeRowDetailToggle?.(event, args);\n });\n this.eventHandler.subscribe(this.onAfterRowDetailToggle, (event, args) => {\n const currentOptions = this.rowOptions;\n if (!args.item?.[`${this._keyPrefix}detailViewLoaded`] && currentOptions.preloadComponent) {\n this.renderComponent(args.item, currentOptions.preloadComponent);\n }\n currentOptions.onAfterRowDetailToggle?.(event, args);\n });\n this.eventHandler.subscribe(this.onAsyncResponse, (event, args) => this.rowOptions.onAsyncResponse?.(event, args));\n this.eventHandler.subscribe(this.onAsyncEndUpdate, (event, args) => this.rowOptions.onAsyncEndUpdate?.(event, args));\n this.eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {\n const currentOptions = this.rowOptions;\n currentOptions.onBeforeRowOutOfViewportRange?.(event, args);\n if (currentOptions.keepComponentAlive) {\n this.detachViewFromDom(args.item);\n } else {\n // Keep a placeholder so onRendered can recreate the component if SlickGrid\n // replaces the detail panel while the row is being reflowed.\n this.disposeView(args.item, true, false);\n }\n });\n this.eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => this.rowOptions.onRowOutOfViewportRange?.(event, args));\n this.eventHandler.subscribe(this.onRowBackToViewportRange, (event, args) => {\n const view = this._views.get(args.rowId);\n if (!view || !view.rendered || !view.element.isConnected) {\n this.redrawView(args.item);\n }\n this.rowOptions.onRowBackToViewportRange?.(event, args);\n });\n this.eventHandler.subscribe(grid.onColumnsReordered, () => this.redrawAll(false));\n if (this.gridOptions.enableSelection || this.gridOptions.enableCheckboxSelector) {\n this.eventHandler.subscribe(grid.onSelectedRowsChanged, () => this.redrawAll(false));\n }\n this.eventHandler.subscribe(grid.onSort, () => this.disposeAll());\n this.eventHandler.subscribe(grid.onRendered, () => this.redrawDetached());\n this._subscriptions.push(\n this._pubSub.subscribe(\n [\n 'onFilterChanged',\n 'onGridMenuColumnsChanged',\n 'onColumnPickerColumnsChanged',\n 'onGridMenuClearAllFilters',\n 'onGridMenuClearAllSorting',\n ],\n () => this.redrawAll(true)\n )\n );\n }\n\n protected override beforeDetailViewRender(item: any): void {\n this.disposeView(item, true);\n }\n\n protected override renderDetailView(item: any): void {\n if (this.rowOptions.viewComponent) {\n this.renderComponent(item, this.rowOptions.viewComponent);\n }\n }\n\n protected async processItem(item: any): Promise<void> {\n const response = await this._userProcess!(item);\n const detail = response instanceof Response ? await response.json() : response;\n if (!detail || !(this.itemIdField in detail)) {\n throw new Error(`[Slickgrid-Svelte] Row detail process must return an item containing \"${this.itemIdField}\".`);\n }\n if (!this._disposed) {\n this.onAsyncResponse.notify({ item: detail }, new SlickEventData(), this);\n }\n }\n\n protected renderComponent(item: any, component: Component<any>, flush = true): void {\n const id = item?.[this.itemIdField];\n const container = this._grid.getContainerNode().getElementsByClassName(`row-detail-${id}`)[0] as HTMLElement | undefined;\n if (!container) {\n return;\n }\n const existing = this._views.get(id);\n if (existing?.component && this.rowOptions.keepComponentAlive && existing.item === item && this.reattachView(existing, container)) {\n return;\n }\n if (existing) {\n this.disposeView(item, true);\n }\n const element = document.createElement('div');\n container.appendChild(element);\n const view = mount(component, {\n target: element,\n props: { model: item, addon: this, grid: this._grid, dataView: this.dataView, parentRef: this.rowOptions.parentRef },\n });\n // effects (e.g. onMount) only run on flush, batched callers flush once after rendering all their views\n if (flush) {\n flushSync();\n }\n this._views.set(id, { item, element, component: view, rendered: true });\n }\n\n protected disposeView(item: any, destroy: boolean, removeFromMap = destroy): void {\n const id = item?.[this.itemIdField];\n const view = this._views.get(id);\n if (!view) {\n return;\n }\n if (destroy) {\n if (view.component) {\n void unmount(view.component);\n view.component = undefined;\n }\n if (removeFromMap) {\n this._views.delete(id);\n }\n }\n view.rendered = false;\n view.element.remove();\n }\n\n protected detachViewFromDom(item: any): void {\n this.disposeView(item, false);\n }\n\n protected reattachView(view: MountedView, container?: HTMLElement): boolean {\n const target =\n container ??\n (this._grid.getContainerNode().getElementsByClassName(`row-detail-${view.item[this.itemIdField]}`)[0] as HTMLElement | undefined);\n if (!target) {\n return false;\n }\n if (view.element.parentElement !== target) {\n target.appendChild(view.element);\n }\n view.rendered = true;\n return true;\n }\n\n protected disposeAll(): void {\n for (const view of Array.from(this._views.values())) {\n this.disposeView(view.item, true);\n }\n }\n\n protected redrawView(item: any, flush = true): void {\n const view = this._views.get(item?.[this.itemIdField]);\n const component = item?.[`${this._keyPrefix}detailViewLoaded`] ? this.rowOptions.viewComponent : this.rowOptions.preloadComponent;\n if (view?.component && this.rowOptions.keepComponentAlive && view.item === item && this.reattachView(view)) {\n return;\n } else if (component) {\n this.renderComponent(item, component, flush);\n }\n }\n\n protected redrawAll(forceRedraw: boolean): void {\n this._forceRedrawPending ||= forceRedraw;\n clearTimeout(this._renderTimer);\n this._renderTimer = setTimeout(() => {\n const forcePendingRedraw = this._forceRedrawPending;\n this._forceRedrawPending = false;\n this.resetRenderedRows();\n for (const view of Array.from(this._views.values())) {\n if (forcePendingRedraw || !view.rendered || !view.element.isConnected) {\n // keep a placeholder so the view is re-created when its panel is back in the DOM\n forcePendingRedraw && this.disposeView(view.item, true, false);\n this.redrawView(view.item, false);\n }\n }\n flushSync();\n });\n }\n\n protected redrawDetached(): void {\n const renderedRange = this._views.size ? this._grid.getRenderedRange() : undefined;\n if (!renderedRange) {\n return;\n }\n let hasRedrawn = false;\n for (const view of Array.from(this._views.values())) {\n const itemId = view.item?.[this.itemIdField];\n if (!this._renderedViewportRowIds.has(itemId) || (view.rendered && view.element.isConnected)) {\n continue;\n }\n const rowIndex = this.dataView.getRowById(itemId);\n if (rowIndex === undefined || rowIndex < renderedRange.top || rowIndex > renderedRange.bottom) {\n continue;\n }\n this.redrawView(view.item, false);\n hasRedrawn = true;\n }\n if (hasRedrawn) {\n flushSync();\n }\n }\n\n /** Dispose of an individual mounted view while leaving the row-detail plugin active. */\n disposeViewByItem(item: any, removeFromArray = false): void {\n this.disposeView(item, true, removeFromArray);\n }\n\n disposeAllViewComponents(): void {\n this.disposeAll();\n }\n\n /** Redraw the expanded row detail components, `forceRedraw` also re-creates the ones that are currently rendered. */\n redrawAllViewComponents(forceRedraw = false): void {\n this.redrawAll(forceRedraw);\n }\n\n getAddonInstance(): SvelteRowDetailView {\n return this;\n }\n\n override collapseDetailView(itemId: number | string, isMultipleCollapsing = false): void {\n const item = this.dataView.getItemById(itemId);\n if (item) {\n this.disposeView(item, true);\n }\n super.collapseDetailView(itemId, isMultipleCollapsing);\n }\n\n override dispose(): void {\n this._disposed = true;\n clearTimeout(this._renderTimer);\n this._forceRedrawPending = false;\n this._subscriptions.forEach((subscription) => subscription.unsubscribe?.());\n this.disposeAll();\n super.dispose();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slickgrid-universal/svelte-row-detail-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "11.1.0",
|
|
4
|
+
"description": "Svelte row detail plugin for Slickgrid-Svelte",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/ghiscoding/slickgrid-universal.git",
|
|
8
|
+
"directory": "frameworks-plugins/svelte-row-detail-plugin"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@slickgrid-universal/common": "11.1.0",
|
|
30
|
+
"@slickgrid-universal/event-pub-sub": "11.0.0",
|
|
31
|
+
"@slickgrid-universal/row-detail-plugin": "11.1.0",
|
|
32
|
+
"tslib": "^2.9.1"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"svelte": ">=5.0.0"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "8edce3c68caa02e218c0884f610d65caeab946d5"
|
|
38
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './svelteRowDetailView.js';
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { SlickEventData, type EventSubscription, type RowDetailView, type SlickGrid } from '@slickgrid-universal/common';
|
|
2
|
+
import type { EventPubSubService } from '@slickgrid-universal/event-pub-sub';
|
|
3
|
+
import { SlickRowDetailView } from '@slickgrid-universal/row-detail-plugin';
|
|
4
|
+
import { flushSync, mount, unmount, type Component } from 'svelte';
|
|
5
|
+
|
|
6
|
+
export interface SvelteRowDetailViewOptions extends RowDetailView {
|
|
7
|
+
preloadComponent?: Component<any>;
|
|
8
|
+
viewComponent?: Component<any>;
|
|
9
|
+
parentRef?: any;
|
|
10
|
+
keepComponentAlive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface MountedView {
|
|
14
|
+
item: any;
|
|
15
|
+
element: HTMLElement;
|
|
16
|
+
component?: Record<string, any>;
|
|
17
|
+
rendered: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Mount Svelte components in the universal row-detail plugin's virtualized panels. */
|
|
21
|
+
export class SvelteRowDetailView extends SlickRowDetailView {
|
|
22
|
+
static readonly pluginName = 'SvelteRowDetailView';
|
|
23
|
+
protected _views = new Map<string | number, MountedView>();
|
|
24
|
+
protected _subscriptions: EventSubscription[] = [];
|
|
25
|
+
protected _userProcess?: (item: any) => Promise<any>;
|
|
26
|
+
protected _renderTimer?: ReturnType<typeof setTimeout>;
|
|
27
|
+
protected _forceRedrawPending = false;
|
|
28
|
+
protected _pubSub: EventPubSubService;
|
|
29
|
+
protected _disposed = false;
|
|
30
|
+
|
|
31
|
+
constructor(pubSub: EventPubSubService) {
|
|
32
|
+
super(pubSub);
|
|
33
|
+
this._pubSub = pubSub;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected get rowOptions(): SvelteRowDetailViewOptions {
|
|
37
|
+
return this.getOptions() as SvelteRowDetailViewOptions;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected get itemIdField(): string {
|
|
41
|
+
return this.gridOptions.datasetIdPropertyName || 'id';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override init(grid: SlickGrid): void {
|
|
45
|
+
super.init(grid);
|
|
46
|
+
const options = this.rowOptions;
|
|
47
|
+
if (typeof options.process !== 'function') {
|
|
48
|
+
throw new Error('[Slickgrid-Svelte] Row detail requires a process function.');
|
|
49
|
+
}
|
|
50
|
+
this._userProcess = options.process as (item: any) => Promise<any>;
|
|
51
|
+
options.process = (item: any) => this.processItem(item);
|
|
52
|
+
if (!options.preTemplate) {
|
|
53
|
+
options.preTemplate = () => '';
|
|
54
|
+
}
|
|
55
|
+
if (!options.postTemplate) {
|
|
56
|
+
options.postTemplate = () => '';
|
|
57
|
+
}
|
|
58
|
+
options.onExtensionRegistered?.(this);
|
|
59
|
+
|
|
60
|
+
this.eventHandler.subscribe(this.onBeforeRowDetailToggle, (event, args) => {
|
|
61
|
+
if (!args.item?.[`${this._keyPrefix}collapsed`]) {
|
|
62
|
+
this.disposeView(args.item, true);
|
|
63
|
+
}
|
|
64
|
+
return this.rowOptions.onBeforeRowDetailToggle?.(event, args);
|
|
65
|
+
});
|
|
66
|
+
this.eventHandler.subscribe(this.onAfterRowDetailToggle, (event, args) => {
|
|
67
|
+
const currentOptions = this.rowOptions;
|
|
68
|
+
if (!args.item?.[`${this._keyPrefix}detailViewLoaded`] && currentOptions.preloadComponent) {
|
|
69
|
+
this.renderComponent(args.item, currentOptions.preloadComponent);
|
|
70
|
+
}
|
|
71
|
+
currentOptions.onAfterRowDetailToggle?.(event, args);
|
|
72
|
+
});
|
|
73
|
+
this.eventHandler.subscribe(this.onAsyncResponse, (event, args) => this.rowOptions.onAsyncResponse?.(event, args));
|
|
74
|
+
this.eventHandler.subscribe(this.onAsyncEndUpdate, (event, args) => this.rowOptions.onAsyncEndUpdate?.(event, args));
|
|
75
|
+
this.eventHandler.subscribe(this.onBeforeRowOutOfViewportRange, (event, args) => {
|
|
76
|
+
const currentOptions = this.rowOptions;
|
|
77
|
+
currentOptions.onBeforeRowOutOfViewportRange?.(event, args);
|
|
78
|
+
if (currentOptions.keepComponentAlive) {
|
|
79
|
+
this.detachViewFromDom(args.item);
|
|
80
|
+
} else {
|
|
81
|
+
// Keep a placeholder so onRendered can recreate the component if SlickGrid
|
|
82
|
+
// replaces the detail panel while the row is being reflowed.
|
|
83
|
+
this.disposeView(args.item, true, false);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
this.eventHandler.subscribe(this.onRowOutOfViewportRange, (event, args) => this.rowOptions.onRowOutOfViewportRange?.(event, args));
|
|
87
|
+
this.eventHandler.subscribe(this.onRowBackToViewportRange, (event, args) => {
|
|
88
|
+
const view = this._views.get(args.rowId);
|
|
89
|
+
if (!view || !view.rendered || !view.element.isConnected) {
|
|
90
|
+
this.redrawView(args.item);
|
|
91
|
+
}
|
|
92
|
+
this.rowOptions.onRowBackToViewportRange?.(event, args);
|
|
93
|
+
});
|
|
94
|
+
this.eventHandler.subscribe(grid.onColumnsReordered, () => this.redrawAll(false));
|
|
95
|
+
if (this.gridOptions.enableSelection || this.gridOptions.enableCheckboxSelector) {
|
|
96
|
+
this.eventHandler.subscribe(grid.onSelectedRowsChanged, () => this.redrawAll(false));
|
|
97
|
+
}
|
|
98
|
+
this.eventHandler.subscribe(grid.onSort, () => this.disposeAll());
|
|
99
|
+
this.eventHandler.subscribe(grid.onRendered, () => this.redrawDetached());
|
|
100
|
+
this._subscriptions.push(
|
|
101
|
+
this._pubSub.subscribe(
|
|
102
|
+
[
|
|
103
|
+
'onFilterChanged',
|
|
104
|
+
'onGridMenuColumnsChanged',
|
|
105
|
+
'onColumnPickerColumnsChanged',
|
|
106
|
+
'onGridMenuClearAllFilters',
|
|
107
|
+
'onGridMenuClearAllSorting',
|
|
108
|
+
],
|
|
109
|
+
() => this.redrawAll(true)
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
protected override beforeDetailViewRender(item: any): void {
|
|
115
|
+
this.disposeView(item, true);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected override renderDetailView(item: any): void {
|
|
119
|
+
if (this.rowOptions.viewComponent) {
|
|
120
|
+
this.renderComponent(item, this.rowOptions.viewComponent);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
protected async processItem(item: any): Promise<void> {
|
|
125
|
+
const response = await this._userProcess!(item);
|
|
126
|
+
const detail = response instanceof Response ? await response.json() : response;
|
|
127
|
+
if (!detail || !(this.itemIdField in detail)) {
|
|
128
|
+
throw new Error(`[Slickgrid-Svelte] Row detail process must return an item containing "${this.itemIdField}".`);
|
|
129
|
+
}
|
|
130
|
+
if (!this._disposed) {
|
|
131
|
+
this.onAsyncResponse.notify({ item: detail }, new SlickEventData(), this);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
protected renderComponent(item: any, component: Component<any>, flush = true): void {
|
|
136
|
+
const id = item?.[this.itemIdField];
|
|
137
|
+
const container = this._grid.getContainerNode().getElementsByClassName(`row-detail-${id}`)[0] as HTMLElement | undefined;
|
|
138
|
+
if (!container) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const existing = this._views.get(id);
|
|
142
|
+
if (existing?.component && this.rowOptions.keepComponentAlive && existing.item === item && this.reattachView(existing, container)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (existing) {
|
|
146
|
+
this.disposeView(item, true);
|
|
147
|
+
}
|
|
148
|
+
const element = document.createElement('div');
|
|
149
|
+
container.appendChild(element);
|
|
150
|
+
const view = mount(component, {
|
|
151
|
+
target: element,
|
|
152
|
+
props: { model: item, addon: this, grid: this._grid, dataView: this.dataView, parentRef: this.rowOptions.parentRef },
|
|
153
|
+
});
|
|
154
|
+
// effects (e.g. onMount) only run on flush, batched callers flush once after rendering all their views
|
|
155
|
+
if (flush) {
|
|
156
|
+
flushSync();
|
|
157
|
+
}
|
|
158
|
+
this._views.set(id, { item, element, component: view, rendered: true });
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
protected disposeView(item: any, destroy: boolean, removeFromMap = destroy): void {
|
|
162
|
+
const id = item?.[this.itemIdField];
|
|
163
|
+
const view = this._views.get(id);
|
|
164
|
+
if (!view) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (destroy) {
|
|
168
|
+
if (view.component) {
|
|
169
|
+
void unmount(view.component);
|
|
170
|
+
view.component = undefined;
|
|
171
|
+
}
|
|
172
|
+
if (removeFromMap) {
|
|
173
|
+
this._views.delete(id);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
view.rendered = false;
|
|
177
|
+
view.element.remove();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
protected detachViewFromDom(item: any): void {
|
|
181
|
+
this.disposeView(item, false);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
protected reattachView(view: MountedView, container?: HTMLElement): boolean {
|
|
185
|
+
const target =
|
|
186
|
+
container ??
|
|
187
|
+
(this._grid.getContainerNode().getElementsByClassName(`row-detail-${view.item[this.itemIdField]}`)[0] as HTMLElement | undefined);
|
|
188
|
+
if (!target) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (view.element.parentElement !== target) {
|
|
192
|
+
target.appendChild(view.element);
|
|
193
|
+
}
|
|
194
|
+
view.rendered = true;
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
protected disposeAll(): void {
|
|
199
|
+
for (const view of Array.from(this._views.values())) {
|
|
200
|
+
this.disposeView(view.item, true);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
protected redrawView(item: any, flush = true): void {
|
|
205
|
+
const view = this._views.get(item?.[this.itemIdField]);
|
|
206
|
+
const component = item?.[`${this._keyPrefix}detailViewLoaded`] ? this.rowOptions.viewComponent : this.rowOptions.preloadComponent;
|
|
207
|
+
if (view?.component && this.rowOptions.keepComponentAlive && view.item === item && this.reattachView(view)) {
|
|
208
|
+
return;
|
|
209
|
+
} else if (component) {
|
|
210
|
+
this.renderComponent(item, component, flush);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
protected redrawAll(forceRedraw: boolean): void {
|
|
215
|
+
this._forceRedrawPending ||= forceRedraw;
|
|
216
|
+
clearTimeout(this._renderTimer);
|
|
217
|
+
this._renderTimer = setTimeout(() => {
|
|
218
|
+
const forcePendingRedraw = this._forceRedrawPending;
|
|
219
|
+
this._forceRedrawPending = false;
|
|
220
|
+
this.resetRenderedRows();
|
|
221
|
+
for (const view of Array.from(this._views.values())) {
|
|
222
|
+
if (forcePendingRedraw || !view.rendered || !view.element.isConnected) {
|
|
223
|
+
// keep a placeholder so the view is re-created when its panel is back in the DOM
|
|
224
|
+
forcePendingRedraw && this.disposeView(view.item, true, false);
|
|
225
|
+
this.redrawView(view.item, false);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
flushSync();
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
protected redrawDetached(): void {
|
|
233
|
+
const renderedRange = this._views.size ? this._grid.getRenderedRange() : undefined;
|
|
234
|
+
if (!renderedRange) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
let hasRedrawn = false;
|
|
238
|
+
for (const view of Array.from(this._views.values())) {
|
|
239
|
+
const itemId = view.item?.[this.itemIdField];
|
|
240
|
+
if (!this._renderedViewportRowIds.has(itemId) || (view.rendered && view.element.isConnected)) {
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const rowIndex = this.dataView.getRowById(itemId);
|
|
244
|
+
if (rowIndex === undefined || rowIndex < renderedRange.top || rowIndex > renderedRange.bottom) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
this.redrawView(view.item, false);
|
|
248
|
+
hasRedrawn = true;
|
|
249
|
+
}
|
|
250
|
+
if (hasRedrawn) {
|
|
251
|
+
flushSync();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Dispose of an individual mounted view while leaving the row-detail plugin active. */
|
|
256
|
+
disposeViewByItem(item: any, removeFromArray = false): void {
|
|
257
|
+
this.disposeView(item, true, removeFromArray);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
disposeAllViewComponents(): void {
|
|
261
|
+
this.disposeAll();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Redraw the expanded row detail components, `forceRedraw` also re-creates the ones that are currently rendered. */
|
|
265
|
+
redrawAllViewComponents(forceRedraw = false): void {
|
|
266
|
+
this.redrawAll(forceRedraw);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
getAddonInstance(): SvelteRowDetailView {
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
override collapseDetailView(itemId: number | string, isMultipleCollapsing = false): void {
|
|
274
|
+
const item = this.dataView.getItemById(itemId);
|
|
275
|
+
if (item) {
|
|
276
|
+
this.disposeView(item, true);
|
|
277
|
+
}
|
|
278
|
+
super.collapseDetailView(itemId, isMultipleCollapsing);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
override dispose(): void {
|
|
282
|
+
this._disposed = true;
|
|
283
|
+
clearTimeout(this._renderTimer);
|
|
284
|
+
this._forceRedrawPending = false;
|
|
285
|
+
this._subscriptions.forEach((subscription) => subscription.unsubscribe?.());
|
|
286
|
+
this.disposeAll();
|
|
287
|
+
super.dispose();
|
|
288
|
+
}
|
|
289
|
+
}
|