@chat21/chat21-web-widget 5.1.32-rc8 → 5.1.33-rc11
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/playwright.yml +27 -0
- package/.playwright-mcp/console-2026-05-08T15-31-09-000Z.log +17 -0
- package/.playwright-mcp/console-2026-05-08T15-32-19-412Z.log +89 -0
- package/.playwright-mcp/console-2026-05-08T16-18-48-424Z.log +133 -0
- package/.playwright-mcp/console-2026-05-11T12-54-06-869Z.log +13 -0
- package/.playwright-mcp/console-2026-05-11T12-54-56-229Z.log +147 -0
- package/.playwright-mcp/console-2026-05-11T12-55-47-174Z.log +183 -0
- package/.playwright-mcp/console-2026-05-11T15-34-03-590Z.log +210 -0
- package/.playwright-mcp/console-2026-05-12T15-07-31-880Z.log +118 -0
- package/.playwright-mcp/page-2026-05-08T15-32-19-900Z.yml +851 -0
- package/.playwright-mcp/page-2026-05-08T15-32-47-264Z.yml +857 -0
- package/.playwright-mcp/page-2026-05-08T15-33-17-089Z.yml +1110 -0
- package/.playwright-mcp/page-2026-05-08T15-33-23-486Z.yml +1069 -0
- package/.playwright-mcp/page-2026-05-08T15-33-45-390Z.yml +1076 -0
- package/.playwright-mcp/page-2026-05-08T15-33-52-666Z.yml +1072 -0
- package/.playwright-mcp/page-2026-05-08T15-34-01-338Z.yml +1085 -0
- package/.playwright-mcp/page-2026-05-08T15-34-07-227Z.yml +1072 -0
- package/.playwright-mcp/page-2026-05-08T15-34-13-875Z.yml +1072 -0
- package/.playwright-mcp/page-2026-05-08T15-34-21-885Z.yml +1109 -0
- package/.playwright-mcp/page-2026-05-08T15-34-32-755Z.yml +1109 -0
- package/.playwright-mcp/page-2026-05-08T15-35-09-607Z.yml +1119 -0
- package/.playwright-mcp/page-2026-05-08T15-35-14-242Z.yml +1109 -0
- package/.playwright-mcp/page-2026-05-08T16-18-48-671Z.yml +44 -0
- package/.playwright-mcp/page-2026-05-08T16-18-52-753Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-19-13-919Z.yml +68 -0
- package/.playwright-mcp/page-2026-05-08T16-19-17-977Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-19-25-733Z.yml +120 -0
- package/.playwright-mcp/page-2026-05-08T16-19-29-252Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-19-39-269Z.yml +80 -0
- package/.playwright-mcp/page-2026-05-08T16-19-43-915Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-20-04-407Z.yml +81 -0
- package/.playwright-mcp/page-2026-05-08T16-20-08-984Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-20-32-397Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-20-58-658Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-21-12-320Z.yml +86 -0
- package/.playwright-mcp/page-2026-05-08T16-21-39-154Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-21-45-420Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-22-21-062Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-08T16-22-58-232Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-23-36-520Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-08T16-23-46-805Z.yml +100 -0
- package/.playwright-mcp/page-2026-05-08T16-23-55-169Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-24-26-574Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-25-34-414Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-25-59-831Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-26-21-809Z.yml +91 -0
- package/.playwright-mcp/page-2026-05-08T16-26-47-443Z.yml +105 -0
- package/.playwright-mcp/page-2026-05-08T16-26-56-136Z.png +0 -0
- package/.playwright-mcp/page-2026-05-08T16-27-59-610Z.yml +48 -0
- package/.playwright-mcp/page-2026-05-11T12-54-07-180Z.yml +44 -0
- package/.playwright-mcp/page-2026-05-11T12-54-56-946Z.yml +4 -0
- package/.playwright-mcp/page-2026-05-11T12-55-47-503Z.yml +24 -0
- package/.playwright-mcp/page-2026-05-11T12-56-00-766Z.yml +28 -0
- package/.playwright-mcp/page-2026-05-11T12-56-06-438Z.yml +90 -0
- package/.playwright-mcp/page-2026-05-11T12-57-56-838Z.yml +106 -0
- package/.playwright-mcp/page-2026-05-11T12-58-00-124Z.yml +106 -0
- package/.playwright-mcp/page-2026-05-11T12-59-08-836Z.yml +61 -0
- package/.playwright-mcp/page-2026-05-11T12-59-12-088Z.yml +61 -0
- package/.playwright-mcp/page-2026-05-11T12-59-26-215Z.yml +69 -0
- package/.playwright-mcp/page-2026-05-11T12-59-29-519Z.yml +69 -0
- package/.playwright-mcp/page-2026-05-11T12-59-37-309Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-11T12-59-39-968Z.yml +79 -0
- package/.playwright-mcp/page-2026-05-11T12-59-45-983Z.yml +78 -0
- package/.playwright-mcp/page-2026-05-11T12-59-49-951Z.yml +78 -0
- package/.playwright-mcp/page-2026-05-11T15-34-04-515Z.yml +0 -0
- package/.playwright-mcp/page-2026-05-12T15-07-32-171Z.yml +44 -0
- package/.playwright-mcp/page-2026-05-12T15-08-09-820Z.yml +119 -0
- package/CHANGELOG.md +68 -3
- package/angular.json +20 -3
- package/deploy_amazon_beta.sh +7 -17
- package/deploy_amazon_prod.sh +41 -0
- package/docs/TILEDESK_WIDGET_ACCESSIBILITY_STATEMENT_COMPLETE.md +379 -0
- package/env.sample +3 -2
- package/mocks/voice-websocket-mock/server.cjs +245 -0
- package/package.json +7 -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.module.ts +4 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.html +19 -11
- package/src/app/component/conversation-detail/conversation/conversation.component.scss +28 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.spec.ts +644 -75
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +63 -17
- 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 +22 -9
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.scss +23 -1
- 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 +7 -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 copy.html +172 -0
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +112 -61
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +133 -16
- 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 +199 -79
- 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 -19
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.scss +67 -10
- package/src/app/component/conversation-detail/stream-audio-spectrum/stream-audio-spectrum.component.ts +142 -12
- 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/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 -0
- package/src/app/component/message/audio-sync/audio-sync.component.scss +1 -1
- package/src/app/component/message/audio-sync/audio-sync.component.spec.ts +81 -1
- package/src/app/component/message/audio-sync/audio-sync.component.ts +134 -24
- 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 +39 -52
- 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 -110
- 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 +59 -2
- package/src/app/providers/json-sources-parser.service.ts +175 -0
- package/src/app/providers/translator.service.ts +24 -6
- package/src/app/providers/tts-audio-playback-coordinator.service.spec.ts +117 -0
- package/src/app/providers/tts-audio-playback-coordinator.service.ts +45 -7
- package/src/app/providers/url-preview.service.ts +82 -0
- package/src/app/providers/voice/audio.types.ts +6 -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 +170 -3
- package/src/app/providers/voice/voice.service.ts +695 -16
- package/src/app/sass/_variables.scss +1 -1
- package/src/app/sass/animations.scss +19 -1
- package/src/app/utils/globals.ts +14 -0
- 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 -100
- package/src/assets/i18n/es.json +107 -101
- package/src/assets/i18n/fr.json +107 -101
- package/src/assets/i18n/it.json +107 -99
- package/src/assets/sounds/keyboard.mp3 +0 -0
- 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/chat21-core/providers/chat-manager.spec.ts +72 -0
- package/src/chat21-core/providers/scripts/script.service.spec.ts +12 -2
- package/src/chat21-core/utils/constants.ts +4 -0
- package/src/chat21-core/utils/utils-message.ts +23 -1
- package/src/widget-config-template.json +3 -1
- package/src/widget-config.json +28 -27
- 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
|
@@ -42,60 +42,99 @@ export class ImageComponent implements OnInit {
|
|
|
42
42
|
// this.onClickImage()
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Opens the image in an accessible lightbox.
|
|
47
|
+
*
|
|
48
|
+
* Accessibility features (WCAG 2.1.1, 2.1.2, 2.4.3, 4.1.2):
|
|
49
|
+
* - Lightbox container is rendered as role="dialog" aria-modal="true" with aria-label.
|
|
50
|
+
* - A real <button> with aria-label closes the dialog.
|
|
51
|
+
* - The dialog can be dismissed via Escape, click on the backdrop, or the close button.
|
|
52
|
+
* - The previously focused element is restored when the lightbox closes.
|
|
53
|
+
* - Focus is moved to the close button on open to keep keyboard users inside the dialog.
|
|
54
|
+
*/
|
|
45
55
|
onClickImage(){
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
ifrm.
|
|
51
|
-
ifrm.setAttribute('
|
|
52
|
-
ifrm.setAttribute('
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
iframeContent
|
|
59
|
-
iframeContent += '
|
|
60
|
-
iframeContent += '</
|
|
61
|
-
iframeContent += '<
|
|
62
|
-
iframeContent +=
|
|
63
|
-
iframeContent +=
|
|
64
|
-
iframeContent +=
|
|
65
|
-
iframeContent +=
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
iframeContent +=
|
|
70
|
-
iframeContent +=
|
|
71
|
-
iframeContent +=
|
|
72
|
-
iframeContent +=
|
|
73
|
-
iframeContent +=
|
|
74
|
-
iframeContent +='
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
56
|
+
const previouslyFocused = document.activeElement as HTMLElement | null;
|
|
57
|
+
const altText = this.metadata?.name || 'Image preview';
|
|
58
|
+
const closeLabel = this.tooltipMessage || 'Close';
|
|
59
|
+
|
|
60
|
+
const ifrm = document.createElement('iframe');
|
|
61
|
+
ifrm.setAttribute('frameborder', '0');
|
|
62
|
+
ifrm.setAttribute('id', 'tiledesk-image-preview');
|
|
63
|
+
ifrm.setAttribute('tiledesk_context', 'parent');
|
|
64
|
+
ifrm.setAttribute('title', altText);
|
|
65
|
+
ifrm.setAttribute('aria-label', altText);
|
|
66
|
+
ifrm.setAttribute('style', 'width: 100%; height: 100%; position: absolute; z-index: 2147483003; border: 0;');
|
|
67
|
+
|
|
68
|
+
let iframeContent = '<!doctype html><html lang="' + (document.documentElement.lang || 'en') + '"><head>';
|
|
69
|
+
iframeContent += '<meta charset="utf-8"/>';
|
|
70
|
+
iframeContent += '<title>' + altText.replace(/[<>]/g, '') + '</title>';
|
|
71
|
+
iframeContent += '<style>';
|
|
72
|
+
iframeContent += 'html,body{margin:0;padding:0;height:100%;}';
|
|
73
|
+
iframeContent += '.tiledesk-popup-backdrop{position:fixed;inset:0;background-color:rgba(0,0,0,0.6);}';
|
|
74
|
+
iframeContent += '.tiledesk-popup-content{position:fixed;inset:0;display:flex;justify-content:center;align-items:center;padding:32px;}';
|
|
75
|
+
iframeContent += '.tiledesk-popup-image{max-height:85vh;max-width:90vw;border-radius:8px;}';
|
|
76
|
+
iframeContent += '.tiledesk-popup-button{position:fixed;top:16px;right:16px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:rgba(255,255,255,0.95);border:1px solid rgba(0,0,0,0.1);border-radius:50%;cursor:pointer;padding:0;}';
|
|
77
|
+
iframeContent += '.tiledesk-popup-button:focus-visible{outline:3px solid #1a73e8;outline-offset:2px;}';
|
|
78
|
+
iframeContent += '.tiledesk-popup-button svg{width:20px;height:20px;fill:#000;}';
|
|
79
|
+
iframeContent += '@media (prefers-reduced-motion: reduce){.tiledesk-popup-backdrop{transition:none;}}';
|
|
80
|
+
iframeContent += '</style></head><body>';
|
|
81
|
+
iframeContent += '<div role="dialog" aria-modal="true" aria-label="' + altText.replace(/"/g, '"') + '" id="frame-root">';
|
|
82
|
+
iframeContent += '<div class="tiledesk-popup-backdrop" id="popup-backdrop"></div>';
|
|
83
|
+
iframeContent += '<div class="tiledesk-popup-content">';
|
|
84
|
+
iframeContent += '<img src="' + this.metadata.src + '" class="tiledesk-popup-image" id="image-popup" alt="' + altText.replace(/"/g, '"') + '">';
|
|
85
|
+
iframeContent += '</div>';
|
|
86
|
+
iframeContent += '<button type="button" id="closeButton" class="tiledesk-popup-button" aria-label="' + closeLabel.replace(/"/g, '"') + '">';
|
|
87
|
+
iframeContent += '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';
|
|
88
|
+
iframeContent += '</button>';
|
|
89
|
+
iframeContent += '</div>';
|
|
90
|
+
iframeContent += '</body></html>';
|
|
91
|
+
|
|
92
|
+
ifrm.srcdoc = iframeContent;
|
|
93
|
+
window.document.body.appendChild(ifrm);
|
|
94
|
+
|
|
95
|
+
const closeLightbox = () => {
|
|
96
|
+
const node = window.document.getElementById('tiledesk-image-preview');
|
|
97
|
+
if (node && node.parentNode) {
|
|
98
|
+
node.parentNode.removeChild(node);
|
|
99
|
+
}
|
|
100
|
+
if (previouslyFocused && typeof previouslyFocused.focus === 'function') {
|
|
101
|
+
try { previouslyFocused.focus(); } catch(e) { /* noop */ }
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
ifrm.onload = function () {
|
|
106
|
+
const doc = ifrm.contentWindow?.document;
|
|
107
|
+
if (!doc) { return; }
|
|
108
|
+
|
|
109
|
+
const closeBtn = doc.getElementById('closeButton') as HTMLButtonElement | null;
|
|
110
|
+
const backdrop = doc.getElementById('popup-backdrop');
|
|
111
|
+
const image = doc.getElementById('image-popup');
|
|
112
|
+
|
|
113
|
+
if (closeBtn) {
|
|
114
|
+
closeBtn.addEventListener('click', (e) => {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
e.stopPropagation();
|
|
117
|
+
closeLightbox();
|
|
118
|
+
});
|
|
119
|
+
closeBtn.focus();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (backdrop) {
|
|
123
|
+
backdrop.addEventListener('click', () => closeLightbox());
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (image) {
|
|
127
|
+
image.addEventListener('click', (e) => e.stopPropagation());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Escape key handler from inside the lightbox iframe
|
|
131
|
+
doc.addEventListener('keydown', (event: KeyboardEvent) => {
|
|
132
|
+
if (event.key === 'Escape' || event.keyCode === 27) {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
closeLightbox();
|
|
135
|
+
}
|
|
90
136
|
});
|
|
91
|
-
// var image = ifrm.contentWindow.document.getElementById('image-popup')
|
|
92
|
-
// image.addEventListener("click", function(event){
|
|
93
|
-
// event.preventDefault();
|
|
94
|
-
// event.stopPropagation();
|
|
95
|
-
// that.downloadImage(that.metadata.src, that.metadata.name)
|
|
96
|
-
// });
|
|
97
137
|
};
|
|
98
|
-
|
|
99
138
|
}
|
|
100
139
|
|
|
101
140
|
|
|
@@ -1,36 +1,48 @@
|
|
|
1
|
-
import { CustomLogger } from './../../../../chat21-core/providers/logger/customLogger';
|
|
2
|
-
import { LoggerInstance } from './../../../../chat21-core/providers/logger/loggerInstance';
|
|
3
|
-
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
4
1
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
5
|
-
import { MarkedPipe } from '../../../pipe/marked.pipe';
|
|
6
2
|
|
|
7
|
-
import {
|
|
3
|
+
import { MessageModel } from 'src/chat21-core/models/message';
|
|
4
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
5
|
+
import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
|
|
8
6
|
import { NGXLogger } from 'ngx-logger';
|
|
7
|
+
import { TooltipDirective } from '../../../directives/tooltip.directive';
|
|
8
|
+
import { DateAgoPipe } from '../../../pipe/date-ago.pipe';
|
|
9
|
+
import { MarkedPipe } from '../../../pipe/marked.pipe';
|
|
10
|
+
import { InfoMessageComponent } from './info-message.component';
|
|
9
11
|
|
|
10
12
|
describe('InfoMessageComponent', () => {
|
|
11
13
|
let component: InfoMessageComponent;
|
|
12
14
|
let fixture: ComponentFixture<InfoMessageComponent>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
|
|
16
|
+
const customLogger = new CustomLogger(ngxlogger);
|
|
15
17
|
|
|
16
18
|
beforeEach(waitForAsync(() => {
|
|
19
|
+
LoggerInstance.setInstance(customLogger);
|
|
17
20
|
TestBed.configureTestingModule({
|
|
18
|
-
declarations: [
|
|
19
|
-
|
|
20
|
-
})
|
|
21
|
-
.compileComponents();
|
|
21
|
+
declarations: [InfoMessageComponent, MarkedPipe, DateAgoPipe, TooltipDirective],
|
|
22
|
+
}).compileComponents();
|
|
22
23
|
}));
|
|
23
24
|
|
|
24
25
|
beforeEach(() => {
|
|
25
26
|
fixture = TestBed.createComponent(InfoMessageComponent);
|
|
26
27
|
component = fixture.componentInstance;
|
|
27
|
-
|
|
28
|
-
let logger = LoggerInstance.getInstance()
|
|
29
|
-
component['logger']= logger
|
|
28
|
+
component.message = { text: 'hello', timestamp: Date.now() } as MessageModel;
|
|
30
29
|
fixture.detectChanges();
|
|
31
30
|
});
|
|
32
31
|
|
|
33
32
|
it('should create', () => {
|
|
34
33
|
expect(component).toBeTruthy();
|
|
35
34
|
});
|
|
35
|
+
|
|
36
|
+
it('ngOnInit should replace br tags with newlines in message text', () => {
|
|
37
|
+
const msg = { text: 'a<br/>b<br>c', timestamp: Date.now() } as MessageModel;
|
|
38
|
+
component.message = { ...msg };
|
|
39
|
+
component.ngOnInit();
|
|
40
|
+
expect(component.message.text).toContain('\n');
|
|
41
|
+
expect(component.message.text).not.toContain('<br');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('ngOnInit should tolerate missing message', () => {
|
|
45
|
+
component.message = undefined as any;
|
|
46
|
+
expect(() => component.ngOnInit()).not.toThrow();
|
|
47
|
+
});
|
|
36
48
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<div class="sources-panel" *ngIf="items && items.length > 0">
|
|
2
|
+
|
|
3
|
+
<div class="sources-header">
|
|
4
|
+
<div class="sources-favicons">
|
|
5
|
+
<img class="header-favicon"
|
|
6
|
+
*ngFor="let item of headerFavicons; trackBy: trackByLink"
|
|
7
|
+
[src]="getFavicon(item)"
|
|
8
|
+
alt=""
|
|
9
|
+
loading="lazy" />
|
|
10
|
+
</div>
|
|
11
|
+
<span class="sources-count">{{ items.length }} {{ items.length === 1 ? 'sito' : 'siti' }}</span>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<a class="source-row"
|
|
15
|
+
*ngFor="let item of visibleItems; trackBy: trackByLink"
|
|
16
|
+
[href]="item.link"
|
|
17
|
+
target="_blank"
|
|
18
|
+
rel="noopener noreferrer">
|
|
19
|
+
|
|
20
|
+
<div class="source-row__left">
|
|
21
|
+
<div class="source-row__title">{{ item.title }}</div>
|
|
22
|
+
<div class="source-row__desc" *ngIf="item.description">{{ item.description }}</div>
|
|
23
|
+
<div class="source-row__meta">
|
|
24
|
+
<img class="source-row__favicon" *ngIf="getFavicon(item)" [src]="getFavicon(item)" alt="" loading="lazy" />
|
|
25
|
+
<span class="source-row__host">{{ getHostname(item) }}</span>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div class="source-row__thumb" *ngIf="item.image">
|
|
30
|
+
<img [src]="item.image" alt="" loading="lazy" (error)="$event.target.closest('.source-row__thumb').remove()" />
|
|
31
|
+
</div>
|
|
32
|
+
</a>
|
|
33
|
+
|
|
34
|
+
<button class="show-all" *ngIf="canExpand" type="button" (click)="toggleShowAll()">
|
|
35
|
+
{{ showAll ? 'Mostra meno' : 'Mostra tutto' }}
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--panel-bck: #ffffff; // #f7f8fa;
|
|
3
|
+
--row-sep: rgba(66, 133, 244, 0.18);
|
|
4
|
+
--text: rgba(0, 0, 0, 0.90);
|
|
5
|
+
--muted: rgba(0, 0, 0, 0.62);
|
|
6
|
+
--accent: #1a73e8;
|
|
7
|
+
--pill-bck: #eaebf1;
|
|
8
|
+
|
|
9
|
+
font-family: "Google Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
|
|
10
|
+
-webkit-font-smoothing: antialiased;
|
|
11
|
+
-moz-osx-font-smoothing: grayscale;
|
|
12
|
+
|
|
13
|
+
--title-line-height: 1.4;
|
|
14
|
+
--title-font-size: 14px;
|
|
15
|
+
|
|
16
|
+
--desc-line-height: 1.3;
|
|
17
|
+
--desc-font-size: 12px;
|
|
18
|
+
|
|
19
|
+
display: block;
|
|
20
|
+
width: 100%;
|
|
21
|
+
max-width: 652px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.sources-header {
|
|
25
|
+
display: none;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 8px;
|
|
28
|
+
padding: 2px 4px 8px 4px;
|
|
29
|
+
border-bottom: 1px solid var(--row-sep);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.sources-favicons {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.header-favicon {
|
|
38
|
+
width: 18px;
|
|
39
|
+
height: 18px;
|
|
40
|
+
border-radius: 50%;
|
|
41
|
+
border: 2px solid #fff;
|
|
42
|
+
background: rgba(255, 255, 255, 0.7);
|
|
43
|
+
object-fit: cover;
|
|
44
|
+
|
|
45
|
+
& + & {
|
|
46
|
+
margin-left: -2px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sources-count {
|
|
51
|
+
font-size: 13px;
|
|
52
|
+
font-weight: 500;
|
|
53
|
+
color: var(--muted);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.sources-panel {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
padding: 18px 12px 10px 12px;
|
|
60
|
+
background: var(--panel-bck);
|
|
61
|
+
border-radius: 18px;
|
|
62
|
+
font-size: 14px;
|
|
63
|
+
width: 100%;
|
|
64
|
+
max-width: 652px;
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.source-row {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: stretch;
|
|
71
|
+
justify-content: space-between;
|
|
72
|
+
gap: 14px;
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
color: inherit;
|
|
75
|
+
padding: 10px 10px;
|
|
76
|
+
border-radius: 12px;
|
|
77
|
+
transition: background 140ms ease;
|
|
78
|
+
font-family: 'Google Sans', Arial, sans-serif;
|
|
79
|
+
width: 100%;
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
|
|
82
|
+
border-bottom: 1px solid var(--row-sep);
|
|
83
|
+
border-bottom-left-radius: 0;
|
|
84
|
+
border-bottom-right-radius: 0;
|
|
85
|
+
|
|
86
|
+
&:hover {
|
|
87
|
+
background: rgba(255, 255, 255, 0.55);
|
|
88
|
+
.source-row__title {
|
|
89
|
+
text-decoration: underline;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// & + & {
|
|
94
|
+
// border-top: 1px solid var(--row-sep);
|
|
95
|
+
// border-top-left-radius: 0;
|
|
96
|
+
// border-top-right-radius: 0;
|
|
97
|
+
// }
|
|
98
|
+
|
|
99
|
+
.source-row__left {
|
|
100
|
+
min-width: 0;
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
gap: 6px;
|
|
104
|
+
flex: 1 1 auto;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.source-row__title {
|
|
108
|
+
font-weight: 500;
|
|
109
|
+
color: var(--text);
|
|
110
|
+
font-size: var(--title-font-size);
|
|
111
|
+
line-height: var(--title-line-height);
|
|
112
|
+
margin: 0px;
|
|
113
|
+
min-width: 0;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
text-overflow: ellipsis;
|
|
116
|
+
display: -webkit-box;
|
|
117
|
+
line-clamp: 2;
|
|
118
|
+
-webkit-line-clamp: 2;
|
|
119
|
+
-webkit-box-orient: vertical;
|
|
120
|
+
white-space: normal;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.source-row__desc {
|
|
124
|
+
font-size: var(--desc-font-size);
|
|
125
|
+
line-height: var(--desc-line-height);
|
|
126
|
+
overflow: hidden;
|
|
127
|
+
text-overflow: ellipsis;
|
|
128
|
+
display: -webkit-box;
|
|
129
|
+
line-clamp: 2;
|
|
130
|
+
-webkit-line-clamp: 2;
|
|
131
|
+
-webkit-box-orient: vertical;
|
|
132
|
+
color: #56595e;
|
|
133
|
+
margin: 0;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.source-row__meta {
|
|
137
|
+
display: flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
gap: 8px;
|
|
140
|
+
margin-top: auto;
|
|
141
|
+
padding-top: 2px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.source-row__favicon {
|
|
145
|
+
width: 16px;
|
|
146
|
+
height: 16px;
|
|
147
|
+
border-radius: 50%;
|
|
148
|
+
flex: 0 0 auto;
|
|
149
|
+
border: 2px solid #fff;
|
|
150
|
+
background: rgba(255, 255, 255, 0.7);
|
|
151
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.source-row__host {
|
|
155
|
+
color: rgba(0, 0, 0, 0.55);
|
|
156
|
+
font-size: 12px;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
white-space: nowrap;
|
|
160
|
+
min-width: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.source-row__thumb {
|
|
164
|
+
width: 56px;
|
|
165
|
+
height: 56px;
|
|
166
|
+
border-radius: 10px;
|
|
167
|
+
overflow: hidden;
|
|
168
|
+
flex: 0 0 auto;
|
|
169
|
+
border: 1px solid rgba(0, 0, 0, 0.06);
|
|
170
|
+
background: rgba(255, 255, 255, 0.65);
|
|
171
|
+
align-self: flex-start;
|
|
172
|
+
display: flex;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
align-items: center;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.source-row__thumb img {
|
|
178
|
+
width: 100%;
|
|
179
|
+
height: 100%;
|
|
180
|
+
object-fit: cover;
|
|
181
|
+
display: block;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.show-all {
|
|
186
|
+
margin-top: 10px;
|
|
187
|
+
border: 0;
|
|
188
|
+
background: var(--pill-bck);
|
|
189
|
+
color: rgba(0, 0, 0, 0.78);
|
|
190
|
+
font-weight: 500;
|
|
191
|
+
padding: 10px 12px;
|
|
192
|
+
border-radius: 999px;
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
transition: filter 140ms ease, transform 140ms ease;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.show-all:hover {
|
|
198
|
+
filter: brightness(0.98);
|
|
199
|
+
transform: translateY(-1px);
|
|
200
|
+
}
|
|
201
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
|
2
|
+
import { getTopLevelDomainFromUrl } from 'src/app/utils/url-utils';
|
|
3
|
+
|
|
4
|
+
export type JsonSourceItem = {
|
|
5
|
+
title?: string;
|
|
6
|
+
link?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
favicon?: string;
|
|
9
|
+
favicon_hd?: string;
|
|
10
|
+
image?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
@Component({
|
|
14
|
+
selector: 'chat-json-sources',
|
|
15
|
+
templateUrl: './json-sources.component.html',
|
|
16
|
+
styleUrls: ['./json-sources.component.scss']
|
|
17
|
+
})
|
|
18
|
+
export class JsonSourcesComponent {
|
|
19
|
+
@Input() items: JsonSourceItem[] = [];
|
|
20
|
+
@Input() themeColor?: string;
|
|
21
|
+
@Input() limit = 3;
|
|
22
|
+
|
|
23
|
+
@Output() onElementRendered = new EventEmitter<{ element: string; status: boolean }>();
|
|
24
|
+
|
|
25
|
+
showAll = false;
|
|
26
|
+
|
|
27
|
+
trackByLink = (_: number, item: JsonSourceItem) => item?.link || item?.title || _;
|
|
28
|
+
|
|
29
|
+
ngAfterViewInit() {
|
|
30
|
+
this.onElementRendered.emit({ element: 'json_sources', status: true });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getFavicon(item: JsonSourceItem): string | null {
|
|
34
|
+
const domain = getTopLevelDomainFromUrl(item?.link || '');
|
|
35
|
+
if (!domain) return null;
|
|
36
|
+
const explicit = (item?.favicon_hd || item?.favicon || '').trim();
|
|
37
|
+
if (explicit) {
|
|
38
|
+
try {
|
|
39
|
+
const faviconDomain = getTopLevelDomainFromUrl(explicit);
|
|
40
|
+
return faviconDomain ? explicit.replace(new URL(explicit).hostname, faviconDomain) : explicit;
|
|
41
|
+
} catch {
|
|
42
|
+
return explicit;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return `https://favicon.im/${domain}`;
|
|
46
|
+
//return `https://${domain}/favicon.ico`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
getHostname(item: JsonSourceItem): string {
|
|
50
|
+
const hostname = this.safeHostname(item?.link || '');
|
|
51
|
+
return hostname || '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private safeHostname(url: string): string {
|
|
55
|
+
try {
|
|
56
|
+
return new URL(url).hostname.replace(/^www\./, '');
|
|
57
|
+
} catch {
|
|
58
|
+
return '';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get visibleItems(): JsonSourceItem[] {
|
|
63
|
+
if (!this.items) return [];
|
|
64
|
+
const normalizedLimit = Math.max(1, this.limit || 1);
|
|
65
|
+
return this.showAll ? this.items : this.items.slice(0, normalizedLimit);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get headerFavicons(): JsonSourceItem[] {
|
|
69
|
+
const seen = new Set<string>();
|
|
70
|
+
return (this.items || []).reduce<JsonSourceItem[]>((acc, item) => {
|
|
71
|
+
const url = this.getFavicon(item);
|
|
72
|
+
if (url && !seen.has(url)) {
|
|
73
|
+
seen.add(url);
|
|
74
|
+
acc.push(item);
|
|
75
|
+
}
|
|
76
|
+
return acc;
|
|
77
|
+
}, []).slice(0, 3);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get canExpand(): boolean {
|
|
81
|
+
const normalizedLimit = Math.max(1, this.limit || 1);
|
|
82
|
+
return (this.items?.length || 0) > normalizedLimit;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
toggleShowAll() {
|
|
86
|
+
this.showAll = !this.showAll;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
<div class="like-container">
|
|
2
2
|
<div class="menu">
|
|
3
3
|
<!-- LIKE -->
|
|
4
|
-
<button class="c21-button-clean c21-like" (click)="onClick('like')">
|
|
5
|
-
<svg
|
|
6
|
-
width="24" height="24" viewBox="0 0 24 24" xml:space="preserve">
|
|
4
|
+
<button type="button" class="c21-button-clean c21-like" (click)="onClick('like')" aria-label="Like message">
|
|
5
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
6
|
+
width="24" height="24" viewBox="0 0 24 24" xml:space="preserve" aria-hidden="true" focusable="false">
|
|
7
7
|
<path fill="black" d="M4.5,9h-3C0.7,9,0,9.6,0,10.4v10.4c0,0.8,0.7,1.5,1.5,1.5h3c0.8,0,1.5-0.7,1.5-1.5V10.5C6,9.7,5.3,9,4.5,9z"/>
|
|
8
8
|
<path fill="black" d="M24,10.5c-0.1-1.7-1.6-3-3.3-3h-4.5c0,0,0,0,0,0c0.4-1.2,0.7-2.2,0.7-2.7c0-1.6-1.2-3.2-3.3-3.2 c-2.2,0-2.8,1.5-3.3,2.7C8.8,8,7.5,7.4,7.5,8.6c0,0.6,0.5,1.1,1.1,1.1c0.2,0,0.5-0.1,0.7-0.2c3.6-2.9,2.7-5.8,4.3-5.8 c0.8,0,1,0.6,1,1c0,0.3-0.4,1.9-1.2,3.4c-0.1,0.2-0.1,0.4-0.1,0.5c0,0.7,0.5,1.1,1.1,1.1h6.5c0.5,0,0.9,0.4,0.9,0.9 c0,0.5-0.4,0.8-0.8,0.9c-0.6,0-1,0.5-1,1.1c0,0.7,0.5,0.7,0.5,1.4c0,1.2-1.6,0.6-1.6,2c0,0.5,0.3,0.6,0.3,1c0,1.1-1.4,0.6-1.4,1.9 c0,0.1,0,0.2,0,0.2c0.1,0.6-0.3,1.1-0.9,1.1l-2.4,0c-1.2,0-2.4-0.4-3.4-1.1l-1.7-1.3c-0.2-0.2-0.4-0.2-0.7-0.2 c-0.6,0-1.1,0.5-1.1,1.1c0,0.3,0.2,0.7,0.4,0.9l1.7,1.3c1.4,1,3,1.6,4.7,1.6h2.5c1.7,0,3-1.3,3.1-2.9c0,0,0,0,0,0 c0.8-0.6,1.3-1.5,1.3-2.6c0-0.1,0-0.3,0-0.4c0.8-0.6,1.4-1.5,1.4-2.6c0-0.2,0-0.5-0.1-0.7C23.5,12.6,24.1,11.6,24,10.5z"/>
|
|
9
|
-
|
|
10
|
-
</svg>
|
|
9
|
+
</svg>
|
|
11
10
|
</button>
|
|
12
11
|
<!-- UNLIKE -->
|
|
13
|
-
<button class="c21-button-clean" (click)="onClick('
|
|
14
|
-
<svg
|
|
15
|
-
width="24" height="24" viewBox="0 0 24 24" xml:space="preserve">
|
|
12
|
+
<button type="button" class="c21-button-clean" (click)="onClick('unlike')" aria-label="Unlike message">
|
|
13
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
14
|
+
width="24" height="24" viewBox="0 0 24 24" xml:space="preserve" aria-hidden="true" focusable="false">
|
|
16
15
|
<path d="M6,13.5V3c0-0.8-0.7-1.5-1.5-1.5h-3C0.7,1.5,0,2.2,0,3v10.5c0,0.8,0.7,1.5,1.5,1.5h3C5.3,15,6,14.3,6,13.5z"/>
|
|
17
16
|
<path d="M22.6,10.7c0.1-0.2,0.1-0.5,0.1-0.7c0-1.1-0.5-2-1.4-2.6c0-0.1,0-0.3,0-0.4c0-1-0.5-2-1.4-2.6c-0.1-1.6-1.5-2.9-3.1-2.9 h-2.5c-1.7,0-3.4,0.6-4.7,1.6L8,4.4C7.7,4.6,7.5,4.9,7.5,5.3c0,0.6,0.5,1.1,1.1,1.1c0.2,0,0.5-0.1,0.7-0.2L11,4.9 c1-0.7,2.2-1.1,3.4-1.1h2.5c0.5,0,0.9,0.4,0.9,0.9c0,0.2-0.1,0.2-0.1,0.4c0,1.3,1.4,0.8,1.4,1.9c0,0.4-0.3,0.5-0.3,1 c0,0.7,0.5,1,0.9,1.1c0.4,0.1,0.7,0.4,0.7,0.9c0,0.6-0.5,0.6-0.5,1.4c0,0.6,0.5,1.1,1,1.1c0.5,0,0.8,0.4,0.8,0.8 c0,0.5-0.4,0.9-0.9,0.9h-6.5c-0.6,0-1.1,0.5-1.1,1.1c0,0.2,0,0.4,0.1,0.5c0.8,1.6,1.2,3.1,1.2,3.4c0,0.4-0.3,1-1,1 c-0.6,0-0.7,0-1.2-1.3c-1.2-2.9-2.9-4.7-3.8-4.7c-0.6,0-1.1,0.5-1.1,1.1c0,0.3,0.1,0.7,0.4,0.9c3.2,2.6,2,6.2,5.7,6.2 c2.1,0,3.3-1.6,3.3-3.2c0-0.6-0.2-1.7-0.7-2.8h4.7c1.7,0,3.1-1.4,3.1-3.2C24,12.3,23.4,11.3,22.6,10.7z"/>
|
|
18
|
-
<title id="altIconTitle">UNLIKE</title>
|
|
19
17
|
</svg>
|
|
20
18
|
</button>
|
|
21
19
|
</div>
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { By } from '@angular/platform-browser';
|
|
3
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
4
|
+
import { CustomLogger } from 'src/chat21-core/providers/logger/customLogger';
|
|
5
|
+
import { NGXLogger } from 'ngx-logger';
|
|
2
6
|
|
|
3
7
|
import { LikeUnlikeComponent } from './like-unlike.component';
|
|
4
8
|
|
|
5
9
|
describe('LikeUnlikeComponent', () => {
|
|
6
10
|
let component: LikeUnlikeComponent;
|
|
7
11
|
let fixture: ComponentFixture<LikeUnlikeComponent>;
|
|
12
|
+
const ngxlogger = jasmine.createSpyObj('NGXLogger', ['log', 'trace', 'debug', 'warn', 'error', 'info']);
|
|
13
|
+
const customLogger = new CustomLogger(ngxlogger);
|
|
8
14
|
|
|
9
15
|
beforeEach(async () => {
|
|
16
|
+
LoggerInstance.setInstance(customLogger);
|
|
10
17
|
await TestBed.configureTestingModule({
|
|
11
|
-
declarations: [
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
18
|
+
declarations: [LikeUnlikeComponent],
|
|
19
|
+
}).compileComponents();
|
|
14
20
|
});
|
|
15
21
|
|
|
16
22
|
beforeEach(() => {
|
|
@@ -22,4 +28,26 @@ describe('LikeUnlikeComponent', () => {
|
|
|
22
28
|
it('should create', () => {
|
|
23
29
|
expect(component).toBeTruthy();
|
|
24
30
|
});
|
|
31
|
+
|
|
32
|
+
it('onClick should log icon id', () => {
|
|
33
|
+
spyOn((component as any).logger, 'debug');
|
|
34
|
+
component.onClick('like');
|
|
35
|
+
expect((component as any).logger.debug).toHaveBeenCalledWith('[LIKE-UNLIKE] onClick-->', 'like');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('like button should have accessible name', () => {
|
|
39
|
+
const btn = fixture.debugElement.queryAll(By.css('button'))[0];
|
|
40
|
+
expect(btn.nativeElement.getAttribute('aria-label')).toBe('Like message');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('unlike button should have accessible name', () => {
|
|
44
|
+
const btn = fixture.debugElement.queryAll(By.css('button'))[1];
|
|
45
|
+
expect(btn.nativeElement.getAttribute('aria-label')).toBe('Unlike message');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('clicking like should invoke logger', () => {
|
|
49
|
+
spyOn((component as any).logger, 'debug');
|
|
50
|
+
fixture.debugElement.queryAll(By.css('button'))[0].triggerEventHandler('click', {});
|
|
51
|
+
expect((component as any).logger.debug).toHaveBeenCalledWith('[LIKE-UNLIKE] onClick-->', 'like');
|
|
52
|
+
});
|
|
25
53
|
});
|