"use strict"; exports.__esModule = true; exports["default"] = stripUnit; var cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/; /** * Returns a given CSS value minus its unit of measure. * * @deprecated - stripUnit's unitReturn functionality has been marked for deprecation in polished 4.0. It's functionality has been been moved to getValueAndUnit. * * @example * // Styles as object usage * const styles = { * '--dimension': stripUnit('100px') * } * * // styled-components usage * const div = styled.div` * --dimension: ${stripUnit('100px')}; * ` * * // CSS in JS Output * * element { * '--dimension': 100 * } */ function stripUnit(value, unitReturn) { if (typeof value !== 'string') return unitReturn ? [value, undefined] : value; var matchedValue = value.match(cssRegex); if (unitReturn) { // eslint-disable-next-line no-console console.warn("stripUnit's unitReturn functionality has been marked for deprecation in polished 4.0. It's functionality has been been moved to getValueAndUnit."); if (matchedValue) return [parseFloat(value), matchedValue[2]]; return [value, undefined]; } if (matchedValue) return parseFloat(value); return value; } module.exports = exports.default;