favesalon-embed 0.1.0 → 1.0.1

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 (127) hide show
  1. package/dist/cjs/chat-button.cjs.entry.js +118 -0
  2. package/dist/cjs/favesalon-embed.cjs.js +7 -3
  3. package/dist/cjs/google-map_5.cjs.entry.js +26 -7
  4. package/dist/cjs/{index-e6bea8f5.js → index-47c2a5f6.js} +512 -208
  5. package/dist/cjs/loader.cjs.js +4 -3
  6. package/dist/cjs/relativeTime-3721080d.js +9 -0
  7. package/dist/cjs/salon-booking-modal.cjs.entry.js +3 -2
  8. package/dist/cjs/salon-booking.cjs.entry.js +3 -2
  9. package/dist/cjs/salon-gift-card-modal.cjs.entry.js +3 -2
  10. package/dist/cjs/salon-gift-card.cjs.entry.js +3 -2
  11. package/dist/cjs/salon-latest-reviews.cjs.entry.js +5 -3
  12. package/dist/cjs/salon-lookbook.cjs.entry.js +7 -3
  13. package/dist/cjs/salon-ranking.cjs.entry.js +3 -2
  14. package/dist/cjs/salon-reviews.cjs.entry.js +10 -3
  15. package/dist/cjs/salon-services.cjs.entry.js +6 -3
  16. package/dist/cjs/salon-stylists.cjs.entry.js +9 -3
  17. package/dist/cjs/services-125c82d8.js +21492 -0
  18. package/dist/cjs/style-detail.cjs.entry.js +11 -9
  19. package/dist/cjs/user-avatar.cjs.entry.js +7 -3
  20. package/dist/collection/collection-manifest.json +3 -2
  21. package/dist/collection/components/chat-button/index.css +122 -0
  22. package/dist/collection/components/chat-button/index.js +218 -0
  23. package/dist/collection/components/chat-conversation/index.js +103 -0
  24. package/dist/collection/components/google-map/index.js +72 -68
  25. package/dist/collection/components/salon-booking/index.css +5 -0
  26. package/dist/collection/components/salon-booking/index.js +85 -80
  27. package/dist/collection/components/salon-booking/salon-booking-modal.js +73 -69
  28. package/dist/collection/components/salon-gift-card/index.css +6 -1
  29. package/dist/collection/components/salon-gift-card/index.js +85 -80
  30. package/dist/collection/components/salon-gift-card/salon-gift-card-modal.js +56 -52
  31. package/dist/collection/components/salon-info/index.css +1 -0
  32. package/dist/collection/components/salon-info/index.js +60 -54
  33. package/dist/collection/components/salon-latest-reviews/index.css +3 -0
  34. package/dist/collection/components/salon-latest-reviews/index.js +131 -144
  35. package/dist/collection/components/salon-latest-styles/index.css +2 -0
  36. package/dist/collection/components/salon-latest-styles/index.js +143 -138
  37. package/dist/collection/components/salon-locations/index.css +3 -0
  38. package/dist/collection/components/salon-locations/index.js +112 -120
  39. package/dist/collection/components/salon-lookbook/index.css +3 -0
  40. package/dist/collection/components/salon-lookbook/index.js +182 -190
  41. package/dist/collection/components/salon-ranking/index.js +68 -65
  42. package/dist/collection/components/salon-reviews/index.css +3 -0
  43. package/dist/collection/components/salon-reviews/index.js +146 -183
  44. package/dist/collection/components/salon-schedules/index.css +3 -0
  45. package/dist/collection/components/salon-schedules/index.js +129 -151
  46. package/dist/collection/components/salon-services/index.css +1 -0
  47. package/dist/collection/components/salon-services/index.js +117 -127
  48. package/dist/collection/components/salon-stylists/index.css +8 -0
  49. package/dist/collection/components/salon-stylists/index.js +137 -136
  50. package/dist/collection/components/style-detail/index.css +14 -0
  51. package/dist/collection/components/style-detail/index.js +265 -340
  52. package/dist/collection/components/user-avatar/index.js +119 -112
  53. package/dist/collection/mocks/users.js +10 -0
  54. package/dist/collection/services/services.js +121 -0
  55. package/dist/collection/types/chat.js +23 -0
  56. package/dist/collection/types/user.js +1 -1
  57. package/dist/custom-elements/index.d.ts +6 -0
  58. package/dist/custom-elements/index.js +24628 -8605
  59. package/dist/esm/chat-button.entry.js +114 -0
  60. package/dist/esm/favesalon-embed.js +4 -3
  61. package/dist/esm/google-map_5.entry.js +26 -7
  62. package/dist/esm/{index-6af0a03d.js → index-3fae868e.js} +512 -209
  63. package/dist/esm/loader.js +4 -3
  64. package/dist/esm/polyfills/css-shim.js +1 -1
  65. package/dist/esm/relativeTime-cd452e6d.js +7 -0
  66. package/dist/esm/salon-booking-modal.entry.js +3 -2
  67. package/dist/esm/salon-booking.entry.js +3 -2
  68. package/dist/esm/salon-gift-card-modal.entry.js +3 -2
  69. package/dist/esm/salon-gift-card.entry.js +3 -2
  70. package/dist/esm/salon-latest-reviews.entry.js +5 -3
  71. package/dist/esm/salon-lookbook.entry.js +7 -3
  72. package/dist/esm/salon-ranking.entry.js +3 -2
  73. package/dist/esm/salon-reviews.entry.js +10 -3
  74. package/dist/esm/salon-services.entry.js +6 -3
  75. package/dist/esm/salon-stylists.entry.js +9 -3
  76. package/dist/esm/services-40a3e622.js +21485 -0
  77. package/dist/esm/style-detail.entry.js +10 -8
  78. package/dist/esm/user-avatar.entry.js +7 -3
  79. package/dist/favesalon-embed/favesalon-embed.esm.js +1 -1
  80. package/dist/favesalon-embed/p-019c5ccd.entry.js +1 -0
  81. package/dist/favesalon-embed/p-083a8821.entry.js +1 -0
  82. package/dist/favesalon-embed/p-0d0ed9ea.entry.js +1 -0
  83. package/dist/favesalon-embed/p-119db8de.entry.js +1 -0
  84. package/dist/favesalon-embed/p-1432c51b.entry.js +1 -0
  85. package/dist/favesalon-embed/p-22093506.entry.js +1 -0
  86. package/dist/favesalon-embed/p-32b314e9.js +2 -0
  87. package/dist/favesalon-embed/p-4a5eca9a.js +1 -1
  88. package/dist/favesalon-embed/p-58d2e9be.js +1 -0
  89. package/dist/favesalon-embed/p-71404b6a.entry.js +1 -0
  90. package/dist/favesalon-embed/p-857c3a61.entry.js +1 -0
  91. package/dist/favesalon-embed/p-99ec77f7.entry.js +1 -0
  92. package/dist/favesalon-embed/p-b0c3673a.entry.js +1 -0
  93. package/dist/favesalon-embed/p-b287b1ea.entry.js +1 -0
  94. package/dist/favesalon-embed/p-b3af7842.entry.js +1 -0
  95. package/dist/favesalon-embed/p-b630ae68.js +1580 -0
  96. package/dist/favesalon-embed/p-ce2c1c9a.entry.js +1 -0
  97. package/dist/favesalon-embed/p-d9b7ad58.entry.js +1 -0
  98. package/dist/favesalon-embed/p-fc9a5551.js +1 -1
  99. package/dist/types/components/chat-button/index.d.ts +24 -0
  100. package/dist/types/components.d.ts +22 -0
  101. package/dist/types/mocks/users.d.ts +10 -0
  102. package/dist/types/services/services.d.ts +15 -0
  103. package/dist/types/stencil-public-runtime.d.ts +85 -11
  104. package/dist/types/types/chat.d.ts +17 -0
  105. package/loader/index.d.ts +9 -0
  106. package/loader/package.json +1 -0
  107. package/package.json +3 -3
  108. package/readme.md +2 -2
  109. package/dist/cjs/services-eee8f251.js +0 -5634
  110. package/dist/esm/services-295247b1.js +0 -5627
  111. package/dist/favesalon-embed/p-292b97ba.entry.js +0 -1
  112. package/dist/favesalon-embed/p-4869dfed.entry.js +0 -1
  113. package/dist/favesalon-embed/p-4aee4fd9.entry.js +0 -1
  114. package/dist/favesalon-embed/p-5528c705.entry.js +0 -1
  115. package/dist/favesalon-embed/p-612ad685.entry.js +0 -1
  116. package/dist/favesalon-embed/p-75aef7e0.entry.js +0 -1
  117. package/dist/favesalon-embed/p-8c780874.entry.js +0 -1
  118. package/dist/favesalon-embed/p-8dbf04c5.js +0 -1
  119. package/dist/favesalon-embed/p-9f31061a.entry.js +0 -1
  120. package/dist/favesalon-embed/p-a60d78e9.entry.js +0 -1
  121. package/dist/favesalon-embed/p-a6debdae.entry.js +0 -1
  122. package/dist/favesalon-embed/p-bad1e9a7.entry.js +0 -1
  123. package/dist/favesalon-embed/p-c2ecb365.js +0 -1
  124. package/dist/favesalon-embed/p-c7dea70c.entry.js +0 -1
  125. package/dist/favesalon-embed/p-f0e14641.entry.js +0 -1
  126. package/dist/types/types/tmp.d.ts +0 -0
  127. /package/dist/{collection/types/tmp.js → types/components/chat-conversation/index.d.ts} +0 -0
