@wistia/ui 1.4.3 → 1.4.4

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.js CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*
3
- * @license @wistia/ui v1.4.3
3
+ * @license @wistia/ui v1.4.4
4
4
  *
5
5
  * Copyright (c) 2024-2026, Wistia, Inc. and its affiliates.
6
6
  *
@@ -72,9 +72,8 @@ const designTokens = css`
72
72
  ${"/*\n * Legacy typography sub-property aliases\n *\n * Terrazzo's plugin-css emits typography composite sub-properties using DTCG\n * names verbatim (kebab-cased):\n * --wui-typography-<style>-font-family\n * --wui-typography-<style>-font-size\n * --wui-typography-<style>-font-weight\n *\n * Prior versions of @wistia/ui exposed shortened legacy names:\n * --wui-typography-<style>-family\n * --wui-typography-<style>-size\n * --wui-typography-<style>-weight\n *\n * These aliases preserve that surface so downstream apps (notably wistia/wistia)\n * keep working unchanged after the Terrazzo migration. Once all known consumers\n * have migrated to the DTCG names, delete this file and remove the import from\n * designTokens/index.tsx.\n *\n * Note: `line-height` and `paragraph-spacing` sub-properties are unchanged\n * between DTCG and the prior surface, so no aliases are required for those.\n *\n * --------------------------------------------------------------------------\n * Migrating consumers in wistia/wistia (run from the VMA repo root):\n *\n * # 1. List every legacy reference site:\n * grep -rnE --include='*.ts' --include='*.tsx' --include='*.css' \\\n * '--wui-typography-(heading-hero|heading-[0-9]|body-[0-9]|label-[0-9])-(family|size|weight)' \\\n * frontend\n *\n * # 2. Apply the rename in-place (BSD sed on macOS):\n * grep -rlE --include='*.ts' --include='*.tsx' --include='*.css' \\\n * '--wui-typography-(heading-hero|heading-[0-9]|body-[0-9]|label-[0-9])-(family|size|weight)' \\\n * frontend \\\n * | xargs sed -i '' -E \\\n * 's/(--wui-typography-(heading-hero|heading-[0-9]|body-[0-9]|label-[0-9]))-(family|size|weight)/\\1-font-\\3/g'\n *\n * # 3. (GNU sed / Linux variant — drop the empty '' after -i):\n * # ... | xargs sed -i -E '...'\n *\n * Special case: frontend/authentication/css/redesign/wistia-ui/design-tokens/\n * typography.css *defines* the legacy names itself (not consumed from\n * @wistia/ui). It will keep working post-rename, but should be migrated for\n * consistency.\n * --------------------------------------------------------------------------\n */\n:root,\n[data-wui-theme='true'] {\n --wui-typography-heading-hero-family: var(--wui-typography-heading-hero-font-family);\n --wui-typography-heading-hero-size: var(--wui-typography-heading-hero-font-size);\n --wui-typography-heading-hero-weight: var(--wui-typography-heading-hero-font-weight);\n --wui-typography-heading-1-family: var(--wui-typography-heading-1-font-family);\n --wui-typography-heading-1-size: var(--wui-typography-heading-1-font-size);\n --wui-typography-heading-1-weight: var(--wui-typography-heading-1-font-weight);\n --wui-typography-heading-2-family: var(--wui-typography-heading-2-font-family);\n --wui-typography-heading-2-size: var(--wui-typography-heading-2-font-size);\n --wui-typography-heading-2-weight: var(--wui-typography-heading-2-font-weight);\n --wui-typography-heading-3-family: var(--wui-typography-heading-3-font-family);\n --wui-typography-heading-3-size: var(--wui-typography-heading-3-font-size);\n --wui-typography-heading-3-weight: var(--wui-typography-heading-3-font-weight);\n --wui-typography-heading-4-family: var(--wui-typography-heading-4-font-family);\n --wui-typography-heading-4-size: var(--wui-typography-heading-4-font-size);\n --wui-typography-heading-4-weight: var(--wui-typography-heading-4-font-weight);\n --wui-typography-heading-5-family: var(--wui-typography-heading-5-font-family);\n --wui-typography-heading-5-size: var(--wui-typography-heading-5-font-size);\n --wui-typography-heading-5-weight: var(--wui-typography-heading-5-font-weight);\n --wui-typography-heading-6-family: var(--wui-typography-heading-6-font-family);\n --wui-typography-heading-6-size: var(--wui-typography-heading-6-font-size);\n --wui-typography-heading-6-weight: var(--wui-typography-heading-6-font-weight);\n --wui-typography-body-1-family: var(--wui-typography-body-1-font-family);\n --wui-typography-body-1-size: var(--wui-typography-body-1-font-size);\n --wui-typography-body-1-weight: var(--wui-typography-body-1-font-weight);\n --wui-typography-body-2-family: var(--wui-typography-body-2-font-family);\n --wui-typography-body-2-size: var(--wui-typography-body-2-font-size);\n --wui-typography-body-2-weight: var(--wui-typography-body-2-font-weight);\n --wui-typography-body-3-family: var(--wui-typography-body-3-font-family);\n --wui-typography-body-3-size: var(--wui-typography-body-3-font-size);\n --wui-typography-body-3-weight: var(--wui-typography-body-3-font-weight);\n --wui-typography-body-4-family: var(--wui-typography-body-4-font-family);\n --wui-typography-body-4-size: var(--wui-typography-body-4-font-size);\n --wui-typography-body-4-weight: var(--wui-typography-body-4-font-weight);\n --wui-typography-label-1-family: var(--wui-typography-label-1-font-family);\n --wui-typography-label-1-size: var(--wui-typography-label-1-font-size);\n --wui-typography-label-1-weight: var(--wui-typography-label-1-font-weight);\n --wui-typography-label-2-family: var(--wui-typography-label-2-font-family);\n --wui-typography-label-2-size: var(--wui-typography-label-2-font-size);\n --wui-typography-label-2-weight: var(--wui-typography-label-2-font-weight);\n --wui-typography-label-3-family: var(--wui-typography-label-3-font-family);\n --wui-typography-label-3-size: var(--wui-typography-label-3-font-size);\n --wui-typography-label-3-weight: var(--wui-typography-label-3-font-weight);\n --wui-typography-label-4-family: var(--wui-typography-label-4-font-family);\n --wui-typography-label-4-size: var(--wui-typography-label-4-font-size);\n --wui-typography-label-4-weight: var(--wui-typography-label-4-font-weight);\n}\n"}
73
73
  `;
