@xk2800/nextjs-template 0.7.1-beta.11 → 0.7.1-beta.13
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/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 +31 -2
- package/components/ui/date-picker-with-presets.tsx +122 -0
- package/components/ui/disclaimer.tsx +4 -0
- 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/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/dist/activity/queries.d.mts +1 -1
- package/dist/activity/queries.d.ts +1 -1
- package/dist/auth/index.d.mts +2 -2
- package/dist/auth/index.d.ts +2 -2
- package/dist/db/index.d.mts +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/schema.d.mts +1 -1
- package/dist/db/schema.d.ts +1 -1
- package/dist/{schema-CN_Y6EXv.d.mts → schema-lgO4CzE4.d.mts} +1 -1
- package/dist/{schema-CN_Y6EXv.d.ts → schema-lgO4CzE4.d.ts} +1 -1
- package/dist/settings/queries.d.mts +1 -1
- package/dist/settings/queries.d.ts +1 -1
- package/package.json +24 -2
|
@@ -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,
|
|
@@ -152,10 +153,20 @@ export type DataTableProps<TRow> = {
|
|
|
152
153
|
/** Rows per page (client-side). Default `10`; `false` renders every row (e.g. server-paginated data). */
|
|
153
154
|
pageSize?: number | false
|
|
154
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
|
|
155
166
|
}
|
|
156
167
|
|
|
157
168
|
export function DataTable<TRow>({
|
|
158
|
-
columns,
|
|
169
|
+
columns: allColumns,
|
|
159
170
|
data,
|
|
160
171
|
getRowId,
|
|
161
172
|
autoCollapse = true,
|
|
@@ -164,8 +175,21 @@ export function DataTable<TRow>({
|
|
|
164
175
|
stickyBreakpoint,
|
|
165
176
|
pageSize = 10,
|
|
166
177
|
className,
|
|
178
|
+
rowClassName,
|
|
179
|
+
tableId,
|
|
180
|
+
columnPicker = true,
|
|
167
181
|
}: DataTableProps<TRow>) {
|
|
168
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)
|
|
169
193
|
const collapseEnabled = autoCollapse && !expandRenderer
|
|
170
194
|
const minCell = minCellWidth ?? MIN_CELL_WIDTH
|
|
171
195
|
|
|
@@ -226,6 +250,11 @@ export function DataTable<TRow>({
|
|
|
226
250
|
|
|
227
251
|
return (
|
|
228
252
|
<div className={className}>
|
|
253
|
+
{tableId && pickerEnabled && columnPicker && toggleable.length > 0 && (
|
|
254
|
+
<div className="flex justify-end pb-2">
|
|
255
|
+
<ColumnPicker tableId={tableId} columns={toggleable} />
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
229
258
|
<div
|
|
230
259
|
ref={observe}
|
|
231
260
|
data-slot="data-table"
|
|
@@ -257,7 +286,7 @@ export function DataTable<TRow>({
|
|
|
257
286
|
const open = expanded.has(id)
|
|
258
287
|
return (
|
|
259
288
|
<React.Fragment key={id}>
|
|
260
|
-
<TableRow>
|
|
289
|
+
<TableRow className={rowClassName?.(row)}>
|
|
261
290
|
{isCollapsed && (
|
|
262
291
|
<TableCell className="w-8 align-top">
|
|
263
292
|
<button
|
|
@@ -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
|
+
}
|
|
@@ -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}
|