@micromag/screen-keypad 0.4.52 → 0.4.54
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 +32 -21
- package/package.json +18 -18
package/es/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { animated } from '@react-spring/web';
|
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import isEmpty from 'lodash/isEmpty';
|
|
8
8
|
import isString from 'lodash/isString';
|
|
9
|
-
import { useRef,
|
|
9
|
+
import { useRef, useState, useMemo, useCallback, useEffect } from 'react';
|
|
10
10
|
import { Close, ScreenElement } from '@micromag/core/components';
|
|
11
11
|
import { usePlaybackContext, usePlaybackMediaRef, useScreenState, useScreenSize, useViewerContext, useViewerWebView, useViewerInteraction, useScreenRenderContext } from '@micromag/core/contexts';
|
|
12
12
|
import { useTrackScreenEvent, useDimensionObserver, useDragProgress } from '@micromag/core/hooks';
|
|
@@ -134,6 +134,10 @@ function KeypadScreen(_ref) {
|
|
|
134
134
|
footerRef = _useDimensionObserver3.ref,
|
|
135
135
|
_useDimensionObserver4 = _useDimensionObserver3.height,
|
|
136
136
|
footerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
|
|
137
|
+
var _useState = useState(false),
|
|
138
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
139
|
+
popupDragDisabled = _useState2[0],
|
|
140
|
+
setPopupDragDisabled = _useState2[1];
|
|
137
141
|
var backgroundPlaying = current && (isView || isEdit) && (isCurrentMedia || !isView);
|
|
138
142
|
var mediaShouldLoad = !isPlaceholder && (current || preload);
|
|
139
143
|
var isInteractivePreview = isEdit && screenState === null;
|
|
@@ -177,14 +181,14 @@ function KeypadScreen(_ref) {
|
|
|
177
181
|
var popupLayoutClassName = useMemo(function () {
|
|
178
182
|
return popupLayout !== null ? camelCase(popupLayout) : '';
|
|
179
183
|
}, [popupLayout]);
|
|
180
|
-
var
|
|
181
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
182
|
-
showPopup = _useState2[0],
|
|
183
|
-
setShowPopup = _useState2[1];
|
|
184
|
-
var _useState3 = useState(null),
|
|
184
|
+
var _useState3 = useState(false),
|
|
185
185
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
showPopup = _useState4[0],
|
|
187
|
+
setShowPopup = _useState4[1];
|
|
188
|
+
var _useState5 = useState(null),
|
|
189
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
190
|
+
popup = _useState6[0],
|
|
191
|
+
setPopup = _useState6[1];
|
|
188
192
|
var _ref7 = popup || {},
|
|
189
193
|
_ref7$heading = _ref7.heading,
|
|
190
194
|
popupHeading = _ref7$heading === void 0 ? null : _ref7$heading,
|
|
@@ -271,10 +275,10 @@ function KeypadScreen(_ref) {
|
|
|
271
275
|
e.stopPropagation();
|
|
272
276
|
}
|
|
273
277
|
}, []);
|
|
274
|
-
var
|
|
275
|
-
|
|
276
|
-
popupDragDirection =
|
|
277
|
-
setPopupDragDirection =
|
|
278
|
+
var _useState7 = useState(null),
|
|
279
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
280
|
+
popupDragDirection = _useState8[0],
|
|
281
|
+
setPopupDragDirection = _useState8[1];
|
|
278
282
|
var onPopupScrollHeightChange = useCallback(function (_ref11) {
|
|
279
283
|
var _ref11$scrolleeHeight = _ref11.scrolleeHeight,
|
|
280
284
|
scrolleeHeight = _ref11$scrolleeHeight === void 0 ? 0 : _ref11$scrolleeHeight;
|
|
@@ -329,10 +333,6 @@ function KeypadScreen(_ref) {
|
|
|
329
333
|
document.removeEventListener('mouseup', handleClickOutside);
|
|
330
334
|
};
|
|
331
335
|
}, [current, popupInnerRef, containerRef, isInteractivePreview, isEdit, showPopup]);
|
|
332
|
-
var _useState7 = useState(false),
|
|
333
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
334
|
-
popupDragDisabled = _useState8[0],
|
|
335
|
-
setPopupDragDisabled = _useState8[1];
|
|
336
336
|
var onPopupScrollBottom = useCallback(function () {
|
|
337
337
|
setPopupDragDisabled(false);
|
|
338
338
|
}, [setPopupDragDisabled]);
|
|
@@ -351,10 +351,12 @@ function KeypadScreen(_ref) {
|
|
|
351
351
|
var onTap = useCallback(function () {
|
|
352
352
|
onCloseModal(showPopup);
|
|
353
353
|
}, [onCloseModal, showPopup]);
|
|
354
|
+
var onResolve = useCallback(function () {}, []);
|
|
354
355
|
var _useDragProgress = useDragProgress({
|
|
355
356
|
disabled: !isView || popupDragDisabled,
|
|
356
357
|
progress: showPopup ? 0 : 1,
|
|
357
358
|
computeProgress: computePopupProgress,
|
|
359
|
+
onResolve: onResolve,
|
|
358
360
|
springParams: {
|
|
359
361
|
config: {
|
|
360
362
|
tension: 300,
|
|
@@ -369,7 +371,15 @@ function KeypadScreen(_ref) {
|
|
|
369
371
|
onTap: onTap
|
|
370
372
|
}),
|
|
371
373
|
bindPopupDrag = _useDragProgress.bind,
|
|
372
|
-
popupSpring = _useDragProgress.progress
|
|
374
|
+
popupSpring = _useDragProgress.progress,
|
|
375
|
+
popupTransitioning = _useDragProgress.transitioning;
|
|
376
|
+
|
|
377
|
+
// Clear popup
|
|
378
|
+
useEffect(function () {
|
|
379
|
+
if (!showPopup && !popupTransitioning && popup !== null) {
|
|
380
|
+
setPopup(null);
|
|
381
|
+
}
|
|
382
|
+
}, [showPopup, popupTransitioning, popup]);
|
|
373
383
|
useEffect(function () {
|
|
374
384
|
var keyup = function keyup(e) {
|
|
375
385
|
if (e.key === 'Escape') {
|
|
@@ -462,17 +472,17 @@ function KeypadScreen(_ref) {
|
|
|
462
472
|
setPopup(null);
|
|
463
473
|
setShowPopup(false);
|
|
464
474
|
}
|
|
465
|
-
if (screenState
|
|
475
|
+
if (screenState != null && screenState.includes('popup')) {
|
|
466
476
|
var index = screenState.split('.').pop();
|
|
467
477
|
var found = items[index];
|
|
468
478
|
setPopup(found);
|
|
469
479
|
setShowPopup(true);
|
|
470
480
|
}
|
|
471
|
-
if (screenState
|
|
481
|
+
if (screenState == null && !isView) {
|
|
472
482
|
setPopup(null);
|
|
473
483
|
setShowPopup(false);
|
|
474
484
|
}
|
|
475
|
-
}, [screenState, items, isView
|
|
485
|
+
}, [screenState, items, isView]);
|
|
476
486
|
return /*#__PURE__*/jsxs("div", {
|
|
477
487
|
ref: containerRef,
|
|
478
488
|
className: classNames([styles.container, className, _defineProperty(_defineProperty({}, styles.isPlaceholder, isPlaceholder), styles.withSquareItems, withSquareItems)]),
|
|
@@ -519,7 +529,8 @@ function KeypadScreen(_ref) {
|
|
|
519
529
|
verticalAlign: layout,
|
|
520
530
|
width: width,
|
|
521
531
|
style: !isPlaceholder ? {
|
|
522
|
-
|
|
532
|
+
paddingLeft: spacing,
|
|
533
|
+
paddingRight: spacing,
|
|
523
534
|
paddingTop: (hasHeader ? headerHeight : spacing) + (current && !isPreview ? viewerTopHeight : 0),
|
|
524
535
|
paddingBottom: (hasFooter ? footerHeight : spacing) + (current && !isPreview ? viewerBottomHeight : 0)
|
|
525
536
|
} : null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-keypad",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.54",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -66,22 +66,22 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@babel/runtime": "^7.28.6",
|
|
69
|
-
"@micromag/core": "^0.4.
|
|
70
|
-
"@micromag/element-background": "^0.4.
|
|
71
|
-
"@micromag/element-button": "^0.4.
|
|
72
|
-
"@micromag/element-call-to-action": "^0.4.
|
|
73
|
-
"@micromag/element-container": "^0.4.
|
|
74
|
-
"@micromag/element-footer": "^0.4.
|
|
75
|
-
"@micromag/element-grid": "^0.4.
|
|
76
|
-
"@micromag/element-header": "^0.4.
|
|
77
|
-
"@micromag/element-heading": "^0.4.
|
|
78
|
-
"@micromag/element-keypad": "^0.4.
|
|
79
|
-
"@micromag/element-layout": "^0.4.
|
|
80
|
-
"@micromag/element-scroll": "^0.4.
|
|
81
|
-
"@micromag/element-text": "^0.4.
|
|
82
|
-
"@micromag/element-urbania-author": "^0.4.
|
|
83
|
-
"@micromag/element-visual": "^0.4.
|
|
84
|
-
"@micromag/transforms": "^0.4.
|
|
69
|
+
"@micromag/core": "^0.4.54",
|
|
70
|
+
"@micromag/element-background": "^0.4.54",
|
|
71
|
+
"@micromag/element-button": "^0.4.54",
|
|
72
|
+
"@micromag/element-call-to-action": "^0.4.54",
|
|
73
|
+
"@micromag/element-container": "^0.4.54",
|
|
74
|
+
"@micromag/element-footer": "^0.4.54",
|
|
75
|
+
"@micromag/element-grid": "^0.4.54",
|
|
76
|
+
"@micromag/element-header": "^0.4.54",
|
|
77
|
+
"@micromag/element-heading": "^0.4.54",
|
|
78
|
+
"@micromag/element-keypad": "^0.4.54",
|
|
79
|
+
"@micromag/element-layout": "^0.4.54",
|
|
80
|
+
"@micromag/element-scroll": "^0.4.54",
|
|
81
|
+
"@micromag/element-text": "^0.4.54",
|
|
82
|
+
"@micromag/element-urbania-author": "^0.4.54",
|
|
83
|
+
"@micromag/element-visual": "^0.4.54",
|
|
84
|
+
"@micromag/transforms": "^0.4.54",
|
|
85
85
|
"@react-spring/core": "^10.0.3",
|
|
86
86
|
"@react-spring/web": "^10.0.3",
|
|
87
87
|
"@use-gesture/react": "^10.3.0",
|
|
@@ -94,6 +94,6 @@
|
|
|
94
94
|
"access": "public",
|
|
95
95
|
"registry": "https://registry.npmjs.org/"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "b7aacdebb4a5c2179a58d21ab2aaea5bcdc43d69",
|
|
98
98
|
"types": "es/index.d.ts"
|
|
99
99
|
}
|