@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 +30 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -380,8 +380,9 @@ type EasyVisionColumn<T> = {
|
|
|
380
380
|
truncate?: boolean;
|
|
381
381
|
/**
|
|
382
382
|
* Allow the user to drag the column's right edge to resize it. The
|
|
383
|
-
* starting width is `width` (or 240px if unset). User-resized widths
|
|
384
|
-
*
|
|
383
|
+
* starting width is `width` (or 240px if unset). User-resized widths
|
|
384
|
+
* live in the table slice alongside page / sort / visibility, so they
|
|
385
|
+
* survive unmount when the table is mounted with `persist`.
|
|
385
386
|
*/
|
|
386
387
|
resizable?: boolean;
|
|
387
388
|
} | {
|
|
@@ -618,6 +619,8 @@ interface TableSliceData {
|
|
|
618
619
|
descending: boolean;
|
|
619
620
|
} | null;
|
|
620
621
|
selection: TableSelection;
|
|
622
|
+
columnVisibility: Record<string, boolean>;
|
|
623
|
+
columnSizing: Record<string, number>;
|
|
621
624
|
}
|
|
622
625
|
type Slice = InputSliceData | SelectorSliceData | MultifilterSliceData | TableSliceData;
|
|
623
626
|
type SliceFor<K extends SliceKind> = Extract<Slice, {
|
package/dist/index.d.ts
CHANGED
|
@@ -380,8 +380,9 @@ type EasyVisionColumn<T> = {
|
|
|
380
380
|
truncate?: boolean;
|
|
381
381
|
/**
|
|
382
382
|
* Allow the user to drag the column's right edge to resize it. The
|
|
383
|
-
* starting width is `width` (or 240px if unset). User-resized widths
|
|
384
|
-
*
|
|
383
|
+
* starting width is `width` (or 240px if unset). User-resized widths
|
|
384
|
+
* live in the table slice alongside page / sort / visibility, so they
|
|
385
|
+
* survive unmount when the table is mounted with `persist`.
|
|
385
386
|
*/
|
|
386
387
|
resizable?: boolean;
|
|
387
388
|
} | {
|
|
@@ -618,6 +619,8 @@ interface TableSliceData {
|
|
|
618
619
|
descending: boolean;
|
|
619
620
|
} | null;
|
|
620
621
|
selection: TableSelection;
|
|
622
|
+
columnVisibility: Record<string, boolean>;
|
|
623
|
+
columnSizing: Record<string, number>;
|
|
621
624
|
}
|
|
622
625
|
type Slice = InputSliceData | SelectorSliceData | MultifilterSliceData | TableSliceData;
|
|
623
626
|
type SliceFor<K extends SliceKind> = Extract<Slice, {
|
package/dist/index.js
CHANGED
|
@@ -2182,7 +2182,11 @@ function EasyVisionTable(props) {
|
|
|
2182
2182
|
selection: {
|
|
2183
2183
|
ids: {},
|
|
2184
2184
|
scope: selectAllScope === "all" ? "all" : "page"
|
|
2185
|
-
}
|
|
2185
|
+
},
|
|
2186
|
+
// Visibility starts empty: defaults from `initiallyHidden` are merged in
|
|
2187
|
+
// at read time, so columns added later still honor their declared default.
|
|
2188
|
+
columnVisibility: {},
|
|
2189
|
+
columnSizing: {}
|
|
2186
2190
|
}),
|
|
2187
2191
|
persist
|
|
2188
2192
|
});
|
|
@@ -2340,13 +2344,23 @@ function EasyVisionTable(props) {
|
|
|
2340
2344
|
};
|
|
2341
2345
|
return [checkboxCol, ...tanstackColumns];
|
|
2342
2346
|
}, [enableRowSelection, tanstackColumns]);
|
|
2343
|
-
const
|
|
2347
|
+
const visibilityDefaults = useMemo(() => {
|
|
2344
2348
|
const v = {};
|
|
2345
2349
|
for (const c of columns) {
|
|
2346
2350
|
if (c.initiallyHidden) v[c.field] = false;
|
|
2347
2351
|
}
|
|
2348
2352
|
return v;
|
|
2349
|
-
});
|
|
2353
|
+
}, [columns]);
|
|
2354
|
+
const columnVisibility = useMemo(
|
|
2355
|
+
() => ({ ...visibilityDefaults, ...slice.columnVisibility }),
|
|
2356
|
+
[visibilityDefaults, slice.columnVisibility]
|
|
2357
|
+
);
|
|
2358
|
+
const resizableFields = useMemo(() => {
|
|
2359
|
+
const s = /* @__PURE__ */ new Set();
|
|
2360
|
+
for (const c of columns) if (c.resizable) s.add(c.field);
|
|
2361
|
+
return s;
|
|
2362
|
+
}, [columns]);
|
|
2363
|
+
const columnSizing = slice.columnSizing;
|
|
2350
2364
|
const rowSelection = useMemo(() => {
|
|
2351
2365
|
if (selection.scope === "all") return {};
|
|
2352
2366
|
const r = {};
|
|
@@ -2360,10 +2374,22 @@ function EasyVisionTable(props) {
|
|
|
2360
2374
|
columns: allColumns,
|
|
2361
2375
|
state: {
|
|
2362
2376
|
columnVisibility,
|
|
2377
|
+
columnSizing,
|
|
2363
2378
|
...enableRowSelection ? { rowSelection } : {},
|
|
2364
2379
|
sorting: sortingState
|
|
2365
2380
|
},
|
|
2366
|
-
onColumnVisibilityChange:
|
|
2381
|
+
onColumnVisibilityChange: (updater) => {
|
|
2382
|
+
const next = typeof updater === "function" ? updater(columnVisibility) : updater;
|
|
2383
|
+
patch({ columnVisibility: next });
|
|
2384
|
+
},
|
|
2385
|
+
onColumnSizingChange: (updater) => {
|
|
2386
|
+
const next = typeof updater === "function" ? updater(columnSizing) : updater;
|
|
2387
|
+
const filtered = {};
|
|
2388
|
+
for (const k in next) {
|
|
2389
|
+
if (resizableFields.has(k)) filtered[k] = next[k];
|
|
2390
|
+
}
|
|
2391
|
+
patch({ columnSizing: filtered });
|
|
2392
|
+
},
|
|
2367
2393
|
enableRowSelection,
|
|
2368
2394
|
onRowSelectionChange: enableRowSelection ? (updater) => {
|
|
2369
2395
|
const next = typeof updater === "function" ? updater(rowSelection) : updater;
|