@dsivd/prestations-ng 19.2.0-beta.2 → 19.2.0-beta.20

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
@@ -8,11 +8,294 @@
8
8
 
9
9
  ## [19.2.0] - should be aligned with prestations-be 19.2.x
10
10
 
11
+ ### Added
12
+
13
+ - [foehn-date-model.type.ts](projects/prestations-ng/src/foehn-input-date/foehn-date-model.type.ts)
14
+ - New `FoehnDateModel` type, the model of `foehn-input-date` (`(number | null)[]`, the JSON of a
15
+ `LenientLocalDate` of prestations-be), to type the date fields of your forms, e.g.
16
+ `birthDate: FoehnDateModel | null = null;`.
17
+ - [eslint/configs/spec-ts-recommended.mjs](projects/prestations-ng/src/eslint/configs/spec-ts-recommended.mjs)
18
+ - New `prestationsNg.configs.specTsRecommended` ESLint config for the Vitest specs, to use in the `extends` of a
19
+ `**/*.spec.ts` block: the `recommended` config of `@vitest/eslint-plugin`, which also counts the assertions of
20
+ the `HttpTestingController` and of the helpers of the specs. It needs `@vitest/eslint-plugin` in the
21
+ devDependencies of your project, only when you use it: 1.6.27 with the TypeScript 5.9 of Angular 21, later
22
+ versions need TypeScript 6. See
23
+ [UPGRADING_V19.md](UPGRADING_V19.md#migrate-to-eslint-flat-configuration).
24
+ - [foehn-bo-multi-upload.component.ts](projects/prestations-ng/src/foehn-upload/foehn-bo-multi-upload/foehn-bo-multi-upload.component.ts)
25
+ - New `localUpload` input. When set to `true`, selected files are kept purely local
26
+ (as `DocumentReferenceWithFile`, no `uploadUrl()` call) so they can be cancelled before
27
+ being sent. Files show up immediately in the list with a "pending" indicator (dictionary
28
+ key `foehn-uploader.pending-label`, French default provided) since they're not uploaded
29
+ yet. It is your responsibility to upload/delete them at save time,
30
+ e.g. via the new
31
+ [document-changes.helper.ts](projects/prestations-ng/src/foehn-upload/document-changes.helper.ts)
32
+ (`splitDocumentChanges`) which computes `filesToAdd`/`documentsToDelete` from the model.
33
+ - The default (direct upload) mode is unchanged.
34
+ - New `maxFileSizeInMo` input: a client-side, per-file size limit that doesn't depend on
35
+ the `fileMaxSizeInBytesByFormKey` server configuration (useful for consumers that don't
36
+ expose that config yet). When both are set, the smallest limit applies. A file too big gets
37
+ the usual `413` error, which can be customized with `customErrors` (`{fileName}`,
38
+ `{fileMaxSize}`).
39
+ - New `chooseButtonStyleModifier` input, appended to the choose button's CSS classes
40
+ (e.g. `btn-sm`), mirroring the same input already available on other uploaders.
41
+
42
+ - [foehn-input-address.component.ts](projects/prestations-ng/src/foehn-address/foehn-input-address.component.ts)
43
+ - Added `streetAllowCustomValue` input to control whether the street field allows custom values (defaults to `true`).
44
+ - Added `swissNpaLocalityBaseUrl` input to control the base URL for Swiss NPA localities (defaults to `'api/refinf/locality'`).
45
+
46
+ - [foehn-navigation.component.html](projects/prestations-ng/src/foehn-navigation/foehn-navigation/foehn-navigation.component.html)
47
+ - [foehn-simple-navigation.component.html](projects/prestations-ng/src/foehn-navigation/foehn-simple-navigation/foehn-simple-navigation.component.html)
48
+ - while the page targeted by "next", "transmit" or "previous" is loading for more than 200 ms (e.g. lazy loaded
49
+ route), the clicked button displays a spinner with the new `loadingLabel` input (dictionary key
50
+ `foehn-navigation.loading.label`, "Chargement...") and the navigation buttons are disabled (`aria-disabled`;
51
+ clicks are ignored from the start of the navigation); a live `output` region announces the loading to screen
52
+ readers (also in 18.3.15)
53
+ - this state is exposed by read-only signals: `pendingNavigationDirection`, `loadingDirection`, `isNavigating`,
54
+ `isLoading`, `isLoadingNext` and `isLoadingPrevious`
55
+ - [foehn-navigation.service.ts](projects/prestations-ng/src/foehn-navigation/foehn-navigation.service.ts)
56
+ - new method `pendingNavigationDirection()`: direction of the navigation started with `next()` or `previous()`
57
+ until it ends, `null` otherwise (also in 18.3.15)
58
+
11
59
  ### Changed
12
60
 
13
61
  Library now runs as strict mode, which may cause some errors to appear in your project after updating.
14
62
  Please check the [UPGRADING_V19.md](UPGRADING_V19.md) guide for more information.
15
63
 
64
+ - [foehn-list-summary.component.ts](projects/prestations-ng/src/foehn-menu-prestation/foehn-list-summary/foehn-list-summary.component.ts)
65
+ - `FoehnListSummaryComponent` is now generic: `FoehnListSummaryComponent<T extends FoehnListItem>`,
66
+ so the model, `getListItemTitle` and `listItemDescriptions` are typed with your own item class
67
+ instead of the base `FoehnListItem`
68
+ - [foehn-list-item-description.ts](projects/prestations-ng/src/foehn-menu-prestation/foehn-list-summary/foehn-list-item-description.ts)
69
+ - 🚨 `FoehnListItemDescription` now takes a type parameter: `FoehnListItemDescription<T>`.
70
+ `getFormattedValue(item: T)` and `hideIfEmpty(item: T)` receive your item type directly, no cast needed.
71
+ Replace `FoehnListItemDescription[]` with `FoehnListItemDescription<MyItem>[]` in your project.
72
+ - [uploader.helper.ts](projects/prestations-ng/src/foehn-upload/uploader.helper.ts)
73
+ - 🚨 `UploaderHelper.addCustomErrorOrDefault()` takes the limits of the uploader in an object (`UploaderErrorLimits`,
74
+ all optional) instead of its last three parameters:
75
+ `addCustomErrorOrDefault(name, errors, errorCode, fileName, customErrors, { overrideAcceptedExtensions, overrideMaxFileNameLength, overrideIllegalCharacters, maxFileSizeInMo })`.
76
+ The custom error 413 returned by the server now also displays the `maxFileSizeInMo` limit of
77
+ `foehn-bo-multi-upload`.
78
+ - [foehn-modal.component.ts](projects/prestations-ng/src/foehn-modal/foehn-modal.component.ts)
79
+ - 🚨 `modalSize` is now typed with the new `FoehnModalSize` type
80
+ (`'' | 'modal-sm' | 'modal-md' | 'modal-lg' | 'modal-xl'`) instead of `string`, as are `HelpModal.modalSize`
81
+ and therefore the `helpModal` of the `foehn-input-*` components. Other values, such as `modal-xs`, are not
82
+ Bootstrap classes, had no effect and no longer compile: replace them with `modal-md` to keep the same size
83
+ (removing them in a `HelpModal` would fall back to `modal-lg`).
84
+ - [foehn-table.component.ts](projects/prestations-ng/src/foehn-table/foehn-table.component.ts)
85
+ - 🚨 `columnsConfiguration` is now an `input()` instead of a `model()`: the table never changes it. The
86
+ two-way binding `[(columnsConfiguration)]` and the `columnsConfigurationChange` output no longer exist, and
87
+ `columnsConfiguration.set()` no longer compiles: bind it with `[columnsConfiguration]`.
88
+ - 🚀 **prestations-ng is now zoneless**: its components no longer need zone.js to be refreshed. They keep
89
+ working in an application using zone.js, and your application can now drop zone.js, see
90
+ [UPGRADING_V19.md](UPGRADING_V19.md#zoneless-optional-but-recommended).
91
+ - the state displayed by the components is held by signals (`signal()`, `computed()`, `linkedSignal()`)
92
+ - what was waiting for `NgZone.onMicrotaskEmpty` or a `setTimeout()` to reach the rendered DOM (focus,
93
+ scroll, value displayed by the autocompletes, default values...) now uses `afterNextRender()`
94
+ - the short asynchronous work of the components is tracked with `PendingTasks`, so that
95
+ `ApplicationRef.whenStable()` (and `fixture.whenStable()` in your tests) waits for it: the debounced
96
+ `userInput` output of the `foehn-input-*` components, the debounced time of `foehn-input-date-time`,
97
+ the locale of `foehn-date-picker`, the default country and the sanitized model of `foehn-input-address`
98
+ - `providePrestationsNgCore()` now provides `provideBrowserGlobalErrorListeners()`: without zone.js, the
99
+ errors thrown in a timer or a promise still reach your `ErrorHandler`
100
+ - 🚨 **The inputs and outputs of the components are unchanged** (except `columnsConfiguration` of `foehn-table`,
101
+ see above), but the following public fields are now signals. If your code reads them (e.g. through
102
+ `viewChild()` or in your tests), call them (`isVisible()` instead of `isVisible`) and write them with `.set()`. Those marked _read-only_ are `computed()` signals.
103
+ - `foehn-agenda`: `srAnnouncements`
104
+ - `foehn-agenda-timeslot-panel`: `selectedTimeSlot` (_read-only_), `timeInputValue` (_read-only_), `isClosed`,
105
+ `timeSlots` (_read-only_), `timeslotRemaining` (_read-only_), `canClose` (_read-only_)
106
+ - `foehn-autocomplete`: `searchValue`, `inputHasFocus`, `hideSuggestions`, `displayedElements`,
107
+ `notificationMessageUpdated`, `VIEW_PORT_HEIGHT` (_read-only_)
108
+ - `foehn-multiselect-autocomplete`: `autocompleteInputValue`, `showEmptyListMessage` (_read-only_), `srAnnouncements`
109
+ - `foehn-select`, `foehn-radio`, `foehn-checkbox` and the autocompletes (`FoehnCheckableGroupComponent`):
110
+ `groupedElements`
111
+ - `foehn-radio`: `inputValue` (_read-only_)
112
+ - `foehn-confirm-modal`: `isVisible` (`content` is now a read-only field instead of a getter)
113
+ - `foehn-date-picker`: `hostId`, `weekDays`, `weeks`, `selectedDate`, `monthListItem`
114
+ - `foehn-dropdown-menu`: `isDropdownVisible`, `popupPosition`
115
+ - `foehn-header`: `connectedEsMenu` (_read-only_)
116
+ - `foehn-input-address`: `country`, `locality`, `street`, `houseNumber`, `postOfficeBoxText`,
117
+ `addressLine1`, `addressLine2` (linked to the model: they follow it and can still be set),
118
+ `streetCustomErrors`
119
+ - `foehn-input-foreign-locality`: `zipCode`, `longName` (linked to the model: they follow it and can still be set)
120
+ - `foehn-input-foreign-street`: `longName` (linked to the model: it follows it and can still be set)
121
+ - `foehn-input-date`: `day`, `month`, `year`, `datePickerModel` (linked to the model: they follow it and can
122
+ still be set)
123
+ - `foehn-input-date-time`: `date`, `time` (linked to the model: they follow it and can still be set)
124
+ - `foehn-input-time`: `hour`, `minute` (linked to the model: they follow it and can still be set)
125
+ - `foehn-input-nav13`: `part2`, `part3`, `part4` (linked to the model: they follow it and can still be set)
126
+ - `foehn-input-textarea`: `isCharCountExceeded`, `charCountLeft`, `charCountLabel`, `ariaLiveStatus` (all
127
+ _read-only_; the methods `countCharLeft()` and `checkCharCountExceeded()` are removed, the count follows the
128
+ model, `max` and `displayCharCount`)
129
+ - `foehn-list`: `currentPage`, `filteredList`
130
+ - `foehn-table`: `currentPage` (linked to the model, `itemsPerPage`, `fixedPageCount` and `sort`: back to the
131
+ first page when its page no longer exists), `filteredList` (_read-only_)
132
+ - `foehn-list-summary`: `listCopyForTable` (_read-only_), `tableConfiguration` (_read-only_)
133
+ - `foehn-notfound`: `seconds`
134
+ - `foehn-page`: `pageTitle`
135
+ - `foehn-page-counter`: `isStable` (was an `Observable<boolean>`)
136
+ - `foehn-page-modal`: `wrongPublicModalVisible`, `formattedPublicsCibles`
137
+ - `foehn-picture-upload`: `pictureToCrop`, `croppedPictureAsBlob`, `loading`
138
+ - `foehn-status-progress-bar`: `isTransmitted`
139
+ - `gesdem-action-recovery-login`: `demandeNotFound`, `rateLimited`, `rateLimitCounter`, `otpRecipient`,
140
+ `otp`
141
+ - `gesdem-action-recovery-registration`: `mailSent`, `model` (replaced by the new `updateModel()` method,
142
+ never mutated)
143
+ - `epayment-form` (`SdkEpaymentComponent`): `failureModalDisplayed`, `redirectModalDisplayed`
144
+ - `captcha` (`SdkRecaptchaComponent`): `isLoaded`, `hasLoadingError`
145
+ - `redirector` (`RedirectComponent`): `counter`
146
+ - The lifecycle hooks that have nothing left to do are removed: `ngOnChanges()` of
147
+ `foehn-agenda-timeslot-panel` and `foehn-table`, `ngAfterViewInit()` of `foehn-list-summary`, `ngOnInit()` of
148
+ `foehn-radio` and `foehn-input-textarea`, `ngOnInit()` and `ngOnDestroy()` of `captcha`.
149
+ - `FoehnInputComponent.onModelChange()` does nothing by default (it set `model_`): override it only to act on a new
150
+ model, e.g. to normalize it. A component deriving its fields from the model with `linkedSignal()` no longer needs
151
+ to override it, see "Creating a reusable component" in [GOOD_PRACTICES.md](GOOD_PRACTICES.md). `model_` is set
152
+ by `FoehnInputComponent` alone, for every component: known once the model of the page has a value to display, then
153
+ following it, and staying known (`null`) when the page sets it back to `undefined`.
154
+ - A component which doesn't override `onModelChange()`, or calls `super.onModelChange()`, now handles `model_` as
155
+ those overriding it without `super` already did: it no longer replaces by `null` a model without any value to
156
+ display given by the page (e.g. `[]`, `''`) when it updates its model without any input of the user, and a
157
+ model set back to `undefined` by the page stays known.
158
+ - If one of your components reads the value of `model_`, not only `model_ !== undefined`: it is `undefined` as
159
+ long as the model of the page has had no value to display, and `null` once the page sets it back to
160
+ `undefined`.
161
+ - `modelChange` of the `foehn-input-*` components is emitted only when the component writes its model (an input of
162
+ the user, a correction of the model given by the page), not when the page changes the model: true since 19.0.0,
163
+ now documented in
164
+ [UPGRADING_V19.md](UPGRADING_V19.md#modelchange-is-emitted-only-when-the-component-writes-its-model), and on the
165
+ Lifecycle page of the documentation, which said the opposite.
166
+ - `SdkDictionaryService.getKeySync()` reads a signal: a `computed()` or a template calling it is refreshed
167
+ when the dictionary is (re)loaded, e.g. when the language changes.
168
+ - `foehn-autocomplete` and `foehn-multiselect-autocomplete`: the value to display, its reset, the default
169
+ values and the focus after a click on a suggestion are applied after the next rendering instead of in a
170
+ `setTimeout()`.
171
+ - Unit tests of the library: Karma and Jasmine are replaced by Vitest 4 in browser mode (Playwright,
172
+ headless Chromium), see [CONTRIBUTING.md](CONTRIBUTING.md#unit-testing).
173
+ - `core-js` is no longer a peer dependency: prestations-ng no longer imports it since 19.1.1, see
174
+ [UPGRADING_V19.md](UPGRADING_V19.md#core-js-is-no-longer-needed-since-1920).
175
+ - `ng add @dsivd/prestations-ng` adds `iban` and `dayjs` (the CommonJS dependencies of prestations-ng) to the
176
+ `allowedCommonJsDependencies` of `angular.json`, instead of `core-js/modules/es.array.includes`, `iban` and
177
+ `zone.js/dist/zone-error`, and no longer sets `allowSyntheticDefaultImports` (implied by the `tsconfig.json` of
178
+ Angular 21: `"module": "preserve"` or `"moduleResolution": "bundler"`).
179
+ - `GOOD_PRACTICES.md` and `INTRODUCTION_ANGULAR_SIGNALS.md` are now in English, like the rest of the
180
+ documentation: the titles of their sections, and so their anchors, have changed.
181
+
182
+ ### Deprecated
183
+
184
+ - `AbstractMenuPageComponent.ngZone` is no longer used and will be removed: `NgZone.onStable` never emits
185
+ without zone.js.
186
+
187
+ ### Fixed
188
+
189
+ - `AbstractPageComponent` and `AbstractPageFromMenuComponent`: a second click on "next" or "transmit" while the next
190
+ page is loading (lazy loaded route, resolver, async guard) no longer saves again and skips the next page:
191
+ `send()`, `sendAndTransmit()` and `transmit()` are ignored until the navigation to the next page ends. Pages
192
+ overriding `onFormSent()` should call the new protected method `navigateToNextPage()` instead of
193
+ `this._navigation.next()` to get this protection (also in 18.3.15).
194
+ - `captcha`: no more `NG0953` warning ("Unexpected emit for destroyed `OutputRef`") when the captcha script fails to
195
+ load after the component has been destroyed (e.g. the user left the page meanwhile).
196
+ - `foehn-multiselect-autocomplete`: the suggestions and the message displayed once every element is selected follow a
197
+ model changed by the project, not only by the user. Once every element was selected, a model set back to some of
198
+ them kept the message and the hidden input; a model selecting every element did not display the message; the
199
+ suggestions still contained the elements selected by the project. An empty list of elements no longer displays
200
+ the message (every element of the list has already been added).
201
+ - `providePrestationsNgCore()` registers again the HTTP interceptors lost with `FoehnPageModule` in 19.0.0: the
202
+ `foehn-transmit-waiting-modal` is displayed again during a long transmission, the warning before the expiration of
203
+ the session receives its date again, and a new version of the application deployed meanwhile is detected again.
204
+ - `foehn-select`, `foehn-radio`, `foehn-checkbox` and the autocompletes:
205
+ - the model is no longer set back to its previous value when the parent changes `elements` and `model`
206
+ at the same time
207
+ - no more error when the component is destroyed while its `elementsUrl` is loading
208
+ - with a `defaultElementValue`, the model can be emptied again (e.g. set to `null` by the parent): the
209
+ default value was set back at once
210
+ - a change of the model or of `disabled` no longer processes the elements again (the default value, the
211
+ display of the model, the grouped elements and, for the autocompletes, the matching of the model)
212
+ - `foehn-autocomplete`:
213
+ - the model is subscribed only once, whatever the number of times the elements are retrieved: the value
214
+ to display was selected again for each retrieval
215
+ - the height of the suggestion list always follows `itemHeightInSuggestionListInPx`, even before the first
216
+ search returning less than 5 suggestions
217
+ - dynamic list (`isSuggestionListDynamic`): a model already set is no longer reset, even for a moment
218
+ (`modelChange` emitted `null`, then the value again), when the loaded elements do not contain it; it is
219
+ displayed once the elements loaded for it contain it, including when they are given at once with the model
220
+ - `isSuggestionListDynamic` can change at runtime: only the matching of the current kind of list is active,
221
+ the matching of the previous kind went on
222
+ - dynamic list: a model changed by the project (another value, `null`) is displayed again; once a value had been
223
+ displayed, the display no longer followed the model. The elements loaded for the search of the user still do
224
+ not replace what they type.
225
+ - `foehn-input-address` without zone.js: an address given by the parent right after the initialization of the
226
+ component (e.g. prefilled with `SessionInfoWithApplicationService.prefillForm()` for a connected user) is no
227
+ longer overwritten by the model with the default country only; the default country and the clean-up of the model
228
+ are applied after the next rendering, from the latest model.
229
+ - `foehn-input-address`: the streets and the street numbers of an address given by the page are loaded again, as in
230
+ v18. Since 19.0.0, they were only loaded once the user chose a locality and a street (the autocompletes no longer
231
+ emit `modelChange` for a model given by the page), and a locality given with its `zipCodeId` only (without
232
+ `postalLocalityHistoryId`) never loaded its streets. The lists now follow the locality and the street, whether
233
+ they come from the page or from the user. The Swiss localities are requested once the Swiss fields are displayed,
234
+ and again only when their URL changes (`swissNpaLocalityBaseUrl`, `specifiedCanton`, `withCompanyLocalities`), no
235
+ longer each time Switzerland is chosen again. The methods `userInputCountry()`, `userInputLocality()` and
236
+ `userInputStreet()` no longer take a parameter.
237
+ - `foehn-input-address`: the deferred clean-up of the model (hidden address lines and post office box) applies
238
+ to the latest model, it could restore a previous value (e.g. remove the default country); nothing is
239
+ updated anymore once the component is destroyed.
240
+ - `FoehnInputComponent`: when the user empties at once every field of a model given by the page, the model is `null`
241
+ again, as in v18, for the components overriding `onModelChange()` without calling `super.onModelChange()`: in
242
+ prestations-ng `foehn-input-date`, `foehn-input-date-time`, `foehn-input-foreign-locality` and
243
+ `foehn-input-foreign-street` (also in the foreign address of `foehn-input-address`), and in your project e.g. a
244
+ list whose last item is removed. Since 19.0.0, the model kept its previous value, which was then saved. The model
245
+ of the page is now known (`model_`) once it has a value to display, and then follows it, before `onModelChange()`,
246
+ which can still change it. Nothing to change in your components, except one whose model can hold a value only in a part it doesn't
247
+ display (e.g. an id) and which updates its model without any input of the user: override the new protected method
248
+ `hasValueToDisplay()`, as `foehn-input-address` does for the country of an address only Swiss.
249
+ - `foehn-input-date-time`: emptying its only filled field empties the model, it kept its value also in v18.
250
+ - `foehn-input-hidden`, `foehn-input-email` and `foehn-input-password` handle their model as `foehn-input-text` does:
251
+ a number `0` given by the page (e.g. a number field in Java bound to a `foehn-input-hidden`) is kept, it was
252
+ replaced by `null`, which was then saved. An empty string is replaced by `null` at once, instead of after a timer
253
+ that `fixture.whenStable()` didn't wait for, and that could overwrite a value given by the page meanwhile. Their
254
+ public field `timeoutReference` is removed.
255
+ - `foehn-input-textarea` replaces by `null` an empty string given by the page, as the other text fields do. Its
256
+ character count follows a change of `max` or `displayCharCount` at once: it kept the previous count until the next
257
+ input, and the textarea stayed `aria-invalid` once the count was no longer displayed.
258
+ - `foehn-radio`: `inputValue` follows a change of `elementValue` or `elementValueIdentity`, not only of the model.
259
+ - `foehn-input-time` replaces by `null` an empty string given by the page, as the other text fields do: the backend
260
+ rejected it (`@ValidStringTime` accepts `null`, not `''`), although the user had entered nothing.
261
+ - 🚨 `ObjectHelper.hasAnyValue()` and `ObjectHelper.isEmpty()`: a number (`0` included), a boolean (`false`
262
+ included) and a date are values. `true`, `5` or a date were empty, as well as `0`, `false` or a date in an object
263
+ or an array (e.g. `{ checked: false }`, `[0, 0]`). Only `null`, `undefined`, `''` and the arrays and objects
264
+ holding none but them are empty. Check your calls on such values, e.g. in the `getValidValue()` of your
265
+ components: a field holding `true` no longer counts as empty.
266
+ - `foehn-multi-upload` and `foehn-bo-multi-upload`:
267
+ - after a failed upload (network, HTTP error), the next files are uploaded: nothing was uploaded anymore,
268
+ without any message, until the page was reloaded
269
+ - after a failed deletion (HTTP error, readonly document), the next files are deleted: nothing was deleted
270
+ anymore, and the error also reached the `ErrorHandler` as unhandled (its message is still displayed)
271
+ - `PendingUploadService.removePendingFile()`: a file which is not pending no longer removes the last pending file.
272
+ - `foehn-multi-upload` and `foehn-bo-multi-upload`: `customErrors` is used again for the errors which have a default
273
+ message (`413`, `415`, `500`, `FILENAME_TOO_LONG`, `FILENAME_SHOULD_NOT_CONTAIN`...): the default messages
274
+ overwrote the given object. Its messages can use `{fileName}` and `{fileMaxSize}`, `{fileExtensions}`,
275
+ `{maxFileNameLength}`, `{fileNameIllegalCharacters}` (as documented) as well as `%1$s` and `%2$s`.
276
+ - `UploaderHelper`: `getDefaultCustomErrors()` and `mergeCustomErrors()` are added, `createDefaultCustomErrors()` is
277
+ deprecated as it overwrites the given custom errors.
278
+ - `foehn-agenda-timeslot-panel`: when the time slots of the day change, the panel is closed again (only the
279
+ first time slots are displayed) unless the selected slot would be hidden; the list was cut while the panel
280
+ stayed open.
281
+ - `foehn-breadcrumb`: a breadcrumb updated in place is displayed again when it is emitted.
282
+ - `fromDictionary` pipe: its subscription is released when the pipe is destroyed.
283
+ - `SdkLogsService`: a log is not sent anymore once the application is destroyed (e.g. at the end of a test),
284
+ when it made the `HttpClient` throw `NG0205`.
285
+ - `SessionInfoWithApplicationService`: `isReady` and `isUserConnected` return the same `Observable` at each read. A
286
+ new one at each read made the `async` pipe of a template subscribe again at each refresh: on a resumed application
287
+ whose form is loaded before the session, `isReady` went back to `null` and hid the content until the session
288
+ arrived.
289
+ - `foehn-list-summary` with `showAsTable`: the table displays the list given by the page when the page replaces it
290
+ (e.g. with the form returned by the backend). Since 19.0.0, it only followed the removals and the sorts made in
291
+ the component.
292
+ - `ng add @dsivd/prestations-ng` works again on the Angular workspaces created since Angular 14: it failed because
293
+ `angular.json` no longer has a `defaultProject` (the dependencies are now added to every application), then
294
+ because of the comments of `tsconfig.json` (now kept, like its formatting).
295
+ - `foehn-feedback-notification`: an error of `api/feedbacknotification/queryparams/{reference}` is logged and the
296
+ links are displayed without the feedback url, it reached the `ErrorHandler` as unhandled.
297
+ - The npm package no longer contains its own archive (`dsivd-prestations-ng-<version>.tgz`).
298
+
16
299
  ## [19.1.1]
17
300
 
18
301
  ### Fixed
@@ -155,6 +438,24 @@ Please check the [UPGRADING_V19.md](UPGRADING_V19.md) guide for more information
155
438
  - [foehn-list-summary.component.ts](projects/prestations-ng/src/foehn-menu-prestation/foehn-list-summary/foehn-list-summary.component.ts)
156
439
  - `[list]` attribut has been removed. Use `[model]` instead.
157
440
 
441
+ ## [18.3.15]
442
+
443
+ ### Updated
444
+
445
+ - [foehn-navigation.component.html](projects/prestations-ng/src/foehn-navigation/foehn-navigation/foehn-navigation.component.html)
446
+ - [foehn-simple-navigation.component.html](projects/prestations-ng/src/foehn-navigation/foehn-simple-navigation/foehn-simple-navigation.component.html)
447
+ - while the page targeted by "next", "transmit" or "previous" is loading for more than 200 ms (e.g. lazy loaded route), the clicked button displays a spinner with the new `loadingLabel` input (dictionary key `foehn-navigation.loading.label`, "Chargement...") and the navigation buttons are disabled (`aria-disabled`; clicks are ignored from the start of the navigation); a `role="status"` region announces the loading to screen readers
448
+ - [foehn-navigation.service.ts](projects/prestations-ng/src/foehn-navigation/foehn-navigation.service.ts)
449
+ - new method `pendingNavigationDirection()`: direction of the navigation started with `next()` or `previous()` until it ends, `null` otherwise
450
+
451
+ ### Fixed
452
+
453
+ - [abstract-page-component.ts](projects/prestations-ng/src/abstract-page-component.ts)
454
+ - fixed a second click on "next" or "transmit" while the next page is loading (lazy loaded route, resolver, async guard) saving again and skipping the next page: `send()`, `sendAndTransmit()` and `transmit()` are now ignored until the navigation to the next page ends
455
+ - new protected method `navigateToNextPage()`: pages overriding `onFormSent()` should call it instead of `this._navigation.next()` to get this protection
456
+ - [abstract-page-from-menu.component.ts](projects/prestations-ng/src/foehn-menu-prestation/abstract-page-from-menu.component.ts)
457
+ - same fix when returning to the parent page
458
+
158
459
  ## [18.3.13]
159
460
 
160
461
  ### Fixed
package/CONTRIBUTING.md CHANGED
@@ -4,9 +4,11 @@
4
4
 
5
5
  - Node 22.18+
6
6
  - npm 10.2+
7
- - Chrome or Chromium
8
7
  - G++
9
8
 
9
+ Chromium is downloaded by Puppeteer during `npm install`: it is used by the unit tests (through Playwright)
10
+ and by the e2e tests (Cypress).
11
+
10
12
  ## Developing using the Dev Tool
11
13
 
12
14
  Since version `8`, `prestations-ng` has a standalone application that allows
@@ -92,9 +94,10 @@ This project uses a set of scripts to lint and format the code, along with pre-c
92
94
 
93
95
  Important scripts are :
94
96
 
95
- - `npm run lint` : run ESLint and Prettier on all files
97
+ - `npm run lint` : run ESLint and Prettier on all files, and check the types of the TypeScript files compiled by no
98
+ build (`lint:types`: `cypress/`, which Cypress only transpiles, and the configuration files of `tsconfig.config.json`)
96
99
  - `npm run format`: run ESLint and Prettier on all files and fix errors automatically
97
- - `npm run validate`: clean and run all tests
100
+ - `npm run validate`: clean, lint and run all tests
98
101
 
99
102
  **Husky** is used as a pre-commit hook to automatically output linting and formatting errors for staged files before committing.
100
103
  In the end, this utilitary calls `npm run lint-staged` which you can also call yourself of course. To have this pre-commit hook,
@@ -168,7 +171,7 @@ Alternatively, you can manually publish the package. Although this method is not
168
171
  - Ensure you can push to the npm registry: `npm adduser --registry=https://registry.npmjs.org --scope=@dsivd`
169
172
  - Update the version number in `package.json` either manually or with `npm version`
170
173
  - Commit and tag the version change
171
- - Package a new version of the library with `npm package`
174
+ - Package a new version of the library with `npm run package`
172
175
  - Publish the package:
173
176
  - `npm run publish:stable` for stable version (released to everybody)
174
177
  - `npm run publish:next` for next version (development only)
@@ -218,6 +221,73 @@ export NODE_OPTIONS=--max_old_space_size=4096
218
221
 
219
222
  Use at your own risks.
220
223
 
224
+ ## Writing signal-first code
225
+
226
+ The library is zoneless: Angular refreshes a component when a signal read by its template changes, or when the
227
+ component is notified (see "Zoneless application" in [GOOD_PRACTICES.md](GOOD_PRACTICES.md) and
228
+ [ANGULAR_SIGNALS.md](ANGULAR_SIGNALS.md)). Write the code as it would be written today with signals, not around a
229
+ mechanism inherited from zone.js:
230
+
231
+ - State read by a template: a `signal()`. State derived from other signals (inputs, model, view queries): a
232
+ `computed()`, or a `linkedSignal()` when it can also be changed locally. Don't keep a signal in sync from
233
+ `ngOnChanges()`, `onModelChange()`, an `effect()` or a `setTimeout()` when it can be derived.
234
+ - React to a signal input with `computed()` or `linkedSignal()`, not with `ngOnChanges()`.
235
+ - Never mutate a value held by a signal or bound to an input (`push()`, `splice()`, `sort()`): write a new array or
236
+ object. No copy is then needed "so that the change detection sees a new reference".
237
+ - Asynchronous work: set a signal in the callback, or convert the `Observable` with `toSignal()` where it is
238
+ displayed. The services keep returning `Observable`s.
239
+ - `markForCheck()` only for a state that can't be a signal (e.g. the `form` of `AbstractPageComponent`, written by
240
+ the projects).
241
+ - Act on the rendered DOM (focus, scroll, measure) with `afterNextRender(..., { injector })`, never with
242
+ `setTimeout()` or `NgZone`.
243
+ - `effect()` as a last resort, with `untracked()` for what isn't a trigger. Never use it to copy a signal into another
244
+ one.
245
+ - Track the short asynchronous work the tests must wait for (e.g. a debounce) with `PendingTasks`.
246
+ - Before fixing existing code, read the history of the mechanism you touch (`git log -S`, `git blame`): many
247
+ `setTimeout()`, copies, `ngOnChanges()` and `NgZone` are workarounds from the zone.js era whose reason is gone. If
248
+ the code wouldn't be written this way today, rewrite it rather than patching around it.
249
+ - A public field of a component that becomes a signal changes how the projects read it: list it in the CHANGELOG
250
+ (_read-only_ for a `computed()`), with 🚨 when an input or an output changes.
251
+
252
+ ## Unit testing
253
+
254
+ The unit tests run with [Vitest](https://vitest.dev/) through the `@angular/build:unit-test` builder of the
255
+ Angular CLI, in the browser mode of Vitest: [Playwright](https://playwright.dev/) drives the headless Chromium
256
+ downloaded by Puppeteer (another browser can be used by setting the `CHROME_BIN` environment variable).
257
+ Neither the library nor the Dev Tool uses zone.js: the tests are **zoneless** too.
258
+
259
+ | Command | Tests |
260
+ | ------------------------- | ---------------------------------------------------------------- |
261
+ | `npm run test:lib` | library (`projects/prestations-ng/src/**/*.spec.ts`) |
262
+ | `npm run test:devtool` | Dev Tool (`src/**/*.spec.ts`) |
263
+ | `npm run test:schematics` | schematics, in Node.js (`projects/prestations-ng/schematics`) |
264
+ | `npm run test:eslint` | ESLint plugin, in Node.js (`projects/prestations-ng/src/eslint`) |
265
+ | `npm test` | builds the library, then runs all of the above |
266
+
267
+ - `ng test prestations-ng` without `--no-watch` runs the tests in watch mode.
268
+ - Only some specs: `ng test prestations-ng --no-watch --include=foehn-table` (folder or file, relative to
269
+ `projects/prestations-ng/src`), and `--filter="FoehnTableComponent"` to filter by test name.
270
+ - The configuration is in `angular.json` (`test` targets), in the `vitest-base.config.mts` file of each project and in
271
+ the `vitest-base.config.mts` file they share, at the root.
272
+ The coverage of the library is written in `projects/prestations-ng/coverage` (read by SonarQube).
273
+ - The configuration files of the tools (`.mjs`/`.mts`, e.g. `eslint.config.mjs`, `vitest-base.config.*`) are listed in
274
+ `tsconfig.config.json`, referenced by `tsconfig.json`: the IDE checks them with the options of the project instead of
275
+ its default ones. Add any new configuration file to its `files`.
276
+
277
+ ### Writing zoneless tests
278
+
279
+ - Use `vi` (`vi.spyOn()`, `vi.fn()`...), the Jest-like API of Vitest. Unlike `spyOn()` in Jasmine,
280
+ `vi.spyOn()` calls the original method: add `.mockReturnValue(...)` or `.mockImplementation(...)` to stub it.
281
+ The spies are restored before each test.
282
+ - `fakeAsync()`, `tick()`, `flush()` and `waitForAsync()` require zone.js: use `async` tests with
283
+ `await fixture.whenStable()`, or `vi.useFakeTimers()` and `await vi.advanceTimersByTimeAsync(ms)`.
284
+ - `fixture.whenStable()` waits for the change detection and the Angular pending tasks (e.g. the debounced
285
+ `userInput` of the inputs), not for the timers, nor for the HTTP requests of a spec: `provideHttpClientTesting()`
286
+ keeps them pending until the test answers them with `HttpTestingController`. Answer them first, then
287
+ `await fixture.whenStable()`.
288
+ - Without zone.js, `fixture.detectChanges()` only refreshes the views that have been notified. A test (or a test
289
+ host component) changing the state of a component must use signals, as the components do.
290
+
221
291
  ## E2E testing
222
292
 
223
293
  `Protractor` is no longer included in new Angular projects as of Angular 12.