favesalon-embed 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/dist/{favesalon-embed/_commonjsHelpers-9bc404fc.js → cjs/_commonjsHelpers-5cfcba41.js} +6 -14
  2. package/dist/cjs/chat-box_5.cjs.entry.js +17439 -0
  3. package/dist/cjs/chat-button.cjs.entry.js +55 -0
  4. package/dist/cjs/colors-38421769.js +69 -0
  5. package/dist/cjs/favesalon-embed.cjs.js +23 -0
  6. package/dist/cjs/google-map.cjs.entry.js +52 -0
  7. package/dist/{favesalon-embed/index-ac52896a.js → cjs/index-7f190886.js} +47 -454
  8. package/dist/cjs/index-dd8176c4.js +1531 -0
  9. package/dist/cjs/index.cjs.js +2 -0
  10. package/dist/cjs/loader.cjs.js +22 -0
  11. package/dist/cjs/relativeTime-3721080d.js +9 -0
  12. package/dist/cjs/salon-booking-modal.cjs.entry.js +30 -0
  13. package/dist/cjs/salon-booking.cjs.entry.js +51 -0
  14. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +29 -0
  15. package/dist/cjs/salon-gift-card.cjs.entry.js +51 -0
  16. package/dist/cjs/salon-info.cjs.entry.js +33 -0
  17. package/dist/cjs/salon-latest-reviews.cjs.entry.js +97 -0
  18. package/dist/cjs/salon-latest-styles_3.cjs.entry.js +241 -0
  19. package/dist/cjs/salon-lookbook.cjs.entry.js +222 -0
  20. package/dist/cjs/salon-ranking.cjs.entry.js +60 -0
  21. package/dist/cjs/salon-reviews.cjs.entry.js +193 -0
  22. package/dist/cjs/salon-services.cjs.entry.js +81 -0
  23. package/dist/cjs/salon-stylists.cjs.entry.js +118 -0
  24. package/dist/{favesalon-embed/services-7cb8f2a6.js → cjs/services-d1bdf299.js} +55 -2415
  25. package/dist/cjs/style-detail.cjs.entry.js +312 -0
  26. package/dist/cjs/utils-c5a33b3c.js +23 -0
  27. package/dist/collection/collection-manifest.json +33 -0
  28. package/dist/collection/components/chat-box/index.css +105 -0
  29. package/dist/collection/components/chat-box/index.js +138 -0
  30. package/dist/collection/components/chat-button/index.css +101 -0
  31. package/dist/collection/components/chat-button/index.js +155 -0
  32. package/dist/collection/components/chat-form/index.css +40 -0
  33. package/dist/collection/components/chat-form/index.js +79 -0
  34. package/dist/collection/components/chat-messages/index.css +48 -0
  35. package/dist/collection/components/chat-messages/index.js +142 -0
  36. package/dist/collection/components/chat-rooms/index.css +102 -0
  37. package/dist/collection/components/chat-rooms/index.js +157 -0
  38. package/dist/collection/components/google-map/assets/map--placeholder.jpeg +0 -0
  39. package/dist/collection/components/google-map/index.css +5 -0
  40. package/dist/collection/components/google-map/index.js +90 -0
  41. package/dist/collection/components/salon-booking/index.css +30 -0
  42. package/dist/collection/components/salon-booking/index.js +126 -0
  43. package/dist/collection/components/salon-booking/salon-booking-modal.js +92 -0
  44. package/dist/collection/components/salon-gift-card/index.css +30 -0
  45. package/dist/collection/components/salon-gift-card/index.js +126 -0
  46. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +73 -0
  47. package/dist/collection/components/salon-info/index.css +1 -0
  48. package/dist/collection/components/salon-info/index.js +77 -0
  49. package/dist/collection/components/salon-latest-reviews/index.css +11 -0
  50. package/dist/collection/components/salon-latest-reviews/index.js +163 -0
  51. package/dist/collection/components/salon-latest-styles/index.css +12 -0
  52. package/dist/{favesalon-embed/salon-latest-styles.entry.js → collection/components/salon-latest-styles/index.js} +99 -14
  53. package/dist/collection/components/salon-locations/index.css +24 -0
  54. package/dist/{favesalon-embed/salon-locations.entry.js → collection/components/salon-locations/index.js} +95 -15
  55. package/dist/collection/components/salon-lookbook/index.css +15 -0
  56. package/dist/collection/components/salon-lookbook/index.js +368 -0
  57. package/dist/collection/components/salon-ranking/index.css +3 -0
  58. package/dist/collection/components/salon-ranking/index.js +117 -0
  59. package/dist/collection/components/salon-reviews/index.css +18 -0
  60. package/dist/collection/components/salon-reviews/index.js +249 -0
  61. package/dist/collection/components/salon-schedules/index.css +18 -0
  62. package/dist/{favesalon-embed/salon-schedules.entry.js → collection/components/salon-schedules/index.js} +95 -14
  63. package/dist/collection/components/salon-services/index.css +1 -0
  64. package/dist/collection/components/salon-services/index.js +146 -0
  65. package/dist/collection/components/salon-stylists/index.css +43 -0
  66. package/dist/collection/components/salon-stylists/index.js +184 -0
  67. package/dist/collection/components/style-detail/index.css +76 -0
  68. package/dist/collection/components/style-detail/index.js +386 -0
  69. package/dist/collection/components/user-avatar/index.css +0 -0
  70. package/dist/collection/components/user-avatar/index.js +159 -0
  71. package/dist/collection/constants/colors.js +65 -0
  72. package/dist/collection/global/global.js +0 -0
  73. package/dist/collection/index.js +1 -0
  74. package/dist/collection/mocks/users.js +10 -0
  75. package/dist/collection/services/services.js +295 -0
  76. package/dist/collection/types/chat.js +23 -0
  77. package/dist/collection/types/common.js +11 -0
  78. package/dist/collection/types/review.js +39 -0
  79. package/dist/collection/types/salon.js +58 -0
  80. package/dist/collection/types/service.js +24 -0
  81. package/dist/collection/types/style.js +128 -0
  82. package/dist/collection/types/stylist.js +30 -0
  83. package/dist/collection/types/user.js +10 -0
  84. package/dist/collection/utils/utils.js +23 -0
  85. package/dist/custom-elements/index.js +44974 -0
  86. package/dist/{favesalon-embed/_commonjsHelpers-a4f66ccd.js → esm/_commonjsHelpers-66ac50f5.js} +2 -14
  87. package/dist/{favesalon-embed/chat-rooms.entry.js → esm/chat-box_5.entry.js} +182 -30
  88. package/dist/{favesalon-embed → esm}/chat-button.entry.js +3 -3
  89. package/dist/esm/favesalon-embed.js +18 -0
  90. package/dist/{favesalon-embed → esm}/google-map.entry.js +1 -1
  91. package/dist/esm/index-0494771f.js +1504 -0
  92. package/dist/{favesalon-embed/index-00b83e1c.js → esm/index-a1c7583c.js} +15 -425
  93. package/dist/esm/index.js +1 -0
  94. package/dist/esm/loader.js +18 -0
  95. package/dist/esm/polyfills/core-js.js +11 -0
  96. package/dist/esm/polyfills/css-shim.js +1 -0
  97. package/dist/esm/polyfills/dom.js +79 -0
  98. package/dist/esm/polyfills/es5-html-element.js +1 -0
  99. package/dist/esm/polyfills/index.js +34 -0
  100. package/dist/esm/polyfills/system.js +6 -0
  101. package/dist/esm/relativeTime-baa50aa2.js +7 -0
  102. package/dist/{favesalon-embed → esm}/salon-booking-modal.entry.js +1 -1
  103. package/dist/{favesalon-embed → esm}/salon-booking.entry.js +3 -3
  104. package/dist/{favesalon-embed → esm}/salon-gift-card-modal.entry.js +1 -1
  105. package/dist/{favesalon-embed → esm}/salon-gift-card.entry.js +3 -3
  106. package/dist/{favesalon-embed → esm}/salon-info.entry.js +3 -3
  107. package/dist/{favesalon-embed → esm}/salon-latest-reviews.entry.js +4 -4
  108. package/dist/esm/salon-latest-styles_3.entry.js +235 -0
  109. package/dist/{favesalon-embed → esm}/salon-lookbook.entry.js +3 -3
  110. package/dist/{favesalon-embed → esm}/salon-ranking.entry.js +1 -1
  111. package/dist/{favesalon-embed → esm}/salon-reviews.entry.js +3 -3
  112. package/dist/{favesalon-embed → esm}/salon-services.entry.js +3 -3
  113. package/dist/{favesalon-embed → esm}/salon-stylists.entry.js +3 -3
  114. package/dist/{favesalon-embed/services-7c46a2fd.js → esm/services-257442e2.js} +99 -2467
  115. package/dist/{favesalon-embed → esm}/style-detail.entry.js +4 -4
  116. package/dist/{favesalon-embed/utils-2c19db45.js → esm/utils-e97485e0.js} +0 -6
  117. package/dist/favesalon-embed/favesalon-embed.css +1 -2439
  118. package/dist/favesalon-embed/favesalon-embed.esm.js +1 -148
  119. package/dist/favesalon-embed/index.esm.js +0 -1
  120. package/dist/favesalon-embed/p-05a1c88a.entry.js +1 -0
  121. package/dist/favesalon-embed/p-0acf0447.entry.js +1 -0
  122. package/dist/favesalon-embed/p-0bc4f624.js +1 -0
  123. package/dist/favesalon-embed/p-1af1515f.entry.js +1 -0
  124. package/dist/favesalon-embed/p-1cba5fc9.entry.js +1 -0
  125. package/dist/favesalon-embed/p-39a4ef15.entry.js +1 -0
  126. package/dist/favesalon-embed/p-3e2cb05b.entry.js +1 -0
  127. package/dist/favesalon-embed/p-47e646f8.js +1 -0
  128. package/dist/favesalon-embed/p-487b311f.entry.js +1 -0
  129. package/dist/favesalon-embed/p-55387c2f.entry.js +1 -0
  130. package/dist/favesalon-embed/p-566f05b4.entry.js +1 -0
  131. package/dist/favesalon-embed/p-862a0de0.entry.js +1 -0
  132. package/dist/favesalon-embed/p-9fe0cbeb.js +2 -0
  133. package/dist/favesalon-embed/p-a33331cc.js +1 -0
  134. package/dist/favesalon-embed/p-aeeb7b5f.entry.js +1 -0
  135. package/dist/favesalon-embed/p-b08e5b54.js +6 -0
  136. package/dist/favesalon-embed/p-b5cca5fc.entry.js +1 -0
  137. package/dist/favesalon-embed/p-c7fb7af5.js +1580 -0
  138. package/dist/favesalon-embed/p-ccab56d8.js +1 -0
  139. package/dist/favesalon-embed/p-d6e13053.entry.js +1 -0
  140. package/dist/favesalon-embed/p-dee42d34.entry.js +1 -0
  141. package/dist/favesalon-embed/p-e661ca1d.entry.js +1 -0
  142. package/dist/favesalon-embed/p-eeceab9c.entry.js +1 -0
  143. package/dist/index.cjs.js +1 -0
  144. package/dist/index.js +1 -0
  145. package/package.json +1 -1
  146. package/dist/favesalon-embed/app-globals-437cc3f3.js +0 -712
  147. package/dist/favesalon-embed/app-globals-60769a2c.js +0 -712
  148. package/dist/favesalon-embed/chat-box.entry.js +0 -54
  149. package/dist/favesalon-embed/chat-form.entry.js +0 -39
  150. package/dist/favesalon-embed/chat-messages.entry.js +0 -53
  151. package/dist/favesalon-embed/css-shim-b7d3d95f.js +0 -4
  152. package/dist/favesalon-embed/dom-64053c71.js +0 -73
  153. package/dist/favesalon-embed/index-04c09911.js +0 -3371
  154. package/dist/favesalon-embed/index-888e99e3.js +0 -3371
  155. package/dist/favesalon-embed/isObject-13b86c17.js +0 -203
  156. package/dist/favesalon-embed/relativeTime-15477f02.js +0 -7
  157. package/dist/favesalon-embed/relativeTime-268e64b0.js +0 -7
  158. package/dist/favesalon-embed/services-55a87166.js +0 -23655
  159. package/dist/favesalon-embed/shadow-css-98135883.js +0 -387
  160. package/dist/favesalon-embed/user-avatar.entry.js +0 -50
  161. /package/dist/{favesalon-embed → esm}/colors-ea36347a.js +0 -0