74
74
  //#endregion
75
- //#region src/css/GlobalStyle.tsx
76
- const GlobalStyle = createGlobalStyle`
77
- ${css`
75
+ //#region src/css/globalStyleAdjustmentsCss.tsx
76
+ const globalStyleAdjustmentsCss = css`
78
77
  /**
79
78
  * 1. Change from 'content-box' so that 'width' calculations are unaffected by 'padding' or 'border'
80
79
  See: https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/
@@ -206,7 +205,11 @@ const GlobalStyle = createGlobalStyle`
206
205
  scroll-behavior: auto !important;
207
206
  }
208
207
  }
209
- `}
208
+ `;
209
+ //#endregion
210
+ //#region src/css/GlobalStyle.tsx
211
+ const GlobalStyle = createGlobalStyle`
212
+ ${globalStyleAdjustmentsCss}
210
213
  ${designTokens}
211
214
  ${clickRegionGlobalStyles}
212
215
  `;
@@ -263,8 +266,9 @@ const AriaLiveProvider = ({ children, debug = false }) => {
263
266
  setTimeout(() => setMessage(null), 1e3);
264
267
  }
265
268
  }, []);
269
+ const value = useMemo(() => ({ announce }), [announce]);
266
270
  return /* @__PURE__ */ jsx(AriaLiveContext, {
267
- value: useMemo(() => ({ announce }), [announce]),
271
+ value,
268
272
  children
269
273
  });
270
274
  };
