This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

7
node_modules/@ctrl/tinycolor/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright (c) Scott Cooper <scttcper@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

689
node_modules/@ctrl/tinycolor/README.md generated vendored Normal file
View File

@@ -0,0 +1,689 @@
# tinycolor
[![npm](https://badgen.net/npm/v/@ctrl/tinycolor)](https://www.npmjs.com/package/@ctrl/tinycolor)
[![CircleCI](https://badgen.net/circleci/github/scttcper/tinycolor)](https://circleci.com/gh/scttcper/tinycolor)
[![coverage](https://badgen.net/codecov/c/github/scttcper/tinycolor)](https://codecov.io/gh/scttcper/tinycolor)
[![bundlesize](https://badgen.net/bundlephobia/min/@ctrl/tinycolor)](https://bundlephobia.com/result?p=@ctrl/tinycolor)
> TinyColor is a small library for color manipulation and conversion
A fork of [tinycolor2](https://github.com/bgrins/TinyColor) by [Brian Grinstead](https://github.com/bgrins)
__DEMO__: https://tinycolor.vercel.app
### Changes from tinycolor2
* reformatted into TypeScript / es2015 and requires node >= 8
* tree shakeable "module" export and no package `sideEffects`
* `tinycolor` is now exported as a class called `TinyColor`
* new `random`, an implementation of [randomColor](https://github.com/davidmerfield/randomColor/) by David Merfield that returns a TinyColor object
* several functions moved out of the tinycolor class and are no longer `TinyColor.<function>`
* `readability`, `fromRatio` moved out
* `random` moved out and renamed to `legacyRandom`
* `toFilter` has been moved out and renamed to `toMsFilter`
* `mix`, `equals` use the current TinyColor object as the first parameter
* added polyad colors tinycolor PR [126](https://github.com/bgrins/TinyColor/pull/126)
* color wheel values (360) are allowed to over or under-spin and still return valid colors tinycolor PR [108](https://github.com/bgrins/TinyColor/pull/108)
* added `tint()` and `shade()` tinycolor PR [159](https://github.com/bgrins/TinyColor/pull/159)
* `isValid`, `format` are now propertys instead of a function
## Install
```sh
npm install @ctrl/tinycolor
```
## Use
```ts
import { TinyColor } from '@ctrl/tinycolor';
const color = new TinyColor('red').toHexString(); // '#ff0000'
```
## Accepted String Input
The string parsing is very permissive. It is meant to make typing a color as input as easy as possible. All commas, percentages, parenthesis are optional, and most input allow either 0-1, 0%-100%, or 0-n (where n is either 100, 255, or 360 depending on the value).
HSL and HSV both require either 0%-100% or 0-1 for the `S`/`L`/`V` properties. The `H` (hue) can have values between 0%-100% or 0-360.
RGB input requires either 0-255 or 0%-100%.
If you call `tinycolor.fromRatio`, RGB and Hue input can also accept 0-1.
Here are some examples of string input:
### Hex, 8-digit (RGBA) Hex
```ts
new TinyColor('#000');
new TinyColor('000');
new TinyColor('#369C');
new TinyColor('369C');
new TinyColor('#f0f0f6');
new TinyColor('f0f0f6');
new TinyColor('#f0f0f688');
new TinyColor('f0f0f688');
```
### RGB, RGBA
```ts
new TinyColor('rgb (255, 0, 0)');
new TinyColor('rgb 255 0 0');
new TinyColor('rgba (255, 0, 0, .5)');
new TinyColor({ r: 255, g: 0, b: 0 });
import { fromRatio } from '@ctrl/tinycolor';
fromRatio({ r: 1, g: 0, b: 0 });
fromRatio({ r: 0.5, g: 0.5, b: 0.5 });
```
### HSL, HSLA
```ts
new TinyColor('hsl(0, 100%, 50%)');
new TinyColor('hsla(0, 100%, 50%, .5)');
new TinyColor('hsl(0, 100%, 50%)');
new TinyColor('hsl 0 1.0 0.5');
new TinyColor({ h: 0, s: 1, l: 0.5 });
```
### HSV, HSVA
```ts
new TinyColor('hsv(0, 100%, 100%)');
new TinyColor('hsva(0, 100%, 100%, .5)');
new TinyColor('hsv (0 100% 100%)');
new TinyColor('hsv 0 1 1');
new TinyColor({ h: 0, s: 100, v: 100 });
```
### Named
```ts
new TinyColor('RED');
new TinyColor('blanchedalmond');
new TinyColor('darkblue');
```
### Number
```ts
new TinyColor(0x0);
new TinyColor(0xaabbcc);
```
### Accepted Object Input
If you are calling this from code, you may want to use object input. Here are some examples of the different types of accepted object inputs:
```ts
{ r: 255, g: 0, b: 0 }
{ r: 255, g: 0, b: 0, a: .5 }
{ h: 0, s: 100, l: 50 }
{ h: 0, s: 100, v: 100 }
```
## Properties
### originalInput
The original input passed into the constructer used to create the tinycolor instance
```ts
const color = new TinyColor('red');
color.originalInput; // "red"
color = new TinyColor({ r: 255, g: 255, b: 255 });
color.originalInput; // "{r: 255, g: 255, b: 255}"
```
### format
Returns the format used to create the tinycolor instance
```ts
const color = new TinyColor('red');
color.format; // "name"
color = new TinyColor({ r: 255, g: 255, b: 255 });
color.format; // "rgb"
```
### isValid
A boolean indicating whether the color was successfully parsed. Note: if the color is not valid then it will act like `black` when being used with other methods.
```ts
const color1 = new TinyColor('red');
color1.isValid; // true
color1.toHexString(); // "#ff0000"
const color2 = new TinyColor('not a color');
color2.isValid; // false
color2.toString(); // "#000000"
```
## Methods
### getBrightness
Returns the perceived brightness of a color, from `0-255`, as defined by [Web Content Accessibility Guidelines (Version 1.0)](http://www.w3.org/TR/AERT#color-contrast).
```ts
const color1 = new TinyColor('#fff');
color1.getBrightness(); // 255
const color2 = new TinyColor('#000');
color2.getBrightness(); // 0
```
### isLight
Return a boolean indicating whether the color's perceived brightness is light.
```ts
const color1 = new TinyColor('#fff');
color1.isLight(); // true
const color2 = new TinyColor('#000');
color2.isLight(); // false
```
### isDark
Return a boolean indicating whether the color's perceived brightness is dark.
```ts
const color1 = new TinyColor('#fff');
color1.isDark(); // false
const color2 = new TinyColor('#000');
color2.isDark(); // true
```
### getLuminance
Returns the perceived luminance of a color, from `0-1` as defined by [Web Content Accessibility Guidelines (Version 2.0).](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef)
```ts
const color1 = new TinyColor('#fff');
color1.getLuminance(); // 1
const color2 = new TinyColor('#000');
color2.getLuminance(); // 0
```
### getAlpha
Returns the alpha value of a color, from `0-1`.
```ts
const color1 = new TinyColor('rgba(255, 0, 0, .5)');
color1.getAlpha(); // 0.5
const color2 = new TinyColor('rgb(255, 0, 0)');
color2.getAlpha(); // 1
const color3 = new TinyColor('transparent');
color3.getAlpha(); // 0
```
### setAlpha
Sets the alpha value on a current color. Accepted range is in between `0-1`.
```ts
const color = new TinyColor('red');
color.getAlpha(); // 1
color.setAlpha(0.5);
color.getAlpha(); // .5
color.toRgbString(); // "rgba(255, 0, 0, .5)"
```
### onBackground
Compute how the color would appear on a background. When the color is fully transparent (i.e. `getAlpha() == 0`), the result will be the background color. When the color is not transparent at all (i.e. `getAlpha() == 1`), the result will be the color itself. Otherwise you will get a computed result.
```ts
const color = new TinyColor('rgba(255, 0, 0, .5)');
const computedColor = color.onBackground('rgb(0, 0, 255)');
computedColor.toRgbString(); // "rgb(128, 0, 128)"
```
### String Representations
The following methods will return a property for the `alpha` value, which can be ignored: `toHsv`, `toHsl`, `toRgb`
### toHsv
```ts
const color = new TinyColor('red');
color.toHsv(); // { h: 0, s: 1, v: 1, a: 1 }
```
### toHsvString
```ts
const color = new TinyColor('red');
color.toHsvString(); // "hsv(0, 100%, 100%)"
color.setAlpha(0.5);
color.toHsvString(); // "hsva(0, 100%, 100%, 0.5)"
```
### toHsl
```ts
const color = new TinyColor('red');
color.toHsl(); // { h: 0, s: 1, l: 0.5, a: 1 }
```
### toHslString
```ts
const color = new TinyColor('red');
color.toHslString(); // "hsl(0, 100%, 50%)"
color.setAlpha(0.5);
color.toHslString(); // "hsla(0, 100%, 50%, 0.5)"
```
### toNumber
```ts
new TinyColor('#aabbcc').toNumber() === 0xaabbcc // true
new TinyColor('rgb(1, 1, 1)').toNumber() === (1 << 16) + (1 << 8) + 1 // true
```
### toHex
```ts
const color = new TinyColor('red');
color.toHex(); // "ff0000"
```
### toHexString
```ts
const color = new TinyColor('red');
color.toHexString(); // "#ff0000"
```
### toHex8
```ts
const color = new TinyColor('red');
color.toHex8(); // "ff0000ff"
```
### toHex8String
```ts
const color = new TinyColor('red');
color.toHex8String(); // "#ff0000ff"
```
### toHexShortString
```ts
const color1 = new TinyColor('#ff000000');
color1.toHexShortString(); // "#ff000000"
color1.toHexShortString(true); // "#f000"
const color2 = new TinyColor('#ff0000ff');
color2.toHexShortString(); // "#ff0000"
color2.toHexShortString(true); // "#f00"
```
### toRgb
```ts
const color = new TinyColor('red');
color.toRgb(); // { r: 255, g: 0, b: 0, a: 1 }
```
### toRgbString
```ts
const color = new TinyColor('red');
color.toRgbString(); // "rgb(255, 0, 0)"
color.setAlpha(0.5);
color.toRgbString(); // "rgba(255, 0, 0, 0.5)"
```
### toPercentageRgb
```ts
const color = new TinyColor('red');
color.toPercentageRgb(); // { r: "100%", g: "0%", b: "0%", a: 1 }
```
### toPercentageRgbString
```ts
const color = new TinyColor('red');
color.toPercentageRgbString(); // "rgb(100%, 0%, 0%)"
color.setAlpha(0.5);
color.toPercentageRgbString(); // "rgba(100%, 0%, 0%, 0.5)"
```
### toName
```ts
const color = new TinyColor('red');
color.toName(); // "red"
```
### toFilter
```ts
import { toMsFilter } from '@ctrl/tinycolor';
toMsFilter('red', 'blue'); // 'progid:DXImageTransform.Microsoft.gradient(startColorstr=#ffff0000,endColorstr=#ff0000ff)'
```
### toString
Print to a string, depending on the input format. You can also override this by passing one of `"rgb", "prgb", "hex6", "hex3", "hex8", "name", "hsl", "hsv"` into the function.
```ts
const color1 = new TinyColor('red');
color1.toString(); // "red"
color1.toString('hsv'); // "hsv(0, 100%, 100%)"
const color2 = new TinyColor('rgb(255, 0, 0)');
color2.toString(); // "rgb(255, 0, 0)"
color2.setAlpha(0.5);
color2.toString(); // "rgba(255, 0, 0, 0.5)"
```
### Color Modification
These methods manipulate the current color, and return it for chaining. For instance:
```ts
new TinyColor('red')
.lighten()
.desaturate()
.toHexString(); // '#f53d3d'
```
### lighten
`lighten: function(amount = 10) -> TinyColor`. Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.
```ts
new TinyColor('#f00').lighten().toString(); // '#ff3333'
new TinyColor('#f00').lighten(100).toString(); // '#ffffff'
```
### brighten
`brighten: function(amount = 10) -> TinyColor`. Brighten the color a given amount, from 0 to 100.
```ts
new TinyColor('#f00').brighten().toString(); // '#ff1919'
```
### darken
`darken: function(amount = 10) -> TinyColor`. Darken the color a given amount, from 0 to 100. Providing 100 will always return black.
```ts
new TinyColor('#f00').darken().toString(); // '#cc0000'
new TinyColor('#f00').darken(100).toString(); // '#000000'
```
### tint
Mix the color with pure white, from 0 to 100. Providing 0 will do nothing, providing 100 will always return white.
```ts
new TinyColor('#f00').tint().toString(); // "#ff1a1a"
new TinyColor('#f00').tint(100).toString(); // "#ffffff"
```
### shade
Mix the color with pure black, from 0 to 100. Providing 0 will do nothing, providing 100 will always return black.
```ts
new TinyColor('#f00').shade().toString(); // "#e60000"
new TinyColor('#f00').shade(100).toString(); // "#000000"
```
### desaturate
`desaturate: function(amount = 10) -> TinyColor`. Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling `greyscale`.
```ts
new TinyColor('#f00').desaturate().toString(); // "#f20d0d"
new TinyColor('#f00').desaturate(100).toString(); // "#808080"
```
### saturate
`saturate: function(amount = 10) -> TinyColor`. Saturate the color a given amount, from 0 to 100.
```ts
new TinyColor('hsl(0, 10%, 50%)').saturate().toString(); // "hsl(0, 20%, 50%)"
```
### greyscale
`greyscale: function() -> TinyColor`. Completely desaturates a color into greyscale. Same as calling `desaturate(100)`.
```ts
new TinyColor('#f00').greyscale().toString(); // "#808080"
```
### spin
`spin: function(amount = 0) -> TinyColor`. Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing (since it sets the hue back to what it was before).
```ts
new TinyColor('#f00').spin(180).toString(); // "#00ffff"
new TinyColor('#f00').spin(-90).toString(); // "#7f00ff"
new TinyColor('#f00').spin(90).toString(); // "#80ff00"
// spin(0) and spin(360) do nothing
new TinyColor('#f00').spin(0).toString(); // "#ff0000"
new TinyColor('#f00').spin(360).toString(); // "#ff0000"
```
### mix
`mix: function(amount = 50) => TinyColor`. Mix the current color a given amount with another color, from 0 to 100. 0 means no mixing (return current color).
```ts
let color1 = new TinyColor('#f0f');
let color2 = new TinyColor('#0f0');
color1.mix(color2).toHexString(); // #808080
```
### Color Combinations
Combination functions return an array of TinyColor objects unless otherwise noted.
### analogous
`analogous: function(results = 6, slices = 30) -> array<TinyColor>`.
```ts
const colors = new TinyColor('#f00').analogous();
colors.map(t => t.toHexString()); // [ "#ff0000", "#ff0066", "#ff0033", "#ff0000", "#ff3300", "#ff6600" ]
```
### monochromatic
`monochromatic: function(, results = 6) -> array<TinyColor>`.
```ts
const colors = new TinyColor('#f00').monochromatic();
colors.map(t => t.toHexString()); // [ "#ff0000", "#2a0000", "#550000", "#800000", "#aa0000", "#d40000" ]
```
### splitcomplement
`splitcomplement: function() -> array<TinyColor>`.
```ts
const colors = new TinyColor('#f00').splitcomplement();
colors.map(t => t.toHexString()); // [ "#ff0000", "#ccff00", "#0066ff" ]
```
### triad
`triad: function() -> array<TinyColor>`. Alias for `polyad(3)`.
```ts
const colors = new TinyColor('#f00').triad();
colors.map(t => t.toHexString()); // [ "#ff0000", "#00ff00", "#0000ff" ]
```
### tetrad
`tetrad: function() -> array<TinyColor>`. Alias for `polyad(4)`.
```ts
const colors = new TinyColor('#f00').tetrad();
colors.map(t => t.toHexString()); // [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ]
```
### polyad
`polyad: function(number) -> array<TinyColor>`.
```ts
const colors = new TinyColor('#f00').polyad(4);
colors.map(t => t.toHexString()); // [ "#ff0000", "#80ff00", "#00ffff", "#7f00ff" ]
```
### complement
`complement: function() -> TinyColor`.
```ts
new TinyColor('#f00').complement().toHexString(); // "#00ffff"
```
## Color Utilities
### equals
```ts
let color1 = new TinyColor('red');
let color2 = new TinyColor('#f00');
color1.equals(color2); // true
```
### random
Returns a random TinyColor object. This is an implementation of [randomColor](https://github.com/davidmerfield/randomColor/) by David Merfield.
The difference input parsing and output formatting are handled by TinyColor.
You can pass an options object to influence the type of color it produces. The options object accepts the following properties:
* `hue` Controls the hue of the generated color. You can pass a string representing a color name: `red`, `orange`, `yellow`, `green`, `blue`, `purple`, `pink` and `monochrome` are currently supported. If you pass a hexidecimal color string such as #00FFFF, its hue value will be extracted and used to generate colors.
* `luminosity` Controls the luminosity of the generated color. You can specify a string containing bright, light or dark.
* `count` An integer which specifies the number of colors to generate.
* `seed` An integer which when passed will cause randomColor to return the same color each time.
* `alpha` A decimal between 0 and 1. Only relevant when using a format with an alpha channel (rgba and hsla). Defaults to a random value.
```ts
import { random } from '@ctrl/tinycolor';
// Returns a TinyColor for an attractive color
random();
// Returns an array of ten green colors
random({
count: 10,
hue: 'green',
});
// Returns a TinyColor object in a light blue
random({
luminosity: 'light',
hue: 'blue',
});
// Returns a TinyColor object in a 'truly random' color
random({
luminosity: 'random',
hue: 'random',
});
// Returns a dark RGB color with specified alpha
random({
luminosity: 'dark',
alpha: 0.5,
});
```
### Readability
TinyColor assesses readability based on the [Web Content Accessibility Guidelines (Version 2.0)](http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef).
#### readability
`readability: function(TinyColor, TinyColor) -> number`.
Returns the contrast ratio between two colors.
```ts
import { readability } from '@ctrl/tinycolor';
readability('#000', '#000'); // 1
readability('#000', '#111'); // 1.1121078324840545
readability('#000', '#fff'); // 21
```
Use the values in your own calculations, or use one of the convenience functions below.
#### isReadable
`isReadable: function(TinyColor, TinyColor, Object) -> Boolean`. Ensure that foreground and background color combinations meet WCAG guidelines. `Object` is optional, defaulting to `{level: "AA",size: "small"}`. `level` can be `"AA"` or "AAA" and `size` can be `"small"` or `"large"`.
Here are links to read more about the [AA](http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html) and [AAA](http://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast7.html) requirements.
```ts
import { isReadable } from '@ctrl/tinycolor';
isReadable("#000", "#111"); // false
isReadable("#ff0088", "#5c1a72", { level: "AA", size: "small" }); // false
isReadable("#ff0088", "#5c1a72", { level: "AA", size: "large" }), // true
```
#### mostReadable
`mostReadable: function(TinyColor, [TinyColor, TinyColor ...], Object) -> Boolean`.
Given a base color and a list of possible foreground or background colors for that base, returns the most readable color.
If none of the colors in the list is readable, `mostReadable` will return the better of black or white if `includeFallbackColors:true`.
```ts
import { mostReadable } from '@ctrl/tinycolor';
mostReadable('#000', ['#f00', '#0f0', '#00f']).toHexString(); // "#00ff00"
mostReadable('#123', ['#124', '#125'], { includeFallbackColors: false }).toHexString(); // "#112255"
mostReadable('#123', ['#124', '#125'], { includeFallbackColors: true }).toHexString(); // "#ffffff"
mostReadable('#ff0088', ['#2e0c3a'], {
includeFallbackColors: true,
level: 'AAA',
size: 'large',
}).toHexString(); // "#2e0c3a",
mostReadable('#ff0088', ['#2e0c3a'], {
includeFallbackColors: true,
level: 'AAA',
size: 'small',
}).toHexString(); // "#000000",
```
See [index.html](https://github.com/bgrins/TinyColor/blob/master/index.html) in the project for a demo.
## Common operations
### clone
`clone: function() -> TinyColor`.
Instantiate a new TinyColor object with the same color. Any changes to the new one won't affect the old one.
```ts
const color1 = new TinyColor('#F00');
const color2 = color1.clone();
color2.setAlpha(0.5);
color1.toString(); // "#ff0000"
color2.toString(); // "rgba(255, 0, 0, 0.5)"
```

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

61
node_modules/@ctrl/tinycolor/dist/conversion.d.ts generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import { HSL, HSV, Numberify, RGB } from './interfaces.js';
/**
* Handle bounds / percentage checking to conform to CSS color spec
* <http://www.w3.org/TR/css3-color/>
* *Assumes:* r, g, b in [0, 255] or [0, 1]
* *Returns:* { r, g, b } in [0, 255]
*/
export declare function rgbToRgb(r: number | string, g: number | string, b: number | string): Numberify<RGB>;
/**
* Converts an RGB color value to HSL.
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
* *Returns:* { h, s, l } in [0,1]
*/
export declare function rgbToHsl(r: number, g: number, b: number): Numberify<HSL>;
/**
* Converts an HSL color value to RGB.
*
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
* *Returns:* { r, g, b } in the set [0, 255]
*/
export declare function hslToRgb(h: number | string, s: number | string, l: number | string): Numberify<RGB>;
/**
* Converts an RGB color value to HSV
*
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
* *Returns:* { h, s, v } in [0,1]
*/
export declare function rgbToHsv(r: number, g: number, b: number): Numberify<HSV>;
/**
* Converts an HSV color value to RGB.
*
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
* *Returns:* { r, g, b } in the set [0, 255]
*/
export declare function hsvToRgb(h: number | string, s: number | string, v: number | string): Numberify<RGB>;
/**
* Converts an RGB color to hex
*
* Assumes r, g, and b are contained in the set [0, 255]
* Returns a 3 or 6 character hex
*/
export declare function rgbToHex(r: number, g: number, b: number, allow3Char: boolean): string;
/**
* Converts an RGBA color plus alpha transparency to hex
*
* Assumes r, g, b are contained in the set [0, 255] and
* a in [0, 1]. Returns a 4 or 8 character rgba hex
*/
export declare function rgbaToHex(r: number, g: number, b: number, a: number, allow4Char: boolean): string;
/**
* Converts an RGBA color to an ARGB Hex8 string
* Rarely used, but required for "toFilter()"
*/
export declare function rgbaToArgbHex(r: number, g: number, b: number, a: number): string;
/** Converts a decimal to a hex value */
export declare function convertDecimalToHex(d: string | number): string;
/** Converts a hex value to a decimal */
export declare function convertHexToDecimal(h: string): number;
/** Parse a base-16 hex value into a base-10 integer */
export declare function parseIntFromHex(val: string): number;
export declare function numberInputToObject(color: number): RGB;

250
node_modules/@ctrl/tinycolor/dist/conversion.js generated vendored Normal file
View File

@@ -0,0 +1,250 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.numberInputToObject = exports.parseIntFromHex = exports.convertHexToDecimal = exports.convertDecimalToHex = exports.rgbaToArgbHex = exports.rgbaToHex = exports.rgbToHex = exports.hsvToRgb = exports.rgbToHsv = exports.hslToRgb = exports.rgbToHsl = exports.rgbToRgb = void 0;
var util_js_1 = require("./util.js");
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
/**
* Handle bounds / percentage checking to conform to CSS color spec
* <http://www.w3.org/TR/css3-color/>
* *Assumes:* r, g, b in [0, 255] or [0, 1]
* *Returns:* { r, g, b } in [0, 255]
*/
function rgbToRgb(r, g, b) {
return {
r: (0, util_js_1.bound01)(r, 255) * 255,
g: (0, util_js_1.bound01)(g, 255) * 255,
b: (0, util_js_1.bound01)(b, 255) * 255,
};
}
exports.rgbToRgb = rgbToRgb;
/**
* Converts an RGB color value to HSL.
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
* *Returns:* { h, s, l } in [0,1]
*/
function rgbToHsl(r, g, b) {
r = (0, util_js_1.bound01)(r, 255);
g = (0, util_js_1.bound01)(g, 255);
b = (0, util_js_1.bound01)(b, 255);
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h = 0;
var s = 0;
var l = (max + min) / 2;
if (max === min) {
s = 0;
h = 0; // achromatic
}
else {
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
default:
break;
}
h /= 6;
}
return { h: h, s: s, l: l };
}
exports.rgbToHsl = rgbToHsl;
function hue2rgb(p, q, t) {
if (t < 0) {
t += 1;
}
if (t > 1) {
t -= 1;
}
if (t < 1 / 6) {
return p + (q - p) * (6 * t);
}
if (t < 1 / 2) {
return q;
}
if (t < 2 / 3) {
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
}
/**
* Converts an HSL color value to RGB.
*
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
* *Returns:* { r, g, b } in the set [0, 255]
*/
function hslToRgb(h, s, l) {
var r;
var g;
var b;
h = (0, util_js_1.bound01)(h, 360);
s = (0, util_js_1.bound01)(s, 100);
l = (0, util_js_1.bound01)(l, 100);
if (s === 0) {
// achromatic
g = l;
b = l;
r = l;
}
else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
return { r: r * 255, g: g * 255, b: b * 255 };
}
exports.hslToRgb = hslToRgb;
/**
* Converts an RGB color value to HSV
*
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
* *Returns:* { h, s, v } in [0,1]
*/
function rgbToHsv(r, g, b) {
r = (0, util_js_1.bound01)(r, 255);
g = (0, util_js_1.bound01)(g, 255);
b = (0, util_js_1.bound01)(b, 255);
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h = 0;
var v = max;
var d = max - min;
var s = max === 0 ? 0 : d / max;
if (max === min) {
h = 0; // achromatic
}
else {
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
default:
break;
}
h /= 6;
}
return { h: h, s: s, v: v };
}
exports.rgbToHsv = rgbToHsv;
/**
* Converts an HSV color value to RGB.
*
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
* *Returns:* { r, g, b } in the set [0, 255]
*/
function hsvToRgb(h, s, v) {
h = (0, util_js_1.bound01)(h, 360) * 6;
s = (0, util_js_1.bound01)(s, 100);
v = (0, util_js_1.bound01)(v, 100);
var i = Math.floor(h);
var f = h - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
var mod = i % 6;
var r = [v, q, p, p, t, v][mod];
var g = [t, v, v, q, p, p][mod];
var b = [p, p, t, v, v, q][mod];
return { r: r * 255, g: g * 255, b: b * 255 };
}
exports.hsvToRgb = hsvToRgb;
/**
* Converts an RGB color to hex
*
* Assumes r, g, and b are contained in the set [0, 255]
* Returns a 3 or 6 character hex
*/
function rgbToHex(r, g, b, allow3Char) {
var hex = [
(0, util_js_1.pad2)(Math.round(r).toString(16)),
(0, util_js_1.pad2)(Math.round(g).toString(16)),
(0, util_js_1.pad2)(Math.round(b).toString(16)),
];
// Return a 3 character hex if possible
if (allow3Char &&
hex[0].startsWith(hex[0].charAt(1)) &&
hex[1].startsWith(hex[1].charAt(1)) &&
hex[2].startsWith(hex[2].charAt(1))) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
}
return hex.join('');
}
exports.rgbToHex = rgbToHex;
/**
* Converts an RGBA color plus alpha transparency to hex
*
* Assumes r, g, b are contained in the set [0, 255] and
* a in [0, 1]. Returns a 4 or 8 character rgba hex
*/
// eslint-disable-next-line max-params
function rgbaToHex(r, g, b, a, allow4Char) {
var hex = [
(0, util_js_1.pad2)(Math.round(r).toString(16)),
(0, util_js_1.pad2)(Math.round(g).toString(16)),
(0, util_js_1.pad2)(Math.round(b).toString(16)),
(0, util_js_1.pad2)(convertDecimalToHex(a)),
];
// Return a 4 character hex if possible
if (allow4Char &&
hex[0].startsWith(hex[0].charAt(1)) &&
hex[1].startsWith(hex[1].charAt(1)) &&
hex[2].startsWith(hex[2].charAt(1)) &&
hex[3].startsWith(hex[3].charAt(1))) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
}
return hex.join('');
}
exports.rgbaToHex = rgbaToHex;
/**
* Converts an RGBA color to an ARGB Hex8 string
* Rarely used, but required for "toFilter()"
*/
function rgbaToArgbHex(r, g, b, a) {
var hex = [
(0, util_js_1.pad2)(convertDecimalToHex(a)),
(0, util_js_1.pad2)(Math.round(r).toString(16)),
(0, util_js_1.pad2)(Math.round(g).toString(16)),
(0, util_js_1.pad2)(Math.round(b).toString(16)),
];
return hex.join('');
}
exports.rgbaToArgbHex = rgbaToArgbHex;
/** Converts a decimal to a hex value */
function convertDecimalToHex(d) {
return Math.round(parseFloat(d) * 255).toString(16);
}
exports.convertDecimalToHex = convertDecimalToHex;
/** Converts a hex value to a decimal */
function convertHexToDecimal(h) {
return parseIntFromHex(h) / 255;
}
exports.convertHexToDecimal = convertHexToDecimal;
/** Parse a base-16 hex value into a base-10 integer */
function parseIntFromHex(val) {
return parseInt(val, 16);
}
exports.parseIntFromHex = parseIntFromHex;
function numberInputToObject(color) {
return {
r: color >> 16,
g: (color & 0xff00) >> 8,
b: color & 0xff,
};
}
exports.numberInputToObject = numberInputToObject;

View File

@@ -0,0 +1,4 @@
/**
* @hidden
*/
export declare const names: Record<string, string>;

157
node_modules/@ctrl/tinycolor/dist/css-color-names.js generated vendored Normal file
View File

@@ -0,0 +1,157 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.names = void 0;
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
/**
* @hidden
*/
exports.names = {
aliceblue: '#f0f8ff',
antiquewhite: '#faebd7',
aqua: '#00ffff',
aquamarine: '#7fffd4',
azure: '#f0ffff',
beige: '#f5f5dc',
bisque: '#ffe4c4',
black: '#000000',
blanchedalmond: '#ffebcd',
blue: '#0000ff',
blueviolet: '#8a2be2',
brown: '#a52a2a',
burlywood: '#deb887',
cadetblue: '#5f9ea0',
chartreuse: '#7fff00',
chocolate: '#d2691e',
coral: '#ff7f50',
cornflowerblue: '#6495ed',
cornsilk: '#fff8dc',
crimson: '#dc143c',
cyan: '#00ffff',
darkblue: '#00008b',
darkcyan: '#008b8b',
darkgoldenrod: '#b8860b',
darkgray: '#a9a9a9',
darkgreen: '#006400',
darkgrey: '#a9a9a9',
darkkhaki: '#bdb76b',
darkmagenta: '#8b008b',
darkolivegreen: '#556b2f',
darkorange: '#ff8c00',
darkorchid: '#9932cc',
darkred: '#8b0000',
darksalmon: '#e9967a',
darkseagreen: '#8fbc8f',
darkslateblue: '#483d8b',
darkslategray: '#2f4f4f',
darkslategrey: '#2f4f4f',
darkturquoise: '#00ced1',
darkviolet: '#9400d3',
deeppink: '#ff1493',
deepskyblue: '#00bfff',
dimgray: '#696969',
dimgrey: '#696969',
dodgerblue: '#1e90ff',
firebrick: '#b22222',
floralwhite: '#fffaf0',
forestgreen: '#228b22',
fuchsia: '#ff00ff',
gainsboro: '#dcdcdc',
ghostwhite: '#f8f8ff',
goldenrod: '#daa520',
gold: '#ffd700',
gray: '#808080',
green: '#008000',
greenyellow: '#adff2f',
grey: '#808080',
honeydew: '#f0fff0',
hotpink: '#ff69b4',
indianred: '#cd5c5c',
indigo: '#4b0082',
ivory: '#fffff0',
khaki: '#f0e68c',
lavenderblush: '#fff0f5',
lavender: '#e6e6fa',
lawngreen: '#7cfc00',
lemonchiffon: '#fffacd',
lightblue: '#add8e6',
lightcoral: '#f08080',
lightcyan: '#e0ffff',
lightgoldenrodyellow: '#fafad2',
lightgray: '#d3d3d3',
lightgreen: '#90ee90',
lightgrey: '#d3d3d3',
lightpink: '#ffb6c1',
lightsalmon: '#ffa07a',
lightseagreen: '#20b2aa',
lightskyblue: '#87cefa',
lightslategray: '#778899',
lightslategrey: '#778899',
lightsteelblue: '#b0c4de',
lightyellow: '#ffffe0',
lime: '#00ff00',
limegreen: '#32cd32',
linen: '#faf0e6',
magenta: '#ff00ff',
maroon: '#800000',
mediumaquamarine: '#66cdaa',
mediumblue: '#0000cd',
mediumorchid: '#ba55d3',
mediumpurple: '#9370db',
mediumseagreen: '#3cb371',
mediumslateblue: '#7b68ee',
mediumspringgreen: '#00fa9a',
mediumturquoise: '#48d1cc',
mediumvioletred: '#c71585',
midnightblue: '#191970',
mintcream: '#f5fffa',
mistyrose: '#ffe4e1',
moccasin: '#ffe4b5',
navajowhite: '#ffdead',
navy: '#000080',
oldlace: '#fdf5e6',
olive: '#808000',
olivedrab: '#6b8e23',
orange: '#ffa500',
orangered: '#ff4500',
orchid: '#da70d6',
palegoldenrod: '#eee8aa',
palegreen: '#98fb98',
paleturquoise: '#afeeee',
palevioletred: '#db7093',
papayawhip: '#ffefd5',
peachpuff: '#ffdab9',
peru: '#cd853f',
pink: '#ffc0cb',
plum: '#dda0dd',
powderblue: '#b0e0e6',
purple: '#800080',
rebeccapurple: '#663399',
red: '#ff0000',
rosybrown: '#bc8f8f',
royalblue: '#4169e1',
saddlebrown: '#8b4513',
salmon: '#fa8072',
sandybrown: '#f4a460',
seagreen: '#2e8b57',
seashell: '#fff5ee',
sienna: '#a0522d',
silver: '#c0c0c0',
skyblue: '#87ceeb',
slateblue: '#6a5acd',
slategray: '#708090',
slategrey: '#708090',
snow: '#fffafa',
springgreen: '#00ff7f',
steelblue: '#4682b4',
tan: '#d2b48c',
teal: '#008080',
thistle: '#d8bfd8',
tomato: '#ff6347',
turquoise: '#40e0d0',
violet: '#ee82ee',
wheat: '#f5deb3',
white: '#ffffff',
whitesmoke: '#f5f5f5',
yellow: '#ffff00',
yellowgreen: '#9acd32',
};

37
node_modules/@ctrl/tinycolor/dist/format-input.d.ts generated vendored Normal file
View File

@@ -0,0 +1,37 @@
import { HSL, HSLA, HSV, HSVA, RGB, RGBA } from './interfaces.js';
/**
* Given a string or object, convert that input to RGB
*
* Possible string inputs:
* ```
* "red"
* "#f00" or "f00"
* "#ff0000" or "ff0000"
* "#ff000000" or "ff000000"
* "rgb 255 0 0" or "rgb (255, 0, 0)"
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
* ```
*/
export declare function inputToRGB(color: string | RGB | RGBA | HSL | HSLA | HSV | HSVA | any): {
ok: boolean;
format: any;
r: number;
g: number;
b: number;
a: number;
};
/**
* Permissive string parsing. Take in a number of formats, and output an object
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
*/
export declare function stringInputToObject(color: string): any;
/**
* Check to see if it looks like a CSS unit
* (see `matchers` above for definition).
*/
export declare function isValidCSSUnit(color: string | number): boolean;

189
node_modules/@ctrl/tinycolor/dist/format-input.js generated vendored Normal file
View File

@@ -0,0 +1,189 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidCSSUnit = exports.stringInputToObject = exports.inputToRGB = void 0;
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
var conversion_js_1 = require("./conversion.js");
var css_color_names_js_1 = require("./css-color-names.js");
var util_js_1 = require("./util.js");
/**
* Given a string or object, convert that input to RGB
*
* Possible string inputs:
* ```
* "red"
* "#f00" or "f00"
* "#ff0000" or "ff0000"
* "#ff000000" or "ff000000"
* "rgb 255 0 0" or "rgb (255, 0, 0)"
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
* ```
*/
function inputToRGB(color) {
var rgb = { r: 0, g: 0, b: 0 };
var a = 1;
var s = null;
var v = null;
var l = null;
var ok = false;
var format = false;
if (typeof color === 'string') {
color = stringInputToObject(color);
}
if (typeof color === 'object') {
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
rgb = (0, conversion_js_1.rgbToRgb)(color.r, color.g, color.b);
ok = true;
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
}
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
s = (0, util_js_1.convertToPercentage)(color.s);
v = (0, util_js_1.convertToPercentage)(color.v);
rgb = (0, conversion_js_1.hsvToRgb)(color.h, s, v);
ok = true;
format = 'hsv';
}
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
s = (0, util_js_1.convertToPercentage)(color.s);
l = (0, util_js_1.convertToPercentage)(color.l);
rgb = (0, conversion_js_1.hslToRgb)(color.h, s, l);
ok = true;
format = 'hsl';
}
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
a = color.a;
}
}
a = (0, util_js_1.boundAlpha)(a);
return {
ok: ok,
format: color.format || format,
r: Math.min(255, Math.max(rgb.r, 0)),
g: Math.min(255, Math.max(rgb.g, 0)),
b: Math.min(255, Math.max(rgb.b, 0)),
a: a,
};
}
exports.inputToRGB = inputToRGB;
// <http://www.w3.org/TR/css3-values/#integers>
var CSS_INTEGER = '[-\\+]?\\d+%?';
// <http://www.w3.org/TR/css3-values/#number-value>
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
// Actual matching.
// Parentheses and commas are optional, but not required.
// Whitespace can take the place of commas or opening paren
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var matchers = {
CSS_UNIT: new RegExp(CSS_UNIT),
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
};
/**
* Permissive string parsing. Take in a number of formats, and output an object
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
*/
function stringInputToObject(color) {
color = color.trim().toLowerCase();
if (color.length === 0) {
return false;
}
var named = false;
if (css_color_names_js_1.names[color]) {
color = css_color_names_js_1.names[color];
named = true;
}
else if (color === 'transparent') {
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
}
// Try to match string input using regular expressions.
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
// Just return an object and let the conversion functions handle that.
// This way the result will be the same whether the tinycolor is initialized with string or object.
var match = matchers.rgb.exec(color);
if (match) {
return { r: match[1], g: match[2], b: match[3] };
}
match = matchers.rgba.exec(color);
if (match) {
return { r: match[1], g: match[2], b: match[3], a: match[4] };
}
match = matchers.hsl.exec(color);
if (match) {
return { h: match[1], s: match[2], l: match[3] };
}
match = matchers.hsla.exec(color);
if (match) {
return { h: match[1], s: match[2], l: match[3], a: match[4] };
}
match = matchers.hsv.exec(color);
if (match) {
return { h: match[1], s: match[2], v: match[3] };
}
match = matchers.hsva.exec(color);
if (match) {
return { h: match[1], s: match[2], v: match[3], a: match[4] };
}
match = matchers.hex8.exec(color);
if (match) {
return {
r: (0, conversion_js_1.parseIntFromHex)(match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3]),
a: (0, conversion_js_1.convertHexToDecimal)(match[4]),
format: named ? 'name' : 'hex8',
};
}
match = matchers.hex6.exec(color);
if (match) {
return {
r: (0, conversion_js_1.parseIntFromHex)(match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3]),
format: named ? 'name' : 'hex',
};
}
match = matchers.hex4.exec(color);
if (match) {
return {
r: (0, conversion_js_1.parseIntFromHex)(match[1] + match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2] + match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3] + match[3]),
a: (0, conversion_js_1.convertHexToDecimal)(match[4] + match[4]),
format: named ? 'name' : 'hex8',
};
}
match = matchers.hex3.exec(color);
if (match) {
return {
r: (0, conversion_js_1.parseIntFromHex)(match[1] + match[1]),
g: (0, conversion_js_1.parseIntFromHex)(match[2] + match[2]),
b: (0, conversion_js_1.parseIntFromHex)(match[3] + match[3]),
format: named ? 'name' : 'hex',
};
}
return false;
}
exports.stringInputToObject = stringInputToObject;
/**
* Check to see if it looks like a CSS unit
* (see `matchers` above for definition).
*/
function isValidCSSUnit(color) {
return Boolean(matchers.CSS_UNIT.exec(String(color)));
}
exports.isValidCSSUnit = isValidCSSUnit;

14
node_modules/@ctrl/tinycolor/dist/from-ratio.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { TinyColor } from './index.js';
export interface RatioInput {
r: number | string;
g: number | string;
b: number | string;
a?: number | string;
}
/**
* If input is an object, force 1 into "1.0" to handle ratios properly
* String input requires "1.0" as input, so 1 will be treated as 1
*/
export declare function fromRatio(ratio: RatioInput, opts?: any): TinyColor;
/** old random function */
export declare function legacyRandom(): TinyColor;

30
node_modules/@ctrl/tinycolor/dist/from-ratio.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.legacyRandom = exports.fromRatio = void 0;
var index_js_1 = require("./index.js");
var util_js_1 = require("./util.js");
/**
* If input is an object, force 1 into "1.0" to handle ratios properly
* String input requires "1.0" as input, so 1 will be treated as 1
*/
function fromRatio(ratio, opts) {
var newColor = {
r: (0, util_js_1.convertToPercentage)(ratio.r),
g: (0, util_js_1.convertToPercentage)(ratio.g),
b: (0, util_js_1.convertToPercentage)(ratio.b),
};
if (ratio.a !== undefined) {
newColor.a = Number(ratio.a);
}
return new index_js_1.TinyColor(newColor, opts);
}
exports.fromRatio = fromRatio;
/** old random function */
function legacyRandom() {
return new index_js_1.TinyColor({
r: Math.random(),
g: Math.random(),
b: Math.random(),
});
}
exports.legacyRandom = legacyRandom;

207
node_modules/@ctrl/tinycolor/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,207 @@
import { HSL, HSLA, HSV, HSVA, Numberify, RGB, RGBA } from './interfaces.js';
export interface TinyColorOptions {
format: string;
gradientType: string;
}
export type ColorInput = string | number | RGB | RGBA | HSL | HSLA | HSV | HSVA | TinyColor;
export type ColorFormats = 'rgb' | 'prgb' | 'hex' | 'hex3' | 'hex4' | 'hex6' | 'hex8' | 'name' | 'hsl' | 'hsv';
export declare class TinyColor {
/** red */
r: number;
/** green */
g: number;
/** blue */
b: number;
/** alpha */
a: number;
/** the format used to create the tinycolor instance */
format: ColorFormats;
/** input passed into the constructer used to create the tinycolor instance */
originalInput: ColorInput;
/** the color was successfully parsed */
isValid: boolean;
gradientType?: string;
/** rounded alpha */
roundA: number;
constructor(color?: ColorInput, opts?: Partial<TinyColorOptions>);
isDark(): boolean;
isLight(): boolean;
/**
* Returns the perceived brightness of the color, from 0-255.
*/
getBrightness(): number;
/**
* Returns the perceived luminance of a color, from 0-1.
*/
getLuminance(): number;
/**
* Returns the alpha value of a color, from 0-1.
*/
getAlpha(): number;
/**
* Sets the alpha value on the current color.
*
* @param alpha - The new alpha value. The accepted range is 0-1.
*/
setAlpha(alpha?: string | number): this;
/**
* Returns whether the color is monochrome.
*/
isMonochrome(): boolean;
/**
* Returns the object as a HSVA object.
*/
toHsv(): Numberify<HSVA>;
/**
* Returns the hsva values interpolated into a string with the following format:
* "hsva(xxx, xxx, xxx, xx)".
*/
toHsvString(): string;
/**
* Returns the object as a HSLA object.
*/
toHsl(): Numberify<HSLA>;
/**
* Returns the hsla values interpolated into a string with the following format:
* "hsla(xxx, xxx, xxx, xx)".
*/
toHslString(): string;
/**
* Returns the hex value of the color.
* @param allow3Char will shorten hex value to 3 char if possible
*/
toHex(allow3Char?: boolean): string;
/**
* Returns the hex value of the color -with a # prefixed.
* @param allow3Char will shorten hex value to 3 char if possible
*/
toHexString(allow3Char?: boolean): string;
/**
* Returns the hex 8 value of the color.
* @param allow4Char will shorten hex value to 4 char if possible
*/
toHex8(allow4Char?: boolean): string;
/**
* Returns the hex 8 value of the color -with a # prefixed.
* @param allow4Char will shorten hex value to 4 char if possible
*/
toHex8String(allow4Char?: boolean): string;
/**
* Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
* @param allowShortChar will shorten hex value to 3 or 4 char if possible
*/
toHexShortString(allowShortChar?: boolean): string;
/**
* Returns the object as a RGBA object.
*/
toRgb(): Numberify<RGBA>;
/**
* Returns the RGBA values interpolated into a string with the following format:
* "RGBA(xxx, xxx, xxx, xx)".
*/
toRgbString(): string;
/**
* Returns the object as a RGBA object.
*/
toPercentageRgb(): RGBA;
/**
* Returns the RGBA relative values interpolated into a string
*/
toPercentageRgbString(): string;
/**
* The 'real' name of the color -if there is one.
*/
toName(): string | false;
/**
* String representation of the color.
*
* @param format - The format to be used when displaying the string representation.
*/
toString<T extends 'name'>(format: T): boolean | string;
toString<T extends ColorFormats>(format?: T): string;
toNumber(): number;
clone(): TinyColor;
/**
* Lighten the color a given amount. Providing 100 will always return white.
* @param amount - valid between 1-100
*/
lighten(amount?: number): TinyColor;
/**
* Brighten the color a given amount, from 0 to 100.
* @param amount - valid between 1-100
*/
brighten(amount?: number): TinyColor;
/**
* Darken the color a given amount, from 0 to 100.
* Providing 100 will always return black.
* @param amount - valid between 1-100
*/
darken(amount?: number): TinyColor;
/**
* Mix the color with pure white, from 0 to 100.
* Providing 0 will do nothing, providing 100 will always return white.
* @param amount - valid between 1-100
*/
tint(amount?: number): TinyColor;
/**
* Mix the color with pure black, from 0 to 100.
* Providing 0 will do nothing, providing 100 will always return black.
* @param amount - valid between 1-100
*/
shade(amount?: number): TinyColor;
/**
* Desaturate the color a given amount, from 0 to 100.
* Providing 100 will is the same as calling greyscale
* @param amount - valid between 1-100
*/
desaturate(amount?: number): TinyColor;
/**
* Saturate the color a given amount, from 0 to 100.
* @param amount - valid between 1-100
*/
saturate(amount?: number): TinyColor;
/**
* Completely desaturates a color into greyscale.
* Same as calling `desaturate(100)`
*/
greyscale(): TinyColor;
/**
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
* Values outside of this range will be wrapped into this range.
*/
spin(amount: number): TinyColor;
/**
* Mix the current color a given amount with another color, from 0 to 100.
* 0 means no mixing (return current color).
*/
mix(color: ColorInput, amount?: number): TinyColor;
analogous(results?: number, slices?: number): TinyColor[];
/**
* taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
*/
complement(): TinyColor;
monochromatic(results?: number): TinyColor[];
splitcomplement(): TinyColor[];
/**
* Compute how the color would appear on a background
*/
onBackground(background: ColorInput): TinyColor;
/**
* Alias for `polyad(3)`
*/
triad(): TinyColor[];
/**
* Alias for `polyad(4)`
*/
tetrad(): TinyColor[];
/**
* Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
* monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
*/
polyad(n: number): TinyColor[];
/**
* compare color vs current color
*/
equals(color?: ColorInput): boolean;
}
export declare function tinycolor(color?: ColorInput, opts?: Partial<TinyColorOptions>): TinyColor;

512
node_modules/@ctrl/tinycolor/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,512 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tinycolor = exports.TinyColor = void 0;
var conversion_js_1 = require("./conversion.js");
var css_color_names_js_1 = require("./css-color-names.js");
var format_input_1 = require("./format-input");
var util_js_1 = require("./util.js");
var TinyColor = /** @class */ (function () {
function TinyColor(color, opts) {
if (color === void 0) { color = ''; }
if (opts === void 0) { opts = {}; }
var _a;
// If input is already a tinycolor, return itself
if (color instanceof TinyColor) {
// eslint-disable-next-line no-constructor-return
return color;
}
if (typeof color === 'number') {
color = (0, conversion_js_1.numberInputToObject)(color);
}
this.originalInput = color;
var rgb = (0, format_input_1.inputToRGB)(color);
this.originalInput = color;
this.r = rgb.r;
this.g = rgb.g;
this.b = rgb.b;
this.a = rgb.a;
this.roundA = Math.round(100 * this.a) / 100;
this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
this.gradientType = opts.gradientType;
// Don't let the range of [0,255] come back in [0,1].
// Potentially lose a little bit of precision here, but will fix issues where
// .5 gets interpreted as half of the total, instead of half of 1
// If it was supposed to be 128, this was already taken care of by `inputToRgb`
if (this.r < 1) {
this.r = Math.round(this.r);
}
if (this.g < 1) {
this.g = Math.round(this.g);
}
if (this.b < 1) {
this.b = Math.round(this.b);
}
this.isValid = rgb.ok;
}
TinyColor.prototype.isDark = function () {
return this.getBrightness() < 128;
};
TinyColor.prototype.isLight = function () {
return !this.isDark();
};
/**
* Returns the perceived brightness of the color, from 0-255.
*/
TinyColor.prototype.getBrightness = function () {
// http://www.w3.org/TR/AERT#color-contrast
var rgb = this.toRgb();
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
};
/**
* Returns the perceived luminance of a color, from 0-1.
*/
TinyColor.prototype.getLuminance = function () {
// http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
var rgb = this.toRgb();
var R;
var G;
var B;
var RsRGB = rgb.r / 255;
var GsRGB = rgb.g / 255;
var BsRGB = rgb.b / 255;
if (RsRGB <= 0.03928) {
R = RsRGB / 12.92;
}
else {
// eslint-disable-next-line prefer-exponentiation-operator
R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
}
if (GsRGB <= 0.03928) {
G = GsRGB / 12.92;
}
else {
// eslint-disable-next-line prefer-exponentiation-operator
G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
}
if (BsRGB <= 0.03928) {
B = BsRGB / 12.92;
}
else {
// eslint-disable-next-line prefer-exponentiation-operator
B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
}
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
};
/**
* Returns the alpha value of a color, from 0-1.
*/
TinyColor.prototype.getAlpha = function () {
return this.a;
};
/**
* Sets the alpha value on the current color.
*
* @param alpha - The new alpha value. The accepted range is 0-1.
*/
TinyColor.prototype.setAlpha = function (alpha) {
this.a = (0, util_js_1.boundAlpha)(alpha);
this.roundA = Math.round(100 * this.a) / 100;
return this;
};
/**
* Returns whether the color is monochrome.
*/
TinyColor.prototype.isMonochrome = function () {
var s = this.toHsl().s;
return s === 0;
};
/**
* Returns the object as a HSVA object.
*/
TinyColor.prototype.toHsv = function () {
var hsv = (0, conversion_js_1.rgbToHsv)(this.r, this.g, this.b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
};
/**
* Returns the hsva values interpolated into a string with the following format:
* "hsva(xxx, xxx, xxx, xx)".
*/
TinyColor.prototype.toHsvString = function () {
var hsv = (0, conversion_js_1.rgbToHsv)(this.r, this.g, this.b);
var h = Math.round(hsv.h * 360);
var s = Math.round(hsv.s * 100);
var v = Math.round(hsv.v * 100);
return this.a === 1 ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")");
};
/**
* Returns the object as a HSLA object.
*/
TinyColor.prototype.toHsl = function () {
var hsl = (0, conversion_js_1.rgbToHsl)(this.r, this.g, this.b);
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
};
/**
* Returns the hsla values interpolated into a string with the following format:
* "hsla(xxx, xxx, xxx, xx)".
*/
TinyColor.prototype.toHslString = function () {
var hsl = (0, conversion_js_1.rgbToHsl)(this.r, this.g, this.b);
var h = Math.round(hsl.h * 360);
var s = Math.round(hsl.s * 100);
var l = Math.round(hsl.l * 100);
return this.a === 1 ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")");
};
/**
* Returns the hex value of the color.
* @param allow3Char will shorten hex value to 3 char if possible
*/
TinyColor.prototype.toHex = function (allow3Char) {
if (allow3Char === void 0) { allow3Char = false; }
return (0, conversion_js_1.rgbToHex)(this.r, this.g, this.b, allow3Char);
};
/**
* Returns the hex value of the color -with a # prefixed.
* @param allow3Char will shorten hex value to 3 char if possible
*/
TinyColor.prototype.toHexString = function (allow3Char) {
if (allow3Char === void 0) { allow3Char = false; }
return '#' + this.toHex(allow3Char);
};
/**
* Returns the hex 8 value of the color.
* @param allow4Char will shorten hex value to 4 char if possible
*/
TinyColor.prototype.toHex8 = function (allow4Char) {
if (allow4Char === void 0) { allow4Char = false; }
return (0, conversion_js_1.rgbaToHex)(this.r, this.g, this.b, this.a, allow4Char);
};
/**
* Returns the hex 8 value of the color -with a # prefixed.
* @param allow4Char will shorten hex value to 4 char if possible
*/
TinyColor.prototype.toHex8String = function (allow4Char) {
if (allow4Char === void 0) { allow4Char = false; }
return '#' + this.toHex8(allow4Char);
};
/**
* Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
* @param allowShortChar will shorten hex value to 3 or 4 char if possible
*/
TinyColor.prototype.toHexShortString = function (allowShortChar) {
if (allowShortChar === void 0) { allowShortChar = false; }
return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
};
/**
* Returns the object as a RGBA object.
*/
TinyColor.prototype.toRgb = function () {
return {
r: Math.round(this.r),
g: Math.round(this.g),
b: Math.round(this.b),
a: this.a,
};
};
/**
* Returns the RGBA values interpolated into a string with the following format:
* "RGBA(xxx, xxx, xxx, xx)".
*/
TinyColor.prototype.toRgbString = function () {
var r = Math.round(this.r);
var g = Math.round(this.g);
var b = Math.round(this.b);
return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")");
};
/**
* Returns the object as a RGBA object.
*/
TinyColor.prototype.toPercentageRgb = function () {
var fmt = function (x) { return "".concat(Math.round((0, util_js_1.bound01)(x, 255) * 100), "%"); };
return {
r: fmt(this.r),
g: fmt(this.g),
b: fmt(this.b),
a: this.a,
};
};
/**
* Returns the RGBA relative values interpolated into a string
*/
TinyColor.prototype.toPercentageRgbString = function () {
var rnd = function (x) { return Math.round((0, util_js_1.bound01)(x, 255) * 100); };
return this.a === 1
? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)")
: "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
};
/**
* The 'real' name of the color -if there is one.
*/
TinyColor.prototype.toName = function () {
if (this.a === 0) {
return 'transparent';
}
if (this.a < 1) {
return false;
}
var hex = '#' + (0, conversion_js_1.rgbToHex)(this.r, this.g, this.b, false);
for (var _i = 0, _a = Object.entries(css_color_names_js_1.names); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
if (hex === value) {
return key;
}
}
return false;
};
TinyColor.prototype.toString = function (format) {
var formatSet = Boolean(format);
format = format !== null && format !== void 0 ? format : this.format;
var formattedString = false;
var hasAlpha = this.a < 1 && this.a >= 0;
var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');
if (needsAlphaFormat) {
// Special case for "transparent", all other non-alpha formats
// will return rgba when there is transparency.
if (format === 'name' && this.a === 0) {
return this.toName();
}
return this.toRgbString();
}
if (format === 'rgb') {
formattedString = this.toRgbString();
}
if (format === 'prgb') {
formattedString = this.toPercentageRgbString();
}
if (format === 'hex' || format === 'hex6') {
formattedString = this.toHexString();
}
if (format === 'hex3') {
formattedString = this.toHexString(true);
}
if (format === 'hex4') {
formattedString = this.toHex8String(true);
}
if (format === 'hex8') {
formattedString = this.toHex8String();
}
if (format === 'name') {
formattedString = this.toName();
}
if (format === 'hsl') {
formattedString = this.toHslString();
}
if (format === 'hsv') {
formattedString = this.toHsvString();
}
return formattedString || this.toHexString();
};
TinyColor.prototype.toNumber = function () {
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
};
TinyColor.prototype.clone = function () {
return new TinyColor(this.toString());
};
/**
* Lighten the color a given amount. Providing 100 will always return white.
* @param amount - valid between 1-100
*/
TinyColor.prototype.lighten = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.l += amount / 100;
hsl.l = (0, util_js_1.clamp01)(hsl.l);
return new TinyColor(hsl);
};
/**
* Brighten the color a given amount, from 0 to 100.
* @param amount - valid between 1-100
*/
TinyColor.prototype.brighten = function (amount) {
if (amount === void 0) { amount = 10; }
var rgb = this.toRgb();
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
return new TinyColor(rgb);
};
/**
* Darken the color a given amount, from 0 to 100.
* Providing 100 will always return black.
* @param amount - valid between 1-100
*/
TinyColor.prototype.darken = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.l -= amount / 100;
hsl.l = (0, util_js_1.clamp01)(hsl.l);
return new TinyColor(hsl);
};
/**
* Mix the color with pure white, from 0 to 100.
* Providing 0 will do nothing, providing 100 will always return white.
* @param amount - valid between 1-100
*/
TinyColor.prototype.tint = function (amount) {
if (amount === void 0) { amount = 10; }
return this.mix('white', amount);
};
/**
* Mix the color with pure black, from 0 to 100.
* Providing 0 will do nothing, providing 100 will always return black.
* @param amount - valid between 1-100
*/
TinyColor.prototype.shade = function (amount) {
if (amount === void 0) { amount = 10; }
return this.mix('black', amount);
};
/**
* Desaturate the color a given amount, from 0 to 100.
* Providing 100 will is the same as calling greyscale
* @param amount - valid between 1-100
*/
TinyColor.prototype.desaturate = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.s -= amount / 100;
hsl.s = (0, util_js_1.clamp01)(hsl.s);
return new TinyColor(hsl);
};
/**
* Saturate the color a given amount, from 0 to 100.
* @param amount - valid between 1-100
*/
TinyColor.prototype.saturate = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.s += amount / 100;
hsl.s = (0, util_js_1.clamp01)(hsl.s);
return new TinyColor(hsl);
};
/**
* Completely desaturates a color into greyscale.
* Same as calling `desaturate(100)`
*/
TinyColor.prototype.greyscale = function () {
return this.desaturate(100);
};
/**
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
* Values outside of this range will be wrapped into this range.
*/
TinyColor.prototype.spin = function (amount) {
var hsl = this.toHsl();
var hue = (hsl.h + amount) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return new TinyColor(hsl);
};
/**
* Mix the current color a given amount with another color, from 0 to 100.
* 0 means no mixing (return current color).
*/
TinyColor.prototype.mix = function (color, amount) {
if (amount === void 0) { amount = 50; }
var rgb1 = this.toRgb();
var rgb2 = new TinyColor(color).toRgb();
var p = amount / 100;
var rgba = {
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b,
a: (rgb2.a - rgb1.a) * p + rgb1.a,
};
return new TinyColor(rgba);
};
TinyColor.prototype.analogous = function (results, slices) {
if (results === void 0) { results = 6; }
if (slices === void 0) { slices = 30; }
var hsl = this.toHsl();
var part = 360 / slices;
var ret = [this];
for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results;) {
hsl.h = (hsl.h + part) % 360;
ret.push(new TinyColor(hsl));
}
return ret;
};
/**
* taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
*/
TinyColor.prototype.complement = function () {
var hsl = this.toHsl();
hsl.h = (hsl.h + 180) % 360;
return new TinyColor(hsl);
};
TinyColor.prototype.monochromatic = function (results) {
if (results === void 0) { results = 6; }
var hsv = this.toHsv();
var h = hsv.h;
var s = hsv.s;
var v = hsv.v;
var res = [];
var modification = 1 / results;
while (results--) {
res.push(new TinyColor({ h: h, s: s, v: v }));
v = (v + modification) % 1;
}
return res;
};
TinyColor.prototype.splitcomplement = function () {
var hsl = this.toHsl();
var h = hsl.h;
return [
this,
new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),
];
};
/**
* Compute how the color would appear on a background
*/
TinyColor.prototype.onBackground = function (background) {
var fg = this.toRgb();
var bg = new TinyColor(background).toRgb();
var alpha = fg.a + bg.a * (1 - fg.a);
return new TinyColor({
r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
a: alpha,
});
};
/**
* Alias for `polyad(3)`
*/
TinyColor.prototype.triad = function () {
return this.polyad(3);
};
/**
* Alias for `polyad(4)`
*/
TinyColor.prototype.tetrad = function () {
return this.polyad(4);
};
/**
* Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
* monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
*/
TinyColor.prototype.polyad = function (n) {
var hsl = this.toHsl();
var h = hsl.h;
var result = [this];
var increment = 360 / n;
for (var i = 1; i < n; i++) {
result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
}
return result;
};
/**
* compare color vs current color
*/
TinyColor.prototype.equals = function (color) {
return this.toRgbString() === new TinyColor(color).toRgbString();
};
return TinyColor;
}());
exports.TinyColor = TinyColor;
// kept for backwards compatability with v1
function tinycolor(color, opts) {
if (color === void 0) { color = ''; }
if (opts === void 0) { opts = {}; }
return new TinyColor(color, opts);
}
exports.tinycolor = tinycolor;

