83
frontend/node_modules/hex-rgb/index.d.ts
generated
vendored
Normal file
83
frontend/node_modules/hex-rgb/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
/* eslint-disable no-redeclare */
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
The RGB output format.
|
||||
|
||||
Note that when using the `css` format, the value of the alpha channel is rounded to two decimal places.
|
||||
|
||||
@default 'object'
|
||||
*/
|
||||
readonly format?: 'object' | 'array' | 'css';
|
||||
|
||||
/**
|
||||
Set the alpha of the color.
|
||||
|
||||
This overrides any existing alpha component in the Hex color string. For example, the `99` in `#22222299`.
|
||||
|
||||
The number must be in the range 0 to 1.
|
||||
*/
|
||||
readonly alpha?: number;
|
||||
}
|
||||
|
||||
export interface RgbaObject {
|
||||
red: number;
|
||||
green: number;
|
||||
blue: number;
|
||||
alpha: number;
|
||||
}
|
||||
|
||||
export type RgbaTuple = [
|
||||
red: number,
|
||||
green: number,
|
||||
blue: number,
|
||||
alpha: number
|
||||
];
|
||||
|
||||
/**
|
||||
Convert HEX color to RGBA.
|
||||
|
||||
@param hex - The color in HEX format. Leading `#` is optional.
|
||||
|
||||
@example
|
||||
```
|
||||
import hexRgb from 'hex-rgb';
|
||||
|
||||
hexRgb('4183c4');
|
||||
//=> {red: 65, green: 131, blue: 196, alpha: 1}
|
||||
|
||||
hexRgb('#4183c4');
|
||||
//=> {red: 65, green: 131, blue: 196, alpha: 1}
|
||||
|
||||
hexRgb('#fff');
|
||||
//=> {red: 255, green: 255, blue: 255, alpha: 1}
|
||||
|
||||
hexRgb('#22222299');
|
||||
//=> {red: 34, green: 34, blue: 34, alpha: 0.6}
|
||||
|
||||
hexRgb('#0006');
|
||||
//=> {red: 0, green: 0, blue: 0, alpha: 0.4}
|
||||
|
||||
hexRgb('#cd2222cc');
|
||||
//=> {red: 205, green: 34, blue: 34, alpha: 0.8}
|
||||
|
||||
hexRgb('#cd2222cc', {format: 'array'});
|
||||
//=> [205, 34, 34, 0.8]
|
||||
|
||||
hexRgb('#cd2222cc', {format: 'css'});
|
||||
//=> 'rgb(205 34 34 / 80%)'
|
||||
|
||||
hexRgb('#000', {format: 'css'});
|
||||
//=> 'rgb(0 0 0)'
|
||||
|
||||
hexRgb('#22222299', {alpha: 1});
|
||||
//=> {red: 34, green: 34, blue: 34, alpha: 1}
|
||||
|
||||
hexRgb('#fff', {alpha: 0.5});
|
||||
//=> {red: 255, green: 255, blue: 255, alpha: 0.5}
|
||||
```
|
||||
*/
|
||||
export default function hexRgb(hex: string): RgbaObject;
|
||||
export default function hexRgb(hex: string, options: Options & {format: 'object'}): RgbaObject; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
export default function hexRgb(hex: string, options: Options & {format: 'array'}): RgbaTuple;
|
||||
export default function hexRgb(hex: string, options: Options & {format: 'css'}): string;
|
||||
45
frontend/node_modules/hex-rgb/index.js
generated
vendored
Normal file
45
frontend/node_modules/hex-rgb/index.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
const hexCharacters = 'a-f\\d';
|
||||
const match3or4Hex = `#?[${hexCharacters}]{3}[${hexCharacters}]?`;
|
||||
const match6or8Hex = `#?[${hexCharacters}]{6}([${hexCharacters}]{2})?`;
|
||||
const nonHexChars = new RegExp(`[^#${hexCharacters}]`, 'gi');
|
||||
const validHexSize = new RegExp(`^${match3or4Hex}$|^${match6or8Hex}$`, 'i');
|
||||
|
||||
export default function hexRgb(hex, options = {}) {
|
||||
if (typeof hex !== 'string' || nonHexChars.test(hex) || !validHexSize.test(hex)) {
|
||||
throw new TypeError('Expected a valid hex string');
|
||||
}
|
||||
|
||||
hex = hex.replace(/^#/, '');
|
||||
let alphaFromHex = 1;
|
||||
|
||||
if (hex.length === 8) {
|
||||
alphaFromHex = Number.parseInt(hex.slice(6, 8), 16) / 255;
|
||||
hex = hex.slice(0, 6);
|
||||
}
|
||||
|
||||
if (hex.length === 4) {
|
||||
alphaFromHex = Number.parseInt(hex.slice(3, 4).repeat(2), 16) / 255;
|
||||
hex = hex.slice(0, 3);
|
||||
}
|
||||
|
||||
if (hex.length === 3) {
|
||||
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
||||
}
|
||||
|
||||
const number = Number.parseInt(hex, 16);
|
||||
const red = number >> 16;
|
||||
const green = (number >> 8) & 255;
|
||||
const blue = number & 255;
|
||||
const alpha = typeof options.alpha === 'number' ? options.alpha : alphaFromHex;
|
||||
|
||||
if (options.format === 'array') {
|
||||
return [red, green, blue, alpha];
|
||||
}
|
||||
|
||||
if (options.format === 'css') {
|
||||
const alphaString = alpha === 1 ? '' : ` / ${Number((alpha * 100).toFixed(2))}%`;
|
||||
return `rgb(${red} ${green} ${blue}${alphaString})`;
|
||||
}
|
||||
|
||||
return {red, green, blue, alpha};
|
||||
}
|
||||
9
frontend/node_modules/hex-rgb/license
generated
vendored
Normal file
9
frontend/node_modules/hex-rgb/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
|
||||
41
frontend/node_modules/hex-rgb/package.json
generated
vendored
Normal file
41
frontend/node_modules/hex-rgb/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "hex-rgb",
|
||||
"version": "5.0.0",
|
||||
"description": "Convert HEX color to RGBA",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/hex-rgb",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"hex",
|
||||
"rgb",
|
||||
"rgba",
|
||||
"color",
|
||||
"colour",
|
||||
"convert",
|
||||
"conversion",
|
||||
"converter",
|
||||
"css"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^3.15.0",
|
||||
"tsd": "^0.14.0",
|
||||
"xo": "^0.39.1"
|
||||
}
|
||||
}
|
||||
86
frontend/node_modules/hex-rgb/readme.md
generated
vendored
Normal file
86
frontend/node_modules/hex-rgb/readme.md
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
# hex-rgb
|
||||
|
||||
> Convert HEX color to RGBA
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install hex-rgb
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import hexRgb from 'hex-rgb';
|
||||
|
||||
hexRgb('4183c4');
|
||||
//=> {red: 65, green: 131, blue: 196, alpha: 1}
|
||||
|
||||
hexRgb('#4183c4');
|
||||
//=> {red: 65, green: 131, blue: 196, alpha: 1}
|
||||
|
||||
hexRgb('#fff');
|
||||
//=> {red: 255, green: 255, blue: 255, alpha: 1}
|
||||
|
||||
hexRgb('#22222299');
|
||||
//=> {red: 34, green: 34, blue: 34, alpha: 0.6}
|
||||
|
||||
hexRgb('#0006');
|
||||
//=> {red: 0, green: 0, blue: 0, alpha: 0.4}
|
||||
|
||||
hexRgb('#cd2222cc');
|
||||
//=> {red: 205, green: 34, blue: 34, alpha: 0.8}
|
||||
|
||||
hexRgb('#cd2222cc', {format: 'array'});
|
||||
//=> [205, 34, 34, 0.8]
|
||||
|
||||
hexRgb('#cd2222cc', {format: 'css'});
|
||||
//=> 'rgb(205 34 34 / 80%)'
|
||||
|
||||
hexRgb('#000', {format: 'css'});
|
||||
//=> 'rgb(0 0 0)'
|
||||
|
||||
hexRgb('#22222299', {alpha: 1});
|
||||
//=> {red: 34, green: 34, blue: 34, alpha: 1}
|
||||
|
||||
hexRgb('#fff', {alpha: 0.5});
|
||||
//=> {red: 255, green: 255, blue: 255, alpha: 0.5}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### hexRgb(hex, options?)
|
||||
|
||||
#### hex
|
||||
|
||||
Type: `string`
|
||||
|
||||
The color in HEX format. Leading `#` is optional.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### format
|
||||
|
||||
Type: `string`\
|
||||
Values: `'object' | 'array' | 'css'`\
|
||||
Defaults: `'object'`
|
||||
|
||||
The RGB output format.
|
||||
|
||||
Note that when using the `css` format, the value of the alpha channel is rounded to two decimal places.
|
||||
|
||||
##### alpha
|
||||
|
||||
Type: `number`
|
||||
|
||||
Set the alpha of the color.
|
||||
|
||||
This overrides any existing alpha component in the Hex color string. For example, the `99` in `#22222299`.
|
||||
|
||||
The number must be in the range 0 to 1.
|
||||
|
||||
## Related
|
||||
|
||||
See [rgb-hex](https://github.com/sindresorhus/rgb-hex) for the inverse.
|
||||
Reference in New Issue
Block a user