@consilioweb/payload-support 0.6.5 → 0.8.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/README.md CHANGED
@@ -37,7 +37,7 @@
37
37
  >
38
38
  > And ensure all `@consilioweb/*` packages are in `transpilePackages` in your `next.config.ts`:
39
39
  > ```ts
40
- > transpilePackages: ['@consilioweb/seo-analyzer', '@consilioweb/admin-nav', /* ...other @consilioweb packages */],
40
+ > transpilePackages: ['@consilioweb/payload-seo-analyzer', '@consilioweb/payload-admin-nav', /* ...other @consilioweb packages */],
41
41
  > ```
42
42
  >
43
43
  > ✅ **Next.js 15** works without any workaround.
@@ -75,7 +75,7 @@ function useAI(messages, client, ticketSubject, replyBody, setReplyBody, setRepl
75
75
  }
76
76
  setAiReplying(false);
77
77
  };
78
- const handleAiRewrite = async () => {
78
+ const handleAiRewrite = async (style = "auto") => {
79
79
  if (!replyBody.trim()) return;
80
80
  setAiRewriting(true);
81
81
  try {
@@ -83,7 +83,7 @@ function useAI(messages, client, ticketSubject, replyBody, setReplyBody, setRepl
83
83
  method: "POST",
84
84
  headers: { "Content-Type": "application/json" },
85
85
  credentials: "include",
86
- body: JSON.stringify({ action: "rewrite", text: replyBody })
86
+ body: JSON.stringify({ action: "rewrite", text: replyBody, style })
87
87
  });
88
88
  if (res.ok) {
89
89
  const data = await res.json();
@@ -74,7 +74,7 @@ function useAI(messages, client, ticketSubject, replyBody, setReplyBody, setRepl
74
74
  }
75
75
  setAiReplying(false);
76
76
  };
77
- const handleAiRewrite = async () => {
77
+ const handleAiRewrite = async (style = "auto") => {
78
78
  if (!replyBody.trim()) return;
79
79
  setAiRewriting(true);
80
80
  try {
@@ -82,7 +82,7 @@ function useAI(messages, client, ticketSubject, replyBody, setReplyBody, setRepl
82
82
  method: "POST",
83
83
  headers: { "Content-Type": "application/json" },
84
84
  credentials: "include",
85
- body: JSON.stringify({ action: "rewrite", text: replyBody })
85
+ body: JSON.stringify({ action: "rewrite", text: replyBody, style })
86
86
  });
87
87
  if (res.ok) {
88
88
  const data = await res.json();
@@ -72,6 +72,100 @@ const layoutStyles = {
72
72
  top: "80px"
73
73
  }
74
74
  };
75
+ const REWRITE_STYLES = [
76
+ { id: "auto", label: "\u270F\uFE0F Auto", desc: "Garde le ton actuel" },
77
+ { id: "tutoyer", label: "\u{1F44B} Tutoyer", desc: "Passe en tu" },
78
+ { id: "vouvoyer", label: "\u{1F3A9} Vouvoyer", desc: "Passe en vous" },
79
+ { id: "formel", label: "\u{1F4BC} Formel", desc: "Ton professionnel" },
80
+ { id: "amical", label: "\u{1F60A} Amical", desc: "Ton chaleureux" },
81
+ { id: "court", label: "\u26A1 Court", desc: "Version concise" }
82
+ ];
83
+ const RewriteDropdown = ({ disabled, loading, onSelect }) => {
84
+ const [open, setOpen] = React.useState(false);
85
+ const ref = React__default.default.useRef(null);
86
+ React__default.default.useEffect(() => {
87
+ if (!open) return;
88
+ const close = (e) => {
89
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
90
+ };
91
+ document.addEventListener("mousedown", close);
92
+ return () => document.removeEventListener("mousedown", close);
93
+ }, [open]);
94
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, style: { position: "relative", display: "inline-block" }, children: [
95
+ /* @__PURE__ */ jsxRuntime.jsxs(
96
+ "button",
97
+ {
98
+ type: "button",
99
+ onClick: () => setOpen(!open),
100
+ disabled,
101
+ style: {
102
+ ...constants.s.outlineBtn("#0891b2", disabled),
103
+ fontSize: "11px",
104
+ padding: "3px 10px",
105
+ borderRadius: "14px",
106
+ display: "flex",
107
+ alignItems: "center",
108
+ gap: "4px"
109
+ },
110
+ children: [
111
+ loading ? "Reformulation..." : "\u270F\uFE0F Reformuler",
112
+ !loading && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 9, opacity: 0.7 }, children: "\u25BC" })
113
+ ]
114
+ }
115
+ ),
116
+ open && !disabled && !loading && /* @__PURE__ */ jsxRuntime.jsx(
117
+ "div",
118
+ {
119
+ style: {
120
+ position: "absolute",
121
+ bottom: "100%",
122
+ left: 0,
123
+ marginBottom: 4,
124
+ background: "var(--theme-elevation-0, #fff)",
125
+ border: "1px solid var(--theme-elevation-200, #e5e7eb)",
126
+ borderRadius: 8,
127
+ boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
128
+ zIndex: 100,
129
+ minWidth: 180,
130
+ overflow: "hidden"
131
+ },
132
+ children: REWRITE_STYLES.map((style) => /* @__PURE__ */ jsxRuntime.jsxs(
133
+ "button",
134
+ {
135
+ type: "button",
136
+ onClick: () => {
137
+ setOpen(false);
138
+ onSelect(style.id);
139
+ },
140
+ style: {
141
+ display: "flex",
142
+ flexDirection: "column",
143
+ width: "100%",
144
+ padding: "8px 12px",
145
+ border: "none",
146
+ background: "transparent",
147
+ cursor: "pointer",
148
+ textAlign: "left",
149
+ borderBottom: "1px solid var(--theme-elevation-100, #f3f4f6)",
150
+ transition: "background 120ms"
151
+ },
152
+ onMouseEnter: (e) => {
153
+ e.target.style.background = "var(--theme-elevation-50, #f9fafb)";
154
+ },
155
+ onMouseLeave: (e) => {
156
+ e.target.style.background = "transparent";
157
+ },
158
+ children: [
159
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 12, fontWeight: 600, color: "var(--theme-text, #111)" }, children: style.label }),
160
+ /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: 10, color: "var(--theme-elevation-500, #6b7280)" }, children: style.desc })
161
+ ]
162
+ },
163
+ style.id
164
+ ))
165
+ }
166
+ )
167
+ ] });
168
+ };
75
169
  const TicketConversation = () => {
76
170
  const { id } = useDocumentIdFromUrl();
77
171
  const [features] = React.useState(() => config.getFeatures());
@@ -805,12 +899,11 @@ const TicketConversation = () => {
805
899
  }
806
900
  ),
