@wistia/ui 0.13.5 → 0.13.6-beta.171ec663.20d8398

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.13.5
3
+ * @license @wistia/ui v0.13.6-beta.171ec663.20d8398
4
4
  *
5
5
  * Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
6
6
  *
@@ -1453,8 +1453,9 @@ var import_styled_components7 = require("styled-components");
1453
1453
  var zIndexTokens = import_styled_components7.css`
1454
1454
  --wui-zindex-under: -1;
1455
1455
  --wui-zindex-backdrop: 500;
1456
- --wui-zindex-modal: 500;
1457
1456
  --wui-zindex-menu: 500;
1457
+ --wui-zindex-modal: 500;
1458
+ --wui-zindex-popover: 500;
1458
1459
  --wui-zindex-select: 500;
1459
1460
  --wui-zindex-tooltip: 500;
1460
1461
  `;
@@ -9745,10 +9746,21 @@ var THREE_SIXTY = 360;
9745
9746
  var TWO_FIFTY_FIVE = 255;
9746
9747
  var DEFAULT_MIN_CONTRAST = 4.5;
9747
9748
  var DEFAULT_COLOR_FOR_COMPARISON = "#ffffff";
9749
+ var DEFAULT_OPACITY_FOR_CONTRAST_CALCULATION = 1;
9748
9750
 
9749
9751
  // src/components/ColorPicker/contrast-utils.ts
9750
9752
  var CONTRAST_EPSILON = 4e-3;
9751
9753
  var VALUE_CHANNEL_SNAP_EPSILON = 5e-4;
