@hitch42/applet 0.1.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/dist/_internal/client.d.ts +7 -0
  3. package/dist/_internal/client.js +60 -0
  4. package/dist/_internal/server.d.ts +79 -0
  5. package/dist/_internal/server.js +232 -0
  6. package/dist/applet.d.ts +1 -0
  7. package/dist/applet.js +160 -0
  8. package/dist/auth-DaVK0k5R.js +350 -0
  9. package/dist/batch-Qa4B4-Yp.d.ts +30 -0
  10. package/dist/build-CEku1lyb.js +2 -0
  11. package/dist/build-Rk3xDZV7.js +74 -0
  12. package/dist/client.d.ts +48 -0
  13. package/dist/client.js +38 -0
  14. package/dist/contract-DMrpbaLJ.d.ts +23 -0
  15. package/dist/deploy-D3BGDqgC.js +2416 -0
  16. package/dist/generate-6Nbt7uii.js +2 -0
  17. package/dist/generate-CH0VQmUi.js +484 -0
  18. package/dist/index.d.ts +74 -0
  19. package/dist/index.js +136 -0
  20. package/dist/init-BS1Y-eNL.js +240 -0
  21. package/dist/lazy-client-x0DCI98S.js +64 -0
  22. package/dist/load-config-BnxocLAQ.js +56 -0
  23. package/dist/logs-m00pzr_O.js +183 -0
  24. package/dist/manifest-BQCAxATS.d.ts +81 -0
  25. package/dist/manifest-DyoJ1MIL.js +174 -0
  26. package/dist/project-CxN-Dtc7.js +346 -0
  27. package/dist/react.d.ts +37 -0
  28. package/dist/react.js +517 -0
  29. package/dist/server.d.ts +46 -0
  30. package/dist/server.js +104 -0
  31. package/dist/upload-DRbVhuDm.js +114 -0
  32. package/dist/upload-YbRKEqR6.d.ts +112 -0
  33. package/dist/variables-CP7Ce3Np.js +133 -0
  34. package/dist/vite.d.ts +63 -0
  35. package/dist/vite.js +358 -0
  36. package/dist/workflow-CTo2kZF1.js +51 -0
  37. package/dist/workflow-DurM6Fwx.d.ts +28 -0
  38. package/package.json +104 -0
  39. package/scaffold/.agents/skills/hitch-applets/SKILL.md +137 -0
  40. package/scaffold/.agents/skills/hitch-applets/references/client.md +73 -0
  41. package/scaffold/.agents/skills/hitch-applets/references/files.md +109 -0
  42. package/scaffold/.agents/skills/hitch-applets/references/manifest.md +171 -0
  43. package/scaffold/.agents/skills/hitch-applets/references/markdown.md +37 -0
  44. package/scaffold/.agents/skills/hitch-applets/references/records.md +152 -0
  45. package/scaffold/.agents/skills/hitch-applets/references/schedules.md +86 -0
  46. package/scaffold/.agents/skills/hitch-applets/references/server.md +98 -0
  47. package/scaffold/.agents/skills/hitch-applets/references/workflows.md +73 -0
  48. package/scaffold/AGENTS.md +38 -0
  49. package/scaffold/applet/components.json +25 -0
  50. package/scaffold/applet/src/client/components/ui/alert.tsx +73 -0
  51. package/scaffold/applet/src/client/components/ui/avatar.tsx +100 -0
  52. package/scaffold/applet/src/client/components/ui/badge.tsx +55 -0
  53. package/scaffold/applet/src/client/components/ui/button.tsx +90 -0
  54. package/scaffold/applet/src/client/components/ui/card.tsx +85 -0
  55. package/scaffold/applet/src/client/components/ui/checkbox.tsx +35 -0
  56. package/scaffold/applet/src/client/components/ui/dialog.tsx +164 -0
  57. package/scaffold/applet/src/client/components/ui/dropdown-menu.tsx +235 -0
  58. package/scaffold/applet/src/client/components/ui/input-group.tsx +144 -0
  59. package/scaffold/applet/src/client/components/ui/input.tsx +22 -0
  60. package/scaffold/applet/src/client/components/ui/label.tsx +29 -0
  61. package/scaffold/applet/src/client/components/ui/popover.tsx +74 -0
  62. package/scaffold/applet/src/client/components/ui/select.tsx +243 -0
  63. package/scaffold/applet/src/client/components/ui/separator.tsx +25 -0
  64. package/scaffold/applet/src/client/components/ui/sheet.tsx +177 -0
  65. package/scaffold/applet/src/client/components/ui/skeleton.tsx +13 -0
  66. package/scaffold/applet/src/client/components/ui/spinner.tsx +16 -0
  67. package/scaffold/applet/src/client/components/ui/switch.tsx +41 -0
  68. package/scaffold/applet/src/client/components/ui/table.tsx +114 -0
  69. package/scaffold/applet/src/client/components/ui/tabs.tsx +78 -0
  70. package/scaffold/applet/src/client/components/ui/textarea.tsx +23 -0
  71. package/scaffold/applet/src/client/lib/utils.ts +6 -0
  72. package/scaffold/applet/src/client/styles/globals.css +136 -0
