@bsv/create-dpp-app 0.0.0-stage → 0.1.0-beta.1

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.
Files changed (81) hide show
  1. package/LICENSE +203 -0
  2. package/README.md +73 -2
  3. package/dist/index.js +97 -0
  4. package/package.json +53 -4
  5. package/template/Dockerfile +35 -0
  6. package/template/README.md +134 -0
  7. package/template/_dockerignore +6 -0
  8. package/template/_env.example +53 -0
  9. package/template/_github/workflows/ci.yml +23 -0
  10. package/template/_gitignore +8 -0
  11. package/template/_prettierrc +6 -0
  12. package/template/apps/api/API.md +49 -0
  13. package/template/apps/api/package.json +34 -0
  14. package/template/apps/api/src/auth.ts +55 -0
  15. package/template/apps/api/src/claims.ts +85 -0
  16. package/template/apps/api/src/cli.ts +42 -0
  17. package/template/apps/api/src/config.ts +66 -0
  18. package/template/apps/api/src/custody.ts +186 -0
  19. package/template/apps/api/src/dev-index.ts +71 -0
  20. package/template/apps/api/src/env.ts +14 -0
  21. package/template/apps/api/src/identifiers.ts +57 -0
  22. package/template/apps/api/src/index-client.ts +136 -0
  23. package/template/apps/api/src/main.ts +50 -0
  24. package/template/apps/api/src/parties.ts +68 -0
  25. package/template/apps/api/src/platform.ts +121 -0
  26. package/template/apps/api/src/profiles.ts +100 -0
  27. package/template/apps/api/src/reader.ts +96 -0
  28. package/template/apps/api/src/server.ts +420 -0
  29. package/template/apps/api/src/store.ts +249 -0
  30. package/template/apps/api/src/wallet.ts +346 -0
  31. package/template/apps/api/src/worker.ts +106 -0
  32. package/template/apps/api/src/writer.ts +351 -0
  33. package/template/apps/api/test/config.test.ts +15 -0
  34. package/template/apps/api/test/external-index.test.ts +31 -0
  35. package/template/apps/api/test/lifecycle.test.ts +136 -0
  36. package/template/apps/api/tsconfig.json +9 -0
  37. package/template/apps/api/vitest.config.ts +9 -0
  38. package/template/apps/web/components.json +21 -0
  39. package/template/apps/web/index.html +12 -0
  40. package/template/apps/web/package.json +33 -0
  41. package/template/apps/web/src/app.tsx +51 -0
  42. package/template/apps/web/src/components/bits.tsx +188 -0
  43. package/template/apps/web/src/components/layout.tsx +118 -0
  44. package/template/apps/web/src/components/passport-form.tsx +244 -0
  45. package/template/apps/web/src/components/read-passport.tsx +48 -0
  46. package/template/apps/web/src/components/reading.tsx +157 -0
  47. package/template/apps/web/src/components/ui/alert.tsx +65 -0
  48. package/template/apps/web/src/components/ui/badge.tsx +47 -0
  49. package/template/apps/web/src/components/ui/button.tsx +63 -0
  50. package/template/apps/web/src/components/ui/card.tsx +91 -0
  51. package/template/apps/web/src/components/ui/dialog.tsx +156 -0
  52. package/template/apps/web/src/components/ui/input.tsx +20 -0
  53. package/template/apps/web/src/components/ui/label.tsx +21 -0
  54. package/template/apps/web/src/components/ui/select.tsx +189 -0
  55. package/template/apps/web/src/components/ui/separator.tsx +25 -0
  56. package/template/apps/web/src/components/ui/table.tsx +115 -0
  57. package/template/apps/web/src/components/ui/tabs.tsx +90 -0
  58. package/template/apps/web/src/components/ui/textarea.tsx +17 -0
  59. package/template/apps/web/src/index.css +81 -0
  60. package/template/apps/web/src/lib/api.ts +286 -0
  61. package/template/apps/web/src/lib/auth.ts +10 -0
  62. package/template/apps/web/src/lib/format.ts +64 -0
  63. package/template/apps/web/src/lib/session.tsx +92 -0
  64. package/template/apps/web/src/lib/use-load.ts +46 -0
  65. package/template/apps/web/src/main.tsx +18 -0
  66. package/template/apps/web/src/pages/accept.tsx +108 -0
  67. package/template/apps/web/src/pages/brand.tsx +94 -0
  68. package/template/apps/web/src/pages/brands.tsx +104 -0
  69. package/template/apps/web/src/pages/home.tsx +51 -0
  70. package/template/apps/web/src/pages/new-passport.tsx +114 -0
  71. package/template/apps/web/src/pages/operations.tsx +150 -0
  72. package/template/apps/web/src/pages/passport.tsx +568 -0
  73. package/template/apps/web/src/pages/public-passport.tsx +24 -0
  74. package/template/apps/web/src/pages/sign-in.tsx +93 -0
  75. package/template/apps/web/src/pages/verify.tsx +30 -0
  76. package/template/apps/web/src/pages/wallet.tsx +141 -0
  77. package/template/apps/web/tsconfig.json +29 -0
  78. package/template/apps/web/vite.config.ts +15 -0
  79. package/template/deploy/compose.yml +26 -0
  80. package/template/package.json +42 -0
  81. package/template/tsconfig.base.json +13 -0