9754
+ var compositeOverWhite = (color, alpha = 1) => {
9755
+ const compositeChannel = (channel) => alpha * channel + (1 - alpha);
9756
+ const colorAsRgb = convertToRgb(color);
9757
+ return {
9758
+ mode: "rgb",
9759
+ r: compositeChannel(colorAsRgb.r),
9760
+ g: compositeChannel(colorAsRgb.g),
9761
+ b: compositeChannel(colorAsRgb.b)
9762
+ };
9763
+ };
9752
9764
  var snapValueToEdges = (value) => {
9753
9765
  if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) {
9754
9766
  return 1;
@@ -9775,7 +9787,8 @@ var getAccessibleColorByValueChannelChange = ({
9775
9787
  colorForComparison,
9776
9788
  minContrast,
9777
9789
  maxIterations = 50,
9778
- direction
9790
+ direction,
9791
+ opacityForContrastCalculation
9779
9792
  }) => {
9780
9793
  const searchingBrighter = direction === "brighter";
9781
9794
  const lowValue = searchingBrighter ? originalHsv.v : 0;
@@ -9787,7 +9800,10 @@ var getAccessibleColorByValueChannelChange = ({
9787
9800
  v: extremeValue,
9788
9801
  mode: "hsv"
9789
9802
  };
9790
- const extremeContrast = (0, import_fn3.wcagContrast)(extremeVariant, colorForComparison);
9803
+ const extremeContrast = (0, import_fn3.wcagContrast)(
9804
+ compositeOverWhite(extremeVariant, opacityForContrastCalculation),
9805
+ colorForComparison
9806
+ );
9791
9807
  if (extremeContrast < minContrast) {
9792
9808
  return null;
9793
9809
  }
@@ -9803,7 +9819,10 @@ var getAccessibleColorByValueChannelChange = ({
9803
9819
  v: midValue,
9804
9820
  mode: "hsv"
9805
9821
  };
9806
- const contrast = (0, import_fn3.wcagContrast)(candidateHsv, colorForComparison);
9822
+ const contrast = (0, import_fn3.wcagContrast)(
9823
+ compositeOverWhite(candidateHsv, opacityForContrastCalculation),
9824
+ colorForComparison
9825
+ );
9807
9826
  if (contrast >= minContrast) {
9808
9827
  bestSoFar = candidateHsv;
9809
9828
  }
@@ -9848,7 +9867,8 @@ var getAccessibleColorBySaturationAndValueChange = ({
9848
9867
  originalHsv,
9849
9868
  colorForComparison,
9850
9869
  minContrast,
9851
- direction
9870
+ direction,
9871
+ opacityForContrastCalculation
9852
9872
  }) => {
9853
9873
  const hsvDifference = (0, import_fn3.differenceEuclidean)("hsv");
9854
9874
  const maxIterations = 50;
@@ -9875,7 +9895,7 @@ var getAccessibleColorBySaturationAndValueChange = ({
9875
9895
  };
9876
9896
  };
9877
9897
  const checkContrast = (hsv) => {
9878
- return (0, import_fn3.wcagContrast)(hsv, colorForComparison);
9898
+ return (0, import_fn3.wcagContrast)(compositeOverWhite(hsv, opacityForContrastCalculation), colorForComparison);
9879
9899
  };
9880
9900
  const extremeHsv = getHsvForStep(highStep);
9881
9901
  if (checkContrast(extremeHsv) < minContrast) {
@@ -9908,14 +9928,16 @@ var getAccessibleColorInDirection = ({
9908
9928
  colorForComparison,
9909
9929
  minContrast,
9910
9930
  maxIterations = 50,
9911
- direction
9931
+ direction,
9932
+ opacityForContrastCalculation
9912
9933
  }) => {
9913
9934
  const valueResult = getAccessibleColorByValueChannelChange({
9914
9935
  originalHsv,
9915
9936
  colorForComparison,
9916
9937
  minContrast,
9917
9938
  maxIterations,
9918
- direction
9939
+ direction,
9940
+ opacityForContrastCalculation
9919
9941
  });
9920
9942
  if (valueResult !== null) {
9921
9943
  return valueResult;
@@ -9924,16 +9946,21 @@ var getAccessibleColorInDirection = ({
9924
9946
  originalHsv,
9925
9947
  colorForComparison,
9926
9948
  minContrast,
9927
- direction
9949
+ direction,
9950
+ opacityForContrastCalculation
9928
9951
  });
9929
9952
  };
9930
9953
  var getAccessibleColor = ({
9931
9954
  originalHsv,
9932
9955
  colorForComparison,
9933
9956
  minContrast = DEFAULT_MIN_CONTRAST,
9934
- maxIterations = 50
9957
+ maxIterations = 50,
9958
+ opacityForContrastCalculation
9935
9959
  }) => {
9936
- const originalContrast = (0, import_fn3.wcagContrast)(originalHsv, colorForComparison);
9960
+ const originalContrast = (0, import_fn3.wcagContrast)(
9961
+ compositeOverWhite(originalHsv, opacityForContrastCalculation),
9962
+ colorForComparison
9963
+ );
9937
9964
  if (originalContrast >= minContrast) {
9938
9965
  return originalHsv;
9939
9966
  }
@@ -9942,14 +9969,16 @@ var getAccessibleColor = ({
9942
9969
  colorForComparison,
9943
9970
  minContrast,
9944
9971
  maxIterations,
9945
- direction: "brighter"
9972
+ direction: "brighter",
9973
+ opacityForContrastCalculation
9946
9974
  });
9947
9975
  const darkerOption = getAccessibleColorInDirection({
9948
9976
  originalHsv,
9949
9977
  colorForComparison,
9950
9978
  minContrast,
9951
9979
  maxIterations,
9952
- direction: "darker"
9980
+ direction: "darker",
9981
+ opacityForContrastCalculation
9953
9982
  });
9954
9983
  const result = chooseClosestDerivativeToOriginal(brighterOption, darkerOption, originalHsv);
9955
9984
  if (result == null) {
@@ -9962,9 +9991,13 @@ var getAccessibleColor = ({
9962
9991
  var hasAccessibleDerivatives = ({
9963
9992
  originalHsv,
9964
9993
  colorForComparison,
9965
- minContrast = DEFAULT_MIN_CONTRAST
9994
+ minContrast = DEFAULT_MIN_CONTRAST,
9995
+ opacityForContrastCalculation
9966
9996
  }) => {
9967
- const originalContrast = (0, import_fn3.wcagContrast)(originalHsv, colorForComparison);
9997
+ const originalContrast = (0, import_fn3.wcagContrast)(
9998
+ compositeOverWhite(originalHsv, opacityForContrastCalculation),
9999
+ colorForComparison
10000
+ );
9968
10001
  if (originalContrast >= minContrast) {
9969
10002
  return true;
9970
10003
  }
@@ -9972,13 +10005,15 @@ var hasAccessibleDerivatives = ({
9972
10005
  originalHsv,
9973
10006
  colorForComparison,
9974
10007
  minContrast,
9975
- direction: "brighter"
10008
+ direction: "brighter",
10009
+ opacityForContrastCalculation
9976
10010
  });
9977
10011
  const darkerOption = getAccessibleColorInDirection({
9978
10012
  originalHsv,
9979
10013
  colorForComparison,
9980
10014
  minContrast,
9981
- direction: "darker"
10015
+ direction: "darker",
10016
+ opacityForContrastCalculation
9982
10017
  });
9983
10018
  return brighterOption !== null || darkerOption !== null;
9984
10019
  };
@@ -9988,10 +10023,11 @@ var import_jsx_runtime225 = require("react/jsx-runtime");
9988
10023
  var ColorPickerContext = (0, import_react41.createContext)(null);
9989
10024
  var ColorPickerProvider = ({
9990
10025
  children,
9991
- value: valueAsHex,
10026
+ colorForComparison,
10027
+ minimumContrastRatio,
9992
10028
  onValueChange,
9993
- minimumContrastRatio = DEFAULT_MIN_CONTRAST,
9994
- colorForComparison = DEFAULT_COLOR_FOR_COMPARISON
10029
+ opacityForContrastCalculation,
10030
+ value: valueAsHex
9995
10031
  }) => {
9996
10032
  const [isTransitioning, setIsTransitioning] = (0, import_react41.useState)(false);
9997
10033
  const [nonDerivedValueAsHsv, setNonDerivedValueAsHsv] = (0, import_react41.useState)(convertToHsv(valueAsHex));
@@ -10000,19 +10036,24 @@ var ColorPickerProvider = ({
10000
10036
  (originalHsv) => getAccessibleColor({
10001
10037
  originalHsv,
10002
10038
  colorForComparison,
10003
- minContrast: minimumContrastRatio
10039
+ minContrast: minimumContrastRatio,
10040
+ opacityForContrastCalculation
10004
10041
  }),
10005
- [minimumContrastRatio, colorForComparison]
10042
+ [colorForComparison, minimumContrastRatio, opacityForContrastCalculation]
10006
10043
  );
10007
10044
  const valueAsHsv = shouldEnforceMinContrast ? getAccessibleDerivativeColor(nonDerivedValueAsHsv) : nonDerivedValueAsHsv;
10008
- const currentContrastRatio = (0, import_fn4.wcagContrast)(valueAsHsv, colorForComparison);
10045
+ const currentContrastRatio = (0, import_fn4.wcagContrast)(
10046
+ compositeOverWhite(valueAsHsv, opacityForContrastCalculation),
10047
+ colorForComparison
10048
+ );
10009
10049
  const hasAccessibleDerivativesValue = (0, import_react41.useMemo)(() => {
10010
10050
  return hasAccessibleDerivatives({
10011
10051
  originalHsv: valueAsHsv,
10012
10052
  colorForComparison,
10013
- minContrast: minimumContrastRatio
10053
+ minContrast: minimumContrastRatio,
10054
+ opacityForContrastCalculation
10014
10055
  });
10015
- }, [valueAsHsv, colorForComparison, minimumContrastRatio]);
10056
+ }, [valueAsHsv, colorForComparison, minimumContrastRatio, opacityForContrastCalculation]);
10016
10057
  const onChangeNonDerivedValueAsHsv = (0, import_react41.useCallback)((nonDerivedValue) => {
10017
10058
  setNonDerivedValueAsHsv(nonDerivedValue);
10018
10059
  }, []);
@@ -10061,6 +10102,7 @@ var ColorPickerProvider = ({
10061
10102
  nonDerivedValueAsHex: (0, import_fn4.formatHex)(nonDerivedValueAsHsv),
10062
10103
  nonDerivedValueAsHsv,
10063
10104
  onChangeNonDerivedValueAsHsv,
10105
+ opacityForContrastCalculation,
10064
10106
  setShouldEnforceMinContrast: setShouldEnforceMinContrastWrapped,
10065
10107
  shouldEnforceMinContrast,
10066
10108
  valueAsHex,
@@ -10075,6 +10117,7 @@ var ColorPickerProvider = ({
10075
10117
  minimumContrastRatio,
10076
10118
  nonDerivedValueAsHsv,
10077
10119
  onChangeNonDerivedValueAsHsv,
10120
+ opacityForContrastCalculation,
10078
10121
  setShouldEnforceMinContrastWrapped,
10079
10122
  shouldEnforceMinContrast,
10080
10123
  valueAsHex,
@@ -10540,6 +10583,7 @@ var ColorPicker = ({
10540
10583
  children,
10541
10584
  colorForComparison = DEFAULT_COLOR_FOR_COMPARISON,
10542
10585
  minimumContrastRatio = DEFAULT_MIN_CONTRAST,
10586
+ opacityForContrastCalculation = DEFAULT_OPACITY_FOR_CONTRAST_CALCULATION,
10543
10587
  onValueChange,
10544
10588
  value
10545
10589
  }) => {
@@ -10549,6 +10593,7 @@ var ColorPicker = ({
10549
10593
  colorForComparison,
10550
10594
  minimumContrastRatio,
10551
10595
  onValueChange,
10596
+ opacityForContrastCalculation,
10552
10597
  value,
10553
10598
  children
10554
10599
  }
@@ -11491,7 +11536,7 @@ var Canvas2 = import_styled_components63.default.canvas`
11491
11536
  display: block;
11492
11537
  width: 100%;
11493
11538
  `;
11494
- var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorForComparison, limit) => {
11539
+ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorForComparison, limit, opacityForContrastCalculation) => {
11495
11540
  const contrastPoints = [];
11496
11541
  for (let x = 0; x < width; x += 1) {
11497
11542
  const saturationChanel = x / (width - 1);
@@ -11500,7 +11545,8 @@ var calculateContrastCurve = (width, height, hue, minimumContrastRatio, colorFor
11500
11545
  originalHsv: { h: hue, s: saturationChanel, v: initialValueChannelForSearch, mode: "hsv" },
11501
11546
  colorForComparison,
11502
11547
  minContrast: minimumContrastRatio,
11503
- direction: limit === "upper" ? "brighter" : "darker"
11548
+ direction: limit === "upper" ? "brighter" : "darker",
11549
+ opacityForContrastCalculation
11504
11550
  });
11505
11551
  if (colorForXAsHsv != null) {
11506
11552
  const point = {
@@ -11540,7 +11586,8 @@ var HSVSaturationValueCanvas = ({
11540
11586
  hue,
11541
11587
  shouldShowContrastCurve = false,
11542
11588
  minimumContrastRatio = DEFAULT_MIN_CONTRAST,
11543
- colorForComparison
11589
+ colorForComparison,
11590
+ opacityForContrastCalculation
11544
11591
  }) => {
11545
11592
  const canvasRef = (0, import_react51.useRef)(null);
11546
11593
  (0, import_react51.useEffect)(() => {
@@ -11564,7 +11611,8 @@ var HSVSaturationValueCanvas = ({
11564
11611
  hue,
11565
11612
  minimumContrastRatio,
11566
11613
  colorForComparison,
11567
- "upper"
11614
+ "upper",
11615
+ opacityForContrastCalculation
11568
11616
  );
11569
11617
  const minHsvValueChannelCurve = calculateContrastCurve(
11570
11618
  width,
@@ -11572,7 +11620,8 @@ var HSVSaturationValueCanvas = ({
11572
11620
  hue,
11573
11621
  minimumContrastRatio,
11574
11622
  colorForComparison,
11575
- "lower"
11623
+ "lower",
11624
+ opacityForContrastCalculation
11576
11625
  );
11577
11626
  if (minHsvValueChannelCurve.length > 0) {
11578
11627
  drawSmoothCurve(ctx, minHsvValueChannelCurve);
@@ -11581,7 +11630,13 @@ var HSVSaturationValueCanvas = ({
11581
11630
  drawSmoothCurve(ctx, maxHsvValueChannelCurve);
11582
11631
  }
11583
11632
  }
11584
- }, [hue, shouldShowContrastCurve, minimumContrastRatio, colorForComparison]);
11633
+ }, [
11634
+ hue,
11635
+ shouldShowContrastCurve,
11636
+ minimumContrastRatio,
11637
+ colorForComparison,
11638
+ opacityForContrastCalculation
11639
+ ]);
11585
11640
  return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)(
11586
11641
  Canvas2,
11587
11642
  {
@@ -11626,14 +11681,15 @@ var SaturationAndValuePicker = ({
11626
11681
  dataTestId
11627
11682
  }) => {
11628
11683
  const {
11629
- valueAsHex,
11630
- onChangeNonDerivedValueAsHsv,
11631
- valueAsHsv,
11684
+ colorForComparison,
11632
11685
  isTransitioning,
11633
11686
  minimumContrastRatio,
11634
- colorForComparison,
11687
+ nonDerivedValueAsHsv,
11688
+ onChangeNonDerivedValueAsHsv,
11689
+ opacityForContrastCalculation,
11635
11690
  shouldEnforceMinContrast,
11636
- nonDerivedValueAsHsv
11691
+ valueAsHex,
11692
+ valueAsHsv
11637
11693
  } = useColorPickerState();
11638
11694
  const containerRef = (0, import_react52.useRef)(null);
11639
11695
  const thumbRef = (0, import_react52.useRef)(null);
@@ -11786,6 +11842,7 @@ var SaturationAndValuePicker = ({
11786
11842
  colorForComparison,
11787
11843
  hue: nonDerivedValueAsHsv.h ?? 0,
11788
11844
  minimumContrastRatio,
11845
+ opacityForContrastCalculation,
11789
11846
  shouldShowContrastCurve: shouldEnforceMinContrast
11790
11847
  }
11791
11848
  ),
@@ -14462,6 +14519,7 @@ PopoverArrow.displayName = "PopoverArrow_UI";
14462
14519
  // src/components/Popover/Popover.tsx
14463
14520
  var import_jsx_runtime282 = require("react/jsx-runtime");
14464
14521
  var StyledContent2 = (0, import_styled_components90.default)(import_react_popover5.Content)`
14522
+ z-index: var(--wui-zindex-popover);
14465
14523
  ${({ $colorScheme }) => getColorScheme($colorScheme)};
14466
14524
  ${({ $unstyled }) => !$unstyled && import_styled_components90.css`
14467
14525
  border-radius: var(--wui-border-radius-02);