@wistia/ui 0.13.2-beta.af67f027.2cf4e13 → 0.13.2-beta.ba4f8c71.ec584ed
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 +73 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +95 -22
- package/dist/index.d.ts +95 -22
- package/dist/index.mjs +73 -114
- 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.ba4f8c71.ec584ed
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -9635,6 +9635,33 @@ var CollapsibleContent = ({ clamp, children }) => {
|
|
|
9635
9635
|
] }) });
|
|
9636
9636
|
};
|
|
9637
9637
|
|
|
9638
|
+
// src/components/ColorPicker/color-conversion-utils.ts
|
|
9639
|
+
var import_fn = require("culori/fn");
|
|
9640
|
+
(0, import_fn.useMode)(import_fn.modeRgb);
|
|
9641
|
+
(0, import_fn.useMode)(import_fn.modeHsv);
|
|
9642
|
+
var convertToHsv = (color) => {
|
|
9643
|
+
const rgb = (0, import_fn.parseHex)(color);
|
|
9644
|
+
if (rgb == null) {
|
|
9645
|
+
throw new Error(`Invalid hex color value: ${color}`);
|
|
9646
|
+
}
|
|
9647
|
+
return (0, import_fn.convertRgbToHsv)(rgb);
|
|
9648
|
+
};
|
|
9649
|
+
var convertToLrgb = (color) => {
|
|
9650
|
+
let result;
|
|
9651
|
+
if (typeof color === "string") {
|
|
9652
|
+
const rgb = (0, import_fn.parseHex)(color);
|
|
9653
|
+
if (rgb == null) {
|
|
9654
|
+
throw new Error(`Invalid hex color value: ${color}`);
|
|
9655
|
+
}
|
|
9656
|
+
result = (0, import_fn.convertRgbToLrgb)(rgb);
|
|
9657
|
+
} else {
|
|
9658
|
+
const rgb = (0, import_fn.convertHsvToRgb)(color);
|
|
9659
|
+
result = (0, import_fn.convertRgbToLrgb)(rgb);
|
|
9660
|
+
}
|
|
9661
|
+
return result;
|
|
9662
|
+
};
|
|
9663
|
+
var convertToRgb = (hsv) => (0, import_fn.convertHsvToRgb)(hsv);
|
|
9664
|
+
|
|
9638
9665
|
// src/components/ColorPicker/ColorGrid.tsx
|
|
9639
9666
|
var import_react42 = require("react");
|
|
9640
9667
|
var import_styled_components47 = __toESM(require("styled-components"));
|
|
@@ -9644,42 +9671,6 @@ var import_react_radio_group = require("@radix-ui/react-radio-group");
|
|
|
9644
9671
|
var import_react41 = require("react");
|
|
9645
9672
|
var import_fn4 = require("culori/fn");
|
|
9646
9673
|
|
|
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
9674
|
// src/components/ColorPicker/transitionBetweenColors.ts
|
|
9684
9675
|
var import_fn2 = require("culori/fn");
|
|
9685
9676
|
var transitionBetweenColors = (fromHsv, toHsv, onColorStep, onTransitionEnd) => {
|
|
@@ -9775,8 +9766,8 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9775
9766
|
v: extremeValue,
|
|
9776
9767
|
mode: "hsv"
|
|
9777
9768
|
};
|
|
9778
|
-
const
|
|
9779
|
-
const extremeContrast = (0, import_fn3.wcagContrast)(
|
|
9769
|
+
const extremeVariantAsLrgb = convertToLrgb(extremeVariant);
|
|
9770
|
+
const extremeContrast = (0, import_fn3.wcagContrast)(extremeVariantAsLrgb, colorForComparisonAsLrgb);
|
|
9780
9771
|
if (extremeContrast < minContrast) {
|
|
9781
9772
|
return null;
|
|
9782
9773
|
}
|
|
@@ -9792,8 +9783,7 @@ var getAccessibleColorByValueChannelChange = ({
|
|
|
9792
9783
|
v: midValue,
|
|
9793
9784
|
mode: "hsv"
|
|
9794
9785
|
};
|
|
9795
|
-
const
|
|
9796
|
-
const contrast = (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(candidateRgb), colorForComparisonAsLrgb);
|
|
9786
|
+
const contrast = (0, import_fn3.wcagContrast)(convertToLrgb(candidateHsv), colorForComparisonAsLrgb);
|
|
9797
9787
|
if (contrast >= minContrast) {
|
|
9798
9788
|
bestSoFar = candidateHsv;
|
|
9799
9789
|
}
|
|
@@ -9865,8 +9855,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
|
|
|
9865
9855
|
};
|
|
9866
9856
|
};
|
|
9867
9857
|
const checkContrast = (hsv) => {
|
|
9868
|
-
|
|
9869
|
-
return (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(rgb), colorForComparisonAsLrgb);
|
|
9858
|
+
return (0, import_fn3.wcagContrast)(convertToLrgb(hsv), colorForComparisonAsLrgb);
|
|
9870
9859
|
};
|
|
9871
9860
|
const extremeHsv = getHsvForStep(highStep);
|
|
9872
9861
|
if (checkContrast(extremeHsv) < minContrast) {
|
|
@@ -9924,8 +9913,7 @@ var getAccessibleColor = ({
|
|
|
9924
9913
|
minContrast = DEFAULT_MIN_CONTRAST,
|
|
9925
9914
|
maxIterations = 50
|
|
9926
9915
|
}) => {
|
|
9927
|
-
const
|
|
9928
|
-
const originalContrast = (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(originalRgb), colorForComparisonAsLrgb);
|
|
9916
|
+
const originalContrast = (0, import_fn3.wcagContrast)(convertToLrgb(originalHsv), colorForComparisonAsLrgb);
|
|
9929
9917
|
if (originalContrast >= minContrast) {
|
|
9930
9918
|
return originalHsv;
|
|
9931
9919
|
}
|
|
@@ -9956,8 +9944,7 @@ var hasAccessibleDerivatives = ({
|
|
|
9956
9944
|
colorForComparisonAsLrgb,
|
|
9957
9945
|
minContrast = DEFAULT_MIN_CONTRAST
|
|
9958
9946
|
}) => {
|
|
9959
|
-
const
|
|
9960
|
-
const originalContrast = (0, import_fn3.wcagContrast)((0, import_fn3.convertRgbToLrgb)(originalRgb), colorForComparisonAsLrgb);
|
|
9947
|
+
const originalContrast = (0, import_fn3.wcagContrast)(convertToLrgb(originalHsv), colorForComparisonAsLrgb);
|
|
9961
9948
|
if (originalContrast >= minContrast) {
|
|
9962
9949
|
return true;
|
|
9963
9950
|
}
|
|
@@ -9984,8 +9971,8 @@ var createInitialState = ({
|
|
|
9984
9971
|
colorForComparisonAsHex,
|
|
9985
9972
|
minimumContrastRatio
|
|
9986
9973
|
}) => {
|
|
9987
|
-
const
|
|
9988
|
-
const
|
|
9974
|
+
const valueAsHsv = convertToHsv(valueAsHex);
|
|
9975
|
+
const colorForComparisonAsLrgb = convertToLrgb(colorForComparisonAsHex);
|
|
9989
9976
|
return {
|
|
9990
9977
|
nonDerivedValueAsHsv: valueAsHsv,
|
|
9991
9978
|
nonDerivedValueAsHex: valueAsHex,
|
|
@@ -10059,18 +10046,11 @@ var ColorPickerProvider = ({
|
|
|
10059
10046
|
minimumContrastRatio
|
|
10060
10047
|
})
|
|
10061
10048
|
);
|
|
10062
|
-
const
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
const { lrgb: colorForComparisonAsLrgb, isValid: colorForComparisonIsValid } = getColorConversions(colorForComparisonAsHex);
|
|
10068
|
-
if (!valueIsValid) {
|
|
10069
|
-
throw new Error(`Invalid color value: ${JSON.stringify(state.valueAsHsv)}`);
|
|
10070
|
-
}
|
|
10071
|
-
if (!colorForComparisonIsValid) {
|
|
10072
|
-
throw new Error(`Invalid comparison color value: ${colorForComparisonAsHex}`);
|
|
10073
|
-
}
|
|
10049
|
+
const valueAsLrgb = (0, import_react41.useMemo)(() => convertToLrgb(state.valueAsHsv), [state.valueAsHsv]);
|
|
10050
|
+
const colorForComparisonAsLrgb = (0, import_react41.useMemo)(
|
|
10051
|
+
() => convertToLrgb(colorForComparisonAsHex),
|
|
10052
|
+
[colorForComparisonAsHex]
|
|
10053
|
+
);
|
|
10074
10054
|
const currentContrastRatio = (0, import_react41.useMemo)(() => {
|
|
10075
10055
|
return (0, import_fn4.wcagContrast)(valueAsLrgb, colorForComparisonAsLrgb);
|
|
10076
10056
|
}, [valueAsLrgb, colorForComparisonAsLrgb]);
|
|
@@ -10092,7 +10072,7 @@ var ColorPickerProvider = ({
|
|
|
10092
10072
|
const onValueAsHsvChange = (0, import_react41.useCallback)(
|
|
10093
10073
|
(rawNewValueAsHsv) => {
|
|
10094
10074
|
const hsvToSet = state.shouldEnforceMinContrast ? getAccessibleDerivativeColor(rawNewValueAsHsv) : rawNewValueAsHsv;
|
|
10095
|
-
const hexToSet =
|
|
10075
|
+
const hexToSet = (0, import_fn4.formatHex)(hsvToSet);
|
|
10096
10076
|
onValueChange(hexToSet);
|
|
10097
10077
|
dispatch({
|
|
10098
10078
|
type: "SET_VALUE_AS_HSV",
|
|
@@ -10108,7 +10088,7 @@ var ColorPickerProvider = ({
|
|
|
10108
10088
|
state.valueAsHsv,
|
|
10109
10089
|
toHsv,
|
|
10110
10090
|
(colorForStepAsHsv) => {
|
|
10111
|
-
const hexValue =
|
|
10091
|
+
const hexValue = (0, import_fn4.formatHex)(colorForStepAsHsv);
|
|
10112
10092
|
onValueChange(hexValue);
|
|
10113
10093
|
dispatch({ type: "SET_VALUE_AS_HSV", payload: { valueAsHsv: colorForStepAsHsv } });
|
|
10114
10094
|
},
|
|
@@ -10139,10 +10119,7 @@ var ColorPickerProvider = ({
|
|
|
10139
10119
|
if (valueAsHex === (0, import_fn4.formatHex)(state.valueAsHsv)) {
|
|
10140
10120
|
return;
|
|
10141
10121
|
}
|
|
10142
|
-
const
|
|
10143
|
-
if (!isNewValueValid) {
|
|
10144
|
-
throw new Error(`Invalid color value: ${valueAsHex}`);
|
|
10145
|
-
}
|
|
10122
|
+
const newValueAsHsv = convertToHsv(valueAsHex);
|
|
10146
10123
|
dispatch({
|
|
10147
10124
|
type: "SET_VALUE_AS_HSV",
|
|
10148
10125
|
payload: { valueAsHsv: newValueAsHsv }
|
|
@@ -10151,7 +10128,6 @@ var ColorPickerProvider = ({
|
|
|
10151
10128
|
const contextValue = (0, import_react41.useMemo)(
|
|
10152
10129
|
() => ({
|
|
10153
10130
|
...state,
|
|
10154
|
-
valueAsRgb,
|
|
10155
10131
|
valueAsLrgb,
|
|
10156
10132
|
currentContrastRatio,
|
|
10157
10133
|
hasAccessibleDerivatives: hasAccessibleDerivativesValue,
|
|
@@ -10164,7 +10140,6 @@ var ColorPickerProvider = ({
|
|
|
10164
10140
|
}),
|
|
10165
10141
|
[
|
|
10166
10142
|
state,
|
|
10167
|
-
valueAsRgb,
|
|
10168
10143
|
valueAsLrgb,
|
|
10169
10144
|
currentContrastRatio,
|
|
10170
10145
|
hasAccessibleDerivativesValue,
|
|
@@ -10200,13 +10175,7 @@ var ColorGrid = ({ children }) => {
|
|
|
10200
10175
|
const { valueAsHex, onValueAsHsvChange } = useColorPickerState();
|
|
10201
10176
|
const onValueChange = (0, import_react42.useCallback)(
|
|
10202
10177
|
(value) => {
|
|
10203
|
-
|
|
10204
|
-
return;
|
|
10205
|
-
}
|
|
10206
|
-
const { isValid, hsv } = getColorConversions(value);
|
|
10207
|
-
if (!isValid) {
|
|
10208
|
-
throw new Error(`Invalid color value: ${value}`);
|
|
10209
|
-
}
|
|
10178
|
+
const hsv = convertToHsv(value);
|
|
10210
10179
|
onValueAsHsvChange(hsv);
|
|
10211
10180
|
},
|
|
10212
10181
|
[onValueAsHsvChange]
|
|
@@ -10220,6 +10189,7 @@ var ColorGrid = ({ children }) => {
|
|
|
10220
10189
|
}
|
|
10221
10190
|
);
|
|
10222
10191
|
};
|
|
10192
|
+
ColorGrid.displayName = "ColorGrid";
|
|
10223
10193
|
|
|
10224
10194
|
// src/components/ColorPicker/ColorGridOption.tsx
|
|
10225
10195
|
var import_styled_components50 = __toESM(require("styled-components"));
|
|
@@ -10438,20 +10408,10 @@ var Container2 = (0, import_styled_components50.default)(import_react_radio_grou
|
|
|
10438
10408
|
appearance: none;
|
|
10439
10409
|
outline: none;
|
|
10440
10410
|
align-items: center;
|
|
10441
|
-
background-color: var(--wui-color-bg-surface);
|
|
10442
10411
|
border-radius: var(--wui-border-radius-rounded);
|
|
10443
10412
|
padding: 0;
|
|
10444
10413
|
cursor: pointer;
|
|
10445
10414
|
user-select: none;
|
|
10446
|
-
|
|
10447
|
-
&:hover,
|
|
10448
|
-
&:focus-visible {
|
|
10449
|
-
background-color: var(--wui-color-bg-surface-hover);
|
|
10450
|
-
}
|
|
10451
|
-
|
|
10452
|
-
&:focus-visible {
|
|
10453
|
-
background-color: var(--wui-color-bg-surface-secondary-hover);
|
|
10454
|
-
}
|
|
10455
10415
|
`;
|
|
10456
10416
|
var ColorGridOption = ({ value, name }) => {
|
|
10457
10417
|
const { valueAsHex, nonDerivedValueAsHex } = useColorPickerState();
|
|
@@ -10482,6 +10442,7 @@ var ColorGridOption = ({ value, name }) => {
|
|
|
10482
10442
|
}
|
|
10483
10443
|
);
|
|
10484
10444
|
};
|
|
10445
|
+
ColorGridOption.displayName = "ColorGridOption";
|
|
10485
10446
|
|
|
10486
10447
|
// src/components/ColorPicker/ColorList.tsx
|
|
10487
10448
|
var import_react43 = require("react");
|
|
@@ -10500,10 +10461,7 @@ var ColorList = ({ children }) => {
|
|
|
10500
10461
|
if (value === "") {
|
|
10501
10462
|
return;
|
|
10502
10463
|
}
|
|
10503
|
-
const
|
|
10504
|
-
if (!isValid) {
|
|
10505
|
-
throw new Error(`Invalid color value: ${value}`);
|
|
10506
|
-
}
|
|
10464
|
+
const hsv = convertToHsv(value);
|
|
10507
10465
|
onValueAsHsvChange(hsv);
|
|
10508
10466
|
},
|
|
10509
10467
|
[onValueAsHsvChange]
|
|
@@ -10518,6 +10476,7 @@ var ColorList = ({ children }) => {
|
|
|
10518
10476
|
}
|
|
10519
10477
|
);
|
|
10520
10478
|
};
|
|
10479
|
+
ColorList.displayName = "ColorList";
|
|
10521
10480
|
|
|
10522
10481
|
// src/components/ColorPicker/ColorListGroup.tsx
|
|
10523
10482
|
var import_styled_components52 = __toESM(require("styled-components"));
|
|
@@ -10547,6 +10506,7 @@ var ColorListGroup = ({ label, children }) => {
|
|
|
10547
10506
|
}
|
|
10548
10507
|
);
|
|
10549
10508
|
};
|
|
10509
|
+
ColorListGroup.displayName = "ColorListGroup";
|
|
10550
10510
|
|
|
10551
10511
|
// src/components/ColorPicker/ColorListOption.tsx
|
|
10552
10512
|
var import_styled_components53 = __toESM(require("styled-components"));
|
|
@@ -10641,13 +10601,11 @@ var ColorListOption = ({ value, name }) => {
|
|
|
10641
10601
|
}
|
|
10642
10602
|
);
|
|
10643
10603
|
};
|
|
10604
|
+
ColorListOption.displayName = "ColorListOption";
|
|
10644
10605
|
|
|
10645
10606
|
// src/components/ColorPicker/ColorPicker.tsx
|
|
10646
10607
|
var import_react_popover = require("@radix-ui/react-popover");
|
|
10647
|
-
var import_fn5 = require("culori/fn");
|
|
10648
10608
|
var import_jsx_runtime234 = require("react/jsx-runtime");
|
|
10649
|
-
(0, import_fn5.useMode)(import_fn5.modeRgb);
|
|
10650
|
-
(0, import_fn5.useMode)(import_fn5.modeHsv);
|
|
10651
10609
|
var ColorPicker = ({
|
|
10652
10610
|
value,
|
|
10653
10611
|
onValueChange,
|
|
@@ -10668,6 +10626,7 @@ var ColorPicker = ({
|
|
|
10668
10626
|
}
|
|
10669
10627
|
) });
|
|
10670
10628
|
};
|
|
10629
|
+
ColorPicker.displayName = "ColorPicker";
|
|
10671
10630
|
|
|
10672
10631
|
// src/components/ColorPicker/ColorPickerPopoverContent.tsx
|
|
10673
10632
|
var import_react_popover2 = require("@radix-ui/react-popover");
|
|
@@ -10696,6 +10655,7 @@ var ColorPickerPopoverContent = ({
|
|
|
10696
10655
|
}
|
|
10697
10656
|
) });
|
|
10698
10657
|
};
|
|
10658
|
+
ColorPickerPopoverContent.displayName = "ColorPickerPopoverContent";
|
|
10699
10659
|
|
|
10700
10660
|
// src/components/ColorPicker/ColorPickerSection.tsx
|
|
10701
10661
|
var import_styled_components55 = __toESM(require("styled-components"));
|
|
@@ -10706,6 +10666,7 @@ var Container5 = import_styled_components55.default.div`
|
|
|
10706
10666
|
var ColorPickerSection = ({ children }) => {
|
|
10707
10667
|
return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(Container5, { children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(Stack, { children }) });
|
|
10708
10668
|
};
|
|
10669
|
+
ColorPickerSection.displayName = "ColorPickerSection";
|
|
10709
10670
|
|
|
10710
10671
|
// src/components/ColorPicker/ColorPickerTrigger.tsx
|
|
10711
10672
|
var import_react44 = require("react");
|
|
@@ -10718,6 +10679,7 @@ var ValueSwatch = () => {
|
|
|
10718
10679
|
const { valueAsHex } = useColorPickerState();
|
|
10719
10680
|
return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)(ColorSwatch, { value: valueAsHex });
|
|
10720
10681
|
};
|
|
10682
|
+
ValueSwatch.displayName = "ValueSwatch";
|
|
10721
10683
|
|
|
10722
10684
|
// src/components/ColorPicker/ValueNameOrHexCode.tsx
|
|
10723
10685
|
var import_jsx_runtime238 = require("react/jsx-runtime");
|
|
@@ -10725,6 +10687,7 @@ var ValueNameOrHexCode = () => {
|
|
|
10725
10687
|
const { valueAsHex } = useColorPickerState();
|
|
10726
10688
|
return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(ColorNameOrHexCode, { hexCode: valueAsHex });
|
|
10727
10689
|
};
|
|
10690
|
+
ValueNameOrHexCode.displayName = "ValueNameOrHexCode";
|
|
10728
10691
|
|
|
10729
10692
|
// src/components/ColorPicker/ColorPickerTrigger.tsx
|
|
10730
10693
|
var import_jsx_runtime239 = require("react/jsx-runtime");
|
|
@@ -11048,10 +11011,11 @@ var ContrastControls = () => {
|
|
|
11048
11011
|
/* @__PURE__ */ (0, import_jsx_runtime244.jsx)(ContrastEnforcerSwitch, {})
|
|
11049
11012
|
] });
|
|
11050
11013
|
};
|
|
11014
|
+
ContrastControls.displayName = "ContrastControls";
|
|
11051
11015
|
|
|
11052
11016
|
// src/components/ColorPicker/HexColorInput.tsx
|
|
11053
11017
|
var import_react48 = require("react");
|
|
11054
|
-
var
|
|
11018
|
+
var import_fn5 = require("culori/fn");
|
|
11055
11019
|
|
|
11056
11020
|
// src/components/Input/Input.tsx
|
|
11057
11021
|
var import_react47 = require("react");
|
|
@@ -11200,10 +11164,7 @@ var Input = (0, import_react47.forwardRef)(
|
|
|
11200
11164
|
...props
|
|
11201
11165
|
}, externalRef) => {
|
|
11202
11166
|
const internalRef = (0, import_react47.useRef)();
|
|
11203
|
-
const ref = (
|
|
11204
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
11205
|
-
(0, import_type_guards35.isNotNil)(externalRef) && (0, import_type_guards35.isRecord)(externalRef) && "current" in externalRef ? externalRef : internalRef
|
|
11206
|
-
);
|
|
11167
|
+
const ref = (0, import_type_guards35.isNotNil)(externalRef) && (0, import_type_guards35.isRecord)(externalRef) && "current" in externalRef ? externalRef : internalRef;
|
|
11207
11168
|
let leftIconToDisplay = leftIcon;
|
|
11208
11169
|
if ((0, import_type_guards35.isNil)(leftIcon) && type === "search") {
|
|
11209
11170
|
leftIconToDisplay = /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(Icon, { type: "search" });
|
|
@@ -11284,14 +11245,14 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11284
11245
|
(event) => {
|
|
11285
11246
|
const newValue = (event.target.value || "#").trim().toLocaleLowerCase();
|
|
11286
11247
|
setTextInputValue(newValue);
|
|
11287
|
-
const isValidHexValue = Boolean((0,
|
|
11248
|
+
const isValidHexValue = Boolean((0, import_fn5.parseHex)(newValue));
|
|
11288
11249
|
if (!isValidHexValue) {
|
|
11289
11250
|
return;
|
|
11290
11251
|
}
|
|
11291
11252
|
if (newValue.length < SIX_DIGIT_HEX_CODE_LENGTH) {
|
|
11292
11253
|
return;
|
|
11293
11254
|
}
|
|
11294
|
-
const newValueAsHsv =
|
|
11255
|
+
const newValueAsHsv = convertToHsv(newValue);
|
|
11295
11256
|
onValueAsHsvChange(newValueAsHsv);
|
|
11296
11257
|
},
|
|
11297
11258
|
[onValueAsHsvChange]
|
|
@@ -11332,7 +11293,7 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11332
11293
|
}
|
|
11333
11294
|
if (key === "ArrowUp" || key === "ArrowDown") {
|
|
11334
11295
|
event.preventDefault();
|
|
11335
|
-
const
|
|
11296
|
+
const currentHsv = convertToHsv(valueAsHex);
|
|
11336
11297
|
const saturationNudge = 0.02;
|
|
11337
11298
|
const newSaturation = Math.max(
|
|
11338
11299
|
0,
|
|
@@ -11366,12 +11327,12 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11366
11327
|
event.preventDefault();
|
|
11367
11328
|
const pastedText = event.clipboardData.getData("text");
|
|
11368
11329
|
const normalizedValue = normalizeHexInput(pastedText);
|
|
11369
|
-
const isValidHexValue = Boolean((0,
|
|
11330
|
+
const isValidHexValue = Boolean((0, import_fn5.parseHex)(normalizedValue));
|
|
11370
11331
|
setTextInputValue(normalizedValue);
|
|
11371
11332
|
if (!isValidHexValue) {
|
|
11372
11333
|
return;
|
|
11373
11334
|
}
|
|
11374
|
-
const newValueAsHsv =
|
|
11335
|
+
const newValueAsHsv = convertToHsv(normalizedValue);
|
|
11375
11336
|
onValueAsHsvChange(newValueAsHsv);
|
|
11376
11337
|
},
|
|
11377
11338
|
[onValueAsHsvChange]
|
|
@@ -11423,17 +11384,18 @@ var HexColorInput = ({ autoFocus = true }) => {
|
|
|
11423
11384
|
}
|
|
11424
11385
|
);
|
|
11425
11386
|
};
|
|
11387
|
+
HexColorInput.displayName = "HexColorInput";
|
|
11426
11388
|
|
|
11427
11389
|
// src/components/ColorPicker/HueSlider.tsx
|
|
11428
11390
|
var import_react50 = require("react");
|
|
11429
11391
|
var import_react_slider = require("@radix-ui/react-slider");
|
|
11430
11392
|
var import_styled_components62 = __toESM(require("styled-components"));
|
|
11431
|
-
var
|
|
11393
|
+
var import_fn7 = require("culori/fn");
|
|
11432
11394
|
|
|
11433
11395
|
// src/components/ColorPicker/HSVHueCanvas.tsx
|
|
11434
11396
|
var import_react49 = require("react");
|
|
11435
11397
|
var import_styled_components61 = __toESM(require("styled-components"));
|
|
11436
|
-
var
|
|
11398
|
+
var import_fn6 = require("culori/fn");
|
|
11437
11399
|
var import_jsx_runtime247 = require("react/jsx-runtime");
|
|
11438
11400
|
var Canvas = import_styled_components61.default.canvas`
|
|
11439
11401
|
display: block;
|
|
@@ -11455,7 +11417,7 @@ var HSVHueCanvas = ({ hsv }) => {
|
|
|
11455
11417
|
const gradient = ctx.createLinearGradient(0, 0, width, 0);
|
|
11456
11418
|
for (let i = 0; i <= THREE_SIXTY; i++) {
|
|
11457
11419
|
const hue = i;
|
|
11458
|
-
const hexColor = (0,
|
|
11420
|
+
const hexColor = (0, import_fn6.formatHex)({ h: hue, s: hsv.s, v: hsv.v, mode: "hsv" });
|
|
11459
11421
|
if (hexColor) {
|
|
11460
11422
|
gradient.addColorStop(i / THREE_SIXTY, hexColor);
|
|
11461
11423
|
}
|
|
@@ -11518,7 +11480,7 @@ var HueSlider = () => {
|
|
|
11518
11480
|
const { nonDerivedValueAsHsv, onValueAsHsvChange, valueAsHsv } = useColorPickerState();
|
|
11519
11481
|
const containerStyle = (0, import_react50.useMemo)(() => {
|
|
11520
11482
|
return {
|
|
11521
|
-
backgroundColor: (0,
|
|
11483
|
+
backgroundColor: (0, import_fn7.formatHex)({
|
|
11522
11484
|
h: 0,
|
|
11523
11485
|
// red
|
|
11524
11486
|
s: valueAsHsv.s,
|
|
@@ -11528,7 +11490,7 @@ var HueSlider = () => {
|
|
|
11528
11490
|
};
|
|
11529
11491
|
}, [valueAsHsv.s, valueAsHsv.v]);
|
|
11530
11492
|
const thumbInnerStyle = (0, import_react50.useMemo)(() => {
|
|
11531
|
-
return { backgroundColor: (0,
|
|
11493
|
+
return { backgroundColor: (0, import_fn7.formatHex)(valueAsHsv) };
|
|
11532
11494
|
}, [valueAsHsv]);
|
|
11533
11495
|
const onHueChange = (0, import_react50.useCallback)(
|
|
11534
11496
|
(values) => {
|
|
@@ -11559,6 +11521,7 @@ var HueSlider = () => {
|
|
|
11559
11521
|
/* @__PURE__ */ (0, import_jsx_runtime248.jsx)(HSVHueCanvas, { hsv: valueAsHsv })
|
|
11560
11522
|
] });
|
|
11561
11523
|
};
|
|
11524
|
+
HueSlider.displayName = "HueSlider";
|
|
11562
11525
|
|
|
11563
11526
|
// src/components/ColorPicker/SaturationAndValuePicker.tsx
|
|
11564
11527
|
var import_react52 = require("react");
|
|
@@ -11567,7 +11530,6 @@ var import_styled_components64 = __toESM(require("styled-components"));
|
|
|
11567
11530
|
// src/components/ColorPicker/HSVSaturationValueCanvas.tsx
|
|
11568
11531
|
var import_react51 = require("react");
|
|
11569
11532
|
var import_styled_components63 = __toESM(require("styled-components"));
|
|
11570
|
-
var import_fn9 = require("culori/fn");
|
|
11571
11533
|
|
|
11572
11534
|
// src/components/ColorPicker/canvas-utils.ts
|
|
11573
11535
|
var drawSmoothCurve = (context, points) => {
|
|
@@ -11636,7 +11598,7 @@ var drawGradientBackground = (ctx, width, height, hue) => {
|
|
|
11636
11598
|
const v = 1 - y / (height - 1);
|
|
11637
11599
|
for (let x = 0; x < width; x++) {
|
|
11638
11600
|
const s = x / (width - 1);
|
|
11639
|
-
const rgb = (
|
|
11601
|
+
const rgb = convertToRgb({ h: hue, s, v, mode: "hsv" });
|
|
11640
11602
|
const idx = 4 * (y * width + x);
|
|
11641
11603
|
data[idx] = rgb.r * TWO_FIFTY_FIVE;
|
|
11642
11604
|
data[idx + 1] = rgb.g * TWO_FIFTY_FIVE;
|
|
@@ -11931,6 +11893,7 @@ var SaturationAndValuePicker = ({
|
|
|
11931
11893
|
)
|
|
11932
11894
|
);
|
|
11933
11895
|
};
|
|
11896
|
+
SaturationAndValuePicker.displayName = "SaturationAndValuePicker";
|
|
11934
11897
|
|
|
11935
11898
|
// src/components/Combobox/Combobox.tsx
|
|
11936
11899
|
var Ariakit = __toESM(require("@ariakit/react"));
|