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