@dolusoft/query-table 3.16.0 → 3.18.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.
@@ -1512,7 +1512,8 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
1512
1512
  "number",
1513
1513
  "integer",
1514
1514
  "date",
1515
- "datetime"
1515
+ "datetime",
1516
+ "ip"
1516
1517
  ];
1517
1518
  const isDated = () => props.type === "date" || props.type === "datetime";
1518
1519
  const hidesInput = () => {
@@ -1567,7 +1568,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
1567
1568
  isRange() ? (openBlock(), createElementBlock(Fragment, { key: 0 }, renderList(bounds, (bound) => {
1568
1569
  return openBlock(), createElementBlock(Fragment, { key: bound }, [isDated() && _ctx.$slots["filter-datetime"] ? renderSlot(_ctx.$slots, "filter-datetime", mergeProps({ ref_for: true }, datetimeProps(bound)), void 0, void 0, 0) : (openBlock(), createElementBlock("input", {
1569
1570
  key: 1,
1570
- type: isDated() ? "date" : "number",
1571
+ type: isDated() ? "date" : __props.type === "ip" ? "text" : "number",
1571
1572
  class: "qt-filter-input",
1572
1573
  "aria-label": boundName(bound),
1573
1574
  value: boundText(bound),
@@ -1584,7 +1585,7 @@ var filter_cell_default = /* @__PURE__ */ defineComponent({
1584
1585
  "aria-invalid": isInvalid() || void 0,
1585
1586
  onInput: _cache[1] || (_cache[1] = ($event) => unref(filters).setInput(__props.column.field, inputValue($event))),
1586
1587
  onKeydown: _cache[2] || (_cache[2] = withKeys(($event) => unref(filters).apply(__props.column.field), ["enter"]))
1587
- }, null, 40, _hoisted_3$3)) : __props.type === "number" || __props.type === "integer" ? (openBlock(), createElementBlock("input", {
1588
+ }, null, 40, _hoisted_3$3)) : __props.type === "number" || __props.type === "integer" || __props.type === "ip" ? (openBlock(), createElementBlock("input", {
1588
1589
  key: 3,
1589
1590
  type: "text",
1590
1591
  class: "qt-filter-input",
@@ -3526,7 +3527,7 @@ var useRowWindow = (o) => {
3526
3527
  const settings = computed((previous) => {
3527
3528
  const value = o.virtual();
3528
3529
  const next = value === true ? {} : value || null;
3529
- return previous && next && previous.overscan === next.overscan && previous.rowHeight === next.rowHeight && previous.estimateRowHeight === next.estimateRowHeight && previous.groupRowHeight === next.groupRowHeight && previous.scrollElement === next.scrollElement ? previous : next;
3530
+ return previous && next && previous.overscan === next.overscan && previous.rowHeight === next.rowHeight && previous.estimateRowHeight === next.estimateRowHeight && previous.groupRowHeight === next.groupRowHeight && previous.scrollElement === next.scrollElement && previous.keepAnchor === next.keepAnchor ? previous : next;
3530
3531
  });
3531
3532
  const enabled = () => settings.value !== null;
3532
3533
  const overscan = () => Math.max(0, settings.value?.overscan ?? 10);
@@ -3583,9 +3584,8 @@ var useRowWindow = (o) => {
3583
3584
  key: groupKey(run.id),
3584
3585
  aria
3585
3586
  });
3586
- /** Position of a row index among the center rows (ascending), or -1. */
3587
- const positionOf = (index) => {
3588
- const rows = center();
3587
+ /** Position of a row index among center rows (ascending), or -1. */
3588
+ const positionIn = (rows, index) => {
3589
3589
  if (rows[index]?.index === index) return index;
3590
3590
  let low = 0;
3591
3591
  let high = rows.length - 1;
@@ -3598,6 +3598,7 @@ var useRowWindow = (o) => {
3598
3598
  }
3599
3599
  return -1;
3600
3600
  };
3601
+ const positionOf = (index) => positionIn(center(), index);
3601
3602
  let heights = /* @__PURE__ */ new Float64Array(0);
3602
3603
  /** Item heights without the group row above an item (C-104). */
3603
3604
  let base = /* @__PURE__ */ new Float64Array(0);
@@ -3712,7 +3713,10 @@ var useRowWindow = (o) => {
3712
3713
  * (it anchors to a spacer when no row is in view); it is put back.
3713
3714
  */
3714
3715
  let expected = null;
3715
- /** A `scrollToIndex` to correct once its row is drawn (C-87). */
3716
+ /**
3717
+ * A row to correct once it is drawn: a `scrollToIndex` (C-87), or an
3718
+ * anchor kept across a change of `rows`, back at its client `top` (C-119).
3719
+ */
3716
3720
  let pending = null;
3717
3721
  /** Frames a `scrollToIndex` waits for its row before it is given up. */
3718
3722
  const pendingFrames = 6;
@@ -3740,12 +3744,15 @@ var useRowWindow = (o) => {
3740
3744
  behavior: "instant"
3741
3745
  });
3742
3746
  };
3747
+ /** Height of a sticky header over the top (client `viewTop`) of the view. */
3748
+ const headCover = (viewTop) => {
3749
+ const head = o.table.value?.tHead?.getBoundingClientRect();
3750
+ return head && head.top <= viewTop + 1 && head.bottom > viewTop ? head.bottom - viewTop : 0;
3751
+ };
3743
3752
  /** How far to scroll to show an item at `top` (client) with `height`. */
3744
3753
  const alignDelta = (top, height, align, groupCover = 0, target = container) => {
3745
3754
  const view = viewport(target);
3746
- const head = o.table.value?.tHead?.getBoundingClientRect();
3747
- const cover = head && head.top <= view.top + 1 && head.bottom > view.top ? head.bottom - view.top : 0;
3748
- const viewTop = view.top + cover + groupCover;
3755
+ const viewTop = view.top + headCover(view.top) + groupCover;
3749
3756
  const viewBottom = view.top + view.height;
3750
3757
  const bottom = top + height;
3751
3758
  switch (align) {
@@ -3779,6 +3786,33 @@ var useRowWindow = (o) => {
3779
3786
  const head = above?.classList.contains("qt-group-row") ? above : null;
3780
3787
  scrollBy(alignDelta((head ?? tr).getBoundingClientRect().top, (whole ? itemHeight(tr) : tr.getBoundingClientRect().height) + (head ? head.getBoundingClientRect().height : 0), align, head ? 0 : coverOf(position, tbody), target), target);
3781
3788
  };
3789
+ /**
3790
+ * The anchor of `keepAnchor` in the drawn body, read before it is drawn
3791
+ * again (C-119): the key and client top of the first data row whose top is
3792
+ * in the view, below a sticky header. `null` when nothing is to be kept,
3793
+ * the first center row being that row included.
3794
+ */
3795
+ const anchorOf = (before) => {
3796
+ const tbody = body();
3797
+ if (!settings.value?.keepAnchor || !o.hasRowKey?.() || !tbody || !container || printing.value) return null;
3798
+ const view = viewport();
3799
+ const viewTop = view.top + headCover(view.top);
3800
+ for (const tr of tbody.children) {
3801
+ const at = tr.getAttribute("data-row-index");
3802
+ if (at === null || tr.hasAttribute("data-pinned-row")) continue;
3803
+ const top = tr.getBoundingClientRect().top;
3804
+ if (top < viewTop - .5) continue;
3805
+ if (top >= view.top + view.height) return null;
3806
+ const position = positionIn(before, Number(at));
3807
+ if (position <= 0) return null;
3808
+ const { row, index } = before[position];
3809
+ return {
3810
+ key: o.keyOf(row, index),
3811
+ top
3812
+ };
3813
+ }
3814
+ return null;
3815
+ };
3782
3816
  /** After a render: correct the drift (C-84) or a `scrollToIndex` (C-87). */
3783
3817
  const settle = () => {
3784
3818
  const tbody = body();
@@ -3790,11 +3824,13 @@ var useRowWindow = (o) => {
3790
3824
  if (pending) {
3791
3825
  const tr = rowElement(tbody, pending.position);
3792
3826
  if (tr) {
3793
- const { align, position } = pending;
3827
+ const done = pending;
3794
3828
  pending = null;
3795
- alignRow(tbody, tr, position, align, container);
3829
+ if ("top" in done) scrollBy(tr.getBoundingClientRect().top - done.top);
3830
+ else alignRow(tbody, tr, done.position, done.align, container);
3796
3831
  return;
3797
3832
  }
3833
+ if ("top" in pending && pending.tries === 0) scrollBy(itemsTop(tbody) + offsets[pending.position] - pending.top);
3798
3834
  if (++pending.tries <= pendingFrames) {
3799
3835
  schedule();
3800
3836
  return;
@@ -4048,7 +4084,22 @@ var useRowWindow = (o) => {
4048
4084
  () => settings.value?.groupRowHeight,
4049
4085
  () => groupShape(groups.value),
4050
4086
  enabled
4051
- ], rebuild, { immediate: true });
4087
+ ], (now, before) => {
4088
+ const old = before?.[0];
4089
+ const keep = old && now[0] !== old && now[5] && before[5] ? anchorOf(old) : null;
4090
+ rebuild();
4091
+ if (keep) {
4092
+ const position = center().findIndex((item) => o.keyOf(item.row, item.index) === keep.key);
4093
+ if (position >= 0) {
4094
+ anchor = null;
4095
+ pending = {
4096
+ position,
4097
+ top: keep.top,
4098
+ tries: 0
4099
+ };
4100
+ }
4101
+ }
4102
+ }, { immediate: true });
4052
4103
  watch([
4053
4104
  () => o.table.value,
4054
4105
  enabled,
@@ -4370,6 +4421,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4370
4421
  table: bodyTable,
4371
4422
  bodyRows: () => state.rowPinning.rows.value,
4372
4423
  keyOf: expansion.keyOf,
4424
+ hasRowKey: () => props.rowKey !== void 0,
4373
4425
  isExpanded: expansion.isExpanded,
4374
4426
  groupBy: () => props.groupBy
4375
4427
  });