@hmcts/opal-frontend-common 0.0.19 → 0.0.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/components/abstract/abstract-form-base/index.d.ts +5 -5
- package/components/govuk/govuk-tabs/govuk-tabs-list-item/README.md +64 -0
- package/components/govuk/govuk-tabs/govuk-tabs-list-item/index.d.ts +21 -0
- package/components/govuk/govuk-tabs/govuk-tabs-panel/README.md +52 -0
- package/components/govuk/govuk-tabs/govuk-tabs-panel/index.d.ts +8 -0
- package/components/govuk/govuk-tabs/index.d.ts +20 -32
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs +16 -13
- package/fesm2022/hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs +56 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs +18 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs +34 -75
- package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs +4 -0
- package/fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs.map +1 -0
- package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs +23 -0
- package/fesm2022/hmcts-opal-frontend-common-services-transformation-service.mjs.map +1 -1
- package/fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs +28 -0
- package/fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs.map +1 -0
- package/package.json +21 -1
- package/services/date-service/interfaces/index.d.ts +10 -0
- package/services/transformation-service/index.d.ts +11 -0
- package/validators/pattern-validator/index.d.ts +14 -0
|
@@ -164,12 +164,12 @@ declare abstract class AbstractFormBaseComponent implements OnInit, OnDestroy {
|
|
|
164
164
|
*/
|
|
165
165
|
protected hasUnsavedChanges(): boolean;
|
|
166
166
|
/**
|
|
167
|
-
* Sets the value of a
|
|
167
|
+
* Sets the value of a form control specified by its path and marks it as touched.
|
|
168
168
|
*
|
|
169
|
-
* @param
|
|
170
|
-
* @param
|
|
169
|
+
* @param value - The value to set for the form control.
|
|
170
|
+
* @param controlPath - The dot-delimited path to the form control within the form group.
|
|
171
171
|
*/
|
|
172
|
-
protected setInputValue(value: string,
|
|
172
|
+
protected setInputValue(value: string, controlPath: string): void;
|
|
173
173
|
/**
|
|
174
174
|
* Handles the form errors for the date input fields.
|
|
175
175
|
* @param formErrors - An array of form errors.
|
|
@@ -229,7 +229,7 @@ declare abstract class AbstractFormBaseComponent implements OnInit, OnDestroy {
|
|
|
229
229
|
* @param route string of route
|
|
230
230
|
* @param nonRelative boolean indicating if route is relative to the parent
|
|
231
231
|
*/
|
|
232
|
-
handleRoute(route: string, nonRelative?: boolean, event?: Event): void;
|
|
232
|
+
handleRoute(route: string, nonRelative?: boolean, event?: Event, routeData?: any): void;
|
|
233
233
|
/**
|
|
234
234
|
* Handles the form submission event.
|
|
235
235
|
*
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# GOV.UK Tab List Item Component
|
|
2
|
+
|
|
3
|
+
This Angular component renders a single `<li>` element with the appropriate GOV.UK class for use within a tabbed navigation structure. It wraps a projected `<a>` tag that acts as the tab link.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Testing](#testing)
|
|
10
|
+
- [Contributing](#contributing)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Each component in the `govuk-tabs` group is exported individually:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { GovukTabListItemComponent } from 'opal-frontend-common/components/govuk/govuk-tabs/govuk-tab-list-item';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
This component renders a `<li>` with appropriate GOV.UK classes for use within a tabs list. It wraps a projected `<a>` element.
|
|
23
|
+
|
|
24
|
+
You must provide the following inputs:
|
|
25
|
+
|
|
26
|
+
- `tabItemFragment` — a unique string fragment to identify this tab
|
|
27
|
+
- `activeTabItemFragment` — the currently selected fragment (e.g. from the route or state)
|
|
28
|
+
- `tabItemId` — the unique ID for accessibility
|
|
29
|
+
|
|
30
|
+
The link text inside the `<a>` is projected using `<ng-content>`.
|
|
31
|
+
|
|
32
|
+
### Example
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<opal-lib-govuk-tabs-list-item
|
|
36
|
+
[tabItemFragment]="'panel-individuals'"
|
|
37
|
+
[activeTabItemFragment]="activeTabFragment"
|
|
38
|
+
[tabItemId]="'tab-individuals'"
|
|
39
|
+
>
|
|
40
|
+
<ng-content [linkText]>Individuals</ng-content>
|
|
41
|
+
</opal-lib-govuk-tabs-list-item>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
This results in:
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<li class="govuk-tabs__list-item govuk-tabs__list-item--selected" id="tab-individuals">
|
|
48
|
+
<a id="tab-individuals" href="#panel-individuals" class="govuk-tabs__tab">Individuals</a>
|
|
49
|
+
</li>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The `govuk-tabs__list-item--selected` class is applied automatically when `tabItemFragment` matches `activeTabItemFragment`.
|
|
53
|
+
|
|
54
|
+
## Testing
|
|
55
|
+
|
|
56
|
+
Unit tests for this component can be found in the `govuk-tab-list-item.component.spec.ts` file. To run the tests:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
ng test
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Contributing
|
|
63
|
+
|
|
64
|
+
Feel free to submit issues or pull requests to improve this component.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class GovukTabsListItemComponent {
|
|
4
|
+
private readonly router;
|
|
5
|
+
private readonly route;
|
|
6
|
+
tabItemId: string;
|
|
7
|
+
tabItemFragment: string;
|
|
8
|
+
activeTabItemFragment: string;
|
|
9
|
+
get hostClass(): string;
|
|
10
|
+
get hostId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Handles the click event of a sub-navigation item.
|
|
13
|
+
* @param event - The click event.
|
|
14
|
+
* @param item - The item string.
|
|
15
|
+
*/
|
|
16
|
+
handleItemClick(event: Event, item: string): void;
|
|
17
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabsListItemComponent, never>;
|
|
18
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsListItemComponent, "opal-lib-govuk-tabs-list-item, [opal-lib-govuk-tabs-list-item]", never, { "tabItemId": { "alias": "tabItemId"; "required": true; }; "tabItemFragment": { "alias": "tabItemFragment"; "required": true; }; "activeTabItemFragment": { "alias": "activeTabItemFragment"; "required": true; }; }, {}, never, ["*"], true, never>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { GovukTabsListItemComponent };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# GOV.UK Tab Panel Component
|
|
2
|
+
|
|
3
|
+
This Angular component renders a GOV.UK-styled tab panel, used in conjunction with `govuk-tabs` and `govuk-tab-list-item`. It wraps content in a `<div>` with the appropriate GOV.UK class.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Usage](#usage)
|
|
9
|
+
- [Testing](#testing)
|
|
10
|
+
- [Contributing](#contributing)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Each component in the `govuk-tabs` group is exported individually:
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { GovukTabPanelComponent } from 'opal-frontend-common/components/govuk/govuk-tabs/govuk-tab-panel';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Wrap your tab content in this component and provide a unique ID to link it with the corresponding tab.
|
|
23
|
+
|
|
24
|
+
### Example
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<opal-lib-govuk-tab-panel id="panel-individuals">
|
|
28
|
+
<h2 class="govuk-heading-m">Individuals</h2>
|
|
29
|
+
<p>This is content for the Individuals tab.</p>
|
|
30
|
+
</opal-lib-govuk-tab-panel>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This renders:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<div class="govuk-tabs__panel" id="panel-individuals">
|
|
37
|
+
<h2 class="govuk-heading-m">Individuals</h2>
|
|
38
|
+
<p>This is content for the Individuals tab.</p>
|
|
39
|
+
</div>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Testing
|
|
43
|
+
|
|
44
|
+
Unit tests for this component can be found in the `govuk-tab-panel.component.spec.ts` file. To run the tests:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ng test
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Contributing
|
|
51
|
+
|
|
52
|
+
Feel free to submit issues or pull requests to improve this component.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
|
|
3
|
+
declare class GovukTabsPanelComponent {
|
|
4
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabsPanelComponent, never>;
|
|
5
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsPanelComponent, "opal-lib-govuk-tabs-panel", never, {}, {}, never, ["*"], true, never>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { GovukTabsPanelComponent };
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { OnInit, OnDestroy, EventEmitter } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
private readonly
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private readonly utilService;
|
|
19
|
-
_tabsPanelId: string;
|
|
20
|
-
tabsId: string;
|
|
21
|
-
set tabsPanelId(tabsPanelId: string);
|
|
22
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabPanelComponent, never>;
|
|
23
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabPanelComponent, "opal-lib-govuk-tab-panel", never, { "tabsId": { "alias": "tabsId"; "required": true; }; "tabsPanelId": { "alias": "tabsPanelId"; "required": true; }; }, {}, never, ["*"], true, never>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
declare class GovukTabsComponent implements AfterViewInit {
|
|
27
|
-
private readonly platformId;
|
|
28
|
-
tabsId: string;
|
|
4
|
+
declare class GovukTabsComponent implements OnInit, OnDestroy {
|
|
5
|
+
private readonly route;
|
|
6
|
+
private readonly ngUnsubscribe;
|
|
7
|
+
tabId: string;
|
|
8
|
+
activeTabFragmentChange: EventEmitter<string>;
|
|
9
|
+
private setupListeners;
|
|
10
|
+
/**
|
|
11
|
+
* Angular lifecycle hook that is called after the component's data-bound properties have been initialized.
|
|
12
|
+
* Initializes the component by setting up necessary event listeners.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This method is part of the Angular OnInit lifecycle interface.
|
|
16
|
+
*/
|
|
17
|
+
ngOnInit(): void;
|
|
29
18
|
/**
|
|
30
|
-
* Lifecycle hook that is called
|
|
31
|
-
*
|
|
32
|
-
* We use it to initialize the govuk-frontend component.
|
|
19
|
+
* Lifecycle hook that is called when the component is about to be destroyed.
|
|
20
|
+
* Unsubscribes from the route fragment subscription.
|
|
33
21
|
*/
|
|
34
|
-
|
|
22
|
+
ngOnDestroy(): void;
|
|
35
23
|
static ɵfac: i0.ɵɵFactoryDeclaration<GovukTabsComponent, never>;
|
|
36
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsComponent, "opal-lib-govuk-tabs", never, { "
|
|
24
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GovukTabsComponent, "opal-lib-govuk-tabs", never, { "tabId": { "alias": "tabId"; "required": true; }; }, { "activeTabFragmentChange": "activeTabFragmentChange"; }, never, ["[tab-list-items]", "[tab-panels]"], true, never>;
|
|
37
25
|
}
|
|
38
26
|
|
|
39
|
-
export {
|
|
27
|
+
export { GovukTabsComponent };
|
|
@@ -311,14 +311,17 @@ class AbstractFormBaseComponent {
|
|
|
311
311
|
return this.form.dirty && !this.formSubmitted;
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
|
-
* Sets the value of a
|
|
314
|
+
* Sets the value of a form control specified by its path and marks it as touched.
|
|
315
315
|
*
|
|
316
|
-
* @param
|
|
317
|
-
* @param
|
|
316
|
+
* @param value - The value to set for the form control.
|
|
317
|
+
* @param controlPath - The dot-delimited path to the form control within the form group.
|
|
318
318
|
*/
|
|
319
|
-
setInputValue(value,
|
|
320
|
-
this.form.
|
|
321
|
-
|
|
319
|
+
setInputValue(value, controlPath) {
|
|
320
|
+
const control = this.form.get(controlPath);
|
|
321
|
+
if (control) {
|
|
322
|
+
control.patchValue(value);
|
|
323
|
+
control.markAsTouched();
|
|
324
|
+
}
|
|
322
325
|
}
|
|
323
326
|
/**
|
|
324
327
|
* Handles the form errors for the date input fields.
|
|
@@ -422,17 +425,17 @@ class AbstractFormBaseComponent {
|
|
|
422
425
|
* @param route string of route
|
|
423
426
|
* @param nonRelative boolean indicating if route is relative to the parent
|
|
424
427
|
*/
|
|
425
|
-
|
|
428
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
429
|
+
handleRoute(route, nonRelative = false, event, routeData) {
|
|
426
430
|
if (event) {
|
|
427
431
|
event.preventDefault();
|
|
428
432
|
}
|
|
429
433
|
this.unsavedChanges.emit(this.hasUnsavedChanges());
|
|
430
|
-
|
|
431
|
-
this.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
434
|
+
const navigationExtras = {
|
|
435
|
+
...(nonRelative ? {} : { relativeTo: this.activatedRoute.parent }),
|
|
436
|
+
...(routeData !== undefined ? { state: routeData } : {}),
|
|
437
|
+
};
|
|
438
|
+
this.router.navigate([route], navigationExtras);
|
|
436
439
|
}
|
|
437
440
|
/**
|
|
438
441
|
* Handles the form submission event.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-base/abstract-form-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-base/hmcts-opal-frontend-common-components-abstract-abstract-form-base.ts"],"sourcesContent":["import { ChangeDetectorRef, Component, EventEmitter, OnDestroy, OnInit, Output, inject } from '@angular/core';\nimport { FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { Subject, takeUntil } from 'rxjs';\nimport { IAbstractFormBaseFieldError } from './interfaces/abstract-form-base-field-error.interface';\nimport { IAbstractFormBaseFieldErrors } from './interfaces/abstract-form-base-field-errors.interface';\nimport { IAbstractFormBaseFormError } from './interfaces/abstract-form-base-form-error.interface';\nimport {\n IAbstractFormBaseFormErrorSummaryMessage,\n IAbstractFormControlErrorMessage,\n IAbstractFormArrayControlValidation,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\nimport { IAbstractFormBaseHighPriorityFormError } from './interfaces/abstract-form-base-high-priority-form-error.interface';\nimport { IAbstractFormBaseForm } from './interfaces/abstract-form-base-form.interface';\nimport { UtilsService } from '@hmcts/opal-frontend-common/services/utils-service';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormBaseComponent implements OnInit, OnDestroy {\n @Output() protected unsavedChanges = new EventEmitter<boolean>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n @Output() protected formSubmit = new EventEmitter<IAbstractFormBaseForm<any>>();\n\n private readonly changeDetectorRef = inject(ChangeDetectorRef);\n private readonly router = inject(Router);\n private readonly activatedRoute = inject(ActivatedRoute);\n protected readonly utilsService = inject(UtilsService);\n\n public form!: FormGroup;\n public formControlErrorMessages!: IAbstractFormControlErrorMessage;\n public formErrorSummaryMessage!: IAbstractFormBaseFormErrorSummaryMessage[];\n protected fieldErrors!: IAbstractFormBaseFieldErrors;\n protected formSubmitted = false;\n protected readonly ngUnsubscribe = new Subject<void>();\n public formErrors!: IAbstractFormBaseFormError[];\n\n constructor() {}\n\n /**\n * Scrolls to the label of the component and focuses on the field id\n *\n * @param fieldId - Field id of the component\n */\n private scroll(fieldId: string): void {\n let labelTarget;\n let fieldElement;\n\n const autocompleteLabel = document.querySelector(`label[for=${fieldId}-autocomplete]`);\n const regularLabel = document.querySelector(`label[for=${fieldId}]`);\n const fieldsetLegend = document.querySelector(`#${fieldId} .govuk-fieldset__legend`);\n\n if (autocompleteLabel) {\n labelTarget = autocompleteLabel;\n fieldElement = document.getElementById(`${fieldId}-autocomplete`);\n } else {\n labelTarget = regularLabel || fieldsetLegend;\n fieldElement = document.getElementById(fieldId);\n }\n\n if (fieldElement) {\n if (labelTarget) {\n labelTarget.scrollIntoView({ behavior: 'smooth' });\n }\n fieldElement.focus();\n }\n }\n\n /**\n * Returns the highest priority form error from the given error keys and field errors.\n * @param errorKeys - An array of error keys.\n * @param fieldErrors - An object containing field errors.\n * @returns The highest priority form error or null if no errors are found.\n */\n private getHighestPriorityError(\n errorKeys: string[] = [],\n fieldErrors: IAbstractFormBaseFieldError = {},\n ): IAbstractFormBaseHighPriorityFormError | null {\n if (errorKeys.length && Object.keys(fieldErrors).length) {\n const errors = errorKeys.map((errorType: string) => {\n return {\n ...fieldErrors[errorType],\n type: errorType,\n };\n });\n\n const sortedErrors = [...errors].sort((a, b) => a.priority - b.priority);\n\n return sortedErrors[0];\n }\n return null;\n }\n\n /**\n * Retrieves the details of the highest priority form error for a given control path.\n * @param controlPath - The path to the control in the form.\n * @returns The details of the highest priority form error, or null if there are no errors.\n */\n private getFieldErrorDetails(controlPath: (string | number)[]): IAbstractFormBaseHighPriorityFormError | null {\n // Get the control\n const control = this.form.get(controlPath);\n\n // If we have errors\n const controlErrors = control?.errors;\n\n if (controlErrors) {\n /// Get all the error keys\n const controlKey = controlPath[controlPath.length - 1];\n const errorKeys = Object.keys(controlErrors) || [];\n const fieldErrors = this.fieldErrors[controlKey] || {};\n\n if (errorKeys.length && Object.keys(fieldErrors).length) {\n return this.getHighestPriorityError(errorKeys, fieldErrors);\n }\n }\n return null;\n }\n\n /**\n * Retrieves all form errors from the provided form and its nested form groups.\n *\n * @param form - The form group to retrieve errors from.\n * @param controlPath - An optional array representing the path to the current control within the form group.\n * @returns An array of form errors, each containing the field ID, error message, priority, and type.\n */\n private getFormErrors(form: FormGroup, controlPath: (string | number)[] = []): IAbstractFormBaseFormError[] {\n // recursively get all errors from all controls in the form including nested form group controls\n const formControls = form.controls;\n\n const errorSummary = Object.keys(formControls)\n .filter((controlName) => formControls[controlName].invalid)\n .map((controlName) => {\n const control = formControls[controlName];\n\n if (control instanceof FormGroup) {\n return this.getFormErrors(control, [...controlPath, controlName]);\n }\n\n if (control instanceof FormArray) {\n return control.controls\n .map((controlItem, index) => {\n // We only support FormGroups in FormArrays\n if (controlItem instanceof FormGroup) {\n return this.getFormErrors(controlItem, [...controlPath, controlName, index]);\n }\n\n return [];\n })\n .flat();\n }\n\n const getFieldErrorDetails = this.getFieldErrorDetails([...controlPath, controlName]);\n\n // Return the error summary entry\n // If we don't have the error details, return a null message\n return {\n fieldId: controlName,\n message: getFieldErrorDetails?.message ?? null,\n priority: getFieldErrorDetails?.priority ?? 999999999,\n type: getFieldErrorDetails?.type ?? null,\n };\n })\n .flat();\n\n // Remove any null errors\n return errorSummary.filter((item) => item?.message !== null);\n }\n\n /**\n * Sets the error messages for the form controls and error summary based on the provided form errors.\n * @param formErrors - An array of form errors containing field IDs and error messages.\n */\n private setErrorMessages(formErrors: IAbstractFormBaseFormError[]) {\n // Reset the form error messages\n this.formControlErrorMessages = {};\n this.formErrorSummaryMessage = [];\n\n // Set the form error messages based on the error summary entries\n formErrors.forEach((entry) => {\n this.formControlErrorMessages[entry.fieldId] = entry.message;\n this.formErrorSummaryMessage.push({ fieldId: entry.fieldId, message: entry.message });\n });\n }\n\n /**\n * Gets the indexes of the date fields to remove based on the form error summary message.\n * @returns An array of indexes representing the date fields to remove.\n */\n private getDateFieldsToRemoveIndexes(): number[] {\n const indexesToRemove: number[] = [];\n // The order of the field ids is important\n // this is the order in which we want to remove them\n const foundIndexes = this.getFormErrorSummaryIndex(\n ['dayOfMonth', 'monthOfYear', 'year'],\n this.formErrorSummaryMessage,\n );\n\n // Determine which indexes to remove based on the found fields\n switch (foundIndexes.length) {\n case 3:\n // All three date fields are present\n indexesToRemove.push(foundIndexes[1], foundIndexes[2]);\n break;\n case 2:\n // Two date fields are present\n indexesToRemove.push(foundIndexes[1]);\n break;\n }\n\n return indexesToRemove;\n }\n\n /**\n * Returns an array of indices corresponding to the positions of the given field IDs in the form error summary message array.\n *\n * @param fieldIds - An array of field IDs to search for in the form error summary message array.\n * @param formErrorSummaryMessage - An array of form error summary messages.\n * @returns An array of indices corresponding to the positions of the field IDs in the form error summary message array.\n */\n private getFormErrorSummaryIndex(\n fieldIds: string[],\n formErrorSummaryMessage: IAbstractFormBaseFormErrorSummaryMessage[],\n ): number[] {\n return fieldIds.reduce((acc: number[], field) => {\n const index = formErrorSummaryMessage.findIndex((error) => error.fieldId === field);\n return index !== -1 ? [...acc, index] : acc;\n }, []);\n }\n\n /**\n * Removes error summary messages from the given array based on the specified indexes.\n *\n * @param formErrorSummaryMessage - The array of error summary messages.\n * @param indexes - The indexes of the error summary messages to be removed.\n * @returns The updated array of error summary messages.\n */\n private removeErrorSummaryMessages(\n formErrorSummaryMessage: IAbstractFormBaseFormErrorSummaryMessage[],\n indexes: number[],\n ): IAbstractFormBaseFormErrorSummaryMessage[] {\n return formErrorSummaryMessage.filter((_, index) => !indexes.includes(index));\n }\n\n /**\n * Splits the form errors into two arrays based on the provided field IDs.\n * Errors with field IDs included in the fieldIds array will be moved to the removedFormErrors array,\n * while the remaining errors will be moved to the cleanFormErrors array.\n *\n * @param fieldIds - An array of field IDs to filter the form errors.\n * @param formErrors - An array of form errors to be split.\n * @returns An array containing two arrays: cleanFormErrors and removedFormErrors.\n */\n private splitFormErrors(\n fieldIds: string[],\n formErrors: IAbstractFormBaseFormError[],\n ): IAbstractFormBaseFormError[][] {\n const cleanFormErrors: IAbstractFormBaseFormError[] = [];\n const removedFormErrors: IAbstractFormBaseFormError[] = [];\n\n formErrors.forEach((error) => {\n if (fieldIds.includes(error.fieldId)) {\n removedFormErrors.push(error);\n } else {\n cleanFormErrors.push(error);\n }\n });\n\n return [cleanFormErrors, removedFormErrors];\n }\n\n /**\n * Manipulates the error message for specific fields in the formErrors array.\n * @param fields - An array of field IDs to target for error message manipulation.\n * @param messageOverride - The new error message to be used for the targeted fields.\n * @param errorType - The type of error to match for the targeted fields.\n * @param formErrors - An array of IFormError objects representing the form errors.\n * @returns An array of IFormError objects with the manipulated error messages.\n */\n private manipulateFormErrorMessage(\n fields: string[],\n messageOverride: string,\n errorType: string,\n formErrors: IAbstractFormBaseFormError[],\n ): IAbstractFormBaseFormError[] {\n const manipulatedFields: IAbstractFormBaseFormError[] = [];\n formErrors.forEach((field) => {\n if (fields.includes(field.fieldId)) {\n if (field.type === errorType) {\n manipulatedFields.push({ ...field, message: messageOverride });\n } else {\n manipulatedFields.push(field);\n }\n } else {\n manipulatedFields.push(field);\n }\n });\n\n return manipulatedFields;\n }\n\n /**\n * Retrieves the form errors with the highest priority.\n *\n * @param formErrors - An array of form errors.\n * @returns An array of form errors with the highest priority.\n */\n private getHighPriorityFormErrors(formErrors: IAbstractFormBaseFormError[]): IAbstractFormBaseFormError[] {\n // Get the lowest priority (1 is the highest priority, 3 is the lowest priority)\n const lowestPriority = Math.min(...formErrors.map((item) => item.priority));\n return formErrors.filter((item) => item.priority === lowestPriority);\n }\n\n /**\n * Focuses on the error summary element and scrolls to the top of the page.\n *\n * This method first triggers change detection to ensure the view is up-to-date.\n * It then selects the error summary element with the class 'govuk-error-summary'.\n * If the error summary element is found, it sets focus on it without scrolling the page.\n * Finally, it calls a utility service to scroll to the top of the page.\n *\n * @private\n */\n private focusAndScrollToErrorSummary(): void {\n this.changeDetectorRef.detectChanges();\n\n const errorSummary = document.querySelector('.govuk-error-summary') as HTMLElement;\n if (errorSummary) {\n errorSummary.focus({ preventScroll: true });\n this.utilsService.scrollToTop();\n }\n }\n\n /**\n * Setup listener for the form value changes and to emit hasUnsavedChanges\n */\n private setupListener(): void {\n this.form.valueChanges.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n this.unsavedChanges.emit(this.hasUnsavedChanges());\n });\n }\n\n /**\n * Adds controls to a form group.\n *\n * @param formGroup - The form group to add controls to.\n * @param controls - An array of form array control validations.\n * @param index - The index of the form array control.\n */\n protected addControlsToFormGroup(\n formGroup: FormGroup,\n controls: IAbstractFormArrayControlValidation[],\n index: number,\n ): void {\n controls.forEach(({ controlName, validators }) => {\n formGroup.addControl(`${controlName}_${index}`, new FormControl(null, validators));\n });\n }\n\n /**\n * Creates a form control with the specified validators and initial value.\n *\n * @param validators - An array of validator functions.\n * @param initialValue - The initial value for the form control. Defaults to null.\n * @returns The created form control.\n */\n protected createFormControl(validators: ValidatorFn[], initialValue: string | null = null): FormControl {\n return new FormControl(initialValue, { validators: [...validators] });\n }\n\n /**\n * Handles the error messages and populates the relevant variables\n */\n protected handleErrorMessages(): void {\n this.formErrors = this.getFormErrors(this.form);\n\n this.setErrorMessages(this.formErrors);\n\n this.formErrorSummaryMessage = this.removeErrorSummaryMessages(\n this.formErrorSummaryMessage,\n this.getDateFieldsToRemoveIndexes(),\n );\n }\n\n /**\n * Checks whether the form has been touched and submitted\n *\n * @returns boolean\n */\n protected hasUnsavedChanges(): boolean {\n return this.form.dirty && !this.formSubmitted;\n }\n\n /**\n * Sets the value of a specified form control and marks it as touched.\n *\n * @param {string} value - The value to set for the form control.\n * @param {string} control - The name of the form control to update.\n */\n protected setInputValue(value: string, control: string) {\n this.form.controls[control].patchValue(value);\n this.form.controls[control].markAsTouched();\n }\n\n /**\n * Handles the form errors for the date input fields.\n * @param formErrors - An array of form errors.\n * @returns An array of form errors with the manipulated error messages.\n */\n protected handleDateInputFormErrors() {\n const dateInputFields = ['dayOfMonth', 'monthOfYear', 'year'];\n const splitFormErrors = this.splitFormErrors(dateInputFields, this.formErrors);\n const highPriorityDateControlErrors = this.getHighPriorityFormErrors(splitFormErrors[1]);\n let manipulatedFormErrors: IAbstractFormBaseFormError[] = highPriorityDateControlErrors;\n\n // If we have more than one error then we want to manipulate the error message\n if (highPriorityDateControlErrors.length > 1) {\n manipulatedFormErrors = this.manipulateFormErrorMessage(\n dateInputFields,\n 'Please enter a DOB',\n 'required',\n manipulatedFormErrors,\n );\n }\n\n return [...splitFormErrors[0], ...manipulatedFormErrors];\n }\n\n /**\n * Sets the initial error messages for the form controls.\n *\n * @param form - The FormGroup instance.\n */\n protected setInitialErrorMessages(): void {\n const formControls = this.form.controls;\n const initialFormControlErrorMessages: IAbstractFormControlErrorMessage = {};\n\n Object.keys(formControls).forEach((controlName) => {\n initialFormControlErrorMessages[controlName] = null;\n });\n\n this.formControlErrorMessages = initialFormControlErrorMessages;\n this.formErrorSummaryMessage = [];\n }\n\n /**\n * Repopulates the search form with the data from the account enquiry search.\n * @param state - The state object containing the search form data.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected rePopulateForm(state: any): void {\n this.form.patchValue(state);\n }\n\n /**\n * Adds a new form control to the form group.\n *\n * @param controlName - The name of the control to add.\n * @param validators - An array of validators to apply to the control.\n */\n protected createControl(controlName: string, validators: ValidatorFn[]): void {\n this.form.addControl(controlName, new FormControl(null, validators));\n }\n\n /**\n * Updates the validators of an existing form control.\n *\n * @param controlName - The name of the control to update.\n * @param validators - An array of validators to apply to the control.\n */\n protected updateControl(controlName: string, validators: ValidatorFn[]): void {\n const control = this.form.get(controlName);\n if (control) {\n control.setValidators(validators);\n control.updateValueAndValidity();\n } else {\n this.createControl(controlName, validators);\n }\n }\n\n /**\n * Removes a control from the form.\n *\n * @param controlName - The name of the control to remove.\n */\n protected removeControl(controlName: string): void {\n if (this.formControlErrorMessages[controlName]) {\n this.removeControlErrors(controlName);\n }\n this.form.removeControl(controlName);\n }\n\n /**\n * Removes the error message associated with the specified control name from the formControlErrorMessages object.\n *\n * @param controlName - The name of the control for which to remove the error message.\n */\n protected removeControlErrors(controlName: string): void {\n delete this.formControlErrorMessages[controlName];\n }\n\n /**\n * Clears the search form.\n */\n public handleClearForm(): void {\n this.form.reset();\n }\n\n /**\n * Handles the scroll of the component error from the summary\n *\n * @param fieldId - Field id of the component\n */\n public scrollTo(fieldId: string): void {\n this['scroll'](fieldId);\n }\n\n /**\n * Handles route with the supplied route\n *\n * @param route string of route\n * @param nonRelative boolean indicating if route is relative to the parent\n */\n public handleRoute(route: string, nonRelative: boolean = false, event?: Event): void {\n if (event) {\n event.preventDefault();\n }\n this.unsavedChanges.emit(this.hasUnsavedChanges());\n if (nonRelative) {\n this.router.navigate([route]);\n } else {\n this.router.navigate([route], { relativeTo: this.activatedRoute.parent });\n }\n }\n\n /**\n * Handles the form submission event.\n *\n * @param event - The form submission event.\n * @returns void\n */\n public handleFormSubmit(event: SubmitEvent): void {\n this.handleErrorMessages();\n\n if (this.form.valid) {\n this.formSubmitted = true;\n const nestedFlow = event.submitter ? event.submitter.className.includes('nested-flow') : false;\n this.unsavedChanges.emit(this.hasUnsavedChanges());\n this.formSubmit.emit({ formData: this.form.value, nestedFlow: nestedFlow });\n } else {\n this.focusAndScrollToErrorSummary();\n }\n }\n\n /**\n * Handles the input event to convert all letters in the input value to uppercase.\n * This method is triggered by an input event and modifies the input value directly.\n *\n * @param event - The input event triggered by the user.\n */\n public handleUppercaseInputMask(event: Event): void {\n const input = event.target as HTMLInputElement;\n input.value = this.utilsService.upperCaseAllLetters(input.value);\n }\n\n public ngOnInit(): void {\n if (this.form) {\n this.setupListener();\n }\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAmBsB,yBAAyB,CAAA;AACzB,IAAA,cAAc,GAAG,IAAI,YAAY,EAAW;;AAE5C,IAAA,UAAU,GAAG,IAAI,YAAY,EAA8B;AAE9D,IAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC7C,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,IAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AAE/C,IAAA,IAAI;AACJ,IAAA,wBAAwB;AACxB,IAAA,uBAAuB;AACpB,IAAA,WAAW;IACX,aAAa,GAAG,KAAK;AACZ,IAAA,aAAa,GAAG,IAAI,OAAO,EAAQ;AAC/C,IAAA,UAAU;AAEjB,IAAA,WAAA,GAAA;AAEA;;;;AAIG;AACK,IAAA,MAAM,CAAC,OAAe,EAAA;AAC5B,QAAA,IAAI,WAAW;AACf,QAAA,IAAI,YAAY;QAEhB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA,UAAA,EAAa,OAAO,CAAA,cAAA,CAAgB,CAAC;QACtF,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA,UAAA,EAAa,OAAO,CAAA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A;AAAzB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,yBAAyB,iJAFnC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAH9C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;wDAEqB,cAAc,EAAA,CAAA;sBAAjC;gBAEmB,UAAU,EAAA,CAAA;sBAA7B;;;ACtBH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-components-abstract-abstract-form-base.mjs","sources":["../../../projects/opal-frontend-common/components/abstract/abstract-form-base/abstract-form-base.component.ts","../../../projects/opal-frontend-common/components/abstract/abstract-form-base/hmcts-opal-frontend-common-components-abstract-abstract-form-base.ts"],"sourcesContent":["import { ChangeDetectorRef, Component, EventEmitter, OnDestroy, OnInit, Output, inject } from '@angular/core';\nimport { FormArray, FormControl, FormGroup, ValidatorFn } from '@angular/forms';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { Subject, takeUntil } from 'rxjs';\nimport { IAbstractFormBaseFieldError } from './interfaces/abstract-form-base-field-error.interface';\nimport { IAbstractFormBaseFieldErrors } from './interfaces/abstract-form-base-field-errors.interface';\nimport { IAbstractFormBaseFormError } from './interfaces/abstract-form-base-form-error.interface';\nimport {\n IAbstractFormBaseFormErrorSummaryMessage,\n IAbstractFormControlErrorMessage,\n IAbstractFormArrayControlValidation,\n} from '@hmcts/opal-frontend-common/components/abstract/interfaces';\nimport { IAbstractFormBaseHighPriorityFormError } from './interfaces/abstract-form-base-high-priority-form-error.interface';\nimport { IAbstractFormBaseForm } from './interfaces/abstract-form-base-form.interface';\nimport { UtilsService } from '@hmcts/opal-frontend-common/services/utils-service';\n\n@Component({\n template: '',\n})\nexport abstract class AbstractFormBaseComponent implements OnInit, OnDestroy {\n @Output() protected unsavedChanges = new EventEmitter<boolean>();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n @Output() protected formSubmit = new EventEmitter<IAbstractFormBaseForm<any>>();\n\n private readonly changeDetectorRef = inject(ChangeDetectorRef);\n private readonly router = inject(Router);\n private readonly activatedRoute = inject(ActivatedRoute);\n protected readonly utilsService = inject(UtilsService);\n\n public form!: FormGroup;\n public formControlErrorMessages!: IAbstractFormControlErrorMessage;\n public formErrorSummaryMessage!: IAbstractFormBaseFormErrorSummaryMessage[];\n protected fieldErrors!: IAbstractFormBaseFieldErrors;\n protected formSubmitted = false;\n protected readonly ngUnsubscribe = new Subject<void>();\n public formErrors!: IAbstractFormBaseFormError[];\n\n constructor() {}\n\n /**\n * Scrolls to the label of the component and focuses on the field id\n *\n * @param fieldId - Field id of the component\n */\n private scroll(fieldId: string): void {\n let labelTarget;\n let fieldElement;\n\n const autocompleteLabel = document.querySelector(`label[for=${fieldId}-autocomplete]`);\n const regularLabel = document.querySelector(`label[for=${fieldId}]`);\n const fieldsetLegend = document.querySelector(`#${fieldId} .govuk-fieldset__legend`);\n\n if (autocompleteLabel) {\n labelTarget = autocompleteLabel;\n fieldElement = document.getElementById(`${fieldId}-autocomplete`);\n } else {\n labelTarget = regularLabel || fieldsetLegend;\n fieldElement = document.getElementById(fieldId);\n }\n\n if (fieldElement) {\n if (labelTarget) {\n labelTarget.scrollIntoView({ behavior: 'smooth' });\n }\n fieldElement.focus();\n }\n }\n\n /**\n * Returns the highest priority form error from the given error keys and field errors.\n * @param errorKeys - An array of error keys.\n * @param fieldErrors - An object containing field errors.\n * @returns The highest priority form error or null if no errors are found.\n */\n private getHighestPriorityError(\n errorKeys: string[] = [],\n fieldErrors: IAbstractFormBaseFieldError = {},\n ): IAbstractFormBaseHighPriorityFormError | null {\n if (errorKeys.length && Object.keys(fieldErrors).length) {\n const errors = errorKeys.map((errorType: string) => {\n return {\n ...fieldErrors[errorType],\n type: errorType,\n };\n });\n\n const sortedErrors = [...errors].sort((a, b) => a.priority - b.priority);\n\n return sortedErrors[0];\n }\n return null;\n }\n\n /**\n * Retrieves the details of the highest priority form error for a given control path.\n * @param controlPath - The path to the control in the form.\n * @returns The details of the highest priority form error, or null if there are no errors.\n */\n private getFieldErrorDetails(controlPath: (string | number)[]): IAbstractFormBaseHighPriorityFormError | null {\n // Get the control\n const control = this.form.get(controlPath);\n\n // If we have errors\n const controlErrors = control?.errors;\n\n if (controlErrors) {\n /// Get all the error keys\n const controlKey = controlPath[controlPath.length - 1];\n const errorKeys = Object.keys(controlErrors) || [];\n const fieldErrors = this.fieldErrors[controlKey] || {};\n\n if (errorKeys.length && Object.keys(fieldErrors).length) {\n return this.getHighestPriorityError(errorKeys, fieldErrors);\n }\n }\n return null;\n }\n\n /**\n * Retrieves all form errors from the provided form and its nested form groups.\n *\n * @param form - The form group to retrieve errors from.\n * @param controlPath - An optional array representing the path to the current control within the form group.\n * @returns An array of form errors, each containing the field ID, error message, priority, and type.\n */\n private getFormErrors(form: FormGroup, controlPath: (string | number)[] = []): IAbstractFormBaseFormError[] {\n // recursively get all errors from all controls in the form including nested form group controls\n const formControls = form.controls;\n\n const errorSummary = Object.keys(formControls)\n .filter((controlName) => formControls[controlName].invalid)\n .map((controlName) => {\n const control = formControls[controlName];\n\n if (control instanceof FormGroup) {\n return this.getFormErrors(control, [...controlPath, controlName]);\n }\n\n if (control instanceof FormArray) {\n return control.controls\n .map((controlItem, index) => {\n // We only support FormGroups in FormArrays\n if (controlItem instanceof FormGroup) {\n return this.getFormErrors(controlItem, [...controlPath, controlName, index]);\n }\n\n return [];\n })\n .flat();\n }\n\n const getFieldErrorDetails = this.getFieldErrorDetails([...controlPath, controlName]);\n\n // Return the error summary entry\n // If we don't have the error details, return a null message\n return {\n fieldId: controlName,\n message: getFieldErrorDetails?.message ?? null,\n priority: getFieldErrorDetails?.priority ?? 999999999,\n type: getFieldErrorDetails?.type ?? null,\n };\n })\n .flat();\n\n // Remove any null errors\n return errorSummary.filter((item) => item?.message !== null);\n }\n\n /**\n * Sets the error messages for the form controls and error summary based on the provided form errors.\n * @param formErrors - An array of form errors containing field IDs and error messages.\n */\n private setErrorMessages(formErrors: IAbstractFormBaseFormError[]) {\n // Reset the form error messages\n this.formControlErrorMessages = {};\n this.formErrorSummaryMessage = [];\n\n // Set the form error messages based on the error summary entries\n formErrors.forEach((entry) => {\n this.formControlErrorMessages[entry.fieldId] = entry.message;\n this.formErrorSummaryMessage.push({ fieldId: entry.fieldId, message: entry.message });\n });\n }\n\n /**\n * Gets the indexes of the date fields to remove based on the form error summary message.\n * @returns An array of indexes representing the date fields to remove.\n */\n private getDateFieldsToRemoveIndexes(): number[] {\n const indexesToRemove: number[] = [];\n // The order of the field ids is important\n // this is the order in which we want to remove them\n const foundIndexes = this.getFormErrorSummaryIndex(\n ['dayOfMonth', 'monthOfYear', 'year'],\n this.formErrorSummaryMessage,\n );\n\n // Determine which indexes to remove based on the found fields\n switch (foundIndexes.length) {\n case 3:\n // All three date fields are present\n indexesToRemove.push(foundIndexes[1], foundIndexes[2]);\n break;\n case 2:\n // Two date fields are present\n indexesToRemove.push(foundIndexes[1]);\n break;\n }\n\n return indexesToRemove;\n }\n\n /**\n * Returns an array of indices corresponding to the positions of the given field IDs in the form error summary message array.\n *\n * @param fieldIds - An array of field IDs to search for in the form error summary message array.\n * @param formErrorSummaryMessage - An array of form error summary messages.\n * @returns An array of indices corresponding to the positions of the field IDs in the form error summary message array.\n */\n private getFormErrorSummaryIndex(\n fieldIds: string[],\n formErrorSummaryMessage: IAbstractFormBaseFormErrorSummaryMessage[],\n ): number[] {\n return fieldIds.reduce((acc: number[], field) => {\n const index = formErrorSummaryMessage.findIndex((error) => error.fieldId === field);\n return index !== -1 ? [...acc, index] : acc;\n }, []);\n }\n\n /**\n * Removes error summary messages from the given array based on the specified indexes.\n *\n * @param formErrorSummaryMessage - The array of error summary messages.\n * @param indexes - The indexes of the error summary messages to be removed.\n * @returns The updated array of error summary messages.\n */\n private removeErrorSummaryMessages(\n formErrorSummaryMessage: IAbstractFormBaseFormErrorSummaryMessage[],\n indexes: number[],\n ): IAbstractFormBaseFormErrorSummaryMessage[] {\n return formErrorSummaryMessage.filter((_, index) => !indexes.includes(index));\n }\n\n /**\n * Splits the form errors into two arrays based on the provided field IDs.\n * Errors with field IDs included in the fieldIds array will be moved to the removedFormErrors array,\n * while the remaining errors will be moved to the cleanFormErrors array.\n *\n * @param fieldIds - An array of field IDs to filter the form errors.\n * @param formErrors - An array of form errors to be split.\n * @returns An array containing two arrays: cleanFormErrors and removedFormErrors.\n */\n private splitFormErrors(\n fieldIds: string[],\n formErrors: IAbstractFormBaseFormError[],\n ): IAbstractFormBaseFormError[][] {\n const cleanFormErrors: IAbstractFormBaseFormError[] = [];\n const removedFormErrors: IAbstractFormBaseFormError[] = [];\n\n formErrors.forEach((error) => {\n if (fieldIds.includes(error.fieldId)) {\n removedFormErrors.push(error);\n } else {\n cleanFormErrors.push(error);\n }\n });\n\n return [cleanFormErrors, removedFormErrors];\n }\n\n /**\n * Manipulates the error message for specific fields in the formErrors array.\n * @param fields - An array of field IDs to target for error message manipulation.\n * @param messageOverride - The new error message to be used for the targeted fields.\n * @param errorType - The type of error to match for the targeted fields.\n * @param formErrors - An array of IFormError objects representing the form errors.\n * @returns An array of IFormError objects with the manipulated error messages.\n */\n private manipulateFormErrorMessage(\n fields: string[],\n messageOverride: string,\n errorType: string,\n formErrors: IAbstractFormBaseFormError[],\n ): IAbstractFormBaseFormError[] {\n const manipulatedFields: IAbstractFormBaseFormError[] = [];\n formErrors.forEach((field) => {\n if (fields.includes(field.fieldId)) {\n if (field.type === errorType) {\n manipulatedFields.push({ ...field, message: messageOverride });\n } else {\n manipulatedFields.push(field);\n }\n } else {\n manipulatedFields.push(field);\n }\n });\n\n return manipulatedFields;\n }\n\n /**\n * Retrieves the form errors with the highest priority.\n *\n * @param formErrors - An array of form errors.\n * @returns An array of form errors with the highest priority.\n */\n private getHighPriorityFormErrors(formErrors: IAbstractFormBaseFormError[]): IAbstractFormBaseFormError[] {\n // Get the lowest priority (1 is the highest priority, 3 is the lowest priority)\n const lowestPriority = Math.min(...formErrors.map((item) => item.priority));\n return formErrors.filter((item) => item.priority === lowestPriority);\n }\n\n /**\n * Focuses on the error summary element and scrolls to the top of the page.\n *\n * This method first triggers change detection to ensure the view is up-to-date.\n * It then selects the error summary element with the class 'govuk-error-summary'.\n * If the error summary element is found, it sets focus on it without scrolling the page.\n * Finally, it calls a utility service to scroll to the top of the page.\n *\n * @private\n */\n private focusAndScrollToErrorSummary(): void {\n this.changeDetectorRef.detectChanges();\n\n const errorSummary = document.querySelector('.govuk-error-summary') as HTMLElement;\n if (errorSummary) {\n errorSummary.focus({ preventScroll: true });\n this.utilsService.scrollToTop();\n }\n }\n\n /**\n * Setup listener for the form value changes and to emit hasUnsavedChanges\n */\n private setupListener(): void {\n this.form.valueChanges.pipe(takeUntil(this.ngUnsubscribe)).subscribe(() => {\n this.unsavedChanges.emit(this.hasUnsavedChanges());\n });\n }\n\n /**\n * Adds controls to a form group.\n *\n * @param formGroup - The form group to add controls to.\n * @param controls - An array of form array control validations.\n * @param index - The index of the form array control.\n */\n protected addControlsToFormGroup(\n formGroup: FormGroup,\n controls: IAbstractFormArrayControlValidation[],\n index: number,\n ): void {\n controls.forEach(({ controlName, validators }) => {\n formGroup.addControl(`${controlName}_${index}`, new FormControl(null, validators));\n });\n }\n\n /**\n * Creates a form control with the specified validators and initial value.\n *\n * @param validators - An array of validator functions.\n * @param initialValue - The initial value for the form control. Defaults to null.\n * @returns The created form control.\n */\n protected createFormControl(validators: ValidatorFn[], initialValue: string | null = null): FormControl {\n return new FormControl(initialValue, { validators: [...validators] });\n }\n\n /**\n * Handles the error messages and populates the relevant variables\n */\n protected handleErrorMessages(): void {\n this.formErrors = this.getFormErrors(this.form);\n\n this.setErrorMessages(this.formErrors);\n\n this.formErrorSummaryMessage = this.removeErrorSummaryMessages(\n this.formErrorSummaryMessage,\n this.getDateFieldsToRemoveIndexes(),\n );\n }\n\n /**\n * Checks whether the form has been touched and submitted\n *\n * @returns boolean\n */\n protected hasUnsavedChanges(): boolean {\n return this.form.dirty && !this.formSubmitted;\n }\n\n /**\n * Sets the value of a form control specified by its path and marks it as touched.\n *\n * @param value - The value to set for the form control.\n * @param controlPath - The dot-delimited path to the form control within the form group.\n */\n protected setInputValue(value: string, controlPath: string): void {\n const control = this.form.get(controlPath);\n if (control) {\n control.patchValue(value);\n control.markAsTouched();\n }\n }\n\n /**\n * Handles the form errors for the date input fields.\n * @param formErrors - An array of form errors.\n * @returns An array of form errors with the manipulated error messages.\n */\n protected handleDateInputFormErrors() {\n const dateInputFields = ['dayOfMonth', 'monthOfYear', 'year'];\n const splitFormErrors = this.splitFormErrors(dateInputFields, this.formErrors);\n const highPriorityDateControlErrors = this.getHighPriorityFormErrors(splitFormErrors[1]);\n let manipulatedFormErrors: IAbstractFormBaseFormError[] = highPriorityDateControlErrors;\n\n // If we have more than one error then we want to manipulate the error message\n if (highPriorityDateControlErrors.length > 1) {\n manipulatedFormErrors = this.manipulateFormErrorMessage(\n dateInputFields,\n 'Please enter a DOB',\n 'required',\n manipulatedFormErrors,\n );\n }\n\n return [...splitFormErrors[0], ...manipulatedFormErrors];\n }\n\n /**\n * Sets the initial error messages for the form controls.\n *\n * @param form - The FormGroup instance.\n */\n protected setInitialErrorMessages(): void {\n const formControls = this.form.controls;\n const initialFormControlErrorMessages: IAbstractFormControlErrorMessage = {};\n\n Object.keys(formControls).forEach((controlName) => {\n initialFormControlErrorMessages[controlName] = null;\n });\n\n this.formControlErrorMessages = initialFormControlErrorMessages;\n this.formErrorSummaryMessage = [];\n }\n\n /**\n * Repopulates the search form with the data from the account enquiry search.\n * @param state - The state object containing the search form data.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected rePopulateForm(state: any): void {\n this.form.patchValue(state);\n }\n\n /**\n * Adds a new form control to the form group.\n *\n * @param controlName - The name of the control to add.\n * @param validators - An array of validators to apply to the control.\n */\n protected createControl(controlName: string, validators: ValidatorFn[]): void {\n this.form.addControl(controlName, new FormControl(null, validators));\n }\n\n /**\n * Updates the validators of an existing form control.\n *\n * @param controlName - The name of the control to update.\n * @param validators - An array of validators to apply to the control.\n */\n protected updateControl(controlName: string, validators: ValidatorFn[]): void {\n const control = this.form.get(controlName);\n if (control) {\n control.setValidators(validators);\n control.updateValueAndValidity();\n } else {\n this.createControl(controlName, validators);\n }\n }\n\n /**\n * Removes a control from the form.\n *\n * @param controlName - The name of the control to remove.\n */\n protected removeControl(controlName: string): void {\n if (this.formControlErrorMessages[controlName]) {\n this.removeControlErrors(controlName);\n }\n this.form.removeControl(controlName);\n }\n\n /**\n * Removes the error message associated with the specified control name from the formControlErrorMessages object.\n *\n * @param controlName - The name of the control for which to remove the error message.\n */\n protected removeControlErrors(controlName: string): void {\n delete this.formControlErrorMessages[controlName];\n }\n\n /**\n * Clears the search form.\n */\n public handleClearForm(): void {\n this.form.reset();\n }\n\n /**\n * Handles the scroll of the component error from the summary\n *\n * @param fieldId - Field id of the component\n */\n public scrollTo(fieldId: string): void {\n this['scroll'](fieldId);\n }\n\n /**\n * Handles route with the supplied route\n *\n * @param route string of route\n * @param nonRelative boolean indicating if route is relative to the parent\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public handleRoute(route: string, nonRelative: boolean = false, event?: Event, routeData?: any): void {\n if (event) {\n event.preventDefault();\n }\n\n this.unsavedChanges.emit(this.hasUnsavedChanges());\n\n const navigationExtras = {\n ...(nonRelative ? {} : { relativeTo: this.activatedRoute.parent }),\n ...(routeData !== undefined ? { state: routeData } : {}),\n };\n\n this.router.navigate([route], navigationExtras);\n }\n\n /**\n * Handles the form submission event.\n *\n * @param event - The form submission event.\n * @returns void\n */\n public handleFormSubmit(event: SubmitEvent): void {\n this.handleErrorMessages();\n\n if (this.form.valid) {\n this.formSubmitted = true;\n const nestedFlow = event.submitter ? event.submitter.className.includes('nested-flow') : false;\n this.unsavedChanges.emit(this.hasUnsavedChanges());\n this.formSubmit.emit({ formData: this.form.value, nestedFlow: nestedFlow });\n } else {\n this.focusAndScrollToErrorSummary();\n }\n }\n\n /**\n * Handles the input event to convert all letters in the input value to uppercase.\n * This method is triggered by an input event and modifies the input value directly.\n *\n * @param event - The input event triggered by the user.\n */\n public handleUppercaseInputMask(event: Event): void {\n const input = event.target as HTMLInputElement;\n input.value = this.utilsService.upperCaseAllLetters(input.value);\n }\n\n public ngOnInit(): void {\n if (this.form) {\n this.setupListener();\n }\n }\n\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAmBsB,yBAAyB,CAAA;AACzB,IAAA,cAAc,GAAG,IAAI,YAAY,EAAW;;AAE5C,IAAA,UAAU,GAAG,IAAI,YAAY,EAA8B;AAE9D,IAAA,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC7C,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AACrC,IAAA,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AAE/C,IAAA,IAAI;AACJ,IAAA,wBAAwB;AACxB,IAAA,uBAAuB;AACpB,IAAA,WAAW;IACX,aAAa,GAAG,KAAK;AACZ,IAAA,aAAa,GAAG,IAAI,OAAO,EAAQ;AAC/C,IAAA,UAAU;AAEjB,IAAA,WAAA,GAAA;AAEA;;;;AAIG;AACK,IAAA,MAAM,CAAC,OAAe,EAAA;AAC5B,QAAA,IAAI,WAAW;AACf,QAAA,IAAI,YAAY;QAEhB,MAAM,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA,UAAA,EAAa,OAAO,CAAA,cAAA,CAAgB,CAAC;QACtF,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA,UAAA,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AAC,QAAQ,EAAE;;wGAhjBX,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,yBAAyB,iJAFnC,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA;;4FAEQ,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAH9C,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA;wDAEqB,cAAc,EAAA,CAAA;sBAAjC;gBAEmB,UAAU,EAAA,CAAA;sBAA7B;;;ACtBH;;AAEG;;;;"}
|
package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, HostBinding, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { Router, ActivatedRoute } from '@angular/router';
|
|
4
|
+
|
|
5
|
+
class GovukTabsListItemComponent {
|
|
6
|
+
router = inject(Router);
|
|
7
|
+
route = inject(ActivatedRoute);
|
|
8
|
+
tabItemId;
|
|
9
|
+
tabItemFragment;
|
|
10
|
+
activeTabItemFragment;
|
|
11
|
+
get hostClass() {
|
|
12
|
+
return this.activeTabItemFragment === this.tabItemFragment
|
|
13
|
+
? 'govuk-tabs__list-item govuk-tabs__list-item--selected'
|
|
14
|
+
: 'govuk-tabs__list-item';
|
|
15
|
+
}
|
|
16
|
+
get hostId() {
|
|
17
|
+
return this.tabItemId;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Handles the click event of a sub-navigation item.
|
|
21
|
+
* @param event - The click event.
|
|
22
|
+
* @param item - The item string.
|
|
23
|
+
*/
|
|
24
|
+
handleItemClick(event, item) {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
this.router.navigate(['./'], { relativeTo: this.route, fragment: item });
|
|
27
|
+
}
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabsListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
29
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: GovukTabsListItemComponent, isStandalone: true, selector: "opal-lib-govuk-tabs-list-item, [opal-lib-govuk-tabs-list-item]", inputs: { tabItemId: "tabItemId", tabItemFragment: "tabItemFragment", activeTabItemFragment: "activeTabItemFragment" }, host: { properties: { "class": "this.hostClass", "id": "this.hostId" } }, ngImport: i0, template: "<a\n class=\"govuk-tabs__tab\"\n (click)=\"handleItemClick($event, tabItemFragment)\"\n (keyup.enter)=\"handleItemClick($event, tabItemFragment)\"\n tabindex=\"0\"\n href=\"#\"\n>\n <ng-content [linkText]></ng-content>\n</a>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
30
|
+
}
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabsListItemComponent, decorators: [{
|
|
32
|
+
type: Component,
|
|
33
|
+
args: [{ selector: 'opal-lib-govuk-tabs-list-item, [opal-lib-govuk-tabs-list-item]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<a\n class=\"govuk-tabs__tab\"\n (click)=\"handleItemClick($event, tabItemFragment)\"\n (keyup.enter)=\"handleItemClick($event, tabItemFragment)\"\n tabindex=\"0\"\n href=\"#\"\n>\n <ng-content [linkText]></ng-content>\n</a>\n" }]
|
|
34
|
+
}], propDecorators: { tabItemId: [{
|
|
35
|
+
type: Input,
|
|
36
|
+
args: [{ required: true }]
|
|
37
|
+
}], tabItemFragment: [{
|
|
38
|
+
type: Input,
|
|
39
|
+
args: [{ required: true }]
|
|
40
|
+
}], activeTabItemFragment: [{
|
|
41
|
+
type: Input,
|
|
42
|
+
args: [{ required: true }]
|
|
43
|
+
}], hostClass: [{
|
|
44
|
+
type: HostBinding,
|
|
45
|
+
args: ['class']
|
|
46
|
+
}], hostId: [{
|
|
47
|
+
type: HostBinding,
|
|
48
|
+
args: ['id']
|
|
49
|
+
}] } });
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Generated bundle index. Do not edit.
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
export { GovukTabsListItemComponent };
|
|
56
|
+
//# sourceMappingURL=hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs.map
|
package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs","sources":["../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs-list-item/govuk-tabs-list-item.component.ts","../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs-list-item/govuk-tabs-list-item.component.html","../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs-list-item/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, HostBinding, inject, Input } from '@angular/core';\nimport { Router, ActivatedRoute } from '@angular/router';\n\n@Component({\n selector: 'opal-lib-govuk-tabs-list-item, [opal-lib-govuk-tabs-list-item]',\n templateUrl: './govuk-tabs-list-item.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class GovukTabsListItemComponent {\n private readonly router = inject(Router);\n private readonly route = inject(ActivatedRoute);\n\n @Input({ required: true }) public tabItemId!: string;\n @Input({ required: true }) public tabItemFragment!: string;\n @Input({ required: true }) public activeTabItemFragment!: string;\n\n @HostBinding('class')\n get hostClass(): string {\n return this.activeTabItemFragment === this.tabItemFragment\n ? 'govuk-tabs__list-item govuk-tabs__list-item--selected'\n : 'govuk-tabs__list-item';\n }\n @HostBinding('id')\n get hostId(): string {\n return this.tabItemId;\n }\n\n /**\n * Handles the click event of a sub-navigation item.\n * @param event - The click event.\n * @param item - The item string.\n */\n public handleItemClick(event: Event, item: string): void {\n event.preventDefault();\n this.router.navigate(['./'], { relativeTo: this.route, fragment: item });\n }\n}\n","<a\n class=\"govuk-tabs__tab\"\n (click)=\"handleItemClick($event, tabItemFragment)\"\n (keyup.enter)=\"handleItemClick($event, tabItemFragment)\"\n tabindex=\"0\"\n href=\"#\"\n>\n <ng-content [linkText]></ng-content>\n</a>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAQa,0BAA0B,CAAA;AACpB,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;AACvB,IAAA,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;AAEb,IAAA,SAAS;AACT,IAAA,eAAe;AACf,IAAA,qBAAqB;AAEvD,IAAA,IACI,SAAS,GAAA;AACX,QAAA,OAAO,IAAI,CAAC,qBAAqB,KAAK,IAAI,CAAC;AACzC,cAAE;cACA,uBAAuB;;AAE7B,IAAA,IACI,MAAM,GAAA;QACR,OAAO,IAAI,CAAC,SAAS;;AAGvB;;;;AAIG;IACI,eAAe,CAAC,KAAY,EAAE,IAAY,EAAA;QAC/C,KAAK,CAAC,cAAc,EAAE;QACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wGA1B/D,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA1B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,0BAA0B,4TCRvC,0OASA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDDa,0BAA0B,EAAA,UAAA,EAAA,CAAA;kBALtC,SAAS;+BACE,gEAAgE,EAAA,eAAA,EAEzD,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,0OAAA,EAAA;8BAMb,SAAS,EAAA,CAAA;sBAA1C,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACS,eAAe,EAAA,CAAA;sBAAhD,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACS,qBAAqB,EAAA,CAAA;sBAAtD,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAGrB,SAAS,EAAA,CAAA;sBADZ,WAAW;uBAAC,OAAO;gBAOhB,MAAM,EAAA,CAAA;sBADT,WAAW;uBAAC,IAAI;;;AEtBnB;;AAEG;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class GovukTabsPanelComponent {
|
|
5
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabsPanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
6
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: GovukTabsPanelComponent, isStandalone: true, selector: "opal-lib-govuk-tabs-panel", ngImport: i0, template: "<div class=\"govuk-tabs__panel\">\n <ng-content></ng-content>\n</div>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
7
|
+
}
|
|
8
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabsPanelComponent, decorators: [{
|
|
9
|
+
type: Component,
|
|
10
|
+
args: [{ selector: 'opal-lib-govuk-tabs-panel', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"govuk-tabs__panel\">\n <ng-content></ng-content>\n</div>\n" }]
|
|
11
|
+
}] });
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generated bundle index. Do not edit.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export { GovukTabsPanelComponent };
|
|
18
|
+
//# sourceMappingURL=hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs.map
|
package/fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs","sources":["../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs-panel/govuk-tabs-panel.component.ts","../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs-panel/govuk-tabs-panel.component.html","../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs-panel/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component } from '@angular/core';\n\n@Component({\n selector: 'opal-lib-govuk-tabs-panel',\n templateUrl: './govuk-tabs-panel.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class GovukTabsPanelComponent {}\n","<div class=\"govuk-tabs__panel\">\n <ng-content></ng-content>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAOa,uBAAuB,CAAA;wGAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAvB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,uBAAuB,qFCPpC,0EAGA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDIa,uBAAuB,EAAA,UAAA,EAAA,CAAA;kBALnC,SAAS;+BACE,2BAA2B,EAAA,eAAA,EAEpB,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,0EAAA,EAAA;;;AELjD;;AAEG;;;;"}
|
|
@@ -1,95 +1,54 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { inject, EventEmitter, Output, Input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { ActivatedRoute } from '@angular/router';
|
|
4
|
+
import { Subject, takeUntil } from 'rxjs';
|
|
5
5
|
|
|
6
|
-
class
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
class GovukTabsComponent {
|
|
7
|
+
route = inject(ActivatedRoute);
|
|
8
|
+
ngUnsubscribe = new Subject();
|
|
9
|
+
tabId;
|
|
10
|
+
activeTabFragmentChange = new EventEmitter();
|
|
11
|
+
setupListeners() {
|
|
12
|
+
this.route.fragment.pipe(takeUntil(this.ngUnsubscribe)).subscribe((fragment) => {
|
|
13
|
+
if (fragment) {
|
|
14
|
+
this.activeTabFragmentChange.emit(fragment);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
12
17
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
args: [{ selector: 'opal-lib-govuk-tab-list-item, [opal-lib-govuk-tab-list-item]', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<a class=\"govuk-tabs__tab\" [href]=\"tabListItemHref\"> {{ tabListItemName }} </a>\n" }]
|
|
23
|
-
}], propDecorators: { tabsId: [{
|
|
24
|
-
type: Input,
|
|
25
|
-
args: [{ required: true }]
|
|
26
|
-
}], tabsListItemId: [{
|
|
27
|
-
type: Input,
|
|
28
|
-
args: [{ required: true }]
|
|
29
|
-
}], tabListItemHref: [{
|
|
30
|
-
type: Input,
|
|
31
|
-
args: [{ required: true }]
|
|
32
|
-
}], tabListItemName: [{
|
|
33
|
-
type: Input,
|
|
34
|
-
args: [{ required: true }]
|
|
35
|
-
}], hostClass: [{
|
|
36
|
-
type: HostBinding,
|
|
37
|
-
args: ['class']
|
|
38
|
-
}], hostId: [{
|
|
39
|
-
type: HostBinding,
|
|
40
|
-
args: ['id']
|
|
41
|
-
}] } });
|
|
42
|
-
|
|
43
|
-
class GovukTabPanelComponent {
|
|
44
|
-
utilService = inject(UtilsService);
|
|
45
|
-
_tabsPanelId;
|
|
46
|
-
tabsId;
|
|
47
|
-
set tabsPanelId(tabsPanelId) {
|
|
48
|
-
this._tabsPanelId = this.utilService.upperCaseFirstLetter(tabsPanelId);
|
|
18
|
+
/**
|
|
19
|
+
* Angular lifecycle hook that is called after the component's data-bound properties have been initialized.
|
|
20
|
+
* Initializes the component by setting up necessary event listeners.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* This method is part of the Angular OnInit lifecycle interface.
|
|
24
|
+
*/
|
|
25
|
+
ngOnInit() {
|
|
26
|
+
this.setupListeners();
|
|
49
27
|
}
|
|
50
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabPanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
51
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: GovukTabPanelComponent, isStandalone: true, selector: "opal-lib-govuk-tab-panel", inputs: { tabsId: "tabsId", tabsPanelId: "tabsPanelId" }, ngImport: i0, template: "<div class=\"govuk-tabs__panel\" [id]=\"tabsId + _tabsPanelId\">\n <ng-content></ng-content>\n</div>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
52
|
-
}
|
|
53
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabPanelComponent, decorators: [{
|
|
54
|
-
type: Component,
|
|
55
|
-
args: [{ selector: 'opal-lib-govuk-tab-panel', imports: [], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"govuk-tabs__panel\" [id]=\"tabsId + _tabsPanelId\">\n <ng-content></ng-content>\n</div>\n" }]
|
|
56
|
-
}], propDecorators: { tabsId: [{
|
|
57
|
-
type: Input,
|
|
58
|
-
args: [{ required: true }]
|
|
59
|
-
}], tabsPanelId: [{
|
|
60
|
-
type: Input,
|
|
61
|
-
args: [{ required: true }]
|
|
62
|
-
}] } });
|
|
63
|
-
|
|
64
|
-
class GovukTabsComponent {
|
|
65
|
-
platformId = inject(PLATFORM_ID);
|
|
66
|
-
tabsId;
|
|
67
28
|
/**
|
|
68
|
-
* Lifecycle hook that is called
|
|
69
|
-
*
|
|
70
|
-
* We use it to initialize the govuk-frontend component.
|
|
29
|
+
* Lifecycle hook that is called when the component is about to be destroyed.
|
|
30
|
+
* Unsubscribes from the route fragment subscription.
|
|
71
31
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
govuk.initAll();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
32
|
+
ngOnDestroy() {
|
|
33
|
+
this.ngUnsubscribe.next();
|
|
34
|
+
this.ngUnsubscribe.complete();
|
|
78
35
|
}
|
|
79
36
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
80
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: GovukTabsComponent, isStandalone: true, selector: "opal-lib-govuk-tabs", inputs: {
|
|
37
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.14", type: GovukTabsComponent, isStandalone: true, selector: "opal-lib-govuk-tabs", inputs: { tabId: "tabId" }, outputs: { activeTabFragmentChange: "activeTabFragmentChange" }, ngImport: i0, template: "<div class=\"govuk-tabs\" data-module=\"govuk-tabs\" [id]=\"tabId\">\n <h2 class=\"govuk-tabs__title\">Contents</h2>\n <ul class=\"govuk-tabs__list\">\n <ng-content select=\"[tab-list-items]\"></ng-content>\n </ul>\n <ng-content select=\"[tab-panels]\"></ng-content>\n</div>\n", changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
81
38
|
}
|
|
82
39
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: GovukTabsComponent, decorators: [{
|
|
83
40
|
type: Component,
|
|
84
|
-
args: [{ selector: 'opal-lib-govuk-tabs',
|
|
85
|
-
}], propDecorators: {
|
|
41
|
+
args: [{ selector: 'opal-lib-govuk-tabs', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"govuk-tabs\" data-module=\"govuk-tabs\" [id]=\"tabId\">\n <h2 class=\"govuk-tabs__title\">Contents</h2>\n <ul class=\"govuk-tabs__list\">\n <ng-content select=\"[tab-list-items]\"></ng-content>\n </ul>\n <ng-content select=\"[tab-panels]\"></ng-content>\n</div>\n" }]
|
|
42
|
+
}], propDecorators: { tabId: [{
|
|
86
43
|
type: Input,
|
|
87
44
|
args: [{ required: true }]
|
|
45
|
+
}], activeTabFragmentChange: [{
|
|
46
|
+
type: Output
|
|
88
47
|
}] } });
|
|
89
48
|
|
|
90
49
|
/**
|
|
91
50
|
* Generated bundle index. Do not edit.
|
|
92
51
|
*/
|
|
93
52
|
|
|
94
|
-
export {
|
|
53
|
+
export { GovukTabsComponent };
|
|
95
54
|
//# sourceMappingURL=hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs","sources":["../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs","sources":["../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs.component.ts","../../../projects/opal-frontend-common/components/govuk/govuk-tabs/govuk-tabs.component.html","../../../projects/opal-frontend-common/components/govuk/govuk-tabs/hmcts-opal-frontend-common-components-govuk-govuk-tabs.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n EventEmitter,\n Input,\n OnDestroy,\n OnInit,\n Output,\n inject,\n} from '@angular/core';\nimport { ActivatedRoute } from '@angular/router';\nimport { Subject, takeUntil } from 'rxjs';\n\n@Component({\n selector: 'opal-lib-govuk-tabs',\n templateUrl: './govuk-tabs.component.html',\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class GovukTabsComponent implements OnInit, OnDestroy {\n private readonly route = inject(ActivatedRoute);\n private readonly ngUnsubscribe = new Subject<void>();\n\n @Input({ required: true }) public tabId!: string;\n @Output() public activeTabFragmentChange = new EventEmitter<string>();\n\n private setupListeners(): void {\n this.route.fragment.pipe(takeUntil(this.ngUnsubscribe)).subscribe((fragment) => {\n if (fragment) {\n this.activeTabFragmentChange.emit(fragment);\n }\n });\n }\n\n /**\n * Angular lifecycle hook that is called after the component's data-bound properties have been initialized.\n * Initializes the component by setting up necessary event listeners.\n *\n * @remarks\n * This method is part of the Angular OnInit lifecycle interface.\n */\n public ngOnInit(): void {\n this.setupListeners();\n }\n\n /**\n * Lifecycle hook that is called when the component is about to be destroyed.\n * Unsubscribes from the route fragment subscription.\n */\n public ngOnDestroy(): void {\n this.ngUnsubscribe.next();\n this.ngUnsubscribe.complete();\n }\n}\n","<div class=\"govuk-tabs\" data-module=\"govuk-tabs\" [id]=\"tabId\">\n <h2 class=\"govuk-tabs__title\">Contents</h2>\n <ul class=\"govuk-tabs__list\">\n <ng-content select=\"[tab-list-items]\"></ng-content>\n </ul>\n <ng-content select=\"[tab-panels]\"></ng-content>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAkBa,kBAAkB,CAAA;AACZ,IAAA,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC;AAC9B,IAAA,aAAa,GAAG,IAAI,OAAO,EAAQ;AAElB,IAAA,KAAK;AACtB,IAAA,uBAAuB,GAAG,IAAI,YAAY,EAAU;IAE7D,cAAc,GAAA;QACpB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,KAAI;YAC7E,IAAI,QAAQ,EAAE;AACZ,gBAAA,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC;;AAE/C,SAAC,CAAC;;AAGJ;;;;;;AAMG;IACI,QAAQ,GAAA;QACb,IAAI,CAAC,cAAc,EAAE;;AAGvB;;;AAGG;IACI,WAAW,GAAA;AAChB,QAAA,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE;AACzB,QAAA,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;;wGAhCpB,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAlB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,kBAAkB,4KClB/B,6RAOA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;4FDWa,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAL9B,SAAS;+BACE,qBAAqB,EAAA,eAAA,EAEd,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,6RAAA,EAAA;8BAMb,KAAK,EAAA,CAAA;sBAAtC,KAAK;uBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACR,uBAAuB,EAAA,CAAA;sBAAvC;;;AEvBH;;AAEG;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-services-date-service-interfaces.mjs","sources":["../../../projects/opal-frontend-common/services/date-service/interfaces/hmcts-opal-frontend-common-services-date-service-interfaces.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;AAEG"}
|
|
@@ -58,6 +58,29 @@ class TransformationService {
|
|
|
58
58
|
}
|
|
59
59
|
return obj;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* replaces the keys in the object provided
|
|
63
|
+
* by replacing the current prefix with a new prefix.
|
|
64
|
+
* Useful when mapping object keys to a different format or structure.
|
|
65
|
+
* @param data - The data object containing key-value pairs.
|
|
66
|
+
* @param currentPrefix - The prefix to be replaced in the keys.
|
|
67
|
+
* @param replacementPrefix - The prefix to replace the current prefix with.
|
|
68
|
+
* @returns A new object with the keys replaced.
|
|
69
|
+
* @template T - The type of the form data object.
|
|
70
|
+
*/
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
replaceKeys(data, currentPrefix, replacementPrefix) {
|
|
73
|
+
if (typeof data !== 'object' || data === null) {
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
const result = {};
|
|
78
|
+
for (const [key, value] of Object.entries(data)) {
|
|
79
|
+
const newKey = key.replace(currentPrefix, replacementPrefix);
|
|
80
|
+
result[newKey] = value;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
61
84
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TransformationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
62
85
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: TransformationService, providedIn: 'root' });
|
|
63
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmcts-opal-frontend-common-services-transformation-service.mjs","sources":["../../../projects/opal-frontend-common/services/transformation-service/transformation.service.ts","../../../projects/opal-frontend-common/services/transformation-service/hmcts-opal-frontend-common-services-transformation-service.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { ITransformItem } from '@hmcts/opal-frontend-common/services/transformation-service/interfaces';\nimport { DateService } from '@hmcts/opal-frontend-common/services/date-service';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TransformationService {\n private readonly dateService = inject(DateService);\n\n /**\n * Applies a transformation to the given value based on the specified transformation configuration.\n *\n * @param value - The value to be transformed.\n * @param transformItem - The configuration for the transformation, including the type of transformation and any necessary format details.\n * @returns The transformed value, or the original value if no transformation is applied.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private applyTransformation(value: any, transformItem: ITransformItem): any {\n if (!value) {\n return value;\n }\n\n if (transformItem.transformType === 'date') {\n if (transformItem.dateInputFormat !== null && transformItem.dateOutputFormat !== null) {\n const parsedDate = this.dateService.getFromFormat(value, transformItem.dateInputFormat);\n if (this.dateService.isValidDate(parsedDate)) {\n return this.dateService.toFormat(parsedDate, transformItem.dateOutputFormat);\n }\n }\n return value;\n }\n\n return value;\n }\n\n /**\n * Transforms the values of an object based on a given transformation configuration.\n *\n * @param obj - The object whose values need to be transformed. It should be a non-null object.\n * @param toTransform - An array of transformation configurations, where each configuration specifies\n * the key to transform and the transformation details.\n * @returns The transformed object with values modified according to the transformation configuration.\n *\n * @remarks\n * - If the input `obj` is not an object or is null, it returns the input as is.\n * - The function recursively processes nested objects.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public transformObjectValues(obj: { [key: string]: any }, toTransform: ITransformItem[]): any {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n for (const [key, value] of Object.entries(obj)) {\n const transformItem = toTransform.find((item) => item.key === key);\n\n if (transformItem) {\n obj[key] = this.applyTransformation(value, transformItem);\n } else if (Array.isArray(value)) {\n obj[key] = value.map((item) =>\n typeof item === 'object' ? this.transformObjectValues(item, toTransform) : item,\n );\n } else if (typeof value === 'object') {\n obj[key] = this.transformObjectValues(value, toTransform); // Recursive call\n }\n }\n return obj;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAOa,qBAAqB,CAAA;AACf,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AAElD;;;;;;AAMG;;IAEK,mBAAmB,CAAC,KAAU,EAAE,aAA6B,EAAA;QACnE,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,OAAO,KAAK;;AAGd,QAAA,IAAI,aAAa,CAAC,aAAa,KAAK,MAAM,EAAE;AAC1C,YAAA,IAAI,aAAa,CAAC,eAAe,KAAK,IAAI,IAAI,aAAa,CAAC,gBAAgB,KAAK,IAAI,EAAE;AACrF,gBAAA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC;gBACvF,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;AAC5C,oBAAA,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,gBAAgB,CAAC;;;AAGhF,YAAA,OAAO,KAAK;;AAGd,QAAA,OAAO,KAAK;;AAGd;;;;;;;;;;;AAWG;;IAEI,qBAAqB,CAAC,GAA2B,EAAE,WAA6B,EAAA;QACrF,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE;AAC3C,YAAA,OAAO,GAAG;;AAGZ,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,YAAA,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC;YAElE,IAAI,aAAa,EAAE;AACjB,gBAAA,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,aAAa,CAAC;;AACpD,iBAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAC/B,gBAAA,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KACxB,OAAO,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,WAAW,CAAC,GAAG,IAAI,CAChF;;AACI,iBAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACpC,gBAAA,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;;;AAG9D,QAAA,OAAO,GAAG;;
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-services-transformation-service.mjs","sources":["../../../projects/opal-frontend-common/services/transformation-service/transformation.service.ts","../../../projects/opal-frontend-common/services/transformation-service/hmcts-opal-frontend-common-services-transformation-service.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { ITransformItem } from '@hmcts/opal-frontend-common/services/transformation-service/interfaces';\nimport { DateService } from '@hmcts/opal-frontend-common/services/date-service';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class TransformationService {\n private readonly dateService = inject(DateService);\n\n /**\n * Applies a transformation to the given value based on the specified transformation configuration.\n *\n * @param value - The value to be transformed.\n * @param transformItem - The configuration for the transformation, including the type of transformation and any necessary format details.\n * @returns The transformed value, or the original value if no transformation is applied.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private applyTransformation(value: any, transformItem: ITransformItem): any {\n if (!value) {\n return value;\n }\n\n if (transformItem.transformType === 'date') {\n if (transformItem.dateInputFormat !== null && transformItem.dateOutputFormat !== null) {\n const parsedDate = this.dateService.getFromFormat(value, transformItem.dateInputFormat);\n if (this.dateService.isValidDate(parsedDate)) {\n return this.dateService.toFormat(parsedDate, transformItem.dateOutputFormat);\n }\n }\n return value;\n }\n\n return value;\n }\n\n /**\n * Transforms the values of an object based on a given transformation configuration.\n *\n * @param obj - The object whose values need to be transformed. It should be a non-null object.\n * @param toTransform - An array of transformation configurations, where each configuration specifies\n * the key to transform and the transformation details.\n * @returns The transformed object with values modified according to the transformation configuration.\n *\n * @remarks\n * - If the input `obj` is not an object or is null, it returns the input as is.\n * - The function recursively processes nested objects.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public transformObjectValues(obj: { [key: string]: any }, toTransform: ITransformItem[]): any {\n if (typeof obj !== 'object' || obj === null) {\n return obj;\n }\n\n for (const [key, value] of Object.entries(obj)) {\n const transformItem = toTransform.find((item) => item.key === key);\n\n if (transformItem) {\n obj[key] = this.applyTransformation(value, transformItem);\n } else if (Array.isArray(value)) {\n obj[key] = value.map((item) =>\n typeof item === 'object' ? this.transformObjectValues(item, toTransform) : item,\n );\n } else if (typeof value === 'object') {\n obj[key] = this.transformObjectValues(value, toTransform); // Recursive call\n }\n }\n return obj;\n }\n\n /**\n * replaces the keys in the object provided\n * by replacing the current prefix with a new prefix.\n * Useful when mapping object keys to a different format or structure.\n * @param data - The data object containing key-value pairs.\n * @param currentPrefix - The prefix to be replaced in the keys.\n * @param replacementPrefix - The prefix to replace the current prefix with.\n * @returns A new object with the keys replaced.\n * @template T - The type of the form data object.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public replaceKeys<T extends object>(data: T, currentPrefix: string, replacementPrefix: string): Record<string, any> {\n if (typeof data !== 'object' || data === null) {\n return {};\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const result: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const newKey = key.replace(currentPrefix, replacementPrefix);\n result[newKey] = value;\n }\n\n return result;\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAOa,qBAAqB,CAAA;AACf,IAAA,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AAElD;;;;;;AAMG;;IAEK,mBAAmB,CAAC,KAAU,EAAE,aAA6B,EAAA;QACnE,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,OAAO,KAAK;;AAGd,QAAA,IAAI,aAAa,CAAC,aAAa,KAAK,MAAM,EAAE;AAC1C,YAAA,IAAI,aAAa,CAAC,eAAe,KAAK,IAAI,IAAI,aAAa,CAAC,gBAAgB,KAAK,IAAI,EAAE;AACrF,gBAAA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC;gBACvF,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;AAC5C,oBAAA,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,gBAAgB,CAAC;;;AAGhF,YAAA,OAAO,KAAK;;AAGd,QAAA,OAAO,KAAK;;AAGd;;;;;;;;;;;AAWG;;IAEI,qBAAqB,CAAC,GAA2B,EAAE,WAA6B,EAAA;QACrF,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE;AAC3C,YAAA,OAAO,GAAG;;AAGZ,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAC9C,YAAA,MAAM,aAAa,GAAG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AA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,cAFpB,MAAM,EAAA,CAAA;;4FAEP,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAHjC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACND;;AAEG;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a validator function that tests a form control's value against a given regular expression.
|
|
3
|
+
* If the value does not match the pattern, it returns a validation error with the provided error key.
|
|
4
|
+
* Returns null for empty or valid values.
|
|
5
|
+
*
|
|
6
|
+
* @param pattern - The regular expression to test the control's value against.
|
|
7
|
+
* @param errorKey - The key to use in the returned validation error object (defaults to 'patternInvalid').
|
|
8
|
+
* @returns A ValidatorFn that returns a validation error object or null.
|
|
9
|
+
*/
|
|
10
|
+
function patternValidator(pattern, errorKey = 'patternInvalid') {
|
|
11
|
+
return (control) => {
|
|
12
|
+
if (!control.value) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return pattern.test(control.value)
|
|
16
|
+
? null
|
|
17
|
+
: {
|
|
18
|
+
[errorKey]: true,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generated bundle index. Do not edit.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export { patternValidator };
|
|
28
|
+
//# sourceMappingURL=hmcts-opal-frontend-common-validators-pattern-validator.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmcts-opal-frontend-common-validators-pattern-validator.mjs","sources":["../../../projects/opal-frontend-common/validators/pattern-validator/pattern.validator.ts","../../../projects/opal-frontend-common/validators/pattern-validator/hmcts-opal-frontend-common-validators-pattern-validator.ts"],"sourcesContent":["import { AbstractControl, ValidationErrors, ValidatorFn } from '@angular/forms';\n\n/**\n * Returns a validator function that tests a form control's value against a given regular expression.\n * If the value does not match the pattern, it returns a validation error with the provided error key.\n * Returns null for empty or valid values.\n *\n * @param pattern - The regular expression to test the control's value against.\n * @param errorKey - The key to use in the returned validation error object (defaults to 'patternInvalid').\n * @returns A ValidatorFn that returns a validation error object or null.\n */\nexport function patternValidator(pattern: RegExp, errorKey: string = 'patternInvalid'): ValidatorFn {\n return (control: AbstractControl): ValidationErrors | null => {\n if (!control.value) {\n return null;\n }\n\n return pattern.test(control.value)\n ? null\n : {\n [errorKey]: true,\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEA;;;;;;;;AAQG;SACa,gBAAgB,CAAC,OAAe,EAAE,WAAmB,gBAAgB,EAAA;IACnF,OAAO,CAAC,OAAwB,KAA6B;AAC3D,QAAA,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;AAClB,YAAA,OAAO,IAAI;;AAGb,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK;AAC/B,cAAE;AACF,cAAE;gBACE,CAAC,QAAQ,GAAG,IAAI;aACjB;AACP,KAAC;AACH;;ACvBA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmcts/opal-frontend-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/common": "^18.2.0 || ^19.0.0",
|
|
@@ -241,6 +241,16 @@
|
|
|
241
241
|
"types": "./components/govuk/govuk-tabs/index.d.ts",
|
|
242
242
|
"default": "./fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs.mjs"
|
|
243
243
|
},
|
|
244
|
+
"./components/govuk/govuk-tabs/govuk-tabs-list-item": {
|
|
245
|
+
"import": "./fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs",
|
|
246
|
+
"types": "./components/govuk/govuk-tabs/govuk-tabs-list-item/index.d.ts",
|
|
247
|
+
"default": "./fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-list-item.mjs"
|
|
248
|
+
},
|
|
249
|
+
"./components/govuk/govuk-tabs/govuk-tabs-panel": {
|
|
250
|
+
"import": "./fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs",
|
|
251
|
+
"types": "./components/govuk/govuk-tabs/govuk-tabs-panel/index.d.ts",
|
|
252
|
+
"default": "./fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tabs-govuk-tabs-panel.mjs"
|
|
253
|
+
},
|
|
244
254
|
"./components/govuk/govuk-tags": {
|
|
245
255
|
"import": "./fesm2022/hmcts-opal-frontend-common-components-govuk-govuk-tags.mjs"
|
|
246
256
|
},
|
|
@@ -475,6 +485,11 @@
|
|
|
475
485
|
"types": "./services/date-service/index.d.ts",
|
|
476
486
|
"default": "./fesm2022/hmcts-opal-frontend-common-services-date-service.mjs"
|
|
477
487
|
},
|
|
488
|
+
"./services/date-service/interfaces": {
|
|
489
|
+
"import": "./fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs",
|
|
490
|
+
"types": "./services/date-service/interfaces/index.d.ts",
|
|
491
|
+
"default": "./fesm2022/hmcts-opal-frontend-common-services-date-service-interfaces.mjs"
|
|
492
|
+
},
|
|
478
493
|
"./services/permissions-service": {
|
|
479
494
|
"import": "./fesm2022/hmcts-opal-frontend-common-services-permissions-service.mjs",
|
|
480
495
|
"types": "./services/permissions-service/index.d.ts",
|
|
@@ -618,6 +633,11 @@
|
|
|
618
633
|
"types": "./validators/past-date/index.d.ts",
|
|
619
634
|
"default": "./fesm2022/hmcts-opal-frontend-common-validators-past-date.mjs"
|
|
620
635
|
},
|
|
636
|
+
"./validators/pattern-validator": {
|
|
637
|
+
"import": "./fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs",
|
|
638
|
+
"types": "./validators/pattern-validator/index.d.ts",
|
|
639
|
+
"default": "./fesm2022/hmcts-opal-frontend-common-validators-pattern-validator.mjs"
|
|
640
|
+
},
|
|
621
641
|
"./validators/special-characters": {
|
|
622
642
|
"import": "./fesm2022/hmcts-opal-frontend-common-validators-special-characters.mjs",
|
|
623
643
|
"types": "./validators/special-characters/index.d.ts",
|
|
@@ -26,6 +26,17 @@ declare class TransformationService {
|
|
|
26
26
|
transformObjectValues(obj: {
|
|
27
27
|
[key: string]: any;
|
|
28
28
|
}, toTransform: ITransformItem[]): any;
|
|
29
|
+
/**
|
|
30
|
+
* replaces the keys in the object provided
|
|
31
|
+
* by replacing the current prefix with a new prefix.
|
|
32
|
+
* Useful when mapping object keys to a different format or structure.
|
|
33
|
+
* @param data - The data object containing key-value pairs.
|
|
34
|
+
* @param currentPrefix - The prefix to be replaced in the keys.
|
|
35
|
+
* @param replacementPrefix - The prefix to replace the current prefix with.
|
|
36
|
+
* @returns A new object with the keys replaced.
|
|
37
|
+
* @template T - The type of the form data object.
|
|
38
|
+
*/
|
|
39
|
+
replaceKeys<T extends object>(data: T, currentPrefix: string, replacementPrefix: string): Record<string, any>;
|
|
29
40
|
static ɵfac: i0.ɵɵFactoryDeclaration<TransformationService, never>;
|
|
30
41
|
static ɵprov: i0.ɵɵInjectableDeclaration<TransformationService>;
|
|
31
42
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ValidatorFn } from '@angular/forms';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns a validator function that tests a form control's value against a given regular expression.
|
|
5
|
+
* If the value does not match the pattern, it returns a validation error with the provided error key.
|
|
6
|
+
* Returns null for empty or valid values.
|
|
7
|
+
*
|
|
8
|
+
* @param pattern - The regular expression to test the control's value against.
|
|
9
|
+
* @param errorKey - The key to use in the returned validation error object (defaults to 'patternInvalid').
|
|
10
|
+
* @returns A ValidatorFn that returns a validation error object or null.
|
|
11
|
+
*/
|
|
12
|
+
declare function patternValidator(pattern: RegExp, errorKey?: string): ValidatorFn;
|
|
13
|
+
|
|
14
|
+
export { patternValidator };
|