@@ -0,0 +1,48 @@
1
+ // Read one passport the way the public page and the verify page do: the
2
+ // reader's report from the index, this platform's journal when it has the
3
+ // passport, and the claims. A journal 404 is not a failure: the passport may
4
+ // be another platform's, and the report still stands on its own.
5
+ import { ErrorNotice, Loading } from '@/components/bits'
6
+ import { PassportReading } from '@/components/reading'
7
+ import { api, isNotFound, type ClaimView, type PassportView, type Verification } from '@/lib/api'
8
+ import { useLoad } from '@/lib/use-load'
9
+
10
+ interface Read {
11
+ verification?: Verification
12
+ verifyError?: unknown
13
+ journal?: PassportView
14
+ claims: ClaimView[]
15
+ }
16
+
17
+ const unlessNotFound =
18
+ <T,>(fallback: T) =>
19
+ (cause: unknown): T => {
20
+ if (isNotFound(cause)) return fallback
21
+ throw cause
22
+ }
23
+
24
+ async function read(passportId: string): Promise<Read> {
25
+ const [verification, journal, claims] = await Promise.all([
26
+ api.verify(passportId).then(
27
+ (value): { ok: true; value: Verification } => ({ ok: true, value }),
28
+ (error: unknown): { ok: false; error: unknown } => ({ ok: false, error })
29
+ ),
30
+ api.passport(passportId).catch(unlessNotFound<PassportView | undefined>(undefined)),
31
+ api.passportClaims(passportId).catch(unlessNotFound<ClaimView[]>([])),
32
+ ])
33
+ return {
34
+ verification: verification.ok ? verification.value : undefined,
35
+ verifyError: verification.ok ? undefined : verification.error,
36
+ journal,
37
+ claims,
38
+ }
39
+ }
40
+
41
+ export function ReadPassport({ passportId, manageLink, publicLink }: { passportId: string; manageLink?: boolean; publicLink?: boolean }) {
42
+ const result = useLoad(() => read(passportId), [passportId])
43
+ if (result.loading) return <Loading what="Reading the passport" />
44
+ if (result.error != null || result.data == null) return <ErrorNotice error={result.error ?? new Error('nothing was read')} title="Could not read the passport" />
45
+ const { verification, verifyError, journal, claims } = result.data
46
+ if (verification == null && journal == null) return <ErrorNotice error={verifyError} title="Nothing was found for this identifier" />
47
+ return <PassportReading passportId={passportId} verification={verification} verifyError={verifyError} journal={journal} claims={claims} manageLink={manageLink} publicLink={publicLink} />
48
+ }
@@ -0,0 +1,157 @@
1
+ // What a reader sees for one passport: the notice first, the product data,
2
+ // the verification report one check per line, then the history and any
3
+ // claims. There is no overall verdict on purpose: the report is the sixteen
4
+ // answers, and a reader decides what they mean for their own purpose.
5
+ import { Link } from 'react-router'
6
+ import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'
7
+ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
8
+ import { CheckBadge, CopyButton, DefinitionList, ErrorNotice, Mono, Section, ToneBadge, entriesOf } from '@/components/bits'
9
+ import type { Check, ClaimView, PassportView, Verification } from '@/lib/api'
10
+ import { STAMP_KEYS, formatTime, humanise, isRecord, publicPathOf, shortTxid } from '@/lib/format'
11
+
12
+ export function ReportChecks({ checks }: { checks: Check[] }) {
13
+ return (
14
+ <div className="space-y-3">
15
+ <ul className="divide-y rounded-lg border">
16
+ {checks.map((check) => (
17
+ <li key={check.name} className="flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
18
+ <span className="text-sm">{check.label}</span>
19
+ <span className="flex shrink-0 items-center gap-2">
20
+ <CheckBadge status={check.status} />
21
+ {check.reasonCode == null ? null : <Mono className="text-muted-foreground">{check.reasonCode}</Mono>}
22
+ </span>
23
+ </li>
24
+ ))}
25
+ </ul>
26
+ <p className="text-sm text-muted-foreground">Unknown means the evidence was not available to this reader, not that the check failed.</p>
27
+ </div>
28
+ )
29
+ }
30
+
31
+ interface ReadingProps {
32
+ passportId: string
33
+ verification?: Verification
34
+ verifyError?: unknown
35
+ journal?: PassportView
36
+ claims?: ClaimView[]
37
+ /** Link to the brand's view when this platform's journal holds the passport. */
38
+ manageLink?: boolean
39
+ /** Link to the identifier's own page; off when this is that page. */
40
+ publicLink?: boolean
41
+ }
42
+
43
+ export function PassportReading({ passportId, verification, verifyError, journal, claims, manageLink, publicLink }: ReadingProps) {
44
+ const latestPayload = journal?.payload ?? verification?.lineage.at(-1)?.payloadPublic
45
+ const payload = isRecord(latestPayload) ? latestPayload : undefined
46
+ const notice = typeof payload?.notice === 'string' ? payload.notice : undefined
47
+ const profile = journal?.profile ?? (payload?.profile == null ? undefined : `${String(payload.profile)}@${String(payload.profile_version ?? '')}`)
48
+ const history = verification?.lineage.map((entry) => ({ op: entry.op, txid: entry.txid, timestamp: entry.timestamp })) ?? journal?.states.map((s) => ({ op: s.op, txid: s.txid, timestamp: s.timestamp })) ?? []
49
+ const path = publicPathOf(passportId)
50
+
51
+ return (
52
+ <div className="space-y-10">
53
+ {notice == null ? null : (
54
+ <Alert className="border-amber-300 bg-amber-50 text-amber-950 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
55
+ <AlertTitle>Notice</AlertTitle>
56
+ <AlertDescription className="text-current">
57
+ <p className="text-base">{notice}</p>
58
+ </AlertDescription>
59
+ </Alert>
60
+ )}
61
+
62
+ <div className="space-y-2">
63
+ <div className="flex flex-wrap items-center gap-2">
64
+ <Mono className="text-sm">{passportId}</Mono>
65
+ <CopyButton text={passportId} label="Copy the identifier" />
66
+ </div>
67
+ <div className="flex flex-wrap items-center gap-2 text-sm text-muted-foreground">
68
+ {profile == null ? null : <span>Profile {profile}</span>}
69
+ {journal == null ? null : <ToneBadge tone={journal.status === 'active' ? 'pass' : 'muted'}>{journal.status}</ToneBadge>}
70
+ {journal?.demonstration ? <ToneBadge tone="warn">Demonstration</ToneBadge> : null}
71
+ {journal == null ? <span>Not in this platform's journal; read from the index alone.</span> : null}
72
+ </div>
73
+ </div>
74
+
75
+ <Section title="Product">
76
+ {payload == null ? <p className="text-sm text-muted-foreground">No payload was read.</p> : <DefinitionList entries={entriesOf(payload, STAMP_KEYS, humanise)} />}
77
+ </Section>
78
+
79
+ <Section title="Verification">
80
+ {verifyError != null ? <ErrorNotice error={verifyError} title="The reader could not verify this passport" /> : null}
81
+ {verification == null ? (
82
+ verifyError == null ? (
83
+ <p className="text-sm text-muted-foreground">No report.</p>
84
+ ) : null
85
+ ) : (
86
+ <>
87
+ <ReportChecks checks={verification.checks} />
88
+ {verification.report.checkedAt == null ? null : <p className="text-xs text-muted-foreground">Checked {formatTime(verification.report.checkedAt)}.</p>}
89
+ </>
90
+ )}
91
+ </Section>
92
+
93
+ <Section title="History">
94
+ {history.length === 0 ? (
95
+ <p className="text-sm text-muted-foreground">No states were read.</p>
96
+ ) : (
97
+ <ol className="divide-y rounded-lg border">
98
+ {history.map((entry) => (
99
+ <li key={entry.txid} className="flex flex-col gap-1 p-3 sm:flex-row sm:items-center sm:justify-between">
100
+ <span className="flex items-center gap-3">
101
+ <ToneBadge tone="neutral">{entry.op}</ToneBadge>
102
+ <span className="text-sm">{formatTime(entry.timestamp)}</span>
103
+ </span>
104
+ <span className="flex items-center gap-1">
105
+ <Mono className="text-muted-foreground">{shortTxid(entry.txid)}</Mono>
106
+ <CopyButton text={entry.txid} label="Copy the txid" />
107
+ </span>
108
+ </li>
109
+ ))}
110
+ </ol>
111
+ )}
112
+ </Section>
113
+
114
+ {claims != null && claims.length > 0 ? (
115
+ <Section title="Claims">
116
+ <Table>
117
+ <TableHeader>
118
+ <TableRow>
119
+ <TableHead>Event</TableHead>
120
+ <TableHead>When</TableHead>
121
+ <TableHead>Issued by</TableHead>
122
+ <TableHead>Signature</TableHead>
123
+ </TableRow>
124
+ </TableHeader>
125
+ <TableBody>
126
+ {claims.map((claim) => (
127
+ <TableRow key={claim.id}>
128
+ <TableCell>{claim.claim.eventType}</TableCell>
129
+ <TableCell>{formatTime(claim.claim.timestamp)}</TableCell>
130
+ <TableCell>{claim.issuedBy}</TableCell>
131
+ <TableCell>
132
+ <ToneBadge tone={claim.verified === 'verified' ? 'pass' : 'fail'}>{claim.verified}</ToneBadge>
133
+ </TableCell>
134
+ </TableRow>
135
+ ))}
136
+ </TableBody>
137
+ </Table>
138
+ </Section>
139
+ ) : null}
140
+
141
+ {manageLink && journal != null ? (
142
+ <p className="text-sm">
143
+ <Link to={`/passports/${encodeURIComponent(passportId)}`} className="underline underline-offset-4">
144
+ Open the brand's view
145
+ </Link>
146
+ </p>
147
+ ) : null}
148
+ {publicLink && path != null ? (
149
+ <p className="text-sm">
150
+ <Link to={path} className="underline underline-offset-4">
151
+ Public page
152
+ </Link>
153
+ </p>
154
+ ) : null}
155
+ </div>
156
+ )
157
+ }
@@ -0,0 +1,65 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { cn } from "cn"
4
+
5
+ const alertVariants = cva(
6
+ "relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
7
+ {
8
+ variants: {
9
+ variant: {
10
+ default: "bg-card text-card-foreground",
11
+ destructive:
12
+ "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current",
13
+ },
14
+ },
15
+ defaultVariants: {
16
+ variant: "default",
17
+ },
18
+ }
19
+ )
20
+
21
+ function Alert({
22
+ className,
23
+ variant,
24
+ ...props
25
+ }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
26
+ return (
27
+ <div
28
+ data-slot="alert"
29
+ role="alert"
30
+ className={cn(alertVariants({ variant }), className)}
31
+ {...props}
32
+ />
33
+ )
34
+ }
35
+
36
+ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
37
+ return (
38
+ <div
39
+ data-slot="alert-title"
40
+ className={cn(
41
+ "col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
42
+ className
43
+ )}
44
+ {...props}
45
+ />
46
+ )
47
+ }
48
+
49
+ function AlertDescription({
50
+ className,
51
+ ...props
52
+ }: React.ComponentProps<"div">) {
53
+ return (
54
+ <div
55
+ data-slot="alert-description"
56
+ className={cn(
57
+ "col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed",
58
+ className
59
+ )}
60
+ {...props}
61
+ />
62
+ )
63
+ }
64
+
65
+ export { Alert, AlertTitle, AlertDescription }
@@ -0,0 +1,47 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { cn } from "cn"
4
+ import { Slot } from "radix-ui"
5
+
6
+ const badgeVariants = cva(
7
+ "inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
12
+ secondary:
13
+ "bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
14
+ destructive:
15
+ "bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",
16
+ outline:
17
+ "border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
18
+ ghost: "[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
19
+ link: "text-primary underline-offset-4 [a&]:hover:underline",
20
+ },
21
+ },
22
+ defaultVariants: {
23
+ variant: "default",
24
+ },
25
+ }
26
+ )
27
+
28
+ function Badge({
29
+ className,
30
+ variant = "default",
31
+ asChild = false,
32
+ ...props
33
+ }: React.ComponentProps<"span"> &
34
+ VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
35
+ const Comp = asChild ? Slot.Root : "span"
36
+
37
+ return (
38
+ <Comp
39
+ data-slot="badge"
40
+ data-variant={variant}
41
+ className={cn(badgeVariants({ variant }), className)}
42
+ {...props}
43
+ />
44
+ )
45
+ }
46
+
47
+ export { Badge, badgeVariants }
@@ -0,0 +1,63 @@
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
+ import { cn } from "cn"
4
+ import { Slot } from "radix-ui"
5
+
6
+ const buttonVariants = cva(
7
+ "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
12
+ destructive:
13
+ "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
14
+ outline:
15
+ "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
16
+ secondary:
17
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18
+ ghost:
19
+ "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
24
+ xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
25
+ sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
26
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
+ icon: "size-9",
28
+ "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
29
+ "icon-sm": "size-8",
30
+ "icon-lg": "size-10",
31
+ },
32
+ },
33
+ defaultVariants: {
34
+ variant: "default",
35
+ size: "default",
36
+ },
37
+ }
38
+ )
39
+
40
+ function Button({
41
+ className,
42
+ variant = "default",
43
+ size = "default",
44
+ asChild = false,
45
+ ...props
46
+ }: React.ComponentProps<"button"> &
47
+ VariantProps<typeof buttonVariants> & {
48
+ asChild?: boolean
49
+ }) {
50
+ const Comp = asChild ? Slot.Root : "button"
51
+
52
+ return (
53
+ <Comp
54
+ data-slot="button"
55
+ data-variant={variant}
56
+ data-size={size}
57
+ className={cn(buttonVariants({ variant, size, className }))}
58
+ {...props}
59
+ />
60
+ )
61
+ }
62
+
63
+ export { Button, buttonVariants }
@@ -0,0 +1,91 @@
1
+ import * as React from "react"
2
+ import { cn } from "cn"
3
+
4
+ function Card({ className, ...props }: React.ComponentProps<"div">) {
5
+ return (
6
+ <div
7
+ data-slot="card"
8
+ className={cn(
9
+ "flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
10
+ className
11
+ )}
12
+ {...props}
13
+ />
14
+ )
15
+ }
16
+
17
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
18
+ return (
19
+ <div
20
+ data-slot="card-header"
21
+ className={cn(
22
+ "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
23
+ className
24
+ )}
25
+ {...props}
26
+ />
27
+ )
28
+ }
29
+
30
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
31
+ return (
32
+ <div
33
+ data-slot="card-title"
34
+ className={cn("leading-none font-semibold", className)}
35
+ {...props}
36
+ />
37
+ )
38
+ }
39
+
40
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
41
+ return (
42
+ <div
43
+ data-slot="card-description"
44
+ className={cn("text-sm text-muted-foreground", className)}
45
+ {...props}
46
+ />
47
+ )
48
+ }
49
+
50
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
51
+ return (
52
+ <div
53
+ data-slot="card-action"
54
+ className={cn(
55
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
56
+ className
57
+ )}
58
+ {...props}
59
+ />
60
+ )
61
+ }
62
+
63
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
64
+ return (
65
+ <div
66
+ data-slot="card-content"
67
+ className={cn("px-6", className)}
68
+ {...props}
69
+ />
70
+ )
71
+ }
72
+
73
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
74
+ return (
75
+ <div
76
+ data-slot="card-footer"
77
+ className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
78
+ {...props}
79
+ />
80
+ )
81
+ }
82
+
83
+ export {
84
+ Card,
85
+ CardHeader,
86
+ CardFooter,
87
+ CardTitle,
88
+ CardAction,
89
+ CardDescription,
90
+ CardContent,
91
+ }
@@ -0,0 +1,156 @@
1
+ import * as React from "react"
2
+ import { cn } from "cn"
3
+ import { XIcon } from "lucide-react"
4
+ import { Dialog as DialogPrimitive } from "radix-ui"
5
+
6
+ import { Button } from "@/components/ui/button"
7
+
8
+ function Dialog({
9
+ ...props
10
+ }: React.ComponentProps<typeof DialogPrimitive.Root>) {
11
+ return <DialogPrimitive.Root data-slot="dialog" {...props} />
12
+ }
13
+
14
+ function DialogTrigger({
15
+ ...props
16
+ }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
17
+ return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
18
+ }
19
+
20
+ function DialogPortal({
21
+ ...props
22
+ }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
23
+ return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
24
+ }
25
+
26
+ function DialogClose({
27
+ ...props
28
+ }: React.ComponentProps<typeof DialogPrimitive.Close>) {
29
+ return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
30
+ }
31
+
32
+ function DialogOverlay({
33
+ className,
34
+ ...props
35
+ }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
36
+ return (
37
+ <DialogPrimitive.Overlay
38
+ data-slot="dialog-overlay"
39
+ className={cn(
40
+ "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
41
+ className
42
+ )}
43
+ {...props}
44
+ />
45
+ )
46
+ }
47
+
48
+ function DialogContent({
49
+ className,
50
+ children,
51
+ showCloseButton = true,
52
+ ...props
53
+ }: React.ComponentProps<typeof DialogPrimitive.Content> & {
54
+ showCloseButton?: boolean
55
+ }) {
56
+ return (
57
+ <DialogPortal data-slot="dialog-portal">
58
+ <DialogOverlay />
59
+ <DialogPrimitive.Content
60
+ data-slot="dialog-content"
61
+ className={cn(
62
+ "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
63
+ className
64
+ )}
65
+ {...props}
66
+ >
67
+ {children}
68
+ {showCloseButton && (
69
+ <DialogPrimitive.Close
70
+ data-slot="dialog-close"
71
+ className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
72
+ >
73
+ <XIcon />
74
+ <span className="sr-only">Close</span>
75
+ </DialogPrimitive.Close>
76
+ )}
77
+ </DialogPrimitive.Content>
78
+ </DialogPortal>
79
+ )
80
+ }
81
+
82
+ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
83
+ return (
84
+ <div
85
+ data-slot="dialog-header"
86
+ className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
87
+ {...props}
88
+ />
89
+ )
90
+ }
91
+
92
+ function DialogFooter({
93
+ className,
94
+ showCloseButton = false,
95
+ children,
96
+ ...props
97
+ }: React.ComponentProps<"div"> & {
98
+ showCloseButton?: boolean
99
+ }) {
100
+ return (
101
+ <div
102
+ data-slot="dialog-footer"
103
+ className={cn(
104
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
105
+ className
106
+ )}
107
+ {...props}
108
+ >
109
+ {children}
110
+ {showCloseButton && (
111
+ <DialogPrimitive.Close asChild>
112
+ <Button variant="outline">Close</Button>
113
+ </DialogPrimitive.Close>
114
+ )}
115
+ </div>
116
+ )
117
+ }
118
+
119
+ function DialogTitle({
120
+ className,
121
+ ...props
122
+ }: React.ComponentProps<typeof DialogPrimitive.Title>) {
123
+ return (
124
+ <DialogPrimitive.Title
125
+ data-slot="dialog-title"
126
+ className={cn("text-lg leading-none font-semibold", className)}
127
+ {...props}
128
+ />
129
+ )
130
+ }
131
+
132
+ function DialogDescription({
133
+ className,
134
+ ...props
135
+ }: React.ComponentProps<typeof DialogPrimitive.Description>) {
136
+ return (
137
+ <DialogPrimitive.Description
138
+ data-slot="dialog-description"
139
+ className={cn("text-sm text-muted-foreground", className)}
140
+ {...props}
141
+ />
142
+ )
143
+ }
144
+
145
+ export {
146
+ Dialog,
147
+ DialogClose,
148
+ DialogContent,
149
+ DialogDescription,
150
+ DialogFooter,
151
+ DialogHeader,
152
+ DialogOverlay,
153
+ DialogPortal,
154
+ DialogTitle,
155
+ DialogTrigger,
156
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from "react"
2
+ import { cn } from "cn"
3
+
4
+ function Input({ className, type, ...props }: React.ComponentProps<"input">) {
5
+ return (
6
+ <input
7
+ type={type}
8
+ data-slot="input"
9
+ className={cn(
10
+ "h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
11
+ "focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
12
+ "aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
13
+ className
14
+ )}
15
+ {...props}
16
+ />
17
+ )
18
+ }
19
+
20
+ export { Input }
@@ -0,0 +1,21 @@
1
+ import * as React from "react"
2
+ import { cn } from "cn"
3
+ import { Label as LabelPrimitive } from "radix-ui"
4
+
5
+ function Label({
6
+ className,
7
+ ...props
8
+ }: React.ComponentProps<typeof LabelPrimitive.Root>) {
9
+ return (
10
+ <LabelPrimitive.Root
11
+ data-slot="label"
12
+ className={cn(
13
+ "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
14
+ className
15
+ )}
16
+ {...props}
17
+ />
18
+ )
19
+ }
20
+
21
+ export { Label }