@proef/common-ui 2.6.42 → 2.6.44

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,16 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useRef, useEffect, useMemo } from "react";
3
- import { OfflineBoxesIcon } from "./OfflineBoxesIcon.js";
4
3
  const DEFAULT_OFFLINE_BOXES_LABELS = {
5
- title: "Offline",
6
- saved: "Saved",
7
- waiting: "To send",
4
+ title: "Inbox and Outbox",
5
+ saved: "Inbox",
6
+ waiting: "Outbox",
8
7
  toSend: "{n} to send",
9
8
  downloading: "Downloading · {ready} of {total}",
10
9
  savedCount: "{n} saved",
11
10
  savedAt: "Last download {date} {time}",
12
11
  nothingSaved: "Nothing saved yet",
13
12
  failed: "{n} failed. What was already saved is still available.",
14
- nothingWaiting: "Nothing waiting to send.",
13
+ nothingWaiting: "What you save without a connection waits here and goes out on its own.",
15
14
  waitingHint: "They go out on their own once there is a connection.",
16
15
  search: "Search…",
17
16
  noMatches: "Nothing matches the search.",
@@ -19,8 +18,21 @@ const DEFAULT_OFFLINE_BOXES_LABELS = {
19
18
  back: "Back",
20
19
  pending: "Waiting for a connection",
21
20
  sending: "Sending…",
22
- rejected: "Refused"
21
+ rejected: "Refused",
22
+ available: "Available offline",
23
+ allSent: "All sent",
24
+ rejectedCount: "{n} refused",
25
+ openSaved: "See what is saved for {title}",
26
+ showJson: "Show JSON",
27
+ hideJson: "Hide JSON",
28
+ copy: "Copy",
29
+ copied: "Copied",
30
+ reading: "Reading…",
31
+ notOnPhone: "Not on the phone",
32
+ savedOn: "Saved {date} {time}"
23
33
  };
34
+ const INBOX_GREEN = "#19C99B";
35
+ const OUTBOX_ORANGE = "#EA6A12";
24
36
  function filled(template, values) {
25
37
  return template.replace(/\{(\w+)\}/g, (whole, name) => name in values ? String(values[name]) : whole);
26
38
  }
@@ -67,36 +79,194 @@ function legendOf(items) {
67
79
  }
68
80
  return [...seen.values()];
69
81
  }
82
+ function OfflineArrow({ up }) {
83
+ return /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: up ? "M10 16V5M5.5 9.5 10 5l4.5 4.5" : "M10 4v11M5.5 10.5 10 15l4.5-4.5", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round" }) });
84
+ }
70
85
  const STATE_TONE = {
71
- pending: "text-orange-700 dark:text-orange-300",
72
- sending: "text-proef-navy dark:text-sky-300",
73
- rejected: "text-red-700 dark:text-red-300"
86
+ pending: { dot: OUTBOX_ORANGE, pill: "bg-orange-50 text-orange-800 dark:bg-orange-950 dark:text-orange-300" },
87
+ sending: { dot: "#001b63", pill: "bg-sky-50 text-proef-navy dark:bg-sky-950 dark:text-sky-300" },
88
+ rejected: { dot: "#dc2626", pill: "bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300" }
74
89
  };
