1 line
18 KiB
JSON
1 line
18 KiB
JSON
|
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nfunction splitValues(value) {\n if (typeof value === 'number') {\n return [[value], false];\n }\n var rawStyle = String(value).trim();\n var importantCells = rawStyle.match(/(.*)(!important)/);\n var splitStyle = (importantCells ? importantCells[1] : rawStyle).trim().split(/\\s+/);\n\n // Combine styles split in brackets, like `calc(1px + 2px)`\n var temp = [];\n var brackets = 0;\n return [splitStyle.reduce(function (list, item) {\n if (item.includes('(') || item.includes(')')) {\n var left = item.split('(').length - 1;\n var right = item.split(')').length - 1;\n brackets += left - right;\n }\n if (brackets >= 0) temp.push(item);\n if (brackets === 0) {\n list.push(temp.join(' '));\n temp = [];\n }\n return list;\n }, []), !!importantCells];\n}\nfunction noSplit(list) {\n list.notSplit = true;\n return list;\n}\nvar keyMap = {\n // Inset\n inset: ['top', 'right', 'bottom', 'left'],\n insetBlock: ['top', 'bottom'],\n insetBlockStart: ['top'],\n insetBlockEnd: ['bottom'],\n insetInline: ['left', 'right'],\n insetInlineStart: ['left'],\n insetInlineEnd: ['right'],\n // Margin\n marginBlock: ['marginTop', 'marginBottom'],\n marginBlockStart: ['marginTop'],\n marginBlockEnd: ['marginBottom'],\n marginInline: ['marginLeft', 'marginRight'],\n marginInlineStart: ['marginLeft'],\n marginInlineEnd: ['marginRight'],\n // Padding\n paddingBlock: ['paddingTop', 'paddingBottom'],\n paddingBlockStart: ['paddingTop'],\n paddingBlockEnd: ['paddingBottom'],\n paddingInline: ['paddingLeft', 'paddingRight'],\n paddingInlineStart: ['paddingLeft'],\n paddingInlineEnd: ['paddingRight'],\n // Border\n borderBlock: noSplit(['borderTop', 'borderBottom']),\n borderBlockStart: noSplit(['borderTop']),\n borderBlockEnd: noSplit(['borderBottom']),\n borderInline: noSplit(['borderLeft', 'borderRight']),\n borderInlineStart: noSplit(['borderLeft']),\n borderInlineEnd: noSplit(['borderRight']),\n // Border width\n borderBlockWidth: ['borderTopWidth', 'borderBottomWidth'],\n borderBlockStartWidth: ['borderTopWidth'],\n borderBlockEndWidth: ['borderBottomWidth'],\n borderInlineWidth: ['borderLeftWidth', 'borderRightWidth'],\n borderInlineStartWidth: ['borderLeftWidth'],\n borderInlineEndWidth: ['borderRightWidth'],\n // Border style\n borderBlockStyle: ['borderTopStyle', 'borderBottomStyle'],\n borderBlockStartStyle: ['borderTopStyle'],\n borderBlockEndStyle: ['borderBottomStyle'],\n borderInlineStyle: ['borderLeftStyle', 'borderRightStyle'],\n borderInlineStartStyle: ['borderLeftStyle'],\n borderInlineEndStyle: ['borderRightStyle'],\n // Border color\n borderBlockColor: ['borderTopColor', 'borderBottomColor'],\n borderBlockStartColor: ['borderTopColor'],\n borderBlockEndColor: ['borderBottomColor'],\n borderInlineColor: ['borderLeftColor', 'borderRightColor'],\n borderInlineStartColor: ['borderLeftColor'],\n borderInlineEndColor: ['borderRightColor'],\n // Border radius\n borderStartStartRadius: ['borderTopLeftRadius'],\n borderStartEndRadius: ['borderTopRightRadius'],\n borderEndStartRadius: ['borderBottomLeftRadius'],\n borderEndEndRadius: ['borderBottomRightRadius']\n};\nfunction wrapImportantAndSkipCheck(value, important) {\n var parsedValue = value;\n if (important) {\n parsedValue = \"\".concat(parsedValue, \" !important\");\n }\n return {\n _skip_check_: true,\n value: parsedValue\n };\n}\n\n/**\n * Convert css logical properties to legacy properties.\n * Such as: `margin-block-start` to `margin-top`.\n * Transform list:\n * - inset\n * - margin\n * - padding\n * - border\n */\nvar transform = {\n visit: function visit(cssObj) {\n var clone = {};\n Object.keys(cssObj).forEach(function (key) {\n var value = cssObj[key];\n var matchValue = keyMap[key];\n if (matchValue && (typeof value === 'number' || typeof value === 'string')) {\n var _splitValues = splitValues(value),\n _splitValues2 = _slic
|