@wistia/ui 0.13.10-beta.56871fba.15bb8f2 → 0.13.10
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 +51 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -8
- package/dist/index.d.ts +1 -8
- package/dist/index.mjs +52 -88
- 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.10
|
|
3
|
+
* @license @wistia/ui v0.13.10
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -149,7 +149,6 @@ __export(index_exports, {
|
|
|
149
149
|
ValueNameOrHexCode: () => ValueNameOrHexCode,
|
|
150
150
|
ValueSwatch: () => ValueSwatch,
|
|
151
151
|
WistiaLogo: () => WistiaLogo,
|
|
152
|
-
calculateContrast: () => calculateContrast,
|
|
153
152
|
colorSchemeOptions: () => colorSchemeOptions,
|
|
154
153
|
copyToClipboard: () => copyToClipboard,
|
|
155
154
|
dateTime: () => dateTime,
|
|
@@ -9763,16 +9762,6 @@ var compositeOverWhite = (color, alpha = 1) => {
|
|
|
9763
9762
|
b: compositeChannel(colorAsRgb.b)
|
|
9764
9763
|
};
|
|
9765
9764
|
};
|
|
9766
|
-
var calculateContrast = ({
|
|
9767
|
-
backgroundColor,
|
|
9768
|
-
foregroundColor = DEFAULT_COLOR_FOR_COMPARISON,
|
|
9769
|
-
backgroundOpacity = DEFAULT_OPACITY_FOR_CONTRAST_CALCULATION
|
|
9770
|
-
}) => {
|
|
9771
|
-
const backgroundColorAsRgb = convertToRgb(backgroundColor);
|
|
9772
|
-
const foregroundColorAsRgb = convertToRgb(foregroundColor);
|
|
9773
|
-
const compositeBackground = compositeOverWhite(backgroundColorAsRgb, backgroundOpacity);
|
|
9774
|
-
return (0, import_fn3.wcagContrast)(compositeBackground, foregroundColorAsRgb);
|
|
9775
|
-
};
|
|
9776
9765
|
var snapValueToEdges = (value) => {
|
|
9777
9766
|
if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) {
|
|
9778
9767
|
return 1;
|
|
@@ -9795,15 +9784,13 @@ var updateSearchBounds = (searchingBrighter, contrast, minContrast, midValue, se
|
|
|
9795
9784
|
return { newSearchLow: searchLow, newSearchHigh: midValue };
|
|
9796
9785
|
};
|
|
9797
9786
|
var getAccessibleColorByValueChannelChange = ({
|
|
9798
|
-
|
|
9787
|
+
originalHsv,
|
|
9799
9788
|
colorForComparison,
|
|
9800
9789
|
minContrast,
|
|
9801
9790
|
maxIterations = 50,
|
|
9802
9791
|
direction,
|
|
9803
|
-
opacityForContrastCalculation
|
|
9804
|
-
shouldConvertToHex = true
|
|
9792
|
+
opacityForContrastCalculation
|
|
9805
9793
|
}) => {
|
|
9806
|
-
const originalHsv = convertToHsv(originalColor);
|
|
9807
9794
|
const searchingBrighter = direction === "brighter";
|
|
9808
9795
|
const lowValue = searchingBrighter ? originalHsv.v : 0;
|
|
9809
9796
|
const highValue = searchingBrighter ? 1 : originalHsv.v;
|
|
@@ -9814,11 +9801,10 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9814
9801
|
v: extremeValue,
|
|
9815
9802
|
mode: "hsv"
|
|
9816
9803
|
};
|
|
9817
|
-
const extremeContrast =
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
});
|
|
9804
|
+
const extremeContrast = (0, import_fn3.wcagContrast)(
|
|
9805
|
+
compositeOverWhite(extremeVariant, opacityForContrastCalculation),
|
|
9806
|
+
colorForComparison
|
|
9807
|
+
);
|
|
9822
9808
|
if (extremeContrast < minContrast) {
|
|
9823
9809
|
return null;
|
|
9824
9810
|
}
|
|
@@ -9834,11 +9820,10 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9834
9820
|
v: midValue,
|
|
9835
9821
|
mode: "hsv"
|
|
9836
9822
|
};
|
|
9837
|
-
const contrast =
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
});
|
|
9823
|
+
const contrast = (0, import_fn3.wcagContrast)(
|
|
9824
|
+
compositeOverWhite(candidateHsv, opacityForContrastCalculation),
|
|
9825
|
+
colorForComparison
|
|
9826
|
+
);
|
|
9842
9827
|
if (contrast >= minContrast) {
|
|
9843
9828
|
bestSoFar = candidateHsv;
|
|
9844
9829
|
}
|
|
@@ -9858,7 +9843,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9858
9843
|
}
|
|
9859
9844
|
return bestSoFar;
|
|
9860
9845
|
};
|
|
9861
|
-
var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption,
|
|
9846
|
+
var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalHsv) => {
|
|
9862
9847
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9863
9848
|
if (!brighterOption && !darkerOption) {
|
|
9864
9849
|
return null;
|
|
@@ -9869,8 +9854,8 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalC
|
|
|
9869
9854
|
if (!darkerOption && brighterOption != null) {
|
|
9870
9855
|
return brighterOption;
|
|
9871
9856
|
}
|
|
9872
|
-
const brighterDifference = brighterOption === null ? Infinity : hsvDifference(
|
|
9873
|
-
const darkerDifference = darkerOption === null ? Infinity : hsvDifference(
|
|
9857
|
+
const brighterDifference = brighterOption === null ? Infinity : hsvDifference(originalHsv, brighterOption);
|
|
9858
|
+
const darkerDifference = darkerOption === null ? Infinity : hsvDifference(originalHsv, darkerOption);
|
|
9874
9859
|
if (brighterDifference <= darkerDifference && brighterOption != null) {
|
|
9875
9860
|
return brighterOption;
|
|
9876
9861
|
}
|
|
@@ -9880,13 +9865,12 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalC
|
|
|
9880
9865
|
throw new Error("Unable to determine the best accessible color variant");
|
|
9881
9866
|
};
|
|
9882
9867
|
var getAccessibleColorBySaturationAndValueChange = ({
|
|
9883
|
-
|
|
9868
|
+
originalHsv,
|
|
9884
9869
|
colorForComparison,
|
|
9885
9870
|
minContrast,
|
|
9886
9871
|
direction,
|
|
9887
9872
|
opacityForContrastCalculation
|
|
9888
9873
|
}) => {
|
|
9889
|
-
const originalHsv = convertToHsv(originalColor);
|
|
9890
9874
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9891
9875
|
const maxIterations = 50;
|
|
9892
9876
|
let lowStep = 0;
|
|
@@ -9912,11 +9896,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9912
9896
|
};
|
|
9913
9897
|
};
|
|
9914
9898
|
const checkContrast = (hsv) => {
|
|
9915
|
-
return
|
|
9916
|
-
backgroundColor: (0, import_fn3.formatHex)(hsv),
|
|
9917
|
-
foregroundColor: colorForComparison,
|
|
9918
|
-
backgroundOpacity: opacityForContrastCalculation
|
|
9919
|
-
});
|
|
9899
|
+
return (0, import_fn3.wcagContrast)(compositeOverWhite(hsv, opacityForContrastCalculation), colorForComparison);
|
|
9920
9900
|
};
|
|
9921
9901
|
const extremeHsv = getHsvForStep(highStep);
|
|
9922
9902
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9945,7 +9925,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9945
9925
|
return bestCandidate;
|
|
9946
9926
|
};
|
|
9947
9927
|
var getAccessibleColorInDirection = ({
|
|
9948
|
-
|
|
9928
|
+
originalHsv,
|
|
9949
9929
|
colorForComparison,
|
|
9950
9930
|
minContrast,
|
|
9951
9931
|
maxIterations = 50,
|
|
@@ -9953,7 +9933,7 @@ var getAccessibleColorInDirection = ({
|
|
|
9953
9933
|
opacityForContrastCalculation
|
|
9954
9934
|
}) => {
|
|
9955
9935
|
const valueResult = getAccessibleColorByValueChannelChange({
|
|
9956
|
-
|
|
9936
|
+
originalHsv,
|
|
9957
9937
|
colorForComparison,
|
|
9958
9938
|
minContrast,
|
|
9959
9939
|
maxIterations,
|
|
@@ -9964,7 +9944,7 @@ var getAccessibleColorInDirection = ({
|
|
|
9964
9944
|
return valueResult;
|
|
9965
9945
|
}
|
|
9966
9946
|
return getAccessibleColorBySaturationAndValueChange({
|
|
9967
|
-
|
|
9947
|
+
originalHsv,
|
|
9968
9948
|
colorForComparison,
|
|
9969
9949
|
minContrast,
|
|
9970
9950
|
direction,
|
|
@@ -9972,23 +9952,21 @@ var getAccessibleColorInDirection = ({
|
|
|
9972
9952
|
});
|
|
9973
9953
|
};
|
|
9974
9954
|
var getAccessibleColor = ({
|
|
9975
|
-
|
|
9955
|
+
originalHsv,
|
|
9976
9956
|
colorForComparison,
|
|
9977
9957
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9978
9958
|
maxIterations = 50,
|
|
9979
9959
|
opacityForContrastCalculation
|
|
9980
9960
|
}) => {
|
|
9981
|
-
const
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
backgroundOpacity: opacityForContrastCalculation
|
|
9986
|
-
});
|
|
9961
|
+
const originalContrast = (0, import_fn3.wcagContrast)(
|
|
9962
|
+
compositeOverWhite(originalHsv, opacityForContrastCalculation),
|
|
9963
|
+
colorForComparison
|
|
9964
|
+
);
|
|
9987
9965
|
if (originalContrast >= minContrast) {
|
|
9988
|
-
return
|
|
9966
|
+
return originalHsv;
|
|
9989
9967
|
}
|
|
9990
9968
|
const brighterOption = getAccessibleColorInDirection({
|
|
9991
|
-
|
|
9969
|
+
originalHsv,
|
|
9992
9970
|
colorForComparison,
|
|
9993
9971
|
minContrast,
|
|
9994
9972
|
maxIterations,
|
|
@@ -9996,45 +9974,43 @@ var getAccessibleColor = ({
|
|
|
9996
9974
|
opacityForContrastCalculation
|
|
9997
9975
|
});
|
|
9998
9976
|
const darkerOption = getAccessibleColorInDirection({
|
|
9999
|
-
|
|
9977
|
+
originalHsv,
|
|
10000
9978
|
colorForComparison,
|
|
10001
9979
|
minContrast,
|
|
10002
9980
|
maxIterations,
|
|
10003
9981
|
direction: "darker",
|
|
10004
9982
|
opacityForContrastCalculation
|
|
10005
9983
|
});
|
|
10006
|
-
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption,
|
|
9984
|
+
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption, originalHsv);
|
|
10007
9985
|
if (result == null) {
|
|
10008
9986
|
throw new Error(
|
|
10009
|
-
`Unable to get accessible derivative for ${(0, import_fn3.formatHex)(
|
|
9987
|
+
`Unable to get accessible derivative for ${(0, import_fn3.formatHex)(originalHsv)} at minimum contrast ratio ${minContrast}`
|
|
10010
9988
|
);
|
|
10011
9989
|
}
|
|
10012
9990
|
return result;
|
|
10013
9991
|
};
|
|
10014
9992
|
var hasAccessibleDerivatives = ({
|
|
10015
|
-
|
|
9993
|
+
originalHsv,
|
|
10016
9994
|
colorForComparison,
|
|
10017
9995
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
10018
9996
|
opacityForContrastCalculation
|
|
10019
9997
|
}) => {
|
|
10020
|
-
const
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
backgroundOpacity: opacityForContrastCalculation
|
|
10025
|
-
});
|
|
9998
|
+
const originalContrast = (0, import_fn3.wcagContrast)(
|
|
9999
|
+
compositeOverWhite(originalHsv, opacityForContrastCalculation),
|
|
10000
|
+
colorForComparison
|
|
10001
|
+
);
|
|
10026
10002
|
if (originalContrast >= minContrast) {
|
|
10027
10003
|
return true;
|
|
10028
10004
|
}
|
|
10029
10005
|
const brighterOption = getAccessibleColorInDirection({
|
|
10030
|
-
|
|
10006
|
+
originalHsv,
|
|
10031
10007
|
colorForComparison,
|
|
10032
10008
|
minContrast,
|
|
10033
10009
|
direction: "brighter",
|
|
10034
10010
|
opacityForContrastCalculation
|
|
10035
10011
|
});
|
|
10036
10012
|
const darkerOption = getAccessibleColorInDirection({
|
|
10037
|
-
|
|
10013
|
+
originalHsv,
|
|
10038
10014
|
colorForComparison,
|
|
10039
10015
|
minContrast,
|
|
10040
10016
|
direction: "darker",
|
|
@@ -10058,28 +10034,27 @@ var ColorPickerProvider = ({
|
|
|
10058
10034
|
const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
|
|
10059
10035
|
const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
|
|
10060
10036
|
const getAccessibleDerivativeColor = (0, import_react41.useCallback)(
|
|
10061
|
-
(
|
|
10062
|
-
|
|
10037
|
+
(originalHsv) => getAccessibleColor({
|
|
10038
|
+
originalHsv,
|
|
10063
10039
|
colorForComparison,
|
|
10064
10040
|
minContrast: minimumContrastRatio,
|
|
10065
10041
|
opacityForContrastCalculation
|
|
10066
10042
|
}),
|
|
10067
10043
|
[colorForComparison, minimumContrastRatio, opacityForContrastCalculation]
|
|
10068
10044
|
);
|
|
10069
|
-
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(
|
|
10070
|
-
const currentContrastRatio =
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
});
|
|
10045
|
+
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
|
|
10046
|
+
const currentContrastRatio = (0, import_fn4.wcagContrast)(
|
|
10047
|
+
compositeOverWhite(valueAsHsv, opacityForContrastCalculation),
|
|
10048
|
+
colorForComparison
|
|
10049
|
+
);
|
|
10075
10050
|
const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
|
|
10076
10051
|
return hasAccessibleDerivatives({
|
|
10077
|
-
|
|
10052
|
+
originalHsv: valueAsHsv,
|
|
10078
10053
|
colorForComparison,
|
|
10079
10054
|
minContrast: minimumContrastRatio,
|
|
10080
10055
|
opacityForContrastCalculation
|
|
10081
10056
|
});
|
|
10082
|
-
}, [
|
|
10057
|
+
}, [valueAsHsv, colorForComparison, minimumContrastRatio, opacityForContrastCalculation]);
|
|
10083
10058
|
const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
|
|
10084
10059
|
setNonDerivedValueAsHsv(nonDerivedValue);
|
|
10085
10060
|
}, []);
|
|
@@ -10103,21 +10078,15 @@ var ColorPickerProvider = ({
|
|
|
10103
10078
|
const setShouldEnforceMinContrastWrapped = (0, import_react41.useCallback)(
|
|
10104
10079
|
(newShouldEnforceMinContrast) => {
|
|
10105
10080
|
setShouldEnforceMinContrast(newShouldEnforceMinContrast);
|
|
10106
|
-
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(
|
|
10081
|
+
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(valueAsHsv) : nonDerivedValueAsHsv;
|
|
10107
10082
|
const currentHsv = valueAsHsv;
|
|
10108
10083
|
if (currentHsv.h !== newColorAsHsv.h || currentHsv.s !== newColorAsHsv.s || currentHsv.v !== newColorAsHsv.v) {
|
|
10109
10084
|
changeValueSmoothly(newColorAsHsv);
|
|
10110
10085
|
}
|
|
10111
10086
|
},
|
|
10112
|
-
[
|
|
10113
|
-
changeValueSmoothly,
|
|
10114
|
-
getAccessibleDerivativeColor,
|
|
10115
|
-
nonDerivedValueAsHsv,
|
|
10116
|
-
valueAsHex,
|
|
10117
|
-
valueAsHsv
|
|
10118
|
-
]
|
|
10087
|
+
[changeValueSmoothly, getAccessibleDerivativeColor, nonDerivedValueAsHsv, valueAsHsv]
|
|
10119
10088
|
);
|
|
10120
|
-
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor(
|
|
10089
|
+
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor(nonDerivedValueAsHsv)) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
|
|
10121
10090
|
(0, import_react41.useEffect)(() => {
|
|
10122
10091
|
if (valueAsHex !== whatValuePropShouldBe && !isTransitioning) {
|
|
10123
10092
|
onValueChange(whatValuePropShouldBe);
|
|
@@ -10748,9 +10717,6 @@ var Container6 = import_styled_components57.default.div`
|
|
|
10748
10717
|
justify-content: end;
|
|
10749
10718
|
align-items: center;
|
|
10750
10719
|
`;
|
|
10751
|
-
var floorToTenth = (value) => {
|
|
10752
|
-
return Math.floor(value * 10) / 10;
|
|
10753
|
-
};
|
|
10754
10720
|
var ContrastIndicator = () => {
|
|
10755
10721
|
const { currentContrastRatio, minimumContrastRatio } = useColorPickerState();
|
|
10756
10722
|
const isContrastSufficient = currentContrastRatio >= minimumContrastRatio;
|
|
@@ -10770,7 +10736,7 @@ var ContrastIndicator = () => {
|
|
|
10770
10736
|
renderAs: "span",
|
|
10771
10737
|
variant: "body4Mono",
|
|
10772
10738
|
children: [
|
|
10773
|
-
|
|
10739
|
+
currentContrastRatio.toFixed(2),
|
|
10774
10740
|
":1"
|
|
10775
10741
|
]
|
|
10776
10742
|
}
|
|
@@ -11582,13 +11548,11 @@ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorFor
|
|
|
11582
11548
|
const saturationChanel = x / (width - 1);
|
|
11583
11549
|
const initialValueChannelForSearch = limit === "upper" ? 0 : 1;
|
|
11584
11550
|
const colorForXAsHsv = getAccessibleColorByValueChannelChange({
|
|
11585
|
-
|
|
11551
|
+
originalHsv: { h: hue, s: saturationChanel, v: initialValueChannelForSearch, mode: "hsv" },
|
|
11586
11552
|
colorForComparison,
|
|
11587
11553
|
minContrast: minimumContrastRatio,
|
|
11588
11554
|
direction: limit === "upper" ? "brighter" : "darker",
|
|
11589
|
-
opacityForContrastCalculation
|
|
11590
|
-
// We set shouldConvertToHex to false to make the curve smoother.
|
|
11591
|
-
shouldConvertToHex: false
|
|
11555
|
+
opacityForContrastCalculation
|
|
11592
11556
|
});
|
|
11593
11557
|
if (colorForXAsHsv != null) {
|
|
11594
11558
|
const point = {
|
|
@@ -17041,7 +17005,6 @@ var ContextMenu = ({
|
|
|
17041
17005
|
ValueNameOrHexCode,
|
|
17042
17006
|
ValueSwatch,
|
|
17043
17007
|
WistiaLogo,
|
|
17044
|
-
calculateContrast,
|
|
17045
17008
|
colorSchemeOptions,
|
|
17046
17009
|
copyToClipboard,
|
|
17047
17010
|
dateTime,
|