@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/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# `@limetry/ui`
|
|
2
|
+
|
|
3
|
+
Shared React Native and web UI for Limetry: buttons, form controls, page chrome, navigation helpers, and icons.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @limetry/ui react react-native react-native-svg
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peers are `react` 18 or newer, `react-native` 0.73 or newer, and `react-native-svg` 15 or newer. Styles use NativeWind.
|
|
12
|
+
|
|
13
|
+
## Use a component
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Button, Card, PageHeader } from "@limetry/ui"
|
|
17
|
+
|
|
18
|
+
export function Approvals() {
|
|
19
|
+
return (
|
|
20
|
+
<Card>
|
|
21
|
+
<PageHeader title="Approvals" />
|
|
22
|
+
<Button>Review</Button>
|
|
23
|
+
</Card>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Subpath exports:
|
|
29
|
+
|
|
30
|
+
- `@limetry/ui/drawer` for the drawer menu
|
|
31
|
+
- `@limetry/ui/tailwind` for the shared Tailwind config
|
|
32
|
+
- `@limetry/ui/global.css` for the global stylesheet
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AlertBanner: () => AlertBanner,
|
|
24
|
+
Badge: () => Badge,
|
|
25
|
+
Button: () => Button,
|
|
26
|
+
Card: () => Card,
|
|
27
|
+
CardHeader: () => CardHeader,
|
|
28
|
+
ChartIcon: () => ChartIcon,
|
|
29
|
+
EmptyState: () => EmptyState,
|
|
30
|
+
FormSection: () => FormSection,
|
|
31
|
+
HomeIcon: () => HomeIcon,
|
|
32
|
+
Input: () => Input,
|
|
33
|
+
KeyIcon: () => KeyIcon,
|
|
34
|
+
MenuIcon: () => MenuIcon,
|
|
35
|
+
PageHeader: () => PageHeader,
|
|
36
|
+
RulesIcon: () => RulesIcon,
|
|
37
|
+
ShieldIcon: () => ShieldIcon,
|
|
38
|
+
StatCard: () => StatCard,
|
|
39
|
+
TerminalIcon: () => TerminalIcon,
|
|
40
|
+
TextArea: () => TextArea,
|
|
41
|
+
UserIcon: () => UserIcon,
|
|
42
|
+
XIcon: () => XIcon,
|
|
43
|
+
cn: () => cn,
|
|
44
|
+
findActiveNavHref: () => findActiveNavHref,
|
|
45
|
+
isHighlightedNavItem: () => isHighlightedNavItem,
|
|
46
|
+
isItemHighlighted: () => isItemHighlighted,
|
|
47
|
+
isNavItemActive: () => isNavItemActive,
|
|
48
|
+
isNavItemOrChildActive: () => isNavItemOrChildActive,
|
|
49
|
+
normalizePathname: () => normalizePathname
|
|
50
|
+
});
|
|
51
|
+
module.exports = __toCommonJS(index_exports);
|
|
52
|
+
|
|
53
|
+
// src/components/badge.tsx
|
|
54
|
+
var import_react_native = require("react-native");
|
|
55
|
+
|
|
56
|
+
// src/lib/cn.ts
|
|
57
|
+
var import_clsx = require("clsx");
|
|
58
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
59
|
+
function cn(...inputs) {
|
|
60
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/components/badge.tsx
|
|
64
|
+
var import_jsx_runtime = require("nativewind/jsx-runtime");
|
|
65
|
+
var variantStyles = {
|
|
66
|
+
default: "bg-slate-100 dark:bg-slate-800",
|
|
67
|
+
success: "bg-emerald-500/15 dark:bg-emerald-500/20",
|
|
68
|
+
warning: "bg-amber-500/15 dark:bg-amber-500/20",
|
|
69
|
+
error: "bg-red-500/15 dark:bg-red-500/20",
|
|
70
|
+
outline: "bg-transparent border border-slate-200 dark:border-slate-700"
|
|
71
|
+
};
|
|
72
|
+
var textVariantStyles = {
|
|
73
|
+
default: "text-slate-600 dark:text-slate-300",
|
|
74
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
75
|
+
warning: "text-amber-600 dark:text-amber-400",
|
|
76
|
+
error: "text-red-600 dark:text-red-400",
|
|
77
|
+
outline: "text-slate-900 dark:text-slate-100"
|
|
78
|
+
};
|
|
79
|
+
function Badge({
|
|
80
|
+
children,
|
|
81
|
+
variant = "default",
|
|
82
|
+
className
|
|
83
|
+
}) {
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { className: cn("self-start rounded-full px-2.5 py-1", variantStyles[variant], className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { className: cn("text-xs font-medium", textVariantStyles[variant]), children }) });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/components/button.tsx
|
|
88
|
+
var import_react_native2 = require("react-native");
|
|
89
|
+
var import_jsx_runtime2 = require("nativewind/jsx-runtime");
|
|
90
|
+
var variantStyles2 = {
|
|
91
|
+
primary: "bg-emerald-500 active:bg-emerald-600 dark:bg-emerald-500 dark:active:bg-emerald-600",
|
|
92
|
+
secondary: "bg-slate-100 active:bg-slate-200 dark:bg-slate-800 dark:active:bg-slate-700",
|
|
93
|
+
ghost: "bg-transparent active:bg-slate-100 dark:active:bg-slate-800",
|
|
94
|
+
destructive: "bg-red-500 active:opacity-90 dark:bg-red-600",
|
|
95
|
+
outline: "bg-transparent border border-slate-300 active:bg-slate-50 dark:border-slate-700 dark:active:bg-slate-800"
|
|
96
|
+
};
|
|
97
|
+
var textVariantStyles2 = {
|
|
98
|
+
primary: "text-white font-semibold",
|
|
99
|
+
secondary: "text-slate-900 font-medium dark:text-slate-100",
|
|
100
|
+
ghost: "text-slate-900 font-medium dark:text-slate-100",
|
|
101
|
+
destructive: "text-white font-semibold",
|
|
102
|
+
outline: "text-slate-900 font-medium dark:text-slate-100"
|
|
103
|
+
};
|
|
104
|
+
var sizeStyles = {
|
|
105
|
+
sm: "px-3 py-1.5 rounded-lg",
|
|
106
|
+
md: "px-4 py-2.5 rounded-xl",
|
|
107
|
+
lg: "px-6 py-3.5 rounded-xl"
|
|
108
|
+
};
|
|
109
|
+
var textSizeStyles = {
|
|
110
|
+
sm: "text-sm",
|
|
111
|
+
md: "text-base",
|
|
112
|
+
lg: "text-lg"
|
|
113
|
+
};
|
|
114
|
+
function Button({
|
|
115
|
+
children,
|
|
116
|
+
variant = "primary",
|
|
117
|
+
size = "md",
|
|
118
|
+
className,
|
|
119
|
+
textClassName,
|
|
120
|
+
disabled,
|
|
121
|
+
...props
|
|
122
|
+
}) {
|
|
123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
124
|
+
import_react_native2.Pressable,
|
|
125
|
+
{
|
|
126
|
+
accessibilityRole: "button",
|
|
127
|
+
className: cn(
|
|
128
|
+
"flex-row items-center justify-center",
|
|
129
|
+
variantStyles2[variant],
|
|
130
|
+
sizeStyles[size],
|
|
131
|
+
disabled && "opacity-50",
|
|
132
|
+
className
|
|
133
|
+
),
|
|
134
|
+
disabled,
|
|
135
|
+
...props,
|
|
136
|
+
children: typeof children === "string" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
137
|
+
import_react_native2.Text,
|
|
138
|
+
{
|
|
139
|
+
className: cn(
|
|
140
|
+
textVariantStyles2[variant],
|
|
141
|
+
textSizeStyles[size],
|
|
142
|
+
textClassName
|
|
143
|
+
),
|
|
144
|
+
children
|
|
145
|
+
}
|
|
146
|
+
) : children
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/components/card.tsx
|
|
152
|
+
var import_react_native3 = require("react-native");
|
|
153
|
+
var import_jsx_runtime3 = require("nativewind/jsx-runtime");
|
|
154
|
+
function Card({ children, className, ...props }) {
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
156
|
+
import_react_native3.View,
|
|
157
|
+
{
|
|
158
|
+
className: cn(
|
|
159
|
+
"rounded-2xl min-h-[88px] border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
|
|
160
|
+
className
|
|
161
|
+
),
|
|
162
|
+
...props,
|
|
163
|
+
children
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function CardHeader({
|
|
168
|
+
title,
|
|
169
|
+
description,
|
|
170
|
+
action,
|
|
171
|
+
className
|
|
172
|
+
}) {
|
|
173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native3.View, { className: cn("mb-4 flex-row items-start justify-between", className), children: [
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_native3.View, { className: "flex-1 pr-3", children: [
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: title }),
|
|
176
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { className: "mt-1 text-sm text-slate-500 dark:text-slate-400", children: description }) : null
|
|
177
|
+
] }),
|
|
178
|
+
action
|
|
179
|
+
] });
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/components/icons.tsx
|
|
183
|
+
var import_lucide_react_native = require("lucide-react-native");
|
|
184
|
+
var import_nativewind = require("nativewind");
|
|
185
|
+
var import_react_native4 = require("react-native");
|
|
186
|
+
var import_jsx_runtime4 = require("nativewind/jsx-runtime");
|
|
187
|
+
function getColorFromClass(className, isDark) {
|
|
188
|
+
if (!className) return isDark ? "#ffffff" : "#0f172a";
|
|
189
|
+
if (className.includes("text-emerald-500")) return "#10B981";
|
|
190
|
+
if (className.includes("text-slate-400")) return "#94A3B8";
|
|
191
|
+
if (className.includes("text-slate-900")) return "#0f172a";
|
|
192
|
+
if (className.includes("text-slate-100")) return "#ffffff";
|
|
193
|
+
if (className.includes("dark:text-slate-100")) return isDark ? "#ffffff" : "#0f172a";
|
|
194
|
+
if (className.includes("dark:text-slate-500")) return isDark ? "#6B7280" : "#94A3B8";
|
|
195
|
+
return isDark ? "#ffffff" : "#0f172a";
|
|
196
|
+
}
|
|
197
|
+
function NativeIcon({
|
|
198
|
+
Icon,
|
|
199
|
+
className
|
|
200
|
+
}) {
|
|
201
|
+
const { colorScheme } = (0, import_nativewind.useColorScheme)();
|
|
202
|
+
const isDark = colorScheme === "dark";
|
|
203
|
+
const color = getColorFromClass(className, isDark);
|
|
204
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.View, { className: cn("h-6 w-6 items-center justify-center", className), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { color, size: 20 }) });
|
|
205
|
+
}
|
|
206
|
+
function ShieldIcon({ className }) {
|
|
207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.Shield, className });
|
|
208
|
+
}
|
|
209
|
+
function KeyIcon({ className }) {
|
|
210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.Key, className });
|
|
211
|
+
}
|
|
212
|
+
function RulesIcon({ className }) {
|
|
213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.Zap, className });
|
|
214
|
+
}
|
|
215
|
+
function ChartIcon({ className }) {
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.BarChart, className });
|
|
217
|
+
}
|
|
218
|
+
function UserIcon({ className }) {
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.User, className });
|
|
220
|
+
}
|
|
221
|
+
function HomeIcon({ className }) {
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.Home, className });
|
|
223
|
+
}
|
|
224
|
+
function TerminalIcon({ className }) {
|
|
225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.Terminal, className });
|
|
226
|
+
}
|
|
227
|
+
function MenuIcon({ className }) {
|
|
228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.Menu, className });
|
|
229
|
+
}
|
|
230
|
+
function XIcon({ className }) {
|
|
231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NativeIcon, { Icon: import_lucide_react_native.X, className });
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/components/input.tsx
|
|
235
|
+
var import_react_native5 = require("react-native");
|
|
236
|
+
var import_jsx_runtime5 = require("nativewind/jsx-runtime");
|
|
237
|
+
function Input({
|
|
238
|
+
label,
|
|
239
|
+
hint,
|
|
240
|
+
error,
|
|
241
|
+
containerClassName,
|
|
242
|
+
className,
|
|
243
|
+
editable = true,
|
|
244
|
+
...props
|
|
245
|
+
}) {
|
|
246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native5.View, { className: cn("mb-4", containerClassName), children: [
|
|
247
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Text, { className: "mb-2 text-sm font-medium text-slate-900 dark:text-slate-100", children: label }) : null,
|
|
248
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
249
|
+
import_react_native5.TextInput,
|
|
250
|
+
{
|
|
251
|
+
className: cn(
|
|
252
|
+
"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",
|
|
253
|
+
!editable && "opacity-60",
|
|
254
|
+
error && "border-red-500 dark:border-red-500",
|
|
255
|
+
className
|
|
256
|
+
),
|
|
257
|
+
editable,
|
|
258
|
+
placeholderTextColor: "#94a3b8",
|
|
259
|
+
...props
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Text, { className: "mt-1.5 text-xs text-red-500 dark:text-red-400", children: error }) : hint ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Text, { className: "mt-1.5 text-xs text-slate-500 dark:text-slate-400", children: hint }) : null
|
|
263
|
+
] });
|
|
264
|
+
}
|
|
265
|
+
function TextArea({
|
|
266
|
+
label,
|
|
267
|
+
hint,
|
|
268
|
+
error,
|
|
269
|
+
containerClassName,
|
|
270
|
+
className,
|
|
271
|
+
rows = 4,
|
|
272
|
+
...props
|
|
273
|
+
}) {
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
275
|
+
Input,
|
|
276
|
+
{
|
|
277
|
+
containerClassName,
|
|
278
|
+
error,
|
|
279
|
+
hint,
|
|
280
|
+
label,
|
|
281
|
+
multiline: true,
|
|
282
|
+
numberOfLines: rows,
|
|
283
|
+
className: cn("min-h-[100px] py-3 font-mono text-sm", className),
|
|
284
|
+
textAlignVertical: "top",
|
|
285
|
+
...props
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
function FormSection({ title, children }) {
|
|
290
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react_native5.View, { className: "mb-6", children: [
|
|
291
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.Text, { className: "mb-4 text-lg font-semibold text-slate-900 dark:text-slate-100", children: title }),
|
|
292
|
+
children
|
|
293
|
+
] });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/components/page-header.tsx
|
|
297
|
+
var import_react_native6 = require("react-native");
|
|
298
|
+
var import_jsx_runtime6 = require("nativewind/jsx-runtime");
|
|
299
|
+
function PageHeader({
|
|
300
|
+
title,
|
|
301
|
+
description,
|
|
302
|
+
action,
|
|
303
|
+
className
|
|
304
|
+
}) {
|
|
305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native6.View, { className: cn("mb-6 flex-row items-start justify-between", className), children: [
|
|
306
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native6.View, { className: "flex-1 pr-4", children: [
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Text, { className: "text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-100 md:text-3xl", children: title }),
|
|
308
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Text, { className: "mt-1 text-base text-slate-500 dark:text-slate-400", children: description }) : null
|
|
309
|
+
] }),
|
|
310
|
+
action
|
|
311
|
+
] });
|
|
312
|
+
}
|
|
313
|
+
function EmptyState({
|
|
314
|
+
title,
|
|
315
|
+
description,
|
|
316
|
+
action
|
|
317
|
+
}) {
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_react_native6.View, { 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: [
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Text, { className: "text-lg font-semibold text-slate-900 dark:text-slate-100", children: title }),
|
|
320
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Text, { className: "mt-2 max-w-sm text-center text-sm text-slate-500 dark:text-slate-400", children: description }),
|
|
321
|
+
action ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.View, { className: "mt-6", children: action }) : null
|
|
322
|
+
] });
|
|
323
|
+
}
|
|
324
|
+
var alertStyles = {
|
|
325
|
+
success: "border-emerald-500/30 bg-emerald-500/10",
|
|
326
|
+
error: "border-red-500/30 bg-red-500/10",
|
|
327
|
+
info: "border-emerald-500/30 bg-emerald-500/10"
|
|
328
|
+
};
|
|
329
|
+
var alertTextStyles = {
|
|
330
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
331
|
+
error: "text-red-600 dark:text-red-400",
|
|
332
|
+
info: "text-emerald-600 dark:text-emerald-400"
|
|
333
|
+
};
|
|
334
|
+
function AlertBanner({
|
|
335
|
+
message,
|
|
336
|
+
variant = "info"
|
|
337
|
+
}) {
|
|
338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.View, { className: cn("mb-4 rounded-xl border px-4 py-3", alertStyles[variant]), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_native6.Text, { className: cn("text-sm font-medium", alertTextStyles[variant]), children: message }) });
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// src/components/stat-card.tsx
|
|
342
|
+
var import_react_native7 = require("react-native");
|
|
343
|
+
var import_jsx_runtime7 = require("nativewind/jsx-runtime");
|
|
344
|
+
var trendColors = {
|
|
345
|
+
up: "text-emerald-500 dark:text-emerald-400",
|
|
346
|
+
down: "text-red-500 dark:text-red-400",
|
|
347
|
+
neutral: "text-slate-500 dark:text-slate-400"
|
|
348
|
+
};
|
|
349
|
+
function StatCard({
|
|
350
|
+
label,
|
|
351
|
+
value,
|
|
352
|
+
change,
|
|
353
|
+
trend = "neutral",
|
|
354
|
+
icon,
|
|
355
|
+
className
|
|
356
|
+
}) {
|
|
357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
358
|
+
import_react_native7.View,
|
|
359
|
+
{
|
|
360
|
+
className: cn(
|
|
361
|
+
"rounded-2xl border border-slate-200 bg-white p-5 dark:border-slate-800 dark:bg-slate-900",
|
|
362
|
+
className
|
|
363
|
+
),
|
|
364
|
+
children: [
|
|
365
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_react_native7.View, { className: "mb-3 flex-row items-center justify-between", children: [
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.Text, { className: "text-sm font-medium text-slate-500 dark:text-slate-400", children: label }),
|
|
367
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.View, { className: "opacity-80", children: icon }) : null
|
|
368
|
+
] }),
|
|
369
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.Text, { className: "text-3xl font-bold tracking-tight text-slate-900 dark:text-slate-100", children: value }),
|
|
370
|
+
change ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.Text, { className: cn("mt-2 text-xs font-medium", trendColors[trend]), children: change }) : null
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/navigation/types.ts
|
|
377
|
+
function normalizePathname(pathname) {
|
|
378
|
+
const normalized = pathname.replace(/\/\([^/]+\)/g, "");
|
|
379
|
+
return normalized.length > 0 ? normalized : "/";
|
|
380
|
+
}
|
|
381
|
+
function isNavItemActive(pathname, href) {
|
|
382
|
+
const path = normalizePathname(pathname);
|
|
383
|
+
const target = normalizePathname(href);
|
|
384
|
+
if (target === "/") {
|
|
385
|
+
return path === "/";
|
|
386
|
+
}
|
|
387
|
+
return path === target || path.startsWith(`${target}/`);
|
|
388
|
+
}
|
|
389
|
+
function isNavItemOrChildActive(pathname, item) {
|
|
390
|
+
if (isNavItemActive(pathname, item.href)) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
return item.children?.some((child) => isNavItemOrChildActive(pathname, child)) ?? false;
|
|
394
|
+
}
|
|
395
|
+
function findActiveNavHref(pathname, items) {
|
|
396
|
+
let bestHref = null;
|
|
397
|
+
let bestLength = -1;
|
|
398
|
+
let bestDepth = -1;
|
|
399
|
+
const walk = (list, depth) => {
|
|
400
|
+
for (const item of list) {
|
|
401
|
+
if (isNavItemActive(pathname, item.href)) {
|
|
402
|
+
const length = normalizePathname(item.href).length;
|
|
403
|
+
if (length > bestLength || length === bestLength && depth > bestDepth) {
|
|
404
|
+
bestLength = length;
|
|
405
|
+
bestDepth = depth;
|
|
406
|
+
bestHref = item.href;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (item.children) {
|
|
410
|
+
walk(item.children, depth + 1);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
walk(items, 0);
|
|
415
|
+
return bestHref;
|
|
416
|
+
}
|
|
417
|
+
function isItemHighlighted(pathname, item, activeHref) {
|
|
418
|
+
if (activeHref === null) {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
const matches = normalizePathname(item.href) === normalizePathname(activeHref);
|
|
422
|
+
if (!matches) {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
const hasActiveChild = item.children?.some((child) => isNavItemOrChildActive(pathname, child)) ?? false;
|
|
426
|
+
return !hasActiveChild;
|
|
427
|
+
}
|
|
428
|
+
function isHighlightedNavItem(pathname, href, items) {
|
|
429
|
+
const activeHref = findActiveNavHref(pathname, items);
|
|
430
|
+
if (activeHref === null) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
return normalizePathname(href) === normalizePathname(activeHref);
|
|
434
|
+
}
|
|
435
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
436
|
+
0 && (module.exports = {
|
|
437
|
+
AlertBanner,
|
|
438
|
+
Badge,
|
|
439
|
+
Button,
|
|
440
|
+
Card,
|
|
441
|
+
CardHeader,
|
|
442
|
+
ChartIcon,
|
|
443
|
+
EmptyState,
|
|
444
|
+
FormSection,
|
|
445
|
+
HomeIcon,
|
|
446
|
+
Input,
|
|
447
|
+
KeyIcon,
|
|
448
|
+
MenuIcon,
|
|
449
|
+
PageHeader,
|
|
450
|
+
RulesIcon,
|
|
451
|
+
ShieldIcon,
|
|
452
|
+
StatCard,
|
|
453
|
+
TerminalIcon,
|
|
454
|
+
TextArea,
|
|
455
|
+
UserIcon,
|
|
456
|
+
XIcon,
|
|
457
|
+
cn,
|
|
458
|
+
findActiveNavHref,
|
|
459
|
+
isHighlightedNavItem,
|
|
460
|
+
isItemHighlighted,
|
|
461
|
+
isNavItemActive,
|
|
462
|
+
isNavItemOrChildActive,
|
|
463
|
+
normalizePathname
|
|
464
|
+
});
|