@easyvision/easyvision-ui 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2207,7 +2207,11 @@ function EasyVisionTable(props) {
2207
2207
  selection: {
2208
2208
  ids: {},
2209
2209
  scope: selectAllScope === "all" ? "all" : "page"
2210
- }
2210
+ },
2211
+ // Visibility starts empty: defaults from `initiallyHidden` are merged in
2212
+ // at read time, so columns added later still honor their declared default.
2213
+ columnVisibility: {},
2214
+ columnSizing: {}
2211
2215
  }),
2212
2216
  persist
2213
2217
  });
@@ -2365,13 +2369,23 @@ function EasyVisionTable(props) {
2365
2369
  };
2366
2370
  return [checkboxCol, ...tanstackColumns];
2367
2371
  }, [enableRowSelection, tanstackColumns]);
2368
- const [columnVisibility, setColumnVisibility] = React8.useState(() => {
2372
+ const visibilityDefaults = React8.useMemo(() => {
2369
2373
  const v = {};
2370
2374
  for (const c of columns) {
2371
2375
  if (c.initiallyHidden) v[c.field] = false;
2372
2376
  }
2373
2377
  return v;
2374
- });
2378
+ }, [columns]);
2379
+ const columnVisibility = React8.useMemo(
2380
+ () => ({ ...visibilityDefaults, ...slice.columnVisibility }),
2381
+ [visibilityDefaults, slice.columnVisibility]
2382
+ );
2383
+ const resizableFields = React8.useMemo(() => {
2384
+ const s = /* @__PURE__ */ new Set();
2385
+ for (const c of columns) if (c.resizable) s.add(c.field);
2386
+ return s;
2387
+ }, [columns]);
2388
+ const columnSizing = slice.columnSizing;
2375
2389
  const rowSelection = React8.useMemo(() => {
2376
2390
  if (selection.scope === "all") return {};
2377
2391
  const r = {};
@@ -2385,10 +2399,22 @@ function EasyVisionTable(props) {
2385
2399
  columns: allColumns,
2386
2400
  state: {
2387
2401
  columnVisibility,
2402
+ columnSizing,
2388
2403
  ...enableRowSelection ? { rowSelection } : {},
2389
2404
  sorting: sortingState
2390
2405
  },
2391
- onColumnVisibilityChange: setColumnVisibility,
2406
+ onColumnVisibilityChange: (updater) => {
2407
+ const next = typeof updater === "function" ? updater(columnVisibility) : updater;
2408
+ patch({ columnVisibility: next });
2409
+ },
2410
+ onColumnSizingChange: (updater) => {
2411
+ const next = typeof updater === "function" ? updater(columnSizing) : updater;
2412
+ const filtered = {};
2413
+ for (const k in next) {
2414
+ if (resizableFields.has(k)) filtered[k] = next[k];
2415
+ }
2416
+ patch({ columnSizing: filtered });
2417
+ },
2392
2418
  enableRowSelection,
2393
2419
  onRowSelectionChange: enableRowSelection ? (updater) => {
2394
2420
  const next = typeof updater === "function" ? updater(rowSelection) : updater;