@storybook/addon-docs 10.0.0-beta.6 → 10.0.0-beta.7

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/blocks.js CHANGED
@@ -5,9 +5,6 @@ import {
5
5
  pickBy,
6
6
  uniq
7
7
  } from "./_browser-chunks/chunk-ZK6NW3SW.js";
8
- import {
9
- tocbot_default
10
- } from "./_browser-chunks/chunk-TQ5Q4DDG.js";
11
8
  import {
12
9
  EmptyBlock,
13
10
  Source,
@@ -1307,6 +1304,836 @@ var IconGallery = /* @__PURE__ */ __name(({ children, ...props }) => React9.crea
1307
1304
  import React10, { useEffect as useEffect2, useId } from "react";
1308
1305
  import { NAVIGATE_URL } from "storybook/internal/core-events";
1309
1306
  import { styled as styled8 } from "storybook/theming";
1307
+
1308
+ // ../../node_modules/tocbot/src/js/build-html.js
1309
+ function build_html_default(options) {
1310
+ const forEach = [].forEach;
1311
+ const some = [].some;
1312
+ const body = typeof window !== "undefined" && document.body;
1313
+ const SPACE_CHAR = " ";
1314
+ let tocElement;
1315
+ let currentlyHighlighting = true;
1316
+ let eventCount = 0;
1317
+ function createEl(d2, container) {
1318
+ const link = container.appendChild(createLink(d2));
1319
+ if (d2.children.length) {
1320
+ const list = createList(d2.isCollapsed);
1321
+ d2.children.forEach((child) => {
1322
+ createEl(child, list);
1323
+ });
1324
+ link.appendChild(list);
1325
+ }
1326
+ }
1327
+ __name(createEl, "createEl");
1328
+ function render(parent, data) {
1329
+ const collapsed = false;
1330
+ const container = createList(collapsed);
1331
+ data.forEach((d2) => {
1332
+ createEl(d2, container);
1333
+ });
1334
+ tocElement = parent || tocElement;
1335
+ if (tocElement === null) {
1336
+ return;
1337
+ }
1338
+ if (tocElement.firstChild) {
1339
+ tocElement.removeChild(tocElement.firstChild);
1340
+ }
1341
+ if (data.length === 0) {
1342
+ return tocElement;
1343
+ }
1344
+ return tocElement.appendChild(container);
1345
+ }
1346
+ __name(render, "render");
1347
+ function createLink(data) {
1348
+ const item = document.createElement("li");
1349
+ const a2 = document.createElement("a");
1350
+ if (options.listItemClass) {
1351
+ item.setAttribute("class", options.listItemClass);
1352
+ }
1353
+ if (options.onClick) {
1354
+ a2.onclick = options.onClick;
1355
+ }
1356
+ if (options.includeTitleTags) {
1357
+ a2.setAttribute("title", data.textContent);
1358
+ }
1359
+ if (options.includeHtml && data.childNodes.length) {
1360
+ forEach.call(data.childNodes, (node) => {
1361
+ a2.appendChild(node.cloneNode(true));
1362
+ });
1363
+ } else {
1364
+ a2.textContent = data.textContent;
1365
+ }
1366
+ a2.setAttribute("href", `${options.basePath}#${data.id}`);
1367
+ a2.setAttribute(
1368
+ "class",
1369
+ `${options.linkClass + SPACE_CHAR}node-name--${data.nodeName}${SPACE_CHAR}${options.extraLinkClasses}`
1370
+ );
1371
+ item.appendChild(a2);
1372
+ return item;
1373
+ }
1374
+ __name(createLink, "createLink");
1375
+ function createList(isCollapsed) {
1376
+ const listElement = options.orderedList ? "ol" : "ul";
1377
+ const list = document.createElement(listElement);
1378
+ let classes = options.listClass + SPACE_CHAR + options.extraListClasses;
1379
+ if (isCollapsed) {
1380
+ classes = classes + SPACE_CHAR + options.collapsibleClass;
1381
+ classes = classes + SPACE_CHAR + options.isCollapsedClass;
1382
+ }
1383
+ list.setAttribute("class", classes);
1384
+ return list;
1385
+ }
1386
+ __name(createList, "createList");
1387
+ function updateFixedSidebarClass() {
1388
+ const scrollTop = getScrollTop();
1389
+ const posFixedEl = document.querySelector(options.positionFixedSelector);
1390
+ if (options.fixedSidebarOffset === "auto") {
1391
+ options.fixedSidebarOffset = tocElement.offsetTop;
1392
+ }
1393
+ if (scrollTop > options.fixedSidebarOffset) {
1394
+ if (posFixedEl.className.indexOf(options.positionFixedClass) === -1) {
1395
+ posFixedEl.className += SPACE_CHAR + options.positionFixedClass;
1396
+ }
1397
+ } else {
1398
+ posFixedEl.className = posFixedEl.className.replace(
1399
+ SPACE_CHAR + options.positionFixedClass,
1400
+ ""
1401
+ );
1402
+ }
1403
+ }
1404
+ __name(updateFixedSidebarClass, "updateFixedSidebarClass");
1405
+ function getHeadingTopPos(obj) {
1406
+ let position = 0;
1407
+ if (obj !== null) {
1408
+ position = obj.offsetTop;
1409
+ if (options.hasInnerContainers) {
1410
+ position += getHeadingTopPos(obj.offsetParent);
1411
+ }
1412
+ }
1413
+ return position;
1414
+ }
1415
+ __name(getHeadingTopPos, "getHeadingTopPos");
1416
+ function updateClassname(obj, className) {
1417
+ if (obj && obj.className !== className) {
1418
+ obj.className = className;
1419
+ }
1420
+ return obj;
1421
+ }
1422
+ __name(updateClassname, "updateClassname");
1423
+ function updateToc(headingsArray, event) {
1424
+ if (options.positionFixedSelector) {
1425
+ updateFixedSidebarClass();
1426
+ }
1427
+ const headings = headingsArray;
1428
+ const clickedHref = event?.target?.getAttribute ? event?.target?.getAttribute("href") : null;
1429
+ const isBottomMode = clickedHref && clickedHref.charAt(0) === "#" ? getIsHeaderBottomMode(clickedHref.replace("#", "")) : false;
1430
+ const shouldUpdate = currentlyHighlighting || isBottomMode;
1431
+ if (event && eventCount < 5) {
1432
+ eventCount++;
1433
+ }
1434
+ if (shouldUpdate && !!tocElement && headings.length > 0) {
1435
+ const topHeader = getTopHeader(headings);
1436
+ const oldActiveTocLink = tocElement.querySelector(
1437
+ `.${options.activeLinkClass}`
1438
+ );
1439
+ const topHeaderId = topHeader.id.replace(
1440
+ /([ #;&,.+*~':"!^$[\]()=>|/\\@])/g,
1441
+ "\\$1"
1442
+ );
1443
+ const hashId = window.location.hash.replace("#", "");
1444
+ let activeId = topHeaderId;
1445
+ const isPageBottomMode = getIsPageBottomMode();
1446
+ if (clickedHref && isBottomMode) {
1447
+ activeId = clickedHref.replace("#", "");
1448
+ } else if (hashId && hashId !== topHeaderId && isPageBottomMode && (getIsHeaderBottomMode(topHeaderId) || eventCount <= 2)) {
1449
+ activeId = hashId;
1450
+ }
1451
+ const activeTocLink = tocElement.querySelector(
1452
+ `.${options.linkClass}[href="${options.basePath}#${activeId}"]`
1453
+ );
1454
+ if (oldActiveTocLink === activeTocLink) {
1455
+ return;
1456
+ }
1457
+ const tocLinks = tocElement.querySelectorAll(`.${options.linkClass}`);
1458
+ forEach.call(tocLinks, (tocLink) => {
1459
+ updateClassname(
1460
+ tocLink,
1461
+ tocLink.className.replace(SPACE_CHAR + options.activeLinkClass, "")
1462
+ );
1463
+ });
1464
+ const tocLis = tocElement.querySelectorAll(`.${options.listItemClass}`);
1465
+ forEach.call(tocLis, (tocLi) => {
1466
+ updateClassname(
1467
+ tocLi,
1468
+ tocLi.className.replace(SPACE_CHAR + options.activeListItemClass, "")
1469
+ );
1470
+ });
1471
+ if (activeTocLink && activeTocLink.className.indexOf(options.activeLinkClass) === -1) {
1472
+ activeTocLink.className += SPACE_CHAR + options.activeLinkClass;
1473
+ }
1474
+ const li = activeTocLink?.parentNode;
1475
+ if (li && li.className.indexOf(options.activeListItemClass) === -1) {
1476
+ li.className += SPACE_CHAR + options.activeListItemClass;
1477
+ }
1478
+ const tocLists = tocElement.querySelectorAll(
1479
+ `.${options.listClass}.${options.collapsibleClass}`
1480
+ );
1481
+ forEach.call(tocLists, (list) => {
1482
+ if (list.className.indexOf(options.isCollapsedClass) === -1) {
1483
+ list.className += SPACE_CHAR + options.isCollapsedClass;
1484
+ }
1485
+ });
1486
+ if (activeTocLink?.nextSibling && activeTocLink.nextSibling.className.indexOf(
1487
+ options.isCollapsedClass
1488
+ ) !== -1) {
1489
+ updateClassname(
1490
+ activeTocLink.nextSibling,
1491
+ activeTocLink.nextSibling.className.replace(
1492
+ SPACE_CHAR + options.isCollapsedClass,
1493
+ ""
1494
+ )
1495
+ );
1496
+ }
1497
+ removeCollapsedFromParents(activeTocLink?.parentNode.parentNode);
1498
+ }
1499
+ }
1500
+ __name(updateToc, "updateToc");
1501
+ function removeCollapsedFromParents(element) {
1502
+ if (element && element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
1503
+ updateClassname(
1504
+ element,
1505
+ element.className.replace(SPACE_CHAR + options.isCollapsedClass, "")
1506
+ );
1507
+ return removeCollapsedFromParents(element.parentNode.parentNode);
1508
+ }
1509
+ return element;
1510
+ }
1511
+ __name(removeCollapsedFromParents, "removeCollapsedFromParents");
1512
+ function disableTocAnimation(event) {
1513
+ const target = event.target || event.srcElement;
1514
+ if (typeof target.className !== "string" || target.className.indexOf(options.linkClass) === -1) {
1515
+ return;
1516
+ }
1517
+ currentlyHighlighting = false;
1518
+ }
1519
+ __name(disableTocAnimation, "disableTocAnimation");
1520
+ function enableTocAnimation() {
1521
+ currentlyHighlighting = true;
1522
+ }
1523
+ __name(enableTocAnimation, "enableTocAnimation");
1524
+ function getCurrentlyHighlighting() {
1525
+ return currentlyHighlighting;
1526
+ }
1527
+ __name(getCurrentlyHighlighting, "getCurrentlyHighlighting");
1528
+ function getIsHeaderBottomMode(headerId) {
1529
+ const scrollEl = getScrollEl();
1530
+ const activeHeading = document?.getElementById(headerId);
1531
+ const isBottomMode = activeHeading.offsetTop > scrollEl.offsetHeight - scrollEl.clientHeight * 1.4 - options.bottomModeThreshold;
1532
+ return isBottomMode;
1533
+ }
1534
+ __name(getIsHeaderBottomMode, "getIsHeaderBottomMode");
1535
+ function getIsPageBottomMode() {
1536
+ const scrollEl = getScrollEl();
1537
+ const isScrollable = scrollEl.scrollHeight > scrollEl.clientHeight;
1538
+ const isBottomMode = getScrollTop() + scrollEl.clientHeight > scrollEl.offsetHeight - options.bottomModeThreshold;
1539
+ return isScrollable && isBottomMode;
1540
+ }
1541
+ __name(getIsPageBottomMode, "getIsPageBottomMode");
1542
+ function getScrollEl() {
1543
+ let el;
1544
+ if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
1545
+ el = document.querySelector(options.scrollContainer);
1546
+ } else {
1547
+ el = document.documentElement || body;
1548
+ }
1549
+ return el;
1550
+ }
1551
+ __name(getScrollEl, "getScrollEl");
1552
+ function getScrollTop() {
1553
+ const el = getScrollEl();
1554
+ return el?.scrollTop || 0;
1555
+ }
1556
+ __name(getScrollTop, "getScrollTop");
1557
+ function getTopHeader(headings, scrollTop = getScrollTop()) {
1558
+ let topHeader;
1559
+ some.call(headings, (heading, i2) => {
1560
+ if (getHeadingTopPos(heading) > scrollTop + options.headingsOffset + 10) {
1561
+ const index = i2 === 0 ? i2 : i2 - 1;
1562
+ topHeader = headings[index];
1563
+ return true;
1564
+ }
1565
+ if (i2 === headings.length - 1) {
1566
+ topHeader = headings[headings.length - 1];
1567
+ return true;
1568
+ }
1569
+ });
1570
+ return topHeader;
1571
+ }
1572
+ __name(getTopHeader, "getTopHeader");
1573
+ function updateUrlHashForHeader(headingsArray) {
1574
+ const scrollTop = getScrollTop();
1575
+ const topHeader = getTopHeader(headingsArray, scrollTop);
1576
+ const isPageBottomMode = getIsPageBottomMode();
1577
+ if ((!topHeader || scrollTop < 5) && !isPageBottomMode) {
1578
+ if (!(window.location.hash === "#" || window.location.hash === "")) {
1579
+ window.history.pushState(null, null, "#");
1580
+ }
1581
+ } else if (topHeader && !isPageBottomMode) {
1582
+ const newHash = `#${topHeader.id}`;
1583
+ if (window.location.hash !== newHash) {
1584
+ window.history.pushState(null, null, newHash);
1585
+ }
1586
+ }
1587
+ }
1588
+ __name(updateUrlHashForHeader, "updateUrlHashForHeader");
1589
+ return {
1590
+ enableTocAnimation,
1591
+ disableTocAnimation,
1592
+ render,
1593
+ updateToc,
1594
+ getCurrentlyHighlighting,
1595
+ getTopHeader,
1596
+ getScrollTop,
1597
+ updateUrlHashForHeader
1598
+ };
1599
+ }
1600
+ __name(build_html_default, "default");
1601
+
1602
+ // ../../node_modules/tocbot/src/js/default-options.js
1603
+ var default_options_default = {
1604
+ // Where to render the table of contents.
1605
+ tocSelector: ".js-toc",
1606
+ // Or, you can pass in a DOM node instead
1607
+ tocElement: null,
1608
+ // Where to grab the headings to build the table of contents.
1609
+ contentSelector: ".js-toc-content",
1610
+ // Or, you can pass in a DOM node instead
1611
+ contentElement: null,
1612
+ // Which headings to grab inside of the contentSelector element.
1613
+ headingSelector: "h1, h2, h3",
1614
+ // Headings that match the ignoreSelector will be skipped.
1615
+ ignoreSelector: ".js-toc-ignore",
1616
+ // For headings inside relative or absolute positioned
1617
+ // containers within content.
1618
+ hasInnerContainers: false,
1619
+ // Main class to add to links.
1620
+ linkClass: "toc-link",
1621
+ // Extra classes to add to links.
1622
+ extraLinkClasses: "",
1623
+ // Class to add to active links,
1624
+ // the link corresponding to the top most heading on the page.
1625
+ activeLinkClass: "is-active-link",
1626
+ // Main class to add to lists.
1627
+ listClass: "toc-list",
1628
+ // Extra classes to add to lists.
1629
+ extraListClasses: "",
1630
+ // Class that gets added when a list should be collapsed.
1631
+ isCollapsedClass: "is-collapsed",
1632
+ // Class that gets added when a list should be able
1633
+ // to be collapsed but isn't necessarily collapsed.
1634
+ collapsibleClass: "is-collapsible",
1635
+ // Class to add to list items.
1636
+ listItemClass: "toc-list-item",
1637
+ // Class to add to active list items.
1638
+ activeListItemClass: "is-active-li",
1639
+ // How many heading levels should not be collapsed.
1640
+ // For example, number 6 will show everything since
1641
+ // there are only 6 heading levels and number 0 will collapse them all.
1642
+ // The sections that are hidden will open
1643
+ // and close as you scroll to headings within them.
1644
+ collapseDepth: 0,
1645
+ // Smooth scrolling enabled.
1646
+ scrollSmooth: true,
1647
+ // Smooth scroll duration.
1648
+ scrollSmoothDuration: 420,
1649
+ // Smooth scroll offset.
1650
+ scrollSmoothOffset: 0,
1651
+ // Callback for scroll end.
1652
+ scrollEndCallback: /* @__PURE__ */ __name(function(e2) {
1653
+ }, "scrollEndCallback"),
1654
+ // Headings offset between the headings and the top of
1655
+ // the document (this is meant for minor adjustments).
1656
+ headingsOffset: 1,
1657
+ // Enable the URL hash to update with the proper heading ID as
1658
+ // a user scrolls the page.
1659
+ enableUrlHashUpdateOnScroll: false,
1660
+ // type of scroll handler to use. to make scroll event not too rapid.
1661
+ // Options are: "debounce" or "throttle"
1662
+ // when set auto , use debounce less than 333ms , other use throttle.
1663
+ // for ios browser can't use history.pushState() more than 100 times per 30 seconds reason
1664
+ scrollHandlerType: "auto",
1665
+ // scrollHandler delay in ms.
1666
+ scrollHandlerTimeout: 50,
1667
+ // Timeout between events firing to make sure it's
1668
+ // not too rapid (for performance reasons).
1669
+ throttleTimeout: 50,
1670
+ // Element to add the positionFixedClass to.
1671
+ positionFixedSelector: null,
1672
+ // Fixed position class to add to make sidebar fixed after scrolling
1673
+ // down past the fixedSidebarOffset.
1674
+ positionFixedClass: "is-position-fixed",
1675
+ // fixedSidebarOffset can be any number but by default is set
1676
+ // to auto which sets the fixedSidebarOffset to the sidebar
1677
+ // element's offsetTop from the top of the document on init.
1678
+ fixedSidebarOffset: "auto",
1679
+ // includeHtml can be set to true to include the HTML markup from the
1680
+ // heading node instead of just including the innerText.
1681
+ includeHtml: false,
1682
+ // includeTitleTags automatically sets the html title tag of the link
1683
+ // to match the title. This can be useful for SEO purposes or
1684
+ // when truncating titles.
1685
+ includeTitleTags: false,
1686
+ // onclick function to apply to all links in toc. will be called with
1687
+ // the event as the first parameter, and this can be used to stop,
1688
+ // propagation, prevent default or perform action
1689
+ onClick: /* @__PURE__ */ __name(function(e2) {
1690
+ }, "onClick"),
1691
+ // orderedList can be set to false to generate unordered lists (ul)
1692
+ // instead of ordered lists (ol)
1693
+ orderedList: true,
1694
+ // If there is a fixed article scroll container, set to calculate offset.
1695
+ scrollContainer: null,
1696
+ // prevent ToC DOM rendering if it's already rendered by an external system.
1697
+ skipRendering: false,
1698
+ // Optional callback to change heading labels.
1699
+ // For example it can be used to cut down and put ellipses on multiline headings you deem too long.
1700
+ // Called each time a heading is parsed. Expects a string and returns the modified label to display.
1701
+ // Additionally, the attribute `data-heading-label` may be used on a heading to specify
1702
+ // a shorter string to be used in the TOC.
1703
+ // function (string) => string
1704
+ headingLabelCallback: false,
1705
+ // ignore headings that are hidden in DOM
1706
+ ignoreHiddenElements: false,
1707
+ // Optional callback to modify properties of parsed headings.
1708
+ // The heading element is passed in node parameter and information
1709
+ // parsed by default parser is provided in obj parameter.
1710
+ // Function has to return the same or modified obj.
1711
+ // The heading will be excluded from TOC if nothing is returned.
1712
+ // function (object, HTMLElement) => object | void
1713
+ headingObjectCallback: null,
1714
+ // Set the base path, useful if you use a `base` tag in `head`.
1715
+ basePath: "",
1716
+ // Only takes affect when `tocSelector` is scrolling,
1717
+ // keep the toc scroll position in sync with the content.
1718
+ disableTocScrollSync: false,
1719
+ // If this is null then just use `tocElement` or `tocSelector` instead
1720
+ // assuming `disableTocScrollSync` is set to false. This allows for
1721
+ // scrolling an outer element (like a nav panel w/ search) containing the toc.
1722
+ // Please pass an element, not a selector here.
1723
+ tocScrollingWrapper: null,
1724
+ // Offset for the toc scroll (top) position when scrolling the page.
1725
+ // Only effective if `disableTocScrollSync` is false.
1726
+ tocScrollOffset: 30,
1727
+ // Threshold for when bottom mode should be enabled to handle
1728
+ // highlighting links that cannot be scrolled to.
1729
+ bottomModeThreshold: 30
1730
+ };
1731
+
1732
+ // ../../node_modules/tocbot/src/js/parse-content.js
1733
+ function parseContent(options) {
1734
+ const reduce = [].reduce;
1735
+ function getLastItem(array2) {
1736
+ return array2[array2.length - 1];
1737
+ }
1738
+ __name(getLastItem, "getLastItem");
1739
+ function getHeadingLevel(heading) {
1740
+ return +heading.nodeName.toUpperCase().replace("H", "");
1741
+ }
1742
+ __name(getHeadingLevel, "getHeadingLevel");
1743
+ function isHTMLElement(maybeElement) {
1744
+ try {
1745
+ return maybeElement instanceof window.HTMLElement || maybeElement instanceof window.parent.HTMLElement;
1746
+ } catch (e2) {
1747
+ return maybeElement instanceof window.HTMLElement;
1748
+ }
1749
+ }
1750
+ __name(isHTMLElement, "isHTMLElement");
1751
+ function getHeadingObject(heading) {
1752
+ if (!isHTMLElement(heading)) return heading;
1753
+ if (options.ignoreHiddenElements && (!heading.offsetHeight || !heading.offsetParent)) {
1754
+ return null;
1755
+ }
1756
+ const headingLabel = heading.getAttribute("data-heading-label") || (options.headingLabelCallback ? String(options.headingLabelCallback(heading.innerText)) : (heading.innerText || heading.textContent).trim());
1757
+ const obj = {
1758
+ id: heading.id,
1759
+ children: [],
1760
+ nodeName: heading.nodeName,
1761
+ headingLevel: getHeadingLevel(heading),
1762
+ textContent: headingLabel
1763
+ };
1764
+ if (options.includeHtml) {
1765
+ obj.childNodes = heading.childNodes;
1766
+ }
1767
+ if (options.headingObjectCallback) {
1768
+ return options.headingObjectCallback(obj, heading);
1769
+ }
1770
+ return obj;
1771
+ }
1772
+ __name(getHeadingObject, "getHeadingObject");
1773
+ function addNode(node, nest) {
1774
+ const obj = getHeadingObject(node);
1775
+ const level = obj.headingLevel;
1776
+ let array2 = nest;
1777
+ let lastItem = getLastItem(array2);
1778
+ const lastItemLevel = lastItem ? lastItem.headingLevel : 0;
1779
+ let counter = level - lastItemLevel;
1780
+ while (counter > 0) {
1781
+ lastItem = getLastItem(array2);
1782
+ if (lastItem && level === lastItem.headingLevel) {
1783
+ break;
1784
+ } else if (lastItem && lastItem.children !== void 0) {
1785
+ array2 = lastItem.children;
1786
+ }
1787
+ counter--;
1788
+ }
1789
+ if (level >= options.collapseDepth) {
1790
+ obj.isCollapsed = true;
1791
+ }
1792
+ array2.push(obj);
1793
+ return array2;
1794
+ }
1795
+ __name(addNode, "addNode");
1796
+ function selectHeadings(contentElement, headingSelector) {
1797
+ let selectors = headingSelector;
1798
+ if (options.ignoreSelector) {
1799
+ selectors = headingSelector.split(",").map(/* @__PURE__ */ __name(function mapSelectors(selector) {
1800
+ return `${selector.trim()}:not(${options.ignoreSelector})`;
1801
+ }, "mapSelectors"));
1802
+ }
1803
+ try {
1804
+ return contentElement.querySelectorAll(selectors);
1805
+ } catch (e2) {
1806
+ console.warn(`Headers not found with selector: ${selectors}`);
1807
+ return null;
1808
+ }
1809
+ }
1810
+ __name(selectHeadings, "selectHeadings");
1811
+ function nestHeadingsArray(headingsArray) {
1812
+ return reduce.call(
1813
+ headingsArray,
1814
+ /* @__PURE__ */ __name(function reducer(prev, curr) {
1815
+ const currentHeading = getHeadingObject(curr);
1816
+ if (currentHeading) {
1817
+ addNode(currentHeading, prev.nest);
1818
+ }
1819
+ return prev;
1820
+ }, "reducer"),
1821
+ {
1822
+ nest: []
1823
+ }
1824
+ );
1825
+ }
1826
+ __name(nestHeadingsArray, "nestHeadingsArray");
1827
+ return {
1828
+ nestHeadingsArray,
1829
+ selectHeadings
1830
+ };
1831
+ }
1832
+ __name(parseContent, "parseContent");
1833
+
1834
+ // ../../node_modules/tocbot/src/js/scroll-smooth/index.js
1835
+ function initSmoothScrolling(options) {
1836
+ var duration = options.duration;
1837
+ var offset = options.offset;
1838
+ if (typeof window === "undefined" || typeof location === "undefined") return;
1839
+ var pageUrl = location.hash ? stripHash(location.href) : location.href;
1840
+ delegatedLinkHijacking();
1841
+ function delegatedLinkHijacking() {
1842
+ document.body.addEventListener("click", onClick, false);
1843
+ function onClick(e2) {
1844
+ if (!isInPageLink(e2.target) || e2.target.className.indexOf("no-smooth-scroll") > -1 || e2.target.href.charAt(e2.target.href.length - 2) === "#" && e2.target.href.charAt(e2.target.href.length - 1) === "!" || e2.target.className.indexOf(options.linkClass) === -1) {
1845
+ return;
1846
+ }
1847
+ jump(e2.target.hash, {
1848
+ duration,
1849
+ offset,
1850
+ callback: /* @__PURE__ */ __name(function() {
1851
+ setFocus(e2.target.hash);
1852
+ }, "callback")
1853
+ });
1854
+ }
1855
+ __name(onClick, "onClick");
1856
+ }
1857
+ __name(delegatedLinkHijacking, "delegatedLinkHijacking");
1858
+ function isInPageLink(n2) {
1859
+ return n2.tagName.toLowerCase() === "a" && (n2.hash.length > 0 || n2.href.charAt(n2.href.length - 1) === "#") && (stripHash(n2.href) === pageUrl || stripHash(n2.href) + "#" === pageUrl);
1860
+ }
1861
+ __name(isInPageLink, "isInPageLink");
1862
+ function stripHash(url) {
1863
+ return url.slice(0, url.lastIndexOf("#"));
1864
+ }
1865
+ __name(stripHash, "stripHash");
1866
+ function setFocus(hash) {
1867
+ var element = document.getElementById(hash.substring(1));
1868
+ if (element) {
1869
+ if (!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)) {
1870
+ element.tabIndex = -1;
1871
+ }
1872
+ element.focus();
1873
+ }
1874
+ }
1875
+ __name(setFocus, "setFocus");
1876
+ }
1877
+ __name(initSmoothScrolling, "initSmoothScrolling");
1878
+ function jump(target, options) {
1879
+ var start = window.pageYOffset;
1880
+ var opt = {
1881
+ duration: options.duration,
1882
+ offset: options.offset || 0,
1883
+ callback: options.callback,
1884
+ easing: options.easing || easeInOutQuad
1885
+ };
1886
+ var tgt = document.querySelector(
1887
+ '[id="' + decodeURI(target).split("#").join("") + '"]'
1888
+ ) || document.querySelector('[id="' + target.split("#").join("") + '"]');
1889
+ var distance = typeof target === "string" ? opt.offset + (target ? tgt && tgt.getBoundingClientRect().top || 0 : -(document.documentElement.scrollTop || document.body.scrollTop)) : target;
1890
+ var duration = typeof opt.duration === "function" ? opt.duration(distance) : opt.duration;
1891
+ var timeStart;
1892
+ var timeElapsed;
1893
+ requestAnimationFrame(function(time) {
1894
+ timeStart = time;
1895
+ loop(time);
1896
+ });
1897
+ function loop(time) {
1898
+ timeElapsed = time - timeStart;
1899
+ window.scrollTo(0, opt.easing(timeElapsed, start, distance, duration));
1900
+ if (timeElapsed < duration) {
1901
+ requestAnimationFrame(loop);
1902
+ } else {
1903
+ end();
1904
+ }
1905
+ }
1906
+ __name(loop, "loop");
1907
+ function end() {
1908
+ window.scrollTo(0, start + distance);
1909
+ if (typeof opt.callback === "function") {
1910
+ opt.callback();
1911
+ }
1912
+ }
1913
+ __name(end, "end");
1914
+ function easeInOutQuad(t, b2, c2, d2) {
1915
+ t /= d2 / 2;
1916
+ if (t < 1) return c2 / 2 * t * t + b2;
1917
+ t--;
1918
+ return -c2 / 2 * (t * (t - 2) - 1) + b2;
1919
+ }
1920
+ __name(easeInOutQuad, "easeInOutQuad");
1921
+ }
1922
+ __name(jump, "jump");
1923
+
1924
+ // ../../node_modules/tocbot/src/js/update-toc-scroll.js
1925
+ function updateTocScroll(options) {
1926
+ const toc = options.tocScrollingWrapper || options.tocElement || document.querySelector(options.tocSelector);
1927
+ if (toc && toc.scrollHeight > toc.clientHeight) {
1928
+ const activeItem = toc.querySelector(`.${options.activeListItemClass}`);
1929
+ if (activeItem) {
1930
+ const eTop = activeItem.offsetTop;
1931
+ const scrollAmount = eTop - options.tocScrollOffset;
1932
+ toc.scrollTop = scrollAmount > 0 ? scrollAmount : 0;
1933
+ }
1934
+ }
1935
+ }
1936
+ __name(updateTocScroll, "updateTocScroll");
1937
+
1938
+ // ../../node_modules/tocbot/src/js/index-esm.js
1939
+ var _options = {};
1940
+ var _buildHtml;
1941
+ var _parseContent;
1942
+ var _headingsArray;
1943
+ var _scrollListener;
1944
+ var clickListener;
1945
+ function init(customOptions) {
1946
+ let hasInitialized = false;
1947
+ _options = extend(default_options_default, customOptions || {});
1948
+ if (_options.scrollSmooth) {
1949
+ _options.duration = _options.scrollSmoothDuration;
1950
+ _options.offset = _options.scrollSmoothOffset;
1951
+ initSmoothScrolling(_options);
1952
+ }
1953
+ _buildHtml = build_html_default(_options);
1954
+ _parseContent = parseContent(_options);
1955
+ destroy();
1956
+ const contentElement = getContentElement(_options);
1957
+ if (contentElement === null) {
1958
+ return;
1959
+ }
1960
+ const tocElement = getTocElement(_options);
1961
+ if (tocElement === null) {
1962
+ return;
1963
+ }
1964
+ _headingsArray = _parseContent.selectHeadings(
1965
+ contentElement,
1966
+ _options.headingSelector
1967
+ );
1968
+ if (_headingsArray === null) {
1969
+ return;
1970
+ }
1971
+ const nestedHeadingsObj = _parseContent.nestHeadingsArray(_headingsArray);
1972
+ const nestedHeadings = nestedHeadingsObj.nest;
1973
+ if (!_options.skipRendering) {
1974
+ _buildHtml.render(tocElement, nestedHeadings);
1975
+ } else {
1976
+ return this;
1977
+ }
1978
+ let isClick = false;
1979
+ const scrollHandlerTimeout = _options.scrollHandlerTimeout || _options.throttleTimeout;
1980
+ const scrollHandler = /* @__PURE__ */ __name((fn, delay) => getScrollHandler(fn, delay, _options.scrollHandlerType), "scrollHandler");
1981
+ _scrollListener = scrollHandler((e2) => {
1982
+ _buildHtml.updateToc(_headingsArray, e2);
1983
+ !_options.disableTocScrollSync && !isClick && updateTocScroll(_options);
1984
+ if (_options.enableUrlHashUpdateOnScroll && hasInitialized) {
1985
+ const enableUpdatingHash = _buildHtml.getCurrentlyHighlighting();
1986
+ enableUpdatingHash && _buildHtml.updateUrlHashForHeader(_headingsArray);
1987
+ }
1988
+ const isTop = e2?.target?.scrollingElement?.scrollTop === 0;
1989
+ if (e2 && (e2.eventPhase === 0 || e2.currentTarget === null) || isTop) {
1990
+ _buildHtml.updateToc(_headingsArray);
1991
+ _options.scrollEndCallback?.(e2);
1992
+ }
1993
+ }, scrollHandlerTimeout);
1994
+ if (!hasInitialized) {
1995
+ _scrollListener();
1996
+ hasInitialized = true;
1997
+ }
1998
+ window.onhashchange = window.onscrollend = (e2) => {
1999
+ _scrollListener(e2);
2000
+ };
2001
+ if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
2002
+ document.querySelector(_options.scrollContainer).addEventListener("scroll", _scrollListener, false);
2003
+ document.querySelector(_options.scrollContainer).addEventListener("resize", _scrollListener, false);
2004
+ } else {
2005
+ document.addEventListener("scroll", _scrollListener, false);
2006
+ document.addEventListener("resize", _scrollListener, false);
2007
+ }
2008
+ let timeout = null;
2009
+ clickListener = throttle((event) => {
2010
+ isClick = true;
2011
+ if (_options.scrollSmooth) {
2012
+ _buildHtml.disableTocAnimation(event);
2013
+ }
2014
+ _buildHtml.updateToc(_headingsArray, event);
2015
+ timeout && clearTimeout(timeout);
2016
+ timeout = setTimeout(() => {
2017
+ _buildHtml.enableTocAnimation();
2018
+ }, _options.scrollSmoothDuration);
2019
+ setTimeout(() => {
2020
+ isClick = false;
2021
+ }, _options.scrollSmoothDuration + 100);
2022
+ }, _options.throttleTimeout);
2023
+ if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
2024
+ document.querySelector(_options.scrollContainer).addEventListener("click", clickListener, false);
2025
+ } else {
2026
+ document.addEventListener("click", clickListener, false);
2027
+ }
2028
+ }
2029
+ __name(init, "init");
2030
+ function destroy() {
2031
+ const tocElement = getTocElement(_options);
2032
+ if (tocElement === null) {
2033
+ return;
2034
+ }
2035
+ if (!_options.skipRendering) {
2036
+ if (tocElement) {
2037
+ tocElement.innerHTML = "";
2038
+ }
2039
+ }
2040
+ if (_options.scrollContainer && document.querySelector(_options.scrollContainer)) {
2041
+ document.querySelector(_options.scrollContainer).removeEventListener("scroll", _scrollListener, false);
2042
+ document.querySelector(_options.scrollContainer).removeEventListener("resize", _scrollListener, false);
2043
+ if (_buildHtml) {
2044
+ document.querySelector(_options.scrollContainer).removeEventListener("click", clickListener, false);
2045
+ }
2046
+ } else {
2047
+ document.removeEventListener("scroll", _scrollListener, false);
2048
+ document.removeEventListener("resize", _scrollListener, false);
2049
+ if (_buildHtml) {
2050
+ document.removeEventListener("click", clickListener, false);
2051
+ }
2052
+ }
2053
+ }
2054
+ __name(destroy, "destroy");
2055
+ function refresh(customOptions) {
2056
+ destroy();
2057
+ init(customOptions || _options);
2058
+ }
2059
+ __name(refresh, "refresh");
2060
+ var hasOwnProp = Object.prototype.hasOwnProperty;
2061
+ function extend(...args) {
2062
+ const target = {};
2063
+ for (let i2 = 0; i2 < args.length; i2++) {
2064
+ const source = args[i2];
2065
+ for (const key in source) {
2066
+ if (hasOwnProp.call(source, key)) {
2067
+ target[key] = source[key];
2068
+ }
2069
+ }
2070
+ }
2071
+ return target;
2072
+ }
2073
+ __name(extend, "extend");
2074
+ function throttle(fn, threshold, scope) {
2075
+ threshold || (threshold = 250);
2076
+ let last;
2077
+ let deferTimer;
2078
+ return function(...args) {
2079
+ const context = scope || this;
2080
+ const now = +/* @__PURE__ */ new Date();
2081
+ if (last && now < last + threshold) {
2082
+ clearTimeout(deferTimer);
2083
+ deferTimer = setTimeout(() => {
2084
+ last = now;
2085
+ fn.apply(context, args);
2086
+ }, threshold);
2087
+ } else {
2088
+ last = now;
2089
+ fn.apply(context, args);
2090
+ }
2091
+ };
2092
+ }
2093
+ __name(throttle, "throttle");
2094
+ function debounce(func, wait) {
2095
+ let timeout;
2096
+ return (...args) => {
2097
+ clearTimeout(timeout);
2098
+ timeout = setTimeout(() => func.apply(this, args), wait);
2099
+ };
2100
+ }
2101
+ __name(debounce, "debounce");
2102
+ function getScrollHandler(func, timeout, type = "auto") {
2103
+ switch (type) {
2104
+ case "debounce":
2105
+ return debounce(func, timeout);
2106
+ case "throttle":
2107
+ return throttle(func, timeout);
2108
+ default:
2109
+ return timeout < 334 ? debounce(func, timeout) : throttle(func, timeout);
2110
+ }
2111
+ }
2112
+ __name(getScrollHandler, "getScrollHandler");
2113
+ function getContentElement(options) {
2114
+ try {
2115
+ return options.contentElement || document.querySelector(options.contentSelector);
2116
+ } catch (e2) {
2117
+ console.warn(`Contents element not found: ${options.contentSelector}`);
2118
+ return null;
2119
+ }
2120
+ }
2121
+ __name(getContentElement, "getContentElement");
2122
+ function getTocElement(options) {
2123
+ try {
2124
+ return options.tocElement || document.querySelector(options.tocSelector);
2125
+ } catch (e2) {
2126
+ console.warn(`TOC element not found: ${options.tocSelector}`);
2127
+ return null;
2128
+ }
2129
+ }
2130
+ __name(getTocElement, "getTocElement");
2131
+
2132
+ // ../../node_modules/tocbot/index.js
2133
+ var tocbot = { destroy, init, refresh };
2134
+ var tocbot_default = tocbot;
2135
+
2136
+ // src/blocks/components/TableOfContents.tsx
1310
2137
  var Aside = styled8.aside(() => ({
1311
2138
  width: "10rem",
1312
2139
  "@media (max-width: 768px)": {
@@ -7473,7 +8300,7 @@ import { Code, components, nameSpaceClassNames } from "storybook/internal/compon
7473
8300
  import { NAVIGATE_URL as NAVIGATE_URL2 } from "storybook/internal/core-events";
7474
8301
  import { LinkIcon } from "@storybook/icons";
7475
8302
  import { styled as styled27 } from "storybook/theming";
7476
- var { document } = globalThis;
8303
+ var { document: document2 } = globalThis;
7477
8304
  var assertIsFn = /* @__PURE__ */ __name((val) => {
7478
8305
  if (typeof val !== "function") {
7479
8306
  throw new Error(`Expected story function, got: ${val}`);
@@ -7518,7 +8345,7 @@ var AnchorInPage = /* @__PURE__ */ __name(({ hash, children }) => {
7518
8345
  target: "_self",
7519
8346
  onClick: (event) => {
7520
8347
  const id = hash.substring(1);
7521
- const element = document.getElementById(id);
8348
+ const element = document2.getElementById(id);
7522
8349
  if (element) {
7523
8350
  navigate(context, hash);
7524
8351
  }
@@ -7598,7 +8425,7 @@ var HeaderWithOcticonAnchor = /* @__PURE__ */ __name(({
7598
8425
  tabIndex: -1,
7599
8426
  target: "_self",
7600
8427
  onClick: (event) => {
7601
- const element = document.getElementById(id);
8428
+ const element = document2.getElementById(id);
7602
8429
  if (element) {
7603
8430
  navigate(context, hash);
7604
8431
  }
@@ -7726,7 +8553,7 @@ import React53 from "react";
7726
8553
  // src/blocks/blocks/DocsContainer.tsx
7727
8554
  import React44, { useEffect as useEffect15 } from "react";
7728
8555
  import { ThemeProvider, ensure as ensureTheme } from "storybook/theming";
7729
- var { document: document2, window: globalWindow3 } = globalThis;
8556
+ var { document: document3, window: globalWindow3 } = globalThis;
7730
8557
  var DocsContainer = /* @__PURE__ */ __name(({
7731
8558
  context,
7732
8559
  theme,
@@ -7744,7 +8571,7 @@ var DocsContainer = /* @__PURE__ */ __name(({
7744
8571
  try {
7745
8572
  url = new URL(globalWindow3.parent.location.toString());
7746
8573
  if (url.hash) {
7747
- const element = document2.getElementById(decodeURIComponent(url.hash.substring(1)));
8574
+ const element = document3.getElementById(decodeURIComponent(url.hash.substring(1)));
7748
8575
  if (element) {
7749
8576
  setTimeout(() => {
7750
8577
  scrollToElement(element);
@@ -8085,7 +8912,8 @@ var _ExternalPreview = class _ExternalPreview extends Preview2 {
8085
8912
  importPath,
8086
8913
  title,
8087
8914
  name,
8088
- type: "story"
8915
+ type: "story",
8916
+ subtype: "story"
8089
8917
  };
8090
8918
  });
8091
8919
  this.onStoriesChanged({ storyIndex: this.storyIndex });