@ctrl/tinycolor 3.5.1 → 3.6.1
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 +12 -0
- package/dist/bundles/tinycolor.umd.min.js +1 -1
- package/dist/bundles/tinycolor.umd.min.js.map +1 -1
- package/dist/conversion.d.ts +1 -1
- package/dist/conversion.js +27 -27
- package/dist/format-input.d.ts +1 -1
- package/dist/format-input.js +27 -27
- package/dist/from-ratio.d.ts +1 -1
- package/dist/from-ratio.js +7 -7
- package/dist/index.d.ts +8 -3
- package/dist/index.js +29 -21
- package/dist/module/conversion.js +1 -1
- package/dist/module/format-input.js +3 -3
- package/dist/module/from-ratio.js +2 -2
- package/dist/module/index.js +13 -5
- package/dist/module/public_api.js +10 -10
- package/dist/module/random.js +1 -1
- package/dist/module/readability.js +1 -1
- package/dist/module/to-ms-filter.js +2 -2
- package/dist/module/umd_api.js +7 -7
- package/dist/public_api.d.ts +10 -10
- package/dist/public_api.js +11 -11
- package/dist/random.d.ts +1 -1
- package/dist/random.js +3 -3
- package/dist/readability.d.ts +1 -1
- package/dist/readability.js +4 -4
- package/dist/to-ms-filter.d.ts +1 -1
- package/dist/to-ms-filter.js +6 -6
- package/dist/umd_api.d.ts +7 -7
- package/dist/umd_api.js +19 -19
- package/package.json +5 -2
package/dist/public_api.js
CHANGED
@@ -14,15 +14,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
var
|
18
|
-
__exportStar(require("./index"), exports);
|
19
|
-
__exportStar(require("./css-color-names"), exports);
|
20
|
-
__exportStar(require("./readability"), exports);
|
21
|
-
__exportStar(require("./to-ms-filter"), exports);
|
22
|
-
__exportStar(require("./from-ratio"), exports);
|
23
|
-
__exportStar(require("./format-input"), exports);
|
24
|
-
__exportStar(require("./random"), exports);
|
25
|
-
__exportStar(require("./interfaces"), exports);
|
26
|
-
__exportStar(require("./conversion"), exports);
|
17
|
+
var index_js_1 = require("./index.js");
|
18
|
+
__exportStar(require("./index.js"), exports);
|
19
|
+
__exportStar(require("./css-color-names.js"), exports);
|
20
|
+
__exportStar(require("./readability.js"), exports);
|
21
|
+
__exportStar(require("./to-ms-filter.js"), exports);
|
22
|
+
__exportStar(require("./from-ratio.js"), exports);
|
23
|
+
__exportStar(require("./format-input.js"), exports);
|
24
|
+
__exportStar(require("./random.js"), exports);
|
25
|
+
__exportStar(require("./interfaces.js"), exports);
|
26
|
+
__exportStar(require("./conversion.js"), exports);
|
27
27
|
// kept for backwards compatability with v1
|
28
|
-
exports.default =
|
28
|
+
exports.default = index_js_1.tinycolor;
|
package/dist/random.d.ts
CHANGED
package/dist/random.js
CHANGED
@@ -4,7 +4,7 @@ exports.bounds = exports.random = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
5
5
|
// randomColor by David Merfield under the CC0 license
|
6
6
|
// https://github.com/davidmerfield/randomColor/
|
7
|
-
var
|
7
|
+
var index_js_1 = require("./index.js");
|
8
8
|
function random(options) {
|
9
9
|
if (options === void 0) { options = {}; }
|
10
10
|
// Check if we need to generate multiple colors
|
@@ -37,7 +37,7 @@ function random(options) {
|
|
37
37
|
res.a = options.alpha;
|
38
38
|
}
|
39
39
|
// Then we return the HSB color in the desired format
|
40
|
-
return new
|
40
|
+
return new index_js_1.TinyColor(res);
|
41
41
|
}
|
42
42
|
exports.random = random;
|
43
43
|
function pickHue(hue, seed) {
|
@@ -122,7 +122,7 @@ function getHueRange(colorInput) {
|
|
122
122
|
return color.hueRange;
|
123
123
|
}
|
124
124
|
}
|
125
|
-
var parsed = new
|
125
|
+
var parsed = new index_js_1.TinyColor(colorInput);
|
126
126
|
if (parsed.isValid) {
|
127
127
|
var hue = parsed.toHsv().h;
|
128
128
|
return [hue, hue];
|
package/dist/readability.d.ts
CHANGED
package/dist/readability.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.mostReadable = exports.isReadable = exports.readability = void 0;
|
4
|
-
var
|
4
|
+
var index_js_1 = require("./index.js");
|
5
5
|
// Readability Functions
|
6
6
|
// ---------------------
|
7
7
|
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
|
@@ -11,8 +11,8 @@ var index_1 = require("./index");
|
|
11
11
|
* Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
|
12
12
|
*/
|
13
13
|
function readability(color1, color2) {
|
14
|
-
var c1 = new
|
15
|
-
var c2 = new
|
14
|
+
var c1 = new index_js_1.TinyColor(color1);
|
15
|
+
var c2 = new index_js_1.TinyColor(color2);
|
16
16
|
return ((Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) /
|
17
17
|
(Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05));
|
18
18
|
}
|
@@ -74,7 +74,7 @@ function mostReadable(baseColor, colorList, args) {
|
|
74
74
|
var score = readability(baseColor, color);
|
75
75
|
if (score > bestScore) {
|
76
76
|
bestScore = score;
|
77
|
-
bestColor = new
|
77
|
+
bestColor = new index_js_1.TinyColor(color);
|
78
78
|
}
|
79
79
|
}
|
80
80
|
if (isReadable(baseColor, bestColor, { level: level, size: size }) || !includeFallbackColors) {
|
package/dist/to-ms-filter.d.ts
CHANGED
package/dist/to-ms-filter.js
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.toMsFilter = void 0;
|
4
|
-
var
|
5
|
-
var
|
4
|
+
var conversion_js_1 = require("./conversion.js");
|
5
|
+
var index_js_1 = require("./index.js");
|
6
6
|
/**
|
7
7
|
* Returns the color represented as a Microsoft filter for use in old versions of IE.
|
8
8
|
*/
|
9
9
|
function toMsFilter(firstColor, secondColor) {
|
10
|
-
var color = new
|
11
|
-
var hex8String = '#' + (0,
|
10
|
+
var color = new index_js_1.TinyColor(firstColor);
|
11
|
+
var hex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(color.r, color.g, color.b, color.a);
|
12
12
|
var secondHex8String = hex8String;
|
13
13
|
var gradientType = color.gradientType ? 'GradientType = 1, ' : '';
|
14
14
|
if (secondColor) {
|
15
|
-
var s = new
|
16
|
-
secondHex8String = '#' + (0,
|
15
|
+
var s = new index_js_1.TinyColor(secondColor);
|
16
|
+
secondHex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(s.r, s.g, s.b, s.a);
|
17
17
|
}
|
18
18
|
return "progid:DXImageTransform.Microsoft.gradient(".concat(gradientType, "startColorstr=").concat(hex8String, ",endColorstr=").concat(secondHex8String, ")");
|
19
19
|
}
|
package/dist/umd_api.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import { names } from './css-color-names';
|
2
|
-
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input';
|
3
|
-
import { fromRatio, legacyRandom } from './from-ratio';
|
4
|
-
import { TinyColor } from './index';
|
5
|
-
import { random } from './random';
|
6
|
-
import { mostReadable, readability } from './readability';
|
7
|
-
import { toMsFilter } from './to-ms-filter';
|
1
|
+
import { names } from './css-color-names.js';
|
2
|
+
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input.js';
|
3
|
+
import { fromRatio, legacyRandom } from './from-ratio.js';
|
4
|
+
import { TinyColor } from './index.js';
|
5
|
+
import { random } from './random.js';
|
6
|
+
import { mostReadable, readability } from './readability.js';
|
7
|
+
import { toMsFilter } from './to-ms-filter.js';
|
8
8
|
export interface TinyColorUMD {
|
9
9
|
(): TinyColor;
|
10
10
|
TinyColor: typeof TinyColor;
|
package/dist/umd_api.js
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
var
|
4
|
-
var
|
5
|
-
var
|
6
|
-
var
|
7
|
-
var
|
8
|
-
var
|
9
|
-
var
|
10
|
-
var tinycolorumd =
|
11
|
-
tinycolorumd.TinyColor =
|
12
|
-
tinycolorumd.readability =
|
13
|
-
tinycolorumd.mostReadable =
|
14
|
-
tinycolorumd.random =
|
15
|
-
tinycolorumd.names =
|
16
|
-
tinycolorumd.fromRatio =
|
17
|
-
tinycolorumd.legacyRandom =
|
18
|
-
tinycolorumd.toMsFilter =
|
19
|
-
tinycolorumd.inputToRGB =
|
20
|
-
tinycolorumd.stringInputToObject =
|
21
|
-
tinycolorumd.isValidCSSUnit =
|
3
|
+
var css_color_names_js_1 = require("./css-color-names.js");
|
4
|
+
var format_input_js_1 = require("./format-input.js");
|
5
|
+
var from_ratio_js_1 = require("./from-ratio.js");
|
6
|
+
var index_js_1 = require("./index.js");
|
7
|
+
var random_js_1 = require("./random.js");
|
8
|
+
var readability_js_1 = require("./readability.js");
|
9
|
+
var to_ms_filter_js_1 = require("./to-ms-filter.js");
|
10
|
+
var tinycolorumd = index_js_1.tinycolor;
|
11
|
+
tinycolorumd.TinyColor = index_js_1.TinyColor;
|
12
|
+
tinycolorumd.readability = readability_js_1.readability;
|
13
|
+
tinycolorumd.mostReadable = readability_js_1.mostReadable;
|
14
|
+
tinycolorumd.random = random_js_1.random;
|
15
|
+
tinycolorumd.names = css_color_names_js_1.names;
|
16
|
+
tinycolorumd.fromRatio = from_ratio_js_1.fromRatio;
|
17
|
+
tinycolorumd.legacyRandom = from_ratio_js_1.legacyRandom;
|
18
|
+
tinycolorumd.toMsFilter = to_ms_filter_js_1.toMsFilter;
|
19
|
+
tinycolorumd.inputToRGB = format_input_js_1.inputToRGB;
|
20
|
+
tinycolorumd.stringInputToObject = format_input_js_1.stringInputToObject;
|
21
|
+
tinycolorumd.isValidCSSUnit = format_input_js_1.isValidCSSUnit;
|
22
22
|
exports.default = tinycolorumd;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ctrl/tinycolor",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.6.1",
|
4
4
|
"description": "Fast, small color manipulation and conversion for JavaScript",
|
5
5
|
"author": "Scott Cooper <scttcper@gmail.com>",
|
6
6
|
"publishConfig": {
|
@@ -58,7 +58,10 @@
|
|
58
58
|
},
|
59
59
|
"jest": {
|
60
60
|
"testEnvironment": "node",
|
61
|
-
"coverageProvider": "v8"
|
61
|
+
"coverageProvider": "v8",
|
62
|
+
"moduleNameMapper": {
|
63
|
+
"(.+)\\.js": "$1"
|
64
|
+
}
|
62
65
|
},
|
63
66
|
"babel": {
|
64
67
|
"presets": [
|