@kronor/dtv 10.0.0 → 10.0.1

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.
Files changed (2) hide show
  1. package/dist/index.es.js +141 -135
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -22786,7 +22786,7 @@ function JS(e, n, t, a) {
22786
22786
  return o === Ls || pf(t, o) ? [] : [{ message: `${a}: mapValues of "${e.filterId}" maps ${JSON.stringify(r)} to ${JSON.stringify(o)}, which is not among its items (${cy(t)})` }];
22787
22787
  });
22788
22788
  }
22789
- function w3(e) {
22789
+ function E3(e) {
22790
22790
  var s;
22791
22791
  const { from: n, to: t } = e, a = [], r = `migration of "${t.definition}" to revision ${t.revision}`;
22792
22792
  for (const l of e.ops)
@@ -22992,7 +22992,7 @@ function aC(e, n, t) {
22992
22992
  };
22993
22993
  return dy(e, a).data.persistedFilterState ?? {};
22994
22994
  }
22995
- function E3(e, n, t) {
22995
+ function S3(e, n, t) {
22996
22996
  let a = t;
22997
22997
  for (const r of e.migrations)
22998
22998
  if (!(r.from.revision < n))
@@ -23255,7 +23255,7 @@ function fC(e, n, t) {
23255
23255
  function pC(e) {
23256
23256
  throw new Error(`Unhandled message: ${JSON.stringify(e)}`);
23257
23257
  }
23258
- const mC = "10.0.0";
23258
+ const mC = "10.0.1";
23259
23259
  function vC(e) {
23260
23260
  var n;
23261
23261
  return {
@@ -23552,7 +23552,7 @@ function wy(e, n) {
23552
23552
  const t = [...e.flatMap((a) => a.data), ...n ?? []];
23553
23553
  return $g(t.map((a) => ({ fieldQuery: a })));
23554
23554
  }
23555
- function S3(e) {
23555
+ function C3(e) {
23556
23556
  return wy(e);
23557
23557
  }
23558
23558
  function DC(e) {
@@ -24150,7 +24150,7 @@ const GC = ({ updateFilterById: e, applyFilters: n }) => {
24150
24150
  /* @__PURE__ */ he.jsx(jn, { label: "Extend the date range back by 1 month", onClick: t, size: "small" })
24151
24151
  ] });
24152
24152
  };
24153
- function C3(e, n) {
24153
+ function x3(e, n) {
24154
24154
  if (!e || typeof e != "object")
24155
24155
  return e;
24156
24156
  const t = e;
@@ -34948,12 +34948,18 @@ function qo(e) {
34948
34948
  }
34949
34949
  return String(e);
34950
34950
  }
34951
+ function sO(e, n) {
34952
+ const t = (r) => String(r).padStart(2, "0"), a = `${n.getFullYear()}-${t(n.getMonth() + 1)}-${t(n.getDate())}`;
34953
+ return e.showTime ?? !0 ? `${a} ${t(n.getHours())}:${t(n.getMinutes())}` : a;
34954
+ }
34951
34955
  function nv(e, n) {
34952
34956
  if (n && typeof n == "object") {
34953
34957
  const t = n;
34954
34958
  if (typeof t.label == "string")
34955
34959
  return t.label;
34956
34960
  }
34961
+ if (e.type === "date" && n instanceof Date && !Number.isNaN(n.getTime()))
34962
+ return sO(e, n);
34957
34963
  if (e.type === "dropdown") {
34958
34964
  const t = e.items.find((a) => a.value === n);
34959
34965
  return t ? t.label : qo(n);
@@ -34963,13 +34969,13 @@ function nv(e, n) {
34963
34969
  return a ? a.label : qo(t);
34964
34970
  }).join(", ") : qo(n);
34965
34971
  }
34966
- function sO(e) {
34972
+ function uO(e) {
34967
34973
  return e == null || e === "" || Array.isArray(e) && e.length === 0;
34968
34974
  }
34969
- function uO(e, n) {
34975
+ function cO(e, n) {
34970
34976
  var r;
34971
34977
  const t = Zo(n.value);
34972
- if (e.value.type === "customOperator")
34978
+ if (e.value.type === "customOperator" || e.value.type === "date")
34973
34979
  return t;
34974
34980
  const a = (r = e.transform) == null ? void 0 : r.toQuery;
34975
34981
  if (!a)
@@ -34984,16 +34990,16 @@ function uO(e, n) {
34984
34990
  if ("condition" in o)
34985
34991
  return t;
34986
34992
  const s = Zo(o.value);
34987
- return sO(s) ? t : s;
34993
+ return uO(s) ? t : s;
34988
34994
  } catch {
34989
34995
  return t;
34990
34996
  }
34991
34997
  }
34992
- function cO(e, n) {
34998
+ function dO(e, n) {
34993
34999
  var s;
34994
35000
  if (nl(n, e))
34995
35001
  return "";
34996
- const t = `${e.fieldLabel ?? lO(e.field)} `, a = uO(e, n);
35002
+ const t = `${e.fieldLabel ?? lO(e.field)} `, a = cO(e, n);
34997
35003
  if (e.value.type === "customOperator") {
34998
35004
  const l = a, u = l == null ? void 0 : l.operator, c = ((s = e.value.operators.find((y) => y.value === u)) == null ? void 0 : s.label) ?? String(u ?? ""), p = l != null && l.value ? Zo(l.value) : null, f = nv(e.value.valueControl, p);
34999
35005
  return `${t}${c} ${f}`.trim();
@@ -35001,9 +35007,9 @@ function cO(e, n) {
35001
35007
  const r = e.type === "in" && Array.isArray(a) && a.length === 1 ? tv("equals") : tv(e.type), o = nv(e.value, a);
35002
35008
  return `${t}${r} ${o}`.trim();
35003
35009
  }
35004
- function dO(e, n) {
35010
+ function fO(e, n) {
35005
35011
  return Yo(e, n, {
35006
- leaf: (t, a) => cO(t, a),
35012
+ leaf: (t, a) => dO(t, a),
35007
35013
  and: (t, a, r) => {
35008
35014
  const o = r.filter(Boolean);
35009
35015
  return o.length === 0 ? "" : o.length === 1 ? o[0] : `AND(${o.join(", ")})`;
@@ -35031,11 +35037,11 @@ function dh(e, n) {
35031
35037
  }
35032
35038
  return [{
35033
35039
  filterId: a,
35034
- displayText: dO(o.expression, r)
35040
+ displayText: fO(o.expression, r)
35035
35041
  }];
35036
35042
  });
35037
35043
  }
35038
- function fO({ savedFilters: e, onFilterDelete: n, onFilterLoad: t, onFilterApply: a, onFilterShare: r, visible: o, filterGroups: s }) {
35044
+ function pO({ savedFilters: e, onFilterDelete: n, onFilterLoad: t, onFilterApply: a, onFilterShare: r, visible: o, filterGroups: s }) {
35039
35045
  if (!o)
35040
35046
  return null;
35041
35047
  const l = (f) => {
@@ -35114,7 +35120,7 @@ function fO({ savedFilters: e, onFilterDelete: n, onFilterLoad: t, onFilterApply
35114
35120
  ] }, f.id)) })
35115
35121
  ] });
35116
35122
  }
35117
- const pO = [
35123
+ const mO = [
35118
35124
  {
35119
35125
  id: "syncFilterStateToUrlOverride",
35120
35126
  kind: "dropdown",
@@ -35145,7 +35151,7 @@ const pO = [
35145
35151
  })
35146
35152
  }
35147
35153
  ];
35148
- function mO({
35154
+ function vO({
35149
35155
  visible: e,
35150
35156
  preferences: n,
35151
35157
  onChangePreferences: t,
@@ -35162,7 +35168,7 @@ function mO({
35162
35168
  }, [p, r.hiddenColumns]), y = qn(() => c.map((h) => ({ label: h.name, value: h.id })), [c]);
35163
35169
  return e ? /* @__PURE__ */ he.jsxs("div", { className: "tw:flex tw:flex-col tw:gap-4 tw:mb-4", children: [
35164
35170
  /* @__PURE__ */ he.jsx("div", { children: /* @__PURE__ */ he.jsx("h3", { className: "tw:text-lg tw:font-medium tw:text-gray-900", children: "Preferences" }) }),
35165
- /* @__PURE__ */ he.jsx("div", { className: "tw:flex tw:flex-col tw:gap-6 tw:w-1/3", children: pO.map((h) => /* @__PURE__ */ he.jsxs("div", { className: "tw:flex tw:justify-between tw:items-center tw:gap-3 tw:flex-wrap", children: [
35171
+ /* @__PURE__ */ he.jsx("div", { className: "tw:flex tw:flex-col tw:gap-6 tw:w-1/3", children: mO.map((h) => /* @__PURE__ */ he.jsxs("div", { className: "tw:flex tw:justify-between tw:items-center tw:gap-3 tw:flex-wrap", children: [
35166
35172
  /* @__PURE__ */ he.jsx("label", { className: "tw:text-sm tw:text-gray-700 tw:w-[240px] tw:flex-shrink-0", children: h.label }),
35167
35173
  /* @__PURE__ */ he.jsx("div", { className: "tw:min-w-[240px]", children: h.kind === "dropdown" && /* @__PURE__ */ he.jsx(
35168
35174
  da,
@@ -35246,8 +35252,8 @@ function mO({
35246
35252
  ] })
35247
35253
  ] }) : null;
35248
35254
  }
35249
- const Of = "2025-09-19T00:00:00.000Z", vO = "dtvSavedFilters";
35250
- function gO(e, n, t) {
35255
+ const Of = "2025-09-19T00:00:00.000Z", gO = "dtvSavedFilters";
35256
+ function yO(e, n, t) {
35251
35257
  const { state: a, resetFilterIds: r } = ff(e.state, t);
35252
35258
  return {
35253
35259
  savedFilter: {
@@ -35261,7 +35267,7 @@ function gO(e, n, t) {
35261
35267
  resetFilterIds: r
35262
35268
  };
35263
35269
  }
35264
- function yO(e, n) {
35270
+ function hO(e, n) {
35265
35271
  return {
35266
35272
  id: e.id,
35267
35273
  name: e.name,
@@ -35271,7 +35277,7 @@ function yO(e, n) {
35271
35277
  formatRevision: Of
35272
35278
  };
35273
35279
  }
35274
- const fh = "1970-01-01T00:00:00.000Z", ph = "2026-01-05T00:00:00.000Z", mh = "2026-01-29T00:00:00.000Z", vh = "2026-03-26T00:00:00.000Z", gh = "2026-05-06T00:00:00.000Z", hO = "2026-10-25T00:00:00.000Z", rv = "dtvSavedFiltersMigratedToUserData";
35280
+ const fh = "1970-01-01T00:00:00.000Z", ph = "2026-01-05T00:00:00.000Z", mh = "2026-01-29T00:00:00.000Z", vh = "2026-03-26T00:00:00.000Z", gh = "2026-05-06T00:00:00.000Z", bO = "2026-10-25T00:00:00.000Z", rv = "dtvSavedFiltersMigratedToUserData";
35275
35281
  function yh(e, n) {
35276
35282
  return $r(e.views) ? {
35277
35283
  ...e,
@@ -35280,13 +35286,13 @@ function yh(e, n) {
35280
35286
  )
35281
35287
  } : e;
35282
35288
  }
35283
- const bO = {
35289
+ const wO = {
35284
35290
  fromRevision: fh,
35285
35291
  toRevision: ph,
35286
35292
  migrate: (e) => {
35287
35293
  try {
35288
35294
  if (localStorage.getItem(rv)) return e;
35289
- const t = localStorage.getItem(vO);
35295
+ const t = localStorage.getItem(gO);
35290
35296
  if (!t) return e;
35291
35297
  const a = JSON.parse(t);
35292
35298
  if (!Array.isArray(a)) return e;
@@ -35326,7 +35332,7 @@ const bO = {
35326
35332
  return console.error("Failed migrating legacy saved filters into user data:", n), e;
35327
35333
  }
35328
35334
  }
35329
- }, wO = {
35335
+ }, EO = {
35330
35336
  fromRevision: ph,
35331
35337
  toRevision: mh,
35332
35338
  migrate: (e) => ({
@@ -35336,31 +35342,31 @@ const bO = {
35336
35342
  syncFilterStateToUrlOverride: null
35337
35343
  }
35338
35344
  })
35339
- }, EO = {
35345
+ }, SO = {
35340
35346
  fromRevision: mh,
35341
35347
  toRevision: vh,
35342
35348
  // Leaves from before this revision hold raw values. Which `FilterValue` a raw value
35343
35349
  // stands for depends on the filter's control, so it cannot be decided here: such
35344
35350
  // leaves decode as `legacy` and are resolved when their view is decoded.
35345
35351
  migrate: (e) => e
35346
- }, SO = {
35352
+ }, CO = {
35347
35353
  fromRevision: vh,
35348
35354
  toRevision: gh,
35349
35355
  // `syncFilterStateToUserData` is absent from older views and decodes to its default.
35350
35356
  migrate: (e) => yh(e, (n) => ({ ...n, persistedFilterState: null }))
35351
- }, CO = {
35357
+ }, xO = {
35352
35358
  fromRevision: gh,
35353
- toRevision: hO,
35359
+ toRevision: bO,
35354
35360
  // Everything stored so far was written without knowing the view definition's revision.
35355
35361
  // Moving to a new format revision also makes older dtv versions leave the data alone,
35356
35362
  // instead of writing it back with view data from a definition they predate.
35357
35363
  migrate: (e) => yh(e, (n) => ({ ...n, definitionRevision: li }))
35358
35364
  }, Rd = [
35359
- bO,
35360
35365
  wO,
35361
35366
  EO,
35362
35367
  SO,
35363
- CO
35368
+ CO,
35369
+ xO
35364
35370
  ], Ni = Rd[Rd.length - 1].toRevision;
35365
35371
  function fs(e) {
35366
35372
  switch (e.kind) {
@@ -35380,7 +35386,7 @@ function fs(e) {
35380
35386
  }
35381
35387
  }
35382
35388
  const jo = (e) => String(e.formatRevision);
35383
- function xO(e, n) {
35389
+ function OO(e, n) {
35384
35390
  if (jo(e) === Ni)
35385
35391
  return ei(e);
35386
35392
  let t = e;
@@ -35416,8 +35422,8 @@ function xO(e, n) {
35416
35422
  expectedRevision: Ni
35417
35423
  }) : ei(t);
35418
35424
  }
35419
- function OO(e) {
35420
- return xO(e, Rd);
35425
+ function IO(e) {
35426
+ return OO(e, Rd);
35421
35427
  }
35422
35428
  function ps() {
35423
35429
  return {
@@ -35451,7 +35457,7 @@ function av() {
35451
35457
  function hh(e) {
35452
35458
  if (!$r(e))
35453
35459
  return St.failure({ kind: "malformed", issue: { path: "$", message: "expected an object" } });
35454
- const n = OO(e);
35460
+ const n = IO(e);
35455
35461
  if (St.isFailure(n))
35456
35462
  return St.failure({ kind: "migrationFailed", error: n.error });
35457
35463
  const { result: t, issues: a } = oy(BS, n.value);
@@ -35460,8 +35466,8 @@ function hh(e) {
35460
35466
  mapSuccess: (r) => ({ data: r, migrated: n.value !== e, issues: a })
35461
35467
  }, t);
35462
35468
  }
35463
- function IO(e, n, t) {
35464
- const a = n.persistedFilterState ? ff(n.persistedFilterState, t, So.WithInitialValues) : null, r = n.savedFilters.map((s) => gO(s, e, t)), o = {
35469
+ function PO(e, n, t) {
35470
+ const a = n.persistedFilterState ? ff(n.persistedFilterState, t, So.WithInitialValues) : null, r = n.savedFilters.map((s) => yO(s, e, t)), o = {
35465
35471
  viewId: e,
35466
35472
  persistedFilterState: (a == null ? void 0 : a.resetFilterIds) ?? [],
35467
35473
  savedFilters: r.filter((s) => s.resetFilterIds.length > 0).map((s) => ({ name: s.savedFilter.name, filterIds: s.resetFilterIds }))
@@ -35480,7 +35486,7 @@ function IO(e, n, t) {
35480
35486
  resets: o.persistedFilterState.length > 0 || o.savedFilters.length > 0 ? o : null
35481
35487
  };
35482
35488
  }
35483
- function PO(e, n, t = li) {
35489
+ function DO(e, n, t = li) {
35484
35490
  return {
35485
35491
  columnOrder: e.columnOrder,
35486
35492
  hiddenColumns: e.hiddenColumns,
@@ -35489,11 +35495,11 @@ function PO(e, n, t = li) {
35489
35495
  ordering: e.ordering,
35490
35496
  syncFilterStateToUserData: e.syncFilterStateToUserData,
35491
35497
  persistedFilterState: e.persistedFilterState ? ti(e.persistedFilterState, n) : null,
35492
- savedFilters: e.savedFilters.map((a) => yO(a, n)),
35498
+ savedFilters: e.savedFilters.map((a) => hO(a, n)),
35493
35499
  definitionRevision: t
35494
35500
  };
35495
35501
  }
35496
- function DO(e) {
35502
+ function RO(e) {
35497
35503
  const n = e.migrations;
35498
35504
  if (n === void 0) return;
35499
35505
  const t = US(e, n.latest.definition, n.latest.revision), a = fy(n.latest, t);
@@ -35501,11 +35507,11 @@ function DO(e) {
35501
35507
  `View "${e.id}" differs from revision ${n.latest.revision} of its definition "${n.latest.definition}". Run \`dtv definitions snapshot\` to add a revision; until then, stored state of changed filters is reset.`
35502
35508
  ), { chain: n, live: t, snapshotDiff: a };
35503
35509
  }
35504
- function RO(e, n, t) {
35510
+ function kO(e, n, t) {
35505
35511
  const a = mf(n, t ?? nu());
35506
35512
  return a.persistedFilterState.length > 0 || a.savedFilters.length > 0 ? { viewId: e, ...a } : null;
35507
35513
  }
35508
- function kO(e, n, t = {}) {
35514
+ function TO(e, n, t = {}) {
35509
35515
  const a = {}, r = {}, o = [], s = [], l = /* @__PURE__ */ new Set();
35510
35516
  let u = !1;
35511
35517
  for (const [c, p] of Object.entries(n)) {
@@ -35526,9 +35532,9 @@ function kO(e, n, t = {}) {
35526
35532
  const T = dy(f.chain, y), E = rC(f.chain.latest, f.live, T.data);
35527
35533
  h = { data: E.data, resets: mf(T.resets, E.resets) }, u || (u = T.data.definitionRevision !== y.definitionRevision);
35528
35534
  }
35529
- const O = IO(c, h.data, p);
35535
+ const O = PO(c, h.data, p);
35530
35536
  a[c] = O.viewData;
35531
- const v = RO(c, h.resets, O.resets);
35537
+ const v = kO(c, h.resets, O.resets);
35532
35538
  v && o.push(v);
35533
35539
  } catch (h) {
35534
35540
  console.error(`Failed to decode the user data of view "${c}"; it is kept as stored:`, h), r[c] = y, s.push({ viewId: c, reason: "decodeFailed" });
@@ -35550,21 +35556,21 @@ function kO(e, n, t = {}) {
35550
35556
  retained: s
35551
35557
  };
35552
35558
  }
35553
- function TO(e, n, t = {}) {
35559
+ function NO(e, n, t = {}) {
35554
35560
  return St.mapResult(
35555
35561
  ({ data: a, migrated: r, issues: o }) => {
35556
- const s = kO(a, n, t);
35562
+ const s = TO(a, n, t);
35557
35563
  return { ...s, migrated: r || s.migrated, issues: o };
35558
35564
  },
35559
35565
  hh(e)
35560
35566
  );
35561
35567
  }
35562
- function NO(e, n, t = {}, a = {}) {
35568
+ function FO(e, n, t = {}, a = {}) {
35563
35569
  const r = { ...t, ...e.retainedViews };
35564
35570
  for (const [o, s] of Object.entries(e.views)) {
35565
35571
  const l = n[o];
35566
35572
  if (!l) continue;
35567
- const u = a[o], c = PO(s, l, hl(u == null ? void 0 : u.chain)), p = r[o];
35573
+ const u = a[o], c = DO(s, l, hl(u == null ? void 0 : u.chain)), p = r[o];
35568
35574
  if (!(p !== void 0 && p.definitionRevision > c.definitionRevision) && (r[o] = c, u !== void 0 && o === u.chain.latest.definition))
35569
35575
  for (const f of my(u.chain))
35570
35576
  n[f] === void 0 && delete r[f];
@@ -35599,14 +35605,14 @@ function Qu(e, n) {
35599
35605
  cause: n
35600
35606
  };
35601
35607
  }
35602
- function FO(e) {
35608
+ function MO(e) {
35603
35609
  return {
35604
35610
  kind: "localStorageFailed",
35605
35611
  message: bh(e),
35606
35612
  cause: e.cause
35607
35613
  };
35608
35614
  }
35609
- function MO(e, n) {
35615
+ function AO(e, n) {
35610
35616
  const t = (r, o) => o.map((s) => n(r, s)).join(", ");
35611
35617
  return {
35612
35618
  severity: "warn",
@@ -35645,7 +35651,7 @@ function Zu(e) {
35645
35651
  }
35646
35652
  const ms = () => {
35647
35653
  };
35648
- function AO(e = Promise.resolve()) {
35654
+ function jO(e = Promise.resolve()) {
35649
35655
  let n = e.then(ms, ms);
35650
35656
  return {
35651
35657
  enqueue(t) {
@@ -35654,7 +35660,7 @@ function AO(e = Promise.resolve()) {
35654
35660
  }
35655
35661
  };
35656
35662
  }
35657
- function jO(e) {
35663
+ function _O(e) {
35658
35664
  let n = null;
35659
35665
  return Object.assign(() => (n === null && (n = { value: e() }), n.value), {
35660
35666
  set: (a) => (n = { value: a }, a)
@@ -35676,19 +35682,19 @@ function lv() {
35676
35682
  return St.failure(iv(n));
35677
35683
  }
35678
35684
  }
35679
- function _O(e) {
35685
+ function LO(e) {
35680
35686
  try {
35681
35687
  return localStorage.setItem(If, JSON.stringify(e)), St.success(void 0);
35682
35688
  } catch (n) {
35683
35689
  return St.failure(wh(n));
35684
35690
  }
35685
35691
  }
35686
- function LO(e, n) {
35692
+ function $O(e, n) {
35687
35693
  const t = n.migrationsByViewId ?? {};
35688
35694
  let a = null;
35689
35695
  const r = [], o = (ie) => {
35690
35696
  a === null ? r.push(ie) : a(ie);
35691
- }, s = (ie) => TO(ie, e, t);
35697
+ }, s = (ie) => NO(ie, e, t);
35692
35698
  function l(ie) {
35693
35699
  return ie.kind === "migrationFailed" ? fs(ie.error) : `the stored user data is not valid (${ie.issue.path}: ${ie.issue.message})`;
35694
35700
  }
@@ -35714,9 +35720,9 @@ function LO(e, n) {
35714
35720
  return ((Te = Ur(je).find((_) => _.id === ge)) == null ? void 0 : Te.label) ?? ge;
35715
35721
  }
35716
35722
  function y(ie) {
35717
- ie.length > 0 && n.showToast(MO(ie, f));
35723
+ ie.length > 0 && n.showToast(AO(ie, f));
35718
35724
  }
35719
- const h = jO(c);
35725
+ const h = _O(c);
35720
35726
  let O = !1;
35721
35727
  function v(ie) {
35722
35728
  return console.error("Failed to read user data:", fs(ie), ie), n.showToast({
@@ -35735,7 +35741,7 @@ function LO(e, n) {
35735
35741
  return T(), h();
35736
35742
  }
35737
35743
  function F(ie) {
35738
- return St.mapFailure(_O(ie), FO);
35744
+ return St.mapFailure(LO(ie), MO);
35739
35745
  }
35740
35746
  async function w(ie) {
35741
35747
  if (!n.save) return St.success(void 0);
@@ -35766,7 +35772,7 @@ function LO(e, n) {
35766
35772
  const je = p();
35767
35773
  if (je !== null && St.isFailure(je) && je.error.kind === "migrationFailed")
35768
35774
  return o(v(je.error.error)), St.success(h.set(ie));
35769
- const Te = je !== null && St.isSuccess(je) ? je.value : null, _ = ge.bumpRevision ? Math.max(ie.revision, h().revision, (Te == null ? void 0 : Te.revision) ?? 0) + 1 : ie.revision, ce = { ...ie, revision: _ }, Ie = NO(ce, e, Te == null ? void 0 : Te.views, t), Be = F(Ie);
35775
+ const Te = je !== null && St.isSuccess(je) ? je.value : null, _ = ge.bumpRevision ? Math.max(ie.revision, h().revision, (Te == null ? void 0 : Te.revision) ?? 0) + 1 : ie.revision, ce = { ...ie, revision: _ }, Ie = FO(ce, e, Te == null ? void 0 : Te.views, t), Be = F(Ie);
35770
35776
  h.set(ce);
35771
35777
  const Xe = ge.remote ? await w(Ie) : St.success(void 0);
35772
35778
  return St.mapResult(() => ce, St.isFailure(Xe) ? Xe : Be);
@@ -35816,7 +35822,7 @@ function LO(e, n) {
35816
35822
  ...St.isFailure(ge) && ge.error.kind !== "unsupportedFormat" ? { error: Q(ge.error) } : {}
35817
35823
  });
35818
35824
  }
35819
- const U = P(), N = AO(U);
35825
+ const U = P(), N = jO(U);
35820
35826
  function $(ie) {
35821
35827
  return N.enqueue(async () => {
35822
35828
  const ge = await re(ie(E()), { bumpRevision: !0, remote: !0 });
@@ -35972,8 +35978,8 @@ function LO(e, n) {
35972
35978
  deleteFilter: ae
35973
35979
  };
35974
35980
  }
35975
- function $O(e, n, t, a) {
35976
- const r = qn(() => LO(e, t), [e, t]), [o, s] = ca(0), l = An(() => s((P) => P + 1), []), u = qn(() => r.getPreferences(), [r, o]), c = qn(() => r.getViewData(n), [r, n, o]), p = qn(() => r.getSavedFilters(n), [r, n, o]), [f, y] = ca(null), h = f === r;
35981
+ function BO(e, n, t, a) {
35982
+ const r = qn(() => $O(e, t), [e, t]), [o, s] = ca(0), l = An(() => s((P) => P + 1), []), u = qn(() => r.getPreferences(), [r, o]), c = qn(() => r.getViewData(n), [r, n, o]), p = qn(() => r.getSavedFilters(n), [r, n, o]), [f, y] = ca(null), h = f === r;
35977
35983
  Yn(() => {
35978
35984
  const P = (k) => {
35979
35985
  k.key === If && (r.refreshFromLocalStorage(), l());
@@ -36059,14 +36065,14 @@ function Eh(e, n, t = {}) {
36059
36065
  throw console.error("Failed to encode filter state:", a), new Error("Failed to encode filter state");
36060
36066
  }
36061
36067
  }
36062
- function BO(e) {
36068
+ function VO(e) {
36063
36069
  const n = e.replace(/-/g, "+").replace(/_/g, "/").padEnd(e.length + (4 - e.length % 4) % 4, "=");
36064
36070
  return JSON.parse(atob(n));
36065
36071
  }
36066
- function VO(e) {
36072
+ function HO(e) {
36067
36073
  let n;
36068
36074
  try {
36069
- n = BO(e);
36075
+ n = VO(e);
36070
36076
  } catch (r) {
36071
36077
  throw console.error("Failed to decode filter state:", r), new Error("Failed to decode filter state");
36072
36078
  }
@@ -36084,7 +36090,7 @@ function sv(e, n) {
36084
36090
  throw console.error("Failed to create shareable URL:", t), new Error("Failed to create shareable URL");
36085
36091
  }
36086
36092
  }
36087
- function HO(e, n) {
36093
+ function KO(e, n) {
36088
36094
  const t = new URL(window.location.href);
36089
36095
  t.searchParams.set(iu, Eh(e, n, { synced: !0 })), window.history.replaceState({}, "", t);
36090
36096
  }
@@ -36100,10 +36106,10 @@ async function uv(e) {
36100
36106
  throw console.error("Failed to copy to clipboard:", n), new Error("Failed to copy to clipboard");
36101
36107
  }
36102
36108
  }
36103
- function KO() {
36109
+ function zO() {
36104
36110
  try {
36105
36111
  const n = new URLSearchParams(window.location.search).get(iu);
36106
- return n ? VO(n) : null;
36112
+ return n ? HO(n) : null;
36107
36113
  } catch (e) {
36108
36114
  return console.warn("Failed to parse filter from URL:", e), null;
36109
36115
  }
@@ -36112,7 +36118,7 @@ function cv() {
36112
36118
  const e = new URL(window.location.href);
36113
36119
  e.searchParams.delete(iu), window.history.replaceState({}, "", e.toString());
36114
36120
  }
36115
- function zO({ actions: e, selectedView: n, filterState: t, selectedRows: a, setFilterState: r, refetch: o, applyFilters: s, showToast: l, paginationState: u, rowsPerPage: c, ordering: p, userData: f }) {
36121
+ function UO({ actions: e, selectedView: n, filterState: t, selectedRows: a, setFilterState: r, refetch: o, applyFilters: s, showToast: l, paginationState: u, rowsPerPage: c, ordering: p, userData: f }) {
36116
36122
  const [y, h] = i.useState(() => /* @__PURE__ */ new Set()), O = ru();
36117
36123
  return /* @__PURE__ */ he.jsx(he.Fragment, { children: e.map((v, T) => {
36118
36124
  const E = y.has(T), F = async () => {
@@ -36169,8 +36175,8 @@ function zO({ actions: e, selectedView: n, filterState: t, selectedRows: a, setF
36169
36175
  );
36170
36176
  }) });
36171
36177
  }
36172
- const UO = WC, GO = 20, qO = [20, 50, 100, 200], dv = /* @__PURE__ */ new WeakMap();
36173
- function WO(e) {
36178
+ const GO = WC, qO = 20, WO = [20, 50, 100, 200], dv = /* @__PURE__ */ new WeakMap();
36179
+ function YO(e) {
36174
36180
  var a, r;
36175
36181
  const n = dv.get(e);
36176
36182
  if (n !== void 0) return n;
@@ -36189,7 +36195,7 @@ function WO(e) {
36189
36195
  return dv.set(e, t), t;
36190
36196
  }
36191
36197
  const fv = /* @__PURE__ */ new WeakMap();
36192
- function YO(e) {
36198
+ function JO(e) {
36193
36199
  var a;
36194
36200
  if (!((a = e.rowExpansion) != null && a.lazy)) return null;
36195
36201
  const n = fv.get(e);
@@ -36205,7 +36211,7 @@ function YO(e) {
36205
36211
  );
36206
36212
  return fv.set(e, t), t;
36207
36213
  }
36208
- function JO({
36214
+ function XO({
36209
36215
  graphqlHost: e,
36210
36216
  requestHeaders: n,
36211
36217
  aiIntegration: t,
@@ -36222,7 +36228,7 @@ function JO({
36222
36228
  rowSelection: h,
36223
36229
  actions: O = [],
36224
36230
  rowClassFunction: v,
36225
- rowsPerPageOptions: T = qO,
36231
+ rowsPerPageOptions: T = WO,
36226
36232
  userData: E,
36227
36233
  analytics: F,
36228
36234
  modifyAiFilterPrompt: w,
@@ -36234,12 +36240,12 @@ function JO({
36234
36240
  return l;
36235
36241
  if (!u)
36236
36242
  throw new Error('App requires either "views" or "viewsJson"');
36237
- return JSON.parse(u).map((q) => pS(q, UO, c));
36243
+ return JSON.parse(u).map((q) => pS(q, GO, c));
36238
36244
  }, [l, u, c]), re = qn(() => Object.fromEntries(S.map((ne) => [ne.id, ne.filterGroups])), [S]), Q = qn(() => Object.fromEntries(S.flatMap((ne) => {
36239
- const q = DO(ne);
36245
+ const q = RO(ne);
36240
36246
  return q === void 0 ? [] : [[ne.id, q]];
36241
36247
  })), [S]), V = qn(() => new Map(S.map((ne) => [ne.id, ne])), [S]), A = qn(() => {
36242
- const ne = KO();
36248
+ const ne = zO();
36243
36249
  if (!ne) return;
36244
36250
  const q = ne.view === null ? S[0] : V.get(ne.view);
36245
36251
  if (!q) {
@@ -36282,7 +36288,7 @@ function JO({
36282
36288
  N,
36283
36289
  {
36284
36290
  viewId: (A == null ? void 0 : A.viewId) ?? S[0].id,
36285
- rowsPerPage: T[0] ?? GO,
36291
+ rowsPerPage: T[0] ?? qO,
36286
36292
  initialFilterState: P,
36287
36293
  initialFilterStateSource: A && {
36288
36294
  trigger: A.synced ? "url" : "link",
@@ -36298,7 +36304,7 @@ function JO({
36298
36304
  return te ? VC({
36299
36305
  client: k,
36300
36306
  view: te,
36301
- query: WO(te),
36307
+ query: YO(te),
36302
36308
  filterState: ne.filters,
36303
36309
  rowLimit: ne.rowsPerPage,
36304
36310
  cursor: ne.cursors.at(-1) ?? null,
@@ -36330,7 +36336,7 @@ function JO({
36330
36336
  return (q = Ie.current) == null ? void 0 : q.show({ ...ne });
36331
36337
  },
36332
36338
  migrationsByViewId: Q
36333
- }), [E == null ? void 0 : E.onLoad, E == null ? void 0 : E.onSave, Q]), xe = $O(re, we.id, Ne, ve), ze = xe.preferences.syncFilterStateToUrlOverride ?? y, Oe = xe.preferences.closeFilterPanelOnApply === !0, Le = xe.viewData.syncFilterStateToUserData, ae = {
36339
+ }), [E == null ? void 0 : E.onLoad, E == null ? void 0 : E.onSave, Q]), xe = BO(re, we.id, Ne, ve), ze = xe.preferences.syncFilterStateToUrlOverride ?? y, Oe = xe.preferences.closeFilterPanelOnApply === !0, Le = xe.viewData.syncFilterStateToUserData, ae = {
36334
36340
  preferences: xe.preferences,
36335
36341
  viewData: xe.viewData
36336
36342
  }, { isReady: $e } = xe, {
@@ -36422,7 +36428,7 @@ function JO({
36422
36428
  return;
36423
36429
  }
36424
36430
  }, [ze, P]), Yn(() => {
36425
- ze && se && HO(we, se);
36431
+ ze && se && KO(we, se);
36426
36432
  }, [ze, se, we]), Yn(() => {
36427
36433
  ze || cv();
36428
36434
  }, [ze]), Yn(() => {
@@ -36491,7 +36497,7 @@ function JO({
36491
36497
  }, un = () => {
36492
36498
  ce.current && ce.current.exportCSV({ selectionOnly: !1 });
36493
36499
  }, mn = An(async ({ rowKey: ne }) => {
36494
- const q = we.rowExpansion, te = YO(we);
36500
+ const q = we.rowExpansion, te = JO(we);
36495
36501
  if (!(q != null && q.lazy) || !te || !M)
36496
36502
  return {};
36497
36503
  const Re = hf(we, M.query.filters, 1, null, M.query.ordering), Me = qa(Zt.condition(we.paginationKey, { _eq: ne })), Ye = Object.keys(Re.conditions).length > 0, wt = await k.request(te, {
@@ -36594,7 +36600,7 @@ function JO({
36594
36600
  ),
36595
36601
  O.length > 0 && /* @__PURE__ */ he.jsx(Wy, { layout: "vertical" }),
36596
36602
  /* @__PURE__ */ he.jsx(
36597
- zO,
36603
+ UO,
36598
36604
  {
36599
36605
  actions: O,
36600
36606
  selectedView: we,
@@ -36646,7 +36652,7 @@ function JO({
36646
36652
  }
36647
36653
  ) }),
36648
36654
  /* @__PURE__ */ he.jsx(
36649
- fO,
36655
+ pO,
36650
36656
  {
36651
36657
  savedFilters: xe.savedFilters,
36652
36658
  onFilterDelete: bt,
@@ -36658,7 +36664,7 @@ function JO({
36658
36664
  }
36659
36665
  ),
36660
36666
  /* @__PURE__ */ he.jsx(
36661
- mO,
36667
+ vO,
36662
36668
  {
36663
36669
  visible: Nt,
36664
36670
  preferences: xe.preferences,
@@ -36741,7 +36747,7 @@ function JO({
36741
36747
  yS($.table) && /* @__PURE__ */ he.jsx(Qx, { message: "Loading data…" }),
36742
36748
  $.showPopout && !p && Kh(
36743
36749
  /* @__PURE__ */ he.jsx("div", { className: "tw:fixed tw:inset-0 tw:bg-white tw:overflow-auto tw:z-10", children: /* @__PURE__ */ he.jsx(
36744
- JO,
36750
+ XO,
36745
36751
  {
36746
36752
  graphqlHost: e,
36747
36753
  requestHeaders: n,
@@ -36777,7 +36783,7 @@ function sa(e) {
36777
36783
  ...n.transform && { transform: n.transform }
36778
36784
  });
36779
36785
  }
36780
- function XO(e) {
36786
+ function QO(e) {
36781
36787
  const n = e.control({ placeholder: "from" }), t = e.control({ placeholder: "to" }), { field: a, fieldLabel: r, transform: o } = e;
36782
36788
  return { type: "and", filters: o ? [
36783
36789
  tr.greaterThanOrEqual({ field: a, control: n, fieldLabel: r, transform: o }),
@@ -36812,9 +36818,9 @@ const tr = {
36812
36818
  and: (e) => ({ type: "and", filters: e.filters }),
36813
36819
  or: (e) => ({ type: "or", filters: e.filters }),
36814
36820
  not: (e) => ({ type: "not", filter: e.filter }),
36815
- range: XO,
36821
+ range: QO,
36816
36822
  allOperators: ES
36817
- }, QO = {
36823
+ }, ZO = {
36818
36824
  text: (e) => ({ type: "text", ...e }),
36819
36825
  number: (e) => ({ type: "number", ...e }),
36820
36826
  date: (e) => ({ type: "date", ...e }),
@@ -36837,10 +36843,10 @@ function Sh(e) {
36837
36843
  cellRenderer: e.cellRenderer
36838
36844
  };
36839
36845
  }
36840
- function ZO(e) {
36846
+ function e3(e) {
36841
36847
  return Sh(e);
36842
36848
  }
36843
- const e3 = (e, n) => {
36849
+ const t3 = (e, n) => {
36844
36850
  let t = e;
36845
36851
  for (const a of n) {
36846
36852
  if (t == null) return null;
@@ -36848,7 +36854,7 @@ const e3 = (e, n) => {
36848
36854
  }
36849
36855
  return t ?? null;
36850
36856
  };
36851
- function t3(e) {
36857
+ function n3(e) {
36852
36858
  const n = e.field, t = n.split("."), a = t[t.length - 1], r = e.select;
36853
36859
  let o;
36854
36860
  if (r === void 0)
@@ -36869,17 +36875,17 @@ function t3(e) {
36869
36875
  ...e.footer !== void 0 ? { footer: e.footer } : {},
36870
36876
  ...e.orderBy !== void 0 ? { orderBy: e.orderBy } : {},
36871
36877
  // The query above selects exactly the checked path, so the value read back is a `Value`.
36872
- cellRenderer: (l) => s({ ...l, value: e3(l.data, t) })
36878
+ cellRenderer: (l) => s({ ...l, value: t3(l.data, t) })
36873
36879
  });
36874
36880
  }
36875
- function n3(e) {
36881
+ function r3(e) {
36876
36882
  return {
36877
36883
  type: "virtualColumn",
36878
36884
  id: e.id,
36879
36885
  data: e.data
36880
36886
  };
36881
36887
  }
36882
- function r3(e) {
36888
+ function a3(e) {
36883
36889
  const n = (t) => (a, r) => t(r ? { ...a, transform: r } : a);
36884
36890
  return {
36885
36891
  equals: n(tr.equals),
@@ -36908,33 +36914,33 @@ function r3(e) {
36908
36914
  function ui(e, n) {
36909
36915
  return { section: e, key: n };
36910
36916
  }
36911
- function a3(e) {
36917
+ function o3(e) {
36912
36918
  return ui("cellRenderers", e);
36913
36919
  }
36914
- function o3(e) {
36920
+ function i3(e) {
36915
36921
  return ui("noRowsComponents", e);
36916
36922
  }
36917
- function i3(e) {
36923
+ function l3(e) {
36918
36924
  return ui("customFilterComponents", e);
36919
36925
  }
36920
- function l3(e) {
36926
+ function s3(e) {
36921
36927
  return ui("queryTransforms", e);
36922
36928
  }
36923
- function s3(e) {
36929
+ function u3(e) {
36924
36930
  return ui("initialValues", e);
36925
36931
  }
36926
- const u3 = {
36932
+ const c3 = {
36927
36933
  and: (...e) => ({ and: [...e] }),
36928
36934
  or: (...e) => ({ or: [...e] })
36929
36935
  };
36930
- function c3(e) {
36936
+ function d3(e) {
36931
36937
  return {
36932
36938
  name: e.name,
36933
36939
  label: e.label,
36934
36940
  filters: e.filters
36935
36941
  };
36936
36942
  }
36937
- function d3(e) {
36943
+ function f3(e) {
36938
36944
  const { rowType: n, ...t } = e;
36939
36945
  return {
36940
36946
  id: t.id,
@@ -36957,7 +36963,7 @@ function pv(e, n, t) {
36957
36963
  r.set(s, o);
36958
36964
  }
36959
36965
  }
36960
- function f3(e) {
36966
+ function p3(e) {
36961
36967
  pv(e.columnDefinitions, (t) => t.id, {
36962
36968
  context: `view("${e.id}") columnDefinitions`,
36963
36969
  keyName: "id"
@@ -36968,11 +36974,11 @@ function f3(e) {
36968
36974
  keyName: "id"
36969
36975
  }), e;
36970
36976
  }
36971
- function p3(e) {
36977
+ function m3(e) {
36972
36978
  const n = { data: e.data, mode: e.mode };
36973
36979
  return e.lazy ? { ...n, lazy: !0, render: e.render, canExpand: e.canExpand } : { ...n, render: e.render, canExpand: e.canExpand };
36974
36980
  }
36975
- const m3 = {
36981
+ const v3 = {
36976
36982
  renameFilter: (e, n) => ({ kind: "renameFilter", from: e, to: n }),
36977
36983
  keep: (e, n) => ({ kind: "keep", filterId: e, because: n.because }),
36978
36984
  reset: (e) => ({ kind: "reset", filterId: e }),
@@ -36985,48 +36991,48 @@ const m3 = {
36985
36991
  resetSort: (e) => ({ kind: "resetSort", columnId: e }),
36986
36992
  todo: (e, n) => ({ kind: "todo", subject: e, message: n })
36987
36993
  };
36988
- function v3(e, n, t) {
36989
- return { from: e, to: n, ops: t(m3) };
36994
+ function g3(e, n, t) {
36995
+ return { from: e, to: n, ops: t(v3) };
36990
36996
  }
36991
- function g3(e, n = []) {
36997
+ function y3(e, n = []) {
36992
36998
  return GS(e, n);
36993
36999
  }
36994
- const x3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
37000
+ const O3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
36995
37001
  __proto__: null,
36996
37002
  CellRenderer: Py,
36997
37003
  DROP: Ls,
36998
- FilterControl: QO,
37004
+ FilterControl: ZO,
36999
37005
  FilterExpr: tr,
37000
37006
  RESET: ad,
37001
37007
  arrayQuery: ef,
37002
- cellRendererRef: a3,
37003
- column: ZO,
37004
- customFilterComponentRef: i3,
37005
- defineMigration: v3,
37006
- defineViewMigrations: g3,
37007
- fieldColumn: t3,
37008
- filter: d3,
37009
- filterExprForRowType: r3,
37010
- filterField: u3,
37011
- filterGroup: c3,
37008
+ cellRendererRef: o3,
37009
+ column: e3,
37010
+ customFilterComponentRef: l3,
37011
+ defineMigration: g3,
37012
+ defineViewMigrations: y3,
37013
+ fieldColumn: n3,
37014
+ filter: f3,
37015
+ filterExprForRowType: a3,
37016
+ filterField: c3,
37017
+ filterGroup: d3,
37012
37018
  hasuraDSLforRowType: af,
37013
- initialValueRef: s3,
37014
- noRowsComponentRef: o3,
37019
+ initialValueRef: u3,
37020
+ noRowsComponentRef: i3,
37015
37021
  objectQuery: Ms,
37016
37022
  queryForRowType: QE,
37017
- queryTransformRef: l3,
37018
- rowExpansion: p3,
37023
+ queryTransformRef: s3,
37024
+ rowExpansion: m3,
37019
37025
  rowType: XE,
37020
37026
  runtimeRef: ui,
37021
37027
  valueQuery: Zd,
37022
- view: f3,
37023
- virtualColumn: n3
37028
+ view: p3,
37029
+ virtualColumn: r3
37024
37030
  }, Symbol.toStringTag, { value: "Module" }));
37025
37031
  export {
37026
- JO as App,
37032
+ XO as App,
37027
37033
  Py as CellRenderer,
37028
- x3 as DSL,
37029
- QO as FilterControl,
37034
+ O3 as DSL,
37035
+ ZO as FilterControl,
37030
37036
  tr as FilterExpr,
37031
37037
  qC as FilterTransform,
37032
37038
  Jg as FilterValue,
@@ -37035,14 +37041,14 @@ export {
37035
37041
  OS as bimap,
37036
37042
  hf as buildGraphQLQueryVariables,
37037
37043
  PC as buildHasuraConditions,
37038
- w3 as checkMigration,
37044
+ E3 as checkMigration,
37039
37045
  hl as currentDefinitionRevision,
37040
37046
  Ya as failure,
37041
- r3 as filterExprForRowType,
37047
+ a3 as filterExprForRowType,
37042
37048
  DS as flatMap,
37043
37049
  Cy as generateGraphQLQuery,
37044
37050
  Sy as generateGraphQLQueryAST,
37045
- S3 as generateSelectionSetFromColumns,
37051
+ C3 as generateSelectionSetFromColumns,
37046
37052
  RS as getOrElse,
37047
37053
  tu as getViewRootFieldName,
37048
37054
  Qg as getViewStaticArgs,
@@ -37053,9 +37059,9 @@ export {
37053
37059
  im as hasuraOperatorsAreEqual,
37054
37060
  cf as isFailure,
37055
37061
  ii as isSuccess,
37056
- E3 as latestFilterId,
37062
+ S3 as latestFilterId,
37057
37063
  xS as mapFailure,
37058
- C3 as mapHasuraCustomOperatorInput,
37064
+ x3 as mapHasuraCustomOperatorInput,
37059
37065
  ay as mapResult,
37060
37066
  PS as match,
37061
37067
  aC as migrateFilterState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronor/dtv",
3
- "version": "10.0.0",
3
+ "version": "10.0.1",
4
4
  "description": "Schema-driven, declarative table views with advanced filtering, data fetching and AI-assisted filter generation.",
5
5
  "repository": {
6
6
  "type": "git",