75
- const ROW = "flex items-center gap-2 border-b border-slate-100 px-2.5 py-1.5 last:border-b-0 dark:border-slate-800";
76
- function TabButton({ active, color, tone, label, value, onClick }) {
77
- return /* @__PURE__ */ jsxs(
90
+ const CARD_SHADOW = "shadow-[0_1px_2px_rgba(0,27,99,0.08)]";
91
+ function TabCard({ active, color, up, label, value, line, progress, alert, onClick }) {
92
+ return /* @__PURE__ */ jsx(
78
93
  "button",
79
94
  {
80
95
  type: "button",
81
96
  role: "tab",
82
97
  "aria-selected": active,
83
98
  onClick,
84
- className: `flex h-[34px] cursor-pointer items-center justify-center gap-1.5 rounded-lg border-0 text-xs font-bold ${active ? "bg-white text-proef-navy shadow-[0_1px_3px_rgba(16,25,94,0.15)] dark:bg-slate-700 dark:text-slate-100" : "bg-transparent text-slate-600 dark:text-slate-300"}`,
85
- children: [
86
- /* @__PURE__ */ jsx("span", { className: "h-2 w-2 rounded-[2px]", style: { background: color } }),
87
- label,
88
- /* @__PURE__ */ jsx("span", { className: `font-black tabular-nums ${tone}`, children: value })
89
- ]
99
+ style: { ["--tone"]: color, WebkitTapHighlightColor: "transparent" },
100
+ className: "group flex min-w-0 cursor-pointer touch-manipulation border-0 bg-transparent p-1.5 text-left font-[inherit] outline-none select-none",
101
+ children: /* @__PURE__ */ jsxs(
102
+ "span",
103
+ {
104
+ className: `relative flex w-full min-w-0 flex-col items-start gap-0.5 overflow-hidden rounded-2xl bg-white px-3.5 pt-3 pb-3 text-proef-navy transition-transform duration-100 group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-[var(--tone)] group-active:scale-[0.96] dark:bg-slate-900 dark:text-slate-100 ${active ? "shadow-[0_8px_24px_-8px_rgba(0,27,99,0.45)] ring-2 ring-[var(--tone)]" : "shadow-[0_2px_8px_-4px_rgba(0,27,99,0.35)] [&>*:not(:first-child)]:opacity-60"}`,
105
+ children: [
106
+ /* @__PURE__ */ jsx("span", { className: "absolute inset-x-0 top-0 h-1", style: { background: color } }),
107
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-[10px] font-black tracking-[0.18em] uppercase", style: { color }, children: [
108
+ /* @__PURE__ */ jsx(OfflineArrow, { up }),
109
+ label
110
+ ] }),
111
+ /* @__PURE__ */ jsx("span", { className: "text-[30px] leading-none font-black tracking-tight tabular-nums", children: value }),
112
+ /* @__PURE__ */ jsx("span", { className: "w-full truncate text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: line }),
113
+ progress !== void 0 && /* @__PURE__ */ jsx("span", { className: "mt-1.5 h-1 w-full overflow-hidden rounded-full bg-slate-100 dark:bg-slate-800", children: /* @__PURE__ */ jsx("span", { className: "block h-full rounded-full transition-[width] duration-500", style: { width: `${progress ?? 0}%`, background: color } }) }),
114
+ alert && /* @__PURE__ */ jsx("span", { className: "mt-1 rounded-full bg-red-50 px-1.5 py-px text-[10px] font-bold text-red-700 dark:bg-red-950 dark:text-red-300", children: alert })
115
+ ]
116
+ }
117
+ )
118
+ }
119
+ );
120
+ }
121
+ function SavedTags({ tags }) {
122
+ return /* @__PURE__ */ jsx("span", { className: "flex shrink-0 gap-1", children: tags.map((tag) => /* @__PURE__ */ jsx(
123
+ "span",
124
+ {
125
+ title: tag.label,
126
+ "aria-label": tag.label,
127
+ className: "flex h-[18px] min-w-[20px] items-center justify-center rounded-md border border-emerald-200 bg-emerald-50 px-1 text-[9px] font-black text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300",
128
+ children: tag.short
129
+ },
130
+ tag.short
131
+ )) });
132
+ }
133
+ function Chevron() {
134
+ return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 20 20", "aria-hidden": "true", className: "shrink-0 text-slate-400", children: /* @__PURE__ */ jsx("path", { d: "M7.5 4l6 6-6 6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) });
135
+ }
136
+ function SavedRow({ item, openLabel, onOpen }) {
137
+ const content = /* @__PURE__ */ jsxs(Fragment, { children: [
138
+ /* @__PURE__ */ jsx("span", { className: "w-1 shrink-0", style: { background: INBOX_GREEN } }),
139
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5 px-3 py-2", children: [
140
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-2", children: [
141
+ /* @__PURE__ */ jsx("span", { className: "text-[13px] font-bold tracking-tight whitespace-nowrap tabular-nums", children: item.title }),
142
+ item.tags && item.tags.length > 0 && /* @__PURE__ */ jsx(SavedTags, { tags: item.tags })
143
+ ] }),
144
+ item.detail && /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-semibold text-slate-800 dark:text-slate-100", children: item.detail }),
145
+ item.meta && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: item.meta })
146
+ ] }),
147
+ onOpen && /* @__PURE__ */ jsx("span", { className: "flex items-center pr-2.5", children: /* @__PURE__ */ jsx(Chevron, {}) })
148
+ ] });
149
+ return /* @__PURE__ */ jsx("li", { className: `overflow-hidden rounded-xl bg-white dark:bg-slate-900 ${CARD_SHADOW}`, children: onOpen ? /* @__PURE__ */ jsx(
150
+ "button",
151
+ {
152
+ type: "button",
153
+ onClick: onOpen,
154
+ "aria-label": filled(openLabel, { title: item.title }),
155
+ style: { WebkitTapHighlightColor: "transparent" },
156
+ className: "flex w-full cursor-pointer touch-manipulation items-stretch border-0 bg-transparent p-0 text-left font-[inherit] text-current active:bg-slate-50 dark:active:bg-slate-800",
157
+ children: content
90
158
  }
159
+ ) : /* @__PURE__ */ jsx("span", { className: "flex items-stretch", children: content }) });
160
+ }
161
+ function sizeOf(text) {
162
+ const bytes = new Blob([text]).size;
163
+ return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
164
+ }
165
+ function requestJson(action, address) {
166
+ return JSON.stringify(
167
+ { method: action.method, path: action.path ? shownPath(action.path, address) : void 0, headers: action.headers ?? {}, body: action.body ?? null },
168
+ null,
169
+ 2
91
170
  );
92
171
  }
