@meetelise/chat 1.53.3 → 1.53.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetelise/chat",
3
- "version": "1.53.3",
3
+ "version": "1.53.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/MeetElise/chat-ui#readme",
@@ -6714,32 +6714,28 @@ xmlns="http://www.w3.org/2000/svg"
6714
6714
  style="transform: translateX(-${100*this.activeIndex}%);"
6715
6715
  >
6716
6716
  ${this.message.media.map((e,t)=>R`
6717
- <div class="image-item">
6718
- <a
6719
- class="image-link"
6720
- href="${e.url}"
6721
- target="_blank"
6722
- rel="noopener noreferrer"
6723
- >
6724
- <img
6725
- class=${ye({active:t===this.activeIndex})}
6726
- src=${e.url}
6727
- alt=""
6728
- />
6729
- </a>
6730
- <div class="image-info">
6731
- ${e.title?R`<p class="img-header">${e.title}</p>`:""}
6732
- ${e.description?R`<p class="img-desc">${e.description}</p>`:""}
6733
- </div>
6734
- </div>
6717
+ <a
6718
+ class="image-link"
6719
+ href="${e.url}"
6720
+ target="_blank"
6721
+ rel="noopener noreferrer"
6722
+ >
6723
+ <img
6724
+ class=${ye({active:t===this.activeIndex})}
6725
+ src=${e.url}
6726
+ alt=""
6727
+ />
6728
+ </a>
6735
6729
  `)}
6736
6730
  </div>
6737
- ${this.message.media.length>1?R` <button class="button prev" @click=${this.prevImage}>
6731
+ ${this.message.media.length>1?R`<div class="controls">
6732
+ <button class="button prev" @click=${this.prevImage}>
6738
6733
  &#10094;
6739
6734
  </button>
6740
6735
  <button class="button next" @click=${this.nextImage}>
6741
6736
  &#10095;
6742
- </button>`:""}
6737
+ </button>
6738
+ </div>`:""}
6743
6739
  </div>
6744
6740
  </div>`:R`<div class="message-inner-body">
6745
6741
  ${this.message.media.map(e=>R`<a
@@ -6750,12 +6746,15 @@ xmlns="http://www.w3.org/2000/svg"
6750
6746
  /></a>`)}
6751
6747
  </div>`:R``}};ic.styles=[Oe,Wu,u`
6752
6748
  /* This element is a flex item in a bubble capped below the chat width.
6753
- Without min-width: 0 it is at least as wide as all slides' captions
6754
- side by side, so the carousel spills out of the bubble and the chat. */
6749
+ Without min-width: 0 it can grow to all slides side by side, so the
6750
+ carousel spills out of the bubble and the chat. */
6755
6751
  :host {
6756
6752
  min-width: 0;
6757
6753
  }
6758
6754
  .carousel {
6755
+ /* Every photo is drawn in a box of this shape, so slides of
6756
+ different shapes neither resize the card nor move the arrows. */
6757
+ --photo-aspect-ratio: 4 / 3;
6759
6758
  position: relative;
6760
6759
  max-width: 400px;
6761
6760
  height: max-content;
@@ -6780,18 +6779,11 @@ xmlns="http://www.w3.org/2000/svg"
6780
6779
  flex-shrink: 0;
6781
6780
  opacity: 0.5;
6782
6781
  transition: opacity 0.5s ease;
6783
- height: 100%;
6782
+ aspect-ratio: var(--photo-aspect-ratio);
6784
6783
  object-fit: contain;
6784
+ background-color: #f2f2f2;
6785
6785
  display: block;
6786
6786
  }
