@nova-design-system/nova-angular-18 3.14.0 → 3.16.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.
Files changed (41) hide show
  1. package/dist/nova-components/esm2022/lib/components/datatable.utils/flex-render/context.mjs +6 -0
  2. package/dist/nova-components/esm2022/lib/components/datatable.utils/flex-render/flags.mjs +42 -0
  3. package/dist/nova-components/esm2022/lib/components/datatable.utils/flex-render/flex-render-component-ref.mjs +171 -0
  4. package/dist/nova-components/esm2022/lib/components/datatable.utils/flex-render/flex-render-component.mjs +39 -0
  5. package/dist/nova-components/esm2022/lib/components/datatable.utils/flex-render/view.mjs +101 -0
  6. package/dist/nova-components/esm2022/lib/components/datatable.utils/flex-render.mjs +211 -0
  7. package/dist/nova-components/esm2022/lib/components/datatable.utils/index.mjs +49 -0
  8. package/dist/nova-components/esm2022/lib/components/datatable.utils/lazy-signal-initializer.mjs +43 -0
  9. package/dist/nova-components/esm2022/lib/components/datatable.utils/proxy.mjs +87 -0
  10. package/dist/nova-components/esm2022/lib/components/index.mjs +2 -0
  11. package/dist/nova-components/esm2022/lib/components/nv-datatable.component.mjs +158 -0
  12. package/dist/nova-components/esm2022/lib/nova-components.module.mjs +7 -5
  13. package/dist/nova-components/esm2022/lib/providers/index.mjs +3 -0
  14. package/dist/nova-components/esm2022/lib/providers/notification-service.component.mjs +183 -0
  15. package/dist/nova-components/esm2022/lib/providers/notification.service.mjs +134 -0
  16. package/dist/nova-components/esm2022/lib/stencil-generated/component-value-accessors.mjs +37 -1
  17. package/dist/nova-components/esm2022/lib/stencil-generated/components.mjs +35 -38
  18. package/dist/nova-components/esm2022/lib/stencil-generated/index.mjs +2 -2
  19. package/dist/nova-components/esm2022/public-api.mjs +3 -1
  20. package/dist/nova-components/fesm2022/nova-components.mjs +1268 -44
  21. package/dist/nova-components/fesm2022/nova-components.mjs.map +1 -1
  22. package/dist/nova-components/lib/components/datatable.utils/flex-render/context.d.ts +3 -0
  23. package/dist/nova-components/lib/components/datatable.utils/flex-render/flags.d.ts +40 -0
  24. package/dist/nova-components/lib/components/datatable.utils/flex-render/flex-render-component-ref.d.ts +39 -0
  25. package/dist/nova-components/lib/components/datatable.utils/flex-render/flex-render-component.d.ts +60 -0
  26. package/dist/nova-components/lib/components/datatable.utils/flex-render/view.d.ts +49 -0
  27. package/dist/nova-components/lib/components/datatable.utils/flex-render.d.ts +26 -0
  28. package/dist/nova-components/lib/components/datatable.utils/index.d.ts +6 -0
  29. package/dist/nova-components/lib/components/datatable.utils/lazy-signal-initializer.d.ts +5 -0
  30. package/dist/nova-components/lib/components/datatable.utils/proxy.d.ts +3 -0
  31. package/dist/nova-components/lib/components/index.d.ts +1 -0
  32. package/dist/nova-components/lib/components/nv-datatable.component.d.ts +46 -0
  33. package/dist/nova-components/lib/nova-components.module.d.ts +4 -3
  34. package/dist/nova-components/lib/providers/index.d.ts +2 -0
  35. package/dist/nova-components/lib/providers/notification-service.component.d.ts +56 -0
  36. package/dist/nova-components/lib/providers/notification.service.d.ts +116 -0
  37. package/dist/nova-components/lib/stencil-generated/component-value-accessors.d.ts +8 -1
  38. package/dist/nova-components/lib/stencil-generated/components.d.ts +13 -22
  39. package/dist/nova-components/lib/stencil-generated/index.d.ts +1 -1
  40. package/dist/nova-components/public-api.d.ts +2 -0
  41. package/package.json +6 -3
@@ -1,8 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { ChangeDetectionStrategy, Component, HostListener, Directive, APP_INITIALIZER, NgModule } from '@angular/core';
2
+ import { ChangeDetectionStrategy, Component, untracked, computed, InjectionToken, inject, reflectComponentType, ViewContainerRef, Injectable, KeyValueDiffers, ChangeDetectorRef, OutputEmitterRef, TemplateRef, Type, Injector, runInInjectionContext, effect, Input, Inject, Directive, signal, input, CUSTOM_ELEMENTS_SCHEMA, HostListener, APP_INITIALIZER, NgModule, ElementRef, ViewChildren } from '@angular/core';
3
3
  import { defineCustomElements } from '@nova-design-system/nova-webcomponents/loader';
4
4
  import { __decorate } from 'tslib';
5
- import { fromEvent } from 'rxjs';
5
+ import { fromEvent, BehaviorSubject } from 'rxjs';
6
+ import * as i2 from '@angular/common';
7
+ import { CommonModule } from '@angular/common';
8
+ import { memo, createTable, getCoreRowModel } from '@tanstack/table-core';
6
9
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
7
10
  export * from '@nova-design-system/nova-webcomponents/constants';
8
11
 
@@ -69,7 +72,7 @@ let NvAccordion = class NvAccordion {
69
72
  this.z = z;
70
73
  c.detach();
71
74
  this.el = r.nativeElement;
72
- proxyOutputs(this, this.el, ['openChanged']);
75
+ proxyOutputs(this, this.el, ['openIndexesChanged']);
73
76
  }
74
77
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvAccordion, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
75
78
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvAccordion, selector: "nv-accordion", inputs: { data: "data", mode: "mode", openIndexes: "openIndexes" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
@@ -1004,12 +1007,12 @@ let NvNotification = class NvNotification {
1004
1007
  proxyOutputs(this, this.el, ['hiddenChanged']);
1005
1008
  }
1006
1009
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvNotification, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
1007
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvNotification, selector: "nv-notification", inputs: { dismissible: "dismissible", emphasis: "emphasis", feedback: "feedback", heading: "heading", hidden: "hidden", icon: "icon", message: "message", uid: "uid" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1010
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvNotification, selector: "nv-notification", inputs: { dismissible: "dismissible", emphasis: "emphasis", feedback: "feedback", heading: "heading", hidden: "hidden", icon: "icon", initiallyHidden: "initiallyHidden", message: "message", uid: "uid" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1008
1011
  };
1009
1012
  NvNotification = __decorate([
1010
1013
  ProxyCmp({
1011
- inputs: ['dismissible', 'emphasis', 'feedback', 'heading', 'hidden', 'icon', 'message', 'uid'],
1012
- methods: ['dismiss']
1014
+ inputs: ['dismissible', 'emphasis', 'feedback', 'heading', 'hidden', 'icon', 'initiallyHidden', 'message', 'uid'],
1015
+ methods: ['dismiss', 'show']
1013
1016
  })
1014
1017
  ], NvNotification);
1015
1018
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvNotification, decorators: [{
@@ -1019,7 +1022,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1019
1022
  changeDetection: ChangeDetectionStrategy.OnPush,
1020
1023
  template: '<ng-content></ng-content>',
1021
1024
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1022
- inputs: ['dismissible', 'emphasis', 'feedback', 'heading', 'hidden', 'icon', 'message', 'uid'],
1025
+ inputs: ['dismissible', 'emphasis', 'feedback', 'heading', 'hidden', 'icon', 'initiallyHidden', 'message', 'uid'],
1026
+ standalone: false
1027
+ }]
1028
+ }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }] });
1029
+ let NvNotificationcontainer = class NvNotificationcontainer {
1030
+ constructor(c, r, z) {
1031
+ this.z = z;
1032
+ c.detach();
1033
+ this.el = r.nativeElement;
1034
+ }
1035
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvNotificationcontainer, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
1036
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvNotificationcontainer, selector: "nv-notificationcontainer", inputs: { position: "position" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1037
+ };
1038
+ NvNotificationcontainer = __decorate([
1039
+ ProxyCmp({
1040
+ inputs: ['position']
1041
+ })
1042
+ ], NvNotificationcontainer);
1043
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvNotificationcontainer, decorators: [{
1044
+ type: Component,
1045
+ args: [{
1046
+ selector: 'nv-notificationcontainer',
1047
+ changeDetection: ChangeDetectionStrategy.OnPush,
1048
+ template: '<ng-content></ng-content>',
1049
+ // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1050
+ inputs: ['position'],
1023
1051
  standalone: false
1024
1052
  }]
1025
1053
  }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }] });
@@ -1103,15 +1131,12 @@ let NvTable = class NvTable {
1103
1131
  this.z = z;
1104
1132
  c.detach();
1105
1133
  this.el = r.nativeElement;
1106
- proxyOutputs(this, this.el, ['action']);
1107
1134
  }
