@wistia/ui 0.5.1 → 0.5.2-beta.140d6460.3762ec2
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 +498 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.mjs +419 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
/*
|
|
3
|
-
* @license @wistia/ui v0.5.
|
|
3
|
+
* @license @wistia/ui v0.5.2-beta.140d6460.3762ec2
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2024-2025, Wistia, Inc. and its affiliates.
|
|
6
6
|
*
|
|
@@ -1461,6 +1461,396 @@ 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
|
+
|
|
1464
1854
|
// src/helpers/mq/mq.ts
|
|
1465
1855
|
import { getValueAndUnit } from "polished";
|
|
1466
1856
|
|
|
@@ -1658,10 +2048,10 @@ var useKey = (key, eventHandler, { eventName = "keydown", eventTarget, eventOpti
|
|
|
1658
2048
|
|
|
1659
2049
|
// src/hooks/useAriaLive/useAriaLive.tsx
|
|
1660
2050
|
import { useContext } from "react";
|
|
1661
|
-
import { isNil as
|
|
2051
|
+
import { isNil as isNil4 } from "@wistia/type-guards";
|
|
1662
2052
|
var useAriaLive = () => {
|
|
1663
2053
|
const context = useContext(AriaLiveContext);
|
|
1664
|
-
if (
|
|
2054
|
+
if (isNil4(context)) {
|
|
1665
2055
|
throw new Error("useAriaLive must be used within an AriaLiveProvider");
|
|
1666
2056
|
}
|
|
1667
2057
|
return context;
|
|
@@ -2160,7 +2550,7 @@ var buttonSizeStyles = {
|
|
|
2160
2550
|
};
|
|
2161
2551
|
|
|
2162
2552
|
// src/components/Icon/Icon.tsx
|
|
2163
|
-
import { isNil as
|
|
2553
|
+
import { isNil as isNil5 } from "@wistia/type-guards";
|
|
2164
2554
|
import styled3 from "styled-components";
|
|
2165
2555
|
|
|
2166
2556
|
// src/components/Icon/icons/AbTestIcon.tsx
|
|
@@ -5358,13 +5748,13 @@ var Icon = ({
|
|
|
5358
5748
|
...otherProps
|
|
5359
5749
|
}) => {
|
|
5360
5750
|
const responsiveSize = useResponsiveProp(size);
|
|
5361
|
-
if (
|
|
5751
|
+
if (isNil5(type)) {
|
|
5362
5752
|
throw new Error("An Icon component requires a `type` prop to be provided");
|
|
5363
5753
|
}
|
|
5364
|
-
if (
|
|
5754
|
+
if (isNil5(iconMap[type])) {
|
|
5365
5755
|
throw new Error(`Type "${type}" does not exist, please update type prop in Icon component.`);
|
|
5366
5756
|
}
|
|
5367
|
-
if (
|
|
5757
|
+
if (isNil5(iconSizeMap[responsiveSize])) {
|
|
5368
5758
|
throw new Error(
|
|
5369
5759
|
`Size "${responsiveSize}" does not exist, please update size prop in Icon component.`
|
|
5370
5760
|
);
|
|
@@ -5396,12 +5786,12 @@ Icon.displayName = "Icon";
|
|
|
5396
5786
|
|
|
5397
5787
|
// src/components/Link/Link.tsx
|
|
5398
5788
|
import { forwardRef } from "react";
|
|
5399
|
-
import { isNil as
|
|
5789
|
+
import { isNil as isNil6, isNotNil as isNotNil4, isNotUndefined as isNotUndefined2, isUndefined as isUndefined2 } from "@wistia/type-guards";
|
|
5400
5790
|
import styled4 from "styled-components";
|
|
5401
5791
|
import { Link as RouterLink, useInRouterContext } from "react-router-dom";
|
|
5402
5792
|
import { jsx as jsx161, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
5403
5793
|
var generateHref = (href, type, disabled) => {
|
|
5404
|
-
if (disabled ||
|
|
5794
|
+
if (disabled || isNil6(href)) {
|
|
5405
5795
|
return void 0;
|
|
5406
5796
|
}
|
|
5407
5797
|
let to = href;
|
|
@@ -5418,7 +5808,7 @@ var isLink = (props) => isNotUndefined2(props.href);
|
|
|
5418
5808
|
var StyledLink = styled4.a`
|
|
5419
5809
|
--link-icon-size: 14px;
|
|
5420
5810
|
|
|
5421
|
-
${({ href }) =>
|
|
5811
|
+
${({ href }) => isNil6(href) && buttonResetCss};
|
|
5422
5812
|
${({ $colorScheme }) => getColorScheme($colorScheme)}
|
|
5423
5813
|
cursor: pointer;
|
|
5424
5814
|
font-family: var(--wui-typography-family-default);
|
|
@@ -5796,7 +6186,7 @@ ActionButton.displayName = "ActionButton";
|
|
|
5796
6186
|
|
|
5797
6187
|
// src/components/Avatar/Avatar.tsx
|
|
5798
6188
|
import { useState as useState4, useMemo as useMemo3, useEffect as useEffect3 } from "react";
|
|
5799
|
-
import { isNil as
|
|
6189
|
+
import { isNil as isNil8 } from "@wistia/type-guards";
|
|
5800
6190
|
import styled8 from "styled-components";
|
|
5801
6191
|
|
|
5802
6192
|
// src/components/ColorSchemeWrapper/ColorSchemeWrapper.tsx
|
|
@@ -5839,13 +6229,13 @@ var ColorSchemeWrapper = ({
|
|
|
5839
6229
|
ColorSchemeWrapper.displayName = "ColorSchemeWrapper";
|
|
5840
6230
|
|
|
5841
6231
|
// src/components/Avatar/formatNameForDisplay.tsx
|
|
5842
|
-
import { isNil as
|
|
6232
|
+
import { isNil as isNil7, isString, isEmptyString } from "@wistia/type-guards";
|
|
5843
6233
|
var containsEmojiCharacter = (char) => {
|
|
5844
6234
|
const emojiRegex = /<a?:.+?:\d{18}>|\p{Extended_Pictographic}/gu;
|
|
5845
6235
|
return emojiRegex.test(char);
|
|
5846
6236
|
};
|
|
5847
6237
|
var formatNameForDisplay = (name) => {
|
|
5848
|
-
if (
|
|
6238
|
+
if (isNil7(name) || !isString(name) || isEmptyString(name) || containsEmojiCharacter(name)) {
|
|
5849
6239
|
return "U";
|
|
5850
6240
|
}
|
|
5851
6241
|
const firstChar = name.trim().substring(0, 1);
|
|
@@ -5908,7 +6298,7 @@ var AvatarWrapper = styled8.div`
|
|
|
5908
6298
|
max-height: ${({ $maxHeight }) => $maxHeight}px;
|
|
5909
6299
|
`;
|
|
5910
6300
|
var chooseColorScheme = (name) => {
|
|
5911
|
-
if (
|
|
6301
|
+
if (isNil8(name) || name === "Anonymous") {
|
|
5912
6302
|
return "default";
|
|
5913
6303
|
}
|
|
5914
6304
|
const filteredColors = colorSchemeOptions.filter(
|
|
@@ -5941,7 +6331,7 @@ var Avatar = ({
|
|
|
5941
6331
|
};
|
|
5942
6332
|
const avatarSize = heightAndWidth ?? avatarSizeMap[size];
|
|
5943
6333
|
const avatarColor = useMemo3(() => chooseColorScheme(name), [name]);
|
|
5944
|
-
const showInitials =
|
|
6334
|
+
const showInitials = isNil8(imageUrl) || imageLoadState === "error";
|
|
5945
6335
|
return /* @__PURE__ */ jsx165(
|
|
5946
6336
|
AvatarWrapper,
|
|
5947
6337
|
{
|
|
@@ -6017,7 +6407,7 @@ Badge.displayName = "Badge";
|
|
|
6017
6407
|
// src/components/Box/Box.tsx
|
|
6018
6408
|
import { Children, cloneElement as cloneElement2, forwardRef as forwardRef5 } from "react";
|
|
6019
6409
|
import styled10 from "styled-components";
|
|
6020
|
-
import { isNotNil as isNotNil7, isNil as
|
|
6410
|
+
import { isNotNil as isNotNil7, isNil as isNil9, isRecord as isRecord3 } from "@wistia/type-guards";
|
|
6021
6411
|
|
|
6022
6412
|
// src/private/helpers/makePolymorphic/makePolymorphic.tsx
|
|
6023
6413
|
var makePolymorphic = (component) => {
|
|
@@ -6090,7 +6480,7 @@ var wrapChildren = (children) => {
|
|
|
6090
6480
|
if (isNotNil7(children)) {
|
|
6091
6481
|
if (typeof children === "object" && isDev) {
|
|
6092
6482
|
return Children.map(children, (child) => {
|
|
6093
|
-
if (
|
|
6483
|
+
if (isNil9(child)) return null;
|
|
6094
6484
|
const elementParams = {};
|
|
6095
6485
|
if (child.type?.displayName === "Box" || child.type?.displayName === "Box_UI") {
|
|
6096
6486
|
elementParams.hasBoxParent = true;
|
|
@@ -6237,7 +6627,7 @@ var Breadcrumb = ({ icon, href, children, ...props }) => {
|
|
|
6237
6627
|
|
|
6238
6628
|
// src/components/ButtonGroup/ButtonGroup.tsx
|
|
6239
6629
|
import styled13 from "styled-components";
|
|
6240
|
-
import { isNil as
|
|
6630
|
+
import { isNil as isNil10 } from "@wistia/type-guards";
|
|
6241
6631
|
import { jsx as jsx170 } from "react/jsx-runtime";
|
|
6242
6632
|
var getAlignment = (align) => {
|
|
6243
6633
|
if (align === "center") {
|
|
@@ -6277,7 +6667,7 @@ var ButtonGroup = ({
|
|
|
6277
6667
|
fullWidth = false,
|
|
6278
6668
|
...otherProps
|
|
6279
6669
|
}) => {
|
|
6280
|
-
if (
|
|
6670
|
+
if (isNil10(children)) {
|
|
6281
6671
|
return null;
|
|
6282
6672
|
}
|
|
6283
6673
|
return /* @__PURE__ */ jsx170(
|
|
@@ -6527,7 +6917,7 @@ Label.displayName = "Label";
|
|
|
6527
6917
|
|
|
6528
6918
|
// src/components/Label/LabelDescription.tsx
|
|
6529
6919
|
import styled17 from "styled-components";
|
|
6530
|
-
import { isNil as
|
|
6920
|
+
import { isNil as isNil11 } from "@wistia/type-guards";
|
|
6531
6921
|
import { jsx as jsx174 } from "react/jsx-runtime";
|
|
6532
6922
|
var StyledLabelDescription = styled17.div`
|
|
6533
6923
|
color: var(--wui-color-text-secondary);
|
|
@@ -6539,7 +6929,7 @@ var LabelDescription = ({
|
|
|
6539
6929
|
children,
|
|
6540
6930
|
...props
|
|
6541
6931
|
}) => {
|
|
6542
|
-
if (
|
|
6932
|
+
if (isNil11(children)) {
|
|
6543
6933
|
return null;
|
|
6544
6934
|
}
|
|
6545
6935
|
return /* @__PURE__ */ jsx174(StyledLabelDescription, { ...props, children });
|
|
@@ -7327,7 +7717,7 @@ IconButton.displayName = "IconButton";
|
|
|
7327
7717
|
// src/components/Input/Input.tsx
|
|
7328
7718
|
import { forwardRef as forwardRef12, cloneElement as cloneElement5, useRef as useRef6 } from "react";
|
|
7329
7719
|
import styled26, { css as css21 } from "styled-components";
|
|
7330
|
-
import { isNil as
|
|
7720
|
+
import { isNil as isNil12, isNotNil as isNotNil9 } from "@wistia/type-guards";
|
|
7331
7721
|
import { jsx as jsx186, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7332
7722
|
var inputStyles = css21`
|
|
7333
7723
|
--wui-input-color-bg: var(--wui-color-bg-surface);
|
|
@@ -7430,7 +7820,7 @@ var Input = forwardRef12(
|
|
|
7430
7820
|
const internalRef = useRef6();
|
|
7431
7821
|
const ref = isValidRef(externalRef) ? externalRef : internalRef;
|
|
7432
7822
|
let leftIconToDisplay = leftIcon;
|
|
7433
|
-
if (
|
|
7823
|
+
if (isNil12(leftIcon) && type === "search") {
|
|
7434
7824
|
leftIconToDisplay = /* @__PURE__ */ jsx186(Icon, { type: "search" });
|
|
7435
7825
|
}
|
|
7436
7826
|
if (isNotNil9(leftIconToDisplay)) {
|
|
@@ -8469,7 +8859,7 @@ Radio.displayName = "Radio";
|
|
|
8469
8859
|
import { forwardRef as forwardRef19 } from "react";
|
|
8470
8860
|
import styled39 from "styled-components";
|
|
8471
8861
|
import { Root as ToggleGroupRoot } from "@radix-ui/react-toggle-group";
|
|
8472
|
-
import { isNil as
|
|
8862
|
+
import { isNil as isNil13 } from "@wistia/type-guards";
|
|
8473
8863
|
import { jsx as jsx203 } from "react/jsx-runtime";
|
|
8474
8864
|
var StyledSegmentedControl = styled39(ToggleGroupRoot)`
|
|
8475
8865
|
display: inline-flex;
|
|
@@ -8488,7 +8878,7 @@ var SegmentedControl = forwardRef19(
|
|
|
8488
8878
|
onSelectedValueChange,
|
|
8489
8879
|
...props
|
|
8490
8880
|
}, ref) => {
|
|
8491
|
-
if (
|
|
8881
|
+
if (isNil13(children)) {
|
|
8492
8882
|
return null;
|
|
8493
8883
|
}
|
|
8494
8884
|
return /* @__PURE__ */ jsx203(
|
|
@@ -8599,7 +8989,7 @@ SegmentedControlItem.displayName = "SegmentedControlItem";
|
|
|
8599
8989
|
// src/components/Tag/Tag.tsx
|
|
8600
8990
|
import { forwardRef as forwardRef21 } from "react";
|
|
8601
8991
|
import styled41 from "styled-components";
|
|
8602
|
-
import { isNil as
|
|
8992
|
+
import { isNil as isNil14, isNotNil as isNotNil17, isNonEmptyString as isNonEmptyString4 } from "@wistia/type-guards";
|
|
8603
8993
|
import { Fragment as Fragment4, jsx as jsx204, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
8604
8994
|
var TagLabel = styled41.a`
|
|
8605
8995
|
${({ $colorScheme }) => getColorScheme($colorScheme)};
|
|
@@ -8677,10 +9067,10 @@ var StyledTag = styled41.div`
|
|
|
8677
9067
|
}
|
|
8678
9068
|
`;
|
|
8679
9069
|
var RemoveButton = ({ onClickRemove, onClickRemoveLabel, colorScheme }) => {
|
|
8680
|
-
if (
|
|
9070
|
+
if (isNil14(onClickRemove)) {
|
|
8681
9071
|
return null;
|
|
8682
9072
|
}
|
|
8683
|
-
if (
|
|
9073
|
+
if (isNil14(onClickRemoveLabel)) {
|
|
8684
9074
|
throw new Error(
|
|
8685
9075
|
"for accessibility, onClickRemoveLabel must be provided if onClickRemove is provided"
|
|
8686
9076
|
);
|
|
@@ -9373,6 +9763,7 @@ export {
|
|
|
9373
9763
|
WistiaLogo,
|
|
9374
9764
|
colorSchemeOptions,
|
|
9375
9765
|
copyToClipboard,
|
|
9766
|
+
dateTime,
|
|
9376
9767
|
ellipsisFlexParentStyle,
|
|
9377
9768
|
ellipsisStyle,
|
|
9378
9769
|
iconSizeMap,
|