@sincpro/web-ui 2.2.0 → 2.4.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 +113 -3
- package/dist/components/board/Board.js +1 -1
- package/dist/components/guide/Guide.d.ts +33 -0
- package/dist/components/guide/Guide.js +288 -0
- package/dist/components/guide/GuideSpot.d.ts +14 -0
- package/dist/components/guide/GuideSpot.js +13 -0
- package/dist/components/guide/index.d.ts +4 -0
- package/dist/components/guide/index.js +6 -0
- package/dist/components/guide/place.d.ts +44 -0
- package/dist/components/guide/place.js +69 -0
- package/dist/components/guide/target.d.ts +41 -0
- package/dist/components/guide/target.js +55 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/listing/GroupingLevels.js +11 -9
- package/dist/components/listing/Listing.js +7 -5
- package/dist/components/listing/RecordCard.js +1 -1
- package/dist/components/listing/Row.js +8 -7
- package/dist/components/navigation/NavigationTree.js +36 -9
- package/dist/components/record/DirtyActions.d.ts +9 -7
- package/dist/components/record/DirtyActions.js +14 -9
- package/dist/components/record/ThumbBar.js +2 -1
- 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/SearchEntry.d.ts +29 -0
- package/dist/components/shell/SearchEntry.js +34 -0
- package/dist/components/shell/Sidebar.d.ts +12 -3
- package/dist/components/shell/Sidebar.js +38 -12
- package/dist/components/shell/TopBar.d.ts +12 -1
- package/dist/components/shell/TopBar.js +7 -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 +2 -0
- package/dist/components/shell/index.js +5 -0
- package/dist/foundations/copy.d.ts +19 -2
- package/dist/foundations/copy.es.js +13 -3
- package/dist/foundations/copy.js +13 -3
- package/dist/foundations/index.d.ts +1 -0
- package/dist/foundations/index.js +2 -0
- package/dist/foundations/shortcut.d.ts +18 -0
- package/dist/foundations/shortcut.js +20 -0
- 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.d.ts +5 -1
- package/dist/primitives/value/Metric.js +8 -6
- package/dist/tokens.css +202 -56
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
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";
|
|
4
|
+
export { SearchEntry, type SearchEntryProps, } from "./SearchEntry.js";
|
|
3
5
|
export { type SidebarDrawer, SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
4
6
|
export { type AppEntry, SystrayButton, TopBar, type TopMenu, } from "./TopBar.js";
|
|
5
7
|
export { Pane, Panes } from "./Panes.js";
|
|
@@ -1,7 +1,12 @@
|
|
|
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";
|
|
7
|
+
/* The way into the application's palette, drawn: «Buscar… ⌘K». The sidebar and the bar draw
|
|
8
|
+
it from their `search`; on its own, for any other place. */
|
|
9
|
+
export { SearchEntry, } from "./SearchEntry.js";
|
|
5
10
|
/* The sidebar's phone drawer, for a bar an application writes itself. */
|
|
6
11
|
export { SidebarToggle, useSidebarDrawer, } from "./sidebarDrawer.js";
|
|
7
12
|
export { SystrayButton, TopBar, } from "./TopBar.js";
|
|
@@ -68,9 +68,10 @@ export type UiCopy = {
|
|
|
68
68
|
location: string;
|
|
69
69
|
status: string;
|
|
70
70
|
faces: string;
|
|
71
|
-
/**
|
|
71
|
+
/** @deprecated Not drawn since 2.4: the Save and Discard buttons already say it. Kept so
|
|
72
|
+
* a copy table written for an earlier version still type-checks. */
|
|
72
73
|
unsaved: string;
|
|
73
|
-
/**
|
|
74
|
+
/** How many fields changed — the Save button's description, for a screen reader. */
|
|
74
75
|
unsavedOne: string;
|
|
75
76
|
unsavedMany: string;
|
|
76
77
|
save: string;
|
|
@@ -108,6 +109,22 @@ export type UiCopy = {
|
|
|
108
109
|
openNavigation: string;
|
|
109
110
|
/** The drawer's name: what a screen reader hears when it opens. */
|
|
110
111
|
navigation: string;
|
|
112
|
+
/** The way into the application's palette, in the sidebar or the bar. */
|
|
113
|
+
search: string;
|
|
114
|
+
};
|
|
115
|
+
/** A guided tour (`Guide`). */
|
|
116
|
+
guide: {
|
|
117
|
+
/** The tour's name when the application gives none. */
|
|
118
|
+
label: string;
|
|
119
|
+
/** «2 de 5»: `{current}` and `{total}`. */
|
|
120
|
+
progress: string;
|
|
121
|
+
/** What a screen reader hears on each step: `{progress}` and `{title}`. */
|
|
122
|
+
step: string;
|
|
123
|
+
next: string;
|
|
124
|
+
back: string;
|
|
125
|
+
skip: string;
|
|
126
|
+
/** The last step's button, in place of «next». */
|
|
127
|
+
finish: string;
|
|
111
128
|
};
|
|
112
129
|
field: {
|
|
113
130
|
drop: string;
|
|
@@ -99,6 +99,16 @@ export const SPANISH_COPY = {
|
|
|
99
99
|
openAsPanel: "Abrir como panel",
|
|
100
100
|
openNavigation: "Abrir la navegación",
|
|
101
101
|
navigation: "Navegación",
|
|
102
|
+
search: "Buscar…",
|
|
103
|
+
},
|
|
104
|
+
guide: {
|
|
105
|
+
label: "Recorrido",
|
|
106
|
+
progress: "{current} de {total}",
|
|
107
|
+
step: "{progress}: {title}",
|
|
108
|
+
next: "Siguiente",
|
|
109
|
+
back: "Atrás",
|
|
110
|
+
skip: "Saltar el recorrido",
|
|
111
|
+
finish: "Terminar",
|
|
102
112
|
},
|
|
103
113
|
field: {
|
|
104
114
|
drop: "Soltá un archivo acá, o elegí uno.",
|
|
@@ -180,9 +190,9 @@ export const SPANISH_COPY = {
|
|
|
180
190
|
askOp: "comparado cómo",
|
|
181
191
|
askJoin: "tienen que coincidir",
|
|
182
192
|
askValue: "contra qué",
|
|
183
|
-
filters: "
|
|
184
|
-
groupBy: "
|
|
185
|
-
favorites: "
|
|
193
|
+
filters: "Filtros",
|
|
194
|
+
groupBy: "Agrupar por",
|
|
195
|
+
favorites: "Favoritos",
|
|
186
196
|
unreadable: "No podemos leer este filtro como árbol — así es como queda. Se puede seguir editando en el JSON de abajo.",
|
|
187
197
|
},
|
|
188
198
|
ops: {
|
package/dist/foundations/copy.js
CHANGED
|
@@ -75,6 +75,16 @@ export const ENGLISH_COPY = {
|
|
|
75
75
|
openAsPanel: "Open as panel",
|
|
76
76
|
openNavigation: "Open the navigation",
|
|
77
77
|
navigation: "Navigation",
|
|
78
|
+
search: "Search…",
|
|
79
|
+
},
|
|
80
|
+
guide: {
|
|
81
|
+
label: "Guided tour",
|
|
82
|
+
progress: "{current} of {total}",
|
|
83
|
+
step: "{progress}: {title}",
|
|
84
|
+
next: "Next",
|
|
85
|
+
back: "Back",
|
|
86
|
+
skip: "Skip the tour",
|
|
87
|
+
finish: "Done",
|
|
78
88
|
},
|
|
79
89
|
field: {
|
|
80
90
|
drop: "Drop a file here, or choose one.",
|
|
@@ -143,9 +153,9 @@ export const ENGLISH_COPY = {
|
|
|
143
153
|
condition: "{field} {op} {value}",
|
|
144
154
|
andMore: "and {count} more",
|
|
145
155
|
placeholder: "search…",
|
|
146
|
-
filters: "
|
|
147
|
-
groupBy: "
|
|
148
|
-
favorites: "
|
|
156
|
+
filters: "Filters",
|
|
157
|
+
groupBy: "Group by",
|
|
158
|
+
favorites: "Favorites",
|
|
149
159
|
},
|
|
150
160
|
failed: {
|
|
151
161
|
operation: "We could not complete the operation",
|
|
@@ -2,6 +2,7 @@ export { type CopyCatalog, type CopyOverride, createCopy, mergeCopyOver, } from
|
|
|
2
2
|
export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, mergeCopy, type UiCopy, type UiCopyOverride, UiCopyProvider, useUiCopy, } from "./copy.js";
|
|
3
3
|
export { byDensity, type Density, DensityProvider, useDensity, } from "./density.js";
|
|
4
4
|
export { controlName, FieldBoundary, type FieldIds, type FormMode, FormModeProvider, useFieldIds, useFormMode, } from "./form.js";
|
|
5
|
+
export { type KeyboardPlatform, type ModShortcut, modShortcut, useKeyboardPlatform, } from "./shortcut.js";
|
|
5
6
|
export { bySurface, SurfaceProvider, useSurface } from "./surface.js";
|
|
6
7
|
export { applyTheme, isTheme, type ResolvedTheme, resolveTheme, type Theme, THEME_ATTRIBUTE, ThemeProvider, type ThemeProviderProps, THEMES, useTheme, } from "./theme.js";
|
|
7
8
|
export type { OpenTarget, Size, Surface, Tone } from "./types.js";
|
|
@@ -6,6 +6,8 @@ export { byDensity, DensityProvider, useDensity, } from "./density.js";
|
|
|
6
6
|
/* A CONTROL'S CONTRACT — the ids its `Field` gives it and whether it is viewed or written. The
|
|
7
7
|
package's controls and the application's speak it alike. */
|
|
8
8
|
export { controlName, FieldBoundary, FormModeProvider, useFieldIds, useFormMode, } from "./form.js";
|
|
9
|
+
/* A SHORTCUT, drawn the way the person's keyboard says it: «⌘K» on a Mac, «Ctrl K» elsewhere. */
|
|
10
|
+
export { modShortcut, useKeyboardPlatform, } from "./shortcut.js";
|
|
9
11
|
/* THE THEME — light, dark or the operating system's. The palettes live in `tokens.css`; this
|
|
10
12
|
only writes `data-theme`. */
|
|
11
13
|
export { bySurface, SurfaceProvider, useSurface } from "./surface.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context: a shortcut is drawn the way the person's keyboard says it — «⌘K» on a Mac, «Ctrl K»
|
|
3
|
+
* everywhere else. A «Ctrl K» on a Mac is a shortcut that does not work, and people stop
|
|
4
|
+
* reading the others. Only the browser knows the platform: on the server and while hydrating
|
|
5
|
+
* it is `null`, and the shortcut appears right after instead of being drawn wrong and
|
|
6
|
+
* corrected in front of the person.
|
|
7
|
+
*/
|
|
8
|
+
export type KeyboardPlatform = "apple" | "other";
|
|
9
|
+
/** The keyboard the page is being used with; `null` on the server and while hydrating. */
|
|
10
|
+
export declare function useKeyboardPlatform(): KeyboardPlatform | null;
|
|
11
|
+
export type ModShortcut = {
|
|
12
|
+
/** What is drawn: «⌘K», «Ctrl K». */
|
|
13
|
+
label: string;
|
|
14
|
+
/** For `aria-keyshortcuts`: «Meta+K», «Control+K». */
|
|
15
|
+
aria: string;
|
|
16
|
+
};
|
|
17
|
+
/** The platform's command key with `key`: ⌘ on a Mac, Ctrl elsewhere. */
|
|
18
|
+
export declare function modShortcut(key: string, platform: KeyboardPlatform): ModShortcut;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
function readPlatform() {
|
|
4
|
+
const nav = navigator;
|
|
5
|
+
/* `userAgentData` where there is one (Chromium); `platform` is deprecated but it is the
|
|
6
|
+
only answer Safari and Firefox give. */
|
|
7
|
+
const name = nav.userAgentData?.platform ?? nav.platform;
|
|
8
|
+
return /mac|iphone|ipad|ipod/i.test(name) ? "apple" : "other";
|
|
9
|
+
}
|
|
10
|
+
const unchanging = () => () => { };
|
|
11
|
+
/** The keyboard the page is being used with; `null` on the server and while hydrating. */
|
|
12
|
+
export function useKeyboardPlatform() {
|
|
13
|
+
return useSyncExternalStore(unchanging, readPlatform, () => null);
|
|
14
|
+
}
|
|
15
|
+
/** The platform's command key with `key`: ⌘ on a Mac, Ctrl elsewhere. */
|
|
16
|
+
export function modShortcut(key, platform) {
|
|
17
|
+
return platform === "apple"
|
|
18
|
+
? { label: `⌘${key}`, aria: `Meta+${key}` }
|
|
19
|
+
: { label: `Ctrl ${key}`, aria: `Control+${key}` };
|
|
20
|
+
}
|
|
@@ -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 {
|
|
@@ -23,7 +23,7 @@ const overlay = tv({
|
|
|
23
23
|
* are rounded (the bottom ones sit on the screen's edge), it stops at `--size-sheet`,
|
|
24
24
|
* and it enters from below — the motion says where it lives. */
|
|
25
25
|
const modal = tv({
|
|
26
|
-
base: "flex max-h-full w-full flex-col overflow-hidden rounded-
|
|
26
|
+
base: "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",
|
|
27
27
|
variants: {
|
|
28
28
|
width: { sm: "max-w-md", md: "max-w-2xl", lg: "max-w-4xl" },
|
|
29
29
|
isEntering: { true: "translate-y-2 opacity-0 max-sm:translate-y-full" },
|
|
@@ -97,7 +97,7 @@ export function Dialog({ open, width = "md", onClose, movable = false, ...surfac
|
|
|
97
97
|
return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
|
|
98
98
|
if (!next)
|
|
99
99
|
onClose();
|
|
100
|
-
}, isDismissable: true, className: overlay, children: _jsx(Modal, { className: (state) => modal({ ...state, width }), ...(movable
|
|
100
|
+
}, isDismissable: true, className: overlay, children: _jsx(Modal, { "data-ui": "dialog", "data-width": width, className: (state) => modal({ ...state, width }), ...(movable
|
|
101
101
|
? { style: { transform: `translate(${offset.x}px, ${offset.y}px)` } }
|
|
102
102
|
: {}), children: _jsx(DialogSurface, { onClose: onClose, ...surface, ...(movable ? { onDragStart: drag } : {}) }) }) }));
|
|
103
103
|
}
|
|
@@ -64,7 +64,7 @@ function CardDatumBox({ id: ownId, value, onChange, placeholder, describedBy: ow
|
|
|
64
64
|
describedBy: ownDescribedBy,
|
|
65
65
|
invalid: ownInvalid,
|
|
66
66
|
});
|
|
67
|
-
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: onChange, inputMode: "numeric", autoComplete: autoComplete, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ...(inputRef === undefined ? {} : { ref: inputRef }), "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
|
|
67
|
+
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: onChange, inputMode: "numeric", autoComplete: autoComplete, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ...(inputRef === undefined ? {} : { ref: inputRef }), "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, "data-ui": "control", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* The expiry of a card, «MM/AA». The value is the four digits («1228»); the slash is drawn.
|
|
@@ -6,6 +6,20 @@ export interface CheckItem {
|
|
|
6
6
|
detail?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The drawn box of a check, with no behaviour of its own.
|
|
11
|
+
*
|
|
12
|
+
* Context: exported for the rows that ARE a multiple choice without being a form input —
|
|
13
|
+
* the filters of the search panel, a grouping level — so they mark «on» with the same box
|
|
14
|
+
* as `Checkbox`. The host carries the semantics (`aria-pressed`, a listbox option); this
|
|
15
|
+
* is `aria-hidden`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CheckMark({ on, mixed, focus, invalid, }: {
|
|
18
|
+
on: boolean;
|
|
19
|
+
mixed?: boolean;
|
|
20
|
+
focus?: boolean;
|
|
21
|
+
invalid?: boolean;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
9
23
|
/**
|
|
10
24
|
* One yes/no answer of a form: «Exento de IVA», «Enviar la factura por correo al
|
|
11
25
|
* publicar».
|
|
@@ -6,7 +6,15 @@ import { useFormMode } from "../../foundations/form.js";
|
|
|
6
6
|
import { Check, Minus } from "lucide-react";
|
|
7
7
|
import { useId } from "react";
|
|
8
8
|
import { Checkbox as AriaCheckbox, ListBox, ListBoxItem, } from "react-aria-components";
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The drawn box of a check, with no behaviour of its own.
|
|
11
|
+
*
|
|
12
|
+
* Context: exported for the rows that ARE a multiple choice without being a form input —
|
|
13
|
+
* the filters of the search panel, a grouping level — so they mark «on» with the same box
|
|
14
|
+
* as `Checkbox`. The host carries the semantics (`aria-pressed`, a listbox option); this
|
|
15
|
+
* is `aria-hidden`.
|
|
16
|
+
*/
|
|
17
|
+
export function CheckMark({ on, mixed = false, focus = false, invalid = false, }) {
|
|
10
18
|
return (_jsx("span", { "aria-hidden": true, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-mark border transition-colors duration-(--duration-instant) forced-color-adjust-none ${on
|
|
11
19
|
? "border-primary bg-primary text-surface forced-colors:border-[Highlight] forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]"
|
|
12
20
|
: `bg-surface text-transparent ${invalid ? "border-danger" : "border-line-strong"} forced-colors:border-[ButtonBorder]`} ${focus ? "outline-2 outline-offset-2 outline-primary forced-colors:outline-[Highlight]" : ""}`, children: mixed ? (_jsx(Minus, { className: "size-3", strokeWidth: 2.5 })) : (_jsx(Check, { className: "size-3", strokeWidth: 2.5 })) }));
|
|
@@ -33,9 +41,9 @@ export function Checkbox({ checked, mixed = false, onChange, label, disabled = f
|
|
|
33
41
|
const textId = useId();
|
|
34
42
|
const on = checked || mixed;
|
|
35
43
|
if (useFormMode(mode) === "read") {
|
|
36
|
-
return (_jsxs("span", { className: "flex min-h-(--size-control-md) items-center gap-2 text-meta text-ink", children: [_jsx(
|
|
44
|
+
return (_jsxs("span", { className: "flex min-h-(--size-control-md) items-center gap-2 text-meta text-ink", children: [_jsx(CheckMark, { on: on, mixed: mixed && !checked }), label] }));
|
|
37
45
|
}
|
|
38
|
-
return (_jsx(AriaCheckbox, { id: id, "aria-labelledby": labelledBy === undefined ? undefined : `${labelledBy} ${textId}`, "aria-describedby": describedBy, isSelected: checked, isIndeterminate: mixed, onChange: (next) => onChange?.(mixed ? true : next), isDisabled: disabled, isInvalid: invalid, className: "group inline-flex min-w-0 cursor-pointer items-center gap-2.5 text-meta text-ink disabled:cursor-not-allowed disabled:opacity-45", children: ({ isSelected, isIndeterminate, isFocusVisible, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx(
|
|
46
|
+
return (_jsx(AriaCheckbox, { id: id, "aria-labelledby": labelledBy === undefined ? undefined : `${labelledBy} ${textId}`, "aria-describedby": describedBy, isSelected: checked, isIndeterminate: mixed, onChange: (next) => onChange?.(mixed ? true : next), isDisabled: disabled, isInvalid: invalid, className: "group inline-flex min-w-0 cursor-pointer items-center gap-2.5 text-meta text-ink disabled:cursor-not-allowed disabled:opacity-45", children: ({ isSelected, isIndeterminate, isFocusVisible, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx(CheckMark, { on: isSelected || isIndeterminate, mixed: isIndeterminate, focus: isFocusVisible, invalid: isInvalid }), _jsx("span", { id: textId, className: "min-w-0", children: label })] })) }));
|
|
39
47
|
}
|
|
40
48
|
/** The chosen values, in the order the person picked them — what `onChange` hands back. */
|
|
41
49
|
function valuesOf(keys, items) {
|
|
@@ -68,5 +76,5 @@ export function CheckList({ label, items, value, onChange, mono = false, emptyLa
|
|
|
68
76
|
}
|
|
69
77
|
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-1.5", children: [_jsx("p", { id: labelId, className: "text-micro text-muted", children: label }), _jsx(ListBox, { "aria-labelledby": labelId, "aria-describedby": describedBy, items: items, selectionMode: "multiple", selectedKeys: value, onSelectionChange: (keys) => onChange?.(valuesOf(keys, items)), disabledKeys: items.filter((item) => item.disabled).map((item) => item.value), shouldFocusWrap: true, className: "flex flex-col overflow-hidden rounded-box border border-line bg-surface outline-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", children: (item) => (_jsx(ListBoxItem, { id: item.value, textValue: item.label, className: ({ isSelected, isFocusVisible, isDisabled }) => `flex min-w-0 cursor-pointer items-center gap-2.5 border-b border-line px-3 py-2 text-left outline-0 last:border-b-0 ${isFocusVisible
|
|
70
78
|
? "outline-2 -outline-offset-2 outline-primary forced-colors:outline-[Highlight]"
|
|
71
|
-
: ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""} ${isSelected ? "bg-primary/8" : "hover:bg-ink/4"}`, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx(
|
|
79
|
+
: ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""} ${isSelected ? "bg-primary/8" : "hover:bg-ink/4"}`, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx(CheckMark, { on: isSelected }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: `truncate text-meta text-ink ${mono ? "font-mono" : ""}`, children: item.label }), item.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: item.detail }))] })] })) })) })] }));
|
|
72
80
|
}
|
|
@@ -50,5 +50,5 @@ export function DurationInput({ id: ownId, value, onChange, placeholder = "0:00"
|
|
|
50
50
|
setDraft(null);
|
|
51
51
|
onChange?.(minutes / 60);
|
|
52
52
|
};
|
|
53
|
-
return (_jsxs(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: draft ?? shown, onChange: setDraft, inputMode: "decimal", isInvalid: invalid, isDisabled: disabled, className: "flex w-full min-w-0 items-center gap-2", children: [_jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, onBlur: commit, onKeyDown: arrows, className: `${controlClasses(invalid)} tabular-nums` }), _jsx("span", { className: "shrink-0 text-meta text-muted", children: copy.field.hours })] }));
|
|
53
|
+
return (_jsxs(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: draft ?? shown, onChange: setDraft, inputMode: "decimal", isInvalid: invalid, isDisabled: disabled, className: "flex w-full min-w-0 items-center gap-2", children: [_jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, onBlur: commit, onKeyDown: arrows, "data-ui": "control", className: `${controlClasses(invalid)} tabular-nums` }), _jsx("span", { className: "shrink-0 text-meta text-muted", children: copy.field.hours })] }));
|
|
54
54
|
}
|
|
@@ -128,9 +128,9 @@ export function ReadValue({ value, mono = false }) {
|
|
|
128
128
|
* be born with another height, another radius or another focus. That was the
|
|
129
129
|
* original defect: every file wrote its own `<input className="…">`. */
|
|
130
130
|
export function controlClasses(invalid = false) {
|
|
131
|
-
return `h-(--size-control-md) w-full min-w-0 rounded-control border bg-
|
|
131
|
+
return `h-(--size-control-md) w-full min-w-0 rounded-ui-control border bg-ui-control px-2.5 text-meta text-ink transition-colors duration-(--duration-instant) placeholder:text-muted focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:bg-ground disabled:text-muted ${invalid
|
|
132
132
|
? "border-danger focus-visible:border-danger focus-visible:outline-danger"
|
|
133
|
-
: "border-
|
|
133
|
+
: "border-ui-control-border focus-visible:border-primary focus-visible:outline-primary"}`;
|
|
134
134
|
}
|
|
135
135
|
/* `aria-describedby` goes on the INPUT and not on React Aria's field: the field adds the ids
|
|
136
136
|
of its own description and error slots, which this system never renders (`Field` draws
|
|
@@ -157,7 +157,7 @@ export function TextInput({ id: ownId, value, onChange, placeholder, describedBy
|
|
|
157
157
|
});
|
|
158
158
|
if (useFormMode(mode) === "read")
|
|
159
159
|
return _jsx(ReadValue, { value: value, mono: mono });
|
|
160
|
-
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: spellCheck, className: `${controlClasses(invalid)} ${mono ? "font-mono tabular-nums" : ""}` }) }));
|
|
160
|
+
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: spellCheck, "data-ui": "control", className: `${controlClasses(invalid)} ${mono ? "font-mono tabular-nums" : ""}` }) }));
|
|
161
161
|
}
|
|
162
162
|
/** The amount, the quantity, the percentage — read in the copy's locale, every time. */
|
|
163
163
|
function useReadNumber(format) {
|
|
@@ -224,17 +224,17 @@ export function TextArea({ id: ownId, value, onChange, placeholder, rows = 3, de
|
|
|
224
224
|
if (useFormMode(mode) === "read") {
|
|
225
225
|
return value === "" ? (_jsx(ReadValue, { value: null })) : (_jsx("span", { className: "text-meta whitespace-pre-line text-ink", children: value }));
|
|
226
226
|
}
|
|
227
|
-
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(AriaTextArea, { "aria-describedby": describedBy, rows: rows, placeholder: placeholder, className: `${controlClasses(invalid)} h-auto resize-y py-1.5 leading-relaxed` }) }));
|
|
227
|
+
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(AriaTextArea, { "aria-describedby": describedBy, rows: rows, placeholder: placeholder, "data-ui": "control", className: `${controlClasses(invalid)} h-auto resize-y py-1.5 leading-relaxed` }) }));
|
|
228
228
|
}
|
|
229
229
|
const selectTrigger = tv({
|
|
230
230
|
extend: focusRing,
|
|
231
|
-
base: "flex h-(--size-control-md) w-full min-w-0 cursor-default items-center gap-2 rounded-control border bg-
|
|
231
|
+
base: "flex h-(--size-control-md) w-full min-w-0 cursor-default items-center gap-2 rounded-ui-control border bg-ui-control pr-2 pl-2.5 text-start text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
|
|
232
232
|
variants: {
|
|
233
233
|
isFocusVisible: {
|
|
234
234
|
true: "border-primary",
|
|
235
235
|
},
|
|
236
236
|
isInvalid: {
|
|
237
|
-
false: "border-
|
|
237
|
+
false: "border-ui-control-border forced-colors:border-[ButtonBorder]",
|
|
238
238
|
true: "border-danger outline-danger forced-colors:border-[Mark]",
|
|
239
239
|
},
|
|
240
240
|
isDisabled: {
|
|
@@ -265,5 +265,5 @@ export function Select({ id: ownId, value, options, onChange, describedBy: ownDe
|
|
|
265
265
|
if (useFormMode(mode) === "read") {
|
|
266
266
|
return _jsx(ReadValue, { value: options.find((o) => o.value === value)?.label ?? null });
|
|
267
267
|
}
|
|
268
|
-
return (_jsx(AriaLocale, { children: _jsxs(AriaSelect, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), "aria-describedby": describedBy, value: value === "" ? null : value, onChange: (next) => onChange?.(next === null ? "" : String(next)), placeholder: placeholder, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: [_jsxs(AriaButton, { className: (state) => selectTrigger({ ...state, isInvalid: invalid }), children: [_jsx(SelectValue, { className: "min-w-0 flex-1 truncate data-placeholder:text-muted", children: ({ isPlaceholder, selectedText, defaultChildren }) => isPlaceholder ? defaultChildren : selectedText }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2 })] }), _jsx(Popover, { placement: "bottom start", className: "min-w-(--trigger-width)", children: _jsx(ListBox, { items: options, className: "max-h-[inherit] overflow-auto p-1 outline-0", children: (option) => (_jsx(ListBoxItem, { id: option.value, textValue: option.label, isDisabled: option.disabled, className: listOptionStyles, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: option.label }), _jsx("span", { className: "flex size-(--size-icon-md) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-md) text-primary forced-colors:text-[HighlightText]", strokeWidth: 2 })) : null })] })) })) }) })] }) }));
|
|
268
|
+
return (_jsx(AriaLocale, { children: _jsxs(AriaSelect, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), "aria-describedby": describedBy, value: value === "" ? null : value, onChange: (next) => onChange?.(next === null ? "" : String(next)), placeholder: placeholder, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: [_jsxs(AriaButton, { "data-ui": "control", className: (state) => selectTrigger({ ...state, isInvalid: invalid }), children: [_jsx(SelectValue, { className: "min-w-0 flex-1 truncate data-placeholder:text-muted", children: ({ isPlaceholder, selectedText, defaultChildren }) => isPlaceholder ? defaultChildren : selectedText }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2 })] }), _jsx(Popover, { placement: "bottom start", className: "min-w-(--trigger-width)", children: _jsx(ListBox, { items: options, className: "max-h-[inherit] overflow-auto p-1 outline-0", children: (option) => (_jsx(ListBoxItem, { id: option.value, textValue: option.label, isDisabled: option.disabled, className: listOptionStyles, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: option.label }), _jsx("span", { className: "flex size-(--size-icon-md) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-md) text-primary forced-colors:text-[HighlightText]", strokeWidth: 2 })) : null })] })) })) }) })] }) }));
|
|
269
269
|
}
|
|
@@ -44,5 +44,5 @@ export function PatternInput({ id: ownId, value, onChange, pattern, placeholder,
|
|
|
44
44
|
onChange?.(next);
|
|
45
45
|
};
|
|
46
46
|
const shown = placeholder ?? pattern.replace(/#/g, "0").replace(/\*/g, "X");
|
|
47
|
-
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, shown), value: drawn, onChange: change, inputMode: /[A*]/.test(pattern) ? "text" : "numeric", isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ref: input, "aria-describedby": describedBy, placeholder: shown, spellCheck: false, autoCapitalize: "characters", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
|
|
47
|
+
return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, shown), value: drawn, onChange: change, inputMode: /[A*]/.test(pattern) ? "text" : "numeric", isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ref: input, "aria-describedby": describedBy, placeholder: shown, spellCheck: false, autoCapitalize: "characters", "data-ui": "control", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
|
|
48
48
|
}
|
|
@@ -86,10 +86,10 @@ function MentionList({ asking, active, listId, }) {
|
|
|
86
86
|
const rect = asking.rect;
|
|
87
87
|
if (rect === null)
|
|
88
88
|
return null;
|
|
89
|
-
return (_jsx("ul", { id: listId, role: "listbox", "aria-label": copy.mentions, className: "fixed z-50 flex w-64 flex-col rounded-
|
|
89
|
+
return (_jsx("ul", { id: listId, role: "listbox", "aria-label": copy.mentions, "data-ui": "popover", className: "fixed z-50 flex w-64 flex-col rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", style: { left: rect.left, top: rect.bottom + 4 }, children: asking.items.length === 0 ? (_jsx("li", { role: "option", "aria-selected": false, "aria-disabled": true, className: "px-2 py-1 text-meta text-muted", children: copy.noMatches })) : (asking.items.map((item, index) => (_jsx("li", { id: `${listId}-${index}`, role: "option", "aria-selected": index === active, onMouseDown: (event) => {
|
|
90
90
|
event.preventDefault();
|
|
91
91
|
asking.pick(item);
|
|
92
|
-
}, className: `cursor-default rounded-control px-2 py-1 text-meta text-ink ${index === active ? "bg-
|
|
92
|
+
}, className: `cursor-default rounded-control px-2 py-1 text-meta text-ink ${index === active ? "bg-ui-option-active" : ""}`, children: item.label }, item.id)))) }));
|
|
93
93
|
}
|
|
94
94
|
export function RichTextEditor({ id, labelledBy, describedBy, invalid, ariaLabel, value, onChange, placeholder, disabled, toolbar, mentions, }) {
|
|
95
95
|
const changed = useRef(onChange);
|
|
@@ -211,5 +211,5 @@ export function SignatureInput({ id: ownId, value, onChange, name = "", alt, des
|
|
|
211
211
|
const paper = cn("relative h-32 w-full overflow-clip rounded-control border bg-surface font-sans text-ink", invalid ? "border-danger" : "border-line-strong", disabled ? "bg-ground" : "");
|
|
212
212
|
return (_jsxs("div", { id: id, role: "group", "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel), "aria-describedby": describedBy, className: "flex w-full min-w-0 flex-col gap-2", children: [_jsxs("div", { ref: pad, "data-theme": "light", className: paper, children: [stored || (typing && has) ? (_jsx("img", { src: value ?? "", alt: label, className: "size-full object-contain object-left" })) : typing ? null : (_jsx("canvas", { ref: canvas, role: "img", "aria-label": copy.media.signaturePad, "aria-describedby": helpId, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, className: cn("absolute inset-0 size-full touch-none", disabled ? "cursor-not-allowed" : "cursor-crosshair") })), _jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-4 bottom-1/4 border-t border-line-strong" })] }), typing ? (_jsxs("label", { className: "flex flex-col gap-1 text-micro font-medium text-muted", children: [copy.media.typedName, _jsx("input", {
|
|
213
213
|
/* The person asked for this box by pressing the button: the focus goes there. */
|
|
214
|
-
autoFocus: true, value: typed, disabled: disabled, autoComplete: "name", onChange: (event) => writeTyped(event.target.value), className: `${controlClasses(invalid)} font-normal` })] })) : (_jsx("p", { id: helpId, className: "text-micro text-muted", children: copy.media.signatureHelp })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { size: "sm", icon: typing ? PenLine : Type, disabled: disabled, onClick: switchMode, children: typing ? copy.media.drawInstead : copy.media.typeName }), _jsx(Button, { role: "ghost", size: "sm", icon: Eraser, disabled: disabled, onClick: clear, children: copy.media.clear })] })] }));
|
|
214
|
+
autoFocus: true, value: typed, disabled: disabled, autoComplete: "name", onChange: (event) => writeTyped(event.target.value), "data-ui": "control", className: `${controlClasses(invalid)} font-normal` })] })) : (_jsx("p", { id: helpId, className: "text-micro text-muted", children: copy.media.signatureHelp })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { size: "sm", icon: typing ? PenLine : Type, disabled: disabled, onClick: switchMode, children: typing ? copy.media.drawInstead : copy.media.typeName }), _jsx(Button, { role: "ghost", size: "sm", icon: Eraser, disabled: disabled, onClick: clear, children: copy.media.clear })] })] }));
|
|
215
215
|
}
|