@hellotext/hellotext 2.4.1 → 2.4.3

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.
@@ -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: currentTarget.dataset.text,
59
- cardElement: card
60
+ body,
61
+ cardElement: card || messageElement || currentTarget
60
62
  }
61
63
  });
62
64
  }
@@ -66,22 +68,41 @@ let _default = /*#__PURE__*/function (_Controller) {
66
68
  currentTarget
67
69
  }) {
68
70
  const card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]');
69
- const payload = {
71
+ const {
72
+ id,
73
+ reference,
74
+ source
75
+ } = card.dataset;
76
+ const item = {
77
+ product: id,
78
+ quantity: 1
79
+ };
80
+ _hellotext.default.track('cart.added', {
81
+ object_parameters: {
82
+ items: [item]
83
+ }
84
+ });
85
+ _hellotext.default.eventEmitter.dispatch('cart.added', {
70
86
  object_parameters: {
71
87
  items: [{
72
- product: card.dataset.id,
73
- quantity: 1
88
+ ...item,
89
+ ...(reference && {
90
+ reference
91
+ }),
92
+ ...(source && {
93
+ source
94
+ })
74
95
  }]
75
96
  }
76
- };
77
- _hellotext.default.track('cart.added', payload);
78
- _hellotext.default.eventEmitter.dispatch('cart.added', payload);
97
+ });
79
98
  }