46
node_modules/@ctrl/tinycolor/dist/interfaces.d.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
/**
* convert all properties in an interface to a number
*/
export type Numberify<T> = {
[P in keyof T]: number;
};
/**
* A representation of additive color mixing.
* Projection of primary color lights on a white screen shows secondary
* colors where two overlap; the combination of all three of red, green,
* and blue in equal intensities makes white.
*/
export interface RGB {
r: number | string;
g: number | string;
b: number | string;
}
export interface RGBA extends RGB {
a: number;
}
/**
* The HSL model describes colors in terms of hue, saturation,
* and lightness (also called luminance).
* @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSL
*/
export interface HSL {
h: number | string;
s: number | string;
l: number | string;
}
export interface HSLA extends HSL {
a: number;
}
/**
* The HSV, or HSB, model describes colors in terms of
* hue, saturation, and value (brightness).
* @link https://en.wikibooks.org/wiki/Color_Models:_RGB,_HSV,_HSL#HSV
*/
export interface HSV {
h: number | string;
s: number | string;
v: number | string;
}
export interface HSVA extends HSV {
a: number;
}

2
node_modules/@ctrl/tinycolor/dist/interfaces.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

235
node_modules/@ctrl/tinycolor/dist/module/conversion.js generated vendored Normal file
View File

