@claralight-design/react 0.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/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/lib/anchored.d.ts +152 -0
- package/dist/lib/anchored.js +821 -0
- package/dist/lib/anchored.js.map +1 -0
- package/dist/lib/morph.js +484 -0
- package/dist/lib/morph.js.map +1 -0
- package/dist/lib/squircle.d.ts +95 -0
- package/dist/lib/squircle.js +220 -0
- package/dist/lib/squircle.js.map +1 -0
- package/dist/lib/utils.d.ts +30 -0
- package/dist/lib/utils.js +76 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/ui/button.d.ts +40 -0
- package/dist/ui/button.js +104 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/card.d.ts +54 -0
- package/dist/ui/card.js +82 -0
- package/dist/ui/card.js.map +1 -0
- package/dist/ui/dialog.d.ts +82 -0
- package/dist/ui/dialog.js +129 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/input.d.ts +34 -0
- package/dist/ui/input.js +60 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/popover.d.ts +67 -0
- package/dist/ui/popover.js +93 -0
- package/dist/ui/popover.js.map +1 -0
- package/dist/ui/scroll-area.d.ts +110 -0
- package/dist/ui/scroll-area.js +125 -0
- package/dist/ui/scroll-area.js.map +1 -0
- package/dist/ui/select.d.ts +113 -0
- package/dist/ui/select.js +213 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui/tooltip.d.ts +108 -0
- package/dist/ui/tooltip.js +142 -0
- package/dist/ui/tooltip.js.map +1 -0
- package/package.json +72 -0
- package/styles/anchored.css +115 -0
- package/styles/base.css +309 -0
- package/styles/fonts/README.md +63 -0
- package/styles/index.css +28 -0
- package/styles/scroll-area.css +299 -0
- package/styles/theme.css +540 -0
- package/styles/tooltip.css +156 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RadiusToken, Squircle, SquircleProps } from "./lib/squircle.js";
|
|
2
|
+
import { cn } from "./lib/utils.js";
|
|
3
|
+
import { AnchoredSide, AnchoredSurface, AnchoredSurfaceProps, SurfaceGeometry, surfacePath } from "./lib/anchored.js";
|
|
4
|
+
import { Button, ButtonProps, buttonVariants } from "./ui/button.js";
|
|
5
|
+
import { Card, CardContent, CardContentProps, CardDescription, CardDescriptionProps, CardFooter, CardFooterProps, CardHeader, CardHeaderProps, CardProps, CardTitle, CardTitleProps, cardVariants } from "./ui/card.js";
|
|
6
|
+
import { Dialog, DialogBackdrop, DialogBackdropProps, DialogClose, DialogCloseProps, DialogDescription, DialogDescriptionProps, DialogPopup, DialogPopupProps, DialogTitle, DialogTitleProps, DialogTrigger, DialogTriggerProps } from "./ui/dialog.js";
|
|
7
|
+
import { Input, InputProps, inputVariants } from "./ui/input.js";
|
|
8
|
+
import { Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverCloseProps, PopoverContent, PopoverContentProps, PopoverDescription, PopoverDescriptionProps, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTitleProps, PopoverTrigger, PopoverTriggerProps } from "./ui/popover.js";
|
|
9
|
+
import { ScrollArea, ScrollAreaContent, ScrollAreaCorner, ScrollAreaEdge, ScrollAreaOrientation, ScrollAreaProps, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, ScrollbarVisibility } from "./ui/scroll-area.js";
|
|
10
|
+
import { Select, SelectContent, SelectContentProps, SelectGroup, SelectGroupLabel, SelectGroupLabelProps, SelectGroupProps, SelectIcon, SelectIconProps, SelectItem, SelectItemIndicator, SelectItemIndicatorProps, SelectItemProps, SelectItemText, SelectItemTextProps, SelectLabel, SelectLabelProps, SelectList, SelectPopup, SelectPortal, SelectPositioner, SelectSeparator, SelectSeparatorProps, SelectTrigger, SelectTriggerProps, SelectValue, SelectValueProps } from "./ui/select.js";
|
|
11
|
+
import { Tooltip, TooltipArrow, TooltipContent, TooltipContentProps, TooltipGroup, TooltipGroupProps, TooltipMotion, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProps, TooltipProvider, TooltipProviderProps, TooltipTrigger, TooltipTriggerProps, TooltipViewport } from "./ui/tooltip.js";
|
|
12
|
+
export { type AnchoredSide, AnchoredSurface, type AnchoredSurfaceProps, Button, type ButtonProps, Card, CardContent, type CardContentProps, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps, Dialog, DialogBackdrop, type DialogBackdropProps, DialogClose, type DialogCloseProps, DialogDescription, type DialogDescriptionProps, DialogPopup, type DialogPopupProps, DialogTitle, type DialogTitleProps, DialogTrigger, type DialogTriggerProps, Input, type InputProps, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, type PopoverCloseProps, PopoverContent, type PopoverContentProps, PopoverDescription, type PopoverDescriptionProps, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, type PopoverTitleProps, PopoverTrigger, type PopoverTriggerProps, type RadiusToken, ScrollArea, ScrollAreaContent, ScrollAreaCorner, type ScrollAreaEdge, type ScrollAreaOrientation, type ScrollAreaProps, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, type ScrollbarVisibility, Select, SelectContent, type SelectContentProps, SelectGroup, SelectGroupLabel, type SelectGroupLabelProps, type SelectGroupProps, SelectIcon, type SelectIconProps, SelectItem, SelectItemIndicator, type SelectItemIndicatorProps, type SelectItemProps, SelectItemText, type SelectItemTextProps, SelectLabel, type SelectLabelProps, SelectList, SelectPopup, SelectPortal, SelectPositioner, SelectSeparator, type SelectSeparatorProps, SelectTrigger, type SelectTriggerProps, SelectValue, type SelectValueProps, Squircle, type SquircleProps, type SurfaceGeometry, Tooltip, TooltipArrow, TooltipContent, type TooltipContentProps, TooltipGroup, type TooltipGroupProps, type TooltipMotion, TooltipPopup, TooltipPortal, TooltipPositioner, type TooltipProps, TooltipProvider, type TooltipProviderProps, TooltipTrigger, type TooltipTriggerProps, TooltipViewport, buttonVariants, cardVariants, cn, inputVariants, surfacePath };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { cn } from "./lib/utils.js";
|
|
2
|
+
import { Squircle } from "./lib/squircle.js";
|
|
3
|
+
import { AnchoredSurface, surfacePath } from "./lib/anchored.js";
|
|
4
|
+
import { Button, buttonVariants } from "./ui/button.js";
|
|
5
|
+
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, cardVariants } from "./ui/card.js";
|
|
6
|
+
import { Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogPopup, DialogTitle, DialogTrigger } from "./ui/dialog.js";
|
|
7
|
+
import { Input, inputVariants } from "./ui/input.js";
|
|
8
|
+
import { Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverContent, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger } from "./ui/popover.js";
|
|
9
|
+
import { ScrollArea, ScrollAreaContent, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from "./ui/scroll-area.js";
|
|
10
|
+
import { Select, SelectContent, SelectGroup, SelectGroupLabel, SelectIcon, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectList, SelectPopup, SelectPortal, SelectPositioner, SelectSeparator, SelectTrigger, SelectValue } from "./ui/select.js";
|
|
11
|
+
import { Tooltip, TooltipArrow, TooltipContent, TooltipGroup, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, TooltipViewport } from "./ui/tooltip.js";
|
|
12
|
+
export { AnchoredSurface, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Dialog, DialogBackdrop, DialogClose, DialogDescription, DialogPopup, DialogTitle, DialogTrigger, Input, Popover, PopoverArrow, PopoverBackdrop, PopoverClose, PopoverContent, PopoverDescription, PopoverPopup, PopoverPortal, PopoverPositioner, PopoverTitle, PopoverTrigger, ScrollArea, ScrollAreaContent, ScrollAreaCorner, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport, Select, SelectContent, SelectGroup, SelectGroupLabel, SelectIcon, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectList, SelectPopup, SelectPortal, SelectPositioner, SelectSeparator, SelectTrigger, SelectValue, Squircle, Tooltip, TooltipArrow, TooltipContent, TooltipGroup, TooltipPopup, TooltipPortal, TooltipPositioner, TooltipProvider, TooltipTrigger, TooltipViewport, buttonVariants, cardVariants, cn, inputVariants, surfacePath };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { RadiusToken } from "./squircle.js";
|
|
2
|
+
import "./utils.js";
|
|
3
|
+
import { ComponentProps, ReactNode } from "react";
|
|
4
|
+
//#region src/lib/anchored.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* ClaraLight's anchored overlay surface — the shape behind `Popover` and
|
|
7
|
+
* `Tooltip`.
|
|
8
|
+
*
|
|
9
|
+
* ## Why this is not `Squircle`
|
|
10
|
+
*
|
|
11
|
+
* A ClaraLight overlay points at its anchor, and the arrow is **part of the
|
|
12
|
+
* surface**, not a second element parked against its edge. That is forced by
|
|
13
|
+
* the design language rather than chosen for elegance: the frost fill is
|
|
14
|
+
* translucent, so two overlapping elements composite their alpha into a
|
|
15
|
+
* visible dark seam, and the 1px outline of the body would run straight across
|
|
16
|
+
* the arrow's mouth. Both are plainly visible at rest, not just in motion.
|
|
17
|
+
*
|
|
18
|
+
* So the body and the tail are a single closed path. `Squircle` cannot express
|
|
19
|
+
* that — Lisse's API takes corner options, with no way to hand it a path — so
|
|
20
|
+
* this primitive owns the same three jobs `Squircle` delegates to Lisse:
|
|
21
|
+
*
|
|
22
|
+
* clip-path the fused path, which is also what clips the backdrop blur
|
|
23
|
+
* the outline an SVG stroke over the same path, because `clip-path` crops
|
|
24
|
+
* `border` (and `outline`) to nothing
|
|
25
|
+
* sync re-measure when the surface resizes, flips side, or the anchor
|
|
26
|
+
* moves the tail — and, for a shared tooltip, drive the tail
|
|
27
|
+
* ahead of a surface that is still travelling
|
|
28
|
+
*
|
|
29
|
+
* It deliberately does **not** render a shadow. Anchored overlays in ClaraLight
|
|
30
|
+
* sit on their outline and their blur alone.
|
|
31
|
+
*
|
|
32
|
+
* ## Why the body still comes from Lisse
|
|
33
|
+
*
|
|
34
|
+
* `generatePath` emits the Figma smoothing construction, which is the whole
|
|
35
|
+
* argument in `squircle.tsx` for not using CSS `corner-shape`. Reimplementing
|
|
36
|
+
* it here would fork the corner geometry of the design system, so the tail is
|
|
37
|
+
* spliced into Lisse's own output instead: its straight edges are discrete
|
|
38
|
+
* absolute `L` commands, which makes the splice an edit rather than a boolean
|
|
39
|
+
* union.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* The physical side of the anchor a surface sits on.
|
|
43
|
+
*
|
|
44
|
+
* Base UI also accepts the logical `inline-start` / `inline-end`, which are
|
|
45
|
+
* deliberately not forwarded: with a physical side in, Base UI's resolved side
|
|
46
|
+
* (and therefore `data-side`, which drives both the tail and the padding) is
|
|
47
|
+
* guaranteed to be one of these four, so the geometry never has to resolve
|
|
48
|
+
* writing direction to know which edge the tail belongs on.
|
|
49
|
+
*/
|
|
50
|
+
export type AnchoredSide = "top" | "bottom" | "left" | "right";
|
|
51
|
+
interface Point {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
}
|
|
55
|
+
export interface SurfaceGeometry {
|
|
56
|
+
/** Border box of the whole surface, tail included. */
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
/** Side of the anchor the surface was placed on. */
|
|
60
|
+
side: AnchoredSide;
|
|
61
|
+
radius: number;
|
|
62
|
+
smoothing: number;
|
|
63
|
+
/** Whether to splice the tail in at all. */
|
|
64
|
+
arrow: boolean;
|
|
65
|
+
/** How far the tail reaches past the body, and its full base width. */
|
|
66
|
+
extent: number;
|
|
67
|
+
arrowWidth: number;
|
|
68
|
+
/** Tail centre along the tail's edge, from the surface's own origin. */
|
|
69
|
+
center: number;
|
|
70
|
+
}
|
|
71
|
+
export interface SurfaceOutline {
|
|
72
|
+
/** The `clip-path` value: the surface's whole filled region. */
|
|
73
|
+
clip: string;
|
|
74
|
+
/**
|
|
75
|
+
* The subpaths to stroke. One when the tail is part of the body's own
|
|
76
|
+
* outline; two when the surface is a union, in which case each is stroked
|
|
77
|
+
* clipped to the outside of the other so the shared join is never drawn.
|
|
78
|
+
*/
|
|
79
|
+
outline: string[];
|
|
80
|
+
/** Where the surface grows from: the tail's tip, or the anchored edge. */
|
|
81
|
+
origin: Point;
|
|
82
|
+
/**
|
|
83
|
+
* Where the tail actually landed, after being held clear of the corners.
|
|
84
|
+
*
|
|
85
|
+
* The requested centre is a wish: it comes from the anchor, which can sit
|
|
86
|
+
* anywhere, including off the end of the surface. This is the answer, and the
|
|
87
|
+
* only value a caller may animate towards — following the wish instead would
|
|
88
|
+
* chase a position the surface will not draw.
|
|
89
|
+
*/
|
|
90
|
+
center: number;
|
|
91
|
+
/**
|
|
92
|
+
* The centres this surface could have drawn: how far the tail can reach along
|
|
93
|
+
* its edge.
|
|
94
|
+
*
|
|
95
|
+
* Anything animating the tail needs this, not just the answer for one frame. A
|
|
96
|
+
* follower aimed at an unreachable centre covers the whole distance to it in
|
|
97
|
+
* its first step and lands on the limit — which is a jump, not a movement.
|
|
98
|
+
* Aimed at the limit itself, the same follower slides.
|
|
99
|
+
*/
|
|
100
|
+
range: {
|
|
101
|
+
min: number;
|
|
102
|
+
max: number;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The surface's filled region and the strokes that trace its boundary.
|
|
107
|
+
*
|
|
108
|
+
* The tail is spliced into the body's own path whenever the anchored edge has
|
|
109
|
+
* a straight run long enough to hold its base. That is the case for every
|
|
110
|
+
* top and bottom overlay and for tall ones on the left or right, and it is the
|
|
111
|
+
* better construction: one continuous outline, stroked in one pass.
|
|
112
|
+
*
|
|
113
|
+
* A short edge has no straight run at all — the corners meet in the middle of
|
|
114
|
+
* it — and no amount of splicing can put a 24px base on it. There the surface
|
|
115
|
+
* becomes the union of the body and a tail whose base sinks below the body's
|
|
116
|
+
* outline, which is what Flutter draws too. The `clip-path` unions them by
|
|
117
|
+
* winding, and the two strokes are clipped against each other.
|
|
118
|
+
*
|
|
119
|
+
* Both constructions need to know where the corners let go of the edge, and
|
|
120
|
+
* that is read off the path Lisse emitted rather than derived from the radius —
|
|
121
|
+
* see `edgeRun`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function surfacePath(geometry: SurfaceGeometry): SurfaceOutline;
|
|
124
|
+
export interface AnchoredSurfaceProps extends Omit<ComponentProps<"div">, "children"> {
|
|
125
|
+
/** Which `--radius-*` token shapes the body's corners. */
|
|
126
|
+
radius: RadiusToken;
|
|
127
|
+
/**
|
|
128
|
+
* Preferred side, used until Base UI reports the side it actually resolved
|
|
129
|
+
* on `data-side`. Only the fallback: a flip updates the tail on its own.
|
|
130
|
+
*/
|
|
131
|
+
side: AnchoredSide;
|
|
132
|
+
/** Whether the surface points at its anchor. */
|
|
133
|
+
arrow?: boolean;
|
|
134
|
+
/** Figma's `xi`; defaults to `--cl-corner-smoothing`, as in `Squircle`. */
|
|
135
|
+
smoothing?: number;
|
|
136
|
+
/** Classes for the wrapper: placement, transform, and the entrance. */
|
|
137
|
+
wrapperClassName?: string;
|
|
138
|
+
/** Classes for the shape itself: fill, border, padding, text. */
|
|
139
|
+
className?: string;
|
|
140
|
+
/** Whether the fused tail follows a new trigger on an interruptible track. */
|
|
141
|
+
tailMotion?: "none" | "fast";
|
|
142
|
+
/**
|
|
143
|
+
* Merge onto a single child rather than rendering a `div`. Needed for the
|
|
144
|
+
* same reason as in `Squircle`: the clipped element is a Base UI part that
|
|
145
|
+
* owns its own tag and behaviour.
|
|
146
|
+
*/
|
|
147
|
+
asChild?: boolean;
|
|
148
|
+
children?: ReactNode;
|
|
149
|
+
}
|
|
150
|
+
export declare function AnchoredSurface({ radius, side, arrow, smoothing, wrapperClassName, className, asChild, children, ref: forwardedRef, style, tailMotion, ...props }: AnchoredSurfaceProps): import("react").JSX.Element;
|
|
151
|
+
//#endregion
|
|
152
|
+
//# sourceMappingURL=anchored.d.ts.map
|