@surreal-ui/react 0.8.0 → 0.9.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 (128) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +955 -7227
  3. package/dist/utils.d.ts +9 -0
  4. package/dist/utils.js +14 -0
  5. package/package.json +25 -8
  6. package/CHANGELOG.md +0 -142
  7. package/src/components/GlassmorphismAlert.tsx +0 -43
  8. package/src/components/GlassmorphismButton.tsx +0 -20
  9. package/src/components/GlassmorphismCard.tsx +0 -43
  10. package/src/components/GlassmorphismEmptyState.tsx +0 -20
  11. package/src/components/GlassmorphismInputGroup.tsx +0 -148
  12. package/src/components/GlassmorphismMenubar.tsx +0 -96
  13. package/src/components/GlassmorphismScrollArea.tsx +0 -67
  14. package/src/components/GlassmorphismTable.tsx +0 -61
  15. package/src/components/GlassmorphismTypography.tsx +0 -31
  16. package/src/components/MinimalistAccordion.tsx +0 -215
  17. package/src/components/MinimalistAlert.tsx +0 -43
  18. package/src/components/MinimalistAlertDialog.tsx +0 -318
  19. package/src/components/MinimalistAspectRatio.tsx +0 -30
  20. package/src/components/MinimalistAvatar.tsx +0 -149
  21. package/src/components/MinimalistBadge.tsx +0 -49
  22. package/src/components/MinimalistBreadcrumb.tsx +0 -109
  23. package/src/components/MinimalistButton.tsx +0 -86
  24. package/src/components/MinimalistButtonGroup.tsx +0 -86
  25. package/src/components/MinimalistCalendar.tsx +0 -355
  26. package/src/components/MinimalistCard.tsx +0 -89
  27. package/src/components/MinimalistCarousel.tsx +0 -266
  28. package/src/components/MinimalistChart.tsx +0 -296
  29. package/src/components/MinimalistCheckbox.tsx +0 -117
  30. package/src/components/MinimalistCodeBlock.tsx +0 -203
  31. package/src/components/MinimalistCollapsible.tsx +0 -134
  32. package/src/components/MinimalistCommand.tsx +0 -344
  33. package/src/components/MinimalistContextMenu.tsx +0 -408
  34. package/src/components/MinimalistDialog.tsx +0 -273
  35. package/src/components/MinimalistDrawer.tsx +0 -220
  36. package/src/components/MinimalistDropdownMenu.tsx +0 -431
  37. package/src/components/MinimalistEmpty.tsx +0 -105
  38. package/src/components/MinimalistEmptyState.tsx +0 -34
  39. package/src/components/MinimalistField.tsx +0 -275
  40. package/src/components/MinimalistForm.tsx +0 -205
  41. package/src/components/MinimalistHoverCard.tsx +0 -48
  42. package/src/components/MinimalistInput.tsx +0 -24
  43. package/src/components/MinimalistInputGroup.tsx +0 -180
  44. package/src/components/MinimalistInputOtp.tsx +0 -189
  45. package/src/components/MinimalistItem.tsx +0 -182
  46. package/src/components/MinimalistKbd.tsx +0 -46
  47. package/src/components/MinimalistLabel.tsx +0 -19
  48. package/src/components/MinimalistMenubar.tsx +0 -491
  49. package/src/components/MinimalistNativeSelect.tsx +0 -77
  50. package/src/components/MinimalistNavigationMenu.tsx +0 -198
  51. package/src/components/MinimalistPagination.tsx +0 -152
  52. package/src/components/MinimalistPopover.tsx +0 -229
  53. package/src/components/MinimalistProgress.tsx +0 -39
  54. package/src/components/MinimalistRadioGroup.tsx +0 -115
  55. package/src/components/MinimalistRangeCalendar.tsx +0 -396
  56. package/src/components/MinimalistResizable.tsx +0 -54
  57. package/src/components/MinimalistScrollArea.tsx +0 -41
  58. package/src/components/MinimalistSelect.tsx +0 -262
  59. package/src/components/MinimalistSeparator.tsx +0 -45
  60. package/src/components/MinimalistSheet.tsx +0 -247
  61. package/src/components/MinimalistSidebar.tsx +0 -638
  62. package/src/components/MinimalistSkeleton.tsx +0 -16
  63. package/src/components/MinimalistSlider.tsx +0 -213
  64. package/src/components/MinimalistSonner.tsx +0 -41
  65. package/src/components/MinimalistSpinner.tsx +0 -39
  66. package/src/components/MinimalistSwitch.tsx +0 -92
  67. package/src/components/MinimalistTable.tsx +0 -65
  68. package/src/components/MinimalistTabs.tsx +0 -171
  69. package/src/components/MinimalistTextarea.tsx +0 -24
  70. package/src/components/MinimalistToggle.tsx +0 -74
  71. package/src/components/MinimalistToggleGroup.tsx +0 -197
  72. package/src/components/MinimalistTooltip.tsx +0 -172
  73. package/src/components/MinimalistTypography.tsx +0 -33
  74. package/src/components/NeubrutalismCard.tsx +0 -84
  75. package/src/components/NeubrutalismItem.tsx +0 -48
  76. package/src/components/ShadcnAccordion.tsx +0 -215
  77. package/src/components/ShadcnAlertDialog.tsx +0 -318
  78. package/src/components/ShadcnAspectRatio.tsx +0 -30
  79. package/src/components/ShadcnAvatar.tsx +0 -149
  80. package/src/components/ShadcnBadge.tsx +0 -49
  81. package/src/components/ShadcnBreadcrumb.tsx +0 -109
  82. package/src/components/ShadcnButton.tsx +0 -86
  83. package/src/components/ShadcnButtonGroup.tsx +0 -86
  84. package/src/components/ShadcnCalendar.tsx +0 -355
  85. package/src/components/ShadcnCarousel.tsx +0 -266
  86. package/src/components/ShadcnChart.tsx +0 -296
  87. package/src/components/ShadcnCheckbox.tsx +0 -117
  88. package/src/components/ShadcnCodeBlock.tsx +0 -203
  89. package/src/components/ShadcnCollapsible.tsx +0 -134
  90. package/src/components/ShadcnCommand.tsx +0 -344
  91. package/src/components/ShadcnContextMenu.tsx +0 -408
  92. package/src/components/ShadcnDialog.tsx +0 -273
  93. package/src/components/ShadcnDrawer.tsx +0 -220
  94. package/src/components/ShadcnDropdownMenu.tsx +0 -431
  95. package/src/components/ShadcnEmpty.tsx +0 -105
  96. package/src/components/ShadcnField.tsx +0 -275
  97. package/src/components/ShadcnForm.tsx +0 -205
  98. package/src/components/ShadcnHoverCard.tsx +0 -48
  99. package/src/components/ShadcnInput.tsx +0 -24
  100. package/src/components/ShadcnInputGroup.tsx +0 -180
  101. package/src/components/ShadcnInputOtp.tsx +0 -189
  102. package/src/components/ShadcnItem.tsx +0 -182
  103. package/src/components/ShadcnKbd.tsx +0 -46
  104. package/src/components/ShadcnLabel.tsx +0 -19
  105. package/src/components/ShadcnMenubar.tsx +0 -491
  106. package/src/components/ShadcnNativeSelect.tsx +0 -77
  107. package/src/components/ShadcnNavigationMenu.tsx +0 -198
  108. package/src/components/ShadcnPagination.tsx +0 -152
  109. package/src/components/ShadcnPopover.tsx +0 -229
  110. package/src/components/ShadcnProgress.tsx +0 -39
  111. package/src/components/ShadcnRadioGroup.tsx +0 -115
  112. package/src/components/ShadcnRangeCalendar.tsx +0 -396
  113. package/src/components/ShadcnSelect.tsx +0 -262
  114. package/src/components/ShadcnSeparator.tsx +0 -45
  115. package/src/components/ShadcnSheet.tsx +0 -247
  116. package/src/components/ShadcnSidebar.tsx +0 -638
  117. package/src/components/ShadcnSkeleton.tsx +0 -16
  118. package/src/components/ShadcnSlider.tsx +0 -213
  119. package/src/components/ShadcnSonner.tsx +0 -41
  120. package/src/components/ShadcnSpinner.tsx +0 -39
  121. package/src/components/ShadcnSwitch.tsx +0 -92
  122. package/src/components/ShadcnTabs.tsx +0 -171
  123. package/src/components/ShadcnTextarea.tsx +0 -24
  124. package/src/components/ShadcnToggle.tsx +0 -74
  125. package/src/components/ShadcnToggleGroup.tsx +0 -197
  126. package/src/components/ShadcnTooltip.tsx +0 -172
  127. package/src/index.ts +0 -124
  128. package/tsconfig.json +0 -10
