@dolusoft/query-table 3.9.0 → 3.11.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.
@@ -380,7 +380,10 @@ var startFlash = (o) => {
380
380
  timer = void 0;
381
381
  timerAt = Infinity;
382
382
  const { nearest, dropped } = marks.prune(performance.now());
383
- if (dropped) version.value++;
383
+ if (dropped) {
384
+ pruneDrawn();
385
+ version.value++;
386
+ }
384
387
  if (nearest !== Infinity) wakeAt(nearest);
385
388
  }, Math.max(0, end - performance.now()));
386
389
  };
@@ -388,8 +391,18 @@ var startFlash = (o) => {
388
391
  const resetAll = () => {
389
392
  tracker.clear();
390
393
  stopClock();
394
+ drawn.clear();
391
395
  if (marks.clear()) version.value++;
392
396
  };
397
+ /**
398
+ * The last `RowFlash` of each row key, with the live marks it was made
399
+ * from as a text of copied numbers (field, phase, generation): never the
400
+ * `Mark` objects, which a restart updates in place. Pruned with the marks.
401
+ */
402
+ const drawn = /* @__PURE__ */ new Map();
403
+ const pruneDrawn = () => {
404
+ for (const key of drawn.keys()) if (!marks.get(key)) drawn.delete(key);
405
+ };
393
406
  const update = () => {
394
407
  if (!active) return;
395
408
  if (o.rowKey() !== rowKey) {
@@ -449,13 +462,12 @@ var startFlash = (o) => {
449
462
  if (at + length < timerAt) wakeAt(at + length);
450
463
  }
451
464
  }
452
- if (changed) version.value++;
465
+ if (changed) {
466
+ pruneDrawn();
467
+ version.value++;
468
+ }
453
469
  };
454
470
  update();
455
- const rowMarksOf = (row, index) => {
456
- version.value;
457
- return keyOf === null ? void 0 : marks.get(keyOf(row, index));
458
- };
459
471
  /** The generation bound to an element, and the elapsed value written on it. */
460
472
  const bound = /* @__PURE__ */ new WeakMap();
461
473
  const written = /* @__PURE__ */ new WeakMap();
@@ -486,20 +498,41 @@ var startFlash = (o) => {
486
498
  written.set(el, value);
487
499
  };
488
500
  const view = {
489
- row: (row, index) => {
490
- const mark = rowMarksOf(row, index)?.row;
491
- return mark ? live(mark, performance.now())?.phase : void 0;
492
- },
493
- cell: (row, index, field) => {
494
- const mark = rowMarksOf(row, index)?.cells?.get(field);
495
- return mark ? live(mark, performance.now())?.phase : void 0;
501
+ of: (key) => {
502
+ version.value;
503
+ const rowMarks = keyOf === null ? void 0 : marks.get(key);
504
+ if (!rowMarks) {
505
+ drawn.delete(key);
506
+ return;
507
+ }
508
+ const now = performance.now();
509
+ const rowMark = live(rowMarks.row, now);
510
+ let text = rowMark ? `${rowMark.phase}${rowMark.gen}` : "";
511
+ rowMarks.cells?.forEach((mark, field) => {
512
+ if (live(mark, now)) text += `|${field}:${mark.phase}${mark.gen}`;
513
+ });
514
+ if (text === "") {
515
+ drawn.delete(key);
516
+ return;
517
+ }
518
+ const last = drawn.get(key);
519
+ if (last?.live === text) return last.flash;
520
+ const flash = {};
521
+ if (rowMark) flash.row = rowMark.phase;
522
+ let cells;
523
+ rowMarks.cells?.forEach((mark, field) => {
524
+ if (live(mark, now)) (cells ??= {})[field] = mark.phase;
525
+ });
526
+ if (cells) flash.cells = cells;
527
+ drawn.set(key, {
528
+ live: text,
529
+ flash
530
+ });
531
+ return flash;
496
532
  },
497
- bind: (vnode) => {
498
- const tr = vnode.el;
499
- const index = Number(vnode.props?.["data-row-index"]);
500
- const row = o.rows()[index];
501
- if (!tr || row === void 0 || keyOf === null) return;
502
- const rowMarks = marks.get(keyOf(row, index));
533
+ bind: (tr, key) => {
534
+ if (keyOf === null) return;
535
+ const rowMarks = marks.get(key);
503
536
  if (!rowMarks && !boundRows.has(tr)) return;
504
537
  const now = performance.now();
505
538
  const rowMark = live(rowMarks?.row, now);
@@ -639,39 +672,12 @@ var useHeaderContextMenu = (options) => {
639
672
  /** Reads a dotted path (`'a.b'`) from a row. */
640
673
  var valueAt = (row, path) => path.split(".").reduce((value, key) => value === null || value === void 0 ? void 0 : value[key], row);
641
674
  //#endregion
642
- //#region src/pin/pin.ts
643
- /** Geometry key of a utility cell; a column's key is its `field`. */
644
- var utilityKey = (utility) => `utility:${utility}`;
645
- /**
646
- * Attributes of a pinned cell (C-47, C-71): `data-pinned` (`''` on the left,
647
- * `'right'` on the right) and, once measured, the `--qt-pin-left` or
648
- * `--qt-pin-right` offset in pixels, next to an optional `width`. Nothing but
649
- * the width for a cell that is not pinned; no `style` when both are absent.
650
- */
651
- var pinAttrs = (side, offset, width) => {
652
- const style = {};
653
- if (width) style.width = width;
654
- if (side && offset !== void 0) style[side === "left" ? "--qt-pin-left" : "--qt-pin-right"] = `${offset}px`;
655
- return {
656
- "data-pinned": side === "left" ? "" : side === "right" ? "right" : void 0,
657
- style: Object.keys(style).length > 0 ? style : void 0
658
- };
659
- };
660
- //#endregion
661
675
  //#region src/body/use-cell-view.ts
662
676
  /**
663
- * What a body cell shows: its text, its attributes, the props for a
664
- * `cell-<field>` slot and the context menu event (C-27, C-28, C-30).
677
+ * The context menu event of the body cells (C-28). What a cell shows is
678
+ * drawn by its row (`parts/table-row.ts`).
665
679
  */
666
680
  var useCellView = (options) => {
667
- /** Text of a cell, whole: the table never cuts it. */
668
- const cellText = (row, column) => String(valueAt(row, column.field) ?? "");
669
- const types = computed(() => new Map(options.entries().map((entry) => [entry.column.field, columnTypeOf$1(entry.column)])));
670
- const cellAttrs = (entry) => ({
671
- "data-field": entry.column.field,
672
- "data-type": types.value.get(entry.column.field),
673
- ...pinAttrs(sideOf(entry.column), options.offsets()[entry.column.field])
674
- });
675
681
  /**
676
682
  * One listener on the `tbody` serves every cell (C-28): a listener per cell
677
683
  * would be a new closure per cell on every render. The cell is the nearest
@@ -705,52 +711,37 @@ var useCellView = (options) => {
705
711
  columnIndex: entry.index
706
712
  });
707
713
  };
708
- const hasCellSlot = (column) => !!options.slots[`cell-${column.field}`];
709
- const slotProps = (row, column, rowIndex, rowPinned) => ({
710
- row,
711
- rowIndex,
712
- column,
713
- cellValue: valueAt(row, column.field),
714
- rowPinned,
715
- pinRow: (position) => options.pinRow(row, rowIndex, position)
716
- });
717
- return {
718
- cellText,
719
- cellAttrs,
720
- hasCellSlot,
721
- slotProps,
722
- onContextMenu
723
- };
714
+ return { onContextMenu };
724
715
  };
725
716
  //#endregion
726
- //#region src/parts/table-body.vue?vue&type=script&setup=true&lang.ts
727
- var _hoisted_1$9 = ["role"];
728
- var _hoisted_2$5 = ["role"];
729
- var _hoisted_3$5 = ["role", "aria-rowindex"];
730
- var _hoisted_4$5 = [
731
- "colspan",
732
- "role",
733
- "aria-colspan"
734
- ];
735
- var _hoisted_5$2 = [
736
- "role",
737
- "data-row-index",
738
- "aria-rowindex",
739
- "data-pinned-row",
740
- "data-row-kind",
741
- "data-expanded",
742
- "data-selected",
743
- "data-flash",
744
- "onVnodeBeforeMount",
745
- "onVnodeUpdated"
746
- ];
747
- var _hoisted_6$2 = ["aria-label", "onClick"];
748
- var _hoisted_7$2 = [
749
- "aria-expanded",
750
- "aria-label",
751
- "onClick"
752
- ];
753
- var _hoisted_8$2 = {
717
+ //#region src/parts/table-row.ts
718
+ var value = () => ({ type: null });
719
+ var needed = () => ({
720
+ type: null,
721
+ required: true
722
+ });
723
+ var off = () => createCommentVNode("", true);
724
+ var panelIcon = () => createElementVNode("svg", {
725
+ width: "14",
726
+ height: "14",
727
+ viewBox: "0 0 24 24",
728
+ fill: "none",
729
+ stroke: "currentColor",
730
+ "stroke-width": "2",
731
+ "stroke-linecap": "round",
732
+ "aria-hidden": "true"
733
+ }, [createElementVNode("line", {
734
+ x1: "12",
735
+ y1: "5",
736
+ x2: "12",
737
+ y2: "19"
738
+ }), createElementVNode("line", {
739
+ x1: "5",
740
+ y1: "12",
741
+ x2: "19",
742
+ y2: "12"
743
+ })], -1);
744
+ var expandIcon = {
754
745
  width: "14",
755
746
  height: "14",
756
747
  viewBox: "0 0 24 24",
@@ -761,29 +752,180 @@ var _hoisted_8$2 = {
761
752
  "stroke-linejoin": "round",
762
753
  "aria-hidden": "true"
763
754
  };
764
- var _hoisted_9$1 = {
755
+ var chevronDown = {
765
756
  key: 0,
766
757
  points: "6 9 12 15 18 9"
767
758
  };
768
- var _hoisted_10 = {
759
+ var chevronRight = {
769
760
  key: 1,
770
761
  points: "9 6 15 12 9 18"
771
762
  };
772
- var _hoisted_11 = [
763
+ var rowDynamic = [
764
+ "role",
765
+ "data-row-index",
766
+ "aria-rowindex",
767
+ "data-pinned-row",
768
+ "data-row-kind",
769
+ "data-expanded",
770
+ "data-selected",
771
+ "data-flash"
772
+ ];
773
+ var panelDynamic = ["aria-label", "onClick"];
774
+ var expandDynamic = [
775
+ "aria-expanded",
776
+ "aria-label",
777
+ "onClick"
778
+ ];
779
+ var selectDynamic = [
773
780
  "aria-label",
774
781
  "checked",
775
782
  "onChange"
776
783
  ];
777
- var _hoisted_12 = ["role", "data-flash"];
778
- var _hoisted_13 = ["role", "data-flash"];
779
- var _hoisted_14 = [
784
+ /** Text of a cell, whole: the table never cuts it. */
785
+ var cellText = (row, column) => String(valueAt(row, column.field) ?? "");
786
+ /**
787
+ * One data row of the body (ADR 0017, C-106 to C-108): its `tr`, the
788
+ * utility cells and the column cells with their `cell-<field>` slots.
789
+ * Internal: not exported from the package.
790
+ *
791
+ * Every prop is a value the body computed for this row (K311-2), so Vue
792
+ * skips a row whose props did not change; the row's render calls no
793
+ * function that reads shared state. Its cell slots are called here, so what
794
+ * a slot reads reactively belongs to this row (K311-4). The render is
795
+ * written with the helpers compiled templates use, and draws the vnodes the
796
+ * `tr` branch of the body's template drew in 3.10 (C-108).
797
+ */
798
+ var tableRow = defineComponent({
799
+ name: "TableRow",
800
+ inheritAttrs: false,
801
+ props: {
802
+ row: needed(),
803
+ /** The row's key, as the body keys it (C-26). */
804
+ rowKey: needed(),
805
+ /** `data-row-index`: the row's index in `rows`. */
806
+ index: needed(),
807
+ /** `aria-rowindex`, with `virtual` only (C-86). */
808
+ aria: value(),
809
+ pinned: needed(),
810
+ /** `data-row-kind` (C-97); `undefined` for none. */
811
+ kind: value(),
812
+ selected: needed(),
813
+ expanded: needed(),
814
+ /** An expand button is drawn (C-98). */
815
+ expandable: needed(),
816
+ /** The row's flash marks (C-94), or `undefined`. */
817
+ flash: value(),
818
+ cells: needed(),
819
+ utilities: needed(),
820
+ labelPanel: needed(),
821
+ labelExpand: needed(),
822
+ labelSelect: needed(),
823
+ /** `scrollBody`: the ARIA roles of C-102. */
824
+ roles: value(),
825
+ /** The body's slots object: the same object for the body's life (K311-3). */
826
+ slots: needed(),
827
+ /** With `flash`: binds the elapsed time after a render (K311-6). */
828
+ flashBind: value(),
829
+ pinRow: needed()
830
+ },
831
+ emits: [
832
+ "toggle",
833
+ "toggleSelected",
834
+ "rightPanel"
835
+ ],
836
+ setup(props, { emit }) {
837
+ const onPanel = withModifiers(() => emit("rightPanel"), ["stop"]);
838
+ const onToggle = () => emit("toggle");
839
+ const onSelect = () => emit("toggleSelected");
840
+ const bind = (vnode) => {
841
+ props.flashBind?.(vnode.el, props.rowKey);
842
+ };
843
+ let panelCache = null;
844
+ return () => {
845
+ const { row, index, pinned, cells, utilities, flash, slots } = props;
846
+ const cellFlash = flash?.cells;
847
+ return openBlock(), createElementBlock("tr", {
848
+ role: props.roles ? "row" : void 0,
849
+ "data-row-index": index,
850
+ "aria-rowindex": props.aria,
851
+ "data-pinned-row": pinned || void 0,
852
+ "data-row-kind": props.kind,
853
+ "data-expanded": props.expanded ? "" : void 0,
854
+ "data-selected": props.selected ? "" : void 0,
855
+ "data-flash": flash?.row,
856
+ onVnodeBeforeMount: props.flashBind ? bind : void 0,
857
+ onVnodeUpdated: props.flashBind ? bind : void 0
858
+ }, [
859
+ utilities.panel ? (openBlock(), createElementBlock("td", mergeProps({ key: 0 }, utilities.panel), [createElementVNode("button", {
860
+ type: "button",
861
+ class: "qt-right-panel-button",
862
+ "aria-label": props.labelPanel,
863
+ onClick: onPanel
864
+ }, [...panelCache ??= [panelIcon()]], 8, panelDynamic)], 16)) : off(),
865
+ utilities.expand ? (openBlock(), createElementBlock("td", mergeProps({ key: 1 }, utilities.expand), [props.expandable ? (openBlock(), createElementBlock("button", {
866
+ key: 0,
867
+ type: "button",
868
+ class: "qt-expand",
869
+ "aria-expanded": props.expanded,
870
+ "aria-label": props.labelExpand,
871
+ onClick: onToggle
872
+ }, [(openBlock(), createElementBlock("svg", expandIcon, [props.expanded ? (openBlock(), createElementBlock("polyline", chevronDown)) : (openBlock(), createElementBlock("polyline", chevronRight))]))], 8, expandDynamic)) : off()], 16)) : off(),
873
+ utilities.select ? (openBlock(), createElementBlock("td", mergeProps({ key: 2 }, utilities.select), [createElementVNode("input", {
874
+ type: "checkbox",
875
+ class: "qt-select-row",
876
+ "aria-label": props.labelSelect,
877
+ checked: props.selected,
878
+ onChange: onSelect
879
+ }, null, 40, selectDynamic)], 16)) : off(),
880
+ (openBlock(true), createElementBlock(Fragment, null, renderList(cells, (cell) => (openBlock(), createElementBlock(Fragment, { key: cell.field }, [cell.slot ? (openBlock(), createElementBlock("td", mergeProps({ key: 0 }, cell.attrs, { "data-flash": cellFlash?.[cell.field] }), [renderSlot(slots, cell.slot, {
881
+ row,
882
+ rowIndex: index,
883
+ column: cell.column,
884
+ cellValue: valueAt(row, cell.field),
885
+ rowPinned: pinned,
886
+ pinRow: (position) => props.pinRow(row, index, position)
887
+ })], 16)) : (openBlock(), createElementBlock("td", mergeProps({ key: 1 }, cell.attrs, { "data-flash": cellFlash?.[cell.field] }), toDisplayString(cellText(row, cell.column)), 17))], 64))), 128))
888
+ ], 8, rowDynamic);
889
+ };
890
+ }
891
+ });
892
+ //#endregion
893
+ //#region src/pin/pin.ts
894
+ /** Geometry key of a utility cell; a column's key is its `field`. */
895
+ var utilityKey = (utility) => `utility:${utility}`;
896
+ /**
897
+ * Attributes of a pinned cell (C-47, C-71): `data-pinned` (`''` on the left,
898
+ * `'right'` on the right) and, once measured, the `--qt-pin-left` or
899
+ * `--qt-pin-right` offset in pixels, next to an optional `width`. Nothing but
900
+ * the width for a cell that is not pinned; no `style` when both are absent.
901
+ */
902
+ var pinAttrs = (side, offset, width) => {
903
+ const style = {};
904
+ if (width) style.width = width;
905
+ if (side && offset !== void 0) style[side === "left" ? "--qt-pin-left" : "--qt-pin-right"] = `${offset}px`;
906
+ return {
907
+ "data-pinned": side === "left" ? "" : side === "right" ? "right" : void 0,
908
+ style: Object.keys(style).length > 0 ? style : void 0
909
+ };
910
+ };
911
+ //#endregion
912
+ //#region src/parts/table-body.vue?vue&type=script&setup=true&lang.ts
913
+ var _hoisted_1$9 = ["role"];
914
+ var _hoisted_2$5 = ["role"];
915
+ var _hoisted_3$5 = ["role", "aria-rowindex"];
916
+ var _hoisted_4$5 = [
917
+ "colspan",
918
+ "role",
919
+ "aria-colspan"
920
+ ];
921
+ var _hoisted_5$2 = [
780
922
  "role",
781
923
  "aria-rowindex",
782
924
  "data-pinned-row"
783
925
  ];
784
- var _hoisted_15 = ["role"];
785
- var _hoisted_16 = ["role"];
786
- var _hoisted_17 = ["role"];
926
+ var _hoisted_6$2 = ["role"];
927
+ var _hoisted_7$2 = ["role"];
928
+ var _hoisted_8$2 = ["role"];
787
929
  //#endregion
788
930
  //#region src/parts/table-body.vue
789
931
  var table_body_default = /* @__PURE__ */ defineComponent({
@@ -794,6 +936,7 @@ var table_body_default = /* @__PURE__ */ defineComponent({
794
936
  pinRow: { type: Function },
795
937
  loading: { type: Boolean },
796
938
  entries: {},
939
+ slotNames: {},
797
940
  columnCount: {},
798
941
  hasSubtable: { type: Boolean },
799
942
  hasRightPanel: { type: Boolean },
@@ -818,14 +961,17 @@ var table_body_default = /* @__PURE__ */ defineComponent({
818
961
  const props = __props;
819
962
  const emit = __emit;
820
963
  const slots = useSlots();
821
- const { cellText, cellAttrs, hasCellSlot, slotProps, onContextMenu } = useCellView({
822
- slots: useSlots(),
964
+ /**
965
+ * The body's slots object: the same object for the life of the body, whose
966
+ * functions Vue replaces before each render. Every row gets it as a prop and
967
+ * calls the latest `cell-<field>` function when it renders (K311-3).
968
+ */
969
+ const rawSlots = useSlots();
970
+ const { onContextMenu } = useCellView({
823
971
  rows: () => props.rows,
824
972
  entries: () => props.entries,
825
- offsets: () => props.offsets,
826
973
  listening: () => props.hasContextMenuListener(),
827
- onContextMenu: (payload) => emit("cellContextMenu", payload),
828
- pinRow: (row, index, position) => props.pinRow(row, index, position)
974
+ onContextMenu: (payload) => emit("cellContextMenu", payload)
829
975
  });
830
976
  /** `role` of a row and of a cell with `scrollBody` (C-102). */
831
977
  const rowRole = () => props.roles ? "row" : void 0;
@@ -836,13 +982,61 @@ var table_body_default = /* @__PURE__ */ defineComponent({
836
982
  role: cellRole(),
837
983
  "aria-colspan": props.roles ? props.columnCount : void 0
838
984
  });
839
- const utilityAttrs = (utility) => ({
840
- role: cellRole(),
841
- ...pinAttrs(props.hasPinned ? "left" : false, props.offsets[utilityKey(utility)])
985
+ const cells = computed((previous) => {
986
+ const names = new Set(props.slotNames.split("\n"));
987
+ const role = cellRole();
988
+ let same = previous?.length === props.entries.length;
989
+ const next = props.entries.map((entry, i) => {
990
+ const { column } = entry;
991
+ const field = column.field;
992
+ const type = columnTypeOf$1(column);
993
+ const side = sideOf(column);
994
+ const offset = props.offsets[field];
995
+ const slot = names.has(`cell-${field}`) ? `cell-${field}` : null;
996
+ const old = previous?.[i];
997
+ if (old && old.column === column && old.type === type && old.side === side && old.offset === offset && old.slot === slot && old.role === role) return old;
998
+ same = false;
999
+ return {
1000
+ field,
1001
+ column,
1002
+ type,
1003
+ side,
1004
+ offset,
1005
+ role,
1006
+ slot,
1007
+ attrs: {
1008
+ role,
1009
+ "data-field": field,
1010
+ "data-type": type,
1011
+ ...pinAttrs(side, offset)
1012
+ }
1013
+ };
1014
+ });
1015
+ return same && previous ? previous : next;
1016
+ });
1017
+ const utilities = computed((previous) => {
1018
+ const role = cellRole();
1019
+ const side = props.hasPinned ? "left" : false;
1020
+ const offsetOf = (utility) => props.offsets[utilityKey(utility)];
1021
+ const signature = [
1022
+ role,
1023
+ side,
1024
+ props.hasRightPanel && `p${offsetOf("right-panel")}`,
1025
+ props.hasSubtable && `e${offsetOf("subtable")}`,
1026
+ props.hasSelection && `s${offsetOf("select")}`
1027
+ ].join("|");
1028
+ if (previous?.signature === signature) return previous;
1029
+ const attrs = (on, utility) => on ? {
1030
+ role,
1031
+ ...pinAttrs(side, offsetOf(utility))
1032
+ } : null;
1033
+ return {
1034
+ panel: attrs(props.hasRightPanel, "right-panel"),
1035
+ expand: attrs(props.hasSubtable, "subtable"),
1036
+ select: attrs(props.hasSelection, "select"),
1037
+ signature
1038
+ };
842
1039
  });
843
- const rightPanelAttrs = () => utilityAttrs("right-panel");
844
- const expandAttrs = () => utilityAttrs("subtable");
845
- const selectAttrs = () => utilityAttrs("select");
846
1040
  const isSpacer = (item) => "spacer" in item;
847
1041
  const isGroup = (item) => "group" in item;
848
1042
  /** A data row: neither a spacer nor a group row. */
@@ -895,78 +1089,54 @@ var table_body_default = /* @__PURE__ */ defineComponent({
895
1089
  count: item.group.count,
896
1090
  row: item.group.row,
897
1091
  rowIndex: item.group.index
898
- }, () => [createTextVNode(toDisplayString(item.group.key), 1)])], 8, _hoisted_4$5)], 8, _hoisted_3$5)) : (openBlock(), createElementBlock("tr", {
1092
+ }, () => [createTextVNode(toDisplayString(item.group.key), 1)])], 8, _hoisted_4$5)], 8, _hoisted_3$5)) : (openBlock(), createBlock(unref(tableRow), {
899
1093
  key: 2,
900
- role: rowRole(),
901
- "data-row-index": item.index,
902
- "aria-rowindex": item.aria,
903
- "data-pinned-row": item.pinned || void 0,
904
- "data-row-kind": kindOf(item),
905
- "data-expanded": isRowExpanded(item) ? "" : void 0,
906
- "data-selected": __props.hasSelection && __props.isSelected(item.row, item.index) ? "" : void 0,
907
- "data-flash": __props.flash ? __props.flash.row(item.row, item.index) : void 0,
908
- onVnodeBeforeMount: __props.flash ? __props.flash.bind : void 0,
909
- onVnodeUpdated: __props.flash ? __props.flash.bind : void 0
910
- }, [
911
- __props.hasRightPanel ? (openBlock(), createElementBlock("td", mergeProps({
912
- key: 0,
913
- ref_for: true
914
- }, rightPanelAttrs()), [createElementVNode("button", {
915
- type: "button",
916
- class: "qt-right-panel-button",
917
- "aria-label": __props.labels.openRightPanel,
918
- onClick: withModifiers(($event) => emit("rowRightPanelClick", item.row), ["stop"])
919
- }, [..._cache[1] || (_cache[1] = [createElementVNode("svg", {
920
- width: "14",
921
- height: "14",
922
- viewBox: "0 0 24 24",
923
- fill: "none",
924
- stroke: "currentColor",
925
- "stroke-width": "2",
926
- "stroke-linecap": "round",
927
- "aria-hidden": "true"
928
- }, [createElementVNode("line", {
929
- x1: "12",
930
- y1: "5",
931
- x2: "12",
932
- y2: "19"
933
- }), createElementVNode("line", {
934
- x1: "5",
935
- y1: "12",
936
- x2: "19",
937
- y2: "12"
938
- })], -1)])], 8, _hoisted_6$2)], 16)) : createCommentVNode("", true),
939
- __props.hasSubtable ? (openBlock(), createElementBlock("td", mergeProps({
940
- key: 1,
941
- ref_for: true
942
- }, expandAttrs()), [__props.canExpand(item.row, item.index) ? (openBlock(), createElementBlock("button", {
943
- key: 0,
944
- type: "button",
945
- class: "qt-expand",
946
- "aria-expanded": isRowExpanded(item),
947
- "aria-label": __props.labels.expandRow,
948
- onClick: ($event) => __props.toggle(item.row, item.index)
949
- }, [(openBlock(), createElementBlock("svg", _hoisted_8$2, [isRowExpanded(item) ? (openBlock(), createElementBlock("polyline", _hoisted_9$1)) : (openBlock(), createElementBlock("polyline", _hoisted_10))]))], 8, _hoisted_7$2)) : createCommentVNode("", true)], 16)) : createCommentVNode("", true),
950
- __props.hasSelection ? (openBlock(), createElementBlock("td", mergeProps({
951
- key: 2,
952
- ref_for: true
953
- }, selectAttrs()), [createElementVNode("input", {
954
- type: "checkbox",
955
- class: "qt-select-row",
956
- "aria-label": __props.labels.selectRow,
957
- checked: __props.isSelected(item.row, item.index),
958
- onChange: ($event) => __props.toggleSelected(item.row, item.index)
959
- }, null, 40, _hoisted_11)], 16)) : createCommentVNode("", true),
960
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.entries, (entry) => {
961
- return openBlock(), createElementBlock(Fragment, { key: entry.column.field }, [unref(hasCellSlot)(entry.column) ? (openBlock(), createElementBlock("td", mergeProps({
962
- key: 0,
963
- role: cellRole()
964
- }, { ref_for: true }, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), [renderSlot(_ctx.$slots, `cell-${entry.column.field}`, mergeProps({ ref_for: true }, unref(slotProps)(item.row, entry.column, item.index, item.pinned)))], 16, _hoisted_12)) : (openBlock(), createElementBlock("td", mergeProps({
965
- key: 1,
966
- role: cellRole()
967
- }, { ref_for: true }, unref(cellAttrs)(entry), { "data-flash": __props.flash ? __props.flash.cell(item.row, item.index, entry.column.field) : void 0 }), toDisplayString(unref(cellText)(item.row, entry.column)), 17, _hoisted_13))], 64);
968
- }), 128))
969
- ], 8, _hoisted_5$2)), isRow(item) && isRowExpanded(item) ? (openBlock(), createElementBlock("tr", {
1094
+ row: item.row,
1095
+ "row-key": __props.keyOf(item.row, item.index),
1096
+ index: item.index,
1097
+ aria: item.aria,
1098
+ pinned: item.pinned,
1099
+ kind: kindOf(item),
1100
+ selected: __props.hasSelection && __props.isSelected(item.row, item.index),
1101
+ expanded: isRowExpanded(item),
1102
+ expandable: __props.hasSubtable && __props.canExpand(item.row, item.index),
1103
+ flash: __props.flash ? __props.flash.of(__props.keyOf(item.row, item.index)) : void 0,
1104
+ cells: cells.value,
1105
+ utilities: utilities.value,
1106
+ "label-panel": __props.labels.openRightPanel,
1107
+ "label-expand": __props.labels.expandRow,
1108
+ "label-select": __props.labels.selectRow,
1109
+ roles: __props.roles,
1110
+ slots: unref(rawSlots),
1111
+ "flash-bind": __props.flash ? __props.flash.bind : void 0,
1112
+ "pin-row": __props.pinRow,
1113
+ onToggle: ($event) => __props.toggle(item.row, item.index),
1114
+ onToggleSelected: ($event) => __props.toggleSelected(item.row, item.index),
1115
+ onRightPanel: ($event) => emit("rowRightPanelClick", item.row)
1116
+ }, null, 8, [
1117
+ "row",
1118
+ "row-key",
1119
+ "index",
1120
+ "aria",
1121
+ "pinned",
1122
+ "kind",
1123
+ "selected",
1124
+ "expanded",
1125
+ "expandable",
1126
+ "flash",
1127
+ "cells",
1128
+ "utilities",
1129
+ "label-panel",
1130
+ "label-expand",
1131
+ "label-select",
1132
+ "roles",
1133
+ "slots",
1134
+ "flash-bind",
1135
+ "pin-row",
1136
+ "onToggle",
1137
+ "onToggleSelected",
1138
+ "onRightPanel"
1139
+ ])), isRow(item) && isRowExpanded(item) ? (openBlock(), createElementBlock("tr", {
970
1140
  key: 3,
971
1141
  class: "qt-subtable-row",
972
1142
  role: rowRole(),
@@ -975,22 +1145,22 @@ var table_body_default = /* @__PURE__ */ defineComponent({
975
1145
  }, [createElementVNode("td", mergeProps({ ref_for: true }, spanAttrs()), [renderSlot(_ctx.$slots, "subtable", {
976
1146
  row: item.row,
977
1147
  rowIndex: item.index
978
- })], 16)], 8, _hoisted_14)) : createCommentVNode("", true)], 64);
1148
+ })], 16)], 8, _hoisted_5$2)) : createCommentVNode("", true)], 64);
979
1149
  }), 128)),
