@nivaro/react 0.3.23 → 0.3.24

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.
@@ -1,17 +1,17 @@
1
1
  import { jsx as m, jsxs as f, Fragment as h } from "react/jsx-runtime";
2
- import { Inbox as b, Bell as u, Mail as k, MessageSquare as x } from "lucide-react";
3
- const y = {
2
+ import { Inbox as b, Bell as u, Mail as k, Users as x, MessageSquare as y } from "lucide-react";
3
+ const g = {
4
4
  ok: "text-emerald-700 dark:text-emerald-400",
5
5
  muted: "text-slate-400 dark:text-slate-500",
6
6
  warn: "text-amber-700 dark:text-amber-400",
7
7
  bad: "text-red-600 dark:text-red-400"
8
8
  };
9
- function $(i) {
10
- return c(i);
9
+ function S(n) {
10
+ return c(n);
11
11
  }
12
- function c(i) {
13
- var o, a, r, n;
14
- const e = i ?? { inapp: { status: "delivered" } }, s = [], l = ((o = e.inapp) == null ? void 0 : o.status) ?? "delivered";
12
+ function c(n) {
13
+ var o, a, r, i;
14
+ const e = n ?? { inapp: { status: "delivered" } }, s = [], l = ((o = e.inapp) == null ? void 0 : o.status) ?? "delivered";
15
15
  if (s.push({
16
16
  key: "inapp",
17
17
  icon: b,
@@ -39,41 +39,51 @@ function c(i) {
39
39
  mailLogId: e.email.mail_log_id ?? null
40
40
  });
41
41
  }
42
- return ((r = e.escalation) != null && r.email_at || (n = e.escalation) != null && n.push_at) && s.push({
42
+ if (((r = e.escalation) != null && r.email_at || (i = e.escalation) != null && i.push_at) && s.push({
43
43
  key: "escalation",
44
44
  icon: u,
45
45
  label: e.escalation.email_at ? "Escalated · email" : "Escalated · push",
46
46
  tone: "warn",
47
47
  tip: `Still unread, so it climbed channels${e.escalation.push_at ? ` · pushed ${new Date(e.escalation.push_at).toLocaleString()}` : ""}${e.escalation.email_at ? ` · emailed ${new Date(e.escalation.email_at).toLocaleString()}` : ""}`,
48
48
  mailLogId: e.escalation.email_log_id ?? null
49
- }), e.sms && e.sms.status !== "not_requested" && s.push({
49
+ }), e.teams) {
50
+ const t = e.teams.status;
51
+ s.push({
52
+ key: "teams",
53
+ icon: x,
54
+ label: t === "sent" ? "Teams" : `Teams · ${t.replace(/_/g, " ")}`,
55
+ tone: t === "sent" ? "ok" : t === "failed" ? "bad" : "muted",
56
+ tip: t === "sent" ? "Sent in Microsoft Teams" : t === "not_connected" ? "Teams not connected" : e.teams.reason ?? `Teams ${t}`
57
+ });
58
+ }
59
+ return e.sms && e.sms.status !== "not_requested" && s.push({
50
60
  key: "sms",
51
- icon: x,
61
+ icon: y,
52
62
  label: "SMS",
53
63
  tone: e.sms.status === "sent" ? "ok" : e.sms.status === "failed" ? "bad" : "muted",
54
64
  tip: e.sms.status === "sent" ? "Text sent" : e.sms.reason ?? `SMS ${e.sms.status}`
55
65
  }), s;
56
66
  }
57
- function w({ delivery: i, mailLogUrl: e, onNavigate: s, className: l }) {
58
- const o = c(i);
67
+ function w({ delivery: n, mailLogUrl: e, onNavigate: s, className: l }) {
68
+ const o = c(n);
59
69
  return /* @__PURE__ */ m(
60
70
  "span",
61
71
  {
62
72
  className: `inline-flex flex-wrap items-center gap-1 ${l ?? ""}`,
63
73
  "data-nvr-delivery": !0,
64
74
  children: o.map((a) => {
65
- const r = a.icon, n = a.mailLogId != null && e ? e(a.mailLogId) : null, t = /* @__PURE__ */ f(h, { children: [
75
+ const r = a.icon, i = a.mailLogId != null && e ? e(a.mailLogId) : null, t = /* @__PURE__ */ f(h, { children: [
66
76
  /* @__PURE__ */ m(r, { className: "h-2.5 w-2.5", strokeWidth: 2 }),
67
77
  a.label
68
- ] }), d = `inline-flex items-center gap-0.5 rounded border border-slate-200/70 px-1 py-px text-[9.5px] font-medium leading-none dark:border-border ${y[a.tone]}`;
69
- return n ? /* @__PURE__ */ m(
78
+ ] }), d = `inline-flex items-center gap-0.5 rounded border border-slate-200/70 px-1 py-px text-[9.5px] font-medium leading-none dark:border-border ${g[a.tone]}`;
79
+ return i ? /* @__PURE__ */ m(
70
80
  "button",
71
81
  {
72
82
  type: "button",
73
83
  "data-tip": `${a.tip} · open mail log`,
74
84
  title: a.tip,
75
85
  onClick: (p) => {
76
- p.stopPropagation(), s == null || s(n);
86
+ p.stopPropagation(), s == null || s(i);
77
87
  },
78
88
  className: `${d} underline decoration-dotted underline-offset-2`,
79
89
  children: t
@@ -86,5 +96,5 @@ function w({ delivery: i, mailLogUrl: e, onNavigate: s, className: l }) {
86
96
  }
87
97
  export {
88
98
  w as DeliveryChips,
89
- $ as describeDelivery
99
+ S as describeDelivery
90
100
  };
@@ -0,0 +1,71 @@
1
+ import { jsxs as t, Fragment as m, jsx as e } from "react/jsx-runtime";
2
+ import { useQueryClient as l, useMutation as c } from "@tanstack/react-query";
3
+ import { useState as u } from "react";
4
+ import { useNivaroClient as f } from "../../context.js";
5
+ import { del as x } from "../../lib/commands.js";
6
+ import { Popover as p, PopoverTrigger as g, PopoverContent as h } from "../ui/popover.js";
7
+ import { ConfirmButton as k } from "./primitives.js";
8
+ function P({ linked: a, linkedAt: r }) {
9
+ const i = f(), d = l(), [s, n] = u(!1), o = c({
10
+ mutationFn: () => (n(!1), i.request(x("/teams/link"))),
11
+ onError: () => n(!0),
12
+ onSettled: () => {
13
+ d.invalidateQueries({ queryKey: ["nvr-profile-teams"] });
14
+ }
15
+ });
16
+ return a ? /* @__PURE__ */ t(m, { children: [
17
+ /* @__PURE__ */ t(
18
+ "span",
19
+ {
20
+ className: "inline-flex flex-wrap items-center justify-center gap-1 text-[10.5px] font-normal normal-case tracking-normal text-emerald-700 dark:text-emerald-400",
21
+ "data-teams-connected": "",
22
+ title: r ? `Connected ${new Date(r).toLocaleString()}` : void 0,
23
+ children: [
24
+ "Connected ·",
25
+ " ",
26
+ /* @__PURE__ */ e(
27
+ k,
28
+ {
29
+ onConfirm: () => o.mutate(),
30
+ confirmLabel: "Disconnect Teams?",
31
+ disabled: o.isPending,
32
+ className: "font-medium text-slate-500 underline decoration-dotted underline-offset-2 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground",
33
+ armedClassName: "font-medium text-red-600 dark:text-red-400",
34
+ children: "Disconnect"
35
+ }
36
+ )
37
+ ]
38
+ }
39
+ ),
40
+ s && /* @__PURE__ */ e(
41
+ "p",
42
+ {
43
+ role: "alert",
44
+ "data-teams-disconnect-error": "",
45
+ className: "mt-0.5 text-[10.5px] font-normal normal-case tracking-normal text-red-600 dark:text-red-400",
46
+ children: "Could not disconnect Teams. Try again; if it keeps failing, ask an admin."
47
+ }
48
+ )
49
+ ] }) : /* @__PURE__ */ t(p, { children: [
50
+ /* @__PURE__ */ e(g, { asChild: !0, children: /* @__PURE__ */ e(
51
+ "button",
52
+ {
53
+ type: "button",
54
+ "data-teams-connect": "",
55
+ className: "rounded border border-slate-200 px-1.5 py-0.5 text-[10.5px] font-medium normal-case tracking-normal text-slate-600 hover:border-slate-400 hover:text-slate-800 dark:border-border dark:text-muted-foreground dark:hover:text-foreground",
56
+ children: "Connect Teams"
57
+ }
58
+ ) }),
59
+ /* @__PURE__ */ e(
60
+ h,
61
+ {
62
+ align: "end",
63
+ className: "w-64 text-[12px] font-normal normal-case tracking-normal text-slate-600 dark:text-muted-foreground",
64
+ children: "Open Nivaro in Teams and say hi, or sign in with Microsoft once, then turn categories on."
65
+ }
66
+ )
67
+ ] });
68
+ }
69
+ export {
70
+ P as TeamsConnect
71
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsxs as c, jsx as a, Fragment as x } from "react/jsx-runtime";
2
- import { Children as f, useState as p, useEffect as g } from "react";
2
+ import { useState as f, useEffect as p, Children as g } from "react";
3
3
  import { useNavigation as b } from "../../context.js";
4
4
  import { cn as o } from "../../lib/utils.js";
5
5
  import { UserAvatar as k } from "../UserAvatar.js";
@@ -121,8 +121,8 @@ function P({
121
121
  title: l,
122
122
  disabled: s
123
123
  }) {
124
- const [i, m] = p(!1);
125
- return g(() => {
124
+ const [i, m] = f(!1);
125
+ return p(() => {
126
126
  if (!i) return;
127
127
  const u = window.setTimeout(() => m(!1), 3e3);
128
128
  return () => window.clearTimeout(u);
@@ -148,7 +148,7 @@ function T({ label: e, children: t }) {
148
148
  ] });
149
149
  }
150
150
  function B({ children: e, cols: t = 3 }) {
151
- const r = f.toArray(e).filter(Boolean).length, n = t === 3 ? 6 : t, d = (n - r % n) % n;
151
+ const r = g.toArray(e).filter(Boolean).length, n = t === 3 ? 6 : t, d = (n - r % n) % n;
152
152
  return /* @__PURE__ */ c(
153
153
  "div",
154
154
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nivaro/react",
3
- "version": "0.3.23",
3
+ "version": "0.3.24",
4
4
  "description": "React hooks and components for Nivaro CMS forms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",