wealth-alpha-chat-widget 2.0.7 → 2.0.9

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.cjs CHANGED
@@ -712,6 +712,7 @@ var chat_default = {
712
712
  chipRow: "chat_chipRow",
713
713
  chip: "chat_chip",
714
714
  chipIcon: "chat_chipIcon",
715
+ chipMain: "chat_chipMain",
715
716
  chipActive: "chat_chipActive",
716
717
  chipDisabled: "chat_chipDisabled",
717
718
  typing: "chat_typing",
@@ -777,21 +778,41 @@ function AuthGate({ brandName, loginUrl, onLoginClick }) {
777
778
  }
778
779
  var HOME_ICON = '<path d="m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/>';
779
780
  var BACK_ICON = '<line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/>';
781
+ var PREV_ICON = '<polyline points="15 18 9 12 15 6"/>';
782
+ var NEXT_ICON = '<polyline points="9 18 15 12 9 6"/>';
780
783
  var EMOJI_RE = /[\u{1F000}-\u{1FAFF}\u{2190}-\u{21FF}\u{2300}-\u{27BF}\u{2B00}-\u{2BFF}\u{FE00}-\u{FE0F}\u{1F1E6}-\u{1F1FF}\u{20E3}]/gu;
781
784
  var stripEmoji = (s) => s.replace(EMOJI_RE, "").replace(/\s{2,}/g, " ").trim();
782
785
  function navIconFor(chip) {
783
- if (chip.id === "__root__") return HOME_ICON;
784
- if (chip.label.trim() === "Back") return BACK_ICON;
786
+ if (chip.id === "__root__") return { svg: HOME_ICON, trailing: false };
787
+ if (chip.label.trim() === "Back") return { svg: BACK_ICON, trailing: false };
788
+ if (chip.id.includes("_page:")) {
789
+ const isPrev = /prev/i.test(chip.label);
790
+ return { svg: isPrev ? PREV_ICON : NEXT_ICON, trailing: !isPrev };
791
+ }
785
792
  return null;
786
793
  }
787
794
  function Chip({ chip, disabled, active, onClick }) {
795
+ const isMainMenu = chip.id === "__root__";
788
796
  const classes = [
789
797
  chat_default.chip,
798
+ isMainMenu ? chat_default.chipMain : "",
790
799
  active ? chat_default.chipActive : "",
791
800
  disabled ? chat_default.chipDisabled : ""
792
801
  ].filter(Boolean).join(" ");
793
802
  const navIcon = navIconFor(chip);
794
803
  const label = stripEmoji(chip.label);
804
+ const iconEl = navIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: chat_default.chipIcon, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
805
+ "svg",
806
+ {
807
+ viewBox: "0 0 24 24",
808
+ fill: "none",
809
+ stroke: "currentColor",
810
+ strokeWidth: 2,
811
+ strokeLinecap: "round",
812
+ strokeLinejoin: "round",
813
+ dangerouslySetInnerHTML: { __html: navIcon.svg }
814
+ }
815
+ ) }) : null;
795
816
  return /* @__PURE__ */ jsxRuntime.jsxs(
796
817
  "button",
797
818
  {
@@ -800,19 +821,9 @@ function Chip({ chip, disabled, active, onClick }) {
800
821
  disabled,
801
822
  onClick: () => !disabled && onClick(chip),
802
823
  children: [
803
- navIcon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: chat_default.chipIcon, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
804
- "svg",
805
- {
806
- viewBox: "0 0 24 24",
807
- fill: "none",
808
- stroke: "currentColor",
809
- strokeWidth: 2,
810
- strokeLinecap: "round",
811
- strokeLinejoin: "round",
812
- dangerouslySetInnerHTML: { __html: navIcon }
813
- }
814
- ) }) : null,
815
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: label })
824
+ navIcon && !navIcon.trailing ? iconEl : null,
825
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
826
+ navIcon && navIcon.trailing ? iconEl : null
816
827
  ]
817
828
  }
818
829
  );
@@ -977,6 +988,9 @@ function MessageBubble({ message, onChipClick, onFeedback }) {
977
988
  };
978
989
  const chips = message.chips ?? [];
979
990
  const showMenuGrid = isBot && message.chipsActive && isRootMenuChips(chips);
991
+ const isNavChip = (c) => c.id === "__root__" || c.label.trim() === "Back";
992
+ const navChips = chips.filter(isNavChip);
993
+ const otherChips = chips.filter((c) => !isNavChip(c));
980
994
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
981
995
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: bubbleClass, children: isBot ? /* @__PURE__ */ jsxRuntime.jsx(
982
996
  "div",
@@ -1051,14 +1065,24 @@ function MessageBubble({ message, onChipClick, onFeedback }) {
1051
1065
  },
1052
1066
  chip.id
1053
1067
  );
1054
- }) }) : isBot && chips.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1055
- ChipRow,
1056
- {
1057
- chips,
1058
- disabled: !message.chipsActive,
1059
- onClick: handleChipClick
1060
- }
1061
- ) : null
1068
+ }) }) : isBot && chips.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1069
+ otherChips.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1070
+ ChipRow,
1071
+ {
1072
+ chips: otherChips,
1073
+ disabled: !message.chipsActive,
1074
+ onClick: handleChipClick
1075
+ }
1076
+ ) : null,
1077
+ navChips.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1078
+ ChipRow,
1079
+ {
1080
+ chips: navChips,
1081
+ disabled: !message.chipsActive,
1082
+ onClick: handleChipClick
1083
+ }
1084
+ ) : null
1085
+ ] }) : null
1062
1086
  ] });
1063
1087
  }
1064
1088
  function TypingIndicator() {