80
99
  }, {
81
100
  key: "moveToLeft",
82
101
  value: function moveToLeft() {
83
102
  if (!this.hasCarouselContainerTarget) return;
84
- const scrollAmount = this.getScrollAmount();
103
+ const nextScrollLeft = this.getPreviousPageScrollLeft();
104
+ const scrollAmount = this.carouselContainerTarget.scrollLeft - nextScrollLeft;
105
+ if (scrollAmount < 1) return;
85
106
  this.carouselContainerTarget.scrollBy({
86
107
  left: -scrollAmount,
87
108
  behavior: 'smooth'
@@ -91,7 +112,9 @@ let _default = /*#__PURE__*/function (_Controller) {
91
112
  key: "moveToRight",
92
113
  value: function moveToRight() {
93
114
  if (!this.hasCarouselContainerTarget) return;
94
- const scrollAmount = this.getScrollAmount();
115
+ const nextScrollLeft = this.getNextPageScrollLeft();
116
+ const scrollAmount = nextScrollLeft - this.carouselContainerTarget.scrollLeft;
117
+ if (scrollAmount < 1) return;
95
118
  this.carouselContainerTarget.scrollBy({
96
119
  left: scrollAmount,
97
120
  behavior: 'smooth'
@@ -100,44 +123,157 @@ let _default = /*#__PURE__*/function (_Controller) {
100
123
  }, {
101
124
  key: "getScrollAmount",
102
125
  value: function getScrollAmount() {
103
- // Get the actual card width from DOM
126
+ return this.getCardScrollAmount();
127
+ }
128
+ }, {
129
+ key: "getCardScrollAmount",
130
+ value: function getCardScrollAmount() {
104
131
  const firstCard = this.carouselContainerTarget.querySelector('.message__carousel_card');
105
132
  if (!firstCard) {
106
133
  return 280; // Fallback to default desktop card width
107
134
  }
108
135
 
109
136
  const cardWidth = firstCard.offsetWidth;
110
- const gap = 16; // gap-x-4 = 1rem = 16px
111
-
112
- return cardWidth + gap;
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;
113
223
  }
114
224
  }, {
115
225
  key: "updateFades",
116
226
  value: function updateFades() {
117
227
  if (!this.hasCarouselContainerTarget) return;
118
- const scrollLeft = this.carouselContainerTarget.scrollLeft;
119
- const maxScroll = this.carouselContainerTarget.scrollWidth - this.carouselContainerTarget.clientWidth;
120
-
121
- // Show left fade if scrolled past start
122
- if (scrollLeft > 0) {
123
- this.leftFadeTarget.classList.remove('hidden');
124
- } else {
125
- 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;
126
233
  }
127
-
128
- // Show right fade if not at end
129
- if (scrollLeft < maxScroll - 1) {
130
- // -1 for rounding errors
131
- this.rightFadeTarget.classList.remove('hidden');
132
- } else {
133
- this.rightFadeTarget.classList.add('hidden');
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;
134
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');
135
263
  }
136
264
  }]);
137
265
  return _default;
138
266
  }(_stimulus.Controller);
139
267
  exports.default = _default;
140
268
  _default.values = {
141
- id: String
269
+ fadeDistance: {
270
+ type: Number,
271
+ default: 64
272
+ },
273
+ id: String,
274
+ pageStartOffset: {
275
+ type: Number,
276
+ default: 0
277
+ }
142
278
  };
143
279
  _default.targets = ['carouselContainer', 'leftFade', 'rightFade', 'carouselCard'];
@@ -1,3 +1,6 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
5
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -45,13 +48,15 @@ var _default = /*#__PURE__*/function (_Controller) {
45
48
  currentTarget
46
49
  } = _ref2;
47
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();
48
53
  this.dispatch('quickReply', {
49
54
  detail: {
50
55
  id: this.idValue,
51
- product: card.dataset.id,
56
+ product: card === null || card === void 0 ? void 0 : card.dataset.id,
52
57
  buttonId: currentTarget.dataset.id,
53
- body: currentTarget.dataset.text,
54
- cardElement: card
58
+ body,
59
+ cardElement: card || messageElement || currentTarget
55
60
  }
56
61
  });
57
62
  }
@@ -62,22 +67,37 @@ var _default = /*#__PURE__*/function (_Controller) {
62
67
  currentTarget
63
68
  } = _ref3;
64
69
  var card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]');
65
- var payload = {
70
+ var {
71
+ id,
72
+ reference,
73
+ source
74
+ } = card.dataset;
75
+ var item = {
76
+ product: id,
77
+ quantity: 1
78
+ };
79
+ Hellotext.track('cart.added', {
66
80
  object_parameters: {
67
- items: [{
68
- product: card.dataset.id,
69
- quantity: 1
70
- }]
81
+ items: [item]
71
82
  }
72
- };
73
- Hellotext.track('cart.added', payload);
74
- Hellotext.eventEmitter.dispatch('cart.added', payload);
83
+ });
84
+ Hellotext.eventEmitter.dispatch('cart.added', {
85
+ object_parameters: {
86
+ items: [_objectSpread(_objectSpread(_objectSpread({}, item), reference && {
87
+ reference
88
+ }), source && {
89
+ source
90
+ })]
91
+ }
92
+ });
75
93
  }
76
94
  }, {
77
95
  key: "moveToLeft",
78
96
  value: function moveToLeft() {
79
97
  if (!this.hasCarouselContainerTarget) return;
80
- var scrollAmount = this.getScrollAmount();
98
+ var nextScrollLeft = this.getPreviousPageScrollLeft();
99
+ var scrollAmount = this.carouselContainerTarget.scrollLeft - nextScrollLeft;
100
+ if (scrollAmount < 1) return;
81
101
  this.carouselContainerTarget.scrollBy({
82
102
  left: -scrollAmount,
83
103
  behavior: 'smooth'
@@ -87,7 +107,9 @@ var _default = /*#__PURE__*/function (_Controller) {
87
107
  key: "moveToRight",
88
108
  value: function moveToRight() {
89
109
  if (!this.hasCarouselContainerTarget) return;
90
- var scrollAmount = this.getScrollAmount();
110
+ var nextScrollLeft = this.getNextPageScrollLeft();
111
+ var scrollAmount = nextScrollLeft - this.carouselContainerTarget.scrollLeft;
112
+ if (scrollAmount < 1) return;
91
113
  this.carouselContainerTarget.scrollBy({
92
114
  left: scrollAmount,
93
115
  behavior: 'smooth'
@@ -96,44 +118,158 @@ var _default = /*#__PURE__*/function (_Controller) {
96
118
  }, {
97
119
  key: "getScrollAmount",
98
120
  value: function getScrollAmount() {
99
- // Get the actual card width from DOM
121
+ return this.getCardScrollAmount();
122
+ }
123
+ }, {
124
+ key: "getCardScrollAmount",
125
+ value: function getCardScrollAmount() {
100
126
  var firstCard = this.carouselContainerTarget.querySelector('.message__carousel_card');
101
127
  if (!firstCard) {
102
128
  return 280; // Fallback to default desktop card width
103
129
  }
104
130
 
105
131
  var cardWidth = firstCard.offsetWidth;
106
- var gap = 16; // gap-x-4 = 1rem = 16px
107
-
108
- return cardWidth + gap;
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;
109
219
  }
110
220
  }, {
111
221
  key: "updateFades",
112
222
  value: function updateFades() {
113
223
  if (!this.hasCarouselContainerTarget) return;
114
- var scrollLeft = this.carouselContainerTarget.scrollLeft;
115
- var maxScroll = this.carouselContainerTarget.scrollWidth - this.carouselContainerTarget.clientWidth;
116
-
117
- // Show left fade if scrolled past start
118
- if (scrollLeft > 0) {
119
- this.leftFadeTarget.classList.remove('hidden');
120
- } else {
121
- 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;
122
229
  }
123
-
124
- // Show right fade if not at end
125
- if (scrollLeft < maxScroll - 1) {
126
- // -1 for rounding errors
127
- this.rightFadeTarget.classList.remove('hidden');
128
- } else {
129
- this.rightFadeTarget.classList.add('hidden');
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;
130
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');
131
259
  }
132
260
  }]);
133
261
  return _default;
134
262
  }(Controller);
135
263
  _default.values = {
136
- id: String
264
+ fadeDistance: {
265
+ type: Number,
266
+ default: 64
267
+ },
268
+ id: String,
269
+ pageStartOffset: {
270
+ type: Number,
271
+ default: 0
272
+ }
137
273
  };
138
274
  _default.targets = ['carouselContainer', 'leftFade', 'rightFade', 'carouselCard'];
139
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
- return `hellotext:webchat:${this.idValue || this.element.id}:teaser-seen`;
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
- return "hellotext:webchat:".concat(this.idValue || this.element.id, ":teaser-seen");
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 {