@six-vallees/ui-react 0.4.0 → 0.6.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/README.md +3 -3
- package/dist/avatar/avatar.d.ts +30 -0
- package/dist/avatar/avatar.js +11 -0
- package/dist/avatar/avatar.js.map +1 -0
- package/dist/badge/badge.d.ts +32 -0
- package/dist/badge/badge.js +10 -0
- package/dist/badge/badge.js.map +1 -0
- package/dist/charts/bar-chart.js +2 -2
- package/dist/charts/lib/series.d.ts +4 -2
- package/dist/charts/lib/series.js +1 -1
- package/dist/charts/line-chart.js +2 -2
- package/dist/charts/ring.d.ts +1 -1
- package/dist/charts/ring.js +2 -2
- package/dist/charts/segmented-bar.js +2 -2
- package/dist/chunk-BYZCFI7X.js +32 -0
- package/dist/chunk-BYZCFI7X.js.map +1 -0
- package/dist/{chunk-OHY4VIKZ.js → chunk-CZ3JB37A.js} +3 -4
- package/dist/chunk-CZ3JB37A.js.map +1 -0
- package/dist/chunk-DCKWB3EY.js +35 -0
- package/dist/chunk-DCKWB3EY.js.map +1 -0
- package/dist/{chunk-TI5GM4IR.js → chunk-G2XJK244.js} +7 -7
- package/dist/{chunk-TI5GM4IR.js.map → chunk-G2XJK244.js.map} +1 -1
- package/dist/chunk-GNHNTI5A.js +30 -0
- package/dist/chunk-GNHNTI5A.js.map +1 -0
- package/dist/chunk-HHUI32DT.js +36 -0
- package/dist/chunk-HHUI32DT.js.map +1 -0
- package/dist/chunk-OVF2VS3L.js +42 -0
- package/dist/chunk-OVF2VS3L.js.map +1 -0
- package/dist/{chunk-N2DFXOTF.js → chunk-OWIUMX76.js} +2 -2
- package/dist/chunk-POUL3ZTV.js +60 -0
- package/dist/chunk-POUL3ZTV.js.map +1 -0
- package/dist/chunk-R7BM6J75.js +93 -0
- package/dist/chunk-R7BM6J75.js.map +1 -0
- package/dist/chunk-RXDJPRH5.js +39 -0
- package/dist/chunk-RXDJPRH5.js.map +1 -0
- package/dist/{chunk-PIFHG2WO.js → chunk-S4HVXD6Z.js} +8 -6
- package/dist/chunk-S4HVXD6Z.js.map +1 -0
- package/dist/chunk-ULEDFFUJ.js +43 -0
- package/dist/chunk-ULEDFFUJ.js.map +1 -0
- package/dist/chunk-WHD5CSTB.js +52 -0
- package/dist/chunk-WHD5CSTB.js.map +1 -0
- package/dist/chunk-WHJ4JVO6.js +39 -0
- package/dist/chunk-WHJ4JVO6.js.map +1 -0
- package/dist/{chunk-65VQL6R2.js → chunk-YX6MSLUB.js} +2 -2
- package/dist/chunk-YX6MSLUB.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +118 -12
- package/dist/input/input.d.ts +22 -0
- package/dist/input/input.js +8 -0
- package/dist/input/input.js.map +1 -0
- package/dist/input/label.d.ts +32 -0
- package/dist/input/label.js +11 -0
- package/dist/input/label.js.map +1 -0
- package/dist/input/textarea.d.ts +13 -0
- package/dist/input/textarea.js +8 -0
- package/dist/input/textarea.js.map +1 -0
- package/dist/overlay/alert-dialog.d.ts +42 -0
- package/dist/overlay/alert-dialog.js +23 -0
- package/dist/overlay/alert-dialog.js.map +1 -0
- package/dist/overlay/popover.d.ts +42 -0
- package/dist/overlay/popover.js +17 -0
- package/dist/overlay/popover.js.map +1 -0
- package/dist/overlay/sheet.d.ts +47 -0
- package/dist/overlay/sheet.js +29 -0
- package/dist/overlay/sheet.js.map +1 -0
- package/dist/overlay/tooltip.d.ts +31 -0
- package/dist/overlay/tooltip.js +15 -0
- package/dist/overlay/tooltip.js.map +1 -0
- package/dist/tabs/tabs.d.ts +24 -0
- package/dist/tabs/tabs.js +15 -0
- package/dist/tabs/tabs.js.map +1 -0
- package/dist/tabs/toggle-group.d.ts +19 -0
- package/dist/tabs/toggle-group.js +11 -0
- package/dist/tabs/toggle-group.js.map +1 -0
- package/package.json +9 -1
- package/dist/chunk-65VQL6R2.js.map +0 -1
- package/dist/chunk-OHY4VIKZ.js.map +0 -1
- package/dist/chunk-PIFHG2WO.js.map +0 -1
- /package/dist/{chunk-N2DFXOTF.js.map → chunk-OWIUMX76.js.map} +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cairn Label. Radix, for one reason that is not styling.
|
|
6
|
+
*
|
|
7
|
+
* A plain `<label htmlFor>` works until the control is a composite — a Radix
|
|
8
|
+
* select, a toggle group, anything that is not a single native element — and
|
|
9
|
+
* then the association silently stops working. Radix's Label also stops the
|
|
10
|
+
* text-selection-on-double-click that makes a form feel broken. That is
|
|
11
|
+
* behaviour, so it is a dependency; the styling below is the whole of our part.
|
|
12
|
+
*
|
|
13
|
+
* The `label` type role, neutral ink on `on-surface-variant`: a label is
|
|
14
|
+
* supporting text and its tone says so. It is never coloured (rule 1) and never
|
|
15
|
+
* set in caps (rule 6) — the pill badge is the one sanctioned kicker.
|
|
16
|
+
*/
|
|
17
|
+
type LabelProps = React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>;
|
|
18
|
+
declare const Label: React.ForwardRefExoticComponent<Omit<LabelPrimitive.LabelProps & React.RefAttributes<HTMLLabelElement>, "ref"> & React.RefAttributes<HTMLLabelElement>>;
|
|
19
|
+
/**
|
|
20
|
+
* A labelled control in one call: the two are wired by a generated id, so a
|
|
21
|
+
* consumer cannot forget the `htmlFor`/`id` pair — the most common way an
|
|
22
|
+
* accessible form stops being one.
|
|
23
|
+
*/
|
|
24
|
+
interface FieldProps {
|
|
25
|
+
label: React.ReactNode;
|
|
26
|
+
/** Receives the generated id; render your control with it. */
|
|
27
|
+
children: (id: string) => React.ReactNode;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
declare function Field({ label, children, className }: FieldProps): React.JSX.Element;
|
|
31
|
+
|
|
32
|
+
export { Field, type FieldProps, Label, type LabelProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cairn Textarea. `Input`'s multi-line sibling, same tokens, same radius role.
|
|
5
|
+
*
|
|
6
|
+
* Resize is left to the browser (`resize-y` only): a horizontally resizable
|
|
7
|
+
* field breaks the column it sits in, and a field that cannot grow at all
|
|
8
|
+
* forces the writer to compose inside a slot.
|
|
9
|
+
*/
|
|
10
|
+
type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
11
|
+
declare const Textarea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
12
|
+
|
|
13
|
+
export { Textarea, type TextareaProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cairn AlertDialog. For the one question you cannot take back.
|
|
6
|
+
*
|
|
7
|
+
* Not a Dialog with different copy. `alertdialog` is its own role: it is
|
|
8
|
+
* announced as an interruption, it is always modal, and focus lands on the
|
|
9
|
+
* safest control rather than the first one — so an accidental Enter cancels
|
|
10
|
+
* instead of destroying. Radix carries that; a Dialog styled to look urgent
|
|
11
|
+
* carries none of it.
|
|
12
|
+
*
|
|
13
|
+
* Use it only where the action is irreversible. A confirmation on a reversible
|
|
14
|
+
* action is a toll booth: it teaches people to click through dialogs, and the
|
|
15
|
+
* one that mattered gets clicked through too.
|
|
16
|
+
*
|
|
17
|
+
* The destructive action is a `danger` Button passed through `asChild`. Danger
|
|
18
|
+
* is a message colour with its own AA-paired ink (rule 4) — it is not the
|
|
19
|
+
* signature accent, and `main` must never stand in for it (rule 3).
|
|
20
|
+
*/
|
|
21
|
+
declare const AlertDialog: React.FC<AlertDialogPrimitive.AlertDialogProps>;
|
|
22
|
+
declare const AlertDialogTrigger: React.ForwardRefExoticComponent<AlertDialogPrimitive.AlertDialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
23
|
+
declare const AlertDialogAction: React.ForwardRefExoticComponent<AlertDialogPrimitive.AlertDialogActionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
24
|
+
declare const AlertDialogCancel: React.ForwardRefExoticComponent<AlertDialogPrimitive.AlertDialogCancelProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
interface AlertDialogContentProps extends React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> {
|
|
26
|
+
/** Where the portal mounts. Defaults to `document.body`. See `PopoverContent`. */
|
|
27
|
+
container?: HTMLElement | null;
|
|
28
|
+
/**
|
|
29
|
+
* Classes for the scrim.
|
|
30
|
+
*
|
|
31
|
+
* Exists so the scrim can be raised with the panel. Lifting only the content's
|
|
32
|
+
* z-index leaves the dim layer stranded below whatever it was meant to cover —
|
|
33
|
+
* the dialog reads as urgent while the page behind it stays bright.
|
|
34
|
+
*/
|
|
35
|
+
overlayClassName?: string;
|
|
36
|
+
}
|
|
37
|
+
declare const AlertDialogContent: React.ForwardRefExoticComponent<AlertDialogContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
38
|
+
declare const AlertDialogTitle: React.ForwardRefExoticComponent<Omit<AlertDialogPrimitive.AlertDialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
39
|
+
declare const AlertDialogDescription: React.ForwardRefExoticComponent<Omit<AlertDialogPrimitive.AlertDialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
40
|
+
declare const AlertDialogFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
|
|
42
|
+
export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, type AlertDialogContentProps, AlertDialogDescription, AlertDialogFooter, AlertDialogTitle, AlertDialogTrigger };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
AlertDialog,
|
|
4
|
+
AlertDialogAction,
|
|
5
|
+
AlertDialogCancel,
|
|
6
|
+
AlertDialogContent,
|
|
7
|
+
AlertDialogDescription,
|
|
8
|
+
AlertDialogFooter,
|
|
9
|
+
AlertDialogTitle,
|
|
10
|
+
AlertDialogTrigger
|
|
11
|
+
} from "../chunk-POUL3ZTV.js";
|
|
12
|
+
import "../chunk-DXRY7AS4.js";
|
|
13
|
+
export {
|
|
14
|
+
AlertDialog,
|
|
15
|
+
AlertDialogAction,
|
|
16
|
+
AlertDialogCancel,
|
|
17
|
+
AlertDialogContent,
|
|
18
|
+
AlertDialogDescription,
|
|
19
|
+
AlertDialogFooter,
|
|
20
|
+
AlertDialogTitle,
|
|
21
|
+
AlertDialogTrigger
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=alert-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cairn Popover. Radix, for the positioning — which is never as simple as it looks.
|
|
6
|
+
*
|
|
7
|
+
* The hand-rolled version is always the same: absolute coordinates, then a
|
|
8
|
+
* `Math.min/max` to keep the card on screen. It works until the trigger is near
|
|
9
|
+
* an edge and the card should flip to the other side, or the page scrolls under
|
|
10
|
+
* it, or the trigger sits inside its own scroll container. Radix's collision
|
|
11
|
+
* handling covers all of that, and brings what the maths never does: focus moves
|
|
12
|
+
* into the panel on open and returns to the trigger on close, Escape dismisses,
|
|
13
|
+
* an outside click dismisses, and the trigger is wired to the panel with
|
|
14
|
+
* `aria-expanded` / `aria-controls`.
|
|
15
|
+
*
|
|
16
|
+
* `Anchor` is exported because a popover does not always hang off a button: a
|
|
17
|
+
* pin dropped on a page has a position but no trigger element.
|
|
18
|
+
*
|
|
19
|
+
* `control` radius, not `card`: the card radius is reserved for feature cards and
|
|
20
|
+
* metric tiles (rule 7). Elevation AND a hairline, deliberately: the shadow
|
|
21
|
+
* carries the lift on the light theme, the hairline is what separates the surface
|
|
22
|
+
* on the dark one, where a black shadow does nothing.
|
|
23
|
+
*/
|
|
24
|
+
declare const Popover: React.FC<PopoverPrimitive.PopoverProps>;
|
|
25
|
+
declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
26
|
+
declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & React.RefAttributes<HTMLDivElement>>;
|
|
27
|
+
declare const PopoverClose: React.ForwardRefExoticComponent<PopoverPrimitive.PopoverCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
28
|
+
interface PopoverContentProps extends React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> {
|
|
29
|
+
/**
|
|
30
|
+
* Where the portal mounts. Defaults to `document.body`.
|
|
31
|
+
*
|
|
32
|
+
* Override it whenever the theme lives on a subtree rather than on the
|
|
33
|
+
* document — a scoped overlay root, a `data-theme` wrapper, a shadow host.
|
|
34
|
+
* Portalled to the body by default, the panel escapes that subtree and renders
|
|
35
|
+
* with none of its tokens: correct behaviour, no styling, and nothing in the
|
|
36
|
+
* console to say why.
|
|
37
|
+
*/
|
|
38
|
+
container?: HTMLElement | null;
|
|
39
|
+
}
|
|
40
|
+
declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
|
|
42
|
+
export { Popover, PopoverAnchor, PopoverClose, PopoverContent, type PopoverContentProps, PopoverTrigger };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Popover,
|
|
4
|
+
PopoverAnchor,
|
|
5
|
+
PopoverClose,
|
|
6
|
+
PopoverContent,
|
|
7
|
+
PopoverTrigger
|
|
8
|
+
} from "../chunk-WHJ4JVO6.js";
|
|
9
|
+
import "../chunk-DXRY7AS4.js";
|
|
10
|
+
export {
|
|
11
|
+
Popover,
|
|
12
|
+
PopoverAnchor,
|
|
13
|
+
PopoverClose,
|
|
14
|
+
PopoverContent,
|
|
15
|
+
PopoverTrigger
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
4
|
+
import { VariantProps } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cairn Sheet. A panel anchored to one edge, on Radix Dialog.
|
|
8
|
+
*
|
|
9
|
+
* The prop that matters is `modal`, and the default here is deliberately the
|
|
10
|
+
* opposite of Radix's. A **modal** sheet takes the page hostage: focus is
|
|
11
|
+
* trapped, everything behind it is inert, and the rest of the screen is dimmed.
|
|
12
|
+
* That is right for a form you must finish. It is wrong for a companion panel —
|
|
13
|
+
* an inspector, a comment thread, a filter rail — where the whole point is to
|
|
14
|
+
* keep working in the page while the panel is open. Ship the modal default and
|
|
15
|
+
* every companion panel in the system becomes a trap.
|
|
16
|
+
*
|
|
17
|
+
* So `modal` defaults to false, and Escape-to-close, the labelled dialog role and
|
|
18
|
+
* the focus return still come from Radix. Pass `modal` explicitly when the panel
|
|
19
|
+
* really must be answered before anything else.
|
|
20
|
+
*
|
|
21
|
+
* A `Title` is not optional. Radix warns when one is missing, and it is right to:
|
|
22
|
+
* a dialog with no accessible name is announced as "dialog", which tells the user
|
|
23
|
+
* nothing. Use `SheetTitle` — wrap it in `sr-only` if the design has no visible
|
|
24
|
+
* heading, never drop it.
|
|
25
|
+
*/
|
|
26
|
+
declare const sheetVariants: (props?: ({
|
|
27
|
+
side?: "right" | "bottom" | "left" | null | undefined;
|
|
28
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
29
|
+
declare const Sheet: React.FC<DialogPrimitive.DialogProps>;
|
|
30
|
+
declare const SheetTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
31
|
+
declare const SheetClose: React.ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
declare const SheetPortal: React.FC<DialogPrimitive.DialogPortalProps>;
|
|
33
|
+
interface SheetContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, VariantProps<typeof sheetVariants> {
|
|
34
|
+
side?: 'right' | 'left' | 'bottom';
|
|
35
|
+
/** Dim and inert the page behind. Only for a panel that must be answered. */
|
|
36
|
+
overlay?: boolean;
|
|
37
|
+
/** Where the portal mounts. Defaults to `document.body`. See `PopoverContent`. */
|
|
38
|
+
container?: HTMLElement | null;
|
|
39
|
+
}
|
|
40
|
+
declare const SheetContent: React.ForwardRefExoticComponent<SheetContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
declare const SheetHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
42
|
+
declare const SheetBody: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
43
|
+
declare const SheetFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
44
|
+
declare const SheetTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
|
|
45
|
+
declare const SheetDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
46
|
+
|
|
47
|
+
export { Sheet, SheetBody, SheetClose, SheetContent, type SheetContentProps, SheetDescription, SheetFooter, SheetHeader, SheetPortal, SheetTitle, SheetTrigger, sheetVariants };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Sheet,
|
|
4
|
+
SheetBody,
|
|
5
|
+
SheetClose,
|
|
6
|
+
SheetContent,
|
|
7
|
+
SheetDescription,
|
|
8
|
+
SheetFooter,
|
|
9
|
+
SheetHeader,
|
|
10
|
+
SheetPortal,
|
|
11
|
+
SheetTitle,
|
|
12
|
+
SheetTrigger,
|
|
13
|
+
sheetVariants
|
|
14
|
+
} from "../chunk-R7BM6J75.js";
|
|
15
|
+
import "../chunk-DXRY7AS4.js";
|
|
16
|
+
export {
|
|
17
|
+
Sheet,
|
|
18
|
+
SheetBody,
|
|
19
|
+
SheetClose,
|
|
20
|
+
SheetContent,
|
|
21
|
+
SheetDescription,
|
|
22
|
+
SheetFooter,
|
|
23
|
+
SheetHeader,
|
|
24
|
+
SheetPortal,
|
|
25
|
+
SheetTitle,
|
|
26
|
+
SheetTrigger,
|
|
27
|
+
sheetVariants
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=sheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cairn Tooltip. Radix, because the `title` attribute is not an accessible
|
|
6
|
+
* alternative to one.
|
|
7
|
+
*
|
|
8
|
+
* `title` looks like the free version of a tooltip and behaves like nothing at
|
|
9
|
+
* all: it never appears on keyboard focus, most screen readers ignore or
|
|
10
|
+
* duplicate it, it cannot be dismissed, and its delay belongs to the operating
|
|
11
|
+
* system. Any information a sighted mouse user gets from it is information a
|
|
12
|
+
* keyboard user does not get. Radix gives focus and hover parity, Escape to
|
|
13
|
+
* dismiss, and a real `aria-describedby` link.
|
|
14
|
+
*
|
|
15
|
+
* The rule that survives all of it: a tooltip may only ever carry information
|
|
16
|
+
* that is *supplementary*. If the interface does not make sense without it, the
|
|
17
|
+
* text belongs on the surface (rule 4 — meaning never rests on a hover).
|
|
18
|
+
*
|
|
19
|
+
* Inverse surface, not a hue: a tooltip is a small dense mark and the inverse
|
|
20
|
+
* pairing is the one that reads at that size on both themes.
|
|
21
|
+
*/
|
|
22
|
+
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
23
|
+
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
24
|
+
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
25
|
+
interface TooltipContentProps extends React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> {
|
|
26
|
+
/** Where the portal mounts. Defaults to `document.body`. See `PopoverContent`. */
|
|
27
|
+
container?: HTMLElement | null;
|
|
28
|
+
}
|
|
29
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<TooltipContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
|
|
31
|
+
export { Tooltip, TooltipContent, type TooltipContentProps, TooltipProvider, TooltipTrigger };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Tooltip,
|
|
4
|
+
TooltipContent,
|
|
5
|
+
TooltipProvider,
|
|
6
|
+
TooltipTrigger
|
|
7
|
+
} from "../chunk-DCKWB3EY.js";
|
|
8
|
+
import "../chunk-DXRY7AS4.js";
|
|
9
|
+
export {
|
|
10
|
+
Tooltip,
|
|
11
|
+
TooltipContent,
|
|
12
|
+
TooltipProvider,
|
|
13
|
+
TooltipTrigger
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cairn Tabs. Radix, and this one is not negotiable.
|
|
6
|
+
*
|
|
7
|
+
* `role="tablist"` on a row of buttons is the most common accessibility lie in a
|
|
8
|
+
* codebase: it announces a tab list to a screen reader and then ships none of
|
|
9
|
+
* the behaviour that word promises — a single tab stop for the whole set, arrow
|
|
10
|
+
* keys to move between tabs, Home/End, and the selected tab bound to its panel
|
|
11
|
+
* by id. Writing the role without the behaviour is worse than writing no role at
|
|
12
|
+
* all, because it tells the user a lie they will act on. Radix has all of it.
|
|
13
|
+
*
|
|
14
|
+
* The selected tab is marked by the surface ramp, not by hue and not by an
|
|
15
|
+
* underline: `surface-muted` is the selected step, `surface-subtle` the hover
|
|
16
|
+
* step, exactly as `sv-state` uses them elsewhere. One mechanism for state
|
|
17
|
+
* across the system (BRAND.md, law 5).
|
|
18
|
+
*/
|
|
19
|
+
declare const Tabs: React.ForwardRefExoticComponent<TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
20
|
+
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
22
|
+
declare const TabsContent: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
23
|
+
|
|
24
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Cairn ToggleGroup. A row of mutually exclusive choices that are NOT tabs.
|
|
6
|
+
*
|
|
7
|
+
* The distinction matters and is usually missed: tabs switch which panel you are
|
|
8
|
+
* looking at, a toggle group sets a value. They announce themselves differently
|
|
9
|
+
* (`tablist` vs `group` of pressed buttons) and a screen reader user acts on the
|
|
10
|
+
* difference. Reaching for `Tabs` because the pills look alike is how a status
|
|
11
|
+
* control ends up telling people it will change the view.
|
|
12
|
+
*
|
|
13
|
+
* Radix carries the roving tabindex, the arrow keys and the pressed state; the
|
|
14
|
+
* surface ramp carries the selection, like every other state in the system.
|
|
15
|
+
*/
|
|
16
|
+
declare const ToggleGroup: React.ForwardRefExoticComponent<(Omit<ToggleGroupPrimitive.ToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<ToggleGroupPrimitive.ToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & React.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
declare const ToggleGroupItem: React.ForwardRefExoticComponent<Omit<ToggleGroupPrimitive.ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
|
|
19
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@six-vallees/ui-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Cairn React components — the Six Vallées design system UI, driven by the Cairn tokens.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -29,7 +29,15 @@
|
|
|
29
29
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@radix-ui/react-alert-dialog": "^1.1.23",
|
|
33
|
+
"@radix-ui/react-avatar": "^1.2.6",
|
|
34
|
+
"@radix-ui/react-dialog": "^1.1.23",
|
|
35
|
+
"@radix-ui/react-label": "^2.1.15",
|
|
36
|
+
"@radix-ui/react-popover": "^1.1.23",
|
|
32
37
|
"@radix-ui/react-slot": "^1.1.2",
|
|
38
|
+
"@radix-ui/react-tabs": "^1.1.21",
|
|
39
|
+
"@radix-ui/react-toggle-group": "^1.1.19",
|
|
40
|
+
"@radix-ui/react-tooltip": "^1.2.16",
|
|
33
41
|
"class-variance-authority": "^0.7.1",
|
|
34
42
|
"clsx": "^2.1.1",
|
|
35
43
|
"tailwind-merge": "^3.0.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/ring.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { cn } from '@/lib/utils';\nimport { chartToken, toneFill } from './lib/series';\n\nexport interface RingProps {\n /** Progress, 0-100. */\n value: number;\n /** Outer diameter in px. */\n size?: number;\n /** Ring thickness in px. */\n thickness?: number;\n /** Colour of the filled arc. Defaults to ink; `accent` uses the signature accent. */\n tone?: 'ink' | 'accent';\n /**\n * Explicit arc colour (a token / CSS colour), overrides `tone`. Pass only colours that\n * clear 3:1 against the surface as a thin stroke, ink, blue, or a dark graphite. Acid\n * and mid-gray are fill-only (they fail as a line); see AGENTS.md rule 9.\n */\n color?: string;\n /**\n * Draw a darker keyline under the arc so a light, low-contrast colour (a pale accent step) stays\n * perceptible, the rim carries the 3:1 shape contrast the fill can't (AGENTS.md rule 9).\n * `true` uses ink; pass a colour (e.g. `sys.color.accent-edge`) for a tonal, in-family rim.\n */\n casing?: boolean | string;\n /** Fill the arc from empty on mount. Honours `prefers-reduced-motion`. */\n animate?: boolean;\n /** Centre content, e.g. the value. Omit for a bare ring. */\n children?: React.ReactNode;\n /** Accessible label; falls back to \"<value>%\". */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Cairn Ring, single-value radial progress. Grayscale by default (ink arc on a\n * neutral track); `tone=\"accent\"` opts into the signature accent, or pass an explicit\n * `color`. The arc fills from empty on mount (rounded cap, 12 o'clock, clockwise).\n * Zero-dependency SVG. A client component (`'use client'`): the mount animation uses state;\n * pass `animate={false}` to render it statically.\n */\nexport function Ring({\n value,\n size = 160,\n thickness = 14,\n tone = 'ink',\n color,\n casing = false,\n animate = true,\n children,\n className,\n 'aria-label': ariaLabel,\n}: RingProps) {\n const pct = Math.min(Math.max(Number.isFinite(value) ? value : 0, 0), 100);\n const r = (size - thickness) / 2;\n const c = 2 * Math.PI * r;\n\n // Fill from empty on mount: first client paint is 0, then rAF advances to the value so the\n // CSS transition animates. Under prefers-reduced-motion we jump straight to the value with the\n // transition removed — self-contained, never relying on a global reduced-motion rule existing.\n const [progress, setProgress] = React.useState(animate ? 0 : pct);\n const [instant, setInstant] = React.useState(!animate);\n React.useEffect(() => {\n if (!animate) {\n setProgress(pct);\n return;\n }\n const reduce =\n typeof window !== 'undefined' && window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;\n if (reduce) {\n setInstant(true);\n setProgress(pct);\n return;\n }\n setInstant(false);\n const id = requestAnimationFrame(() => setProgress(pct));\n return () => cancelAnimationFrame(id);\n }, [pct, animate]);\n\n const arc = (progress / 100) * c;\n const motion = instant ? undefined : 'transition-[stroke-dasharray] duration-[900ms] ease-out';\n const stroke = color ?? toneFill(tone);\n return (\n <div\n className={cn('relative inline-grid place-items-center', className)}\n style={{ width: size, height: size }}\n role=\"img\"\n aria-label={ariaLabel ?? `${Math.round(pct)}%`}\n >\n <svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} className=\"rotate-[-90deg]\" aria-hidden=\"true\">\n <circle cx={size / 2} cy={size / 2} r={r} fill=\"none\" stroke={chartToken.track} strokeWidth={thickness} />\n {casing && (\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke={typeof casing === 'string' ? casing : 'var(--sv-sys-color-on-surface)'}\n strokeWidth={thickness + 2}\n strokeLinecap=\"round\"\n strokeDasharray={`${arc} ${c - arc}`}\n className={motion}\n />\n )}\n <circle\n cx={size / 2}\n cy={size / 2}\n r={r}\n fill=\"none\"\n stroke={stroke}\n strokeWidth={thickness}\n strokeLinecap=\"round\"\n strokeDasharray={`${arc} ${c - arc}`}\n className={motion}\n />\n </svg>\n {children != null && <div className=\"absolute inset-0 grid place-items-center\">{children}</div>}\n </div>\n );\n}\nRing.displayName = 'Ring';\n"],"mappings":";;;;;;;;;AAEA,YAAY,WAAW;AAyFjB,SACE,KADF;AAhDC,SAAS,KAAK;AAAA,EACnB;AAAA,EACA,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,OAAO;AAAA,EACP;AAAA,EACA,SAAS;AAAA,EACT,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,cAAc;AAChB,GAAc;AACZ,QAAM,MAAM,KAAK,IAAI,KAAK,IAAI,OAAO,SAAS,KAAK,IAAI,QAAQ,GAAG,CAAC,GAAG,GAAG;AACzE,QAAM,KAAK,OAAO,aAAa;AAC/B,QAAM,IAAI,IAAI,KAAK,KAAK;AAKxB,QAAM,CAAC,UAAU,WAAW,IAAU,eAAS,UAAU,IAAI,GAAG;AAChE,QAAM,CAAC,SAAS,UAAU,IAAU,eAAS,CAAC,OAAO;AACrD,EAAM,gBAAU,MAAM;AACpB,QAAI,CAAC,SAAS;AACZ,kBAAY,GAAG;AACf;AAAA,IACF;AACA,UAAM,SACJ,OAAO,WAAW,eAAe,OAAO,aAAa,kCAAkC,EAAE;AAC3F,QAAI,QAAQ;AACV,iBAAW,IAAI;AACf,kBAAY,GAAG;AACf;AAAA,IACF;AACA,eAAW,KAAK;AAChB,UAAM,KAAK,sBAAsB,MAAM,YAAY,GAAG,CAAC;AACvD,WAAO,MAAM,qBAAqB,EAAE;AAAA,EACtC,GAAG,CAAC,KAAK,OAAO,CAAC;AAEjB,QAAM,MAAO,WAAW,MAAO;AAC/B,QAAM,SAAS,UAAU,SAAY;AACrC,QAAM,SAAS,SAAS,SAAS,IAAI;AACrC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,2CAA2C,SAAS;AAAA,MAClE,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,MACnC,MAAK;AAAA,MACL,cAAY,aAAa,GAAG,KAAK,MAAM,GAAG,CAAC;AAAA,MAE3C;AAAA,6BAAC,SAAI,OAAO,MAAM,QAAQ,MAAM,SAAS,OAAO,IAAI,IAAI,IAAI,IAAI,WAAU,mBAAkB,eAAY,QACtG;AAAA,8BAAC,YAAO,IAAI,OAAO,GAAG,IAAI,OAAO,GAAG,GAAM,MAAK,QAAO,QAAQ,WAAW,OAAO,aAAa,WAAW;AAAA,UACvG,UACC;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,OAAO;AAAA,cACX,IAAI,OAAO;AAAA,cACX;AAAA,cACA,MAAK;AAAA,cACL,QAAQ,OAAO,WAAW,WAAW,SAAS;AAAA,cAC9C,aAAa,YAAY;AAAA,cACzB,eAAc;AAAA,cACd,iBAAiB,GAAG,GAAG,IAAI,IAAI,GAAG;AAAA,cAClC,WAAW;AAAA;AAAA,UACb;AAAA,UAEF;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,OAAO;AAAA,cACX,IAAI,OAAO;AAAA,cACX;AAAA,cACA,MAAK;AAAA,cACL;AAAA,cACA,aAAa;AAAA,cACb,eAAc;AAAA,cACd,iBAAiB,GAAG,GAAG,IAAI,IAAI,GAAG;AAAA,cAClC,WAAW;AAAA;AAAA,UACb;AAAA,WACF;AAAA,QACC,YAAY,QAAQ,oBAAC,SAAI,WAAU,4CAA4C,UAAS;AAAA;AAAA;AAAA,EAC3F;AAEJ;AACA,KAAK,cAAc;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/segmented-bar.tsx"],"sourcesContent":["import { cn } from '@/lib/utils';\nimport {\n categorical, categoricalOn, categoricalNeedsEdge,\n sequential, sequentialOn, sequentialNeedsEdge,\n toneNeedsEdge, markEdge, chartToken,\n} from './lib/series';\n\nexport interface Segment {\n label: string;\n value: number;\n /** Pull this segment forward (ink) and others recede. */\n active?: boolean;\n}\n\nexport interface SegmentedBarProps {\n data: Segment[];\n /** Bar thickness in px. */\n height?: number;\n /**\n * How segments get colour:\n * - `mono` (default): grayscale, active segment is ink, the rest are muted tints.\n * - `categorical`: the capped unordered palette (≤4 meaningful categories).\n * - `sequential`: single-hue magnitude ramp, in data order.\n */\n scale?: 'mono' | 'categorical' | 'sequential';\n /** Show the label + value row beneath the bar. */\n showLegend?: boolean;\n className?: string;\n}\n\n/**\n * Cairn SegmentedBar, a single horizontal bar split into labelled parts (a share-of-total\n * / stacked bar). Grayscale by default; hue is opt-in via `scale`. Every segment carries a\n * text label + value, so meaning never rests on colour alone (WCAG-safe). Zero-dependency.\n */\nexport function SegmentedBar({ data, height = 40, scale = 'mono', showLegend = true, className }: SegmentedBarProps) {\n // Negative / non-finite segment values would produce invalid or overflowing widths; clamp to 0.\n const safe = (v: number) => (Number.isFinite(v) && v > 0 ? v : 0);\n const total = data.reduce((s, d) => s + safe(d.value), 0) || 1;\n const hasActive = data.some((d) => d.active);\n\n const fill = (d: Segment, i: number): string => {\n if (scale === 'categorical') return categorical(i);\n if (scale === 'sequential') return sequential(i, data.length);\n // mono: ink for the active (or all, when none is active), muted tints otherwise.\n if (!hasActive) return chartToken.ink;\n return d.active ? chartToken.ink : chartToken.muted;\n };\n\n // Accessible foreground paired to each fill, WCAG AA, never a blend mode that guesses.\n const onFill = (d: Segment, i: number): string => {\n if (scale === 'categorical') return categoricalOn(i);\n if (scale === 'sequential') return sequentialOn(i, data.length);\n // mono: white on ink fills, ink on the light muted tint.\n if (!hasActive) return 'var(--sv-sys-color-on-primary)';\n return d.active ? 'var(--sv-sys-color-on-primary)' : 'var(--sv-sys-color-on-surface)';\n };\n\n // A keyline only where the fill cannot carry its own 3:1 shape contrast. Dark and saturated\n // segments get none: boxing every segment turns the bar into a table (rule 9, AGENTS.md).\n const edge = (d: Segment, i: number): string | undefined => {\n if (scale === 'categorical') return markEdge(categoricalNeedsEdge(i));\n if (scale === 'sequential') return markEdge(sequentialNeedsEdge(i, data.length));\n return markEdge(toneNeedsEdge(!hasActive || d.active ? 'ink' : 'muted'));\n };\n\n return (\n <div className={cn('w-full', className)}>\n {/* A thin gap separates adjacent segments, so the keyline is not needed for that job: it\n appears only under a pale fill, which cannot carry the 3:1 shape contrast against the\n surface on its own (AGENTS.md rule 9). */}\n <div\n className=\"flex w-full\"\n style={{ height, gap: 2 }}\n role=\"img\"\n aria-label={data.map((d) => `${d.label} ${d.value}`).join(', ')}\n >\n {data.map((d, i) => (\n <div\n key={d.label}\n className=\"flex items-center justify-end px-2 first:rounded-l-control last:rounded-r-control\"\n style={{\n width: `${(safe(d.value) / total) * 100}%`,\n background: fill(d, i),\n boxShadow: edge(d, i),\n }}\n >\n <span className=\"truncate sv-body-xs font-medium tabular-nums\" style={{ color: onFill(d, i) }}>{d.value}</span>\n </div>\n ))}\n </div>\n {showLegend && (\n <ul className=\"mt-3 flex flex-wrap gap-x-4 gap-y-1\">\n {data.map((d, i) => (\n <li key={d.label} className={cn('flex items-center gap-1.5 sv-body-sm', d.active ? 'text-on-surface' : 'text-on-surface-variant')}>\n <span className=\"size-2 shrink-0 rounded-swatch\" style={{ background: fill(d, i) }} aria-hidden=\"true\" />\n {d.label}\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n}\nSegmentedBar.displayName = 'SegmentedBar';\n"],"mappings":";;;;;;;;;;;;;;;;AAuFY,cAOA,YAPA;AApDL,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,QAAQ,QAAQ,aAAa,MAAM,UAAU,GAAsB;AAEnH,QAAM,OAAO,CAAC,MAAe,OAAO,SAAS,CAAC,KAAK,IAAI,IAAI,IAAI;AAC/D,QAAM,QAAQ,KAAK,OAAO,CAAC,GAAG,MAAM,IAAI,KAAK,EAAE,KAAK,GAAG,CAAC,KAAK;AAC7D,QAAM,YAAY,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM;AAE3C,QAAM,OAAO,CAAC,GAAY,MAAsB;AAC9C,QAAI,UAAU,cAAe,QAAO,YAAY,CAAC;AACjD,QAAI,UAAU,aAAc,QAAO,WAAW,GAAG,KAAK,MAAM;AAE5D,QAAI,CAAC,UAAW,QAAO,WAAW;AAClC,WAAO,EAAE,SAAS,WAAW,MAAM,WAAW;AAAA,EAChD;AAGA,QAAM,SAAS,CAAC,GAAY,MAAsB;AAChD,QAAI,UAAU,cAAe,QAAO,cAAc,CAAC;AACnD,QAAI,UAAU,aAAc,QAAO,aAAa,GAAG,KAAK,MAAM;AAE9D,QAAI,CAAC,UAAW,QAAO;AACvB,WAAO,EAAE,SAAS,mCAAmC;AAAA,EACvD;AAIA,QAAM,OAAO,CAAC,GAAY,MAAkC;AAC1D,QAAI,UAAU,cAAe,QAAO,SAAS,qBAAqB,CAAC,CAAC;AACpE,QAAI,UAAU,aAAc,QAAO,SAAS,oBAAoB,GAAG,KAAK,MAAM,CAAC;AAC/E,WAAO,SAAS,cAAc,CAAC,aAAa,EAAE,SAAS,QAAQ,OAAO,CAAC;AAAA,EACzE;AAEA,SACE,qBAAC,SAAI,WAAW,GAAG,UAAU,SAAS,GAIpC;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO,EAAE,QAAQ,KAAK,EAAE;AAAA,QACxB,MAAK;AAAA,QACL,cAAY,KAAK,IAAI,CAAC,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,IAAI;AAAA,QAE7D,eAAK,IAAI,CAAC,GAAG,MACZ;AAAA,UAAC;AAAA;AAAA,YAEC,WAAU;AAAA,YACV,OAAO;AAAA,cACL,OAAO,GAAI,KAAK,EAAE,KAAK,IAAI,QAAS,GAAG;AAAA,cACvC,YAAY,KAAK,GAAG,CAAC;AAAA,cACrB,WAAW,KAAK,GAAG,CAAC;AAAA,YACtB;AAAA,YAEA,8BAAC,UAAK,WAAU,gDAA+C,OAAO,EAAE,OAAO,OAAO,GAAG,CAAC,EAAE,GAAI,YAAE,OAAM;AAAA;AAAA,UARnG,EAAE;AAAA,QAST,CACD;AAAA;AAAA,IACH;AAAA,IACC,cACC,oBAAC,QAAG,WAAU,uCACX,eAAK,IAAI,CAAC,GAAG,MACZ,qBAAC,QAAiB,WAAW,GAAG,wCAAwC,EAAE,SAAS,oBAAoB,yBAAyB,GAC9H;AAAA,0BAAC,UAAK,WAAU,kCAAiC,OAAO,EAAE,YAAY,KAAK,GAAG,CAAC,EAAE,GAAG,eAAY,QAAO;AAAA,MACtG,EAAE;AAAA,SAFI,EAAE,KAGX,CACD,GACH;AAAA,KAEJ;AAEJ;AACA,aAAa,cAAc;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/charts/bar-chart.tsx"],"sourcesContent":["'use client';\nimport * as React from 'react';\nimport { cn } from '@/lib/utils';\nimport { chartToken, toneFill, markEdge } from './lib/series';\n\nexport interface BarDatum {\n label: string;\n value: number;\n /** Highlight this bar (ink) and show its value by default. */\n active?: boolean;\n}\n\nexport interface BarChartProps {\n data: BarDatum[];\n height?: number;\n showValue?: boolean;\n /** Colour of the promoted bar. Defaults to ink; `accent` uses the signature accent. */\n tone?: 'ink' | 'accent';\n className?: string;\n}\n\n/**\n * Cairn BarChart, grayscale-first: muted neutral bars, the active bar promoted to ink\n * (or the signature accent via `tone=\"accent\"`) with a value pill. Interactive: hover any\n * bar to promote it and reveal its value. Colours resolve from `sys.chart.*` tokens (via\n * `chartToken`), so a theme swap recolours the chart for free. The chart carries a text\n * `aria-label` listing every label/value, so the data is never mouse-only (WCAG-safe).\n */\nexport function BarChart({ data, height = 200, showValue = true, tone = 'ink', className }: BarChartProps) {\n const max = Math.max(...data.map((d) => (Number.isFinite(d.value) ? d.value : 0)), 1);\n const [hover, setHover] = React.useState<number | null>(null);\n\n const activeFill = toneFill(tone);\n const mutedFill = chartToken.muted;\n\n return (\n <div className={cn('w-full', className)} role=\"group\" aria-label=\"Bar chart\">\n <div className=\"flex items-end gap-2\" style={{ height }} onMouseLeave={() => setHover(null)}>\n {data.map((d, i) => {\n const on = d.active || hover === i;\n const dim = hover != null && hover !== i;\n const h = Number.isFinite(d.value) ? d.value : 0;\n return (\n // Each bar is a focusable graphical object: keyboard + screen-reader parity with hover,\n // so its value is never mouse-only (rule 9). Focus mirrors hover to reveal the pill.\n <div\n key={d.label}\n role=\"img\"\n aria-label={`${d.label}: ${d.value}`}\n tabIndex={0}\n className=\"flex h-full flex-1 flex-col items-center justify-end gap-2 rounded-control outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus\"\n onMouseEnter={() => setHover(i)}\n onFocus={() => setHover(i)}\n onBlur={() => setHover(null)}\n >\n <span\n className={cn(\n 'rounded-pill px-2 py-0.5 sv-body-xs font-medium tabular-nums transition-opacity duration-150',\n on && showValue ? 'opacity-100' : 'opacity-0'\n )}\n style={{ background: activeFill, color: 'var(--sv-sys-color-on-primary)' }}\n >\n {d.value}\n </span>\n <div\n className={cn(\n 'w-full rounded-t-control transition-[height,background-color,opacity] duration-500 ease-out',\n dim && 'opacity-60'\n )}\n style={{\n height: `${Math.max(2, (h / max) * 100)}%`,\n background: on ? activeFill : mutedFill,\n // Only the pale muted fill (< 3:1 vs the surface) takes a keyline; the active\n // ink bar carries its own shape contrast and stays bare (AGENTS.md rule 9).\n boxShadow: markEdge(!on),\n }}\n />\n </div>\n );\n })}\n </div>\n <div className=\"mt-3 flex gap-2\" aria-hidden=\"true\">\n {data.map((d, i) => (\n <span\n key={d.label}\n className={cn(\n 'flex-1 text-center sv-body-sm transition-colors',\n d.active || hover === i ? 'text-on-surface' : 'text-on-surface-variant'\n )}\n >\n {d.label}\n </span>\n ))}\n </div>\n </div>\n );\n}\nBarChart.displayName = 'BarChart';\n"],"mappings":";;;;;;;;;;AACA,YAAY,WAAW;AA4CX,SAUE,KAVF;AAjBL,SAAS,SAAS,EAAE,MAAM,SAAS,KAAK,YAAY,MAAM,OAAO,OAAO,UAAU,GAAkB;AACzG,QAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC,MAAO,OAAO,SAAS,EAAE,KAAK,IAAI,EAAE,QAAQ,CAAE,GAAG,CAAC;AACpF,QAAM,CAAC,OAAO,QAAQ,IAAU,eAAwB,IAAI;AAE5D,QAAM,aAAa,SAAS,IAAI;AAChC,QAAM,YAAY,WAAW;AAE7B,SACE,qBAAC,SAAI,WAAW,GAAG,UAAU,SAAS,GAAG,MAAK,SAAQ,cAAW,aAC/D;AAAA,wBAAC,SAAI,WAAU,wBAAuB,OAAO,EAAE,OAAO,GAAG,cAAc,MAAM,SAAS,IAAI,GACvF,eAAK,IAAI,CAAC,GAAG,MAAM;AAClB,YAAM,KAAK,EAAE,UAAU,UAAU;AACjC,YAAM,MAAM,SAAS,QAAQ,UAAU;AACvC,YAAM,IAAI,OAAO,SAAS,EAAE,KAAK,IAAI,EAAE,QAAQ;AAC/C;AAAA;AAAA;AAAA,QAGE;AAAA,UAAC;AAAA;AAAA,YAEC,MAAK;AAAA,YACL,cAAY,GAAG,EAAE,KAAK,KAAK,EAAE,KAAK;AAAA,YAClC,UAAU;AAAA,YACV,WAAU;AAAA,YACV,cAAc,MAAM,SAAS,CAAC;AAAA,YAC9B,SAAS,MAAM,SAAS,CAAC;AAAA,YACzB,QAAQ,MAAM,SAAS,IAAI;AAAA,YAE3B;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAW;AAAA,oBACT;AAAA,oBACA,MAAM,YAAY,gBAAgB;AAAA,kBACpC;AAAA,kBACA,OAAO,EAAE,YAAY,YAAY,OAAO,iCAAiC;AAAA,kBAExE,YAAE;AAAA;AAAA,cACL;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,WAAW;AAAA,oBACT;AAAA,oBACA,OAAO;AAAA,kBACT;AAAA,kBACA,OAAO;AAAA,oBACL,QAAQ,GAAG,KAAK,IAAI,GAAI,IAAI,MAAO,GAAG,CAAC;AAAA,oBACvC,YAAY,KAAK,aAAa;AAAA;AAAA;AAAA,oBAG9B,WAAW,SAAS,CAAC,EAAE;AAAA,kBACzB;AAAA;AAAA,cACF;AAAA;AAAA;AAAA,UA9BK,EAAE;AAAA,QA+BT;AAAA;AAAA,IAEJ,CAAC,GACH;AAAA,IACA,oBAAC,SAAI,WAAU,mBAAkB,eAAY,QAC1C,eAAK,IAAI,CAAC,GAAG,MACZ;AAAA,MAAC;AAAA;AAAA,QAEC,WAAW;AAAA,UACT;AAAA,UACA,EAAE,UAAU,UAAU,IAAI,oBAAoB;AAAA,QAChD;AAAA,QAEC,YAAE;AAAA;AAAA,MANE,EAAE;AAAA,IAOT,CACD,GACH;AAAA,KACF;AAEJ;AACA,SAAS,cAAc;","names":[]}
|
|
File without changes
|