1 line
14 KiB
JSON
1 line
14 KiB
JSON
|
{"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 React, { useContext } from 'react';\nimport { QRCodeCanvas, QRCodeSVG } from '@rc-component/qrcode';\nimport classNames from 'classnames';\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport { useLocale } from '../locale';\nimport { useToken } from '../theme/internal';\nimport useStyle from './style/index';\nimport QRcodeStatus from './QrcodeStatus';\nconst QRCode = props => {\n var _a, _b, _c, _d;\n const [, token] = useToken();\n const {\n value,\n type = 'canvas',\n icon = '',\n size = 160,\n iconSize,\n color = token.colorText,\n errorLevel = 'M',\n status = 'active',\n bordered = true,\n onRefresh,\n style,\n className,\n rootClassName,\n prefixCls: customizePrefixCls,\n bgColor = 'transparent',\n statusRender\n } = props,\n rest = __rest(props, [\"value\", \"type\", \"icon\", \"size\", \"iconSize\", \"color\", \"errorLevel\", \"status\", \"bordered\", \"onRefresh\", \"style\", \"className\", \"rootClassName\", \"prefixCls\", \"bgColor\", \"statusRender\"]);\n const {\n getPrefixCls\n } = useContext(ConfigContext);\n const prefixCls = getPrefixCls('qrcode', customizePrefixCls);\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const imageSettings = {\n src: icon,\n x: undefined,\n y: undefined,\n height: typeof iconSize === 'number' ? iconSize : (_a = iconSize === null || iconSize === void 0 ? void 0 : iconSize.height) !== null && _a !== void 0 ? _a : 40,\n width: typeof iconSize === 'number' ? iconSize : (_b = iconSize === null || iconSize === void 0 ? void 0 : iconSize.width) !== null && _b !== void 0 ? _b : 40,\n excavate: true,\n crossOrigin: 'anonymous'\n };\n const qrCodeProps = {\n value,\n size,\n level: errorLevel,\n bgColor,\n fgColor: color,\n style: {\n width: style === null || style === void 0 ? void 0 : style.width,\n height: style === null || style === void 0 ? void 0 : style.height\n },\n imageSettings: icon ? imageSettings : undefined\n };\n const [locale] = useLocale('QRCode');\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('QRCode');\n process.env.NODE_ENV !== \"production\" ? warning(!!value, 'usage', 'need to receive `value` props') : void 0;\n process.env.NODE_ENV !== \"production\" ? warning(!(icon && errorLevel === 'L'), 'usage', 'ErrorLevel `L` is not recommended to be used with `icon`, for scanning result would be affected by low level.') : void 0;\n }\n if (!value) {\n return null;\n }\n const mergedCls = classNames(prefixCls, className, rootClassName, hashId, cssVarCls, {\n [`${prefixCls}-borderless`]: !bordered\n });\n const mergedStyle = Object.assign(Object.assign({\n backgroundColor: bgColor\n }, style), {\n width: (_c = style === null || style === void 0 ? void 0 : style.width) !== null && _c !== void 0 ? _c : size,\n height: (_d = style === null || style === void 0 ? void 0 : style.height) !== null && _d !== void 0 ? _d : size\n });\n return wrapCSSVar( /*#__PURE__*/React.createElement(\"div\", Object.assign({}, rest, {\n className: mergedCls,\n style: mergedStyle\n }), status !== 'active' && ( /*#__PURE__*/React.createElement(\"div\", {\n className: `${prefixCls}-mask`\n }, /*#__PURE__*/React.createElement(QRcodeStatus, {\n prefixCls: prefixCls,\n locale: locale,\n status: status,\n onRefresh: onRefresh,\n statusRender: statusRender\n }))), type === 'canvas' ? /*#__PURE__*/React.cr
|