@seeqdev/qomponents 0.0.132 → 0.0.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -135
- package/dist/Accordion/Accordion.js +8 -8
- package/dist/Accordion/Accordion.stories.js +114 -114
- package/dist/Accordion/Accordion.test.js +54 -54
- package/dist/Accordion/Accordion.types.js +1 -1
- package/dist/Accordion/index.js +1 -1
- package/dist/Alert/Alert.js +33 -33
- package/dist/Alert/Alert.stories.js +51 -51
- package/dist/Alert/Alert.test.js +50 -50
- package/dist/Alert/Alert.types.js +1 -1
- package/dist/Alert/index.js +1 -1
- package/dist/Button/Button.js +91 -91
- package/dist/Button/Button.stories.js +99 -99
- package/dist/Button/Button.test.js +48 -48
- package/dist/Button/Button.types.js +4 -4
- package/dist/Button/index.js +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +32 -32
- package/dist/ButtonGroup/ButtonGroup.stories.js +384 -384
- package/dist/ButtonGroup/ButtonGroup.test.js +66 -66
- package/dist/ButtonGroup/ButtonGroup.types.js +1 -1
- package/dist/ButtonGroup/index.js +1 -1
- package/dist/ButtonWithDropdown/ButtonWithDropdown.js +59 -59
- package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +142 -142
- package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -92
- package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
- package/dist/ButtonWithDropdown/index.js +1 -1
- package/dist/ButtonWithPopover/ButtonWithPopover.js +61 -61
- package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +74 -74
- package/dist/ButtonWithPopover/ButtonWithPopover.test.js +81 -81
- package/dist/ButtonWithPopover/ButtonWithPopover.types.js +1 -1
- package/dist/ButtonWithPopover/index.js +1 -1
- package/dist/Carousel/Carousel.js +66 -66
- package/dist/Carousel/Carousel.stories.js +114 -114
- package/dist/Carousel/Carousel.test.js +47 -47
- package/dist/Carousel/Carousel.types.js +1 -1
- package/dist/Carousel/index.js +1 -1
- package/dist/Checkbox/Checkbox.js +25 -25
- package/dist/Checkbox/Checkbox.stories.js +33 -33
- package/dist/Checkbox/Checkbox.test.js +93 -93
- package/dist/Checkbox/Checkbox.types.js +1 -1
- package/dist/Checkbox/index.js +1 -1
- package/dist/Collapse/Collapse.js +17 -17
- package/dist/Collapse/Collapse.stories.js +36 -36
- package/dist/Collapse/Collapse.test.js +18 -18
- package/dist/Collapse/Collapse.types.js +1 -1
- package/dist/Collapse/index.js +1 -1
- package/dist/Icon/Icon.js +54 -54
- package/dist/Icon/Icon.stories.js +46 -46
- package/dist/Icon/Icon.test.js +54 -54
- package/dist/Icon/Icon.types.js +15 -15
- package/dist/Icon/index.js +1 -1
- package/dist/InputGroup/InputGroup.js +31 -31
- package/dist/InputGroup/InputGroup.stories.js +167 -167
- package/dist/InputGroup/InputGroup.test.js +42 -42
- package/dist/InputGroup/InputGroup.types.js +1 -1
- package/dist/InputGroup/index.js +1 -1
- package/dist/Modal/Modal.js +99 -99
- package/dist/Modal/Modal.js.map +1 -1
- package/dist/Modal/Modal.stories.js +126 -126
- package/dist/Modal/Modal.test.js +107 -107
- package/dist/Modal/Modal.types.js +1 -1
- package/dist/Modal/index.js +1 -1
- package/dist/ProgressBar/ProgressBar.js +49 -29
- package/dist/ProgressBar/ProgressBar.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.stories.js +80 -72
- package/dist/ProgressBar/ProgressBar.stories.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.test.js +43 -37
- package/dist/ProgressBar/ProgressBar.test.js.map +1 -1
- package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
- package/dist/ProgressBar/ProgressBar.types.js +1 -1
- package/dist/ProgressBar/index.js +1 -1
- package/dist/SeeqActionDropdown/SeeqActionDropdown.js +47 -47
- package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +79 -79
- package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -72
- package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -1
- package/dist/SeeqActionDropdown/index.js +1 -1
- package/dist/SeeqActionDropdown/variants.js +22 -22
- package/dist/Select/Select.js +173 -173
- package/dist/Select/Select.stories.js +79 -79
- package/dist/Select/Select.test.js +181 -181
- package/dist/Select/Select.types.js +1 -1
- package/dist/Select/index.js +2 -2
- package/dist/Slider/Slider.js +12 -12
- package/dist/Slider/Slider.stories.js +57 -57
- package/dist/Slider/Slider.test.js +32 -32
- package/dist/Slider/Slider.types.js +1 -1
- package/dist/Slider/index.js +1 -1
- package/dist/Tabs/Tabs.js +21 -21
- package/dist/Tabs/Tabs.stories.js +90 -90
- package/dist/Tabs/Tabs.test.js +90 -90
- package/dist/Tabs/Tabs.types.js +1 -1
- package/dist/Tabs/index.js +1 -1
- package/dist/TextArea/TextArea.js +24 -24
- package/dist/TextArea/TextArea.stories.js +45 -45
- package/dist/TextArea/TextArea.test.js +67 -67
- package/dist/TextArea/TextArea.types.js +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/TextField/TextField.js +78 -78
- package/dist/TextField/TextField.stories.js +69 -69
- package/dist/TextField/TextField.test.js +38 -38
- package/dist/TextField/TextField.types.js +1 -1
- package/dist/TextField/index.js +1 -1
- package/dist/ToolbarButton/ToolbarButton.js +74 -74
- package/dist/ToolbarButton/ToolbarButton.stories.js +93 -93
- package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
- package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
- package/dist/ToolbarButton/index.js +1 -1
- package/dist/Tooltip/QTip.stories.js +44 -44
- package/dist/Tooltip/QTip.types.js +1 -1
- package/dist/Tooltip/QTipPerformance.stories.js +29 -29
- package/dist/Tooltip/Qtip.js +167 -167
- package/dist/Tooltip/Tooltip.js +35 -35
- package/dist/Tooltip/Tooltip.stories.js +31 -31
- package/dist/Tooltip/Tooltip.types.js +2 -2
- package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
- package/dist/Tooltip/index.js +2 -2
- package/dist/Tooltip/qTip.utilities.js +10 -10
- package/dist/example/.eslintrc.cjs +14 -14
- package/dist/example/README.md +33 -33
- package/dist/example/index.html +13 -13
- package/dist/example/package.json +30 -30
- package/dist/example/src/ComplexSelectExample.tsx +81 -81
- package/dist/example/src/Example.tsx +408 -408
- package/dist/example/src/index.css +102 -102
- package/dist/example/src/main.tsx +10 -10
- package/dist/example/src/vite-env.d.ts +1 -1
- package/dist/example/tsconfig.json +33 -33
- package/dist/example/tsconfig.node.json +12 -12
- package/dist/example/vite.config.ts +12 -12
- package/dist/index.esm.js +1229 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1229 -31
- package/dist/index.js.map +1 -1
- package/dist/styles.css +3714 -3709
- package/dist/types.js +1 -1
- package/dist/utils/browserId.js +28 -28
- package/dist/utils/svg.js +19 -19
- package/dist/utils/validateStyleDimension.js +13 -13
- package/dist/utils/validateStyleDimension.test.js +19 -19
- package/package.json +88 -86
package/dist/index.js
CHANGED
|
@@ -109,7 +109,7 @@ const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClas
|
|
|
109
109
|
const fontAwesomePrefix = iconPrefix ? iconPrefix : 'fa-sharp fa-regular';
|
|
110
110
|
const iconPrefixString = icon.startsWith('fc') ? 'fc' : fontAwesomePrefix;
|
|
111
111
|
const style = type === 'color' && color ? { color } : {};
|
|
112
|
-
const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
|
|
112
|
+
const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
|
|
113
113
|
${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'tw-cursor-pointer' : ''} ${extraClassNames} focus:tw-outline-none focus-visible:tw-outline-none tw-outline-none`;
|
|
114
114
|
const tooltipData = getQTipData(tooltipProps);
|
|
115
115
|
return (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number, ...tooltipData }));
|
|
@@ -1498,7 +1498,7 @@ const arrow$1 = options => ({
|
|
|
1498
1498
|
* clipping boundary. Alternative to `autoPlacement`.
|
|
1499
1499
|
* @see https://floating-ui.com/docs/flip
|
|
1500
1500
|
*/
|
|
1501
|
-
const flip = function (options) {
|
|
1501
|
+
const flip$1 = function (options) {
|
|
1502
1502
|
if (options === void 0) {
|
|
1503
1503
|
options = {};
|
|
1504
1504
|
}
|
|
@@ -3123,7 +3123,7 @@ const $cf1ac5d9fe0e8206$export$bc4ae5855d3c4fc = /*#__PURE__*/ React.forwardRef(
|
|
|
3123
3123
|
limiter: sticky === 'partial' ? limitShift() : undefined,
|
|
3124
3124
|
...detectOverflowOptions
|
|
3125
3125
|
}),
|
|
3126
|
-
avoidCollisions && flip({
|
|
3126
|
+
avoidCollisions && flip$1({
|
|
3127
3127
|
...detectOverflowOptions
|
|
3128
3128
|
}),
|
|
3129
3129
|
size({
|
|
@@ -4777,13 +4777,13 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
|
|
|
4777
4777
|
const arrowBaseClasses = 'before:tw-content-[\'\'] before:tw-absolute before:tw-border-8';
|
|
4778
4778
|
const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
|
|
4779
4779
|
const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
|
|
4780
|
-
const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
|
|
4780
|
+
const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
|
|
4781
4781
|
before:tw-border-l-transparent before:tw-border-r-black`;
|
|
4782
|
-
const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
|
|
4782
|
+
const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
|
|
4783
4783
|
before:tw-border-l-black before:tw-border-r-transparent`;
|
|
4784
|
-
const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
|
|
4784
|
+
const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
|
|
4785
4785
|
before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
|
|
4786
|
-
const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
|
|
4786
|
+
const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
|
|
4787
4787
|
before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
|
|
4788
4788
|
const placements = {
|
|
4789
4789
|
top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
|
|
@@ -4793,7 +4793,7 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
|
|
|
4793
4793
|
};
|
|
4794
4794
|
return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
|
|
4795
4795
|
children,
|
|
4796
|
-
React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
|
|
4796
|
+
React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
|
|
4797
4797
|
tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
|
|
4798
4798
|
};
|
|
4799
4799
|
|
|
@@ -6325,22 +6325,22 @@ const QTip = () => {
|
|
|
6325
6325
|
React.createElement("div", { className: "tw-absolute tw-w-[10px] tw-h-[10px] tw-rotate-45 tw-bg-black", ref: tooltipArrowRef }))));
|
|
6326
6326
|
};
|
|
6327
6327
|
|
|
6328
|
-
function _typeof(obj) {
|
|
6328
|
+
function _typeof$1(obj) {
|
|
6329
6329
|
"@babel/helpers - typeof";
|
|
6330
6330
|
|
|
6331
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
6331
|
+
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
6332
6332
|
return typeof obj;
|
|
6333
6333
|
} : function (obj) {
|
|
6334
6334
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
6335
|
-
}, _typeof(obj);
|
|
6335
|
+
}, _typeof$1(obj);
|
|
6336
6336
|
}
|
|
6337
6337
|
|
|
6338
6338
|
function _toPrimitive(input, hint) {
|
|
6339
|
-
if (_typeof(input) !== "object" || input === null) return input;
|
|
6339
|
+
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
6340
6340
|
var prim = input[Symbol.toPrimitive];
|
|
6341
6341
|
if (prim !== undefined) {
|
|
6342
6342
|
var res = prim.call(input, hint || "default");
|
|
6343
|
-
if (_typeof(res) !== "object") return res;
|
|
6343
|
+
if (_typeof$1(res) !== "object") return res;
|
|
6344
6344
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
6345
6345
|
}
|
|
6346
6346
|
return (hint === "string" ? String : Number)(input);
|
|
@@ -6348,7 +6348,7 @@ function _toPrimitive(input, hint) {
|
|
|
6348
6348
|
|
|
6349
6349
|
function _toPropertyKey(arg) {
|
|
6350
6350
|
var key = _toPrimitive(arg, "string");
|
|
6351
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
6351
|
+
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
6352
6352
|
}
|
|
6353
6353
|
|
|
6354
6354
|
function _defineProperty(obj, key, value) {
|
|
@@ -6615,7 +6615,7 @@ function _assertThisInitialized(self) {
|
|
|
6615
6615
|
}
|
|
6616
6616
|
|
|
6617
6617
|
function _possibleConstructorReturn(self, call) {
|
|
6618
|
-
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
6618
|
+
if (call && (_typeof$1(call) === "object" || typeof call === "function")) {
|
|
6619
6619
|
return call;
|
|
6620
6620
|
} else if (call !== void 0) {
|
|
6621
6621
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
@@ -9340,7 +9340,7 @@ function classNames$1(prefix, state) {
|
|
|
9340
9340
|
|
|
9341
9341
|
var cleanValue = function cleanValue(value) {
|
|
9342
9342
|
if (isArray(value)) return value.filter(Boolean);
|
|
9343
|
-
if (_typeof(value) === 'object' && value !== null) return [value];
|
|
9343
|
+
if (_typeof$1(value) === 'object' && value !== null) return [value];
|
|
9344
9344
|
return [];
|
|
9345
9345
|
};
|
|
9346
9346
|
|
|
@@ -13781,9 +13781,9 @@ const Dialog = $5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9;
|
|
|
13781
13781
|
const DialogPortal = $5d3850c4d0b4e6c7$export$602eac185826482c;
|
|
13782
13782
|
const DialogClose = $5d3850c4d0b4e6c7$export$f39c2d165cd861fe;
|
|
13783
13783
|
const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => (React.createElement(DialogPortal, null,
|
|
13784
|
-
React.createElement("div", { className: "tw-select-none tw-fixed tw-w-full tw-h-full tw-opacity-50 tw-inset-0 tw-z-[1009] tw-bg-sq-dark-background\
|
|
13785
|
-
React.createElement($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, { ref: ref, className: `tw-fixed tw-left-[50%] tw-top-0 tw-my-6 tw-translate-x-[-50%] tw-z-[1010] tw-grid
|
|
13786
|
-
tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
|
|
13784
|
+
React.createElement("div", { className: "tw-select-none tw-fixed tw-w-full tw-h-full tw-opacity-50 tw-inset-0 tw-z-[1009] tw-bg-sq-dark-background\n data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0\n data-[state=open]:fade-in-0 " }),
|
|
13785
|
+
React.createElement($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, { ref: ref, className: `tw-fixed tw-left-[50%] tw-top-0 tw-my-6 tw-translate-x-[-50%] tw-z-[1010] tw-grid
|
|
13786
|
+
tw-gap-4 tw-border tw-bg-sq-white dark:tw-bg-sq-dark-background tw-p-6 tw-shadow-lg tw-duration-200
|
|
13787
13787
|
tw-rounded-lg ${className}`, ...props }, children))));
|
|
13788
13788
|
DialogContent.displayName = $5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2.displayName;
|
|
13789
13789
|
const DialogHeader = (props) => (React.createElement("div", { className: "tw-w-full tw-justify-between" },
|
|
@@ -13855,7 +13855,7 @@ const Modal = ({ titleIcon, title = 'Modal title example', titleSuffixLabel, sub
|
|
|
13855
13855
|
'tw-max-w-5xl': size === '5xl',
|
|
13856
13856
|
'tw-max-w-6xl': size === '6xl',
|
|
13857
13857
|
}, dialogClassName) },
|
|
13858
|
-
React.createElement(DialogHeader, { className: "modal-header tw-flex tw-w-full tw-justify-between tw-border-sq-disabled-gray\
|
|
13858
|
+
React.createElement(DialogHeader, { className: "modal-header tw-flex tw-w-full tw-justify-between tw-border-sq-disabled-gray\n dark:tw-border-sq-dark-disabled-gray tw-border-0 tw-border-b tw-px-6 tw-py-4" },
|
|
13859
13859
|
React.createElement("div", { className: "tw-flex tw-w-full" }, renderTitle()),
|
|
13860
13860
|
!hideCloseIcon && (React.createElement(DialogClose, { autoFocus: false, className: "[&:has(:focus-visible)]:none tw-opacity-70 tw-bg-transparent hover:tw-opacity-100 close tw-cursor-pointer tw-ml-4", "data-testid": "closeButton" },
|
|
13861
13861
|
React.createElement("span", { className: "tw-cursor-pointer" }, "\u00D7")))),
|
|
@@ -14784,8 +14784,8 @@ const ButtonWithPopover = ({ children, trigger, id, hasArrow, extraTriggerClassN
|
|
|
14784
14784
|
React__namespace.useEffect(() => clearHoverTimeout, []);
|
|
14785
14785
|
const renderContent = () => {
|
|
14786
14786
|
return (React__namespace.createElement($cb5cc270b50c6fcd$export$7c6e2c02157bb7d2, { sideOffset: placementOffset, align: align, side: placement, onInteractOutside: onInteractOutside, onPointerDownOutside: onPointerDownOutside, alignOffset: isHoverEnabled ? -10 : alignOffset, asChild: true, onClick: () => isCloseOnContentClick && onOpenChange && onOpenChange(false), className: "focus-visible:tw-outline-none tw-outline-none tw-w-full tw-h-full" },
|
|
14787
|
-
React__namespace.createElement("div", { "data-testid": containerTestId, className: `${bgStyles$2} ${borderStyles$2} tw-relative tw-z-[1200] tw-min-w-6 focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out
|
|
14788
|
-
data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade tw-text-sq-text-color
|
|
14787
|
+
React__namespace.createElement("div", { "data-testid": containerTestId, className: `${bgStyles$2} ${borderStyles$2} tw-relative tw-z-[1200] tw-min-w-6 focus-visible:tw-outline-none tw-outline-none data-[state=open]:tw-animate-in data-[state=closed]:tw-animate-out
|
|
14788
|
+
data-[side=top]:tw-animate-slideDownAndFade data-[side=right]:tw-animate-slideLeftAndFade data-[side=bottom]:tw-animate-slideUpAndFade data-[side=left]:tw-animate-slideRightAndFade tw-text-sq-text-color
|
|
14789
14789
|
${extraPopoverClassNames || ''}` },
|
|
14790
14790
|
hasArrow && (React__namespace.createElement($cb5cc270b50c6fcd$export$21b07c8f274aebd5, { asChild: true },
|
|
14791
14791
|
React__namespace.createElement("div", { className: "tw-fill-transparent tw-bg-white tw-w-[15px] tw-h-[15px] tw-mt-[-7px] tw-rotate-45 dark:tw-bg-sq-dark-background tw-border-b tw-border-r tw-border-sq-disabled-gray dark:tw-border-gray-500" }))),
|
|
@@ -16526,7 +16526,7 @@ function normalizeColor(color) {
|
|
|
16526
16526
|
) >>> 0;
|
|
16527
16527
|
}
|
|
16528
16528
|
if (match = hsl.exec(color)) {
|
|
16529
|
-
return (hslToRgb(
|
|
16529
|
+
return (hslToRgb$1(
|
|
16530
16530
|
parse360(match[1]),
|
|
16531
16531
|
// h
|
|
16532
16532
|
parsePercentage(match[2]),
|
|
@@ -16537,7 +16537,7 @@ function normalizeColor(color) {
|
|
|
16537
16537
|
0;
|
|
16538
16538
|
}
|
|
16539
16539
|
if (match = hsla.exec(color)) {
|
|
16540
|
-
return (hslToRgb(
|
|
16540
|
+
return (hslToRgb$1(
|
|
16541
16541
|
parse360(match[1]),
|
|
16542
16542
|
// h
|
|
16543
16543
|
parsePercentage(match[2]),
|
|
@@ -16562,7 +16562,7 @@ function hue2rgb(p, q, t) {
|
|
|
16562
16562
|
return p + (q - p) * (2 / 3 - t) * 6;
|
|
16563
16563
|
return p;
|
|
16564
16564
|
}
|
|
16565
|
-
function hslToRgb(h, s, l) {
|
|
16565
|
+
function hslToRgb$1(h, s, l) {
|
|
16566
16566
|
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
16567
16567
|
const p = 2 * l - q;
|
|
16568
16568
|
const r = hue2rgb(p, q, h + 1 / 3);
|
|
@@ -20940,10 +20940,1192 @@ Defaulting to \`null\`.`;
|
|
|
20940
20940
|
var Root = Progress;
|
|
20941
20941
|
var Indicator = ProgressIndicator$1;
|
|
20942
20942
|
|
|
20943
|
+
// This file is autogenerated. It's used to publish ESM to npm.
|
|
20944
|
+
function _typeof(obj) {
|
|
20945
|
+
"@babel/helpers - typeof";
|
|
20946
|
+
|
|
20947
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
20948
|
+
return typeof obj;
|
|
20949
|
+
} : function (obj) {
|
|
20950
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
20951
|
+
}, _typeof(obj);
|
|
20952
|
+
}
|
|
20953
|
+
|
|
20954
|
+
// https://github.com/bgrins/TinyColor
|
|
20955
|
+
// Brian Grinstead, MIT License
|
|
20956
|
+
|
|
20957
|
+
var trimLeft = /^\s+/;
|
|
20958
|
+
var trimRight = /\s+$/;
|
|
20959
|
+
function tinycolor(color, opts) {
|
|
20960
|
+
color = color ? color : "";
|
|
20961
|
+
opts = opts || {};
|
|
20962
|
+
|
|
20963
|
+
// If input is already a tinycolor, return itself
|
|
20964
|
+
if (color instanceof tinycolor) {
|
|
20965
|
+
return color;
|
|
20966
|
+
}
|
|
20967
|
+
// If we are called as a function, call using new instead
|
|
20968
|
+
if (!(this instanceof tinycolor)) {
|
|
20969
|
+
return new tinycolor(color, opts);
|
|
20970
|
+
}
|
|
20971
|
+
var rgb = inputToRGB(color);
|
|
20972
|
+
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 = opts.format || rgb.format;
|
|
20973
|
+
this._gradientType = opts.gradientType;
|
|
20974
|
+
|
|
20975
|
+
// Don't let the range of [0,255] come back in [0,1].
|
|
20976
|
+
// Potentially lose a little bit of precision here, but will fix issues where
|
|
20977
|
+
// .5 gets interpreted as half of the total, instead of half of 1
|
|
20978
|
+
// If it was supposed to be 128, this was already taken care of by `inputToRgb`
|
|
20979
|
+
if (this._r < 1) this._r = Math.round(this._r);
|
|
20980
|
+
if (this._g < 1) this._g = Math.round(this._g);
|
|
20981
|
+
if (this._b < 1) this._b = Math.round(this._b);
|
|
20982
|
+
this._ok = rgb.ok;
|
|
20983
|
+
}
|
|
20984
|
+
tinycolor.prototype = {
|
|
20985
|
+
isDark: function isDark() {
|
|
20986
|
+
return this.getBrightness() < 128;
|
|
20987
|
+
},
|
|
20988
|
+
isLight: function isLight() {
|
|
20989
|
+
return !this.isDark();
|
|
20990
|
+
},
|
|
20991
|
+
isValid: function isValid() {
|
|
20992
|
+
return this._ok;
|
|
20993
|
+
},
|
|
20994
|
+
getOriginalInput: function getOriginalInput() {
|
|
20995
|
+
return this._originalInput;
|
|
20996
|
+
},
|
|
20997
|
+
getFormat: function getFormat() {
|
|
20998
|
+
return this._format;
|
|
20999
|
+
},
|
|
21000
|
+
getAlpha: function getAlpha() {
|
|
21001
|
+
return this._a;
|
|
21002
|
+
},
|
|
21003
|
+
getBrightness: function getBrightness() {
|
|
21004
|
+
//http://www.w3.org/TR/AERT#color-contrast
|
|
21005
|
+
var rgb = this.toRgb();
|
|
21006
|
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
21007
|
+
},
|
|
21008
|
+
getLuminance: function getLuminance() {
|
|
21009
|
+
//http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
21010
|
+
var rgb = this.toRgb();
|
|
21011
|
+
var RsRGB, GsRGB, BsRGB, R, G, B;
|
|
21012
|
+
RsRGB = rgb.r / 255;
|
|
21013
|
+
GsRGB = rgb.g / 255;
|
|
21014
|
+
BsRGB = rgb.b / 255;
|
|
21015
|
+
if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
|
|
21016
|
+
if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
|
|
21017
|
+
if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
|
|
21018
|
+
return 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
21019
|
+
},
|
|
21020
|
+
setAlpha: function setAlpha(value) {
|
|
21021
|
+
this._a = boundAlpha(value);
|
|
21022
|
+
this._roundA = Math.round(100 * this._a) / 100;
|
|
21023
|
+
return this;
|
|
21024
|
+
},
|
|
21025
|
+
toHsv: function toHsv() {
|
|
21026
|
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
|
21027
|
+
return {
|
|
21028
|
+
h: hsv.h * 360,
|
|
21029
|
+
s: hsv.s,
|
|
21030
|
+
v: hsv.v,
|
|
21031
|
+
a: this._a
|
|
21032
|
+
};
|
|
21033
|
+
},
|
|
21034
|
+
toHsvString: function toHsvString() {
|
|
21035
|
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
|
21036
|
+
var h = Math.round(hsv.h * 360),
|
|
21037
|
+
s = Math.round(hsv.s * 100),
|
|
21038
|
+
v = Math.round(hsv.v * 100);
|
|
21039
|
+
return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
|
|
21040
|
+
},
|
|
21041
|
+
toHsl: function toHsl() {
|
|
21042
|
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
|
21043
|
+
return {
|
|
21044
|
+
h: hsl.h * 360,
|
|
21045
|
+
s: hsl.s,
|
|
21046
|
+
l: hsl.l,
|
|
21047
|
+
a: this._a
|
|
21048
|
+
};
|
|
21049
|
+
},
|
|
21050
|
+
toHslString: function toHslString() {
|
|
21051
|
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
|
21052
|
+
var h = Math.round(hsl.h * 360),
|
|
21053
|
+
s = Math.round(hsl.s * 100),
|
|
21054
|
+
l = Math.round(hsl.l * 100);
|
|
21055
|
+
return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
|
|
21056
|
+
},
|
|
21057
|
+
toHex: function toHex(allow3Char) {
|
|
21058
|
+
return rgbToHex(this._r, this._g, this._b, allow3Char);
|
|
21059
|
+
},
|
|
21060
|
+
toHexString: function toHexString(allow3Char) {
|
|
21061
|
+
return "#" + this.toHex(allow3Char);
|
|
21062
|
+
},
|
|
21063
|
+
toHex8: function toHex8(allow4Char) {
|
|
21064
|
+
return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
|
|
21065
|
+
},
|
|
21066
|
+
toHex8String: function toHex8String(allow4Char) {
|
|
21067
|
+
return "#" + this.toHex8(allow4Char);
|
|
21068
|
+
},
|
|
21069
|
+
toRgb: function toRgb() {
|
|
21070
|
+
return {
|
|
21071
|
+
r: Math.round(this._r),
|
|
21072
|
+
g: Math.round(this._g),
|
|
21073
|
+
b: Math.round(this._b),
|
|
21074
|
+
a: this._a
|
|
21075
|
+
};
|
|
21076
|
+
},
|
|
21077
|
+
toRgbString: function toRgbString() {
|
|
21078
|
+
return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
|
|
21079
|
+
},
|
|
21080
|
+
toPercentageRgb: function toPercentageRgb() {
|
|
21081
|
+
return {
|
|
21082
|
+
r: Math.round(bound01(this._r, 255) * 100) + "%",
|
|
21083
|
+
g: Math.round(bound01(this._g, 255) * 100) + "%",
|
|
21084
|
+
b: Math.round(bound01(this._b, 255) * 100) + "%",
|
|
21085
|
+
a: this._a
|
|
21086
|
+
};
|
|
21087
|
+
},
|
|
21088
|
+
toPercentageRgbString: function toPercentageRgbString() {
|
|
21089
|
+
return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
|
|
21090
|
+
},
|
|
21091
|
+
toName: function toName() {
|
|
21092
|
+
if (this._a === 0) {
|
|
21093
|
+
return "transparent";
|
|
21094
|
+
}
|
|
21095
|
+
if (this._a < 1) {
|
|
21096
|
+
return false;
|
|
21097
|
+
}
|
|
21098
|
+
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
|
|
21099
|
+
},
|
|
21100
|
+
toFilter: function toFilter(secondColor) {
|
|
21101
|
+
var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
|
|
21102
|
+
var secondHex8String = hex8String;
|
|
21103
|
+
var gradientType = this._gradientType ? "GradientType = 1, " : "";
|
|
21104
|
+
if (secondColor) {
|
|
21105
|
+
var s = tinycolor(secondColor);
|
|
21106
|
+
secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
|
|
21107
|
+
}
|
|
21108
|
+
return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
|
|
21109
|
+
},
|
|
21110
|
+
toString: function toString(format) {
|
|
21111
|
+
var formatSet = !!format;
|
|
21112
|
+
format = format || this._format;
|
|
21113
|
+
var formattedString = false;
|
|
21114
|
+
var hasAlpha = this._a < 1 && this._a >= 0;
|
|
21115
|
+
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
|
|
21116
|
+
if (needsAlphaFormat) {
|
|
21117
|
+
// Special case for "transparent", all other non-alpha formats
|
|
21118
|
+
// will return rgba when there is transparency.
|
|
21119
|
+
if (format === "name" && this._a === 0) {
|
|
21120
|
+
return this.toName();
|
|
21121
|
+
}
|
|
21122
|
+
return this.toRgbString();
|
|
21123
|
+
}
|
|
21124
|
+
if (format === "rgb") {
|
|
21125
|
+
formattedString = this.toRgbString();
|
|
21126
|
+
}
|
|
21127
|
+
if (format === "prgb") {
|
|
21128
|
+
formattedString = this.toPercentageRgbString();
|
|
21129
|
+
}
|
|
21130
|
+
if (format === "hex" || format === "hex6") {
|
|
21131
|
+
formattedString = this.toHexString();
|
|
21132
|
+
}
|
|
21133
|
+
if (format === "hex3") {
|
|
21134
|
+
formattedString = this.toHexString(true);
|
|
21135
|
+
}
|
|
21136
|
+
if (format === "hex4") {
|
|
21137
|
+
formattedString = this.toHex8String(true);
|
|
21138
|
+
}
|
|
21139
|
+
if (format === "hex8") {
|
|
21140
|
+
formattedString = this.toHex8String();
|
|
21141
|
+
}
|
|
21142
|
+
if (format === "name") {
|
|
21143
|
+
formattedString = this.toName();
|
|
21144
|
+
}
|
|
21145
|
+
if (format === "hsl") {
|
|
21146
|
+
formattedString = this.toHslString();
|
|
21147
|
+
}
|
|
21148
|
+
if (format === "hsv") {
|
|
21149
|
+
formattedString = this.toHsvString();
|
|
21150
|
+
}
|
|
21151
|
+
return formattedString || this.toHexString();
|
|
21152
|
+
},
|
|
21153
|
+
clone: function clone() {
|
|
21154
|
+
return tinycolor(this.toString());
|
|
21155
|
+
},
|
|
21156
|
+
_applyModification: function _applyModification(fn, args) {
|
|
21157
|
+
var color = fn.apply(null, [this].concat([].slice.call(args)));
|
|
21158
|
+
this._r = color._r;
|
|
21159
|
+
this._g = color._g;
|
|
21160
|
+
this._b = color._b;
|
|
21161
|
+
this.setAlpha(color._a);
|
|
21162
|
+
return this;
|
|
21163
|
+
},
|
|
21164
|
+
lighten: function lighten() {
|
|
21165
|
+
return this._applyModification(_lighten, arguments);
|
|
21166
|
+
},
|
|
21167
|
+
brighten: function brighten() {
|
|
21168
|
+
return this._applyModification(_brighten, arguments);
|
|
21169
|
+
},
|
|
21170
|
+
darken: function darken() {
|
|
21171
|
+
return this._applyModification(_darken, arguments);
|
|
21172
|
+
},
|
|
21173
|
+
desaturate: function desaturate() {
|
|
21174
|
+
return this._applyModification(_desaturate, arguments);
|
|
21175
|
+
},
|
|
21176
|
+
saturate: function saturate() {
|
|
21177
|
+
return this._applyModification(_saturate, arguments);
|
|
21178
|
+
},
|
|
21179
|
+
greyscale: function greyscale() {
|
|
21180
|
+
return this._applyModification(_greyscale, arguments);
|
|
21181
|
+
},
|
|
21182
|
+
spin: function spin() {
|
|
21183
|
+
return this._applyModification(_spin, arguments);
|
|
21184
|
+
},
|
|
21185
|
+
_applyCombination: function _applyCombination(fn, args) {
|
|
21186
|
+
return fn.apply(null, [this].concat([].slice.call(args)));
|
|
21187
|
+
},
|
|
21188
|
+
analogous: function analogous() {
|
|
21189
|
+
return this._applyCombination(_analogous, arguments);
|
|
21190
|
+
},
|
|
21191
|
+
complement: function complement() {
|
|
21192
|
+
return this._applyCombination(_complement, arguments);
|
|
21193
|
+
},
|
|
21194
|
+
monochromatic: function monochromatic() {
|
|
21195
|
+
return this._applyCombination(_monochromatic, arguments);
|
|
21196
|
+
},
|
|
21197
|
+
splitcomplement: function splitcomplement() {
|
|
21198
|
+
return this._applyCombination(_splitcomplement, arguments);
|
|
21199
|
+
},
|
|
21200
|
+
// Disabled until https://github.com/bgrins/TinyColor/issues/254
|
|
21201
|
+
// polyad: function (number) {
|
|
21202
|
+
// return this._applyCombination(polyad, [number]);
|
|
21203
|
+
// },
|
|
21204
|
+
triad: function triad() {
|
|
21205
|
+
return this._applyCombination(polyad, [3]);
|
|
21206
|
+
},
|
|
21207
|
+
tetrad: function tetrad() {
|
|
21208
|
+
return this._applyCombination(polyad, [4]);
|
|
21209
|
+
}
|
|
21210
|
+
};
|
|
21211
|
+
|
|
21212
|
+
// If input is an object, force 1 into "1.0" to handle ratios properly
|
|
21213
|
+
// String input requires "1.0" as input, so 1 will be treated as 1
|
|
21214
|
+
tinycolor.fromRatio = function (color, opts) {
|
|
21215
|
+
if (_typeof(color) == "object") {
|
|
21216
|
+
var newColor = {};
|
|
21217
|
+
for (var i in color) {
|
|
21218
|
+
if (color.hasOwnProperty(i)) {
|
|
21219
|
+
if (i === "a") {
|
|
21220
|
+
newColor[i] = color[i];
|
|
21221
|
+
} else {
|
|
21222
|
+
newColor[i] = convertToPercentage(color[i]);
|
|
21223
|
+
}
|
|
21224
|
+
}
|
|
21225
|
+
}
|
|
21226
|
+
color = newColor;
|
|
21227
|
+
}
|
|
21228
|
+
return tinycolor(color, opts);
|
|
21229
|
+
};
|
|
21230
|
+
|
|
21231
|
+
// Given a string or object, convert that input to RGB
|
|
21232
|
+
// Possible string inputs:
|
|
21233
|
+
//
|
|
21234
|
+
// "red"
|
|
21235
|
+
// "#f00" or "f00"
|
|
21236
|
+
// "#ff0000" or "ff0000"
|
|
21237
|
+
// "#ff000000" or "ff000000"
|
|
21238
|
+
// "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
21239
|
+
// "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
21240
|
+
// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
21241
|
+
// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
21242
|
+
// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
21243
|
+
// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
21244
|
+
// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
21245
|
+
//
|
|
21246
|
+
function inputToRGB(color) {
|
|
21247
|
+
var rgb = {
|
|
21248
|
+
r: 0,
|
|
21249
|
+
g: 0,
|
|
21250
|
+
b: 0
|
|
21251
|
+
};
|
|
21252
|
+
var a = 1;
|
|
21253
|
+
var s = null;
|
|
21254
|
+
var v = null;
|
|
21255
|
+
var l = null;
|
|
21256
|
+
var ok = false;
|
|
21257
|
+
var format = false;
|
|
21258
|
+
if (typeof color == "string") {
|
|
21259
|
+
color = stringInputToObject(color);
|
|
21260
|
+
}
|
|
21261
|
+
if (_typeof(color) == "object") {
|
|
21262
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
21263
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
21264
|
+
ok = true;
|
|
21265
|
+
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
|
21266
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
21267
|
+
s = convertToPercentage(color.s);
|
|
21268
|
+
v = convertToPercentage(color.v);
|
|
21269
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
21270
|
+
ok = true;
|
|
21271
|
+
format = "hsv";
|
|
21272
|
+
} else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
21273
|
+
s = convertToPercentage(color.s);
|
|
21274
|
+
l = convertToPercentage(color.l);
|
|
21275
|
+
rgb = hslToRgb(color.h, s, l);
|
|
21276
|
+
ok = true;
|
|
21277
|
+
format = "hsl";
|
|
21278
|
+
}
|
|
21279
|
+
if (color.hasOwnProperty("a")) {
|
|
21280
|
+
a = color.a;
|
|
21281
|
+
}
|
|
21282
|
+
}
|
|
21283
|
+
a = boundAlpha(a);
|
|
21284
|
+
return {
|
|
21285
|
+
ok: ok,
|
|
21286
|
+
format: color.format || format,
|
|
21287
|
+
r: Math.min(255, Math.max(rgb.r, 0)),
|
|
21288
|
+
g: Math.min(255, Math.max(rgb.g, 0)),
|
|
21289
|
+
b: Math.min(255, Math.max(rgb.b, 0)),
|
|
21290
|
+
a: a
|
|
21291
|
+
};
|
|
21292
|
+
}
|
|
21293
|
+
|
|
21294
|
+
// Conversion Functions
|
|
21295
|
+
// --------------------
|
|
21296
|
+
|
|
21297
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
21298
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
21299
|
+
|
|
21300
|
+
// `rgbToRgb`
|
|
21301
|
+
// Handle bounds / percentage checking to conform to CSS color spec
|
|
21302
|
+
// <http://www.w3.org/TR/css3-color/>
|
|
21303
|
+
// *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
21304
|
+
// *Returns:* { r, g, b } in [0, 255]
|
|
21305
|
+
function rgbToRgb(r, g, b) {
|
|
21306
|
+
return {
|
|
21307
|
+
r: bound01(r, 255) * 255,
|
|
21308
|
+
g: bound01(g, 255) * 255,
|
|
21309
|
+
b: bound01(b, 255) * 255
|
|
21310
|
+
};
|
|
21311
|
+
}
|
|
21312
|
+
|
|
21313
|
+
// `rgbToHsl`
|
|
21314
|
+
// Converts an RGB color value to HSL.
|
|
21315
|
+
// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
21316
|
+
// *Returns:* { h, s, l } in [0,1]
|
|
21317
|
+
function rgbToHsl(r, g, b) {
|
|
21318
|
+
r = bound01(r, 255);
|
|
21319
|
+
g = bound01(g, 255);
|
|
21320
|
+
b = bound01(b, 255);
|
|
21321
|
+
var max = Math.max(r, g, b),
|
|
21322
|
+
min = Math.min(r, g, b);
|
|
21323
|
+
var h,
|
|
21324
|
+
s,
|
|
21325
|
+
l = (max + min) / 2;
|
|
21326
|
+
if (max == min) {
|
|
21327
|
+
h = s = 0; // achromatic
|
|
21328
|
+
} else {
|
|
21329
|
+
var d = max - min;
|
|
21330
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
21331
|
+
switch (max) {
|
|
21332
|
+
case r:
|
|
21333
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
21334
|
+
break;
|
|
21335
|
+
case g:
|
|
21336
|
+
h = (b - r) / d + 2;
|
|
21337
|
+
break;
|
|
21338
|
+
case b:
|
|
21339
|
+
h = (r - g) / d + 4;
|
|
21340
|
+
break;
|
|
21341
|
+
}
|
|
21342
|
+
h /= 6;
|
|
21343
|
+
}
|
|
21344
|
+
return {
|
|
21345
|
+
h: h,
|
|
21346
|
+
s: s,
|
|
21347
|
+
l: l
|
|
21348
|
+
};
|
|
21349
|
+
}
|
|
21350
|
+
|
|
21351
|
+
// `hslToRgb`
|
|
21352
|
+
// Converts an HSL color value to RGB.
|
|
21353
|
+
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
21354
|
+
// *Returns:* { r, g, b } in the set [0, 255]
|
|
21355
|
+
function hslToRgb(h, s, l) {
|
|
21356
|
+
var r, g, b;
|
|
21357
|
+
h = bound01(h, 360);
|
|
21358
|
+
s = bound01(s, 100);
|
|
21359
|
+
l = bound01(l, 100);
|
|
21360
|
+
function hue2rgb(p, q, t) {
|
|
21361
|
+
if (t < 0) t += 1;
|
|
21362
|
+
if (t > 1) t -= 1;
|
|
21363
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
21364
|
+
if (t < 1 / 2) return q;
|
|
21365
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
21366
|
+
return p;
|
|
21367
|
+
}
|
|
21368
|
+
if (s === 0) {
|
|
21369
|
+
r = g = b = l; // achromatic
|
|
21370
|
+
} else {
|
|
21371
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
21372
|
+
var p = 2 * l - q;
|
|
21373
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
21374
|
+
g = hue2rgb(p, q, h);
|
|
21375
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
21376
|
+
}
|
|
21377
|
+
return {
|
|
21378
|
+
r: r * 255,
|
|
21379
|
+
g: g * 255,
|
|
21380
|
+
b: b * 255
|
|
21381
|
+
};
|
|
21382
|
+
}
|
|
21383
|
+
|
|
21384
|
+
// `rgbToHsv`
|
|
21385
|
+
// Converts an RGB color value to HSV
|
|
21386
|
+
// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
21387
|
+
// *Returns:* { h, s, v } in [0,1]
|
|
21388
|
+
function rgbToHsv(r, g, b) {
|
|
21389
|
+
r = bound01(r, 255);
|
|
21390
|
+
g = bound01(g, 255);
|
|
21391
|
+
b = bound01(b, 255);
|
|
21392
|
+
var max = Math.max(r, g, b),
|
|
21393
|
+
min = Math.min(r, g, b);
|
|
21394
|
+
var h,
|
|
21395
|
+
s,
|
|
21396
|
+
v = max;
|
|
21397
|
+
var d = max - min;
|
|
21398
|
+
s = max === 0 ? 0 : d / max;
|
|
21399
|
+
if (max == min) {
|
|
21400
|
+
h = 0; // achromatic
|
|
21401
|
+
} else {
|
|
21402
|
+
switch (max) {
|
|
21403
|
+
case r:
|
|
21404
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
21405
|
+
break;
|
|
21406
|
+
case g:
|
|
21407
|
+
h = (b - r) / d + 2;
|
|
21408
|
+
break;
|
|
21409
|
+
case b:
|
|
21410
|
+
h = (r - g) / d + 4;
|
|
21411
|
+
break;
|
|
21412
|
+
}
|
|
21413
|
+
h /= 6;
|
|
21414
|
+
}
|
|
21415
|
+
return {
|
|
21416
|
+
h: h,
|
|
21417
|
+
s: s,
|
|
21418
|
+
v: v
|
|
21419
|
+
};
|
|
21420
|
+
}
|
|
21421
|
+
|
|
21422
|
+
// `hsvToRgb`
|
|
21423
|
+
// Converts an HSV color value to RGB.
|
|
21424
|
+
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
21425
|
+
// *Returns:* { r, g, b } in the set [0, 255]
|
|
21426
|
+
function hsvToRgb(h, s, v) {
|
|
21427
|
+
h = bound01(h, 360) * 6;
|
|
21428
|
+
s = bound01(s, 100);
|
|
21429
|
+
v = bound01(v, 100);
|
|
21430
|
+
var i = Math.floor(h),
|
|
21431
|
+
f = h - i,
|
|
21432
|
+
p = v * (1 - s),
|
|
21433
|
+
q = v * (1 - f * s),
|
|
21434
|
+
t = v * (1 - (1 - f) * s),
|
|
21435
|
+
mod = i % 6,
|
|
21436
|
+
r = [v, q, p, p, t, v][mod],
|
|
21437
|
+
g = [t, v, v, q, p, p][mod],
|
|
21438
|
+
b = [p, p, t, v, v, q][mod];
|
|
21439
|
+
return {
|
|
21440
|
+
r: r * 255,
|
|
21441
|
+
g: g * 255,
|
|
21442
|
+
b: b * 255
|
|
21443
|
+
};
|
|
21444
|
+
}
|
|
21445
|
+
|
|
21446
|
+
// `rgbToHex`
|
|
21447
|
+
// Converts an RGB color to hex
|
|
21448
|
+
// Assumes r, g, and b are contained in the set [0, 255]
|
|
21449
|
+
// Returns a 3 or 6 character hex
|
|
21450
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
21451
|
+
var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
|
|
21452
|
+
|
|
21453
|
+
// Return a 3 character hex if possible
|
|
21454
|
+
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
|
|
21455
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
21456
|
+
}
|
|
21457
|
+
return hex.join("");
|
|
21458
|
+
}
|
|
21459
|
+
|
|
21460
|
+
// `rgbaToHex`
|
|
21461
|
+
// Converts an RGBA color plus alpha transparency to hex
|
|
21462
|
+
// Assumes r, g, b are contained in the set [0, 255] and
|
|
21463
|
+
// a in [0, 1]. Returns a 4 or 8 character rgba hex
|
|
21464
|
+
function rgbaToHex(r, g, b, a, allow4Char) {
|
|
21465
|
+
var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
|
|
21466
|
+
|
|
21467
|
+
// Return a 4 character hex if possible
|
|
21468
|
+
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
|
|
21469
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
21470
|
+
}
|
|
21471
|
+
return hex.join("");
|
|
21472
|
+
}
|
|
21473
|
+
|
|
21474
|
+
// `rgbaToArgbHex`
|
|
21475
|
+
// Converts an RGBA color to an ARGB Hex8 string
|
|
21476
|
+
// Rarely used, but required for "toFilter()"
|
|
21477
|
+
function rgbaToArgbHex(r, g, b, a) {
|
|
21478
|
+
var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
|
|
21479
|
+
return hex.join("");
|
|
21480
|
+
}
|
|
21481
|
+
|
|
21482
|
+
// `equals`
|
|
21483
|
+
// Can be called with any tinycolor input
|
|
21484
|
+
tinycolor.equals = function (color1, color2) {
|
|
21485
|
+
if (!color1 || !color2) return false;
|
|
21486
|
+
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
|
|
21487
|
+
};
|
|
21488
|
+
tinycolor.random = function () {
|
|
21489
|
+
return tinycolor.fromRatio({
|
|
21490
|
+
r: Math.random(),
|
|
21491
|
+
g: Math.random(),
|
|
21492
|
+
b: Math.random()
|
|
21493
|
+
});
|
|
21494
|
+
};
|
|
21495
|
+
|
|
21496
|
+
// Modification Functions
|
|
21497
|
+
// ----------------------
|
|
21498
|
+
// Thanks to less.js for some of the basics here
|
|
21499
|
+
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
|
|
21500
|
+
|
|
21501
|
+
function _desaturate(color, amount) {
|
|
21502
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
21503
|
+
var hsl = tinycolor(color).toHsl();
|
|
21504
|
+
hsl.s -= amount / 100;
|
|
21505
|
+
hsl.s = clamp01(hsl.s);
|
|
21506
|
+
return tinycolor(hsl);
|
|
21507
|
+
}
|
|
21508
|
+
function _saturate(color, amount) {
|
|
21509
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
21510
|
+
var hsl = tinycolor(color).toHsl();
|
|
21511
|
+
hsl.s += amount / 100;
|
|
21512
|
+
hsl.s = clamp01(hsl.s);
|
|
21513
|
+
return tinycolor(hsl);
|
|
21514
|
+
}
|
|
21515
|
+
function _greyscale(color) {
|
|
21516
|
+
return tinycolor(color).desaturate(100);
|
|
21517
|
+
}
|
|
21518
|
+
function _lighten(color, amount) {
|
|
21519
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
21520
|
+
var hsl = tinycolor(color).toHsl();
|
|
21521
|
+
hsl.l += amount / 100;
|
|
21522
|
+
hsl.l = clamp01(hsl.l);
|
|
21523
|
+
return tinycolor(hsl);
|
|
21524
|
+
}
|
|
21525
|
+
function _brighten(color, amount) {
|
|
21526
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
21527
|
+
var rgb = tinycolor(color).toRgb();
|
|
21528
|
+
rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
|
|
21529
|
+
rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
|
|
21530
|
+
rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
|
|
21531
|
+
return tinycolor(rgb);
|
|
21532
|
+
}
|
|
21533
|
+
function _darken(color, amount) {
|
|
21534
|
+
amount = amount === 0 ? 0 : amount || 10;
|
|
21535
|
+
var hsl = tinycolor(color).toHsl();
|
|
21536
|
+
hsl.l -= amount / 100;
|
|
21537
|
+
hsl.l = clamp01(hsl.l);
|
|
21538
|
+
return tinycolor(hsl);
|
|
21539
|
+
}
|
|
21540
|
+
|
|
21541
|
+
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
|
21542
|
+
// Values outside of this range will be wrapped into this range.
|
|
21543
|
+
function _spin(color, amount) {
|
|
21544
|
+
var hsl = tinycolor(color).toHsl();
|
|
21545
|
+
var hue = (hsl.h + amount) % 360;
|
|
21546
|
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
|
21547
|
+
return tinycolor(hsl);
|
|
21548
|
+
}
|
|
21549
|
+
|
|
21550
|
+
// Combination Functions
|
|
21551
|
+
// ---------------------
|
|
21552
|
+
// Thanks to jQuery xColor for some of the ideas behind these
|
|
21553
|
+
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
|
|
21554
|
+
|
|
21555
|
+
function _complement(color) {
|
|
21556
|
+
var hsl = tinycolor(color).toHsl();
|
|
21557
|
+
hsl.h = (hsl.h + 180) % 360;
|
|
21558
|
+
return tinycolor(hsl);
|
|
21559
|
+
}
|
|
21560
|
+
function polyad(color, number) {
|
|
21561
|
+
if (isNaN(number) || number <= 0) {
|
|
21562
|
+
throw new Error("Argument to polyad must be a positive number");
|
|
21563
|
+
}
|
|
21564
|
+
var hsl = tinycolor(color).toHsl();
|
|
21565
|
+
var result = [tinycolor(color)];
|
|
21566
|
+
var step = 360 / number;
|
|
21567
|
+
for (var i = 1; i < number; i++) {
|
|
21568
|
+
result.push(tinycolor({
|
|
21569
|
+
h: (hsl.h + i * step) % 360,
|
|
21570
|
+
s: hsl.s,
|
|
21571
|
+
l: hsl.l
|
|
21572
|
+
}));
|
|
21573
|
+
}
|
|
21574
|
+
return result;
|
|
21575
|
+
}
|
|
21576
|
+
function _splitcomplement(color) {
|
|
21577
|
+
var hsl = tinycolor(color).toHsl();
|
|
21578
|
+
var h = hsl.h;
|
|
21579
|
+
return [tinycolor(color), tinycolor({
|
|
21580
|
+
h: (h + 72) % 360,
|
|
21581
|
+
s: hsl.s,
|
|
21582
|
+
l: hsl.l
|
|
21583
|
+
}), tinycolor({
|
|
21584
|
+
h: (h + 216) % 360,
|
|
21585
|
+
s: hsl.s,
|
|
21586
|
+
l: hsl.l
|
|
21587
|
+
})];
|
|
21588
|
+
}
|
|
21589
|
+
function _analogous(color, results, slices) {
|
|
21590
|
+
results = results || 6;
|
|
21591
|
+
slices = slices || 30;
|
|
21592
|
+
var hsl = tinycolor(color).toHsl();
|
|
21593
|
+
var part = 360 / slices;
|
|
21594
|
+
var ret = [tinycolor(color)];
|
|
21595
|
+
for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
|
|
21596
|
+
hsl.h = (hsl.h + part) % 360;
|
|
21597
|
+
ret.push(tinycolor(hsl));
|
|
21598
|
+
}
|
|
21599
|
+
return ret;
|
|
21600
|
+
}
|
|
21601
|
+
function _monochromatic(color, results) {
|
|
21602
|
+
results = results || 6;
|
|
21603
|
+
var hsv = tinycolor(color).toHsv();
|
|
21604
|
+
var h = hsv.h,
|
|
21605
|
+
s = hsv.s,
|
|
21606
|
+
v = hsv.v;
|
|
21607
|
+
var ret = [];
|
|
21608
|
+
var modification = 1 / results;
|
|
21609
|
+
while (results--) {
|
|
21610
|
+
ret.push(tinycolor({
|
|
21611
|
+
h: h,
|
|
21612
|
+
s: s,
|
|
21613
|
+
v: v
|
|
21614
|
+
}));
|
|
21615
|
+
v = (v + modification) % 1;
|
|
21616
|
+
}
|
|
21617
|
+
return ret;
|
|
21618
|
+
}
|
|
21619
|
+
|
|
21620
|
+
// Utility Functions
|
|
21621
|
+
// ---------------------
|
|
21622
|
+
|
|
21623
|
+
tinycolor.mix = function (color1, color2, amount) {
|
|
21624
|
+
amount = amount === 0 ? 0 : amount || 50;
|
|
21625
|
+
var rgb1 = tinycolor(color1).toRgb();
|
|
21626
|
+
var rgb2 = tinycolor(color2).toRgb();
|
|
21627
|
+
var p = amount / 100;
|
|
21628
|
+
var rgba = {
|
|
21629
|
+
r: (rgb2.r - rgb1.r) * p + rgb1.r,
|
|
21630
|
+
g: (rgb2.g - rgb1.g) * p + rgb1.g,
|
|
21631
|
+
b: (rgb2.b - rgb1.b) * p + rgb1.b,
|
|
21632
|
+
a: (rgb2.a - rgb1.a) * p + rgb1.a
|
|
21633
|
+
};
|
|
21634
|
+
return tinycolor(rgba);
|
|
21635
|
+
};
|
|
21636
|
+
|
|
21637
|
+
// Readability Functions
|
|
21638
|
+
// ---------------------
|
|
21639
|
+
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
|
|
21640
|
+
|
|
21641
|
+
// `contrast`
|
|
21642
|
+
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
|
|
21643
|
+
tinycolor.readability = function (color1, color2) {
|
|
21644
|
+
var c1 = tinycolor(color1);
|
|
21645
|
+
var c2 = tinycolor(color2);
|
|
21646
|
+
return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
|
|
21647
|
+
};
|
|
21648
|
+
|
|
21649
|
+
// `isReadable`
|
|
21650
|
+
// Ensure that foreground and background color combinations meet WCAG2 guidelines.
|
|
21651
|
+
// The third argument is an optional Object.
|
|
21652
|
+
// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
|
|
21653
|
+
// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
|
|
21654
|
+
// If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
|
|
21655
|
+
|
|
21656
|
+
// *Example*
|
|
21657
|
+
// tinycolor.isReadable("#000", "#111") => false
|
|
21658
|
+
// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
|
|
21659
|
+
tinycolor.isReadable = function (color1, color2, wcag2) {
|
|
21660
|
+
var readability = tinycolor.readability(color1, color2);
|
|
21661
|
+
var wcag2Parms, out;
|
|
21662
|
+
out = false;
|
|
21663
|
+
wcag2Parms = validateWCAG2Parms(wcag2);
|
|
21664
|
+
switch (wcag2Parms.level + wcag2Parms.size) {
|
|
21665
|
+
case "AAsmall":
|
|
21666
|
+
case "AAAlarge":
|
|
21667
|
+
out = readability >= 4.5;
|
|
21668
|
+
break;
|
|
21669
|
+
case "AAlarge":
|
|
21670
|
+
out = readability >= 3;
|
|
21671
|
+
break;
|
|
21672
|
+
case "AAAsmall":
|
|
21673
|
+
out = readability >= 7;
|
|
21674
|
+
break;
|
|
21675
|
+
}
|
|
21676
|
+
return out;
|
|
21677
|
+
};
|
|
21678
|
+
|
|
21679
|
+
// `mostReadable`
|
|
21680
|
+
// Given a base color and a list of possible foreground or background
|
|
21681
|
+
// colors for that base, returns the most readable color.
|
|
21682
|
+
// Optionally returns Black or White if the most readable color is unreadable.
|
|
21683
|
+
// *Example*
|
|
21684
|
+
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
|
|
21685
|
+
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
|
|
21686
|
+
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
|
|
21687
|
+
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
|
|
21688
|
+
tinycolor.mostReadable = function (baseColor, colorList, args) {
|
|
21689
|
+
var bestColor = null;
|
|
21690
|
+
var bestScore = 0;
|
|
21691
|
+
var readability;
|
|
21692
|
+
var includeFallbackColors, level, size;
|
|
21693
|
+
args = args || {};
|
|
21694
|
+
includeFallbackColors = args.includeFallbackColors;
|
|
21695
|
+
level = args.level;
|
|
21696
|
+
size = args.size;
|
|
21697
|
+
for (var i = 0; i < colorList.length; i++) {
|
|
21698
|
+
readability = tinycolor.readability(baseColor, colorList[i]);
|
|
21699
|
+
if (readability > bestScore) {
|
|
21700
|
+
bestScore = readability;
|
|
21701
|
+
bestColor = tinycolor(colorList[i]);
|
|
21702
|
+
}
|
|
21703
|
+
}
|
|
21704
|
+
if (tinycolor.isReadable(baseColor, bestColor, {
|
|
21705
|
+
level: level,
|
|
21706
|
+
size: size
|
|
21707
|
+
}) || !includeFallbackColors) {
|
|
21708
|
+
return bestColor;
|
|
21709
|
+
} else {
|
|
21710
|
+
args.includeFallbackColors = false;
|
|
21711
|
+
return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
|
|
21712
|
+
}
|
|
21713
|
+
};
|
|
21714
|
+
|
|
21715
|
+
// Big List of Colors
|
|
21716
|
+
// ------------------
|
|
21717
|
+
// <https://www.w3.org/TR/css-color-4/#named-colors>
|
|
21718
|
+
var names = tinycolor.names = {
|
|
21719
|
+
aliceblue: "f0f8ff",
|
|
21720
|
+
antiquewhite: "faebd7",
|
|
21721
|
+
aqua: "0ff",
|
|
21722
|
+
aquamarine: "7fffd4",
|
|
21723
|
+
azure: "f0ffff",
|
|
21724
|
+
beige: "f5f5dc",
|
|
21725
|
+
bisque: "ffe4c4",
|
|
21726
|
+
black: "000",
|
|
21727
|
+
blanchedalmond: "ffebcd",
|
|
21728
|
+
blue: "00f",
|
|
21729
|
+
blueviolet: "8a2be2",
|
|
21730
|
+
brown: "a52a2a",
|
|
21731
|
+
burlywood: "deb887",
|
|
21732
|
+
burntsienna: "ea7e5d",
|
|
21733
|
+
cadetblue: "5f9ea0",
|
|
21734
|
+
chartreuse: "7fff00",
|
|
21735
|
+
chocolate: "d2691e",
|
|
21736
|
+
coral: "ff7f50",
|
|
21737
|
+
cornflowerblue: "6495ed",
|
|
21738
|
+
cornsilk: "fff8dc",
|
|
21739
|
+
crimson: "dc143c",
|
|
21740
|
+
cyan: "0ff",
|
|
21741
|
+
darkblue: "00008b",
|
|
21742
|
+
darkcyan: "008b8b",
|
|
21743
|
+
darkgoldenrod: "b8860b",
|
|
21744
|
+
darkgray: "a9a9a9",
|
|
21745
|
+
darkgreen: "006400",
|
|
21746
|
+
darkgrey: "a9a9a9",
|
|
21747
|
+
darkkhaki: "bdb76b",
|
|
21748
|
+
darkmagenta: "8b008b",
|
|
21749
|
+
darkolivegreen: "556b2f",
|
|
21750
|
+
darkorange: "ff8c00",
|
|
21751
|
+
darkorchid: "9932cc",
|
|
21752
|
+
darkred: "8b0000",
|
|
21753
|
+
darksalmon: "e9967a",
|
|
21754
|
+
darkseagreen: "8fbc8f",
|
|
21755
|
+
darkslateblue: "483d8b",
|
|
21756
|
+
darkslategray: "2f4f4f",
|
|
21757
|
+
darkslategrey: "2f4f4f",
|
|
21758
|
+
darkturquoise: "00ced1",
|
|
21759
|
+
darkviolet: "9400d3",
|
|
21760
|
+
deeppink: "ff1493",
|
|
21761
|
+
deepskyblue: "00bfff",
|
|
21762
|
+
dimgray: "696969",
|
|
21763
|
+
dimgrey: "696969",
|
|
21764
|
+
dodgerblue: "1e90ff",
|
|
21765
|
+
firebrick: "b22222",
|
|
21766
|
+
floralwhite: "fffaf0",
|
|
21767
|
+
forestgreen: "228b22",
|
|
21768
|
+
fuchsia: "f0f",
|
|
21769
|
+
gainsboro: "dcdcdc",
|
|
21770
|
+
ghostwhite: "f8f8ff",
|
|
21771
|
+
gold: "ffd700",
|
|
21772
|
+
goldenrod: "daa520",
|
|
21773
|
+
gray: "808080",
|
|
21774
|
+
green: "008000",
|
|
21775
|
+
greenyellow: "adff2f",
|
|
21776
|
+
grey: "808080",
|
|
21777
|
+
honeydew: "f0fff0",
|
|
21778
|
+
hotpink: "ff69b4",
|
|
21779
|
+
indianred: "cd5c5c",
|
|
21780
|
+
indigo: "4b0082",
|
|
21781
|
+
ivory: "fffff0",
|
|
21782
|
+
khaki: "f0e68c",
|
|
21783
|
+
lavender: "e6e6fa",
|
|
21784
|
+
lavenderblush: "fff0f5",
|
|
21785
|
+
lawngreen: "7cfc00",
|
|
21786
|
+
lemonchiffon: "fffacd",
|
|
21787
|
+
lightblue: "add8e6",
|
|
21788
|
+
lightcoral: "f08080",
|
|
21789
|
+
lightcyan: "e0ffff",
|
|
21790
|
+
lightgoldenrodyellow: "fafad2",
|
|
21791
|
+
lightgray: "d3d3d3",
|
|
21792
|
+
lightgreen: "90ee90",
|
|
21793
|
+
lightgrey: "d3d3d3",
|
|
21794
|
+
lightpink: "ffb6c1",
|
|
21795
|
+
lightsalmon: "ffa07a",
|
|
21796
|
+
lightseagreen: "20b2aa",
|
|
21797
|
+
lightskyblue: "87cefa",
|
|
21798
|
+
lightslategray: "789",
|
|
21799
|
+
lightslategrey: "789",
|
|
21800
|
+
lightsteelblue: "b0c4de",
|
|
21801
|
+
lightyellow: "ffffe0",
|
|
21802
|
+
lime: "0f0",
|
|
21803
|
+
limegreen: "32cd32",
|
|
21804
|
+
linen: "faf0e6",
|
|
21805
|
+
magenta: "f0f",
|
|
21806
|
+
maroon: "800000",
|
|
21807
|
+
mediumaquamarine: "66cdaa",
|
|
21808
|
+
mediumblue: "0000cd",
|
|
21809
|
+
mediumorchid: "ba55d3",
|
|
21810
|
+
mediumpurple: "9370db",
|
|
21811
|
+
mediumseagreen: "3cb371",
|
|
21812
|
+
mediumslateblue: "7b68ee",
|
|
21813
|
+
mediumspringgreen: "00fa9a",
|
|
21814
|
+
mediumturquoise: "48d1cc",
|
|
21815
|
+
mediumvioletred: "c71585",
|
|
21816
|
+
midnightblue: "191970",
|
|
21817
|
+
mintcream: "f5fffa",
|
|
21818
|
+
mistyrose: "ffe4e1",
|
|
21819
|
+
moccasin: "ffe4b5",
|
|
21820
|
+
navajowhite: "ffdead",
|
|
21821
|
+
navy: "000080",
|
|
21822
|
+
oldlace: "fdf5e6",
|
|
21823
|
+
olive: "808000",
|
|
21824
|
+
olivedrab: "6b8e23",
|
|
21825
|
+
orange: "ffa500",
|
|
21826
|
+
orangered: "ff4500",
|
|
21827
|
+
orchid: "da70d6",
|
|
21828
|
+
palegoldenrod: "eee8aa",
|
|
21829
|
+
palegreen: "98fb98",
|
|
21830
|
+
paleturquoise: "afeeee",
|
|
21831
|
+
palevioletred: "db7093",
|
|
21832
|
+
papayawhip: "ffefd5",
|
|
21833
|
+
peachpuff: "ffdab9",
|
|
21834
|
+
peru: "cd853f",
|
|
21835
|
+
pink: "ffc0cb",
|
|
21836
|
+
plum: "dda0dd",
|
|
21837
|
+
powderblue: "b0e0e6",
|
|
21838
|
+
purple: "800080",
|
|
21839
|
+
rebeccapurple: "663399",
|
|
21840
|
+
red: "f00",
|
|
21841
|
+
rosybrown: "bc8f8f",
|
|
21842
|
+
royalblue: "4169e1",
|
|
21843
|
+
saddlebrown: "8b4513",
|
|
21844
|
+
salmon: "fa8072",
|
|
21845
|
+
sandybrown: "f4a460",
|
|
21846
|
+
seagreen: "2e8b57",
|
|
21847
|
+
seashell: "fff5ee",
|
|
21848
|
+
sienna: "a0522d",
|
|
21849
|
+
silver: "c0c0c0",
|
|
21850
|
+
skyblue: "87ceeb",
|
|
21851
|
+
slateblue: "6a5acd",
|
|
21852
|
+
slategray: "708090",
|
|
21853
|
+
slategrey: "708090",
|
|
21854
|
+
snow: "fffafa",
|
|
21855
|
+
springgreen: "00ff7f",
|
|
21856
|
+
steelblue: "4682b4",
|
|
21857
|
+
tan: "d2b48c",
|
|
21858
|
+
teal: "008080",
|
|
21859
|
+
thistle: "d8bfd8",
|
|
21860
|
+
tomato: "ff6347",
|
|
21861
|
+
turquoise: "40e0d0",
|
|
21862
|
+
violet: "ee82ee",
|
|
21863
|
+
wheat: "f5deb3",
|
|
21864
|
+
white: "fff",
|
|
21865
|
+
whitesmoke: "f5f5f5",
|
|
21866
|
+
yellow: "ff0",
|
|
21867
|
+
yellowgreen: "9acd32"
|
|
21868
|
+
};
|
|
21869
|
+
|
|
21870
|
+
// Make it easy to access colors via `hexNames[hex]`
|
|
21871
|
+
var hexNames = tinycolor.hexNames = flip(names);
|
|
21872
|
+
|
|
21873
|
+
// Utilities
|
|
21874
|
+
// ---------
|
|
21875
|
+
|
|
21876
|
+
// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
|
|
21877
|
+
function flip(o) {
|
|
21878
|
+
var flipped = {};
|
|
21879
|
+
for (var i in o) {
|
|
21880
|
+
if (o.hasOwnProperty(i)) {
|
|
21881
|
+
flipped[o[i]] = i;
|
|
21882
|
+
}
|
|
21883
|
+
}
|
|
21884
|
+
return flipped;
|
|
21885
|
+
}
|
|
21886
|
+
|
|
21887
|
+
// Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
21888
|
+
function boundAlpha(a) {
|
|
21889
|
+
a = parseFloat(a);
|
|
21890
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
21891
|
+
a = 1;
|
|
21892
|
+
}
|
|
21893
|
+
return a;
|
|
21894
|
+
}
|
|
21895
|
+
|
|
21896
|
+
// Take input from [0, n] and return it as [0, 1]
|
|
21897
|
+
function bound01(n, max) {
|
|
21898
|
+
if (isOnePointZero(n)) n = "100%";
|
|
21899
|
+
var processPercent = isPercentage(n);
|
|
21900
|
+
n = Math.min(max, Math.max(0, parseFloat(n)));
|
|
21901
|
+
|
|
21902
|
+
// Automatically convert percentage into number
|
|
21903
|
+
if (processPercent) {
|
|
21904
|
+
n = parseInt(n * max, 10) / 100;
|
|
21905
|
+
}
|
|
21906
|
+
|
|
21907
|
+
// Handle floating point rounding errors
|
|
21908
|
+
if (Math.abs(n - max) < 0.000001) {
|
|
21909
|
+
return 1;
|
|
21910
|
+
}
|
|
21911
|
+
|
|
21912
|
+
// Convert into [0, 1] range if it isn't already
|
|
21913
|
+
return n % max / parseFloat(max);
|
|
21914
|
+
}
|
|
21915
|
+
|
|
21916
|
+
// Force a number between 0 and 1
|
|
21917
|
+
function clamp01(val) {
|
|
21918
|
+
return Math.min(1, Math.max(0, val));
|
|
21919
|
+
}
|
|
21920
|
+
|
|
21921
|
+
// Parse a base-16 hex value into a base-10 integer
|
|
21922
|
+
function parseIntFromHex(val) {
|
|
21923
|
+
return parseInt(val, 16);
|
|
21924
|
+
}
|
|
21925
|
+
|
|
21926
|
+
// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
21927
|
+
// <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
21928
|
+
function isOnePointZero(n) {
|
|
21929
|
+
return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
|
|
21930
|
+
}
|
|
21931
|
+
|
|
21932
|
+
// Check to see if string passed in is a percentage
|
|
21933
|
+
function isPercentage(n) {
|
|
21934
|
+
return typeof n === "string" && n.indexOf("%") != -1;
|
|
21935
|
+
}
|
|
21936
|
+
|
|
21937
|
+
// Force a hex value to have 2 characters
|
|
21938
|
+
function pad2(c) {
|
|
21939
|
+
return c.length == 1 ? "0" + c : "" + c;
|
|
21940
|
+
}
|
|
21941
|
+
|
|
21942
|
+
// Replace a decimal with it's percentage value
|
|
21943
|
+
function convertToPercentage(n) {
|
|
21944
|
+
if (n <= 1) {
|
|
21945
|
+
n = n * 100 + "%";
|
|
21946
|
+
}
|
|
21947
|
+
return n;
|
|
21948
|
+
}
|
|
21949
|
+
|
|
21950
|
+
// Converts a decimal to a hex value
|
|
21951
|
+
function convertDecimalToHex(d) {
|
|
21952
|
+
return Math.round(parseFloat(d) * 255).toString(16);
|
|
21953
|
+
}
|
|
21954
|
+
// Converts a hex value to a decimal
|
|
21955
|
+
function convertHexToDecimal(h) {
|
|
21956
|
+
return parseIntFromHex(h) / 255;
|
|
21957
|
+
}
|
|
21958
|
+
var matchers = function () {
|
|
21959
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
21960
|
+
var CSS_INTEGER = "[-\\+]?\\d+%?";
|
|
21961
|
+
|
|
21962
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
21963
|
+
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
|
|
21964
|
+
|
|
21965
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
21966
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
21967
|
+
|
|
21968
|
+
// Actual matching.
|
|
21969
|
+
// Parentheses and commas are optional, but not required.
|
|
21970
|
+
// Whitespace can take the place of commas or opening paren
|
|
21971
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
21972
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
21973
|
+
return {
|
|
21974
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
21975
|
+
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
|
21976
|
+
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
|
21977
|
+
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
|
21978
|
+
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
|
21979
|
+
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
|
21980
|
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
|
21981
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
21982
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
21983
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
21984
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
21985
|
+
};
|
|
21986
|
+
}();
|
|
21987
|
+
|
|
21988
|
+
// `isValidCSSUnit`
|
|
21989
|
+
// Take in a single string / number and check to see if it looks like a CSS unit
|
|
21990
|
+
// (see `matchers` above for definition).
|
|
21991
|
+
function isValidCSSUnit(color) {
|
|
21992
|
+
return !!matchers.CSS_UNIT.exec(color);
|
|
21993
|
+
}
|
|
21994
|
+
|
|
21995
|
+
// `stringInputToObject`
|
|
21996
|
+
// Permissive string parsing. Take in a number of formats, and output an object
|
|
21997
|
+
// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
21998
|
+
function stringInputToObject(color) {
|
|
21999
|
+
color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
|
|
22000
|
+
var named = false;
|
|
22001
|
+
if (names[color]) {
|
|
22002
|
+
color = names[color];
|
|
22003
|
+
named = true;
|
|
22004
|
+
} else if (color == "transparent") {
|
|
22005
|
+
return {
|
|
22006
|
+
r: 0,
|
|
22007
|
+
g: 0,
|
|
22008
|
+
b: 0,
|
|
22009
|
+
a: 0,
|
|
22010
|
+
format: "name"
|
|
22011
|
+
};
|
|
22012
|
+
}
|
|
22013
|
+
|
|
22014
|
+
// Try to match string input using regular expressions.
|
|
22015
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
22016
|
+
// Just return an object and let the conversion functions handle that.
|
|
22017
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
22018
|
+
var match;
|
|
22019
|
+
if (match = matchers.rgb.exec(color)) {
|
|
22020
|
+
return {
|
|
22021
|
+
r: match[1],
|
|
22022
|
+
g: match[2],
|
|
22023
|
+
b: match[3]
|
|
22024
|
+
};
|
|
22025
|
+
}
|
|
22026
|
+
if (match = matchers.rgba.exec(color)) {
|
|
22027
|
+
return {
|
|
22028
|
+
r: match[1],
|
|
22029
|
+
g: match[2],
|
|
22030
|
+
b: match[3],
|
|
22031
|
+
a: match[4]
|
|
22032
|
+
};
|
|
22033
|
+
}
|
|
22034
|
+
if (match = matchers.hsl.exec(color)) {
|
|
22035
|
+
return {
|
|
22036
|
+
h: match[1],
|
|
22037
|
+
s: match[2],
|
|
22038
|
+
l: match[3]
|
|
22039
|
+
};
|
|
22040
|
+
}
|
|
22041
|
+
if (match = matchers.hsla.exec(color)) {
|
|
22042
|
+
return {
|
|
22043
|
+
h: match[1],
|
|
22044
|
+
s: match[2],
|
|
22045
|
+
l: match[3],
|
|
22046
|
+
a: match[4]
|
|
22047
|
+
};
|
|
22048
|
+
}
|
|
22049
|
+
if (match = matchers.hsv.exec(color)) {
|
|
22050
|
+
return {
|
|
22051
|
+
h: match[1],
|
|
22052
|
+
s: match[2],
|
|
22053
|
+
v: match[3]
|
|
22054
|
+
};
|
|
22055
|
+
}
|
|
22056
|
+
if (match = matchers.hsva.exec(color)) {
|
|
22057
|
+
return {
|
|
22058
|
+
h: match[1],
|
|
22059
|
+
s: match[2],
|
|
22060
|
+
v: match[3],
|
|
22061
|
+
a: match[4]
|
|
22062
|
+
};
|
|
22063
|
+
}
|
|
22064
|
+
if (match = matchers.hex8.exec(color)) {
|
|
22065
|
+
return {
|
|
22066
|
+
r: parseIntFromHex(match[1]),
|
|
22067
|
+
g: parseIntFromHex(match[2]),
|
|
22068
|
+
b: parseIntFromHex(match[3]),
|
|
22069
|
+
a: convertHexToDecimal(match[4]),
|
|
22070
|
+
format: named ? "name" : "hex8"
|
|
22071
|
+
};
|
|
22072
|
+
}
|
|
22073
|
+
if (match = matchers.hex6.exec(color)) {
|
|
22074
|
+
return {
|
|
22075
|
+
r: parseIntFromHex(match[1]),
|
|
22076
|
+
g: parseIntFromHex(match[2]),
|
|
22077
|
+
b: parseIntFromHex(match[3]),
|
|
22078
|
+
format: named ? "name" : "hex"
|
|
22079
|
+
};
|
|
22080
|
+
}
|
|
22081
|
+
if (match = matchers.hex4.exec(color)) {
|
|
22082
|
+
return {
|
|
22083
|
+
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
22084
|
+
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
22085
|
+
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
22086
|
+
a: convertHexToDecimal(match[4] + "" + match[4]),
|
|
22087
|
+
format: named ? "name" : "hex8"
|
|
22088
|
+
};
|
|
22089
|
+
}
|
|
22090
|
+
if (match = matchers.hex3.exec(color)) {
|
|
22091
|
+
return {
|
|
22092
|
+
r: parseIntFromHex(match[1] + "" + match[1]),
|
|
22093
|
+
g: parseIntFromHex(match[2] + "" + match[2]),
|
|
22094
|
+
b: parseIntFromHex(match[3] + "" + match[3]),
|
|
22095
|
+
format: named ? "name" : "hex"
|
|
22096
|
+
};
|
|
22097
|
+
}
|
|
22098
|
+
return false;
|
|
22099
|
+
}
|
|
22100
|
+
function validateWCAG2Parms(parms) {
|
|
22101
|
+
// return valid WCAG2 parms for isReadable.
|
|
22102
|
+
// If input parms are invalid, return {"level":"AA", "size":"small"}
|
|
22103
|
+
var level, size;
|
|
22104
|
+
parms = parms || {
|
|
22105
|
+
level: "AA",
|
|
22106
|
+
size: "small"
|
|
22107
|
+
};
|
|
22108
|
+
level = (parms.level || "AA").toUpperCase();
|
|
22109
|
+
size = (parms.size || "small").toLowerCase();
|
|
22110
|
+
if (level !== "AA" && level !== "AAA") {
|
|
22111
|
+
level = "AA";
|
|
22112
|
+
}
|
|
22113
|
+
if (size !== "small" && size !== "large") {
|
|
22114
|
+
size = "small";
|
|
22115
|
+
}
|
|
22116
|
+
return {
|
|
22117
|
+
level: level,
|
|
22118
|
+
size: size
|
|
22119
|
+
};
|
|
22120
|
+
}
|
|
22121
|
+
|
|
22122
|
+
const baseLabelClasses = 'tw-left-1 tw-text-xs tw-text-sq-text-color dark:tw-text-sq-dark-text tw-items-center tw-h-[18px]';
|
|
20943
22123
|
const ProgressIndicator = (props) => {
|
|
20944
22124
|
const { value, color = undefined, testId, label, extraClasses = '', labelClasses = '', valuesLength, max, index, ...tooltipProps } = props;
|
|
20945
22125
|
const tooltipData = getQTipData(tooltipProps);
|
|
20946
22126
|
const previousWidth = React.useRef(0);
|
|
22127
|
+
const indicatorElementRef = React.useRef(null);
|
|
22128
|
+
const [textColorClass, setTextColorClass] = React.useState('');
|
|
20947
22129
|
const [animatedWidth, setAnimatedWidth] = React.useState(previousWidth.current);
|
|
20948
22130
|
React.useEffect(() => {
|
|
20949
22131
|
const timeout = setTimeout(() => {
|
|
@@ -20953,17 +22135,33 @@ const ProgressIndicator = (props) => {
|
|
|
20953
22135
|
}, 100);
|
|
20954
22136
|
return () => clearTimeout(timeout);
|
|
20955
22137
|
}, [value]);
|
|
20956
|
-
|
|
22138
|
+
const bgColor = color || undefined;
|
|
22139
|
+
const bgClass = color ? '' : 'tw-bg-sq-color-dark';
|
|
22140
|
+
const computeTextClass = (elem) => {
|
|
22141
|
+
const computedStyle = getComputedStyle(elem);
|
|
22142
|
+
const backgroundColor = computedStyle.backgroundColor;
|
|
22143
|
+
const textColorClass = tinycolor(backgroundColor).isDark()
|
|
22144
|
+
? 'tw-text-sq-white dark:tw-text-sq-white'
|
|
22145
|
+
: 'tw-text-sq-text-color dark:tw-text-sq-text-color';
|
|
22146
|
+
setTextColorClass(textColorClass);
|
|
22147
|
+
};
|
|
22148
|
+
React.useEffect(() => {
|
|
22149
|
+
if (indicatorElementRef.current) {
|
|
22150
|
+
computeTextClass(indicatorElementRef.current);
|
|
22151
|
+
}
|
|
22152
|
+
}, [!!indicatorElementRef.current]);
|
|
22153
|
+
return (React.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-w-full tw-h-[18px] tw-duration-[660ms] tw-flex tw-justify-center tw-items-center tw-overflow-hidden ${bgClass} ${extraClasses}`, ...tooltipData, "data-qtip-text": tooltipProps.tooltip ? tooltipProps.tooltip : `${value}%`, "data-testid": `progress-bar-indicator-${testId ? testId : value}`, key: `${index}-${value}`, ref: indicatorElementRef, style: {
|
|
20957
22154
|
// Background color will default to the theme color if undefined
|
|
20958
|
-
backgroundColor:
|
|
22155
|
+
backgroundColor: bgColor,
|
|
20959
22156
|
animation: 'width 660ms forwards',
|
|
20960
22157
|
width: `${animatedWidth}%`,
|
|
20961
|
-
} }, label ?
|
|
22158
|
+
} }, label ? React.createElement("span", { className: `${baseLabelClasses} ${labelClasses} ${textColorClass}` }, label) : undefined));
|
|
20962
22159
|
};
|
|
20963
|
-
const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', }) => {
|
|
20964
|
-
|
|
22160
|
+
const ProgressBar = ({ values = [], max = 100, containerExtraClasses = '', zeroValueLabel = 'No progress yet', }) => {
|
|
22161
|
+
const totalValue = values.reduce((acc, { value }) => acc + value, 0);
|
|
22162
|
+
return (React.createElement(Root, { className: `tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray tw-flex tw-flex-1 ${containerExtraClasses}`, max: max, value: totalValue }, totalValue > 0 ? (values.map((props, i) => {
|
|
20965
22163
|
return React.createElement(ProgressIndicator, { ...props, max: max, valuesLength: values.length, index: i, key: i });
|
|
20966
|
-
})));
|
|
22164
|
+
})) : (React.createElement("div", { className: `${baseLabelClasses} tw-mx-auto tw-overflow-hidden` }, zeroValueLabel))));
|
|
20967
22165
|
};
|
|
20968
22166
|
|
|
20969
22167
|
const baseClasses = 'tw-flex tw-outline-none tw-rounded-sm tw-w-full tw-relative tw-flex-wrap';
|