@nova-design-system/nova-angular-19 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.
@@ -4,9 +4,9 @@ import * as i0 from "@angular/core";
4
4
  /**
5
5
  * Context type for cell templates - uses TanStack Table's CellContext directly
6
6
  */
7
- export type NvDatatableCellContext<T> = {
7
+ export type NvDatatableCellContext<T, V> = {
8
8
  /** The cell's actual value */
9
- $implicit: CellContext<T, unknown>;
9
+ $implicit: CellContext<T, V>;
10
10
  };
11
11
  /**
12
12
  * Directive to mark ng-templates as cell templates for specific fields.
@@ -24,14 +24,14 @@ export type NvDatatableCellContext<T> = {
24
24
  * </nv-datatable>
25
25
  * ```
26
26
  */
27
- export declare class NvDatatableCellDirective<T = any> {
28
- template: TemplateRef<NvDatatableCellContext<T>>;
27
+ export declare class NvDatatableCellDirective<T, V> {
28
+ template: TemplateRef<NvDatatableCellContext<T, V>>;
29
29
  /**
30
30
  * The field name this template should render.
31
31
  * Should match a field in your column definitions.
32
32
  */
33
33
  nvDatatableCell: string;
34
- constructor(template: TemplateRef<NvDatatableCellContext<T>>);
35
- static ɵfac: i0.ɵɵFactoryDeclaration<NvDatatableCellDirective<any>, never>;
36
- static ɵdir: i0.ɵɵDirectiveDeclaration<NvDatatableCellDirective<any>, "ng-template[nvDatatableCell]", never, { "nvDatatableCell": { "alias": "nvDatatableCell"; "required": true; }; }, {}, never, never, true, never>;
34
+ constructor(template: TemplateRef<NvDatatableCellContext<T, V>>);
35
+ static ɵfac: i0.ɵɵFactoryDeclaration<NvDatatableCellDirective<any, any>, never>;
36
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NvDatatableCellDirective<any, any>, "ng-template[nvDatatableCell]", never, { "nvDatatableCell": { "alias": "nvDatatableCell"; "required": true; }; }, {}, never, never, true, never>;
37
37
  }
@@ -1,33 +1,125 @@
1
1
  import { TemplateRef, QueryList, AfterViewInit, OnDestroy } from '@angular/core';
2
2
  import { NvDatatableCellDirective } from './nv-datatable-cell.directive';
3
- import { type FlexRenderComponent, type ColumnDef, type CellContext } from './datatable.utils';
3
+ import { type FlexRenderComponent, type ColumnDef, type CellContext, type NoInfer } from './datatable.utils';
4
4
  import * as i0 from "@angular/core";
5
- export type { CellContext as NvDatatableCellContext };
6
- export { flexRenderComponent as nvDatatableRenderComponent } from './datatable.utils';
7
- /** Type definition for a datatable row. */
8
- export type NvDatatableRow = Record<string, string | number | boolean | null | undefined | typeof Date>;
9
- /** Parameters for custom cell rendering function. */
10
- export interface NvTableRenderCellParams<T extends NvDatatableRow, V> {
11
- value: V;
12
- row: T;
13
- field: keyof T;
14
- rowIndex: number;
5
+ /**
6
+ * A powerful, flexible datatable component built on TanStack Table.
7
+ * Supports custom cell rendering, column configuration, pagination, and full TypeScript typing.
8
+ */
9
+ export declare class NvDatatable<T> implements AfterViewInit, OnDestroy {
10
+ /** Column definitions */
11
+ columns: import("@angular/core").InputSignal<NvDatatableColumn<T, keyof T, T[keyof T]>[]>;
12
+ /** Row data */
13
+ rows: import("@angular/core").InputSignal<T[]>;
14
+ /** Optional pagination configuration */
15
+ pagination: import("@angular/core").InputSignal<NvDatatablePaginationConfig | undefined>;
16
+ /** Should the header stick to the top of the table when scrolling? */
17
+ stickyHeader: import("@angular/core").InputSignal<boolean>;
18
+ /** Template for custom pagination UI */
19
+ paginationTemplate?: TemplateRef<{
20
+ $implicit: NvDatatableRenderPaginationAPI;
21
+ }>;
22
+ /** Cell templates provided via nvDatatableCell directive */
23
+ cellTemplates?: QueryList<NvDatatableCellDirective<T, T[keyof T]>>;
24
+ /** Signal to track cell templates array */
25
+ private cellTemplatesSignal;
26
+ /** Map of field names to cell templates */
27
+ private cellTemplateMap;
28
+ /** Pagination state for server mode */
29
+ private paginationState;
30
+ /** Reference to table rows for infinite scroll observer */
31
+ private tableRows;
32
+ /** Intersection observer for infinite scroll */
33
+ private observer;
34
+ /** Helper to check if using infinite scroll */
35
+ isInfiniteScroll: import("@angular/core").Signal<boolean>;
36
+ /** Computed table columns with proper typing and filtering. */
37
+ tableColumns: import("@angular/core").Signal<ColumnDef<T, T[keyof T]>[]>;
38
+ /** TanStack table instance with Signals */
39
+ private tableInstance;
40
+ /** Public getter for table instance. */
41
+ table(): import("@tanstack/table-core").Table<T>;
42
+ /** Build pagination API for template */
43
+ paginationAPI: import("@angular/core").Signal<NvDatatableRenderPaginationAPI | null>;
44
+ constructor();
45
+ ngAfterViewInit(): void;
46
+ ngOnDestroy(): void;
47
+ static ɵfac: i0.ɵɵFactoryDeclaration<NvDatatable<any>, never>;
48
+ static ɵcmp: i0.ɵɵComponentDeclaration<NvDatatable<any>, "nv-datatable", never, { "columns": { "alias": "columns"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "pagination": { "alias": "pagination"; "required": false; "isSignal": true; }; "stickyHeader": { "alias": "stickyHeader"; "required": false; "isSignal": true; }; }, {}, ["paginationTemplate", "cellTemplates"], never, true, never>;
15
49
  }
50
+ /********************************* UTILS **************************************/
51
+ /**
52
+ * Creates a strongly-typed column factory for a given row type.
53
+ *
54
+ * @template Row The row data type (e.g., `Product`)
55
+ *
56
+ * @returns {function} A function that accepts a column definition and infers:
57
+ * - `K` as the field key (`keyof Row`)
58
+ * - `F` as the return type of `valueFormatter` (defaults to `Row[K]`)
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * // Define your row type
63
+ * interface Product {
64
+ * name: string;
65
+ * price: number;
66
+ * }
67
+ *
68
+ * const col = makeColumn<Product>();
69
+ */
70
+ export declare function makeColumn<Row>(): <K extends keyof Row, F = Row[K]>(col: NvDatatableColumn<Row, K, F>) => NvDatatableColumn<Row>;
71
+ export { flexRenderComponent as nvDatatableRenderComponent } from './datatable.utils';
72
+ /********************************* TYPES **************************************/
73
+ export type { CellContext as NvDatatableCellContext };
16
74
  /** Column definition for NvDatatable. */
17
- export interface NvDatatableColumn<T extends NvDatatableRow> {
18
- field: keyof T;
75
+ export interface NvDatatableColumn<Row, K extends keyof Row = keyof Row, F = Row[K]> {
76
+ /** Field name from row data */
77
+ field: K;
78
+ /** Display name for column header */
19
79
  headerName?: string;
80
+ /** Column width in pixels */
20
81
  width?: number;
82
+ /** Whether column is resizable */
21
83
  resizable?: boolean;
84
+ /** Whether column is hidden */
22
85
  hidden?: boolean;
86
+ /**
87
+ * Transform the raw value before rendering. Receives the cell value and full row object.
88
+ * This is useful for formatting dates, converting arrays to strings, accessing nested objects, etc.
89
+ * The transformed value is then passed to renderCell or templates.
90
+ */
91
+ valueFormatter?: (params: NvTableValueFormatterParams<Row, Row[K], K>) => F;
23
92
  /**
24
93
  * Custom cell renderer function that can return either a string or Angular TemplateRef.
25
94
  * Use `$implicit` in your template to receive the CellContext.
95
+ * Note: If valueFormatter is provided, renderCell receives the formatted value.
26
96
  */
27
- renderCell?: (context: CellContext<T, unknown>) => string | FlexRenderComponent | TemplateRef<{
28
- $implicit: CellContext<T, unknown>;
97
+ renderCell?: (context: CellContext<Row, F>) => string | FlexRenderComponent | TemplateRef<{
98
+ $implicit: CellContext<Row, F>;
29
99
  }>;
30
100
  }
101
+ /** Parameters for custom cell rendering function. */
102
+ export interface NvTableRenderCellParams<Row, Value, Field> {
103
+ /** Cell value */
104
+ value: Value | NoInfer<Value>;
105
+ /** Row data */
106
+ row: Row;
107
+ /** Field name */
108
+ field: Field;
109
+ /** Row index */
110
+ rowIndex: number;
111
+ }
112
+ /**
113
+ * Parameters for valueFormatter function.
114
+ */
115
+ export interface NvTableValueFormatterParams<Row, Value, Field> {
116
+ /** Cell original value */
117
+ value: Value;
118
+ /** Row data */
119
+ row: Row;
120
+ /** Field name */
121
+ field: Field;
122
+ }
31
123
  /**
32
124
  * Pagination configuration for NvDatatable.
33
125
  * Supports three modes: client-side, server-side with buttons, and infinite scroll.
@@ -92,47 +184,3 @@ export interface NvDatatableRenderPaginationAPI {
92
184
  /** Whether more items are available (only for infinite scroll) */
93
185
  hasMore?: boolean;
94
186
  }
95
- /**
96
- * Nova Datatable built on TanStack Table (Angular).
97
- */
98
- export declare class NvDatatable<T extends NvDatatableRow = NvDatatableRow> implements AfterViewInit, OnDestroy {
99
- /** Column definitions */
100
- columns: import("@angular/core").InputSignal<NvDatatableColumn<T>[]>;
101
- /** Row data */
102
- rows: import("@angular/core").InputSignal<T[]>;
103
- /** Optional pagination configuration */
104
- pagination: import("@angular/core").InputSignal<NvDatatablePaginationConfig | undefined>;
105
- /** Should the header stick to the top of the table when scrolling? */
106
- stickyHeader: import("@angular/core").InputSignal<boolean>;
107
- /** Template for custom pagination UI */
108
- paginationTemplate?: TemplateRef<{
109
- $implicit: NvDatatableRenderPaginationAPI;
110
- }>;
111
- /** Cell templates provided via nvDatatableCell directive */
112
- cellTemplates?: QueryList<NvDatatableCellDirective<T>>;
113
- /** Signal to track cell templates array */
114
- private cellTemplatesSignal;
115
- /** Map of field names to cell templates */
116
- private cellTemplateMap;
117
- /** Pagination state for server mode */
118
- private paginationState;
119
- /** Reference to table rows for infinite scroll observer */
120
- private tableRows;
121
- /** Intersection observer for infinite scroll */
122
- private observer;
123
- /** Helper to check if using infinite scroll */
124
- isInfiniteScroll: import("@angular/core").Signal<boolean>;
125
- /** Computed table columns with proper typing and filtering. */
126
- tableColumns: import("@angular/core").Signal<ColumnDef<T>[]>;
127
- /** TanStack table instance with Signals */
128
- private tableInstance;
129
- /** Public getter for table instance. */
130
- table(): import("@tanstack/table-core").Table<T>;
131
- /** Build pagination API for template */
132
- paginationAPI: import("@angular/core").Signal<NvDatatableRenderPaginationAPI | null>;
133
- constructor();
134
- ngAfterViewInit(): void;
135
- ngOnDestroy(): void;
136
- static ɵfac: i0.ɵɵFactoryDeclaration<NvDatatable<any>, never>;
137
- static ɵcmp: i0.ɵɵComponentDeclaration<NvDatatable<any>, "nv-datatable", never, { "columns": { "alias": "columns"; "required": false; "isSignal": true; }; "rows": { "alias": "rows"; "required": false; "isSignal": true; }; "pagination": { "alias": "pagination"; "required": false; "isSignal": true; }; "stickyHeader": { "alias": "stickyHeader"; "required": false; "isSignal": true; }; }, {}, ["paginationTemplate", "cellTemplates"], never, true, never>;
138
- }
@@ -360,7 +360,7 @@ export declare interface NvFieldnumber extends Components.NvFieldnumber {
360
360
  /**
361
361
  * Emitted when the input value changes. @bind value
362
362
  */
363
- valueChanged: EventEmitter<CustomEvent<number>>;
363
+ valueChanged: EventEmitter<CustomEvent<number | null>>;
364
364
  }
365
365
  export declare class NvFieldpassword {
366
366
  protected z: NgZone;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nova-design-system/nova-angular-19",
3
- "version": "3.19.0",
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",