@@ -0,0 +1,235 @@
import { bound01, pad2 } from './util.js';
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
/**
* Handle bounds / percentage checking to conform to CSS color spec
* <http://www.w3.org/TR/css3-color/>
* *Assumes:* r, g, b in [0, 255] or [0, 1]
* *Returns:* { r, g, b } in [0, 255]
*/
export function rgbToRgb(r, g, b) {
return {
r: bound01(r, 255) * 255,
g: bound01(g, 255) * 255,
b: bound01(b, 255) * 255,
};
}
/**
* Converts an RGB color value to HSL.
* *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
* *Returns:* { h, s, l } in [0,1]
*/
export function rgbToHsl(r, g, b) {
r = bound01(r, 255);
g = bound01(g, 255);
b = bound01(b, 255);
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h = 0;
var s = 0;
var l = (max + min) / 2;
if (max === min) {
s = 0;
h = 0; // achromatic
}
else {
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
default:
break;
}
h /= 6;
}
return { h: h, s: s, l: l };
}
function hue2rgb(p, q, t) {
if (t < 0) {
t += 1;
}
if (t > 1) {
t -= 1;
}
if (t < 1 / 6) {
return p + (q - p) * (6 * t);
}
if (t < 1 / 2) {
return q;
}
if (t < 2 / 3) {
return p + (q - p) * (2 / 3 - t) * 6;
}
return p;
}
/**
* Converts an HSL color value to RGB.
*
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
* *Returns:* { r, g, b } in the set [0, 255]
*/
export function hslToRgb(h, s, l) {
var r;
var g;
var b;
h = bound01(h, 360);
s = bound01(s, 100);
l = bound01(l, 100);
if (s === 0) {
// achromatic
g = l;
b = l;
r = l;
}
else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
return { r: r * 255, g: g * 255, b: b * 255 };
}
/**
* Converts an RGB color value to HSV
*
* *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
* *Returns:* { h, s, v } in [0,1]
*/
export function rgbToHsv(r, g, b) {
r = bound01(r, 255);
g = bound01(g, 255);
b = bound01(b, 255);
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h = 0;
var v = max;
var d = max - min;
var s = max === 0 ? 0 : d / max;
if (max === min) {
h = 0; // achromatic
}
else {
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
default:
break;
}
h /= 6;
}
return { h: h, s: s, v: v };
}
/**
* Converts an HSV color value to RGB.
*
* *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
* *Returns:* { r, g, b } in the set [0, 255]
*/
export function hsvToRgb(h, s, v) {
h = bound01(h, 360) * 6;
s = bound01(s, 100);
v = bound01(v, 100);
var i = Math.floor(h);
var f = h - i;
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
var mod = i % 6;
var r = [v, q, p, p, t, v][mod];
var g = [t, v, v, q, p, p][mod];
var b = [p, p, t, v, v, q][mod];
return { r: r * 255, g: g * 255, b: b * 255 };
}
/**
* Converts an RGB color to hex
*
* Assumes r, g, and b are contained in the set [0, 255]
* Returns a 3 or 6 character hex
*/
export function rgbToHex(r, g, b, allow3Char) {
var hex = [
pad2(Math.round(r).toString(16)),
pad2(Math.round(g).toString(16)),
pad2(Math.round(b).toString(16)),
];
// Return a 3 character hex if possible
if (allow3Char &&
hex[0].startsWith(hex[0].charAt(1)) &&
hex[1].startsWith(hex[1].charAt(1)) &&
hex[2].startsWith(hex[2].charAt(1))) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
}
return hex.join('');
}
/**
* Converts an RGBA color plus alpha transparency to hex
*
* Assumes r, g, b are contained in the set [0, 255] and
* a in [0, 1]. Returns a 4 or 8 character rgba hex
*/
// eslint-disable-next-line max-params
export function rgbaToHex(r, g, b, a, allow4Char) {
var hex = [
pad2(Math.round(r).toString(16)),
pad2(Math.round(g).toString(16)),
pad2(Math.round(b).toString(16)),
pad2(convertDecimalToHex(a)),
];
// Return a 4 character hex if possible
if (allow4Char &&
hex[0].startsWith(hex[0].charAt(1)) &&
hex[1].startsWith(hex[1].charAt(1)) &&
hex[2].startsWith(hex[2].charAt(1)) &&
hex[3].startsWith(hex[3].charAt(1))) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
}
return hex.join('');
}
/**
* Converts an RGBA color to an ARGB Hex8 string
* Rarely used, but required for "toFilter()"
*/
export function rgbaToArgbHex(r, g, b, a) {
var hex = [
pad2(convertDecimalToHex(a)),
pad2(Math.round(r).toString(16)),
pad2(Math.round(g).toString(16)),
pad2(Math.round(b).toString(16)),
];
return hex.join('');
}
/** Converts a decimal to a hex value */
export function convertDecimalToHex(d) {
return Math.round(parseFloat(d) * 255).toString(16);
}
/** Converts a hex value to a decimal */
export function convertHexToDecimal(h) {
return parseIntFromHex(h) / 255;
}
/** Parse a base-16 hex value into a base-10 integer */
export function parseIntFromHex(val) {
return parseInt(val, 16);
}
export function numberInputToObject(color) {
return {
r: color >> 16,
g: (color & 0xff00) >> 8,
b: color & 0xff,
};
}

