@dolusoft/query-table 3.10.0 → 3.11.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.
@@ -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
  }
@@ -1806,7 +1976,7 @@ var table_header_default = /* @__PURE__ */ defineComponent({
1806
1976
  },
1807
1977
  setup(__props) {
1808
1978
  const props = __props;
1809
- const given = (name) => props.slotNames.split(" ").includes(name);
1979
+ const given = (name) => props.slotNames.split("\n").includes(name);
1810
1980
  const { filters, sort, layout, resize, reorder, selection, labels } = useTableContext();
1811
1981
  const dragAttrs = (column) => {
1812
1982
  const drag = reorder.dragging.value;
@@ -2326,6 +2496,7 @@ var isDevelopment$1 = () => {
2326
2496
  return true;
2327
2497
  }
2328
2498
  };
2499
+ var automaticLayout = "[QueryTable] `scrollBody`: the body table has the automatic layout, so its columns follow its rows, not the header. Give the body and footer tables `table-layout: fixed` and a width that is a length or a percentage, such as `width: 100%`: with `width: auto` or `max-content` the browser uses the automatic layout whatever `table-layout` says (C-101).";
2329
2500
  /**
2330
2501
  * Header, body and footer of `scrollBody` scroll sideways together (C-101):
2331
2502
  * one passive `scroll` listener on each wrapper sets the `scrollLeft` of the
@@ -2374,12 +2545,43 @@ var useScrollBody = (options) => {
2374
2545
  const table = options.bodyTable();
2375
2546
  if (table && !warned && isDevelopment$1() && getComputedStyle(table).tableLayout !== "fixed") {
2376
2547
  warned = true;
2377
- console.warn("[QueryTable] `scrollBody` with `table-layout: auto` on the body table: its columns follow its rows, not the header. Set `table-layout: fixed` (C-101).");
2548
+ console.warn(automaticLayout);
2378
2549
  }
2379
2550
  }, {
2380
2551
  flush: "post",
2381
2552
  immediate: true
2382
2553
  });
2554
+ /**
2555
+ * `table-layout: fixed` applies only to a table with a definite width:
2556
+ * under `width: auto` or `max-content` the browser lays the body out
2557
+ * automatically while `tableLayout` still reads `fixed`, and a cell wider
2558
+ * than its `col` widens its column and the table. That shows once the
2559
+ * rows hold such a cell, so it is checked whenever the rows or the `col`
2560
+ * widths change, against `col` widths that match the header cells (not
2561
+ * ones a change of the drawn columns has made stale until measured).
2562
+ */
2563
+ const checkLayout = () => {
2564
+ const head = options.headTable();
2565
+ const body = options.bodyTable();
2566
+ if (warned || !head || !body) return;
2567
+ const cells = head.querySelectorAll(":scope > thead > tr > *");
2568
+ const widths = options.colWidths();
2569
+ if (cells.length === 0 || cells.length !== widths.length || [...cells].some((cell, i) => {
2570
+ const width = widths[i];
2571
+ return width === void 0 || Math.abs(cell.getBoundingClientRect().width - width) >= .5;
2572
+ })) return;
2573
+ if (body.getBoundingClientRect().width - head.getBoundingClientRect().width >= 1) {
2574
+ warned = true;
2575
+ console.warn(automaticLayout);
2576
+ }
2577
+ };
2578
+ if (isDevelopment$1()) watch(() => options.enabled() ? [
2579
+ options.colWidths(),
2580
+ options.rows(),
2581
+ options.bodyTable()
2582
+ ] : null, (sources) => {
2583
+ if (sources) checkLayout();
2584
+ }, { flush: "post" });
2383
2585
  onBeforeUnmount(detach);
2384
2586
  };
2385
2587
  //#endregion
@@ -3881,7 +4083,10 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3881
4083
  body: bodyWrap.value,
3882
4084
  foot: footWrap.value
3883
4085
  }),
3884
- bodyTable: () => bodyTableEl.value
4086
+ headTable: () => tableEl.value,
4087
+ bodyTable: () => bodyTableEl.value,
4088
+ colWidths: () => colWidths.value,
4089
+ rows: () => props.rows
3885
4090
  });
3886
4091
  const resize = useColumnResize({
3887
4092
  resizable: () => props.resizable,
@@ -3983,7 +4188,8 @@ var query_table_default = /* @__PURE__ */ defineComponent({
3983
4188
  }
3984
4189
  });
3985
4190
  const bodySlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-") || name === "subtable" || name === "empty" || name === "loading" || name === "load-more" || name === "group");
3986
- const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join(" ");
4191
+ const headerSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("header-") || name === "filter-datetime" || name === "filter-menu").sort().join("\n");
4192
+ const cellSlotNames = () => Object.keys(rawSlots).filter((name) => name.startsWith("cell-")).sort().join("\n");
3987
4193
  __expose({
3988
4194
  collapseAll: expansion.collapseAll,
3989
4195
  expandAll: expansion.expandAll,
@@ -4067,6 +4273,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4067
4273
  "pin-row": unref(state).rowPinning.pin,
4068
4274
  loading: __props.loading,
4069
4275
  entries: unref(entries),
4276
+ "slot-names": cellSlotNames(),
4070
4277
  "column-count": columnCount.value,
4071
4278
  "has-subtable": __props.hasSubtable,
4072
4279
  "has-right-panel": __props.hasRightPanel,
@@ -4100,6 +4307,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4100
4307
  "pin-row",
4101
4308
  "loading",
4102
4309
  "entries",
4310
+ "slot-names",
4103
4311
  "column-count",
4104
4312
  "has-subtable",
4105
4313
  "has-right-panel",
@@ -4184,6 +4392,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4184
4392
  "pin-row": unref(state).rowPinning.pin,
4185
4393
  loading: __props.loading,
4186
4394
  entries: unref(entries),
4395
+ "slot-names": cellSlotNames(),
4187
4396
  "column-count": columnCount.value,
4188
4397
  "has-subtable": __props.hasSubtable,
4189
4398
  "has-right-panel": __props.hasRightPanel,
@@ -4216,6 +4425,7 @@ var query_table_default = /* @__PURE__ */ defineComponent({
4216
4425
  "pin-row",
4217
4426
  "loading",
4218
4427
  "entries",
4428
+ "slot-names",
4219
4429
  "column-count",
4220
4430
  "has-subtable",
4221
4431
  "has-right-panel",