@fayz-ai/plugin-automations 0.15.13 → 0.15.15

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.js CHANGED
@@ -4,7 +4,7 @@ import { getSupabaseClientOptional, useTranslation, errorMessage, startEventLog,
4
4
  import { PageActions, resolveFayzAgentConnection, registerRailPage, getFayzSupabaseClientOptional, useConnectors, useAgentSurface, askAI, SettingsTabs, adminNavigateTo, RightRailPage, AskAIButton, useOrganizationStore, connectorRoute, ConnectorMark, ConnectorDeliveries } from '@fayz-ai/admin';
5
5
  import * as LucideIcons from 'lucide-react';
6
6
  import { Plus, ChevronRight, ListChecks, MessageSquare, Clock, Trash2, Workflow, WandSparkles, Zap, Receipt, Megaphone, Smartphone, Mail, RotateCcw, Check, Monitor, RefreshCw, History, Send, AlertTriangle, CircleCheck, CircleSlash } from 'lucide-react';
7
- import { toast, Card, PageHeaderActions, Switch, DataTable, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, ModalFooter, Button, PageTabs, WhatsAppIcon, SubpageHeader, Badge, Hint, HeaderTabs, PhoneField } from '@fayz-ai/ui';
7
+ import { toast, Card, PageHeaderActions, Button, Switch, DataTable, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Input, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, ModalFooter, PageTabs, WhatsAppIcon, SubpageHeader, Badge, Hint, HeaderTabs, Textarea, PhoneField } from '@fayz-ai/ui';
8
8
  import { createFayzAutomationsClient, FayzAutomationsError } from '@fayz-ai/sdk/automations';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
 
@@ -253,11 +253,13 @@ function RunRow({ run }) {
253
253
  const { Icon } = cfg;
254
254
  return /* @__PURE__ */ jsxs("div", { className: "border-b border-border last:border-b-0", children: [
255
255
  /* @__PURE__ */ jsxs(
256
- "button",
256
+ Button,
257
257
  {
258
+ variant: "bare",
259
+ size: "bare",
258
260
  type: "button",
259
261
  onClick: () => setOpen(!open),
260
- className: "flex w-full items-center gap-3 px-4 py-2.5 text-left transition-colors hover:bg-muted/40",
262
+ className: "flex w-full items-center justify-start gap-3 rounded-none px-4 py-2.5 text-left font-normal transition-colors hover:bg-muted/40",
261
263
  children: [
262
264
  /* @__PURE__ */ jsx(ChevronRight, { className: `h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${open ? "rotate-90" : ""}` }),
263
265
  /* @__PURE__ */ jsx(Icon, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
@@ -506,15 +508,14 @@ function TestSendStrip({ eventKey, channel, placeholders, template }) {
506
508
  /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
507
509
  /* @__PURE__ */ jsx("label", { className: "mb-1 block text-xs font-medium text-muted-foreground", children: isEmail ? "E-mail que recebe o teste" : "N\xFAmero que recebe o teste" }),
508
510
  isEmail ? /* @__PURE__ */ jsx(
509
- "input",
511
+ Input,
510
512
  {
511
513
  type: "email",
512
514
  value: recipient,
513
515
  onChange: (e) => setRecipient(e.target.value),
514
516
  placeholder: "voce@exemplo.com",
515
517
  disabled: sending,
516
- "aria-label": "E-mail que recebe o teste",
517
- className: "w-full rounded-input border border-input bg-card px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
518
+ "aria-label": "E-mail que recebe o teste"
518
519
  }
519
520
  ) : /* @__PURE__ */ jsx(
520
521
  PhoneField,
@@ -846,8 +847,10 @@ function AutomationDetailPage({ eventKey, channel, store: store2, backTo = "/aut
846
847
  !embedded && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-border px-4 py-2.5", children: [
847
848
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: "Pr\xE9via" }),
848
849
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: ["desktop", "mobile"].map((d) => /* @__PURE__ */ jsx(
849
- "button",
850
+ Button,
850
851
  {
852
+ variant: "bare",
853
+ size: "bare",
851
854
  type: "button",
852
855
  onClick: () => setDevice(d),
853
856
  "aria-label": d === "desktop" ? "Computador" : "Celular",
@@ -917,23 +920,22 @@ function AutomationDetailPage({ eventKey, channel, store: store2, backTo = "/aut
917
920
  hasSubject && /* @__PURE__ */ jsxs("div", { children: [
918
921
  /* @__PURE__ */ jsx("label", { className: "mb-1 block text-xs font-medium text-muted-foreground", children: "Assunto" }),
919
922
  /* @__PURE__ */ jsx(
920
- "input",
923
+ Input,
921
924
  {
922
925
  value: current.subject,
923
- onChange: (e) => setDraft({ ...current, subject: e.target.value }),
924
- className: "w-full rounded-input border border-input bg-card px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
926
+ onChange: (e) => setDraft({ ...current, subject: e.target.value })
925
927
  }
926
928
  )
927
929
  ] }),
928
930
  /* @__PURE__ */ jsxs("div", { children: [
929
931
  /* @__PURE__ */ jsx("label", { className: "mb-1 block text-xs font-medium text-muted-foreground", children: "Mensagem" }),
930
932
  /* @__PURE__ */ jsx(
931
- "textarea",
933
+ Textarea,
932
934
  {
933
935
  rows: 14,
934
936
  value: current.body,
935
937
  onChange: (e) => setDraft({ ...current, body: e.target.value }),
936
- className: "w-full rounded-input border border-input bg-card px-3 py-2 font-mono text-xs leading-relaxed focus:outline-none focus:ring-2 focus:ring-ring"
938
+ className: "font-mono text-xs leading-relaxed"
937
939
  }
938
940
  )
939
941
  ] }),
@@ -977,8 +979,8 @@ function AutomationDetailPage({ eventKey, channel, store: store2, backTo = "/aut
977
979
  // teto da Meta para QUICK_REPLY; mudar o texto de um
978
980
  // modelo já aprovado dispara nova aprovação — a
979
981
  // pastilha de status acima conta essa história.
980
- /* @__PURE__ */ jsx(
981
- "input",
982
+ /* @__PURE__ */ jsx("div", { className: "w-36", children: /* @__PURE__ */ jsx(
983
+ Input,
982
984
  {
983
985
  value: labelValue,
984
986
  maxLength: 25,
@@ -989,9 +991,9 @@ function AutomationDetailPage({ eventKey, channel, store: store2, backTo = "/aut
989
991
  onKeyDown: (e) => {
990
992
  if (e.key === "Enter") e.target.blur();
991
993
  },
992
- className: "w-36 rounded-input border border-input bg-card px-2 py-1 text-sm focus:outline-none focus:ring-2 focus:ring-ring"
994
+ className: "h-auto px-2 py-1"
993
995
  }
994
- ),
996
+ ) }),
995
997
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: blocked ? "Para cobrar por aqui, configure a conta de pagamento em Conversas \u2192 Tyxter." : action.hint })
996
998
  ] }, action.id);
997
999
  }) })
@@ -1109,12 +1111,14 @@ function AutomationCard({
1109
1111
  ),
1110
1112
  row.listDeliveries && /* @__PURE__ */ jsxs(Fragment, { children: [
1111
1113
  /* @__PURE__ */ jsxs(
1112
- "button",
1114
+ Button,
1113
1115
  {
1116
+ variant: "bare",
1117
+ size: "bare",
1114
1118
  type: "button",
1115
1119
  onClick: () => setOpen(!open),
1116
1120
  "aria-expanded": open,
1117
- className: "flex w-full items-center gap-2 border-t border-border px-4 py-2 text-left transition-colors hover:bg-muted/40",
1121
+ className: "flex w-full items-center justify-start gap-2 rounded-none border-t border-border px-4 py-2 text-left font-normal transition-colors hover:bg-muted/40",
1118
1122
  children: [
1119
1123
  /* @__PURE__ */ jsx(ChevronRight, { className: `h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${open ? "rotate-90" : ""}` }),
1120
1124
  /* @__PURE__ */ jsxs("span", { className: "text-xs font-medium", children: [
@@ -1787,8 +1791,10 @@ function useStepColumns(onDelete) {
1787
1791
  id: "actions",
1788
1792
  header: "",
1789
1793
  cell: ({ row }) => /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
1790
- "button",
1794
+ Button,
1791
1795
  {
1796
+ variant: "bare",
1797
+ size: "bare",
1792
1798
  onClick: (e) => {
1793
1799
  e.stopPropagation();
1794
1800
  onDelete(row.original.id);
@@ -1801,6 +1807,7 @@ function useStepColumns(onDelete) {
1801
1807
  }
1802
1808
  ], [t, onDelete]);
1803
1809
  }
1810
+ var COMPOSER_TRIGGER = "h-auto w-auto gap-2 rounded-md border-border px-2 py-1.5 shadow-none";
1804
1811
  function StepComposer({ steps, onAdd }) {
1805
1812
  const t = useTranslation();
1806
1813
  const [kind, setKind] = useState("message");
@@ -1820,32 +1827,22 @@ function StepComposer({ steps, onAdd }) {
1820
1827
  setValue("");
1821
1828
  };
1822
1829
  return /* @__PURE__ */ jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-2 rounded-lg border border-dashed p-3", children: [
1823
- /* @__PURE__ */ jsxs(
1824
- "select",
1825
- {
1826
- value: kind,
1827
- onChange: (e) => {
1828
- setKind(e.target.value);
1829
- setValue("");
1830
- },
1831
- className: "rounded-md border bg-background px-2 py-1.5 text-sm",
1832
- children: [
1833
- /* @__PURE__ */ jsx("option", { value: "message", children: t("automations.flow.kindMessage") }),
1834
- /* @__PURE__ */ jsx("option", { value: "task", children: t("automations.flow.kindTask") })
1835
- ]
1836
- }
1837
- ),
1838
- /* @__PURE__ */ jsx(
1839
- "select",
1840
- {
1841
- value: delay,
1842
- onChange: (e) => setDelay(Number(e.target.value)),
1843
- className: "rounded-md border bg-background px-2 py-1.5 text-sm",
1844
- children: DELAY_CHOICES.map((m) => /* @__PURE__ */ jsx("option", { value: m, children: describeDelay(m, t) }, m))
1845
- }
1846
- ),
1847
- /* @__PURE__ */ jsx(
1848
- "input",
1830
+ /* @__PURE__ */ jsxs(Select, { value: kind, onValueChange: (v) => {
1831
+ setKind(v);
1832
+ setValue("");
1833
+ }, children: [
1834
+ /* @__PURE__ */ jsx(SelectTrigger, { className: COMPOSER_TRIGGER, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1835
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
1836
+ /* @__PURE__ */ jsx(SelectItem, { value: "message", children: t("automations.flow.kindMessage") }),
1837
+ /* @__PURE__ */ jsx(SelectItem, { value: "task", children: t("automations.flow.kindTask") })
1838
+ ] })
1839
+ ] }),
1840
+ /* @__PURE__ */ jsxs(Select, { value: String(delay), onValueChange: (v) => setDelay(Number(v)), children: [
1841
+ /* @__PURE__ */ jsx(SelectTrigger, { className: COMPOSER_TRIGGER, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1842
+ /* @__PURE__ */ jsx(SelectContent, { children: DELAY_CHOICES.map((m) => /* @__PURE__ */ jsx(SelectItem, { value: String(m), children: describeDelay(m, t) }, m)) })
1843
+ ] }),
1844
+ /* @__PURE__ */ jsx("div", { className: "min-w-[200px] flex-1", children: /* @__PURE__ */ jsx(
1845
+ Input,
1849
1846
  {
1850
1847
  value,
1851
1848
  onChange: (e) => setValue(e.target.value),
@@ -1853,20 +1850,13 @@ function StepComposer({ steps, onAdd }) {
1853
1850
  if (e.key === "Enter") submit();
1854
1851
  },
1855
1852
  placeholder: t(kind === "task" ? "automations.flow.titlePlaceholder" : "automations.flow.templatePlaceholder"),
1856
- className: "min-w-[200px] flex-1 rounded-md border bg-background px-2 py-1.5 text-sm"
1853
+ className: "h-auto rounded-md border-border bg-background px-2 py-1.5 shadow-none"
1857
1854
  }
1858
- ),
1859
- /* @__PURE__ */ jsxs(
1860
- "button",
1861
- {
1862
- onClick: submit,
1863
- className: "inline-flex items-center gap-1 rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:opacity-90",
1864
- children: [
1865
- /* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" }),
1866
- t("automations.flow.addStep")
1867
- ]
1868
- }
1869
- )
1855
+ ) }),
1856
+ /* @__PURE__ */ jsxs(Button, { onClick: submit, className: "gap-1", children: [
1857
+ /* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5" }),
1858
+ t("automations.flow.addStep")
1859
+ ] })
1870
1860
  ] });
1871
1861
  }
1872
1862
  function FlowsPage() {
@@ -1976,10 +1966,12 @@ function FlowsPage() {
1976
1966
  ] }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: flows.map((flow) => /* @__PURE__ */ jsxs(Card, { className: "p-3", children: [
1977
1967
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1978
1968
  /* @__PURE__ */ jsxs(
1979
- "button",
1969
+ Button,
1980
1970
  {
1971
+ variant: "bare",
1972
+ size: "bare",
1981
1973
  onClick: () => setSelectedId(selectedId === flow.id ? null : flow.id),
1982
- className: "flex flex-1 items-center gap-2 text-left",
1974
+ className: "flex flex-1 items-center gap-2 text-left font-normal justify-start",
1983
1975
  children: [
1984
1976
  /* @__PURE__ */ jsx(
1985
1977
  ChevronRight,