807
901
  features.ai && /* @__PURE__ */ jsxRuntime.jsx(
808
- "button",
902
+ RewriteDropdown,
809
903
  {
810
- onClick: handleAiRewrite,
811
904
  disabled: aiRewriting || !replyBody.trim(),
812
- style: { ...constants.s.outlineBtn("#0891b2", aiRewriting || !replyBody.trim()), fontSize: "11px", padding: "3px 10px", borderRadius: "14px" },
813
- children: aiRewriting ? "Reformulation..." : "Reformuler"
905
+ loading: aiRewriting,
906
+ onSelect: (style) => handleAiRewrite(style)
814
907
  }
815
908
  ),
816
909
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -67,6 +67,100 @@ const layoutStyles = {
67
67
  top: "80px"
68
68
  }
69
69
  };
70
+ const REWRITE_STYLES = [
71
+ { id: "auto", label: "\u270F\uFE0F Auto", desc: "Garde le ton actuel" },
72
+ { id: "tutoyer", label: "\u{1F44B} Tutoyer", desc: "Passe en tu" },
73
+ { id: "vouvoyer", label: "\u{1F3A9} Vouvoyer", desc: "Passe en vous" },
74
+ { id: "formel", label: "\u{1F4BC} Formel", desc: "Ton professionnel" },
75
+ { id: "amical", label: "\u{1F60A} Amical", desc: "Ton chaleureux" },
76
+ { id: "court", label: "\u26A1 Court", desc: "Version concise" }
77
+ ];
78
+ const RewriteDropdown = ({ disabled, loading, onSelect }) => {
79
+ const [open, setOpen] = useState(false);
80
+ const ref = React.useRef(null);
81
+ React.useEffect(() => {
82
+ if (!open) return;
83
+ const close = (e) => {
84
+ if (ref.current && !ref.current.contains(e.target)) setOpen(false);
85
+ };
86
+ document.addEventListener("mousedown", close);
87
+ return () => document.removeEventListener("mousedown", close);
88
+ }, [open]);
89
+ return /* @__PURE__ */ jsxs("div", { ref, style: { position: "relative", display: "inline-block" }, children: [
90
+ /* @__PURE__ */ jsxs(
91
+ "button",
92
+ {
93
+ type: "button",
94
+ onClick: () => setOpen(!open),
95
+ disabled,
96
+ style: {
97
+ ...s.outlineBtn("#0891b2", disabled),
98
+ fontSize: "11px",
99
+ padding: "3px 10px",
100
+ borderRadius: "14px",
101
+ display: "flex",
102
+ alignItems: "center",
103
+ gap: "4px"
104
+ },
105
+ children: [
106
+ loading ? "Reformulation..." : "\u270F\uFE0F Reformuler",
107
+ !loading && /* @__PURE__ */ jsx("span", { style: { fontSize: 9, opacity: 0.7 }, children: "\u25BC" })
108
+ ]
109
+ }
110
+ ),
111
+ open && !disabled && !loading && /* @__PURE__ */ jsx(
112
+ "div",
113
+ {
114
+ style: {
115
+ position: "absolute",
116
+ bottom: "100%",
117
+ left: 0,
118
+ marginBottom: 4,
119
+ background: "var(--theme-elevation-0, #fff)",
120
+ border: "1px solid var(--theme-elevation-200, #e5e7eb)",
121
+ borderRadius: 8,
122
+ boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
123
+ zIndex: 100,
124
+ minWidth: 180,
125
+ overflow: "hidden"
126
+ },
127
+ children: REWRITE_STYLES.map((style) => /* @__PURE__ */ jsxs(
128
+ "button",
129
+ {
130
+ type: "button",
131
+ onClick: () => {
132
+ setOpen(false);
133
+ onSelect(style.id);
134
+ },
135
+ style: {
136
+ display: "flex",
137
+ flexDirection: "column",
138
+ width: "100%",
139
+ padding: "8px 12px",
140
+ border: "none",
141
+ background: "transparent",
142
+ cursor: "pointer",
143
+ textAlign: "left",
144
+ borderBottom: "1px solid var(--theme-elevation-100, #f3f4f6)",
145
+ transition: "background 120ms"
146
+ },
147
+ onMouseEnter: (e) => {
148
+ e.target.style.background = "var(--theme-elevation-50, #f9fafb)";
149
+ },
150
+ onMouseLeave: (e) => {
151
+ e.target.style.background = "transparent";
152
+ },
153
+ children: [
154
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 12, fontWeight: 600, color: "var(--theme-text, #111)" }, children: style.label }),
155
+ /* @__PURE__ */ jsx("span", { style: { fontSize: 10, color: "var(--theme-elevation-500, #6b7280)" }, children: style.desc })
156
+ ]
157
+ },
158
+ style.id
159
+ ))
160
+ }
161
+ )
162
+ ] });
163
+ };
70
164
  const TicketConversation = () => {
71
165
  const { id } = useDocumentIdFromUrl();
72
166
  const [features] = useState(() => getFeatures());
@@ -800,12 +894,11 @@ const TicketConversation = () => {
800
894
  }
801
895
  ),
802
896
  features.ai && /* @__PURE__ */ jsx(
803
- "button",
897
+ RewriteDropdown,
804
898
  {
805
- onClick: handleAiRewrite,
806
899
  disabled: aiRewriting || !replyBody.trim(),
807
- style: { ...s.outlineBtn("#0891b2", aiRewriting || !replyBody.trim()), fontSize: "11px", padding: "3px 10px", borderRadius: "14px" },
808
- children: aiRewriting ? "Reformulation..." : "Reformuler"
900
+ loading: aiRewriting,
901
+ onSelect: (style) => handleAiRewrite(style)
809
902
  }
810
903
  ),
811
904
  /* @__PURE__ */ jsx(