mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-11-03 03:18:52 +00:00
Upstream sync from shadcn-ui/ui (1686 commits since last merge base). Key changes: - packages/shadcn upgraded to 4.1.0 (CLI font transformers, scaffold from github, chart colors) - apps/v4 replaces apps/www as the primary docs/registry app - Font system: 25+ heading font registries, font markers utility, @supports override - Chart improvements: recharts v3 compat, radial chart fixes - templates/ updated with monorepo variants (astro, vite, react-router, start) - skills/shadcn AI skill definitions added - deprecated/ removed (auth, auth-firebase, cli, www) Preserved Hanzo-only paths: app/, pkg/, demo/, docs/, template/next/
166 lines
5.1 KiB
TypeScript
166 lines
5.1 KiB
TypeScript
/* eslint-disable react/no-children-prop */
|
|
"use client"
|
|
|
|
import * as React from "react"
|
|
import { useForm } from "@tanstack/react-form"
|
|
import { toast } from "sonner"
|
|
import * as z from "zod"
|
|
|
|
import { Button } from "@/registry/new-york-v4/ui/button"
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardFooter,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/registry/new-york-v4/ui/card"
|
|
import {
|
|
Field,
|
|
FieldDescription,
|
|
FieldError,
|
|
FieldGroup,
|
|
FieldLabel,
|
|
} from "@/registry/new-york-v4/ui/field"
|
|
import { Input } from "@/registry/new-york-v4/ui/input"
|
|
import {
|
|
InputGroup,
|
|
InputGroupAddon,
|
|
InputGroupText,
|
|
InputGroupTextarea,
|
|
} from "@/registry/new-york-v4/ui/input-group"
|
|
|
|
const formSchema = z.object({
|
|
title: z
|
|
.string()
|
|
.min(5, "Bug title must be at least 5 characters.")
|
|
.max(32, "Bug title must be at most 32 characters."),
|
|
description: z
|
|
.string()
|
|
.min(20, "Description must be at least 20 characters.")
|
|
.max(100, "Description must be at most 100 characters."),
|
|
})
|
|
|
|
export default function BugReportForm() {
|
|
const form = useForm({
|
|
defaultValues: {
|
|
title: "",
|
|
description: "",
|
|
},
|
|
validators: {
|
|
onSubmit: formSchema,
|
|
},
|
|
onSubmit: async ({ value }) => {
|
|
toast("You submitted the following values:", {
|
|
description: (
|
|
<pre className="mt-2 w-[320px] overflow-x-auto rounded-md bg-code p-4 text-code-foreground">
|
|
<code>{JSON.stringify(value, null, 2)}</code>
|
|
</pre>
|
|
),
|
|
position: "bottom-right",
|
|
classNames: {
|
|
content: "flex flex-col gap-2",
|
|
},
|
|
style: {
|
|
"--border-radius": "calc(var(--radius) + 4px)",
|
|
} as React.CSSProperties,
|
|
})
|
|
},
|
|
})
|
|
|
|
return (
|
|
<Card className="w-full sm:max-w-md">
|
|
<CardHeader>
|
|
<CardTitle>Bug Report</CardTitle>
|
|
<CardDescription>
|
|
Help us improve by reporting bugs you encounter.
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<form
|
|
id="bug-report-form"
|
|
onSubmit={(e) => {
|
|
e.preventDefault()
|
|
form.handleSubmit()
|
|
}}
|
|
>
|
|
<FieldGroup>
|
|
<form.Field
|
|
name="title"
|
|
children={(field) => {
|
|
const isInvalid =
|
|
field.state.meta.isTouched && !field.state.meta.isValid
|
|
return (
|
|
<Field data-invalid={isInvalid}>
|
|
<FieldLabel htmlFor={field.name}>Bug Title</FieldLabel>
|
|
<Input
|
|
id={field.name}
|
|
name={field.name}
|
|
value={field.state.value}
|
|
onBlur={field.handleBlur}
|
|
onChange={(e) => field.handleChange(e.target.value)}
|
|
aria-invalid={isInvalid}
|
|
placeholder="Login button not working on mobile"
|
|
autoComplete="off"
|
|
/>
|
|
{isInvalid && (
|
|
<FieldError errors={field.state.meta.errors} />
|
|
)}
|
|
</Field>
|
|
)
|
|
}}
|
|
/>
|
|
<form.Field
|
|
name="description"
|
|
children={(field) => {
|
|
const isInvalid =
|
|
field.state.meta.isTouched && !field.state.meta.isValid
|
|
return (
|
|
<Field data-invalid={isInvalid}>
|
|
<FieldLabel htmlFor={field.name}>Description</FieldLabel>
|
|
<InputGroup>
|
|
<InputGroupTextarea
|
|
id={field.name}
|
|
name={field.name}
|
|
value={field.state.value}
|
|
onBlur={field.handleBlur}
|
|
onChange={(e) => field.handleChange(e.target.value)}
|
|
placeholder="I'm having an issue with the login button on mobile."
|
|
rows={6}
|
|
className="min-h-24 resize-none"
|
|
aria-invalid={isInvalid}
|
|
/>
|
|
<InputGroupAddon align="block-end">
|
|
<InputGroupText className="tabular-nums">
|
|
{field.state.value.length}/100 characters
|
|
</InputGroupText>
|
|
</InputGroupAddon>
|
|
</InputGroup>
|
|
<FieldDescription>
|
|
Include steps to reproduce, expected behavior, and what
|
|
actually happened.
|
|
</FieldDescription>
|
|
{isInvalid && (
|
|
<FieldError errors={field.state.meta.errors} />
|
|
)}
|
|
</Field>
|
|
)
|
|
}}
|
|
/>
|
|
</FieldGroup>
|
|
</form>
|
|
</CardContent>
|
|
<CardFooter>
|
|
<Field orientation="horizontal">
|
|
<Button type="button" variant="outline" onClick={() => form.reset()}>
|
|
Reset
|
|
</Button>
|
|
<Button type="submit" form="bug-report-form">
|
|
Submit
|
|
</Button>
|
|
</Field>
|
|
</CardFooter>
|
|
</Card>
|
|
)
|
|
}
|