@sincpro/web-ui 2.0.0 → 2.2.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 +45 -0
- package/dist/components/activity/Activity.d.ts +13 -14
- package/dist/components/activity/Activity.js +1 -1
- package/dist/components/activity/Messages.d.ts +5 -5
- package/dist/components/activity/Messages.js +8 -8
- package/dist/components/attachments/Attachments.d.ts +7 -1
- package/dist/components/attachments/Attachments.js +8 -2
- package/dist/components/board/Board.d.ts +32 -2
- package/dist/components/board/Board.js +27 -4
- package/dist/components/board/index.d.ts +1 -1
- package/dist/components/board/index.js +2 -1
- package/dist/components/form/Form.js +6 -6
- package/dist/components/form/index.js +2 -2
- package/dist/components/frame/FrameView.d.ts +5 -5
- package/dist/components/frame/FrameView.js +4 -4
- package/dist/components/listing/GroupingLevels.d.ts +22 -22
- package/dist/components/listing/GroupingLevels.js +9 -9
- package/dist/components/listing/Listing.d.ts +11 -11
- package/dist/components/listing/Listing.js +11 -11
- package/dist/components/listing/ListingBar.js +11 -11
- package/dist/components/listing/Row.d.ts +19 -19
- package/dist/components/listing/Row.js +27 -27
- package/dist/components/listing/SortMenu.d.ts +36 -36
- package/dist/components/listing/SortMenu.js +6 -6
- package/dist/components/listing/grouping.d.ts +16 -16
- package/dist/components/listing/grouping.js +6 -6
- package/dist/components/listing/index.js +1 -1
- package/dist/components/listing/modelColumns.d.ts +25 -25
- package/dist/components/listing/modelColumns.js +24 -24
- package/dist/components/listing/pages.js +4 -4
- package/dist/components/listing/set.d.ts +18 -18
- package/dist/components/navigation/NavigationTree.js +2 -2
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +22 -22
- package/dist/components/search/CriteriaBuilder.js +31 -31
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +12 -12
- package/dist/components/search/FilterBuilder.d.ts +67 -67
- package/dist/components/search/FilterBuilder.js +104 -104
- package/dist/components/search/JoinWord.d.ts +1 -1
- package/dist/components/search/JoinWord.js +14 -14
- package/dist/components/search/JsonEditor.d.ts +8 -8
- package/dist/components/search/JsonEditor.js +16 -16
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +140 -117
- package/dist/components/search/criteria.d.ts +61 -61
- package/dist/components/search/criteria.js +39 -39
- package/dist/components/search/datePeriods.d.ts +47 -48
- package/dist/components/search/datePeriods.js +29 -29
- package/dist/components/search/dateRanges.d.ts +27 -27
- package/dist/components/search/dateRanges.js +16 -16
- package/dist/components/search/index.js +13 -13
- package/dist/components/search/model.d.ts +28 -28
- package/dist/components/search/model.js +21 -21
- package/dist/components/search/query.d.ts +71 -71
- package/dist/components/search/query.js +119 -119
- package/dist/components/shell/AppFrame.d.ts +9 -2
- package/dist/components/shell/AppFrame.js +102 -14
- package/dist/components/shell/Sidebar.d.ts +34 -0
- package/dist/components/shell/Sidebar.js +32 -0
- package/dist/components/shell/TopBar.d.ts +2 -0
- package/dist/components/shell/TopBar.js +13 -9
- package/dist/components/shell/index.d.ts +2 -0
- package/dist/components/shell/index.js +5 -1
- package/dist/components/shell/sidebarDrawer.d.ts +26 -0
- package/dist/components/shell/sidebarDrawer.js +22 -0
- package/dist/foundations/calendar.d.ts +27 -27
- package/dist/foundations/calendar.js +72 -72
- package/dist/foundations/chart.d.ts +57 -57
- package/dist/foundations/chart.js +27 -27
- package/dist/foundations/copy.d.ts +109 -94
- package/dist/foundations/copy.es.js +10 -2
- package/dist/foundations/copy.js +10 -2
- package/dist/foundations/grouping.d.ts +175 -175
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +21 -21
- package/dist/foundations/pivot.d.ts +133 -131
- package/dist/foundations/pivot.js +54 -54
- package/dist/foundations/pivotSheet.d.ts +36 -36
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/slots.d.ts +38 -38
- package/dist/foundations/slots.js +18 -18
- package/dist/foundations/sticky.d.ts +28 -28
- package/dist/foundations/sticky.js +59 -59
- package/dist/foundations/xlsx.d.ts +47 -47
- package/dist/foundations/xlsx.js +0 -0
- package/dist/primitives/block/Line.d.ts +4 -4
- package/dist/primitives/block/Line.js +28 -28
- package/dist/primitives/block/index.js +2 -2
- package/dist/primitives/cell/index.js +2 -2
- package/dist/primitives/choice/index.js +3 -3
- package/dist/primitives/date/Calendar.d.ts +7 -1
- package/dist/primitives/date/Calendar.js +13 -3
- package/dist/primitives/date/DatePicker.d.ts +4 -1
- package/dist/primitives/date/DatePicker.js +2 -2
- package/dist/primitives/date/index.js +3 -3
- package/dist/primitives/disclosure/index.js +1 -1
- package/dist/primitives/field/DropZone.d.ts +22 -3
- package/dist/primitives/field/DropZone.js +33 -12
- package/dist/primitives/menu/Menu.d.ts +10 -6
- package/dist/primitives/menu/Menu.js +4 -3
- package/dist/primitives/notice/Callout.d.ts +30 -30
- package/dist/primitives/notice/Callout.js +6 -6
- package/dist/primitives/overlay/index.js +3 -3
- package/dist/primitives/picker/Picker.d.ts +6 -0
- package/dist/primitives/picker/Picker.js +27 -4
- package/dist/primitives/picker/index.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +32 -32
- package/dist/primitives/table/DataTable.js +24 -24
- package/dist/primitives/table/EditableTable.d.ts +10 -10
- package/dist/primitives/table/EditableTable.js +9 -9
- package/dist/primitives/table/ReportTable.js +7 -7
- package/dist/primitives/table/SheetTable.d.ts +13 -13
- package/dist/primitives/table/SheetTable.js +14 -14
- package/dist/primitives/table/Table.js +8 -8
- package/dist/primitives/tabs/Tabs.d.ts +46 -46
- package/dist/primitives/tabs/Tabs.js +4 -30
- package/dist/primitives/tag/Count.d.ts +23 -0
- package/dist/primitives/tag/Count.js +59 -0
- package/dist/primitives/tag/index.d.ts +1 -0
- package/dist/primitives/tag/index.js +5 -2
- package/dist/primitives/toolbar/index.js +1 -1
- package/dist/primitives/value/Copyable.d.ts +22 -22
- package/dist/primitives/value/Copyable.js +9 -9
- package/dist/primitives/value/Metric.d.ts +7 -2
- package/dist/primitives/value/Metric.js +12 -4
- package/dist/tokens.css +164 -57
- package/dist/views/list/List.d.ts +36 -36
- package/dist/views/list/List.js +19 -19
- package/dist/views/list/ListView.js +74 -74
- package/dist/views/list/columns.d.ts +10 -10
- package/dist/views/list/columns.js +10 -10
- package/dist/views/list/derive.d.ts +30 -30
- package/dist/views/list/derive.js +49 -49
- package/dist/views/list/index.js +2 -2
- package/dist/views/list/presentations.js +3 -3
- package/dist/views/list/types.d.ts +109 -109
- package/dist/views/record/Record.d.ts +14 -14
- package/dist/views/record/Record.js +24 -24
- package/dist/views/record/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LucideIcon } from "lucide-react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
export type SidebarAction = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: LucideIcon;
|
|
7
|
+
/** A link instead of an action — «Ver el sitio». It is followed, not reported. */
|
|
8
|
+
href?: string;
|
|
9
|
+
/** The link opens in another tab; a screen reader is told so. */
|
|
10
|
+
external?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type SidebarProps = {
|
|
13
|
+
/** The product, at the top: its name and its mark — an icon, or the logo's image. */
|
|
14
|
+
brand?: {
|
|
15
|
+
label: string;
|
|
16
|
+
icon?: LucideIcon;
|
|
17
|
+
logo?: string;
|
|
18
|
+
};
|
|
19
|
+
/** Who is signed in. */
|
|
20
|
+
user?: {
|
|
21
|
+
name: string;
|
|
22
|
+
detail?: string;
|
|
23
|
+
avatar?: string;
|
|
24
|
+
};
|
|
25
|
+
/** The navigation: a `NavigationTree`. It scrolls; the top and the bottom stay. */
|
|
26
|
+
children: ReactNode;
|
|
27
|
+
/** The account, pinned to the bottom: change the password, view the site, sign out. */
|
|
28
|
+
actions?: readonly SidebarAction[];
|
|
29
|
+
/** An action without `href` was chosen. */
|
|
30
|
+
onAction?: (id: string) => void;
|
|
31
|
+
/** Anything else at the very bottom: a `ThemeSwitcher`, the version. */
|
|
32
|
+
footer?: ReactNode;
|
|
33
|
+
};
|
|
34
|
+
export declare function Sidebar({ brand, user, children, actions, onAction, footer }: SidebarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useSidebarDrawer } from "./sidebarDrawer.js";
|
|
4
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { Avatar } from "../../primitives/value/Person.js";
|
|
6
|
+
const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta text-ink no-underline transition-colors duration-(--duration-instant) hover:bg-ink/6 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary";
|
|
7
|
+
function Brand({ brand }) {
|
|
8
|
+
const Icon = brand.icon;
|
|
9
|
+
return (_jsxs("div", { className: "flex min-w-0 items-center gap-2 px-4 pt-4 pb-2", children: [brand.logo === undefined ? (Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-lg) shrink-0 text-primary", strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx("img", { src: brand.logo, alt: "", className: "size-(--size-control-md) shrink-0 object-contain" })), _jsx("span", { className: "min-w-0 truncate text-lead font-semibold text-ink", children: brand.label })] }));
|
|
10
|
+
}
|
|
11
|
+
function User({ user }) {
|
|
12
|
+
return (_jsxs("div", { className: "flex min-w-0 items-center gap-2 px-4 py-2", children: [_jsx(Avatar, { name: user.name, size: "md", ...(user.avatar === undefined ? {} : { src: user.avatar }) }), _jsxs("span", { className: "flex min-w-0 flex-col leading-tight", children: [_jsx("span", { className: "truncate text-meta text-ink", children: user.name }), user.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: user.detail }))] })] }));
|
|
13
|
+
}
|
|
14
|
+
function Action({ action, onAction, }) {
|
|
15
|
+
const copy = useUiCopy();
|
|
16
|
+
const drawer = useSidebarDrawer();
|
|
17
|
+
const Icon = action.icon;
|
|
18
|
+
const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "min-w-0 truncate", children: action.label })] }));
|
|
19
|
+
if (action.href !== undefined) {
|
|
20
|
+
return (_jsxs("a", { href: action.href, className: ROW, ...(action.external === true ? { target: "_blank", rel: "noreferrer" } : {}), children: [content, action.external === true ? (_jsx("span", { className: "sr-only", children: ` (${copy.field.newTab})` })) : null] }));
|
|
21
|
+
}
|
|
22
|
+
return (_jsx("button", { type: "button", className: ROW, onClick: () => {
|
|
23
|
+
onAction?.(action.id);
|
|
24
|
+
drawer?.close();
|
|
25
|
+
}, children: content }));
|
|
26
|
+
}
|
|
27
|
+
export function Sidebar({ brand, user, children, actions, onAction, footer }) {
|
|
28
|
+
const copy = useUiCopy();
|
|
29
|
+
const head = brand !== undefined || user !== undefined;
|
|
30
|
+
const foot = (actions !== undefined && actions.length > 0) || footer !== undefined;
|
|
31
|
+
return (_jsxs("div", { className: "flex h-full min-h-0 min-w-0 flex-col", children: [head ? (_jsxs("div", { className: "shrink-0 border-b border-line pb-2", children: [brand === undefined ? null : _jsx(Brand, { brand: brand }), user === undefined ? null : _jsx(User, { user: user })] })) : null, _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { className: "flex shrink-0 flex-col gap-2 border-t border-line p-2", children: [actions === undefined || actions.length === 0 ? null : (_jsx("ul", { "aria-label": copy.shell.account, className: "flex flex-col gap-px", children: actions.map((action) => (_jsx("li", { children: _jsx(Action, { action: action, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }));
|
|
32
|
+
}
|
|
@@ -12,6 +12,8 @@ export interface TopMenu {
|
|
|
12
12
|
id: string;
|
|
13
13
|
label: string;
|
|
14
14
|
groups: readonly MenuGroup[];
|
|
15
|
+
/** What is waiting inside — «Pagos 5» — seen without opening the menu. Zero is not drawn. */
|
|
16
|
+
count?: number;
|
|
15
17
|
}
|
|
16
18
|
export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
|
|
17
19
|
/** The product's name, when there is ONE product. It is drawn like the
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { SidebarToggle } from "./sidebarDrawer.js";
|
|
3
4
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
5
|
import { SurfaceProvider } from "../../foundations/surface.js";
|
|
5
6
|
import { Menu } from "../../primitives/menu/Menu.js";
|
|
7
|
+
import { Count, countText } from "../../primitives/tag/Count.js";
|
|
6
8
|
import { Avatar } from "../../primitives/value/Person.js";
|
|
7
9
|
import { Grid3x3 } from "lucide-react";
|
|
8
|
-
import { useState } from "react";
|
|
10
|
+
import { useMemo, useState } from "react";
|
|
9
11
|
export function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }) {
|
|
10
12
|
const copy = useUiCopy();
|
|
11
13
|
const actual = apps?.find((a) => a.id === currentApp);
|
|
12
14
|
const brand = app ?? actual;
|
|
13
|
-
return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: [brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
|
|
15
|
+
return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [_jsx(SidebarToggle, {}), apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: [brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
|
|
14
16
|
}
|
|
15
17
|
/** The app switcher: a grid, not a list.
|
|
16
18
|
*
|
|
@@ -31,20 +33,22 @@ export function AppSwitcher({ apps, current, onSelect, }) {
|
|
|
31
33
|
}, className: `flex flex-col items-center gap-1.5 rounded-box px-2 py-3 text-center transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${here ? "bg-primary/8 text-primary" : "text-ink hover:bg-ink/5"}`, children: [_jsx(a.icon, { className: "size-(--size-icon-lg)", strokeWidth: 1.75, "aria-hidden": true }), _jsx("span", { className: "text-micro leading-tight", children: a.label })] }, a.id));
|
|
32
34
|
}) })] }))] }));
|
|
33
35
|
}
|
|
36
|
+
/** A badge over an icon is read in a glance: past two digits it says «a lot». */
|
|
37
|
+
const SYSTRAY_MAX = 99;
|
|
34
38
|
/** A systray icon with its count.
|
|
35
39
|
*
|
|
36
40
|
* Zero is NOT drawn: a bell with a «0» next to it forces you to read a number
|
|
37
41
|
* to discover there is nothing. With no count you can already see there is
|
|
38
42
|
* nothing. */
|
|
39
43
|
export function SystrayButton({ icon: Icon, label, count = 0, tone = "info", onClick, active = false, }) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (_jsxs("button", { type: "button", onClick: onClick, title: count > 0 ? `${label} (${
|
|
44
|
+
const copy = useUiCopy();
|
|
45
|
+
const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
|
|
46
|
+
/* The button says the number in its name, so the badge is only seen — and both say the
|
|
47
|
+
same «99+», not a badge that is cut and a name that is not. */
|
|
48
|
+
const said = countText(count, number.format, SYSTRAY_MAX);
|
|
49
|
+
return (_jsxs("button", { type: "button", onClick: onClick, title: count > 0 ? `${label} (${said})` : label, "aria-label": count > 0 ? `${label}: ${said}` : label, className: `relative inline-flex size-(--size-control-md) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-link ${active
|
|
46
50
|
? "bg-chrome-ink/12 text-chrome-ink"
|
|
47
|
-
: "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true }), count <= 0 ? null : (_jsx("span", {
|
|
51
|
+
: "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true }), count <= 0 ? null : (_jsx("span", { className: "absolute -top-0.5 -right-0.5 flex", children: _jsx(Count, { value: count, tone: tone, solid: true, max: SYSTRAY_MAX, surface: "chrome", "aria-hidden": true }) }))] }));
|
|
48
52
|
}
|
|
49
53
|
/** Who I am and how I leave. The name is drawn when there is width; when narrow
|
|
50
54
|
* only the avatar stays, which is what gets recognised without reading. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { AppFrame } from "./AppFrame.js";
|
|
2
|
+
export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
|
|
3
|
+
export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
2
4
|
export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
|
|
3
5
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* THE APPLICATION FRAME — what sits above every view. */
|
|
2
2
|
export { AppFrame } from "./AppFrame.js";
|
|
3
|
+
/* The whole chrome in one column, for a back office with no bar on top. */
|
|
4
|
+
export { Sidebar, } from "./Sidebar.js";
|
|
5
|
+
/* The sidebar's phone drawer, for a bar an application writes itself. */
|
|
6
|
+
export { SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
3
7
|
export { SystrayButton, TopBar, } from "./TopBar.js";
|
|
4
8
|
/* A screen of N sets side by side — the reconciliation: each pane scrolls on its own. */
|
|
5
9
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context: **the sidebar on a phone.** Below `sm` (`--container-handheld`) a 15 rem column
|
|
3
|
+
* beside the view is two thirds of a 390 px screen, so `AppFrame` hides it and offers the
|
|
4
|
+
* SAME sidebar as a drawer from the start edge. What opens the drawer lives in the bar on
|
|
5
|
+
* top — the application's `TopBar`, or the bar the frame draws when the sidebar is the
|
|
6
|
+
* only chrome — and the frame is the one that knows there is a drawer. This is that
|
|
7
|
+
* contract: `null` outside a frame with a sidebar, so a `TopBar` without one draws no
|
|
8
|
+
* button that opens nothing.
|
|
9
|
+
*/
|
|
10
|
+
export type SidebarDrawer = {
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
open: () => void;
|
|
13
|
+
close: () => void;
|
|
14
|
+
/** The drawer's id, for `aria-controls`. */
|
|
15
|
+
id: string;
|
|
16
|
+
};
|
|
17
|
+
export declare const SidebarDrawerContext: import("react").Context<SidebarDrawer | null>;
|
|
18
|
+
/** The phone drawer of the frame's sidebar, for a bar or a control an application writes
|
|
19
|
+
* itself. `null` when the frame has no sidebar. */
|
|
20
|
+
export declare function useSidebarDrawer(): SidebarDrawer | null;
|
|
21
|
+
/** The button that opens the sidebar on a phone. It draws nothing on a wider screen — the
|
|
22
|
+
* sidebar is in view there — nor outside a frame with a sidebar. `TopBar` draws it first
|
|
23
|
+
* on its own; write it only in a bar of your own. */
|
|
24
|
+
export declare function SidebarToggle({ surface }: {
|
|
25
|
+
surface?: "canvas" | "chrome";
|
|
26
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { IconButton } from "../../primitives/button/Button.js";
|
|
5
|
+
import { Menu as Hamburger } from "lucide-react";
|
|
6
|
+
import { createContext, useContext } from "react";
|
|
7
|
+
export const SidebarDrawerContext = createContext(null);
|
|
8
|
+
/** The phone drawer of the frame's sidebar, for a bar or a control an application writes
|
|
9
|
+
* itself. `null` when the frame has no sidebar. */
|
|
10
|
+
export function useSidebarDrawer() {
|
|
11
|
+
return useContext(SidebarDrawerContext);
|
|
12
|
+
}
|
|
13
|
+
/** The button that opens the sidebar on a phone. It draws nothing on a wider screen — the
|
|
14
|
+
* sidebar is in view there — nor outside a frame with a sidebar. `TopBar` draws it first
|
|
15
|
+
* on its own; write it only in a bar of your own. */
|
|
16
|
+
export function SidebarToggle({ surface = "chrome" }) {
|
|
17
|
+
const copy = useUiCopy();
|
|
18
|
+
const drawer = useSidebarDrawer();
|
|
19
|
+
if (drawer === null)
|
|
20
|
+
return null;
|
|
21
|
+
return (_jsx("span", { className: "flex shrink-0 sm:hidden", children: _jsx(IconButton, { icon: Hamburger, label: copy.shell.openNavigation, size: "md", surface: surface, expanded: drawer.isOpen, haspopup: "dialog", ...(drawer.isOpen ? { "aria-controls": drawer.id } : {}), onClick: drawer.open }) }));
|
|
22
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
1
|
+
/** The grain of a date level. Without a grain, a date field splits by
|
|
2
|
+
* instant and every row ends up in its own bucket, which is not grouping. */
|
|
3
3
|
export type GroupGrain = "day" | "week" | "month" | "quarter" | "year";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* A date cut down to the KEY of its grain.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* «2026-09-15»—,
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* The text is the one the engine produces —«2026», «2026-Q3», «2026-09», «2026-W38»,
|
|
8
|
+
* «2026-09-15»—, and both sides writing it the same is what lets a grouping
|
|
9
|
+
* made in the browser be compared with one counted a thousand kilometres away. Without a date
|
|
10
|
+
* the key is empty: a bucket that exists —the one for those that have none— and that is
|
|
11
|
+
* drawn with the words of the copy.
|
|
12
12
|
*/
|
|
13
13
|
export declare function dateKey(when: Date | string | number | null | undefined, grain: GroupGrain): string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* The LABEL of a date key, in the active language.
|
|
16
16
|
*
|
|
17
|
-
* `within`
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* `within` are the grains the buckets above already said: with the year
|
|
18
|
+
* above, a month is «Septiembre» and not «Septiembre de 2026». A key that does not
|
|
19
|
+
* have the shape of its grain is drawn AS IS —that is what keeps a bucket
|
|
20
|
+
* counted elsewhere, with a key this layer did not write, readable
|
|
21
|
+
* instead of vanishing behind an invented date.
|
|
22
22
|
*/
|
|
23
23
|
export declare function dateLabel(key: string, grain: GroupGrain, within?: readonly GroupGrain[]): string;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
26
|
-
* «2026-W52» →
|
|
27
|
-
*
|
|
25
|
+
* The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
|
|
26
|
+
* «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —
|
|
27
|
+
* one counted elsewhere, which this layer did not write and so cannot continue.
|
|
28
28
|
*/
|
|
29
29
|
export declare function nextDateKey(key: string, grain: GroupGrain): string | null;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* All the keys of a grain between two, both included: the whole time AXIS.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
33
|
+
* An axis that skips the month where nothing happened lies about time —August stuck to
|
|
34
|
+
* October reads as one month— and that gap is often exactly what someone is looking for. `null` if
|
|
35
|
+
* some key cannot be continued or if there would be more than `max`: an axis by day over ten years
|
|
36
|
+
* is not a chart.
|
|
37
37
|
*/
|
|
38
38
|
export declare function dateKeysBetween(first: string, last: string, grain: GroupGrain, max?: number): string[] | null;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
39
|
+
/** The name of a month —1 to 12— in the active language. Used by whoever offers months
|
|
40
|
+
* without holding any date, like the cut by period. */
|
|
41
41
|
export declare function monthName(month: number): string;
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
/** What a GRAIN is called —«día», «semana»—, which is different from what a bucket
|
|
43
|
+
* of it is called: the grain names the cut and the label names what was cut. It comes from
|
|
44
|
+
* the copy, which is where the time units in the singular already live. */
|
|
45
45
|
export declare function grainName(grain: GroupGrain): string;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
import { currentCopy, currentCopyLocale, fillCopy } from "./copy.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* THE CALENDAR: from a date to a KEY, and from a key to a LABEL.
|
|
4
4
|
*
|
|
5
|
-
* Context:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
5
|
+
* Context: a date bucket has two texts and they are not the same. «2026-09» is
|
|
6
|
+
* what the engine writes —what identifies the bucket, what is compared with what
|
|
7
|
+
* the server counted, what is stored folded— and «Septiembre» is what is
|
|
8
|
+
* read. Writing only one forces a choice of which one is lost: with the key in view
|
|
9
|
+
* the interface speaks machine, and with the label as identity two Septembers of
|
|
10
|
+
* different years melt into a bucket that does not exist.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* That is why there are two functions and not one:
|
|
13
13
|
*
|
|
14
|
-
* dateKey(when, "month") → «2026-09»
|
|
15
|
-
* dateLabel("2026-09", …) → «Septiembre»
|
|
14
|
+
* dateKey(when, "month") → «2026-09» the identity, in a single language
|
|
15
|
+
* dateLabel("2026-09", …) → «Septiembre» the label, in the active language
|
|
16
16
|
*
|
|
17
|
-
* ──
|
|
17
|
+
* ── The language is not translated: it is ASKED for ─────────────────
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* The months and the days of the week are said by `Intl` with the `locale` the copy
|
|
20
|
+
* has set, so there is no table of twelve months here, in Spanish or in
|
|
21
|
+
* English — nor would one have to be written for a third language. The only things that
|
|
22
|
+
* are copy are the week and the quarter, because no calendar names them: «W38»
|
|
23
|
+
* is not a word and `Intl` does not have it.
|
|
24
24
|
*
|
|
25
|
-
* ──
|
|
25
|
+
* ── A label says what the one above did NOT say ─────────────────────
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* A tree of dates is read from top to bottom, and repeating the year in every month
|
|
28
|
+
* and the month in every day fills the indentation with text that is already two lines
|
|
29
|
+
* above:
|
|
30
30
|
*
|
|
31
|
-
* 2026 ←
|
|
32
|
-
* Septiembre ←
|
|
33
|
-
* Semana 38 ←
|
|
34
|
-
* Martes ←
|
|
31
|
+
* 2026 ← the year is said once
|
|
32
|
+
* Septiembre ← not «Septiembre de 2026»
|
|
33
|
+
* Semana 38 ← not «Semana 38 de 2026»
|
|
34
|
+
* Martes ← not «martes, 15 sept 2026»
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* `within` takes care of that: the grains that the buckets above —of the same
|
|
37
|
+
* field— already said. With nobody above, the label stands alone and says the whole
|
|
38
|
+
* date, because a bare «Martes» is not a day.
|
|
39
39
|
*/
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* The shape of each grain's key. It is the whole `GroupGrain`: a grain the
|
|
42
|
+
* calendar could not cut would be a level that splits nothing.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
44
|
+
* The ranges go in the expression and not in an `if` because `new Date(2026, 12, 1)`
|
|
45
|
+
* does not fail: it rolls over to January 2027. A key «2026-13» drawn as «Enero»
|
|
46
|
+
* is a month nobody counted, and that is worse than an unreadable label.
|
|
47
47
|
*/
|
|
48
48
|
const KEY_SHAPES = {
|
|
49
49
|
year: /^(\d{4})$/,
|
|
@@ -53,13 +53,13 @@ const KEY_SHAPES = {
|
|
|
53
53
|
day: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* A date cut down to the KEY of its grain.
|
|
57
57
|
*
|
|
58
|
-
*
|
|
59
|
-
* «2026-09-15»—,
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
58
|
+
* The text is the one the engine produces —«2026», «2026-Q3», «2026-09», «2026-W38»,
|
|
59
|
+
* «2026-09-15»—, and both sides writing it the same is what lets a grouping
|
|
60
|
+
* made in the browser be compared with one counted a thousand kilometres away. Without a date
|
|
61
|
+
* the key is empty: a bucket that exists —the one for those that have none— and that is
|
|
62
|
+
* drawn with the words of the copy.
|
|
63
63
|
*/
|
|
64
64
|
export function dateKey(when, grain) {
|
|
65
65
|
if (when === null || when === undefined || when === "")
|
|
@@ -90,13 +90,13 @@ export function dateKey(when, grain) {
|
|
|
90
90
|
return `${year}-${pad(month)}-${pad(date.getDate())}`;
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* The LABEL of a date key, in the active language.
|
|
94
94
|
*
|
|
95
|
-
* `within`
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
95
|
+
* `within` are the grains the buckets above already said: with the year
|
|
96
|
+
* above, a month is «Septiembre» and not «Septiembre de 2026». A key that does not
|
|
97
|
+
* have the shape of its grain is drawn AS IS —that is what keeps a bucket
|
|
98
|
+
* counted elsewhere, with a key this layer did not write, readable
|
|
99
|
+
* instead of vanishing behind an invented date.
|
|
100
100
|
*/
|
|
101
101
|
export function dateLabel(key, grain, within = []) {
|
|
102
102
|
const copy = currentCopy();
|
|
@@ -118,8 +118,8 @@ export function dateLabel(key, grain, within = []) {
|
|
|
118
118
|
}
|
|
119
119
|
if (grain === "week") {
|
|
120
120
|
const week = Number(parts[2]);
|
|
121
|
-
/*
|
|
122
|
-
|
|
121
|
+
/* The month is enough too: a week inside September already knows which
|
|
122
|
+
year it is, because the month said so. */
|
|
123
123
|
return said("year") || said("quarter") || said("month")
|
|
124
124
|
? fillCopy(copy.calendar.week, { n: week })
|
|
125
125
|
: fillCopy(copy.calendar.weekOfYear, { n: week, year });
|
|
@@ -132,13 +132,13 @@ export function dateLabel(key, grain, within = []) {
|
|
|
132
132
|
}
|
|
133
133
|
const day = Number(parts[3]);
|
|
134
134
|
const when = new Date(year, Number(parts[2]) - 1, day);
|
|
135
|
-
/*
|
|
136
|
-
|
|
135
|
+
/* 31 February has the shape of a day and is none: `Date` rolls it over
|
|
136
|
+
to 3 March instead of complaining, so we ask whether the same day came back. */
|
|
137
137
|
if (when.getDate() !== day)
|
|
138
138
|
return key;
|
|
139
|
-
/*
|
|
140
|
-
|
|
141
|
-
«Martes»
|
|
139
|
+
/* Inside a week, the day is its NAME: there are seven and none repeats,
|
|
140
|
+
so «Martes» is enough and the day number would be noise. Outside it is not: a bare
|
|
141
|
+
«Martes» does not say which of the fifty-two. */
|
|
142
142
|
if (said("week"))
|
|
143
143
|
return capitalized(format(locale, { weekday: "long" }).format(when));
|
|
144
144
|
return capitalized(format(locale, {
|
|
@@ -149,9 +149,9 @@ export function dateLabel(key, grain, within = []) {
|
|
|
149
149
|
}).format(when));
|
|
150
150
|
}
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
153
|
-
* «2026-W52» →
|
|
154
|
-
*
|
|
152
|
+
* The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
|
|
153
|
+
* «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —
|
|
154
|
+
* one counted elsewhere, which this layer did not write and so cannot continue.
|
|
155
155
|
*/
|
|
156
156
|
export function nextDateKey(key, grain) {
|
|
157
157
|
const parts = KEY_SHAPES[grain].exec(key);
|
|
@@ -179,12 +179,12 @@ export function nextDateKey(key, grain) {
|
|
|
179
179
|
return dateKey(date, "day");
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
-
*
|
|
182
|
+
* All the keys of a grain between two, both included: the whole time AXIS.
|
|
183
183
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
184
|
+
* An axis that skips the month where nothing happened lies about time —August stuck to
|
|
185
|
+
* October reads as one month— and that gap is often exactly what someone is looking for. `null` if
|
|
186
|
+
* some key cannot be continued or if there would be more than `max`: an axis by day over ten years
|
|
187
|
+
* is not a chart.
|
|
188
188
|
*/
|
|
189
189
|
export function dateKeysBetween(first, last, grain, max = 1000) {
|
|
190
190
|
const out = [first];
|
|
@@ -198,24 +198,24 @@ export function dateKeysBetween(first, last, grain, max = 1000) {
|
|
|
198
198
|
}
|
|
199
199
|
return key === last ? out : null;
|
|
200
200
|
}
|
|
201
|
-
/**
|
|
202
|
-
*
|
|
201
|
+
/** The name of a month —1 to 12— in the active language. Used by whoever offers months
|
|
202
|
+
* without holding any date, like the cut by period. */
|
|
203
203
|
export function monthName(month) {
|
|
204
204
|
return capitalized(format(currentCopyLocale(), { month: "long" }).format(new Date(2000, month - 1, 1)));
|
|
205
205
|
}
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
206
|
+
/** What a GRAIN is called —«día», «semana»—, which is different from what a bucket
|
|
207
|
+
* of it is called: the grain names the cut and the label names what was cut. It comes from
|
|
208
|
+
* the copy, which is where the time units in the singular already live. */
|
|
209
209
|
export function grainName(grain) {
|
|
210
210
|
return capitalized(currentCopy().dates[grain]);
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
|
-
*
|
|
213
|
+
* The ISO year and week of a date.
|
|
214
214
|
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
215
|
+
* Week 1 is the one holding the first Thursday of the year, so it is computed with
|
|
216
|
+
* the Thursday of the datum's week: it decides which year it belongs to, and that is
|
|
217
|
+
* why a week at the end of December can be week 1 of the next year. The year
|
|
218
|
+
* that comes out of here is that of THAT week and not that of the date.
|
|
219
219
|
*/
|
|
220
220
|
function isoWeek(date) {
|
|
221
221
|
const thursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
@@ -229,9 +229,9 @@ function isoWeek(date) {
|
|
|
229
229
|
function format(locale, options) {
|
|
230
230
|
return new Intl.DateTimeFormat(locale, options);
|
|
231
231
|
}
|
|
232
|
-
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
232
|
+
/** A label heads a bucket, and in Spanish `Intl` returns «septiembre» in
|
|
233
|
+
* lowercase. The first letter is raised with the active language, which is the one that knows
|
|
234
|
+
* what the capital of that letter is. */
|
|
235
235
|
function capitalized(text) {
|
|
236
236
|
const first = text.charAt(0);
|
|
237
237
|
return first === "" ? text : first.toLocaleUpperCase(currentCopyLocale()) + text.slice(1);
|