b7813b3c1418e9e269fe951ade76fb5753ddfb7fbaf3333cbf53f2c7f37bd77e.json 6.9 KB

1
  1. {"ast":null,"code":"import React, { useContext, useRef } from 'react';\nimport classNames from 'classnames';\nimport isVisible from \"rc-util/es/Dom/isVisible\";\nimport { composeRef, getNodeRef, 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 !== window.Node.ELEMENT_NODE || 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('disabled:') || node.getAttribute('aria-disabled') === 'true' || 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(getNodeRef(children), 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","getNodeRef","supportRef","ConfigContext","cloneElement","useStyle","useWave","Wave","props","children","disabled","component","getPrefixCls","containerRef","prefixCls","hashId","showWave","useEffect","node","current","nodeType","window","Node","ELEMENT_NODE","onClick","e","target","getAttribute","className","includes","addEventListener","removeEventListener","isValidElement","ref","process","env","NODE_ENV","displayName"],"sources":["/Users/max_liu/max_liu/company/tools_auto_pt/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, getNodeRef, 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 !== window.Node.ELEMENT_NODE || 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('disabled:') || node.getAttribute('aria-disabled') === 'true' || 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(getNodeRef(children), containerRef) : containerRef;\n return cloneElement(children, {\n ref\n });\n};\nif (process.env.NODE_ENV !== 'production') {\n Wave.displayName = 'Wave';\n}\nexport default Wave;"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,MAAM,QAAQ,OAAO;AACjD,OAAOC,UAAU,MAAM,YAAY;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