@xk2800/nextjs-template 0.7.1-beta.9 → 0.7.2-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.
- package/components/auth/oneTap.tsx +15 -5
- package/components/dashboard/admin/adminActivityLogsTable.tsx +4 -0
- package/components/dashboard/admin/adminUsersTable.tsx +154 -34
- package/components/dashboard/admin/impersonationLogCard.tsx +2 -2
- package/components/dashboard/appSidebar.tsx +2 -2
- package/components/dashboard/deleteAccountCard.tsx +31 -4
- package/components/dashboard/navStyleToggle.tsx +29 -0
- package/components/dashboard/topNav.tsx +95 -0
- package/components/email/email-template-banned.tsx +53 -0
- package/components/ui/alert-dialog.tsx +1 -1
- package/components/ui/avatar.tsx +1 -1
- package/components/ui/badge.tsx +4 -2
- package/components/ui/calendar.tsx +220 -0
- package/components/ui/category-selector.tsx +215 -0
- package/components/ui/chart.tsx +374 -0
- package/components/ui/column-picker.tsx +140 -0
- package/components/ui/command.tsx +184 -0
- package/components/ui/data-table.tsx +44 -6
- package/components/ui/date-picker-with-presets.tsx +122 -0
- package/components/ui/dialog.tsx +1 -1
- package/components/ui/disclaimer.tsx +4 -0
- package/components/ui/dropdown-menu.tsx +1 -1
- package/components/ui/field.tsx +248 -0
- package/components/ui/info-tooltip.tsx +53 -0
- package/components/ui/input.tsx +10 -1
- package/components/ui/label.tsx +1 -1
- package/components/ui/month-selector.tsx +194 -0
- package/components/ui/navigation-menu.tsx +168 -0
- package/components/ui/pagination.tsx +127 -0
- package/components/ui/popover.tsx +89 -0
- package/components/ui/source-selector.tsx +164 -0
- package/components/ui/switch.tsx +3 -3
- package/dist/activity/logger.d.mts +3 -1
- package/dist/activity/logger.d.ts +3 -1
- package/dist/activity/logger.js +20 -1
- package/dist/activity/logger.js.map +1 -1
- package/dist/activity/logger.mjs +4 -4
- package/dist/activity/queries.d.mts +1 -1
- package/dist/activity/queries.d.ts +1 -1
- package/dist/activity/queries.js +20 -1
- package/dist/activity/queries.js.map +1 -1
- package/dist/activity/queries.mjs +3 -3
- package/dist/admin/queries.js +20 -1
- package/dist/admin/queries.js.map +1 -1
- package/dist/admin/queries.mjs +3 -3
- package/dist/api/feedback.js +527 -71
- package/dist/api/feedback.js.map +1 -1
- package/dist/api/feedback.mjs +8 -8
- package/dist/api/marketing.js +527 -71
- package/dist/api/marketing.js.map +1 -1
- package/dist/api/marketing.mjs +10 -10
- package/dist/auth/helpers.d.mts +3 -3
- package/dist/auth/helpers.d.ts +3 -3
- package/dist/auth/helpers.js +525 -69
- package/dist/auth/helpers.js.map +1 -1
- package/dist/auth/helpers.mjs +8 -8
- package/dist/auth/index.d.mts +149 -10
- package/dist/auth/index.d.ts +149 -10
- package/dist/auth/index.js +525 -69
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/index.mjs +7 -7
- package/dist/auth-client/index.d.mts +16 -16
- package/dist/auth-client/index.d.ts +16 -16
- package/dist/{chunk-P2G23JMY.mjs → chunk-2BJ3B4FR.mjs} +5 -5
- package/dist/{chunk-P2G23JMY.mjs.map → chunk-2BJ3B4FR.mjs.map} +1 -1
- package/dist/{chunk-6MDQRT6U.mjs → chunk-653GF7OT.mjs} +4 -4
- package/dist/{chunk-6MDQRT6U.mjs.map → chunk-653GF7OT.mjs.map} +1 -1
- package/dist/chunk-EIS4SCQW.mjs +899 -0
- package/dist/chunk-EIS4SCQW.mjs.map +1 -0
- package/dist/{chunk-6Z3WUSDJ.mjs → chunk-H3XZTZ5K.mjs} +5 -5
- package/dist/{chunk-6Z3WUSDJ.mjs.map → chunk-H3XZTZ5K.mjs.map} +1 -1
- package/dist/{chunk-TKWNEKK6.mjs → chunk-HUEDEAY3.mjs} +8 -2
- package/dist/chunk-HUEDEAY3.mjs.map +1 -0
- package/dist/{chunk-ZJMFE5B2.mjs → chunk-K62JYJRR.mjs} +4 -4
- package/dist/{chunk-ZJMFE5B2.mjs.map → chunk-K62JYJRR.mjs.map} +1 -1
- package/dist/{chunk-OVKVD2HH.mjs → chunk-L242CZ64.mjs} +3 -3
- package/dist/{chunk-OVKVD2HH.mjs.map → chunk-L242CZ64.mjs.map} +1 -1
- package/dist/{chunk-C6RGN6QA.mjs → chunk-NQELV53D.mjs} +4 -4
- package/dist/{chunk-C6RGN6QA.mjs.map → chunk-NQELV53D.mjs.map} +1 -1
- package/dist/{chunk-7F2POZM6.mjs → chunk-O5EQYHNC.mjs} +4 -4
- package/dist/chunk-O5EQYHNC.mjs.map +1 -0
- package/dist/{chunk-TR5XFBTD.mjs → chunk-TE5BEAQB.mjs} +17 -4
- package/dist/chunk-TE5BEAQB.mjs.map +1 -0
- package/dist/config/env.d.mts +2 -0
- package/dist/config/env.d.ts +2 -0
- package/dist/config/env.js +6 -0
- package/dist/config/env.js.map +1 -1
- package/dist/config/env.mjs +1 -1
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.js +20 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/index.mjs +3 -3
- package/dist/db/schema.d.mts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/db/schema.js +14 -1
- package/dist/db/schema.js.map +1 -1
- package/dist/db/schema.mjs +1 -1
- package/dist/errors.js +20 -1
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +4 -4
- package/dist/marketing/index.js +6 -0
- package/dist/marketing/index.js.map +1 -1
- package/dist/marketing/index.mjs +3 -3
- package/dist/{schema-CN_Y6EXv.d.mts → schema-DzC5zdOq.d.mts} +146 -2
- package/dist/{schema-CN_Y6EXv.d.ts → schema-DzC5zdOq.d.ts} +146 -2
- package/dist/sessions/queries.js +20 -1
- package/dist/sessions/queries.js.map +1 -1
- package/dist/sessions/queries.mjs +3 -3
- package/dist/settings/queries.d.mts +1 -1
- package/dist/settings/queries.d.ts +1 -1
- package/dist/settings/queries.js +20 -1
- package/dist/settings/queries.js.map +1 -1
- package/dist/settings/queries.mjs +4 -4
- package/dist/users/queries.d.mts +3 -0
- package/dist/users/queries.d.ts +3 -0
- package/dist/users/queries.js +20 -1
- package/dist/users/queries.js.map +1 -1
- package/dist/users/queries.mjs +3 -3
- package/lib/maintenance.ts +0 -1
- package/lib/recalculate-columns.ts +8 -2
- package/package.json +28 -18
- package/styles/theme.css +6 -0
- package/dist/chunk-7F2POZM6.mjs.map +0 -1
- package/dist/chunk-7QVIOQ47.mjs +0 -462
- package/dist/chunk-7QVIOQ47.mjs.map +0 -1
- package/dist/chunk-TKWNEKK6.mjs.map +0 -1
- package/dist/chunk-TR5XFBTD.mjs.map +0 -1
|
@@ -6,6 +6,7 @@ import { ChevronLeft, ChevronRight } from "lucide-react"
|
|
|
6
6
|
import { cn } from "../../lib/utils"
|
|
7
7
|
import { Button } from "./button"
|
|
8
8
|
import { useDimensions } from "../../hooks/use-dimensions"
|
|
9
|
+
import { ColumnPicker, useColumnPickerEnabled, useHiddenColumns } from "./column-picker"
|
|
9
10
|
import {
|
|
10
11
|
MIN_CELL_WIDTH,
|
|
11
12
|
STICKY_BREAKPOINT,
|
|
@@ -23,6 +24,8 @@ import {
|
|
|
23
24
|
export { MIN_CELL_WIDTH, STICKY_BREAKPOINT, recalculateColumns }
|
|
24
25
|
export type { Column }
|
|
25
26
|
|
|
27
|
+
const ALIGN_CLASS = { left: undefined, center: "text-center", right: "text-right" } as const
|
|
28
|
+
|
|
26
29
|
function renderCell<TRow>(col: Column<TRow>, row: TRow): React.ReactNode {
|
|
27
30
|
if (col.renderer) return col.renderer(row)
|
|
28
31
|
const value = (row as Record<string, unknown>)[col.name]
|
|
@@ -150,10 +153,20 @@ export type DataTableProps<TRow> = {
|
|
|
150
153
|
/** Rows per page (client-side). Default `10`; `false` renders every row (e.g. server-paginated data). */
|
|
151
154
|
pageSize?: number | false
|
|
152
155
|
className?: string
|
|
156
|
+
/** Extra classes for a data row (e.g. to highlight a selected one). */
|
|
157
|
+
rowClassName?: (row: TRow) => string | undefined
|
|
158
|
+
/**
|
|
159
|
+
* Lets each user show/hide columns (remembered in localStorage under this id) via a
|
|
160
|
+
* "Columns" menu. The first column and `sticky` columns are always shown.
|
|
161
|
+
* Wrap in `<ColumnPickerProvider enabled={false}>` to turn it off app-wide.
|
|
162
|
+
*/
|
|
163
|
+
tableId?: string
|
|
164
|
+
/** Render the "Columns" menu for this table. Default `true`; only matters with `tableId`. */
|
|
165
|
+
columnPicker?: boolean
|
|
153
166
|
}
|
|
154
167
|
|
|
155
168
|
export function DataTable<TRow>({
|
|
156
|
-
columns,
|
|
169
|
+
columns: allColumns,
|
|
157
170
|
data,
|
|
158
171
|
getRowId,
|
|
159
172
|
autoCollapse = true,
|
|
@@ -162,8 +175,21 @@ export function DataTable<TRow>({
|
|
|
162
175
|
stickyBreakpoint,
|
|
163
176
|
pageSize = 10,
|
|
164
177
|
className,
|
|
178
|
+
rowClassName,
|
|
179
|
+
tableId,
|
|
180
|
+
columnPicker = true,
|
|
165
181
|
}: DataTableProps<TRow>) {
|
|
166
182
|
const { observe, width } = useDimensions()
|
|
183
|
+
const pickerEnabled = useColumnPickerEnabled()
|
|
184
|
+
const [userHidden] = useHiddenColumns(pickerEnabled ? tableId : undefined)
|
|
185
|
+
const columns = React.useMemo(
|
|
186
|
+
() =>
|
|
187
|
+
userHidden.length
|
|
188
|
+
? allColumns.filter((c, i) => i === 0 || c.sticky || !userHidden.includes(c.name))
|
|
189
|
+
: allColumns,
|
|
190
|
+
[allColumns, userHidden],
|
|
191
|
+
)
|
|
192
|
+
const toggleable = allColumns.filter((c, i) => i > 0 && !c.sticky)
|
|
167
193
|
const collapseEnabled = autoCollapse && !expandRenderer
|
|
168
194
|
const minCell = minCellWidth ?? MIN_CELL_WIDTH
|
|
169
195
|
|
|
@@ -200,11 +226,17 @@ export function DataTable<TRow>({
|
|
|
200
226
|
}
|
|
201
227
|
}, [width, columns, collapseEnabled, minCellWidth, stickyBreakpoint])
|
|
202
228
|
|
|
203
|
-
const visible = collapseEnabled
|
|
204
|
-
? colState.filter((c) => !c.autoHide)
|
|
205
|
-
: colState
|
|
206
229
|
const hidden = collapseEnabled ? colState.filter((c) => c.autoHide) : []
|
|
207
230
|
const isCollapsed = hidden.length > 0
|
|
231
|
+
const visible = !collapseEnabled
|
|
232
|
+
? colState
|
|
233
|
+
: isCollapsed
|
|
234
|
+
? colState
|
|
235
|
+
.map((c, i) => [c, c.priority ?? i] as const)
|
|
236
|
+
.filter(([c]) => !c.autoHide)
|
|
237
|
+
.sort((a, b) => a[1] - b[1])
|
|
238
|
+
.map(([c]) => c)
|
|
239
|
+
: colState
|
|
208
240
|
|
|
209
241
|
const [page, setPage] = React.useState(1)
|
|
210
242
|
const pages = pageSize ? Math.max(1, Math.ceil(data.length / pageSize)) : 1
|
|
@@ -224,6 +256,11 @@ export function DataTable<TRow>({
|
|
|
224
256
|
|
|
225
257
|
return (
|
|
226
258
|
<div className={className}>
|
|
259
|
+
{tableId && pickerEnabled && columnPicker && toggleable.length > 0 && (
|
|
260
|
+
<div className="flex justify-end pb-2">
|
|
261
|
+
<ColumnPicker tableId={tableId} columns={toggleable} />
|
|
262
|
+
</div>
|
|
263
|
+
)}
|
|
227
264
|
<div
|
|
228
265
|
ref={observe}
|
|
229
266
|
data-slot="data-table"
|
|
@@ -241,6 +278,7 @@ export function DataTable<TRow>({
|
|
|
241
278
|
{visible.map((col) => (
|
|
242
279
|
<TableHead
|
|
243
280
|
key={col.name}
|
|
281
|
+
className={ALIGN_CLASS[col.align ?? "left"]}
|
|
244
282
|
style={{ minWidth: col.minWidth ?? minCell, maxWidth: col.maxWidth }}
|
|
245
283
|
>
|
|
246
284
|
{col.title}
|
|
@@ -254,7 +292,7 @@ export function DataTable<TRow>({
|
|
|
254
292
|
const open = expanded.has(id)
|
|
255
293
|
return (
|
|
256
294
|
<React.Fragment key={id}>
|
|
257
|
-
<TableRow>
|
|
295
|
+
<TableRow className={rowClassName?.(row)}>
|
|
258
296
|
{isCollapsed && (
|
|
259
297
|
<TableCell className="w-8 align-top">
|
|
260
298
|
<button
|
|
@@ -276,7 +314,7 @@ export function DataTable<TRow>({
|
|
|
276
314
|
{visible.map((col) => (
|
|
277
315
|
<TableCell
|
|
278
316
|
key={col.name}
|
|
279
|
-
className="whitespace-normal break-words align-top"
|
|
317
|
+
className={cn("whitespace-normal break-words align-top", ALIGN_CLASS[col.align ?? "left"])}
|
|
280
318
|
style={{ maxWidth: col.maxWidth }}
|
|
281
319
|
>
|
|
282
320
|
{renderCell(col, row)}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { CalendarIcon } from "lucide-react"
|
|
5
|
+
import { format, startOfMonth, endOfMonth, startOfYear, subMonths, subDays } from "date-fns"
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
import { Button } from "./button"
|
|
8
|
+
import { Calendar } from "./calendar"
|
|
9
|
+
import {
|
|
10
|
+
Popover,
|
|
11
|
+
PopoverContent,
|
|
12
|
+
PopoverTrigger,
|
|
13
|
+
} from "./popover"
|
|
14
|
+
|
|
15
|
+
interface DatePickerWithPresetsProps {
|
|
16
|
+
date?: Date
|
|
17
|
+
onDateChange?: (date: Date | undefined) => void
|
|
18
|
+
placeholder?: string
|
|
19
|
+
className?: string
|
|
20
|
+
disableFutureDates?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function DatePickerWithPresets({
|
|
24
|
+
date,
|
|
25
|
+
onDateChange,
|
|
26
|
+
placeholder = "Pick a date",
|
|
27
|
+
className,
|
|
28
|
+
disableFutureDates = false,
|
|
29
|
+
}: DatePickerWithPresetsProps) {
|
|
30
|
+
const [open, setOpen] = React.useState(false)
|
|
31
|
+
|
|
32
|
+
const allPresets = [
|
|
33
|
+
{
|
|
34
|
+
name: "Today",
|
|
35
|
+
date: new Date(),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "Yesterday",
|
|
39
|
+
date: subDays(new Date(), 1),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "This Month Start",
|
|
43
|
+
date: startOfMonth(new Date()),
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Last Month Start",
|
|
47
|
+
date: startOfMonth(subMonths(new Date(), 1)),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "This Year Start",
|
|
51
|
+
date: startOfYear(new Date()),
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
// Filter out future dates if disableFutureDates is true
|
|
56
|
+
const presets = disableFutureDates
|
|
57
|
+
? allPresets.filter(preset => preset.date <= new Date())
|
|
58
|
+
: allPresets
|
|
59
|
+
|
|
60
|
+
const handlePresetClick = (presetDate: Date) => {
|
|
61
|
+
onDateChange?.(presetDate)
|
|
62
|
+
setOpen(false)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const handleDateSelect = (selectedDate: Date | undefined) => {
|
|
66
|
+
onDateChange?.(selectedDate)
|
|
67
|
+
if (selectedDate) {
|
|
68
|
+
setOpen(false)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
74
|
+
<PopoverTrigger asChild>
|
|
75
|
+
<Button
|
|
76
|
+
variant="outline"
|
|
77
|
+
className={cn(
|
|
78
|
+
"w-full justify-start text-left font-normal",
|
|
79
|
+
!date && "text-muted-foreground",
|
|
80
|
+
className
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
<CalendarIcon className="mr-2 h-4 w-4" />
|
|
84
|
+
{date ? format(date, "PPP") : <span>{placeholder}</span>}
|
|
85
|
+
</Button>
|
|
86
|
+
</PopoverTrigger>
|
|
87
|
+
<PopoverContent className="w-auto p-0" align="start">
|
|
88
|
+
<div className="flex flex-col md:flex-row">
|
|
89
|
+
{/* Presets — bottom on mobile, left on desktop */}
|
|
90
|
+
<div className="order-last md:order-first flex flex-col gap-1 p-2 md:border-r md:min-w-[148px]">
|
|
91
|
+
<div className="text-xs font-medium text-muted-foreground px-2 py-1">
|
|
92
|
+
Presets
|
|
93
|
+
</div>
|
|
94
|
+
{presets.map((preset) => (
|
|
95
|
+
<Button
|
|
96
|
+
key={preset.name}
|
|
97
|
+
variant="ghost"
|
|
98
|
+
className="justify-start font-normal h-8"
|
|
99
|
+
onClick={() => handlePresetClick(preset.date)}
|
|
100
|
+
>
|
|
101
|
+
{preset.name}
|
|
102
|
+
</Button>
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
{/* Calendar — top on mobile, right on desktop */}
|
|
106
|
+
<div className="order-first md:order-last p-2">
|
|
107
|
+
<Calendar
|
|
108
|
+
mode="single"
|
|
109
|
+
selected={date}
|
|
110
|
+
onSelect={handleDateSelect}
|
|
111
|
+
captionLayout="dropdown"
|
|
112
|
+
disabled={disableFutureDates ? (date) => date > new Date() : undefined}
|
|
113
|
+
defaultMonth={date || new Date()}
|
|
114
|
+
startMonth={disableFutureDates ? new Date(2020, 0, 1) : undefined}
|
|
115
|
+
endMonth={disableFutureDates ? new Date() : undefined}
|
|
116
|
+
/>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</PopoverContent>
|
|
120
|
+
</Popover>
|
|
121
|
+
)
|
|
122
|
+
}
|
package/components/ui/dialog.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import
|
|
4
|
+
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
|
5
5
|
import { Check, ChevronRight, Circle } from "lucide-react"
|
|
6
6
|
|
|
7
7
|
import { cn } from "../../lib/utils"
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useMemo } from "react"
|
|
4
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
import { Label } from "./label"
|
|
8
|
+
import { Separator } from "./separator"
|
|
9
|
+
|
|
10
|
+
function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">) {
|
|
11
|
+
return (
|
|
12
|
+
<fieldset
|
|
13
|
+
data-slot="field-set"
|
|
14
|
+
className={cn(
|
|
15
|
+
"flex flex-col gap-6",
|
|
16
|
+
"has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function FieldLegend({
|
|
25
|
+
className,
|
|
26
|
+
variant = "legend",
|
|
27
|
+
...props
|
|
28
|
+
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
|
|
29
|
+
return (
|
|
30
|
+
<legend
|
|
31
|
+
data-slot="field-legend"
|
|
32
|
+
data-variant={variant}
|
|
33
|
+
className={cn(
|
|
34
|
+
"mb-3 font-medium",
|
|
35
|
+
"data-[variant=legend]:text-base",
|
|
36
|
+
"data-[variant=label]:text-sm",
|
|
37
|
+
className
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function FieldGroup({ className, ...props }: React.ComponentProps<"div">) {
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
data-slot="field-group"
|
|
48
|
+
className={cn(
|
|
49
|
+
"group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
|
|
50
|
+
className
|
|
51
|
+
)}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const fieldVariants = cva(
|
|
58
|
+
"group/field flex w-full gap-3 data-[invalid=true]:text-destructive",
|
|
59
|
+
{
|
|
60
|
+
variants: {
|
|
61
|
+
orientation: {
|
|
62
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
63
|
+
horizontal: [
|
|
64
|
+
"flex-row items-center",
|
|
65
|
+
"[&>[data-slot=field-label]]:flex-auto",
|
|
66
|
+
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
67
|
+
],
|
|
68
|
+
responsive: [
|
|
69
|
+
"flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto",
|
|
70
|
+
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
71
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
orientation: "vertical",
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
function Field({
|
|
82
|
+
className,
|
|
83
|
+
orientation = "vertical",
|
|
84
|
+
...props
|
|
85
|
+
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
role="group"
|
|
89
|
+
data-slot="field"
|
|
90
|
+
data-orientation={orientation}
|
|
91
|
+
className={cn(fieldVariants({ orientation }), className)}
|
|
92
|
+
{...props}
|
|
93
|
+
/>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function FieldContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
98
|
+
return (
|
|
99
|
+
<div
|
|
100
|
+
data-slot="field-content"
|
|
101
|
+
className={cn(
|
|
102
|
+
"group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
|
|
103
|
+
className
|
|
104
|
+
)}
|
|
105
|
+
{...props}
|
|
106
|
+
/>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function FieldLabel({
|
|
111
|
+
className,
|
|
112
|
+
...props
|
|
113
|
+
}: React.ComponentProps<typeof Label>) {
|
|
114
|
+
return (
|
|
115
|
+
<Label
|
|
116
|
+
data-slot="field-label"
|
|
117
|
+
className={cn(
|
|
118
|
+
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50",
|
|
119
|
+
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4",
|
|
120
|
+
"has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10",
|
|
121
|
+
className
|
|
122
|
+
)}
|
|
123
|
+
{...props}
|
|
124
|
+
/>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function FieldTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
data-slot="field-label"
|
|
132
|
+
className={cn(
|
|
133
|
+
"flex w-fit items-center gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50",
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
{...props}
|
|
137
|
+
/>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function FieldDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
142
|
+
return (
|
|
143
|
+
<p
|
|
144
|
+
data-slot="field-description"
|
|
145
|
+
className={cn(
|
|
146
|
+
"text-sm leading-normal font-normal text-muted-foreground group-has-[[data-orientation=horizontal]]/field:text-balance",
|
|
147
|
+
"last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5",
|
|
148
|
+
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
|
|
149
|
+
className
|
|
150
|
+
)}
|
|
151
|
+
{...props}
|
|
152
|
+
/>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function FieldSeparator({
|
|
157
|
+
children,
|
|
158
|
+
className,
|
|
159
|
+
...props
|
|
160
|
+
}: React.ComponentProps<"div"> & {
|
|
161
|
+
children?: React.ReactNode
|
|
162
|
+
}) {
|
|
163
|
+
return (
|
|
164
|
+
<div
|
|
165
|
+
data-slot="field-separator"
|
|
166
|
+
data-content={!!children}
|
|
167
|
+
className={cn(
|
|
168
|
+
"relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
|
|
169
|
+
className
|
|
170
|
+
)}
|
|
171
|
+
{...props}
|
|
172
|
+
>
|
|
173
|
+
<Separator className="absolute inset-0 top-1/2" />
|
|
174
|
+
{children && (
|
|
175
|
+
<span
|
|
176
|
+
className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
|
|
177
|
+
data-slot="field-separator-content"
|
|
178
|
+
>
|
|
179
|
+
{children}
|
|
180
|
+
</span>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function FieldError({
|
|
187
|
+
className,
|
|
188
|
+
children,
|
|
189
|
+
errors,
|
|
190
|
+
...props
|
|
191
|
+
}: React.ComponentProps<"div"> & {
|
|
192
|
+
errors?: Array<{ message?: string } | undefined>
|
|
193
|
+
}) {
|
|
194
|
+
const content = useMemo(() => {
|
|
195
|
+
if (children) {
|
|
196
|
+
return children
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (!errors?.length) {
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const uniqueErrors = [
|
|
204
|
+
...new Map(errors.map((error) => [error?.message, error])).values(),
|
|
205
|
+
]
|
|
206
|
+
|
|
207
|
+
if (uniqueErrors?.length == 1) {
|
|
208
|
+
return uniqueErrors[0]?.message
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return (
|
|
212
|
+
<ul className="ml-4 flex list-disc flex-col gap-1">
|
|
213
|
+
{uniqueErrors.map(
|
|
214
|
+
(error, index) =>
|
|
215
|
+
error?.message && <li key={index}>{error.message}</li>
|
|
216
|
+
)}
|
|
217
|
+
</ul>
|
|
218
|
+
)
|
|
219
|
+
}, [children, errors])
|
|
220
|
+
|
|
221
|
+
if (!content) {
|
|
222
|
+
return null
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div
|
|
227
|
+
role="alert"
|
|
228
|
+
data-slot="field-error"
|
|
229
|
+
className={cn("text-sm font-normal text-destructive", className)}
|
|
230
|
+
{...props}
|
|
231
|
+
>
|
|
232
|
+
{content}
|
|
233
|
+
</div>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
Field,
|
|
239
|
+
FieldLabel,
|
|
240
|
+
FieldDescription,
|
|
241
|
+
FieldError,
|
|
242
|
+
FieldGroup,
|
|
243
|
+
FieldLegend,
|
|
244
|
+
FieldSeparator,
|
|
245
|
+
FieldSet,
|
|
246
|
+
FieldContent,
|
|
247
|
+
FieldTitle,
|
|
248
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* InfoTooltip — a small ⓘ icon that opens a popover with a plain-English
|
|
5
|
+
* explanation. Works on mobile (click) and desktop (click).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useState } from 'react'
|
|
9
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover'
|
|
10
|
+
import { Info } from 'lucide-react'
|
|
11
|
+
import { cn } from '../../lib/utils'
|
|
12
|
+
|
|
13
|
+
interface InfoTooltipProps {
|
|
14
|
+
/** Short headline shown in bold */
|
|
15
|
+
title: string
|
|
16
|
+
/** Plain-English explanation — write like you're explaining to a 10-year-old */
|
|
17
|
+
children: React.ReactNode
|
|
18
|
+
className?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function InfoTooltip({ title, children, className }: InfoTooltipProps) {
|
|
22
|
+
const [open, setOpen] = useState(false)
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
26
|
+
<PopoverTrigger asChild>
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
className={cn(
|
|
30
|
+
'inline-flex items-center justify-center rounded-full text-muted-foreground',
|
|
31
|
+
'hover:text-foreground transition-colors',
|
|
32
|
+
'focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-ring',
|
|
33
|
+
className
|
|
34
|
+
)}
|
|
35
|
+
aria-label={`Explain: ${title}`}
|
|
36
|
+
>
|
|
37
|
+
<Info className="h-3.5 w-3.5" />
|
|
38
|
+
</button>
|
|
39
|
+
</PopoverTrigger>
|
|
40
|
+
<PopoverContent
|
|
41
|
+
side="top"
|
|
42
|
+
align="start"
|
|
43
|
+
className="w-72 p-3 text-sm shadow-lg"
|
|
44
|
+
onClick={(e) => e.stopPropagation()}
|
|
45
|
+
>
|
|
46
|
+
<p className="font-semibold text-foreground mb-1">{title}</p>
|
|
47
|
+
<div className="text-muted-foreground text-xs leading-relaxed space-y-1">
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
</PopoverContent>
|
|
51
|
+
</Popover>
|
|
52
|
+
)
|
|
53
|
+
}
|
package/components/ui/input.tsx
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
1
3
|
import * as React from "react"
|
|
2
4
|
|
|
3
5
|
import { cn } from "../../lib/utils"
|
|
4
6
|
|
|
5
|
-
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
7
|
+
function Input({ className, type, onKeyDown, ...props }: React.ComponentProps<"input">) {
|
|
6
8
|
return (
|
|
7
9
|
<input
|
|
8
10
|
type={type}
|
|
9
11
|
data-slot="input"
|
|
12
|
+
onKeyDown={(e) => {
|
|
13
|
+
// number inputs don't step with the arrow keys
|
|
14
|
+
if (type === "number" && (e.key === "ArrowUp" || e.key === "ArrowDown")) e.preventDefault()
|
|
15
|
+
onKeyDown?.(e)
|
|
16
|
+
}}
|
|
10
17
|
className={cn(
|
|
11
18
|
"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",
|
|
12
19
|
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
13
20
|
"aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
|
|
21
|
+
// hide the browser's number spinners
|
|
22
|
+
"[&[type=number]]:[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
14
23
|
className
|
|
15
24
|
)}
|
|
16
25
|
{...props}
|
package/components/ui/label.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import
|
|
4
|
+
import { Label as LabelPrimitive } from "radix-ui"
|
|
5
5
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
6
6
|
|
|
7
7
|
import { cn } from "../../lib/utils"
|