@micromag/screen-keypad 0.3.362 → 0.3.370

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/es/index.js CHANGED
@@ -6,13 +6,13 @@ import { animated } from '@react-spring/web';
6
6
  import camelCase from 'camelcase';
7
7
  import classNames from 'classnames';
8
8
  import PropTypes from 'prop-types';
9
- import React, { useMemo, useState, useCallback, useEffect } from 'react';
9
+ import React, { useRef, useMemo, useState, useCallback, useEffect } from 'react';
10
10
  import { PropTypes as PropTypes$1 } from '@micromag/core';
11
- import { PlaceholderImage, PlaceholderText, ScreenElement, PlaceholderButton } from '@micromag/core/components';
12
- import { usePlaybackContext, usePlaybackMediaRef, useScreenState, useScreenSize, useViewerContext, useViewerWebView, useScreenRenderContext } from '@micromag/core/contexts';
11
+ import { ScreenElement, PlaceholderButton } from '@micromag/core/components';
12
+ import { usePlaybackContext, usePlaybackMediaRef, useScreenState, useScreenSize, useViewerContext, useViewerWebView, useViewerInteraction, useScreenRenderContext } from '@micromag/core/contexts';
13
13
  import { useTrackScreenEvent, useDimensionObserver, useDragProgress } from '@micromag/core/hooks';
14
14
  import { isHeaderFilled, isFooterFilled, getFooterProps, isTextFilled, getStyleFromBox, getStyleFromText } from '@micromag/core/utils';
15
- import Background, { Background as Background$1 } from '@micromag/element-background';
15
+ import Background from '@micromag/element-background';
16
16
  import Button from '@micromag/element-button';
17
17
  import CallToAction from '@micromag/element-call-to-action';
18
18
  import Container from '@micromag/element-container';
@@ -25,7 +25,7 @@ import Scroll from '@micromag/element-scroll';
25
25
  import Text from '@micromag/element-text';
26
26
  import Visual from '@micromag/element-visual';
27
27
 
28
- var styles = {"popupButton":"micromag-screen-keypad-popupButton","layoutLabelOver":"micromag-screen-keypad-layoutLabelOver","emptyButtonLabel":"micromag-screen-keypad-emptyButtonLabel","buttonLabel":"micromag-screen-keypad-buttonLabel","withSquareItems":"micromag-screen-keypad-withSquareItems","layoutNoLabel":"micromag-screen-keypad-layoutNoLabel","thumbnail":"micromag-screen-keypad-thumbnail","popupBackdrop":"micromag-screen-keypad-popupBackdrop","button":"micromag-screen-keypad-button","background":"micromag-screen-keypad-background","container":"micromag-screen-keypad-container","disabled":"micromag-screen-keypad-disabled","hidden":"micromag-screen-keypad-hidden","placeholder":"micromag-screen-keypad-placeholder","content":"micromag-screen-keypad-content","emptyTitle":"micromag-screen-keypad-emptyTitle","emptyText":"micromag-screen-keypad-emptyText","isPlaceholder":"micromag-screen-keypad-isPlaceholder","layout":"micromag-screen-keypad-layout","header":"micromag-screen-keypad-header","footer":"micromag-screen-keypad-footer","inner":"micromag-screen-keypad-inner","grid":"micromag-screen-keypad-grid","item":"micromag-screen-keypad-item","placeholderItem":"micromag-screen-keypad-placeholderItem","isEmpty":"micromag-screen-keypad-isEmpty","disableHover":"micromag-screen-keypad-disableHover","isLink":"micromag-screen-keypad-isLink","imagePlaceholder":"micromag-screen-keypad-imagePlaceholder","buttonPlaceholder":"micromag-screen-keypad-buttonPlaceholder","buttonVisualPlaceholder":"micromag-screen-keypad-buttonVisualPlaceholder","empty":"micromag-screen-keypad-empty","emptyButtonVisual":"micromag-screen-keypad-emptyButtonVisual","popup":"micromag-screen-keypad-popup","popupInner":"micromag-screen-keypad-popupInner","popupContent":"micromag-screen-keypad-popupContent","popupWrapper":"micromag-screen-keypad-popupWrapper","popupHeading":"micromag-screen-keypad-popupHeading","popupVisual":"micromag-screen-keypad-popupVisual","contentSplit":"micromag-screen-keypad-contentSplit","emptyHeading":"micromag-screen-keypad-emptyHeading","emptyVisual":"micromag-screen-keypad-emptyVisual","emptyContent":"micromag-screen-keypad-emptyContent","contentBottom":"micromag-screen-keypad-contentBottom","popupCTA":"micromag-screen-keypad-popupCTA","layoutLabelTop":"micromag-screen-keypad-layoutLabelTop","buttonVisual":"micromag-screen-keypad-buttonVisual"};
28
+ var styles = {"popupButton":"micromag-screen-keypad-popupButton","popup":"micromag-screen-keypad-popup","layoutLabelOver":"micromag-screen-keypad-layoutLabelOver","emptyButtonLabel":"micromag-screen-keypad-emptyButtonLabel","buttonLabel":"micromag-screen-keypad-buttonLabel","withSquareItems":"micromag-screen-keypad-withSquareItems","layoutNoLabel":"micromag-screen-keypad-layoutNoLabel","thumbnail":"micromag-screen-keypad-thumbnail","popupBackdrop":"micromag-screen-keypad-popupBackdrop","button":"micromag-screen-keypad-button","background":"micromag-screen-keypad-background","container":"micromag-screen-keypad-container","disabled":"micromag-screen-keypad-disabled","hidden":"micromag-screen-keypad-hidden","placeholder":"micromag-screen-keypad-placeholder","content":"micromag-screen-keypad-content","emptyTitle":"micromag-screen-keypad-emptyTitle","emptyText":"micromag-screen-keypad-emptyText","isPlaceholder":"micromag-screen-keypad-isPlaceholder","layout":"micromag-screen-keypad-layout","header":"micromag-screen-keypad-header","footer":"micromag-screen-keypad-footer","inner":"micromag-screen-keypad-inner","grid":"micromag-screen-keypad-grid","item":"micromag-screen-keypad-item","placeholderItem":"micromag-screen-keypad-placeholderItem","isEmpty":"micromag-screen-keypad-isEmpty","disableHover":"micromag-screen-keypad-disableHover","isLink":"micromag-screen-keypad-isLink","imagePlaceholder":"micromag-screen-keypad-imagePlaceholder","buttonPlaceholder":"micromag-screen-keypad-buttonPlaceholder","buttonVisualPlaceholder":"micromag-screen-keypad-buttonVisualPlaceholder","empty":"micromag-screen-keypad-empty","emptyButtonVisual":"micromag-screen-keypad-emptyButtonVisual","popupScroll":"micromag-screen-keypad-popupScroll","popupInner":"micromag-screen-keypad-popupInner","popupContent":"micromag-screen-keypad-popupContent","popupHeading":"micromag-screen-keypad-popupHeading","popupVisual":"micromag-screen-keypad-popupVisual","contentSplit":"micromag-screen-keypad-contentSplit","emptyHeading":"micromag-screen-keypad-emptyHeading","emptyVisual":"micromag-screen-keypad-emptyVisual","emptyContent":"micromag-screen-keypad-emptyContent","emptyCTA":"micromag-screen-keypad-emptyCTA","popupCTA":"micromag-screen-keypad-popupCTA","contentBottom":"micromag-screen-keypad-contentBottom","layoutLabelTop":"micromag-screen-keypad-layoutLabelTop","buttonVisual":"micromag-screen-keypad-buttonVisual"};
29
29
 
