@fayz-ai/plugin-conversations 0.19.0 → 0.20.0

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
@@ -1,10 +1,10 @@
1
1
  import * as React12 from 'react';
2
2
  import React12__default, { useState, useRef, useEffect, useCallback, useMemo } from 'react';
3
3
  import { Loader2, MessageSquare, AlertTriangle, Pause, Play, Send, RefreshCw, Plus, Clock, CheckCircle2, Check, ShieldCheck, ShieldAlert, QrCode, Zap, ExternalLink, SquarePen, Globe, Mail, Instagram, Phone, Search, User, Inbox, CheckCheck, ChevronLeft, Archive, PanelRight, X, MapPin, Tag, StickyNote, Link2, MoreVertical, Snowflake, Sun, Flame, Building2, UserRound, Copy, FileText, Download } from 'lucide-react';
4
- import { toast, Button, Input, defineKpiWidget, defineTableWidget, PageHeaderActions, cn, Badge, FilterChip, Skeleton, KpiCard, TableWidget } from '@fayz-ai/ui';
4
+ import { toast, Button, Input, defineKpiWidget, defineTableWidget, PageHeaderActions, cn, Badge, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, ModalFooter, FilterChip, Skeleton, KpiCard, TableWidget } from '@fayz-ai/ui';
5
5
  import { createConnectionStore, connectionRuns, connectionStatus, getActiveTenantId, getSupabaseClientOptional, useActiveTenantId, registerTranslations, useTranslation, countByTenant, CONNECTOR_RUNTIME_TOKEN_HEADER, connectorRuntimeToken, errorMessage } from '@fayz-ai/core';
6
6
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
- import { SettingsGroup, PluginSettingsPanel, useNavContribution, PermissionGate, useLimitGuard, RightRailPage, ContactPicker, invalidateLimit } from '@fayz-ai/admin';
7
+ import { SettingsGroup, PluginSettingsPanel, useNavContribution, useRightRailStore, PageActions, useLimitGuard, ContactPicker, invalidateLimit } from '@fayz-ai/admin';
8
8
  import { useStore } from 'zustand';
9
9
  import { createStore } from 'zustand/vanilla';
10
10
 
@@ -1437,7 +1437,7 @@ function MessageThread({ selected, onTogglePanel, panelOpen, onBack, className }
1437
1437
  /* @__PURE__ */ jsx(Avatar, { name: selected.contactName, accent: selected.accent, size: "sm", channel: selected.channel }),
1438
1438
  /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1439
1439
  /* @__PURE__ */ jsx("p", { className: "truncate text-sm font-semibold text-foreground", children: selected.contactName }),
1440
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
1440
+ !panelOpen && /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-1.5 text-xs text-muted-foreground", children: [
1441
1441
  /* @__PURE__ */ jsx(ChannelBadge, { channel: selected.channel }),
1442
1442
  /* @__PURE__ */ jsx("span", { className: "truncate", children: selected.contactHandle })
1443
1443
  ] })
@@ -1753,14 +1753,10 @@ function NewConversationPanel({
1753
1753
  setSubmitting(false);
1754
1754
  }
1755
1755
  }
1756
- return /* @__PURE__ */ jsx(
1757
- RightRailPage,
1758
- {
1759
- title: t("conversations.new.title"),
1760
- open,
1761
- onClose: () => onOpenChange(false),
1762
- width: "max-w-md",
1763
- children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-5 py-4", children: [
1756
+ return /* @__PURE__ */ jsx(Modal, { open, onOpenChange, children: /* @__PURE__ */ jsxs(ModalContent, { className: "max-w-md", children: [
1757
+ /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsx(ModalTitle, { children: t("conversations.new.title") }) }),
1758
+ /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
1759
+ /* @__PURE__ */ jsxs(ModalBody, { className: "space-y-4", children: [
1764
1760
  /* @__PURE__ */ jsxs("div", { children: [
1765
1761
  /* @__PURE__ */ jsx("label", { className: "mb-1.5 block text-xs font-medium text-muted-foreground", children: t("conversations.new.channel") }),
1766
1762
  /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1.5", children: CHANNELS.map((ch) => {
@@ -1824,11 +1820,11 @@ function NewConversationPanel({
1824
1820
  className: "max-h-40 min-h-[64px] w-full resize-none rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary"
1825
1821
  }
1826
1822
  )
1827
- ] }),
1828
- /* @__PURE__ */ jsx("div", { className: "mt-auto pt-2", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !canSubmit, className: "w-full", children: submitting ? t("conversations.new.creating") : t("conversations.new.create") }) })
1829
- ] })
1830
- }
1831
- );
1823
+ ] })
1824
+ ] }),
1825
+ /* @__PURE__ */ jsx(ModalFooter, { children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !canSubmit, className: "w-full", children: submitting ? t("conversations.new.creating") : t("conversations.new.create") }) })
1826
+ ] })
1827
+ ] }) });
1832
1828
  }
1833
1829
  function useCaixaAoVivo() {
1834
1830
  const tenantId = useActiveTenantId();
@@ -1852,26 +1848,26 @@ function InboxView() {
1852
1848
  const { conversations, selectedId, deselect } = useConversationsStore((s) => s);
1853
1849
  useCaixaAoVivo();
1854
1850
  const isWidePanel = useMediaQuery("(min-width: 1280px)");
1851
+ const railOpen = useRightRailStore((s) => s.open);
1855
1852
  const [panelOpen, setPanelOpen] = React12__default.useState(false);
1856
1853
  const [newOpen, setNewOpen] = React12__default.useState(false);
1857
1854
  const selected = conversations.find((c) => c.id === selectedId) ?? null;
1858
1855
  React12__default.useEffect(() => {
1859
- setPanelOpen(isWidePanel);
1860
- }, [isWidePanel]);
1856
+ setPanelOpen(isWidePanel && !railOpen);
1857
+ }, [isWidePanel, railOpen]);
1858
+ const newActions = React12__default.useMemo(() => [{
1859
+ id: "new-conversation",
1860
+ label: t("conversations.list.new"),
1861
+ icon: SquarePen,
1862
+ intent: "primary",
1863
+ // Starting a conversation creates a thread — the FAB is a "+".
1864
+ creates: true,
1865
+ testId: "conversations-new",
1866
+ permission: { feature: "conversations", action: "create" },
1867
+ onSelect: () => setNewOpen(true)
1868
+ }], [t]);
1861
1869
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1862
- /* @__PURE__ */ jsx(PermissionGate, { feature: "conversations", action: "create", children: /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsxs(
1863
- Button,
1864
- {
1865
- size: "sm",
1866
- onClick: () => setNewOpen(true),
1867
- "aria-label": t("conversations.list.new"),
1868
- "data-testid": "conversations-new",
1869
- children: [
1870
- /* @__PURE__ */ jsx(SquarePen, { className: "h-3.5 w-3.5 sm:mr-1.5" }),
1871
- /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: t("conversations.list.new") })
1872
- ]
1873
- }
1874
- ) }) }),
1870
+ /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsx(PageActions, { actions: newActions }) }),
1875
1871
  /* @__PURE__ */ jsx(NewConversationPanel, { open: newOpen, onOpenChange: setNewOpen }),
1876
1872
  /* @__PURE__ */ jsxs("div", { className: "relative flex h-full min-h-0 overflow-hidden bg-background", children: [
1877
1873
  /* @__PURE__ */ jsx(ConversationList, { className: cn(selected ? "hidden lg:flex" : "flex") }),