93
- function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBack, describeSaved, describeWrite }) {
94
- const [tab, setTab] = useState("saved");
172
+ function JsonToggle({ json, L, tone }) {
173
+ const [open, setOpen] = useState(false);
174
+ const [copied, setCopied] = useState(false);
175
+ const copy = async () => {
176
+ try {
177
+ await navigator.clipboard.writeText(json);
178
+ setCopied(true);
179
+ setTimeout(() => setCopied(false), 1500);
180
+ } catch {
181
+ setCopied(false);
182
+ }
183
+ };
184
+ const toneClass = tone === "inbox" ? "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300" : "border-orange-200 bg-orange-50 text-orange-800 dark:border-orange-900 dark:bg-orange-950 dark:text-orange-300";
185
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
186
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
187
+ /* @__PURE__ */ jsx(
188
+ "button",
189
+ {
190
+ type: "button",
191
+ onClick: () => setOpen((before) => !before),
192
+ "aria-expanded": open,
193
+ className: `flex h-9 cursor-pointer items-center rounded-full border px-3 text-[11px] font-bold ${toneClass}`,
194
+ children: open ? L.hideJson : L.showJson
195
+ }
196
+ ),
197
+ open && typeof navigator !== "undefined" && navigator.clipboard && /* @__PURE__ */ jsx(
198
+ "button",
199
+ {
200
+ type: "button",
201
+ onClick: () => void copy(),
202
+ className: "flex h-9 cursor-pointer items-center rounded-full border border-slate-300 bg-white px-3 text-[11px] font-bold text-current dark:border-slate-600 dark:bg-slate-800",
203
+ children: copied ? L.copied : L.copy
204
+ }
205
+ )
206
+ ] }),
207
+ open && /* @__PURE__ */ jsx("pre", { className: "m-0 max-h-[60vh] overflow-auto rounded-lg bg-slate-950 p-2.5 font-mono text-[10.5px] leading-snug whitespace-pre text-emerald-100", children: json })
208
+ ] });
209
+ }
210
+ function SavedPartCard({ part, L, read }) {
211
+ const [result, setResult] = useState({ state: "reading" });
212
+ useEffect(() => {
213
+ let current = true;
214
+ read(part.path).then((answer) => {
215
+ if (!current) return;
216
+ if (!answer || !answer.found) setResult({ state: "missing" });
217
+ else setResult({ state: "found", json: JSON.stringify(answer.body, null, 2), savedAt: answer.savedAt });
218
+ }).catch(() => {
219
+ if (current) setResult({ state: "missing" });
220
+ });
221
+ return () => {
222
+ current = false;
223
+ };
224
+ }, [part.path, read]);
225
+ return /* @__PURE__ */ jsxs("li", { className: `flex flex-col gap-1.5 rounded-xl bg-white px-3 py-2.5 dark:bg-slate-900 ${CARD_SHADOW}`, children: [
226
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
227
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col gap-0.5", children: [
228
+ /* @__PURE__ */ jsx("span", { className: "text-[13px] font-bold", children: part.label }),
229
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-[10px] break-all text-slate-500 dark:text-slate-400", children: part.path })
230
+ ] }),
231
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-right text-[10px] text-slate-600 tabular-nums dark:text-slate-300", children: [
232
+ result.state === "reading" && L.reading,
233
+ result.state === "missing" && /* @__PURE__ */ jsx("span", { className: "font-bold text-red-700 dark:text-red-300", children: L.notOnPhone }),
234
+ result.state === "found" && /* @__PURE__ */ jsxs(Fragment, { children: [
235
+ /* @__PURE__ */ jsx("span", { className: "block", children: filled(L.savedOn, { date: day(result.savedAt), time: clock(result.savedAt) }) }),
236
+ /* @__PURE__ */ jsx("span", { className: "block", children: sizeOf(result.json) })
237
+ ] })
238
+ ] })
239
+ ] }),
240
+ result.state === "found" && /* @__PURE__ */ jsx(JsonToggle, { json: result.json, L, tone: "inbox" })
241
+ ] });
242
+ }
243
+ function SavedItemDetail({ item, L, read }) {
244
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5", children: [
245
+ /* @__PURE__ */ jsxs("div", { className: `flex items-stretch overflow-hidden rounded-xl bg-white dark:bg-slate-900 ${CARD_SHADOW}`, children: [
246
+ /* @__PURE__ */ jsx("span", { className: "w-1 shrink-0", style: { background: INBOX_GREEN } }),
247
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5 px-3 py-2", children: [
248
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-2", children: [
249
+ /* @__PURE__ */ jsx("span", { className: "text-[15px] font-black tracking-tight whitespace-nowrap tabular-nums", children: item.title }),
250
+ item.tags && item.tags.length > 0 && /* @__PURE__ */ jsx(SavedTags, { tags: item.tags })
251
+ ] }),
252
+ item.detail && /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold text-slate-800 dark:text-slate-100", children: item.detail }),
253
+ item.meta && /* @__PURE__ */ jsx("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: item.meta })
254
+ ] })
255
+ ] }),
256
+ /* @__PURE__ */ jsx("ul", { className: "m-0 flex list-none flex-col gap-1.5 p-0", children: (item.parts ?? []).map((part) => /* @__PURE__ */ jsx(SavedPartCard, { part, L, read }, part.path)) })
257
+ ] });
258
+ }
259
+ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBack, describeSaved, describeWrite, readSaved }) {
260
+ const [tab, setTab] = useState(() => toSendOf(state) > 0 ? "waiting" : "saved");
95
261
  const [search, setSearch] = useState("");
262
+ const [openItem, setOpenItem] = useState(null);
263
+ const listScroll = useRef(0);
264
+ const panelRef = useRef(null);
96
265
  const backRef = useRef(null);
97
266
  const { inbox, downloading, waiting } = state;
98
267
  const pct = percentOf(state);
99
- const pctLabel = pct === null ? "–" : `${pct}%`;
268
+ const toSend = toSendOf(state);
269
+ const refused = waiting.length - toSend;
100
270
  useEffect(() => {
101
271
  backRef.current?.focus();
102
272
  const before = document.body.style.overflow;
@@ -105,22 +275,42 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
105
275
  document.body.style.overflow = before;
106
276
  };
107
277
  }, []);
