@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,iBAAiB,EAAmB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAkCrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IACtE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAIjE;IAGD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,WAAW,CAA4B;IAK/C,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAMhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAavB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAoCtC;IAEF;;;;OAIG;IACH,OAAO,CAAC,cAAc;
|
|
1
|
+
{"version":3,"file":"ContextMenuPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/context-menu/ContextMenuPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,KAAK,EAAE,iBAAiB,EAAmB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAkCrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,iBAAiB,CAAC;IACtE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,iBAAiB;IAE9B,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAIjE;IAGD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,WAAW,CAA4B;IAK/C,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,OAAO,+BAA+B,EAAE,WAAW,GAAG,IAAI;IAMhF,gBAAgB;IACP,MAAM,IAAI,IAAI;IAavB;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAoCtC;IAEF;;;;OAIG;IACH,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,qBAAqB;IAqC7B;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAsB/B,gBAAgB;IACP,WAAW,IAAI,IAAI;IA2F5B;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI;IAoCxE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAQhB;;;OAGG;IACH,UAAU,IAAI,OAAO;CAMtB"}
|
|
@@ -11,7 +11,7 @@ const y = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
11
11
|
filterActive: y,
|
|
12
12
|
print: "🖨️"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class S {
|
|
15
15
|
/**
|
|
16
16
|
* Plugin dependencies - declare other plugins this one requires.
|
|
17
17
|
*
|
|
@@ -149,6 +149,63 @@ class M {
|
|
|
149
149
|
const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
|
|
150
150
|
return this.grid?.dispatchEvent?.(n), n.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(e, t) {
|
|
172
|
+
this.grid?._pluginManager?.subscribe(this, e, t);
|
|
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(e) {
|
|
186
|
+
this.grid?._pluginManager?.unsubscribe(this, e);
|
|
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(e, t) {
|
|
207
|
+
this.grid?._pluginManager?.emitPluginEvent(e, t);
|
|
208
|
+
}
|
|
152
209
|
/**
|
|
153
210
|
* Request a re-render of the grid.
|
|
154
211
|
*/
|
|
@@ -311,31 +368,31 @@ class M {
|
|
|
311
368
|
}
|
|
312
369
|
// #endregion
|
|
313
370
|
}
|
|
314
|
-
const
|
|
315
|
-
function x(
|
|
316
|
-
return (typeof
|
|
371
|
+
const g = "@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg));color:var(--tbw-context-menu-fg, var(--tbw-color-fg));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border));border-radius:var(--tbw-context-menu-radius, var(--tbw-border-radius));box-shadow:var(--tbw-context-menu-shadow, 0 2px 10px var(--tbw-color-shadow));min-width:var(--tbw-context-menu-min-width, var(--tbw-menu-min-width));padding:var(--tbw-spacing-xs) 0;z-index:10000;font-size:var(--tbw-context-menu-font-size, var(--tbw-font-size-sm));font-family:var(--tbw-context-menu-font-family, var(--tbw-font-family))}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-context-menu-item-padding, var(--tbw-menu-item-padding));cursor:pointer;gap:var(--tbw-context-menu-item-gap, var(--tbw-menu-item-gap))}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:var(--tbw-context-menu-danger, var(--tbw-color-danger))}.tbw-context-menu-icon{width:var(--tbw-context-menu-icon-size, var(--tbw-icon-size));text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted));font-size:var(--tbw-context-menu-shortcut-size, var(--tbw-font-size-xs))}.tbw-context-menu-arrow{font-size:var(--tbw-context-menu-arrow-size, var(--tbw-font-size-2xs));color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border));margin:var(--tbw-spacing-xs) 0}}";
|
|
372
|
+
function x(s, e) {
|
|
373
|
+
return (typeof s == "function" ? s(e) : s).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
|
|
317
374
|
}
|
|
318
|
-
function z(
|
|
319
|
-
return
|
|
375
|
+
function z(s, e) {
|
|
376
|
+
return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
|
|
320
377
|
}
|
|
321
|
-
function v(
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
for (const o of
|
|
378
|
+
function v(s, e, t, n = I.submenuArrow) {
|
|
379
|
+
const r = document.createElement("div");
|
|
380
|
+
r.className = "tbw-context-menu", r.setAttribute("role", "menu");
|
|
381
|
+
for (const o of s) {
|
|
325
382
|
if (o.separator) {
|
|
326
383
|
const l = document.createElement("div");
|
|
327
|
-
l.className = "tbw-context-menu-separator", l.setAttribute("role", "separator"),
|
|
384
|
+
l.className = "tbw-context-menu-separator", l.setAttribute("role", "separator"), r.appendChild(l);
|
|
328
385
|
continue;
|
|
329
386
|
}
|
|
330
387
|
const i = document.createElement("div");
|
|
331
388
|
i.className = "tbw-context-menu-item", o.cssClass && i.classList.add(o.cssClass), i.setAttribute("role", "menuitem"), i.setAttribute("data-id", o.id);
|
|
332
|
-
const
|
|
333
|
-
if (
|
|
389
|
+
const u = z(o, e);
|
|
390
|
+
if (u && (i.classList.add("disabled"), i.setAttribute("aria-disabled", "true")), o.icon) {
|
|
334
391
|
const l = document.createElement("span");
|
|
335
392
|
l.className = "tbw-context-menu-icon", l.innerHTML = o.icon, i.appendChild(l);
|
|
336
393
|
}
|
|
337
|
-
const
|
|
338
|
-
if (
|
|
394
|
+
const c = document.createElement("span");
|
|
395
|
+
if (c.className = "tbw-context-menu-label", c.textContent = o.name, i.appendChild(c), o.shortcut) {
|
|
339
396
|
const l = document.createElement("span");
|
|
340
397
|
l.className = "tbw-context-menu-shortcut", l.textContent = o.shortcut, i.appendChild(l);
|
|
341
398
|
}
|
|
@@ -346,42 +403,42 @@ function v(r, e, t, n = I.submenuArrow) {
|
|
|
346
403
|
const b = x(o.subMenu, e), d = v(b, e, t, n);
|
|
347
404
|
d.classList.add("tbw-context-submenu"), d.style.position = "absolute", d.style.left = "100%", d.style.top = "0", i.style.position = "relative", i.appendChild(d);
|
|
348
405
|
}), i.addEventListener("mouseleave", () => {
|
|
349
|
-
const
|
|
350
|
-
|
|
406
|
+
const a = i.querySelector(".tbw-context-menu");
|
|
407
|
+
a && a.remove();
|
|
351
408
|
});
|
|
352
409
|
}
|
|
353
|
-
!
|
|
410
|
+
!u && o.action && !o.subMenu && i.addEventListener("click", (l) => {
|
|
354
411
|
l.stopPropagation(), t(o);
|
|
355
|
-
}),
|
|
412
|
+
}), r.appendChild(i);
|
|
356
413
|
}
|
|
357
|
-
return
|
|
414
|
+
return r;
|
|
358
415
|
}
|
|
359
|
-
function C(
|
|
360
|
-
|
|
361
|
-
const n =
|
|
362
|
-
let i = e,
|
|
363
|
-
e + n.width >
|
|
416
|
+
function C(s, e, t) {
|
|
417
|
+
s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
|
|
418
|
+
const n = s.getBoundingClientRect(), r = window.innerWidth, o = window.innerHeight;
|
|
419
|
+
let i = e, u = t;
|
|
420
|
+
e + n.width > r && (i = e - n.width), t + n.height > o && (u = t - n.height), i = Math.max(0, i), u = Math.max(0, u), s.style.left = `${i}px`, s.style.top = `${u}px`, s.style.visibility = "visible";
|
|
364
421
|
}
|
|
365
|
-
let h = null, f = null, m = null,
|
|
422
|
+
let h = null, f = null, m = null, w = 0;
|
|
366
423
|
const p = [
|
|
367
424
|
{
|
|
368
425
|
id: "copy",
|
|
369
426
|
name: "Copy",
|
|
370
427
|
shortcut: "Ctrl+C",
|
|
371
|
-
action: (
|
|
372
|
-
|
|
428
|
+
action: (s) => {
|
|
429
|
+
s.grid?.plugins?.clipboard?.copy?.();
|
|
373
430
|
}
|
|
374
431
|
},
|
|
375
432
|
{ separator: !0, id: "sep1", name: "" },
|
|
376
433
|
{
|
|
377
434
|
id: "export-csv",
|
|
378
435
|
name: "Export CSV",
|
|
379
|
-
action: (
|
|
380
|
-
|
|
436
|
+
action: (s) => {
|
|
437
|
+
s.grid?.plugins?.export?.exportCsv?.();
|
|
381
438
|
}
|
|
382
439
|
}
|
|
383
440
|
];
|
|
384
|
-
class
|
|
441
|
+
class M extends S {
|
|
385
442
|
/** @internal */
|
|
386
443
|
name = "contextMenu";
|
|
387
444
|
/** @internal */
|
|
@@ -399,7 +456,7 @@ class S extends M {
|
|
|
399
456
|
// #region Lifecycle
|
|
400
457
|
/** @internal */
|
|
401
458
|
attach(e) {
|
|
402
|
-
super.attach(e), this.installGlobalHandlers(),
|
|
459
|
+
super.attach(e), this.installGlobalHandlers(), w++;
|
|
403
460
|
}
|
|
404
461
|
/** @internal */
|
|
405
462
|
detach() {
|
|
@@ -456,18 +513,19 @@ class S extends M {
|
|
|
456
513
|
copyGridStyles(e) {
|
|
457
514
|
const t = this.gridElement;
|
|
458
515
|
if (!t) return;
|
|
459
|
-
const n = getComputedStyle(t),
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
516
|
+
const n = getComputedStyle(t), r = [], o = n.getPropertyValue("color-scheme").trim();
|
|
517
|
+
o && r.push(`color-scheme: ${o}`);
|
|
518
|
+
for (const i of M.CSS_VARS_TO_COPY) {
|
|
519
|
+
const u = n.getPropertyValue(i).trim();
|
|
520
|
+
u && r.push(`${i}: ${u}`);
|
|
463
521
|
}
|
|
464
|
-
if (
|
|
465
|
-
const
|
|
466
|
-
e.setAttribute("style",
|
|
522
|
+
if (r.length > 0) {
|
|
523
|
+
const i = e.getAttribute("style") || "";
|
|
524
|
+
e.setAttribute("style", i + r.join("; ") + ";");
|
|
467
525
|
}
|
|
468
526
|
}
|
|
469
527
|
installGlobalHandlers() {
|
|
470
|
-
!m && typeof document < "u" && typeof
|
|
528
|
+
!m && typeof document < "u" && typeof g == "string" && g && (m = document.createElement("style"), m.id = "tbw-context-menu-styles", m.textContent = g, document.head.appendChild(m)), h || (h = () => {
|
|
471
529
|
document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
|
|
472
530
|
}, document.addEventListener("click", h)), f || (f = (e) => {
|
|
473
531
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
|
|
@@ -478,7 +536,7 @@ class S extends M {
|
|
|
478
536
|
* Uses reference counting to ensure handlers persist while any grid uses the plugin.
|
|
479
537
|
*/
|
|
480
538
|
uninstallGlobalHandlers() {
|
|
481
|
-
|
|
539
|
+
w--, !(w > 0) && (h && (document.removeEventListener("click", h), h = null), f && (document.removeEventListener("keydown", f), f = null), m && (m.remove(), m = null));
|
|
482
540
|
}
|
|
483
541
|
// #endregion
|
|
484
542
|
// #region Hooks
|
|
@@ -488,46 +546,46 @@ class S extends M {
|
|
|
488
546
|
if (!e) return;
|
|
489
547
|
const t = e.children[0];
|
|
490
548
|
t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
const o =
|
|
494
|
-
let
|
|
549
|
+
const r = n;
|
|
550
|
+
r.preventDefault();
|
|
551
|
+
const o = r.target, i = o.closest("[data-row][data-col]"), u = o.closest(".header-cell");
|
|
552
|
+
let c;
|
|
495
553
|
if (i) {
|
|
496
|
-
const
|
|
497
|
-
|
|
554
|
+
const a = parseInt(i.getAttribute("data-row") ?? "-1", 10), b = parseInt(i.getAttribute("data-col") ?? "-1", 10), d = this.columns[b], E = this.rows[a];
|
|
555
|
+
c = {
|
|
498
556
|
row: E,
|
|
499
|
-
rowIndex:
|
|
557
|
+
rowIndex: a,
|
|
500
558
|
column: d,
|
|
501
559
|
columnIndex: b,
|
|
502
560
|
field: d?.field ?? "",
|
|
503
561
|
value: E?.[d?.field] ?? null,
|
|
504
562
|
isHeader: !1,
|
|
505
|
-
event:
|
|
563
|
+
event: r
|
|
506
564
|
};
|
|
507
|
-
} else if (
|
|
508
|
-
const
|
|
509
|
-
|
|
565
|
+
} else if (u) {
|
|
566
|
+
const a = parseInt(u.getAttribute("data-col") ?? "-1", 10), b = this.columns[a];
|
|
567
|
+
c = {
|
|
510
568
|
row: null,
|
|
511
569
|
rowIndex: -1,
|
|
512
570
|
column: b,
|
|
513
|
-
columnIndex:
|
|
571
|
+
columnIndex: a,
|
|
514
572
|
field: b?.field ?? "",
|
|
515
573
|
value: null,
|
|
516
574
|
isHeader: !0,
|
|
517
|
-
event:
|
|
575
|
+
event: r
|
|
518
576
|
};
|
|
519
577
|
} else
|
|
520
578
|
return;
|
|
521
|
-
this.params =
|
|
522
|
-
const l = x(this.config.items ?? p,
|
|
579
|
+
this.params = c, this.position = { x: r.clientX, y: r.clientY };
|
|
580
|
+
const l = x(this.config.items ?? p, c);
|
|
523
581
|
l.length && (this.menuElement && this.menuElement.remove(), this.menuElement = v(
|
|
524
582
|
l,
|
|
525
|
-
|
|
526
|
-
(
|
|
527
|
-
|
|
583
|
+
c,
|
|
584
|
+
(a) => {
|
|
585
|
+
a.action && a.action(c), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
528
586
|
},
|
|
529
587
|
this.gridIcons.submenuArrow
|
|
530
|
-
), document.body.appendChild(this.menuElement), this.copyGridStyles(this.menuElement), C(this.menuElement,
|
|
588
|
+
), document.body.appendChild(this.menuElement), this.copyGridStyles(this.menuElement), C(this.menuElement, r.clientX, r.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: c, items: l }));
|
|
531
589
|
}));
|
|
532
590
|
}
|
|
533
591
|
// #endregion
|
|
@@ -539,7 +597,7 @@ class S extends M {
|
|
|
539
597
|
* @param params - Partial context menu parameters
|
|
540
598
|
*/
|
|
541
599
|
showMenu(e, t, n) {
|
|
542
|
-
const
|
|
600
|
+
const r = {
|
|
543
601
|
row: n.row ?? null,
|
|
544
602
|
rowIndex: n.rowIndex ?? -1,
|
|
545
603
|
column: n.column ?? null,
|
|
@@ -548,12 +606,12 @@ class S extends M {
|
|
|
548
606
|
value: n.value ?? null,
|
|
549
607
|
isHeader: n.isHeader ?? !1,
|
|
550
608
|
event: n.event ?? new MouseEvent("contextmenu")
|
|
551
|
-
}, o = x(this.config.items ?? p,
|
|
609
|
+
}, o = x(this.config.items ?? p, r);
|
|
552
610
|
this.menuElement && this.menuElement.remove(), this.menuElement = v(
|
|
553
611
|
o,
|
|
554
|
-
|
|
612
|
+
r,
|
|
555
613
|
(i) => {
|
|
556
|
-
i.action && i.action(
|
|
614
|
+
i.action && i.action(r), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
557
615
|
},
|
|
558
616
|
this.gridIcons.submenuArrow
|
|
559
617
|
), document.body.appendChild(this.menuElement), this.copyGridStyles(this.menuElement), C(this.menuElement, e, t), this.isOpen = !0;
|
|
@@ -575,6 +633,6 @@ class S extends M {
|
|
|
575
633
|
// Styles are injected globally via installGlobalHandlers() since menu renders in document.body
|
|
576
634
|
}
|
|
577
635
|
export {
|
|
578
|
-
|
|
636
|
+
M as ContextMenuPlugin
|
|
579
637
|
};
|
|
580
638
|
//# sourceMappingURL=index.js.map
|