@nivaro/react 0.3.40 → 0.3.42
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/components/LayoutForm.js +100 -98
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +645 -16
- package/dist/index.js +814 -775
- package/dist/shared/components/ActivityEntry.js +154 -0
- package/dist/shared/components/AudienceConfirmPanel.js +98 -0
- package/dist/shared/components/BackgroundRunOffer.js +43 -31
- package/dist/shared/components/BroadcastView.js +225 -204
- package/dist/shared/components/CollectionBrowserView.js +3924 -3584
- package/dist/shared/components/ConfigHistory.js +153 -0
- package/dist/shared/components/ConfigReadBack.js +65 -0
- package/dist/shared/components/DataTable.js +379 -346
- package/dist/shared/components/ForceReloadBanner.js +47 -40
- package/dist/shared/components/IdleReloadWatcher.js +69 -0
- package/dist/shared/components/ItemEditForm.js +4041 -3853
- package/dist/shared/components/MyWorkView.js +278 -213
- package/dist/shared/components/NotificationBell.js +130 -121
- package/dist/shared/components/PickerExcludedRows.js +3 -3
- package/dist/shared/components/ProfileView.js +776 -1003
- package/dist/shared/components/RecentRecordsRail.js +34 -16
- package/dist/shared/components/RecordReadView.js +500 -477
- package/dist/shared/components/Skeletons.js +199 -0
- package/dist/shared/components/SlowNotice.js +63 -0
- package/dist/shared/components/Term.js +23 -0
- package/dist/shared/components/WidgetSlot.js +350 -353
- package/dist/shared/components/access/PermissionSummary.js +106 -0
- package/dist/shared/components/bulk/BulkActionButtons.js +76 -73
- package/dist/shared/components/chat/ChatPanel.js +902 -886
- package/dist/shared/components/chat/MemberPaging.js +70 -0
- package/dist/shared/components/chat/RoomParts.js +147 -117
- package/dist/shared/components/chat/ScreenClip.js +73 -69
- package/dist/shared/components/chat/chat-core.js +449 -396
- package/dist/shared/components/chat/huddle/huddle-store.js +48 -43
- package/dist/shared/components/help-videos/api.js +2 -5
- package/dist/shared/components/help-videos/viewer/HelpVideoMatchChip.js +79 -0
- package/dist/shared/components/help-videos/viewer/matchChip.js +50 -0
- package/dist/shared/components/imports/CollectionImportPanel.js +139 -133
- package/dist/shared/components/imports/RunDetailSheet.js +222 -227
- package/dist/shared/components/integrations/console/ErrorExplanation.js +121 -0
- package/dist/shared/components/integrations/console/PartnerDetail.js +175 -174
- package/dist/shared/components/integrations/console/SubmissionRow.js +36 -34
- package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +50 -48
- package/dist/shared/components/item-edit/FieldComments.js +212 -0
- package/dist/shared/components/item-edit/FieldRow.js +340 -336
- package/dist/shared/components/item-edit/RecordGrantTools.js +28 -28
- package/dist/shared/components/item-edit/RecordHeaderActions.js +23 -22
- package/dist/shared/components/item-edit/RelationCombobox.js +231 -222
- package/dist/shared/components/item-edit/RuleHiddenNotes.js +55 -0
- package/dist/shared/components/item-edit/field-comments-context.js +6 -0
- package/dist/shared/components/item-edit/field-sources.js +33 -0
- package/dist/shared/components/item-edit/rule-hidden.js +30 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +113 -96
- package/dist/shared/components/layout-editor/editors/cascade-filters.js +170 -145
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +22 -18
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +177 -159
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +35 -34
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +124 -111
- package/dist/shared/components/layout-editor/inspector/kit.js +292 -277
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/settings/settings-registry.js +1 -1
- package/dist/shared/components/list/CopyListLinkButton.js +41 -0
- package/dist/shared/components/list/InlineEdit.js +363 -0
- package/dist/shared/components/notifications/NotificationCenterView.js +213 -181
- package/dist/shared/components/notifications/NotificationDetailBits.js +205 -82
- package/dist/shared/components/notifications/NotificationRulesEditor.js +515 -0
- package/dist/shared/components/notifications/TestMyRules.js +137 -0
- package/dist/shared/components/notifications/changes-lines.js +24 -0
- package/dist/shared/components/notifications/why-lines.js +64 -0
- package/dist/shared/components/panels/CommentPanel.js +316 -281
- package/dist/shared/components/panels/LegalHoldBanner.js +38 -0
- package/dist/shared/components/panels/PipelinePanel.js +201 -196
- package/dist/shared/components/panels/RevisionsPanel.js +496 -479
- package/dist/shared/components/pipeline/PipelineEditorView.js +1587 -1560
- package/dist/shared/components/pipeline/PipelineStateOwners.js +116 -103
- package/dist/shared/components/profile/PersonDidPanel.js +188 -0
- package/dist/shared/components/profile/PersonProfile.js +57 -52
- package/dist/shared/components/queue/QueueWorklist.js +1526 -1365
- package/dist/shared/hooks/useSlowReason.js +39 -0
- package/dist/shared/lib/activity-sentence.js +670 -0
- package/dist/shared/lib/config-sentences.js +418 -0
- package/dist/shared/lib/core-glossary.js +229 -0
- package/dist/shared/lib/error-hints.js +159 -0
- package/dist/shared/lib/error-message.js +105 -0
- package/dist/shared/lib/error-toast.js +22 -0
- package/dist/shared/lib/field-comments.js +25 -0
- package/dist/shared/lib/filter-sentence.js +261 -0
- package/dist/shared/lib/glossary.js +55 -48
- package/dist/shared/lib/idle-reload.js +138 -0
- package/dist/shared/lib/layout-resolve.js +42 -29
- package/dist/shared/lib/list-inline-edit.js +190 -0
- package/dist/shared/lib/list-link.js +147 -0
- package/dist/shared/lib/prefetch.js +259 -106
- package/dist/shared/lib/record-ref.js +72 -0
- package/dist/shared/lib/reload-holds.js +25 -0
- package/dist/shared/lib/safe-error.js +52 -24
- package/dist/shared/lib/skeleton-shapes.js +72 -0
- package/dist/shared/lib/slow-reason.js +63 -0
- package/package.json +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsxs as m, jsx as e, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as b } from "@tanstack/react-query";
|
|
3
|
+
import { ChevronDown as S, ChevronRight as A, Eye as C, KeyRound as D, Bot as L, Upload as j, Workflow as _, Clock as I, Cog as R } from "lucide-react";
|
|
4
|
+
import { useState as T, useMemo as u } from "react";
|
|
5
|
+
import { useOptionalNivaroClient as q } from "../context.js";
|
|
6
|
+
import { renderActivityGroupSentence as B, renderActivitySentence as U, actorName as W, groupActivity as E, activityLabelRefs as K, actorOf as Z, activityWhy as G } from "../lib/activity-sentence.js";
|
|
7
|
+
import { post as J } from "../lib/commands.js";
|
|
8
|
+
import { cn as f } from "../lib/utils.js";
|
|
9
|
+
import { AgentBadge as M } from "./AgentBadge.js";
|
|
10
|
+
import { UserAvatar as Q } from "./UserAvatar.js";
|
|
11
|
+
function z(a) {
|
|
12
|
+
if (!a) return null;
|
|
13
|
+
const t = new Date(a);
|
|
14
|
+
return Number.isNaN(t.getTime()) ? null : {
|
|
15
|
+
short: (/* @__PURE__ */ new Date()).toDateString() === t.toDateString() ? t.toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : t.toLocaleString([], {
|
|
16
|
+
month: "short",
|
|
17
|
+
day: "numeric",
|
|
18
|
+
hour: "numeric",
|
|
19
|
+
minute: "2-digit"
|
|
20
|
+
}),
|
|
21
|
+
full: t.toLocaleString()
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const F = "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-300";
|
|
25
|
+
function H({ entry: a, name: t }) {
|
|
26
|
+
const i = Z(a).kind, n = i === "view_as" ? /* @__PURE__ */ e(C, { className: "h-3.5 w-3.5" }) : i === "api_key" ? /* @__PURE__ */ e(D, { className: "h-3.5 w-3.5" }) : i === "mcp" ? /* @__PURE__ */ e(L, { className: "h-3.5 w-3.5" }) : i === "import" ? /* @__PURE__ */ e(j, { className: "h-3.5 w-3.5" }) : i === "flow" ? /* @__PURE__ */ e(_, { className: "h-3.5 w-3.5" }) : i === "cron" ? /* @__PURE__ */ e(I, { className: "h-3.5 w-3.5" }) : i === "system" ? /* @__PURE__ */ e(R, { className: "h-3.5 w-3.5" }) : null;
|
|
27
|
+
if (n)
|
|
28
|
+
return /* @__PURE__ */ e("span", { className: F, "data-activity-actor": i, "aria-hidden": !0, children: n });
|
|
29
|
+
const l = t.split(" ").map((c) => c[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
|
|
30
|
+
return /* @__PURE__ */ e(
|
|
31
|
+
Q,
|
|
32
|
+
{
|
|
33
|
+
userId: a.user ?? a.user_id ?? null,
|
|
34
|
+
className: "h-6 w-6",
|
|
35
|
+
fallback: /* @__PURE__ */ e("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-nvr-cyan/10 text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: l })
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function O({ entry: a }) {
|
|
40
|
+
const t = G(a);
|
|
41
|
+
return !t.reason && !t.note && !t.approval ? null : /* @__PURE__ */ m("span", { className: "mt-0.5 block space-y-0.5 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
42
|
+
t.note && /* @__PURE__ */ m("span", { className: "block truncate italic", "data-activity-why": "note", "data-tip": t.note, children: [
|
|
43
|
+
"“",
|
|
44
|
+
t.note,
|
|
45
|
+
"”"
|
|
46
|
+
] }),
|
|
47
|
+
t.reason && /* @__PURE__ */ m("span", { className: "block truncate", "data-activity-why": "reason", "data-tip": t.reason, children: [
|
|
48
|
+
"Reason: ",
|
|
49
|
+
t.reason
|
|
50
|
+
] }),
|
|
51
|
+
t.approval && /* @__PURE__ */ m("span", { className: "block truncate", "data-activity-why": "approval", children: [
|
|
52
|
+
"Approval: ",
|
|
53
|
+
t.approval
|
|
54
|
+
] })
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
function y({
|
|
58
|
+
entry: a,
|
|
59
|
+
labels: t,
|
|
60
|
+
group: i,
|
|
61
|
+
onOpen: n,
|
|
62
|
+
actions: l,
|
|
63
|
+
showTime: c = !0,
|
|
64
|
+
className: o
|
|
65
|
+
}) {
|
|
66
|
+
const [r, v] = T(!1), s = i && i.length > 1 ? i : null, h = s ? B(s, t) : U(a, t), x = W(a, t), p = z(a.timestamp), N = !!n || !!s, k = () => {
|
|
67
|
+
s ? v((d) => !d) : n == null || n(a);
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ m("div", { className: f("min-w-0", o), "data-activity-entry": a.id ?? "", children: [
|
|
70
|
+
/* @__PURE__ */ m("div", { className: "flex w-full items-start gap-2.5 rounded-md px-2 py-2", children: [
|
|
71
|
+
/* @__PURE__ */ e(H, { entry: a, name: x }),
|
|
72
|
+
/* @__PURE__ */ m("span", { className: "min-w-0 flex-1 text-[12.5px] leading-5 text-slate-700 dark:text-slate-200", children: [
|
|
73
|
+
N ? /* @__PURE__ */ m(
|
|
74
|
+
"button",
|
|
75
|
+
{
|
|
76
|
+
type: "button",
|
|
77
|
+
onClick: k,
|
|
78
|
+
"aria-expanded": s ? r : void 0,
|
|
79
|
+
className: "inline-flex max-w-full items-start gap-1 text-left hover:underline",
|
|
80
|
+
children: [
|
|
81
|
+
s && (r ? /* @__PURE__ */ e(S, { className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-slate-400" }) : /* @__PURE__ */ e(A, { className: "mt-[3px] h-3.5 w-3.5 shrink-0 text-slate-400" })),
|
|
82
|
+
/* @__PURE__ */ e("span", { "data-activity-sentence": !0, children: h })
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
) : /* @__PURE__ */ e("span", { "data-activity-sentence": !0, children: h }),
|
|
86
|
+
!s && /* @__PURE__ */ e(O, { entry: a })
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ e(M, { label: a.via_agent }),
|
|
89
|
+
c && p && /* @__PURE__ */ e(
|
|
90
|
+
"span",
|
|
91
|
+
{
|
|
92
|
+
className: "shrink-0 pt-px text-[11px] tabular-nums text-slate-400",
|
|
93
|
+
"data-tip": p.full,
|
|
94
|
+
children: p.short
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
l && /* @__PURE__ */ e("span", { className: "flex shrink-0 items-center gap-1", children: l })
|
|
98
|
+
] }),
|
|
99
|
+
s && r && /* @__PURE__ */ e("div", { className: "ml-[18px] border-l border-slate-200 pl-3 dark:border-border", children: s.map((d, g) => /* @__PURE__ */ e(
|
|
100
|
+
y,
|
|
101
|
+
{
|
|
102
|
+
entry: d,
|
|
103
|
+
labels: t,
|
|
104
|
+
onOpen: n,
|
|
105
|
+
showTime: c
|
|
106
|
+
},
|
|
107
|
+
String(d.id ?? g)
|
|
108
|
+
)) })
|
|
109
|
+
] });
|
|
110
|
+
}
|
|
111
|
+
function rt({
|
|
112
|
+
entries: a,
|
|
113
|
+
labels: t,
|
|
114
|
+
onOpen: i,
|
|
115
|
+
actionsFor: n,
|
|
116
|
+
empty: l,
|
|
117
|
+
className: c
|
|
118
|
+
}) {
|
|
119
|
+
const o = u(() => E(a), [a]);
|
|
120
|
+
return o.length === 0 ? /* @__PURE__ */ e(w, { children: l ?? null }) : /* @__PURE__ */ e("div", { className: f("divide-y divide-slate-100 dark:divide-border", c), children: o.map((r) => /* @__PURE__ */ e(
|
|
121
|
+
y,
|
|
122
|
+
{
|
|
123
|
+
entry: r.entries[0],
|
|
124
|
+
group: r.entries.length > 1 ? r.entries : void 0,
|
|
125
|
+
labels: t,
|
|
126
|
+
onOpen: i,
|
|
127
|
+
actions: n == null ? void 0 : n(r)
|
|
128
|
+
},
|
|
129
|
+
r.key
|
|
130
|
+
)) });
|
|
131
|
+
}
|
|
132
|
+
function st(a, t = {}) {
|
|
133
|
+
const i = q(), n = u(() => K(a), [a]), l = u(() => JSON.stringify(n), [n]), c = n.refs.length === 0 && n.users.length === 0 && n.collections.length === 0, { data: o } = b({
|
|
134
|
+
queryKey: ["activity-labels", l],
|
|
135
|
+
queryFn: async () => (await i.request(J("/activity/labels", n))).data,
|
|
136
|
+
enabled: !!i && !c && t.enabled !== !1,
|
|
137
|
+
staleTime: 6e4,
|
|
138
|
+
retry: !1
|
|
139
|
+
});
|
|
140
|
+
return u(() => {
|
|
141
|
+
let r = null;
|
|
142
|
+
try {
|
|
143
|
+
r = Intl.DateTimeFormat().resolvedOptions().timeZone ?? null;
|
|
144
|
+
} catch {
|
|
145
|
+
r = null;
|
|
146
|
+
}
|
|
147
|
+
return o ? { ...o, timeZone: r } : void 0;
|
|
148
|
+
}, [o]);
|
|
149
|
+
}
|
|
150
|
+
export {
|
|
151
|
+
y as ActivityEntry,
|
|
152
|
+
rt as ActivityFeed,
|
|
153
|
+
st as useActivityLabels
|
|
154
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsxs as s, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { cn as i } from "../lib/utils.js";
|
|
3
|
+
function x(e) {
|
|
4
|
+
var l;
|
|
5
|
+
const a = e, r = a != null && a.response && "data" in a.response ? a.response.data : a == null ? void 0 : a.response;
|
|
6
|
+
return (((l = a == null ? void 0 : a.response) == null ? void 0 : l.status) ?? (a == null ? void 0 : a.status)) !== 409 || (r == null ? void 0 : r.code) !== "AUDIENCE_CONFIRM_REQUIRED" || !r.audience ? null : r.audience;
|
|
7
|
+
}
|
|
8
|
+
function c(e) {
|
|
9
|
+
if (e.includes_everyone) return `Saving this tells everyone (${e.count} people).`;
|
|
10
|
+
const a = `${e.count} ${e.count === 1 ? "person" : "people"}`;
|
|
11
|
+
if (e.includes_roles.length > 0) {
|
|
12
|
+
const r = e.includes_roles.map((n) => n.name).join(", ");
|
|
13
|
+
return `Saving this tells ${a}, including the whole ${r} role${e.includes_roles.length > 1 ? "s" : ""}.`;
|
|
14
|
+
}
|
|
15
|
+
return `Saving this tells ${a} — more than ${e.threshold}.`;
|
|
16
|
+
}
|
|
17
|
+
function h({
|
|
18
|
+
preview: e,
|
|
19
|
+
onConfirm: a,
|
|
20
|
+
onCancel: r,
|
|
21
|
+
busy: n = !1,
|
|
22
|
+
confirmLabel: l = "Confirm and save",
|
|
23
|
+
className: m
|
|
24
|
+
}) {
|
|
25
|
+
const o = Math.max(0, e.count - e.external_addresses - e.sample.length);
|
|
26
|
+
return /* @__PURE__ */ s(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
role: "alert",
|
|
30
|
+
"data-audience-confirm": !0,
|
|
31
|
+
className: i(
|
|
32
|
+
"rounded-lg border border-amber-200 bg-amber-50 px-3.5 py-3 text-[12.5px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200",
|
|
33
|
+
m
|
|
34
|
+
),
|
|
35
|
+
children: [
|
|
36
|
+
/* @__PURE__ */ d("p", { className: "font-semibold", children: c(e) }),
|
|
37
|
+
e.includes_roles.length > 0 && /* @__PURE__ */ d("div", { className: "mt-2 flex flex-wrap gap-1.5", children: e.includes_roles.map((t) => /* @__PURE__ */ s(
|
|
38
|
+
"span",
|
|
39
|
+
{
|
|
40
|
+
className: "rounded-full border border-amber-300 bg-white px-2 py-0.5 text-[11.5px] font-medium text-amber-800 dark:border-amber-400/40 dark:bg-amber-400/10 dark:text-amber-200",
|
|
41
|
+
children: [
|
|
42
|
+
"Whole role: ",
|
|
43
|
+
t.name,
|
|
44
|
+
" (",
|
|
45
|
+
t.members,
|
|
46
|
+
")"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
t.id
|
|
50
|
+
)) }),
|
|
51
|
+
e.sample.length > 0 && /* @__PURE__ */ s("p", { className: "mt-2 leading-relaxed text-amber-800 dark:text-amber-200/90", children: [
|
|
52
|
+
e.sample.map((t) => t.name).join(", "),
|
|
53
|
+
o > 0 && /* @__PURE__ */ s("span", { className: "font-medium", children: [
|
|
54
|
+
" and ",
|
|
55
|
+
o,
|
|
56
|
+
" more"
|
|
57
|
+
] }),
|
|
58
|
+
e.external_addresses > 0 && /* @__PURE__ */ s("span", { children: [
|
|
59
|
+
" ",
|
|
60
|
+
"(+ ",
|
|
61
|
+
e.external_addresses,
|
|
62
|
+
" outside address",
|
|
63
|
+
e.external_addresses === 1 ? "" : "es",
|
|
64
|
+
")"
|
|
65
|
+
] })
|
|
66
|
+
] }),
|
|
67
|
+
e.notes.length > 0 && /* @__PURE__ */ d("ul", { className: "mt-2 list-disc space-y-0.5 pl-4 text-[11.5px] text-amber-700 dark:text-amber-300/80", children: e.notes.map((t) => /* @__PURE__ */ d("li", { children: t }, t)) }),
|
|
68
|
+
/* @__PURE__ */ s("div", { className: "mt-3 flex flex-wrap items-center gap-2", children: [
|
|
69
|
+
/* @__PURE__ */ d(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
disabled: n,
|
|
74
|
+
onClick: a,
|
|
75
|
+
className: "h-8 rounded-md bg-nvr-cyan px-3 text-[12.5px] font-medium text-white disabled:opacity-50",
|
|
76
|
+
children: n ? "Saving…" : l
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ d(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
type: "button",
|
|
83
|
+
disabled: n,
|
|
84
|
+
onClick: r,
|
|
85
|
+
className: "h-8 rounded-md border border-amber-300 bg-white px-3 text-[12.5px] font-medium text-amber-800 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-400/40 dark:bg-transparent dark:text-amber-200 dark:hover:bg-amber-400/15",
|
|
86
|
+
children: "Cancel"
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
h as AudienceConfirmPanel,
|
|
96
|
+
x as audienceConfirmFromError,
|
|
97
|
+
c as audienceSummary
|
|
98
|
+
};
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AlertCircle as
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { AlertCircle as h, Timer as b, Loader2 as v } from "lucide-react";
|
|
3
|
+
import { useState as w, useEffect as k } from "react";
|
|
4
|
+
import { useSlowReason as y } from "../hooks/useSlowReason.js";
|
|
5
|
+
import { useBackgroundRun as N, clock as d, runProgress as S } from "../lib/background-runs.js";
|
|
6
|
+
import { cn as c } from "../lib/utils.js";
|
|
7
|
+
import { SlowNoticeView as R } from "./SlowNotice.js";
|
|
8
|
+
function X({
|
|
9
|
+
className: r,
|
|
10
|
+
...n
|
|
9
11
|
}) {
|
|
10
|
-
var
|
|
11
|
-
const e =
|
|
12
|
+
var f, x;
|
|
13
|
+
const e = N(n), s = y({
|
|
14
|
+
pending: n.pending && e.phase !== "running" && e.phase !== "done",
|
|
15
|
+
request: n.request,
|
|
16
|
+
label: n.label
|
|
17
|
+
}), p = (f = e.run) != null && f.started_at ? Date.parse(e.run.started_at) : null, [g, m] = w(() => Date.now());
|
|
12
18
|
if (k(() => {
|
|
13
19
|
if (e.phase !== "running") return;
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
return () => clearInterval(
|
|
17
|
-
}, [e.phase]), e.phase === "
|
|
20
|
+
m(Date.now());
|
|
21
|
+
const l = setInterval(() => m(Date.now()), 1e3);
|
|
22
|
+
return () => clearInterval(l);
|
|
23
|
+
}, [e.phase]), e.phase === "done") return null;
|
|
24
|
+
if (e.phase === "idle")
|
|
25
|
+
return s.slow ? /* @__PURE__ */ t(R, { reason: s, className: r }) : null;
|
|
18
26
|
if (e.phase === "error")
|
|
19
27
|
return /* @__PURE__ */ a(
|
|
20
28
|
"div",
|
|
21
29
|
{
|
|
22
30
|
"data-background-run": "error",
|
|
23
31
|
role: "alert",
|
|
24
|
-
className:
|
|
32
|
+
className: c("flex flex-wrap items-center gap-x-2 gap-y-1 text-[12px]", r),
|
|
25
33
|
children: [
|
|
26
|
-
/* @__PURE__ */ t(
|
|
34
|
+
/* @__PURE__ */ t(h, { className: "h-3.5 w-3.5 shrink-0 text-rose-500" }),
|
|
27
35
|
/* @__PURE__ */ t("span", { className: "min-w-0 text-rose-700 dark:text-rose-300", children: e.error ?? "The background run failed." }),
|
|
28
36
|
/* @__PURE__ */ t(
|
|
29
37
|
"button",
|
|
@@ -38,13 +46,13 @@ function _({
|
|
|
38
46
|
}
|
|
39
47
|
);
|
|
40
48
|
if (e.phase === "running") {
|
|
41
|
-
const
|
|
49
|
+
const l = p ? Math.max(0, g - p) : 0, u = ((x = e.run) == null ? void 0 : x.expected_ms) ?? null, i = S(l, u);
|
|
42
50
|
return /* @__PURE__ */ a(
|
|
43
51
|
"div",
|
|
44
52
|
{
|
|
45
53
|
"data-background-run": "running",
|
|
46
54
|
"aria-live": "polite",
|
|
47
|
-
className:
|
|
55
|
+
className: c("flex w-full min-w-0 flex-col gap-1.5", r),
|
|
48
56
|
children: [
|
|
49
57
|
/* @__PURE__ */ t(
|
|
50
58
|
"div",
|
|
@@ -53,13 +61,13 @@ function _({
|
|
|
53
61
|
"aria-label": "Background run",
|
|
54
62
|
"aria-valuemin": 0,
|
|
55
63
|
"aria-valuemax": 100,
|
|
56
|
-
"aria-valuenow":
|
|
64
|
+
"aria-valuenow": i == null ? void 0 : Math.round(i * 100),
|
|
57
65
|
className: "relative h-1 w-full overflow-hidden rounded-full bg-slate-100 dark:bg-slate-800",
|
|
58
|
-
children:
|
|
66
|
+
children: i == null ? /* @__PURE__ */ t("div", { className: "nvr-bgrun-sweep absolute inset-y-0 left-0 w-1/3 rounded-full bg-nvr-cyan/70" }) : /* @__PURE__ */ t(
|
|
59
67
|
"div",
|
|
60
68
|
{
|
|
61
69
|
className: "h-full w-full origin-left rounded-full bg-nvr-cyan transition-transform duration-1000 ease-linear motion-reduce:transition-none",
|
|
62
|
-
style: { transform: `scaleX(${
|
|
70
|
+
style: { transform: `scaleX(${i})` }
|
|
63
71
|
}
|
|
64
72
|
)
|
|
65
73
|
}
|
|
@@ -68,26 +76,30 @@ function _({
|
|
|
68
76
|
"Running in the background",
|
|
69
77
|
/* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: " · " }),
|
|
70
78
|
/* @__PURE__ */ a("span", { className: "tabular-nums", children: [
|
|
71
|
-
|
|
72
|
-
|
|
79
|
+
d(l),
|
|
80
|
+
u ? ` of about ${d(u)}` : ""
|
|
73
81
|
] })
|
|
74
82
|
] }),
|
|
75
83
|
/* @__PURE__ */ t("p", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: "You can leave this page. Your jobs tray says when it is ready." }),
|
|
76
|
-
/* @__PURE__ */ t("style", { children:
|
|
84
|
+
/* @__PURE__ */ t("style", { children: T })
|
|
77
85
|
]
|
|
78
86
|
}
|
|
79
87
|
);
|
|
80
88
|
}
|
|
81
|
-
const
|
|
89
|
+
const o = e.typicalMs;
|
|
82
90
|
return /* @__PURE__ */ a(
|
|
83
91
|
"div",
|
|
84
92
|
{
|
|
85
93
|
"data-background-run": "offer",
|
|
86
|
-
className:
|
|
94
|
+
className: c("flex flex-wrap items-center gap-x-3 gap-y-1.5", r),
|
|
87
95
|
children: [
|
|
88
96
|
/* @__PURE__ */ a("span", { className: "inline-flex min-w-0 items-center gap-1.5 text-[12px] text-slate-600 dark:text-slate-300", children: [
|
|
89
|
-
/* @__PURE__ */ t(
|
|
90
|
-
|
|
97
|
+
/* @__PURE__ */ t(b, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
98
|
+
o && o >= 1e3 ? `This usually takes about ${d(o)}.` : "This is taking a while.",
|
|
99
|
+
s.text && /* @__PURE__ */ a("span", { "data-slow-reason": !0, className: "text-slate-500 dark:text-slate-400", children: [
|
|
100
|
+
s.text,
|
|
101
|
+
"."
|
|
102
|
+
] })
|
|
91
103
|
] }),
|
|
92
104
|
/* @__PURE__ */ a(
|
|
93
105
|
"button",
|
|
@@ -98,7 +110,7 @@ function _({
|
|
|
98
110
|
"data-background-run-start": !0,
|
|
99
111
|
className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 bg-white px-2.5 text-[12px] font-medium text-slate-700 transition-colors duration-150 hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan disabled:pointer-events-none disabled:opacity-60 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-200 dark:hover:bg-slate-800",
|
|
100
112
|
children: [
|
|
101
|
-
e.phase === "starting" && /* @__PURE__ */ t(
|
|
113
|
+
e.phase === "starting" && /* @__PURE__ */ t(v, { className: "h-3 w-3 animate-spin" }),
|
|
102
114
|
"Run in background"
|
|
103
115
|
]
|
|
104
116
|
}
|
|
@@ -107,11 +119,11 @@ function _({
|
|
|
107
119
|
}
|
|
108
120
|
);
|
|
109
121
|
}
|
|
110
|
-
const
|
|
122
|
+
const T = `
|
|
111
123
|
@keyframes nvr-bgrun-sweep { from { transform: translateX(-100%) } to { transform: translateX(300%) } }
|
|
112
124
|
.nvr-bgrun-sweep { animation: nvr-bgrun-sweep 1.6s cubic-bezier(0.25, 1, 0.5, 1) infinite }
|
|
113
125
|
@media (prefers-reduced-motion: reduce) { .nvr-bgrun-sweep { animation: none; width: 100%; opacity: .5 } }
|
|
114
126
|
`;
|
|
115
127
|
export {
|
|
116
|
-
|
|
128
|
+
X as BackgroundRunOffer
|
|
117
129
|
};
|