Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-pdf/stylesheet

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf/stylesheet - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

6

CHANGELOG.md
# @react-pdf/stylesheet
## 4.1.3
### Patch Changes
- [#2205](https://github.com/diegomura/react-pdf/pull/2205) [`9a5e0be`](https://github.com/diegomura/react-pdf/commit/9a5e0befb89756db07ce053192a136df9d4ba905) Thanks [@jeetiss](https://github.com/jeetiss)! - update babel
## 4.1.2

@@ -4,0 +10,0 @@

172

lib/index.cjs.js

@@ -23,10 +23,9 @@ 'use strict';

// https://developer.mozilla.org/en-US/docs/Web/CSS/flex#values
// TODO: change flex defaults to [0, 1, 'auto'] as in spec in next major release
var flexDefaults = [1, 1, 0];
var flexAuto = [1, 1, 'auto'];
var expandFlex = function expandFlex(key, value) {
var defaults = flexDefaults;
var matches = [];
if (value === 'auto') {

@@ -37,3 +36,2 @@ defaults = flexAuto;

}
var flexGrow = matches[0] || defaults[0];

@@ -51,25 +49,21 @@ var flexShrink = matches[1] || defaults[1];

var BOX_MODEL_UNITS = 'px,in,mm,cm,pt,%,vw,vh';
var logError = function logError(style, value) {
console.error("\n @react-pdf/stylesheet parsing error:\n\n " + style + ": " + value + ",\n " + ' '.repeat(style.length + 2) + "^\n Unsupported " + style + " value format\n ");
};
var expandBoxModel = function expandBoxModel(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
expandsTo = _ref.expandsTo,
_ref$maxValues = _ref.maxValues,
maxValues = _ref$maxValues === void 0 ? 1 : _ref$maxValues,
_ref$autoSupported = _ref.autoSupported,
autoSupported = _ref$autoSupported === void 0 ? false : _ref$autoSupported;
expandsTo = _ref.expandsTo,
_ref$maxValues = _ref.maxValues,
maxValues = _ref$maxValues === void 0 ? 1 : _ref$maxValues,
_ref$autoSupported = _ref.autoSupported,
autoSupported = _ref$autoSupported === void 0 ? false : _ref$autoSupported;
return function (model, value) {
var _ref2;
var nodes = parse__default["default"]("" + value);
var parts = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i]; // value contains `calc`, `url` or other css function
// value contains `calc`, `url` or other css function
// `,`, `/` or strings that unsupported by margin and padding
if (node.type === 'function' || node.type === 'string' || node.type === 'div') {

@@ -79,3 +73,2 @@ logError(model, value);

}
if (node.type === 'word') {

@@ -85,4 +78,5 @@ if (node.value === 'auto' && autoSupported) {

} else {
var result = parseUnit__default["default"](node.value); // when unit isn't specified this condition is true
var result = parseUnit__default["default"](node.value);
// when unit isn't specified this condition is true
if (result && BOX_MODEL_UNITS.includes(result.unit)) {

@@ -96,5 +90,5 @@ parts.push(node.value);

}
} // checks that we have enough parsed values
}
// checks that we have enough parsed values
if (parts.length > maxValues) {

@@ -104,5 +98,3 @@ logError(model, value);

}
var first = parts[0];
if (expandsTo) {

@@ -119,3 +111,2 @@ var second = parts[1] || parts[0];

}
return _ref2 = {}, _ref2[model] = first, _ref2;

@@ -128,5 +119,5 @@ };

var first = _ref.first,
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
return {

@@ -145,3 +136,3 @@ marginTop: first,

var first = _ref2.first,
second = _ref2.second;
second = _ref2.second;
return {

@@ -158,3 +149,3 @@ marginTop: first,

var first = _ref3.first,
second = _ref3.second;
second = _ref3.second;
return {

@@ -173,10 +164,7 @@ marginRight: first,

var BORDER_SHORTHAND_REGEX = /(-?\d+(\.\d+)?(px|in|mm|cm|pt|vw|vh|px)?)\s(\S+)\s(.+)/;
var matchBorderShorthand = function matchBorderShorthand(value) {
return value.match(BORDER_SHORTHAND_REGEX) || [];
};
var expandBorders = function expandBorders(key, value) {
var match = matchBorderShorthand("" + value);
if (match) {

@@ -186,9 +174,6 @@ var color = match[5] || value;

var width = match[1] || value;
if (key.match(/(Top|Right|Bottom|Left)$/)) {
var _ref;
return _ref = {}, _ref[key + "Color"] = color, _ref[key + "Style"] = style, _ref[key + "Width"] = width, _ref;
}
if (key.match(/Color$/)) {

@@ -202,3 +187,2 @@ return {

}
if (key.match(/Style$/)) {

@@ -212,3 +196,2 @@ return {

}
if (key.match(/Width$/)) {

@@ -222,3 +205,2 @@ return {

}
if (key.match(/Radius$/)) {

@@ -232,3 +214,2 @@ return {

}
return {

@@ -249,3 +230,2 @@ borderTopColor: color,

}
return value;

@@ -257,5 +237,5 @@ };

var first = _ref.first,
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
return {

@@ -273,3 +253,3 @@ paddingTop: first,

var first = _ref2.first,
second = _ref2.second;
second = _ref2.second;
return {

@@ -285,3 +265,3 @@ paddingTop: first,

var first = _ref3.first,
second = _ref3.second;
second = _ref3.second;
return {

@@ -308,3 +288,2 @@ paddingRight: first,

};
var sortTransformOriginPair = function sortTransformOriginPair(a, b) {

@@ -315,3 +294,2 @@ if (Y_AXIS_SHORTHANDS[a]) return 1;

};
var getTransformOriginPair = function getTransformOriginPair(values) {

@@ -321,5 +299,5 @@ if (!values || values.length === 0) return ['center', 'center'];

return pair.sort(sortTransformOriginPair);
}; // Transforms shorthand transformOrigin values
};
// Transforms shorthand transformOrigin values
var expandTransformOrigin = function expandTransformOrigin(key, value) {

@@ -371,2 +349,3 @@ var match = ("" + value).split(' ');

};
/**

@@ -379,8 +358,7 @@ * Transforms style key-value

*/
var expandStyle = function expandStyle(key, value) {
var _ref;
return shorthands[key] ? shorthands[key](key, value) : (_ref = {}, _ref[key] = value, _ref);
};
/**

@@ -392,4 +370,2 @@ * Expand the shorthand properties.

*/
var expand = function expand(style) {

@@ -399,3 +375,2 @@ if (!style) return style;

var resolvedStyle = {};
for (var i = 0; i < propsArray.length; i += 1) {

@@ -406,3 +381,2 @@ var key = propsArray[i];

var keys = Object.keys(extended);
for (var j = 0; j < keys.length; j += 1) {

@@ -414,3 +388,2 @@ var propName = keys[j];

}
return resolvedStyle;

@@ -425,6 +398,6 @@ };

*/
var compact = function compact(array) {
return array.filter(Boolean);
};
/**

@@ -436,4 +409,2 @@ * Merges style objects array

*/
var mergeStyles = function mergeStyles(styles) {

@@ -450,2 +421,3 @@ return styles.reduce(function (acc, style) {

};
/**

@@ -457,4 +429,2 @@ * Flattens an array of style objects, into one aggregated style object.

*/
var flatten = fns.compose(mergeStyles, compact, fns.castArray);

@@ -478,2 +448,3 @@

};
/**

@@ -486,4 +457,2 @@ * Transform given scalar value

*/
var transformUnit = function transformUnit(container, value) {

@@ -494,19 +463,13 @@ var scalar = parseValue(value);

var cmFactor = 1 / 2.54 * dpi;
switch (scalar.unit) {
case 'in':
return scalar.value * dpi;
case 'mm':
return scalar.value * mmFactor;
case 'cm':
return scalar.value * cmFactor;
case 'vh':
return scalar.value * (container.height / 100);
case 'vw':
return scalar.value * (container.width / 100);
default:

@@ -520,6 +483,6 @@ return scalar.value;

};
var isHsl = function isHsl(value) {
return /hsla?/g.test(value);
};
/**

@@ -531,4 +494,2 @@ * Transform rgb color to hexa

*/
var parseRgb = function parseRgb(value) {

@@ -538,2 +499,3 @@ var rgb = colorString__default["default"].get.rgb(value);

};
/**

@@ -545,4 +507,2 @@ * Transform Hsl color to hexa

*/
var parseHsl = function parseHsl(value) {

@@ -553,2 +513,3 @@ var hsl = colorString__default["default"].get.hsl(value).map(Math.round);

};
/**

@@ -560,4 +521,2 @@ * Transform given color to hexa

*/
var transformColor = function transformColor(value) {

@@ -570,18 +529,15 @@ if (isRgb(value)) return parseRgb(value);

var parse = function parse(transformString) {
var transforms = transformString.trim().split(/\) |\)/); // Handle "initial", "inherit", "unset".
var transforms = transformString.trim().split(/\) |\)/);
// Handle "initial", "inherit", "unset".
if (transforms.length === 1) {
return [[transforms[0], true]];
}
var parsed = [];
for (var i = 0; i < transforms.length; i += 1) {
var transform = transforms[i];
if (transform) {
var _transform$split = transform.split('('),
name = _transform$split[0],
rawValue = _transform$split[1];
name = _transform$split[0],
rawValue = _transform$split[1];
var splitChar = rawValue.indexOf(',') >= 0 ? ',' : ' ';

@@ -597,21 +553,15 @@ var value = rawValue.split(splitChar).map(function (val) {

}
return parsed;
};
var parseAngle = function parseAngle(value) {
var unitsRegexp = /(-?\d*\.?\d*)(\w*)?/i;
var _unitsRegexp$exec = unitsRegexp.exec(value),
angle = _unitsRegexp$exec[1],
unit = _unitsRegexp$exec[2];
angle = _unitsRegexp$exec[1],
unit = _unitsRegexp$exec[2];
var number = Number.parseFloat(angle);
return unit === 'rad' ? number * 180 / Math.PI : number;
};
var normalizeTransformOperation = function normalizeTransformOperation(_ref) {
var operation = _ref.operation,
value = _ref.value;
value = _ref.value;
switch (operation) {

@@ -621,8 +571,7 @@ case 'scale':

var _value$map = value.map(function (num) {
return Number.parseFloat(num);
}),
scaleX = _value$map[0],
_value$map$ = _value$map[1],
scaleY = _value$map$ === void 0 ? scaleX : _value$map$;
return Number.parseFloat(num);
}),
scaleX = _value$map[0],
_value$map$ = _value$map[1],
scaleY = _value$map$ === void 0 ? scaleX : _value$map$;
return {

@@ -633,3 +582,2 @@ operation: 'scale',

}
case 'scaleX':

@@ -642,3 +590,2 @@ {

}
case 'scaleY':

@@ -651,3 +598,2 @@ {

}
case 'rotate':

@@ -660,3 +606,2 @@ {

}
case 'translate':

@@ -671,3 +616,2 @@ {

}
case 'translateX':

@@ -680,3 +624,2 @@ {

}
case 'translateY':

@@ -689,3 +632,2 @@ {

}
case 'skew':

@@ -698,3 +640,2 @@ {

}
case 'skewX':

@@ -707,3 +648,2 @@ {

}
case 'skewY':

@@ -716,3 +656,2 @@ {

}
default:

@@ -729,3 +668,2 @@ {

};
var normalize = function normalize(operations) {

@@ -736,3 +674,2 @@ return operations.map(function (operation) {

};
var processTransform = function processTransform(value) {

@@ -759,3 +696,2 @@ if (typeof value !== 'string') return value;

};
var processFontWeight = function processFontWeight(value) {

@@ -772,3 +708,2 @@ if (!value) return FONT_WEIGHTS.normal;

};
var castFloat = function castFloat(value) {

@@ -785,10 +720,7 @@ if (typeof value !== 'string') return value;

return '0%';
case 'right':
case 'bottom':
return '100%';
case 'center':
return '50%';
default:

@@ -815,3 +747,2 @@ return null;

};
var transformStyle = function transformStyle(key, value, container) {

@@ -821,2 +752,3 @@ var result = handlers[key] ? handlers[key](value) : value;

};
/**

@@ -828,4 +760,2 @@ * Transform styles values

*/
var transform = function transform(container) {

@@ -836,3 +766,2 @@ return function (style) {

var resolvedStyle = {};
for (var i = 0; i < propsArray.length; i += 1) {

@@ -844,3 +773,2 @@ var key = propsArray[i];

}
return resolvedStyle;

@@ -856,13 +784,9 @@ };

*/
var resolveMediaQueries = function resolveMediaQueries(container, styles) {
return Object.keys(styles).reduce(function (acc, key) {
var _extends2;
if (/@media/.test(key)) {
var _matchMedia;
return _extends__default["default"]({}, acc, matchMedia__default["default"]((_matchMedia = {}, _matchMedia[key] = styles[key], _matchMedia), container));
}
return _extends__default["default"]({}, acc, (_extends2 = {}, _extends2[key] = styles[key], _extends2));

@@ -879,3 +803,2 @@ }, {});

*/
var resolveStyles = function resolveStyles(container, style) {

@@ -885,5 +808,4 @@ var computeMediaQueries = function computeMediaQueries(value) {

};
return fns.compose(transform(container), expand, computeMediaQueries, flatten)(style);
}; // Utils exported for SVG processing
};

@@ -890,0 +812,0 @@ exports["default"] = resolveStyles;

@@ -10,10 +10,9 @@ import { compose, castArray } from '@react-pdf/fns';

// https://developer.mozilla.org/en-US/docs/Web/CSS/flex#values
// TODO: change flex defaults to [0, 1, 'auto'] as in spec in next major release
var flexDefaults = [1, 1, 0];
var flexAuto = [1, 1, 'auto'];
var expandFlex = function expandFlex(key, value) {
var defaults = flexDefaults;
var matches = [];
if (value === 'auto') {

@@ -24,3 +23,2 @@ defaults = flexAuto;

}
var flexGrow = matches[0] || defaults[0];

@@ -38,25 +36,21 @@ var flexShrink = matches[1] || defaults[1];

var BOX_MODEL_UNITS = 'px,in,mm,cm,pt,%,vw,vh';
var logError = function logError(style, value) {
console.error("\n @react-pdf/stylesheet parsing error:\n\n " + style + ": " + value + ",\n " + ' '.repeat(style.length + 2) + "^\n Unsupported " + style + " value format\n ");
};
var expandBoxModel = function expandBoxModel(_temp) {
var _ref = _temp === void 0 ? {} : _temp,
expandsTo = _ref.expandsTo,
_ref$maxValues = _ref.maxValues,
maxValues = _ref$maxValues === void 0 ? 1 : _ref$maxValues,
_ref$autoSupported = _ref.autoSupported,
autoSupported = _ref$autoSupported === void 0 ? false : _ref$autoSupported;
expandsTo = _ref.expandsTo,
_ref$maxValues = _ref.maxValues,
maxValues = _ref$maxValues === void 0 ? 1 : _ref$maxValues,
_ref$autoSupported = _ref.autoSupported,
autoSupported = _ref$autoSupported === void 0 ? false : _ref$autoSupported;
return function (model, value) {
var _ref2;
var nodes = parse$1("" + value);
var parts = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i]; // value contains `calc`, `url` or other css function
// value contains `calc`, `url` or other css function
// `,`, `/` or strings that unsupported by margin and padding
if (node.type === 'function' || node.type === 'string' || node.type === 'div') {

@@ -66,3 +60,2 @@ logError(model, value);

}
if (node.type === 'word') {

@@ -72,4 +65,5 @@ if (node.value === 'auto' && autoSupported) {

} else {
var result = parseUnit(node.value); // when unit isn't specified this condition is true
var result = parseUnit(node.value);
// when unit isn't specified this condition is true
if (result && BOX_MODEL_UNITS.includes(result.unit)) {

@@ -83,5 +77,5 @@ parts.push(node.value);

}
} // checks that we have enough parsed values
}
// checks that we have enough parsed values
if (parts.length > maxValues) {

@@ -91,5 +85,3 @@ logError(model, value);

}
var first = parts[0];
if (expandsTo) {

@@ -106,3 +98,2 @@ var second = parts[1] || parts[0];

}
return _ref2 = {}, _ref2[model] = first, _ref2;

@@ -115,5 +106,5 @@ };

var first = _ref.first,
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
return {

@@ -132,3 +123,3 @@ marginTop: first,

var first = _ref2.first,
second = _ref2.second;
second = _ref2.second;
return {

@@ -145,3 +136,3 @@ marginTop: first,

var first = _ref3.first,
second = _ref3.second;
second = _ref3.second;
return {

@@ -160,10 +151,7 @@ marginRight: first,

var BORDER_SHORTHAND_REGEX = /(-?\d+(\.\d+)?(px|in|mm|cm|pt|vw|vh|px)?)\s(\S+)\s(.+)/;
var matchBorderShorthand = function matchBorderShorthand(value) {
return value.match(BORDER_SHORTHAND_REGEX) || [];
};
var expandBorders = function expandBorders(key, value) {
var match = matchBorderShorthand("" + value);
if (match) {

@@ -173,9 +161,6 @@ var color = match[5] || value;

var width = match[1] || value;
if (key.match(/(Top|Right|Bottom|Left)$/)) {
var _ref;
return _ref = {}, _ref[key + "Color"] = color, _ref[key + "Style"] = style, _ref[key + "Width"] = width, _ref;
}
if (key.match(/Color$/)) {

@@ -189,3 +174,2 @@ return {

}
if (key.match(/Style$/)) {

@@ -199,3 +183,2 @@ return {

}
if (key.match(/Width$/)) {

@@ -209,3 +192,2 @@ return {

}
if (key.match(/Radius$/)) {

@@ -219,3 +201,2 @@ return {

}
return {

@@ -236,3 +217,2 @@ borderTopColor: color,

}
return value;

@@ -244,5 +224,5 @@ };

var first = _ref.first,
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
second = _ref.second,
third = _ref.third,
fourth = _ref.fourth;
return {

@@ -260,3 +240,3 @@ paddingTop: first,

var first = _ref2.first,
second = _ref2.second;
second = _ref2.second;
return {

@@ -272,3 +252,3 @@ paddingTop: first,

var first = _ref3.first,
second = _ref3.second;
second = _ref3.second;
return {

@@ -295,3 +275,2 @@ paddingRight: first,

};
var sortTransformOriginPair = function sortTransformOriginPair(a, b) {

@@ -302,3 +281,2 @@ if (Y_AXIS_SHORTHANDS[a]) return 1;

};
var getTransformOriginPair = function getTransformOriginPair(values) {

@@ -308,5 +286,5 @@ if (!values || values.length === 0) return ['center', 'center'];

return pair.sort(sortTransformOriginPair);
}; // Transforms shorthand transformOrigin values
};
// Transforms shorthand transformOrigin values
var expandTransformOrigin = function expandTransformOrigin(key, value) {

@@ -358,2 +336,3 @@ var match = ("" + value).split(' ');

};
/**

@@ -366,8 +345,7 @@ * Transforms style key-value

*/
var expandStyle = function expandStyle(key, value) {
var _ref;
return shorthands[key] ? shorthands[key](key, value) : (_ref = {}, _ref[key] = value, _ref);
};
/**

@@ -379,4 +357,2 @@ * Expand the shorthand properties.

*/
var expand = function expand(style) {

@@ -386,3 +362,2 @@ if (!style) return style;

var resolvedStyle = {};
for (var i = 0; i < propsArray.length; i += 1) {

@@ -393,3 +368,2 @@ var key = propsArray[i];

var keys = Object.keys(extended);
for (var j = 0; j < keys.length; j += 1) {

@@ -401,3 +375,2 @@ var propName = keys[j];

}
return resolvedStyle;

@@ -412,6 +385,6 @@ };

*/
var compact = function compact(array) {
return array.filter(Boolean);
};
/**

@@ -423,4 +396,2 @@ * Merges style objects array

*/
var mergeStyles = function mergeStyles(styles) {

@@ -437,2 +408,3 @@ return styles.reduce(function (acc, style) {

};
/**

@@ -444,4 +416,2 @@ * Flattens an array of style objects, into one aggregated style object.

*/
var flatten = compose(mergeStyles, compact, castArray);

@@ -465,2 +435,3 @@

};
/**

@@ -473,4 +444,2 @@ * Transform given scalar value

*/
var transformUnit = function transformUnit(container, value) {

@@ -481,19 +450,13 @@ var scalar = parseValue(value);

var cmFactor = 1 / 2.54 * dpi;
switch (scalar.unit) {
case 'in':
return scalar.value * dpi;
case 'mm':
return scalar.value * mmFactor;
case 'cm':
return scalar.value * cmFactor;
case 'vh':
return scalar.value * (container.height / 100);
case 'vw':
return scalar.value * (container.width / 100);
default:

@@ -507,6 +470,6 @@ return scalar.value;

};
var isHsl = function isHsl(value) {
return /hsla?/g.test(value);
};
/**

@@ -518,4 +481,2 @@ * Transform rgb color to hexa

*/
var parseRgb = function parseRgb(value) {

@@ -525,2 +486,3 @@ var rgb = colorString.get.rgb(value);

};
/**

@@ -532,4 +494,2 @@ * Transform Hsl color to hexa

*/
var parseHsl = function parseHsl(value) {

@@ -540,2 +500,3 @@ var hsl = colorString.get.hsl(value).map(Math.round);

};
/**

@@ -547,4 +508,2 @@ * Transform given color to hexa

*/
var transformColor = function transformColor(value) {

@@ -557,18 +516,15 @@ if (isRgb(value)) return parseRgb(value);

var parse = function parse(transformString) {
var transforms = transformString.trim().split(/\) |\)/); // Handle "initial", "inherit", "unset".
var transforms = transformString.trim().split(/\) |\)/);
// Handle "initial", "inherit", "unset".
if (transforms.length === 1) {
return [[transforms[0], true]];
}
var parsed = [];
for (var i = 0; i < transforms.length; i += 1) {
var transform = transforms[i];
if (transform) {
var _transform$split = transform.split('('),
name = _transform$split[0],
rawValue = _transform$split[1];
name = _transform$split[0],
rawValue = _transform$split[1];
var splitChar = rawValue.indexOf(',') >= 0 ? ',' : ' ';

@@ -584,21 +540,15 @@ var value = rawValue.split(splitChar).map(function (val) {

}
return parsed;
};
var parseAngle = function parseAngle(value) {
var unitsRegexp = /(-?\d*\.?\d*)(\w*)?/i;
var _unitsRegexp$exec = unitsRegexp.exec(value),
angle = _unitsRegexp$exec[1],
unit = _unitsRegexp$exec[2];
angle = _unitsRegexp$exec[1],
unit = _unitsRegexp$exec[2];
var number = Number.parseFloat(angle);
return unit === 'rad' ? number * 180 / Math.PI : number;
};
var normalizeTransformOperation = function normalizeTransformOperation(_ref) {
var operation = _ref.operation,
value = _ref.value;
value = _ref.value;
switch (operation) {

@@ -608,8 +558,7 @@ case 'scale':

var _value$map = value.map(function (num) {
return Number.parseFloat(num);
}),
scaleX = _value$map[0],
_value$map$ = _value$map[1],
scaleY = _value$map$ === void 0 ? scaleX : _value$map$;
return Number.parseFloat(num);
}),
scaleX = _value$map[0],
_value$map$ = _value$map[1],
scaleY = _value$map$ === void 0 ? scaleX : _value$map$;
return {

@@ -620,3 +569,2 @@ operation: 'scale',

}
case 'scaleX':

@@ -629,3 +577,2 @@ {

}
case 'scaleY':

@@ -638,3 +585,2 @@ {

}
case 'rotate':

@@ -647,3 +593,2 @@ {

}
case 'translate':

@@ -658,3 +603,2 @@ {

}
case 'translateX':

@@ -667,3 +611,2 @@ {

}
case 'translateY':

@@ -676,3 +619,2 @@ {

}
case 'skew':

@@ -685,3 +627,2 @@ {

}
case 'skewX':

@@ -694,3 +635,2 @@ {

}
case 'skewY':

@@ -703,3 +643,2 @@ {

}
default:

@@ -716,3 +655,2 @@ {

};
var normalize = function normalize(operations) {

@@ -723,3 +661,2 @@ return operations.map(function (operation) {

};
var processTransform = function processTransform(value) {

@@ -746,3 +683,2 @@ if (typeof value !== 'string') return value;

};
var processFontWeight = function processFontWeight(value) {

@@ -759,3 +695,2 @@ if (!value) return FONT_WEIGHTS.normal;

};
var castFloat = function castFloat(value) {

@@ -772,10 +707,7 @@ if (typeof value !== 'string') return value;

return '0%';
case 'right':
case 'bottom':
return '100%';
case 'center':
return '50%';
default:

@@ -802,3 +734,2 @@ return null;

};
var transformStyle = function transformStyle(key, value, container) {

@@ -808,2 +739,3 @@ var result = handlers[key] ? handlers[key](value) : value;

};
/**

@@ -815,4 +747,2 @@ * Transform styles values

*/
var transform = function transform(container) {

@@ -823,3 +753,2 @@ return function (style) {

var resolvedStyle = {};
for (var i = 0; i < propsArray.length; i += 1) {

@@ -831,3 +760,2 @@ var key = propsArray[i];

}
return resolvedStyle;

@@ -843,13 +771,9 @@ };

*/
var resolveMediaQueries = function resolveMediaQueries(container, styles) {
return Object.keys(styles).reduce(function (acc, key) {
var _extends2;
if (/@media/.test(key)) {
var _matchMedia;
return _extends({}, acc, matchMedia((_matchMedia = {}, _matchMedia[key] = styles[key], _matchMedia), container));
}
return _extends({}, acc, (_extends2 = {}, _extends2[key] = styles[key], _extends2));

@@ -866,3 +790,2 @@ }, {});

*/
var resolveStyles = function resolveStyles(container, style) {

@@ -872,6 +795,5 @@ var computeMediaQueries = function computeMediaQueries(value) {

};
return compose(transform(container), expand, computeMediaQueries, flatten)(style);
}; // Utils exported for SVG processing
};
export { resolveStyles as default, flatten, processTransform, transformColor };
{
"name": "@react-pdf/stylesheet",
"version": "4.1.2",
"version": "4.1.3",
"license": "MIT",

@@ -21,3 +21,3 @@ "description": "A styles engine for Node and the browser",

"dependencies": {
"@babel/runtime": "^7.16.4",
"@babel/runtime": "^7.20.13",
"@react-pdf/fns": "2.0.0",

@@ -24,0 +24,0 @@ "@react-pdf/types": "^2.2.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc