@shopgate/pwa-ui-shared 7.29.1-beta.1 → 7.30.0-alpha.2
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.
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
function
|
|
2
|
-
* The
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import React,{useEffect,useRef,useMemo}from'react';import PropTypes from'prop-types';import{Transition}from'react-transition-group';import{themeConfig}from'@shopgate/pwa-common/helpers/config';import style from"../../style";/**
|
|
2
|
+
* The RippleAnimation component
|
|
3
|
+
*
|
|
4
|
+
* Plays a one-shot ripple animation and calls `onComplete` when finished.
|
|
5
|
+
* @param {Object} props The component props.
|
|
6
|
+
* @param {string} props.color The ripple color.
|
|
7
|
+
* @param {number} props.duration The animation duration in milliseconds.
|
|
8
|
+
* @param {Function} props.onComplete The callback to be called when the animation is complete.
|
|
9
|
+
* @param {number} props.size The size of the ripple in pixels.
|
|
10
|
+
* @param {number} props.x The x coordinate of the ripple center.
|
|
11
|
+
* @param {number} props.y The y coordinate of the ripple center.
|
|
12
|
+
* @returns {JSX.Element}
|
|
13
|
+
*/function RippleAnimation(_ref){var color=_ref.color,duration=_ref.duration,onComplete=_ref.onComplete,size=_ref.size,x=_ref.x,y=_ref.y;var nodeRef=useRef(null);// Trigger the animation immediately
|
|
14
|
+
var inProp=true;var baseStyle=useMemo(function(){return{position:'absolute',backgroundColor:color,height:size,width:size,left:x,top:y,borderRadius:'50%',transform:'translate3d(-50%, -50%, 0) scale3d(0, 0, 1)',opacity:0.25,transition:"opacity ".concat(duration,"ms cubic-bezier(0.25, 0.1, 0.25, 1), transform ").concat(duration,"ms cubic-bezier(0.25, 0.1, 0.25, 1)"),pointerEvents:'none'};},[color,duration,size,x,y]);var transitionStyles=useMemo(function(){return{entering:{transform:'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)',opacity:0},entered:{transform:'translate3d(-50%, -50%, 0) scale3d(1, 1, 1)',opacity:0},exiting:{},exited:{},unmounted:{}};},[]);// Run callback when transition ends
|
|
15
|
+
useEffect(function(){var el=nodeRef.current;if(!el)return undefined;/**
|
|
16
|
+
* Handles the transition end event and calls onComplete for relevant properties.
|
|
17
|
+
* @param {TransitionEvent} e - The transition event object
|
|
18
|
+
*/var handleEnd=function handleEnd(e){// Only handle transform or opacity transitions
|
|
19
|
+
if(e.propertyName==='transform'||e.propertyName==='opacity'){onComplete();}};el.addEventListener('transitionend',handleEnd);return function(){return el.removeEventListener('transitionend',handleEnd);};},[onComplete]);return React.createElement(Transition,{"in":inProp,timeout:duration,appear:true,mountOnEnter:true,unmountOnExit:true,nodeRef:nodeRef},function(state){return React.createElement("div",{ref:nodeRef,className:style.ripple,style:_extends({},baseStyle,{},transitionStyles[state])});});}RippleAnimation.defaultProps={color:themeConfig.colors.dark,duration:300,onComplete:function onComplete(){},size:48,x:0,y:0};export default React.memo(RippleAnimation);
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopgate/pwa-ui-shared",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.30.0-alpha.2",
|
|
4
4
|
"description": "Shopgate's shared UI components.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@shopgate/pwa-ui-ios": "7.
|
|
9
|
-
"@shopgate/pwa-ui-material": "7.
|
|
8
|
+
"@shopgate/pwa-ui-ios": "7.30.0-alpha.2",
|
|
9
|
+
"@shopgate/pwa-ui-material": "7.30.0-alpha.2",
|
|
10
10
|
"react-day-picker": "^7.4.8"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@shopgate/pwa-common": "7.
|
|
14
|
-
"@shopgate/pwa-common-commerce": "7.
|
|
13
|
+
"@shopgate/pwa-common": "7.30.0-alpha.2",
|
|
14
|
+
"@shopgate/pwa-common-commerce": "7.30.0-alpha.2",
|
|
15
15
|
"classnames": "2.5.1",
|
|
16
16
|
"react": "~16.14.0"
|
|
17
17
|
},
|