@@ -1,105 +0,0 @@
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 MinimalistEmpty;
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { Boxes } from 'lucide-react';
3
- interface MinimalistEmptyStateProps {
4
- title?: string;
5
- description?: string;
6
- actionText?: string;
7
- actionHref?: string;
8
- }
9
- export const MinimalistEmptyState: React.FC<MinimalistEmptyStateProps> = ({
10
- title = 'No components found',
11
- description = 'No components match your search filters. Try clearing filters or run the seed script to populate components.',
12
- actionText = 'Create Component',
13
- actionHref = '/studio'
14
- }) => {
15
- return (
16
- <div className="text-center py-16 bg-slate-900/40 border border-dashed border-slate-800 rounded-3xl space-y-4">
17
- <div className="inline-flex p-4 bg-slate-800/50 rounded-2xl text-slate-400">
18
- <Boxes className="w-10 h-10 mx-auto text-indigo-400" />
19
- </div>
20
- <h3 className="text-xl font-bold text-white">{title}</h3>
21
- <p className="text-slate-400 max-w-md mx-auto text-sm">{description}</p>
22
- <div className="pt-2 flex justify-center gap-3">
23
- <a
24
- href={actionHref}
25
- className="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white text-sm font-semibold rounded-xl transition-colors"
26
- >
27
- {actionText}
28
- </a>
29
- </div>
30
- </div>
31
- );
32
- };
33
-
34
- export default MinimalistEmptyState;
@@ -1,275 +0,0 @@
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 MinimalistField;
@@ -1,205 +0,0 @@
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>(
29
- ({ className, ...props }, ref) => (
30
- <form ref={ref} className={cn('space-y-6', className)} {...props} />
31
- )
32
- );
33
- Form.displayName = 'Form';
34
-
35
- export interface ShadcnFormItemProps extends React.HTMLAttributes<HTMLDivElement> {
36
- name?: string;
37
- error?: string;
38
- }
39
-
40
- export const ShadcnFormItem = React.forwardRef<HTMLDivElement, FormItemProps>(
41
- ({ className, id: customId, name, error, ...props }, ref) => {
42
- const id = customId || React.useId();
43
- return (
44
- <FormItemContext.Provider value={{ id, name, error }}>
45
- <div ref={ref} data-slot="form-item" className={cn('space-y-2', className)} {...props} />
46
- </FormItemContext.Provider>
47
- );
48
- }
49
- );
50
- FormItem.displayName = 'FormItem';
51
-
52
- export interface ShadcnFormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {}
53
-
54
- export const ShadcnFormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(
55
- ({ className, ...props }, ref) => {
56
- const { error, formItemId } = useFormField();
57
- return (
58
- <label
59
- ref={ref}
60
- data-slot="form-label"
61
- data-error={error ? '' : undefined}
62
- htmlFor={formItemId}
63
- className={cn(
64
- 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 data-[error]:text-destructive',
65
- className
66
- )}
67
- {...props}
68
- />
69
- );
70
- }
71
- );
72
- FormLabel.displayName = 'FormLabel';
73
-
74
- export interface ShadcnFormControlProps extends React.HTMLAttributes<HTMLDivElement> {}
75
-
76
- export const ShadcnFormControl = React.forwardRef<HTMLDivElement, FormControlProps>(
77
- ({ ...props }, ref) => {
78
- const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
79
- return (
80
- <div
81
- ref={ref}
82
- data-slot="form-control"
83
- id={formItemId}
84
- aria-describedby={!error ? formDescriptionId : `${formDescriptionId} ${formMessageId}`}
85
- aria-invalid={!!error}
86
- {...props}
87
- />
88
- );
89
- }
90
- );
91
- FormControl.displayName = 'FormControl';
92
-
93
- export interface ShadcnFormDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {}
94
-
95
- export const ShadcnFormDescription = React.forwardRef<HTMLParagraphElement, FormDescriptionProps>(
96
- ({ className, ...props }, ref) => {
97
- const { formDescriptionId } = useFormField();
98
- return (
99
- <p
100
- ref={ref}
101
- data-slot="form-description"
102
- id={formDescriptionId}
103
- className={cn('text-sm text-muted-foreground', className)}
104
- {...props}
105
- />
106
- );
107
- }
108
- );
109
- FormDescription.displayName = 'FormDescription';
110
-
111
- export interface ShadcnFormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {
112
- children?: React.ReactNode;
113
- }
114
-
115
- export const ShadcnFormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(
116
- ({ className, children, ...props }, ref) => {
117
- const { error, formMessageId } = useFormField();
118
- const body = error ? String(error) : children;
119
-
120
- if (!body) {
121
- return null;
122
- }
123
-
124
- return (
125
- <p
126
- ref={ref}
127
- data-slot="form-message"
128
- id={formMessageId}
129
- className={cn('text-sm font-medium text-destructive', className)}
130
- {...props}
131
- >
132
- {body}
133
- </p>
134
- );
135
- }
136
- );
137
- FormMessage.displayName = 'FormMessage';
138
-
139
- export interface FormFieldsetProps extends React.FieldsetHTMLAttributes<HTMLFieldSetElement> {}
140
-
141
- export const FormFieldset = React.forwardRef<HTMLFieldSetElement, FormFieldsetProps>(
142
- ({ className, ...props }, ref) => (
143
- <fieldset ref={ref} className={cn('space-y-2', className)} {...props} />
144
- )
145
- );
146
- FormFieldset.displayName = 'FormFieldset';
147
-
148
- export interface FormLegendProps extends React.HTMLAttributes<HTMLLegendElement> {
149
- error?: boolean;
150
- }
151
-
152
- export const FormLegend = React.forwardRef<HTMLLegendElement, FormLegendProps>(
153
- ({ className, error, ...props }, ref) => (
154
- <legend
155
- ref={ref}
156
- data-slot="form-legend"
157
- data-error={error ? '' : undefined}
158
- className={cn('text-sm leading-none font-medium data-[error]:text-destructive', className)}
159
- {...props}
160
- />
161
- )
162
- );
163
- FormLegend.displayName = 'FormLegend';
164
-
165
- export interface ShadcnFormButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
166
- variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
167
- }
168
-
169
- export const ShadcnFormButton = React.forwardRef<HTMLButtonElement, FormButtonProps>(
170
- ({ className, type = 'submit', variant = 'default', ...props }, ref) => (
171
- <button
172
- ref={ref}
173
- type={type}
174
- className={cn(
175
- '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',
176
- variant === 'default' && 'bg-primary text-primary-foreground hover:bg-primary/90',
177
- variant === 'destructive' &&
178
- 'bg-destructive text-destructive-foreground hover:bg-destructive/90',
179
- variant === 'outline' &&
180
- 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
181
- variant === 'secondary' && 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
182
- variant === 'ghost' && 'hover:bg-accent hover:text-accent-foreground',
183
- variant === 'link' && 'text-primary underline-offset-4 hover:underline',
184
- className
185
- )}
186
- {...props}
187
- />
188
- )
189
- );
190
- FormButton.displayName = 'FormButton';
191
-
192
- export {
193
- FormItem as Field,
194
- FormControl as Control,
195
- FormLabel as Label,
196
- FormButton as Button,
197
- FormMessage as FieldErrors,
198
- FormDescription as Description,
199
- FormFieldset as Fieldset,
200
- FormLegend as Legend,
201
- FormItem as FormField,
202
- FormMessage as FormFieldErrors
203
- };
204
-
205
- export default MinimalistForm;
@@ -1,48 +0,0 @@
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 MinimalistHoverCard;
@@ -1,24 +0,0 @@
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 MinimalistInput;