1108
1135
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvTable, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
1109
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvTable, selector: "nv-table", inputs: { columnsConfig: "columnsConfig", columnsConfigJson: "columnsConfigJson", data: "data", dataJson: "dataJson", fallbackValue: "fallbackValue", noColumnsNoDataMessage: "noColumnsNoDataMessage", noDataMessage: "noDataMessage" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1136
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvTable, selector: "nv-table", ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1110
1137
  };
1111
1138
  NvTable = __decorate([
1112
- ProxyCmp({
1113
- inputs: ['columnsConfig', 'columnsConfigJson', 'data', 'dataJson', 'fallbackValue', 'noColumnsNoDataMessage', 'noDataMessage']
1114
- })
1139
+ ProxyCmp({})
1115
1140
  ], NvTable);
1116
1141
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvTable, decorators: [{
1117
1142
  type: Component,
@@ -1120,32 +1145,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1120
1145
  changeDetection: ChangeDetectionStrategy.OnPush,
1121
1146
  template: '<ng-content></ng-content>',
1122
1147
  // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1123
- inputs: ['columnsConfig', 'columnsConfigJson', 'data', 'dataJson', 'fallbackValue', 'noColumnsNoDataMessage', 'noDataMessage'],
1124
- standalone: false
1125
- }]
1126
- }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }] });
1127
- let NvTablecolumn = class NvTablecolumn {
1128
- constructor(c, r, z) {
1129
- this.z = z;
1130
- c.detach();
1131
- this.el = r.nativeElement;
1132
- }
1133
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvTablecolumn, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
1134
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NvTablecolumn, selector: "nv-tablecolumn", inputs: { header: "header", name: "name" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1135
- };
1136
- NvTablecolumn = __decorate([
1137
- ProxyCmp({
1138
- inputs: ['header', 'name']
1139
- })
1140
- ], NvTablecolumn);
1141
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvTablecolumn, decorators: [{
1142
- type: Component,
1143
- args: [{
1144
- selector: 'nv-tablecolumn',
1145
- changeDetection: ChangeDetectionStrategy.OnPush,
1146
- template: '<ng-content></ng-content>',
1147
- // eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
1148
- inputs: ['header', { name: 'name', required: true }],
1148
+ inputs: [],
1149
1149
  standalone: false
1150
1150
  }]
1151
1151
  }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }] });
@@ -1292,17 +1292,895 @@ const DIRECTIVES = [
1292
1292
  NvMenu,
1293
1293
  NvMenuitem,
1294
1294
  NvNotification,
1295
+ NvNotificationcontainer,
1295
1296
  NvPopover,
1296
1297
  NvRow,
1297
1298
  NvStack,
1298
1299
  NvTable,
1299
- NvTablecolumn,
1300
1300
  NvToggle,
1301
1301
  NvTogglebutton,
1302
1302
  NvTogglebuttongroup,
1303
1303
  NvTooltip
1304
1304
  ];
1305
1305
 
