1 line
7.5 KiB
JSON
1 line
7.5 KiB
JSON
|
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\n/**\n * respect https://github.com/cuth/postcss-pxtorem\n */\n// @ts-ignore\nimport unitless from '@emotion/unitless';\nvar pxRegex = /url\\([^)]+\\)|var\\([^)]+\\)|(\\d*\\.?\\d+)px/g;\nfunction toFixed(number, precision) {\n var multiplier = Math.pow(10, precision + 1),\n wholeNumber = Math.floor(number * multiplier);\n return Math.round(wholeNumber / 10) * 10 / multiplier;\n}\nvar transform = function transform() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var _options$rootValue = options.rootValue,\n rootValue = _options$rootValue === void 0 ? 16 : _options$rootValue,\n _options$precision = options.precision,\n precision = _options$precision === void 0 ? 5 : _options$precision,\n _options$mediaQuery = options.mediaQuery,\n mediaQuery = _options$mediaQuery === void 0 ? false : _options$mediaQuery;\n var pxReplace = function pxReplace(m, $1) {\n if (!$1) return m;\n var pixels = parseFloat($1);\n // covenant: pixels <= 1, not transform to rem @zombieJ\n if (pixels <= 1) return m;\n var fixedVal = toFixed(pixels / rootValue, precision);\n return \"\".concat(fixedVal, \"rem\");\n };\n var visit = function visit(cssObj) {\n var clone = _objectSpread({}, cssObj);\n Object.entries(cssObj).forEach(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n key = _ref2[0],\n value = _ref2[1];\n if (typeof value === 'string' && value.includes('px')) {\n var newValue = value.replace(pxRegex, pxReplace);\n clone[key] = newValue;\n }\n\n // no unit\n if (!unitless[key] && typeof value === 'number' && value !== 0) {\n clone[key] = \"\".concat(value, \"px\").replace(pxRegex, pxReplace);\n }\n\n // Media queries\n var mergedKey = key.trim();\n if (mergedKey.startsWith('@') && mergedKey.includes('px') && mediaQuery) {\n var newKey = key.replace(pxRegex, pxReplace);\n clone[newKey] = clone[key];\n delete clone[key];\n }\n });\n return clone;\n };\n return {\n visit: visit\n };\n};\nexport default transform;","map":{"version":3,"names":["_slicedToArray","_objectSpread","unitless","pxRegex","toFixed","number","precision","multiplier","Math","pow","wholeNumber","floor","round","transform","options","arguments","length","undefined","_options$rootValue","rootValue","_options$precision","_options$mediaQuery","mediaQuery","pxReplace","m","$1","pixels","parseFloat","fixedVal","concat","visit","cssObj","clone","Object","entries","forEach","_ref","_ref2","key","value","includes","newValue","replace","mergedKey","trim","startsWith","newKey"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/@ant-design/cssinjs/es/transformers/px2rem.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\n/**\n * respect https://github.com/cuth/postcss-pxtorem\n */\n// @ts-ignore\nimport unitless from '@emotion/unitless';\nvar pxRegex = /url\\([^)]+\\)|var\\([^)]+\\)|(\\d*\\.?\\d+)px/g;\nfunction toFixed(number, precision) {\n var multiplier = Math.pow(10, precision + 1),\n wholeNumber = Math.floor(number * multiplier);\n return Math.round(wholeNumber / 10) * 10 / multiplier;\n}\nvar transform = function transform() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var _options$rootValue = options.rootValue,\n rootValue = _options$rootValue === void 0 ? 16 : _options$rootValue,\n _options$precision = options.precision,\n precision = _options$precision === void 0 ? 5 : _options$precision,\n _options$mediaQuery = options.mediaQuery,\n mediaQuery = _options$mediaQuery === void 0 ? false : _options$mediaQuery;\n var pxReplace = function pxReplace(m, $1) {\n if (!$1) return m;\n var pixe
|