View File

@@ -0,0 +1,154 @@
// https://github.com/bahamas10/css-color-names/blob/master/css-color-names.json
/**
* @hidden
*/
export var names = {
aliceblue: '#f0f8ff',
antiquewhite: '#faebd7',
aqua: '#00ffff',
aquamarine: '#7fffd4',
azure: '#f0ffff',
beige: '#f5f5dc',
bisque: '#ffe4c4',
black: '#000000',
blanchedalmond: '#ffebcd',
blue: '#0000ff',
blueviolet: '#8a2be2',
brown: '#a52a2a',
burlywood: '#deb887',
cadetblue: '#5f9ea0',
chartreuse: '#7fff00',
chocolate: '#d2691e',
coral: '#ff7f50',
cornflowerblue: '#6495ed',
cornsilk: '#fff8dc',
crimson: '#dc143c',
cyan: '#00ffff',
darkblue: '#00008b',
darkcyan: '#008b8b',
darkgoldenrod: '#b8860b',
darkgray: '#a9a9a9',
darkgreen: '#006400',
darkgrey: '#a9a9a9',
darkkhaki: '#bdb76b',
darkmagenta: '#8b008b',
darkolivegreen: '#556b2f',
darkorange: '#ff8c00',
darkorchid: '#9932cc',
darkred: '#8b0000',
darksalmon: '#e9967a',
darkseagreen: '#8fbc8f',
darkslateblue: '#483d8b',
darkslategray: '#2f4f4f',
darkslategrey: '#2f4f4f',
darkturquoise: '#00ced1',
darkviolet: '#9400d3',
deeppink: '#ff1493',
deepskyblue: '#00bfff',
dimgray: '#696969',
dimgrey: '#696969',
dodgerblue: '#1e90ff',
firebrick: '#b22222',
floralwhite: '#fffaf0',
forestgreen: '#228b22',
fuchsia: '#ff00ff',
gainsboro: '#dcdcdc',
ghostwhite: '#f8f8ff',
goldenrod: '#daa520',
gold: '#ffd700',
gray: '#808080',
green: '#008000',
greenyellow: '#adff2f',
grey: '#808080',
honeydew: '#f0fff0',
hotpink: '#ff69b4',
indianred: '#cd5c5c',
indigo: '#4b0082',
ivory: '#fffff0',
khaki: '#f0e68c',
lavenderblush: '#fff0f5',
lavender: '#e6e6fa',
lawngreen: '#7cfc00',
lemonchiffon: '#fffacd',
lightblue: '#add8e6',
lightcoral: '#f08080',
lightcyan: '#e0ffff',
lightgoldenrodyellow: '#fafad2',
lightgray: '#d3d3d3',
lightgreen: '#90ee90',
lightgrey: '#d3d3d3',
lightpink: '#ffb6c1',
lightsalmon: '#ffa07a',
lightseagreen: '#20b2aa',
lightskyblue: '#87cefa',
lightslategray: '#778899',
lightslategrey: '#778899',
lightsteelblue: '#b0c4de',
lightyellow: '#ffffe0',
lime: '#00ff00',
limegreen: '#32cd32',
linen: '#faf0e6',
magenta: '#ff00ff',
maroon: '#800000',
mediumaquamarine: '#66cdaa',
mediumblue: '#0000cd',
mediumorchid: '#ba55d3',
mediumpurple: '#9370db',
mediumseagreen: '#3cb371',
mediumslateblue: '#7b68ee',
mediumspringgreen: '#00fa9a',
mediumturquoise: '#48d1cc',
mediumvioletred: '#c71585',
midnightblue: '#191970',
mintcream: '#f5fffa',
mistyrose: '#ffe4e1',
moccasin: '#ffe4b5',
navajowhite: '#ffdead',
navy: '#000080',
oldlace: '#fdf5e6',
olive: '#808000',
olivedrab: '#6b8e23',
orange: '#ffa500',
orangered: '#ff4500',
orchid: '#da70d6',
palegoldenrod: '#eee8aa',
palegreen: '#98fb98',
paleturquoise: '#afeeee',
palevioletred: '#db7093',
papayawhip: '#ffefd5',
peachpuff: '#ffdab9',
peru: '#cd853f',
pink: '#ffc0cb',
plum: '#dda0dd',
powderblue: '#b0e0e6',
purple: '#800080',
rebeccapurple: '#663399',
red: '#ff0000',
rosybrown: '#bc8f8f',
royalblue: '#4169e1',
saddlebrown: '#8b4513',
salmon: '#fa8072',
sandybrown: '#f4a460',
seagreen: '#2e8b57',
seashell: '#fff5ee',
sienna: '#a0522d',
silver: '#c0c0c0',
skyblue: '#87ceeb',
slateblue: '#6a5acd',
slategray: '#708090',
slategrey: '#708090',
snow: '#fffafa',
springgreen: '#00ff7f',
steelblue: '#4682b4',
tan: '#d2b48c',
teal: '#008080',
thistle: '#d8bfd8',
tomato: '#ff6347',
turquoise: '#40e0d0',
violet: '#ee82ee',
wheat: '#f5deb3',
white: '#ffffff',
whitesmoke: '#f5f5f5',
yellow: '#ffff00',
yellowgreen: '#9acd32',
};

