@wistia/ui 0.14.2 → 0.14.3-beta.a65ea2b3.ea2330d

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 CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v0.14.2
3
+ * @license @wistia/ui v0.14.3-beta.a65ea2b3.ea2330d
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -10062,6 +10062,7 @@ var ColorPickerProvider = ({
10062
10062
  }) => {
10063
10063
  const [isTransitioning, setIsTransitioning] = (0, import_react41.useState)(false);
10064
10064
  const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
10065
+ const [valueAsHsv, setValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
10065
10066
  const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
10066
10067
  const getAccessibleDerivativeColor = (0, import_react41.useCallback)(
10067
10068
  (originalColor) => getAccessibleColor({
@@ -10072,7 +10073,6 @@ var ColorPickerProvider = ({
10072
10073
  }),
10073
10074
  [colorForComparison, minimumContrastRatio, opacityForContrastCalculation]
10074
10075
  );
10075
- const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
10076
10076
  const currentContrastRatio = calculateContrast({
10077
10077
  backgroundColor: valueAsHex,
10078
10078
  foregroundColor: colorForComparison,
@@ -10086,9 +10086,18 @@ var ColorPickerProvider = ({
10086
10086
  opacityForContrastCalculation
10087
10087
  });
10088
10088
  }, [valueAsHex, colorForComparison, minimumContrastRatio, opacityForContrastCalculation]);
10089
- const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
10090
- setNonDerivedValueAsHsv(nonDerivedValue);
10091
- }, []);
10089
+ const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)(
10090
+ (nonDerivedValue) => {
10091
+ const finalValue = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValue) : nonDerivedValue;
10092
+ const finalValueAsHex = (0, import_fn4.formatHex)(finalValue);
10093
+ if (finalValueAsHex !== valueAsHex) {
10094
+ onValueChange(finalValueAsHex);
10095
+ }
10096
+ setValueAsHsv(finalValue);
10097
+ setNonDerivedValueAsHsv(nonDerivedValue);
10098
+ },
10099
+ [getAccessibleDerivativeColor, onValueChange, shouldEnforceMinContrast, valueAsHex]
10100
+ );
10092
10101
  const changeValueSmoothly = (0, import_react41.useCallback)(
10093
10102
  (toHsv) => {
10094
10103
  setIsTransitioning(true);
@@ -10098,6 +10107,7 @@ var ColorPickerProvider = ({
10098
10107
  (colorForStepAsHsv) => {
10099
10108
  const hexValue = (0, import_fn4.formatHex)(colorForStepAsHsv);
10100
10109
  onValueChange(hexValue);
10110
+ setValueAsHsv(colorForStepAsHsv);
10101
10111
  },
10102
10112
  () => {
10103
10113
  setIsTransitioning(false);
@@ -10123,12 +10133,11 @@ var ColorPickerProvider = ({
10123
10133
  valueAsHsv
10124
10134
  ]
10125
10135
  );
10126
- const whatValuePropShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(getAccessibleDerivativeColor((0, import_fn4.formatHex)(nonDerivedValueAsHsv))) : (0, import_fn4.formatHex)(nonDerivedValueAsHsv);
10127
- (0, import_react41.useEffect)(() => {
10128
- if (valueAsHex.toLocaleLowerCase() !== whatValuePropShouldBe.toLocaleLowerCase() && !isTransitioning) {
10129
- onValueChange(whatValuePropShouldBe);
10130
- }
10131
- }, [valueAsHex, whatValuePropShouldBe, isTransitioning, onValueChange]);
10136
+ const whatValueAsHexShouldBe = (0, import_fn4.formatHex)(valueAsHsv);
10137
+ if (whatValueAsHexShouldBe !== valueAsHex && !isTransitioning) {
10138
+ setValueAsHsv(convertToHsv(valueAsHex));
10139
+ setNonDerivedValueAsHsv(convertToHsv(valueAsHex));
10140
+ }
10132
10141
  const contextValue = (0, import_react41.useMemo)(
10133
10142
  () => ({
10134
10143
  colorForComparison,
@@ -10497,7 +10506,8 @@ var Container2 = (0, import_styled_components51.default)(import_react_radio_grou
10497
10506
  cursor: pointer;
10498
10507
  user-select: none;
10499
10508
  `;
10500
- var ColorGridOption = ({ value, name }) => {
10509
+ var ColorGridOption = ({ value: rawValue, name }) => {
10510
+ const value = rawValue.toLocaleLowerCase();
10501
10511
  const { valueAsHsv, nonDerivedValueAsHex } = useColorPickerState();
10502
10512
  const valueAsHex = (0, import_fn5.formatHex)(valueAsHsv);
10503
10513
  const isSelected = valueAsHex === value;
@@ -10655,7 +10665,8 @@ var Container5 = (0, import_styled_components54.default)(import_react_toggle_gro
10655
10665
  background-color: var(--wui-color-bg-surface-secondary-hover);
10656
10666
  }
10657
10667
  `;
10658
- var ColorListOption = ({ value, name }) => {
10668
+ var ColorListOption = ({ value: rawValue, name }) => {
10669
+ const value = rawValue.toLocaleLowerCase();
10659
10670
  const { valueAsHsv, nonDerivedValueAsHex } = useColorPickerState();
10660
10671
  const valueAsHex = (0, import_fn6.formatHex)(valueAsHsv);
10661
10672
  const isSelected = valueAsHex === value;
@@ -10708,7 +10719,7 @@ var ColorPicker = ({
10708
10719
  minimumContrastRatio,
10709
10720
  onValueChange,
10710
10721
  opacityForContrastCalculation,
10711
- value,
10722
+ value: value.toLocaleLowerCase(),
10712
10723
  children
10713
10724
  }
10714
10725
  ) });