6787
- .image-item {
6788
- width: 100%;
6789
- max-width: none;
6790
- flex-shrink: 0;
6791
- display: flex;
6792
- flex-direction: column;
6793
- gap: 10px;
6794
- }
6795
6787
  .image-link {
6796
6788
  width: 100%;
6797
6789
  max-width: none;
@@ -6800,11 +6792,22 @@ xmlns="http://www.w3.org/2000/svg"
6800
6792
  .carousel img.active {
6801
6793
  opacity: 1;
6802
6794
  }
6803
- .button {
6795
+ .controls {
6804
6796
  position: absolute;
6805
- top: 50%;
6806
- transform: translateY(-50%);
6807
- background-color: rgba(0, 0, 0, 0.1);
6797
+ top: 0;
6798
+ left: 0;
6799
+ width: 100%;
6800
+ aspect-ratio: var(--photo-aspect-ratio);
6801
+ display: flex;
6802
+ align-items: center;
6803
+ justify-content: space-between;
6804
+ padding: 0 2px;
6805
+ box-sizing: border-box;
6806
+ pointer-events: none;
6807
+ }
6808
+ .button {
6809
+ pointer-events: auto;
6810
+ background-color: rgba(0, 0, 0, 0.6);
6808
6811
  color: white;
6809
6812
  border: none;
6810
6813
  border-radius: 2px;
@@ -6816,35 +6819,7 @@ xmlns="http://www.w3.org/2000/svg"
6816
6819
  transition: background-color 0.3s ease;
6817
6820
  }
6818
6821
  .button:hover {
6819
- background-color: rgba(0, 0, 0, 0.5);
6820
- }
6821
- .prev {
6822
- left: 2px;
6823
- }
6824
- .next {
6825
- right: 2px;
6826
- }
6827
- .image-info {
6828
- display: flex;
6829
- flex-direction: column;
6830
- gap: 5px;
6831
- }
6832
- .image-info p {
6833
- margin: 0;
6834
- padding: 0;
6835
- white-space: wrap;
6836
- overflow: hidden;
6837
- word-wrap: break-word;
6838
- }
6839
- .image-info .img-header {
6840
- color: #333;
6841
- font-size: 14px;
6842
- }
6843
- .image-info .img-desc {
6844
- color: #666;
6845
- font-size: 12px;
6846
- max-height: 200px;
6847
- overflow-y: auto;
6822
+ background-color: rgba(0, 0, 0, 0.8);
6848
6823
  }
6849
6824
  `],nc([ue({attribute:!0})],ic.prototype,"message",void 0),nc([ue({attribute:!0})],ic.prototype,"myPubnub",void 0),nc([ue({attribute:!0})],ic.prototype,"onMount",void 0),nc([de()],ic.prototype,"showMediaAsCarousel",void 0),nc([de()],ic.prototype,"activeIndex",void 0),ic=nc([se("pubnub-media")],ic);function rc(e,t){var n=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return n<0?-1:n>0?1:n}function oc(e,t){ii(2,arguments);var n=ri(e),i=ri(t),r=rc(n,i),o=Math.abs(function(e,t){ii(2,arguments);var n=rr(e),i=rr(t),r=n.getTime()-zi(n),o=i.getTime()-zi(i);return Math.round((r-o)/864e5)}(n,i));n.setDate(n.getDate()-r*o);var a=r*(o-Number(rc(n,i)===-r));return 0===a?0:a}const ac=u`
6850
6825
  #utilities-container {
@@ -12,12 +12,15 @@ export class PubnubMedia extends LitElement {
12
12
  pubnubChatStyles,
13
13
  css`
14
14
  /* This element is a flex item in a bubble capped below the chat width.
15
- Without min-width: 0 it is at least as wide as all slides' captions
16
- side by side, so the carousel spills out of the bubble and the chat. */
15
+ Without min-width: 0 it can grow to all slides side by side, so the
16
+ carousel spills out of the bubble and the chat. */
17
17
  :host {
18
18
  min-width: 0;
19
19
  }
20
20
  .carousel {
21
+ /* Every photo is drawn in a box of this shape, so slides of
22
+ different shapes neither resize the card nor move the arrows. */
23
+ --photo-aspect-ratio: 4 / 3;
21
24
  position: relative;
22
25
  max-width: 400px;
23
26
  height: max-content;
@@ -42,18 +45,11 @@ export class PubnubMedia extends LitElement {
42
45
  flex-shrink: 0;
43
46
  opacity: 0.5;
44
47
  transition: opacity 0.5s ease;
45
- height: 100%;
48
+ aspect-ratio: var(--photo-aspect-ratio);
46
49
  object-fit: contain;
50
+ background-color: #f2f2f2;
47
51
  display: block;
48
52
  }
49
- .image-item {
50
- width: 100%;
51
- max-width: none;
52
- flex-shrink: 0;
53
- display: flex;
54
- flex-direction: column;
55
- gap: 10px;
56
- }
57
53
  .image-link {
58
54
  width: 100%;
59
55
  max-width: none;
@@ -62,11 +58,22 @@ export class PubnubMedia extends LitElement {
62
58
  .carousel img.active {
63
59
  opacity: 1;
64
60
  }
65
- .button {
61
+ .controls {
66
62
  position: absolute;
67
- top: 50%;
68
- transform: translateY(-50%);
69
- background-color: rgba(0, 0, 0, 0.1);
63
+ top: 0;
64
+ left: 0;
65
+ width: 100%;
66
+ aspect-ratio: var(--photo-aspect-ratio);
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: space-between;
70
+ padding: 0 2px;
71
+ box-sizing: border-box;
72
+ pointer-events: none;
73
+ }
74
+ .button {
75
+ pointer-events: auto;
76
+ background-color: rgba(0, 0, 0, 0.6);
70
77
  color: white;
71
78
  border: none;
72
79
  border-radius: 2px;
@@ -78,35 +85,7 @@ export class PubnubMedia extends LitElement {
78
85
  transition: background-color 0.3s ease;
79
86
  }
80
87
  .button:hover {
81
- background-color: rgba(0, 0, 0, 0.5);
82
- }
83
- .prev {
84
- left: 2px;
85
- }
86
- .next {
87
- right: 2px;
88
- }
89
- .image-info {
90
- display: flex;
91
- flex-direction: column;
92
- gap: 5px;
93
- }
94
- .image-info p {
95
- margin: 0;
96
- padding: 0;
97
- white-space: wrap;
98
- overflow: hidden;
99
- word-wrap: break-word;
100
- }
101
- .image-info .img-header {
102
- color: #333;
103
- font-size: 14px;
104
- }
105
- .image-info .img-desc {
106
- color: #666;
107
- font-size: 12px;
108
- max-height: 200px;
109
- overflow-y: auto;
88
+ background-color: rgba(0, 0, 0, 0.8);
110
89
  }
111
90
  `,
112
91
  ];
@@ -163,38 +142,30 @@ export class PubnubMedia extends LitElement {
163
142
  >
164
143
  ${this.message.media.map(
165
144
  (image, index) => html`
166
- <div class="image-item">
167
- <a
168
- class="image-link"
169
- href="${image.url}"
170
- target="_blank"
171
- rel="noopener noreferrer"
172
- >
173
- <img
174
- class=${classMap({ active: index === this.activeIndex })}
175
- src=${image.url}
176
- alt=""
177
- />
178
- </a>
179
- <div class="image-info">
180
- ${image.title
181
- ? html`<p class="img-header">${image.title}</p>`
182
- : ""}
183
- ${image.description
184
- ? html`<p class="img-desc">${image.description}</p>`
185
- : ""}
186
- </div>
187
- </div>
145
+ <a
146
+ class="image-link"
147
+ href="${image.url}"
148
+ target="_blank"
149
+ rel="noopener noreferrer"
150
+ >
151
+ <img
152
+ class=${classMap({ active: index === this.activeIndex })}
153
+ src=${image.url}
154
+ alt=""
155
+ />
156
+ </a>
188
157
  `
189
158
  )}
190
159
  </div>
191
160
  ${this.message.media.length > 1
192
- ? html` <button class="button prev" @click=${this.prevImage}>
161
+ ? html`<div class="controls">
162
+ <button class="button prev" @click=${this.prevImage}>
193
163
  &#10094;
194
164
  </button>
195
165
  <button class="button next" @click=${this.nextImage}>
196
166
  &#10095;
197
- </button>`
167
+ </button>
168
+ </div>`
198
169
  : ""}
199
170
  </div>
200
171
  </div>`;
@@ -199,8 +199,8 @@ it("keeps a photo carousel and its arrows inside the message bubble", async () =
199
199
  )}`;
200
200
  const photos: SimpleMediaChatMessage = {
201
201
  timestamp: 100,
202
- // Eight captioned photos, as one floor plan can have: the overflow came
203
- // from the slides' combined caption widths, so a few short ones hide it.
202
+ // Eight photos with names and descriptions, as one floor plan can have.
203
+ // Their names and descriptions are not drawn.
204
204
  media: [
205
205
  "Living Room",
206
206
  "Dining Area",
@@ -238,7 +238,15 @@ it("keeps a photo carousel and its arrows inside the message bubble", async () =
238
238
  const next = media.shadowRoot
239
239
  ?.querySelector(".next")
240
240
  ?.getBoundingClientRect();
241
- if (!bubble || !carousel || !next) throw new Error("Expected a carousel");
241
+ const photo = media.shadowRoot
242
+ ?.querySelector("img.active")
243
+ ?.getBoundingClientRect();
244
+ if (!bubble || !carousel || !next || !photo)
245
+ throw new Error("Expected a carousel");
242
246
  expect(carousel.right).to.be.at.most(bubble.right);
243
247
  expect(next.right).to.be.at.most(bubble.right);
248
+ // Centred on the photo, not on the photo and its caption together.
249
+ const centreY = (box: DOMRect) => (box.top + box.bottom) / 2;
250
+ expect(centreY(next)).to.be.closeTo(centreY(photo), 1);
251
+ expect(media.shadowRoot?.textContent).not.to.contain("Living Room");
244
252
  });