compote-ui 0.41.3 → 0.42.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.
@@ -1,4 +1,4 @@
1
- import { type ColumnResizeMode, type Row, type RowData, type SvelteTable, type TableState } from '@tanstack/svelte-table';
1
+ import { type ColumnResizeMode, type ColumnVisibilityState, type Row, type RowData, type SvelteTable, type TableState } from '@tanstack/svelte-table';
2
2
  import type { DataTableColumn, DataTableLeafColumn } from './types';
3
3
  declare const dataTableFeatures: {
4
4
  columnVisibilityFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnVisibilityFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
@@ -24,6 +24,7 @@ export type CreateDataTableOptions<T extends RowData> = {
24
24
  enableMultiRowSelection?: boolean | ((row: Row<DataTableFeatures, T>) => boolean);
25
25
  enableSorting?: boolean;
26
26
  debugTable?: boolean;
27
+ onColumnVisibilityChange?: (visibility: ColumnVisibilityState) => void;
27
28
  };
28
29
  export declare function createTable<T extends RowData>(options: CreateDataTableOptions<T>): SvelteTable<{
29
30
  columnVisibilityFeature: import("@tanstack/table-core").TableFeature<import("@tanstack/table-core").ColumnVisibilityFeatureConstructors<import("@tanstack/table-core").TableFeatures, RowData>>;
@@ -17,7 +17,7 @@ function oneOfFilterFn(row, columnId, filterValue) {
17
17
  oneOfFilterFn.autoRemove = (val) => !Array.isArray(val) || val.length === 0;
18
18
  export function createTable(options) {
19
19
  const localeCtx = useLocaleContext();
20
- return createTanStackTable({
20
+ const table = createTanStackTable({
21
21
  _features: dataTableFeatures,
22
22
  _rowModels: {
23
23
  sortedRowModel: createSortedRowModel(sortFns),
@@ -61,6 +61,15 @@ export function createTable(options) {
61
61
  sorting: state.sorting,
62
62
  columnFilters: state.columnFilters
63
63
  }));
64
+ if (options.onColumnVisibilityChange) {
65
+ const { onColumnVisibilityChange } = options;
66
+ const orig = table.setColumnVisibility.bind(table);
67
+ table.setColumnVisibility = (updater) => {
68
+ orig(updater);
69
+ onColumnVisibilityChange(table.store.state.columnVisibility);
70
+ };
71
+ }
72
+ return table;
64
73
  }
65
74
  function createColumnVisibility(columns) {
66
75
  return getLeafColumns(columns).reduce((visibility, column) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.41.3",
3
+ "version": "0.42.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev --open",
@@ -11,7 +11,9 @@
11
11
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
12
12
  "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
13
13
  "lint": "prettier --check . && eslint .",
14
- "format": "prettier --write ."
14
+ "format": "prettier --write .",
15
+ "patch": "npm version patch && npm publish",
16
+ "minor": "npm version minor && npm publish"
15
17
  },
16
18
  "files": [
17
19
  "dist",