@sdods/ui 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/dist/index.d.mts +66 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +313 -0
- package/dist/index.mjs +270 -0
- package/package.json +56 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface Theme {
|
|
5
|
+
name: string;
|
|
6
|
+
colors: {
|
|
7
|
+
primary: string;
|
|
8
|
+
secondary: string;
|
|
9
|
+
accent: string;
|
|
10
|
+
background: string;
|
|
11
|
+
foreground: string;
|
|
12
|
+
muted: string;
|
|
13
|
+
border: string;
|
|
14
|
+
error: string;
|
|
15
|
+
success: string;
|
|
16
|
+
warning: string;
|
|
17
|
+
};
|
|
18
|
+
fonts: {
|
|
19
|
+
sans: string;
|
|
20
|
+
mono: string;
|
|
21
|
+
};
|
|
22
|
+
radii: {
|
|
23
|
+
sm: string;
|
|
24
|
+
md: string;
|
|
25
|
+
lg: string;
|
|
26
|
+
full: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare const themes: Record<string, Theme>;
|
|
30
|
+
interface ThemeProviderProps {
|
|
31
|
+
theme?: Theme | keyof typeof themes;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
declare function useTheme(): Theme;
|
|
36
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
37
|
+
variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive';
|
|
38
|
+
size?: 'sm' | 'md' | 'lg';
|
|
39
|
+
loading?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
42
|
+
interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
43
|
+
variant?: 'default' | 'elevated' | 'outlined';
|
|
44
|
+
}
|
|
45
|
+
declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
47
|
+
error?: string;
|
|
48
|
+
label?: string;
|
|
49
|
+
}
|
|
50
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
51
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
52
|
+
variant?: 'default' | 'primary' | 'success' | 'warning' | 'error';
|
|
53
|
+
}
|
|
54
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
55
|
+
interface SpinnerProps {
|
|
56
|
+
size?: 'sm' | 'md' | 'lg';
|
|
57
|
+
className?: string;
|
|
58
|
+
}
|
|
59
|
+
declare function Spinner({ size, className }: SpinnerProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
interface AvatarProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
61
|
+
size?: 'sm' | 'md' | 'lg';
|
|
62
|
+
fallback?: string;
|
|
63
|
+
}
|
|
64
|
+
declare function Avatar({ size, fallback, src, alt, className, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
|
|
65
|
+
|
|
66
|
+
export { Avatar, type AvatarProps, Badge, type BadgeProps, Button, type ButtonProps, Card, type CardProps, Input, type InputProps, Spinner, type SpinnerProps, type Theme, ThemeProvider, type ThemeProviderProps, themes, useTheme };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
interface Theme {
|
|
5
|
+
name: string;
|
|
6
|
+
colors: {
|
|
7
|
+
primary: string;
|
|
8
|
+
secondary: string;
|
|
9
|
+
accent: string;
|
|
10
|
+
background: string;
|
|
11
|
+
foreground: string;
|
|
12
|
+
muted: string;
|
|
13
|
+
border: string;
|
|
14
|
+
error: string;
|
|
15
|
+
success: string;
|
|
16
|
+
warning: string;
|
|
17
|
+
};
|
|
18
|
+
fonts: {
|
|
19
|
+
sans: string;
|
|
20
|
+
mono: string;
|
|
21
|
+
};
|
|
22
|
+
radii: {
|
|
23
|
+
sm: string;
|
|
24
|
+
md: string;
|
|
25
|
+
lg: string;
|
|
26
|
+
full: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare const themes: Record<string, Theme>;
|
|
30
|
+
interface ThemeProviderProps {
|
|
31
|
+
theme?: Theme | keyof typeof themes;
|
|
32
|
+
children: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
declare function ThemeProvider({ theme, children }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
|
|
35
|
+
declare function useTheme(): Theme;
|
|
36
|
+
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
37
|
+
variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive';
|
|
38
|
+
size?: 'sm' | 'md' | 'lg';
|
|
39
|
+
loading?: boolean;
|
|
40
|
+
}
|
|
41
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
42
|
+
interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
43
|
+
variant?: 'default' | 'elevated' | 'outlined';
|
|
44
|
+
}
|
|
45
|
+
declare const Card: React.ForwardRefExoticComponent<CardProps & React.RefAttributes<HTMLDivElement>>;
|
|
46
|
+
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
47
|
+
error?: string;
|
|
48
|
+
label?: string;
|
|
49
|
+
}
|
|
50
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
51
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
52
|
+
variant?: 'default' | 'primary' | 'success' | 'warning' | 'error';
|
|
53
|
+
}
|
|
54
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
55
|
+
interface SpinnerProps {
|
|
56
|
+
size?: 'sm' | 'md' | 'lg';
|
|
57
|
+
className?: string;
|
|
58
|
+
}
|
|
59
|
+
declare function Spinner({ size, className }: SpinnerProps): react_jsx_runtime.JSX.Element;
|
|
60
|
+
interface AvatarProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
61
|
+
size?: 'sm' | 'md' | 'lg';
|
|
62
|
+
fallback?: string;
|
|
63
|
+
}
|
|
64
|
+
declare function Avatar({ size, fallback, src, alt, className, ...props }: AvatarProps): react_jsx_runtime.JSX.Element;
|
|
65
|
+
|
|
66
|
+
export { Avatar, type AvatarProps, Badge, type BadgeProps, Button, type ButtonProps, Card, type CardProps, Input, type InputProps, Spinner, type SpinnerProps, type Theme, ThemeProvider, type ThemeProviderProps, themes, useTheme };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
Avatar: () => Avatar,
|
|
34
|
+
Badge: () => Badge,
|
|
35
|
+
Button: () => Button,
|
|
36
|
+
Card: () => Card,
|
|
37
|
+
Input: () => Input,
|
|
38
|
+
Spinner: () => Spinner,
|
|
39
|
+
ThemeProvider: () => ThemeProvider,
|
|
40
|
+
themes: () => themes,
|
|
41
|
+
useTheme: () => useTheme
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(index_exports);
|
|
44
|
+
var React = __toESM(require("react"));
|
|
45
|
+
var import_clsx = require("clsx");
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var themes = {
|
|
48
|
+
yarlis: {
|
|
49
|
+
name: "yarlis",
|
|
50
|
+
colors: {
|
|
51
|
+
primary: "#316FA7",
|
|
52
|
+
secondary: "#7C3AED",
|
|
53
|
+
accent: "#06B6D4",
|
|
54
|
+
background: "#0F172A",
|
|
55
|
+
foreground: "#F8FAFC",
|
|
56
|
+
muted: "#64748B",
|
|
57
|
+
border: "#334155",
|
|
58
|
+
error: "#EF4444",
|
|
59
|
+
success: "#22C55E",
|
|
60
|
+
warning: "#F59E0B"
|
|
61
|
+
},
|
|
62
|
+
fonts: {
|
|
63
|
+
sans: "Inter, system-ui, sans-serif",
|
|
64
|
+
mono: "JetBrains Mono, monospace"
|
|
65
|
+
},
|
|
66
|
+
radii: {
|
|
67
|
+
sm: "0.25rem",
|
|
68
|
+
md: "0.5rem",
|
|
69
|
+
lg: "1rem",
|
|
70
|
+
full: "9999px"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
light: {
|
|
74
|
+
name: "light",
|
|
75
|
+
colors: {
|
|
76
|
+
primary: "#2563EB",
|
|
77
|
+
secondary: "#7C3AED",
|
|
78
|
+
accent: "#06B6D4",
|
|
79
|
+
background: "#FFFFFF",
|
|
80
|
+
foreground: "#0F172A",
|
|
81
|
+
muted: "#64748B",
|
|
82
|
+
border: "#E2E8F0",
|
|
83
|
+
error: "#EF4444",
|
|
84
|
+
success: "#22C55E",
|
|
85
|
+
warning: "#F59E0B"
|
|
86
|
+
},
|
|
87
|
+
fonts: {
|
|
88
|
+
sans: "Inter, system-ui, sans-serif",
|
|
89
|
+
mono: "JetBrains Mono, monospace"
|
|
90
|
+
},
|
|
91
|
+
radii: {
|
|
92
|
+
sm: "0.25rem",
|
|
93
|
+
md: "0.5rem",
|
|
94
|
+
lg: "1rem",
|
|
95
|
+
full: "9999px"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
var ThemeContext = React.createContext(themes.yarlis);
|
|
100
|
+
function ThemeProvider({ theme = "yarlis", children }) {
|
|
101
|
+
const resolvedTheme = typeof theme === "string" ? themes[theme] : theme;
|
|
102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
|
+
"div",
|
|
104
|
+
{
|
|
105
|
+
style: {
|
|
106
|
+
"--color-primary": resolvedTheme.colors.primary,
|
|
107
|
+
"--color-secondary": resolvedTheme.colors.secondary,
|
|
108
|
+
"--color-accent": resolvedTheme.colors.accent,
|
|
109
|
+
"--color-background": resolvedTheme.colors.background,
|
|
110
|
+
"--color-foreground": resolvedTheme.colors.foreground,
|
|
111
|
+
"--color-muted": resolvedTheme.colors.muted,
|
|
112
|
+
"--color-border": resolvedTheme.colors.border,
|
|
113
|
+
"--color-error": resolvedTheme.colors.error,
|
|
114
|
+
"--color-success": resolvedTheme.colors.success,
|
|
115
|
+
"--color-warning": resolvedTheme.colors.warning,
|
|
116
|
+
"--font-sans": resolvedTheme.fonts.sans,
|
|
117
|
+
"--font-mono": resolvedTheme.fonts.mono,
|
|
118
|
+
"--radius-sm": resolvedTheme.radii.sm,
|
|
119
|
+
"--radius-md": resolvedTheme.radii.md,
|
|
120
|
+
"--radius-lg": resolvedTheme.radii.lg,
|
|
121
|
+
"--radius-full": resolvedTheme.radii.full
|
|
122
|
+
},
|
|
123
|
+
children
|
|
124
|
+
}
|
|
125
|
+
) });
|
|
126
|
+
}
|
|
127
|
+
function useTheme() {
|
|
128
|
+
return React.useContext(ThemeContext);
|
|
129
|
+
}
|
|
130
|
+
var Button = React.forwardRef(
|
|
131
|
+
({ variant = "primary", size = "md", loading, className, children, disabled, ...props }, ref) => {
|
|
132
|
+
const baseStyles = "inline-flex items-center justify-center font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none";
|
|
133
|
+
const variants = {
|
|
134
|
+
primary: "bg-[var(--color-primary)] text-white hover:opacity-90 focus:ring-[var(--color-primary)]",
|
|
135
|
+
secondary: "bg-[var(--color-secondary)] text-white hover:opacity-90 focus:ring-[var(--color-secondary)]",
|
|
136
|
+
outline: "border border-[var(--color-border)] bg-transparent hover:bg-[var(--color-muted)]/10",
|
|
137
|
+
ghost: "bg-transparent hover:bg-[var(--color-muted)]/10",
|
|
138
|
+
destructive: "bg-[var(--color-error)] text-white hover:opacity-90 focus:ring-[var(--color-error)]"
|
|
139
|
+
};
|
|
140
|
+
const sizes = {
|
|
141
|
+
sm: "h-8 px-3 text-sm rounded-[var(--radius-sm)]",
|
|
142
|
+
md: "h-10 px-4 text-base rounded-[var(--radius-md)]",
|
|
143
|
+
lg: "h-12 px-6 text-lg rounded-[var(--radius-md)]"
|
|
144
|
+
};
|
|
145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
146
|
+
"button",
|
|
147
|
+
{
|
|
148
|
+
ref,
|
|
149
|
+
className: (0, import_clsx.clsx)(baseStyles, variants[variant], sizes[size], className),
|
|
150
|
+
disabled: disabled || loading,
|
|
151
|
+
...props,
|
|
152
|
+
children: [
|
|
153
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", fill: "none", viewBox: "0 0 24 24", children: [
|
|
154
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
156
|
+
] }),
|
|
157
|
+
children
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
Button.displayName = "Button";
|
|
164
|
+
var Card = React.forwardRef(
|
|
165
|
+
({ variant = "default", className, children, ...props }, ref) => {
|
|
166
|
+
const variants = {
|
|
167
|
+
default: "bg-[var(--color-background)] border border-[var(--color-border)]",
|
|
168
|
+
elevated: "bg-[var(--color-background)] shadow-lg",
|
|
169
|
+
outlined: "bg-transparent border-2 border-[var(--color-border)]"
|
|
170
|
+
};
|
|
171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
ref,
|
|
175
|
+
className: (0, import_clsx.clsx)(
|
|
176
|
+
"rounded-[var(--radius-lg)] p-6",
|
|
177
|
+
variants[variant],
|
|
178
|
+
className
|
|
179
|
+
),
|
|
180
|
+
...props,
|
|
181
|
+
children
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
Card.displayName = "Card";
|
|
187
|
+
var Input = React.forwardRef(
|
|
188
|
+
({ error, label, className, id, ...props }, ref) => {
|
|
189
|
+
const inputId = id || React.useId();
|
|
190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
191
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: inputId, className: "text-sm font-medium text-[var(--color-foreground)]", children: label }),
|
|
192
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
+
"input",
|
|
194
|
+
{
|
|
195
|
+
ref,
|
|
196
|
+
id: inputId,
|
|
197
|
+
className: (0, import_clsx.clsx)(
|
|
198
|
+
"h-10 px-3 rounded-[var(--radius-md)] border bg-[var(--color-background)] text-[var(--color-foreground)]",
|
|
199
|
+
"focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)]",
|
|
200
|
+
error ? "border-[var(--color-error)]" : "border-[var(--color-border)]",
|
|
201
|
+
className
|
|
202
|
+
),
|
|
203
|
+
...props
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-sm text-[var(--color-error)]", children: error })
|
|
207
|
+
] });
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
Input.displayName = "Input";
|
|
211
|
+
var Badge = React.forwardRef(
|
|
212
|
+
({ variant = "default", className, ...props }, ref) => {
|
|
213
|
+
const variants = {
|
|
214
|
+
default: "bg-[var(--color-muted)]/20 text-[var(--color-foreground)]",
|
|
215
|
+
primary: "bg-[var(--color-primary)]/20 text-[var(--color-primary)]",
|
|
216
|
+
success: "bg-[var(--color-success)]/20 text-[var(--color-success)]",
|
|
217
|
+
warning: "bg-[var(--color-warning)]/20 text-[var(--color-warning)]",
|
|
218
|
+
error: "bg-[var(--color-error)]/20 text-[var(--color-error)]"
|
|
219
|
+
};
|
|
220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
221
|
+
"span",
|
|
222
|
+
{
|
|
223
|
+
ref,
|
|
224
|
+
className: (0, import_clsx.clsx)(
|
|
225
|
+
"inline-flex items-center px-2 py-1 text-xs font-medium rounded-[var(--radius-full)]",
|
|
226
|
+
variants[variant],
|
|
227
|
+
className
|
|
228
|
+
),
|
|
229
|
+
...props
|
|
230
|
+
}
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
Badge.displayName = "Badge";
|
|
235
|
+
function Spinner({ size = "md", className }) {
|
|
236
|
+
const sizes = {
|
|
237
|
+
sm: "h-4 w-4",
|
|
238
|
+
md: "h-8 w-8",
|
|
239
|
+
lg: "h-12 w-12"
|
|
240
|
+
};
|
|
241
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
242
|
+
"svg",
|
|
243
|
+
{
|
|
244
|
+
className: (0, import_clsx.clsx)("animate-spin text-[var(--color-primary)]", sizes[size], className),
|
|
245
|
+
fill: "none",
|
|
246
|
+
viewBox: "0 0 24 24",
|
|
247
|
+
children: [
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
249
|
+
"circle",
|
|
250
|
+
{
|
|
251
|
+
className: "opacity-25",
|
|
252
|
+
cx: "12",
|
|
253
|
+
cy: "12",
|
|
254
|
+
r: "10",
|
|
255
|
+
stroke: "currentColor",
|
|
256
|
+
strokeWidth: "4"
|
|
257
|
+
}
|
|
258
|
+
),
|
|
259
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
260
|
+
"path",
|
|
261
|
+
{
|
|
262
|
+
className: "opacity-75",
|
|
263
|
+
fill: "currentColor",
|
|
264
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
]
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
function Avatar({ size = "md", fallback, src, alt, className, ...props }) {
|
|
272
|
+
const [error, setError] = React.useState(false);
|
|
273
|
+
const sizes = {
|
|
274
|
+
sm: "h-8 w-8 text-xs",
|
|
275
|
+
md: "h-10 w-10 text-sm",
|
|
276
|
+
lg: "h-16 w-16 text-lg"
|
|
277
|
+
};
|
|
278
|
+
if (error || !src) {
|
|
279
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
280
|
+
"div",
|
|
281
|
+
{
|
|
282
|
+
className: (0, import_clsx.clsx)(
|
|
283
|
+
"flex items-center justify-center rounded-[var(--radius-full)] bg-[var(--color-primary)] text-white font-medium",
|
|
284
|
+
sizes[size],
|
|
285
|
+
className
|
|
286
|
+
),
|
|
287
|
+
children: fallback || alt?.charAt(0).toUpperCase() || "?"
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
292
|
+
"img",
|
|
293
|
+
{
|
|
294
|
+
src,
|
|
295
|
+
alt,
|
|
296
|
+
onError: () => setError(true),
|
|
297
|
+
className: (0, import_clsx.clsx)("rounded-[var(--radius-full)] object-cover", sizes[size], className),
|
|
298
|
+
...props
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
303
|
+
0 && (module.exports = {
|
|
304
|
+
Avatar,
|
|
305
|
+
Badge,
|
|
306
|
+
Button,
|
|
307
|
+
Card,
|
|
308
|
+
Input,
|
|
309
|
+
Spinner,
|
|
310
|
+
ThemeProvider,
|
|
311
|
+
themes,
|
|
312
|
+
useTheme
|
|
313
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { clsx } from "clsx";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var themes = {
|
|
6
|
+
yarlis: {
|
|
7
|
+
name: "yarlis",
|
|
8
|
+
colors: {
|
|
9
|
+
primary: "#316FA7",
|
|
10
|
+
secondary: "#7C3AED",
|
|
11
|
+
accent: "#06B6D4",
|
|
12
|
+
background: "#0F172A",
|
|
13
|
+
foreground: "#F8FAFC",
|
|
14
|
+
muted: "#64748B",
|
|
15
|
+
border: "#334155",
|
|
16
|
+
error: "#EF4444",
|
|
17
|
+
success: "#22C55E",
|
|
18
|
+
warning: "#F59E0B"
|
|
19
|
+
},
|
|
20
|
+
fonts: {
|
|
21
|
+
sans: "Inter, system-ui, sans-serif",
|
|
22
|
+
mono: "JetBrains Mono, monospace"
|
|
23
|
+
},
|
|
24
|
+
radii: {
|
|
25
|
+
sm: "0.25rem",
|
|
26
|
+
md: "0.5rem",
|
|
27
|
+
lg: "1rem",
|
|
28
|
+
full: "9999px"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
light: {
|
|
32
|
+
name: "light",
|
|
33
|
+
colors: {
|
|
34
|
+
primary: "#2563EB",
|
|
35
|
+
secondary: "#7C3AED",
|
|
36
|
+
accent: "#06B6D4",
|
|
37
|
+
background: "#FFFFFF",
|
|
38
|
+
foreground: "#0F172A",
|
|
39
|
+
muted: "#64748B",
|
|
40
|
+
border: "#E2E8F0",
|
|
41
|
+
error: "#EF4444",
|
|
42
|
+
success: "#22C55E",
|
|
43
|
+
warning: "#F59E0B"
|
|
44
|
+
},
|
|
45
|
+
fonts: {
|
|
46
|
+
sans: "Inter, system-ui, sans-serif",
|
|
47
|
+
mono: "JetBrains Mono, monospace"
|
|
48
|
+
},
|
|
49
|
+
radii: {
|
|
50
|
+
sm: "0.25rem",
|
|
51
|
+
md: "0.5rem",
|
|
52
|
+
lg: "1rem",
|
|
53
|
+
full: "9999px"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var ThemeContext = React.createContext(themes.yarlis);
|
|
58
|
+
function ThemeProvider({ theme = "yarlis", children }) {
|
|
59
|
+
const resolvedTheme = typeof theme === "string" ? themes[theme] : theme;
|
|
60
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
style: {
|
|
64
|
+
"--color-primary": resolvedTheme.colors.primary,
|
|
65
|
+
"--color-secondary": resolvedTheme.colors.secondary,
|
|
66
|
+
"--color-accent": resolvedTheme.colors.accent,
|
|
67
|
+
"--color-background": resolvedTheme.colors.background,
|
|
68
|
+
"--color-foreground": resolvedTheme.colors.foreground,
|
|
69
|
+
"--color-muted": resolvedTheme.colors.muted,
|
|
70
|
+
"--color-border": resolvedTheme.colors.border,
|
|
71
|
+
"--color-error": resolvedTheme.colors.error,
|
|
72
|
+
"--color-success": resolvedTheme.colors.success,
|
|
73
|
+
"--color-warning": resolvedTheme.colors.warning,
|
|
74
|
+
"--font-sans": resolvedTheme.fonts.sans,
|
|
75
|
+
"--font-mono": resolvedTheme.fonts.mono,
|
|
76
|
+
"--radius-sm": resolvedTheme.radii.sm,
|
|
77
|
+
"--radius-md": resolvedTheme.radii.md,
|
|
78
|
+
"--radius-lg": resolvedTheme.radii.lg,
|
|
79
|
+
"--radius-full": resolvedTheme.radii.full
|
|
80
|
+
},
|
|
81
|
+
children
|
|
82
|
+
}
|
|
83
|
+
) });
|
|
84
|
+
}
|
|
85
|
+
function useTheme() {
|
|
86
|
+
return React.useContext(ThemeContext);
|
|
87
|
+
}
|
|
88
|
+
var Button = React.forwardRef(
|
|
89
|
+
({ variant = "primary", size = "md", loading, className, children, disabled, ...props }, ref) => {
|
|
90
|
+
const baseStyles = "inline-flex items-center justify-center font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none";
|
|
91
|
+
const variants = {
|
|
92
|
+
primary: "bg-[var(--color-primary)] text-white hover:opacity-90 focus:ring-[var(--color-primary)]",
|
|
93
|
+
secondary: "bg-[var(--color-secondary)] text-white hover:opacity-90 focus:ring-[var(--color-secondary)]",
|
|
94
|
+
outline: "border border-[var(--color-border)] bg-transparent hover:bg-[var(--color-muted)]/10",
|
|
95
|
+
ghost: "bg-transparent hover:bg-[var(--color-muted)]/10",
|
|
96
|
+
destructive: "bg-[var(--color-error)] text-white hover:opacity-90 focus:ring-[var(--color-error)]"
|
|
97
|
+
};
|
|
98
|
+
const sizes = {
|
|
99
|
+
sm: "h-8 px-3 text-sm rounded-[var(--radius-sm)]",
|
|
100
|
+
md: "h-10 px-4 text-base rounded-[var(--radius-md)]",
|
|
101
|
+
lg: "h-12 px-6 text-lg rounded-[var(--radius-md)]"
|
|
102
|
+
};
|
|
103
|
+
return /* @__PURE__ */ jsxs(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
ref,
|
|
107
|
+
className: clsx(baseStyles, variants[variant], sizes[size], className),
|
|
108
|
+
disabled: disabled || loading,
|
|
109
|
+
...props,
|
|
110
|
+
children: [
|
|
111
|
+
loading && /* @__PURE__ */ jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4", fill: "none", viewBox: "0 0 24 24", children: [
|
|
112
|
+
/* @__PURE__ */ jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
113
|
+
/* @__PURE__ */ jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z" })
|
|
114
|
+
] }),
|
|
115
|
+
children
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
Button.displayName = "Button";
|
|
122
|
+
var Card = React.forwardRef(
|
|
123
|
+
({ variant = "default", className, children, ...props }, ref) => {
|
|
124
|
+
const variants = {
|
|
125
|
+
default: "bg-[var(--color-background)] border border-[var(--color-border)]",
|
|
126
|
+
elevated: "bg-[var(--color-background)] shadow-lg",
|
|
127
|
+
outlined: "bg-transparent border-2 border-[var(--color-border)]"
|
|
128
|
+
};
|
|
129
|
+
return /* @__PURE__ */ jsx(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
ref,
|
|
133
|
+
className: clsx(
|
|
134
|
+
"rounded-[var(--radius-lg)] p-6",
|
|
135
|
+
variants[variant],
|
|
136
|
+
className
|
|
137
|
+
),
|
|
138
|
+
...props,
|
|
139
|
+
children
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
Card.displayName = "Card";
|
|
145
|
+
var Input = React.forwardRef(
|
|
146
|
+
({ error, label, className, id, ...props }, ref) => {
|
|
147
|
+
const inputId = id || React.useId();
|
|
148
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
149
|
+
label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "text-sm font-medium text-[var(--color-foreground)]", children: label }),
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
"input",
|
|
152
|
+
{
|
|
153
|
+
ref,
|
|
154
|
+
id: inputId,
|
|
155
|
+
className: clsx(
|
|
156
|
+
"h-10 px-3 rounded-[var(--radius-md)] border bg-[var(--color-background)] text-[var(--color-foreground)]",
|
|
157
|
+
"focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)]",
|
|
158
|
+
error ? "border-[var(--color-error)]" : "border-[var(--color-border)]",
|
|
159
|
+
className
|
|
160
|
+
),
|
|
161
|
+
...props
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
error && /* @__PURE__ */ jsx("span", { className: "text-sm text-[var(--color-error)]", children: error })
|
|
165
|
+
] });
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
Input.displayName = "Input";
|
|
169
|
+
var Badge = React.forwardRef(
|
|
170
|
+
({ variant = "default", className, ...props }, ref) => {
|
|
171
|
+
const variants = {
|
|
172
|
+
default: "bg-[var(--color-muted)]/20 text-[var(--color-foreground)]",
|
|
173
|
+
primary: "bg-[var(--color-primary)]/20 text-[var(--color-primary)]",
|
|
174
|
+
success: "bg-[var(--color-success)]/20 text-[var(--color-success)]",
|
|
175
|
+
warning: "bg-[var(--color-warning)]/20 text-[var(--color-warning)]",
|
|
176
|
+
error: "bg-[var(--color-error)]/20 text-[var(--color-error)]"
|
|
177
|
+
};
|
|
178
|
+
return /* @__PURE__ */ jsx(
|
|
179
|
+
"span",
|
|
180
|
+
{
|
|
181
|
+
ref,
|
|
182
|
+
className: clsx(
|
|
183
|
+
"inline-flex items-center px-2 py-1 text-xs font-medium rounded-[var(--radius-full)]",
|
|
184
|
+
variants[variant],
|
|
185
|
+
className
|
|
186
|
+
),
|
|
187
|
+
...props
|
|
188
|
+
}
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
Badge.displayName = "Badge";
|
|
193
|
+
function Spinner({ size = "md", className }) {
|
|
194
|
+
const sizes = {
|
|
195
|
+
sm: "h-4 w-4",
|
|
196
|
+
md: "h-8 w-8",
|
|
197
|
+
lg: "h-12 w-12"
|
|
198
|
+
};
|
|
199
|
+
return /* @__PURE__ */ jsxs(
|
|
200
|
+
"svg",
|
|
201
|
+
{
|
|
202
|
+
className: clsx("animate-spin text-[var(--color-primary)]", sizes[size], className),
|
|
203
|
+
fill: "none",
|
|
204
|
+
viewBox: "0 0 24 24",
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsx(
|
|
207
|
+
"circle",
|
|
208
|
+
{
|
|
209
|
+
className: "opacity-25",
|
|
210
|
+
cx: "12",
|
|
211
|
+
cy: "12",
|
|
212
|
+
r: "10",
|
|
213
|
+
stroke: "currentColor",
|
|
214
|
+
strokeWidth: "4"
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ jsx(
|
|
218
|
+
"path",
|
|
219
|
+
{
|
|
220
|
+
className: "opacity-75",
|
|
221
|
+
fill: "currentColor",
|
|
222
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
function Avatar({ size = "md", fallback, src, alt, className, ...props }) {
|
|
230
|
+
const [error, setError] = React.useState(false);
|
|
231
|
+
const sizes = {
|
|
232
|
+
sm: "h-8 w-8 text-xs",
|
|
233
|
+
md: "h-10 w-10 text-sm",
|
|
234
|
+
lg: "h-16 w-16 text-lg"
|
|
235
|
+
};
|
|
236
|
+
if (error || !src) {
|
|
237
|
+
return /* @__PURE__ */ jsx(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
className: clsx(
|
|
241
|
+
"flex items-center justify-center rounded-[var(--radius-full)] bg-[var(--color-primary)] text-white font-medium",
|
|
242
|
+
sizes[size],
|
|
243
|
+
className
|
|
244
|
+
),
|
|
245
|
+
children: fallback || alt?.charAt(0).toUpperCase() || "?"
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
return /* @__PURE__ */ jsx(
|
|
250
|
+
"img",
|
|
251
|
+
{
|
|
252
|
+
src,
|
|
253
|
+
alt,
|
|
254
|
+
onError: () => setError(true),
|
|
255
|
+
className: clsx("rounded-[var(--radius-full)] object-cover", sizes[size], className),
|
|
256
|
+
...props
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
export {
|
|
261
|
+
Avatar,
|
|
262
|
+
Badge,
|
|
263
|
+
Button,
|
|
264
|
+
Card,
|
|
265
|
+
Input,
|
|
266
|
+
Spinner,
|
|
267
|
+
ThemeProvider,
|
|
268
|
+
themes,
|
|
269
|
+
useTheme
|
|
270
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sdods/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React component library with theming",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
},
|
|
14
|
+
"./styles.css": "./dist/styles.css"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"**/*.css"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup src/index.tsx --format cjs,esm --dts --external react",
|
|
24
|
+
"dev": "tsup src/index.tsx --format cjs,esm --dts --watch --external react",
|
|
25
|
+
"test": "vitest",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"clean": "rm -rf dist"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@sdods/core": "workspace:*",
|
|
31
|
+
"clsx": "^2.1.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": ">=18.0.0",
|
|
35
|
+
"react-dom": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/react": "^18.2.0",
|
|
39
|
+
"@types/react-dom": "^18.2.0",
|
|
40
|
+
"react": "^18.2.0",
|
|
41
|
+
"react-dom": "^18.2.0",
|
|
42
|
+
"tsup": "^8.0.0",
|
|
43
|
+
"typescript": "^5.4.0",
|
|
44
|
+
"vitest": "^2.0.0"
|
|
45
|
+
},
|
|
46
|
+
"keywords": ["sdods", "ui", "react", "components", "design-system"],
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/siri1410/sdods.git",
|
|
51
|
+
"directory": "packages/ui"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|