@tmls-ai/support 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. package/dist/index.js +94 -40
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -135,6 +135,17 @@ function SupportWidget(props) {
135
135
  const [messages, setMessages] = useState([]);
136
136
  const [shotUrls, setShotUrls] = useState({});
137
137
  const [reply, setReply] = useState("");
138
+ const [isMobile, setIsMobile] = useState(
139
+ () => typeof window !== "undefined" && window.matchMedia("(max-width: 767px)").matches
140
+ );
141
+ useEffect(() => {
142
+ if (typeof window === "undefined") return;
143
+ const mq = window.matchMedia("(max-width: 767px)");
144
+ const onChange = () => setIsMobile(mq.matches);
145
+ onChange();
146
+ mq.addEventListener("change", onChange);
147
+ return () => mq.removeEventListener("change", onChange);
148
+ }, []);
138
149
  useEffect(() => {
139
150
  installErrorCapture();
140
151
  }, []);
@@ -251,27 +262,92 @@ function SupportWidget(props) {
251
262
  background: active ? accent : "transparent",
252
263
  color: active ? "#fff" : "#c8c8d0"
253
264
  });
265
+ const toggle = () => {
266
+ if (open) deeplinkTicket = null;
267
+ setOpen((o) => !o);
268
+ if (!open && withShot) captureShot();
269
+ };
270
+ const panelStyle = isMobile ? {
271
+ position: "fixed",
272
+ left: 0,
273
+ right: 0,
274
+ bottom: 0,
275
+ width: "auto",
276
+ maxHeight: "85vh",
277
+ background: "#141418",
278
+ color: "#e8e8ea",
279
+ borderTop: "0.5px solid rgba(255,255,255,0.12)",
280
+ borderRadius: "16px 16px 0 0",
281
+ boxShadow: "0 -16px 48px rgba(0,0,0,0.5)",
282
+ overflow: "hidden",
283
+ display: "flex",
284
+ flexDirection: "column",
285
+ zIndex: 2147483e3,
286
+ paddingBottom: "env(safe-area-inset-bottom, 0px)"
287
+ } : {
288
+ position: "absolute",
289
+ bottom: 60,
290
+ right: 0,
291
+ width: 360,
292
+ maxHeight: 560,
293
+ background: "#141418",
294
+ color: "#e8e8ea",
295
+ border: "0.5px solid rgba(255,255,255,0.12)",
296
+ borderRadius: 16,
297
+ boxShadow: "0 16px 48px rgba(0,0,0,0.5)",
298
+ overflow: "hidden",
299
+ display: "flex",
300
+ flexDirection: "column"
301
+ };
302
+ const launcherStyle = isMobile ? {
303
+ position: "fixed",
304
+ right: 0,
305
+ top: "50%",
306
+ transform: "translateY(-50%)",
307
+ width: 30,
308
+ height: 56,
309
+ borderRadius: "14px 0 0 14px",
310
+ border: "none",
311
+ cursor: "pointer",
312
+ background: accent,
313
+ color: "#fff",
314
+ fontSize: 20,
315
+ boxShadow: "-3px 0 14px rgba(0,0,0,0.4)",
316
+ display: "flex",
317
+ alignItems: "center",
318
+ justifyContent: "center",
319
+ paddingRight: 4,
320
+ zIndex: 2147483e3
321
+ } : {
322
+ width: 48,
323
+ height: 48,
324
+ borderRadius: 999,
325
+ border: "none",
326
+ cursor: "pointer",
327
+ background: accent,
328
+ color: "#fff",
329
+ fontSize: 22,
330
+ boxShadow: "0 4px 16px rgba(0,0,0,0.35)"
331
+ };
254
332
  return /* @__PURE__ */ jsxs("div", { "data-tmls-support-root": "true", style: { position: "fixed", bottom: 20, right: 20, zIndex: 2147483e3, fontFamily: "system-ui, sans-serif" }, children: [
255
- open && /* @__PURE__ */ jsxs("div", { style: {
256
- position: "absolute",
257
- bottom: 60,
258
- right: 0,
259
- width: 360,
260
- maxHeight: 560,
261
- background: "#141418",
262
- color: "#e8e8ea",
263
- border: "0.5px solid rgba(255,255,255,0.12)",
264
- borderRadius: 16,
265
- boxShadow: "0 16px 48px rgba(0,0,0,0.5)",
266
- overflow: "hidden",
267
- display: "flex",
268
- flexDirection: "column"
269
- }, children: [
333
+ open && /* @__PURE__ */ jsxs("div", { style: panelStyle, children: [
270
334
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "12px 14px", borderBottom: "0.5px solid rgba(255,255,255,0.08)" }, children: [
271
335
  /* @__PURE__ */ jsx("strong", { style: { fontSize: 14 }, children: "Support" }),
272
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, fontSize: 12 }, children: [
336
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, fontSize: 12, alignItems: "center" }, children: [
273
337
  /* @__PURE__ */ jsx("button", { onClick: () => setView("new"), style: tab(view === "new" || view === "sent", accent), children: "New" }),
274
- /* @__PURE__ */ jsx("button", { onClick: openThreads, style: tab(view === "threads" || view === "thread", accent), children: "My tickets" })
338
+ /* @__PURE__ */ jsx("button", { onClick: openThreads, style: tab(view === "threads" || view === "thread", accent), children: "My tickets" }),
339
+ isMobile && /* @__PURE__ */ jsx(
340
+ "button",
341
+ {
342
+ onClick: () => {
343
+ deeplinkTicket = null;
344
+ setOpen(false);
345
+ },
346
+ "aria-label": "Close",
347
+ style: { background: "transparent", border: "none", cursor: "pointer", color: "#8a8a92", fontSize: 20, lineHeight: 1, padding: "0 2px" },
348
+ children: "\xD7"
349
+ }
350
+ )
275
351
  ] })
276
352
  ] }),
277
353
  /* @__PURE__ */ jsxs("div", { style: { padding: 14, overflowY: "auto" }, children: [
@@ -362,29 +438,7 @@ function SupportWidget(props) {
362
438
  ] })
363
439
  ] })
364
440
  ] }),
365
- /* @__PURE__ */ jsx(
366
- "button",
367
- {
368
- onClick: () => {
369
- if (open) deeplinkTicket = null;
370
- setOpen((o) => !o);
371
- if (!open && withShot) captureShot();
372
- },
373
- "aria-label": "Support",
374
- style: {
375
- width: 48,
376
- height: 48,
377
- borderRadius: 999,
378
- border: "none",
379
- cursor: "pointer",
380
- background: accent,
381
- color: "#fff",
382
- fontSize: 22,
383
- boxShadow: "0 4px 16px rgba(0,0,0,0.35)"
384
- },
385
- children: open ? "\xD7" : "?"
386
- }
387
- )
441
+ (!isMobile || !open) && /* @__PURE__ */ jsx("button", { onClick: toggle, "aria-label": "Support", style: launcherStyle, children: open && !isMobile ? "\xD7" : "?" })
388
442
  ] });
389
443
  }
390
444
  var tab = (active, accent) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmls-ai/support",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Embeddable Timeless support widget — bottom-right report overlay (type / severity / screenshot) + ticket thread. Auto-captures context, talks to tmls-support-api.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",