@@ -0,0 +1,243 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import {
5
+ Button as ButtonPrimitive,
6
+ composeRenderProps,
7
+ Header as HeaderPrimitive,
8
+ ListBoxItem as ListBoxItemPrimitive,
9
+ ListBox as ListBoxPrimitive,
10
+ ListBoxSection as ListBoxSectionPrimitive,
11
+ Popover as PopoverPrimitive,
12
+ SearchField,
13
+ Select as SelectPrimitive,
14
+ SelectValue as SelectValuePrimitive,
15
+ Separator as SeparatorPrimitive,
16
+ type ListBoxProps,
17
+ type SearchFieldProps,
18
+ type ListBoxSectionProps as SelectGroupProps,
19
+ type SelectProps,
20
+ type SelectValueProps,
21
+ } from "react-aria-components";
22
+
23
+ import { cn } from "@/client/lib/utils";
24
+ import { InputGroup, InputGroupAddon, InputGroupInput } from "@/client/components/ui/input-group";
25
+ import { ChevronDownIcon, SearchIcon, CheckIcon } from "lucide-react";
26
+
27
+ function Select<T extends object, M extends "single" | "multiple" = "single">({
28
+ className,
29
+ ...props
30
+ }: SelectProps<T, M>) {
31
+ return <SelectPrimitive data-slot="select" className={cn("w-fit", className)} {...props} />;
32
+ }
33
+
34
+ function SelectGroup<T extends object>({ className, ...props }: SelectGroupProps<T>) {
35
+ return (
36
+ <ListBoxSectionPrimitive
37
+ data-slot="select-group"
38
+ className={cn("scroll-my-1.5 p-1", className)}
39
+ {...props}
40
+ />
41
+ );
42
+ }
43
+
44
+ function SelectValue<T extends object>({ className, children, ...props }: SelectValueProps<T>) {
45
+ return (
46
+ <SelectValuePrimitive
47
+ data-slot="select-value"
48
+ className={cn("flex flex-1 text-left data-placeholder:text-muted-foreground", className)}
49
+ {...props}
50
+ >
51
+ {typeof children === "function"
52
+ ? children
53
+ : ({ selectedItems, selectedText, defaultChildren }) =>
54
+ selectedItems.length > 1 ? selectedText : defaultChildren}
55
+ </SelectValuePrimitive>
56
+ );
57
+ }
58
+
59
+ function SelectTrigger({
60
+ className,
61
+ size = "default",
62
+ children,
63
+ ...props
64
+ }: Omit<React.ComponentProps<typeof ButtonPrimitive>, "children"> & {
65
+ children?: React.ReactNode;
66
+ size?: "sm" | "default";
67
+ }) {
68
+ return (
69
+ <ButtonPrimitive
70
+ data-slot="select-trigger"
71
+ data-size={size}
72
+ className={cn(
73
+ "flex w-full items-center justify-between gap-1.5 rounded-2xl border border-transparent bg-input/50 px-3 py-2 text-sm whitespace-nowrap transition-[color,box-shadow] duration-200 outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
74
+ className,
75
+ )}
76
+ {...props}
77
+ >
78
+ {children}
79
+ <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
80
+ </ButtonPrimitive>
81
+ );
82
+ }
83
+
84
+ function SelectContent({
85
+ className,
86
+ children,
87
+ placement = "bottom",
88
+ offset = 4,
89
+ crossOffset = 0,
90
+ ...props
91
+ }: Omit<React.ComponentProps<typeof PopoverPrimitive>, "className" | "children"> & {
92
+ className?: string;
93
+ children?: React.ReactNode;
94
+ }) {
95
+ return (
96
+ <SelectPopover
97
+ className={className}
98
+ placement={placement}
99
+ offset={offset}
100
+ crossOffset={crossOffset}
101
+ {...props}
102
+ >
103
+ <SelectList>{children}</SelectList>
104
+ </SelectPopover>
105
+ );
106
+ }
107
+
108
+ function SelectPopover({
109
+ className,
110
+ children,
111
+ placement = "bottom start",
112
+ offset = 4,
113
+ crossOffset = 0,
114
+ ...props
115
+ }: Omit<React.ComponentProps<typeof PopoverPrimitive>, "className" | "children"> & {
116
+ className?: string;
117
+ children?: React.ReactNode;
118
+ }) {
119
+ return (
120
+ <PopoverPrimitive
121
+ data-slot="select-content"
122
+ placement={placement}
123
+ offset={offset}
124
+ crossOffset={crossOffset}
125
+ className={cn(
126
+ "relative isolate z-50 w-(--trigger-width) min-w-36 origin-(--trigger-anchor-point) overflow-hidden rounded-2xl bg-popover text-popover-foreground shadow-lg ring-1 ring-foreground/5 duration-100 data-entering:animate-in data-entering:fade-in-0 data-entering:zoom-in-95 data-exiting:animate-out data-exiting:fade-out-0 data-exiting:zoom-out-95 data-[placement=bottom]:slide-in-from-top-2 data-[placement=left]:slide-in-from-right-2 data-[placement=right]:slide-in-from-left-2 data-[placement=top]:slide-in-from-bottom-2 **:data-[slot$=-item]:data-focused:bg-foreground/10 dark:ring-foreground/10",
127
+ className,
128
+ )}
129
+ {...props}
130
+ >
131
+ {children}
132
+ </PopoverPrimitive>
133
+ );
134
+ }
135
+
136
+ function SelectList<T extends object>({ className, ...props }: ListBoxProps<T>) {
137
+ return (
138
+ <ListBoxPrimitive
139
+ data-slot="select-list"
140
+ className={cn(
141
+ "group/select-list max-h-[inherit] overflow-x-hidden overflow-y-auto p-0 outline-hidden",
142
+ className,
143
+ )}
144
+ {...props}
145
+ />
146
+ );
147
+ }
148
+
149
+ function SelectInput({ className, ...props }: SearchFieldProps) {
150
+ return (
151
+ <SearchField
152
+ {...props}
153
+ autoFocus
154
+ data-slot="select-input-wrapper"
155
+ className={cn("p-1 pb-0", className)}
156
+ >
157
+ <InputGroup>
158
+ <InputGroupInput
159
+ data-slot="select-input"
160
+ className="[&::-webkit-search-cancel-button]:hidden"
161
+ />
162
+ <InputGroupAddon>
163
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
164
+ </InputGroupAddon>
165
+ </InputGroup>
166
+ </SearchField>
167
+ );
168
+ }
169
+
170
+ function SelectLabel({ className, ...props }: React.ComponentProps<typeof HeaderPrimitive>) {
171
+ return (
172
+ <HeaderPrimitive
173
+ data-slot="select-label"
174
+ className={cn("px-2 py-1 text-xs text-muted-foreground", className)}
175
+ {...props}
176
+ />
177
+ );
178
+ }
179
+
180
+ function SelectItem({
181
+ className,
182
+ children,
183
+ ...props
184
+ }: React.ComponentProps<typeof ListBoxItemPrimitive>) {
185
+ return (
186
+ <ListBoxItemPrimitive
187
+ data-slot="select-item"
188
+ textValue={typeof children === "string" ? children : undefined}
189
+ className={cn(
190
+ "relative flex min-h-7 w-full cursor-default items-center gap-2 rounded-xl py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-focused:bg-accent data-focused:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
191
+ className,
192
+ )}
193
+ {...props}
194
+ >
195
+ {composeRenderProps(children, (children, { isSelected }) => (
196
+ <>
197
+ <span className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">{children}</span>
198
+ <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center">
199
+ {isSelected ? <CheckIcon className="pointer-events-none" /> : null}
200
+ </span>
201
+ </>
202
+ ))}
203
+ </ListBoxItemPrimitive>
204
+ );
205
+ }
206
+
207
+ function SelectSeparator({ className, ...props }: React.ComponentProps<typeof SeparatorPrimitive>) {
208
+ return (
209
+ <SeparatorPrimitive
210
+ data-slot="select-separator"
211
+ className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
212
+ {...props}
213
+ />
214
+ );
215
+ }
216
+
217
+ function SelectEmpty({ className, ...props }: React.ComponentProps<"div">) {
218
+ return (
219
+ <div
220
+ data-slot="select-empty"
221
+ className={cn(
222
+ "hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/select-list:flex",
223
+ className,
224
+ )}
225
+ {...props}
226
+ />
227
+ );
228
+ }
229
+
230
+ export {
231
+ Select,
232
+ SelectContent,
233
+ SelectGroup,
234
+ SelectInput,
235
+ SelectItem,
236
+ SelectLabel,
237
+ SelectList,
238
+ SelectPopover,
239
+ SelectSeparator,
240
+ SelectTrigger,
241
+ SelectValue,
242
+ SelectEmpty,
243
+ };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+
3
+ import { Separator as SeparatorPrimitive } from "react-aria-components";
4
+
5
+ import { cn } from "@/client/lib/utils";
6
+
7
+ function Separator({
8
+ className,
9
+ orientation = "horizontal",
10
+ ...props
11
+ }: React.ComponentProps<typeof SeparatorPrimitive>) {
12
+ return (
13
+ <SeparatorPrimitive
14
+ data-slot="separator"
15
+ orientation={orientation}
16
+ className={cn(
17
+ "block shrink-0 border-0 bg-border aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=vertical]:w-px aria-[orientation=vertical]:self-stretch [:is(hr)]:h-px [:is(hr)]:w-full",
18
+ className,
19
+ )}
20
+ {...props}
21
+ />
22
+ );
23
+ }
24
+
25
+ export { Separator };
@@ -0,0 +1,177 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import {
5
+ Heading,
6
+ ModalOverlay as ModalOverlayPrimitive,
7
+ Modal as ModalPrimitive,
8
+ Dialog as SheetPrimitive,
9
+ DialogTrigger as SheetTriggerPrimitive,
10
+ type ModalOverlayProps as ModalOverlayPrimitiveProps,
11
+ type DialogProps as SheetPrimitiveProps,
12
+ type DialogTriggerProps as SheetTriggerPrimitiveProps,
13
+ } from "react-aria-components";
14
+
15
+ import { cn } from "@/client/lib/utils";
16
+ import { Button } from "@/client/components/ui/button";
17
+ import { XIcon } from "lucide-react";
18
+
19
+ function SheetTrigger({ ...props }: SheetTriggerPrimitiveProps) {
20
+ return <SheetTriggerPrimitive data-slot="sheet-trigger" {...props} />;
21
+ }
22
+
23
+ function SheetClose({
24
+ className,
25
+ variant = "outline",
26
+ size = "default",
27
+ ...props
28
+ }: React.ComponentProps<typeof Button>) {
29
+ return (
30
+ <Button
31
+ slot="close"
32
+ data-slot="sheet-close"
33
+ variant={variant}
34
+ size={size}
35
+ className={cn(className)}
36
+ {...props}
37
+ />
38
+ );
39
+ }
40
+
41
+ function SheetOverlay({
42
+ className,
43
+ children,
44
+ ...props
45
+ }: Omit<ModalOverlayPrimitiveProps, "className" | "children"> & {
46
+ className?: string;
47
+ children: React.ReactNode;
48
+ }) {
49
+ return (
50
+ <ModalOverlayPrimitive
51
+ data-slot="sheet-overlay"
52
+ isDismissable
53
+ className={cn(
54
+ "fixed inset-0 z-50 bg-black/30 transition-opacity duration-150 data-entering:opacity-0 data-exiting:opacity-0 supports-backdrop-filter:backdrop-blur-sm",
55
+ className,
56
+ )}
57
+ {...props}
58
+ >
59
+ {children}
60
+ </ModalOverlayPrimitive>
61
+ );
62
+ }
63
+
64
+ function Sheet({
65
+ className,
66
+ children,
67
+ side = "right",
68
+ showCloseButton = true,
69
+ ...props
70
+ }: Omit<ModalOverlayPrimitiveProps, "className" | "children"> &
71
+ Pick<React.ComponentProps<typeof ModalPrimitive>, "isDismissable"> & {
72
+ className?: string;
73
+ children: React.ReactNode;
74
+ side?: "top" | "right" | "bottom" | "left";
75
+ showCloseButton?: boolean;
76
+ }) {
77
+ return (
78
+ <SheetOverlay {...props}>
79
+ <ModalPrimitive
80
+ data-slot="sheet-content"
81
+ data-side={side}
82
+ className={cn(
83
+ "fixed z-50 flex flex-col bg-popover bg-clip-padding text-sm text-popover-foreground shadow-xl transition duration-200 ease-in-out data-entering:opacity-0 data-exiting:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-entering:translate-y-[2.5rem] data-[side=bottom]:data-exiting:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-entering:translate-x-[-2.5rem] data-[side=left]:data-exiting:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-entering:translate-x-[2.5rem] data-[side=right]:data-exiting:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-entering:translate-y-[-2.5rem] data-[side=top]:data-exiting:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
84
+ className,
85
+ )}
86
+ >
87
+ <SheetPrimitive
88
+ data-slot="sheet"
89
+ className="[display:inherit] h-full max-h-[inherit] [flex-direction:inherit] [gap:inherit] outline-none"
90
+ >
91
+ {children}
92
+ {showCloseButton && (
93
+ <SheetClose
94
+ variant="ghost"
95
+ className="absolute top-4 right-4 bg-secondary"
96
+ size="icon-sm"
97
+ >
98
+ <XIcon />
99
+ <span className="sr-only">Close</span>
100
+ </SheetClose>
101
+ )}
102
+ </SheetPrimitive>
103
+ </ModalPrimitive>
104
+ </SheetOverlay>
105
+ );
106
+ }
107
+
108
+ function SheetContent({
109
+ className,
110
+ children,
111
+ side = "right",
112
+ showCloseButton = true,
113
+ ...props
114
+ }: React.ComponentProps<typeof Sheet> & {
115
+ side?: "top" | "right" | "bottom" | "left";
116
+ showCloseButton?: boolean;
117
+ }) {
118
+ return (
119
+ <Sheet className={className} side={side} showCloseButton={showCloseButton} {...props}>
120
+ {children}
121
+ </Sheet>
122
+ );
123
+ }
124
+
125
+ function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
126
+ return (
127
+ <div
128
+ data-slot="sheet-header"
129
+ className={cn("flex flex-col gap-1.5 p-6", className)}
130
+ {...props}
131
+ />
132
+ );
133
+ }
134
+
135
+ function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
136
+ return (
137
+ <div
138
+ data-slot="sheet-footer"
139
+ className={cn("mt-auto flex flex-col gap-2 p-6", className)}
140
+ {...props}
141
+ />
142
+ );
143
+ }
144
+
145
+ function SheetTitle({ className, ...props }: Omit<React.ComponentProps<typeof Heading>, "slot">) {
146
+ return (
147
+ <Heading
148
+ slot="title"
149
+ data-slot="sheet-title"
150
+ className={cn("font-heading text-base font-medium text-foreground", className)}
151
+ {...props}
152
+ />
153
+ );
154
+ }
155
+
156
+ function SheetDescription({ className, ...props }: Omit<React.ComponentProps<"div">, "slot">) {
157
+ return (
158
+ <div
159
+ data-slot="sheet-description"
160
+ className={cn("text-sm text-muted-foreground", className)}
161
+ {...props}
162
+ />
163
+ );
164
+ }
165
+
166
+ export {
167
+ type SheetPrimitiveProps,
168
+ type SheetTriggerPrimitiveProps,
169
+ Sheet,
170
+ SheetTrigger,
171
+ SheetClose,
172
+ SheetContent,
173
+ SheetHeader,
174
+ SheetFooter,
175
+ SheetTitle,
176
+ SheetDescription,
177
+ };
@@ -0,0 +1,13 @@
1
+ import { cn } from "@/client/lib/utils";
2
+
3
+ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
+ return (
5
+ <div
6
+ data-slot="skeleton"
7
+ className={cn("animate-pulse rounded-2xl bg-muted", className)}
8
+ {...props}
9
+ />
10
+ );
11
+ }
12
+
13
+ export { Skeleton };
@@ -0,0 +1,16 @@
1
+ import { cn } from "@/client/lib/utils";
2
+ import { Loader2Icon } from "lucide-react";
3
+
4
+ function Spinner({ className, ...props }: React.ComponentProps<"svg">) {
5
+ return (
6
+ <Loader2Icon
7
+ data-slot="spinner"
8
+ role="status"
9
+ aria-label="Loading"
10
+ className={cn("size-4 animate-spin", className)}
11
+ {...props}
12
+ />
13
+ );
14
+ }
15
+
16
+ export { Spinner };
@@ -0,0 +1,41 @@
1
+ import {
2
+ composeRenderProps,
3
+ Switch as SwitchPrimitive,
4
+ type SwitchProps as SwitchPrimitiveProps,
5
+ } from "react-aria-components";
6
+
7
+ import { cn } from "@/client/lib/utils";
8
+
9
+ function Switch({
10
+ className,
11
+ size = "default",
12
+ children,
13
+ ...props
14
+ }: SwitchPrimitiveProps & {
15
+ size?: "sm" | "default";
16
+ }) {
17
+ return (
18
+ <SwitchPrimitive
19
+ data-slot="switch"
20
+ data-size={size}
21
+ className={cn(
22
+ "peer group/switch relative inline-flex shrink-0 items-center rounded-2xl border-2 transition-all outline-none not-data-selected:border-transparent not-data-selected:bg-input/90 group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-focus-visible:border-ring data-focus-visible:ring-3 data-focus-visible:ring-ring/30 data-invalid:border-destructive data-invalid:ring-3 data-invalid:ring-destructive/20 data-[size=default]:h-5 data-[size=default]:w-8 data-[size=sm]:h-4 data-[size=sm]:w-6 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 dark:data-invalid:border-destructive/50 dark:data-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary group-has-[:focus-visible]/field-label:data-checked:border-primary data-unchecked:border-transparent data-unchecked:bg-input/90 group-has-[:focus-visible]/field-label:data-unchecked:border-transparent data-selected:border-primary data-selected:bg-primary data-disabled:cursor-not-allowed data-disabled:opacity-50",
23
+ className,
24
+ )}
25
+ {...props}
26
+ >
27
+ {composeRenderProps(children, (children, { isSelected }) => (
28
+ <>
29
+ <span
30
+ data-slot="switch-thumb"
31
+ data-selected={isSelected || undefined}
32
+ className="pointer-events-none block rounded-2xl bg-background shadow-sm ring-0 transition-transform not-dark:bg-clip-padding not-data-selected:translate-x-0 group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 dark:not-data-selected:bg-foreground data-checked:translate-x-[calc(100%-4px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground data-selected:translate-x-[calc(100%-4px)] dark:data-selected:bg-primary-foreground"
33
+ />
34
+ {children}
35
+ </>
36
+ ))}
37
+ </SwitchPrimitive>
38
+ );
39
+ }
40
+
41
+ export { Switch };
@@ -0,0 +1,114 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import {
5
+ Cell as CellPrimitive,
6
+ Column as ColumnPrimitive,
7
+ Row as RowPrimitive,
8
+ TableBody as TableBodyPrimitive,
9
+ TableFooter as TableFooterPrimitive,
10
+ TableHeader as TableHeaderPrimitive,
11
+ Table as TablePrimitive,
12
+ type CellProps,
13
+ type ColumnProps,
14
+ type RowProps,
15
+ type TableBodyProps,
16
+ type TableFooterProps,
17
+ type TableHeaderProps,
18
+ type TableProps,
19
+ } from "react-aria-components";
20
+
21
+ import { cn } from "@/client/lib/utils";
22
+
23
+ function Table({ className, ...props }: TableProps) {
24
+ return (
25
+ <div data-slot="table-container" className="relative w-full overflow-x-auto">
26
+ <TablePrimitive
27
+ data-slot="table"
28
+ className={cn("w-full caption-bottom text-sm", className)}
29
+ {...props}
30
+ />
31
+ </div>
32
+ );
33
+ }
34
+
35
+ function TableHeader<T>({ className, ...props }: TableHeaderProps<T>) {
36
+ return (
37
+ <TableHeaderPrimitive
38
+ data-slot="table-header"
39
+ className={cn("[&_tr]:border-b", className)}
40
+ {...props}
41
+ />
42
+ );
43
+ }
44
+
45
+ function TableBody<T>({ className, ...props }: TableBodyProps<T>) {
46
+ return (
47
+ <TableBodyPrimitive
48
+ data-slot="table-body"
49
+ className={cn("data-empty:h-24 data-empty:text-center [&_tr:last-child]:border-0", className)}
50
+ {...props}
51
+ />
52
+ );
53
+ }
54
+
55
+ function TableFooter<T>({ className, ...props }: TableFooterProps<T>) {
56
+ return (
57
+ <TableFooterPrimitive
58
+ data-slot="table-footer"
59
+ className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
60
+ {...props}
61
+ />
62
+ );
63
+ }
64
+
65
+ function TableRow<T>({ className, ...props }: RowProps<T>) {
66
+ return (
67
+ <RowPrimitive
68
+ data-slot="table-row"
69
+ className={cn(
70
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted data-selected:bg-muted",
71
+ className,
72
+ )}
73
+ {...props}
74
+ />
75
+ );
76
+ }
77
+
78
+ function TableHead({ className, ...props }: ColumnProps) {
79
+ return (
80
+ <ColumnPrimitive
81
+ data-slot="table-head"
82
+ className={cn(
83
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([data-slot=checkbox])]:pr-0 [&:has([role=checkbox])]:pr-0",
84
+ className,
85
+ )}
86
+ {...props}
87
+ />
88
+ );
89
+ }
90
+
91
+ function TableCell({ className, ...props }: CellProps) {
92
+ return (
93
+ <CellPrimitive
94
+ data-slot="table-cell"
95
+ className={cn(
96
+ "p-2 align-middle whitespace-nowrap [&:has([data-slot=checkbox])]:pr-0 [&:has([role=checkbox])]:pr-0",
97
+ className,
98
+ )}
99
+ {...props}
100
+ />
101
+ );
102
+ }
103
+
104
+ function TableCaption({ className, ...props }: React.ComponentProps<"figcaption">) {
105
+ return (
106
+ <figcaption
107
+ data-slot="table-caption"
108
+ className={cn("mt-4 text-center text-sm text-muted-foreground", className)}
109
+ {...props}
110
+ />
111
+ );
112
+ }
113
+
114
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };