@argon8/react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,16 @@
1
- # Temporary Holding Version
1
+ # @argon8/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The React components of the Argon8 apps, styled with Tailwind 4 on [`@argon8/tokens`](https://www.npmjs.com/package/@argon8/tokens).
4
+ React 19; no inline styles, so they run under a strict Content Security Policy.
5
+
6
+ ```css
7
+ @import "tailwindcss";
8
+ @import "@argon8/react/strict.css";
9
+ @import "@argon8/react/styles.css";
10
+ ```
11
+
12
+ ```tsx
13
+ import { Alert, Button, Field, Input, Table } from "@argon8/react";
14
+ ```
15
+
16
+ Apache-2.0. Source and docs: https://github.com/argon8hq/design-system
@@ -0,0 +1,51 @@
1
+ import type { ReactNode } from "react";
2
+ import { type Tone } from "./status.js";
3
+ export declare function Alert({ tone, title, children, className, role, strong, actions, onDismiss, }: {
4
+ tone?: Tone;
5
+ title: ReactNode;
6
+ children?: ReactNode;
7
+ className?: string;
8
+ role?: "alert" | "status";
9
+ strong?: boolean;
10
+ actions?: ReactNode;
11
+ onDismiss?: () => void;
12
+ }): import("react").JSX.Element;
13
+ declare const DETAILS: {
14
+ readonly technical: {
15
+ readonly root: "text-meta text-ink-muted";
16
+ readonly summary: "";
17
+ readonly body: "mt-1 font-mono break-words whitespace-pre-wrap text-ink";
18
+ };
19
+ readonly hint: {
20
+ readonly root: "text-meta text-ink-muted";
21
+ readonly summary: "";
22
+ readonly body: "mt-1 text-body";
23
+ };
24
+ readonly disclosure: {
25
+ readonly root: "text-body text-ink";
26
+ readonly summary: "font-medium";
27
+ readonly body: "mt-2";
28
+ };
29
+ readonly section: {
30
+ readonly root: "text-body text-ink";
31
+ readonly summary: "px-4 py-3 text-meta text-ink-muted [&>strong]:text-section [&>strong]:font-semibold [&>strong]:text-ink";
32
+ readonly body: "";
33
+ };
34
+ };
35
+ /**
36
+ * Something shown on demand, on the native <details>.
37
+ * - `technical` (the default): the second tier of an error, the exact words (Amazon's, the
38
+ * database's), the class and the IDs, in mono for support. The first tier, a plain sentence and
39
+ * what to do, is always visible beside it.
40
+ * - `hint`: a quiet "Show the steps" under something.
41
+ * - `disclosure`: an optional part of a form ("More settings").
42
+ * - `section`: a whole Card that opens; the summary's <strong> is its heading, the rest its meta.
43
+ */
44
+ export declare function Details({ summary, variant, children, className, open, }: {
45
+ summary?: ReactNode;
46
+ variant?: keyof typeof DETAILS;
47
+ children: ReactNode;
48
+ className?: string;
49
+ open?: boolean;
50
+ }): import("react").JSX.Element;
51
+ export {};
package/dist/alert.js ADDED
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from "./button.js";
3
+ import { cn } from "./cn.js";
4
+ import { ToneIcon, toneEdge, toneText, toneTint } from "./status.js";
5
+ // docs/components.md 3.3. A message: what happened, and what to do next (`actions`). Calm by
6
+ // default (the surface with a tone edge); `strong` (tinted, role=alert) only for what stops everything.
7
+ // No toasts: an Alert stays where the thing happened.
8
+ export function Alert({ tone = "info", title, children, className, role, strong, actions, onDismiss, }) {
9
+ return (_jsxs("div", { role: role ?? (strong || tone === "danger" ? "alert" : "status"), "data-tone": tone, "data-strong": strong ? "" : undefined, className: cn("flex items-start gap-2.5 rounded-control border px-4 py-3 text-body", strong ? toneTint(tone) : cn("border-l-4 border-line bg-surface", toneEdge(tone)), className), children: [_jsx(ToneIcon, { tone: tone, className: "mt-1" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: cn("font-semibold", toneText(tone)), children: title }), children ? _jsx("div", { className: "mt-1 max-w-prose space-y-1 text-ink-muted", children: children }) : null, actions ? _jsx("div", { className: "mt-3 flex flex-wrap gap-2", children: actions }) : null] }), onDismiss ? (_jsx(Button, { variant: "ghost", size: "sm", "aria-label": "Dismiss", onClick: onDismiss, className: "-my-1 -mr-2 px-2", children: "\u00D7" })) : null] }));
10
+ }
11
+ const DETAILS = {
12
+ technical: { root: "text-meta text-ink-muted", summary: "", body: "mt-1 font-mono break-words whitespace-pre-wrap text-ink" },
13
+ hint: { root: "text-meta text-ink-muted", summary: "", body: "mt-1 text-body" },
14
+ disclosure: { root: "text-body text-ink", summary: "font-medium", body: "mt-2" },
15
+ section: { root: "text-body text-ink", summary: "px-4 py-3 text-meta text-ink-muted [&>strong]:text-section [&>strong]:font-semibold [&>strong]:text-ink", body: "" },
16
+ };
17
+ /**
18
+ * Something shown on demand, on the native <details>.
19
+ * - `technical` (the default): the second tier of an error, the exact words (Amazon's, the
20
+ * database's), the class and the IDs, in mono for support. The first tier, a plain sentence and
21
+ * what to do, is always visible beside it.
22
+ * - `hint`: a quiet "Show the steps" under something.
23
+ * - `disclosure`: an optional part of a form ("More settings").
24
+ * - `section`: a whole Card that opens; the summary's <strong> is its heading, the rest its meta.
25
+ */
26
+ export function Details({ summary = "Technical detail", variant = "technical", children, className, open, }) {
27
+ const v = DETAILS[variant];
28
+ return (_jsxs("details", { open: open || undefined, "data-variant": variant, className: cn("group", v.root, className), children: [_jsx("summary", { className: cn("w-fit cursor-pointer rounded-tag select-none hover:text-ink", v.summary), children: summary }), _jsx("div", { className: v.body, children: children })] }));
29
+ }
@@ -0,0 +1,20 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import { type ComponentProps, type ReactNode } from "react";
3
+ export declare const buttonVariants: (props?: ({
4
+ variant?: "link" | "primary" | "secondary" | "ghost" | "destructive" | null | undefined;
5
+ size?: "sm" | "md" | "lg" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ export declare function Spinner({ className, label }: {
8
+ className?: string;
9
+ label?: string;
10
+ }): import("react").JSX.Element;
11
+ export type ButtonProps = Omit<ComponentProps<"button">, "children"> & VariantProps<typeof buttonVariants> & {
12
+ children?: ReactNode;
13
+ /** Working: busy, ignores clicks, keeps its width. */
14
+ pending?: boolean;
15
+ /** Temporarily unavailable: the reason, shown beside the button. */
16
+ unavailable?: string;
17
+ iconStart?: ReactNode;
18
+ iconEnd?: ReactNode;
19
+ };
20
+ export declare function Button({ className, variant, size, type, pending, unavailable, iconStart, iconEnd, children, onClick, "aria-describedby": describedBy, ...props }: ButtonProps): import("react").JSX.Element;
package/dist/button.js ADDED
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import { useId } from "react";
4
+ import { cn } from "./cn.js";
5
+ // docs/components.md 3.1. One primary per view. `pending` keeps the label (so the width holds)
6
+ // under a spinner; `unavailable` says why beside the button instead of fading it.
7
+ export const buttonVariants = cva("relative inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-control font-medium transition-colors duration-150 motion-reduce:transition-none disabled:cursor-not-allowed disabled:bg-surface-sunk disabled:text-ink-subtle aria-disabled:cursor-not-allowed", {
8
+ variants: {
9
+ variant: {
10
+ primary: "bg-action text-on-action hover:bg-action-hover",
11
+ secondary: "border border-line-strong bg-surface text-ink hover:bg-surface-hover",
12
+ ghost: "text-ink-muted hover:bg-surface-hover hover:text-ink",
13
+ destructive: "bg-danger-fill text-on-danger hover:bg-danger-fill-hover",
14
+ link: "h-auto px-0 text-accent underline underline-offset-2 hover:text-accent-hover",
15
+ },
16
+ size: {
17
+ sm: "h-control-touch-sm px-2.5 text-meta sm:h-control-sm",
18
+ md: "h-control-touch-md px-3.5 text-body sm:h-control-md",
19
+ lg: "h-control-lg w-full px-4 text-body",
20
+ },
21
+ },
22
+ compoundVariants: [
23
+ { variant: "link", size: ["sm", "md", "lg"], className: "h-auto px-0 sm:h-auto" },
24
+ ],
25
+ defaultVariants: { variant: "primary", size: "md" },
26
+ });
27
+ const UNAVAILABLE = "aria-disabled:bg-surface-sunk aria-disabled:text-ink-subtle aria-disabled:border-line aria-disabled:hover:bg-surface-sunk";
28
+ export function Spinner({ className, label }) {
29
+ return (_jsxs("svg", { "data-spinner": "", viewBox: "0 0 16 16", role: label ? "img" : undefined, "aria-label": label, "aria-hidden": label ? undefined : true, className: cn("size-4 motion-safe:animate-spin", className), children: [_jsx("circle", { cx: "8", cy: "8", r: "6", className: "fill-none stroke-current opacity-25", strokeWidth: "2" }), _jsx("path", { d: "M14 8a6 6 0 0 0-6-6", className: "fill-none stroke-current", strokeWidth: "2", strokeLinecap: "round" })] }));
30
+ }
31
+ export function Button({ className, variant, size, type = "button", pending, unavailable, iconStart, iconEnd, children, onClick, "aria-describedby": describedBy, ...props }) {
32
+ const reasonId = useId();
33
+ const blocked = Boolean(pending || unavailable);
34
+ const click = (e) => {
35
+ if (blocked) {
36
+ e.preventDefault();
37
+ return;
38
+ }
39
+ onClick?.(e);
40
+ };
41
+ const v = variant ?? "primary";
42
+ const s = size ?? "md";
43
+ const button = (_jsxs("button", { type: type, "data-variant": v, "data-size": s, "aria-busy": pending || undefined, "aria-disabled": blocked || undefined, "aria-describedby": unavailable ? cn(reasonId, describedBy) : describedBy, className: cn(buttonVariants({ variant: v, size: s }), unavailable && UNAVAILABLE, className), onClick: click, ...props, children: [_jsxs("span", { className: cn("inline-flex items-center gap-1.5", pending && "invisible"), children: [iconStart, children, iconEnd] }), pending ? (_jsx("span", { className: "absolute inset-0 inline-flex items-center justify-center", children: _jsx(Spinner, {}) })) : null] }));
44
+ if (!unavailable)
45
+ return button;
46
+ return (_jsxs("span", { className: "inline-flex flex-wrap items-center gap-2", children: [button, _jsx("span", { id: reasonId, className: "text-meta text-ink-muted", children: unavailable })] }));
47
+ }
@@ -0,0 +1,53 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ /** A labelled box, with an optional line under the label. */
3
+ export declare function Checkbox({ label, description, className, "aria-describedby": describedBy, ...props }: Omit<ComponentProps<"input">, "type"> & {
4
+ label: ReactNode;
5
+ description?: ReactNode;
6
+ }): import("react").JSX.Element;
7
+ export type Option<V extends string> = {
8
+ value: V;
9
+ label: ReactNode;
10
+ description?: ReactNode;
11
+ };
12
+ /**
13
+ * One of a few choices, stacked with descriptions. Controlled (`value` and `onChange`) or posted
14
+ * with a form (`defaultValue`).
15
+ */
16
+ export declare function RadioGroup<V extends string>({ name, options, value, defaultValue, onChange, disabled, className, }: {
17
+ name: string;
18
+ options: Option<V>[];
19
+ value?: V | null;
20
+ defaultValue?: V;
21
+ onChange?: (v: V) => void;
22
+ disabled?: boolean;
23
+ className?: string;
24
+ }): import("react").JSX.Element;
25
+ /** A group of controls under one legend, with the group's error. */
26
+ export declare function Fieldset({ legend, description, error, children, className }: {
27
+ legend: ReactNode;
28
+ description?: ReactNode;
29
+ error?: ReactNode;
30
+ children: ReactNode;
31
+ className?: string;
32
+ }): import("react").JSX.Element;
33
+ /** An on/off control that says which it is. The label names what it switches. */
34
+ export declare function Switch({ checked, onChange, label, disabled, pending }: {
35
+ checked: boolean;
36
+ onChange: (on: boolean) => void;
37
+ label: string;
38
+ disabled?: boolean;
39
+ pending?: boolean;
40
+ }): import("react").JSX.Element;
41
+ /** A small set of choices side by side (native radios underneath: arrow keys move between them). */
42
+ export declare function Segmented<V extends string>({ name, value, options, onChange, label, className, invalid, }: {
43
+ name: string;
44
+ value: V | null;
45
+ options: {
46
+ value: V;
47
+ label: ReactNode;
48
+ }[];
49
+ onChange: (v: V) => void;
50
+ label: string;
51
+ className?: string;
52
+ invalid?: boolean;
53
+ }): import("react").JSX.Element;
package/dist/choice.js ADDED
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { cn } from "./cn.js";
4
+ // docs/components.md 3.2. Native inputs underneath, so forms post them and arrow keys work.
5
+ /** A labelled box, with an optional line under the label. */
6
+ export function Checkbox({ label, description, className, "aria-describedby": describedBy, ...props }) {
7
+ const id = useId();
8
+ return (_jsxs("label", { className: cn("flex items-start gap-2 text-body text-ink", className), children: [_jsx("input", { type: "checkbox", className: "mt-0.5 size-4 shrink-0 accent-action", ...props, "aria-describedby": cn(description && `${id}-d`, describedBy) || undefined }), _jsxs("span", { children: [label, description ? (_jsx("span", { id: `${id}-d`, className: "block text-meta text-ink-muted", children: description })) : null] })] }));
9
+ }
10
+ /**
11
+ * One of a few choices, stacked with descriptions. Controlled (`value` and `onChange`) or posted
12
+ * with a form (`defaultValue`).
13
+ */
14
+ export function RadioGroup({ name, options, value, defaultValue, onChange, disabled, className, }) {
15
+ const id = useId();
16
+ return (_jsx("div", { className: cn("flex flex-col gap-1.5 text-body", className), children: options.map((o) => (_jsxs("label", { className: "flex items-start gap-2 text-ink", children: [_jsx("input", { type: "radio", name: name, value: o.value, disabled: disabled, className: "mt-0.5 size-4 shrink-0 accent-action", "aria-describedby": o.description ? `${id}-${o.value}` : undefined, ...(value !== undefined ? { checked: value === o.value, onChange: () => onChange?.(o.value) } : { defaultChecked: defaultValue === o.value }) }), _jsxs("span", { children: [o.label, o.description ? (_jsx("span", { id: `${id}-${o.value}`, className: "block text-meta text-ink-muted", children: o.description })) : null] })] }, o.value))) }));
17
+ }
18
+ /** A group of controls under one legend, with the group's error. */
19
+ export function Fieldset({ legend, description, error, children, className }) {
20
+ const id = useId();
21
+ const describedBy = [description ? `${id}-d` : null, error ? `${id}-e` : null].filter(Boolean).join(" ") || undefined;
22
+ return (_jsxs("fieldset", { "aria-describedby": describedBy, className: cn("flex flex-col gap-1.5", className), children: [_jsx("legend", { className: "mb-1 text-body font-medium text-ink", children: legend }), description ? (_jsx("p", { id: `${id}-d`, className: "text-meta text-ink-muted", children: description })) : null, children, error ? (_jsx("p", { id: `${id}-e`, role: "alert", className: "text-meta font-medium text-danger", children: error })) : null] }));
23
+ }
24
+ /** An on/off control that says which it is. The label names what it switches. */
25
+ export function Switch({ checked, onChange, label, disabled, pending }) {
26
+ return (_jsxs("button", { type: "button", role: "switch", "aria-checked": checked, "aria-label": label, "aria-busy": pending || undefined, disabled: disabled, onClick: () => !pending && onChange(!checked), className: "group inline-flex items-center gap-2 rounded-control py-1 text-meta font-medium text-ink-muted disabled:cursor-not-allowed disabled:text-ink-subtle", children: [_jsx("span", { "aria-hidden": true, className: cn("relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors duration-150 motion-reduce:transition-none group-disabled:bg-surface-sunk", checked ? "bg-action" : "bg-line-strong"), children: _jsx("span", { className: cn("absolute left-0.5 size-4 rounded-full bg-surface shadow-float transition-transform duration-150 motion-reduce:transition-none", checked && "translate-x-4") }) }), _jsx("span", { "aria-hidden": true, children: checked ? "On" : "Off" })] }));
27
+ }
28
+ /** A small set of choices side by side (native radios underneath: arrow keys move between them). */
29
+ export function Segmented({ name, value, options, onChange, label, className, invalid, }) {
30
+ return (_jsx("div", { role: "radiogroup", "aria-label": label, "aria-invalid": invalid || undefined, className: cn("inline-flex overflow-hidden rounded-control border bg-surface text-body", invalid ? "border-danger-solid" : "border-line-strong", className), children: options.map((o, i) => (_jsxs("label", { className: cn("relative flex h-control-touch-md cursor-pointer items-center px-3 whitespace-nowrap select-none sm:h-control-md has-[:focus-visible]:outline-2 has-[:focus-visible]:-outline-offset-2 has-[:focus-visible]:outline-accent", i > 0 && "border-l border-line-strong", value === o.value ? "bg-action text-on-action" : "text-ink hover:bg-surface-hover"), children: [_jsx("input", { type: "radio", name: name, value: o.value, checked: value === o.value, onChange: () => onChange(o.value), className: "sr-only" }), o.label] }, o.value))) }));
31
+ }
package/dist/cn.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
package/dist/cn.js ADDED
@@ -0,0 +1,14 @@
1
+ import { clsx } from "clsx";
2
+ import { extendTailwindMerge } from "tailwind-merge";
3
+ // The token utilities (@argon8/tokens) are colours and sizes tailwind-merge does not know by name;
4
+ // told here, `cn("text-muted", "text-sm")` keeps both and `cn("bg-surface", "bg-action")` keeps the last.
5
+ const merge = extendTailwindMerge({
6
+ extend: {
7
+ classGroups: {
8
+ "font-size": [{ text: ["meta", "body", "section", "prose", "mono", "page", "figure"] }],
9
+ },
10
+ },
11
+ });
12
+ export function cn(...inputs) {
13
+ return merge(clsx(inputs));
14
+ }
package/dist/code.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from "react";
2
+ /** Copies a text and says so for two seconds (announced); on refusal, says to select it instead. */
3
+ export declare function CopyButton({ text, label, copiedLabel, className, variant, "aria-label": ariaLabel, }: {
4
+ text: string;
5
+ label?: string;
6
+ copiedLabel?: string;
7
+ className?: string;
8
+ variant?: "secondary" | "ghost";
9
+ "aria-label"?: string;
10
+ }): import("react").JSX.Element;
11
+ /**
12
+ * Code, a command, an ID. Inline by default; `block` is a dark panel for a command to run, with a
13
+ * Copy button when `copy` is set. `wrap` breaks long IDs and paths instead of scrolling.
14
+ */
15
+ export declare function Code({ children, block, copy, wrap, className, ...rest }: {
16
+ children: ReactNode;
17
+ block?: boolean;
18
+ copy?: string;
19
+ wrap?: boolean;
20
+ className?: string;
21
+ "data-testid"?: string;
22
+ }): import("react").JSX.Element;
package/dist/code.js ADDED
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { Button } from "./button.js";
4
+ import { cn } from "./cn.js";
5
+ // docs/components.md 3.1 and 3.4.
6
+ /** Copies a text and says so for two seconds (announced); on refusal, says to select it instead. */
7
+ export function CopyButton({ text, label = "Copy", copiedLabel = "Copied", className, variant = "secondary", "aria-label": ariaLabel, }) {
8
+ const [state, setState] = useState("idle");
9
+ const timer = useRef(null);
10
+ useEffect(() => () => {
11
+ if (timer.current)
12
+ clearTimeout(timer.current);
13
+ }, []);
14
+ async function copy() {
15
+ try {
16
+ await navigator.clipboard.writeText(text);
17
+ setState("copied");
18
+ }
19
+ catch {
20
+ setState("failed");
21
+ }
22
+ if (timer.current)
23
+ clearTimeout(timer.current);
24
+ timer.current = setTimeout(() => setState("idle"), 2000);
25
+ }
26
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", variant: variant, onClick: copy, className: className, "aria-label": ariaLabel, children: state === "copied" ? copiedLabel : label }), _jsx("span", { role: "status", className: "sr-only", children: state === "copied" ? copiedLabel : state === "failed" ? "Could not copy: select the text and copy it yourself." : "" })] }));
27
+ }
28
+ /**
29
+ * Code, a command, an ID. Inline by default; `block` is a dark panel for a command to run, with a
30
+ * Copy button when `copy` is set. `wrap` breaks long IDs and paths instead of scrolling.
31
+ */
32
+ export function Code({ children, block, copy, wrap, className, ...rest }) {
33
+ if (!block) {
34
+ return (_jsx("code", { className: cn("rounded-tag bg-surface-sunk px-1 py-px font-mono text-mono text-ink", wrap && "break-all", className), ...rest, children: children }));
35
+ }
36
+ const pre = (_jsx("pre", { className: cn("min-w-0 flex-1 overflow-x-auto rounded-control bg-ink px-3 py-2 font-mono text-mono text-surface", wrap && "break-all whitespace-pre-wrap", !copy && className), ...rest, children: _jsx("code", { children: children }) }));
37
+ if (!copy)
38
+ return pre;
39
+ return (_jsxs("div", { className: cn("flex items-start gap-2", className), children: [pre, _jsx(CopyButton, { text: copy })] }));
40
+ }
@@ -0,0 +1,39 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ /** The surface a Section's table, list or form sits on. */
3
+ export declare function Panel({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
4
+ export declare function Card({ className, ...props }: ComponentProps<"section">): import("react").JSX.Element;
5
+ export declare function CardHeader({ title, description, actions, className, id }: {
6
+ title: ReactNode;
7
+ description?: ReactNode;
8
+ actions?: ReactNode;
9
+ className?: string;
10
+ id?: string;
11
+ }): import("react").JSX.Element;
12
+ export declare function CardBody({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
13
+ /** A titled part of a page with no box around it. */
14
+ export declare function Section({ title, description, actions, children, className, id }: {
15
+ title: ReactNode;
16
+ description?: ReactNode;
17
+ actions?: ReactNode;
18
+ children: ReactNode;
19
+ className?: string;
20
+ id?: string;
21
+ }): import("react").JSX.Element;
22
+ /** What fills a place and what makes it appear: one action, left-aligned. `boxed` when it stands alone on a page. */
23
+ export declare function EmptyState({ title, children, action, boxed, className }: {
24
+ title: ReactNode;
25
+ children?: ReactNode;
26
+ action?: ReactNode;
27
+ boxed?: boolean;
28
+ className?: string;
29
+ }): import("react").JSX.Element;
30
+ /** A page or a part still loading: one calm sentence in the page's own frame, with its height reserved. No shimmer. */
31
+ export declare function LoadingState({ label, className }: {
32
+ label: ReactNode;
33
+ className?: string;
34
+ }): import("react").JSX.Element;
35
+ /** Two columns of facts (one on a phone). An absent value reads "none". */
36
+ export declare function KeyValues({ items, className }: {
37
+ items: [ReactNode, ReactNode][];
38
+ className?: string;
39
+ }): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { cn } from "./cn.js";
4
+ // docs/components.md 3.5. The box goes on what holds the content (a table, a form), not around
5
+ // a whole section: Panel is that box, Card is a Panel with a header, Section is a heading with no box.
6
+ /** The surface a Section's table, list or form sits on. */
7
+ export function Panel({ className, ...props }) {
8
+ return _jsx("div", { className: cn("rounded-control border border-line bg-surface", className), ...props });
9
+ }
10
+ export function Card({ className, ...props }) {
11
+ return _jsx("section", { className: cn("rounded-control border border-line bg-surface", className), ...props });
12
+ }
13
+ export function CardHeader({ title, description, actions, className, id }) {
14
+ return (_jsxs("div", { className: cn("flex flex-wrap items-start justify-between gap-2 border-b border-line px-4 py-3", className), children: [_jsxs("div", { children: [_jsx("h2", { id: id, className: "text-section font-semibold text-ink", children: title }), description ? _jsx("p", { className: "mt-0.5 max-w-prose text-meta text-ink-muted", children: description }) : null] }), actions ? _jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions }) : null] }));
15
+ }
16
+ export function CardBody({ className, ...props }) {
17
+ return _jsx("div", { className: cn("px-4 py-3", className), ...props });
18
+ }
19
+ /** A titled part of a page with no box around it. */
20
+ export function Section({ title, description, actions, children, className, id }) {
21
+ const hid = useId();
22
+ return (_jsxs("section", { "aria-labelledby": hid, id: id, className: cn("scroll-mt-4 space-y-2", className), children: [_jsxs("div", { className: "flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1", children: [_jsxs("div", { children: [_jsx("h2", { id: hid, className: "text-section font-semibold text-ink", children: title }), description ? _jsx("p", { className: "max-w-prose text-meta text-ink-muted", children: description }) : null] }), actions ? _jsx("div", { className: "flex flex-wrap items-center gap-2 text-body", children: actions }) : null] }), children] }));
23
+ }
24
+ // docs/components.md 3.8.
25
+ /** What fills a place and what makes it appear: one action, left-aligned. `boxed` when it stands alone on a page. */
26
+ export function EmptyState({ title, children, action, boxed, className }) {
27
+ return (_jsxs("div", { className: cn("px-4 py-6 text-body", boxed && "rounded-control border border-dashed border-line-strong bg-surface", className), children: [_jsx("p", { className: "font-medium text-ink", children: title }), children ? _jsx("div", { className: "mt-1 max-w-prose text-ink-muted", children: children }) : null, action ? _jsx("div", { className: "mt-3 flex flex-wrap gap-2", children: action }) : null] }));
28
+ }
29
+ /** A page or a part still loading: one calm sentence in the page's own frame, with its height reserved. No shimmer. */
30
+ export function LoadingState({ label, className }) {
31
+ return (_jsx("p", { role: "status", className: cn("min-h-40 text-body text-ink-muted", className), children: label }));
32
+ }
33
+ /** Two columns of facts (one on a phone). An absent value reads "none". */
34
+ export function KeyValues({ items, className }) {
35
+ return (_jsx("dl", { className: cn("grid grid-cols-1 gap-x-6 gap-y-2 text-body sm:grid-cols-[max-content_1fr]", className), children: items.map(([k, v], i) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-meta font-medium text-ink-muted sm:pt-0.5", children: k }), _jsx("dd", { className: "min-w-0 tabular-nums", children: v ?? _jsx("span", { className: "text-ink-subtle", children: "none" }) })] }, i))) }));
36
+ }