twico-ui 1.18.1 → 1.19.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.
package/dist/index.mjs CHANGED
@@ -7875,11 +7875,15 @@ function Tooltip({
7875
7875
  placement = "top",
7876
7876
  delay = 120,
7877
7877
  className = "",
7878
+ open: openProp,
7879
+ anchor,
7878
7880
  ...rest
7879
7881
  }) {
7880
7882
  const __twcStyles = useScopedStyles("twc-tooltip-styles", TOOLTIP_CSS);
7883
+ const anchored = anchor !== void 0;
7881
7884
  const id = React51__default.useId();
7882
- const [show, setShow] = React51__default.useState(false);
7885
+ const [showU, setShowU] = React51__default.useState(false);
7886
+ const show = anchored ? !!openProp : showU;
7883
7887
  const [coords, setCoords] = React51__default.useState(null);
7884
7888
  const timer = React51__default.useRef(null);
7885
7889
  const closeTimer = React51__default.useRef(null);
@@ -7888,12 +7892,12 @@ function Tooltip({
7888
7892
  const open = () => {
7889
7893
  clearTimeout(closeTimer.current);
7890
7894
  clearTimeout(timer.current);
7891
- timer.current = setTimeout(() => setShow(true), delay);
7895
+ timer.current = setTimeout(() => setShowU(true), delay);
7892
7896
  };
7893
7897
  const close = () => {
7894
7898
  clearTimeout(timer.current);
7895
7899
  clearTimeout(closeTimer.current);
7896
- closeTimer.current = setTimeout(() => setShow(false), 120);
7900
+ closeTimer.current = setTimeout(() => setShowU(false), 120);
7897
7901
  };
7898
7902
  const cancelClose = () => {
7899
7903
  clearTimeout(closeTimer.current);
@@ -7903,8 +7907,8 @@ function Tooltip({
7903
7907
  clearTimeout(closeTimer.current);
7904
7908
  }, []);
7905
7909
  const place = React51__default.useCallback(() => {
7906
- const el = wrapRef.current;
7907
- if (!el) return;
7910
+ const el = anchored ? anchor : wrapRef.current;
7911
+ if (!el || !el.getBoundingClientRect) return;
7908
7912
  const r2 = el.getBoundingClientRect();
7909
7913
  const cx = Math.round(r2.left + r2.width / 2), cy = Math.round(r2.top + r2.height / 2);
7910
7914
  const vw = window.innerWidth, vh = window.innerHeight, gap = 8, margin = 8;
@@ -7936,7 +7940,7 @@ function Tooltip({
7936
7940
  const c = clampX(cx);
7937
7941
  setCoords({ ...base, left: c, bottom: Math.round(vh - r2.top + gap), arrowX: arrowX(c) });
7938
7942
  }
7939
- }, [placement]);
7943
+ }, [placement, anchored, anchor]);
7940
7944
  React51__default.useEffect(() => {
7941
7945
  place();
7942
7946
  }, [place]);
@@ -7952,16 +7956,50 @@ function Tooltip({
7952
7956
  };
7953
7957
  }, [show, place]);
7954
7958
  React51__default.useEffect(() => {
7955
- if (!show) return;
7959
+ if (!show || anchored) return;
7956
7960
  const onKeyDown = (e) => {
7957
7961
  if (e.key === "Escape") {
7958
7962
  clearTimeout(timer.current);
7959
- setShow(false);
7963
+ setShowU(false);
7960
7964
  }
7961
7965
  };
7962
7966
  document.addEventListener("keydown", onKeyDown);
7963
7967
  return () => document.removeEventListener("keydown", onKeyDown);
7964
- }, [show]);
7968
+ }, [show, anchored]);
7969
+ const bubble = coords && (!anchored || anchor) ? createPortal(
7970
+ /* @__PURE__ */ jsxs(
7971
+ "span",
7972
+ {
7973
+ ref: tipRef,
7974
+ id,
7975
+ className: "twc-tooltip",
7976
+ "data-place": coords.place || placement,
7977
+ "data-show": show || void 0,
7978
+ role: "tooltip",
7979
+ "aria-hidden": show ? void 0 : "true",
7980
+ onMouseEnter: anchored ? void 0 : cancelClose,
7981
+ onMouseLeave: anchored ? void 0 : close,
7982
+ style: {
7983
+ position: "fixed",
7984
+ left: coords.left,
7985
+ right: coords.right,
7986
+ top: coords.top,
7987
+ bottom: coords.bottom,
7988
+ "--_tw-arrow-x": coords.arrowX != null ? `${coords.arrowX}px` : void 0,
7989
+ "--_tw-arrow-y": coords.arrowY != null ? `${coords.arrowY}px` : void 0
7990
+ },
7991
+ children: [
7992
+ label,
7993
+ /* @__PURE__ */ jsx("span", { className: "twc-tooltip__arrow", "aria-hidden": "true" })
7994
+ ]
7995
+ }
7996
+ ),
7997
+ document.body
7998
+ ) : null;
7999
+ if (anchored) return /* @__PURE__ */ jsxs(Fragment, { children: [
8000
+ __twcStyles,
8001
+ bubble
8002
+ ] });
7965
8003
  const describedBy = show ? id : void 0;
