@isoftdata/svelte-table 2.9.6 → 2.10.0-beta.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.
@@ -14,13 +14,49 @@ export declare class ColumnInfoRunicStore<R extends UuidRowProps> {
14
14
  #private;
15
15
  serializableValuesAndDefaultsArr: Array<SerializableKey>;
16
16
  getSerializableFieldValues: {
17
+ readonly pinned: (column: Partial<GenericColumnInfo<R>> | undefined) => boolean | undefined;
17
18
  readonly visible: (column: Partial<GenericColumnInfo<R>> | undefined) => boolean;
18
19
  readonly userWidth: (column: Partial<GenericColumnInfo<R>> | undefined) => string | undefined;
19
20
  };
20
21
  lsKey: string | null;
21
22
  userAccountId: number;
22
- constructor(getColumns: () => Array<Column<R>>, options: StoreOptions);
23
- get columns(): {
23
+ columns: {
24
+ align?: "start" | "left" | "center" | "right" | "end" | undefined;
25
+ class?: string | undefined;
26
+ defaultSortColumn?: boolean | undefined;
27
+ defaultSortDirection?: import("./types").SortDirection | undefined;
28
+ ellipsis?: boolean | undefined;
29
+ footer?: {
30
+ fn: "COUNT" | "AVG" | "SUM";
31
+ altProperty?: RowProperties<R> | undefined;
32
+ formatCurrency?: boolean;
33
+ requiredValue?: unknown;
34
+ } | {
35
+ fn: (previousValue: import("./types").FooterReducerValue<R>, currentValue: import("./types").FooterReducerValue<R>) => import("./types").FooterReducerValue<R>;
36
+ initialValue: string | number;
37
+ altProperty?: RowProperties<R> | undefined;
38
+ formatCurrency?: boolean;
39
+ requiredValue?: unknown;
40
+ } | undefined;
41
+ formatter?: ((value: unknown) => unknown) | undefined;
42
+ hideForPrint?: boolean | undefined;
43
+ icon?: import("@fortawesome/fontawesome-common-types").IconName | undefined;
44
+ iconLeft?: boolean | undefined;
45
+ iconPrefix?: import("@fortawesome/fontawesome-common-types").IconPrefix | undefined;
46
+ minWidth?: string | undefined;
47
+ name?: string | undefined;
48
+ numeric?: boolean | undefined;
49
+ property: `_${string}` | RowProperties<R>;
50
+ sortType?: "ALPHA_NUM" | "STANDARD" | false | undefined;
51
+ pinned?: boolean | undefined;
52
+ title?: string | undefined;
53
+ unhidable?: boolean | undefined;
54
+ userWidth?: string | undefined;
55
+ width?: string | undefined;
56
+ wrap?: boolean | undefined;
57
+ visible: boolean;
58
+ }[];
59
+ pinnedColumns: {
24
60
  align?: "start" | "left" | "center" | "right" | "end" | undefined;
25
61
  class?: string | undefined;
26
62
  defaultSortColumn?: boolean | undefined;
@@ -48,6 +84,7 @@ export declare class ColumnInfoRunicStore<R extends UuidRowProps> {
48
84
  numeric?: boolean | undefined;
49
85
  property: `_${string}` | RowProperties<R>;
50
86
  sortType?: "ALPHA_NUM" | "STANDARD" | false | undefined;
87
+ pinned?: boolean | undefined;
51
88
  title?: string | undefined;
52
89
  unhidable?: boolean | undefined;
53
90
  userWidth?: string | undefined;
@@ -55,11 +92,13 @@ export declare class ColumnInfoRunicStore<R extends UuidRowProps> {
55
92
  wrap?: boolean | undefined;
56
93
  visible: boolean;
57
94
  }[];
95
+ constructor(getColumns: () => Array<Column<R>>, options: StoreOptions);
58
96
  get current(): ColumnInfoObject<R>;
59
97
  updateColumn(property: RowProperties<R> | ArbitraryProperty, value: Partial<GenericColumnInfo<R>>): void;
60
98
  updateColumns(newColumnInfos: Array<Partial<GenericColumnInfo<R>> & {
61
99
  property: RowProperties<R> | ArbitraryProperty;
62
100
  }>): void;
101
+ getPinnedColumnOffset(property: RowProperties<R> | ArbitraryProperty): string;
63
102
  private getStoreValFromColumns;
64
103
  /** Takes values from the given column, removes non-serializable values, and fills in with default serializable values */
65
104
  private getSerializableValuesWithDefaults;
@@ -5,6 +5,7 @@ import { PersistedUserState } from '@isoftdata/svelte-store-user-local-writable'
5
5
  const serializableValuesAndDefaults = Object.freeze({
6
6
  visible: true,
7
7
  userWidth: undefined,
8
+ pinned: false,
8
9
  });
9
10
  function writableKlona(...args) {
10
11
  return klona(...args);
@@ -12,6 +13,7 @@ function writableKlona(...args) {
12
13
  export class ColumnInfoRunicStore {
13
14
  serializableValuesAndDefaultsArr = Object.keys(serializableValuesAndDefaults);
14
15
  getSerializableFieldValues = {
16
+ pinned: (column) => column?.pinned,
15
17
  visible: (column) => column?.visible ?? true,
16
18
  userWidth: (column) => column?.userWidth ?? column?.width ?? column?.minWidth,
17
19
  };
@@ -20,6 +22,8 @@ export class ColumnInfoRunicStore {
20
22
  #value = $state({});
21
23
  #persistedState = null;
22
24
  #lastValue = undefined;
25
+ columns = $derived(Object.values(this.#value));
26
+ pinnedColumns = $derived(this.columns.filter(c => c.pinned));
23
27
  constructor(getColumns, options) {
24
28
  this.lsKey = options.key ? `column-info-store-${options.key}` : null;
25
29
  this.userAccountId = options.userAccountId ?? -1;
@@ -41,9 +45,6 @@ export class ColumnInfoRunicStore {
41
45
  });
42
46
  });
43
47
  }
44
- get columns() {
45
- return Object.values(this.#value);
46
- }
47
48
  get current() {
48
49
  return this.#value;
49
50
  }
@@ -69,6 +70,26 @@ export class ColumnInfoRunicStore {
69
70
  this.#persistedState.current = this.makeDerived(this.#value);
70
71
  }
71
72
  }
73
+ getPinnedColumnOffset(property) {
74
+ const colIndex = this.pinnedColumns.findIndex(c => c.property === property);
75
+ if (colIndex === -1) {
76
+ console.warn(`Could not find columns ${property} in list of pinned columns: ${this.pinnedColumns.join(', ')}`);
77
+ return '0px';
78
+ }
79
+ else if (colIndex === 0) {
80
+ return '0px';
81
+ }
82
+ const offsetPx = this.pinnedColumns.slice(0, colIndex).reduce((acc, col) => {
83
+ if (col.userWidth && col.visible) {
84
+ acc += parseFloat(col.userWidth);
85
+ }
86
+ else {
87
+ console.warn(`Cannot make column ${property} pinned because it has no userWidth!`);
88
+ }
89
+ return acc;
90
+ }, 0);
91
+ return `${offsetPx}px`;
92
+ }
72
93
  getStoreValFromColumns(columns, storeValue) {
73
94
  const columnInfo = columns.reduce((acc, column) => {
74
95
  const storedColumn = storeValue
package/dist/types.d.ts CHANGED
@@ -55,6 +55,7 @@ export type Column<R extends UuidRowProps = any> = {
55
55
  numeric?: boolean;
56
56
  property: RowProperties<R> | ArbitraryProperty;
57
57
  sortType?: 'ALPHA_NUM' | 'STANDARD' | false;
58
+ pinned?: boolean;
58
59
  title?: string;
59
60
  unhidable?: boolean;
60
61
  /** The column's width set by column resizing. Separated from `width` to retain the default value after resizing */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/svelte-table",
3
- "version": "2.9.6",
3
+ "version": "2.10.0-beta.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@isoftdata/svelte-select": "^2.0.1",
25
25
  "@isoftdata/svelte-textarea": "^2.0.0",
26
26
  "@sveltejs/adapter-auto": "^3.3.1",
27
- "@sveltejs/kit": "^2.18.0",
27
+ "@sveltejs/kit": "^2.53.2",
28
28
  "@sveltejs/package": "^2.3.10",
29
29
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
30
30
  "@types/natural-compare-lite": "^1.4.2",
@@ -37,7 +37,7 @@
37
37
  "prettier": "^3.5.3",
38
38
  "prettier-plugin-svelte": "^3.3.3",
39
39
  "publint": "^0.1.16",
40
- "svelte": "5.50.2",
40
+ "svelte": "5.53.5",
41
41
  "svelte-check": "^4.1.4",
42
42
  "tslib": "^2.8.1",
43
43
  "type-fest": "^4.41.0",
@@ -51,7 +51,8 @@
51
51
  "dependencies": {
52
52
  "@isoftdata/browser-event": "^2.3.2",
53
53
  "@isoftdata/svelte-button": "^2.1.0",
54
- "@isoftdata/svelte-context-menu": "^2.0.0",
54
+ "@isoftdata/svelte-context-menu": "^2.0.4",
55
+ "@isoftdata/svelte-icon": "^2.1.0",
55
56
  "@isoftdata/svelte-input": "^2.1.1",
56
57
  "@isoftdata/svelte-store-user-local-writable": "^2.0.0",
57
58
  "@isoftdata/utility-bootstrap": "^2.2.1",