@smallwebco/tinypivot-vue 1.0.12 → 1.0.13

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.
@@ -1,4 +1,4 @@
1
- import { ref as M, computed as T, watch as Ue, defineComponent as Qe, onMounted as xt, nextTick as je, onUnmounted as Tt, createElementBlock as u, openBlock as r, createElementVNode as e, toDisplayString as R, normalizeClass as q, withDirectives as it, createCommentVNode as z, vModelText as rt, createTextVNode as I, Fragment as W, renderList as J, withModifiers as He, unref as S, normalizeStyle as ve, createVNode as Ye, createBlock as io, Transition as ro, withCtx as uo, withKeys as vo, Teleport as co } from "vue";
1
+ import { ref as M, computed as T, watch as ze, defineComponent as Qe, onMounted as xt, nextTick as Ue, onUnmounted as Tt, createElementBlock as u, openBlock as r, createElementVNode as e, toDisplayString as R, normalizeClass as q, withDirectives as it, createCommentVNode as z, vModelText as rt, createTextVNode as I, Fragment as W, renderList as J, withModifiers as Ke, unref as S, normalizeStyle as ve, createVNode as Ye, createBlock as io, Transition as ro, withCtx as uo, withKeys as vo, Teleport as co } from "vue";
2
2
  import { useVueTable as go, getFilteredRowModel as po, getSortedRowModel as fo, getCoreRowModel as mo } from "@tanstack/vue-table";
