@limetry/ui 1.2.49
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 +36 -0
- package/dist/index.cjs +464 -0
- package/dist/index.d.cts +504 -0
- package/dist/index.d.ts +504 -0
- package/dist/index.js +421 -0
- package/package.json +75 -0
- package/src/components/badge.tsx +66 -0
- package/src/components/button.tsx +117 -0
- package/src/components/card.tsx +89 -0
- package/src/components/drawer-menu.tsx +252 -0
- package/src/components/drawer-menu.types.ts +87 -0
- package/src/components/drawer-menu.web.tsx +348 -0
- package/src/components/icons.tsx +164 -0
- package/src/components/icons.web.tsx +141 -0
- package/src/components/input.tsx +143 -0
- package/src/components/page-header.tsx +142 -0
- package/src/components/stat-card.tsx +81 -0
- package/src/global.css +82 -0
- package/src/index.ts +39 -0
- package/src/lib/cn.ts +15 -0
- package/src/navigation/types.test.ts +72 -0
- package/src/navigation/types.ts +152 -0
- package/tailwind.config.ts +97 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
// src/components/badge.tsx
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
|
|
4
|
+
// src/lib/cn.ts
|
|
5
|
+
import { clsx } from "clsx";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/components/badge.tsx
|
|
12
|
+
import { jsx } from "nativewind/jsx-runtime";
|
|
13
|
+
var variantStyles = {
|
|
14
|
+
default: "bg-slate-100 dark:bg-slate-800",
|
|
15
|
+
success: "bg-emerald-500/15 dark:bg-emerald-500/20",
|
|
16
|
+
warning: "bg-amber-500/15 dark:bg-amber-500/20",
|
|
17
|
+
error: "bg-red-500/15 dark:bg-red-500/20",
|
|
18
|
+
outline: "bg-transparent border border-slate-200 dark:border-slate-700"
|
|
19
|
+
};
|
|
20
|
+
var textVariantStyles = {
|
|
21
|
+
default: "text-slate-600 dark:text-slate-300",
|
|
22
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
23
|
+
warning: "text-amber-600 dark:text-amber-400",
|
|
24
|
+
error: "text-red-600 dark:text-red-400",
|
|
25
|
+
outline: "text-slate-900 dark:text-slate-100"
|
|
26
|
+
};
|
|
27
|
+
function Badge({
|
|
28
|
+
children,
|
|
29
|
+
variant = "default",
|
|
30
|
+
className
|
|
31
|
+
}) {
|
|
32
|
+
return /* @__PURE__ */ jsx(View, { className: cn("self-start rounded-full px-2.5 py-1", variantStyles[variant], className), children: /* @__PURE__ */ jsx(Text, { className: cn("text-xs font-medium", textVariantStyles[variant]), children }) });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/components/button.tsx
|
|
36
|
+
import { Pressable, Text as Text2 } from "react-native";
|
|
37
|
+
import { jsx as jsx2 } from "nativewind/jsx-runtime";
|
|
38
|
+
var variantStyles2 = {
|
|
39
|
+
primary: "bg-emerald-500 active:bg-emerald-600 dark:bg-emerald-500 dark:active:bg-emerald-600",
|
|
40
|
+
secondary: "bg-slate-100 active:bg-slate-200 dark:bg-slate-800 dark:active:bg-slate-700",
|
|
41
|
+
ghost: "bg-transparent active:bg-slate-100 dark:active:bg-slate-800",
|
|
42
|
+
destructive: "bg-red-500 active:opacity-90 dark:bg-red-600",
|
|
43
|
+
outline: "bg-transparent border border-slate-300 active:bg-slate-50 dark:border-slate-700 dark:active:bg-slate-800"
|
|
44
|
+
};
|
|
45
|
+
var textVariantStyles2 = {
|
|
46
|
+
primary: "text-white font-semibold",
|
|
47
|
+
secondary: "text-slate-900 font-medium dark:text-slate-100",
|
|
48
|
+
ghost: "text-slate-900 font-medium dark:text-slate-100",
|
|
49
|
+
destructive: "text-white font-semibold",
|
|
50
|
+
outline: "text-slate-900 font-medium dark:text-slate-100"
|
|
51
|
+
};
|
|
52
|
+
var sizeStyles = {
|
|
53
|
+
sm: "px-3 py-1.5 rounded-lg",
|
|
54
|
+
md: "px-4 py-2.5 rounded-xl",
|
|
55
|
+
lg: "px-6 py-3.5 rounded-xl"
|
|
56
|
+
};
|
|
57
|
+
var textSizeStyles = {
|
|
58
|
+
sm: "text-sm",
|
|
59
|
+
md: "text-base",
|
|
60
|
+
lg: "text-lg"
|
|
61
|
+
};
|
|
62
|
+
function Button({
|
|
63
|
+
children,
|
|
64
|
+
variant = "primary",
|
|
65
|
+
size = "md",
|
|
66
|
+
className,
|
|
67
|
+
textClassName,
|
|
68
|
+
disabled,
|
|
69
|
+
...props
|
|
70
|
+
}) {
|
|
71
|
+
return /* @__PURE__ */ jsx2(
|
|
72
|
+
Pressable,
|
|
73
|
+
{
|
|
74
|
+
accessibilityRole: "button",
|
|
75
|
+
className: cn(
|
|
76
|
+
"flex-row items-center justify-center",
|
|
77
|
+
variantStyles2[variant],
|
|
78
|
+
sizeStyles[size],
|
|
79
|
+
disabled && "opacity-50",
|
|
80
|
+
className
|
|
81
|
+
),
|
|
82
|
+
disabled,
|
|
83
|
+
...props,
|
|
84
|
+
children: typeof children === "string" ? /* @__PURE__ */ jsx2(
|
|
85
|
+
Text2,
|
|
86
|
+
{
|
|
87
|
+
className: cn(
|
|
88
|
+
textVariantStyles2[variant],
|
|
89
|
+
textSizeStyles[size],
|
|
90
|
+
textClassName
|
|
91
|
+
),
|
|
92
|
+
children
|
|
93
|
+
}
|
|
94
|
+
) : children
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/components/card.tsx
|
|
100
|
+
import { Text as Text3, View as View2 } from "react-native";
|
|
101
|
+
import { jsx as jsx3, jsxs } from "nativewind/jsx-runtime";
|
|
102
|
+
function Card({ children, className, ...props }) {
|
|
103
|
+
return /* @__PURE__ */ jsx3(
|
|
104
|
+
View2,
|
|
105
|
+
{
|
|
106
|
+
className: cn(
|
|
107
|
+
"rounded-2xl min-h-[88px] border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
|
|
108
|
+
className
|
|
109
|
+
),
|
|
110
|
+
...props,
|
|
111
|
+
children
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function CardHeader({
|
|
116
|
+
title,
|
|
117
|
+
description,
|
|
118
|
+
action,
|
|
119
|
+
className
|
|
120
|
+
}) {
|
|
121
|
+
return /* @__PURE__ */ jsxs(View2, { className: cn("mb-4 flex-row items-start justify-between", className), children: [
|
|
122
|
+
/* @__PURE__ */ jsxs(View2, { className: "flex-1 pr-3", children: [
|
|
123
|
+
/* @__PURE__ */ jsx3(Text3, { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: title }),
|
|
124
|
+
description ? /* @__PURE__ */ jsx3(Text3, { className: "mt-1 text-sm text-slate-500 dark:text-slate-400", children: description }) : null
|
|
125
|
+
] }),
|
|
126
|
+
action
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/components/icons.tsx
|
|
131
|
+
import {
|
|
132
|
+
BarChart,
|
|
133
|
+
Home,
|
|
134
|
+
Key,
|
|
135
|
+
Menu,
|
|
136
|
+
Shield,
|
|
137
|
+
Terminal,
|
|
138
|
+
User,
|
|
139
|
+
X,
|
|
140
|
+
Zap
|
|
141
|
+
} from "lucide-react-native";
|
|
142
|
+
import { useColorScheme } from "nativewind";
|
|
143
|
+
import { View as View3 } from "react-native";
|
|
144
|
+
import { jsx as jsx4 } from "nativewind/jsx-runtime";
|
|
145
|
+
function getColorFromClass(className, isDark) {
|
|
146
|
+
if (!className) return isDark ? "#ffffff" : "#0f172a";
|
|
147
|
+
if (className.includes("text-emerald-500")) return "#10B981";
|
|
148
|
+
if (className.includes("text-slate-400")) return "#94A3B8";
|
|
149
|
+
if (className.includes("text-slate-900")) return "#0f172a";
|
|
150
|
+
if (className.includes("text-slate-100")) return "#ffffff";
|
|
151
|
+
if (className.includes("dark:text-slate-100")) return isDark ? "#ffffff" : "#0f172a";
|
|
152
|
+
if (className.includes("dark:text-slate-500")) return isDark ? "#6B7280" : "#94A3B8";
|
|
153
|
+
return isDark ? "#ffffff" : "#0f172a";
|
|
154
|
+
}
|
|
155
|
+
function NativeIcon({
|
|
156
|
+
Icon,
|
|
157
|
+
className
|
|
158
|
+
}) {
|
|
159
|
+
const { colorScheme } = useColorScheme();
|
|
160
|
+
const isDark = colorScheme === "dark";
|
|
161
|
+
const color = getColorFromClass(className, isDark);
|
|
162
|
+
return /* @__PURE__ */ jsx4(View3, { className: cn("h-6 w-6 items-center justify-center", className), children: /* @__PURE__ */ jsx4(Icon, { color, size: 20 }) });
|
|
163
|
+
}
|
|
164
|
+
function ShieldIcon({ className }) {
|
|
165
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: Shield, className });
|
|
166
|
+
}
|
|
167
|
+
function KeyIcon({ className }) {
|
|
168
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: Key, className });
|
|
169
|
+
}
|
|
170
|
+
function RulesIcon({ className }) {
|
|
171
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: Zap, className });
|
|
172
|
+
}
|
|
173
|
+
function ChartIcon({ className }) {
|
|
174
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: BarChart, className });
|
|
175
|
+
}
|
|
176
|
+
function UserIcon({ className }) {
|
|
177
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: User, className });
|
|
178
|
+
}
|
|
179
|
+
function HomeIcon({ className }) {
|
|
180
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: Home, className });
|
|
181
|
+
}
|
|
182
|
+
function TerminalIcon({ className }) {
|
|
183
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: Terminal, className });
|
|
184
|
+
}
|
|
185
|
+
function MenuIcon({ className }) {
|
|
186
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: Menu, className });
|
|
187
|
+
}
|
|
188
|
+
function XIcon({ className }) {
|
|
189
|
+
return /* @__PURE__ */ jsx4(NativeIcon, { Icon: X, className });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/components/input.tsx
|
|
193
|
+
import { Text as Text4, TextInput, View as View4 } from "react-native";
|
|
194
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "nativewind/jsx-runtime";
|
|
195
|
+
function Input({
|
|
196
|
+
label,
|
|
197
|
+
hint,
|
|
198
|
+
error,
|
|
199
|
+
containerClassName,
|
|
200
|
+
className,
|
|
201
|
+
editable = true,
|
|
202
|
+
...props
|
|
203
|
+
}) {
|
|
204
|
+
return /* @__PURE__ */ jsxs2(View4, { className: cn("mb-4", containerClassName), children: [
|
|
205
|
+
label ? /* @__PURE__ */ jsx5(Text4, { className: "mb-2 text-sm font-medium text-slate-900 dark:text-slate-100", children: label }) : null,
|
|
206
|
+
/* @__PURE__ */ jsx5(
|
|
207
|
+
TextInput,
|
|
208
|
+
{
|
|
209
|
+
className: cn(
|
|
210
|
+
"rounded-xl border border-slate-200 bg-slate-50 px-4 py-3 text-base text-slate-900 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100",
|
|
211
|
+
!editable && "opacity-60",
|
|
212
|
+
error && "border-red-500 dark:border-red-500",
|
|
213
|
+
className
|
|
214
|
+
),
|
|
215
|
+
editable,
|
|
216
|
+
placeholderTextColor: "#94a3b8",
|
|
217
|
+
...props
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
error ? /* @__PURE__ */ jsx5(Text4, { className: "mt-1.5 text-xs text-red-500 dark:text-red-400", children: error }) : hint ? /* @__PURE__ */ jsx5(Text4, { className: "mt-1.5 text-xs text-slate-500 dark:text-slate-400", children: hint }) : null
|
|
221
|
+
] });
|
|
222
|
+
}
|
|
223
|
+
function TextArea({
|
|
224
|
+
label,
|
|
225
|
+
hint,
|
|
226
|
+
error,
|
|
227
|
+
containerClassName,
|
|
228
|
+
className,
|
|
229
|
+
rows = 4,
|
|
230
|
+
...props
|
|
231
|
+
}) {
|
|
232
|
+
return /* @__PURE__ */ jsx5(
|
|
233
|
+
Input,
|
|
234
|
+
{
|
|
235
|
+
containerClassName,
|
|
236
|
+
error,
|
|
237
|
+
hint,
|
|
238
|
+
label,
|
|
239
|
+
multiline: true,
|
|
240
|
+
numberOfLines: rows,
|
|
241
|
+
className: cn("min-h-[100px] py-3 font-mono text-sm", className),
|
|
242
|
+
textAlignVertical: "top",
|
|
243
|
+
...props
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function FormSection({ title, children }) {
|
|
248
|
+
return /* @__PURE__ */ jsxs2(View4, { className: "mb-6", children: [
|
|
249
|
+
/* @__PURE__ */ jsx5(Text4, { className: "mb-4 text-lg font-semibold text-slate-900 dark:text-slate-100", children: title }),
|
|
250
|
+
children
|
|
251
|
+
] });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// src/components/page-header.tsx
|
|
255
|
+
import { Text as Text5, View as View5 } from "react-native";
|
|
256
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "nativewind/jsx-runtime";
|
|
257
|
+
function PageHeader({
|
|
258
|
+
title,
|
|
259
|
+
description,
|
|
260
|
+
action,
|
|
261
|
+
className
|
|
262
|
+
}) {
|
|
263
|
+
return /* @__PURE__ */ jsxs3(View5, { className: cn("mb-6 flex-row items-start justify-between", className), children: [
|
|
264
|
+
/* @__PURE__ */ jsxs3(View5, { className: "flex-1 pr-4", children: [
|
|
265
|
+
/* @__PURE__ */ jsx6(Text5, { className: "text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-100 md:text-3xl", children: title }),
|
|
266
|
+
description ? /* @__PURE__ */ jsx6(Text5, { className: "mt-1 text-base text-slate-500 dark:text-slate-400", children: description }) : null
|
|
267
|
+
] }),
|
|
268
|
+
action
|
|
269
|
+
] });
|
|
270
|
+
}
|
|
271
|
+
function EmptyState({
|
|
272
|
+
title,
|
|
273
|
+
description,
|
|
274
|
+
action
|
|
275
|
+
}) {
|
|
276
|
+
return /* @__PURE__ */ jsxs3(View5, { className: "items-center rounded-2xl border border-dashed border-slate-200 bg-white px-6 py-16 dark:border-slate-700 dark:bg-slate-900", children: [
|
|
277
|
+
/* @__PURE__ */ jsx6(Text5, { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: title }),
|
|
278
|
+
/* @__PURE__ */ jsx6(Text5, { className: "mt-2 max-w-sm text-center text-sm text-slate-500 dark:text-slate-400", children: description }),
|
|
279
|
+
action ? /* @__PURE__ */ jsx6(View5, { className: "mt-6", children: action }) : null
|
|
280
|
+
] });
|
|
281
|
+
}
|
|
282
|
+
var alertStyles = {
|
|
283
|
+
success: "border-emerald-500/30 bg-emerald-500/10",
|
|
284
|
+
error: "border-red-500/30 bg-red-500/10",
|
|
285
|
+
info: "border-emerald-500/30 bg-emerald-500/10"
|
|
286
|
+
};
|
|
287
|
+
var alertTextStyles = {
|
|
288
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
289
|
+
error: "text-red-600 dark:text-red-400",
|
|
290
|
+
info: "text-emerald-600 dark:text-emerald-400"
|
|
291
|
+
};
|
|
292
|
+
function AlertBanner({
|
|
293
|
+
message,
|
|
294
|
+
variant = "info"
|
|
295
|
+
}) {
|
|
296
|
+
return /* @__PURE__ */ jsx6(View5, { className: cn("mb-4 rounded-xl border px-4 py-3", alertStyles[variant]), children: /* @__PURE__ */ jsx6(Text5, { className: cn("text-sm font-medium", alertTextStyles[variant]), children: message }) });
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/components/stat-card.tsx
|
|
300
|
+
import { Text as Text6, View as View6 } from "react-native";
|
|
301
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "nativewind/jsx-runtime";
|
|
302
|
+
var trendColors = {
|
|
303
|
+
up: "text-emerald-500 dark:text-emerald-400",
|
|
304
|
+
down: "text-red-500 dark:text-red-400",
|
|
305
|
+
neutral: "text-slate-500 dark:text-slate-400"
|
|
306
|
+
};
|
|
307
|
+
function StatCard({
|
|
308
|
+
label,
|
|
309
|
+
value,
|
|
310
|
+
change,
|
|
311
|
+
trend = "neutral",
|
|
312
|
+
icon,
|
|
313
|
+
className
|
|
314
|
+
}) {
|
|
315
|
+
return /* @__PURE__ */ jsxs4(
|
|
316
|
+
View6,
|
|
317
|
+
{
|
|
318
|
+
className: cn(
|
|
319
|
+
"rounded-2xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
|
|
320
|
+
className
|
|
321
|
+
),
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ jsxs4(View6, { className: "mb-3 flex-row items-center justify-between", children: [
|
|
324
|
+
/* @__PURE__ */ jsx7(Text6, { className: "text-sm font-medium text-slate-500 dark:text-slate-400", children: label }),
|
|
325
|
+
icon ? /* @__PURE__ */ jsx7(View6, { className: "opacity-80", children: icon }) : null
|
|
326
|
+
] }),
|
|
327
|
+
/* @__PURE__ */ jsx7(Text6, { className: "text-3xl font-bold tracking-tight text-slate-900 dark:text-slate-100", children: value }),
|
|
328
|
+
change ? /* @__PURE__ */ jsx7(Text6, { className: cn("mt-2 text-xs font-medium", trendColors[trend]), children: change }) : null
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/navigation/types.ts
|
|
335
|
+
function normalizePathname(pathname) {
|
|
336
|
+
const normalized = pathname.replace(/\/\([^/]+\)/g, "");
|
|
337
|
+
return normalized.length > 0 ? normalized : "/";
|
|
338
|
+
}
|
|
339
|
+
function isNavItemActive(pathname, href) {
|
|
340
|
+
const path = normalizePathname(pathname);
|
|
341
|
+
const target = normalizePathname(href);
|
|
342
|
+
if (target === "/") {
|
|
343
|
+
return path === "/";
|
|
344
|
+
}
|
|
345
|
+
return path === target || path.startsWith(`${target}/`);
|
|
346
|
+
}
|
|
347
|
+
function isNavItemOrChildActive(pathname, item) {
|
|
348
|
+
if (isNavItemActive(pathname, item.href)) {
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
return item.children?.some((child) => isNavItemOrChildActive(pathname, child)) ?? false;
|
|
352
|
+
}
|
|
353
|
+
function findActiveNavHref(pathname, items) {
|
|
354
|
+
let bestHref = null;
|
|
355
|
+
let bestLength = -1;
|
|
356
|
+
let bestDepth = -1;
|
|
357
|
+
const walk = (list, depth) => {
|
|
358
|
+
for (const item of list) {
|
|
359
|
+
if (isNavItemActive(pathname, item.href)) {
|
|
360
|
+
const length = normalizePathname(item.href).length;
|
|
361
|
+
if (length > bestLength || length === bestLength && depth > bestDepth) {
|
|
362
|
+
bestLength = length;
|
|
363
|
+
bestDepth = depth;
|
|
364
|
+
bestHref = item.href;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (item.children) {
|
|
368
|
+
walk(item.children, depth + 1);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
walk(items, 0);
|
|
373
|
+
return bestHref;
|
|
374
|
+
}
|
|
375
|
+
function isItemHighlighted(pathname, item, activeHref) {
|
|
376
|
+
if (activeHref === null) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
const matches = normalizePathname(item.href) === normalizePathname(activeHref);
|
|
380
|
+
if (!matches) {
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
const hasActiveChild = item.children?.some((child) => isNavItemOrChildActive(pathname, child)) ?? false;
|
|
384
|
+
return !hasActiveChild;
|
|
385
|
+
}
|
|
386
|
+
function isHighlightedNavItem(pathname, href, items) {
|
|
387
|
+
const activeHref = findActiveNavHref(pathname, items);
|
|
388
|
+
if (activeHref === null) {
|
|
389
|
+
return false;
|
|
390
|
+
}
|
|
391
|
+
return normalizePathname(href) === normalizePathname(activeHref);
|
|
392
|
+
}
|
|
393
|
+
export {
|
|
394
|
+
AlertBanner,
|
|
395
|
+
Badge,
|
|
396
|
+
Button,
|
|
397
|
+
Card,
|
|
398
|
+
CardHeader,
|
|
399
|
+
ChartIcon,
|
|
400
|
+
EmptyState,
|
|
401
|
+
FormSection,
|
|
402
|
+
HomeIcon,
|
|
403
|
+
Input,
|
|
404
|
+
KeyIcon,
|
|
405
|
+
MenuIcon,
|
|
406
|
+
PageHeader,
|
|
407
|
+
RulesIcon,
|
|
408
|
+
ShieldIcon,
|
|
409
|
+
StatCard,
|
|
410
|
+
TerminalIcon,
|
|
411
|
+
TextArea,
|
|
412
|
+
UserIcon,
|
|
413
|
+
XIcon,
|
|
414
|
+
cn,
|
|
415
|
+
findActiveNavHref,
|
|
416
|
+
isHighlightedNavItem,
|
|
417
|
+
isItemHighlighted,
|
|
418
|
+
isNavItemActive,
|
|
419
|
+
isNavItemOrChildActive,
|
|
420
|
+
normalizePathname
|
|
421
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@limetry/ui",
|
|
3
|
+
"version": "1.2.49",
|
|
4
|
+
"description": "Shared design system for Limetry — components, icons, and design tokens.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.ts",
|
|
8
|
+
"react-native": "./src/index.ts",
|
|
9
|
+
"types": "./src/index.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs",
|
|
15
|
+
"default": "./src/index.ts"
|
|
16
|
+
},
|
|
17
|
+
"./drawer": {
|
|
18
|
+
"types": "./src/components/drawer-menu.web.tsx",
|
|
19
|
+
"react-native": "./src/components/drawer-menu.tsx",
|
|
20
|
+
"browser": "./src/components/drawer-menu.web.tsx",
|
|
21
|
+
"import": "./src/components/drawer-menu.web.tsx",
|
|
22
|
+
"default": "./src/components/drawer-menu.web.tsx"
|
|
23
|
+
},
|
|
24
|
+
"./tailwind": "./tailwind.config.ts",
|
|
25
|
+
"./global.css": "./src/global.css"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src",
|
|
30
|
+
"tailwind.config.ts"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean --out-dir dist",
|
|
34
|
+
"typecheck": "tsgo -p tsconfig.json --noEmit",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"prepack": "node ../../scripts/rewrite-workspace-protocol.mjs prepare",
|
|
37
|
+
"postpack": "node ../../scripts/rewrite-workspace-protocol.mjs restore",
|
|
38
|
+
"prepublishOnly": "yarn build"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"registry": "https://registry.npmjs.org"
|
|
43
|
+
},
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git+https://github.com/limetry/limetry.git",
|
|
47
|
+
"directory": "packages/ui"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"clsx": "^2.1.1",
|
|
51
|
+
"lucide-react": "^1.41.0",
|
|
52
|
+
"lucide-react-native": "^1.41.0",
|
|
53
|
+
"nativewind": "^4.1.23",
|
|
54
|
+
"tailwind-merge": "^3.0.2"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@babel/core": "^7.26.0",
|
|
58
|
+
"@types/react": "^19.1.0",
|
|
59
|
+
"react": "19.2.8",
|
|
60
|
+
"react-dom": "19.2.8",
|
|
61
|
+
"react-native": "0.86.2",
|
|
62
|
+
"react-native-css-interop": "^0.2.6",
|
|
63
|
+
"react-native-reanimated": "~3.17.5",
|
|
64
|
+
"react-native-svg": "15.15.5",
|
|
65
|
+
"tailwindcss": "^3.4.19",
|
|
66
|
+
"tsup": "^8.5.0",
|
|
67
|
+
"typescript": "^5.8.2",
|
|
68
|
+
"vitest": "4.1.11"
|
|
69
|
+
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"react": ">=18",
|
|
72
|
+
"react-native": ">=0.73",
|
|
73
|
+
"react-native-svg": ">=15"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact status pill for labels such as success, warning, and error.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { Text, View } from "react-native"
|
|
6
|
+
|
|
7
|
+
import { cn } from "../lib/cn"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Color treatment for {@link Badge}.
|
|
11
|
+
*/
|
|
12
|
+
type BadgeVariant = "default" | "success" | "warning" | "error" | "outline"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Props for {@link Badge}.
|
|
16
|
+
*/
|
|
17
|
+
type BadgeProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Badge label text.
|
|
20
|
+
*/
|
|
21
|
+
children: string
|
|
22
|
+
/**
|
|
23
|
+
* Visual variant; defaults to `"default"`.
|
|
24
|
+
*/
|
|
25
|
+
variant?: BadgeVariant
|
|
26
|
+
/**
|
|
27
|
+
* Extra classes on the badge container.
|
|
28
|
+
*/
|
|
29
|
+
className?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const variantStyles: Record<BadgeVariant, string> = {
|
|
33
|
+
default: "bg-slate-100 dark:bg-slate-800",
|
|
34
|
+
success: "bg-emerald-500/15 dark:bg-emerald-500/20",
|
|
35
|
+
warning: "bg-amber-500/15 dark:bg-amber-500/20",
|
|
36
|
+
error: "bg-red-500/15 dark:bg-red-500/20",
|
|
37
|
+
outline: "bg-transparent border border-slate-200 dark:border-slate-700",
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const textVariantStyles: Record<BadgeVariant, string> = {
|
|
41
|
+
default: "text-slate-600 dark:text-slate-300",
|
|
42
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
43
|
+
warning: "text-amber-600 dark:text-amber-400",
|
|
44
|
+
error: "text-red-600 dark:text-red-400",
|
|
45
|
+
outline: "text-slate-900 dark:text-slate-100",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Self-start rounded label chip.
|
|
50
|
+
*
|
|
51
|
+
* @param props - Label text, variant, and className.
|
|
52
|
+
* @returns A styled badge `View`.
|
|
53
|
+
*/
|
|
54
|
+
export function Badge({
|
|
55
|
+
children,
|
|
56
|
+
variant = "default",
|
|
57
|
+
className,
|
|
58
|
+
}: BadgeProps): React.JSX.Element {
|
|
59
|
+
return (
|
|
60
|
+
<View className={cn("self-start rounded-full px-2.5 py-1", variantStyles[variant], className)}>
|
|
61
|
+
<Text className={cn("text-xs font-medium", textVariantStyles[variant])}>
|
|
62
|
+
{children}
|
|
63
|
+
</Text>
|
|
64
|
+
</View>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pressable button with variant and size presets for NativeWind surfaces.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ReactNode } from "react"
|
|
6
|
+
import { Pressable, type PressableProps,Text } from "react-native"
|
|
7
|
+
|
|
8
|
+
import { cn } from "../lib/cn"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Visual treatment for {@link Button}.
|
|
12
|
+
*/
|
|
13
|
+
type ButtonVariant = "primary" | "secondary" | "ghost" | "destructive" | "outline"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Padding and type scale for {@link Button}.
|
|
17
|
+
*/
|
|
18
|
+
type ButtonSize = "sm" | "md" | "lg"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Props for {@link Button}, extending React Native `PressableProps`.
|
|
22
|
+
*/
|
|
23
|
+
type ButtonProps = PressableProps & {
|
|
24
|
+
/**
|
|
25
|
+
* Button label string or custom children.
|
|
26
|
+
*/
|
|
27
|
+
children: ReactNode
|
|
28
|
+
/**
|
|
29
|
+
* Color / border treatment; defaults to `"primary"`.
|
|
30
|
+
*/
|
|
31
|
+
variant?: ButtonVariant
|
|
32
|
+
/**
|
|
33
|
+
* Padding and text size; defaults to `"md"`.
|
|
34
|
+
*/
|
|
35
|
+
size?: ButtonSize
|
|
36
|
+
/**
|
|
37
|
+
* Extra classes merged onto the pressable root.
|
|
38
|
+
*/
|
|
39
|
+
className?: string
|
|
40
|
+
/**
|
|
41
|
+
* Extra classes merged onto the string-label `Text` child.
|
|
42
|
+
*/
|
|
43
|
+
textClassName?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const variantStyles: Record<ButtonVariant, string> = {
|
|
47
|
+
primary: "bg-emerald-500 active:bg-emerald-600 dark:bg-emerald-500 dark:active:bg-emerald-600",
|
|
48
|
+
secondary: "bg-slate-100 active:bg-slate-200 dark:bg-slate-800 dark:active:bg-slate-700",
|
|
49
|
+
ghost: "bg-transparent active:bg-slate-100 dark:active:bg-slate-800",
|
|
50
|
+
destructive: "bg-red-500 active:opacity-90 dark:bg-red-600",
|
|
51
|
+
outline: "bg-transparent border border-slate-300 active:bg-slate-50 dark:border-slate-700 dark:active:bg-slate-800",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const textVariantStyles: Record<ButtonVariant, string> = {
|
|
55
|
+
primary: "text-white font-semibold",
|
|
56
|
+
secondary: "text-slate-900 font-medium dark:text-slate-100",
|
|
57
|
+
ghost: "text-slate-900 font-medium dark:text-slate-100",
|
|
58
|
+
destructive: "text-white font-semibold",
|
|
59
|
+
outline: "text-slate-900 font-medium dark:text-slate-100",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const sizeStyles: Record<ButtonSize, string> = {
|
|
63
|
+
sm: "px-3 py-1.5 rounded-lg",
|
|
64
|
+
md: "px-4 py-2.5 rounded-xl",
|
|
65
|
+
lg: "px-6 py-3.5 rounded-xl",
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const textSizeStyles: Record<ButtonSize, string> = {
|
|
69
|
+
sm: "text-sm",
|
|
70
|
+
md: "text-base",
|
|
71
|
+
lg: "text-lg",
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Accessible pressable button that wraps string children in styled `Text`.
|
|
76
|
+
*
|
|
77
|
+
* @param props - Variant, size, class names, and Pressable props.
|
|
78
|
+
* @returns A `Pressable` root with optional styled label text.
|
|
79
|
+
*/
|
|
80
|
+
export function Button({
|
|
81
|
+
children,
|
|
82
|
+
variant = "primary",
|
|
83
|
+
size = "md",
|
|
84
|
+
className,
|
|
85
|
+
textClassName,
|
|
86
|
+
disabled,
|
|
87
|
+
...props
|
|
88
|
+
}: ButtonProps): React.JSX.Element {
|
|
89
|
+
return (
|
|
90
|
+
<Pressable
|
|
91
|
+
accessibilityRole="button"
|
|
92
|
+
className={cn(
|
|
93
|
+
"flex-row items-center justify-center",
|
|
94
|
+
variantStyles[variant],
|
|
95
|
+
sizeStyles[size],
|
|
96
|
+
disabled && "opacity-50",
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
disabled={disabled}
|
|
100
|
+
{...props}
|
|
101
|
+
>
|
|
102
|
+
{typeof children === "string" ? (
|
|
103
|
+
<Text
|
|
104
|
+
className={cn(
|
|
105
|
+
textVariantStyles[variant],
|
|
106
|
+
textSizeStyles[size],
|
|
107
|
+
textClassName,
|
|
108
|
+
)}
|
|
109
|
+
>
|
|
110
|
+
{children}
|
|
111
|
+
</Text>
|
|
112
|
+
) : (
|
|
113
|
+
children
|
|
114
|
+
)}
|
|
115
|
+
</Pressable>
|
|
116
|
+
)
|
|
117
|
+
}
|