@wordpress/components
Version:
UI components for WordPress.
8 lines (7 loc) • 1.65 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/font-size-picker/utils.ts"],
"sourcesContent": ["/**\n * Internal dependencies\n */\n\n/**\n * Some themes use css vars for their font sizes, so until we\n * have the way of calculating them don't display them.\n *\n * @param value The value that is checked.\n * @return Whether the value is a simple css value.\n */\nexport function isSimpleCssValue(value) {\n const sizeRegex = /^[\\d\\.]+(px|em|rem|vw|vh|%|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)?$/i;\n return sizeRegex.test(String(value));\n}\n\n/**\n * Generates hint text for a font size.\n * This function returns the hint provided by the consumer, if any.\n * If no hint is provided, it falls back to showing the size value for simple CSS values.\n *\n * @param fontSize The font size object to generate hint text for.\n * @return The hint text provided by the consumer, or the size value for simple CSS values, or undefined.\n */\nexport function generateFontSizeHint(fontSize) {\n // If the font size already has a hint, use it\n if (fontSize.hint) {\n return fontSize.hint;\n }\n\n // Fallback to showing the size value if it's a simple CSS value\n if (isSimpleCssValue(fontSize.size)) {\n return String(fontSize.size);\n }\n return undefined;\n}"],
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,iBAAiB,OAAO;AACtC,QAAM,YAAY;AAClB,SAAO,UAAU,KAAK,OAAO,KAAK,CAAC;AACrC;AAUO,SAAS,qBAAqB,UAAU;AAE7C,MAAI,SAAS,MAAM;AACjB,WAAO,SAAS;AAAA,EAClB;AAGA,MAAI,iBAAiB,SAAS,IAAI,GAAG;AACnC,WAAO,OAAO,SAAS,IAAI;AAAA,EAC7B;AACA,SAAO;AACT;",
"names": []
}