30
30
  var placeholders = [{
31
31
  id: '1'
@@ -96,6 +96,7 @@ var propTypes = {
96
96
  visual: PropTypes$1.visualElement,
97
97
  boxStyle: PropTypes$1.boxStyle
98
98
  })),
99
+ title: PropTypes$1.headingElement,
99
100
  layout: PropTypes.oneOf(['top', 'middle', 'bottom']),
100
101
  spacing: PropTypes.number,
101
102
  keypadSettings: PropTypes.shape({
@@ -126,6 +127,7 @@ var propTypes = {
126
127
  };
127
128
  var defaultProps = {
128
129
  items: null,
130
+ title: null,
129
131
  layout: null,
130
132
  spacing: 20,
131
133
  keypadSettings: null,
@@ -139,8 +141,9 @@ var defaultProps = {
139
141
  className: null
140
142
  };
141
143
  var KeypadScreen = function KeypadScreen(_ref) {
142
- var _ref18;
144
+ var _ref20;
143
145
  var items = _ref.items,
146
+ title = _ref.title,
144
147
  layout = _ref.layout,
145
148
  spacing = _ref.spacing,
146
149
  keypadSettings = _ref.keypadSettings,
@@ -152,6 +155,8 @@ var KeypadScreen = function KeypadScreen(_ref) {
152
155
  current = _ref.current,
153
156
  active = _ref.active,
154
157
  className = _ref.className;
158
+ var containerRef = useRef(null);
159
+ var popupInnerRef = useRef(null);
155
160
  var trackScreenEvent = useTrackScreenEvent('keypad');
156
161
  var _usePlaybackContext = usePlaybackContext(),
157
162
  muted = _usePlaybackContext.muted;
@@ -167,6 +172,9 @@ var KeypadScreen = function KeypadScreen(_ref) {
167
172
  viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
168
173
  var _useViewerWebView = useViewerWebView(),
169
174
  openWebView = _useViewerWebView.open;
175
+ var _useViewerInteraction = useViewerInteraction(),
176
+ enableInteraction = _useViewerInteraction.enableInteraction,
177
+ disableInteraction = _useViewerInteraction.disableInteraction;
170
178
  var _useScreenRenderConte = useScreenRenderContext(),
171
179
  isView = _useScreenRenderConte.isView,
172
180
  isPreview = _useScreenRenderConte.isPreview,
@@ -180,6 +188,10 @@ var KeypadScreen = function KeypadScreen(_ref) {
180
188
  openWebView: openWebView,
181
189
  isPreview: isPreview
182
190
  });
191
+ var hasTitle = isTextFilled(title);
192
+ var _ref2 = title || {},
193
+ _ref2$textStyle = _ref2.textStyle,
194
+ titleTextStyle = _ref2$textStyle === void 0 ? null : _ref2$textStyle;
183
195
  var _useDimensionObserver = useDimensionObserver(),
184
196
  headerRef = _useDimensionObserver.ref,
185
197
  _useDimensionObserver2 = _useDimensionObserver.height,
@@ -191,36 +203,41 @@ var KeypadScreen = function KeypadScreen(_ref) {
191
203
  var backgroundPlaying = current && (isView || isEdit);
192
204
  var mediaShouldLoad = !isPlaceholder && (current || active);
193
205
  var isInteractivePreview = isEdit && screenState === null;
194
- var _ref2 = keypadSettings || {},
195
- _ref2$layout = _ref2.layout,
196
- keypadLayout = _ref2$layout === void 0 ? null : _ref2$layout;
197
- var _ref3 = keypadLayout || {},
198
- _ref3$columnAlign = _ref3.columnAlign,
199
- columnAlign = _ref3$columnAlign === void 0 ? null : _ref3$columnAlign,
200
- _ref3$columns = _ref3.columns,
201
- columns = _ref3$columns === void 0 ? null : _ref3$columns,
202
- _ref3$spacing = _ref3.spacing,
203
- columnSpacing = _ref3$spacing === void 0 ? null : _ref3$spacing,
204
- _ref3$withSquareItems = _ref3.withSquareItems,
205
- withSquareItems = _ref3$withSquareItems === void 0 ? false : _ref3$withSquareItems;
206
- var _ref4 = buttonStyles || {},
207
- _ref4$layout = _ref4.layout,
208
- buttonLayout = _ref4$layout === void 0 ? null : _ref4$layout,
209
- _ref4$textStyle = _ref4.textStyle,
210
- buttonTextStyle = _ref4$textStyle === void 0 ? null : _ref4$textStyle,
211
- _ref4$boxStyle = _ref4.boxStyle,
212
- buttonBoxStyle = _ref4$boxStyle === void 0 ? null : _ref4$boxStyle;
213
- var _ref5 = popupStyles || {},
206
+ var _ref3 = keypadSettings || {},
207
+ _ref3$layout = _ref3.layout,
208
+ keypadLayout = _ref3$layout === void 0 ? null : _ref3$layout;
209
+ var _ref4 = keypadLayout || {},
210
+ _ref4$columnAlign = _ref4.columnAlign,
211
+ columnAlign = _ref4$columnAlign === void 0 ? null : _ref4$columnAlign,
212
+ _ref4$columns = _ref4.columns,
213
+ columns = _ref4$columns === void 0 ? null : _ref4$columns,
214
+ _ref4$spacing = _ref4.spacing,
215
+ columnSpacing = _ref4$spacing === void 0 ? null : _ref4$spacing,
216
+ _ref4$withSquareItems = _ref4.withSquareItems,
217
+ withSquareItems = _ref4$withSquareItems === void 0 ? false : _ref4$withSquareItems;
218
+ var _ref5 = buttonStyles || {},
214
219
  _ref5$layout = _ref5.layout,
215
- popupLayout = _ref5$layout === void 0 ? null : _ref5$layout,
216
- _ref5$backdrop = _ref5.backdrop,
217
- popupBackdrop = _ref5$backdrop === void 0 ? null : _ref5$backdrop,
218
- _ref5$headingTextStyl = _ref5.headingTextStyle,
219
- headingTextStyle = _ref5$headingTextStyl === void 0 ? null : _ref5$headingTextStyl,
220
- _ref5$contentTextStyl = _ref5.contentTextStyle,
221
- contentTextStyle = _ref5$contentTextStyl === void 0 ? null : _ref5$contentTextStyl,
220
+ buttonLayout = _ref5$layout === void 0 ? null : _ref5$layout,
221
+ _ref5$textStyle = _ref5.textStyle,
222
+ buttonTextStyle = _ref5$textStyle === void 0 ? null : _ref5$textStyle,
222
223
  _ref5$boxStyle = _ref5.boxStyle,
223
- popupBoxStyle = _ref5$boxStyle === void 0 ? null : _ref5$boxStyle;
224
+ buttonBoxStyle = _ref5$boxStyle === void 0 ? null : _ref5$boxStyle;
225
+ var _ref6 = popupStyles || {},
226
+ _ref6$layout = _ref6.layout,
227
+ popupLayout = _ref6$layout === void 0 ? null : _ref6$layout,
228
+ _ref6$headingTextStyl = _ref6.headingTextStyle,
229
+ headingTextStyle = _ref6$headingTextStyl === void 0 ? null : _ref6$headingTextStyl,
230
+ _ref6$contentTextStyl = _ref6.contentTextStyle,
231
+ contentTextStyle = _ref6$contentTextStyl === void 0 ? null : _ref6$contentTextStyl,
232
+ _ref6$button = _ref6.button,
233
+ popupButtons = _ref6$button === void 0 ? null : _ref6$button,
234
+ _ref6$boxStyle = _ref6.boxStyle,
235
+ popupBoxStyle = _ref6$boxStyle === void 0 ? null : _ref6$boxStyle;
236
+ var _ref7 = popupButtons || {},
237
+ _ref7$buttonTextStyle = _ref7.buttonTextStyle,
238
+ popupButtonsTextStyle = _ref7$buttonTextStyle === void 0 ? null : _ref7$buttonTextStyle,
239
+ _ref7$boxStyle = _ref7.boxStyle,
240
+ popupButtonsBoxStyle = _ref7$boxStyle === void 0 ? null : _ref7$boxStyle;
224
241
  var popupLayoutClassName = useMemo(function () {
225
242
  return popupLayout !== null ? camelCase(popupLayout) : '';
226
243
  }, [popupLayout]);
@@ -232,45 +249,40 @@ var KeypadScreen = function KeypadScreen(_ref) {
232
249
  _useState4 = _slicedToArray(_useState3, 2),
233
250
  popup = _useState4[0],
234
251
  setPopup = _useState4[1];
235
- var _ref6 = popup || {},
236
- _ref6$heading = _ref6.heading,
237
- popupHeading = _ref6$heading === void 0 ? null : _ref6$heading,
238
- _ref6$content = _ref6.content,
239
- popupContent = _ref6$content === void 0 ? null : _ref6$content,
240
- _ref6$largeVisual = _ref6.largeVisual,
241
- largeVisual = _ref6$largeVisual === void 0 ? null : _ref6$largeVisual,
242
- _ref6$button = _ref6.button,
243
- popupButton = _ref6$button === void 0 ? null : _ref6$button;
252
+ var _ref8 = popup || {},
253
+ _ref8$heading = _ref8.heading,
254
+ popupHeading = _ref8$heading === void 0 ? null : _ref8$heading,
255
+ _ref8$content = _ref8.content,
256
+ popupContent = _ref8$content === void 0 ? null : _ref8$content,
257
+ _ref8$largeVisual = _ref8.largeVisual,
258
+ largeVisual = _ref8$largeVisual === void 0 ? null : _ref8$largeVisual,
259
+ _ref8$button = _ref8.button,
260
+ popupButton = _ref8$button === void 0 ? null : _ref8$button;
244
261
  var hasPopupHeading = isTextFilled(popupHeading);
245
- var _ref7 = popupHeading || {},
246
- _ref7$textStyle = _ref7.textStyle,
247
- popupHeadingTextStyle = _ref7$textStyle === void 0 ? null : _ref7$textStyle;
262
+ var _ref9 = popupHeading || {},
263
+ _ref9$textStyle = _ref9.textStyle,
264
+ popupHeadingTextStyle = _ref9$textStyle === void 0 ? null : _ref9$textStyle;
248
265
  var hasPopupContent = isTextFilled(popupContent);
249
- var _ref8 = popupContent || {},
250
- _ref8$textStyle = _ref8.textStyle,
251
- popupContentTextStyle = _ref8$textStyle === void 0 ? null : _ref8$textStyle;
252
- var _ref9 = popupBackdrop || {},
253
- _ref9$color = _ref9.color,
254
- backdropColor = _ref9$color === void 0 ? null : _ref9$color,
255
- _ref9$image = _ref9.image,
256
- backdropMedia = _ref9$image === void 0 ? null : _ref9$image;
257
- var _ref10 = popupButton || {},
258
- _ref10$label = _ref10.label,
259
- buttonLabel = _ref10$label === void 0 ? null : _ref10$label,
260
- _ref10$url = _ref10.url,
261
- buttonUrl = _ref10$url === void 0 ? null : _ref10$url,
262
- _ref10$inWebView = _ref10.inWebView,
263
- popupInWebView = _ref10$inWebView === void 0 ? false : _ref10$inWebView,
264
- _ref10$boxStyle = _ref10.boxStyle,
265
- popupButtonBoxStyle = _ref10$boxStyle === void 0 ? null : _ref10$boxStyle;
266
+ var _ref10 = popupContent || {},
267
+ _ref10$textStyle = _ref10.textStyle,
268
+ popupContentTextStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
269
+ var _ref11 = popupButton || {},
270
+ _ref11$label = _ref11.label,
271
+ buttonLabel = _ref11$label === void 0 ? null : _ref11$label,
272
+ _ref11$url = _ref11.url,
273
+ buttonUrl = _ref11$url === void 0 ? null : _ref11$url,
274
+ _ref11$inWebView = _ref11.inWebView,
275
+ popupInWebView = _ref11$inWebView === void 0 ? false : _ref11$inWebView,
276
+ _ref11$boxStyle = _ref11.boxStyle,
277
+ popupButtonBoxStyle = _ref11$boxStyle === void 0 ? null : _ref11$boxStyle;
266
278
  var onItemClick = useCallback(function (e, item) {
267
- var _ref11 = item || {},
268
- _ref11$inWebView = _ref11.inWebView,
269
- inWebView = _ref11$inWebView === void 0 ? false : _ref11$inWebView,
270
- _ref11$url = _ref11.url,
271
- url = _ref11$url === void 0 ? null : _ref11$url;
272
279
  e.stopPropagation();
273
280
  trackScreenEvent('click_item', item);
281
+ var _ref12 = item || {},
282
+ _ref12$inWebView = _ref12.inWebView,
283
+ inWebView = _ref12$inWebView === void 0 ? false : _ref12$inWebView,
284
+ _ref12$url = _ref12.url,
285
+ url = _ref12$url === void 0 ? null : _ref12$url;
274
286
  if (inWebView && url !== null) {
275
287
  openWebView({
276
288
  url: url
@@ -278,33 +290,80 @@ var KeypadScreen = function KeypadScreen(_ref) {
278
290
  return;
279
291
  }
280
292
  setPopup(item);
281
- setShowPopup(1);
282
- }, [setPopup, trackScreenEvent]);
293
+ setShowPopup(true);
294
+ }, [disableInteraction, setPopup, trackScreenEvent]);
283
295
  var onCloseModal = useCallback(function () {
284
- setShowPopup(0);
296
+ setShowPopup(false);
285
297
  trackScreenEvent('close_modal');
286
- }, [setShowPopup]);
287
- var computePopupProgress = useCallback(function (_ref12) {
288
- var dragActive = _ref12.active,
289
- _ref12$movement = _slicedToArray(_ref12.movement, 2),
290
- my = _ref12$movement[1],
291
- _ref12$velocity = _slicedToArray(_ref12.velocity, 2),
292
- vy = _ref12$velocity[1];
298
+ }, [enableInteraction, setShowPopup, trackScreenEvent]);
299
+ var _useState5 = useState(0),
300
+ _useState6 = _slicedToArray(_useState5, 2),
301
+ popupDragDirection = _useState6[0],
302
+ setPopupDragDirection = _useState6[1];
303
+ var onPopupScrollHeightChange = useCallback(function (_ref13) {
304
+ var _ref13$scrolleeHeight = _ref13.scrolleeHeight,
305
+ scrolleeHeight = _ref13$scrolleeHeight === void 0 ? 0 : _ref13$scrolleeHeight;
306
+ if (Math.floor(scrolleeHeight) >= Math.floor(height)) {
307
+ setPopupDragDirection('top');
308
+ } else {
309
+ setPopupDragDirection('bottom');
310
+ }
311
+ }, [height]);
312
+ var computePopupProgress = useCallback(function (_ref14) {
313
+ var dragActive = _ref14.active,
314
+ _ref14$movement = _slicedToArray(_ref14.movement, 2),
315
+ my = _ref14$movement[1],
316
+ _ref14$velocity = _slicedToArray(_ref14.velocity, 2),
317
+ vy = _ref14$velocity[1];
293
318
  var damper = 0.5;
294
- var p = Math.max(0, my) / window.innerHeight;
295
- var progress = p * damper;
296
- var reachedThreshold = vy > 0.3 || Math.abs(p) > 0.3;
319
+ var delta = Math.abs(my) / window.innerHeight;
320
+ var reachedThreshold = vy > 1 || delta > 0.3;
321
+ var progress = 0;
322
+ if (popupDragDirection === 'top' && my < 0) {
323
+ progress = delta * damper * -1;
324
+ } else if (popupDragDirection === 'bottom' && my > 0) {
325
+ progress = delta * damper;
326
+ }
297
327
  if (!dragActive) {
298
328
  if (reachedThreshold) {
299
329
  onCloseModal();
330
+ return 1;
331
+ }
332
+ return 0;
333
+ }
334
+ return progress;
335
+ }, [onCloseModal, popupDragDirection]);
336
+ useEffect(function () {
337
+ if (showPopup) {
338
+ disableInteraction();
339
+ } else {
340
+ enableInteraction();
341
+ }
342
+ }, [showPopup]);
343
+ useEffect(function () {
344
+ function handleClickOutside(event) {
345
+ if (!current && isView || popupInnerRef.current && !popupInnerRef.current.contains(event.target) && containerRef.current && containerRef.current.contains(event.target) && !isInteractivePreview && !isEdit && showPopup) {
346
+ onCloseModal();
300
347
  }
301
- return reachedThreshold ? 0 : 1;
302
348
  }
303
- return 1 - progress;
304
- }, [onCloseModal]);
349
+ document.addEventListener('mousedown', handleClickOutside);
350
+ return function () {
351
+ document.removeEventListener('mousedown', handleClickOutside);
352
+ };
353
+ }, [current, popupInnerRef, containerRef, isInteractivePreview, isEdit, showPopup]);
354
+ var _useState7 = useState(false),
355
+ _useState8 = _slicedToArray(_useState7, 2),
356
+ popupDragDisabled = _useState8[0],
357
+ setPopupDragDisabled = _useState8[1];
358
+ var onPopupScrollBottom = useCallback(function () {
359
+ setPopupDragDisabled(false);
360
+ }, [setPopupDragDisabled]);
361
+ var onPopupScrollNotBottom = useCallback(function () {
362
+ setPopupDragDisabled(true);
363
+ }, [setPopupDragDisabled]);
305
364
  var _useDragProgress = useDragProgress({
306
- disabled: !isView,
307
- progress: showPopup ? 1 : 0,
365
+ disabled: !isView || popupDragDisabled,
366
+ progress: showPopup ? 0 : 1,
308
367
  computeProgress: computePopupProgress,
309
368
  springParams: {
310
369
  config: {
@@ -318,7 +377,7 @@ var KeypadScreen = function KeypadScreen(_ref) {
318
377
  useEffect(function () {
319
378
  var keyup = function keyup(e) {
320
379
  if (e.key === 'Escape') {
321
- if (showPopup === 1) {
380
+ if (showPopup) {
322
381
  onCloseModal();
323
382
  }
324
383
  }
@@ -330,37 +389,37 @@ var KeypadScreen = function KeypadScreen(_ref) {
330
389
  }, [showPopup, onCloseModal]);
331
390
  var gridItems = useMemo(function () {
332
391
  return (items === null || items.length === 0 ? placeholders : items).map(function (item) {
333
- var _ref17;
334
- var _ref13 = item || {},
335
- _ref13$id = _ref13.id,
336
- id = _ref13$id === void 0 ? null : _ref13$id,
337
- _ref13$label = _ref13.label,
338
- label = _ref13$label === void 0 ? null : _ref13$label,
339
- _ref13$visual = _ref13.visual,
340
- visual = _ref13$visual === void 0 ? null : _ref13$visual,
341
- _ref13$textStyle = _ref13.textStyle,
342
- textStyle = _ref13$textStyle === void 0 ? null : _ref13$textStyle,
343
- _ref13$boxStyle = _ref13.boxStyle,
344
- boxStyle = _ref13$boxStyle === void 0 ? null : _ref13$boxStyle,
345
- _ref13$heading = _ref13.heading,
346
- heading = _ref13$heading === void 0 ? null : _ref13$heading,
347
- _ref13$content = _ref13.content,
348
- content = _ref13$content === void 0 ? null : _ref13$content,
349
- _ref13$url = _ref13.url,
350
- url = _ref13$url === void 0 ? null : _ref13$url,
351
- _ref13$inWebView = _ref13.inWebView,
352
- inWebView = _ref13$inWebView === void 0 ? false : _ref13$inWebView,
353
- _ref13$largeVisual = _ref13.largeVisual,
354
- popupLargeVisual = _ref13$largeVisual === void 0 ? null : _ref13$largeVisual;
355
- var _ref14 = visual || {},
356
- _ref14$url = _ref14.url,
357
- visualUrl = _ref14$url === void 0 ? null : _ref14$url;
358
- var _ref15 = heading || {},
359
- _ref15$body = _ref15.body,
360
- headingBody = _ref15$body === void 0 ? null : _ref15$body;
361
- var _ref16 = content || {},
362
- _ref16$body = _ref16.body,
363
- contentBody = _ref16$body === void 0 ? null : _ref16$body;
392
+ var _ref19;
393
+ var _ref15 = item || {},
394
+ _ref15$id = _ref15.id,
395
+ id = _ref15$id === void 0 ? null : _ref15$id,
396
+ _ref15$label = _ref15.label,
397
+ label = _ref15$label === void 0 ? null : _ref15$label,
398
+ _ref15$visual = _ref15.visual,
399
+ visual = _ref15$visual === void 0 ? null : _ref15$visual,
400
+ _ref15$textStyle = _ref15.textStyle,
401
+ textStyle = _ref15$textStyle === void 0 ? null : _ref15$textStyle,
402
+ _ref15$boxStyle = _ref15.boxStyle,
403
+ boxStyle = _ref15$boxStyle === void 0 ? null : _ref15$boxStyle,
404
+ _ref15$heading = _ref15.heading,
405
+ heading = _ref15$heading === void 0 ? null : _ref15$heading,
406
+ _ref15$content = _ref15.content,
407
+ content = _ref15$content === void 0 ? null : _ref15$content,
408
+ _ref15$url = _ref15.url,
409
+ url = _ref15$url === void 0 ? null : _ref15$url,
410
+ _ref15$inWebView = _ref15.inWebView,
411
+ inWebView = _ref15$inWebView === void 0 ? false : _ref15$inWebView,
412
+ _ref15$largeVisual = _ref15.largeVisual,
413
+ popupLargeVisual = _ref15$largeVisual === void 0 ? null : _ref15$largeVisual;
414
+ var _ref16 = visual || {},
415
+ _ref16$url = _ref16.url,
416
+ visualUrl = _ref16$url === void 0 ? null : _ref16$url;
417
+ var _ref17 = heading || {},
418
+ _ref17$body = _ref17.body,
419
+ headingBody = _ref17$body === void 0 ? null : _ref17$body;
420
+ var _ref18 = content || {},
421
+ _ref18$body = _ref18.body,
422
+ contentBody = _ref18$body === void 0 ? null : _ref18$body;
364
423
  var key = label || visualUrl || id;
365
424
  var isEmpty = label === null && visual === null;
366
425
  var isExternalLink = url !== null && !inWebView;
@@ -369,18 +428,14 @@ var KeypadScreen = function KeypadScreen(_ref) {
369
428
  key: key,
370
429
  className: styles.item
371
430
  }, /*#__PURE__*/React.createElement(Button, {
372
- className: classNames([styles.button, (_ref17 = {}, _defineProperty(_ref17, styles.layoutLabelBottom, buttonLayout === 'label-bottom'), _defineProperty(_ref17, styles.layoutLabelTop, buttonLayout === 'label-top'), _defineProperty(_ref17, styles.layoutNoLabel, buttonLayout === 'no-label'), _defineProperty(_ref17, styles.layoutLabelOver, buttonLayout === 'label-over'), _defineProperty(_ref17, styles.isEmpty, isEmpty), _defineProperty(_ref17, styles.isLink, url !== null), _defineProperty(_ref17, styles.disableHover, isPopupEmpty && url === null), _ref17)]),
431
+ className: classNames([styles.button, (_ref19 = {}, _defineProperty(_ref19, styles.layoutLabelBottom, buttonLayout === 'label-bottom'), _defineProperty(_ref19, styles.layoutLabelTop, buttonLayout === 'label-top'), _defineProperty(_ref19, styles.layoutNoLabel, buttonLayout === 'no-label'), _defineProperty(_ref19, styles.layoutLabelOver, buttonLayout === 'label-over'), _defineProperty(_ref19, styles.isEmpty, isEmpty), _defineProperty(_ref19, styles.isLink, url !== null), _defineProperty(_ref19, styles.disableHover, isPopupEmpty && url === null), _ref19)]),
373
432
  style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getStyleFromBox(buttonBoxStyle)), getStyleFromText(buttonTextStyle)), getStyleFromBox(boxStyle)), getStyleFromText(textStyle)),
374
433
  external: isExternalLink,
375
434
  href: isExternalLink ? url : null,
376
- onClick: !isPopupEmpty || !isExternalLink ? function (e) {
435
+ onClick: !isPopupEmpty || url !== null && !isExternalLink ? function (e) {
377
436
  return onItemClick(e, item);
378
437
  } : null
379
- }, isEmpty && (isInteractivePreview || isPreview) ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PlaceholderImage, {
380
- className: styles.imagePlaceholder
381
- }), /*#__PURE__*/React.createElement(PlaceholderText, {
382
- lines: 2
383
- })) : /*#__PURE__*/React.createElement(React.Fragment, null, visual !== null || !isInteractivePreview ? /*#__PURE__*/React.createElement(ScreenElement, {
438
+ }, /*#__PURE__*/React.createElement(ScreenElement, {
384
439
  emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
385
440
  id: "Qanvis",
386
441
  defaultMessage: [{
@@ -390,12 +445,12 @@ var KeypadScreen = function KeypadScreen(_ref) {
390
445
  }),
391
446
  emptyClassName: classNames([styles.empty, styles.buttonVisual, styles.emptyButtonVisual]),
392
447
  isEmpty: visual === null
393
- }, /*#__PURE__*/React.createElement(Visual, {
448
+ }, visual !== null ? /*#__PURE__*/React.createElement(Visual, {
394
449
  className: styles.buttonVisual,
395
450
  imageClassName: styles.thumbnail,
396
451
  media: visual,
397
452
  width: "auto"
398
- })) : null, label !== null || !isInteractivePreview ? /*#__PURE__*/React.createElement(ScreenElement, {
453
+ }) : null), /*#__PURE__*/React.createElement(ScreenElement, {
399
454
  placeholder: /*#__PURE__*/React.createElement(PlaceholderButton, null),
400
455
  emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
401
456
  id: "Zbu5Uk",
@@ -406,33 +461,34 @@ var KeypadScreen = function KeypadScreen(_ref) {
406
461
  }),
407
462
  emptyClassName: classNames([styles.empty, styles.emptyButtonLabel]),
408
463
  isEmpty: label === null
409
- }, /*#__PURE__*/React.createElement("div", {
464
+ }, label !== null || !isInteractivePreview ? /*#__PURE__*/React.createElement("div", {
410
465
  className: styles.buttonLabel
411
- }, label)) : null)));
466
+ }, label) : null)));
412
467
  });
413
468
  }, [items, screenState, keypadSettings]);
414
469
  useEffect(function () {
415
470
  if (screenState === 'popup' && isPlaceholder) {
416
471
  setPopup(placeholderPopupBoxStyles); // @note force placeholder
417
- setShowPopup(1);
472
+ setShowPopup(true);
418
473
  }
419
474
  if (screenState === 'keypad') {
420
475
  setPopup(null);
421
- setShowPopup(0);
476
+ setShowPopup(false);
422
477
  }
423
478
  if (screenState !== null && screenState.includes('popup')) {
424
479
  var index = screenState.split('.').pop();
425
480
  var found = items[index];
426
- setShowPopup(1);
427
481
  setPopup(found);
482
+ setShowPopup(true);
428
483
  }
429
484
  if (screenState === null) {
430
- setShowPopup(0);
431
485
  setPopup(null);
486
+ setShowPopup(false);
432
487
  }
433
488
  }, [screenState, items]);
434
489
  return /*#__PURE__*/React.createElement("div", {
435
- className: classNames([styles.container, (_ref18 = {}, _defineProperty(_ref18, className, className !== null), _defineProperty(_ref18, styles.isPlaceholder, isPlaceholder), _defineProperty(_ref18, styles.withSquareItems, withSquareItems), _ref18)]),
490
+ ref: containerRef,
491
+ className: classNames([styles.container, (_ref20 = {}, _defineProperty(_ref20, className, className !== null), _defineProperty(_ref20, styles.isPlaceholder, isPlaceholder), _defineProperty(_ref20, styles.withSquareItems, withSquareItems), _ref20)]),
436
492
  "data-screen-ready": true
437
493
  }, isEdit && screenState !== null ? /*#__PURE__*/React.createElement("div", mouseBlocker) : null, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
438
494
  background: background,
@@ -452,10 +508,12 @@ var KeypadScreen = function KeypadScreen(_ref) {
452
508
  width: width,
453
509
  height: height,
454
510
  verticalAlign: layout,
455
- disabled: isPreview || isPlaceholder || isEdit || showPopup !== 0
511
+ withArrow: !showPopup,
512
+ disabled: isPreview || isPlaceholder || showPopup
456
513
  }, /*#__PURE__*/React.createElement(Layout, {
457
514
  className: styles.layout,
458
515
  verticalAlign: layout,
516
+ width: width,
459
517
  style: !isPlaceholder ? {
460
518
  padding: spacing,
461
519
  paddingTop: (hasHeader ? headerHeight : spacing) + (current && !isPreview ? viewerTopHeight : 0),
@@ -471,7 +529,22 @@ var KeypadScreen = function KeypadScreen(_ref) {
471
529
  paddingBottom: spacing,
472
530
  transform: !isPreview ? "translate(0, ".concat(viewerTopHeight, "px)") : null
473
531
  }
474
- }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(Keypad$1, {
532
+ }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(ScreenElement, {
533
+ placeholder: "Title",
534
+ emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
535
+ id: "BSTWf8",
536
+ defaultMessage: [{
537
+ "type": 0,
538
+ "value": "Title"
539
+ }]
540
+ }),
541
+ emptyClassName: classNames([styles.empty, styles.emptyHeading]),
542
+ isEmpty: !hasTitle
543
+ }, hasTitle ? /*#__PURE__*/React.createElement(Heading, Object.assign({
544
+ className: styles.title
545
+ }, title, {
546
+ textStyle: _objectSpread(_objectSpread({}, headingTextStyle), getStyleFromText(titleTextStyle))
547
+ })) : null), /*#__PURE__*/React.createElement(Keypad$1, {
475
548
  className: classNames([styles.grid, _defineProperty({}, styles.gridPlaceholder, isPlaceholder)]),
476
549
  align: columnAlign,
477
550
  columns: isPlaceholder ? 3 : columns,
@@ -487,52 +560,40 @@ var KeypadScreen = function KeypadScreen(_ref) {
487
560
  paddingBottom: spacing / 2,
488
561
  paddingTop: spacing
489
562
  }
490
- }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null), /*#__PURE__*/React.createElement(animated.div, {
563
+ }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null), popup !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(animated.div, {
491
564
  className: classNames([styles.popupBackdrop]),
492
565
  style: {
493
566
  opacity: popupSpring.to(function (p) {
494
- return p;
567
+ return 1 - Math.abs(p);
495
568
  })
496
569
  }
497
- }, /*#__PURE__*/React.createElement(Background$1, {
498
- width: width,
499
- height: height,
500
- resolution: resolution,
501
- playing: backgroundPlaying,
502
- media: backdropMedia,
503
- color: backdropColor,
504
- muted: true
505
- })), /*#__PURE__*/React.createElement(animated.div, Object.assign({
570
+ }), /*#__PURE__*/React.createElement(animated.div, Object.assign({
506
571
  className: styles.popup,
507
572
  style: {
508
573
  transform: popupSpring.to(function (p) {
509
- return "translateY(".concat(100 * (1 - (p < 0.2 ? 0.1 * p + p : p)), "%)");
574
+ return "translateY(".concat(100 * p
575
+ // 100 * (1 - (p < 0.2 && p > -0.2 ? 0.1 * p + p : p))
576
+ , "%) scale(").concat(1 - Math.abs(p * 0.5), ")");
510
577
  }),
511
578
  pointerEvents: popupSpring.to(function (p) {
512
- return p < 0.1 ? 'none' : 'auto';
579
+ return Math.abs(p) > 0.5 ? 'none' : 'auto';
513
580
  })
514
581
  }
515
- }, bindPopupDrag(), {
516
- onClick: function onClick() {
517
- if (onCloseModal !== null) {
518
- onCloseModal();
519
- }
520
- }
521
- }), /*#__PURE__*/React.createElement(Scroll, {
522
- disabled: isPreview || isPlaceholder || isEdit,
582
+ }, bindPopupDrag()), /*#__PURE__*/React.createElement(Scroll, {
583
+ disabled: isPreview || isPlaceholder,
523
584
  verticalAlign: "middle",
524
585
  withArrow: false,
586
+ scrollPosition: !showPopup ? 1 : null,
587
+ onScrolledBottom: onPopupScrollBottom,
588
+ onScrolledNotBottom: onPopupScrollNotBottom,
589
+ onScrollHeightChange: onPopupScrollHeightChange,
590
+ className: styles.popupScroll,
525
591
  withShadow: true
526
- }, /*#__PURE__*/React.createElement("button", {
527
- type: "button",
528
- className: styles.popupButton
529
592
  }, /*#__PURE__*/React.createElement("div", {
593
+ ref: popupInnerRef,
530
594
  className: classNames([styles.popupInner, styles[popupLayoutClassName]]),
531
595
  style: _objectSpread(_objectSpread({}, getStyleFromBox(placeholderPopupBoxStyles)), getStyleFromBox(popupBoxStyle))
532
- }, /*#__PURE__*/React.createElement("div", {
533
- className: styles.popupWrapper
534
596
  }, /*#__PURE__*/React.createElement(ScreenElement, {
535
- placeholder: "popupHeading",
536
597
  emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
537
598
  id: "IE7U/Q",
538
599
  defaultMessage: [{
@@ -559,9 +620,10 @@ var KeypadScreen = function KeypadScreen(_ref) {
559
620
  isEmpty: !hasPopupContent
560
621
  }, hasPopupContent ? /*#__PURE__*/React.createElement(Text, Object.assign({
561
622
  className: styles.popupContent
623
+ // @TODO: There's a styles clash here, check if there's more elsewhere
562
624
  }, popupContent, {
563
625
  textStyle: _objectSpread(_objectSpread({}, contentTextStyle), popupContentTextStyle)
564
- })) : null), largeVisual !== null ? /*#__PURE__*/React.createElement(ScreenElement, {
626
+ })) : null), /*#__PURE__*/React.createElement(ScreenElement, {
565
627
  placeholder: "image",
566
628
  emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
567
629
  id: "z4Pr+g",
@@ -572,11 +634,11 @@ var KeypadScreen = function KeypadScreen(_ref) {
572
634
  }),
573
635
  emptyClassName: classNames([styles.empty, styles.emptyVisual]),
574
636
  isEmpty: largeVisual === null
575
- }, /*#__PURE__*/React.createElement(Visual, {
637
+ }, largeVisual !== null ? /*#__PURE__*/React.createElement(Visual, {
576
638
  className: styles.popupVisual,
577
639
  media: largeVisual,
578
640
  width: "100%"
579
- })) : null, /*#__PURE__*/React.createElement(ScreenElement, {
641
+ }) : null), /*#__PURE__*/React.createElement(ScreenElement, {
580
642
  placeholder: "button",
581
643
  emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
582
644
  id: "N7Kj8z",
@@ -585,18 +647,22 @@ var KeypadScreen = function KeypadScreen(_ref) {
585
647
  "value": "Button"
586
648
  }]
587
649
  }),
588
- emptyClassName: classNames([styles.empty]),
650
+ emptyClassName: classNames([styles.empty, styles.emptyCTA]),
589
651
  isEmpty: popupButton === null
590
652
  }, popupButton !== null ? /*#__PURE__*/React.createElement(CallToAction, {
591
653
  className: styles.popupCTA,
592
- label: buttonLabel,
654
+ label: _objectSpread(_objectSpread({}, popupButtonsTextStyle), buttonLabel),
593
655
  url: buttonUrl,
594
656
  inWebView: popupInWebView,
595
657
  openWebView: openWebView,
596
658
  type: "click",
597
- boxStyle: popupButtonBoxStyle,
598
- style: _objectSpread({}, getStyleFromBox(popupButtonBoxStyle))
599
- }) : null)))))))));
659
+ boxStyle: _objectSpread(_objectSpread({}, popupButtonsBoxStyle), popupButtonBoxStyle)
660
+ // style={{
661
+ // ...getStyleFromText(popupButtonsTextStyle),
662
+ // ...getStyleFromBox(popupButtonsBoxStyle),
663
+ // ...getStyleFromBox(popupButtonBoxStyle),
664
+ // }}
665
+ }) : null))))) : null)));
600
666
  };
