1 line
11 KiB
JSON
1 line
11 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nvar _excluded = [\"value\", \"size\", \"level\", \"bgColor\", \"fgColor\", \"includeMargin\", \"minVersion\", \"title\", \"marginSize\", \"imageSettings\"];\nimport React from 'react';\nimport { DEFAULT_BACKGROUND_COLOR, DEFAULT_FRONT_COLOR, DEFAULT_NEED_MARGIN, DEFAULT_LEVEL, DEFAULT_MINVERSION, DEFAULT_SIZE, excavateModules, generatePath } from \"./utils\";\nimport { useQRCode } from \"./hooks/useQRCode\";\nvar QRCodeSVG = /*#__PURE__*/React.forwardRef(function QRCodeSVG(props, forwardedRef) {\n var value = props.value,\n _props$size = props.size,\n size = _props$size === void 0 ? DEFAULT_SIZE : _props$size,\n _props$level = props.level,\n level = _props$level === void 0 ? DEFAULT_LEVEL : _props$level,\n _props$bgColor = props.bgColor,\n bgColor = _props$bgColor === void 0 ? DEFAULT_BACKGROUND_COLOR : _props$bgColor,\n _props$fgColor = props.fgColor,\n fgColor = _props$fgColor === void 0 ? DEFAULT_FRONT_COLOR : _props$fgColor,\n _props$includeMargin = props.includeMargin,\n includeMargin = _props$includeMargin === void 0 ? DEFAULT_NEED_MARGIN : _props$includeMargin,\n _props$minVersion = props.minVersion,\n minVersion = _props$minVersion === void 0 ? DEFAULT_MINVERSION : _props$minVersion,\n title = props.title,\n marginSize = props.marginSize,\n imageSettings = props.imageSettings,\n otherProps = _objectWithoutProperties(props, _excluded);\n var _useQRCode = useQRCode({\n value: value,\n level: level,\n minVersion: minVersion,\n includeMargin: includeMargin,\n marginSize: marginSize,\n imageSettings: imageSettings,\n size: size\n }),\n margin = _useQRCode.margin,\n cells = _useQRCode.cells,\n numCells = _useQRCode.numCells,\n calculatedImageSettings = _useQRCode.calculatedImageSettings;\n var cellsToDraw = cells;\n var image = null;\n if (imageSettings != null && calculatedImageSettings != null) {\n if (calculatedImageSettings.excavation != null) {\n cellsToDraw = excavateModules(cells, calculatedImageSettings.excavation);\n }\n image = /*#__PURE__*/React.createElement(\"image\", {\n href: imageSettings.src,\n height: calculatedImageSettings.h,\n width: calculatedImageSettings.w,\n x: calculatedImageSettings.x + margin,\n y: calculatedImageSettings.y + margin,\n preserveAspectRatio: \"none\",\n opacity: calculatedImageSettings.opacity\n // when crossOrigin is not set, the image will be tainted\n // and the canvas cannot be exported to an image\n ,\n\n crossOrigin: calculatedImageSettings.crossOrigin\n });\n }\n var fgPath = generatePath(cellsToDraw, margin);\n return /*#__PURE__*/React.createElement(\"svg\", _extends({\n height: size,\n width: size,\n viewBox: \"0 0 \".concat(numCells, \" \").concat(numCells),\n ref: forwardedRef,\n role: \"img\"\n }, otherProps), !!title && /*#__PURE__*/React.createElement(\"title\", null, title), /*#__PURE__*/React.createElement(\"path\", {\n fill: bgColor,\n d: \"M0,0 h\".concat(numCells, \"v\").concat(numCells, \"H0z\"),\n shapeRendering: \"crispEdges\"\n }), /*#__PURE__*/React.createElement(\"path\", {\n fill: fgColor,\n d: fgPath,\n shapeRendering: \"crispEdges\"\n }), image);\n});\nQRCodeSVG.displayName = 'QRCodeSVG';\nexport { QRCodeSVG };","map":{"version":3,"names":["_extends","_objectWithoutProperties","_excluded","React","DEFAULT_BACKGROUND_COLOR","DEFAULT_FRONT_COLOR","DEFAULT_NEED_MARGIN","DEFAULT_LEVEL","DEFAULT_MINVERSION","DEFAULT_SIZE","excavateModules","generatePath","useQRCode","QRCodeSVG","forwardRef","props","forwardedRef","value","_props$size","size","_props$level","level","_props$bgColor","bgColor","_props$fgColor","fgColor","_props$includeMargin","includeMargin","_props$minVersion","minVersion","title","marginSize","imageSettings","otherProps","_useQRCode","margin","cells","nu
|