atlasui-lib 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/CHANGELOG.md +157 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/cli/index.js +364 -0
- package/dist/index.d.mts +1027 -0
- package/dist/index.d.ts +1027 -0
- package/dist/index.js +3954 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3733 -0
- package/dist/index.mjs.map +1 -0
- package/dist/provider.d.mts +15 -0
- package/dist/provider.d.ts +15 -0
- package/dist/provider.js +816 -0
- package/dist/provider.js.map +1 -0
- package/dist/provider.mjs +780 -0
- package/dist/provider.mjs.map +1 -0
- package/dist/tailwind.d.ts +25 -0
- package/dist/tailwind.js +129 -0
- package/package.json +138 -0
- package/src/cli/index.ts +301 -0
- package/src/cli/registry.ts +139 -0
- package/src/components/advanced-forms/index.tsx +567 -0
- package/src/components/basic/Button.tsx +135 -0
- package/src/components/basic/IconButton.tsx +69 -0
- package/src/components/basic/index.tsx +446 -0
- package/src/components/data-display/index.tsx +608 -0
- package/src/components/feedback/index.tsx +554 -0
- package/src/components/forms/index.tsx +476 -0
- package/src/components/layout/index.tsx +296 -0
- package/src/components/media/index.tsx +437 -0
- package/src/components/navigation/index.tsx +484 -0
- package/src/components/overlay/index.tsx +473 -0
- package/src/components/utility/index.tsx +411 -0
- package/src/hooks/index.ts +271 -0
- package/src/hooks/use-toast.tsx +74 -0
- package/src/index.ts +353 -0
- package/src/provider.tsx +54 -0
- package/src/styles/atlas.css +252 -0
- package/src/tailwind.ts +124 -0
- package/src/types/index.ts +95 -0
- package/src/utils/cn.ts +66 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio";
|
|
3
|
+
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../utils/cn";
|
|
6
|
+
|
|
7
|
+
// ─── Container ─────────────────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
export interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
maxWidth?: "sm" | "md" | "lg" | "xl" | "2xl" | "full";
|
|
11
|
+
center?: boolean;
|
|
12
|
+
padded?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const maxWidthMap = {
|
|
16
|
+
sm: "max-w-screen-sm",
|
|
17
|
+
md: "max-w-screen-md",
|
|
18
|
+
lg: "max-w-screen-lg",
|
|
19
|
+
xl: "max-w-screen-xl",
|
|
20
|
+
"2xl": "max-w-screen-2xl",
|
|
21
|
+
full: "max-w-full",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Container = React.forwardRef<HTMLDivElement, ContainerProps>(
|
|
25
|
+
({ className, maxWidth = "xl", center = true, padded = true, ...props }, ref) => (
|
|
26
|
+
<div
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={cn(
|
|
29
|
+
"atlas-container w-full",
|
|
30
|
+
maxWidthMap[maxWidth],
|
|
31
|
+
center && "mx-auto",
|
|
32
|
+
padded && "px-4 sm:px-6 lg:px-8",
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
Container.displayName = "Container";
|
|
40
|
+
|
|
41
|
+
// ─── Stack ─────────────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
export interface StackProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
44
|
+
direction?: "row" | "column";
|
|
45
|
+
gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16;
|
|
46
|
+
align?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
47
|
+
justify?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
48
|
+
wrap?: boolean;
|
|
49
|
+
divider?: React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const Stack = React.forwardRef<HTMLDivElement, StackProps>(
|
|
53
|
+
({ className, direction = "column", gap = 4, align, justify, wrap, divider, children, ...props }, ref) => {
|
|
54
|
+
const gapClass = `gap-${gap}`;
|
|
55
|
+
const validChildren = React.Children.toArray(children).filter(React.isValidElement);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
ref={ref}
|
|
60
|
+
className={cn(
|
|
61
|
+
"atlas-stack flex",
|
|
62
|
+
direction === "row" ? "flex-row" : "flex-col",
|
|
63
|
+
gapClass,
|
|
64
|
+
align && `items-${align}`,
|
|
65
|
+
justify && `justify-${justify}`,
|
|
66
|
+
wrap && "flex-wrap",
|
|
67
|
+
className
|
|
68
|
+
)}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
{divider
|
|
72
|
+
? validChildren.map((child, i) => (
|
|
73
|
+
<React.Fragment key={i}>
|
|
74
|
+
{child}
|
|
75
|
+
{i < validChildren.length - 1 && divider}
|
|
76
|
+
</React.Fragment>
|
|
77
|
+
))
|
|
78
|
+
: children}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
Stack.displayName = "Stack";
|
|
84
|
+
|
|
85
|
+
// ─── Grid ──────────────────────────────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
88
|
+
cols?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
89
|
+
gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12;
|
|
90
|
+
rows?: number;
|
|
91
|
+
flow?: "row" | "col" | "dense";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const Grid = React.forwardRef<HTMLDivElement, GridProps>(
|
|
95
|
+
({ className, cols = 1, gap = 4, rows, flow, ...props }, ref) => (
|
|
96
|
+
<div
|
|
97
|
+
ref={ref}
|
|
98
|
+
className={cn(
|
|
99
|
+
"atlas-grid grid",
|
|
100
|
+
`grid-cols-${cols}`,
|
|
101
|
+
`gap-${gap}`,
|
|
102
|
+
rows && `grid-rows-${rows}`,
|
|
103
|
+
flow && `grid-flow-${flow}`,
|
|
104
|
+
className
|
|
105
|
+
)}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
Grid.displayName = "Grid";
|
|
111
|
+
|
|
112
|
+
// ─── Flex ──────────────────────────────────────────────────────────────────
|
|
113
|
+
|
|
114
|
+
export interface FlexProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
115
|
+
direction?: "row" | "col" | "row-reverse" | "col-reverse";
|
|
116
|
+
align?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
117
|
+
justify?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
118
|
+
wrap?: boolean | "reverse";
|
|
119
|
+
gap?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12;
|
|
120
|
+
inline?: boolean;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const Flex = React.forwardRef<HTMLDivElement, FlexProps>(
|
|
124
|
+
({ className, direction = "row", align, justify, wrap, gap, inline, ...props }, ref) => (
|
|
125
|
+
<div
|
|
126
|
+
ref={ref}
|
|
127
|
+
className={cn(
|
|
128
|
+
"atlas-flex",
|
|
129
|
+
inline ? "inline-flex" : "flex",
|
|
130
|
+
direction !== "row" && `flex-${direction}`,
|
|
131
|
+
align && `items-${align}`,
|
|
132
|
+
justify && `justify-${justify}`,
|
|
133
|
+
wrap === true && "flex-wrap",
|
|
134
|
+
wrap === "reverse" && "flex-wrap-reverse",
|
|
135
|
+
gap !== undefined && `gap-${gap}`,
|
|
136
|
+
className
|
|
137
|
+
)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
Flex.displayName = "Flex";
|
|
143
|
+
|
|
144
|
+
// ─── Section ──────────────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
export interface SectionProps extends React.HTMLAttributes<HTMLElement> {
|
|
147
|
+
as?: React.ElementType;
|
|
148
|
+
py?: "sm" | "md" | "lg" | "xl" | "2xl";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const pyMap = { sm: "py-8", md: "py-12", lg: "py-16", xl: "py-24", "2xl": "py-32" };
|
|
152
|
+
|
|
153
|
+
const Section = React.forwardRef<HTMLElement, SectionProps>(
|
|
154
|
+
({ className, as: Comp = "section", py = "lg", ...props }, ref) => (
|
|
155
|
+
<Comp ref={ref} className={cn("atlas-section w-full", pyMap[py], className)} {...props} />
|
|
156
|
+
)
|
|
157
|
+
);
|
|
158
|
+
Section.displayName = "Section";
|
|
159
|
+
|
|
160
|
+
// ─── Spacer ───────────────────────────────────────────────────────────────
|
|
161
|
+
|
|
162
|
+
export interface SpacerProps {
|
|
163
|
+
size?: 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24;
|
|
164
|
+
axis?: "horizontal" | "vertical" | "both";
|
|
165
|
+
className?: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const Spacer = ({ size = 4, axis = "vertical", className }: SpacerProps) => (
|
|
169
|
+
<span
|
|
170
|
+
className={cn(
|
|
171
|
+
"atlas-spacer block",
|
|
172
|
+
axis === "vertical" && `h-${size}`,
|
|
173
|
+
axis === "horizontal" && `w-${size}`,
|
|
174
|
+
axis === "both" && `h-${size} w-${size}`,
|
|
175
|
+
className
|
|
176
|
+
)}
|
|
177
|
+
aria-hidden="true"
|
|
178
|
+
/>
|
|
179
|
+
);
|
|
180
|
+
Spacer.displayName = "Spacer";
|
|
181
|
+
|
|
182
|
+
// ─── AspectRatio ──────────────────────────────────────────────────────────
|
|
183
|
+
|
|
184
|
+
const AspectRatio = React.forwardRef<
|
|
185
|
+
React.ElementRef<typeof AspectRatioPrimitive.Root>,
|
|
186
|
+
React.ComponentPropsWithoutRef<typeof AspectRatioPrimitive.Root>
|
|
187
|
+
>(({ className, ...props }, ref) => (
|
|
188
|
+
<AspectRatioPrimitive.Root ref={ref} className={cn("atlas-aspect-ratio", className)} {...props} />
|
|
189
|
+
));
|
|
190
|
+
AspectRatio.displayName = "AspectRatio";
|
|
191
|
+
|
|
192
|
+
// ─── Center ───────────────────────────────────────────────────────────────
|
|
193
|
+
|
|
194
|
+
export interface CenterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
195
|
+
inline?: boolean;
|
|
196
|
+
minH?: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const Center = React.forwardRef<HTMLDivElement, CenterProps>(
|
|
200
|
+
({ className, inline, minH, style, ...props }, ref) => (
|
|
201
|
+
<div
|
|
202
|
+
ref={ref}
|
|
203
|
+
className={cn(
|
|
204
|
+
"atlas-center",
|
|
205
|
+
inline ? "inline-flex" : "flex",
|
|
206
|
+
"items-center justify-center",
|
|
207
|
+
className
|
|
208
|
+
)}
|
|
209
|
+
style={{ minHeight: minH, ...style }}
|
|
210
|
+
{...props}
|
|
211
|
+
/>
|
|
212
|
+
)
|
|
213
|
+
);
|
|
214
|
+
Center.displayName = "Center";
|
|
215
|
+
|
|
216
|
+
// ─── ScrollArea ───────────────────────────────────────────────────────────
|
|
217
|
+
|
|
218
|
+
const ScrollArea = React.forwardRef<
|
|
219
|
+
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
|
220
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
|
|
221
|
+
orientation?: "vertical" | "horizontal" | "both";
|
|
222
|
+
}
|
|
223
|
+
>(({ className, children, orientation = "vertical", ...props }, ref) => (
|
|
224
|
+
<ScrollAreaPrimitive.Root
|
|
225
|
+
ref={ref}
|
|
226
|
+
className={cn("atlas-scroll-area relative overflow-hidden", className)}
|
|
227
|
+
{...props}
|
|
228
|
+
>
|
|
229
|
+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
|
230
|
+
{children}
|
|
231
|
+
</ScrollAreaPrimitive.Viewport>
|
|
232
|
+
{(orientation === "vertical" || orientation === "both") && (
|
|
233
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
234
|
+
orientation="vertical"
|
|
235
|
+
className="flex touch-none select-none transition-colors h-full w-2.5 border-l border-l-transparent p-[1px]"
|
|
236
|
+
>
|
|
237
|
+
<ScrollAreaPrimitive.Thumb className="relative flex-1 rounded-full bg-border" />
|
|
238
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
239
|
+
)}
|
|
240
|
+
{(orientation === "horizontal" || orientation === "both") && (
|
|
241
|
+
<ScrollAreaPrimitive.Scrollbar
|
|
242
|
+
orientation="horizontal"
|
|
243
|
+
className="flex touch-none select-none transition-colors flex-col h-2.5 border-t border-t-transparent p-[1px]"
|
|
244
|
+
>
|
|
245
|
+
<ScrollAreaPrimitive.Thumb className="relative flex-1 rounded-full bg-border" />
|
|
246
|
+
</ScrollAreaPrimitive.Scrollbar>
|
|
247
|
+
)}
|
|
248
|
+
<ScrollAreaPrimitive.Corner />
|
|
249
|
+
</ScrollAreaPrimitive.Root>
|
|
250
|
+
));
|
|
251
|
+
ScrollArea.displayName = "ScrollArea";
|
|
252
|
+
|
|
253
|
+
// ─── Masonry ──────────────────────────────────────────────────────────────
|
|
254
|
+
|
|
255
|
+
export interface MasonryProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
256
|
+
columns?: number | { sm?: number; md?: number; lg?: number; xl?: number };
|
|
257
|
+
gap?: number;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const Masonry = React.forwardRef<HTMLDivElement, MasonryProps>(
|
|
261
|
+
({ className, columns = 3, gap = 4, children, ...props }, ref) => {
|
|
262
|
+
const cols = typeof columns === "number" ? columns : 3;
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<div
|
|
266
|
+
ref={ref}
|
|
267
|
+
className={cn("atlas-masonry w-full", className)}
|
|
268
|
+
style={{
|
|
269
|
+
columnCount: cols,
|
|
270
|
+
columnGap: `${gap * 4}px`,
|
|
271
|
+
}}
|
|
272
|
+
{...props}
|
|
273
|
+
>
|
|
274
|
+
{React.Children.map(children, (child) => (
|
|
275
|
+
<div style={{ breakInside: "avoid", marginBottom: `${gap * 4}px` }}>
|
|
276
|
+
{child}
|
|
277
|
+
</div>
|
|
278
|
+
))}
|
|
279
|
+
</div>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
Masonry.displayName = "Masonry";
|
|
284
|
+
|
|
285
|
+
export {
|
|
286
|
+
Container,
|
|
287
|
+
Stack,
|
|
288
|
+
Grid,
|
|
289
|
+
Flex,
|
|
290
|
+
Section,
|
|
291
|
+
Spacer,
|
|
292
|
+
AspectRatio,
|
|
293
|
+
Center,
|
|
294
|
+
ScrollArea,
|
|
295
|
+
Masonry,
|
|
296
|
+
};
|