1306
+ /**
1307
+ * Implementation from @tanstack/angular-query
1308
+ * {@link https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/util/lazy-init/lazy-init.ts}
1309
+ */
1310
+ function lazyInit(initializer) {
1311
+ let object = null;
1312
+ const initializeObject = () => {
1313
+ if (!object) {
1314
+ object = untracked(() => initializer());
1315
+ }
1316
+ };
1317
+ queueMicrotask(() => initializeObject());
1318
+ const table = () => { };
1319
+ return new Proxy(table, {
1320
+ apply(target, thisArg, argArray) {
1321
+ initializeObject();
1322
+ if (typeof object === 'function') {
1323
+ return Reflect.apply(object, thisArg, argArray);
1324
+ }
1325
+ return Reflect.apply(target, thisArg, argArray);
1326
+ },
1327
+ get(_, prop, receiver) {
1328
+ initializeObject();
1329
+ return Reflect.get(object, prop, receiver);
1330
+ },
1331
+ has(_, prop) {
1332
+ initializeObject();
1333
+ return Reflect.has(object, prop);
1334
+ },
1335
+ ownKeys() {
1336
+ initializeObject();
1337
+ return Reflect.ownKeys(object);
1338
+ },
1339
+ getOwnPropertyDescriptor() {
1340
+ return {
1341
+ enumerable: true,
1342
+ configurable: true,
1343
+ };
1344
+ },
1345
+ });
1346
+ }
1347
+
1348
+ function proxifyTable(tableSignal) {
1349
+ const internalState = tableSignal;
1350
+ return new Proxy(internalState, {
1351
+ apply() {
1352
+ return tableSignal();
1353
+ },
1354
+ get(target, property) {
1355
+ if (target[property]) {
1356
+ return target[property];
1357
+ }
1358
+ const table = untracked(tableSignal);
1359
+ /**
1360
+ * Attempt to convert all accessors into computed ones,
1361
+ * excluding handlers as they do not retain any reactive value
1362
+ */
1363
+ if (property.startsWith('get') &&
1364
+ !property.endsWith('Handler')
1365
+ // e.g. getCoreRowModel, getSelectedRowModel etc.
1366
+ // We need that after a signal change even `rowModel` may mark the view as dirty.
1367
+ // This allows to always get the latest `getContext` value while using flexRender
1368
+ // && !property.endsWith('Model')
1369
+ ) {
1370
+ const maybeFn = table[property];
1371
+ if (typeof maybeFn === 'function') {
1372
+ Object.defineProperty(target, property, {
1373
+ value: toComputed(tableSignal, maybeFn),
1374
+ configurable: true,
1375
+ enumerable: true,
1376
+ });
1377
+ return target[property];
1378
+ }
1379
+ }
1380
+ // @ts-expect-error
1381
+ return (target[property] = table[property]);
1382
+ },
1383
+ has(_, prop) {
1384
+ return !!untracked(tableSignal)[prop];
1385
+ },
1386
+ ownKeys() {
1387
+ return Reflect.ownKeys(untracked(tableSignal));
1388
+ },
1389
+ getOwnPropertyDescriptor() {
1390
+ return {
1391
+ enumerable: true,
1392
+ configurable: true,
1393
+ };
1394
+ },
1395
+ });
1396
+ }
1397
+ /**
1398
+ * Here we'll handle all type of accessors:
1399
+ * - 0 argument -> e.g. table.getCanNextPage())
1400
+ * - 0~1 arguments -> e.g. table.getIsSomeRowsPinned(position?)
1401
+ * - 1 required argument -> e.g. table.getColumn(columnId)
1402
+ * - 1+ argument -> e.g. table.getRow(id, searchAll?)
1403
+ *
1404
+ * Since we are not able to detect automatically the accessors parameters,
1405
+ * we'll wrap all accessors into a cached function wrapping a computed
1406
+ * that return it's value based on the given parameters
1407
+ */
1408
+ function toComputed(signal, fn) {
1409
+ const hasArgs = fn.length > 0;
1410
+ if (!hasArgs) {
1411
+ return computed(() => {
1412
+ void signal();
1413
+ return fn();
1414
+ });
1415
+ }
1416
+ const computedCache = {};
1417
+ return (...argsArray) => {
1418
+ const serializedArgs = serializeArgs(...argsArray);
1419
+ if (computedCache.hasOwnProperty(serializedArgs)) {
1420
+ return computedCache[serializedArgs]?.();
1421
+ }
1422
+ const computedSignal = computed(() => {
1423
+ void signal();
1424
+ return fn(...argsArray);
1425
+ });
1426
+ computedCache[serializedArgs] = computedSignal;
1427
+ return computedSignal();
1428
+ };
1429
+ }
1430
+ function serializeArgs(...args) {
1431
+ return JSON.stringify(args);
1432
+ }
1433
+
1434
+ const FlexRenderComponentProps = new InjectionToken('[@tanstack/angular-table] Flex render component context props');
1435
+ function injectFlexRenderContext() {
1436
+ return inject(FlexRenderComponentProps);
1437
+ }
1438
+
1439
+ /**
1440
+ * Flags used to manage and optimize the rendering lifecycle of content of the cell,
1441
+ * while using FlexRenderDirective.
1442
+ */
1443
+ var FlexRenderFlags;
1444
+ (function (FlexRenderFlags) {
1445
+ /**
1446
+ * Indicates that the view is being created for the first time or will be cleared during the next update phase.
1447
+ * This is the initial state and will transition after the first ngDoCheck.
1448
+ */
1449
+ FlexRenderFlags[FlexRenderFlags["ViewFirstRender"] = 1] = "ViewFirstRender";
1450
+ /**
1451
+ * Represents a state where the view is not dirty, meaning no changes require rendering updates.
1452
+ */
1453
+ FlexRenderFlags[FlexRenderFlags["Pristine"] = 2] = "Pristine";
1454
+ /**
1455
+ * Indicates the `content` property has been modified or the view requires a complete re-render.
1456
+ * When this flag is enabled, the view will be cleared and recreated from scratch.
1457
+ */
1458
+ FlexRenderFlags[FlexRenderFlags["ContentChanged"] = 4] = "ContentChanged";
1459
+ /**
1460
+ * Indicates that the `props` property reference has changed.
1461
+ * When this flag is enabled, the view context is updated based on the type of the content.
1462
+ *
1463
+ * For Component view, inputs will be updated and view will be marked as dirty.
1464
+ * For TemplateRef and primitive values, view will be marked as dirty
1465
+ */
1466
+ FlexRenderFlags[FlexRenderFlags["PropsReferenceChanged"] = 8] = "PropsReferenceChanged";
1467
+ /**
1468
+ * Indicates that the current rendered view needs to be checked for changes.
1469
+ */
1470
+ FlexRenderFlags[FlexRenderFlags["DirtyCheck"] = 16] = "DirtyCheck";
1471
+ /**
1472
+ * Indicates that a signal within the `content(props)` result has changed
1473
+ */
1474
+ FlexRenderFlags[FlexRenderFlags["DirtySignal"] = 32] = "DirtySignal";
1475
+ /**
1476
+ * Indicates that the first render effect has been checked at least one time.
1477
+ */
1478
+ FlexRenderFlags[FlexRenderFlags["RenderEffectChecked"] = 64] = "RenderEffectChecked";
1479
+ })(FlexRenderFlags || (FlexRenderFlags = {}));
1480
+
1481
+ /**
1482
+ * Helper function to create a [@link FlexRenderComponent] instance, with better type-safety.
1483
+ *
1484
+ * - options object must be passed when the given component instance contains at least one required signal input.
1485
+ * - options/inputs is typed with the given component inputs
1486
+ * - options/outputs is typed with the given component outputs
1487
+ */
1488
+ function flexRenderComponent(component, ...options) {
1489
+ const { inputs, injector, outputs } = options?.[0] ?? {};
1490
+ return new FlexRenderComponent(component, inputs, injector, outputs);
1491
+ }
1492
+ /**
1493
+ * Wrapper class for a component that will be used as content for {@link FlexRenderDirective}
1494
+ *
1495
+ * Prefer {@link flexRenderComponent} helper for better type-safety
1496
+ */
1497
+ class FlexRenderComponent {
1498
+ constructor(component, inputs, injector, outputs) {
1499
+ this.component = component;
1500
+ this.inputs = inputs;
1501
+ this.injector = injector;
1502
+ this.outputs = outputs;
1503
+ this.allowedInputNames = [];
1504
+ this.allowedOutputNames = [];
1505
+ const mirror = reflectComponentType(component);
1506
+ if (!mirror) {
1507
+ throw new Error(`[@tanstack-table/angular] The provided symbol is not a component`);
1508
+ }
1509
+ this.mirror = mirror;
1510
+ for (const input of this.mirror.inputs) {
1511
+ this.allowedInputNames.push(input.propName);
1512
+ }
1513
+ for (const output of this.mirror.outputs) {
1514
+ this.allowedOutputNames.push(output.propName);
1515
+ }
1516
+ }
1517
+ }
1518
+
1519
+ class FlexRenderComponentFactory {
1520
+ #viewContainerRef = inject(ViewContainerRef);
1521
+ createComponent(flexRenderComponent, componentInjector) {
1522
+ const componentRef = this.#viewContainerRef.createComponent(flexRenderComponent.component, {
1523
+ injector: componentInjector,
1524
+ });
1525
+ const view = new FlexRenderComponentRef(componentRef, flexRenderComponent, componentInjector);
1526
+ const { inputs, outputs } = flexRenderComponent;
1527
+ if (inputs)
1528
+ view.setInputs(inputs);
1529
+ if (outputs)
1530
+ view.setOutputs(outputs);
1531
+ return view;
1532
+ }
1533
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FlexRenderComponentFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1534
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FlexRenderComponentFactory }); }
1535
+ }
1536
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FlexRenderComponentFactory, decorators: [{
1537
+ type: Injectable
1538
+ }] });
1539
+ class FlexRenderComponentRef {
1540
+ #keyValueDiffersFactory;
1541
+ #componentData;
1542
+ #inputValueDiffer;
1543
+ #outputRegistry;
1544
+ constructor(componentRef, componentData, componentInjector) {
1545
+ this.componentRef = componentRef;
1546
+ this.componentInjector = componentInjector;
1547
+ this.#componentData = componentData;
1548
+ this.#keyValueDiffersFactory = componentInjector.get(KeyValueDiffers);
1549
+ this.#outputRegistry = new FlexRenderComponentOutputManager(this.#keyValueDiffersFactory, this.outputs);
1550
+ this.#inputValueDiffer = this.#keyValueDiffersFactory
1551
+ .find(this.inputs)
1552
+ .create();
1553
+ this.#inputValueDiffer.diff(this.inputs);
1554
+ this.componentRef.onDestroy(() => this.#outputRegistry.unsubscribeAll());
1555
+ }
1556
+ get component() {
1557
+ return this.#componentData.component;
1558
+ }
1559
+ get inputs() {
1560
+ return this.#componentData.inputs ?? {};
1561
+ }
1562
+ get outputs() {
1563
+ return this.#componentData.outputs ?? {};
1564
+ }
1565
+ /**
1566
+ * Get component input and output diff by the given item
1567
+ */
1568
+ diff(item) {
1569
+ return {
1570
+ inputDiff: this.#inputValueDiffer.diff(item.inputs ?? {}),
1571
+ outputDiff: this.#outputRegistry.diff(item.outputs ?? {}),
1572
+ };
1573
+ }
1574
+ /**
1575
+ *
1576
+ * @param compare Whether the current ref component instance is the same as the given one
1577
+ */
1578
+ eqType(compare) {
1579
+ return compare.component === this.component;
1580
+ }
1581
+ /**
1582
+ * Tries to update current component refs input by the new given content component.
1583
+ */
1584
+ update(content) {
1585
+ const eq = this.eqType(content);
1586
+ if (!eq)
1587
+ return;
1588
+ const { inputDiff, outputDiff } = this.diff(content);
1589
+ if (inputDiff) {
1590
+ inputDiff.forEachAddedItem(item => this.setInput(item.key, item.currentValue));
1591
+ inputDiff.forEachChangedItem(item => this.setInput(item.key, item.currentValue));
1592
+ inputDiff.forEachRemovedItem(item => this.setInput(item.key, undefined));
1593
+ }
1594
+ if (outputDiff) {
1595
+ outputDiff.forEachAddedItem(item => {
1596
+ this.setOutput(item.key, item.currentValue);
1597
+ });
1598
+ outputDiff.forEachChangedItem(item => {
1599
+ if (item.currentValue) {
1600
+ this.#outputRegistry.setListener(item.key, item.currentValue);
1601
+ }
1602
+ else {
1603
+ this.#outputRegistry.unsubscribe(item.key);
1604
+ }
1605
+ });
1606
+ outputDiff.forEachRemovedItem(item => {
1607
+ this.#outputRegistry.unsubscribe(item.key);
1608
+ });
1609
+ }
1610
+ this.#componentData = content;
1611
+ }
1612
+ markAsDirty() {
1613
+ this.componentRef.injector.get(ChangeDetectorRef).markForCheck();
1614
+ }
1615
+ setInputs(inputs) {
1616
+ for (const prop in inputs) {
1617
+ this.setInput(prop, inputs[prop]);
1618
+ }
1619
+ }
1620
+ setInput(key, value) {
1621
+ if (this.#componentData.allowedInputNames.includes(key)) {
1622
+ this.componentRef.setInput(key, value);
1623
+ }
1624
+ }
1625
+ setOutputs(outputs) {
1626
+ this.#outputRegistry.unsubscribeAll();
1627
+ for (const prop in outputs) {
1628
+ this.setOutput(prop, outputs[prop]);
1629
+ }
1630
+ }
1631
+ setOutput(outputName, emit) {
1632
+ if (!this.#componentData.allowedOutputNames.includes(outputName))
1633
+ return;
1634
+ if (!emit) {
1635
+ this.#outputRegistry.unsubscribe(outputName);
1636
+ return;
1637
+ }
1638
+ const hasListener = this.#outputRegistry.hasListener(outputName);
1639
+ this.#outputRegistry.setListener(outputName, emit);
1640
+ if (hasListener) {
1641
+ return;
1642
+ }
1643
+ const instance = this.componentRef.instance;
1644
+ const output = instance[outputName];
1645
+ if (output && output instanceof OutputEmitterRef) {
1646
+ output.subscribe(value => {
1647
+ this.#outputRegistry.getListener(outputName)?.(value);
1648
+ });
1649
+ }
1650
+ }
1651
+ }
1652
+ class FlexRenderComponentOutputManager {
1653
+ #outputSubscribers = {};
1654
+ #outputListeners = {};
1655
+ #valueDiffer;
1656
+ constructor(keyValueDiffers, initialOutputs) {
1657
+ this.#valueDiffer = keyValueDiffers.find(initialOutputs).create();
1658
+ if (initialOutputs) {
1659
+ this.#valueDiffer.diff(initialOutputs);
1660
+ }
1661
+ }
1662
+ hasListener(outputName) {
1663
+ return outputName in this.#outputListeners;
1664
+ }
1665
+ setListener(outputName, callback) {
1666
+ this.#outputListeners[outputName] = callback;
1667
+ }
1668
+ getListener(outputName) {
1669
+ return this.#outputListeners[outputName];
1670
+ }
1671
+ unsubscribeAll() {
1672
+ for (const prop in this.#outputSubscribers) {
1673
+ this.unsubscribe(prop);
1674
+ }
1675
+ }
1676
+ unsubscribe(outputName) {
1677
+ if (outputName in this.#outputSubscribers) {
1678
+ this.#outputSubscribers[outputName]?.unsubscribe();
1679
+ delete this.#outputSubscribers[outputName];
1680
+ delete this.#outputListeners[outputName];
1681
+ }
1682
+ }
1683
+ diff(outputs) {
1684
+ return this.#valueDiffer.diff(outputs ?? {});
1685
+ }
1686
+ }
1687
+
1688
+ function mapToFlexRenderTypedContent(content) {
1689
+ if (content === null || content === undefined) {
1690
+ return { kind: 'null' };
1691
+ }
1692
+ if (typeof content === 'string' || typeof content === 'number') {
1693
+ return { kind: 'primitive', content };
1694
+ }
1695
+ if (content instanceof FlexRenderComponent) {
1696
+ return { kind: 'flexRenderComponent', content };
1697
+ }
1698
+ else if (content instanceof TemplateRef) {
1699
+ return { kind: 'templateRef', content };
1700
+ }
1701
+ else if (content instanceof Type) {
1702
+ return { kind: 'component', content };
1703
+ }
1704
+ else {
1705
+ return { kind: 'primitive', content };
1706
+ }
1707
+ }
1708
+ class FlexRenderView {
1709
+ #previousContent;
1710
+ #content;
1711
+ constructor(initialContent, view) {
1712
+ this.#content = initialContent;
1713
+ this.view = view;
1714
+ }
1715
+ get previousContent() {
1716
+ return this.#previousContent ?? { kind: 'null' };
1717
+ }
1718
+ get content() {
1719
+ return this.#content;
1720
+ }
1721
+ set content(content) {
1722
+ this.#previousContent = this.#content;
1723
+ this.#content = content;
1724
+ }
1725
+ }
1726
+ class FlexRenderTemplateView extends FlexRenderView {
1727
+ constructor(initialContent, view) {
1728
+ super(initialContent, view);
1729
+ }
1730
+ updateProps(props) {
1731
+ this.view.markForCheck();
1732
+ }
1733
+ dirtyCheck() {
1734
+ // Basically a no-op. When the view is created via EmbeddedViewRef, we don't need to do any manual update
1735
+ // since this type of content has a proxy as a context, then every time the root component is checked for changes,
1736
+ // the property getter will be re-evaluated.
1737
+ //
1738
+ // If in a future we need to manually mark the view as dirty, just uncomment next line
1739
+ // this.view.markForCheck()
1740
+ }
1741
+ onDestroy(callback) {
1742
+ this.view.onDestroy(callback);
1743
+ }
1744
+ }
1745
+ class FlexRenderComponentView extends FlexRenderView {
1746
+ constructor(initialContent, view) {
1747
+ super(initialContent, view);
1748
+ }
1749
+ updateProps(props) {
1750
+ switch (this.content.kind) {
1751
+ case 'component': {
1752
+ this.view.setInputs(props);
1753
+ break;
1754
+ }
1755
+ case 'flexRenderComponent': {
1756
+ // No-op. When FlexRenderFlags.PropsReferenceChanged is set,
1757
+ // FlexRenderComponent will be updated into `dirtyCheck`.
1758
+ break;
1759
+ }
1760
+ }
1761
+ }
1762
+ dirtyCheck() {
1763
+ switch (this.content.kind) {
1764
+ case 'component': {
1765
+ // Component context is currently valuated with the cell context. Since it's reference
1766
+ // shouldn't change, we force mark the component as dirty in order to re-evaluate function invocation in view.
1767
+ // NOTE: this should behave like having a component with ChangeDetectionStrategy.Default
1768
+ this.view.markAsDirty();
1769
+ break;
1770
+ }
1771
+ case 'flexRenderComponent': {
1772
+ // Given context instance will always have a different reference than the previous one,
1773
+ // so instead of recreating the entire view, we will only update the current view
1774
+ if (this.view.eqType(this.content.content)) {
1775
+ this.view.update(this.content.content);
1776
+ }
1777
+ this.view.markAsDirty();
1778
+ break;
1779
+ }
1780
+ }
1781
+ }
1782
+ onDestroy(callback) {
1783
+ this.view.componentRef.onDestroy(callback);
1784
+ }
1785
+ }
1786
+
1787
+ class FlexRenderDirective {
1788
+ #flexRenderComponentFactory;
1789
+ #changeDetectorRef;
1790
+ #latestContent;
1791
+ #getContentValue;
1792
+ constructor(viewContainerRef, templateRef) {
1793
+ this.viewContainerRef = viewContainerRef;
1794
+ this.templateRef = templateRef;
1795
+ this.#flexRenderComponentFactory = inject(FlexRenderComponentFactory);
1796
+ this.#changeDetectorRef = inject(ChangeDetectorRef);
1797
+ this.content = undefined;
1798
+ this.props = {};
1799
+ this.injector = inject(Injector);
1800
+ this.renderFlags = FlexRenderFlags.ViewFirstRender;
1801
+ this.renderView = null;
1802
+ this.#latestContent = () => {
1803
+ const { content, props } = this;
1804
+ return typeof content !== 'function'
1805
+ ? content
1806
+ : runInInjectionContext(this.injector, () => content(props));
1807
+ };
1808
+ this.#getContentValue = memo(() => [this.#latestContent(), this.props, this.content], latestContent => {
1809
+ return mapToFlexRenderTypedContent(latestContent);
1810
+ }, { key: 'flexRenderContentValue', debug: () => false });
1811
+ this.#currentEffectRef = null;
1812
+ }
1813
+ ngOnChanges(changes) {
1814
+ if (changes['props']) {
1815
+ this.renderFlags |= FlexRenderFlags.PropsReferenceChanged;
1816
+ }
1817
+ if (changes['content']) {
1818
+ this.renderFlags |=
1819
+ FlexRenderFlags.ContentChanged | FlexRenderFlags.ViewFirstRender;
1820
+ this.update();
1821
+ }
1822
+ }
1823
+ ngDoCheck() {
1824
+ if (this.renderFlags & FlexRenderFlags.ViewFirstRender) {
1825
+ // On the initial render, the view is created during the `ngOnChanges` hook.
1826
+ // Since `ngDoCheck` is called immediately afterward, there's no need to check for changes in this phase.
1827
+ this.renderFlags &= ~FlexRenderFlags.ViewFirstRender;
1828
+ return;
1829
+ }
1830
+ this.renderFlags |= FlexRenderFlags.DirtyCheck;
1831
+ const latestContent = this.#getContentValue();
1832
+ if (latestContent.kind === 'null' || !this.renderView) {
1833
+ this.renderFlags |= FlexRenderFlags.ContentChanged;
1834
+ }
1835
+ else {
1836
+ this.renderView.content = latestContent;
1837
+ const { kind: previousKind } = this.renderView.previousContent;
1838
+ if (latestContent.kind !== previousKind) {
1839
+ this.renderFlags |= FlexRenderFlags.ContentChanged;
1840
+ }
1841
+ }
1842
+ this.update();
1843
+ }
1844
+ update() {
1845
+ if (this.renderFlags &
1846
+ (FlexRenderFlags.ContentChanged | FlexRenderFlags.ViewFirstRender)) {
1847
+ this.render();
1848
+ return;
1849
+ }
1850
+ if (this.renderFlags & FlexRenderFlags.PropsReferenceChanged) {
1851
+ if (this.renderView)
1852
+ this.renderView.updateProps(this.props);
1853
+ this.renderFlags &= ~FlexRenderFlags.PropsReferenceChanged;
1854
+ }
1855
+ if (this.renderFlags &
1856
+ (FlexRenderFlags.DirtyCheck | FlexRenderFlags.DirtySignal)) {
1857
+ if (this.renderView)
1858
+ this.renderView.dirtyCheck();
1859
+ this.renderFlags &= ~(FlexRenderFlags.DirtyCheck | FlexRenderFlags.DirtySignal);
1860
+ }
1861
+ }
1862
+ #currentEffectRef;
1863
+ render() {
1864
+ if (this.#shouldRecreateEntireView() && this.#currentEffectRef) {
1865
+ this.#currentEffectRef.destroy();
1866
+ this.#currentEffectRef = null;
1867
+ this.renderFlags &= ~FlexRenderFlags.RenderEffectChecked;
1868
+ }
1869
+ this.viewContainerRef.clear();
1870
+ this.renderFlags =
1871
+ FlexRenderFlags.Pristine |
1872
+ (this.renderFlags & FlexRenderFlags.ViewFirstRender) |
1873
+ (this.renderFlags & FlexRenderFlags.RenderEffectChecked);
1874
+ const resolvedContent = this.#getContentValue();
1875
+ if (resolvedContent.kind === 'null') {
1876
+ this.renderView = null;
1877
+ }
1878
+ else {
1879
+ this.renderView = this.#renderViewByContent(resolvedContent);
1880
+ }
1881
+ // If the content is a function `content(props)`, we initialize an effect
1882
+ // in order to react to changes if the given definition use signals.
1883
+ if (!this.#currentEffectRef && typeof this.content === 'function') {
1884
+ this.#currentEffectRef = effect(() => {
1885
+ this.#latestContent();
1886
+ if (!(this.renderFlags & FlexRenderFlags.RenderEffectChecked)) {
1887
+ this.renderFlags |= FlexRenderFlags.RenderEffectChecked;
1888
+ return;
1889
+ }
1890
+ this.renderFlags |= FlexRenderFlags.DirtySignal;
1891
+ // This will mark the view as changed,
1892
+ // so we'll try to check for updates into ngDoCheck
1893
+ this.#changeDetectorRef.markForCheck();
1894
+ }, { injector: this.viewContainerRef.injector });
1895
+ }
1896
+ }
1897
+ #shouldRecreateEntireView() {
1898
+ return (this.renderFlags &
1899
+ FlexRenderFlags.ContentChanged &
1900
+ FlexRenderFlags.ViewFirstRender);
1901
+ }
1902
+ #renderViewByContent(content) {
1903
+ if (content.kind === 'primitive') {
1904
+ return this.#renderStringContent(content);
1905
+ }
1906
+ else if (content.kind === 'templateRef') {
1907
+ return this.#renderTemplateRefContent(content);
1908
+ }
1909
+ else if (content.kind === 'flexRenderComponent') {
1910
+ return this.#renderComponent(content);
1911
+ }
1912
+ else if (content.kind === 'component') {
1913
+ return this.#renderCustomComponent(content);
1914
+ }
1915
+ else {
1916
+ return null;
1917
+ }
1918
+ }
1919
+ #renderStringContent(template) {
1920
+ const context = () => {
1921
+ return typeof this.content === 'string' ||
1922
+ typeof this.content === 'number'
1923
+ ? this.content
1924
+ : this.content?.(this.props);
1925
+ };
1926
+ const ref = this.viewContainerRef.createEmbeddedView(this.templateRef, {
1927
+ get $implicit() {
1928
+ return context();
1929
+ },
1930
+ });
1931
+ return new FlexRenderTemplateView(template, ref);
1932
+ }
1933
+ #renderTemplateRefContent(template) {
1934
+ const latestContext = () => this.props;
1935
+ const view = this.viewContainerRef.createEmbeddedView(template.content, {
1936
+ get $implicit() {
1937
+ return latestContext();
1938
+ },
1939
+ });
1940
+ return new FlexRenderTemplateView(template, view);
1941
+ }
1942
+ #renderComponent(flexRenderComponent) {
1943
+ const { inputs, outputs, injector } = flexRenderComponent.content;
1944
+ const getContext = () => this.props;
1945
+ const proxy = new Proxy(this.props, {
1946
+ get: (_, key) => getContext()[key],
1947
+ });
1948
+ const componentInjector = Injector.create({
1949
+ parent: injector ?? this.injector,
1950
+ providers: [{ provide: FlexRenderComponentProps, useValue: proxy }],
1951
+ });
1952
+ const view = this.#flexRenderComponentFactory.createComponent(flexRenderComponent.content, componentInjector);
1953
+ return new FlexRenderComponentView(flexRenderComponent, view);
1954
+ }
1955
+ #renderCustomComponent(component) {
1956
+ const view = this.#flexRenderComponentFactory.createComponent(flexRenderComponent(component.content, {
1957
+ inputs: this.props,
1958
+ injector: this.injector,
1959
+ }), this.injector);
1960
+ return new FlexRenderComponentView(component, view);
1961
+ }
1962
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FlexRenderDirective, deps: [{ token: ViewContainerRef }, { token: TemplateRef }], target: i0.ɵɵFactoryTarget.Directive }); }
1963
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: FlexRenderDirective, isStandalone: true, selector: "[flexRender]", inputs: { content: ["flexRender", "content"], props: ["flexRenderProps", "props"], injector: ["flexRenderInjector", "injector"] }, providers: [FlexRenderComponentFactory], usesOnChanges: true, ngImport: i0 }); }
1964
+ }
1965
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FlexRenderDirective, decorators: [{
1966
+ type: Directive,
1967
+ args: [{
1968
+ selector: '[flexRender]',
1969
+ standalone: true,
1970
+ providers: [FlexRenderComponentFactory],
1971
+ }]
1972
+ }], ctorParameters: () => [{ type: i0.ViewContainerRef, decorators: [{
1973
+ type: Inject,
1974
+ args: [ViewContainerRef]
1975
+ }] }, { type: i0.TemplateRef, decorators: [{
1976
+ type: Inject,
1977
+ args: [TemplateRef]
1978
+ }] }], propDecorators: { content: [{
1979
+ type: Input,
1980
+ args: [{ required: true, alias: 'flexRender' }]
1981
+ }], props: [{
1982
+ type: Input,
1983
+ args: [{ required: true, alias: 'flexRenderProps' }]
1984
+ }], injector: [{
1985
+ type: Input,
1986
+ args: [{ required: false, alias: 'flexRenderInjector' }]
1987
+ }] } });
1988
+
1989
+ function createAngularTable(options) {
1990
+ return lazyInit(() => {
1991
+ const resolvedOptions = {
1992
+ state: {},
1993
+ onStateChange: () => { },
1994
+ renderFallbackValue: null,
1995
+ ...options(),
1996
+ };
1997
+ const table = createTable(resolvedOptions);
1998
+ // By default, manage table state here using the table's initial state
1999
+ const state = signal(table.initialState);
2000
+ // Compose table options using computed.
2001
+ // This is to allow `tableSignal` to listen and set table option
2002
+ const updatedOptions = computed(() => {
2003
+ // listen to table state changed
2004
+ const tableState = state();
2005
+ // listen to input options changed
2006
+ const tableOptions = options();
2007
+ return {
2008
+ ...table.options,
2009
+ ...resolvedOptions,
2010
+ ...tableOptions,
2011
+ state: { ...tableState, ...tableOptions.state },
2012
+ onStateChange: updater => {
2013
+ const value = updater instanceof Function ? updater(tableState) : updater;
2014
+ state.set(value);
2015
+ resolvedOptions.onStateChange?.(updater);
2016
+ },
2017
+ };
2018
+ });
2019
+ // convert table instance to signal for proxify to listen to any table state and options changes
2020
+ const tableSignal = computed(() => {
2021
+ table.setOptions(updatedOptions());
2022
+ return table;
2023
+ }, {
2024
+ equal: () => false,
2025
+ });
2026
+ // proxify Table instance to provide ability for consumer to listen to any table state changes
2027
+ return proxifyTable(tableSignal);
2028
+ });
2029
+ }
2030
+
2031
+ /* eslint-disable jsdoc/require-jsdoc */
2032
+ /* eslint-disable jsdoc/require-returns */
2033
+ /**
2034
+ * Nova Datatable built on TanStack Table (Angular).
2035
+ */
2036
+ class NvDatatable {
2037
+ constructor() {
2038
+ /** Column definitions */
2039
+ this.columns = input([]);
2040
+ /** Row data */
2041
+ this.rows = input([]);
2042
+ /** Computed table columns with proper typing and filtering. */
2043
+ this.tableColumns = computed(() => this.columns()
2044
+ .filter((col) => !col.hidden)
2045
+ .map((col) => ({
2046
+ accessorKey: col.field,
2047
+ header: col.headerName || String(col.field),
2048
+ size: col.width,
2049
+ enableResizing: col.resizable ?? true,
2050
+ cell: col.renderCell ??
2051
+ ((context) => context.getValue()),
2052
+ })));
2053
+ /** TanStack table instance with Signals */
2054
+ this.tableInstance = createAngularTable(() => ({
2055
+ data: this.rows(),
2056
+ columns: this.tableColumns(),
2057
+ getCoreRowModel: getCoreRowModel(),
2058
+ }));
2059
+ }
2060
+ /** Public getter for table instance. */
2061
+ table() {
2062
+ return this.tableInstance();
2063
+ }
2064
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvDatatable, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
2065
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: NvDatatable, isStandalone: true, selector: "nv-datatable", inputs: { columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
2066
+ <nv-table>
2067
+ <table>
2068
+ <thead>
2069
+ @for (headerGroup of table().getHeaderGroups(); track headerGroup.id)
2070
+ {
2071
+ <tr>
2072
+ @for (header of headerGroup.headers; track header.id) {
2073
+ <th
2074
+ [attr.data-testid]="'datatable-header-' + header.id"
2075
+ [style.width]="
2076
+ header.column.columnDef.size
2077
+ ? header.column.columnDef.size + 'px'
2078
+ : null
2079
+ "
2080
+ [attr.data-no-resize]="
2081
+ !header.column.columnDef.enableResizing ? 'true' : null
2082
+ "
2083
+ >
2084
+ @if (!header.isPlaceholder) {
2085
+ {{ header.column.columnDef.header }}
2086
+ }
2087
+ </th>
2088
+ }
2089
+ </tr>
2090
+ }
2091
+ </thead>
2092
+
2093
+ <tbody>
2094
+ @for (row of table().getRowModel().rows; track row.id) {
2095
+ <tr [attr.data-testid]="'datatable-row-' + row.id">
2096
+ @for (cell of row.getVisibleCells(); track cell.id) {
2097
+ <td
2098
+ [attr.data-testid]="'datatable-cell-' + cell.id"
2099
+ style="padding: 8px; border-bottom: 1px solid #eee;"
2100
+ >
2101
+ <!-- Let FlexRender handle strings vs TemplateRef -->
2102
+ <ng-container
2103
+ *flexRender="
2104
+ cell.column.columnDef.cell;
2105
+ props: cell.getContext();
2106
+ let cellContent
2107
+ "
2108
+ >
2109
+ {{ cellContent }}
2110
+ </ng-container>
2111
+ </td>
2112
+ }
2113
+ </tr>
2114
+ }
2115
+ </tbody>
2116
+ </table>
2117
+ </nv-table>
2118
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: FlexRenderDirective, selector: "[flexRender]", inputs: ["flexRender", "flexRenderProps", "flexRenderInjector"] }] }); }
2119
+ }
2120
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvDatatable, decorators: [{
2121
+ type: Component,
2122
+ args: [{
2123
+ selector: 'nv-datatable',
2124
+ standalone: true,
2125
+ imports: [CommonModule, FlexRenderDirective],
2126
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
2127
+ template: `
2128
+ <nv-table>
2129
+ <table>
2130
+ <thead>
2131
+ @for (headerGroup of table().getHeaderGroups(); track headerGroup.id)
2132
+ {
2133
+ <tr>
2134
+ @for (header of headerGroup.headers; track header.id) {
2135
+ <th
2136
+ [attr.data-testid]="'datatable-header-' + header.id"
2137
+ [style.width]="
2138
+ header.column.columnDef.size
2139
+ ? header.column.columnDef.size + 'px'
2140
+ : null
2141
+ "
2142
+ [attr.data-no-resize]="
2143
+ !header.column.columnDef.enableResizing ? 'true' : null
2144
+ "
2145
+ >
2146
+ @if (!header.isPlaceholder) {
2147
+ {{ header.column.columnDef.header }}
2148
+ }
2149
+ </th>
2150
+ }
2151
+ </tr>
2152
+ }
2153
+ </thead>
2154
+
2155
+ <tbody>
2156
+ @for (row of table().getRowModel().rows; track row.id) {
2157
+ <tr [attr.data-testid]="'datatable-row-' + row.id">
2158
+ @for (cell of row.getVisibleCells(); track cell.id) {
2159
+ <td
2160
+ [attr.data-testid]="'datatable-cell-' + cell.id"
2161
+ style="padding: 8px; border-bottom: 1px solid #eee;"
2162
+ >
2163
+ <!-- Let FlexRender handle strings vs TemplateRef -->
2164
+ <ng-container
2165
+ *flexRender="
2166
+ cell.column.columnDef.cell;
2167
+ props: cell.getContext();
2168
+ let cellContent
2169
+ "
2170
+ >
2171
+ {{ cellContent }}
2172
+ </ng-container>
2173
+ </td>
2174
+ }
2175
+ </tr>
2176
+ }
2177
+ </tbody>
2178
+ </table>
2179
+ </nv-table>
2180
+ `,
2181
+ }]
2182
+ }] });
2183
+
1306
2184
  class ValueAccessor {
1307
2185
  constructor(el) {
1308
2186
  this.el = el;
@@ -1342,6 +2220,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
1342
2220
  args: ['focusout']
1343
2221
  }] } });
