@wistia/ui 0.13.5-beta.ab523c1c.ae6e767 → 0.13.5
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 +46 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +9 -13
- package/dist/index.d.ts +9 -13
- package/dist/index.mjs +43 -103
- 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.5
|
|
3
|
+
* @license @wistia/ui v0.13.5
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -9745,21 +9745,10 @@ var THREE_SIXTY = 360;
|
|
|
9745
9745
|
var TWO_FIFTY_FIVE = 255;
|
|
9746
9746
|
var DEFAULT_MIN_CONTRAST = 4.5;
|
|
9747
9747
|
var DEFAULT_COLOR_FOR_COMPARISON = "#ffffff";
|
|
9748
|
-
var DEFAULT_OPACITY_FOR_CONTRAST_CALCULATION = 1;
|
|
9749
9748
|
|
|
9750
9749
|
// src/components/ColorPicker/contrast-utils.ts
|
|
9751
9750
|
var CONTRAST_EPSILON = 4e-3;
|
|
9752
9751
|
var VALUE_CHANNEL_SNAP_EPSILON = 5e-4;
|
|
9753
|
-
var compositeOverWhite = (color, alpha = 1) => {
|
|
9754
|
-
const compositeChannel = (channel) => alpha * channel + (1 - alpha);
|
|
9755
|
-
const colorAsRgb = convertToRgb(color);
|
|
9756
|
-
return {
|
|
9757
|
-
mode: "rgb",
|
|
9758
|
-
r: compositeChannel(colorAsRgb.r),
|
|
9759
|
-
g: compositeChannel(colorAsRgb.g),
|
|
9760
|
-
b: compositeChannel(colorAsRgb.b)
|
|
9761
|
-
};
|
|
9762
|
-
};
|
|
9763
9752
|
var snapValueToEdges = (value) => {
|
|
9764
9753
|
if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) {
|
|
9765
9754
|
return 1;
|
|
@@ -9786,8 +9775,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9786
9775
|
colorForComparison,
|
|
9787
9776
|
minContrast,
|
|
9788
9777
|
maxIterations = 50,
|
|
9789
|
-
direction
|
|
9790
|
-
opacityForContrastCalculation
|
|
9778
|
+
direction
|
|
9791
9779
|
}) => {
|
|
9792
9780
|
const searchingBrighter = direction === "brighter";
|
|
9793
9781
|
const lowValue = searchingBrighter ? originalHsv.v : 0;
|
|
@@ -9799,10 +9787,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9799
9787
|
v: extremeValue,
|
|
9800
9788
|
mode: "hsv"
|
|
9801
9789
|
};
|
|
9802
|
-
const extremeContrast = (0, import_fn3.wcagContrast)(
|
|
9803
|
-
compositeOverWhite(extremeVariant, opacityForContrastCalculation),
|
|
9804
|
-
colorForComparison
|
|
9805
|
-
);
|
|
9790
|
+
const extremeContrast = (0, import_fn3.wcagContrast)(extremeVariant, colorForComparison);
|
|
9806
9791
|
if (extremeContrast < minContrast) {
|
|
9807
9792
|
return null;
|
|
9808
9793
|
}
|
|
@@ -9818,10 +9803,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9818
9803
|
v: midValue,
|
|
9819
9804
|
mode: "hsv"
|
|
9820
9805
|
};
|
|
9821
|
-
const contrast = (0, import_fn3.wcagContrast)(
|
|
9822
|
-
compositeOverWhite(candidateHsv, opacityForContrastCalculation),
|
|
9823
|
-
colorForComparison
|
|
9824
|
-
);
|
|
9806
|
+
const contrast = (0, import_fn3.wcagContrast)(candidateHsv, colorForComparison);
|
|
9825
9807
|
if (contrast >= minContrast) {
|
|
9826
9808
|
bestSoFar = candidateHsv;
|
|
9827
9809
|
}
|
|
@@ -9866,8 +9848,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9866
9848
|
originalHsv,
|
|
9867
9849
|
colorForComparison,
|
|
9868
9850
|
minContrast,
|
|
9869
|
-
direction
|
|
9870
|
-
opacityForContrastCalculation
|
|
9851
|
+
direction
|
|
9871
9852
|
}) => {
|
|
9872
9853
|
const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
|
|
9873
9854
|
const maxIterations = 50;
|
|
@@ -9894,7 +9875,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9894
9875
|
};
|
|
9895
9876
|
};
|
|
9896
9877
|
const checkContrast = (hsv) => {
|
|
9897
|
-
return (0, import_fn3.wcagContrast)(
|
|
9878
|
+
return (0, import_fn3.wcagContrast)(hsv, colorForComparison);
|
|
9898
9879
|
};
|
|
9899
9880
|
const extremeHsv = getHsvForStep(highStep);
|
|
9900
9881
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9927,16 +9908,14 @@ var getAccessibleColorInDirection = ({
|
|
|
9927
9908
|
colorForComparison,
|
|
9928
9909
|
minContrast,
|
|
9929
9910
|
maxIterations = 50,
|
|
9930
|
-
direction
|
|
9931
|
-
opacityForContrastCalculation
|
|
9911
|
+
direction
|
|
9932
9912
|
}) => {
|
|
9933
9913
|
const valueResult = getAccessibleColorByValueChannelChange({
|
|
9934
9914
|
originalHsv,
|
|
9935
9915
|
colorForComparison,
|
|
9936
9916
|
minContrast,
|
|
9937
9917
|
maxIterations,
|
|
9938
|
-
direction
|
|
9939
|
-
opacityForContrastCalculation
|
|
9918
|
+
direction
|
|
9940
9919
|
});
|
|
9941
9920
|
if (valueResult !== null) {
|
|
9942
9921
|
return valueResult;
|
|
@@ -9945,21 +9924,16 @@ var getAccessibleColorInDirection = ({
|
|
|
9945
9924
|
originalHsv,
|
|
9946
9925
|
colorForComparison,
|
|
9947
9926
|
minContrast,
|
|
9948
|
-
direction
|
|
9949
|
-
opacityForContrastCalculation
|
|
9927
|
+
direction
|
|
9950
9928
|
});
|
|
9951
9929
|
};
|
|
9952
9930
|
var getAccessibleColor = ({
|
|
9953
9931
|
originalHsv,
|
|
9954
9932
|
colorForComparison,
|
|
9955
9933
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9956
|
-
maxIterations = 50
|
|
9957
|
-
opacityForContrastCalculation
|
|
9934
|
+
maxIterations = 50
|
|
9958
9935
|
}) => {
|
|
9959
|
-
const originalContrast = (0, import_fn3.wcagContrast)(
|
|
9960
|
-
compositeOverWhite(originalHsv, opacityForContrastCalculation),
|
|
9961
|
-
colorForComparison
|
|
9962
|
-
);
|
|
9936
|
+
const originalContrast = (0, import_fn3.wcagContrast)(originalHsv, colorForComparison);
|
|
9963
9937
|
if (originalContrast >= minContrast) {
|
|
9964
9938
|
return originalHsv;
|
|
9965
9939
|
}
|
|
@@ -9968,16 +9942,14 @@ var getAccessibleColor = ({
|
|
|
9968
9942
|
colorForComparison,
|
|
9969
9943
|
minContrast,
|
|
9970
9944
|
maxIterations,
|
|
9971
|
-
direction: "brighter"
|
|
9972
|
-
opacityForContrastCalculation
|
|
9945
|
+
direction: "brighter"
|
|
9973
9946
|
});
|
|
9974
9947
|
const darkerOption = getAccessibleColorInDirection({
|
|
9975
9948
|
originalHsv,
|
|
9976
9949
|
colorForComparison,
|
|
9977
9950
|
minContrast,
|
|
9978
9951
|
maxIterations,
|
|
9979
|
-
direction: "darker"
|
|
9980
|
-
opacityForContrastCalculation
|
|
9952
|
+
direction: "darker"
|
|
9981
9953
|
});
|
|
9982
9954
|
const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption, originalHsv);
|
|
9983
9955
|
if (result == null) {
|
|
@@ -9990,13 +9962,9 @@ var getAccessibleColor = ({
|
|
|
9990
9962
|
var hasAccessibleDerivatives = ({
|
|
9991
9963
|
originalHsv,
|
|
9992
9964
|
colorForComparison,
|
|
9993
|
-
minContrast = DEFAULT_MIN_CONTRAST
|
|
9994
|
-
opacityForContrastCalculation
|
|
9965
|
+
minContrast = DEFAULT_MIN_CONTRAST
|
|
9995
9966
|
}) => {
|
|
9996
|
-
const originalContrast = (0, import_fn3.wcagContrast)(
|
|
9997
|
-
compositeOverWhite(originalHsv, opacityForContrastCalculation),
|
|
9998
|
-
colorForComparison
|
|
9999
|
-
);
|
|
9967
|
+
const originalContrast = (0, import_fn3.wcagContrast)(originalHsv, colorForComparison);
|
|
10000
9968
|
if (originalContrast >= minContrast) {
|
|
10001
9969
|
return true;
|
|
10002
9970
|
}
|
|
@@ -10004,15 +9972,13 @@ var hasAccessibleDerivatives = ({
|
|
|
10004
9972
|
originalHsv,
|
|
10005
9973
|
colorForComparison,
|
|
10006
9974
|
minContrast,
|
|
10007
|
-
direction: "brighter"
|
|
10008
|
-
opacityForContrastCalculation
|
|
9975
|
+
direction: "brighter"
|
|
10009
9976
|
});
|
|
10010
9977
|
const darkerOption = getAccessibleColorInDirection({
|
|
10011
9978
|
originalHsv,
|
|
10012
9979
|
colorForComparison,
|
|
10013
9980
|
minContrast,
|
|
10014
|
-
direction: "darker"
|
|
10015
|
-
opacityForContrastCalculation
|
|
9981
|
+
direction: "darker"
|
|
10016
9982
|
});
|
|
10017
9983
|
return brighterOption !== null || darkerOption !== null;
|
|
10018
9984
|
};
|
|
@@ -10022,11 +9988,10 @@ var import_jsx_runtime225 = require("react/jsx-runtime");
|
|
|
10022
9988
|
var ColorPickerContext = (0, import_react41.createContext)(null);
|
|
10023
9989
|
var ColorPickerProvider = ({
|
|
10024
9990
|
children,
|
|
10025
|
-
|
|
10026
|
-
minimumContrastRatio,
|
|
9991
|
+
value: valueAsHex,
|
|
10027
9992
|
onValueChange,
|
|
10028
|
-
|
|
10029
|
-
|
|
9993
|
+
minimumContrastRatio = DEFAULT_MIN_CONTRAST,
|
|
9994
|
+
colorForComparison = DEFAULT_COLOR_FOR_COMPARISON
|
|
10030
9995
|
}) => {
|
|
10031
9996
|
const [isTransitioning, setIsTransitioning] = (0, import_react41.useState)(false);
|
|
10032
9997
|
const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
|
|
@@ -10035,24 +10000,19 @@ var ColorPickerProvider = ({
|
|
|
10035
10000
|
(originalHsv) => getAccessibleColor({
|
|
10036
10001
|
originalHsv,
|
|
10037
10002
|
colorForComparison,
|
|
10038
|
-
minContrast: minimumContrastRatio
|
|
10039
|
-
opacityForContrastCalculation
|
|
10003
|
+
minContrast: minimumContrastRatio
|
|
10040
10004
|
}),
|
|
10041
|
-
[
|
|
10005
|
+
[minimumContrastRatio, colorForComparison]
|
|
10042
10006
|
);
|
|
10043
10007
|
const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
|
|
10044
|
-
const currentContrastRatio = (0, import_fn4.wcagContrast)(
|
|
10045
|
-
compositeOverWhite(valueAsHsv, opacityForContrastCalculation),
|
|
10046
|
-
colorForComparison
|
|
10047
|
-
);
|
|
10008
|
+
const currentContrastRatio = (0, import_fn4.wcagContrast)(valueAsHsv, colorForComparison);
|
|
10048
10009
|
const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
|
|
10049
10010
|
return hasAccessibleDerivatives({
|
|
10050
10011
|
originalHsv: valueAsHsv,
|
|
10051
10012
|
colorForComparison,
|
|
10052
|
-
minContrast: minimumContrastRatio
|
|
10053
|
-
opacityForContrastCalculation
|
|
10013
|
+
minContrast: minimumContrastRatio
|
|
10054
10014
|
});
|
|
10055
|
-
}, [valueAsHsv, colorForComparison, minimumContrastRatio
|
|
10015
|
+
}, [valueAsHsv, colorForComparison, minimumContrastRatio]);
|
|
10056
10016
|
const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
|
|
10057
10017
|
setNonDerivedValueAsHsv(nonDerivedValue);
|
|
10058
10018
|
}, []);
|
|
@@ -10101,7 +10061,6 @@ var ColorPickerProvider = ({
|
|
|
10101
10061
|
nonDerivedValueAsHex: (0, import_fn4.formatHex)(nonDerivedValueAsHsv),
|
|
10102
10062
|
nonDerivedValueAsHsv,
|
|
10103
10063
|
onChangeNonDerivedValueAsHsv,
|
|
10104
|
-
opacityForContrastCalculation,
|
|
10105
10064
|
setShouldEnforceMinContrast: setShouldEnforceMinContrastWrapped,
|
|
10106
10065
|
shouldEnforceMinContrast,
|
|
10107
10066
|
valueAsHex,
|
|
@@ -10116,7 +10075,6 @@ var ColorPickerProvider = ({
|
|
|
10116
10075
|
minimumContrastRatio,
|
|
10117
10076
|
nonDerivedValueAsHsv,
|
|
10118
10077
|
onChangeNonDerivedValueAsHsv,
|
|
10119
|
-
opacityForContrastCalculation,
|
|
10120
10078
|
setShouldEnforceMinContrastWrapped,
|
|
10121
10079
|
shouldEnforceMinContrast,
|
|
10122
10080
|
valueAsHex,
|
|
@@ -10166,7 +10124,6 @@ ColorGrid.displayName = "ColorGrid_UI";
|
|
|
10166
10124
|
// src/components/ColorPicker/ColorGridOption.tsx
|
|
10167
10125
|
var import_styled_components50 = __toESM(require("styled-components"));
|
|
10168
10126
|
var import_react_radio_group2 = require("@radix-ui/react-radio-group");
|
|
10169
|
-
var import_fn5 = require("culori/fn");
|
|
10170
10127
|
|
|
10171
10128
|
// src/components/ColorPicker/ColorSwatch.tsx
|
|
10172
10129
|
var import_styled_components48 = __toESM(require("styled-components"));
|
|
@@ -10387,8 +10344,7 @@ var Container2 = (0, import_styled_components50.default)(import_react_radio_grou
|
|
|
10387
10344
|
user-select: none;
|
|
10388
10345
|
`;
|
|
10389
10346
|
var ColorGridOption = ({ value, name }) => {
|
|
10390
|
-
const {
|
|
10391
|
-
const valueAsHex = (0, import_fn5.formatHex)(valueAsHsv);
|
|
10347
|
+
const { valueAsHex, nonDerivedValueAsHex } = useColorPickerState();
|
|
10392
10348
|
const isSelected = valueAsHex === value;
|
|
10393
10349
|
const derivativeIsSelected = !isSelected && nonDerivedValueAsHex === value;
|
|
10394
10350
|
return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)(
|
|
@@ -10485,7 +10441,6 @@ ColorListGroup.displayName = "ColorListGroup_UI";
|
|
|
10485
10441
|
// src/components/ColorPicker/ColorListOption.tsx
|
|
10486
10442
|
var import_styled_components53 = __toESM(require("styled-components"));
|
|
10487
10443
|
var import_react_toggle_group2 = require("@radix-ui/react-toggle-group");
|
|
10488
|
-
var import_fn6 = require("culori/fn");
|
|
10489
10444
|
|
|
10490
10445
|
// src/components/ColorPicker/ColorNameOrHexCode.tsx
|
|
10491
10446
|
var import_jsx_runtime232 = require("react/jsx-runtime");
|
|
@@ -10545,8 +10500,7 @@ var Container4 = (0, import_styled_components53.default)(import_react_toggle_gro
|
|
|
10545
10500
|
}
|
|
10546
10501
|
`;
|
|
10547
10502
|
var ColorListOption = ({ value, name }) => {
|
|
10548
|
-
const {
|
|
10549
|
-
const valueAsHex = (0, import_fn6.formatHex)(valueAsHsv);
|
|
10503
|
+
const { valueAsHex, nonDerivedValueAsHex } = useColorPickerState();
|
|
10550
10504
|
const isSelected = valueAsHex === value;
|
|
10551
10505
|
const derivativeIsSelected = !isSelected && nonDerivedValueAsHex === value;
|
|
10552
10506
|
return /* @__PURE__ */ (0, import_jsx_runtime233.jsxs)(
|
|
@@ -10586,7 +10540,6 @@ var ColorPicker = ({
|
|
|
10586
10540
|
children,
|
|
10587
10541
|
colorForComparison = DEFAULT_COLOR_FOR_COMPARISON,
|
|
10588
10542
|
minimumContrastRatio = DEFAULT_MIN_CONTRAST,
|
|
10589
|
-
opacityForContrastCalculation = DEFAULT_OPACITY_FOR_CONTRAST_CALCULATION,
|
|
10590
10543
|
onValueChange,
|
|
10591
10544
|
value
|
|
10592
10545
|
}) => {
|
|
@@ -10596,7 +10549,6 @@ var ColorPicker = ({
|
|
|
10596
10549
|
colorForComparison,
|
|
10597
10550
|
minimumContrastRatio,
|
|
10598
10551
|
onValueChange,
|
|
10599
|
-
opacityForContrastCalculation,
|
|
10600
10552
|
value,
|
|
10601
10553
|
children
|
|
10602
10554
|
}
|
|
@@ -10991,7 +10943,7 @@ ContrastControls.displayName = "ContrastControls_UI";
|
|
|
10991
10943
|
|
|
10992
10944
|
// src/components/ColorPicker/HexColorInput.tsx
|
|
10993
10945
|
var import_react48 = require("react");
|
|
10994
|
-
var
|
|
10946
|
+
var import_fn5 = require("culori/fn");
|
|
10995
10947
|
|
|
10996
10948
|
// src/components/Input/Input.tsx
|
|
10997
10949
|
var import_react47 = require("react");
|
|
@@ -11221,7 +11173,7 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11221
11173
|
(event) => {
|
|
11222
11174
|
const newValue = (event.target.value || "#").trim().toLocaleLowerCase();
|
|
11223
11175
|
setTextInputValue(newValue);
|
|
11224
|
-
const isValidHexValue = Boolean((0,
|
|
11176
|
+
const isValidHexValue = Boolean((0, import_fn5.parseHex)(newValue));
|
|
11225
11177
|
if (!isValidHexValue) {
|
|
11226
11178
|
return;
|
|
11227
11179
|
}
|
|
@@ -11303,7 +11255,7 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11303
11255
|
event.preventDefault();
|
|
11304
11256
|
const pastedText = event.clipboardData.getData("text");
|
|
11305
11257
|
const normalizedValue = normalizeHexInput(pastedText);
|
|
11306
|
-
const isValidHexValue = Boolean((0,
|
|
11258
|
+
const isValidHexValue = Boolean((0, import_fn5.parseHex)(normalizedValue));
|
|
11307
11259
|
setTextInputValue(normalizedValue);
|
|
11308
11260
|
if (!isValidHexValue) {
|
|
11309
11261
|
return;
|
|
@@ -11366,12 +11318,12 @@ HexColorInput.displayName = "HexColorInput_UI";
|
|
|
11366
11318
|
var import_react50 = require("react");
|
|
11367
11319
|
var import_react_slider = require("@radix-ui/react-slider");
|
|
11368
11320
|
var import_styled_components62 = __toESM(require("styled-components"));
|
|
11369
|
-
var
|
|
11321
|
+
var import_fn7 = require("culori/fn");
|
|
11370
11322
|
|
|
11371
11323
|
// src/components/ColorPicker/HSVHueCanvas.tsx
|
|
11372
11324
|
var import_react49 = require("react");
|
|
11373
11325
|
var import_styled_components61 = __toESM(require("styled-components"));
|
|
11374
|
-
var
|
|
11326
|
+
var import_fn6 = require("culori/fn");
|
|
11375
11327
|
var import_jsx_runtime247 = require("react/jsx-runtime");
|
|
11376
11328
|
var Canvas = import_styled_components61.default.canvas`
|
|
11377
11329
|
display: block;
|
|
@@ -11393,7 +11345,7 @@ var HSVHueCanvas = ({ hsv }) => {
|
|
|
11393
11345
|
const gradient = ctx.createLinearGradient(0, 0, width, 0);
|
|
11394
11346
|
for (let i = 0; i <= THREE_SIXTY; i++) {
|
|
11395
11347
|
const hue = i;
|
|
11396
|
-
const hexColor = (0,
|
|
11348
|
+
const hexColor = (0, import_fn6.formatHex)({ h: hue, s: hsv.s, v: hsv.v, mode: "hsv" });
|
|
11397
11349
|
if (hexColor) {
|
|
11398
11350
|
gradient.addColorStop(i / THREE_SIXTY, hexColor);
|
|
11399
11351
|
}
|
|
@@ -11456,7 +11408,7 @@ var HueSlider = () => {
|
|
|
11456
11408
|
const { nonDerivedValueAsHsv, onChangeNonDerivedValueAsHsv, valueAsHsv } = useColorPickerState();
|
|
11457
11409
|
const containerStyle = (0, import_react50.useMemo)(() => {
|
|
11458
11410
|
return {
|
|
11459
|
-
backgroundColor: (0,
|
|
11411
|
+
backgroundColor: (0, import_fn7.formatHex)({
|
|
11460
11412
|
h: 0,
|
|
11461
11413
|
// red
|
|
11462
11414
|
s: valueAsHsv.s,
|
|
@@ -11466,7 +11418,7 @@ var HueSlider = () => {
|
|
|
11466
11418
|
};
|
|
11467
11419
|
}, [valueAsHsv.s, valueAsHsv.v]);
|
|
11468
11420
|
const thumbInnerStyle = (0, import_react50.useMemo)(() => {
|
|
11469
|
-
return { backgroundColor: (0,
|
|
11421
|
+
return { backgroundColor: (0, import_fn7.formatHex)(valueAsHsv) };
|
|
11470
11422
|
}, [valueAsHsv]);
|
|
11471
11423
|
const onHueChange = (0, import_react50.useCallback)(
|
|
11472
11424
|
(values) => {
|
|
@@ -11539,7 +11491,7 @@ var Canvas2 = import_styled_components63.default.canvas`
|
|
|
11539
11491
|
display: block;
|
|
11540
11492
|
width: 100%;
|
|
11541
11493
|
`;
|
|
11542
|
-
var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorForComparison, limit
|
|
11494
|
+
var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorForComparison, limit) => {
|
|
11543
11495
|
const contrastPoints = [];
|
|
11544
11496
|
for (let x = 0; x < width; x += 1) {
|
|
11545
11497
|
const saturationChanel = x / (width - 1);
|
|
@@ -11548,8 +11500,7 @@ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorFor
|
|
|
11548
11500
|
originalHsv: { h: hue, s: saturationChanel, v: initialValueChannelForSearch, mode: "hsv" },
|
|
11549
11501
|
colorForComparison,
|
|
11550
11502
|
minContrast: minimumContrastRatio,
|
|
11551
|
-
direction: limit === "upper" ? "brighter" : "darker"
|
|
11552
|
-
opacityForContrastCalculation
|
|
11503
|
+
direction: limit === "upper" ? "brighter" : "darker"
|
|
11553
11504
|
});
|
|
11554
11505
|
if (colorForXAsHsv != null) {
|
|
11555
11506
|
const point = {
|
|
@@ -11589,8 +11540,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11589
11540
|
hue,
|
|
11590
11541
|
shouldShowContrastCurve = false,
|
|
11591
11542
|
minimumContrastRatio = DEFAULT_MIN_CONTRAST,
|
|
11592
|
-
colorForComparison
|
|
11593
|
-
opacityForContrastCalculation
|
|
11543
|
+
colorForComparison
|
|
11594
11544
|
}) => {
|
|
11595
11545
|
const canvasRef = (0, import_react51.useRef)(null);
|
|
11596
11546
|
(0, import_react51.useEffect)(() => {
|
|
@@ -11614,8 +11564,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11614
11564
|
hue,
|
|
11615
11565
|
minimumContrastRatio,
|
|
11616
11566
|
colorForComparison,
|
|
11617
|
-
"upper"
|
|
11618
|
-
opacityForContrastCalculation
|
|
11567
|
+
"upper"
|
|
11619
11568
|
);
|
|
11620
11569
|
const minHsvValueChannelCurve = calculateContrastCurve(
|
|
11621
11570
|
width,
|
|
@@ -11623,8 +11572,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11623
11572
|
hue,
|
|
11624
11573
|
minimumContrastRatio,
|
|
11625
11574
|
colorForComparison,
|
|
11626
|
-
"lower"
|
|
11627
|
-
opacityForContrastCalculation
|
|
11575
|
+
"lower"
|
|
11628
11576
|
);
|
|
11629
11577
|
if (minHsvValueChannelCurve.length > 0) {
|
|
11630
11578
|
drawSmoothCurve(ctx, minHsvValueChannelCurve);
|
|
@@ -11633,13 +11581,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11633
11581
|
drawSmoothCurve(ctx, maxHsvValueChannelCurve);
|
|
11634
11582
|
}
|
|
11635
11583
|
}
|
|
11636
|
-
}, [
|
|
11637
|
-
hue,
|
|
11638
|
-
shouldShowContrastCurve,
|
|
11639
|
-
minimumContrastRatio,
|
|
11640
|
-
colorForComparison,
|
|
11641
|
-
opacityForContrastCalculation
|
|
11642
|
-
]);
|
|
11584
|
+
}, [hue, shouldShowContrastCurve, minimumContrastRatio, colorForComparison]);
|
|
11643
11585
|
return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
|
|
11644
11586
|
Canvas2,
|
|
11645
11587
|
{
|
|
@@ -11684,15 +11626,14 @@ var SaturationAndValuePicker = ({
|
|
|
11684
11626
|
dataTestId
|
|
11685
11627
|
}) => {
|
|
11686
11628
|
const {
|
|
11687
|
-
|
|
11629
|
+
valueAsHex,
|
|
11630
|
+
onChangeNonDerivedValueAsHsv,
|
|
11631
|
+
valueAsHsv,
|
|
11688
11632
|
isTransitioning,
|
|
11689
11633
|
minimumContrastRatio,
|
|
11690
|
-
|
|
11691
|
-
onChangeNonDerivedValueAsHsv,
|
|
11692
|
-
opacityForContrastCalculation,
|
|
11634
|
+
colorForComparison,
|
|
11693
11635
|
shouldEnforceMinContrast,
|
|
11694
|
-
|
|
11695
|
-
valueAsHsv
|
|
11636
|
+
nonDerivedValueAsHsv
|
|
11696
11637
|
} = useColorPickerState();
|
|
11697
11638
|
const containerRef = (0, import_react52.useRef)(null);
|
|
11698
11639
|
const thumbRef = (0, import_react52.useRef)(null);
|
|
@@ -11845,7 +11786,6 @@ var SaturationAndValuePicker = ({
|
|
|
11845
11786
|
colorForComparison,
|
|
11846
11787
|
hue: nonDerivedValueAsHsv.h ?? 0,
|
|
11847
11788
|
minimumContrastRatio,
|
|
11848
|
-
opacityForContrastCalculation,
|
|
11849
11789
|
shouldShowContrastCurve: shouldEnforceMinContrast
|
|
11850
11790
|
}
|
|
11851
11791
|
),
|