@brainfish-ai/components 0.16.8 → 0.16.10-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alert.d.ts +1 -1
- package/dist/badge.d.ts +1 -1
- package/dist/card.d.ts +6 -8
- package/dist/chart-area-linear.d.ts +41 -0
- package/dist/chart-radial-stacked.d.ts +31 -0
- package/dist/colors.d.ts +0 -5
- package/dist/components/ui/alert.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/card.d.ts +8 -9
- package/dist/components/ui/item.d.ts +23 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/convos.d.ts +107 -0
- package/dist/esm/ChatSearch.css +1 -1
- package/dist/esm/chunks/{ChatSearch.D8_9CRIM.js → ChatSearch.BV8FTS2Y.js} +51 -10
- package/dist/esm/chunks/ChatSearch.BV8FTS2Y.js.map +1 -0
- package/dist/esm/chunks/{FormattedMessage.DdZqirSo.js → FormattedMessage.BcAkzCZt.js} +4 -13
- package/dist/esm/chunks/FormattedMessage.BcAkzCZt.js.map +1 -0
- package/dist/esm/chunks/chart.DGCX9VIn.js +219 -0
- package/dist/esm/chunks/chart.DGCX9VIn.js.map +1 -0
- package/dist/esm/chunks/{combobox.BRm6ZDEB.js → combobox.CkN-wAHB.js} +2 -2
- package/dist/esm/chunks/{combobox.BRm6ZDEB.js.map → combobox.CkN-wAHB.js.map} +1 -1
- package/dist/esm/chunks/{data-table.qS51pU0z.js → data-table.CVyV_UqZ.js} +2 -2
- package/dist/esm/chunks/{data-table.qS51pU0z.js.map → data-table.CVyV_UqZ.js.map} +1 -1
- package/dist/esm/chunks/{date-picker.DqcdwXZS.js → date-picker.sQXSlqNZ.js} +2 -2
- package/dist/esm/chunks/{date-picker.DqcdwXZS.js.map → date-picker.sQXSlqNZ.js.map} +1 -1
- package/dist/esm/chunks/extends.mO86zOh3.js +12 -0
- package/dist/esm/chunks/extends.mO86zOh3.js.map +1 -0
- package/dist/esm/chunks/{file-upload-status.vhPIBONC.js → file-upload-status.Vw0Zxmir.js} +3 -3
- package/dist/esm/chunks/file-upload-status.Vw0Zxmir.js.map +1 -0
- package/dist/esm/chunks/{filters.Bd9OruMH.js → filters.BMbm1LUz.js} +2 -2
- package/dist/esm/chunks/{filters.Bd9OruMH.js.map → filters.BMbm1LUz.js.map} +1 -1
- package/dist/esm/chunks/formatNumber.Bm2k8QrT.js +10 -0
- package/dist/esm/chunks/formatNumber.Bm2k8QrT.js.map +1 -0
- package/dist/esm/chunks/generating-star.COkD0gHd.js +1489 -0
- package/dist/esm/chunks/generating-star.COkD0gHd.js.map +1 -0
- package/dist/esm/chunks/{simpleSelect.BfAgKOea.js → simpleSelect.B1rktKkt.js} +2 -2
- package/dist/esm/chunks/{simpleSelect.BfAgKOea.js.map → simpleSelect.B1rktKkt.js.map} +1 -1
- package/dist/esm/chunks/{two-level-combobox.DFonmrmc.js → two-level-combobox.DsWPDcI6.js} +2 -2
- package/dist/esm/chunks/{two-level-combobox.DFonmrmc.js.map → two-level-combobox.DsWPDcI6.js.map} +1 -1
- package/dist/esm/chunks/{utils.DaMF_LVC.js → utils.Cwtlq8dh.js} +2 -10
- package/dist/esm/chunks/{utils.DaMF_LVC.js.map → utils.Cwtlq8dh.js.map} +1 -1
- package/dist/esm/colors.js +138 -145
- package/dist/esm/colors.js.map +1 -1
- package/dist/esm/components/chart-area-linear.js +87 -0
- package/dist/esm/components/chart-area-linear.js.map +1 -0
- package/dist/esm/components/chart-radial-stacked.js +59 -0
- package/dist/esm/components/chart-radial-stacked.js.map +1 -0
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/components/combobox.js +1 -1
- package/dist/esm/components/convos.js +158 -0
- package/dist/esm/components/convos.js.map +1 -0
- package/dist/esm/components/data-table.js +1 -1
- package/dist/esm/components/date-picker.js +1 -1
- package/dist/esm/components/file-upload.js +1 -1
- package/dist/esm/components/filter.js +1 -1
- package/dist/esm/components/generating-star.js +1 -1
- package/dist/esm/components/markdown.js +1 -1
- package/dist/esm/components/metric-card.js +61 -0
- package/dist/esm/components/metric-card.js.map +1 -0
- package/dist/esm/components/select.js +1 -1
- package/dist/esm/components/two-level-combobox.js +1 -1
- package/dist/esm/components/ui/accordion.js +3 -3
- package/dist/esm/components/ui/accordion.js.map +1 -1
- package/dist/esm/components/ui/alert-dialog.js +1 -1
- package/dist/esm/components/ui/alert.js +1 -1
- package/dist/esm/components/ui/badge.js +6 -6
- package/dist/esm/components/ui/badge.js.map +1 -1
- package/dist/esm/components/ui/button.js +1 -1
- package/dist/esm/components/ui/calendar.js +1 -1
- package/dist/esm/components/ui/card.js +52 -47
- package/dist/esm/components/ui/card.js.map +1 -1
- package/dist/esm/components/ui/command.js +1 -1
- package/dist/esm/components/ui/dialog.js +1 -1
- package/dist/esm/components/ui/div-button.js +1 -1
- package/dist/esm/components/ui/dropdown-menu.js +1 -1
- package/dist/esm/components/ui/input.js +1 -1
- package/dist/esm/components/ui/item.js +179 -0
- package/dist/esm/components/ui/item.js.map +1 -0
- package/dist/esm/components/ui/label.js +1 -1
- package/dist/esm/components/ui/popover.js +1 -1
- package/dist/esm/components/ui/progress.js +1 -1
- package/dist/esm/components/ui/scroll-area.js +1 -1
- package/dist/esm/components/ui/select.js +1 -1
- package/dist/esm/components/ui/separator.js +24 -0
- package/dist/esm/components/ui/separator.js.map +1 -0
- package/dist/esm/components/ui/switch.js +1 -1
- package/dist/esm/components/ui/table.js +1 -1
- package/dist/esm/components/ui/textarea.js +1 -1
- package/dist/esm/components/ui/tooltip.js +1 -1
- package/dist/esm/convos.css +1 -0
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.js +11 -11
- package/dist/generating-star.d.ts +9 -4
- package/dist/index.d.ts +7 -14
- package/dist/item.d.ts +39 -0
- package/dist/metric-card.d.ts +21 -0
- package/dist/separator.d.ts +6 -0
- package/dist/stats.html +1 -1
- package/package.json +4 -1
- package/tailwind.config.js +130 -117
- package/dist/esm/chunks/ChatSearch.D8_9CRIM.js.map +0 -1
- package/dist/esm/chunks/FormattedMessage.DdZqirSo.js.map +0 -1
- package/dist/esm/chunks/file-upload-status.vhPIBONC.js.map +0 -1
- package/dist/esm/chunks/generating-star.DFwZcGvH.js +0 -106
- package/dist/esm/chunks/generating-star.DFwZcGvH.js.map +0 -1
|
@@ -0,0 +1,1489 @@
|
|
|
1
|
+
import React__default, { useState, useEffect } from 'react';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { c as cn } from './utils.Cwtlq8dh.js';
|
|
4
|
+
import { _ as _extends } from './extends.mO86zOh3.js';
|
|
5
|
+
|
|
6
|
+
function _assertThisInitialized(e) {
|
|
7
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
8
|
+
return e;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function _getPrototypeOf(t) {
|
|
12
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
13
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
14
|
+
}, _getPrototypeOf(t);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function _setPrototypeOf(t, e) {
|
|
18
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
19
|
+
return t.__proto__ = e, t;
|
|
20
|
+
}, _setPrototypeOf(t, e);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const useDarkMode = () => {
|
|
24
|
+
const [isDarkMode, setIsDarkMode] = useState(() => document.documentElement.classList.contains("dark"));
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const observer = new MutationObserver(() => {
|
|
27
|
+
setIsDarkMode(document.documentElement.classList.contains("dark"));
|
|
28
|
+
});
|
|
29
|
+
observer.observe(document.documentElement, {
|
|
30
|
+
attributes: true,
|
|
31
|
+
attributeFilter: ["class"]
|
|
32
|
+
});
|
|
33
|
+
return () => observer.disconnect();
|
|
34
|
+
}, []);
|
|
35
|
+
return isDarkMode;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function _inheritsLoose(t, o) {
|
|
39
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _isNativeFunction(t) {
|
|
43
|
+
try {
|
|
44
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
45
|
+
} catch (n) {
|
|
46
|
+
return "function" == typeof t;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _isNativeReflectConstruct() {
|
|
51
|
+
try {
|
|
52
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
53
|
+
} catch (t) {}
|
|
54
|
+
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
55
|
+
return !!t;
|
|
56
|
+
})();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function _construct(t, e, r) {
|
|
60
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
61
|
+
var o = [null];
|
|
62
|
+
o.push.apply(o, e);
|
|
63
|
+
var p = new (t.bind.apply(t, o))();
|
|
64
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _wrapNativeSuper(t) {
|
|
68
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
69
|
+
return _wrapNativeSuper = function _wrapNativeSuper(t) {
|
|
70
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
71
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
72
|
+
if (void 0 !== r) {
|
|
73
|
+
if (r.has(t)) return r.get(t);
|
|
74
|
+
r.set(t, Wrapper);
|
|
75
|
+
}
|
|
76
|
+
function Wrapper() {
|
|
77
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
78
|
+
}
|
|
79
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
80
|
+
constructor: {
|
|
81
|
+
value: Wrapper,
|
|
82
|
+
enumerable: false,
|
|
83
|
+
writable: true,
|
|
84
|
+
configurable: true
|
|
85
|
+
}
|
|
86
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
87
|
+
}, _wrapNativeSuper(t);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// based on https://github.com/styled-components/styled-components/blob/fcf6f3804c57a14dd7984dfab7bc06ee2edca044/src/utils/error.js
|
|
91
|
+
/**
|
|
92
|
+
* Parse errors.md and turn it into a simple hash of code: message
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
var ERRORS = {
|
|
96
|
+
"1": "Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).\n\n",
|
|
97
|
+
"2": "Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).\n\n",
|
|
98
|
+
"3": "Passed an incorrect argument to a color function, please pass a string representation of a color.\n\n",
|
|
99
|
+
"4": "Couldn't generate valid rgb string from %s, it returned %s.\n\n",
|
|
100
|
+
"5": "Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.\n\n",
|
|
101
|
+
"6": "Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).\n\n",
|
|
102
|
+
"7": "Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).\n\n",
|
|
103
|
+
"8": "Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.\n\n",
|
|
104
|
+
"9": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
105
|
+
"10": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
106
|
+
"11": "Invalid value passed as base to modularScale, expected number or em string but got \"%s\"\n\n",
|
|
107
|
+
"12": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got \"%s\" instead.\n\n",
|
|
108
|
+
"13": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got \"%s\" instead.\n\n",
|
|
109
|
+
"14": "Passed invalid pixel value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
110
|
+
"15": "Passed invalid base value (\"%s\") to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
111
|
+
"16": "You must provide a template to this method.\n\n",
|
|
112
|
+
"17": "You passed an unsupported selector state to this method.\n\n",
|
|
113
|
+
"18": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
114
|
+
"19": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
115
|
+
"20": "expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
116
|
+
"21": "expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
117
|
+
"22": "expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",
|
|
118
|
+
"23": "fontFace expects a name of a font-family.\n\n",
|
|
119
|
+
"24": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
120
|
+
"25": "fontFace expects localFonts to be an array.\n\n",
|
|
121
|
+
"26": "fontFace expects fileFormats to be an array.\n\n",
|
|
122
|
+
"27": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
123
|
+
"28": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
124
|
+
"29": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
125
|
+
"30": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
126
|
+
"31": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation\n\n",
|
|
127
|
+
"32": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')\n\n",
|
|
128
|
+
"33": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation\n\n",
|
|
129
|
+
"34": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
130
|
+
"35": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
|
131
|
+
"36": "Property must be a string value.\n\n",
|
|
132
|
+
"37": "Syntax Error at %s.\n\n",
|
|
133
|
+
"38": "Formula contains a function that needs parentheses at %s.\n\n",
|
|
134
|
+
"39": "Formula is missing closing parenthesis at %s.\n\n",
|
|
135
|
+
"40": "Formula has too many closing parentheses at %s.\n\n",
|
|
136
|
+
"41": "All values in a formula must have the same unit or be unitless.\n\n",
|
|
137
|
+
"42": "Please provide a number of steps to the modularScale helper.\n\n",
|
|
138
|
+
"43": "Please pass a number or one of the predefined scales to the modularScale helper as the ratio.\n\n",
|
|
139
|
+
"44": "Invalid value passed as base to modularScale, expected number or em/rem string but got %s.\n\n",
|
|
140
|
+
"45": "Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.\n\n",
|
|
141
|
+
"46": "Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.\n\n",
|
|
142
|
+
"47": "minScreen and maxScreen must be provided as stringified numbers with the same units.\n\n",
|
|
143
|
+
"48": "fromSize and toSize must be provided as stringified numbers with the same units.\n\n",
|
|
144
|
+
"49": "Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.\n\n",
|
|
145
|
+
"50": "Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.\n\n",
|
|
146
|
+
"51": "Expects the first argument object to have the properties prop, fromSize, and toSize.\n\n",
|
|
147
|
+
"52": "fontFace expects either the path to the font file(s) or a name of a local copy.\n\n",
|
|
148
|
+
"53": "fontFace expects localFonts to be an array.\n\n",
|
|
149
|
+
"54": "fontFace expects fileFormats to be an array.\n\n",
|
|
150
|
+
"55": "fontFace expects a name of a font-family.\n\n",
|
|
151
|
+
"56": "linearGradient requries at least 2 color-stops to properly render.\n\n",
|
|
152
|
+
"57": "radialGradient requries at least 2 color-stops to properly render.\n\n",
|
|
153
|
+
"58": "Please supply a filename to retinaImage() as the first argument.\n\n",
|
|
154
|
+
"59": "Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.\n\n",
|
|
155
|
+
"60": "Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",
|
|
156
|
+
"61": "Property must be a string value.\n\n",
|
|
157
|
+
"62": "borderRadius expects a radius value as a string or number as the second argument.\n\n",
|
|
158
|
+
"63": "borderRadius expects one of \"top\", \"bottom\", \"left\" or \"right\" as the first argument.\n\n",
|
|
159
|
+
"64": "The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
160
|
+
"65": "To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').\n\n",
|
|
161
|
+
"66": "The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.\n\n",
|
|
162
|
+
"67": "You must provide a template to this method.\n\n",
|
|
163
|
+
"68": "You passed an unsupported selector state to this method.\n\n",
|
|
164
|
+
"69": "Expected a string ending in \"px\" or a number passed as the first argument to %s(), got %s instead.\n\n",
|
|
165
|
+
"70": "Expected a string ending in \"px\" or a number passed as the second argument to %s(), got %s instead.\n\n",
|
|
166
|
+
"71": "Passed invalid pixel value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
167
|
+
"72": "Passed invalid base value %s to %s(), please pass a value like \"12px\" or 12.\n\n",
|
|
168
|
+
"73": "Please provide a valid CSS variable.\n\n",
|
|
169
|
+
"74": "CSS variable not found and no default was provided.\n\n",
|
|
170
|
+
"75": "important requires a valid style object, got a %s instead.\n\n",
|
|
171
|
+
"76": "fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.\n\n",
|
|
172
|
+
"77": "remToPx expects a value in \"rem\" but you provided it in \"%s\".\n\n",
|
|
173
|
+
"78": "base must be set in \"px\" or \"%\" but you set it in \"%s\".\n"
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* super basic version of sprintf
|
|
178
|
+
* @private
|
|
179
|
+
*/
|
|
180
|
+
function format() {
|
|
181
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
182
|
+
args[_key] = arguments[_key];
|
|
183
|
+
}
|
|
184
|
+
var a = args[0];
|
|
185
|
+
var b = [];
|
|
186
|
+
var c;
|
|
187
|
+
for (c = 1; c < args.length; c += 1) {
|
|
188
|
+
b.push(args[c]);
|
|
189
|
+
}
|
|
190
|
+
b.forEach(function (d) {
|
|
191
|
+
a = a.replace(/%[a-z]/, d);
|
|
192
|
+
});
|
|
193
|
+
return a;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Create an error file out of errors.md for development and a simple web link to the full errors
|
|
198
|
+
* in production mode.
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
var PolishedError = /*#__PURE__*/function (_Error) {
|
|
202
|
+
_inheritsLoose(PolishedError, _Error);
|
|
203
|
+
function PolishedError(code) {
|
|
204
|
+
var _this;
|
|
205
|
+
if (process.env.NODE_ENV === 'production') {
|
|
206
|
+
_this = _Error.call(this, "An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#" + code + " for more information.") || this;
|
|
207
|
+
} else {
|
|
208
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
209
|
+
args[_key2 - 1] = arguments[_key2];
|
|
210
|
+
}
|
|
211
|
+
_this = _Error.call(this, format.apply(void 0, [ERRORS[code]].concat(args))) || this;
|
|
212
|
+
}
|
|
213
|
+
return _assertThisInitialized(_this);
|
|
214
|
+
}
|
|
215
|
+
return PolishedError;
|
|
216
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
217
|
+
|
|
218
|
+
var cssVariableRegex = /--[\S]*/g;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Fetches the value of a passed CSS Variable in the :root scope, or otherwise returns a defaultValue if provided.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* // Styles as object usage
|
|
225
|
+
* const styles = {
|
|
226
|
+
* 'background': cssVar('--background-color'),
|
|
227
|
+
* }
|
|
228
|
+
*
|
|
229
|
+
* // styled-components usage
|
|
230
|
+
* const div = styled.div`
|
|
231
|
+
* background: ${cssVar('--background-color')};
|
|
232
|
+
* `
|
|
233
|
+
*
|
|
234
|
+
* // CSS in JS Output
|
|
235
|
+
*
|
|
236
|
+
* element {
|
|
237
|
+
* 'background': 'red'
|
|
238
|
+
* }
|
|
239
|
+
*/
|
|
240
|
+
function cssVar(cssVariable, defaultValue) {
|
|
241
|
+
if (!cssVariable || !cssVariable.match(cssVariableRegex)) {
|
|
242
|
+
throw new PolishedError(73);
|
|
243
|
+
}
|
|
244
|
+
var variableValue;
|
|
245
|
+
|
|
246
|
+
/* eslint-disable */
|
|
247
|
+
/* istanbul ignore next */
|
|
248
|
+
if (typeof document !== 'undefined' && document.documentElement !== null) {
|
|
249
|
+
variableValue = getComputedStyle(document.documentElement).getPropertyValue(cssVariable);
|
|
250
|
+
}
|
|
251
|
+
/* eslint-enable */
|
|
252
|
+
|
|
253
|
+
if (variableValue) {
|
|
254
|
+
return variableValue.trim();
|
|
255
|
+
}
|
|
256
|
+
throw new PolishedError(74);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function colorToInt(color) {
|
|
260
|
+
return Math.round(color * 255);
|
|
261
|
+
}
|
|
262
|
+
function convertToInt(red, green, blue) {
|
|
263
|
+
return colorToInt(red) + "," + colorToInt(green) + "," + colorToInt(blue);
|
|
264
|
+
}
|
|
265
|
+
function hslToRgb(hue, saturation, lightness, convert) {
|
|
266
|
+
if (convert === void 0) {
|
|
267
|
+
convert = convertToInt;
|
|
268
|
+
}
|
|
269
|
+
if (saturation === 0) {
|
|
270
|
+
// achromatic
|
|
271
|
+
return convert(lightness, lightness, lightness);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// formulae from https://en.wikipedia.org/wiki/HSL_and_HSV
|
|
275
|
+
var huePrime = (hue % 360 + 360) % 360 / 60;
|
|
276
|
+
var chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
|
|
277
|
+
var secondComponent = chroma * (1 - Math.abs(huePrime % 2 - 1));
|
|
278
|
+
var red = 0;
|
|
279
|
+
var green = 0;
|
|
280
|
+
var blue = 0;
|
|
281
|
+
if (huePrime >= 0 && huePrime < 1) {
|
|
282
|
+
red = chroma;
|
|
283
|
+
green = secondComponent;
|
|
284
|
+
} else if (huePrime >= 1 && huePrime < 2) {
|
|
285
|
+
red = secondComponent;
|
|
286
|
+
green = chroma;
|
|
287
|
+
} else if (huePrime >= 2 && huePrime < 3) {
|
|
288
|
+
green = chroma;
|
|
289
|
+
blue = secondComponent;
|
|
290
|
+
} else if (huePrime >= 3 && huePrime < 4) {
|
|
291
|
+
green = secondComponent;
|
|
292
|
+
blue = chroma;
|
|
293
|
+
} else if (huePrime >= 4 && huePrime < 5) {
|
|
294
|
+
red = secondComponent;
|
|
295
|
+
blue = chroma;
|
|
296
|
+
} else if (huePrime >= 5 && huePrime < 6) {
|
|
297
|
+
red = chroma;
|
|
298
|
+
blue = secondComponent;
|
|
299
|
+
}
|
|
300
|
+
var lightnessModification = lightness - chroma / 2;
|
|
301
|
+
var finalRed = red + lightnessModification;
|
|
302
|
+
var finalGreen = green + lightnessModification;
|
|
303
|
+
var finalBlue = blue + lightnessModification;
|
|
304
|
+
return convert(finalRed, finalGreen, finalBlue);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
var namedColorMap = {
|
|
308
|
+
aliceblue: 'f0f8ff',
|
|
309
|
+
antiquewhite: 'faebd7',
|
|
310
|
+
aqua: '00ffff',
|
|
311
|
+
aquamarine: '7fffd4',
|
|
312
|
+
azure: 'f0ffff',
|
|
313
|
+
beige: 'f5f5dc',
|
|
314
|
+
bisque: 'ffe4c4',
|
|
315
|
+
black: '000',
|
|
316
|
+
blanchedalmond: 'ffebcd',
|
|
317
|
+
blue: '0000ff',
|
|
318
|
+
blueviolet: '8a2be2',
|
|
319
|
+
brown: 'a52a2a',
|
|
320
|
+
burlywood: 'deb887',
|
|
321
|
+
cadetblue: '5f9ea0',
|
|
322
|
+
chartreuse: '7fff00',
|
|
323
|
+
chocolate: 'd2691e',
|
|
324
|
+
coral: 'ff7f50',
|
|
325
|
+
cornflowerblue: '6495ed',
|
|
326
|
+
cornsilk: 'fff8dc',
|
|
327
|
+
crimson: 'dc143c',
|
|
328
|
+
cyan: '00ffff',
|
|
329
|
+
darkblue: '00008b',
|
|
330
|
+
darkcyan: '008b8b',
|
|
331
|
+
darkgoldenrod: 'b8860b',
|
|
332
|
+
darkgray: 'a9a9a9',
|
|
333
|
+
darkgreen: '006400',
|
|
334
|
+
darkgrey: 'a9a9a9',
|
|
335
|
+
darkkhaki: 'bdb76b',
|
|
336
|
+
darkmagenta: '8b008b',
|
|
337
|
+
darkolivegreen: '556b2f',
|
|
338
|
+
darkorange: 'ff8c00',
|
|
339
|
+
darkorchid: '9932cc',
|
|
340
|
+
darkred: '8b0000',
|
|
341
|
+
darksalmon: 'e9967a',
|
|
342
|
+
darkseagreen: '8fbc8f',
|
|
343
|
+
darkslateblue: '483d8b',
|
|
344
|
+
darkslategray: '2f4f4f',
|
|
345
|
+
darkslategrey: '2f4f4f',
|
|
346
|
+
darkturquoise: '00ced1',
|
|
347
|
+
darkviolet: '9400d3',
|
|
348
|
+
deeppink: 'ff1493',
|
|
349
|
+
deepskyblue: '00bfff',
|
|
350
|
+
dimgray: '696969',
|
|
351
|
+
dimgrey: '696969',
|
|
352
|
+
dodgerblue: '1e90ff',
|
|
353
|
+
firebrick: 'b22222',
|
|
354
|
+
floralwhite: 'fffaf0',
|
|
355
|
+
forestgreen: '228b22',
|
|
356
|
+
fuchsia: 'ff00ff',
|
|
357
|
+
gainsboro: 'dcdcdc',
|
|
358
|
+
ghostwhite: 'f8f8ff',
|
|
359
|
+
gold: 'ffd700',
|
|
360
|
+
goldenrod: 'daa520',
|
|
361
|
+
gray: '808080',
|
|
362
|
+
green: '008000',
|
|
363
|
+
greenyellow: 'adff2f',
|
|
364
|
+
grey: '808080',
|
|
365
|
+
honeydew: 'f0fff0',
|
|
366
|
+
hotpink: 'ff69b4',
|
|
367
|
+
indianred: 'cd5c5c',
|
|
368
|
+
indigo: '4b0082',
|
|
369
|
+
ivory: 'fffff0',
|
|
370
|
+
khaki: 'f0e68c',
|
|
371
|
+
lavender: 'e6e6fa',
|
|
372
|
+
lavenderblush: 'fff0f5',
|
|
373
|
+
lawngreen: '7cfc00',
|
|
374
|
+
lemonchiffon: 'fffacd',
|
|
375
|
+
lightblue: 'add8e6',
|
|
376
|
+
lightcoral: 'f08080',
|
|
377
|
+
lightcyan: 'e0ffff',
|
|
378
|
+
lightgoldenrodyellow: 'fafad2',
|
|
379
|
+
lightgray: 'd3d3d3',
|
|
380
|
+
lightgreen: '90ee90',
|
|
381
|
+
lightgrey: 'd3d3d3',
|
|
382
|
+
lightpink: 'ffb6c1',
|
|
383
|
+
lightsalmon: 'ffa07a',
|
|
384
|
+
lightseagreen: '20b2aa',
|
|
385
|
+
lightskyblue: '87cefa',
|
|
386
|
+
lightslategray: '789',
|
|
387
|
+
lightslategrey: '789',
|
|
388
|
+
lightsteelblue: 'b0c4de',
|
|
389
|
+
lightyellow: 'ffffe0',
|
|
390
|
+
lime: '0f0',
|
|
391
|
+
limegreen: '32cd32',
|
|
392
|
+
linen: 'faf0e6',
|
|
393
|
+
magenta: 'f0f',
|
|
394
|
+
maroon: '800000',
|
|
395
|
+
mediumaquamarine: '66cdaa',
|
|
396
|
+
mediumblue: '0000cd',
|
|
397
|
+
mediumorchid: 'ba55d3',
|
|
398
|
+
mediumpurple: '9370db',
|
|
399
|
+
mediumseagreen: '3cb371',
|
|
400
|
+
mediumslateblue: '7b68ee',
|
|
401
|
+
mediumspringgreen: '00fa9a',
|
|
402
|
+
mediumturquoise: '48d1cc',
|
|
403
|
+
mediumvioletred: 'c71585',
|
|
404
|
+
midnightblue: '191970',
|
|
405
|
+
mintcream: 'f5fffa',
|
|
406
|
+
mistyrose: 'ffe4e1',
|
|
407
|
+
moccasin: 'ffe4b5',
|
|
408
|
+
navajowhite: 'ffdead',
|
|
409
|
+
navy: '000080',
|
|
410
|
+
oldlace: 'fdf5e6',
|
|
411
|
+
olive: '808000',
|
|
412
|
+
olivedrab: '6b8e23',
|
|
413
|
+
orange: 'ffa500',
|
|
414
|
+
orangered: 'ff4500',
|
|
415
|
+
orchid: 'da70d6',
|
|
416
|
+
palegoldenrod: 'eee8aa',
|
|
417
|
+
palegreen: '98fb98',
|
|
418
|
+
paleturquoise: 'afeeee',
|
|
419
|
+
palevioletred: 'db7093',
|
|
420
|
+
papayawhip: 'ffefd5',
|
|
421
|
+
peachpuff: 'ffdab9',
|
|
422
|
+
peru: 'cd853f',
|
|
423
|
+
pink: 'ffc0cb',
|
|
424
|
+
plum: 'dda0dd',
|
|
425
|
+
powderblue: 'b0e0e6',
|
|
426
|
+
purple: '800080',
|
|
427
|
+
rebeccapurple: '639',
|
|
428
|
+
red: 'f00',
|
|
429
|
+
rosybrown: 'bc8f8f',
|
|
430
|
+
royalblue: '4169e1',
|
|
431
|
+
saddlebrown: '8b4513',
|
|
432
|
+
salmon: 'fa8072',
|
|
433
|
+
sandybrown: 'f4a460',
|
|
434
|
+
seagreen: '2e8b57',
|
|
435
|
+
seashell: 'fff5ee',
|
|
436
|
+
sienna: 'a0522d',
|
|
437
|
+
silver: 'c0c0c0',
|
|
438
|
+
skyblue: '87ceeb',
|
|
439
|
+
slateblue: '6a5acd',
|
|
440
|
+
slategray: '708090',
|
|
441
|
+
slategrey: '708090',
|
|
442
|
+
snow: 'fffafa',
|
|
443
|
+
springgreen: '00ff7f',
|
|
444
|
+
steelblue: '4682b4',
|
|
445
|
+
tan: 'd2b48c',
|
|
446
|
+
teal: '008080',
|
|
447
|
+
thistle: 'd8bfd8',
|
|
448
|
+
tomato: 'ff6347',
|
|
449
|
+
turquoise: '40e0d0',
|
|
450
|
+
violet: 'ee82ee',
|
|
451
|
+
wheat: 'f5deb3',
|
|
452
|
+
white: 'fff',
|
|
453
|
+
whitesmoke: 'f5f5f5',
|
|
454
|
+
yellow: 'ff0',
|
|
455
|
+
yellowgreen: '9acd32'
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Checks if a string is a CSS named color and returns its equivalent hex value, otherwise returns the original color.
|
|
460
|
+
* @private
|
|
461
|
+
*/
|
|
462
|
+
function nameToHex(color) {
|
|
463
|
+
if (typeof color !== 'string') return color;
|
|
464
|
+
var normalizedColorName = color.toLowerCase();
|
|
465
|
+
return namedColorMap[normalizedColorName] ? "#" + namedColorMap[normalizedColorName] : color;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
var hexRegex = /^#[a-fA-F0-9]{6}$/;
|
|
469
|
+
var hexRgbaRegex = /^#[a-fA-F0-9]{8}$/;
|
|
470
|
+
var reducedHexRegex = /^#[a-fA-F0-9]{3}$/;
|
|
471
|
+
var reducedRgbaHexRegex = /^#[a-fA-F0-9]{4}$/;
|
|
472
|
+
var rgbRegex = /^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i;
|
|
473
|
+
var rgbaRegex = /^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
474
|
+
var hslRegex = /^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i;
|
|
475
|
+
var hslaRegex = /^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Returns an RgbColor or RgbaColor object. This utility function is only useful
|
|
479
|
+
* if want to extract a color component. With the color util `toColorString` you
|
|
480
|
+
* can convert a RgbColor or RgbaColor object back to a string.
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* // Assigns `{ red: 255, green: 0, blue: 0 }` to color1
|
|
484
|
+
* const color1 = parseToRgb('rgb(255, 0, 0)');
|
|
485
|
+
* // Assigns `{ red: 92, green: 102, blue: 112, alpha: 0.75 }` to color2
|
|
486
|
+
* const color2 = parseToRgb('hsla(210, 10%, 40%, 0.75)');
|
|
487
|
+
*/
|
|
488
|
+
function parseToRgb(color) {
|
|
489
|
+
if (typeof color !== 'string') {
|
|
490
|
+
throw new PolishedError(3);
|
|
491
|
+
}
|
|
492
|
+
var normalizedColor = nameToHex(color);
|
|
493
|
+
if (normalizedColor.match(hexRegex)) {
|
|
494
|
+
return {
|
|
495
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
496
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
497
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16)
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
if (normalizedColor.match(hexRgbaRegex)) {
|
|
501
|
+
var alpha = parseFloat((parseInt("" + normalizedColor[7] + normalizedColor[8], 16) / 255).toFixed(2));
|
|
502
|
+
return {
|
|
503
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[2], 16),
|
|
504
|
+
green: parseInt("" + normalizedColor[3] + normalizedColor[4], 16),
|
|
505
|
+
blue: parseInt("" + normalizedColor[5] + normalizedColor[6], 16),
|
|
506
|
+
alpha: alpha
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
if (normalizedColor.match(reducedHexRegex)) {
|
|
510
|
+
return {
|
|
511
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
512
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
513
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16)
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
if (normalizedColor.match(reducedRgbaHexRegex)) {
|
|
517
|
+
var _alpha = parseFloat((parseInt("" + normalizedColor[4] + normalizedColor[4], 16) / 255).toFixed(2));
|
|
518
|
+
return {
|
|
519
|
+
red: parseInt("" + normalizedColor[1] + normalizedColor[1], 16),
|
|
520
|
+
green: parseInt("" + normalizedColor[2] + normalizedColor[2], 16),
|
|
521
|
+
blue: parseInt("" + normalizedColor[3] + normalizedColor[3], 16),
|
|
522
|
+
alpha: _alpha
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
var rgbMatched = rgbRegex.exec(normalizedColor);
|
|
526
|
+
if (rgbMatched) {
|
|
527
|
+
return {
|
|
528
|
+
red: parseInt("" + rgbMatched[1], 10),
|
|
529
|
+
green: parseInt("" + rgbMatched[2], 10),
|
|
530
|
+
blue: parseInt("" + rgbMatched[3], 10)
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
var rgbaMatched = rgbaRegex.exec(normalizedColor.substring(0, 50));
|
|
534
|
+
if (rgbaMatched) {
|
|
535
|
+
return {
|
|
536
|
+
red: parseInt("" + rgbaMatched[1], 10),
|
|
537
|
+
green: parseInt("" + rgbaMatched[2], 10),
|
|
538
|
+
blue: parseInt("" + rgbaMatched[3], 10),
|
|
539
|
+
alpha: parseFloat("" + rgbaMatched[4]) > 1 ? parseFloat("" + rgbaMatched[4]) / 100 : parseFloat("" + rgbaMatched[4])
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
var hslMatched = hslRegex.exec(normalizedColor);
|
|
543
|
+
if (hslMatched) {
|
|
544
|
+
var hue = parseInt("" + hslMatched[1], 10);
|
|
545
|
+
var saturation = parseInt("" + hslMatched[2], 10) / 100;
|
|
546
|
+
var lightness = parseInt("" + hslMatched[3], 10) / 100;
|
|
547
|
+
var rgbColorString = "rgb(" + hslToRgb(hue, saturation, lightness) + ")";
|
|
548
|
+
var hslRgbMatched = rgbRegex.exec(rgbColorString);
|
|
549
|
+
if (!hslRgbMatched) {
|
|
550
|
+
throw new PolishedError(4, normalizedColor, rgbColorString);
|
|
551
|
+
}
|
|
552
|
+
return {
|
|
553
|
+
red: parseInt("" + hslRgbMatched[1], 10),
|
|
554
|
+
green: parseInt("" + hslRgbMatched[2], 10),
|
|
555
|
+
blue: parseInt("" + hslRgbMatched[3], 10)
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
var hslaMatched = hslaRegex.exec(normalizedColor.substring(0, 50));
|
|
559
|
+
if (hslaMatched) {
|
|
560
|
+
var _hue = parseInt("" + hslaMatched[1], 10);
|
|
561
|
+
var _saturation = parseInt("" + hslaMatched[2], 10) / 100;
|
|
562
|
+
var _lightness = parseInt("" + hslaMatched[3], 10) / 100;
|
|
563
|
+
var _rgbColorString = "rgb(" + hslToRgb(_hue, _saturation, _lightness) + ")";
|
|
564
|
+
var _hslRgbMatched = rgbRegex.exec(_rgbColorString);
|
|
565
|
+
if (!_hslRgbMatched) {
|
|
566
|
+
throw new PolishedError(4, normalizedColor, _rgbColorString);
|
|
567
|
+
}
|
|
568
|
+
return {
|
|
569
|
+
red: parseInt("" + _hslRgbMatched[1], 10),
|
|
570
|
+
green: parseInt("" + _hslRgbMatched[2], 10),
|
|
571
|
+
blue: parseInt("" + _hslRgbMatched[3], 10),
|
|
572
|
+
alpha: parseFloat("" + hslaMatched[4]) > 1 ? parseFloat("" + hslaMatched[4]) / 100 : parseFloat("" + hslaMatched[4])
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
throw new PolishedError(5);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function rgbToHsl(color) {
|
|
579
|
+
// make sure rgb are contained in a set of [0, 255]
|
|
580
|
+
var red = color.red / 255;
|
|
581
|
+
var green = color.green / 255;
|
|
582
|
+
var blue = color.blue / 255;
|
|
583
|
+
var max = Math.max(red, green, blue);
|
|
584
|
+
var min = Math.min(red, green, blue);
|
|
585
|
+
var lightness = (max + min) / 2;
|
|
586
|
+
if (max === min) {
|
|
587
|
+
// achromatic
|
|
588
|
+
if (color.alpha !== undefined) {
|
|
589
|
+
return {
|
|
590
|
+
hue: 0,
|
|
591
|
+
saturation: 0,
|
|
592
|
+
lightness: lightness,
|
|
593
|
+
alpha: color.alpha
|
|
594
|
+
};
|
|
595
|
+
} else {
|
|
596
|
+
return {
|
|
597
|
+
hue: 0,
|
|
598
|
+
saturation: 0,
|
|
599
|
+
lightness: lightness
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
var hue;
|
|
604
|
+
var delta = max - min;
|
|
605
|
+
var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
606
|
+
switch (max) {
|
|
607
|
+
case red:
|
|
608
|
+
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
|
609
|
+
break;
|
|
610
|
+
case green:
|
|
611
|
+
hue = (blue - red) / delta + 2;
|
|
612
|
+
break;
|
|
613
|
+
default:
|
|
614
|
+
// blue case
|
|
615
|
+
hue = (red - green) / delta + 4;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
hue *= 60;
|
|
619
|
+
if (color.alpha !== undefined) {
|
|
620
|
+
return {
|
|
621
|
+
hue: hue,
|
|
622
|
+
saturation: saturation,
|
|
623
|
+
lightness: lightness,
|
|
624
|
+
alpha: color.alpha
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
hue: hue,
|
|
629
|
+
saturation: saturation,
|
|
630
|
+
lightness: lightness
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Returns an HslColor or HslaColor object. This utility function is only useful
|
|
636
|
+
* if want to extract a color component. With the color util `toColorString` you
|
|
637
|
+
* can convert a HslColor or HslaColor object back to a string.
|
|
638
|
+
*
|
|
639
|
+
* @example
|
|
640
|
+
* // Assigns `{ hue: 0, saturation: 1, lightness: 0.5 }` to color1
|
|
641
|
+
* const color1 = parseToHsl('rgb(255, 0, 0)');
|
|
642
|
+
* // Assigns `{ hue: 128, saturation: 1, lightness: 0.5, alpha: 0.75 }` to color2
|
|
643
|
+
* const color2 = parseToHsl('hsla(128, 100%, 50%, 0.75)');
|
|
644
|
+
*/
|
|
645
|
+
function parseToHsl(color) {
|
|
646
|
+
// Note: At a later stage we can optimize this function as right now a hsl
|
|
647
|
+
// color would be parsed converted to rgb values and converted back to hsl.
|
|
648
|
+
return rgbToHsl(parseToRgb(color));
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Reduces hex values if possible e.g. #ff8866 to #f86
|
|
653
|
+
* @private
|
|
654
|
+
*/
|
|
655
|
+
var reduceHexValue = function reduceHexValue(value) {
|
|
656
|
+
if (value.length === 7 && value[1] === value[2] && value[3] === value[4] && value[5] === value[6]) {
|
|
657
|
+
return "#" + value[1] + value[3] + value[5];
|
|
658
|
+
}
|
|
659
|
+
return value;
|
|
660
|
+
};
|
|
661
|
+
var reduceHexValue$1 = reduceHexValue;
|
|
662
|
+
|
|
663
|
+
function numberToHex(value) {
|
|
664
|
+
var hex = value.toString(16);
|
|
665
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function colorToHex(color) {
|
|
669
|
+
return numberToHex(Math.round(color * 255));
|
|
670
|
+
}
|
|
671
|
+
function convertToHex(red, green, blue) {
|
|
672
|
+
return reduceHexValue$1("#" + colorToHex(red) + colorToHex(green) + colorToHex(blue));
|
|
673
|
+
}
|
|
674
|
+
function hslToHex(hue, saturation, lightness) {
|
|
675
|
+
return hslToRgb(hue, saturation, lightness, convertToHex);
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* // Styles as object usage
|
|
683
|
+
* const styles = {
|
|
684
|
+
* background: hsl(359, 0.75, 0.4),
|
|
685
|
+
* background: hsl({ hue: 360, saturation: 0.75, lightness: 0.4 }),
|
|
686
|
+
* }
|
|
687
|
+
*
|
|
688
|
+
* // styled-components usage
|
|
689
|
+
* const div = styled.div`
|
|
690
|
+
* background: ${hsl(359, 0.75, 0.4)};
|
|
691
|
+
* background: ${hsl({ hue: 360, saturation: 0.75, lightness: 0.4 })};
|
|
692
|
+
* `
|
|
693
|
+
*
|
|
694
|
+
* // CSS in JS Output
|
|
695
|
+
*
|
|
696
|
+
* element {
|
|
697
|
+
* background: "#b3191c";
|
|
698
|
+
* background: "#b3191c";
|
|
699
|
+
* }
|
|
700
|
+
*/
|
|
701
|
+
function hsl(value, saturation, lightness) {
|
|
702
|
+
if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
|
|
703
|
+
return hslToHex(value.hue, value.saturation, value.lightness);
|
|
704
|
+
}
|
|
705
|
+
throw new PolishedError(1);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* // Styles as object usage
|
|
713
|
+
* const styles = {
|
|
714
|
+
* background: hsla(359, 0.75, 0.4, 0.7),
|
|
715
|
+
* background: hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 }),
|
|
716
|
+
* background: hsla(359, 0.75, 0.4, 1),
|
|
717
|
+
* }
|
|
718
|
+
*
|
|
719
|
+
* // styled-components usage
|
|
720
|
+
* const div = styled.div`
|
|
721
|
+
* background: ${hsla(359, 0.75, 0.4, 0.7)};
|
|
722
|
+
* background: ${hsla({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0,7 })};
|
|
723
|
+
* background: ${hsla(359, 0.75, 0.4, 1)};
|
|
724
|
+
* `
|
|
725
|
+
*
|
|
726
|
+
* // CSS in JS Output
|
|
727
|
+
*
|
|
728
|
+
* element {
|
|
729
|
+
* background: "rgba(179,25,28,0.7)";
|
|
730
|
+
* background: "rgba(179,25,28,0.7)";
|
|
731
|
+
* background: "#b3191c";
|
|
732
|
+
* }
|
|
733
|
+
*/
|
|
734
|
+
function hsla(value, saturation, lightness, alpha) {
|
|
735
|
+
if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
|
|
736
|
+
return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
|
|
737
|
+
}
|
|
738
|
+
throw new PolishedError(2);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Returns a string value for the color. The returned result is the smallest possible hex notation.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* // Styles as object usage
|
|
746
|
+
* const styles = {
|
|
747
|
+
* background: rgb(255, 205, 100),
|
|
748
|
+
* background: rgb({ red: 255, green: 205, blue: 100 }),
|
|
749
|
+
* }
|
|
750
|
+
*
|
|
751
|
+
* // styled-components usage
|
|
752
|
+
* const div = styled.div`
|
|
753
|
+
* background: ${rgb(255, 205, 100)};
|
|
754
|
+
* background: ${rgb({ red: 255, green: 205, blue: 100 })};
|
|
755
|
+
* `
|
|
756
|
+
*
|
|
757
|
+
* // CSS in JS Output
|
|
758
|
+
*
|
|
759
|
+
* element {
|
|
760
|
+
* background: "#ffcd64";
|
|
761
|
+
* background: "#ffcd64";
|
|
762
|
+
* }
|
|
763
|
+
*/
|
|
764
|
+
function rgb(value, green, blue) {
|
|
765
|
+
if (typeof value === 'number' && typeof green === 'number' && typeof blue === 'number') {
|
|
766
|
+
return reduceHexValue$1("#" + numberToHex(value) + numberToHex(green) + numberToHex(blue));
|
|
767
|
+
} else if (typeof value === 'object' && green === undefined && blue === undefined) {
|
|
768
|
+
return reduceHexValue$1("#" + numberToHex(value.red) + numberToHex(value.green) + numberToHex(value.blue));
|
|
769
|
+
}
|
|
770
|
+
throw new PolishedError(6);
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Returns a string value for the color. The returned result is the smallest possible rgba or hex notation.
|
|
775
|
+
*
|
|
776
|
+
* Can also be used to fade a color by passing a hex value or named CSS color along with an alpha value.
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* // Styles as object usage
|
|
780
|
+
* const styles = {
|
|
781
|
+
* background: rgba(255, 205, 100, 0.7),
|
|
782
|
+
* background: rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 }),
|
|
783
|
+
* background: rgba(255, 205, 100, 1),
|
|
784
|
+
* background: rgba('#ffffff', 0.4),
|
|
785
|
+
* background: rgba('black', 0.7),
|
|
786
|
+
* }
|
|
787
|
+
*
|
|
788
|
+
* // styled-components usage
|
|
789
|
+
* const div = styled.div`
|
|
790
|
+
* background: ${rgba(255, 205, 100, 0.7)};
|
|
791
|
+
* background: ${rgba({ red: 255, green: 205, blue: 100, alpha: 0.7 })};
|
|
792
|
+
* background: ${rgba(255, 205, 100, 1)};
|
|
793
|
+
* background: ${rgba('#ffffff', 0.4)};
|
|
794
|
+
* background: ${rgba('black', 0.7)};
|
|
795
|
+
* `
|
|
796
|
+
*
|
|
797
|
+
* // CSS in JS Output
|
|
798
|
+
*
|
|
799
|
+
* element {
|
|
800
|
+
* background: "rgba(255,205,100,0.7)";
|
|
801
|
+
* background: "rgba(255,205,100,0.7)";
|
|
802
|
+
* background: "#ffcd64";
|
|
803
|
+
* background: "rgba(255,255,255,0.4)";
|
|
804
|
+
* background: "rgba(0,0,0,0.7)";
|
|
805
|
+
* }
|
|
806
|
+
*/
|
|
807
|
+
function rgba(firstValue, secondValue, thirdValue, fourthValue) {
|
|
808
|
+
if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
|
|
809
|
+
return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
|
|
810
|
+
}
|
|
811
|
+
throw new PolishedError(7);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
var isRgb = function isRgb(color) {
|
|
815
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
816
|
+
};
|
|
817
|
+
var isRgba = function isRgba(color) {
|
|
818
|
+
return typeof color.red === 'number' && typeof color.green === 'number' && typeof color.blue === 'number' && typeof color.alpha === 'number';
|
|
819
|
+
};
|
|
820
|
+
var isHsl = function isHsl(color) {
|
|
821
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && (typeof color.alpha !== 'number' || typeof color.alpha === 'undefined');
|
|
822
|
+
};
|
|
823
|
+
var isHsla = function isHsla(color) {
|
|
824
|
+
return typeof color.hue === 'number' && typeof color.saturation === 'number' && typeof color.lightness === 'number' && typeof color.alpha === 'number';
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Converts a RgbColor, RgbaColor, HslColor or HslaColor object to a color string.
|
|
829
|
+
* This util is useful in case you only know on runtime which color object is
|
|
830
|
+
* used. Otherwise we recommend to rely on `rgb`, `rgba`, `hsl` or `hsla`.
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* // Styles as object usage
|
|
834
|
+
* const styles = {
|
|
835
|
+
* background: toColorString({ red: 255, green: 205, blue: 100 }),
|
|
836
|
+
* background: toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 }),
|
|
837
|
+
* background: toColorString({ hue: 240, saturation: 1, lightness: 0.5 }),
|
|
838
|
+
* background: toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 }),
|
|
839
|
+
* }
|
|
840
|
+
*
|
|
841
|
+
* // styled-components usage
|
|
842
|
+
* const div = styled.div`
|
|
843
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100 })};
|
|
844
|
+
* background: ${toColorString({ red: 255, green: 205, blue: 100, alpha: 0.72 })};
|
|
845
|
+
* background: ${toColorString({ hue: 240, saturation: 1, lightness: 0.5 })};
|
|
846
|
+
* background: ${toColorString({ hue: 360, saturation: 0.75, lightness: 0.4, alpha: 0.72 })};
|
|
847
|
+
* `
|
|
848
|
+
*
|
|
849
|
+
* // CSS in JS Output
|
|
850
|
+
* element {
|
|
851
|
+
* background: "#ffcd64";
|
|
852
|
+
* background: "rgba(255,205,100,0.72)";
|
|
853
|
+
* background: "#00f";
|
|
854
|
+
* background: "rgba(179,25,25,0.72)";
|
|
855
|
+
* }
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
function toColorString(color) {
|
|
859
|
+
if (typeof color !== 'object') throw new PolishedError(8);
|
|
860
|
+
if (isRgba(color)) return rgba(color);
|
|
861
|
+
if (isRgb(color)) return rgb(color);
|
|
862
|
+
if (isHsla(color)) return hsla(color);
|
|
863
|
+
if (isHsl(color)) return hsl(color);
|
|
864
|
+
throw new PolishedError(8);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
// Type definitions taken from https://github.com/gcanti/flow-static-land/blob/master/src/Fun.js
|
|
868
|
+
// eslint-disable-next-line no-unused-vars
|
|
869
|
+
// eslint-disable-next-line no-unused-vars
|
|
870
|
+
// eslint-disable-next-line no-redeclare
|
|
871
|
+
function curried(f, length, acc) {
|
|
872
|
+
return function fn() {
|
|
873
|
+
// eslint-disable-next-line prefer-rest-params
|
|
874
|
+
var combined = acc.concat(Array.prototype.slice.call(arguments));
|
|
875
|
+
return combined.length >= length ? f.apply(this, combined) : curried(f, length, combined);
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// eslint-disable-next-line no-redeclare
|
|
880
|
+
function curry(f) {
|
|
881
|
+
// eslint-disable-line no-redeclare
|
|
882
|
+
return curried(f, f.length, []);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Changes the hue of the color. Hue is a number between 0 to 360. The first
|
|
887
|
+
* argument for adjustHue is the amount of degrees the color is rotated around
|
|
888
|
+
* the color wheel, always producing a positive hue value.
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* // Styles as object usage
|
|
892
|
+
* const styles = {
|
|
893
|
+
* background: adjustHue(180, '#448'),
|
|
894
|
+
* background: adjustHue('180', 'rgba(101,100,205,0.7)'),
|
|
895
|
+
* }
|
|
896
|
+
*
|
|
897
|
+
* // styled-components usage
|
|
898
|
+
* const div = styled.div`
|
|
899
|
+
* background: ${adjustHue(180, '#448')};
|
|
900
|
+
* background: ${adjustHue('180', 'rgba(101,100,205,0.7)')};
|
|
901
|
+
* `
|
|
902
|
+
*
|
|
903
|
+
* // CSS in JS Output
|
|
904
|
+
* element {
|
|
905
|
+
* background: "#888844";
|
|
906
|
+
* background: "rgba(136,136,68,0.7)";
|
|
907
|
+
* }
|
|
908
|
+
*/
|
|
909
|
+
function adjustHue(degree, color) {
|
|
910
|
+
if (color === 'transparent') return color;
|
|
911
|
+
var hslColor = parseToHsl(color);
|
|
912
|
+
return toColorString(_extends({}, hslColor, {
|
|
913
|
+
hue: hslColor.hue + parseFloat(degree)
|
|
914
|
+
}));
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// prettier-ignore
|
|
918
|
+
curry /* ::<number | string, string, string> */(adjustHue);
|
|
919
|
+
|
|
920
|
+
function guard(lowerBoundary, upperBoundary, value) {
|
|
921
|
+
return Math.max(lowerBoundary, Math.min(upperBoundary, value));
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* Returns a string value for the darkened color.
|
|
926
|
+
*
|
|
927
|
+
* @example
|
|
928
|
+
* // Styles as object usage
|
|
929
|
+
* const styles = {
|
|
930
|
+
* background: darken(0.2, '#FFCD64'),
|
|
931
|
+
* background: darken('0.2', 'rgba(255,205,100,0.7)'),
|
|
932
|
+
* }
|
|
933
|
+
*
|
|
934
|
+
* // styled-components usage
|
|
935
|
+
* const div = styled.div`
|
|
936
|
+
* background: ${darken(0.2, '#FFCD64')};
|
|
937
|
+
* background: ${darken('0.2', 'rgba(255,205,100,0.7)')};
|
|
938
|
+
* `
|
|
939
|
+
*
|
|
940
|
+
* // CSS in JS Output
|
|
941
|
+
*
|
|
942
|
+
* element {
|
|
943
|
+
* background: "#ffbd31";
|
|
944
|
+
* background: "rgba(255,189,49,0.7)";
|
|
945
|
+
* }
|
|
946
|
+
*/
|
|
947
|
+
function darken(amount, color) {
|
|
948
|
+
if (color === 'transparent') return color;
|
|
949
|
+
var hslColor = parseToHsl(color);
|
|
950
|
+
return toColorString(_extends({}, hslColor, {
|
|
951
|
+
lightness: guard(0, 1, hslColor.lightness - parseFloat(amount))
|
|
952
|
+
}));
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
// prettier-ignore
|
|
956
|
+
curry /* ::<number | string, string, string> */(darken);
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Decreases the intensity of a color. Its range is between 0 to 1. The first
|
|
960
|
+
* argument of the desaturate function is the amount by how much the color
|
|
961
|
+
* intensity should be decreased.
|
|
962
|
+
*
|
|
963
|
+
* @example
|
|
964
|
+
* // Styles as object usage
|
|
965
|
+
* const styles = {
|
|
966
|
+
* background: desaturate(0.2, '#CCCD64'),
|
|
967
|
+
* background: desaturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
968
|
+
* }
|
|
969
|
+
*
|
|
970
|
+
* // styled-components usage
|
|
971
|
+
* const div = styled.div`
|
|
972
|
+
* background: ${desaturate(0.2, '#CCCD64')};
|
|
973
|
+
* background: ${desaturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
974
|
+
* `
|
|
975
|
+
*
|
|
976
|
+
* // CSS in JS Output
|
|
977
|
+
* element {
|
|
978
|
+
* background: "#b8b979";
|
|
979
|
+
* background: "rgba(184,185,121,0.7)";
|
|
980
|
+
* }
|
|
981
|
+
*/
|
|
982
|
+
function desaturate(amount, color) {
|
|
983
|
+
if (color === 'transparent') return color;
|
|
984
|
+
var hslColor = parseToHsl(color);
|
|
985
|
+
return toColorString(_extends({}, hslColor, {
|
|
986
|
+
saturation: guard(0, 1, hslColor.saturation - parseFloat(amount))
|
|
987
|
+
}));
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
// prettier-ignore
|
|
991
|
+
curry /* ::<number | string, string, string> */(desaturate);
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Returns a number (float) representing the luminance of a color.
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* // Styles as object usage
|
|
998
|
+
* const styles = {
|
|
999
|
+
* background: getLuminance('#CCCD64') >= getLuminance('#0000ff') ? '#CCCD64' : '#0000ff',
|
|
1000
|
+
* background: getLuminance('rgba(58, 133, 255, 1)') >= getLuminance('rgba(255, 57, 149, 1)') ?
|
|
1001
|
+
* 'rgba(58, 133, 255, 1)' :
|
|
1002
|
+
* 'rgba(255, 57, 149, 1)',
|
|
1003
|
+
* }
|
|
1004
|
+
*
|
|
1005
|
+
* // styled-components usage
|
|
1006
|
+
* const div = styled.div`
|
|
1007
|
+
* background: ${getLuminance('#CCCD64') >= getLuminance('#0000ff') ? '#CCCD64' : '#0000ff'};
|
|
1008
|
+
* background: ${getLuminance('rgba(58, 133, 255, 1)') >= getLuminance('rgba(255, 57, 149, 1)') ?
|
|
1009
|
+
* 'rgba(58, 133, 255, 1)' :
|
|
1010
|
+
* 'rgba(255, 57, 149, 1)'};
|
|
1011
|
+
*
|
|
1012
|
+
* // CSS in JS Output
|
|
1013
|
+
*
|
|
1014
|
+
* div {
|
|
1015
|
+
* background: "#CCCD64";
|
|
1016
|
+
* background: "rgba(58, 133, 255, 1)";
|
|
1017
|
+
* }
|
|
1018
|
+
*/
|
|
1019
|
+
function getLuminance(color) {
|
|
1020
|
+
if (color === 'transparent') return 0;
|
|
1021
|
+
var rgbColor = parseToRgb(color);
|
|
1022
|
+
var _Object$keys$map = Object.keys(rgbColor).map(function (key) {
|
|
1023
|
+
var channel = rgbColor[key] / 255;
|
|
1024
|
+
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
|
1025
|
+
}),
|
|
1026
|
+
r = _Object$keys$map[0],
|
|
1027
|
+
g = _Object$keys$map[1],
|
|
1028
|
+
b = _Object$keys$map[2];
|
|
1029
|
+
return parseFloat((0.2126 * r + 0.7152 * g + 0.0722 * b).toFixed(3));
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Returns a string value for the lightened color.
|
|
1034
|
+
*
|
|
1035
|
+
* @example
|
|
1036
|
+
* // Styles as object usage
|
|
1037
|
+
* const styles = {
|
|
1038
|
+
* background: lighten(0.2, '#CCCD64'),
|
|
1039
|
+
* background: lighten('0.2', 'rgba(204,205,100,0.7)'),
|
|
1040
|
+
* }
|
|
1041
|
+
*
|
|
1042
|
+
* // styled-components usage
|
|
1043
|
+
* const div = styled.div`
|
|
1044
|
+
* background: ${lighten(0.2, '#FFCD64')};
|
|
1045
|
+
* background: ${lighten('0.2', 'rgba(204,205,100,0.7)')};
|
|
1046
|
+
* `
|
|
1047
|
+
*
|
|
1048
|
+
* // CSS in JS Output
|
|
1049
|
+
*
|
|
1050
|
+
* element {
|
|
1051
|
+
* background: "#e5e6b1";
|
|
1052
|
+
* background: "rgba(229,230,177,0.7)";
|
|
1053
|
+
* }
|
|
1054
|
+
*/
|
|
1055
|
+
function lighten(amount, color) {
|
|
1056
|
+
if (color === 'transparent') return color;
|
|
1057
|
+
var hslColor = parseToHsl(color);
|
|
1058
|
+
return toColorString(_extends({}, hslColor, {
|
|
1059
|
+
lightness: guard(0, 1, hslColor.lightness + parseFloat(amount))
|
|
1060
|
+
}));
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// prettier-ignore
|
|
1064
|
+
curry /* ::<number | string, string, string> */(lighten);
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Mixes the two provided colors together by calculating the average of each of the RGB components weighted to the first color by the provided weight.
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* // Styles as object usage
|
|
1071
|
+
* const styles = {
|
|
1072
|
+
* background: mix(0.5, '#f00', '#00f')
|
|
1073
|
+
* background: mix(0.25, '#f00', '#00f')
|
|
1074
|
+
* background: mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')
|
|
1075
|
+
* }
|
|
1076
|
+
*
|
|
1077
|
+
* // styled-components usage
|
|
1078
|
+
* const div = styled.div`
|
|
1079
|
+
* background: ${mix(0.5, '#f00', '#00f')};
|
|
1080
|
+
* background: ${mix(0.25, '#f00', '#00f')};
|
|
1081
|
+
* background: ${mix('0.5', 'rgba(255, 0, 0, 0.5)', '#00f')};
|
|
1082
|
+
* `
|
|
1083
|
+
*
|
|
1084
|
+
* // CSS in JS Output
|
|
1085
|
+
*
|
|
1086
|
+
* element {
|
|
1087
|
+
* background: "#7f007f";
|
|
1088
|
+
* background: "#3f00bf";
|
|
1089
|
+
* background: "rgba(63, 0, 191, 0.75)";
|
|
1090
|
+
* }
|
|
1091
|
+
*/
|
|
1092
|
+
function mix(weight, color, otherColor) {
|
|
1093
|
+
if (color === 'transparent') return otherColor;
|
|
1094
|
+
if (otherColor === 'transparent') return color;
|
|
1095
|
+
if (weight === 0) return otherColor;
|
|
1096
|
+
var parsedColor1 = parseToRgb(color);
|
|
1097
|
+
var color1 = _extends({}, parsedColor1, {
|
|
1098
|
+
alpha: typeof parsedColor1.alpha === 'number' ? parsedColor1.alpha : 1
|
|
1099
|
+
});
|
|
1100
|
+
var parsedColor2 = parseToRgb(otherColor);
|
|
1101
|
+
var color2 = _extends({}, parsedColor2, {
|
|
1102
|
+
alpha: typeof parsedColor2.alpha === 'number' ? parsedColor2.alpha : 1
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
// The formula is copied from the original Sass implementation:
|
|
1106
|
+
// http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method
|
|
1107
|
+
var alphaDelta = color1.alpha - color2.alpha;
|
|
1108
|
+
var x = parseFloat(weight) * 2 - 1;
|
|
1109
|
+
var y = x * alphaDelta === -1 ? x : x + alphaDelta;
|
|
1110
|
+
var z = 1 + x * alphaDelta;
|
|
1111
|
+
var weight1 = (y / z + 1) / 2.0;
|
|
1112
|
+
var weight2 = 1 - weight1;
|
|
1113
|
+
var mixedColor = {
|
|
1114
|
+
red: Math.floor(color1.red * weight1 + color2.red * weight2),
|
|
1115
|
+
green: Math.floor(color1.green * weight1 + color2.green * weight2),
|
|
1116
|
+
blue: Math.floor(color1.blue * weight1 + color2.blue * weight2),
|
|
1117
|
+
alpha: color1.alpha * parseFloat(weight) + color2.alpha * (1 - parseFloat(weight))
|
|
1118
|
+
};
|
|
1119
|
+
return rgba(mixedColor);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
// prettier-ignore
|
|
1123
|
+
var curriedMix = curry /* ::<number | string, string, string, string> */(mix);
|
|
1124
|
+
var mix$1 = curriedMix;
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Increases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
1128
|
+
*
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* // Styles as object usage
|
|
1132
|
+
* const styles = {
|
|
1133
|
+
* background: opacify(0.1, 'rgba(255, 255, 255, 0.9)');
|
|
1134
|
+
* background: opacify(0.2, 'hsla(0, 0%, 100%, 0.5)'),
|
|
1135
|
+
* background: opacify('0.5', 'rgba(255, 0, 0, 0.2)'),
|
|
1136
|
+
* }
|
|
1137
|
+
*
|
|
1138
|
+
* // styled-components usage
|
|
1139
|
+
* const div = styled.div`
|
|
1140
|
+
* background: ${opacify(0.1, 'rgba(255, 255, 255, 0.9)')};
|
|
1141
|
+
* background: ${opacify(0.2, 'hsla(0, 0%, 100%, 0.5)')},
|
|
1142
|
+
* background: ${opacify('0.5', 'rgba(255, 0, 0, 0.2)')},
|
|
1143
|
+
* `
|
|
1144
|
+
*
|
|
1145
|
+
* // CSS in JS Output
|
|
1146
|
+
*
|
|
1147
|
+
* element {
|
|
1148
|
+
* background: "#fff";
|
|
1149
|
+
* background: "rgba(255,255,255,0.7)";
|
|
1150
|
+
* background: "rgba(255,0,0,0.7)";
|
|
1151
|
+
* }
|
|
1152
|
+
*/
|
|
1153
|
+
function opacify(amount, color) {
|
|
1154
|
+
if (color === 'transparent') return color;
|
|
1155
|
+
var parsedColor = parseToRgb(color);
|
|
1156
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
1157
|
+
var colorWithAlpha = _extends({}, parsedColor, {
|
|
1158
|
+
alpha: guard(0, 1, (alpha * 100 + parseFloat(amount) * 100) / 100)
|
|
1159
|
+
});
|
|
1160
|
+
return rgba(colorWithAlpha);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// prettier-ignore
|
|
1164
|
+
curry /* ::<number | string, string, string> */(opacify);
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Increases the intensity of a color. Its range is between 0 to 1. The first
|
|
1168
|
+
* argument of the saturate function is the amount by how much the color
|
|
1169
|
+
* intensity should be increased.
|
|
1170
|
+
*
|
|
1171
|
+
* @example
|
|
1172
|
+
* // Styles as object usage
|
|
1173
|
+
* const styles = {
|
|
1174
|
+
* background: saturate(0.2, '#CCCD64'),
|
|
1175
|
+
* background: saturate('0.2', 'rgba(204,205,100,0.7)'),
|
|
1176
|
+
* }
|
|
1177
|
+
*
|
|
1178
|
+
* // styled-components usage
|
|
1179
|
+
* const div = styled.div`
|
|
1180
|
+
* background: ${saturate(0.2, '#FFCD64')};
|
|
1181
|
+
* background: ${saturate('0.2', 'rgba(204,205,100,0.7)')};
|
|
1182
|
+
* `
|
|
1183
|
+
*
|
|
1184
|
+
* // CSS in JS Output
|
|
1185
|
+
*
|
|
1186
|
+
* element {
|
|
1187
|
+
* background: "#e0e250";
|
|
1188
|
+
* background: "rgba(224,226,80,0.7)";
|
|
1189
|
+
* }
|
|
1190
|
+
*/
|
|
1191
|
+
function saturate(amount, color) {
|
|
1192
|
+
if (color === 'transparent') return color;
|
|
1193
|
+
var hslColor = parseToHsl(color);
|
|
1194
|
+
return toColorString(_extends({}, hslColor, {
|
|
1195
|
+
saturation: guard(0, 1, hslColor.saturation + parseFloat(amount))
|
|
1196
|
+
}));
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// prettier-ignore
|
|
1200
|
+
curry /* ::<number | string, string, string> */(saturate);
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Sets the hue of a color to the provided value. The hue range can be
|
|
1204
|
+
* from 0 and 359.
|
|
1205
|
+
*
|
|
1206
|
+
* @example
|
|
1207
|
+
* // Styles as object usage
|
|
1208
|
+
* const styles = {
|
|
1209
|
+
* background: setHue(42, '#CCCD64'),
|
|
1210
|
+
* background: setHue('244', 'rgba(204,205,100,0.7)'),
|
|
1211
|
+
* }
|
|
1212
|
+
*
|
|
1213
|
+
* // styled-components usage
|
|
1214
|
+
* const div = styled.div`
|
|
1215
|
+
* background: ${setHue(42, '#CCCD64')};
|
|
1216
|
+
* background: ${setHue('244', 'rgba(204,205,100,0.7)')};
|
|
1217
|
+
* `
|
|
1218
|
+
*
|
|
1219
|
+
* // CSS in JS Output
|
|
1220
|
+
* element {
|
|
1221
|
+
* background: "#cdae64";
|
|
1222
|
+
* background: "rgba(107,100,205,0.7)";
|
|
1223
|
+
* }
|
|
1224
|
+
*/
|
|
1225
|
+
function setHue(hue, color) {
|
|
1226
|
+
if (color === 'transparent') return color;
|
|
1227
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
1228
|
+
hue: parseFloat(hue)
|
|
1229
|
+
}));
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
// prettier-ignore
|
|
1233
|
+
curry /* ::<number | string, string, string> */(setHue);
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Sets the lightness of a color to the provided value. The lightness range can be
|
|
1237
|
+
* from 0 and 1.
|
|
1238
|
+
*
|
|
1239
|
+
* @example
|
|
1240
|
+
* // Styles as object usage
|
|
1241
|
+
* const styles = {
|
|
1242
|
+
* background: setLightness(0.2, '#CCCD64'),
|
|
1243
|
+
* background: setLightness('0.75', 'rgba(204,205,100,0.7)'),
|
|
1244
|
+
* }
|
|
1245
|
+
*
|
|
1246
|
+
* // styled-components usage
|
|
1247
|
+
* const div = styled.div`
|
|
1248
|
+
* background: ${setLightness(0.2, '#CCCD64')};
|
|
1249
|
+
* background: ${setLightness('0.75', 'rgba(204,205,100,0.7)')};
|
|
1250
|
+
* `
|
|
1251
|
+
*
|
|
1252
|
+
* // CSS in JS Output
|
|
1253
|
+
* element {
|
|
1254
|
+
* background: "#4d4d19";
|
|
1255
|
+
* background: "rgba(223,224,159,0.7)";
|
|
1256
|
+
* }
|
|
1257
|
+
*/
|
|
1258
|
+
function setLightness(lightness, color) {
|
|
1259
|
+
if (color === 'transparent') return color;
|
|
1260
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
1261
|
+
lightness: parseFloat(lightness)
|
|
1262
|
+
}));
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
// prettier-ignore
|
|
1266
|
+
curry /* ::<number | string, string, string> */(setLightness);
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* Sets the saturation of a color to the provided value. The saturation range can be
|
|
1270
|
+
* from 0 and 1.
|
|
1271
|
+
*
|
|
1272
|
+
* @example
|
|
1273
|
+
* // Styles as object usage
|
|
1274
|
+
* const styles = {
|
|
1275
|
+
* background: setSaturation(0.2, '#CCCD64'),
|
|
1276
|
+
* background: setSaturation('0.75', 'rgba(204,205,100,0.7)'),
|
|
1277
|
+
* }
|
|
1278
|
+
*
|
|
1279
|
+
* // styled-components usage
|
|
1280
|
+
* const div = styled.div`
|
|
1281
|
+
* background: ${setSaturation(0.2, '#CCCD64')};
|
|
1282
|
+
* background: ${setSaturation('0.75', 'rgba(204,205,100,0.7)')};
|
|
1283
|
+
* `
|
|
1284
|
+
*
|
|
1285
|
+
* // CSS in JS Output
|
|
1286
|
+
* element {
|
|
1287
|
+
* background: "#adad84";
|
|
1288
|
+
* background: "rgba(228,229,76,0.7)";
|
|
1289
|
+
* }
|
|
1290
|
+
*/
|
|
1291
|
+
function setSaturation(saturation, color) {
|
|
1292
|
+
if (color === 'transparent') return color;
|
|
1293
|
+
return toColorString(_extends({}, parseToHsl(color), {
|
|
1294
|
+
saturation: parseFloat(saturation)
|
|
1295
|
+
}));
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// prettier-ignore
|
|
1299
|
+
curry /* ::<number | string, string, string> */(setSaturation);
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Shades a color by mixing it with black. `shade` can produce
|
|
1303
|
+
* hue shifts, where as `darken` manipulates the luminance channel and therefore
|
|
1304
|
+
* doesn't produce hue shifts.
|
|
1305
|
+
*
|
|
1306
|
+
* @example
|
|
1307
|
+
* // Styles as object usage
|
|
1308
|
+
* const styles = {
|
|
1309
|
+
* background: shade(0.25, '#00f')
|
|
1310
|
+
* }
|
|
1311
|
+
*
|
|
1312
|
+
* // styled-components usage
|
|
1313
|
+
* const div = styled.div`
|
|
1314
|
+
* background: ${shade(0.25, '#00f')};
|
|
1315
|
+
* `
|
|
1316
|
+
*
|
|
1317
|
+
* // CSS in JS Output
|
|
1318
|
+
*
|
|
1319
|
+
* element {
|
|
1320
|
+
* background: "#00003f";
|
|
1321
|
+
* }
|
|
1322
|
+
*/
|
|
1323
|
+
|
|
1324
|
+
function shade(percentage, color) {
|
|
1325
|
+
if (color === 'transparent') return color;
|
|
1326
|
+
return mix$1(parseFloat(percentage), 'rgb(0, 0, 0)', color);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
// prettier-ignore
|
|
1330
|
+
curry /* ::<number | string, string, string> */(shade);
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* Tints a color by mixing it with white. `tint` can produce
|
|
1334
|
+
* hue shifts, where as `lighten` manipulates the luminance channel and therefore
|
|
1335
|
+
* doesn't produce hue shifts.
|
|
1336
|
+
*
|
|
1337
|
+
* @example
|
|
1338
|
+
* // Styles as object usage
|
|
1339
|
+
* const styles = {
|
|
1340
|
+
* background: tint(0.25, '#00f')
|
|
1341
|
+
* }
|
|
1342
|
+
*
|
|
1343
|
+
* // styled-components usage
|
|
1344
|
+
* const div = styled.div`
|
|
1345
|
+
* background: ${tint(0.25, '#00f')};
|
|
1346
|
+
* `
|
|
1347
|
+
*
|
|
1348
|
+
* // CSS in JS Output
|
|
1349
|
+
*
|
|
1350
|
+
* element {
|
|
1351
|
+
* background: "#bfbfff";
|
|
1352
|
+
* }
|
|
1353
|
+
*/
|
|
1354
|
+
|
|
1355
|
+
function tint(percentage, color) {
|
|
1356
|
+
if (color === 'transparent') return color;
|
|
1357
|
+
return mix$1(parseFloat(percentage), 'rgb(255, 255, 255)', color);
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
// prettier-ignore
|
|
1361
|
+
curry /* ::<number | string, string, string> */(tint);
|
|
1362
|
+
|
|
1363
|
+
/**
|
|
1364
|
+
* Decreases the opacity of a color. Its range for the amount is between 0 to 1.
|
|
1365
|
+
*
|
|
1366
|
+
*
|
|
1367
|
+
* @example
|
|
1368
|
+
* // Styles as object usage
|
|
1369
|
+
* const styles = {
|
|
1370
|
+
* background: transparentize(0.1, '#fff'),
|
|
1371
|
+
* background: transparentize(0.2, 'hsl(0, 0%, 100%)'),
|
|
1372
|
+
* background: transparentize('0.5', 'rgba(255, 0, 0, 0.8)'),
|
|
1373
|
+
* }
|
|
1374
|
+
*
|
|
1375
|
+
* // styled-components usage
|
|
1376
|
+
* const div = styled.div`
|
|
1377
|
+
* background: ${transparentize(0.1, '#fff')};
|
|
1378
|
+
* background: ${transparentize(0.2, 'hsl(0, 0%, 100%)')};
|
|
1379
|
+
* background: ${transparentize('0.5', 'rgba(255, 0, 0, 0.8)')};
|
|
1380
|
+
* `
|
|
1381
|
+
*
|
|
1382
|
+
* // CSS in JS Output
|
|
1383
|
+
*
|
|
1384
|
+
* element {
|
|
1385
|
+
* background: "rgba(255,255,255,0.9)";
|
|
1386
|
+
* background: "rgba(255,255,255,0.8)";
|
|
1387
|
+
* background: "rgba(255,0,0,0.3)";
|
|
1388
|
+
* }
|
|
1389
|
+
*/
|
|
1390
|
+
function transparentize(amount, color) {
|
|
1391
|
+
if (color === 'transparent') return color;
|
|
1392
|
+
var parsedColor = parseToRgb(color);
|
|
1393
|
+
var alpha = typeof parsedColor.alpha === 'number' ? parsedColor.alpha : 1;
|
|
1394
|
+
var colorWithAlpha = _extends({}, parsedColor, {
|
|
1395
|
+
alpha: guard(0, 1, +(alpha * 100 - parseFloat(amount) * 100).toFixed(2) / 100)
|
|
1396
|
+
});
|
|
1397
|
+
return rgba(colorWithAlpha);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
// prettier-ignore
|
|
1401
|
+
curry /* ::<number | string, string, string> */(transparentize);
|
|
1402
|
+
|
|
1403
|
+
const useAccessibleColor = (primaryColorVar, primaryForegroundVar) => {
|
|
1404
|
+
const [foregroundColor, setForegroundColor] = useState(`var(${primaryForegroundVar})`);
|
|
1405
|
+
const isDarkMode = useDarkMode();
|
|
1406
|
+
useEffect(() => {
|
|
1407
|
+
const primaryColor = cssVar(primaryColorVar);
|
|
1408
|
+
const primaryForeground = cssVar(primaryForegroundVar);
|
|
1409
|
+
if (primaryColor && primaryForeground) {
|
|
1410
|
+
const luminance = getLuminance(primaryColor.toString());
|
|
1411
|
+
if (luminance <= 0.5) {
|
|
1412
|
+
setForegroundColor(isDarkMode ? `var(--bfc-ring)` : `var(${primaryColorVar})`);
|
|
1413
|
+
} else {
|
|
1414
|
+
setForegroundColor(isDarkMode ? `var(${primaryColorVar})` : `var(${primaryForegroundVar})`);
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}, [primaryColorVar, primaryForegroundVar, isDarkMode]);
|
|
1418
|
+
return foregroundColor;
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
const generatingStarVariants = cva("min-w-5", {
|
|
1422
|
+
variants: {
|
|
1423
|
+
variant: {
|
|
1424
|
+
default: "size-6",
|
|
1425
|
+
gradient: "size-8"
|
|
1426
|
+
},
|
|
1427
|
+
loading: {
|
|
1428
|
+
true: "animate-spin"
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
defaultVariants: {
|
|
1432
|
+
variant: "default"
|
|
1433
|
+
}
|
|
1434
|
+
});
|
|
1435
|
+
const TRANSFORM_MATRIX = "matrix(0 0.0120051 -0.0120051 0 16.0051 16.0051)";
|
|
1436
|
+
const FOREIGN_OBJECT_PROPS = {
|
|
1437
|
+
x: "-1083.3",
|
|
1438
|
+
y: "-1083.3",
|
|
1439
|
+
width: "2166.6",
|
|
1440
|
+
height: "2166.6"
|
|
1441
|
+
};
|
|
1442
|
+
const STAR_OUTER_PATH = "M16.0127 3.5C16.5221 3.50002 17.0197 3.65584 17.4375 3.94727C17.8553 4.23871 18.1736 4.65182 18.3496 5.12988L20.6445 11.3652L26.876 13.6689L27.0283 13.7246L27.0391 13.7402C27.4497 13.9244 27.8038 14.2171 28.0625 14.5879C28.3539 15.0057 28.5098 15.5032 28.5098 16.0127C28.5097 16.5221 28.3539 17.0197 28.0625 17.4375C27.7711 17.8552 27.3579 18.1737 26.8799 18.3496L20.6426 20.6445L18.334 26.8809C18.158 27.3587 17.8396 27.7712 17.4219 28.0625C17.0042 28.3538 16.5073 28.5097 15.998 28.5098C15.4886 28.5098 14.9911 28.3539 14.5732 28.0625C14.1554 27.771 13.8371 27.358 13.6611 26.8799L11.3652 20.6436L5.12891 18.334V18.333C4.65135 18.1569 4.23846 17.8394 3.94727 17.4219C3.65606 17.0042 3.5001 16.5072 3.5 15.998C3.5 15.4887 3.65596 14.991 3.94727 14.5732C4.2387 14.1554 4.65182 13.8371 5.12988 13.6611L11.3652 11.3652L13.6758 5.12891C13.8518 4.65116 14.1703 4.23855 14.5879 3.94727C15.0057 3.65585 15.5033 3.5 16.0127 3.5ZM13.9463 13.0498L13.9473 13.0508C13.8723 13.2565 13.7535 13.4438 13.5986 13.5986C13.4438 13.7535 13.2565 13.8723 13.0508 13.9473L13.0498 13.9463L7.46875 16.0049L13.0498 18.0625H13.0508C13.2564 18.1374 13.4438 18.2564 13.5986 18.4111C13.7529 18.5654 13.8713 18.7521 13.9463 18.957L16.0049 24.541L18.0684 18.9521L18.1328 18.8027C18.2049 18.6578 18.3001 18.5251 18.415 18.4102C18.5684 18.2568 18.7535 18.1385 18.957 18.0635L24.541 16.0049L18.9521 13.9414C18.7486 13.8664 18.5636 13.7481 18.4102 13.5947C18.2568 13.4413 18.1385 13.2563 18.0635 13.0527L16.0049 7.46875L13.9463 13.0498Z";
|
|
1443
|
+
const STAR_INNER_PATH = "M13.9463 13.0498L13.9473 13.0508C13.8723 13.2565 13.7535 13.4438 13.5986 13.5986C13.4438 13.7535 13.2565 13.8723 13.0508 13.9473L13.0498 13.9463L7.46875 16.0049L13.0498 18.0625H13.0508C13.2564 18.1374 13.4438 18.2564 13.5986 18.4111C13.7529 18.5654 13.8713 18.7521 13.9463 18.957L16.0049 24.541L18.0684 18.9521L18.1328 18.8027C18.2049 18.6578 18.3001 18.5251 18.415 18.4102C18.5684 18.2568 18.7535 18.1385 18.957 18.0635L24.541 16.0049L18.9521 13.9414C18.7486 13.8664 18.5636 13.7481 18.4102 13.5947C18.2568 13.4413 18.1385 13.2563 18.0635 13.0527L16.0049 7.46875L13.9463 13.0498Z";
|
|
1444
|
+
const BLUE_STAR_PATH = "M31.7071 9.70711C31.8946 9.51957 32 9.26522 32 9C32 8.73478 31.8946 8.48043 31.7071 8.29289C31.5196 8.10536 31.2652 8 31 8H30V7C30 6.73478 29.8946 6.48043 29.7071 6.29289C29.5196 6.10536 29.2652 6 29 6C28.7348 6 28.4804 6.10536 28.2929 6.29289C28.1054 6.48043 28 6.73478 28 7V8H27C26.7348 8 26.4804 8.10536 26.2929 8.29289C26.1054 8.48043 26 8.73478 26 9C26 9.26522 26.1054 9.51957 26.2929 9.70711C26.4804 9.89464 26.7348 10 27 10H28V11C28 11.2652 28.1054 11.5196 28.2929 11.7071C28.4804 11.8946 28.7348 12 29 12C29.2652 12 29.5196 11.8946 29.7071 11.7071C29.8946 11.5196 30 11.2652 30 11V10H31C31.2652 10 31.5196 9.89464 31.7071 9.70711Z";
|
|
1445
|
+
const GREEN_STAR_PATH = "M19.2929 3.29289C19.1054 3.48043 19 3.73478 19 4C19 4.26522 19.1054 4.51957 19.2929 4.70711C19.4804 4.89464 19.7348 5 20 5H22V7C22 7.26522 22.1054 7.51957 22.2929 7.70711C22.4804 7.89464 22.7348 8 23 8C23.2652 8 23.5196 7.89464 23.7071 7.70711C23.8946 7.51957 24 7.26522 24 7V5H26C26.2652 5 26.5196 4.89464 26.7071 4.70711C26.8946 4.51957 27 4.26522 27 4C27 3.73478 26.8946 3.48043 26.7071 3.29289C26.5196 3.10536 26.2652 3 26 3H24V1C24 0.734784 23.8946 0.48043 23.7071 0.292893C23.5196 0.105357 23.2652 0 23 0C22.7348 0 22.4804 0.105357 22.2929 0.292893C22.1054 0.48043 22 0.734784 22 1V3H20C19.7348 3 19.4804 3.10536 19.2929 3.29289Z";
|
|
1446
|
+
function ClippedBackground({
|
|
1447
|
+
clipPathId,
|
|
1448
|
+
className,
|
|
1449
|
+
loading
|
|
1450
|
+
}) {
|
|
1451
|
+
return /* @__PURE__ */ React__default.createElement("g", { clipPath: `url(#${clipPathId})` }, /* @__PURE__ */ React__default.createElement("g", { transform: TRANSFORM_MATRIX }, /* @__PURE__ */ React__default.createElement("foreignObject", { ...FOREIGN_OBJECT_PROPS }, /* @__PURE__ */ React__default.createElement("div", { className: cn(className, loading && "animate-spin") }))));
|
|
1452
|
+
}
|
|
1453
|
+
function GeneratingStar({ loading, variant, className, ...props }) {
|
|
1454
|
+
const strokeColor = useAccessibleColor("--bfc-primary", "--bfc-border");
|
|
1455
|
+
const isGradient = variant === "gradient" /* GRADIENT */;
|
|
1456
|
+
const isDefault = !isGradient;
|
|
1457
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
1458
|
+
"svg",
|
|
1459
|
+
{
|
|
1460
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1461
|
+
width: "32",
|
|
1462
|
+
height: "32",
|
|
1463
|
+
viewBox: "0 0 32 32",
|
|
1464
|
+
fill: "none",
|
|
1465
|
+
className: cn(generatingStarVariants({ variant }), className),
|
|
1466
|
+
...props
|
|
1467
|
+
},
|
|
1468
|
+
/* @__PURE__ */ React__default.createElement(
|
|
1469
|
+
ClippedBackground,
|
|
1470
|
+
{
|
|
1471
|
+
clipPathId: "star-clip-path",
|
|
1472
|
+
className: cn("sparkle", {
|
|
1473
|
+
"gradient": isGradient,
|
|
1474
|
+
"bg-border": isDefault && strokeColor !== "var(--bfc-primary)",
|
|
1475
|
+
"bg-primary": isDefault && strokeColor === "var(--bfc-primary)"
|
|
1476
|
+
}),
|
|
1477
|
+
loading
|
|
1478
|
+
}
|
|
1479
|
+
),
|
|
1480
|
+
/* @__PURE__ */ React__default.createElement("path", { stroke: "var(--bfc-v2-color-mono-100)", className: cn({ "animate-spin": loading }), d: STAR_OUTER_PATH }),
|
|
1481
|
+
isDefault && /* @__PURE__ */ React__default.createElement("g", { className: "transform origin-center scale-125" }, /* @__PURE__ */ React__default.createElement("g", { className: cn({ "animate-spin": loading }) }, /* @__PURE__ */ React__default.createElement("path", { fill: "var(--bfc-primary)", d: STAR_INNER_PATH }))),
|
|
1482
|
+
/* @__PURE__ */ React__default.createElement("path", { fill: isGradient ? "#3C82F6" : "var(--bfc-primary)", d: BLUE_STAR_PATH }),
|
|
1483
|
+
/* @__PURE__ */ React__default.createElement("path", { fill: isGradient ? "#35D399" : "var(--bfc-primary)", d: GREEN_STAR_PATH }),
|
|
1484
|
+
/* @__PURE__ */ React__default.createElement("defs", null, /* @__PURE__ */ React__default.createElement("clipPath", { id: "star-clip-path", className: cn({ "animate-spin": loading }) }, /* @__PURE__ */ React__default.createElement("path", { d: STAR_OUTER_PATH })))
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
export { GeneratingStar as G, generatingStarVariants as g };
|
|
1489
|
+
//# sourceMappingURL=generating-star.COkD0gHd.js.map
|