veloria-ui 0.1.2
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 +206 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/cli/index.js +511 -0
- package/dist/index.d.mts +1317 -0
- package/dist/index.d.ts +1317 -0
- package/dist/index.js +5373 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +5130 -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 +1197 -0
- package/dist/provider.js.map +1 -0
- package/dist/provider.mjs +1161 -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 +303 -0
- package/src/cli/registry.ts +139 -0
- package/src/components/advanced-forms/index.tsx +975 -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 +1158 -0
- package/src/components/feedback/index.tsx +1051 -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 +566 -0
- package/src/hooks/index.ts +602 -0
- package/src/hooks/use-toast.tsx +74 -0
- package/src/index.ts +396 -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
package/src/tailwind.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { Config } from "tailwindcss";
|
|
2
|
+
|
|
3
|
+
// tailwindcss is a peerDep — it lives in the consumer's node_modules, never
|
|
4
|
+
// bundled into veloria-ui. We require() at runtime so tsup marks it external
|
|
5
|
+
// correctly instead of trying to resolve it at build time.
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
7
|
+
const plugin = require("tailwindcss/plugin") as (
|
|
8
|
+
handler: Parameters<typeof import("tailwindcss/plugin")>[0],
|
|
9
|
+
config?: Parameters<typeof import("tailwindcss/plugin")>[1]
|
|
10
|
+
) => ReturnType<typeof import("tailwindcss/plugin")>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Veloria UI Tailwind plugin.
|
|
14
|
+
*
|
|
15
|
+
* Maps the CSS custom properties in atlas.css to Tailwind utilities.
|
|
16
|
+
* Add to your tailwind.config.ts:
|
|
17
|
+
*
|
|
18
|
+
* import { atlasPlugin } from "veloria-ui/tailwind";
|
|
19
|
+
* plugins: [atlasPlugin],
|
|
20
|
+
*
|
|
21
|
+
* Or use atlasPreset which also sets darkMode: ["class"]:
|
|
22
|
+
*
|
|
23
|
+
* import { atlasPreset } from "veloria-ui/tailwind";
|
|
24
|
+
* presets: [atlasPreset],
|
|
25
|
+
*/
|
|
26
|
+
export const atlasPlugin = plugin(
|
|
27
|
+
({ addBase, addUtilities }) => {
|
|
28
|
+
addBase({
|
|
29
|
+
"*": { "border-color": "hsl(var(--border))" },
|
|
30
|
+
body: {
|
|
31
|
+
"background-color": "hsl(var(--background))",
|
|
32
|
+
color: "hsl(var(--foreground))",
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
addUtilities({
|
|
36
|
+
".text-balance": { "text-wrap": "balance" },
|
|
37
|
+
".text-pretty": { "text-wrap": "pretty" },
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
theme: {
|
|
42
|
+
extend: {
|
|
43
|
+
colors: {
|
|
44
|
+
background: "hsl(var(--background))",
|
|
45
|
+
foreground: "hsl(var(--foreground))",
|
|
46
|
+
card: {
|
|
47
|
+
DEFAULT: "hsl(var(--card))",
|
|
48
|
+
foreground: "hsl(var(--card-foreground))",
|
|
49
|
+
},
|
|
50
|
+
popover: {
|
|
51
|
+
DEFAULT: "hsl(var(--popover))",
|
|
52
|
+
foreground: "hsl(var(--popover-foreground))",
|
|
53
|
+
},
|
|
54
|
+
primary: {
|
|
55
|
+
DEFAULT: "hsl(var(--primary))",
|
|
56
|
+
foreground: "hsl(var(--primary-foreground))",
|
|
57
|
+
},
|
|
58
|
+
secondary: {
|
|
59
|
+
DEFAULT: "hsl(var(--secondary))",
|
|
60
|
+
foreground: "hsl(var(--secondary-foreground))",
|
|
61
|
+
},
|
|
62
|
+
muted: {
|
|
63
|
+
DEFAULT: "hsl(var(--muted))",
|
|
64
|
+
foreground: "hsl(var(--muted-foreground))",
|
|
65
|
+
},
|
|
66
|
+
accent: {
|
|
67
|
+
DEFAULT: "hsl(var(--accent))",
|
|
68
|
+
foreground: "hsl(var(--accent-foreground))",
|
|
69
|
+
},
|
|
70
|
+
destructive: {
|
|
71
|
+
DEFAULT: "hsl(var(--destructive))",
|
|
72
|
+
foreground: "hsl(var(--destructive-foreground))",
|
|
73
|
+
},
|
|
74
|
+
success: {
|
|
75
|
+
DEFAULT: "hsl(var(--success))",
|
|
76
|
+
foreground: "hsl(var(--success-foreground))",
|
|
77
|
+
},
|
|
78
|
+
warning: {
|
|
79
|
+
DEFAULT: "hsl(var(--warning))",
|
|
80
|
+
foreground: "hsl(var(--warning-foreground))",
|
|
81
|
+
},
|
|
82
|
+
info: {
|
|
83
|
+
DEFAULT: "hsl(var(--info))",
|
|
84
|
+
foreground: "hsl(var(--info-foreground))",
|
|
85
|
+
},
|
|
86
|
+
border: "hsl(var(--border))",
|
|
87
|
+
input: "hsl(var(--input))",
|
|
88
|
+
ring: "hsl(var(--ring))",
|
|
89
|
+
},
|
|
90
|
+
borderRadius: {
|
|
91
|
+
lg: "var(--radius)",
|
|
92
|
+
md: "calc(var(--radius) - 2px)",
|
|
93
|
+
sm: "calc(var(--radius) - 4px)",
|
|
94
|
+
},
|
|
95
|
+
fontFamily: {
|
|
96
|
+
sans: ["var(--font-sans)"],
|
|
97
|
+
mono: ["var(--font-mono)"],
|
|
98
|
+
},
|
|
99
|
+
keyframes: {
|
|
100
|
+
"accordion-down": {
|
|
101
|
+
from: { height: "0" },
|
|
102
|
+
to: { height: "var(--radix-accordion-content-height)" },
|
|
103
|
+
},
|
|
104
|
+
"accordion-up": {
|
|
105
|
+
from: { height: "var(--radix-accordion-content-height)" },
|
|
106
|
+
to: { height: "0" },
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
animation: {
|
|
110
|
+
"accordion-down": "accordion-down 0.2s ease-out",
|
|
111
|
+
"accordion-up": "accordion-up 0.2s ease-out",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
/** Full preset — includes the plugin + darkMode: ["class"]. Recommended for new projects. */
|
|
119
|
+
export const atlasPreset: Partial<Config> = {
|
|
120
|
+
darkMode: ["class"],
|
|
121
|
+
plugins: [atlasPlugin],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export default atlasPlugin;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
// ─── Size System ────────────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export type Size = "xs" | "sm" | "md" | "lg" | "xl" | "2xl";
|
|
7
|
+
export type ResponsiveSize = Size | Partial<Record<"base" | "sm" | "md" | "lg" | "xl", Size>>;
|
|
8
|
+
|
|
9
|
+
// ─── Color Variants ─────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export type ColorScheme =
|
|
12
|
+
| "primary"
|
|
13
|
+
| "secondary"
|
|
14
|
+
| "success"
|
|
15
|
+
| "warning"
|
|
16
|
+
| "danger"
|
|
17
|
+
| "info"
|
|
18
|
+
| "neutral"
|
|
19
|
+
| "ghost";
|
|
20
|
+
|
|
21
|
+
// ─── Visual Variants ────────────────────────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
export type Variant = "solid" | "outline" | "ghost" | "soft" | "link";
|
|
24
|
+
|
|
25
|
+
// ─── Placement ──────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
export type Placement =
|
|
28
|
+
| "top"
|
|
29
|
+
| "top-start"
|
|
30
|
+
| "top-end"
|
|
31
|
+
| "bottom"
|
|
32
|
+
| "bottom-start"
|
|
33
|
+
| "bottom-end"
|
|
34
|
+
| "left"
|
|
35
|
+
| "left-start"
|
|
36
|
+
| "left-end"
|
|
37
|
+
| "right"
|
|
38
|
+
| "right-start"
|
|
39
|
+
| "right-end";
|
|
40
|
+
|
|
41
|
+
export type Side = "top" | "right" | "bottom" | "left";
|
|
42
|
+
|
|
43
|
+
// ─── Shared Component Props ──────────────────────────────────────────────────
|
|
44
|
+
|
|
45
|
+
export interface AtlasBaseProps {
|
|
46
|
+
/** Additional CSS class names */
|
|
47
|
+
className?: string;
|
|
48
|
+
/** Inline style overrides */
|
|
49
|
+
style?: React.CSSProperties;
|
|
50
|
+
/** Data attributes passthrough */
|
|
51
|
+
[key: `data-${string}`]: unknown;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface AtlasAriaProps {
|
|
55
|
+
"aria-label"?: string;
|
|
56
|
+
"aria-labelledby"?: string;
|
|
57
|
+
"aria-describedby"?: string;
|
|
58
|
+
"aria-hidden"?: boolean;
|
|
59
|
+
id?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ─── Polymorphic Component Support ──────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
export type AsChildProps<T extends React.ElementType = React.ElementType> = {
|
|
65
|
+
asChild?: boolean;
|
|
66
|
+
as?: T;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type PolymorphicRef<C extends React.ElementType> =
|
|
70
|
+
React.ComponentPropsWithRef<C>["ref"];
|
|
71
|
+
|
|
72
|
+
export type PolymorphicComponentPropsWithRef<
|
|
73
|
+
C extends React.ElementType,
|
|
74
|
+
Props = object
|
|
75
|
+
> = Props &
|
|
76
|
+
Omit<React.ComponentPropsWithRef<C>, keyof Props> & {
|
|
77
|
+
as?: C;
|
|
78
|
+
ref?: PolymorphicRef<C>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// ─── Orientation ─────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
export type Orientation = "horizontal" | "vertical";
|
|
84
|
+
|
|
85
|
+
// ─── Status ──────────────────────────────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
export type Status = "idle" | "loading" | "success" | "error" | "warning";
|
|
88
|
+
|
|
89
|
+
// ─── Theme ───────────────────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
export type Theme = "light" | "dark" | "system";
|
|
92
|
+
|
|
93
|
+
// ─── Re-exports ───────────────────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
export type { VariantProps };
|
package/src/utils/cn.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ClassValue, clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Merges Tailwind classes without conflicts.
|
|
6
|
+
* Wrapper around clsx + tailwind-merge — use this everywhere in Veloria UI
|
|
7
|
+
* instead of raw string concatenation.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* cn("px-4 py-2", isLarge && "px-8", className)
|
|
11
|
+
*/
|
|
12
|
+
export function cn(...inputs: ClassValue[]): string {
|
|
13
|
+
return twMerge(clsx(inputs));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Chains two event handlers so both fire, but respects defaultPrevented
|
|
18
|
+
* on the original handler before calling ours.
|
|
19
|
+
*/
|
|
20
|
+
export function composeEventHandlers<E>(
|
|
21
|
+
originalEventHandler?: (event: E) => void,
|
|
22
|
+
ourEventHandler?: (event: E) => void,
|
|
23
|
+
{ checkForDefaultPrevented = true } = {}
|
|
24
|
+
) {
|
|
25
|
+
return function handleEvent(event: E) {
|
|
26
|
+
originalEventHandler?.(event);
|
|
27
|
+
if (
|
|
28
|
+
!checkForDefaultPrevented ||
|
|
29
|
+
!(event as unknown as Event).defaultPrevented
|
|
30
|
+
) {
|
|
31
|
+
return ourEventHandler?.(event);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Quick incrementing ID generator — used for linking labels to inputs
|
|
38
|
+
* when no explicit id prop is passed.
|
|
39
|
+
*/
|
|
40
|
+
let idCounter = 0;
|
|
41
|
+
export function generateId(prefix = "atlas"): string {
|
|
42
|
+
return `${prefix}-${++idCounter}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True only in browser environments. Guards SSR code paths. */
|
|
46
|
+
export const isBrowser = typeof window !== "undefined";
|
|
47
|
+
|
|
48
|
+
/** A do-nothing function. Handy as a default prop value. */
|
|
49
|
+
export const noop = () => undefined;
|
|
50
|
+
|
|
51
|
+
/** Narrows out null and undefined from a value. */
|
|
52
|
+
export function isDefined<T>(value: T | undefined | null): value is T {
|
|
53
|
+
return value !== undefined && value !== null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Filters React.Children down to only valid elements.
|
|
58
|
+
* Useful when mapping children and you need to skip strings/nulls.
|
|
59
|
+
*/
|
|
60
|
+
export function getValidChildren(children: React.ReactNode) {
|
|
61
|
+
return React.Children.toArray(children).filter((child) =>
|
|
62
|
+
React.isValidElement(child)
|
|
63
|
+
) as React.ReactElement[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
import React from "react";
|