@@ -2,27 +2,29 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e6bea8f5.js');
6
- const services = require('./services-eee8f251.js');
7
- const _commonjsHelpers = require('./_commonjsHelpers-5cfcba41.js');
5
+ const index = require('./index-47c2a5f6.js');
6
+ const services = require('./services-125c82d8.js');
7
+ const relativeTime = require('./relativeTime-3721080d.js');
8
8
  const colors = require('./colors-38421769.js');
9
-
10
- var relativeTime = _commonjsHelpers.createCommonjsModule(function (module, exports) {
11
- !function(r,e){module.exports=e();}(_commonjsHelpers.commonjsGlobal,(function(){return function(r,e,t){r=r||{};var n=e.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,!0):i.diff(e,y.d,!0));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(""+p)),a="string"==typeof v?v.replace("%d",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return "function"==typeof M?M(a):M.replace("%s",a)},n.to=function(r,e){return i(r,e,this,!0)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)};}}));
12
- });
9
+ require('./_commonjsHelpers-5cfcba41.js');
13
10
 
14
11
  const indexCss = ".salon-modal.salon-modal--lookbook-detail .salon-modal--close{display:none !important}.salon-modal.salon-modal--lookbook-detail .salon-modal--content{background-color:#fff;position:fixed;top:0;right:0;bottom:0;left:0;width:100%;height:100%;z-index:1000;overflow-y:auto}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--image{height:240px !important}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--thumbnails{text-align:center}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--thumbnail{display:inline-block;margin-top:12px;margin-right:12px;height:40px;width:60px}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--button{border:none;position:absolute;top:50%;z-index:20;height:40px;width:40px;-moz-border-radius:50px;-webkit-border-radius:50px;border-radius:50px;-moz-transform:translate(0, -50%);-webkit-transform:translate(0, -50%);transform:translate(0, -50%)}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--prev{left:24px}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--next{right:24px}@media (min-width: 768px){.salon-modal.salon-modal--lookbook-detail .style-detail--slides--image{height:360px !important}}@media (min-width: 992px){.salon-modal.salon-modal--lookbook-detail .style-detail--slides--image{height:480px !important}.salon-modal.salon-modal--lookbook-detail .style-detail--slides--thumbnail{height:56px;width:72px}}";