1344
2222
 
2223
+ class NvAccordionValueAccessor extends ValueAccessor {
2224
+ constructor(el) {
2225
+ super(el);
2226
+ }
2227
+ handleOpenIndexesChanged(event) {
2228
+ this.handleChangeEvent(event.target.openIndexes);
2229
+ }
2230
+ writeValue(value) {
2231
+ this.el.nativeElement.openIndexes = this.lastValue = value;
2232
+ }
2233
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvAccordionValueAccessor, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive }); }
2234
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: NvAccordionValueAccessor, selector: "nv-accordion", host: { listeners: { "openIndexesChanged": "handleOpenIndexesChanged($event)" } }, providers: [
2235
+ {
2236
+ provide: NG_VALUE_ACCESSOR,
2237
+ useExisting: NvAccordionValueAccessor,
2238
+ multi: true,
2239
+ },
2240
+ ], usesInheritance: true, ngImport: i0 }); }
2241
+ }
2242
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NvAccordionValueAccessor, decorators: [{
2243
+ type: Directive,
2244
+ args: [{
2245
+ selector: 'nv-accordion',
2246
+ providers: [
2247
+ {
2248
+ provide: NG_VALUE_ACCESSOR,
2249
+ useExisting: NvAccordionValueAccessor,
2250
+ multi: true,
2251
+ },
2252
+ ],
2253
+ }]
2254
+ }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { handleOpenIndexesChanged: [{
2255
+ type: HostListener,
2256
+ args: ['openIndexesChanged', ['$event']]
2257
+ }] } });
1345
2258
  class NvAlertValueAccessor extends ValueAccessor {
1346
2259
  constructor(el) {
1347
2260
  super(el);
@@ -2043,6 +2956,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
2043
2956
  args: ['valueChanged', ['$event']]
2044
2957
  }] } });
