import _typeof from "@babel/runtime/helpers/esm/typeof"; import canUseDOM from "rc-util/es/Dom/canUseDom"; // ================= Transition ================= // Event wrapper. Copy from react source code function makePrefixMap(styleProp, eventName) { var prefixes = {}; prefixes[styleProp.toLowerCase()] = eventName.toLowerCase(); prefixes["Webkit".concat(styleProp)] = "webkit".concat(eventName); prefixes["Moz".concat(styleProp)] = "moz".concat(eventName); prefixes["ms".concat(styleProp)] = "MS".concat(eventName); prefixes["O".concat(styleProp)] = "o".concat(eventName.toLowerCase()); return prefixes; } export function getVendorPrefixes(domSupport, win) { var prefixes = { animationend: makePrefixMap('Animation', 'AnimationEnd'), transitionend: makePrefixMap('Transition', 'TransitionEnd') }; if (domSupport) { if (!('AnimationEvent' in win)) { delete prefixes.animationend.animation; } if (!('TransitionEvent' in win)) { delete prefixes.transitionend.transition; } } return prefixes; } var vendorPrefixes = getVendorPrefixes(canUseDOM(), typeof window !== 'undefined' ? window : {}); var style = {}; if (canUseDOM()) { var _document$createEleme = document.createElement('div'); style = _document$createEleme.style; } var prefixedEventNames = {}; export function getVendorPrefixedEventName(eventName) { if (prefixedEventNames[eventName]) { return prefixedEventNames[eventName]; } var prefixMap = vendorPrefixes[eventName]; if (prefixMap) { var stylePropList = Object.keys(prefixMap); var len = stylePropList.length; for (var i = 0; i < len; i += 1) { var styleProp = stylePropList[i]; if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) { prefixedEventNames[eventName] = prefixMap[styleProp]; return prefixedEventNames[eventName]; } } } return ''; } var internalAnimationEndName = getVendorPrefixedEventName('animationend'); var internalTransitionEndName = getVendorPrefixedEventName('transitionend'); export var supportTransition = !!(internalAnimationEndName && internalTransitionEndName); export var animationEndName = internalAnimationEndName || 'animationend'; export var transitionEndName = internalTransitionEndName || 'transitionend'; export function getTransitionName(transitionName, transitionType) { if (!transitionName) return null; if (_typeof(transitionName) === 'object') { var type = transitionType.replace(/-\w/g, function (match) { return match[1].toUpperCase(); }); return transitionName[type]; } return "".concat(transitionName, "-").concat(transitionType); }