@jonmilner/ui 0.11.3 → 0.11.5
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/Switch/Switch.css +2 -0
- package/dist/Switch/Switch.css.mjs +7 -0
- package/dist/Switch/index.d.mts +29 -0
- package/dist/Switch/index.mjs +59 -0
- 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 +1 -0
- package/dist/docs/Button.md +1 -1
- package/dist/docs/Checkbox.md +1 -1
- package/dist/docs/Chip.md +1 -0
- package/dist/docs/Field.md +6 -3
- package/dist/docs/Heading.md +1 -0
- package/dist/docs/Stack.md +1 -0
- package/dist/docs/Switch.md +119 -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 +3 -0
- package/dist/docs/manifest.json +444 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +12 -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 +13 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../styles/layers.css";
|
|
2
|
+
import "./Textarea.css";
|
|
3
|
+
/* empty css */
|
|
4
|
+
/* empty css */
|
|
5
|
+
import { createRuntimeFn as e } from "@vanilla-extract/recipes/createRuntimeFn";
|
|
6
|
+
// src/Textarea/Textarea.css.ts
|
|
7
|
+
var t = "_1kwv2lp0", n = e({
|
|
8
|
+
defaultClassName: "_1kwv2lp1",
|
|
9
|
+
variantClassNames: { size: {
|
|
10
|
+
sm: "_1kwv2lp2",
|
|
11
|
+
med: "_1kwv2lp3",
|
|
12
|
+
lg: "_1kwv2lp4"
|
|
13
|
+
} },
|
|
14
|
+
defaultVariants: {},
|
|
15
|
+
compoundVariants: []
|
|
16
|
+
});
|
|
17
|
+
export { t as hiddenLabel, n as input };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { StyleProps } from "../Box/base.mjs";
|
|
2
|
+
import { TextFieldInputProps } from "../TextField/index.mjs";
|
|
3
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
|
+
export type TextareaInputProps = Pick<ComponentPropsWithRef<"textarea">, Exclude<keyof TextFieldInputProps, "pattern">>;
|
|
5
|
+
export type TextareaProps = StyleProps & {
|
|
6
|
+
className?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
error?: ReactNode;
|
|
11
|
+
hideLabel?: boolean;
|
|
12
|
+
inputProps?: TextareaInputProps;
|
|
13
|
+
label: ReactNode;
|
|
14
|
+
name?: string;
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
rows?: number;
|
|
19
|
+
size?: "sm" | "med" | "lg";
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
value?: string;
|
|
22
|
+
};
|
|
23
|
+
export declare function Textarea({ label, hideLabel, rows, value, defaultValue, onValueChange, placeholder, description, error, size, disabled, required, name, inputProps, className, style, ...atoms }: TextareaProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { controlText as e } from "../styles/control-size.mjs";
|
|
2
|
+
import { Text as t } from "../Text/index.mjs";
|
|
3
|
+
import { Field as n } from "../Field/index.mjs";
|
|
4
|
+
import { hiddenLabel as r, input as i } from "./Textarea.css.mjs";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { Input as s } from "@base-ui/react/input";
|
|
7
|
+
// src/Textarea/index.tsx
|
|
8
|
+
function c({ label: c, hideLabel: l = !1, rows: u = 3, value: d, defaultValue: f, onValueChange: p, placeholder: m, description: h, error: g, size: _ = "med", disabled: v = !1, required: y = !1, name: b, inputProps: x, className: S, style: C, ...w }) {
|
|
9
|
+
return /* @__PURE__ */ o(n, {
|
|
10
|
+
...w,
|
|
11
|
+
className: S,
|
|
12
|
+
disabled: v,
|
|
13
|
+
invalid: g != null && g !== !1 && g !== "",
|
|
14
|
+
style: C,
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ a(n.Label, {
|
|
17
|
+
className: l ? r : void 0,
|
|
18
|
+
children: c
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ a(s, {
|
|
21
|
+
...x,
|
|
22
|
+
defaultValue: f,
|
|
23
|
+
name: b,
|
|
24
|
+
onValueChange: p && ((e) => p(e)),
|
|
25
|
+
placeholder: m,
|
|
26
|
+
render: /* @__PURE__ */ a(t, {
|
|
27
|
+
as: "textarea",
|
|
28
|
+
className: i({ size: _ }),
|
|
29
|
+
rows: u,
|
|
30
|
+
size: e[_]
|
|
31
|
+
}),
|
|
32
|
+
required: y,
|
|
33
|
+
value: d
|
|
34
|
+
}),
|
|
35
|
+
h != null && /* @__PURE__ */ a(n.Description, { children: h }),
|
|
36
|
+
/* @__PURE__ */ a(n.Error, { children: g })
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export { c as Textarea };
|
package/dist/Toast/Toast.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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.switch, components.tabs, components.tag, components.text-field, components.textarea, components.toast, components.visually-hidden, components.table;
|
|
2
2
|
@layer components.toast{.hcnvsc1{inline-size:min(100% - 2 * var(--space-16), 6 * var(--space-64));inset-block-end:var(--space-16);inset-inline-end:var(--space-16);container:hcnvsc0/inline-size}.hcnvsc1:focus-visible{outline:var(--space-2) solid var(--color-focus);outline-offset:var(--space-2)}.hcnvsc2{gap:var(--space-8);margin:calc(-1 * var(--space-16));padding:var(--space-16);overscroll-behavior:contain;flex-direction:column;max-block-size:100dvh;margin-inline-start:calc(-1 * var(--space-24));padding-inline-start:var(--space-24);display:flex;overflow:hidden auto}.hcnvsc2:empty{padding:0}.hcnvsc2:has([data-swiping],[data-swipe-direction=down]){overflow-y:hidden}.hcnvsc3{border:var(--space-1) solid var(--color-border);transform:translate(var(--toast-swipe-movement-x,0), var(--toast-swipe-movement-y,0));transition:opacity var(--duration-med) var(--easing-standard), translate var(--duration-med) var(--easing-enter), transform var(--duration-med) var(--easing-enter)}.hcnvsc3:focus-visible{outline:var(--space-2) solid var(--color-focus);outline-offset:var(--space-2)}.hcnvsc3[data-starting-style],.hcnvsc3[data-ending-style]{opacity:0;translate:0 var(--distance-med)}.hcnvsc3[data-swiping]{transition:none}.hcnvsc3[data-limited]{display:none}.hcnvsc4{overflow-wrap:anywhere}.hcnvsca{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:0;padding:0;position:absolute;inset-block-start:0;inset-inline-start:0;overflow:hidden}@container hcnvsc0 (inline-size<16rem){.hcnvsc3{flex-wrap:wrap}.hcnvsc4{flex-basis:100%;order:1}.hcnvsc5{margin-inline-start:auto}}}
|
|
@@ -1,2 +1,2 @@
|
|
|
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.switch, components.tabs, components.tag, components.text-field, components.textarea, components.toast, components.visually-hidden, components.table;
|
|
2
2
|
@layer components.visually-hidden{._1qk18b30{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:0;padding:0;position:absolute;overflow:hidden}}
|
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.switch, 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
|
@@ -14,6 +14,7 @@ The base element every component builds on: one element, chosen with `as`, style
|
|
|
14
14
|
|
|
15
15
|
- Text: use `Text` or `Heading`; all visible text goes through them.
|
|
16
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
|
package/dist/docs/Button.md
CHANGED
|
@@ -13,7 +13,7 @@ The labelled action: a `<button type="button">` with the house look, or a link s
|
|
|
13
13
|
|
|
14
14
|
- An icon with no visible label: use `IconButton`.
|
|
15
15
|
- A link inside running text: use a plain `<a>` (or the link component).
|
|
16
|
-
- A toggle, a choice between options, or a menu trigger: use the component for that widget (Checkbox, Tabs, Menu), which handles its keyboard and state.
|
|
16
|
+
- A toggle, a choice between options, or a menu trigger: use the component for that widget (Checkbox, Switch, Tabs, Menu), which handles its keyboard and state.
|
|
17
17
|
- A one-off pressable area, such as a whole card: use `Clickable`.
|
|
18
18
|
|
|
19
19
|
## Rules
|
package/dist/docs/Checkbox.md
CHANGED
|
@@ -11,7 +11,7 @@ A two-state choice, with a third mixed state for a "select all" over a partly se
|
|
|
11
11
|
|
|
12
12
|
## When not to use
|
|
13
13
|
|
|
14
|
-
- A setting that applies the moment it flips: `Switch
|
|
14
|
+
- A setting that applies the moment it flips: use `Switch`.
|
|
15
15
|
- One choice out of several: `RadioGroup` is planned.
|
|
16
16
|
- Picking several options from a long list in a popup: use `MultiSelect`.
|
|
17
17
|
|
package/dist/docs/Chip.md
CHANGED
|
@@ -15,6 +15,7 @@ A toggle that filters content or picks an option: "Unread", "Starred", "Medium".
|
|
|
15
15
|
- A status or fact: use `Badge`.
|
|
16
16
|
- A category or topic label on content: use `Tag` (#101).
|
|
17
17
|
- A one-off action: use `Button`.
|
|
18
|
+
- A setting that applies the moment it changes: use `Switch`.
|
|
18
19
|
- Switching between views of the same content: use `Tabs`.
|
|
19
20
|
- A form field with a required single answer: a radio group (not yet in the library); a `ChipGroup` can be cleared.
|
|
20
21
|
- Picking several values from a list too long to show: use `MultiSelect`.
|
package/dist/docs/Field.md
CHANGED
|
@@ -6,7 +6,7 @@ Wires one form control to its label, description and error: ids, `htmlFor`, `ari
|
|
|
6
6
|
|
|
7
7
|
## When to use
|
|
8
8
|
|
|
9
|
-
- Any form control that needs a visible label, help text or an error, including a control a component builds (Checkbox, MultiSelect build on Field rather than their own wiring).
|
|
9
|
+
- Any form control that needs a visible label, help text or an error, including a control a component builds (Checkbox, MultiSelect, Switch build on Field rather than their own wiring).
|
|
10
10
|
- Showing a server validation error next to its control. The app's action or submit handler returns it; set `invalid` and put the message in `Field.Error` (a props control such as `TextField` takes it as `error` instead; ADR 0133).
|
|
11
11
|
|
|
12
12
|
## When not to use
|
|
@@ -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
|
|
|
@@ -22,7 +22,7 @@ Wires one form control to its label, description and error: ids, `htmlFor`, `ari
|
|
|
22
22
|
- Mark the field with `invalid` whenever you pass an error message; the message alone does not set `aria-invalid`.
|
|
23
23
|
- `Field.Error` always renders a slot one line tall, so a one-line error appears without moving anything. A longer message wraps inside the field (even an unbroken URL) and pushes only what is below. Keep messages to one line where you can.
|
|
24
24
|
- `Field.Error` with children shows them; with `match` set to a validity key (`"valueMissing"`), only when that check fails. Without children, it shows the control's native validation message while the control is invalid.
|
|
25
|
-
- `Field.Label` renders a `label`. Keep it for `Field.Control` and for `Checkbox`, whose hidden input the label points at: clicking it toggles the
|
|
25
|
+
- `Field.Label` renders a `label`. Keep it for `Field.Control` and for `Checkbox` and `Switch`, whose hidden input the label points at: clicking it toggles the control, as on a native checkbox. For a Base UI control with no input at all, set `nativeLabel={false}`; it renders a `span` that names the control (`aria-labelledby`); clicking it focuses the control.
|
|
26
26
|
- `disabled` on Field disables the control and mutes the label. A message in `Field.Error` still shows while disabled; clear it if the field is locked.
|
|
27
27
|
- `name`, `validate`, `validationMode`, `dirty` and `touched` pass through to Base UI's `Field.Root`. `validate` and event handlers are functions, so set them from a client component.
|
|
28
28
|
- Every part takes style props; the root's `display`, `flexDirection` and `gap` (`"8"`) are defaults you can replace. The label, description and error also take Text's `size`, `font`, `weight`, `leading` and `truncate` over their defaults (`sm`; the label in the `label` font at `medium`). `className` is a string and `style` an object (not Base UI's state functions), and the consumer's come last.
|
|
@@ -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
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Turns one setting on or off, and the change applies the moment it flips. Built on Base UI `Switch` (ADR 0003, 0137): a `span` with `role="switch"` and `aria-checked`, plus a hidden checkbox input that submits with a form. The span is a 24 px target with the shared focus ring around a pill track: off is an outlined track with the thumb at the start, on a filled `accent` track with the thumb at the end. It composes `Field` for its label, description and error (ADR 0026), with the label after the switch.
|
|
6
|
+
|
|
7
|
+
## When to use
|
|
8
|
+
|
|
9
|
+
- A setting saved as soon as it changes: "Auto-merge", "Email notifications", "Dark mode".
|
|
10
|
+
- A row in a settings list, where each setting stands alone.
|
|
11
|
+
|
|
12
|
+
## When not to use
|
|
13
|
+
|
|
14
|
+
- A choice sent when the form is submitted ("Accept the terms"), or picking items from a list: use `Checkbox`.
|
|
15
|
+
- A toggle in a toolbar, like bold or a filter: use `Button` or `Chip` with `aria-pressed`.
|
|
16
|
+
- Two options that are not on and off ("Monthly" or "Yearly"): `RadioGroup` is planned.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
- Name it with `label` (or `label` with `hideLabel`) or with `aria-label` when the context shows the setting, as in a table row. The type requires exactly one. The label names the setting, never its state: "Auto-merge", not "On".
|
|
21
|
+
- `checked` with `onCheckedChange` controls it; `defaultChecked` leaves it uncontrolled. `onCheckedChange` gets the new state only.
|
|
22
|
+
- Apply the change in `onCheckedChange`. While it is being saved, pass `busy`: the switch sets `aria-busy`, turns read-only, dims and shows the progress cursor, and keeps focus so the user does not lose their place. Clear `busy` when the save settles, failed or not (a `finally`), or the switch stays locked; on failure, put `checked` back and show `error`. A `readOnly` or `disabled` switch ignores `busy`.
|
|
23
|
+
- Click, a click on the label, Space and Enter all toggle it. Enter does not submit the form, unlike on a checkbox.
|
|
24
|
+
- `description` and `error` render below the row through `Field`; a non-empty `error` marks it invalid (`aria-invalid`, a thicker `danger` border) and joins its `aria-describedby`.
|
|
25
|
+
- `disabled` takes it out of the tab order and dashes the border. `readOnly` keeps it focusable and announced (`aria-readonly`) but unchangeable and dots the border; say nearby why it cannot change.
|
|
26
|
+
- `name` submits `value` (default `"on"`) while on; off submits nothing unless you set `uncheckedValue`.
|
|
27
|
+
- One size: the target is 24 px, the track 38 by 22. Style props, `className` and `style` go to the `Field` around the row and its messages, not to the switch.
|
|
28
|
+
- The module has no hooks, so a server component can render it. `onCheckedChange` is a function: set it from a client component.
|
|
29
|
+
|
|
30
|
+
## Do
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
<Switch
|
|
34
|
+
label="Auto-merge"
|
|
35
|
+
description="Merge the pull request once its checks pass."
|
|
36
|
+
checked={autoMerge}
|
|
37
|
+
busy={saving}
|
|
38
|
+
error={saveError}
|
|
39
|
+
onCheckedChange={async (next) => {
|
|
40
|
+
setAutoMerge(next);
|
|
41
|
+
setSaveError(undefined);
|
|
42
|
+
setSaving(true);
|
|
43
|
+
try {
|
|
44
|
+
await saveAutoMerge(next);
|
|
45
|
+
} catch {
|
|
46
|
+
setAutoMerge(!next);
|
|
47
|
+
setSaveError("Couldn't save. Try again.");
|
|
48
|
+
} finally {
|
|
49
|
+
setSaving(false);
|
|
50
|
+
}
|
|
51
|
+
}}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
// The row's heading names the setting.
|
|
57
|
+
<Switch
|
|
58
|
+
aria-label={`Notifications for ${repo.name}`}
|
|
59
|
+
checked={repo.notify}
|
|
60
|
+
onCheckedChange={(next) => setNotify(repo.id, next)}
|
|
61
|
+
/>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Don't
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
// The label names the state, so the switch reads "On, switch, on".
|
|
68
|
+
<Switch label={enabled ? "On" : "Off"} checked={enabled} onCheckedChange={setEnabled} />
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
// Disabling while saving drops focus mid-request: pass `busy`.
|
|
73
|
+
<Switch label="Auto-merge" checked={autoMerge} disabled={saving} onCheckedChange={save} />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
// A choice that waits for the form's submit button is a checkbox.
|
|
78
|
+
<form>
|
|
79
|
+
<Switch label="Accept the terms" name="terms" />
|
|
80
|
+
<Button type="submit">Sign up</Button>
|
|
81
|
+
</form>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Accessibility
|
|
85
|
+
|
|
86
|
+
- Role `switch` with `aria-checked` `"true"` or `"false"`; `aria-disabled`, `aria-readonly`, `aria-required` and `aria-busy` follow the props, and `aria-invalid` the `error`.
|
|
87
|
+
- The label, description and error reach it through `aria-labelledby` and `aria-describedby`, which Base UI adds after hydration; server HTML has the label's `for`, so a click on the label toggles the switch.
|
|
88
|
+
- On and off differ in the thumb's position as well as the fill, so the state is never color alone. Invalid is a thicker border, disabled a dashed one, read-only a dotted one. The off track's border is `borderStrong` and its thumb `fgMuted`, the on track `accent` with an `accentFg` thumb: 3:1 or more on every surface, in both modes.
|
|
89
|
+
- The thumb slides `distance.lg` as it crossfades; under reduced motion the distance is zero and only the crossfade runs.
|
|
90
|
+
- Under forced colors the track maps to system colors: off a `CanvasText` border and thumb on `Canvas`, on a `LinkText` fill with a `Canvas` thumb, and a `Highlight` focus ring.
|
|
91
|
+
- Busy is momentary, like disabled, so the track's half-opacity dim is outside the 3:1 rule (the focus ring is not dimmed); `aria-busy` tells assistive tech, and the switch keeps focus and its name.
|
|
92
|
+
|
|
93
|
+
## Props
|
|
94
|
+
|
|
95
|
+
Generated from the TypeScript types.
|
|
96
|
+
|
|
97
|
+
### Switch
|
|
98
|
+
|
|
99
|
+
| Prop | Type | Required | Description |
|
|
100
|
+
| --- | --- | --- | --- |
|
|
101
|
+
| `aria-label` | `string` | no | |
|
|
102
|
+
| `busy` | `boolean` | no | |
|
|
103
|
+
| `checked` | `boolean` | no | |
|
|
104
|
+
| `className` | `string` | no | |
|
|
105
|
+
| `defaultChecked` | `boolean` | no | |
|
|
106
|
+
| `description` | `ReactNode` | no | |
|
|
107
|
+
| `disabled` | `boolean` | no | |
|
|
108
|
+
| `error` | `ReactNode` | no | |
|
|
109
|
+
| `hideLabel` | `boolean` | no | |
|
|
110
|
+
| `label` | `ReactNode` | no | |
|
|
111
|
+
| `name` | `string` | no | |
|
|
112
|
+
| `onCheckedChange` | `((checked: boolean) => void)` | no | |
|
|
113
|
+
| `readOnly` | `boolean` | no | |
|
|
114
|
+
| `required` | `boolean` | no | |
|
|
115
|
+
| `style` | `CSSProperties` | no | |
|
|
116
|
+
| `uncheckedValue` | `string` | no | |
|
|
117
|
+
| `value` | `string` | no | |
|
|
118
|
+
|
|
119
|
+
Also accepts the style props (see `manifest.json` `styleProps`).
|
|
@@ -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 | |
|