@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.
@@ -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
- const conversion_1 = require("./conversion");
5
- const css_color_names_1 = require("./css-color-names");
6
- const util_1 = require("./util");
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
- let rgb = { r: 0, g: 0, b: 0 };
27
- let a = 1;
28
- let s = null;
29
- let v = null;
30
- let l = null;
31
- let ok = false;
32
- let format = false;
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
- const CSS_INTEGER = '[-\\+]?\\d+%?';
72
+ var CSS_INTEGER = '[-\\+]?\\d+%?';
73
73
  // <http://www.w3.org/TR/css3-values/#number-value>
74
- const CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
74
+ var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
75
75
  // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
76
- const CSS_UNIT = `(?:${CSS_NUMBER})|(?:${CSS_INTEGER})`;
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
- const PERMISSIVE_MATCH3 = `[\\s|\\(]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})\\s*\\)?`;
81
- const PERMISSIVE_MATCH4 = `[\\s|\\(]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})\\s*\\)?`;
82
- const matchers = {
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
- let named = false;
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
- let match = matchers.rgb.exec(color);
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
  }
@@ -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
- const index_1 = require("./index");
5
- const util_1 = require("./util");
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
- const newColor = {
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
@@ -43,7 +43,7 @@ export declare class TinyColor {
43
43
  *
44
44
  * @param alpha - The new alpha value. The accepted range is 0-1.
45
45
  */
46
- setAlpha(alpha?: string | number): TinyColor;
46
+ setAlpha(alpha?: string | number): this;
47
47
  /**
48
48
  * Returns the object as a HSVA object.
49
49
  */