15
12
 
16
- services.dayjs_min.extend(relativeTime);
17
- let StyleDetail = class {
13
+ services.dayjs_min.extend(relativeTime.relativeTime);
14
+ const StyleDetail = class {
18
15
  constructor(hostRef) {
19
16
  index.registerInstance(this, hostRef);
17
+ this.salonId = undefined;
18
+ this.salonLookbook = undefined;
19
+ this.lookbookInfo = undefined;
20
20
  this.isModalOpen = true;
21
21
  this.currentMediaIdx = 0;
22
+ this.currentMedia = undefined;
22
23
  this.albumMedias = [];
23
24
  this.similarStyles = [];
24
25
  this.totalComments = 0;
25
26
  this.lookbookComments = [];
27
+ this.isLayoutSetup = undefined;
26
28
  }
27
29
  componentWillLoad() {
28
30
  this.injectSDK();
@@ -2,15 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e6bea8f5.js');
5
+ const index = require('./index-47c2a5f6.js');
6
6
  const colors = require('./colors-38421769.js');
7
7
 
8
8
  const indexCss = "";
9
9
 
10
- let UserAvatar = class {
10
+ const UserAvatar = class {
11
11
  constructor(hostRef) {
12
12
  index.registerInstance(this, hostRef);
13
13
  this.size = 24;
14
+ this.name = undefined;
15
+ this.nameStyle = undefined;
16
+ this.shortName = undefined;
17
+ this.avatar = undefined;
14
18
  }
15
19
  render() {
16
20
  return (index.h("div", { style: { display: "flex", alignItems: "center" } }, this.avatar && (index.h("div", { style: {
@@ -33,7 +37,7 @@ let UserAvatar = class {
33
37
  height: `${this.size}px`,
34
38
  width: `${this.size}px`,
35
39
  minWidth: `${this.size}px`,
36
- } }, this.shortName)), index.h("div", { style: Object.assign({ flexShrink: '1', flexGrow: '1', marginLeft: '12px', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }, this.nameStyle) }, this.name)));
40
+ } }, this.shortName)), this.name && (index.h("div", { style: Object.assign({ flexShrink: '1', flexGrow: '1', marginLeft: '12px', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' }, this.nameStyle) }, this.name))));
37
41
  }
38
42
  };
39
43
  UserAvatar.style = indexCss;
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "entries": [
3
+ "./components/chat-button/index.js",
3
4
  "./components/google-map/index.js",
4
5
  "./components/salon-booking/index.js",
5
6
  "./components/salon-booking/salon-booking-modal.js",
@@ -20,8 +21,8 @@
20
21
  ],
21
22
  "compiler": {
22
23
  "name": "@stencil/core",
23
- "version": "2.9.0",
24
- "typescriptVersion": "4.2.3"
24
+ "version": "2.22.3",
25
+ "typescriptVersion": "4.9.4"
25
26
  },
26
27
  "collections": [],
27
28
  "bundles": []
@@ -0,0 +1,122 @@
1
+ chat-button {
2
+ display: inline-block;
3
+ position: relative;
4
+ }
5
+
6
+ .chat-button--indicator {
7
+ cursor: pointer;
8
+ position: absolute;
9
+ inset: 0;
10
+ }
11
+
12
+ .chat-button--counter {
13
+ background-color: rgb(240, 90, 97);
14
+ border: 1px solid rgb(255, 255, 255);
15
+ position: absolute;
16
+ right: -6px;
17
+ bottom: 12px;
18
+ height: 8px;
19
+ width: 8px;
20
+ -moz-border-radius: 8px;
21
+ -webkit-border-radius: 8px;
22
+ border-radius: 8px;
23
+ }
24
+
25
+ .chat-box {
26
+ background-color: #fff;
27
+ display: flex;
28
+ flex-direction: column;
29
+ position: fixed;
30
+ inset: 0px;
31
+ z-index: 20000;
32
+ }
33
+
34
+ .chat-box--header {
35
+ display: flex;
36
+ justify-content: space-between;
37
+ padding: 16px;
38
+ position: relative;
39
+ }
40
+
41
+ .chat-box--header-title {
42
+ color: #fff;
43
+ font-size: 20px;
44
+ font-weight: 600;
45
+ line-height: 1;
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: space-between;
49
+ margin: 0;
50
+ }
51
+
52
+
53
+ .chat-message {
54
+ overflow: hidden;
55
+ clear: both;
56
+ min-width: 240px;
57
+ }
58
+
59
+ .chat-message--meta {
60
+ display: flex;
61
+ }
62
+
63
+ .chat-message--message {
64
+ background-color: #F1F1F1;
65
+ padding: 8px 12px;
66
+ position: relative;
67
+ float: left;
68
+ margin-top: 6px;
69
+ -moz-border-radius: 0 10px 10px 10px;
70
+ -webkit-border-radius: 0 10px 10px 10px;
71
+ border-radius: 0 10px 10px 10px;
72
+ }
73
+
74
+ .chat-conversation--time {
75
+ clear: both;
76
+ color: #999;
77
+ font-size: 75%;
78
+ padding-top: 2px;
79
+ }
80
+
81
+ .chat-message.is-owner .chat-message--content {
82
+ margin-left: 12px;
83
+ }
84
+
85
+ .chat-message.is-guest .chat-message--meta {
86
+ flex-direction: row-reverse;
87
+ }
88
+ .chat-message.is-guest .chat-message--message {
89
+ background-color: #EFF7FF;
90
+ float: right;
91
+ margin-right: 12px;
92
+ text-align: right;
93
+ -moz-border-radius: 10px 0 10px 10px;
94
+ -webkit-border-radius: 10px 0 10px 10px;
95
+ border-radius: 10px 0 10px 10px;
96
+ }
97
+
98
+
99
+ @media (min-width: 768px) {
100
+ .chat-box {
101
+ border: 1px solid #fff;
102
+ left: unset;
103
+ top: unset;
104
+ right: 1px;
105
+ bottom: 0px;
106
+ height: 420px;
107
+ max-height: 90vh;
108
+ width: 600px;
109
+ -moz-border-radius: 8px 8px 0px 0px;
110
+ -webkit-border-radius: 8px 8px 0px 0px;
111
+ border-radius: 8px 8px 0px 0px;
112
+ -moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 24px;
113
+ -webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 24px;
114
+ box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 24px;
115
+ }
116
+
117
+ .chat-box--header {
118
+ -moz-border-radius: 8px 8px 0px 0px;
119
+ -webkit-border-radius: 8px 8px 0px 0px;
120
+ border-radius: 8px 8px 0px 0px;
121
+ }
122
+ }
@@ -0,0 +1,218 @@
1
+ import dayjs from 'dayjs';
2
+ import { h } from '@stencil/core';
3
+ import HttpService from '../../services/services';
4
+ import relativeTime from 'dayjs/plugin/relativeTime';
5
+ dayjs.extend(relativeTime);
6
+ export class ChatButton {
7
+ constructor() {
8
+ this.onSubmitMessage = async () => {
9
+ try {
10
+ const elNewMessage = document.getElementById('chat-form--input');
11
+ await HttpService().sendChatMessage({
12
+ message: elNewMessage.value,
13
+ senderId: this.senderInfo.id,
14
+ chatRoomId: this.chatRoom.uid,
15
+ });
16
+ elNewMessage.value = '';
17
+ }
18
+ catch (error) { }
19
+ };
20
+ this.markMessagesAsRead = async () => {
21
+ try {
22
+ const unreadMessages = (this.chatMessages || []).filter(message => {
23
+ return Boolean(message.unRead) && message.senderId !== this.senderInfo.id;
24
+ });
25
+ if (unreadMessages.length > 0) {
26
+ await HttpService().markMessagesAsRead(this.chatRoom.uid, unreadMessages);
27
+ }
28
+ }
29
+ catch (e) { }
30
+ };
31
+ this.scrollToLastMessage = () => {
32
+ const targetElement = document.getElementById('chat--last-message');
33
+ targetElement && targetElement.scrollIntoView();
34
+ };
35
+ this.renderMessage = (chatMessage) => {
36
+ const { message, senderId, timestamp } = chatMessage;
37
+ const isOwner = this.senderInfo.id === senderId;
38
+ 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.senderInfo : this.receiverInfo) || {}).fullName || '').charAt(0), avatar: ((isOwner ? this.senderInfo : this.receiverInfo) || {}).avatar }), h("div", { class: "chat-message--content" }, h("div", { class: "chat-message--message" }, message), timestamp && (h("div", { class: "chat-conversation--time" }, dayjs(timestamp).format('HH:mm')))))));
39
+ };
40
+ this.renderMessages = () => {
41
+ const isEmpty = (this.chatMessages || []).length === 0;
42
+ return (h("div", { class: "chat-messages" }, !isEmpty && this.chatMessages.map(this.renderMessage), isEmpty && (h("div", { style: { paddingTop: '48px', textAlign: 'center' } }, h("i", { class: "ri-bubble-chart-line", style: { fontSize: '48px' } }), h("div", { style: { color: 'rgba(0, 0, 0, 0.45)', marginTop: '8px' } }, "Enter a message on below to get starting"))), h("div", { id: "chat--last-message" })));
43
+ };
44
+ this.primaryColor = undefined;
45
+ this.accessToken = undefined;
46
+ this.senderId = undefined;
47
+ this.receiverId = undefined;
48
+ this.senderInfo = {};
49
+ this.receiverInfo = {};
50
+ this.chatRoom = undefined;
51
+ this.chatMessages = undefined;
52
+ this.isChatExpanded = undefined;
53
+ }
54
+ componentWillLoad() {
55
+ this.fetchData();
56
+ }
57
+ componentDidLoad() {
58
+ this.scrollToLastMessage();
59
+ this.markMessagesAsRead();
60
+ }
61
+ componentWillUpdate() {
62
+ this.scrollToLastMessage();
63
+ }
64
+ async fetchData() {
65
+ try {
66
+ this.chatRoom = await HttpService().createChatRoom(this.receiverId, this.accessToken);
67
+ if (this.chatRoom) {
68
+ HttpService().fetchChatMessages(this.chatRoom.uid, (messages) => this.chatMessages = messages);
69
+ this.senderInfo = this.chatRoom.members.find(user => user.id === Number(this.senderId));
70
+ this.receiverInfo = this.chatRoom.members.find(user => user.id === Number(this.receiverId));
71
+ }
72
+ }
73
+ catch (e) { }
74
+ }
75
+ renderForm() {
76
+ return (h("div", { style: { display: 'flex', height: '100%' } }, h("input", { id: "chat-form--input", type: "text", class: "form-control", placeholder: "Enter a message...", style: { border: 'none' }, onKeyPress: (evt) => {
77
+ if (evt.key === 'Enter') {
78
+ evt.preventDefault();
79
+ this.onSubmitMessage();
80
+ }
81
+ } }), h("button", { type: "button", class: "btn btn-link", style: {
82
+ textDecoration: 'none',
83
+ display: 'flex',
84
+ height: '100%',
85
+ alignItems: 'center',
86
+ }, onClick: () => this.onSubmitMessage() }, h("i", { class: "ri-send-plane-2-line", style: { color: '#111', fontSize: '24px', lineHeight: '1' } }))));
87
+ }
88
+ render() {
89
+ const unreadMessages = (this.chatMessages || []).filter(message => {
90
+ return Boolean(message.unRead) && message.senderId !== this.senderInfo.id;
91
+ });
92
+ 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: {
93
+ backgroundColor: this.primaryColor || '#f05a61',
94
+ } }, h("h3", { class: "chat-box--header-title" }, "Chat"), h("div", { class: "salon-modal--close", onClick: () => this.isChatExpanded = false, style: { position: 'static' } })), h("div", { style: {
95
+ flexShrink: '1',
96
+ flexGrow: '1',
97
+ overflowY: 'auto',
98
+ padding: '16px',
99
+ } }, this.renderMessages()), h("div", { style: {
100
+ height: '50px',
101
+ minHeight: '50px',
102
+ paddingTop: '1',
103
+ borderTop: '1px solid rgb(245, 245, 245)',
104
+ } }, this.renderForm()))));
105
+ }
106
+ static get is() { return "chat-button"; }
107
+ static get originalStyleUrls() {
108
+ return {
109
+ "$": ["index.css"]
110
+ };
111
+ }
112
+ static get styleUrls() {
113
+ return {
114
+ "$": ["index.css"]
115
+ };
116
+ }
117
+ static get properties() {
118
+ return {
119
+ "primaryColor": {
120
+ "type": "string",
121
+ "mutable": false,
122
+ "complexType": {
123
+ "original": "string",
124
+ "resolved": "string",
125
+ "references": {}
126
+ },
127
+ "required": false,
128
+ "optional": false,
129
+ "docs": {
130
+ "tags": [],
131
+ "text": ""
132
+ },
133
+ "attribute": "primary-color",
134
+ "reflect": false
135
+ },
136
+ "accessToken": {
137
+ "type": "string",
138
+ "mutable": false,
139
+ "complexType": {
140
+ "original": "string",
141
+ "resolved": "string",
142
+ "references": {}
143
+ },
144
+ "required": false,
145
+ "optional": false,
146
+ "docs": {
147
+ "tags": [],
148
+ "text": ""
149
+ },
150
+ "attribute": "access-token",
151
+ "reflect": false
152
+ },
153
+ "senderId": {
154
+ "type": "string",
155
+ "mutable": false,
156
+ "complexType": {
157
+ "original": "string",
158
+ "resolved": "string",
159
+ "references": {}
160
+ },
161
+ "required": false,
162
+ "optional": false,
163
+ "docs": {
164
+ "tags": [],
165
+ "text": ""
166
+ },
167
+ "attribute": "sender-id",
168
+ "reflect": false
169
+ },
170
+ "receiverId": {
171
+ "type": "string",
172
+ "mutable": false,
173
+ "complexType": {
174
+ "original": "string",
175
+ "resolved": "string",
176
+ "references": {}
177
+ },
178
+ "required": false,
179
+ "optional": false,
180
+ "docs": {
181
+ "tags": [],
182
+ "text": ""
183
+ },
184
+ "attribute": "receiver-id",
185
+ "reflect": false
186
+ }
187
+ };
188
+ }
189
+ static get states() {
190
+ return {
191
+ "senderInfo": {},
192
+ "receiverInfo": {},
193
+ "chatRoom": {},
194
+ "chatMessages": {},
195
+ "isChatExpanded": {}
196
+ };
197
+ }
198
+ static get methods() {
199
+ return {
200
+ "fetchData": {
201
+ "complexType": {
202
+ "signature": "() => Promise<void>",
203
+ "parameters": [],
204
+ "references": {
205
+ "Promise": {
206
+ "location": "global"
207
+ }
208
+ },
209
+ "return": "Promise<void>"
210
+ },
211
+ "docs": {
212
+ "text": "",
213
+ "tags": []
214
+ }
215
+ }
216
+ };
217
+ }
218
+ }
@@ -0,0 +1,103 @@
1
+ // import { Component, Prop, h, Method, State } from '@stencil/core';
2
+ // import { User } from '../../types/user';
3
+ // import { ChatMessage, ChatRoom } from '../../types/chat';
4
+ // import HttpService from '../../services/services';
5
+ // @Component({
6
+ // tag: 'chat-conversation',
7
+ // styleUrl: 'index.css',
8
+ // })
9
+ // export class ChatButton {
10
+ // @Prop() primaryColor: string;
11
+ // @Prop() accessToken: string;
12
+ // @Prop() sender: User;
13
+ // @Prop() receiver: User;
14
+ // @State() chatRoom: ChatRoom;
15
+ // @State() chatMessages: ChatMessage[];
16
+ // componentWillLoad() {
17
+ // this.senderInfo = this.sender ? JSON.parse(this.sender) : null;
18
+ // this.receiverInfo = this.receiver ? JSON.parse(this.receiver) : null;
19
+ // this.fetchData();
20
+ // }
21
+ // @Method()
22
+ // async fetchData() {
23
+ // try {
24
+ // const chatRooms: ChatRoom[] = await HttpService().fetchChatRooms(this.accessToken);
25
+ // this.chatRoom = (chatRooms || []).find(chatRoom => {
26
+ // return chatRoom.members.find(user => user.id === this.receiverInfo.id);
27
+ // });
28
+ // if (this.chatRoom) {
29
+ // HttpService().fetchChatMessages(this.chatRoom.uid, (messages) => this.chatMessages = messages);
30
+ // }
31
+ // } catch(e) {}
32
+ // }
33
+ // render() {
34
+ // return (
35
+ // <div>
36
+ // <div
37
+ // class="chat-button--indicator"
38
+ // onClick={() => this.isChatExpanded = true}
39
+ // >
40
+ // <span class="chat-button--counter"></span>
41
+ // </div>
42
+ // <div
43
+ // class="chat-box"
44
+ // style={this.isChatExpanded ? {} : { display: 'none' }}
45
+ // >
46
+ // <div style={{
47
+ // backgroundColor: this.primaryColor || '#f05a61',
48
+ // display: 'flex',
49
+ // justifyContent: 'space-between',
50
+ // padding: '16px',
51
+ // position: 'relative',
52
+ // borderRadius: '8px 8px 0px 0px',
53
+ // }}>
54
+ // <h3 style={{
55
+ // color: '#fff',
56
+ // fontSize: '20px',
57
+ // fontWeight: '600',
58
+ // lineHeight: '1',
59
+ // display: 'flex',
60
+ // alignItems: 'center',
61
+ // justifyContent: 'space-between',
62
+ // margin: '0',
63
+ // }}>Chat</h3>
64
+ // <div
65
+ // class="salon-modal--close"
66
+ // onClick={() => this.isChatExpanded = false}
67
+ // style={{ position: 'static' }}
68
+ // />
69
+ // </div>
70
+ // <div style={{
71
+ // flexShrink: '1',
72
+ // flexGrow: '1',
73
+ // display: 'flex',
74
+ // flexDirection: 'column',
75
+ // }}>
76
+ // <div style={{ padding: '16px', flexGrow: '1', flexShrink: '1' }}>
77
+ // {/* <ChatConversation
78
+ // sender={senderUser}
79
+ // receiver={receiverUser}
80
+ // chatRoom={currentChatRoom}
81
+ // chatMessages={messages || []}
82
+ // /> */}
83
+ // ChatConversation
84
+ // </div>
85
+ // <div style={{
86
+ // height: '50px',
87
+ // paddingTop: '1',
88
+ // borderTop: '1px solid rgb(245, 245, 245)',
89
+ // }}>
90
+ // {/* <ChatForm
91
+ // sender={senderUser}
92
+ // receiver={receiverUser}
93
+ // chatRoom={currentChatRoom}
94
+ // onSendMessageSuccess={(chatMessage) => {}}
95
+ // /> */}
96
+ // Chat form
97
+ // </div>
98
+ // </div>
99
+ // </div>
100
+ // </div>
101
+ // );
102
+ // }
103
+ // }