itsi 0.2.16 → 0.2.18

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 (170) hide show
  1. checksums.yaml +4 -4
  2. data/.zed/settings.json +32 -0
  3. data/CHANGELOG.md +21 -0
  4. data/Cargo.lock +4 -2
  5. data/crates/itsi_acme/Cargo.toml +1 -1
  6. data/crates/itsi_scheduler/Cargo.toml +1 -1
  7. data/crates/itsi_server/Cargo.toml +3 -1
  8. data/crates/itsi_server/src/lib.rs +6 -1
  9. data/crates/itsi_server/src/ruby_types/itsi_body_proxy/mod.rs +2 -0
  10. data/crates/itsi_server/src/ruby_types/itsi_grpc_call.rs +4 -4
  11. data/crates/itsi_server/src/ruby_types/itsi_grpc_response_stream/mod.rs +14 -13
  12. data/crates/itsi_server/src/ruby_types/itsi_http_request.rs +64 -33
  13. data/crates/itsi_server/src/ruby_types/itsi_http_response.rs +151 -152
  14. data/crates/itsi_server/src/ruby_types/itsi_server/file_watcher.rs +422 -110
  15. data/crates/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +62 -15
  16. data/crates/itsi_server/src/ruby_types/itsi_server.rs +1 -1
  17. data/crates/itsi_server/src/server/binds/listener.rs +45 -7
  18. data/crates/itsi_server/src/server/frame_stream.rs +142 -0
  19. data/crates/itsi_server/src/server/http_message_types.rs +142 -9
  20. data/crates/itsi_server/src/server/io_stream.rs +28 -5
  21. data/crates/itsi_server/src/server/lifecycle_event.rs +1 -1
  22. data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_basic.rs +2 -3
  23. data/crates/itsi_server/src/server/middleware_stack/middlewares/compression.rs +8 -10
  24. data/crates/itsi_server/src/server/middleware_stack/middlewares/cors.rs +2 -3
  25. data/crates/itsi_server/src/server/middleware_stack/middlewares/csp.rs +3 -3
  26. data/crates/itsi_server/src/server/middleware_stack/middlewares/error_response/default_responses.rs +54 -56
  27. data/crates/itsi_server/src/server/middleware_stack/middlewares/error_response.rs +5 -7
  28. data/crates/itsi_server/src/server/middleware_stack/middlewares/etag.rs +5 -5
  29. data/crates/itsi_server/src/server/middleware_stack/middlewares/proxy.rs +7 -10
  30. data/crates/itsi_server/src/server/middleware_stack/middlewares/redirect.rs +2 -3
  31. data/crates/itsi_server/src/server/middleware_stack/middlewares/static_assets.rs +1 -2
  32. data/crates/itsi_server/src/server/middleware_stack/middlewares/static_response.rs +4 -6
  33. data/crates/itsi_server/src/server/mod.rs +1 -0
  34. data/crates/itsi_server/src/server/process_worker.rs +3 -4
  35. data/crates/itsi_server/src/server/serve_strategy/acceptor.rs +16 -12
  36. data/crates/itsi_server/src/server/serve_strategy/cluster_mode.rs +83 -31
  37. data/crates/itsi_server/src/server/serve_strategy/single_mode.rs +166 -142
  38. data/crates/itsi_server/src/server/signal.rs +37 -9
  39. data/crates/itsi_server/src/server/thread_worker.rs +84 -69
  40. data/crates/itsi_server/src/services/itsi_http_service.rs +43 -43
  41. data/crates/itsi_server/src/services/static_file_server.rs +28 -47
  42. data/docs/benchmark-dashboard/.gitignore +27 -0
  43. data/docs/benchmark-dashboard/app/api/benchmarks/route.ts +22 -0
  44. data/docs/benchmark-dashboard/app/globals.css +94 -0
  45. data/docs/benchmark-dashboard/app/layout.tsx +20 -0
  46. data/docs/benchmark-dashboard/app/page.tsx +252 -0
  47. data/docs/benchmark-dashboard/components/benchmark-dashboard.tsx +1663 -0
  48. data/docs/benchmark-dashboard/components/theme-provider.tsx +11 -0
  49. data/docs/benchmark-dashboard/components/ui/accordion.tsx +58 -0
  50. data/docs/benchmark-dashboard/components/ui/alert-dialog.tsx +141 -0
  51. data/docs/benchmark-dashboard/components/ui/alert.tsx +59 -0
  52. data/docs/benchmark-dashboard/components/ui/aspect-ratio.tsx +7 -0
  53. data/docs/benchmark-dashboard/components/ui/avatar.tsx +50 -0
  54. data/docs/benchmark-dashboard/components/ui/badge.tsx +36 -0
  55. data/docs/benchmark-dashboard/components/ui/breadcrumb.tsx +115 -0
  56. data/docs/benchmark-dashboard/components/ui/button.tsx +56 -0
  57. data/docs/benchmark-dashboard/components/ui/calendar.tsx +66 -0
  58. data/docs/benchmark-dashboard/components/ui/card.tsx +79 -0
  59. data/docs/benchmark-dashboard/components/ui/carousel.tsx +262 -0
  60. data/docs/benchmark-dashboard/components/ui/chart.tsx +365 -0
  61. data/docs/benchmark-dashboard/components/ui/checkbox.tsx +30 -0
  62. data/docs/benchmark-dashboard/components/ui/collapsible.tsx +11 -0
  63. data/docs/benchmark-dashboard/components/ui/command.tsx +153 -0
  64. data/docs/benchmark-dashboard/components/ui/context-menu.tsx +200 -0
  65. data/docs/benchmark-dashboard/components/ui/dialog.tsx +122 -0
  66. data/docs/benchmark-dashboard/components/ui/drawer.tsx +118 -0
  67. data/docs/benchmark-dashboard/components/ui/dropdown-menu.tsx +200 -0
  68. data/docs/benchmark-dashboard/components/ui/form.tsx +178 -0
  69. data/docs/benchmark-dashboard/components/ui/hover-card.tsx +29 -0
  70. data/docs/benchmark-dashboard/components/ui/input-otp.tsx +71 -0
  71. data/docs/benchmark-dashboard/components/ui/input.tsx +22 -0
  72. data/docs/benchmark-dashboard/components/ui/label.tsx +26 -0
  73. data/docs/benchmark-dashboard/components/ui/loading-spinner.tsx +12 -0
  74. data/docs/benchmark-dashboard/components/ui/menubar.tsx +236 -0
  75. data/docs/benchmark-dashboard/components/ui/navigation-menu.tsx +128 -0
  76. data/docs/benchmark-dashboard/components/ui/pagination.tsx +117 -0
  77. data/docs/benchmark-dashboard/components/ui/popover.tsx +31 -0
  78. data/docs/benchmark-dashboard/components/ui/progress.tsx +28 -0
  79. data/docs/benchmark-dashboard/components/ui/radio-group.tsx +44 -0
  80. data/docs/benchmark-dashboard/components/ui/resizable.tsx +45 -0
  81. data/docs/benchmark-dashboard/components/ui/scroll-area.tsx +48 -0
  82. data/docs/benchmark-dashboard/components/ui/select.tsx +160 -0
  83. data/docs/benchmark-dashboard/components/ui/separator.tsx +31 -0
  84. data/docs/benchmark-dashboard/components/ui/sheet.tsx +140 -0
  85. data/docs/benchmark-dashboard/components/ui/sidebar.tsx +763 -0
  86. data/docs/benchmark-dashboard/components/ui/skeleton.tsx +15 -0
  87. data/docs/benchmark-dashboard/components/ui/slider.tsx +28 -0
  88. data/docs/benchmark-dashboard/components/ui/sonner.tsx +31 -0
  89. data/docs/benchmark-dashboard/components/ui/switch.tsx +29 -0
  90. data/docs/benchmark-dashboard/components/ui/table.tsx +117 -0
  91. data/docs/benchmark-dashboard/components/ui/tabs.tsx +55 -0
  92. data/docs/benchmark-dashboard/components/ui/textarea.tsx +22 -0
  93. data/docs/benchmark-dashboard/components/ui/toast.tsx +129 -0
  94. data/docs/benchmark-dashboard/components/ui/toaster.tsx +35 -0
  95. data/docs/benchmark-dashboard/components/ui/toggle-group.tsx +61 -0
  96. data/docs/benchmark-dashboard/components/ui/toggle.tsx +45 -0
  97. data/docs/benchmark-dashboard/components/ui/tooltip.tsx +30 -0
  98. data/docs/benchmark-dashboard/components/ui/use-mobile.tsx +19 -0
  99. data/docs/benchmark-dashboard/components/ui/use-toast.ts +194 -0
  100. data/docs/benchmark-dashboard/components.json +21 -0
  101. data/docs/benchmark-dashboard/dist/benchmark-dashboard.css +1 -0
  102. data/docs/benchmark-dashboard/dist/benchmark-dashboard.iife.js +211 -0
  103. data/docs/benchmark-dashboard/dist/placeholder-logo.png +0 -0
  104. data/docs/benchmark-dashboard/dist/placeholder-logo.svg +1 -0
  105. data/docs/benchmark-dashboard/dist/placeholder-user.jpg +0 -0
  106. data/docs/benchmark-dashboard/dist/placeholder.jpg +0 -0
  107. data/docs/benchmark-dashboard/dist/placeholder.svg +1 -0
  108. data/docs/benchmark-dashboard/embed.tsx +13 -0
  109. data/docs/benchmark-dashboard/hooks/use-mobile.tsx +19 -0
  110. data/docs/benchmark-dashboard/hooks/use-toast.ts +194 -0
  111. data/docs/benchmark-dashboard/lib/benchmark-utils.ts +54 -0
  112. data/docs/benchmark-dashboard/lib/utils.ts +6 -0
  113. data/docs/benchmark-dashboard/next.config.mjs +14 -0
  114. data/docs/benchmark-dashboard/package-lock.json +5859 -0
  115. data/docs/benchmark-dashboard/package.json +72 -0
  116. data/docs/benchmark-dashboard/pnpm-lock.yaml +5 -0
  117. data/docs/benchmark-dashboard/postcss.config.mjs +8 -0
  118. data/docs/benchmark-dashboard/styles/globals.css +94 -0
  119. data/docs/benchmark-dashboard/tailwind.config.ts +96 -0
  120. data/docs/benchmark-dashboard/tsconfig.json +27 -0
  121. data/docs/benchmark-dashboard/vite.config.ts +24 -0
  122. data/docs/build.rb +52 -0
  123. data/docs/content/acknowledgements/_index.md +1 -1
  124. data/docs/content/benchmarks/index.md +96 -0
  125. data/docs/content/configuration/_index.md +2 -2
  126. data/docs/content/getting_started/_index.md +76 -46
  127. data/docs/content/itsi_scheduler/_index.md +2 -2
  128. data/docs/hugo.yaml +10 -1
  129. data/docs/static/results.json +1 -0
  130. data/docs/static/scripts/benchmark-dashboard.iife.js +211 -0
  131. data/docs/static/styles/benchmark-dashboard.css +1 -0
  132. data/examples/api_with_schema_and_controllers/README.md +1 -1
  133. data/gems/scheduler/Cargo.lock +1 -1
  134. data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
  135. data/gems/server/Cargo.lock +3 -1
  136. data/gems/server/exe/itsi +8 -5
  137. data/gems/server/lib/itsi/http_request.rb +31 -39
  138. data/gems/server/lib/itsi/http_response.rb +5 -0
  139. data/gems/server/lib/itsi/rack_env_pool.rb +59 -0
  140. data/gems/server/lib/itsi/server/config/dsl.rb +6 -4
  141. data/gems/server/lib/itsi/server/config/middleware/compression.md +3 -3
  142. data/gems/server/lib/itsi/server/config/middleware/endpoint/controller.md +1 -1
  143. data/gems/server/lib/itsi/server/config/middleware/proxy.md +2 -2
  144. data/gems/server/lib/itsi/server/config/middleware/proxy.rb +1 -1
  145. data/gems/server/lib/itsi/server/config/middleware/rackup_file.rb +2 -2
  146. data/gems/server/lib/itsi/server/config/options/auto_reload_config.rb +11 -6
  147. data/gems/server/lib/itsi/server/config/options/include.md +1 -0
  148. data/gems/server/lib/itsi/server/config/options/include.rb +13 -8
  149. data/gems/server/lib/itsi/server/config/options/pipeline_flush.md +16 -0
  150. data/gems/server/lib/itsi/server/config/options/pipeline_flush.rb +19 -0
  151. data/gems/server/lib/itsi/server/config/options/reuse_port.rb +2 -4
  152. data/gems/server/lib/itsi/server/config/options/writev.md +25 -0
  153. data/gems/server/lib/itsi/server/config/options/writev.rb +19 -0
  154. data/gems/server/lib/itsi/server/config.rb +22 -9
  155. data/gems/server/lib/itsi/server/default_config/Itsi.rb +9 -8
  156. data/gems/server/lib/itsi/server/grpc/grpc_call.rb +2 -0
  157. data/gems/server/lib/itsi/server/grpc/grpc_interface.rb +2 -2
  158. data/gems/server/lib/itsi/server/rack/handler/itsi.rb +3 -1
  159. data/gems/server/lib/itsi/server/rack_interface.rb +17 -12
  160. data/gems/server/lib/itsi/server/scheduler_interface.rb +2 -0
  161. data/gems/server/lib/itsi/server/version.rb +1 -1
  162. data/gems/server/lib/itsi/server.rb +1 -0
  163. data/gems/server/lib/ruby_lsp/itsi/addon.rb +12 -13
  164. data/gems/server/test/helpers/test_helper.rb +12 -13
  165. data/gems/server/test/middleware/grpc/grpc.rb +13 -14
  166. data/gems/server/test/middleware/grpc/test_service_impl.rb +3 -3
  167. data/gems/server/test/middleware/proxy.rb +262 -268
  168. data/lib/itsi/version.rb +1 -1
  169. metadata +97 -6
  170. data/tasks.txt +0 -28
