@ai-matrx/design-system 0.56.2 → 0.59.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.
@@ -34775,7 +34775,7 @@ function TableIconActions({ actions }) {
34775
34775
  }
34776
34776
 
34777
34777
  // src/data-table/MatrxDataTable.tsx
34778
- var import_react28 = require("react");
34778
+ var import_react29 = require("react");
34779
34779
  var import_react_dom4 = require("react-dom");
34780
34780
 
34781
34781
  // src/data-table/tableCardContext.ts
@@ -35660,6 +35660,162 @@ function Skeleton({ className, animated = true, ...props }) {
35660
35660
  );
35661
35661
  }
35662
35662
 
35663
+ // src/data-table/row-drawing.ts
35664
+ var import_react3 = require("react");
35665
+ var LAZY = /* @__PURE__ */ Symbol.for("@ai-matrx/design-system/data-table/lazy-callback");
35666
+ var MAX_DEPTH = 32;
35667
+ var HANDLER_KEY = /^on[A-Z]/;
35668
+ function lazyCallback(fn) {
35669
+ fn[LAZY] = true;
35670
+ return fn;
35671
+ }
35672
+ function isLazy(fn) {
35673
+ return fn[LAZY] === true;
35674
+ }
35675
+ function trampolinable(key, fn) {
35676
+ return isLazy(fn) || HANDLER_KEY.test(key);
35677
+ }
35678
+ function isPlainObject(value) {
35679
+ if (value === null || typeof value !== "object") return false;
35680
+ const proto = Object.getPrototypeOf(value);
35681
+ return proto === Object.prototype || proto === null;
35682
+ }
35683
+ function makeSlot(fn) {
35684
+ const slot = {
35685
+ fn,
35686
+ // A Proxy rather than a bare wrapper: a handler that carries its own members (a debounced
35687
+ // function's `cancel`) keeps them, read from the latest function.
35688
+ stable: new Proxy((() => void 0), {
35689
+ apply: (_target, thisArg, args) => Reflect.apply(slot.fn, thisArg, args),
35690
+ get: (_target, key) => Reflect.get(slot.fn, key)
35691
+ })
35692
+ };
35693
+ return slot;
35694
+ }
35695
+ function sameEntries(a, b, path2, depth, updates) {
35696
+ const keys2 = Object.keys(a);
35697
+ if (keys2.length !== Object.keys(b).length) return false;
35698
+ for (const key of keys2) {
35699
+ if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
35700
+ if (key === "ref") {
35701
+ if (!Object.is(a[key], b[key])) return false;
35702
+ continue;
35703
+ }
35704
+ if (!sameDrawing(a[key], b[key], key, `${path2}/${key}`, depth + 1, updates)) return false;
35705
+ }
35706
+ return true;
35707
+ }
35708
+ function sameDrawing(previous, next, key, path2, depth, updates) {
35709
+ if (Object.is(previous, next)) return true;
35710
+ if (typeof previous === "function" && typeof next === "function") {
35711
+ if (trampolinable(key, previous) && trampolinable(key, next)) {
35712
+ updates.push([path2, next]);
35713
+ return true;
35714
+ }
35715
+ return false;
35716
+ }
35717
+ if (depth > MAX_DEPTH) return false;
35718
+ if ((0, import_react3.isValidElement)(previous) && (0, import_react3.isValidElement)(next)) {
35719
+ if (previous.type !== next.type || previous.key !== next.key) return false;
35720
+ return sameEntries(
35721
+ previous.props,
35722
+ next.props,
35723
+ path2,
35724
+ depth,
35725
+ updates
35726
+ );
35727
+ }
35728
+ if (Array.isArray(previous) && Array.isArray(next)) {
35729
+ if (previous.length !== next.length) return false;
35730
+ for (let i = 0; i < previous.length; i += 1) {
35731
+ if (!sameDrawing(previous[i], next[i], key, `${path2}/${i}`, depth + 1, updates)) return false;
35732
+ }
35733
+ return true;
35734
+ }
35735
+ if (isPlainObject(previous) && isPlainObject(next)) return sameEntries(previous, next, path2, depth, updates);
35736
+ return false;
35737
+ }
35738
+ function stabilize(value, key, path2, depth, slots, reuse) {
35739
+ if (typeof value === "function") {
35740
+ if (!trampolinable(key, value)) return value;
35741
+ const fn = value;
35742
+ const kept = reuse?.get(path2);
35743
+ const slot = kept ?? makeSlot(fn);
35744
+ slot.fn = fn;
35745
+ slots.set(path2, slot);
35746
+ return slot.stable;
35747
+ }
35748
+ if (depth > MAX_DEPTH) return value;
35749
+ if ((0, import_react3.isValidElement)(value)) {
35750
+ const props = value.props;
35751
+ let changed = null;
35752
+ for (const propKey of Object.keys(props)) {
35753
+ if (propKey === "ref") continue;
35754
+ const before2 = props[propKey];
35755
+ const after2 = stabilize(before2, propKey, `${path2}/${propKey}`, depth + 1, slots, reuse);
35756
+ if (after2 !== before2) (changed ??= {})[propKey] = after2;
35757
+ }
35758
+ if (!changed) return value;
35759
+ const clone = (0, import_react3.cloneElement)(value, changed);
35760
+ const before = value._store;
35761
+ const after = clone._store;
35762
+ if (before && after && "validated" in before) {
35763
+ try {
35764
+ after.validated = before.validated;
35765
+ } catch {
35766
+ }
35767
+ }
35768
+ return clone;
35769
+ }
35770
+ if (Array.isArray(value)) {
35771
+ let out = null;
35772
+ for (let i = 0; i < value.length; i += 1) {
35773
+ const after = stabilize(value[i], key, `${path2}/${i}`, depth + 1, slots, reuse);
35774
+ if (after !== value[i]) (out ??= value.slice())[i] = after;
35775
+ }
35776
+ return out ?? value;
35777
+ }
35778
+ if (isPlainObject(value)) {
35779
+ let out = null;
35780
+ for (const entryKey of Object.keys(value)) {
35781
+ const before = value[entryKey];
35782
+ const after = stabilize(before, entryKey, `${path2}/${entryKey}`, depth + 1, slots, reuse);
35783
+ if (after !== before) (out ??= { ...value })[entryKey] = after;
35784
+ }
35785
+ return out ?? value;
35786
+ }
35787
+ return value;
35788
+ }
35789
+ var RowDrawings = class {
35790
+ rows = /* @__PURE__ */ new Map();
35791
+ /**
35792
+ * The element to hand React for this row. The SAME object as last time when `raw` draws what the
35793
+ * last one drew (its handlers are re-pointed); a new one otherwise.
35794
+ */
35795
+ draw(rowId, raw) {
35796
+ const previous = this.rows.get(rowId);
35797
+ if (previous) {
35798
+ const updates = [];
35799
+ if (sameDrawing(previous.raw, raw, "", "", 0, updates) && updates.every(([path2]) => previous.slots.has(path2))) {
35800
+ for (const [path2, fn] of updates) previous.slots.get(path2).fn = fn;
35801
+ previous.raw = raw;
35802
+ return previous.out;
35803
+ }
35804
+ }
35805
+ const slots = /* @__PURE__ */ new Map();
35806
+ const out = stabilize(raw, "", "", 0, slots, previous?.slots);
35807
+ this.rows.set(rowId, { raw, out, slots });
35808
+ return out;
35809
+ }
35810
+ /** Forget rows that are no longer in the table (bounded by what was ever drawn). */
35811
+ prune(liveIds) {
35812
+ for (const id of this.rows.keys()) if (!liveIds.has(id)) this.rows.delete(id);
35813
+ }
35814
+ get size() {
35815
+ return this.rows.size;
35816
+ }
35817
+ };
35818
+
35663
35819
  // src/data-table/TableTitleRow.tsx
35664
35820
  var import_jsx_runtime16 = require("react/jsx-runtime");
