@caido-utils/components 0.2.4 → 0.3.1

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.
@@ -4,12 +4,14 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
4
4
  field: string;
5
5
  header: string;
6
6
  sortable?: boolean;
7
+ style?: Record<string, string>;
7
8
  }[];
8
9
  rowHeight?: number;
9
10
  selectable?: boolean | "single" | "multiple";
10
11
  selection?: Record<string, unknown>[] | null;
11
12
  activeRow?: Record<string, unknown> | null;
12
13
  scrollKey?: string;
14
+ dataKey?: string;
13
15
  }>, {
14
16
  rowHeight: number;
15
17
  selectable: boolean;
@@ -21,12 +23,14 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
21
23
  field: string;
22
24
  header: string;
23
25
  sortable?: boolean;
26
+ style?: Record<string, string>;
24
27
  }[];
25
28
  rowHeight?: number;
26
29
  selectable?: boolean | "single" | "multiple";
27
30
  selection?: Record<string, unknown>[] | null;
28
31
  activeRow?: Record<string, unknown> | null;
29
32
  scrollKey?: string;
33
+ dataKey?: string;
30
34
  }>, {
31
35
  rowHeight: number;
32
36
  selectable: boolean;
@@ -21,6 +21,7 @@ type ColumnDef = {
21
21
  field: string;
22
22
  header: string;
23
23
  sortable?: boolean;
24
+ style?: Record<string, string>;
24
25
  };
25
26
 
26
27
  const props = withDefaults(
@@ -32,6 +33,7 @@ const props = withDefaults(
32
33
  selection?: Record<string, unknown>[] | null;
33
34
  activeRow?: Record<string, unknown> | null;
34
35
  scrollKey?: string;
36
+ dataKey?: string;
35
37
  }>(),
36
38
  {
37
39
  rowHeight: ROW_HEIGHT,
@@ -119,10 +121,10 @@ onBeforeUnmount(() => {
119
121
  const isMultiple = props.selectable === "multiple";
120
122
 
121
123
  const attrs = useAttrs();
122
- const dataKeyAttr = (attrs["dataKey"] as string) ?? "id";
124
+ const dataKeyAttr = computed(() => props.dataKey ?? "id");
123
125
 
124
126
  function getRowKey(row: Record<string, unknown>): unknown {
125
- return row[dataKeyAttr];
127
+ return row[dataKeyAttr.value];
126
128
  }
127
129
 
128
130
  // --- Selection logic ---
@@ -270,7 +272,7 @@ const columnPt = {
270
272
  :field="col.field"
271
273
  :header="col.header"
272
274
  :sortable="col.sortable"
273
- :style="{ height: `${props.rowHeight}px` }"
275
+ :style="{ height: `${props.rowHeight}px`, ...col.style }"
274
276
  :pt="columnPt"
275
277
  >
276
278
  <template v-if="col.sortable" #sorticon="{ sorted, sortOrder }">
@@ -4,12 +4,14 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
4
4
  field: string;
5
5
  header: string;
6
6
  sortable?: boolean;
7
+ style?: Record<string, string>;
7
8
  }[];
8
9
  rowHeight?: number;
9
10
  selectable?: boolean | "single" | "multiple";
10
11
  selection?: Record<string, unknown>[] | null;
11
12
  activeRow?: Record<string, unknown> | null;
12
13
  scrollKey?: string;
14
+ dataKey?: string;
13
15
  }>, {
14
16
  rowHeight: number;
15
17
  selectable: boolean;
@@ -21,12 +23,14 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<__VLS_With
21
23
  field: string;
22
24
  header: string;
23
25
  sortable?: boolean;
26
+ style?: Record<string, string>;
24
27
  }[];
25
28
  rowHeight?: number;
26
29
  selectable?: boolean | "single" | "multiple";
27
30
  selection?: Record<string, unknown>[] | null;
28
31
  activeRow?: Record<string, unknown> | null;
29
32
  scrollKey?: string;
33
+ dataKey?: string;
30
34
  }>, {
31
35
  rowHeight: number;
32
36
  selectable: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido-utils/components",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"