nsw-design-system 3.6.0 → 3.7.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/js/main.js CHANGED
@@ -31,6 +31,69 @@
31
31
  }
32
32
  }
33
33
 
34
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
35
+ // require the crypto API and do not support built-in fallback to lower quality random number
36
+ // generators (like Math.random()).
37
+ let getRandomValues;
38
+ const rnds8 = new Uint8Array(16);
39
+ function rng() {
40
+ // lazy load so that environments that need to polyfill have a chance to do so
41
+ if (!getRandomValues) {
42
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
43
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
44
+ if (!getRandomValues) {
45
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
46
+ }
47
+ }
48
+ return getRandomValues(rnds8);
49
+ }
50
+
51
+ /**
52
+ * Convert array of 16 byte values to UUID string format of the form:
53
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
54
+ */
55
+
56
+ const byteToHex = [];
57
+ for (let i = 0; i < 256; ++i) {
58
+ byteToHex.push((i + 0x100).toString(16).slice(1));
59
+ }
60
+ function unsafeStringify(arr, offset = 0) {
61
+ // Note: Be careful editing this code! It's been tuned for performance
62
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
63
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
64
+ }
65
+
66
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
67
+ var native = {
68
+ randomUUID
69
+ };
70
+
71
+ function v4(options, buf, offset) {
72
+ if (native.randomUUID && !buf && !options) {
73
+ return native.randomUUID();
74
+ }
75
+ options = options || {};
76
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
77
+
78
+ rnds[6] = rnds[6] & 0x0f | 0x40;
79
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
80
+
81
+ if (buf) {
82
+ offset = offset || 0;
83
+ for (let i = 0; i < 16; ++i) {
84
+ buf[offset + i] = rnds[i];
85
+ }
86
+ return buf;
87
+ }
88
+ return unsafeStringify(rnds);
89
+ }
90
+
91
+ // eslint-disable-next-line import/no-extraneous-dependencies
92
+ const uniqueId = prefix => {
93
+ const prefixValue = prefix === undefined ? 'nsw' : prefix;
94
+ const uuid = v4();
95
+ return `${prefixValue}-${uuid}`;
96
+ };
34
97
  const focusObjectGenerator = arr => {
35
98
  const focusableElements = {
36
99
  all: arr,
@@ -76,10 +139,6 @@
76
139
  const found = Object.keys(transitions).filter(key => el.style[key] !== undefined);
77
140
  return transitions[found[0]];
78
141
  };
79
- const uniqueId = prefix => {
80
- const prefixValue = prefix === undefined ? 'nsw' : prefix;
81
- return `${prefixValue}-${Math.random().toString(36).substr(2, 16)}`;
82
- };
83
142
 
84
143
  class Navigation {
85
144
  constructor() {
@@ -1397,6 +1456,1659 @@
1397
1456
  }
1398
1457
  }
1399
1458
 
1459
+ function getAlignment(placement) {
1460
+ return placement.split('-')[1];
1461
+ }
1462
+ function getLengthFromAxis(axis) {
1463
+ return axis === 'y' ? 'height' : 'width';
1464
+ }
1465
+ function getSide(placement) {
1466
+ return placement.split('-')[0];
1467
+ }
1468
+ function getMainAxisFromPlacement(placement) {
1469
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
1470
+ }
1471
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1472
+ let {
1473
+ reference,
1474
+ floating
1475
+ } = _ref;
1476
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1477
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1478
+ const mainAxis = getMainAxisFromPlacement(placement);
1479
+ const length = getLengthFromAxis(mainAxis);
1480
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
1481
+ const side = getSide(placement);
1482
+ const isVertical = mainAxis === 'x';
1483
+ let coords;
1484
+ switch (side) {
1485
+ case 'top':
1486
+ coords = {
1487
+ x: commonX,
1488
+ y: reference.y - floating.height
1489
+ };
1490
+ break;
1491
+ case 'bottom':
1492
+ coords = {
1493
+ x: commonX,
1494
+ y: reference.y + reference.height
1495
+ };
1496
+ break;
1497
+ case 'right':
1498
+ coords = {
1499
+ x: reference.x + reference.width,
1500
+ y: commonY
1501
+ };
1502
+ break;
1503
+ case 'left':
1504
+ coords = {
1505
+ x: reference.x - floating.width,
1506
+ y: commonY
1507
+ };
1508
+ break;
1509
+ default:
1510
+ coords = {
1511
+ x: reference.x,
1512
+ y: reference.y
1513
+ };
1514
+ }
1515
+ switch (getAlignment(placement)) {
1516
+ case 'start':
1517
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1518
+ break;
1519
+ case 'end':
1520
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1521
+ break;
1522
+ }
1523
+ return coords;
1524
+ }
1525
+
1526
+ /**
1527
+ * Computes the `x` and `y` coordinates that will place the floating element
1528
+ * next to a reference element when it is given a certain positioning strategy.
1529
+ *
1530
+ * This export does not have any `platform` interface logic. You will need to
1531
+ * write one for the platform you are using Floating UI with.
1532
+ */
1533
+ const computePosition$1 = async (reference, floating, config) => {
1534
+ const {
1535
+ placement = 'bottom',
1536
+ strategy = 'absolute',
1537
+ middleware = [],
1538
+ platform
1539
+ } = config;
1540
+ const validMiddleware = middleware.filter(Boolean);
1541
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1542
+ let rects = await platform.getElementRects({
1543
+ reference,
1544
+ floating,
1545
+ strategy
1546
+ });
1547
+ let {
1548
+ x,
1549
+ y
1550
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1551
+ let statefulPlacement = placement;
1552
+ let middlewareData = {};
1553
+ let resetCount = 0;
1554
+ for (let i = 0; i < validMiddleware.length; i++) {
1555
+ const {
1556
+ name,
1557
+ fn
1558
+ } = validMiddleware[i];
1559
+ const {
1560
+ x: nextX,
1561
+ y: nextY,
1562
+ data,
1563
+ reset
1564
+ } = await fn({
1565
+ x,
1566
+ y,
1567
+ initialPlacement: placement,
1568
+ placement: statefulPlacement,
1569
+ strategy,
1570
+ middlewareData,
1571
+ rects,
1572
+ platform,
1573
+ elements: {
1574
+ reference,
1575
+ floating
1576
+ }
1577
+ });
1578
+ x = nextX != null ? nextX : x;
1579
+ y = nextY != null ? nextY : y;
1580
+ middlewareData = {
1581
+ ...middlewareData,
1582
+ [name]: {
1583
+ ...middlewareData[name],
1584
+ ...data
1585
+ }
1586
+ };
1587
+ if (reset && resetCount <= 50) {
1588
+ resetCount++;
1589
+ if (typeof reset === 'object') {
1590
+ if (reset.placement) {
1591
+ statefulPlacement = reset.placement;
1592
+ }
1593
+ if (reset.rects) {
1594
+ rects = reset.rects === true ? await platform.getElementRects({
1595
+ reference,
1596
+ floating,
1597
+ strategy
1598
+ }) : reset.rects;
1599
+ }
1600
+ ({
1601
+ x,
1602
+ y
1603
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1604
+ }
1605
+ i = -1;
1606
+ continue;
1607
+ }
1608
+ }
1609
+ return {
1610
+ x,
1611
+ y,
1612
+ placement: statefulPlacement,
1613
+ strategy,
1614
+ middlewareData
1615
+ };
1616
+ };
1617
+ function expandPaddingObject(padding) {
1618
+ return {
1619
+ top: 0,
1620
+ right: 0,
1621
+ bottom: 0,
1622
+ left: 0,
1623
+ ...padding
1624
+ };
1625
+ }
1626
+ function getSideObjectFromPadding(padding) {
1627
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
1628
+ top: padding,
1629
+ right: padding,
1630
+ bottom: padding,
1631
+ left: padding
1632
+ };
1633
+ }
1634
+ function rectToClientRect(rect) {
1635
+ return {
1636
+ ...rect,
1637
+ top: rect.y,
1638
+ left: rect.x,
1639
+ right: rect.x + rect.width,
1640
+ bottom: rect.y + rect.height
1641
+ };
1642
+ }
1643
+
1644
+ /**
1645
+ * Resolves with an object of overflow side offsets that determine how much the
1646
+ * element is overflowing a given clipping boundary on each side.
1647
+ * - positive = overflowing the boundary by that number of pixels
1648
+ * - negative = how many pixels left before it will overflow
1649
+ * - 0 = lies flush with the boundary
1650
+ * @see https://floating-ui.com/docs/detectOverflow
1651
+ */
1652
+ async function detectOverflow(state, options) {
1653
+ var _await$platform$isEle;
1654
+ if (options === void 0) {
1655
+ options = {};
1656
+ }
1657
+ const {
1658
+ x,
1659
+ y,
1660
+ platform,
1661
+ rects,
1662
+ elements,
1663
+ strategy
1664
+ } = state;
1665
+ const {
1666
+ boundary = 'clippingAncestors',
1667
+ rootBoundary = 'viewport',
1668
+ elementContext = 'floating',
1669
+ altBoundary = false,
1670
+ padding = 0
1671
+ } = options;
1672
+ const paddingObject = getSideObjectFromPadding(padding);
1673
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1674
+ const element = elements[altBoundary ? altContext : elementContext];
1675
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1676
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1677
+ boundary,
1678
+ rootBoundary,
1679
+ strategy
1680
+ }));
1681
+ const rect = elementContext === 'floating' ? {
1682
+ ...rects.floating,
1683
+ x,
1684
+ y
1685
+ } : rects.reference;
1686
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1687
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1688
+ x: 1,
1689
+ y: 1
1690
+ } : {
1691
+ x: 1,
1692
+ y: 1
1693
+ };
1694
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1695
+ rect,
1696
+ offsetParent,
1697
+ strategy
1698
+ }) : rect);
1699
+ return {
1700
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1701
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1702
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1703
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1704
+ };
1705
+ }
1706
+ const min$1 = Math.min;
1707
+ const max$1 = Math.max;
1708
+ function within(min$1$1, value, max$1$1) {
1709
+ return max$1(min$1$1, min$1(value, max$1$1));
1710
+ }
1711
+
1712
+ /**
1713
+ * Provides data to position an inner element of the floating element so that it
1714
+ * appears centered to the reference element.
1715
+ * @see https://floating-ui.com/docs/arrow
1716
+ */
1717
+ const arrow = options => ({
1718
+ name: 'arrow',
1719
+ options,
1720
+ async fn(state) {
1721
+ // Since `element` is required, we don't Partial<> the type.
1722
+ const {
1723
+ element,
1724
+ padding = 0
1725
+ } = options || {};
1726
+ const {
1727
+ x,
1728
+ y,
1729
+ placement,
1730
+ rects,
1731
+ platform,
1732
+ elements
1733
+ } = state;
1734
+ if (element == null) {
1735
+ return {};
1736
+ }
1737
+ const paddingObject = getSideObjectFromPadding(padding);
1738
+ const coords = {
1739
+ x,
1740
+ y
1741
+ };
1742
+ const axis = getMainAxisFromPlacement(placement);
1743
+ const length = getLengthFromAxis(axis);
1744
+ const arrowDimensions = await platform.getDimensions(element);
1745
+ const isYAxis = axis === 'y';
1746
+ const minProp = isYAxis ? 'top' : 'left';
1747
+ const maxProp = isYAxis ? 'bottom' : 'right';
1748
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1749
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1750
+ const startDiff = coords[axis] - rects.reference[axis];
1751
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1752
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1753
+
1754
+ // DOM platform can return `window` as the `offsetParent`.
1755
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1756
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1757
+ }
1758
+ const centerToReference = endDiff / 2 - startDiff / 2;
1759
+
1760
+ // Make sure the arrow doesn't overflow the floating element if the center
1761
+ // point is outside the floating element's bounds.
1762
+ const min = paddingObject[minProp];
1763
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
1764
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1765
+ const offset = within(min, center, max);
1766
+
1767
+ // If the reference is small enough that the arrow's padding causes it to
1768
+ // to point to nothing for an aligned placement, adjust the offset of the
1769
+ // floating element itself. This stops `shift()` from taking action, but can
1770
+ // be worked around by calling it again after the `arrow()` if desired.
1771
+ const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min ? paddingObject[minProp] : paddingObject[maxProp]) - arrowDimensions[length] / 2 < 0;
1772
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
1773
+ return {
1774
+ [axis]: coords[axis] - alignmentOffset,
1775
+ data: {
1776
+ [axis]: offset,
1777
+ centerOffset: center - offset
1778
+ }
1779
+ };
1780
+ }
1781
+ });
1782
+ const oppositeSideMap = {
1783
+ left: 'right',
1784
+ right: 'left',
1785
+ bottom: 'top',
1786
+ top: 'bottom'
1787
+ };
1788
+ function getOppositePlacement(placement) {
1789
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
1790
+ }
1791
+ function getAlignmentSides(placement, rects, rtl) {
1792
+ if (rtl === void 0) {
1793
+ rtl = false;
1794
+ }
1795
+ const alignment = getAlignment(placement);
1796
+ const mainAxis = getMainAxisFromPlacement(placement);
1797
+ const length = getLengthFromAxis(mainAxis);
1798
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
1799
+ if (rects.reference[length] > rects.floating[length]) {
1800
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1801
+ }
1802
+ return {
1803
+ main: mainAlignmentSide,
1804
+ cross: getOppositePlacement(mainAlignmentSide)
1805
+ };
1806
+ }
1807
+ const oppositeAlignmentMap = {
1808
+ start: 'end',
1809
+ end: 'start'
1810
+ };
1811
+ function getOppositeAlignmentPlacement(placement) {
1812
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
1813
+ }
1814
+ function getExpandedPlacements(placement) {
1815
+ const oppositePlacement = getOppositePlacement(placement);
1816
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1817
+ }
1818
+ function getSideList(side, isStart, rtl) {
1819
+ const lr = ['left', 'right'];
1820
+ const rl = ['right', 'left'];
1821
+ const tb = ['top', 'bottom'];
1822
+ const bt = ['bottom', 'top'];
1823
+ switch (side) {
1824
+ case 'top':
1825
+ case 'bottom':
1826
+ if (rtl) return isStart ? rl : lr;
1827
+ return isStart ? lr : rl;
1828
+ case 'left':
1829
+ case 'right':
1830
+ return isStart ? tb : bt;
1831
+ default:
1832
+ return [];
1833
+ }
1834
+ }
1835
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1836
+ const alignment = getAlignment(placement);
1837
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
1838
+ if (alignment) {
1839
+ list = list.map(side => side + "-" + alignment);
1840
+ if (flipAlignment) {
1841
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1842
+ }
1843
+ }
1844
+ return list;
1845
+ }
1846
+
1847
+ /**
1848
+ * Optimizes the visibility of the floating element by flipping the `placement`
1849
+ * in order to keep it in view when the preferred placement(s) will overflow the
1850
+ * clipping boundary. Alternative to `autoPlacement`.
1851
+ * @see https://floating-ui.com/docs/flip
1852
+ */
1853
+ const flip = function (options) {
1854
+ if (options === void 0) {
1855
+ options = {};
1856
+ }
1857
+ return {
1858
+ name: 'flip',
1859
+ options,
1860
+ async fn(state) {
1861
+ var _middlewareData$flip;
1862
+ const {
1863
+ placement,
1864
+ middlewareData,
1865
+ rects,
1866
+ initialPlacement,
1867
+ platform,
1868
+ elements
1869
+ } = state;
1870
+ const {
1871
+ mainAxis: checkMainAxis = true,
1872
+ crossAxis: checkCrossAxis = true,
1873
+ fallbackPlacements: specifiedFallbackPlacements,
1874
+ fallbackStrategy = 'bestFit',
1875
+ fallbackAxisSideDirection = 'none',
1876
+ flipAlignment = true,
1877
+ ...detectOverflowOptions
1878
+ } = options;
1879
+ const side = getSide(placement);
1880
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1881
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1882
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1883
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
1884
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1885
+ }
1886
+ const placements = [initialPlacement, ...fallbackPlacements];
1887
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1888
+ const overflows = [];
1889
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1890
+ if (checkMainAxis) {
1891
+ overflows.push(overflow[side]);
1892
+ }
1893
+ if (checkCrossAxis) {
1894
+ const {
1895
+ main,
1896
+ cross
1897
+ } = getAlignmentSides(placement, rects, rtl);
1898
+ overflows.push(overflow[main], overflow[cross]);
1899
+ }
1900
+ overflowsData = [...overflowsData, {
1901
+ placement,
1902
+ overflows
1903
+ }];
1904
+
1905
+ // One or more sides is overflowing.
1906
+ if (!overflows.every(side => side <= 0)) {
1907
+ var _middlewareData$flip2, _overflowsData$filter;
1908
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1909
+ const nextPlacement = placements[nextIndex];
1910
+ if (nextPlacement) {
1911
+ // Try next placement and re-run the lifecycle.
1912
+ return {
1913
+ data: {
1914
+ index: nextIndex,
1915
+ overflows: overflowsData
1916
+ },
1917
+ reset: {
1918
+ placement: nextPlacement
1919
+ }
1920
+ };
1921
+ }
1922
+
1923
+ // First, find the candidates that fit on the mainAxis side of overflow,
1924
+ // then find the placement that fits the best on the main crossAxis side.
1925
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
1926
+
1927
+ // Otherwise fallback.
1928
+ if (!resetPlacement) {
1929
+ switch (fallbackStrategy) {
1930
+ case 'bestFit':
1931
+ {
1932
+ var _overflowsData$map$so;
1933
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
1934
+ if (placement) {
1935
+ resetPlacement = placement;
1936
+ }
1937
+ break;
1938
+ }
1939
+ case 'initialPlacement':
1940
+ resetPlacement = initialPlacement;
1941
+ break;
1942
+ }
1943
+ }
1944
+ if (placement !== resetPlacement) {
1945
+ return {
1946
+ reset: {
1947
+ placement: resetPlacement
1948
+ }
1949
+ };
1950
+ }
1951
+ }
1952
+ return {};
1953
+ }
1954
+ };
1955
+ };
1956
+ async function convertValueToCoords(state, value) {
1957
+ const {
1958
+ placement,
1959
+ platform,
1960
+ elements
1961
+ } = state;
1962
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1963
+ const side = getSide(placement);
1964
+ const alignment = getAlignment(placement);
1965
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
1966
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1967
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1968
+ const rawValue = typeof value === 'function' ? value(state) : value;
1969
+
1970
+ // eslint-disable-next-line prefer-const
1971
+ let {
1972
+ mainAxis,
1973
+ crossAxis,
1974
+ alignmentAxis
1975
+ } = typeof rawValue === 'number' ? {
1976
+ mainAxis: rawValue,
1977
+ crossAxis: 0,
1978
+ alignmentAxis: null
1979
+ } : {
1980
+ mainAxis: 0,
1981
+ crossAxis: 0,
1982
+ alignmentAxis: null,
1983
+ ...rawValue
1984
+ };
1985
+ if (alignment && typeof alignmentAxis === 'number') {
1986
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1987
+ }
1988
+ return isVertical ? {
1989
+ x: crossAxis * crossAxisMulti,
1990
+ y: mainAxis * mainAxisMulti
1991
+ } : {
1992
+ x: mainAxis * mainAxisMulti,
1993
+ y: crossAxis * crossAxisMulti
1994
+ };
1995
+ }
1996
+
1997
+ /**
1998
+ * Modifies the placement by translating the floating element along the
1999
+ * specified axes.
2000
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2001
+ * object may be passed.
2002
+ * @see https://floating-ui.com/docs/offset
2003
+ */
2004
+ const offset = function (value) {
2005
+ if (value === void 0) {
2006
+ value = 0;
2007
+ }
2008
+ return {
2009
+ name: 'offset',
2010
+ options: value,
2011
+ async fn(state) {
2012
+ const {
2013
+ x,
2014
+ y
2015
+ } = state;
2016
+ const diffCoords = await convertValueToCoords(state, value);
2017
+ return {
2018
+ x: x + diffCoords.x,
2019
+ y: y + diffCoords.y,
2020
+ data: diffCoords
2021
+ };
2022
+ }
2023
+ };
2024
+ };
2025
+ function getCrossAxis(axis) {
2026
+ return axis === 'x' ? 'y' : 'x';
2027
+ }
2028
+
2029
+ /**
2030
+ * Optimizes the visibility of the floating element by shifting it in order to
2031
+ * keep it in view when it will overflow the clipping boundary.
2032
+ * @see https://floating-ui.com/docs/shift
2033
+ */
2034
+ const shift = function (options) {
2035
+ if (options === void 0) {
2036
+ options = {};
2037
+ }
2038
+ return {
2039
+ name: 'shift',
2040
+ options,
2041
+ async fn(state) {
2042
+ const {
2043
+ x,
2044
+ y,
2045
+ placement
2046
+ } = state;
2047
+ const {
2048
+ mainAxis: checkMainAxis = true,
2049
+ crossAxis: checkCrossAxis = false,
2050
+ limiter = {
2051
+ fn: _ref => {
2052
+ let {
2053
+ x,
2054
+ y
2055
+ } = _ref;
2056
+ return {
2057
+ x,
2058
+ y
2059
+ };
2060
+ }
2061
+ },
2062
+ ...detectOverflowOptions
2063
+ } = options;
2064
+ const coords = {
2065
+ x,
2066
+ y
2067
+ };
2068
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2069
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
2070
+ const crossAxis = getCrossAxis(mainAxis);
2071
+ let mainAxisCoord = coords[mainAxis];
2072
+ let crossAxisCoord = coords[crossAxis];
2073
+ if (checkMainAxis) {
2074
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
2075
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2076
+ const min = mainAxisCoord + overflow[minSide];
2077
+ const max = mainAxisCoord - overflow[maxSide];
2078
+ mainAxisCoord = within(min, mainAxisCoord, max);
2079
+ }
2080
+ if (checkCrossAxis) {
2081
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
2082
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2083
+ const min = crossAxisCoord + overflow[minSide];
2084
+ const max = crossAxisCoord - overflow[maxSide];
2085
+ crossAxisCoord = within(min, crossAxisCoord, max);
2086
+ }
2087
+ const limitedCoords = limiter.fn({
2088
+ ...state,
2089
+ [mainAxis]: mainAxisCoord,
2090
+ [crossAxis]: crossAxisCoord
2091
+ });
2092
+ return {
2093
+ ...limitedCoords,
2094
+ data: {
2095
+ x: limitedCoords.x - x,
2096
+ y: limitedCoords.y - y
2097
+ }
2098
+ };
2099
+ }
2100
+ };
2101
+ };
2102
+
2103
+ function getWindow(node) {
2104
+ var _node$ownerDocument;
2105
+ return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2106
+ }
2107
+ function getComputedStyle$1(element) {
2108
+ return getWindow(element).getComputedStyle(element);
2109
+ }
2110
+ function isNode(value) {
2111
+ return value instanceof getWindow(value).Node;
2112
+ }
2113
+ function getNodeName(node) {
2114
+ return isNode(node) ? (node.nodeName || '').toLowerCase() : '';
2115
+ }
2116
+ let uaString;
2117
+ function getUAString() {
2118
+ if (uaString) {
2119
+ return uaString;
2120
+ }
2121
+ const uaData = navigator.userAgentData;
2122
+ if (uaData && Array.isArray(uaData.brands)) {
2123
+ uaString = uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
2124
+ return uaString;
2125
+ }
2126
+ return navigator.userAgent;
2127
+ }
2128
+ function isHTMLElement(value) {
2129
+ return value instanceof getWindow(value).HTMLElement;
2130
+ }
2131
+ function isElement(value) {
2132
+ return value instanceof getWindow(value).Element;
2133
+ }
2134
+ function isShadowRoot(node) {
2135
+ // Browsers without `ShadowRoot` support.
2136
+ if (typeof ShadowRoot === 'undefined') {
2137
+ return false;
2138
+ }
2139
+ const OwnElement = getWindow(node).ShadowRoot;
2140
+ return node instanceof OwnElement || node instanceof ShadowRoot;
2141
+ }
2142
+ function isOverflowElement(element) {
2143
+ const {
2144
+ overflow,
2145
+ overflowX,
2146
+ overflowY,
2147
+ display
2148
+ } = getComputedStyle$1(element);
2149
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
2150
+ }
2151
+ function isTableElement(element) {
2152
+ return ['table', 'td', 'th'].includes(getNodeName(element));
2153
+ }
2154
+ function isContainingBlock(element) {
2155
+ // TODO: Try to use feature detection here instead.
2156
+ const isFirefox = /firefox/i.test(getUAString());
2157
+ const css = getComputedStyle$1(element);
2158
+ const backdropFilter = css.backdropFilter || css.WebkitBackdropFilter;
2159
+
2160
+ // This is non-exhaustive but covers the most common CSS properties that
2161
+ // create a containing block.
2162
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2163
+ return css.transform !== 'none' || css.perspective !== 'none' || (backdropFilter ? backdropFilter !== 'none' : false) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective'].some(value => css.willChange.includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => {
2164
+ // Add type check for old browsers.
2165
+ const contain = css.contain;
2166
+ return contain != null ? contain.includes(value) : false;
2167
+ });
2168
+ }
2169
+
2170
+ /**
2171
+ * Determines whether or not `.getBoundingClientRect()` is affected by visual
2172
+ * viewport offsets. In Safari, the `x`/`y` offsets are values relative to the
2173
+ * visual viewport, while in other engines, they are values relative to the
2174
+ * layout viewport.
2175
+ */
2176
+ function isClientRectVisualViewportBased() {
2177
+ // TODO: Try to use feature detection here instead. Feature detection for
2178
+ // this can fail in various ways, making the userAgent check the most
2179
+ // reliable:
2180
+ // • Always-visible scrollbar or not
2181
+ // • Width of <html>
2182
+
2183
+ // Is Safari.
2184
+ return /^((?!chrome|android).)*safari/i.test(getUAString());
2185
+ }
2186
+ function isLastTraversableNode(node) {
2187
+ return ['html', 'body', '#document'].includes(getNodeName(node));
2188
+ }
2189
+ const min = Math.min;
2190
+ const max = Math.max;
2191
+ const round = Math.round;
2192
+ function getCssDimensions(element) {
2193
+ const css = getComputedStyle$1(element);
2194
+ // In testing environments, the `width` and `height` properties are empty
2195
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2196
+ let width = parseFloat(css.width) || 0;
2197
+ let height = parseFloat(css.height) || 0;
2198
+ const hasOffset = isHTMLElement(element);
2199
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2200
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2201
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2202
+ if (shouldFallback) {
2203
+ width = offsetWidth;
2204
+ height = offsetHeight;
2205
+ }
2206
+ return {
2207
+ width,
2208
+ height,
2209
+ fallback: shouldFallback
2210
+ };
2211
+ }
2212
+ function unwrapElement(element) {
2213
+ return !isElement(element) ? element.contextElement : element;
2214
+ }
2215
+ const FALLBACK_SCALE = {
2216
+ x: 1,
2217
+ y: 1
2218
+ };
2219
+ function getScale(element) {
2220
+ const domElement = unwrapElement(element);
2221
+ if (!isHTMLElement(domElement)) {
2222
+ return FALLBACK_SCALE;
2223
+ }
2224
+ const rect = domElement.getBoundingClientRect();
2225
+ const {
2226
+ width,
2227
+ height,
2228
+ fallback
2229
+ } = getCssDimensions(domElement);
2230
+ let x = (fallback ? round(rect.width) : rect.width) / width;
2231
+ let y = (fallback ? round(rect.height) : rect.height) / height;
2232
+
2233
+ // 0, NaN, or Infinity should always fallback to 1.
2234
+
2235
+ if (!x || !Number.isFinite(x)) {
2236
+ x = 1;
2237
+ }
2238
+ if (!y || !Number.isFinite(y)) {
2239
+ y = 1;
2240
+ }
2241
+ return {
2242
+ x,
2243
+ y
2244
+ };
2245
+ }
2246
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2247
+ var _win$visualViewport, _win$visualViewport2;
2248
+ if (includeScale === void 0) {
2249
+ includeScale = false;
2250
+ }
2251
+ if (isFixedStrategy === void 0) {
2252
+ isFixedStrategy = false;
2253
+ }
2254
+ const clientRect = element.getBoundingClientRect();
2255
+ const domElement = unwrapElement(element);
2256
+ let scale = FALLBACK_SCALE;
2257
+ if (includeScale) {
2258
+ if (offsetParent) {
2259
+ if (isElement(offsetParent)) {
2260
+ scale = getScale(offsetParent);
2261
+ }
2262
+ } else {
2263
+ scale = getScale(element);
2264
+ }
2265
+ }
2266
+ const win = domElement ? getWindow(domElement) : window;
2267
+ const addVisualOffsets = isClientRectVisualViewportBased() && isFixedStrategy;
2268
+ let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
2269
+ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
2270
+ let width = clientRect.width / scale.x;
2271
+ let height = clientRect.height / scale.y;
2272
+ if (domElement) {
2273
+ const win = getWindow(domElement);
2274
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2275
+ let currentIFrame = win.frameElement;
2276
+ while (currentIFrame && offsetParent && offsetWin !== win) {
2277
+ const iframeScale = getScale(currentIFrame);
2278
+ const iframeRect = currentIFrame.getBoundingClientRect();
2279
+ const css = getComputedStyle(currentIFrame);
2280
+ iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2281
+ iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2282
+ x *= iframeScale.x;
2283
+ y *= iframeScale.y;
2284
+ width *= iframeScale.x;
2285
+ height *= iframeScale.y;
2286
+ x += iframeRect.x;
2287
+ y += iframeRect.y;
2288
+ currentIFrame = getWindow(currentIFrame).frameElement;
2289
+ }
2290
+ }
2291
+ return rectToClientRect({
2292
+ width,
2293
+ height,
2294
+ x,
2295
+ y
2296
+ });
2297
+ }
2298
+ function getDocumentElement(node) {
2299
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
2300
+ }
2301
+ function getNodeScroll(element) {
2302
+ if (isElement(element)) {
2303
+ return {
2304
+ scrollLeft: element.scrollLeft,
2305
+ scrollTop: element.scrollTop
2306
+ };
2307
+ }
2308
+ return {
2309
+ scrollLeft: element.pageXOffset,
2310
+ scrollTop: element.pageYOffset
2311
+ };
2312
+ }
2313
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2314
+ let {
2315
+ rect,
2316
+ offsetParent,
2317
+ strategy
2318
+ } = _ref;
2319
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2320
+ const documentElement = getDocumentElement(offsetParent);
2321
+ if (offsetParent === documentElement) {
2322
+ return rect;
2323
+ }
2324
+ let scroll = {
2325
+ scrollLeft: 0,
2326
+ scrollTop: 0
2327
+ };
2328
+ let scale = {
2329
+ x: 1,
2330
+ y: 1
2331
+ };
2332
+ const offsets = {
2333
+ x: 0,
2334
+ y: 0
2335
+ };
2336
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2337
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2338
+ scroll = getNodeScroll(offsetParent);
2339
+ }
2340
+ if (isHTMLElement(offsetParent)) {
2341
+ const offsetRect = getBoundingClientRect(offsetParent);
2342
+ scale = getScale(offsetParent);
2343
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2344
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2345
+ }
2346
+ }
2347
+ return {
2348
+ width: rect.width * scale.x,
2349
+ height: rect.height * scale.y,
2350
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2351
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2352
+ };
2353
+ }
2354
+ function getWindowScrollBarX(element) {
2355
+ // If <html> has a CSS width greater than the viewport, then this will be
2356
+ // incorrect for RTL.
2357
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2358
+ }
2359
+
2360
+ // Gets the entire size of the scrollable document area, even extending outside
2361
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2362
+ function getDocumentRect(element) {
2363
+ const html = getDocumentElement(element);
2364
+ const scroll = getNodeScroll(element);
2365
+ const body = element.ownerDocument.body;
2366
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2367
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2368
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2369
+ const y = -scroll.scrollTop;
2370
+ if (getComputedStyle$1(body).direction === 'rtl') {
2371
+ x += max(html.clientWidth, body.clientWidth) - width;
2372
+ }
2373
+ return {
2374
+ width,
2375
+ height,
2376
+ x,
2377
+ y
2378
+ };
2379
+ }
2380
+ function getParentNode(node) {
2381
+ if (getNodeName(node) === 'html') {
2382
+ return node;
2383
+ }
2384
+ const result =
2385
+ // Step into the shadow DOM of the parent of a slotted node.
2386
+ node.assignedSlot ||
2387
+ // DOM Element detected.
2388
+ node.parentNode ||
2389
+ // ShadowRoot detected.
2390
+ isShadowRoot(node) && node.host ||
2391
+ // Fallback.
2392
+ getDocumentElement(node);
2393
+ return isShadowRoot(result) ? result.host : result;
2394
+ }
2395
+ function getNearestOverflowAncestor(node) {
2396
+ const parentNode = getParentNode(node);
2397
+ if (isLastTraversableNode(parentNode)) {
2398
+ // `getParentNode` will never return a `Document` due to the fallback
2399
+ // check, so it's either the <html> or <body> element.
2400
+ return parentNode.ownerDocument.body;
2401
+ }
2402
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2403
+ return parentNode;
2404
+ }
2405
+ return getNearestOverflowAncestor(parentNode);
2406
+ }
2407
+ function getOverflowAncestors(node, list) {
2408
+ var _node$ownerDocument;
2409
+ if (list === void 0) {
2410
+ list = [];
2411
+ }
2412
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2413
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
2414
+ const win = getWindow(scrollableAncestor);
2415
+ if (isBody) {
2416
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
2417
+ }
2418
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
2419
+ }
2420
+ function getViewportRect(element, strategy) {
2421
+ const win = getWindow(element);
2422
+ const html = getDocumentElement(element);
2423
+ const visualViewport = win.visualViewport;
2424
+ let width = html.clientWidth;
2425
+ let height = html.clientHeight;
2426
+ let x = 0;
2427
+ let y = 0;
2428
+ if (visualViewport) {
2429
+ width = visualViewport.width;
2430
+ height = visualViewport.height;
2431
+ const visualViewportBased = isClientRectVisualViewportBased();
2432
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
2433
+ x = visualViewport.offsetLeft;
2434
+ y = visualViewport.offsetTop;
2435
+ }
2436
+ }
2437
+ return {
2438
+ width,
2439
+ height,
2440
+ x,
2441
+ y
2442
+ };
2443
+ }
2444
+
2445
+ // Returns the inner client rect, subtracting scrollbars if present.
2446
+ function getInnerBoundingClientRect(element, strategy) {
2447
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
2448
+ const top = clientRect.top + element.clientTop;
2449
+ const left = clientRect.left + element.clientLeft;
2450
+ const scale = isHTMLElement(element) ? getScale(element) : {
2451
+ x: 1,
2452
+ y: 1
2453
+ };
2454
+ const width = element.clientWidth * scale.x;
2455
+ const height = element.clientHeight * scale.y;
2456
+ const x = left * scale.x;
2457
+ const y = top * scale.y;
2458
+ return {
2459
+ width,
2460
+ height,
2461
+ x,
2462
+ y
2463
+ };
2464
+ }
2465
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2466
+ let rect;
2467
+ if (clippingAncestor === 'viewport') {
2468
+ rect = getViewportRect(element, strategy);
2469
+ } else if (clippingAncestor === 'document') {
2470
+ rect = getDocumentRect(getDocumentElement(element));
2471
+ } else if (isElement(clippingAncestor)) {
2472
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2473
+ } else {
2474
+ const mutableRect = {
2475
+ ...clippingAncestor
2476
+ };
2477
+ if (isClientRectVisualViewportBased()) {
2478
+ var _win$visualViewport, _win$visualViewport2;
2479
+ const win = getWindow(element);
2480
+ mutableRect.x -= ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0;
2481
+ mutableRect.y -= ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0;
2482
+ }
2483
+ rect = mutableRect;
2484
+ }
2485
+ return rectToClientRect(rect);
2486
+ }
2487
+ function hasFixedPositionAncestor(element, stopNode) {
2488
+ const parentNode = getParentNode(element);
2489
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2490
+ return false;
2491
+ }
2492
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
2493
+ }
2494
+
2495
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
2496
+ // clipping (or hiding) child elements. This returns all clipping ancestors
2497
+ // of the given element up the tree.
2498
+ function getClippingElementAncestors(element, cache) {
2499
+ const cachedResult = cache.get(element);
2500
+ if (cachedResult) {
2501
+ return cachedResult;
2502
+ }
2503
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
2504
+ let currentContainingBlockComputedStyle = null;
2505
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
2506
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2507
+
2508
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2509
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2510
+ const computedStyle = getComputedStyle$1(currentNode);
2511
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2512
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
2513
+ currentContainingBlockComputedStyle = null;
2514
+ }
2515
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2516
+ if (shouldDropCurrentNode) {
2517
+ // Drop non-containing blocks.
2518
+ result = result.filter(ancestor => ancestor !== currentNode);
2519
+ } else {
2520
+ // Record last containing block for next iteration.
2521
+ currentContainingBlockComputedStyle = computedStyle;
2522
+ }
2523
+ currentNode = getParentNode(currentNode);
2524
+ }
2525
+ cache.set(element, result);
2526
+ return result;
2527
+ }
2528
+
2529
+ // Gets the maximum area that the element is visible in due to any number of
2530
+ // clipping ancestors.
2531
+ function getClippingRect(_ref) {
2532
+ let {
2533
+ element,
2534
+ boundary,
2535
+ rootBoundary,
2536
+ strategy
2537
+ } = _ref;
2538
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
2539
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2540
+ const firstClippingAncestor = clippingAncestors[0];
2541
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2542
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2543
+ accRect.top = max(rect.top, accRect.top);
2544
+ accRect.right = min(rect.right, accRect.right);
2545
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2546
+ accRect.left = max(rect.left, accRect.left);
2547
+ return accRect;
2548
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2549
+ return {
2550
+ width: clippingRect.right - clippingRect.left,
2551
+ height: clippingRect.bottom - clippingRect.top,
2552
+ x: clippingRect.left,
2553
+ y: clippingRect.top
2554
+ };
2555
+ }
2556
+ function getDimensions(element) {
2557
+ return getCssDimensions(element);
2558
+ }
2559
+ function getTrueOffsetParent(element, polyfill) {
2560
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
2561
+ return null;
2562
+ }
2563
+ if (polyfill) {
2564
+ return polyfill(element);
2565
+ }
2566
+ return element.offsetParent;
2567
+ }
2568
+ function getContainingBlock(element) {
2569
+ let currentNode = getParentNode(element);
2570
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2571
+ if (isContainingBlock(currentNode)) {
2572
+ return currentNode;
2573
+ } else {
2574
+ currentNode = getParentNode(currentNode);
2575
+ }
2576
+ }
2577
+ return null;
2578
+ }
2579
+
2580
+ // Gets the closest ancestor positioned element. Handles some edge cases,
2581
+ // such as table ancestors and cross browser bugs.
2582
+ function getOffsetParent(element, polyfill) {
2583
+ const window = getWindow(element);
2584
+ if (!isHTMLElement(element)) {
2585
+ return window;
2586
+ }
2587
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2588
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
2589
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2590
+ }
2591
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
2592
+ return window;
2593
+ }
2594
+ return offsetParent || getContainingBlock(element) || window;
2595
+ }
2596
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2597
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2598
+ const documentElement = getDocumentElement(offsetParent);
2599
+ const rect = getBoundingClientRect(element, true, strategy === 'fixed', offsetParent);
2600
+ let scroll = {
2601
+ scrollLeft: 0,
2602
+ scrollTop: 0
2603
+ };
2604
+ const offsets = {
2605
+ x: 0,
2606
+ y: 0
2607
+ };
2608
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2609
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2610
+ scroll = getNodeScroll(offsetParent);
2611
+ }
2612
+ if (isHTMLElement(offsetParent)) {
2613
+ const offsetRect = getBoundingClientRect(offsetParent, true);
2614
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2615
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2616
+ } else if (documentElement) {
2617
+ offsets.x = getWindowScrollBarX(documentElement);
2618
+ }
2619
+ }
2620
+ return {
2621
+ x: rect.left + scroll.scrollLeft - offsets.x,
2622
+ y: rect.top + scroll.scrollTop - offsets.y,
2623
+ width: rect.width,
2624
+ height: rect.height
2625
+ };
2626
+ }
2627
+ const platform = {
2628
+ getClippingRect,
2629
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2630
+ isElement,
2631
+ getDimensions,
2632
+ getOffsetParent,
2633
+ getDocumentElement,
2634
+ getScale,
2635
+ async getElementRects(_ref) {
2636
+ let {
2637
+ reference,
2638
+ floating,
2639
+ strategy
2640
+ } = _ref;
2641
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2642
+ const getDimensionsFn = this.getDimensions;
2643
+ return {
2644
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
2645
+ floating: {
2646
+ x: 0,
2647
+ y: 0,
2648
+ ...(await getDimensionsFn(floating))
2649
+ }
2650
+ };
2651
+ },
2652
+ getClientRects: element => Array.from(element.getClientRects()),
2653
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
2654
+ };
2655
+
2656
+ /**
2657
+ * Computes the `x` and `y` coordinates that will place the floating element
2658
+ * next to a reference element when it is given a certain CSS positioning
2659
+ * strategy.
2660
+ */
2661
+ const computePosition = (reference, floating, options) => {
2662
+ // This caches the expensive `getClippingElementAncestors` function so that
2663
+ // multiple lifecycle resets re-use the same result. It only lives for a
2664
+ // single call. If other functions become expensive, we can add them as well.
2665
+ const cache = new Map();
2666
+ const mergedOptions = {
2667
+ platform,
2668
+ ...options
2669
+ };
2670
+ const platformWithCache = {
2671
+ ...mergedOptions.platform,
2672
+ _c: cache
2673
+ };
2674
+ return computePosition$1(reference, floating, {
2675
+ ...mergedOptions,
2676
+ platform: platformWithCache
2677
+ });
2678
+ };
2679
+
2680
+ /* eslint-disable max-len */
2681
+ class Tooltip {
2682
+ constructor(element) {
2683
+ this.tooltip = element;
2684
+ this.uID = uniqueId('tooltip');
2685
+ this.tooltipElement = false;
2686
+ this.arrowElement = false;
2687
+ this.tooltipContent = false;
2688
+ this.tooltipDelay = 400;
2689
+ this.screenSize = false;
2690
+ this.tooltipTheme = this.tooltip.getAttribute('data-theme') || 'dark';
2691
+ }
2692
+ init() {
2693
+ this.tooltipContent = this.tooltip.getAttribute('title');
2694
+ this.constructor.setAttributes(this.tooltip, {
2695
+ 'data-tooltip-content': this.tooltipContent,
2696
+ 'aria-describedby': this.uID,
2697
+ tabindex: '0'
2698
+ });
2699
+ this.tooltip.removeAttribute('title');
2700
+ const eventArray = ['mouseenter', 'mouseleave', 'focus', 'blur'];
2701
+ eventArray.forEach((event, _ref) => {
2702
+ let {
2703
+ listener = this.handleEvent.bind(this)
2704
+ } = _ref;
2705
+ this.tooltip.addEventListener(event, listener);
2706
+ });
2707
+ }
2708
+ handleEvent(event) {
2709
+ switch (event.type) {
2710
+ case 'mouseenter':
2711
+ case 'focus':
2712
+ this.showTooltip(this, event);
2713
+ break;
2714
+ case 'mouseleave':
2715
+ case 'blur':
2716
+ this.hideTooltip(this, event);
2717
+ break;
2718
+ default:
2719
+ console.log(`Unexpected event type: ${event.type}`);
2720
+ break;
2721
+ }
2722
+ }
2723
+ createTooltipElement() {
2724
+ if (!this.tooltipElement) {
2725
+ this.tooltipElement = document.createElement('div');
2726
+ document.body.appendChild(this.tooltipElement);
2727
+ }
2728
+ this.constructor.setAttributes(this.tooltipElement, {
2729
+ id: this.uID,
2730
+ class: `nsw-tooltip__element nsw-tooltip__element--${this.tooltipTheme}`,
2731
+ role: 'tooltip'
2732
+ });
2733
+ if (this.tooltip) {
2734
+ this.arrowElement = document.createElement('div');
2735
+ this.arrowElement.className = 'nsw-tooltip__arrow';
2736
+ }
2737
+ this.tooltipContent = this.tooltip.getAttribute('data-tooltip-content');
2738
+ this.tooltipElement.innerHTML = this.tooltipContent;
2739
+ this.tooltipElement.insertAdjacentElement('beforeend', this.arrowElement);
2740
+ }
2741
+ showTooltip() {
2742
+ setTimeout(() => {
2743
+ this.createTooltipElement();
2744
+ this.tooltipElement.classList.add('active');
2745
+ const range = document.createRange();
2746
+ const text = this.tooltipElement.childNodes[0];
2747
+ range.setStartBefore(text);
2748
+ range.setEndAfter(text);
2749
+ const clientRect = range.getBoundingClientRect();
2750
+ this.matchMedia();
2751
+ this.tooltipElement.style.width = `${clientRect.width + this.screenSize}px`;
2752
+ this.updateTooltip(this.tooltipElement, this.arrowElement);
2753
+ }, this.tooltipDelay);
2754
+ }
2755
+ hideTooltip() {
2756
+ setTimeout(() => {
2757
+ this.tooltipElement.classList.remove('active');
2758
+ this.tooltipElement.style.width = '';
2759
+ }, this.tooltipDelay);
2760
+ }
2761
+ matchMedia() {
2762
+ if (window.matchMedia('(min-width: 576px)').matches) {
2763
+ this.screenSize = 32;
2764
+ } else {
2765
+ this.screenSize = 16;
2766
+ }
2767
+ }
2768
+ updateTooltip(tooltip, arrowElement) {
2769
+ let anchor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.tooltip;
2770
+ computePosition(anchor, tooltip, {
2771
+ placement: 'top',
2772
+ middleware: [offset(8), flip(), shift({
2773
+ padding: 5
2774
+ }), arrow({
2775
+ element: arrowElement
2776
+ })]
2777
+ }).then(_ref2 => {
2778
+ let {
2779
+ x,
2780
+ y,
2781
+ placement,
2782
+ middlewareData
2783
+ } = _ref2;
2784
+ Object.assign(tooltip.style, {
2785
+ left: `${x}px`,
2786
+ top: `${y}px`
2787
+ });
2788
+
2789
+ // Accessing the data
2790
+ const {
2791
+ x: arrowX,
2792
+ y: arrowY
2793
+ } = middlewareData.arrow;
2794
+ const staticSide = {
2795
+ top: 'bottom',
2796
+ right: 'left',
2797
+ bottom: 'top',
2798
+ left: 'right'
2799
+ }[placement.split('-')[0]];
2800
+ Object.assign(arrowElement.style, {
2801
+ left: arrowX != null ? `${arrowX}px` : '',
2802
+ top: arrowY != null ? `${arrowY}px` : '',
2803
+ right: '',
2804
+ bottom: '',
2805
+ [staticSide]: '-6px'
2806
+ });
2807
+ });
2808
+ }
2809
+ static setAttributes(el, attrs) {
2810
+ Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
2811
+ }
2812
+ }
2813
+
2814
+ /* eslint-disable no-shadow */
2815
+ /* eslint-disable no-continue */
2816
+ /* eslint-disable consistent-return */
2817
+ /* eslint-disable no-script-url */
2818
+ /* eslint-disable no-restricted-syntax */
2819
+ /*!
2820
+ * Sanitize an HTML string
2821
+ * (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
2822
+ * @param {String} str The HTML string to sanitize
2823
+ * @param {Boolean} nodes If true, returns HTML nodes instead of a string
2824
+ * @return {String|NodeList} The sanitized string or nodes
2825
+ */
2826
+ function cleanHTML(str, nodes) {
2827
+ /**
2828
+ * Convert the string to an HTML document
2829
+ * @return {Node} An HTML document
2830
+ */
2831
+ function stringToHTML() {
2832
+ const parser = new DOMParser();
2833
+ const doc = parser.parseFromString(str, 'text/html');
2834
+ return doc.body || document.createElement('body');
2835
+ }
2836
+
2837
+ /**
2838
+ * Remove <script> elements
2839
+ * @param {Node} html The HTML
2840
+ */
2841
+ function removeScripts(html) {
2842
+ const scripts = html.querySelectorAll('script');
2843
+ for (const script of scripts) {
2844
+ script.remove();
2845
+ }
2846
+ }
2847
+
2848
+ /**
2849
+ * Check if the attribute is potentially dangerous
2850
+ * @param {String} name The attribute name
2851
+ * @param {String} value The attribute value
2852
+ * @return {Boolean} If true, the attribute is potentially dangerous
2853
+ */
2854
+ function isPossiblyDangerous(name, value) {
2855
+ const val = value.replace(/\s+/g, '').toLowerCase();
2856
+ if (['src', 'href', 'xlink:href'].includes(name)) {
2857
+ if (val.includes('javascript:') || val.includes('data:text/html')) return true;
2858
+ }
2859
+ if (name.startsWith('on')) return true;
2860
+ }
2861
+
2862
+ /**
2863
+ * Remove potentially dangerous attributes from an element
2864
+ * @param {Node} elem The element
2865
+ */
2866
+ function removeAttributes(elem) {
2867
+ // Loop through each attribute
2868
+ // If it's dangerous, remove it
2869
+ const atts = elem.attributes;
2870
+ for (const {
2871
+ name,
2872
+ value
2873
+ } of atts) {
2874
+ if (!isPossiblyDangerous(name, value)) continue;
2875
+ elem.removeAttribute(name);
2876
+ }
2877
+ }
2878
+
2879
+ /**
2880
+ * Remove dangerous stuff from the HTML document's nodes
2881
+ * @param {Node} html The HTML document
2882
+ */
2883
+ function clean(html) {
2884
+ const nodes = html.children;
2885
+ for (const node of nodes) {
2886
+ removeAttributes(node);
2887
+ clean(node);
2888
+ }
2889
+ }
2890
+
2891
+ // Convert the string to HTML
2892
+ const html = stringToHTML();
2893
+
2894
+ // Sanitize it
2895
+ removeScripts(html);
2896
+ clean(html);
2897
+
2898
+ // If the user wants HTML nodes back, return them
2899
+ // Otherwise, pass a sanitized string back
2900
+ return nodes ? html.childNodes : html.innerHTML;
2901
+ }
2902
+
2903
+ /* eslint-disable max-len, import/no-extraneous-dependencies */
2904
+ class Toggletip {
2905
+ constructor(element) {
2906
+ this.toggletip = element;
2907
+ this.toggletipId = this.toggletip.getAttribute('aria-controls');
2908
+ this.toggletipElement = document.querySelector(`#${this.toggletipId}`);
2909
+ this.toggletipContent = this.toggletipElement.innerHTML;
2910
+ this.toggletipText = this.toggletip.innerText;
2911
+ this.toggletipHeading = this.toggletip.getAttribute('data-title') || this.toggletipText;
2912
+ this.arrowElement = false;
2913
+ this.closeButton = false;
2914
+ this.toggletipIsOpen = false;
2915
+ this.toggletipVisibleClass = 'active';
2916
+ this.firstFocusable = false;
2917
+ this.lastFocusable = false;
2918
+ }
2919
+ init() {
2920
+ this.constructor.setAttributes(this.toggletip, {
2921
+ tabindex: '0',
2922
+ 'aria-haspopup': 'dialog'
2923
+ });
2924
+ this.initEvents();
2925
+ }
2926
+ initEvents() {
2927
+ this.toggletip.addEventListener('click', this.toggleToggletip.bind(this));
2928
+ this.toggletip.addEventListener('keyup', event => {
2929
+ if (event.code && event.code.toLowerCase() === 'enter' || event.key && event.key.toLowerCase() === 'enter') {
2930
+ this.toggleToggletip();
2931
+ }
2932
+ });
2933
+ this.toggletipElement.addEventListener('keydown', this.trapFocus.bind(this));
2934
+ window.addEventListener('click', event => {
2935
+ this.checkToggletipClick(event.target);
2936
+ });
2937
+ window.addEventListener('keyup', event => {
2938
+ if (event.code && event.code.toLowerCase() === 'escape' || event.key && event.key.toLowerCase() === 'escape') {
2939
+ this.checkToggletipFocus();
2940
+ }
2941
+ });
2942
+ window.addEventListener('resize', () => {
2943
+ if (this.toggletipIsOpen) this.toggleToggletip();
2944
+ });
2945
+ window.addEventListener('scroll', () => {
2946
+ if (this.toggletipIsOpen) this.toggleToggletip();
2947
+ });
2948
+ }
2949
+ toggleToggletip() {
2950
+ if (this.toggletipElement.classList.contains('active')) {
2951
+ this.hideToggletip();
2952
+ } else {
2953
+ this.toggletipElement.focus();
2954
+ this.showToggletip();
2955
+ }
2956
+ }
2957
+ createToggletipElement() {
2958
+ if (this.toggletipElement) {
2959
+ this.toggletipElement.innerHTML = '';
2960
+ const createToggletip = `
2961
+ <div class="nsw-toggletip__header">
2962
+ <div id="nsw-toggletip__header" class="sr-only">${cleanHTML(this.toggletipHeading)}</div>
2963
+ <button type="button" class="nsw-icon-button">
2964
+ <span class="sr-only">Remove file</span>
2965
+ <span class="material-icons nsw-material-icons" focusable="false" aria-hidden="true">close</span>
2966
+ </button>
2967
+ </div>
2968
+ <div id="nsw-toggletip__content" class="nsw-toggletip__content">
2969
+ ${cleanHTML(this.toggletipContent)}
2970
+ </div>
2971
+ <div class="nsw-toggletip__arrow"></div>`;
2972
+ this.toggletipElement.insertAdjacentHTML('afterbegin', createToggletip);
2973
+ }
2974
+ this.constructor.setAttributes(this.toggletipElement, {
2975
+ 'aria-labelledby': 'nsw-toggletip__header',
2976
+ 'aria-describedby': 'nsw-toggletip__content',
2977
+ 'aria-expanded': 'false',
2978
+ tabindex: '0',
2979
+ role: 'dialog'
2980
+ });
2981
+ }
2982
+ showToggletip() {
2983
+ this.createToggletipElement();
2984
+ this.arrowElement = this.toggletipElement.querySelector('.nsw-toggletip__arrow');
2985
+ this.closeButton = this.toggletipElement.querySelector('.nsw-icon-button');
2986
+ this.toggletipElement.setAttribute('aria-expanded', 'true');
2987
+ this.toggletipElement.classList.add('active');
2988
+ this.toggletipIsOpen = true;
2989
+ this.getFocusableElements();
2990
+ this.toggletipElement.focus({
2991
+ preventScroll: true
2992
+ });
2993
+ this.toggletip.addEventListener('transitionend', () => {
2994
+ this.focusToggletip();
2995
+ }, {
2996
+ once: true
2997
+ });
2998
+ this.updateToggletip(this.toggletipElement, this.arrowElement);
2999
+ this.closeButton.addEventListener('click', this.toggleToggletip.bind(this));
3000
+ }
3001
+ hideToggletip() {
3002
+ this.toggletipElement.setAttribute('aria-expanded', 'false');
3003
+ this.toggletipElement.classList.remove('active');
3004
+ this.toggletipIsOpen = false;
3005
+ }
3006
+ updateToggletip(toggletip, arrowElement) {
3007
+ let anchor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.toggletip;
3008
+ computePosition(anchor, toggletip, {
3009
+ placement: 'top',
3010
+ middleware: [offset(8), flip(), shift({
3011
+ padding: 5
3012
+ }), arrow({
3013
+ element: arrowElement
3014
+ })]
3015
+ }).then(_ref => {
3016
+ let {
3017
+ x,
3018
+ y,
3019
+ placement,
3020
+ middlewareData
3021
+ } = _ref;
3022
+ Object.assign(toggletip.style, {
3023
+ left: `${x}px`,
3024
+ top: `${y}px`
3025
+ });
3026
+ const {
3027
+ x: arrowX,
3028
+ y: arrowY
3029
+ } = middlewareData.arrow;
3030
+ const staticSide = {
3031
+ top: 'bottom',
3032
+ right: 'left',
3033
+ bottom: 'top',
3034
+ left: 'right'
3035
+ }[placement.split('-')[0]];
3036
+ Object.assign(arrowElement.style, {
3037
+ left: arrowX != null ? `${arrowX}px` : '',
3038
+ top: arrowY != null ? `${arrowY}px` : '',
3039
+ right: '',
3040
+ bottom: '',
3041
+ [staticSide]: '-6px'
3042
+ });
3043
+ });
3044
+ }
3045
+ checkToggletipClick(target) {
3046
+ if (!this.toggletipIsOpen) return;
3047
+ if (!this.toggletipElement.contains(target) && !target.closest(`[aria-controls="${this.toggletipId}"]`)) this.toggleToggletip();
3048
+ }
3049
+ checkToggletipFocus() {
3050
+ if (!this.toggletipIsOpen) return;
3051
+ this.constructor.moveFocus(this.toggletip);
3052
+ this.toggleToggletip();
3053
+ }
3054
+ focusToggletip() {
3055
+ if (this.firstFocusable) {
3056
+ this.firstFocusable.focus({
3057
+ preventScroll: true
3058
+ });
3059
+ } else {
3060
+ this.constructor.moveFocus(this.toggletipElement);
3061
+ }
3062
+ }
3063
+ getFocusableElements() {
3064
+ const focusableElString = '[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex]:not([tabindex="-1"]), [contenteditable], audio[controls], video[controls], summary';
3065
+ const allFocusable = this.toggletipElement.querySelectorAll(focusableElString);
3066
+ this.getFirstVisible(allFocusable);
3067
+ this.getLastVisible(allFocusable);
3068
+ }
3069
+ getFirstVisible(elements) {
3070
+ for (let i = 0; i < elements.length; i += 1) {
3071
+ if (this.constructor.isVisible(elements[i])) {
3072
+ this.firstFocusable = elements[i];
3073
+ break;
3074
+ }
3075
+ }
3076
+ }
3077
+ getLastVisible(elements) {
3078
+ for (let i = elements.length - 1; i >= 0; i -= 1) {
3079
+ if (this.constructor.isVisible(elements[i])) {
3080
+ this.lastFocusable = elements[i];
3081
+ break;
3082
+ }
3083
+ }
3084
+ }
3085
+ trapFocus(event) {
3086
+ if (this.firstFocusable === document.activeElement && event.shiftKey) {
3087
+ event.preventDefault();
3088
+ this.lastFocusable.focus();
3089
+ }
3090
+ if (this.lastFocusable === document.activeElement && !event.shiftKey) {
3091
+ event.preventDefault();
3092
+ this.firstFocusable.focus();
3093
+ }
3094
+ }
3095
+ static isVisible(element) {
3096
+ return element.offsetWidth || element.offsetHeight || element.getClientRects().length;
3097
+ }
3098
+ static moveFocus(element) {
3099
+ element.focus({
3100
+ preventScroll: true
3101
+ });
3102
+ if (document.activeElement !== element) {
3103
+ element.setAttribute('tabindex', '-1');
3104
+ element.focus();
3105
+ }
3106
+ }
3107
+ static setAttributes(el, attrs) {
3108
+ Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
3109
+ }
3110
+ }
3111
+
1400
3112
  if (window.NodeList && !NodeList.prototype.forEach) {
1401
3113
  NodeList.prototype.forEach = Array.prototype.forEach;
1402
3114
  }
