create-app-ui 1.0.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/LICENSE +21 -0
- package/README.md +117 -0
- package/boilerplate/README.md +18 -0
- package/boilerplate/react-base/.env.example +1 -0
- package/boilerplate/react-base/README.md +3 -0
- package/boilerplate/react-base/components.json +19 -0
- package/boilerplate/react-base/eslint.config.js +32 -0
- package/boilerplate/react-base/index.html +12 -0
- package/boilerplate/react-base/package.json +71 -0
- package/boilerplate/react-base/postcss.config.js +6 -0
- package/boilerplate/react-base/prettier.config.js +6 -0
- package/boilerplate/react-base/src/api/axios.ts +20 -0
- package/boilerplate/react-base/src/app/store.ts +13 -0
- package/boilerplate/react-base/src/components/data-table.tsx +919 -0
- package/boilerplate/react-base/src/components/ui/accordion.tsx +44 -0
- package/boilerplate/react-base/src/components/ui/alert-dialog.tsx +105 -0
- package/boilerplate/react-base/src/components/ui/alert.tsx +40 -0
- package/boilerplate/react-base/src/components/ui/avatar.tsx +30 -0
- package/boilerplate/react-base/src/components/ui/badge.tsx +27 -0
- package/boilerplate/react-base/src/components/ui/bar-chart.tsx +76 -0
- package/boilerplate/react-base/src/components/ui/breadcrumb.tsx +87 -0
- package/boilerplate/react-base/src/components/ui/button.tsx +34 -0
- package/boilerplate/react-base/src/components/ui/calendar.tsx +63 -0
- package/boilerplate/react-base/src/components/ui/card.tsx +36 -0
- package/boilerplate/react-base/src/components/ui/chart.tsx +280 -0
- package/boilerplate/react-base/src/components/ui/checkbox.tsx +51 -0
- package/boilerplate/react-base/src/components/ui/context-menu.tsx +173 -0
- package/boilerplate/react-base/src/components/ui/date-picker.tsx +42 -0
- package/boilerplate/react-base/src/components/ui/dialog.tsx +87 -0
- package/boilerplate/react-base/src/components/ui/drawer.tsx +81 -0
- package/boilerplate/react-base/src/components/ui/dropdown-menu.tsx +81 -0
- package/boilerplate/react-base/src/components/ui/dropdown-types.ts +28 -0
- package/boilerplate/react-base/src/components/ui/field.tsx +194 -0
- package/boilerplate/react-base/src/components/ui/hover-card.tsx +26 -0
- package/boilerplate/react-base/src/components/ui/input-group.tsx +98 -0
- package/boilerplate/react-base/src/components/ui/input-otp.tsx +63 -0
- package/boilerplate/react-base/src/components/ui/input.tsx +12 -0
- package/boilerplate/react-base/src/components/ui/item.tsx +152 -0
- package/boilerplate/react-base/src/components/ui/kbd.tsx +13 -0
- package/boilerplate/react-base/src/components/ui/label.tsx +14 -0
- package/boilerplate/react-base/src/components/ui/line-chart.tsx +65 -0
- package/boilerplate/react-base/src/components/ui/menubar.tsx +217 -0
- package/boilerplate/react-base/src/components/ui/multi-select-dropdown.tsx +200 -0
- package/boilerplate/react-base/src/components/ui/navigation-menu.tsx +120 -0
- package/boilerplate/react-base/src/components/ui/pie-chart.tsx +87 -0
- package/boilerplate/react-base/src/components/ui/popover.tsx +29 -0
- package/boilerplate/react-base/src/components/ui/progress.tsx +19 -0
- package/boilerplate/react-base/src/components/ui/radio-group.tsx +36 -0
- package/boilerplate/react-base/src/components/ui/scroll-area.tsx +38 -0
- package/boilerplate/react-base/src/components/ui/searchable-dropdown.tsx +118 -0
- package/boilerplate/react-base/src/components/ui/select.tsx +140 -0
- package/boilerplate/react-base/src/components/ui/separator.tsx +20 -0
- package/boilerplate/react-base/src/components/ui/sheet.tsx +70 -0
- package/boilerplate/react-base/src/components/ui/sidebar.tsx +470 -0
- package/boilerplate/react-base/src/components/ui/skeleton.tsx +11 -0
- package/boilerplate/react-base/src/components/ui/slider.tsx +23 -0
- package/boilerplate/react-base/src/components/ui/sonner.tsx +21 -0
- package/boilerplate/react-base/src/components/ui/sparkline.tsx +38 -0
- package/boilerplate/react-base/src/components/ui/spinner.tsx +10 -0
- package/boilerplate/react-base/src/components/ui/switch.tsx +16 -0
- package/boilerplate/react-base/src/components/ui/table.tsx +80 -0
- package/boilerplate/react-base/src/components/ui/tabs.tsx +32 -0
- package/boilerplate/react-base/src/components/ui/textarea.tsx +12 -0
- package/boilerplate/react-base/src/components/ui/toggle-group.tsx +49 -0
- package/boilerplate/react-base/src/components/ui/toggle.tsx +33 -0
- package/boilerplate/react-base/src/components/ui/tooltip.tsx +23 -0
- package/boilerplate/react-base/src/components/ui/typography.tsx +76 -0
- package/boilerplate/react-base/src/config/constants.ts +3 -0
- package/boilerplate/react-base/src/config/theme.ts +432 -0
- package/boilerplate/react-base/src/config/user.ts +52 -0
- package/boilerplate/react-base/src/context/theme-provider.tsx +12 -0
- package/boilerplate/react-base/src/features/auth/authSlice.ts +19 -0
- package/boilerplate/react-base/src/hooks/index.ts +1 -0
- package/boilerplate/react-base/src/hooks/use-mobile.ts +17 -0
- package/boilerplate/react-base/src/lib/utils.ts +6 -0
- package/boilerplate/react-base/src/routes/index.tsx +7 -0
- package/boilerplate/react-base/src/styles/globals.css +15 -0
- package/boilerplate/react-base/src/vite-env.d.ts +31 -0
- package/boilerplate/react-base/tailwind.config.ts +75 -0
- package/boilerplate/react-base/tsconfig.app.json +20 -0
- package/boilerplate/react-base/tsconfig.json +7 -0
- package/boilerplate/react-base/tsconfig.node.json +16 -0
- package/boilerplate/react-base/vite.config.ts +12 -0
- package/dist/bin/index.js +8 -0
- package/dist/src/cli-args.js +52 -0
- package/dist/src/generator.js +85 -0
- package/dist/src/installer.js +7 -0
- package/dist/src/paths.js +61 -0
- package/dist/src/prompts.js +79 -0
- package/dist/src/replace-placeholders.js +22 -0
- package/dist/src/utils.js +16 -0
- package/package.json +63 -0
- package/templates/admin-portal/README.md +26 -0
- package/templates/admin-portal/src/App.tsx +85 -0
- package/templates/admin-portal/src/assets/auth-hero.jpg +0 -0
- package/templates/admin-portal/src/assets/brand-logo.png +0 -0
- package/templates/admin-portal/src/components/app-breadcrumb.tsx +41 -0
- package/templates/admin-portal/src/components/app-header.tsx +20 -0
- package/templates/admin-portal/src/components/app-sidebar.tsx +78 -0
- package/templates/admin-portal/src/components/auth-layout.tsx +66 -0
- package/templates/admin-portal/src/components/dashboard-metric-card.tsx +105 -0
- package/templates/admin-portal/src/components/data-table.tsx +919 -0
- package/templates/admin-portal/src/components/layout-shell.tsx +23 -0
- package/templates/admin-portal/src/components/notifications-sheet.tsx +91 -0
- package/templates/admin-portal/src/components/sidebar-nav.tsx +164 -0
- package/templates/admin-portal/src/components/user-avatar.tsx +26 -0
- package/templates/admin-portal/src/components/user-menu.tsx +163 -0
- package/templates/admin-portal/src/config/branding.ts +17 -0
- package/templates/admin-portal/src/config/chart-data.ts +44 -0
- package/templates/admin-portal/src/config/navigation.ts +42 -0
- package/templates/admin-portal/src/context/auth-context.tsx +32 -0
- package/templates/admin-portal/src/lib/breadcrumbs.ts +58 -0
- package/templates/admin-portal/src/main.tsx +18 -0
- package/templates/admin-portal/src/pages/components/demo-columns.tsx +170 -0
- package/templates/admin-portal/src/pages/components.tsx +1368 -0
- package/templates/admin-portal/src/pages/dashboard.tsx +143 -0
- package/templates/admin-portal/src/pages/login.tsx +81 -0
- package/templates/admin-portal/src/pages/settings/notifications.tsx +31 -0
- package/templates/admin-portal/src/pages/settings/profile.tsx +26 -0
- package/templates/admin-portal/src/pages/signup.tsx +81 -0
- package/templates/admin-portal/src/pages/users.tsx +12 -0
- package/templates/admin-portal/tsconfig.json +10 -0
- package/templates/blank/README.md +15 -0
- package/templates/blank/src/App.tsx +5 -0
- package/templates/blank/src/main.tsx +15 -0
- package/templates/blank/src/pages/home.tsx +20 -0
- package/templates/blank/tsconfig.json +10 -0
- package/templates/tsconfig.overlay.base.json +7 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as RechartsPrimitive from "recharts";
|
|
3
|
+
import { ui } from "@/config/theme";
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
export type ChartConfig = Record<
|
|
7
|
+
string,
|
|
8
|
+
{
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
icon?: React.ComponentType;
|
|
11
|
+
color?: string;
|
|
12
|
+
}
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
type ChartContextProps = {
|
|
16
|
+
config: ChartConfig;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ChartContext = React.createContext<ChartContextProps | null>(null);
|
|
20
|
+
|
|
21
|
+
function useChart() {
|
|
22
|
+
const context = React.useContext(ChartContext);
|
|
23
|
+
if (!context) {
|
|
24
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function ChartContainer({
|
|
30
|
+
id,
|
|
31
|
+
className,
|
|
32
|
+
children,
|
|
33
|
+
config,
|
|
34
|
+
...props
|
|
35
|
+
}: React.ComponentProps<"div"> & {
|
|
36
|
+
config: ChartConfig;
|
|
37
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
38
|
+
}) {
|
|
39
|
+
const uniqueId = React.useId();
|
|
40
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<ChartContext.Provider value={{ config }}>
|
|
44
|
+
<div
|
|
45
|
+
data-chart={chartId}
|
|
46
|
+
className={cn(ui("chartContainer"), className)}
|
|
47
|
+
{...props}
|
|
48
|
+
>
|
|
49
|
+
<ChartStyle id={chartId} config={config} />
|
|
50
|
+
<RechartsPrimitive.ResponsiveContainer>{children}</RechartsPrimitive.ResponsiveContainer>
|
|
51
|
+
</div>
|
|
52
|
+
</ChartContext.Provider>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ChartStyle({ id, config }: { id: string; config: ChartConfig }) {
|
|
57
|
+
const colorConfig = Object.entries(config).filter(([, item]) => item.color);
|
|
58
|
+
|
|
59
|
+
if (!colorConfig.length) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<style
|
|
65
|
+
dangerouslySetInnerHTML={{
|
|
66
|
+
__html: Object.entries(config)
|
|
67
|
+
.filter(([, item]) => item.color)
|
|
68
|
+
.map(([key, item]) => `[data-chart=${id}] { --color-${key}: ${item.color}; }`)
|
|
69
|
+
.join("\n"),
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
76
|
+
|
|
77
|
+
type TooltipPayloadItem = {
|
|
78
|
+
value?: number | string;
|
|
79
|
+
name?: string;
|
|
80
|
+
dataKey?: string | number;
|
|
81
|
+
color?: string;
|
|
82
|
+
payload?: Record<string, unknown> & { fill?: string };
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type ChartTooltipContentProps = React.ComponentProps<"div"> & {
|
|
86
|
+
active?: boolean;
|
|
87
|
+
payload?: TooltipPayloadItem[];
|
|
88
|
+
label?: string;
|
|
89
|
+
hideLabel?: boolean;
|
|
90
|
+
hideIndicator?: boolean;
|
|
91
|
+
indicator?: "line" | "dot" | "dashed";
|
|
92
|
+
nameKey?: string;
|
|
93
|
+
labelKey?: string;
|
|
94
|
+
labelFormatter?: (label: unknown, payload: TooltipPayloadItem[]) => React.ReactNode;
|
|
95
|
+
labelClassName?: string;
|
|
96
|
+
formatter?: (
|
|
97
|
+
value: number | string,
|
|
98
|
+
name: string,
|
|
99
|
+
item: TooltipPayloadItem,
|
|
100
|
+
index: number,
|
|
101
|
+
payload: Record<string, unknown>,
|
|
102
|
+
) => React.ReactNode;
|
|
103
|
+
color?: string;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function ChartTooltipContent({
|
|
107
|
+
active,
|
|
108
|
+
payload,
|
|
109
|
+
className,
|
|
110
|
+
indicator = "dot",
|
|
111
|
+
hideLabel = false,
|
|
112
|
+
hideIndicator = false,
|
|
113
|
+
label,
|
|
114
|
+
labelFormatter,
|
|
115
|
+
labelClassName,
|
|
116
|
+
formatter,
|
|
117
|
+
color,
|
|
118
|
+
nameKey,
|
|
119
|
+
labelKey,
|
|
120
|
+
}: ChartTooltipContentProps) {
|
|
121
|
+
const { config } = useChart();
|
|
122
|
+
|
|
123
|
+
if (!active || !payload?.length) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
className={cn(
|
|
132
|
+
"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl",
|
|
133
|
+
className,
|
|
134
|
+
)}
|
|
135
|
+
>
|
|
136
|
+
{!nestLabel && !hideLabel ? (
|
|
137
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
138
|
+
{labelFormatter
|
|
139
|
+
? labelFormatter(label, payload)
|
|
140
|
+
: labelKey && payload[0]?.payload
|
|
141
|
+
? String(payload[0].payload[labelKey])
|
|
142
|
+
: label}
|
|
143
|
+
</div>
|
|
144
|
+
) : null}
|
|
145
|
+
<div className="grid gap-1.5">
|
|
146
|
+
{payload.map((item, index) => {
|
|
147
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
148
|
+
const itemConfig = config[key];
|
|
149
|
+
const indicatorColor = color || item.payload?.fill || item.color;
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
key={String(item.dataKey)}
|
|
154
|
+
className={cn(
|
|
155
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground",
|
|
156
|
+
indicator === "dot" && "items-center",
|
|
157
|
+
)}
|
|
158
|
+
>
|
|
159
|
+
{formatter && item?.value !== undefined && item.name ? (
|
|
160
|
+
formatter(item.value, item.name, item, index, item.payload ?? {})
|
|
161
|
+
) : (
|
|
162
|
+
<>
|
|
163
|
+
{itemConfig?.icon ? (
|
|
164
|
+
<itemConfig.icon />
|
|
165
|
+
) : !hideIndicator ? (
|
|
166
|
+
<div
|
|
167
|
+
className={cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
|
168
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
169
|
+
"w-1": indicator === "line",
|
|
170
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
171
|
+
"my-0.5": nestLabel && indicator === "dashed",
|
|
172
|
+
})}
|
|
173
|
+
style={
|
|
174
|
+
{
|
|
175
|
+
"--color-bg": indicatorColor,
|
|
176
|
+
"--color-border": indicatorColor,
|
|
177
|
+
} as React.CSSProperties
|
|
178
|
+
}
|
|
179
|
+
/>
|
|
180
|
+
) : null}
|
|
181
|
+
<div
|
|
182
|
+
className={cn(
|
|
183
|
+
"flex flex-1 justify-between leading-none",
|
|
184
|
+
nestLabel ? "items-end" : "items-center",
|
|
185
|
+
)}
|
|
186
|
+
>
|
|
187
|
+
<div className="grid gap-1.5">
|
|
188
|
+
{nestLabel && !hideLabel ? (
|
|
189
|
+
<div className={cn("font-medium", labelClassName)}>
|
|
190
|
+
{labelFormatter
|
|
191
|
+
? labelFormatter(label, payload)
|
|
192
|
+
: labelKey && item.payload
|
|
193
|
+
? String(item.payload[labelKey])
|
|
194
|
+
: label}
|
|
195
|
+
</div>
|
|
196
|
+
) : null}
|
|
197
|
+
<span className="text-muted-foreground">{itemConfig?.label || item.name}</span>
|
|
198
|
+
</div>
|
|
199
|
+
{item.value !== undefined && (
|
|
200
|
+
<span className="font-mono font-medium tabular-nums text-foreground">
|
|
201
|
+
{Number(item.value).toLocaleString()}
|
|
202
|
+
</span>
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
);
|
|
209
|
+
})}
|
|
210
|
+
</div>
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
216
|
+
|
|
217
|
+
type LegendPayloadItem = {
|
|
218
|
+
value?: string;
|
|
219
|
+
dataKey?: string | number;
|
|
220
|
+
color?: string;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
type ChartLegendContentProps = React.ComponentProps<"div"> & {
|
|
224
|
+
payload?: LegendPayloadItem[];
|
|
225
|
+
verticalAlign?: "top" | "bottom";
|
|
226
|
+
hideIcon?: boolean;
|
|
227
|
+
nameKey?: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
function ChartLegendContent({
|
|
231
|
+
className,
|
|
232
|
+
hideIcon = false,
|
|
233
|
+
payload,
|
|
234
|
+
verticalAlign = "bottom",
|
|
235
|
+
nameKey,
|
|
236
|
+
}: ChartLegendContentProps) {
|
|
237
|
+
const { config } = useChart();
|
|
238
|
+
|
|
239
|
+
if (!payload?.length) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<div
|
|
245
|
+
className={cn(
|
|
246
|
+
"flex items-center justify-center gap-4",
|
|
247
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
248
|
+
className,
|
|
249
|
+
)}
|
|
250
|
+
>
|
|
251
|
+
{payload.map((item) => {
|
|
252
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
253
|
+
const itemConfig = config[key];
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<div
|
|
257
|
+
key={item.value}
|
|
258
|
+
className={cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground")}
|
|
259
|
+
>
|
|
260
|
+
{itemConfig?.icon && !hideIcon ? (
|
|
261
|
+
<itemConfig.icon />
|
|
262
|
+
) : (
|
|
263
|
+
<div className="h-2 w-2 shrink-0 rounded-[2px]" style={{ backgroundColor: item.color }} />
|
|
264
|
+
)}
|
|
265
|
+
{itemConfig?.label}
|
|
266
|
+
</div>
|
|
267
|
+
);
|
|
268
|
+
})}
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
ChartContainer,
|
|
275
|
+
ChartLegend,
|
|
276
|
+
ChartLegendContent,
|
|
277
|
+
ChartStyle,
|
|
278
|
+
ChartTooltip,
|
|
279
|
+
ChartTooltipContent,
|
|
280
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
import { Check } from "lucide-react";
|
|
5
|
+
import { ui } from "@/config/theme";
|
|
6
|
+
import { cn } from "@/lib/utils";
|
|
7
|
+
|
|
8
|
+
const checkboxVariants = cva(ui("checkbox"), {
|
|
9
|
+
variants: {
|
|
10
|
+
shape: {
|
|
11
|
+
rounded: "rounded-sm",
|
|
12
|
+
square: "rounded-none",
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
default: "h-4 w-4",
|
|
16
|
+
sm: "h-3.5 w-3.5",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
shape: "rounded",
|
|
21
|
+
size: "default",
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const checkboxIndicatorVariants = cva("flex items-center justify-center text-current", {
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
default: "[&_svg]:h-4 [&_svg]:w-4",
|
|
29
|
+
sm: "[&_svg]:h-3 [&_svg]:w-3",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
size: "default",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export type CheckboxProps = React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> &
|
|
38
|
+
VariantProps<typeof checkboxVariants>;
|
|
39
|
+
|
|
40
|
+
const Checkbox = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(
|
|
41
|
+
({ className, shape, size, ...props }, ref) => (
|
|
42
|
+
<CheckboxPrimitive.Root ref={ref} className={cn(checkboxVariants({ shape, size }), className)} {...props}>
|
|
43
|
+
<CheckboxPrimitive.Indicator className={checkboxIndicatorVariants({ size })}>
|
|
44
|
+
<Check />
|
|
45
|
+
</CheckboxPrimitive.Indicator>
|
|
46
|
+
</CheckboxPrimitive.Root>
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
|
|
50
|
+
|
|
51
|
+
export { Checkbox, checkboxVariants };
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
3
|
+
import { Check, ChevronRight, Circle } from "lucide-react";
|
|
4
|
+
import { ui } from "@/config/theme";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
const ContextMenu = ContextMenuPrimitive.Root;
|
|
8
|
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
9
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
10
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal;
|
|
11
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
12
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
13
|
+
|
|
14
|
+
const ContextMenuSubTrigger = React.forwardRef<
|
|
15
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
16
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
17
|
+
inset?: boolean;
|
|
18
|
+
}
|
|
19
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
20
|
+
<ContextMenuPrimitive.SubTrigger
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cn(
|
|
23
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
24
|
+
inset && "pl-8",
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
<ChevronRight className="ml-auto h-4 w-4" />
|
|
31
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
32
|
+
));
|
|
33
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
|
|
34
|
+
|
|
35
|
+
const ContextMenuSubContent = React.forwardRef<
|
|
36
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
37
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
|
|
38
|
+
>(({ className, ...props }, ref) => (
|
|
39
|
+
<ContextMenuPrimitive.SubContent
|
|
40
|
+
ref={ref}
|
|
41
|
+
className={cn(
|
|
42
|
+
ui("popoverMenu"),
|
|
43
|
+
className,
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
));
|
|
48
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
|
|
49
|
+
|
|
50
|
+
const ContextMenuContent = React.forwardRef<
|
|
51
|
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
52
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
|
|
53
|
+
>(({ className, ...props }, ref) => (
|
|
54
|
+
<ContextMenuPrimitive.Portal>
|
|
55
|
+
<ContextMenuPrimitive.Content
|
|
56
|
+
ref={ref}
|
|
57
|
+
className={cn(
|
|
58
|
+
ui("popoverMenu"),
|
|
59
|
+
className,
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
</ContextMenuPrimitive.Portal>
|
|
64
|
+
));
|
|
65
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
|
|
66
|
+
|
|
67
|
+
const ContextMenuItem = React.forwardRef<
|
|
68
|
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
69
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
|
|
70
|
+
inset?: boolean;
|
|
71
|
+
}
|
|
72
|
+
>(({ className, inset, ...props }, ref) => (
|
|
73
|
+
<ContextMenuPrimitive.Item
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={cn(
|
|
76
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
77
|
+
inset && "pl-8",
|
|
78
|
+
className,
|
|
79
|
+
)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
));
|
|
83
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
|
|
84
|
+
|
|
85
|
+
const ContextMenuCheckboxItem = React.forwardRef<
|
|
86
|
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
87
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
88
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
89
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
90
|
+
ref={ref}
|
|
91
|
+
className={cn(
|
|
92
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
93
|
+
className,
|
|
94
|
+
)}
|
|
95
|
+
checked={checked}
|
|
96
|
+
{...props}
|
|
97
|
+
>
|
|
98
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
99
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
100
|
+
<Check className="h-4 w-4" />
|
|
101
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
102
|
+
</span>
|
|
103
|
+
{children}
|
|
104
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
105
|
+
));
|
|
106
|
+
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
|
|
107
|
+
|
|
108
|
+
const ContextMenuRadioItem = React.forwardRef<
|
|
109
|
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
110
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
111
|
+
>(({ className, children, ...props }, ref) => (
|
|
112
|
+
<ContextMenuPrimitive.RadioItem
|
|
113
|
+
ref={ref}
|
|
114
|
+
className={cn(
|
|
115
|
+
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
116
|
+
className,
|
|
117
|
+
)}
|
|
118
|
+
{...props}
|
|
119
|
+
>
|
|
120
|
+
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
121
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
122
|
+
<Circle className="h-2 w-2 fill-current" />
|
|
123
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
124
|
+
</span>
|
|
125
|
+
{children}
|
|
126
|
+
</ContextMenuPrimitive.RadioItem>
|
|
127
|
+
));
|
|
128
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
|
|
129
|
+
|
|
130
|
+
const ContextMenuLabel = React.forwardRef<
|
|
131
|
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
132
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
|
|
133
|
+
inset?: boolean;
|
|
134
|
+
}
|
|
135
|
+
>(({ className, inset, ...props }, ref) => (
|
|
136
|
+
<ContextMenuPrimitive.Label
|
|
137
|
+
ref={ref}
|
|
138
|
+
className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
|
|
139
|
+
{...props}
|
|
140
|
+
/>
|
|
141
|
+
));
|
|
142
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
|
|
143
|
+
|
|
144
|
+
const ContextMenuSeparator = React.forwardRef<
|
|
145
|
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
146
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
147
|
+
>(({ className, ...props }, ref) => (
|
|
148
|
+
<ContextMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-border", className)} {...props} />
|
|
149
|
+
));
|
|
150
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
|
|
151
|
+
|
|
152
|
+
function ContextMenuShortcut({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) {
|
|
153
|
+
return <span className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)} {...props} />;
|
|
154
|
+
}
|
|
155
|
+
ContextMenuShortcut.displayName = "ContextMenuShortcut";
|
|
156
|
+
|
|
157
|
+
export {
|
|
158
|
+
ContextMenu,
|
|
159
|
+
ContextMenuCheckboxItem,
|
|
160
|
+
ContextMenuContent,
|
|
161
|
+
ContextMenuGroup,
|
|
162
|
+
ContextMenuItem,
|
|
163
|
+
ContextMenuLabel,
|
|
164
|
+
ContextMenuPortal,
|
|
165
|
+
ContextMenuRadioGroup,
|
|
166
|
+
ContextMenuRadioItem,
|
|
167
|
+
ContextMenuSeparator,
|
|
168
|
+
ContextMenuShortcut,
|
|
169
|
+
ContextMenuSub,
|
|
170
|
+
ContextMenuSubContent,
|
|
171
|
+
ContextMenuSubTrigger,
|
|
172
|
+
ContextMenuTrigger,
|
|
173
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { format } from "date-fns";
|
|
2
|
+
import { Calendar as CalendarIcon } from "lucide-react";
|
|
3
|
+
import { Button } from "@/components/ui/button";
|
|
4
|
+
import { Calendar } from "@/components/ui/calendar";
|
|
5
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
|
6
|
+
import { ui } from "@/config/theme";
|
|
7
|
+
import { cn } from "@/lib/utils";
|
|
8
|
+
|
|
9
|
+
export type DatePickerProps = {
|
|
10
|
+
date?: Date;
|
|
11
|
+
onDateChange?: (date: Date | undefined) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function DatePicker({
|
|
18
|
+
date,
|
|
19
|
+
onDateChange,
|
|
20
|
+
placeholder = "Pick a date",
|
|
21
|
+
className,
|
|
22
|
+
disabled,
|
|
23
|
+
}: DatePickerProps) {
|
|
24
|
+
return (
|
|
25
|
+
<Popover>
|
|
26
|
+
<PopoverTrigger asChild>
|
|
27
|
+
<Button
|
|
28
|
+
type="button"
|
|
29
|
+
variant="outline"
|
|
30
|
+
disabled={disabled}
|
|
31
|
+
className={cn(ui("datePickerTrigger"), !date && ui("typographyMuted"), className)}
|
|
32
|
+
>
|
|
33
|
+
<CalendarIcon className="mr-2 h-4 w-4" />
|
|
34
|
+
{date ? format(date, "PPP") : <span>{placeholder}</span>}
|
|
35
|
+
</Button>
|
|
36
|
+
</PopoverTrigger>
|
|
37
|
+
<PopoverContent className={ui("datePickerPopoverContent")} align="start">
|
|
38
|
+
<Calendar mode="single" selected={date} onSelect={onDateChange} initialFocus />
|
|
39
|
+
</PopoverContent>
|
|
40
|
+
</Popover>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import { ui } from "@/config/theme";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
const Dialog = DialogPrimitive.Root;
|
|
8
|
+
const DialogTrigger = DialogPrimitive.Trigger;
|
|
9
|
+
const DialogPortal = DialogPrimitive.Portal;
|
|
10
|
+
const DialogClose = DialogPrimitive.Close;
|
|
11
|
+
|
|
12
|
+
const DialogOverlay = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof DialogPrimitive.Overlay>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<DialogPrimitive.Overlay
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(ui("overlay"), className)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
));
|
|
22
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
23
|
+
|
|
24
|
+
const DialogContent = React.forwardRef<
|
|
25
|
+
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
26
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
27
|
+
>(({ className, children, ...props }, ref) => (
|
|
28
|
+
<DialogPortal>
|
|
29
|
+
<DialogOverlay />
|
|
30
|
+
<DialogPrimitive.Content
|
|
31
|
+
ref={ref}
|
|
32
|
+
className={cn(
|
|
33
|
+
ui("modalContent"),
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
<DialogPrimitive.Close className={ui("iconClose")}>
|
|
40
|
+
<X className="h-4 w-4" />
|
|
41
|
+
<span className="sr-only">Close</span>
|
|
42
|
+
</DialogPrimitive.Close>
|
|
43
|
+
</DialogPrimitive.Content>
|
|
44
|
+
</DialogPortal>
|
|
45
|
+
));
|
|
46
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
47
|
+
|
|
48
|
+
function DialogHeader({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
|
49
|
+
return <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />;
|
|
50
|
+
}
|
|
51
|
+
DialogHeader.displayName = "DialogHeader";
|
|
52
|
+
|
|
53
|
+
function DialogFooter({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
|
|
54
|
+
return (
|
|
55
|
+
<div className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)} {...props} />
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
DialogFooter.displayName = "DialogFooter";
|
|
59
|
+
|
|
60
|
+
const DialogTitle = React.forwardRef<
|
|
61
|
+
React.ElementRef<typeof DialogPrimitive.Title>,
|
|
62
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
|
63
|
+
>(({ className, ...props }, ref) => (
|
|
64
|
+
<DialogPrimitive.Title ref={ref} className={cn("text-lg font-semibold leading-none tracking-tight", className)} {...props} />
|
|
65
|
+
));
|
|
66
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
67
|
+
|
|
68
|
+
const DialogDescription = React.forwardRef<
|
|
69
|
+
React.ElementRef<typeof DialogPrimitive.Description>,
|
|
70
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
|
71
|
+
>(({ className, ...props }, ref) => (
|
|
72
|
+
<DialogPrimitive.Description ref={ref} className={cn(ui("typographyMuted"), className)} {...props} />
|
|
73
|
+
));
|
|
74
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
Dialog,
|
|
78
|
+
DialogClose,
|
|
79
|
+
DialogContent,
|
|
80
|
+
DialogDescription,
|
|
81
|
+
DialogFooter,
|
|
82
|
+
DialogHeader,
|
|
83
|
+
DialogOverlay,
|
|
84
|
+
DialogPortal,
|
|
85
|
+
DialogTitle,
|
|
86
|
+
DialogTrigger,
|
|
87
|
+
};
|