@hellotext/hellotext 2.4.2 → 2.4.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.
- package/dist/hellotext.js +1 -1
- package/lib/controllers/message_controller.cjs +144 -25
- package/lib/controllers/message_controller.js +145 -25
- package/lib/controllers/mixins/usePopover.cjs +2 -0
- package/lib/controllers/mixins/usePopover.js +2 -0
- package/lib/controllers/webchat/useTeaser.cjs +3 -1
- package/lib/controllers/webchat/useTeaser.js +3 -1
- package/lib/controllers/webchat_controller.cjs +219 -25
- package/lib/controllers/webchat_controller.js +233 -25
- package/lib/core/configuration.cjs +19 -0
- package/lib/core/configuration.js +19 -0
- package/lib/models/business.cjs +86 -5
- package/lib/models/business.js +82 -5
- package/lib/models/webchat.cjs +18 -3
- package/lib/models/webchat.js +27 -6
- package/package.json +1 -1
- package/src/controllers/message_controller.js +145 -22
- package/src/controllers/mixins/usePopover.js +1 -0
- package/src/controllers/webchat/useTeaser.js +4 -1
- package/src/controllers/webchat_controller.js +255 -27
- package/src/core/configuration.js +25 -0
- package/src/models/business.js +86 -5
- package/src/models/webchat.js +22 -3
|
@@ -50,13 +50,15 @@ let _default = /*#__PURE__*/function (_Controller) {
|
|
|
50
50
|
currentTarget
|
|
51
51
|
}) {
|
|
52
52
|
const card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]');
|
|
53
|
+
const messageElement = currentTarget.closest('[data-controller~="hellotext--message"]');
|
|
54
|
+
const body = currentTarget.dataset.text || currentTarget.textContent.trim();
|
|
53
55
|
this.dispatch('quickReply', {
|
|
54
56
|
detail: {
|
|
55
57
|
id: this.idValue,
|
|
56
|
-
product: card.dataset.id,
|
|
58
|
+
product: card === null || card === void 0 ? void 0 : card.dataset.id,
|
|
57
59
|
buttonId: currentTarget.dataset.id,
|
|
58
|
-
body
|
|
59
|
-
cardElement: card
|
|
60
|
+
body,
|
|
61
|
+
cardElement: card || messageElement || currentTarget
|
|
60
62
|
}
|
|
61
63
|
});
|
|
62
64
|
}
|
|
@@ -98,7 +100,9 @@ let _default = /*#__PURE__*/function (_Controller) {
|
|
|
98
100
|
key: "moveToLeft",
|
|
99
101
|
value: function moveToLeft() {
|
|
100
102
|
if (!this.hasCarouselContainerTarget) return;
|
|
101
|
-
const
|
|
103
|
+
const nextScrollLeft = this.getPreviousPageScrollLeft();
|
|
104
|
+
const scrollAmount = this.carouselContainerTarget.scrollLeft - nextScrollLeft;
|
|
105
|
+
if (scrollAmount < 1) return;
|
|
102
106
|
this.carouselContainerTarget.scrollBy({
|
|
103
107
|
left: -scrollAmount,
|
|
104
108
|
behavior: 'smooth'
|
|
@@ -108,7 +112,9 @@ let _default = /*#__PURE__*/function (_Controller) {
|
|
|
108
112
|
key: "moveToRight",
|
|
109
113
|
value: function moveToRight() {
|
|
110
114
|
if (!this.hasCarouselContainerTarget) return;
|
|
111
|
-
const
|
|
115
|
+
const nextScrollLeft = this.getNextPageScrollLeft();
|
|
116
|
+
const scrollAmount = nextScrollLeft - this.carouselContainerTarget.scrollLeft;
|
|
117
|
+
if (scrollAmount < 1) return;
|
|
112
118
|
this.carouselContainerTarget.scrollBy({
|
|
113
119
|
left: scrollAmount,
|
|
114
120
|
behavior: 'smooth'
|
|
@@ -117,44 +123,157 @@ let _default = /*#__PURE__*/function (_Controller) {
|
|
|
117
123
|
}, {
|
|
118
124
|
key: "getScrollAmount",
|
|
119
125
|
value: function getScrollAmount() {
|
|
120
|
-
|
|
126
|
+
return this.getCardScrollAmount();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "getCardScrollAmount",
|
|
130
|
+
value: function getCardScrollAmount() {
|
|
121
131
|
const firstCard = this.carouselContainerTarget.querySelector('.message__carousel_card');
|
|
122
132
|
if (!firstCard) {
|
|
123
133
|
return 280; // Fallback to default desktop card width
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
const cardWidth = firstCard.offsetWidth;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
137
|
+
return cardWidth + this.getGap();
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "getPageScrollAmount",
|
|
141
|
+
value: function getPageScrollAmount() {
|
|
142
|
+
const scrollAmount = this.carouselContainerTarget.clientWidth - this.getGap();
|
|
143
|
+
return scrollAmount > 0 ? scrollAmount : this.getCardScrollAmount();
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "getNextPageScrollLeft",
|
|
147
|
+
value: function getNextPageScrollLeft() {
|
|
148
|
+
const currentScrollLeft = this.getCurrentScrollLeft();
|
|
149
|
+
const viewportRight = currentScrollLeft + this.carouselContainerTarget.clientWidth;
|
|
150
|
+
const cardMetrics = this.getCardMetrics();
|
|
151
|
+
const nextCard = cardMetrics.find(card => card.end > viewportRight + 1);
|
|
152
|
+
const targetScrollLeft = nextCard ? this.getPageAlignedScrollLeft(nextCard.start) : currentScrollLeft + this.getPageScrollAmount();
|
|
153
|
+
const fallbackScrollLeft = currentScrollLeft + this.getPageScrollAmount();
|
|
154
|
+
return this.clampScrollLeft(targetScrollLeft > currentScrollLeft + 1 ? targetScrollLeft : fallbackScrollLeft);
|
|
155
|
+
}
|
|
156
|
+
}, {
|
|
157
|
+
key: "getPreviousPageScrollLeft",
|
|
158
|
+
value: function getPreviousPageScrollLeft() {
|
|
159
|
+
const currentScrollLeft = this.getCurrentScrollLeft();
|
|
160
|
+
if (currentScrollLeft <= 1) return 0;
|
|
161
|
+
const targetThreshold = Math.max(currentScrollLeft - this.getPageScrollAmount(), 0);
|
|
162
|
+
if (targetThreshold <= 1) return 0;
|
|
163
|
+
const cardMetrics = this.getCardMetrics();
|
|
164
|
+
const previousPageCard = cardMetrics.find(card => card.start >= targetThreshold - 1 && card.start < currentScrollLeft - 1);
|
|
165
|
+
const previousCard = [...cardMetrics].reverse().find(card => card.start < currentScrollLeft - 1);
|
|
166
|
+
return this.getPageAlignedScrollLeft((previousPageCard === null || previousPageCard === void 0 ? void 0 : previousPageCard.start) ?? (previousCard === null || previousCard === void 0 ? void 0 : previousCard.start) ?? 0);
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
key: "getPageAlignedScrollLeft",
|
|
170
|
+
value: function getPageAlignedScrollLeft(cardStart) {
|
|
171
|
+
const pageStartOffset = this.getPageStartOffset();
|
|
172
|
+
if (cardStart <= pageStartOffset + 1) return 0;
|
|
173
|
+
return this.clampScrollLeft(cardStart - pageStartOffset);
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "getCardMetrics",
|
|
177
|
+
value: function getCardMetrics() {
|
|
178
|
+
return Array.from(this.carouselContainerTarget.querySelectorAll('.message__carousel_card')).map(card => {
|
|
179
|
+
const start = this.getCardScrollLeft(card);
|
|
180
|
+
return {
|
|
181
|
+
start,
|
|
182
|
+
end: start + card.offsetWidth
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "getCardScrollLeft",
|
|
188
|
+
value: function getCardScrollLeft(card) {
|
|
189
|
+
const cardRect = card.getBoundingClientRect();
|
|
190
|
+
const containerRect = this.carouselContainerTarget.getBoundingClientRect();
|
|
191
|
+
if (cardRect.left || cardRect.width || containerRect.left || containerRect.width) {
|
|
192
|
+
return cardRect.left - containerRect.left + this.carouselContainerTarget.scrollLeft;
|
|
193
|
+
}
|
|
194
|
+
return card.offsetLeft || 0;
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "getCurrentScrollLeft",
|
|
198
|
+
value: function getCurrentScrollLeft() {
|
|
199
|
+
return this.clampScrollLeft(this.carouselContainerTarget.scrollLeft);
|
|
200
|
+
}
|
|
201
|
+
}, {
|
|
202
|
+
key: "clampScrollLeft",
|
|
203
|
+
value: function clampScrollLeft(scrollLeft) {
|
|
204
|
+
const maxScroll = Math.max(this.carouselContainerTarget.scrollWidth - this.carouselContainerTarget.clientWidth, 0);
|
|
205
|
+
return Math.min(Math.max(scrollLeft, 0), maxScroll);
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "getGap",
|
|
209
|
+
value: function getGap() {
|
|
210
|
+
const styles = window.getComputedStyle(this.carouselContainerTarget);
|
|
211
|
+
const gap = Number.parseFloat(styles.columnGap || styles.gap);
|
|
212
|
+
return Number.isFinite(gap) ? gap : 16;
|
|
213
|
+
}
|
|
214
|
+
}, {
|
|
215
|
+
key: "getFadeDistance",
|
|
216
|
+
value: function getFadeDistance() {
|
|
217
|
+
return Number.isFinite(this.fadeDistanceValue) ? this.fadeDistanceValue : 64;
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
220
|
+
key: "getPageStartOffset",
|
|
221
|
+
value: function getPageStartOffset() {
|
|
222
|
+
return Number.isFinite(this.pageStartOffsetValue) ? this.pageStartOffsetValue : 0;
|
|
130
223
|
}
|
|
131
224
|
}, {
|
|
132
225
|
key: "updateFades",
|
|
133
226
|
value: function updateFades() {
|
|
134
227
|
if (!this.hasCarouselContainerTarget) return;
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
this.leftFadeTarget.classList.remove('hidden');
|
|
141
|
-
} else {
|
|
142
|
-
this.leftFadeTarget.classList.add('hidden');
|
|
228
|
+
const maxScroll = Math.max(this.carouselContainerTarget.scrollWidth - this.carouselContainerTarget.clientWidth, 0);
|
|
229
|
+
if (maxScroll <= 1) {
|
|
230
|
+
this.hideFade(this.leftFadeTarget);
|
|
231
|
+
this.hideFade(this.rightFadeTarget);
|
|
232
|
+
return;
|
|
143
233
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
234
|
+
const scrollLeft = Math.min(Math.max(this.carouselContainerTarget.scrollLeft, 0), maxScroll);
|
|
235
|
+
const fadeDistance = this.getFadeDistance();
|
|
236
|
+
this.setFadeOpacity(this.leftFadeTarget, scrollLeft / fadeDistance);
|
|
237
|
+
this.setFadeOpacity(this.rightFadeTarget, (maxScroll - scrollLeft) / fadeDistance);
|
|
238
|
+
}
|
|
239
|
+
}, {
|
|
240
|
+
key: "setFadeOpacity",
|
|
241
|
+
value: function setFadeOpacity(fadeTarget, opacity) {
|
|
242
|
+
const clampedOpacity = Math.min(Math.max(opacity, 0), 1);
|
|
243
|
+
if (clampedOpacity <= 0.05) {
|
|
244
|
+
this.hideFade(fadeTarget);
|
|
245
|
+
return;
|
|
151
246
|
}
|
|
247
|
+
fadeTarget.classList.remove('hidden');
|
|
248
|
+
fadeTarget.removeAttribute('disabled');
|
|
249
|
+
fadeTarget.removeAttribute('tabindex');
|
|
250
|
+
fadeTarget.setAttribute('aria-hidden', 'false');
|
|
251
|
+
fadeTarget.style.opacity = clampedOpacity.toFixed(3);
|
|
252
|
+
fadeTarget.style.pointerEvents = 'auto';
|
|
253
|
+
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "hideFade",
|
|
256
|
+
value: function hideFade(fadeTarget) {
|
|
257
|
+
fadeTarget.style.opacity = '0';
|
|
258
|
+
fadeTarget.style.pointerEvents = 'none';
|
|
259
|
+
fadeTarget.setAttribute('aria-hidden', 'true');
|
|
260
|
+
fadeTarget.setAttribute('tabindex', '-1');
|
|
261
|
+
if ('disabled' in fadeTarget) fadeTarget.disabled = true;
|
|
262
|
+
fadeTarget.classList.add('hidden');
|
|
152
263
|
}
|
|
153
264
|
}]);
|
|
154
265
|
return _default;
|
|
155
266
|
}(_stimulus.Controller);
|
|
156
267
|
exports.default = _default;
|
|
157
268
|
_default.values = {
|
|
158
|
-
|
|
269
|
+
fadeDistance: {
|
|
270
|
+
type: Number,
|
|
271
|
+
default: 64
|
|
272
|
+
},
|
|
273
|
+
id: String,
|
|
274
|
+
pageStartOffset: {
|
|
275
|
+
type: Number,
|
|
276
|
+
default: 0
|
|
277
|
+
}
|
|
159
278
|
};
|
|
160
279
|
_default.targets = ['carouselContainer', 'leftFade', 'rightFade', 'carouselCard'];
|
|
@@ -48,13 +48,15 @@ var _default = /*#__PURE__*/function (_Controller) {
|
|
|
48
48
|
currentTarget
|
|
49
49
|
} = _ref2;
|
|
50
50
|
var card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]');
|
|
51
|
+
var messageElement = currentTarget.closest('[data-controller~="hellotext--message"]');
|
|
52
|
+
var body = currentTarget.dataset.text || currentTarget.textContent.trim();
|
|
51
53
|
this.dispatch('quickReply', {
|
|
52
54
|
detail: {
|
|
53
55
|
id: this.idValue,
|
|
54
|
-
product: card.dataset.id,
|
|
56
|
+
product: card === null || card === void 0 ? void 0 : card.dataset.id,
|
|
55
57
|
buttonId: currentTarget.dataset.id,
|
|
56
|
-
body
|
|
57
|
-
cardElement: card
|
|
58
|
+
body,
|
|
59
|
+
cardElement: card || messageElement || currentTarget
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -93,7 +95,9 @@ var _default = /*#__PURE__*/function (_Controller) {
|
|
|
93
95
|
key: "moveToLeft",
|
|
94
96
|
value: function moveToLeft() {
|
|
95
97
|
if (!this.hasCarouselContainerTarget) return;
|
|
96
|
-
var
|
|
98
|
+
var nextScrollLeft = this.getPreviousPageScrollLeft();
|
|
99
|
+
var scrollAmount = this.carouselContainerTarget.scrollLeft - nextScrollLeft;
|
|
100
|
+
if (scrollAmount < 1) return;
|
|
97
101
|
this.carouselContainerTarget.scrollBy({
|
|
98
102
|
left: -scrollAmount,
|
|
99
103
|
behavior: 'smooth'
|
|
@@ -103,7 +107,9 @@ var _default = /*#__PURE__*/function (_Controller) {
|
|
|
103
107
|
key: "moveToRight",
|
|
104
108
|
value: function moveToRight() {
|
|
105
109
|
if (!this.hasCarouselContainerTarget) return;
|
|
106
|
-
var
|
|
110
|
+
var nextScrollLeft = this.getNextPageScrollLeft();
|
|
111
|
+
var scrollAmount = nextScrollLeft - this.carouselContainerTarget.scrollLeft;
|
|
112
|
+
if (scrollAmount < 1) return;
|
|
107
113
|
this.carouselContainerTarget.scrollBy({
|
|
108
114
|
left: scrollAmount,
|
|
109
115
|
behavior: 'smooth'
|
|
@@ -112,44 +118,158 @@ var _default = /*#__PURE__*/function (_Controller) {
|
|
|
112
118
|
}, {
|
|
113
119
|
key: "getScrollAmount",
|
|
114
120
|
value: function getScrollAmount() {
|
|
115
|
-
|
|
121
|
+
return this.getCardScrollAmount();
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "getCardScrollAmount",
|
|
125
|
+
value: function getCardScrollAmount() {
|
|
116
126
|
var firstCard = this.carouselContainerTarget.querySelector('.message__carousel_card');
|
|
117
127
|
if (!firstCard) {
|
|
118
128
|
return 280; // Fallback to default desktop card width
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
var cardWidth = firstCard.offsetWidth;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
return cardWidth + this.getGap();
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "getPageScrollAmount",
|
|
136
|
+
value: function getPageScrollAmount() {
|
|
137
|
+
var scrollAmount = this.carouselContainerTarget.clientWidth - this.getGap();
|
|
138
|
+
return scrollAmount > 0 ? scrollAmount : this.getCardScrollAmount();
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "getNextPageScrollLeft",
|
|
142
|
+
value: function getNextPageScrollLeft() {
|
|
143
|
+
var currentScrollLeft = this.getCurrentScrollLeft();
|
|
144
|
+
var viewportRight = currentScrollLeft + this.carouselContainerTarget.clientWidth;
|
|
145
|
+
var cardMetrics = this.getCardMetrics();
|
|
146
|
+
var nextCard = cardMetrics.find(card => card.end > viewportRight + 1);
|
|
147
|
+
var targetScrollLeft = nextCard ? this.getPageAlignedScrollLeft(nextCard.start) : currentScrollLeft + this.getPageScrollAmount();
|
|
148
|
+
var fallbackScrollLeft = currentScrollLeft + this.getPageScrollAmount();
|
|
149
|
+
return this.clampScrollLeft(targetScrollLeft > currentScrollLeft + 1 ? targetScrollLeft : fallbackScrollLeft);
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "getPreviousPageScrollLeft",
|
|
153
|
+
value: function getPreviousPageScrollLeft() {
|
|
154
|
+
var _ref4, _previousPageCard$sta;
|
|
155
|
+
var currentScrollLeft = this.getCurrentScrollLeft();
|
|
156
|
+
if (currentScrollLeft <= 1) return 0;
|
|
157
|
+
var targetThreshold = Math.max(currentScrollLeft - this.getPageScrollAmount(), 0);
|
|
158
|
+
if (targetThreshold <= 1) return 0;
|
|
159
|
+
var cardMetrics = this.getCardMetrics();
|
|
160
|
+
var previousPageCard = cardMetrics.find(card => card.start >= targetThreshold - 1 && card.start < currentScrollLeft - 1);
|
|
161
|
+
var previousCard = [...cardMetrics].reverse().find(card => card.start < currentScrollLeft - 1);
|
|
162
|
+
return this.getPageAlignedScrollLeft((_ref4 = (_previousPageCard$sta = previousPageCard === null || previousPageCard === void 0 ? void 0 : previousPageCard.start) !== null && _previousPageCard$sta !== void 0 ? _previousPageCard$sta : previousCard === null || previousCard === void 0 ? void 0 : previousCard.start) !== null && _ref4 !== void 0 ? _ref4 : 0);
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "getPageAlignedScrollLeft",
|
|
166
|
+
value: function getPageAlignedScrollLeft(cardStart) {
|
|
167
|
+
var pageStartOffset = this.getPageStartOffset();
|
|
168
|
+
if (cardStart <= pageStartOffset + 1) return 0;
|
|
169
|
+
return this.clampScrollLeft(cardStart - pageStartOffset);
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "getCardMetrics",
|
|
173
|
+
value: function getCardMetrics() {
|
|
174
|
+
return Array.from(this.carouselContainerTarget.querySelectorAll('.message__carousel_card')).map(card => {
|
|
175
|
+
var start = this.getCardScrollLeft(card);
|
|
176
|
+
return {
|
|
177
|
+
start,
|
|
178
|
+
end: start + card.offsetWidth
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "getCardScrollLeft",
|
|
184
|
+
value: function getCardScrollLeft(card) {
|
|
185
|
+
var cardRect = card.getBoundingClientRect();
|
|
186
|
+
var containerRect = this.carouselContainerTarget.getBoundingClientRect();
|
|
187
|
+
if (cardRect.left || cardRect.width || containerRect.left || containerRect.width) {
|
|
188
|
+
return cardRect.left - containerRect.left + this.carouselContainerTarget.scrollLeft;
|
|
189
|
+
}
|
|
190
|
+
return card.offsetLeft || 0;
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "getCurrentScrollLeft",
|
|
194
|
+
value: function getCurrentScrollLeft() {
|
|
195
|
+
return this.clampScrollLeft(this.carouselContainerTarget.scrollLeft);
|
|
196
|
+
}
|
|
197
|
+
}, {
|
|
198
|
+
key: "clampScrollLeft",
|
|
199
|
+
value: function clampScrollLeft(scrollLeft) {
|
|
200
|
+
var maxScroll = Math.max(this.carouselContainerTarget.scrollWidth - this.carouselContainerTarget.clientWidth, 0);
|
|
201
|
+
return Math.min(Math.max(scrollLeft, 0), maxScroll);
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "getGap",
|
|
205
|
+
value: function getGap() {
|
|
206
|
+
var styles = window.getComputedStyle(this.carouselContainerTarget);
|
|
207
|
+
var gap = Number.parseFloat(styles.columnGap || styles.gap);
|
|
208
|
+
return Number.isFinite(gap) ? gap : 16;
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "getFadeDistance",
|
|
212
|
+
value: function getFadeDistance() {
|
|
213
|
+
return Number.isFinite(this.fadeDistanceValue) ? this.fadeDistanceValue : 64;
|
|
214
|
+
}
|
|
215
|
+
}, {
|
|
216
|
+
key: "getPageStartOffset",
|
|
217
|
+
value: function getPageStartOffset() {
|
|
218
|
+
return Number.isFinite(this.pageStartOffsetValue) ? this.pageStartOffsetValue : 0;
|
|
125
219
|
}
|
|
126
220
|
}, {
|
|
127
221
|
key: "updateFades",
|
|
128
222
|
value: function updateFades() {
|
|
129
223
|
if (!this.hasCarouselContainerTarget) return;
|
|
130
|
-
var
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.leftFadeTarget.classList.remove('hidden');
|
|
136
|
-
} else {
|
|
137
|
-
this.leftFadeTarget.classList.add('hidden');
|
|
224
|
+
var maxScroll = Math.max(this.carouselContainerTarget.scrollWidth - this.carouselContainerTarget.clientWidth, 0);
|
|
225
|
+
if (maxScroll <= 1) {
|
|
226
|
+
this.hideFade(this.leftFadeTarget);
|
|
227
|
+
this.hideFade(this.rightFadeTarget);
|
|
228
|
+
return;
|
|
138
229
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
230
|
+
var scrollLeft = Math.min(Math.max(this.carouselContainerTarget.scrollLeft, 0), maxScroll);
|
|
231
|
+
var fadeDistance = this.getFadeDistance();
|
|
232
|
+
this.setFadeOpacity(this.leftFadeTarget, scrollLeft / fadeDistance);
|
|
233
|
+
this.setFadeOpacity(this.rightFadeTarget, (maxScroll - scrollLeft) / fadeDistance);
|
|
234
|
+
}
|
|
235
|
+
}, {
|
|
236
|
+
key: "setFadeOpacity",
|
|
237
|
+
value: function setFadeOpacity(fadeTarget, opacity) {
|
|
238
|
+
var clampedOpacity = Math.min(Math.max(opacity, 0), 1);
|
|
239
|
+
if (clampedOpacity <= 0.05) {
|
|
240
|
+
this.hideFade(fadeTarget);
|
|
241
|
+
return;
|
|
146
242
|
}
|
|
243
|
+
fadeTarget.classList.remove('hidden');
|
|
244
|
+
fadeTarget.removeAttribute('disabled');
|
|
245
|
+
fadeTarget.removeAttribute('tabindex');
|
|
246
|
+
fadeTarget.setAttribute('aria-hidden', 'false');
|
|
247
|
+
fadeTarget.style.opacity = clampedOpacity.toFixed(3);
|
|
248
|
+
fadeTarget.style.pointerEvents = 'auto';
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "hideFade",
|
|
252
|
+
value: function hideFade(fadeTarget) {
|
|
253
|
+
fadeTarget.style.opacity = '0';
|
|
254
|
+
fadeTarget.style.pointerEvents = 'none';
|
|
255
|
+
fadeTarget.setAttribute('aria-hidden', 'true');
|
|
256
|
+
fadeTarget.setAttribute('tabindex', '-1');
|
|
257
|
+
if ('disabled' in fadeTarget) fadeTarget.disabled = true;
|
|
258
|
+
fadeTarget.classList.add('hidden');
|
|
147
259
|
}
|
|
148
260
|
}]);
|
|
149
261
|
return _default;
|
|
150
262
|
}(Controller);
|
|
151
263
|
_default.values = {
|
|
152
|
-
|
|
264
|
+
fadeDistance: {
|
|
265
|
+
type: Number,
|
|
266
|
+
default: 64
|
|
267
|
+
},
|
|
268
|
+
id: String,
|
|
269
|
+
pageStartOffset: {
|
|
270
|
+
type: Number,
|
|
271
|
+
default: 0
|
|
272
|
+
}
|
|
153
273
|
};
|
|
154
274
|
_default.targets = ['carouselContainer', 'leftFade', 'rightFade', 'carouselCard'];
|
|
155
275
|
export { _default as default };
|
|
@@ -48,6 +48,8 @@ const usePopover = controller => {
|
|
|
48
48
|
openValueChanged() {
|
|
49
49
|
if (this.disabledValue) return;
|
|
50
50
|
if (this.openValue) {
|
|
51
|
+
var _this$preparePopoverO;
|
|
52
|
+
(_this$preparePopoverO = this.preparePopoverOpenAnimation) === null || _this$preparePopoverO === void 0 ? void 0 : _this$preparePopoverO.call(this);
|
|
51
53
|
this.popoverTarget.showPopover();
|
|
52
54
|
this.popoverTarget.setAttribute('aria-expanded', 'true');
|
|
53
55
|
if (this['onPopoverOpened']) {
|
|
@@ -44,6 +44,8 @@ export var usePopover = controller => {
|
|
|
44
44
|
openValueChanged() {
|
|
45
45
|
if (this.disabledValue) return;
|
|
46
46
|
if (this.openValue) {
|
|
47
|
+
var _this$preparePopoverO;
|
|
48
|
+
(_this$preparePopoverO = this.preparePopoverOpenAnimation) === null || _this$preparePopoverO === void 0 ? void 0 : _this$preparePopoverO.call(this);
|
|
47
49
|
this.popoverTarget.showPopover();
|
|
48
50
|
this.popoverTarget.setAttribute('aria-expanded', 'true');
|
|
49
51
|
if (this['onPopoverOpened']) {
|
|
@@ -118,7 +118,9 @@ const useTeaser = controller => {
|
|
|
118
118
|
return messages.some(message => message !== this.messageTemplateTarget);
|
|
119
119
|
},
|
|
120
120
|
teaserSeenKey() {
|
|
121
|
-
|
|
121
|
+
const teaserVersion = this.hasTeaserTarget ? this.teaserTarget.dataset.teaserVersion : '';
|
|
122
|
+
const versionSegment = teaserVersion ? `:${teaserVersion}` : '';
|
|
123
|
+
return `hellotext:webchat:${this.idValue || this.element.id}:teaser-seen${versionSegment}`;
|
|
122
124
|
},
|
|
123
125
|
teaserSeenForSession() {
|
|
124
126
|
try {
|
|
@@ -112,7 +112,9 @@ export var useTeaser = controller => {
|
|
|
112
112
|
return messages.some(message => message !== this.messageTemplateTarget);
|
|
113
113
|
},
|
|
114
114
|
teaserSeenKey() {
|
|
115
|
-
|
|
115
|
+
var teaserVersion = this.hasTeaserTarget ? this.teaserTarget.dataset.teaserVersion : '';
|
|
116
|
+
var versionSegment = teaserVersion ? ":".concat(teaserVersion) : '';
|
|
117
|
+
return "hellotext:webchat:".concat(this.idValue || this.element.id, ":teaser-seen").concat(versionSegment);
|
|
116
118
|
},
|
|
117
119
|
teaserSeenForSession() {
|
|
118
120
|
try {
|