@wistia/ui 0.13.10 → 0.13.11-beta.d63b15d9.edae9b7
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 +106 -70
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.mjs +106 -71
- 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.d63b15d9.edae9b7
|
|
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,
|
|
@@ -1675,6 +1676,7 @@ var minutesInHour = 60;
|
|
|
1675
1676
|
var halfAnHourInMinutes = 30;
|
|
1676
1677
|
var hoursInDay = 24;
|
|
1677
1678
|
var milisecondsInSecond = 1e3;
|
|
1679
|
+
var daysInWeek = 7;
|
|
1678
1680
|
var millisecondsInDay = hoursInDay * minutesInHour * secondsInMinute * milisecondsInSecond;
|
|
1679
1681
|
|
|
1680
1682
|
// src/helpers/dateTime/buildTimeDuration.ts
|
|
@@ -1818,7 +1820,7 @@ var dateTimeRounded = (dateTime2, toISOString = true) => {
|
|
|
1818
1820
|
|
|
1819
1821
|
// src/helpers/dateTime/dateTimeString.ts
|
|
1820
1822
|
var import_type_guards3 = require("@wistia/type-guards");
|
|
1821
|
-
var dateTimeString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1823
|
+
var dateTimeString = (date, { timeZone = defaultTimeZone, omitYear = false } = {}) => {
|
|
1822
1824
|
if ((0, import_type_guards3.isNil)(date)) {
|
|
1823
1825
|
return "";
|
|
1824
1826
|
}
|
|
@@ -1827,11 +1829,15 @@ var dateTimeString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
|
1827
1829
|
return "";
|
|
1828
1830
|
}
|
|
1829
1831
|
try {
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1832
|
+
const baseOptions = {
|
|
1833
|
+
month: "short",
|
|
1834
|
+
day: "numeric",
|
|
1835
|
+
hour: "numeric",
|
|
1836
|
+
minute: "2-digit",
|
|
1833
1837
|
timeZone
|
|
1834
|
-
}
|
|
1838
|
+
};
|
|
1839
|
+
const options = omitYear ? baseOptions : { ...baseOptions, year: "numeric" };
|
|
1840
|
+
return formattedDate.toLocaleDateString(defaultLocales, options);
|
|
1835
1841
|
} catch (error) {
|
|
1836
1842
|
console.error(error);
|
|
1837
1843
|
return "";
|
|
@@ -1982,13 +1988,12 @@ var differenceInCalendarDays = (dateLeft, dateRight) => {
|
|
|
1982
1988
|
};
|
|
1983
1989
|
|
|
1984
1990
|
// src/helpers/dateTime/timeAgoString.ts
|
|
1985
|
-
var timeAgoString = (date, { nowAnchor = /* @__PURE__ */ new Date() } = {}) => {
|
|
1986
|
-
if (isInvalidDate(date))
|
|
1987
|
-
return "";
|
|
1988
|
-
}
|
|
1991
|
+
var timeAgoString = (date, { nowAnchor = /* @__PURE__ */ new Date(), includeTime = true } = {}) => {
|
|
1992
|
+
if (isInvalidDate(date)) return "";
|
|
1989
1993
|
const minutesAgo = (nowAnchor.valueOf() - date.valueOf()) / (secondsInMinute * milisecondsInSecond);
|
|
1990
1994
|
const minutesAgoRounded = Math.round(minutesAgo);
|
|
1991
1995
|
const differenceInDays = differenceInCalendarDays(nowAnchor, date);
|
|
1996
|
+
const isSameYear = date.getFullYear() === nowAnchor.getFullYear();
|
|
1992
1997
|
if (minutesAgo < 0) {
|
|
1993
1998
|
return dateTimeString(date);
|
|
1994
1999
|
}
|
|
@@ -2002,20 +2007,15 @@ var timeAgoString = (date, { nowAnchor = /* @__PURE__ */ new Date() } = {}) => {
|
|
|
2002
2007
|
return `${minutesAgoRounded} minutes ago`;
|
|
2003
2008
|
}
|
|
2004
2009
|
if (differenceInDays === 0) {
|
|
2005
|
-
return `Today, ${Intl.DateTimeFormat(defaultLocales, {
|
|
2010
|
+
return includeTime ? `Today, ${Intl.DateTimeFormat(defaultLocales, { hour: "numeric", minute: "2-digit" }).format(date)}` : "Today";
|
|
2006
2011
|
}
|
|
2007
2012
|
if (differenceInDays === 1) {
|
|
2008
|
-
return `Yesterday, ${Intl.DateTimeFormat(defaultLocales, {
|
|
2013
|
+
return includeTime ? `Yesterday, ${Intl.DateTimeFormat(defaultLocales, { hour: "numeric", minute: "2-digit" }).format(date)}` : "Yesterday";
|
|
2009
2014
|
}
|
|
2010
|
-
if (
|
|
2011
|
-
return
|
|
2012
|
-
day: "numeric",
|
|
2013
|
-
month: "short",
|
|
2014
|
-
hour: "numeric",
|
|
2015
|
-
minute: "2-digit"
|
|
2016
|
-
}).format(date);
|
|
2015
|
+
if (differenceInDays < daysInWeek && !includeTime) {
|
|
2016
|
+
return `on ${dayOfWeekString(date)}`;
|
|
2017
2017
|
}
|
|
2018
|
-
return dateTimeString(date);
|
|
2018
|
+
return includeTime ? dateTimeString(date, { omitYear: isSameYear }) : dateOnlyString(date, { omitYear: isSameYear });
|
|
2019
2019
|
};
|
|
2020
2020
|
|
|
2021
2021
|
// src/helpers/dateTime/timeOnlyString.ts
|
|
@@ -9762,6 +9762,16 @@ var compositeOverWhite = (color, alpha = 1) => {
|
|
|
9762
9762
|
b: compositeChannel(colorAsRgb.b)
|
|
9763
9763
|
};
|
|
9764
9764
|
};
|
|
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
|
+
};
|
|
9765
9775
|
var snapValueToEdges = (value) => {
|
|
9766
9776
|
if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) {
|
|
9767
9777
|
return 1;
|
|
@@ -9784,13 +9794,15 @@ var updateSearchBounds = (searchingBrighter, contrast, minContrast, midValue, se
|
|
|
9784
9794
|
return { newSearchLow: searchLow, newSearchHigh: midValue };
|
|
9785
9795
|
};
|
|
9786
9796
|
var getAccessibleColorByValueChannelChange = ({
|
|
9787
|
-
|
|
9797
|
+
originalColor,
|
|
9788
9798
|
colorForComparison,
|
|
9789
9799
|
minContrast,
|
|
9790
9800
|
maxIterations = 50,
|
|
9791
9801
|
direction,
|
|
9792
|
-
opacityForContrastCalculation
|
|
9802
|
+
opacityForContrastCalculation,
|
|
9803
|
+
shouldConvertToHex = true
|
|
9793
9804
|
}) => {
|
|
9805
|
+
const originalHsv = convertToHsv(originalColor);
|
|
9794
9806
|
const searchingBrighter = direction === "brighter";
|
|
9795
9807
|
const lowValue = searchingBrighter ? originalHsv.v : 0;
|
|
9796
9808
|
const highValue = searchingBrighter ? 1 : originalHsv.v;
|
|
@@ -9801,10 +9813,11 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9801
9813
|
v: extremeValue,
|
|
9802
9814
|
mode: "hsv"
|
|
9803
9815
|
};
|
|
9804
|
-
const extremeContrast = (
|
|
9805
|
-
|
|
9806
|
-
colorForComparison
|
|
9807
|
-
|
|
9816
|
+
const extremeContrast = calculateContrast({
|
|
9817
|
+
backgroundColor: shouldConvertToHex ? (0, import_fn3.formatHex)(extremeVariant) : extremeVariant,
|
|
9818
|
+
foregroundColor: colorForComparison,
|
|
9819
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9820
|
+
});
|
|
9808
9821
|
if (extremeContrast < minContrast) {
|
|
9809
9822
|
return null;
|
|
9810
9823
|
}
|
|
@@ -9820,10 +9833,11 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9820
9833
|
v: midValue,
|
|
9821
9834
|
mode: "hsv"
|
|
9822
9835
|
};
|
|
9823
|
-
const contrast = (
|
|
9824
|
-
|
|
9825
|
-
colorForComparison
|
|
9826
|
-
|
|
9836
|
+
const contrast = calculateContrast({
|
|
9837
|
+
backgroundColor: shouldConvertToHex ? (0, import_fn3.formatHex)(candidateHsv) : candidateHsv,
|
|
9838
|
+
foregroundColor: colorForComparison,
|
|
9839
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9840
|
+
});
|
|
9827
9841
|
if (contrast >= minContrast) {
|
|
9828
9842
|
bestSoFar = candidateHsv;
|
|
9829
9843
|
}
|
|
@@ -9843,7 +9857,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9843
9857
|
}
|
|
9844
9858
|
return bestSoFar;
|
|
9845
9859
|
};
|
|
9846
|
-
var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption,
|
|
9860
|
+
var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalColor) => {
|
|
9847
9861
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9848
9862
|
if (!brighterOption && !darkerOption) {
|
|
9849
9863
|
return null;
|
|
@@ -9854,8 +9868,8 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalH
|
|
|
9854
9868
|
if (!darkerOption && brighterOption != null) {
|
|
9855
9869
|
return brighterOption;
|
|
9856
9870
|
}
|
|
9857
|
-
const brighterDifference = brighterOption === null ? Infinity : hsvDifference(
|
|
9858
|
-
const darkerDifference = darkerOption === null ? Infinity : hsvDifference(
|
|
9871
|
+
const brighterDifference = brighterOption === null ? Infinity : hsvDifference(originalColor, brighterOption);
|
|
9872
|
+
const darkerDifference = darkerOption === null ? Infinity : hsvDifference(originalColor, darkerOption);
|
|
9859
9873
|
if (brighterDifference <= darkerDifference && brighterOption != null) {
|
|
9860
9874
|
return brighterOption;
|
|
9861
9875
|
}
|
|
@@ -9865,12 +9879,13 @@ var chooseClosestDerivativeToOriginal = (brighterOption, darkerOption, originalH
|
|
|
9865
9879
|
throw new Error("Unable to determine the best accessible color variant");
|
|
9866
9880
|
};
|
|
9867
9881
|
var getAccessibleColorBySaturationAndValueChange = ({
|
|
9868
|
-
|
|
9882
|
+
originalColor,
|
|
9869
9883
|
colorForComparison,
|
|
9870
9884
|
minContrast,
|
|
9871
9885
|
direction,
|
|
9872
9886
|
opacityForContrastCalculation
|
|
9873
9887
|
}) => {
|
|
9888
|
+
const originalHsv = convertToHsv(originalColor);
|
|
9874
9889
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9875
9890
|
const maxIterations = 50;
|
|
9876
9891
|
let lowStep = 0;
|
|
@@ -9896,7 +9911,11 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9896
9911
|
};
|
|
9897
9912
|
};
|
|
9898
9913
|
const checkContrast = (hsv) => {
|
|
9899
|
-
return (
|
|
9914
|
+
return calculateContrast({
|
|
9915
|
+
backgroundColor: (0, import_fn3.formatHex)(hsv),
|
|
9916
|
+
foregroundColor: colorForComparison,
|
|
9917
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9918
|
+
});
|
|
9900
9919
|
};
|
|
9901
9920
|
const extremeHsv = getHsvForStep(highStep);
|
|
9902
9921
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9925,7 +9944,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9925
9944
|
return bestCandidate;
|
|
9926
9945
|
};
|
|
9927
9946
|
var getAccessibleColorInDirection = ({
|
|
9928
|
-
|
|
9947
|
+
originalColor,
|
|
9929
9948
|
colorForComparison,
|
|
9930
9949
|
minContrast,
|
|
9931
9950
|
maxIterations = 50,
|
|
@@ -9933,7 +9952,7 @@ var getAccessibleColorInDirection = ({
|
|
|
9933
9952
|
opacityForContrastCalculation
|
|
9934
9953
|
}) => {
|
|
9935
9954
|
const valueResult = getAccessibleColorByValueChannelChange({
|
|
9936
|
-
|
|
9955
|
+
originalColor,
|
|
9937
9956
|
colorForComparison,
|
|
9938
9957
|
minContrast,
|
|
9939
9958
|
maxIterations,
|
|
@@ -9944,7 +9963,7 @@ var getAccessibleColorInDirection = ({
|
|
|
9944
9963
|
return valueResult;
|
|
9945
9964
|
}
|
|
9946
9965
|
return getAccessibleColorBySaturationAndValueChange({
|
|
9947
|
-
|
|
9966
|
+
originalColor,
|
|
9948
9967
|
colorForComparison,
|
|
9949
9968
|
minContrast,
|
|
9950
9969
|
direction,
|
|
@@ -9952,21 +9971,23 @@ var getAccessibleColorInDirection = ({
|
|
|
9952
9971
|
});
|
|
9953
9972
|
};
|
|
9954
9973
|
var getAccessibleColor = ({
|
|
9955
|
-
|
|
9974
|
+
originalColor,
|
|
9956
9975
|
colorForComparison,
|
|
9957
9976
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9958
9977
|
maxIterations = 50,
|
|
9959
9978
|
opacityForContrastCalculation
|
|
9960
9979
|
}) => {
|
|
9961
|
-
const
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9980
|
+
const originalColorAsHsv = convertToHsv(originalColor);
|
|
9981
|
+
const originalContrast = calculateContrast({
|
|
9982
|
+
backgroundColor: (0, import_fn3.formatHex)(originalColorAsHsv),
|
|
9983
|
+
foregroundColor: colorForComparison,
|
|
9984
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
9985
|
+
});
|
|
9965
9986
|
if (originalContrast >= minContrast) {
|
|
9966
|
-
return
|
|
9987
|
+
return convertToHsv(originalColor);
|
|
9967
9988
|
}
|
|
9968
9989
|
const brighterOption = getAccessibleColorInDirection({
|
|
9969
|
-
|
|
9990
|
+
originalColor,
|
|
9970
9991
|
colorForComparison,
|
|
9971
9992
|
minContrast,
|
|
9972
9993
|
maxIterations,
|
|
@@ -9974,43 +9995,45 @@ var getAccessibleColor = ({
|
|
|
9974
9995
|
opacityForContrastCalculation
|
|
9975
9996
|
});
|
|
9976
9997
|
const darkerOption = getAccessibleColorInDirection({
|
|
9977
|
-
|
|
9998
|
+
originalColor,
|
|
9978
9999
|
colorForComparison,
|
|
9979
10000
|
minContrast,
|
|
9980
10001
|
maxIterations,
|
|
9981
10002
|
direction: "darker",
|
|
9982
10003
|
opacityForContrastCalculation
|
|
9983
10004
|
});
|
|
9984
|
-
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption,
|
|
10005
|
+
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption, originalColor);
|
|
9985
10006
|
if (result == null) {
|
|
9986
10007
|
throw new Error(
|
|
9987
|
-
`Unable to get accessible derivative for ${(0, import_fn3.formatHex)(
|
|
10008
|
+
`Unable to get accessible derivative for ${(0, import_fn3.formatHex)(originalColor)} at minimum contrast ratio ${minContrast}`
|
|
9988
10009
|
);
|
|
9989
10010
|
}
|
|
9990
10011
|
return result;
|
|
9991
10012
|
};
|
|
9992
10013
|
var hasAccessibleDerivatives = ({
|
|
9993
|
-
|
|
10014
|
+
originalColor,
|
|
9994
10015
|
colorForComparison,
|
|
9995
10016
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9996
10017
|
opacityForContrastCalculation
|
|
9997
10018
|
}) => {
|
|
9998
|
-
const
|
|
9999
|
-
|
|
10000
|
-
|
|
10001
|
-
|
|
10019
|
+
const originalColorAsHsv = convertToHsv(originalColor);
|
|
10020
|
+
const originalContrast = calculateContrast({
|
|
10021
|
+
backgroundColor: (0, import_fn3.formatHex)(originalColorAsHsv),
|
|
10022
|
+
foregroundColor: colorForComparison,
|
|
10023
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
10024
|
+
});
|
|
10002
10025
|
if (originalContrast >= minContrast) {
|
|
10003
10026
|
return true;
|
|
10004
10027
|
}
|
|
10005
10028
|
const brighterOption = getAccessibleColorInDirection({
|
|
10006
|
-
|
|
10029
|
+
originalColor,
|
|
10007
10030
|
colorForComparison,
|
|
10008
10031
|
minContrast,
|
|
10009
10032
|
direction: "brighter",
|
|
10010
10033
|
opacityForContrastCalculation
|
|
10011
10034
|
});
|
|
10012
10035
|
const darkerOption = getAccessibleColorInDirection({
|
|
10013
|
-
|
|
10036
|
+
originalColor,
|
|
10014
10037
|
colorForComparison,
|
|
10015
10038
|
minContrast,
|
|
10016
10039
|
direction: "darker",
|
|
@@ -10034,27 +10057,28 @@ var ColorPickerProvider = ({
|
|
|
10034
10057
|
const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
|
|
10035
10058
|
const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
|
|
10036
10059
|
const getAccessibleDerivativeColor = (0, import_react41.useCallback)(
|
|
10037
|
-
(
|
|
10038
|
-
|
|
10060
|
+
(originalColor) => getAccessibleColor({
|
|
10061
|
+
originalColor,
|
|
10039
10062
|
colorForComparison,
|
|
10040
10063
|
minContrast: minimumContrastRatio,
|
|
10041
10064
|
opacityForContrastCalculation
|
|
10042
10065
|
}),
|
|
10043
10066
|
[colorForComparison, minimumContrastRatio, opacityForContrastCalculation]
|
|
10044
10067
|
);
|
|
10045
|
-
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
|
|
10046
|
-
const currentContrastRatio = (
|
|
10047
|
-
|
|
10048
|
-
colorForComparison
|
|
10049
|
-
|
|
10068
|
+
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor((0, import_fn4.formatHex)(nonDerivedValueAsHsv)) : nonDerivedValueAsHsv;
|
|
10069
|
+
const currentContrastRatio = calculateContrast({
|
|
10070
|
+
backgroundColor: valueAsHex,
|
|
10071
|
+
foregroundColor: colorForComparison,
|
|
10072
|
+
backgroundOpacity: opacityForContrastCalculation
|
|
10073
|
+
});
|
|
10050
10074
|
const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
|
|
10051
10075
|
return hasAccessibleDerivatives({
|
|
10052
|
-
|
|
10076
|
+
originalColor: valueAsHex,
|
|
10053
10077
|
colorForComparison,
|
|
10054
10078
|
minContrast: minimumContrastRatio,
|
|
10055
10079
|
opacityForContrastCalculation
|
|
10056
10080
|
});
|
|
10057
|
-
}, [
|
|
10081
|
+
}, [valueAsHex, colorForComparison, minimumContrastRatio, opacityForContrastCalculation]);
|
|
10058
10082
|
const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
|
|
10059
10083
|
setNonDerivedValueAsHsv(nonDerivedValue);
|
|
10060
10084
|
}, []);
|
|
@@ -10078,15 +10102,21 @@ var ColorPickerProvider = ({
|
|
|
10078
10102
|
const setShouldEnforceMinContrastWrapped = (0, import_react41.useCallback)(
|
|
10079
10103
|
(newShouldEnforceMinContrast) => {
|
|
10080
10104
|
setShouldEnforceMinContrast(newShouldEnforceMinContrast);
|
|
10081
|
-
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(
|
|
10105
|
+
const newColorAsHsv = newShouldEnforceMinContrast ? getAccessibleDerivativeColor(valueAsHex) : nonDerivedValueAsHsv;
|
|
10082
10106
|
const currentHsv = valueAsHsv;
|
|
10083
10107
|
if (currentHsv.h !== newColorAsHsv.h || currentHsv.s !== newColorAsHsv.s || currentHsv.v !== newColorAsHsv.v) {
|
|
10084
10108
|
changeValueSmoothly(newColorAsHsv);
|
|
10085
10109
|
}
|
|
10086
10110
|
},
|
|
10087
|
-
[
|
|
10111
|
+
[
|
|
10112
|
+
changeValueSmoothly,
|
|
10113
|
+
getAccessibleDerivativeColor,
|
|
10114
|
+
nonDerivedValueAsHsv,
|
|
10115
|
+
valueAsHex,
|
|
10116
|
+
valueAsHsv
|
|
10117
|
+
]
|
|
10088
10118
|
);
|
|
10089
|
-
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor(nonDerivedValueAsHsv)) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
|
|
10119
|
+
const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor((0, import_fn4.formatHex)(nonDerivedValueAsHsv))) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
|
|
10090
10120
|
(0, import_react41.useEffect)(() => {
|
|
10091
10121
|
if (valueAsHex !== whatValuePropShouldBe && !isTransitioning) {
|
|
10092
10122
|
onValueChange(whatValuePropShouldBe);
|
|
@@ -10717,6 +10747,9 @@ var Container6 = import_styled_components57.default.div`
|
|
|
10717
10747
|
justify-content: end;
|
|
10718
10748
|
align-items: center;
|
|
10719
10749
|
`;
|
|
10750
|
+
var floorToTenth = (value) => {
|
|
10751
|
+
return Math.floor(value * 10) / 10;
|
|
10752
|
+
};
|
|
10720
10753
|
var ContrastIndicator = () => {
|
|
10721
10754
|
const { currentContrastRatio, minimumContrastRatio } = useColorPickerState();
|
|
10722
10755
|
const isContrastSufficient = currentContrastRatio >= minimumContrastRatio;
|
|
@@ -10736,7 +10769,7 @@ var ContrastIndicator = () => {
|
|
|
10736
10769
|
renderAs: "span",
|
|
10737
10770
|
variant: "body4Mono",
|
|
10738
10771
|
children: [
|
|
10739
|
-
currentContrastRatio.toFixed(
|
|
10772
|
+
floorToTenth(currentContrastRatio).toFixed(1),
|
|
10740
10773
|
":1"
|
|
10741
10774
|
]
|
|
10742
10775
|
}
|
|
@@ -11548,11 +11581,13 @@ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorFor
|
|
|
11548
11581
|
const saturationChanel = x / (width - 1);
|
|
11549
11582
|
const initialValueChannelForSearch = limit === "upper" ? 0 : 1;
|
|
11550
11583
|
const colorForXAsHsv = getAccessibleColorByValueChannelChange({
|
|
11551
|
-
|
|
11584
|
+
originalColor: { h: hue, s: saturationChanel, v: initialValueChannelForSearch, mode: "hsv" },
|
|
11552
11585
|
colorForComparison,
|
|
11553
11586
|
minContrast: minimumContrastRatio,
|
|
11554
11587
|
direction: limit === "upper" ? "brighter" : "darker",
|
|
11555
|
-
opacityForContrastCalculation
|
|
11588
|
+
opacityForContrastCalculation,
|
|
11589
|
+
// We set shouldConvertToHex to false to make the curve smoother.
|
|
11590
|
+
shouldConvertToHex: false
|
|
11556
11591
|
});
|
|
11557
11592
|
if (colorForXAsHsv != null) {
|
|
11558
11593
|
const point = {
|
|
@@ -17005,6 +17040,7 @@ var ContextMenu = ({
|
|
|
17005
17040
|
ValueNameOrHexCode,
|
|
17006
17041
|
ValueSwatch,
|
|
17007
17042
|
WistiaLogo,
|
|
17043
|
+
calculateContrast,
|
|
17008
17044
|
colorSchemeOptions,
|
|
17009
17045
|
copyToClipboard,
|
|
17010
17046
|
dateTime,
|