@atelic-action/ui 0.17.2 → 1.0.0

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 (184) hide show
  1. package/README.md +428 -44
  2. package/bin/atelic-check-base-path.ts +5 -0
  3. package/bin/atelic-clean-sitemap.ts +5 -0
  4. package/bin/atelic-contact-canary.ts +5 -0
  5. package/bin/atelic-print-sheets.sh +1 -1
  6. package/bin/atelic-seal-document.mjs +1 -1
  7. package/bin/atelic-serve-static.ts +1 -1
  8. package/dist/gate/index.d.ts +1 -1
  9. package/dist/gate/index.js +1 -1
  10. package/dist/gate/middleware.d.ts +4 -1
  11. package/dist/gate/middleware.js +14 -5
  12. package/dist/gate/wall.d.ts +25 -0
  13. package/dist/gate/wall.js +41 -2
  14. package/dist/routing/basePath.d.ts +24 -0
  15. package/dist/routing/basePath.js +54 -0
  16. package/dist/vite/index.d.ts +3 -2
  17. package/dist/vite/index.js +3 -2
  18. package/dist/vite/marketing-config.d.ts +50 -0
  19. package/dist/vite/marketing-config.js +83 -0
  20. package/package.json +164 -5
  21. package/src/app/AppProvider.tsx +41 -0
  22. package/src/app/AuthGuard.tsx +27 -0
  23. package/src/app/CardErrorBoundary.tsx +39 -0
  24. package/src/app/ErrorFallback.tsx +39 -0
  25. package/src/app/GoogleGlyph.tsx +22 -0
  26. package/src/app/config.ts +54 -0
  27. package/src/app/configure.ts +18 -0
  28. package/src/app/context/AppContext.tsx +52 -0
  29. package/src/app/context/SidebarContext.tsx +124 -0
  30. package/src/app/context/UserContext.tsx +139 -0
  31. package/src/app/hooks/useDebounce.ts +12 -0
  32. package/src/app/hooks/useIsDesktop.ts +31 -0
  33. package/src/app/hooks/useWakeLock.ts +49 -0
  34. package/src/app/index.ts +64 -0
  35. package/src/app/layout/ActionButton.tsx +67 -0
  36. package/src/app/layout/AppLayout.tsx +110 -0
  37. package/src/app/layout/AppPage.tsx +268 -0
  38. package/src/app/layout/Breadcrumbs.tsx +57 -0
  39. package/src/app/layout/DesktopRail.tsx +168 -0
  40. package/src/app/layout/FormActionButtons.tsx +69 -0
  41. package/src/app/layout/MobileMenu.tsx +156 -0
  42. package/src/app/layout/MobileTabBar.tsx +43 -0
  43. package/src/app/layout/PageError.tsx +30 -0
  44. package/src/app/layout/PageSkeleton.tsx +65 -0
  45. package/src/app/layout/SectionCards.tsx +33 -0
  46. package/src/app/layout/UserMenu.tsx +104 -0
  47. package/src/app/layout/identity.ts +22 -0
  48. package/src/app/layout/index.ts +20 -0
  49. package/src/app/layout/nav.ts +52 -0
  50. package/src/app/lib/dates.ts +57 -0
  51. package/src/app/lib/env.ts +37 -0
  52. package/src/app/lib/format.ts +61 -0
  53. package/src/app/lib/http.ts +205 -0
  54. package/src/app/lib/lastAuth.ts +45 -0
  55. package/src/app/lib/oauth.ts +32 -0
  56. package/src/app/lib/publicRoutes.ts +33 -0
  57. package/src/app/lib/queryClient.ts +38 -0
  58. package/src/app/lib/search.ts +17 -0
  59. package/src/app/lib/session.ts +36 -0
  60. package/src/app/lib/tokenRefresh.ts +137 -0
  61. package/src/app/lib/transformKeys.ts +60 -0
  62. package/src/app/lib/units.ts +228 -0
  63. package/src/app/lib/unwrap.ts +48 -0
  64. package/src/app/lib/utils.ts +10 -0
  65. package/src/app/stores/authStore.ts +80 -0
  66. package/src/app/stores/storage.ts +40 -0
  67. package/src/app/stores/unitsStore.ts +54 -0
  68. package/src/app/types/index.ts +72 -0
  69. package/src/app/types/query.ts +11 -0
  70. package/src/app/ui/accordion.tsx +54 -0
  71. package/src/app/ui/alert-dialog.tsx +114 -0
  72. package/src/app/ui/alert.tsx +49 -0
  73. package/src/app/ui/avatar.tsx +45 -0
  74. package/src/app/ui/badge-list.tsx +51 -0
  75. package/src/app/ui/badge.tsx +33 -0
  76. package/src/app/ui/button.tsx +49 -0
  77. package/src/app/ui/callout.tsx +22 -0
  78. package/src/app/ui/card.tsx +55 -0
  79. package/src/app/ui/checkbox.tsx +26 -0
  80. package/src/app/ui/clear-button.tsx +42 -0
  81. package/src/app/ui/command.tsx +140 -0
  82. package/src/app/ui/country-dropdown.tsx +184 -0
  83. package/src/app/ui/dialog.tsx +104 -0
  84. package/src/app/ui/dropdown-menu.tsx +185 -0
  85. package/src/app/ui/form.tsx +172 -0
  86. package/src/app/ui/index.ts +36 -0
  87. package/src/app/ui/input.tsx +22 -0
  88. package/src/app/ui/label.tsx +19 -0
  89. package/src/app/ui/option-select.tsx +56 -0
  90. package/src/app/ui/pagination.tsx +90 -0
  91. package/src/app/ui/popover.tsx +29 -0
  92. package/src/app/ui/progress.tsx +25 -0
  93. package/src/app/ui/search-input.tsx +63 -0
  94. package/src/app/ui/select.tsx +151 -0
  95. package/src/app/ui/separator.tsx +24 -0
  96. package/src/app/ui/sheet.tsx +119 -0
  97. package/src/app/ui/slider.tsx +23 -0
  98. package/src/app/ui/switch.tsx +27 -0
  99. package/src/app/ui/textarea.tsx +21 -0
  100. package/src/app/ui/tooltip.tsx +32 -0
  101. package/src/artifact/ArtifactShell.tsx +2 -2
  102. package/src/artifact/Gate.tsx +2 -2
  103. package/src/artifact/Writeup.tsx +7 -7
  104. package/src/chrome/SiteShell.tsx +141 -0
  105. package/src/chrome/index.ts +2 -0
  106. package/src/components/Disclosure.tsx +80 -14
  107. package/src/components/GateLogin.tsx +1 -1
  108. package/src/components/Watermark.tsx +1 -1
  109. package/src/components/index.ts +6 -2
  110. package/src/gate/index.ts +1 -1
  111. package/src/gate/middleware.ts +17 -6
  112. package/src/gate/wall.ts +60 -2
  113. package/src/lib/basePathAudit.ts +96 -0
  114. package/src/lib/displayDate.ts +25 -0
  115. package/src/lib/honeypot.ts +11 -0
  116. package/src/lib/hours.ts +28 -0
  117. package/src/lib/sitemap.ts +34 -0
  118. package/src/lib/trackEvent.ts +26 -0
  119. package/src/lib/useOpenHeight.ts +28 -0
  120. package/src/primitives/Button.tsx +3 -1
  121. package/src/primitives/Chip.tsx +3 -1
  122. package/src/primitives/ImageFrame.tsx +48 -0
  123. package/src/primitives/ProseBlocks.tsx +67 -0
  124. package/src/primitives/QuoteCard.tsx +20 -0
  125. package/src/primitives/StarRow.tsx +37 -0
  126. package/src/primitives/TickList.tsx +24 -0
  127. package/src/primitives/index.ts +5 -0
  128. package/src/routing/BasePathProvider.tsx +47 -0
  129. package/src/routing/basePath.ts +57 -0
  130. package/src/routing/index.ts +8 -0
  131. package/src/scripts/check-base-path.ts +130 -0
  132. package/src/scripts/clean-sitemap.ts +27 -0
  133. package/src/scripts/contact-canary.ts +98 -0
  134. package/src/scripts/serve-static.ts +29 -3
  135. package/src/sections/BlogIndex.tsx +57 -0
  136. package/src/sections/BlogPost.tsx +65 -0
  137. package/src/sections/CTABanner.tsx +93 -0
  138. package/src/sections/CTASection.tsx +60 -0
  139. package/src/sections/ComparisonTable.tsx +114 -0
  140. package/src/sections/ContactForm.tsx +163 -0
  141. package/src/sections/ContactInfoCard.tsx +92 -0
  142. package/src/sections/CredentialList.tsx +28 -0
  143. package/src/sections/DeviceShowcase.tsx +39 -0
  144. package/src/sections/ExpandList.tsx +58 -0
  145. package/src/sections/FAQBrowser.tsx +283 -0
  146. package/src/sections/FeatureDetail.tsx +60 -0
  147. package/src/sections/FeatureGrid.tsx +83 -0
  148. package/src/sections/Gallery.tsx +84 -0
  149. package/src/sections/Hero.tsx +110 -0
  150. package/src/sections/HoursTable.tsx +23 -0
  151. package/src/sections/JumpRail.tsx +35 -0
  152. package/src/sections/LegalPage.tsx +43 -0
  153. package/src/sections/LocationSection.tsx +66 -0
  154. package/src/sections/Locations.tsx +71 -0
  155. package/src/sections/LogoMarquee.tsx +27 -0
  156. package/src/sections/MapEmbed.tsx +75 -0
  157. package/src/sections/MediaBand.tsx +20 -0
  158. package/src/sections/MenuList.tsx +44 -0
  159. package/src/sections/PageHero.tsx +25 -0
  160. package/src/sections/PressQuotes.tsx +51 -0
  161. package/src/sections/PricingBand.tsx +43 -0
  162. package/src/sections/PricingCard.tsx +36 -0
  163. package/src/sections/ProcessSteps.tsx +45 -0
  164. package/src/sections/ProfileCards.tsx +73 -0
  165. package/src/sections/RevealSlider.tsx +156 -0
  166. package/src/sections/ReviewCarousel.tsx +223 -0
  167. package/src/sections/ReviewWall.tsx +220 -0
  168. package/src/sections/SocialStrip.tsx +83 -0
  169. package/src/sections/SplitSection.tsx +56 -0
  170. package/src/sections/index.ts +76 -0
  171. package/src/sections/siteConfig.ts +201 -0
  172. package/src/styles/app.css +673 -0
  173. package/src/styles/artifact.css +472 -399
  174. package/src/styles/base.css +49 -47
  175. package/src/styles/chrome.css +71 -71
  176. package/src/styles/components.css +150 -140
  177. package/src/styles/gate.css +29 -29
  178. package/src/styles/primitives.css +190 -25
  179. package/src/styles/sections.css +2652 -0
  180. package/src/styles/star-rating.css +2 -2
  181. package/src/vite/index.ts +9 -2
  182. package/src/vite/marketing-config.ts +128 -0
  183. package/src/components/Collapsible.tsx +0 -43
  184. /package/src/scripts/{build-gate-payload.mjs → seal-document.mjs} +0 -0