View File

@@ -0,0 +1,183 @@
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
import { convertHexToDecimal, hslToRgb, hsvToRgb, parseIntFromHex, rgbToRgb, } from './conversion.js';
import { names } from './css-color-names.js';
import { boundAlpha, convertToPercentage } from './util.js';
/**
* Given a string or object, convert that input to RGB
*
* Possible string inputs:
* ```
* "red"
* "#f00" or "f00"
* "#ff0000" or "ff0000"
* "#ff000000" or "ff000000"
* "rgb 255 0 0" or "rgb (255, 0, 0)"
* "rgb 1.0 0 0" or "rgb (1, 0, 0)"
* "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
* "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
* "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
* "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
* "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
* ```
*/
export function inputToRGB(color) {
var rgb = { r: 0, g: 0, b: 0 };
var a = 1;
var s = null;
var v = null;
var l = null;
var ok = false;
var format = false;
if (typeof color === 'string') {
color = stringInputToObject(color);
}
if (typeof color === 'object') {
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
rgb = rgbToRgb(color.r, color.g, color.b);
ok = true;
format = String(color.r).substr(-1) === '%' ? 'prgb' : 'rgb';
}
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
s = convertToPercentage(color.s);
v = convertToPercentage(color.v);
rgb = hsvToRgb(color.h, s, v);
ok = true;
format = 'hsv';
}
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
s = convertToPercentage(color.s);
l = convertToPercentage(color.l);
rgb = hslToRgb(color.h, s, l);
ok = true;
format = 'hsl';
}
if (Object.prototype.hasOwnProperty.call(color, 'a')) {
a = color.a;
}
}
a = boundAlpha(a);
return {
ok: ok,
format: color.format || format,
r: Math.min(255, Math.max(rgb.r, 0)),
g: Math.min(255, Math.max(rgb.g, 0)),
b: Math.min(255, Math.max(rgb.b, 0)),
a: a,
};
}
// <http://www.w3.org/TR/css3-values/#integers>
var CSS_INTEGER = '[-\\+]?\\d+%?';
// <http://www.w3.org/TR/css3-values/#number-value>
var CSS_NUMBER = '[-\\+]?\\d*\\.\\d+%?';
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
var CSS_UNIT = "(?:".concat(CSS_NUMBER, ")|(?:").concat(CSS_INTEGER, ")");
// Actual matching.
// Parentheses and commas are optional, but not required.
// Whitespace can take the place of commas or opening paren
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(".concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")[,|\\s]+(").concat(CSS_UNIT, ")\\s*\\)?");
var matchers = {
CSS_UNIT: new RegExp(CSS_UNIT),
rgb: new RegExp('rgb' + PERMISSIVE_MATCH3),
rgba: new RegExp('rgba' + PERMISSIVE_MATCH4),
hsl: new RegExp('hsl' + PERMISSIVE_MATCH3),
hsla: new RegExp('hsla' + PERMISSIVE_MATCH4),
hsv: new RegExp('hsv' + PERMISSIVE_MATCH3),
hsva: new RegExp('hsva' + PERMISSIVE_MATCH4),
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
};
/**
* Permissive string parsing. Take in a number of formats, and output an object
* based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
*/
export function stringInputToObject(color) {
color = color.trim().toLowerCase();
if (color.length === 0) {
return false;
}
var named = false;
if (names[color]) {
color = names[color];
named = true;
}
else if (color === 'transparent') {
return { r: 0, g: 0, b: 0, a: 0, format: 'name' };
}
// Try to match string input using regular expressions.
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
// Just return an object and let the conversion functions handle that.
// This way the result will be the same whether the tinycolor is initialized with string or object.
var match = matchers.rgb.exec(color);
if (match) {
return { r: match[1], g: match[2], b: match[3] };
}
match = matchers.rgba.exec(color);
if (match) {
return { r: match[1], g: match[2], b: match[3], a: match[4] };
}
match = matchers.hsl.exec(color);
if (match) {
return { h: match[1], s: match[2], l: match[3] };
}
match = matchers.hsla.exec(color);
if (match) {
return { h: match[1], s: match[2], l: match[3], a: match[4] };
}
match = matchers.hsv.exec(color);
if (match) {
return { h: match[1], s: match[2], v: match[3] };
}
match = matchers.hsva.exec(color);
if (match) {
return { h: match[1], s: match[2], v: match[3], a: match[4] };
}
match = matchers.hex8.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1]),
g: parseIntFromHex(match[2]),
b: parseIntFromHex(match[3]),
a: convertHexToDecimal(match[4]),
format: named ? 'name' : 'hex8',
};
}
match = matchers.hex6.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1]),
g: parseIntFromHex(match[2]),
b: parseIntFromHex(match[3]),
format: named ? 'name' : 'hex',
};
}
match = matchers.hex4.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1] + match[1]),
g: parseIntFromHex(match[2] + match[2]),
b: parseIntFromHex(match[3] + match[3]),
a: convertHexToDecimal(match[4] + match[4]),
format: named ? 'name' : 'hex8',
};
}
match = matchers.hex3.exec(color);
if (match) {
return {
r: parseIntFromHex(match[1] + match[1]),
g: parseIntFromHex(match[2] + match[2]),
b: parseIntFromHex(match[3] + match[3]),
format: named ? 'name' : 'hex',
};
}
return false;
}
/**
* Check to see if it looks like a CSS unit
* (see `matchers` above for definition).
*/
export function isValidCSSUnit(color) {
return Boolean(matchers.CSS_UNIT.exec(String(color)));
}

25
node_modules/@ctrl/tinycolor/dist/module/from-ratio.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import { TinyColor } from './index.js';
import { convertToPercentage } from './util.js';
/**
* If input is an object, force 1 into "1.0" to handle ratios properly
* String input requires "1.0" as input, so 1 will be treated as 1
*/
export function fromRatio(ratio, opts) {
var newColor = {
r: convertToPercentage(ratio.r),
g: convertToPercentage(ratio.g),
b: convertToPercentage(ratio.b),
};
if (ratio.a !== undefined) {
newColor.a = Number(ratio.a);
}
return new TinyColor(newColor, opts);
}
/** old random function */
export function legacyRandom() {
return new TinyColor({
r: Math.random(),
g: Math.random(),
b: Math.random(),
});
}

508
node_modules/@ctrl/tinycolor/dist/module/index.js generated vendored Normal file
View File

