fernwell 0.1.0 → 0.3.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/fernwell.css CHANGED
@@ -1,4 +1,4 @@
1
- /*! fernwell v0.1.0 | MIT | https://github.com/JacobKnaack/fernwell */
1
+ /*! fernwell v0.3.0 | MIT | https://github.com/JacobKnaack/fernwell */
2
2
  /* src/css/tokens.css */
3
3
  @layer fw-tokens {
4
4
  :root,
@@ -549,6 +549,15 @@ textarea.fw-input,
549
549
  .fw-checkbox input:checked + .fw-box::after {
550
550
  opacity: 1;
551
551
  }
552
+ .fw-checkbox input:indeterminate + .fw-box {
553
+ background: var(--fw-primary);
554
+ border-color: var(--fw-primary);
555
+ }
556
+ .fw-checkbox input:indeterminate + .fw-box::after {
557
+ opacity: 1;
558
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8h9' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
559
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8h9' stroke='%23000' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
560
+ }
552
561
  .fw-checkbox input:focus-visible + .fw-box {
553
562
  box-shadow: var(--fw-focus-ring);
554
563
  }
@@ -1295,8 +1304,9 @@ textarea.fw-input,
1295
1304
  }
1296
1305
  @media (max-width: 560px) {
1297
1306
  .fw-drawer {
1298
- width: 100vw;
1299
- max-width: 100vw;
1307
+ left: 0;
1308
+ width: auto;
1309
+ max-width: none;
1300
1310
  }
1301
1311
  }
1302
1312
  @media (prefers-reduced-motion: reduce) {
@@ -1493,6 +1503,158 @@ textarea.fw-input,
1493
1503
  gap: var(--fw-sp-3);
1494
1504
  }
1495
1505
 
1506
+ /* src/css/components/menu.css */
1507
+ .fw-menu {
1508
+ --fw-menu-indent: var(--fw-sp-4);
1509
+ --fw-menu-row-h: 36px;
1510
+ font-family: var(--fw-font-body);
1511
+ color: var(--fw-text);
1512
+ }
1513
+ .fw-menu-list {
1514
+ list-style: none;
1515
+ margin: 0;
1516
+ padding: 0;
1517
+ display: flex;
1518
+ flex-direction: column;
1519
+ gap: 2px;
1520
+ }
1521
+ .fw-menu-group > .fw-menu-list {
1522
+ margin: 2px 0 0 var(--fw-menu-indent);
1523
+ padding-left: var(--fw-sp-3);
1524
+ border-left: var(--fw-border-w) solid var(--fw-bg-dim);
1525
+ }
1526
+ .fw-menu-link,
1527
+ .fw-menu-summary {
1528
+ display: flex;
1529
+ align-items: center;
1530
+ gap: var(--fw-sp-2);
1531
+ min-height: var(--fw-menu-row-h);
1532
+ padding: 0 var(--fw-sp-3);
1533
+ border-radius: var(--fw-r-sm);
1534
+ color: var(--fw-text);
1535
+ font-family: var(--fw-font-body);
1536
+ font-size: 14px;
1537
+ font-weight: 600;
1538
+ line-height: 1.3;
1539
+ text-decoration: none;
1540
+ text-align: left;
1541
+ background: none;
1542
+ border: none;
1543
+ cursor: pointer;
1544
+ transition: background-color var(--fw-motion-fast) var(--fw-motion-ease), color var(--fw-motion-fast) var(--fw-motion-ease);
1545
+ }
1546
+ @media (hover: hover) {
1547
+ .fw-menu-link:hover,
1548
+ .fw-menu-summary:hover {
1549
+ background: var(--fw-bg);
1550
+ text-decoration: none;
1551
+ }
1552
+ }
1553
+ .fw-menu-link:focus-visible,
1554
+ .fw-menu-summary:focus-visible {
1555
+ outline: none;
1556
+ box-shadow: var(--fw-focus-ring);
1557
+ }
1558
+ .fw-menu-link[aria-current=page] {
1559
+ background: var(--fw-secondary-bg);
1560
+ color: var(--fw-secondary);
1561
+ }
1562
+ .fw-menu-summary.is-current {
1563
+ color: var(--fw-secondary);
1564
+ }
1565
+ .fw-menu-summary {
1566
+ list-style: none;
1567
+ user-select: none;
1568
+ }
1569
+ .fw-menu-summary::-webkit-details-marker {
1570
+ display: none;
1571
+ }
1572
+ .fw-menu-summary::after {
1573
+ content: "";
1574
+ flex-shrink: 0;
1575
+ width: 16px;
1576
+ height: 16px;
1577
+ margin-left: auto;
1578
+ background-color: currentColor;
1579
+ opacity: 0.55;
1580
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M6 4l4 4-4 4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
1581
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M6 4l4 4-4 4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
1582
+ transition: transform var(--fw-motion-fast) var(--fw-motion-ease), opacity var(--fw-motion-fast) var(--fw-motion-ease);
1583
+ }
1584
+ .fw-menu-summary:hover::after,
1585
+ .fw-menu-summary.is-current::after {
1586
+ opacity: 1;
1587
+ }
1588
+ .fw-menu-group[open] > .fw-menu-summary::after {
1589
+ transform: rotate(90deg);
1590
+ }
1591
+ .fw-menu-split {
1592
+ position: relative;
1593
+ }
1594
+ .fw-menu-split > .fw-menu-link {
1595
+ padding-right: 44px;
1596
+ }
1597
+ .fw-menu-summary-icon {
1598
+ position: absolute;
1599
+ top: 0;
1600
+ right: 0;
1601
+ width: var(--fw-menu-row-h);
1602
+ height: var(--fw-menu-row-h);
1603
+ min-height: 0;
1604
+ padding: 0;
1605
+ justify-content: center;
1606
+ }
1607
+ .fw-menu-summary-icon::after {
1608
+ margin-left: 0;
1609
+ }
1610
+ .fw-menu-panel {
1611
+ padding: var(--fw-sp-2) var(--fw-sp-3) var(--fw-sp-4);
1612
+ color: var(--fw-text-soft);
1613
+ font-size: 14px;
1614
+ line-height: 1.5;
1615
+ }
1616
+ .fw-menu-panel > :first-child {
1617
+ margin-top: 0;
1618
+ }
1619
+ .fw-menu-panel > :last-child {
1620
+ margin-bottom: 0;
1621
+ }
1622
+ .fw-menu-accordion > .fw-menu-group + .fw-menu-group {
1623
+ border-top: var(--fw-border-w) solid var(--fw-bg-dim);
1624
+ }
1625
+ .fw-menu-accordion > .fw-menu-group > .fw-menu-summary {
1626
+ min-height: 44px;
1627
+ padding-inline: 0;
1628
+ border-radius: 0;
1629
+ font-family: var(--fw-font-display);
1630
+ font-size: 15px;
1631
+ font-weight: 700;
1632
+ }
1633
+ .fw-menu-accordion > .fw-menu-group > .fw-menu-summary::after {
1634
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1635
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1636
+ }
1637
+ .fw-menu-accordion > .fw-menu-group[open] > .fw-menu-summary::after {
1638
+ transform: rotate(180deg);
1639
+ }
1640
+ @media (hover: hover) {
1641
+ .fw-menu-accordion > .fw-menu-group > .fw-menu-summary:hover {
1642
+ background: none;
1643
+ color: var(--fw-secondary);
1644
+ }
1645
+ }
1646
+ .fw-menu-accordion > .fw-menu-group > .fw-menu-summary:focus-visible {
1647
+ border-radius: 4px;
1648
+ }
1649
+ .fw-menu-accordion > .fw-menu-group > .fw-menu-panel {
1650
+ padding-inline: 0;
1651
+ }
1652
+ @media (prefers-reduced-motion: reduce) {
1653
+ .fw-menu-summary::after {
1654
+ transition: none;
1655
+ }
1656
+ }
1657
+
1496
1658
  /* src/css/components/pagination.css */