278
+ useEffect(() => {
279
+ if (!openItem) return;
280
+ const escape = (e) => {
281
+ if (e.key !== "Escape") return;
282
+ e.stopImmediatePropagation();
283
+ setOpenItem(null);
284
+ };
285
+ document.addEventListener("keydown", escape, true);
286
+ return () => document.removeEventListener("keydown", escape, true);
287
+ }, [openItem]);
288
+ const openSaved = (item) => {
289
+ listScroll.current = panelRef.current?.scrollTop ?? 0;
290
+ setOpenItem(item);
291
+ panelRef.current?.scrollTo?.({ top: 0 });
292
+ };
293
+ const closeSaved = () => {
294
+ setOpenItem(null);
295
+ requestAnimationFrame(() => panelRef.current?.scrollTo?.({ top: listScroll.current }));
296
+ };
108
297
  const summary = useMemo(() => {
109
298
  const paths = inbox.saved.map((saved) => shownPath(saved, address));
110
299
  if (describeSaved) return describeSaved(paths);
111
- return { items: paths.map((path) => ({ key: path, title: path })) };
300
+ return { items: paths.map((path) => ({ key: path, title: path, parts: [{ label: path, path }] })) };
112
301
  }, [inbox.saved, address, describeSaved]);
113
302
  const wanted = plain(search.trim());
114
303
  const shown = summary.items.filter((item) => matches(item, wanted));
115
- const footer = legendOf(summary.items).map((tag) => `${tag.short} ${tag.label}`);
116
- if (summary.note) footer.push(summary.note);
117
- const savedLine = downloading ? filled(L.downloading, { ready: inbox.ready, total: inbox.total }) : summary.items.length ? filled(L.savedCount, { n: summary.items.length }) : L.nothingSaved;
304
+ const legend = legendOf(summary.items);
305
+ const downloadingLine = filled(L.downloading, { ready: inbox.ready, total: inbox.total });
306
+ const savedLine = downloading ? downloadingLine : summary.items.length ? filled(L.savedCount, { n: summary.items.length }) : L.nothingSaved;
118
307
  const describe = (action) => {
119
308
  if (!action.method || !action.path) return { title: action.id };
120
309
  const write = { method: action.method, path: shownPath(action.path, address) };
121
310
  return describeWrite?.(write) ?? { title: `${write.method} ${write.path}` };
122
311
  };
123
312
  const stateLabel = (action) => action.state === "sending" ? L.sending : action.state === "rejected" ? L.rejected : L.pending;
