@arc-ui/community-components 3.13.0 → 3.13.1

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/lib/index.d.cts CHANGED
@@ -602,6 +602,11 @@ interface ArticleSidebarProps {
602
602
  * Sharing options for the article.
603
603
  */
604
604
  share?: Share;
605
+ /**
606
+ * The article URL used by the share buttons.
607
+ * If it is not provided, the component uses the current browser URL.
608
+ */
609
+ url?: string;
605
610
  }
606
611
 
607
612
  type ListProps = InformationCardProps;
package/lib/index.d.mts CHANGED
@@ -602,6 +602,11 @@ interface ArticleSidebarProps {
602
602
  * Sharing options for the article.
603
603
  */
604
604
  share?: Share;
605
+ /**
606
+ * The article URL used by the share buttons.
607
+ * If it is not provided, the component uses the current browser URL.
608
+ */
609
+ url?: string;
605
610
  }
606
611
 
607
612
  type ListProps = InformationCardProps;
package/lib/index.mjs CHANGED
@@ -3835,10 +3835,15 @@ var styles$e = {"tagGroup":"ArticleSidebar-module_tagGroup__rIPQc","textContent"
3835
3835
  */
3836
3836
  var ArticleSidebar = function (_a) {
3837
3837
  var _b;
3838
- var author = _a.author, aboutSection = _a.aboutSection, topics = _a.topics, share = _a.share, additionalContent = _a.additionalContent, linkSection = _a.linkSection, props = __rest(_a, ["author", "aboutSection", "topics", "share", "additionalContent", "linkSection"]);
3838
+ var author = _a.author, aboutSection = _a.aboutSection, topics = _a.topics, share = _a.share, additionalContent = _a.additionalContent, linkSection = _a.linkSection, providedUrl = _a.url, props = __rest(_a, ["author", "aboutSection", "topics", "share", "additionalContent", "linkSection", "url"]);
3839
3839
  var id = useId();
3840
3840
  var _c = useState(false), showToast = _c[0], setShowToast = _c[1];
3841
- var url = location.href;
3841
+ var _d = useState(""), clientUrl = _d[0], setClientUrl = _d[1];
3842
+ useEffect(function () {
3843
+ if (!providedUrl)
3844
+ setClientUrl(window.location.href);
3845
+ }, [providedUrl]);
3846
+ var url = providedUrl !== null && providedUrl !== void 0 ? providedUrl : clientUrl;
3842
3847
  var copyTextToClipBoard = function () { return __awaiter(void 0, void 0, void 0, function () {
3843
3848
  return __generator(this, function (_a) {
3844
3849
  switch (_a.label) {
@@ -3859,14 +3864,14 @@ var ArticleSidebar = function (_a) {
3859
3864
  ariaLabel: share.clipboardAriaLabel || "Copy url to clipboard",
3860
3865
  },
3861
3866
  {
3862
- href: "mailto:?subject=".concat(share.articleTitle, "&body=").concat(url),
3867
+ href: "mailto:?subject=".concat(encodeURIComponent(share.articleTitle), "&body=").concat(encodeURIComponent(url)),
3863
3868
  icon: BtIconEmailUnread,
3864
3869
  ariaLabel: share.emailAriaLabel || "Share by email",
3865
3870
  }
3866
3871
  ], (share.linkedin
3867
3872
  ? [
3868
3873
  {
3869
- href: "https://www.linkedin.com/sharing/share-offsite/?url=".concat(url),
3874
+ href: "https://www.linkedin.com/sharing/share-offsite/?url=".concat(encodeURIComponent(url)),
3870
3875
  icon: ArcIconSocialLinkedin,
3871
3876
  ariaLabel: share.linkedInAriaLabel || "Share on LinkedIn",
3872
3877
  },
@@ -3874,14 +3879,15 @@ var ArticleSidebar = function (_a) {
3874
3879
  : []), true), (share.x
3875
3880
  ? [
3876
3881
  {
3877
- href: "https://twitter.com/intent/tweet?url=".concat(url),
3882
+ href: "https://twitter.com/intent/tweet?url=".concat(encodeURIComponent(url)),
3878
3883
  icon: ArcIconSocialX,
3879
3884
  ariaLabel: share.xAriaLabel || "Share on x",
3880
3885
  },
3881
3886
  ]
3882
3887
  : []), true) : [];
3883
3888
  var hasTopContent = Boolean(author || aboutSection || additionalContent);
3884
- var hasBottomContent = Boolean(linkSection || topics || share);
3889
+ var showShare = share && url;
3890
+ var hasBottomContent = Boolean(linkSection || topics || showShare);
3885
3891
  return (React.createElement("div", __assign({}, filterAttrs(props)),
3886
3892
  React.createElement("div", { className: classNames((_b = {},
3887
3893
  _b[styles$e.textContent] = hasTopContent,
@@ -3909,9 +3915,9 @@ var ArticleSidebar = function (_a) {
3909
3915
  React.createElement(Heading, { level: linkSection.headingLevel }, linkSection.heading),
3910
3916
  linkSection.links.map(function (_a) {
3911
3917
  var text = _a.text, url = _a.url, ariaLabel = _a.ariaLabel;
3912
- return (React.createElement(React.Fragment, null,
3918
+ return (React.createElement(React.Fragment, { key: "".concat(id, "-").concat(url) },
3913
3919
  React.createElement(VerticalSpace, { size: "8" }),
3914
- React.createElement("div", { key: "".concat(id, "-").concat(url) },
3920
+ React.createElement("div", null,
3915
3921
  React.createElement(Link, { "aria-label": ariaLabel, size: "s", href: url }, text))));
3916
3922
  }))),
3917
3923
  topics && (React.createElement(React.Fragment, null,
@@ -3919,7 +3925,7 @@ var ArticleSidebar = function (_a) {
3919
3925
  React.createElement(Heading, { level: topics.headingLevel }, topics.heading),
3920
3926
  React.createElement(VerticalSpace, { size: "16" }),
3921
3927
  React.createElement("div", { className: styles$e.tagGroup }, topics.tags.map(function (tag) { return (React.createElement(Tag, __assign({ key: "".concat(id, "-").concat(tag.title) }, tag))); })))),
3922
- share && (React.createElement(React.Fragment, null,
3928
+ showShare && (React.createElement(React.Fragment, null,
3923
3929
  (linkSection || topics) && (React.createElement("div", { "data-testid": "links-topics-content-rule" },
3924
3930
  React.createElement(VerticalSpace, { size: "32" }),
3925
3931
  React.createElement(Rule, null),