sparkdesign 0.4.6 → 0.4.8
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/AI_README.md +60 -0
- package/README.md +1 -1
- package/cli/dist/commands/add.js +1 -1
- package/cli/dist/commands/init.js +1 -1
- package/cli/registry/AGENTS.md +9 -2
- package/cli/registry/agent-manifest.json +794 -0
- package/cli/registry/basic/alert-dialog.tsx +3 -6
- package/cli/registry/basic/alert.tsx +76 -0
- package/cli/registry/basic/aspect-ratio.tsx +8 -0
- package/cli/registry/basic/breadcrumb.tsx +117 -0
- package/cli/registry/basic/button-group.tsx +79 -0
- package/cli/registry/basic/button.tsx +19 -6
- package/cli/registry/basic/calendar.tsx +221 -0
- package/cli/registry/basic/card.tsx +115 -0
- package/cli/registry/basic/carousel.tsx +241 -0
- package/cli/registry/basic/chart.tsx +372 -0
- package/cli/registry/basic/checkbox.tsx +42 -0
- package/cli/registry/basic/collapsible-card.tsx +4 -6
- package/cli/registry/basic/combobox.tsx +133 -0
- package/cli/registry/basic/command.tsx +184 -0
- package/cli/registry/basic/context-menu.tsx +238 -0
- package/cli/registry/basic/data-table.tsx +73 -0
- package/cli/registry/basic/date-picker.tsx +84 -0
- package/cli/registry/basic/dialog.tsx +164 -0
- package/cli/registry/basic/direction.tsx +25 -0
- package/cli/registry/basic/drawer.tsx +162 -0
- package/cli/registry/basic/dropdown-menu.tsx +2 -7
- package/cli/registry/basic/empty.tsx +104 -0
- package/cli/registry/basic/field.tsx +248 -0
- package/cli/registry/basic/hover-card.tsx +57 -0
- package/cli/registry/basic/icon-button.tsx +18 -11
- package/cli/registry/basic/input-group.tsx +168 -0
- package/cli/registry/basic/input-otp.tsx +75 -0
- package/cli/registry/basic/input.tsx +43 -0
- package/cli/registry/basic/item.tsx +204 -0
- package/cli/registry/basic/label.tsx +24 -0
- package/cli/registry/basic/menubar.tsx +274 -0
- package/cli/registry/basic/native-select.tsx +62 -0
- package/cli/registry/basic/navigation-menu.tsx +168 -0
- package/cli/registry/basic/popover.tsx +58 -0
- package/cli/registry/basic/scroll-area.tsx +58 -0
- package/cli/registry/basic/select.tsx +24 -3
- package/cli/registry/basic/separator.tsx +26 -0
- package/cli/registry/basic/sheet.tsx +18 -0
- package/cli/registry/basic/spinner.tsx +20 -5
- package/cli/registry/basic/textarea.tsx +43 -0
- package/cli/registry/basic/toggle.tsx +1 -1
- package/cli/registry/basic/tooltip.tsx +2 -1
- package/cli/registry/basic/typography.tsx +1 -1
- package/cli/registry/chat/chat-input/chat-input-textarea.tsx +1 -1
- package/cli/registry/chat/chat-input/compound.tsx +4 -3
- package/cli/registry/chat/chat-input/context.tsx +4 -1
- package/cli/registry/chat/code-block-part.tsx +1 -1
- package/cli/registry/chat/conversation-anchor-nav.tsx +349 -0
- package/cli/registry/chat/file-attachment.tsx +2 -1
- package/cli/registry/chat/file-review-part.tsx +21 -21
- package/cli/registry/chat/markdown.tsx +2 -2
- package/cli/registry/chat/queue-indicator.tsx +1 -0
- package/cli/registry/chat/streaming-markdown-block.tsx +12 -8
- package/cli/registry/chat/tool-invocation-card.tsx +4 -1
- package/cli/registry/lib/file-icon-maps.ts +22 -22
- package/cli/registry/meta.json +600 -15
- package/cli/registry/tokens/ontology.json +404 -0
- package/cli/registry/tokens/scale/presets/compact.css +16 -5
- package/cli/registry/tokens/scale/presets/dense.css +13 -2
- package/cli/registry/tokens/scale/presets/sharp.css +18 -6
- package/cli/registry/tokens/scale/presets/soft.css +23 -1
- package/dist/registry/basic/alert-dialog.d.ts +1 -1
- package/dist/registry/basic/alert.d.ts +24 -0
- package/dist/registry/basic/aspect-ratio.d.ts +16 -0
- package/dist/registry/basic/avatar.d.ts +1 -1
- package/dist/registry/basic/breadcrumb.d.ts +24 -0
- package/dist/registry/basic/button-group.d.ts +26 -0
- package/dist/registry/basic/button.d.ts +3 -1
- package/dist/registry/basic/calendar.d.ts +22 -0
- package/dist/registry/basic/card.d.ts +32 -0
- package/dist/registry/basic/carousel.d.ts +19 -0
- package/dist/registry/basic/chart.d.ts +55 -0
- package/dist/registry/basic/checkbox.d.ts +21 -0
- package/dist/registry/basic/combobox.d.ts +37 -0
- package/dist/registry/basic/command.d.ts +18 -0
- package/dist/registry/basic/context-menu.d.ts +44 -0
- package/dist/registry/basic/data-table.d.ts +26 -0
- package/dist/registry/basic/date-picker.d.ts +27 -0
- package/dist/registry/basic/dialog.d.ts +39 -0
- package/dist/registry/basic/direction.d.ts +19 -0
- package/dist/registry/basic/drawer.d.ts +37 -0
- package/dist/registry/basic/empty.d.ts +22 -0
- package/dist/registry/basic/field.d.ts +24 -0
- package/dist/registry/basic/hover-card.d.ts +22 -0
- package/dist/registry/basic/icon-button.d.ts +2 -1
- package/dist/registry/basic/input-group.d.ts +29 -0
- package/dist/registry/basic/input-otp.d.ts +22 -0
- package/dist/registry/basic/input.d.ts +20 -0
- package/dist/registry/basic/item.d.ts +34 -0
- package/dist/registry/basic/label.d.ts +16 -0
- package/dist/registry/basic/menubar.d.ts +37 -0
- package/dist/registry/basic/native-select.d.ts +18 -0
- package/dist/registry/basic/navigation-menu.d.ts +25 -0
- package/dist/registry/basic/popover.d.ts +23 -0
- package/dist/registry/basic/resizable.d.ts +48 -48
- package/dist/registry/basic/scroll-area.d.ts +5 -0
- package/dist/registry/basic/select.d.ts +7 -2
- package/dist/registry/basic/separator.d.ts +16 -0
- package/dist/registry/basic/sheet.d.ts +13 -0
- package/dist/registry/basic/spinner.d.ts +6 -2
- package/dist/registry/basic/tag.d.ts +1 -1
- package/dist/registry/basic/textarea.d.ts +21 -0
- package/dist/registry/chat/chat-input/context.d.ts +3 -1
- package/dist/registry/chat/conversation-anchor-nav.d.ts +72 -0
- package/dist/registry/chat/tool-invocation-card.d.ts +2 -0
- package/dist/scale/computed.css +11 -0
- package/dist/scale/config.css +11 -0
- package/dist/scale/presets/compact.css +23 -5
- package/dist/scale/presets/dense.css +20 -2
- package/dist/scale/presets/sharp.css +25 -6
- package/dist/scale/presets/soft.css +30 -1
- package/dist/spark-design.cjs.js +37 -33
- package/dist/spark-design.es.js +10324 -8950
- package/dist/sparkdesign.css +1 -1
- package/dist/src/components/basic/Alert/index.d.ts +13 -0
- package/dist/src/components/basic/AspectRatio/index.d.ts +13 -0
- package/dist/src/components/basic/Breadcrumb/index.d.ts +12 -0
- package/dist/src/components/basic/ButtonGroup/index.d.ts +13 -0
- package/dist/src/components/basic/Calendar/index.d.ts +13 -0
- package/dist/src/components/basic/Card/index.d.ts +13 -0
- package/dist/src/components/basic/Carousel/index.d.ts +12 -0
- package/dist/src/components/basic/Chart/index.d.ts +13 -0
- package/dist/src/components/basic/Checkbox/index.d.ts +13 -0
- package/dist/src/components/basic/Combobox/index.d.ts +13 -0
- package/dist/src/components/basic/Command/index.d.ts +12 -0
- package/dist/src/components/basic/ContextMenu/index.d.ts +19 -0
- package/dist/src/components/basic/DataTable/index.d.ts +13 -0
- package/dist/src/components/basic/DatePicker/index.d.ts +13 -0
- package/dist/src/components/basic/Dialog/index.d.ts +16 -0
- package/dist/src/components/basic/Direction/index.d.ts +13 -0
- package/dist/src/components/basic/Drawer/index.d.ts +16 -0
- package/dist/src/components/basic/Empty/index.d.ts +12 -0
- package/dist/src/components/basic/Field/index.d.ts +12 -0
- package/dist/src/components/basic/HoverCard/index.d.ts +16 -0
- package/dist/src/components/basic/Input/index.d.ts +13 -0
- package/dist/src/components/basic/InputGroup/index.d.ts +12 -0
- package/dist/src/components/basic/InputOTP/index.d.ts +12 -0
- package/dist/src/components/basic/Item/index.d.ts +12 -0
- package/dist/src/components/basic/Label/index.d.ts +13 -0
- package/dist/src/components/basic/Menubar/index.d.ts +12 -0
- package/dist/src/components/basic/NativeSelect/index.d.ts +12 -0
- package/dist/src/components/basic/NavigationMenu/index.d.ts +12 -0
- package/dist/src/components/basic/Popover/index.d.ts +16 -0
- package/dist/src/components/basic/ScrollArea/index.d.ts +12 -0
- package/dist/src/components/basic/Separator/index.d.ts +13 -0
- package/dist/src/components/basic/Sheet/index.d.ts +13 -0
- package/dist/src/components/basic/Textarea/index.d.ts +13 -0
- package/dist/src/components/chat/ConversationAnchorNav/index.d.ts +13 -0
- package/dist/src/components/chat/StreamingMarkdownBlock/index.d.ts +13 -0
- package/dist/src/components/index.d.ts +58 -1
- package/dist/src/lib/index.d.ts +1 -1
- package/dist/src/lib/motion.d.ts +79 -0
- package/dist/theme-base.css +22 -0
- package/dist/themes/dark-mint.css +6 -0
- package/dist/themes/dark-parchment.css +6 -0
- package/dist/themes/light-parchment.css +6 -0
- package/dist/tokens/AGENTS.md +1 -0
- package/dist/tokens/scale/computed.css +11 -0
- package/dist/tokens/scale/config.css +11 -0
- package/dist/tokens/scale/presets/compact.css +23 -5
- package/dist/tokens/scale/presets/dense.css +20 -2
- package/dist/tokens/scale/presets/sharp.css +25 -6
- package/dist/tokens/scale/presets/soft.css +30 -1
- package/dist/tokens/theme-base.css +22 -0
- package/dist/tokens/themes/dark-mint.css +6 -0
- package/dist/tokens/themes/dark-parchment.css +6 -0
- package/dist/tokens/themes/light-parchment.css +6 -0
- package/docs/agent/component-selection.md +60 -0
- package/docs/agent/token-ontology.md +37 -0
- package/package.json +31 -5
- package/registry/agent-manifest.json +794 -0
- package/registry/tokens/ontology.json +404 -0
- package/dist/_basePickBy-DnQN8w3y.js +0 -151
- package/dist/_basePickBy-a-kPMlkg.cjs +0 -1
- package/dist/_baseUniq-B-N2NQ50.js +0 -614
- package/dist/_baseUniq-Cc_zbSif.cjs +0 -1
- package/dist/arc-BQBhijZ6.js +0 -83
- package/dist/arc-mWQt0Yph.cjs +0 -1
- package/dist/architectureDiagram-VXUJARFQ-BMZEucno.cjs +0 -36
- package/dist/architectureDiagram-VXUJARFQ-DTdjD3Bp.js +0 -4661
- package/dist/blockDiagram-VD42YOAC-CzHn0yob.js +0 -2256
- package/dist/blockDiagram-VD42YOAC-DDxdHAlz.cjs +0 -122
- package/dist/c4Diagram-YG6GDRKO-4Gz0I4gj.cjs +0 -10
- package/dist/c4Diagram-YG6GDRKO-BIy--yVN.js +0 -1580
- package/dist/channel-BQn0o8bs.js +0 -5
- package/dist/channel-DaN7XniJ.cjs +0 -1
- package/dist/chunk-4BX2VUAB-BlQFTQqz.cjs +0 -1
- package/dist/chunk-4BX2VUAB-Czitj3Kc.js +0 -8
- package/dist/chunk-55IACEB6-DXacNZbO.js +0 -8
- package/dist/chunk-55IACEB6-DnDxpye9.cjs +0 -1
- package/dist/chunk-B4BG7PRW-CBdN0q_V.js +0 -1375
- package/dist/chunk-B4BG7PRW-DbGvUkGO.cjs +0 -165
- package/dist/chunk-DI55MBZ5-D1YJMs6x.cjs +0 -220
- package/dist/chunk-DI55MBZ5-NCQTvayw.js +0 -1370
- package/dist/chunk-FMBD7UC4-CsGMbrtr.js +0 -19
- package/dist/chunk-FMBD7UC4-Di7cUUh5.cjs +0 -15
- package/dist/chunk-QN33PNHL-0j5LC8Lm.cjs +0 -1
- package/dist/chunk-QN33PNHL-3GERZBRm.js +0 -19
- package/dist/chunk-QZHKN3VN-AVEY9ImQ.js +0 -15
- package/dist/chunk-QZHKN3VN-s8Z0a8mc.cjs +0 -1
- package/dist/chunk-TZMSLE5B-CAf87HPt.cjs +0 -1
- package/dist/chunk-TZMSLE5B-sbiflal0.js +0 -64
- package/dist/classDiagram-2ON5EDUG-Ct9JLIN2.cjs +0 -1
- package/dist/classDiagram-2ON5EDUG-Dzfrft3a.js +0 -16
- package/dist/classDiagram-v2-WZHVMYZB-Ct9JLIN2.cjs +0 -1
- package/dist/classDiagram-v2-WZHVMYZB-Dzfrft3a.js +0 -16
- package/dist/clone-Cde_NQ8V.js +0 -8
- package/dist/clone-DCNjWuM2.cjs +0 -1
- package/dist/cose-bilkent-S5V4N54A-0uLijMro.cjs +0 -1
- package/dist/cose-bilkent-S5V4N54A-Bb08N431.js +0 -2608
- package/dist/cytoscape.esm-CNUX3VTg.cjs +0 -321
- package/dist/cytoscape.esm-Cvf3sx9F.js +0 -18704
- package/dist/dagre-6UL2VRFP-CY_Wz5Zd.js +0 -444
- package/dist/dagre-6UL2VRFP-Dxe7_qZc.cjs +0 -4
- package/dist/defaultLocale-BgPVtth8.js +0 -171
- package/dist/defaultLocale-C4wbwF1n.cjs +0 -1
- package/dist/diagram-PSM6KHXK-D2bdb7MT.js +0 -531
- package/dist/diagram-PSM6KHXK-YF69SUjY.cjs +0 -24
- package/dist/diagram-QEK2KX5R-BpUSoh0-.js +0 -217
- package/dist/diagram-QEK2KX5R-DZPGteon.cjs +0 -43
- package/dist/diagram-S2PKOQOG-ht-zdvFG.cjs +0 -24
- package/dist/diagram-S2PKOQOG-zFeLJ50Z.js +0 -142
- package/dist/erDiagram-Q2GNP2WA-B38iJ6ts.js +0 -841
- package/dist/erDiagram-Q2GNP2WA-RgS80DDU.cjs +0 -60
- package/dist/flowDiagram-NV44I4VS-BHilOs2p.cjs +0 -162
- package/dist/flowDiagram-NV44I4VS-BrBJcoce.js +0 -1620
- package/dist/ganttDiagram-JELNMOA3-pZiJeFio.cjs +0 -267
- package/dist/ganttDiagram-JELNMOA3-tw6FhkWJ.js +0 -2670
- package/dist/gitGraphDiagram-V2S2FVAM-BWn5uIK5.js +0 -699
- package/dist/gitGraphDiagram-V2S2FVAM-DKKeG-9R.cjs +0 -65
- package/dist/graph-DIbblrZP.cjs +0 -1
- package/dist/graph-DPcK91G3.js +0 -247
- package/dist/infoDiagram-HS3SLOUP-B8gwwhct.cjs +0 -2
- package/dist/infoDiagram-HS3SLOUP-D47PNcP_.js +0 -24
- package/dist/init-CHZsXQcr.cjs +0 -1
- package/dist/init-DjUOC4st.js +0 -16
- package/dist/journeyDiagram-XKPGCS4Q-BG3cfhyU.js +0 -834
- package/dist/journeyDiagram-XKPGCS4Q-D8DVLJof.cjs +0 -139
- package/dist/kanban-definition-3W4ZIXB7-4OCnEouP.cjs +0 -89
- package/dist/kanban-definition-3W4ZIXB7-CWi_ssF9.js +0 -719
- package/dist/layout-Byuh8f-J.cjs +0 -1
- package/dist/layout-CdLdvj1j.js +0 -1335
- package/dist/linear-C2Q_PI9B.js +0 -259
- package/dist/linear-C69aPBW1.cjs +0 -1
- package/dist/mermaid.core-DBwAx_jp.cjs +0 -249
- package/dist/mermaid.core-gFR0XUlD.js +0 -15300
- package/dist/mindmap-definition-VGOIOE7T-8P7obVV4.cjs +0 -68
- package/dist/mindmap-definition-VGOIOE7T-DnOa7WJ9.js +0 -784
- package/dist/ordinal-B6-f3MAq.js +0 -61
- package/dist/ordinal-CagbB1m8.cjs +0 -1
- package/dist/pieDiagram-ADFJNKIX-5NAlvhMo.js +0 -161
- package/dist/pieDiagram-ADFJNKIX-CQBG4yR9.cjs +0 -30
- package/dist/quadrantDiagram-AYHSOK5B-Oe4y7RZ0.cjs +0 -7
- package/dist/quadrantDiagram-AYHSOK5B-rh2DPEP1.js +0 -1022
- package/dist/requirementDiagram-UZGBJVZJ-DcWaCuXr.js +0 -850
- package/dist/requirementDiagram-UZGBJVZJ-gfdlrFiq.cjs +0 -64
- package/dist/sankeyDiagram-TZEHDZUN-CQIKFwD0.js +0 -810
- package/dist/sankeyDiagram-TZEHDZUN-DvPtzQvC.cjs +0 -10
- package/dist/sequenceDiagram-WL72ISMW-BNrsMagL.cjs +0 -145
- package/dist/sequenceDiagram-WL72ISMW-iCX3ckKx.js +0 -2511
- package/dist/stateDiagram-FKZM4ZOC-DBvJ_eeL.cjs +0 -1
- package/dist/stateDiagram-FKZM4ZOC-ZVsJlaHJ.js +0 -263
- package/dist/stateDiagram-v2-4FDKWEC3-CB_nTHcE.js +0 -16
- package/dist/stateDiagram-v2-4FDKWEC3-Xkx17v6T.cjs +0 -1
- package/dist/timeline-definition-IT6M3QCI-BmGkYQiz.cjs +0 -61
- package/dist/timeline-definition-IT6M3QCI-Ck8zTt6w.js +0 -795
- package/dist/treemap-GDKQZRPO-B9sfERx8.js +0 -17922
- package/dist/treemap-GDKQZRPO-BVfJRs0Z.cjs +0 -160
- package/dist/xychartDiagram-PRI3JC2R-By_S8NzN.js +0 -1340
- package/dist/xychartDiagram-PRI3JC2R-CNfDrGxM.cjs +0 -7
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Command as CommandPrimitive } from "cmdk"
|
|
5
|
+
import { SearchIcon } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
import {
|
|
9
|
+
Dialog,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogDescription,
|
|
12
|
+
DialogHeader,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from "./dialog"
|
|
15
|
+
|
|
16
|
+
function Command({
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<typeof CommandPrimitive>) {
|
|
20
|
+
return (
|
|
21
|
+
<CommandPrimitive
|
|
22
|
+
data-slot="command"
|
|
23
|
+
className={cn(
|
|
24
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-bg-container text-text",
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function CommandDialog({
|
|
33
|
+
title = "Command Palette",
|
|
34
|
+
description = "Search for a command to run...",
|
|
35
|
+
children,
|
|
36
|
+
className,
|
|
37
|
+
showCloseButton = true,
|
|
38
|
+
...props
|
|
39
|
+
}: React.ComponentProps<typeof Dialog> & {
|
|
40
|
+
title?: string
|
|
41
|
+
description?: string
|
|
42
|
+
className?: string
|
|
43
|
+
showCloseButton?: boolean
|
|
44
|
+
}) {
|
|
45
|
+
return (
|
|
46
|
+
<Dialog {...props}>
|
|
47
|
+
<DialogHeader className="sr-only">
|
|
48
|
+
<DialogTitle>{title}</DialogTitle>
|
|
49
|
+
<DialogDescription>{description}</DialogDescription>
|
|
50
|
+
</DialogHeader>
|
|
51
|
+
<DialogContent
|
|
52
|
+
className={cn("overflow-hidden p-0", className)}
|
|
53
|
+
hideCloseButton={!showCloseButton}
|
|
54
|
+
>
|
|
55
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-text-tertiary [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
|
|
56
|
+
{children}
|
|
57
|
+
</Command>
|
|
58
|
+
</DialogContent>
|
|
59
|
+
</Dialog>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function CommandInput({
|
|
64
|
+
className,
|
|
65
|
+
...props
|
|
66
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
data-slot="command-input-wrapper"
|
|
70
|
+
className="flex h-9 items-center gap-2 border-b px-3"
|
|
71
|
+
>
|
|
72
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
73
|
+
<CommandPrimitive.Input
|
|
74
|
+
data-slot="command-input"
|
|
75
|
+
className={cn(
|
|
76
|
+
"flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-text-tertiary disabled:cursor-not-allowed disabled:opacity-50",
|
|
77
|
+
className
|
|
78
|
+
)}
|
|
79
|
+
{...props}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function CommandList({
|
|
86
|
+
className,
|
|
87
|
+
...props
|
|
88
|
+
}: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
89
|
+
return (
|
|
90
|
+
<CommandPrimitive.List
|
|
91
|
+
data-slot="command-list"
|
|
92
|
+
className={cn(
|
|
93
|
+
"max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
94
|
+
className
|
|
95
|
+
)}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function CommandEmpty({
|
|
102
|
+
...props
|
|
103
|
+
}: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
104
|
+
return (
|
|
105
|
+
<CommandPrimitive.Empty
|
|
106
|
+
data-slot="command-empty"
|
|
107
|
+
className="py-6 text-center text-sm"
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function CommandGroup({
|
|
114
|
+
className,
|
|
115
|
+
...props
|
|
116
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
117
|
+
return (
|
|
118
|
+
<CommandPrimitive.Group
|
|
119
|
+
data-slot="command-group"
|
|
120
|
+
className={cn(
|
|
121
|
+
"overflow-hidden p-1 text-text [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-text-tertiary",
|
|
122
|
+
className
|
|
123
|
+
)}
|
|
124
|
+
{...props}
|
|
125
|
+
/>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function CommandSeparator({
|
|
130
|
+
className,
|
|
131
|
+
...props
|
|
132
|
+
}: React.ComponentProps<typeof CommandPrimitive.Separator>) {
|
|
133
|
+
return (
|
|
134
|
+
<CommandPrimitive.Separator
|
|
135
|
+
data-slot="command-separator"
|
|
136
|
+
className={cn("-mx-1 h-px bg-border", className)}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function CommandItem({
|
|
143
|
+
className,
|
|
144
|
+
...props
|
|
145
|
+
}: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
146
|
+
return (
|
|
147
|
+
<CommandPrimitive.Item
|
|
148
|
+
data-slot="command-item"
|
|
149
|
+
className={cn(
|
|
150
|
+
"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-fill-secondary data-[selected=true]:text-text [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-text-tertiary",
|
|
151
|
+
className
|
|
152
|
+
)}
|
|
153
|
+
{...props}
|
|
154
|
+
/>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function CommandShortcut({
|
|
159
|
+
className,
|
|
160
|
+
...props
|
|
161
|
+
}: React.ComponentProps<"span">) {
|
|
162
|
+
return (
|
|
163
|
+
<span
|
|
164
|
+
data-slot="command-shortcut"
|
|
165
|
+
className={cn(
|
|
166
|
+
"ml-auto text-xs tracking-widest text-text-tertiary",
|
|
167
|
+
className
|
|
168
|
+
)}
|
|
169
|
+
{...props}
|
|
170
|
+
/>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export {
|
|
175
|
+
Command,
|
|
176
|
+
CommandDialog,
|
|
177
|
+
CommandInput,
|
|
178
|
+
CommandList,
|
|
179
|
+
CommandEmpty,
|
|
180
|
+
CommandGroup,
|
|
181
|
+
CommandItem,
|
|
182
|
+
CommandShortcut,
|
|
183
|
+
CommandSeparator,
|
|
184
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { motion } from 'framer-motion'
|
|
3
|
+
import * as ContextMenuPrimitive from '@radix-ui/react-context-menu'
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
5
|
+
import { cn } from '@/lib/utils'
|
|
6
|
+
import { MOTION_SCALE_IN } from '@/lib/motion'
|
|
7
|
+
import { ArrowRightLine, CheckLine } from './icons-inline'
|
|
8
|
+
import { getThemeFromDocument } from './theme-from-document'
|
|
9
|
+
|
|
10
|
+
const ContextMenu = ContextMenuPrimitive.Root
|
|
11
|
+
const ContextMenuTrigger = ContextMenuPrimitive.Trigger
|
|
12
|
+
const ContextMenuGroup = ContextMenuPrimitive.Group
|
|
13
|
+
const ContextMenuPortal = ContextMenuPrimitive.Portal
|
|
14
|
+
const ContextMenuSub = ContextMenuPrimitive.Sub
|
|
15
|
+
const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup
|
|
16
|
+
|
|
17
|
+
const contentClasses =
|
|
18
|
+
'z-50 min-w-32 overflow-hidden rounded-lg border border-border-tertiary bg-bg-container p-1 text-text shadow-lg outline-none'
|
|
19
|
+
|
|
20
|
+
export interface ContextMenuContentProps
|
|
21
|
+
extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> {
|
|
22
|
+
dataStyle?: string
|
|
23
|
+
dataTheme?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ContextMenuContent = React.forwardRef<
|
|
27
|
+
React.ElementRef<typeof ContextMenuPrimitive.Content>,
|
|
28
|
+
ContextMenuContentProps
|
|
29
|
+
>(({ className, children, dataStyle, dataTheme, ...props }, ref) => {
|
|
30
|
+
const fromDoc = getThemeFromDocument()
|
|
31
|
+
const dataProps =
|
|
32
|
+
dataStyle !== undefined
|
|
33
|
+
? { 'data-style': dataStyle, 'data-theme': dataTheme ?? fromDoc['data-theme'] ?? '' }
|
|
34
|
+
: fromDoc
|
|
35
|
+
return (
|
|
36
|
+
<ContextMenuPrimitive.Portal>
|
|
37
|
+
<div style={{ display: 'contents' }} {...dataProps}>
|
|
38
|
+
<ContextMenuPrimitive.Content
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(contentClasses, className)}
|
|
41
|
+
{...props}
|
|
42
|
+
>
|
|
43
|
+
<motion.div
|
|
44
|
+
{...MOTION_SCALE_IN}
|
|
45
|
+
>
|
|
46
|
+
{children}
|
|
47
|
+
</motion.div>
|
|
48
|
+
</ContextMenuPrimitive.Content>
|
|
49
|
+
</div>
|
|
50
|
+
</ContextMenuPrimitive.Portal>
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName
|
|
54
|
+
|
|
55
|
+
const subTriggerVariants = cva(
|
|
56
|
+
'flex h-9 w-full cursor-pointer select-none items-center gap-2 rounded-sm px-3 text-sm outline-none hover:bg-fill-secondary focus:bg-fill-secondary data-[highlighted]:bg-fill-secondary data-[state=open]:bg-fill-secondary',
|
|
57
|
+
{
|
|
58
|
+
variants: { inset: { true: 'pl-8 pr-3', false: '' } },
|
|
59
|
+
defaultVariants: { inset: false },
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
const ContextMenuSubTrigger = React.forwardRef<
|
|
64
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
|
|
65
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> &
|
|
66
|
+
VariantProps<typeof subTriggerVariants>
|
|
67
|
+
>(({ className, inset = false, children, ...props }, ref) => (
|
|
68
|
+
<ContextMenuPrimitive.SubTrigger
|
|
69
|
+
ref={ref}
|
|
70
|
+
className={cn(subTriggerVariants({ inset }), className)}
|
|
71
|
+
{...props}
|
|
72
|
+
>
|
|
73
|
+
{children}
|
|
74
|
+
<span className="ml-auto flex h-4 w-4 items-center justify-center">
|
|
75
|
+
<ArrowRightLine className="h-4 w-4" />
|
|
76
|
+
</span>
|
|
77
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
78
|
+
))
|
|
79
|
+
ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName
|
|
80
|
+
|
|
81
|
+
const ContextMenuSubContent = React.forwardRef<
|
|
82
|
+
React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
|
|
83
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent> & {
|
|
84
|
+
dataStyle?: string
|
|
85
|
+
dataTheme?: string
|
|
86
|
+
}
|
|
87
|
+
>(({ className, dataStyle, dataTheme, ...props }, ref) => {
|
|
88
|
+
const fromDoc = getThemeFromDocument()
|
|
89
|
+
const dataProps =
|
|
90
|
+
dataStyle !== undefined
|
|
91
|
+
? { 'data-style': dataStyle, 'data-theme': dataTheme ?? fromDoc['data-theme'] ?? '' }
|
|
92
|
+
: fromDoc
|
|
93
|
+
return (
|
|
94
|
+
<ContextMenuPrimitive.Portal>
|
|
95
|
+
<div style={{ display: 'contents' }} {...dataProps}>
|
|
96
|
+
<ContextMenuPrimitive.SubContent
|
|
97
|
+
ref={ref}
|
|
98
|
+
className={cn(contentClasses, className)}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
</ContextMenuPrimitive.Portal>
|
|
103
|
+
)
|
|
104
|
+
})
|
|
105
|
+
ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName
|
|
106
|
+
|
|
107
|
+
const itemVariants = cva(
|
|
108
|
+
'relative flex h-9 w-full min-w-0 cursor-pointer select-none items-center gap-2 rounded-sm px-3 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
109
|
+
{
|
|
110
|
+
variants: {
|
|
111
|
+
variant: {
|
|
112
|
+
default:
|
|
113
|
+
'hover:bg-fill-secondary focus:bg-fill-secondary focus:text-text data-[highlighted]:bg-fill-secondary data-[highlighted]:text-text',
|
|
114
|
+
destructive:
|
|
115
|
+
'text-error hover:bg-error-bg focus:bg-error-bg focus:text-error data-[highlighted]:bg-error-bg data-[highlighted]:text-error',
|
|
116
|
+
},
|
|
117
|
+
inset: { true: 'pl-8 pr-3', false: '' },
|
|
118
|
+
},
|
|
119
|
+
defaultVariants: { variant: 'default', inset: false },
|
|
120
|
+
},
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
const ContextMenuItem = React.forwardRef<
|
|
124
|
+
React.ElementRef<typeof ContextMenuPrimitive.Item>,
|
|
125
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> &
|
|
126
|
+
VariantProps<typeof itemVariants>
|
|
127
|
+
>(({ className, inset = false, variant = 'default', ...props }, ref) => (
|
|
128
|
+
<ContextMenuPrimitive.Item
|
|
129
|
+
ref={ref}
|
|
130
|
+
className={cn(itemVariants({ variant, inset }), className)}
|
|
131
|
+
{...props}
|
|
132
|
+
/>
|
|
133
|
+
))
|
|
134
|
+
ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName
|
|
135
|
+
|
|
136
|
+
const itemIndicatorClasses =
|
|
137
|
+
'relative flex h-9 w-full min-w-0 cursor-pointer select-none items-center gap-2 rounded-sm pl-8 pr-3 text-sm outline-none hover:bg-fill-secondary focus:bg-fill-secondary focus:text-text data-[highlighted]:bg-fill-secondary data-[highlighted]:text-text data-[disabled]:pointer-events-none data-[disabled]:opacity-50'
|
|
138
|
+
|
|
139
|
+
const ContextMenuCheckboxItem = React.forwardRef<
|
|
140
|
+
React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
|
|
141
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
|
|
142
|
+
>(({ className, children, checked, ...rest }, ref) => (
|
|
143
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
144
|
+
ref={ref}
|
|
145
|
+
checked={checked}
|
|
146
|
+
className={cn(itemIndicatorClasses, className)}
|
|
147
|
+
{...rest}
|
|
148
|
+
>
|
|
149
|
+
<span className="absolute left-2 top-1/2 flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center">
|
|
150
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
151
|
+
<CheckLine className="h-4 w-4" />
|
|
152
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
153
|
+
</span>
|
|
154
|
+
{children}
|
|
155
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
156
|
+
))
|
|
157
|
+
ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName
|
|
158
|
+
|
|
159
|
+
const ContextMenuRadioItem = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
|
|
162
|
+
>(({ className, children, ...props }, ref) => (
|
|
163
|
+
<ContextMenuPrimitive.RadioItem
|
|
164
|
+
ref={ref}
|
|
165
|
+
className={cn(itemIndicatorClasses, className)}
|
|
166
|
+
{...props}
|
|
167
|
+
>
|
|
168
|
+
<span className="absolute left-2 top-1/2 flex h-3.5 w-3.5 -translate-y-1/2 items-center justify-center">
|
|
169
|
+
<ContextMenuPrimitive.ItemIndicator>
|
|
170
|
+
<div className="h-2 w-2 rounded-full bg-primary" />
|
|
171
|
+
</ContextMenuPrimitive.ItemIndicator>
|
|
172
|
+
</span>
|
|
173
|
+
{children}
|
|
174
|
+
</ContextMenuPrimitive.RadioItem>
|
|
175
|
+
))
|
|
176
|
+
ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName
|
|
177
|
+
|
|
178
|
+
const labelVariants = cva(
|
|
179
|
+
'flex h-9 items-center px-3 text-sm font-semibold text-text-secondary',
|
|
180
|
+
{
|
|
181
|
+
variants: { inset: { true: 'pl-8 pr-3', false: '' } },
|
|
182
|
+
defaultVariants: { inset: false },
|
|
183
|
+
},
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
const ContextMenuLabel = React.forwardRef<
|
|
187
|
+
React.ElementRef<typeof ContextMenuPrimitive.Label>,
|
|
188
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> &
|
|
189
|
+
VariantProps<typeof labelVariants>
|
|
190
|
+
>(({ className, inset = false, ...props }, ref) => (
|
|
191
|
+
<ContextMenuPrimitive.Label
|
|
192
|
+
ref={ref}
|
|
193
|
+
className={cn(labelVariants({ inset }), className)}
|
|
194
|
+
{...props}
|
|
195
|
+
/>
|
|
196
|
+
))
|
|
197
|
+
ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName
|
|
198
|
+
|
|
199
|
+
const ContextMenuSeparator = React.forwardRef<
|
|
200
|
+
React.ElementRef<typeof ContextMenuPrimitive.Separator>,
|
|
201
|
+
React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
|
|
202
|
+
>(({ className, ...props }, ref) => (
|
|
203
|
+
<ContextMenuPrimitive.Separator
|
|
204
|
+
ref={ref}
|
|
205
|
+
className={cn('my-1 mx-1 h-px bg-border-tertiary', className)}
|
|
206
|
+
{...props}
|
|
207
|
+
/>
|
|
208
|
+
))
|
|
209
|
+
ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName
|
|
210
|
+
|
|
211
|
+
const ContextMenuShortcut: React.FC<React.HTMLAttributes<HTMLSpanElement>> = ({
|
|
212
|
+
className,
|
|
213
|
+
...props
|
|
214
|
+
}) => (
|
|
215
|
+
<span
|
|
216
|
+
className={cn('ml-auto text-xs tracking-widest text-text-tertiary', className)}
|
|
217
|
+
{...props}
|
|
218
|
+
/>
|
|
219
|
+
)
|
|
220
|
+
ContextMenuShortcut.displayName = 'ContextMenuShortcut'
|
|
221
|
+
|
|
222
|
+
export {
|
|
223
|
+
ContextMenu,
|
|
224
|
+
ContextMenuTrigger,
|
|
225
|
+
ContextMenuContent,
|
|
226
|
+
ContextMenuItem,
|
|
227
|
+
ContextMenuCheckboxItem,
|
|
228
|
+
ContextMenuRadioItem,
|
|
229
|
+
ContextMenuLabel,
|
|
230
|
+
ContextMenuSeparator,
|
|
231
|
+
ContextMenuShortcut,
|
|
232
|
+
ContextMenuGroup,
|
|
233
|
+
ContextMenuPortal,
|
|
234
|
+
ContextMenuSub,
|
|
235
|
+
ContextMenuSubContent,
|
|
236
|
+
ContextMenuSubTrigger,
|
|
237
|
+
ContextMenuRadioGroup,
|
|
238
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { cn } from '@/lib/utils'
|
|
3
|
+
import {
|
|
4
|
+
Table,
|
|
5
|
+
TableBody,
|
|
6
|
+
TableCell,
|
|
7
|
+
TableHead,
|
|
8
|
+
TableHeader,
|
|
9
|
+
TableRow,
|
|
10
|
+
} from './table'
|
|
11
|
+
|
|
12
|
+
export interface DataTableColumn<TData> {
|
|
13
|
+
key: string
|
|
14
|
+
header: React.ReactNode
|
|
15
|
+
cell?: (row: TData, index: number) => React.ReactNode
|
|
16
|
+
accessor?: keyof TData
|
|
17
|
+
className?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DataTableProps<TData> extends React.HTMLAttributes<HTMLDivElement> {
|
|
21
|
+
columns: DataTableColumn<TData>[]
|
|
22
|
+
data: TData[]
|
|
23
|
+
emptyText?: React.ReactNode
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function DataTable<TData extends Record<string, unknown>>({
|
|
27
|
+
columns,
|
|
28
|
+
data,
|
|
29
|
+
emptyText = 'No results.',
|
|
30
|
+
className,
|
|
31
|
+
...props
|
|
32
|
+
}: DataTableProps<TData>) {
|
|
33
|
+
return (
|
|
34
|
+
<div className={cn('w-full overflow-auto rounded-lg border border-border-tertiary', className)} {...props}>
|
|
35
|
+
<Table>
|
|
36
|
+
<TableHeader>
|
|
37
|
+
<TableRow>
|
|
38
|
+
{columns.map((column) => (
|
|
39
|
+
<TableHead key={column.key} className={column.className}>
|
|
40
|
+
{column.header}
|
|
41
|
+
</TableHead>
|
|
42
|
+
))}
|
|
43
|
+
</TableRow>
|
|
44
|
+
</TableHeader>
|
|
45
|
+
<TableBody>
|
|
46
|
+
{data.length > 0 ? (
|
|
47
|
+
data.map((row, rowIndex) => (
|
|
48
|
+
<TableRow key={rowIndex}>
|
|
49
|
+
{columns.map((column) => (
|
|
50
|
+
<TableCell key={column.key} className={column.className}>
|
|
51
|
+
{column.cell
|
|
52
|
+
? column.cell(row, rowIndex)
|
|
53
|
+
: column.accessor
|
|
54
|
+
? String(row[column.accessor] ?? '')
|
|
55
|
+
: null}
|
|
56
|
+
</TableCell>
|
|
57
|
+
))}
|
|
58
|
+
</TableRow>
|
|
59
|
+
))
|
|
60
|
+
) : (
|
|
61
|
+
<TableRow>
|
|
62
|
+
<TableCell colSpan={columns.length} className="h-24 text-center text-text-tertiary">
|
|
63
|
+
{emptyText}
|
|
64
|
+
</TableCell>
|
|
65
|
+
</TableRow>
|
|
66
|
+
)}
|
|
67
|
+
</TableBody>
|
|
68
|
+
</Table>
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { DataTable }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { format } from 'date-fns'
|
|
3
|
+
import { CalendarIcon } from 'lucide-react'
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/lib/utils'
|
|
6
|
+
import { Button } from './button'
|
|
7
|
+
import { Calendar } from './calendar'
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from './popover'
|
|
9
|
+
|
|
10
|
+
export interface DatePickerProps {
|
|
11
|
+
value?: Date
|
|
12
|
+
defaultValue?: Date
|
|
13
|
+
onChange?: (date: Date | undefined) => void
|
|
14
|
+
placeholder?: React.ReactNode
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
className?: string
|
|
17
|
+
align?: 'start' | 'center' | 'end'
|
|
18
|
+
formatString?: string
|
|
19
|
+
id?: string
|
|
20
|
+
name?: string
|
|
21
|
+
'aria-label'?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function DatePicker({
|
|
25
|
+
value,
|
|
26
|
+
defaultValue,
|
|
27
|
+
onChange,
|
|
28
|
+
placeholder = 'Pick a date',
|
|
29
|
+
disabled,
|
|
30
|
+
className,
|
|
31
|
+
align = 'start',
|
|
32
|
+
formatString = 'PPP',
|
|
33
|
+
id,
|
|
34
|
+
name,
|
|
35
|
+
'aria-label': ariaLabel,
|
|
36
|
+
}: DatePickerProps) {
|
|
37
|
+
const isControlled = value !== undefined
|
|
38
|
+
const [internal, setInternal] = React.useState<Date | undefined>(defaultValue)
|
|
39
|
+
const [open, setOpen] = React.useState(false)
|
|
40
|
+
const selected = isControlled ? value : internal
|
|
41
|
+
|
|
42
|
+
const handleSelect = React.useCallback(
|
|
43
|
+
(next: Date | undefined) => {
|
|
44
|
+
if (!isControlled) setInternal(next)
|
|
45
|
+
onChange?.(next)
|
|
46
|
+
if (next) setOpen(false)
|
|
47
|
+
},
|
|
48
|
+
[isControlled, onChange],
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
53
|
+
<PopoverTrigger asChild>
|
|
54
|
+
<Button
|
|
55
|
+
id={id}
|
|
56
|
+
variant="outline"
|
|
57
|
+
disabled={disabled}
|
|
58
|
+
aria-label={ariaLabel ?? (typeof placeholder === 'string' ? placeholder : 'Pick a date')}
|
|
59
|
+
className={cn(
|
|
60
|
+
'w-60 justify-start text-left font-normal',
|
|
61
|
+
!selected && 'text-text-tertiary',
|
|
62
|
+
className,
|
|
63
|
+
)}
|
|
64
|
+
suffixIcon={<CalendarIcon className="ml-auto size-4 opacity-60" />}
|
|
65
|
+
>
|
|
66
|
+
{selected ? format(selected, formatString) : <span>{placeholder}</span>}
|
|
67
|
+
</Button>
|
|
68
|
+
</PopoverTrigger>
|
|
69
|
+
<PopoverContent className="w-auto p-0" align={align}>
|
|
70
|
+
<Calendar
|
|
71
|
+
mode="single"
|
|
72
|
+
selected={selected}
|
|
73
|
+
onSelect={handleSelect}
|
|
74
|
+
autoFocus
|
|
75
|
+
/>
|
|
76
|
+
{name ? (
|
|
77
|
+
<input type="hidden" name={name} value={selected ? selected.toISOString() : ''} />
|
|
78
|
+
) : null}
|
|
79
|
+
</PopoverContent>
|
|
80
|
+
</Popover>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { DatePicker }
|