3
3
  function ho(t) {
4
4
  const i = t.filter((c) => c != null && c !== "");
@@ -528,7 +528,7 @@ function Ko(t) {
528
528
  const w = v.value.find((x) => x.id === g);
529
529
  return w ? w.desc ? "desc" : "asc" : null;
530
530
  }
531
- return Ue(i, () => {
531
+ return ze(i, () => {
532
532
  $();
533
533
  }), {
534
534
  // Table instance
@@ -646,7 +646,7 @@ function _o(t) {
646
646
  const g = C.value.filter((x) => !x.isNumeric && x.uniqueCount < 50), w = C.value.filter((x) => x.isNumeric);
647
647
  g.length > 0 && w.length > 0 && (l.value = [g[0].field], m.value = [{ field: w[0].field, aggregation: "sum" }]);
648
648
  }
649
- return Ue(
649
+ return ze(
650
650
  t,
651
651
  (g) => {
652
652
  if (g.length === 0) return;
@@ -678,7 +678,7 @@ function _o(t) {
678
678
  }
679
679
  },
680
680
  { immediate: !0 }
681
- ), Ue(
681
+ ), ze(
682
682
  [l, v, m, y, c],
683
683
  () => {
684
684
  if (!b.value) return;
@@ -933,13 +933,13 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
933
933
  s.key === "Escape" ? l("close") : s.key === "Enter" && s.ctrlKey && H();
934
934
  }
935
935
  return xt(() => {
936
- je(() => {
936
+ Ue(() => {
937
937
  var s;
938
938
  (s = y.value) == null || s.focus();
939
939
  }), document.addEventListener("mousedown", B), document.addEventListener("keydown", f);
940
940
  }), Tt(() => {
941
941
  document.removeEventListener("mousedown", B), document.removeEventListener("keydown", f);
942
- }), Ue(() => n.selectedValues, (s) => {
942
+ }), ze(() => n.selectedValues, (s) => {
943
943
  c.value = new Set(s);
944
944
  }, { immediate: !0 }), (s, d) => (r(), u("div", {
945
945
  ref_key: "dropdownRef",
@@ -1244,7 +1244,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1244
1244
  key: 0,
1245
1245
  class: "vpg-toggle-btn",
1246
1246
  title: d.assignedTo === "row" ? "Move to Columns" : "Move to Rows",
1247
- onClick: He((g) => X(d.field, d.assignedTo), ["stop"])
1247
+ onClick: Ke((g) => X(d.field, d.assignedTo), ["stop"])
1248
1248
  }, [...s[8] || (s[8] = [
1249
1249
  e("svg", {
1250
1250
  class: "vpg-icon-xs",
@@ -1265,7 +1265,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1265
1265
  class: "vpg-agg-select",
1266
1266
  value: d.valueConfig.aggregation,
1267
1267
  onChange: (g) => _(d.field, d.valueConfig.aggregation, g.target.value),
1268
- onClick: s[1] || (s[1] = He(() => {
1268
+ onClick: s[1] || (s[1] = Ke(() => {
1269
1269
  }, ["stop"]))
1270
1270
  }, [
1271
1271
  (r(), u(W, null, J(y, (g) => e("option", {
@@ -1276,7 +1276,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1276
1276
  e("button", {
1277
1277
  class: "vpg-remove-btn",
1278
1278
  title: "Remove",
1279
- onClick: He((g) => B(d.field, d.assignedTo, d.valueConfig), ["stop"])
1279
+ onClick: Ke((g) => B(d.field, d.assignedTo, d.valueConfig), ["stop"])
1280
1280
  }, " × ", 8, wn)
1281
1281
  ])
1282
1282
  ], 42, cn);
@@ -1499,14 +1499,14 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1499
1499
  return [];
1500
1500
  const E = n.pivotResult.rowHeaders.map((k, A) => A), p = n.pivotResult.rowHeaders, P = n.pivotResult.data;
1501
1501
  return E.sort((k, A) => {
1502
- var G, Me, Le, Pe, Ee, Ne;
1502
+ var G, Me, Ee, Ne, Be, je;
1503
1503
  let N;
1504
1504
  if (s.value === "row") {
1505
1505
  const be = ((G = p[k]) == null ? void 0 : G.join(" / ")) || "", ke = ((Me = p[A]) == null ? void 0 : Me.join(" / ")) || "";
1506
1506
  N = be.localeCompare(ke, void 0, { numeric: !0, sensitivity: "base" });
1507
1507
  } else {
1508
- const be = s.value, ke = ((Pe = (Le = P[k]) == null ? void 0 : Le[be]) == null ? void 0 : Pe.value) ?? null, Be = ((Ne = (Ee = P[A]) == null ? void 0 : Ee[be]) == null ? void 0 : Ne.value) ?? null;
1509
- ke === null && Be === null ? N = 0 : ke === null ? N = 1 : Be === null ? N = -1 : N = ke - Be;
1508
+ const be = s.value, ke = ((Ne = (Ee = P[k]) == null ? void 0 : Ee[be]) == null ? void 0 : Ne.value) ?? null, He = ((je = (Be = P[A]) == null ? void 0 : Be[be]) == null ? void 0 : je.value) ?? null;
1509
+ ke === null && He === null ? N = 0 : ke === null ? N = 1 : He === null ? N = -1 : N = ke - He;
1510
1510
  }
1511
1511
  return f.value === "asc" ? N : -N;
1512
1512
  }), E;
@@ -1567,7 +1567,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1567
1567
  }
1568
1568
  c.value = null;
1569
1569
  }
1570
- function Ke(E, p, P) {
1570
+ function We(E, p, P) {
1571
1571
  b.value = { zone: E, index: p }, P.dataTransfer.effectAllowed = "move", P.dataTransfer.setData("text/plain", `reorder:${E}:${p}`), requestAnimationFrame(() => {
1572
1572
  c.value = null;
1573
1573
  });
@@ -1581,7 +1581,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1581
1581
  function re() {
1582
1582
  C.value = null;
1583
1583
  }
1584
- function We(E, p, P) {
1584
+ function Ae(E, p, P) {
1585
1585
  if (P.preventDefault(), P.stopPropagation(), !b.value || b.value.zone !== E)
1586
1586
  return;
1587
1587
  const k = b.value.index;
@@ -1592,7 +1592,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1592
1592
  const A = E === "row" ? [...n.rowFields] : [...n.columnFields], [N] = A.splice(k, 1);
1593
1593
  A.splice(p, 0, N), l(E === "row" ? "reorderRowFields" : "reorderColumnFields", A), b.value = null, C.value = null;
1594
1594
  }
1595
- function ze(E, p) {
1595
+ function Le(E, p) {
1596
1596
  var P, k;
1597
1597
  return ((P = b.value) == null ? void 0 : P.zone) === E && ((k = b.value) == null ? void 0 : k.index) === p;
1598
1598
  }
@@ -1600,7 +1600,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1600
1600
  var P, k;
1601
1601
  return ((P = C.value) == null ? void 0 : P.zone) === E && ((k = C.value) == null ? void 0 : k.index) === p;
1602
1602
  }
1603
- const Ae = M(180), we = M(80);
1603
+ const Pe = M(180), we = M(80);
1604
1604
  return (E, p) => {
1605
1605
  var P;
1606
1606
  return r(), u("div", {
@@ -1699,21 +1699,21 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1699
1699
  (r(!0), u(W, null, J(t.rowFields, (k, A) => (r(), u("div", {
1700
1700
  key: k,
1701
1701
  class: q(["vpg-mini-chip vpg-row-chip", {
1702
- "vpg-chip-dragging": ze("row", A),
1702
+ "vpg-chip-dragging": Le("row", A),
1703
1703
  "vpg-chip-drop-target": _e("row", A)
1704
1704
  }]),
1705
1705
  draggable: "true",
1706
- onDragstart: (N) => Ke("row", A, N),
1706
+ onDragstart: (N) => We("row", A, N),
1707
1707
  onDragend: ye,
1708
1708
  onDragover: (N) => he("row", A, N),
1709
1709
  onDragleave: re,
1710
- onDrop: (N) => We("row", A, N)
1710
+ onDrop: (N) => Ae("row", A, N)
1711
1711
  }, [
1712
1712
  p[14] || (p[14] = e("span", { class: "vpg-drag-handle" }, "⋮⋮", -1)),
1713
1713
  e("span", ol, R(k), 1),
1714
1714
  e("button", {
1715
1715
  class: "vpg-mini-remove",
1716
- onClick: He((N) => l("removeRowField", k), ["stop"])
1716
+ onClick: Ke((N) => l("removeRowField", k), ["stop"])
1717
1717
  }, "×", 8, nl)
1718
1718
  ], 42, tl))), 128)),
1719
1719
  t.rowFields.length === 0 ? (r(), u("span", ll, "Drop here")) : z("", !0)
@@ -1733,21 +1733,21 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1733
1733
  (r(!0), u(W, null, J(t.columnFields, (k, A) => (r(), u("div", {
1734
1734
  key: k,
1735
1735
  class: q(["vpg-mini-chip vpg-column-chip", {
1736
- "vpg-chip-dragging": ze("column", A),
1736
+ "vpg-chip-dragging": Le("column", A),
1737
1737
  "vpg-chip-drop-target": _e("column", A)
1738
1738
  }]),
1739
1739
  draggable: "true",
1740
- onDragstart: (N) => Ke("column", A, N),
1740
+ onDragstart: (N) => We("column", A, N),
1741
1741
  onDragend: ye,
1742
1742
  onDragover: (N) => he("column", A, N),
1743
1743
  onDragleave: re,
1744
- onDrop: (N) => We("column", A, N)
1744
+ onDrop: (N) => Ae("column", A, N)
1745
1745
  }, [
1746
1746
  p[16] || (p[16] = e("span", { class: "vpg-drag-handle" }, "⋮⋮", -1)),
1747
1747
  e("span", il, R(k), 1),
1748
1748
  e("button", {
1749
1749
  class: "vpg-mini-remove",
1750
- onClick: He((N) => l("removeColumnField", k), ["stop"])
1750
+ onClick: Ke((N) => l("removeColumnField", k), ["stop"])
1751
1751
  }, "×", 8, rl)
1752
1752
  ], 42, al))), 128)),
1753
1753
  t.columnFields.length === 0 ? (r(), u("span", ul, "Drop here")) : z("", !0)
@@ -1821,7 +1821,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1821
1821
  key: 0,
1822
1822
  class: "vpg-row-header-label",
1823
1823
  rowspan: g.value.length,
1824
- style: ve({ width: `${Ae.value}px` }),
1824
+ style: ve({ width: `${Pe.value}px` }),
1825
1825
  onClick: p[8] || (p[8] = (N) => d("row"))
1826
1826
  }, [
1827
1827
  e("div", yl, [
@@ -1860,7 +1860,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1860
1860
  }, [
1861
1861
  e("th", {
1862
1862
  class: "vpg-row-header-cell",
1863
- style: ve({ width: `${Ae.value}px` })
1863
+ style: ve({ width: `${Pe.value}px` })
1864
1864
  }, [
1865
1865
  (r(!0), u(W, null, J(t.pivotResult.rowHeaders[k], (A, N) => (r(), u("span", {
1866
1866
  key: N,
@@ -1881,7 +1881,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
1881
1881
  t.pivotResult.columnTotals.length > 0 ? (r(), u("tr", Ml, [
1882
1882
  e("th", {
1883
1883
  class: "vpg-row-header-cell vpg-total-label",
1884
- style: ve({ width: `${Ae.value}px` })
1884
+ style: ve({ width: `${Pe.value}px` })
1885
1885
  }, " Total ", 4),
1886
1886
  (r(!0), u(W, null, J(t.pivotResult.columnTotals, (k, A) => (r(), u("td", {
1887
1887
  key: A,
@@ -2048,13 +2048,13 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2048
2048
  getColumnStats: ee,
2049
2049
  hasActiveFilter: ie,
2050
2050
  setColumnFilter: me,
2051
- getColumnFilterValues: Ke,
2051
+ getColumnFilterValues: We,
2052
2052
  clearAllFilters: ye,
2053
2053
  toggleSort: he,
2054
2054
  getSortDirection: re,
2055
- columnFilters: We,
2056
- activeFilters: ze
2057
- } = Ko({ data: F }), _e = T(() => g.getFilteredRowModel().rows.map((o) => o.original)), Ae = T(() => ze.value.length === 0 ? null : ze.value.map((a) => {
2055
+ columnFilters: Ae,
2056
+ activeFilters: Le
2057
+ } = Ko({ data: F }), _e = T(() => g.getFilteredRowModel().rows.map((o) => o.original)), Pe = T(() => Le.value.length === 0 ? null : Le.value.map((a) => {
2058
2058
  var o;
2059
2059
  return {
2060
2060
  column: a.column,
@@ -2071,13 +2071,13 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2071
2071
  isConfigured: N,
2072
2072
  pivotResult: G,
2073
2073
  addRowField: Me,
2074
- removeRowField: Le,
2075
- addColumnField: Pe,
2076
- removeColumnField: Ee,
2077
- addValueField: Ne,
2074
+ removeRowField: Ee,
2075
+ addColumnField: Ne,
2076
+ removeColumnField: Be,
2077
+ addValueField: je,
2078
2078
  removeValueField: be,
2079
2079
  updateValueFieldAggregation: ke,
2080
- clearConfig: Be,
2080
+ clearConfig: He,
2081
2081
  autoSuggestConfig: At
2082
2082
  } = _o(_e), qe = T(() => {
2083
2083
  if (!C.value.trim() || !n.enableSearch)
@@ -2104,6 +2104,9 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2104
2104
  function Nt() {
2105
2105
  $.value > 1 && $.value--;
2106
2106
  }
2107
+ ze([Ae, C], () => {
2108
+ $.value = 1;
2109
+ });
2107
2110
  function Bt() {
2108
2111
  if (te.value === "pivot") {
2109
2112
  jt();
@@ -2241,7 +2244,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2241
2244
  h === null ? (he(a), o === "desc" && re(a) === "asc" && he(a)) : h !== o && he(a);
2242
2245
  }
2243
2246
  }
2244
- const Xe = T(() => We.value.length), pe = M(null), ue = M(null), se = M(null), nt = M(!1);
2247
+ const Xe = T(() => Ae.value.length), pe = M(null), ue = M(null), se = M(null), nt = M(!1);
2245
2248
  function Yt(a) {
2246
2249
  const o = Fe.value.length - 1;
2247
2250
  o < 0 || (ue.value = { row: 0, col: a }, se.value = { row: o, col: a }, pe.value = { row: 0, col: a });
@@ -2298,7 +2301,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2298
2301
  return;
2299
2302
  }
2300
2303
  if ((a.ctrlKey || a.metaKey) && a.key === "f" && n.enableSearch) {
2301
- a.preventDefault(), V.value = !0, je(() => {
2304
+ a.preventDefault(), V.value = !0, Ue(() => {
2302
2305
  const Y = document.querySelector(".vpg-search-input");
2303
2306
  Y == null || Y.focus();
2304
2307
  });
@@ -2329,7 +2332,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2329
2332
  }
2330
2333
  }
2331
2334
  function Qt(a, o) {
2332
- je(() => {
2335
+ Ue(() => {
2333
2336
  var j;
2334
2337
  const h = (j = ft.value) == null ? void 0 : j.querySelector(
2335
2338
  `[data-row="${a}"][data-col="${o}"]`
@@ -2386,15 +2389,15 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2386
2389
  }
2387
2390
  }
2388
2391
  xt(() => {
2389
- mt(), document.addEventListener("keydown", wt), document.addEventListener("mouseup", kt), je(() => {
2392
+ mt(), document.addEventListener("keydown", wt), document.addEventListener("mouseup", kt), Ue(() => {
2390
2393
  var a;
2391
2394
  (a = ot.value) == null || a.addEventListener("scroll", Ct, { passive: !0 });
2392
2395
  }), window.addEventListener("scroll", yt, { passive: !0, capture: !0 });
2393
2396
  }), Tt(() => {
2394
2397
  var a;
2395
2398
  document.removeEventListener("keydown", wt), document.removeEventListener("mouseup", kt), (a = ot.value) == null || a.removeEventListener("scroll", Ct), window.removeEventListener("scroll", yt, { capture: !0 });
2396
- }), Ue(() => n.data, () => {
2397
- je(mt);
2399
+ }), ze(() => n.data, () => {
2400
+ Ue(mt);
2398
2401
  }, { immediate: !0 });
2399
2402
  const so = T(() => w.value.reduce((a, o) => a + (ge.value[o] || Ce), 0));
2400
2403
  function ao(a) {
@@ -2830,16 +2833,16 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2830
2833
  "show-column-totals": S(k),
2831
2834
  "onUpdate:showRowTotals": o[9] || (o[9] = (h) => P.value = h),
2832
2835
  "onUpdate:showColumnTotals": o[10] || (o[10] = (h) => k.value = h),
2833
- onClearConfig: S(Be),
2836
+ onClearConfig: S(He),
2834
2837
  onAutoSuggest: S(At),
2835
2838
  onDragStart: Kt,
2836
2839
  onDragEnd: Wt,
2837
2840
  onUpdateAggregation: S(ke),
2838
2841
  onAddRowField: S(Me),
2839
- onRemoveRowField: S(Le),
2840
- onAddColumnField: S(Pe),
2841
- onRemoveColumnField: S(Ee),
2842
- onAddValueField: S(Ne),
2842
+ onRemoveRowField: S(Ee),
2843
+ onAddColumnField: S(Ne),
2844
+ onRemoveColumnField: S(Be),
2845
+ onAddValueField: S(je),
2843
2846
  onRemoveValueField: S(be)
2844
2847
  }, null, 8, ["available-fields", "row-fields", "column-fields", "value-fields", "show-row-totals", "show-column-totals", "onClearConfig", "onAutoSuggest", "onUpdateAggregation", "onAddRowField", "onRemoveRowField", "onAddColumnField", "onRemoveColumnField", "onAddValueField", "onRemoveValueField"])
2845
2848
  ])) : z("", !0),
@@ -2854,14 +2857,14 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
2854
2857
  "dragging-field": tt.value,
2855
2858
  "pivot-result": S(G),
2856
2859
  "font-size": b.value,
2857
- "active-filters": Ae.value,
2860
+ "active-filters": Pe.value,
2858
2861
  "total-row-count": S(L),
2859
2862
  "filtered-row-count": S(x),
2860
2863
  onAddRowField: S(Me),
2861
- onRemoveRowField: S(Le),
2862
- onAddColumnField: S(Pe),
2863
- onRemoveColumnField: S(Ee),
2864
- onAddValueField: S(Ne),
2864
+ onRemoveRowField: S(Ee),
2865
+ onAddColumnField: S(Ne),
2866
+ onRemoveColumnField: S(Be),
2867
+ onAddValueField: S(je),
2865
2868
  onRemoveValueField: S(be),
2866
2869
  onUpdateAggregation: S(ke),
2867
2870
  onReorderRowFields: _t,
@@ -3031,7 +3034,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
3031
3034
  "column-id": ne.value,
3032
3035
  "column-name": ne.value,
3033
3036
  stats: S(ee)(ne.value),
3034
- "selected-values": S(Ke)(ne.value),
3037
+ "selected-values": S(We)(ne.value),
3035
3038
  "sort-direction": S(re)(ne.value),
3036
3039
  onFilter: o[13] || (o[13] = (h) => Gt(ne.value, h)),
3037
3040
  onSort: o[14] || (o[14] = (h) => Xt(ne.value, h)),
@@ -3041,7 +3044,7 @@ const Yo = { class: "vpg-filter-header" }, Zo = { class: "vpg-filter-title" }, J
3041
3044
  ]))
3042
3045
  ], 6));
3043
3046
  }
3044
- }), Hs = /* @__PURE__ */ et(Vs, [["__scopeId", "data-v-2f0c0741"]]);
3047
+ }), Hs = /* @__PURE__ */ et(Vs, [["__scopeId", "data-v-d439bb38"]]);
3045
3048
  export {
3046
3049
  ln as ColumnFilter,
3047
3050
  Hs as DataGrid,