@arc-ui/components 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -369,6 +369,10 @@ var BrandLogo = function (_a) {
369
369
  } }, filterDataAttrs(props)), label ? React.createElement("span", { className: "arc-BrandLogo-text" }, label) : null));
370
370
  };
371
371
 
372
+ /**
373
+ * Do not edit directly
374
+ * Generated file
375
+ */
372
376
  const ArcBreakpointM = 768;
373
377
  const ArcBreakpointL = 1024;
374
378
  const iconsSelected = [
@@ -1508,7 +1512,9 @@ var Panel = function (_a) {
1508
1512
  // and the click is not on a SubNavItem-link.
1509
1513
  // This ensures that one SubNavItem Panel per NavItem always remains open.
1510
1514
  (subNavItemRef &&
1511
- !e.target.classList.contains(subNavLink)) ||
1515
+ !e.target.classList.contains(subNavLink) &&
1516
+ !e.target.classList.contains("".concat(subNavLink, "Title")) &&
1517
+ !e.target.classList.contains("".concat(subNavLink, "SubTitle"))) ||
1512
1518
  // Panel is inside a SubNavItem
1513
1519
  // and the click is not inside the Panel's NavItem parent.
1514
1520
  // This prevents SubNavItem Panels in sibling NavItems from being closed.
@@ -1636,12 +1642,31 @@ var NavItemRehydrator = (function (el, hydrate) { return __awaiter(void 0, void
1636
1642
  });
1637
1643
  }); });
1638
1644
 
1645
+ /**
1646
+ * Use `Text` to display text.
1647
+ */
1648
+ var Text = function (_a) {
1649
+ var _b;
1650
+ var _c = _a.align, align = _c === void 0 ? "left" : _c, children = _a.children, _d = _a.isInline, isInline = _d === void 0 ? false : _d, _e = _a.isMeasured, isMeasured = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? "m" : _f, _g = _a.tone, tone = _g === void 0 ? "default" : _g, props = __rest(_a, ["align", "children", "isInline", "isMeasured", "size", "tone"]);
1651
+ var surface = useContext(Context$3).surface;
1652
+ return (React.createElement("span", __assign({ className: classNames((_b = {
1653
+ "arc-Text": true
1654
+ },
1655
+ _b[suffixModifier("arc-Text--align", align)] = align !== "left",
1656
+ _b["arc-Text--inline"] = isInline,
1657
+ _b["arc-Text--measured"] = isMeasured,
1658
+ _b["arc-Text--size".concat(size && size.toUpperCase())] = size && size !== "m",
1659
+ _b["arc-Text--".concat(tone)] = tone !== "default",
1660
+ _b["arc-Text--onDarkSurface"] = surface === "dark",
1661
+ _b)) }, filterDataAttrs(props)), children));
1662
+ };
1663
+
1639
1664
  var SubNavItem = function (_a) {
1640
1665
  var _b, _c;
1641
- var children = _a.children, _d = _a.isDefaultItem, isDefaultItem = _d === void 0 ? false : _d, href = _a.href, promo = _a.promo, title = _a.title, props = __rest(_a, ["children", "isDefaultItem", "href", "promo", "title"]);
1642
- var _e = useContext(Context$1), navItem = _e.navItem, subTitle = _e.subTitle;
1666
+ var children = _a.children, _d = _a.isDefaultItem, isDefaultItem = _d === void 0 ? false : _d, href = _a.href, offsetXL = _a.offsetXL, promo = _a.promo, subTitle = _a.subTitle, title = _a.title, viewAllTitle = _a.viewAllTitle, props = __rest(_a, ["children", "isDefaultItem", "href", "offsetXL", "promo", "subTitle", "title", "viewAllTitle"]);
1667
+ var navItem = useContext(Context$1).navItem;
1643
1668
  var subNavItem = useRef();
1644
- var _f = useState(false), panelOpen = _f[0], setPanelOpen = _f[1];
1669
+ var _e = useState(false), panelOpen = _e[0], setPanelOpen = _e[1];
1645
1670
  var isMinWidthArcBreakpointL = useMediaQuery("(min-width: ".concat(ArcBreakpointL, "px)"));
1646
1671
  useEffect(function () {
1647
1672
  React.Children.map(children, function (item) {
@@ -1661,52 +1686,75 @@ var SubNavItem = function (_a) {
1661
1686
  setPanelOpen(false);
1662
1687
  }
1663
1688
  }, [isDefaultItem, isMinWidthArcBreakpointL]);
1689
+ var linkTitle = (React.createElement(React.Fragment, null,
1690
+ React.createElement("span", { className: "arc-SiteHeaderSubNavItem-linkTitle" }, title),
1691
+ subTitle ? (React.createElement("span", { className: "arc-SiteHeaderSubNavItem-linkSubTitle" }, subTitle)) : null));
1664
1692
  return (React.createElement("li", __assign({ className: classNames((_b = {},
1665
1693
  _b["arc-SiteHeaderSubNavItem"] = true,
1666
1694
  _b["arc-SiteHeaderSubNavItem--linkSelected"] = children && panelOpen,
1667
- _b)), ref: subNavItem }, filterDataAttrs(props), { "data-default-item": isDefaultItem || null }), !children ? (href ? (React.createElement("a", { className: "arc-SiteHeaderSubNavItem-link", href: href }, title)) : null) : (React.createElement(React.Fragment, null,
1695
+ _b[suffixModifier("arc-SiteHeaderSubNavItem--offsetXL", offsetXL || "")] = offsetXL,
1696
+ _b)), ref: subNavItem }, filterDataAttrs(props), { "data-default-item": isDefaultItem || null }), !children ? (href ? (React.createElement("a", { className: "arc-SiteHeaderSubNavItem-link", href: href }, linkTitle)) : null) : (React.createElement(React.Fragment, null,
1668
1697
  React.createElement("button", { "aria-expanded": panelOpen, className: classNames((_c = {},
1669
1698
  _c["arc-SiteHeaderSubNavItem-link"] = true,
1670
1699
  _c["arc-SiteHeaderSubNavItem-link--itemHasChildren"] = children,
1671
1700
  _c)), onClick: function () {
1672
1701
  setPanelOpen(true);
1673
- } }, title),
1674
- React.createElement(Panel, { navItemRef: navItem, open: panelOpen, setOpen: setPanelOpen, subNavItemRef: subNavItem, subNavLink: "arc-SiteHeaderSubNavItem-link", promo: promo, title: React.createElement(React.Fragment, null,
1675
- subTitle && "".concat(subTitle, " "),
1676
- React.createElement("b", null, title)) }, children)))));
1702
+ } }, linkTitle),
1703
+ React.createElement(Panel, { navItemRef: navItem, open: panelOpen, setOpen: setPanelOpen, subNavItemRef: subNavItem, subNavLink: "arc-SiteHeaderSubNavItem-link", promo: promo, title: React.createElement("span", null,
1704
+ title,
1705
+ subTitle && (React.createElement(Text, { size: "xs", tone: "supporting" }, subTitle))), viewAll: href ? (React.createElement(Panel.ViewAll, { href: href, title: viewAllTitle || "View all ".concat(title.toLowerCase()) })) : (undefined) }, children)))));
1677
1706
  };