35665
35821
  function TableTitleRow({
@@ -35727,11 +35883,11 @@ function TableTitleRow({
35727
35883
  }
35728
35884
 
35729
35885
  // src/data-table/TableSearch.tsx
35730
- var import_react3 = require("react");
35886
+ var import_react4 = require("react");
35731
35887
  var import_jsx_runtime17 = require("react/jsx-runtime");
35732
35888
  function TableSearch({ value, onChange, scope, onScopeChange, scopes, placeholder = "Search\u2026" }) {
35733
- const [expanded, setExpanded] = (0, import_react3.useState)(false);
35734
- const inputRef = (0, import_react3.useRef)(null);
35889
+ const [expanded, setExpanded] = (0, import_react4.useState)(false);
35890
+ const inputRef = (0, import_react4.useRef)(null);
35735
35891
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { "data-matrx-table-search": true, className: "h-11 min-w-0 w-full sm:max-w-xs", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
35736
35892
  "div",
35737
35893
  {
@@ -35777,7 +35933,7 @@ function TableSearch({ value, onChange, scope, onScopeChange, scopes, placeholde
35777
35933
  }
35778
35934
 
35779
35935
  // src/data-table/useScrollPagination.ts
35780
- var import_react4 = require("react");
35936
+ var import_react5 = require("react");
35781
35937
  var DEFAULT_THRESHOLD_PX = 96;
35782
35938
  var DEFAULT_INTENT_TIMEOUT_MS = 1200;
35783
35939
  function resolveContainer(container) {
@@ -35848,8 +36004,8 @@ function useScrollPagination({
35848
36004
  intentTimeoutMs = DEFAULT_INTENT_TIMEOUT_MS,
35849
36005
  enabled = true
35850
36006
  }) {
35851
- const [requestError, setRequestError] = (0, import_react4.useState)(null);
35852
- const latestRef = (0, import_react4.useRef)({
36007
+ const [requestError, setRequestError] = (0, import_react5.useState)(null);
36008
+ const latestRef = (0, import_react5.useRef)({
35853
36009
  queryKey,
35854
36010
  hasNextPage,
35855
36011
  isFetchingNextPage,
@@ -35871,16 +36027,16 @@ function useScrollPagination({
35871
36027
  thresholdPx,
35872
36028
  enabled
35873
36029
  };
35874
- const intentRef = (0, import_react4.useRef)(null);
35875
- const inputSequenceRef = (0, import_react4.useRef)(0);
35876
- const consumedSequenceRef = (0, import_react4.useRef)(0);
35877
- const requestGenerationRef = (0, import_react4.useRef)(0);
35878
- const inFlightGenerationRef = (0, import_react4.useRef)(null);
35879
- const requestErrorRef = (0, import_react4.useRef)(null);
35880
- const mountedRef = (0, import_react4.useRef)(false);
35881
- const observedTopRef = (0, import_react4.useRef)(/* @__PURE__ */ new WeakMap());
36030
+ const intentRef = (0, import_react5.useRef)(null);
36031
+ const inputSequenceRef = (0, import_react5.useRef)(0);
36032
+ const consumedSequenceRef = (0, import_react5.useRef)(0);
36033
+ const requestGenerationRef = (0, import_react5.useRef)(0);
36034
+ const inFlightGenerationRef = (0, import_react5.useRef)(null);
36035
+ const requestErrorRef = (0, import_react5.useRef)(null);
36036
+ const mountedRef = (0, import_react5.useRef)(false);
36037
+ const observedTopRef = (0, import_react5.useRef)(/* @__PURE__ */ new WeakMap());
35882
36038
  const effectiveError = error ?? requestError;
35883
- (0, import_react4.useEffect)(() => {
36039
+ (0, import_react5.useEffect)(() => {
35884
36040
  mountedRef.current = true;
35885
36041
  return () => {
35886
36042
  mountedRef.current = false;
@@ -35910,7 +36066,7 @@ function useScrollPagination({
35910
36066
  }
35911
36067
  }
35912
36068
  };
35913
- (0, import_react4.useEffect)(() => {
36069
+ (0, import_react5.useEffect)(() => {
35914
36070
  intentRef.current = null;
35915
36071
  observedTopRef.current = /* @__PURE__ */ new WeakMap();
35916
36072
  consumedSequenceRef.current = inputSequenceRef.current;
@@ -35919,7 +36075,7 @@ function useScrollPagination({
35919
36075
  inFlightGenerationRef.current = null;
35920
36076
  requestGenerationRef.current += 1;
35921
36077
  }, [queryKey]);
35922
- (0, import_react4.useEffect)(() => {
36078
+ (0, import_react5.useEffect)(() => {
35923
36079
  if (mode !== "scroll" || !enabled || typeof window === "undefined") return;
35924
36080
  const attachable = containers.map(resolveContainer).filter((container) => container !== null);
35925
36081
  const ownerCleanups = /* @__PURE__ */ new Map();
@@ -36015,7 +36171,7 @@ function useScrollPagination({
36015
36171
  }
36016
36172
 
36017
36173
  // src/data-table/useProgressiveTableRows.ts
36018
- var import_react5 = require("react");
36174
+ var import_react6 = require("react");
36019
36175
  function safePageSize(pageSize) {
36020
36176
  return Number.isFinite(pageSize) && pageSize > 0 ? Math.floor(pageSize) : 0;
36021
36177
  }
@@ -36041,15 +36197,15 @@ function useProgressiveTableRows({
36041
36197
  const pageSize = safePageSize(rawPageSize);
36042
36198
  const hasExplicitRequestedPage = rawRequestedPage !== void 0;
36043
36199
  const requestedPage = safeRequestedPage(rawRequestedPage);
36044
- const initialRequestedPageRef = (0, import_react5.useRef)(requestedPage);
36045
- const latestRequestedPageRef = (0, import_react5.useRef)(requestedPage);
36046
- const optimisticAdvancePageRef = (0, import_react5.useRef)(null);
36200
+ const initialRequestedPageRef = (0, import_react6.useRef)(requestedPage);
36201
+ const latestRequestedPageRef = (0, import_react6.useRef)(requestedPage);
36202
+ const optimisticAdvancePageRef = (0, import_react6.useRef)(null);
36047
36203
  latestRequestedPageRef.current = requestedPage;
36048
36204
  const progressionKey = `${queryKey}\0${pageSize}`;
36049
36205
  const initialShownCount = startCount(pageSize, initialRequestedPageRef.current);
36050
36206
  const resetShownCount = startCount(pageSize, 1);
36051
36207
  const queryStartShownCount = hasExplicitRequestedPage ? startCount(pageSize, requestedPage) : resetShownCount;
36052
- const [progression, setProgression] = (0, import_react5.useState)(() => ({
36208
+ const [progression, setProgression] = (0, import_react6.useState)(() => ({
36053
36209
  key: progressionKey,
36054
36210
  shownCount: initialShownCount,
36055
36211
  requestedPage
@@ -36060,7 +36216,7 @@ function useProgressiveTableRows({
36060
36216
  const shownCount = progression.key !== progressionKey ? queryStartShownCount : externallyRequestedPage ? startCount(pageSize, requestedPage) : Math.max(progression.shownCount, resetShownCount);
36061
36217
  const visibleCount = Math.min(rows.length, shownCount);
36062
36218
  const hasMore = enabled && pageSize > 0 && visibleCount < rows.length;
36063
- (0, import_react5.useEffect)(() => {
36219
+ (0, import_react6.useEffect)(() => {
36064
36220
  setProgression((current) => {
36065
36221
  if (current.key !== progressionKey) {
36066
36222
  optimisticAdvancePageRef.current = null;
@@ -36100,12 +36256,12 @@ function useProgressiveTableRows({
36100
36256
  onPageAdvance(nextPage);
36101
36257
  }
36102
36258
  };
36103
- const warnedUnderfill = (0, import_react5.useRef)(null);
36104
- const numberedMeasured = (0, import_react5.useRef)(false);
36105
- const fillInputs = (0, import_react5.useRef)({ containers, onPageSizeChange, visibleCount });
36259
+ const warnedUnderfill = (0, import_react6.useRef)(null);
36260
+ const numberedMeasured = (0, import_react6.useRef)(false);
36261
+ const fillInputs = (0, import_react6.useRef)({ containers, onPageSizeChange, visibleCount });
36106
36262
  fillInputs.current = { containers, onPageSizeChange, visibleCount };
36107
36263
  const containerCount = containers.length;
36108
- (0, import_react5.useEffect)(() => {
36264
+ (0, import_react6.useEffect)(() => {
36109
36265
  if (!hasMore && !numberedPageHasMore) return;
36110
36266
  if (!hasMore && numberedMeasured.current) return;
36111
36267
  if (!hasMore) numberedMeasured.current = true;
@@ -36151,7 +36307,7 @@ function useProgressiveTableRows({
36151
36307
  ...thresholdPx === void 0 ? {} : { thresholdPx }
36152
36308
  });
36153
36309
  return {
36154
- rows: (0, import_react5.useMemo)(() => rows.slice(0, visibleCount), [rows, visibleCount]),
36310
+ rows: (0, import_react6.useMemo)(() => rows.slice(0, visibleCount), [rows, visibleCount]),
36155
36311
  shownCount: visibleCount,
36156
36312
  hasMore,
36157
36313
  showMore: scroll.requestNextPage
@@ -36761,32 +36917,32 @@ function DefaultTableStaleNotice({ error, what, onRetry }) {
36761
36917
  }
36762
36918
 
36763
36919
  // src/data-table/useTableNotice.tsx
36764
- var import_react7 = require("react");
36920
+ var import_react8 = require("react");
36765
36921
 
36766
36922
  // src/data-table/host.tsx
36767
- var import_react6 = require("react");
36923
+ var import_react7 = require("react");
36768
36924
  var import_jsx_runtime23 = require("react/jsx-runtime");
36769
36925
  var HOST_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.design-system.table-host-context");
36770
36926
  var hostRegistry = globalThis;
36771
- var HostContext = hostRegistry[HOST_SLOT] ??= (0, import_react6.createContext)({});
36927
+ var HostContext = hostRegistry[HOST_SLOT] ??= (0, import_react7.createContext)({});
36772
36928
  function MatrxDataTableProvider({ value, children }) {
36773
36929
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(HostContext.Provider, { value, children });
36774
36930
  }
36775
36931
  function useMatrxDataTableHost() {
36776
- return (0, import_react6.useContext)(HostContext);
36932
+ return (0, import_react7.useContext)(HostContext);
36777
36933
  }
36778
36934
  var ROW_ALCHEMY_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.design-system.table-row-alchemy-context");
36779
36935
  var rowAlchemyRegistry = globalThis;
36780
- var RowAlchemyContext = rowAlchemyRegistry[ROW_ALCHEMY_SLOT] ??= (0, import_react6.createContext)(null);
36936
+ var RowAlchemyContext = rowAlchemyRegistry[ROW_ALCHEMY_SLOT] ??= (0, import_react7.createContext)(null);
36781
36937
  function MatrxTableRowAlchemyScope({ value, children }) {
36782
36938
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RowAlchemyContext.Provider, { value, children });
36783
36939
  }
36784
36940
  function useMatrxTableRowAlchemy() {
36785
- return (0, import_react6.useContext)(RowAlchemyContext);
36941
+ return (0, import_react7.useContext)(RowAlchemyContext);
36786
36942
  }
36787
36943
  var ROW_CONTROLS_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.design-system.table-row-controls-context");
36788
36944
  var rowControlsRegistry = globalThis;
36789
- var RowControlsContext = rowControlsRegistry[ROW_CONTROLS_SLOT] ??= (0, import_react6.createContext)(null);
36945
+ var RowControlsContext = rowControlsRegistry[ROW_CONTROLS_SLOT] ??= (0, import_react7.createContext)(null);
36790
36946
  function MatrxTableRowControlsScope({ value, children }) {
36791
36947
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(RowControlsContext.Provider, { value, children });
36792
36948
  }
@@ -36795,8 +36951,8 @@ function MatrxTableRowControlsScope({ value, children }) {
36795
36951
  var import_jsx_runtime24 = require("react/jsx-runtime");
36796
36952
  function useTableNotice() {
36797
36953
  const host = useMatrxDataTableHost();
36798
- const [message, setMessage] = (0, import_react7.useState)(null);
36799
- const notify = (0, import_react7.useMemo)(
36954
+ const [message, setMessage] = (0, import_react8.useState)(null);
36955
+ const notify = (0, import_react8.useMemo)(
36800
36956
  () => ({
36801
36957
  success(text) {
36802
36958
  if (host.notify) host.notify.success(text);
@@ -37137,13 +37293,13 @@ function GenericTablePagination({
37137
37293
  }
37138
37294
 
37139
37295
  // src/data-table/TableViewTabs.tsx
37140
- var import_react8 = require("react");
37296
+ var import_react9 = require("react");
37141
37297
  var import_jsx_runtime26 = require("react/jsx-runtime");
37142
37298
  function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, related, editingId, onEditCancel, onEditDone, closable = true, closeLabel = "Close", addHint = "New view from the current one \xB7 double-click a tab to rename", renameable = true }) {
37143
- const [renaming, setRenaming] = (0, import_react8.useState)(null);
37144
- const [draft, setDraft] = (0, import_react8.useState)("");
37145
- const opened = (0, import_react8.useRef)(null);
37146
- (0, import_react8.useEffect)(() => {
37299
+ const [renaming, setRenaming] = (0, import_react9.useState)(null);
37300
+ const [draft, setDraft] = (0, import_react9.useState)("");
37301
+ const opened = (0, import_react9.useRef)(null);
37302
+ (0, import_react9.useEffect)(() => {
37147
37303
  if (!editingId || opened.current === editingId) return;
37148
37304
  const tab = tabs.find((t) => t.id === editingId);
37149
37305
  if (!tab) return;
@@ -37244,16 +37400,16 @@ function TableViewTabs({ tabs, activeId, onSelect, onAdd, onClose, onRename, rel
37244
37400
  }
37245
37401
  var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
37246
37402
  function TableViewWorkspace({ snapshot, onApply, related, store }) {
37247
- const [localViews, setLocalViews] = (0, import_react8.useState)([]);
37248
- const [defaultSnapshot, setDefaultSnapshot] = (0, import_react8.useState)(snapshot);
37249
- const [activeId, setActiveId] = (0, import_react8.useState)("default");
37250
- const [namingId, setNamingId] = (0, import_react8.useState)(null);
37403
+ const [localViews, setLocalViews] = (0, import_react9.useState)([]);
37404
+ const [defaultSnapshot, setDefaultSnapshot] = (0, import_react9.useState)(snapshot);
37405
+ const [activeId, setActiveId] = (0, import_react9.useState)("default");
37406
+ const [namingId, setNamingId] = (0, import_react9.useState)(null);
37251
37407
  const saved = store ? store.views : localViews;
37252
37408
  const write = (next) => store ? store.onChange(next) : setLocalViews(next);
37253
37409
  const tabs = [{ id: "default", label: "Default view", snapshot: defaultSnapshot }, ...saved];
37254
37410
  const stashed = () => saved.map((tab) => tab.id === activeId && !same(tab.snapshot, snapshot) ? { ...tab, snapshot } : tab);
37255
37411
  const activeSaved = saved.find((tab) => tab.id === activeId);
37256
- (0, import_react8.useEffect)(() => {
37412
+ (0, import_react9.useEffect)(() => {
37257
37413
  if (store && activeSaved && !same(activeSaved.snapshot, snapshot)) write(stashed());
37258
37414
  }, [snapshot]);
37259
37415
  const select = (id) => {
@@ -38474,16 +38630,16 @@ var React17 = __toESM(require("react"), 1);
38474
38630
  var React15 = __toESM(require("react"), 1);
38475
38631
 
38476
38632
  // src/use-scroll-fade.ts
38477
- var import_react9 = require("react");
38633
+ var import_react10 = require("react");
38478
38634
  var EPSILON = 2;
38479
38635
  function useScrollFade() {
38480
- const [state, setState] = (0, import_react9.useState)({
38636
+ const [state, setState] = (0, import_react10.useState)({
38481
38637
  top: false,
38482
38638
  bottom: false
38483
38639
  });
38484
- const nodeRef = (0, import_react9.useRef)(null);
38485
- const cleanupRef = (0, import_react9.useRef)(null);
38486
- const measure = (0, import_react9.useCallback)(() => {
38640
+ const nodeRef = (0, import_react10.useRef)(null);
38641
+ const cleanupRef = (0, import_react10.useRef)(null);
38642
+ const measure = (0, import_react10.useCallback)(() => {
38487
38643
  const el = nodeRef.current;
38488
38644
  if (!el) return;
38489
38645
  const overflowing = el.scrollHeight - el.clientHeight > EPSILON;
@@ -38495,7 +38651,7 @@ function useScrollFade() {
38495
38651
  (prev) => prev.top === next.top && prev.bottom === next.bottom ? prev : next
38496
38652
  );
38497
38653
  }, []);
38498
- const ref = (0, import_react9.useCallback)(
38654
+ const ref = (0, import_react10.useCallback)(
38499
38655
  (node) => {
38500
38656
  cleanupRef.current?.();
38501
38657
  cleanupRef.current = null;
@@ -38515,7 +38671,7 @@ function useScrollFade() {
38515
38671
  },
38516
38672
  [measure]
38517
38673
  );
38518
- (0, import_react9.useEffect)(() => () => cleanupRef.current?.(), []);
38674
+ (0, import_react10.useEffect)(() => () => cleanupRef.current?.(), []);
38519
38675
  return {
38520
38676
  ref,
38521
38677
  state,
@@ -38755,7 +38911,7 @@ var ContextMenuShortcut = ({
38755
38911
  ContextMenuShortcut.displayName = "ContextMenuShortcut";
38756
38912
 
38757
38913
  // src/data-table/LayeredFilterBuilder.tsx
38758
- var import_react10 = require("react");
38914
+ var import_react11 = require("react");
38759
38915
 
38760
38916
  // src/popover.tsx
38761
38917
  var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"), 1);
@@ -38819,8 +38975,8 @@ function LayeredFilterBuilder({
38819
38975
  maxRules = 20,
38820
38976
  label = "Advanced filters"
38821
38977
  }) {
38822
- const [open, setOpen] = (0, import_react10.useState)(false);
38823
- const [draggedIndex, setDraggedIndex] = (0, import_react10.useState)(null);
38978
+ const [open, setOpen] = (0, import_react11.useState)(false);
38979
+ const [draggedIndex, setDraggedIndex] = (0, import_react11.useState)(null);
38824
38980
  if (fields.length === 0) return null;
38825
38981
  const updateRule = (index, patch) => {
38826
38982
  onChange(
@@ -40853,7 +41009,7 @@ function WorkspaceWindowSlot({ onNode, sessionKey, onClose }) {
40853
41009
  }
40854
41010
 
40855
41011
  // src/tap-target/tap-target-button.tsx
40856
- var import_react13 = require("react");
41012
+ var import_react14 = require("react");
40857
41013
 
40858
41014
  // src/tap-target/cn.ts
40859
41015
  function cn2(...values) {
@@ -40861,7 +41017,7 @@ function cn2(...values) {
40861
41017
  }
40862
41018
 
40863
41019
  // src/tap-target/tap-target-guard.ts
40864
- var import_react11 = require("react");
41020
+ var import_react12 = require("react");
40865
41021
  var GUARD_SLOT = /* @__PURE__ */ Symbol.for("@ai-matrx/tap-target:guard");
40866
41022
  function guardOn() {
40867
41023
  return globalThis[GUARD_SLOT] === true;
@@ -41122,8 +41278,8 @@ function assignRef(ref, value) {
41122
41278
  else if (ref) ref.current = value;
41123
41279
  }
41124
41280
  function useTapGuardRef(forwarded, propViolation) {
41125
- const current = (0, import_react11.useRef)(null);
41126
- return (0, import_react11.useCallback)(
41281
+ const current = (0, import_react12.useRef)(null);
41282
+ return (0, import_react12.useCallback)(
41127
41283
  (node) => {
41128
41284
  assignRef(forwarded, node);
41129
41285
  if (current.current && current.current !== node) mounted.delete(current.current);
@@ -41144,7 +41300,7 @@ function useTapGuardRef(forwarded, propViolation) {
41144
41300
  }
41145
41301
 
41146
41302
  // src/tap-target/tap-features.tsx
41147
- var import_react12 = require("react");
41303
+ var import_react13 = require("react");
41148
41304
  var import_jsx_runtime35 = require("react/jsx-runtime");
41149
41305
  var TAP_TONE_CLASS = {
41150
41306
  default: "text-foreground",
@@ -41186,7 +41342,7 @@ function matchesShortcut(e, shortcut) {
41186
41342
  return e.key.toLowerCase() === p.key;
41187
41343
  }
41188
41344
  function useTapShortcut(shortcut, getNode, enabled) {
41189
- (0, import_react12.useEffect)(() => {
41345
+ (0, import_react13.useEffect)(() => {
41190
41346
  if (!shortcut || !enabled) return;
41191
41347
  const onKey = (e) => {
41192
41348
  if (!matchesShortcut(e, shortcut)) return;
@@ -41261,8 +41417,8 @@ function IconContent({
41261
41417
  className
41262
41418
  }) {
41263
41419
  if (icon) {
41264
- if ((0, import_react13.isValidElement)(icon)) {
41265
- return (0, import_react13.cloneElement)(icon, {
41420
+ if ((0, import_react14.isValidElement)(icon)) {
41421
+ return (0, import_react14.cloneElement)(icon, {
41266
41422
  className: cn2(className, icon.props.className)
41267
41423
  });
41268
41424
  }
@@ -41371,15 +41527,15 @@ function useTapTarget({
41371
41527
  buttonRef,
41372
41528
  propViolation
41373
41529
  );
41374
- const nodeRef = (0, import_react13.useRef)(null);
41375
- const triggerRef = (0, import_react13.useCallback)(
41530
+ const nodeRef = (0, import_react14.useRef)(null);
41531
+ const triggerRef = (0, import_react14.useCallback)(
41376
41532
  (node) => {
41377
41533
  nodeRef.current = node;
41378
41534
  guardRef(node);
41379
41535
  },
41380
41536
  [guardRef]
41381
41537
  );
41382
- const getNode = (0, import_react13.useCallback)(() => nodeRef.current, []);
41538
+ const getNode = (0, import_react14.useCallback)(() => nodeRef.current, []);
41383
41539
  useTapShortcut(shortcut, getNode, !isDisabled && !loading);
41384
41540
  const toneColor = tone ? TAP_TONE_CLASS[tone] : pressed && !colorClassName ? TAP_TONE_CLASS.primary : null;
41385
41541
  if (toneColor) {
@@ -41569,7 +41725,7 @@ function withTooltip(trigger, {
41569
41725
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TooltipContent, { side: tooltipSide, align: tooltipAlign, children: tooltipBody(label, shortcut) })
41570
41726
  ] });
41571
41727
  }
41572
- var TapTargetButton = (0, import_react13.forwardRef)(function TapTargetButton2({
41728
+ var TapTargetButton = (0, import_react14.forwardRef)(function TapTargetButton2({
41573
41729
  icon,
41574
41730
  children,
41575
41731
  strokeWidth = 2,
@@ -41618,7 +41774,7 @@ var TapTargetButton = (0, import_react13.forwardRef)(function TapTargetButton2({
41618
41774
  buttonRef: ref
41619
41775
  });
41620
41776
  });
41621
- var TapTargetButtonTransparent = (0, import_react13.forwardRef)(function TapTargetButtonTransparent2({
41777
+ var TapTargetButtonTransparent = (0, import_react14.forwardRef)(function TapTargetButtonTransparent2({
41622
41778
  icon,
41623
41779
  children,
41624
41780
  strokeWidth = 2,
@@ -41667,7 +41823,7 @@ var TapTargetButtonTransparent = (0, import_react13.forwardRef)(function TapTarg
41667
41823
  buttonRef: ref
41668
41824
  });
41669
41825
  });
41670
- var TapTargetButtonOutline = (0, import_react13.forwardRef)(function TapTargetButtonOutline2({
41826
+ var TapTargetButtonOutline = (0, import_react14.forwardRef)(function TapTargetButtonOutline2({
41671
41827
  icon,
41672
41828
  children,
41673
41829
  strokeWidth = 2,
@@ -41717,7 +41873,7 @@ var TapTargetButtonOutline = (0, import_react13.forwardRef)(function TapTargetBu
41717
41873
  buttonRef: ref
41718
41874
  });
41719
41875
  });
41720
- var TapTargetButtonSolid = (0, import_react13.forwardRef)(function TapTargetButtonSolid2({
41876
+ var TapTargetButtonSolid = (0, import_react14.forwardRef)(function TapTargetButtonSolid2({
41721
41877
  icon,
41722
41878
  children,
41723
41879
  strokeWidth = 2,
@@ -41784,10 +41940,10 @@ function solidClasses(tone, bgColor, iconColor, hoverBgColor, activeBgColor) {
41784
41940
  labelClassName: `matrx-tap-label ${glyph}`
41785
41941
  };
41786
41942
  }
41787
- var TapTargetButtonDestructive = (0, import_react13.forwardRef)(function TapTargetButtonDestructive2({ tone = "destructive", ...rest }, ref) {
41943
+ var TapTargetButtonDestructive = (0, import_react14.forwardRef)(function TapTargetButtonDestructive2({ tone = "destructive", ...rest }, ref) {
41788
41944
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(TapTargetButtonSolid, { ref, tone, ...rest });
41789
41945
  });
41790
- var TapTargetButtonForGroup = (0, import_react13.forwardRef)(function TapTargetButtonForGroup2({
41946
+ var TapTargetButtonForGroup = (0, import_react14.forwardRef)(function TapTargetButtonForGroup2({
41791
41947
  icon,
41792
41948
  children,
41793
41949
  strokeWidth = 2,
@@ -43010,9 +43166,9 @@ function useCopySubsetVariant() {
43010
43166
  }
43011
43167
 
43012
43168
  // src/data-table/clipping.ts
43013
- var import_react14 = require("react");
43169
+ var import_react15 = require("react");
43014
43170
  function useClippedContentGuard(ref, options) {
43015
- (0, import_react14.useEffect)(() => {
43171
+ (0, import_react15.useEffect)(() => {
43016
43172
  if (!options.enabled || !ref.current) return;
43017
43173
  const node = ref.current;
43018
43174
  const check2 = () => {
@@ -43026,7 +43182,7 @@ function useClippedContentGuard(ref, options) {
43026
43182
  }
43027
43183
 
43028
43184
  // src/data-table/url-state.ts
43029
- var import_react15 = require("react");
43185
+ var import_react16 = require("react");
43030
43186
  var import_url_state = require("@ai-matrx/kit/url-state");
43031
43187
  function parseSort(raw) {
43032
43188
  if (!raw) return null;
@@ -43078,11 +43234,11 @@ function useTableUrlState(options) {
43078
43234
  textHistory = "session"
43079
43235
  } = options;
43080
43236
  const prefix = tableUrlParamPrefix(tableId);
43081
- const key = (0, import_react15.useCallback)((name) => `${prefix}.${name}`, [prefix]);
43237
+ const key = (0, import_react16.useCallback)((name) => `${prefix}.${name}`, [prefix]);
43082
43238
  const defaultSortId = defaultSort?.id;
43083
43239
  const defaultSortDirection = defaultSort?.direction;
43084
43240
  const searchParams = (0, import_url_state.useUrlSearchParams)();
43085
- const readState = (0, import_react15.useCallback)(
43241
+ const readState = (0, import_react16.useCallback)(
43086
43242
  (params) => {
43087
43243
  const initialSort = defaultSortId && defaultSortDirection ? { id: defaultSortId, direction: defaultSortDirection } : null;
43088
43244
  return {
@@ -43103,9 +43259,9 @@ function useTableUrlState(options) {
43103
43259
  [defaultPageSize, defaultSortDirection, defaultSortId, key]
43104
43260
  );
43105
43261
  const state = readState(searchParams);
43106
- const lastTextWriteAt = (0, import_react15.useRef)(0);
43107
- const [debouncedSearch, setDebouncedSearch] = (0, import_react15.useState)(state.search);
43108
- (0, import_react15.useEffect)(() => {
43262
+ const lastTextWriteAt = (0, import_react16.useRef)(0);
43263
+ const [debouncedSearch, setDebouncedSearch] = (0, import_react16.useState)(state.search);
43264
+ (0, import_react16.useEffect)(() => {
43109
43265
  if (state.search === debouncedSearch) return;
43110
43266
  const timer = window.setTimeout(
43111
43267
  () => setDebouncedSearch(state.search),
@@ -43113,7 +43269,7 @@ function useTableUrlState(options) {
43113
43269
  );
43114
43270
  return () => window.clearTimeout(timer);
43115
43271
  }, [state.search, debouncedSearch, searchDebounceMs]);
43116
- const writeState = (0, import_react15.useCallback)(
43272
+ const writeState = (0, import_react16.useCallback)(
43117
43273
  (nextState, mode = history) => {
43118
43274
  const params = new URLSearchParams(window.location.search);
43119
43275
  const setOrDelete = (name, value) => {
@@ -43164,7 +43320,7 @@ function useTableUrlState(options) {
43164
43320
  },
43165
43321
  [defaultPageSize, defaultSortDirection, defaultSortId, history, key]
43166
43322
  );
43167
- const onStateChange = (0, import_react15.useCallback)(
43323
+ const onStateChange = (0, import_react16.useCallback)(
43168
43324
  (next) => {
43169
43325
  const changed = Object.keys(next).filter(
43170
43326
  (name) => JSON.stringify(next[name]) !== JSON.stringify(state[name])
@@ -43182,7 +43338,7 @@ function useTableUrlState(options) {
43182
43338
  },
43183
43339
  [history, state, textHistory, writeState]
43184
43340
  );
43185
- const reset = (0, import_react15.useCallback)(() => {
43341
+ const reset = (0, import_react16.useCallback)(() => {
43186
43342
  const dSort = defaultSortId && defaultSortDirection ? { id: defaultSortId, direction: defaultSortDirection } : null;
43187
43343
  const next = {
43188
43344
  page: 1,
@@ -43198,7 +43354,7 @@ function useTableUrlState(options) {
43198
43354
  writeState(next);
43199
43355
  setDebouncedSearch("");
43200
43356
  }, [defaultPageSize, defaultSortDirection, defaultSortId, writeState]);
43201
- const queryState = (0, import_react15.useMemo)(
43357
+ const queryState = (0, import_react16.useMemo)(
43202
43358
  () => state.search === debouncedSearch ? state : { ...state, search: debouncedSearch, page: 1 },
43203
43359
  [state, debouncedSearch]
43204
43360
  );
@@ -43209,14 +43365,14 @@ function useTableUrlState(options) {
43209
43365
  var import_url_state3 = require("@ai-matrx/kit/url-state");
43210
43366
 
43211
43367
  // src/data-table/RowAlchemyLauncher.tsx
43212
- var import_react16 = require("react");
43368
+ var import_react17 = require("react");
43213
43369
  var import_jsx_runtime40 = require("react/jsx-runtime");
43214
43370
  function MatrxTableRowAlchemyProvider({ copy, placement, controls, children }) {
43215
- const controller = (0, import_react16.useRef)(null);
43371
+ const controller = (0, import_react17.useRef)(null);
43216
43372
  const { CopyControls } = useMatrxDataTableHost();
43217
- const [active, setActive] = (0, import_react16.useState)(false);
43218
- const [fallback, setFallback] = (0, import_react16.useState)(false);
43219
- (0, import_react16.useEffect)(() => {
43373
+ const [active, setActive] = (0, import_react17.useState)(false);
43374
+ const [fallback, setFallback] = (0, import_react17.useState)(false);
43375
+ (0, import_react17.useEffect)(() => {
43220
43376
  if (placement !== "menu" || active) return;
43221
43377
  const timer = window.setTimeout(() => {
43222
43378
  if (!active) {
@@ -43226,11 +43382,11 @@ function MatrxTableRowAlchemyProvider({ copy, placement, controls, children }) {
43226
43382
  }, 0);
43227
43383
  return () => window.clearTimeout(timer);
43228
43384
  }, [active, placement]);
43229
- const activate = (0, import_react16.useCallback)(() => setActive(true), []);
43230
- const mountMenu = (0, import_react16.useCallback)((target, onClose, restoreFocus) => {
43385
+ const activate = (0, import_react17.useCallback)(() => setActive(true), []);
43386
+ const mountMenu = (0, import_react17.useCallback)((target, onClose, restoreFocus) => {
43231
43387
  controller.current?.mountPalette(target, onClose, restoreFocus);
43232
43388
  }, []);
43233
- const prepare = (0, import_react16.useCallback)(async (restoreFocus) => {
43389
+ const prepare = (0, import_react17.useCallback)(async (restoreFocus) => {
43234
43390
  if (copy.disabled) throw new Error("Alchemy is disabled for this record.");
43235
43391
  if (!controller.current) throw new Error("Alchemy is unavailable because its launcher did not mount.");
43236
43392
  await controller.current.preparePrimary(restoreFocus ? { restoreFocus } : void 0);
@@ -43251,7 +43407,7 @@ function MatrxTableRowAlchemyProvider({ copy, placement, controls, children }) {
43251
43407
  }
43252
43408
 
43253
43409
  // src/data-table/ColumnHeaderCell.tsx
43254
- var import_react17 = require("react");
43410
+ var import_react18 = require("react");
43255
43411
  var import_core = require("@dnd-kit/core");
43256
43412
 
43257
43413
  // src/command.tsx
@@ -43522,7 +43678,7 @@ function HeaderMenuItems({
43522
43678
  onDone,
43523
43679
  depth = 0
43524
43680
  }) {
43525
- const [openSubmenu, setOpenSubmenu] = (0, import_react17.useState)(null);
43681
+ const [openSubmenu, setOpenSubmenu] = (0, import_react18.useState)(null);
43526
43682
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: cn("flex flex-col gap-0.5", depth > 0 && "ml-3 border-l border-border pl-1"), role: "group", children: items.map((item) => {
43527
43683
  const disabled = Boolean(item.disabledReason);
43528
43684
  const hasSubmenu = Boolean(item.submenu && item.submenu.length > 0);
@@ -43563,7 +43719,7 @@ function HeaderMenuItems({
43563
43719
  ] }, item.id);
43564
43720
  }) });
43565
43721
  }
43566
- var HeaderButton = (0, import_react17.forwardRef)(({ dragDescription, "aria-describedby": tooltipDescription, ...props }, ref) => {
43722
+ var HeaderButton = (0, import_react18.forwardRef)(({ dragDescription, "aria-describedby": tooltipDescription, ...props }, ref) => {
43567
43723
  const descriptions = [tooltipDescription, dragDescription].filter((value) => Boolean(value)).join(" ");
43568
43724
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
43569
43725
  "button",
@@ -43638,18 +43794,18 @@ function ColumnHeaderCell({
43638
43794
  const filterActive = isColumnFilterActive(filterValue);
43639
43795
  const deferredFilter = filterKind === "text" || filterApplyLabel !== void 0 || Boolean(filterShowCancel) || filterFooterHint !== void 0;
43640
43796
  const showFilterCancel = filterShowCancel ?? filterKind === "text";
43641
- const [filterOpen, setFilterOpen] = (0, import_react17.useState)(false);
43642
- const [pendingNegation, setPendingNegation] = (0, import_react17.useState)(false);
43643
- const [draftFilter, setDraftFilter] = (0, import_react17.useState)(filterValue);
43644
- (0, import_react17.useEffect)(() => {
43797
+ const [filterOpen, setFilterOpen] = (0, import_react18.useState)(false);
43798
+ const [pendingNegation, setPendingNegation] = (0, import_react18.useState)(false);
43799
+ const [draftFilter, setDraftFilter] = (0, import_react18.useState)(filterValue);
43800
+ (0, import_react18.useEffect)(() => {
43645
43801
  if (!filterOpen) {
43646
43802
  setDraftFilter(filterValue);
43647
43803
  setPendingNegation(filterValue?.negated ?? false);
43648
43804
  }
43649
43805
  }, [filterOpen, filterValue]);
43650
- const notifyOpen = (0, import_react17.useRef)(onFilterOpen);
43806
+ const notifyOpen = (0, import_react18.useRef)(onFilterOpen);
43651
43807
  notifyOpen.current = onFilterOpen;
43652
- (0, import_react17.useEffect)(() => {
43808
+ (0, import_react18.useEffect)(() => {
43653
43809
  if (filterOpen) notifyOpen.current?.();
43654
43810
  }, [filterOpen]);
43655
43811
  const applyFilter = () => {
@@ -44146,10 +44302,10 @@ function FacetChecklist({
44146
44302
  value,
44147
44303
  onChange
44148
44304
  }) {
44149
- const [query, setQuery] = (0, import_react17.useState)("");
44305
+ const [query, setQuery] = (0, import_react18.useState)("");
44150
44306
  const selected = value?.kind === "select" ? (value.values ?? (value.value && value.value !== "__all__" ? [value.value] : [])).map((candidate) => candidate === SELECT_EMPTY_VALUE ? "" : candidate) : [];
44151
44307
  const selectedSet = new Set(selected);
44152
- const rows = (0, import_react17.useMemo)(() => {
44308
+ const rows = (0, import_react18.useMemo)(() => {
44153
44309
  if (!facets) return [];
44154
44310
  const listed = facets.values.map((entry) => ({
44155
44311
  value: entry.value,
@@ -44323,8 +44479,8 @@ function SearchableSelectFilter({
44323
44479
  single = false,
44324
44480
  allowCustom = false
44325
44481
  }) {
44326
- const [query, setQuery] = (0, import_react17.useState)("");
44327
- const filtered = (0, import_react17.useMemo)(() => {
44482
+ const [query, setQuery] = (0, import_react18.useState)("");
44483
+ const filtered = (0, import_react18.useMemo)(() => {
44328
44484
  const q = query.trim().toLowerCase();
44329
44485
  if (!q) return options;
44330
44486
  return options.filter(
@@ -44453,11 +44609,11 @@ function NumberFilterBody({
44453
44609
  }) {
44454
44610
  const min = value?.kind === "number" ? value.min : void 0;
44455
44611
  const max = value?.kind === "number" ? value.max : void 0;
44456
- const [op, setOp] = (0, import_react17.useState)(() => numberOpOf(value));
44457
- const [minText, setMinText] = (0, import_react17.useState)(
44612
+ const [op, setOp] = (0, import_react18.useState)(() => numberOpOf(value));
44613
+ const [minText, setMinText] = (0, import_react18.useState)(
44458
44614
  value?.kind === "number" && value.op === "lt" && max !== void 0 ? String(max) : min !== void 0 ? String(min) : ""
44459
44615
  );
44460
- const [maxText, setMaxText] = (0, import_react17.useState)(max !== void 0 ? String(max) : "");
44616
+ const [maxText, setMaxText] = (0, import_react18.useState)(max !== void 0 ? String(max) : "");
44461
44617
  const active = value?.kind === "number" && (value.op === "empty" || value.op === "not_empty" || min !== void 0 || max !== void 0);
44462
44618
  const emit2 = (nextOp, lowRaw, highRaw) => {
44463
44619
  if (nextOp === "empty" || nextOp === "not_empty") {
@@ -44663,7 +44819,7 @@ function MatrxTableGroupHeaderRow({
44663
44819
  }
44664
44820
 
44665
44821
  // src/data-table/DrillAnswerTable.tsx
44666
- var import_react18 = require("react");
44822
+ var import_react19 = require("react");
44667
44823
  var import_format10 = require("@ai-matrx/kit/format");
44668
44824
 
44669
44825
  // src/dropdown-menu.tsx
@@ -45889,12 +46045,12 @@ function MatrxDrillAnswerTable({
45889
46045
  attributes
45890
46046
  }) {
45891
46047
  const host = useMatrxDataTableHost();
45892
- const tableId = `drill-answer-${(0, import_react18.useId)()}`;
45893
- const [query, setQuery] = (0, import_react18.useState)("");
45894
- const [peek, setPeek] = (0, import_react18.useState)(null);
45895
- const [collapsed, setCollapsed] = (0, import_react18.useState)(() => /* @__PURE__ */ new Set());
46048
+ const tableId = `drill-answer-${(0, import_react19.useId)()}`;
46049
+ const [query, setQuery] = (0, import_react19.useState)("");
46050
+ const [peek, setPeek] = (0, import_react19.useState)(null);
46051
+ const [collapsed, setCollapsed] = (0, import_react19.useState)(() => /* @__PURE__ */ new Set());
45896
46052
  const selectionFor = JSON.stringify([question.by, question.across ?? null, question.where, question.window ?? null]);
45897
- const [ticked, setTicked] = (0, import_react18.useState)(() => ({ forQuestion: selectionFor, keys: /* @__PURE__ */ new Set() }));
46053
+ const [ticked, setTicked] = (0, import_react19.useState)(() => ({ forQuestion: selectionFor, keys: /* @__PURE__ */ new Set() }));
45898
46054
  const selected = ticked.forQuestion === selectionFor ? ticked.keys : /* @__PURE__ */ new Set();
45899
46055
  const toggleTick = (key) => setTicked(() => {
45900
46056
  const keys2 = new Set(selected);
@@ -45902,12 +46058,12 @@ function MatrxDrillAnswerTable({
45902
46058
  else keys2.add(key);
45903
46059
  return { forQuestion: selectionFor, keys: keys2 };
45904
46060
  });
45905
- const shown = (0, import_react18.useMemo)(
46061
+ const shown = (0, import_react19.useMemo)(
45906
46062
  () => question.show.map((key) => measures.find((m) => m.key === key)).filter((m) => Boolean(m)),
45907
46063
  [question.show, measures]
45908
46064
  );
45909
- const tree = (0, import_react18.useMemo)(() => buildDrillTree(question, answers, measures), [question, answers, measures]);
45910
- const columns = (0, import_react18.useMemo)(
46065
+ const tree = (0, import_react19.useMemo)(() => buildDrillTree(question, answers, measures), [question, answers, measures]);
46066
+ const columns = (0, import_react19.useMemo)(
45911
46067
  () => pivotColumns(question, answers, dimensions, measures, pivotColumnCap ?? MATRX_DRILL_PIVOT_COLUMNS),
45912
46068
  [question, answers, dimensions, measures, pivotColumnCap]
45913
46069
  );
@@ -46087,7 +46243,7 @@ function MatrxDrillAnswerTable({
46087
46243
  const intoLabel = intoRef ? dimensionRefLabel(dimensions, intoRef) : null;
46088
46244
  const drill = () => onQuestionChange(drillInto(scope, node.groups, dimensions, intoRef, paths));
46089
46245
  const records = () => onQuestionChange(drillToRecords(scope, node.groups));
46090
- return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react18.Fragment, { children: [
46246
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react19.Fragment, { children: [
46091
46247
  /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
46092
46248
  MatrxTableGroupHeaderRow,
46093
46249
  {
@@ -46349,7 +46505,7 @@ function DrillExport({
46349
46505
  measures,
46350
46506
  emptyLabel
46351
46507
  }) {
46352
- const [said, setSaid] = (0, import_react18.useState)(null);
46508
+ const [said, setSaid] = (0, import_react19.useState)(null);
46353
46509
  const grid = drillAnswerGrid(question, answers, dimensions, measures, emptyLabel);
46354
46510
  const trail = question.where.map((w) => `${dimensionRefLabel(dimensions, w.dim)}: ${drillValueLabel(dimensions, w.dim, w.value, emptyLabel)}`);
46355
46511
  const copy = async (text, what) => {
@@ -46403,7 +46559,7 @@ function DrillExport({
46403
46559
  }
46404
46560
 
46405
46561
  // src/data-table/DrillControls.tsx
46406
- var import_react19 = require("react");
46562
+ var import_react20 = require("react");
46407
46563
  var import_jsx_runtime46 = require("react/jsx-runtime");
46408
46564
  var NONE = "\0none";
46409
46565
  function refsFree(dimensions, taken) {
@@ -46637,7 +46793,7 @@ function MatrxDrillTrail({
46637
46793
  children: [
46638
46794
  crumbs.map((crumb, i) => {
46639
46795
  const last = i === crumbs.length - 1;
46640
- return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_react19.Fragment, { children: [
46796
+ return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_react20.Fragment, { children: [
46641
46797
  i > 0 ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ChevronRight, { "aria-hidden": "true", className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }) : null,
46642
46798
  last ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
46643
46799
  "span",
@@ -46693,11 +46849,11 @@ function MatrxDrillWindowMenu({
46693
46849
  customRange = true
46694
46850
  }) {
46695
46851
  const label = drillWindowLabel(question.window);
46696
- const [editing, setEditing] = (0, import_react19.useState)(false);
46697
- const toForm = (0, import_react19.useRef)(false);
46852
+ const [editing, setEditing] = (0, import_react20.useState)(false);
46853
+ const toForm = (0, import_react20.useRef)(false);
46698
46854
  const current = question.window ? drillWindowRange(question.window) : null;
46699
- const [from, setFrom] = (0, import_react19.useState)("");
46700
- const [to, setTo] = (0, import_react19.useState)("");
46855
+ const [from, setFrom] = (0, import_react20.useState)("");
46856
+ const [to, setTo] = (0, import_react20.useState)("");
46701
46857
  const isPreset = !question.window || presets.some((p) => p.key === question.window);
46702
46858
  const openCustom = () => {
46703
46859
  setFrom(localInput(current?.from));
@@ -46815,7 +46971,7 @@ function MatrxDrillWindowMenu({
46815
46971
  }
46816
46972
 
46817
46973
  // src/data-table/ColumnResizeHandle.tsx
46818
- var import_react20 = require("react");
46974
+ var import_react21 = require("react");
46819
46975
 
46820
46976
  // src/data-table/column-resize.ts
46821
46977
  var DEFAULT_COLUMN_MIN_WIDTH = 80;
@@ -46857,24 +47013,24 @@ function ColumnResizeHandle({
46857
47013
  onResizeCancel,
46858
47014
  onResizeCommit
46859
47015
  }) {
46860
- const handleRef = (0, import_react20.useRef)(null);
46861
- const activeResizeRef = (0, import_react20.useRef)(null);
46862
- const previewRafRef = (0, import_react20.useRef)(null);
46863
- const queuedWidthRef = (0, import_react20.useRef)(null);
46864
- const keyboardWidthRef = (0, import_react20.useRef)(null);
46865
- const [announcedWidth, setAnnouncedWidth] = (0, import_react20.useState)(null);
47016
+ const handleRef = (0, import_react21.useRef)(null);
47017
+ const activeResizeRef = (0, import_react21.useRef)(null);
47018
+ const previewRafRef = (0, import_react21.useRef)(null);
47019
+ const queuedWidthRef = (0, import_react21.useRef)(null);
47020
+ const keyboardWidthRef = (0, import_react21.useRef)(null);
47021
+ const [announcedWidth, setAnnouncedWidth] = (0, import_react21.useState)(null);
46866
47022
  const bounds = resolveColumnResizeBounds(minWidth, maxWidth);
46867
47023
  const cssVar = columnResizeCssVar(columnId2);
46868
- const readWidth = (0, import_react20.useCallback)(() => {
47024
+ const readWidth = (0, import_react21.useCallback)(() => {
46869
47025
  const header = handleRef.current?.closest("th");
46870
47026
  const measured = header?.getBoundingClientRect().width ?? 0;
46871
47027
  const computed = header ? Number.parseFloat(getComputedStyle(header).width) : 0;
46872
47028
  return clampColumnWidth(measured || computed || keyboardWidthRef.current || bounds.minWidth, bounds);
46873
47029
  }, [bounds]);
46874
- const writePreview = (0, import_react20.useCallback)((width) => {
47030
+ const writePreview = (0, import_react21.useCallback)((width) => {
46875
47031
  tableRef.current?.style.setProperty(cssVar, `${width}px`);
46876
47032
  }, [cssVar, tableRef]);
46877
- const queuePreview = (0, import_react20.useCallback)((width) => {
47033
+ const queuePreview = (0, import_react21.useCallback)((width) => {
46878
47034
  queuedWidthRef.current = width;
46879
47035
  if (previewRafRef.current !== null) return;
46880
47036
  previewRafRef.current = requestAnimationFrame(() => {
@@ -46884,12 +47040,12 @@ function ColumnResizeHandle({
46884
47040
  if (nextWidth !== null) writePreview(nextWidth);
46885
47041
  });
46886
47042
  }, [writePreview]);
46887
- const clearQueuedPreview = (0, import_react20.useCallback)(() => {
47043
+ const clearQueuedPreview = (0, import_react21.useCallback)(() => {
46888
47044
  if (previewRafRef.current !== null) cancelAnimationFrame(previewRafRef.current);
46889
47045
  previewRafRef.current = null;
46890
47046
  queuedWidthRef.current = null;
46891
47047
  }, []);
46892
- const finishPointerResize = (0, import_react20.useCallback)((commit) => {
47048
+ const finishPointerResize = (0, import_react21.useCallback)((commit) => {
46893
47049
  const active = activeResizeRef.current;
46894
47050
  if (!active) return;
46895
47051
  activeResizeRef.current = null;
@@ -46909,7 +47065,7 @@ function ColumnResizeHandle({
46909
47065
  handleRef.current.releasePointerCapture(active.pointerId);
46910
47066
  }
46911
47067
  }, [clearQueuedPreview, columnId2, cssVar, onResizeCancel, onResizeCommit, tableRef, writePreview]);
46912
- (0, import_react20.useEffect)(() => () => clearQueuedPreview(), [clearQueuedPreview]);
47068
+ (0, import_react21.useEffect)(() => () => clearQueuedPreview(), [clearQueuedPreview]);
46913
47069
  const onPointerDown = (event) => {
46914
47070
  if (disabled || event.button !== 0 || !event.isPrimary) return;
46915
47071
  event.preventDefault();
@@ -47274,7 +47430,7 @@ function groupSummary(group, rowNoun = "row") {
47274
47430
  }
47275
47431
 
47276
47432
  // src/data-table/useSpreadsheetGrid.ts
47277
- var import_react21 = require("react");
47433
+ var import_react22 = require("react");
47278
47434
 
47279
47435
  // src/data-table/grid-selection.ts
47280
47436
  function rangeBounds(range, rowIds, fieldNames) {
@@ -48002,41 +48158,41 @@ var LAYERS_THE_GRID_OPENS = `[data-radix-popper-content-wrapper], [data-radix-po
48002
48158
  var OPEN_LAYERS = `[role="menu"], [role="dialog"], [role="alertdialog"], [role="listbox"]`;
48003
48159
  var READ_ONLY_REASON = "This table is view-only \u2014 you can select and copy, but not change cells.";
48004
48160
  function useSpreadsheetGrid(options) {
48005
- const [range, setRange] = (0, import_react21.useState)(null);
48006
- const [fillTarget, setFillTarget] = (0, import_react21.useState)(null);
48007
- const [stack, setStack] = (0, import_react21.useState)(() => createUndoStack(options?.undoDepth ?? 100));
48008
- const draggingRef = (0, import_react21.useRef)(null);
48009
- const catcherRef = (0, import_react21.useRef)(null);
48010
- const composingRef = (0, import_react21.useRef)(false);
48011
- const optionsRef = (0, import_react21.useRef)(options);
48161
+ const [range, setRange] = (0, import_react22.useState)(null);
48162
+ const [fillTarget, setFillTarget] = (0, import_react22.useState)(null);
48163
+ const [stack, setStack] = (0, import_react22.useState)(() => createUndoStack(options?.undoDepth ?? 100));
48164
+ const draggingRef = (0, import_react22.useRef)(null);
48165
+ const catcherRef = (0, import_react22.useRef)(null);
48166
+ const composingRef = (0, import_react22.useRef)(false);
48167
+ const optionsRef = (0, import_react22.useRef)(options);
48012
48168
  optionsRef.current = options;
48013
48169
  const rowIds = options?.rowIds ?? [];
48014
- const columnIds = (0, import_react21.useMemo)(
48170
+ const columnIds = (0, import_react22.useMemo)(
48015
48171
  () => options ? options.columnIds.filter((id) => id !== "") : [],
48016
48172
  [options]
48017
48173
  );
48018
- (0, import_react21.useEffect)(() => {
48174
+ (0, import_react22.useEffect)(() => {
48019
48175
  if (!range) return;
48020
48176
  const rowSet = new Set(rowIds);
48021
48177
  const colSet = new Set(columnIds);
48022
48178
  const alive = rowSet.has(range.anchor.rowId) && rowSet.has(range.focus.rowId) && colSet.has(range.anchor.fieldName) && colSet.has(range.focus.fieldName);
48023
48179
  if (!alive) setRange(null);
48024
48180
  }, [range, rowIds, columnIds]);
48025
- const bounds = (0, import_react21.useMemo)(
48181
+ const bounds = (0, import_react22.useMemo)(
48026
48182
  () => range ? rangeBounds(range, rowIds, columnIds) : null,
48027
48183
  [range, rowIds, columnIds]
48028
48184
  );
48029
- const rowIndexById = (0, import_react21.useMemo)(() => {
48185
+ const rowIndexById = (0, import_react22.useMemo)(() => {
48030
48186
  const map = /* @__PURE__ */ new Map();
48031
48187
  for (let i = 0; i < rowIds.length; i += 1) map.set(rowIds[i], i);
48032
48188
  return map;
48033
48189
  }, [rowIds]);
48034
- const columnIndexById = (0, import_react21.useMemo)(() => {
48190
+ const columnIndexById = (0, import_react22.useMemo)(() => {
48035
48191
  const map = /* @__PURE__ */ new Map();
48036
48192
  for (let i = 0; i < columnIds.length; i += 1) map.set(columnIds[i], i);
48037
48193
  return map;
48038
48194
  }, [columnIds]);
48039
- const screenPatches = (0, import_react21.useCallback)(
48195
+ const screenPatches = (0, import_react22.useCallback)(
48040
48196
  (patches) => {
48041
48197
  const validate = optionsRef.current?.validateCell;
48042
48198
  if (!validate) return { accepted: patches, refusals: [] };
@@ -48056,7 +48212,7 @@ function useSpreadsheetGrid(options) {
48056
48212
  },
48057
48213
  []
48058
48214
  );
48059
- const applyPatches = (0, import_react21.useCallback)(
48215
+ const applyPatches = (0, import_react22.useCallback)(
48060
48216
  async (patches, intent, label) => {
48061
48217
  const current = optionsRef.current;
48062
48218
  if (!current || patches.length === 0) return;
@@ -48074,21 +48230,21 @@ function useSpreadsheetGrid(options) {
48074
48230
  },
48075
48231
  []
48076
48232
  );
48077
- const refuseWrite = (0, import_react21.useCallback)(() => {
48233
+ const refuseWrite = (0, import_react22.useCallback)(() => {
48078
48234
  const current = optionsRef.current;
48079
48235
  if (!current) return true;
48080
48236
  if (!current.readOnly && current.onPatch) return false;
48081
48237
  current.notify?.(current.readOnlyReason ?? READ_ONLY_REASON);
48082
48238
  return true;
48083
48239
  }, []);
48084
- const readValueAt = (0, import_react21.useCallback)((rowIndex, columnIndex) => {
48240
+ const readValueAt = (0, import_react22.useCallback)((rowIndex, columnIndex) => {
48085
48241
  const current = optionsRef.current;
48086
48242
  const rowId = current?.rowIds[rowIndex];
48087
48243
  const columnId2 = current?.columnIds[columnIndex];
48088
48244
  if (!current || rowId === void 0 || columnId2 === void 0) return null;
48089
48245
  return current.valueAt(rowId, columnId2);
48090
48246
  }, []);
48091
- const fillRequestBase = (0, import_react21.useCallback)(() => {
48247
+ const fillRequestBase = (0, import_react22.useCallback)(() => {
48092
48248
  const current = optionsRef.current;
48093
48249
  if (!current) return null;
48094
48250
  return {
@@ -48098,7 +48254,7 @@ function useSpreadsheetGrid(options) {
48098
48254
  isColumnWritable: current.isColumnWritable
48099
48255
  };
48100
48256
  }, [readValueAt]);
48101
- const announceSkips = (0, import_react21.useCallback)(
48257
+ const announceSkips = (0, import_react22.useCallback)(
48102
48258
  (skipped, summary) => {
48103
48259
  const current = optionsRef.current;
48104
48260
  if (!current?.notify) return;
@@ -48113,7 +48269,7 @@ function useSpreadsheetGrid(options) {
48113
48269
  },
48114
48270
  []
48115
48271
  );
48116
- const doFillDown = (0, import_react21.useCallback)(async () => {
48272
+ const doFillDown = (0, import_react22.useCallback)(async () => {
48117
48273
  if (refuseWrite()) return;
48118
48274
  const base = fillRequestBase();
48119
48275
  if (!base || !bounds) return;
@@ -48125,7 +48281,7 @@ function useSpreadsheetGrid(options) {
48125
48281
  await applyPatches(screened.accepted, "fill-down", "Filled down");
48126
48282
  announceSkips([...result.skipped, ...screened.refusals], result.summary);
48127
48283
  }, [fillRequestBase, bounds, applyPatches, announceSkips, screenPatches, refuseWrite]);
48128
- const doClear = (0, import_react21.useCallback)(async () => {
48284
+ const doClear = (0, import_react22.useCallback)(async () => {
48129
48285
  if (refuseWrite()) return;
48130
48286
  const current = optionsRef.current;
48131
48287
  if (!current || !bounds) return;
@@ -48154,7 +48310,7 @@ function useSpreadsheetGrid(options) {
48154
48310
  `Cleared ${screened.accepted.length} cells.`
48155
48311
  );
48156
48312
  }, [bounds, applyPatches, announceSkips, screenPatches, refuseWrite]);
48157
- const doUndo = (0, import_react21.useCallback)(async () => {
48313
+ const doUndo = (0, import_react22.useCallback)(async () => {
48158
48314
  if (refuseWrite()) return;
48159
48315
  const taken = popUndo(stack);
48160
48316
  if (!taken.entry) return;
@@ -48162,14 +48318,14 @@ function useSpreadsheetGrid(options) {
48162
48318
  await applyPatches(taken.entry.undo, "undo", taken.entry.label);
48163
48319
  optionsRef.current?.notify?.(taken.entry.label);
48164
48320
  }, [stack, applyPatches, refuseWrite]);
48165
- const doRedo = (0, import_react21.useCallback)(async () => {
48321
+ const doRedo = (0, import_react22.useCallback)(async () => {
48166
48322
  if (refuseWrite()) return;
48167
48323
  const taken = popRedo(stack);
48168
48324
  if (!taken.entry) return;
48169
48325
  setStack(taken.stack);
48170
48326
  await applyPatches(taken.entry.redo, "redo", taken.entry.label);
48171
48327
  }, [stack, applyPatches, refuseWrite]);
48172
- const move = (0, import_react21.useCallback)(
48328
+ const move = (0, import_react22.useCallback)(
48173
48329
  (direction, extend) => {
48174
48330
  setRange((previous) => {
48175
48331
  const from = previous ? extend ? previous.focus : previous.anchor : null;
@@ -48181,31 +48337,31 @@ function useSpreadsheetGrid(options) {
48181
48337
  },
48182
48338
  [rowIds, columnIds]
48183
48339
  );
48184
- const rowIdsRef = (0, import_react21.useRef)(rowIds);
48340
+ const rowIdsRef = (0, import_react22.useRef)(rowIds);
48185
48341
  rowIdsRef.current = rowIds;
48186
- const columnIdsRef = (0, import_react21.useRef)(columnIds);
48342
+ const columnIdsRef = (0, import_react22.useRef)(columnIds);
48187
48343
  columnIdsRef.current = columnIds;
48188
- const rangeRef = (0, import_react21.useRef)(range);
48344
+ const rangeRef = (0, import_react22.useRef)(range);
48189
48345
  rangeRef.current = range;
48190
- const focusGrid = (0, import_react21.useCallback)(() => {
48346
+ const focusGrid = (0, import_react22.useCallback)(() => {
48191
48347
  const catcher = catcherRef.current;
48192
48348
  if (catcher && catcher.isConnected) {
48193
48349
  catcher.focus({ preventScroll: true });
48194
48350
  return;
48195
48351
  }
48196
48352
  }, []);
48197
- const focusIsLost = (0, import_react21.useCallback)(() => {
48353
+ const focusIsLost = (0, import_react22.useCallback)(() => {
48198
48354
  if (typeof document === "undefined") return false;
48199
48355
  const active = document.activeElement;
48200
48356
  return !active || active === document.body || active === document.documentElement || !active.isConnected;
48201
48357
  }, []);
48202
- const focusIsLostOrOurs = (0, import_react21.useCallback)(() => {
48358
+ const focusIsLostOrOurs = (0, import_react22.useCallback)(() => {
48203
48359
  if (focusIsLost()) return true;
48204
48360
  const container = catcherRef.current?.closest('[data-matrx-table-spreadsheet="true"]');
48205
48361
  const active = typeof document === "undefined" ? null : document.activeElement;
48206
48362
  return Boolean(container && active && container.contains(active));
48207
48363
  }, [focusIsLost]);
48208
- const endEdit = (0, import_react21.useCallback)(
48364
+ const endEdit = (0, import_react22.useCallback)(
48209
48365
  (exit = "stay", from = null, how = "keyboard") => {
48210
48366
  const move2 = exit === "down" ? "down" : exit === "up" ? "up" : exit === "right" ? "nextCell" : exit === "left" ? "prevCell" : null;
48211
48367
  const at2 = from ? { rowId: from.rowId, fieldName: from.columnId } : null;
@@ -48228,7 +48384,7 @@ function useSpreadsheetGrid(options) {
48228
48384
  },
48229
48385
  [focusGrid, focusIsLost, focusIsLostOrOurs]
48230
48386
  );
48231
- const select = (0, import_react21.useCallback)(
48387
+ const select = (0, import_react22.useCallback)(
48232
48388
  (anchor, focus) => {
48233
48389
  const a = { rowId: anchor.rowId, fieldName: anchor.columnId };
48234
48390
  const f = focus ? { rowId: focus.rowId, fieldName: focus.columnId } : a;
@@ -48236,7 +48392,7 @@ function useSpreadsheetGrid(options) {
48236
48392
  },
48237
48393
  []
48238
48394
  );
48239
- const onKeyDownCapture = (0, import_react21.useCallback)(
48395
+ const onKeyDownCapture = (0, import_react22.useCallback)(
48240
48396
  (event) => {
48241
48397
  const key = event.key;
48242
48398
  if (key !== "Enter" && key !== "Tab" && key !== "Escape") return;
@@ -48255,7 +48411,7 @@ function useSpreadsheetGrid(options) {
48255
48411
  [endEdit, focusIsLost]
48256
48412
  );
48257
48413
  const holdsARange = range !== null;
48258
- (0, import_react21.useEffect)(() => {
48414
+ (0, import_react22.useEffect)(() => {
48259
48415
  if (!holdsARange || typeof document === "undefined") return;
48260
48416
  const onPointerDown = (event) => {
48261
48417
  const target = event.target instanceof Element ? event.target : null;
@@ -48271,7 +48427,7 @@ function useSpreadsheetGrid(options) {
48271
48427
  document.addEventListener("pointerdown", onPointerDown, true);
48272
48428
  return () => document.removeEventListener("pointerdown", onPointerDown, true);
48273
48429
  }, [holdsARange]);
48274
- (0, import_react21.useEffect)(() => {
48430
+ (0, import_react22.useEffect)(() => {
48275
48431
  if (!holdsARange || typeof document === "undefined" || typeof MutationObserver === "undefined") return;
48276
48432
  const timers = [];
48277
48433
  const lookAgain = () => {
@@ -48297,8 +48453,8 @@ function useSpreadsheetGrid(options) {
48297
48453
  for (const t of timers) clearTimeout(t);
48298
48454
  };
48299
48455
  }, [holdsARange, focusGrid, focusIsLost]);
48300
- const controller = (0, import_react21.useMemo)(() => ({ endEdit, select, focusGrid }), [endEdit, select, focusGrid]);
48301
- const onKeyDown = (0, import_react21.useCallback)(
48456
+ const controller = (0, import_react22.useMemo)(() => ({ endEdit, select, focusGrid }), [endEdit, select, focusGrid]);
48457
+ const onKeyDown = (0, import_react22.useCallback)(
48302
48458
  (event) => {
48303
48459
  const current = optionsRef.current;
48304
48460
  if (!current) return;
@@ -48382,7 +48538,7 @@ function useSpreadsheetGrid(options) {
48382
48538
  },
48383
48539
  [move, range, rowIds, columnIds, doClear, doFillDown, doUndo, doRedo]
48384
48540
  );
48385
- const selectionAsTsv = (0, import_react21.useCallback)(() => {
48541
+ const selectionAsTsv = (0, import_react22.useCallback)(() => {
48386
48542
  const current = optionsRef.current;
48387
48543
  if (!current || !range) return "";
48388
48544
  const grid = rangeRows(range, rowIds, columnIds).map(
@@ -48390,14 +48546,14 @@ function useSpreadsheetGrid(options) {
48390
48546
  );
48391
48547
  return gridToTsv(grid);
48392
48548
  }, [range, rowIds, columnIds]);
48393
- const selectionAddresses = (0, import_react21.useCallback)(() => {
48549
+ const selectionAddresses = (0, import_react22.useCallback)(() => {
48394
48550
  if (!range || !bounds) return { rowIds: [], columnIds: [] };
48395
48551
  return {
48396
48552
  rowIds: rowIds.slice(bounds.r0, bounds.r1 + 1),
48397
48553
  columnIds: columnIds.slice(bounds.c0, bounds.c1 + 1)
48398
48554
  };
48399
48555
  }, [range, bounds, rowIds, columnIds]);
48400
- const onCopy = (0, import_react21.useCallback)(
48556
+ const onCopy = (0, import_react22.useCallback)(
48401
48557
  (event) => {
48402
48558
  if (!optionsRef.current || !range || targetsAnEditor(event.target)) return;
48403
48559
  if (camePastAPortalIntoTheContainer(event.target)) return;
@@ -48411,7 +48567,7 @@ function useSpreadsheetGrid(options) {
48411
48567
  },
48412
48568
  [range, selectionAsTsv, selectionAddresses]
48413
48569
  );
48414
- const onCut = (0, import_react21.useCallback)(
48570
+ const onCut = (0, import_react22.useCallback)(
48415
48571
  (event) => {
48416
48572
  if (!optionsRef.current || !range || targetsAnEditor(event.target)) return;
48417
48573
  if (camePastAPortalIntoTheContainer(event.target)) return;
@@ -48423,7 +48579,7 @@ function useSpreadsheetGrid(options) {
48423
48579
  },
48424
48580
  [range, selectionAsTsv, doClear]
48425
48581
  );
48426
- const onPaste = (0, import_react21.useCallback)(
48582
+ const onPaste = (0, import_react22.useCallback)(
48427
48583
  (event) => {
48428
48584
  const current = optionsRef.current;
48429
48585
  if (!current || current.paste === false || !range || targetsAnEditor(event.target)) return;
@@ -48520,7 +48676,7 @@ function useSpreadsheetGrid(options) {
48520
48676
  },
48521
48677
  [range, bounds, rowIds, columnIds, applyPatches, announceSkips, screenPatches, refuseWrite]
48522
48678
  );
48523
- const cellProps = (0, import_react21.useCallback)(
48679
+ const cellProps = (0, import_react22.useCallback)(
48524
48680
  (rowId, columnId2) => {
48525
48681
  const address = { rowId, fieldName: columnId2 };
48526
48682
  const rowIndex = rowIndexById.get(rowId) ?? -1;
@@ -48569,7 +48725,7 @@ function useSpreadsheetGrid(options) {
48569
48725
  },
48570
48726
  [rowIndexById, columnIndexById, bounds, range, fillTarget]
48571
48727
  );
48572
- const isFillHandleCell = (0, import_react21.useCallback)(
48728
+ const isFillHandleCell = (0, import_react22.useCallback)(
48573
48729
  (rowId, columnId2) => {
48574
48730
  const current = optionsRef.current;
48575
48731
  if (!current || current.fillHandle === false || current.readOnly || !bounds) return false;
@@ -48577,7 +48733,7 @@ function useSpreadsheetGrid(options) {
48577
48733
  },
48578
48734
  [bounds, rowIds, columnIds]
48579
48735
  );
48580
- const startFillDrag = (0, import_react21.useCallback)(
48736
+ const startFillDrag = (0, import_react22.useCallback)(
48581
48737
  (event) => {
48582
48738
  event.preventDefault();
48583
48739
  event.stopPropagation();
@@ -48585,11 +48741,11 @@ function useSpreadsheetGrid(options) {
48585
48741
  },
48586
48742
  []
48587
48743
  );
48588
- const fillTargetRef = (0, import_react21.useRef)(null);
48744
+ const fillTargetRef = (0, import_react22.useRef)(null);
48589
48745
  fillTargetRef.current = fillTarget;
48590
- const boundsRef = (0, import_react21.useRef)(null);
48746
+ const boundsRef = (0, import_react22.useRef)(null);
48591
48747
  boundsRef.current = bounds;
48592
- (0, import_react21.useEffect)(() => {
48748
+ (0, import_react22.useEffect)(() => {
48593
48749
  if (!options) return;
48594
48750
  const commit = () => {
48595
48751
  const wasDragging = draggingRef.current;
@@ -48614,7 +48770,7 @@ function useSpreadsheetGrid(options) {
48614
48770
  window.addEventListener("mouseup", commit);
48615
48771
  return () => window.removeEventListener("mouseup", commit);
48616
48772
  }, [options, fillRequestBase, applyPatches, announceSkips, screenPatches, refuseWrite]);
48617
- const takeTypedText = (0, import_react21.useCallback)(
48773
+ const takeTypedText = (0, import_react22.useCallback)(
48618
48774
  (text) => {
48619
48775
  if (catcherRef.current) catcherRef.current.value = "";
48620
48776
  const current = optionsRef.current;
@@ -48685,7 +48841,7 @@ function useSpreadsheetGrid(options) {
48685
48841
  }
48686
48842
 
48687
48843
  // src/data-table/ToolbarOverflow.tsx
48688
- var import_react22 = require("react");
48844
+ var import_react23 = require("react");
48689
48845
 
48690
48846
  // src/bottom-sheet.tsx
48691
48847
  var import_react_visually_hidden = require("@radix-ui/react-visually-hidden");
@@ -48925,13 +49081,13 @@ function BottomSheet({
48925
49081
  // src/data-table/ToolbarOverflow.tsx
48926
49082
  var import_jsx_runtime50 = require("react/jsx-runtime");
48927
49083
  var TOOLBAR_CONTROL_HEIGHT = "h-8";
48928
- var ListedContext = (0, import_react22.createContext)(false);
49084
+ var ListedContext = (0, import_react23.createContext)(false);
48929
49085
  function useToolbarListed() {
48930
- return (0, import_react22.useContext)(ListedContext);
49086
+ return (0, import_react23.useContext)(ListedContext);
48931
49087
  }
48932
49088
  var LIST_CLASS = "flex flex-col items-stretch gap-1 [&>*]:w-full [&_[data-matrx-table-toolbar-action]]:w-full [&_[data-matrx-table-group-by]]:w-full";
48933
49089
  function ToolbarOverflowMenu({ children, label = "More tools" }) {
48934
- const [open, setOpen] = (0, import_react22.useState)(false);
49090
+ const [open, setOpen] = (0, import_react23.useState)(false);
48935
49091
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(Popover, { open, onOpenChange: setOpen, children: [
48936
49092
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
48937
49093
  Button,
@@ -48959,7 +49115,7 @@ function ToolbarOverflowSheet({
48959
49115
  title = "Table tools",
48960
49116
  top
48961
49117
  }) {
48962
- const [open, setOpen] = (0, import_react22.useState)(false);
49118
+ const [open, setOpen] = (0, import_react23.useState)(false);
48963
49119
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
48964
49120
  /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
48965
49121
  Button,
@@ -49004,16 +49160,16 @@ function ToolbarListedLabel({ label, children }) {
49004
49160
  }
49005
49161
 
49006
49162
  // src/data-table/pinned-fold.ts
49007
- var import_react23 = require("react");
49163
+ var import_react24 = require("react");
49008
49164
  function pinnedMustFold(room, full) {
49009
49165
  if (room <= 0 || full === null) return false;
49010
49166
  return full > room + 0.5;
49011
49167
  }
49012
49168
  function usePinnedFold(el, active) {
49013
- const [folded, setFolded] = (0, import_react23.useState)(false);
49014
- const full = (0, import_react23.useRef)(null);
49015
- const current = (0, import_react23.useRef)(false);
49016
- (0, import_react23.useEffect)(() => {
49169
+ const [folded, setFolded] = (0, import_react24.useState)(false);
49170
+ const full = (0, import_react24.useRef)(null);
49171
+ const current = (0, import_react24.useRef)(false);
49172
+ (0, import_react24.useEffect)(() => {
49017
49173
  if (!active || !el) {
49018
49174
  if (current.current) {
49019
49175
  current.current = false;
@@ -49200,7 +49356,7 @@ function rankTableSearchRows(rows, columns, query, options = {}, extraText) {
49200
49356
  }
49201
49357
 
49202
49358
  // src/data-table/ColumnManager.tsx
49203
- var import_react24 = require("react");
49359
+ var import_react25 = require("react");
49204
49360
  var import_core2 = require("@dnd-kit/core");
49205
49361
  var import_jsx_runtime51 = require("react/jsx-runtime");
49206
49362
  function ColumnManager({
@@ -49211,15 +49367,15 @@ function ColumnManager({
49211
49367
  hidden,
49212
49368
  onApply
49213
49369
  }) {
49214
- const byId = (0, import_react24.useMemo)(
49370
+ const byId = (0, import_react25.useMemo)(
49215
49371
  () => new Map(columns.map((column) => [columnId(column), column])),
49216
49372
  [columns]
49217
49373
  );
49218
- const [draftOrder, setDraftOrder] = (0, import_react24.useState)(order);
49219
- const [draftHidden, setDraftHidden] = (0, import_react24.useState)(() => new Set(hidden));
49220
- const [draggedColumnId, setDraggedColumnId] = (0, import_react24.useState)(null);
49221
- const [dropTarget, setDropTarget] = (0, import_react24.useState)(null);
49222
- (0, import_react24.useEffect)(() => {
49374
+ const [draftOrder, setDraftOrder] = (0, import_react25.useState)(order);
49375
+ const [draftHidden, setDraftHidden] = (0, import_react25.useState)(() => new Set(hidden));
49376
+ const [draggedColumnId, setDraggedColumnId] = (0, import_react25.useState)(null);
49377
+ const [dropTarget, setDropTarget] = (0, import_react25.useState)(null);
49378
+ (0, import_react25.useEffect)(() => {
49223
49379
  if (!open) return;
49224
49380
  setDraftOrder(order);
49225
49381
  setDraftHidden(new Set(hidden));
@@ -49761,7 +49917,7 @@ function parseTableViewSnapshot(raw) {
49761
49917
  }
49762
49918
 
49763
49919
  // src/data-table/MatrxUuidCell.tsx
49764
- var import_react25 = require("react");
49920
+ var import_react26 = require("react");
49765
49921
  var import_jsx_runtime52 = require("react/jsx-runtime");
49766
49922
  var SHORT_LEN = 8;
49767
49923
  function shortUuid(id, len = SHORT_LEN) {
@@ -49801,11 +49957,11 @@ function MatrxUuidCell({
49801
49957
  }) {
49802
49958
  const { resolveEntityDoors, ResourcePeek } = useMatrxDataTableHost();
49803
49959
  const { notify, notice } = useTableNotice();
49804
- const [copied, setCopied] = (0, import_react25.useState)(false);
49805
- const [opening, setOpening] = (0, import_react25.useState)(false);
49806
- const [peekOpen, setPeekOpen] = (0, import_react25.useState)(false);
49807
- const timer = (0, import_react25.useRef)(null);
49808
- (0, import_react25.useEffect)(
49960
+ const [copied, setCopied] = (0, import_react26.useState)(false);
49961
+ const [opening, setOpening] = (0, import_react26.useState)(false);
49962
+ const [peekOpen, setPeekOpen] = (0, import_react26.useState)(false);
49963
+ const timer = (0, import_react26.useRef)(null);
49964
+ (0, import_react26.useEffect)(
49809
49965
  () => () => {
49810
49966
  if (timer.current) clearTimeout(timer.current);
49811
49967
  },
@@ -50015,7 +50171,7 @@ function formatValue2(value) {
50015
50171
  return String(value);
50016
50172
  }
50017
50173
  }
50018
- function isPlainObject(value) {
50174
+ function isPlainObject2(value) {
50019
50175
  return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
50020
50176
  }
50021
50177
  function DataRowInspector({
@@ -50028,7 +50184,7 @@ function DataRowInspector({
50028
50184
  location,
50029
50185
  tokenForField = noFieldToken
50030
50186
  }) {
50031
- const entries = isPlainObject(row) ? Object.entries(row) : [["value", row]];
50187
+ const entries = isPlainObject2(row) ? Object.entries(row) : [["value", row]];
50032
50188
  const fieldButtons = (key, value) => fieldCopy ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "absolute right-1 top-1 opacity-0 transition-opacity focus-within:opacity-100 group-hover/field:opacity-100", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
50033
50189
  CopyButtons,
50034
50190
  {
@@ -50101,7 +50257,7 @@ function DataRowInspector({
50101
50257
  }
50102
50258
 
50103
50259
  // src/data-table/DataRowWindow.tsx
50104
- var import_react26 = require("react");
50260
+ var import_react27 = require("react");
50105
50261
  var import_jsx_runtime54 = require("react/jsx-runtime");
50106
50262
  function DataRowWindow({
50107
50263
  isOpen,
@@ -50122,8 +50278,8 @@ function DataRowWindow({
50122
50278
  const hasEdit = editContent != null;
50123
50279
  const hasTabs = hasEdit && children == null;
50124
50280
  const initialTab = defaultTab ?? (hasEdit ? "edit" : "view");
50125
- const [tab, setTab] = (0, import_react26.useState)(initialTab);
50126
- (0, import_react26.useEffect)(() => {
50281
+ const [tab, setTab] = (0, import_react27.useState)(initialTab);
50282
+ (0, import_react27.useEffect)(() => {
50127
50283
  if (!isOpen) return;
50128
50284
  setTab(defaultTab ?? (hasEdit ? "edit" : "view"));
50129
50285
  }, [isOpen, windowId, hasEdit, defaultTab]);
@@ -51364,7 +51520,7 @@ function DirtySavePill({
51364
51520
  }
51365
51521
 
51366
51522
  // src/data-table/EditableTableCell.tsx
51367
- var import_react27 = require("react");
51523
+ var import_react28 = require("react");
51368
51524
  var import_jsx_runtime57 = require("react/jsx-runtime");
51369
51525
  function CellRefusal({ reason }) {
51370
51526
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
@@ -51426,12 +51582,12 @@ function EditableTableCell({
51426
51582
  editRequest,
51427
51583
  editSeed
51428
51584
  }) {
51429
- const [open, setOpen] = (0, import_react27.useState)(false);
51430
- const [refusal, setRefusal] = (0, import_react27.useState)(null);
51431
- (0, import_react27.useEffect)(() => {
51585
+ const [open, setOpen] = (0, import_react28.useState)(false);
51586
+ const [refusal, setRefusal] = (0, import_react28.useState)(null);
51587
+ (0, import_react28.useEffect)(() => {
51432
51588
  if (editRequest !== void 0) setOpen(true);
51433
51589
  }, [editRequest]);
51434
- (0, import_react27.useEffect)(() => {
51590
+ (0, import_react28.useEffect)(() => {
51435
51591
  if (!open) setRefusal(null);
51436
51592
  }, [open]);
51437
51593
  const usePencil = Boolean(href) || editTrigger === "pencil";
@@ -51535,13 +51691,13 @@ function InlineStringEditor({
51535
51691
  editRequest,
51536
51692
  editSeed
51537
51693
  }) {
51538
- const [editing, setEditing] = (0, import_react27.useState)(false);
51539
- const [draft, setDraft] = (0, import_react27.useState)(value);
51540
- const [refusal, setRefusal] = (0, import_react27.useState)(null);
51541
- const handledEditRequest = (0, import_react27.useRef)(void 0);
51542
- const seedRef = (0, import_react27.useRef)(editSeed);
51694
+ const [editing, setEditing] = (0, import_react28.useState)(false);
51695
+ const [draft, setDraft] = (0, import_react28.useState)(value);
51696
+ const [refusal, setRefusal] = (0, import_react28.useState)(null);
51697
+ const handledEditRequest = (0, import_react28.useRef)(void 0);
51698
+ const seedRef = (0, import_react28.useRef)(editSeed);
51543
51699
  seedRef.current = editSeed;
51544
- (0, import_react27.useEffect)(() => {
51700
+ (0, import_react28.useEffect)(() => {
51545
51701
  if (editRequest === void 0 || handledEditRequest.current === editRequest) return;
51546
51702
  handledEditRequest.current = editRequest;
51547
51703
  setDraft(seedRef.current ?? value);
@@ -51701,8 +51857,8 @@ function DateEditor({
51701
51857
  onCommit,
51702
51858
  onCancel
51703
51859
  }) {
51704
- const [draft, setDraft] = (0, import_react27.useState)(value);
51705
- const done = (0, import_react27.useRef)(false);
51860
+ const [draft, setDraft] = (0, import_react28.useState)(value);
51861
+ const done = (0, import_react28.useRef)(false);
51706
51862
  const finish = () => {
51707
51863
  if (done.current) return;
51708
51864
  done.current = true;
@@ -51737,8 +51893,8 @@ function TagsEditor({
51737
51893
  onCommit,
51738
51894
  onCancel
51739
51895
  }) {
51740
- const [tags, setTags] = (0, import_react27.useState)(value);
51741
- const [draft, setDraft] = (0, import_react27.useState)("");
51896
+ const [tags, setTags] = (0, import_react28.useState)(value);
51897
+ const [draft, setDraft] = (0, import_react28.useState)("");
51742
51898
  const add = (raw) => {
51743
51899
  const next = raw.trim();
51744
51900
  if (!next || tags.includes(next)) return;
@@ -51835,7 +51991,7 @@ function NumberEditor({
51835
51991
  onCommit,
51836
51992
  onCancel
51837
51993
  }) {
51838
- const [draft, setDraft] = (0, import_react27.useState)(String(value));
51994
+ const [draft, setDraft] = (0, import_react28.useState)(String(value));
51839
51995
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "flex flex-col gap-2", children: [
51840
51996
  /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
51841
51997
  Input,
@@ -52264,7 +52420,7 @@ function TableToolbarAction({
52264
52420
  disabled,
52265
52421
  onClick,
52266
52422
  children: [
52267
- (0, import_react28.isValidElement)(children) ? (0, import_react28.cloneElement)(children, { className: cn("h-4 w-4", children.props.className) }) : children,
52423
+ (0, import_react29.isValidElement)(children) ? (0, import_react29.cloneElement)(children, { className: cn("h-4 w-4", children.props.className) }) : children,
52268
52424
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("span", { children: ariaLabel })
52269
52425
  ]
52270
52426
  }
@@ -52286,7 +52442,7 @@ function TableToolbarAction({
52286
52442
  "aria-busy": busy || void 0,
52287
52443
  disabled,
52288
52444
  onClick,
52289
- children: (0, import_react28.isValidElement)(children) ? (0, import_react28.cloneElement)(children, { className: cn("h-5 w-5", children.props.className) }) : children
52445
+ children: (0, import_react29.isValidElement)(children) ? (0, import_react29.cloneElement)(children, { className: cn("h-5 w-5", children.props.className) }) : children
52290
52446
  }
52291
52447
  ) }) }),
52292
52448
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(TooltipContent, { children: tooltip ?? ariaLabel })
@@ -52315,9 +52471,10 @@ function tableRowCopyProps(copy, row, sourceId, defaultColumns) {
52315
52471
  label: copy.label,
52316
52472
  ...copy.rowReferences ? { references: copy.rowReferences(row) } : {},
52317
52473
  ...copy.triggerVariant ? { triggerVariant: copy.triggerVariant } : {},
52318
- human: () => copy.humanRow(row),
52319
- json: () => copy.agentRow ? copy.agentRow(row) : row,
52320
- agent: () => defaultColumns ? buildDefaultTableRowAgentInput(copy, row, defaultColumns) : buildRowAgentInput(copy, row),
52474
+ // Run on a copy, never while the menu renders: a row may keep a trampoline to them.
52475
+ human: lazyCallback(() => copy.humanRow(row)),
52476
+ json: lazyCallback(() => copy.agentRow ? copy.agentRow(row) : row),
52477
+ agent: lazyCallback(() => defaultColumns ? buildDefaultTableRowAgentInput(copy, row, defaultColumns()) : buildRowAgentInput(copy, row)),
52321
52478
  ...aiVariants === void 0 ? {} : { aiVariants }
52322
52479
  };
52323
52480
  }
@@ -52343,7 +52500,7 @@ function MatrxDataTable(suppliedProps) {
52343
52500
  const props = card ? withTableCardDefaults(suppliedProps, card) : suppliedProps;
52344
52501
  const sourceRows = props.query?.mode === "controlled-append" ? props.query.pagination.rows : props.data;
52345
52502
  const availableRows = sourceRows ?? EMPTY_TABLE_ROWS;
52346
- const [defaultSelectionState, setDefaultSelectionState] = (0, import_react28.useState)({
52503
+ const [defaultSelectionState, setDefaultSelectionState] = (0, import_react29.useState)({
52347
52504
  sourceRows: availableRows,
52348
52505
  selectedIds: []
52349
52506
  });
@@ -52381,7 +52538,7 @@ function useHostCustomFieldColumns(token, rows) {
52381
52538
  const host = useMatrxDataTableHost();
52382
52539
  const useColumns = host.useCustomFieldColumns ?? noCustomFieldColumns;
52383
52540
  const orgKey = token ? rowOrganizationIds(rows).join(",") : "";
52384
- const organizationIds = (0, import_react28.useMemo)(() => orgKey ? orgKey.split(",") : [], [orgKey]);
52541
+ const organizationIds = (0, import_react29.useMemo)(() => orgKey ? orgKey.split(",") : [], [orgKey]);
52385
52542
  const answer = useColumns(token, organizationIds);
52386
52543
  return answer?.columns ?? NO_CUSTOM_FIELD_COLUMNS;
52387
52544
  }
@@ -52401,7 +52558,7 @@ function MatrxDataTableWithUrlState({
52401
52558
  ...urlState.history === void 0 ? {} : { history: urlState.history },
52402
52559
  ...urlState.textHistory === void 0 ? {} : { textHistory: urlState.textHistory }
52403
52560
  });
52404
- (0, import_react28.useEffect)(() => {
52561
+ (0, import_react29.useEffect)(() => {
52405
52562
  if (activeUrlTableIds.has(urlState.id)) {
52406
52563
  throw new Error(
52407
52564
  `Duplicate MatrxDataTable urlState.id "${urlState.id}" on one page. Give every table a unique stable id.`
@@ -52510,7 +52667,7 @@ var DND_MEASURING = { droppable: { strategy: import_core3.MeasuringStrategy.Alwa
52510
52667
  var NO_LAYERED_FILTERS = [];
52511
52668
  var NO_GROUPING_VALUE = "__matrx_no_grouping__";
52512
52669
  function useRenderEpoch(values) {
52513
- const held = (0, import_react28.useRef)(null);
52670
+ const held = (0, import_react29.useRef)(null);
52514
52671
  const previous = held.current;
52515
52672
  if (previous !== null && previous.values.length === values.length && previous.values.every((value, i) => Object.is(value, values[i]))) {
52516
52673
  return previous.epoch;
@@ -52550,12 +52707,12 @@ function versionFacts(version2) {
52550
52707
  return Array.isArray(version2) ? ["rowVersion", ...version2] : ["rowVersion", version2];
52551
52708
  }
52552
52709
  function sameBodyRow(a, b) {
52553
- return a.row === b.row && a.index === b.index && a.epoch === b.epoch && a.rowId === b.rowId && a.facts.length === b.facts.length && a.facts.every((fact, i) => Object.is(fact, b.facts[i]));
52710
+ return a.row === b.row && a.index === b.index && a.epoch === b.epoch && a.probe === b.probe && a.rowId === b.rowId && a.facts.length === b.facts.length && a.facts.every((fact, i) => Object.is(fact, b.facts[i]));
52554
52711
  }
52555
- var MatrxTableBodyRow = (0, import_react28.memo)(function MatrxTableBodyRow2({ row, index, render }) {
52556
- return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_jsx_runtime59.Fragment, { children: render(row, index) });
52712
+ var MatrxTableBodyRow = (0, import_react29.memo)(function MatrxTableBodyRow2({ rowId, row, index, draw }) {
52713
+ return draw(rowId, row, index);
52557
52714
  }, sameBodyRow);
52558
- var MatrxTableChrome = (0, import_react28.memo)(function MatrxTableChrome2({ render }) {
52715
+ var MatrxTableChrome = (0, import_react29.memo)(function MatrxTableChrome2({ render }) {
52559
52716
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_jsx_runtime59.Fragment, { children: render() });
52560
52717
  }, (a, b) => a.part === b.part && a.epoch === b.epoch);
52561
52718
  function columnsSignature(columns) {
@@ -52653,7 +52810,7 @@ function MatrxDataTableCore(coreProps) {
52653
52810
  fitToWidth = false,
52654
52811
  appearance = "standalone"
52655
52812
  } = coreProps;
52656
- const columns = (0, import_react28.useMemo)(() => suppliedColumns.filter((column) => !("customActions" in column) || column.customActions !== void 0).map((column) => {
52813
+ const columns = (0, import_react29.useMemo)(() => suppliedColumns.filter((column) => !("customActions" in column) || column.customActions !== void 0).map((column) => {
52657
52814
  if (!column.customActions) return column;
52658
52815
  const {
52659
52816
  accessorKey: _key,
@@ -52668,11 +52825,11 @@ function MatrxDataTableCore(coreProps) {
52668
52825
  }), [suppliedColumns]);
52669
52826
  const embedded = appearance === "embedded";
52670
52827
  const zebra = suppliedZebra ?? !embedded;
52671
- const tableCard = (0, import_react28.useContext)(TableCardOwnerContext);
52828
+ const tableCard = (0, import_react29.useContext)(TableCardOwnerContext);
52672
52829
  const selectionConfig = suppliedSelectionConfig === false ? void 0 : suppliedSelectionConfig;
52673
52830
  const appendQuery = query?.mode === "controlled-append" ? query : null;
52674
52831
  const appendQueryKey = appendQuery?.pagination.queryKey ?? null;
52675
- const committedAppendQueryKey = (0, import_react28.useRef)(appendQueryKey);
52832
+ const committedAppendQueryKey = (0, import_react29.useRef)(appendQueryKey);
52676
52833
  const appendSourceChanged = appendQuery !== null && committedAppendQueryKey.current !== appendQueryKey;
52677
52834
  const data = (appendQuery ? appendQuery.pagination.rows : suppliedData) ?? EMPTY_TABLE_ROWS;
52678
52835
  const readView = tableReadView(read, data.length, appendQuery ? appendQuery.pagination.loading : suppliedLoading);
@@ -52690,16 +52847,16 @@ function MatrxDataTableCore(coreProps) {
52690
52847
  const Link = host.Link ?? DefaultTableLink;
52691
52848
  const SidePanelSurface = host.SidePanelSurface ?? DefaultTableSidePanel;
52692
52849
  const { notify: toast, notice } = useTableNotice();
52693
- const [savedViewError, setSavedViewError] = (0, import_react28.useState)(null);
52694
- const [toolbarActionError, setToolbarActionError] = (0, import_react28.useState)(null);
52695
- const [toolbarActionPending, setToolbarActionPending] = (0, import_react28.useState)({ refresh: false, add: false });
52696
- const toolbarActionPendingRef = (0, import_react28.useRef)({ refresh: false, add: false });
52850
+ const [savedViewError, setSavedViewError] = (0, import_react29.useState)(null);
52851
+ const [toolbarActionError, setToolbarActionError] = (0, import_react29.useState)(null);
52852
+ const [toolbarActionPending, setToolbarActionPending] = (0, import_react29.useState)({ refresh: false, add: false });
52853
+ const toolbarActionPendingRef = (0, import_react29.useRef)({ refresh: false, add: false });
52697
52854
  const CHECKBOX_TAP_AREA = "h-4 w-4 touch-manipulation";
52698
52855
  const mobileCardsClass = mobileCardsBreakpoint === "lg" ? "lg:hidden" : "sm:hidden";
52699
52856
  const tableWithCardsClass = mobileCardsBreakpoint === "lg" ? "max-lg:hidden" : "max-sm:hidden";
52700
52857
  const cardsQuery = mobileCardsBreakpoint === "lg" ? "(max-width: 1023px)" : "(max-width: 639px)";
52701
- const [cardsActive, setCardsActive] = (0, import_react28.useState)(null);
52702
- (0, import_react28.useEffect)(() => {
52858
+ const [cardsActive, setCardsActive] = (0, import_react29.useState)(null);
52859
+ (0, import_react29.useEffect)(() => {
52703
52860
  if (!mobileCards || typeof window === "undefined" || !window.matchMedia) return;
52704
52861
  const mql = window.matchMedia(cardsQuery);
52705
52862
  const read2 = () => setCardsActive(mql.matches);
@@ -52720,7 +52877,7 @@ function MatrxDataTableCore(coreProps) {
52720
52877
  const sourceOwnsIntelligentSearch = sourceProcessing?.intelligentSearch === "source";
52721
52878
  const sourceOwnsSearch = remoteQuery?.mode === "controlled" && sourceProcessing?.search !== "local" || appendQuery !== null && sourceProcessing === void 0 || sourceProcessing?.search === "source" || sourceOwnsIntelligentSearch;
52722
52879
  const intelligentSearchEnabled = toolbar?.intelligentSearch !== void 0 && (sourceOwnsIntelligentSearch || remoteQuery === null && !sourceOwnsSearch);
52723
- const emitControlledQueryChange = (0, import_react28.useCallback)(
52880
+ const emitControlledQueryChange = (0, import_react29.useCallback)(
52724
52881
  (patch, options) => {
52725
52882
  if (!controlledQuery) return;
52726
52883
  controlledQuery.onStateChange(
@@ -52729,8 +52886,8 @@ function MatrxDataTableCore(coreProps) {
52729
52886
  },
52730
52887
  [controlledQuery]
52731
52888
  );
52732
- const [internalSearch, setInternalSearch] = (0, import_react28.useState)("");
52733
- const [draggedRowId, setDraggedRowId] = (0, import_react28.useState)(null);
52889
+ const [internalSearch, setInternalSearch] = (0, import_react29.useState)("");
52890
+ const [draggedRowId, setDraggedRowId] = (0, import_react29.useState)(null);
52734
52891
  const hierarchySensors = (0, import_core3.useSensors)((0, import_core3.useSensor)(import_core3.PointerSensor, POINTER_SENSOR_OPTIONS));
52735
52892
  const toolbarSearchControlled = toolbar?.searchValue !== void 0;
52736
52893
  const searchValue = controlledQuery ? controlledQuery.state.search : toolbarSearchControlled ? toolbar?.searchValue ?? "" : internalSearch;
@@ -52742,7 +52899,7 @@ function MatrxDataTableCore(coreProps) {
52742
52899
  }
52743
52900
  toolbar?.onSearchChange?.(v);
52744
52901
  };
52745
- const [internalSearchMatchMode, setInternalSearchMatchMode] = (0, import_react28.useState)(
52902
+ const [internalSearchMatchMode, setInternalSearchMatchMode] = (0, import_react29.useState)(
52746
52903
  toolbar?.searchMatch?.defaultMode ?? "contains"
52747
52904
  );
52748
52905
  const searchMatchMode = controlledQuery ? controlledQuery.state.searchMatchMode ?? toolbar?.searchMatch?.defaultMode ?? "contains" : internalSearchMatchMode;
@@ -52753,7 +52910,7 @@ function MatrxDataTableCore(coreProps) {
52753
52910
  }
52754
52911
  setInternalSearchMatchMode(mode);
52755
52912
  };
52756
- const [internalSearchScope, setInternalSearchScope] = (0, import_react28.useState)("all");
52913
+ const [internalSearchScope, setInternalSearchScope] = (0, import_react29.useState)("all");
52757
52914
  const searchScope = controlledQuery ? controlledQuery.state.searchScope ?? "all" : internalSearchScope;
52758
52915
  const setSearchScope = (scope) => {
52759
52916
  if (controlledQuery) {
@@ -52762,7 +52919,7 @@ function MatrxDataTableCore(coreProps) {
52762
52919
  }
52763
52920
  setInternalSearchScope(scope);
52764
52921
  };
52765
- const [internalAnyOf, setInternalAnyOf] = (0, import_react28.useState)("");
52922
+ const [internalAnyOf, setInternalAnyOf] = (0, import_react29.useState)("");
52766
52923
  const toolbarAnyOfControlled = toolbar?.anyOf?.value !== void 0;
52767
52924
  const anyOfValue = controlledQuery ? controlledQuery.state.anyOf : toolbarAnyOfControlled ? toolbar?.anyOf?.value ?? "" : internalAnyOf;
52768
52925
  const setAnyOfValue = (v) => {
@@ -52773,7 +52930,7 @@ function MatrxDataTableCore(coreProps) {
52773
52930
  }
52774
52931
  toolbar?.anyOf?.onChange?.(v);
52775
52932
  };
52776
- const [internalLayeredFilters, setInternalLayeredFilters] = (0, import_react28.useState)([]);
52933
+ const [internalLayeredFilters, setInternalLayeredFilters] = (0, import_react29.useState)([]);
52777
52934
  const layeredFilters = controlledQuery ? controlledQuery.state.layeredFilters ?? NO_LAYERED_FILTERS : internalLayeredFilters;
52778
52935
  const setLayeredFilters = (next) => {
52779
52936
  if (controlledQuery) {
@@ -52782,9 +52939,9 @@ function MatrxDataTableCore(coreProps) {
52782
52939
  }
52783
52940
  setInternalLayeredFilters(next);
52784
52941
  };
52785
- const [internalColumnFilters, setInternalColumnFilters] = (0, import_react28.useState)({});
52942
+ const [internalColumnFilters, setInternalColumnFilters] = (0, import_react29.useState)({});
52786
52943
  const columnFilters = controlledQuery ? controlledQuery.state.columnFilters : internalColumnFilters;
52787
- const localColumnFilters = (0, import_react28.useMemo)(() => {
52944
+ const localColumnFilters = (0, import_react29.useMemo)(() => {
52788
52945
  if (appendDefaultsToSourceProcessing) return {};
52789
52946
  if (sourceColumnFilterOwnership === "source") return {};
52790
52947
  if (sourceColumnFilterOwnership === void 0 || sourceColumnFilterOwnership === "local") {
@@ -52806,7 +52963,7 @@ function MatrxDataTableCore(coreProps) {
52806
52963
  }
52807
52964
  setInternalColumnFilters(nextFilters);
52808
52965
  };
52809
- const [internalSort, setInternalSort] = (0, import_react28.useState)(defaultSort);
52966
+ const [internalSort, setInternalSort] = (0, import_react29.useState)(defaultSort);
52810
52967
  const sort = controlledQuery ? controlledQuery.state.sort : internalSort;
52811
52968
  const setSort = (next) => {
52812
52969
  if (controlledQuery) {
@@ -52815,7 +52972,7 @@ function MatrxDataTableCore(coreProps) {
52815
52972
  }
52816
52973
  setInternalSort(next);
52817
52974
  };
52818
- const [internalPage, setInternalPage] = (0, import_react28.useState)(1);
52975
+ const [internalPage, setInternalPage] = (0, import_react29.useState)(1);
52819
52976
  const page = controlledQuery ? controlledQuery.state.page : internalPage;
52820
52977
  const setPage = (next) => {
52821
52978
  if (controlledQuery) {
@@ -52824,7 +52981,7 @@ function MatrxDataTableCore(coreProps) {
52824
52981
  }
52825
52982
  setInternalPage(next);
52826
52983
  };
52827
- const [internalPageSize, setInternalPageSize] = (0, import_react28.useState)(
52984
+ const [internalPageSize, setInternalPageSize] = (0, import_react29.useState)(
52828
52985
  defaultPageSize
52829
52986
  );
52830
52987
  const pageSize = controlledQuery ? controlledQuery.state.pageSize : internalPageSize;
@@ -52835,29 +52992,29 @@ function MatrxDataTableCore(coreProps) {
52835
52992
  }
52836
52993
  setInternalPageSize(next);
52837
52994
  };
52838
- const [uncontrolledSelectedId, setUncontrolledSelectedId] = (0, import_react28.useState)(null);
52995
+ const [uncontrolledSelectedId, setUncontrolledSelectedId] = (0, import_react29.useState)(null);
52839
52996
  const rawSelectedId = controlledSelectedId !== void 0 ? controlledSelectedId : uncontrolledSelectedId;
52840
52997
  const selectedId = appendSourceChanged ? null : rawSelectedId;
52841
- const [openRequest, setOpenRequest] = (0, import_react28.useState)(0);
52998
+ const [openRequest, setOpenRequest] = (0, import_react29.useState)(0);
52842
52999
  const setSelectedId = (id) => {
52843
53000
  if (controlledSelectedId === void 0) setUncontrolledSelectedId(id);
52844
53001
  onSelectedIdChange?.(id);
52845
53002
  };
52846
- const [uncontrolledWindowRowId, setUncontrolledWindowRowId] = (0, import_react28.useState)(null);
53003
+ const [uncontrolledWindowRowId, setUncontrolledWindowRowId] = (0, import_react29.useState)(null);
52847
53004
  const rawWindowRowId = controlledWindowRowId !== void 0 ? controlledWindowRowId : uncontrolledWindowRowId;
52848
53005
  const windowRowId = appendSourceChanged ? null : rawWindowRowId;
52849
53006
  const setWindowRowId = (id) => {
52850
53007
  if (controlledWindowRowId === void 0) setUncontrolledWindowRowId(id);
52851
53008
  onWindowRowIdChange?.(id);
52852
53009
  };
52853
- const [windowRowSnapshot, setWindowRowSnapshot] = (0, import_react28.useState)(null);
53010
+ const [windowRowSnapshot, setWindowRowSnapshot] = (0, import_react29.useState)(null);
52854
53011
  const editScopeKey = appendQueryKey === null ? "\0local" : `append:${appendQueryKey}`;
52855
- const [editsByScope, setEditsByScope] = (0, import_react28.useState)({});
52856
- const editRevisionRef = (0, import_react28.useRef)({});
52857
- const [savingByScope, setSavingByScope] = (0, import_react28.useState)({});
52858
- const savingScopesRef = (0, import_react28.useRef)(/* @__PURE__ */ new Set());
52859
- const [editRequest, setEditRequest] = (0, import_react28.useState)(null);
52860
- const [confirmForeignDraftDiscard, setConfirmForeignDraftDiscard] = (0, import_react28.useState)(false);
53012
+ const [editsByScope, setEditsByScope] = (0, import_react29.useState)({});
53013
+ const editRevisionRef = (0, import_react29.useRef)({});
53014
+ const [savingByScope, setSavingByScope] = (0, import_react29.useState)({});
53015
+ const savingScopesRef = (0, import_react29.useRef)(/* @__PURE__ */ new Set());
53016
+ const [editRequest, setEditRequest] = (0, import_react29.useState)(null);
53017
+ const [confirmForeignDraftDiscard, setConfirmForeignDraftDiscard] = (0, import_react29.useState)(false);
52861
53018
  const edits = editsByScope[editScopeKey]?.values ?? {};
52862
53019
  const saving = (savingByScope[editScopeKey] ?? 0) > 0;
52863
53020
  const setEdits = (next) => {
@@ -52924,7 +53081,7 @@ function MatrxDataTableCore(coreProps) {
52924
53081
  rows: Object.entries(draft.values).map(([rowId, columns2]) => ({ rowId, columns: columns2 }))
52925
53082
  }));
52926
53083
  const selection = appendSourceChanged && selectionConfig ? { ...selectionConfig, selectedIds: [] } : selectionConfig;
52927
- (0, import_react28.useEffect)(() => {
53084
+ (0, import_react29.useEffect)(() => {
52928
53085
  const previous = committedAppendQueryKey.current;
52929
53086
  committedAppendQueryKey.current = appendQueryKey;
52930
53087
  if (previous === null || appendQueryKey === null || previous === appendQueryKey) {
@@ -52942,15 +53099,15 @@ function MatrxDataTableCore(coreProps) {
52942
53099
  onWindowRowIdChange,
52943
53100
  selectionConfig
52944
53101
  ]);
52945
- const scrollRef = (0, import_react28.useRef)(null);
52946
- const tableRef = (0, import_react28.useRef)(null);
52947
- const tableHeaderRef = (0, import_react28.useRef)(null);
52948
- const cardsScrollRef = (0, import_react28.useRef)(null);
52949
- const scrollContainers = (0, import_react28.useMemo)(() => [scrollRef, cardsScrollRef], []);
52950
- const [documentStickyHeader, setDocumentStickyHeader] = (0, import_react28.useState)(false);
52951
- const documentStickyHeaderRef = (0, import_react28.useRef)(false);
52952
- const previousAppendKeyForScrollReset = (0, import_react28.useRef)(appendQueryKey);
52953
- (0, import_react28.useLayoutEffect)(() => {
53102
+ const scrollRef = (0, import_react29.useRef)(null);
53103
+ const tableRef = (0, import_react29.useRef)(null);
53104
+ const tableHeaderRef = (0, import_react29.useRef)(null);
53105
+ const cardsScrollRef = (0, import_react29.useRef)(null);
53106
+ const scrollContainers = (0, import_react29.useMemo)(() => [scrollRef, cardsScrollRef], []);
53107
+ const [documentStickyHeader, setDocumentStickyHeader] = (0, import_react29.useState)(false);
53108
+ const documentStickyHeaderRef = (0, import_react29.useRef)(false);
53109
+ const previousAppendKeyForScrollReset = (0, import_react29.useRef)(appendQueryKey);
53110
+ (0, import_react29.useLayoutEffect)(() => {
52954
53111
  const previous = previousAppendKeyForScrollReset.current;
52955
53112
  previousAppendKeyForScrollReset.current = appendQueryKey;
52956
53113
  if (previous === null || appendQueryKey === null || previous === appendQueryKey) {
@@ -52975,25 +53132,25 @@ function MatrxDataTableCore(coreProps) {
52975
53132
  ...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.thresholdPx !== void 0 ? { thresholdPx: appendScrollPolicy.thresholdPx } : {},
52976
53133
  ...appendScrollPolicy?.mode === "scroll" && appendScrollPolicy.intentTimeoutMs !== void 0 ? { intentTimeoutMs: appendScrollPolicy.intentTimeoutMs } : {}
52977
53134
  });
52978
- const rootRef = (0, import_react28.useRef)(null);
53135
+ const rootRef = (0, import_react29.useRef)(null);
52979
53136
  useClippedContentGuard(rootRef, {
52980
53137
  label: typeof copy === "object" && copy.listLabel ? `Table: ${copy.listLabel}` : "MatrxDataTable"
52981
53138
  });
52982
- const [scrollHintRight, setScrollHintRight] = (0, import_react28.useState)(false);
52983
- const [scrollHintLeft, setScrollHintLeft] = (0, import_react28.useState)(false);
52984
- const [scrollHintRightInset, setScrollHintRightInset] = (0, import_react28.useState)(6);
52985
- const hintScrollLeft = (0, import_react28.useRef)(0);
52986
- const updateScrollHint = (0, import_react28.useCallback)(() => {
53139
+ const [scrollHintRight, setScrollHintRight] = (0, import_react29.useState)(false);
53140
+ const [scrollHintLeft, setScrollHintLeft] = (0, import_react29.useState)(false);
53141
+ const [scrollHintRightInset, setScrollHintRightInset] = (0, import_react29.useState)(6);
53142
+ const hintScrollLeft = (0, import_react29.useRef)(0);
53143
+ const updateScrollHint = (0, import_react29.useCallback)(() => {
52987
53144
  const el = scrollRef.current;
52988
53145
  if (!el) return;
52989
53146
  hintScrollLeft.current = el.scrollLeft;
52990
53147
  const hasRows = Boolean(el.querySelector("tbody tr[data-row-id]"));
52991
- const actions = el.querySelector("th[data-matrx-table-actions-column]");
53148
+ const actions = el.querySelector("th[data-matrx-table-actions-column], th[data-matrx-table-pinned-actions]");
52992
53149
  setScrollHintRight(hasRows && el.scrollLeft + el.clientWidth < el.scrollWidth - 2);
52993
53150
  setScrollHintLeft(hasRows && el.scrollLeft > 2);
52994
53151
  setScrollHintRightInset(actions ? Math.ceil(actions.getBoundingClientRect().width) + 6 : 6);
52995
53152
  }, []);
52996
- const onTableScroll = (0, import_react28.useCallback)(() => {
53153
+ const onTableScroll = (0, import_react29.useCallback)(() => {
52997
53154
  const el = scrollRef.current;
52998
53155
  if (!el || el.scrollLeft === hintScrollLeft.current) return;
52999
53156
  updateScrollHint();
@@ -53006,7 +53163,7 @@ function MatrxDataTableCore(coreProps) {
53006
53163
  behavior: "smooth"
53007
53164
  });
53008
53165
  };
53009
- (0, import_react28.useEffect)(() => {
53166
+ (0, import_react29.useEffect)(() => {
53010
53167
  window.addEventListener("resize", updateScrollHint);
53011
53168
  const el = scrollRef.current;
53012
53169
  const observer = el && typeof ResizeObserver !== "undefined" ? new ResizeObserver(updateScrollHint) : null;
@@ -53021,7 +53178,7 @@ function MatrxDataTableCore(coreProps) {
53021
53178
  observer?.disconnect();
53022
53179
  };
53023
53180
  }, [updateScrollHint, data, columns]);
53024
- (0, import_react28.useLayoutEffect)(() => {
53181
+ (0, import_react29.useLayoutEffect)(() => {
53025
53182
  const scroll = scrollRef.current;
53026
53183
  const table = tableRef.current;
53027
53184
  const header = tableHeaderRef.current;
@@ -53080,30 +53237,30 @@ function MatrxDataTableCore(coreProps) {
53080
53237
  window.removeEventListener("resize", requestUpdate);
53081
53238
  };
53082
53239
  }, [stickyHeader, data, columns]);
53083
- const [columnOrder, setColumnOrder] = (0, import_react28.useState)(() => columnState?.order ?? columns.map(columnId));
53084
- const [hiddenColumnIds, setHiddenColumnIds] = (0, import_react28.useState)(
53240
+ const [columnOrder, setColumnOrder] = (0, import_react29.useState)(() => columnState?.order ?? columns.map(columnId));
53241
+ const [hiddenColumnIds, setHiddenColumnIds] = (0, import_react29.useState)(
53085
53242
  () => new Set(columnState?.hidden ?? columns.filter((column) => column.hidden).map(columnId))
53086
53243
  );
53087
- const [columnWidths, setColumnWidths] = (0, import_react28.useState)(
53244
+ const [columnWidths, setColumnWidths] = (0, import_react29.useState)(
53088
53245
  () => normalizeColumnWidthsForColumns(columnState?.widths, columns)
53089
53246
  );
53090
- const [fixedTableGeometry, setFixedTableGeometry] = (0, import_react28.useState)(null);
53091
- const knownColumnIds = (0, import_react28.useRef)(new Set(columns.map(columnId)));
53092
- const draggedColumnId = (0, import_react28.useRef)(null);
53093
- const columnDragActive = (0, import_react28.useRef)(false);
53094
- const columnDragRaf = (0, import_react28.useRef)(null);
53095
- const columnDragScrollDirection = (0, import_react28.useRef)(0);
53096
- const [columnDragPreview, setColumnDragPreview] = (0, import_react28.useState)(null);
53097
- const stopColumnDragScroll = (0, import_react28.useCallback)(() => {
53247
+ const [fixedTableGeometry, setFixedTableGeometry] = (0, import_react29.useState)(null);
53248
+ const knownColumnIds = (0, import_react29.useRef)(new Set(columns.map(columnId)));
53249
+ const draggedColumnId = (0, import_react29.useRef)(null);
53250
+ const columnDragActive = (0, import_react29.useRef)(false);
53251
+ const columnDragRaf = (0, import_react29.useRef)(null);
53252
+ const columnDragScrollDirection = (0, import_react29.useRef)(0);
53253
+ const [columnDragPreview, setColumnDragPreview] = (0, import_react29.useState)(null);
53254
+ const stopColumnDragScroll = (0, import_react29.useCallback)(() => {
53098
53255
  if (columnDragRaf.current !== null) cancelAnimationFrame(columnDragRaf.current);
53099
53256
  columnDragRaf.current = null;
53100
53257
  columnDragScrollDirection.current = 0;
53101
53258
  }, []);
53102
- (0, import_react28.useEffect)(() => () => {
53259
+ (0, import_react29.useEffect)(() => () => {
53103
53260
  columnDragActive.current = false;
53104
53261
  stopColumnDragScroll();
53105
53262
  }, [stopColumnDragScroll]);
53106
- const startColumnDragScroll = (0, import_react28.useCallback)(() => {
53263
+ const startColumnDragScroll = (0, import_react29.useCallback)(() => {
53107
53264
  if (!columnDragActive.current || columnDragRaf.current !== null) return;
53108
53265
  const scrollStep = () => {
53109
53266
  const scroll = scrollRef.current;
@@ -53130,25 +53287,25 @@ function MatrxDataTableCore(coreProps) {
53130
53287
  };
53131
53288
  columnDragRaf.current = requestAnimationFrame(scrollStep);
53132
53289
  }, []);
53133
- const commitColumnState = (0, import_react28.useCallback)((order, hidden) => {
53290
+ const commitColumnState = (0, import_react29.useCallback)((order, hidden) => {
53134
53291
  if (columnState) columnState.onChange({ order, hidden: [...hidden] });
53135
53292
  else {
53136
53293
  setColumnOrder(order);
53137
53294
  setHiddenColumnIds(hidden);
53138
53295
  }
53139
53296
  }, [columnState]);
53140
- const [internalColumnManagerOpen, setInternalColumnManagerOpen] = (0, import_react28.useState)(false);
53297
+ const [internalColumnManagerOpen, setInternalColumnManagerOpen] = (0, import_react29.useState)(false);
53141
53298
  const columnManagerOpen = controlledColumnManager?.open ?? internalColumnManagerOpen;
53142
53299
  const setColumnManagerOpen = controlledColumnManager?.onOpenChange ?? setInternalColumnManagerOpen;
53143
- const columnIds = (0, import_react28.useMemo)(() => columns.map(columnId), [columns]);
53144
- const effectiveColumnOrder = (0, import_react28.useMemo)(() => columnState ? [...columnState.order.filter((id, index, values) => columnIds.includes(id) && values.indexOf(id) === index), ...columnIds.filter((id) => !columnState.order.includes(id))] : columnOrder, [columnIds, columnOrder, columnState]);
53145
- const effectiveHiddenColumnIds = (0, import_react28.useMemo)(() => columnState ? new Set(columnState.hidden.filter((id) => columnIds.includes(id))) : hiddenColumnIds, [columnIds, columnState, hiddenColumnIds]);
53146
- const effectiveColumnWidths = (0, import_react28.useMemo)(
53300
+ const columnIds = (0, import_react29.useMemo)(() => columns.map(columnId), [columns]);
53301
+ const effectiveColumnOrder = (0, import_react29.useMemo)(() => columnState ? [...columnState.order.filter((id, index, values) => columnIds.includes(id) && values.indexOf(id) === index), ...columnIds.filter((id) => !columnState.order.includes(id))] : columnOrder, [columnIds, columnOrder, columnState]);
53302
+ const effectiveHiddenColumnIds = (0, import_react29.useMemo)(() => columnState ? new Set(columnState.hidden.filter((id) => columnIds.includes(id))) : hiddenColumnIds, [columnIds, columnState, hiddenColumnIds]);
53303
+ const effectiveColumnWidths = (0, import_react29.useMemo)(
53147
53304
  () => normalizeColumnWidthsForColumns(columnState?.widths ?? columnWidths, columns),
53148
53305
  [columns, columnState?.widths, columnWidths]
53149
53306
  );
53150
- const resizeGestureSnapshotRef = (0, import_react28.useRef)(null);
53151
- const measureVisibleColumnWidths = (0, import_react28.useCallback)(() => {
53307
+ const resizeGestureSnapshotRef = (0, import_react29.useRef)(null);
53308
+ const measureVisibleColumnWidths = (0, import_react29.useCallback)(() => {
53152
53309
  const measured = {};
53153
53310
  const headers = tableRef.current ? Array.from(tableRef.current.querySelectorAll(
53154
53311
  "thead th[data-matrx-table-column-id]"
@@ -53162,7 +53319,7 @@ function MatrxDataTableCore(coreProps) {
53162
53319
  }
53163
53320
  return normalizeColumnWidthsForColumns(measured, columns);
53164
53321
  }, [columns]);
53165
- const measureFixedTableGeometry = (0, import_react28.useCallback)(() => {
53322
+ const measureFixedTableGeometry = (0, import_react29.useCallback)(() => {
53166
53323
  const table = tableRef.current;
53167
53324
  const headers = table ? Array.from(table.querySelectorAll("thead th")) : [];
53168
53325
  const widthFor = (selector) => {
@@ -53197,16 +53354,16 @@ function MatrxDataTableCore(coreProps) {
53197
53354
  ...actionsWidth === void 0 ? {} : { actionsWidth }
53198
53355
  };
53199
53356
  }, [resolvedDensity]);
53200
- const captureResizeGestureSnapshot = (0, import_react28.useCallback)(() => {
53357
+ const captureResizeGestureSnapshot = (0, import_react29.useCallback)(() => {
53201
53358
  resizeGestureSnapshotRef.current = {
53202
53359
  widths: measureVisibleColumnWidths(),
53203
53360
  geometry: measureFixedTableGeometry()
53204
53361
  };
53205
53362
  }, [measureFixedTableGeometry, measureVisibleColumnWidths]);
53206
- const clearResizeGestureSnapshot = (0, import_react28.useCallback)(() => {
53363
+ const clearResizeGestureSnapshot = (0, import_react29.useCallback)(() => {
53207
53364
  resizeGestureSnapshotRef.current = null;
53208
53365
  }, []);
53209
- const commitColumnWidths = (0, import_react28.useCallback)((next, captureInitialWidths = false) => {
53366
+ const commitColumnWidths = (0, import_react29.useCallback)((next, captureInitialWidths = false) => {
53210
53367
  const gestureSnapshot = captureInitialWidths ? resizeGestureSnapshotRef.current : null;
53211
53368
  resizeGestureSnapshotRef.current = null;
53212
53369
  const normalized = normalizeColumnWidthsForColumns(
@@ -53225,7 +53382,7 @@ function MatrxDataTableCore(coreProps) {
53225
53382
  }
53226
53383
  setColumnWidths(normalized);
53227
53384
  }, [columnIds, columnState, columns, measureFixedTableGeometry, measureVisibleColumnWidths]);
53228
- (0, import_react28.useEffect)(() => {
53385
+ (0, import_react29.useEffect)(() => {
53229
53386
  const ids = columns.map(columnId);
53230
53387
  if (columnState) return;
53231
53388
  const previousIds = knownColumnIds.current;
@@ -53244,31 +53401,31 @@ function MatrxDataTableCore(coreProps) {
53244
53401
  setColumnWidths((current) => normalizeColumnWidthsForColumns(current, columns));
53245
53402
  knownColumnIds.current = new Set(ids);
53246
53403
  }, [columns, columnState]);
53247
- (0, import_react28.useLayoutEffect)(() => {
53404
+ (0, import_react29.useLayoutEffect)(() => {
53248
53405
  for (const id of columnIds) {
53249
53406
  tableRef.current?.style.removeProperty(columnResizeCssVar(id));
53250
53407
  }
53251
53408
  });
53252
- const previewColumnOrder = (0, import_react28.useMemo)(
53409
+ const previewColumnOrder = (0, import_react29.useMemo)(
53253
53410
  () => projectColumnDragOrder(effectiveColumnOrder, columnDragPreview),
53254
53411
  [columnDragPreview, effectiveColumnOrder]
53255
53412
  );
53256
53413
  useColumnReorderAnimation(tableRef, previewColumnOrder.join("\0"), columnDragPreview !== null);
53257
- const visibleColumns = (0, import_react28.useMemo)(() => {
53414
+ const visibleColumns = (0, import_react29.useMemo)(() => {
53258
53415
  const byId = new Map(columns.map((column) => [columnId(column), column]));
53259
53416
  return previewColumnOrder.map((id) => byId.get(id)).filter(
53260
53417
  (column) => column !== void 0 && !effectiveHiddenColumnIds.has(columnId(column))
53261
53418
  );
53262
53419
  }, [columns, effectiveHiddenColumnIds, previewColumnOrder]);
53263
53420
  const usesMeasuredFixedLayout = visibleColumns.length > 0 && visibleColumns.every((column) => effectiveColumnWidths[columnId(column)] !== void 0);
53264
- (0, import_react28.useLayoutEffect)(() => {
53421
+ (0, import_react29.useLayoutEffect)(() => {
53265
53422
  if (!usesMeasuredFixedLayout) {
53266
53423
  if (fixedTableGeometry !== null) setFixedTableGeometry(null);
53267
53424
  return;
53268
53425
  }
53269
53426
  if (fixedTableGeometry === null) setFixedTableGeometry(measureFixedTableGeometry());
53270
53427
  }, [fixedTableGeometry, measureFixedTableGeometry, usesMeasuredFixedLayout]);
53271
- (0, import_react28.useLayoutEffect)(() => {
53428
+ (0, import_react29.useLayoutEffect)(() => {
53272
53429
  if (!usesMeasuredFixedLayout) return;
53273
53430
  const table = tableRef.current;
53274
53431
  if (!table) return;
@@ -53292,8 +53449,8 @@ function MatrxDataTableCore(coreProps) {
53292
53449
  const fixedLayoutActive = usesMeasuredFixedLayout && fixedTableGeometry !== null;
53293
53450
  const freezeWanted = visibleColumns.some((column) => column.frozen);
53294
53451
  const selectionColumnWidth = fixedTableGeometry?.selectionWidth ?? (selection && (freezeWanted || fitToWidth) ? SELECTION_COLUMN_PX : void 0);
53295
- const [fitSpace, setFitSpace] = (0, import_react28.useState)(null);
53296
- (0, import_react28.useLayoutEffect)(() => {
53452
+ const [fitSpace, setFitSpace] = (0, import_react29.useState)(null);
53453
+ (0, import_react29.useLayoutEffect)(() => {
53297
53454
  if (!fitToWidth) {
53298
53455
  setFitSpace(null);
53299
53456
  return;
@@ -53308,13 +53465,24 @@ function MatrxDataTableCore(coreProps) {
53308
53465
  ...strips.map((strip) => Math.ceil(strip.scrollWidth) + 16),
53309
53466
  actionsHeader ? Math.ceil(actionsHeader.scrollWidth) : 0
53310
53467
  );
53468
+ const custom = {};
53469
+ for (const strip of Array.from(el.querySelectorAll("[data-matrx-table-custom-actions]"))) {
53470
+ const id = strip.closest("td")?.getAttribute("data-matrx-table-column-id");
53471
+ if (id) custom[id] = Math.max(custom[id] ?? 0, Math.ceil(strip.scrollWidth) + 16);
53472
+ }
53473
+ for (const id of Object.keys(custom)) {
53474
+ const header = Array.from(el.querySelectorAll("thead th[data-matrx-table-column-id]")).find((th) => th.getAttribute("data-matrx-table-column-id") === id);
53475
+ const inner = header?.firstElementChild;
53476
+ if (inner) custom[id] = Math.max(custom[id], Math.ceil(inner.scrollWidth) + 16);
53477
+ }
53311
53478
  const table2 = el.querySelector(":scope > table");
53312
53479
  const spill = table2 && table2.hasAttribute("data-matrx-table-fit") ? Math.max(0, el.scrollWidth - el.clientWidth) : 0;
53313
53480
  setFitSpace((now) => {
53314
53481
  const sameWidth = now !== null && now.width === el.clientWidth;
53315
53482
  const slack = sameWidth ? now.slack + spill : spill;
53316
- const next = { width: el.clientWidth, actions, slack };
53317
- return now && now.width === next.width && now.actions === next.actions && now.slack === next.slack ? now : next;
53483
+ const next = { width: el.clientWidth, actions, slack, custom };
53484
+ const sameCustom = now !== null && Object.keys(now.custom).length === Object.keys(custom).length && Object.entries(custom).every(([id, w]) => now.custom[id] === w);
53485
+ return now && sameCustom && now.width === next.width && now.actions === next.actions && now.slack === next.slack ? now : next;
53318
53486
  });
53319
53487
  };
53320
53488
  read2();
@@ -53325,13 +53493,14 @@ function MatrxDataTableCore(coreProps) {
53325
53493
  if (table) observer.observe(table);
53326
53494
  return () => observer.disconnect();
53327
53495
  }, [fitToWidth, data.length]);
53328
- const fittedWidths = (0, import_react28.useMemo)(() => {
53496
+ const fittedWidths = (0, import_react29.useMemo)(() => {
53329
53497
  if (!fitToWidth || !fitSpace) return null;
53330
- const keepsItsWidth = (col) => resolveColumnMarker(col) !== void 0 || col.resizable === false && pixelWidth(col.width) !== void 0;
53498
+ const contentWidth = (col) => col.customActions ? fitSpace.custom[columnId(col)] : void 0;
53499
+ const keepsItsWidth = (col) => resolveColumnMarker(col) !== void 0 || col.resizable === false && pixelWidth(col.width) !== void 0 || contentWidth(col) !== void 0;
53331
53500
  const scaling = visibleColumns.filter((col) => !keepsItsWidth(col));
53332
- const fixed = visibleColumns.filter(keepsItsWidth).reduce((sum, col) => sum + (pixelWidth(col.width) ?? 40), 0);
53501
+ const fixed = visibleColumns.filter(keepsItsWidth).reduce((sum, col) => sum + (contentWidth(col) ?? pixelWidth(col.width) ?? 40), 0);
53333
53502
  const utilities = (selection ? selectionColumnWidth ?? SELECTION_COLUMN_PX : 0) + fitSpace.actions;
53334
- return fitColumnWidths(
53503
+ const shares = fitColumnWidths(
53335
53504
  scaling.map(columnId),
53336
53505
  (id) => {
53337
53506
  const col = scaling.find((c) => columnId(c) === id);
@@ -53339,10 +53508,17 @@ function MatrxDataTableCore(coreProps) {
53339
53508
  },
53340
53509
  fitSpace.width - utilities - fixed - fitSpace.slack
53341
53510
  );
53511
+ if (!shares) return null;
53512
+ const out = { ...shares };
53513
+ for (const col of visibleColumns) {
53514
+ const w = contentWidth(col);
53515
+ if (w !== void 0) out[columnId(col)] = w;
53516
+ }
53517
+ return out;
53342
53518
  }, [fitToWidth, fitSpace, visibleColumns, selection, selectionColumnWidth, effectiveColumnWidths]);
53343
53519
  const fitActive = fittedWidths !== null;
53344
53520
  const actionsColumnWidth = fitActive && fitSpace ? fitSpace.actions : fixedTableGeometry?.actionsWidth;
53345
- const frozenColumns = (0, import_react28.useMemo)(() => {
53521
+ const frozenColumns = (0, import_react29.useMemo)(() => {
53346
53522
  if (!freezeWanted) return NO_FROZEN_COLUMNS;
53347
53523
  const ids = visibleColumns.map(columnId);
53348
53524
  const byId = new Map(visibleColumns.map((column) => [columnId(column), column]));
@@ -53390,15 +53566,18 @@ function MatrxDataTableCore(coreProps) {
53390
53566
  const color = cellTintColor(row, id, colId);
53391
53567
  return color ? CELL_TINT_CLASS[color] : void 0;
53392
53568
  };
53393
- const declaredVisibleCopyColumns = (0, import_react28.useMemo)(
53569
+ const declaredVisibleCopyColumns = (0, import_react29.useMemo)(
53394
53570
  () => visibleColumns.filter((column) => column.accessorFn !== void 0 || column.accessorKey !== void 0),
53395
53571
  [visibleColumns]
53396
53572
  );
53397
- const tableCopySourceNamespace = (0, import_react28.useId)();
53398
- const tableContextMenuInstanceId = (0, import_react28.useId)();
53399
- const tableDndContextId = (0, import_react28.useId)();
53573
+ const tableCopySourceNamespace = (0, import_react29.useId)();
53574
+ const tableContextMenuInstanceId = (0, import_react29.useId)();
53575
+ const tableDndContextId = (0, import_react29.useId)();
53400
53576
  const defaultCopyTitle = toolbar?.title || "Table";
53401
- const defaultCopy = (0, import_react28.useMemo)(() => ({
53577
+ const copyColumnsLatest = (0, import_react29.useRef)(declaredVisibleCopyColumns);
53578
+ copyColumnsLatest.current = declaredVisibleCopyColumns;
53579
+ const readDeclaredCopyColumns = lazyCallback(() => copyColumnsLatest.current);
53580
+ const defaultCopy = (0, import_react29.useMemo)(() => ({
53402
53581
  label: defaultCopyTitle,
53403
53582
  listLabel: defaultCopyTitle,
53404
53583
  location: defaultCopyTitle,
@@ -53407,23 +53586,23 @@ function MatrxDataTableCore(coreProps) {
53407
53586
  listDescription: `${defaultCopyTitle} \u2014 ${remoteQuery ? "current filtered/sorted loaded view" : "current filtered/sorted view"}.`,
53408
53587
  listAttributes: (_visible, loaded) => remoteQuery ? { coverage: "loaded-current-view", loaded_count: loaded.length } : { coverage: "current-view" },
53409
53588
  humanRow: (row) => formatDefaultTableCopyRecord(
53410
- projectDefaultTableCopyRow(row, declaredVisibleCopyColumns),
53411
- declaredVisibleCopyColumns
53589
+ projectDefaultTableCopyRow(row, copyColumnsLatest.current),
53590
+ copyColumnsLatest.current
53412
53591
  ),
53413
- agentRow: (row) => projectDefaultTableCopyRow(row, declaredVisibleCopyColumns)
53414
- }), [defaultCopyTitle, declaredVisibleCopyColumns, remoteQuery]);
53592
+ agentRow: (row) => projectDefaultTableCopyRow(row, copyColumnsLatest.current)
53593
+ }), [defaultCopyTitle, remoteQuery]);
53415
53594
  const effectiveCopy = copy === false ? void 0 : copy ?? defaultCopy;
53416
- const visibleDataColumns = (0, import_react28.useMemo)(() => visibleColumns.filter((column) => !column.customActions), [visibleColumns]);
53595
+ const visibleDataColumns = (0, import_react29.useMemo)(() => visibleColumns.filter((column) => !column.customActions), [visibleColumns]);
53417
53596
  const effectiveCopyColumns = copy === void 0 ? declaredVisibleCopyColumns : visibleDataColumns;
53418
53597
  const copySubsetVariant2 = useCopySubsetVariant();
53419
- const chromeLatest = (0, import_react28.useRef)({
53598
+ const chromeLatest = (0, import_react29.useRef)({
53420
53599
  processed: [],
53421
53600
  data: [],
53422
53601
  toggleAllOnPage: () => void 0,
53423
53602
  showMore: async () => void 0,
53424
53603
  applySavedView: () => void 0
53425
53604
  });
53426
- const applyLatestSavedView = (0, import_react28.useCallback)((snapshot) => chromeLatest.current.applySavedView(snapshot), []);
53605
+ const applyLatestSavedView = (0, import_react29.useCallback)((snapshot) => chromeLatest.current.applySavedView(snapshot), []);
53427
53606
  const copySubsetColumns = () => effectiveCopyColumns.filter((c) => c.filter !== false || c.accessorKey || c.accessorFn).map((c) => ({
53428
53607
  id: columnId(c),
53429
53608
  header: typeof c.header === "string" ? c.header : columnId(c),
@@ -53444,7 +53623,7 @@ function MatrxDataTableCore(coreProps) {
53444
53623
  serializer: (shaped) => buildViewAgentInput(effectiveCopy, shaped, chromeLatest.current.data, { scope: "custom" })
53445
53624
  }), copySubsetSize(rows().length, copySubsetColumns().length))
53446
53625
  ] : [];
53447
- const filterMeta = (0, import_react28.useMemo)(() => {
53626
+ const filterMeta = (0, import_react29.useMemo)(() => {
53448
53627
  const meta = /* @__PURE__ */ new Map();
53449
53628
  for (const col of visibleColumns) {
53450
53629
  const id = columnId(col);
@@ -53452,14 +53631,14 @@ function MatrxDataTableCore(coreProps) {
53452
53631
  }
53453
53632
  return meta;
53454
53633
  }, [visibleColumns, data, remoteQuery]);
53455
- const intelligentSearchScopes = (0, import_react28.useMemo)(
53634
+ const intelligentSearchScopes = (0, import_react29.useMemo)(
53456
53635
  () => resolveTableSearchScopes(data, columns, {
53457
53636
  ...toolbar?.intelligentSearch?.roles === void 0 ? {} : { roles: toolbar.intelligentSearch.roles },
53458
53637
  ...toolbar?.intelligentSearch?.scopes === void 0 ? {} : { scopes: toolbar.intelligentSearch.scopes }
53459
53638
  }),
53460
53639
  [columns, data, toolbar?.intelligentSearch?.roles, toolbar?.intelligentSearch?.scopes]
53461
53640
  );
53462
- const processed = (0, import_react28.useMemo)(() => {
53641
+ const processed = (0, import_react29.useMemo)(() => {
53463
53642
  if (remoteQuery && !appendUsesLocalProcessing && !remoteQueryUsesLocalProcessing) return data;
53464
53643
  if (processLocalRows) {
53465
53644
  return processLocalRows(data, {
@@ -53523,8 +53702,8 @@ function MatrxDataTableCore(coreProps) {
53523
53702
  intelligentSearchEnabled,
53524
53703
  searchScope
53525
53704
  ]);
53526
- const lastNotifiedViewRows = (0, import_react28.useRef)(null);
53527
- (0, import_react28.useEffect)(() => {
53705
+ const lastNotifiedViewRows = (0, import_react29.useRef)(null);
53706
+ (0, import_react29.useEffect)(() => {
53528
53707
  if (!onViewChange) {
53529
53708
  lastNotifiedViewRows.current = null;
53530
53709
  return;
@@ -53533,7 +53712,7 @@ function MatrxDataTableCore(coreProps) {
53533
53712
  lastNotifiedViewRows.current = processed;
53534
53713
  if (changed) onViewChange(processed);
53535
53714
  }, [processed, onViewChange]);
53536
- (0, import_react28.useEffect)(() => {
53715
+ (0, import_react29.useEffect)(() => {
53537
53716
  if (controlledQuery) return;
53538
53717
  setInternalPage(1);
53539
53718
  }, [
@@ -53581,7 +53760,7 @@ function MatrxDataTableCore(coreProps) {
53581
53760
  numberedPageHasMore: !hidePagination && !isLoading && !isFetching && processed.length > 0 && safePage < pageCount && (remoteQuery?.mode === "controlled" || !remoteQuery),
53582
53761
  onPageAdvance: setPage
53583
53762
  });
53584
- const paginated = (0, import_react28.useMemo)(() => {
53763
+ const paginated = (0, import_react29.useMemo)(() => {
53585
53764
  if (remoteQuery) return processed;
53586
53765
  if (hidePagination) return processed;
53587
53766
  if (localProgressiveEnabled) return [...progressiveRows.rows];
@@ -53591,16 +53770,16 @@ function MatrxDataTableCore(coreProps) {
53591
53770
  }, [processed, safePage, effectivePageSize, pageSize, remoteQuery, hidePagination, localProgressiveEnabled, progressiveRows.rows]);
53592
53771
  const drillGrouped = Boolean(drill && drill.question.by.length > 0);
53593
53772
  const groupingColumnId = drill ? null : grouping?.columnId ?? null;
53594
- const [uncontrolledCollapsed, setUncontrolledCollapsed] = (0, import_react28.useState)([]);
53773
+ const [uncontrolledCollapsed, setUncontrolledCollapsed] = (0, import_react29.useState)([]);
53595
53774
  const collapsedGroups = grouping?.collapsed ?? uncontrolledCollapsed;
53596
- const setCollapsedGroups = (0, import_react28.useCallback)(
53775
+ const setCollapsedGroups = (0, import_react29.useCallback)(
53597
53776
  (next) => {
53598
53777
  if (grouping?.onCollapsedChange) grouping.onCollapsedChange(next);
53599
53778
  else setUncontrolledCollapsed(next);
53600
53779
  },
53601
53780
  [grouping]
53602
53781
  );
53603
- const groups = (0, import_react28.useMemo)(() => {
53782
+ const groups = (0, import_react29.useMemo)(() => {
53604
53783
  if (!grouping || !groupingColumnId) return null;
53605
53784
  const groupColumn = columns.find((col) => columnId(col) === groupingColumnId);
53606
53785
  if (!groupColumn) return null;
@@ -53619,7 +53798,7 @@ function MatrxDataTableCore(coreProps) {
53619
53798
  ...grouping.emptyLabel ? { emptyLabel: grouping.emptyLabel } : {}
53620
53799
  });
53621
53800
  }, [grouping, groupingColumnId, columns, paginated]);
53622
- const groupableColumns = (0, import_react28.useMemo)(() => {
53801
+ const groupableColumns = (0, import_react29.useMemo)(() => {
53623
53802
  const allowed = grouping?.groupableColumnIds;
53624
53803
  return visibleColumns.filter((col) => {
53625
53804
  const id = columnId(col);
@@ -53627,7 +53806,7 @@ function MatrxDataTableCore(coreProps) {
53627
53806
  return col.accessorKey !== void 0 || col.accessorFn !== void 0;
53628
53807
  });
53629
53808
  }, [visibleColumns, grouping?.groupableColumnIds]);
53630
- const groupedRenderRows = (0, import_react28.useMemo)(
53809
+ const groupedRenderRows = (0, import_react29.useMemo)(
53631
53810
  () => groups ? flattenGroups(groups, collapsedGroups) : null,
53632
53811
  [groups, collapsedGroups]
53633
53812
  );
@@ -53639,7 +53818,7 @@ function MatrxDataTableCore(coreProps) {
53639
53818
  const bodyEntryCount = groupedRenderRows ? groupedRenderRows.length : paginated.length;
53640
53819
  const virtualizeActive = virtualizeConfig !== null && virtualizeConfig.enabled !== false && bodyEntryCount > virtualThreshold && !hierarchy && expandedDetail === void 0;
53641
53820
  const columnWindowWidth = virtualizeConfig?.columnWidth ?? 160;
53642
- const frozenRunLength = (0, import_react28.useMemo)(() => {
53821
+ const frozenRunLength = (0, import_react29.useMemo)(() => {
53643
53822
  let run = 0;
53644
53823
  for (const col of visibleColumns) {
53645
53824
  if (frozenColumns.offsets[columnId(col)] === void 0) break;
@@ -53648,9 +53827,9 @@ function MatrxDataTableCore(coreProps) {
53648
53827
  return run;
53649
53828
  }, [visibleColumns, frozenColumns]);
53650
53829
  const columnVirtualizeActive = virtualizeConfig !== null && virtualizeConfig.enabled !== false && virtualizeConfig.columns === true && visibleColumns.length - frozenRunLength > 30 && !hierarchy && mobileCards === void 0;
53651
- const [rowWindow, setRowWindow] = (0, import_react28.useState)(null);
53652
- const [columnWindow, setColumnWindow] = (0, import_react28.useState)(null);
53653
- const windowInputs = (0, import_react28.useRef)({
53830
+ const [rowWindow, setRowWindow] = (0, import_react29.useState)(null);
53831
+ const [columnWindow, setColumnWindow] = (0, import_react29.useState)(null);
53832
+ const windowInputs = (0, import_react29.useRef)({
53654
53833
  virtualizeActive: false,
53655
53834
  bodyEntryCount: 0,
53656
53835
  virtualRowHeight: 40,
@@ -53670,7 +53849,7 @@ function MatrxDataTableCore(coreProps) {
53670
53849
  columnWindowWidth,
53671
53850
  frozenRunLength
53672
53851
  };
53673
- const recomputeWindows = (0, import_react28.useCallback)(() => {
53852
+ const recomputeWindows = (0, import_react29.useCallback)(() => {
53674
53853
  const el = scrollRef.current;
53675
53854
  const input = windowInputs.current;
53676
53855
  const nextRow = input.virtualizeActive ? computeWindow({
@@ -53691,7 +53870,7 @@ function MatrxDataTableCore(coreProps) {
53691
53870
  setRowWindow((prev) => sameWindow(prev, nextRow) ? prev : nextRow);
53692
53871
  setColumnWindow((prev) => sameWindow(prev, nextColumn) ? prev : nextColumn);
53693
53872
  }, []);
53694
- const effectiveRowWindow = (0, import_react28.useMemo)(() => {
53873
+ const effectiveRowWindow = (0, import_react29.useMemo)(() => {
53695
53874
  if (!virtualizeActive) return null;
53696
53875
  if (rowWindow && rowWindow.end <= bodyEntryCount) return rowWindow;
53697
53876
  return computeWindow({
@@ -53702,7 +53881,7 @@ function MatrxDataTableCore(coreProps) {
53702
53881
  overscan: virtualizeConfig?.overscan ?? 8
53703
53882
  });
53704
53883
  }, [virtualizeActive, rowWindow, bodyEntryCount, virtualRowHeight, virtualizeConfig?.overscan]);
53705
- const effectiveColumnWindow = (0, import_react28.useMemo)(() => {
53884
+ const effectiveColumnWindow = (0, import_react29.useMemo)(() => {
53706
53885
  if (!columnVirtualizeActive) return null;
53707
53886
  if (columnWindow && columnWindow.end <= visibleColumns.length) return columnWindow;
53708
53887
  return computeWindow({
@@ -53722,7 +53901,7 @@ function MatrxDataTableCore(coreProps) {
53722
53901
  frozenRunLength
53723
53902
  ]);
53724
53903
  const metricsWanted = virtualizeActive || columnVirtualizeActive;
53725
- (0, import_react28.useEffect)(() => {
53904
+ (0, import_react29.useEffect)(() => {
53726
53905
  recomputeWindows();
53727
53906
  }, [
53728
53907
  recomputeWindows,
@@ -53734,7 +53913,7 @@ function MatrxDataTableCore(coreProps) {
53734
53913
  columnWindowWidth,
53735
53914
  frozenRunLength
53736
53915
  ]);
53737
- (0, import_react28.useEffect)(() => {
53916
+ (0, import_react29.useEffect)(() => {
53738
53917
  if (!metricsWanted) return;
53739
53918
  const el = scrollRef.current;
53740
53919
  if (!el) return;
@@ -53755,7 +53934,7 @@ function MatrxDataTableCore(coreProps) {
53755
53934
  observer?.disconnect();
53756
53935
  };
53757
53936
  }, [metricsWanted, recomputeWindows]);
53758
- const renderedColumns = (0, import_react28.useMemo)(
53937
+ const renderedColumns = (0, import_react29.useMemo)(
53759
53938
  () => effectiveColumnWindow ? [
53760
53939
  ...visibleColumns.slice(0, frozenRunLength),
53761
53940
  ...visibleColumns.slice(effectiveColumnWindow.start, effectiveColumnWindow.end)
@@ -53763,7 +53942,7 @@ function MatrxDataTableCore(coreProps) {
53763
53942
  [effectiveColumnWindow, visibleColumns, frozenRunLength]
53764
53943
  );
53765
53944
  const columnSpacers = effectiveColumnWindow ? { start: effectiveColumnWindow.padStart, end: effectiveColumnWindow.padEnd } : null;
53766
- const windowedWidthFor = (0, import_react28.useCallback)(
53945
+ const windowedWidthFor = (0, import_react29.useCallback)(
53767
53946
  (id, declared) => {
53768
53947
  const fitted = fittedWidths?.[id];
53769
53948
  if (fitted !== void 0) return fitted;
@@ -53775,7 +53954,7 @@ function MatrxDataTableCore(coreProps) {
53775
53954
  [effectiveColumnWindow, effectiveColumnWidths, frozenColumns, columnWindowWidth, fittedWidths]
53776
53955
  );
53777
53956
  const coverageUnanswered = readView.failure || read?.status === "loading" && data.length === 0;
53778
- const coverageResult = (0, import_react28.useMemo)(() => {
53957
+ const coverageResult = (0, import_react29.useMemo)(() => {
53779
53958
  if (!coverage || coverageUnanswered) return null;
53780
53959
  return describeCoverage({
53781
53960
  loaded: coverage.loaded ?? data.length,
@@ -53786,7 +53965,7 @@ function MatrxDataTableCore(coreProps) {
53786
53965
  ...coverage.noun === void 0 ? {} : { noun: coverage.noun }
53787
53966
  });
53788
53967
  }, [coverage, coverageUnanswered, data.length]);
53789
- const bodyEntries = (0, import_react28.useMemo)(() => {
53968
+ const bodyEntries = (0, import_react29.useMemo)(() => {
53790
53969
  const from = effectiveRowWindow ? effectiveRowWindow.start : 0;
53791
53970
  const to = effectiveRowWindow ? effectiveRowWindow.end : void 0;
53792
53971
  const windowed = groupedRenderRows ? groupedRenderRows.slice(from, to).map(
@@ -53803,28 +53982,28 @@ function MatrxDataTableCore(coreProps) {
53803
53982
  windowed.push({ kind: "spacer", height: effectiveRowWindow.padEnd, place: "end" });
53804
53983
  return windowed;
53805
53984
  }, [groupedRenderRows, collapsedGroups, paginated, effectiveRowWindow]);
53806
- const getRowIdRef = (0, import_react28.useRef)(getRowId);
53985
+ const getRowIdRef = (0, import_react29.useRef)(getRowId);
53807
53986
  getRowIdRef.current = getRowId;
53808
- const spreadsheetRowIds = (0, import_react28.useMemo)(
53987
+ const spreadsheetRowIds = (0, import_react29.useMemo)(
53809
53988
  () => paginated.map((row) => getRowIdRef.current(row)),
53810
53989
  [paginated]
53811
53990
  );
53812
- const spreadsheetColumnIds = (0, import_react28.useMemo)(
53991
+ const spreadsheetColumnIds = (0, import_react29.useMemo)(
53813
53992
  () => visibleColumns.filter((col) => !col.customActions).map((col) => columnId(col)),
53814
53993
  [visibleColumns]
53815
53994
  );
53816
- const spreadsheetRowById = (0, import_react28.useMemo)(() => {
53995
+ const spreadsheetRowById = (0, import_react29.useMemo)(() => {
53817
53996
  const map = /* @__PURE__ */ new Map();
53818
53997
  for (const row of paginated) map.set(getRowIdRef.current(row), row);
53819
53998
  return map;
53820
53999
  }, [paginated]);
53821
- const spreadsheetColumnById = (0, import_react28.useMemo)(() => {
54000
+ const spreadsheetColumnById = (0, import_react29.useMemo)(() => {
53822
54001
  const map = /* @__PURE__ */ new Map();
53823
54002
  for (const col of visibleColumns) if (!col.customActions) map.set(columnId(col), col);
53824
54003
  return map;
53825
54004
  }, [visibleColumns]);
53826
54005
  const spreadsheetEnabled = Boolean(spreadsheet && spreadsheet.enabled !== false);
53827
- const openRowRef = (0, import_react28.useRef)(() => void 0);
54006
+ const openRowRef = (0, import_react29.useRef)(() => void 0);
53828
54007
  const sheet = useSpreadsheetGrid(
53829
54008
  spreadsheetEnabled && spreadsheet ? {
53830
54009
  rowIds: spreadsheetRowIds,
@@ -53866,12 +54045,12 @@ function MatrxDataTableCore(coreProps) {
53866
54045
  } : null
53867
54046
  );
53868
54047
  if (spreadsheet?.controllerRef) spreadsheet.controllerRef.current = spreadsheetEnabled ? sheet.controller : null;
53869
- const sheetRef = (0, import_react28.useRef)(sheet);
54048
+ const sheetRef = (0, import_react29.useRef)(sheet);
53870
54049
  sheetRef.current = sheet;
53871
- const onSheetSelectionRef = (0, import_react28.useRef)(spreadsheet?.onSelectionChange);
54050
+ const onSheetSelectionRef = (0, import_react29.useRef)(spreadsheet?.onSelectionChange);
53872
54051
  onSheetSelectionRef.current = spreadsheet?.onSelectionChange;
53873
54052
  const sheetSelectionKey = sheet.range ? `${sheet.range.anchor.rowId}\0${sheet.range.anchor.fieldName}\0${sheet.range.focus.rowId}\0${sheet.range.focus.fieldName}\0${sheet.bounds ? `${sheet.bounds.r0}:${sheet.bounds.r1}:${sheet.bounds.c0}:${sheet.bounds.c1}` : ""}` : "";
53874
- (0, import_react28.useEffect)(() => {
54053
+ (0, import_react29.useEffect)(() => {
53875
54054
  const tell = onSheetSelectionRef.current;
53876
54055
  if (!tell) return;
53877
54056
  const current = sheetRef.current;
@@ -53888,12 +54067,12 @@ function MatrxDataTableCore(coreProps) {
53888
54067
  tsv: current.selectionTsv()
53889
54068
  });
53890
54069
  }, [sheetSelectionKey]);
53891
- const searchValueRef = (0, import_react28.useRef)(searchValue);
54070
+ const searchValueRef = (0, import_react29.useRef)(searchValue);
53892
54071
  searchValueRef.current = searchValue;
53893
54072
  const facetsEnabled = Boolean(facets && facets.enabled !== false);
53894
54073
  const coreSuggestionsEnabled = facets?.enabled !== false;
53895
- const [facetState, setFacetState] = (0, import_react28.useState)({});
53896
- const facetReadCell = (0, import_react28.useCallback)(
54074
+ const [facetState, setFacetState] = (0, import_react29.useState)({});
54075
+ const facetReadCell = (0, import_react29.useCallback)(
53897
54076
  (row, colId) => {
53898
54077
  if (facets?.readCell) return facets.readCell(row, colId);
53899
54078
  const col = visibleColumns.find((candidate) => columnId(candidate) === colId);
@@ -53903,11 +54082,11 @@ function MatrxDataTableCore(coreProps) {
53903
54082
  );
53904
54083
  const coreFacetTotal = remoteQuery?.mode === "controlled" ? remoteQuery.totalItems : appendQuery?.pagination.sourceRecords?.total ?? coverage?.matched ?? coverage?.total;
53905
54084
  const coreFacetLoaded = appendQuery?.pagination.sourceRecords?.loaded;
53906
- const facetInputsRef = (0, import_react28.useRef)({ data, facets, facetReadCell, coreFacetTotal, coreFacetLoaded });
54085
+ const facetInputsRef = (0, import_react29.useRef)({ data, facets, facetReadCell, coreFacetTotal, coreFacetLoaded });
53907
54086
  facetInputsRef.current = { data, facets, facetReadCell, coreFacetTotal, coreFacetLoaded };
53908
- const facetRequestRef = (0, import_react28.useRef)(/* @__PURE__ */ new Map());
53909
- const requestedFacetColumns = (0, import_react28.useRef)(/* @__PURE__ */ new Set());
53910
- const requestFacets = (0, import_react28.useCallback)((colId) => {
54087
+ const facetRequestRef = (0, import_react29.useRef)(/* @__PURE__ */ new Map());
54088
+ const requestedFacetColumns = (0, import_react29.useRef)(/* @__PURE__ */ new Set());
54089
+ const requestFacets = (0, import_react29.useCallback)((colId) => {
53911
54090
  requestedFacetColumns.current.add(colId);
53912
54091
  const { data: rows, facets: config, facetReadCell: readCell, coreFacetTotal: total, coreFacetLoaded: loaded } = facetInputsRef.current;
53913
54092
  if (!config || config.enabled === false) {
@@ -53990,7 +54169,7 @@ function MatrxDataTableCore(coreProps) {
53990
54169
  }));
53991
54170
  });
53992
54171
  }, []);
53993
- (0, import_react28.useEffect)(() => {
54172
+ (0, import_react29.useEffect)(() => {
53994
54173
  setFacetState((current) => Object.keys(current).length === 0 ? current : {});
53995
54174
  for (const [colId, ticket] of facetRequestRef.current) {
53996
54175
  facetRequestRef.current.set(colId, ticket + 1);
@@ -54000,15 +54179,15 @@ function MatrxDataTableCore(coreProps) {
54000
54179
  }
54001
54180
  }, [facetsEnabled, coreSuggestionsEnabled, data, searchValue, coreFacetTotal, coreFacetLoaded, requestFacets]);
54002
54181
  const totalIsKnown = !isLoading && !readView.failure;
54003
- (0, import_react28.useEffect)(() => {
54182
+ (0, import_react29.useEffect)(() => {
54004
54183
  if (!controlledQuery || !totalIsKnown || controlledQuery.state.page === safePage) return;
54005
54184
  emitControlledQueryChange({ page: safePage });
54006
54185
  }, [controlledQuery, emitControlledQueryChange, safePage, totalIsKnown]);
54007
- const selectedRow = (0, import_react28.useMemo)(() => {
54186
+ const selectedRow = (0, import_react29.useMemo)(() => {
54008
54187
  if (!selectedId) return null;
54009
54188
  return data.find((r) => getRowId(r) === selectedId) ?? null;
54010
54189
  }, [data, selectedId, getRowId]);
54011
- const windowRow = (0, import_react28.useMemo)(() => {
54190
+ const windowRow = (0, import_react29.useMemo)(() => {
54012
54191
  if (!windowRowId) return null;
54013
54192
  return data.find((r) => getRowId(r) === windowRowId) ?? (windowRowSnapshot && windowRowSnapshot.queryKey === appendQueryKey && getRowId(windowRowSnapshot.row) === windowRowId ? windowRowSnapshot.row : null);
54014
54193
  }, [data, windowRowId, windowRowSnapshot, getRowId, appendQueryKey]);
@@ -54021,7 +54200,8 @@ function MatrxDataTableCore(coreProps) {
54021
54200
  const showRowCopy = effectiveCopy !== void 0 && effectiveCopy.showRow !== false;
54022
54201
  const menuActionsColumn = visibleColumns.find((column) => column.customActions);
54023
54202
  const rowCopyInMenu = rowCopyPlacement === "menu" && menuActionsColumn !== void 0;
54024
- const showInlineRowCopy = showRowCopy && !rowCopyInMenu;
54203
+ const rowCopyInCustomColumn = showRowCopy && !rowCopyInMenu && menuActionsColumn !== void 0;
54204
+ const showInlineRowCopy = showRowCopy && !rowCopyInMenu && !rowCopyInCustomColumn;
54025
54205
  const showToolbarCopy = effectiveCopy !== void 0 && effectiveCopy.showToolbar !== false;
54026
54206
  const placeToolbar = (node) => {
54027
54207
  if (toolbar && "portalInto" in toolbar) {
@@ -54034,14 +54214,14 @@ function MatrxDataTableCore(coreProps) {
54034
54214
  const reportCardTotal = embedded ? tableCard?.reportTotal : void 0;
54035
54215
  const cardTotal = appendQuery ? appendQuery.pagination.totalItems : remoteQuery?.mode === "controlled" ? isLoading ? void 0 : remoteQuery.totalItems : isLoading ? void 0 : sourceProcessing ? sourceTotal : data.length;
54036
54216
  const embeddedControlledPage = embedded && remoteQuery?.mode === "controlled" ? remoteQuery.state.page : 1;
54037
- (0, import_react28.useEffect)(() => {
54217
+ (0, import_react29.useEffect)(() => {
54038
54218
  if (embeddedControlledPage !== 1) emitControlledQueryChange({ page: 1 });
54039
54219
  }, [embeddedControlledPage]);
54040
- (0, import_react28.useEffect)(() => {
54220
+ (0, import_react29.useEffect)(() => {
54041
54221
  reportCardTotal?.(cardTotal);
54042
54222
  }, [reportCardTotal, cardTotal]);
54043
- (0, import_react28.useEffect)(() => () => reportCardTotal?.(void 0), [reportCardTotal]);
54044
- const [pinnedEl, setPinnedEl] = (0, import_react28.useState)(null);
54223
+ (0, import_react29.useEffect)(() => () => reportCardTotal?.(void 0), [reportCardTotal]);
54224
+ const [pinnedEl, setPinnedEl] = (0, import_react29.useState)(null);
54045
54225
  const pinnedRowActive = Boolean(
54046
54226
  toolbar?.singleRow && toolbar.overflow && toolbar.overflow.mode !== "sheet" && (toolbar.overflow.pinned || toolbar.overflow.mode === "menu")
54047
54227
  );
@@ -54105,7 +54285,7 @@ function MatrxDataTableCore(coreProps) {
54105
54285
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
54106
54286
  MatrxTableRowAlchemyProvider,
54107
54287
  {
54108
- copy: tableRowCopyProps(effectiveCopy, row, `${tableCopySourceNamespace}:row:${getRowId(row)}`, copy === void 0 ? declaredVisibleCopyColumns : void 0),
54288
+ copy: tableRowCopyProps(effectiveCopy, row, `${tableCopySourceNamespace}:row:${getRowId(row)}`, copy === void 0 ? readDeclaredCopyColumns : void 0),
54109
54289
  placement: rowCopyInMenu ? "menu" : "inline",
54110
54290
  controls,
54111
54291
  children: scopedActions
@@ -54161,7 +54341,7 @@ function MatrxDataTableCore(coreProps) {
54161
54341
  ...resolveSummaryValue(summary?.source?.totals?.[id], value)
54162
54342
  }));
54163
54343
  const hasSummaryTotals = summaryTotals.length > 0;
54164
- const changeCount = (0, import_react28.useMemo)(() => {
54344
+ const changeCount = (0, import_react29.useMemo)(() => {
54165
54345
  let n = 0;
54166
54346
  for (const fields of Object.values(edits)) {
54167
54347
  n += Object.keys(fields).length;
@@ -54346,7 +54526,7 @@ function MatrxDataTableCore(coreProps) {
54346
54526
  }));
54347
54527
  return true;
54348
54528
  };
54349
- const requestCellEditRef = (0, import_react28.useRef)(requestCellEdit);
54529
+ const requestCellEditRef = (0, import_react29.useRef)(requestCellEdit);
54350
54530
  requestCellEditRef.current = requestCellEdit;
54351
54531
  const buildRecordControls = (row) => {
54352
54532
  const rowId = getRowId(row);
@@ -54373,7 +54553,7 @@ function MatrxDataTableCore(coreProps) {
54373
54553
  };
54374
54554
  const hierarchyRows = hierarchy?.rows ?? data;
54375
54555
  const hierarchyGetParentId = hierarchy?.getParentId;
54376
- const hierarchyIndex = (0, import_react28.useMemo)(() => {
54556
+ const hierarchyIndex = (0, import_react29.useMemo)(() => {
54377
54557
  if (!hierarchyGetParentId) return null;
54378
54558
  const byId = /* @__PURE__ */ new Map();
54379
54559
  const parentById = /* @__PURE__ */ new Map();
@@ -54405,7 +54585,7 @@ function MatrxDataTableCore(coreProps) {
54405
54585
  return { byId, parentById, depthById };
54406
54586
  }, [hierarchyGetParentId, hierarchyRows, getRowId]);
54407
54587
  const draggedRow = draggedRowId && hierarchyIndex ? hierarchyIndex.byId.get(draggedRowId) : void 0;
54408
- const hierarchyBlockedIds = (0, import_react28.useMemo)(() => {
54588
+ const hierarchyBlockedIds = (0, import_react29.useMemo)(() => {
54409
54589
  if (!draggedRowId || !hierarchyIndex) return null;
54410
54590
  const childrenById = /* @__PURE__ */ new Map();
54411
54591
  for (const [id, parentId] of hierarchyIndex.parentById) {
@@ -54692,16 +54872,16 @@ function MatrxDataTableCore(coreProps) {
54692
54872
  return [];
54693
54873
  }
54694
54874
  };
54695
- const menuSectionsForRef = (0, import_react28.useRef)(menuSectionsFor);
54875
+ const menuSectionsForRef = (0, import_react29.useRef)(menuSectionsFor);
54696
54876
  menuSectionsForRef.current = menuSectionsFor;
54697
54877
  const hasMenuSections = Boolean(contextMenu?.sections);
54698
- const boundarySections = (0, import_react28.useCallback)(
54878
+ const boundarySections = (0, import_react29.useCallback)(
54699
54879
  (target) => menuSectionsForRef.current(target),
54700
54880
  []
54701
54881
  );
54702
- const resolveMenuLevelRef = (0, import_react28.useRef)(resolveMenuLevel);
54882
+ const resolveMenuLevelRef = (0, import_react29.useRef)(resolveMenuLevel);
54703
54883
  resolveMenuLevelRef.current = resolveMenuLevel;
54704
- (0, import_react28.useEffect)(() => {
54884
+ (0, import_react29.useEffect)(() => {
54705
54885
  if (!host.rowContextRegistry) return;
54706
54886
  return host.rowContextRegistry.register(
54707
54887
  tableContextMenuInstanceId,
@@ -54709,8 +54889,10 @@ function MatrxDataTableCore(coreProps) {
54709
54889
  );
54710
54890
  }, [host.rowContextRegistry, tableContextMenuInstanceId]);
54711
54891
  const showActionsCol = windowEnabled || Boolean(rowActions) || showInlineRowCopy;
54892
+ const lastVisibleColumn = visibleColumns[visibleColumns.length - 1];
54893
+ const pinnedActionsColumnId = !showActionsCol && lastVisibleColumn?.customActions ? columnId(lastVisibleColumn) : void 0;
54712
54894
  const getSelectionId = selection?.getSelectionId ?? getRowId;
54713
- const selectedIdSet = (0, import_react28.useMemo)(
54895
+ const selectedIdSet = (0, import_react29.useMemo)(
54714
54896
  () => new Set(selection?.selectedIds ?? []),
54715
54897
  [selection?.selectedIds]
54716
54898
  );
@@ -54722,7 +54904,7 @@ function MatrxDataTableCore(coreProps) {
54722
54904
  );
54723
54905
  const allOnPageSelected = selectableRows.length > 0 && selectedOnPage.length === selectableRows.length;
54724
54906
  const someOnPageSelected = selectedOnPage.length > 0 && !allOnPageSelected;
54725
- const selectedRows = (0, import_react28.useMemo)(() => {
54907
+ const selectedRows = (0, import_react29.useMemo)(() => {
54726
54908
  const resolved = /* @__PURE__ */ new Set();
54727
54909
  return data.filter((row) => {
54728
54910
  const id = getSelectionId(row);
@@ -54731,7 +54913,7 @@ function MatrxDataTableCore(coreProps) {
54731
54913
  return true;
54732
54914
  });
54733
54915
  }, [data, getSelectionId, selectedIdSet]);
54734
- const lastToggledIndex = (0, import_react28.useRef)(null);
54916
+ const lastToggledIndex = (0, import_react29.useRef)(null);
54735
54917
  const setSelectedIds = (next) => selection?.onSelectedIdsChange([...next]);
54736
54918
  const toggleRowSelected = (index, shiftKey) => {
54737
54919
  if (!selection) return;
@@ -54772,7 +54954,7 @@ function MatrxDataTableCore(coreProps) {
54772
54954
  }
54773
54955
  } : facet
54774
54956
  ) : toolbar?.facets;
54775
- const rowLatest = (0, import_react28.useRef)(null);
54957
+ const rowLatest = (0, import_react29.useRef)(null);
54776
54958
  const renderRecordCell = (row, col, index, suppliedControls) => {
54777
54959
  const id = getRowId(row);
54778
54960
  const field = col.accessorKey ? String(col.accessorKey) : columnId(col);
@@ -54781,15 +54963,28 @@ function MatrxDataTableCore(coreProps) {
54781
54963
  if (col.customActions) {
54782
54964
  const controls = suppliedControls ?? liveRecordControls(displayRow);
54783
54965
  const content = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(MatrxTableRowControlsScope, { value: controls, children: col.customActions(displayRow, controls) });
54784
- return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { "data-matrx-table-custom-actions": true, "data-matrx-cell-control": true, className: "inline-flex items-center justify-end gap-0", onClick: (event) => event.stopPropagation(), children: effectiveCopy && showRowCopy ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
54785
- MatrxTableRowAlchemyProvider,
54786
- {
54787
- copy: tableRowCopyProps(effectiveCopy, displayRow, `${tableCopySourceNamespace}:row:${getRowId(displayRow)}`, copy === void 0 ? declaredVisibleCopyColumns : void 0),
54788
- placement: rowCopyInMenu && columnId(col) === (menuActionsColumn ? columnId(menuActionsColumn) : void 0) ? "menu" : "inline",
54789
- controls,
54790
- children: content
54791
- }
54792
- ) : content });
54966
+ const copyHere = rowCopyInCustomColumn && effectiveCopy && menuActionsColumn !== void 0 && columnId(col) === columnId(menuActionsColumn);
54967
+ return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { "data-matrx-table-custom-actions": true, "data-matrx-cell-control": true, className: cn("inline-flex items-center justify-end gap-0", compactRows && "[&_button]:h-6 [&_button]:min-h-6"), onClick: (event) => event.stopPropagation(), children: [
54968
+ copyHere && effectiveCopy ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
54969
+ TableRowCopyControl,
54970
+ {
54971
+ size: "toolbar",
54972
+ copy: effectiveCopy,
54973
+ row: displayRow,
54974
+ sourceId: `${tableCopySourceNamespace}:row:${getRowId(displayRow)}`,
54975
+ ...copy === void 0 ? { defaultColumns: readDeclaredCopyColumns } : {}
54976
+ }
54977
+ ) : null,
54978
+ effectiveCopy && showRowCopy ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
54979
+ MatrxTableRowAlchemyProvider,
54980
+ {
54981
+ copy: tableRowCopyProps(effectiveCopy, displayRow, `${tableCopySourceNamespace}:row:${getRowId(displayRow)}`, copy === void 0 ? readDeclaredCopyColumns : void 0),
54982
+ placement: rowCopyInMenu && columnId(col) === (menuActionsColumn ? columnId(menuActionsColumn) : void 0) ? "menu" : "inline",
54983
+ controls,
54984
+ children: content
54985
+ }
54986
+ ) : content
54987
+ ] });
54793
54988
  }
54794
54989
  const display = renderCell(displayRow, col, index);
54795
54990
  const href = col.href?.(row) ?? void 0;
@@ -54822,7 +55017,7 @@ function MatrxDataTableCore(coreProps) {
54822
55017
  }
54823
55018
  return href ? /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Link, { href, onClick: (event) => event.stopPropagation(), className: "block w-full min-w-0 rounded outline-none focus-visible:ring-2 focus-visible:ring-ring", children: display }) : display;
54824
55019
  };
54825
- const currentViewSnapshot = (0, import_react28.useMemo)(
55020
+ const currentViewSnapshot = (0, import_react29.useMemo)(
54826
55021
  () => ({
54827
55022
  __kind: "matrx-table-view",
54828
55023
  version: 1,
@@ -54858,7 +55053,7 @@ function MatrxDataTableCore(coreProps) {
54858
55053
  ]
54859
55054
  );
54860
55055
  const declaredDefaultSort = urlState ? urlState.defaultSort ?? null : defaultSort;
54861
- const declaredDefaultViewSnapshot = (0, import_react28.useMemo)(
55056
+ const declaredDefaultViewSnapshot = (0, import_react29.useMemo)(
54862
55057
  () => defaultViewSnapshot ?? {
54863
55058
  __kind: "matrx-table-view",
54864
55059
  version: 1,
@@ -54876,7 +55071,7 @@ function MatrxDataTableCore(coreProps) {
54876
55071
  },
54877
55072
  [columns, defaultPageSize, declaredDefaultSort, defaultViewSnapshot]
54878
55073
  );
54879
- const applySavedView = (0, import_react28.useCallback)(
55074
+ const applySavedView = (0, import_react29.useCallback)(
54880
55075
  (rawSnapshot) => {
54881
55076
  const snapshot = parseTableViewSnapshot(rawSnapshot);
54882
55077
  if (!snapshot) {
@@ -54957,15 +55152,15 @@ function MatrxDataTableCore(coreProps) {
54957
55152
  const drawn = buildRecordControls(row);
54958
55153
  const live = {};
54959
55154
  for (const [key, value] of Object.entries(drawn)) {
54960
- live[key] = typeof value === "function" ? (...args) => {
55155
+ live[key] = typeof value === "function" ? lazyCallback((...args) => {
54961
55156
  const now = rowLatest.current.buildRecordControls(row);
54962
55157
  const handler = now[key];
54963
55158
  return typeof handler === "function" ? handler(...args) : void 0;
54964
- } : value;
55159
+ }) : value;
54965
55160
  }
54966
55161
  return live;
54967
55162
  };
54968
- const rowEpoch = useRenderEpoch([
55163
+ const rowShape = [
54969
55164
  // WHAT A BODY ROW READS FROM THIS TABLE'S PROPS — and nothing it does not, so a host that
54970
55165
  // rebuilds its toolbar, its query or its empty state on every render redraws no row. Handlers
54971
55166
  // are absent on purpose: they run through `rowLatest`. Columns count by what a body cell
@@ -55029,7 +55224,12 @@ function MatrxDataTableCore(coreProps) {
55029
55224
  hierarchyIndex,
55030
55225
  hierarchyBlockedIds,
55031
55226
  draggedRowId
55032
- ]);
55227
+ ];
55228
+ const rowEpoch = useRenderEpoch(rowShape.filter((value) => typeof value !== "function" && (typeof value !== "object" || value === null)));
55229
+ const rowProbe = useRenderEpoch(rowShape.filter((value) => typeof value === "function" || typeof value === "object" && value !== null));
55230
+ const rowDrawings = (0, import_react29.useRef)(null);
55231
+ rowDrawings.current ??= new RowDrawings();
55232
+ const drawBodyRow = (rowId, row, index) => rowDrawings.current.draw(rowId, renderRecordRow(row, index));
55033
55233
  chromeLatest.current = { processed, data, toggleAllOnPage, showMore: progressiveRows.showMore, applySavedView };
55034
55234
  const chromeGeometry = [
55035
55235
  ...Object.entries(effectiveColumnWidths).flat(),
@@ -55293,6 +55493,7 @@ function MatrxDataTableCore(coreProps) {
55293
55493
  "td",
55294
55494
  {
55295
55495
  "data-matrx-table-column-id": columnId(col),
55496
+ "data-matrx-table-pinned-actions": pinnedActionsColumnId === columnId(col) ? "" : void 0,
55296
55497
  "data-matrx-column-drag-shadow": isColumnDragShadow ? "true" : void 0,
55297
55498
  ...sheetCell ? {
55298
55499
  "data-matrx-cell-row": sheetCell["data-matrx-cell-row"],
@@ -55331,6 +55532,11 @@ function MatrxDataTableCore(coreProps) {
55331
55532
  frozen && sheetCell?.["data-matrx-cell-selected"] && "sm:bg-[color-mix(in_oklab,var(--color-primary)_10%,var(--color-card))]",
55332
55533
  frozen && canHoverFrozenCell && "sm:group-hover/matrx-row:bg-[color-mix(in_oklab,var(--color-muted)_50%,var(--color-card))]",
55333
55534
  frozenEdgeId === columnId(col) && FROZEN_EDGE_CLASS,
55535
+ pinnedActionsColumnId === columnId(col) && [
55536
+ "text-right sm:sticky sm:right-0 sm:z-20 sm:shadow-[inset_1px_0_0_var(--color-border)]",
55537
+ frozenRowBackgroundClass,
55538
+ canHoverFrozenCell && "sm:group-hover/matrx-row:bg-[color-mix(in_oklab,var(--color-muted)_50%,var(--color-card))]"
55539
+ ],
55334
55540
  // A cell tint paints OVER the row tint beneath
55335
55541
  // it, and the consumer's own hook comes last so
55336
55542
  // it can always win.
@@ -55465,7 +55671,7 @@ function MatrxDataTableCore(coreProps) {
55465
55671
  copy: effectiveCopy,
55466
55672
  row: displayRow,
55467
55673
  sourceId: `${tableCopySourceNamespace}:row:${getRowId(displayRow)}`,
55468
- ...copy === void 0 ? { defaultColumns: declaredVisibleCopyColumns } : {}
55674
+ ...copy === void 0 ? { defaultColumns: readDeclaredCopyColumns } : {}
55469
55675
  }
55470
55676
  ) : null,
55471
55677
  renderRowActions(displayRow, controls),
@@ -55515,7 +55721,7 @@ function MatrxDataTableCore(coreProps) {
55515
55721
  },
55516
55722
  `${id}:expanded-detail`
55517
55723
  ) : null;
55518
- return hierarchy ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_react28.Fragment, { children: [
55724
+ return hierarchy ? /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_react29.Fragment, { children: [
55519
55725
  /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
55520
55726
  HierarchyDroppableRow,
55521
55727
  {
@@ -55525,7 +55731,7 @@ function MatrxDataTableCore(coreProps) {
55525
55731
  }
55526
55732
  ),
55527
55733
  inlineDetail
55528
- ] }, id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_react28.Fragment, { children: [
55734
+ ] }, id) : /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_react29.Fragment, { children: [
55529
55735
  wrappedRow,
55530
55736
  inlineDetail
55531
55737
  ] }, id);
@@ -56101,11 +56307,11 @@ function MatrxDataTableCore(coreProps) {
56101
56307
  copy: effectiveCopy,
56102
56308
  row: displayRow,
56103
56309
  sourceId: `${tableCopySourceNamespace}:row:${getRowId(displayRow)}`,
56104
- ...copy === void 0 ? { defaultColumns: declaredVisibleCopyColumns } : {}
56310
+ ...copy === void 0 ? { defaultColumns: readDeclaredCopyColumns } : {}
56105
56311
  }
56106
56312
  ) : null,
56107
56313
  renderRowActions(displayRow, controls),
56108
- visibleColumns.filter((column) => column.customActions).map((column) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_react28.Fragment, { children: renderRecordCell(row, column, index, controls) }, columnId(column)))
56314
+ visibleColumns.filter((column) => column.customActions).map((column) => /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_react29.Fragment, { children: renderRecordCell(row, column, index, controls) }, columnId(column)))
56109
56315
  ]
56110
56316
  }
56111
56317
  ) : null,
@@ -56313,6 +56519,7 @@ function MatrxDataTableCore(coreProps) {
56313
56519
  {
56314
56520
  "data-matrx-table-column-id": id,
56315
56521
  "data-matrx-header-column-id": id,
56522
+ "data-matrx-table-pinned-actions": pinnedActionsColumnId === id ? "" : void 0,
56316
56523
  "data-matrx-column-drag-shadow": isColumnDragShadow ? "true" : void 0,
56317
56524
  "aria-sort": isSorted ? sort?.direction === "asc" ? "ascending" : "descending" : void 0,
56318
56525
  className: cn(
@@ -56340,7 +56547,9 @@ function MatrxDataTableCore(coreProps) {
56340
56547
  frozenColumns.offsets[id] !== void 0 && FROZEN_HEADER_CLASS,
56341
56548
  phoneFrozenId === id && FROZEN_PHONE_HEADER_CLASS,
56342
56549
  embedded && (frozenColumns.offsets[id] !== void 0 || phoneFrozenId === id) && "sm:bg-card max-sm:bg-card",
56343
- frozenEdgeId === id && FROZEN_EDGE_CLASS
56550
+ frozenEdgeId === id && FROZEN_EDGE_CLASS,
56551
+ pinnedActionsColumnId === id && "sm:sticky sm:right-0 sm:z-30 sm:bg-muted sm:shadow-[inset_1px_0_0_var(--color-border)]",
56552
+ pinnedActionsColumnId === id && embedded && "sm:bg-card"
56344
56553
  ),
56345
56554
  style: {
56346
56555
  ...columnWidthVar(width, windowedWidthFor(id, width), id, columnResizable),
@@ -56539,8 +56748,9 @@ function MatrxDataTableCore(coreProps) {
56539
56748
  row,
56540
56749
  index,
56541
56750
  epoch: rowEpoch,
56751
+ probe: rowProbe,
56542
56752
  facts: rowFactsFor(row, id, index),
56543
- render: renderRecordRow
56753
+ draw: drawBodyRow
56544
56754
  },
56545
56755
  id
56546
56756
  );
@@ -56991,7 +57201,7 @@ function MatrxDataTableCore(coreProps) {
56991
57201
  copy: effectiveCopy,
56992
57202
  sourceId: `${tableCopySourceNamespace}:row:${getRowId(selectedRow)}`,
56993
57203
  row: selectedRow,
56994
- ...copy === void 0 ? { defaultColumns: declaredVisibleCopyColumns } : {}
57204
+ ...copy === void 0 ? { defaultColumns: readDeclaredCopyColumns } : {}
56995
57205
  }
56996
57206
  ) : null,
56997
57207
  detail?.headerActions?.(selectedRow),
@@ -57079,7 +57289,7 @@ function MatrxDataTableCore(coreProps) {
57079
57289
  copy: effectiveCopy,
57080
57290
  sourceId: `${tableCopySourceNamespace}:row:${getRowId(windowRow)}`,
57081
57291
  row: windowRow,
57082
- ...copy === void 0 ? { defaultColumns: declaredVisibleCopyColumns } : {}
57292
+ ...copy === void 0 ? { defaultColumns: readDeclaredCopyColumns } : {}
57083
57293
  }
57084
57294
  ) : null
57085
57295
  ] }),
@@ -57242,7 +57452,7 @@ function HierarchyDragIndicatorLayer({
57242
57452
  scrollRef,
57243
57453
  resolve: resolve2
57244
57454
  }) {
57245
- const [indicator, setIndicator] = (0, import_react28.useState)(
57455
+ const [indicator, setIndicator] = (0, import_react29.useState)(
57246
57456
  null
57247
57457
  );
57248
57458
  (0, import_core3.useDndMonitor)({
@@ -57346,9 +57556,9 @@ function HierarchyDroppableRow({
57346
57556
  children
57347
57557
  }) {
57348
57558
  const { setNodeRef } = (0, import_core3.useDroppable)({ id, disabled });
57349
- if (!(0, import_react28.isValidElement)(children) || children.type !== "tr") return children;
57559
+ if (!(0, import_react29.isValidElement)(children) || children.type !== "tr") return children;
57350
57560
  const row = children;
57351
- return (0, import_react28.cloneElement)(row, {
57561
+ return (0, import_react29.cloneElement)(row, {
57352
57562
  ref: setNodeRef,
57353
57563
  className: row.props.className
57354
57564
  });
@@ -57442,7 +57652,7 @@ function columnWidthVar(width, resizedWidth, id, resizable) {
57442
57652
  };
57443
57653
  }
57444
57654
  function DefaultJsonCell({ value }) {
57445
- const [open, setOpen] = (0, import_react28.useState)(false);
57655
+ const [open, setOpen] = (0, import_react29.useState)(false);
57446
57656
  const host = useMatrxDataTableHost();
57447
57657
  const Viewer = host.JsonViewer;
57448
57658
  const text = JSON.stringify(value, null, 2);
@@ -57522,7 +57732,7 @@ function resolveStringTitle(title, fallback) {
57522
57732
  }
57523
57733
 
57524
57734
  // src/data-table/MatrxTableCard.tsx
57525
- var import_react29 = require("react");
57735
+ var import_react30 = require("react");
57526
57736
  var import_jsx_runtime60 = require("react/jsx-runtime");
57527
57737
  function nounText(noun) {
57528
57738
  return `${noun.count.toLocaleString()} ${noun.count === 1 ? noun.singular : noun.plural}`;
@@ -57546,10 +57756,10 @@ function MatrxTableCard({
57546
57756
  className
57547
57757
  }) {
57548
57758
  const { Link } = useMatrxDataTableHost();
57549
- const [toolbarSlot, setToolbarSlot] = (0, import_react29.useState)(null);
57550
- const [footerSlot, setFooterSlot] = (0, import_react29.useState)(null);
57551
- const [reportedTotal, setReportedTotal] = (0, import_react29.useState)(void 0);
57552
- const context = (0, import_react29.useMemo)(
57759
+ const [toolbarSlot, setToolbarSlot] = (0, import_react30.useState)(null);
57760
+ const [footerSlot, setFooterSlot] = (0, import_react30.useState)(null);
57761
+ const [reportedTotal, setReportedTotal] = (0, import_react30.useState)(void 0);
57762
+ const context = (0, import_react30.useMemo)(
57553
57763
  () => ({ appearance: "embedded", toolbarSlot, footerSlot, initialRows, reportTotal: setReportedTotal }),
57554
57764
  [toolbarSlot, footerSlot, initialRows]
57555
57765
  );
@@ -57662,7 +57872,7 @@ function MatrxTableCardEmpty({ message, action, children }) {
57662
57872
  }
57663
57873
 
57664
57874
  // src/data-table/SavedViewsControl.tsx
57665
- var import_react30 = require("react");
57875
+ var import_react31 = require("react");
57666
57876
  var import_jsx_runtime61 = require("react/jsx-runtime");
57667
57877
  function SavedViewsControl({
57668
57878
  views,
@@ -57679,14 +57889,14 @@ function SavedViewsControl({
57679
57889
  onRemove,
57680
57890
  related
57681
57891
  }) {
57682
- const unsavedChangesId = (0, import_react30.useId)();
57683
- const [saveOpen, setSaveOpen] = (0, import_react30.useState)(false);
57684
- const [name, setName] = (0, import_react30.useState)("");
57685
- const [saving, setSaving] = (0, import_react30.useState)(false);
57686
- const [removing, setRemoving] = (0, import_react30.useState)(false);
57687
- const [actionError, setActionError] = (0, import_react30.useState)(null);
57688
- const [pendingSelect, setPendingSelect] = (0, import_react30.useState)(void 0);
57689
- const [pendingRemove, setPendingRemove] = (0, import_react30.useState)(null);
57892
+ const unsavedChangesId = (0, import_react31.useId)();
57893
+ const [saveOpen, setSaveOpen] = (0, import_react31.useState)(false);
57894
+ const [name, setName] = (0, import_react31.useState)("");
57895
+ const [saving, setSaving] = (0, import_react31.useState)(false);
57896
+ const [removing, setRemoving] = (0, import_react31.useState)(false);
57897
+ const [actionError, setActionError] = (0, import_react31.useState)(null);
57898
+ const [pendingSelect, setPendingSelect] = (0, import_react31.useState)(void 0);
57899
+ const [pendingRemove, setPendingRemove] = (0, import_react31.useState)(null);
57690
57900
  const visibleError = actionError ?? error;
57691
57901
  const select = (id) => {
57692
57902
  if (id === activeId) return;
@@ -57904,7 +58114,7 @@ function downloadTableAsXlsx({
57904
58114
  }
57905
58115
 
57906
58116
  // src/data-table/drill-url-state.ts
57907
- var import_react31 = require("react");
58117
+ var import_react32 = require("react");
57908
58118
  var import_url_state4 = require("@ai-matrx/kit/url-state");
57909
58119
  function useDrillUrlState({
57910
58120
  fallback,
@@ -57912,19 +58122,19 @@ function useDrillUrlState({
57912
58122
  }) {
57913
58123
  const params = (0, import_url_state4.useUrlSearchParams)();
57914
58124
  const fallbackKey = JSON.stringify(fallback);
57915
- const question = (0, import_react31.useMemo)(
58125
+ const question = (0, import_react32.useMemo)(
57916
58126
  () => drillQuestionFromParams(params, JSON.parse(fallbackKey), prefix),
57917
58127
  [params, fallbackKey, prefix]
57918
58128
  );
57919
58129
  const fromAddress = addressHasDrill(params, prefix);
57920
- const setQuestion = (0, import_react31.useCallback)(
58130
+ const setQuestion = (0, import_react32.useCallback)(
57921
58131
  (next) => {
57922
58132
  const current = new URLSearchParams(window.location.search);
57923
58133
  (0, import_url_state4.commitUrlParams)(drillQuestionToParams(next, current, prefix), "push");
57924
58134
  },
57925
58135
  [prefix]
57926
58136
  );
57927
- const clearAddress = (0, import_react31.useCallback)(() => {
58137
+ const clearAddress = (0, import_react32.useCallback)(() => {
57928
58138
  const current = new URLSearchParams(window.location.search);
57929
58139
  const patch = drillQuestionToParams({ by: [], across: null, show: [], where: [] }, current, prefix);
57930
58140
  (0, import_url_state4.commitUrlParams)(patch, "replace");