1497
1659
  .fw-pagination {
1498
1660
  display: flex;
@@ -1545,4 +1707,223 @@ textarea.fw-input,
1545
1707
  pointer-events: none;
1546
1708
  }
1547
1709
 
1710
+ /* src/css/components/table.css */
1711
+ .fw-table-wrap {
1712
+ overflow-x: auto;
1713
+ background: var(--fw-surface);
1714
+ border: var(--fw-border-w) solid var(--fw-bg-dim);
1715
+ border-radius: var(--fw-r-lg);
1716
+ box-shadow: var(--fw-shadow-sm);
1717
+ font-family: var(--fw-font-body);
1718
+ color: var(--fw-text);
1719
+ }
1720
+ .fw-table-wrap:focus-visible {
1721
+ outline: none;
1722
+ box-shadow: var(--fw-focus-ring);
1723
+ }
1724
+ .fw-table-wrap.fw-table-sticky {
1725
+ max-height: var(--fw-table-max-height, 460px);
1726
+ overflow: auto;
1727
+ }
1728
+ .fw-table-sticky .fw-table thead th {
1729
+ position: sticky;
1730
+ top: 0;
1731
+ z-index: 1;
1732
+ }
1733
+ .fw-table {
1734
+ width: 100%;
1735
+ border-collapse: separate;
1736
+ border-spacing: 0;
1737
+ font-family: var(--fw-font-body);
1738
+ font-size: 14px;
1739
+ line-height: 1.4;
1740
+ color: var(--fw-text);
1741
+ text-align: left;
1742
+ }
1743
+ .fw-table caption {
1744
+ caption-side: top;
1745
+ text-align: left;
1746
+ font-family: var(--fw-font-display);
1747
+ font-weight: 700;
1748
+ font-size: 16px;
1749
+ color: var(--fw-text);
1750
+ padding: var(--fw-sp-4) var(--fw-sp-5) var(--fw-sp-2);
1751
+ }
1752
+ .fw-table th,
1753
+ .fw-table td {
1754
+ padding: var(--fw-sp-3) var(--fw-sp-4);
1755
+ vertical-align: middle;
1756
+ }
1757
+ .fw-table th:first-child,
1758
+ .fw-table td:first-child {
1759
+ padding-left: var(--fw-sp-5);
1760
+ }
1761
+ .fw-table th:last-child,
1762
+ .fw-table td:last-child {
1763
+ padding-right: var(--fw-sp-5);
1764
+ }
1765
+ .fw-table thead th {
1766
+ font-size: 12px;
1767
+ font-weight: 700;
1768
+ letter-spacing: 0.02em;
1769
+ color: var(--fw-text-soft);
1770
+ background: var(--fw-surface);
1771
+ border-bottom: var(--fw-border-w) solid var(--fw-bg-dim);
1772
+ white-space: nowrap;
1773
+ }
1774
+ .fw-table tbody tr + tr > td {
1775
+ border-top: var(--fw-border-w) solid var(--fw-bg-dim);
1776
+ }
1777
+ .fw-table tbody td {
1778
+ transition: background-color var(--fw-motion-fast) var(--fw-motion-ease);
1779
+ }
1780
+ .fw-table-striped tbody tr:nth-child(even) > td {
1781
+ background: var(--fw-bg);
1782
+ }
1783
+ @media (hover: hover) {
1784
+ .fw-table tbody tr:hover > td {
1785
+ background: var(--fw-secondary-bg);
1786
+ }
1787
+ }
1788
+ .fw-table tbody tr.is-selected > td,
1789
+ .fw-table tbody tr[aria-selected=true] > td {
1790
+ background: var(--fw-secondary-bg);
1791
+ }
1792
+ .fw-table tbody tr.is-selected > td:first-child,
1793
+ .fw-table tbody tr[aria-selected=true] > td:first-child {
1794
+ box-shadow: inset 3px 0 0 var(--fw-secondary);
1795
+ }
1796
+ .fw-table-compact th,
1797
+ .fw-table-compact td {
1798
+ padding: var(--fw-sp-2) var(--fw-sp-3);
1799
+ font-size: 13px;
1800
+ }
1801
+ .fw-table-compact th:first-child,
1802
+ .fw-table-compact td:first-child {
1803
+ padding-left: var(--fw-sp-4);
1804
+ }
1805
+ .fw-table-compact th:last-child,
1806
+ .fw-table-compact td:last-child {
1807
+ padding-right: var(--fw-sp-4);
1808
+ }
1809
+ .fw-table-num {
1810
+ font-family: var(--fw-font-mono);
1811
+ text-align: right;
1812
+ font-variant-numeric: tabular-nums;
1813
+ white-space: nowrap;
1814
+ }
1815
+ .fw-table-num .fw-table-sort {
1816
+ flex-direction: row-reverse;
1817
+ }
1818
+ .fw-table-select {
1819
+ width: 1%;
1820
+ padding-right: 0;
1821
+ box-sizing: border-box;
1822
+ }
1823
+ .fw-table-select .fw-checkbox {
1824
+ gap: 0;
1825
+ vertical-align: middle;
1826
+ }
1827
+ .fw-table-actions {
1828
+ width: 1%;
1829
+ text-align: right;
1830
+ white-space: nowrap;
1831
+ box-sizing: border-box;
1832
+ }
1833
+ .fw-table-actions .fw-icon-btn {
1834
+ vertical-align: middle;
1835
+ }
1836
+ .fw-table-actions > * + * {
1837
+ margin-left: var(--fw-sp-1);
1838
+ }
1839
+ .fw-table-empty > td {
1840
+ text-align: center;
1841
+ padding: var(--fw-sp-7) var(--fw-sp-5);
1842
+ color: var(--fw-text-soft);
1843
+ font-family: var(--fw-font-display);
1844
+ }
1845
+ .fw-table-empty:hover > td {
1846
+ background: transparent;
1847
+ }
1848
+ .fw-table-loading > td {
1849
+ text-align: center;
1850
+ padding: var(--fw-sp-6) var(--fw-sp-5);
1851
+ }
1852
+ .fw-table[aria-busy=true] tbody,
1853
+ .fw-table.is-loading tbody {
1854
+ opacity: 0.5;
1855
+ pointer-events: none;
1856
+ transition: opacity var(--fw-motion-fast) var(--fw-motion-ease);
1857
+ }
1858
+ th[data-fw-sort] {
1859
+ cursor: pointer;
1860
+ }
1861
+ .fw-table-sort {
1862
+ display: inline-flex;
1863
+ align-items: center;
1864
+ gap: var(--fw-sp-1);
1865
+ padding: 2px 4px;
1866
+ margin: -2px -4px;
1867
+ border: 0;
1868
+ background: none;
1869
+ font: inherit;
1870
+ color: inherit;
1871
+ letter-spacing: inherit;
1872
+ cursor: pointer;
1873
+ border-radius: 6px;
1874
+ }
1875
+ th[data-fw-sort]:hover .fw-table-sort,
1876
+ th[aria-sort=ascending] .fw-table-sort,
1877
+ th[aria-sort=descending] .fw-table-sort {
1878
+ color: var(--fw-text);
1879
+ }
1880
+ .fw-table-sort:focus-visible {
1881
+ outline: none;
1882
+ box-shadow: var(--fw-focus-ring);
1883
+ }
1884
+ .fw-table-sort::after {
1885
+ content: "";
1886
+ width: 12px;
1887
+ height: 12px;
1888
+ flex-shrink: 0;
1889
+ background-color: currentColor;
1890
+ opacity: 0.35;
1891
+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M5 6.5l3-3 3 3M5 9.5l3 3 3-3' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
1892
+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M5 6.5l3-3 3 3M5 9.5l3 3 3-3' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
1893
+ transition: opacity var(--fw-motion-fast) var(--fw-motion-ease);
1894
+ }
1895
+ th[aria-sort=ascending] .fw-table-sort::after {
1896
+ opacity: 1;
1897
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 10l4-4 4 4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1898
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 10l4-4 4 4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1899
+ }
1900
+ th[aria-sort=descending] .fw-table-sort::after {
1901
+ opacity: 1;
1902
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1903
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1904
+ }
1905
+ @media (max-width: 560px) {
1906
+ .fw-table {
1907
+ table-layout: fixed;
1908
+ }
1909
+ .fw-table-select {
1910
+ width: var(--fw-table-select-w, 44px);
1911
+ }
1912
+ .fw-table-actions {
1913
+ width: var(--fw-table-actions-w, 96px);
1914
+ }
1915
+ .fw-table td:not(.fw-table-select):not(.fw-table-actions):not(.fw-table-num) {
1916
+ white-space: normal;
1917
+ overflow-wrap: anywhere;
1918
+ }
1919
+ .fw-table-num {
1920
+ overflow: hidden;
1921
+ text-overflow: ellipsis;
1922
+ }
1923
+ .fw-table th {
1924
+ overflow: hidden;
1925
+ text-overflow: ellipsis;
1926
+ }
1927
+ }
1928
+
1548
1929
  /* src/css/index.css */
