@wistia/ui 0.14.6 → 0.14.7

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.6
3
+ * @license @wistia/ui v0.14.7
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -10061,6 +10061,7 @@ var ColorPickerProvider = ({
10061
10061
  value: valueAsHex
10062
10062
  }) => {
10063
10063
  const [isTransitioning, setIsTransitioning] = (0, import_react41.useState)(false);
10064
+ const [isDragging, setIsDragging] = (0, import_react41.useState)(false);
10064
10065
  const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
10065
10066
  const [valueAsHsv, setValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
10066
10067
  const [shouldEnforceMinContrast, setShouldEnforceMinContrast] = (0, import_react41.useState)(false);
@@ -10133,23 +10134,41 @@ var ColorPickerProvider = ({
10133
10134
  valueAsHsv
10134
10135
  ]
10135
10136
  );
10136
- const whatValueAsHexShouldBe = (0, import_fn4.formatHex)(valueAsHsv);
10137
- if (whatValueAsHexShouldBe !== valueAsHex && !isTransitioning) {
10138
- setValueAsHsv(convertToHsv(valueAsHex));
10137
+ const accessibleHsvFromValueAsHex = getAccessibleDerivativeColor(valueAsHex);
10138
+ const whatValueAsHexShouldBe = shouldEnforceMinContrast ? (0, import_fn4.formatHex)(accessibleHsvFromValueAsHex) : valueAsHex;
10139
+ const valueAsHsvConvertedToHex = (0, import_fn4.formatHex)(valueAsHsv);
10140
+ if (whatValueAsHexShouldBe !== valueAsHsvConvertedToHex && !isTransitioning && !isDragging) {
10141
+ setValueAsHsv(
10142
+ shouldEnforceMinContrast ? getAccessibleDerivativeColor(valueAsHex) : convertToHsv(valueAsHex)
10143
+ );
10139
10144
  setNonDerivedValueAsHsv(convertToHsv(valueAsHex));
10140
10145
  }
10146
+ (0, import_react41.useEffect)(() => {
10147
+ if (valueAsHex !== valueAsHsvConvertedToHex && !isTransitioning && !isDragging) {
10148
+ onValueChange(whatValueAsHexShouldBe);
10149
+ }
10150
+ }, [
10151
+ isDragging,
10152
+ isTransitioning,
10153
+ onValueChange,
10154
+ valueAsHex,
10155
+ valueAsHsvConvertedToHex,
10156
+ whatValueAsHexShouldBe
10157
+ ]);
10141
10158
  const contextValue = (0, import_react41.useMemo)(
10142
10159
  () => ({
10143
10160
  colorForComparison,
10144
10161
  currentContrastRatio,
10145
10162
  getAccessibleDerivativeColor,
10146
10163
  hasAccessibleDerivatives: hasAccessibleDerivativesValue,
10164
+ isDragging,
10147
10165
  isTransitioning,
10148
10166
  minimumContrastRatio,
10149
10167
  nonDerivedValueAsHex: (0, import_fn4.formatHex)(nonDerivedValueAsHsv),
10150
10168
  nonDerivedValueAsHsv,
10151
10169
  onChangeNonDerivedValueAsHsv,
10152
10170
  opacityForContrastCalculation,
10171
+ setIsDragging,
10153
10172
  setShouldEnforceMinContrast: setShouldEnforceMinContrastWrapped,
10154
10173
  shouldEnforceMinContrast,
10155
10174
  valueAsHex,
@@ -10160,6 +10179,7 @@ var ColorPickerProvider = ({
10160
10179
  currentContrastRatio,
10161
10180
  getAccessibleDerivativeColor,
10162
10181
  hasAccessibleDerivativesValue,
10182
+ isDragging,
10163
10183
  isTransitioning,
10164
10184
  minimumContrastRatio,
10165
10185
  nonDerivedValueAsHsv,
@@ -11811,11 +11831,13 @@ var SaturationAndValuePicker = ({
11811
11831
  }) => {
11812
11832
  const {
11813
11833
  colorForComparison,
11834
+ isDragging,
11814
11835
  isTransitioning,
11815
11836
  minimumContrastRatio,
11816
11837
  nonDerivedValueAsHsv,
11817
11838
  onChangeNonDerivedValueAsHsv,
11818
11839
  opacityForContrastCalculation,
11840
+ setIsDragging,
11819
11841
  shouldEnforceMinContrast,
11820
11842
  valueAsHex,
11821
11843
  valueAsHsv
@@ -11865,7 +11887,6 @@ var SaturationAndValuePicker = ({
11865
11887
  },
11866
11888
  [nonDerivedValueAsHsv, onChangeNonDerivedValueAsHsv]
11867
11889
  );
11868
- const [isDragging, setIsDragging] = (0, import_react52.useState)(false);
11869
11890
  const updateSaturationAndValueFromCoordinates = (0, import_react52.useCallback)(
11870
11891
  (clientX, clientY) => {
11871
11892
  const container = containerRef.current;
@@ -11892,7 +11913,7 @@ var SaturationAndValuePicker = ({
11892
11913
  setIsDragging(true);
11893
11914
  updateSaturationAndValueFromCoordinates(event.clientX, event.clientY);
11894
11915
  },
11895
- [updateSaturationAndValueFromCoordinates, thumbRef]
11916
+ [setIsDragging, updateSaturationAndValueFromCoordinates]
11896
11917
  );
11897
11918
  const onThumbMouseDown = (0, import_react52.useCallback)(
11898
11919
  (event) => {
@@ -11900,7 +11921,7 @@ var SaturationAndValuePicker = ({
11900
11921
  thumbRef.current?.focus();
11901
11922
  setIsDragging(true);
11902
11923
  },
11903
- [thumbRef]
11924
+ [setIsDragging]
11904
11925
  );
11905
11926
  const onThumbKeyDown = (0, import_react52.useCallback)(
11906
11927
  (event) => {
@@ -11935,7 +11956,7 @@ var SaturationAndValuePicker = ({
11935
11956
  },
11936
11957
  [isDragging, updateSaturationAndValueFromCoordinates]
11937
11958
  );
11938
- const onWindowMouseUp = (0, import_react52.useCallback)(() => setIsDragging(false), []);
11959
+ const onWindowMouseUp = (0, import_react52.useCallback)(() => setIsDragging(false), [setIsDragging]);
11939
11960
  (0, import_react52.useEffect)(() => {
11940
11961
  window.addEventListener("mousemove", onWindowMouseMove);
11941
11962
  window.addEventListener("mouseup", onWindowMouseUp);