1678
1707
 
1679
1708
  var SubNavItemRehydrator = (function (el, hydrate) { return __awaiter(void 0, void 0, void 0, function () {
1680
- var children, promo, link, href, title, props;
1681
- return __generator(this, function (_a) {
1682
- switch (_a.label) {
1709
+ var children, promo, link, linkTitle, viewAll, href, title, offsetXL, props;
1710
+ var _a;
1711
+ return __generator(this, function (_b) {
1712
+ switch (_b.label) {
1683
1713
  case 0:
1684
1714
  children = el.querySelector(".arc-SiteHeaderPanel-items");
1685
1715
  promo = el.querySelector(".arc-SiteHeaderPanel-promo");
1686
1716
  if (!children) return [3 /*break*/, 2];
1687
1717
  return [4 /*yield*/, hydrate(children)];
1688
1718
  case 1:
1689
- children = _a.sent();
1690
- _a.label = 2;
1719
+ children = _b.sent();
1720
+ _b.label = 2;
1691
1721
  case 2:
1692
1722
  if (!promo) return [3 /*break*/, 4];
1693
1723
  return [4 /*yield*/, hydrate(promo)];
1694
1724
  case 3:
1695
- promo = _a.sent();
1696
- _a.label = 4;
1725
+ promo = _b.sent();
1726
+ _b.label = 4;
1697
1727
  case 4:
1698
1728
  link = el.querySelector(".arc-SiteHeaderSubNavItem-link");
1729
+ linkTitle = el.querySelector(".arc-SiteHeaderSubNavItem-linkTitle");
1730
+ viewAll = el.querySelector(".arc-SiteHeaderPanel-viewAll");
1699
1731
  href = "";
1700
1732
  title = "";
1701
1733
  if (link) {
1702
1734
  href = link.getAttribute("href") || /* istanbul ignore next */ "";
1703
- title = link.textContent || /* istanbul ignore next */ "";
1735
+ }
1736
+ if (linkTitle) {
1737
+ title = linkTitle.textContent || /* istanbul ignore next */ "";
1738
+ }
1739
+ if (viewAll) {
1740
+ href = viewAll.getAttribute("href") || /* istanbul ignore next */ "";
1741
+ }
1742
+ offsetXL = undefined;
1743
+ if (el.classList.contains("arc-SiteHeaderSubNavItem--offsetXL24")) {
1744
+ offsetXL = "24";
1745
+ }
1746
+ if (el.classList.contains("arc-SiteHeaderSubNavItem--offsetXL48")) {
1747
+ offsetXL = "48";
1704
1748
  }
1705
1749
  props = {
1706
1750
  href: href,
1707
1751
  isDefaultItem: Boolean(el.dataset.defaultItem),
1752
+ offsetXL: offsetXL,
1708
1753
  promo: promo || undefined,
1709
- title: title
1754
+ subTitle: ((_a = el.querySelector(".arc-SiteHeaderSubNavItem-linkSubTitle")) === null || _a === void 0 ? void 0 : _a.textContent) ||
1755
+ undefined,
1756
+ title: title,
1757
+ viewAllTitle: (viewAll === null || viewAll === void 0 ? void 0 : viewAll.textContent) || undefined
1710
1758
  };
1711
1759
  return [2 /*return*/, React.createElement(SubNavItem, __assign({}, props), children)];
1712
1760
  }
@@ -1773,7 +1821,7 @@ function wrap(el, wrapper) {
1773
1821
  wrapper.appendChild(el);
1774
1822
  }
1775
1823
  var NavItemWithSubNavRehydrator = (function (el, hydrate) { return __awaiter(void 0, void 0, void 0, function () {
1776
- var subNavItem1, subNavItem2, subNavItem3, div1, div2, slot1, slot2, slot3, div3, link, subTitle, viewAll, title, props;
1824
+ var subNavItem1, subNavItem2, subNavItem3, div1, div2, slot1, slot2, slot3, div3, link, subTitle, viewAllNodes, viewAll, title, props;
1777
1825
  return __generator(this, function (_a) {
1778
1826
  switch (_a.label) {
1779
1827
  case 0:
@@ -1803,7 +1851,8 @@ var NavItemWithSubNavRehydrator = (function (el, hydrate) { return __awaiter(voi
1803
1851
  case 4:
1804
1852
  link = el.querySelector(".arc-SiteHeaderNavItem-link");
1805
1853
  subTitle = el.querySelector(".arc-SiteHeaderPanel-title");
1806
- viewAll = el.querySelector(".arc-SiteHeaderPanel-viewAll");
1854
+ viewAllNodes = el.querySelectorAll(".arc-SiteHeaderPanel-viewAll");
1855
+ viewAll = viewAllNodes[viewAllNodes.length - 1];
1807
1856
  title = "";
1808
1857
  if (link) {
1809
1858
  title = link.textContent || /* istanbul ignore next */ "";
@@ -1970,25 +2019,6 @@ SiteHeaderRehydrator.NavItemRehydrator = NavItemRehydrator;
1970
2019
  SiteHeaderRehydrator.NavItemWithSubNavRehydrator = NavItemWithSubNavRehydrator;
1971
2020
  SiteHeaderRehydrator.SubNavItemRehydrator = SubNavItemRehydrator;
1972
2021
 
1973
- /**
1974
- * Use `Text` to display text.
1975
- */
1976
- var Text = function (_a) {
1977
- var _b;
1978
- var _c = _a.align, align = _c === void 0 ? "left" : _c, children = _a.children, _d = _a.isInline, isInline = _d === void 0 ? false : _d, _e = _a.isMeasured, isMeasured = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? "m" : _f, _g = _a.tone, tone = _g === void 0 ? "default" : _g, props = __rest(_a, ["align", "children", "isInline", "isMeasured", "size", "tone"]);
1979
- var surface = useContext(Context$3).surface;
1980
- return (React.createElement("span", __assign({ className: classNames((_b = {
1981
- "arc-Text": true
1982
- },
1983
- _b[suffixModifier("arc-Text--align", align)] = align !== "left",
1984
- _b["arc-Text--inline"] = isInline,
1985
- _b["arc-Text--measured"] = isMeasured,
1986
- _b["arc-Text--size".concat(size && size.toUpperCase())] = size && size !== "m",
1987
- _b["arc-Text--".concat(tone)] = tone !== "default",
1988
- _b["arc-Text--onDarkSurface"] = surface === "dark",
1989
- _b)) }, filterDataAttrs(props)), children));
1990
- };
1991
-
1992
2022
  /**
1993
2023
  * Use `TextInput` to allow custom user text entry with a keyboard.
1994
2024
  */