@@ -0,0 +1,508 @@
import { numberInputToObject, rgbaToHex, rgbToHex, rgbToHsl, rgbToHsv } from './conversion.js';
import { names } from './css-color-names.js';
import { inputToRGB } from './format-input';
import { bound01, boundAlpha, clamp01 } from './util.js';
var TinyColor = /** @class */ (function () {
function TinyColor(color, opts) {
if (color === void 0) { color = ''; }
if (opts === void 0) { opts = {}; }
var _a;
// If input is already a tinycolor, return itself
if (color instanceof TinyColor) {
// eslint-disable-next-line no-constructor-return
return color;
}
if (typeof color === 'number') {
color = numberInputToObject(color);
}
this.originalInput = color;
var rgb = inputToRGB(color);
this.originalInput = color;
this.r = rgb.r;
this.g = rgb.g;
this.b = rgb.b;
this.a = rgb.a;
this.roundA = Math.round(100 * this.a) / 100;
this.format = (_a = opts.format) !== null && _a !== void 0 ? _a : rgb.format;
this.gradientType = opts.gradientType;
// Don't let the range of [0,255] come back in [0,1].
// Potentially lose a little bit of precision here, but will fix issues where
// .5 gets interpreted as half of the total, instead of half of 1
// If it was supposed to be 128, this was already taken care of by `inputToRgb`
if (this.r < 1) {
this.r = Math.round(this.r);
}
if (this.g < 1) {
this.g = Math.round(this.g);
}
if (this.b < 1) {
this.b = Math.round(this.b);
}
this.isValid = rgb.ok;
}
TinyColor.prototype.isDark = function () {
return this.getBrightness() < 128;
};
TinyColor.prototype.isLight = function () {
return !this.isDark();
};
/**
* Returns the perceived brightness of the color, from 0-255.
*/
TinyColor.prototype.getBrightness = function () {
// http://www.w3.org/TR/AERT#color-contrast
var rgb = this.toRgb();
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
};
/**
* Returns the perceived luminance of a color, from 0-1.
*/
TinyColor.prototype.getLuminance = function () {
// http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
var rgb = this.toRgb();
var R;
var G;
var B;
var RsRGB = rgb.r / 255;
var GsRGB = rgb.g / 255;
var BsRGB = rgb.b / 255;
if (RsRGB <= 0.03928) {
R = RsRGB / 12.92;
}
else {
// eslint-disable-next-line prefer-exponentiation-operator
R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
}
if (GsRGB <= 0.03928) {
G = GsRGB / 12.92;
}
else {
// eslint-disable-next-line prefer-exponentiation-operator
G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
}
if (BsRGB <= 0.03928) {
B = BsRGB / 12.92;
}
else {
// eslint-disable-next-line prefer-exponentiation-operator
B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
}
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
};
/**
* Returns the alpha value of a color, from 0-1.
*/
TinyColor.prototype.getAlpha = function () {
return this.a;
};
/**
* Sets the alpha value on the current color.
*
* @param alpha - The new alpha value. The accepted range is 0-1.
*/
TinyColor.prototype.setAlpha = function (alpha) {
this.a = boundAlpha(alpha);
this.roundA = Math.round(100 * this.a) / 100;
return this;
};
/**
* Returns whether the color is monochrome.
*/
TinyColor.prototype.isMonochrome = function () {
var s = this.toHsl().s;
return s === 0;
};
/**
* Returns the object as a HSVA object.
*/
TinyColor.prototype.toHsv = function () {
var hsv = rgbToHsv(this.r, this.g, this.b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
};
/**
* Returns the hsva values interpolated into a string with the following format:
* "hsva(xxx, xxx, xxx, xx)".
*/
TinyColor.prototype.toHsvString = function () {
var hsv = rgbToHsv(this.r, this.g, this.b);
var h = Math.round(hsv.h * 360);
var s = Math.round(hsv.s * 100);
var v = Math.round(hsv.v * 100);
return this.a === 1 ? "hsv(".concat(h, ", ").concat(s, "%, ").concat(v, "%)") : "hsva(".concat(h, ", ").concat(s, "%, ").concat(v, "%, ").concat(this.roundA, ")");
};
/**
* Returns the object as a HSLA object.
*/
TinyColor.prototype.toHsl = function () {
var hsl = rgbToHsl(this.r, this.g, this.b);
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
};
/**
* Returns the hsla values interpolated into a string with the following format:
* "hsla(xxx, xxx, xxx, xx)".
*/
TinyColor.prototype.toHslString = function () {
var hsl = rgbToHsl(this.r, this.g, this.b);
var h = Math.round(hsl.h * 360);
var s = Math.round(hsl.s * 100);
var l = Math.round(hsl.l * 100);
return this.a === 1 ? "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)") : "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(this.roundA, ")");
};
/**
* Returns the hex value of the color.
* @param allow3Char will shorten hex value to 3 char if possible
*/
TinyColor.prototype.toHex = function (allow3Char) {
if (allow3Char === void 0) { allow3Char = false; }
return rgbToHex(this.r, this.g, this.b, allow3Char);
};
/**
* Returns the hex value of the color -with a # prefixed.
* @param allow3Char will shorten hex value to 3 char if possible
*/
TinyColor.prototype.toHexString = function (allow3Char) {
if (allow3Char === void 0) { allow3Char = false; }
return '#' + this.toHex(allow3Char);
};
/**
* Returns the hex 8 value of the color.
* @param allow4Char will shorten hex value to 4 char if possible
*/
TinyColor.prototype.toHex8 = function (allow4Char) {
if (allow4Char === void 0) { allow4Char = false; }
return rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
};
/**
* Returns the hex 8 value of the color -with a # prefixed.
* @param allow4Char will shorten hex value to 4 char if possible
*/
TinyColor.prototype.toHex8String = function (allow4Char) {
if (allow4Char === void 0) { allow4Char = false; }
return '#' + this.toHex8(allow4Char);
};
/**
* Returns the shorter hex value of the color depends on its alpha -with a # prefixed.
* @param allowShortChar will shorten hex value to 3 or 4 char if possible
*/
TinyColor.prototype.toHexShortString = function (allowShortChar) {
if (allowShortChar === void 0) { allowShortChar = false; }
return this.a === 1 ? this.toHexString(allowShortChar) : this.toHex8String(allowShortChar);
};
/**
* Returns the object as a RGBA object.
*/
TinyColor.prototype.toRgb = function () {
return {
r: Math.round(this.r),
g: Math.round(this.g),
b: Math.round(this.b),
a: this.a,
};
};
/**
* Returns the RGBA values interpolated into a string with the following format:
* "RGBA(xxx, xxx, xxx, xx)".
*/
TinyColor.prototype.toRgbString = function () {
var r = Math.round(this.r);
var g = Math.round(this.g);
var b = Math.round(this.b);
return this.a === 1 ? "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")") : "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(this.roundA, ")");
};
/**
* Returns the object as a RGBA object.
*/
TinyColor.prototype.toPercentageRgb = function () {
var fmt = function (x) { return "".concat(Math.round(bound01(x, 255) * 100), "%"); };
return {
r: fmt(this.r),
g: fmt(this.g),
b: fmt(this.b),
a: this.a,
};
};
/**
* Returns the RGBA relative values interpolated into a string
*/
TinyColor.prototype.toPercentageRgbString = function () {
var rnd = function (x) { return Math.round(bound01(x, 255) * 100); };
return this.a === 1
? "rgb(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%)")
: "rgba(".concat(rnd(this.r), "%, ").concat(rnd(this.g), "%, ").concat(rnd(this.b), "%, ").concat(this.roundA, ")");
};
/**
* The 'real' name of the color -if there is one.
*/
TinyColor.prototype.toName = function () {
if (this.a === 0) {
return 'transparent';
}
if (this.a < 1) {
return false;
}
var hex = '#' + rgbToHex(this.r, this.g, this.b, false);
for (var _i = 0, _a = Object.entries(names); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
if (hex === value) {
return key;
}
}
return false;
};
TinyColor.prototype.toString = function (format) {
var formatSet = Boolean(format);
format = format !== null && format !== void 0 ? format : this.format;
var formattedString = false;
var hasAlpha = this.a < 1 && this.a >= 0;
var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');
if (needsAlphaFormat) {
// Special case for "transparent", all other non-alpha formats
// will return rgba when there is transparency.
if (format === 'name' && this.a === 0) {
return this.toName();
}
return this.toRgbString();
}
if (format === 'rgb') {
formattedString = this.toRgbString();
}
if (format === 'prgb') {
formattedString = this.toPercentageRgbString();
}
if (format === 'hex' || format === 'hex6') {
formattedString = this.toHexString();
}
if (format === 'hex3') {
formattedString = this.toHexString(true);
}
if (format === 'hex4') {
formattedString = this.toHex8String(true);
}
if (format === 'hex8') {
formattedString = this.toHex8String();
}
if (format === 'name') {
formattedString = this.toName();
}
if (format === 'hsl') {
formattedString = this.toHslString();
}
if (format === 'hsv') {
formattedString = this.toHsvString();
}
return formattedString || this.toHexString();
};
TinyColor.prototype.toNumber = function () {
return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
};
TinyColor.prototype.clone = function () {
return new TinyColor(this.toString());
};
/**
* Lighten the color a given amount. Providing 100 will always return white.
* @param amount - valid between 1-100
*/
TinyColor.prototype.lighten = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.l += amount / 100;
hsl.l = clamp01(hsl.l);
return new TinyColor(hsl);
};
/**
* Brighten the color a given amount, from 0 to 100.
* @param amount - valid between 1-100
*/
TinyColor.prototype.brighten = function (amount) {
if (amount === void 0) { amount = 10; }
var rgb = this.toRgb();
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
return new TinyColor(rgb);
};
/**
* Darken the color a given amount, from 0 to 100.
* Providing 100 will always return black.
* @param amount - valid between 1-100
*/
TinyColor.prototype.darken = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.l -= amount / 100;
hsl.l = clamp01(hsl.l);
return new TinyColor(hsl);
};
/**
* Mix the color with pure white, from 0 to 100.
* Providing 0 will do nothing, providing 100 will always return white.
* @param amount - valid between 1-100
*/
TinyColor.prototype.tint = function (amount) {
if (amount === void 0) { amount = 10; }
return this.mix('white', amount);
};
/**
* Mix the color with pure black, from 0 to 100.
* Providing 0 will do nothing, providing 100 will always return black.
* @param amount - valid between 1-100
*/
TinyColor.prototype.shade = function (amount) {
if (amount === void 0) { amount = 10; }
return this.mix('black', amount);
};
/**
* Desaturate the color a given amount, from 0 to 100.
* Providing 100 will is the same as calling greyscale
* @param amount - valid between 1-100
*/
TinyColor.prototype.desaturate = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.s -= amount / 100;
hsl.s = clamp01(hsl.s);
return new TinyColor(hsl);
};
/**
* Saturate the color a given amount, from 0 to 100.
* @param amount - valid between 1-100
*/
TinyColor.prototype.saturate = function (amount) {
if (amount === void 0) { amount = 10; }
var hsl = this.toHsl();
hsl.s += amount / 100;
hsl.s = clamp01(hsl.s);
return new TinyColor(hsl);
};
/**
* Completely desaturates a color into greyscale.
* Same as calling `desaturate(100)`
*/
TinyColor.prototype.greyscale = function () {
return this.desaturate(100);
};
/**
* Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
* Values outside of this range will be wrapped into this range.
*/
TinyColor.prototype.spin = function (amount) {
var hsl = this.toHsl();
var hue = (hsl.h + amount) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return new TinyColor(hsl);
};
/**
* Mix the current color a given amount with another color, from 0 to 100.
* 0 means no mixing (return current color).
*/
TinyColor.prototype.mix = function (color, amount) {
if (amount === void 0) { amount = 50; }
var rgb1 = this.toRgb();
var rgb2 = new TinyColor(color).toRgb();
var p = amount / 100;
var rgba = {
r: (rgb2.r - rgb1.r) * p + rgb1.r,
g: (rgb2.g - rgb1.g) * p + rgb1.g,
b: (rgb2.b - rgb1.b) * p + rgb1.b,
a: (rgb2.a - rgb1.a) * p + rgb1.a,
};
return new TinyColor(rgba);
};
TinyColor.prototype.analogous = function (results, slices) {
if (results === void 0) { results = 6; }
if (slices === void 0) { slices = 30; }
var hsl = this.toHsl();
var part = 360 / slices;
var ret = [this];
for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results;) {
hsl.h = (hsl.h + part) % 360;
ret.push(new TinyColor(hsl));
}
return ret;
};
/**
* taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
*/
TinyColor.prototype.complement = function () {
var hsl = this.toHsl();
hsl.h = (hsl.h + 180) % 360;
return new TinyColor(hsl);
};
TinyColor.prototype.monochromatic = function (results) {
if (results === void 0) { results = 6; }
var hsv = this.toHsv();
var h = hsv.h;
var s = hsv.s;
var v = hsv.v;
var res = [];
var modification = 1 / results;
while (results--) {
res.push(new TinyColor({ h: h, s: s, v: v }));
v = (v + modification) % 1;
}
return res;
};
TinyColor.prototype.splitcomplement = function () {
var hsl = this.toHsl();
var h = hsl.h;
return [
this,
new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),
];
};
/**
* Compute how the color would appear on a background
*/
TinyColor.prototype.onBackground = function (background) {
var fg = this.toRgb();
var bg = new TinyColor(background).toRgb();
var alpha = fg.a + bg.a * (1 - fg.a);
return new TinyColor({
r: (fg.r * fg.a + bg.r * bg.a * (1 - fg.a)) / alpha,
g: (fg.g * fg.a + bg.g * bg.a * (1 - fg.a)) / alpha,
b: (fg.b * fg.a + bg.b * bg.a * (1 - fg.a)) / alpha,
a: alpha,
});
};
/**
* Alias for `polyad(3)`
*/
TinyColor.prototype.triad = function () {
return this.polyad(3);
};
/**
* Alias for `polyad(4)`
*/
TinyColor.prototype.tetrad = function () {
return this.polyad(4);
};
/**
* Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
* monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
*/
TinyColor.prototype.polyad = function (n) {
var hsl = this.toHsl();
var h = hsl.h;
var result = [this];
var increment = 360 / n;
for (var i = 1; i < n; i++) {
result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
}
return result;
};
/**
* compare color vs current color
*/
TinyColor.prototype.equals = function (color) {
return this.toRgbString() === new TinyColor(color).toRgbString();
};
return TinyColor;
}());
export { TinyColor };
// kept for backwards compatability with v1
export function tinycolor(color, opts) {
if (color === void 0) { color = ''; }
if (opts === void 0) { opts = {}; }
return new TinyColor(color, opts);
}

View File

@@ -0,0 +1 @@
export {};

12
node_modules/@ctrl/tinycolor/dist/module/public_api.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
import { tinycolor } from './index.js';
export * from './index.js';
export * from './css-color-names.js';
export * from './readability.js';
export * from './to-ms-filter.js';
export * from './from-ratio.js';
export * from './format-input.js';
export * from './random.js';
export * from './interfaces.js';
export * from './conversion.js';
// kept for backwards compatability with v1
export default tinycolor;

278
node_modules/@ctrl/tinycolor/dist/module/random.js generated vendored Normal file
View File

