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