@@ -0,0 +1,200 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
5
+ import { Check, ChevronRight, Circle } from "lucide-react"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const DropdownMenu = DropdownMenuPrimitive.Root
10
+
11
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
12
+
13
+ const DropdownMenuGroup = DropdownMenuPrimitive.Group
14
+
15
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal
16
+
17
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub
18
+
19
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
20
+
21
+ const DropdownMenuSubTrigger = React.forwardRef<
22
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
23
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
24
+ inset?: boolean
25
+ }
26
+ >(({ className, inset, children, ...props }, ref) => (
27
+ <DropdownMenuPrimitive.SubTrigger
28
+ ref={ref}
29
+ className={cn(
30
+ "flex cursor-default gap-2 select-none items-center 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",
31
+ inset && "pl-8",
32
+ className
33
+ )}
34
+ {...props}
35
+ >
36
+ {children}
37
+ <ChevronRight className="ml-auto" />
38
+ </DropdownMenuPrimitive.SubTrigger>
39
+ ))
40
+ DropdownMenuSubTrigger.displayName =
41
+ DropdownMenuPrimitive.SubTrigger.displayName
42
+
43
+ const DropdownMenuSubContent = React.forwardRef<
44
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
45
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
46
+ >(({ className, ...props }, ref) => (
47
+ <DropdownMenuPrimitive.SubContent
48
+ ref={ref}
49
+ className={cn(
50
+ "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",
51
+ className
52
+ )}
53
+ {...props}
54
+ />
55
+ ))
56
+ DropdownMenuSubContent.displayName =
57
+ DropdownMenuPrimitive.SubContent.displayName
58
+
59
+ const DropdownMenuContent = React.forwardRef<
60
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
61
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
62
+ >(({ className, sideOffset = 4, ...props }, ref) => (
63
+ <DropdownMenuPrimitive.Portal>
64
+ <DropdownMenuPrimitive.Content
65
+ ref={ref}
66
+ sideOffset={sideOffset}
67
+ className={cn(
68
+ "z-50 min-w-[8rem] overflow-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",
69
+ className
70
+ )}
71
+ {...props}
72
+ />
73
+ </DropdownMenuPrimitive.Portal>
74
+ ))
75
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
76
+
77
+ const DropdownMenuItem = React.forwardRef<
78
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
79
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
80
+ inset?: boolean
81
+ }
82
+ >(({ className, inset, ...props }, ref) => (
83
+ <DropdownMenuPrimitive.Item
84
+ ref={ref}
85
+ className={cn(
86
+ "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",
87
+ inset && "pl-8",
88
+ className
89
+ )}
90
+ {...props}
91
+ />
92
+ ))
93
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
94
+
95
+ const DropdownMenuCheckboxItem = React.forwardRef<
96
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
97
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
98
+ >(({ className, children, checked, ...props }, ref) => (
99
+ <DropdownMenuPrimitive.CheckboxItem
100
+ ref={ref}
101
+ className={cn(
102
+ "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",
103
+ className
104
+ )}
105
+ checked={checked}
106
+ {...props}
107
+ >
108
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
109
+ <DropdownMenuPrimitive.ItemIndicator>
110
+ <Check className="h-4 w-4" />
111
+ </DropdownMenuPrimitive.ItemIndicator>
112
+ </span>
113
+ {children}
114
+ </DropdownMenuPrimitive.CheckboxItem>
115
+ ))
116
+ DropdownMenuCheckboxItem.displayName =
117
+ DropdownMenuPrimitive.CheckboxItem.displayName
118
+
119
+ const DropdownMenuRadioItem = React.forwardRef<
120
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
121
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
122
+ >(({ className, children, ...props }, ref) => (
123
+ <DropdownMenuPrimitive.RadioItem
124
+ ref={ref}
125
+ className={cn(
126
+ "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",
127
+ className
128
+ )}
129
+ {...props}
130
+ >
131
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
132
+ <DropdownMenuPrimitive.ItemIndicator>
133
+ <Circle className="h-2 w-2 fill-current" />
134
+ </DropdownMenuPrimitive.ItemIndicator>
135
+ </span>
136
+ {children}
137
+ </DropdownMenuPrimitive.RadioItem>
138
+ ))
139
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
140
+
141
+ const DropdownMenuLabel = React.forwardRef<
142
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
143
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
144
+ inset?: boolean
145
+ }
146
+ >(({ className, inset, ...props }, ref) => (
147
+ <DropdownMenuPrimitive.Label
148
+ ref={ref}
149
+ className={cn(
150
+ "px-2 py-1.5 text-sm font-semibold",
151
+ inset && "pl-8",
152
+ className
153
+ )}
154
+ {...props}
155
+ />
156
+ ))
157
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
158
+
159
+ const DropdownMenuSeparator = React.forwardRef<
160
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
161
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
162
+ >(({ className, ...props }, ref) => (
163
+ <DropdownMenuPrimitive.Separator
164
+ ref={ref}
165
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
166
+ {...props}
167
+ />
168
+ ))
169
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
170
+
171
+ const DropdownMenuShortcut = ({
172
+ className,
173
+ ...props
174
+ }: React.HTMLAttributes<HTMLSpanElement>) => {
175
+ return (
176
+ <span
177
+ className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
178
+ {...props}
179
+ />
180
+ )
181
+ }
182
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
183
+
184
+ export {
185
+ DropdownMenu,
186
+ DropdownMenuTrigger,
187
+ DropdownMenuContent,
188
+ DropdownMenuItem,
189
+ DropdownMenuCheckboxItem,
190
+ DropdownMenuRadioItem,
191
+ DropdownMenuLabel,
192
+ DropdownMenuSeparator,
193
+ DropdownMenuShortcut,
194
+ DropdownMenuGroup,
195
+ DropdownMenuPortal,
196
+ DropdownMenuSub,
197
+ DropdownMenuSubContent,
198
+ DropdownMenuSubTrigger,
199
+ DropdownMenuRadioGroup,
200
+ }
@@ -0,0 +1,178 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as LabelPrimitive from "@radix-ui/react-label"
5
+ import { Slot } from "@radix-ui/react-slot"
6
+ import {
7
+ Controller,
8
+ ControllerProps,
9
+ FieldPath,
10
+ FieldValues,
11
+ FormProvider,
12
+ useFormContext,
13
+ } from "react-hook-form"
14
+
15
+ import { cn } from "@/lib/utils"
16
+ import { Label } from "@/components/ui/label"
17
+
18
+ const Form = FormProvider
19
+
20
+ type FormFieldContextValue<
21
+ TFieldValues extends FieldValues = FieldValues,
22
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
23
+ > = {
24
+ name: TName
25
+ }
26
+
27
+ const FormFieldContext = React.createContext<FormFieldContextValue>(
28
+ {} as FormFieldContextValue
29
+ )
30
+
31
+ const FormField = <
32
+ TFieldValues extends FieldValues = FieldValues,
33
+ TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>
34
+ >({
35
+ ...props
36
+ }: ControllerProps<TFieldValues, TName>) => {
37
+ return (
38
+ <FormFieldContext.Provider value={{ name: props.name }}>
39
+ <Controller {...props} />
40
+ </FormFieldContext.Provider>
41
+ )
42
+ }
43
+
44
+ const useFormField = () => {
45
+ const fieldContext = React.useContext(FormFieldContext)
46
+ const itemContext = React.useContext(FormItemContext)
47
+ const { getFieldState, formState } = useFormContext()
48
+
49
+ const fieldState = getFieldState(fieldContext.name, formState)
50
+
51
+ if (!fieldContext) {
52
+ throw new Error("useFormField should be used within <FormField>")
53
+ }
54
+
55
+ const { id } = itemContext
56
+
57
+ return {
58
+ id,
59
+ name: fieldContext.name,
60
+ formItemId: `${id}-form-item`,
61
+ formDescriptionId: `${id}-form-item-description`,
62
+ formMessageId: `${id}-form-item-message`,
63
+ ...fieldState,
64
+ }
65
+ }
66
+
67
+ type FormItemContextValue = {
68
+ id: string
69
+ }
70
+
71
+ const FormItemContext = React.createContext<FormItemContextValue>(
72
+ {} as FormItemContextValue
73
+ )
74
+
75
+ const FormItem = React.forwardRef<
76
+ HTMLDivElement,
77
+ React.HTMLAttributes<HTMLDivElement>
78
+ >(({ className, ...props }, ref) => {
79
+ const id = React.useId()
80
+
81
+ return (
82
+ <FormItemContext.Provider value={{ id }}>
83
+ <div ref={ref} className={cn("space-y-2", className)} {...props} />
84
+ </FormItemContext.Provider>
85
+ )
86
+ })
87
+ FormItem.displayName = "FormItem"
88
+
89
+ const FormLabel = React.forwardRef<
90
+ React.ElementRef<typeof LabelPrimitive.Root>,
91
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
92
+ >(({ className, ...props }, ref) => {
93
+ const { error, formItemId } = useFormField()
94
+
95
+ return (
96
+ <Label
97
+ ref={ref}
98
+ className={cn(error && "text-destructive", className)}
99
+ htmlFor={formItemId}
100
+ {...props}
101
+ />
102
+ )
103
+ })
104
+ FormLabel.displayName = "FormLabel"
105
+
106
+ const FormControl = React.forwardRef<
107
+ React.ElementRef<typeof Slot>,
108
+ React.ComponentPropsWithoutRef<typeof Slot>
109
+ >(({ ...props }, ref) => {
110
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField()
111
+
112
+ return (
113
+ <Slot
114
+ ref={ref}
115
+ id={formItemId}
116
+ aria-describedby={
117
+ !error
118
+ ? `${formDescriptionId}`
119
+ : `${formDescriptionId} ${formMessageId}`
120
+ }
121
+ aria-invalid={!!error}
122
+ {...props}
123
+ />
124
+ )
125
+ })
126
+ FormControl.displayName = "FormControl"
127
+
128
+ const FormDescription = React.forwardRef<
129
+ HTMLParagraphElement,
130
+ React.HTMLAttributes<HTMLParagraphElement>
131
+ >(({ className, ...props }, ref) => {
132
+ const { formDescriptionId } = useFormField()
133
+
134
+ return (
135
+ <p
136
+ ref={ref}
137
+ id={formDescriptionId}
138
+ className={cn("text-sm text-muted-foreground", className)}
139
+ {...props}
140
+ />
141
+ )
142
+ })
143
+ FormDescription.displayName = "FormDescription"
144
+
145
+ const FormMessage = React.forwardRef<
146
+ HTMLParagraphElement,
147
+ React.HTMLAttributes<HTMLParagraphElement>
148
+ >(({ className, children, ...props }, ref) => {
149
+ const { error, formMessageId } = useFormField()
150
+ const body = error ? String(error?.message) : children
151
+
152
+ if (!body) {
153
+ return null
154
+ }
155
+
156
+ return (
157
+ <p
158
+ ref={ref}
159
+ id={formMessageId}
160
+ className={cn("text-sm font-medium text-destructive", className)}
161
+ {...props}
162
+ >
163
+ {body}
164
+ </p>
165
+ )
166
+ })
167
+ FormMessage.displayName = "FormMessage"
168
+
169
+ export {
170
+ useFormField,
171
+ Form,
172
+ FormItem,
173
+ FormLabel,
174
+ FormControl,
175
+ FormDescription,
176
+ FormMessage,
177
+ FormField,
178
+ }
@@ -0,0 +1,29 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ const HoverCard = HoverCardPrimitive.Root
9
+
10
+ const HoverCardTrigger = HoverCardPrimitive.Trigger
11
+
12
+ const HoverCardContent = React.forwardRef<
13
+ React.ElementRef<typeof HoverCardPrimitive.Content>,
14
+ React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
15
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
16
+ <HoverCardPrimitive.Content
17
+ ref={ref}
18
+ align={align}
19
+ sideOffset={sideOffset}
20
+ className={cn(
21
+ "z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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",
22
+ className
23
+ )}
24
+ {...props}
25
+ />
26
+ ))
27
+ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
28
+
29
+ export { HoverCard, HoverCardTrigger, HoverCardContent }
@@ -0,0 +1,71 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { OTPInput, OTPInputContext } from "input-otp"
5
+ import { Dot } from "lucide-react"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const InputOTP = React.forwardRef<
10
+ React.ElementRef<typeof OTPInput>,
11
+ React.ComponentPropsWithoutRef<typeof OTPInput>
12
+ >(({ className, containerClassName, ...props }, ref) => (
13
+ <OTPInput
14
+ ref={ref}
15
+ containerClassName={cn(
16
+ "flex items-center gap-2 has-[:disabled]:opacity-50",
17
+ containerClassName
18
+ )}
19
+ className={cn("disabled:cursor-not-allowed", className)}
20
+ {...props}
21
+ />
22
+ ))
23
+ InputOTP.displayName = "InputOTP"
24
+
25
+ const InputOTPGroup = React.forwardRef<
26
+ React.ElementRef<"div">,
27
+ React.ComponentPropsWithoutRef<"div">
28
+ >(({ className, ...props }, ref) => (
29
+ <div ref={ref} className={cn("flex items-center", className)} {...props} />
30
+ ))
31
+ InputOTPGroup.displayName = "InputOTPGroup"
32
+
33
+ const InputOTPSlot = React.forwardRef<
34
+ React.ElementRef<"div">,
35
+ React.ComponentPropsWithoutRef<"div"> & { index: number }
36
+ >(({ index, className, ...props }, ref) => {
37
+ const inputOTPContext = React.useContext(OTPInputContext)
38
+ const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
39
+
40
+ return (
41
+ <div
42
+ ref={ref}
43
+ className={cn(
44
+ "relative flex h-10 w-10 items-center justify-center border-y border-r border-input text-sm transition-all first:rounded-l-md first:border-l last:rounded-r-md",
45
+ isActive && "z-10 ring-2 ring-ring ring-offset-background",
46
+ className
47
+ )}
48
+ {...props}
49
+ >
50
+ {char}
51
+ {hasFakeCaret && (
52
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
53
+ <div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
54
+ </div>
55
+ )}
56
+ </div>
57
+ )
58
+ })
59
+ InputOTPSlot.displayName = "InputOTPSlot"
60
+
61
+ const InputOTPSeparator = React.forwardRef<
62
+ React.ElementRef<"div">,
63
+ React.ComponentPropsWithoutRef<"div">
64
+ >(({ ...props }, ref) => (
65
+ <div ref={ref} role="separator" {...props}>
66
+ <Dot />
67
+ </div>
68
+ ))
69
+ InputOTPSeparator.displayName = "InputOTPSeparator"
70
+
71
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator }
@@ -0,0 +1,22 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
6
+ ({ className, type, ...props }, ref) => {
7
+ return (
8
+ <input
9
+ type={type}
10
+ className={cn(
11
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12
+ className
13
+ )}
14
+ ref={ref}
15
+ {...props}
16
+ />
17
+ )
18
+ }
19
+ )
20
+ Input.displayName = "Input"
21
+
22
+ export { Input }
@@ -0,0 +1,26 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import * as LabelPrimitive from "@radix-ui/react-label"
5
+ import { cva, type VariantProps } from "class-variance-authority"
6
+
7
+ import { cn } from "@/lib/utils"
8
+
9
+ const labelVariants = cva(
10
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
11
+ )
12
+
13
+ const Label = React.forwardRef<
14
+ React.ElementRef<typeof LabelPrimitive.Root>,
15
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
16
+ VariantProps<typeof labelVariants>
17
+ >(({ className, ...props }, ref) => (
18
+ <LabelPrimitive.Root
19
+ ref={ref}
20
+ className={cn(labelVariants(), className)}
21
+ {...props}
22
+ />
23
+ ))
24
+ Label.displayName = LabelPrimitive.Root.displayName
25
+
26
+ export { Label }
@@ -0,0 +1,12 @@
1
+ export function LoadingSpinner() {
2
+ return (
3
+ <div
4
+ className="inline-block h-6 w-6 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"
5
+ role="status"
6
+ >
7
+ <span className="!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]">
8
+ Loading...
9
+ </span>
10
+ </div>
11
+ )
12
+ }