moodle_local_treestudyplan/amd/build/util/css-calc.min.js.map

1 line
7.5 KiB
Text
Raw Normal View History

2024-02-23 09:20:10 +01:00
{"version":3,"file":"css-calc.min.js","sources":["../../src/util/css-calc.js"],"sourcesContent":["/*eslint no-trailing-spaces: \"off\"*/\n/*eslint no-eval: \"off\"*/\n\n/***********************************\n * Licence: MIT\n * (c) 2023 Morglod/jchnkl\n * converted from the typescript @ https://github.com/Morglod/csscalc/\n */\n\n// units -> pixels\nexport const Absolute = {\n /** browser version of pixel */\n px: 1,\n /** One centimeter. 1cm = 96px/2.54 */\n cm: 96 / 2.54,\n /** One millimeter. 1mm = 1/10th of 1cm */\n mm: 96 / 25.4,\n /** One quarter of a millimeter. 1Q = 1/40th of 1cm */\n Q: 96 / 101.6,\n /** One inch. 1in = 2.54cm = 96px */\n in: 96,\n /** One pica. 1pc = 12pt = 1/6th of 1in */\n pc: 96 / 6,\n /** One point. 1pt = 1/72nd of 1in */\n pt: 96 / 72\n };\n\n // units ->(calc context)-> pixels\n export const Relative = {\n /**\n * Equal to 1% of the height of the viewport\n * @param {number} count\n * @param {object} ctx\n */\n vh: (count = 1, ctx) => {\n return ((ctx ? ctx.viewportHeight : window.innerHeight) / 100) * count;\n },\n /**\n * Equal to 1% of the width of the viewport\n * @param {number} count\n * @param {object} ctx\n */\n vw: (count = 1, ctx) => {\n return ((ctx ? ctx.viewportWidth : window.innerWidth) / 100) * count;\n },\n /**\n * 1/100th of the smallest viewport side\n * @param {number} count\n * @param {object} ctx\n */\n vmin: (count = 1, ctx) => {\n return (\n ((ctx\n ? Math.min(ctx.viewportWidth, ctx.viewportHeight)\n : Math.min(window.innerWidth, window.innerHeight)) /\n 100) *\n count\n );\n },\n /**\n * 1/100th of the largest viewport side\n * @param {number} count\n * @param {object} ctx\n */\n vmax: (count = 1, ctx) => {\n return (\n ((ctx\n ? Math.max(ctx.viewportWidth, ctx.viewportHeight)\n : Math.max(window.innerWidth, window.innerHeight)) /\n 100) *\n count\n );\n },\n /**\n * Represents the font-size of <html> element\n * @param {number} count\n * @param {object} ctx\n */\n rem: (count = 1, ctx) => {\n return (\n (ctx\n ? ctx.htmlFontSize\n : parseFloat(\n window.getComputedStyle(document.querySelector(\"html\")).fontSize\n )) * count\n );\n },\n /**\n * percent of width\n * @param {number} count\n * @param {object} ctx\n */\n \"%w\": (count = 1, ctx) => {\n return ((ctx ? ctx.width : document.body.clientWidth) / 100) * count;\n },\n /**\n * percent of height\n * @param {number} count\n * @param {object} ctx\n */\n \"%h\": (count = 1, ctx) => {\n return ((ctx ? ctx.height : document.body.clientHeight) / 100) * count;\n }\n };\n\n export const Units = {\n ...Relative,\n ...Absolute\n };\n\n export const UnitRegexpStr = `(?:\\\\s|^)(\\\\d*(?:\\\\.\\\\d+)?)(${Object.keys(\n Units\n ).join(\"|\")})(?:\\\\s|$|\\\\n)`;\n export const UnitRegexp = new RegExp(UnitRegexpStr);\n export const UnitRegexpGM = new RegExp(UnitRegexpStr, \"gm\");\n\n /**\n *\n * @param {*} count\n * @param {*} fromUnits\n * @param {*} toUnits\n * @param {*} ctx\n * @returns\n */\n export function convert(count, fromUnits, toUnits, ctx = calcCtx()) {\n const baseUnit = Units[fromUnits];\n const basePx =\n typeof baseUnit === \"function\" ? baseUnit(count, ctx) : baseUnit * count;\n\n const dstUnit = Units[toUnits];\n const dstBasePx = typeof dstUnit === \"function\" ? dstUnit(1, ctx) : dstUnit;\n\n return basePx / dstBasePx;\n }\n\n /**\n *\n * @param {*} expr\n * @param {*} toUnits\n * @param {*} ctx\n * @returns\n */\n export function convertAllInStr(expr, toUnits, ctx = calcCtx()) {\n return expr.replace(UnitRegexpGM, (substr, count, unit) => {\n return convert(parseFloat(count), unit, toUnits, ctx).toString();\n });\n }\n\n /**\n *\n