@@ -0,0 +1,101 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap');
2
+
3
+ chat-button {
4
+ position: relative;
5
+ }
6
+
7
+ .chat-button--indicator {
8
+ cursor: pointer;
9
+ position: absolute;
10
+ inset: 0;
11
+ }
12
+
13
+ .chat-button--counter {
14
+ background-color: rgb(240, 90, 97);
15
+ border: 1px solid rgb(255, 255, 255);
16
+ position: absolute;
17
+ right: 6px;
18
+ top: 0px;
19
+ height: 8px;
20
+ width: 8px;
21
+ -moz-border-radius: 8px;
22
+ -webkit-border-radius: 8px;
23
+ border-radius: 8px;
24
+ }
25
+
26
+
27
+ .chat-box {
28
+ font-family: 'Roboto', sans-serif;
29
+ -webkit-font-smoothing: antialiased;
30
+ -moz-osx-font-smoothing: grayscale;
31
+
32
+ background-color: #fff;
33
+ display: flex;
34
+ flex-direction: column;
35
+ position: fixed;
36
+ inset: 0px;
37
+ z-index: 20000;
38
+ font-size: 16px;
39
+ text-align: left;
40
+ color: #141414;
41
+ }
42
+
43
+ .chat-box--header {
44
+ display: flex;
45
+ justify-content: space-between;
46
+ padding: 16px;
47
+ position: relative;
48
+ }
49
+
50
+ .chat-box--title {
51
+ color: #fff;
52
+ font-size: 20px;
53
+ font-weight: 600;
54
+ line-height: 1;
55
+ display: flex;
56
+ align-items: center;
57
+ justify-content: space-between;
58
+ margin: 0;
59
+ }
60
+
61
+ .chat-box--close {
62
+ cursor: pointer;
63
+ display: block;
64
+ position: absolute;
65
+ z-index: 1000;
66
+ top: 50%;
67
+ right: 0;
68
+ width: 30px;
69
+ height: 30px;
70
+ transform: translate(0, -50%);
71
+ background-size: contain;
72
+ background-repeat: no-repeat;
73
+ background-position: center center;
74
+ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAA3hJREFUaAXlm8+K00Acx7MiCIJH/yw+gA9g25O49SL4AO3Bp1jw5NvktC+wF88qevK4BU97EmzxUBCEolK/n5gp3W6TTJPfpNPNF37MNsl85/vN/DaTmU6PknC4K+pniqeKJ3k8UnkvDxXJzzy+q/yaxxeVHxW/FNHjgRSeKt4rFoplzaAuHHDBGR2eS9G54reirsmienDCTRt7xwsp+KAoEmt9nLaGitZxrBbPFNaGfPloGw2t4JVamSt8xYW6Dg1oCYo3Yv+rCGViV160oMkcd8SYKnYV1Nb1aEOjCe6L5ZOiLfF120EjWhuBu3YIZt1NQmujnk5F4MgOpURzLfAwOBSTmzp3fpDxuI/pabxpqOoz2r2HLAb0GMbZKlNV5/Hg9XJypguryA7lPF5KMdTZQzHjqxNPhWhzIuAruOl1eNqKEx1tSh5rfbxdw7mOxCq4qS68ZTjKS1YVvilu559vWvFHhh4rZrdyZ69Vmpgdj8fJbDZLJpNJ0uv1cnr/gjrUhQMuI+ANjyuwftQ0bbL6Erp0mM/ny8Fg4M3LtdRxgMtKl3jwmIHVxYXChFy94/Rmpa/pTbNUhstKV+4Rr8lLQ9KlUvJKLyG8yvQ2s9SBy1Jb7jV5a0yapfF6apaZLjLLcWtd4sNrmJUMHyM+1xibTjH82Zh01TNlhsrOhdKTe00uAzZQmN6+KW+sDa/JD2PSVQ873m29yf+1Q9VDzfEYlHi1G5LKBBWZbtEsHbFwb1oYDwr1ZiF/2bnCSg1OBE/pfr9/bWx26UxJL3ONPISOLKUvQza0LZUxSKyjpdTGa/vDEr25rddbMM0Q3O6Lx3rqFvU+x6UrRKQY7tyrZecmD9FODy8uLizTmilwNj0kraNcAJhOp5aGVwsAGD5VmJBrWWbJSgWT9zrzWepQF47RaGSiKfeGx6Szi3gzmX/HHbihwBser4B9UJYpFBNX4R6vTn3VQnez0SymnrHQMsRYGTr1dSk34ljRqS/EMd2pLQ8YBp3a1PLfcqCpo8gtHkZFHKkTX6fs3MY0blKnth66rKCnU0VRGu37ONrQaA4eZDFtWAu2fXj9zjFkxTBOo8F7t926gTp/83Kyzzcy2kZD6xiqxTYnHLRFm3vHiRSwNSjkz3hoIzo8lCKWUlg/YtGs7tObunDAZfpDLbfEI15zsEIY3U/x/gHHc/G1zltnAgAAAABJRU5ErkJggg==');
75
+ }
76
+
77
+
78
+ @media (min-width: 768px) {
79
+ .chat-box {
80
+ border: 1px solid #fff;
81
+ left: unset;
82
+ top: unset;
83
+ right: 1px;
84
+ bottom: 0px;
85
+ height: 420px;
86
+ max-height: 90vh;
87
+ width: 600px;
88
+ -moz-border-radius: 8px 8px 0px 0px;
89
+ -webkit-border-radius: 8px 8px 0px 0px;
90
+ border-radius: 8px 8px 0px 0px;
91
+ -moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 24px;
92
+ -webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 24px;
93
+ box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 24px;
94
+ }
95
+
96
+ .chat-box--header {
97
+ -moz-border-radius: 8px 8px 0px 0px;
98
+ -webkit-border-radius: 8px 8px 0px 0px;
99
+ border-radius: 8px 8px 0px 0px;
100
+ }
101
+ }
@@ -0,0 +1,155 @@
1
+ import { h } from '@stencil/core';
2
+ import { Colors } from '../../constants/colors';
3
+ import HttpService from '../../services/services';
4
+ export class ChatButton {
5
+ constructor() {
6
+ this.primaryColor = undefined;
7
+ this.accessToken = undefined;
8
+ this.senderId = undefined;
9
+ this.receiverId = undefined;
10
+ this.senderInfo = {};
11
+ this.receiverInfo = {};
12
+ this.chatRoom = {};
13
+ this.chatMessages = undefined;
14
+ this.isChatExpanded = undefined;
15
+ }
16
+ componentWillLoad() {
17
+ this.fetchData();
18
+ }
19
+ async fetchData() {
20
+ try {
21
+ this.chatRoom = await HttpService().createChatRoom(this.receiverId, this.accessToken);
22
+ if (this.chatRoom) {
23
+ HttpService().fetchChatMessages(this.chatRoom.uid, (messages) => this.chatMessages = messages);
24
+ this.senderInfo = this.chatRoom.members.find(user => user.id === Number(this.senderId));
25
+ this.receiverInfo = this.chatRoom.members.find(user => user.id === Number(this.receiverId));
26
+ }
27
+ }
28
+ catch (e) { }
29
+ }
30
+ render() {
31
+ const unreadMessages = (this.chatMessages || []).filter(message => {
32
+ return Boolean(message.unRead) && message.senderId !== this.senderInfo.id;
33
+ });
34
+ return (h("div", null, h("div", { class: "chat-button--indicator", onClick: () => this.isChatExpanded = true }, unreadMessages.length > 0 && h("span", { class: "chat-button--counter" })), h("div", { class: "chat-box", style: this.isChatExpanded ? {} : { display: 'none' } }, h("div", { class: "chat-box--header", style: {
35
+ backgroundColor: this.primaryColor || '#f05a61',
36
+ } }, h("h3", { class: "chat-box--title" }, "Chat"), h("div", { style: { position: 'relative' } }, h("div", { class: "chat-box--close", onClick: () => this.isChatExpanded = false }))), h("div", { style: {
37
+ flexShrink: '1',
38
+ flexGrow: '1',
39
+ overflowY: 'auto',
40
+ padding: '16px',
41
+ } }, h("chat-messages", { sender: this.senderInfo, receiver: this.receiverInfo, messages: this.chatMessages || [], "chat-room-id": this.chatRoom.uid })), h("div", { style: { borderTop: `1px solid ${Colors.Gray02}` } }, h("chat-form", { "sender-id": this.senderInfo.id ? Number(this.senderInfo.id) : null, "chat-room-id": this.chatRoom.uid })))));
42
+ }
43
+ static get is() { return "chat-button"; }
44
+ static get originalStyleUrls() {
45
+ return {
46
+ "$": ["index.css"]
47
+ };
48
+ }
49
+ static get styleUrls() {
50
+ return {
51
+ "$": ["index.css"]
52
+ };
53
+ }
54
+ static get properties() {
55
+ return {
56
+ "primaryColor": {
57
+ "type": "string",
58
+ "mutable": false,
59
+ "complexType": {
60
+ "original": "string",
61
+ "resolved": "string",
62
+ "references": {}
63
+ },
64
+ "required": false,
65
+ "optional": false,
66
+ "docs": {
67
+ "tags": [],
68
+ "text": ""
69
+ },
70
+ "attribute": "primary-color",
71
+ "reflect": false
72
+ },
73
+ "accessToken": {
74
+ "type": "string",
75
+ "mutable": false,
76
+ "complexType": {
77
+ "original": "string",
78
+ "resolved": "string",
79
+ "references": {}
80
+ },
81
+ "required": false,
82
+ "optional": false,
83
+ "docs": {
84
+ "tags": [],
85
+ "text": ""
86
+ },
87
+ "attribute": "access-token",
88
+ "reflect": false
89
+ },
90
+ "senderId": {
91
+ "type": "string",
92
+ "mutable": false,
93
+ "complexType": {
94
+ "original": "string",
95
+ "resolved": "string",
96
+ "references": {}
97
+ },
98
+ "required": false,
99
+ "optional": false,
100
+ "docs": {
101
+ "tags": [],
102
+ "text": ""
103
+ },
104
+ "attribute": "sender-id",
105
+ "reflect": false
106
+ },
107
+ "receiverId": {
108
+ "type": "string",
109
+ "mutable": false,
110
+ "complexType": {
111
+ "original": "string",
112
+ "resolved": "string",
113
+ "references": {}
114
+ },
115
+ "required": false,
116
+ "optional": false,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": ""
120
+ },
121
+ "attribute": "receiver-id",
122
+ "reflect": false
123
+ }
124
+ };
125
+ }
126
+ static get states() {
127
+ return {
128
+ "senderInfo": {},
129
+ "receiverInfo": {},
130
+ "chatRoom": {},
131
+ "chatMessages": {},
132
+ "isChatExpanded": {}
133
+ };
134
+ }
135
+ static get methods() {
136
+ return {
137
+ "fetchData": {
138
+ "complexType": {
139
+ "signature": "() => Promise<void>",
140
+ "parameters": [],
141
+ "references": {
142
+ "Promise": {
143
+ "location": "global"
144
+ }
145
+ },
146
+ "return": "Promise<void>"
147
+ },
148
+ "docs": {
149
+ "text": "",
150
+ "tags": []
151
+ }
152
+ }
153
+ };
154
+ }
155
+ }
@@ -0,0 +1,40 @@
1
+ .chat-form {
2
+ display: flex;
3
+ height: 56px;
4
+ width: 100%;
5
+ }
6
+
7
+ .chat-form #chat-form--input {
8
+ border: none;
9
+ outline: none;
10
+ flex-shrink: 1;
11
+ flex-grow: 1;
12
+ height: 100%;
13
+ font-size: 16px;
14
+ padding-left: 16px;
15
+ padding-right: 16px;
16
+
17
+ -moz-border-radius: 6px;
18
+ -webkit-border-radius: 6px;
19
+ border-radius: 6px;
20
+ }
21
+
22
+ .chat-form > button {
23
+ background-color: #001529;
24
+ border: none;
25
+ color: #fff;
26
+ cursor: pointer;
27
+ font-size: 16px;
28
+ min-width: 80px;
29
+ height: 42px;
30
+ margin: 7px;
31
+ -moz-border-radius: 4px;
32
+ -webkit-border-radius: 4px;
33
+ border-radius: 4px;
34
+ }
35
+
36
+ .chat-form > button:hover,
37
+ .chat-form > button:focus,
38
+ .chat-form > button:active {
39
+ background-color: #001529;
40
+ }
@@ -0,0 +1,79 @@
1
+ import { h } from '@stencil/core';
2
+ import HttpService from '../../services/services';
3
+ export class ChatForm {
4
+ constructor() {
5
+ this.onSubmitMessage = async () => {
6
+ try {
7
+ const elNewMessage = document.getElementById('chat-form--input');
8
+ if (!!elNewMessage.value) {
9
+ await HttpService().sendChatMessage({
10
+ message: elNewMessage.value,
11
+ senderId: this.senderId,
12
+ chatRoomId: this.chatRoomId,
13
+ });
14
+ elNewMessage.value = '';
15
+ }
16
+ }
17
+ catch (error) { }
18
+ };
19
+ this.senderId = undefined;
20
+ this.chatRoomId = undefined;
21
+ }
22
+ render() {
23
+ return (h("div", { class: "chat-form" }, h("input", { id: "chat-form--input", type: "text", placeholder: "Enter a message...", onKeyPress: (evt) => {
24
+ if (evt.key === 'Enter') {
25
+ evt.preventDefault();
26
+ this.onSubmitMessage();
27
+ }
28
+ } }), h("button", { type: "button", onClick: () => this.onSubmitMessage() }, "Send")));
29
+ }
30
+ static get is() { return "chat-form"; }
31
+ static get originalStyleUrls() {
32
+ return {
33
+ "$": ["index.css"]
34
+ };
35
+ }
36
+ static get styleUrls() {
37
+ return {
38
+ "$": ["index.css"]
39
+ };
40
+ }
41
+ static get properties() {
42
+ return {
43
+ "senderId": {
44
+ "type": "number",
45
+ "mutable": false,
46
+ "complexType": {
47
+ "original": "number",
48
+ "resolved": "number",
49
+ "references": {}
50
+ },
51
+ "required": false,
52
+ "optional": false,
53
+ "docs": {
54
+ "tags": [],
55
+ "text": ""
56
+ },
57
+ "attribute": "sender-id",
58
+ "reflect": false
59
+ },
60
+ "chatRoomId": {
61
+ "type": "string",
62
+ "mutable": false,
63
+ "complexType": {
64
+ "original": "string",
65
+ "resolved": "string",
66
+ "references": {}
67
+ },
68
+ "required": false,
69
+ "optional": false,
70
+ "docs": {
71
+ "tags": [],
72
+ "text": ""
73
+ },
74
+ "attribute": "chat-room-id",
75
+ "reflect": false
76
+ }
77
+ };
78
+ }
79
+ }
@@ -0,0 +1,48 @@
1
+ .chat-message {
2
+ overflow: hidden;
3
+ clear: both;
4
+ min-width: 240px;
5
+ }
6
+
7
+ .chat-message + .chat-message {
8
+ margin-top: 6px;
9
+ }
10
+
11
+ .chat-message--meta {
12
+ display: flex;
13
+ }
14
+
15
+ .chat-message--title {
16
+ background-color: #F1F1F1;
17
+ padding: 8px 12px;
18
+ position: relative;
19
+ float: left;
20
+ margin-top: 6px;
21
+ -moz-border-radius: 0 10px 10px 10px;
22
+ -webkit-border-radius: 0 10px 10px 10px;
23
+ border-radius: 0 10px 10px 10px;
24
+ }
25
+
26
+ .chat-message--time {
27
+ clear: both;
28
+ color: #999;
29
+ font-size: 75%;
30
+ padding-top: 2px;
31
+ }
32
+
33
+ .chat-message.is-owner .chat-message--content {
34
+ margin-left: 12px;
35
+ }
36
+
37
+ .chat-message.is-guest .chat-message--meta {
38
+ flex-direction: row-reverse;
39
+ }
40
+ .chat-message.is-guest .chat-message--title {
41
+ background-color: #EFF7FF;
42
+ float: right;
43
+ margin-right: 12px;
44
+ text-align: right;
45
+ -moz-border-radius: 10px 0 10px 10px;
46
+ -webkit-border-radius: 10px 0 10px 10px;
47
+ border-radius: 10px 0 10px 10px;
48
+ }
@@ -0,0 +1,142 @@
1
+ import dayjs from 'dayjs';
2
+ import { h } from '@stencil/core';
3
+ import { Colors } from '../../constants/colors';
4
+ import { dateFormat } from '../../types/common';
5
+ import HttpService from '../../services/services';
6
+ import relativeTime from 'dayjs/plugin/relativeTime';
7
+ dayjs.extend(relativeTime);
8
+ export class ChatMessages {
9
+ constructor() {
10
+ this.markMessagesAsRead = async () => {
11
+ try {
12
+ const unreadMessages = (this.messages || []).filter(message => {
13
+ return Boolean(message.unRead) && message.senderId !== this.sender.id;
14
+ });
15
+ if (unreadMessages.length > 0) {
16
+ await HttpService().markMessagesAsRead(this.chatRoomId, unreadMessages);
17
+ }
18
+ }
19
+ catch (e) { }
20
+ };
21
+ this.scrollToLastMessage = () => {
22
+ const targetElement = document.getElementById('chat--last-message');
23
+ targetElement && targetElement.scrollIntoView();
24
+ };
25
+ this.renderMessage = (chatMessage) => {
26
+ const { message, senderId, timestamp } = chatMessage;
27
+ const isOwner = this.sender.id === senderId;
28
+ const todayStr = dayjs().format(dateFormat);
29
+ const messageDayStr = dayjs(timestamp).format(dateFormat);
30
+ return (h("div", { class: `chat-message ${isOwner ? 'is-owner' : 'is-guest'}` }, h("div", { class: "chat-message--meta" }, h("user-avatar", { size: 40, shortName: String(((isOwner ? this.sender : this.receiver) || {}).fullName || '').charAt(0), avatar: ((isOwner ? this.sender : this.receiver) || {}).avatar }), h("div", { class: "chat-message--content" }, h("div", { class: "chat-message--title" }, message), timestamp && (h("div", { class: "chat-message--time" }, todayStr === messageDayStr ? dayjs(timestamp).format('HH:mm') : dayjs(timestamp).fromNow()))))));
31
+ };
32
+ this.sender = {};
33
+ this.receiver = {};
34
+ this.messages = [];
35
+ this.chatRoomId = undefined;
36
+ }
37
+ componentDidLoad() {
38
+ this.markMessagesAsRead();
39
+ }
40
+ componentDidUpdate() {
41
+ this.scrollToLastMessage();
42
+ }
43
+ render() {
44
+ const isEmpty = (this.messages || []).length === 0;
45
+ return (h("div", { class: "chat-messages" }, !isEmpty && this.messages.map(this.renderMessage), isEmpty && (h("div", { style: { padding: '48px', textAlign: 'center' } }, h("div", { style: { color: Colors.Green04 } }, "No messages yet"))), h("div", { id: "chat--last-message" })));
46
+ }
47
+ static get is() { return "chat-messages"; }
48
+ static get originalStyleUrls() {
49
+ return {
50
+ "$": ["index.css"]
51
+ };
52
+ }
53
+ static get styleUrls() {
54
+ return {
55
+ "$": ["index.css"]
56
+ };
57
+ }
58
+ static get properties() {
59
+ return {
60
+ "sender": {
61
+ "type": "unknown",
62
+ "mutable": false,
63
+ "complexType": {
64
+ "original": "User",
65
+ "resolved": "User",
66
+ "references": {
67
+ "User": {
68
+ "location": "import",
69
+ "path": "../../types/user"
70
+ }
71
+ }
72
+ },
73
+ "required": false,
74
+ "optional": false,
75
+ "docs": {
76
+ "tags": [],
77
+ "text": ""
78
+ },
79
+ "defaultValue": "{} as User"
80
+ },
81
+ "receiver": {
82
+ "type": "unknown",
83
+ "mutable": false,
84
+ "complexType": {
85
+ "original": "User",
86
+ "resolved": "User",
87
+ "references": {
88
+ "User": {
89
+ "location": "import",
90
+ "path": "../../types/user"
91
+ }
92
+ }
93
+ },
94
+ "required": false,
95
+ "optional": false,
96
+ "docs": {
97
+ "tags": [],
98
+ "text": ""
99
+ },
100
+ "defaultValue": "{} as User"
101
+ },
102
+ "messages": {
103
+ "type": "unknown",
104
+ "mutable": false,
105
+ "complexType": {
106
+ "original": "ChatMessage[]",
107
+ "resolved": "ChatMessage[]",
108
+ "references": {
109
+ "ChatMessage": {
110
+ "location": "import",
111
+ "path": "../../types/chat"
112
+ }
113
+ }
114
+ },
115
+ "required": false,
116
+ "optional": false,
117
+ "docs": {
118
+ "tags": [],
119
+ "text": ""
120
+ },
121
+ "defaultValue": "[]"
122
+ },
123
+ "chatRoomId": {
124
+ "type": "string",
125
+ "mutable": false,
126
+ "complexType": {
127
+ "original": "string",
128
+ "resolved": "string",
129
+ "references": {}
130
+ },
131
+ "required": false,
132
+ "optional": false,
133
+ "docs": {
134
+ "tags": [],
135
+ "text": ""
136
+ },
137
+ "attribute": "chat-room-id",
138
+ "reflect": false
139
+ }
140
+ };
141
+ }
142
+ }
@@ -0,0 +1,102 @@
1
+ chat-rooms,
2
+ .chat-rooms {
3
+ display: flex;
4
+ flex-direction: column;
5
+ height: 100%;
6
+ width: 100%;
7
+ }
8
+
9
+ .chat-rooms--search {
10
+ background-color: #001529;
11
+ border-bottom: 1px solid #EFEFEF;
12
+ display: flex;
13
+ padding: 16px;
14
+ }
15
+
16
+ .chat-rooms--search > input {
17
+ background-color: #F5F5F5;
18
+ border: 1px solid #EFEFEF;
19
+ height: 40px;
20
+ width: 100%;
21
+ font-size: 16px;
22
+ padding-left: 16px;
23
+ padding-right: 16px;
24
+
25
+ -moz-border-radius: 4px;
26
+ -webkit-border-radius: 4px;
27
+ border-radius: 4px;
28
+ }
29
+
30
+ .chat-rooms--search > input:hover,
31
+ .chat-rooms--search > input:active {
32
+ border: 1px solid #DBDBDB;
33
+ }
34
+
35
+ .chat-rooms--search > button {
36
+ background-color: #F5F5F5;
37
+ border: 1px solid #EFEFEF;
38
+ font-size: 16px;
39
+ min-width: 80px;
40
+ height: 40px;
41
+ margin-left: 12px;
42
+ -moz-border-radius: 4px;
43
+ -webkit-border-radius: 4px;
44
+ border-radius: 4px;
45
+ }
46
+
47
+ .chat-rooms--list {
48
+ flex-grow: 1;
49
+ flex-shrink: 1;
50
+ overflow-y: auto;
51
+ }
52
+
53
+ .chat-room {
54
+ cursor: pointer;
55
+ display: flex;
56
+ position: relative;
57
+ margin-bottom: 1px;
58
+ padding: 12px 16px;
59
+ }
60
+
61
+ .chat-room:hover,
62
+ .chat-room.is-active {
63
+ background-color: #F5F5F5;
64
+ }
65
+
66
+ .chat-room--user {
67
+ flex-grow: 1;
68
+ flex-shrink: 1;
69
+ overflow: hidden;
70
+ }
71
+
72
+ .chat-room--user-name {
73
+ font-size: 16px;
74
+ font-weight: 600;
75
+ line-height: 18px;
76
+ white-space: nowrap;
77
+ overflow: hidden;
78
+ text-overflow: ellipsis;
79
+ }
80
+
81
+ .chat-room--latest-message {
82
+ font-size: 12px;
83
+ line-height: 14px;
84
+ margin-top: 4px;
85
+ white-space: nowrap;
86
+ overflow: hidden;
87
+ text-overflow: ellipsis;
88
+ }
89
+
90
+ .chat-room--user-indicator {
91
+ background-color: rgb(240, 90, 97);
92
+ border: 1px solid rgb(255, 255, 255);
93
+ height: 8px;
94
+ width: 8px;
95
+ position: absolute;
96
+ right: 8px;
97
+ top: 50%;
98
+ transform: translate(0, -50%);
99
+ -moz-border-radius: 8px;
100
+ -webkit-border-radius: 8px;
101
+ border-radius: 8px;
102
+ }