@sincpro/web-ui 2.2.0 → 2.3.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 +69 -3
- package/dist/components/board/Board.js +1 -1
- package/dist/components/listing/GroupingLevels.js +11 -9
- package/dist/components/listing/RecordCard.js +1 -1
- package/dist/components/navigation/NavigationTree.js +36 -9
- package/dist/components/search/CriteriaBuilder.js +3 -2
- package/dist/components/search/CriteriaChips.js +6 -5
- package/dist/components/search/JoinWord.js +1 -1
- package/dist/components/search/SearchBar.js +41 -25
- package/dist/components/shell/AppFrame.d.ts +10 -1
- package/dist/components/shell/AppFrame.js +53 -10
- package/dist/components/shell/Sidebar.d.ts +8 -3
- package/dist/components/shell/Sidebar.js +36 -11
- package/dist/components/shell/TopBar.d.ts +8 -1
- package/dist/components/shell/TopBar.js +6 -5
- package/dist/components/shell/brandMark.d.ts +17 -0
- package/dist/components/shell/brandMark.js +9 -0
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +2 -0
- package/dist/foundations/copy.es.js +3 -3
- package/dist/foundations/copy.js +3 -3
- package/dist/foundations/variants.js +19 -2
- package/dist/primitives/block/Block.js +1 -1
- package/dist/primitives/button/Button.d.ts +3 -1
- package/dist/primitives/button/Button.js +6 -6
- package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
- package/dist/primitives/choice/SegmentedControl.js +35 -7
- package/dist/primitives/dialog/Dialog.d.ts +1 -1
- package/dist/primitives/dialog/Dialog.js +2 -2
- package/dist/primitives/field/CardNumberInput.js +1 -1
- package/dist/primitives/field/Checks.d.ts +14 -0
- package/dist/primitives/field/Checks.js +12 -4
- package/dist/primitives/field/DurationInput.js +1 -1
- package/dist/primitives/field/Field.js +7 -7
- package/dist/primitives/field/PatternInput.js +1 -1
- package/dist/primitives/field/RichTextEditor.js +2 -2
- package/dist/primitives/field/SignatureInput.js +1 -1
- package/dist/primitives/field/aria.d.ts +2 -2
- package/dist/primitives/field/aria.js +5 -5
- package/dist/primitives/field/index.d.ts +1 -1
- package/dist/primitives/field/index.js +1 -1
- package/dist/primitives/menu/Menu.d.ts +23 -7
- package/dist/primitives/menu/Menu.js +76 -22
- package/dist/primitives/overlay/Popover.js +2 -2
- package/dist/primitives/picker/Picker.js +3 -3
- package/dist/primitives/picker/TagsField.js +1 -1
- package/dist/primitives/table/EditableTable.js +2 -2
- package/dist/primitives/table/ReportTable.js +1 -1
- package/dist/primitives/table/Table.js +2 -2
- package/dist/primitives/tag/Tag.d.ts +9 -0
- package/dist/primitives/tag/Tag.js +14 -1
- package/dist/primitives/tag/Tags.js +6 -7
- package/dist/primitives/value/Metric.js +4 -4
- package/dist/tokens.css +163 -36
- package/package.json +1 -1
|
@@ -5,7 +5,8 @@ import { SidebarDrawerContext } from "./sidebarDrawer.js";
|
|
|
5
5
|
import { TopBar } from "./TopBar.js";
|
|
6
6
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
7
7
|
import { HANDHELD_WIDTH } from "../../foundations/layout.js";
|
|
8
|
-
import { stickyTop, useStickyLayer } from "../../foundations/sticky.js";
|
|
8
|
+
import { stickyReset, stickyTop, useStickyLayer } from "../../foundations/sticky.js";
|
|
9
|
+
import { bySurface, SurfaceProvider } from "../../foundations/surface.js";
|
|
9
10
|
import { IconButton } from "../../primitives/button/Button.js";
|
|
10
11
|
import { X } from "lucide-react";
|
|
11
12
|
import { useEffect, useId, useMemo, useState } from "react";
|
|
@@ -83,6 +84,36 @@ import { Dialog as AriaDialog, Modal, ModalOverlay } from "react-aria-components
|
|
|
83
84
|
* `TopBar` draws first, or — with no `menu` — from the bar the frame draws for
|
|
84
85
|
* the phone alone (`narrowMenu`, a bare `TopBar` by default). Following a link
|
|
85
86
|
* in it closes it: the person went where they were going.
|
|
87
|
+
*
|
|
88
|
+
* ── In the brand's colour: `sidebarSurface="chrome"` ────────────────
|
|
89
|
+
*
|
|
90
|
+
* The frame paints the column (and the drawer), so the frame is told which
|
|
91
|
+
* surface it is, and hands it to what is inside: a `Sidebar`, its tree, its
|
|
92
|
+
* counts. It is meant for the sidebar AS the chrome — with a `menu` too it
|
|
93
|
+
* would be a second dark band beside the bar's.
|
|
94
|
+
*
|
|
95
|
+
* ── A workspace that scrolls itself: `scroll="view"` ────────────────
|
|
96
|
+
*
|
|
97
|
+
* ┌──────────┬────────────────────────────────────────────┐
|
|
98
|
+
* │ sidebar │ ┌ the workspace ─────────────────────────┐ │
|
|
99
|
+
* │ │ │ its own header sticks at ITS top │ │ ← exactly the window,
|
|
100
|
+
* │ │ │ …and it scrolls inside itself… │ │ minus the bar
|
|
101
|
+
* │ │ └────────────────────────────────────────┘ │
|
|
102
|
+
* └──────────┴────────────────────────────────────────────┘
|
|
103
|
+
*
|
|
104
|
+
* By default the PAGE scrolls and the bars above announce their height in
|
|
105
|
+
* `--sticky-top`, so a view's sticky bands hang under them. A workspace
|
|
106
|
+
* (composer's) is the opposite: it is as tall as the window and scrolls
|
|
107
|
+
* inside its own boxes, where that offset is wrong — a table's header stuck
|
|
108
|
+
* that far down INSIDE the box, over its first rows. With `scroll="view"` the
|
|
109
|
+
* frame is the window's height, the view gets what the bars leave, and the
|
|
110
|
+
* stack starts from zero inside it (`stickyReset`). Without it every app wrote
|
|
111
|
+
* the same two `div`s by hand — the frame this component exists to replace.
|
|
112
|
+
*
|
|
113
|
+
* ── On paper ────────────────────────────────────────────────────────
|
|
114
|
+
*
|
|
115
|
+
* The bar, the sidebar and the drawer do not print: a printed record is the
|
|
116
|
+
* record. And a frame the window's height lets the whole view out on paper.
|
|
86
117
|
* ==================================================================== */
|
|
87
118
|
/* Following a link closes the drawer. On the CAPTURE phase: React Aria's links stop the
|
|
88
119
|
click from bubbling, and a keyboard Enter on one reaches here as the click it dispatches. */
|
|
@@ -95,12 +126,12 @@ function closeOnLink(close) {
|
|
|
95
126
|
/** The sidebar as a drawer, for a phone: modal (the page behind is inert and dimmed, the
|
|
96
127
|
* focus is kept inside and returns to the button), dismissed by the scrim, Escape, its ×
|
|
97
128
|
* or a link followed. */
|
|
98
|
-
function SidebarDrawerPanel({ id, open, onClose, children, }) {
|
|
129
|
+
function SidebarDrawerPanel({ id, open, onClose, surface, children, }) {
|
|
99
130
|
const copy = useUiCopy();
|
|
100
131
|
return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
|
|
101
132
|
if (!next)
|
|
102
133
|
onClose();
|
|
103
|
-
}, isDismissable: true, className: ({ isEntering, isExiting }) => `fixed inset-0 z-50 bg-scrim/40 transition-opacity duration-(--duration-quick) ease-(--ease-out) sm:hidden ${isEntering || isExiting ? "opacity-0" : ""}`, children: _jsx(Modal, { className: ({ isEntering, isExiting }) => `fixed inset-y-0 start-0 flex w-(--container-drawer) flex-col border-e
|
|
134
|
+
}, isDismissable: true, className: ({ isEntering, isExiting }) => `fixed inset-0 z-50 bg-scrim/40 transition-opacity duration-(--duration-quick) ease-(--ease-out) sm:hidden print:hidden ${isEntering || isExiting ? "opacity-0" : ""}`, children: _jsx(Modal, { className: ({ isEntering, isExiting }) => `fixed inset-y-0 start-0 flex w-(--container-drawer) flex-col border-e shadow-window outline-0 transition-[translate] duration-(--duration-panel) ease-(--ease-out) ${bySurface(surface, "border-line-strong bg-ground", "border-chrome-edge bg-chrome")} ${isEntering || isExiting ? "-translate-x-full rtl:translate-x-full" : ""}`, children: _jsx(AriaDialog, { id: id, "aria-label": copy.shell.navigation, className: "flex min-h-0 flex-1 flex-col outline-0", children: _jsxs(SurfaceProvider, { value: surface, children: [_jsx("div", { className: "flex shrink-0 justify-end px-2 pt-2", children: _jsx(IconButton, { icon: X, label: copy.shell.close, onClick: onClose }) }), _jsx("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto", onClickCapture: closeOnLink(onClose), children: children })] }) }) }) }));
|
|
104
135
|
}
|
|
105
136
|
export function AppFrame({
|
|
106
137
|
/** The bar at the top. It stays in view while scrolling. */
|
|
@@ -115,7 +146,13 @@ sidebar,
|
|
|
115
146
|
/** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
|
|
116
147
|
* drawer and something has to open it — a `TopBar` with the product's name, which draws
|
|
117
148
|
* the button first. A bare `TopBar` by default. */
|
|
118
|
-
narrowMenu,
|
|
149
|
+
narrowMenu,
|
|
150
|
+
/** The surface of the sidebar and its drawer. `chrome` wears the brand's colour — for the
|
|
151
|
+
* sidebar as the application's chrome (no `menu`). `canvas` by default. */
|
|
152
|
+
sidebarSurface = "canvas",
|
|
153
|
+
/** Who scrolls. `page` (the default): the whole page, with the bars stuck on top. `view`:
|
|
154
|
+
* the frame is the window's height and the view scrolls inside itself — a workspace. */
|
|
155
|
+
scroll = "page", children, }) {
|
|
119
156
|
/* The top bar MEASURES what it takes and passes it to what is below: a list's
|
|
120
157
|
bar sticks beneath it, and a table's header beneath the other two. None of the
|
|
121
158
|
three has a fixed height — see `system/sticky.tsx`. */
|
|
@@ -154,15 +191,21 @@ narrowMenu, children, }) {
|
|
|
154
191
|
on a phone a bar appears to open it. */
|
|
155
192
|
const sidebarIsChrome = hasSidebar && menu === undefined;
|
|
156
193
|
const top = sidebarIsChrome ? (narrowMenu ?? _jsx(TopBar, {})) : menu;
|
|
194
|
+
/* With `scroll="view"` the regions down to `main` take the height they are given instead of
|
|
195
|
+
growing with their content (`min-h-0`), and `main` is where the view scrolls: the stack
|
|
196
|
+
of sticky things starts again at its top. */
|
|
197
|
+
const fills = scroll === "view";
|
|
198
|
+
const region = fills ? "min-h-0" : "";
|
|
199
|
+
const mainScroll = fills ? "min-h-0 overflow-y-auto print:overflow-visible" : "";
|
|
157
200
|
/* The sidebar sits on the ground tone, the content on the paper (surface): the same white
|
|
158
|
-
for both made the navigation read as part of the list bar. On
|
|
159
|
-
drawer shows it. */
|
|
160
|
-
const aside = sidebar === undefined ? null : (_jsx("aside", { className:
|
|
161
|
-
return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className:
|
|
201
|
+
for both made the navigation read as part of the list bar. On the chrome it wears the
|
|
202
|
+
brand's colour. On a phone it is hidden: the drawer shows it. */
|
|
203
|
+
const aside = sidebar === undefined ? null : (_jsx("aside", { className: `sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r max-sm:hidden print:hidden ${bySurface(sidebarSurface, "border-ui-sidebar-border bg-ui-sidebar", "border-chrome-edge bg-chrome")}`, style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, "data-ui": "frame.sidebar", children: _jsx(SurfaceProvider, { value: sidebarSurface, children: sidebar }) }));
|
|
204
|
+
return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className: `relative flex min-w-0 flex-col bg-ground ${fills ? "h-dvh overflow-hidden print:h-auto print:overflow-visible" : "min-h-dvh"}`, "data-ui": "frame", "data-scroll": scroll, children: [top === undefined ? null : (
|
|
162
205
|
/* Hidden on a wide screen when it is only the phone's bar: it measures 0 there, so
|
|
163
206
|
nothing below is pushed down by it. */
|
|
164
|
-
_jsx("div", { ref: bar.ref, className: `sticky top-0 z-40 ${sidebarIsChrome ? "sm:hidden" : ""}`, children: top })), sidebar === undefined ? (_jsx("main", { className:
|
|
207
|
+
_jsx("div", { ref: bar.ref, className: `sticky top-0 z-40 print:hidden ${sidebarIsChrome ? "sm:hidden" : ""}`, "data-ui": "frame.bar", children: top })), sidebar === undefined ? (_jsx("main", { className: `flex min-w-0 flex-1 flex-col ${mainScroll}`, style: fills ? stickyReset() : bar.below, "data-ui": "frame.main", children: children })) : sidebarIsChrome ? (_jsxs("div", { className: `flex min-w-0 flex-1 items-start ${region}`, style: bar.below, children: [aside, _jsx("main", { className: `flex min-w-0 flex-1 flex-col self-stretch ${mainScroll}`, ...(fills ? { style: stickyReset() } : {}), "data-ui": "frame.main", children: children })] })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${region}`, style: bar.below, children: [_jsx("div", { ref: (node) => {
|
|
165
208
|
head.ref.current = node;
|
|
166
209
|
setSlot(node);
|
|
167
|
-
}, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className:
|
|
210
|
+
}, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className: `flex min-w-0 flex-1 items-start ${region}`, style: head.below, children: [aside, _jsx("main", { className: `flex min-w-0 flex-1 flex-col self-stretch ${mainScroll}`, ...(fills ? { style: stickyReset() } : {}), "data-ui": "frame.main", children: children })] })] }) })), status, sidebar === undefined ? null : (_jsx(SidebarDrawerPanel, { id: drawerId, open: drawerOpen, onClose: () => setDrawerOpen(false), surface: sidebarSurface, children: sidebar }))] }) }));
|
|
168
211
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type BrandLogo } from "./brandMark.js";
|
|
2
|
+
import type { Surface } from "../../foundations/types.js";
|
|
1
3
|
import type { LucideIcon } from "lucide-react";
|
|
2
4
|
import type { ReactNode } from "react";
|
|
3
5
|
export type SidebarAction = {
|
|
@@ -10,11 +12,12 @@ export type SidebarAction = {
|
|
|
10
12
|
external?: boolean;
|
|
11
13
|
};
|
|
12
14
|
export type SidebarProps = {
|
|
13
|
-
/** The product, at the top: its name and its mark — an icon, or
|
|
15
|
+
/** The product, at the top: its name and its mark — an icon, or its logo: the URL of an
|
|
16
|
+
* image, or an inline `<svg>` that paints with the tokens and so follows theme and surface. */
|
|
14
17
|
brand?: {
|
|
15
18
|
label: string;
|
|
16
19
|
icon?: LucideIcon;
|
|
17
|
-
logo?:
|
|
20
|
+
logo?: BrandLogo;
|
|
18
21
|
};
|
|
19
22
|
/** Who is signed in. */
|
|
20
23
|
user?: {
|
|
@@ -30,5 +33,7 @@ export type SidebarProps = {
|
|
|
30
33
|
onAction?: (id: string) => void;
|
|
31
34
|
/** Anything else at the very bottom: a `ThemeSwitcher`, the version. */
|
|
32
35
|
footer?: ReactNode;
|
|
36
|
+
/** `chrome` wears the brand's colour. By default the frame's `sidebarSurface`. */
|
|
37
|
+
surface?: Surface;
|
|
33
38
|
};
|
|
34
|
-
export declare function Sidebar({ brand, user, children, actions, onAction, footer }: SidebarProps): import("react").JSX.Element;
|
|
39
|
+
export declare function Sidebar({ brand, user, children, actions, onAction, footer, surface, }: SidebarProps): import("react").JSX.Element;
|
|
@@ -1,32 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { BrandMark } from "./brandMark.js";
|
|
3
4
|
import { useSidebarDrawer } from "./sidebarDrawer.js";
|
|
4
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
6
|
+
import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
|
|
5
7
|
import { Avatar } from "../../primitives/value/Person.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
/* Each surface's colours in one place: the column is ONE surface, and a row drawn with the
|
|
9
|
+
other palette is the bug the surface context exists to prevent. The hairlines are ink at a
|
|
10
|
+
low alpha on the chrome: `chrome-edge` is the chrome itself on light, an invisible line. */
|
|
11
|
+
const SKIN = {
|
|
12
|
+
canvas: {
|
|
13
|
+
root: "",
|
|
14
|
+
ink: "text-ink",
|
|
15
|
+
muted: "text-muted",
|
|
16
|
+
mark: "text-primary",
|
|
17
|
+
line: "border-line",
|
|
18
|
+
row: "text-ink hover:bg-ink/6 focus-visible:outline-primary",
|
|
19
|
+
},
|
|
20
|
+
chrome: {
|
|
21
|
+
root: "bg-chrome",
|
|
22
|
+
ink: "text-chrome-ink",
|
|
23
|
+
muted: "text-chrome-muted",
|
|
24
|
+
mark: "text-chrome-link",
|
|
25
|
+
line: "border-chrome-ink/12",
|
|
26
|
+
row: "text-chrome-ink hover:bg-chrome-ink/10 focus-visible:outline-chrome-link",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta no-underline transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2";
|
|
30
|
+
function Brand({ brand, skin }) {
|
|
8
31
|
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:
|
|
32
|
+
return (_jsxs("div", { "data-ui": "sidebar.brand", 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 ${skin.mark}`, strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-md) shrink-0" })), _jsx("span", { className: `min-w-0 truncate text-lead font-semibold ${skin.ink}`, children: brand.label })] }));
|
|
10
33
|
}
|
|
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:
|
|
34
|
+
function User({ user, skin }) {
|
|
35
|
+
return (_jsxs("div", { "data-ui": "sidebar.user", 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 ${skin.ink}`, children: user.name }), user.detail === undefined ? null : (_jsx("span", { className: `truncate text-micro ${skin.muted}`, children: user.detail }))] })] }));
|
|
13
36
|
}
|
|
14
|
-
function Action({ action, onAction, }) {
|
|
37
|
+
function Action({ action, skin, onAction, }) {
|
|
15
38
|
const copy = useUiCopy();
|
|
16
39
|
const drawer = useSidebarDrawer();
|
|
17
40
|
const Icon = action.icon;
|
|
18
|
-
const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className:
|
|
41
|
+
const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${skin.muted}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "min-w-0 truncate", children: action.label })] }));
|
|
19
42
|
if (action.href !== undefined) {
|
|
20
|
-
return (_jsxs("a", { href: action.href, className: ROW
|
|
43
|
+
return (_jsxs("a", { href: action.href, className: `${ROW} ${skin.row}`, ...(action.external === true ? { target: "_blank", rel: "noreferrer" } : {}), children: [content, action.external === true ? (_jsx("span", { className: "sr-only", children: ` (${copy.field.newTab})` })) : null] }));
|
|
21
44
|
}
|
|
22
|
-
return (_jsx("button", { type: "button", className: ROW
|
|
45
|
+
return (_jsx("button", { type: "button", className: `${ROW} ${skin.row}`, onClick: () => {
|
|
23
46
|
onAction?.(action.id);
|
|
24
47
|
drawer?.close();
|
|
25
48
|
}, children: content }));
|
|
26
49
|
}
|
|
27
|
-
export function Sidebar({ brand, user, children, actions, onAction, footer }) {
|
|
50
|
+
export function Sidebar({ brand, user, children, actions, onAction, footer, surface, }) {
|
|
28
51
|
const copy = useUiCopy();
|
|
52
|
+
const sup = useSurface(surface);
|
|
53
|
+
const skin = SKIN[sup];
|
|
29
54
|
const head = brand !== undefined || user !== undefined;
|
|
30
55
|
const foot = (actions !== undefined && actions.length > 0) || footer !== undefined;
|
|
31
|
-
return (_jsxs("div", { className:
|
|
56
|
+
return (_jsx(SurfaceProvider, { value: sup, children: _jsxs("div", { "data-ui": "sidebar", "data-surface": sup, className: `flex h-full min-h-0 min-w-0 flex-col ${skin.root}`, children: [head ? (_jsxs("div", { className: `shrink-0 border-b pb-2 ${skin.line}`, children: [brand === undefined ? null : _jsx(Brand, { brand: brand, skin: skin }), user === undefined ? null : _jsx(User, { user: user, skin: skin })] })) : null, _jsx("div", { "data-ui": "sidebar.nav", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { "data-ui": "sidebar.account", className: `flex shrink-0 flex-col gap-2 border-t p-2 ${skin.line}`, 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, skin: skin, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }) }));
|
|
32
57
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BrandLogo } from "./brandMark.js";
|
|
1
2
|
import { type MenuGroup } from "../../primitives/menu/Menu.js";
|
|
2
3
|
import { type LucideIcon } from "lucide-react";
|
|
3
4
|
import { type ReactNode } from "react";
|
|
@@ -14,14 +15,17 @@ export interface TopMenu {
|
|
|
14
15
|
groups: readonly MenuGroup[];
|
|
15
16
|
/** What is waiting inside — «Pagos 5» — seen without opening the menu. Zero is not drawn. */
|
|
16
17
|
count?: number;
|
|
18
|
+
/** `columns` lays its sections side by side: a big module menu, seen whole. */
|
|
19
|
+
layout?: "list" | "columns";
|
|
17
20
|
}
|
|
18
|
-
export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
|
|
21
|
+
export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
|
|
19
22
|
/** The product's name, when there is ONE product. It is drawn like the
|
|
20
23
|
* current app of the switcher —same icon, same weight— but without the
|
|
21
24
|
* switcher: nothing to switch to. */
|
|
22
25
|
app?: {
|
|
23
26
|
label: string;
|
|
24
27
|
icon?: LucideIcon;
|
|
28
|
+
logo?: BrandLogo;
|
|
25
29
|
};
|
|
26
30
|
/** Everything that exists. Without this there is no switcher — a product with
|
|
27
31
|
* a single app does not need one, and drawing it empty promises something
|
|
@@ -31,6 +35,9 @@ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMe
|
|
|
31
35
|
onAppSelect?: (id: string) => void;
|
|
32
36
|
/** The menus OF the current app. */
|
|
33
37
|
menus?: readonly TopMenu[];
|
|
38
|
+
/** The menu that holds the screen on view: marked with a bar under its label, so «where am
|
|
39
|
+
* I» is answered without opening any of them. */
|
|
40
|
+
currentMenu?: string;
|
|
34
41
|
onMenuSelect?: (menuId: string, optionId: string) => void;
|
|
35
42
|
/** What happened while I was not looking: activity, alerts. Icons with a count. */
|
|
36
43
|
systray?: ReactNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { BrandMark } from "./brandMark.js";
|
|
3
4
|
import { SidebarToggle } from "./sidebarDrawer.js";
|
|
4
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
6
|
import { SurfaceProvider } from "../../foundations/surface.js";
|
|
@@ -8,11 +9,11 @@ import { Count, countText } from "../../primitives/tag/Count.js";
|
|
|
8
9
|
import { Avatar } from "../../primitives/value/Person.js";
|
|
9
10
|
import { Grid3x3 } from "lucide-react";
|
|
10
11
|
import { useMemo, useState } from "react";
|
|
11
|
-
export function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }) {
|
|
12
|
+
export function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, systray, user, onUserSelect, userGroups, }) {
|
|
12
13
|
const copy = useUiCopy();
|
|
13
14
|
const actual = apps?.find((a) => a.id === currentApp);
|
|
14
15
|
const brand = app ?? actual;
|
|
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 }) }))] })] }) }));
|
|
16
|
+
return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { "data-ui": "topbar", 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", { "data-ui": "topbar.brand", className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: ["logo" in brand && brand.logo !== undefined ? (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-sm) shrink-0" })) : 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", { "data-ui": "topbar.menus", 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, current: m.id === currentMenu, ...(m.layout === undefined ? {} : { layout: m.layout }), ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { "data-ui": "topbar.actions", 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 }) }))] })] }) }));
|
|
16
17
|
}
|
|
17
18
|
/** The app switcher: a grid, not a list.
|
|
18
19
|
*
|
|
@@ -25,12 +26,12 @@ export function AppSwitcher({ apps, current, onSelect, }) {
|
|
|
25
26
|
const copy = useUiCopy();
|
|
26
27
|
return (_jsxs("div", { className: "relative shrink-0", children: [_jsx("button", { type: "button", onClick: () => setOpen((v) => !v), "aria-expanded": open, "aria-haspopup": "menu", "aria-label": copy.shell.modules, title: copy.shell.modules, className: `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 ${open
|
|
27
28
|
? "bg-chrome-ink/12 text-chrome-ink"
|
|
28
|
-
: "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: _jsx(Grid3x3, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), !open ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40", onClick: () => setOpen(false), role: "presentation" }), _jsx("div", { role: "menu", className: "absolute top-full left-0 z-50 mt-1 grid w-(--container-apps) grid-cols-3 gap-1 rounded-
|
|
29
|
+
: "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: _jsx(Grid3x3, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), !open ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40", onClick: () => setOpen(false), role: "presentation" }), _jsx("div", { role: "menu", className: "absolute top-full left-0 z-50 mt-1 grid w-(--container-apps) grid-cols-3 gap-1 rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", children: apps.map((a) => {
|
|
29
30
|
const here = a.id === current;
|
|
30
31
|
return (_jsxs("button", { type: "button", role: "menuitem", title: a.hint, onClick: () => {
|
|
31
32
|
onSelect?.(a.id);
|
|
32
33
|
setOpen(false);
|
|
33
|
-
}, className: `flex flex-col items-center gap-1.5 rounded-
|
|
34
|
+
}, className: `flex flex-col items-center gap-1.5 rounded-control 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));
|
|
34
35
|
}) })] }))] }));
|
|
35
36
|
}
|
|
36
37
|
/** A badge over an icon is read in a glance: past two digits it says «a lot». */
|
|
@@ -54,5 +55,5 @@ export function SystrayButton({ icon: Icon, label, count = 0, tone = "info", onC
|
|
|
54
55
|
* only the avatar stays, which is what gets recognised without reading. */
|
|
55
56
|
export function UserMenu({ name, detail, groups, onSelect, }) {
|
|
56
57
|
const copy = useUiCopy();
|
|
57
|
-
return (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pl-1", children: [_jsx(Avatar, { name: name, size: "md" }), _jsxs("span", { className: "hidden min-w-0 flex-col leading-tight sm:flex", children: [_jsx("span", { className: "truncate text-meta text-chrome-ink", children: name }), detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-chrome-muted", children: detail }))] }), _jsx(Menu, { label: copy.shell.account, groups: groups, surface: "chrome", variant: "text", align: "end", iconOnly: true, ...(onSelect === undefined ? {} : { onSelect }) })] }));
|
|
58
|
+
return (_jsxs("span", { "data-ui": "topbar.user", className: "flex shrink-0 items-center gap-2 pl-1", children: [_jsx(Avatar, { name: name, size: "md" }), _jsxs("span", { className: "hidden min-w-0 flex-col leading-tight sm:flex", children: [_jsx("span", { className: "truncate text-meta text-chrome-ink", children: name }), detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-chrome-muted", children: detail }))] }), _jsx(Menu, { label: copy.shell.account, groups: groups, surface: "chrome", variant: "text", align: "end", iconOnly: true, ...(onSelect === undefined ? {} : { onSelect }) })] }));
|
|
58
59
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A product's mark: the URL of an image, or an element drawn inline.
|
|
4
|
+
*
|
|
5
|
+
* Context: an image paints with the colours baked into its file, so it cannot follow the
|
|
6
|
+
* theme nor the surface it sits on — a navy crest disappears on a navy sidebar and glares in
|
|
7
|
+
* the dark theme. An inline `<svg>` that paints with `currentColor` or the tokens
|
|
8
|
+
* (`var(--color-chrome-accent)`) follows both. A string stays a URL, so `logo: "/logo.svg"`
|
|
9
|
+
* keeps working.
|
|
10
|
+
*/
|
|
11
|
+
export type BrandLogo = string | ReactElement;
|
|
12
|
+
/** Draws a `BrandLogo` in a box the host sizes. Decorative: the product's name is written
|
|
13
|
+
* beside it, and saying it twice is noise for a screen reader. */
|
|
14
|
+
export declare function BrandMark({ logo, className }: {
|
|
15
|
+
logo: BrandLogo;
|
|
16
|
+
className: string;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/** Draws a `BrandLogo` in a box the host sizes. Decorative: the product's name is written
|
|
3
|
+
* beside it, and saying it twice is noise for a screen reader. */
|
|
4
|
+
export function BrandMark({ logo, className }) {
|
|
5
|
+
if (typeof logo === "string") {
|
|
6
|
+
return _jsx("img", { src: logo, alt: "", className: `${className} object-contain` });
|
|
7
|
+
}
|
|
8
|
+
return (_jsx("span", { "aria-hidden": true, className: `${className} flex items-center justify-center *:size-full`, children: logo }));
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AppFrame } from "./AppFrame.js";
|
|
2
|
+
export { type BrandLogo } from "./brandMark.js";
|
|
2
3
|
export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
|
|
3
4
|
export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
4
5
|
export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* THE APPLICATION FRAME — what sits above every view. */
|
|
2
2
|
export { AppFrame } from "./AppFrame.js";
|
|
3
|
+
/* A product's mark: an image's URL, or an inline <svg> that paints with the tokens. */
|
|
4
|
+
export {} from "./brandMark.js";
|
|
3
5
|
/* The whole chrome in one column, for a back office with no bar on top. */
|
|
4
6
|
export { Sidebar, } from "./Sidebar.js";
|
|
5
7
|
/* The sidebar's phone drawer, for a bar an application writes itself. */
|
|
@@ -180,9 +180,9 @@ export const SPANISH_COPY = {
|
|
|
180
180
|
askOp: "comparado cómo",
|
|
181
181
|
askJoin: "tienen que coincidir",
|
|
182
182
|
askValue: "contra qué",
|
|
183
|
-
filters: "
|
|
184
|
-
groupBy: "
|
|
185
|
-
favorites: "
|
|
183
|
+
filters: "Filtros",
|
|
184
|
+
groupBy: "Agrupar por",
|
|
185
|
+
favorites: "Favoritos",
|
|
186
186
|
unreadable: "No podemos leer este filtro como árbol — así es como queda. Se puede seguir editando en el JSON de abajo.",
|
|
187
187
|
},
|
|
188
188
|
ops: {
|
package/dist/foundations/copy.js
CHANGED
|
@@ -143,9 +143,9 @@ export const ENGLISH_COPY = {
|
|
|
143
143
|
condition: "{field} {op} {value}",
|
|
144
144
|
andMore: "and {count} more",
|
|
145
145
|
placeholder: "search…",
|
|
146
|
-
filters: "
|
|
147
|
-
groupBy: "
|
|
148
|
-
favorites: "
|
|
146
|
+
filters: "Filters",
|
|
147
|
+
groupBy: "Group by",
|
|
148
|
+
favorites: "Favorites",
|
|
149
149
|
},
|
|
150
150
|
failed: {
|
|
151
151
|
operation: "We could not complete the operation",
|
|
@@ -15,8 +15,25 @@ const twMergeConfig = {
|
|
|
15
15
|
extend: {
|
|
16
16
|
theme: {
|
|
17
17
|
text: ["micro", "meta", "body", "lead", "title", "display"],
|
|
18
|
-
radius: [
|
|
19
|
-
|
|
18
|
+
radius: [
|
|
19
|
+
"mark",
|
|
20
|
+
"control",
|
|
21
|
+
"box",
|
|
22
|
+
"panel",
|
|
23
|
+
"pill",
|
|
24
|
+
/* The component tokens (`tokens.css`, `@theme inline`). */
|
|
25
|
+
"ui-button",
|
|
26
|
+
"ui-icon-button",
|
|
27
|
+
"ui-control",
|
|
28
|
+
"ui-popover",
|
|
29
|
+
"ui-option",
|
|
30
|
+
"ui-dialog",
|
|
31
|
+
"ui-card",
|
|
32
|
+
"ui-tag",
|
|
33
|
+
"ui-search",
|
|
34
|
+
"ui-nav",
|
|
35
|
+
],
|
|
36
|
+
shadow: ["raised", "float", "window", "ui-popover"],
|
|
20
37
|
},
|
|
21
38
|
},
|
|
22
39
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Tag } from "../tag/Tag.js";
|
|
3
3
|
export function Block({ title, count, aside, actions, status, flush = false, children, }) {
|
|
4
4
|
const withHeader = title !== undefined || actions !== undefined || status !== undefined;
|
|
5
|
-
return (_jsxs("section", { className: "min-w-0 rounded-
|
|
5
|
+
return (_jsxs("section", { "data-ui": "block", className: "min-w-0 rounded-ui-card border border-ui-card-border bg-ui-card", children: [!withHeader ? null : (_jsxs("header", { className: "flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-1 border-b border-line px-3 py-2", children: [title === undefined ? null : (_jsx(SectionHeader, { title: title, count: count, aside: aside })), status === undefined ? null : (_jsx(Tag, { tone: status.tone ?? "neutral", children: status.label })), actions === undefined ? null : (_jsx("div", { className: "ml-auto flex flex-wrap items-center gap-1", children: actions }))] })), _jsx("div", { className: flush ? "" : "px-3 py-2.5", children: children })] }));
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* A cut in the page: between two groups of fields, or between a sheet of
|
|
@@ -31,7 +31,9 @@ export type ButtonPopup = "menu" | "dialog" | "listbox";
|
|
|
31
31
|
*
|
|
32
32
|
* What stays out on purpose: `className` and `style` — the look is the role, the size and
|
|
33
33
|
* the surface, and a primitive that takes classes from outside stops being the one place
|
|
34
|
-
* where a button is decided
|
|
34
|
+
* where a button is decided. An application changes it through its tokens
|
|
35
|
+
* (`--ui-button-radius`) and its part (`data-ui="button"`, `data-emphasis`), which keep
|
|
36
|
+
* every button of the product changing together; `role`, because here it is the button's ROLE in the hierarchy
|
|
35
37
|
* (`primary`…), not an ARIA role; and the attributes the props below already own. */
|
|
36
38
|
type NativeProps<E extends "button" | "a", Own extends string> = Omit<ComponentPropsWithRef<E>, "children" | "className" | "style" | "role" | Own>;
|
|
37
39
|
export type ButtonProps = NativeProps<"button", "type" | "disabled" | "title" | "aria-haspopup" | "aria-expanded"> & {
|
|
@@ -129,7 +129,7 @@ const ROLE = {
|
|
|
129
129
|
* with «+ Crear», which was the only primary button in the product with a
|
|
130
130
|
* different height. */
|
|
131
131
|
export function buttonClasses(role = "secondary", size = "md", surface = "canvas") {
|
|
132
|
-
return `inline-flex shrink-0 items-center justify-center rounded-
|
|
132
|
+
return `inline-flex shrink-0 items-center justify-center rounded-ui-button whitespace-nowrap transition-[background-color,border-color,filter,color] duration-(--duration-instant) ease-(--ease-out) disabled:pointer-events-none disabled:opacity-45 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${SIZE[size]} ${WEIGHT[role]} ${ROLE[role][surface]}`;
|
|
133
133
|
}
|
|
134
134
|
const ICON = {
|
|
135
135
|
sm: { size: "size-(--size-icon-sm)", stroke: 2 },
|
|
@@ -157,7 +157,7 @@ export function Button({ children, role = "secondary", size = "md", surface: sur
|
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
onClick?.(event);
|
|
160
|
-
}, ...popupAttrs(expanded, haspopup), "data-emphasis": role, className: busy
|
|
160
|
+
}, ...popupAttrs(expanded, haspopup), "data-ui": "button", "data-emphasis": role, "data-size": size, "data-surface": surface, className: busy
|
|
161
161
|
? `${buttonClasses(role, size, surface)} cursor-progress`
|
|
162
162
|
: buttonClasses(role, size, surface), children: [Mark === undefined ? null : (_jsx(Mark, { className: `${ic.size} shrink-0 ${busy ? "motion-safe:animate-spin" : ""}`, strokeWidth: ic.stroke, "aria-hidden": true })), children] }));
|
|
163
163
|
}
|
|
@@ -177,7 +177,7 @@ export function Button({ children, role = "secondary", size = "md", surface: sur
|
|
|
177
177
|
export function ButtonLink({ children, href, role = "secondary", size = "md", surface: surfaceProp, icon: Icon, download, title, ref, ...native }) {
|
|
178
178
|
const surface = useSurface(surfaceProp);
|
|
179
179
|
const ic = ICON[size];
|
|
180
|
-
return (_jsxs("a", { ...native, ref: ref, "data-emphasis": role, href: href, title: title, ...(download === undefined ? {} : { download }), className: `${buttonClasses(role, size, surface)} no-underline`, children: [Icon === undefined ? null : (_jsx(Icon, { className: `${ic.size} shrink-0`, strokeWidth: ic.stroke, "aria-hidden": true })), children] }));
|
|
180
|
+
return (_jsxs("a", { ...native, ref: ref, "data-ui": "button", "data-emphasis": role, "data-size": size, "data-surface": surface, href: href, title: title, ...(download === undefined ? {} : { download }), className: `${buttonClasses(role, size, surface)} no-underline`, children: [Icon === undefined ? null : (_jsx(Icon, { className: `${ic.size} shrink-0`, strokeWidth: ic.stroke, "aria-hidden": true })), children] }));
|
|
181
181
|
}
|
|
182
182
|
/** Outside the component because the button and the link share it: the same
|
|
183
183
|
* icon has to look the same whether it leads to an action or to a file. */
|
|
@@ -197,7 +197,7 @@ const TONE = {
|
|
|
197
197
|
};
|
|
198
198
|
/* `aria-pressed` is a TOGGLE's state — bold on, a filter applied: it reads as the action
|
|
199
199
|
tint, the same as a chosen option, so «on» is seen and not only heard. */
|
|
200
|
-
const BOX = "inline-flex shrink-0 items-center justify-center rounded-
|
|
200
|
+
const BOX = "inline-flex shrink-0 items-center justify-center rounded-ui-icon-button transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-pressed:bg-primary/12 aria-pressed:text-primary";
|
|
201
201
|
const SQUARE = {
|
|
202
202
|
sm: "size-(--size-control-sm)",
|
|
203
203
|
md: "size-(--size-control-md)",
|
|
@@ -229,7 +229,7 @@ function Labelled({ label, tooltip, children, }) {
|
|
|
229
229
|
export function IconButton({ icon: Icon, label, size = "sm", surface: surfaceProp, tone = "normal", disabled = false, type = "button", expanded, haspopup, tooltip = true, ref, ...native }) {
|
|
230
230
|
const surface = useSurface(surfaceProp);
|
|
231
231
|
const ic = ICON[size];
|
|
232
|
-
return (_jsx(Labelled, { label: label, tooltip: tooltip, children: (title) => (_jsx("button", { ...native, ref: ref, type: type, title: title, "aria-label": label, disabled: disabled, ...popupAttrs(expanded, haspopup), className: `${BOX} disabled:pointer-events-none disabled:opacity-45 ${SQUARE[size]} ${TONE[tone][surface]}`, children: _jsx(Icon, { className: ic.size, strokeWidth: ic.stroke, "aria-hidden": true }) })) }));
|
|
232
|
+
return (_jsx(Labelled, { label: label, tooltip: tooltip, children: (title) => (_jsx("button", { ...native, ref: ref, type: type, title: title, "aria-label": label, disabled: disabled, ...popupAttrs(expanded, haspopup), "data-ui": "icon-button", "data-tone": tone, "data-size": size, "data-surface": surface, className: `${BOX} disabled:pointer-events-none disabled:opacity-45 ${SQUARE[size]} ${TONE[tone][surface]}`, children: _jsx(Icon, { className: ic.size, strokeWidth: ic.stroke, "aria-hidden": true }) })) }));
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* The same icon, but it is a real link.
|
|
@@ -242,5 +242,5 @@ export function IconButton({ icon: Icon, label, size = "sm", surface: surfacePro
|
|
|
242
242
|
export function IconLink({ icon: Icon, label, href, download, size = "sm", surface: surfaceProp, tone = "action", tooltip = true, ref, ...native }) {
|
|
243
243
|
const surface = useSurface(surfaceProp);
|
|
244
244
|
const ic = ICON[size];
|
|
245
|
-
return (_jsx(Labelled, { label: label, tooltip: tooltip, children: (title) => (_jsx("a", { ...native, ref: ref, href: href, ...(download === undefined ? {} : { download }), title: title, "aria-label": label, className: `${BOX} ${SQUARE[size]} ${TONE[tone][surface]}`, children: _jsx(Icon, { className: ic.size, strokeWidth: ic.stroke, "aria-hidden": true }) })) }));
|
|
245
|
+
return (_jsx(Labelled, { label: label, tooltip: tooltip, children: (title) => (_jsx("a", { ...native, ref: ref, href: href, ...(download === undefined ? {} : { download }), title: title, "aria-label": label, "data-ui": "icon-button", "data-tone": tone, "data-size": size, "data-surface": surface, className: `${BOX} ${SQUARE[size]} ${TONE[tone][surface]}`, children: _jsx(Icon, { className: ic.size, strokeWidth: ic.stroke, "aria-hidden": true }) })) }));
|
|
246
246
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type FormMode } from "../../foundations/form.js";
|
|
2
|
+
import type { Surface } from "../../foundations/types.js";
|
|
2
3
|
import { type SegmentOption } from "./options.js";
|
|
3
4
|
export type SegmentedControlProps = {
|
|
4
5
|
value: string;
|
|
@@ -12,5 +13,7 @@ export type SegmentedControlProps = {
|
|
|
12
13
|
mode?: FormMode;
|
|
13
14
|
/** The name of the group when it is not inside a `Field` — "Período". */
|
|
14
15
|
"aria-label"?: string;
|
|
16
|
+
/** By default it inherits it from the surface that wraps it. */
|
|
17
|
+
surface?: Surface;
|
|
15
18
|
};
|
|
16
|
-
export declare function SegmentedControl({ value, onChange, options, size, disabled, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, }: SegmentedControlProps): import("react").JSX.Element;
|
|
19
|
+
export declare function SegmentedControl({ value, onChange, options, size, disabled, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, surface, }: SegmentedControlProps): import("react").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { controlName, useFieldIds } from "../../foundations/form.js";
|
|
4
4
|
import { useFormMode } from "../../foundations/form.js";
|
|
5
|
+
import { useSurface } from "../../foundations/surface.js";
|
|
5
6
|
import { tv } from "../../foundations/variants.js";
|
|
6
7
|
import { labelOf } from "./options.js";
|
|
7
8
|
import { ReadValue } from "../field/Field.js";
|
|
@@ -20,25 +21,36 @@ import { ToggleButton, ToggleButtonGroup } from "react-aria-components";
|
|
|
20
21
|
* instead (the kind of a contact: Persona · Empresa), and then it follows the form: in read
|
|
21
22
|
* mode it draws the chosen label.
|
|
22
23
|
*/
|
|
24
|
+
/* On the chrome (the `ThemeSwitcher` at the foot of a sidebar in the brand's colour) the
|
|
25
|
+
control speaks the chrome's palette: a white box on the navy was the mix the surface
|
|
26
|
+
context exists to prevent. The hairline is ink at 25 %, the selection ink at 15 %. */
|
|
23
27
|
const group = tv({
|
|
24
|
-
base: "inline-flex w-fit max-w-full min-w-0 shrink-0 items-stretch overflow-hidden rounded-control border
|
|
28
|
+
base: "inline-flex w-fit max-w-full min-w-0 shrink-0 items-stretch overflow-hidden rounded-control border forced-colors:border-[ButtonBorder]",
|
|
25
29
|
variants: {
|
|
26
30
|
size: {
|
|
27
31
|
sm: "h-(--size-control-sm)",
|
|
28
32
|
md: "h-(--size-control-md)",
|
|
29
33
|
},
|
|
34
|
+
surface: {
|
|
35
|
+
canvas: "border-line-strong bg-surface",
|
|
36
|
+
chrome: "border-chrome-ink/25 bg-chrome-ink/6",
|
|
37
|
+
},
|
|
30
38
|
},
|
|
31
39
|
});
|
|
32
40
|
const segment = tv({
|
|
33
|
-
base: "inline-flex min-w-0 cursor-pointer items-center justify-center gap-1.5 border-l
|
|
41
|
+
base: "inline-flex min-w-0 cursor-pointer items-center justify-center gap-1.5 border-l text-meta whitespace-nowrap transition-colors duration-(--duration-instant) outline-0 first:border-l-0 forced-color-adjust-none forced-colors:border-[ButtonBorder]",
|
|
34
42
|
variants: {
|
|
35
43
|
size: {
|
|
36
44
|
sm: "px-2.5",
|
|
37
45
|
md: "px-3.5",
|
|
38
46
|
},
|
|
47
|
+
surface: {
|
|
48
|
+
canvas: "border-line-strong",
|
|
49
|
+
chrome: "border-chrome-ink/25",
|
|
50
|
+
},
|
|
39
51
|
isSelected: {
|
|
40
|
-
false: "
|
|
41
|
-
true: "
|
|
52
|
+
false: "",
|
|
53
|
+
true: "forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
|
|
42
54
|
},
|
|
43
55
|
isFocusVisible: {
|
|
44
56
|
true: "outline-2 -outline-offset-2 outline-primary forced-colors:outline-[Highlight]",
|
|
@@ -47,8 +59,24 @@ const segment = tv({
|
|
|
47
59
|
true: "cursor-not-allowed opacity-45",
|
|
48
60
|
},
|
|
49
61
|
},
|
|
62
|
+
compoundVariants: [
|
|
63
|
+
{
|
|
64
|
+
surface: "canvas",
|
|
65
|
+
isSelected: false,
|
|
66
|
+
class: "bg-surface text-muted hover:bg-ink/5 hover:text-ink pressed:bg-ink/10",
|
|
67
|
+
},
|
|
68
|
+
{ surface: "canvas", isSelected: true, class: "bg-ink/8 text-ink" },
|
|
69
|
+
{
|
|
70
|
+
surface: "chrome",
|
|
71
|
+
isSelected: false,
|
|
72
|
+
class: "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink pressed:bg-chrome-ink/15",
|
|
73
|
+
},
|
|
74
|
+
{ surface: "chrome", isSelected: true, class: "bg-chrome-ink/15 text-chrome-ink" },
|
|
75
|
+
{ surface: "chrome", isFocusVisible: true, class: "outline-chrome-link" },
|
|
76
|
+
],
|
|
50
77
|
});
|
|
51
|
-
export function SegmentedControl({ value, onChange, options, size = "md", disabled = false, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, }) {
|
|
78
|
+
export function SegmentedControl({ value, onChange, options, size = "md", disabled = false, describedBy: ownDescribedBy, mode, "aria-label": ariaLabel, surface, }) {
|
|
79
|
+
const sup = useSurface(surface);
|
|
52
80
|
/* No `id`: a group of buttons is not something a `<label for>` can point at; the field
|
|
53
81
|
names it through `aria-labelledby`. */
|
|
54
82
|
const { labelledBy, describedBy } = useFieldIds({ describedBy: ownDescribedBy });
|
|
@@ -62,8 +90,8 @@ export function SegmentedControl({ value, onChange, options, size = "md", disabl
|
|
|
62
90
|
const [next] = keys;
|
|
63
91
|
if (next !== undefined && String(next) !== value)
|
|
64
92
|
onChange?.(String(next));
|
|
65
|
-
}, isDisabled: disabled, className: group({ size }), children: options.map((o) => {
|
|
93
|
+
}, isDisabled: disabled, className: group({ size, surface: sup }), children: options.map((o) => {
|
|
66
94
|
const Icon = o.icon;
|
|
67
|
-
return (_jsxs(ToggleButton, { id: o.value, isDisabled: o.disabled, className: (state) => segment({ ...state, size }), children: [Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0", strokeWidth: 2 })), o.label] }, o.value));
|
|
95
|
+
return (_jsxs(ToggleButton, { id: o.value, isDisabled: o.disabled, className: (state) => segment({ ...state, size, surface: sup }), children: [Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0", strokeWidth: 2 })), o.label] }, o.value));
|
|
68
96
|
}) }));
|
|
69
97
|
}
|
|
@@ -33,7 +33,7 @@ export declare const dialogStyles: {
|
|
|
33
33
|
isExiting: {
|
|
34
34
|
true: string;
|
|
35
35
|
};
|
|
36
|
-
}, undefined, "flex max-h-full w-full flex-col overflow-hidden rounded-
|
|
36
|
+
}, undefined, "flex max-h-full w-full flex-col overflow-hidden rounded-ui-dialog border border-line-strong bg-ui-dialog text-ink shadow-window outline-0 transition-[opacity,translate] duration-(--duration-panel) ease-(--ease-out) forced-colors:bg-[Canvas] max-sm:max-h-(--size-sheet) max-sm:max-w-none max-sm:rounded-b-none max-sm:border-x-0 max-sm:border-b-0", undefined, undefined, undefined>;
|
|
37
37
|
};
|
|
38
38
|
export type DialogWidth = "sm" | "md" | "lg";
|
|
39
39
|
export interface DialogProps {
|