@wistia/ui 3.2.1 → 3.4.0
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/CHANGELOG.md +18 -0
- package/dist/index.d.ts +42 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +123 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v3.
|
|
3
|
+
* @license @wistia/ui v3.4.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2026, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1546,21 +1546,34 @@ const scopeTab = (node, event) => {
|
|
|
1546
1546
|
const target = tabbable[event.shiftKey ? tabbable.length - 1 : 0];
|
|
1547
1547
|
if (target) target.focus();
|
|
1548
1548
|
};
|
|
1549
|
+
const ariaHiderState = /* @__PURE__ */ new WeakMap();
|
|
1549
1550
|
const createAriaHider = (containerNode, selector = "body > :not(script)") => {
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
const
|
|
1553
|
-
if (
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1551
|
+
const hiddenNodes = [...document.querySelectorAll(selector)].filter((node) => !node.contains(containerNode));
|
|
1552
|
+
hiddenNodes.forEach((node) => {
|
|
1553
|
+
const state = ariaHiderState.get(node);
|
|
1554
|
+
if (state) {
|
|
1555
|
+
state.count += 1;
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
const originalAriaHidden = node.getAttribute("aria-hidden");
|
|
1559
|
+
ariaHiderState.set(node, {
|
|
1560
|
+
count: 1,
|
|
1561
|
+
originalAriaHidden
|
|
1562
|
+
});
|
|
1563
|
+
if (originalAriaHidden === null || originalAriaHidden === "false") node.setAttribute("aria-hidden", "true");
|
|
1558
1564
|
});
|
|
1565
|
+
let isRestored = false;
|
|
1559
1566
|
return () => {
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1567
|
+
if (isRestored) return;
|
|
1568
|
+
isRestored = true;
|
|
1569
|
+
hiddenNodes.forEach((node) => {
|
|
1570
|
+
const state = ariaHiderState.get(node);
|
|
1571
|
+
if (!state) return;
|
|
1572
|
+
state.count -= 1;
|
|
1573
|
+
if (state.count > 0) return;
|
|
1574
|
+
ariaHiderState.delete(node);
|
|
1575
|
+
if (state.originalAriaHidden === null) node.removeAttribute("aria-hidden");
|
|
1576
|
+
else node.setAttribute("aria-hidden", state.originalAriaHidden);
|
|
1564
1577
|
});
|
|
1565
1578
|
};
|
|
1566
1579
|
};
|
|
@@ -1570,47 +1583,53 @@ const isRef = (val) => {
|
|
|
1570
1583
|
return val !== null && typeof val === "object" && "current" in val;
|
|
1571
1584
|
};
|
|
1572
1585
|
const useFocusTrap = (active = true, options = {}) => {
|
|
1573
|
-
const
|
|
1574
|
-
const
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1577
|
-
|
|
1586
|
+
const { disableAriaHider = false, focusSelector } = options;
|
|
1587
|
+
const [node, setNode] = useState(null);
|
|
1588
|
+
const nodeRef = useRef(null);
|
|
1589
|
+
const setRef = useCallback((nextNode) => {
|
|
1590
|
+
nodeRef.current = nextNode ?? null;
|
|
1591
|
+
setNode(nextNode ?? null);
|
|
1592
|
+
}, []);
|
|
1593
|
+
useLayoutEffect(() => {
|
|
1594
|
+
if (!active || node === null) return;
|
|
1595
|
+
setupScopedFocus(node);
|
|
1596
|
+
markForFocusLater();
|
|
1597
|
+
let restoreAria = null;
|
|
1598
|
+
const processNode = () => {
|
|
1599
|
+
restoreAria = disableAriaHider ? null : createAriaHider(node);
|
|
1600
|
+
let focusElement = null;
|
|
1601
|
+
if (isNotUndefined(focusSelector)) {
|
|
1602
|
+
if (isRef(focusSelector)) focusElement = focusSelector.current;
|
|
1603
|
+
else focusElement = typeof focusSelector === "string" ? node.querySelector(focusSelector) : focusSelector;
|
|
1604
|
+
}
|
|
1605
|
+
if (!focusElement) {
|
|
1606
|
+
const children = [...node.querySelectorAll(FOCUSABLE_ELEMENT_SELECTORS)];
|
|
1607
|
+
focusElement = children.find((element) => isTabbableElement(element)) ?? children.find((element) => isFocusableElement(element)) ?? null;
|
|
1608
|
+
if (!focusElement && isFocusableElement(node)) focusElement = node;
|
|
1609
|
+
}
|
|
1610
|
+
if (focusElement) focusElement.focus();
|
|
1611
|
+
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);
|
|
1612
|
+
};
|
|
1613
|
+
const timeoutId = setTimeout(() => {
|
|
1614
|
+
if (node.ownerDocument) processNode();
|
|
1615
|
+
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);
|
|
1616
|
+
}, 0);
|
|
1617
|
+
return () => {
|
|
1618
|
+
clearTimeout(timeoutId);
|
|
1619
|
+
restoreAria?.();
|
|
1578
1620
|
returnFocus();
|
|
1579
1621
|
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;
|
|
1622
|
+
};
|
|
1605
1623
|
}, [
|
|
1606
1624
|
active,
|
|
1607
|
-
|
|
1608
|
-
|
|
1625
|
+
node,
|
|
1626
|
+
focusSelector,
|
|
1627
|
+
disableAriaHider
|
|
1609
1628
|
]);
|
|
1610
1629
|
useEffect(() => {
|
|
1611
1630
|
if (!active) return;
|
|
1612
1631
|
const handleKeyDown = (event) => {
|
|
1613
|
-
if (event.key === "Tab" &&
|
|
1632
|
+
if (event.key === "Tab" && nodeRef.current) scopeTab(nodeRef.current, event);
|
|
1614
1633
|
};
|
|
1615
1634
|
document.addEventListener("keydown", handleKeyDown);
|
|
1616
1635
|
return () => {
|
|
@@ -1887,6 +1906,14 @@ const lineClampCss = ($lines = 1) => css`
|
|
|
1887
1906
|
white-space: initial;
|
|
1888
1907
|
`;
|
|
1889
1908
|
//#endregion
|
|
1909
|
+
//#region src/css/wordBreakCss.tsx
|
|
1910
|
+
const wordBreakCss = (wordBreak = "anywhere") => {
|
|
1911
|
+
if (wordBreak === "word") return css`
|
|
1912
|
+
word-break: normal;
|
|
1913
|
+
overflow-wrap: anywhere;
|
|
1914
|
+
`;
|
|
1915
|
+
};
|
|
1916
|
+
//#endregion
|
|
1890
1917
|
//#region src/components/Ellipsis/Ellipsis.tsx
|
|
1891
1918
|
const ellipsisStyle = css`
|
|
1892
1919
|
overflow: hidden;
|
|
@@ -1918,12 +1945,14 @@ const EllipsisComponent = styled.span`
|
|
|
1918
1945
|
${({ $lines }) => {
|
|
1919
1946
|
if (isNotNil($lines)) return lineClampCss($lines);
|
|
1920
1947
|
}}
|
|
1948
|
+
${({ $wordBreak }) => wordBreakCss($wordBreak)};
|
|
1921
1949
|
`;
|
|
1922
1950
|
/**
|
|
1923
1951
|
* Truncate text with an ellispsis visble at the end
|
|
1924
1952
|
*/
|
|
1925
|
-
const Ellipsis = ({ children, lines, ...props }) => /* @__PURE__ */ jsx(EllipsisComponent, {
|
|
1953
|
+
const Ellipsis = ({ children, lines, wordBreak = "anywhere", ...props }) => /* @__PURE__ */ jsx(EllipsisComponent, {
|
|
1926
1954
|
$lines: lines,
|
|
1955
|
+
$wordBreak: wordBreak,
|
|
1927
1956
|
...props,
|
|
1928
1957
|
children
|
|
1929
1958
|
});
|
|
@@ -2811,6 +2840,20 @@ const ChatIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
|
2811
2840
|
})
|
|
2812
2841
|
});
|
|
2813
2842
|
//#endregion
|
|
2843
|
+
//#region src/components/Icon/icons/ChatSparkleIcon.tsx
|
|
2844
|
+
const ChatSparkleIcon = (props) => /* @__PURE__ */ jsxs("svg", {
|
|
2845
|
+
...props,
|
|
2846
|
+
viewBox: "0 0 24 24",
|
|
2847
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2848
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
2849
|
+
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",
|
|
2850
|
+
fill: "currentColor"
|
|
2851
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
2852
|
+
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",
|
|
2853
|
+
fill: "currentColor"
|
|
2854
|
+
})]
|
|
2855
|
+
});
|
|
2856
|
+
//#endregion
|
|
2814
2857
|
//#region src/components/Icon/icons/CheckmarkCircleIcon.tsx
|
|
2815
2858
|
const CheckmarkCircleIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
2816
2859
|
...props,
|
|
@@ -3190,6 +3233,17 @@ const DiamondIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
|
3190
3233
|
})
|
|
3191
3234
|
});
|
|
3192
3235
|
//#endregion
|
|
3236
|
+
//#region src/components/Icon/icons/DockRightIcon.tsx
|
|
3237
|
+
const DockRightIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
3238
|
+
...props,
|
|
3239
|
+
viewBox: "0 0 24 24",
|
|
3240
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3241
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
3242
|
+
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",
|
|
3243
|
+
fill: "currentColor"
|
|
3244
|
+
})
|
|
3245
|
+
});
|
|
3246
|
+
//#endregion
|
|
3193
3247
|
//#region src/components/Icon/icons/DocsDevIcon.tsx
|
|
3194
3248
|
const DocsDevIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
3195
3249
|
...props,
|
|
@@ -5436,6 +5490,17 @@ const WebinarSeriesIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
|
5436
5490
|
})
|
|
5437
5491
|
});
|
|
5438
5492
|
//#endregion
|
|
5493
|
+
//#region src/components/Icon/icons/WistiaIcon.tsx
|
|
5494
|
+
const WistiaIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
5495
|
+
...props,
|
|
5496
|
+
viewBox: "0 0 24 24",
|
|
5497
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5498
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
5499
|
+
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",
|
|
5500
|
+
fill: "currentColor"
|
|
5501
|
+
})
|
|
5502
|
+
});
|
|
5503
|
+
//#endregion
|
|
5439
5504
|
//#region src/components/Icon/icons/WriteIcon.tsx
|
|
5440
5505
|
const WriteIcon = (props) => /* @__PURE__ */ jsx("svg", {
|
|
5441
5506
|
...props,
|
|
@@ -5523,6 +5588,7 @@ const iconMap = {
|
|
|
5523
5588
|
channel: ChannelIcon,
|
|
5524
5589
|
chapters: ChaptersIcon,
|
|
5525
5590
|
chat: ChatIcon,
|
|
5591
|
+
"chat-sparkle": ChatSparkleIcon,
|
|
5526
5592
|
checkmark: CheckmarkIcon,
|
|
5527
5593
|
"checkmark-circle": CheckmarkCircleIcon,
|
|
5528
5594
|
"checkmark-circle-outline": CheckmarkCircleOutlineIcon,
|
|
@@ -5554,6 +5620,7 @@ const iconMap = {
|
|
|
5554
5620
|
delete: DeleteIcon,
|
|
5555
5621
|
desktop: DesktopIcon,
|
|
5556
5622
|
diamond: DiamondIcon,
|
|
5623
|
+
"dock-right": DockRightIcon,
|
|
5557
5624
|
"docs-dev": DocsDevIcon,
|
|
5558
5625
|
"dots-horizontal": DotsHorizontalIcon,
|
|
5559
5626
|
download: DownloadIcon,
|
|
@@ -5728,6 +5795,7 @@ const iconMap = {
|
|
|
5728
5795
|
waveform: WaveformIcon,
|
|
5729
5796
|
webhook: WebhookIcon,
|
|
5730
5797
|
"webinar-series": WebinarSeriesIcon,
|
|
5798
|
+
wistia: WistiaIcon,
|
|
5731
5799
|
write: WriteIcon,
|
|
5732
5800
|
"zoom-in": ZoomInIcon,
|
|
5733
5801
|
"zoom-out": ZoomOutIcon
|
|
@@ -6871,10 +6939,11 @@ const PolymorphicStyledHeading = withPolymorphicAs(styled.div`
|
|
|
6871
6939
|
line-height: var(--line-height);
|
|
6872
6940
|
color: var(--text-color);
|
|
6873
6941
|
${({ $variant }) => headingVariantStyleMap[$variant]}
|
|
6874
|
-
${({ $maxLines }) => {
|
|
6942
|
+
${({ $maxLines, $wordBreak }) => {
|
|
6875
6943
|
if (isNotNil($maxLines)) return css`
|
|
6876
6944
|
${ellipsisStyle};
|
|
6877
6945
|
${lineClampCss($maxLines)};
|
|
6946
|
+
${wordBreakCss($wordBreak)};
|
|
6878
6947
|
`;
|
|
6879
6948
|
}}
|
|
6880
6949
|
${({ $inline }) => $inline && css`
|
|
@@ -6902,7 +6971,7 @@ const headingVariantElementMap = {
|
|
|
6902
6971
|
heading5: "h5",
|
|
6903
6972
|
heading6: "h6"
|
|
6904
6973
|
};
|
|
6905
|
-
const HeadingComponent = ({ ref, align = "left", children, colorScheme = "inherit", disabled = false, inline = false, maxChars, preventUserSelect = false, prominence = "primary", maxLines, textTransform, variant = "heading1", renderAs, ...props }) => {
|
|
6974
|
+
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
6975
|
const processedChildren = applyMaxCharsToChildren(children, maxChars);
|
|
6907
6976
|
return /* @__PURE__ */ jsx(PolymorphicStyledHeading, {
|
|
6908
6977
|
ref,
|
|
@@ -6915,6 +6984,7 @@ const HeadingComponent = ({ ref, align = "left", children, colorScheme = "inheri
|
|
|
6915
6984
|
$prominence: prominence,
|
|
6916
6985
|
$textTransform: textTransform,
|
|
6917
6986
|
$variant: variant,
|
|
6987
|
+
$wordBreak: wordBreak,
|
|
6918
6988
|
as: renderAs ?? headingVariantElementMap[variant] ?? DEFAULT_ELEMENT$3,
|
|
6919
6989
|
...props,
|
|
6920
6990
|
children: processedChildren
|
|
@@ -7098,10 +7168,11 @@ const PolymorphicStyledText = withPolymorphicAs(styled.div`
|
|
|
7098
7168
|
font-style: normal;
|
|
7099
7169
|
margin: 0;
|
|
7100
7170
|
${({ $variant }) => textVariantStyleMap[$variant]}
|
|
7101
|
-
${({ $maxLines }) => {
|
|
7171
|
+
${({ $maxLines, $wordBreak }) => {
|
|
7102
7172
|
if (isNotNil($maxLines)) return css`
|
|
7103
7173
|
${ellipsisStyle};
|
|
7104
7174
|
${lineClampCss($maxLines)};
|
|
7175
|
+
${wordBreakCss($wordBreak)};
|
|
7105
7176
|
`;
|
|
7106
7177
|
}}
|
|
7107
7178
|
${({ $inline }) => $inline && css`
|
|
@@ -7127,7 +7198,7 @@ const PolymorphicStyledText = withPolymorphicAs(styled.div`
|
|
|
7127
7198
|
}
|
|
7128
7199
|
`}
|
|
7129
7200
|
`);
|
|
7130
|
-
const TextComponent = ({ ref, align = "left", children, colorScheme = "inherit", disabled = false, inline = false, maxChars, preventUserSelect = false, prominence = "primary", maxLines, textTransform, variant = "body2", renderAs, ...props }) => {
|
|
7201
|
+
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
7202
|
const processedChildren = applyMaxCharsToChildren(children, maxChars);
|
|
7132
7203
|
return /* @__PURE__ */ jsx(PolymorphicStyledText, {
|
|
7133
7204
|
ref,
|
|
@@ -7140,6 +7211,7 @@ const TextComponent = ({ ref, align = "left", children, colorScheme = "inherit",
|
|
|
7140
7211
|
$prominence: prominence,
|
|
7141
7212
|
$textTransform: textTransform,
|
|
7142
7213
|
$variant: variant,
|
|
7214
|
+
$wordBreak: wordBreak,
|
|
7143
7215
|
as: renderAs ?? textVariantElementMap[variant] ?? DEFAULT_ELEMENT$2,
|
|
7144
7216
|
...props,
|
|
7145
7217
|
children: processedChildren
|