@@ -1,4 +1,4 @@
1
- /*! fernwell v0.1.0 | MIT | https://github.com/JacobKnaack/fernwell */
2
- var Me=Object.defineProperty;var E=(e,t)=>{for(var n in t)Me(e,n,{get:t[n],enumerable:!0})};var N={};E(N,{get:()=>B,getToken:()=>Ce,init:()=>C,resetTokens:()=>Be,set:()=>M,setTokens:()=>Se,toggle:()=>ue});var O="fw-theme",He="fw:themechange",Ae="--fw-",le="data-fw-tokens";function S(){try{return window.localStorage}catch{return null}}function B(){var t;let e=document.documentElement.getAttribute("data-theme");return e==="dark"||e==="light"?e:(t=window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function M(e,{persist:t=!0}={}){var n;document.documentElement.setAttribute("data-theme",e),t&&((n=S())==null||n.setItem(O,e)),document.querySelectorAll("[data-fw-theme-toggle]").forEach(o=>fe(o,e)),document.dispatchEvent(new CustomEvent(He,{detail:e}))}function ue(){let e=B()==="dark"?"light":"dark";return M(e),e}function fe(e,t){e.setAttribute("aria-pressed",String(t==="dark"));let n=t==="dark"?e.dataset.fwThemeLabelDark:e.dataset.fwThemeLabelLight;n!==void 0&&(e.textContent=n)}function C(e=document){var o,s,i,a;let t=(o=S())==null?void 0:o.getItem(O),n=t==="dark"||t==="light"?t:B();M(n,{persist:!1}),e.querySelectorAll("[data-fw-theme-toggle]").forEach(u=>{u.dataset.fwBound||(u.dataset.fwBound="1",fe(u,n),u.addEventListener("click",()=>ue()))}),(a=(s=window.matchMedia)==null?void 0:(i=s.call(window,"(prefers-color-scheme: dark)")).addEventListener)==null||a.call(i,"change",u=>{var w;(w=S())!=null&&w.getItem(O)||M(u.matches?"dark":"light",{persist:!1})})}var L=new Map;function me(e){return e.startsWith("--")?e:`${Ae}${e}`}function Oe(e){return Object.values(e).some(t=>t!==null&&typeof t=="object")}function ce(e){return Object.entries(e).map(([t,n])=>`${me(t)}:${n};`).join("")}function de(e){let t=document.head.querySelector(`style[${le}]`);if(t||!e)return t;let n=document.createElement("style");return n.setAttribute(le,""),document.head.appendChild(n),n}function pe(){var t;if(L.size===0){(t=de(!1))==null||t.remove();return}let e=[];L.forEach(({light:n,dark:o},s)=>{if(Object.keys(n).length&&e.push(`${s}{${ce(n)}}`),Object.keys(o).length){let i=s===":root"?'[data-theme="dark"]':`[data-theme="dark"] ${s}, ${s}[data-theme="dark"]`;e.push(`${i}{${ce(o)}}`)}}),de(!0).textContent=e.join(`
3
- `)}function Se(e,t={}){var s,i;let n=(s=t.scope)!=null?s:":root",o=(i=L.get(n))!=null?i:{light:{},dark:{}};Oe(e)?(Object.assign(o.light,e.light),Object.assign(o.dark,e.dark)):(Object.assign(o.light,e),Object.assign(o.dark,e)),L.set(n,o),pe()}function Be(e){e?L.delete(e):L.clear(),pe()}function Ce(e,t=document.documentElement){return getComputedStyle(t).getPropertyValue(me(e)).trim()}var q={};E(q,{combobox:()=>ve,init:()=>$});var Ne=0;function x(e){return e.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function ve(e,t={}){var se,re,ie,ae;let n=(se=t.filter)!=null?se:((r,l)=>r.toLowerCase().includes(l)),o=(re=t.emptyText)!=null?re:"No matches",s=(ie=t.options)!=null?ie:$e(e),i=[],a=-1,u=!1,w=e.getAttribute("list");w&&(e.dataset.fwList=w,e.removeAttribute("list"));let X=(ae=e.closest(".fw-combobox"))!=null?ae:qe(e),c=document.createElement("ul"),A=`fw-combobox-${++Ne}`;c.className="fw-combobox-list",c.id=A,c.setAttribute("role","listbox"),X.appendChild(c),e.setAttribute("role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",A),e.autocomplete="off";function ke(r){i=r,a=-1;let l=e.value.trim().toLowerCase();if(r.length===0){c.innerHTML=`<li class="fw-combobox-empty">${x(o)}</li>`;return}c.innerHTML=r.map((f,b)=>{let g=l?f.toLowerCase().indexOf(l):-1,ye=g>-1?`${x(f.slice(0,g))}<b>${x(f.slice(g,g+l.length))}</b>${x(f.slice(g+l.length))}`:x(f);return`<li class="fw-combobox-option" role="option" id="${A}-${b}" data-index="${b}" aria-selected="false">${ye}</li>`}).join("")}function h(){let r=e.value.trim().toLowerCase();ke(r?s.filter(l=>n(l,r)):s),c.classList.add("is-open"),e.setAttribute("aria-expanded","true")}function y(){c.classList.remove("is-open"),e.setAttribute("aria-expanded","false"),e.removeAttribute("aria-activedescendant"),a=-1}function J(r){let l=c.querySelectorAll(".fw-combobox-option");l.forEach(b=>{b.classList.remove("is-active"),b.setAttribute("aria-selected","false")});let f=l[r];f&&(f.classList.add("is-active"),f.setAttribute("aria-selected","true"),f.scrollIntoView({block:"nearest"}),e.setAttribute("aria-activedescendant",f.id)),a=r}function Q(r){var l;e.value=r,y(),u=!0,e.focus(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),u=!1,(l=t.onSelect)==null||l.call(t,r)}let Z=()=>{u||h()},ee=()=>{u||h()},te=r=>{r.key==="ArrowDown"?(r.preventDefault(),c.classList.contains("is-open")||h(),J(Math.min(a+1,i.length-1))):r.key==="ArrowUp"?(r.preventDefault(),J(Math.max(a-1,0))):r.key==="Enter"?a>-1&&i[a]!==void 0&&(r.preventDefault(),Q(i[a])):r.key==="Escape"&&y()},ne=r=>{let l=r.target.closest(".fw-combobox-option");l&&(r.preventDefault(),Q(i[Number(l.dataset.index)]))},oe=r=>{X.contains(r.target)||y()};return e.addEventListener("input",Z),e.addEventListener("focus",ee),e.addEventListener("keydown",te),c.addEventListener("mousedown",ne),document.addEventListener("click",oe),{open:h,close:y,setOptions(r){s=r,c.classList.contains("is-open")&&h()},destroy(){e.removeEventListener("input",Z),e.removeEventListener("focus",ee),e.removeEventListener("keydown",te),c.removeEventListener("mousedown",ne),document.removeEventListener("click",oe),c.remove(),e.dataset.fwList&&e.setAttribute("list",e.dataset.fwList),delete e.dataset.fwBound}}}function $e(e){var o;let t=(o=e.getAttribute("list"))!=null?o:e.dataset.fwList,n=t?document.getElementById(t):null;return n?Array.from(n.querySelectorAll("option")).map(s=>s.value||s.textContent||""):[]}function qe(e){var n;let t=document.createElement("div");return t.className="fw-combobox",(n=e.parentNode)==null||n.insertBefore(t,e),t.appendChild(e),t}function $(e=document){e.querySelectorAll("input[data-fw-combobox]").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",ve(t))})}var V={};E(V,{bindOutsideClickToClose:()=>j,close:()=>m,init:()=>K,open:()=>F,toggle:()=>je});var p="is-open",Le="fw-scroll-lock",v=[],I=new WeakMap,Ie='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function P(e){return typeof e=="string"?document.getElementById(e):e}function D(e){if(e.classList.contains("fw-modal-overlay"))return e;let t=e.id?document.querySelector(`[data-fw-drawer-overlay="${e.id}"]`):null;if(t)return t;let n=e.previousElementSibling;return n instanceof HTMLElement&&n.classList.contains("fw-drawer-overlay")?n:null}function F(e,t=(n=>(n=document.activeElement)!=null?n:null)()){var i;let o=P(e);if(!o||o.classList.contains(p))return;o.classList.add(p),(i=D(o))==null||i.classList.add(p),I.set(o,t),v.push(o),document.body.classList.add(Le),o.dispatchEvent(new CustomEvent("fw:open",{bubbles:!0}));let s=o.querySelector(Ie);s?s.focus({preventScroll:!0}):(o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1"),o.focus({preventScroll:!0}))}function m(e){var o,s,i;let t=P(e);if(!t||!t.classList.contains(p))return;t.classList.remove(p),(o=D(t))==null||o.classList.remove(p);let n=v.indexOf(t);n>-1&&v.splice(n,1),v.length===0&&document.body.classList.remove(Le),t.dispatchEvent(new CustomEvent("fw:close",{bubbles:!0})),(i=(s=I.get(t))==null?void 0:s.focus)==null||i.call(s,{preventScroll:!0}),I.delete(t)}function je(e){let t=P(e);t&&(t.classList.contains(p)?m:F)(t)}function j(e,t){let n=!1;e.addEventListener("mousedown",o=>{n=o.target===e}),e.addEventListener("click",o=>{o.target===e&&n&&t()})}var Ee=!1;function K(e=document){e.querySelectorAll("[data-fw-open-modal], [data-fw-open-drawer]").forEach(t=>{var o,s;if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=(s=(o=t.dataset.fwOpenModal)!=null?o:t.dataset.fwOpenDrawer)!=null?s:"";t.addEventListener("click",()=>F(n,t))}),e.querySelectorAll(".fw-modal-overlay").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",j(t,()=>m(t)),t.querySelectorAll("[data-fw-close-modal]").forEach(n=>n.addEventListener("click",()=>m(t))))}),e.querySelectorAll(".fw-drawer").forEach(t=>{if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=D(t);n&&j(n,()=>m(t)),t.querySelectorAll("[data-fw-close-drawer]").forEach(o=>o.addEventListener("click",()=>m(t)))}),Ee||(Ee=!0,document.addEventListener("keydown",t=>{t.key==="Escape"&&v.length&&m(v[v.length-1])}))}var z={};E(z,{close:()=>H,init:()=>W,open:()=>Te});var R="is-open";function Te(e){let t=_(e);t&&(t.classList.add(R),e.setAttribute("aria-expanded","true"))}function H(e){let t=_(e);t&&(t.classList.remove(R),e.setAttribute("aria-expanded","false"))}function _(e){let t=e.getAttribute("aria-controls");return t?document.getElementById(t):null}function W(e=document){e.querySelectorAll("[data-fw-nav-toggle]").forEach(t=>{var s,i;if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=_(t);if(!n)return;let o=(i=(s=t.closest(".fw-nav"))!=null?s:t.parentElement)!=null?i:t;t.addEventListener("click",a=>{a.stopPropagation(),(n.classList.contains(R)?H:Te)(t)}),document.addEventListener("click",a=>{!o.contains(a.target)&&!n.contains(a.target)&&H(t)}),document.addEventListener("keydown",a=>{a.key==="Escape"&&H(t)})})}var U={};E(U,{init:()=>G,resetAll:()=>ge,resetButtonLoading:()=>be,setButtonLoading:()=>he});var k="fw-btn-loading";function he(e,t){var o,s;if(!e||e.classList.contains(k))return;e.dataset.fwOriginalHtml=e.innerHTML,e.disabled=!0,e.setAttribute("aria-busy","true"),e.classList.add(k);let n=(s=(o=t!=null?t:e.dataset.fwLoadingText)!=null?o:e.textContent)!=null?s:"";e.innerHTML='<span class="fw-spinner fw-spinner-sm" aria-hidden="true"></span>',e.appendChild(document.createTextNode(n))}function be(e){!e||!e.classList.contains(k)||(e.disabled=!1,e.removeAttribute("aria-busy"),e.classList.remove(k),e.dataset.fwOriginalHtml!==void 0&&(e.innerHTML=e.dataset.fwOriginalHtml,delete e.dataset.fwOriginalHtml))}function ge(e=document){e.querySelectorAll(`.${k}`).forEach(be)}var we=!1;function G(e=document){e.querySelectorAll("form[data-fw-loading]").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",t.addEventListener("submit",()=>{let n=t.querySelector('button[type="submit"], button:not([type])');he(n)}))}),we||(we=!0,window.addEventListener("pageshow",t=>{t.persisted&&ge()}))}var Y={};E(Y,{hide:()=>xe,show:()=>De});var d=null,T=null;function Pe(){return d&&d.isConnected||(d=document.createElement("div"),d.className="fw-toast",d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.innerHTML='<span class="fw-toast-dot" aria-hidden="true"></span><span class="fw-toast-text"></span>',document.body.appendChild(d)),d}function De(e,{variant:t="success",duration:n=4e3}={}){let o=Pe();return o.className=`fw-toast${t==="success"?"":` fw-toast-${t}`}`,o.querySelector(".fw-toast-text").textContent=e,T&&clearTimeout(T),o.classList.remove("is-show"),o.offsetWidth,o.classList.add("is-show"),n>0&&(T=setTimeout(xe,n)),o}function xe(){d==null||d.classList.remove("is-show"),T&&clearTimeout(T),T=null}var Fe="0.1.0";function Ke(e=document){C(e),$(e),K(e),W(e),G(e)}var Ve={version:Fe,init:Ke,theme:N,combobox:q,modal:V,nav:z,loading:U,toast:Y},_e=Ve;export{q as combobox,_e as default,Ke as init,U as loading,V as modal,z as nav,N as theme,Y as toast,Fe as version};
1
+ /*! fernwell v0.3.0 | MIT | https://github.com/JacobKnaack/fernwell */
2
+ var Xe=Object.defineProperty;var T=(e,t)=>{for(var n in t)Xe(e,n,{get:t[n],enumerable:!0})};var P={};T(P,{get:()=>$,getToken:()=>nt,init:()=>R,resetTokens:()=>tt,set:()=>S,setTokens:()=>et,toggle:()=>ye});var N="fw-theme",Je="fw:themechange",Qe="--fw-",ge="data-fw-tokens";function I(){try{return window.localStorage}catch{return null}}function $(){var t;let e=document.documentElement.getAttribute("data-theme");return e==="dark"||e==="light"?e:(t=window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches?"dark":"light"}function S(e,{persist:t=!0}={}){var n;document.documentElement.setAttribute("data-theme",e),t&&((n=I())==null||n.setItem(N,e)),document.querySelectorAll("[data-fw-theme-toggle]").forEach(o=>xe(o,e)),document.dispatchEvent(new CustomEvent(Je,{detail:e}))}function ye(){let e=$()==="dark"?"light":"dark";return S(e),e}function xe(e,t){e.setAttribute("aria-pressed",String(t==="dark"));let n=t==="dark"?e.dataset.fwThemeLabelDark:e.dataset.fwThemeLabelLight;n!==void 0&&(e.textContent=n)}function R(e=document){var o,r,s,l;let t=(o=I())==null?void 0:o.getItem(N),n=t==="dark"||t==="light"?t:$();S(n,{persist:!1}),e.querySelectorAll("[data-fw-theme-toggle]").forEach(d=>{d.dataset.fwBound||(d.dataset.fwBound="1",xe(d,n),d.addEventListener("click",()=>ye()))}),(l=(r=window.matchMedia)==null?void 0:(s=r.call(window,"(prefers-color-scheme: dark)")).addEventListener)==null||l.call(s,"change",d=>{var f;(f=I())!=null&&f.getItem(N)||S(d.matches?"dark":"light",{persist:!1})})}var b=new Map;function ke(e){return e.startsWith("--")?e:`${Qe}${e}`}function Ze(e){return Object.values(e).some(t=>t!==null&&typeof t=="object")}function Me(e){return Object.entries(e).map(([t,n])=>`${ke(t)}:${n};`).join("")}function He(e){let t=document.head.querySelector(`style[${ge}]`);if(t||!e)return t;let n=document.createElement("style");return n.setAttribute(ge,""),document.head.appendChild(n),n}function Ae(){var t;if(b.size===0){(t=He(!1))==null||t.remove();return}let e=[];b.forEach(({light:n,dark:o},r)=>{if(Object.keys(n).length&&e.push(`${r}{${Me(n)}}`),Object.keys(o).length){let s=r===":root"?'[data-theme="dark"]':`[data-theme="dark"] ${r}, ${r}[data-theme="dark"]`;e.push(`${s}{${Me(o)}}`)}}),He(!0).textContent=e.join(`
3
+ `)}function et(e,t={}){var r,s;let n=(r=t.scope)!=null?r:":root",o=(s=b.get(n))!=null?s:{light:{},dark:{}};Ze(e)?(Object.assign(o.light,e.light),Object.assign(o.dark,e.dark)):(Object.assign(o.light,e),Object.assign(o.dark,e)),b.set(n,o),Ae()}function tt(e){e?b.delete(e):b.clear(),Ae()}function nt(e,t=document.documentElement){return getComputedStyle(t).getPropertyValue(ke(e)).trim()}var K={};T(K,{combobox:()=>Se,init:()=>j});var ot=0;function x(e){return e.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Se(e,t={}){var we,ve,he,be;let n=(we=t.filter)!=null?we:((i,c)=>i.toLowerCase().includes(c)),o=(ve=t.emptyText)!=null?ve:"No matches",r=(he=t.options)!=null?he:rt(e),s=[],l=-1,d=!1,f=e.getAttribute("list");f&&(e.dataset.fwList=f,e.removeAttribute("list"));let u=(be=e.closest(".fw-combobox"))!=null?be:st(e),a=document.createElement("ul"),B=`fw-combobox-${++ot}`;a.className="fw-combobox-list",a.id=B,a.setAttribute("role","listbox"),u.appendChild(a),e.setAttribute("role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",B),e.autocomplete="off";function ze(i){s=i,l=-1;let c=e.value.trim().toLowerCase();if(i.length===0){a.innerHTML=`<li class="fw-combobox-empty">${x(o)}</li>`;return}a.innerHTML=i.map((E,H)=>{let y=c?E.toLowerCase().indexOf(c):-1,Ye=y>-1?`${x(E.slice(0,y))}<b>${x(E.slice(y,y+c.length))}</b>${x(E.slice(y+c.length))}`:x(E);return`<li class="fw-combobox-option" role="option" id="${B}-${H}" data-index="${H}" aria-selected="false">${Ye}</li>`}).join("")}function M(){let i=e.value.trim().toLowerCase();ze(i?r.filter(c=>n(c,i)):r),a.classList.add("is-open"),e.setAttribute("aria-expanded","true")}function A(){a.classList.remove("is-open"),e.setAttribute("aria-expanded","false"),e.removeAttribute("aria-activedescendant"),l=-1}function ue(i){let c=a.querySelectorAll(".fw-combobox-option");c.forEach(H=>{H.classList.remove("is-active"),H.setAttribute("aria-selected","false")});let E=c[i];E&&(E.classList.add("is-active"),E.setAttribute("aria-selected","true"),E.scrollIntoView({block:"nearest"}),e.setAttribute("aria-activedescendant",E.id)),l=i}function fe(i){var c;e.value=i,A(),d=!0,e.focus(),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),d=!1,(c=t.onSelect)==null||c.call(t,i)}let me=()=>{d||M()},Ee=()=>{d||M()},pe=i=>{i.key==="ArrowDown"?(i.preventDefault(),a.classList.contains("is-open")||M(),ue(Math.min(l+1,s.length-1))):i.key==="ArrowUp"?(i.preventDefault(),ue(Math.max(l-1,0))):i.key==="Enter"?l>-1&&s[l]!==void 0&&(i.preventDefault(),fe(s[l])):i.key==="Escape"&&A()},Te=i=>{let c=i.target.closest(".fw-combobox-option");c&&(i.preventDefault(),fe(s[Number(c.dataset.index)]))},Le=i=>{u.contains(i.target)||A()};return e.addEventListener("input",me),e.addEventListener("focus",Ee),e.addEventListener("keydown",pe),a.addEventListener("mousedown",Te),document.addEventListener("click",Le),{open:M,close:A,setOptions(i){r=i,a.classList.contains("is-open")&&M()},destroy(){e.removeEventListener("input",me),e.removeEventListener("focus",Ee),e.removeEventListener("keydown",pe),a.removeEventListener("mousedown",Te),document.removeEventListener("click",Le),a.remove(),e.dataset.fwList&&e.setAttribute("list",e.dataset.fwList),delete e.dataset.fwBound}}}function rt(e){var o;let t=(o=e.getAttribute("list"))!=null?o:e.dataset.fwList,n=t?document.getElementById(t):null;return n?Array.from(n.querySelectorAll("option")).map(r=>r.value||r.textContent||""):[]}function st(e){var n;let t=document.createElement("div");return t.className="fw-combobox",(n=e.parentNode)==null||n.insertBefore(t,e),t.appendChild(e),t}function j(e=document){e.querySelectorAll("input[data-fw-combobox]").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",Se(t))})}var z={};T(z,{bindOutsideClickToClose:()=>V,close:()=>L,init:()=>_,open:()=>W,toggle:()=>lt});var w="is-open",Ce="fw-scroll-lock",v=[],F=new WeakMap,it='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function G(e){return typeof e=="string"?document.getElementById(e):e}function U(e){if(e.classList.contains("fw-modal-overlay"))return e;let t=e.id?document.querySelector(`[data-fw-drawer-overlay="${e.id}"]`):null;if(t)return t;let n=e.previousElementSibling;return n instanceof HTMLElement&&n.classList.contains("fw-drawer-overlay")?n:null}function W(e,t=(n=>(n=document.activeElement)!=null?n:null)()){var s;let o=G(e);if(!o||o.classList.contains(w))return;o.classList.add(w),(s=U(o))==null||s.classList.add(w),F.set(o,t),v.push(o),document.body.classList.add(Ce),o.dispatchEvent(new CustomEvent("fw:open",{bubbles:!0}));let r=o.querySelector(it);r?r.focus({preventScroll:!0}):(o.hasAttribute("tabindex")||o.setAttribute("tabindex","-1"),o.focus({preventScroll:!0}))}function L(e){var o,r,s;let t=G(e);if(!t||!t.classList.contains(w))return;t.classList.remove(w),(o=U(t))==null||o.classList.remove(w);let n=v.indexOf(t);n>-1&&v.splice(n,1),v.length===0&&document.body.classList.remove(Ce),t.dispatchEvent(new CustomEvent("fw:close",{bubbles:!0})),(s=(r=F.get(t))==null?void 0:r.focus)==null||s.call(r,{preventScroll:!0}),F.delete(t)}function lt(e){let t=G(e);t&&(t.classList.contains(w)?L:W)(t)}function V(e,t){let n=!1;e.addEventListener("mousedown",o=>{n=o.target===e}),e.addEventListener("click",o=>{o.target===e&&n&&t()})}var Oe=!1;function _(e=document){e.querySelectorAll("[data-fw-open-modal], [data-fw-open-drawer]").forEach(t=>{var o,r;if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=(r=(o=t.dataset.fwOpenModal)!=null?o:t.dataset.fwOpenDrawer)!=null?r:"";t.addEventListener("click",()=>W(n,t))}),e.querySelectorAll(".fw-modal-overlay").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",V(t,()=>L(t)),t.querySelectorAll("[data-fw-close-modal]").forEach(n=>n.addEventListener("click",()=>L(t))))}),e.querySelectorAll(".fw-drawer").forEach(t=>{if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=U(t);n&&V(n,()=>L(t)),t.querySelectorAll("[data-fw-close-drawer]").forEach(o=>o.addEventListener("click",()=>L(t)))}),Oe||(Oe=!0,document.addEventListener("keydown",t=>{t.key==="Escape"&&v.length&&L(v[v.length-1])}))}var Q={};T(Q,{close:()=>O,init:()=>J,open:()=>De});var Y="is-open";function De(e){let t=X(e);t&&(t.classList.add(Y),e.setAttribute("aria-expanded","true"))}function O(e){let t=X(e);t&&(t.classList.remove(Y),e.setAttribute("aria-expanded","false"))}function X(e){let t=e.getAttribute("aria-controls");return t?document.getElementById(t):null}function J(e=document){e.querySelectorAll("[data-fw-nav-toggle]").forEach(t=>{var r,s;if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=X(t);if(!n)return;let o=(s=(r=t.closest(".fw-nav"))!=null?r:t.parentElement)!=null?s:t;t.addEventListener("click",l=>{l.stopPropagation(),(n.classList.contains(Y)?O:De)(t)}),document.addEventListener("click",l=>{!o.contains(l.target)&&!n.contains(l.target)&&O(t)}),document.addEventListener("keydown",l=>{l.key==="Escape"&&O(t)})})}var ee={};T(ee,{init:()=>Z,resetAll:()=>Ie,resetButtonLoading:()=>Ne,setButtonLoading:()=>Be});var k="fw-btn-loading";function Be(e,t){var o,r;if(!e||e.classList.contains(k))return;e.dataset.fwOriginalHtml=e.innerHTML,e.disabled=!0,e.setAttribute("aria-busy","true"),e.classList.add(k);let n=(r=(o=t!=null?t:e.dataset.fwLoadingText)!=null?o:e.textContent)!=null?r:"";e.innerHTML='<span class="fw-spinner fw-spinner-sm" aria-hidden="true"></span>',e.appendChild(document.createTextNode(n))}function Ne(e){!e||!e.classList.contains(k)||(e.disabled=!1,e.removeAttribute("aria-busy"),e.classList.remove(k),e.dataset.fwOriginalHtml!==void 0&&(e.innerHTML=e.dataset.fwOriginalHtml,delete e.dataset.fwOriginalHtml))}function Ie(e=document){e.querySelectorAll(`.${k}`).forEach(Ne)}var qe=!1;function Z(e=document){e.querySelectorAll("form[data-fw-loading]").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",t.addEventListener("submit",()=>{let n=t.querySelector('button[type="submit"], button:not([type])');Be(n)}))}),qe||(qe=!0,window.addEventListener("pageshow",t=>{t.persisted&&Ie()}))}var te={};T(te,{hide:()=>$e,show:()=>ct});var m=null,g=null;function at(){return m&&m.isConnected||(m=document.createElement("div"),m.className="fw-toast",m.setAttribute("role","status"),m.setAttribute("aria-live","polite"),m.innerHTML='<span class="fw-toast-dot" aria-hidden="true"></span><span class="fw-toast-text"></span>',document.body.appendChild(m)),m}function ct(e,{variant:t="success",duration:n=4e3}={}){let o=at();return o.className=`fw-toast${t==="success"?"":` fw-toast-${t}`}`,o.querySelector(".fw-toast-text").textContent=e,g&&clearTimeout(g),o.classList.remove("is-show"),o.offsetWidth,o.classList.add("is-show"),n>0&&(g=setTimeout($e,n)),o}function $e(){m==null||m.classList.remove("is-show"),g&&clearTimeout(g),g=null}var ae={};T(ae,{getSelected:()=>ie,init:()=>le,selectAll:()=>Fe,setRowSelected:()=>Ke,sort:()=>ne});var dt="is-selected";function oe(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))}function Re(e,t){var o,r,s;let n=e.cells[t];return(s=(r=n==null?void 0:n.dataset.fwSortValue)!=null?r:(o=n==null?void 0:n.textContent)==null?void 0:o.trim())!=null?s:""}function ut(e,t){let n=Number(e),o=Number(t);return e!==""&&t!==""&&Number.isFinite(n)&&Number.isFinite(o)?n-o:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}function je(e){var t,n;return Array.from((n=(t=e.tHead)==null?void 0:t.querySelectorAll("th[data-fw-sort]"))!=null?n:[])}function Pe(e){return e.getAttribute("aria-sort")==="ascending"?"descending":"ascending"}function ne(e,t,n){let o=e.tBodies[0];if(!o)return;let r=Array.from(o.rows),s=r.filter(u=>u.cells.length>t),l=r.filter(u=>u.cells.length<=t),d=n==="ascending"?1:-1;s.sort((u,a)=>d*ut(Re(u,t),Re(a,t))),[...s,...l].forEach(u=>o.appendChild(u));let f=null;je(e).forEach(u=>{let a=u.cellIndex===t;u.setAttribute("aria-sort",a?n:"none"),a&&(f=u)}),f&&oe(e,"fw:sort",{column:t,direction:n,th:f})}function C(e){return Array.from(e.querySelectorAll("tbody input[data-fw-select-row]"))}function re(e,t){e.classList.toggle(dt,t),e.setAttribute("aria-selected",t?"true":"false")}function se(e){let t=e.querySelector("[data-fw-select-all]");if(!t)return;let n=C(e),o=n.filter(r=>r.checked).length;t.checked=o>0&&o===n.length,t.indeterminate=o>0&&o<n.length}function ie(e){return C(e).filter(t=>t.checked).map(t=>t.closest("tr")).filter(t=>t!==null)}function Ke(e,t){let n=e.querySelector("input[data-fw-select-row]");n&&(n.checked=t),re(e,t);let o=e.closest("table");o&&(se(o),oe(o,"fw:select",{rows:ie(o),all:!1}))}function Fe(e,t){C(e).forEach(n=>{n.checked=t;let o=n.closest("tr");o&&re(o,t)}),se(e),oe(e,"fw:select",{rows:ie(e),all:!0})}function le(e=document){e.querySelectorAll("table[data-fw-table]").forEach(t=>{t.dataset.fwBound||(t.dataset.fwBound="1",je(t).forEach(n=>{n.hasAttribute("aria-sort")||n.setAttribute("aria-sort","none")}),t.addEventListener("click",n=>{let o=n.target.closest("th[data-fw-sort]");o&&t.contains(o)&&ne(t,o.cellIndex,Pe(o))}),t.addEventListener("keydown",n=>{if(n.key!=="Enter"&&n.key!==" ")return;let o=n.target;if(!o.matches("th[data-fw-sort], th[data-fw-sort] .fw-table-sort"))return;let r=o.closest("th[data-fw-sort]");r&&(n.preventDefault(),ne(t,r.cellIndex,Pe(r)))}),t.addEventListener("change",n=>{let o=n.target;if(o.matches("[data-fw-select-all]"))Fe(t,o.checked);else if(o.matches("[data-fw-select-row]")){let r=o.closest("tr");r&&Ke(r,o.checked)}}),C(t).forEach(n=>{let o=n.closest("tr");o&&n.checked&&re(o,!0)}),se(t))})}var de={};T(de,{close:()=>q,collapseAll:()=>Tt,expandAll:()=>pt,init:()=>ce,open:()=>D,reveal:()=>Ue,toggle:()=>Et});var p=".fw-menu-group",Ge=".fw-menu-link, .fw-menu-summary",ft="is-current";function mt(e,t){e.dispatchEvent(new CustomEvent("fw:toggle",{bubbles:!0,detail:t}))}function D(e){e.open=!0}function q(e){e.open=!1}function Et(e,t){e.open=t!=null?t:!e.open}function pt(e){e.querySelectorAll(p).forEach(D)}function Tt(e){e.querySelectorAll(p).forEach(q)}function Ue(e){var n,o,r,s;let t=(o=(n=e.parentElement)==null?void 0:n.closest(p))!=null?o:null;for(;t;)D(t),t=(s=(r=t.parentElement)==null?void 0:r.closest(p))!=null?s:null}function Ve(e){e.querySelectorAll(p).forEach(t=>{let n=t.querySelector(":scope > .fw-menu-summary");if(!n)return;let o=!t.open&&t.querySelector("[aria-current]")!==null;n.classList.toggle(ft,o)})}function We(e){return e.matches(".fw-menu-summary")?e.closest(p):null}function _e(e){var n,o,r;return(r=(o=((n=We(e))!=null?n:e).parentElement)==null?void 0:o.closest(p))!=null?r:null}function Lt(e){var t,n;for(let o=_e(e);o;o=(n=(t=o.parentElement)==null?void 0:t.closest(p))!=null?n:null)if(!o.open)return!1;return!0}function wt(e){return Array.from(e.querySelectorAll(Ge)).filter(Lt)}function h(e){return e?(e.focus(),!0):!1}function vt(e){var n;let t=e.closest(".fw-menu-split");return(n=t==null?void 0:t.querySelector(":scope > .fw-menu-group > .fw-menu-summary"))!=null?n:null}function ht(e,t){var d;if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return;let n=t.target instanceof HTMLElement&&t.target.matches(Ge)?t.target:null;if(!n||!e.contains(n))return;let o=wt(e),r=o.indexOf(n),s=We(n),l=!0;switch(t.key){case"ArrowDown":h(o[r+1]);break;case"ArrowUp":h(o[r-1]);break;case"Home":h(o[0]);break;case"End":h(o[o.length-1]);break;case"ArrowRight":s?s.open?s.contains((d=o[r+1])!=null?d:e)&&h(o[r+1]):D(s):h(vt(n));break;case"ArrowLeft":if(s!=null&&s.open)q(s);else{let f=_e(n);h(f==null?void 0:f.querySelector(":scope > .fw-menu-summary"))}break;default:l=!1}l&&t.preventDefault()}function ce(e=document){e.querySelectorAll("[data-fw-menu]").forEach(t=>{if(t.dataset.fwBound)return;t.dataset.fwBound="1";let n=t.hasAttribute("data-fw-menu-exclusive");t.addEventListener("toggle",o=>{let r=o.target;!(r instanceof HTMLDetailsElement)||!r.matches(p)||(n&&r.open&&r.parentElement&&Array.from(r.parentElement.children).forEach(s=>{s!==r&&s instanceof HTMLDetailsElement&&s.matches(p)&&q(s)}),Ve(t),mt(r,{group:r,open:r.open}))},!0),t.addEventListener("keydown",o=>ht(t,o)),t.querySelectorAll("[aria-current]").forEach(Ue),Ve(t)})}var bt="0.3.0";function gt(e=document){R(e),j(e),_(e),J(e),Z(e),le(e),ce(e)}var Mt={version:bt,init:gt,theme:P,combobox:K,modal:z,nav:Q,loading:ee,toast:te,table:ae,menu:de},yt=Mt;export{K as combobox,yt as default,gt as init,ee as loading,de as menu,z as modal,Q as nav,ae as table,P as theme,te as toast,bt as version};
4
4
  //# sourceMappingURL=fernwell.esm.js.map