@svgrid/grid 2.5.2 → 2.6.2

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.
@@ -37,6 +37,7 @@
37
37
  name,
38
38
  size = 'md',
39
39
  ariaLabel,
40
+ block = false,
40
41
  invalid = false,
41
42
  required = false,
42
43
  error,
@@ -93,7 +94,7 @@
93
94
  </script>
94
95
 
95
96
  <SvField id={uid} {label} {hint} {error} {required} {dir}>
96
- <button bind:this={triggerEl} class="sv-country sv-country--{size}" class:is-open={ci.open} class:is-disabled={disabled} class:is-invalid={invalid} {...ci.triggerProps()}>
97
+ <button bind:this={triggerEl} class="sv-country sv-country--{size}" class:is-block={block} class:is-open={ci.open} class:is-disabled={disabled} class:is-invalid={invalid} {...ci.triggerProps()}>
97
98
  {#if selected}
98
99
  <span class="sv-country__flag" aria-hidden="true">{flagEmoji(selected.code)}</span>
99
100
  <span class="sv-country__name">{selected.name}</span>
@@ -157,4 +158,6 @@
157
158
  :global(.sv-country__opt) { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
158
159
  :global(.sv-country__opt.is-active) { background: var(--sg-row-hover-bg, #f1f5f9); }
159
160
  :global(.sv-country__opt.is-selected) { color: var(--sg-accent, #2563eb); font-weight: 600; }
161
+ /* Fill the container - see `block` in SvEditorProps. */
162
+ .sv-country.is-block { width: 100%; max-width: 100%; }
160
163
  </style>
@@ -1,4 +1,4 @@
1
- import { applyExcelFilter, applyGroupAggregate, normalizeForFilter, createColumnVirtualizer, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createTreeRowModel, createSvelteVirtualizer, createSortedRowModel, createSvGrid, getGridCellDomId, sortFns, } from "./index";
1
+ import { applyGroupAggregate, compileExcelFilter, normalizeForFilter, createColumnVirtualizer, createCoreRowModel, createExpandedRowModel, createFilteredRowModel, createGroupedRowModel, createTreeRowModel, createSvelteVirtualizer, createSortedRowModel, createSvGrid, getGridCellDomId, sortFns, } from "./index";
2
2
  import { createRowScrollScaling, resolveMaxDomHeight, } from "./virtualization/scroll-scaling";
3
3
  import "./sv-grid-scrollbar";
4
4
  import { computeColumnStat, formatsNeedingStats, formatNeedsStats, } from "./conditional-formatting";
@@ -976,7 +976,11 @@ export function createSvGridController(rawProps, domIdBase) {
976
976
  return value.trim().length > 0 && (valueTo ?? "").trim().length > 0;
977
977
  return value.trim().length > 0;
978
978
  };
979
- const evalCond = (cellValue, columnId, op, value, valueTo) => applyExcelFilter(cellValue, { id: columnId, operator: op, value, valueTo: op === "between" ? valueTo : undefined }, { locale: (props.filterLocale ?? props.localization?.locale) });
979
+ // Compile a condition ONCE per filter change rather than once per row.
980
+ // Folding the needle, splitting `in` tokens and building a regex all
981
+ // depend only on the filter, so over 100k rows this used to be 100k
982
+ // redundant passes.
983
+ const compileCond = (columnId, op, value, valueTo) => compileExcelFilter({ id: columnId, operator: op, value, valueTo: op === "between" ? valueTo : undefined }, { locale: (props.filterLocale ?? props.localization?.locale) });
980
984
  // A column filter is active if either of its (up to two) conditions is.
981
985
  const menuFilters = Object.entries(filterMenuValues).filter(([_, f]) => {
982
986
  const a = condActive(f.operator, f.value, f.valueTo);
@@ -984,19 +988,27 @@ export function createSvGridController(rawProps, domIdBase) {
984
988
  return a || b;
985
989
  });
986
990
  if (menuFilters.length) {
987
- rows = rows.filter((row) => menuFilters.every(([columnId, f]) => {
991
+ // Hoisted out of the row loop: each column's (up to two) conditions
992
+ // become compiled predicates before a single row is tested.
993
+ const compiledMenuFilters = menuFilters.map(([columnId, f]) => ({
994
+ columnId,
995
+ join: f.join,
996
+ a: condActive(f.operator, f.value, f.valueTo)
997
+ ? compileCond(columnId, f.operator, f.value, f.valueTo)
998
+ : null,
999
+ b: !!f.operator2 && condActive(f.operator2, f.value2 ?? "", f.valueTo2)
1000
+ ? compileCond(columnId, f.operator2, f.value2 ?? "", f.valueTo2)
1001
+ : null,
1002
+ }));
1003
+ rows = rows.filter((row) => compiledMenuFilters.every(({ columnId, join, a, b }) => {
988
1004
  const cellValue = getRowColumnValue(row, columnId);
989
- const aActive = condActive(f.operator, f.value, f.valueTo);
990
- const bActive = !!f.operator2 && condActive(f.operator2, f.value2 ?? "", f.valueTo2);
991
- const ra = aActive ? evalCond(cellValue, columnId, f.operator, f.value, f.valueTo) : null;
992
- const rb = bActive
993
- ? evalCond(cellValue, columnId, f.operator2, f.value2 ?? "", f.valueTo2)
994
- : null;
1005
+ const ra = a ? a(cellValue) : null;
1006
+ const rb = b ? b(cellValue) : null;
995
1007
  if (ra === null)
996
1008
  return rb ?? true;
997
1009
  if (rb === null)
998
1010
  return ra;
999
- return f.join === "OR" ? ra || rb : ra && rb;
1011
+ return join === "OR" ? ra || rb : ra && rb;
1000
1012
  }));
1001
1013
  }
1002
1014
  const valueFilterEntries = Object.entries(valueFilters);
@@ -44,6 +44,7 @@
44
44
  orientation = 'horizontal',
45
45
  name,
46
46
  ariaLabel,
47
+ block = false,
47
48
  invalid = false,
48
49
  required = false,
49
50
  error,
@@ -109,7 +110,7 @@
109
110
 
110
111
  <SvField id={uid} {label} {hint} {error} {required} {dir}>
111
112
  <div
112
- class="sv-slider sv-slider--{orientation} sv-slider--{size}"
113
+ class="sv-slider sv-slider--{orientation} sv-slider--{size}" class:is-block={block}
113
114
  class:is-disabled={disabled}
114
115
  class:is-readonly={readonly}
115
116
  dir={resolvedDir}
@@ -197,4 +198,6 @@
197
198
  .sv-slider__tick { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--sg-muted, #94a3b8); }
198
199
  .sv-slider--horizontal .sv-slider__tick { inset-inline-start: var(--p); top: 50%; transform: translate(-50%, -50%); }
199
200
  .sv-slider--vertical .sv-slider__tick { bottom: var(--p); left: 50%; transform: translate(-50%, 50%); }
201
+ /* Fill the container - see `block` in SvEditorProps. */
202
+ .sv-slider--horizontal.is-block { width: 100%; max-width: 100%; }
200
203
  </style>
@@ -36,6 +36,7 @@
36
36
  size = 'md',
37
37
  name,
38
38
  ariaLabel,
39
+ block = false,
39
40
  invalid = false,
40
41
  required = false,
41
42
  error,
@@ -69,7 +70,7 @@
69
70
  </script>
70
71
 
71
72
  <SvField id={uid} {label} {hint} {error} {required} {dir}>
72
- <div class="sv-tags sv-tags--{size}" class:is-disabled={disabled} class:is-invalid={invalid} {...ti.rootProps()}>
73
+ <div class="sv-tags sv-tags--{size}" class:is-block={block} class:is-disabled={disabled} class:is-invalid={invalid} {...ti.rootProps()}>
73
74
  {#each value as tag, i (tag + i)}
74
75
  <span class="sv-tags__chip" {...ti.tagProps(i)}>
75
76
  <span class="sv-tags__label">{tag}</span>
@@ -109,4 +110,6 @@
109
110
  .sv-tags__x { background: none; border: 0; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; opacity: 0.7; }
110
111
  .sv-tags__x:hover { opacity: 1; }
111
112
  .sv-tags__input { flex: 1; min-width: 80px; border: 0; background: none; outline: none; color: inherit; font: inherit; font-size: var(--_fs); height: 24px; }
113
+ /* Fill the container - see `block` in SvEditorProps. */
114
+ .sv-tags.is-block { width: 100%; max-width: 100%; }
112
115
  </style>
@@ -1,4 +1,4 @@
1
- import { Gn as e, io as t, no as n, ro as r } from "./src-72QTH8lh.js";
1
+ import { Gn as e, ao as t, io as n, ro as r } from "./src-CEpw6Ato.js";
2
2
  import { l as i } from "./SvDateTimePicker-CHnUkWcH.js";
3
3
  import * as a from "svelte/internal/client";
4
4
  import "svelte/internal/disclose-version";
@@ -173,10 +173,10 @@ function oe(oe, N) {
173
173
  });
174
174
  let Ee = a.derived(() => P().autosizeColumn), De = a.derived(() => P().autosizeAllColumns), Oe = a.derived(() => P().resetColumns), ke = a.derived(() => P().openChooseColumns), Ae = a.derived(() => P().sortColumnFromMenu), je = a.derived(() => P().clearColumnSort), Me = a.derived(() => P().groupByColumnFromMenu), Ne = a.derived(() => P().clearGroupingFromMenu), Pe = a.derived(() => P().columnMenuFacetValues), Fe = a.derived(() => P().columnMenuVisibleFacets), X = a.derived(() => P().columnMenuFacetOptions), Ie = a.derived(() => P().columnMenuSelectedFacets), Le = a.derived(() => P().setFacetSelection), Re = a.derived(() => P().setFilterTokens), Z = a.derived(() => P().inSuggestOptions), ze = a.derived(() => P().openInSuggest), Be = a.derived(() => P().closeInSuggest), Ve = a.derived(() => P().isAllFacetsChecked), He = a.derived(() => P().toggleAllFacets), Ue = 40;
175
175
  function We(e, t) {
176
- a.get(ze)(e, t), P().inSuggestQuery = r(e.value);
176
+ a.get(ze)(e, t), P().inSuggestQuery = n(e.value);
177
177
  }
178
178
  function Ge(e, t) {
179
- P().inSuggestQuery = r(e.value), P().inSuggestFor !== t && a.get(ze)(e, t);
179
+ P().inSuggestQuery = n(e.value), P().inSuggestFor !== t && a.get(ze)(e, t);
180
180
  }
181
181
  function Ke(e) {
182
182
  return e.map((e) => ({
@@ -392,16 +392,16 @@ function oe(oe, N) {
392
392
  a.get(V) && e(mt);
393
393
  });
394
394
  var ht = a.sibling(pt, 2), gt = (t) => {
395
- let i = a.derived(() => a.get(Ce)), o = a.derived(() => new Set(n(a.get(Se)[a.get(i)] ?? "")));
395
+ let i = a.derived(() => a.get(Ce)), o = a.derived(() => new Set(r(a.get(Se)[a.get(i)] ?? "")));
396
396
  var s = re(), c = a.child(s), l = (t) => {
397
397
  {
398
- let n = a.derived(() => a.get(Z).length > 40);
398
+ let r = a.derived(() => a.get(Z).length > 40);
399
399
  e(t, {
400
400
  block: !0,
401
401
  checkbox: !0,
402
402
  multiple: !0,
403
403
  get virtual() {
404
- return a.get(n);
404
+ return a.get(r);
405
405
  },
406
406
  rows: 8,
407
407
  rowHeight: 26,
@@ -414,8 +414,8 @@ function oe(oe, N) {
414
414
  return a.get(o);
415
415
  },
416
416
  onChange: (e) => {
417
- let t = new Set(e), n = r(a.get(Se)[a.get(i)] ?? "");
418
- n && t.delete(n), a.get(Re)(a.get(i), [...t]), P().inSuggestQuery = "";
417
+ let t = new Set(e), r = n(a.get(Se)[a.get(i)] ?? "");
418
+ r && t.delete(r), a.get(Re)(a.get(i), [...t]), P().inSuggestQuery = "";
419
419
  }
420
420
  });
421
421
  }
@@ -1,4 +1,4 @@
1
- import { Gn as e, io as t, no as n, ro as r } from "./src-Cm7C_WOZ.js";
1
+ import { Gn as e, ao as t, io as n, ro as r } from "./src-M2NfKnjX.js";
2
2
  import { E as i, F as a, G as o, H as s, I as c, L as l, N as u, Q as d, U as f, V as p, X as m, Y as h, Z as g, _, d as v, et as y, f as b, ft as x, g as S, h as ee, j as C, k as w, lt as T, m as E, mt as D, nt as O, o as k, pt as A, st as j, t as te, tt as M, u as N, ut as P, v as F } from "./disclose-version-Dr7rEVv-.js";
3
3
  import { l as ne } from "./SvDateTimePicker-CRQH_U7E.js";
4
4
  //#region src/GridMenus.svelte
@@ -172,10 +172,10 @@ function V(l, p) {
172
172
  });
173
173
  let $e = j(() => H().autosizeColumn), et = j(() => H().autosizeAllColumns), tt = j(() => H().resetColumns), nt = j(() => H().openChooseColumns), rt = j(() => H().sortColumnFromMenu), it = j(() => H().clearColumnSort), at = j(() => H().groupByColumnFromMenu), ot = j(() => H().clearGroupingFromMenu), st = j(() => H().columnMenuFacetValues), ct = j(() => H().columnMenuVisibleFacets), lt = j(() => H().columnMenuFacetOptions), ut = j(() => H().columnMenuSelectedFacets), dt = j(() => H().setFacetSelection), ft = j(() => H().setFilterTokens), pt = j(() => H().inSuggestOptions), mt = j(() => H().openInSuggest), ht = j(() => H().closeInSuggest), gt = j(() => H().isAllFacetsChecked), _t = j(() => H().toggleAllFacets), vt = 40;
174
174
  function yt(e, t) {
175
- o(mt)(e, t), H().inSuggestQuery = r(e.value);
175
+ o(mt)(e, t), H().inSuggestQuery = n(e.value);
176
176
  }
177
177
  function bt(e, t) {
178
- H().inSuggestQuery = r(e.value), H().inSuggestFor !== t && o(mt)(e, t);
178
+ H().inSuggestQuery = n(e.value), H().inSuggestFor !== t && o(mt)(e, t);
179
179
  }
180
180
  function xt(e) {
181
181
  return e.map((e) => ({
@@ -391,16 +391,16 @@ function V(l, p) {
391
391
  o(q) && e(Gt);
392
392
  });
393
393
  var Kt = O(Wt, 2), qt = (t) => {
394
- let i = j(() => o(Xe)), c = j(() => new Set(n(o(Ye)[o(i)] ?? "")));
394
+ let i = j(() => o(Xe)), c = j(() => new Set(r(o(Ye)[o(i)] ?? "")));
395
395
  var l = Te(), u = y(l), d = (t) => {
396
396
  {
397
- let n = j(() => o(pt).length > 40);
397
+ let r = j(() => o(pt).length > 40);
398
398
  e(t, {
399
399
  block: !0,
400
400
  checkbox: !0,
401
401
  multiple: !0,
402
402
  get virtual() {
403
- return o(n);
403
+ return o(r);
404
404
  },
405
405
  rows: 8,
406
406
  rowHeight: 26,
@@ -413,8 +413,8 @@ function V(l, p) {
413
413
  return o(c);
414
414
  },
415
415
  onChange: (e) => {
416
- let t = new Set(e), n = r(o(Ye)[o(i)] ?? "");
417
- n && t.delete(n), o(ft)(o(i), [...t]), H().inSuggestQuery = "";
416
+ let t = new Set(e), r = n(o(Ye)[o(i)] ?? "");
417
+ r && t.delete(r), o(ft)(o(i), [...t]), H().inSuggestQuery = "";
418
418
  }
419
419
  });
420
420
  }