@sincpro/web-ui 2.15.0 → 2.16.0
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/README.md +13 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/media/Carousel.d.ts +34 -0
- package/dist/components/media/Carousel.js +148 -0
- package/dist/components/media/Stories.d.ts +71 -0
- package/dist/components/media/Stories.js +174 -0
- package/dist/components/media/index.d.ts +2 -0
- package/dist/components/media/index.js +4 -0
- package/dist/components/media/motion.d.ts +7 -0
- package/dist/components/media/motion.js +17 -0
- package/dist/components/navigation/PortalNav.d.ts +49 -0
- package/dist/components/navigation/PortalNav.js +40 -0
- package/dist/components/navigation/index.d.ts +1 -0
- package/dist/components/navigation/index.js +3 -0
- package/dist/components/preview/FilePreview.d.ts +5 -3
- package/dist/components/preview/FilePreview.js +39 -3
- package/dist/components/preview/index.d.ts +1 -1
- package/dist/components/preview/index.js +1 -1
- package/dist/components/preview/previewKind.d.ts +12 -2
- package/dist/components/preview/previewKind.js +44 -2
- package/dist/components/shell/Notifications.d.ts +64 -0
- package/dist/components/shell/Notifications.js +84 -0
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +3 -0
- package/dist/foundations/copy.es.js +31 -0
- package/dist/foundations/uiCopy.d.ts +53 -0
- package/dist/foundations/uiCopy.js +38 -1
- package/dist/primitives/choice/CheckField.d.ts +26 -0
- package/dist/primitives/choice/CheckField.js +45 -0
- package/dist/primitives/choice/index.d.ts +1 -0
- package/dist/primitives/choice/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { formatFileSize } from "../attachments/files.js";
|
|
4
|
-
import { previewKind, } from "./previewKind.js";
|
|
4
|
+
import { officeKind, previewKind, } from "./previewKind.js";
|
|
5
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
6
6
|
import { Button, ButtonLink } from "../../primitives/button/Button.js";
|
|
7
7
|
import { Empty, Failed, Skeleton } from "../../primitives/notice/Notice.js";
|
|
8
|
-
import { Download } from "lucide-react";
|
|
8
|
+
import { Download, ExternalLink, FileSpreadsheet, FileText, Presentation, } from "lucide-react";
|
|
9
9
|
import { lazy, Suspense, useEffect, useState } from "react";
|
|
10
10
|
/* ==================================================================== *
|
|
11
11
|
* FILE PREVIEW — the file itself, drawn by what it is.
|
|
@@ -22,6 +22,10 @@ import { lazy, Suspense, useEffect, useState } from "react";
|
|
|
22
22
|
* pdf pdf.js, loaded on demand (PdfPreview)
|
|
23
23
|
* markdown streamdown, sanitized (Markdown)
|
|
24
24
|
* text the text in mono, up to a limit (a log can be gigabytes)
|
|
25
|
+
* video the browser's own <video>, its controls, a poster if any
|
|
26
|
+
* audio the browser's own <audio>, its controls
|
|
27
|
+
* office a card with the icon of its family and «Abrir» — Word,
|
|
28
|
+
* Excel and PowerPoint are drawn honestly only by their program
|
|
25
29
|
* other the icon's name and the download — no preview pretended
|
|
26
30
|
*
|
|
27
31
|
* ── The download is always there ────────────────────────────────────
|
|
@@ -36,7 +40,7 @@ const PdfPreview = lazy(() => import("./PdfPreview.js"));
|
|
|
36
40
|
const MarkdownView = lazy(() => import("../../primitives/value/Markdown.js").then((m) => ({ default: m.Markdown })));
|
|
37
41
|
/** A text preview larger than this is not read into the tab: download instead. */
|
|
38
42
|
const MAX_TEXT_BYTES = 1_000_000;
|
|
39
|
-
export { previewKind };
|
|
43
|
+
export { officeKind, previewKind };
|
|
40
44
|
export function FilePreview({ file, pdfWorkerUrl }) {
|
|
41
45
|
const copy = useUiCopy();
|
|
42
46
|
const kind = previewKind(file.name, file.type);
|
|
@@ -52,8 +56,40 @@ function Body({ kind, file, pdfWorkerUrl, }) {
|
|
|
52
56
|
}
|
|
53
57
|
if (kind === "markdown" || kind === "text")
|
|
54
58
|
return _jsx(TextPreview, { kind: kind, file: file });
|
|
59
|
+
if (kind === "video")
|
|
60
|
+
return _jsx(VideoPreview, { file: file });
|
|
61
|
+
if (kind === "audio")
|
|
62
|
+
return _jsx(AudioPreview, { file: file });
|
|
63
|
+
if (kind === "office")
|
|
64
|
+
return _jsx(OfficeCard, { file: file });
|
|
55
65
|
return _jsx(Unsupported, {});
|
|
56
66
|
}
|
|
67
|
+
/* The browser's own players: their controls are keyboard- and screen-reader-ready in every
|
|
68
|
+
engine, and a hand-made bar would be one more thing to get wrong. `preload="metadata"`: the
|
|
69
|
+
length and the first frame, not the whole file, until the person presses play. */
|
|
70
|
+
function VideoPreview({ file }) {
|
|
71
|
+
const copy = useUiCopy();
|
|
72
|
+
return (_jsx("video", { "data-ui": "file-preview.video", src: file.url, poster: file.poster, controls: true, playsInline: true, preload: "metadata", "aria-label": file.name, className: "max-h-full max-w-full rounded-control bg-scrim/95", children: copy.preview.unsupported }));
|
|
73
|
+
}
|
|
74
|
+
function AudioPreview({ file }) {
|
|
75
|
+
const copy = useUiCopy();
|
|
76
|
+
return (_jsx("div", { className: "flex w-full max-w-(--container-prose) items-center self-center", children: _jsx("audio", { "data-ui": "file-preview.audio", src: file.url, controls: true, preload: "metadata", "aria-label": file.name, className: "w-full", children: copy.preview.unsupported }) }));
|
|
77
|
+
}
|
|
78
|
+
const OFFICE_ICON = {
|
|
79
|
+
doc: FileText,
|
|
80
|
+
sheet: FileSpreadsheet,
|
|
81
|
+
slides: Presentation,
|
|
82
|
+
};
|
|
83
|
+
/* An Office file has no honest drawing in a browser: a converted copy loses its formulas,
|
|
84
|
+
its page breaks, its fonts. The card says WHICH program it is for — an icon and a word,
|
|
85
|
+
never only a colour — and opens it in a tab of its own, where the browser hands it to its
|
|
86
|
+
program or keeps it; the download stays in the header, once. */
|
|
87
|
+
function OfficeCard({ file }) {
|
|
88
|
+
const copy = useUiCopy();
|
|
89
|
+
const family = officeKind(file.name, file.type) ?? "doc";
|
|
90
|
+
const Icon = OFFICE_ICON[family];
|
|
91
|
+
return (_jsxs("div", { "data-ui": "file-preview.office", "data-kind": family, className: "flex max-w-(--container-short) flex-col items-center gap-3 self-center text-center", children: [_jsx("span", { className: "flex size-16 items-center justify-center rounded-ui-card bg-surface text-primary shadow-raised", children: _jsx(Icon, { "aria-hidden": true, className: "size-8", strokeWidth: 1.5 }) }), _jsx("p", { className: "text-body font-medium text-ink", children: copy.preview.office[family] }), _jsx("p", { className: "text-meta text-muted", children: copy.preview.officeSentence }), _jsx(ButtonLink, { href: file.url, target: "_blank", rel: "noopener noreferrer", role: "secondary", size: "sm", icon: ExternalLink, children: copy.preview.open })] }));
|
|
92
|
+
}
|
|
57
93
|
function ImagePreview({ file }) {
|
|
58
94
|
const copy = useUiCopy();
|
|
59
95
|
const [actual, setActual] = useState(false);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { FilePreview, type FilePreviewProps, type PreviewFile, } from "./FilePreview.js";
|
|
2
|
-
export { type PreviewKind, previewKind, } from "./previewKind.js";
|
|
2
|
+
export { type OfficeKind, officeKind, type PreviewKind, previewKind, } from "./previewKind.js";
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/** The three Office families a preview names apart — the icon and the word say which. */
|
|
2
|
+
export type OfficeKind = "doc" | "sheet" | "slides";
|
|
3
|
+
/**
|
|
4
|
+
* The renderer for a file. Pure, so the choice is tested without a browser.
|
|
5
|
+
*
|
|
6
|
+
* Context: `video` and `audio` are the browser's own players (`<video>`, `<audio>`, their
|
|
7
|
+
* controls), and `office` is a document only its program draws honestly — a card that says
|
|
8
|
+
* which one it is and opens or downloads it. A CSV stays `text`: it is read, not opened.
|
|
9
|
+
*/
|
|
10
|
+
export type PreviewKind = "image" | "pdf" | "markdown" | "text" | "video" | "audio" | "office" | "other";
|
|
11
|
+
/** Which Office family a file is — `undefined` when it is none. */
|
|
12
|
+
export declare function officeKind(name: string, type?: string): OfficeKind | undefined;
|
|
3
13
|
export declare function previewKind(name: string, type?: string): PreviewKind;
|
|
@@ -3,15 +3,57 @@ import { attachmentKind, fileExtension } from "../attachments/files.js";
|
|
|
3
3
|
viewer to do it): a server component that decides how a file will be shown reads this. */
|
|
4
4
|
const TEXT_EXTENSIONS = new Set(["txt", "csv", "json", "log", "xml", "yaml", "yml"]);
|
|
5
5
|
const MARKDOWN_EXTENSIONS = new Set(["md", "markdown"]);
|
|
6
|
-
|
|
6
|
+
/* What a browser plays with its own element. `ogg` is audio unless the server says video. */
|
|
7
|
+
const VIDEO_EXTENSIONS = new Set(["mp4", "m4v", "webm", "ogv", "mov"]);
|
|
8
|
+
const AUDIO_EXTENSIONS = new Set(["mp3", "m4a", "aac", "wav", "oga", "ogg", "opus", "flac"]);
|
|
9
|
+
const OFFICE_EXTENSIONS = {
|
|
10
|
+
doc: "doc",
|
|
11
|
+
docx: "doc",
|
|
12
|
+
odt: "doc",
|
|
13
|
+
rtf: "doc",
|
|
14
|
+
xls: "sheet",
|
|
15
|
+
xlsx: "sheet",
|
|
16
|
+
xlsm: "sheet",
|
|
17
|
+
ods: "sheet",
|
|
18
|
+
ppt: "slides",
|
|
19
|
+
pptx: "slides",
|
|
20
|
+
pps: "slides",
|
|
21
|
+
ppsx: "slides",
|
|
22
|
+
odp: "slides",
|
|
23
|
+
};
|
|
24
|
+
/** Which Office family a file is — `undefined` when it is none. */
|
|
25
|
+
export function officeKind(name, type) {
|
|
26
|
+
const mime = (type ?? "").toLowerCase();
|
|
27
|
+
if (mime.includes("presentation") || mime.includes("ms-powerpoint"))
|
|
28
|
+
return "slides";
|
|
29
|
+
if (mime.includes("spreadsheet") || mime.includes("ms-excel"))
|
|
30
|
+
return "sheet";
|
|
31
|
+
if (mime.includes("wordprocessing") ||
|
|
32
|
+
mime.includes("msword") ||
|
|
33
|
+
mime.includes("opendocument.text")) {
|
|
34
|
+
return "doc";
|
|
35
|
+
}
|
|
36
|
+
return OFFICE_EXTENSIONS[fileExtension(name)];
|
|
37
|
+
}
|
|
7
38
|
export function previewKind(name, type) {
|
|
8
39
|
const kind = attachmentKind(name, type);
|
|
9
40
|
if (kind === "image" || kind === "pdf")
|
|
10
41
|
return kind;
|
|
42
|
+
const mime = (type ?? "").toLowerCase();
|
|
11
43
|
const extension = fileExtension(name).toLowerCase();
|
|
44
|
+
if (mime.startsWith("video/"))
|
|
45
|
+
return "video";
|
|
46
|
+
if (mime.startsWith("audio/"))
|
|
47
|
+
return "audio";
|
|
12
48
|
if (MARKDOWN_EXTENSIONS.has(extension))
|
|
13
49
|
return "markdown";
|
|
14
|
-
if (TEXT_EXTENSIONS.has(extension) ||
|
|
50
|
+
if (TEXT_EXTENSIONS.has(extension) || mime.startsWith("text/"))
|
|
15
51
|
return "text";
|
|
52
|
+
if (VIDEO_EXTENSIONS.has(extension))
|
|
53
|
+
return "video";
|
|
54
|
+
if (AUDIO_EXTENSIONS.has(extension))
|
|
55
|
+
return "audio";
|
|
56
|
+
if (officeKind(name, type) !== undefined)
|
|
57
|
+
return "office";
|
|
16
58
|
return "other";
|
|
17
59
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { InboxItem } from "./Inbox.js";
|
|
2
|
+
import { type LucideIcon } from "lucide-react";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
/** A notification: an `InboxItem`, with who it is from and one thing to do about it. */
|
|
5
|
+
export type NotificationItem = InboxItem & {
|
|
6
|
+
/** Who did it — a person's face reads faster than an icon. Wins over `icon`. */
|
|
7
|
+
avatar?: {
|
|
8
|
+
name: string;
|
|
9
|
+
src?: string;
|
|
10
|
+
};
|
|
11
|
+
/** One action of its own: «Responder», «Ver el pago». */
|
|
12
|
+
action?: {
|
|
13
|
+
label: string;
|
|
14
|
+
onPress: () => void;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type NotificationBellProps = {
|
|
18
|
+
unread?: number;
|
|
19
|
+
/** «Notificaciones» by default. */
|
|
20
|
+
label?: string;
|
|
21
|
+
icon?: LucideIcon;
|
|
22
|
+
/** Without a panel it is a plain button (a link to the notifications page, say). */
|
|
23
|
+
onPress?: () => void;
|
|
24
|
+
/** The panel it opens in a popover. A function gets `close`, for an item that navigates. */
|
|
25
|
+
children?: ReactNode | ((close: () => void) => ReactNode);
|
|
26
|
+
/** Opened, when the application holds it. */
|
|
27
|
+
open?: boolean;
|
|
28
|
+
onOpenChange?: (open: boolean) => void;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The bell with the unread count, for any header — a public site's, a portal's, not only the
|
|
32
|
+
* ERP's dark bar (that one is `Inbox`).
|
|
33
|
+
*
|
|
34
|
+
* Context: zero is not drawn, past 99 it says «99+», and the number is in the button's name
|
|
35
|
+
* (the badge is only seen), the way `SystrayButton` does it; this one is drawn on the paper's
|
|
36
|
+
* ink, so it sits in a white header.
|
|
37
|
+
*/
|
|
38
|
+
export declare function NotificationBell({ unread, label, icon: Icon, onPress, children, open: openProp, onOpenChange, }: NotificationBellProps): import("react").JSX.Element;
|
|
39
|
+
export type NotificationPanelProps = {
|
|
40
|
+
/** Newest first, as the application sorts them. */
|
|
41
|
+
items: readonly NotificationItem[];
|
|
42
|
+
/** Pressing one: the application opens what it is about. */
|
|
43
|
+
onOpen?: (id: string) => void;
|
|
44
|
+
/** An unread one was opened: the application marks it read. */
|
|
45
|
+
onRead?: (id: string) => void;
|
|
46
|
+
/** «Marcar todo como leído» — drawn while something is unread. */
|
|
47
|
+
onReadAll?: () => void;
|
|
48
|
+
/** «Ver más» — the next page, or the whole history. */
|
|
49
|
+
onMore?: () => void;
|
|
50
|
+
/** «Notificaciones» by default. */
|
|
51
|
+
title?: string;
|
|
52
|
+
/** The clock «Hoy» and the times are read against; now by default. */
|
|
53
|
+
now?: Date;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The notification centre: grouped by «Hoy» and «Antes», a face or an icon, the unread dot,
|
|
57
|
+
* one action per item, «Marcar todo como leído», «Ver más» and the empty state.
|
|
58
|
+
*
|
|
59
|
+
* Context: controlled — it fetches nothing; the application passes the page it has and is
|
|
60
|
+
* told what was opened, read or asked for. Unread is not only a colour: the dot goes with the
|
|
61
|
+
* title in bold and the word said (as `InboxList`). An item's action is a button BESIDE the
|
|
62
|
+
* item, never inside it: one press, one meaning.
|
|
63
|
+
*/
|
|
64
|
+
export declare function NotificationPanel({ items, onOpen, onRead, onReadAll, onMore, title, now, }: NotificationPanelProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { SurfaceProvider } from "../../foundations/surface.js";
|
|
5
|
+
import { Button } from "../../primitives/button/Button.js";
|
|
6
|
+
import { Empty } from "../../primitives/notice/Notice.js";
|
|
7
|
+
import { NOTICE_ICON } from "../../primitives/notice/tones.js";
|
|
8
|
+
import { Popover } from "../../primitives/overlay/Popover.js";
|
|
9
|
+
import { Count, countText } from "../../primitives/tag/Count.js";
|
|
10
|
+
import { Avatar } from "../../primitives/value/Avatar.js";
|
|
11
|
+
import { formatRelative } from "../../primitives/value/format.js";
|
|
12
|
+
import { Bell } from "lucide-react";
|
|
13
|
+
import { useMemo, useState } from "react";
|
|
14
|
+
import { Dialog, DialogTrigger, Heading, Pressable } from "react-aria-components";
|
|
15
|
+
/* A badge over an icon is read in a glance: past two digits it says «a lot» (as the systray). */
|
|
16
|
+
const BELL_MAX = 99;
|
|
17
|
+
/**
|
|
18
|
+
* The bell with the unread count, for any header — a public site's, a portal's, not only the
|
|
19
|
+
* ERP's dark bar (that one is `Inbox`).
|
|
20
|
+
*
|
|
21
|
+
* Context: zero is not drawn, past 99 it says «99+», and the number is in the button's name
|
|
22
|
+
* (the badge is only seen), the way `SystrayButton` does it; this one is drawn on the paper's
|
|
23
|
+
* ink, so it sits in a white header.
|
|
24
|
+
*/
|
|
25
|
+
export function NotificationBell({ unread = 0, label, icon: Icon = Bell, onPress, children, open: openProp, onOpenChange, }) {
|
|
26
|
+
const copy = useUiCopy();
|
|
27
|
+
const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
|
|
28
|
+
const [own, setOwn] = useState(false);
|
|
29
|
+
const open = openProp ?? own;
|
|
30
|
+
const setOpen = (next) => {
|
|
31
|
+
if (openProp === undefined)
|
|
32
|
+
setOwn(next);
|
|
33
|
+
onOpenChange?.(next);
|
|
34
|
+
};
|
|
35
|
+
const name = label ?? copy.inbox.label;
|
|
36
|
+
const said = countText(unread, number.format, BELL_MAX);
|
|
37
|
+
const button = (_jsxs("button", { type: "button", "data-ui": "notification-bell", onClick: children === undefined ? onPress : undefined, "aria-label": unread > 0 ? `${name}: ${said}` : name, title: name, className: `relative inline-flex size-(--size-control-md) items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/6 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${open ? "bg-ink/6 text-ink" : ""}`, ...(children === undefined
|
|
38
|
+
? {}
|
|
39
|
+
: { "aria-haspopup": "dialog", "aria-expanded": open }), children: [_jsx(Icon, { "aria-hidden": true, className: "size-(--size-icon-md)", strokeWidth: 2 }), unread <= 0 ? null : (_jsx("span", { className: "absolute -top-0.5 -right-0.5 flex", children: _jsx(Count, { value: unread, tone: "bad", solid: true, max: BELL_MAX, "aria-hidden": true }) }))] }));
|
|
40
|
+
if (children === undefined)
|
|
41
|
+
return button;
|
|
42
|
+
return (_jsxs(DialogTrigger, { isOpen: open, onOpenChange: setOpen, children: [_jsx(Pressable, { children: button }), _jsx(Popover, { placement: "bottom end", children: _jsx(Dialog, { "aria-label": name, className: "max-h-[inherit] w-(--container-inbox) overflow-auto outline-0", children: _jsx(SurfaceProvider, { value: "canvas", children: typeof children === "function" ? children(() => setOpen(false)) : children }) }) })] }));
|
|
43
|
+
}
|
|
44
|
+
const ICON_TONE = {
|
|
45
|
+
info: "text-info",
|
|
46
|
+
good: "text-good",
|
|
47
|
+
warn: "text-warn",
|
|
48
|
+
bad: "text-bad",
|
|
49
|
+
};
|
|
50
|
+
function sameDay(a, b) {
|
|
51
|
+
return (a.getFullYear() === b.getFullYear() &&
|
|
52
|
+
a.getMonth() === b.getMonth() &&
|
|
53
|
+
a.getDate() === b.getDate());
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The notification centre: grouped by «Hoy» and «Antes», a face or an icon, the unread dot,
|
|
57
|
+
* one action per item, «Marcar todo como leído», «Ver más» and the empty state.
|
|
58
|
+
*
|
|
59
|
+
* Context: controlled — it fetches nothing; the application passes the page it has and is
|
|
60
|
+
* told what was opened, read or asked for. Unread is not only a colour: the dot goes with the
|
|
61
|
+
* title in bold and the word said (as `InboxList`). An item's action is a button BESIDE the
|
|
62
|
+
* item, never inside it: one press, one meaning.
|
|
63
|
+
*/
|
|
64
|
+
export function NotificationPanel({ items, onOpen, onRead, onReadAll, onMore, title, now, }) {
|
|
65
|
+
const copy = useUiCopy();
|
|
66
|
+
const clock = now ?? new Date();
|
|
67
|
+
const unread = items.filter((item) => item.unread === true).length;
|
|
68
|
+
const today = items.filter((item) => sameDay(new Date(item.when), clock));
|
|
69
|
+
const before = items.filter((item) => !sameDay(new Date(item.when), clock));
|
|
70
|
+
const groups = [
|
|
71
|
+
{ key: "today", label: copy.notifications.today, items: today },
|
|
72
|
+
{ key: "before", label: copy.notifications.before, items: before },
|
|
73
|
+
].filter((group) => group.items.length > 0);
|
|
74
|
+
const row = (item) => {
|
|
75
|
+
const fresh = item.unread === true;
|
|
76
|
+
const Icon = item.icon ?? (item.tone === undefined ? undefined : NOTICE_ICON[item.tone]);
|
|
77
|
+
return (_jsxs("li", { className: `flex items-start ${fresh ? "bg-primary/4" : ""}`, children: [_jsxs("button", { type: "button", "data-ui": "notification-panel.item", "data-unread": fresh ? "" : undefined, onClick: () => {
|
|
78
|
+
if (fresh)
|
|
79
|
+
onRead?.(item.id);
|
|
80
|
+
onOpen?.(item.id);
|
|
81
|
+
}, className: "flex min-w-0 flex-1 items-start gap-3 px-3 py-2.5 text-left transition-colors duration-(--duration-instant) hover:bg-ink/4 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary", children: [item.avatar !== undefined ? (_jsx(Avatar, { name: item.avatar.name, size: "lg", ...(item.avatar.src === undefined ? {} : { src: item.avatar.src }) })) : Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, strokeWidth: 2, className: `mt-0.5 size-(--size-icon-md) shrink-0 ${item.tone === undefined ? "text-muted" : ICON_TONE[item.tone]}` })), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsxs("span", { className: `text-meta text-ink ${fresh ? "font-semibold" : "font-normal"}`, children: [fresh ? _jsxs("span", { className: "sr-only", children: [copy.inbox.unread, ": "] }) : null, item.title] }), item.detail === undefined ? null : (_jsx("span", { className: "line-clamp-2 text-meta text-muted", children: item.detail })), _jsx("span", { className: "text-micro text-muted tabular-nums", children: formatRelative(new Date(item.when), now, copy) })] }), fresh ? (_jsx("span", { "aria-hidden": true, className: "mt-1.5 size-2 shrink-0 rounded-pill bg-primary" })) : null] }), item.action === undefined ? null : (_jsx("span", { className: "shrink-0 py-2 pr-2", children: _jsx(Button, { role: "secondary", size: "sm", onClick: item.action.onPress, children: item.action.label }) }))] }, item.id));
|
|
82
|
+
};
|
|
83
|
+
return (_jsxs("div", { "data-ui": "notification-panel", className: "flex min-w-0 flex-col", children: [_jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-line px-3 py-2", children: [_jsxs(Heading, { level: 2, className: "text-meta font-semibold text-ink", children: [title ?? copy.inbox.label, unread === 0 ? null : (_jsx("span", { className: "ml-1.5 font-normal text-muted tabular-nums", children: fillCopy(copy.inbox.unreadCount, { count: unread }) }))] }), onReadAll === undefined || unread === 0 ? null : (_jsx(Button, { role: "ghost", size: "sm", onClick: onReadAll, children: copy.inbox.markAllRead }))] }), items.length === 0 ? (_jsx(Empty, { sentence: copy.inbox.empty })) : (groups.map((group) => (_jsxs("section", { "aria-label": group.label, "data-ui": "notification-panel.group", children: [_jsx("h3", { className: "px-3 pt-3 pb-1 text-micro font-semibold text-muted uppercase", children: group.label }), _jsx("ul", { className: "flex flex-col divide-y divide-line", children: group.items.map(row) })] }, group.key)))), onMore === undefined || items.length === 0 ? null : (_jsx("div", { className: "border-t border-line px-1 py-1", children: _jsx(Button, { role: "ghost", size: "sm", onClick: onMore, children: copy.notifications.more }) }))] }));
|
|
84
|
+
}
|
|
@@ -5,5 +5,6 @@ export { SearchEntry, type SearchEntryProps, } from "./SearchEntry.js";
|
|
|
5
5
|
export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
6
6
|
export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
|
|
7
7
|
export { Inbox, type InboxItem, InboxList, type InboxListProps, type InboxProps, } from "./Inbox.js";
|
|
8
|
+
export { NotificationBell, type NotificationBellProps, type NotificationItem, NotificationPanel, type NotificationPanelProps, } from "./Notifications.js";
|
|
8
9
|
export { KioskFrame, type KioskFrameProps, } from "./KioskFrame.js";
|
|
9
10
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -13,6 +13,9 @@ export { SystrayButton, TopBar, } from "./TopBar.js";
|
|
|
13
13
|
/* The notifications: a bell with how many are unread and the list in a popover — or the list
|
|
14
14
|
alone, as a portal's page. */
|
|
15
15
|
export { Inbox, InboxList, } from "./Inbox.js";
|
|
16
|
+
/* The notification centre for any header: the bell with its count, and the panel grouped by
|
|
17
|
+
«Hoy» / «Anteriores» with an action per item. Controlled — it fetches nothing. */
|
|
18
|
+
export { NotificationBell, NotificationPanel, } from "./Notifications.js";
|
|
16
19
|
/* A screen of N sets side by side — the reconciliation: each pane scrolls on its own. */
|
|
17
20
|
export { KioskFrame, } from "./KioskFrame.js";
|
|
18
21
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -636,6 +636,31 @@ export const SPANISH_COPY = {
|
|
|
636
636
|
close: "Cerrar",
|
|
637
637
|
empty: "Todavía no hay imágenes",
|
|
638
638
|
},
|
|
639
|
+
carousel: {
|
|
640
|
+
roledescription: "carrusel",
|
|
641
|
+
slide: "diapositiva",
|
|
642
|
+
position: "{index} de {total}",
|
|
643
|
+
previous: "Diapositiva anterior",
|
|
644
|
+
next: "Diapositiva siguiente",
|
|
645
|
+
goTo: "Ir a la diapositiva {index}",
|
|
646
|
+
pause: "Pausar",
|
|
647
|
+
play: "Reproducir",
|
|
648
|
+
},
|
|
649
|
+
stories: {
|
|
650
|
+
label: "Historias",
|
|
651
|
+
open: "Historias de {name}",
|
|
652
|
+
seen: "vistas",
|
|
653
|
+
unseen: "nuevas",
|
|
654
|
+
viewer: "Historias de {name}",
|
|
655
|
+
position: "{index} de {total}",
|
|
656
|
+
previous: "Anterior",
|
|
657
|
+
next: "Siguiente",
|
|
658
|
+
pause: "Pausar",
|
|
659
|
+
play: "Reproducir",
|
|
660
|
+
close: "Cerrar",
|
|
661
|
+
},
|
|
662
|
+
notifications: { today: "Hoy", before: "Anteriores", more: "Ver más" },
|
|
663
|
+
portalNav: { label: "Mi portal" },
|
|
639
664
|
inbox: {
|
|
640
665
|
label: "Notificaciones",
|
|
641
666
|
unread: "Sin leer",
|
|
@@ -756,8 +781,14 @@ export const SPANISH_COPY = {
|
|
|
756
781
|
pdf: "PDF",
|
|
757
782
|
text: "Texto",
|
|
758
783
|
markdown: "Documento",
|
|
784
|
+
video: "Video",
|
|
785
|
+
audio: "Audio",
|
|
786
|
+
office: "Documento de Office",
|
|
759
787
|
other: "Archivo",
|
|
760
788
|
},
|
|
789
|
+
office: { doc: "Documento de Word", sheet: "Hoja de cálculo", slides: "Presentación" },
|
|
790
|
+
officeSentence: "Se ve mejor en su programa. Abrilo o descargalo.",
|
|
791
|
+
open: "Abrir",
|
|
761
792
|
},
|
|
762
793
|
chat: {
|
|
763
794
|
thread: "Conversación",
|
|
@@ -948,6 +948,46 @@ export type UiCopy = {
|
|
|
948
948
|
empty: string;
|
|
949
949
|
};
|
|
950
950
|
/** The notifications (`Inbox`, `InboxList`). */
|
|
951
|
+
/** Slides that turn (`Carousel`). */
|
|
952
|
+
carousel: {
|
|
953
|
+
roledescription: string;
|
|
954
|
+
slide: string;
|
|
955
|
+
/** `{index}` of `{total}`. */
|
|
956
|
+
position: string;
|
|
957
|
+
previous: string;
|
|
958
|
+
next: string;
|
|
959
|
+
/** `{index}`: the dot that goes there. */
|
|
960
|
+
goTo: string;
|
|
961
|
+
pause: string;
|
|
962
|
+
play: string;
|
|
963
|
+
};
|
|
964
|
+
/** A person's stories (`StoryBar`, `StoryViewer`). */
|
|
965
|
+
stories: {
|
|
966
|
+
label: string;
|
|
967
|
+
/** `{name}`: the ring that opens them. */
|
|
968
|
+
open: string;
|
|
969
|
+
seen: string;
|
|
970
|
+
unseen: string;
|
|
971
|
+
/** `{name}`: the viewer's name. */
|
|
972
|
+
viewer: string;
|
|
973
|
+
/** `{index}` of `{total}`. */
|
|
974
|
+
position: string;
|
|
975
|
+
previous: string;
|
|
976
|
+
next: string;
|
|
977
|
+
pause: string;
|
|
978
|
+
play: string;
|
|
979
|
+
close: string;
|
|
980
|
+
};
|
|
981
|
+
/** The notification centre (`NotificationPanel`); the rest of its words are `inbox`'s. */
|
|
982
|
+
notifications: {
|
|
983
|
+
today: string;
|
|
984
|
+
before: string;
|
|
985
|
+
more: string;
|
|
986
|
+
};
|
|
987
|
+
/** A portal's side menu (`PortalNav`). */
|
|
988
|
+
portalNav: {
|
|
989
|
+
label: string;
|
|
990
|
+
};
|
|
951
991
|
inbox: {
|
|
952
992
|
label: string;
|
|
953
993
|
unread: string;
|
|
@@ -1132,8 +1172,21 @@ export type UiCopy = {
|
|
|
1132
1172
|
pdf: string;
|
|
1133
1173
|
text: string;
|
|
1134
1174
|
markdown: string;
|
|
1175
|
+
video: string;
|
|
1176
|
+
audio: string;
|
|
1177
|
+
office: string;
|
|
1135
1178
|
other: string;
|
|
1136
1179
|
};
|
|
1180
|
+
/** The Office card's heading, one per family: the word says which program. */
|
|
1181
|
+
office: {
|
|
1182
|
+
doc: string;
|
|
1183
|
+
sheet: string;
|
|
1184
|
+
slides: string;
|
|
1185
|
+
};
|
|
1186
|
+
/** Under it: why there is no drawing, and what to do. */
|
|
1187
|
+
officeSentence: string;
|
|
1188
|
+
/** Opens the file in a tab of its own. */
|
|
1189
|
+
open: string;
|
|
1137
1190
|
};
|
|
1138
1191
|
/** A conversation: the thread of messages and the composer under it. */
|
|
1139
1192
|
chat: {
|
|
@@ -621,6 +621,31 @@ export const ENGLISH_COPY = {
|
|
|
621
621
|
close: "Close",
|
|
622
622
|
empty: "No images yet",
|
|
623
623
|
},
|
|
624
|
+
carousel: {
|
|
625
|
+
roledescription: "carousel",
|
|
626
|
+
slide: "slide",
|
|
627
|
+
position: "{index} of {total}",
|
|
628
|
+
previous: "Previous slide",
|
|
629
|
+
next: "Next slide",
|
|
630
|
+
goTo: "Go to slide {index}",
|
|
631
|
+
pause: "Pause",
|
|
632
|
+
play: "Play",
|
|
633
|
+
},
|
|
634
|
+
stories: {
|
|
635
|
+
label: "Stories",
|
|
636
|
+
open: "Stories of {name}",
|
|
637
|
+
seen: "seen",
|
|
638
|
+
unseen: "new",
|
|
639
|
+
viewer: "Stories of {name}",
|
|
640
|
+
position: "{index} of {total}",
|
|
641
|
+
previous: "Previous",
|
|
642
|
+
next: "Next",
|
|
643
|
+
pause: "Pause",
|
|
644
|
+
play: "Play",
|
|
645
|
+
close: "Close",
|
|
646
|
+
},
|
|
647
|
+
notifications: { today: "Today", before: "Earlier", more: "See more" },
|
|
648
|
+
portalNav: { label: "My portal" },
|
|
624
649
|
inbox: {
|
|
625
650
|
label: "Notifications",
|
|
626
651
|
unread: "Unread",
|
|
@@ -741,7 +766,19 @@ export const ENGLISH_COPY = {
|
|
|
741
766
|
nextPage: "Next page",
|
|
742
767
|
fit: "Fit",
|
|
743
768
|
actualSize: "Actual size",
|
|
744
|
-
kind: {
|
|
769
|
+
kind: {
|
|
770
|
+
image: "Image",
|
|
771
|
+
pdf: "PDF",
|
|
772
|
+
text: "Text",
|
|
773
|
+
markdown: "Document",
|
|
774
|
+
video: "Video",
|
|
775
|
+
audio: "Audio",
|
|
776
|
+
office: "Office document",
|
|
777
|
+
other: "File",
|
|
778
|
+
},
|
|
779
|
+
office: { doc: "Word document", sheet: "Spreadsheet", slides: "Presentation" },
|
|
780
|
+
officeSentence: "Its program draws it best. Open it or download it.",
|
|
781
|
+
open: "Open",
|
|
745
782
|
},
|
|
746
783
|
chat: {
|
|
747
784
|
thread: "Conversation",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type FormMode } from "../../foundations/form.js";
|
|
2
|
+
export type CheckFieldProps = {
|
|
3
|
+
/** The sentence that IS its name: «Recibir el boletín por correo». */
|
|
4
|
+
label: string;
|
|
5
|
+
/** A line under it: what saying yes does. */
|
|
6
|
+
hint?: string;
|
|
7
|
+
checked: boolean;
|
|
8
|
+
onChange?: (next: boolean) => void;
|
|
9
|
+
/** A box (the default) or a switch. In the «settings» style it is always a switch: a
|
|
10
|
+
* settings row turns something on, it does not tick an item of a list. */
|
|
11
|
+
control?: "checkbox" | "switch";
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Forces the mode; by default the form's (read mode draws the answer). */
|
|
14
|
+
mode?: FormMode;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A yes/no whose sentence is its own name, as a row of a form.
|
|
18
|
+
*
|
|
19
|
+
* Context: a `Checkbox` inside a `Field` says its name twice («Boletín · Recibir el
|
|
20
|
+
* boletín») and, in `FormSection columns`, sits under an empty label — the box at the height
|
|
21
|
+
* of the neighbours' LABELS, not of their controls. This row keeps a label's height empty
|
|
22
|
+
* above it (stacked), or the label column empty beside it (horizontal), so the box lines up
|
|
23
|
+
* with the inputs next to it. In the «settings» style it is that style's row: the sentence
|
|
24
|
+
* and its help on the left, the switch on the right, named by the sentence.
|
|
25
|
+
*/
|
|
26
|
+
export declare function CheckField({ label, hint, checked, onChange, control, disabled, mode, }: CheckFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { byDensity, useDensity } from "../../foundations/density.js";
|
|
4
|
+
import { FieldIdsContext, useFormStyle, } from "../../foundations/form.js";
|
|
5
|
+
import { Switch } from "./Switch.js";
|
|
6
|
+
import { Checkbox } from "../field/Checks.js";
|
|
7
|
+
import { useSheetLayout } from "../field/layout.js";
|
|
8
|
+
import { useId } from "react";
|
|
9
|
+
/**
|
|
10
|
+
* A yes/no whose sentence is its own name, as a row of a form.
|
|
11
|
+
*
|
|
12
|
+
* Context: a `Checkbox` inside a `Field` says its name twice («Boletín · Recibir el
|
|
13
|
+
* boletín») and, in `FormSection columns`, sits under an empty label — the box at the height
|
|
14
|
+
* of the neighbours' LABELS, not of their controls. This row keeps a label's height empty
|
|
15
|
+
* above it (stacked), or the label column empty beside it (horizontal), so the box lines up
|
|
16
|
+
* with the inputs next to it. In the «settings» style it is that style's row: the sentence
|
|
17
|
+
* and its help on the left, the switch on the right, named by the sentence.
|
|
18
|
+
*/
|
|
19
|
+
export function CheckField({ label, hint, checked, onChange, control = "checkbox", disabled = false, mode, }) {
|
|
20
|
+
const d = useDensity();
|
|
21
|
+
const settings = useFormStyle() === "settings";
|
|
22
|
+
const horizontal = useSheetLayout() === "horizontal";
|
|
23
|
+
const id = useId();
|
|
24
|
+
const hintId = hint === undefined ? undefined : `${id}-hint`;
|
|
25
|
+
const hintNode = hint === undefined ? null : (_jsx("p", { id: hintId, className: "max-w-prose text-micro text-muted", children: hint }));
|
|
26
|
+
if (settings) {
|
|
27
|
+
/* The sentence names the switch the way a field's label does: through the field ids. */
|
|
28
|
+
const ids = {
|
|
29
|
+
id,
|
|
30
|
+
labelId: `${id}-label`,
|
|
31
|
+
label,
|
|
32
|
+
describedBy: hintId,
|
|
33
|
+
invalid: false,
|
|
34
|
+
};
|
|
35
|
+
return (_jsxs("div", { "data-ui": "check-field", "data-style": "settings", className: "flex min-w-0 items-start justify-between gap-6", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsx("label", { id: ids.labelId, htmlFor: id, className: "text-meta font-medium text-ink", children: label }), hintNode] }), _jsx(FieldIdsContext.Provider, { value: ids, children: _jsx("span", { className: "shrink-0", children: _jsx(Switch, { checked: checked, onChange: onChange, disabled: disabled, ...(mode === undefined ? {} : { mode }) }) }) })] }));
|
|
36
|
+
}
|
|
37
|
+
const answer = control === "switch" ? (_jsx(Switch, { checked: checked, onChange: onChange, disabled: disabled, describedBy: hintId, ...(mode === undefined ? {} : { mode }), children: label })) : (_jsx(Checkbox, { checked: checked, onChange: onChange, label: label, disabled: disabled, describedBy: hintId, ...(mode === undefined ? {} : { mode }) }));
|
|
38
|
+
/* Its own context: inside a `Field` by mistake it would be named twice. */
|
|
39
|
+
const row = (_jsxs(FieldIdsContext.Provider, { value: null, children: [_jsx("div", { className: "flex min-h-(--size-control-md) items-center", children: answer }), hintNode] }));
|
|
40
|
+
if (horizontal) {
|
|
41
|
+
return (_jsxs("div", { "data-ui": "check-field", className: "grid-label grid min-w-0 items-start gap-x-4", children: [_jsx("span", { "aria-hidden": true }), _jsx("div", { className: "flex min-w-0 flex-col gap-1", children: row })] }));
|
|
42
|
+
}
|
|
43
|
+
/* The empty line is a label's, in its type: the box starts where the neighbours' inputs do. */
|
|
44
|
+
return (_jsxs("div", { "data-ui": "check-field", className: `flex min-w-0 flex-col ${byDensity(d, "gap-1", "gap-0.5")}`, children: [_jsx("span", { "aria-hidden": true, className: "text-micro select-none", children: " " }), _jsx("div", { className: "flex min-w-0 flex-col gap-1", children: row })] }));
|
|
45
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { CheckField, type CheckFieldProps, } from "./CheckField.js";
|
|
1
2
|
export { ComboBox, type ComboBoxProps } from "./ComboBox.js";
|
|
2
3
|
export { KanbanState, type KanbanStateValue, } from "./KanbanState.js";
|
|
3
4
|
export { type ChoiceOption, type SegmentOption, } from "./options.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* THE CHOICES — pick one of many by typing (ComboBox), one of a few in sight
|
|
2
2
|
(RadioGroup, SegmentedControl), turn on or off (Switch), a value in a range (Slider)
|
|
3
3
|
and search for loose text (SearchField). The value is always plain data. */
|
|
4
|
+
/* A yes/no as a form row: the sentence is its name, lined up with the inputs beside it. */
|
|
5
|
+
export { CheckField, } from "./CheckField.js";
|
|
4
6
|
export { ComboBox } from "./ComboBox.js";
|
|
5
7
|
export { KanbanState, } from "./KanbanState.js";
|
|
6
8
|
export {} from "./options.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|