@@ -0,0 +1,278 @@
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
// randomColor by David Merfield under the CC0 license
// https://github.com/davidmerfield/randomColor/
import { TinyColor } from './index.js';
export function random(options) {
if (options === void 0) { options = {}; }
// Check if we need to generate multiple colors
if (options.count !== undefined &&
options.count !== null) {
var totalColors = options.count;
var colors = [];
options.count = undefined;
while (totalColors > colors.length) {
// Since we're generating multiple colors,
// incremement the seed. Otherwise we'd just
// generate the same color each time...
options.count = null;
if (options.seed) {
options.seed += 1;
}
colors.push(random(options));
}
options.count = totalColors;
return colors;
}
// First we pick a hue (H)
var h = pickHue(options.hue, options.seed);
// Then use H to determine saturation (S)
var s = pickSaturation(h, options);
// Then use S and H to determine brightness (B).
var v = pickBrightness(h, s, options);
var res = { h: h, s: s, v: v };
if (options.alpha !== undefined) {
res.a = options.alpha;
}
// Then we return the HSB color in the desired format
return new TinyColor(res);
}
function pickHue(hue, seed) {
var hueRange = getHueRange(hue);
var res = randomWithin(hueRange, seed);
// Instead of storing red as two seperate ranges,
// we group them, using negative numbers
if (res < 0) {
res = 360 + res;
}
return res;
}
function pickSaturation(hue, options) {
if (options.hue === 'monochrome') {
return 0;
}
if (options.luminosity === 'random') {
return randomWithin([0, 100], options.seed);
}
var saturationRange = getColorInfo(hue).saturationRange;
var sMin = saturationRange[0];
var sMax = saturationRange[1];
switch (options.luminosity) {
case 'bright':
sMin = 55;
break;
case 'dark':
sMin = sMax - 10;
break;
case 'light':
sMax = 55;
break;
default:
break;
}
return randomWithin([sMin, sMax], options.seed);
}
function pickBrightness(H, S, options) {
var bMin = getMinimumBrightness(H, S);
var bMax = 100;
switch (options.luminosity) {
case 'dark':
bMax = bMin + 20;
break;
case 'light':
bMin = (bMax + bMin) / 2;
break;
case 'random':
bMin = 0;
bMax = 100;
break;
default:
break;
}
return randomWithin([bMin, bMax], options.seed);
}
function getMinimumBrightness(H, S) {
var lowerBounds = getColorInfo(H).lowerBounds;
for (var i = 0; i < lowerBounds.length - 1; i++) {
var s1 = lowerBounds[i][0];
var v1 = lowerBounds[i][1];
var s2 = lowerBounds[i + 1][0];
var v2 = lowerBounds[i + 1][1];
if (S >= s1 && S <= s2) {
var m = (v2 - v1) / (s2 - s1);
var b = v1 - m * s1;
return m * S + b;
}
}
return 0;
}
function getHueRange(colorInput) {
var num = parseInt(colorInput, 10);
if (!Number.isNaN(num) && num < 360 && num > 0) {
return [num, num];
}
if (typeof colorInput === 'string') {
var namedColor = bounds.find(function (n) { return n.name === colorInput; });
if (namedColor) {
var color = defineColor(namedColor);
if (color.hueRange) {
return color.hueRange;
}
}
var parsed = new TinyColor(colorInput);
if (parsed.isValid) {
var hue = parsed.toHsv().h;
return [hue, hue];
}
}
return [0, 360];
}
function getColorInfo(hue) {
// Maps red colors to make picking hue easier
if (hue >= 334 && hue <= 360) {
hue -= 360;
}
for (var _i = 0, bounds_1 = bounds; _i < bounds_1.length; _i++) {
var bound = bounds_1[_i];
var color = defineColor(bound);
if (color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1]) {
return color;
}
}
throw Error('Color not found');
}
function randomWithin(range, seed) {
if (seed === undefined) {
return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0]));
}
// Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
var max = range[1] || 1;
var min = range[0] || 0;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280.0;
return Math.floor(min + rnd * (max - min));
}
function defineColor(bound) {
var sMin = bound.lowerBounds[0][0];
var sMax = bound.lowerBounds[bound.lowerBounds.length - 1][0];
var bMin = bound.lowerBounds[bound.lowerBounds.length - 1][1];
var bMax = bound.lowerBounds[0][1];
return {
name: bound.name,
hueRange: bound.hueRange,
lowerBounds: bound.lowerBounds,
saturationRange: [sMin, sMax],
brightnessRange: [bMin, bMax],
};
}
/**
* @hidden
*/
export var bounds = [
{
name: 'monochrome',
hueRange: null,
lowerBounds: [
[0, 0],
[100, 0],
],
},
{
name: 'red',
hueRange: [-26, 18],
lowerBounds: [
[20, 100],
[30, 92],
[40, 89],
[50, 85],
[60, 78],
[70, 70],
[80, 60],
[90, 55],
[100, 50],
],
},
{
name: 'orange',
hueRange: [19, 46],
lowerBounds: [
[20, 100],
[30, 93],
[40, 88],
[50, 86],
[60, 85],
[70, 70],
[100, 70],
],
},
{
name: 'yellow',
hueRange: [47, 62],
lowerBounds: [
[25, 100],
[40, 94],
[50, 89],
[60, 86],
[70, 84],
[80, 82],
[90, 80],
[100, 75],
],
},
{
name: 'green',
hueRange: [63, 178],
lowerBounds: [
[30, 100],
[40, 90],
[50, 85],
[60, 81],
[70, 74],
[80, 64],
[90, 50],
[100, 40],
],
},
{
name: 'blue',
hueRange: [179, 257],
lowerBounds: [
[20, 100],
[30, 86],
[40, 80],
[50, 74],
[60, 60],
[70, 52],
[80, 44],
[90, 39],
[100, 35],
],
},
{
name: 'purple',
hueRange: [258, 282],
lowerBounds: [
[20, 100],
[30, 87],
[40, 79],
[50, 70],
[60, 65],
[70, 59],
[80, 52],
[90, 45],
[100, 42],
],
},
{
name: 'pink',
hueRange: [283, 334],
lowerBounds: [
[20, 100],
[30, 90],
[40, 86],
[60, 84],
[80, 80],
[90, 75],
[100, 73],
],
},
];

View File

@@ -0,0 +1,80 @@
import { TinyColor } from './index.js';
// Readability Functions
// ---------------------
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
/**
* AKA `contrast`
*
* Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
*/
export function readability(color1, color2) {
var c1 = new TinyColor(color1);
var c2 = new TinyColor(color2);
return ((Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) /
(Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05));
}
/**
* Ensure that foreground and background color combinations meet WCAG2 guidelines.
* The third argument is an object.
* the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
* the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
* If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
*
* Example
* ```ts
* new TinyColor().isReadable('#000', '#111') => false
* new TinyColor().isReadable('#000', '#111', { level: 'AA', size: 'large' }) => false
* ```
*/
export function isReadable(color1, color2, wcag2) {
var _a, _b;
if (wcag2 === void 0) { wcag2 = { level: 'AA', size: 'small' }; }
var readabilityLevel = readability(color1, color2);
switch (((_a = wcag2.level) !== null && _a !== void 0 ? _a : 'AA') + ((_b = wcag2.size) !== null && _b !== void 0 ? _b : 'small')) {
case 'AAsmall':
case 'AAAlarge':
return readabilityLevel >= 4.5;
case 'AAlarge':
return readabilityLevel >= 3;
case 'AAAsmall':
return readabilityLevel >= 7;
default:
return false;
}
}
/**
* Given a base color and a list of possible foreground or background
* colors for that base, returns the most readable color.
* Optionally returns Black or White if the most readable color is unreadable.
*
* @param baseColor - the base color.
* @param colorList - array of colors to pick the most readable one from.
* @param args - and object with extra arguments
*
* Example
* ```ts
* new TinyColor().mostReadable('#123', ['#124", "#125'], { includeFallbackColors: false }).toHexString(); // "#112255"
* new TinyColor().mostReadable('#123', ['#124", "#125'],{ includeFallbackColors: true }).toHexString(); // "#ffffff"
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'large' }).toHexString(); // "#faf3f3"
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'small' }).toHexString(); // "#ffffff"
* ```
*/
export function mostReadable(baseColor, colorList, args) {
if (args === void 0) { args = { includeFallbackColors: false, level: 'AA', size: 'small' }; }
var bestColor = null;
var bestScore = 0;
var includeFallbackColors = args.includeFallbackColors, level = args.level, size = args.size;
for (var _i = 0, colorList_1 = colorList; _i < colorList_1.length; _i++) {
var color = colorList_1[_i];
var score = readability(baseColor, color);
if (score > bestScore) {
bestScore = score;
bestColor = new TinyColor(color);
}
}
if (isReadable(baseColor, bestColor, { level: level, size: size }) || !includeFallbackColors) {
return bestColor;
}
args.includeFallbackColors = false;
return mostReadable(baseColor, ['#fff', '#000'], args);
}

View File

@@ -0,0 +1,16 @@
import { rgbaToArgbHex } from './conversion.js';
import { TinyColor } from './index.js';
/**
* Returns the color represented as a Microsoft filter for use in old versions of IE.
*/
export function toMsFilter(firstColor, secondColor) {
var color = new TinyColor(firstColor);
var hex8String = '#' + rgbaToArgbHex(color.r, color.g, color.b, color.a);
var secondHex8String = hex8String;
var gradientType = color.gradientType ? 'GradientType = 1, ' : '';
if (secondColor) {
var s = new TinyColor(secondColor);
secondHex8String = '#' + rgbaToArgbHex(s.r, s.g, s.b, s.a);
}
return "progid:DXImageTransform.Microsoft.gradient(".concat(gradientType, "startColorstr=").concat(hex8String, ",endColorstr=").concat(secondHex8String, ")");
}

20
node_modules/@ctrl/tinycolor/dist/module/umd_api.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import { names } from './css-color-names.js';
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input.js';
import { fromRatio, legacyRandom } from './from-ratio.js';
import { TinyColor, tinycolor } from './index.js';
import { random } from './random.js';
import { mostReadable, readability } from './readability.js';
import { toMsFilter } from './to-ms-filter.js';
var tinycolorumd = tinycolor;
tinycolorumd.TinyColor = TinyColor;
tinycolorumd.readability = readability;
tinycolorumd.mostReadable = mostReadable;
tinycolorumd.random = random;
tinycolorumd.names = names;
tinycolorumd.fromRatio = fromRatio;
tinycolorumd.legacyRandom = legacyRandom;
tinycolorumd.toMsFilter = toMsFilter;
tinycolorumd.inputToRGB = inputToRGB;
tinycolorumd.stringInputToObject = stringInputToObject;
tinycolorumd.isValidCSSUnit = isValidCSSUnit;
export default tinycolorumd;

82
node_modules/@ctrl/tinycolor/dist/module/util.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
/**
* Take input from [0, n] and return it as [0, 1]
* @hidden
*/
export function bound01(n, max) {
if (isOnePointZero(n)) {
n = '100%';
}
var isPercent = isPercentage(n);
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
// Automatically convert percentage into number
if (isPercent) {
n = parseInt(String(n * max), 10) / 100;
}
// Handle floating point rounding errors
if (Math.abs(n - max) < 0.000001) {
return 1;
}
// Convert into [0, 1] range if it isn't already
if (max === 360) {
// If n is a hue given in degrees,
// wrap around out-of-range values into [0, 360] range
// then convert into [0, 1].
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
}
else {
// If n not a hue given in degrees
// Convert into [0, 1] range if it isn't already.
n = (n % max) / parseFloat(String(max));
}
return n;
}
/**
* Force a number between 0 and 1
* @hidden
*/
export function clamp01(val) {
return Math.min(1, Math.max(0, val));
}
/**
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
* @hidden
*/
export function isOnePointZero(n) {
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
}
/**
* Check to see if string passed in is a percentage
* @hidden
*/
export function isPercentage(n) {
return typeof n === 'string' && n.indexOf('%') !== -1;
}
/**
* Return a valid alpha value [0,1] with all invalid values being set to 1
* @hidden
*/
export function boundAlpha(a) {
a = parseFloat(a);
if (isNaN(a) || a < 0 || a > 1) {
a = 1;
}
return a;
}
/**
* Replace a decimal with it's percentage value
* @hidden
*/
export function convertToPercentage(n) {
if (n <= 1) {
return "".concat(Number(n) * 100, "%");
}
return n;
}
/**
* Force a hex value to have 2 characters
* @hidden
*/
export function pad2(c) {
return c.length === 1 ? '0' + c : String(c);
}

11
node_modules/@ctrl/tinycolor/dist/public_api.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { tinycolor } from './index.js';
export * from './index.js';
export * from './css-color-names.js';
export * from './readability.js';
export * from './to-ms-filter.js';
export * from './from-ratio.js';
export * from './format-input.js';
export * from './random.js';
export * from './interfaces.js';
export * from './conversion.js';
export default tinycolor;

28
node_modules/@ctrl/tinycolor/dist/public_api.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
var index_js_1 = require("./index.js");
__exportStar(require("./index.js"), exports);
__exportStar(require("./css-color-names.js"), exports);
__exportStar(require("./readability.js"), exports);
__exportStar(require("./to-ms-filter.js"), exports);
__exportStar(require("./from-ratio.js"), exports);
__exportStar(require("./format-input.js"), exports);
__exportStar(require("./random.js"), exports);
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./conversion.js"), exports);
// kept for backwards compatability with v1
exports.default = index_js_1.tinycolor;

24
node_modules/@ctrl/tinycolor/dist/random.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { TinyColor } from './index.js';
export interface RandomOptions {
seed?: number;
hue?: number | string | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'monochrome';
luminosity?: 'random' | 'bright' | 'dark' | 'light';
alpha?: number;
}
export interface RandomCountOptions extends RandomOptions {
count?: number | null;
}
export declare function random(options?: RandomOptions): TinyColor;
export declare function random(options?: RandomCountOptions): TinyColor[];
/**
* @hidden
*/
export interface ColorBound {
name: string;
hueRange: [number, number] | null;
lowerBounds: Array<[number, number]>;
}
/**
* @hidden
*/
export declare const bounds: ColorBound[];

282
node_modules/@ctrl/tinycolor/dist/random.js generated vendored Normal file
View File

@@ -0,0 +1,282 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bounds = exports.random = void 0;
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
// randomColor by David Merfield under the CC0 license
// https://github.com/davidmerfield/randomColor/
var index_js_1 = require("./index.js");
function random(options) {
if (options === void 0) { options = {}; }
// Check if we need to generate multiple colors
if (options.count !== undefined &&
options.count !== null) {
var totalColors = options.count;
var colors = [];
options.count = undefined;
while (totalColors > colors.length) {
// Since we're generating multiple colors,
// incremement the seed. Otherwise we'd just
// generate the same color each time...
options.count = null;
if (options.seed) {
options.seed += 1;
}
colors.push(random(options));
}
options.count = totalColors;
return colors;
}
// First we pick a hue (H)
var h = pickHue(options.hue, options.seed);
// Then use H to determine saturation (S)
var s = pickSaturation(h, options);
// Then use S and H to determine brightness (B).
var v = pickBrightness(h, s, options);
var res = { h: h, s: s, v: v };
if (options.alpha !== undefined) {
res.a = options.alpha;
}
// Then we return the HSB color in the desired format
return new index_js_1.TinyColor(res);
}
exports.random = random;
function pickHue(hue, seed) {
var hueRange = getHueRange(hue);
var res = randomWithin(hueRange, seed);
// Instead of storing red as two seperate ranges,
// we group them, using negative numbers
if (res < 0) {
res = 360 + res;
}
return res;
}
function pickSaturation(hue, options) {
if (options.hue === 'monochrome') {
return 0;
}
if (options.luminosity === 'random') {
return randomWithin([0, 100], options.seed);
}
var saturationRange = getColorInfo(hue).saturationRange;
var sMin = saturationRange[0];
var sMax = saturationRange[1];
switch (options.luminosity) {
case 'bright':
sMin = 55;
break;
case 'dark':
sMin = sMax - 10;
break;
case 'light':
sMax = 55;
break;
default:
break;
}
return randomWithin([sMin, sMax], options.seed);
}
function pickBrightness(H, S, options) {
var bMin = getMinimumBrightness(H, S);
var bMax = 100;
switch (options.luminosity) {
case 'dark':
bMax = bMin + 20;
break;
case 'light':
bMin = (bMax + bMin) / 2;
break;
case 'random':
bMin = 0;
bMax = 100;
break;
default:
break;
}
return randomWithin([bMin, bMax], options.seed);
}
function getMinimumBrightness(H, S) {
var lowerBounds = getColorInfo(H).lowerBounds;
for (var i = 0; i < lowerBounds.length - 1; i++) {
var s1 = lowerBounds[i][0];
var v1 = lowerBounds[i][1];
var s2 = lowerBounds[i + 1][0];
var v2 = lowerBounds[i + 1][1];
if (S >= s1 && S <= s2) {
var m = (v2 - v1) / (s2 - s1);
var b = v1 - m * s1;
return m * S + b;
}
}
return 0;
}
function getHueRange(colorInput) {
var num = parseInt(colorInput, 10);
if (!Number.isNaN(num) && num < 360 && num > 0) {
return [num, num];
}
if (typeof colorInput === 'string') {
var namedColor = exports.bounds.find(function (n) { return n.name === colorInput; });
if (namedColor) {
var color = defineColor(namedColor);
if (color.hueRange) {
return color.hueRange;
}
}
var parsed = new index_js_1.TinyColor(colorInput);
if (parsed.isValid) {
var hue = parsed.toHsv().h;
return [hue, hue];
}
}
return [0, 360];
}
function getColorInfo(hue) {
// Maps red colors to make picking hue easier
if (hue >= 334 && hue <= 360) {
hue -= 360;
}
for (var _i = 0, bounds_1 = exports.bounds; _i < bounds_1.length; _i++) {
var bound = bounds_1[_i];
var color = defineColor(bound);
if (color.hueRange && hue >= color.hueRange[0] && hue <= color.hueRange[1]) {
return color;
}
}
throw Error('Color not found');
}
function randomWithin(range, seed) {
if (seed === undefined) {
return Math.floor(range[0] + Math.random() * (range[1] + 1 - range[0]));
}
// Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
var max = range[1] || 1;
var min = range[0] || 0;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280.0;
return Math.floor(min + rnd * (max - min));
}
function defineColor(bound) {
var sMin = bound.lowerBounds[0][0];
var sMax = bound.lowerBounds[bound.lowerBounds.length - 1][0];
var bMin = bound.lowerBounds[bound.lowerBounds.length - 1][1];
var bMax = bound.lowerBounds[0][1];
return {
name: bound.name,
hueRange: bound.hueRange,
lowerBounds: bound.lowerBounds,
saturationRange: [sMin, sMax],
brightnessRange: [bMin, bMax],
};
}
/**
* @hidden
*/
exports.bounds = [
{
name: 'monochrome',
hueRange: null,
lowerBounds: [
[0, 0],
[100, 0],
],
},
{
name: 'red',
hueRange: [-26, 18],
lowerBounds: [
[20, 100],
[30, 92],
[40, 89],
[50, 85],
[60, 78],
[70, 70],
[80, 60],
[90, 55],
[100, 50],
],
},
{
name: 'orange',
hueRange: [19, 46],
lowerBounds: [
[20, 100],
[30, 93],
[40, 88],
[50, 86],
[60, 85],
[70, 70],
[100, 70],
],
},
{
name: 'yellow',
hueRange: [47, 62],
lowerBounds: [
[25, 100],
[40, 94],
[50, 89],
[60, 86],
[70, 84],
[80, 82],
[90, 80],
[100, 75],
],
},
{
name: 'green',
hueRange: [63, 178],
lowerBounds: [
[30, 100],
[40, 90],
[50, 85],
[60, 81],
[70, 74],
[80, 64],
[90, 50],
[100, 40],
],
},
{
name: 'blue',
hueRange: [179, 257],
lowerBounds: [
[20, 100],
[30, 86],
[40, 80],
[50, 74],
[60, 60],
[70, 52],
[80, 44],
[90, 39],
[100, 35],
],
},
{
name: 'purple',
hueRange: [258, 282],
lowerBounds: [
[20, 100],
[30, 87],
[40, 79],
[50, 70],
[60, 65],
[70, 59],
[80, 52],
[90, 45],
[100, 42],
],
},
{
name: 'pink',
hueRange: [283, 334],
lowerBounds: [
[20, 100],
[30, 90],
[40, 86],
[60, 84],
[80, 80],
[90, 75],
[100, 73],
],
},
];