7966
8004
  const trigger = React51__default.isValidElement(children) && children.type !== React51__default.Fragment ? React51__default.cloneElement(children, {
7967
8005
  "aria-describedby": [children.props["aria-describedby"], describedBy].filter(Boolean).join(" ") || void 0
@@ -7979,36 +8017,7 @@ function Tooltip({
7979
8017
  children: [
7980
8018
  __twcStyles,
7981
8019
  trigger,
7982
- coords ? createPortal(
7983
- /* @__PURE__ */ jsxs(
7984
- "span",
7985
- {
7986
- ref: tipRef,
7987
- id,
7988
- className: "twc-tooltip",
7989
- "data-place": coords.place || placement,
7990
- "data-show": show || void 0,
7991
- role: "tooltip",
7992
- "aria-hidden": show ? void 0 : "true",
7993
- onMouseEnter: cancelClose,
7994
- onMouseLeave: close,
7995
- style: {
7996
- position: "fixed",
7997
- left: coords.left,
7998
- right: coords.right,
7999
- top: coords.top,
8000
- bottom: coords.bottom,
8001
- "--_tw-arrow-x": coords.arrowX != null ? `${coords.arrowX}px` : void 0,
8002
- "--_tw-arrow-y": coords.arrowY != null ? `${coords.arrowY}px` : void 0
8003
- },
8004
- children: [
8005
- label,
8006
- /* @__PURE__ */ jsx("span", { className: "twc-tooltip__arrow", "aria-hidden": "true" })
8007
- ]
8008
- }
8009
- ),
8010
- document.body
8011
- ) : null
8020
+ bubble
8012
8021
  ]
8013
8022
  }
8014
8023
  );
@@ -8325,8 +8334,8 @@ var DT_CSS = `
8325
8334
  .twc-dt__row[data-pinned-row="top"] > .twc-dt__td { border-bottom: var(--border-medium) solid var(--color-primary-border); box-shadow: 0 1px 0 var(--color-primary-border); }
8326
8335
  .twc-dt__row[data-pinned-row="bottom"] > .twc-dt__td { border-top: var(--border-medium) solid var(--color-primary-border); }
8327
8336
 
8328
- /* Row reordering */
8329
- .twc-dt__row[data-reorderable] { cursor: grab; }
8337
+ /* Row reordering \u2014 the grab affordance lives on the drag handle only (#263), not the whole row, so
8338
+ hovering a normal data cell isn't presented as draggable (the row stays a drag source for the mouse). */
8330
8339
  .twc-dt__row[data-row-dragging] { opacity: 0.4; }
8331
8340
  /* #239 diff mode: row op tint + before\u2192after cells (single-line, clipped by the td's own overflow). */
8332
8341
  .twc-dt__row[data-op="added"] > .twc-dt__td { background: color-mix(in srgb, var(--color-success) 7%, transparent); }
@@ -8357,6 +8366,7 @@ var DT_CSS = `
8357
8366
  .twc-dt__row:hover .twc-dt__row-handle, .twc-dt__row-handle:focus-visible { opacity: 0.7; }
8358
8367
  .twc-dt__row-handle:focus-visible { outline: none; box-shadow: var(--ring); color: var(--color-primary); }
8359
8368
  .twc-dt__row-handle[data-grabbed="true"] { opacity: 1; color: var(--color-primary); }
8369
+ .twc-dt__row-handle:active, .twc-dt__row-handle[data-grabbed="true"] { cursor: grabbing; }
8360
8370
  .twc-dt__row-handle svg { width: 14px; height: 14px; }
8361
8371
  /* Visually-hidden aria-live region for reorder announcements */
8362
8372
  .twc-dt__sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@@ -9242,6 +9252,40 @@ function Datatable({
9242
9252
  const scrollRef = React51__default.useRef(null);
9243
9253
  const [scrollTop, setScrollTop] = React51__default.useState(0);
9244
9254
  const [viewportH, setViewportH] = React51__default.useState(0);
9255
+ const [ovTip, setOvTip] = React51__default.useState(null);
9256
+ const ovTimer = React51__default.useRef(null);
9257
+ const hideOverflowTip = () => {
9258
+ clearTimeout(ovTimer.current);
9259
+ setOvTip((t) => t ? null : t);
9260
+ };
9261
+ const onOverflowOver = (e) => {
9262
+ const el = e.target.closest?.("[data-ovtext]");
9263
+ if (!el) return;
9264
+ if (ovTip && ovTip.anchor === el) return;
9265
+ clearTimeout(ovTimer.current);
9266
+ if (el.scrollWidth > el.clientWidth + 1) {
9267
+ const text = el.getAttribute("data-ovtext");
9268
+ ovTimer.current = setTimeout(() => setOvTip({ anchor: el, text }), 120);
9269
+ } else if (ovTip) setOvTip(null);
9270
+ };
9271
+ const onOverflowOut = (e) => {
9272
+ const el = e.target.closest?.("[data-ovtext]");
9273
+ if (el && !el.contains(e.relatedTarget)) hideOverflowTip();
9274
+ };
9275
+ const onOverflowFocus = (e) => {
9276
+ const el = e.target.closest?.("[data-ovtext]");
9277
+ if (el && el.scrollWidth > el.clientWidth + 1) setOvTip({ anchor: el, text: el.getAttribute("data-ovtext") });
9278
+ else hideOverflowTip();
9279
+ };
9280
+ React51__default.useEffect(() => () => clearTimeout(ovTimer.current), []);
9281
+ React51__default.useEffect(() => {
9282
+ if (!ovTip) return void 0;
9283
+ const onKey = (e) => {
9284
+ if (e.key === "Escape") setOvTip(null);
9285
+ };
9286
+ document.addEventListener("keydown", onKey);
9287
+ return () => document.removeEventListener("keydown", onKey);
9288
+ }, [ovTip]);
9245
9289
  const [pivotOn, setPivotOn] = React51__default.useState(pivotMode);
9246
9290
  const [aggConfig, setAggConfig] = React51__default.useState(() => {
9247
9291
  const m = {};
@@ -10407,7 +10451,7 @@ function Datatable({
10407
10451
  "data-pin": st.pin,
10408
10452
  "data-pin-edge": st.edge,
10409
10453
  style: { width: widthOf(c), ...st.style },
10410
- title: cellTitle,
10454
+ "data-ovtext": cellTitle,
10411
10455
  onClick: selectionMode === "cell" ? (e) => handleCellClick(e, k, row, c) : void 0,
10412
10456
  onFocus: () => setFocus((f) => f.r === ri && f.c === ci ? f : { r: ri, c: ci }),
10413
10457
  onDoubleClick: editable ? () => beginEdit(k, c, row) : void 0,
@@ -10748,233 +10792,247 @@ function Datatable({
10748
10792
  /* @__PURE__ */ jsx("button", { type: "button", className: "twc-dt__groupbar-clear", onClick: () => setGroupBy([]), children: "Clear all" })
10749
10793
  ] }) : null,
10750
10794
  /* @__PURE__ */ jsx("div", { className: "twc-dt__sr", role: "status", "aria-live": "polite", children: reorderMsg }),
10751
- pivotActive ? renderPivot() : /* @__PURE__ */ jsx("div", { className: "twc-dt__scroll", style: { maxHeight: height }, ref: scrollRef, onScroll: virtualizing ? onScrollVirtual : void 0, children: /* @__PURE__ */ jsxs(
10752
- "table",
10795
+ pivotActive ? renderPivot() : /* @__PURE__ */ jsx(
10796
+ "div",
10753
10797
  {
10754
- className: "twc-dt__table",
10755
- style: { width: tableMinWidth, minWidth: "100%" },
10756
- ref: gridRef,
10757
- role: "grid",
10758
- "aria-label": ariaLabelAttr || ariaLabel,
10759
- "aria-rowcount": totalRows + 1,
10760
- "aria-colcount": ordered.length + (checkboxSelection ? 1 : 0),
10761
- "aria-busy": loading || void 0,
10762
- onKeyDown: onGridKeyDown,
10763
- children: [
10764
- /* @__PURE__ */ jsx("thead", { ref: theadRef, children: /* @__PURE__ */ jsxs("tr", { role: "row", "aria-rowindex": 1, children: [
10765
- checkboxSelection ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th", role: "columnheader", "aria-label": "Select", "data-pin": "left", "data-pin-edge": pins.left.length || showRowNum ? void 0 : "left", style: { insetInlineStart: 0, width: CHK_W, minWidth: CHK_W }, children: /* @__PURE__ */ jsx("div", { className: "twc-dt__th-inner", style: { justifyContent: "center", padding: 0 }, children: /* @__PURE__ */ jsx(
10766
- "span",
10767
- {
10768
- className: "twc-dt__check",
10769
- "data-checked": allSel || void 0,
10770
- "data-indeterminate": !allSel && someSel || void 0,
10771
- onClick: toggleAll,
10772
- role: "checkbox",
10773
- "aria-checked": allSel ? true : someSel ? "mixed" : false,
10774
- "aria-label": "Select all rows",
10775
- tabIndex: 0,
10776
- onKeyDown: (e) => {
10777
- if (e.key === " " || e.key === "Enter") {
10778
- e.preventDefault();
10779
- toggleAll();
10798
+ className: "twc-dt__scroll",
10799
+ style: { maxHeight: height },
10800
+ ref: scrollRef,
10801
+ onScroll: virtualizing ? onScrollVirtual : void 0,
10802
+ onMouseOver: onOverflowOver,
10803
+ onMouseOut: onOverflowOut,
10804
+ onFocus: onOverflowFocus,
10805
+ onBlur: hideOverflowTip,
10806
+ children: /* @__PURE__ */ jsxs(
10807
+ "table",
10808
+ {
10809
+ className: "twc-dt__table",
10810
+ style: { width: tableMinWidth, minWidth: "100%" },
10811
+ ref: gridRef,
10812
+ role: "grid",
10813
+ "aria-label": ariaLabelAttr || ariaLabel,
10814
+ "aria-rowcount": totalRows + 1,
10815
+ "aria-colcount": ordered.length + (checkboxSelection ? 1 : 0),
10816
+ "aria-busy": loading || void 0,
10817
+ onKeyDown: onGridKeyDown,
10818
+ children: [
10819
+ /* @__PURE__ */ jsx("thead", { ref: theadRef, children: /* @__PURE__ */ jsxs("tr", { role: "row", "aria-rowindex": 1, children: [
10820
+ checkboxSelection ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th", role: "columnheader", "aria-label": "Select", "data-pin": "left", "data-pin-edge": pins.left.length || showRowNum ? void 0 : "left", style: { insetInlineStart: 0, width: CHK_W, minWidth: CHK_W }, children: /* @__PURE__ */ jsx("div", { className: "twc-dt__th-inner", style: { justifyContent: "center", padding: 0 }, children: /* @__PURE__ */ jsx(
10821
+ "span",
10822
+ {
10823
+ className: "twc-dt__check",
10824
+ "data-checked": allSel || void 0,
10825
+ "data-indeterminate": !allSel && someSel || void 0,
10826
+ onClick: toggleAll,
10827
+ role: "checkbox",
10828
+ "aria-checked": allSel ? true : someSel ? "mixed" : false,
10829
+ "aria-label": "Select all rows",
10830
+ tabIndex: 0,
10831
+ onKeyDown: (e) => {
10832
+ if (e.key === " " || e.key === "Enter") {
10833
+ e.preventDefault();
10834
+ toggleAll();
10835
+ }
10836
+ },
10837
+ children: /* @__PURE__ */ jsx(Svg, { d: allSel ? I.check : I.minus })
10780
10838
  }
10781
- },
10782
- children: /* @__PURE__ */ jsx(Svg, { d: allSel ? I.check : I.minus })
10783
- }
10784
- ) }) }) : null,
10785
- showRowNum ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th twc-dt__rownum", role: "columnheader", "aria-label": "Row number", "data-pin": "left", "data-pin-edge": pins.left.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W, minWidth: NUM_W }, children: /* @__PURE__ */ jsxs("div", { className: "twc-dt__th-inner", children: [
10786
- /* @__PURE__ */ jsx("span", { className: "twc-dt__th-label", style: { flex: "none", cursor: "default" }, children: "#" }),
10787
- /* @__PURE__ */ jsx(
10788
- "button",
10789
- {
10790
- type: "button",
10791
- className: "twc-dt__menu-btn",
10792
- "aria-label": "Row number column menu",
10793
- "aria-haspopup": "menu",
10794
- "aria-expanded": colMenu?.field === "__rownum__" || void 0,
10795
- onClick: (e) => {
10796
- e.stopPropagation();
10797
- menuTriggerRef.current = e.currentTarget;
10798
- setPanel(null);
10799
- closePanel();
10800
- setRowMenu(null);
10801
- closeRowMenu();
10802
- setExportOpen(false);
10803
- closeExport();
10804
- setColMenu({ field: "__rownum__" });
10805
- openMenu(e.currentTarget, "right", 180);
10806
- },
10807
- children: /* @__PURE__ */ jsx(Svg, { d: I.more })
10808
- }
10809
- )
10810
- ] }) }) : null,
10811
- ordered.map((c) => {
10812
- const st = stickyOf(c.field);
10813
- const sorted = sort && sort.field === c.field ? sort.dir : void 0;
10814
- const w = widthOf(c);
10815
- const reorderable = !disableColumnReorder && st.pin == null && c.type !== "actions" && c.reorderable !== false;
10816
- const resizable = !disableColumnResize && c.resizable !== false;
10817
- const hasMenu = !c.disableColumnMenu && (c.sortable || c.filterable || c.pinnable || c.hideable);
10818
- return /* @__PURE__ */ jsxs(
10819
- "th",
10820
- {
10821
- className: "twc-dt__th",
10822
- role: "columnheader",
10823
- scope: "col",
10824
- "aria-sort": sorted ? sorted === "asc" ? "ascending" : "descending" : c.sortable ? "none" : void 0,
10825
- "data-num": c.type === "number" || void 0,
10826
- "data-actions-col": c.type === "actions" || void 0,
10827
- "data-sorted": sorted,
10828
- "data-pin": st.pin,
10829
- "data-pin-edge": st.edge,
10830
- "data-dragging": drag.from === c.field || void 0,
10831
- "data-dropbefore": drag.over === c.field && !drag.after || void 0,
10832
- "data-dropafter": drag.over === c.field && drag.after || void 0,
10833
- style: { width: w, minWidth: w, ...st.style },
10834
- onDragOver: reorderable && drag.from ? (e) => {
10835
- e.preventDefault();
10836
- const r2 = e.currentTarget.getBoundingClientRect();
10837
- const after = e.clientX > r2.left + r2.width / 2;
10838
- setDrag((d) => d.over === c.field && d.after === after ? d : { ...d, over: c.field, after });
10839
- } : void 0,
10840
- onDrop: reorderable && drag.from ? (e) => {
10841
- e.preventDefault();
10842
- onColDrop(c.field);
10843
- } : void 0,
10844
- children: [
10845
- /* @__PURE__ */ jsxs("div", { className: "twc-dt__th-inner", children: [
10846
- /* @__PURE__ */ jsxs(
10847
- "span",
10848
- {
10849
- className: "twc-dt__th-label",
10850
- role: c.sortable ? "button" : void 0,
10851
- tabIndex: c.sortable ? 0 : void 0,
10852
- title: typeof c.headerName === "string" ? c.headerName : void 0,
10853
- "aria-label": c.sortable ? `${c.headerName}, sort` : void 0,
10854
- draggable: reorderable || void 0,
10855
- onDragStart: reorderable ? (e) => {
10856
- setDrag({ from: c.field, over: null, after: false });
10857
- e.dataTransfer.effectAllowed = "move";
10858
- e.dataTransfer.setData("text/plain", c.field);
10859
- } : void 0,
10860
- onDragEnd: reorderable ? () => setDrag({ from: null, over: null, after: false }) : void 0,
10861
- onClick: () => c.sortable && cycleSort(c.field),
10862
- onKeyDown: c.sortable ? (e) => {
10863
- if (e.key === "Enter" || e.key === " ") {
10864
- e.preventDefault();
10865
- cycleSort(c.field);
10839
+ ) }) }) : null,
10840
+ showRowNum ? /* @__PURE__ */ jsx("th", { className: "twc-dt__th twc-dt__rownum", role: "columnheader", "aria-label": "Row number", "data-pin": "left", "data-pin-edge": pins.left.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W, minWidth: NUM_W }, children: /* @__PURE__ */ jsxs("div", { className: "twc-dt__th-inner", children: [
10841
+ /* @__PURE__ */ jsx("span", { className: "twc-dt__th-label", style: { flex: "none", cursor: "default" }, children: "#" }),
10842
+ /* @__PURE__ */ jsx(
10843
+ "button",
10844
+ {
10845
+ type: "button",
10846
+ className: "twc-dt__menu-btn",
10847
+ "aria-label": "Row number column menu",
10848
+ "aria-haspopup": "menu",
10849
+ "aria-expanded": colMenu?.field === "__rownum__" || void 0,
10850
+ onClick: (e) => {
10851
+ e.stopPropagation();
10852
+ menuTriggerRef.current = e.currentTarget;
10853
+ setPanel(null);
10854
+ closePanel();
10855
+ setRowMenu(null);
10856
+ closeRowMenu();
10857
+ setExportOpen(false);
10858
+ closeExport();
10859
+ setColMenu({ field: "__rownum__" });
10860
+ openMenu(e.currentTarget, "right", 180);
10861
+ },
10862
+ children: /* @__PURE__ */ jsx(Svg, { d: I.more })
10863
+ }
10864
+ )
10865
+ ] }) }) : null,
10866
+ ordered.map((c) => {
10867
+ const st = stickyOf(c.field);
10868
+ const sorted = sort && sort.field === c.field ? sort.dir : void 0;
10869
+ const w = widthOf(c);
10870
+ const reorderable = !disableColumnReorder && st.pin == null && c.type !== "actions" && c.reorderable !== false;
10871
+ const resizable = !disableColumnResize && c.resizable !== false;
10872
+ const hasMenu = !c.disableColumnMenu && (c.sortable || c.filterable || c.pinnable || c.hideable);
10873
+ return /* @__PURE__ */ jsxs(
10874
+ "th",
10875
+ {
10876
+ className: "twc-dt__th",
10877
+ role: "columnheader",
10878
+ scope: "col",
10879
+ "aria-sort": sorted ? sorted === "asc" ? "ascending" : "descending" : c.sortable ? "none" : void 0,
10880
+ "data-num": c.type === "number" || void 0,
10881
+ "data-actions-col": c.type === "actions" || void 0,
10882
+ "data-sorted": sorted,
10883
+ "data-pin": st.pin,
10884
+ "data-pin-edge": st.edge,
10885
+ "data-dragging": drag.from === c.field || void 0,
10886
+ "data-dropbefore": drag.over === c.field && !drag.after || void 0,
10887
+ "data-dropafter": drag.over === c.field && drag.after || void 0,
10888
+ style: { width: w, minWidth: w, ...st.style },
10889
+ onDragOver: reorderable && drag.from ? (e) => {
10890
+ e.preventDefault();
10891
+ const r2 = e.currentTarget.getBoundingClientRect();
10892
+ const after = e.clientX > r2.left + r2.width / 2;
10893
+ setDrag((d) => d.over === c.field && d.after === after ? d : { ...d, over: c.field, after });
10894
+ } : void 0,
10895
+ onDrop: reorderable && drag.from ? (e) => {
10896
+ e.preventDefault();
10897
+ onColDrop(c.field);
10898
+ } : void 0,
10899
+ children: [
10900
+ /* @__PURE__ */ jsxs("div", { className: "twc-dt__th-inner", children: [
10901
+ /* @__PURE__ */ jsxs(
10902
+ "span",
10903
+ {
10904
+ className: "twc-dt__th-label",
10905
+ role: c.sortable ? "button" : void 0,
10906
+ tabIndex: c.sortable ? 0 : void 0,
10907
+ "data-ovtext": typeof c.headerName === "string" ? c.headerName : void 0,
10908
+ "aria-label": c.sortable ? `${c.headerName}, sort` : void 0,
10909
+ draggable: reorderable || void 0,
10910
+ onDragStart: reorderable ? (e) => {
10911
+ setDrag({ from: c.field, over: null, after: false });
10912
+ e.dataTransfer.effectAllowed = "move";
10913
+ e.dataTransfer.setData("text/plain", c.field);
10914
+ } : void 0,
10915
+ onDragEnd: reorderable ? () => setDrag({ from: null, over: null, after: false }) : void 0,
10916
+ onClick: () => c.sortable && cycleSort(c.field),
10917
+ onKeyDown: c.sortable ? (e) => {
10918
+ if (e.key === "Enter" || e.key === " ") {
10919
+ e.preventDefault();
10920
+ cycleSort(c.field);
10921
+ }
10922
+ } : void 0,
10923
+ children: [
10924
+ reorderable ? /* @__PURE__ */ jsx("span", { className: "twc-dt__grip", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.grip }) }) : null,
10925
+ filteredFields.has(c.field) ? /* @__PURE__ */ jsx("span", { className: "twc-dt__filterdot" }) : null,
10926
+ c.headerName,
10927
+ c.sortable ? /* @__PURE__ */ jsx("span", { className: "twc-dt__sort", children: /* @__PURE__ */ jsx(Svg, { d: I.arrow }) }) : null
10928
+ ]
10866
10929
  }
10867
- } : void 0,
10868
- children: [
10869
- reorderable ? /* @__PURE__ */ jsx("span", { className: "twc-dt__grip", "aria-hidden": "true", children: /* @__PURE__ */ jsx(Svg, { d: I.grip }) }) : null,
10870
- filteredFields.has(c.field) ? /* @__PURE__ */ jsx("span", { className: "twc-dt__filterdot" }) : null,
10871
- c.headerName,
10872
- c.sortable ? /* @__PURE__ */ jsx("span", { className: "twc-dt__sort", children: /* @__PURE__ */ jsx(Svg, { d: I.arrow }) }) : null
10873
- ]
10874
- }
10875
- ),
10876
- hasMenu ? /* @__PURE__ */ jsx(
10877
- "button",
10878
- {
10879
- type: "button",
10880
- className: "twc-dt__menu-btn",
10881
- "aria-label": "Column menu",
10882
- "aria-haspopup": "menu",
10883
- "aria-expanded": colMenu?.field === c.field || void 0,
10884
- onClick: (e) => {
10885
- e.stopPropagation();
10886
- menuTriggerRef.current = e.currentTarget;
10887
- setPanel(null);
10888
- closePanel();
10889
- setRowMenu(null);
10890
- closeRowMenu();
10891
- setExportOpen(false);
10892
- closeExport();
10893
- setColMenu({ field: c.field });
10894
- openMenu(e.currentTarget, "right", 230);
10895
- },
10896
- children: /* @__PURE__ */ jsx(Svg, { d: I.more })
10897
- }
10898
- ) : null
10899
- ] }),
10900
- resizable ? /* @__PURE__ */ jsx(
10901
- "span",
10902
- {
10903
- className: "twc-dt__resizer",
10904
- "data-active": resizing || void 0,
10905
- role: "separator",
10906
- "aria-orientation": "vertical",
10907
- "aria-label": `Resize ${c.headerName} column (double-click to fit content)`,
10908
- "aria-valuenow": w,
10909
- "aria-valuemin": 72,
10910
- tabIndex: 0,
10911
- onPointerDown: (e) => startResize(e, c.field),
10912
- onClick: (e) => e.stopPropagation(),
10913
- onDoubleClick: (e) => {
10914
- e.preventDefault();
10915
- e.stopPropagation();
10916
- autoFitColumn(c.field, e.currentTarget.closest("th"));
10917
- },
10918
- onKeyDown: (e) => {
10919
- if (e.key === "Enter" || e.key === " ") {
10920
- e.preventDefault();
10921
- e.stopPropagation();
10922
- autoFitColumn(c.field, e.currentTarget.closest("th"));
10923
- return;
10930
+ ),
10931
+ hasMenu ? /* @__PURE__ */ jsx(
10932
+ "button",
10933
+ {
10934
+ type: "button",
10935
+ className: "twc-dt__menu-btn",
10936
+ "aria-label": "Column menu",
10937
+ "aria-haspopup": "menu",
10938
+ "aria-expanded": colMenu?.field === c.field || void 0,
10939
+ onClick: (e) => {
10940
+ e.stopPropagation();
10941
+ menuTriggerRef.current = e.currentTarget;
10942
+ setPanel(null);
10943
+ closePanel();
10944
+ setRowMenu(null);
10945
+ closeRowMenu();
10946
+ setExportOpen(false);
10947
+ closeExport();
10948
+ setColMenu({ field: c.field });
10949
+ openMenu(e.currentTarget, "right", 230);
10950
+ },
10951
+ children: /* @__PURE__ */ jsx(Svg, { d: I.more })
10952
+ }
10953
+ ) : null
10954
+ ] }),
10955
+ resizable ? /* @__PURE__ */ jsx(
10956
+ "span",
10957
+ {
10958
+ className: "twc-dt__resizer",
10959
+ "data-active": resizing || void 0,
10960
+ role: "separator",
10961
+ "aria-orientation": "vertical",
10962
+ "aria-label": `Resize ${c.headerName} column (double-click to fit content)`,
10963
+ "aria-valuenow": w,
10964
+ "aria-valuemin": 72,
10965
+ tabIndex: 0,
10966
+ onPointerDown: (e) => startResize(e, c.field),
10967
+ onClick: (e) => e.stopPropagation(),
10968
+ onDoubleClick: (e) => {
10969
+ e.preventDefault();
10970
+ e.stopPropagation();
10971
+ autoFitColumn(c.field, e.currentTarget.closest("th"));
10972
+ },
10973
+ onKeyDown: (e) => {
10974
+ if (e.key === "Enter" || e.key === " ") {
10975
+ e.preventDefault();
10976
+ e.stopPropagation();
10977
+ autoFitColumn(c.field, e.currentTarget.closest("th"));
10978
+ return;
10979
+ }
10980
+ if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
10981
+ e.preventDefault();
10982
+ e.stopPropagation();
10983
+ const delta = e.key === "ArrowRight" ? 10 : -10;
10984
+ setWidths((m) => ({ ...m, [c.field]: Math.max(72, (m[c.field] ?? intrinsicWidth(c)) + delta) }));
10985
+ },
10986
+ title: "Drag to resize \xB7 double-click to fit content"
10924
10987
  }
10925
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
10926
- e.preventDefault();
10927
- e.stopPropagation();
10928
- const delta = e.key === "ArrowRight" ? 10 : -10;
10929
- setWidths((m) => ({ ...m, [c.field]: Math.max(72, (m[c.field] ?? intrinsicWidth(c)) + delta) }));
10930
- },
10931
- title: "Drag to resize \xB7 double-click to fit content"
10932
- }
10933
- ) : null
10934
- ]
10935
- },
10936
- c.field
10937
- );
10938
- })
10939
- ] }) }),
10940
- /* @__PURE__ */ jsx("tbody", { children: loading ? Array.from({ length: paginated ? Math.min(sizeVal, 8) : 8 }).map((_, ri) => /* @__PURE__ */ jsxs("tr", { className: "twc-dt__row", role: "row", children: [
10941
- checkboxSelection ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", "data-pin": "left", style: { insetInlineStart: 0, width: CHK_W }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": "18px", height: 18, borderRadius: 4 } }) }) : null,
10942
- showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", style: { insetInlineStart: numLeft, width: NUM_W }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": "16px", height: 14, borderRadius: 4 } }) }) : null,
10943
- ordered.map((c, ci) => {
10944
- const st = stickyOf(c.field);
10945
- return /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", "data-num": c.type === "number" || void 0, "data-pin": st.pin, "data-pin-edge": st.edge, style: { width: widthOf(c), ...st.style }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": `${45 + (ri * 13 + ci * 29) % 45}%` } }) }, c.field);
10946
- })
10947
- ] }, ri)) : (displayItems ? displayItems.length === 0 : paged.length === 0) ? (
10948
- // #121: customizable, filter-aware empty state. #122: grid roles on the empty row.
10949
- /* @__PURE__ */ jsx("tr", { role: "row", "aria-rowindex": 2, children: /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", colSpan: totalCols, style: { maxWidth: "none" }, children: /* @__PURE__ */ jsx("div", { className: "twc-dt__empty", children: renderEmpty ? renderEmpty() : emptyMessage ?? (filters.length > 0 || quick.trim() !== "" ? "No rows match your filters" : "No rows") }) }) })
10950
- ) : displayItems ? (() => {
10951
- let li = -1;
10952
- return displayItems.map((item) => item.kind === "group" ? renderGroupRow(item) : renderLeaf(item.row, ++li));
10953
- })() : /* @__PURE__ */ jsxs(Fragment, { children: [
10954
- pinnedTopRows.map((row) => renderLeaf(row, keyIndex.get(keyOf(row)), "top")),
10955
- vWindow ? /* @__PURE__ */ jsxs(Fragment, { children: [
10956
- vWindow.padTop > 0 ? /* @__PURE__ */ jsx("tr", { "aria-hidden": "true", className: "twc-dt__vspacer", children: /* @__PURE__ */ jsx("td", { colSpan: totalCols, style: { height: vWindow.padTop, padding: 0, border: "none", maxWidth: "none" } }) }) : null,
10957
- middleRows.slice(vWindow.start, vWindow.end).map((row, i) => renderLeaf(row, keyIndex.get(keyOf(row)), void 0, vWindow.start + i)),
10958
- vWindow.padBottom > 0 ? /* @__PURE__ */ jsx("tr", { "aria-hidden": "true", className: "twc-dt__vspacer", children: /* @__PURE__ */ jsx("td", { colSpan: totalCols, style: { height: vWindow.padBottom, padding: 0, border: "none", maxWidth: "none" } }) }) : null
10959
- ] }) : middleRows.map((row, i) => renderLeaf(row, keyIndex.get(keyOf(row)), void 0, i)),
10960
- pinnedBottomRows.map((row) => renderLeaf(row, keyIndex.get(keyOf(row)), "bottom"))
10961
- ] }) }),
10962
- hasAggregation && aggOn && !loading && paged.length > 0 ? /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsxs("tr", { role: "row", children: [
10963
- checkboxSelection ? /* @__PURE__ */ jsx("td", { role: "gridcell", "data-pin": "left", "data-pin-edge": pins.left.length || showRowNum ? void 0 : "left", style: { insetInlineStart: 0, width: CHK_W } }) : null,
10964
- showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", "data-pin-edge": pins.left.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W } }) : null,
10965
- ordered.map((c) => {
10966
- const st = stickyOf(c.field);
10967
- const v = aggregate(c);
10968
- const display = v == null ? null : c.aggregationFormatter ? c.aggregationFormatter(v) : c.valueFormatter ? c.valueFormatter(v, null) : typeof v === "number" ? v.toLocaleString() : v;
10969
- return /* @__PURE__ */ jsx("td", { role: "gridcell", "data-num": c.type === "number" || void 0, "data-pin": st.pin, "data-pin-edge": st.edge, style: { width: widthOf(c), ...st.style }, children: v == null ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
10970
- typeof aggOf(c) === "string" ? /* @__PURE__ */ jsx("span", { className: "twc-dt__agg-label", children: aggLabels[aggOf(c)] }) : null,
10971
- /* @__PURE__ */ jsx("span", { className: "twc-dt__agg-val", children: display })
10972
- ] }) }, c.field);
10973
- })
10974
- ] }) }) : null
10975
- ]
10988
+ ) : null
10989
+ ]
10990
+ },
10991
+ c.field
10992
+ );
10993
+ })
10994
+ ] }) }),
10995
+ /* @__PURE__ */ jsx("tbody", { children: loading ? Array.from({ length: paginated ? Math.min(sizeVal, 8) : 8 }).map((_, ri) => /* @__PURE__ */ jsxs("tr", { className: "twc-dt__row", role: "row", children: [
10996
+ checkboxSelection ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", "data-pin": "left", style: { insetInlineStart: 0, width: CHK_W }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": "18px", height: 18, borderRadius: 4 } }) }) : null,
10997
+ showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__td twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", style: { insetInlineStart: numLeft, width: NUM_W }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": "16px", height: 14, borderRadius: 4 } }) }) : null,
10998
+ ordered.map((c, ci) => {
10999
+ const st = stickyOf(c.field);
11000
+ return /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", "data-num": c.type === "number" || void 0, "data-pin": st.pin, "data-pin-edge": st.edge, style: { width: widthOf(c), ...st.style }, children: /* @__PURE__ */ jsx("span", { className: "twc-dt__sk", "aria-hidden": "true", style: { "--_w": `${45 + (ri * 13 + ci * 29) % 45}%` } }) }, c.field);
11001
+ })
11002
+ ] }, ri)) : (displayItems ? displayItems.length === 0 : paged.length === 0) ? (
11003
+ // #121: customizable, filter-aware empty state. #122: grid roles on the empty row.
11004
+ /* @__PURE__ */ jsx("tr", { role: "row", "aria-rowindex": 2, children: /* @__PURE__ */ jsx("td", { className: "twc-dt__td", role: "gridcell", colSpan: totalCols, style: { maxWidth: "none" }, children: /* @__PURE__ */ jsx("div", { className: "twc-dt__empty", children: renderEmpty ? renderEmpty() : emptyMessage ?? (filters.length > 0 || quick.trim() !== "" ? "No rows match your filters" : "No rows") }) }) })
11005
+ ) : displayItems ? (() => {
11006
+ let li = -1;
11007
+ return displayItems.map((item) => item.kind === "group" ? renderGroupRow(item) : renderLeaf(item.row, ++li));
11008
+ })() : /* @__PURE__ */ jsxs(Fragment, { children: [
11009
+ pinnedTopRows.map((row) => renderLeaf(row, keyIndex.get(keyOf(row)), "top")),
11010
+ vWindow ? /* @__PURE__ */ jsxs(Fragment, { children: [
11011
+ vWindow.padTop > 0 ? /* @__PURE__ */ jsx("tr", { "aria-hidden": "true", className: "twc-dt__vspacer", children: /* @__PURE__ */ jsx("td", { colSpan: totalCols, style: { height: vWindow.padTop, padding: 0, border: "none", maxWidth: "none" } }) }) : null,
11012
+ middleRows.slice(vWindow.start, vWindow.end).map((row, i) => renderLeaf(row, keyIndex.get(keyOf(row)), void 0, vWindow.start + i)),
11013
+ vWindow.padBottom > 0 ? /* @__PURE__ */ jsx("tr", { "aria-hidden": "true", className: "twc-dt__vspacer", children: /* @__PURE__ */ jsx("td", { colSpan: totalCols, style: { height: vWindow.padBottom, padding: 0, border: "none", maxWidth: "none" } }) }) : null
11014
+ ] }) : middleRows.map((row, i) => renderLeaf(row, keyIndex.get(keyOf(row)), void 0, i)),
11015
+ pinnedBottomRows.map((row) => renderLeaf(row, keyIndex.get(keyOf(row)), "bottom"))
11016
+ ] }) }),
11017
+ hasAggregation && aggOn && !loading && paged.length > 0 ? /* @__PURE__ */ jsx("tfoot", { children: /* @__PURE__ */ jsxs("tr", { role: "row", children: [
11018
+ checkboxSelection ? /* @__PURE__ */ jsx("td", { role: "gridcell", "data-pin": "left", "data-pin-edge": pins.left.length || showRowNum ? void 0 : "left", style: { insetInlineStart: 0, width: CHK_W } }) : null,
11019
+ showRowNum ? /* @__PURE__ */ jsx("td", { className: "twc-dt__rownum", role: "gridcell", "aria-hidden": "true", "data-pin": "left", "data-pin-edge": pins.left.length ? void 0 : "left", style: { insetInlineStart: numLeft, width: NUM_W } }) : null,
11020
+ ordered.map((c) => {
11021
+ const st = stickyOf(c.field);
11022
+ const v = aggregate(c);
11023
+ const display = v == null ? null : c.aggregationFormatter ? c.aggregationFormatter(v) : c.valueFormatter ? c.valueFormatter(v, null) : typeof v === "number" ? v.toLocaleString() : v;
11024
+ return /* @__PURE__ */ jsx("td", { role: "gridcell", "data-num": c.type === "number" || void 0, "data-pin": st.pin, "data-pin-edge": st.edge, style: { width: widthOf(c), ...st.style }, children: v == null ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
11025
+ typeof aggOf(c) === "string" ? /* @__PURE__ */ jsx("span", { className: "twc-dt__agg-label", children: aggLabels[aggOf(c)] }) : null,
11026
+ /* @__PURE__ */ jsx("span", { className: "twc-dt__agg-val", children: display })
11027
+ ] }) }, c.field);
11028
+ })
11029
+ ] }) }) : null
11030
+ ]
11031
+ }
11032
+ )
10976
11033
  }
10977
- ) }),
11034
+ ),
11035
+ /* @__PURE__ */ jsx(Tooltip, { anchor: ovTip ? ovTip.anchor : null, open: !!ovTip, label: ovTip ? ovTip.text : null, placement: "top" }),
10978
11036
  !pivotActive ? /* @__PURE__ */ jsxs("div", { className: "twc-dt__footer", children: [
10979
11037
  /* @__PURE__ */ jsxs("div", { className: "twc-dt__footer-row", "data-bottom": "true", children: [
10980
11038
  /* @__PURE__ */ jsx("span", { className: "twc-dt__status", children: loading ? "Loading\u2026" : (() => {