2045
2958
  const VALUE_ACCESSORS = [
2959
+ NvAccordionValueAccessor,
2046
2960
  NvAlertValueAccessor,
2047
2961
  NvCalendarValueAccessor,
2048
2962
  NvDatagridValueAccessor,
@@ -2079,20 +2993,21 @@ function provideNovaComponents() {
2079
2993
  }
2080
2994
  class NovaComponentsModule {
2081
2995
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2082
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsModule, declarations: [NvAccordion, NvAccordionItem, NvAlert, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCol, NvDatagrid, NvDatagridcolumn, NvDialog, NvDialogfooter, NvDialogheader, NvFieldcheckbox, NvFielddate, NvFielddaterange, NvFielddropdown, NvFielddropdownitem, NvFielddropdownitemcheck, NvFieldmultiselect, NvFieldnumber, NvFieldpassword, NvFieldradio, NvFieldselect, NvFieldslider, NvFieldtext, NvFieldtextarea, NvFieldtime, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvPopover, NvRow, NvStack, NvTable, NvTablecolumn, NvToggle, NvTogglebutton, NvTogglebuttongroup, NvTooltip], exports: [NvAccordion, NvAccordionItem, NvAlert, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCol, NvDatagrid, NvDatagridcolumn, NvDialog, NvDialogfooter, NvDialogheader, NvFieldcheckbox, NvFielddate, NvFielddaterange, NvFielddropdown, NvFielddropdownitem, NvFielddropdownitemcheck, NvFieldmultiselect, NvFieldnumber, NvFieldpassword, NvFieldradio, NvFieldselect, NvFieldslider, NvFieldtext, NvFieldtextarea, NvFieldtime, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvPopover, NvRow, NvStack, NvTable, NvTablecolumn, NvToggle, NvTogglebutton, NvTogglebuttongroup, NvTooltip] }); }
2083
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsModule, providers: [provideNovaComponents()] }); }
2996
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsModule, declarations: [NvAccordion, NvAccordionItem, NvAlert, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCol, NvDatagrid, NvDatagridcolumn, NvDialog, NvDialogfooter, NvDialogheader, NvFieldcheckbox, NvFielddate, NvFielddaterange, NvFielddropdown, NvFielddropdownitem, NvFielddropdownitemcheck, NvFieldmultiselect, NvFieldnumber, NvFieldpassword, NvFieldradio, NvFieldselect, NvFieldslider, NvFieldtext, NvFieldtextarea, NvFieldtime, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvNotificationcontainer, NvPopover, NvRow, NvStack, NvTable, NvToggle, NvTogglebutton, NvTogglebuttongroup, NvTooltip], imports: [NvDatatable], exports: [NvAccordion, NvAccordionItem, NvAlert, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCol, NvDatagrid, NvDatagridcolumn, NvDialog, NvDialogfooter, NvDialogheader, NvFieldcheckbox, NvFielddate, NvFielddaterange, NvFielddropdown, NvFielddropdownitem, NvFielddropdownitemcheck, NvFieldmultiselect, NvFieldnumber, NvFieldpassword, NvFieldradio, NvFieldselect, NvFieldslider, NvFieldtext, NvFieldtextarea, NvFieldtime, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvNotificationcontainer, NvPopover, NvRow, NvStack, NvTable, NvToggle, NvTogglebutton, NvTogglebuttongroup, NvTooltip, NvDatatable] }); }
2997
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsModule, providers: [provideNovaComponents()], imports: [NvDatatable] }); }
2084
2998
  }
