@wistia/ui 3.2.1 → 3.4.0-beta.1b6a2e2d.3526ea7

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 v3.2.1
3
+ * @license @wistia/ui v3.4.0-beta.1b6a2e2d.3526ea7
4
4
  *
5
5
  * Copyright (c) 2024-2026, Wistia, Inc. and its affiliates.
6
6
  *
@@ -1498,6 +1498,24 @@ const isTabbableElement = (element) => {
1498
1498
  return (isTabIndexNaN(element) || tabIndex >= 0) && isFocusableElement(element);
1499
1499
  };
1500
1500
  const findTabbableDescendants = (element) => [...element.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)].filter((el) => isTabbableElement(el));
1501
+ const splitIdList = (value) => (value ?? "").split(/\s+/).filter((id) => id !== "");
1502
+ const getLinkedIds = (owner) => [...splitIdList(owner.getAttribute("aria-owns")), ...owner.getAttribute("aria-expanded") === "true" ? splitIdList(owner.getAttribute("aria-controls")) : []];
1503
+ /**
1504
+ * The parts of the page a trap treats as its own: `container`, plus every popup that
1505
+ * something in the trap has opened. Popups such as Menu, Popover and Select render in a
1506
+ * portal at the end of <body>, outside the trap in the DOM. They are linked back to it by
1507
+ * `aria-owns` or by an expanded `aria-controls`. Links are followed transitively, so a
1508
+ * submenu opened from that menu counts too.
1509
+ */
1510
+ const getTrapRegions = (container) => {
1511
+ const regions = [container];
1512
+ for (const region of regions) for (const owner of region.querySelectorAll("[aria-owns], [aria-controls]")) for (const id of getLinkedIds(owner)) {
1513
+ const linked = document.getElementById(id);
1514
+ if (linked !== null && !regions.includes(linked)) regions.push(linked);
1515
+ }
1516
+ return regions;
1517
+ };
1518
+ const isInsideTrap = (container, target) => target !== null && (container.contains(target) || getTrapRegions(container).some((region) => region.contains(target)));
1501
1519
  const focusLaterElements = [];
1502
1520
  let focusElement = null;
1503
1521
  let needToFocus = false;
@@ -1508,7 +1526,7 @@ const handleFocus = () => {
1508
1526
  if (needToFocus) {
1509
1527
  needToFocus = false;
1510
1528
  if (!focusElement) return;
1511
- if (focusElement.contains(document.activeElement)) return;
1529
+ if (isInsideTrap(focusElement, document.activeElement)) return;
1512
1530
  (findTabbableDescendants(focusElement)[0] ?? focusElement).focus();
1513
1531
  }
1514
1532
  };
@@ -1546,21 +1564,35 @@ const scopeTab = (node, event) => {
1546
1564
  const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0];
1547
1565
  if (target) target.focus();
1548
1566
  };
