@wistia/ui 0.5.0-beta.4e01027d.1af5149 → 0.5.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/dist/index.cjs +106 -498
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -32
- package/dist/index.d.ts +1 -32
- package/dist/index.mjs +28 -419
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.5.0
|
|
3
|
+
* @license @wistia/ui v0.5.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1461,396 +1461,6 @@ var copyToClipboard = async (textToCopy) => {
|
|
|
1461
1461
|
});
|
|
1462
1462
|
};
|
|
1463
1463
|
|
|
1464
|
-
// src/helpers/dateTime/constants.ts
|
|
1465
|
-
var defaultLocales = ["en-US"];
|
|
1466
|
-
var defaultTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
1467
|
-
var secondsInMinute = 60;
|
|
1468
|
-
var minutesInHour = 60;
|
|
1469
|
-
var halfAnHourInMinutes = 30;
|
|
1470
|
-
var hoursInDay = 24;
|
|
1471
|
-
var milisecondsInSecond = 1e3;
|
|
1472
|
-
var millisecondsInDay = hoursInDay * minutesInHour * secondsInMinute * milisecondsInSecond;
|
|
1473
|
-
|
|
1474
|
-
// src/helpers/dateTime/buildTimeDuration.ts
|
|
1475
|
-
var buildTimeDuration = (numberOfMilliseconds) => {
|
|
1476
|
-
const numberOfSeconds = Math.floor(numberOfMilliseconds / milisecondsInSecond);
|
|
1477
|
-
const numberOfMinutes = Math.floor(numberOfSeconds / secondsInMinute);
|
|
1478
|
-
const numberOfHours = Math.floor(numberOfMinutes / minutesInHour);
|
|
1479
|
-
const seconds = numberOfSeconds - numberOfMinutes * secondsInMinute;
|
|
1480
|
-
const minutes = numberOfMinutes - numberOfHours * minutesInHour;
|
|
1481
|
-
return { seconds, minutes, hours: numberOfHours };
|
|
1482
|
-
};
|
|
1483
|
-
|
|
1484
|
-
// src/helpers/dateTime/isDate.ts
|
|
1485
|
-
var isDate = (date) => date instanceof Date;
|
|
1486
|
-
|
|
1487
|
-
// src/helpers/dateTime/isInvalidDate.ts
|
|
1488
|
-
var isInvalidDate = (date) => {
|
|
1489
|
-
if (!isDate(date)) {
|
|
1490
|
-
return true;
|
|
1491
|
-
}
|
|
1492
|
-
const time = date.getTime();
|
|
1493
|
-
return time === 0 || Number.isNaN(time);
|
|
1494
|
-
};
|
|
1495
|
-
|
|
1496
|
-
// src/helpers/dateTime/dateOnlyISOString.ts
|
|
1497
|
-
var dateOnlyISOString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1498
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1499
|
-
return "";
|
|
1500
|
-
}
|
|
1501
|
-
try {
|
|
1502
|
-
const formatter = new Intl.DateTimeFormat(defaultLocales, {
|
|
1503
|
-
year: "numeric",
|
|
1504
|
-
month: "2-digit",
|
|
1505
|
-
day: "2-digit",
|
|
1506
|
-
timeZone
|
|
1507
|
-
});
|
|
1508
|
-
const parts = formatter.formatToParts(date);
|
|
1509
|
-
const partsAsObject = parts.reduce(
|
|
1510
|
-
(map, obj) => {
|
|
1511
|
-
map[obj.type] = obj.value;
|
|
1512
|
-
return map;
|
|
1513
|
-
},
|
|
1514
|
-
{}
|
|
1515
|
-
);
|
|
1516
|
-
return `${partsAsObject.year}-${partsAsObject.month}-${partsAsObject.day}`;
|
|
1517
|
-
} catch (error) {
|
|
1518
|
-
console.error(error);
|
|
1519
|
-
return "";
|
|
1520
|
-
}
|
|
1521
|
-
};
|
|
1522
|
-
|
|
1523
|
-
// src/helpers/dateTime/dateOnlyString.ts
|
|
1524
|
-
var dateOnlyString = (date, { timeZone = defaultTimeZone, omitYear = false } = {}) => {
|
|
1525
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1526
|
-
return "";
|
|
1527
|
-
}
|
|
1528
|
-
const formatOptions = omitYear ? { month: "short", day: "numeric", timeZone } : { dateStyle: "medium", timeZone };
|
|
1529
|
-
try {
|
|
1530
|
-
return new Intl.DateTimeFormat(defaultLocales, formatOptions).format(date);
|
|
1531
|
-
} catch (error) {
|
|
1532
|
-
console.error(error);
|
|
1533
|
-
return "";
|
|
1534
|
-
}
|
|
1535
|
-
};
|
|
1536
|
-
|
|
1537
|
-
// src/helpers/dateTime/dateOnlyStringForSentence.ts
|
|
1538
|
-
var dateOnlyStringForSentence = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1539
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1540
|
-
return "";
|
|
1541
|
-
}
|
|
1542
|
-
try {
|
|
1543
|
-
return new Intl.DateTimeFormat(defaultLocales, {
|
|
1544
|
-
dateStyle: "long",
|
|
1545
|
-
timeZone
|
|
1546
|
-
}).format(date);
|
|
1547
|
-
} catch (error) {
|
|
1548
|
-
console.error(error);
|
|
1549
|
-
return "";
|
|
1550
|
-
}
|
|
1551
|
-
};
|
|
1552
|
-
|
|
1553
|
-
// src/helpers/dateTime/dateOnlyStringNumeric.ts
|
|
1554
|
-
var dateOnlyStringNumeric = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1555
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1556
|
-
return "";
|
|
1557
|
-
}
|
|
1558
|
-
try {
|
|
1559
|
-
return new Intl.DateTimeFormat(defaultLocales, {
|
|
1560
|
-
year: "numeric",
|
|
1561
|
-
month: "2-digit",
|
|
1562
|
-
day: "2-digit",
|
|
1563
|
-
timeZone
|
|
1564
|
-
}).format(date);
|
|
1565
|
-
} catch (error) {
|
|
1566
|
-
console.error(error);
|
|
1567
|
-
return "";
|
|
1568
|
-
}
|
|
1569
|
-
};
|
|
1570
|
-
|
|
1571
|
-
// src/helpers/dateTime/dateTimeToDate.ts
|
|
1572
|
-
var dateTimeToDate = (dateTime2) => {
|
|
1573
|
-
const { year, month, dayOfMonth, hours, minutes } = dateTime2 ?? {};
|
|
1574
|
-
if (year !== void 0 && month !== void 0 && dayOfMonth !== void 0) {
|
|
1575
|
-
return new Date(year, month, dayOfMonth, hours ?? 0, minutes ?? 0);
|
|
1576
|
-
}
|
|
1577
|
-
return null;
|
|
1578
|
-
};
|
|
1579
|
-
|
|
1580
|
-
// src/helpers/dateTime/dateToDateTime.ts
|
|
1581
|
-
var dateToDateTime = (date) => {
|
|
1582
|
-
if (!isDate(date)) {
|
|
1583
|
-
return null;
|
|
1584
|
-
}
|
|
1585
|
-
return {
|
|
1586
|
-
year: date.getFullYear(),
|
|
1587
|
-
month: date.getMonth(),
|
|
1588
|
-
dayOfMonth: date.getDate(),
|
|
1589
|
-
hours: date.getHours(),
|
|
1590
|
-
minutes: date.getMinutes()
|
|
1591
|
-
};
|
|
1592
|
-
};
|
|
1593
|
-
|
|
1594
|
-
// src/helpers/dateTime/dateTimeToISO.ts
|
|
1595
|
-
var dateTimeToISO = (dateTime2) => dateTimeToDate(dateTime2)?.toISOString() ?? null;
|
|
1596
|
-
|
|
1597
|
-
// src/helpers/dateTime/dateTimeRounded.ts
|
|
1598
|
-
var dateTimeRounded = (dateTime2, toISOString = true) => {
|
|
1599
|
-
const first30Min = dateTime2.getMinutes() <= halfAnHourInMinutes;
|
|
1600
|
-
const hours = first30Min ? dateTime2.getHours() : dateTime2.getHours() + 1;
|
|
1601
|
-
const minutes = first30Min ? halfAnHourInMinutes : 0;
|
|
1602
|
-
const dateWithTime = {
|
|
1603
|
-
...dateToDateTime(dateTime2),
|
|
1604
|
-
hours,
|
|
1605
|
-
minutes
|
|
1606
|
-
};
|
|
1607
|
-
if (toISOString) {
|
|
1608
|
-
return dateTimeToISO(dateWithTime);
|
|
1609
|
-
}
|
|
1610
|
-
return dateTimeToDate(dateWithTime);
|
|
1611
|
-
};
|
|
1612
|
-
|
|
1613
|
-
// src/helpers/dateTime/dateTimeString.ts
|
|
1614
|
-
import { isNil as isNil2 } from "@wistia/type-guards";
|
|
1615
|
-
var dateTimeString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1616
|
-
if (isNil2(date)) {
|
|
1617
|
-
return "";
|
|
1618
|
-
}
|
|
1619
|
-
const formattedDate = new Date(date);
|
|
1620
|
-
if (isInvalidDate(formattedDate)) {
|
|
1621
|
-
return "";
|
|
1622
|
-
}
|
|
1623
|
-
try {
|
|
1624
|
-
return new Intl.DateTimeFormat(defaultLocales, {
|
|
1625
|
-
dateStyle: "medium",
|
|
1626
|
-
timeStyle: "short",
|
|
1627
|
-
timeZone
|
|
1628
|
-
}).format(formattedDate);
|
|
1629
|
-
} catch (error) {
|
|
1630
|
-
console.error(error);
|
|
1631
|
-
return "";
|
|
1632
|
-
}
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
// src/helpers/dateTime/dateTimeStringForSentence.ts
|
|
1636
|
-
var dateTimeStringForSentence = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1637
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1638
|
-
return "";
|
|
1639
|
-
}
|
|
1640
|
-
try {
|
|
1641
|
-
const { year, month, day, hour, minute, dayPeriod } = new Intl.DateTimeFormat(defaultLocales, {
|
|
1642
|
-
month: "long",
|
|
1643
|
-
day: "numeric",
|
|
1644
|
-
year: "numeric",
|
|
1645
|
-
hour: "numeric",
|
|
1646
|
-
minute: "2-digit",
|
|
1647
|
-
timeZone
|
|
1648
|
-
}).formatToParts(date).reduce((acc, part) => {
|
|
1649
|
-
if (part.type !== "literal") {
|
|
1650
|
-
acc[part.type] = part.value;
|
|
1651
|
-
}
|
|
1652
|
-
return acc;
|
|
1653
|
-
}, {});
|
|
1654
|
-
return `${month} ${day}, ${year}, ${hour}:${minute} ${dayPeriod}`;
|
|
1655
|
-
} catch (error) {
|
|
1656
|
-
console.error(error);
|
|
1657
|
-
return "";
|
|
1658
|
-
}
|
|
1659
|
-
};
|
|
1660
|
-
|
|
1661
|
-
// src/helpers/dateTime/dateUTCOffset.ts
|
|
1662
|
-
var dateUTCOffset = (date) => {
|
|
1663
|
-
const offsetInHours = date.getTimezoneOffset() / minutesInHour * -1;
|
|
1664
|
-
const hours = Math.round(offsetInHours);
|
|
1665
|
-
const minutes = (offsetInHours - hours) * minutesInHour;
|
|
1666
|
-
const prefix = hours >= 0 ? "+" : "";
|
|
1667
|
-
const hoursString = `${hours}`.padStart(2, "0");
|
|
1668
|
-
const minutesString = `${minutes}`.padStart(2, "0");
|
|
1669
|
-
return `${prefix}${hoursString}:${minutesString}`;
|
|
1670
|
-
};
|
|
1671
|
-
|
|
1672
|
-
// src/helpers/dateTime/dayOfWeekString.ts
|
|
1673
|
-
var dayOfWeekString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1674
|
-
if (date === null) {
|
|
1675
|
-
return "";
|
|
1676
|
-
}
|
|
1677
|
-
try {
|
|
1678
|
-
return new Intl.DateTimeFormat(defaultLocales, {
|
|
1679
|
-
weekday: "long",
|
|
1680
|
-
timeZone
|
|
1681
|
-
}).format(date);
|
|
1682
|
-
} catch (error) {
|
|
1683
|
-
console.error(error);
|
|
1684
|
-
return "";
|
|
1685
|
-
}
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
// src/helpers/dateTime/padTimeInteger.ts
|
|
1689
|
-
var padTimeInteger = (num) => num.toString().padStart(2, "0");
|
|
1690
|
-
|
|
1691
|
-
// src/helpers/dateTime/mediaDurationString.ts
|
|
1692
|
-
var mediaDurationString = (numberOfMilliseconds) => {
|
|
1693
|
-
const { hours, minutes, seconds } = buildTimeDuration(numberOfMilliseconds);
|
|
1694
|
-
if (hours < 1) {
|
|
1695
|
-
return `${minutes}:${padTimeInteger(seconds)}`;
|
|
1696
|
-
}
|
|
1697
|
-
return `${hours}:${padTimeInteger(minutes)}:${padTimeInteger(seconds)}`;
|
|
1698
|
-
};
|
|
1699
|
-
|
|
1700
|
-
// src/helpers/dateTime/millisecondsToDurationISOString.ts
|
|
1701
|
-
var millisecondsToDurationISOString = (numberOfMilliseconds) => {
|
|
1702
|
-
const { seconds, minutes, hours } = buildTimeDuration(numberOfMilliseconds);
|
|
1703
|
-
let string = "PT";
|
|
1704
|
-
if (hours) {
|
|
1705
|
-
string += `${hours}H`;
|
|
1706
|
-
}
|
|
1707
|
-
if (minutes) {
|
|
1708
|
-
string += `${minutes}M`;
|
|
1709
|
-
}
|
|
1710
|
-
if (seconds) {
|
|
1711
|
-
string += `${seconds}S`;
|
|
1712
|
-
}
|
|
1713
|
-
if (!(seconds || minutes || hours)) {
|
|
1714
|
-
string += "0S";
|
|
1715
|
-
}
|
|
1716
|
-
return string;
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
|
-
// src/helpers/dateTime/monthDayStringNumeric.ts
|
|
1720
|
-
var monthDayStringNumeric = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1721
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1722
|
-
return "";
|
|
1723
|
-
}
|
|
1724
|
-
try {
|
|
1725
|
-
return new Intl.DateTimeFormat(defaultLocales, {
|
|
1726
|
-
month: "2-digit",
|
|
1727
|
-
day: "2-digit",
|
|
1728
|
-
timeZone
|
|
1729
|
-
}).format(date);
|
|
1730
|
-
} catch (error) {
|
|
1731
|
-
console.error(error);
|
|
1732
|
-
return "";
|
|
1733
|
-
}
|
|
1734
|
-
};
|
|
1735
|
-
|
|
1736
|
-
// src/helpers/dateTime/sessionDurationString.ts
|
|
1737
|
-
var sessionDurationString = (numberOfMilliseconds) => {
|
|
1738
|
-
const { hours, minutes, seconds } = buildTimeDuration(numberOfMilliseconds);
|
|
1739
|
-
return `${hours}:${padTimeInteger(minutes)}:${padTimeInteger(seconds)}`;
|
|
1740
|
-
};
|
|
1741
|
-
|
|
1742
|
-
// src/helpers/dateTime/getLocalDateParts.ts
|
|
1743
|
-
import { isNil as isNil3 } from "@wistia/type-guards";
|
|
1744
|
-
var getLocalDateParts = (date) => {
|
|
1745
|
-
const parts = new Intl.DateTimeFormat(defaultLocales, {
|
|
1746
|
-
year: "numeric",
|
|
1747
|
-
month: "numeric",
|
|
1748
|
-
day: "numeric",
|
|
1749
|
-
timeZone: defaultTimeZone
|
|
1750
|
-
}).formatToParts(date);
|
|
1751
|
-
const yearPart = parts.find((part) => part.type === "year");
|
|
1752
|
-
const monthPart = parts.find((part) => part.type === "month");
|
|
1753
|
-
const dayPart = parts.find((part) => part.type === "day");
|
|
1754
|
-
if (isNil3(yearPart) || isNil3(monthPart) || isNil3(dayPart)) {
|
|
1755
|
-
throw new Error("Failed to parse date parts");
|
|
1756
|
-
}
|
|
1757
|
-
const year = parseInt(yearPart.value, 10);
|
|
1758
|
-
const month = parseInt(monthPart.value, 10);
|
|
1759
|
-
const day = parseInt(dayPart.value, 10);
|
|
1760
|
-
return { year, month, day };
|
|
1761
|
-
};
|
|
1762
|
-
|
|
1763
|
-
// src/helpers/dateTime/differenceInCalendarDays.ts
|
|
1764
|
-
var differenceInCalendarDays = (dateLeft, dateRight) => {
|
|
1765
|
-
const leftDate = isDate(dateLeft) ? dateLeft : new Date(dateLeft);
|
|
1766
|
-
const rightDate = isDate(dateRight) ? dateRight : new Date(dateRight);
|
|
1767
|
-
if (Number.isNaN(leftDate.getTime()) || Number.isNaN(rightDate.getTime())) {
|
|
1768
|
-
return NaN;
|
|
1769
|
-
}
|
|
1770
|
-
const { year: y1, month: m1, day: d1 } = getLocalDateParts(leftDate);
|
|
1771
|
-
const { year: y2, month: m2, day: d2 } = getLocalDateParts(rightDate);
|
|
1772
|
-
const startOfDayLeft = new Date(y1, m1 - 1, d1).getTime();
|
|
1773
|
-
const startOfDayRight = new Date(y2, m2 - 1, d2).getTime();
|
|
1774
|
-
const msDiff = startOfDayLeft - startOfDayRight;
|
|
1775
|
-
return Math.round(msDiff / millisecondsInDay);
|
|
1776
|
-
};
|
|
1777
|
-
|
|
1778
|
-
// src/helpers/dateTime/timeAgoString.ts
|
|
1779
|
-
var timeAgoString = (date, { nowAnchor = /* @__PURE__ */ new Date() } = {}) => {
|
|
1780
|
-
if (isInvalidDate(date)) {
|
|
1781
|
-
return "";
|
|
1782
|
-
}
|
|
1783
|
-
const minutesAgo = (nowAnchor.valueOf() - date.valueOf()) / (secondsInMinute * milisecondsInSecond);
|
|
1784
|
-
const minutesAgoRounded = Math.round(minutesAgo);
|
|
1785
|
-
const differenceInDays = differenceInCalendarDays(nowAnchor, date);
|
|
1786
|
-
if (minutesAgo < 0) {
|
|
1787
|
-
return dateTimeString(date);
|
|
1788
|
-
}
|
|
1789
|
-
if (minutesAgo < 1) {
|
|
1790
|
-
return "< 1 minute ago";
|
|
1791
|
-
}
|
|
1792
|
-
if (minutesAgoRounded < 2) {
|
|
1793
|
-
return "1 minute ago";
|
|
1794
|
-
}
|
|
1795
|
-
if (minutesAgoRounded <= minutesInHour) {
|
|
1796
|
-
return `${minutesAgoRounded} minutes ago`;
|
|
1797
|
-
}
|
|
1798
|
-
if (differenceInDays === 0) {
|
|
1799
|
-
return `Today, ${Intl.DateTimeFormat(defaultLocales, { timeStyle: "short" }).format(date)}`;
|
|
1800
|
-
}
|
|
1801
|
-
if (differenceInDays === 1) {
|
|
1802
|
-
return `Yesterday, ${Intl.DateTimeFormat(defaultLocales, { timeStyle: "short" }).format(date)}`;
|
|
1803
|
-
}
|
|
1804
|
-
if (date.getFullYear() === nowAnchor.getFullYear()) {
|
|
1805
|
-
return Intl.DateTimeFormat(defaultLocales, {
|
|
1806
|
-
day: "numeric",
|
|
1807
|
-
month: "short",
|
|
1808
|
-
hour: "numeric",
|
|
1809
|
-
minute: "2-digit"
|
|
1810
|
-
}).format(date);
|
|
1811
|
-
}
|
|
1812
|
-
return dateTimeString(date);
|
|
1813
|
-
};
|
|
1814
|
-
|
|
1815
|
-
// src/helpers/dateTime/timeOnlyString.ts
|
|
1816
|
-
var timeOnlyString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
1817
|
-
if (!isDate(date) || isInvalidDate(date)) {
|
|
1818
|
-
return "";
|
|
1819
|
-
}
|
|
1820
|
-
try {
|
|
1821
|
-
return new Intl.DateTimeFormat(defaultLocales, {
|
|
1822
|
-
timeStyle: "short",
|
|
1823
|
-
timeZone
|
|
1824
|
-
}).format(date);
|
|
1825
|
-
} catch (error) {
|
|
1826
|
-
console.error(error);
|
|
1827
|
-
return "";
|
|
1828
|
-
}
|
|
1829
|
-
};
|
|
1830
|
-
|
|
1831
|
-
// src/helpers/dateTime/index.ts
|
|
1832
|
-
var dateTime = {
|
|
1833
|
-
buildTimeDuration,
|
|
1834
|
-
dateOnlyISOString,
|
|
1835
|
-
dateOnlyString,
|
|
1836
|
-
dateOnlyStringForSentence,
|
|
1837
|
-
dateOnlyStringNumeric,
|
|
1838
|
-
dateTimeRounded,
|
|
1839
|
-
dateTimeString,
|
|
1840
|
-
dateTimeStringForSentence,
|
|
1841
|
-
dateTimeToDate,
|
|
1842
|
-
dateTimeToISO,
|
|
1843
|
-
dateToDateTime,
|
|
1844
|
-
dateUTCOffset,
|
|
1845
|
-
dayOfWeekString,
|
|
1846
|
-
mediaDurationString,
|
|
1847
|
-
millisecondsToDurationISOString,
|
|
1848
|
-
monthDayStringNumeric,
|
|
1849
|
-
sessionDurationString,
|
|
1850
|
-
timeAgoString,
|
|
1851
|
-
timeOnlyString
|
|
1852
|
-
};
|
|
1853
|
-
|
|
1854
1464
|
// src/helpers/mq/mq.ts
|
|
1855
1465
|
import { getValueAndUnit } from "polished";
|
|
1856
1466
|
|
|
@@ -2048,10 +1658,10 @@ var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOpti
|
|
|
2048
1658
|
|
|
2049
1659
|
// src/hooks/useAriaLive/useAriaLive.tsx
|
|
2050
1660
|
import { useContext } from "react";
|
|
2051
|
-
import { isNil as
|
|
1661
|
+
import { isNil as isNil2 } from "@wistia/type-guards";
|
|
2052
1662
|
var useAriaLive = () => {
|
|
2053
1663
|
const context = useContext(AriaLiveContext);
|
|
2054
|
-
if (
|
|
1664
|
+
if (isNil2(context)) {
|
|
2055
1665
|
throw new Error("useAriaLive must be used within an AriaLiveProvider");
|
|
2056
1666
|
}
|
|
2057
1667
|
return context;
|
|
@@ -2550,7 +2160,7 @@ var buttonSizeStyles = {
|
|
|
2550
2160
|
};
|
|
2551
2161
|
|
|
2552
2162
|
// src/components/Icon/Icon.tsx
|
|
2553
|
-
import { isNil as
|
|
2163
|
+
import { isNil as isNil3 } from "@wistia/type-guards";
|
|
2554
2164
|
import styled3 from "styled-components";
|
|
2555
2165
|
|
|
2556
2166
|
// src/components/Icon/icons/AbTestIcon.tsx
|
|
@@ -5748,13 +5358,13 @@ var Icon = ({
|
|
|
5748
5358
|
...otherProps
|
|
5749
5359
|
}) => {
|
|
5750
5360
|
const responsiveSize = useResponsiveProp(size);
|
|
5751
|
-
if (
|
|
5361
|
+
if (isNil3(type)) {
|
|
5752
5362
|
throw new Error("An Icon component requires a `type` prop to be provided");
|
|
5753
5363
|
}
|
|
5754
|
-
if (
|
|
5364
|
+
if (isNil3(iconMap[type])) {
|
|
5755
5365
|
throw new Error(`Type "${type}" does not exist, please update type prop in Icon component.`);
|
|
5756
5366
|
}
|
|
5757
|
-
if (
|
|
5367
|
+
if (isNil3(iconSizeMap[responsiveSize])) {
|
|
5758
5368
|
throw new Error(
|
|
5759
5369
|
`Size "${responsiveSize}" does not exist, please update size prop in Icon component.`
|
|
5760
5370
|
);
|
|
@@ -5786,12 +5396,12 @@ Icon.displayName = "Icon";
|
|
|
5786
5396
|
|
|
5787
5397
|
// src/components/Link/Link.tsx
|
|
5788
5398
|
import { forwardRef } from "react";
|
|
5789
|
-
import { isNil as
|
|
5399
|
+
import { isNil as isNil4, isNotNil as isNotNil4, isNotUndefined as isNotUndefined2, isUndefined as isUndefined2 } from "@wistia/type-guards";
|
|
5790
5400
|
import styled4 from "styled-components";
|
|
5791
5401
|
import { Link as RouterLink, useInRouterContext } from "react-router-dom";
|
|
5792
5402
|
import { jsx as jsx161, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
5793
5403
|
var generateHref = (href, type, disabled) => {
|
|
5794
|
-
if (disabled ||
|
|
5404
|
+
if (disabled || isNil4(href)) {
|
|
5795
5405
|
return void 0;
|
|
5796
5406
|
}
|
|
5797
5407
|
let to = href;
|
|
@@ -5808,7 +5418,7 @@ var isLink = (props) => isNotUndefined2(props.href);
|
|
|
5808
5418
|
var StyledLink = styled4.a`
|
|
5809
5419
|
--link-icon-size: 14px;
|
|
5810
5420
|
|
|
5811
|
-
${({ href }) =>
|
|
5421
|
+
${({ href }) => isNil4(href) && buttonResetCss};
|
|
5812
5422
|
${({ $colorScheme }) => getColorScheme($colorScheme)}
|
|
5813
5423
|
cursor: pointer;
|
|
5814
5424
|
font-family: var(--wui-typography-family-default);
|
|
@@ -6186,7 +5796,7 @@ ActionButton.displayName = "ActionButton";
|
|
|
6186
5796
|
|
|
6187
5797
|
// src/components/Avatar/Avatar.tsx
|
|
6188
5798
|
import { useState as useState4, useMemo as useMemo3, useEffect as useEffect3 } from "react";
|
|
6189
|
-
import { isNil as
|
|
5799
|
+
import { isNil as isNil6 } from "@wistia/type-guards";
|
|
6190
5800
|
import styled8 from "styled-components";
|
|
6191
5801
|
|
|
6192
5802
|
// src/components/ColorSchemeWrapper/ColorSchemeWrapper.tsx
|
|
@@ -6229,13 +5839,13 @@ var ColorSchemeWrapper = ({
|
|
|
6229
5839
|
ColorSchemeWrapper.displayName = "ColorSchemeWrapper";
|
|
6230
5840
|
|
|
6231
5841
|
// src/components/Avatar/formatNameForDisplay.tsx
|
|
6232
|
-
import { isNil as
|
|
5842
|
+
import { isNil as isNil5, isString, isEmptyString } from "@wistia/type-guards";
|
|
6233
5843
|
var containsEmojiCharacter = (char) => {
|
|
6234
5844
|
const emojiRegex = /<a?:.+?:\d{18}>|\p{Extended_Pictographic}/gu;
|
|
6235
5845
|
return emojiRegex.test(char);
|
|
6236
5846
|
};
|
|
6237
5847
|
var formatNameForDisplay = (name) => {
|
|
6238
|
-
if (
|
|
5848
|
+
if (isNil5(name) || !isString(name) || isEmptyString(name) || containsEmojiCharacter(name)) {
|
|
6239
5849
|
return "U";
|
|
6240
5850
|
}
|
|
6241
5851
|
const firstChar = name.trim().substring(0, 1);
|
|
@@ -6298,7 +5908,7 @@ var AvatarWrapper = styled8.div`
|
|
|
6298
5908
|
max-height: ${({ $maxHeight }) => $maxHeight}px;
|
|
6299
5909
|
`;
|
|
6300
5910
|
var chooseColorScheme = (name) => {
|
|
6301
|
-
if (
|
|
5911
|
+
if (isNil6(name) || name === "Anonymous") {
|
|
6302
5912
|
return "default";
|
|
6303
5913
|
}
|
|
6304
5914
|
const filteredColors = colorSchemeOptions.filter(
|
|
@@ -6331,7 +5941,7 @@ var Avatar = ({
|
|
|
6331
5941
|
};
|
|
6332
5942
|
const avatarSize = heightAndWidth ?? avatarSizeMap[size];
|
|
6333
5943
|
const avatarColor = useMemo3(() => chooseColorScheme(name), [name]);
|
|
6334
|
-
const showInitials =
|
|
5944
|
+
const showInitials = isNil6(imageUrl) || imageLoadState === "error";
|
|
6335
5945
|
return /* @__PURE__ */ jsx165(
|
|
6336
5946
|
AvatarWrapper,
|
|
6337
5947
|
{
|
|
@@ -6407,7 +6017,7 @@ Badge.displayName = "Badge";
|
|
|
6407
6017
|
// src/components/Box/Box.tsx
|
|
6408
6018
|
import { Children, cloneElement as cloneElement2, forwardRef as forwardRef5 } from "react";
|
|
6409
6019
|
import styled10 from "styled-components";
|
|
6410
|
-
import { isNotNil as isNotNil7, isNil as
|
|
6020
|
+
import { isNotNil as isNotNil7, isNil as isNil7, isRecord as isRecord3 } from "@wistia/type-guards";
|
|
6411
6021
|
|
|
6412
6022
|
// src/private/helpers/makePolymorphic/makePolymorphic.tsx
|
|
6413
6023
|
var makePolymorphic = (component) => {
|
|
@@ -6480,7 +6090,7 @@ var wrapChildren = (children) => {
|
|
|
6480
6090
|
if (isNotNil7(children)) {
|
|
6481
6091
|
if (typeof children === "object" && isDev) {
|
|
6482
6092
|
return Children.map(children, (child) => {
|
|
6483
|
-
if (
|
|
6093
|
+
if (isNil7(child)) return null;
|
|
6484
6094
|
const elementParams = {};
|
|
6485
6095
|
if (child.type?.displayName === "Box" || child.type?.displayName === "Box_UI") {
|
|
6486
6096
|
elementParams.hasBoxParent = true;
|
|
@@ -6627,7 +6237,7 @@ var Breadcrumb = ({ icon, href, children, ...props }) => {
|
|
|
6627
6237
|
|
|
6628
6238
|
// src/components/ButtonGroup/ButtonGroup.tsx
|
|
6629
6239
|
import styled13 from "styled-components";
|
|
6630
|
-
import { isNil as
|
|
6240
|
+
import { isNil as isNil8 } from "@wistia/type-guards";
|
|
6631
6241
|
import { jsx as jsx170 } from "react/jsx-runtime";
|
|
6632
6242
|
var getAlignment = (align) => {
|
|
6633
6243
|
if (align === "center") {
|
|
@@ -6667,7 +6277,7 @@ var ButtonGroup = ({
|
|
|
6667
6277
|
fullWidth = false,
|
|
6668
6278
|
...otherProps
|
|
6669
6279
|
}) => {
|
|
6670
|
-
if (
|
|
6280
|
+
if (isNil8(children)) {
|
|
6671
6281
|
return null;
|
|
6672
6282
|
}
|
|
6673
6283
|
return /* @__PURE__ */ jsx170(
|
|
@@ -6917,7 +6527,7 @@ Label.displayName = "Label";
|
|
|
6917
6527
|
|
|
6918
6528
|
// src/components/Label/LabelDescription.tsx
|
|
6919
6529
|
import styled17 from "styled-components";
|
|
6920
|
-
import { isNil as
|
|
6530
|
+
import { isNil as isNil9 } from "@wistia/type-guards";
|
|
6921
6531
|
import { jsx as jsx174 } from "react/jsx-runtime";
|
|
6922
6532
|
var StyledLabelDescription = styled17.div`
|
|
6923
6533
|
color: var(--wui-color-text-secondary);
|
|
@@ -6929,7 +6539,7 @@ var LabelDescription = ({
|
|
|
6929
6539
|
children,
|
|
6930
6540
|
...props
|
|
6931
6541
|
}) => {
|
|
6932
|
-
if (
|
|
6542
|
+
if (isNil9(children)) {
|
|
6933
6543
|
return null;
|
|
6934
6544
|
}
|
|
6935
6545
|
return /* @__PURE__ */ jsx174(StyledLabelDescription, { ...props, children });
|
|
@@ -7717,7 +7327,7 @@ IconButton.displayName = "IconButton";
|
|
|
7717
7327
|
// src/components/Input/Input.tsx
|
|
7718
7328
|
import { forwardRef as forwardRef12, cloneElement as cloneElement5, useRef as useRef6 } from "react";
|
|
7719
7329
|
import styled26, { css as css21 } from "styled-components";
|
|
7720
|
-
import { isNil as
|
|
7330
|
+
import { isNil as isNil10, isNotNil as isNotNil9 } from "@wistia/type-guards";
|
|
7721
7331
|
import { jsx as jsx186, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7722
7332
|
var inputStyles = css21`
|
|
7723
7333
|
--wui-input-color-bg: var(--wui-color-bg-surface);
|
|
@@ -7820,7 +7430,7 @@ var Input = forwardRef12(
|
|
|
7820
7430
|
const internalRef = useRef6();
|
|
7821
7431
|
const ref = isValidRef(externalRef) ? externalRef : internalRef;
|
|
7822
7432
|
let leftIconToDisplay = leftIcon;
|
|
7823
|
-
if (
|
|
7433
|
+
if (isNil10(leftIcon) && type === "search") {
|
|
7824
7434
|
leftIconToDisplay = /* @__PURE__ */ jsx186(Icon, { type: "search" });
|
|
7825
7435
|
}
|
|
7826
7436
|
if (isNotNil9(leftIconToDisplay)) {
|
|
@@ -8857,7 +8467,7 @@ Radio.displayName = "Radio";
|
|
|
8857
8467
|
import { forwardRef as forwardRef19 } from "react";
|
|
8858
8468
|
import styled39 from "styled-components";
|
|
8859
8469
|
import { Root as ToggleGroupRoot } from "@radix-ui/react-toggle-group";
|
|
8860
|
-
import { isNil as
|
|
8470
|
+
import { isNil as isNil11 } from "@wistia/type-guards";
|
|
8861
8471
|
import { jsx as jsx203 } from "react/jsx-runtime";
|
|
8862
8472
|
var StyledSegmentedControl = styled39(ToggleGroupRoot)`
|
|
8863
8473
|
display: inline-flex;
|
|
@@ -8876,7 +8486,7 @@ var SegmentedControl = forwardRef19(
|
|
|
8876
8486
|
onSelectedValueChange,
|
|
8877
8487
|
...props
|
|
8878
8488
|
}, ref) => {
|
|
8879
|
-
if (
|
|
8489
|
+
if (isNil11(children)) {
|
|
8880
8490
|
return null;
|
|
8881
8491
|
}
|
|
8882
8492
|
return /* @__PURE__ */ jsx203(
|
|
@@ -8987,7 +8597,7 @@ SegmentedControlItem.displayName = "SegmentedControlItem";
|
|
|
8987
8597
|
// src/components/Tag/Tag.tsx
|
|
8988
8598
|
import { forwardRef as forwardRef21 } from "react";
|
|
8989
8599
|
import styled41 from "styled-components";
|
|
8990
|
-
import { isNil as
|
|
8600
|
+
import { isNil as isNil12, isNotNil as isNotNil17, isNonEmptyString as isNonEmptyString4 } from "@wistia/type-guards";
|
|
8991
8601
|
import { Fragment as Fragment4, jsx as jsx204, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
8992
8602
|
var TagLabel = styled41.a`
|
|
8993
8603
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
@@ -9065,10 +8675,10 @@ var StyledTag = styled41.div`
|
|
|
9065
8675
|
}
|
|
9066
8676
|
`;
|
|
9067
8677
|
var RemoveButton = ({ onClickRemove, onClickRemoveLabel, colorScheme }) => {
|
|
9068
|
-
if (
|
|
8678
|
+
if (isNil12(onClickRemove)) {
|
|
9069
8679
|
return null;
|
|
9070
8680
|
}
|
|
9071
|
-
if (
|
|
8681
|
+
if (isNil12(onClickRemoveLabel)) {
|
|
9072
8682
|
throw new Error(
|
|
9073
8683
|
"for accessibility, onClickRemoveLabel must be provided if onClickRemove is provided"
|
|
9074
8684
|
);
|
|
@@ -9761,7 +9371,6 @@ export {
|
|
|
9761
9371
|
WistiaLogo,
|
|
9762
9372
|
colorSchemeOptions,
|
|
9763
9373
|
copyToClipboard,
|
|
9764
|
-
dateTime,
|
|
9765
9374
|
ellipsisFlexParentStyle,
|
|
9766
9375
|
ellipsisStyle,
|
|
9767
9376
|
iconSizeMap,
|