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

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.3-beta.a65ea2b3.ea2330d
3
+ * @license @wistia/ui v0.14.3
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -10062,7 +10062,6 @@ 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));
10066
10065
  const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
10067
10066
  const getAccessibleDerivativeColor = (0, import_react41.useCallback)(
10068
10067
  (originalColor) => getAccessibleColor({
@@ -10073,6 +10072,7 @@ var ColorPickerProvider = ({
10073
10072
  }),
10074
10073
  [colorForComparison, minimumContrastRatio, opacityForContrastCalculation]
10075
10074
  );
10075
+ const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
10076
10076
  const currentContrastRatio = calculateContrast({
10077
10077
  backgroundColor: valueAsHex,
10078
10078
  foregroundColor: colorForComparison,
@@ -10086,18 +10086,9 @@ var ColorPickerProvider = ({
10086
10086
  opacityForContrastCalculation
10087
10087
  });
10088
10088
  }, [valueAsHex, colorForComparison, minimumContrastRatio, opacityForContrastCalculation]);
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
- );
10089
+ const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
10090
+ setNonDerivedValueAsHsv(nonDerivedValue);
10091
+ }, []);
10101
10092
  const changeValueSmoothly = (0, import_react41.useCallback)(
10102
10093
  (toHsv) => {
10103
10094
  setIsTransitioning(true);
@@ -10107,7 +10098,6 @@ var ColorPickerProvider = ({
10107
10098
  (colorForStepAsHsv) => {
10108
10099
  const hexValue = (0, import_fn4.formatHex)(colorForStepAsHsv);
10109
10100
  onValueChange(hexValue);
10110
- setValueAsHsv(colorForStepAsHsv);
10111
10101
  },
10112
10102
  () => {
10113
10103
  setIsTransitioning(false);
@@ -10133,11 +10123,12 @@ var ColorPickerProvider = ({
10133
10123
  valueAsHsv
10134
10124
  ]
10135
10125
  );
10136
- const whatValueAsHexShouldBe = (0, import_fn4.formatHex)(valueAsHsv);
10137
- if (whatValueAsHexShouldBe !== valueAsHex && !isTransitioning) {
10138
- setValueAsHsv(convertToHsv(valueAsHex));
10139
- setNonDerivedValueAsHsv(convertToHsv(valueAsHex));
10140
- }
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 !== whatValuePropShouldBe && !isTransitioning) {
10129
+ onValueChange(whatValuePropShouldBe);
10130
+ }
10131
+ }, [valueAsHex, whatValuePropShouldBe, isTransitioning, onValueChange]);
10141
10132
  const contextValue = (0, import_react41.useMemo)(
10142
10133
  () => ({
10143
10134
  colorForComparison,