980
1150
  __props.loading && slots.loading ? (openBlock(), createElementBlock("tr", {
981
1151
  key: 0,
982
1152
  class: "qt-loading-row",
983
1153
  role: rowRole()
984
- }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "loading")], 16)], 8, _hoisted_15)) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", {
1154
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "loading")], 16)], 8, _hoisted_6$2)) : !__props.loading && __props.rows.length === 0 && slots.empty ? (openBlock(), createElementBlock("tr", {
985
1155
  key: 1,
986
1156
  class: "qt-empty-row",
987
1157
  role: rowRole()
988
- }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "empty")], 16)], 8, _hoisted_16)) : createCommentVNode("", true),
1158
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "empty")], 16)], 8, _hoisted_7$2)) : createCommentVNode("", true),
989
1159
  !__props.loading && __props.rows.length > 0 && __props.loadMore && slots["load-more"] ? (openBlock(), createElementBlock("tr", {
990
1160
  key: 2,
991
1161
  class: "qt-load-more-row",
992
1162
  role: rowRole()
993
- }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 16)], 8, _hoisted_17)) : createCommentVNode("", true)
1163
+ }, [createElementVNode("td", normalizeProps(guardReactiveProps(spanAttrs())), [renderSlot(_ctx.$slots, "load-more", normalizeProps(guardReactiveProps(__props.loadMore)))], 16)], 8, _hoisted_8$2)) : createCommentVNode("", true)
994
1164
  ], 40, _hoisted_1$9);
