@micromag/screen-keypad 0.3.256

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/lib/index.js ADDED
@@ -0,0 +1,772 @@
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 camelCase = require('camelcase');
11
+ var classNames = require('classnames');
12
+ var PropTypes = require('prop-types');
13
+ var React = require('react');
14
+ var core = require('@micromag/core');
15
+ var components = require('@micromag/core/components');
16
+ var contexts = require('@micromag/core/contexts');
17
+ var hooks = require('@micromag/core/hooks');
18
+ var utils = require('@micromag/core/utils');
19
+ var Background = require('@micromag/element-background');
20
+ var Button = require('@micromag/element-button');
21
+ var Container = require('@micromag/element-container');
22
+ var Heading = require('@micromag/element-heading');
23
+ var Keypad$1 = require('@micromag/element-keypad');
24
+ var Layout = require('@micromag/element-layout');
25
+ var Scroll = require('@micromag/element-scroll');
26
+ var Text = require('@micromag/element-text');
27
+ var Visual = require('@micromag/element-visual');
28
+
29
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
30
+
31
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
32
+ var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
33
+ var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
34
+ var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);
35
+ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
36
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
37
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
38
+ var Background__default = /*#__PURE__*/_interopDefaultLegacy(Background);
39
+ var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
40
+ var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
41
+ var Heading__default = /*#__PURE__*/_interopDefaultLegacy(Heading);
42
+ var Keypad__default = /*#__PURE__*/_interopDefaultLegacy(Keypad$1);
43
+ var Layout__default = /*#__PURE__*/_interopDefaultLegacy(Layout);
44
+ var Scroll__default = /*#__PURE__*/_interopDefaultLegacy(Scroll);
45
+ var Text__default = /*#__PURE__*/_interopDefaultLegacy(Text);
46
+ var Visual__default = /*#__PURE__*/_interopDefaultLegacy(Visual);
47
+
48
+ var styles = {"popupButton":"micromag-screen-keypad-popupButton","background":"micromag-screen-keypad-background","layoutLabelOver":"micromag-screen-keypad-layoutLabelOver","buttonLabel":"micromag-screen-keypad-buttonLabel","emptyButtonLabel":"micromag-screen-keypad-emptyButtonLabel","popupBackdrop":"micromag-screen-keypad-popupBackdrop","withSquareItems":"micromag-screen-keypad-withSquareItems","button":"micromag-screen-keypad-button","thumbnail":"micromag-screen-keypad-thumbnail","layoutNoLabel":"micromag-screen-keypad-layoutNoLabel","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","emptyText":"micromag-screen-keypad-emptyText","emptyTitle":"micromag-screen-keypad-emptyTitle","isPlaceholder":"micromag-screen-keypad-isPlaceholder","layout":"micromag-screen-keypad-layout","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","isPopupEmpty":"micromag-screen-keypad-isPopupEmpty","buttonPlaceholder":"micromag-screen-keypad-buttonPlaceholder","imagePlaceholder":"micromag-screen-keypad-imagePlaceholder","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","layoutLabelTop":"micromag-screen-keypad-layoutLabelTop","buttonVisual":"micromag-screen-keypad-buttonVisual"};
49
+
50
+ var placeholders = [{
51
+ id: '1'
52
+ }, {
53
+ id: '2'
54
+ }, {
55
+ id: '3'
56
+ }, {
57
+ id: '4'
58
+ }, {
59
+ id: '5'
60
+ }, {
61
+ id: '6'
62
+ }, {
63
+ id: '7'
64
+ }, {
65
+ id: '8'
66
+ }, {
67
+ id: '9'
68
+ }];
69
+ var placeholderPopupBoxStyles = {
70
+ padding: {
71
+ left: 30,
72
+ top: 30,
73
+ right: 30,
74
+ bottom: 30
75
+ }
76
+ };
77
+ var stopDragEventsPropagation = {
78
+ onTouchMove: function onTouchMove(e) {
79
+ return e.stopPropagation();
80
+ },
81
+ onTouchStart: function onTouchStart(e) {
82
+ return e.stopPropagation();
83
+ },
84
+ onTouchEnd: function onTouchEnd(e) {
85
+ return e.stopPropagation();
86
+ },
87
+ onPointerMove: function onPointerMove(e) {
88
+ return e.stopPropagation();
89
+ },
90
+ onPointerUp: function onPointerUp(e) {
91
+ return e.stopPropagation();
92
+ },
93
+ onPointerDown: function onPointerDown(e) {
94
+ return e.stopPropagation();
95
+ }
96
+ };
97
+
98
+ var mouseBlocker = _objectSpread__default["default"](_objectSpread__default["default"]({}, stopDragEventsPropagation), {}, {
99
+ onClick: function onClick(e) {
100
+ return e.stopPropagation();
101
+ },
102
+ style: {
103
+ position: 'fixed',
104
+ zIndex: '1000',
105
+ top: 0,
106
+ right: 0,
107
+ bottom: 0,
108
+ left: 0,
109
+ cursor: 'default'
110
+ }
111
+ });
112
+
113
+ var propTypes = {
114
+ items: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
115
+ id: PropTypes__default["default"].string,
116
+ heading: core.PropTypes.headingElement,
117
+ description: core.PropTypes.textElement,
118
+ visual: core.PropTypes.visualElement,
119
+ boxStyle: core.PropTypes.boxStyle
120
+ })),
121
+ layout: PropTypes__default["default"].oneOf(['top', 'middle', 'bottom']),
122
+ keypadSettings: PropTypes__default["default"].shape({
123
+ layout: PropTypes__default["default"].shape({
124
+ columnAlign: PropTypes__default["default"].oneOf(['left', 'right', 'middle']),
125
+ columns: PropTypes__default["default"].number,
126
+ spacing: PropTypes__default["default"].number,
127
+ withSquareItems: PropTypes__default["default"].bool
128
+ })
129
+ }),
130
+ buttonStyles: PropTypes__default["default"].shape({
131
+ layout: PropTypes__default["default"].string,
132
+ textStyle: core.PropTypes.textStyle,
133
+ boxStyle: core.PropTypes.boxStyle
134
+ }),
135
+ popupStyles: PropTypes__default["default"].shape({
136
+ layout: PropTypes__default["default"].oneOf(['content-top', 'content-split', 'content-bottom']),
137
+ textStyle: core.PropTypes.textStyle,
138
+ boxStyle: core.PropTypes.boxStyle
139
+ }),
140
+ background: core.PropTypes.backgroundElement,
141
+ current: PropTypes__default["default"].bool,
142
+ active: PropTypes__default["default"].bool,
143
+ className: PropTypes__default["default"].string
144
+ };
145
+ var defaultProps = {
146
+ items: null,
147
+ layout: null,
148
+ keypadSettings: null,
149
+ buttonStyles: null,
150
+ popupStyles: null,
151
+ background: null,
152
+ current: true,
153
+ active: true,
154
+ className: null
155
+ };
156
+
157
+ var KeypadScreen = function KeypadScreen(_ref) {
158
+ var _ref15;
159
+
160
+ var items = _ref.items,
161
+ layout = _ref.layout,
162
+ keypadSettings = _ref.keypadSettings,
163
+ buttonStyles = _ref.buttonStyles,
164
+ popupStyles = _ref.popupStyles,
165
+ background = _ref.background,
166
+ current = _ref.current,
167
+ active = _ref.active,
168
+ className = _ref.className;
169
+ var trackScreenEvent = hooks.useTrackScreenEvent('keypad');
170
+
171
+ var _usePlaybackContext = contexts.usePlaybackContext(),
172
+ muted = _usePlaybackContext.muted;
173
+
174
+ var mediaRef = contexts.usePlaybackMediaRef(current);
175
+
176
+ var _useScreenSize = contexts.useScreenSize(),
177
+ width = _useScreenSize.width,
178
+ height = _useScreenSize.height,
179
+ resolution = _useScreenSize.resolution; // const { topHeight: viewerTopHeight, bottomHeight: viewerBottomHeight } = useViewerContext();
180
+
181
+
182
+ var _useScreenRenderConte = contexts.useScreenRenderContext(),
183
+ isView = _useScreenRenderConte.isView,
184
+ isPreview = _useScreenRenderConte.isPreview,
185
+ isPlaceholder = _useScreenRenderConte.isPlaceholder,
186
+ isEdit = _useScreenRenderConte.isEdit;
187
+
188
+ var screenState = contexts.useScreenState();
189
+ var backgroundPlaying = current && (isView || isEdit);
190
+ var mediaShouldLoad = !isPlaceholder && (current || active);
191
+ var isInteractivePreview = isEdit && screenState === null;
192
+
193
+ var _ref2 = keypadSettings || {},
194
+ _ref2$layout = _ref2.layout,
195
+ keypadLayout = _ref2$layout === void 0 ? null : _ref2$layout;
196
+
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
+ spacing = _ref3$spacing === void 0 ? null : _ref3$spacing,
204
+ _ref3$withSquareItems = _ref3.withSquareItems,
205
+ withSquareItems = _ref3$withSquareItems === void 0 ? false : _ref3$withSquareItems;
206
+
207
+ var _ref4 = buttonStyles || {},
208
+ _ref4$layout = _ref4.layout,
209
+ buttonLayout = _ref4$layout === void 0 ? null : _ref4$layout,
210
+ _ref4$textStyle = _ref4.textStyle,
211
+ buttonTextStyle = _ref4$textStyle === void 0 ? null : _ref4$textStyle,
212
+ _ref4$boxStyle = _ref4.boxStyle,
213
+ buttonBoxStyle = _ref4$boxStyle === void 0 ? null : _ref4$boxStyle;
214
+
215
+ var _ref5 = popupStyles || {},
216
+ _ref5$layout = _ref5.layout,
217
+ popupLayout = _ref5$layout === void 0 ? null : _ref5$layout,
218
+ _ref5$backdrop = _ref5.backdrop,
219
+ popupBackdrop = _ref5$backdrop === void 0 ? null : _ref5$backdrop,
220
+ _ref5$textStyle = _ref5.textStyle,
221
+ popupTextStyle = _ref5$textStyle === void 0 ? null : _ref5$textStyle,
222
+ _ref5$boxStyle = _ref5.boxStyle,
223
+ popupBoxStyle = _ref5$boxStyle === void 0 ? null : _ref5$boxStyle;
224
+
225
+ var popupLayoutClassName = React.useMemo(function () {
226
+ return popupLayout !== null ? camelCase__default["default"](popupLayout) : '';
227
+ }, [popupLayout]);
228
+
229
+ var _useState = React.useState(false),
230
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
231
+ showPopup = _useState2[0],
232
+ setShowPopup = _useState2[1];
233
+
234
+ var _useState3 = React.useState(null),
235
+ _useState4 = _slicedToArray__default["default"](_useState3, 2),
236
+ popup = _useState4[0],
237
+ setPopup = _useState4[1];
238
+
239
+ var _ref6 = popup || {},
240
+ _ref6$heading = _ref6.heading,
241
+ popupHeading = _ref6$heading === void 0 ? null : _ref6$heading,
242
+ _ref6$content = _ref6.content,
243
+ popupContent = _ref6$content === void 0 ? null : _ref6$content,
244
+ _ref6$largeVisual = _ref6.largeVisual,
245
+ largeVisual = _ref6$largeVisual === void 0 ? null : _ref6$largeVisual;
246
+
247
+ var _ref7 = popupHeading || {},
248
+ _ref7$body = _ref7.body,
249
+ popupHeadingBody = _ref7$body === void 0 ? null : _ref7$body;
250
+
251
+ var _ref8 = popupContent || {},
252
+ _ref8$body = _ref8.body,
253
+ popupContentBody = _ref8$body === void 0 ? null : _ref8$body;
254
+
255
+ var onItemClick = React.useCallback(function (e, item) {
256
+ e.stopPropagation();
257
+ setPopup(item);
258
+ setShowPopup(1);
259
+ trackScreenEvent('click_item', item);
260
+ }, [setPopup, trackScreenEvent]);
261
+ var onCloseModal = React.useCallback(function () {
262
+ setShowPopup(0);
263
+ trackScreenEvent('close_modal');
264
+ }, [setShowPopup]);
265
+ var computePopupProgress = React.useCallback(function (_ref9) {
266
+ var dragActive = _ref9.active,
267
+ _ref9$movement = _slicedToArray__default["default"](_ref9.movement, 2),
268
+ my = _ref9$movement[1],
269
+ _ref9$velocity = _slicedToArray__default["default"](_ref9.velocity, 2),
270
+ vy = _ref9$velocity[1];
271
+
272
+ var damper = 0.5;
273
+ var p = Math.max(0, my) / window.innerHeight;
274
+ var progress = p * damper;
275
+ var reachedThreshold = vy > 0.3 || Math.abs(p) > 0.3;
276
+
277
+ if (!dragActive) {
278
+ if (reachedThreshold) {
279
+ onCloseModal();
280
+ }
281
+
282
+ return reachedThreshold ? 0 : 1;
283
+ }
284
+
285
+ return 1 - progress;
286
+ }, [onCloseModal]);
287
+
288
+ var _useDragProgress = hooks.useDragProgress({
289
+ disabled: !isView,
290
+ progress: showPopup ? 1 : 0,
291
+ computeProgress: computePopupProgress,
292
+ springParams: {
293
+ config: {
294
+ tension: 300,
295
+ friction: 30
296
+ }
297
+ }
298
+ }),
299
+ bindPopupDrag = _useDragProgress.bind,
300
+ popupSpring = _useDragProgress.progress;
301
+
302
+ var gridItems = React.useMemo(function () {
303
+ return (items === null || items.length === 0 ? placeholders : items).map(function (item) {
304
+ var _ref14;
305
+
306
+ var _ref10 = item || {},
307
+ _ref10$id = _ref10.id,
308
+ id = _ref10$id === void 0 ? null : _ref10$id,
309
+ _ref10$label = _ref10.label,
310
+ label = _ref10$label === void 0 ? null : _ref10$label,
311
+ _ref10$visual = _ref10.visual,
312
+ visual = _ref10$visual === void 0 ? null : _ref10$visual,
313
+ _ref10$textStyle = _ref10.textStyle,
314
+ textStyle = _ref10$textStyle === void 0 ? null : _ref10$textStyle,
315
+ _ref10$boxStyle = _ref10.boxStyle,
316
+ boxStyle = _ref10$boxStyle === void 0 ? null : _ref10$boxStyle,
317
+ _ref10$heading = _ref10.heading,
318
+ heading = _ref10$heading === void 0 ? null : _ref10$heading,
319
+ _ref10$content = _ref10.content,
320
+ content = _ref10$content === void 0 ? null : _ref10$content,
321
+ _ref10$largeVisual = _ref10.largeVisual,
322
+ popupLargeVisual = _ref10$largeVisual === void 0 ? null : _ref10$largeVisual;
323
+
324
+ var _ref11 = visual || {},
325
+ _ref11$url = _ref11.url,
326
+ visualUrl = _ref11$url === void 0 ? null : _ref11$url;
327
+
328
+ var _ref12 = heading || {},
329
+ _ref12$body = _ref12.body,
330
+ headingBody = _ref12$body === void 0 ? null : _ref12$body;
331
+
332
+ var _ref13 = content || {},
333
+ _ref13$body = _ref13.body,
334
+ contentBody = _ref13$body === void 0 ? null : _ref13$body;
335
+
336
+ var key = label || visualUrl || id;
337
+ var isEmpty = label === null && visual === null;
338
+ var isPopupEmpty = (heading === null || headingBody === '') && (content === null || contentBody === '') && popupLargeVisual === null;
339
+ return /*#__PURE__*/React__default["default"].createElement("div", {
340
+ key: key,
341
+ className: styles.item
342
+ }, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
343
+ className: classNames__default["default"]([styles.button, (_ref14 = {}, _defineProperty__default["default"](_ref14, styles.layoutLabelBottom, buttonLayout === 'label-bottom'), _defineProperty__default["default"](_ref14, styles.layoutLabelTop, buttonLayout === 'label-top'), _defineProperty__default["default"](_ref14, styles.layoutNoLabel, buttonLayout === 'no-label'), _defineProperty__default["default"](_ref14, styles.layoutLabelOver, buttonLayout === 'label-over'), _defineProperty__default["default"](_ref14, styles.isEmpty, isEmpty), _defineProperty__default["default"](_ref14, styles.isPopupEmpty, isPopupEmpty), _ref14)]),
344
+ style: _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromBox(buttonBoxStyle)), utils.getStyleFromText(buttonTextStyle)), utils.getStyleFromBox(boxStyle)), utils.getStyleFromText(textStyle)),
345
+ onClick: !isPopupEmpty ? function (e) {
346
+ return onItemClick(e, item);
347
+ } : function (e) {
348
+ return e.preventDefault();
349
+ }
350
+ }, isEmpty && (isInteractivePreview || isPreview) ? /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(components.PlaceholderImage, {
351
+ className: styles.imagePlaceholder
352
+ }), /*#__PURE__*/React__default["default"].createElement(components.PlaceholderText, {
353
+ lines: 2
354
+ })) : /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, visual !== null || !isInteractivePreview ? /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
355
+ emptyLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
356
+ id: "Qanvis",
357
+ defaultMessage: [{
358
+ "type": 0,
359
+ "value": "Visual"
360
+ }]
361
+ }),
362
+ emptyClassName: classNames__default["default"]([styles.empty, styles.buttonVisual, styles.emptyButtonVisual]),
363
+ isEmpty: visual === null
364
+ }, /*#__PURE__*/React__default["default"].createElement(Visual__default["default"], {
365
+ className: styles.buttonVisual,
366
+ imageClassName: styles.thumbnail,
367
+ media: visual,
368
+ width: "auto"
369
+ })) : null, label !== null || !isInteractivePreview ? /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
370
+ placeholder: /*#__PURE__*/React__default["default"].createElement(components.PlaceholderButton, null),
371
+ emptyLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
372
+ id: "Zbu5Uk",
373
+ defaultMessage: [{
374
+ "type": 0,
375
+ "value": "Label"
376
+ }]
377
+ }),
378
+ emptyClassName: classNames__default["default"]([styles.empty, styles.emptyButtonLabel]),
379
+ isEmpty: label === null
380
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
381
+ className: styles.buttonLabel
382
+ }, label)) : null)));
383
+ });
384
+ }, [items, screenState, keypadSettings]);
385
+ React.useEffect(function () {
386
+ if (screenState === 'popup') {
387
+ setPopup(placeholderPopupBoxStyles); // @note force placeholder
388
+
389
+ setShowPopup(1);
390
+ }
391
+
392
+ if (screenState === 'keypad') {
393
+ setPopup(null);
394
+ setShowPopup(0);
395
+ }
396
+
397
+ if (screenState !== null && screenState.includes('popups')) {
398
+ var index = screenState.split('.').pop();
399
+ var found = items[index];
400
+ setShowPopup(1);
401
+ setPopup(found);
402
+ }
403
+
404
+ if (screenState === null) {
405
+ setShowPopup(0);
406
+ setPopup(null);
407
+ }
408
+ }, [screenState, items]);
409
+ return /*#__PURE__*/React__default["default"].createElement("div", {
410
+ className: classNames__default["default"]([styles.container, (_ref15 = {}, _defineProperty__default["default"](_ref15, className, className !== null), _defineProperty__default["default"](_ref15, styles.isPlaceholder, isPlaceholder), _defineProperty__default["default"](_ref15, styles.withSquareItems, withSquareItems), _ref15)]),
411
+ "data-screen-ready": true
412
+ }, isEdit && screenState !== null ? /*#__PURE__*/React__default["default"].createElement("div", mouseBlocker) : null, !isPlaceholder ? /*#__PURE__*/React__default["default"].createElement(Background__default["default"], {
413
+ background: background,
414
+ width: width,
415
+ height: height,
416
+ resolution: resolution,
417
+ playing: backgroundPlaying,
418
+ muted: muted,
419
+ shouldLoad: mediaShouldLoad,
420
+ mediaRef: mediaRef,
421
+ className: styles.background
422
+ }) : null, /*#__PURE__*/React__default["default"].createElement(Container__default["default"], {
423
+ width: width,
424
+ height: height,
425
+ className: styles.inner
426
+ }, /*#__PURE__*/React__default["default"].createElement(Layout__default["default"], {
427
+ className: styles.layout,
428
+ verticalAlign: layout // style={
429
+ // !isPlaceholder
430
+ // ? {
431
+ // padding: spacing,
432
+ // paddingTop: (!isPreview ? viewerTopHeight : 0) + spacing,
433
+ // paddingBottom:
434
+ // (current && !isPreview ? viewerBottomHeight : 0) + spacing,
435
+ // }
436
+ // : null
437
+ // }
438
+
439
+ }, /*#__PURE__*/React__default["default"].createElement(Keypad__default["default"], {
440
+ className: classNames__default["default"]([styles.grid, _defineProperty__default["default"]({}, styles.gridPlaceholder, isPlaceholder)]),
441
+ align: columnAlign,
442
+ columns: isPlaceholder ? 3 : columns,
443
+ spacing: isPlaceholder ? 2 : spacing,
444
+ items: gridItems
445
+ })), /*#__PURE__*/React__default["default"].createElement(web.animated.div, {
446
+ className: classNames__default["default"]([styles.popupBackdrop]),
447
+ style: _objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromColor(popupBackdrop)), {}, {
448
+ opacity: popupSpring.to(function (p) {
449
+ return p;
450
+ })
451
+ })
452
+ }), /*#__PURE__*/React__default["default"].createElement(web.animated.div, Object.assign({
453
+ className: styles.popup,
454
+ style: {
455
+ transform: popupSpring.to(function (p) {
456
+ return "translateY(".concat(100 * (1 - (p < 0.2 ? 0.1 * p + p : p)), "%)");
457
+ }),
458
+ pointerEvents: popupSpring.to(function (p) {
459
+ return p < 0.1 ? 'none' : 'auto';
460
+ })
461
+ }
462
+ }, bindPopupDrag()), /*#__PURE__*/React__default["default"].createElement(Scroll__default["default"], null, /*#__PURE__*/React__default["default"].createElement("button", {
463
+ type: "button",
464
+ className: styles.popupButton,
465
+ onClick: function onClick() {
466
+ if (onCloseModal !== null) {
467
+ onCloseModal();
468
+ }
469
+ }
470
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
471
+ className: classNames__default["default"]([styles.popupInner, styles[popupLayoutClassName]]),
472
+ style: _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, utils.getStyleFromBox(placeholderPopupBoxStyles)), utils.getStyleFromBox(popupBoxStyle)), utils.getStyleFromText(popupTextStyle))
473
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
474
+ className: styles.popupWrapper
475
+ }, !isInteractivePreview || popupHeading !== null ? /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
476
+ placeholder: "popupHeading",
477
+ emptyLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
478
+ id: "IE7U/Q",
479
+ defaultMessage: [{
480
+ "type": 0,
481
+ "value": "Heading"
482
+ }]
483
+ }),
484
+ emptyClassName: classNames__default["default"]([styles.empty, styles.emptyHeading]),
485
+ isEmpty: (popupHeading === null || popupHeadingBody === '') && screenState !== 'popup'
486
+ }, /*#__PURE__*/React__default["default"].createElement(Heading__default["default"], Object.assign({
487
+ className: styles.popupHeading,
488
+ body: "Lorem ipsum"
489
+ }, popupHeading))) : null, !isInteractivePreview || popupContent !== null ? /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
490
+ placeholder: "popupContent",
491
+ emptyLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
492
+ id: "JRZoe6",
493
+ defaultMessage: [{
494
+ "type": 0,
495
+ "value": "Content"
496
+ }]
497
+ }),
498
+ emptyClassName: classNames__default["default"]([styles.empty, styles.emptyContent]),
499
+ isEmpty: (popupContent === null || popupContentBody === '') && popupContent === null && screenState !== 'popup'
500
+ }, /*#__PURE__*/React__default["default"].createElement(Text__default["default"], Object.assign({
501
+ className: styles.popupContent,
502
+ body: "Lorem ipsum dolor sit amet consectetur adipiscing elit."
503
+ }, popupContent))) : null, !isInteractivePreview || largeVisual !== null ? /*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
504
+ placeholder: "popupVisual",
505
+ emptyLabel: /*#__PURE__*/React__default["default"].createElement(reactIntl.FormattedMessage, {
506
+ id: "z4Pr+g",
507
+ defaultMessage: [{
508
+ "type": 0,
509
+ "value": "Visual (Image or Video)"
510
+ }]
511
+ }),
512
+ emptyClassName: classNames__default["default"]([styles.empty, styles.emptyVisual]),
513
+ isEmpty: largeVisual === null
514
+ }, /*#__PURE__*/React__default["default"].createElement(Visual__default["default"], {
515
+ className: styles.popupVisual,
516
+ media: largeVisual,
517
+ width: "100%"
518
+ })) : null, largeVisual === null && isPreview ? /*#__PURE__*/React__default["default"].createElement(components.PlaceholderImage, {
519
+ className: styles.popupVisual
520
+ }) : null)))))));
521
+ };
522
+
523
+ KeypadScreen.propTypes = propTypes;
524
+ KeypadScreen.defaultProps = defaultProps;
525
+ var Keypad = /*#__PURE__*/React__default["default"].memo(KeypadScreen);
526
+
527
+ var definition = [{
528
+ id: 'keypad',
529
+ type: 'screen',
530
+ group: {
531
+ label: reactIntl.defineMessage({
532
+ id: "cGItoy",
533
+ defaultMessage: [{
534
+ "type": 0,
535
+ "value": "List"
536
+ }]
537
+ }),
538
+ order: 4
539
+ },
540
+ title: reactIntl.defineMessage({
541
+ id: "75nZbY",
542
+ defaultMessage: [{
543
+ "type": 0,
544
+ "value": "Keypad"
545
+ }]
546
+ }),
547
+ layouts: ['top', 'middle', 'bottom'],
548
+ component: Keypad,
549
+ states: [{
550
+ id: 'keypad',
551
+ label: reactIntl.defineMessage({
552
+ id: "Z4f5qh",
553
+ defaultMessage: [{
554
+ "type": 0,
555
+ "value": "Buttons"
556
+ }]
557
+ }),
558
+ fields: [{
559
+ name: 'items',
560
+ type: 'buttons',
561
+ label: reactIntl.defineMessage({
562
+ id: "fbUW2U",
563
+ defaultMessage: [{
564
+ "type": 0,
565
+ "value": "Items"
566
+ }]
567
+ }),
568
+ theme: {
569
+ label: {
570
+ textStyle: 'button'
571
+ }
572
+ },
573
+ isSection: true
574
+ }, {
575
+ name: 'buttonStyles',
576
+ type: 'fields',
577
+ defaultValue: {
578
+ layout: 'label-bottom',
579
+ boxStyle: {
580
+ backgroundColor: {
581
+ alpha: 0.15,
582
+ color: '#000000'
583
+ }
584
+ }
585
+ },
586
+ isList: true,
587
+ fields: [{
588
+ name: 'layout',
589
+ type: 'button-layout',
590
+ isHorizontal: true,
591
+ label: reactIntl.defineMessage({
592
+ id: "OPxJx/",
593
+ defaultMessage: [{
594
+ "type": 0,
595
+ "value": "Layout"
596
+ }]
597
+ })
598
+ }, {
599
+ name: 'textStyle',
600
+ type: 'text-style-form',
601
+ label: reactIntl.defineMessage({
602
+ id: "rzXCu2",
603
+ defaultMessage: [{
604
+ "type": 0,
605
+ "value": "Label style"
606
+ }]
607
+ })
608
+ }, {
609
+ name: 'boxStyle',
610
+ type: 'box-style-form',
611
+ label: reactIntl.defineMessage({
612
+ id: "nno1Pq",
613
+ defaultMessage: [{
614
+ "type": 0,
615
+ "value": "Button style"
616
+ }]
617
+ })
618
+ }]
619
+ }]
620
+ }, {
621
+ id: 'popup',
622
+ label: reactIntl.defineMessage({
623
+ id: "mBYGpP",
624
+ defaultMessage: [{
625
+ "type": 0,
626
+ "value": "Popup"
627
+ }]
628
+ }),
629
+ fields: [{
630
+ name: 'popupStyles',
631
+ type: 'fields',
632
+ defaultValue: {
633
+ layout: 'content-top'
634
+ },
635
+ isList: true,
636
+ fields: [{
637
+ name: 'layout',
638
+ type: 'card-layout',
639
+ // defaultValue: 'content-top',
640
+ label: reactIntl.defineMessage({
641
+ id: "OPxJx/",
642
+ defaultMessage: [{
643
+ "type": 0,
644
+ "value": "Layout"
645
+ }]
646
+ })
647
+ }, {
648
+ name: 'textStyle',
649
+ type: 'text-style-form',
650
+ label: reactIntl.defineMessage({
651
+ id: "OEckOD",
652
+ defaultMessage: [{
653
+ "type": 0,
654
+ "value": "Text style"
655
+ }]
656
+ })
657
+ }, {
658
+ name: 'boxStyle',
659
+ type: 'box-style-form',
660
+ label: reactIntl.defineMessage({
661
+ id: "heeSlL",
662
+ defaultMessage: [{
663
+ "type": 0,
664
+ "value": "Frame and backgound styles"
665
+ }]
666
+ })
667
+ }, {
668
+ name: 'backdrop',
669
+ type: 'color',
670
+ label: reactIntl.defineMessage({
671
+ id: "uv3PH4",
672
+ defaultMessage: [{
673
+ "type": 0,
674
+ "value": "Backdrop color"
675
+ }]
676
+ })
677
+ }]
678
+ }]
679
+ }, {
680
+ id: 'popups',
681
+ label: reactIntl.defineMessage({
682
+ id: "Hyqnww",
683
+ defaultMessage: [{
684
+ "type": 0,
685
+ "value": "Popups"
686
+ }]
687
+ }),
688
+ defaultValue: [],
689
+ repeatable: true,
690
+ fieldName: 'items',
691
+ fields: [{
692
+ name: 'heading',
693
+ type: 'heading-element',
694
+ label: reactIntl.defineMessage({
695
+ id: "6iR9Mt",
696
+ defaultMessage: [{
697
+ "type": 0,
698
+ "value": "Heading"
699
+ }]
700
+ })
701
+ }, {
702
+ name: 'content',
703
+ type: 'text-element',
704
+ label: reactIntl.defineMessage({
705
+ id: "uoF5Pv",
706
+ defaultMessage: [{
707
+ "type": 0,
708
+ "value": "Content"
709
+ }]
710
+ })
711
+ }, {
712
+ name: 'largeVisual',
713
+ type: 'visual',
714
+ label: reactIntl.defineMessage({
715
+ id: "HwqzVR",
716
+ defaultMessage: [{
717
+ "type": 0,
718
+ "value": "Visual"
719
+ }]
720
+ })
721
+ }]
722
+ }],
723
+ fields: [{
724
+ name: 'layout',
725
+ type: 'screen-layout',
726
+ defaultValue: 'middle',
727
+ label: reactIntl.defineMessage({
728
+ id: "4iBXj2",
729
+ defaultMessage: [{
730
+ "type": 0,
731
+ "value": "Layout"
732
+ }]
733
+ })
734
+ }, {
735
+ name: 'keypadSettings',
736
+ type: 'fields',
737
+ isList: true,
738
+ withoutLabel: true,
739
+ defaultValue: {
740
+ layout: {
741
+ columnAlign: 'middle',
742
+ columns: 3,
743
+ spacing: 2,
744
+ withSquareItems: false
745
+ }
746
+ },
747
+ label: reactIntl.defineMessage({
748
+ id: "FjuRaw",
749
+ defaultMessage: [{
750
+ "type": 0,
751
+ "value": "Keypad settings"
752
+ }]
753
+ }),
754
+ fields: [{
755
+ name: 'layout',
756
+ type: 'keypad-layout-form'
757
+ }]
758
+ }, {
759
+ name: 'background',
760
+ type: 'background',
761
+ label: reactIntl.defineMessage({
762
+ id: "+MPZRu",
763
+ defaultMessage: [{
764
+ "type": 0,
765
+ "value": "Background"
766
+ }]
767
+ })
768
+ }]
769
+ }];
770
+
771
+ exports.Keypad = Keypad;
772
+ exports["default"] = definition;