@react-pdf/stylesheet 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/transform/units.js +6 -7
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @react-pdf/stylesheet
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1869](https://github.com/diegomura/react-pdf/pull/1869) [`5d2c308`](https://github.com/diegomura/react-pdf/commit/5d2c3088cf438a8abf1038b14a21117fecf59d57) Thanks [@diegomura](https://github.com/diegomura)! - feat: variable dpi
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`1411d16`](https://github.com/diegomura/react-pdf/commit/1411d162e04ca237bad93729695c363fdf4bdbeb), [`4fadb48`](https://github.com/diegomura/react-pdf/commit/4fadb48983d7269452f89f80c7e341ece859aaee), [`ce8762f`](https://github.com/diegomura/react-pdf/commit/ce8762f6de5c796e69ec5a225c7f3ff9c619a960), [`5d2c308`](https://github.com/diegomura/react-pdf/commit/5d2c3088cf438a8abf1038b14a21117fecf59d57)]:
|
|
12
|
+
- @react-pdf/types@2.1.0
|
|
13
|
+
|
|
3
14
|
## 3.0.0
|
|
4
15
|
|
|
5
16
|
### Major Changes
|
package/lib/transform/units.js
CHANGED
|
@@ -2,17 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
-
var DPI = 72; // 72pt per inch.
|
|
6
5
|
|
|
7
|
-
var MM_FACTOR = 1 / 25.4 * DPI;
|
|
8
|
-
var CM_FACTOR = 1 / 2.54 * DPI;
|
|
9
6
|
/**
|
|
10
7
|
* Parses scalar value in value and unit pairs
|
|
11
8
|
*
|
|
12
9
|
* @param {String} scalar value
|
|
13
10
|
* @returns {Object} parsed value
|
|
14
11
|
*/
|
|
15
|
-
|
|
16
12
|
var parseValue = function parseValue(value) {
|
|
17
13
|
var match = /^(-?\d*\.?\d+)(in|mm|cm|pt|vh|vw|px)?$/g.exec(value);
|
|
18
14
|
return match ? {
|
|
@@ -34,16 +30,19 @@ var parseValue = function parseValue(value) {
|
|
|
34
30
|
|
|
35
31
|
var transformUnit = function transformUnit(container, value) {
|
|
36
32
|
var scalar = parseValue(value);
|
|
33
|
+
var dpi = container.dpi || 72;
|
|
34
|
+
var mmFactor = 1 / 25.4 * dpi;
|
|
35
|
+
var cmFactor = 1 / 2.54 * dpi;
|
|
37
36
|
|
|
38
37
|
switch (scalar.unit) {
|
|
39
38
|
case 'in':
|
|
40
|
-
return scalar.value *
|
|
39
|
+
return scalar.value * dpi;
|
|
41
40
|
|
|
42
41
|
case 'mm':
|
|
43
|
-
return scalar.value *
|
|
42
|
+
return scalar.value * mmFactor;
|
|
44
43
|
|
|
45
44
|
case 'cm':
|
|
46
|
-
return scalar.value *
|
|
45
|
+
return scalar.value * cmFactor;
|
|
47
46
|
|
|
48
47
|
case 'vh':
|
|
49
48
|
return scalar.value * (container.height / 100);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-pdf/stylesheet",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A styles engine for Node and the browser",
|
|
6
6
|
"author": "Diego Muracciole <diegomuracciole@gmail.com>",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.16.4",
|
|
21
21
|
"@react-pdf/fns": "1.0.0",
|
|
22
|
-
"@react-pdf/types": "^2.0
|
|
22
|
+
"@react-pdf/types": "^2.1.0",
|
|
23
23
|
"color-string": "^1.5.3",
|
|
24
24
|
"hsl-to-hex": "^1.0.0",
|
|
25
25
|
"media-engine": "^1.0.3",
|