2085
2999
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsModule, decorators: [{
2086
3000
  type: NgModule,
2087
3001
  args: [{
3002
+ imports: [NvDatatable],
2088
3003
  declarations: [...DIRECTIVES],
2089
- exports: [...DIRECTIVES],
3004
+ exports: [...DIRECTIVES, NvDatatable],
2090
3005
  providers: [provideNovaComponents()],
2091
3006
  }]
2092
3007
  }] });
2093
3008
  class NovaComponentsValueAccessorModule {
2094
3009
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsValueAccessorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2095
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsValueAccessorModule, declarations: [NvAlertValueAccessor, NvCalendarValueAccessor, NvDatagridValueAccessor, NvDialogValueAccessor, NvFieldcheckboxValueAccessor, NvFielddateValueAccessor, NvFielddaterangeValueAccessor, NvFielddropdownValueAccessor, NvFieldmultiselectValueAccessor, NvFieldnumberValueAccessor, NvFieldpasswordValueAccessor, NvFieldradioValueAccessor, NvFieldselectValueAccessor, NvFieldsliderValueAccessor, NvFieldtextValueAccessor, NvFieldtextareaValueAccessor, NvNotificationValueAccessor, NvPopoverValueAccessor, NvToggleValueAccessor, NvTogglebuttongroupValueAccessor], exports: [NvAlertValueAccessor, NvCalendarValueAccessor, NvDatagridValueAccessor, NvDialogValueAccessor, NvFieldcheckboxValueAccessor, NvFielddateValueAccessor, NvFielddaterangeValueAccessor, NvFielddropdownValueAccessor, NvFieldmultiselectValueAccessor, NvFieldnumberValueAccessor, NvFieldpasswordValueAccessor, NvFieldradioValueAccessor, NvFieldselectValueAccessor, NvFieldsliderValueAccessor, NvFieldtextValueAccessor, NvFieldtextareaValueAccessor, NvNotificationValueAccessor, NvPopoverValueAccessor, NvToggleValueAccessor, NvTogglebuttongroupValueAccessor] }); }
3010
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsValueAccessorModule, declarations: [NvAccordionValueAccessor, NvAlertValueAccessor, NvCalendarValueAccessor, NvDatagridValueAccessor, NvDialogValueAccessor, NvFieldcheckboxValueAccessor, NvFielddateValueAccessor, NvFielddaterangeValueAccessor, NvFielddropdownValueAccessor, NvFieldmultiselectValueAccessor, NvFieldnumberValueAccessor, NvFieldpasswordValueAccessor, NvFieldradioValueAccessor, NvFieldselectValueAccessor, NvFieldsliderValueAccessor, NvFieldtextValueAccessor, NvFieldtextareaValueAccessor, NvNotificationValueAccessor, NvPopoverValueAccessor, NvToggleValueAccessor, NvTogglebuttongroupValueAccessor], exports: [NvAccordionValueAccessor, NvAlertValueAccessor, NvCalendarValueAccessor, NvDatagridValueAccessor, NvDialogValueAccessor, NvFieldcheckboxValueAccessor, NvFielddateValueAccessor, NvFielddaterangeValueAccessor, NvFielddropdownValueAccessor, NvFieldmultiselectValueAccessor, NvFieldnumberValueAccessor, NvFieldpasswordValueAccessor, NvFieldradioValueAccessor, NvFieldselectValueAccessor, NvFieldsliderValueAccessor, NvFieldtextValueAccessor, NvFieldtextareaValueAccessor, NvNotificationValueAccessor, NvPopoverValueAccessor, NvToggleValueAccessor, NvTogglebuttongroupValueAccessor] }); }
2096
3011
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsValueAccessorModule }); }
2097
3012
  }
