@jonmilner/ui 0.11.2 → 0.11.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/dist/Avatar/Avatar.css +1 -1
- package/dist/Badge/Badge.css +1 -1
- package/dist/Box/Box.css +1 -1
- package/dist/Button/Button.css +1 -1
- package/dist/Checkbox/Checkbox.css +1 -1
- package/dist/Chip/Chip.css +1 -1
- package/dist/Clickable/Clickable.css +1 -1
- package/dist/ColorField/ColorField.css +1 -1
- package/dist/Dialog/Dialog.css +1 -1
- package/dist/Field/Field.css +1 -1
- package/dist/Heading/Heading.css +1 -1
- package/dist/Icon/Icon.css +1 -1
- package/dist/IconButton/IconButton.css +1 -1
- package/dist/Inline/Inline.css +1 -1
- package/dist/Menu/Menu.css +1 -1
- package/dist/MultiSelect/MultiSelect.css +1 -1
- package/dist/SearchField/SearchField.css +1 -1
- package/dist/Stack/Stack.css +1 -1
- package/dist/Table/Table.css +2 -0
- package/dist/Table/Table.css.mjs +16 -0
- package/dist/Table/index.d.mts +61 -0
- package/dist/Table/index.mjs +110 -0
- package/dist/Tabs/Tabs.css +1 -1
- package/dist/Tag/Tag.css +1 -1
- package/dist/Text/Text.css +2 -2
- package/dist/Text/Text.css.mjs +6 -6
- package/dist/Text/index.d.mts +2 -1
- package/dist/Text/index.mjs +12 -11
- package/dist/TextField/TextField.css +1 -1
- package/dist/Textarea/Textarea.css +2 -0
- package/dist/Textarea/Textarea.css.mjs +17 -0
- package/dist/Textarea/index.d.mts +23 -0
- package/dist/Textarea/index.mjs +40 -0
- package/dist/Toast/Toast.css +1 -1
- package/dist/VisuallyHidden/VisuallyHidden.css +1 -1
- package/dist/base.css +1 -1
- package/dist/contrast/mixes.mjs +38 -17
- package/dist/docs/Box.md +25 -3
- package/dist/docs/Field.md +4 -1
- package/dist/docs/Heading.md +1 -0
- package/dist/docs/Stack.md +27 -0
- package/dist/docs/Table.md +192 -0
- package/dist/docs/Tabs.md +1 -0
- package/dist/docs/Text.md +2 -0
- package/dist/docs/TextField.md +1 -1
- package/dist/docs/Textarea.md +103 -0
- package/dist/docs/lint.md +1 -1
- package/dist/docs/llms.txt +9 -0
- package/dist/docs/manifest.json +351 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +11 -9
- package/dist/lint/index.mjs +2 -0
- package/dist/styles/atoms.css +1 -1
- package/dist/styles/hover-tint.mjs +1 -1
- package/dist/styles/layers.css +1 -1
- package/dist/styles/responsive.css +1 -1
- package/dist/styles/split-text-props.mjs +1 -0
- package/package.json +9 -1
package/dist/base.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@layer tokens, reset, atoms.base, atoms.sm, atoms.med, atoms.lg, atoms.xl, components.box, components.checkbox, components.clickable, components.icon, components.icon-button, components.inline, components.stack, components.text, components.avatar, components.badge, components.button, components.chip, components.field, components.color-field, components.heading, components.dialog, components.alert-dialog, components.menu, components.multiselect, components.search-field, components.tabs, components.tag, components.text-field, components.toast, components.visually-hidden;
|
|
1
|
+
@layer tokens, reset, atoms.base, atoms.sm, atoms.med, atoms.lg, atoms.xl, components.box, components.checkbox, components.clickable, components.icon, components.icon-button, components.inline, components.stack, components.text, components.avatar, components.badge, components.button, components.chip, components.field, components.color-field, components.heading, components.dialog, components.alert-dialog, components.menu, components.multiselect, components.search-field, components.tabs, components.tag, components.text-field, components.textarea, components.toast, components.visually-hidden, components.table;
|
|
2
2
|
@layer tokens{:root{--space-0:0rem;--space-1:.0625rem;--space-2:.125rem;--space-4:.25rem;--space-6:.375rem;--space-8:.5rem;--space-12:.75rem;--space-16:1rem;--space-20:1.25rem;--space-24:1.5rem;--space-32:2rem;--space-40:2.5rem;--space-48:3rem;--space-64:4rem;--space-80:5rem;--space-96:6rem;--size-xs:1.5rem;--size-sm:2rem;--size-med:2.5rem;--size-lg:3rem;--size-xl:3.5rem;--container-prose:40rem;--container-page:64rem;--container-wide:80rem;--radius-none:0;--radius-sm:.25rem;--radius-med:.5rem;--radius-lg:.75rem;--radius-xl:1rem;--radius-full:9999px;--font-size-xs:.75rem;--font-size-sm:.875rem;--font-size-med:1rem;--font-size-lg:1.125rem;--font-size-xl:1.25rem;--font-size-2xl:1.5rem;--font-size-3xl:1.875rem;--font-size-4xl:2.25rem;--font-weight-regular:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--line-height-sm:1.25;--line-height-med:1.5;--line-height-lg:1.75;--z-index-base:0;--z-index-raised:1;--z-index-dropdown:1000;--z-index-sticky:1100;--z-index-overlay:1200;--z-index-modal:1300;--z-index-popover:1400;--z-index-toast:1500;--z-index-tooltip:1600;--duration-fast:.12s;--duration-med:.2s;--duration-slow:.32s;--easing-standard:cubic-bezier(.2, 0, 0, 1);--easing-enter:cubic-bezier(0, 0, 0, 1);--easing-exit:cubic-bezier(.3, 0, 1, 1);--distance-sm:.25rem;--distance-med:.5rem;--distance-lg:1rem;--scale-sm:.02;--scale-med:.05;--scale-lg:.1}[data-brand]{--shadow-sm:0 1px 2px color-mix(in srgb, var(--color-shadow) 12%, transparent);--shadow-med:0 2px 8px color-mix(in srgb, var(--color-shadow) 14%, transparent), 0 1px 2px color-mix(in srgb, var(--color-shadow) 8%, transparent);--shadow-lg:0 8px 24px color-mix(in srgb, var(--color-shadow) 16%, transparent), 0 2px 6px color-mix(in srgb, var(--color-shadow) 8%, transparent)}[data-brand][data-mode=light]{color-scheme:light}[data-brand][data-mode=dark]{--shadow-sm:0 0 0 1px color-mix(in srgb, var(--color-fg) 10%, transparent), 0 1px 2px color-mix(in srgb, var(--color-shadow) 40%, transparent);--shadow-med:0 0 0 1px color-mix(in srgb, var(--color-fg) 10%, transparent), 0 2px 8px color-mix(in srgb, var(--color-shadow) 48%, transparent), 0 1px 2px color-mix(in srgb, var(--color-shadow) 32%, transparent);--shadow-lg:0 0 0 1px color-mix(in srgb, var(--color-fg) 10%, transparent), 0 8px 24px color-mix(in srgb, var(--color-shadow) 56%, transparent), 0 2px 6px color-mix(in srgb, var(--color-shadow) 32%, transparent);color-scheme:dark}[data-brand][data-mode=system]{color-scheme:light dark}:dir(ltr){--dir:1}:dir(rtl){--dir:-1}@media (prefers-color-scheme:dark){[data-brand][data-mode=system]{--shadow-sm:0 0 0 1px color-mix(in srgb, var(--color-fg) 10%, transparent), 0 1px 2px color-mix(in srgb, var(--color-shadow) 40%, transparent);--shadow-med:0 0 0 1px color-mix(in srgb, var(--color-fg) 10%, transparent), 0 2px 8px color-mix(in srgb, var(--color-shadow) 48%, transparent), 0 1px 2px color-mix(in srgb, var(--color-shadow) 32%, transparent);--shadow-lg:0 0 0 1px color-mix(in srgb, var(--color-fg) 10%, transparent), 0 8px 24px color-mix(in srgb, var(--color-shadow) 56%, transparent), 0 2px 6px color-mix(in srgb, var(--color-shadow) 32%, transparent)}}@media (prefers-reduced-motion:reduce){:root{--distance-sm:0rem;--distance-med:0rem;--distance-lg:0rem;--scale-sm:0;--scale-med:0;--scale-lg:0;--duration-fast:.12s;--duration-med:.12s;--duration-slow:.12s}}}
|
|
3
3
|
|
|
4
4
|
@font-face{src:local(Arial),local(ArialMT);font-weight:400;font-style:normal;size-adjust:101.568%;ascent-override:95.3892%;descent-override:23.7511%;line-gap-override:0%;font-family:Inter Fallback Arial}@font-face{src:local(Arial Bold),local(Arial-BoldMT);font-weight:700;font-style:normal;size-adjust:101.637%;ascent-override:95.3241%;descent-override:23.7349%;line-gap-override:0%;font-family:Inter Fallback Arial}@font-face{src:local(Arial Italic),local(Arial-ItalicMT);font-weight:400;font-style:italic;size-adjust:101.637%;ascent-override:95.3241%;descent-override:23.7349%;line-gap-override:0%;font-family:Inter Fallback Arial}@font-face{src:local(Arial Bold Italic),local(Arial-BoldItalicMT);font-weight:700;font-style:italic;size-adjust:101.706%;ascent-override:95.2591%;descent-override:23.7187%;line-gap-override:0%;font-family:Inter Fallback Arial}@font-face{src:local(Menlo Regular),local(Menlo-Regular);font-weight:400;font-style:normal;size-adjust:100.137%;ascent-override:101.871%;descent-override:29.9621%;line-gap-override:0%;font-family:JetBrains Mono Fallback Menlo}@font-face{src:local(Menlo Bold),local(Menlo-Bold);font-weight:700;font-style:normal;size-adjust:100.003%;ascent-override:102.007%;descent-override:30.0022%;line-gap-override:0%;font-family:JetBrains Mono Fallback Menlo}@font-face{src:local(Menlo Italic),local(Menlo-Italic);font-weight:400;font-style:italic;size-adjust:100.137%;ascent-override:101.871%;descent-override:29.9621%;line-gap-override:0%;font-family:JetBrains Mono Fallback Menlo}@font-face{src:local(Menlo Bold Italic),local(Menlo-BoldItalic);font-weight:700;font-style:italic;size-adjust:100.003%;ascent-override:102.007%;descent-override:30.0022%;line-gap-override:0%;font-family:JetBrains Mono Fallback Menlo}@font-face{src:local(Consolas);font-weight:400;font-style:normal;size-adjust:114.387%;ascent-override:89.1798%;descent-override:26.2293%;line-gap-override:0%;font-family:JetBrains Mono Fallback Consolas}@font-face{src:local(Consolas Bold),local(Consolas-Bold);font-weight:700;font-style:normal;size-adjust:114.387%;ascent-override:89.1798%;descent-override:26.2293%;line-gap-override:0%;font-family:JetBrains Mono Fallback Consolas}@font-face{src:local(Consolas Italic),local(Consolas-Italic);font-weight:400;font-style:italic;size-adjust:114.387%;ascent-override:89.1798%;descent-override:26.2293%;line-gap-override:0%;font-family:JetBrains Mono Fallback Consolas}@font-face{src:local(Consolas Bold Italic),local(Consolas-BoldItalic);font-weight:700;font-style:italic;size-adjust:114.387%;ascent-override:89.1798%;descent-override:26.2293%;line-gap-override:0%;font-family:JetBrains Mono Fallback Consolas}@font-face{src:local(Courier New),local(CourierNewPSMT);font-weight:400;font-style:normal;size-adjust:127.781%;ascent-override:79.8319%;descent-override:23.48%;line-gap-override:0%;font-family:JetBrains Mono Fallback Courier New}@font-face{src:local(Courier New Bold),local(CourierNewPS-BoldMT);font-weight:700;font-style:normal;size-adjust:123.353%;ascent-override:82.6977%;descent-override:24.3229%;line-gap-override:0%;font-family:JetBrains Mono Fallback Courier New}@font-face{src:local(Courier New Italic),local(CourierNewPS-ItalicMT);font-weight:400;font-style:italic;size-adjust:127.781%;ascent-override:79.8319%;descent-override:23.48%;line-gap-override:0%;font-family:JetBrains Mono Fallback Courier New}@font-face{src:local(Courier New Bold Italic),local(CourierNewPS-BoldItalicMT);font-weight:700;font-style:italic;size-adjust:123.353%;ascent-override:82.6977%;descent-override:24.3229%;line-gap-override:0%;font-family:JetBrains Mono Fallback Courier New}@layer tokens{[data-brand=default]{--color-bg:light-dark(oklch(100% 0 0),oklch(14.5% .006 265));--color-bg-muted:light-dark(oklch(96.8% .004 265),oklch(27% .01 265));--color-bg-raised:light-dark(oklch(100% 0 0),oklch(20.5% .008 265));--color-fg:light-dark(oklch(14.5% .006 265),oklch(98.5% .002 265));--color-fg-muted:light-dark(oklch(44.5% .014 265),oklch(71% .012 265));--color-border:light-dark(oklch(92.5% .006 265),oklch(27% .01 265));--color-border-strong:oklch(55.5% .014 265);--color-accent:light-dark(oklch(54.6% .19 258),oklch(70.7% .14 258));--color-accent-fg:light-dark(oklch(100% 0 0),oklch(14.5% .006 265));--color-accent-fill:light-dark(oklch(54.6% .19 258),oklch(48.8% .18 258));--color-accent-fill-fg:oklch(100% 0 0);--color-danger:light-dark(oklch(56% .2 25),oklch(70.4% .17 25));--color-danger-fg:light-dark(oklch(100% 0 0),oklch(14.5% .006 265));--color-success:light-dark(oklch(52% .135 150),oklch(76% .15 150));--color-success-fg:light-dark(oklch(100% 0 0),oklch(14.5% .006 265));--color-warning:light-dark(oklch(53% .11 75),oklch(81% .145 75));--color-warning-fg:light-dark(oklch(100% 0 0),oklch(14.5% .006 265));--color-done:light-dark(oklch(55% .2 295),oklch(72% .15 295));--color-done-fg:light-dark(oklch(100% 0 0),oklch(14.5% .006 265));--color-neutral-subtle:light-dark(oklch(96.8% .004 265),oklch(27% .01 265));--color-neutral-subtle-fg:light-dark(oklch(37% .013 265),oklch(92.5% .006 265));--color-accent-subtle:light-dark(oklch(93.2% .032 258),oklch(28.2% .09 258));--color-accent-subtle-fg:light-dark(oklch(48.8% .18 258),oklch(80.9% .095 258));--color-success-subtle:light-dark(oklch(94.5% .04 150),oklch(26% .06 150));--color-success-subtle-fg:light-dark(oklch(46.5% .12 150),oklch(84% .115 150));--color-warning-subtle:light-dark(oklch(95.5% .03 75),oklch(27% .05 75));--color-warning-subtle-fg:light-dark(oklch(47.5% .1 75),oklch(86% .105 75));--color-danger-subtle:light-dark(oklch(93.6% .032 25),oklch(25.8% .085 25));--color-danger-subtle-fg:light-dark(oklch(50.5% .19 25),oklch(80.8% .105 25));--color-done-subtle:light-dark(oklch(93.8% .032 295),oklch(28% .095 295));--color-done-subtle-fg:light-dark(oklch(49% .19 295),oklch(81.5% .1 295));--color-focus:light-dark(oklch(54.6% .19 258),oklch(70.7% .14 258));--color-shadow:light-dark(oklch(14.5% .006 265),oklch(0% 0 0));--font-body:"Inter", "Inter Fallback Arial", sans-serif;--font-heading:"Inter", "Inter Fallback Arial", sans-serif;--font-display:"Inter", "Inter Fallback Arial", sans-serif;--font-label:"Inter", "Inter Fallback Arial", sans-serif;--font-mono:"JetBrains Mono", "JetBrains Mono Fallback Menlo", "JetBrains Mono Fallback Consolas", "JetBrains Mono Fallback Courier New", monospace;--font-trim-body-cap:.36377;--font-trim-body-baseline:.36377;--font-trim-heading-cap:.36377;--font-trim-heading-baseline:.36377;--font-trim-display-cap:.36377;--font-trim-display-baseline:.36377;--font-trim-label-cap:.36377;--font-trim-label-baseline:.36377;--font-trim-mono-cap:.37;--font-trim-mono-baseline:.36}@media (forced-colors:active){[data-brand][data-brand]{--color-bg:Canvas;--color-bg-muted:Canvas;--color-bg-raised:Canvas;--color-fg:CanvasText;--color-fg-muted:CanvasText;--color-border:CanvasText;--color-border-strong:CanvasText;--color-accent:LinkText;--color-accent-fg:Canvas;--color-accent-fill:LinkText;--color-accent-fill-fg:Canvas;--color-danger:CanvasText;--color-danger-fg:Canvas;--color-success:CanvasText;--color-success-fg:Canvas;--color-warning:CanvasText;--color-warning-fg:Canvas;--color-done:CanvasText;--color-done-fg:Canvas;--color-neutral-subtle:Canvas;--color-neutral-subtle-fg:CanvasText;--color-accent-subtle:Canvas;--color-accent-subtle-fg:CanvasText;--color-success-subtle:Canvas;--color-success-subtle-fg:CanvasText;--color-warning-subtle:Canvas;--color-warning-subtle-fg:CanvasText;--color-danger-subtle:Canvas;--color-danger-subtle-fg:CanvasText;--color-done-subtle:Canvas;--color-done-subtle-fg:CanvasText;--color-focus:Highlight;--color-shadow:CanvasText}}}
|
package/dist/contrast/mixes.mjs
CHANGED
|
@@ -1,41 +1,62 @@
|
|
|
1
1
|
import { fills as e } from "../styles/button-fills.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { subtleFills as t } from "../styles/subtle-fills.mjs";
|
|
3
|
+
import { contrastRatio as n, surfaces as r } from "./contrast.mjs";
|
|
4
|
+
import { highlightFill as i, highlightText as a } from "../styles/highlight.mjs";
|
|
5
|
+
import { hoverFill as o } from "../styles/hover-tint.mjs";
|
|
5
6
|
// src/contrast/mixes.ts
|
|
6
|
-
var
|
|
7
|
+
var s = [
|
|
7
8
|
{
|
|
8
9
|
name: "Menu highlight",
|
|
9
|
-
fill:
|
|
10
|
-
text:
|
|
10
|
+
fill: i,
|
|
11
|
+
text: a,
|
|
11
12
|
min: 4.5
|
|
12
13
|
},
|
|
13
|
-
...Object.entries(e).flatMap(([e, { backgroundColor: t, color:
|
|
14
|
-
name: t ? `${e} Button hover` : `${e} Button hover on ${
|
|
15
|
-
fill: (e) =>
|
|
16
|
-
text: [
|
|
14
|
+
...Object.entries(e).flatMap(([e, { backgroundColor: t, color: n }]) => (t ? [t] : r).map((r) => ({
|
|
15
|
+
name: t ? `${e} Button hover` : `${e} Button hover on ${r}`,
|
|
16
|
+
fill: (e) => o(e.fg, e[r]),
|
|
17
|
+
text: [n],
|
|
17
18
|
min: 4.5
|
|
18
19
|
}))),
|
|
19
20
|
{
|
|
20
21
|
name: "pressed Chip hover",
|
|
21
|
-
fill: (e) =>
|
|
22
|
+
fill: (e) => o(e.fg, e.accent),
|
|
22
23
|
text: ["accentFg"],
|
|
23
24
|
min: 4.5
|
|
24
|
-
}
|
|
25
|
+
},
|
|
26
|
+
...r.map((e) => ({
|
|
27
|
+
name: `Table row hover on ${e}`,
|
|
28
|
+
fill: (t) => o(t.fg, t[e], "5%"),
|
|
29
|
+
text: e === "bgMuted" ? ["fg", "fgMuted"] : [
|
|
30
|
+
"fg",
|
|
31
|
+
"fgMuted",
|
|
32
|
+
"accent",
|
|
33
|
+
"danger",
|
|
34
|
+
"success",
|
|
35
|
+
"warning",
|
|
36
|
+
"done"
|
|
37
|
+
],
|
|
38
|
+
min: 4.5
|
|
39
|
+
})),
|
|
40
|
+
...Object.entries(t).map(([e, { backgroundColor: t, color: n }]) => ({
|
|
41
|
+
name: `${e} Table row hover`,
|
|
42
|
+
fill: (e) => o(e.fg, e[t], "5%"),
|
|
43
|
+
text: [n],
|
|
44
|
+
min: 4.5
|
|
45
|
+
}))
|
|
25
46
|
];
|
|
26
|
-
function
|
|
27
|
-
return ["light", "dark"].flatMap((
|
|
47
|
+
function c(e) {
|
|
48
|
+
return ["light", "dark"].flatMap((t) => s.flatMap(({ name: r, fill: i, text: a, min: o }) => {
|
|
28
49
|
let s = i(e.color);
|
|
29
50
|
return a.flatMap((i) => {
|
|
30
|
-
let a =
|
|
51
|
+
let a = n(e.color[i], s, t);
|
|
31
52
|
return a < o ? [{
|
|
32
53
|
fg: i,
|
|
33
54
|
mix: r,
|
|
34
55
|
min: o,
|
|
35
|
-
mode:
|
|
56
|
+
mode: t,
|
|
36
57
|
ratio: a
|
|
37
58
|
}] : [];
|
|
38
59
|
});
|
|
39
60
|
}));
|
|
40
61
|
}
|
|
41
|
-
export {
|
|
62
|
+
export { c as checkMixes, s as contrastMixes };
|
package/dist/docs/Box.md
CHANGED
|
@@ -6,14 +6,15 @@ The base element every component builds on: one element, chosen with `as`, style
|
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
9
|
-
-
|
|
9
|
+
- Surfaces that need tokens but no behavior: a padded panel, a sticky bar, a grid.
|
|
10
10
|
- A semantic element (`as="section"`, `as="nav"`, `as="ul"`) that needs style props.
|
|
11
11
|
- Building a new component: render a `Box` and pass its tunable values as default style props.
|
|
12
12
|
|
|
13
13
|
## When not to use
|
|
14
14
|
|
|
15
15
|
- Text: use `Text` or `Heading`; all visible text goes through them.
|
|
16
|
-
- Stacks and rows of children with a gap: use `Stack` or `Inline`.
|
|
16
|
+
- Stacks and rows of children with a gap: use `Stack` or `Inline`. A Box with `display="flex"`, `flexDirection="column"` and `gap` is a `Stack` rebuilt by hand.
|
|
17
|
+
- Records in rows that share named columns: use `Table`, not a grid of boxes, so the columns have headers.
|
|
17
18
|
- Anything interactive: use `Button` or a link component, which bring focus and states.
|
|
18
19
|
|
|
19
20
|
## Rules
|
|
@@ -33,7 +34,20 @@ The base element every component builds on: one element, chosen with `as`, style
|
|
|
33
34
|
## Do
|
|
34
35
|
|
|
35
36
|
```tsx
|
|
36
|
-
|
|
37
|
+
// A centered column: `Stack`, not a Box with flex props (see Don't).
|
|
38
|
+
<Stack gap="16" alignItems="center">
|
|
39
|
+
<Heading>No projects yet</Heading>
|
|
40
|
+
<Button variant="primary">Create project</Button>
|
|
41
|
+
</Stack>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
<Box
|
|
46
|
+
as="section"
|
|
47
|
+
aria-label="Billing"
|
|
48
|
+
padding={{ base: "16", med: "24" }}
|
|
49
|
+
backgroundColor="bgRaised"
|
|
50
|
+
>
|
|
37
51
|
…
|
|
38
52
|
</Box>
|
|
39
53
|
```
|
|
@@ -57,6 +71,14 @@ import "@jonmilner/ui/responsive.css";
|
|
|
57
71
|
|
|
58
72
|
## Don't
|
|
59
73
|
|
|
74
|
+
```tsx
|
|
75
|
+
// A Box rebuilding Stack: write `<Stack gap="16" alignItems="center">` (see Do).
|
|
76
|
+
<Box display="flex" flexDirection="column" alignItems="center" gap="16">
|
|
77
|
+
<Heading>No projects yet</Heading>
|
|
78
|
+
<Button variant="primary">Create project</Button>
|
|
79
|
+
</Box>
|
|
80
|
+
```
|
|
81
|
+
|
|
60
82
|
```tsx
|
|
61
83
|
// Physical property, `md`: neither type-checks.
|
|
62
84
|
<Box paddingLeft="16" gap="md" />
|
package/dist/docs/Field.md
CHANGED
|
@@ -14,7 +14,7 @@ Wires one form control to its label, description and error: ids, `htmlFor`, `ari
|
|
|
14
14
|
- An error about the whole form (a failed save, a network error): put it in a reserved slot at the form level, not on one field.
|
|
15
15
|
- The result of submitting the form ("Profile saved"): use `Toast`; the field's message is for that one input.
|
|
16
16
|
- A group of controls with one legend: a public `Fieldset` is not planned (ADR 0133). For checkboxes, write a native `fieldset` and `legend` with one Field per Checkbox. For one choice among a few, `RadioGroup` is planned and carries its own legend.
|
|
17
|
-
- A single line of text, a search, a colour or a choice from a list: use `TextField`, `SearchField`, `ColorField` or `MultiSelect`, which build on this Field.
|
|
17
|
+
- A single line of text, several lines, a search, a colour or a choice from a list: use `TextField`, `Textarea`, `SearchField`, `ColorField` or `MultiSelect`, which build on this Field.
|
|
18
18
|
|
|
19
19
|
## Rules
|
|
20
20
|
|
|
@@ -111,6 +111,7 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
111
111
|
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
112
112
|
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
113
113
|
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
114
|
+
| `tabularNums` | `boolean` | no | |
|
|
114
115
|
| `truncate` | `"box" \| boolean` | no | |
|
|
115
116
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
116
117
|
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
|
@@ -125,6 +126,7 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
125
126
|
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
126
127
|
| `match` | `boolean \| keyof ValidityState` | no | Determines whether to show the error message according to the field's [ValidityState](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState). Specifying `true` will always show the error message, and lets external libraries control the visibility. |
|
|
127
128
|
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
129
|
+
| `tabularNums` | `boolean` | no | |
|
|
128
130
|
| `truncate` | `"box" \| boolean` | no | |
|
|
129
131
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
130
132
|
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
|
@@ -139,6 +141,7 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
139
141
|
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
140
142
|
| `nativeLabel` | `boolean` | no | Whether the component renders a native `<label>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a label (for example, `<div>`). This is useful to avoid inheriting label behaviors on `<button>` controls (such as `<Select.Trigger>` and `<Combobox.Trigger>`), including avoiding `:hover` on the button when hovering the label, and preventing clicks on the label from firing on the button. |
|
|
141
143
|
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
144
|
+
| `tabularNums` | `boolean` | no | |
|
|
142
145
|
| `truncate` | `"box" \| boolean` | no | |
|
|
143
146
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
144
147
|
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
package/dist/docs/Heading.md
CHANGED
|
@@ -63,6 +63,7 @@ Generated from the TypeScript types.
|
|
|
63
63
|
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
64
64
|
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
65
65
|
| `size` | `"2xl" \| "lg" \| "med" \| "sm" \| "xl"` | no | |
|
|
66
|
+
| `tabularNums` | `boolean` | no | |
|
|
66
67
|
| `truncate` | `"box" \| boolean` | no | |
|
|
67
68
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
68
69
|
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
package/dist/docs/Stack.md
CHANGED
|
@@ -14,6 +14,7 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
14
14
|
|
|
15
15
|
- A row of items that wraps (buttons, tags, metadata): use `Inline`.
|
|
16
16
|
- A two-dimensional layout: use `Box` with `display="grid"`.
|
|
17
|
+
- Records that share named columns, to compare row by row: use `Table`.
|
|
17
18
|
- One child, or spacing only on one side: use `Box` with padding or margin.
|
|
18
19
|
|
|
19
20
|
## Rules
|
|
@@ -22,6 +23,7 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
22
23
|
- Space comes from `gap`, never from margins on the children.
|
|
23
24
|
- It takes every `Box` prop, and the layout defaults are style props, so `display`, `flexDirection` and `alignItems` override them.
|
|
24
25
|
- Children are not wrapped, so each child is a flex item: it stretches to the column's width unless `alignItems` says otherwise.
|
|
26
|
+
- A list needs no `className` or stylesheet. `paddingInlineStart="0"` drops the `ul` indent, and a row that is a `Box as="li"` with a `display` other than `list-item` draws no marker.
|
|
25
27
|
- The consumer's `className` comes last and `style` is passed through; `ref` is a plain prop typed for the `as` element.
|
|
26
28
|
|
|
27
29
|
## Do
|
|
@@ -39,8 +41,33 @@ A vertical column of children with even space between them. `Stack` is a `Box` w
|
|
|
39
41
|
</Stack>
|
|
40
42
|
```
|
|
41
43
|
|
|
44
|
+
```tsx
|
|
45
|
+
// A styled list with no className: the rows are surfaces, and a flex `li` draws no marker.
|
|
46
|
+
<Stack as="ul" gap="8" paddingInlineStart="0" aria-label="Projects">
|
|
47
|
+
{projects.map((project) => (
|
|
48
|
+
<Box
|
|
49
|
+
as="li"
|
|
50
|
+
key={project.id}
|
|
51
|
+
display="flex"
|
|
52
|
+
padding="12"
|
|
53
|
+
backgroundColor="bgRaised"
|
|
54
|
+
borderRadius="med"
|
|
55
|
+
>
|
|
56
|
+
<Text>{project.name}</Text>
|
|
57
|
+
</Box>
|
|
58
|
+
))}
|
|
59
|
+
</Stack>
|
|
60
|
+
```
|
|
61
|
+
|
|
42
62
|
## Don't
|
|
43
63
|
|
|
64
|
+
```tsx
|
|
65
|
+
// A class and an app stylesheet for what style props cover.
|
|
66
|
+
<Stack as="ul" gap="8" className="project-list">
|
|
67
|
+
<li>…</li>
|
|
68
|
+
</Stack>
|
|
69
|
+
```
|
|
70
|
+
|
|
44
71
|
```tsx
|
|
45
72
|
// Margins on children instead of gap; and `gap` is required.
|
|
46
73
|
<Stack>
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Table
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Records in rows that share named columns, so a reader can scan and compare them: transactions, members, invoices. A native `table` with parts for each element (`Table.Head`, `Table.Body`, `Table.Foot`, `Table.Row`, `Table.HeaderCell`, `Table.Cell`, `Table.ColumnGroup`, `Table.Column`). It has no `grid` role and no roving focus: a link, `Checkbox` or `Menu` in a cell keeps the page's tab order, and a screen reader's table commands work as on any table.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- A list of records with the same fields, where a reader compares one row against another: amounts, dates, statuses.
|
|
10
|
+
- Figures that should line up down a column: set `numeric` on the column's cells.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- Items with no shared columns (a feed, a list of links): use a `ul` in a `Stack`.
|
|
15
|
+
- One record's fields, label beside value: a description list, not a one-row table.
|
|
16
|
+
- A data grid, with cell focus, arrow keys, editing or a selection model: not this component and not in the library.
|
|
17
|
+
- No rows: render the app's empty message in place of the table, not a table with an empty body.
|
|
18
|
+
- A phone layout of one card per row: that is the app's layout; Table stays a table.
|
|
19
|
+
- After a row is removed, focus is the app's to move (to the next row's control, or a heading); Table does not restore it.
|
|
20
|
+
- A sticky header, edge shadows, virtualisation or column resizing: not supported.
|
|
21
|
+
|
|
22
|
+
## Rules
|
|
23
|
+
|
|
24
|
+
- A table needs a name, and its type requires one: `caption` (a visible title, `sm` semibold above the table), or `aria-label`, or `aria-labelledby` when a heading above already names it. `hideCaption` keeps the caption for screen readers only.
|
|
25
|
+
- `Table.Cell` is `Text` at `sm`; `Table.HeaderCell` is `Text` at `xs` semibold in `fgMuted`, `scope="col"` by default. A row header (`scope="row"`) is `sm` semibold in the row's color at any size, so it reads on a toned row. Both take Text's props (`weight`, `color`, `wrap`) but not `truncate`, which breaks a cell's padding and does not clip in an `auto` column, and are text components: text goes straight in them, no `Text` wrapper.
|
|
26
|
+
- `numeric` on a `Cell` or `HeaderCell` aligns it to the end and sets tabular figures, so digits line up. Set it on every cell of the column, header included.
|
|
27
|
+
- `hideLabel` on a `HeaderCell` keeps its name for screen readers only, for a column of checkboxes or row actions. Never leave a header empty.
|
|
28
|
+
- `tone` on a `Row` fills it with the tone's subtle fill and sets its text (`<tone>SubtleFg` on `<tone>Subtle`). The row's content carries the meaning (a status `Badge` or word): under forced colors the fill is gone. A header cell in a toned body row needs `scope="row"`: the default `scope="col"` keeps `fgMuted`, which is not checked on a tone's fill.
|
|
29
|
+
- `aria-busy="true"` on a `Row` dims a row whose change is pending: its text turns `fgMuted` (a toned row keeps its tone's text). Say so in the row too (a "Saving" Badge), and set it back when the change lands.
|
|
30
|
+
- Body rows take a light hover tint only where hover is real (`(hover: hover)`); it never means anything, it only helps the eye follow a row. On a `bgMuted` surface, colored text in a cell (`color="danger"`) falls under 4.5:1 under the tint: put a status there in a `Badge`.
|
|
31
|
+
- `layout`: `auto` (default) sizes columns from their content; `fixed` sizes them from the first row and the columns' widths, so it is faster on a long table and its columns stay put. Set a width with `inlineSize` on `Table.Column` inside `Table.ColumnGroup`: a size step, a container width, `auto`, `full` or `fit`. A width no token gives goes in `className`, the documented exception.
|
|
32
|
+
- The table is `inlineSize="full"` by default. Cells have `8` block and `12` inline padding as default style props, and a `border` rule below each. Every part takes `className`, `style`, `ref` and the style props; the consumer's win.
|
|
33
|
+
- No part has hooks, so a server component can render the whole table.
|
|
34
|
+
|
|
35
|
+
## Do
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<Table caption="Recent transactions">
|
|
39
|
+
<Table.Head>
|
|
40
|
+
<Table.Row>
|
|
41
|
+
<Table.HeaderCell>Payee</Table.HeaderCell>
|
|
42
|
+
<Table.HeaderCell>Status</Table.HeaderCell>
|
|
43
|
+
<Table.HeaderCell numeric>Amount</Table.HeaderCell>
|
|
44
|
+
</Table.Row>
|
|
45
|
+
</Table.Head>
|
|
46
|
+
<Table.Body>
|
|
47
|
+
<Table.Row>
|
|
48
|
+
<Table.Cell>Acme Hardware</Table.Cell>
|
|
49
|
+
<Table.Cell>
|
|
50
|
+
<Badge subtle>Cleared</Badge>
|
|
51
|
+
</Table.Cell>
|
|
52
|
+
<Table.Cell numeric>$1,204.00</Table.Cell>
|
|
53
|
+
</Table.Row>
|
|
54
|
+
<Table.Row tone="danger">
|
|
55
|
+
<Table.Cell>City Water</Table.Cell>
|
|
56
|
+
<Table.Cell>Overdue</Table.Cell>
|
|
57
|
+
<Table.Cell numeric>$88.10</Table.Cell>
|
|
58
|
+
</Table.Row>
|
|
59
|
+
</Table.Body>
|
|
60
|
+
</Table>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// A heading already names it; the checkbox column's header is for screen readers only.
|
|
65
|
+
<Table aria-labelledby="members-heading">
|
|
66
|
+
<Table.Head>
|
|
67
|
+
<Table.Row>
|
|
68
|
+
<Table.HeaderCell hideLabel>Select</Table.HeaderCell>
|
|
69
|
+
<Table.HeaderCell>Name</Table.HeaderCell>
|
|
70
|
+
</Table.Row>
|
|
71
|
+
</Table.Head>
|
|
72
|
+
<Table.Body>
|
|
73
|
+
<Table.Row>
|
|
74
|
+
<Table.Cell>
|
|
75
|
+
<Checkbox aria-label="Select Ada Lovelace" />
|
|
76
|
+
</Table.Cell>
|
|
77
|
+
<Table.Cell>Ada Lovelace</Table.Cell>
|
|
78
|
+
</Table.Row>
|
|
79
|
+
</Table.Body>
|
|
80
|
+
</Table>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Don't
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
// No name: a screen reader announces "table" and nothing else. This fails typecheck.
|
|
87
|
+
<Table>…</Table>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
// Color alone says the row is overdue.
|
|
92
|
+
<Table.Row tone="danger">
|
|
93
|
+
<Table.Cell>City Water</Table.Cell>
|
|
94
|
+
<Table.Cell numeric>$88.10</Table.Cell>
|
|
95
|
+
</Table.Row>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
// An empty body: say there is nothing, instead.
|
|
100
|
+
<Table caption="Invoices">
|
|
101
|
+
<Table.Body />
|
|
102
|
+
</Table>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Accessibility
|
|
106
|
+
|
|
107
|
+
- Native table semantics: rows, column and row headers are announced, and screen readers' table navigation works. Column headers are `scope="col"`; set `scope="row"` on a row's first cell when it names the row.
|
|
108
|
+
- A `caption`, `aria-label` or `aria-labelledby` names the table (WCAG 1.3.1).
|
|
109
|
+
- Controls in cells are in the tab order, in reading order. Give each a name that says its row ("Select Ada Lovelace", "Actions for City Water").
|
|
110
|
+
- A pending row's `aria-busy` tells assistive tech it is changing; a toned row's meaning is in its text (WCAG 1.4.1).
|
|
111
|
+
- The text on each tone fill, and on the hover tint over each surface and fill (colored text roles over `bg` and `bgRaised` only), is checked for 4.5:1 in `contrast/mixes.ts`.
|
|
112
|
+
|
|
113
|
+
## Props
|
|
114
|
+
|
|
115
|
+
Generated from the TypeScript types.
|
|
116
|
+
|
|
117
|
+
### Table
|
|
118
|
+
|
|
119
|
+
| Prop | Type | Required | Description |
|
|
120
|
+
| --- | --- | --- | --- |
|
|
121
|
+
| `aria-label` | `string` | no | Defines a string value that labels the current element. |
|
|
122
|
+
| `aria-labelledby` | `string` | no | Identifies the element (or elements) that labels the current element. |
|
|
123
|
+
| `caption` | `string \| ReactElement<unknown, string \| JSXElementConstructor<any>>` | no | |
|
|
124
|
+
| `hideCaption` | `boolean` | no | |
|
|
125
|
+
| `layout` | `"auto" \| "fixed"` | no | |
|
|
126
|
+
|
|
127
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
128
|
+
|
|
129
|
+
### Table.Body
|
|
130
|
+
|
|
131
|
+
No props of its own.
|
|
132
|
+
|
|
133
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
134
|
+
|
|
135
|
+
### Table.Cell
|
|
136
|
+
|
|
137
|
+
| Prop | Type | Required | Description |
|
|
138
|
+
| --- | --- | --- | --- |
|
|
139
|
+
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
140
|
+
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
141
|
+
| `numeric` | `boolean` | no | |
|
|
142
|
+
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
143
|
+
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
144
|
+
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
|
145
|
+
|
|
146
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
147
|
+
|
|
148
|
+
### Table.Column
|
|
149
|
+
|
|
150
|
+
No props of its own.
|
|
151
|
+
|
|
152
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
153
|
+
|
|
154
|
+
### Table.ColumnGroup
|
|
155
|
+
|
|
156
|
+
No props of its own.
|
|
157
|
+
|
|
158
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
159
|
+
|
|
160
|
+
### Table.Foot
|
|
161
|
+
|
|
162
|
+
No props of its own.
|
|
163
|
+
|
|
164
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
165
|
+
|
|
166
|
+
### Table.Head
|
|
167
|
+
|
|
168
|
+
No props of its own.
|
|
169
|
+
|
|
170
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
171
|
+
|
|
172
|
+
### Table.HeaderCell
|
|
173
|
+
|
|
174
|
+
| Prop | Type | Required | Description |
|
|
175
|
+
| --- | --- | --- | --- |
|
|
176
|
+
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
177
|
+
| `hideLabel` | `boolean` | no | |
|
|
178
|
+
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
179
|
+
| `numeric` | `boolean` | no | |
|
|
180
|
+
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
181
|
+
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
182
|
+
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
|
183
|
+
|
|
184
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
185
|
+
|
|
186
|
+
### Table.Row
|
|
187
|
+
|
|
188
|
+
| Prop | Type | Required | Description |
|
|
189
|
+
| --- | --- | --- | --- |
|
|
190
|
+
| `tone` | `"accent" \| "danger" \| "done" \| "neutral" \| "success" \| "warning"` | no | |
|
|
191
|
+
|
|
192
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/Tabs.md
CHANGED
|
@@ -124,6 +124,7 @@ Also accepts the style props (see `manifest.json` `styleProps`).
|
|
|
124
124
|
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
125
125
|
| `nativeButton` | `boolean` | no | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
|
|
126
126
|
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
127
|
+
| `tabularNums` | `boolean` | no | |
|
|
127
128
|
| `value` | `any` | yes | The value of the Tab. |
|
|
128
129
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
129
130
|
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
package/dist/docs/Text.md
CHANGED
|
@@ -25,6 +25,7 @@ The base of all visible text, and the primitive every text component builds on.
|
|
|
25
25
|
- `font` takes a font role: `body` (default), `heading`, `display`, `label`, `mono`. The brand maps roles to fonts.
|
|
26
26
|
- `weight` takes `regular` (default), `medium`, `semibold` or `bold`.
|
|
27
27
|
- `leading` takes a unitless line height: `sm`, `med` (default) or `lg`. The trim follows it.
|
|
28
|
+
- `tabularNums` gives every digit the same width, so figures in a column or a ticking count line up: amounts, durations, counts in a table. Prose numbers keep the font's own figures.
|
|
28
29
|
- `color` takes a color role (`fg`, `fgMuted`, `accent`, …), never a raw color. Unset, it inherits.
|
|
29
30
|
- `truncate` keeps one line and cuts it with an ellipsis, without clipping ascenders or descenders. It sets the block margins, so do not combine it with margin props.
|
|
30
31
|
- `truncate="box"` cuts a part of another Text's line (a field's summary inside a button's label) at its own box: untrimmed, in the outer Text's font until its own props say otherwise. Use it only inside another Text, below a Box or element that is not a Text run.
|
|
@@ -115,6 +116,7 @@ Generated from the TypeScript types.
|
|
|
115
116
|
| `font` | `"body" \| "display" \| "heading" \| "label" \| "mono"` | no | |
|
|
116
117
|
| `leading` | `"lg" \| "med" \| "sm"` | no | |
|
|
117
118
|
| `size` | `"2xl" \| "3xl" \| "4xl" \| "lg" \| "med" \| "sm" \| "xl" \| "xs"` | no | |
|
|
119
|
+
| `tabularNums` | `boolean` | no | |
|
|
118
120
|
| `truncate` | `"box" \| boolean` | no | |
|
|
119
121
|
| `weight` | `"bold" \| "medium" \| "regular" \| "semibold"` | no | |
|
|
120
122
|
| `wrap` | `"nowrap" \| "pre" \| "pre-wrap"` | no | |
|
package/dist/docs/TextField.md
CHANGED
|
@@ -12,7 +12,7 @@ A form field for one line of text that is not a search: an `<input>` (role `text
|
|
|
12
12
|
## When not to use
|
|
13
13
|
|
|
14
14
|
- A query that searches or filters: use `SearchField`; it is announced as a search and has a clear button.
|
|
15
|
-
- Several lines of text:
|
|
15
|
+
- Several lines of text (a reply, a note, a description): use `Textarea`.
|
|
16
16
|
- A number with steppers or a range: a number field is not planned (ADR 0133); use `TextField` with `inputMode` in `inputProps` and validate in the app.
|
|
17
17
|
- Picking from a known list as the user types: wait for `Combobox` (planned).
|
|
18
18
|
- Picking one or several values from a list: use `MultiSelect` or `ChipGroup`.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Textarea
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
A form field for several lines of free text: a `<textarea>` (role `textbox`, multi-line) with TextField's look. Built on Base UI's `Input` rendered as a textarea (ADR 0003); it composes `Field` for its label, description and error (ADR 0026, 0136). `rows` sets its starting height, three by default, and the user can drag it taller or shorter. Three sizes (`sm`, `med`, `lg`) set TextField's text size and padding, so the first line sits where a TextField's text does (ADR 0124).
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- A reply, a note, a comment, a description, a message: free text that may run to several lines or paragraphs.
|
|
10
|
+
- A settings or edit form whose fields line up with a `TextField`: they share the border, the text size and the inline padding.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- One line of text (a name, an email, a title): use `TextField`; Enter submits its form.
|
|
15
|
+
- A query that searches or filters: use `SearchField`.
|
|
16
|
+
- Formatted text (bold, links, lists): a rich text editor is out of scope; take Markdown in a Textarea and render it in the app.
|
|
17
|
+
- A character counter or a box that grows with its text: neither is built in. Set `maxLength` in `inputProps` for a hard cap, and `rows` for the height the content usually needs.
|
|
18
|
+
|
|
19
|
+
## Rules
|
|
20
|
+
|
|
21
|
+
- `label` is required and names the textarea, even when the design shows none: pass `hideLabel` to keep it for assistive technology and hide it from sight. Never pass an empty label, and never let `placeholder` stand in for one.
|
|
22
|
+
- `value` with `onValueChange` controls it; `defaultValue` leaves it uncontrolled. `onValueChange` gets the new string on each keystroke, line breaks as `\n`.
|
|
23
|
+
- `rows` (default `3`) sets the starting height in lines. The user may resize it vertically only, never under one line or one control height, and not while it is disabled; text longer than the box scrolls inside it.
|
|
24
|
+
- `description` and `error` render below the textarea through `Field`; a non-empty `error` marks the field invalid (`aria-invalid`, a danger border) and joins the textarea's `aria-describedby`. Field's error slot announces it (ADR 0097): never add a `role="alert"` of your own.
|
|
25
|
+
- `disabled` uses the native `disabled`: the textarea leaves the tab order and does not submit, with a dashed border. `required` sets the native `required`.
|
|
26
|
+
- `name` submits the value with its form. A native form reset puts an uncontrolled field back to its `defaultValue` but fires no change, so `onValueChange` misses it; control the field if the form resets and you track the value.
|
|
27
|
+
- Enter adds a line; it never submits the form. Submitting on Mod+Enter is the app's choice, with its own `onKeyDown` in `inputProps`.
|
|
28
|
+
- Style props, `className` and `style` go to the `Field` around the label, textarea and messages, not to the textarea.
|
|
29
|
+
- `inputProps` reach the textarea: `ref`, `id`, `autoFocus`, `autoComplete`, `spellCheck`, `enterKeyHint`, `inputMode`, `maxLength`, `minLength`, `onKeyDown`, and only the `aria-*` valid on a text box (ADR 0110, 0136): `aria-controls`, `aria-activedescendant`, `aria-autocomplete`, `aria-placeholder`, `aria-details`, `aria-keyshortcuts`, `aria-owns`, `aria-flowto`, `aria-current`, `aria-roledescription`, `aria-busy`, `aria-live`, `aria-atomic` and `aria-relevant`. `label` owns the name, Field owns `aria-invalid`, `aria-describedby` and `aria-errormessage`, `disabled` and `required` own their state, and the native textarea is multi-line already, so those, `aria-readonly`, `aria-hidden` and `aria-multiline` are not among them. The type closes the set, so an object literal with another `aria-*` is a type error; nothing strips one at runtime. Hint with `placeholder`, not `aria-placeholder`: the textarea has a native placeholder.
|
|
30
|
+
- The field handles no keys; a consumer `onKeyDown` is passed straight through.
|
|
31
|
+
- A consumer `ref` gets the textarea. A consumer `id` takes over from Field's generated one at hydration, and the label follows it.
|
|
32
|
+
- The module has no hooks, so a server component can render it; `onValueChange`, and an `inputProps` `ref` or `onKeyDown`, must come from a client component.
|
|
33
|
+
|
|
34
|
+
## Do
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Textarea label="Reply" name="reply" required rows={5} />
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
<Textarea
|
|
42
|
+
label="Description"
|
|
43
|
+
description="Shown on the project page."
|
|
44
|
+
error={errors?.description}
|
|
45
|
+
name="description"
|
|
46
|
+
inputProps={{ maxLength: 2000 }}
|
|
47
|
+
/>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
<Textarea label="Note" value={note} onValueChange={setNote} inputProps={{ spellCheck: true }} />
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Don't
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
// A hand-rolled alert: Field's error slot already announces it and joins the description.
|
|
58
|
+
<Textarea label="Reply" />
|
|
59
|
+
<Text role="alert">{error}</Text>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// Another name for the textarea: `label` names it, visible or not.
|
|
64
|
+
<Textarea label="Reply" inputProps={{ "aria-label": "Your reply" }} />
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```tsx
|
|
68
|
+
// A one-line Textarea: a title is a TextField, and Enter submits its form.
|
|
69
|
+
<Textarea label="Title" rows={1} />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Accessibility
|
|
73
|
+
|
|
74
|
+
- The textarea is a multi-line `textbox` named by the label, visible or not.
|
|
75
|
+
- Invalid adds a danger border and the error message with its icon, never color alone; disabled adds a dashed border. Every size is at least 24 px tall. Under forced colors the border, text and disabled state use system colors. On a coarse pointer (a touch screen) the text is 16px at every size, so iOS Safari does not zoom the page when the field takes focus.
|
|
76
|
+
- Text longer than the box scrolls inside it, with the keyboard as with a pointer; the page around it does not move.
|
|
77
|
+
|
|
78
|
+
## Props
|
|
79
|
+
|
|
80
|
+
Generated from the TypeScript types.
|
|
81
|
+
|
|
82
|
+
### Textarea
|
|
83
|
+
|
|
84
|
+
| Prop | Type | Required | Description |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `className` | `string` | no | |
|
|
87
|
+
| `defaultValue` | `string` | no | |
|
|
88
|
+
| `description` | `ReactNode` | no | |
|
|
89
|
+
| `disabled` | `boolean` | no | |
|
|
90
|
+
| `error` | `ReactNode` | no | |
|
|
91
|
+
| `hideLabel` | `boolean` | no | |
|
|
92
|
+
| `inputProps` | `TextareaInputProps` | no | |
|
|
93
|
+
| `label` | `ReactNode` | yes | |
|
|
94
|
+
| `name` | `string` | no | |
|
|
95
|
+
| `onValueChange` | `((value: string) => void)` | no | |
|
|
96
|
+
| `placeholder` | `string` | no | |
|
|
97
|
+
| `required` | `boolean` | no | |
|
|
98
|
+
| `rows` | `number` | no | |
|
|
99
|
+
| `size` | `"lg" \| "med" \| "sm"` | no | |
|
|
100
|
+
| `style` | `CSSProperties` | no | |
|
|
101
|
+
| `value` | `string` | no | |
|
|
102
|
+
|
|
103
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
package/dist/docs/lint.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
## textComponents
|
|
6
6
|
|
|
7
|
-
The library's components and parts that render their children through `Text`, plus `VisuallyHidden`, whose children are hidden text. Pass it as `textComponents`, so documented usage such as `<Tabs.Tab>Privacy</Tabs.Tab>`, `<Field.Label>Email</Field.Label>` or `<VisuallyHidden>unread messages</VisuallyHidden>` passes `ui/no-bare-text`.
|
|
7
|
+
The library's components and parts that render their children through `Text`, plus `VisuallyHidden`, whose children are hidden text. Pass it as `textComponents`, so documented usage such as `<Tabs.Tab>Privacy</Tabs.Tab>`, `<Field.Label>Email</Field.Label>`, `<Table.Cell>Paid</Table.Cell>` or `<VisuallyHidden>unread messages</VisuallyHidden>` passes `ui/no-bare-text`.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
import { lint, uiLint } from "@jonmilner/oxlint-config";
|
package/dist/docs/llms.txt
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> React design system. Each component's docs say when to use it, its rules and props.
|
|
4
4
|
|
|
5
|
+
## Rules for every screen
|
|
6
|
+
|
|
7
|
+
- Lay out with `Stack` (a column) and `Inline` (a row that wraps), spaced by their `gap`. Never rebuild them from a `Box` with `display`, `flexDirection` and `gap`.
|
|
8
|
+
- `Box` is for a surface (padding, background, radius, shadow) or a semantic element that needs style props.
|
|
9
|
+
- No `className`, `style` or app stylesheet for what a style prop or a component covers. Style props take token keys, so no raw colors or lengths either.
|
|
10
|
+
- A list is `Stack as="ul"` with `li` children. For one without markers or indent, add `paddingInlineStart="0"` and make each row a `Box as="li" display="flex"`, as Stack's docs show.
|
|
11
|
+
|
|
5
12
|
## Components
|
|
6
13
|
|
|
7
14
|
- [AlertDialog](AlertDialog.md): Asks the user to confirm a consequential action before it runs: delete a project, discard unsaved changes, sign out every device. Built on Base UI's AlertDialog, which owns the behavior: `role="alertdialog"`, focus moves into the dialog and stays there, the page behind is inert, Esc closes it, and a click outside does not. It wears Dialog's panel at the `sm` width with a title, a description, Cancel and one confirm button, and Cancel takes focus on open.
|
|
@@ -23,10 +30,12 @@
|
|
|
23
30
|
- [MultiSelect](MultiSelect.md): A form field for picking any number of values from a list too long to show at once. A trigger styled as Button's secondary look opens a listbox of options; each selected option shows a check mark, and the trigger summarises the selection as the joined labels, or a count ("3 selected") once the labels would not fit. Built on Base UI's `Select` in multiple mode (ADR 0003), which owns the keyboard and focus: arrow keys, Home and End move through the options, typing jumps to a match, Esc and an outside click close it, and focus returns to the trigger. It composes `Field` for its label, description and error (ADR 0026).
|
|
24
31
|
- [SearchField](SearchField.md): A form field for a search query: an `<input type="search">` (role `searchbox`) with a search icon at its inline start and, while it holds a value, a clear button at its inline end. Escape empties a field that has a value, and the clear button empties it and puts focus back in the input, so a keyboard user never loses their place (ADR 0087). Built on Base UI's `Input` (ADR 0003); it composes `Field` for its label, description and error (ADR 0026). Three sizes at Button's heights (`sm`, `med`, `lg`: 24, 32 and 40 px, ADR 0124); the clear button is 24px, or 32px in `lg`.
|
|
25
32
|
- [Stack](Stack.md): A vertical column of children with even space between them. `Stack` is a `Box` with `display="flex"` and `flexDirection="column"` as default style props, spaced by a required `gap`. Children render as they are: no wrapper per child.
|
|
33
|
+
- [Table](Table.md): Records in rows that share named columns, so a reader can scan and compare them: transactions, members, invoices. A native `table` with parts for each element (`Table.Head`, `Table.Body`, `Table.Foot`, `Table.Row`, `Table.HeaderCell`, `Table.Cell`, `Table.ColumnGroup`, `Table.Column`). It has no `grid` role and no roving focus: a link, `Checkbox` or `Menu` in a cell keeps the page's tab order, and a screen reader's table commands work as on any table.
|
|
26
34
|
- [Tabs](Tabs.md): Switches between views that share one place on the page. The parts are `Tabs` (the root, a flex column; a row when vertical), `Tabs.List` (the `tablist`), `Tabs.Tab` (a `tab` button on `Clickable`) and `Tabs.Panel` (the `tabpanel`). Built on Base UI `Tabs` (ADR 0003, 0046): it owns the selection, one tab stop with arrow-key roving, `aria-selected`, and the ids that tie each tab to its panel. The selected tab shows an accent bar that fades and grows in (ADR 0049).
|
|
27
35
|
- [Tag](Tag.md): A label that puts content in a category: a topic, a label, a user-made category. A `span` with a subtle tone fill (gray by default) and an `lg` radius (half a one-line tag's height, so one line reads as a pill and wrapped lines stay inside the fill) around a `Text` in the `label` font. It can be read-only, a link, or removable.
|
|
28
36
|
- [Text](Text.md): The base of all visible text, and the primitive every text component builds on. Capsize trims the box to the cap height and the baseline, so the gap around text is the visible space. It takes every Box style prop (`color`, `textAlign`, margins), plus `size`, `font`, `weight`, `leading`, `truncate` and `wrap`.
|
|
29
37
|
- [TextField](TextField.md): A form field for one line of text that is not a search: an `<input>` (role `textbox`) with SearchField's look and no icon or button over it. `type` picks `text`, `email`, `url` or `tel`. Built on Base UI's `Input` (ADR 0003); it composes `Field` for its label, description and error (ADR 0026, 0110). Three sizes at Button's heights (`sm`, `med`, `lg`: 24, 32 and 40 px, ADR 0124).
|
|
38
|
+
- [Textarea](Textarea.md): A form field for several lines of free text: a `<textarea>` (role `textbox`, multi-line) with TextField's look. Built on Base UI's `Input` rendered as a textarea (ADR 0003); it composes `Field` for its label, description and error (ADR 0026, 0136). `rows` sets its starting height, three by default, and the user can drag it taller or shorter. Three sizes (`sm`, `med`, `lg`) set TextField's text size and padding, so the first line sits where a TextField's text does (ADR 0124).
|
|
30
39
|
- [Toast](Toast.md): Tells the user briefly about the result of an action without interrupting them: "Changes saved", "Message sent", "Couldn't upload the file". Material calls it a snackbar and Atlassian a flag. Built on Base UI's Toast, which owns the queue, the timers and swipe-to-dismiss. The parts add the look: a raised card in a stack at the bottom end corner, an icon per variant, a close button, and a slide-up-and-fade that is a plain fade under reduced motion. A toast never takes focus and moves nothing on the page.
|
|
31
40
|
- [VisuallyHidden](VisuallyHidden.md): Text that screen readers read and nobody sees: a 1px clipped box, out of the layout, still in the accessibility tree. Use it for words a sighted user gets from the layout, an icon or a color, never to hide a control or a skip link. One element, chosen with `as`, a `span` by default.
|
|
32
41
|
|