@dsivd/prestations-ng 19.2.0-beta.3 → 19.2.0-beta.4

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.
package/CHANGELOG.md CHANGED
@@ -13,6 +13,15 @@
13
13
  Library now runs as strict mode, which may cause some errors to appear in your project after updating.
14
14
  Please check the [UPGRADING_V19.md](UPGRADING_V19.md) guide for more information.
15
15
 
16
+ - [foehn-list-summary.component.ts](projects/prestations-ng/src/foehn-menu-prestation/foehn-list-summary/foehn-list-summary.component.ts)
17
+ - `FoehnListSummaryComponent` is now generic: `FoehnListSummaryComponent<T extends FoehnListItem>`,
18
+ so the model, `getListItemTitle` and `listItemDescriptions` are typed with your own item class
19
+ instead of the base `FoehnListItem`
20
+ - [foehn-list-item-description.ts](projects/prestations-ng/src/foehn-menu-prestation/foehn-list-summary/foehn-list-item-description.ts)
21
+ - 🚨 `FoehnListItemDescription` now takes a type parameter: `FoehnListItemDescription<T>`.
22
+ `getFormattedValue(item: T)` and `hideIfEmpty(item: T)` receive your item type directly, no cast needed.
23
+ Replace `FoehnListItemDescription[]` with `FoehnListItemDescription<MyItem>[]` in your project.
24
+
16
25
  ## [19.1.1]
17
26
 
18
27
  ### Fixed
package/UPGRADING_V19.md CHANGED
@@ -1449,6 +1449,42 @@ npm run test
1449
1449
  npm start
1450
1450
  ```
1451
1451
 
1452
+ ### `foehn-list-summary` is now generic (since 19.2.0)
1453
+
1454
+ `FoehnListSummaryComponent` is now `FoehnListSummaryComponent<T extends FoehnListItem>` and `FoehnListItemDescription` now takes a type parameter: `FoehnListItemDescription<T>`.
1455
+ Using `FoehnListItemDescription` without its type parameter no longer compiles.
1456
+
1457
+ Replace every `FoehnListItemDescription` with `FoehnListItemDescription<MyItem>`, where `MyItem` is your class extending `FoehnListItem`. You can then drop the casts (or `any`) in `getFormattedValue` and `hideIfEmpty`:
1458
+
1459
+ Before:
1460
+
1461
+ ```typescript
1462
+ getListItemsDescription(): FoehnListItemDescription[] {
1463
+ return [
1464
+ {
1465
+ label: 'Name',
1466
+ getFormattedValue: (item: FoehnListItem) =>
1467
+ (item as MyItem).name ?? '',
1468
+ },
1469
+ ];
1470
+ }
1471
+ ```
1472
+
1473
+ After:
1474
+
1475
+ ```typescript
1476
+ getListItemsDescription(): FoehnListItemDescription<MyItem>[] {
1477
+ return [
1478
+ {
1479
+ label: 'Name',
1480
+ getFormattedValue: (item: MyItem) => item.name ?? '',
1481
+ },
1482
+ ];
1483
+ }
1484
+ ```
1485
+
1486
+ The same applies to the function passed to `getListItemTitle`, which now receives a `MyItem`.
1487
+
1452
1488
  ### Last but not least, check if your application is working!!!
1453
1489
 
1454
1490
  #### Be sure your application gets a fresh start