@@ -346,7 +350,7 @@ const copyToClipboard = async (textToCopy) => {
346
350
  const defaultLocales = ["en-US"];
347
351
  const defaultTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
348
352
  const milisecondsInSecond = 1e3;
349
- const millisecondsInDay = 1440 * 60 * milisecondsInSecond;
353
+ const millisecondsInDay = 86400 * milisecondsInSecond;
350
354
  //#endregion
351
355
  //#region src/helpers/dateTime/buildTimeDuration.ts
352
356
  /**
@@ -1157,7 +1161,8 @@ const DEFAULT_GRADIENT = "defaultMidOne";
1157
1161
  const getSemiRandomBackgroundGradient = (id) => {
1158
1162
  if (!(typeof id === "string" && id)) return gradientMap[0] ?? DEFAULT_GRADIENT;
1159
1163
  const hashCode = [...id].reduce((num, char) => Math.imul(MULTIPLIER, num) + (char.codePointAt(0) ?? 0) || 0, 0);
1160
- return gradientMap[Math.abs(hashCode) % gradientMap.length] ?? DEFAULT_GRADIENT;
1164
+ const index = Math.abs(hashCode) % gradientMap.length;
1165
+ return gradientMap[index] ?? DEFAULT_GRADIENT;
1161
1166
  };
1162
1167
  //#endregion
1163
1168
  //#region src/helpers/mergeRefs/mergeRefs.ts
@@ -1320,10 +1325,11 @@ const useElementObserver = () => {
1320
1325
  * @param config Optional configuration for the file picker
1321
1326
  */
1322
1327
  const useFilePicker = (config = {}) => {
1323
- return useFilePicker$1({
1328
+ const finalConfig = {
1324
1329
  readFilesContent: false,
1325
1330
  ...config
1326
- });
1331
+ };
1332
+ return useFilePicker$1(finalConfig);
1327
1333
  };
1328
1334
  /**
1329
1335
  * Hook that wraps `useImperativeFilePicker` from the use-file-picker library
@@ -1331,10 +1337,11 @@ const useFilePicker = (config = {}) => {
1331
1337
  * @param config Optional configuration for the imperative file picker
1332
1338
  */
1333
1339
  const useImperativeFilePicker = (config = {}) => {
1334
- return useImperativeFilePicker$1({
1340
+ const finalConfig = {
1335
1341
  readFilesContent: false,
1336
1342
  ...config
1337
- });
1343
+ };
1344
+ return useImperativeFilePicker$1(finalConfig);
1338
1345
  };
1339
1346
  //#endregion
1340
1347
  //#region src/hooks/useFocusTrap/helpers.ts
@@ -1570,7 +1577,7 @@ const useEvent = (eventName, eventHandler, eventTarget = typeof document !== "un
1570
1577
  //#endregion
1571
1578
  //#region src/hooks/useKey/useKey.ts
1572
1579
  const useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOptions } = {}) => {
1573
- useEvent(eventName, useCallback((handlerEvent) => {
1580
+ const memoizedEventHandler = useCallback((handlerEvent) => {
1574
1581
  if ([
1575
1582
  "INPUT",
1576
1583
  "TEXTAREA",
@@ -1582,7 +1589,8 @@ const useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOp
1582
1589
  else if (key) matchesKey = true;
1583
1590
  else matchesKey = false;
1584
1591
  if (matchesKey) eventHandler(handlerEvent);
1585
- }, [key, eventHandler]), eventTarget, eventOptions);
1592
+ }, [key, eventHandler]);
1593
+ useEvent(eventName, memoizedEventHandler, eventTarget, eventOptions);
1586
1594
  };
1587
1595
  //#endregion
1588
1596
  //#region src/private/hooks/useUpdateEffect/useUpdateEffect.ts
@@ -5744,6 +5752,7 @@ const Button = ({ children, forceState, className, leftIcon, rightIcon, colorSch
5744
5752
  const responsiveFullWidth = useResponsiveProp(fullWidth);
5745
5753
  const responsiveSize = useResponsiveProp(size);
5746
5754
  const isAriaDisabled = () => isLoading || disabled;
5755
+ const buttonRef = ref;
5747
5756
  const commonProps = {
5748
5757
  "aria-disabled": isAriaDisabled() || void 0,
5749
5758
  $colorScheme: colorScheme,
@@ -5755,7 +5764,7 @@ const Button = ({ children, forceState, className, leftIcon, rightIcon, colorSch
5755
5764
  };
5756
5765
  if (forceState) commonProps.className = `${className ?? ""} force-state-${forceState}`;
5757
5766
  if (isLink(props)) return /* @__PURE__ */ jsx(StyledButton$2, {
5758
- ref,
5767
+ ref: buttonRef,
5759
5768
  as: Link,
5760
5769
  disabled: isAriaDisabled(),
5761
5770
  ...props,
@@ -6096,7 +6105,8 @@ const chooseColorScheme = (name) => {
6096
6105
  for (let i = 0; i < str.length; i += 1) sum = Math.trunc(Math.imul(multiplier, sum) + (str.codePointAt(i) ?? 0));
6097
6106
  return sum;
6098
6107
  };
6099
- return brandColorSchemeOptions[Math.abs(hashCode(name)) % brandColorSchemeOptions.length] ?? "blue";
6108
+ const index = Math.abs(hashCode(name)) % brandColorSchemeOptions.length;
6109
+ return brandColorSchemeOptions[index] ?? "blue";
6100
6110
  };
6101
6111
  /**
6102
6112
  * An avatar uses a photo or initials to represent an identity.
@@ -6404,7 +6414,8 @@ const applyMaxCharsToChildren = (children, maxChars) => {
6404
6414
  if (isNil(maxChars)) return children;
6405
6415
  if (isString(children)) return truncateString(children, maxChars);
6406
6416
  if (isNumber(children)) return truncateString(String(children), maxChars);
6407
- return truncateString(typeof children === "object" ? JSON.stringify(children) : String(children), maxChars);
6417
+ const textContent = typeof children === "object" ? JSON.stringify(children) : String(children);
6418
+ return truncateString(textContent, maxChars);
6408
6419
  };
6409
6420
  const variantStyleMap$1 = {
6410
6421
  hero: css`
@@ -6846,6 +6857,7 @@ const Breadcrumbs = ({ children, ...props }) => {
6846
6857
  const { isXsAndDown } = useMq();
6847
6858
  let crumbs = Children.toArray(children);
6848
6859
  if (isXsAndDown) crumbs = crumbs.slice(-1);
6860
+ const crumbMaxWidth = Math.floor(100 / crumbs.length) - BUFFER_WIDTH;
6849
6861
  return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("style", {
6850
6862
  type: "text/css",
6851
6863
  children: `
@@ -6856,7 +6868,7 @@ const Breadcrumbs = ({ children, ...props }) => {
6856
6868
 
6857
6869
  @container breadcrumbs (width < 100vw) {
6858
6870
  [data-wui-breadcrumb] {
6859
- max-width: ${Math.floor(100 / crumbs.length) - BUFFER_WIDTH}cqw;
6871
+ max-width: ${crumbMaxWidth}cqw;
6860
6872
  }
6861
6873
  }
6862
6874
  `
@@ -7030,7 +7042,7 @@ const StyledFormControlLabel = styled.label`
7030
7042
  align-items: flex-start;
7031
7043
  gap: var(--wui-space-02);
7032
7044
  width: 100%;
7033
- color: var(--wui-color-tex);
7045
+ color: var(--wui-color-text);
7034
7046
  font-size: var(--wui-typography-label-3-font-size);
7035
7047
  font-weight: var(--wui-typography-label-3-font-weight);
7036
7048
  line-height: var(--wui-typography-body-3-line-height);
@@ -7625,10 +7637,11 @@ const compositeOverWhite = (color, alpha = 1) => {
7625
7637
  const calculateContrast = ({ backgroundColor, foregroundColor = DEFAULT_COLOR_FOR_COMPARISON, backgroundOpacity = 1 }) => {
7626
7638
  const backgroundColorAsRgb = convertToRgb(backgroundColor);
7627
7639
  const foregroundColorAsRgb = convertToRgb(foregroundColor);
7628
- return wcagContrast(compositeOverWhite(backgroundColorAsRgb, backgroundOpacity), foregroundColorAsRgb);
7640
+ const compositeBackground = compositeOverWhite(backgroundColorAsRgb, backgroundOpacity);
7641
+ return wcagContrast(compositeBackground, foregroundColorAsRgb);
7629
7642
  };
7630
7643
  const snapValueToEdges = (value) => {
7631
- if (value > 1 - VALUE_CHANNEL_SNAP_EPSILON) return 1;
7644
+ if (value > .9995) return 1;
7632
7645
  if (value < VALUE_CHANNEL_SNAP_EPSILON) return 0;
7633
7646
  return value;
7634
7647
  };
@@ -9332,9 +9345,10 @@ const drawGradientBackground = (ctx, width, height, hue) => {
9332
9345
  for (let y = 0; y < height; y++) {
9333
9346
  const v = 1 - y / (height - 1);
9334
9347
  for (let x = 0; x < width; x++) {
9348
+ const s = x / (width - 1);
9335
9349
  const rgb = convertToRgb({
9336
9350
  h: hue,
9337
- s: x / (width - 1),
9351
+ s,
9338
9352
  v,
9339
9353
  mode: "hsv"
9340
9354
  });
@@ -10702,10 +10716,11 @@ const useCreatePopoverAnchorRef = () => useRef(null);
10702
10716
  */
10703
10717
  const PopoverAnchor = ({ children }) => {
10704
10718
  const sharedRef = usePopoverAnchor();
10719
+ const callbackRef = useCallback((node) => {
10720
+ if (sharedRef) sharedRef.current = node;
10721
+ }, [sharedRef]);
10705
10722
  return /* @__PURE__ */ jsx("div", {
10706
- ref: useCallback((node) => {
10707
- if (sharedRef) sharedRef.current = node;
10708
- }, [sharedRef]),
10723
+ ref: callbackRef,
10709
10724
  children
10710
10725
  });
10711
10726
  };
@@ -12754,13 +12769,11 @@ const InputClickToCopy = ({ value, onCopy, disabled = false, ref, ...props }) =>
12754
12769
  //#endregion
12755
12770
  //#region src/components/InputDuration/constants.ts
12756
12771
  const SECONDS_PER_MINUTE = 60;
12757
- const MINUTES_PER_HOUR = 60;
12758
- const MAX_MINUTES_UNIT_VALUE = SECONDS_PER_MINUTE - 1;
12759
- const SECONDS_PER_TEN_MINUTES = SECONDS_PER_MINUTE * 10;
12760
- const SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
12761
- const TEN_HOURS = SECONDS_PER_HOUR * 10;
12772
+ const MAX_MINUTES_UNIT_VALUE = 59;
12773
+ const SECONDS_PER_TEN_MINUTES = 600;
12774
+ const SECONDS_PER_HOUR = 3600;
12762
12775
  const ONE_HUNDREDTH_OF_A_SECOND = .01;
12763
- const MAX_TIME = TEN_HOURS - ONE_HUNDREDTH_OF_A_SECOND;
12776
+ const MAX_TIME = 35999.99;
12764
12777
  const NUMBER_STRING_SET = /* @__PURE__ */ new Set([
12765
12778
  "0",
12766
12779
  "1",
@@ -14082,7 +14095,8 @@ const StyledSubTrigger = styled(Menu$1.SubmenuTrigger)`
14082
14095
  const SUBMENU_CLOSE_DELAY = 200;
14083
14096
  const SubMenuTrigger = ({ icon, ...props }) => {
14084
14097
  const { isSmAndUp } = useMq();
14085
- return /* @__PURE__ */ jsx(isSmAndUp ? StyledSubTrigger : Menu$1.Item, {
14098
+ const Trigger = isSmAndUp ? StyledSubTrigger : Menu$1.Item;
14099
+ return /* @__PURE__ */ jsx(Trigger, {
14086
14100
  nativeButton: true,
14087
14101
  ...isSmAndUp && { closeDelay: SUBMENU_CLOSE_DELAY },
14088
14102
  render: /* @__PURE__ */ jsx(MenuItemButton, {
@@ -14464,8 +14478,7 @@ const modalExit = keyframes`
14464
14478
  transform: translateX(-50%) translateY(calc(var(--wui-modal-translate-y) + 24px));
14465
14479
  }
14466
14480
  `;
14467
- const positionStyleMap = {
14468
- centered: css`
14481
+ const centeredModalStyles = css`
14469
14482
  --wui-modal-screen-offset: var(--wui-space-05);
14470
14483
  --wui-modal-translate-y: -50%;
14471
14484
 
@@ -14480,8 +14493,8 @@ const positionStyleMap = {
14480
14493
  &[data-closed] {
14481
14494
  animation: ${modalExit} var(--wui-motion-duration-03) var(--wui-motion-ease-out) forwards;
14482
14495
  }
14483
- `,
14484
- "fixed-top": css`
14496
+ `;
14497
+ const fixedTopModalStyles = css`
14485
14498
  --wui-modal-screen-offset-top: 15vh;
14486
14499
  --wui-modal-screen-offset-bottom: 5vh;
14487
14500
  --wui-modal-translate-y: 0%;
@@ -14499,14 +14512,8 @@ const positionStyleMap = {
14499
14512
  &[data-closed] {
14500
14513
  animation: ${modalExit} var(--wui-motion-duration-03) var(--wui-motion-ease-out) forwards;
14501
14514
  }
14502
- `,
14503
- "right-side-panel": css`
14504
- --wui-modal-screen-offset: var(--wui-space-05);
14505
-
14506
- height: calc(100vh - var(--wui-modal-screen-offset) * 2);
14507
- top: var(--wui-modal-screen-offset);
14508
- right: var(--wui-modal-screen-offset);
14509
- animation: ${keyframes`
14515
+ `;
14516
+ const slideInRight = keyframes`
14510
14517
  from {
14511
14518
  opacity: 0;
14512
14519
  transform: translateX(100%);
@@ -14516,11 +14523,8 @@ const positionStyleMap = {
14516
14523
  opacity: 1;
14517
14524
  transform: translateX(0);
14518
14525
  }
14519
- `} var(--wui-motion-duration-05) var(--wui-motion-ease-out);
14520
- transform-origin: right center;
14521
-
14522
- &[data-closed] {
14523
- animation: ${keyframes`
14526
+ `;
14527
+ const slideOutRight = keyframes`
14524
14528
  from {
14525
14529
  opacity: 1;
14526
14530
  transform: translateX(0);
@@ -14530,7 +14534,21 @@ const positionStyleMap = {
14530
14534
  opacity: 0;
14531
14535
  transform: translateX(100%);
14532
14536
  }
14533
- `} var(--wui-motion-duration-03) var(--wui-motion-ease-in) forwards;
14537
+ `;
14538
+ const positionStyleMap = {
14539
+ centered: centeredModalStyles,
14540
+ "fixed-top": fixedTopModalStyles,
14541
+ "right-side-panel": css`
14542
+ --wui-modal-screen-offset: var(--wui-space-05);
14543
+
14544
+ height: calc(100vh - var(--wui-modal-screen-offset) * 2);
14545
+ top: var(--wui-modal-screen-offset);
14546
+ right: var(--wui-modal-screen-offset);
14547
+ animation: ${slideInRight} var(--wui-motion-duration-05) var(--wui-motion-ease-out);
14548
+ transform-origin: right center;
14549
+
14550
+ &[data-closed] {
14551
+ animation: ${slideOutRight} var(--wui-motion-duration-03) var(--wui-motion-ease-in) forwards;
14534
14552
  }
14535
14553
  `
14536
14554
  };