@@ -0,0 +1,184 @@
1
+ "use client";
2
+ import { countries as countryList } from "country-data-list";
3
+ import { CheckIcon, ChevronDown, Globe } from "lucide-react";
4
+ import { forwardRef, useCallback, useEffect, useState } from "react";
5
+ import { CircleFlag } from "react-circle-flags";
6
+ import { cn } from "../lib/utils";
7
+ import {
8
+ Command,
9
+ CommandEmpty,
10
+ CommandGroup,
11
+ CommandInput,
12
+ CommandItem,
13
+ CommandList,
14
+ } from "./command";
15
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover";
16
+
17
+ export type Country = {
18
+ alpha2: string;
19
+ alpha3: string;
20
+ countryCallingCodes: string[];
21
+ currencies: string[];
22
+ emoji?: string;
23
+ ioc: string;
24
+ languages: string[];
25
+ name: string;
26
+ status: string;
27
+ };
28
+
29
+ interface CountryDropdownProps {
30
+ id?: string;
31
+ value?: string;
32
+ onChange?: (value: string) => void;
33
+ disabled?: boolean;
34
+ placeholder?: string;
35
+ className?: string;
36
+ }
37
+
38
+ // Filter to countries with emoji support, excluding deleted entries.
39
+ // North Korea (PRK) excluded due to international sanctions compliance.
40
+ const defaultOptions: Country[] = countryList.all.filter(
41
+ (country: Country) => country.emoji && country.status !== "deleted" && country.ioc !== "PRK",
42
+ );
43
+
44
+ const CountryDropdownComponent = (
45
+ {
46
+ id,
47
+ value,
48
+ onChange,
49
+ disabled = false,
50
+ placeholder = "Select country",
51
+ className,
52
+ }: CountryDropdownProps,
53
+ ref: React.ForwardedRef<HTMLButtonElement>,
54
+ ) => {
55
+ const [open, setOpen] = useState(false);
56
+ const [selectedCountry, setSelectedCountry] = useState<Country | null>(null);
57
+
58
+ useEffect(() => {
59
+ if (!value) {
60
+ setSelectedCountry(null);
61
+ return;
62
+ }
63
+ const country = defaultOptions.find((c) => c.name === value || c.alpha2 === value);
64
+ setSelectedCountry(country ?? null);
65
+ }, [value]);
66
+
67
+ const handleSelect = useCallback(
68
+ (country: Country) => {
69
+ setSelectedCountry(country);
70
+ onChange?.(country.name);
71
+ setOpen(false);
72
+ },
73
+ [onChange],
74
+ );
75
+
76
+ const handleClear = useCallback(() => {
77
+ setSelectedCountry(null);
78
+ onChange?.("");
79
+ setOpen(false);
80
+ }, [onChange]);
81
+
82
+ return (
83
+ <Popover open={open} onOpenChange={setOpen}>
84
+ <PopoverTrigger
85
+ id={id}
86
+ ref={ref}
87
+ className={cn(
88
+ "flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 hover:bg-secondary/80",
89
+ className,
90
+ )}
91
+ disabled={disabled}
92
+ >
93
+ {selectedCountry ? (
94
+ <div className="flex items-center flex-grow gap-2 overflow-hidden">
95
+ <div className="inline-flex items-center justify-center w-5 h-5 shrink-0 overflow-hidden rounded-full">
96
+ <CircleFlag countryCode={selectedCountry.alpha2.toLowerCase()} height={20} />
97
+ </div>
98
+ <span className="overflow-hidden text-ellipsis whitespace-nowrap">
99
+ {selectedCountry.name}
100
+ </span>
101
+ </div>
102
+ ) : (
103
+ <span className="flex items-center gap-2 text-muted-foreground">
104
+ <Globe size={16} />
105
+ {placeholder}
106
+ </span>
107
+ )}
108
+ <ChevronDown size={16} className="shrink-0 text-muted-foreground" />
109
+ </PopoverTrigger>
110
+ <PopoverContent
111
+ collisionPadding={10}
112
+ side="bottom"
113
+ className="min-w-(--radix-popper-anchor-width) p-0"
114
+ >
115
+ <Command className="w-full max-h-[200px] sm:max-h-[270px]">
116
+ <CommandList>
117
+ <div className="sticky top-0 z-10 bg-popover">
118
+ <CommandInput placeholder="Search country..." />
119
+ </div>
120
+ <CommandEmpty>No country found.</CommandEmpty>
121
+ <CommandGroup>
122
+ <CommandItem className="flex items-center w-full gap-2" onSelect={handleClear}>
123
+ <div className="flex flex-grow space-x-2 overflow-hidden">
124
+ <div className="inline-flex items-center justify-center w-5 h-5 shrink-0">
125
+ <Globe size={16} className="text-muted-foreground" />
126
+ </div>
127
+ <span className="overflow-hidden text-ellipsis whitespace-nowrap text-muted-foreground">
128
+ Not specified
129
+ </span>
130
+ </div>
131
+ <CheckIcon
132
+ className={cn(
133
+ "ml-auto h-4 w-4 shrink-0",
134
+ !selectedCountry ? "opacity-100" : "opacity-0",
135
+ )}
136
+ />
137
+ </CommandItem>
138
+ {defaultOptions
139
+ .filter((x) => x.name)
140
+ .map((option) => (
141
+ <CommandItem
142
+ className="flex items-center w-full gap-2"
143
+ key={option.alpha3}
144
+ onSelect={() => handleSelect(option)}
145
+ >
146
+ <div className="flex flex-grow space-x-2 overflow-hidden">
147
+ <div className="inline-flex items-center justify-center w-5 h-5 shrink-0 overflow-hidden rounded-full">
148
+ <CircleFlag countryCode={option.alpha2.toLowerCase()} height={20} />
149
+ </div>
150
+ <span className="overflow-hidden text-ellipsis whitespace-nowrap">
151
+ {option.name}
152
+ </span>
153
+ </div>
154
+ <CheckIcon
155
+ className={cn(
156
+ "ml-auto h-4 w-4 shrink-0",
157
+ selectedCountry?.alpha3 === option.alpha3 ? "opacity-100" : "opacity-0",
158
+ )}
159
+ />
160
+ </CommandItem>
161
+ ))}
162
+ </CommandGroup>
163
+ </CommandList>
164
+ </Command>
165
+ </PopoverContent>
166
+ </Popover>
167
+ );
168
+ };
169
+
170
+ CountryDropdownComponent.displayName = "CountryDropdown";
171
+ export const CountryDropdown = forwardRef(CountryDropdownComponent);
172
+
173
+ /**
174
+ * Get the flag component for a country name.
175
+ */
176
+ export function getCountryFlag(countryName: string): React.ReactNode {
177
+ const country = defaultOptions.find((c) => c.name === countryName);
178
+ if (!country) return null;
179
+ return (
180
+ <span className="inline-flex items-center justify-center w-4 h-4 shrink-0 overflow-hidden rounded-full">
181
+ <CircleFlag countryCode={country.alpha2.toLowerCase()} height={16} />
182
+ </span>
183
+ );
184
+ }
@@ -0,0 +1,104 @@
1
+ "use client";
2
+
3
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
4
+ import { X } from "lucide-react";
5
+ import * as React from "react";
6
+
7
+ import { cn } from "../lib/utils";
8
+
9
+ const Dialog = DialogPrimitive.Root;
10
+
11
+ const DialogTrigger = DialogPrimitive.Trigger;
12
+
13
+ const DialogPortal = DialogPrimitive.Portal;
14
+
15
+ const DialogClose = DialogPrimitive.Close;
16
+
17
+ const DialogOverlay = React.forwardRef<
18
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
19
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
20
+ >(({ className, ...props }, ref) => (
21
+ <DialogPrimitive.Overlay
22
+ ref={ref}
23
+ className={cn(
24
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
25
+ className,
26
+ )}
27
+ {...props}
28
+ />
29
+ ));
30
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
31
+
32
+ const DialogContent = React.forwardRef<
33
+ React.ElementRef<typeof DialogPrimitive.Content>,
34
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
35
+ >(({ className, children, ...props }, ref) => (
36
+ <DialogPortal>
37
+ <DialogOverlay />
38
+ <DialogPrimitive.Content
39
+ ref={ref}
40
+ className={cn(
41
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
42
+ className,
43
+ )}
44
+ {...props}
45
+ >
46
+ {children}
47
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
48
+ <X className="h-4 w-4" />
49
+ <span className="sr-only">Close</span>
50
+ </DialogPrimitive.Close>
51
+ </DialogPrimitive.Content>
52
+ </DialogPortal>
53
+ ));
54
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
55
+
56
+ const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
57
+ <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
58
+ );
59
+ DialogHeader.displayName = "DialogHeader";
60
+
61
+ const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
62
+ <div
63
+ className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
64
+ {...props}
65
+ />
66
+ );
67
+ DialogFooter.displayName = "DialogFooter";
68
+
69
+ const DialogTitle = React.forwardRef<
70
+ React.ElementRef<typeof DialogPrimitive.Title>,
71
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
72
+ >(({ className, ...props }, ref) => (
73
+ <DialogPrimitive.Title
74
+ ref={ref}
75
+ className={cn("text-lg font-semibold leading-none tracking-tight", className)}
76
+ {...props}
77
+ />
78
+ ));
79
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
80
+
81
+ const DialogDescription = React.forwardRef<
82
+ React.ElementRef<typeof DialogPrimitive.Description>,
83
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
84
+ >(({ className, ...props }, ref) => (
85
+ <DialogPrimitive.Description
86
+ ref={ref}
87
+ className={cn("text-sm text-muted-foreground", className)}
88
+ {...props}
89
+ />
90
+ ));
91
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
92
+
93
+ export {
94
+ Dialog,
95
+ DialogClose,
96
+ DialogContent,
97
+ DialogDescription,
98
+ DialogFooter,
99
+ DialogHeader,
100
+ DialogOverlay,
101
+ DialogPortal,
102
+ DialogTitle,
103
+ DialogTrigger,
104
+ };
@@ -0,0 +1,185 @@
1
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
2
+ import { Check, ChevronRight, Circle } from "lucide-react";
3
+ import * as React from "react";
4
+
5
+ import { cn } from "../lib/utils";
6
+
7
+ const DropdownMenu = DropdownMenuPrimitive.Root;
8
+
9
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
10
+
11
+ const DropdownMenuGroup = DropdownMenuPrimitive.Group;
12
+
13
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
14
+
15
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
16
+
17
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
18
+
19
+ const DropdownMenuSubTrigger = React.forwardRef<
20
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
21
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
22
+ inset?: boolean;
23
+ }
24
+ >(({ className, inset, children, ...props }, ref) => (
25
+ <DropdownMenuPrimitive.SubTrigger
26
+ ref={ref}
27
+ className={cn(
28
+ "flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
29
+ inset && "pl-8",
30
+ className,
31
+ )}
32
+ {...props}
33
+ >
34
+ {children}
35
+ <ChevronRight className="ml-auto" />
36
+ </DropdownMenuPrimitive.SubTrigger>
37
+ ));
38
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
39
+
40
+ const DropdownMenuSubContent = React.forwardRef<
41
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
42
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
43
+ >(({ className, ...props }, ref) => (
44
+ <DropdownMenuPrimitive.SubContent
45
+ ref={ref}
46
+ className={cn(
47
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-dropdown-menu-content-transform-origin)",
48
+ className,
49
+ )}
50
+ {...props}
51
+ />
52
+ ));
53
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
54
+
55
+ const DropdownMenuContent = React.forwardRef<
56
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
57
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
58
+ >(({ className, sideOffset = 4, ...props }, ref) => (
59
+ <DropdownMenuPrimitive.Portal>
60
+ <DropdownMenuPrimitive.Content
61
+ ref={ref}
62
+ sideOffset={sideOffset}
63
+ className={cn(
64
+ "z-50 max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-dropdown-menu-content-transform-origin)",
65
+ className,
66
+ )}
67
+ {...props}
68
+ />
69
+ </DropdownMenuPrimitive.Portal>
70
+ ));
71
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
72
+
73
+ const DropdownMenuItem = React.forwardRef<
74
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
75
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
76
+ inset?: boolean;
77
+ }
78
+ >(({ className, inset, ...props }, ref) => (
79
+ <DropdownMenuPrimitive.Item
80
+ ref={ref}
81
+ className={cn(
82
+ "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
83
+ inset && "pl-8",
84
+ className,
85
+ )}
86
+ {...props}
87
+ />
88
+ ));
89
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
90
+
91
+ const DropdownMenuCheckboxItem = React.forwardRef<
92
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
93
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
94
+ >(({ className, children, checked, ...props }, ref) => (
95
+ <DropdownMenuPrimitive.CheckboxItem
96
+ ref={ref}
97
+ className={cn(
98
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
99
+ className,
100
+ )}
101
+ checked={checked}
102
+ {...props}
103
+ >
104
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
105
+ <DropdownMenuPrimitive.ItemIndicator>
106
+ <Check className="h-4 w-4" />
107
+ </DropdownMenuPrimitive.ItemIndicator>
108
+ </span>
109
+ {children}
110
+ </DropdownMenuPrimitive.CheckboxItem>
111
+ ));
112
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
113
+
114
+ const DropdownMenuRadioItem = React.forwardRef<
115
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
116
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
117
+ >(({ className, children, ...props }, ref) => (
118
+ <DropdownMenuPrimitive.RadioItem
119
+ ref={ref}
120
+ className={cn(
121
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
122
+ className,
123
+ )}
124
+ {...props}
125
+ >
126
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
127
+ <DropdownMenuPrimitive.ItemIndicator>
128
+ <Circle className="h-2 w-2 fill-current" />
129
+ </DropdownMenuPrimitive.ItemIndicator>
130
+ </span>
131
+ {children}
132
+ </DropdownMenuPrimitive.RadioItem>
133
+ ));
134
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
135
+
136
+ const DropdownMenuLabel = React.forwardRef<
137
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
138
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
139
+ inset?: boolean;
140
+ }
141
+ >(({ className, inset, ...props }, ref) => (
142
+ <DropdownMenuPrimitive.Label
143
+ ref={ref}
144
+ className={cn("px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className)}
145
+ {...props}
146
+ />
147
+ ));
148
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
149
+
150
+ const DropdownMenuSeparator = React.forwardRef<
151
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
152
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
153
+ >(({ className, ...props }, ref) => (
154
+ <DropdownMenuPrimitive.Separator
155
+ ref={ref}
156
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
157
+ {...props}
158
+ />
159
+ ));
160
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
161
+
162
+ const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
163
+ return (
164
+ <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} />
165
+ );
166
+ };
167
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
168
+
169
+ export {
170
+ DropdownMenu,
171
+ DropdownMenuCheckboxItem,
172
+ DropdownMenuContent,
173
+ DropdownMenuGroup,
174
+ DropdownMenuItem,
175
+ DropdownMenuLabel,
176
+ DropdownMenuPortal,
177
+ DropdownMenuRadioGroup,
178
+ DropdownMenuRadioItem,
179
+ DropdownMenuSeparator,
180
+ DropdownMenuShortcut,
181
+ DropdownMenuSub,
182
+ DropdownMenuSubContent,
183
+ DropdownMenuSubTrigger,
184
+ DropdownMenuTrigger,
185
+ };
@@ -0,0 +1,172 @@
1
+ "use client";
2
+
3
+ import type * as LabelPrimitive from "@radix-ui/react-label";
4
+ import { Slot } from "@radix-ui/react-slot";
5
+ import * as React from "react";
6
+ import {
7
+ Controller,
8
+ type ControllerProps,
9
+ type FieldPath,
10
+ type FieldValues,
11
+ FormProvider,
12
+ useFormContext,
13
+ } from "react-hook-form";
14
+ import { cn } from "../lib/utils";
15
+ import { Label } from "./label";
16
+
17
+ const Form = FormProvider;
18
+
19
+ type FormFieldContextValue<
20
+ TFieldValues extends FieldValues = FieldValues,
21
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
22
+ > = {
23
+ name: TName;
24
+ };
25
+
26
+ const FormFieldContext = React.createContext<FormFieldContextValue | null>(null);
27
+
28
+ const FormField = <
29
+ TFieldValues extends FieldValues = FieldValues,
30
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
31
+ >({
32
+ ...props
33
+ }: ControllerProps<TFieldValues, TName>) => {
34
+ return (
35
+ <FormFieldContext.Provider value={{ name: props.name }}>
36
+ <Controller {...props} />
37
+ </FormFieldContext.Provider>
38
+ );
39
+ };
40
+
41
+ const useFormField = () => {
42
+ const fieldContext = React.useContext(FormFieldContext);
43
+ const itemContext = React.useContext(FormItemContext);
44
+ const { getFieldState, formState } = useFormContext();
45
+
46
+ if (!fieldContext) {
47
+ throw new Error("useFormField should be used within <FormField>");
48
+ }
49
+
50
+ if (!itemContext) {
51
+ throw new Error("useFormField should be used within <FormItem>");
52
+ }
53
+
54
+ const fieldState = getFieldState(fieldContext.name, formState);
55
+
56
+ const { id } = itemContext;
57
+
58
+ return {
59
+ id,
60
+ name: fieldContext.name,
61
+ formItemId: `${id}-form-item`,
62
+ formDescriptionId: `${id}-form-item-description`,
63
+ formMessageId: `${id}-form-item-message`,
64
+ ...fieldState,
65
+ };
66
+ };
67
+
68
+ type FormItemContextValue = {
69
+ id: string;
70
+ };
71
+
72
+ const FormItemContext = React.createContext<FormItemContextValue | null>(null);
73
+
74
+ const FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
75
+ ({ className, ...props }, ref) => {
76
+ const id = React.useId();
77
+
78
+ return (
79
+ <FormItemContext.Provider value={{ id }}>
80
+ <div ref={ref} className={cn("space-y-2", className)} {...props} />
81
+ </FormItemContext.Provider>
82
+ );
83
+ },
84
+ );
85
+ FormItem.displayName = "FormItem";
86
+
87
+ const FormLabel = React.forwardRef<
88
+ React.ElementRef<typeof LabelPrimitive.Root>,
89
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
90
+ >(({ className, ...props }, ref) => {
91
+ const { error, formItemId } = useFormField();
92
+
93
+ return (
94
+ <Label
95
+ ref={ref}
96
+ className={cn(error && "text-destructive", className)}
97
+ htmlFor={formItemId}
98
+ {...props}
99
+ />
100
+ );
101
+ });
102
+ FormLabel.displayName = "FormLabel";
103
+
104
+ const FormControl = React.forwardRef<
105
+ React.ElementRef<typeof Slot>,
106
+ React.ComponentPropsWithoutRef<typeof Slot>
107
+ >(({ ...props }, ref) => {
108
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
109
+
110
+ return (
111
+ <Slot
112
+ ref={ref}
113
+ id={formItemId}
114
+ aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}
115
+ aria-invalid={!!error}
116
+ {...props}
117
+ />
118
+ );
119
+ });
120
+ FormControl.displayName = "FormControl";
121
+
122
+ const FormDescription = React.forwardRef<
123
+ HTMLParagraphElement,
124
+ React.HTMLAttributes<HTMLParagraphElement>
125
+ >(({ className, ...props }, ref) => {
126
+ const { formDescriptionId } = useFormField();
127
+
128
+ return (
129
+ <p
130
+ ref={ref}
131
+ id={formDescriptionId}
132
+ className={cn("text-sm text-muted-foreground", className)}
133
+ {...props}
134
+ />
135
+ );
136
+ });
137
+ FormDescription.displayName = "FormDescription";
138
+
139
+ const FormMessage = React.forwardRef<
140
+ HTMLParagraphElement,
141
+ React.HTMLAttributes<HTMLParagraphElement>
142
+ >(({ className, children, ...props }, ref) => {
143
+ const { error, formMessageId } = useFormField();
144
+ const body = error ? String(error?.message ?? "") : children;
145
+
146
+ if (!body) {
147
+ return null;
148
+ }
149
+
150
+ return (
151
+ <p
152
+ ref={ref}
153
+ id={formMessageId}
154
+ className={cn("text-sm font-medium text-destructive", className)}
155
+ {...props}
156
+ >
157
+ {body}
158
+ </p>
159
+ );
160
+ });
161
+ FormMessage.displayName = "FormMessage";
162
+
163
+ export {
164
+ Form,
165
+ FormControl,
166
+ FormDescription,
167
+ FormField,
168
+ FormItem,
169
+ FormLabel,
170
+ FormMessage,
171
+ useFormField,
172
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The shadcn kit the app shell is built from, styled with Tailwind utilities
3
+ * against the shadcn tokens `styles/app.css` defines. Each file is the
4
+ * shadcn source as the template carried it; add a component here, not in an
5
+ * app.
6
+ */
7
+ export * from "./accordion";
8
+ export * from "./alert";
9
+ export * from "./alert-dialog";
10
+ export * from "./avatar";
11
+ export * from "./badge";
12
+ export * from "./badge-list";
13
+ export * from "./button";
14
+ export * from "./callout";
15
+ export * from "./card";
16
+ export * from "./checkbox";
17
+ export * from "./clear-button";
18
+ export * from "./command";
19
+ export * from "./country-dropdown";
20
+ export * from "./dialog";
21
+ export * from "./dropdown-menu";
22
+ export * from "./form";
23
+ export * from "./input";
24
+ export * from "./label";
25
+ export * from "./option-select";
26
+ export * from "./pagination";
27
+ export * from "./popover";
28
+ export * from "./progress";
29
+ export * from "./search-input";
30
+ export * from "./select";
31
+ export * from "./separator";
32
+ export * from "./sheet";
33
+ export * from "./slider";
34
+ export * from "./switch";
35
+ export * from "./textarea";
36
+ export * from "./tooltip";