313
+ const panel = "flex min-h-0 flex-1 flex-col gap-2.5 overflow-auto px-4 pt-4 pb-[calc(env(safe-area-inset-bottom,0px)+1rem)]";
124
314
  return /* @__PURE__ */ jsxs(
125
315
  "div",
126
316
  {
@@ -130,53 +320,91 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
130
320
  onClick: (e) => e.stopPropagation(),
131
321
  className: "fixed inset-0 z-[60] flex flex-col bg-slate-100 font-[inherit] text-proef-navy dark:bg-slate-950 dark:text-slate-100",
132
322
  children: [
133
- /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-col gap-2.5 border-b border-slate-200 bg-white px-3 pt-[calc(env(safe-area-inset-top,0px)+0.75rem)] pb-2.5 dark:border-slate-800 dark:bg-slate-900", children: [
134
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
323
+ /* @__PURE__ */ jsxs("div", { className: "relative shrink-0 bg-proef-navy px-4 pt-[calc(env(safe-area-inset-top,0px)+0.75rem)] pb-14 text-white", children: [
324
+ /* @__PURE__ */ jsx(
325
+ "div",
326
+ {
327
+ "aria-hidden": "true",
328
+ className: "pointer-events-none absolute inset-0 opacity-60",
329
+ style: { background: `radial-gradient(120% 90% at 0% 0%, ${INBOX_GREEN}33 0%, transparent 55%), radial-gradient(120% 90% at 100% 0%, ${OUTBOX_ORANGE}33 0%, transparent 55%)` }
330
+ }
331
+ ),
332
+ /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-2", children: [
135
333
  /* @__PURE__ */ jsx(
136
334
  "button",
137
335
  {
138
336
  ref: backRef,
139
337
  type: "button",
140
338
  "aria-label": L.back,
141
- onClick: onBack,
142
- className: "-ml-1.5 flex h-11 w-11 cursor-pointer items-center justify-center rounded-lg border-0 bg-transparent text-current hover:bg-slate-100 dark:hover:bg-slate-800",
143
- children: /* @__PURE__ */ jsx("svg", { width: "18", height: "18", viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M12.5 4L6.5 10l6 6", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
339
+ onClick: tab === "saved" && openItem ? closeSaved : onBack,
340
+ className: "-ml-2 flex h-11 w-11 cursor-pointer items-center justify-center rounded-full border-0 bg-transparent text-white outline-none hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white/70",
341
+ children: /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M12.5 4L6.5 10l6 6", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round" }) })
144
342
  }
145
343
  ),
146
- /* @__PURE__ */ jsx(OfflineBoxesIcon, { size: 24 }),
147
- /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-baseline gap-1.5", children: [
148
- /* @__PURE__ */ jsx("h2", { className: "m-0 text-[15px] font-black tracking-tight uppercase", children: L.title }),
149
- subtitle && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-600 dark:text-slate-300", children: subtitle })
344
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
345
+ /* @__PURE__ */ jsxs("h2", { className: "m-0 text-xl leading-tight font-black tracking-tight", children: [
346
+ /* @__PURE__ */ jsx("span", { style: { color: INBOX_GREEN }, children: L.saved }),
347
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "px-1.5 text-white/50", children: "·" }),
348
+ /* @__PURE__ */ jsx("span", { style: { color: OUTBOX_ORANGE }, children: L.waiting })
349
+ ] }),
350
+ subtitle && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-white/70", children: subtitle })
150
351
  ] }),
151
- onRefresh && /* @__PURE__ */ jsxs(
352
+ onRefresh && /* @__PURE__ */ jsx(
152
353
  "button",
153
354
  {
154
355
  type: "button",
155
356
  disabled: downloading,
156
357
  onClick: onRefresh,
157
- className: "flex h-[30px] cursor-pointer items-center gap-1 rounded-full border border-slate-300 bg-white px-2.5 text-[11px] font-bold text-current disabled:cursor-default disabled:opacity-50 dark:border-slate-600 dark:bg-slate-800",
158
- children: [
159
- /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }),
160
- L.refresh
161
- ]
358
+ "aria-label": L.refresh,
359
+ className: "flex h-11 w-11 cursor-pointer items-center justify-center rounded-full border border-white/25 bg-white/10 text-white disabled:cursor-default disabled:opacity-50",
360
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", "aria-hidden": "true", className: downloading ? "animate-spin" : "", children: /* @__PURE__ */ jsx("path", { d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9M13.5 2.5v3h-3", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })
162
361
  }
163
362
  )
164
- ] }),
165
- /* @__PURE__ */ jsxs("div", { role: "tablist", className: "grid grid-cols-2 gap-[3px] rounded-[10px] bg-slate-100 p-[3px] dark:bg-slate-800", children: [
166
- /* @__PURE__ */ jsx(TabButton, { active: tab === "saved", color: "#19C99B", tone: "text-emerald-700 dark:text-emerald-300", label: L.saved, value: pctLabel, onClick: () => setTab("saved") }),
167
- /* @__PURE__ */ jsx(TabButton, { active: tab === "waiting", color: "#EA6A12", tone: "text-orange-700 dark:text-orange-300", label: L.waiting, value: toSendOf(state), onClick: () => setTab("waiting") })
168
363
  ] })
169
364
  ] }),
