@nova-design-system/nova-angular 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.
@@ -2094,7 +2094,8 @@ function createAngularTable(options) {
2094
2094
  /* eslint-disable jsdoc/require-jsdoc */
2095
2095
  /* eslint-disable jsdoc/require-returns */
2096
2096
  /**
2097
- * Nova Datatable built on TanStack Table (Angular).
2097
+ * A powerful, flexible datatable component built on TanStack Table.
2098
+ * Supports custom cell rendering, column configuration, pagination, and full TypeScript typing.
2098
2099
  */
2099
2100
  class NvDatatable {
2100
2101
  /** Public getter for table instance. */
@@ -2136,27 +2137,41 @@ class NvDatatable {
2136
2137
  const templateMap = this.cellTemplateMap();
2137
2138
  return this.columns()
2138
2139
  .filter((col) => !col.hidden)
2139
- .map((col) => ({
2140
- accessorKey: col.field,
2141
- header: col.headerName || String(col.field),
2142
- size: col.width,
2143
- enableResizing: col.resizable ?? true,
2144
- cell: (context) => {
2140
+ .map((col) => {
2141
+ // Shared cell renderer
2142
+ const cellRenderer = (context) => {
2145
2143
  const fieldName = String(col.field);
2146
2144
  const cellTemplate = templateMap.get(fieldName);
2147
2145
  // Priority: template > renderCell > default
2148
2146
  if (cellTemplate) {
2149
- // Return TemplateRef directly - FlexRender will handle it
2147
+ // Return TemplateRef directly - getValue() returns formatted value
2150
2148
  return cellTemplate;
2151
2149
  }
2152
2150
  // Fall back to renderCell if provided
2153
2151
  if (col.renderCell) {
2154
2152
  return col.renderCell(context);
2155
2153
  }
2156
- // Default: just return the value
2154
+ // Default: just return the value (formatted if valueFormatter was used)
2157
2155
  return context.getValue();
2158
- },
2159
- }));
2156
+ };
2157
+ return {
2158
+ accessorKey: col.field,
2159
+ accessorFn: col.valueFormatter
2160
+ ? (row) => {
2161
+ const rawValue = row[col.field];
2162
+ return col.valueFormatter({
2163
+ value: rawValue,
2164
+ row,
2165
+ field: col.field,
2166
+ });
2167
+ }
2168
+ : undefined,
2169
+ header: col.headerName || String(col.field),
2170
+ size: col.width,
2171
+ enableResizing: col.resizable ?? true,
2172
+ cell: cellRenderer,
2173
+ };
2174
+ });
2160
2175
  });
2161
2176
  /** TanStack table instance with Signals */
2162
2177
  this.tableInstance = createAngularTable(() => {
@@ -2468,6 +2483,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImpor
2468
2483
  type: ContentChildren,
2469
2484
  args: [NvDatatableCellDirective]
2470
2485
  }] } });
2486
+ /********************************* UTILS **************************************/
2487
+ /**
2488
+ * Creates a strongly-typed column factory for a given row type.
2489
+ *
2490
+ * @template Row The row data type (e.g., `Product`)
2491
+ *
2492
+ * @returns {function} A function that accepts a column definition and infers:
2493
+ * - `K` as the field key (`keyof Row`)
2494
+ * - `F` as the return type of `valueFormatter` (defaults to `Row[K]`)
2495
+ *
2496
+ * @example
2497
+ * ```ts
2498
+ * // Define your row type
2499
+ * interface Product {
2500
+ * name: string;
2501
+ * price: number;
2502
+ * }
2503
+ *
2504
+ * const col = makeColumn<Product>();
2505
+ */
2506
+ function makeColumn() {
2507
+ return function define(col) {
2508
+ return col;
2509
+ };
2510
+ }
2471
2511
 