1567
+ const ariaHiderState = /* @__PURE__ */ new WeakMap();
1549
1568
  const createAriaHider = (containerNode, selector = "body > :not(script)") => {
1550
- const rootNodes = [...document.querySelectorAll(selector)].map((node) => {
1551
- if (node.contains(containerNode)) return;
1552
- const ariaHidden = node.getAttribute("aria-hidden");
1553
- if (ariaHidden === null || ariaHidden === "false") node.setAttribute("aria-hidden", "true");
1554
- return {
1555
- node,
1556
- ariaHidden
1557
- };
1569
+ const regions = getTrapRegions(containerNode);
1570
+ const hiddenNodes = [...document.querySelectorAll(selector)].filter((node) => !regions.some((region) => node.contains(region)));
1571
+ hiddenNodes.forEach((node) => {
1572
+ const state = ariaHiderState.get(node);
1573
+ if (state) {
1574
+ state.count += 1;
1575
+ return;
1576
+ }
1577
+ const originalAriaHidden = node.getAttribute("aria-hidden");
1578
+ ariaHiderState.set(node, {
1579
+ count: 1,
1580
+ originalAriaHidden
1581
+ });
1582
+ if (originalAriaHidden === null || originalAriaHidden === "false") node.setAttribute("aria-hidden", "true");
1558
1583
  });
1584
+ let isRestored = false;
1559
1585
  return () => {
1560
- rootNodes.forEach((item) => {
1561
- if (!item) return;
1562
- if (item.ariaHidden === null) item.node.removeAttribute("aria-hidden");
1563
- else item.node.setAttribute("aria-hidden", item.ariaHidden);
1586
+ if (isRestored) return;
1587
+ isRestored = true;
1588
+ hiddenNodes.forEach((node) => {
1589
+ const state = ariaHiderState.get(node);
1590
+ if (!state) return;
1591
+ state.count -= 1;
1592
+ if (state.count > 0) return;
1593
+ ariaHiderState.delete(node);
1594
+ if (state.originalAriaHidden === null) node.removeAttribute("aria-hidden");
1595
+ else node.setAttribute("aria-hidden", state.originalAriaHidden);
1564
1596
  });
1565
1597
  };
1566
1598
  };
@@ -1570,47 +1602,53 @@ const isRef = (val) => {
1570
1602
  return val !== null && typeof val === "object" && "current" in val;
1571
1603
  };
1572
1604
  const useFocusTrap = (active = true, options = {}) => {
1573
- const ref = useRef(null);
1574
- const restoreAriaRef = useRef(null);
1575
- const setRef = useCallback((node) => {
1576
- if (restoreAriaRef.current !== null) restoreAriaRef.current();
1577
- if (ref.current) {
1605
+ const { disableAriaHider = false, focusSelector } = options;
1606
+ const [node, setNode] = useState(null);
1607
+ const nodeRef = useRef(null);
1608
+ const setRef = useCallback((nextNode) => {
1609
+ nodeRef.current = nextNode ?? null;
1610
+ setNode(nextNode ?? null);
1611
+ }, []);
1612
+ useLayoutEffect(() => {
1613
+ if (!active || node === null) return;
1614
+ setupScopedFocus(node);
1615
+ markForFocusLater();
1616
+ let restoreAria = null;
1617
+ const processNode = () => {
1618
+ restoreAria = disableAriaHider ? null : createAriaHider(node);
1619
+ let focusElement = null;
1620
+ if (isNotUndefined(focusSelector)) {
1621
+ if (isRef(focusSelector)) focusElement = focusSelector.current;
1622
+ else focusElement = typeof focusSelector === "string" ? node.querySelector(focusSelector) : focusSelector;
1623
+ }
1624
+ if (!focusElement) {
1625
+ const children = [...node.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)];
1626
+ focusElement = children.find((element) => isTabbableElement(element)) ?? children.find((element) => isFocusableElement(element)) ?? null;
1627
+ if (!focusElement && isFocusableElement(node)) focusElement = node;
1628
+ }
1629
+ if (focusElement) focusElement.focus();
1630
+ if (!focusElement) console.warn("[useFocusTrap]: Failed to find a focusable element after activating the focus trap. Make sure to include at an element that can recieve focus. As a fallback, you can also set \"tabIndex={-1}\" on the focus trap node.", node);
1631
+ };
1632
+ const timeoutId = setTimeout(() => {
1633
+ if (node.ownerDocument) processNode();
1634
+ if (!node.ownerDocument) console.warn("[useFocusTrap]: The focus trap is not part of the DOM yet, so it is unable to correctly set focus. Make sure to render the ref node.", node);
1635
+ }, 0);
1636
+ return () => {
1637
+ clearTimeout(timeoutId);
1638
+ restoreAria?.();
1578
1639
  returnFocus();
1579
1640
  teardownScopedFocus();
1580
- }
1581
- if (active && node !== null && node !== void 0) {
1582
- setupScopedFocus(node);
1583
- markForFocusLater();
1584
- const processNode = (node2) => {
1585
- restoreAriaRef.current = !(options.disableAriaHider ?? false) ? createAriaHider(node2) : null;
1586
- let focusElement = null;
1587
- if (isNotUndefined(options.focusSelector)) {
1588
- if (isRef(options.focusSelector)) focusElement = options.focusSelector.current;
1589
- else focusElement = typeof options.focusSelector === "string" ? node2.querySelector(options.focusSelector) : options.focusSelector;
1590
- }
1591
- if (!focusElement) {
1592
- const children = [...node2.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)];
1593
- focusElement = children.find((element) => isTabbableElement(element)) ?? children.find((element) => isFocusableElement(element)) ?? null;
1594
- if (!focusElement && isFocusableElement(node2)) focusElement = node2;
1595
- }
1596
- if (focusElement) focusElement.focus();
1597
- if (!focusElement) console.warn("[useFocusTrap]: Failed to find a focusable element after activating the focus trap. Make sure to include at an element that can recieve focus. As a fallback, you can also set \"tabIndex={-1}\" on the focus trap node.", node2);
1598
- };
1599
- setTimeout(() => {
1600
- if (node.ownerDocument) processNode(node);
1601
- if (!node.ownerDocument) console.warn("[useFocusTrap]: The focus trap is not part of the DOM yet, so it is unable to correctly set focus. Make sure to render the ref node.", node);
1602
- }, 0);
1603
- ref.current = node;
1604
- } else ref.current = null;
1641
+ };
1605
1642
  }, [
1606
1643
  active,
1607
- options.focusSelector,
1608
- options.disableAriaHider
1644
+ node,
1645
+ focusSelector,
1646
+ disableAriaHider
1609
1647
  ]);
1610
1648
  useEffect(() => {
1611
1649
  if (!active) return;
1612
1650
  const handleKeyDown = (event) => {
1613
- if (event.key === "Tab" && ref.current) scopeTab(ref.current, event);
1651
+ if (event.key === "Tab" && nodeRef.current) scopeTab(nodeRef.current, event);
1614
1652
  };
1615
1653
  document.addEventListener("keydown", handleKeyDown);
1616
1654
  return () => {
@@ -1887,6 +1925,14 @@ const lineClampCss = ($lines = 1) => css`
1887
1925
  white-space: initial;
1888
1926
  `;
1889
1927
  //#endregion
1928
+ //#region src/css/wordBreakCss.tsx
1929
+ const wordBreakCss = (wordBreak = "anywhere") => {
1930
+ if (wordBreak === "word") return css`
1931
+ word-break: normal;
1932
+ overflow-wrap: anywhere;
1933
+ `;
1934
+ };
1935
+ //#endregion
1890
1936
  //#region src/components/Ellipsis/Ellipsis.tsx
1891
1937
  const ellipsisStyle = css`
1892
1938
  overflow: hidden;
@@ -1918,12 +1964,14 @@ const EllipsisComponent = styled.span`
1918
1964
  ${({ $lines }) => {
1919
1965
  if (isNotNil($lines)) return lineClampCss($lines);
1920
1966
  }}
1967
+ ${({ $wordBreak }) => wordBreakCss($wordBreak)};
1921
1968
  `;
1922
1969
  /**
1923
1970
  * Truncate text with an ellispsis visble at the end
1924
1971
  */
1925
- const Ellipsis = ({ children, lines, ...props }) => /* @__PURE__ */ jsx(EllipsisComponent, {
1972
+ const Ellipsis = ({ children, lines, wordBreak = "anywhere", ...props }) => /* @__PURE__ */ jsx(EllipsisComponent, {
1926
1973
  $lines: lines,
1974
+ $wordBreak: wordBreak,
1927
1975
  ...props,
1928
1976
  children
1929
1977
  });
@@ -2811,6 +2859,20 @@ const ChatIcon = (props) => /* @__PURE__ */ jsx("svg", {
2811
2859
  })
2812
2860
  });
2813
2861
  //#endregion
2862
+ //#region src/components/Icon/icons/ChatSparkleIcon.tsx
2863
+ const ChatSparkleIcon = (props) => /* @__PURE__ */ jsxs("svg", {
2864
+ ...props,
2865
+ viewBox: "0 0 24 24",
2866
+ xmlns: "http://www.w3.org/2000/svg",
2867
+ children: [/* @__PURE__ */ jsx("path", {
2868
+ d: "M18.333 2.667A3.667 3.667 0 0 1 22 6.334v3.88a1 1 0 0 1-2 0v-3.88c0-.92-.746-1.667-1.667-1.667H5.667C4.747 4.667 4 5.414 4 6.334v13.25l3.375-2.699A1 1 0 0 1 8 16.667h3a1 1 0 1 1 0 2H8.352l-4.727 3.78A1.001 1.001 0 0 1 2 21.668V6.334a3.667 3.667 0 0 1 3.667-3.667z",
2869
+ fill: "currentColor"
2870
+ }), /* @__PURE__ */ jsx("path", {
2871
+ d: "M19 12.669a1 1 0 0 1 .948.681l.843 2.526 2.525.841a1 1 0 0 1 0 1.899l-2.525.842-.843 2.525a1 1 0 0 1-1.896 0l-.843-2.525-2.525-.842a1 1 0 0 1 0-1.899l2.525-.841.843-2.526a1 1 0 0 1 .948-.68",
2872
+ fill: "currentColor"
2873
+ })]
2874
+ });
2875
+ //#endregion
2814
2876
  //#region src/components/Icon/icons/CheckmarkCircleIcon.tsx
2815
2877
  const CheckmarkCircleIcon = (props) => /* @__PURE__ */ jsx("svg", {
2816
2878
  ...props,
@@ -3190,6 +3252,17 @@ const DiamondIcon = (props) => /* @__PURE__ */ jsx("svg", {
3190
3252
  })
3191
3253
  });
3192
3254
  //#endregion
3255
+ //#region src/components/Icon/icons/DockRightIcon.tsx
3256
+ const DockRightIcon = (props) => /* @__PURE__ */ jsx("svg", {
3257
+ ...props,
3258
+ viewBox: "0 0 24 24",
3259
+ xmlns: "http://www.w3.org/2000/svg",
3260
+ children: /* @__PURE__ */ jsx("path", {
3261
+ d: "M19 3.333H5A3.67 3.67 0 0 0 1.333 7v10A3.67 3.67 0 0 0 5 20.667h14A3.67 3.67 0 0 0 22.667 17V7A3.67 3.67 0 0 0 19 3.333M20.667 17c0 .92-.747 1.667-1.667 1.667h-2.667c-.92 0-1.666-.747-1.666-1.667V7c0-.92.746-1.667 1.666-1.667H19c.92 0 1.667.747 1.667 1.667z",
3262
+ fill: "currentColor"
3263
+ })
3264
+ });
3265
+ //#endregion
3193
3266
  //#region src/components/Icon/icons/DocsDevIcon.tsx
3194
3267
  const DocsDevIcon = (props) => /* @__PURE__ */ jsx("svg", {
3195
3268
  ...props,
@@ -5436,6 +5509,17 @@ const WebinarSeriesIcon = (props) => /* @__PURE__ */ jsx("svg", {
5436
5509
  })
5437
5510
  });
5438
5511
  //#endregion
5512
+ //#region src/components/Icon/icons/WistiaIcon.tsx
5513
+ const WistiaIcon = (props) => /* @__PURE__ */ jsx("svg", {
5514
+ ...props,
5515
+ viewBox: "0 0 24 24",
5516
+ xmlns: "http://www.w3.org/2000/svg",
5517
+ children: /* @__PURE__ */ jsx("path", {
5518
+ d: "M11.312 14.304H8.087c-.98 0-1.91.422-2.549 1.16l-4.074 4.688c2.964.155 6.065.155 8.248.155 11.355 0 12.955-6.99 12.955-10.264-.986 1.197-3.759 4.26-11.362 4.26zm9.953-10.605c-.05.57-.366 2.909-7.014 2.909-5.408 0-7.59 0-12.918-.106l3.994 4.59a4.13 4.13 0 0 0 3.076 1.426c1.321.018 3.132.037 3.43.037 6.827 0 10.66-3.132 10.66-6.133 0-1.247-.415-2.134-1.222-2.729z",
5519
+ fill: "currentColor"
5520
+ })
5521
+ });
5522
+ //#endregion
5439
5523
  //#region src/components/Icon/icons/WriteIcon.tsx
5440
5524
  const WriteIcon = (props) => /* @__PURE__ */ jsx("svg", {
5441
5525
  ...props,
@@ -5523,6 +5607,7 @@ const iconMap = {
5523
5607
  channel: ChannelIcon,
5524
5608
  chapters: ChaptersIcon,
5525
5609
  chat: ChatIcon,
5610
+ "chat-sparkle": ChatSparkleIcon,
5526
5611
  checkmark: CheckmarkIcon,
5527
5612
  "checkmark-circle": CheckmarkCircleIcon,
5528
5613
  "checkmark-circle-outline": CheckmarkCircleOutlineIcon,
@@ -5554,6 +5639,7 @@ const iconMap = {
5554
5639
  delete: DeleteIcon,
5555
5640
  desktop: DesktopIcon,
5556
5641
  diamond: DiamondIcon,
5642
+ "dock-right": DockRightIcon,
5557
5643
  "docs-dev": DocsDevIcon,
5558
5644
  "dots-horizontal": DotsHorizontalIcon,
5559
5645
  download: DownloadIcon,
@@ -5728,6 +5814,7 @@ const iconMap = {
5728
5814
  waveform: WaveformIcon,
5729
5815
  webhook: WebhookIcon,
5730
5816
  "webinar-series": WebinarSeriesIcon,
5817
+ wistia: WistiaIcon,
5731
5818
  write: WriteIcon,
5732
5819
  "zoom-in": ZoomInIcon,
5733
5820
  "zoom-out": ZoomOutIcon
@@ -6871,10 +6958,11 @@ const PolymorphicStyledHeading = withPolymorphicAs(styled.div`
6871
6958
  line-height: var(--line-height);
6872
6959
  color: var(--text-color);
6873
6960
  ${({ $variant }) => headingVariantStyleMap[$variant]}
6874
- ${({ $maxLines }) => {
6961
+ ${({ $maxLines, $wordBreak }) => {
6875
6962
  if (isNotNil($maxLines)) return css`
6876
6963
  ${ellipsisStyle};
6877
6964
  ${lineClampCss($maxLines)};
6965
+ ${wordBreakCss($wordBreak)};
6878
6966
  `;
6879
6967
  }}
6880
6968
  ${({ $inline }) => $inline && css`
@@ -6902,7 +6990,7 @@ const headingVariantElementMap = {
6902
6990
  heading5: "h5",
6903
6991
  heading6: "h6"
6904
6992
  };
6905
- const HeadingComponent = ({ ref, align = "left", children, colorScheme = "inherit", disabled = false, inline = false, maxChars, preventUserSelect = false, prominence = "primary", maxLines, textTransform, variant = "heading1", renderAs, ...props }) => {
6993
+ const HeadingComponent = ({ ref, align = "left", children, colorScheme = "inherit", disabled = false, inline = false, maxChars, preventUserSelect = false, prominence = "primary", maxLines, textTransform, wordBreak = "anywhere", variant = "heading1", renderAs, ...props }) => {
6906
6994
  const processedChildren = applyMaxCharsToChildren(children, maxChars);
6907
6995
  return /* @__PURE__ */ jsx(PolymorphicStyledHeading, {
6908
6996
  ref,
@@ -6915,6 +7003,7 @@ const HeadingComponent = ({ ref, align = "left", children, colorScheme = "inheri
6915
7003
  $prominence: prominence,
6916
7004
  $textTransform: textTransform,
6917
7005
  $variant: variant,
7006
+ $wordBreak: wordBreak,
6918
7007
  as: renderAs ?? headingVariantElementMap[variant] ?? DEFAULT_ELEMENT$3,
6919
7008
  ...props,
6920
7009
  children: processedChildren
@@ -7098,10 +7187,11 @@ const PolymorphicStyledText = withPolymorphicAs(styled.div`
7098
7187
  font-style: normal;
7099
7188
  margin: 0;
7100
7189
  ${({ $variant }) => textVariantStyleMap[$variant]}
7101
- ${({ $maxLines }) => {
7190
+ ${({ $maxLines, $wordBreak }) => {
7102
7191
  if (isNotNil($maxLines)) return css`
7103
7192
  ${ellipsisStyle};
7104
7193
  ${lineClampCss($maxLines)};
7194
+ ${wordBreakCss($wordBreak)};
7105
7195
  `;
7106
7196
  }}
7107
7197
  ${({ $inline }) => $inline && css`
@@ -7127,7 +7217,7 @@ const PolymorphicStyledText = withPolymorphicAs(styled.div`
7127
7217
  }
7128
7218
  `}
7129
7219
  `);
7130
- const TextComponent = ({ ref, align = "left", children, colorScheme = "inherit", disabled = false, inline = false, maxChars, preventUserSelect = false, prominence = "primary", maxLines, textTransform, variant = "body2", renderAs, ...props }) => {
7220
+ const TextComponent = ({ ref, align = "left", children, colorScheme = "inherit", disabled = false, inline = false, maxChars, preventUserSelect = false, prominence = "primary", maxLines, textTransform, wordBreak = "anywhere", variant = "body2", renderAs, ...props }) => {
7131
7221
  const processedChildren = applyMaxCharsToChildren(children, maxChars);
7132
7222
  return /* @__PURE__ */ jsx(PolymorphicStyledText, {
7133
7223
  ref,
@@ -7140,6 +7230,7 @@ const TextComponent = ({ ref, align = "left", children, colorScheme = "inherit",
7140
7230
  $prominence: prominence,
7141
7231
  $textTransform: textTransform,
7142
7232
  $variant: variant,
7233
+ $wordBreak: wordBreak,
7143
7234
  as: renderAs ?? textVariantElementMap[variant] ?? DEFAULT_ELEMENT$2,
7144
7235
  ...props,
7145
7236
  children: processedChildren