camber-ui 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/README.md +72 -2
- package/dist/chunk-XW4RP3PC.js +45 -0
- package/dist/chunk-XW4RP3PC.js.map +1 -0
- package/dist/index.d.ts +456 -0
- package/dist/index.js +1146 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +1178 -0
- package/dist/theme.d.ts +351 -0
- package/dist/theme.js +298 -0
- package/dist/theme.js.map +1 -0
- package/dist/themes/default.css +67 -0
- package/dist/themes/midnight.css +66 -0
- package/package.json +73 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matt Arnold
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# camber-ui
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React components wrapped in Tailwind. A CSS design-token file themes them. Load more than one file and set `data-theme` to choose the active theme.
|
|
4
|
+
|
|
5
|
+
This package is the React library `camber-ui`. It is not `@byre/camber`, which is a separate web-component spec.
|
|
6
|
+
|
|
7
|
+
Peer dependencies are `react` and `react-dom` version 19 or newer. The component entry is a client module. `camber-ui/theme` has no client banner, so token checks can run outside the browser.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install camber-ui react react-dom
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Button, setTheme } from "camber-ui";
|
|
19
|
+
import "camber-ui/styles.css";
|
|
20
|
+
import "camber-ui/themes/midnight.css";
|
|
21
|
+
|
|
22
|
+
setTheme("midnight");
|
|
23
|
+
|
|
24
|
+
export function App() {
|
|
25
|
+
return <Button>Save</Button>;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`styles.css` includes the component CSS and the default tokens on `:root` and `[data-theme="default"]`. Import any extra theme file after it. Use `setTheme` (or set `data-theme` yourself) to activate a loaded theme. `getTheme` reads the current value.
|
|
30
|
+
|
|
31
|
+
## Customize in 60 seconds
|
|
32
|
+
|
|
33
|
+
Override a few tokens in your app CSS. Primary brand and focus are usually enough to start:
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
:root {
|
|
37
|
+
--camber-button-primary-bg: #0f766e;
|
|
38
|
+
--camber-button-primary-bg-hover: #0d9488;
|
|
39
|
+
--camber-button-primary-fg: #ffffff;
|
|
40
|
+
--camber-focus: #0f766e;
|
|
41
|
+
--camber-border: #94a3b8;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Import `camber-ui/styles.css` first, then your overrides. For a full theme file with a name, use the dashboard in this repository and export `camber-{name}.css`, then:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import "camber-ui/styles.css";
|
|
49
|
+
import "./camber-brand.css";
|
|
50
|
+
import { setTheme } from "camber-ui";
|
|
51
|
+
|
|
52
|
+
setTheme("brand");
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A theme name is a lowercase letter, then up to 40 letters, numbers, or hyphens.
|
|
56
|
+
|
|
57
|
+
## Fonts
|
|
58
|
+
|
|
59
|
+
Both shipped themes use the system font stack. Change `--camber-font` or `--camber-font-mono` in your app. The dashboard does not edit the font family and does not load font files.
|
|
60
|
+
|
|
61
|
+
## What is exported
|
|
62
|
+
|
|
63
|
+
Components, their prop types, `setTheme`, `getTheme`, `pillTones`, `pillToneClass`, and the type scales (`headingScale`, `paragraphScale`, `quoteScale`, `listScale`, `codeScale`, `textScale`) come from `camber-ui`. The full list is in the repository `CHANGELOG.md`.
|
|
64
|
+
|
|
65
|
+
Most roots accept `className` for layout. Accordion, Tabs, and Menu support controlled values (`value` / `onValueChange`, or `open` / `onOpenChange` for Menu). `Link` accepts `variant` (`text` | `primary` | `secondary` | `ghost`) and `size` for button looks; Navbar primary links use ghost.
|
|
66
|
+
|
|
67
|
+
Pill color repeats a text label. Do not convey a pill's meaning by color alone.
|
|
68
|
+
|
|
69
|
+
`camber-ui/theme` exports the token names, the shipped themes, contrast checks, and `themeBlock` for writing a theme file. Spacing and opacity tokens are not contrast pairs.
|
|
70
|
+
|
|
71
|
+
## Dashboard and docs
|
|
72
|
+
|
|
73
|
+
Theme export and marketing docs live in the [camber-ui repository](https://github.com/crosslogicdigital/camber-ui) (`apps/dashboard`, `apps/site`). They are not part of this npm package.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/tokens/css.ts
|
|
2
|
+
function isThemeName(name) {
|
|
3
|
+
return /^[a-z][a-z0-9-]{0,40}$/.test(name);
|
|
4
|
+
}
|
|
5
|
+
function isSafeTokenName(name) {
|
|
6
|
+
return name.startsWith("--camber-") && !/[^a-z0-9-]/.test(name.slice(2));
|
|
7
|
+
}
|
|
8
|
+
function isSafeTokenValue(value) {
|
|
9
|
+
return value.length > 0 && value.length <= 200 && !/[;{}]/.test(value) && !value.includes("/*") && !value.includes("*/") && !value.includes("\n");
|
|
10
|
+
}
|
|
11
|
+
function themeSelector(name) {
|
|
12
|
+
if (!isThemeName(name)) {
|
|
13
|
+
throw new Error("Unsafe theme name");
|
|
14
|
+
}
|
|
15
|
+
return `[data-theme="${name}"]`;
|
|
16
|
+
}
|
|
17
|
+
function themeBlock(options) {
|
|
18
|
+
if (options.colorScheme !== "light" && options.colorScheme !== "dark") {
|
|
19
|
+
throw new Error("Unsafe color scheme");
|
|
20
|
+
}
|
|
21
|
+
if (options.title.includes("*/") || options.detail.includes("*/")) {
|
|
22
|
+
throw new Error("Unsafe theme comment");
|
|
23
|
+
}
|
|
24
|
+
const lines = Object.entries(options.tokens).map(([token, value]) => {
|
|
25
|
+
if (!isSafeTokenName(token) || !isSafeTokenValue(value)) {
|
|
26
|
+
throw new Error(`Unsafe token ${token}`);
|
|
27
|
+
}
|
|
28
|
+
return ` ${token}: ${value};`;
|
|
29
|
+
});
|
|
30
|
+
return [
|
|
31
|
+
"/**",
|
|
32
|
+
` * camber-ui theme: ${options.title}`,
|
|
33
|
+
` * ${options.detail}`,
|
|
34
|
+
" */",
|
|
35
|
+
`${options.selector} {`,
|
|
36
|
+
` color-scheme: ${options.colorScheme};`,
|
|
37
|
+
...lines,
|
|
38
|
+
"}",
|
|
39
|
+
""
|
|
40
|
+
].join("\n");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { isSafeTokenValue, isThemeName, themeBlock, themeSelector };
|
|
44
|
+
//# sourceMappingURL=chunk-XW4RP3PC.js.map
|
|
45
|
+
//# sourceMappingURL=chunk-XW4RP3PC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tokens/css.ts"],"names":[],"mappings":";AASO,SAAS,YAAY,IAAA,EAAuB;AACjD,EAAA,OAAO,wBAAA,CAAyB,KAAK,IAAI,CAAA;AAC3C;AAGO,SAAS,gBAAgB,IAAA,EAAuB;AACrD,EAAA,OAAO,IAAA,CAAK,UAAA,CAAW,WAAW,CAAA,IAAK,CAAC,aAAa,IAAA,CAAK,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAA;AACzE;AAGO,SAAS,iBAAiB,KAAA,EAAwB;AACvD,EAAA,OAAO,KAAA,CAAM,MAAA,GAAS,CAAA,IAAK,KAAA,CAAM,MAAA,IAAU,OAAO,CAAC,OAAA,CAAQ,IAAA,CAAK,KAAK,CAAA,IAAK,CAAC,MAAM,QAAA,CAAS,IAAI,CAAA,IAAK,CAAC,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA,IAAK,CAAC,KAAA,CAAM,QAAA,CAAS,IAAI,CAAA;AAClJ;AAGO,SAAS,cAAc,IAAA,EAAsB;AAClD,EAAA,IAAI,CAAC,WAAA,CAAY,IAAI,CAAA,EAAG;AACtB,IAAA,MAAM,IAAI,MAAM,mBAAmB,CAAA;AAAA,EACrC;AACA,EAAA,OAAO,gBAAgB,IAAI,CAAA,EAAA,CAAA;AAC7B;AAWO,SAAS,WAAW,OAAA,EAAoC;AAC7D,EAAA,IAAI,OAAA,CAAQ,WAAA,KAAgB,OAAA,IAAW,OAAA,CAAQ,gBAAgB,MAAA,EAAQ;AACrE,IAAA,MAAM,IAAI,MAAM,qBAAqB,CAAA;AAAA,EACvC;AACA,EAAA,IAAI,OAAA,CAAQ,MAAM,QAAA,CAAS,IAAI,KAAK,OAAA,CAAQ,MAAA,CAAO,QAAA,CAAS,IAAI,CAAA,EAAG;AACjE,IAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AAAA,EACxC;AACA,EAAA,MAAM,KAAA,GAAS,MAAA,CAAO,OAAA,CAAQ,OAAA,CAAQ,MAAM,CAAA,CAA4B,GAAA,CAAI,CAAC,CAAC,KAAA,EAAO,KAAK,CAAA,KAAM;AAC9F,IAAA,IAAI,CAAC,eAAA,CAAgB,KAAK,KAAK,CAAC,gBAAA,CAAiB,KAAK,CAAA,EAAG;AACvD,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,aAAA,EAAgB,KAAK,CAAA,CAAE,CAAA;AAAA,IACzC;AACA,IAAA,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,EAAA,EAAK,KAAK,CAAA,CAAA,CAAA;AAAA,EAC7B,CAAC,CAAA;AACD,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,CAAA,oBAAA,EAAuB,QAAQ,KAAK,CAAA,CAAA;AAAA,IACpC,CAAA,GAAA,EAAM,QAAQ,MAAM,CAAA,CAAA;AAAA,IACpB,KAAA;AAAA,IACA,CAAA,EAAG,QAAQ,QAAQ,CAAA,EAAA,CAAA;AAAA,IACnB,CAAA,gBAAA,EAAmB,QAAQ,WAAW,CAAA,CAAA,CAAA;AAAA,IACtC,GAAG,KAAA;AAAA,IACH,GAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,IAAI,CAAA;AACb","file":"chunk-XW4RP3PC.js","sourcesContent":["/**\n * Serializes camber design tokens into one theme CSS block.\n * Called by scripts/emit-themes.ts and by the dashboard export.\n */\nimport type { TokenName } from \"./themes.ts\";\n\nexport type ColorScheme = \"light\" | \"dark\";\n\n/** Theme file names used in data-theme and in the download filename. */\nexport function isThemeName(name: string): boolean {\n return /^[a-z][a-z0-9-]{0,40}$/.test(name);\n}\n\n/** Custom property names produced by this package. */\nexport function isSafeTokenName(name: string): boolean {\n return name.startsWith(\"--camber-\") && !/[^a-z0-9-]/.test(name.slice(2));\n}\n\n/** Rejects values that could escape a CSS declaration. */\nexport function isSafeTokenValue(value: string): boolean {\n return value.length > 0 && value.length <= 200 && !/[;{}]/.test(value) && !value.includes(\"/*\") && !value.includes(\"*/\") && !value.includes(\"\\n\");\n}\n\n/** Builds the data-theme selector for an exported theme. Called by the dashboard. */\nexport function themeSelector(name: string): string {\n if (!isThemeName(name)) {\n throw new Error(\"Unsafe theme name\");\n }\n return `[data-theme=\"${name}\"]`;\n}\n\ntype ThemeBlockOptions = {\n selector: string;\n colorScheme: ColorScheme;\n tokens: Readonly<Record<TokenName, string>>;\n title: string;\n detail: string;\n};\n\n/** Returns the CSS file body for one theme. Throws if a token is unsafe. */\nexport function themeBlock(options: ThemeBlockOptions): string {\n if (options.colorScheme !== \"light\" && options.colorScheme !== \"dark\") {\n throw new Error(\"Unsafe color scheme\");\n }\n if (options.title.includes(\"*/\") || options.detail.includes(\"*/\")) {\n throw new Error(\"Unsafe theme comment\");\n }\n const lines = (Object.entries(options.tokens) as [TokenName, string][]).map(([token, value]) => {\n if (!isSafeTokenName(token) || !isSafeTokenValue(value)) {\n throw new Error(`Unsafe token ${token}`);\n }\n return ` ${token}: ${value};`;\n });\n return [\n \"/**\",\n ` * camber-ui theme: ${options.title}`,\n ` * ${options.detail}`,\n \" */\",\n `${options.selector} {`,\n ` color-scheme: ${options.colorScheme};`,\n ...lines,\n \"}\",\n \"\",\n ].join(\"\\n\");\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps, ReactNode, ReactElement, FormEvent } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Sets data-theme on <html>. Throws when the name is not a valid theme id. */
|
|
5
|
+
declare function setTheme(name: string): void;
|
|
6
|
+
/** Returns the current data-theme value, or undefined when unset. */
|
|
7
|
+
declare function getTheme(): string | undefined;
|
|
8
|
+
|
|
9
|
+
/** Button and button-looking Link variants. */
|
|
10
|
+
type ButtonVariant = "primary" | "secondary" | "ghost";
|
|
11
|
+
/** Button and button-looking Link sizes. */
|
|
12
|
+
type ButtonSize = "sm" | "md";
|
|
13
|
+
|
|
14
|
+
type ButtonProps = ComponentProps<"button"> & {
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
size?: ButtonSize;
|
|
17
|
+
};
|
|
18
|
+
/** Renders a button. Defaults to type="button" so it does not submit a form. */
|
|
19
|
+
declare function Button({ variant, size, className, type, ...props }: ButtonProps): react.JSX.Element;
|
|
20
|
+
|
|
21
|
+
type LinkVariant = "text" | ButtonVariant;
|
|
22
|
+
type LinkProps = ComponentProps<"a"> & {
|
|
23
|
+
/** Opens a new tab and sets rel="noopener noreferrer". */
|
|
24
|
+
external?: boolean;
|
|
25
|
+
/** text keeps underline link styles. Other values match Button. */
|
|
26
|
+
variant?: LinkVariant;
|
|
27
|
+
/** Used when variant is primary, secondary, or ghost. */
|
|
28
|
+
size?: ButtonSize;
|
|
29
|
+
};
|
|
30
|
+
/** Renders an anchor. Underline and text stay on in the visited state for variant="text". */
|
|
31
|
+
declare function Link({ external, variant, size, target, rel, className, ...props }: LinkProps): react.JSX.Element;
|
|
32
|
+
|
|
33
|
+
declare const pillTones: readonly ["neutral", "info", "success", "warning", "danger"];
|
|
34
|
+
type PillTone = (typeof pillTones)[number];
|
|
35
|
+
type PillProps = ComponentProps<"span"> & {
|
|
36
|
+
tone?: PillTone;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
};
|
|
39
|
+
/** Background and text classes for one tone. Alert and Toast use this too. */
|
|
40
|
+
declare function pillToneClass(tone?: PillTone): string;
|
|
41
|
+
/** Renders a non-interactive status label. */
|
|
42
|
+
declare function Pill({ tone, className, ...props }: PillProps): react.JSX.Element;
|
|
43
|
+
|
|
44
|
+
type InputProps = ComponentProps<"input">;
|
|
45
|
+
/** Renders a single-line text control. */
|
|
46
|
+
declare function Input({ className, type, ...props }: InputProps): react.JSX.Element;
|
|
47
|
+
|
|
48
|
+
type ControlProps = {
|
|
49
|
+
id?: string;
|
|
50
|
+
"aria-describedby"?: string;
|
|
51
|
+
"aria-invalid"?: boolean | "true" | "false";
|
|
52
|
+
};
|
|
53
|
+
type FieldProps = {
|
|
54
|
+
label: string;
|
|
55
|
+
hint?: string;
|
|
56
|
+
error?: string;
|
|
57
|
+
children: ReactElement<ControlProps>;
|
|
58
|
+
className?: string;
|
|
59
|
+
};
|
|
60
|
+
/** Connects a label, hint, and error to a single control. */
|
|
61
|
+
declare function Field({ label, hint, error, children, className }: FieldProps): react.JSX.Element;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Type scale shared by the typography components.
|
|
65
|
+
* Size is a unitless multiple of the base size token, such as 1.25 or 0.89.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
declare const headingScale: {
|
|
69
|
+
readonly h1: 2.5;
|
|
70
|
+
readonly h2: 2;
|
|
71
|
+
readonly h3: 1.5;
|
|
72
|
+
readonly h4: 1.25;
|
|
73
|
+
readonly h5: 1;
|
|
74
|
+
readonly h6: 0.875;
|
|
75
|
+
};
|
|
76
|
+
declare const paragraphScale: {
|
|
77
|
+
readonly p: 1;
|
|
78
|
+
readonly address: 1;
|
|
79
|
+
readonly figcaption: 0.875;
|
|
80
|
+
};
|
|
81
|
+
declare const quoteScale: {
|
|
82
|
+
readonly blockquote: 1.25;
|
|
83
|
+
readonly q: 1;
|
|
84
|
+
};
|
|
85
|
+
declare const listScale: {
|
|
86
|
+
readonly ul: 1;
|
|
87
|
+
readonly ol: 1;
|
|
88
|
+
readonly dl: 1;
|
|
89
|
+
};
|
|
90
|
+
declare const codeScale: {
|
|
91
|
+
readonly code: 0.875;
|
|
92
|
+
readonly pre: 0.875;
|
|
93
|
+
readonly kbd: 0.875;
|
|
94
|
+
readonly samp: 0.875;
|
|
95
|
+
};
|
|
96
|
+
declare const textScale: {
|
|
97
|
+
readonly span: 1;
|
|
98
|
+
readonly strong: 1;
|
|
99
|
+
readonly b: 1;
|
|
100
|
+
readonly em: 1;
|
|
101
|
+
readonly i: 1;
|
|
102
|
+
readonly small: 0.875;
|
|
103
|
+
readonly mark: 1;
|
|
104
|
+
readonly abbr: 1;
|
|
105
|
+
readonly cite: 1;
|
|
106
|
+
readonly dfn: 1;
|
|
107
|
+
readonly var: 1;
|
|
108
|
+
readonly time: 1;
|
|
109
|
+
readonly u: 1;
|
|
110
|
+
readonly s: 1;
|
|
111
|
+
readonly del: 1;
|
|
112
|
+
readonly ins: 1;
|
|
113
|
+
readonly sub: 0.75;
|
|
114
|
+
readonly sup: 0.75;
|
|
115
|
+
};
|
|
116
|
+
type HeadingTag = keyof typeof headingScale;
|
|
117
|
+
type ParagraphTag = keyof typeof paragraphScale;
|
|
118
|
+
type QuoteTag = keyof typeof quoteScale;
|
|
119
|
+
type ListTag = keyof typeof listScale;
|
|
120
|
+
type CodeTag = keyof typeof codeScale;
|
|
121
|
+
type TextTag = keyof typeof textScale;
|
|
122
|
+
|
|
123
|
+
type HeadingProps = ComponentProps<"h2"> & {
|
|
124
|
+
as?: HeadingTag;
|
|
125
|
+
size?: number;
|
|
126
|
+
};
|
|
127
|
+
/** Renders a heading at the scale for its level, or at `size` when that is set. */
|
|
128
|
+
declare function Heading({ as, size, className, style, ...props }: HeadingProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
129
|
+
|
|
130
|
+
type ParagraphProps = ComponentProps<"p"> & {
|
|
131
|
+
as?: ParagraphTag;
|
|
132
|
+
size?: number;
|
|
133
|
+
};
|
|
134
|
+
/** Renders body copy at the scale for its element, or at `size` when that is set. */
|
|
135
|
+
declare function Paragraph({ as, size, className, style, ...props }: ParagraphProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
136
|
+
|
|
137
|
+
type QuoteProps = ComponentProps<"blockquote"> & {
|
|
138
|
+
as?: QuoteTag;
|
|
139
|
+
size?: number;
|
|
140
|
+
};
|
|
141
|
+
/** Renders a quotation. An inline q keeps the browser's quotation marks. */
|
|
142
|
+
declare function Quote({ as, size, className, style, ...props }: QuoteProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
143
|
+
|
|
144
|
+
type ListProps = ComponentProps<"ul"> & {
|
|
145
|
+
as?: ListTag;
|
|
146
|
+
size?: number;
|
|
147
|
+
};
|
|
148
|
+
/** Renders a list. Children are li, or dt and dd when `as` is dl. */
|
|
149
|
+
declare function List({ as, size, className, style, ...props }: ListProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
150
|
+
|
|
151
|
+
type CodeProps = ComponentProps<"code"> & {
|
|
152
|
+
as?: CodeTag;
|
|
153
|
+
size?: number;
|
|
154
|
+
};
|
|
155
|
+
/** Renders monospace text. pre wraps long lines so a narrow column can hold it. */
|
|
156
|
+
declare function Code({ as, size, className, style, ...props }: CodeProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
157
|
+
|
|
158
|
+
type TextProps = ComponentProps<"span"> & {
|
|
159
|
+
as?: TextTag;
|
|
160
|
+
size?: number;
|
|
161
|
+
dateTime?: string;
|
|
162
|
+
};
|
|
163
|
+
/** Renders an inline phrasing element at the scale for that element, or at `size`. */
|
|
164
|
+
declare function Text({ as, size, className, style, ...props }: TextProps): react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
165
|
+
|
|
166
|
+
type TextareaProps = ComponentProps<"textarea">;
|
|
167
|
+
/** Renders a multi-line text control. */
|
|
168
|
+
declare function Textarea({ className, ...props }: TextareaProps): react.JSX.Element;
|
|
169
|
+
|
|
170
|
+
type SelectProps = ComponentProps<"select">;
|
|
171
|
+
/** Renders a native select so the choice stays in the platform menu. */
|
|
172
|
+
declare function Select({ className, ...props }: SelectProps): react.JSX.Element;
|
|
173
|
+
|
|
174
|
+
type CheckboxProps = Omit<ComponentProps<"input">, "type"> & {
|
|
175
|
+
children?: ReactNode;
|
|
176
|
+
};
|
|
177
|
+
/** Renders a checkbox. Without children it is the control Field labels. */
|
|
178
|
+
declare function Checkbox({ children, className, ...props }: CheckboxProps): react.JSX.Element;
|
|
179
|
+
|
|
180
|
+
type RadioProps = Omit<ComponentProps<"input">, "type"> & {
|
|
181
|
+
children?: ReactNode;
|
|
182
|
+
};
|
|
183
|
+
/** Renders a radio. Without children it is the control Field labels. */
|
|
184
|
+
declare function Radio({ children, className, ...props }: RadioProps): react.JSX.Element;
|
|
185
|
+
|
|
186
|
+
type SwitchProps = Omit<ComponentProps<"input">, "type"> & {
|
|
187
|
+
children?: ReactNode;
|
|
188
|
+
};
|
|
189
|
+
/** Renders an on/off switch. Without children it is the control Field labels. */
|
|
190
|
+
declare function Switch({ children, className, ...props }: SwitchProps): react.JSX.Element;
|
|
191
|
+
|
|
192
|
+
type SliderProps = Omit<ComponentProps<"input">, "type">;
|
|
193
|
+
/** Renders a range control. The value is announced by the platform. */
|
|
194
|
+
declare function Slider({ className, ...props }: SliderProps): react.JSX.Element;
|
|
195
|
+
|
|
196
|
+
type AvatarProps = {
|
|
197
|
+
name: string;
|
|
198
|
+
src?: string;
|
|
199
|
+
className?: string;
|
|
200
|
+
};
|
|
201
|
+
/** Renders initials on the neutral pill, or a photo whose alt is the person's name. The secondary button fill matches the paper surface, so it cannot mark the circle. */
|
|
202
|
+
declare function Avatar({ name, src, className }: AvatarProps): react.JSX.Element;
|
|
203
|
+
|
|
204
|
+
type DividerProps = {
|
|
205
|
+
children?: ReactNode;
|
|
206
|
+
className?: string;
|
|
207
|
+
};
|
|
208
|
+
/** Renders a horizontal rule, with optional text in the middle. */
|
|
209
|
+
declare function Divider({ children, className }: DividerProps): react.JSX.Element;
|
|
210
|
+
|
|
211
|
+
type SpinnerProps = {
|
|
212
|
+
label?: string;
|
|
213
|
+
className?: string;
|
|
214
|
+
};
|
|
215
|
+
/** Renders a loading indicator with its name beside it. */
|
|
216
|
+
declare function Spinner({ label, className }: SpinnerProps): react.JSX.Element;
|
|
217
|
+
|
|
218
|
+
type ProgressProps = {
|
|
219
|
+
label: string;
|
|
220
|
+
value: number;
|
|
221
|
+
max?: number;
|
|
222
|
+
className?: string;
|
|
223
|
+
};
|
|
224
|
+
/** Renders a labeled progress bar. */
|
|
225
|
+
declare function Progress({ label, value, max, className }: ProgressProps): react.JSX.Element;
|
|
226
|
+
|
|
227
|
+
type AlertProps = {
|
|
228
|
+
tone?: PillTone;
|
|
229
|
+
title?: string;
|
|
230
|
+
children: ReactNode;
|
|
231
|
+
className?: string;
|
|
232
|
+
};
|
|
233
|
+
/** Renders a status message. Warning and danger use the alert role. */
|
|
234
|
+
declare function Alert({ tone, title, children, className }: AlertProps): react.JSX.Element;
|
|
235
|
+
|
|
236
|
+
type ToastProps = {
|
|
237
|
+
tone?: PillTone;
|
|
238
|
+
children: ReactNode;
|
|
239
|
+
onDismiss?: () => void;
|
|
240
|
+
className?: string;
|
|
241
|
+
};
|
|
242
|
+
/** Renders a status note. Dismiss stays a button so it is in the tab order. */
|
|
243
|
+
declare function Toast({ tone, children, onDismiss, className }: ToastProps): react.JSX.Element;
|
|
244
|
+
|
|
245
|
+
type BreadcrumbItem = {
|
|
246
|
+
label: string;
|
|
247
|
+
href?: string;
|
|
248
|
+
};
|
|
249
|
+
type BreadcrumbProps = {
|
|
250
|
+
items: readonly BreadcrumbItem[];
|
|
251
|
+
className?: string;
|
|
252
|
+
};
|
|
253
|
+
/** Renders a breadcrumb trail. */
|
|
254
|
+
declare function Breadcrumb({ items, className }: BreadcrumbProps): react.JSX.Element;
|
|
255
|
+
|
|
256
|
+
type ButtonGroupProps = {
|
|
257
|
+
label: string;
|
|
258
|
+
children: ReactNode;
|
|
259
|
+
className?: string;
|
|
260
|
+
};
|
|
261
|
+
/** Renders related buttons as one group. */
|
|
262
|
+
declare function ButtonGroup({ label, children, className }: ButtonGroupProps): react.JSX.Element;
|
|
263
|
+
|
|
264
|
+
type CardProps = {
|
|
265
|
+
title: string;
|
|
266
|
+
children: ReactNode;
|
|
267
|
+
action?: ReactNode;
|
|
268
|
+
className?: string;
|
|
269
|
+
};
|
|
270
|
+
/** Renders a card. The title is a heading. */
|
|
271
|
+
declare function Card({ title, children, action, className }: CardProps): react.JSX.Element;
|
|
272
|
+
|
|
273
|
+
type TabItem = {
|
|
274
|
+
id: string;
|
|
275
|
+
label: string;
|
|
276
|
+
children: ReactNode;
|
|
277
|
+
};
|
|
278
|
+
type TabsProps = {
|
|
279
|
+
label: string;
|
|
280
|
+
items: readonly TabItem[];
|
|
281
|
+
className?: string;
|
|
282
|
+
value?: string;
|
|
283
|
+
defaultValue?: string;
|
|
284
|
+
onValueChange?: (value: string) => void;
|
|
285
|
+
};
|
|
286
|
+
/** Renders a tab list and the selected panel. */
|
|
287
|
+
declare function Tabs({ label, items, className, value: valueProp, defaultValue, onValueChange, }: TabsProps): react.JSX.Element;
|
|
288
|
+
|
|
289
|
+
type AccordionItem = {
|
|
290
|
+
id: string;
|
|
291
|
+
title: string;
|
|
292
|
+
children: ReactNode;
|
|
293
|
+
};
|
|
294
|
+
type AccordionProps = {
|
|
295
|
+
items: readonly AccordionItem[];
|
|
296
|
+
className?: string;
|
|
297
|
+
/** Controlled open item id. Pass null to close every section. */
|
|
298
|
+
value?: string | null;
|
|
299
|
+
/** Uncontrolled initial open item. Defaults to the first item. */
|
|
300
|
+
defaultValue?: string | null;
|
|
301
|
+
onValueChange?: (value: string | null) => void;
|
|
302
|
+
};
|
|
303
|
+
/** Renders disclosure sections in one bordered surface. The title button states whether it is open. */
|
|
304
|
+
declare function Accordion({ items, className, value: valueProp, defaultValue, onValueChange, }: AccordionProps): react.JSX.Element;
|
|
305
|
+
|
|
306
|
+
type PaginationProps = {
|
|
307
|
+
page: number;
|
|
308
|
+
pages: number;
|
|
309
|
+
onPage: (page: number) => void;
|
|
310
|
+
className?: string;
|
|
311
|
+
};
|
|
312
|
+
/** Renders previous, the current page, and next. */
|
|
313
|
+
declare function Pagination({ page, pages, onPage, className }: PaginationProps): react.JSX.Element;
|
|
314
|
+
|
|
315
|
+
type TableProps = {
|
|
316
|
+
caption: string;
|
|
317
|
+
columns: readonly string[];
|
|
318
|
+
rows: readonly (readonly ReactNode[])[];
|
|
319
|
+
className?: string;
|
|
320
|
+
};
|
|
321
|
+
/** Renders a data table. Column headers are scoped. */
|
|
322
|
+
declare function Table({ caption, columns, rows, className }: TableProps): react.JSX.Element;
|
|
323
|
+
|
|
324
|
+
type DialogProps = {
|
|
325
|
+
open: boolean;
|
|
326
|
+
title: string;
|
|
327
|
+
children: ReactNode;
|
|
328
|
+
onClose?: () => void;
|
|
329
|
+
modal?: boolean;
|
|
330
|
+
className?: string;
|
|
331
|
+
};
|
|
332
|
+
/** Renders a dialog named by its title. Escape asks the parent to close it. */
|
|
333
|
+
declare function Dialog({ open, title, children, onClose, modal, className }: DialogProps): react.JSX.Element;
|
|
334
|
+
|
|
335
|
+
type MenuItem = {
|
|
336
|
+
id: string;
|
|
337
|
+
label: string;
|
|
338
|
+
onSelect?: () => void;
|
|
339
|
+
};
|
|
340
|
+
type MenuProps = {
|
|
341
|
+
label: string;
|
|
342
|
+
items: readonly MenuItem[];
|
|
343
|
+
className?: string;
|
|
344
|
+
open?: boolean;
|
|
345
|
+
defaultOpen?: boolean;
|
|
346
|
+
onOpenChange?: (open: boolean) => void;
|
|
347
|
+
};
|
|
348
|
+
/** Renders a button that opens a menu of actions. Arrows move inside it. */
|
|
349
|
+
declare function Menu({ label, items, className, open: openProp, defaultOpen, onOpenChange, }: MenuProps): react.JSX.Element;
|
|
350
|
+
|
|
351
|
+
type StatProps = {
|
|
352
|
+
label: string;
|
|
353
|
+
value: string;
|
|
354
|
+
hint?: string;
|
|
355
|
+
className?: string;
|
|
356
|
+
};
|
|
357
|
+
/** Renders one measurement. The label is text, not color. */
|
|
358
|
+
declare function Stat({ label, value, hint, className }: StatProps): react.JSX.Element;
|
|
359
|
+
|
|
360
|
+
type EmptyStateProps = {
|
|
361
|
+
title: string;
|
|
362
|
+
children: ReactNode;
|
|
363
|
+
action?: ReactNode;
|
|
364
|
+
className?: string;
|
|
365
|
+
};
|
|
366
|
+
/** Renders an empty collection with a heading and an optional action. */
|
|
367
|
+
declare function EmptyState({ title, children, action, className }: EmptyStateProps): react.JSX.Element;
|
|
368
|
+
|
|
369
|
+
type NavbarLink = {
|
|
370
|
+
href: string;
|
|
371
|
+
label: string;
|
|
372
|
+
};
|
|
373
|
+
type NavbarProps = {
|
|
374
|
+
brand: string;
|
|
375
|
+
links: readonly NavbarLink[];
|
|
376
|
+
children?: ReactNode;
|
|
377
|
+
className?: string;
|
|
378
|
+
};
|
|
379
|
+
/** Renders the top bar of a product page. */
|
|
380
|
+
declare function Navbar({ brand, links, children, className }: NavbarProps): react.JSX.Element;
|
|
381
|
+
|
|
382
|
+
type FooterProps = {
|
|
383
|
+
note: string;
|
|
384
|
+
links: readonly NavbarLink[];
|
|
385
|
+
className?: string;
|
|
386
|
+
};
|
|
387
|
+
/** Renders a page footer. */
|
|
388
|
+
declare function Footer({ note, links, className }: FooterProps): react.JSX.Element;
|
|
389
|
+
|
|
390
|
+
type HeroProps = {
|
|
391
|
+
kicker?: string;
|
|
392
|
+
title: string;
|
|
393
|
+
children: ReactNode;
|
|
394
|
+
actions?: ReactNode;
|
|
395
|
+
className?: string;
|
|
396
|
+
};
|
|
397
|
+
/** Renders the opening block of a page. */
|
|
398
|
+
declare function Hero({ kicker, title, children, actions, className }: HeroProps): react.JSX.Element;
|
|
399
|
+
|
|
400
|
+
type FeatureItem = {
|
|
401
|
+
title: string;
|
|
402
|
+
body: string;
|
|
403
|
+
};
|
|
404
|
+
type FeaturesProps = {
|
|
405
|
+
title: string;
|
|
406
|
+
items: readonly FeatureItem[];
|
|
407
|
+
className?: string;
|
|
408
|
+
};
|
|
409
|
+
/** Renders a feature grid. Each point has a heading and a sentence. */
|
|
410
|
+
declare function Features({ title, items, className }: FeaturesProps): react.JSX.Element;
|
|
411
|
+
|
|
412
|
+
type PricingTier = {
|
|
413
|
+
name: string;
|
|
414
|
+
price: string;
|
|
415
|
+
detail: string;
|
|
416
|
+
features: readonly string[];
|
|
417
|
+
action?: ReactNode;
|
|
418
|
+
};
|
|
419
|
+
type PricingProps = {
|
|
420
|
+
title: string;
|
|
421
|
+
tiers: readonly PricingTier[];
|
|
422
|
+
className?: string;
|
|
423
|
+
};
|
|
424
|
+
/** Renders pricing tiers. The feature list is text, not a color key. */
|
|
425
|
+
declare function Pricing({ title, tiers, className }: PricingProps): react.JSX.Element;
|
|
426
|
+
|
|
427
|
+
type FaqProps = {
|
|
428
|
+
title: string;
|
|
429
|
+
items: readonly AccordionItem[];
|
|
430
|
+
className?: string;
|
|
431
|
+
};
|
|
432
|
+
/** Renders a frequently asked section. */
|
|
433
|
+
declare function Faq({ title, items, className }: FaqProps): react.JSX.Element;
|
|
434
|
+
|
|
435
|
+
type Testimonial = {
|
|
436
|
+
quote: string;
|
|
437
|
+
name: string;
|
|
438
|
+
role: string;
|
|
439
|
+
};
|
|
440
|
+
type TestimonialsProps = {
|
|
441
|
+
title: string;
|
|
442
|
+
quotes: readonly Testimonial[];
|
|
443
|
+
className?: string;
|
|
444
|
+
};
|
|
445
|
+
/** Renders quotations with attribution. */
|
|
446
|
+
declare function Testimonials({ title, quotes, className }: TestimonialsProps): react.JSX.Element;
|
|
447
|
+
|
|
448
|
+
type ContactFormProps = {
|
|
449
|
+
action?: string;
|
|
450
|
+
onSubmit?: (event: FormEvent<HTMLFormElement>) => void;
|
|
451
|
+
className?: string;
|
|
452
|
+
};
|
|
453
|
+
/** Renders a contact form. Submit stays on the page unless the caller handles it. */
|
|
454
|
+
declare function ContactForm({ action, onSubmit, className }: ContactFormProps): react.JSX.Element;
|
|
455
|
+
|
|
456
|
+
export { Accordion, type AccordionItem, type AccordionProps, Alert, type AlertProps, Avatar, type AvatarProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Code, type CodeProps, type CodeTag, ContactForm, type ContactFormProps, Dialog, type DialogProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Faq, type FaqProps, type FeatureItem, Features, type FeaturesProps, Field, type FieldProps, Footer, type FooterProps, Heading, type HeadingProps, type HeadingTag, Hero, type HeroProps, Input, type InputProps, Link, type LinkProps, type LinkVariant, List, type ListProps, type ListTag, Menu, type MenuItem, type MenuProps, Navbar, type NavbarLink, type NavbarProps, Pagination, type PaginationProps, Paragraph, type ParagraphProps, type ParagraphTag, Pill, type PillProps, type PillTone, Pricing, type PricingProps, type PricingTier, Progress, type ProgressProps, Quote, type QuoteProps, type QuoteTag, Radio, type RadioProps, Select, type SelectProps, Slider, type SliderProps, Spinner, type SpinnerProps, Stat, type StatProps, Switch, type SwitchProps, type TabItem, Table, type TableProps, Tabs, type TabsProps, type Testimonial, Testimonials, type TestimonialsProps, Text, type TextProps, type TextTag, Textarea, type TextareaProps, Toast, type ToastProps, codeScale, getTheme, headingScale, listScale, paragraphScale, pillToneClass, pillTones, quoteScale, setTheme, textScale };
|