@toolbox-web/grid 1.3.1 → 1.4.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/all.d.ts +1 -0
- package/all.d.ts.map +1 -1
- package/all.js +899 -637
- package/all.js.map +1 -1
- package/index.js +641 -600
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts +7 -0
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/types.d.ts +147 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +2 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +6 -5
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +2 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +9 -6
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +2 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +60 -59
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +2 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +2 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +2 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +2 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +2 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +2 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +2 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts +98 -0
- package/lib/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/lib/plugins/print/index.d.ts +10 -0
- package/lib/plugins/print/index.d.ts.map +1 -0
- package/lib/plugins/print/index.js +626 -0
- package/lib/plugins/print/index.js.map +1 -0
- package/lib/plugins/print/print-isolated.d.ts +26 -0
- package/lib/plugins/print/print-isolated.d.ts.map +1 -0
- package/lib/plugins/print/types.d.ts +147 -0
- package/lib/plugins/print/types.d.ts.map +1 -0
- package/lib/plugins/reorder/index.js +2 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +2 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +2 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +109 -97
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +2 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +2 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +2 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +98 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +11 -11
- package/umd/grid.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/print.umd.js +76 -0
- package/umd/plugins/print.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
function _(h) {
|
|
2
|
-
const { totalRows: e, viewportHeight: t, scrollTop: r, rowHeight:
|
|
3
|
-
let o = Math.floor(r /
|
|
2
|
+
const { totalRows: e, viewportHeight: t, scrollTop: r, rowHeight: i, overscan: n } = h, a = Math.ceil(t / i);
|
|
3
|
+
let o = Math.floor(r / i) - n;
|
|
4
4
|
o < 0 && (o = 0);
|
|
5
|
-
let l = o + a +
|
|
6
|
-
return l > e && (l = e), l === e && o > 0 && (o = Math.max(0, l - a -
|
|
5
|
+
let l = o + a + n * 2;
|
|
6
|
+
return l > e && (l = e), l === e && o > 0 && (o = Math.max(0, l - a - n * 2)), {
|
|
7
7
|
start: o,
|
|
8
8
|
end: l,
|
|
9
|
-
offsetY: o *
|
|
10
|
-
totalHeight: e *
|
|
9
|
+
offsetY: o * i,
|
|
10
|
+
totalHeight: e * i
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function M(h, e) {
|
|
@@ -23,7 +23,8 @@ const H = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
23
23
|
dragHandle: "⋮⋮",
|
|
24
24
|
toolPanel: "☰",
|
|
25
25
|
filter: H,
|
|
26
|
-
filterActive: H
|
|
26
|
+
filterActive: H,
|
|
27
|
+
print: "🖨️"
|
|
27
28
|
};
|
|
28
29
|
class q {
|
|
29
30
|
/**
|
|
@@ -335,21 +336,21 @@ function Y(h, e, t = !1) {
|
|
|
335
336
|
if (e.operator === "notBlank")
|
|
336
337
|
return r != null && r !== "";
|
|
337
338
|
if (r == null) return !1;
|
|
338
|
-
const
|
|
339
|
+
const i = String(r), n = t ? i : i.toLowerCase(), a = t ? String(e.value) : String(e.value).toLowerCase();
|
|
339
340
|
switch (e.operator) {
|
|
340
341
|
// Text operators
|
|
341
342
|
case "contains":
|
|
342
|
-
return
|
|
343
|
+
return n.includes(a);
|
|
343
344
|
case "notContains":
|
|
344
|
-
return !
|
|
345
|
+
return !n.includes(a);
|
|
345
346
|
case "equals":
|
|
346
|
-
return
|
|
347
|
+
return n === a;
|
|
347
348
|
case "notEquals":
|
|
348
|
-
return
|
|
349
|
+
return n !== a;
|
|
349
350
|
case "startsWith":
|
|
350
|
-
return
|
|
351
|
+
return n.startsWith(a);
|
|
351
352
|
case "endsWith":
|
|
352
|
-
return
|
|
353
|
+
return n.endsWith(a);
|
|
353
354
|
// Number/Date operators (use raw numeric values)
|
|
354
355
|
case "lessThan":
|
|
355
356
|
return Number(r) < Number(e.value);
|
|
@@ -371,7 +372,7 @@ function Y(h, e, t = !1) {
|
|
|
371
372
|
}
|
|
372
373
|
}
|
|
373
374
|
function D(h, e, t = !1) {
|
|
374
|
-
return e.length ? h.filter((r) => e.every((
|
|
375
|
+
return e.length ? h.filter((r) => e.every((i) => Y(r, i, t))) : h;
|
|
375
376
|
}
|
|
376
377
|
function $(h) {
|
|
377
378
|
return JSON.stringify(
|
|
@@ -386,12 +387,12 @@ function $(h) {
|
|
|
386
387
|
function V(h, e) {
|
|
387
388
|
const t = /* @__PURE__ */ new Set();
|
|
388
389
|
for (const r of h) {
|
|
389
|
-
const
|
|
390
|
-
|
|
390
|
+
const i = r[e];
|
|
391
|
+
i != null && t.add(i);
|
|
391
392
|
}
|
|
392
|
-
return [...t].sort((r,
|
|
393
|
+
return [...t].sort((r, i) => typeof r == "number" && typeof i == "number" ? r - i : String(r).localeCompare(String(i)));
|
|
393
394
|
}
|
|
394
|
-
const G = '@layer tbw-plugins{tbw-grid .tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem)}tbw-grid .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}tbw-grid .header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}tbw-grid .tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s;color:inherit;vertical-align:middle}tbw-grid .tbw-filter-btn:hover,tbw-grid .tbw-filter-btn.active{opacity:1;visibility:visible}tbw-grid .tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}}', K = "@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);left:anchor(left);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-search-input{width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:var(--tbw-font-size-xs, .75rem);padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}}";
|
|
395
|
+
const G = '@layer tbw-plugins{tbw-grid .tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem)}tbw-grid .tbw-quick-filter-input:focus{outline:none;border-color:var(--tbw-color-accent)}tbw-grid .header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}tbw-grid .tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s,display 0s allow-discrete;color:inherit;vertical-align:middle;transition-behavior:allow-discrete}tbw-grid .tbw-filter-btn:hover,tbw-grid .tbw-filter-btn.active{opacity:1;visibility:visible;display:inline-flex}tbw-grid .tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}tbw-grid .header-row .cell:hover .tbw-filter-btn,tbw-grid .header-row .cell.filtered .tbw-filter-btn{display:inline-flex;visibility:visible}}', K = "@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);left:anchor(left);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-search-input{width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:var(--tbw-font-size-xs, .75rem);padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}}";
|
|
395
396
|
class v extends q {
|
|
396
397
|
/** @internal */
|
|
397
398
|
name = "filtering";
|
|
@@ -466,19 +467,19 @@ class v extends q {
|
|
|
466
467
|
const r = $(t);
|
|
467
468
|
if (this.cacheKey === r && this.cachedResult)
|
|
468
469
|
return this.cachedResult;
|
|
469
|
-
const
|
|
470
|
-
return this.cachedResult =
|
|
470
|
+
const i = D([...e], t, this.config.caseSensitive);
|
|
471
|
+
return this.cachedResult = i, this.cacheKey = r, i;
|
|
471
472
|
}
|
|
472
473
|
/** @internal */
|
|
473
474
|
afterRender() {
|
|
474
475
|
const e = this.gridElement;
|
|
475
476
|
if (!e) return;
|
|
476
477
|
e.querySelectorAll('[part~="header-cell"]').forEach((r) => {
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
const
|
|
480
|
-
if (!
|
|
481
|
-
const a =
|
|
478
|
+
const i = r.getAttribute("data-col");
|
|
479
|
+
if (i === null) return;
|
|
480
|
+
const n = this.visibleColumns[parseInt(i, 10)];
|
|
481
|
+
if (!n || n.filterable === !1 || B(n)) return;
|
|
482
|
+
const a = n.field;
|
|
482
483
|
if (!a) return;
|
|
483
484
|
const o = this.filters.has(a);
|
|
484
485
|
let l = r.querySelector(".tbw-filter-btn");
|
|
@@ -490,10 +491,10 @@ class v extends q {
|
|
|
490
491
|
}
|
|
491
492
|
return;
|
|
492
493
|
}
|
|
493
|
-
l = document.createElement("button"), l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${
|
|
494
|
+
l = document.createElement("button"), l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${n.header ?? a}`);
|
|
494
495
|
const m = o ? "filterActive" : "filter";
|
|
495
496
|
this.setIcon(l, this.resolveIcon(m)), o && (l.classList.add("active"), r.classList.add("filtered")), l.addEventListener("click", (b) => {
|
|
496
|
-
b.stopPropagation(), this.toggleFilterPanel(a,
|
|
497
|
+
b.stopPropagation(), this.toggleFilterPanel(a, n, l);
|
|
497
498
|
});
|
|
498
499
|
const p = r.querySelector(".resize-handle");
|
|
499
500
|
p ? r.insertBefore(l, p) : r.appendChild(l);
|
|
@@ -594,8 +595,8 @@ class v extends q {
|
|
|
594
595
|
copyGridThemeContext(e) {
|
|
595
596
|
const t = this.gridElement;
|
|
596
597
|
if (!t) return;
|
|
597
|
-
for (const
|
|
598
|
-
|
|
598
|
+
for (const i of t.classList)
|
|
599
|
+
i.startsWith("tbw-") || i === "selecting" || e.classList.add(i);
|
|
599
600
|
const r = t.dataset.theme;
|
|
600
601
|
r && (e.dataset.theme = r);
|
|
601
602
|
}
|
|
@@ -620,27 +621,27 @@ class v extends q {
|
|
|
620
621
|
return;
|
|
621
622
|
}
|
|
622
623
|
this.closeFilterPanel();
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
625
|
-
|
|
626
|
-
this.openPanelField !== e || !this.panelElement || (
|
|
624
|
+
const i = document.createElement("div");
|
|
625
|
+
if (i.className = "tbw-filter-panel", this.copyGridThemeContext(i), this.isAnimationEnabled && i.classList.add("tbw-filter-panel-animated"), this.panelElement = i, this.openPanelField = e, this.config.valuesHandler) {
|
|
626
|
+
i.innerHTML = '<div class="tbw-filter-loading">Loading...</div>', document.body.appendChild(i), this.positionPanel(i, r), this.setupPanelCloseHandler(i, r), this.config.valuesHandler(e, t).then((a) => {
|
|
627
|
+
this.openPanelField !== e || !this.panelElement || (i.innerHTML = "", this.renderPanelContent(e, t, i, a));
|
|
627
628
|
});
|
|
628
629
|
return;
|
|
629
630
|
}
|
|
630
|
-
const
|
|
631
|
-
this.renderPanelContent(e, t,
|
|
631
|
+
const n = V(this.sourceRows, e);
|
|
632
|
+
this.renderPanelContent(e, t, i, n), document.body.appendChild(i), this.positionPanel(i, r), this.setupPanelCloseHandler(i, r);
|
|
632
633
|
}
|
|
633
634
|
/**
|
|
634
635
|
* Render filter panel content with given values
|
|
635
636
|
*/
|
|
636
|
-
renderPanelContent(e, t, r,
|
|
637
|
-
let
|
|
638
|
-
|
|
637
|
+
renderPanelContent(e, t, r, i) {
|
|
638
|
+
let n = this.excludedValues.get(e);
|
|
639
|
+
n || (n = /* @__PURE__ */ new Set(), this.excludedValues.set(e, n));
|
|
639
640
|
const a = this.searchText.get(e) ?? "", o = {
|
|
640
641
|
field: e,
|
|
641
642
|
column: t,
|
|
642
|
-
uniqueValues:
|
|
643
|
-
excludedValues:
|
|
643
|
+
uniqueValues: i,
|
|
644
|
+
excludedValues: n,
|
|
644
645
|
searchText: a,
|
|
645
646
|
applySetFilter: (m) => {
|
|
646
647
|
this.applySetFilter(e, m), this.closeFilterPanel();
|
|
@@ -654,7 +655,7 @@ class v extends q {
|
|
|
654
655
|
closePanel: () => this.closeFilterPanel()
|
|
655
656
|
};
|
|
656
657
|
let l = !1;
|
|
657
|
-
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(r, o), l = r.children.length > 0), l || this.renderDefaultFilterPanel(r, o,
|
|
658
|
+
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(r, o), l = r.children.length > 0), l || this.renderDefaultFilterPanel(r, o, i, n);
|
|
658
659
|
}
|
|
659
660
|
/**
|
|
660
661
|
* Setup click-outside handler to close the panel
|
|
@@ -690,28 +691,28 @@ class v extends q {
|
|
|
690
691
|
* Uses CSS Anchor Positioning if supported, falls back to JS positioning
|
|
691
692
|
*/
|
|
692
693
|
positionPanel(e, t) {
|
|
693
|
-
const
|
|
694
|
-
if (
|
|
694
|
+
const i = t.closest(".cell") ?? t;
|
|
695
|
+
if (i.style.anchorName = "--tbw-filter-anchor", this.panelAnchorElement = i, v.checkAnchorPositioningSupport()) {
|
|
695
696
|
requestAnimationFrame(() => {
|
|
696
|
-
const a = e.getBoundingClientRect(), o =
|
|
697
|
+
const a = e.getBoundingClientRect(), o = i.getBoundingClientRect();
|
|
697
698
|
a.top < o.top && e.classList.add("tbw-filter-panel-above");
|
|
698
699
|
});
|
|
699
700
|
return;
|
|
700
701
|
}
|
|
701
|
-
const
|
|
702
|
-
e.style.position = "fixed", e.style.top = `${
|
|
702
|
+
const n = i.getBoundingClientRect();
|
|
703
|
+
e.style.position = "fixed", e.style.top = `${n.bottom + 4}px`, e.style.left = `${n.left}px`, requestAnimationFrame(() => {
|
|
703
704
|
const a = e.getBoundingClientRect();
|
|
704
|
-
a.right > window.innerWidth - 8 && (e.style.left = `${
|
|
705
|
+
a.right > window.innerWidth - 8 && (e.style.left = `${n.right - a.width}px`), a.bottom > window.innerHeight - 8 && (e.style.top = `${n.top - a.height - 4}px`, e.classList.add("tbw-filter-panel-above"));
|
|
705
706
|
});
|
|
706
707
|
}
|
|
707
708
|
/**
|
|
708
709
|
* Render the default filter panel content
|
|
709
710
|
*/
|
|
710
|
-
renderDefaultFilterPanel(e, t, r,
|
|
711
|
-
const { field:
|
|
711
|
+
renderDefaultFilterPanel(e, t, r, i) {
|
|
712
|
+
const { field: n } = t, a = this.getListItemHeight(), o = document.createElement("div");
|
|
712
713
|
o.className = "tbw-filter-search";
|
|
713
714
|
const l = document.createElement("input");
|
|
714
|
-
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(
|
|
715
|
+
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(n) ?? "", o.appendChild(l), e.appendChild(o);
|
|
715
716
|
const m = document.createElement("div");
|
|
716
717
|
m.className = "tbw-filter-actions";
|
|
717
718
|
const p = document.createElement("label");
|
|
@@ -739,7 +740,7 @@ class v extends q {
|
|
|
739
740
|
const x = /* @__PURE__ */ new Map();
|
|
740
741
|
r.forEach((s) => {
|
|
741
742
|
const u = s == null ? "__null__" : String(s);
|
|
742
|
-
x.set(u, !
|
|
743
|
+
x.set(u, !i.has(s));
|
|
743
744
|
}), F();
|
|
744
745
|
let C = [];
|
|
745
746
|
const I = (s, u) => {
|
|
@@ -792,7 +793,7 @@ class v extends q {
|
|
|
792
793
|
let N;
|
|
793
794
|
l.addEventListener("input", () => {
|
|
794
795
|
clearTimeout(N), N = setTimeout(() => {
|
|
795
|
-
this.searchText.set(
|
|
796
|
+
this.searchText.set(n, l.value), L(l.value);
|
|
796
797
|
}, this.config.debounceMs ?? 150);
|
|
797
798
|
});
|
|
798
799
|
const R = document.createElement("div");
|
|
@@ -829,13 +830,13 @@ class v extends q {
|
|
|
829
830
|
/**
|
|
830
831
|
* Apply a text filter
|
|
831
832
|
*/
|
|
832
|
-
applyTextFilter(e, t, r,
|
|
833
|
+
applyTextFilter(e, t, r, i) {
|
|
833
834
|
this.filters.set(e, {
|
|
834
835
|
field: e,
|
|
835
836
|
type: "text",
|
|
836
837
|
operator: t,
|
|
837
838
|
value: r,
|
|
838
|
-
valueTo:
|
|
839
|
+
valueTo: i
|
|
839
840
|
}), this.applyFiltersInternal();
|
|
840
841
|
}
|
|
841
842
|
/**
|
|
@@ -847,13 +848,13 @@ class v extends q {
|
|
|
847
848
|
if (this.config.filterHandler) {
|
|
848
849
|
const t = this.grid;
|
|
849
850
|
t.setAttribute("aria-busy", "true");
|
|
850
|
-
const r = this.config.filterHandler(e, this.sourceRows),
|
|
851
|
-
t.removeAttribute("aria-busy"), this.cachedResult =
|
|
851
|
+
const r = this.config.filterHandler(e, this.sourceRows), i = (n) => {
|
|
852
|
+
t.removeAttribute("aria-busy"), this.cachedResult = n, this.grid.rows = n, this.emit("filter-change", {
|
|
852
853
|
filters: e,
|
|
853
|
-
filteredRowCount:
|
|
854
|
+
filteredRowCount: n.length
|
|
854
855
|
}), this.requestRender();
|
|
855
856
|
};
|
|
856
|
-
r && typeof r.then == "function" ? r.then(
|
|
857
|
+
r && typeof r.then == "function" ? r.then(i) : i(r);
|
|
857
858
|
return;
|
|
858
859
|
}
|
|
859
860
|
this.emit("filter-change", {
|