@wistia/ui 0.13.10 → 0.13.11-beta.e83846c4.6d00a8f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +116 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.mjs +174 -131
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.13.
|
|
3
|
+
* @license @wistia/ui v0.13.11-beta.e83846c4.6d00a8f
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -149,6 +149,7 @@ __export(index_exports, {
|
|
|
149
149
|
ValueNameOrHexCode: () => ValueNameOrHexCode,
|
|
150
150
|
ValueSwatch: () => ValueSwatch,
|
|
151
151
|
WistiaLogo: () => WistiaLogo,
|
|
152
|
+
calculateContrast: () => calculateContrast,
|
|
152
153
|
colorSchemeOptions: () => colorSchemeOptions,
|
|
153
154
|
copyToClipboard: () => copyToClipboard,
|
|
154
155
|
dateTime: () => dateTime,
|
|
@@ -7183,10 +7184,26 @@ var iconSizeMap = {
|
|
|
7183
7184
|
xl: "32",
|
|
7184
7185
|
xxl: "48"
|
|
7185
7186
|
};
|
|
7187
|
+
var iconInlineStyle = import_styled_components19.css`
|
|
7188
|
+
[data-wui-icon-inline] {
|
|
7189
|
+
--wui-icon-inline-size: 0.8em;
|
|
7190
|
+
--wui-icon-inline-offset: 0.05em;
|
|
7191
|
+
--wui-icon-vertical-align: none;
|
|
7192
|
+
|
|
7193
|
+
top: var(--wui-icon-inline-offset);
|
|
7194
|
+
position: relative;
|
|
7195
|
+
}
|
|
7196
|
+
`;
|
|
7186
7197
|
var StyledIcon = import_styled_components19.default.svg`
|
|
7187
7198
|
${({ $colorScheme }) => getColorScheme($colorScheme ?? "inherit")}
|
|
7199
|
+
--wui-icon-size: var(--wui-icon-inline-size, ${({ $height }) => $height}px);
|
|
7200
|
+
--wui-icon-vertical-align: middle;
|
|
7201
|
+
|
|
7202
|
+
height: var(--wui-icon-size);
|
|
7203
|
+
width: var(--wui-icon-size);
|
|
7188
7204
|
`;
|
|
7189
7205
|
var Icon = ({
|
|
7206
|
+
useInlineStyles = true,
|
|
7190
7207
|
invertColor,
|
|
7191
7208
|
colorScheme = "inherit",
|
|
7192
7209
|
size = "lg",
|
|
@@ -7208,7 +7225,7 @@ var Icon = ({
|
|
|
7208
7225
|
}
|
|
7209
7226
|
const IconElement = iconMap[type];
|
|
7210
7227
|
const defaultStyle = {
|
|
7211
|
-
verticalAlign: "
|
|
7228
|
+
verticalAlign: "var(--wui-icon-vertical-align)",
|
|
7212
7229
|
...style
|
|
7213
7230
|
};
|
|
7214
7231
|
const iconColor = invertColor ? "var(--wui-color-icon-on-fill)" : "var(--wui-color-icon)";
|
|
@@ -7216,13 +7233,14 @@ var Icon = ({
|
|
|
7216
7233
|
StyledIcon,
|
|
7217
7234
|
{
|
|
7218
7235
|
$colorScheme: colorScheme,
|
|
7236
|
+
$height: iconSizeMap[responsiveSize],
|
|
7237
|
+
$width: iconSizeMap[responsiveSize],
|
|
7219
7238
|
"aria-hidden": "true",
|
|
7220
7239
|
as: IconElement,
|
|
7221
|
-
|
|
7240
|
+
"data-wui-icon-inline": useInlineStyles ? true : void 0,
|
|
7222
7241
|
role: "presentation",
|
|
7223
7242
|
style: defaultStyle,
|
|
7224
7243
|
viewBox: "0 0 24 24",
|
|
7225
|
-
width: `${iconSizeMap[responsiveSize]}px`,
|
|
7226
7244
|
xmlns: "http://www.w3.org/2000/svg",
|
|
7227
7245
|
...props,
|
|
7228
7246
|
color: iconColor
|
|
@@ -8246,6 +8264,8 @@ var StyledHeading = import_styled_components28.default.div`
|
|
|
8246
8264
|
text-align: ${$align};
|
|
8247
8265
|
`}
|
|
8248
8266
|
margin: 0;
|
|
8267
|
+
|
|
8268
|
+
${iconInlineStyle}
|
|
8249
8269
|
`;
|
|
8250
8270
|
var variantElementMap = {
|
|
8251
8271
|
hero: DEFAULT_ELEMENT2,
|
|
@@ -8427,6 +8447,7 @@ var StyledText = import_styled_components29.default.div`
|
|
|
8427
8447
|
return "var(--wui-color-text)";
|
|
8428
8448
|
}};
|
|
8429
8449
|
|
|
8450
|
+
${iconInlineStyle}
|
|
8430
8451
|
color: var(--text-color);
|
|
8431
8452
|
font-family: var(--font-family);
|
|
8432
8453
|
font-size: var(--font-size);
|
|
@@ -8653,21 +8674,6 @@ var StyledBanner = import_styled_components32.default.div`
|
|
|
8653
8674
|
|
|
8654
8675
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
8655
8676
|
`;
|
|
8656
|
-
var IconWrapper = (0, import_styled_components32.default)(Box)`
|
|
8657
|
-
--wui-banner-icon-size: var(--font-size, 24px);
|
|
8658
|
-
|
|
8659
|
-
${({ $iconPosition }) => $iconPosition === "inline" && import_styled_components32.css`
|
|
8660
|
-
display: inline-block;
|
|
8661
|
-
vertical-align: text-bottom;
|
|
8662
|
-
margin-right: calc(var(--wui-banner-icon-size) / 3);
|
|
8663
|
-
`}
|
|
8664
|
-
|
|
8665
|
-
svg {
|
|
8666
|
-
color: var(--wui-color-icon);
|
|
8667
|
-
width: var(--wui-banner-icon-size);
|
|
8668
|
-
height: var(--wui-banner-icon-size);
|
|
8669
|
-
}
|
|
8670
|
-
`;
|
|
8671
8677
|
var Banner = ({
|
|
8672
8678
|
bodyText,
|
|
8673
8679
|
colorScheme = "inherit",
|
|
@@ -8730,9 +8736,8 @@ var Banner = ({
|
|
|
8730
8736
|
style: { padding: "var(--wui-banner-padding)" },
|
|
8731
8737
|
children: [
|
|
8732
8738
|
iconPosition === "above" && /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(
|
|
8733
|
-
|
|
8739
|
+
Box,
|
|
8734
8740
|
{
|
|
8735
|
-
$iconPosition: "above",
|
|
8736
8741
|
alignSelf: "stretch",
|
|
8737
8742
|
direction: "column",
|
|
8738
8743
|
justifyContent: "center",
|
|
@@ -8748,7 +8753,10 @@ var Banner = ({
|
|
|
8748
8753
|
justifyContent: "center",
|
|
8749
8754
|
children: [
|
|
8750
8755
|
(0, import_type_guards24.isNotNil)(headingText) ? /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(Heading, { variant: headingVariant, children: [
|
|
8751
|
-
iconPosition === "inline" && /* @__PURE__ */ (0, import_jsx_runtime208.
|
|
8756
|
+
iconPosition === "inline" && /* @__PURE__ */ (0, import_jsx_runtime208.jsxs)(import_jsx_runtime208.Fragment, { children: [
|
|
8757
|
+
icon,
|
|
8758
|
+
" "
|
|
8759
|
+
] }),
|
|
8752
8760
|
headingText
|
|
8753
8761
|
] }) : null,
|
|
8754
8762
|
/* @__PURE__ */ (0, import_jsx_runtime208.jsx)(Text, { variant: textVariant, children: bodyText })
|
|
@@ -9762,6 +9770,16 @@ var compositeOverWhite = (color, alpha = 1) => {
|
|
|
9762
9770
|
b: compositeChannel(colorAsRgb.b)
|
|
9763
9771
|
};
|
|
9764
9772
|
};
|
|
9773
|
+
var calculateContrast = ({
|
|
9774
|
+
backgroundColor,
|
|
9775
|
+
foregroundColor = DEFAULT_COLOR_FOR_COMPARISON,
|
|
9776
|
+
backgroundOpacity = DEFAULT_OPACITY_FOR_CONTRAST_CALCULATION
|
|
9777
|
+
}) => {
|
|
9778
|
+
const backgroundColorAsRgb = convertToRgb(backgroundColor);
|
|
9779
|
+
const foregroundColorAsRgb = convertToRgb(foregroundColor);
|
|
9780
|
+
const compositeBackground = compositeOverWhite(backgroundColorAsRgb, backgroundOpacity);
|
|
9781
|
+
return (0, import_fn3.wcagContrast)(compositeBackground, foregroundColorAsRgb);
|
|
9782
|
+
};
|
|
9765
9783
|
var snapValueToEdges = (value) => {
|
|
9766
9784
|
if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) {
|
|
9767
9785
|
return 1;
|
|
@@ -9784,13 +9802,15 @@ var updateSearchBounds = (searchingBrighter, contrast, minContrast, midValue, se
|
|
|
9784
9802
|
return { newSearchLow: searchLow, newSearchHigh: midValue };
|
|
9785
9803
|
};
|
|
9786
9804
|
var getAccessibleColorByValueChannelChange = ({
|
|
9787
|
-
|
|
9805
|
+
originalColor,
|
|
9788
9806
|
colorForComparison,
|
|
9789
9807
|
minContrast,
|
|
9790
9808
|
maxIterations = 50,
|
|
9791
9809
|
direction,
|
|
9792
|
-
opacityForContrastCalculation
|
|
9810
|
+
opacityForContrastCalculation,
|
|
9811
|
+
shouldConvertToHex = true
|
|
9793
9812
|
}) => {
|
|
9813
|
+
const originalHsv = convertToHsv(originalColor);
|
|
9794
9814
|
const searchingBrighter = direction === "brighter";
|
|
9795
9815
|
const lowValue = searchingBrighter ? originalHsv.v : 0;
|
|
9796
9816
|
const highValue = searchingBrighter ? 1 : originalHsv.v;
|
|
@@ -9801,10 +9821,11 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9801
9821
|
v: extremeValue,
|
|
9802
9822
|
mode: "hsv"
|
|
9803
9823
|
};
|
|
9804
|
-
const extremeContrast = (
|
|
9805
|
-
|
|
9806
|
-
colorForComparison
|
|
9807
|
-
|
|
9824
|
+
const extremeContrast = calculateContrast({
|
|
9825
|
+
backgroundColor: shouldConvertToHex ? (0, import_fn3.formatHex)(extremeVariant) : extremeVariant,
|
|
9826
|
+
foregroundColor: colorForComparison,
|
|
9827
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9828
|
+
});
|
|
9808
9829
|
if (extremeContrast < minContrast) {
|
|
9809
9830
|
return null;
|
|
9810
9831
|
}
|
|
@@ -9820,10 +9841,11 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9820
9841
|
v: midValue,
|
|
9821
9842
|
mode: "hsv"
|
|
9822
9843
|
};
|
|
9823
|
-
const contrast = (
|
|
9824
|
-
|
|
9825
|
-
colorForComparison
|
|
9826
|
-
|
|
9844
|
+
const contrast = calculateContrast({
|
|
9845
|
+
backgroundColor: shouldConvertToHex ? (0, import_fn3.formatHex)(candidateHsv) : candidateHsv,
|
|
9846
|
+
foregroundColor: colorForComparison,
|
|
9847
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9848
|
+
});
|
|
9827
9849
|
if (contrast >= minContrast) {
|
|
9828
9850
|
bestSoFar = candidateHsv;
|
|
9829
9851
|
}
|
|
@@ -9843,7 +9865,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9843
9865
|
}
|
|
9844
9866
|
return bestSoFar;
|
|
9845
9867
|
};
|
|
9846
|
-
var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption,
|
|
9868
|
+
var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalColor) => {
|
|
9847
9869
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9848
9870
|
if (!brighterOption && !darkerOption) {
|
|
9849
9871
|
return null;
|
|
@@ -9854,8 +9876,8 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalH
|
|
|
9854
9876
|
if (!darkerOption && brighterOption != null) {
|
|
9855
9877
|
return brighterOption;
|
|
9856
9878
|
}
|
|
9857
|
-
const brighterDifference = brighterOption === null ? Infinity : hsvDifference(
|
|
9858
|
-
const darkerDifference = darkerOption === null ? Infinity : hsvDifference(
|
|
9879
|
+
const brighterDifference = brighterOption === null ? Infinity : hsvDifference(originalColor, brighterOption);
|
|
9880
|
+
const darkerDifference = darkerOption === null ? Infinity : hsvDifference(originalColor, darkerOption);
|
|
9859
9881
|
if (brighterDifference <= darkerDifference && brighterOption != null) {
|
|
9860
9882
|
return brighterOption;
|
|
9861
9883
|
}
|
|
@@ -9865,12 +9887,13 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalH
|
|
|
9865
9887
|
throw new Error("Unable to determine the best accessible color variant");
|
|
9866
9888
|
};
|
|
9867
9889
|
var getAccessibleColorBySaturationAndValueChange = ({
|
|
9868
|
-
|
|
9890
|
+
originalColor,
|
|
9869
9891
|
colorForComparison,
|
|
9870
9892
|
minContrast,
|
|
9871
9893
|
direction,
|
|
9872
9894
|
opacityForContrastCalculation
|
|
9873
9895
|
}) => {
|
|
9896
|
+
const originalHsv = convertToHsv(originalColor);
|
|
9874
9897
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9875
9898
|
const maxIterations = 50;
|
|
9876
9899
|
let lowStep = 0;
|
|
@@ -9896,7 +9919,11 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9896
9919
|
};
|
|
9897
9920
|
};
|
|
9898
9921
|
const checkContrast = (hsv) => {
|
|
9899
|
-
return (
|
|
9922
|
+
return calculateContrast({
|
|
9923
|
+
backgroundColor: (0, import_fn3.formatHex)(hsv),
|
|
9924
|
+
foregroundColor: colorForComparison,
|
|
9925
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9926
|
+
});
|
|
9900
9927
|
};
|
|
9901
9928
|
const extremeHsv = getHsvForStep(highStep);
|
|
9902
9929
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9925,7 +9952,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9925
9952
|
return bestCandidate;
|
|
9926
9953
|
};
|
|
9927
9954
|
var getAccessibleColorInDirection = ({
|
|
9928
|
-
|
|
9955
|
+
originalColor,
|
|
9929
9956
|
colorForComparison,
|
|
9930
9957
|
minContrast,
|
|
9931
9958
|
maxIterations = 50,
|
|
@@ -9933,7 +9960,7 @@ var getAccessibleColorInDirection = ({
|
|
|
9933
9960
|
opacityForContrastCalculation
|
|
9934
9961
|
}) => {
|
|
9935
9962
|
const valueResult = getAccessibleColorByValueChannelChange({
|
|
9936
|
-
|
|
9963
|
+
originalColor,
|
|
9937
9964
|
colorForComparison,
|
|
9938
9965
|
minContrast,
|
|
9939
9966
|
maxIterations,
|
|
@@ -9944,7 +9971,7 @@ var getAccessibleColorInDirection = ({
|
|
|
9944
9971
|
return valueResult;
|
|
9945
9972
|
}
|
|
9946
9973
|
return getAccessibleColorBySaturationAndValueChange({
|
|
9947
|
-
|
|
9974
|
+
originalColor,
|
|
9948
9975
|
colorForComparison,
|
|
9949
9976
|
minContrast,
|
|
9950
9977
|
direction,
|
|
@@ -9952,21 +9979,23 @@ var getAccessibleColorInDirection = ({
|
|
|
9952
9979
|
});
|
|
9953
9980
|
};
|
|
9954
9981
|
var getAccessibleColor = ({
|
|
9955
|
-
|
|
9982
|
+
originalColor,
|
|
9956
9983
|
colorForComparison,
|
|
9957
9984
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9958
9985
|
maxIterations = 50,
|
|
9959
9986
|
opacityForContrastCalculation
|
|
9960
9987
|
}) => {
|
|
9961
|
-
const
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9988
|
+
const originalColorAsHsv = convertToHsv(originalColor);
|
|
9989
|
+
const originalContrast = calculateContrast({
|
|
9990
|
+
backgroundColor: (0, import_fn3.formatHex)(originalColorAsHsv),
|
|
9991
|
+
foregroundColor: colorForComparison,
|
|
9992
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9993
|
+
});
|
|
9965
9994
|
if (originalContrast >= minContrast) {
|
|
9966
|
-
return
|
|
9995
|
+
return convertToHsv(originalColor);
|
|
9967
9996
|
}
|
|
9968
9997
|
const brighterOption = getAccessibleColorInDirection({
|
|
9969
|
-
|
|
9998
|
+
originalColor,
|
|
9970
9999
|
colorForComparison,
|
|
9971
10000
|
minContrast,
|
|
9972
10001
|
maxIterations,
|
|
@@ -9974,43 +10003,45 @@ var getAccessibleColor = ({
|
|
|
9974
10003
|
opacityForContrastCalculation
|
|
9975
10004
|
});
|
|
9976
10005
|
const darkerOption = getAccessibleColorInDirection({
|
|
9977
|
-
|
|
10006
|
+
originalColor,
|
|
9978
10007
|
colorForComparison,
|
|
9979
10008
|
minContrast,
|
|
9980
10009
|
maxIterations,
|
|
9981
10010
|
direction: "darker",
|
|
9982
10011
|
opacityForContrastCalculation
|
|
9983
10012
|
});
|
|
9984
|
-
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption,
|
|
10013
|
+
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption, originalColor);
|
|
9985
10014
|
if (result == null) {
|
|
9986
10015
|
throw new Error(
|
|
9987
|
-
`Unable to get accessible derivative for ${(0, import_fn3.formatHex)(
|
|
10016
|
+
`Unable to get accessible derivative for ${(0, import_fn3.formatHex)(originalColor)} at minimum contrast ratio ${minContrast}`
|
|
9988
10017
|
);
|
|
9989
10018
|
}
|
|
9990
10019
|
return result;
|
|
9991
10020
|
};
|
|
9992
10021
|
var hasAccessibleDerivatives = ({
|
|
9993
|
-
|
|
10022
|
+
originalColor,
|
|
9994
10023
|
colorForComparison,
|
|
9995
10024
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9996
10025
|
opacityForContrastCalculation
|
|
9997
10026
|
}) => {
|
|
9998
|
-
const
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10027
|
+
const originalColorAsHsv = convertToHsv(originalColor);
|
|
10028
|
+
const originalContrast = calculateContrast({
|
|
10029
|
+
backgroundColor: (0, import_fn3.formatHex)(originalColorAsHsv),
|
|
10030
|
+
foregroundColor: colorForComparison,
|
|
10031
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
10032
|
+
});
|
|
10002
10033
|
if (originalContrast >= minContrast) {
|
|
10003
10034
|
return true;
|
|
10004
10035
|
}
|
|
10005
10036
|
const brighterOption = getAccessibleColorInDirection({
|
|
10006
|
-
|
|
10037
|
+
originalColor,
|
|
10007
10038
|
colorForComparison,
|
|
10008
10039
|
minContrast,
|
|
10009
10040
|
direction: "brighter",
|
|
10010
10041
|
opacityForContrastCalculation
|
|
10011
10042
|
});
|
|
10012
10043
|
const darkerOption = getAccessibleColorInDirection({
|
|
10013
|
-
|
|
10044
|
+
originalColor,
|
|
10014
10045
|
colorForComparison,
|
|
10015
10046
|
minContrast,
|
|
10016
10047
|
direction: "darker",
|
|
@@ -10034,27 +10065,28 @@ var ColorPickerProvider = ({
|
|
|
10034
10065
|
const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
|
|
10035
10066
|
const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
|
|
10036
10067
|
const getAccessibleDerivativeColor = (0, import_react41.useCallback)(
|
|
10037
|
-
(
|
|
10038
|
-
|
|
10068
|
+
(originalColor) => getAccessibleColor({
|
|
10069
|
+
originalColor,
|
|
10039
10070
|
colorForComparison,
|
|
10040
10071
|
minContrast: minimumContrastRatio,
|
|
10041
10072
|
opacityForContrastCalculation
|
|
10042
10073
|
}),
|
|
10043
10074
|
[colorForComparison, minimumContrastRatio, opacityForContrastCalculation]
|
|
10044
10075
|
);
|
|
10045
|
-
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
|
|
10046
|
-
const currentContrastRatio = (
|
|
10047
|
-
|
|
10048
|
-
colorForComparison
|
|
10049
|
-
|
|
10076
|
+
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor((0, import_fn4.formatHex)(nonDerivedValueAsHsv)) : nonDerivedValueAsHsv;
|
|
10077
|
+
const currentContrastRatio = calculateContrast({
|
|
10078
|
+
backgroundColor: valueAsHex,
|
|
10079
|
+
foregroundColor: colorForComparison,
|
|
10080
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
10081
|
+
});
|
|
10050
10082
|
const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
|
|
10051
10083
|
return hasAccessibleDerivatives({
|
|
10052
|
-
|
|
10084
|
+
originalColor: valueAsHex,
|
|
10053
10085
|
colorForComparison,
|
|
10054
10086
|
minContrast: minimumContrastRatio,
|
|
10055
10087
|
opacityForContrastCalculation
|
|
10056
10088
|
});
|
|
10057
|
-
}, [
|
|
10089
|
+
}, [valueAsHex, colorForComparison, minimumContrastRatio, opacityForContrastCalculation]);
|
|
10058
10090
|
const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
|
|
10059
10091
|
setNonDerivedValueAsHsv(nonDerivedValue);
|
|
10060
10092
|
}, []);
|
|
@@ -10078,15 +10110,21 @@ var ColorPickerProvider = ({
|
|
|
10078
10110
|
const setShouldEnforceMinContrastWrapped = (0, import_react41.useCallback)(
|
|
10079
10111
|
(newShouldEnforceMinContrast) => {
|
|
10080
10112
|
setShouldEnforceMinContrast(newShouldEnforceMinContrast);
|
|
10081
|
-
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(
|
|
10113
|
+
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(valueAsHex) : nonDerivedValueAsHsv;
|
|
10082
10114
|
const currentHsv = valueAsHsv;
|
|
10083
10115
|
if (currentHsv.h !== newColorAsHsv.h || currentHsv.s !== newColorAsHsv.s || currentHsv.v !== newColorAsHsv.v) {
|
|
10084
10116
|
changeValueSmoothly(newColorAsHsv);
|
|
10085
10117
|
}
|
|
10086
10118
|
},
|
|
10087
|
-
[
|
|
10119
|
+
[
|
|
10120
|
+
changeValueSmoothly,
|
|
10121
|
+
getAccessibleDerivativeColor,
|
|
10122
|
+
nonDerivedValueAsHsv,
|
|
10123
|
+
valueAsHex,
|
|
10124
|
+
valueAsHsv
|
|
10125
|
+
]
|
|
10088
10126
|
);
|
|
10089
|
-
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor(nonDerivedValueAsHsv)) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
|
|
10127
|
+
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor((0, import_fn4.formatHex)(nonDerivedValueAsHsv))) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
|
|
10090
10128
|
(0, import_react41.useEffect)(() => {
|
|
10091
10129
|
if (valueAsHex !== whatValuePropShouldBe && !isTransitioning) {
|
|
10092
10130
|
onValueChange(whatValuePropShouldBe);
|
|
@@ -10717,6 +10755,9 @@ var Container6 = import_styled_components57.default.div`
|
|
|
10717
10755
|
justify-content: end;
|
|
10718
10756
|
align-items: center;
|
|
10719
10757
|
`;
|
|
10758
|
+
var floorToTenth = (value) => {
|
|
10759
|
+
return Math.floor(value * 10) / 10;
|
|
10760
|
+
};
|
|
10720
10761
|
var ContrastIndicator = () => {
|
|
10721
10762
|
const { currentContrastRatio, minimumContrastRatio } = useColorPickerState();
|
|
10722
10763
|
const isContrastSufficient = currentContrastRatio >= minimumContrastRatio;
|
|
@@ -10736,7 +10777,7 @@ var ContrastIndicator = () => {
|
|
|
10736
10777
|
renderAs: "span",
|
|
10737
10778
|
variant: "body4Mono",
|
|
10738
10779
|
children: [
|
|
10739
|
-
currentContrastRatio.toFixed(
|
|
10780
|
+
floorToTenth(currentContrastRatio).toFixed(1),
|
|
10740
10781
|
":1"
|
|
10741
10782
|
]
|
|
10742
10783
|
}
|
|
@@ -11548,11 +11589,13 @@ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorFor
|
|
|
11548
11589
|
const saturationChanel = x / (width - 1);
|
|
11549
11590
|
const initialValueChannelForSearch = limit === "upper" ? 0 : 1;
|
|
11550
11591
|
const colorForXAsHsv = getAccessibleColorByValueChannelChange({
|
|
11551
|
-
|
|
11592
|
+
originalColor: { h: hue, s: saturationChanel, v: initialValueChannelForSearch, mode: "hsv" },
|
|
11552
11593
|
colorForComparison,
|
|
11553
11594
|
minContrast: minimumContrastRatio,
|
|
11554
11595
|
direction: limit === "upper" ? "brighter" : "darker",
|
|
11555
|
-
opacityForContrastCalculation
|
|
11596
|
+
opacityForContrastCalculation,
|
|
11597
|
+
// We set shouldConvertToHex to false to make the curve smoother.
|
|
11598
|
+
shouldConvertToHex: false
|
|
11556
11599
|
});
|
|
11557
11600
|
if (colorForXAsHsv != null) {
|
|
11558
11601
|
const point = {
|
|
@@ -17005,6 +17048,7 @@ var ContextMenu = ({
|
|
|
17005
17048
|
ValueNameOrHexCode,
|
|
17006
17049
|
ValueSwatch,
|
|
17007
17050
|
WistiaLogo,
|
|
17051
|
+
calculateContrast,
|
|
17008
17052
|
colorSchemeOptions,
|
|
17009
17053
|
copyToClipboard,
|
|
17010
17054
|
dateTime,
|