@wistia/ui 0.13.2-beta.8a821dcc.7e25bfb → 0.13.2-beta.8d39b694.362d245
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 +135 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +99 -22
- package/dist/index.d.ts +99 -22
- package/dist/index.mjs +135 -134
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.13.2-beta.
|
|
3
|
+
* @license @wistia/ui v0.13.2-beta.8d39b694.362d245
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -8206,11 +8206,24 @@ var variantStyleMap = {
|
|
|
8206
8206
|
var DEFAULT_ELEMENT2 = "h1";
|
|
8207
8207
|
var StyledHeading = import_styled_components28.default.div`
|
|
8208
8208
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
8209
|
+
--text-color: ${({ $prominence, $disabled }) => {
|
|
8210
|
+
if ($disabled) {
|
|
8211
|
+
return "var(--wui-color-text-disabled)";
|
|
8212
|
+
}
|
|
8213
|
+
if ($prominence === "secondary") {
|
|
8214
|
+
return "var(--wui-color-text-secondary)";
|
|
8215
|
+
}
|
|
8216
|
+
if ($prominence === "button") {
|
|
8217
|
+
return "var(--wui-color-text-button)";
|
|
8218
|
+
}
|
|
8219
|
+
return "var(--wui-color-text)";
|
|
8220
|
+
}};
|
|
8221
|
+
|
|
8209
8222
|
font-family: var(--font-family);
|
|
8210
8223
|
font-size: var(--font-size);
|
|
8211
8224
|
font-weight: var(--font-weight);
|
|
8212
8225
|
line-height: var(--line-height);
|
|
8213
|
-
color: var(--
|
|
8226
|
+
color: var(--text-color);
|
|
8214
8227
|
${({ $variant }) => variantStyleMap[$variant]}
|
|
8215
8228
|
${({ $truncate }) => {
|
|
8216
8229
|
if ((0, import_type_guards21.isNotNil)($truncate)) {
|
|
@@ -8224,9 +8237,6 @@ var StyledHeading = import_styled_components28.default.div`
|
|
|
8224
8237
|
${({ $inline }) => $inline && import_styled_components28.css`
|
|
8225
8238
|
display: inline-block;
|
|
8226
8239
|
`}
|
|
8227
|
-
${({ $disabled }) => $disabled && import_styled_components28.css`
|
|
8228
|
-
color: var(--wui-color-text-disabled);
|
|
8229
|
-
`}
|
|
8230
8240
|
${({ $preventUserSelect }) => $preventUserSelect && import_styled_components28.css`
|
|
8231
8241
|
user-select: none;
|
|
8232
8242
|
`}
|
|
@@ -8251,6 +8261,7 @@ var HeadingComponent = (0, import_react28.forwardRef)(
|
|
|
8251
8261
|
disabled = false,
|
|
8252
8262
|
inline = false,
|
|
8253
8263
|
preventUserSelect = false,
|
|
8264
|
+
prominence = "primary",
|
|
8254
8265
|
truncate,
|
|
8255
8266
|
variant = "heading1",
|
|
8256
8267
|
renderAs,
|
|
@@ -8264,6 +8275,7 @@ var HeadingComponent = (0, import_react28.forwardRef)(
|
|
|
8264
8275
|
$disabled: disabled,
|
|
8265
8276
|
$inline: inline,
|
|
8266
8277
|
$preventUserSelect: preventUserSelect,
|
|
8278
|
+
$prominence: prominence,
|
|
8267
8279
|
$truncate: truncate,
|
|
8268
8280
|
$variant: variant,
|
|
8269
8281
|
as: renderAs ?? variantElementMap[variant] ?? DEFAULT_ELEMENT2,
|
|
@@ -9635,6 +9647,33 @@ var CollapsibleContent = ({ clamp, children }) => {
|
|
|
9635
9647
|
] }) });
|
|
9636
9648
|
};
|
|
9637
9649
|
|
|
9650
|
+
// src/components/ColorPicker/color-conversion-utils.ts
|
|
9651
|
+
var import_fn = require("culori/fn");
|
|
9652
|
+
(0, import_fn.useMode)(import_fn.modeRgb);
|
|
9653
|
+
(0, import_fn.useMode)(import_fn.modeHsv);
|
|
9654
|
+
var convertToHsv = (color) => {
|
|
9655
|
+
const rgb = (0, import_fn.parseHex)(color);
|
|
9656
|
+
if (rgb == null) {
|
|
9657
|
+
throw new Error(`Invalid hex color value: ${color}`);
|
|
9658
|
+
}
|
|
9659
|
+
return (0, import_fn.convertRgbToHsv)(rgb);
|
|
9660
|
+
};
|
|
9661
|
+
var convertToLrgb = (color) => {
|
|
9662
|
+
let result;
|
|
9663
|
+
if (typeof color === "string") {
|
|
9664
|
+
const rgb = (0, import_fn.parseHex)(color);
|
|
9665
|
+
if (rgb == null) {
|
|
9666
|
+
throw new Error(`Invalid hex color value: ${color}`);
|
|
9667
|
+
}
|
|
9668
|
+
result = (0, import_fn.convertRgbToLrgb)(rgb);
|
|
9669
|
+
} else {
|
|
9670
|
+
const rgb = (0, import_fn.convertHsvToRgb)(color);
|
|
9671
|
+
result = (0, import_fn.convertRgbToLrgb)(rgb);
|
|
9672
|
+
}
|
|
9673
|
+
return result;
|
|
9674
|
+
};
|
|
9675
|
+
var convertToRgb = (hsv) => (0, import_fn.convertHsvToRgb)(hsv);
|
|
9676
|
+
|
|
9638
9677
|
// src/components/ColorPicker/ColorGrid.tsx
|
|
9639
9678
|
var import_react42 = require("react");
|
|
9640
9679
|
var import_styled_components47 = __toESM(require("styled-components"));
|
|
@@ -9644,42 +9683,6 @@ var import_react_radio_group = require("@radix-ui/react-radio-group");
|
|
|
9644
9683
|
var import_react41 = require("react");
|
|
9645
9684
|
var import_fn4 = require("culori/fn");
|
|
9646
9685
|
|
|
9647
|
-
// src/components/ColorPicker/getColorConversions.ts
|
|
9648
|
-
var import_fn = require("culori/fn");
|
|
9649
|
-
var getColorConversions = (color) => {
|
|
9650
|
-
if (typeof color === "string") {
|
|
9651
|
-
const rgb2 = (0, import_fn.parseHex)(color);
|
|
9652
|
-
if (!rgb2) {
|
|
9653
|
-
return {
|
|
9654
|
-
hex: color,
|
|
9655
|
-
rgb: { r: 0, g: 0, b: 0, mode: "rgb" },
|
|
9656
|
-
hsv: { h: 0, s: 0, v: 0, mode: "hsv" },
|
|
9657
|
-
lrgb: { r: 0, g: 0, b: 0, mode: "lrgb" },
|
|
9658
|
-
isValid: false
|
|
9659
|
-
};
|
|
9660
|
-
}
|
|
9661
|
-
const hsv = (0, import_fn.convertRgbToHsv)(rgb2);
|
|
9662
|
-
const lrgb2 = (0, import_fn.convertRgbToLrgb)(rgb2);
|
|
9663
|
-
return {
|
|
9664
|
-
hex: color,
|
|
9665
|
-
rgb: rgb2,
|
|
9666
|
-
hsv,
|
|
9667
|
-
lrgb: lrgb2,
|
|
9668
|
-
isValid: true
|
|
9669
|
-
};
|
|
9670
|
-
}
|
|
9671
|
-
const rgb = (0, import_fn.convertHsvToRgb)(color);
|
|
9672
|
-
const hex = (0, import_fn.serializeHex)(rgb);
|
|
9673
|
-
const lrgb = (0, import_fn.convertRgbToLrgb)(rgb);
|
|
9674
|
-
return {
|
|
9675
|
-
hex,
|
|
9676
|
-
rgb,
|
|
9677
|
-
hsv: color,
|
|
9678
|
-
lrgb,
|
|
9679
|
-
isValid: true
|
|
9680
|
-
};
|
|
9681
|
-
};
|
|
9682
|
-
|
|
9683
9686
|
// src/components/ColorPicker/transitionBetweenColors.ts
|
|
9684
9687
|
var import_fn2 = require("culori/fn");
|
|
9685
9688
|
var transitionBetweenColors = (fromHsv, toHsv, onColorStep, onTransitionEnd) => {
|
|
@@ -9736,6 +9739,28 @@ var DEFAULT_COLOR_FOR_COMPARISON = "#ffffff";
|
|
|
9736
9739
|
|
|
9737
9740
|
// src/components/ColorPicker/contrast-utils.ts
|
|
9738
9741
|
var CONTRAST_EPSILON = 4e-3;
|
|
9742
|
+
var VALUE_CHANNEL_SNAP_EPSILON = 5e-4;
|
|
9743
|
+
var snapValueToEdges = (value) => {
|
|
9744
|
+
if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) {
|
|
9745
|
+
return 1;
|
|
9746
|
+
}
|
|
9747
|
+
if (value < VALUE_CHANNEL_SNAP_EPSILON) {
|
|
9748
|
+
return 0;
|
|
9749
|
+
}
|
|
9750
|
+
return value;
|
|
9751
|
+
};
|
|
9752
|
+
var updateSearchBounds = (searchingBrighter, contrast, minContrast, midValue, searchLow, searchHigh) => {
|
|
9753
|
+
if (contrast >= minContrast) {
|
|
9754
|
+
if (searchingBrighter) {
|
|
9755
|
+
return { newSearchLow: searchLow, newSearchHigh: midValue };
|
|
9756
|
+
}
|
|
9757
|
+
return { newSearchLow: midValue, newSearchHigh: searchHigh };
|
|
9758
|
+
}
|
|
9759
|
+
if (searchingBrighter) {
|
|
9760
|
+
return { newSearchLow: midValue, newSearchHigh: searchHigh };
|
|
9761
|
+
}
|
|
9762
|
+
return { newSearchLow: searchLow, newSearchHigh: midValue };
|
|
9763
|
+
};
|
|
9739
9764
|
var getAccessibleColorByValueChannelChange = ({
|
|
9740
9765
|
originalHsv,
|
|
9741
9766
|
colorForComparisonAsLrgb,
|
|
@@ -9753,8 +9778,8 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9753
9778
|
v: extremeValue,
|
|
9754
9779
|
mode: "hsv"
|
|
9755
9780
|
};
|
|
9756
|
-
const
|
|
9757
|
-
const extremeContrast = (0, import_fn3.wcagContrast)(
|
|
9781
|
+
const extremeVariantAsLrgb = convertToLrgb(extremeVariant);
|
|
9782
|
+
const extremeContrast = (0, import_fn3.wcagContrast)(extremeVariantAsLrgb, colorForComparisonAsLrgb);
|
|
9758
9783
|
if (extremeContrast < minContrast) {
|
|
9759
9784
|
return null;
|
|
9760
9785
|
}
|
|
@@ -9762,27 +9787,28 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9762
9787
|
let searchHigh = highValue;
|
|
9763
9788
|
let bestSoFar = extremeVariant;
|
|
9764
9789
|
for (let i = 0; i < maxIterations; i++) {
|
|
9765
|
-
const
|
|
9790
|
+
const rawMidValue = (searchLow + searchHigh) / 2;
|
|
9791
|
+
const midValue = snapValueToEdges(rawMidValue);
|
|
9766
9792
|
const candidateHsv = {
|
|
9767
9793
|
h: originalHsv.h ?? 0,
|
|
9768
9794
|
s: originalHsv.s,
|
|
9769
9795
|
v: midValue,
|
|
9770
9796
|
mode: "hsv"
|
|
9771
9797
|
};
|
|
9772
|
-
const
|
|
9773
|
-
const contrast = (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(candidateRgb), colorForComparisonAsLrgb);
|
|
9798
|
+
const contrast = (0, import_fn3.wcagContrast)(convertToLrgb(candidateHsv), colorForComparisonAsLrgb);
|
|
9774
9799
|
if (contrast >= minContrast) {
|
|
9775
9800
|
bestSoFar = candidateHsv;
|
|
9776
|
-
if (searchingBrighter) {
|
|
9777
|
-
searchHigh = midValue;
|
|
9778
|
-
} else {
|
|
9779
|
-
searchLow = midValue;
|
|
9780
|
-
}
|
|
9781
|
-
} else if (searchingBrighter) {
|
|
9782
|
-
searchLow = midValue;
|
|
9783
|
-
} else {
|
|
9784
|
-
searchHigh = midValue;
|
|
9785
9801
|
}
|
|
9802
|
+
const { newSearchLow, newSearchHigh } = updateSearchBounds(
|
|
9803
|
+
searchingBrighter,
|
|
9804
|
+
contrast,
|
|
9805
|
+
minContrast,
|
|
9806
|
+
midValue,
|
|
9807
|
+
searchLow,
|
|
9808
|
+
searchHigh
|
|
9809
|
+
);
|
|
9810
|
+
searchLow = newSearchLow;
|
|
9811
|
+
searchHigh = newSearchHigh;
|
|
9786
9812
|
if (contrast >= minContrast && contrast - minContrast < CONTRAST_EPSILON) {
|
|
9787
9813
|
break;
|
|
9788
9814
|
}
|
|
@@ -9841,8 +9867,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9841
9867
|
};
|
|
9842
9868
|
};
|
|
9843
9869
|
const checkContrast = (hsv) => {
|
|
9844
|
-
|
|
9845
|
-
return (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(rgb), colorForComparisonAsLrgb);
|
|
9870
|
+
return (0, import_fn3.wcagContrast)(convertToLrgb(hsv), colorForComparisonAsLrgb);
|
|
9846
9871
|
};
|
|
9847
9872
|
const extremeHsv = getHsvForStep(highStep);
|
|
9848
9873
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9900,8 +9925,7 @@ var getAccessibleColor = ({
|
|
|
9900
9925
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9901
9926
|
maxIterations = 50
|
|
9902
9927
|
}) => {
|
|
9903
|
-
const
|
|
9904
|
-
const originalContrast = (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(originalRgb), colorForComparisonAsLrgb);
|
|
9928
|
+
const originalContrast = (0, import_fn3.wcagContrast)(convertToLrgb(originalHsv), colorForComparisonAsLrgb);
|
|
9905
9929
|
if (originalContrast >= minContrast) {
|
|
9906
9930
|
return originalHsv;
|
|
9907
9931
|
}
|
|
@@ -9932,8 +9956,7 @@ var hasAccessibleDerivatives = ({
|
|
|
9932
9956
|
colorForComparisonAsLrgb,
|
|
9933
9957
|
minContrast = DEFAULT_MIN_CONTRAST
|
|
9934
9958
|
}) => {
|
|
9935
|
-
const
|
|
9936
|
-
const originalContrast = (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(originalRgb), colorForComparisonAsLrgb);
|
|
9959
|
+
const originalContrast = (0, import_fn3.wcagContrast)(convertToLrgb(originalHsv), colorForComparisonAsLrgb);
|
|
9937
9960
|
if (originalContrast >= minContrast) {
|
|
9938
9961
|
return true;
|
|
9939
9962
|
}
|
|
@@ -9960,8 +9983,8 @@ var createInitialState = ({
|
|
|
9960
9983
|
colorForComparisonAsHex,
|
|
9961
9984
|
minimumContrastRatio
|
|
9962
9985
|
}) => {
|
|
9963
|
-
const
|
|
9964
|
-
const
|
|
9986
|
+
const valueAsHsv = convertToHsv(valueAsHex);
|
|
9987
|
+
const colorForComparisonAsLrgb = convertToLrgb(colorForComparisonAsHex);
|
|
9965
9988
|
return {
|
|
9966
9989
|
nonDerivedValueAsHsv: valueAsHsv,
|
|
9967
9990
|
nonDerivedValueAsHex: valueAsHex,
|
|
@@ -10035,18 +10058,11 @@ var ColorPickerProvider = ({
|
|
|
10035
10058
|
minimumContrastRatio
|
|
10036
10059
|
})
|
|
10037
10060
|
);
|
|
10038
|
-
const
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
const { lrgb: colorForComparisonAsLrgb, isValid: colorForComparisonIsValid } = getColorConversions(colorForComparisonAsHex);
|
|
10044
|
-
if (!valueIsValid) {
|
|
10045
|
-
throw new Error(`Invalid color value: ${JSON.stringify(state.valueAsHsv)}`);
|
|
10046
|
-
}
|
|
10047
|
-
if (!colorForComparisonIsValid) {
|
|
10048
|
-
throw new Error(`Invalid comparison color value: ${colorForComparisonAsHex}`);
|
|
10049
|
-
}
|
|
10061
|
+
const valueAsLrgb = (0, import_react41.useMemo)(() => convertToLrgb(state.valueAsHsv), [state.valueAsHsv]);
|
|
10062
|
+
const colorForComparisonAsLrgb = (0, import_react41.useMemo)(
|
|
10063
|
+
() => convertToLrgb(colorForComparisonAsHex),
|
|
10064
|
+
[colorForComparisonAsHex]
|
|
10065
|
+
);
|
|
10050
10066
|
const currentContrastRatio = (0, import_react41.useMemo)(() => {
|
|
10051
10067
|
return (0, import_fn4.wcagContrast)(valueAsLrgb, colorForComparisonAsLrgb);
|
|
10052
10068
|
}, [valueAsLrgb, colorForComparisonAsLrgb]);
|
|
@@ -10068,7 +10084,7 @@ var ColorPickerProvider = ({
|
|
|
10068
10084
|
const onValueAsHsvChange = (0, import_react41.useCallback)(
|
|
10069
10085
|
(rawNewValueAsHsv) => {
|
|
10070
10086
|
const hsvToSet = state.shouldEnforceMinContrast ? getAccessibleDerivativeColor(rawNewValueAsHsv) : rawNewValueAsHsv;
|
|
10071
|
-
const hexToSet =
|
|
10087
|
+
const hexToSet = (0, import_fn4.formatHex)(hsvToSet);
|
|
10072
10088
|
onValueChange(hexToSet);
|
|
10073
10089
|
dispatch({
|
|
10074
10090
|
type: "SET_VALUE_AS_HSV",
|
|
@@ -10084,7 +10100,7 @@ var ColorPickerProvider = ({
|
|
|
10084
10100
|
state.valueAsHsv,
|
|
10085
10101
|
toHsv,
|
|
10086
10102
|
(colorForStepAsHsv) => {
|
|
10087
|
-
const hexValue =
|
|
10103
|
+
const hexValue = (0, import_fn4.formatHex)(colorForStepAsHsv);
|
|
10088
10104
|
onValueChange(hexValue);
|
|
10089
10105
|
dispatch({ type: "SET_VALUE_AS_HSV", payload: { valueAsHsv: colorForStepAsHsv } });
|
|
10090
10106
|
},
|
|
@@ -10115,10 +10131,7 @@ var ColorPickerProvider = ({
|
|
|
10115
10131
|
if (valueAsHex === (0, import_fn4.formatHex)(state.valueAsHsv)) {
|
|
10116
10132
|
return;
|
|
10117
10133
|
}
|
|
10118
|
-
const
|
|
10119
|
-
if (!isNewValueValid) {
|
|
10120
|
-
throw new Error(`Invalid color value: ${valueAsHex}`);
|
|
10121
|
-
}
|
|
10134
|
+
const newValueAsHsv = convertToHsv(valueAsHex);
|
|
10122
10135
|
dispatch({
|
|
10123
10136
|
type: "SET_VALUE_AS_HSV",
|
|
10124
10137
|
payload: { valueAsHsv: newValueAsHsv }
|
|
@@ -10127,7 +10140,6 @@ var ColorPickerProvider = ({
|
|
|
10127
10140
|
const contextValue = (0, import_react41.useMemo)(
|
|
10128
10141
|
() => ({
|
|
10129
10142
|
...state,
|
|
10130
|
-
valueAsRgb,
|
|
10131
10143
|
valueAsLrgb,
|
|
10132
10144
|
currentContrastRatio,
|
|
10133
10145
|
hasAccessibleDerivatives: hasAccessibleDerivativesValue,
|
|
@@ -10140,7 +10152,6 @@ var ColorPickerProvider = ({
|
|
|
10140
10152
|
}),
|
|
10141
10153
|
[
|
|
10142
10154
|
state,
|
|
10143
|
-
valueAsRgb,
|
|
10144
10155
|
valueAsLrgb,
|
|
10145
10156
|
currentContrastRatio,
|
|
10146
10157
|
hasAccessibleDerivativesValue,
|
|
@@ -10176,13 +10187,7 @@ var ColorGrid = ({ children }) => {
|
|
|
10176
10187
|
const { valueAsHex, onValueAsHsvChange } = useColorPickerState();
|
|
10177
10188
|
const onValueChange = (0, import_react42.useCallback)(
|
|
10178
10189
|
(value) => {
|
|
10179
|
-
|
|
10180
|
-
return;
|
|
10181
|
-
}
|
|
10182
|
-
const { isValid, hsv } = getColorConversions(value);
|
|
10183
|
-
if (!isValid) {
|
|
10184
|
-
throw new Error(`Invalid color value: ${value}`);
|
|
10185
|
-
}
|
|
10190
|
+
const hsv = convertToHsv(value);
|
|
10186
10191
|
onValueAsHsvChange(hsv);
|
|
10187
10192
|
},
|
|
10188
10193
|
[onValueAsHsvChange]
|
|
@@ -10196,6 +10201,7 @@ var ColorGrid = ({ children }) => {
|
|
|
10196
10201
|
}
|
|
10197
10202
|
);
|
|
10198
10203
|
};
|
|
10204
|
+
ColorGrid.displayName = "ColorGrid";
|
|
10199
10205
|
|
|
10200
10206
|
// src/components/ColorPicker/ColorGridOption.tsx
|
|
10201
10207
|
var import_styled_components50 = __toESM(require("styled-components"));
|
|
@@ -10414,20 +10420,10 @@ var Container2 = (0, import_styled_components50.default)(import_react_radio_grou
|
|
|
10414
10420
|
appearance: none;
|
|
10415
10421
|
outline: none;
|
|
10416
10422
|
align-items: center;
|
|
10417
|
-
background-color: var(--wui-color-bg-surface);
|
|
10418
10423
|
border-radius: var(--wui-border-radius-rounded);
|
|
10419
10424
|
padding: 0;
|
|
10420
10425
|
cursor: pointer;
|
|
10421
10426
|
user-select: none;
|
|
10422
|
-
|
|
10423
|
-
&:hover,
|
|
10424
|
-
&:focus-visible {
|
|
10425
|
-
background-color: var(--wui-color-bg-surface-hover);
|
|
10426
|
-
}
|
|
10427
|
-
|
|
10428
|
-
&:focus-visible {
|
|
10429
|
-
background-color: var(--wui-color-bg-surface-secondary-hover);
|
|
10430
|
-
}
|
|
10431
10427
|
`;
|
|
10432
10428
|
var ColorGridOption = ({ value, name }) => {
|
|
10433
10429
|
const { valueAsHex, nonDerivedValueAsHex } = useColorPickerState();
|
|
@@ -10458,6 +10454,7 @@ var ColorGridOption = ({ value, name }) => {
|
|
|
10458
10454
|
}
|
|
10459
10455
|
);
|
|
10460
10456
|
};
|
|
10457
|
+
ColorGridOption.displayName = "ColorGridOption";
|
|
10461
10458
|
|
|
10462
10459
|
// src/components/ColorPicker/ColorList.tsx
|
|
10463
10460
|
var import_react43 = require("react");
|
|
@@ -10476,10 +10473,7 @@ var ColorList = ({ children }) => {
|
|
|
10476
10473
|
if (value === "") {
|
|
10477
10474
|
return;
|
|
10478
10475
|
}
|
|
10479
|
-
const
|
|
10480
|
-
if (!isValid) {
|
|
10481
|
-
throw new Error(`Invalid color value: ${value}`);
|
|
10482
|
-
}
|
|
10476
|
+
const hsv = convertToHsv(value);
|
|
10483
10477
|
onValueAsHsvChange(hsv);
|
|
10484
10478
|
},
|
|
10485
10479
|
[onValueAsHsvChange]
|
|
@@ -10494,6 +10488,7 @@ var ColorList = ({ children }) => {
|
|
|
10494
10488
|
}
|
|
10495
10489
|
);
|
|
10496
10490
|
};
|
|
10491
|
+
ColorList.displayName = "ColorList";
|
|
10497
10492
|
|
|
10498
10493
|
// src/components/ColorPicker/ColorListGroup.tsx
|
|
10499
10494
|
var import_styled_components52 = __toESM(require("styled-components"));
|
|
@@ -10523,6 +10518,7 @@ var ColorListGroup = ({ label, children }) => {
|
|
|
10523
10518
|
}
|
|
10524
10519
|
);
|
|
10525
10520
|
};
|
|
10521
|
+
ColorListGroup.displayName = "ColorListGroup";
|
|
10526
10522
|
|
|
10527
10523
|
// src/components/ColorPicker/ColorListOption.tsx
|
|
10528
10524
|
var import_styled_components53 = __toESM(require("styled-components"));
|
|
@@ -10617,13 +10613,11 @@ var ColorListOption = ({ value, name }) => {
|
|
|
10617
10613
|
}
|
|
10618
10614
|
);
|
|
10619
10615
|
};
|
|
10616
|
+
ColorListOption.displayName = "ColorListOption";
|
|
10620
10617
|
|
|
10621
10618
|
// src/components/ColorPicker/ColorPicker.tsx
|
|
10622
10619
|
var import_react_popover = require("@radix-ui/react-popover");
|
|
10623
|
-
var import_fn5 = require("culori/fn");
|
|
10624
10620
|
var import_jsx_runtime234 = require("react/jsx-runtime");
|
|
10625
|
-
(0, import_fn5.useMode)(import_fn5.modeRgb);
|
|
10626
|
-
(0, import_fn5.useMode)(import_fn5.modeHsv);
|
|
10627
10621
|
var ColorPicker = ({
|
|
10628
10622
|
value,
|
|
10629
10623
|
onValueChange,
|
|
@@ -10644,6 +10638,7 @@ var ColorPicker = ({
|
|
|
10644
10638
|
}
|
|
10645
10639
|
) });
|
|
10646
10640
|
};
|
|
10641
|
+
ColorPicker.displayName = "ColorPicker";
|
|
10647
10642
|
|
|
10648
10643
|
// src/components/ColorPicker/ColorPickerPopoverContent.tsx
|
|
10649
10644
|
var import_react_popover2 = require("@radix-ui/react-popover");
|
|
@@ -10672,6 +10667,7 @@ var ColorPickerPopoverContent = ({
|
|
|
10672
10667
|
}
|
|
10673
10668
|
) });
|
|
10674
10669
|
};
|
|
10670
|
+
ColorPickerPopoverContent.displayName = "ColorPickerPopoverContent";
|
|
10675
10671
|
|
|
10676
10672
|
// src/components/ColorPicker/ColorPickerSection.tsx
|
|
10677
10673
|
var import_styled_components55 = __toESM(require("styled-components"));
|
|
@@ -10682,6 +10678,7 @@ var Container5 = import_styled_components55.default.div`
|
|
|
10682
10678
|
var ColorPickerSection = ({ children }) => {
|
|
10683
10679
|
return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(Container5, { children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(Stack, { children }) });
|
|
10684
10680
|
};
|
|
10681
|
+
ColorPickerSection.displayName = "ColorPickerSection";
|
|
10685
10682
|
|
|
10686
10683
|
// src/components/ColorPicker/ColorPickerTrigger.tsx
|
|
10687
10684
|
var import_react44 = require("react");
|
|
@@ -10694,6 +10691,7 @@ var ValueSwatch = () => {
|
|
|
10694
10691
|
const { valueAsHex } = useColorPickerState();
|
|
10695
10692
|
return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(ColorSwatch, { value: valueAsHex });
|
|
10696
10693
|
};
|
|
10694
|
+
ValueSwatch.displayName = "ValueSwatch";
|
|
10697
10695
|
|
|
10698
10696
|
// src/components/ColorPicker/ValueNameOrHexCode.tsx
|
|
10699
10697
|
var import_jsx_runtime238 = require("react/jsx-runtime");
|
|
@@ -10701,6 +10699,7 @@ var ValueNameOrHexCode = () => {
|
|
|
10701
10699
|
const { valueAsHex } = useColorPickerState();
|
|
10702
10700
|
return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(ColorNameOrHexCode, { hexCode: valueAsHex });
|
|
10703
10701
|
};
|
|
10702
|
+
ValueNameOrHexCode.displayName = "ValueNameOrHexCode";
|
|
10704
10703
|
|
|
10705
10704
|
// src/components/ColorPicker/ColorPickerTrigger.tsx
|
|
10706
10705
|
var import_jsx_runtime239 = require("react/jsx-runtime");
|
|
@@ -11024,10 +11023,11 @@ var ContrastControls = () => {
|
|
|
11024
11023
|
/* @__PURE__ */ (0, import_jsx_runtime244.jsx)(ContrastEnforcerSwitch, {})
|
|
11025
11024
|
] });
|
|
11026
11025
|
};
|
|
11026
|
+
ContrastControls.displayName = "ContrastControls";
|
|
11027
11027
|
|
|
11028
11028
|
// src/components/ColorPicker/HexColorInput.tsx
|
|
11029
11029
|
var import_react48 = require("react");
|
|
11030
|
-
var
|
|
11030
|
+
var import_fn5 = require("culori/fn");
|
|
11031
11031
|
|
|
11032
11032
|
// src/components/Input/Input.tsx
|
|
11033
11033
|
var import_react47 = require("react");
|
|
@@ -11176,10 +11176,7 @@ var Input = (0, import_react47.forwardRef)(
|
|
|
11176
11176
|
...props
|
|
11177
11177
|
}, externalRef) => {
|
|
11178
11178
|
const internalRef = (0, import_react47.useRef)();
|
|
11179
|
-
const ref = (
|
|
11180
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
11181
|
-
(0, import_type_guards35.isNotNil)(externalRef) && (0, import_type_guards35.isRecord)(externalRef) && "current" in externalRef ? externalRef : internalRef
|
|
11182
|
-
);
|
|
11179
|
+
const ref = (0, import_type_guards35.isNotNil)(externalRef) && (0, import_type_guards35.isRecord)(externalRef) && "current" in externalRef ? externalRef : internalRef;
|
|
11183
11180
|
let leftIconToDisplay = leftIcon;
|
|
11184
11181
|
if ((0, import_type_guards35.isNil)(leftIcon) && type === "search") {
|
|
11185
11182
|
leftIconToDisplay = /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(Icon, { type: "search" });
|
|
@@ -11260,14 +11257,14 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11260
11257
|
(event) => {
|
|
11261
11258
|
const newValue = (event.target.value || "#").trim().toLocaleLowerCase();
|
|
11262
11259
|
setTextInputValue(newValue);
|
|
11263
|
-
const isValidHexValue = Boolean((0,
|
|
11260
|
+
const isValidHexValue = Boolean((0, import_fn5.parseHex)(newValue));
|
|
11264
11261
|
if (!isValidHexValue) {
|
|
11265
11262
|
return;
|
|
11266
11263
|
}
|
|
11267
11264
|
if (newValue.length < SIX_DIGIT_HEX_CODE_LENGTH) {
|
|
11268
11265
|
return;
|
|
11269
11266
|
}
|
|
11270
|
-
const newValueAsHsv =
|
|
11267
|
+
const newValueAsHsv = convertToHsv(newValue);
|
|
11271
11268
|
onValueAsHsvChange(newValueAsHsv);
|
|
11272
11269
|
},
|
|
11273
11270
|
[onValueAsHsvChange]
|
|
@@ -11308,7 +11305,7 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11308
11305
|
}
|
|
11309
11306
|
if (key === "ArrowUp" || key === "ArrowDown") {
|
|
11310
11307
|
event.preventDefault();
|
|
11311
|
-
const
|
|
11308
|
+
const currentHsv = convertToHsv(valueAsHex);
|
|
11312
11309
|
const saturationNudge = 0.02;
|
|
11313
11310
|
const newSaturation = Math.max(
|
|
11314
11311
|
0,
|
|
@@ -11342,12 +11339,12 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11342
11339
|
event.preventDefault();
|
|
11343
11340
|
const pastedText = event.clipboardData.getData("text");
|
|
11344
11341
|
const normalizedValue = normalizeHexInput(pastedText);
|
|
11345
|
-
const isValidHexValue = Boolean((0,
|
|
11342
|
+
const isValidHexValue = Boolean((0, import_fn5.parseHex)(normalizedValue));
|
|
11346
11343
|
setTextInputValue(normalizedValue);
|
|
11347
11344
|
if (!isValidHexValue) {
|
|
11348
11345
|
return;
|
|
11349
11346
|
}
|
|
11350
|
-
const newValueAsHsv =
|
|
11347
|
+
const newValueAsHsv = convertToHsv(normalizedValue);
|
|
11351
11348
|
onValueAsHsvChange(newValueAsHsv);
|
|
11352
11349
|
},
|
|
11353
11350
|
[onValueAsHsvChange]
|
|
@@ -11399,17 +11396,18 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11399
11396
|
}
|
|
11400
11397
|
);
|
|
11401
11398
|
};
|
|
11399
|
+
HexColorInput.displayName = "HexColorInput";
|
|
11402
11400
|
|
|
11403
11401
|
// src/components/ColorPicker/HueSlider.tsx
|
|
11404
11402
|
var import_react50 = require("react");
|
|
11405
11403
|
var import_react_slider = require("@radix-ui/react-slider");
|
|
11406
11404
|
var import_styled_components62 = __toESM(require("styled-components"));
|
|
11407
|
-
var
|
|
11405
|
+
var import_fn7 = require("culori/fn");
|
|
11408
11406
|
|
|
11409
11407
|
// src/components/ColorPicker/HSVHueCanvas.tsx
|
|
11410
11408
|
var import_react49 = require("react");
|
|
11411
11409
|
var import_styled_components61 = __toESM(require("styled-components"));
|
|
11412
|
-
var
|
|
11410
|
+
var import_fn6 = require("culori/fn");
|
|
11413
11411
|
var import_jsx_runtime247 = require("react/jsx-runtime");
|
|
11414
11412
|
var Canvas = import_styled_components61.default.canvas`
|
|
11415
11413
|
display: block;
|
|
@@ -11431,7 +11429,7 @@ var HSVHueCanvas = ({ hsv }) => {
|
|
|
11431
11429
|
const gradient = ctx.createLinearGradient(0, 0, width, 0);
|
|
11432
11430
|
for (let i = 0; i <= THREE_SIXTY; i++) {
|
|
11433
11431
|
const hue = i;
|
|
11434
|
-
const hexColor = (0,
|
|
11432
|
+
const hexColor = (0, import_fn6.formatHex)({ h: hue, s: hsv.s, v: hsv.v, mode: "hsv" });
|
|
11435
11433
|
if (hexColor) {
|
|
11436
11434
|
gradient.addColorStop(i / THREE_SIXTY, hexColor);
|
|
11437
11435
|
}
|
|
@@ -11494,7 +11492,7 @@ var HueSlider = () => {
|
|
|
11494
11492
|
const { nonDerivedValueAsHsv, onValueAsHsvChange, valueAsHsv } = useColorPickerState();
|
|
11495
11493
|
const containerStyle = (0, import_react50.useMemo)(() => {
|
|
11496
11494
|
return {
|
|
11497
|
-
backgroundColor: (0,
|
|
11495
|
+
backgroundColor: (0, import_fn7.formatHex)({
|
|
11498
11496
|
h: 0,
|
|
11499
11497
|
// red
|
|
11500
11498
|
s: valueAsHsv.s,
|
|
@@ -11504,7 +11502,7 @@ var HueSlider = () => {
|
|
|
11504
11502
|
};
|
|
11505
11503
|
}, [valueAsHsv.s, valueAsHsv.v]);
|
|
11506
11504
|
const thumbInnerStyle = (0, import_react50.useMemo)(() => {
|
|
11507
|
-
return { backgroundColor: (0,
|
|
11505
|
+
return { backgroundColor: (0, import_fn7.formatHex)(valueAsHsv) };
|
|
11508
11506
|
}, [valueAsHsv]);
|
|
11509
11507
|
const onHueChange = (0, import_react50.useCallback)(
|
|
11510
11508
|
(values) => {
|
|
@@ -11535,6 +11533,7 @@ var HueSlider = () => {
|
|
|
11535
11533
|
/* @__PURE__ */ (0, import_jsx_runtime248.jsx)(HSVHueCanvas, { hsv: valueAsHsv })
|
|
11536
11534
|
] });
|
|
11537
11535
|
};
|
|
11536
|
+
HueSlider.displayName = "HueSlider";
|
|
11538
11537
|
|
|
11539
11538
|
// src/components/ColorPicker/SaturationAndValuePicker.tsx
|
|
11540
11539
|
var import_react52 = require("react");
|
|
@@ -11543,7 +11542,6 @@ var import_styled_components64 = __toESM(require("styled-components"));
|
|
|
11543
11542
|
// src/components/ColorPicker/HSVSaturationValueCanvas.tsx
|
|
11544
11543
|
var import_react51 = require("react");
|
|
11545
11544
|
var import_styled_components63 = __toESM(require("styled-components"));
|
|
11546
|
-
var import_fn9 = require("culori/fn");
|
|
11547
11545
|
|
|
11548
11546
|
// src/components/ColorPicker/canvas-utils.ts
|
|
11549
11547
|
var drawSmoothCurve = (context, points) => {
|
|
@@ -11596,6 +11594,12 @@ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorFor
|
|
|
11596
11594
|
};
|
|
11597
11595
|
contrastPoints.push(point);
|
|
11598
11596
|
}
|
|
11597
|
+
if (colorForXAsHsv == null) {
|
|
11598
|
+
break;
|
|
11599
|
+
}
|
|
11600
|
+
if (colorForXAsHsv.v >= 1) {
|
|
11601
|
+
break;
|
|
11602
|
+
}
|
|
11599
11603
|
}
|
|
11600
11604
|
return contrastPoints;
|
|
11601
11605
|
};
|
|
@@ -11606,7 +11610,7 @@ var drawGradientBackground = (ctx, width, height, hue) => {
|
|
|
11606
11610
|
const v = 1 - y / (height - 1);
|
|
11607
11611
|
for (let x = 0; x < width; x++) {
|
|
11608
11612
|
const s = x / (width - 1);
|
|
11609
|
-
const rgb = (
|
|
11613
|
+
const rgb = convertToRgb({ h: hue, s, v, mode: "hsv" });
|
|
11610
11614
|
const idx = 4 * (y * width + x);
|
|
11611
11615
|
data[idx] = rgb.r * TWO_FIFTY_FIVE;
|
|
11612
11616
|
data[idx + 1] = rgb.g * TWO_FIFTY_FIVE;
|
|
@@ -11638,7 +11642,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11638
11642
|
if (shouldShowContrastCurve && colorForComparisonAsLrgb) {
|
|
11639
11643
|
ctx.lineWidth = 1.5;
|
|
11640
11644
|
ctx.strokeStyle = "white";
|
|
11641
|
-
const
|
|
11645
|
+
const maxHsvValueChannelCurve = calculateContrastCurve(
|
|
11642
11646
|
width,
|
|
11643
11647
|
height,
|
|
11644
11648
|
hue,
|
|
@@ -11646,7 +11650,7 @@ var HSVSaturationValueCanvas = ({
|
|
|
11646
11650
|
colorForComparisonAsLrgb,
|
|
11647
11651
|
"upper"
|
|
11648
11652
|
);
|
|
11649
|
-
const
|
|
11653
|
+
const minHsvValueChannelCurve = calculateContrastCurve(
|
|
11650
11654
|
width,
|
|
11651
11655
|
height,
|
|
11652
11656
|
hue,
|
|
@@ -11654,11 +11658,11 @@ var HSVSaturationValueCanvas = ({
|
|
|
11654
11658
|
colorForComparisonAsLrgb,
|
|
11655
11659
|
"lower"
|
|
11656
11660
|
);
|
|
11657
|
-
if (
|
|
11658
|
-
drawSmoothCurve(ctx,
|
|
11661
|
+
if (minHsvValueChannelCurve.length > 0) {
|
|
11662
|
+
drawSmoothCurve(ctx, minHsvValueChannelCurve);
|
|
11659
11663
|
}
|
|
11660
|
-
if (
|
|
11661
|
-
drawSmoothCurve(ctx,
|
|
11664
|
+
if (maxHsvValueChannelCurve.length > 0) {
|
|
11665
|
+
drawSmoothCurve(ctx, maxHsvValueChannelCurve);
|
|
11662
11666
|
}
|
|
11663
11667
|
}
|
|
11664
11668
|
}, [hue, shouldShowContrastCurve, minimumContrastRatio, colorForComparisonAsLrgb]);
|
|
@@ -11901,6 +11905,7 @@ var SaturationAndValuePicker = ({
|
|
|
11901
11905
|
)
|
|
11902
11906
|
);
|
|
11903
11907
|
};
|
|
11908
|
+
SaturationAndValuePicker.displayName = "SaturationAndValuePicker";
|
|
11904
11909
|
|
|
11905
11910
|
// src/components/Combobox/Combobox.tsx
|
|
11906
11911
|
var Ariakit = __toESM(require("@ariakit/react"));
|