@embedreach/components 0.2.8 → 0.2.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.
@@ -60341,8 +60341,12 @@ const InfoTooltip = ({ title: title2, alertText, Icon: Icon2 = Info, onClick, as
60341
60341
  const [isOpen, setIsOpen] = useState(false);
60342
60342
  const handleClick = (e4) => {
60343
60343
  e4.stopPropagation();
60344
- setIsOpen(!isOpen);
60345
- onClick?.();
60344
+ if (onClick) {
60345
+ onClick();
60346
+ setIsOpen(false);
60347
+ } else {
60348
+ setIsOpen(!isOpen);
60349
+ }
60346
60350
  };
60347
60351
  return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { open: isOpen, onOpenChange: setIsOpen, children: [
60348
60352
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild, children: /* @__PURE__ */ jsx(
@@ -66063,7 +66067,8 @@ const AutomationEditorSMSPreview = ({
66063
66067
  const AutomationEditorTabs = ({
66064
66068
  disablePreview = false,
66065
66069
  disableEditContent = false,
66066
- disablePreviewSubtext = false
66070
+ disablePreviewSubtext = false,
66071
+ hideSms = false
66067
66072
  }) => {
66068
66073
  const [activeTab, setActiveTab] = useState("email");
66069
66074
  const [initialLoad, setInitialLoad] = useState(false);
@@ -66094,46 +66099,52 @@ const AutomationEditorTabs = ({
66094
66099
  defaultValue: "email",
66095
66100
  className: "flex flex-col gap-4 pt-4 flex-1 bg-muted rounded-md",
66096
66101
  children: [
66097
- /* @__PURE__ */ jsx("div", { className: "max-w-[640px] mx-auto w-full", children: /* @__PURE__ */ jsxs(TabsList, { className: "grid w-full grid-cols-2", children: [
66098
- /* @__PURE__ */ jsx(TabsTrigger, { value: "email", className: "group", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
66099
- /* @__PURE__ */ jsx(
66100
- "img",
66101
- {
66102
- src: emailActiveIcon,
66103
- alt: "Email",
66104
- className: "w-4 h-4 mr-2 hidden group-data-[state=active]:block"
66105
- }
66106
- ),
66107
- /* @__PURE__ */ jsx(
66108
- "img",
66109
- {
66110
- src: emailInactiveIcon,
66111
- alt: "Email",
66112
- className: "w-4 h-4 mr-2 block group-data-[state=active]:hidden"
66113
- }
66114
- ),
66115
- "Email"
66116
- ] }) }),
66117
- /* @__PURE__ */ jsx(TabsTrigger, { value: "sms", className: "group", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
66118
- /* @__PURE__ */ jsx(
66119
- "img",
66120
- {
66121
- src: smsActiveIcon,
66122
- alt: "SMS",
66123
- className: "w-4 h-4 mr-2 hidden group-data-[state=active]:block"
66124
- }
66125
- ),
66126
- /* @__PURE__ */ jsx(
66127
- "img",
66128
- {
66129
- src: smsInactiveIcon,
66130
- alt: "SMS",
66131
- className: "w-4 h-4 mr-2 block group-data-[state=active]:hidden"
66132
- }
66133
- ),
66134
- "SMS"
66135
- ] }) })
66136
- ] }) }),
66102
+ /* @__PURE__ */ jsx("div", { className: "max-w-[640px] mx-auto w-full", children: /* @__PURE__ */ jsxs(
66103
+ TabsList,
66104
+ {
66105
+ className: `grid w-full ${hideSms ? "grid-cols-1" : "grid-cols-2"}`,
66106
+ children: [
66107
+ /* @__PURE__ */ jsx(TabsTrigger, { value: "email", className: "group", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
66108
+ /* @__PURE__ */ jsx(
66109
+ "img",
66110
+ {
66111
+ src: emailActiveIcon,
66112
+ alt: "Email",
66113
+ className: "w-4 h-4 mr-2 hidden group-data-[state=active]:block"
66114
+ }
66115
+ ),
66116
+ /* @__PURE__ */ jsx(
66117
+ "img",
66118
+ {
66119
+ src: emailInactiveIcon,
66120
+ alt: "Email",
66121
+ className: "w-4 h-4 mr-2 block group-data-[state=active]:hidden"
66122
+ }
66123
+ ),
66124
+ "Email"
66125
+ ] }) }),
66126
+ !hideSms && /* @__PURE__ */ jsx(TabsTrigger, { value: "sms", className: "group", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
66127
+ /* @__PURE__ */ jsx(
66128
+ "img",
66129
+ {
66130
+ src: smsActiveIcon,
66131
+ alt: "SMS",
66132
+ className: "w-4 h-4 mr-2 hidden group-data-[state=active]:block"
66133
+ }
66134
+ ),
66135
+ /* @__PURE__ */ jsx(
66136
+ "img",
66137
+ {
66138
+ src: smsInactiveIcon,
66139
+ alt: "SMS",
66140
+ className: "w-4 h-4 mr-2 block group-data-[state=active]:hidden"
66141
+ }
66142
+ ),
66143
+ "SMS"
66144
+ ] }) })
66145
+ ]
66146
+ }
66147
+ ) }),
66137
66148
  /* @__PURE__ */ jsxs("div", { className: "max-w-[1000px] mx-auto w-full flex-1", children: [
66138
66149
  /* @__PURE__ */ jsx(TabsContent, { value: "sms", children: /* @__PURE__ */ jsx(
66139
66150
  AutomationEditorSMSPreview,
@@ -73457,6 +73468,13 @@ const OneTimeWizardMain = ({ onFinish, getExtraMergeFields, onBeforeSchedule })
73457
73468
  renderFooter()
73458
73469
  ] });
73459
73470
  };
73471
+ const OneTimeWizardWrapper = ({ children: children2, actionId }) => {
73472
+ const { setActionId: setActionId2 } = useContext$1(Context);
73473
+ useEffect(() => {
73474
+ setActionId2(actionId);
73475
+ }, [actionId, setActionId2]);
73476
+ return /* @__PURE__ */ jsx("div", { children: children2 });
73477
+ };
73460
73478
  const OneTimeBroadcast = () => {
73461
73479
  return /* @__PURE__ */ jsxs("div", { children: [
73462
73480
  /* @__PURE__ */ jsx("div", { className: styles$4.iconWrapper, children: /* @__PURE__ */ jsx(IconDefinitions.OneTimeBroadcast, {}) }),
@@ -73569,6 +73587,7 @@ const CreateAutomationModal = ({
73569
73587
  const [automationId, setAutomationId] = useState(
73570
73588
  void 0
73571
73589
  );
73590
+ const [communicationActionId, setCommunicationActionId] = useState(void 0);
73572
73591
  const [initalStateSet, setInitalStateSet] = useState(false);
73573
73592
  const [automationState, setAutomationState] = useState(
73574
73593
  /**
@@ -73643,6 +73662,7 @@ const CreateAutomationModal = ({
73643
73662
  });
73644
73663
  if (automationType === AutomationTriggerType.ONE_TIME) {
73645
73664
  setCurrentStep(CreateAutomationModalStep.OneTimeWizard);
73665
+ setCommunicationActionId(actionId);
73646
73666
  setStartedCreating(false);
73647
73667
  } else {
73648
73668
  onClose?.(response.id);
@@ -73709,10 +73729,10 @@ const CreateAutomationModal = ({
73709
73729
  }
73710
73730
  );
73711
73731
  case CreateAutomationModalStep.OneTimeWizard:
73712
- if (!automationId) {
73732
+ if (!automationId || !communicationActionId) {
73713
73733
  return null;
73714
73734
  }
73715
- return /* @__PURE__ */ jsx(ViewAutomationProvider, { automationId, children: /* @__PURE__ */ jsx(
73735
+ return /* @__PURE__ */ jsx(ViewAutomationProvider, { automationId, children: /* @__PURE__ */ jsx(OneTimeWizardWrapper, { actionId: communicationActionId, children: /* @__PURE__ */ jsx(
73716
73736
  OneTimeWizardMain,
73717
73737
  {
73718
73738
  onFinish: () => {
@@ -73721,7 +73741,7 @@ const CreateAutomationModal = ({
73721
73741
  getExtraMergeFields,
73722
73742
  onBeforeSchedule
73723
73743
  }
73724
- ) });
73744
+ ) }) });
73725
73745
  default:
73726
73746
  throw UnreachableCaseStatement$1(currentStep, CreateAutomationModalStep);
73727
73747
  }
@@ -74041,6 +74061,7 @@ const StatsGrid = ({
74041
74061
  const AutomationStatistics = ({
74042
74062
  automationId,
74043
74063
  includeSales = false,
74064
+ includeSms = false,
74044
74065
  automation: automation2
74045
74066
  }) => {
74046
74067
  const [activeTab, setActiveTab] = useState("email");
@@ -74062,11 +74083,13 @@ const AutomationStatistics = ({
74062
74083
  label: `Email ${t$1("engage:insight", { count: 2 })}`,
74063
74084
  content: /* @__PURE__ */ jsx(StatsGrid, { activeTab: "email", statistics })
74064
74085
  },
74065
- {
74066
- id: "sms",
74067
- label: `SMS ${t$1("engage:insight", { count: 2 })}`,
74068
- content: /* @__PURE__ */ jsx(StatsGrid, { activeTab: "sms", statistics })
74069
- },
74086
+ ...includeSms ? [
74087
+ {
74088
+ id: "sms",
74089
+ label: `SMS ${t$1("engage:insight", { count: 2 })}`,
74090
+ content: /* @__PURE__ */ jsx(StatsGrid, { activeTab: "sms", statistics })
74091
+ }
74092
+ ] : [],
74070
74093
  ...includeSales ? [
74071
74094
  {
74072
74095
  id: "sales",
@@ -81724,6 +81747,10 @@ function AutomationEditDialog({
81724
81747
  defaultValues: {
81725
81748
  name: automation2?.name ?? "",
81726
81749
  description: automation2?.description ?? ""
81750
+ },
81751
+ values: {
81752
+ name: automation2?.name ?? "",
81753
+ description: automation2?.description ?? ""
81727
81754
  }
81728
81755
  });
81729
81756
  function onSubmit(values) {
@@ -81738,8 +81765,17 @@ function AutomationEditDialog({
81738
81765
  }
81739
81766
  return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
81740
81767
  /* @__PURE__ */ jsxs(DialogHeader, { children: [
81741
- /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Automation" }),
81742
- /* @__PURE__ */ jsx(DialogDescription, { children: "Update the title and description of your automation." })
81768
+ /* @__PURE__ */ jsxs(DialogTitle, { children: [
81769
+ "Edit",
81770
+ " ",
81771
+ automation2.triggerType === AutomationTriggerType.ONE_TIME ? t$1("engage:one_time") : t$1("engage:automation")
81772
+ ] }),
81773
+ /* @__PURE__ */ jsxs(DialogDescription, { children: [
81774
+ "Update the title and description of your",
81775
+ " ",
81776
+ automation2.triggerType === AutomationTriggerType.ONE_TIME ? t$1("engage:one_time") : t$1("engage:automation"),
81777
+ "."
81778
+ ] })
81743
81779
  ] }),
81744
81780
  /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-4", children: [
81745
81781
  /* @__PURE__ */ jsx(
@@ -82055,7 +82091,7 @@ const AutomationsEditorHeader = ({ showBackButton, onDuplicationCreated, onBefor
82055
82091
  )
82056
82092
  ] });
82057
82093
  };
82058
- const AutomationsEditorStatsTab = () => {
82094
+ const AutomationsEditorStatsTab = ({ hideSms, hideSales }) => {
82059
82095
  const automation2 = useAutomation();
82060
82096
  const { isLoading: isStatisticsLoading } = useGetBusinessAutomationStatistics(
82061
82097
  automation2?.id
@@ -82073,7 +82109,8 @@ const AutomationsEditorStatsTab = () => {
82073
82109
  {
82074
82110
  automationId: automation2.id,
82075
82111
  automation: automation2,
82076
- includeSales: true
82112
+ includeSales: !hideSales,
82113
+ includeSms: !hideSms
82077
82114
  }
82078
82115
  ) });
82079
82116
  };
@@ -84652,11 +84689,16 @@ const AutomationsEditorStep = ({
84652
84689
  const AutomationFlowMain = () => {
84653
84690
  const [isDetailsVisible, setIsDetailsVisible] = useState(false);
84654
84691
  const [actionDataWithMetadata, setActionDataWithMetadata] = useState(void 0);
84692
+ const [isEditingDescription, setIsEditingDescription] = useState(false);
84693
+ const [editedDescription, setEditedDescription] = useState("");
84694
+ const [optimisticDescription, setOptimisticDescription] = useState(null);
84655
84695
  const automation2 = useAutomation();
84656
84696
  const {
84657
84697
  setActionId: setActionId2,
84658
84698
  state: { selectedActionId }
84659
84699
  } = useContext$1(Context);
84700
+ const { updateAutomation: businessUpdateAutomation } = useUpdateBusinessAutomation(automation2?.id || "");
84701
+ const { toast: toast2 } = useToast();
84660
84702
  useEffect(() => {
84661
84703
  if (!automation2) {
84662
84704
  return;
@@ -84704,6 +84746,10 @@ const AutomationFlowMain = () => {
84704
84746
  };
84705
84747
  getData();
84706
84748
  }, [automation2]);
84749
+ useEffect(() => {
84750
+ setOptimisticDescription(null);
84751
+ setEditedDescription(automation2?.description ?? "");
84752
+ }, [automation2?.description]);
84707
84753
  if (!automation2 || !actionDataWithMetadata) {
84708
84754
  return null;
84709
84755
  }
@@ -84725,17 +84771,69 @@ const AutomationFlowMain = () => {
84725
84771
  ] });
84726
84772
  };
84727
84773
  }
84774
+ const handleSaveDescription = async () => {
84775
+ setOptimisticDescription(editedDescription);
84776
+ businessUpdateAutomation(
84777
+ {
84778
+ description: editedDescription
84779
+ },
84780
+ {
84781
+ onSuccess: () => {
84782
+ toast2({
84783
+ title: "Description updated 🚀"
84784
+ });
84785
+ setIsEditingDescription(false);
84786
+ }
84787
+ }
84788
+ );
84789
+ };
84790
+ const handleCancelEdit = () => {
84791
+ setIsEditingDescription(false);
84792
+ };
84728
84793
  const renderAutomationDescription = () => {
84729
- if (!automation2.description) return null;
84794
+ if (!automation2.description && !isEditingDescription) return null;
84730
84795
  return /* @__PURE__ */ jsx(
84731
84796
  "div",
84732
84797
  {
84733
- className: "w-full mx-auto rounded-xl bg-neutral-50 dark:bg-neutral-900 shadow-sm px-4 py-3 my-2 border border-neutral-200 dark:border-neutral-800 text-neutral-800 dark:text-neutral-100 text-[15px] font-medium leading-snug tracking-tight justify-start",
84798
+ className: "w-full mx-auto rounded-xl bg-neutral-50 dark:bg-neutral-900 shadow-sm px-4 py-3 my-2 border border-neutral-200 dark:border-neutral-800 text-neutral-800 dark:text-neutral-100 text-[15px] font-medium leading-snug tracking-tight justify-start group relative transition-colors duration-150",
84734
84799
  style: {
84735
- /* Container queries for mobile optimization */
84736
84800
  containerType: "inline-size"
84737
84801
  },
84738
- children: automation2.description
84802
+ tabIndex: 0,
84803
+ onClick: () => {
84804
+ setIsEditingDescription(true);
84805
+ },
84806
+ role: "button",
84807
+ "aria-label": "Edit automation description",
84808
+ children: isEditingDescription ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
84809
+ /* @__PURE__ */ jsx(
84810
+ "textarea",
84811
+ {
84812
+ className: "w-full bg-transparent outline-none resize-none text-[15px] font-medium leading-snug tracking-tight text-neutral-800 dark:text-neutral-100 rounded-xl border border-primary-500 focus:ring-2 focus:ring-primary-400 transition-all min-h-[48px] p-2",
84813
+ style: { containerType: "inline-size" },
84814
+ value: editedDescription,
84815
+ autoFocus: true,
84816
+ rows: 2,
84817
+ maxLength: 300,
84818
+ onChange: (e4) => setEditedDescription(e4.target.value),
84819
+ onBlur: handleCancelEdit,
84820
+ "aria-label": "Edit automation description textarea"
84821
+ }
84822
+ ),
84823
+ /* @__PURE__ */ jsx(
84824
+ Button$1,
84825
+ {
84826
+ variant: "secondary",
84827
+ onClick: handleSaveDescription,
84828
+ onMouseDown: (e4) => e4.preventDefault(),
84829
+ className: "z-20",
84830
+ children: "Update Description"
84831
+ }
84832
+ )
84833
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
84834
+ /* @__PURE__ */ jsx("span", { className: "pr-8 select-text cursor-pointer", children: optimisticDescription !== null ? optimisticDescription : automation2.description }),
84835
+ /* @__PURE__ */ jsx("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 group-focus:opacity-100 transition-opacity duration-150 pointer-events-none", children: /* @__PURE__ */ jsx(IconDefinitions.EditIcon, { className: "w-4 h-4" }) })
84836
+ ] })
84739
84837
  }
84740
84838
  );
84741
84839
  };
@@ -84792,26 +84890,26 @@ const AutomationsEditorSidebar = () => {
84792
84890
  }
84793
84891
  return /* @__PURE__ */ jsx("div", { className: "h-full pt-4 relative", children: /* @__PURE__ */ jsx("div", { className: "absolute inset-0 overflow-y-auto flex flex-col gap-3", children: /* @__PURE__ */ jsx(AutomationFlowMain, {}) }) });
84794
84892
  };
84795
- const AutomationsEditorMain = () => {
84893
+ const AutomationsEditorMain = ({ hideSms }) => {
84796
84894
  const {
84797
84895
  state: { selectedActionId }
84798
84896
  } = useContext$1(Context);
84799
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 h-full w-full", children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: selectedActionId === BuiltInActionIds.EditTime ? /* @__PURE__ */ jsx(AutomationSelectTimeMain, {}) : selectedActionId === BuiltInActionIds.EditAudience ? /* @__PURE__ */ jsx(AutomationAudienceSelectorMain, {}) : /* @__PURE__ */ jsx(AutomationEditorTabs, {}) }) });
84897
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 h-full w-full", children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: selectedActionId === BuiltInActionIds.EditTime ? /* @__PURE__ */ jsx(AutomationSelectTimeMain, {}) : selectedActionId === BuiltInActionIds.EditAudience ? /* @__PURE__ */ jsx(AutomationAudienceSelectorMain, {}) : /* @__PURE__ */ jsx(AutomationEditorTabs, { hideSms }) }) });
84800
84898
  };
84801
- const AutomationsEditorWorkflowTab = () => {
84899
+ const AutomationsEditorWorkflowTab = ({ hideSms }) => {
84802
84900
  return /* @__PURE__ */ jsxs(ResizablePanelGroup, { direction: "horizontal", className: "flex-1", children: [
84803
84901
  /* @__PURE__ */ jsx(ResizablePanel, { defaultSize: 30, minSize: 16, maxSize: 48, children: /* @__PURE__ */ jsx("aside", { className: "h-full", children: /* @__PURE__ */ jsx(AutomationsEditorSidebar, {}) }) }),
84804
84902
  /* @__PURE__ */ jsx(ResizableHandle, { className: "px-1 opacity-0 hover:opacity-100 transition-opacity duration-200 mx-1" }),
84805
- /* @__PURE__ */ jsx(ResizablePanel, { defaultSize: 70, children: /* @__PURE__ */ jsx("main", { className: "h-full", children: /* @__PURE__ */ jsx(AutomationsEditorMain, {}) }) })
84903
+ /* @__PURE__ */ jsx(ResizablePanel, { defaultSize: 70, children: /* @__PURE__ */ jsx("main", { className: "h-full", children: /* @__PURE__ */ jsx(AutomationsEditorMain, { hideSms }) }) })
84806
84904
  ] });
84807
84905
  };
84808
- const AutomationsEditorTabs = () => {
84906
+ const AutomationsEditorTabs = ({ hideSms, hideSales }) => {
84809
84907
  const [activeTab, setActiveTab] = React__default.useState("workflow");
84810
84908
  const tabs = [
84811
84909
  {
84812
84910
  id: "workflow",
84813
84911
  label: "Workflow",
84814
- content: /* @__PURE__ */ jsx(AutomationsEditorWorkflowTab, {})
84912
+ content: /* @__PURE__ */ jsx(AutomationsEditorWorkflowTab, { hideSms })
84815
84913
  },
84816
84914
  {
84817
84915
  id: "recipients",
@@ -84821,7 +84919,7 @@ const AutomationsEditorTabs = () => {
84821
84919
  {
84822
84920
  id: "insights",
84823
84921
  label: t$1("engage:insight", { count: 2 }),
84824
- content: /* @__PURE__ */ jsx(AutomationsEditorStatsTab, {})
84922
+ content: /* @__PURE__ */ jsx(AutomationsEditorStatsTab, { hideSms, hideSales })
84825
84923
  }
84826
84924
  ];
84827
84925
  return /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(
@@ -84838,7 +84936,9 @@ const ViewAutomationMain = ({
84838
84936
  showBackButton = false,
84839
84937
  onDuplicationCreated,
84840
84938
  onBeforeSchedule,
84841
- getExtraMergeFields
84939
+ getExtraMergeFields,
84940
+ hideSms,
84941
+ hideSales
84842
84942
  }) => {
84843
84943
  const automation2 = useAutomation();
84844
84944
  const communicationGroup = useCommunicationGroup();
@@ -84895,7 +84995,7 @@ const ViewAutomationMain = ({
84895
84995
  onBeforeSchedule
84896
84996
  }
84897
84997
  ),
84898
- /* @__PURE__ */ jsx("div", { className: "flex-1 border-t", children: /* @__PURE__ */ jsx(AutomationsEditorTabs, {}) })
84998
+ /* @__PURE__ */ jsx("div", { className: "flex-1 border-t", children: /* @__PURE__ */ jsx(AutomationsEditorTabs, { hideSms, hideSales }) })
84899
84999
  ] });
84900
85000
  };
84901
85001
  const ViewAutomationContent = ({ ...props2 }) => {
package/dist/index.d.ts CHANGED
@@ -300,6 +300,11 @@ export declare type ViewAutomationProps = {
300
300
  estimatedEmailRecipients: number;
301
301
  estimatedSmsRecipients: number;
302
302
  }) => Promise<true | string>;
303
+ /**
304
+ * Optional boolean to hide features
305
+ */
306
+ hideSms?: boolean;
307
+ hideSales?: boolean;
303
308
  };
304
309
 
305
310
  export { }