@@ -1426,6 +3138,8 @@
1426
3138
  const tabs = document.querySelectorAll('.js-tabs');
1427
3139
  const globalAlert = document.querySelectorAll('.js-global-alert');
1428
3140
  const multiSelect = document.querySelectorAll('.js-multi-select');
3141
+ const tooltip = document.querySelectorAll('.js-tooltip');
3142
+ const toggletip = document.querySelectorAll('.js-toggletip');
1429
3143
  openSearchButton.forEach(element => {
1430
3144
  new SiteSearch(element).init();
1431
3145
  });
@@ -1466,6 +3180,16 @@
1466
3180
  new Select(element).init();
1467
3181
  });
1468
3182
  }
3183
+ if (tooltip) {
3184
+ tooltip.forEach(element => {
3185
+ new Tooltip(element).init();
3186
+ });
3187
+ }
3188
+ if (toggletip) {
3189
+ toggletip.forEach(element => {
3190
+ new Toggletip(element).init();
3191
+ });
3192
+ }
1469
3193
  }
1470
3194
 
1471
3195
  exports.Accordion = Accordion;
@@ -1477,6 +3201,8 @@
1477
3201
  exports.Select = Select;
1478
3202
  exports.SiteSearch = SiteSearch;
1479
3203
  exports.Tabs = Tabs;
3204
+ exports.Toggletip = Toggletip;
3205
+ exports.Tooltip = Tooltip;
1480
3206
  exports.initSite = initSite;
1481
3207
 
1482
3208
  }));