2098
3013
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NovaComponentsValueAccessorModule, decorators: [{
@@ -2103,6 +3018,315 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
2103
3018
  }]
2104
3019
  }] });
2105
3020
 
3021
+ /**
3022
+ * Utility function to generate unique IDs.
3023
+ *
3024
+ * @returns {string} A unique identifier string
3025
+ */
3026
+ const generateId = () => {
3027
+ return `notification-${Date.now()}-${Math.random()
3028
+ .toString(36)
3029
+ .substr(2, 9)}`;
3030
+ };
3031
+ /**
3032
+ * Angular service for managing notifications.
3033
+ */
3034
+ class NotificationService {
3035
+ /**
3036
+ * Current array of notifications.
3037
+ *
3038
+ * @returns {Notification[]} Array of active notifications
3039
+ */
3040
+ get notifications() {
3041
+ return this._notifications.value;
3042
+ }
3043
+ constructor() {
3044
+ this._notifications = new BehaviorSubject([]);
3045
+ /**
3046
+ * Observable stream of active notifications.
3047
+ */
3048
+ this.notifications$ = this._notifications.asObservable();
3049
+ // keep track of all notification refs
3050
+ this.elRefs = new Map();
3051
+ this._config = {
3052
+ position: 'top-right',
3053
+ maxNotifications: 50,
3054
+ className: '',
3055
+ };
3056
+ }
3057
+ /**
3058
+ * Configure the notification service.
3059
+ *
3060
+ * @param {NotificationServiceConfig} config Configuration options
3061
+ */
3062
+ configure(config) {
3063
+ Object.assign(this._config, config);
3064
+ }
3065
+ /**
3066
+ * Get the current configuration.
3067
+ *
3068
+ * @returns {Required<NotificationServiceConfig>} Current configuration
3069
+ */
3070
+ get config() {
3071
+ return { ...this._config };
3072
+ }
3073
+ registerRef(id, el) {
3074
+ this.elRefs.set(id, el);
3075
+ }
3076
+ unregisterRef(id) {
3077
+ this.elRefs.delete(id);
3078
+ }
3079
+ clearRefs() {
3080
+ this.elRefs.clear();
3081
+ }
3082
+ /**
3083
+ * Show a new notification.
3084
+ *
3085
+ * @param {NotificationOptions} options The notification options
3086
+ * @returns {string} The notification ID
3087
+ */
3088
+ show(options) {
3089
+ const id = options.id || generateId();
3090
+ const notification = {
3091
+ id,
3092
+ heading: options.heading,
3093
+ message: options.message,
3094
+ dismissible: options.dismissible ?? true,
3095
+ emphasis: options.emphasis ?? 'medium',
3096
+ feedback: options.feedback ?? 'information',
3097
+ icon: options.icon,
3098
+ actions: options.actions ?? [],
3099
+ actionSlot: options.actionSlot,
3100
+ createdAt: Date.now(),
3101
+ };
3102
+ const currentNotifications = this._notifications.value;
3103
+ // Remove oldest notifications if we exceed max
3104
+ const newNotifications = [notification, ...currentNotifications];
3105
+ if (newNotifications.length > this._config.maxNotifications) {
3106
+ this._notifications.next(newNotifications.slice(0, this._config.maxNotifications));
3107
+ }
3108
+ else {
3109
+ this._notifications.next(newNotifications);
3110
+ }
3111
+ setTimeout(() => {
3112
+ const ref = this.elRefs.get(id);
3113
+ ref?.show();
3114
+ }, 0);
3115
+ return id;
3116
+ }
3117
+ /**
3118
+ * Dismiss a specific notification by ID. This will remove the notification
3119
+ * after the animation completes.
3120
+ *
3121
+ * @param {string} id The notification ID to dismiss
3122
+ */
3123
+ dismiss(id) {
3124
+ this.elRefs.get(id)?.dismiss?.();
3125
+ }
3126
+ /**
3127
+ * Immediately remove a specific notification by ID.
3128
+ *
3129
+ * @param {string} id The notification ID to dismiss
3130
+ */
3131
+ remove(id) {
3132
+ const currentNotifications = this._notifications.value;
3133
+ const filteredNotifications = currentNotifications.filter((notification) => notification.id !== id);
3134
+ this._notifications.next(filteredNotifications);
3135
+ }
3136
+ /**
3137
+ * Immediately remove all active notifications.
3138
+ */
3139
+ removeAll() {
3140
+ this._notifications.next([]);
3141
+ }
3142
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NotificationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
3143
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NotificationService, providedIn: 'root' }); }
3144
+ }
3145
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NotificationService, decorators: [{
3146
+ type: Injectable,
3147
+ args: [{
3148
+ providedIn: 'root',
3149
+ }]
3150
+ }], ctorParameters: () => [] });
3151
+
3152
+ /**
3153
+ * Angular component that renders the notification container with active notifications.
3154
+ */
3155
+ class NotificationServiceComponent {
3156
+ constructor(notificationService) {
3157
+ this.notificationService = notificationService;
3158
+ /**
3159
+ * Array of active notifications.
3160
+ */
3161
+ this.notifications = [];
3162
+ }
3163
+ /**
3164
+ * Component initialization.
3165
+ */
3166
+ ngOnInit() {
3167
+ // Use service config if no input provided
3168
+ this.position ??= this.notificationService.config.position;
3169
+ this.className ??= this.notificationService.config.className;
3170
+ // Subscribe to notification changes
3171
+ this.subscription = this.notificationService.notifications$.subscribe((list) => (this.notifications = list));
3172
+ }
3173
+ /**
3174
+ * Synchronize notification elements/refs with the service.
3175
+ */
3176
+ ngAfterViewInit() {
3177
+ const sync = () => {
3178
+ this.notificationService.clearRefs();
3179
+ for (const elRef of this.notificationEls.toArray()) {
3180
+ const el = elRef.nativeElement;
3181
+ const id = el.getAttribute('data-id');
3182
+ if (id)
3183
+ this.notificationService.registerRef(id, el);
3184
+ }
3185
+ };
3186
+ sync();
3187
+ this.notificationEls.changes.subscribe(sync);
3188
+ }
3189
+ /**
3190
+ * Component cleanup.
3191
+ */
3192
+ ngOnDestroy() {
3193
+ this.subscription?.unsubscribe();
3194
+ this.notificationService.clearRefs();
3195
+ }
3196
+ /**
3197
+ * Track function for ngFor to optimize rendering.
3198
+ *
3199
+ * @param {number} index The index of the item
3200
+ * @param {Notification} notification The notification item
3201
+ * @returns {string} The notification ID
3202
+ */
3203
+ trackByNotificationId(index, notification) {
3204
+ return notification.id;
3205
+ }
3206
+ /**
3207
+ * Handle notification hidden state change.
3208
+ *
3209
+ * @param {CustomEvent<boolean>} event The hidden changed event
3210
+ * @param {string} id The notification ID
3211
+ */
3212
+ handleHiddenChanged(event, id) {
3213
+ if (event.detail && id) {
3214
+ this.notificationService.remove(id);
3215
+ }
3216
+ }
3217
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NotificationServiceComponent, deps: [{ token: NotificationService }], target: i0.ɵɵFactoryTarget.Component }); }
3218
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NotificationServiceComponent, isStandalone: true, selector: "nv-notification-service", inputs: { position: "position", className: "className" }, viewQueries: [{ propertyName: "notificationEls", predicate: ["notificationEl"], descendants: true, read: ElementRef }], ngImport: i0, template: `
3219
+ <nv-notificationcontainer
3220
+ [position]="position"
3221
+ [class]="className"
3222
+ data-testid="notification-container"
3223
+ >
3224
+ <nv-notification
3225
+ *ngFor="
3226
+ let notification of notifications;
3227
+ trackBy: trackByNotificationId
3228
+ "
3229
+ #notificationEl
3230
+ [attr.data-id]="notification.id"
3231
+ [heading]="notification.heading"
3232
+ [message]="notification.message"
3233
+ [dismissible]="notification.dismissible"
3234
+ [emphasis]="notification.emphasis"
3235
+ [feedback]="notification.feedback"
3236
+ [icon]="notification.icon"
3237
+ [initiallyHidden]="true"
3238
+ (hiddenChanged)="handleHiddenChanged($event, notification.id)"
3239
+ >
3240
+ <!-- Actions slot content for the custom element -->
3241
+ <div
3242
+ slot="actions"
3243
+ class="flex gap-2"
3244
+ *ngIf="notification.actions?.length || notification.actionSlot"
3245
+ >
3246
+ <!-- Config-driven actions -->
3247
+ <nv-button
3248
+ *ngFor="let action of notification.actions"
3249
+ emphasis="low"
3250
+ size="sm"
3251
+ (click)="action.onClick()"
3252
+ >
3253
+ {{ action.label }}
3254
+ </nv-button>
3255
+
3256
+ <!-- Component-driven actions -->
3257
+ <ng-container
3258
+ *ngIf="notification.actionSlot"
3259
+ [ngComponentOutlet]="notification.actionSlot"
3260
+ ></ng-container>
3261
+ </div>
3262
+ </nv-notification>
3263
+ </nv-notificationcontainer>
3264
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] }); }
3265
+ }
3266
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NotificationServiceComponent, decorators: [{
3267
+ type: Component,
3268
+ args: [{
3269
+ selector: 'nv-notification-service',
3270
+ standalone: true,
3271
+ imports: [CommonModule],
3272
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
3273
+ template: `
3274
+ <nv-notificationcontainer
3275
+ [position]="position"
3276
+ [class]="className"
3277
+ data-testid="notification-container"
3278
+ >
3279
+ <nv-notification
3280
+ *ngFor="
3281
+ let notification of notifications;
3282
+ trackBy: trackByNotificationId
3283
+ "
3284
+ #notificationEl
3285
+ [attr.data-id]="notification.id"
3286
+ [heading]="notification.heading"
3287
+ [message]="notification.message"
3288
+ [dismissible]="notification.dismissible"
3289
+ [emphasis]="notification.emphasis"
3290
+ [feedback]="notification.feedback"
3291
+ [icon]="notification.icon"
3292
+ [initiallyHidden]="true"
3293
+ (hiddenChanged)="handleHiddenChanged($event, notification.id)"
3294
+ >
3295
+ <!-- Actions slot content for the custom element -->
3296
+ <div
3297
+ slot="actions"
3298
+ class="flex gap-2"
3299
+ *ngIf="notification.actions?.length || notification.actionSlot"
3300
+ >
3301
+ <!-- Config-driven actions -->
3302
+ <nv-button
3303
+ *ngFor="let action of notification.actions"
3304
+ emphasis="low"
3305
+ size="sm"
3306
+ (click)="action.onClick()"
3307
+ >
3308
+ {{ action.label }}
3309
+ </nv-button>
3310
+
3311
+ <!-- Component-driven actions -->
3312
+ <ng-container
3313
+ *ngIf="notification.actionSlot"
3314
+ [ngComponentOutlet]="notification.actionSlot"
3315
+ ></ng-container>
3316
+ </div>
3317
+ </nv-notification>
3318
+ </nv-notificationcontainer>
3319
+ `,
3320
+ }]
3321
+ }], ctorParameters: () => [{ type: NotificationService }], propDecorators: { position: [{
3322
+ type: Input
3323
+ }], className: [{
3324
+ type: Input
3325
+ }], notificationEls: [{
3326
+ type: ViewChildren,
3327
+ args: ['notificationEl', { read: ElementRef }]
3328
+ }] } });
3329
+
2106
3330
  /*
2107
3331
  * Public API Surface of nova-components
2108
3332
  */
@@ -2111,5 +3335,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
2111
3335
  * Generated bundle index. Do not edit.
2112
3336
  */
2113
3337
 
2114
- export { NovaComponentsModule, NovaComponentsValueAccessorModule, NvAccordion, NvAccordionItem, NvAlert, NvAlertValueAccessor, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCalendarValueAccessor, NvCol, NvDatagrid, NvDatagridValueAccessor, NvDatagridcolumn, 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, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvNotificationValueAccessor, NvPopover, NvPopoverValueAccessor, NvRow, NvStack, NvTable, NvTablecolumn, NvToggle, NvToggleValueAccessor, NvTogglebutton, NvTogglebuttongroup, NvTogglebuttongroupValueAccessor, NvTooltip, VALUE_ACCESSORS, provideNovaComponents };
3338
+ export { NotificationService, NotificationServiceComponent, NovaComponentsModule, NovaComponentsValueAccessorModule, NvAccordion, NvAccordionItem, NvAccordionValueAccessor, NvAlert, NvAlertValueAccessor, NvAvatar, NvBadge, NvBreadcrumb, NvBreadcrumbs, NvButton, NvButtongroup, NvCalendar, NvCalendarValueAccessor, NvCol, NvDatagrid, NvDatagridValueAccessor, NvDatagridcolumn, NvDatatable, 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, NvIcon, NvIconbutton, NvLoader, NvMenu, NvMenuitem, NvNotification, NvNotificationValueAccessor, NvNotificationcontainer, NvPopover, NvPopoverValueAccessor, NvRow, NvStack, NvTable, NvToggle, NvToggleValueAccessor, NvTogglebutton, NvTogglebuttongroup, NvTogglebuttongroupValueAccessor, NvTooltip, VALUE_ACCESSORS, flexRenderComponent as nvDatatableRenderComponent, provideNovaComponents };
2115
3339
  //# sourceMappingURL=nova-components.mjs.map