@nivaro/react 0.2.54 → 0.2.55
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +99 -98
- package/dist/index.d.ts +339 -2
- package/dist/index.js +644 -618
- package/dist/layout-editor.d.ts +4 -0
- package/dist/shared/components/BackgroundRunOffer.js +117 -0
- package/dist/shared/components/BroadcastView.js +214 -213
- package/dist/shared/components/CollectionBrowserView.js +2592 -2695
- package/dist/shared/components/ItemEditForm.js +4066 -3832
- package/dist/shared/components/JobsTray.js +100 -55
- package/dist/shared/components/MyWorkView.js +91 -89
- package/dist/shared/components/NotificationBell.js +80 -79
- package/dist/shared/components/ProfileView.js +568 -520
- package/dist/shared/components/RecordCompare.js +254 -0
- package/dist/shared/components/RecordReadView.js +599 -552
- package/dist/shared/components/ReportView.js +578 -543
- package/dist/shared/components/RowPresence.js +91 -0
- package/dist/shared/components/WidgetSlot.js +474 -458
- package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
- package/dist/shared/components/ai/AskPanel.js +139 -119
- package/dist/shared/components/ai/FirstWeekCard.js +126 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
- package/dist/shared/components/bulk/bulk-field-options.js +45 -0
- package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
- package/dist/shared/components/chat/ChannelArchive.js +326 -0
- package/dist/shared/components/chat/ChannelExtras.js +141 -121
- package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
- package/dist/shared/components/chat/ChatPanel.js +1695 -1733
- package/dist/shared/components/chat/Composer.js +357 -303
- package/dist/shared/components/chat/MessageActions.js +92 -0
- package/dist/shared/components/chat/MessageFormat.js +290 -264
- package/dist/shared/components/chat/OutboxBubbles.js +146 -0
- package/dist/shared/components/chat/RequestIdCard.js +135 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
- package/dist/shared/components/chat/RoomParts.js +213 -274
- package/dist/shared/components/chat/ScreenClip.js +184 -0
- package/dist/shared/components/chat/chat-core.js +402 -483
- package/dist/shared/components/chat/chat-drafts.js +59 -0
- package/dist/shared/components/chat/chat-emoji.js +348 -0
- package/dist/shared/components/chat/chat-local-time.js +41 -0
- package/dist/shared/components/chat/chat-outbox.js +303 -0
- package/dist/shared/components/chat/chat-window.js +163 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
- package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
- package/dist/shared/components/help-videos/api.js +76 -73
- package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
- package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
- package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
- package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
- package/dist/shared/components/item-edit/FieldRow.js +292 -279
- package/dist/shared/components/item-edit/GroupSection.js +698 -574
- package/dist/shared/components/item-edit/InlineTableField.js +3 -1
- package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
- package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
- package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
- package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
- package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
- package/dist/shared/components/item-edit/lazy-sections.js +36 -0
- package/dist/shared/components/item-edit/lock-why.js +39 -32
- package/dist/shared/components/item-edit/picker-miss.js +26 -0
- package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
- package/dist/shared/components/layout-editor/AddPanel.js +134 -117
- package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
- package/dist/shared/components/layout-editor/CollabParts.js +80 -75
- package/dist/shared/components/layout-editor/DesignNode.js +126 -120
- package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
- package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
- package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
- package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
- package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
- package/dist/shared/components/layout-editor/StagedChip.js +22 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
- package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
- package/dist/shared/components/layout-editor/dnd/node.js +69 -57
- package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
- package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
- package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
- package/dist/shared/components/layout-editor/entry/presets.js +71 -0
- package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
- package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
- package/dist/shared/components/layout-editor/grid-guides.js +142 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
- package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
- package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
- package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
- package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
- package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
- package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/restore-piece.js +192 -0
- package/dist/shared/components/layout-editor/section-structure.js +241 -0
- package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
- package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
- package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
- package/dist/shared/components/layout-editor/staged-api.js +64 -0
- package/dist/shared/components/layout-editor/structure-ops.js +81 -77
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
- package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
- package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
- package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
- package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
- package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
- package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
- package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
- package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
- package/dist/shared/components/profile/AgentsPanel.js +479 -0
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
- package/dist/shared/components/support/SupportAnalytics.js +171 -0
- package/dist/shared/components/support/SupportView.js +75 -73
- package/dist/shared/lib/background-runs.js +150 -0
- package/dist/shared/lib/delivery-ack.js +9 -0
- package/dist/shared/lib/entry-badge-style.js +13 -0
- package/dist/shared/lib/entry-config.js +71 -0
- package/dist/shared/lib/form-sections.js +64 -0
- package/dist/shared/lib/form-structure.js +99 -0
- package/dist/shared/lib/form-usage-beacon.js +101 -52
- package/dist/shared/lib/jobs-tray.js +25 -23
- package/dist/shared/lib/keyset-pager.js +37 -0
- package/dist/shared/lib/layout-ops.js +84 -82
- package/dist/shared/lib/layout-resolve.js +113 -0
- package/dist/shared/lib/placement-behaviour.js +144 -0
- package/dist/shared/lib/prefetch.js +149 -0
- package/dist/shared/lib/presence-hooks.js +199 -0
- package/dist/shared/lib/record-outbox.js +82 -81
- package/dist/shared/lib/replay-socket.js +93 -0
- package/dist/shared/lib/request-gate.js +51 -50
- package/dist/shared/lib/room-gaps.js +96 -0
- package/dist/shared/lib/search-log.js +27 -0
- package/dist/shared/lib/socket-realtime.js +101 -80
- package/dist/shared/lib/worker-socket.js +200 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useQueryClient as C, useQuery as I } from "@tanstack/react-query";
|
|
2
|
+
import { useEffect as f, useRef as h } from "react";
|
|
3
|
+
import { useNivaroClient as R } from "../../context.js";
|
|
4
|
+
import { get as E, put as Q, del as S } from "../../lib/commands.js";
|
|
5
|
+
import { useOptionalRealtime as D } from "../../lib/realtime.js";
|
|
6
|
+
const U = 1500, l = Math.random().toString(36).slice(2, 12);
|
|
7
|
+
function M(t = !0) {
|
|
8
|
+
const r = R(), e = D(), a = C(), { data: s } = I({
|
|
9
|
+
queryKey: ["nvr-chat-drafts"],
|
|
10
|
+
queryFn: () => r.request(E("/chat/drafts")).then((u) => (u.data ?? []).map((d) => d.room)),
|
|
11
|
+
enabled: t,
|
|
12
|
+
staleTime: 6e4
|
|
13
|
+
});
|
|
14
|
+
return f(() => {
|
|
15
|
+
if (!(!t || !e))
|
|
16
|
+
return e.on(
|
|
17
|
+
"chat:draft",
|
|
18
|
+
() => void a.invalidateQueries({ queryKey: ["nvr-chat-drafts"] })
|
|
19
|
+
);
|
|
20
|
+
}, [t, e, a]), new Set(s ?? []);
|
|
21
|
+
}
|
|
22
|
+
function N(t, r, e, a) {
|
|
23
|
+
const s = R(), u = D(), d = C(), c = h(""), p = h(e);
|
|
24
|
+
p.current = e;
|
|
25
|
+
const m = h(!1), q = async (n) => {
|
|
26
|
+
var o;
|
|
27
|
+
try {
|
|
28
|
+
const i = ((o = (await s.request(
|
|
29
|
+
E(`/chat/drafts/${encodeURIComponent(t)}`)
|
|
30
|
+
)).data) == null ? void 0 : o.body) ?? "", y = p.current;
|
|
31
|
+
(n ? y === "" : y === c.current) ? (c.current = i, i !== y && a(i)) : n && (c.current = i);
|
|
32
|
+
} catch {
|
|
33
|
+
} finally {
|
|
34
|
+
m.current = !0;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
f(() => {
|
|
38
|
+
r && (m.current = !1, c.current = "", q(!0));
|
|
39
|
+
}, [t, r]), f(() => {
|
|
40
|
+
if (!(!r || !u))
|
|
41
|
+
return u.on("chat:draft", (n) => {
|
|
42
|
+
!n || n.room !== t || n.device === l || q(!1);
|
|
43
|
+
});
|
|
44
|
+
}, [r, u, t]), f(() => {
|
|
45
|
+
if (!r || !m.current || e === c.current) return;
|
|
46
|
+
const n = setTimeout(() => {
|
|
47
|
+
const o = e, v = () => {
|
|
48
|
+
c.current = o, d.invalidateQueries({ queryKey: ["nvr-chat-drafts"] });
|
|
49
|
+
};
|
|
50
|
+
(o.trim() ? s.request(Q(`/chat/drafts/${encodeURIComponent(t)}`, { body: o, device: l })) : s.request(S(`/chat/drafts/${encodeURIComponent(t)}?device=${l}`))).then(v).catch(() => {
|
|
51
|
+
});
|
|
52
|
+
}, U);
|
|
53
|
+
return () => clearTimeout(n);
|
|
54
|
+
}, [e, t, r]);
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
M as useDraftRooms,
|
|
58
|
+
N as useDraftSync
|
|
59
|
+
};
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { jsx as o, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as _, useQueryClient as O } from "@tanstack/react-query";
|
|
3
|
+
import { Smile as q, Search as I, Trash2 as W, Plus as F } from "lucide-react";
|
|
4
|
+
import { useEffect as G, useState as p, useSyncExternalStore as K, useRef as L, useMemo as Q } from "react";
|
|
5
|
+
import { toast as x } from "sonner";
|
|
6
|
+
import { useNivaroClient as T, useApiFetchConfig as z, useItemEditAuth as U } from "../../context.js";
|
|
7
|
+
import { get as D, del as H } from "../../lib/commands.js";
|
|
8
|
+
import { cn as N } from "../../lib/utils.js";
|
|
9
|
+
import { Popover as J, PopoverTrigger as X, PopoverContent as Y } from "../ui/popover.js";
|
|
10
|
+
import { Skeleton as V } from "../ui/skeleton.js";
|
|
11
|
+
import { REACTION_EMOJI as Z } from "./chat-core.js";
|
|
12
|
+
const ee = /^:([a-z0-9][a-z0-9_+-]{1,39}):$/;
|
|
13
|
+
let w = /* @__PURE__ */ new Map();
|
|
14
|
+
const j = /* @__PURE__ */ new Set();
|
|
15
|
+
function te(t) {
|
|
16
|
+
w = t;
|
|
17
|
+
for (const a of j) a();
|
|
18
|
+
}
|
|
19
|
+
function re(t) {
|
|
20
|
+
return j.add(t), () => j.delete(t);
|
|
21
|
+
}
|
|
22
|
+
function oe() {
|
|
23
|
+
return K(
|
|
24
|
+
re,
|
|
25
|
+
() => w,
|
|
26
|
+
() => w
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function ae() {
|
|
30
|
+
const t = T(), a = z(), s = _({
|
|
31
|
+
queryKey: ["nvr-chat-emoji"],
|
|
32
|
+
queryFn: () => t.request(D("/chat/emoji")).then((i) => i.data ?? []),
|
|
33
|
+
staleTime: 5 * 6e4
|
|
34
|
+
}), r = s.data;
|
|
35
|
+
return G(() => {
|
|
36
|
+
r && te(
|
|
37
|
+
new Map(
|
|
38
|
+
r.map((i) => [i.shortcode, `${a.apiBase}/chat/emoji/${i.id}/image?v=${i.file}`])
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
}, [r, a.apiBase]), { emoji: r ?? [], loading: s.isLoading, error: s.isError };
|
|
42
|
+
}
|
|
43
|
+
function ie({ value: t, size: a = 16 }) {
|
|
44
|
+
const s = oe(), r = ee.exec(t), i = r ? s.get(r[1]) : void 0;
|
|
45
|
+
return i ? /* @__PURE__ */ o(
|
|
46
|
+
"img",
|
|
47
|
+
{
|
|
48
|
+
src: i,
|
|
49
|
+
alt: t,
|
|
50
|
+
"data-tip": t,
|
|
51
|
+
width: a,
|
|
52
|
+
height: a,
|
|
53
|
+
loading: "lazy",
|
|
54
|
+
draggable: !1,
|
|
55
|
+
className: "inline-block align-text-bottom object-contain",
|
|
56
|
+
style: { width: a, height: a },
|
|
57
|
+
"data-chat-custom-emoji": r == null ? void 0 : r[1]
|
|
58
|
+
}
|
|
59
|
+
) : /* @__PURE__ */ o("span", { children: t });
|
|
60
|
+
}
|
|
61
|
+
function ke(t, a, s) {
|
|
62
|
+
if (a.size === 0 || !t.includes(":")) return [t];
|
|
63
|
+
const r = [];
|
|
64
|
+
let i = 0, h = 0;
|
|
65
|
+
for (const n of t.matchAll(/:([a-z0-9][a-z0-9_+-]{1,39}):/g)) {
|
|
66
|
+
const l = a.get(n[1]);
|
|
67
|
+
if (!l) continue;
|
|
68
|
+
const u = n.index ?? 0;
|
|
69
|
+
u > i && r.push(t.slice(i, u)), r.push(
|
|
70
|
+
/* @__PURE__ */ o(
|
|
71
|
+
"img",
|
|
72
|
+
{
|
|
73
|
+
src: l,
|
|
74
|
+
alt: n[0],
|
|
75
|
+
"data-tip": n[0],
|
|
76
|
+
loading: "lazy",
|
|
77
|
+
draggable: !1,
|
|
78
|
+
className: "mx-px inline-block h-[1.25em] w-[1.25em] align-text-bottom object-contain",
|
|
79
|
+
"data-chat-custom-emoji": n[1]
|
|
80
|
+
},
|
|
81
|
+
`${s}.em${h++}`
|
|
82
|
+
)
|
|
83
|
+
), i = u + n[0].length;
|
|
84
|
+
}
|
|
85
|
+
return i === 0 ? [t] : (i < t.length && r.push(t.slice(i)), r);
|
|
86
|
+
}
|
|
87
|
+
const se = [
|
|
88
|
+
...Z,
|
|
89
|
+
"🙌",
|
|
90
|
+
"🙏",
|
|
91
|
+
"🔥",
|
|
92
|
+
"🚀",
|
|
93
|
+
"💡",
|
|
94
|
+
"👏",
|
|
95
|
+
"😄",
|
|
96
|
+
"😅",
|
|
97
|
+
"🤔",
|
|
98
|
+
"😮",
|
|
99
|
+
"😢",
|
|
100
|
+
"👎",
|
|
101
|
+
"❌",
|
|
102
|
+
"⚠️",
|
|
103
|
+
"📌",
|
|
104
|
+
"⏳"
|
|
105
|
+
], k = 256 * 1024;
|
|
106
|
+
function ne({
|
|
107
|
+
onPick: t,
|
|
108
|
+
children: a,
|
|
109
|
+
align: s = "start",
|
|
110
|
+
onOpenChange: r
|
|
111
|
+
}) {
|
|
112
|
+
const [i, h] = p(!1), n = (l) => {
|
|
113
|
+
h(l), r == null || r(l);
|
|
114
|
+
};
|
|
115
|
+
return /* @__PURE__ */ m(J, { open: i, onOpenChange: n, children: [
|
|
116
|
+
/* @__PURE__ */ o(X, { asChild: !0, children: a }),
|
|
117
|
+
/* @__PURE__ */ o(Y, { align: s, className: "w-[264px] p-0", "data-chat-emoji-picker": !0, children: i && /* @__PURE__ */ o(
|
|
118
|
+
le,
|
|
119
|
+
{
|
|
120
|
+
onPick: (l) => {
|
|
121
|
+
t(l), n(!1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
) })
|
|
125
|
+
] });
|
|
126
|
+
}
|
|
127
|
+
function le({ onPick: t }) {
|
|
128
|
+
const [a, s] = p("common"), { emoji: r, loading: i, error: h } = ae(), [n, l] = p(""), u = (c, v) => /* @__PURE__ */ o(
|
|
129
|
+
"button",
|
|
130
|
+
{
|
|
131
|
+
type: "button",
|
|
132
|
+
role: "tab",
|
|
133
|
+
"aria-selected": a === c,
|
|
134
|
+
onClick: () => s(c),
|
|
135
|
+
className: N(
|
|
136
|
+
"h-7 flex-1 rounded-md text-[12px] font-medium transition-colors",
|
|
137
|
+
a === c ? "bg-slate-100 text-slate-900 dark:bg-muted dark:text-slate-100" : "text-slate-500 hover:text-slate-800 dark:text-slate-400 dark:hover:text-slate-100"
|
|
138
|
+
),
|
|
139
|
+
"data-chat-emoji-tab": c,
|
|
140
|
+
children: v
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
return /* @__PURE__ */ m("div", { children: [
|
|
144
|
+
/* @__PURE__ */ m("div", { role: "tablist", className: "flex gap-1 border-b border-slate-200 p-1.5 dark:border-border", children: [
|
|
145
|
+
u("common", "Common"),
|
|
146
|
+
u("workspace", r.length ? `Workspace · ${r.length}` : "Workspace")
|
|
147
|
+
] }),
|
|
148
|
+
a === "common" ? /* @__PURE__ */ o("div", { className: "grid grid-cols-8 gap-0.5 p-2", children: se.map((c) => /* @__PURE__ */ o(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
onClick: () => t(c),
|
|
153
|
+
className: "flex h-7 w-7 items-center justify-center rounded-md text-[16px] hover:bg-slate-100 dark:hover:bg-muted",
|
|
154
|
+
"aria-label": c,
|
|
155
|
+
children: c
|
|
156
|
+
},
|
|
157
|
+
c
|
|
158
|
+
)) }) : /* @__PURE__ */ o(
|
|
159
|
+
ce,
|
|
160
|
+
{
|
|
161
|
+
emoji: r,
|
|
162
|
+
loading: i,
|
|
163
|
+
error: h,
|
|
164
|
+
q: n,
|
|
165
|
+
setQ: l,
|
|
166
|
+
onPick: t
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] });
|
|
170
|
+
}
|
|
171
|
+
function ce({
|
|
172
|
+
emoji: t,
|
|
173
|
+
loading: a,
|
|
174
|
+
error: s,
|
|
175
|
+
q: r,
|
|
176
|
+
setQ: i,
|
|
177
|
+
onPick: h
|
|
178
|
+
}) {
|
|
179
|
+
const { isAdmin: n } = U(), l = z(), u = T(), c = O(), [v, C] = p(!1), [g, E] = p(""), [$, A] = p(!1), [f, y] = p(null), b = L(null), S = Q(
|
|
180
|
+
() => t.filter((e) => !r.trim() || e.shortcode.includes(r.trim().toLowerCase())),
|
|
181
|
+
[t, r]
|
|
182
|
+
), B = () => void c.invalidateQueries({ queryKey: ["nvr-chat-emoji"] }), M = async (e) => {
|
|
183
|
+
if (e) {
|
|
184
|
+
if (e.size > k) {
|
|
185
|
+
x.error(`Emoji images are limited to ${k / 1024} KB`);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
A(!0);
|
|
189
|
+
try {
|
|
190
|
+
const d = new FormData();
|
|
191
|
+
d.append("file", e);
|
|
192
|
+
const P = await fetch(
|
|
193
|
+
`${l.apiBase}/chat/emoji?shortcode=${encodeURIComponent(g)}`,
|
|
194
|
+
{
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: l.authHeaders,
|
|
197
|
+
credentials: l.credentials,
|
|
198
|
+
body: d
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
if (!P.ok) {
|
|
202
|
+
const R = await P.json().catch(() => ({}));
|
|
203
|
+
x.error(R.error ?? "Could not add that emoji");
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
x.success(`Added :${g}:`), E(""), C(!1), B();
|
|
207
|
+
} finally {
|
|
208
|
+
A(!1), b.current && (b.current.value = "");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
return /* @__PURE__ */ m("div", { children: [
|
|
213
|
+
/* @__PURE__ */ m("div", { className: "relative px-2 pt-2", children: [
|
|
214
|
+
/* @__PURE__ */ o(I, { className: "pointer-events-none absolute left-4 top-[17px] h-3.5 w-3.5 text-slate-400" }),
|
|
215
|
+
/* @__PURE__ */ o(
|
|
216
|
+
"input",
|
|
217
|
+
{
|
|
218
|
+
value: r,
|
|
219
|
+
onChange: (e) => i(e.target.value),
|
|
220
|
+
placeholder: "Search workspace emoji",
|
|
221
|
+
className: "h-8 w-full rounded-md border border-slate-200 bg-white pl-7 pr-2 text-[12px] outline-none placeholder:text-slate-500 focus:border-nvr-cyan dark:border-border dark:bg-card",
|
|
222
|
+
"aria-label": "Search workspace emoji"
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] }),
|
|
226
|
+
/* @__PURE__ */ o("div", { className: "max-h-[200px] overflow-y-auto p-2", "data-chat-emoji-grid": !0, children: a ? /* @__PURE__ */ o("div", { className: "grid grid-cols-7 gap-1", children: Array.from({ length: 14 }, (e, d) => /* @__PURE__ */ o(V, { className: "h-8 w-8 rounded-md" }, d)) }) : s ? /* @__PURE__ */ o("p", { className: "px-1 py-3 text-center text-[12px] text-slate-500 dark:text-slate-400", children: "Workspace emoji could not be loaded." }) : S.length === 0 ? /* @__PURE__ */ o("p", { className: "px-1 py-3 text-center text-[12px] text-slate-500 dark:text-slate-400", children: t.length === 0 ? n ? "No workspace emoji yet. Add the first one below." : "No workspace emoji yet. Ask an admin to add some." : "Nothing matches that." }) : /* @__PURE__ */ o("div", { className: "grid grid-cols-7 gap-1", children: S.map((e) => /* @__PURE__ */ m("div", { className: "group/em relative", children: [
|
|
227
|
+
/* @__PURE__ */ o(
|
|
228
|
+
"button",
|
|
229
|
+
{
|
|
230
|
+
type: "button",
|
|
231
|
+
onClick: () => h(`:${e.shortcode}:`),
|
|
232
|
+
className: "flex h-8 w-8 items-center justify-center rounded-md hover:bg-slate-100 dark:hover:bg-muted",
|
|
233
|
+
"aria-label": `:${e.shortcode}:`,
|
|
234
|
+
"data-tip": `:${e.shortcode}:`,
|
|
235
|
+
children: /* @__PURE__ */ o(ie, { value: `:${e.shortcode}:`, size: 22 })
|
|
236
|
+
}
|
|
237
|
+
),
|
|
238
|
+
n && /* @__PURE__ */ o(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
type: "button",
|
|
242
|
+
onClick: () => {
|
|
243
|
+
if (f !== e.id) {
|
|
244
|
+
y(e.id);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
y(null), u.request(H(`/chat/emoji/${e.id}`)).then(B).catch(() => x.error("Could not remove that emoji"));
|
|
248
|
+
},
|
|
249
|
+
onBlur: () => y((d) => d === e.id ? null : d),
|
|
250
|
+
className: N(
|
|
251
|
+
"absolute -right-0.5 -top-0.5 z-[1] flex h-4 items-center justify-center rounded-full ring-1 transition-opacity focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan",
|
|
252
|
+
f === e.id ? "bg-red-600 px-1.5 text-[10px] font-medium text-white opacity-100 ring-red-600" : "w-4 bg-white text-slate-500 opacity-0 ring-slate-200 hover:text-red-600 group-hover/em:opacity-100 dark:bg-card dark:text-slate-400 dark:ring-border"
|
|
253
|
+
),
|
|
254
|
+
"aria-label": f === e.id ? `Confirm: remove :${e.shortcode}: (it shows as text again)` : `Remove :${e.shortcode}:`,
|
|
255
|
+
"data-tip": f === e.id ? "Click again — it shows as text again" : void 0,
|
|
256
|
+
children: f === e.id ? "Remove?" : /* @__PURE__ */ o(W, { className: "h-2.5 w-2.5" })
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
] }, e.id)) }) }),
|
|
260
|
+
n && /* @__PURE__ */ m("div", { className: "border-t border-slate-200 p-2 dark:border-border", children: [
|
|
261
|
+
v ? /* @__PURE__ */ m("div", { className: "flex items-center gap-1.5", children: [
|
|
262
|
+
/* @__PURE__ */ o(
|
|
263
|
+
"input",
|
|
264
|
+
{
|
|
265
|
+
value: g,
|
|
266
|
+
onChange: (e) => E(e.target.value.toLowerCase().replace(/[^a-z0-9_+-]/g, "")),
|
|
267
|
+
placeholder: "party_parrot",
|
|
268
|
+
maxLength: 40,
|
|
269
|
+
className: "h-7 min-w-0 flex-1 rounded-md border border-slate-200 bg-white px-2 text-[12px] outline-none placeholder:text-slate-500 focus:border-nvr-cyan dark:border-border dark:bg-card",
|
|
270
|
+
"aria-label": "Emoji shortcode"
|
|
271
|
+
}
|
|
272
|
+
),
|
|
273
|
+
/* @__PURE__ */ o(
|
|
274
|
+
"input",
|
|
275
|
+
{
|
|
276
|
+
ref: b,
|
|
277
|
+
type: "file",
|
|
278
|
+
accept: "image/png,image/gif,image/jpeg,image/webp",
|
|
279
|
+
className: "hidden",
|
|
280
|
+
onChange: (e) => {
|
|
281
|
+
var d;
|
|
282
|
+
return void M((d = e.target.files) == null ? void 0 : d[0]);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
/* @__PURE__ */ o(
|
|
287
|
+
"button",
|
|
288
|
+
{
|
|
289
|
+
type: "button",
|
|
290
|
+
disabled: g.length < 2 || $,
|
|
291
|
+
onClick: () => {
|
|
292
|
+
var e;
|
|
293
|
+
return (e = b.current) == null ? void 0 : e.click();
|
|
294
|
+
},
|
|
295
|
+
className: "h-7 rounded-md bg-nvr-cyan px-2 text-[12px] font-medium text-white disabled:opacity-40",
|
|
296
|
+
children: $ ? "Adding…" : "Choose image"
|
|
297
|
+
}
|
|
298
|
+
)
|
|
299
|
+
] }) : /* @__PURE__ */ m(
|
|
300
|
+
"button",
|
|
301
|
+
{
|
|
302
|
+
type: "button",
|
|
303
|
+
onClick: () => C(!0),
|
|
304
|
+
className: "inline-flex items-center gap-1 text-[12px] font-medium text-slate-600 hover:text-slate-900 dark:text-slate-300 dark:hover:text-white",
|
|
305
|
+
"data-chat-emoji-add": !0,
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ o(F, { className: "h-3.5 w-3.5" }),
|
|
308
|
+
" Add emoji"
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
/* @__PURE__ */ m("p", { className: "mt-1 text-[11px] text-slate-500 dark:text-slate-400", children: [
|
|
313
|
+
"PNG, GIF, JPEG or WebP, up to ",
|
|
314
|
+
k / 1024,
|
|
315
|
+
" KB."
|
|
316
|
+
] })
|
|
317
|
+
] })
|
|
318
|
+
] });
|
|
319
|
+
}
|
|
320
|
+
function we({
|
|
321
|
+
onPick: t,
|
|
322
|
+
className: a,
|
|
323
|
+
label: s = "Emoji",
|
|
324
|
+
onOpenChange: r
|
|
325
|
+
}) {
|
|
326
|
+
return /* @__PURE__ */ o(ne, { onPick: t, onOpenChange: r, children: /* @__PURE__ */ o(
|
|
327
|
+
"button",
|
|
328
|
+
{
|
|
329
|
+
type: "button",
|
|
330
|
+
className: N(
|
|
331
|
+
"rounded-full p-0.5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",
|
|
332
|
+
a
|
|
333
|
+
),
|
|
334
|
+
"aria-label": s,
|
|
335
|
+
"data-tip": s,
|
|
336
|
+
"data-chat-emoji-button": !0,
|
|
337
|
+
children: /* @__PURE__ */ o(q, { className: "h-3 w-3" })
|
|
338
|
+
}
|
|
339
|
+
) });
|
|
340
|
+
}
|
|
341
|
+
export {
|
|
342
|
+
we as EmojiButton,
|
|
343
|
+
ie as EmojiGlyph,
|
|
344
|
+
ne as EmojiPicker,
|
|
345
|
+
ae as useCustomEmoji,
|
|
346
|
+
oe as useEmojiUrls,
|
|
347
|
+
ke as withCustomEmoji
|
|
348
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const m = { start: "08:00", end: "18:00" };
|
|
2
|
+
function o(t, n) {
|
|
3
|
+
try {
|
|
4
|
+
const e = new Intl.DateTimeFormat("en-US", {
|
|
5
|
+
timeZone: t,
|
|
6
|
+
weekday: "short",
|
|
7
|
+
hour: "2-digit",
|
|
8
|
+
minute: "2-digit",
|
|
9
|
+
hourCycle: "h23"
|
|
10
|
+
}).formatToParts(n), r = (h) => {
|
|
11
|
+
var i;
|
|
12
|
+
return ((i = e.find((a) => a.type === h)) == null ? void 0 : i.value) ?? "";
|
|
13
|
+
}, u = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"].indexOf(r("weekday")), s = r("hour") === "24" ? "00" : r("hour"), l = new Intl.DateTimeFormat("en-US", {
|
|
14
|
+
timeZone: t,
|
|
15
|
+
hour: "numeric",
|
|
16
|
+
minute: "2-digit"
|
|
17
|
+
}).format(n);
|
|
18
|
+
return u < 0 ? null : { day: u, hhmm: `${s}:${r("minute")}`, label: l };
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function c(t, n) {
|
|
24
|
+
if (!t.timezone) return null;
|
|
25
|
+
const e = o(t.timezone, n);
|
|
26
|
+
if (!e) return null;
|
|
27
|
+
if (e.day === 0 || e.day === 6) return !0;
|
|
28
|
+
const r = t.working_hours ?? m;
|
|
29
|
+
return e.hhmm < r.start || e.hhmm >= r.end;
|
|
30
|
+
}
|
|
31
|
+
function d(t, n, e) {
|
|
32
|
+
if (!(t != null && t.timezone) || c(t, e) !== !0) return null;
|
|
33
|
+
const r = o(t.timezone, e);
|
|
34
|
+
if (!r) return null;
|
|
35
|
+
const u = n.split(/\s+/)[0] || n;
|
|
36
|
+
return `It is ${r.label} for ${u}, outside their working hours. They will see this when they are back.`;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
c as isOutsideWorkingHours,
|
|
40
|
+
d as offHoursNote
|
|
41
|
+
};
|