@surreal-ui/react 0.5.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 (125) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/index.js +11307 -0
  3. package/package.json +38 -0
  4. package/src/components/GlassmorphismAlert.tsx +40 -0
  5. package/src/components/GlassmorphismButton.tsx +20 -0
  6. package/src/components/GlassmorphismCard.tsx +43 -0
  7. package/src/components/GlassmorphismEmptyState.tsx +20 -0
  8. package/src/components/GlassmorphismInputGroup.tsx +148 -0
  9. package/src/components/GlassmorphismMenubar.tsx +96 -0
  10. package/src/components/GlassmorphismScrollArea.tsx +67 -0
  11. package/src/components/GlassmorphismTable.tsx +61 -0
  12. package/src/components/GlassmorphismTypography.tsx +31 -0
  13. package/src/components/MinimalistAccordion.tsx +215 -0
  14. package/src/components/MinimalistAlert.tsx +40 -0
  15. package/src/components/MinimalistAlertDialog.tsx +317 -0
  16. package/src/components/MinimalistAspectRatio.tsx +30 -0
  17. package/src/components/MinimalistAvatar.tsx +149 -0
  18. package/src/components/MinimalistBadge.tsx +49 -0
  19. package/src/components/MinimalistBreadcrumb.tsx +105 -0
  20. package/src/components/MinimalistButton.tsx +86 -0
  21. package/src/components/MinimalistButtonGroup.tsx +85 -0
  22. package/src/components/MinimalistCalendar.tsx +352 -0
  23. package/src/components/MinimalistCard.tsx +89 -0
  24. package/src/components/MinimalistCarousel.tsx +266 -0
  25. package/src/components/MinimalistChart.tsx +296 -0
  26. package/src/components/MinimalistCheckbox.tsx +117 -0
  27. package/src/components/MinimalistCodeBlock.tsx +203 -0
  28. package/src/components/MinimalistCollapsible.tsx +134 -0
  29. package/src/components/MinimalistCommand.tsx +344 -0
  30. package/src/components/MinimalistContextMenu.tsx +400 -0
  31. package/src/components/MinimalistDialog.tsx +269 -0
  32. package/src/components/MinimalistDrawer.tsx +216 -0
  33. package/src/components/MinimalistDropdownMenu.tsx +431 -0
  34. package/src/components/MinimalistEmpty.tsx +105 -0
  35. package/src/components/MinimalistEmptyState.tsx +34 -0
  36. package/src/components/MinimalistField.tsx +275 -0
  37. package/src/components/MinimalistForm.tsx +203 -0
  38. package/src/components/MinimalistHoverCard.tsx +48 -0
  39. package/src/components/MinimalistInput.tsx +24 -0
  40. package/src/components/MinimalistInputGroup.tsx +180 -0
  41. package/src/components/MinimalistInputOtp.tsx +189 -0
  42. package/src/components/MinimalistItem.tsx +181 -0
  43. package/src/components/MinimalistKbd.tsx +46 -0
  44. package/src/components/MinimalistLabel.tsx +19 -0
  45. package/src/components/MinimalistMenubar.tsx +491 -0
  46. package/src/components/MinimalistNativeSelect.tsx +77 -0
  47. package/src/components/MinimalistNavigationMenu.tsx +198 -0
  48. package/src/components/MinimalistPagination.tsx +152 -0
  49. package/src/components/MinimalistPopover.tsx +228 -0
  50. package/src/components/MinimalistProgress.tsx +39 -0
  51. package/src/components/MinimalistRadioGroup.tsx +115 -0
  52. package/src/components/MinimalistRangeCalendar.tsx +396 -0
  53. package/src/components/MinimalistResizable.tsx +54 -0
  54. package/src/components/MinimalistScrollArea.tsx +41 -0
  55. package/src/components/MinimalistSelect.tsx +265 -0
  56. package/src/components/MinimalistSeparator.tsx +45 -0
  57. package/src/components/MinimalistSheet.tsx +247 -0
  58. package/src/components/MinimalistSidebar.tsx +637 -0
  59. package/src/components/MinimalistSkeleton.tsx +16 -0
  60. package/src/components/MinimalistSlider.tsx +213 -0
  61. package/src/components/MinimalistSonner.tsx +41 -0
  62. package/src/components/MinimalistSpinner.tsx +39 -0
  63. package/src/components/MinimalistSwitch.tsx +92 -0
  64. package/src/components/MinimalistTable.tsx +65 -0
  65. package/src/components/MinimalistTabs.tsx +166 -0
  66. package/src/components/MinimalistTextarea.tsx +24 -0
  67. package/src/components/MinimalistToggle.tsx +74 -0
  68. package/src/components/MinimalistToggleGroup.tsx +196 -0
  69. package/src/components/MinimalistTooltip.tsx +172 -0
  70. package/src/components/MinimalistTypography.tsx +33 -0
  71. package/src/components/NeubrutalismCard.tsx +3 -0
  72. package/src/components/NeubrutalismItem.tsx +48 -0
  73. package/src/components/ShadcnAccordion.tsx +215 -0
  74. package/src/components/ShadcnAlertDialog.tsx +317 -0
  75. package/src/components/ShadcnAspectRatio.tsx +30 -0
  76. package/src/components/ShadcnAvatar.tsx +149 -0
  77. package/src/components/ShadcnBadge.tsx +49 -0
  78. package/src/components/ShadcnBreadcrumb.tsx +105 -0
  79. package/src/components/ShadcnButton.tsx +86 -0
  80. package/src/components/ShadcnButtonGroup.tsx +85 -0
  81. package/src/components/ShadcnCalendar.tsx +352 -0
  82. package/src/components/ShadcnCarousel.tsx +266 -0
  83. package/src/components/ShadcnChart.tsx +296 -0
  84. package/src/components/ShadcnCheckbox.tsx +117 -0
  85. package/src/components/ShadcnCodeBlock.tsx +203 -0
  86. package/src/components/ShadcnCollapsible.tsx +134 -0
  87. package/src/components/ShadcnCommand.tsx +344 -0
  88. package/src/components/ShadcnContextMenu.tsx +400 -0
  89. package/src/components/ShadcnDialog.tsx +269 -0
  90. package/src/components/ShadcnDrawer.tsx +216 -0
  91. package/src/components/ShadcnDropdownMenu.tsx +431 -0
  92. package/src/components/ShadcnEmpty.tsx +105 -0
  93. package/src/components/ShadcnField.tsx +275 -0
  94. package/src/components/ShadcnForm.tsx +203 -0
  95. package/src/components/ShadcnHoverCard.tsx +48 -0
  96. package/src/components/ShadcnInput.tsx +24 -0
  97. package/src/components/ShadcnInputGroup.tsx +180 -0
  98. package/src/components/ShadcnInputOtp.tsx +189 -0
  99. package/src/components/ShadcnItem.tsx +181 -0
  100. package/src/components/ShadcnKbd.tsx +46 -0
  101. package/src/components/ShadcnLabel.tsx +19 -0
  102. package/src/components/ShadcnMenubar.tsx +491 -0
  103. package/src/components/ShadcnNativeSelect.tsx +77 -0
  104. package/src/components/ShadcnNavigationMenu.tsx +198 -0
  105. package/src/components/ShadcnPagination.tsx +152 -0
  106. package/src/components/ShadcnPopover.tsx +228 -0
  107. package/src/components/ShadcnProgress.tsx +39 -0
  108. package/src/components/ShadcnRadioGroup.tsx +115 -0
  109. package/src/components/ShadcnRangeCalendar.tsx +396 -0
  110. package/src/components/ShadcnSelect.tsx +265 -0
  111. package/src/components/ShadcnSeparator.tsx +45 -0
  112. package/src/components/ShadcnSheet.tsx +247 -0
  113. package/src/components/ShadcnSidebar.tsx +637 -0
  114. package/src/components/ShadcnSkeleton.tsx +16 -0
  115. package/src/components/ShadcnSlider.tsx +213 -0
  116. package/src/components/ShadcnSonner.tsx +41 -0
  117. package/src/components/ShadcnSpinner.tsx +39 -0
  118. package/src/components/ShadcnSwitch.tsx +92 -0
  119. package/src/components/ShadcnTabs.tsx +166 -0
  120. package/src/components/ShadcnTextarea.tsx +24 -0
  121. package/src/components/ShadcnToggle.tsx +74 -0
  122. package/src/components/ShadcnToggleGroup.tsx +196 -0
  123. package/src/components/ShadcnTooltip.tsx +172 -0
  124. package/src/index.ts +124 -0
  125. package/tsconfig.json +10 -0
