@nova-design-system/nova-vue 3.19.0 → 3.20.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.
|
@@ -6,9 +6,9 @@ import { type VNode, type PropType } from 'vue';
|
|
|
6
6
|
* @returns {component} A Vue component definition typed for the specified row
|
|
7
7
|
* type.
|
|
8
8
|
*/
|
|
9
|
-
export declare function createNvDatatable<T
|
|
9
|
+
export declare function createNvDatatable<T>(): import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
10
|
columns: {
|
|
11
|
-
type: PropType<NvDatatableColumn<T>[]>;
|
|
11
|
+
type: PropType<NvDatatableColumn<T, keyof T, T[keyof T]>[]>;
|
|
12
12
|
required: true;
|
|
13
13
|
default: () => any[];
|
|
14
14
|
};
|
|
@@ -33,7 +33,7 @@ export declare function createNvDatatable<T extends NvDatatableRow>(): import("v
|
|
|
33
33
|
[key: string]: any;
|
|
34
34
|
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
35
35
|
columns: {
|
|
36
|
-
type: PropType<NvDatatableColumn<T>[]>;
|
|
36
|
+
type: PropType<NvDatatableColumn<T, keyof T, T[keyof T]>[]>;
|
|
37
37
|
required: true;
|
|
38
38
|
default: () => any[];
|
|
39
39
|
};
|
|
@@ -55,95 +55,91 @@ export declare function createNvDatatable<T extends NvDatatableRow>(): import("v
|
|
|
55
55
|
default: boolean;
|
|
56
56
|
};
|
|
57
57
|
}>> & Readonly<{}>, {
|
|
58
|
-
columns: NvDatatableColumn<T>[];
|
|
58
|
+
columns: NvDatatableColumn<T, keyof T, T[keyof T]>[];
|
|
59
59
|
rows: T[];
|
|
60
60
|
pagination: NvDatatablePaginationConfig;
|
|
61
61
|
renderPagination: (api: NvDatatableRenderPaginationAPI) => VNode;
|
|
62
62
|
stickyHeader: boolean;
|
|
63
63
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
|
+
/********************************* UTILS **************************************/
|
|
64
65
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
66
|
+
* Creates a strongly-typed column factory for a given row type.
|
|
67
|
+
*
|
|
68
|
+
* @template Row The row data type (e.g., `Product`)
|
|
69
|
+
*
|
|
70
|
+
* @returns {function} A function that accepts a column definition and infers:
|
|
71
|
+
* - `K` as the field key (`keyof Row`)
|
|
72
|
+
* - `F` as the return type of `valueFormatter` (defaults to `Row[K]`)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // Define your row type
|
|
77
|
+
* interface Product {
|
|
78
|
+
* name: string;
|
|
79
|
+
* price: number;
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
82
|
+
* const col = makeColumn<Product>();
|
|
67
83
|
*/
|
|
68
|
-
export declare
|
|
69
|
-
columns: {
|
|
70
|
-
type: PropType<NvDatatableColumn<NvDatatableRow>[]>;
|
|
71
|
-
required: true;
|
|
72
|
-
default: () => any[];
|
|
73
|
-
};
|
|
74
|
-
rows: {
|
|
75
|
-
type: PropType<NvDatatableRow[]>;
|
|
76
|
-
required: true;
|
|
77
|
-
default: () => any[];
|
|
78
|
-
};
|
|
79
|
-
pagination: {
|
|
80
|
-
type: PropType<NvDatatablePaginationConfig>;
|
|
81
|
-
default: any;
|
|
82
|
-
};
|
|
83
|
-
renderPagination: {
|
|
84
|
-
type: PropType<(api: NvDatatableRenderPaginationAPI) => VNode>;
|
|
85
|
-
default: any;
|
|
86
|
-
};
|
|
87
|
-
stickyHeader: {
|
|
88
|
-
type: BooleanConstructor;
|
|
89
|
-
default: boolean;
|
|
90
|
-
};
|
|
91
|
-
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
92
|
-
[key: string]: any;
|
|
93
|
-
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
94
|
-
columns: {
|
|
95
|
-
type: PropType<NvDatatableColumn<NvDatatableRow>[]>;
|
|
96
|
-
required: true;
|
|
97
|
-
default: () => any[];
|
|
98
|
-
};
|
|
99
|
-
rows: {
|
|
100
|
-
type: PropType<NvDatatableRow[]>;
|
|
101
|
-
required: true;
|
|
102
|
-
default: () => any[];
|
|
103
|
-
};
|
|
104
|
-
pagination: {
|
|
105
|
-
type: PropType<NvDatatablePaginationConfig>;
|
|
106
|
-
default: any;
|
|
107
|
-
};
|
|
108
|
-
renderPagination: {
|
|
109
|
-
type: PropType<(api: NvDatatableRenderPaginationAPI) => VNode>;
|
|
110
|
-
default: any;
|
|
111
|
-
};
|
|
112
|
-
stickyHeader: {
|
|
113
|
-
type: BooleanConstructor;
|
|
114
|
-
default: boolean;
|
|
115
|
-
};
|
|
116
|
-
}>> & Readonly<{}>, {
|
|
117
|
-
columns: NvDatatableColumn<NvDatatableRow>[];
|
|
118
|
-
rows: NvDatatableRow[];
|
|
119
|
-
pagination: NvDatatablePaginationConfig;
|
|
120
|
-
renderPagination: (api: NvDatatableRenderPaginationAPI) => VNode;
|
|
121
|
-
stickyHeader: boolean;
|
|
122
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
84
|
+
export declare function makeColumn<Row>(): <K extends keyof Row, F = Row[K]>(col: NvDatatableColumn<Row, K, F>) => NvDatatableColumn<Row, keyof Row, Row[keyof Row]>;
|
|
123
85
|
/********************************* TYPES **************************************/
|
|
124
86
|
/**
|
|
125
|
-
*
|
|
87
|
+
* Slot props for NvDatatable cell slots.
|
|
88
|
+
* Use this type to provide type safety for custom cell slot implementations.
|
|
89
|
+
*
|
|
90
|
+
* @template Row The row data type
|
|
91
|
+
* @template K The field key (keyof Row)
|
|
92
|
+
* @template F The formatted value type (defaults to Row[K])
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* type PersonRow = {
|
|
97
|
+
* id: number;
|
|
98
|
+
* isActive: boolean;
|
|
99
|
+
* };
|
|
100
|
+
*
|
|
101
|
+
* // For a column with valueFormatter that returns string
|
|
102
|
+
* type StatusSlotProps = NvDatatableSlotProps<PersonRow, 'isActive', string>;
|
|
103
|
+
*
|
|
104
|
+
* // For a column without valueFormatter (uses raw value)
|
|
105
|
+
* type IdSlotProps = NvDatatableSlotProps<PersonRow, 'id', number>;
|
|
106
|
+
* ```
|
|
126
107
|
*/
|
|
127
|
-
export
|
|
108
|
+
export interface NvDatatableSlotProps<Row, K extends keyof Row = keyof Row, F = Row[K]> {
|
|
109
|
+
/** The cell value (formatted if valueFormatter was used) */
|
|
110
|
+
value: F;
|
|
111
|
+
/** The full row data */
|
|
112
|
+
row: Row;
|
|
113
|
+
/** The field name */
|
|
114
|
+
field: K;
|
|
115
|
+
/** The row index (zero-based) */
|
|
116
|
+
rowIndex: number;
|
|
117
|
+
}
|
|
128
118
|
/**
|
|
129
|
-
*
|
|
119
|
+
* Props for NvDatatable component.
|
|
130
120
|
*/
|
|
131
|
-
export interface
|
|
132
|
-
/**
|
|
133
|
-
|
|
121
|
+
export interface NvDatatableProps<T> {
|
|
122
|
+
/** Column definitions */
|
|
123
|
+
columns: Array<NvDatatableColumn<T>>;
|
|
134
124
|
/** Row data */
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
|
|
125
|
+
rows: Array<T>;
|
|
126
|
+
/** Optional pagination configuration */
|
|
127
|
+
pagination?: NvDatatablePaginationConfig;
|
|
128
|
+
/** Optional render function for custom pagination UI */
|
|
129
|
+
renderPagination?: (api: NvDatatableRenderPaginationAPI) => VNode;
|
|
130
|
+
/** Should the header stick to the top of the table when scrolling? */
|
|
131
|
+
stickyHeader?: boolean;
|
|
132
|
+
/** CSS class */
|
|
133
|
+
class?: string;
|
|
134
|
+
/** Inline styles */
|
|
135
|
+
style?: string | Record<string, string>;
|
|
140
136
|
}
|
|
141
137
|
/**
|
|
142
138
|
* Column definition for NvDatatable.
|
|
143
139
|
*/
|
|
144
|
-
export interface NvDatatableColumn<
|
|
140
|
+
export interface NvDatatableColumn<Row, K extends keyof Row = keyof Row, F = Row[K]> {
|
|
145
141
|
/** Field name from row data */
|
|
146
|
-
field:
|
|
142
|
+
field: K;
|
|
147
143
|
/** Display name for column header */
|
|
148
144
|
headerName?: string;
|
|
149
145
|
/** Column width in pixels */
|
|
@@ -152,27 +148,34 @@ export interface NvDatatableColumn<T extends NvDatatableRow> {
|
|
|
152
148
|
resizable?: boolean;
|
|
153
149
|
/** Whether column is hidden */
|
|
154
150
|
hidden?: boolean;
|
|
151
|
+
/** Transform the raw value before rendering. Receives the cell value and full row object. */
|
|
152
|
+
valueFormatter?: (params: NvTableValueFormatterParams<Row, Row[K], K>) => F;
|
|
155
153
|
/** Custom cell renderer */
|
|
156
|
-
renderCell?: (params: NvTableRenderCellParams<
|
|
154
|
+
renderCell?: (params: NvTableRenderCellParams<Row, F, K>) => VNode | string | number;
|
|
157
155
|
}
|
|
158
156
|
/**
|
|
159
|
-
*
|
|
157
|
+
* Parameters for custom cell rendering function.
|
|
160
158
|
*/
|
|
161
|
-
export interface
|
|
162
|
-
/**
|
|
163
|
-
|
|
159
|
+
export interface NvTableRenderCellParams<Row, Value, Field> {
|
|
160
|
+
/** Cell value */
|
|
161
|
+
value: Value;
|
|
164
162
|
/** Row data */
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
163
|
+
row: Row;
|
|
164
|
+
/** Field name */
|
|
165
|
+
field: Field;
|
|
166
|
+
/** Row index */
|
|
167
|
+
rowIndex: number;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Parameters for valueFormatter function.
|
|
171
|
+
*/
|
|
172
|
+
export interface NvTableValueFormatterParams<Row, Value, Field> {
|
|
173
|
+
/** Cell original value */
|
|
174
|
+
value: Value;
|
|
175
|
+
/** Row data */
|
|
176
|
+
row: Row;
|
|
177
|
+
/** Field name */
|
|
178
|
+
field: Field;
|
|
176
179
|
}
|
|
177
180
|
/**
|
|
178
181
|
* Pagination configuration for NvDatatable.
|
|
@@ -48,6 +48,16 @@ export function createNvDatatable() {
|
|
|
48
48
|
.filter((col) => !col.hidden)
|
|
49
49
|
.map((col) => ({
|
|
50
50
|
accessorKey: col.field,
|
|
51
|
+
accessorFn: col.valueFormatter
|
|
52
|
+
? (row) => {
|
|
53
|
+
const rawValue = row[col.field];
|
|
54
|
+
return col.valueFormatter({
|
|
55
|
+
value: rawValue,
|
|
56
|
+
row,
|
|
57
|
+
field: col.field,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
: undefined,
|
|
51
61
|
header: col.headerName || String(col.field),
|
|
52
62
|
size: col.width,
|
|
53
63
|
enableResizing: col.resizable ?? true,
|
|
@@ -304,8 +314,28 @@ export function createNvDatatable() {
|
|
|
304
314
|
},
|
|
305
315
|
});
|
|
306
316
|
}
|
|
317
|
+
/********************************* UTILS **************************************/
|
|
307
318
|
/**
|
|
308
|
-
*
|
|
309
|
-
*
|
|
319
|
+
* Creates a strongly-typed column factory for a given row type.
|
|
320
|
+
*
|
|
321
|
+
* @template Row The row data type (e.g., `Product`)
|
|
322
|
+
*
|
|
323
|
+
* @returns {function} A function that accepts a column definition and infers:
|
|
324
|
+
* - `K` as the field key (`keyof Row`)
|
|
325
|
+
* - `F` as the return type of `valueFormatter` (defaults to `Row[K]`)
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* // Define your row type
|
|
330
|
+
* interface Product {
|
|
331
|
+
* name: string;
|
|
332
|
+
* price: number;
|
|
333
|
+
* }
|
|
334
|
+
*
|
|
335
|
+
* const col = makeColumn<Product>();
|
|
310
336
|
*/
|
|
311
|
-
export
|
|
337
|
+
export function makeColumn() {
|
|
338
|
+
return function define(col) {
|
|
339
|
+
return col;
|
|
340
|
+
};
|
|
341
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nova-design-system/nova-vue",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "Nova is a design system created by Elia Group to empower creators to efficiently build solutions that people love to use.",
|
|
5
5
|
"author": "Elia Group",
|
|
6
6
|
"homepage": "https://nova.eliagroup.io",
|