@toolbox-web/grid 1.6.2 → 1.8.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 +51 -15
- package/all.js +267 -158
- package/all.js.map +1 -1
- package/index.js +866 -722
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +68 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +182 -1
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -1
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +56 -1
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +36 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +1349 -31
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +140 -87
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +64 -7
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +123 -65
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +6 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +95 -13
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +91 -34
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +6 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +192 -123
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +57 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +7 -2
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +142 -60
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +69 -12
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +70 -13
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +3 -3
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +106 -36
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +57 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +57 -0
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts.map +1 -1
- package/lib/plugins/print/index.js +58 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/column-drag.d.ts +2 -2
- package/lib/plugins/reorder/index.js +68 -17
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts +6 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +125 -54
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +169 -112
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +14 -2
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +84 -7
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +79 -22
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +7 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +140 -58
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +6 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +79 -10
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +57 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +80 -2
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +25 -25
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/print.umd.js +1 -1
- package/umd/plugins/print.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
|
@@ -11,7 +11,7 @@ const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
11
11
|
filterActive: h,
|
|
12
12
|
print: "🖨️"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class v {
|
|
15
15
|
/**
|
|
16
16
|
* Plugin dependencies - declare other plugins this one requires.
|
|
17
17
|
*
|
|
@@ -149,6 +149,63 @@ class C {
|
|
|
149
149
|
const o = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
|
|
150
150
|
return this.grid?.dispatchEvent?.(o), o.defaultPrevented;
|
|
151
151
|
}
|
|
152
|
+
// =========================================================================
|
|
153
|
+
// Event Bus - Plugin-to-Plugin Communication
|
|
154
|
+
// =========================================================================
|
|
155
|
+
/**
|
|
156
|
+
* Subscribe to an event from another plugin.
|
|
157
|
+
* The subscription is automatically cleaned up when this plugin is detached.
|
|
158
|
+
*
|
|
159
|
+
* @category Plugin Development
|
|
160
|
+
* @param eventType - The event type to listen for (e.g., 'filter-change')
|
|
161
|
+
* @param callback - The callback to invoke when the event is emitted
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // In attach() or other initialization
|
|
166
|
+
* this.on('filter-change', (detail) => {
|
|
167
|
+
* console.log('Filter changed:', detail);
|
|
168
|
+
* });
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
on(t, e) {
|
|
172
|
+
this.grid?._pluginManager?.subscribe(this, t, e);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Unsubscribe from a plugin event.
|
|
176
|
+
*
|
|
177
|
+
* @category Plugin Development
|
|
178
|
+
* @param eventType - The event type to stop listening for
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* this.off('filter-change');
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
off(t) {
|
|
186
|
+
this.grid?._pluginManager?.unsubscribe(this, t);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Emit an event to other plugins via the Event Bus.
|
|
190
|
+
* This is for inter-plugin communication only; it does NOT dispatch DOM events.
|
|
191
|
+
* Use `emit()` to dispatch DOM events that external consumers can listen to.
|
|
192
|
+
*
|
|
193
|
+
* @category Plugin Development
|
|
194
|
+
* @param eventType - The event type to emit (should be declared in manifest.events)
|
|
195
|
+
* @param detail - The event payload
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* // Emit to other plugins (not DOM)
|
|
200
|
+
* this.emitPluginEvent('filter-change', { field: 'name', value: 'Alice' });
|
|
201
|
+
*
|
|
202
|
+
* // For DOM events that consumers can addEventListener to:
|
|
203
|
+
* this.emit('filter-change', { field: 'name', value: 'Alice' });
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
emitPluginEvent(t, e) {
|
|
207
|
+
this.grid?._pluginManager?.emitPluginEvent(t, e);
|
|
208
|
+
}
|
|
152
209
|
/**
|
|
153
210
|
* Request a re-render of the grid.
|
|
154
211
|
*/
|
|
@@ -311,20 +368,20 @@ class C {
|
|
|
311
368
|
}
|
|
312
369
|
// #endregion
|
|
313
370
|
}
|
|
314
|
-
function
|
|
371
|
+
function C(r, t, e) {
|
|
315
372
|
return t.length ? [...r].sort((o, i) => {
|
|
316
373
|
for (const n of t) {
|
|
317
|
-
const d = e.find((c) => c.field === n.field)?.sortComparator ??
|
|
374
|
+
const d = e.find((c) => c.field === n.field)?.sortComparator ?? M, u = o[n.field], g = i[n.field], s = d(u, g, o, i);
|
|
318
375
|
if (s !== 0)
|
|
319
376
|
return n.direction === "asc" ? s : -s;
|
|
320
377
|
}
|
|
321
378
|
return 0;
|
|
322
379
|
}) : [...r];
|
|
323
380
|
}
|
|
324
|
-
function
|
|
381
|
+
function M(r, t) {
|
|
325
382
|
return r == null && t == null ? 0 : r == null ? 1 : t == null ? -1 : typeof r == "number" && typeof t == "number" ? r - t : r instanceof Date && t instanceof Date ? r.getTime() - t.getTime() : typeof r == "boolean" && typeof t == "boolean" ? r === t ? 0 : r ? -1 : 1 : String(r).localeCompare(String(t));
|
|
326
383
|
}
|
|
327
|
-
function
|
|
384
|
+
function S(r, t, e, o) {
|
|
328
385
|
const i = r.find((n) => n.field === t);
|
|
329
386
|
return e ? i ? i.direction === "asc" ? r.map((n) => n.field === t ? { ...n, direction: "desc" } : n) : r.filter((n) => n.field !== t) : r.length < o ? [...r, { field: t, direction: "asc" }] : r : i?.direction === "asc" ? [{ field: t, direction: "desc" }] : i?.direction === "desc" ? [] : [{ field: t, direction: "asc" }];
|
|
330
387
|
}
|
|
@@ -335,12 +392,12 @@ function m(r, t) {
|
|
|
335
392
|
function p(r, t) {
|
|
336
393
|
return r.find((e) => e.field === t)?.direction;
|
|
337
394
|
}
|
|
338
|
-
const
|
|
339
|
-
class
|
|
395
|
+
const w = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-indicator{margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-index{font-size:var(--tbw-font-size-2xs, .7em);background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:var(--tbw-multi-sort-badge-size, 1em);height:var(--tbw-multi-sort-badge-size, 1em);display:inline-flex;align-items:center;justify-content:center;margin-left:var(--tbw-spacing-xs, .125em);font-weight:600}}';
|
|
396
|
+
class y extends v {
|
|
340
397
|
/** @internal */
|
|
341
398
|
name = "multiSort";
|
|
342
399
|
/** @internal */
|
|
343
|
-
styles =
|
|
400
|
+
styles = w;
|
|
344
401
|
/** @internal */
|
|
345
402
|
get defaultConfig() {
|
|
346
403
|
return {
|
|
@@ -360,13 +417,13 @@ class M extends C {
|
|
|
360
417
|
// #region Hooks
|
|
361
418
|
/** @internal */
|
|
362
419
|
processRows(t) {
|
|
363
|
-
return this.sortModel.length === 0 ? [...t] :
|
|
420
|
+
return this.sortModel.length === 0 ? [...t] : C([...t], this.sortModel, [...this.columns]);
|
|
364
421
|
}
|
|
365
422
|
/** @internal */
|
|
366
423
|
onHeaderClick(t) {
|
|
367
424
|
if (!this.columns.find((n) => n.field === t.field)?.sortable) return !1;
|
|
368
425
|
const o = t.originalEvent.shiftKey, i = this.config.maxSortColumns ?? 3;
|
|
369
|
-
return this.sortModel =
|
|
426
|
+
return this.sortModel = S(this.sortModel, t.field, o, i), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
370
427
|
}
|
|
371
428
|
/** @internal */
|
|
372
429
|
afterRender() {
|
|
@@ -381,8 +438,8 @@ class M extends C {
|
|
|
381
438
|
i.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), i.setAttribute("data-sort", d);
|
|
382
439
|
const s = document.createElement("span");
|
|
383
440
|
s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
|
|
384
|
-
const c = i.querySelector(".tbw-filter-btn"), b = i.querySelector(".resize-handle"),
|
|
385
|
-
if (
|
|
441
|
+
const c = i.querySelector(".tbw-filter-btn"), b = i.querySelector(".resize-handle"), f = c ?? b;
|
|
442
|
+
if (f ? i.insertBefore(s, f) : i.appendChild(s), e && this.sortModel.length > 1 && a !== void 0) {
|
|
386
443
|
const l = document.createElement("span");
|
|
387
444
|
l.className = "sort-index", l.textContent = String(a), s.nextSibling ? i.insertBefore(l, s.nextSibling) : i.appendChild(l);
|
|
388
445
|
}
|
|
@@ -462,6 +519,6 @@ class M extends C {
|
|
|
462
519
|
// #endregion
|
|
463
520
|
}
|
|
464
521
|
export {
|
|
465
|
-
|
|
522
|
+
y as MultiSortPlugin
|
|
466
523
|
};
|
|
467
524
|
//# sourceMappingURL=index.js.map
|