@micromag/screen-keypad 0.3.531 → 0.3.547

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/es/index.js +4 -5
  2. package/package.json +19 -20
  3. package/lib/index.js +0 -1005
package/es/index.js CHANGED
@@ -18,7 +18,7 @@ import Container from '@micromag/element-container';
18
18
  import Footer from '@micromag/element-footer';
19
19
  import Header from '@micromag/element-header';
20
20
  import Heading from '@micromag/element-heading';
21
- import Keypad$1 from '@micromag/element-keypad';
21
+ import Keypad from '@micromag/element-keypad';
22
22
  import Layout from '@micromag/element-layout';
23
23
  import Scroll from '@micromag/element-scroll';
24
24
  import Text from '@micromag/element-text';
@@ -543,7 +543,7 @@ var KeypadScreen = function KeypadScreen(_ref) {
543
543
  className: styles.title
544
544
  }, title, {
545
545
  textStyle: titleTextStyle
546
- })) : null), /*#__PURE__*/React.createElement(Keypad$1, {
546
+ })) : null), /*#__PURE__*/React.createElement(Keypad, {
547
547
  className: classNames([styles.grid, _defineProperty({}, styles.gridPlaceholder, isPlaceholder)]),
548
548
  align: columnAlign,
549
549
  columns: isPlaceholder ? 3 : columns,
@@ -657,7 +657,6 @@ var KeypadScreen = function KeypadScreen(_ref) {
657
657
  };
658
658
  KeypadScreen.propTypes = propTypes;
659
659
  KeypadScreen.defaultProps = defaultProps;
660
- var Keypad = KeypadScreen;
661
660
 
662
661
  var definition = [{
663
662
  id: 'keypad',
@@ -680,7 +679,7 @@ var definition = [{
680
679
  }]
681
680
  }),
682
681
  layouts: ['top', 'middle', 'bottom'],
683
- component: Keypad,
682
+ component: KeypadScreen,
684
683
  states: [{
685
684
  id: 'keypad',
686
685
  label: defineMessage({
@@ -997,4 +996,4 @@ var definition = [{
997
996
  }]
998
997
  }];
999
998
 
1000
- export { Keypad, definition as default };
999
+ export { KeypadScreen as Keypad, definition as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-keypad",
3
- "version": "0.3.531",
3
+ "version": "0.3.547",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -34,12 +34,11 @@
34
34
  }
35
35
  ],
36
36
  "license": "ISC",
37
- "main": "lib/index.js",
37
+ "type": "module",
38
38
  "module": "es/index.js",
39
39
  "style": "assets/css/styles.css",
40
40
  "exports": {
41
41
  ".": {
42
- "require": "./lib/index.js",
43
42
  "import": "./es/index.js"
44
43
  },
45
44
  "./assets/css/styles": "./assets/css/styles.css",
@@ -66,22 +65,22 @@
66
65
  },
67
66
  "dependencies": {
68
67
  "@babel/runtime": "^7.13.10",
69
- "@micromag/core": "^0.3.531",
70
- "@micromag/element-background": "^0.3.531",
71
- "@micromag/element-button": "^0.3.531",
72
- "@micromag/element-call-to-action": "^0.3.531",
73
- "@micromag/element-container": "^0.3.531",
74
- "@micromag/element-footer": "^0.3.531",
75
- "@micromag/element-grid": "^0.3.531",
76
- "@micromag/element-header": "^0.3.531",
77
- "@micromag/element-heading": "^0.3.531",
78
- "@micromag/element-keypad": "^0.3.531",
79
- "@micromag/element-layout": "^0.3.531",
80
- "@micromag/element-scroll": "^0.3.531",
81
- "@micromag/element-text": "^0.3.531",
82
- "@micromag/element-urbania-author": "^0.3.531",
83
- "@micromag/element-visual": "^0.3.531",
84
- "@micromag/transforms": "^0.3.531",
68
+ "@micromag/core": "^0.3.547",
69
+ "@micromag/element-background": "^0.3.547",
70
+ "@micromag/element-button": "^0.3.547",
71
+ "@micromag/element-call-to-action": "^0.3.547",
72
+ "@micromag/element-container": "^0.3.547",
73
+ "@micromag/element-footer": "^0.3.547",
74
+ "@micromag/element-grid": "^0.3.547",
75
+ "@micromag/element-header": "^0.3.547",
76
+ "@micromag/element-heading": "^0.3.547",
77
+ "@micromag/element-keypad": "^0.3.547",
78
+ "@micromag/element-layout": "^0.3.547",
79
+ "@micromag/element-scroll": "^0.3.547",
80
+ "@micromag/element-text": "^0.3.547",
81
+ "@micromag/element-urbania-author": "^0.3.547",
82
+ "@micromag/element-visual": "^0.3.547",
83
+ "@micromag/transforms": "^0.3.547",
85
84
  "@react-spring/core": "^9.6.1",
86
85
  "@react-spring/web": "^9.6.1",
87
86
  "@use-gesture/react": "^10.3.0",
@@ -96,5 +95,5 @@
96
95
  "access": "public",
97
96
  "registry": "https://registry.npmjs.org/"
98
97
  },
99
- "gitHead": "e3a59c467ad33528b38eb4badd78b6ed0e38a3a6"
98
+ "gitHead": "3c2f5904ce61fcfa61f673c38c2a5ec56e9e2b07"
100
99
  }
package/lib/index.js DELETED
@@ -1,1005 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var reactIntl = require('react-intl');
6
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
7
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
8
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
9
- var web = require('@react-spring/web');
10
- var classNames = require('classnames');
11
- var PropTypes = require('prop-types');
12
- var React = require('react');
13
- var core = require('@micromag/core');
14
- var components = require('@micromag/core/components');
15
- var contexts = require('@micromag/core/contexts');
16
- var hooks = require('@micromag/core/hooks');
17
- var utils = require('@micromag/core/utils');
18
- var Background = require('@micromag/element-background');
19
- var Button = require('@micromag/element-button');
20
- var CallToAction = require('@micromag/element-call-to-action');
21
- var Container = require('@micromag/element-container');
22
- var Footer = require('@micromag/element-footer');
23
- var Header = require('@micromag/element-header');
24
- var Heading = require('@micromag/element-heading');
25
- var Keypad$1 = require('@micromag/element-keypad');
26
- var Layout = require('@micromag/element-layout');
27
- var Scroll = require('@micromag/element-scroll');
28
- var Text = require('@micromag/element-text');
29
- var Visual = require('@micromag/element-visual');
30
-
31
- 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"};
32
-
33
- var placeholders = [{
34
- id: '1'
35
- }, {
36
- id: '2'
37
- }, {
38
- id: '3'
39
- }, {
40
- id: '4'
41
- }, {
42
- id: '5'
43
- }, {
44
- id: '6'
45
- }, {
46
- id: '7'
47
- }, {
48
- id: '8'
49
- }, {
50
- id: '9'
51
- }];
52
- var placeholderPopupBoxStyles = {
53
- padding: {
54
- left: 30,
55
- top: 30,
56
- right: 30,
57
- bottom: 30
58
- }
59
- };
60
- var stopDragEventsPropagation = {
61
- onTouchMove: function onTouchMove(e) {
62
- return e.stopPropagation();
63
- },
64
- onTouchStart: function onTouchStart(e) {
65
- return e.stopPropagation();
66
- },
67
- onTouchEnd: function onTouchEnd(e) {
68
- return e.stopPropagation();
69
- },
70
- onPointerMove: function onPointerMove(e) {
71
- return e.stopPropagation();
72
- },
73
- onPointerUp: function onPointerUp(e) {
74
- return e.stopPropagation();
75
- },
76
- onPointerDown: function onPointerDown(e) {
77
- return e.stopPropagation();
78
- }
79
- };
80
- var mouseBlocker = _objectSpread(_objectSpread({}, stopDragEventsPropagation), {}, {
81
- onClick: function onClick(e) {
82
- return e.stopPropagation();
83
- },
84
- style: {
85
- position: 'fixed',
86
- zIndex: '1000',
87
- top: 0,
88
- right: 0,
89
- bottom: 0,
90
- left: 0,
91
- cursor: 'default'
92
- }
93
- });
94
- var propTypes = {
95
- items: PropTypes.arrayOf(PropTypes.shape({
96
- id: PropTypes.string,
97
- heading: core.PropTypes.headingElement,
98
- description: core.PropTypes.textElement,
99
- visual: core.PropTypes.visualElement,
100
- boxStyle: core.PropTypes.boxStyle
101
- })),
102
- title: core.PropTypes.headingElement,
103
- layout: PropTypes.oneOf(['top', 'middle', 'bottom']),
104
- spacing: PropTypes.number,
105
- keypadSettings: PropTypes.shape({
106
- layout: PropTypes.shape({
107
- columnAlign: PropTypes.oneOf(['left', 'right', 'middle']),
108
- columns: PropTypes.number,
109
- spacing: PropTypes.number,
110
- withSquareItems: PropTypes.bool
111
- })
112
- }),
113
- buttonStyles: PropTypes.shape({
114
- layout: PropTypes.string,
115
- textStyle: core.PropTypes.textStyle,
116
- boxStyle: core.PropTypes.boxStyle
117
- }),
118
- popupStyles: PropTypes.shape({
119
- layout: PropTypes.oneOf(['content-top', 'content-split', 'content-bottom']),
120
- headingTextStyle: core.PropTypes.textStyle,
121
- contentTextStyle: core.PropTypes.textStyle,
122
- boxStyle: core.PropTypes.boxStyle
123
- }),
124
- header: core.PropTypes.header,
125
- footer: core.PropTypes.footer,
126
- background: core.PropTypes.backgroundElement,
127
- current: PropTypes.bool,
128
- active: PropTypes.bool,
129
- className: PropTypes.string
130
- };
131
- var defaultProps = {
132
- items: null,
133
- title: null,
134
- layout: null,
135
- spacing: 20,
136
- keypadSettings: null,
137
- buttonStyles: null,
138
- popupStyles: null,
139
- header: null,
140
- footer: null,
141
- background: null,
142
- current: true,
143
- active: true,
144
- className: null
145
- };
146
- var KeypadScreen = function KeypadScreen(_ref) {
147
- var items = _ref.items,
148
- title = _ref.title,
149
- layout = _ref.layout,
150
- spacing = _ref.spacing,
151
- keypadSettings = _ref.keypadSettings,
152
- buttonStyles = _ref.buttonStyles,
153
- popupStyles = _ref.popupStyles,
154
- header = _ref.header,
155
- footer = _ref.footer,
156
- background = _ref.background,
157
- current = _ref.current,
158
- active = _ref.active,
159
- className = _ref.className;
160
- var containerRef = React.useRef(null);
161
- var popupInnerRef = React.useRef(null);
162
- var trackScreenEvent = hooks.useTrackScreenEvent('keypad');
163
- var _usePlaybackContext = contexts.usePlaybackContext(),
164
- muted = _usePlaybackContext.muted;
165
- var mediaRef = contexts.usePlaybackMediaRef(current);
166
- var screenState = contexts.useScreenState();
167
- var _useScreenSize = contexts.useScreenSize(),
168
- width = _useScreenSize.width,
169
- height = _useScreenSize.height,
170
- resolution = _useScreenSize.resolution;
171
- var _useViewerContext = contexts.useViewerContext(),
172
- viewerTopHeight = _useViewerContext.topHeight,
173
- viewerBottomHeight = _useViewerContext.bottomHeight,
174
- viewerBottomSidesWidth = _useViewerContext.bottomSidesWidth;
175
- var _useViewerWebView = contexts.useViewerWebView(),
176
- openWebView = _useViewerWebView.open;
177
- var _useViewerInteraction = contexts.useViewerInteraction(),
178
- enableInteraction = _useViewerInteraction.enableInteraction,
179
- disableInteraction = _useViewerInteraction.disableInteraction;
180
- var _useScreenRenderConte = contexts.useScreenRenderContext(),
181
- isView = _useScreenRenderConte.isView,
182
- isPreview = _useScreenRenderConte.isPreview,
183
- isPlaceholder = _useScreenRenderConte.isPlaceholder,
184
- isEdit = _useScreenRenderConte.isEdit;
185
- var hasHeader = utils.isHeaderFilled(header);
186
- var hasFooter = utils.isFooterFilled(footer);
187
- var footerProps = utils.getFooterProps(footer, {
188
- isView: isView,
189
- current: current,
190
- openWebView: openWebView,
191
- isPreview: isPreview
192
- });
193
- var hasTitle = utils.isTextFilled(title);
194
- var _ref2 = title || {},
195
- _ref2$textStyle = _ref2.textStyle,
196
- titleTextStyle = _ref2$textStyle === void 0 ? null : _ref2$textStyle;
197
- var _useDimensionObserver = hooks.useDimensionObserver(),
198
- headerRef = _useDimensionObserver.ref,
199
- _useDimensionObserver2 = _useDimensionObserver.height,
200
- headerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
201
- var _useDimensionObserver3 = hooks.useDimensionObserver(),
202
- footerRef = _useDimensionObserver3.ref,
203
- _useDimensionObserver4 = _useDimensionObserver3.height,
204
- footerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
205
- var backgroundPlaying = current && (isView || isEdit);
206
- var mediaShouldLoad = !isPlaceholder && (current || active);
207
- var isInteractivePreview = isEdit && screenState === null;
208
- var _ref3 = keypadSettings || {},
209
- _ref3$layout = _ref3.layout,
210
- keypadLayout = _ref3$layout === void 0 ? null : _ref3$layout;
211
- var _ref4 = keypadLayout || {},
212
- _ref4$columnAlign = _ref4.columnAlign,
213
- columnAlign = _ref4$columnAlign === void 0 ? null : _ref4$columnAlign,
214
- _ref4$columns = _ref4.columns,
215
- columns = _ref4$columns === void 0 ? null : _ref4$columns,
216
- _ref4$spacing = _ref4.spacing,
217
- columnSpacing = _ref4$spacing === void 0 ? null : _ref4$spacing,
218
- _ref4$withSquareItems = _ref4.withSquareItems,
219
- withSquareItems = _ref4$withSquareItems === void 0 ? false : _ref4$withSquareItems;
220
- var _ref5 = buttonStyles || {},
221
- _ref5$layout = _ref5.layout,
222
- buttonLayout = _ref5$layout === void 0 ? null : _ref5$layout,
223
- _ref5$textStyle = _ref5.textStyle,
224
- buttonTextStyle = _ref5$textStyle === void 0 ? null : _ref5$textStyle,
225
- _ref5$boxStyle = _ref5.boxStyle,
226
- buttonBoxStyle = _ref5$boxStyle === void 0 ? null : _ref5$boxStyle;
227
- var _ref6 = popupStyles || {},
228
- _ref6$layout = _ref6.layout,
229
- popupLayout = _ref6$layout === void 0 ? null : _ref6$layout,
230
- _ref6$headingTextStyl = _ref6.headingTextStyle,
231
- headingTextStyle = _ref6$headingTextStyl === void 0 ? null : _ref6$headingTextStyl,
232
- _ref6$contentTextStyl = _ref6.contentTextStyle,
233
- contentTextStyle = _ref6$contentTextStyl === void 0 ? null : _ref6$contentTextStyl,
234
- _ref6$button = _ref6.button,
235
- popupButtons = _ref6$button === void 0 ? null : _ref6$button,
236
- _ref6$boxStyle = _ref6.boxStyle,
237
- popupBoxStyle = _ref6$boxStyle === void 0 ? null : _ref6$boxStyle;
238
- var _ref7 = popupButtons || {},
239
- _ref7$buttonTextStyle = _ref7.buttonTextStyle,
240
- popupButtonsTextStyle = _ref7$buttonTextStyle === void 0 ? null : _ref7$buttonTextStyle,
241
- _ref7$boxStyle = _ref7.boxStyle,
242
- popupButtonsBoxStyle = _ref7$boxStyle === void 0 ? null : _ref7$boxStyle;
243
- var popupLayoutClassName = React.useMemo(function () {
244
- return popupLayout !== null ? utils.camelCase(popupLayout) : '';
245
- }, [popupLayout]);
246
- var _useState = React.useState(false),
247
- _useState2 = _slicedToArray(_useState, 2),
248
- showPopup = _useState2[0],
249
- setShowPopup = _useState2[1];
250
- var _useState3 = React.useState(null),
251
- _useState4 = _slicedToArray(_useState3, 2),
252
- popup = _useState4[0],
253
- setPopup = _useState4[1];
254
- var _ref8 = popup || {},
255
- _ref8$heading = _ref8.heading,
256
- popupHeading = _ref8$heading === void 0 ? null : _ref8$heading,
257
- _ref8$content = _ref8.content,
258
- popupContent = _ref8$content === void 0 ? null : _ref8$content,
259
- _ref8$largeVisual = _ref8.largeVisual,
260
- largeVisual = _ref8$largeVisual === void 0 ? null : _ref8$largeVisual,
261
- _ref8$button = _ref8.button,
262
- popupButton = _ref8$button === void 0 ? null : _ref8$button;
263
- var hasPopupHeading = utils.isTextFilled(popupHeading);
264
- var _ref9 = popupHeading || {},
265
- _ref9$textStyle = _ref9.textStyle,
266
- popupHeadingTextStyle = _ref9$textStyle === void 0 ? null : _ref9$textStyle;
267
- var hasPopupContent = utils.isTextFilled(popupContent);
268
- var _ref10 = popupContent || {},
269
- _ref10$textStyle = _ref10.textStyle,
270
- popupContentTextStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle;
271
- var _ref11 = popupButton || {},
272
- _ref11$label = _ref11.label,
273
- buttonLabel = _ref11$label === void 0 ? null : _ref11$label,
274
- _ref11$url = _ref11.url,
275
- buttonUrl = _ref11$url === void 0 ? null : _ref11$url,
276
- _ref11$inWebView = _ref11.inWebView,
277
- popupInWebView = _ref11$inWebView === void 0 ? false : _ref11$inWebView,
278
- _ref11$boxStyle = _ref11.boxStyle,
279
- popupButtonBoxStyle = _ref11$boxStyle === void 0 ? null : _ref11$boxStyle;
280
- var onItemClick = React.useCallback(function (e, item) {
281
- e.stopPropagation();
282
- trackScreenEvent('click_item', item);
283
- var _ref12 = item || {},
284
- _ref12$inWebView = _ref12.inWebView,
285
- inWebView = _ref12$inWebView === void 0 ? false : _ref12$inWebView,
286
- _ref12$url = _ref12.url,
287
- url = _ref12$url === void 0 ? null : _ref12$url;
288
- if (inWebView && url !== null) {
289
- openWebView({
290
- url: url
291
- });
292
- return;
293
- }
294
- setPopup(item);
295
- setShowPopup(true);
296
- }, [disableInteraction, setPopup, trackScreenEvent]);
297
- var onCloseModal = React.useCallback(function () {
298
- setShowPopup(false);
299
- trackScreenEvent('close_modal');
300
- }, [enableInteraction, setShowPopup, trackScreenEvent]);
301
- var _useState5 = React.useState(0),
302
- _useState6 = _slicedToArray(_useState5, 2),
303
- popupDragDirection = _useState6[0],
304
- setPopupDragDirection = _useState6[1];
305
- var onPopupScrollHeightChange = React.useCallback(function (_ref13) {
306
- var _ref13$scrolleeHeight = _ref13.scrolleeHeight,
307
- scrolleeHeight = _ref13$scrolleeHeight === void 0 ? 0 : _ref13$scrolleeHeight;
308
- if (Math.floor(scrolleeHeight) >= Math.floor(height)) {
309
- setPopupDragDirection('top');
310
- } else {
311
- setPopupDragDirection('bottom');
312
- }
313
- }, [height]);
314
- var computePopupProgress = React.useCallback(function (_ref14) {
315
- var dragActive = _ref14.active,
316
- _ref14$movement = _slicedToArray(_ref14.movement, 2),
317
- my = _ref14$movement[1],
318
- _ref14$velocity = _slicedToArray(_ref14.velocity, 2),
319
- vy = _ref14$velocity[1];
320
- var damper = 0.5;
321
- var delta = Math.abs(my) / window.innerHeight;
322
- var reachedThreshold = vy > 1 || delta > 0.3;
323
- var progress = 0;
324
- if (popupDragDirection === 'top' && my < 0) {
325
- progress = delta * damper * -1;
326
- } else if (popupDragDirection === 'bottom' && my > 0) {
327
- progress = delta * damper;
328
- }
329
- if (!dragActive) {
330
- if (reachedThreshold) {
331
- onCloseModal();
332
- return 1;
333
- }
334
- return 0;
335
- }
336
- return progress;
337
- }, [onCloseModal, popupDragDirection]);
338
- React.useEffect(function () {
339
- if (showPopup) {
340
- disableInteraction();
341
- } else {
342
- enableInteraction();
343
- }
344
- }, [showPopup]);
345
- React.useEffect(function () {
346
- function handleClickOutside(event) {
347
- if (!current && isView || popupInnerRef.current && !popupInnerRef.current.contains(event.target) && containerRef.current && containerRef.current.contains(event.target) && !isInteractivePreview && !isEdit && showPopup) {
348
- onCloseModal();
349
- }
350
- }
351
- document.addEventListener('mousedown', handleClickOutside);
352
- return function () {
353
- document.removeEventListener('mousedown', handleClickOutside);
354
- };
355
- }, [current, popupInnerRef, containerRef, isInteractivePreview, isEdit, showPopup]);
356
- var _useState7 = React.useState(false),
357
- _useState8 = _slicedToArray(_useState7, 2),
358
- popupDragDisabled = _useState8[0],
359
- setPopupDragDisabled = _useState8[1];
360
- var onPopupScrollBottom = React.useCallback(function () {
361
- setPopupDragDisabled(false);
362
- }, [setPopupDragDisabled]);
363
- var onPopupScrollNotBottom = React.useCallback(function () {
364
- setPopupDragDisabled(true);
365
- }, [setPopupDragDisabled]);
366
- var _useDragProgress = hooks.useDragProgress({
367
- disabled: !isView || popupDragDisabled,
368
- progress: showPopup ? 0 : 1,
369
- computeProgress: computePopupProgress,
370
- springParams: {
371
- config: {
372
- tension: 300,
373
- friction: 30
374
- }
375
- }
376
- }),
377
- bindPopupDrag = _useDragProgress.bind,
378
- popupSpring = _useDragProgress.progress;
379
- React.useEffect(function () {
380
- var keyup = function keyup(e) {
381
- if (e.key === 'Escape') {
382
- if (showPopup) {
383
- onCloseModal();
384
- }
385
- }
386
- };
387
- document.addEventListener('keyup', keyup);
388
- return function () {
389
- document.removeEventListener('keyup', keyup);
390
- };
391
- }, [showPopup, onCloseModal]);
392
- var gridItems = React.useMemo(function () {
393
- return (items === null || items.length === 0 ? placeholders : items).map(function (item) {
394
- var _ref15 = item || {},
395
- _ref15$id = _ref15.id,
396
- id = _ref15$id === void 0 ? null : _ref15$id,
397
- _ref15$label = _ref15.label,
398
- label = _ref15$label === void 0 ? null : _ref15$label,
399
- _ref15$visual = _ref15.visual,
400
- visual = _ref15$visual === void 0 ? null : _ref15$visual,
401
- _ref15$textStyle = _ref15.textStyle,
402
- textStyle = _ref15$textStyle === void 0 ? null : _ref15$textStyle,
403
- _ref15$boxStyle = _ref15.boxStyle,
404
- boxStyle = _ref15$boxStyle === void 0 ? null : _ref15$boxStyle,
405
- _ref15$heading = _ref15.heading,
406
- heading = _ref15$heading === void 0 ? null : _ref15$heading,
407
- _ref15$content = _ref15.content,
408
- content = _ref15$content === void 0 ? null : _ref15$content,
409
- _ref15$url = _ref15.url,
410
- url = _ref15$url === void 0 ? null : _ref15$url,
411
- _ref15$inWebView = _ref15.inWebView,
412
- inWebView = _ref15$inWebView === void 0 ? false : _ref15$inWebView,
413
- _ref15$largeVisual = _ref15.largeVisual,
414
- popupLargeVisual = _ref15$largeVisual === void 0 ? null : _ref15$largeVisual;
415
- var _ref16 = visual || {},
416
- _ref16$url = _ref16.url,
417
- visualUrl = _ref16$url === void 0 ? null : _ref16$url;
418
- var _ref17 = heading || {},
419
- _ref17$body = _ref17.body,
420
- headingBody = _ref17$body === void 0 ? null : _ref17$body;
421
- var _ref18 = content || {},
422
- _ref18$body = _ref18.body,
423
- contentBody = _ref18$body === void 0 ? null : _ref18$body;
424
- var key = label || visualUrl || id;
425
- var isEmpty = label === null && visual === null;
426
- var isExternalLink = url !== null && !inWebView;
427
- var isPopupEmpty = (heading === null || headingBody === null || headingBody === '') && (content === null || contentBody === null || contentBody === '') && popupLargeVisual === null;
428
- return /*#__PURE__*/React.createElement("div", {
429
- key: key,
430
- className: styles.item
431
- }, /*#__PURE__*/React.createElement(Button, {
432
- className: classNames([styles.button, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.layoutLabelBottom, buttonLayout === 'label-bottom'), styles.layoutLabelTop, buttonLayout === 'label-top'), styles.layoutNoLabel, buttonLayout === 'no-label'), styles.layoutLabelOver, buttonLayout === 'label-over'), styles.isEmpty, isEmpty), styles.isLink, url !== null), styles.disableHover, isPopupEmpty && url === null)]),
433
- style: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, utils.getStyleFromBox(buttonBoxStyle)), utils.getStyleFromText(buttonTextStyle)), utils.getStyleFromBox(boxStyle)), utils.getStyleFromText(textStyle)),
434
- external: isExternalLink,
435
- href: isExternalLink ? url : null,
436
- focusable: current,
437
- onClick: !isPopupEmpty || url !== null && !isExternalLink ? function (e) {
438
- return onItemClick(e, item);
439
- } : null
440
- }, /*#__PURE__*/React.createElement(components.ScreenElement, {
441
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
442
- id: "Qanvis",
443
- defaultMessage: [{
444
- "type": 0,
445
- "value": "Visual"
446
- }]
447
- }),
448
- emptyClassName: classNames([styles.empty, styles.buttonVisual, styles.emptyButtonVisual]),
449
- isEmpty: visual === null
450
- }, visual !== null ? /*#__PURE__*/React.createElement(Visual, {
451
- className: styles.buttonVisual,
452
- imageClassName: styles.thumbnail,
453
- media: visual,
454
- width: "auto"
455
- }) : null), /*#__PURE__*/React.createElement(components.ScreenElement, {
456
- placeholder: /*#__PURE__*/React.createElement(components.PlaceholderButton, null),
457
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
458
- id: "Zbu5Uk",
459
- defaultMessage: [{
460
- "type": 0,
461
- "value": "Label"
462
- }]
463
- }),
464
- emptyClassName: classNames([styles.empty, styles.emptyButtonLabel]),
465
- isEmpty: label === null
466
- }, label !== null || !isInteractivePreview ? /*#__PURE__*/React.createElement("div", {
467
- className: styles.buttonLabel
468
- }, label) : null)));
469
- });
470
- }, [items, screenState, keypadSettings]);
471
- React.useEffect(function () {
472
- if (screenState === 'popup' && isPlaceholder) {
473
- setPopup(placeholderPopupBoxStyles); // @note force placeholder
474
- setShowPopup(true);
475
- }
476
- if (screenState === 'keypad') {
477
- setPopup(null);
478
- setShowPopup(false);
479
- }
480
- if (screenState !== null && screenState.includes('popup')) {
481
- var index = screenState.split('.').pop();
482
- var found = items[index];
483
- setPopup(found);
484
- setShowPopup(true);
485
- }
486
- if (screenState === null) {
487
- setPopup(null);
488
- setShowPopup(false);
489
- }
490
- }, [screenState, items]);
491
- return /*#__PURE__*/React.createElement("div", {
492
- ref: containerRef,
493
- className: classNames([styles.container, _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles.isPlaceholder, isPlaceholder), styles.withSquareItems, withSquareItems)]),
494
- "data-screen-ready": true
495
- }, isEdit && screenState !== null ? /*#__PURE__*/React.createElement("div", mouseBlocker) : null, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
496
- background: background,
497
- width: width,
498
- height: height,
499
- resolution: resolution,
500
- playing: backgroundPlaying,
501
- muted: muted,
502
- shouldLoad: mediaShouldLoad,
503
- mediaRef: mediaRef,
504
- className: styles.background
505
- }) : null, /*#__PURE__*/React.createElement(Container, {
506
- width: width,
507
- height: height,
508
- className: styles.inner
509
- }, /*#__PURE__*/React.createElement(Scroll, {
510
- width: width,
511
- height: height,
512
- verticalAlign: layout,
513
- withArrow: !showPopup,
514
- withShadow: !showPopup,
515
- disabled: isPreview || isPlaceholder || showPopup
516
- }, /*#__PURE__*/React.createElement(Layout, {
517
- className: styles.layout,
518
- verticalAlign: layout,
519
- width: width,
520
- style: !isPlaceholder ? {
521
- padding: spacing,
522
- paddingTop: (hasHeader ? headerHeight : spacing) + (current && !isPreview ? viewerTopHeight : 0),
523
- paddingBottom: (hasFooter ? footerHeight : spacing) + (current && !isPreview ? viewerBottomHeight : 0)
524
- } : null
525
- }, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
526
- ref: headerRef,
527
- className: styles.header,
528
- style: {
529
- paddingTop: spacing / 2,
530
- paddingLeft: spacing,
531
- paddingRight: spacing,
532
- paddingBottom: spacing,
533
- transform: !isPreview ? "translate(0, ".concat(viewerTopHeight, "px)") : null
534
- }
535
- }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(components.ScreenElement, {
536
- placeholder: "Title",
537
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
538
- id: "BSTWf8",
539
- defaultMessage: [{
540
- "type": 0,
541
- "value": "Title"
542
- }]
543
- }),
544
- emptyClassName: classNames([styles.empty, styles.emptyHeading]),
545
- isEmpty: !hasTitle
546
- }, hasTitle ? /*#__PURE__*/React.createElement(Heading, Object.assign({
547
- className: styles.title
548
- }, title, {
549
- textStyle: titleTextStyle
550
- })) : null), /*#__PURE__*/React.createElement(Keypad$1, {
551
- className: classNames([styles.grid, _defineProperty({}, styles.gridPlaceholder, isPlaceholder)]),
552
- align: columnAlign,
553
- columns: isPlaceholder ? 3 : columns,
554
- spacing: isPlaceholder ? 2 : columnSpacing,
555
- items: gridItems
556
- }), !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
557
- ref: footerRef,
558
- className: styles.footer,
559
- style: {
560
- transform: current && !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
561
- paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
562
- paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
563
- paddingBottom: spacing / 2,
564
- paddingTop: spacing
565
- }
566
- }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null), popup !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(web.animated.div, {
567
- className: classNames([styles.popupBackdrop]),
568
- style: {
569
- opacity: popupSpring.to(function (p) {
570
- return 1 - Math.abs(p);
571
- })
572
- }
573
- }), /*#__PURE__*/React.createElement(web.animated.div, Object.assign({
574
- className: styles.popup,
575
- style: {
576
- transform: popupSpring.to(function (p) {
577
- return "translateY(".concat(100 * p, "%) scale(").concat(1 - Math.abs(p * 0.5), ")");
578
- }),
579
- pointerEvents: popupSpring.to(function (p) {
580
- return Math.abs(p) > 0.5 ? 'none' : 'auto';
581
- })
582
- }
583
- }, bindPopupDrag()), /*#__PURE__*/React.createElement(Scroll, {
584
- disabled: isPreview || isPlaceholder,
585
- verticalAlign: "middle",
586
- withArrow: false,
587
- scrollPosition: !showPopup ? 1 : null,
588
- onScrolledBottom: onPopupScrollBottom,
589
- onScrolledNotBottom: onPopupScrollNotBottom,
590
- onScrollHeightChange: onPopupScrollHeightChange,
591
- className: styles.popupScroll,
592
- withShadow: true
593
- }, /*#__PURE__*/React.createElement("div", {
594
- ref: popupInnerRef,
595
- className: classNames([styles.popupInner, styles[popupLayoutClassName]]),
596
- style: _objectSpread(_objectSpread({}, utils.getStyleFromBox(placeholderPopupBoxStyles)), utils.getStyleFromBox(popupBoxStyle))
597
- }, /*#__PURE__*/React.createElement(components.ScreenElement, {
598
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
599
- id: "IE7U/Q",
600
- defaultMessage: [{
601
- "type": 0,
602
- "value": "Heading"
603
- }]
604
- }),
605
- emptyClassName: classNames([styles.empty, styles.emptyHeading]),
606
- isEmpty: !hasPopupHeading
607
- }, hasPopupHeading ? /*#__PURE__*/React.createElement(Heading, Object.assign({
608
- className: styles.popupHeading
609
- }, popupHeading, {
610
- textStyle: _objectSpread(_objectSpread({}, headingTextStyle), popupHeadingTextStyle)
611
- })) : null), /*#__PURE__*/React.createElement(components.ScreenElement, {
612
- placeholder: "popupContent",
613
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
614
- id: "JRZoe6",
615
- defaultMessage: [{
616
- "type": 0,
617
- "value": "Content"
618
- }]
619
- }),
620
- emptyClassName: classNames([styles.empty, styles.emptyContent]),
621
- isEmpty: !hasPopupContent
622
- }, hasPopupContent ? /*#__PURE__*/React.createElement(Text, Object.assign({
623
- className: styles.popupContent
624
- }, popupContent, {
625
- textStyle: _objectSpread(_objectSpread({}, contentTextStyle), popupContentTextStyle)
626
- })) : null), /*#__PURE__*/React.createElement(components.ScreenElement, {
627
- placeholder: "image",
628
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
629
- id: "z4Pr+g",
630
- defaultMessage: [{
631
- "type": 0,
632
- "value": "Visual (Image or Video)"
633
- }]
634
- }),
635
- emptyClassName: classNames([styles.empty, styles.emptyVisual]),
636
- isEmpty: largeVisual === null
637
- }, largeVisual !== null ? /*#__PURE__*/React.createElement(Visual, {
638
- className: styles.popupVisual,
639
- media: largeVisual,
640
- width: "100%"
641
- }) : null), /*#__PURE__*/React.createElement(components.ScreenElement, {
642
- placeholder: "button",
643
- emptyLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
644
- id: "N7Kj8z",
645
- defaultMessage: [{
646
- "type": 0,
647
- "value": "Button"
648
- }]
649
- }),
650
- emptyClassName: classNames([styles.empty, styles.emptyCTA]),
651
- isEmpty: popupButton === null
652
- }, popupButton !== null ? /*#__PURE__*/React.createElement(CallToAction, {
653
- className: styles.popupCTA,
654
- label: _objectSpread(_objectSpread({}, popupButtonsTextStyle), buttonLabel),
655
- url: buttonUrl,
656
- inWebView: popupInWebView,
657
- openWebView: openWebView,
658
- type: "click",
659
- boxStyle: _objectSpread(_objectSpread({}, popupButtonsBoxStyle), popupButtonBoxStyle)
660
- }) : null))))) : null)));
661
- };
662
- KeypadScreen.propTypes = propTypes;
663
- KeypadScreen.defaultProps = defaultProps;
664
- var Keypad = KeypadScreen;
665
-
666
- var definition = [{
667
- id: 'keypad',
668
- type: 'screen',
669
- group: {
670
- label: reactIntl.defineMessage({
671
- id: "cGItoy",
672
- defaultMessage: [{
673
- "type": 0,
674
- "value": "List"
675
- }]
676
- }),
677
- order: 4
678
- },
679
- title: reactIntl.defineMessage({
680
- id: "75nZbY",
681
- defaultMessage: [{
682
- "type": 0,
683
- "value": "Keypad"
684
- }]
685
- }),
686
- layouts: ['top', 'middle', 'bottom'],
687
- component: Keypad,
688
- states: [{
689
- id: 'keypad',
690
- label: reactIntl.defineMessage({
691
- id: "Z4f5qh",
692
- defaultMessage: [{
693
- "type": 0,
694
- "value": "Buttons"
695
- }]
696
- }),
697
- fields: [{
698
- name: 'layout',
699
- type: 'screen-layout',
700
- defaultValue: 'middle',
701
- label: reactIntl.defineMessage({
702
- id: "4iBXj2",
703
- defaultMessage: [{
704
- "type": 0,
705
- "value": "Layout"
706
- }]
707
- })
708
- }, {
709
- name: 'keypadSettings',
710
- type: 'fields',
711
- isList: false,
712
- withoutLabel: true,
713
- defaultValue: {
714
- layout: {
715
- columnAlign: 'middle',
716
- columns: 3,
717
- spacing: 2,
718
- withSquareItems: false
719
- }
720
- },
721
- label: reactIntl.defineMessage({
722
- id: "FjuRaw",
723
- defaultMessage: [{
724
- "type": 0,
725
- "value": "Keypad settings"
726
- }]
727
- }),
728
- fields: [{
729
- name: 'layout',
730
- type: 'keypad-layout',
731
- isList: true
732
- }]
733
- }, {
734
- name: 'items',
735
- type: 'buttons',
736
- label: reactIntl.defineMessage({
737
- id: "fbUW2U",
738
- defaultMessage: [{
739
- "type": 0,
740
- "value": "Items"
741
- }]
742
- }),
743
- isSection: true
744
- }, {
745
- name: 'buttonStyles',
746
- type: 'fields',
747
- defaultValue: {
748
- layout: 'label-bottom',
749
- boxStyle: {
750
- backgroundColor: {
751
- alpha: 0.15,
752
- color: '#000000'
753
- }
754
- }
755
- },
756
- isList: true,
757
- fields: [{
758
- name: 'layout',
759
- type: 'button-layout',
760
- label: reactIntl.defineMessage({
761
- id: "OPxJx/",
762
- defaultMessage: [{
763
- "type": 0,
764
- "value": "Layout"
765
- }]
766
- })
767
- }, {
768
- name: 'textStyle',
769
- type: 'text-style-form',
770
- label: reactIntl.defineMessage({
771
- id: "rzXCu2",
772
- defaultMessage: [{
773
- "type": 0,
774
- "value": "Label style"
775
- }]
776
- })
777
- }, {
778
- name: 'boxStyle',
779
- type: 'box-style-form',
780
- label: reactIntl.defineMessage({
781
- id: "nno1Pq",
782
- defaultMessage: [{
783
- "type": 0,
784
- "value": "Button style"
785
- }]
786
- })
787
- }]
788
- }]
789
- }, {
790
- id: 'popups',
791
- label: reactIntl.defineMessage({
792
- id: "FYm4w+",
793
- defaultMessage: [{
794
- "type": 0,
795
- "value": "Popups"
796
- }]
797
- }),
798
- fields: [{
799
- name: 'popupStyles',
800
- type: 'fields',
801
- defaultValue: {
802
- layout: 'content-top'
803
- },
804
- isList: true,
805
- fields: [{
806
- name: 'layout',
807
- type: 'card-layout',
808
- label: reactIntl.defineMessage({
809
- id: "OPxJx/",
810
- defaultMessage: [{
811
- "type": 0,
812
- "value": "Layout"
813
- }]
814
- })
815
- }, {
816
- name: 'headingTextStyle',
817
- type: 'text-style-form',
818
- label: reactIntl.defineMessage({
819
- id: "zrK6ak",
820
- defaultMessage: [{
821
- "type": 0,
822
- "value": "Heading text style"
823
- }]
824
- })
825
- }, {
826
- name: 'contentTextStyle',
827
- type: 'text-style-form',
828
- label: reactIntl.defineMessage({
829
- id: "z9nSIG",
830
- defaultMessage: [{
831
- "type": 0,
832
- "value": "Content text style"
833
- }]
834
- })
835
- }, {
836
- name: 'button',
837
- type: 'fields',
838
- label: reactIntl.defineMessage({
839
- id: "i6bmbD",
840
- defaultMessage: [{
841
- "type": 0,
842
- "value": "Button"
843
- }]
844
- }),
845
- fields: [{
846
- name: 'buttonTextStyle',
847
- type: 'text-style-form',
848
- label: reactIntl.defineMessage({
849
- id: "p5RHzq",
850
- defaultMessage: [{
851
- "type": 0,
852
- "value": "Button text style"
853
- }]
854
- })
855
- }, {
856
- name: 'buttonStyle',
857
- type: 'box-style-form',
858
- label: reactIntl.defineMessage({
859
- id: "nno1Pq",
860
- defaultMessage: [{
861
- "type": 0,
862
- "value": "Button style"
863
- }]
864
- })
865
- }]
866
- }, {
867
- name: 'boxStyle',
868
- type: 'box-style-form',
869
- label: reactIntl.defineMessage({
870
- id: "p1pghO",
871
- defaultMessage: [{
872
- "type": 0,
873
- "value": "Box style"
874
- }]
875
- })
876
- }]
877
- }]
878
- }, {
879
- id: 'popup',
880
- label: reactIntl.defineMessage({
881
- id: "sSahY1",
882
- defaultMessage: [{
883
- "type": 0,
884
- "value": "Popup"
885
- }]
886
- }),
887
- defaultValue: [],
888
- repeatable: true,
889
- fieldName: 'items',
890
- fields: [{
891
- name: 'heading',
892
- type: 'heading-element',
893
- label: reactIntl.defineMessage({
894
- id: "6iR9Mt",
895
- defaultMessage: [{
896
- "type": 0,
897
- "value": "Heading"
898
- }]
899
- })
900
- }, {
901
- name: 'content',
902
- type: 'text-element',
903
- label: reactIntl.defineMessage({
904
- id: "uoF5Pv",
905
- defaultMessage: [{
906
- "type": 0,
907
- "value": "Content"
908
- }]
909
- }),
910
- theme: {
911
- label: {
912
- textStyle: 'text'
913
- }
914
- }
915
- }, {
916
- name: 'largeVisual',
917
- type: 'visual',
918
- label: reactIntl.defineMessage({
919
- id: "HwqzVR",
920
- defaultMessage: [{
921
- "type": 0,
922
- "value": "Visual"
923
- }]
924
- })
925
- }, {
926
- name: 'button',
927
- type: 'button-link',
928
- label: reactIntl.defineMessage({
929
- id: "i6bmbD",
930
- defaultMessage: [{
931
- "type": 0,
932
- "value": "Button"
933
- }]
934
- }),
935
- theme: {
936
- label: {
937
- textStyle: 'button'
938
- }
939
- }
940
- }]
941
- }],
942
- fields: [{
943
- name: 'title',
944
- type: 'heading-element',
945
- theme: {
946
- textStyle: 'heading1'
947
- },
948
- label: reactIntl.defineMessage({
949
- id: "N25iDO",
950
- defaultMessage: [{
951
- "type": 0,
952
- "value": "Title"
953
- }]
954
- })
955
- }, {
956
- name: 'background',
957
- type: 'background',
958
- label: reactIntl.defineMessage({
959
- id: "+MPZRu",
960
- defaultMessage: [{
961
- "type": 0,
962
- "value": "Background"
963
- }]
964
- })
965
- }, {
966
- name: 'header',
967
- type: 'header',
968
- label: reactIntl.defineMessage({
969
- id: "rhuDxI",
970
- defaultMessage: [{
971
- "type": 0,
972
- "value": "Header"
973
- }]
974
- }),
975
- theme: {
976
- badge: {
977
- label: {
978
- textStyle: 'badge'
979
- },
980
- boxStyle: 'badge'
981
- }
982
- }
983
- }, {
984
- name: 'footer',
985
- type: 'footer',
986
- label: reactIntl.defineMessage({
987
- id: "g4nybp",
988
- defaultMessage: [{
989
- "type": 0,
990
- "value": "Footer"
991
- }]
992
- }),
993
- theme: {
994
- callToAction: {
995
- label: {
996
- textStyle: 'cta'
997
- },
998
- boxStyle: 'cta'
999
- }
1000
- }
1001
- }]
1002
- }];
1003
-
1004
- exports.Keypad = Keypad;
1005
- exports.default = definition;