170
- tab === "saved" ? /* @__PURE__ */ jsxs("div", { role: "tabpanel", "aria-label": L.saved, className: "flex min-h-0 flex-1 flex-col gap-2 overflow-auto px-3 pt-2.5 pb-[calc(env(safe-area-inset-bottom,0px)+0.625rem)]", children: [
171
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 text-[11px] text-slate-600 tabular-nums dark:text-slate-300", children: [
172
- /* @__PURE__ */ jsx("span", { children: savedLine }),
365
+ /* @__PURE__ */ jsxs("div", { role: "tablist", className: "relative z-10 -mt-[3.125rem] grid shrink-0 grid-cols-2 px-2.5", children: [
366
+ /* @__PURE__ */ jsx(
367
+ TabCard,
368
+ {
369
+ active: tab === "saved",
370
+ color: INBOX_GREEN,
371
+ label: L.saved,
372
+ value: pct === null ? "–" : `${pct}%`,
373
+ line: downloading ? downloadingLine : L.available,
374
+ progress: pct,
375
+ onClick: () => {
376
+ setTab("saved");
377
+ setOpenItem(null);
378
+ }
379
+ }
380
+ ),
381
+ /* @__PURE__ */ jsx(
382
+ TabCard,
383
+ {
384
+ active: tab === "waiting",
385
+ color: OUTBOX_ORANGE,
386
+ up: true,
387
+ label: L.waiting,
388
+ value: String(toSend),
389
+ line: toSend === 0 ? L.allSent : filled(L.toSend, { n: toSend }),
390
+ alert: refused > 0 ? filled(L.rejectedCount, { n: refused }) : void 0,
391
+ onClick: () => setTab("waiting")
392
+ }
393
+ )
394
+ ] }),
395
+ tab === "saved" ? /* @__PURE__ */ jsx("div", { ref: panelRef, role: "tabpanel", "aria-label": L.saved, className: panel, children: openItem && readSaved ? /* @__PURE__ */ jsx(SavedItemDetail, { item: openItem, L, read: readSaved }) : /* @__PURE__ */ jsxs(Fragment, { children: [
396
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 text-[11px] font-semibold text-slate-600 tabular-nums dark:text-slate-300", children: [
397
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
398
+ /* @__PURE__ */ jsx("span", { className: `h-2 w-2 rounded-full ${downloading ? "animate-pulse" : ""}`, style: { background: INBOX_GREEN } }),
399
+ savedLine
400
+ ] }),
173
401
  inbox.finishedAt && /* @__PURE__ */ jsx("span", { children: filled(L.savedAt, { date: day(inbox.finishedAt), time: clock(inbox.finishedAt) }) })
174
402
  ] }),
175
- !downloading && inbox.failed > 0 && /* @__PURE__ */ jsx("p", { className: "m-0 text-[11px] text-orange-800 dark:text-orange-300", children: filled(L.failed, { n: inbox.failed }) }),
176
- summary.items.length > 0 && /* @__PURE__ */ jsxs("label", { className: "flex h-[34px] shrink-0 items-center gap-1.5 rounded-[9px] border border-slate-300 bg-white px-2.5 dark:border-slate-700 dark:bg-slate-900", children: [
177
- /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 16 16", "aria-hidden": "true", className: "shrink-0 text-slate-500", children: [
178
- /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.6" }),
179
- /* @__PURE__ */ jsx("path", { d: "M10.5 10.5L14 14", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
403
+ !downloading && inbox.failed > 0 && /* @__PURE__ */ jsx("p", { className: "m-0 rounded-lg bg-orange-50 px-2.5 py-1.5 text-[11px] text-orange-800 dark:bg-orange-950 dark:text-orange-300", children: filled(L.failed, { n: inbox.failed }) }),
404
+ summary.items.length > 0 && /* @__PURE__ */ jsxs("label", { className: "flex h-11 shrink-0 items-center gap-2 rounded-full border border-slate-200 bg-white px-4 shadow-[0_1px_2px_rgba(0,27,99,0.06)] dark:border-slate-700 dark:bg-slate-900", children: [
405
+ /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 16 16", "aria-hidden": "true", className: "shrink-0 text-slate-400", children: [
406
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.8" }),
407
+ /* @__PURE__ */ jsx("path", { d: "M10.5 10.5L14 14", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
180
408
  ] }),
181
409
  /* @__PURE__ */ jsx(
182
410
  "input",
@@ -186,48 +414,71 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
186
414
  onChange: (e) => setSearch(e.target.value),
187
415
  placeholder: L.search,
188
416
  "aria-label": L.search,
189
- className: "min-w-0 flex-1 border-0 bg-transparent text-base text-current outline-none placeholder:text-slate-500 sm:text-xs"
417
+ className: "min-w-0 flex-1 border-0 bg-transparent text-base text-current outline-none placeholder:text-slate-400 sm:text-sm"
190
418
  }
191
419
  )
192
420
  ] }),
193
- shown.length > 0 && /* @__PURE__ */ jsx("ul", { className: "m-0 shrink-0 list-none overflow-hidden rounded-[10px] bg-white p-0 dark:bg-slate-900", children: shown.map((item) => /* @__PURE__ */ jsxs("li", { className: ROW, children: [
194
- /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-px", children: [
195
- /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 items-baseline gap-1.5 text-xs", children: [
196
- /* @__PURE__ */ jsx("span", { className: "font-extrabold break-all tabular-nums", children: item.title }),
197
- item.meta && /* @__PURE__ */ jsx("span", { className: "truncate text-[10px] text-slate-600 dark:text-slate-300", children: item.meta })
198
- ] }),
199
- item.detail && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-700 dark:text-slate-200", children: item.detail })
200
- ] }),
201
- item.tags && item.tags.length > 0 && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 gap-[3px]", children: item.tags.map((tag) => /* @__PURE__ */ jsx(
202
- "span",
203
- {
204
- title: tag.label,
205
- "aria-label": tag.label,
206
- className: "flex h-[18px] min-w-[18px] items-center justify-center rounded-[5px] bg-emerald-50 px-0.5 text-[9px] font-extrabold text-emerald-800 dark:bg-emerald-950 dark:text-emerald-300",
207
- children: tag.short
208
- },
209
- tag.short
210
- )) })
211
- ] }, item.key)) }),
212
- summary.items.length > 0 && shown.length === 0 && /* @__PURE__ */ jsx("p", { className: "m-0 px-0.5 text-xs text-slate-600 dark:text-slate-300", children: L.noMatches }),
213
- footer.length > 0 && /* @__PURE__ */ jsx("span", { className: "px-0.5 text-[10px] text-slate-600 dark:text-slate-300", children: footer.join(" · ") })
214
- ] }) : /* @__PURE__ */ jsx("div", { role: "tabpanel", "aria-label": L.waiting, className: "flex min-h-0 flex-1 flex-col gap-2 overflow-auto px-3 pt-2.5 pb-[calc(env(safe-area-inset-bottom,0px)+0.625rem)]", children: waiting.length === 0 ? /* @__PURE__ */ jsx("p", { className: "m-0 text-xs text-slate-600 dark:text-slate-300", children: L.nothingWaiting }) : /* @__PURE__ */ jsxs(Fragment, { children: [
215
- /* @__PURE__ */ jsx("span", { className: "text-[11px] text-slate-600 dark:text-slate-300", children: L.waitingHint }),
216
- /* @__PURE__ */ jsx("ul", { className: "m-0 shrink-0 list-none overflow-hidden rounded-[10px] bg-white p-0 dark:bg-slate-900", children: waiting.map((action) => {
217
- const description = describe(action);
218
- return /* @__PURE__ */ jsxs("li", { className: ROW, children: [
219
- /* @__PURE__ */ jsx("span", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-[7px] bg-orange-50 text-orange-700 dark:bg-orange-950 dark:text-orange-300", children: /* @__PURE__ */ jsx("svg", { width: "13", height: "13", viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M10 15V5M6 9l4-4 4 4", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
220
- /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-px", children: [
221
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold break-all", children: description.title }),
222
- description.detail && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-600 dark:text-slate-300", children: description.detail }),
223
- action.state === "rejected" && action.reason && /* @__PURE__ */ jsx("span", { className: "text-[11px] text-red-700 dark:text-red-300", children: action.reason })
224
- ] }),
225
- /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 flex-col items-end gap-px text-[10px]", children: [
226
- /* @__PURE__ */ jsx("span", { className: `font-bold ${STATE_TONE[action.state] ?? ""}`, children: stateLabel(action) }),
227
- action.createdAt && /* @__PURE__ */ jsx("span", { className: "text-slate-600 tabular-nums dark:text-slate-300", children: clock(action.createdAt) })
228
- ] })
229
- ] }, action.id);
230
- }) })
421
+ shown.length > 0 && /* @__PURE__ */ jsx("ul", { className: "m-0 flex shrink-0 list-none flex-col gap-1.5 p-0", children: shown.map((item) => /* @__PURE__ */ jsx(
422
+ SavedRow,
423
+ {
424
+ item,
425
+ openLabel: L.openSaved,
426
+ onOpen: readSaved && item.parts && item.parts.length > 0 ? () => openSaved(item) : void 0
427
+ },
428
+ item.key
429
+ )) }),
430
+ summary.items.length > 0 && shown.length === 0 && /* @__PURE__ */ jsx("p", { className: "m-0 px-1 text-xs text-slate-600 dark:text-slate-300", children: L.noMatches }),
431
+ (legend.length > 0 || summary.note) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 px-1 text-[10px] text-slate-500 dark:text-slate-400", children: [
432
+ legend.map((tag) => /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
433
+ /* @__PURE__ */ jsx("span", { className: "rounded border border-emerald-200 bg-emerald-50 px-1 font-black text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300", children: tag.short }),
434
+ tag.label
435
+ ] }, tag.short)),
436
+ summary.note && /* @__PURE__ */ jsx("span", { className: "basis-full", children: summary.note })
437
+ ] })
438
+ ] }) }) : /* @__PURE__ */ jsx("div", { role: "tabpanel", "aria-label": L.waiting, className: panel, children: waiting.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col items-center justify-center gap-3 px-6 pb-16 text-center", children: [
439
+ /* @__PURE__ */ jsx("span", { className: "flex h-20 w-20 items-center justify-center rounded-full", style: { background: `${OUTBOX_ORANGE}1f` }, children: /* @__PURE__ */ jsx("span", { className: "flex h-12 w-12 items-center justify-center rounded-full text-white", style: { background: OUTBOX_ORANGE }, children: /* @__PURE__ */ jsx("svg", { width: "22", height: "22", viewBox: "0 0 20 20", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M4.5 10.5l3.5 3.5 7.5-8", fill: "none", stroke: "currentColor", strokeWidth: "2.6", strokeLinecap: "round", strokeLinejoin: "round" }) }) }) }),
440
+ /* @__PURE__ */ jsx("span", { className: "text-lg font-black tracking-tight", children: L.allSent }),
441
+ /* @__PURE__ */ jsx("span", { className: "max-w-[260px] text-xs text-slate-600 dark:text-slate-300", children: L.nothingWaiting })
442
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
443
+ /* @__PURE__ */ jsx("span", { className: "px-1 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: L.waitingHint }),
444
+ /* @__PURE__ */ jsxs("ol", { className: "relative m-0 flex list-none flex-col gap-2 p-0 pl-5", children: [
445
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "absolute top-3 bottom-3 left-[7px] w-0.5 rounded bg-orange-200 dark:bg-orange-900" }),
446
+ waiting.map((action) => {
447
+ const description = describe(action);
448
+ const tone = STATE_TONE[action.state] ?? STATE_TONE.pending;
449
+ return /* @__PURE__ */ jsxs("li", { className: "relative", children: [
450
+ /* @__PURE__ */ jsx(
451
+ "span",
452
+ {
453
+ "aria-hidden": "true",
454
+ className: `absolute top-3.5 -left-5 h-3.5 w-3.5 rounded-full border-[3px] border-slate-100 dark:border-slate-950 ${action.state === "sending" ? "animate-pulse" : ""}`,
455
+ style: { background: tone.dot }
456
+ }
457
+ ),
458
+ /* @__PURE__ */ jsxs("div", { className: `flex flex-col gap-1.5 rounded-xl bg-white px-3 py-2.5 dark:bg-slate-900 ${CARD_SHADOW}`, children: [
459
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
460
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
461
+ /* @__PURE__ */ jsx("span", { className: "text-[13px] font-bold break-words", children: description.title }),
462
+ description.detail && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-600 dark:text-slate-300", children: description.detail }),
463
+ action.state === "rejected" && action.reason && /* @__PURE__ */ jsx("span", { className: "text-[11px] text-red-700 dark:text-red-300", children: action.reason })
464
+ ] }),
465
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 flex-col items-end gap-1", children: [
466
+ /* @__PURE__ */ jsx("span", { className: `rounded-full px-2 py-0.5 text-[10px] font-bold whitespace-nowrap ${tone.pill}`, children: stateLabel(action) }),
467
+ action.createdAt && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-500 tabular-nums dark:text-slate-400", children: clock(action.createdAt) })
468
+ ] })
469
+ ] }),
470
+ action.method && action.path && /* @__PURE__ */ jsxs(Fragment, { children: [
471
+ /* @__PURE__ */ jsxs("span", { className: "font-mono text-[10px] break-all text-slate-500 dark:text-slate-400", children: [
472
+ action.method,
473
+ " ",
474
+ shownPath(action.path, address)
475
+ ] }),
476
+ /* @__PURE__ */ jsx(JsonToggle, { json: requestJson(action, address), L, tone: "outbox" })
477
+ ] })
478
+ ] })
479
+ ] }, action.id);
480
+ })
481
+ ] })
231
482
  ] }) })
232
483
  ]
233
484
  }
@@ -235,6 +486,9 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
235
486
  }
236
487
  export {
237
488
  DEFAULT_OFFLINE_BOXES_LABELS,
489
+ INBOX_GREEN,
490
+ OUTBOX_ORANGE,
491
+ OfflineArrow,
238
492
  OfflineBoxesView as default,
239
493
  filled,
240
494
  percentOf,