@@ -0,0 +1,105 @@
1
+ import * as React from 'react';
2
+ import { cn, cva, type VariantProps } from '@surreal-ui/core';
3
+
4
+ export const emptyMediaVariants = cva(
5
+ 'mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0',
6
+ {
7
+ variants: {
8
+ variant: {
9
+ default: 'bg-transparent',
10
+ icon: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4",
11
+ },
12
+ },
13
+ defaultVariants: {
14
+ variant: 'default',
15
+ },
16
+ },
17
+ );
18
+
19
+ export type EmptyMediaVariant = VariantProps<typeof emptyMediaVariants>['variant'];
20
+
21
+ export interface ShadcnEmptyProps extends React.ComponentProps<'div'> {}
22
+
23
+ export function ShadcnEmpty({ className, ...props }: EmptyProps) {
24
+ return (
25
+ <div
26
+ data-slot="empty"
27
+ className={cn(
28
+ 'gap-4 rounded-xl border border-dashed p-6 flex w-full min-w-0 flex-1 flex-col items-center justify-center text-center text-balance',
29
+ className,
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ export interface ShadcnEmptyHeaderProps extends React.ComponentProps<'div'> {}
37
+
38
+ export function ShadcnEmptyHeader({ className, ...props }: EmptyHeaderProps) {
39
+ return (
40
+ <div
41
+ data-slot="empty-header"
42
+ className={cn('gap-2 flex max-w-sm flex-col items-center', className)}
43
+ {...props}
44
+ />
45
+ );
46
+ }
47
+
48
+ export interface ShadcnEmptyMediaProps extends React.ComponentProps<'div'> {
49
+ variant?: EmptyMediaVariant;
50
+ }
51
+
52
+ export function ShadcnEmptyMedia({ className, variant = 'default', ...props }: EmptyMediaProps) {
53
+ return (
54
+ <div
55
+ data-slot="empty-icon"
56
+ data-variant={variant}
57
+ className={cn(emptyMediaVariants({ variant }), className)}
58
+ {...props}
59
+ />
60
+ );
61
+ }
62
+
63
+ export interface ShadcnEmptyTitleProps extends React.ComponentProps<'div'> {}
64
+
65
+ export function ShadcnEmptyTitle({ className, ...props }: EmptyTitleProps) {
66
+ return (
67
+ <div
68
+ data-slot="empty-title"
69
+ className={cn('text-sm font-medium tracking-tight', className)}
70
+ {...props}
71
+ />
72
+ );
73
+ }
74
+
75
+ export interface ShadcnEmptyDescriptionProps extends React.ComponentProps<'div'> {}
76
+
77
+ export function ShadcnEmptyDescription({ className, ...props }: EmptyDescriptionProps) {
78
+ return (
79
+ <div
80
+ data-slot="empty-description"
81
+ className={cn(
82
+ 'text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
83
+ className,
84
+ )}
85
+ {...props}
86
+ />
87
+ );
88
+ }
89
+
90
+ export interface ShadcnEmptyContentProps extends React.ComponentProps<'div'> {}
91
+
92
+ export function ShadcnEmptyContent({ className, ...props }: EmptyContentProps) {
93
+ return (
94
+ <div
95
+ data-slot="empty-content"
96
+ className={cn(
97
+ 'gap-2.5 text-sm flex w-full max-w-sm min-w-0 flex-col items-center text-balance',
98
+ className,
99
+ )}
100
+ {...props}
101
+ />
102
+ );
103
+ }
104
+
105
+ export default ShadcnEmpty;
@@ -0,0 +1,275 @@
1
+ import * as React from 'react';
2
+ import { cn, cva, type VariantProps } from '@surreal-ui/core';
3
+
4
+ export const shadcnFieldVariants = cva(
5
+ 'gap-2 data-[invalid=true]:text-destructive group/field flex w-full',
6
+ {
7
+ variants: {
8
+ orientation: {
9
+ vertical: 'cn-field-orientation-vertical flex-col [&>*]:w-full [&>.sr-only]:w-auto',
10
+ horizontal:
11
+ 'cn-field-orientation-horizontal flex-row items-center has-[>[data-slot=field-content]]:items-start [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
12
+ responsive:
13
+ 'cn-field-orientation-responsive flex-col @md/field-group:flex-row @md/field-group:items-center @md/field-group:has-[>[data-slot=field-content]]:items-start [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ orientation: 'vertical',
18
+ },
19
+ },
20
+ );
21
+
22
+ export type FieldOrientation = VariantProps<typeof fieldVariants>['orientation'];
23
+
24
+ export interface ShadcnFieldProps extends React.ComponentProps<'div'> {
25
+ orientation?: FieldOrientation;
26
+ invalid?: boolean;
27
+ }
28
+
29
+ export const ShadcnField = React.forwardRef<HTMLDivElement, FieldProps>(
30
+ ({ className, orientation = 'vertical', invalid = false, children, ...props }, ref) => {
31
+ return (
32
+ <div
33
+ ref={ref}
34
+ role="group"
35
+ data-slot="field"
36
+ data-orientation={orientation}
37
+ data-invalid={invalid ? 'true' : undefined}
38
+ className={cn(shadcnFieldVariants({ orientation }), className)}
39
+ {...props}
40
+ >
41
+ {children}
42
+ </div>
43
+ );
44
+ },
45
+ );
46
+ Field.displayName = 'Field';
47
+
48
+ export interface ShadcnFieldContentProps extends React.ComponentProps<'div'> {}
49
+
50
+ export const ShadcnFieldContent = React.forwardRef<HTMLDivElement, FieldContentProps>(
51
+ ({ className, children, ...props }, ref) => {
52
+ return (
53
+ <div
54
+ ref={ref}
55
+ data-slot="field-content"
56
+ className={cn('gap-0.5 group/field-content flex flex-1 flex-col leading-snug', className)}
57
+ {...props}
58
+ >
59
+ {children}
60
+ </div>
61
+ );
62
+ },
63
+ );
64
+ FieldContent.displayName = 'FieldContent';
65
+
66
+ export interface ShadcnFieldDescriptionProps extends React.ComponentProps<'p'> {}
67
+
68
+ export const ShadcnFieldDescription = React.forwardRef<HTMLParagraphElement, FieldDescriptionProps>(
69
+ ({ className, children, ...props }, ref) => {
70
+ return (
71
+ <p
72
+ ref={ref}
73
+ data-slot="field-description"
74
+ className={cn(
75
+ 'text-left text-sm text-muted-foreground [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance last:mt-0 nth-last-2:-mt-1 [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
76
+ className,
77
+ )}
78
+ {...props}
79
+ >
80
+ {children}
81
+ </p>
82
+ );
83
+ },
84
+ );
85
+ FieldDescription.displayName = 'FieldDescription';
86
+
87
+ export interface FieldErrorProps extends React.ComponentProps<'div'> {
88
+ errors?: { message?: string }[];
89
+ }
90
+
91
+ export const FieldError = React.forwardRef<HTMLDivElement, FieldErrorProps>(
92
+ ({ className, errors, children, ...props }, ref) => {
93
+ const hasContent = Boolean(
94
+ children ||
95
+ (errors && errors.length > 0 && (errors.length > 1 || Boolean(errors[0]?.message))),
96
+ );
97
+
98
+ if (!hasContent) return null;
99
+
100
+ return (
101
+ <div
102
+ ref={ref}
103
+ role="alert"
104
+ data-slot="field-error"
105
+ className={cn('text-sm text-destructive font-normal', className)}
106
+ {...props}
107
+ >
108
+ {children ? (
109
+ children
110
+ ) : errors && errors.length === 1 && errors[0]?.message ? (
111
+ errors[0].message
112
+ ) : errors && errors.length > 1 ? (
113
+ <ul className="ml-4 flex list-disc flex-col gap-1">
114
+ {errors.map((error, index) =>
115
+ error?.message ? <li key={index}>{error.message}</li> : null,
116
+ )}
117
+ </ul>
118
+ ) : null}
119
+ </div>
120
+ );
121
+ },
122
+ );
123
+ FieldError.displayName = 'FieldError';
124
+
125
+ export interface ShadcnFieldGroupProps extends React.ComponentProps<'div'> {}
126
+
127
+ export const ShadcnFieldGroup = React.forwardRef<HTMLDivElement, FieldGroupProps>(
128
+ ({ className, children, ...props }, ref) => {
129
+ return (
130
+ <div
131
+ ref={ref}
132
+ data-slot="field-group"
133
+ className={cn(
134
+ 'gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4 group/field-group @container/field-group flex w-full flex-col',
135
+ className,
136
+ )}
137
+ {...props}
138
+ >
139
+ {children}
140
+ </div>
141
+ );
142
+ },
143
+ );
144
+ FieldGroup.displayName = 'FieldGroup';
145
+
146
+ export interface ShadcnFieldLabelProps extends React.ComponentProps<'label'> {}
147
+
148
+ export const ShadcnFieldLabel = React.forwardRef<HTMLLabelElement, FieldLabelProps>(
149
+ ({ className, children, ...props }, ref) => {
150
+ return (
151
+ <label
152
+ ref={ref}
153
+ data-slot="field-label"
154
+ className={cn(
155
+ 'gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 group/field-label peer/field-label flex w-fit cursor-pointer text-sm font-medium text-foreground leading-snug has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
156
+ className,
157
+ )}
158
+ {...props}
159
+ >
160
+ {children}
161
+ </label>
162
+ );
163
+ },
164
+ );
165
+ FieldLabel.displayName = 'FieldLabel';
166
+
167
+ export interface FieldLegendProps extends React.ComponentProps<'legend'> {
168
+ variant?: 'legend' | 'label';
169
+ }
170
+
171
+ export const FieldLegend = React.forwardRef<HTMLLegendElement, FieldLegendProps>(
172
+ ({ className, variant = 'legend', children, ...props }, ref) => {
173
+ return (
174
+ <legend
175
+ ref={ref}
176
+ data-slot="field-legend"
177
+ data-variant={variant}
178
+ className={cn(
179
+ 'mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base text-foreground',
180
+ className,
181
+ )}
182
+ {...props}
183
+ >
184
+ {children}
185
+ </legend>
186
+ );
187
+ },
188
+ );
189
+ FieldLegend.displayName = 'FieldLegend';
190
+
191
+ export interface ShadcnFieldSeparatorProps extends React.ComponentProps<'div'> {}
192
+
193
+ export const ShadcnFieldSeparator = React.forwardRef<HTMLDivElement, FieldSeparatorProps>(
194
+ ({ className, children, ...props }, ref) => {
195
+ return (
196
+ <div
197
+ ref={ref}
198
+ data-slot="field-separator"
199
+ data-content={Boolean(children)}
200
+ className={cn(
201
+ '-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative flex items-center justify-center',
202
+ className,
203
+ )}
204
+ {...props}
205
+ >
206
+ <div className="absolute inset-0 top-1/2 -translate-y-1/2 border-t border-border w-full" />
207
+ {children ? (
208
+ <span
209
+ className="px-2 text-muted-foreground relative bg-background text-xs uppercase tracking-wider"
210
+ data-slot="field-separator-content"
211
+ >
212
+ {children}
213
+ </span>
214
+ ) : null}
215
+ </div>
216
+ );
217
+ },
218
+ );
219
+ FieldSeparator.displayName = 'FieldSeparator';
220
+
221
+ export interface FieldSetProps extends React.ComponentProps<'fieldset'> {}
222
+
223
+ export const FieldSet = React.forwardRef<HTMLFieldSetElement, FieldSetProps>(
224
+ ({ className, children, ...props }, ref) => {
225
+ return (
226
+ <fieldset
227
+ ref={ref}
228
+ data-slot="field-set"
229
+ className={cn(
230
+ 'gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col border-0 p-0 m-0',
231
+ className,
232
+ )}
233
+ {...props}
234
+ >
235
+ {children}
236
+ </fieldset>
237
+ );
238
+ },
239
+ );
240
+ FieldSet.displayName = 'FieldSet';
241
+
242
+ export interface ShadcnFieldTitleProps extends React.ComponentProps<'div'> {}
243
+
244
+ export const ShadcnFieldTitle = React.forwardRef<HTMLDivElement, FieldTitleProps>(
245
+ ({ className, children, ...props }, ref) => {
246
+ return (
247
+ <div
248
+ ref={ref}
249
+ data-slot="field-label"
250
+ className={cn(
251
+ 'gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center text-foreground',
252
+ className,
253
+ )}
254
+ {...props}
255
+ >
256
+ {children}
257
+ </div>
258
+ );
259
+ },
260
+ );
261
+ FieldTitle.displayName = 'FieldTitle';
262
+
263
+ export {
264
+ ShadcnField as Root,
265
+ FieldSet as Set,
266
+ FieldLegend as Legend,
267
+ FieldGroup as Group,
268
+ FieldContent as Content,
269
+ FieldLabel as Label,
270
+ FieldTitle as Title,
271
+ FieldDescription as Description,
272
+ FieldSeparator as Separator,
273
+ FieldError as Error,
274
+ };
275
+ export default ShadcnField;
@@ -0,0 +1,203 @@
1
+ import * as React from 'react';
2
+ import { cn } from '@surreal-ui/core';
3
+
4
+ type FormItemContextValue = {
5
+ id: string;
6
+ name?: string;
7
+ error?: string;
8
+ };
9
+
10
+ const FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue);
11
+
12
+ export const useFormField = () => {
13
+ const itemContext = React.useContext(FormItemContext);
14
+ const id = itemContext.id || React.useId();
15
+
16
+ return {
17
+ id,
18
+ name: itemContext.name,
19
+ formItemId: `${id}-form-item`,
20
+ formDescriptionId: `${id}-form-item-description`,
21
+ formMessageId: `${id}-form-item-message`,
22
+ error: itemContext.error,
23
+ };
24
+ };
25
+
26
+ export interface ShadcnFormProps extends React.FormHTMLAttributes<HTMLFormElement> {}
27
+
28
+ export const ShadcnForm = React.forwardRef<HTMLFormElement, FormProps>(({ className, ...props }, ref) => (
29
+ <form ref={ref} className={cn('space-y-6', className)} {...props} />
30
+ ));
31
+ Form.displayName = 'Form';
32
+
33
+ export interface ShadcnFormItemProps extends React.HTMLAttributes<HTMLDivElement> {
34
+ name?: string;
35
+ error?: string;
36
+ }
37
+
38
+ export const ShadcnFormItem = React.forwardRef<HTMLDivElement, FormItemProps>(
39
+ ({ className, id: customId, name, error, ...props }, ref) => {
40
+ const id = customId || React.useId();
41
+ return (
42
+ <FormItemContext.Provider value={{ id, name, error }}>
43
+ <div ref={ref} data-slot="form-item" className={cn('space-y-2', className)} {...props} />
44
+ </FormItemContext.Provider>
45
+ );
46
+ },
47
+ );
48
+ FormItem.displayName = 'FormItem';
49
+
50
+ export interface ShadcnFormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {}
51
+
52
+ export const ShadcnFormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(
53
+ ({ className, ...props }, ref) => {
54
+ const { error, formItemId } = useFormField();
55
+ return (
56
+ <label
57
+ ref={ref}
58
+ data-slot="form-label"
59
+ data-error={error ? '' : undefined}
60
+ htmlFor={formItemId}
61
+ className={cn(
62
+ 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 data-[error]:text-destructive',
63
+ className,
64
+ )}
65
+ {...props}
66
+ />
67
+ );
68
+ },
69
+ );
70
+ FormLabel.displayName = 'FormLabel';
71
+
72
+ export interface ShadcnFormControlProps extends React.HTMLAttributes<HTMLDivElement> {}
73
+
74
+ export const ShadcnFormControl = React.forwardRef<HTMLDivElement, FormControlProps>(
75
+ ({ ...props }, ref) => {
76
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
77
+ return (
78
+ <div
79
+ ref={ref}
80
+ data-slot="form-control"
81
+ id={formItemId}
82
+ aria-describedby={!error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`}
83
+ aria-invalid={!!error}
84
+ {...props}
85
+ />
86
+ );
87
+ },
88
+ );
89
+ FormControl.displayName = 'FormControl';
90
+
91
+ export interface ShadcnFormDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {}
92
+
93
+ export const ShadcnFormDescription = React.forwardRef<HTMLParagraphElement, FormDescriptionProps>(
94
+ ({ className, ...props }, ref) => {
95
+ const { formDescriptionId } = useFormField();
96
+ return (
97
+ <p
98
+ ref={ref}
99
+ data-slot="form-description"
100
+ id={formDescriptionId}
101
+ className={cn('text-sm text-muted-foreground', className)}
102
+ {...props}
103
+ />
104
+ );
105
+ },
106
+ );
107
+ FormDescription.displayName = 'FormDescription';
108
+
109
+ export interface ShadcnFormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {
110
+ children?: React.ReactNode;
111
+ }
112
+
113
+ export const ShadcnFormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(
114
+ ({ className, children, ...props }, ref) => {
115
+ const { error, formMessageId } = useFormField();
116
+ const body = error ? String(error) : children;
117
+
118
+ if (!body) {
119
+ return null;
120
+ }
121
+
122
+ return (
123
+ <p
124
+ ref={ref}
125
+ data-slot="form-message"
126
+ id={formMessageId}
127
+ className={cn('text-sm font-medium text-destructive', className)}
128
+ {...props}
129
+ >
130
+ {body}
131
+ </p>
132
+ );
133
+ },
134
+ );
135
+ FormMessage.displayName = 'FormMessage';
136
+
137
+ export interface FormFieldsetProps extends React.FieldsetHTMLAttributes<HTMLFieldSetElement> {}
138
+
139
+ export const FormFieldset = React.forwardRef<HTMLFieldSetElement, FormFieldsetProps>(
140
+ ({ className, ...props }, ref) => (
141
+ <fieldset ref={ref} className={cn('space-y-2', className)} {...props} />
142
+ ),
143
+ );
144
+ FormFieldset.displayName = 'FormFieldset';
145
+
146
+ export interface FormLegendProps extends React.HTMLAttributes<HTMLLegendElement> {
147
+ error?: boolean;
148
+ }
149
+
150
+ export const FormLegend = React.forwardRef<HTMLLegendElement, FormLegendProps>(
151
+ ({ className, error, ...props }, ref) => (
152
+ <legend
153
+ ref={ref}
154
+ data-slot="form-legend"
155
+ data-error={error ? '' : undefined}
156
+ className={cn('text-sm leading-none font-medium data-[error]:text-destructive', className)}
157
+ {...props}
158
+ />
159
+ ),
160
+ );
161
+ FormLegend.displayName = 'FormLegend';
162
+
163
+ export interface ShadcnFormButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
164
+ variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
165
+ }
166
+
167
+ export const ShadcnFormButton = React.forwardRef<HTMLButtonElement, FormButtonProps>(
168
+ ({ className, type = 'submit', variant = 'default', ...props }, ref) => (
169
+ <button
170
+ ref={ref}
171
+ type={type}
172
+ className={cn(
173
+ 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 h-9 px-4 py-2 shadow',
174
+ variant === 'default' && 'bg-primary text-primary-foreground hover:bg-primary/90',
175
+ variant === 'destructive' &&
176
+ 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
177
+ variant === 'outline' &&
178
+ 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
179
+ variant === 'secondary' && 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
180
+ variant === 'ghost' && 'hover:bg-accent hover:text-accent-foreground',
181
+ variant === 'link' && 'text-primary underline-offset-4 hover:underline',
182
+ className,
183
+ )}
184
+ {...props}
185
+ />
186
+ ),
187
+ );
188
+ FormButton.displayName = 'FormButton';
189
+
190
+ export {
191
+ FormItem as Field,
192
+ FormControl as Control,
193
+ FormLabel as Label,
194
+ FormButton as Button,
195
+ FormMessage as FieldErrors,
196
+ FormDescription as Description,
197
+ FormFieldset as Fieldset,
198
+ FormLegend as Legend,
199
+ FormItem as FormField,
200
+ FormMessage as FormFieldErrors,
201
+ };
202
+
203
+ export default ShadcnForm;
@@ -0,0 +1,48 @@
1
+ import * as React from 'react';
2
+ import * as HoverCardPrimitive from '@radix-ui/react-hover-card';
3
+ import { cn } from '@surreal-ui/core';
4
+
5
+ const HoverCard = HoverCardPrimitive.Root;
6
+
7
+ const HoverCardTrigger = HoverCardPrimitive.Trigger;
8
+
9
+ const HoverCardPortal = HoverCardPrimitive.Portal;
10
+
11
+ export interface ShadcnHoverCardContentProps extends React.ComponentPropsWithoutRef<
12
+ typeof HoverCardPrimitive.Content
13
+ > {
14
+ portalProps?: React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Portal>;
15
+ }
16
+
17
+ const HoverCardContent = React.forwardRef<
18
+ React.ComponentRef<typeof HoverCardPrimitive.Content>,
19
+ HoverCardContentProps
20
+ >(({ className, align = 'center', sideOffset = 4, portalProps, ...props }, ref) => (
21
+ <HoverCardPortal {...portalProps}>
22
+ <HoverCardPrimitive.Content
23
+ ref={ref}
24
+ align={align}
25
+ sideOffset={sideOffset}
26
+ data-slot="hover-card-content"
27
+ className={cn(
28
+ 'z-50 w-64 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 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 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 origin-(--radix-hover-card-content-transform-origin) outline-hidden',
29
+ className,
30
+ )}
31
+ {...props}
32
+ />
33
+ </HoverCardPortal>
34
+ ));
35
+ HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
36
+
37
+ export {
38
+ ShadcnHoverCard,
39
+ HoverCardTrigger,
40
+ HoverCardContent,
41
+ HoverCardPortal,
42
+ ShadcnHoverCard as Root,
43
+ HoverCardTrigger as Trigger,
44
+ HoverCardContent as Content,
45
+ HoverCardPortal as Portal,
46
+ };
47
+
48
+ export default ShadcnHoverCard;
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { cn } from '@surreal-ui/core';
3
+
4
+ export interface ShadcnInputProps extends React.ComponentProps<'input'> {}
5
+
6
+ export const ShadcnInput = React.forwardRef<HTMLInputElement, InputProps>(
7
+ ({ className, type, 'data-slot': dataSlot = 'input', ...props }, ref) => {
8
+ return (
9
+ <input
10
+ type={type}
11
+ data-slot={dataSlot}
12
+ className={cn(
13
+ 'h-8 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
14
+ className,
15
+ )}
16
+ ref={ref}
17
+ {...props}
18
+ />
19
+ );
20
+ },
21
+ );
22
+ Input.displayName = 'Input';
23
+
24
+ export default ShadcnInput;