1 line
6.5 KiB
JSON
1 line
6.5 KiB
JSON
|
{"ast":null,"code":"import React, { useContext, useRef } from 'react';\nimport classNames from 'classnames';\nimport isVisible from \"rc-util/es/Dom/isVisible\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport { ConfigContext } from '../../config-provider';\nimport { cloneElement } from '../reactNode';\nimport useStyle from './style';\nimport useWave from './useWave';\nconst Wave = props => {\n const {\n children,\n disabled,\n component\n } = props;\n const {\n getPrefixCls\n } = useContext(ConfigContext);\n const containerRef = useRef(null);\n // ============================== Style ===============================\n const prefixCls = getPrefixCls('wave');\n const [, hashId] = useStyle(prefixCls);\n // =============================== Wave ===============================\n const showWave = useWave(containerRef, classNames(prefixCls, hashId), component);\n // ============================== Effect ==============================\n React.useEffect(() => {\n const node = containerRef.current;\n if (!node || node.nodeType !== 1 || disabled) {\n return;\n }\n // Click handler\n const onClick = e => {\n // Fix radio button click twice\n if (!isVisible(e.target) ||\n // No need wave\n !node.getAttribute || node.getAttribute('disabled') || node.disabled || node.className.includes('disabled') || node.className.includes('-leave')) {\n return;\n }\n showWave(e);\n };\n // Bind events\n node.addEventListener('click', onClick, true);\n return () => {\n node.removeEventListener('click', onClick, true);\n };\n }, [disabled]);\n // ============================== Render ==============================\n if (! /*#__PURE__*/React.isValidElement(children)) {\n return children !== null && children !== void 0 ? children : null;\n }\n const ref = supportRef(children) ? composeRef(children.ref, containerRef) : containerRef;\n return cloneElement(children, {\n ref\n });\n};\nif (process.env.NODE_ENV !== 'production') {\n Wave.displayName = 'Wave';\n}\nexport default Wave;","map":{"version":3,"names":["React","useContext","useRef","classNames","isVisible","composeRef","supportRef","ConfigContext","cloneElement","useStyle","useWave","Wave","props","children","disabled","component","getPrefixCls","containerRef","prefixCls","hashId","showWave","useEffect","node","current","nodeType","onClick","e","target","getAttribute","className","includes","addEventListener","removeEventListener","isValidElement","ref","process","env","NODE_ENV","displayName"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/_util/wave/index.js"],"sourcesContent":["import React, { useContext, useRef } from 'react';\nimport classNames from 'classnames';\nimport isVisible from \"rc-util/es/Dom/isVisible\";\nimport { composeRef, supportRef } from \"rc-util/es/ref\";\nimport { ConfigContext } from '../../config-provider';\nimport { cloneElement } from '../reactNode';\nimport useStyle from './style';\nimport useWave from './useWave';\nconst Wave = props => {\n const {\n children,\n disabled,\n component\n } = props;\n const {\n getPrefixCls\n } = useContext(ConfigContext);\n const containerRef = useRef(null);\n // ============================== Style ===============================\n const prefixCls = getPrefixCls('wave');\n const [, hashId] = useStyle(prefixCls);\n // =============================== Wave ===============================\n const showWave = useWave(containerRef, classNames(prefixCls, hashId), component);\n // ============================== Effect ==============================\n React.useEffect(() => {\n const node = containerRef.current;\n if (!node || node.nodeType !== 1 || disabled) {\n return;\n }\n // Click handler\n const onClick = e => {\n // Fix radio button click twice\n if (!isVisible(e.target) ||\n // No need wave\n !node.getAttribute || node.getAttribute('disabled') || node.disabled || node.className.includes('disabled') || node.className.inc
|