@sereno-ds/ui 0.36.2 → 0.36.4
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 +12 -12
- package/dist/_internal/Field.d.ts +8 -2
- package/dist/_internal/Field.js +6 -5
- package/dist/_internal/Field.js.map +1 -1
- package/dist/_internal/fieldA11y.d.ts +21 -4
- package/dist/_internal/fieldA11y.js +7 -2
- package/dist/_internal/fieldA11y.js.map +1 -1
- package/dist/_internal/mask.d.ts +1 -1
- package/dist/_internal/mask.js.map +1 -1
- package/dist/core/Avatar.d.ts +1 -1
- package/dist/core/Avatar.js.map +1 -1
- package/dist/core/Badge.js +1 -1
- package/dist/core/Badge.js.map +1 -1
- package/dist/core/Brand.d.ts +2 -2
- package/dist/core/Brand.js.map +1 -1
- package/dist/core/Button.d.ts +1 -1
- package/dist/core/Button.js.map +1 -1
- package/dist/core/Card.js +1 -1
- package/dist/core/Card.js.map +1 -1
- package/dist/core/IconButton.d.ts +2 -2
- package/dist/core/IconButton.js.map +1 -1
- package/dist/core/Menu.d.ts +5 -5
- package/dist/core/Menu.js.map +1 -1
- package/dist/core/Table.d.ts +7 -7
- package/dist/core/Table.js +1 -1
- package/dist/core/Table.js.map +1 -1
- package/dist/core/Typography.d.ts +3 -3
- package/dist/core/Typography.js +1 -1
- package/dist/core/Typography.js.map +1 -1
- package/dist/feedback/Alert.d.ts +2 -2
- package/dist/feedback/Alert.js.map +1 -1
- package/dist/feedback/Dialog.d.ts +5 -5
- package/dist/feedback/Dialog.js.map +1 -1
- package/dist/feedback/Skeleton.d.ts +1 -1
- package/dist/feedback/Skeleton.js.map +1 -1
- package/dist/feedback/Toast.d.ts +1 -1
- package/dist/feedback/Toast.js.map +1 -1
- package/dist/feedback/ToastProvider.d.ts +3 -3
- package/dist/feedback/ToastProvider.js +1 -1
- package/dist/feedback/ToastProvider.js.map +1 -1
- package/dist/forms/AvatarUpload.d.ts +5 -5
- package/dist/forms/AvatarUpload.js +2 -2
- package/dist/forms/AvatarUpload.js.map +1 -1
- package/dist/forms/Checkbox.d.ts +3 -3
- package/dist/forms/Checkbox.js +1 -1
- package/dist/forms/Checkbox.js.map +1 -1
- package/dist/forms/DatePicker.d.ts +9 -9
- package/dist/forms/DatePicker.js +1 -1
- package/dist/forms/DatePicker.js.map +1 -1
- package/dist/forms/DateTimePicker.d.ts +14 -14
- package/dist/forms/DateTimePicker.js +2 -2
- package/dist/forms/DateTimePicker.js.map +1 -1
- package/dist/forms/FileUpload.d.ts +4 -4
- package/dist/forms/FileUpload.js +7 -3
- package/dist/forms/FileUpload.js.map +1 -1
- package/dist/forms/Input.d.ts +1 -1
- package/dist/forms/Input.js +4 -2
- package/dist/forms/Input.js.map +1 -1
- package/dist/forms/Radio.d.ts +5 -5
- package/dist/forms/Radio.js.map +1 -1
- package/dist/forms/SearchInput.d.ts +2 -2
- package/dist/forms/SearchInput.js.map +1 -1
- package/dist/forms/Select.d.ts +9 -9
- package/dist/forms/Select.js +2 -2
- package/dist/forms/Select.js.map +1 -1
- package/dist/forms/Switch.d.ts +3 -3
- package/dist/forms/Switch.js.map +1 -1
- package/dist/forms/Textarea.d.ts +1 -1
- package/dist/forms/Textarea.js +3 -1
- package/dist/forms/Textarea.js.map +1 -1
- package/dist/forms/_internal/CalendarGrid.d.ts +6 -6
- package/dist/forms/_internal/CalendarGrid.js +1 -1
- package/dist/forms/_internal/CalendarGrid.js.map +1 -1
- package/dist/forms/_internal/fieldBoxStyle.d.ts +2 -2
- package/dist/forms/_internal/fieldBoxStyle.js +2 -2
- package/dist/forms/_internal/fieldBoxStyle.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/navigation/BottomNav.d.ts +1 -1
- package/dist/navigation/BottomNav.js +1 -1
- package/dist/navigation/BottomNav.js.map +1 -1
- package/dist/navigation/SidebarNav.d.ts +9 -9
- package/dist/navigation/SidebarNav.js +1 -1
- package/dist/navigation/SidebarNav.js.map +1 -1
- package/dist/navigation/Stepper.d.ts +5 -5
- package/dist/navigation/Stepper.js.map +1 -1
- package/dist/navigation/Tabs.d.ts +2 -2
- package/dist/navigation/Tabs.js +11 -11
- package/dist/navigation/Tabs.js.map +1 -1
- package/dist/navigation/TopBar.d.ts +3 -3
- package/dist/navigation/TopBar.js.map +1 -1
- package/dist/styles.css +23 -23
- package/dist/theme/ThemeProvider.d.ts +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @sereno-ds/ui
|
|
2
2
|
|
|
3
|
-
React primitives for the Sereno Design System
|
|
3
|
+
React primitives for the Sereno Design System, token-driven, inline styles, **no UI base library** (no Radix / MUI / Tailwind). Native light/dark via one `data-theme` attribute.
|
|
4
4
|
|
|
5
5
|
> Browse every component with a live preview: the Sereno DS showcase.
|
|
6
6
|
|
|
@@ -10,9 +10,9 @@ React primitives for the Sereno Design System — token-driven, inline styles, *
|
|
|
10
10
|
npm i @sereno-ds/ui @sereno-ds/tokens lucide-react
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
`@sereno-ds/tokens` (the CSS custom properties everything reads) and `lucide-react` (icons
|
|
13
|
+
`@sereno-ds/tokens` (the CSS custom properties everything reads) and `lucide-react` (icons, see below) are **peer/companion deps** you install alongside. `react` / `react-dom` (>=18, works on 19) you already have. `next-themes` comes bundled.
|
|
14
14
|
|
|
15
|
-
## Setup
|
|
15
|
+
## Setup - three things, once, at the app root
|
|
16
16
|
|
|
17
17
|
### 1. Import the stylesheets, in this order
|
|
18
18
|
|
|
@@ -21,11 +21,11 @@ import '@sereno-ds/tokens/tokens.css'; // the token layer (colors, spacing, dark
|
|
|
21
21
|
import '@sereno-ds/ui/styles.css'; // component keyframes + a few structural rules
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
`tokens.css` **must** come first. Both are side-effect CSS
|
|
24
|
+
`tokens.css` **must** come first. Both are side-effect CSS: import them once (a root layout, `_app`, or `main.tsx`), not per-component.
|
|
25
25
|
|
|
26
26
|
### 2. Provide the fonts
|
|
27
27
|
|
|
28
|
-
Components reference three font CSS variables. Define them however you host fonts; the tokens already carry a system fallback, so text renders without them
|
|
28
|
+
Components reference three font CSS variables. Define them however you host fonts; the tokens already carry a system fallback, so text renders without them, just off-brand.
|
|
29
29
|
|
|
30
30
|
| Variable | Family |
|
|
31
31
|
|---|---|
|
|
@@ -75,7 +75,7 @@ import { ThemeProvider } from '@sereno-ds/ui';
|
|
|
75
75
|
<ThemeProvider>{children}</ThemeProvider>;
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
It writes `data-theme="light" | "dark"` on `<html>` (defaults to the OS preference, remembers the choice). If you already manage `data-theme` yourself, you can skip it
|
|
78
|
+
It writes `data-theme="light" | "dark"` on `<html>` (defaults to the OS preference, remembers the choice). If you already manage `data-theme` yourself, you can skip it, the tokens only need that attribute to be set.
|
|
79
79
|
|
|
80
80
|
## Use
|
|
81
81
|
|
|
@@ -98,7 +98,7 @@ export function Example() {
|
|
|
98
98
|
## Compound components
|
|
99
99
|
|
|
100
100
|
`Table`, `Tabs`, `SidebarNav`, `BottomNav`, `Stepper`, `Dialog` and `TopBar` are
|
|
101
|
-
the root plus dot-notated sub-parts
|
|
101
|
+
the root plus dot-notated sub-parts, compose them like JSX, not a config
|
|
102
102
|
object/array:
|
|
103
103
|
|
|
104
104
|
```tsx
|
|
@@ -129,15 +129,15 @@ import { Dialog, Button } from '@sereno-ds/ui';
|
|
|
129
129
|
</Dialog>;
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
- Only the root is exported
|
|
132
|
+
- Only the root is exported: `Dialog.Header`, `Tabs.Tab`, etc. resolve to
|
|
133
133
|
`undefined` if imported from a Server Component. Everything compound needs
|
|
134
134
|
`'use client'` somewhere above it in the tree.
|
|
135
135
|
- Sub-parts outside their root throw at render (`` <Tabs.Tab> must be
|
|
136
136
|
rendered inside <Tabs>. ``) instead of failing silently.
|
|
137
137
|
- `Header` / `Footer` (`Dialog`), `List` / `Panel` (`Tabs`), `Section`
|
|
138
|
-
(`SidebarNav`) are optional
|
|
138
|
+
(`SidebarNav`) are optional, render only the sub-parts a given screen
|
|
139
139
|
needs.
|
|
140
|
-
- `Select` and `DateTimePicker` are hand-rolled but **not** compound
|
|
140
|
+
- `Select` and `DateTimePicker` are hand-rolled but **not** compound, each
|
|
141
141
|
option / day is plain data (`options`, `times`), not JSX a consumer
|
|
142
142
|
composes. See each component's own JSDoc, or the showcase's Props tab, for
|
|
143
143
|
the rest of the sub-parts per component.
|
|
@@ -145,8 +145,8 @@ import { Dialog, Button } from '@sereno-ds/ui';
|
|
|
145
145
|
## Contract
|
|
146
146
|
|
|
147
147
|
- **Tokens are required.** Components read only CSS custom properties (`--bg-*`, `--text-*`, `--border-*`, `--radius-*`, `--space-*`, `--font-*`, …). They live in `@sereno-ds/tokens`; without it, everything renders unstyled.
|
|
148
|
-
- **Dark mode** is the same components on `[data-theme="dark"]
|
|
149
|
-
- **Icons come from you.** Where a component takes an icon (`Button` `iconLeft`, `TopBar` actions, …) you pass a node
|
|
148
|
+
- **Dark mode** is the same components on `[data-theme="dark"]`, no `theme` prop, no variant.
|
|
149
|
+
- **Icons come from you.** Where a component takes an icon (`Button` `iconLeft`, `TopBar` actions, …) you pass a node, typically `lucide-react`, but any 20px-ish SVG works. `@sereno-ds/ui` also uses `lucide-react` for its own built-in affordances (the `Select` caret, the `Input` password eye, `ThemeToggle`), so it's a required peer.
|
|
150
150
|
- **Zero CSS-in-JS runtime.** Styles are plain inline `style={{ … }}` reading `var(--token)`.
|
|
151
151
|
|
|
152
152
|
## License
|
|
@@ -10,10 +10,16 @@ interface FieldProps {
|
|
|
10
10
|
error?: string;
|
|
11
11
|
required?: boolean;
|
|
12
12
|
htmlFor?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The control says it is required itself (`aria-required`, see `fieldA11y`), so the asterisk
|
|
15
|
+
* is hidden from assistive technology, which would read it as a symbol. Leave it off for a
|
|
16
|
+
* control that cannot carry `aria-required` (a button): there the asterisk is all it has.
|
|
17
|
+
*/
|
|
18
|
+
requiredExposed?: boolean;
|
|
13
19
|
/** Right-aligned node on the hint row (e.g. a character counter). */
|
|
14
20
|
counter?: React.ReactNode;
|
|
15
21
|
/**
|
|
16
|
-
* Reserve the hint/error row's height even when there's nothing to show
|
|
22
|
+
* Reserve the hint/error row's height even when there's nothing to show -
|
|
17
23
|
* keeps the field's own height stable as `error`/`hint` come and go (e.g.
|
|
18
24
|
* several fields in a form invalidating at once), instead of every field
|
|
19
25
|
* growing the moment a message appears. Off by default: most fields don't
|
|
@@ -23,6 +29,6 @@ interface FieldProps {
|
|
|
23
29
|
children?: React.ReactNode;
|
|
24
30
|
style?: React.CSSProperties;
|
|
25
31
|
}
|
|
26
|
-
declare function Field({ label, hint, error, required, htmlFor, counter, preserveHelperSpace, children, style }: FieldProps): React.JSX.Element;
|
|
32
|
+
declare function Field({ label, hint, error, required, requiredExposed, htmlFor, counter, preserveHelperSpace, children, style }: FieldProps): React.JSX.Element;
|
|
27
33
|
|
|
28
34
|
export { Field, type FieldProps };
|
package/dist/_internal/Field.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { sx } from "./style.js";
|
|
4
|
-
import { fieldMessageId } from "./fieldA11y.js";
|
|
5
|
-
function Field({ label, hint, error, required, htmlFor, counter, preserveHelperSpace = false, children, style }) {
|
|
4
|
+
import { fieldLabelId, fieldMessageId } from "./fieldA11y.js";
|
|
5
|
+
function Field({ label, hint, error, required, requiredExposed = false, htmlFor, counter, preserveHelperSpace = false, children, style }) {
|
|
6
6
|
return (
|
|
7
|
-
// No `gap` here
|
|
7
|
+
// No `gap` here - the label→field and field→helper gaps are deliberately
|
|
8
8
|
// different sizes (below), not one uniform rhythm.
|
|
9
9
|
/* @__PURE__ */ jsxs("div", { style: sx({ display: "flex", flexDirection: "column", ...style }), children: [
|
|
10
10
|
label && /* @__PURE__ */ jsxs(
|
|
11
11
|
"label",
|
|
12
12
|
{
|
|
13
|
+
id: htmlFor ? fieldLabelId(htmlFor) : void 0,
|
|
13
14
|
htmlFor,
|
|
14
15
|
style: sx({
|
|
15
16
|
fontFamily: "var(--font-body)",
|
|
@@ -21,7 +22,7 @@ function Field({ label, hint, error, required, htmlFor, counter, preserveHelperS
|
|
|
21
22
|
}),
|
|
22
23
|
children: [
|
|
23
24
|
label,
|
|
24
|
-
required && /* @__PURE__ */ jsx("span", { style: sx({ color: "var(--interactive-error)", marginLeft: 3 }), children: "*" })
|
|
25
|
+
required && /* @__PURE__ */ jsx("span", { "aria-hidden": requiredExposed || void 0, style: sx({ color: "var(--interactive-error)", marginLeft: 3 }), children: "*" })
|
|
25
26
|
]
|
|
26
27
|
}
|
|
27
28
|
),
|
|
@@ -34,7 +35,7 @@ function Field({ label, hint, error, required, htmlFor, counter, preserveHelperS
|
|
|
34
35
|
alignItems: "baseline",
|
|
35
36
|
gap: "var(--space-3)",
|
|
36
37
|
marginTop: "var(--space-1)",
|
|
37
|
-
// One line's worth of height, reserved up front
|
|
38
|
+
// One line's worth of height, reserved up front - so text
|
|
38
39
|
// appearing/disappearing never changes the row's own size.
|
|
39
40
|
minHeight: preserveHelperSpace ? "calc(var(--text-xs) * 1.45)" : void 0,
|
|
40
41
|
justifyContent: error || hint ? "space-between" : "flex-end"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_internal/Field.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from './style';\nimport { fieldMessageId } from './fieldA11y';\n\n/**\n * Label + hint/error wrapper shared by the form controls. The hint / error line gets an\n * `id` (see `fieldA11y`) so the control can name it in `aria-describedby`.\n */\nexport interface FieldProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n htmlFor?: string;\n /** Right-aligned node on the hint row (e.g. a character counter). */\n counter?: React.ReactNode;\n /**\n * Reserve the hint/error row's height even when there's nothing to show
|
|
1
|
+
{"version":3,"sources":["../../src/_internal/Field.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from './style';\nimport { fieldLabelId, fieldMessageId } from './fieldA11y';\n\n/**\n * Label + hint/error wrapper shared by the form controls. The hint / error line gets an\n * `id` (see `fieldA11y`) so the control can name it in `aria-describedby`.\n */\nexport interface FieldProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n htmlFor?: string;\n /**\n * The control says it is required itself (`aria-required`, see `fieldA11y`), so the asterisk\n * is hidden from assistive technology, which would read it as a symbol. Leave it off for a\n * control that cannot carry `aria-required` (a button): there the asterisk is all it has.\n */\n requiredExposed?: boolean;\n /** Right-aligned node on the hint row (e.g. a character counter). */\n counter?: React.ReactNode;\n /**\n * Reserve the hint/error row's height even when there's nothing to show -\n * keeps the field's own height stable as `error`/`hint` come and go (e.g.\n * several fields in a form invalidating at once), instead of every field\n * growing the moment a message appears. Off by default: most fields don't\n * need the empty gap when there's nothing under them.\n */\n preserveHelperSpace?: boolean;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n}\n\nexport function Field({ label, hint, error, required, requiredExposed = false, htmlFor, counter, preserveHelperSpace = false, children, style }: FieldProps) {\n return (\n // No `gap` here - the label→field and field→helper gaps are deliberately\n // different sizes (below), not one uniform rhythm.\n <div style={sx({ display: 'flex', flexDirection: 'column', ...style })}>\n {label && (\n <label\n id={htmlFor ? fieldLabelId(htmlFor) : undefined}\n htmlFor={htmlFor}\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n letterSpacing: 'var(--tracking-snug)',\n marginBottom: 'var(--space-2)',\n })}\n >\n {label}\n {required && (\n <span aria-hidden={requiredExposed || undefined} style={sx({ color: 'var(--interactive-error)', marginLeft: 3 })}>\n *\n </span>\n )}\n </label>\n )}\n {children}\n {(error || hint || counter || preserveHelperSpace) && (\n <div\n style={sx({\n display: 'flex',\n alignItems: 'baseline',\n gap: 'var(--space-3)',\n marginTop: 'var(--space-1)',\n // One line's worth of height, reserved up front - so text\n // appearing/disappearing never changes the row's own size.\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n justifyContent: error || hint ? 'space-between' : 'flex-end',\n })}\n >\n {(error || hint) && (\n <span\n id={htmlFor ? fieldMessageId(htmlFor) : undefined}\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n lineHeight: 1.45,\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n })}\n >\n {error || hint}\n </span>\n )}\n {counter}\n </div>\n )}\n </div>\n );\n}"],"mappings":";AA0CQ,SAcI,KAdJ;AAvCR,SAAS,UAAU;AACnB,SAAS,cAAc,sBAAsB;AAgCtC,SAAS,MAAM,EAAE,OAAO,MAAM,OAAO,UAAU,kBAAkB,OAAO,SAAS,SAAS,sBAAsB,OAAO,UAAU,MAAM,GAAe;AAC3J;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,GAAG,MAAM,CAAC,GAClE;AAAA,eACC;AAAA,QAAC;AAAA;AAAA,UACC,IAAI,UAAU,aAAa,OAAO,IAAI;AAAA,UACtC;AAAA,UACA,OAAO,GAAG;AAAA,YACR,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO;AAAA,YACP,eAAe;AAAA,YACf,cAAc;AAAA,UAChB,CAAC;AAAA,UAEA;AAAA;AAAA,YACA,YACC,oBAAC,UAAK,eAAa,mBAAmB,QAAW,OAAO,GAAG,EAAE,OAAO,4BAA4B,YAAY,EAAE,CAAC,GAAG,eAElH;AAAA;AAAA;AAAA,MAEJ;AAAA,MAED;AAAA,OACC,SAAS,QAAQ,WAAW,wBAC5B;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,GAAG;AAAA,YACR,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,KAAK;AAAA,YACL,WAAW;AAAA;AAAA;AAAA,YAGX,WAAW,sBAAsB,gCAAgC;AAAA,YACjE,gBAAgB,SAAS,OAAO,kBAAkB;AAAA,UACpD,CAAC;AAAA,UAEC;AAAA,sBAAS,SACT;AAAA,cAAC;AAAA;AAAA,gBACC,IAAI,UAAU,eAAe,OAAO,IAAI;AAAA,gBACxC,OAAO,GAAG;AAAA,kBACR,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,OAAO,QAAQ,6BAA6B;AAAA,gBAC9C,CAAC;AAAA,gBAEA,mBAAS;AAAA;AAAA,YACZ;AAAA,YAED;AAAA;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA;AAEJ;","names":[]}
|
|
@@ -6,6 +6,12 @@ import * as React from 'react';
|
|
|
6
6
|
* through this one function, so the two can never drift apart.
|
|
7
7
|
*/
|
|
8
8
|
declare function fieldMessageId(controlId: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* The `id` of the `<label>` `Field` renders for the control whose own id is `controlId`, so a
|
|
11
|
+
* control whose `<label for>` cannot reach it (the hidden file input of `FileUpload` and
|
|
12
|
+
* `AvatarUpload`) can still be named by it through `aria-labelledby`.
|
|
13
|
+
*/
|
|
14
|
+
declare function fieldLabelId(controlId: string): string;
|
|
9
15
|
interface FieldA11yInput {
|
|
10
16
|
hint?: string;
|
|
11
17
|
error?: string;
|
|
@@ -13,22 +19,33 @@ interface FieldA11yInput {
|
|
|
13
19
|
describedBy?: string;
|
|
14
20
|
/** The consumer's own `aria-invalid`, used only when there is no `error` to say so. */
|
|
15
21
|
invalid?: React.AriaAttributes['aria-invalid'];
|
|
22
|
+
/**
|
|
23
|
+
* The field is required. Pass it only for a control whose role supports `aria-required`
|
|
24
|
+
* (a text box, a combobox): on a button it is invalid ARIA, and axe flags it.
|
|
25
|
+
*/
|
|
26
|
+
required?: boolean;
|
|
27
|
+
/** The consumer's own `aria-required`, used only when `required` is not set. */
|
|
28
|
+
ariaRequired?: React.AriaAttributes['aria-required'];
|
|
16
29
|
}
|
|
17
30
|
/**
|
|
18
|
-
* The
|
|
19
|
-
*
|
|
31
|
+
* The attributes that tie a form control to its `Field`, so a screen reader says the control
|
|
32
|
+
* is required and invalid, and reads the error (or the hint), when it takes focus:
|
|
20
33
|
*
|
|
21
34
|
* - `aria-invalid` is `true` when there is an `error`, and otherwise whatever the consumer
|
|
22
35
|
* passed (nothing, by default, so a valid field has no attribute at all).
|
|
23
36
|
* - `aria-describedby` lists the message's id while there is an `error` or a `hint` (the
|
|
24
37
|
* error already replaces the hint, so it is one id either way), then the consumer's own
|
|
25
38
|
* ids. Absent when there is nothing to point at.
|
|
39
|
+
* - `aria-required` is `true` when `required` is set, and otherwise whatever the consumer
|
|
40
|
+
* passed. It is `aria-required`, not the native `required`, so the browser's own form
|
|
41
|
+
* validation is not switched on.
|
|
26
42
|
*
|
|
27
43
|
* Spread the result on the element that takes focus, after any `{...rest}`.
|
|
28
44
|
*/
|
|
29
|
-
declare function fieldA11y(controlId: string, { hint, error, describedBy, invalid }: FieldA11yInput): {
|
|
45
|
+
declare function fieldA11y(controlId: string, { hint, error, describedBy, invalid, required, ariaRequired }: FieldA11yInput): {
|
|
30
46
|
readonly 'aria-invalid': boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
31
47
|
readonly 'aria-describedby': string | undefined;
|
|
48
|
+
readonly 'aria-required': (boolean | "true" | "false") | undefined;
|
|
32
49
|
};
|
|
33
50
|
|
|
34
|
-
export { type FieldA11yInput, fieldA11y, fieldMessageId };
|
|
51
|
+
export { type FieldA11yInput, fieldA11y, fieldLabelId, fieldMessageId };
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
function fieldMessageId(controlId) {
|
|
2
2
|
return `${controlId}-message`;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function fieldLabelId(controlId) {
|
|
5
|
+
return `${controlId}-label`;
|
|
6
|
+
}
|
|
7
|
+
function fieldA11y(controlId, { hint, error, describedBy, invalid, required, ariaRequired }) {
|
|
5
8
|
const ids = [error || hint ? fieldMessageId(controlId) : "", describedBy?.trim() ?? ""].filter(Boolean).join(" ");
|
|
6
9
|
return {
|
|
7
10
|
"aria-invalid": error ? true : invalid,
|
|
8
|
-
"aria-describedby": ids || void 0
|
|
11
|
+
"aria-describedby": ids || void 0,
|
|
12
|
+
"aria-required": required ? true : ariaRequired
|
|
9
13
|
};
|
|
10
14
|
}
|
|
11
15
|
export {
|
|
12
16
|
fieldA11y,
|
|
17
|
+
fieldLabelId,
|
|
13
18
|
fieldMessageId
|
|
14
19
|
};
|
|
15
20
|
//# sourceMappingURL=fieldA11y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_internal/fieldA11y.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * The `id` of the hint / error line `Field` renders for the control whose own id is\n * `controlId`. `Field` stamps it on the line and `fieldA11y` points the control at it, both\n * through this one function, so the two can never drift apart.\n */\nexport function fieldMessageId(controlId: string): string {\n return `${controlId}-message`;\n}\n\nexport interface FieldA11yInput {\n hint?: string;\n error?: string;\n /** The consumer's own `aria-describedby`, kept (never replaced). */\n describedBy?: string;\n /** The consumer's own `aria-invalid`, used only when there is no `error` to say so. */\n invalid?: React.AriaAttributes['aria-invalid'];\n}\n\n/**\n * The
|
|
1
|
+
{"version":3,"sources":["../../src/_internal/fieldA11y.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * The `id` of the hint / error line `Field` renders for the control whose own id is\n * `controlId`. `Field` stamps it on the line and `fieldA11y` points the control at it, both\n * through this one function, so the two can never drift apart.\n */\nexport function fieldMessageId(controlId: string): string {\n return `${controlId}-message`;\n}\n\n/**\n * The `id` of the `<label>` `Field` renders for the control whose own id is `controlId`, so a\n * control whose `<label for>` cannot reach it (the hidden file input of `FileUpload` and\n * `AvatarUpload`) can still be named by it through `aria-labelledby`.\n */\nexport function fieldLabelId(controlId: string): string {\n return `${controlId}-label`;\n}\n\nexport interface FieldA11yInput {\n hint?: string;\n error?: string;\n /** The consumer's own `aria-describedby`, kept (never replaced). */\n describedBy?: string;\n /** The consumer's own `aria-invalid`, used only when there is no `error` to say so. */\n invalid?: React.AriaAttributes['aria-invalid'];\n /**\n * The field is required. Pass it only for a control whose role supports `aria-required`\n * (a text box, a combobox): on a button it is invalid ARIA, and axe flags it.\n */\n required?: boolean;\n /** The consumer's own `aria-required`, used only when `required` is not set. */\n ariaRequired?: React.AriaAttributes['aria-required'];\n}\n\n/**\n * The attributes that tie a form control to its `Field`, so a screen reader says the control\n * is required and invalid, and reads the error (or the hint), when it takes focus:\n *\n * - `aria-invalid` is `true` when there is an `error`, and otherwise whatever the consumer\n * passed (nothing, by default, so a valid field has no attribute at all).\n * - `aria-describedby` lists the message's id while there is an `error` or a `hint` (the\n * error already replaces the hint, so it is one id either way), then the consumer's own\n * ids. Absent when there is nothing to point at.\n * - `aria-required` is `true` when `required` is set, and otherwise whatever the consumer\n * passed. It is `aria-required`, not the native `required`, so the browser's own form\n * validation is not switched on.\n *\n * Spread the result on the element that takes focus, after any `{...rest}`.\n */\nexport function fieldA11y(controlId: string, { hint, error, describedBy, invalid, required, ariaRequired }: FieldA11yInput) {\n const ids = [error || hint ? fieldMessageId(controlId) : '', describedBy?.trim() ?? ''].filter(Boolean).join(' ');\n return {\n 'aria-invalid': error ? true : invalid,\n 'aria-describedby': ids || undefined,\n 'aria-required': required ? true : ariaRequired,\n } as const;\n}\n"],"mappings":"AAOO,SAAS,eAAe,WAA2B;AACxD,SAAO,GAAG,SAAS;AACrB;AAOO,SAAS,aAAa,WAA2B;AACtD,SAAO,GAAG,SAAS;AACrB;AAiCO,SAAS,UAAU,WAAmB,EAAE,MAAM,OAAO,aAAa,SAAS,UAAU,aAAa,GAAmB;AAC1H,QAAM,MAAM,CAAC,SAAS,OAAO,eAAe,SAAS,IAAI,IAAI,aAAa,KAAK,KAAK,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAChH,SAAO;AAAA,IACL,gBAAgB,QAAQ,OAAO;AAAA,IAC/B,oBAAoB,OAAO;AAAA,IAC3B,iBAAiB,WAAW,OAAO;AAAA,EACrC;AACF;","names":[]}
|
package/dist/_internal/mask.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hand-rolled input masks
|
|
2
|
+
* Hand-rolled input masks - no dependency. `formatMask` takes a preset name (or a
|
|
3
3
|
* custom `#`-per-digit pattern) and a raw string, and returns the formatted value.
|
|
4
4
|
* Extra characters are dropped; separators are inserted positionally.
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/_internal/mask.ts"],"sourcesContent":["/**\n * Hand-rolled input masks
|
|
1
|
+
{"version":3,"sources":["../../src/_internal/mask.ts"],"sourcesContent":["/**\n * Hand-rolled input masks - no dependency. `formatMask` takes a preset name (or a\n * custom `#`-per-digit pattern) and a raw string, and returns the formatted value.\n * Extra characters are dropped; separators are inserted positionally.\n */\n\nexport type MaskName = 'phone' | 'cpf' | 'cep' | 'currency';\n\nconst onlyDigits = (s: string) => s.replace(/\\D/g, '');\n\n/** Apply a positional pattern where `#` is one digit and everything else is a literal. */\nfunction applyPattern(pattern: string, raw: string): string {\n const d = onlyDigits(raw);\n let out = '';\n let i = 0;\n for (const ch of pattern) {\n if (i >= d.length) break;\n if (ch === '#') out += d[i++];\n else out += ch;\n }\n return out;\n}\n\nconst PHONE_10 = '(##) ####-####'; // landline\nconst PHONE_11 = '(##) #####-####'; // mobile\n\n/**\n * BR currency amount - digits are read as cents. \"1234\" → \"12,34\". No symbol:\n * pair it with `prefix=\"R$\"` on the field so the value stays a plain number string.\n */\nfunction currencyBRL(raw: string): string {\n const cents = (onlyDigits(raw).replace(/^0+/, '') || '0').padStart(3, '0');\n const int = cents.slice(0, -2).replace(/\\B(?=(\\d{3})+(?!\\d))/g, '.');\n return `${int},${cents.slice(-2)}`;\n}\n\nexport function formatMask(name: MaskName | string, raw: string): string {\n if (!raw) return '';\n switch (name) {\n case 'phone':\n return applyPattern(onlyDigits(raw).length > 10 ? PHONE_11 : PHONE_10, raw);\n case 'cpf':\n return applyPattern('###.###.###-##', raw);\n case 'cep':\n return applyPattern('#####-###', raw);\n case 'currency':\n return currencyBRL(raw);\n default:\n return applyPattern(name, raw); // custom '#' pattern\n }\n}\n\n/** Max length of the fully-formatted value, so the field stops accepting input. */\nexport const MASK_MAXLENGTH: Record<string, number> = {\n phone: 15, // \"(11) 99999-9999\"\n cpf: 14, // \"000.000.000-00\"\n cep: 9, // \"00000-000\"\n currency: 14, // \"999.999.999,99\"\n};\n\nexport const MASK_INPUTMODE: Record<string, 'numeric' | 'tel'> = {\n phone: 'tel',\n cpf: 'numeric',\n cep: 'numeric',\n currency: 'numeric',\n};\n"],"mappings":"AAQA,MAAM,aAAa,CAAC,MAAc,EAAE,QAAQ,OAAO,EAAE;AAGrD,SAAS,aAAa,SAAiB,KAAqB;AAC1D,QAAM,IAAI,WAAW,GAAG;AACxB,MAAI,MAAM;AACV,MAAI,IAAI;AACR,aAAW,MAAM,SAAS;AACxB,QAAI,KAAK,EAAE,OAAQ;AACnB,QAAI,OAAO,IAAK,QAAO,EAAE,GAAG;AAAA,QACvB,QAAO;AAAA,EACd;AACA,SAAO;AACT;AAEA,MAAM,WAAW;AACjB,MAAM,WAAW;AAMjB,SAAS,YAAY,KAAqB;AACxC,QAAM,SAAS,WAAW,GAAG,EAAE,QAAQ,OAAO,EAAE,KAAK,KAAK,SAAS,GAAG,GAAG;AACzE,QAAM,MAAM,MAAM,MAAM,GAAG,EAAE,EAAE,QAAQ,yBAAyB,GAAG;AACnE,SAAO,GAAG,GAAG,IAAI,MAAM,MAAM,EAAE,CAAC;AAClC;AAEO,SAAS,WAAW,MAAyB,KAAqB;AACvE,MAAI,CAAC,IAAK,QAAO;AACjB,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,aAAa,WAAW,GAAG,EAAE,SAAS,KAAK,WAAW,UAAU,GAAG;AAAA,IAC5E,KAAK;AACH,aAAO,aAAa,kBAAkB,GAAG;AAAA,IAC3C,KAAK;AACH,aAAO,aAAa,aAAa,GAAG;AAAA,IACtC,KAAK;AACH,aAAO,YAAY,GAAG;AAAA,IACxB;AACE,aAAO,aAAa,MAAM,GAAG;AAAA,EACjC;AACF;AAGO,MAAM,iBAAyC;AAAA,EACpD,OAAO;AAAA;AAAA,EACP,KAAK;AAAA;AAAA,EACL,KAAK;AAAA;AAAA,EACL,UAAU;AAAA;AACZ;AAEO,MAAM,iBAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,KAAK;AAAA,EACL,KAAK;AAAA,EACL,UAAU;AACZ;","names":[]}
|
package/dist/core/Avatar.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
|
|
3
3
|
/** Circular professional/client identity. Falls back to brand-soft initials when no photo exists. */
|
|
4
4
|
interface AvatarProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
5
|
-
/** Full name
|
|
5
|
+
/** Full name - drives the initials fallback and the img alt. */
|
|
6
6
|
name?: string;
|
|
7
7
|
src?: string;
|
|
8
8
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
package/dist/core/Avatar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Avatar.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Circular professional/client identity. Falls back to brand-soft initials when no photo exists. */\nexport interface AvatarProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Full name
|
|
1
|
+
{"version":3,"sources":["../../src/core/Avatar.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Circular professional/client identity. Falls back to brand-soft initials when no photo exists. */\nexport interface AvatarProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Full name - drives the initials fallback and the img alt. */\n name?: string;\n src?: string;\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n /** Optional lifecycle dot in the lower-right corner. */\n status?: 'confirmed' | 'pending' | 'cancelled';\n}\n\nconst S = { xs: 24, sm: 32, md: 40, lg: 56, xl: 80 } as const;\n\nfunction initials(name: string): string {\n return (name || '')\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((w) => w[0] || '')\n .join('')\n .toUpperCase();\n}\n\nexport function Avatar({ name = '', src, size = 'md', status, style, ...rest }: AvatarProps) {\n const d = S[size] || S.md;\n const fs = d <= 24 ? 10 : d <= 32 ? 12 : d <= 40 ? 14 : d <= 56 ? 18 : 26;\n const dot = status\n ? ({ confirmed: '--status-success-dot', pending: '--status-warning-dot', cancelled: '--status-error-dot' } as const)[status]\n : null;\n return (\n <span {...rest} style={sx({ position: 'relative', display: 'inline-flex', flex: '0 0 auto', ...style })}>\n <span\n style={sx({\n width: d,\n height: d,\n borderRadius: 'var(--radius-avatar)',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n // Initials fill is a distinct brand tint (not --bg-brand-soft) so the\n // disc still reads when placed on a brand-soft surface (e.g. the\n // booking profile header).\n background: src ? 'var(--bg-subtle)' : 'color-mix(in srgb, var(--brand-500) 22%, var(--bg-surface))',\n color: 'var(--text-brand)',\n fontFamily: 'var(--font-display)',\n fontSize: fs,\n fontWeight: 'var(--weight-bold)',\n letterSpacing: 'var(--tracking-snug)',\n border: 'var(--border-width-hairline) solid ' + (src ? 'var(--border-subtle)' : 'color-mix(in srgb, var(--brand-500) 30%, transparent)'),\n })}\n >\n {src ? (\n // Plain <img>: this is a portable DS primitive, not tied to next/image.\n // eslint-disable-next-line @next/next/no-img-element\n <img src={src} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n initials(name)\n )}\n </span>\n {dot && (\n <span\n style={sx({\n position: 'absolute',\n right: -1,\n bottom: -1,\n width: Math.max(8, d * 0.28),\n height: Math.max(8, d * 0.28),\n borderRadius: '999px',\n background: 'var(' + dot + ')',\n border: '2px solid var(--bg-surface)',\n })}\n />\n )}\n </span>\n );\n}"],"mappings":";AAkCI,SAyBM,KAzBN;AA/BJ,SAAS,UAAU;AAYnB,MAAM,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAEnD,SAAS,SAAS,MAAsB;AACtC,UAAQ,QAAQ,IACb,KAAK,EACL,MAAM,KAAK,EACX,MAAM,GAAG,CAAC,EACV,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EACrB,KAAK,EAAE,EACP,YAAY;AACjB;AAEO,SAAS,OAAO,EAAE,OAAO,IAAI,KAAK,OAAO,MAAM,QAAQ,OAAO,GAAG,KAAK,GAAgB;AAC3F,QAAM,IAAI,EAAE,IAAI,KAAK,EAAE;AACvB,QAAM,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;AACvE,QAAM,MAAM,SACP,EAAE,WAAW,wBAAwB,SAAS,wBAAwB,WAAW,qBAAqB,EAAY,MAAM,IACzH;AACJ,SACE,qBAAC,UAAM,GAAG,MAAM,OAAO,GAAG,EAAE,UAAU,YAAY,SAAS,eAAe,MAAM,YAAY,GAAG,MAAM,CAAC,GACpG;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,GAAG;AAAA,UACR,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,UAAU;AAAA,UACV,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,gBAAgB;AAAA;AAAA;AAAA;AAAA,UAIhB,YAAY,MAAM,qBAAqB;AAAA,UACvC,OAAO;AAAA,UACP,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,YAAY;AAAA,UACZ,eAAe;AAAA,UACf,QAAQ,yCAAyC,MAAM,yBAAyB;AAAA,QAClF,CAAC;AAAA,QAEA;AAAA;AAAA;AAAA,UAGC,oBAAC,SAAI,KAAU,KAAK,MAAM,OAAO,GAAG,EAAE,OAAO,QAAQ,QAAQ,QAAQ,WAAW,QAAQ,CAAC,GAAG;AAAA,YAE5F,SAAS,IAAI;AAAA;AAAA,IAEjB;AAAA,IACC,OACC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,GAAG;AAAA,UACR,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ;AAAA,UACR,OAAO,KAAK,IAAI,GAAG,IAAI,IAAI;AAAA,UAC3B,QAAQ,KAAK,IAAI,GAAG,IAAI,IAAI;AAAA,UAC5B,cAAc;AAAA,UACd,YAAY,SAAS,MAAM;AAAA,UAC3B,QAAQ;AAAA,QACV,CAAC;AAAA;AAAA,IACH;AAAA,KAEJ;AAEJ;","names":[]}
|
package/dist/core/Badge.js
CHANGED
|
@@ -24,7 +24,7 @@ function Badge({ tone = "neutral", size = "md", dot = true, children, style, ...
|
|
|
24
24
|
padding: sm ? "2px 8px" : "4px 10px",
|
|
25
25
|
borderRadius: "var(--radius-chip)",
|
|
26
26
|
background: "var(" + bg + ")",
|
|
27
|
-
// The neutral fill can match a tinted surface it sits on
|
|
27
|
+
// The neutral fill can match a tinted surface it sits on - a hairline
|
|
28
28
|
// keeps the chip defined on any background. Tinted tones read on their own.
|
|
29
29
|
border: "var(--border-width-hairline) solid " + (tone === "neutral" ? "var(--border-default)" : "transparent"),
|
|
30
30
|
color: "var(" + fg + ")",
|
package/dist/core/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Badge.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Status pill for the booking lifecycle and other short labels.\n */\nexport interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Semantic tone. Same five tones across Badge, Alert and Toast. */\n tone?: 'success' | 'warning' | 'error' | 'info' | 'neutral';\n size?: 'sm' | 'md';\n /** Leading status dot. Keep it on for lifecycle states. */\n dot?: boolean;\n children?: React.ReactNode;\n}\n\nconst TONES: Record<NonNullable<BadgeProps['tone']>, [string, string, string]> = {\n success: ['--status-success-bg', '--status-success-fg', '--status-success-dot'],\n warning: ['--status-warning-bg', '--status-warning-fg', '--status-warning-dot'],\n error: ['--status-error-bg', '--status-error-fg', '--status-error-dot'],\n info: ['--status-info-bg', '--status-info-fg', '--status-info-dot'],\n // Neutral = an outlined chip (surface fill + hairline border, added below) so it\n // reads on any background, including a tinted one.\n neutral: ['--bg-surface', '--text-secondary', '--text-muted'],\n};\n\nexport function Badge({ tone = 'neutral', size = 'md', dot = true, children, style, ...rest }: BadgeProps) {\n const [bg, fg, dt] = TONES[tone] || TONES.neutral;\n const sm = size === 'sm';\n return (\n <span\n {...rest}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n gap: sm ? 5 : 6,\n padding: sm ? '2px 8px' : '4px 10px',\n borderRadius: 'var(--radius-chip)',\n background: 'var(' + bg + ')',\n // The neutral fill can match a tinted surface it sits on
|
|
1
|
+
{"version":3,"sources":["../../src/core/Badge.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Status pill for the booking lifecycle and other short labels.\n */\nexport interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Semantic tone. Same five tones across Badge, Alert and Toast. */\n tone?: 'success' | 'warning' | 'error' | 'info' | 'neutral';\n size?: 'sm' | 'md';\n /** Leading status dot. Keep it on for lifecycle states. */\n dot?: boolean;\n children?: React.ReactNode;\n}\n\nconst TONES: Record<NonNullable<BadgeProps['tone']>, [string, string, string]> = {\n success: ['--status-success-bg', '--status-success-fg', '--status-success-dot'],\n warning: ['--status-warning-bg', '--status-warning-fg', '--status-warning-dot'],\n error: ['--status-error-bg', '--status-error-fg', '--status-error-dot'],\n info: ['--status-info-bg', '--status-info-fg', '--status-info-dot'],\n // Neutral = an outlined chip (surface fill + hairline border, added below) so it\n // reads on any background, including a tinted one.\n neutral: ['--bg-surface', '--text-secondary', '--text-muted'],\n};\n\nexport function Badge({ tone = 'neutral', size = 'md', dot = true, children, style, ...rest }: BadgeProps) {\n const [bg, fg, dt] = TONES[tone] || TONES.neutral;\n const sm = size === 'sm';\n return (\n <span\n {...rest}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n gap: sm ? 5 : 6,\n padding: sm ? '2px 8px' : '4px 10px',\n borderRadius: 'var(--radius-chip)',\n background: 'var(' + bg + ')',\n // The neutral fill can match a tinted surface it sits on - a hairline\n // keeps the chip defined on any background. Tinted tones read on their own.\n border: 'var(--border-width-hairline) solid ' + (tone === 'neutral' ? 'var(--border-default)' : 'transparent'),\n color: 'var(' + fg + ')',\n fontFamily: 'var(--font-body)',\n fontSize: sm ? 'var(--text-2xs)' : 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n lineHeight: 1.4,\n whiteSpace: 'nowrap',\n ...style,\n })}\n >\n {dot && <span style={sx({ width: sm ? 5 : 6, height: sm ? 5 : 6, borderRadius: '999px', background: 'var(' + dt + ')', flex: '0 0 auto' })} />}\n {children}\n </span>\n );\n}"],"mappings":";AA+BI,SAsBU,KAtBV;AA5BJ,SAAS,UAAU;AAcnB,MAAM,QAA2E;AAAA,EAC/E,SAAS,CAAC,uBAAuB,uBAAuB,sBAAsB;AAAA,EAC9E,SAAS,CAAC,uBAAuB,uBAAuB,sBAAsB;AAAA,EAC9E,OAAO,CAAC,qBAAqB,qBAAqB,oBAAoB;AAAA,EACtE,MAAM,CAAC,oBAAoB,oBAAoB,mBAAmB;AAAA;AAAA;AAAA,EAGlE,SAAS,CAAC,gBAAgB,oBAAoB,cAAc;AAC9D;AAEO,SAAS,MAAM,EAAE,OAAO,WAAW,OAAO,MAAM,MAAM,MAAM,UAAU,OAAO,GAAG,KAAK,GAAe;AACzG,QAAM,CAAC,IAAI,IAAI,EAAE,IAAI,MAAM,IAAI,KAAK,MAAM;AAC1C,QAAM,KAAK,SAAS;AACpB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,KAAK,KAAK,IAAI;AAAA,QACd,SAAS,KAAK,YAAY;AAAA,QAC1B,cAAc;AAAA,QACd,YAAY,SAAS,KAAK;AAAA;AAAA;AAAA,QAG1B,QAAQ,yCAAyC,SAAS,YAAY,0BAA0B;AAAA,QAChG,OAAO,SAAS,KAAK;AAAA,QACrB,YAAY;AAAA,QACZ,UAAU,KAAK,oBAAoB;AAAA,QACnC,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,eAAO,oBAAC,UAAK,OAAO,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,QAAQ,KAAK,IAAI,GAAG,cAAc,SAAS,YAAY,SAAS,KAAK,KAAK,MAAM,WAAW,CAAC,GAAG;AAAA,QAC3I;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
package/dist/core/Brand.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The Sereno mark: an indigo water-drop symbol, optionally locked up with the
|
|
5
|
-
* "sereno" wordmark. Token-driven
|
|
5
|
+
* "sereno" wordmark. Token-driven - the gradient is the brand indigo
|
|
6
6
|
* (`#7d8bdf` → `#4f46e5`), the wordmark uses `--font-display` (Manrope) at 500.
|
|
7
7
|
*/
|
|
8
8
|
interface BrandProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
@@ -10,7 +10,7 @@ interface BrandProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
10
10
|
size?: number;
|
|
11
11
|
/** `symbol` (default), `lockup` (symbol + wordmark, horizontal) or `lockup-vertical`. */
|
|
12
12
|
variant?: 'symbol' | 'lockup' | 'lockup-vertical';
|
|
13
|
-
/** One-colour rendering (`currentColor`) instead of the gradient
|
|
13
|
+
/** One-colour rendering (`currentColor`) instead of the gradient - for favicons, print, tinted surfaces. */
|
|
14
14
|
mono?: boolean;
|
|
15
15
|
}
|
|
16
16
|
declare function Brand({ size, variant, mono, style, ...rest }: BrandProps): React.JSX.Element;
|
package/dist/core/Brand.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Brand.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * The Sereno mark: an indigo water-drop symbol, optionally locked up with the\n * \"sereno\" wordmark. Token-driven
|
|
1
|
+
{"version":3,"sources":["../../src/core/Brand.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * The Sereno mark: an indigo water-drop symbol, optionally locked up with the\n * \"sereno\" wordmark. Token-driven - the gradient is the brand indigo\n * (`#7d8bdf` → `#4f46e5`), the wordmark uses `--font-display` (Manrope) at 500.\n */\nexport interface BrandProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Symbol height in px. In the lockups it also drives the wordmark size. */\n size?: number;\n /** `symbol` (default), `lockup` (symbol + wordmark, horizontal) or `lockup-vertical`. */\n variant?: 'symbol' | 'lockup' | 'lockup-vertical';\n /** One-colour rendering (`currentColor`) instead of the gradient - for favicons, print, tinted surfaces. */\n mono?: boolean;\n}\n\nconst DROP = 'M24 3 C 22 7.5 8 22 8 31.5 C 8 39 15 45 24 45 C 33 45 40 39 40 31.5 C 40 22 26 7.5 24 3 Z';\n\nfunction Mark({ size, mono, decorative }: { size: number; mono: boolean; decorative: boolean }) {\n const gid = React.useId();\n const a11y = decorative ? { 'aria-hidden': true as const } : { role: 'img' as const, 'aria-label': 'Sereno' };\n return (\n <svg width={size} height={size} viewBox=\"0 0 48 48\" {...a11y} style={{ display: 'block', flex: '0 0 auto' }}>\n {!mono && (\n <defs>\n <linearGradient id={gid} x1=\"0\" y1=\"3\" x2=\"0\" y2=\"45\" gradientUnits=\"userSpaceOnUse\">\n <stop offset=\"0\" stopColor=\"#7d8bdf\" />\n <stop offset=\"1\" stopColor=\"#4f46e5\" />\n </linearGradient>\n </defs>\n )}\n <path d={DROP} fill={mono ? 'currentColor' : `url(#${gid})`} />\n </svg>\n );\n}\n\nexport function Brand({ size = 24, variant = 'symbol', mono = false, style, ...rest }: BrandProps) {\n if (variant === 'symbol') {\n return (\n <span {...rest} style={sx({ display: 'inline-flex', ...style })}>\n <Mark size={size} mono={mono} decorative={false} />\n </span>\n );\n }\n\n const vertical = variant === 'lockup-vertical';\n const fontSize = Math.round(size * (vertical ? 1 : 0.78));\n const gap = Math.round(size * (vertical ? 0.28 : 0.34));\n return (\n <span\n {...rest}\n style={sx({\n display: 'inline-flex',\n flexDirection: vertical ? 'column' : 'row',\n alignItems: 'center',\n gap,\n ...style,\n })}\n >\n <Mark size={size} mono={mono} decorative />\n <span\n style={sx({\n fontFamily: 'var(--font-display)',\n fontWeight: 500,\n fontSize,\n letterSpacing: '-0.02em',\n lineHeight: 1,\n color: mono ? 'currentColor' : 'var(--text-primary)',\n })}\n >\n sereno\n </span>\n </span>\n );\n}\n"],"mappings":";AA4BU,SACE,KADF;AA1BV,YAAY,WAAW;AACvB,SAAS,UAAU;AAgBnB,MAAM,OAAO;AAEb,SAAS,KAAK,EAAE,MAAM,MAAM,WAAW,GAAyD;AAC9F,QAAM,MAAM,MAAM,MAAM;AACxB,QAAM,OAAO,aAAa,EAAE,eAAe,KAAc,IAAI,EAAE,MAAM,OAAgB,cAAc,SAAS;AAC5G,SACE,qBAAC,SAAI,OAAO,MAAM,QAAQ,MAAM,SAAQ,aAAa,GAAG,MAAM,OAAO,EAAE,SAAS,SAAS,MAAM,WAAW,GACvG;AAAA,KAAC,QACA,oBAAC,UACC,+BAAC,oBAAe,IAAI,KAAK,IAAG,KAAI,IAAG,KAAI,IAAG,KAAI,IAAG,MAAK,eAAc,kBAClE;AAAA,0BAAC,UAAK,QAAO,KAAI,WAAU,WAAU;AAAA,MACrC,oBAAC,UAAK,QAAO,KAAI,WAAU,WAAU;AAAA,OACvC,GACF;AAAA,IAEF,oBAAC,UAAK,GAAG,MAAM,MAAM,OAAO,iBAAiB,QAAQ,GAAG,KAAK;AAAA,KAC/D;AAEJ;AAEO,SAAS,MAAM,EAAE,OAAO,IAAI,UAAU,UAAU,OAAO,OAAO,OAAO,GAAG,KAAK,GAAe;AACjG,MAAI,YAAY,UAAU;AACxB,WACE,oBAAC,UAAM,GAAG,MAAM,OAAO,GAAG,EAAE,SAAS,eAAe,GAAG,MAAM,CAAC,GAC5D,8BAAC,QAAK,MAAY,MAAY,YAAY,OAAO,GACnD;AAAA,EAEJ;AAEA,QAAM,WAAW,YAAY;AAC7B,QAAM,WAAW,KAAK,MAAM,QAAQ,WAAW,IAAI,KAAK;AACxD,QAAM,MAAM,KAAK,MAAM,QAAQ,WAAW,OAAO,KAAK;AACtD,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,eAAe,WAAW,WAAW;AAAA,QACrC,YAAY;AAAA,QACZ;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAAA,MAED;AAAA,4BAAC,QAAK,MAAY,MAAY,YAAU,MAAC;AAAA,QACzC;AAAA,UAAC;AAAA;AAAA,YACC,OAAO,GAAG;AAAA,cACR,YAAY;AAAA,cACZ,YAAY;AAAA,cACZ;AAAA,cACA,eAAe;AAAA,cACf,YAAY;AAAA,cACZ,OAAO,OAAO,iBAAiB;AAAA,YACjC,CAAC;AAAA,YACF;AAAA;AAAA,QAED;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
package/dist/core/Button.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
/**
|
|
4
4
|
* Primary action control. `primary` for navigation-level commitment, `accent` for the single
|
|
5
5
|
* conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the
|
|
6
|
-
* same words as Badge / Alert / Toast. (No `info`
|
|
6
|
+
* same words as Badge / Alert / Toast. (No `info` - in Sereno that is the brand indigo = `primary`.)
|
|
7
7
|
*/
|
|
8
8
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
9
9
|
/** Visual role. Only one `accent` button per screen. */
|
package/dist/core/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Primary action control. `primary` for navigation-level commitment, `accent` for the single\n * conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the\n * same words as Badge / Alert / Toast. (No `info`
|
|
1
|
+
{"version":3,"sources":["../../src/core/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Primary action control. `primary` for navigation-level commitment, `accent` for the single\n * conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the\n * same words as Badge / Alert / Toast. (No `info` - in Sereno that is the brand indigo = `primary`.)\n */\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual role. Only one `accent` button per screen. */\n variant?: 'primary' | 'accent' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'error';\n /** Control height. `lg`/`xl` are the mobile defaults (≥44px tap target). */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n fullWidth?: boolean;\n disabled?: boolean;\n /** Shows a spinner and blocks interaction. */\n loading?: boolean;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n children?: React.ReactNode;\n}\n\nexport interface InteractState {\n hover: boolean;\n press: boolean;\n focus: boolean;\n handlers: React.HTMLAttributes<HTMLElement>;\n}\n\n/** Shared hover / press / focus-visible tracking used by Button, IconButton and Card. */\nexport function useInteract(disabled: boolean): InteractState {\n const [hover, setHover] = React.useState(false);\n const [press, setPress] = React.useState(false);\n const [focus, setFocus] = React.useState(false);\n const handlers: React.HTMLAttributes<HTMLElement> = disabled\n ? {}\n : {\n onMouseEnter: () => setHover(true),\n onMouseLeave: () => {\n setHover(false);\n setPress(false);\n },\n onMouseDown: () => setPress(true),\n onMouseUp: () => setPress(false),\n onFocus: (e) => {\n if ((e.target as HTMLElement).matches(':focus-visible')) setFocus(true);\n },\n onBlur: () => setFocus(false),\n };\n return { hover, press, focus, handlers };\n}\n\nconst SIZES = {\n sm: { h: 'var(--control-height-sm)', px: 'var(--space-3)', fs: 'var(--text-sm)', gap: '6px' },\n md: { h: 'var(--control-height-md)', px: 'var(--space-4)', fs: 'var(--text-base)', gap: '8px' },\n lg: { h: 'var(--control-height-lg)', px: 'var(--space-5)', fs: 'var(--text-md)', gap: '10px' },\n xl: { h: 'var(--control-height-xl)', px: 'var(--space-6)', fs: 'var(--text-lg)', gap: '10px' },\n} as const;\n\nfunction palette(variant: NonNullable<ButtonProps['variant']>, s: InteractState) {\n switch (variant) {\n case 'accent':\n return { bg: s.press ? 'var(--interactive-accent-active)' : s.hover ? 'var(--interactive-accent-hover)' : 'var(--interactive-accent)', fg: 'var(--interactive-accent-fg)', bd: 'transparent', sh: s.hover && !s.press ? 'var(--shadow-accent)' : 'var(--shadow-xs)', ring: 'var(--focus-ring-accent)' };\n case 'secondary':\n return { bg: s.press ? 'var(--interactive-secondary-active)' : s.hover ? 'var(--interactive-secondary-hover)' : 'var(--interactive-secondary)', fg: 'var(--interactive-secondary-fg)', bd: 'var(--border-default)', sh: 'var(--shadow-xs)', ring: 'var(--focus-ring)' };\n case 'ghost':\n return { bg: s.hover ? 'var(--interactive-ghost-hover)' : 'transparent', fg: 'var(--text-secondary)', bd: 'transparent', sh: 'none', ring: 'var(--focus-ring)' };\n case 'success':\n return { bg: s.hover ? 'var(--interactive-success-hover)' : 'var(--interactive-success)', fg: 'var(--interactive-success-fg)', bd: 'transparent', sh: 'var(--shadow-xs)', ring: 'var(--focus-ring)' };\n case 'warning':\n return { bg: s.hover ? 'var(--interactive-warning-hover)' : 'var(--interactive-warning)', fg: 'var(--interactive-warning-fg)', bd: 'transparent', sh: 'var(--shadow-xs)', ring: 'var(--focus-ring)' };\n case 'error':\n return { bg: s.hover ? 'var(--interactive-error-hover)' : 'var(--interactive-error)', fg: 'var(--interactive-error-fg)', bd: 'transparent', sh: 'var(--shadow-xs)', ring: 'var(--focus-ring)' };\n case 'link':\n return { bg: 'transparent', fg: s.hover ? 'var(--text-link-hover)' : 'var(--text-link)', bd: 'transparent', sh: 'none', ring: 'var(--focus-ring)' };\n default:\n return { bg: s.press ? 'var(--interactive-primary-active)' : s.hover ? 'var(--interactive-primary-hover)' : 'var(--interactive-primary)', fg: 'var(--interactive-primary-fg)', bd: 'transparent', sh: s.hover && !s.press ? 'var(--shadow-brand)' : 'var(--shadow-xs)', ring: 'var(--focus-ring)' };\n }\n}\n\nexport function Button({ variant = 'primary', size = 'md', fullWidth = false, disabled = false, loading = false, iconLeft, iconRight, children, style, ...rest }: ButtonProps) {\n const st = useInteract(disabled || loading);\n const sz = SIZES[size] || SIZES.md;\n const p = palette(variant, st);\n const isLink = variant === 'link';\n return (\n <button\n type=\"button\"\n disabled={disabled || loading}\n {...st.handlers}\n {...rest}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: sz.gap,\n height: isLink ? 'auto' : sz.h,\n padding: isLink ? 0 : '0 ' + sz.px,\n width: fullWidth ? '100%' : undefined,\n fontFamily: 'var(--font-body)',\n fontSize: sz.fs,\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n borderRadius: isLink ? 'var(--radius-xs)' : 'var(--radius-control)',\n border: 'var(--border-width-hairline) solid ' + (disabled ? 'transparent' : p.bd),\n background: disabled ? 'var(--interactive-disabled-bg)' : p.bg,\n color: disabled ? 'var(--interactive-disabled-fg)' : p.fg,\n boxShadow: disabled ? 'none' : st.focus ? p.ring : p.sh,\n transform: st.press && !disabled ? 'scale(var(--press-scale))' : 'none',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: loading ? 0.75 : 1,\n transition: 'var(--transition-control)',\n outline: 'none',\n textDecoration: isLink && st.hover ? 'underline' : 'none',\n textUnderlineOffset: '2px',\n ...style,\n })}\n >\n {loading ? (\n <span style={sx({ width: '1em', height: '1em', borderRadius: '999px', border: '2px solid currentColor', borderTopColor: 'transparent', display: 'inline-block', animation: 'sereno-spin .7s linear infinite' })} />\n ) : (\n iconLeft\n )}\n {children}\n {iconRight}\n </button>\n );\n}"],"mappings":"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","names":[]}
|
package/dist/core/Card.js
CHANGED
|
@@ -34,7 +34,7 @@ function Card({ padding = "md", elevation = "sm", interactive = false, selected
|
|
|
34
34
|
transition: "var(--transition-control)",
|
|
35
35
|
cursor: interactive ? "pointer" : "default",
|
|
36
36
|
// outline:none is safe here (unlike the CSS-class pattern elsewhere in
|
|
37
|
-
// this package)
|
|
37
|
+
// this package) - it pairs with the JS-driven boxShadow ring above,
|
|
38
38
|
// the same useInteract-based substitute Button/IconButton already use.
|
|
39
39
|
outline: clickable ? "none" : void 0,
|
|
40
40
|
...style
|
package/dist/core/Card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Card.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { useInteract } from './Button';\n\n/** Neutral surface container: a crisp 1px ring + optional soft lift + 14px radius. The base of every list row and panel. */\nexport interface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n padding?: 'none' | 'sm' | 'md' | 'lg';\n elevation?: 'none' | 'sm' | 'md' | 'lg';\n /** Adds hover lift, press scale and pointer cursor. */\n interactive?: boolean;\n /** Brand-coloured ring for a chosen option. */\n selected?: boolean;\n children?: React.ReactNode;\n}\n\nconst PADS = { none: 0, sm: 'var(--space-3)', md: 'var(--space-4)', lg: 'var(--space-5)' } as const;\n// The edge is a box-shadow ring (pixel-crisp at any radius), with the elevation\n// drop-shadow layered beneath it
|
|
1
|
+
{"version":3,"sources":["../../src/core/Card.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { useInteract } from './Button';\n\n/** Neutral surface container: a crisp 1px ring + optional soft lift + 14px radius. The base of every list row and panel. */\nexport interface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n padding?: 'none' | 'sm' | 'md' | 'lg';\n elevation?: 'none' | 'sm' | 'md' | 'lg';\n /** Adds hover lift, press scale and pointer cursor. */\n interactive?: boolean;\n /** Brand-coloured ring for a chosen option. */\n selected?: boolean;\n children?: React.ReactNode;\n}\n\nconst PADS = { none: 0, sm: 'var(--space-3)', md: 'var(--space-4)', lg: 'var(--space-5)' } as const;\n// The edge is a box-shadow ring (pixel-crisp at any radius), with the elevation\n// drop-shadow layered beneath it - never a real `border` fighting the shadow.\nconst DROP = { none: '', sm: 'var(--shadow-xs)', md: 'var(--shadow-md)', lg: 'var(--shadow-lg)' } as const;\n\nexport function Card({ padding = 'md', elevation = 'sm', interactive = false, selected = false, children, style, onClick, onKeyDown, ...rest }: CardProps) {\n const st = useInteract(!interactive);\n const lifted = interactive && st.hover;\n // A Card only needs real button semantics (SS-228) when it owns its own\n // onClick - `interactive` alone (no onClick) means it's just borrowing the\n // hover/press visual inside an already-interactive wrapper (e.g. the\n // landing page's Cards inside a <Link>), and giving it a tabIndex there\n // would nest one focusable control inside another.\n const clickable = interactive && !!onClick;\n\n const ring = selected ? '0 0 0 1.5px var(--border-brand)' : '0 0 0 1px ' + (st.hover ? 'var(--border-strong)' : 'var(--border-default)');\n const drop = selected ? 'var(--shadow-md)' : lifted ? (elevation === 'lg' ? 'var(--shadow-lg)' : 'var(--shadow-md)') : DROP[elevation];\n\n return (\n <div\n {...(interactive ? st.handlers : {})}\n role={clickable ? 'button' : undefined}\n tabIndex={clickable ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n clickable\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n // Not a real MouseEvent - every onClick in this codebase ignores\n // the event argument, so the cast is safe in practice.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- see above\n onClick(e as any);\n }\n onKeyDown?.(e);\n }\n : onKeyDown\n }\n {...rest}\n style={sx({\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-card)',\n padding: PADS[padding],\n boxShadow: [ring, drop, clickable && st.focus ? 'var(--focus-ring)' : null].filter(Boolean).join(', '),\n transform: lifted && !st.press ? 'translateY(var(--hover-lift))' : interactive && st.press ? 'scale(var(--press-scale))' : 'none',\n transition: 'var(--transition-control)',\n cursor: interactive ? 'pointer' : 'default',\n // outline:none is safe here (unlike the CSS-class pattern elsewhere in\n // this package) - it pairs with the JS-driven boxShadow ring above,\n // the same useInteract-based substitute Button/IconButton already use.\n outline: clickable ? 'none' : undefined,\n ...style,\n })}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";AAoCI;AAjCJ,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAa5B,MAAM,OAAO,EAAE,MAAM,GAAG,IAAI,kBAAkB,IAAI,kBAAkB,IAAI,iBAAiB;AAGzF,MAAM,OAAO,EAAE,MAAM,IAAI,IAAI,oBAAoB,IAAI,oBAAoB,IAAI,mBAAmB;AAEzF,SAAS,KAAK,EAAE,UAAU,MAAM,YAAY,MAAM,cAAc,OAAO,WAAW,OAAO,UAAU,OAAO,SAAS,WAAW,GAAG,KAAK,GAAc;AACzJ,QAAM,KAAK,YAAY,CAAC,WAAW;AACnC,QAAM,SAAS,eAAe,GAAG;AAMjC,QAAM,YAAY,eAAe,CAAC,CAAC;AAEnC,QAAM,OAAO,WAAW,oCAAoC,gBAAgB,GAAG,QAAQ,yBAAyB;AAChH,QAAM,OAAO,WAAW,qBAAqB,SAAU,cAAc,OAAO,qBAAqB,qBAAsB,KAAK,SAAS;AAErI,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAI,cAAc,GAAG,WAAW,CAAC;AAAA,MAClC,MAAM,YAAY,WAAW;AAAA,MAC7B,UAAU,YAAY,IAAI;AAAA,MAC1B;AAAA,MACA,WACE,YACI,CAAC,MAAM;AACL,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,YAAE,eAAe;AAIjB,kBAAQ,CAAQ;AAAA,QAClB;AACA,oBAAY,CAAC;AAAA,MACf,IACA;AAAA,MAEL,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,SAAS,KAAK,OAAO;AAAA,QACrB,WAAW,CAAC,MAAM,MAAM,aAAa,GAAG,QAAQ,sBAAsB,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAAA,QACrG,WAAW,UAAU,CAAC,GAAG,QAAQ,kCAAkC,eAAe,GAAG,QAAQ,8BAA8B;AAAA,QAC3H,YAAY;AAAA,QACZ,QAAQ,cAAc,YAAY;AAAA;AAAA;AAAA;AAAA,QAIlC,SAAS,YAAY,SAAS;AAAA,QAC9B,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -2,12 +2,12 @@ import * as React from 'react';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Square icon-only control for toolbars, card corners and top bars. Always pass `label`.
|
|
5
|
-
* `success` / `warning` / `error` are solid semantic fills
|
|
5
|
+
* `success` / `warning` / `error` are solid semantic fills - same words as Button / Badge.
|
|
6
6
|
*/
|
|
7
7
|
interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
8
8
|
variant?: 'ghost' | 'secondary' | 'primary' | 'success' | 'warning' | 'error';
|
|
9
9
|
size?: 'sm' | 'md' | 'lg';
|
|
10
|
-
/** Accessible name
|
|
10
|
+
/** Accessible name - becomes aria-label and title. Required. */
|
|
11
11
|
label: string;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
/** The icon element (Lucide 20px stroke 1.75). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/IconButton.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { useInteract } from './Button';\n\n/**\n * Square icon-only control for toolbars, card corners and top bars. Always pass `label`.\n * `success` / `warning` / `error` are solid semantic fills
|
|
1
|
+
{"version":3,"sources":["../../src/core/IconButton.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { useInteract } from './Button';\n\n/**\n * Square icon-only control for toolbars, card corners and top bars. Always pass `label`.\n * `success` / `warning` / `error` are solid semantic fills - same words as Button / Badge.\n */\nexport interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: 'ghost' | 'secondary' | 'primary' | 'success' | 'warning' | 'error';\n size?: 'sm' | 'md' | 'lg';\n /** Accessible name - becomes aria-label and title. Required. */\n label: string;\n disabled?: boolean;\n /** The icon element (Lucide 20px stroke 1.75). */\n children?: React.ReactNode;\n}\n\nconst S = { sm: 32, md: 40, lg: 48 } as const;\n\n/** Solid-fill variants: [base, hover, fg]. */\nconst SOLID: Partial<Record<NonNullable<IconButtonProps['variant']>, [string, string, string]>> = {\n primary: ['--interactive-primary', '--interactive-primary-hover', '--interactive-primary-fg'],\n success: ['--interactive-success', '--interactive-success-hover', '--interactive-success-fg'],\n warning: ['--interactive-warning', '--interactive-warning-hover', '--interactive-warning-fg'],\n error: ['--interactive-error', '--interactive-error-hover', '--interactive-error-fg'],\n};\n\nexport function IconButton({ variant = 'ghost', size = 'md', label, disabled = false, children, style, ...rest }: IconButtonProps) {\n const st = useInteract(disabled);\n const d = S[size] || S.md;\n const solid = SOLID[variant];\n const outline = variant === 'secondary';\n\n let background = 'transparent';\n let color = 'var(--text-secondary)';\n if (disabled) {\n background = 'var(--interactive-disabled-bg)';\n color = 'var(--interactive-disabled-fg)';\n } else if (solid) {\n background = `var(${st.hover ? solid[1] : solid[0]})`;\n color = `var(${solid[2]})`;\n } else if (outline) {\n background = st.hover ? 'var(--interactive-secondary-hover)' : 'var(--interactive-secondary)';\n } else if (st.hover) {\n background = 'var(--interactive-ghost-hover)';\n }\n\n return (\n <button\n type=\"button\"\n aria-label={label}\n title={label}\n disabled={disabled}\n {...st.handlers}\n {...rest}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: d,\n height: d,\n flex: '0 0 auto',\n borderRadius: 'var(--radius-control)',\n border: 'var(--border-width-hairline) solid ' + (outline ? 'var(--border-default)' : 'transparent'),\n background,\n color,\n boxShadow: st.focus ? 'var(--focus-ring)' : 'none',\n transform: st.press && !disabled ? 'scale(var(--press-scale))' : 'none',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n outline: 'none',\n ...style,\n })}\n >\n {children}\n </button>\n );\n}\n"],"mappings":";AAmDI;AAhDJ,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAgB5B,MAAM,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAGnC,MAAM,QAA4F;AAAA,EAChG,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,OAAO,CAAC,uBAAuB,6BAA6B,wBAAwB;AACtF;AAEO,SAAS,WAAW,EAAE,UAAU,SAAS,OAAO,MAAM,OAAO,WAAW,OAAO,UAAU,OAAO,GAAG,KAAK,GAAoB;AACjI,QAAM,KAAK,YAAY,QAAQ;AAC/B,QAAM,IAAI,EAAE,IAAI,KAAK,EAAE;AACvB,QAAM,QAAQ,MAAM,OAAO;AAC3B,QAAM,UAAU,YAAY;AAE5B,MAAI,aAAa;AACjB,MAAI,QAAQ;AACZ,MAAI,UAAU;AACZ,iBAAa;AACb,YAAQ;AAAA,EACV,WAAW,OAAO;AAChB,iBAAa,OAAO,GAAG,QAAQ,MAAM,CAAC,IAAI,MAAM,CAAC,CAAC;AAClD,YAAQ,OAAO,MAAM,CAAC,CAAC;AAAA,EACzB,WAAW,SAAS;AAClB,iBAAa,GAAG,QAAQ,uCAAuC;AAAA,EACjE,WAAW,GAAG,OAAO;AACnB,iBAAa;AAAA,EACf;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO;AAAA,MACP;AAAA,MACC,GAAG,GAAG;AAAA,MACN,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,cAAc;AAAA,QACd,QAAQ,yCAAyC,UAAU,0BAA0B;AAAA,QACrF;AAAA,QACA;AAAA,QACA,WAAW,GAAG,QAAQ,sBAAsB;AAAA,QAC5C,WAAW,GAAG,SAAS,CAAC,WAAW,8BAA8B;AAAA,QACjE,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
package/dist/core/Menu.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Action menu / dropdown
|
|
4
|
+
* Action menu / dropdown - a `trigger` you supply plus a portalled panel of
|
|
5
5
|
* items. Same mechanics as `Select`: `position: fixed` panel measured off the
|
|
6
6
|
* trigger, flips up when there's no room, closes on outside pointerdown / `Escape`
|
|
7
7
|
* / selection, and returns focus to the trigger. `role="menu"` with arrow-key
|
|
@@ -24,7 +24,7 @@ import * as React from 'react';
|
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
26
|
* For a rich popover (a notifications list, say) pass a render function instead
|
|
27
|
-
* of `items`
|
|
27
|
+
* of `items` - it receives `close`:
|
|
28
28
|
* `<Menu trigger={…}>{(close) => <NotificationList onDone={close} />}</Menu>`
|
|
29
29
|
*/
|
|
30
30
|
interface MenuItem {
|
|
@@ -49,14 +49,14 @@ type MenuEntry = MenuItem | MenuSeparator | MenuHeading;
|
|
|
49
49
|
interface MenuProps {
|
|
50
50
|
/** The clickable element that opens the menu (an `IconButton`, `Button`, avatar button…). */
|
|
51
51
|
trigger: React.ReactElement;
|
|
52
|
-
/** Overlaid on the trigger
|
|
52
|
+
/** Overlaid on the trigger - a notification count, a status dot. Sits in a
|
|
53
53
|
* `pointer-events: none` layer so a click still opens the menu. */
|
|
54
54
|
adornment?: React.ReactNode;
|
|
55
55
|
/** Structured rows. Omit when using the `children` render function. */
|
|
56
56
|
items?: MenuEntry[];
|
|
57
|
-
/** Rich panel content
|
|
57
|
+
/** Rich panel content - receives `close`. Mutually exclusive with `items`. */
|
|
58
58
|
children?: (close: () => void) => React.ReactNode;
|
|
59
|
-
/** A block above the `items`
|
|
59
|
+
/** A block above the `items` - a name + email, a title. Not part of the keyboard roving. */
|
|
60
60
|
header?: React.ReactNode;
|
|
61
61
|
/** Accessible name for the panel, and a heading row when `items` is used. */
|
|
62
62
|
label?: string;
|