@ctrl/tinycolor 3.2.0 → 3.3.2
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/README.md +11 -1
- package/dist/bundles/tinycolor.umd.min.js.map +1 -1
- package/dist/conversion.js +32 -32
- package/dist/css-color-names.d.ts +1 -3
- package/dist/format-input.js +20 -20
- package/dist/from-ratio.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +183 -159
- package/dist/module/index.js +6 -3
- package/dist/public_api.js +1 -1
- package/dist/random.js +39 -37
- package/dist/readability.js +15 -12
- package/dist/to-ms-filter.js +8 -8
- package/dist/umd_api.js +8 -8
- package/dist/util.js +2 -2
- package/package.json +13 -13
package/dist/format-input.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isValidCSSUnit = exports.stringInputToObject = exports.inputToRGB = void 0;
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
var conversion_1 = require("./conversion");
|
5
|
+
var css_color_names_1 = require("./css-color-names");
|
6
|
+
var util_1 = require("./util");
|
7
7
|
/**
|
8
8
|
* Given a string or object, convert that input to RGB
|
9
9
|
*
|
@@ -23,13 +23,13 @@ const util_1 = require("./util");
|
|
23
23
|
* ```
|
24
24
|
*/
|
25
25
|
function inputToRGB(color) {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
27
|
+
var a = 1;
|
28
|
+
var s = null;
|
29
|
+
var v = null;
|
30
|
+
var l = null;
|
31
|
+
var ok = false;
|
32
|
+
var format = false;
|
33
33
|
if (typeof color === 'string') {
|
34
34
|
color = stringInputToObject(color);
|
35
35
|
}
|
@@ -59,27 +59,27 @@ function inputToRGB(color) {
|
|
59
59
|
}
|
60
60
|
a = util_1.boundAlpha(a);
|
61
61
|
return {
|
62
|
-
ok,
|
62
|
+
ok: ok,
|
63
63
|
format: color.format || format,
|
64
64
|
r: Math.min(255, Math.max(rgb.r, 0)),
|
65
65
|
g: Math.min(255, Math.max(rgb.g, 0)),
|
66
66
|
b: Math.min(255, Math.max(rgb.b, 0)),
|
67
|
-
a,
|
67
|
+
a: a,
|
68
68
|
};
|
69
69
|
}
|
70
70
|
exports.inputToRGB = inputToRGB;
|
71
71
|
// <http://www.w3.org/TR/css3-values/#integers>
|
72
|
-
|
72
|
+
var CSS_INTEGER = '[-\\+]?\\d+%?';
|
73
73
|
// <http://www.w3.org/TR/css3-values/#number-value>
|
74
|
-
|
74
|
+
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
|
75
75
|
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
76
|
-
|
76
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
77
77
|
// Actual matching.
|
78
78
|
// Parentheses and commas are optional, but not required.
|
79
79
|
// Whitespace can take the place of commas or opening paren
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
81
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
82
|
+
var matchers = {
|
83
83
|
CSS_UNIT: new RegExp(CSS_UNIT),
|
84
84
|
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
|
85
85
|
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
|
@@ -101,7 +101,7 @@ function stringInputToObject(color) {
|
|
101
101
|
if (color.length === 0) {
|
102
102
|
return false;
|
103
103
|
}
|
104
|
-
|
104
|
+
var named = false;
|
105
105
|
if (css_color_names_1.names[color]) {
|
106
106
|
color = css_color_names_1.names[color];
|
107
107
|
named = true;
|
@@ -113,7 +113,7 @@ function stringInputToObject(color) {
|
|
113
113
|
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
114
114
|
// Just return an object and let the conversion functions handle that.
|
115
115
|
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
116
|
-
|
116
|
+
var match = matchers.rgb.exec(color);
|
117
117
|
if (match) {
|
118
118
|
return { r: match[1], g: match[2], b: match[3] };
|
119
119
|
}
|
package/dist/from-ratio.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.legacyRandom = exports.fromRatio = void 0;
|
4
|
-
|
5
|
-
|
4
|
+
var index_1 = require("./index");
|
5
|
+
var util_1 = require("./util");
|
6
6
|
/**
|
7
7
|
* If input is an object, force 1 into "1.0" to handle ratios properly
|
8
8
|
* String input requires "1.0" as input, so 1 will be treated as 1
|
9
9
|
*/
|
10
10
|
function fromRatio(ratio, opts) {
|
11
|
-
|
11
|
+
var newColor = {
|
12
12
|
r: util_1.convertToPercentage(ratio.r),
|
13
13
|
g: util_1.convertToPercentage(ratio.g),
|
14
14
|
b: util_1.convertToPercentage(ratio.b),
|
package/dist/index.d.ts
CHANGED