46
node_modules/@ctrl/tinycolor/dist/readability.d.ts generated vendored Normal file
View File

@@ -0,0 +1,46 @@
import { ColorInput, TinyColor } from './index.js';
/**
* AKA `contrast`
*
* Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
*/
export declare function readability(color1: ColorInput, color2: ColorInput): number;
export interface WCAG2Parms {
level?: 'AA' | 'AAA';
size?: 'large' | 'small';
}
/**
* Ensure that foreground and background color combinations meet WCAG2 guidelines.
* The third argument is an object.
* the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
* the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
* If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
*
* Example
* ```ts
* new TinyColor().isReadable('#000', '#111') => false
* new TinyColor().isReadable('#000', '#111', { level: 'AA', size: 'large' }) => false
* ```
*/
export declare function isReadable(color1: ColorInput, color2: ColorInput, wcag2?: WCAG2Parms): boolean;
export interface WCAG2FallbackParms extends WCAG2Parms {
includeFallbackColors?: boolean;
}
/**
* Given a base color and a list of possible foreground or background
* colors for that base, returns the most readable color.
* Optionally returns Black or White if the most readable color is unreadable.
*
* @param baseColor - the base color.
* @param colorList - array of colors to pick the most readable one from.
* @param args - and object with extra arguments
*
* Example
* ```ts
* new TinyColor().mostReadable('#123', ['#124", "#125'], { includeFallbackColors: false }).toHexString(); // "#112255"
* new TinyColor().mostReadable('#123', ['#124", "#125'],{ includeFallbackColors: true }).toHexString(); // "#ffffff"
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'large' }).toHexString(); // "#faf3f3"
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'small' }).toHexString(); // "#ffffff"
* ```
*/
export declare function mostReadable(baseColor: ColorInput, colorList: ColorInput[], args?: WCAG2FallbackParms): TinyColor | null;

86
node_modules/@ctrl/tinycolor/dist/readability.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mostReadable = exports.isReadable = exports.readability = void 0;
var index_js_1 = require("./index.js");
// Readability Functions
// ---------------------
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
/**
* AKA `contrast`
*
* Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
*/
function readability(color1, color2) {
var c1 = new index_js_1.TinyColor(color1);
var c2 = new index_js_1.TinyColor(color2);
return ((Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) /
(Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05));
}
exports.readability = readability;
/**
* Ensure that foreground and background color combinations meet WCAG2 guidelines.
* The third argument is an object.
* the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
* the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
* If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
*
* Example
* ```ts
* new TinyColor().isReadable('#000', '#111') => false
* new TinyColor().isReadable('#000', '#111', { level: 'AA', size: 'large' }) => false
* ```
*/
function isReadable(color1, color2, wcag2) {
var _a, _b;
if (wcag2 === void 0) { wcag2 = { level: 'AA', size: 'small' }; }
var readabilityLevel = readability(color1, color2);
switch (((_a = wcag2.level) !== null && _a !== void 0 ? _a : 'AA') + ((_b = wcag2.size) !== null && _b !== void 0 ? _b : 'small')) {
case 'AAsmall':
case 'AAAlarge':
return readabilityLevel >= 4.5;
case 'AAlarge':
return readabilityLevel >= 3;
case 'AAAsmall':
return readabilityLevel >= 7;
default:
return false;
}
}
exports.isReadable = isReadable;
/**
* Given a base color and a list of possible foreground or background
* colors for that base, returns the most readable color.
* Optionally returns Black or White if the most readable color is unreadable.
*
* @param baseColor - the base color.
* @param colorList - array of colors to pick the most readable one from.
* @param args - and object with extra arguments
*
* Example
* ```ts
* new TinyColor().mostReadable('#123', ['#124", "#125'], { includeFallbackColors: false }).toHexString(); // "#112255"
* new TinyColor().mostReadable('#123', ['#124", "#125'],{ includeFallbackColors: true }).toHexString(); // "#ffffff"
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'large' }).toHexString(); // "#faf3f3"
* new TinyColor().mostReadable('#a8015a', ["#faf3f3"], { includeFallbackColors:true, level: 'AAA', size: 'small' }).toHexString(); // "#ffffff"
* ```
*/
function mostReadable(baseColor, colorList, args) {
if (args === void 0) { args = { includeFallbackColors: false, level: 'AA', size: 'small' }; }
var bestColor = null;
var bestScore = 0;
var includeFallbackColors = args.includeFallbackColors, level = args.level, size = args.size;
for (var _i = 0, colorList_1 = colorList; _i < colorList_1.length; _i++) {
var color = colorList_1[_i];
var score = readability(baseColor, color);
if (score > bestScore) {
bestScore = score;
bestColor = new index_js_1.TinyColor(color);
}
}
if (isReadable(baseColor, bestColor, { level: level, size: size }) || !includeFallbackColors) {
return bestColor;
}
args.includeFallbackColors = false;
return mostReadable(baseColor, ['#fff', '#000'], args);
}
exports.mostReadable = mostReadable;

5
node_modules/@ctrl/tinycolor/dist/to-ms-filter.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { ColorInput } from './index.js';
/**
* Returns the color represented as a Microsoft filter for use in old versions of IE.
*/
export declare function toMsFilter(firstColor: ColorInput, secondColor?: ColorInput): string;

20
node_modules/@ctrl/tinycolor/dist/to-ms-filter.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMsFilter = void 0;
var conversion_js_1 = require("./conversion.js");
var index_js_1 = require("./index.js");
/**
* Returns the color represented as a Microsoft filter for use in old versions of IE.
*/
function toMsFilter(firstColor, secondColor) {
var color = new index_js_1.TinyColor(firstColor);
var hex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(color.r, color.g, color.b, color.a);
var secondHex8String = hex8String;
var gradientType = color.gradientType ? 'GradientType = 1, ' : '';
if (secondColor) {
var s = new index_js_1.TinyColor(secondColor);
secondHex8String = '#' + (0, conversion_js_1.rgbaToArgbHex)(s.r, s.g, s.b, s.a);
}
return "progid:DXImageTransform.Microsoft.gradient(".concat(gradientType, "startColorstr=").concat(hex8String, ",endColorstr=").concat(secondHex8String, ")");
}
exports.toMsFilter = toMsFilter;

23
node_modules/@ctrl/tinycolor/dist/umd_api.d.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { names } from './css-color-names.js';
import { inputToRGB, isValidCSSUnit, stringInputToObject } from './format-input.js';
import { fromRatio, legacyRandom } from './from-ratio.js';
import { TinyColor } from './index.js';
import { random } from './random.js';
import { mostReadable, readability } from './readability.js';
import { toMsFilter } from './to-ms-filter.js';
export interface TinyColorUMD {
(): TinyColor;
TinyColor: typeof TinyColor;
readability: typeof readability;
random: typeof random;
names: typeof names;
fromRatio: typeof fromRatio;
legacyRandom: typeof legacyRandom;
toMsFilter: typeof toMsFilter;
inputToRGB: typeof inputToRGB;
stringInputToObject: typeof stringInputToObject;
isValidCSSUnit: typeof isValidCSSUnit;
mostReadable: typeof mostReadable;
}
declare const tinycolorumd: TinyColorUMD;
export default tinycolorumd;

22
node_modules/@ctrl/tinycolor/dist/umd_api.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var css_color_names_js_1 = require("./css-color-names.js");
var format_input_js_1 = require("./format-input.js");
var from_ratio_js_1 = require("./from-ratio.js");
var index_js_1 = require("./index.js");
var random_js_1 = require("./random.js");
var readability_js_1 = require("./readability.js");
var to_ms_filter_js_1 = require("./to-ms-filter.js");
var tinycolorumd = index_js_1.tinycolor;
tinycolorumd.TinyColor = index_js_1.TinyColor;
tinycolorumd.readability = readability_js_1.readability;
tinycolorumd.mostReadable = readability_js_1.mostReadable;
tinycolorumd.random = random_js_1.random;
tinycolorumd.names = css_color_names_js_1.names;
tinycolorumd.fromRatio = from_ratio_js_1.fromRatio;
tinycolorumd.legacyRandom = from_ratio_js_1.legacyRandom;
tinycolorumd.toMsFilter = to_ms_filter_js_1.toMsFilter;
tinycolorumd.inputToRGB = format_input_js_1.inputToRGB;
tinycolorumd.stringInputToObject = format_input_js_1.stringInputToObject;
tinycolorumd.isValidCSSUnit = format_input_js_1.isValidCSSUnit;
exports.default = tinycolorumd;

36
node_modules/@ctrl/tinycolor/dist/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,36 @@
/**
* Take input from [0, n] and return it as [0, 1]
* @hidden
*/
export declare function bound01(n: any, max: number): number;
/**
* Force a number between 0 and 1
* @hidden
*/
export declare function clamp01(val: number): number;
/**
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
* @hidden
*/
export declare function isOnePointZero(n: string | number): boolean;
/**
* Check to see if string passed in is a percentage
* @hidden
*/
export declare function isPercentage(n: string | number): boolean;
/**
* Return a valid alpha value [0,1] with all invalid values being set to 1
* @hidden
*/
export declare function boundAlpha(a?: number | string): number;
/**
* Replace a decimal with it's percentage value
* @hidden
*/
export declare function convertToPercentage(n: number | string): number | string;
/**
* Force a hex value to have 2 characters
* @hidden
*/
export declare function pad2(c: string): string;

92
node_modules/@ctrl/tinycolor/dist/util.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pad2 = exports.convertToPercentage = exports.boundAlpha = exports.isPercentage = exports.isOnePointZero = exports.clamp01 = exports.bound01 = void 0;
/**
* Take input from [0, n] and return it as [0, 1]
* @hidden
*/
function bound01(n, max) {
if (isOnePointZero(n)) {
n = '100%';
}
var isPercent = isPercentage(n);
n = max === 360 ? n : Math.min(max, Math.max(0, parseFloat(n)));
// Automatically convert percentage into number
if (isPercent) {
n = parseInt(String(n * max), 10) / 100;
}
// Handle floating point rounding errors
if (Math.abs(n - max) < 0.000001) {
return 1;
}
// Convert into [0, 1] range if it isn't already
if (max === 360) {
// If n is a hue given in degrees,
// wrap around out-of-range values into [0, 360] range
// then convert into [0, 1].
n = (n < 0 ? (n % max) + max : n % max) / parseFloat(String(max));
}
else {
// If n not a hue given in degrees
// Convert into [0, 1] range if it isn't already.
n = (n % max) / parseFloat(String(max));
}
return n;
}
exports.bound01 = bound01;
/**
* Force a number between 0 and 1
* @hidden
*/
function clamp01(val) {
return Math.min(1, Math.max(0, val));
}
exports.clamp01 = clamp01;
/**
* Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
* <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
* @hidden
*/
function isOnePointZero(n) {
return typeof n === 'string' && n.indexOf('.') !== -1 && parseFloat(n) === 1;
}
exports.isOnePointZero = isOnePointZero;
/**
* Check to see if string passed in is a percentage
* @hidden
*/
function isPercentage(n) {
return typeof n === 'string' && n.indexOf('%') !== -1;
}
exports.isPercentage = isPercentage;
/**
* Return a valid alpha value [0,1] with all invalid values being set to 1
* @hidden
*/
function boundAlpha(a) {
a = parseFloat(a);
if (isNaN(a) || a < 0 || a > 1) {
a = 1;
}
return a;
}
exports.boundAlpha = boundAlpha;
/**
* Replace a decimal with it's percentage value
* @hidden
*/
function convertToPercentage(n) {
if (n <= 1) {
return "".concat(Number(n) * 100, "%");
}
return n;
}
exports.convertToPercentage = convertToPercentage;
/**
* Force a hex value to have 2 characters
* @hidden
*/
function pad2(c) {
return c.length === 1 ? '0' + c : String(c);
}
exports.pad2 = pad2;

80
node_modules/@ctrl/tinycolor/package.json generated vendored Normal file
View File

@@ -0,0 +1,80 @@
{
"name": "@ctrl/tinycolor",
"version": "3.6.1",
"description": "Fast, small color manipulation and conversion for JavaScript",
"author": "Scott Cooper <scttcper@gmail.com>",
"publishConfig": {
"access": "public"
},
"license": "MIT",
"homepage": "https://tinycolor.vercel.app",
"repository": "scttcper/tinycolor",
"keywords": [
"typescript",
"color",
"manipulation",
"tinycolor",
"hsa",
"rgb"
],
"main": "dist/public_api.js",
"module": "dist/module/public_api.js",
"typings": "dist/public_api.d.ts",
"files": [
"dist"
],
"sideEffects": false,
"scripts": {
"build:demo": "rollup -c rollup.demo.js",
"watch:demo": "rollup -c rollup.demo.js -w",
"lint": "eslint --ext .js,.ts, .",
"lint:fix": "eslint --fix --ext .js,.ts, .",
"prepare": "npm run build",
"build": "del-cli dist && tsc -p tsconfig.build.json && tsc -p tsconfig.module.json && ts-node build",
"build:docs": "typedoc --out demo/public/docs --hideGenerator --tsconfig tsconfig.build.json src/public_api.ts",
"test": "jest",
"test:ci": "jest --ci --runInBand --reporters=default --reporters=jest-junit --coverage",
"test:watch": "jest --watch"
},
"dependencies": {},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "7.19.6",
"@babel/preset-typescript": "7.18.6",
"@ctrl/eslint-config": "3.5.6",
"@jest/globals": "29.3.1",
"@types/node": "18.11.11",
"del-cli": "5.0.0",
"jest": "29.3.1",
"jest-junit": "15.0.0",
"rollup": "2.70.1",
"rollup-plugin-livereload": "2.0.5",
"rollup-plugin-serve": "1.1.0",
"rollup-plugin-sourcemaps": "0.6.3",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.34.1",
"ts-node": "10.9.1",
"typedoc": "0.23.21",
"typescript": "4.9.3"
},
"jest": {
"testEnvironment": "node",
"coverageProvider": "v8",
"moduleNameMapper": {
"(.+)\\.js": "$1"
}
},
"babel": {
"presets": [
"@babel/preset-typescript"
],
"plugins": [
"@babel/plugin-transform-modules-commonjs"
]
},
"release": {
"branch": "master"
},
"engines": {
"node": ">=10"
}
}