@chat21/chat21-web-widget 5.1.33 → 5.1.34-rc1
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/.angular-mcp-cache/package.json +1 -0
- package/.cursor/angular18-accessibility-auditor-skill.md +442 -0
- package/.cursor/mcp.json +15 -0
- package/.github/workflows/docker-community-push-latest.yml +23 -13
- package/.github/workflows/docker-image-tag-community-tag-push.yml +22 -12
- package/.github/workflows/playwright.yml +27 -0
- package/CHANGELOG.md +130 -6
- package/Dockerfile +4 -5
- package/angular.json +24 -4
- package/docs/changelog/this-branch.md +36 -0
- package/env.sample +3 -2
- package/mocks/voice-websocket-mock/server.cjs +245 -0
- package/nginx.conf +22 -2
- package/package.json +10 -3
- package/playwright.config.ts +41 -0
- package/src/app/app.component.html +2 -2
- package/src/app/app.component.scss +25 -14
- package/src/app/app.component.spec.ts +21 -6
- package/src/app/app.component.ts +10 -9
- package/src/app/app.module.ts +15 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.html +25 -11
- package/src/app/component/conversation-detail/conversation/conversation.component.scss +40 -2
- package/src/app/component/conversation-detail/conversation/conversation.component.spec.ts +644 -75
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +100 -14
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.html +25 -13
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.spec.ts +123 -5
- package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +1 -0
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.html +23 -10
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +33 -2
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.spec.ts +242 -149
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +8 -6
- package/src/app/component/conversation-detail/conversation-emojii/conversation-emojii.component.spec.ts +53 -3
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +200 -96
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +211 -6
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.spec.ts +452 -78
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +291 -76
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.html +113 -53
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.scss +12 -4
- package/src/app/component/conversation-detail/conversation-header/conversation-header.component.spec.ts +274 -29
- package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.html +23 -9
- package/src/app/component/conversation-detail/conversation-internal-frame/conversation-internal-frame.component.spec.ts +80 -8
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.html +29 -23
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.spec.ts +185 -16
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +34 -14
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.html +46 -0
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.scss +83 -0
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.ts +192 -0
- package/src/app/component/error-alert/error-alert.component.spec.ts +65 -5
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.html +16 -7
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.scss +21 -0
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.spec.ts +89 -7
- package/src/app/component/form/form-builder/form-builder.component.html +1 -1
- package/src/app/component/form/form-builder/form-builder.component.spec.ts +163 -21
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.html +8 -4
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.scss +10 -5
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.spec.ts +90 -16
- package/src/app/component/form/inputs/form-checkbox/form-checkbox.component.ts +26 -0
- package/src/app/component/form/inputs/form-label/form-label.component.spec.ts +45 -11
- package/src/app/component/form/inputs/form-radio-button/form-radio-button.component.spec.ts +24 -6
- package/src/app/component/form/inputs/form-select/form-select.component.spec.ts +14 -5
- package/src/app/component/form/inputs/form-text/form-text.component.html +14 -12
- package/src/app/component/form/inputs/form-text/form-text.component.scss +11 -1
- package/src/app/component/form/inputs/form-text/form-text.component.spec.ts +113 -17
- package/src/app/component/form/inputs/form-text/form-text.component.ts +35 -3
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.html +13 -11
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.scss +6 -5
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.spec.ts +149 -13
- package/src/app/component/form/inputs/form-textarea/form-textarea.component.ts +26 -0
- package/src/app/component/form/prechat-form/prechat-form.component.html +14 -11
- package/src/app/component/form/prechat-form/prechat-form.component.spec.ts +102 -10
- package/src/app/component/form/prechat-form/prechat-form.component.ts +8 -1
- package/src/app/component/form/prechat-form-test-mock.ts +35 -0
- package/src/app/component/home/home.component.html +38 -31
- package/src/app/component/home/home.component.scss +4 -2
- package/src/app/component/home/home.component.spec.ts +226 -11
- package/src/app/component/home-conversations/home-conversations.component.html +30 -26
- package/src/app/component/home-conversations/home-conversations.component.scss +3 -0
- package/src/app/component/home-conversations/home-conversations.component.spec.ts +212 -36
- package/src/app/component/last-message/last-message.component.html +15 -9
- package/src/app/component/last-message/last-message.component.scss +16 -2
- package/src/app/component/last-message/last-message.component.spec.ts +204 -23
- package/src/app/component/last-message/last-message.component.ts +4 -1
- package/src/app/component/launcher-button/launcher-button.component.html +8 -13
- package/src/app/component/launcher-button/launcher-button.component.spec.ts +104 -8
- package/src/app/component/list-all-conversations/list-all-conversations.component.html +12 -17
- package/src/app/component/list-all-conversations/list-all-conversations.component.scss +2 -0
- package/src/app/component/list-conversations/list-conversations.component.html +22 -22
- package/src/app/component/menu-options/menu-options.component.html +30 -20
- package/src/app/component/menu-options/menu-options.component.spec.ts +125 -9
- package/src/app/component/message/audio/audio.component.html +13 -15
- package/src/app/component/message/audio/audio.component.spec.ts +140 -5
- package/src/app/component/message/audio/audio.component.ts +1 -5
- package/src/app/component/message/audio-sync/audio-sync.component.html +18 -0
- package/src/app/component/message/audio-sync/audio-sync.component.scss +65 -0
- package/src/app/component/message/audio-sync/audio-sync.component.spec.ts +103 -0
- package/src/app/component/message/audio-sync/audio-sync.component.ts +643 -0
- package/src/app/component/message/avatar/avatar.component.html +2 -2
- package/src/app/component/message/avatar/avatar.component.spec.ts +99 -7
- package/src/app/component/message/bubble-message/bubble-message.component.html +43 -51
- package/src/app/component/message/bubble-message/bubble-message.component.scss +59 -1
- package/src/app/component/message/bubble-message/bubble-message.component.spec.ts +154 -57
- package/src/app/component/message/bubble-message/bubble-message.component.ts +152 -109
- package/src/app/component/message/buttons/action-button/action-button.component.html +3 -4
- package/src/app/component/message/buttons/action-button/action-button.component.spec.ts +49 -5
- package/src/app/component/message/buttons/link-button/link-button.component.scss +5 -8
- package/src/app/component/message/buttons/link-button/link-button.component.spec.ts +50 -5
- package/src/app/component/message/buttons/text-button/text-button.component.spec.ts +44 -5
- package/src/app/component/message/carousel/carousel.component.html +29 -16
- package/src/app/component/message/carousel/carousel.component.scss +20 -8
- package/src/app/component/message/carousel/carousel.component.spec.ts +80 -3
- package/src/app/component/message/carousel/carousel.component.ts +16 -0
- package/src/app/component/message/frame/frame.component.html +9 -4
- package/src/app/component/message/frame/frame.component.spec.ts +34 -15
- package/src/app/component/message/frame/frame.component.ts +7 -2
- package/src/app/component/message/html/html.component.html +1 -1
- package/src/app/component/message/html/html.component.scss +1 -1
- package/src/app/component/message/html/html.component.spec.ts +24 -7
- package/src/app/component/message/image/image.component.html +12 -10
- package/src/app/component/message/image/image.component.scss +16 -0
- package/src/app/component/message/image/image.component.spec.ts +101 -15
- package/src/app/component/message/image/image.component.ts +90 -51
- package/src/app/component/message/info-message/info-message.component.spec.ts +26 -14
- package/src/app/component/message/json-sources/json-sources.component.html +38 -0
- package/src/app/component/message/json-sources/json-sources.component.scss +201 -0
- package/src/app/component/message/json-sources/json-sources.component.ts +89 -0
- package/src/app/component/message/like-unlike/like-unlike.component.html +7 -9
- package/src/app/component/message/like-unlike/like-unlike.component.spec.ts +31 -3
- package/src/app/component/message/return-receipt/return-receipt.component.spec.ts +38 -17
- package/src/app/component/message/text/text.component.html +3 -3
- package/src/app/component/message/text/text.component.scss +80 -86
- package/src/app/component/message/text/text.component.spec.ts +106 -13
- package/src/app/component/message-attachment/message-attachment.component.spec.ts +134 -13
- package/src/app/component/selection-department/selection-department.component.html +21 -23
- package/src/app/component/selection-department/selection-department.component.spec.ts +159 -14
- package/src/app/component/selection-department/selection-department.component.ts +8 -1
- package/src/app/component/send-button/send-button.component.html +5 -13
- package/src/app/component/send-button/send-button.component.spec.ts +2 -2
- package/src/app/component/star-rating-widget/star-rating-widget.component.html +51 -81
- package/src/app/directives/tooltip.directive.spec.ts +8 -4
- package/src/app/modals/confirm-close/confirm-close.component.html +20 -8
- package/src/app/modals/confirm-close/confirm-close.component.scss +3 -0
- package/src/app/modals/confirm-close/confirm-close.component.spec.ts +13 -4
- package/src/app/modals/confirm-close/confirm-close.component.ts +8 -1
- package/src/app/pipe/html-entites-encode.pipe.spec.ts +35 -2
- package/src/app/pipe/marked.pipe.spec.ts +38 -2
- package/src/app/pipe/marked.pipe.ts +51 -41
- package/src/app/providers/app-config.service.ts +4 -2
- package/src/app/providers/brand.service.spec.ts +23 -2
- package/src/app/providers/brand.service.ts +1 -1
- package/src/app/providers/global-settings.service.spec.ts +1009 -14
- package/src/app/providers/global-settings.service.ts +82 -2
- package/src/app/providers/json-sources-parser.service.ts +175 -0
- package/src/app/providers/translator.service.ts +26 -6
- package/src/app/providers/tts-audio-playback-coordinator.service.spec.ts +117 -0
- package/src/app/providers/tts-audio-playback-coordinator.service.ts +109 -0
- package/src/app/providers/url-preview.service.ts +82 -0
- package/src/app/providers/voice/STT&TTS/openai-voice.config.ts +12 -0
- package/src/app/providers/voice/STT&TTS/openai-voice.provider.ts +171 -0
- package/src/app/providers/voice/STT&TTS/speech-provider.abstract.ts +39 -0
- package/src/app/providers/voice/audio.types.ts +40 -0
- package/src/app/providers/voice/vad.service.spec.ts +28 -0
- package/src/app/providers/voice/vad.service.ts +70 -0
- package/src/app/providers/voice/voice-streaming.service.spec.ts +23 -0
- package/src/app/providers/voice/voice-streaming.service.ts +702 -0
- package/src/app/providers/voice/voice-streaming.types.ts +112 -0
- package/src/app/providers/voice/voice.service.spec.ts +227 -0
- package/src/app/providers/voice/voice.service.ts +973 -0
- package/src/app/sass/_variables.scss +3 -0
- package/src/app/sass/animations.scss +19 -1
- package/src/app/shims/onnxruntime-web-wasm.ts +4 -0
- package/src/app/utils/globals.ts +21 -1
- package/src/app/utils/json-sources-utils.ts +27 -0
- package/src/app/utils/url-utils.ts +98 -0
- package/src/app/utils/utils-resources.ts +1 -1
- package/src/assets/i18n/en.json +106 -99
- package/src/assets/i18n/es.json +107 -100
- package/src/assets/i18n/fr.json +107 -100
- package/src/assets/i18n/it.json +107 -98
- package/src/assets/onnx/ort-wasm-simd-threaded.mjs +59 -0
- package/src/assets/onnx/ort-wasm-simd-threaded.wasm +0 -0
- package/src/assets/sounds/keyboard.mp3 +0 -0
- package/src/assets/twp/chatbot-panel.html +3 -1
- package/src/assets/twp/index-dev.html +18 -0
- package/src/assets/twp/tiledesk_widget_files/widget-css-override-example.css +14 -0
- package/src/assets/vad/silero_vad_legacy.onnx +0 -0
- package/src/assets/vad/vad.worklet.bundle.min.js +1 -0
- package/src/chat21-core/models/message.ts +2 -1
- package/src/chat21-core/providers/chat-manager.spec.ts +72 -0
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +3 -2
- package/src/chat21-core/providers/mqtt/mqtt-conversation-handler.ts +12 -0
- package/src/chat21-core/providers/scripts/script.service.spec.ts +12 -2
- package/src/chat21-core/providers/tiledesk/tiledesk-requests.service.ts +1 -1
- package/src/chat21-core/utils/constants.ts +4 -0
- package/src/chat21-core/utils/utils-message.ts +45 -6
- package/src/chat21-core/utils/utils.ts +5 -2
- package/src/widget-config-template.json +4 -1
- package/src/widget-config.json +4 -1
- package/tests/widget-form-rich.spec.ts +67 -0
- package/tests/widget-index-dev-settings.spec.ts +52 -0
- package/tests/widget-twp-iframe.spec.ts +39 -0
- package/tsconfig.json +5 -0
|
@@ -1,30 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Component } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
3
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
4
|
+
import { By } from '@angular/platform-browser';
|
|
4
5
|
|
|
6
|
+
import { FormArray } from 'src/chat21-core/models/formArray';
|
|
5
7
|
import { FormCheckboxComponent } from './form-checkbox.component';
|
|
6
8
|
|
|
9
|
+
@Component({
|
|
10
|
+
template: `
|
|
11
|
+
<form [formGroup]="form">
|
|
12
|
+
<chat-form-checkbox
|
|
13
|
+
[element]="element"
|
|
14
|
+
controlName="acceptTerms"
|
|
15
|
+
[translationErrorLabelMap]="translationErrorLabelMap"
|
|
16
|
+
[stylesMap]="stylesMap"
|
|
17
|
+
[hasSubmitted]="hasSubmitted"
|
|
18
|
+
></chat-form-checkbox>
|
|
19
|
+
</form>`,
|
|
20
|
+
})
|
|
21
|
+
class FormCheckboxHostComponent {
|
|
22
|
+
form = new FormBuilder().group({
|
|
23
|
+
acceptTerms: [false, [Validators.requiredTrue]],
|
|
24
|
+
});
|
|
25
|
+
element = {
|
|
26
|
+
name: 'acceptTerms',
|
|
27
|
+
type: 'checkbox',
|
|
28
|
+
text: 'I accept the terms',
|
|
29
|
+
mandatory: true,
|
|
30
|
+
tabIndex: 1500,
|
|
31
|
+
} as FormArray;
|
|
32
|
+
stylesMap = new Map<string, string>([
|
|
33
|
+
['themeColor', '#2a6ac1'],
|
|
34
|
+
['foregroundColor', '#ffffff'],
|
|
35
|
+
]);
|
|
36
|
+
translationErrorLabelMap = new Map<string, string>([
|
|
37
|
+
['LABEL_ERROR_FIELD_REQUIRED', 'You must accept'],
|
|
38
|
+
]);
|
|
39
|
+
hasSubmitted = false;
|
|
40
|
+
}
|
|
41
|
+
|
|
7
42
|
describe('FormCheckboxComponent', () => {
|
|
8
|
-
let
|
|
9
|
-
let
|
|
10
|
-
|
|
43
|
+
let fixture: ComponentFixture<FormCheckboxHostComponent>;
|
|
44
|
+
let host: FormCheckboxHostComponent;
|
|
45
|
+
|
|
11
46
|
beforeEach(waitForAsync(() => {
|
|
12
47
|
TestBed.configureTestingModule({
|
|
13
|
-
declarations: [ FormCheckboxComponent
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
.compileComponents();
|
|
48
|
+
declarations: [FormCheckboxHostComponent, FormCheckboxComponent],
|
|
49
|
+
imports: [ReactiveFormsModule],
|
|
50
|
+
}).compileComponents();
|
|
17
51
|
}));
|
|
18
52
|
|
|
19
53
|
beforeEach(() => {
|
|
20
|
-
fixture = TestBed.createComponent(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
54
|
+
fixture = TestBed.createComponent(FormCheckboxHostComponent);
|
|
55
|
+
host = fixture.componentInstance;
|
|
56
|
+
fixture.detectChanges();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should create with checkbox wired to label for=id', () => {
|
|
60
|
+
const box = fixture.nativeElement.querySelector(
|
|
61
|
+
'input#c21-prechat-acceptTerms',
|
|
62
|
+
) as HTMLInputElement;
|
|
63
|
+
expect(box.type).toBe('checkbox');
|
|
64
|
+
const label = fixture.nativeElement.querySelector(
|
|
65
|
+
'label[for="c21-prechat-acceptTerms"]',
|
|
66
|
+
) as HTMLLabelElement;
|
|
67
|
+
expect(label.textContent?.trim()).toBe('I accept the terms');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should expose aria-invalid after submit when still unchecked', () => {
|
|
71
|
+
host.hasSubmitted = true;
|
|
24
72
|
fixture.detectChanges();
|
|
73
|
+
const box = fixture.nativeElement.querySelector(
|
|
74
|
+
'input#c21-prechat-acceptTerms',
|
|
75
|
+
) as HTMLInputElement;
|
|
76
|
+
expect(box.getAttribute('aria-invalid')).toBe('true');
|
|
77
|
+
expect(box.getAttribute('aria-describedby')).toBe('c21-prechat-acceptTerms-errors');
|
|
78
|
+
const alert = fixture.nativeElement.querySelector(
|
|
79
|
+
'#c21-prechat-acceptTerms-errors',
|
|
80
|
+
) as HTMLElement;
|
|
81
|
+
expect(alert.textContent).toContain('You must accept');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('onEnterPressed should bubble intent to parent form-builder via output', () => {
|
|
85
|
+
const inner = fixture.debugElement.query(By.directive(FormCheckboxComponent))
|
|
86
|
+
.componentInstance as FormCheckboxComponent;
|
|
87
|
+
spyOn(inner.onKeyEnterPressed, 'emit');
|
|
88
|
+
inner.onEnterPressed(new KeyboardEvent('keydown', { key: 'Enter' }));
|
|
89
|
+
expect(inner.onKeyEnterPressed.emit).toHaveBeenCalled();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('ariaInvalid should be false before first submit', () => {
|
|
93
|
+
const inner = fixture.debugElement.query(By.directive(FormCheckboxComponent))
|
|
94
|
+
.componentInstance as FormCheckboxComponent;
|
|
95
|
+
expect(inner.ariaInvalid).toBe('false');
|
|
25
96
|
});
|
|
26
97
|
|
|
27
|
-
it('should
|
|
28
|
-
|
|
98
|
+
it('fieldBaseId should sanitize special characters in name', () => {
|
|
99
|
+
const inner = fixture.debugElement.query(By.directive(FormCheckboxComponent))
|
|
100
|
+
.componentInstance as FormCheckboxComponent;
|
|
101
|
+
inner.element = { name: 'a/b', text: 'x' } as FormArray;
|
|
102
|
+
expect(inner.fieldBaseId).toBe('c21-prechat-a_b');
|
|
29
103
|
});
|
|
30
104
|
});
|
|
@@ -17,6 +17,32 @@ export class FormCheckboxComponent implements OnInit {
|
|
|
17
17
|
@Output() onKeyEnterPressed = new EventEmitter<any>();
|
|
18
18
|
|
|
19
19
|
form: FormGroup<any>;
|
|
20
|
+
|
|
21
|
+
get fieldBaseId(): string {
|
|
22
|
+
const raw = this.element?.name || this.controlName || 'field';
|
|
23
|
+
return 'c21-prechat-' + String(raw).replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get errorsId(): string {
|
|
27
|
+
return this.fieldBaseId + '-errors';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get ariaDescribedByErrors(): string | null {
|
|
31
|
+
const name = this.element?.name;
|
|
32
|
+
if (!this.hasSubmitted || !this.form?.controls?.[name]?.errors) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return this.errorsId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get ariaInvalid(): 'true' | 'false' {
|
|
39
|
+
const name = this.element?.name;
|
|
40
|
+
if (!this.hasSubmitted || !this.form?.controls?.[name]) {
|
|
41
|
+
return 'false';
|
|
42
|
+
}
|
|
43
|
+
return this.form.controls[name].invalid ? 'true' : 'false';
|
|
44
|
+
}
|
|
45
|
+
|
|
20
46
|
constructor(private rootFormGroup: FormGroupDirective,
|
|
21
47
|
private elementRef: ElementRef) { }
|
|
22
48
|
|
|
@@ -1,27 +1,61 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
1
2
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
2
|
-
import {
|
|
3
|
+
import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
+
import { By } from '@angular/platform-browser';
|
|
3
5
|
|
|
6
|
+
import { FormArray } from 'src/chat21-core/models/formArray';
|
|
4
7
|
import { FormLabelComponent } from './form-label.component';
|
|
5
8
|
|
|
9
|
+
@Component({
|
|
10
|
+
template: `
|
|
11
|
+
<form [formGroup]="form">
|
|
12
|
+
<chat-form-label
|
|
13
|
+
[element]="element"
|
|
14
|
+
controlName="intro"
|
|
15
|
+
[hasSubmitted]="hasSubmitted"
|
|
16
|
+
></chat-form-label>
|
|
17
|
+
</form>`,
|
|
18
|
+
})
|
|
19
|
+
class FormLabelHostComponent {
|
|
20
|
+
form = new FormBuilder().group({});
|
|
21
|
+
hasSubmitted = false;
|
|
22
|
+
element = {
|
|
23
|
+
name: 'intro',
|
|
24
|
+
type: 'static',
|
|
25
|
+
text: '<strong>Welcome</strong> to support',
|
|
26
|
+
tabIndex: 0,
|
|
27
|
+
} as FormArray;
|
|
28
|
+
}
|
|
29
|
+
|
|
6
30
|
describe('FormLabelComponent', () => {
|
|
7
|
-
let
|
|
8
|
-
let fixture: ComponentFixture<FormLabelComponent>;
|
|
31
|
+
let fixture: ComponentFixture<FormLabelHostComponent>;
|
|
9
32
|
|
|
10
33
|
beforeEach(waitForAsync(() => {
|
|
11
34
|
TestBed.configureTestingModule({
|
|
12
|
-
declarations: [ FormLabelComponent
|
|
13
|
-
|
|
14
|
-
})
|
|
15
|
-
.compileComponents();
|
|
35
|
+
declarations: [FormLabelHostComponent, FormLabelComponent],
|
|
36
|
+
imports: [ReactiveFormsModule],
|
|
37
|
+
}).compileComponents();
|
|
16
38
|
}));
|
|
17
39
|
|
|
18
40
|
beforeEach(() => {
|
|
19
|
-
fixture = TestBed.createComponent(
|
|
20
|
-
component = fixture.componentInstance;
|
|
41
|
+
fixture = TestBed.createComponent(FormLabelHostComponent);
|
|
21
42
|
fixture.detectChanges();
|
|
22
43
|
});
|
|
23
44
|
|
|
24
|
-
it('should create', () => {
|
|
25
|
-
|
|
45
|
+
it('should create and bind innerHTML from static field text', () => {
|
|
46
|
+
const host = fixture.nativeElement.querySelector('.c21-header-label label') as HTMLElement;
|
|
47
|
+
expect(host.innerHTML).toContain('<strong>Welcome</strong>');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should assign tabindex from element', () => {
|
|
51
|
+
const host = fixture.nativeElement.querySelector('.c21-header-label label') as HTMLElement;
|
|
52
|
+
expect(host.getAttribute('tabindex')).toBe('0');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('should wire FormGroup from parent via FormGroupDirective', () => {
|
|
56
|
+
const inner = fixture.componentInstance;
|
|
57
|
+
const labelComp = fixture.debugElement.query(By.directive(FormLabelComponent))
|
|
58
|
+
.componentInstance as FormLabelComponent;
|
|
59
|
+
expect(labelComp.form).toBe(inner.form);
|
|
26
60
|
});
|
|
27
61
|
});
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
2
2
|
|
|
3
3
|
import { FormRadioButtonComponent } from './form-radio-button.component';
|
|
4
4
|
|
|
5
|
-
describe('
|
|
5
|
+
describe('FormRadioButtonComponent', () => {
|
|
6
6
|
let component: FormRadioButtonComponent;
|
|
7
7
|
let fixture: ComponentFixture<FormRadioButtonComponent>;
|
|
8
8
|
|
|
9
|
-
beforeEach(
|
|
9
|
+
beforeEach(waitForAsync(() => {
|
|
10
10
|
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
11
|
+
declarations: [FormRadioButtonComponent],
|
|
12
|
+
}).compileComponents();
|
|
14
13
|
}));
|
|
15
14
|
|
|
16
15
|
beforeEach(() => {
|
|
@@ -22,4 +21,23 @@ describe('RadioButtonComponent', () => {
|
|
|
22
21
|
it('should create', () => {
|
|
23
22
|
expect(component).toBeTruthy();
|
|
24
23
|
});
|
|
24
|
+
|
|
25
|
+
it('should render two radio inputs sharing a name for single-choice semantics', () => {
|
|
26
|
+
const radios = fixture.nativeElement.querySelectorAll(
|
|
27
|
+
'input[type="radio"]',
|
|
28
|
+
) as NodeListOf<HTMLInputElement>;
|
|
29
|
+
expect(radios.length).toBe(2);
|
|
30
|
+
expect(radios[0].name).toBe(radios[1].name);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should associate each radio with a label via for/id', () => {
|
|
34
|
+
const r1 = fixture.nativeElement.querySelector('#flexRadioDefault1') as HTMLInputElement;
|
|
35
|
+
const r2 = fixture.nativeElement.querySelector('#flexRadioDefault2') as HTMLInputElement;
|
|
36
|
+
const l1 = fixture.nativeElement.querySelector('label[for="flexRadioDefault1"]') as HTMLLabelElement;
|
|
37
|
+
const l2 = fixture.nativeElement.querySelector('label[for="flexRadioDefault2"]') as HTMLLabelElement;
|
|
38
|
+
expect(l1).toBeTruthy();
|
|
39
|
+
expect(l2).toBeTruthy();
|
|
40
|
+
expect(r2.checked).toBe(true);
|
|
41
|
+
expect(r1.checked).toBe(false);
|
|
42
|
+
});
|
|
25
43
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
1
|
+
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
2
|
+
|
|
2
3
|
import { FormSelectComponent } from './form-select.component';
|
|
3
4
|
|
|
4
|
-
describe('
|
|
5
|
+
describe('FormSelectComponent', () => {
|
|
5
6
|
let component: FormSelectComponent;
|
|
6
7
|
let fixture: ComponentFixture<FormSelectComponent>;
|
|
7
8
|
|
|
8
9
|
beforeEach(waitForAsync(() => {
|
|
9
10
|
TestBed.configureTestingModule({
|
|
10
|
-
declarations: [
|
|
11
|
-
})
|
|
12
|
-
.compileComponents();
|
|
11
|
+
declarations: [FormSelectComponent],
|
|
12
|
+
}).compileComponents();
|
|
13
13
|
}));
|
|
14
14
|
|
|
15
15
|
beforeEach(() => {
|
|
@@ -21,4 +21,13 @@ describe('SelectComponent', () => {
|
|
|
21
21
|
it('should create', () => {
|
|
22
22
|
expect(component).toBeTruthy();
|
|
23
23
|
});
|
|
24
|
+
|
|
25
|
+
it('should render placeholder copy until a real select is implemented', () => {
|
|
26
|
+
const p = fixture.nativeElement.querySelector('p') as HTMLParagraphElement;
|
|
27
|
+
expect(p.textContent?.trim()).toBe('select works!');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('ngOnInit should complete without throwing', () => {
|
|
31
|
+
expect(() => component.ngOnInit()).not.toThrow();
|
|
32
|
+
});
|
|
24
33
|
});
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
<form [formGroup]="form">
|
|
2
|
-
<div class="form-group label-floating"
|
|
2
|
+
<div class="form-group label-floating"
|
|
3
3
|
[ngClass]="{'is-empty': !form?.controls[element.name].value}"
|
|
4
|
-
id="
|
|
5
|
-
<label class="control-label">
|
|
4
|
+
[id]="'wrap-' + fieldBaseId" #div_input>
|
|
5
|
+
<label class="control-label" [attr.for]="fieldBaseId">
|
|
6
6
|
{{element?.text}}
|
|
7
7
|
</label>
|
|
8
|
-
<input
|
|
9
|
-
[
|
|
8
|
+
<input
|
|
9
|
+
[id]="fieldBaseId"
|
|
10
|
+
[formControlName]="element?.name"
|
|
10
11
|
[type]="inputType"
|
|
11
12
|
[tabIndex]="element?.tabIndex"
|
|
12
|
-
class="form-control"
|
|
13
|
+
class="form-control"
|
|
13
14
|
[class.errors]="form?.controls[element?.name].errors && hasSubmitted"
|
|
14
|
-
|
|
15
|
+
[attr.aria-required]="element?.mandatory ? 'true' : null"
|
|
16
|
+
[attr.aria-invalid]="ariaInvalid"
|
|
17
|
+
[attr.aria-describedby]="ariaDescribedByErrors"
|
|
18
|
+
(keydown.enter)="onEnterPressed($event)"
|
|
15
19
|
(focus)="onFocus()" (focusout)="onFocusOut()">
|
|
16
20
|
</div>
|
|
17
|
-
<div *ngIf="hasSubmitted && form?.controls[element?.name]
|
|
18
|
-
{{translationErrorLabelMap?.get('LABEL_ERROR_FIELD_REQUIRED')}}
|
|
19
|
-
|
|
20
|
-
<div *ngIf="hasSubmitted && form?.controls[element?.name].errors && form?.controls[element?.name].hasError('pattern') && element?.errorLabel" class="text-danger">
|
|
21
|
-
{{element?.errorLabel}}
|
|
21
|
+
<div [id]="errorsId" *ngIf="hasSubmitted && form?.controls[element?.name]?.errors" class="text-danger" role="alert">
|
|
22
|
+
<span *ngIf="form?.controls[element?.name].hasError('required')">{{translationErrorLabelMap?.get('LABEL_ERROR_FIELD_REQUIRED')}}</span>
|
|
23
|
+
<span *ngIf="form?.controls[element?.name].hasError('pattern') && element?.errorLabel">{{element?.errorLabel}}</span>
|
|
22
24
|
</div>
|
|
23
25
|
</form>
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/* Remove input border colour */
|
|
44
|
-
input:focus,
|
|
44
|
+
input:focus:not(:focus-visible),
|
|
45
45
|
input:active,
|
|
46
46
|
input:hover,
|
|
47
47
|
input:visited {
|
|
@@ -49,6 +49,11 @@
|
|
|
49
49
|
background-color: #ffffff;
|
|
50
50
|
outline: none;
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
input:focus-visible {
|
|
54
|
+
outline: 2px solid var(--themeColor, #1a73e8);
|
|
55
|
+
outline-offset: 2px;
|
|
56
|
+
}
|
|
52
57
|
|
|
53
58
|
/* Remove input background colour for Chrome autocomplete */
|
|
54
59
|
input:-webkit-autofill,
|
|
@@ -179,6 +184,11 @@ input {
|
|
|
179
184
|
transition-duration: 0.3s;
|
|
180
185
|
}
|
|
181
186
|
|
|
187
|
+
.form-group.is-focused .form-control:focus-visible {
|
|
188
|
+
outline: 2px solid var(--themeColor, #1a73e8) !important;
|
|
189
|
+
outline-offset: 2px;
|
|
190
|
+
}
|
|
191
|
+
|
|
182
192
|
.form-group.is-focused.form-info .form-control {
|
|
183
193
|
background-image: linear-gradient(#00bcd4, #00bcd4), linear-gradient(#D2D2D2, #D2D2D2);
|
|
184
194
|
}
|
|
@@ -1,31 +1,127 @@
|
|
|
1
|
+
import { Component } from '@angular/core';
|
|
1
2
|
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
|
2
|
-
import {
|
|
3
|
+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
|
|
4
|
+
import { By } from '@angular/platform-browser';
|
|
3
5
|
|
|
6
|
+
import { FormArray } from 'src/chat21-core/models/formArray';
|
|
7
|
+
import { clonePrechatFormJsonMock } from '../../prechat-form-test-mock';
|
|
4
8
|
import { FormTextComponent } from './form-text.component';
|
|
5
9
|
|
|
10
|
+
@Component({
|
|
11
|
+
template: `
|
|
12
|
+
<form [formGroup]="form">
|
|
13
|
+
<chat-form-text
|
|
14
|
+
[element]="element"
|
|
15
|
+
[controlName]="controlName"
|
|
16
|
+
[translationErrorLabelMap]="translationErrorLabelMap"
|
|
17
|
+
[stylesMap]="stylesMap"
|
|
18
|
+
[hasSubmitted]="hasSubmitted"
|
|
19
|
+
></chat-form-text>
|
|
20
|
+
</form>`,
|
|
21
|
+
})
|
|
22
|
+
class FormTextHostComponent {
|
|
23
|
+
form = new FormBuilder().group({
|
|
24
|
+
userFullname: ['', Validators.required],
|
|
25
|
+
userEmail: ['', [Validators.required, Validators.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)]],
|
|
26
|
+
});
|
|
27
|
+
controlName = 'userFullname';
|
|
28
|
+
element = {
|
|
29
|
+
name: 'userFullname',
|
|
30
|
+
type: 'text',
|
|
31
|
+
mandatory: true,
|
|
32
|
+
text: 'User fullname',
|
|
33
|
+
tabIndex: 1411,
|
|
34
|
+
} as FormArray;
|
|
35
|
+
stylesMap = new Map<string, string>([
|
|
36
|
+
['themeColor', '#2a6ac1'],
|
|
37
|
+
['foregroundColor', '#ffffff'],
|
|
38
|
+
]);
|
|
39
|
+
translationErrorLabelMap = new Map<string, string>([
|
|
40
|
+
['LABEL_ERROR_FIELD_REQUIRED', 'Required field'],
|
|
41
|
+
]);
|
|
42
|
+
hasSubmitted = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
6
45
|
describe('FormTextComponent', () => {
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
let translationErrorLabelMap = new Map<string, string>();
|
|
46
|
+
let hostFixture: ComponentFixture<FormTextHostComponent>;
|
|
47
|
+
let host: FormTextHostComponent;
|
|
48
|
+
|
|
11
49
|
beforeEach(waitForAsync(() => {
|
|
12
50
|
TestBed.configureTestingModule({
|
|
13
|
-
declarations: [ FormTextComponent
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
.compileComponents();
|
|
51
|
+
declarations: [FormTextHostComponent, FormTextComponent],
|
|
52
|
+
imports: [ReactiveFormsModule],
|
|
53
|
+
}).compileComponents();
|
|
17
54
|
}));
|
|
18
55
|
|
|
19
56
|
beforeEach(() => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
57
|
+
hostFixture = TestBed.createComponent(FormTextHostComponent);
|
|
58
|
+
host = hostFixture.componentInstance;
|
|
59
|
+
hostFixture.detectChanges();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should create with label and stable id from mock-like field', () => {
|
|
63
|
+
expect(hostFixture.nativeElement.querySelector('chat-form-text')).toBeTruthy();
|
|
64
|
+
const input = hostFixture.nativeElement.querySelector(
|
|
65
|
+
'input#c21-prechat-userFullname',
|
|
66
|
+
) as HTMLInputElement;
|
|
67
|
+
expect(input.type).toBe('text');
|
|
68
|
+
expect(input.getAttribute('aria-required')).toBe('true');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should use email input type when control name suggests email', () => {
|
|
72
|
+
host.controlName = 'userEmail';
|
|
73
|
+
host.element = clonePrechatFormJsonMock()[1] as FormArray;
|
|
74
|
+
host.element.text = 'Email';
|
|
75
|
+
hostFixture.detectChanges();
|
|
76
|
+
const input = hostFixture.nativeElement.querySelector(
|
|
77
|
+
'input#c21-prechat-userEmail',
|
|
78
|
+
) as HTMLInputElement;
|
|
79
|
+
expect(input.type).toBe('email');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should show required error region when submitted and empty', () => {
|
|
83
|
+
host.hasSubmitted = true;
|
|
84
|
+
hostFixture.detectChanges();
|
|
85
|
+
const input = hostFixture.nativeElement.querySelector(
|
|
86
|
+
'input#c21-prechat-userFullname',
|
|
87
|
+
) as HTMLInputElement;
|
|
88
|
+
expect(input.getAttribute('aria-invalid')).toBe('true');
|
|
89
|
+
expect(input.getAttribute('aria-describedby')).toBe('c21-prechat-userFullname-errors');
|
|
90
|
+
const alert = hostFixture.nativeElement.querySelector(
|
|
91
|
+
'#c21-prechat-userFullname-errors',
|
|
92
|
+
) as HTMLElement;
|
|
93
|
+
expect(alert.textContent).toContain('Required field');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('onEnterPressed should emit keyboard event', () => {
|
|
97
|
+
const inner = hostFixture.debugElement.query(By.directive(FormTextComponent))
|
|
98
|
+
.componentInstance as FormTextComponent;
|
|
99
|
+
spyOn(inner.onKeyEnterPressed, 'emit');
|
|
100
|
+
const ev = new KeyboardEvent('keydown', { key: 'Enter' });
|
|
101
|
+
inner.onEnterPressed(ev);
|
|
102
|
+
expect(inner.onKeyEnterPressed.emit).toHaveBeenCalledWith(ev);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('ariaInvalid should stay false until form is submitted', () => {
|
|
106
|
+
const inner = hostFixture.debugElement.query(By.directive(FormTextComponent))
|
|
107
|
+
.componentInstance as FormTextComponent;
|
|
108
|
+
expect(inner.ariaInvalid).toBe('false');
|
|
109
|
+
host.hasSubmitted = true;
|
|
110
|
+
hostFixture.detectChanges();
|
|
111
|
+
expect(inner.ariaInvalid).toBe('true');
|
|
26
112
|
});
|
|
27
113
|
|
|
28
|
-
it('should
|
|
29
|
-
|
|
114
|
+
it('ngOnChanges should map theme CSS variables onto host', () => {
|
|
115
|
+
const innerDe = hostFixture.debugElement.query(By.directive(FormTextComponent));
|
|
116
|
+
const inner = innerDe.componentInstance as FormTextComponent;
|
|
117
|
+
inner.ngOnChanges({
|
|
118
|
+
stylesMap: {
|
|
119
|
+
currentValue: host.stylesMap,
|
|
120
|
+
previousValue: null,
|
|
121
|
+
firstChange: true,
|
|
122
|
+
isFirstChange: () => true,
|
|
123
|
+
},
|
|
124
|
+
} as any);
|
|
125
|
+
expect(innerDe.nativeElement.style.getPropertyValue('--themeColor')).toBe('#2a6ac1');
|
|
30
126
|
});
|
|
31
127
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, SimpleChange, ViewChild } from '@angular/core';
|
|
1
|
+
import { Component, ElementRef, EventEmitter, Input, OnInit, OnDestroy, Output, SimpleChange, ViewChild } from '@angular/core';
|
|
2
2
|
import { FormGroup, FormGroupDirective } from '@angular/forms';
|
|
3
|
+
import { Subscription } from 'rxjs';
|
|
3
4
|
import { FormArray } from '../../../../../chat21-core/models/formArray';
|
|
4
5
|
|
|
5
6
|
@Component({
|
|
@@ -7,7 +8,7 @@ import { FormArray } from '../../../../../chat21-core/models/formArray';
|
|
|
7
8
|
templateUrl: './form-text.component.html',
|
|
8
9
|
styleUrls: ['./form-text.component.scss']
|
|
9
10
|
})
|
|
10
|
-
export class FormTextComponent implements OnInit {
|
|
11
|
+
export class FormTextComponent implements OnInit, OnDestroy {
|
|
11
12
|
|
|
12
13
|
@Input() element: FormArray;
|
|
13
14
|
@Input() controlName: string;
|
|
@@ -19,19 +20,50 @@ export class FormTextComponent implements OnInit {
|
|
|
19
20
|
@ViewChild('div_input') input: ElementRef;
|
|
20
21
|
form: FormGroup<any>;
|
|
21
22
|
inputType: string = 'text'
|
|
23
|
+
private valueChangesSub?: Subscription;
|
|
24
|
+
|
|
25
|
+
get fieldBaseId(): string {
|
|
26
|
+
const raw = this.element?.name || this.controlName || 'field';
|
|
27
|
+
return 'c21-prechat-' + String(raw).replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get errorsId(): string {
|
|
31
|
+
return this.fieldBaseId + '-errors';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get ariaDescribedByErrors(): string | null {
|
|
35
|
+
const name = this.element?.name;
|
|
36
|
+
if (!this.hasSubmitted || !this.form?.controls?.[name]?.errors) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return this.errorsId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get ariaInvalid(): 'true' | 'false' {
|
|
43
|
+
const name = this.element?.name;
|
|
44
|
+
if (!this.hasSubmitted || !this.form?.controls?.[name]) {
|
|
45
|
+
return 'false';
|
|
46
|
+
}
|
|
47
|
+
return this.form.controls[name].invalid ? 'true' : 'false';
|
|
48
|
+
}
|
|
49
|
+
|
|
22
50
|
constructor(private rootFormGroup: FormGroupDirective,
|
|
23
51
|
private elementRef: ElementRef) { }
|
|
24
52
|
|
|
25
53
|
ngOnInit() {
|
|
26
54
|
this.form = this.rootFormGroup.control as FormGroup<any>;
|
|
27
55
|
if(this.form && this.form.controls && this.form.controls[this.controlName]){
|
|
28
|
-
this.form.controls[this.controlName].valueChanges.subscribe((value) => {
|
|
56
|
+
this.valueChangesSub = this.form.controls[this.controlName].valueChanges.subscribe((value) => {
|
|
29
57
|
this.hasSubmitted= false;
|
|
30
58
|
this.setFormStyle();
|
|
31
59
|
})
|
|
32
60
|
}
|
|
33
61
|
}
|
|
34
62
|
|
|
63
|
+
ngOnDestroy() {
|
|
64
|
+
this.valueChangesSub?.unsubscribe();
|
|
65
|
+
}
|
|
66
|
+
|
|
35
67
|
ngOnChanges(changes: SimpleChange){
|
|
36
68
|
if(this.controlName && (this.controlName.toLowerCase().includes('email') || this.controlName.toLowerCase().includes('e-mail')) ){
|
|
37
69
|
this.inputType = 'email';
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
<form [formGroup]="form">
|
|
2
|
-
<div class="form-group label-floating" id="
|
|
2
|
+
<div class="form-group label-floating" [id]="'wrap-' + fieldBaseId" #div_input
|
|
3
3
|
[ngClass]="{'is-empty': !form?.controls[element.name]?.value}">
|
|
4
|
-
<label class="control-label">
|
|
4
|
+
<label class="control-label" [attr.for]="fieldBaseId">
|
|
5
5
|
{{element?.text}}
|
|
6
6
|
</label>
|
|
7
|
-
<textarea
|
|
8
|
-
[
|
|
7
|
+
<textarea
|
|
8
|
+
[id]="fieldBaseId"
|
|
9
|
+
[formControlName]="element?.name"
|
|
9
10
|
[rows]="rows"
|
|
10
11
|
[tabIndex]="element?.tabIndex"
|
|
11
12
|
type="text"
|
|
12
13
|
class="form-control"
|
|
14
|
+
[attr.aria-required]="element?.mandatory ? 'true' : null"
|
|
15
|
+
[attr.aria-invalid]="ariaInvalid"
|
|
16
|
+
[attr.aria-describedby]="ariaDescribedByErrors"
|
|
13
17
|
(keydown)="onkeydown($event)"
|
|
14
|
-
(keydown.enter)="onEnterPressed($event)"
|
|
15
|
-
(focus)="onFocus()"
|
|
18
|
+
(keydown.enter)="onEnterPressed($event)"
|
|
19
|
+
(focus)="onFocus()"
|
|
16
20
|
(focusout)="onFocusOut()">
|
|
17
21
|
</textarea>
|
|
18
22
|
</div>
|
|
19
|
-
<div *ngIf="hasSubmitted && form?.controls[element.name]
|
|
20
|
-
{{translationErrorLabelMap.get('LABEL_ERROR_FIELD_REQUIRED')}}
|
|
21
|
-
|
|
22
|
-
<div *ngIf="hasSubmitted && form?.controls[element.name].errors && form?.controls[element.name].hasError('pattern') && element?.errorLabel" class="text-danger">
|
|
23
|
-
{{element.errorLabel}}
|
|
23
|
+
<div [id]="errorsId" *ngIf="hasSubmitted && form?.controls[element.name]?.errors" class="text-danger" role="alert">
|
|
24
|
+
<span *ngIf="form?.controls[element.name].hasError('required')">{{translationErrorLabelMap.get('LABEL_ERROR_FIELD_REQUIRED')}}</span>
|
|
25
|
+
<span *ngIf="form?.controls[element.name].hasError('pattern') && element?.errorLabel">{{element.errorLabel}}</span>
|
|
24
26
|
</div>
|
|
25
27
|
</form>
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/* Remove input border colour */
|
|
45
|
-
textarea:focus,
|
|
45
|
+
textarea:focus:not(:focus-visible),
|
|
46
46
|
textarea:active,
|
|
47
47
|
textarea:hover,
|
|
48
48
|
textarea:visited {
|
|
@@ -52,9 +52,6 @@
|
|
|
52
52
|
background-position: center bottom,center calc(100% - 1px);
|
|
53
53
|
background-color: rgba(0,0,0,0);
|
|
54
54
|
transition: background 0s ease-out;
|
|
55
|
-
// box-shadow: none;
|
|
56
|
-
// background-color: #ffffff;
|
|
57
|
-
// outline: none;
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
/* Remove input background colour for Chrome autocomplete */
|
|
@@ -182,11 +179,15 @@ textarea {
|
|
|
182
179
|
background-repeat: no-repeat;
|
|
183
180
|
background-position: center bottom,center calc(100% - 1px);
|
|
184
181
|
background-size: 100% 2px, 100% 1px;
|
|
185
|
-
// box-shadow: none;
|
|
186
182
|
transition-duration: 0.3s;
|
|
187
183
|
width: 100%;
|
|
188
184
|
}
|
|
189
185
|
|
|
186
|
+
.form-group.is-focused .form-control:focus-visible {
|
|
187
|
+
outline: 2px solid var(--themeColor, #1a73e8) !important;
|
|
188
|
+
outline-offset: 2px;
|
|
189
|
+
}
|
|
190
|
+
|
|
190
191
|
.form-group.is-focused.form-info .form-control {
|
|
191
192
|
background-image: linear-gradient(#00bcd4, #00bcd4), linear-gradient(#D2D2D2, #D2D2D2);
|
|
192
193
|
}
|