@trackunit/react-table 2.11.10-alpha-e1e6a0f33ce.0 → 2.11.11-alpha-7afddbbe4cc.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.
Files changed (3) hide show
  1. package/index.cjs.js +5 -26
  2. package/index.esm.js +5 -26
  3. package/package.json +10 -10
package/index.cjs.js CHANGED
@@ -1784,11 +1784,6 @@ const computeMergedPinning = (initialPinning, columnConfigPinning) => {
1784
1784
  */
1785
1785
  const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProps }) => {
1786
1786
  const stableColumns = react.useMemo(() => JSON.stringify(columns), [columns]);
1787
- // The column definitions are the single source of defaults: `meta.hiddenByDefault`, definition
1788
- // order, `meta.pinned`, and `size`. They seed the state when `initialState` says nothing, and
1789
- // they are the baseline for what `onTableStateChange` reports (see `persistTableState`).
1790
- // Consumers that want a different default should set it on the column, not in `initialState`:
1791
- // a value in `initialState` is treated as saved state.
1792
1787
  const columnDefaults = react.useMemo(() => {
1793
1788
  const columnsList = JSON.parse(stableColumns);
1794
1789
  const visibilityById = {};
@@ -1887,13 +1882,9 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1887
1882
  // A ref exposes the latest derived state to the change callbacks without making them depend on
1888
1883
  // it (callbacks run on user events, outside render). Every managed key on `state` is always
1889
1884
  // defined — it originates from `baseState` — so the callbacks read it directly.
1890
- //
1891
- // `applyUpdate` resolves a TanStack updater against that ref and advances the ref at once, so
1892
- // several updaters fired from one event (the column menu's Reset toggles every column that
1893
- // differs from its default in a single click) build on each other instead of each starting
1894
- // from the state as of the last render.
1895
1885
  const stateRef = react.useRef(state);
1896
1886
  stateRef.current = state;
1887
+ // Advances the ref at once so several updaters from one event (Reset) build on each other.
1897
1888
  const applyUpdate = (key, value) => {
1898
1889
  const current = stateRef.current[key];
1899
1890
  const next = typeof value === "function" ? value(current) : value;
@@ -1901,13 +1892,8 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1901
1892
  setUserEdits(prev => ({ ...prev, [key]: next }));
1902
1893
  return next;
1903
1894
  };
1904
- // Reports only the field that changed — `useTablePersistence` merges partial reports — so a
1905
- // change can never store another field's unsettled or transient value. Within a field, only
1906
- // what differs from the column defaults is reported: visibility entries equal to
1907
- // `hiddenByDefault`, sizes equal to the default size, an order equal to the definition order and
1908
- // a pinning equal to `meta.pinned` all read back the same when absent, so storing them would only
1909
- // freeze today's defaults under the user's layout and bloat what is shared. A field with nothing
1910
- // left is reported empty so the store can drop it.
1895
+ // Reports only what differs from the column defaults (see the hook's JSDoc); storing a default
1896
+ // would freeze it under the user's layout.
1911
1897
  const persistTableState = react.useCallback((nextState) => {
1912
1898
  if (!onTableStateChange) {
1913
1899
  return;
@@ -1927,9 +1913,6 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1927
1913
  }
1928
1914
  onTableStateChange(reported);
1929
1915
  }, [onTableStateChange, columnDefaults, defaultColumnSizingById, stableUpdatedInitialColumnPinning]);
1930
- // Whether a column-resize drag is in progress, as of the last render (TanStack
1931
- // flags it at pointer-down, before the first move arrives), and whether a
1932
- // sizing change was held back during one.
1933
1916
  const isResizingColumnRef = react.useRef(false);
1934
1917
  const sizingReportPendingRef = react.useRef(false);
1935
1918
  const table = reactTable.useReactTable({
@@ -1945,10 +1928,7 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1945
1928
  },
1946
1929
  onColumnSizingChange: value => {
1947
1930
  const next = applyUpdate("columnSizing", value);
1948
- // A drag updates the sizing on every pointer move (`columnResizeMode:
1949
- // "onChange"`); the store would write every move. The report waits for
1950
- // the drag to end (see the effect below). Anything else — `resetSize`,
1951
- // `setColumnSizing` — is reported at once.
1931
+ // A drag fires this on every pointer move; report it once, when the drag ends (effect below).
1952
1932
  if (isResizingColumnRef.current) {
1953
1933
  sizingReportPendingRef.current = true;
1954
1934
  }
@@ -1981,8 +1961,7 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1981
1961
  });
1982
1962
  const isResizingColumn = table.getState().columnSizingInfo.isResizingColumn !== false;
1983
1963
  isResizingColumnRef.current = isResizingColumn;
1984
- // The drag has ended: report the sizing it left behind, once. TanStack
1985
- // applies the final size before it clears the flag, so the ref holds it.
1964
+ // TanStack applies the final size before it clears the flag, so `stateRef` already holds it.
1986
1965
  react.useEffect(() => {
1987
1966
  if (!isResizingColumn && sizingReportPendingRef.current) {
1988
1967
  sizingReportPendingRef.current = false;
package/index.esm.js CHANGED
@@ -1783,11 +1783,6 @@ const computeMergedPinning = (initialPinning, columnConfigPinning) => {
1783
1783
  */
1784
1784
  const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProps }) => {
1785
1785
  const stableColumns = useMemo(() => JSON.stringify(columns), [columns]);
1786
- // The column definitions are the single source of defaults: `meta.hiddenByDefault`, definition
1787
- // order, `meta.pinned`, and `size`. They seed the state when `initialState` says nothing, and
1788
- // they are the baseline for what `onTableStateChange` reports (see `persistTableState`).
1789
- // Consumers that want a different default should set it on the column, not in `initialState`:
1790
- // a value in `initialState` is treated as saved state.
1791
1786
  const columnDefaults = useMemo(() => {
1792
1787
  const columnsList = JSON.parse(stableColumns);
1793
1788
  const visibilityById = {};
@@ -1886,13 +1881,9 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1886
1881
  // A ref exposes the latest derived state to the change callbacks without making them depend on
1887
1882
  // it (callbacks run on user events, outside render). Every managed key on `state` is always
1888
1883
  // defined — it originates from `baseState` — so the callbacks read it directly.
1889
- //
1890
- // `applyUpdate` resolves a TanStack updater against that ref and advances the ref at once, so
1891
- // several updaters fired from one event (the column menu's Reset toggles every column that
1892
- // differs from its default in a single click) build on each other instead of each starting
1893
- // from the state as of the last render.
1894
1884
  const stateRef = useRef(state);
1895
1885
  stateRef.current = state;
1886
+ // Advances the ref at once so several updaters from one event (Reset) build on each other.
1896
1887
  const applyUpdate = (key, value) => {
1897
1888
  const current = stateRef.current[key];
1898
1889
  const next = typeof value === "function" ? value(current) : value;
@@ -1900,13 +1891,8 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1900
1891
  setUserEdits(prev => ({ ...prev, [key]: next }));
1901
1892
  return next;
1902
1893
  };
1903
- // Reports only the field that changed — `useTablePersistence` merges partial reports — so a
1904
- // change can never store another field's unsettled or transient value. Within a field, only
1905
- // what differs from the column defaults is reported: visibility entries equal to
1906
- // `hiddenByDefault`, sizes equal to the default size, an order equal to the definition order and
1907
- // a pinning equal to `meta.pinned` all read back the same when absent, so storing them would only
1908
- // freeze today's defaults under the user's layout and bloat what is shared. A field with nothing
1909
- // left is reported empty so the store can drop it.
1894
+ // Reports only what differs from the column defaults (see the hook's JSDoc); storing a default
1895
+ // would freeze it under the user's layout.
1910
1896
  const persistTableState = useCallback((nextState) => {
1911
1897
  if (!onTableStateChange) {
1912
1898
  return;
@@ -1926,9 +1912,6 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1926
1912
  }
1927
1913
  onTableStateChange(reported);
1928
1914
  }, [onTableStateChange, columnDefaults, defaultColumnSizingById, stableUpdatedInitialColumnPinning]);
1929
- // Whether a column-resize drag is in progress, as of the last render (TanStack
1930
- // flags it at pointer-down, before the first move arrives), and whether a
1931
- // sizing change was held back during one.
1932
1915
  const isResizingColumnRef = useRef(false);
1933
1916
  const sizingReportPendingRef = useRef(false);
1934
1917
  const table = useReactTable({
@@ -1944,10 +1927,7 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1944
1927
  },
1945
1928
  onColumnSizingChange: value => {
1946
1929
  const next = applyUpdate("columnSizing", value);
1947
- // A drag updates the sizing on every pointer move (`columnResizeMode:
1948
- // "onChange"`); the store would write every move. The report waits for
1949
- // the drag to end (see the effect below). Anything else — `resetSize`,
1950
- // `setColumnSizing` — is reported at once.
1930
+ // A drag fires this on every pointer move; report it once, when the drag ends (effect below).
1951
1931
  if (isResizingColumnRef.current) {
1952
1932
  sizingReportPendingRef.current = true;
1953
1933
  }
@@ -1980,8 +1960,7 @@ const useTable = ({ onTableStateChange, initialState, columns, ...reactTableProp
1980
1960
  });
1981
1961
  const isResizingColumn = table.getState().columnSizingInfo.isResizingColumn !== false;
1982
1962
  isResizingColumnRef.current = isResizingColumn;
1983
- // The drag has ended: report the sizing it left behind, once. TanStack
1984
- // applies the final size before it clears the flag, so the ref holds it.
1963
+ // TanStack applies the final size before it clears the flag, so `stateRef` already holds it.
1985
1964
  useEffect(() => {
1986
1965
  if (!isResizingColumn && sizingReportPendingRef.current) {
1987
1966
  sizingReportPendingRef.current = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "2.11.10-alpha-e1e6a0f33ce.0",
3
+ "version": "2.11.11-alpha-7afddbbe4cc.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -11,15 +11,15 @@
11
11
  "react-dnd": "16.0.1",
12
12
  "react-dnd-html5-backend": "16.0.1",
13
13
  "tailwind-merge": "^2.0.0",
14
- "@trackunit/react-components": "3.8.3-alpha-e1e6a0f33ce.0",
15
- "@trackunit/react-core-hooks": "1.25.6-alpha-e1e6a0f33ce.0",
16
- "@trackunit/shared-utils": "1.19.6-alpha-e1e6a0f33ce.0",
17
- "@trackunit/css-class-variance-utilities": "2.3.6-alpha-e1e6a0f33ce.0",
18
- "@trackunit/ui-icons": "1.17.6-alpha-e1e6a0f33ce.0",
19
- "@trackunit/react-table-base-components": "2.12.10-alpha-e1e6a0f33ce.0",
20
- "@trackunit/react-form-components": "2.10.10-alpha-e1e6a0f33ce.0",
21
- "@trackunit/i18n-library-translation": "2.8.6-alpha-e1e6a0f33ce.0",
22
- "@trackunit/iris-app-runtime-core-api": "1.21.6-alpha-e1e6a0f33ce.0",
14
+ "@trackunit/react-components": "3.8.4-alpha-7afddbbe4cc.0",
15
+ "@trackunit/react-core-hooks": "1.25.7-alpha-7afddbbe4cc.0",
16
+ "@trackunit/shared-utils": "1.19.7-alpha-7afddbbe4cc.0",
17
+ "@trackunit/css-class-variance-utilities": "2.3.7-alpha-7afddbbe4cc.0",
18
+ "@trackunit/ui-icons": "1.17.7-alpha-7afddbbe4cc.0",
19
+ "@trackunit/react-table-base-components": "2.12.11-alpha-7afddbbe4cc.0",
20
+ "@trackunit/react-form-components": "2.10.11-alpha-7afddbbe4cc.0",
21
+ "@trackunit/i18n-library-translation": "2.8.7-alpha-7afddbbe4cc.0",
22
+ "@trackunit/iris-app-runtime-core-api": "1.21.7-alpha-7afddbbe4cc.0",
23
23
  "zod": "^3.25.76"
24
24
  },
25
25
  "peerDependencies": {