2472
2512
  class ValueAccessor {
2473
2513
  constructor(el) {
@@ -3706,5 +3746,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.9", ngImpor
3706
3746
  * Generated bundle index. Do not edit.
3707
3747
  */
3708
3748
 
3709
- export { NotificationService, NotificationServiceComponent, NovaComponentsModule, NovaComponentsProvidersModule, NovaComponentsValueAccessorModule, NvAccordion, NvAccordionItem, NvAccordionValueAccessor, NvAlert, NvAlertValueAccessor, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCalendarValueAccessor, NvCol, NvDatagrid, NvDatagridValueAccessor, NvDatagridcolumn, NvDatatable, NvDatatableCellDirective, NvDialog, NvDialogValueAccessor, NvDialogfooter, NvDialogheader, NvFieldcheckbox, NvFieldcheckboxValueAccessor, NvFielddate, NvFielddateValueAccessor, NvFielddaterange, NvFielddaterangeValueAccessor, NvFielddropdown, NvFielddropdownValueAccessor, NvFielddropdownitem, NvFielddropdownitemcheck, NvFieldmultiselect, NvFieldmultiselectValueAccessor, NvFieldnumber, NvFieldnumberValueAccessor, NvFieldpassword, NvFieldpasswordValueAccessor, NvFieldradio, NvFieldradioValueAccessor, NvFieldselect, NvFieldselectValueAccessor, NvFieldslider, NvFieldsliderValueAccessor, NvFieldtext, NvFieldtextValueAccessor, NvFieldtextarea, NvFieldtextareaValueAccessor, NvFieldtime, NvFieldtimeValueAccessor, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvNotificationValueAccessor, NvNotificationcontainer, NvPopover, NvPopoverValueAccessor, NvRow, NvSplit, NvSplitValueAccessor, NvStack, NvTable, NvToggle, NvToggleValueAccessor, NvTogglebutton, NvTogglebuttongroup, NvTogglebuttongroupValueAccessor, NvTooltip, VALUE_ACCESSORS, flexRenderComponent as nvDatatableRenderComponent, provideNovaComponents };
3749
+ export { NotificationService, NotificationServiceComponent, NovaComponentsModule, NovaComponentsProvidersModule, NovaComponentsValueAccessorModule, NvAccordion, NvAccordionItem, NvAccordionValueAccessor, NvAlert, NvAlertValueAccessor, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCalendarValueAccessor, NvCol, NvDatagrid, NvDatagridValueAccessor, NvDatagridcolumn, NvDatatable, NvDatatableCellDirective, NvDialog, NvDialogValueAccessor, NvDialogfooter, NvDialogheader, NvFieldcheckbox, NvFieldcheckboxValueAccessor, NvFielddate, NvFielddateValueAccessor, NvFielddaterange, NvFielddaterangeValueAccessor, NvFielddropdown, NvFielddropdownValueAccessor, NvFielddropdownitem, NvFielddropdownitemcheck, NvFieldmultiselect, NvFieldmultiselectValueAccessor, NvFieldnumber, NvFieldnumberValueAccessor, NvFieldpassword, NvFieldpasswordValueAccessor, NvFieldradio, NvFieldradioValueAccessor, NvFieldselect, NvFieldselectValueAccessor, NvFieldslider, NvFieldsliderValueAccessor, NvFieldtext, NvFieldtextValueAccessor, NvFieldtextarea, NvFieldtextareaValueAccessor, NvFieldtime, NvFieldtimeValueAccessor, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvNotificationValueAccessor, NvNotificationcontainer, NvPopover, NvPopoverValueAccessor, NvRow, NvSplit, NvSplitValueAccessor, NvStack, NvTable, NvToggle, NvToggleValueAccessor, NvTogglebutton, NvTogglebuttongroup, NvTogglebuttongroupValueAccessor, NvTooltip, VALUE_ACCESSORS, makeColumn, flexRenderComponent as nvDatatableRenderComponent, provideNovaComponents };
3710
3750
  //# sourceMappingURL=nova-components.mjs.map