@proef/common-ui 2.6.42 → 2.6.43
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/esm/v1/components/feedback/OfflineBoxes/OfflineBoxes.js +20 -7
- package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxes.js.map +1 -1
- package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxesView.js +175 -88
- package/dist/esm/v1/components/feedback/OfflineBoxes/OfflineBoxesView.js.map +1 -1
- package/dist/style.components.css +2 -2
- package/dist/style.css +2 -2
- package/dist/style.layered.css +2 -2
- package/dist/types/v1/components/feedback/OfflineBoxes/OfflineBoxes.d.ts +3 -3
- package/dist/types/v1/components/feedback/OfflineBoxes/OfflineBoxesView.d.ts +23 -10
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { createPortal } from "react-dom";
|
|
|
4
4
|
import { useOfflineBoxes } from "../../../capabilities/onepoint-rn/useOfflineBoxes.js";
|
|
5
5
|
import { useDialogContainer } from "../../overlays/Dialog/Dialog.js";
|
|
6
6
|
import { OfflineBoxesIcon } from "./OfflineBoxesIcon.js";
|
|
7
|
-
import OfflineBoxesView, { DEFAULT_OFFLINE_BOXES_LABELS, percentOf, toSendOf, filled } from "./OfflineBoxesView.js";
|
|
7
|
+
import OfflineBoxesView, { DEFAULT_OFFLINE_BOXES_LABELS, percentOf, toSendOf, INBOX_GREEN, OfflineArrow, OUTBOX_ORANGE, filled } from "./OfflineBoxesView.js";
|
|
8
8
|
function OfflineBoxes({ storageId, inboxIds, onRefresh, address, subtitle, describeSaved, describeWrite, labels, className = "" }) {
|
|
9
9
|
const L = { ...DEFAULT_OFFLINE_BOXES_LABELS, ...labels };
|
|
10
10
|
const state = useOfflineBoxes({ storageId, inboxIds });
|
|
@@ -37,17 +37,30 @@ function OfflineBoxes({ storageId, inboxIds, onRefresh, address, subtitle, descr
|
|
|
37
37
|
type: "button",
|
|
38
38
|
"aria-haspopup": "dialog",
|
|
39
39
|
"aria-expanded": open,
|
|
40
|
-
"aria-label": `${L.title}: ${pctLabel} · ${filled(L.toSend, { n: toSend })}`,
|
|
40
|
+
"aria-label": `${L.title}: ${L.saved} ${pctLabel} · ${filled(L.toSend, { n: toSend })}`,
|
|
41
41
|
onClick: (e) => {
|
|
42
42
|
e.stopPropagation();
|
|
43
43
|
setOpen(true);
|
|
44
44
|
},
|
|
45
|
-
className: "flex min-h-11 cursor-pointer items-center gap-1.5 rounded-
|
|
45
|
+
className: "flex min-h-11 cursor-pointer items-center gap-1.5 rounded-full border-0 bg-transparent px-1 hover:bg-slate-100 dark:hover:bg-slate-800",
|
|
46
46
|
children: [
|
|
47
|
-
/* @__PURE__ */ jsx(OfflineBoxesIcon, { size:
|
|
48
|
-
/* @__PURE__ */ jsxs("span", { className: "flex
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
47
|
+
/* @__PURE__ */ jsx(OfflineBoxesIcon, { size: 26 }),
|
|
48
|
+
/* @__PURE__ */ jsxs("span", { className: "flex h-7 items-stretch overflow-hidden rounded-full text-[11px] font-black whitespace-nowrap tabular-nums shadow-[0_1px_3px_rgba(0,27,99,0.18)]", children: [
|
|
49
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-0.5 pr-1.5 pl-2 text-white", style: { background: INBOX_GREEN }, children: [
|
|
50
|
+
/* @__PURE__ */ jsx(OfflineArrow, {}),
|
|
51
|
+
pctLabel
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ jsxs(
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
className: `flex items-center gap-0.5 pr-2 pl-1.5 ${toSend > 0 ? "text-white" : "bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-400"}`,
|
|
57
|
+
style: toSend > 0 ? { background: OUTBOX_ORANGE } : void 0,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx(OfflineArrow, { up: true }),
|
|
60
|
+
toSend
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
)
|
|
51
64
|
] })
|
|
52
65
|
]
|
|
53
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OfflineBoxes.js","sources":["../../../../../../src/v1/components/feedback/OfflineBoxes/OfflineBoxes.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\r\nimport { createPortal } from 'react-dom'\r\nimport { useOfflineBoxes } from '../../../capabilities/onepoint-rn/useOfflineBoxes'\r\nimport { useDialogContainer } from '../../overlays/Dialog/Dialog'\r\nimport OfflineBoxesIcon from './OfflineBoxesIcon'\r\nimport OfflineBoxesView, {\r\n DEFAULT_OFFLINE_BOXES_LABELS,\r\n filled,\r\n percentOf,\r\n toSendOf,\r\n type OfflineBoxesLabels,\r\n type OfflineSavedSummary,\r\n type OfflineWrite,\r\n type OfflineWriteDescription,\r\n} from './OfflineBoxesView'\r\n\r\nexport {\r\n DEFAULT_OFFLINE_BOXES_LABELS,\r\n type OfflineBoxesLabels,\r\n type OfflineSavedItem,\r\n type OfflineSavedSummary,\r\n type OfflineSavedTag,\r\n type OfflineWrite,\r\n type OfflineWriteDescription,\r\n} from './OfflineBoxesView'\r\n\r\nexport interface OfflineBoxesProps {\r\n /** O mesmo `storageId` do `connectOutbox` e do `connectInbox`. */\r\n storageId: string | undefined\r\n /** As inboxes que este sítio mostra (ex: `['ajustes']`). Somam-se. */\r\n inboxIds: string[]\r\n /** O que o botão Atualizar faz (ex: chamar o `syncInbox`). Sem ele, não há botão. */\r\n onRefresh?: () => void\r\n /** Endereço da API (`api.defaults.baseURL`): os endereços chegam ao `describeSaved` e ao `describeWrite` sem ele à frente. */\r\n address?: string\r\n /** Linha ao lado do título na vista (ex: o nome do ecrã). */\r\n subtitle?: string\r\n /** Transforma os endereços guardados nas linhas que se mostram (ex: uma por OT). Sem ele, mostra os endereços. */\r\n describeSaved?: (paths: string[]) => OfflineSavedSummary\r\n /** Diz o que é cada escrita por enviar (ex: \"Ajuste guardado\"). Sem ele, ou se devolver `null`, mostra método e endereço. */\r\n describeWrite?: (write: OfflineWrite) => OfflineWriteDescription | null\r\n labels?: Partial<OfflineBoxesLabels>\r\n className?: string\r\n}\r\n\r\n/**\r\n * O que a app tem guardado para usar sem rede (Inbox, verde) e o que tem por\r\n * enviar (Outbox, laranja), num
|
|
1
|
+
{"version":3,"file":"OfflineBoxes.js","sources":["../../../../../../src/v1/components/feedback/OfflineBoxes/OfflineBoxes.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react'\r\nimport { createPortal } from 'react-dom'\r\nimport { useOfflineBoxes } from '../../../capabilities/onepoint-rn/useOfflineBoxes'\r\nimport { useDialogContainer } from '../../overlays/Dialog/Dialog'\r\nimport OfflineBoxesIcon from './OfflineBoxesIcon'\r\nimport OfflineBoxesView, {\r\n DEFAULT_OFFLINE_BOXES_LABELS,\r\n INBOX_GREEN,\r\n OUTBOX_ORANGE,\r\n OfflineArrow,\r\n filled,\r\n percentOf,\r\n toSendOf,\r\n type OfflineBoxesLabels,\r\n type OfflineSavedSummary,\r\n type OfflineWrite,\r\n type OfflineWriteDescription,\r\n} from './OfflineBoxesView'\r\n\r\nexport {\r\n DEFAULT_OFFLINE_BOXES_LABELS,\r\n type OfflineBoxesLabels,\r\n type OfflineSavedItem,\r\n type OfflineSavedSummary,\r\n type OfflineSavedTag,\r\n type OfflineWrite,\r\n type OfflineWriteDescription,\r\n} from './OfflineBoxesView'\r\n\r\nexport interface OfflineBoxesProps {\r\n /** O mesmo `storageId` do `connectOutbox` e do `connectInbox`. */\r\n storageId: string | undefined\r\n /** As inboxes que este sítio mostra (ex: `['ajustes']`). Somam-se. */\r\n inboxIds: string[]\r\n /** O que o botão Atualizar faz (ex: chamar o `syncInbox`). Sem ele, não há botão. */\r\n onRefresh?: () => void\r\n /** Endereço da API (`api.defaults.baseURL`): os endereços chegam ao `describeSaved` e ao `describeWrite` sem ele à frente. */\r\n address?: string\r\n /** Linha ao lado do título na vista (ex: o nome do ecrã). */\r\n subtitle?: string\r\n /** Transforma os endereços guardados nas linhas que se mostram (ex: uma por OT). Sem ele, mostra os endereços. */\r\n describeSaved?: (paths: string[]) => OfflineSavedSummary\r\n /** Diz o que é cada escrita por enviar (ex: \"Ajuste guardado\"). Sem ele, ou se devolver `null`, mostra método e endereço. */\r\n describeWrite?: (write: OfflineWrite) => OfflineWriteDescription | null\r\n labels?: Partial<OfflineBoxesLabels>\r\n className?: string\r\n}\r\n\r\n/**\r\n * O que a app tem guardado para usar sem rede (Inbox, verde) e o que tem por\r\n * enviar (Outbox, laranja), num botão que se põe onde se quiser (ex: à\r\n * direita do título): o ícone e uma pílula com duas metades, a percentagem\r\n * guardada (sobe enquanto a descarga corre) e quantas escritas faltam enviar. Tocar abre a vista inteira\r\n * com o detalhe. Fora da app OnePoint não aparece.\r\n */\r\nexport default function OfflineBoxes({ storageId, inboxIds, onRefresh, address, subtitle, describeSaved, describeWrite, labels, className = '' }: OfflineBoxesProps) {\r\n const L = { ...DEFAULT_OFFLINE_BOXES_LABELS, ...labels }\r\n const state = useOfflineBoxes({ storageId, inboxIds })\r\n const [open, setOpen] = useState(false)\r\n const triggerRef = useRef<HTMLButtonElement>(null)\r\n const dialogContainer = useDialogContainer()\r\n\r\n const close = () => {\r\n setOpen(false)\r\n triggerRef.current?.focus()\r\n }\r\n\r\n useEffect(() => {\r\n if (!open) return\r\n const escape = (e: KeyboardEvent) => {\r\n if (e.key !== 'Escape') return\r\n setOpen(false)\r\n triggerRef.current?.focus()\r\n }\r\n document.addEventListener('keydown', escape)\r\n return () => document.removeEventListener('keydown', escape)\r\n }, [open])\r\n\r\n if (!state) return null\r\n\r\n const pct = percentOf(state)\r\n const pctLabel = pct === null ? '–' : `${pct}%`\r\n const toSend = toSendOf(state)\r\n\r\n return (\r\n <div className={`relative inline-flex shrink-0 ${className}`}>\r\n <button\r\n ref={triggerRef}\r\n type=\"button\"\r\n aria-haspopup=\"dialog\"\r\n aria-expanded={open}\r\n aria-label={`${L.title}: ${L.saved} ${pctLabel} · ${filled(L.toSend, { n: toSend })}`}\r\n onClick={(e) => {\r\n e.stopPropagation()\r\n setOpen(true)\r\n }}\r\n className=\"flex min-h-11 cursor-pointer items-center gap-1.5 rounded-full border-0 bg-transparent px-1 hover:bg-slate-100 dark:hover:bg-slate-800\"\r\n >\r\n <OfflineBoxesIcon size={26} />\r\n <span className=\"flex h-7 items-stretch overflow-hidden rounded-full text-[11px] font-black whitespace-nowrap tabular-nums shadow-[0_1px_3px_rgba(0,27,99,0.18)]\">\r\n <span className=\"flex items-center gap-0.5 pr-1.5 pl-2 text-white\" style={{ background: INBOX_GREEN }}>\r\n <OfflineArrow />\r\n {pctLabel}\r\n </span>\r\n <span\r\n className={`flex items-center gap-0.5 pr-2 pl-1.5 ${toSend > 0 ? 'text-white' : 'bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-400'}`}\r\n style={toSend > 0 ? { background: OUTBOX_ORANGE } : undefined}\r\n >\r\n <OfflineArrow up />\r\n {toSend}\r\n </span>\r\n </span>\r\n </button>\r\n {open &&\r\n createPortal(\r\n <OfflineBoxesView\r\n state={state}\r\n labels={L}\r\n subtitle={subtitle}\r\n address={address}\r\n onRefresh={onRefresh}\r\n onBack={close}\r\n describeSaved={describeSaved}\r\n describeWrite={describeWrite}\r\n />,\r\n dialogContainer ?? document.body,\r\n )}\r\n </div>\r\n )\r\n}\r\n\r\nexport { OfflineBoxes }\r\n"],"names":[],"mappings":";;;;;;;AAuDA,SAAwB,aAAa,EAAE,WAAW,UAAU,WAAW,SAAS,UAAU,eAAe,eAAe,QAAQ,YAAY,GAAA,GAAyB;AACnK,QAAM,IAAI,EAAE,GAAG,8BAA8B,GAAG,OAAA;AAChD,QAAM,QAAQ,gBAAgB,EAAE,WAAW,UAAU;AACrD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,aAAa,OAA0B,IAAI;AACjD,QAAM,kBAAkB,mBAAA;AAExB,QAAM,QAAQ,MAAM;AAClB,YAAQ,KAAK;AACb,eAAW,SAAS,MAAA;AAAA,EACtB;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,UAAM,SAAS,CAAC,MAAqB;AACnC,UAAI,EAAE,QAAQ,SAAU;AACxB,cAAQ,KAAK;AACb,iBAAW,SAAS,MAAA;AAAA,IACtB;AACA,aAAS,iBAAiB,WAAW,MAAM;AAC3C,WAAO,MAAM,SAAS,oBAAoB,WAAW,MAAM;AAAA,EAC7D,GAAG,CAAC,IAAI,CAAC;AAET,MAAI,CAAC,MAAO,QAAO;AAEnB,QAAM,MAAM,UAAU,KAAK;AAC3B,QAAM,WAAW,QAAQ,OAAO,MAAM,GAAG,GAAG;AAC5C,QAAM,SAAS,SAAS,KAAK;AAE7B,SACE,qBAAC,OAAA,EAAI,WAAW,iCAAiC,SAAS,IACxD,UAAA;AAAA,IAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK;AAAA,QACL,MAAK;AAAA,QACL,iBAAc;AAAA,QACd,iBAAe;AAAA,QACf,cAAY,GAAG,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,QAAQ,MAAM,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAA,CAAQ,CAAC;AAAA,QACnF,SAAS,CAAC,MAAM;AACd,YAAE,gBAAA;AACF,kBAAQ,IAAI;AAAA,QACd;AAAA,QACA,WAAU;AAAA,QAEV,UAAA;AAAA,UAAA,oBAAC,kBAAA,EAAiB,MAAM,GAAA,CAAI;AAAA,UAC5B,qBAAC,QAAA,EAAK,WAAU,mJACd,UAAA;AAAA,YAAA,qBAAC,UAAK,WAAU,oDAAmD,OAAO,EAAE,YAAY,eACtF,UAAA;AAAA,cAAA,oBAAC,cAAA,EAAa;AAAA,cACb;AAAA,YAAA,GACH;AAAA,YACA;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,WAAW,yCAAyC,SAAS,IAAI,eAAe,mEAAmE;AAAA,gBACnJ,OAAO,SAAS,IAAI,EAAE,YAAY,kBAAkB;AAAA,gBAEpD,UAAA;AAAA,kBAAA,oBAAC,cAAA,EAAa,IAAE,KAAA,CAAC;AAAA,kBAChB;AAAA,gBAAA;AAAA,cAAA;AAAA,YAAA;AAAA,UACH,EAAA,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAED,QACC;AAAA,MACE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC;AAAA,UACA,QAAQ;AAAA,UACR;AAAA,UACA;AAAA,UACA;AAAA,UACA,QAAQ;AAAA,UACR;AAAA,UACA;AAAA,QAAA;AAAA,MAAA;AAAA,MAEF,mBAAmB,SAAS;AAAA,IAAA;AAAA,EAC9B,GACJ;AAEJ;"}
|
|
@@ -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: "
|
|
6
|
-
saved: "
|
|
7
|
-
waiting: "
|
|
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: "
|
|
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,13 @@ 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"
|
|
23
25
|
};
|
|
26
|
+
const INBOX_GREEN = "#19C99B";
|
|
27
|
+
const OUTBOX_ORANGE = "#EA6A12";
|
|
24
28
|
function filled(template, values) {
|
|
25
29
|
return template.replace(/\{(\w+)\}/g, (whole, name) => name in values ? String(values[name]) : whole);
|
|
26
30
|
}
|
|
@@ -67,36 +71,75 @@ function legendOf(items) {
|
|
|
67
71
|
}
|
|
68
72
|
return [...seen.values()];
|
|
69
73
|
}
|
|
74
|
+
function OfflineArrow({ up }) {
|
|
75
|
+
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" }) });
|
|
76
|
+
}
|
|
70
77
|
const STATE_TONE = {
|
|
71
|
-
pending: "text-orange-
|
|
72
|
-
sending: "text-proef-navy dark:text-sky-300",
|
|
73
|
-
rejected: "text-red-700 dark:text-red-300"
|
|
78
|
+
pending: { dot: OUTBOX_ORANGE, pill: "bg-orange-50 text-orange-800 dark:bg-orange-950 dark:text-orange-300" },
|
|
79
|
+
sending: { dot: "#001b63", pill: "bg-sky-50 text-proef-navy dark:bg-sky-950 dark:text-sky-300" },
|
|
80
|
+
rejected: { dot: "#dc2626", pill: "bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300" }
|
|
74
81
|
};
|
|
75
|
-
const
|
|
76
|
-
function
|
|
77
|
-
return /* @__PURE__ */
|
|
82
|
+
const CARD_SHADOW = "shadow-[0_1px_2px_rgba(0,27,99,0.08)]";
|
|
83
|
+
function TabCard({ active, color, up, label, value, line, progress, alert, onClick }) {
|
|
84
|
+
return /* @__PURE__ */ jsx(
|
|
78
85
|
"button",
|
|
79
86
|
{
|
|
80
87
|
type: "button",
|
|
81
88
|
role: "tab",
|
|
82
89
|
"aria-selected": active,
|
|
83
90
|
onClick,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
style: { ["--tone"]: color, WebkitTapHighlightColor: "transparent" },
|
|
92
|
+
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",
|
|
93
|
+
children: /* @__PURE__ */ jsxs(
|
|
94
|
+
"span",
|
|
95
|
+
{
|
|
96
|
+
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"}`,
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-x-0 top-0 h-1", style: { background: color } }),
|
|
99
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1 text-[10px] font-black tracking-[0.18em] uppercase", style: { color }, children: [
|
|
100
|
+
/* @__PURE__ */ jsx(OfflineArrow, { up }),
|
|
101
|
+
label
|
|
102
|
+
] }),
|
|
103
|
+
/* @__PURE__ */ jsx("span", { className: "text-[30px] leading-none font-black tracking-tight tabular-nums", children: value }),
|
|
104
|
+
/* @__PURE__ */ jsx("span", { className: "w-full truncate text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: line }),
|
|
105
|
+
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 } }) }),
|
|
106
|
+
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 })
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
)
|
|
90
110
|
}
|
|
91
111
|
);
|
|
92
112
|
}
|
|
113
|
+
function SavedRow({ item }) {
|
|
114
|
+
return /* @__PURE__ */ jsxs("li", { className: `flex items-stretch overflow-hidden rounded-xl bg-white dark:bg-slate-900 ${CARD_SHADOW}`, children: [
|
|
115
|
+
/* @__PURE__ */ jsx("span", { className: "w-1 shrink-0", style: { background: INBOX_GREEN } }),
|
|
116
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5 px-3 py-2", children: [
|
|
117
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-2", children: [
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: "text-[13px] font-bold tracking-tight whitespace-nowrap tabular-nums", children: item.title }),
|
|
119
|
+
item.tags && item.tags.length > 0 && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 gap-1", children: item.tags.map((tag) => /* @__PURE__ */ jsx(
|
|
120
|
+
"span",
|
|
121
|
+
{
|
|
122
|
+
title: tag.label,
|
|
123
|
+
"aria-label": tag.label,
|
|
124
|
+
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",
|
|
125
|
+
children: tag.short
|
|
126
|
+
},
|
|
127
|
+
tag.short
|
|
128
|
+
)) })
|
|
129
|
+
] }),
|
|
130
|
+
item.detail && /* @__PURE__ */ jsx("span", { className: "truncate text-xs font-semibold text-slate-800 dark:text-slate-100", children: item.detail }),
|
|
131
|
+
item.meta && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: item.meta })
|
|
132
|
+
] })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
93
135
|
function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBack, describeSaved, describeWrite }) {
|
|
94
|
-
const [tab, setTab] = useState("saved");
|
|
136
|
+
const [tab, setTab] = useState(() => toSendOf(state) > 0 ? "waiting" : "saved");
|
|
95
137
|
const [search, setSearch] = useState("");
|
|
96
138
|
const backRef = useRef(null);
|
|
97
139
|
const { inbox, downloading, waiting } = state;
|
|
98
140
|
const pct = percentOf(state);
|
|
99
|
-
const
|
|
141
|
+
const toSend = toSendOf(state);
|
|
142
|
+
const refused = waiting.length - toSend;
|
|
100
143
|
useEffect(() => {
|
|
101
144
|
backRef.current?.focus();
|
|
102
145
|
const before = document.body.style.overflow;
|
|
@@ -112,15 +155,16 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
|
|
|
112
155
|
}, [inbox.saved, address, describeSaved]);
|
|
113
156
|
const wanted = plain(search.trim());
|
|
114
157
|
const shown = summary.items.filter((item) => matches(item, wanted));
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
const savedLine = downloading ?
|
|
158
|
+
const legend = legendOf(summary.items);
|
|
159
|
+
const downloadingLine = filled(L.downloading, { ready: inbox.ready, total: inbox.total });
|
|
160
|
+
const savedLine = downloading ? downloadingLine : summary.items.length ? filled(L.savedCount, { n: summary.items.length }) : L.nothingSaved;
|
|
118
161
|
const describe = (action) => {
|
|
119
162
|
if (!action.method || !action.path) return { title: action.id };
|
|
120
163
|
const write = { method: action.method, path: shownPath(action.path, address) };
|
|
121
164
|
return describeWrite?.(write) ?? { title: `${write.method} ${write.path}` };
|
|
122
165
|
};
|
|
123
166
|
const stateLabel = (action) => action.state === "sending" ? L.sending : action.state === "rejected" ? L.rejected : L.pending;
|
|
167
|
+
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
168
|
return /* @__PURE__ */ jsxs(
|
|
125
169
|
"div",
|
|
126
170
|
{
|
|
@@ -130,8 +174,16 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
|
|
|
130
174
|
onClick: (e) => e.stopPropagation(),
|
|
131
175
|
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
176
|
children: [
|
|
133
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
134
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__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: [
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
"div",
|
|
180
|
+
{
|
|
181
|
+
"aria-hidden": "true",
|
|
182
|
+
className: "pointer-events-none absolute inset-0 opacity-60",
|
|
183
|
+
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%)` }
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-2", children: [
|
|
135
187
|
/* @__PURE__ */ jsx(
|
|
136
188
|
"button",
|
|
137
189
|
{
|
|
@@ -139,44 +191,71 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
|
|
|
139
191
|
type: "button",
|
|
140
192
|
"aria-label": L.back,
|
|
141
193
|
onClick: onBack,
|
|
142
|
-
className: "-ml-
|
|
143
|
-
children: /* @__PURE__ */ jsx("svg", { width: "
|
|
194
|
+
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",
|
|
195
|
+
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
196
|
}
|
|
145
197
|
),
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
198
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
199
|
+
/* @__PURE__ */ jsxs("h2", { className: "m-0 text-xl leading-tight font-black tracking-tight", children: [
|
|
200
|
+
/* @__PURE__ */ jsx("span", { style: { color: INBOX_GREEN }, children: L.saved }),
|
|
201
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "px-1.5 text-white/50", children: "·" }),
|
|
202
|
+
/* @__PURE__ */ jsx("span", { style: { color: OUTBOX_ORANGE }, children: L.waiting })
|
|
203
|
+
] }),
|
|
204
|
+
subtitle && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-white/70", children: subtitle })
|
|
150
205
|
] }),
|
|
151
|
-
onRefresh && /* @__PURE__ */
|
|
206
|
+
onRefresh && /* @__PURE__ */ jsx(
|
|
152
207
|
"button",
|
|
153
208
|
{
|
|
154
209
|
type: "button",
|
|
155
210
|
disabled: downloading,
|
|
156
211
|
onClick: onRefresh,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
L.refresh
|
|
161
|
-
]
|
|
212
|
+
"aria-label": L.refresh,
|
|
213
|
+
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",
|
|
214
|
+
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
215
|
}
|
|
163
216
|
)
|
|
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
217
|
] })
|
|
169
218
|
] }),
|
|
170
|
-
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
|
|
219
|
+
/* @__PURE__ */ jsxs("div", { role: "tablist", className: "relative z-10 -mt-[3.125rem] grid shrink-0 grid-cols-2 px-2.5", children: [
|
|
220
|
+
/* @__PURE__ */ jsx(
|
|
221
|
+
TabCard,
|
|
222
|
+
{
|
|
223
|
+
active: tab === "saved",
|
|
224
|
+
color: INBOX_GREEN,
|
|
225
|
+
label: L.saved,
|
|
226
|
+
value: pct === null ? "–" : `${pct}%`,
|
|
227
|
+
line: downloading ? downloadingLine : L.available,
|
|
228
|
+
progress: pct,
|
|
229
|
+
onClick: () => setTab("saved")
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx(
|
|
233
|
+
TabCard,
|
|
234
|
+
{
|
|
235
|
+
active: tab === "waiting",
|
|
236
|
+
color: OUTBOX_ORANGE,
|
|
237
|
+
up: true,
|
|
238
|
+
label: L.waiting,
|
|
239
|
+
value: String(toSend),
|
|
240
|
+
line: toSend === 0 ? L.allSent : filled(L.toSend, { n: toSend }),
|
|
241
|
+
alert: refused > 0 ? filled(L.rejectedCount, { n: refused }) : void 0,
|
|
242
|
+
onClick: () => setTab("waiting")
|
|
243
|
+
}
|
|
244
|
+
)
|
|
245
|
+
] }),
|
|
246
|
+
tab === "saved" ? /* @__PURE__ */ jsxs("div", { role: "tabpanel", "aria-label": L.saved, className: panel, children: [
|
|
247
|
+
/* @__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: [
|
|
248
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5", children: [
|
|
249
|
+
/* @__PURE__ */ jsx("span", { className: `h-2 w-2 rounded-full ${downloading ? "animate-pulse" : ""}`, style: { background: INBOX_GREEN } }),
|
|
250
|
+
savedLine
|
|
251
|
+
] }),
|
|
173
252
|
inbox.finishedAt && /* @__PURE__ */ jsx("span", { children: filled(L.savedAt, { date: day(inbox.finishedAt), time: clock(inbox.finishedAt) }) })
|
|
174
253
|
] }),
|
|
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-
|
|
177
|
-
/* @__PURE__ */ jsxs("svg", { width: "
|
|
178
|
-
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.
|
|
179
|
-
/* @__PURE__ */ jsx("path", { d: "M10.5 10.5L14 14", stroke: "currentColor", strokeWidth: "1.
|
|
254
|
+
!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 }) }),
|
|
255
|
+
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: [
|
|
256
|
+
/* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 16 16", "aria-hidden": "true", className: "shrink-0 text-slate-400", children: [
|
|
257
|
+
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.8" }),
|
|
258
|
+
/* @__PURE__ */ jsx("path", { d: "M10.5 10.5L14 14", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
|
|
180
259
|
] }),
|
|
181
260
|
/* @__PURE__ */ jsx(
|
|
182
261
|
"input",
|
|
@@ -186,48 +265,53 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
|
|
|
186
265
|
onChange: (e) => setSearch(e.target.value),
|
|
187
266
|
placeholder: L.search,
|
|
188
267
|
"aria-label": L.search,
|
|
189
|
-
className: "min-w-0 flex-1 border-0 bg-transparent text-base text-current outline-none placeholder:text-slate-
|
|
268
|
+
className: "min-w-0 flex-1 border-0 bg-transparent text-base text-current outline-none placeholder:text-slate-400 sm:text-sm"
|
|
190
269
|
}
|
|
191
270
|
)
|
|
192
271
|
] }),
|
|
193
|
-
shown.length > 0 && /* @__PURE__ */ jsx("ul", { className: "m-0 shrink-0 list-none
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
272
|
+
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(SavedRow, { item }, item.key)) }),
|
|
273
|
+
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 }),
|
|
274
|
+
(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: [
|
|
275
|
+
legend.map((tag) => /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1", children: [
|
|
276
|
+
/* @__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 }),
|
|
277
|
+
tag.label
|
|
278
|
+
] }, tag.short)),
|
|
279
|
+
summary.note && /* @__PURE__ */ jsx("span", { className: "basis-full", children: summary.note })
|
|
280
|
+
] })
|
|
281
|
+
] }) : /* @__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: [
|
|
282
|
+
/* @__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" }) }) }) }),
|
|
283
|
+
/* @__PURE__ */ jsx("span", { className: "text-lg font-black tracking-tight", children: L.allSent }),
|
|
284
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[260px] text-xs text-slate-600 dark:text-slate-300", children: L.nothingWaiting })
|
|
285
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
286
|
+
/* @__PURE__ */ jsx("span", { className: "px-1 text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: L.waitingHint }),
|
|
287
|
+
/* @__PURE__ */ jsxs("ol", { className: "relative m-0 flex list-none flex-col gap-2 p-0 pl-5", children: [
|
|
288
|
+
/* @__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" }),
|
|
289
|
+
waiting.map((action) => {
|
|
290
|
+
const description = describe(action);
|
|
291
|
+
const tone = STATE_TONE[action.state] ?? STATE_TONE.pending;
|
|
292
|
+
return /* @__PURE__ */ jsxs("li", { className: "relative", children: [
|
|
293
|
+
/* @__PURE__ */ jsx(
|
|
294
|
+
"span",
|
|
295
|
+
{
|
|
296
|
+
"aria-hidden": "true",
|
|
297
|
+
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" : ""}`,
|
|
298
|
+
style: { background: tone.dot }
|
|
299
|
+
}
|
|
300
|
+
),
|
|
301
|
+
/* @__PURE__ */ jsxs("div", { className: `flex items-start gap-2 rounded-xl bg-white px-3 py-2.5 dark:bg-slate-900 ${CARD_SHADOW}`, children: [
|
|
302
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
303
|
+
/* @__PURE__ */ jsx("span", { className: "text-[13px] font-bold break-words", children: description.title }),
|
|
304
|
+
description.detail && /* @__PURE__ */ jsx("span", { className: "truncate text-[11px] text-slate-600 dark:text-slate-300", children: description.detail }),
|
|
305
|
+
action.state === "rejected" && action.reason && /* @__PURE__ */ jsx("span", { className: "text-[11px] text-red-700 dark:text-red-300", children: action.reason })
|
|
306
|
+
] }),
|
|
307
|
+
/* @__PURE__ */ jsxs("span", { className: "flex shrink-0 flex-col items-end gap-1", children: [
|
|
308
|
+
/* @__PURE__ */ jsx("span", { className: `rounded-full px-2 py-0.5 text-[10px] font-bold whitespace-nowrap ${tone.pill}`, children: stateLabel(action) }),
|
|
309
|
+
action.createdAt && /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-500 tabular-nums dark:text-slate-400", children: clock(action.createdAt) })
|
|
310
|
+
] })
|
|
311
|
+
] })
|
|
312
|
+
] }, action.id);
|
|
313
|
+
})
|
|
314
|
+
] })
|
|
231
315
|
] }) })
|
|
232
316
|
]
|
|
233
317
|
}
|
|
@@ -235,6 +319,9 @@ function OfflineBoxesView({ state, labels: L, subtitle, address, onRefresh, onBa
|
|
|
235
319
|
}
|
|
236
320
|
export {
|
|
237
321
|
DEFAULT_OFFLINE_BOXES_LABELS,
|
|
322
|
+
INBOX_GREEN,
|
|
323
|
+
OUTBOX_ORANGE,
|
|
324
|
+
OfflineArrow,
|
|
238
325
|
OfflineBoxesView as default,
|
|
239
326
|
filled,
|
|
240
327
|
percentOf,
|