@wistia/ui 0.4.5 → 0.4.6-beta.12aa477c.cc6313b
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 +129 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.mjs +106 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.4.
|
|
3
|
+
* @license @wistia/ui v0.4.6-beta.12aa477c.cc6313b
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1545,10 +1545,18 @@ var useActiveMq = () => {
|
|
|
1545
1545
|
};
|
|
1546
1546
|
|
|
1547
1547
|
// src/hooks/useKey/useKey.ts
|
|
1548
|
-
import {
|
|
1548
|
+
import { useCallback as useCallback3 } from "react";
|
|
1549
1549
|
|
|
1550
1550
|
// src/private/hooks/useEvent/useEvent.ts
|
|
1551
1551
|
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
1552
|
+
|
|
1553
|
+
// src/private/helpers/isObjectRef/isObjectRef.ts
|
|
1554
|
+
import { isNotNil, isRecord } from "@wistia/type-guards";
|
|
1555
|
+
var isObjectRef = (value) => {
|
|
1556
|
+
return isNotNil(value) && isRecord(value) && "current" in value;
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
// src/private/hooks/useEvent/useEvent.ts
|
|
1552
1560
|
var isEventTargetSupported = (eventTarget) => (
|
|
1553
1561
|
// @ts-expect-error the compiler thinks that addEventListener may not exist on eventTarget, but we still need to check it.
|
|
1554
1562
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
@@ -1564,7 +1572,8 @@ var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}
|
|
|
1564
1572
|
savedEventOptions.current = eventOptions;
|
|
1565
1573
|
}, [eventOptions]);
|
|
1566
1574
|
useEffect2(() => {
|
|
1567
|
-
|
|
1575
|
+
const target = isObjectRef(eventTarget) ? eventTarget.current : eventTarget;
|
|
1576
|
+
if (!eventName || !isEventTargetSupported(target)) {
|
|
1568
1577
|
return;
|
|
1569
1578
|
}
|
|
1570
1579
|
const eventListener = (event) => {
|
|
@@ -1574,39 +1583,36 @@ var useEvent = (eventName, eventHandler, eventTarget = window, eventOptions = {}
|
|
|
1574
1583
|
return () => {
|
|
1575
1584
|
};
|
|
1576
1585
|
};
|
|
1577
|
-
|
|
1586
|
+
target.addEventListener(eventName, eventListener, savedEventOptions.current);
|
|
1578
1587
|
return () => {
|
|
1579
|
-
|
|
1588
|
+
target.removeEventListener(eventName, eventListener, savedEventOptions.current);
|
|
1580
1589
|
};
|
|
1581
1590
|
}, [eventName, eventTarget, savedEventOptions]);
|
|
1582
1591
|
};
|
|
1583
1592
|
|
|
1584
1593
|
// src/hooks/useKey/useKey.ts
|
|
1585
|
-
var
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
}
|
|
1589
|
-
if (typeof keyFilter === "string") {
|
|
1590
|
-
return (event) => event.key === keyFilter;
|
|
1591
|
-
}
|
|
1592
|
-
if (keyFilter !== null && keyFilter !== void 0 && !!keyFilter) {
|
|
1593
|
-
return () => true;
|
|
1594
|
-
}
|
|
1595
|
-
return () => false;
|
|
1596
|
-
};
|
|
1597
|
-
var useKey = (key, eventHandler, options = {}, dependencies = [key]) => {
|
|
1598
|
-
const { eventName = "keydown", eventTarget, eventOptions } = options;
|
|
1599
|
-
const memoizedEventHandler = useMemo2(() => {
|
|
1600
|
-
const predicate = createKeyPredicate(key);
|
|
1601
|
-
return (handlerEvent) => {
|
|
1594
|
+
var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOptions } = {}) => {
|
|
1595
|
+
const memoizedEventHandler = useCallback3(
|
|
1596
|
+
(handlerEvent) => {
|
|
1602
1597
|
if (["INPUT", "TEXTAREA", "SELECT"].includes(document.activeElement?.nodeName ?? "") || document.activeElement?.isContentEditable) {
|
|
1603
1598
|
return;
|
|
1604
1599
|
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1600
|
+
let matchesKey = false;
|
|
1601
|
+
if (typeof key === "function") {
|
|
1602
|
+
matchesKey = key(handlerEvent);
|
|
1603
|
+
} else if (typeof key === "string") {
|
|
1604
|
+
matchesKey = handlerEvent.key === key;
|
|
1605
|
+
} else if (key) {
|
|
1606
|
+
matchesKey = true;
|
|
1607
|
+
} else {
|
|
1608
|
+
matchesKey = false;
|
|
1609
|
+
}
|
|
1610
|
+
if (matchesKey) {
|
|
1611
|
+
eventHandler(handlerEvent);
|
|
1607
1612
|
}
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1613
|
+
},
|
|
1614
|
+
[key, eventHandler]
|
|
1615
|
+
);
|
|
1610
1616
|
useEvent(eventName, memoizedEventHandler, eventTarget, eventOptions);
|
|
1611
1617
|
};
|
|
1612
1618
|
|
|
@@ -1622,16 +1628,16 @@ var useAriaLive = () => {
|
|
|
1622
1628
|
};
|
|
1623
1629
|
|
|
1624
1630
|
// src/hooks/useToast/useToast.tsx
|
|
1625
|
-
import { useCallback as
|
|
1631
|
+
import { useCallback as useCallback4 } from "react";
|
|
1626
1632
|
import { toast as sonnerToast } from "sonner";
|
|
1627
1633
|
|
|
1628
1634
|
// src/private/components/Toast/Toast.tsx
|
|
1629
1635
|
import { cloneElement, isValidElement } from "react";
|
|
1630
1636
|
import styled2 from "styled-components";
|
|
1631
|
-
import { isNotNil as
|
|
1637
|
+
import { isNotNil as isNotNil3 } from "@wistia/type-guards";
|
|
1632
1638
|
|
|
1633
1639
|
// src/components/Ellipsis/Ellipsis.tsx
|
|
1634
|
-
import { isNotNil } from "@wistia/type-guards";
|
|
1640
|
+
import { isNotNil as isNotNil2 } from "@wistia/type-guards";
|
|
1635
1641
|
import styled, { css as css10 } from "styled-components";
|
|
1636
1642
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1637
1643
|
var ellipsisStyle = css10`
|
|
@@ -1663,7 +1669,7 @@ var ellipsisFlexParentStyle = css10`
|
|
|
1663
1669
|
var EllipsisComponent = styled.div`
|
|
1664
1670
|
${ellipsisStyle};
|
|
1665
1671
|
${({ $lines }) => {
|
|
1666
|
-
if (
|
|
1672
|
+
if (isNotNil2($lines)) {
|
|
1667
1673
|
return css10`
|
|
1668
1674
|
-webkit-box-orient: vertical;
|
|
1669
1675
|
-webkit-line-clamp: ${$lines};
|
|
@@ -1847,7 +1853,7 @@ var StyledToast = styled2.div`
|
|
|
1847
1853
|
}
|
|
1848
1854
|
`;
|
|
1849
1855
|
var Action = ({ actionButton }) => {
|
|
1850
|
-
if (
|
|
1856
|
+
if (isNotNil3(actionButton) && isValidElement(actionButton)) {
|
|
1851
1857
|
return /* @__PURE__ */ jsx5(ActionWrapper, { children: cloneElement(actionButton, {
|
|
1852
1858
|
variant: "soft",
|
|
1853
1859
|
// force Button variant
|
|
@@ -1871,7 +1877,7 @@ var Toast = ({
|
|
|
1871
1877
|
$colorScheme: colorScheme,
|
|
1872
1878
|
children: [
|
|
1873
1879
|
/* @__PURE__ */ jsxs2(MessageWrapper, { children: [
|
|
1874
|
-
|
|
1880
|
+
isNotNil3(icon) ? icon : null,
|
|
1875
1881
|
/* @__PURE__ */ jsx5(Message, { lines: 3, children: message })
|
|
1876
1882
|
] }),
|
|
1877
1883
|
/* @__PURE__ */ jsx5(Action, { actionButton: action })
|
|
@@ -1884,7 +1890,7 @@ Toast.displayName = "Toast";
|
|
|
1884
1890
|
// src/hooks/useToast/useToast.tsx
|
|
1885
1891
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1886
1892
|
var useToast = () => {
|
|
1887
|
-
return
|
|
1893
|
+
return useCallback4(
|
|
1888
1894
|
({ message, action, colorScheme, icon, position = "bottom-left", duration = 3e3 }) => {
|
|
1889
1895
|
sonnerToast.custom(
|
|
1890
1896
|
() => {
|
|
@@ -1912,7 +1918,7 @@ import styled6, { css as css14 } from "styled-components";
|
|
|
1912
1918
|
// src/components/Button/Button.tsx
|
|
1913
1919
|
import { forwardRef as forwardRef2 } from "react";
|
|
1914
1920
|
import styled5 from "styled-components";
|
|
1915
|
-
import { isNotNil as
|
|
1921
|
+
import { isNotNil as isNotNil5, isNotUndefined as isNotUndefined3 } from "@wistia/type-guards";
|
|
1916
1922
|
|
|
1917
1923
|
// src/css/buttonResetCss.tsx
|
|
1918
1924
|
import { css as css12 } from "styled-components";
|
|
@@ -5276,15 +5282,15 @@ var iconMap = {
|
|
|
5276
5282
|
};
|
|
5277
5283
|
|
|
5278
5284
|
// src/private/hooks/useResponsiveProp/useResponsiveProp.ts
|
|
5279
|
-
import { isNotUndefined, isRecord, isUndefined } from "@wistia/type-guards";
|
|
5280
|
-
import { useMemo as
|
|
5285
|
+
import { isNotUndefined, isRecord as isRecord2, isUndefined } from "@wistia/type-guards";
|
|
5286
|
+
import { useMemo as useMemo2 } from "react";
|
|
5281
5287
|
var isResponsiveObject = (values) => {
|
|
5282
5288
|
return typeof values === "object" && values !== null && !Array.isArray(values) && "base" in values;
|
|
5283
5289
|
};
|
|
5284
5290
|
var useResponsiveProp = (values) => {
|
|
5285
5291
|
const activeMediaQueries = useActiveMq();
|
|
5286
|
-
return
|
|
5287
|
-
if (
|
|
5292
|
+
return useMemo2(() => {
|
|
5293
|
+
if (isRecord2(values) && isResponsiveObject(values)) {
|
|
5288
5294
|
const mq2 = activeMediaQueries.find((key) => key in values);
|
|
5289
5295
|
return isNotUndefined(mq2) && isNotUndefined(values[mq2]) ? values[mq2] : values.base;
|
|
5290
5296
|
}
|
|
@@ -5351,7 +5357,7 @@ Icon.displayName = "Icon";
|
|
|
5351
5357
|
|
|
5352
5358
|
// src/components/Link/Link.tsx
|
|
5353
5359
|
import { forwardRef } from "react";
|
|
5354
|
-
import { isNil as isNil4, isNotNil as
|
|
5360
|
+
import { isNil as isNil4, isNotNil as isNotNil4, isNotUndefined as isNotUndefined2, isUndefined as isUndefined2 } from "@wistia/type-guards";
|
|
5355
5361
|
import styled4 from "styled-components";
|
|
5356
5362
|
import { Link as RouterLink, useInRouterContext } from "react-router-dom";
|
|
5357
5363
|
import { jsx as jsx161 } from "react/jsx-runtime";
|
|
@@ -5402,7 +5408,7 @@ var Link = forwardRef(
|
|
|
5402
5408
|
} finally {
|
|
5403
5409
|
if (routingCallback !== null) {
|
|
5404
5410
|
routingCallback();
|
|
5405
|
-
} else if (
|
|
5411
|
+
} else if (isNotNil4(to)) {
|
|
5406
5412
|
window.location.assign(to);
|
|
5407
5413
|
} else {
|
|
5408
5414
|
}
|
|
@@ -5502,8 +5508,8 @@ var ButtonContent = ({
|
|
|
5502
5508
|
/* @__PURE__ */ jsxs5(
|
|
5503
5509
|
StyledButtonContent,
|
|
5504
5510
|
{
|
|
5505
|
-
$hasLeftIcon:
|
|
5506
|
-
$hasRightIcon:
|
|
5511
|
+
$hasLeftIcon: isNotNil5(leftIcon),
|
|
5512
|
+
$hasRightIcon: isNotNil5(rightIcon),
|
|
5507
5513
|
$isLoading: isLoading,
|
|
5508
5514
|
children: [
|
|
5509
5515
|
leftIcon ?? null,
|
|
@@ -5571,7 +5577,7 @@ var Button = forwardRef2(
|
|
|
5571
5577
|
event.preventDefault();
|
|
5572
5578
|
return;
|
|
5573
5579
|
}
|
|
5574
|
-
if (
|
|
5580
|
+
if (isNotNil5(onClick)) {
|
|
5575
5581
|
onClick(event);
|
|
5576
5582
|
}
|
|
5577
5583
|
};
|
|
@@ -5731,7 +5737,7 @@ var ActionButton = forwardRef3(
|
|
|
5731
5737
|
ActionButton.displayName = "ActionButton";
|
|
5732
5738
|
|
|
5733
5739
|
// src/components/Avatar/Avatar.tsx
|
|
5734
|
-
import { useState as useState4, useMemo as
|
|
5740
|
+
import { useState as useState4, useMemo as useMemo3, useEffect as useEffect3 } from "react";
|
|
5735
5741
|
import { isNil as isNil6 } from "@wistia/type-guards";
|
|
5736
5742
|
import styled8 from "styled-components";
|
|
5737
5743
|
|
|
@@ -5863,6 +5869,9 @@ var Avatar = ({
|
|
|
5863
5869
|
...otherProps
|
|
5864
5870
|
}) => {
|
|
5865
5871
|
const [imageLoadState, setImageLoadState] = useState4(null);
|
|
5872
|
+
useEffect3(() => {
|
|
5873
|
+
setImageLoadState(null);
|
|
5874
|
+
}, [imageUrl]);
|
|
5866
5875
|
const handleImageLoad = () => {
|
|
5867
5876
|
setImageLoadState("loaded");
|
|
5868
5877
|
onImageLoad?.("image");
|
|
@@ -5872,7 +5881,7 @@ var Avatar = ({
|
|
|
5872
5881
|
onImageLoad?.("initials");
|
|
5873
5882
|
};
|
|
5874
5883
|
const avatarSize = heightAndWidth ?? avatarSizeMap[size];
|
|
5875
|
-
const avatarColor =
|
|
5884
|
+
const avatarColor = useMemo3(() => chooseColorScheme(name), [name]);
|
|
5876
5885
|
const showInitials = isNil6(imageUrl) || imageLoadState === "error";
|
|
5877
5886
|
return /* @__PURE__ */ jsx165(
|
|
5878
5887
|
AvatarWrapper,
|
|
@@ -5904,7 +5913,7 @@ Avatar.displayName = "Avatar";
|
|
|
5904
5913
|
// src/components/Badge/Badge.tsx
|
|
5905
5914
|
import { forwardRef as forwardRef4 } from "react";
|
|
5906
5915
|
import styled9 from "styled-components";
|
|
5907
|
-
import { isNotNil as
|
|
5916
|
+
import { isNotNil as isNotNil6 } from "@wistia/type-guards";
|
|
5908
5917
|
import { jsx as jsx166, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
5909
5918
|
var StyledBadge = styled9.div`
|
|
5910
5919
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
@@ -5928,7 +5937,7 @@ var StyledBadge = styled9.div`
|
|
|
5928
5937
|
`;
|
|
5929
5938
|
var Badge = forwardRef4(
|
|
5930
5939
|
({ colorScheme = "inherit", label, icon, ...otherProps }, ref) => {
|
|
5931
|
-
const hasIcon =
|
|
5940
|
+
const hasIcon = isNotNil6(icon);
|
|
5932
5941
|
return /* @__PURE__ */ jsxs7(
|
|
5933
5942
|
StyledBadge,
|
|
5934
5943
|
{
|
|
@@ -5949,12 +5958,12 @@ Badge.displayName = "Badge";
|
|
|
5949
5958
|
// src/components/Box/Box.tsx
|
|
5950
5959
|
import { Children, cloneElement as cloneElement2 } from "react";
|
|
5951
5960
|
import styled10 from "styled-components";
|
|
5952
|
-
import { isNotNil as
|
|
5961
|
+
import { isNotNil as isNotNil7, isNil as isNil7, isRecord as isRecord3 } from "@wistia/type-guards";
|
|
5953
5962
|
import { jsx as jsx167 } from "react/jsx-runtime";
|
|
5954
5963
|
var isDev = process.env["NODE_ENV"] === "development" || process.env["NODE_ENV"] === "test";
|
|
5955
5964
|
var getGapStyle = (gap) => {
|
|
5956
|
-
if (
|
|
5957
|
-
if (
|
|
5965
|
+
if (isNotNil7(gap)) {
|
|
5966
|
+
if (isRecord3(gap)) {
|
|
5958
5967
|
return Object.entries(gap).map(([key, value]) => {
|
|
5959
5968
|
return `${key}-gap: var(--wui-${value})};`;
|
|
5960
5969
|
}).join("");
|
|
@@ -5997,22 +6006,22 @@ var BoxComponent = styled10.div`
|
|
|
5997
6006
|
align-content: ${({ $alignContent }) => $alignContent};
|
|
5998
6007
|
align-items: ${({ $alignItems }) => $alignItems};
|
|
5999
6008
|
align-self: ${({ $alignSelf }) => $alignSelf ?? null};
|
|
6000
|
-
display: ${({ $inline }) =>
|
|
6001
|
-
flex-basis: ${({ $basis }) =>
|
|
6009
|
+
display: ${({ $inline }) => isNotNil7($inline) && $inline ? "inline-flex" : "flex"};
|
|
6010
|
+
flex-basis: ${({ $basis }) => isNotNil7($basis) ? $basis : null};
|
|
6002
6011
|
flex-direction: ${({ $flexDirection }) => $flexDirection};
|
|
6003
6012
|
${({ $fillBox: fill }) => getFillStyle(fill)};
|
|
6004
6013
|
${({ $fillViewport }) => getFillViewportStyle($fillViewport)};
|
|
6005
6014
|
|
|
6006
6015
|
/* Box children styles */
|
|
6007
|
-
flex-grow: ${({ $grow }) =>
|
|
6008
|
-
flex-shrink: ${({ $shrink }) =>
|
|
6016
|
+
flex-grow: ${({ $grow }) => isNotNil7($grow) ? $grow : null};
|
|
6017
|
+
flex-shrink: ${({ $shrink }) => isNotNil7($shrink) ? $shrink : null};
|
|
6009
6018
|
flex-wrap: ${({ $wrapItems }) => $wrapItems ? "wrap" : "nowrap"};
|
|
6010
6019
|
${({ $gap }) => getGapStyle($gap)};
|
|
6011
6020
|
justify-content: ${({ $justifyContent }) => $justifyContent};
|
|
6012
|
-
order: ${({ $order }) =>
|
|
6021
|
+
order: ${({ $order }) => isNotNil7($order) ? $order : null};
|
|
6013
6022
|
`;
|
|
6014
6023
|
var wrapChildren = (children) => {
|
|
6015
|
-
if (
|
|
6024
|
+
if (isNotNil7(children)) {
|
|
6016
6025
|
if (typeof children === "object" && isDev) {
|
|
6017
6026
|
return Children.map(children, (child) => {
|
|
6018
6027
|
if (isNil7(child)) return null;
|
|
@@ -6098,11 +6107,12 @@ Breadcrumbs.displayName = "Breadcrumbs";
|
|
|
6098
6107
|
|
|
6099
6108
|
// src/components/Breadcrumbs/Breadcrumb.tsx
|
|
6100
6109
|
import { Fragment as Fragment2, jsx as jsx169, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
6101
|
-
var Breadcrumb = ({ icon, href, children }) => {
|
|
6110
|
+
var Breadcrumb = ({ icon, href, children, ...props }) => {
|
|
6102
6111
|
return /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
6103
6112
|
/* @__PURE__ */ jsx169(
|
|
6104
6113
|
Button,
|
|
6105
6114
|
{
|
|
6115
|
+
...props,
|
|
6106
6116
|
href,
|
|
6107
6117
|
leftIcon: icon,
|
|
6108
6118
|
variant: "ghost",
|
|
@@ -6618,7 +6628,7 @@ var Divider = ({
|
|
|
6618
6628
|
Divider.displayName = "Divider";
|
|
6619
6629
|
|
|
6620
6630
|
// src/components/Form/Form.tsx
|
|
6621
|
-
import { forwardRef as forwardRef8, useRef as useRef3, useMemo as
|
|
6631
|
+
import { forwardRef as forwardRef8, useRef as useRef3, useMemo as useMemo4, createContext as createContext2, useState as useState5, useId as useId2 } from "react";
|
|
6622
6632
|
import styled20 from "styled-components";
|
|
6623
6633
|
import { isNotUndefined as isNotUndefined4, isUndefined as isUndefined3 } from "@wistia/type-guards";
|
|
6624
6634
|
|
|
@@ -6712,7 +6722,7 @@ var FormComponent = ({ children, action, values = {}, validate, fullWidth = fals
|
|
|
6712
6722
|
void action(null);
|
|
6713
6723
|
}
|
|
6714
6724
|
};
|
|
6715
|
-
const context =
|
|
6725
|
+
const context = useMemo4(() => {
|
|
6716
6726
|
return {
|
|
6717
6727
|
values,
|
|
6718
6728
|
errors,
|
|
@@ -6743,12 +6753,12 @@ FormComponent.displayName = "Form";
|
|
|
6743
6753
|
var Form = forwardRef8(FormComponent);
|
|
6744
6754
|
|
|
6745
6755
|
// src/components/Form/useFormState.tsx
|
|
6746
|
-
import { useCallback as
|
|
6756
|
+
import { useCallback as useCallback5, useState as useState6 } from "react";
|
|
6747
6757
|
var useFormState = (action, initialData = {}) => {
|
|
6748
6758
|
const [data, setData] = useState6(initialData);
|
|
6749
6759
|
const [isPending, setIsPending] = useState6(false);
|
|
6750
6760
|
const [error, setError] = useState6(null);
|
|
6751
|
-
const formAction =
|
|
6761
|
+
const formAction = useCallback5(
|
|
6752
6762
|
async (nextFormData) => {
|
|
6753
6763
|
if (nextFormData === null) {
|
|
6754
6764
|
setData(initialData);
|
|
@@ -6819,7 +6829,7 @@ var FormErrorSummary = ({ description }) => {
|
|
|
6819
6829
|
// src/components/FormField/FormField.tsx
|
|
6820
6830
|
import { Children as Children2, cloneElement as cloneElement3, useContext as useContext3 } from "react";
|
|
6821
6831
|
import styled23 from "styled-components";
|
|
6822
|
-
import { isArray as isArray2, isNotNil as
|
|
6832
|
+
import { isArray as isArray2, isNotNil as isNotNil8, isNotUndefined as isNotUndefined6, isUndefined as isUndefined4 } from "@wistia/type-guards";
|
|
6823
6833
|
|
|
6824
6834
|
// src/components/Text/Text.tsx
|
|
6825
6835
|
import { forwardRef as forwardRef9 } from "react";
|
|
@@ -6999,7 +7009,7 @@ TextComponent.displayName = "Text";
|
|
|
6999
7009
|
var Text = makePolymorphic(TextComponent);
|
|
7000
7010
|
|
|
7001
7011
|
// src/components/FormGroup/CheckboxGroup.tsx
|
|
7002
|
-
import { createContext as createContext3, useMemo as
|
|
7012
|
+
import { createContext as createContext3, useMemo as useMemo5 } from "react";
|
|
7003
7013
|
|
|
7004
7014
|
// src/components/FormGroup/FormGroup.tsx
|
|
7005
7015
|
import styled22 from "styled-components";
|
|
@@ -7045,7 +7055,7 @@ var CheckboxGroup = ({
|
|
|
7045
7055
|
value,
|
|
7046
7056
|
...props
|
|
7047
7057
|
}) => {
|
|
7048
|
-
const context =
|
|
7058
|
+
const context = useMemo5(() => {
|
|
7049
7059
|
return {
|
|
7050
7060
|
name,
|
|
7051
7061
|
onChange
|
|
@@ -7123,8 +7133,8 @@ var FormField = ({
|
|
|
7123
7133
|
defaultValue
|
|
7124
7134
|
};
|
|
7125
7135
|
}
|
|
7126
|
-
if (
|
|
7127
|
-
const computedName =
|
|
7136
|
+
if (isNotNil8(checkboxGroup)) {
|
|
7137
|
+
const computedName = isNotNil8(checkboxGroup.name) ? `${checkboxGroup.name}[${name}]` : name;
|
|
7128
7138
|
const handleChange = (event) => {
|
|
7129
7139
|
if (isNotUndefined6(props.onChange)) {
|
|
7130
7140
|
props.onChange(event);
|
|
@@ -7137,15 +7147,15 @@ var FormField = ({
|
|
|
7137
7147
|
...childProps,
|
|
7138
7148
|
name: computedName,
|
|
7139
7149
|
onChange: handleChange,
|
|
7140
|
-
"aria-invalid":
|
|
7141
|
-
"aria-describedby":
|
|
7150
|
+
"aria-invalid": isNotNil8(error),
|
|
7151
|
+
"aria-describedby": isNotNil8(error) ? `${id}-error` : void 0
|
|
7142
7152
|
};
|
|
7143
7153
|
}
|
|
7144
7154
|
Children2.only(children);
|
|
7145
7155
|
return /* @__PURE__ */ jsxs12(StyledFormField, { ...props, children: [
|
|
7146
7156
|
!isInlineLabel && /* @__PURE__ */ jsx183(Label, { htmlFor: id, children: label }),
|
|
7147
7157
|
cloneElement3(children, childProps),
|
|
7148
|
-
|
|
7158
|
+
isNotNil8(computedError) ? /* @__PURE__ */ jsx183(
|
|
7149
7159
|
ErrorMessages,
|
|
7150
7160
|
{
|
|
7151
7161
|
errors: computedError,
|
|
@@ -7157,7 +7167,7 @@ var FormField = ({
|
|
|
7157
7167
|
FormField.displayName = "FormField";
|
|
7158
7168
|
|
|
7159
7169
|
// src/components/FormGroup/RadioGroup.tsx
|
|
7160
|
-
import { createContext as createContext4, useMemo as
|
|
7170
|
+
import { createContext as createContext4, useMemo as useMemo6 } from "react";
|
|
7161
7171
|
import { jsx as jsx184 } from "react/jsx-runtime";
|
|
7162
7172
|
var RadioGroupContext = createContext4(null);
|
|
7163
7173
|
var RadioGroup = ({
|
|
@@ -7167,7 +7177,7 @@ var RadioGroup = ({
|
|
|
7167
7177
|
value,
|
|
7168
7178
|
...props
|
|
7169
7179
|
}) => {
|
|
7170
|
-
const context =
|
|
7180
|
+
const context = useMemo6(() => {
|
|
7171
7181
|
return {
|
|
7172
7182
|
name,
|
|
7173
7183
|
onChange
|
|
@@ -7218,7 +7228,7 @@ IconButton.displayName = "IconButton";
|
|
|
7218
7228
|
// src/components/Input/Input.tsx
|
|
7219
7229
|
import { forwardRef as forwardRef11, cloneElement as cloneElement5, useRef as useRef6 } from "react";
|
|
7220
7230
|
import styled25, { css as css19 } from "styled-components";
|
|
7221
|
-
import { isNil as isNil10, isNotNil as
|
|
7231
|
+
import { isNil as isNil10, isNotNil as isNotNil9 } from "@wistia/type-guards";
|
|
7222
7232
|
import { jsx as jsx186, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
7223
7233
|
var inputStyles = css19`
|
|
7224
7234
|
--wui-input-color-bg: var(--wui-color-bg-surface);
|
|
@@ -7306,7 +7316,7 @@ var StyledInputContainer = styled25.div`
|
|
|
7306
7316
|
}
|
|
7307
7317
|
`;
|
|
7308
7318
|
var isValidRef = (ref) => {
|
|
7309
|
-
return typeof ref === "object" && ref !== null && "current" in ref &&
|
|
7319
|
+
return typeof ref === "object" && ref !== null && "current" in ref && isNotNil9(ref.current);
|
|
7310
7320
|
};
|
|
7311
7321
|
var Input = forwardRef11(
|
|
7312
7322
|
({
|
|
@@ -7324,21 +7334,21 @@ var Input = forwardRef11(
|
|
|
7324
7334
|
if (isNil10(leftIcon) && type === "search") {
|
|
7325
7335
|
leftIconToDisplay = /* @__PURE__ */ jsx186(Icon, { type: "search" });
|
|
7326
7336
|
}
|
|
7327
|
-
if (
|
|
7337
|
+
if (isNotNil9(leftIconToDisplay)) {
|
|
7328
7338
|
leftIconToDisplay = cloneElement5(leftIconToDisplay, {
|
|
7329
7339
|
size: "md",
|
|
7330
7340
|
className: "wui-input-left-icon"
|
|
7331
7341
|
});
|
|
7332
7342
|
}
|
|
7333
7343
|
let rightIconToDisplay = rightIcon;
|
|
7334
|
-
if (
|
|
7344
|
+
if (isNotNil9(rightIconToDisplay)) {
|
|
7335
7345
|
rightIconToDisplay = cloneElement5(rightIconToDisplay, {
|
|
7336
7346
|
size: "md",
|
|
7337
7347
|
className: "wui-input-right-icon"
|
|
7338
7348
|
});
|
|
7339
7349
|
}
|
|
7340
7350
|
const handleFocus = (event) => {
|
|
7341
|
-
if (
|
|
7351
|
+
if (isNotNil9(props.onFocus)) {
|
|
7342
7352
|
props.onFocus(event);
|
|
7343
7353
|
}
|
|
7344
7354
|
if (autoSelect && ref && "current" in ref) {
|
|
@@ -7386,7 +7396,7 @@ import {
|
|
|
7386
7396
|
DropdownMenuPortal,
|
|
7387
7397
|
DropdownMenuContent
|
|
7388
7398
|
} from "@radix-ui/react-dropdown-menu";
|
|
7389
|
-
import { isNotNil as
|
|
7399
|
+
import { isNotNil as isNotNil10, isNotUndefined as isNotUndefined7 } from "@wistia/type-guards";
|
|
7390
7400
|
import { jsx as jsx187, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
7391
7401
|
var open = keyframes`
|
|
7392
7402
|
from {
|
|
@@ -7487,7 +7497,7 @@ var Menu = ({
|
|
|
7487
7497
|
...props
|
|
7488
7498
|
}) => {
|
|
7489
7499
|
let controlProps = {
|
|
7490
|
-
...
|
|
7500
|
+
...isNotNil10(onOpenChange) && isNotNil10(isOpen) ? { open: isOpen, onOpenChange } : {}
|
|
7491
7501
|
};
|
|
7492
7502
|
if (disabled) {
|
|
7493
7503
|
controlProps = {
|
|
@@ -7569,12 +7579,12 @@ import {
|
|
|
7569
7579
|
DropdownMenuSubTrigger,
|
|
7570
7580
|
DropdownMenuItem
|
|
7571
7581
|
} from "@radix-ui/react-dropdown-menu";
|
|
7572
|
-
import { isNotNil as
|
|
7582
|
+
import { isNotNil as isNotNil12 } from "@wistia/type-guards";
|
|
7573
7583
|
|
|
7574
7584
|
// src/components/Menu/MenuItemButton.tsx
|
|
7575
7585
|
import { forwardRef as forwardRef12 } from "react";
|
|
7576
7586
|
import styled28 from "styled-components";
|
|
7577
|
-
import { isNotNil as
|
|
7587
|
+
import { isNotNil as isNotNil11, isNotUndefined as isNotUndefined8 } from "@wistia/type-guards";
|
|
7578
7588
|
import { jsx as jsx189, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7579
7589
|
var StyledButton3 = styled28(Button)`
|
|
7580
7590
|
${({ colorScheme }) => getColorScheme(colorScheme)};
|
|
@@ -7677,7 +7687,7 @@ var MenuItemButton = forwardRef12(({ children, appearance, command, icon, ...pro
|
|
|
7677
7687
|
children: [
|
|
7678
7688
|
props.leftIcon ? /* @__PURE__ */ jsx189(StyledLeftIconContainer, { children: props.leftIcon }) : null,
|
|
7679
7689
|
/* @__PURE__ */ jsx189(StyledLabelAndDescriptionContainer, { children }),
|
|
7680
|
-
|
|
7690
|
+
isNotNil11(badge) || isNotNil11(command) ? /* @__PURE__ */ jsx189(StyledBadgeContainer, { children: badge ?? command }) : null,
|
|
7681
7691
|
props.rightIcon ? /* @__PURE__ */ jsx189(StyledRightIconContainer, { children: props.rightIcon }) : null
|
|
7682
7692
|
]
|
|
7683
7693
|
}
|
|
@@ -7744,7 +7754,7 @@ var SubMenu = ({
|
|
|
7744
7754
|
return isSmAndUp ? /* @__PURE__ */ jsxs16(DropdownMenuSub, { onOpenChange, children: [
|
|
7745
7755
|
/* @__PURE__ */ jsxs16(SubMenuTrigger, { ...props, children: [
|
|
7746
7756
|
/* @__PURE__ */ jsx191(MenuItemLabel, { children: label }),
|
|
7747
|
-
|
|
7757
|
+
isNotNil12(description) ? /* @__PURE__ */ jsx191(MenuItemDescription, { children: description }) : null
|
|
7748
7758
|
] }),
|
|
7749
7759
|
/* @__PURE__ */ jsx191(DropdownMenuPortal2, { children: /* @__PURE__ */ jsx191(SubMenuContent, { children }) })
|
|
7750
7760
|
] }) : /* @__PURE__ */ jsxs16(DropdownMenuGroup, { children: [
|
|
@@ -7931,7 +7941,7 @@ CheckboxMenuItem.displayName = "CheckboxMenuItem";
|
|
|
7931
7941
|
import { forwardRef as forwardRef16 } from "react";
|
|
7932
7942
|
import styled36 from "styled-components";
|
|
7933
7943
|
import { Root as DialogRoot, Portal as DialogPortal } from "@radix-ui/react-dialog";
|
|
7934
|
-
import { isNotNil as
|
|
7944
|
+
import { isNotNil as isNotNil15 } from "@wistia/type-guards";
|
|
7935
7945
|
|
|
7936
7946
|
// src/components/Modal/ModalHeader.tsx
|
|
7937
7947
|
import styled33 from "styled-components";
|
|
@@ -7958,7 +7968,7 @@ var ModalCloseButton = () => {
|
|
|
7958
7968
|
|
|
7959
7969
|
// src/components/ScreenReaderOnly/ScreenReaderOnly.tsx
|
|
7960
7970
|
import styled32 from "styled-components";
|
|
7961
|
-
import { isNotNil as
|
|
7971
|
+
import { isNotNil as isNotNil13 } from "@wistia/type-guards";
|
|
7962
7972
|
import { jsx as jsx197 } from "react/jsx-runtime";
|
|
7963
7973
|
var VisuallyHidden = styled32.div({ ...visuallyHiddenStyle });
|
|
7964
7974
|
var VisuallyHiddenButFocusable = styled32.div({
|
|
@@ -7970,7 +7980,7 @@ var ScreenReaderOnly = ({
|
|
|
7970
7980
|
focusable = false,
|
|
7971
7981
|
...otherProps
|
|
7972
7982
|
}) => {
|
|
7973
|
-
const accessibleText =
|
|
7983
|
+
const accessibleText = isNotNil13(text) ? text : children;
|
|
7974
7984
|
if (focusable) {
|
|
7975
7985
|
return /* @__PURE__ */ jsx197(VisuallyHiddenButFocusable, { ...otherProps, children: accessibleText });
|
|
7976
7986
|
}
|
|
@@ -8016,16 +8026,16 @@ import styled34 from "styled-components";
|
|
|
8016
8026
|
import { Content as DialogContent } from "@radix-ui/react-dialog";
|
|
8017
8027
|
|
|
8018
8028
|
// src/private/hooks/useFocusRestore/useFocusRestore.ts
|
|
8019
|
-
import { useRef as useRef7, useEffect as
|
|
8020
|
-
import { isNotNil as
|
|
8029
|
+
import { useRef as useRef7, useEffect as useEffect4 } from "react";
|
|
8030
|
+
import { isNotNil as isNotNil14 } from "@wistia/type-guards";
|
|
8021
8031
|
var useFocusRestore = () => {
|
|
8022
8032
|
const previouslyFocusedRef = useRef7(null);
|
|
8023
|
-
|
|
8033
|
+
useEffect4(() => {
|
|
8024
8034
|
previouslyFocusedRef.current = document.activeElement;
|
|
8025
8035
|
}, []);
|
|
8026
|
-
|
|
8036
|
+
useEffect4(() => {
|
|
8027
8037
|
return () => {
|
|
8028
|
-
if (
|
|
8038
|
+
if (isNotNil14(previouslyFocusedRef.current)) {
|
|
8029
8039
|
setTimeout(() => {
|
|
8030
8040
|
previouslyFocusedRef.current?.focus();
|
|
8031
8041
|
}, 0);
|
|
@@ -8169,7 +8179,7 @@ var Modal = forwardRef16(
|
|
|
8169
8179
|
DialogRoot,
|
|
8170
8180
|
{
|
|
8171
8181
|
onOpenChange: (open2) => {
|
|
8172
|
-
if (!open2 &&
|
|
8182
|
+
if (!open2 && isNotNil15(onRequestClose)) {
|
|
8173
8183
|
onRequestClose();
|
|
8174
8184
|
}
|
|
8175
8185
|
},
|
|
@@ -8183,7 +8193,7 @@ var Modal = forwardRef16(
|
|
|
8183
8193
|
"aria-describedby": void 0,
|
|
8184
8194
|
fullHeight,
|
|
8185
8195
|
onOpenAutoFocus: (event) => {
|
|
8186
|
-
if (
|
|
8196
|
+
if (isNotNil15(initialFocusRef) && initialFocusRef.current) {
|
|
8187
8197
|
event.preventDefault();
|
|
8188
8198
|
requestAnimationFrame(() => {
|
|
8189
8199
|
initialFocusRef.current?.focus();
|
|
@@ -8345,7 +8355,7 @@ Radio.displayName = "Radio";
|
|
|
8345
8355
|
// src/components/Tag/Tag.tsx
|
|
8346
8356
|
import { forwardRef as forwardRef18 } from "react";
|
|
8347
8357
|
import styled38 from "styled-components";
|
|
8348
|
-
import { isNil as isNil11, isNotNil as
|
|
8358
|
+
import { isNil as isNil11, isNotNil as isNotNil16, isNonEmptyString as isNonEmptyString4 } from "@wistia/type-guards";
|
|
8349
8359
|
import { Fragment as Fragment3, jsx as jsx203, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
8350
8360
|
var TagLabel = styled38.a`
|
|
8351
8361
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
@@ -8451,7 +8461,7 @@ var RemoveButton = ({ onClickRemove, onClickRemoveLabel, colorScheme }) => {
|
|
|
8451
8461
|
};
|
|
8452
8462
|
var Tag = forwardRef18(
|
|
8453
8463
|
({ onClickRemove, colorScheme = "inherit", href, label, onClickRemoveLabel, ...otherProps }, ref) => {
|
|
8454
|
-
const labelProps =
|
|
8464
|
+
const labelProps = isNotNil16(href) && isNonEmptyString4(href) ? { href, as: "a" } : { as: "span" };
|
|
8455
8465
|
return /* @__PURE__ */ jsxs22(
|
|
8456
8466
|
StyledTag,
|
|
8457
8467
|
{
|
|
@@ -8595,7 +8605,7 @@ Tooltip.displayName = "Tooltip";
|
|
|
8595
8605
|
|
|
8596
8606
|
// src/components/WistiaLogo/WistiaLogo.tsx
|
|
8597
8607
|
import styled40 from "styled-components";
|
|
8598
|
-
import { isNotNil as
|
|
8608
|
+
import { isNotNil as isNotNil17 } from "@wistia/type-guards";
|
|
8599
8609
|
import { jsx as jsx205, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
8600
8610
|
var renderBrandmark = (brandmarkColor, iconOnly) => {
|
|
8601
8611
|
if (iconOnly) {
|
|
@@ -8689,7 +8699,7 @@ var WistiaLogo = ({
|
|
|
8689
8699
|
...otherProps,
|
|
8690
8700
|
children: [
|
|
8691
8701
|
/* @__PURE__ */ jsx205("title", { children: title }),
|
|
8692
|
-
|
|
8702
|
+
isNotNil17(description) ? /* @__PURE__ */ jsx205("desc", { children: description }) : null,
|
|
8693
8703
|
renderBrandmark(brandmarkColor, iconOnly),
|
|
8694
8704
|
renderLogotype(logotypeColor, iconOnly)
|
|
8695
8705
|
]
|