@dialtribe/chat-client 0.5.0 → 0.5.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/dist/index.d.mts CHANGED
@@ -859,12 +859,14 @@ interface NotificationsPanelProps {
859
859
  * navigation (e.g. client-side routing); otherwise the browser goes to its url.
860
860
  */
861
861
  onOpen?: (item: NotificationItem) => boolean | void;
862
+ /** Called after a notification with a link was opened (the rail closes itself on mobile). */
863
+ onOpened?: (item: NotificationItem) => void;
862
864
  }
863
865
  /**
864
866
  * The notifications list shown in the messages rail. Usable on its own too
865
867
  * (any host panel) as long as it's under a <DialtribeChatProvider>.
866
868
  */
867
- declare function NotificationsPanel({ labels, onClose, onOpen }: NotificationsPanelProps): react.JSX.Element;
869
+ declare function NotificationsPanel({ labels, onClose, onOpen, onOpened }: NotificationsPanelProps): react.JSX.Element;
868
870
 
869
871
  interface AvatarProps {
870
872
  name: string;
package/dist/index.d.ts CHANGED
@@ -859,12 +859,14 @@ interface NotificationsPanelProps {
859
859
  * navigation (e.g. client-side routing); otherwise the browser goes to its url.
860
860
  */
861
861
  onOpen?: (item: NotificationItem) => boolean | void;
862
+ /** Called after a notification with a link was opened (the rail closes itself on mobile). */
863
+ onOpened?: (item: NotificationItem) => void;
862
864
  }
863
865
  /**
864
866
  * The notifications list shown in the messages rail. Usable on its own too
865
867
  * (any host panel) as long as it's under a <DialtribeChatProvider>.
866
868
  */
867
- declare function NotificationsPanel({ labels, onClose, onOpen }: NotificationsPanelProps): react.JSX.Element;
869
+ declare function NotificationsPanel({ labels, onClose, onOpen, onOpened }: NotificationsPanelProps): react.JSX.Element;
868
870
 
869
871
  interface AvatarProps {
870
872
  name: string;
package/dist/index.js CHANGED
@@ -1625,7 +1625,7 @@ function groupRows(items) {
1625
1625
  }
1626
1626
  return rows;
1627
1627
  }
1628
- function NotificationsPanel({ labels, onClose, onOpen }) {
1628
+ function NotificationsPanel({ labels, onClose, onOpen, onOpened }) {
1629
1629
  const n = useDialtribeNotifications();
1630
1630
  const rows = react.useMemo(() => groupRows(n.items), [n.items]);
1631
1631
  const { status, markSeen } = n;
@@ -1634,10 +1634,16 @@ function NotificationsPanel({ labels, onClose, onOpen }) {
1634
1634
  });
1635
1635
  }, [status, markSeen]);
1636
1636
  const open = (row) => {
1637
+ if (!row.lead.url) {
1638
+ if (row.unread) void n.markRead(row.ids).catch(() => {
1639
+ });
1640
+ return;
1641
+ }
1637
1642
  void n.click(row.ids).catch(() => {
1638
1643
  });
1639
1644
  const handled = onOpen?.(row.lead);
1640
- if (!handled && row.lead.url) window.location.assign(row.lead.url);
1645
+ onOpened?.(row.lead);
1646
+ if (!handled) window.location.assign(row.lead.url);
1641
1647
  };
1642
1648
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dtc-notif", children: [
1643
1649
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dtc-panel-header", children: [
@@ -1654,7 +1660,7 @@ function NotificationsPanel({ labels, onClose, onOpen }) {
1654
1660
  "button",
1655
1661
  {
1656
1662
  type: "button",
1657
- className: `dtc-notif-row ${row.unread ? "dtc-notif-row-unread" : ""}`,
1663
+ className: `dtc-notif-row ${row.unread ? "dtc-notif-row-unread" : ""} ${row.lead.url ? "" : "dtc-notif-row-static"}`,
1658
1664
  onClick: () => open(row),
1659
1665
  children: [
1660
1666
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -1792,7 +1798,17 @@ function DialtribeMessages({
1792
1798
  rollup > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dtc-badge-count dtc-badge-float", children: badgeText(rollup) })
1793
1799
  ] }),
1794
1800
  isOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dtc-messages-panel", role: "dialog", "aria-label": activeItem?.label ?? labels.messages, children: [
1795
- view.kind === "notifications" && notifications !== false ? /* @__PURE__ */ jsxRuntime.jsx(NotificationsPanel, { labels, onClose: ui.close, onOpen: notifOnOpen }) : activeItem ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dtc-item-panel", children: typeof activeItem.panel === "function" ? activeItem.panel({ close: ui.close }) : activeItem.panel }) : view.kind !== "room" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1801
+ view.kind === "notifications" && notifications !== false ? /* @__PURE__ */ jsxRuntime.jsx(
1802
+ NotificationsPanel,
1803
+ {
1804
+ labels,
1805
+ onClose: ui.close,
1806
+ onOpen: notifOnOpen,
1807
+ onOpened: () => {
1808
+ if (isMobile) ui.close();
1809
+ }
1810
+ }
1811
+ ) : activeItem ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dtc-item-panel", children: typeof activeItem.panel === "function" ? activeItem.panel({ close: ui.close }) : activeItem.panel }) : view.kind !== "room" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1796
1812
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dtc-panel-header", children: [
1797
1813
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dtc-panel-title", children: labels.messages }),
1798
1814
  /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "dtc-icon-btn", onClick: ui.close, "aria-label": labels.close, title: labels.close, children: /* @__PURE__ */ jsxRuntime.jsx(CloseIcon2, {}) })