PromoCursed/node_modules/.cache/babel-loader/bfa02223dc5fcec2ef57fa3ef41ccc7ba9bae8adc4673d4a67d4a434ebef8d0c.json

1 line
14 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport * as React from 'react';\nimport { useRef, useState } from 'react';\nimport EyeInvisibleOutlined from \"@ant-design/icons/es/icons/EyeInvisibleOutlined\";\nimport EyeOutlined from \"@ant-design/icons/es/icons/EyeOutlined\";\nimport classNames from 'classnames';\nimport omit from \"rc-util/es/omit\";\nimport { composeRef } from \"rc-util/es/ref\";\nimport { ConfigContext } from '../config-provider';\nimport useRemovePasswordTimeout from './hooks/useRemovePasswordTimeout';\nimport Input from './Input';\nconst defaultIconRender = visible => visible ? /*#__PURE__*/React.createElement(EyeOutlined, null) : /*#__PURE__*/React.createElement(EyeInvisibleOutlined, null);\nconst actionMap = {\n click: 'onClick',\n hover: 'onMouseOver'\n};\nconst Password = /*#__PURE__*/React.forwardRef((props, ref) => {\n const {\n disabled,\n action = 'click',\n visibilityToggle = true,\n iconRender = defaultIconRender\n } = props;\n const visibilityControlled = typeof visibilityToggle === 'object' && visibilityToggle.visible !== undefined;\n const [visible, setVisible] = useState(() => visibilityControlled ? visibilityToggle.visible : false);\n const inputRef = useRef(null);\n React.useEffect(() => {\n if (visibilityControlled) {\n setVisible(visibilityToggle.visible);\n }\n }, [visibilityControlled, visibilityToggle]);\n // Remove Password value\n const removePasswordTimeout = useRemovePasswordTimeout(inputRef);\n const onVisibleChange = () => {\n if (disabled) {\n return;\n }\n if (visible) {\n removePasswordTimeout();\n }\n setVisible(prevState => {\n var _a;\n const newState = !prevState;\n if (typeof visibilityToggle === 'object') {\n (_a = visibilityToggle.onVisibleChange) === null || _a === void 0 ? void 0 : _a.call(visibilityToggle, newState);\n }\n return newState;\n });\n };\n const getIcon = prefixCls => {\n const iconTrigger = actionMap[action] || '';\n const icon = iconRender(visible);\n const iconProps = {\n [iconTrigger]: onVisibleChange,\n className: `${prefixCls}-icon`,\n key: 'passwordIcon',\n onMouseDown: e => {\n // Prevent focused state lost\n // https://github.com/ant-design/ant-design/issues/15173\n e.preventDefault();\n },\n onMouseUp: e => {\n // Prevent caret position change\n // https://github.com/ant-design/ant-design/issues/23524\n e.preventDefault();\n }\n };\n return /*#__PURE__*/React.cloneElement( /*#__PURE__*/React.isValidElement(icon) ? icon : /*#__PURE__*/React.createElement(\"span\", null, icon), iconProps);\n };\n const {\n className,\n prefixCls: customizePrefixCls,\n inputPrefixCls: customizeInputPrefixCls,\n size\n } = props,\n restProps = __rest(props, [\"className\", \"prefixCls\", \"inputPrefixCls\", \"size\"]);\n const {\n getPrefixCls\n } = React.useContext(ConfigContext);\n const inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);\n const prefixCls = getPrefixCls('input-password', customizePrefixCls);\n const suffixIcon = visibilityToggle && getIcon(prefixCls);\n const inputClassName = classNames(prefixCls, className, {\n [`${prefixCls}-${size}`]: !!size\n });\n const omittedProps = Object.assign(Object.assign({}, omit(restProps, ['suffix', 'iconRender', 'visibilityToggle'])), {\n type: visible ? 'text' : 'password',\n className: inputClassName,\n prefixCls: inputPrefixCls,\n suffix: suffixIcon\n });\n if (size) {\n omittedProps.size = size;\n }\n return /*#__