601
667
  KeypadScreen.propTypes = propTypes;
602
668
  KeypadScreen.defaultProps = defaultProps;
@@ -701,7 +767,6 @@ var definition = [{
701
767
  fields: [{
702
768
  name: 'layout',
703
769
  type: 'button-layout',
704
- isHorizontal: true,
705
770
  label: defineMessage({
706
771
  id: "OPxJx/",
707
772
  defaultMessage: [{
@@ -778,23 +843,44 @@ var definition = [{
778
843
  }]
779
844
  })
780
845
  }, {
781
- name: 'boxStyle',
782
- type: 'box-style-form',
846
+ name: 'button',
847
+ type: 'fields',
783
848
  label: defineMessage({
784
- id: "p1pghO",
849
+ id: "i6bmbD",
785
850
  defaultMessage: [{
786
851
  "type": 0,
787
- "value": "Box style"
852
+ "value": "Button"
788
853
  }]
789
- })
854
+ }),
855
+ fields: [{
856
+ name: 'buttonTextStyle',
857
+ type: 'text-style-form',
858
+ label: defineMessage({
859
+ id: "p5RHzq",
860
+ defaultMessage: [{
861
+ "type": 0,
862
+ "value": "Button text style"
863
+ }]
864
+ })
865
+ }, {
866
+ name: 'buttonStyle',
867
+ type: 'box-style-form',
868
+ label: defineMessage({
869
+ id: "nno1Pq",
870
+ defaultMessage: [{
871
+ "type": 0,
872
+ "value": "Button style"
873
+ }]
874
+ })
875
+ }]
790
876
  }, {
791
- name: 'backdrop',
792
- type: 'background',
877
+ name: 'boxStyle',
878
+ type: 'box-style-form',
793
879
  label: defineMessage({
794
- id: "cDj1mZ",
880
+ id: "p1pghO",
795
881
  defaultMessage: [{
796
882
  "type": 0,
797
- "value": "Background"
883
+ "value": "Box style"
798
884
  }]
799
885
  })
800
886
  }]
@@ -854,6 +940,19 @@ var definition = [{
854
940
  }]
855
941
  }],
856
942
  fields: [{
943
+ name: 'title',
944
+ type: 'heading-element',
945
+ theme: {
946
+ textStyle: 'heading1'
947
+ },
948
+ label: defineMessage({
949
+ id: "N25iDO",
950
+ defaultMessage: [{
951
+ "type": 0,
952
+ "value": "Title"
953
+ }]
954
+ })
955
+ }, {
857
956
  name: 'background',
858
957
  type: 'background',
859
958
  label: defineMessage({