995
1165
  };
996
1166
  }
@@ -1261,12 +1431,19 @@ var reorder_handle_default = /* @__PURE__ */ defineComponent({
1261
1431
  * load-more). A subtable or a spanning cell would otherwise widen the
1262
1432
  * columns it spans with content that is not theirs.
1263
1433
  */
1264
- var notCounted = [
1265
- ":scope > thead > tr > th[data-field] > .qt-filter",
1434
+ var notCountedParts = [
1266
1435
  ":scope > thead > tr > th[data-field] > .qt-resize-handle",
1267
1436
  ":scope > tbody > tr:not([data-row-index])",
1268
1437
  ":scope > tfoot"
1269
- ].join(", ");
1438
+ ];
1439
+ var filterRow = ":scope > thead > tr > th[data-field] > .qt-filter";
1440
+ var notCounted = [filterRow, ...notCountedParts].join(", ");
1441
+ var notCountedWithFilters = notCountedParts.join(", ");
1442
+ /**
1443
+ * The room a text, number or date filter input keeps for its text when the
1444
+ * filter row counts (C-100): six characters of the input's own font.
1445
+ */
1446
+ var filterText = "6ch";
1270
1447
  /**
1271
1448
  * Sets inline declarations for one read and puts every `style` attribute
1272
1449
  * back exactly as it was, absent included, so the markup after the call is
@@ -1302,7 +1479,7 @@ var styleSwap = () => {
1302
1479
  * (C-101): it is laid out the same way, its `col` widths left out, and a
1303
1480
  * column takes the wider of its header cell and its body cells.
1304
1481
  */
1305
- var measureColumnWidths = (table, fields, body) => {
1482
+ var measureColumnWidths = (table, fields, body, options = {}) => {
1306
1483
  const widths = {};
1307
1484
  if (!table?.tHead) return widths;
1308
1485
  const wanted = fields ? new Set(fields) : null;
@@ -1313,7 +1490,8 @@ var measureColumnWidths = (table, fields, body) => {
1313
1490
  swap.set(table, "width", "max-content");
1314
1491
  swap.set(table, "min-width", "0");
1315
1492
  for (const th of headers) swap.set(th, "width", "auto");
1316
- for (const part of Array.from(table.querySelectorAll(notCounted))) swap.set(part, "display", "none");
1493
+ for (const part of Array.from(table.querySelectorAll(options.filters ? notCountedWithFilters : notCounted))) swap.set(part, "display", "none");
1494
+ if (options.filters) countFilters(table, swap);
1317
1495
  const split = body && body !== table ? body : null;
1318
1496
  if (split) {
1319
1497
  swap.set(split, "table-layout", "auto");
@@ -1323,18 +1501,109 @@ var measureColumnWidths = (table, fields, body) => {
1323
1501
  for (const part of Array.from(split.querySelectorAll(":scope > tbody > tr:not([data-row-index])"))) swap.set(part, "display", "none");
1324
1502
  }
1325
1503
  const firstRow = split?.querySelector(":scope > tbody > tr[data-row-index]");
1504
+ const measured = [];
1326
1505
  for (const th of headers) {
1327
1506
  const field = th.dataset.field;
1328
1507
  if (field === void 0 || wanted && !wanted.has(field)) continue;
1508
+ const own = th.getBoundingClientRect().width;
1509
+ if (own === 0) continue;
1329
1510
  const cell = firstRow?.querySelector(`:scope > td[data-field="${CSS.escape(field)}"]`);
1330
- const width = Math.max(th.getBoundingClientRect().width, cell?.getBoundingClientRect().width ?? 0);
1331
- if (width > 0) widths[field] = Math.ceil(width);
1511
+ measured.push([
1512
+ field,
1513
+ th,
1514
+ Math.max(own, cell?.getBoundingClientRect().width ?? 0)
1515
+ ]);
1332
1516
  }
1517
+ const floors = options.filters ? filterFloors(measured.map(([, th]) => th), swap) : null;
1518
+ for (const [field, th, width] of measured) widths[field] = Math.ceil(Math.max(width, floors?.get(th) ?? 0));
1333
1519
  } finally {
1334
1520
  swap.restore();
1335
1521
  }
1336
1522
  return widths;
1337
1523
  };
1524
+ /**
1525
+ * Takes the filter rows out of the read (C-100): out of the cell's flow
1526
+ * (`position: absolute`), so nothing in them widens the column by being
1527
+ * there, and no size container, which would switch the row to its narrow
1528
+ * form. Each control of the table stops growing and shrinking: a text or
1529
+ * number input six characters wide (padding and border on top), a select
1530
+ * and a date or time input as wide as they draw themselves, a filter button
1531
+ * at its own width, back in the row's flow when a skin's narrow form laid it
1532
+ * `absolute` over the input. A control `fixed` over the page (a panel)
1533
+ * stays out.
1534
+ */
1535
+ var countFilters = (table, swap) => {
1536
+ const rows = Array.from(table.querySelectorAll(filterRow));
1537
+ for (const row of rows) {
1538
+ swap.set(row, "position", "absolute");
1539
+ swap.set(row, "container-type", "normal");
1540
+ swap.set(row, "contain", "none");
1541
+ swap.set(row, "box-sizing", "content-box");
1542
+ for (const input of Array.from(row.querySelectorAll(":scope > .qt-filter-input"))) {
1543
+ swap.set(input, "flex", "none");
1544
+ swap.set(input, "min-width", "0");
1545
+ if (input instanceof HTMLInputElement && textTypes.has(input.type)) {
1546
+ swap.set(input, "box-sizing", "content-box");
1547
+ swap.set(input, "width", filterText);
1548
+ } else swap.set(input, "width", "auto");
1549
+ }
1550
+ for (const button of Array.from(row.querySelectorAll(":scope > .qt-filter-button"))) swap.set(button, "flex", "none");
1551
+ }
1552
+ for (const row of rows) for (const button of Array.from(row.querySelectorAll(":scope > .qt-filter-button"))) if (getComputedStyle(button).position === "absolute") swap.set(button, "position", "static");
1553
+ };
1554
+ /** The inputs that keep six characters of text; the others draw their own. */
1555
+ var textTypes = /* @__PURE__ */ new Set([
1556
+ "text",
1557
+ "number",
1558
+ "search"
1559
+ ]);
1560
+ var horizontal = (style) => (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0) + (parseFloat(style.borderLeftWidth) || 0) + (parseFloat(style.borderRightWidth) || 0);
1561
+ /** The table's own filter controls, the row's children, that take room. */
1562
+ var controlsOf = (row) => Array.from(row.querySelectorAll(":scope > :is(.qt-filter-input, .qt-filter-button)")).filter((control) => {
1563
+ const { position } = getComputedStyle(control);
1564
+ return position !== "fixed" && position !== "absolute";
1565
+ });
1566
+ /** The row's content width the probes draw it at: `0` and this. */
1567
+ var probe = 1e3;
1568
+ /**
1569
+ * The width each header cell needs for its filter controls, from the
1570
+ * controls alone: the row's width is never read, so slot content in it
1571
+ * cannot count, by its own width or by a width it took from the column. The
1572
+ * controls are drawn side by side in rows `0` and `probe` pixels wide, and
1573
+ * each width (a control, the gap) is taken as a fixed part plus a share of
1574
+ * the row, which is what a percentage padding is. The row then needs `R`
1575
+ * with `R = fixed + share * R`, the cell `R` plus the row's and the cell's
1576
+ * padding and border.
1577
+ */
1578
+ var filterFloors = (headers, swap) => {
1579
+ const rows = headers.flatMap((th) => {
1580
+ const row = th.querySelector(":scope > .qt-filter");
1581
+ const controls = row ? controlsOf(row) : [];
1582
+ return row && controls.length > 0 ? [{
1583
+ th,
1584
+ row,
1585
+ controls
1586
+ }] : [];
1587
+ });
1588
+ const read = (width) => {
1589
+ for (const { row } of rows) swap.set(row, "width", `${width}px`);
1590
+ return rows.map(({ row, controls }) => {
1591
+ const drawn = controls.map((control) => control.getBoundingClientRect().width).filter((each) => each > 0);
1592
+ const gap = parseFloat(getComputedStyle(row).columnGap) || 0;
1593
+ return drawn.length === 0 ? 0 : drawn.reduce((sum, each) => sum + each, 0) + gap * (drawn.length - 1);
1594
+ });
1595
+ };
1596
+ const atZero = read(0);
1597
+ const atProbe = read(probe);
1598
+ const floors = /* @__PURE__ */ new Map();
1599
+ rows.forEach(({ th, row }, index) => {
1600
+ const fixed = atZero[index];
1601
+ if (fixed === 0) return;
1602
+ const share = Math.min(.9, Math.max(0, (atProbe[index] - fixed) / probe));
1603
+ floors.set(th, fixed / (1 - share) + horizontal(getComputedStyle(row)) + horizontal(getComputedStyle(th)));
1604
+ });
1605
+ return floors;
1606
+ };
1338
1607
  //#endregion
1339
1608
  //#region src/resize/width-scale.ts
1340
1609
  var same = (width) => width;
@@ -1523,7 +1792,7 @@ var useColumnResize = (options) => {
1523
1792
  const scale = scaleOf(th, column);
1524
1793
  const from = scale.declared(drawn);
1525
1794
  const step = scale.declared(Math.round(drawn) + sign * (event.shiftKey ? 50 : 10));
1526
- const to = sign ? from + sign * Math.max(1, Math.abs(step - from)) : measureColumnWidths(th.closest("table"), [column.field], options.body())[column.field];
1795
+ const to = sign ? from + sign * Math.max(1, Math.abs(step - from)) : measureColumnWidths(th.closest("table"), [column.field], options.body(), { filters: true })[column.field];
1527
1796
  if (to !== void 0) commit(column, from, to);
1528
1797
  }
1529
1798
  };
@@ -1707,7 +1976,7 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1707
1976
  },
1708
1977
  setup(__props) {
1709
1978
  const props = __props;
1710
- const given = (name) => props.slotNames.split(" ").includes(name);
1979
+ const given = (name) => props.slotNames.split("\n").includes(name);
1711
1980
  const { filters, sort, layout, resize, reorder, selection, labels } = useTableContext();
1712
1981
  const dragAttrs = (column) => {
1713
1982
  const drag = reorder.dragging.value;
@@ -2165,7 +2434,7 @@ var useAutoWidth = (options) => {
2165
2434
  result = cloneQuery(query);
2166
2435
  }
2167
2436
  if (options.rows().length === 0) return;
2168
- const measured = measureColumnWidths(table, columns.map((column) => column.field), options.body());
2437
+ const measured = measureColumnWidths(table, columns.map((column) => column.field), options.body(), { filters: true });
2169
2438
  if (Object.keys(measured).length === 0) {
2170
2439
  waiting = true;
2171
2440
  return;
@@ -3884,7 +4153,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3884
4153
  }
3885
4154
  });
3886
4155
  const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading" || name === "load-more" || name === "group");
3887
- const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join(" ");
4156
+ const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join("\n");
4157
+ const cellSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-")).sort().join("\n");
3888
4158
  __expose({
3889
4159
  collapseAll: expansion.collapseAll,
3890
4160
  expandAll: expansion.expandAll,
@@ -3968,6 +4238,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3968
4238
  "pin-row": unref(state).rowPinning.pin,
3969
4239
  loading: __props.loading,
3970
4240
  entries: unref(entries),
4241
+ "slot-names": cellSlotNames(),
3971
4242
  "column-count": columnCount.value,
3972
4243
  "has-subtable": __props.hasSubtable,
3973
4244
  "has-right-panel": __props.hasRightPanel,
@@ -4001,6 +4272,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4001
4272
  "pin-row",
4002
4273
  "loading",
4003
4274
  "entries",
4275
+ "slot-names",
4004
4276
  "column-count",
4005
4277
  "has-subtable",
4006
4278
  "has-right-panel",
@@ -4085,6 +4357,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4085
4357
  "pin-row": unref(state).rowPinning.pin,
4086
4358
  loading: __props.loading,
4087
4359
  entries: unref(entries),
4360
+ "slot-names": cellSlotNames(),
4088
4361
  "column-count": columnCount.value,
4089
4362
  "has-subtable": __props.hasSubtable,
4090
4363
  "has-right-panel": __props.hasRightPanel,
@@ -4117,6 +4390,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4117
4390
  "pin-row",
4118
4391
  "loading",
4119
4392
  "entries",
4393
+ "slot-names",
4120
4394
  "column-count",
4121
4395
  "has-subtable",
4122
4396
  "has-right-panel",