@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,180 @@
1
+ import * as React from 'react';
2
+ import { cn, cva, type VariantProps } from '@surreal-ui/core';
3
+
4
+ export const inputGroupAddonVariants = cva(
5
+ "h-auto gap-2 py-1.5 text-sm font-medium text-muted-foreground group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none",
6
+ {
7
+ variants: {
8
+ align: {
9
+ 'inline-start': 'pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem] order-first',
10
+ 'inline-end': 'pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem] order-last',
11
+ 'block-start':
12
+ 'px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start',
13
+ 'block-end':
14
+ 'px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start',
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ align: 'inline-start',
19
+ },
20
+ },
21
+ );
22
+
23
+ export const inputGroupButtonVariants = cva(
24
+ 'gap-2 text-sm flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 shadow-none hover:bg-accent hover:text-accent-foreground',
25
+ {
26
+ variants: {
27
+ size: {
28
+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
29
+ sm: 'h-7 gap-1.5 rounded-md px-2 text-xs',
30
+ 'icon-xs': 'size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0',
31
+ 'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
32
+ },
33
+ },
34
+ defaultVariants: {
35
+ size: 'xs',
36
+ },
37
+ },
38
+ );
39
+
40
+ export interface ShadcnInputGroupProps extends React.ComponentProps<'div'> {}
41
+
42
+ export const ShadcnInputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
43
+ ({ className, children, ...props }, ref) => {
44
+ return (
45
+ <div
46
+ ref={ref}
47
+ data-slot="input-group"
48
+ role="group"
49
+ className={cn(
50
+ 'group/input-group h-8 rounded-lg border border-input transition-colors in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto',
51
+ className,
52
+ )}
53
+ {...props}
54
+ >
55
+ {children}
56
+ </div>
57
+ );
58
+ },
59
+ );
60
+ InputGroup.displayName = 'InputGroup';
61
+
62
+ export interface InputGroupAddonProps
63
+ extends React.ComponentProps<'div'>, VariantProps<typeof inputGroupAddonVariants> {}
64
+
65
+ export const InputGroupAddon = React.forwardRef<HTMLDivElement, InputGroupAddonProps>(
66
+ ({ className, align = 'inline-start', onClick, children, ...props }, ref) => {
67
+ return (
68
+ <div
69
+ ref={ref}
70
+ role="group"
71
+ data-slot="input-group-addon"
72
+ data-align={align}
73
+ className={cn(inputGroupAddonVariants({ align }), className)}
74
+ onClick={(e) => {
75
+ if ((e.target as HTMLElement).closest('button')) {
76
+ onClick?.(e);
77
+ return;
78
+ }
79
+ e.currentTarget.parentElement
80
+ ?.querySelector<HTMLInputElement | HTMLTextAreaElement>('input, textarea')
81
+ ?.focus();
82
+ onClick?.(e);
83
+ }}
84
+ {...props}
85
+ >
86
+ {children}
87
+ </div>
88
+ );
89
+ },
90
+ );
91
+ InputGroupAddon.displayName = 'InputGroupAddon';
92
+
93
+ export interface ShadcnInputGroupButtonProps
94
+ extends React.ComponentProps<'button'>, VariantProps<typeof inputGroupButtonVariants> {}
95
+
96
+ export const ShadcnInputGroupButton = React.forwardRef<HTMLButtonElement, InputGroupButtonProps>(
97
+ ({ className, size = 'xs', type = 'button', children, ...props }, ref) => {
98
+ return (
99
+ <button
100
+ ref={ref}
101
+ type={type}
102
+ data-size={size}
103
+ className={cn(inputGroupButtonVariants({ size }), className)}
104
+ {...props}
105
+ >
106
+ {children}
107
+ </button>
108
+ );
109
+ },
110
+ );
111
+ InputGroupButton.displayName = 'InputGroupButton';
112
+
113
+ export interface ShadcnInputGroupInputProps extends React.ComponentProps<'input'> {}
114
+
115
+ export const ShadcnInputGroupInput = React.forwardRef<HTMLInputElement, InputGroupInputProps>(
116
+ ({ className, ...props }, ref) => {
117
+ return (
118
+ <input
119
+ ref={ref}
120
+ data-slot="input-group-control"
121
+ className={cn(
122
+ 'flex-1 rounded-none border-0 bg-transparent px-2.5 py-1 text-sm shadow-none ring-0 outline-none placeholder:text-muted-foreground focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent',
123
+ className,
124
+ )}
125
+ {...props}
126
+ />
127
+ );
128
+ },
129
+ );
130
+ InputGroupInput.displayName = 'InputGroupInput';
131
+
132
+ export interface ShadcnInputGroupTextProps extends React.ComponentProps<'span'> {}
133
+
134
+ export const ShadcnInputGroupText = React.forwardRef<HTMLSpanElement, InputGroupTextProps>(
135
+ ({ className, children, ...props }, ref) => {
136
+ return (
137
+ <span
138
+ ref={ref}
139
+ className={cn(
140
+ "gap-2 text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
141
+ className,
142
+ )}
143
+ {...props}
144
+ >
145
+ {children}
146
+ </span>
147
+ );
148
+ },
149
+ );
150
+ InputGroupText.displayName = 'InputGroupText';
151
+
152
+ export interface InputGroupTextareaProps extends React.ComponentProps<'textarea'> {}
153
+
154
+ export const InputGroupTextarea = React.forwardRef<HTMLTextAreaElement, InputGroupTextareaProps>(
155
+ ({ className, ...props }, ref) => {
156
+ return (
157
+ <textarea
158
+ ref={ref}
159
+ data-slot="input-group-control"
160
+ className={cn(
161
+ 'flex-1 resize-none rounded-none border-0 bg-transparent px-2.5 py-2 text-sm shadow-none ring-0 outline-none placeholder:text-muted-foreground focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent',
162
+ className,
163
+ )}
164
+ {...props}
165
+ />
166
+ );
167
+ },
168
+ );
169
+ InputGroupTextarea.displayName = 'InputGroupTextarea';
170
+
171
+ export {
172
+ ShadcnInputGroup as Root,
173
+ InputGroupAddon as Addon,
174
+ InputGroupButton as Button,
175
+ InputGroupInput as Input,
176
+ InputGroupText as Text,
177
+ InputGroupTextarea as Textarea,
178
+ };
179
+
180
+ export default MinimalistInputGroup;
@@ -0,0 +1,189 @@
1
+ import * as React from 'react';
2
+ import { Minus } from 'lucide-react';
3
+ import { cn } from '@surreal-ui/core';
4
+
5
+ interface InputOTPContextValue {
6
+ value: string;
7
+ maxLength: number;
8
+ disabled?: boolean;
9
+ activeIndex: number;
10
+ isFocused: boolean;
11
+ onSlotClick: (index: number) => void;
12
+ }
13
+
14
+ const InputOTPContext = React.createContext<InputOTPContextValue | null>(null);
15
+
16
+ export interface InputOTPRootProps extends React.ComponentProps<'div'> {
17
+ value?: string;
18
+ defaultValue?: string;
19
+ maxLength?: number;
20
+ disabled?: boolean;
21
+ pattern?: string;
22
+ onValueChange?: (val: string) => void;
23
+ onComplete?: (val: string) => void;
24
+ }
25
+
26
+ export const InputOTP = React.forwardRef<HTMLDivElement, InputOTPRootProps>(
27
+ (
28
+ {
29
+ className,
30
+ value: controlledValue,
31
+ defaultValue = '',
32
+ maxLength = 6,
33
+ disabled = false,
34
+ pattern = '^[0-9]*$',
35
+ onValueChange,
36
+ onComplete,
37
+ children,
38
+ ...props
39
+ },
40
+ ref,
41
+ ) => {
42
+ const [internalValue, setInternalValue] = React.useState(defaultValue);
43
+ const [isFocused, setIsFocused] = React.useState(false);
44
+ const inputRef = React.useRef<HTMLInputElement | null>(null);
45
+
46
+ const isControlled = controlledValue !== undefined;
47
+ const currentValue = isControlled ? controlledValue : internalValue;
48
+
49
+ const activeIndex = isFocused ? Math.min(currentValue.length, maxLength - 1) : -1;
50
+
51
+ const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
52
+ const nextVal = e.target.value.slice(0, maxLength);
53
+ if (pattern && nextVal !== '') {
54
+ const regex = new RegExp(pattern);
55
+ if (!regex.test(nextVal)) return;
56
+ }
57
+ if (!isControlled) {
58
+ setInternalValue(nextVal);
59
+ }
60
+ onValueChange?.(nextVal);
61
+ if (nextVal.length === maxLength) {
62
+ onComplete?.(nextVal);
63
+ }
64
+ };
65
+
66
+ const handleSlotClick = (index: number) => {
67
+ if (disabled) return;
68
+ inputRef.current?.focus();
69
+ const pos = Math.min(index, currentValue.length);
70
+ inputRef.current?.setSelectionRange(pos, pos);
71
+ };
72
+
73
+ const contextValue = React.useMemo<InputOTPContextValue>(
74
+ () => ({
75
+ value: currentValue,
76
+ maxLength,
77
+ disabled,
78
+ activeIndex,
79
+ isFocused,
80
+ onSlotClick: handleSlotClick,
81
+ }),
82
+ [currentValue, maxLength, disabled, activeIndex, isFocused],
83
+ );
84
+
85
+ return (
86
+ <InputOTPContext.Provider value={contextValue}>
87
+ <div
88
+ ref={ref}
89
+ data-slot="input-otp"
90
+ className={cn(
91
+ 'relative flex items-center gap-2 has-disabled:opacity-50 select-none',
92
+ className,
93
+ )}
94
+ {...props}
95
+ >
96
+ <input
97
+ ref={inputRef}
98
+ type="text"
99
+ inputMode="numeric"
100
+ autoComplete="one-time-code"
101
+ value={currentValue}
102
+ maxLength={maxLength}
103
+ disabled={disabled}
104
+ className="absolute inset-0 h-full w-full opacity-0 cursor-pointer disabled:cursor-not-allowed"
105
+ onChange={handleInput}
106
+ onFocus={() => setIsFocused(true)}
107
+ onBlur={() => setIsFocused(false)}
108
+ />
109
+ {children}
110
+ </div>
111
+ </InputOTPContext.Provider>
112
+ );
113
+ },
114
+ );
115
+ InputOTP.displayName = 'InputOTP';
116
+
117
+ export interface InputOTPGroupProps extends React.ComponentProps<'div'> {}
118
+
119
+ export const InputOTPGroup = React.forwardRef<HTMLDivElement, InputOTPGroupProps>(
120
+ ({ className, ...props }, ref) => (
121
+ <div
122
+ ref={ref}
123
+ data-slot="input-otp-group"
124
+ className={cn('flex items-center', className)}
125
+ {...props}
126
+ />
127
+ ),
128
+ );
129
+ InputOTPGroup.displayName = 'InputOTPGroup';
130
+
131
+ export interface InputOTPSlotProps extends React.ComponentProps<'div'> {
132
+ index: number;
133
+ }
134
+
135
+ export const InputOTPSlot = React.forwardRef<HTMLDivElement, InputOTPSlotProps>(
136
+ ({ index, className, ...props }, ref) => {
137
+ const ctx = React.useContext(InputOTPContext);
138
+ const char = ctx ? (ctx.value[index] ?? '') : '';
139
+ const isActive = ctx ? ctx.isFocused && ctx.activeIndex === index : false;
140
+
141
+ return (
142
+ <div
143
+ ref={ref}
144
+ role="presentation"
145
+ data-slot="input-otp-slot"
146
+ data-active={isActive ? '' : undefined}
147
+ className={cn(
148
+ 'relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-xs transition-all first:rounded-l-md border-l-0 first:border-l last:rounded-r-md',
149
+ isActive && 'z-10 ring-1 ring-ring border-ring',
150
+ className,
151
+ )}
152
+ onClick={() => ctx?.onSlotClick(index)}
153
+ {...props}
154
+ >
155
+ {char}
156
+ {isActive && (
157
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
158
+ <div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
159
+ </div>
160
+ )}
161
+ </div>
162
+ );
163
+ },
164
+ );
165
+ InputOTPSlot.displayName = 'InputOTPSlot';
166
+
167
+ export interface InputOTPSeparatorProps extends React.ComponentProps<'div'> {}
168
+
169
+ export const InputOTPSeparator = React.forwardRef<HTMLDivElement, InputOTPSeparatorProps>(
170
+ ({ className, children, ...props }, ref) => (
171
+ <div
172
+ ref={ref}
173
+ role="separator"
174
+ data-slot="input-otp-separator"
175
+ className={cn('text-muted-foreground px-1', className)}
176
+ {...props}
177
+ >
178
+ {children ?? <Minus className="size-4" />}
179
+ </div>
180
+ ),
181
+ );
182
+ InputOTPSeparator.displayName = 'InputOTPSeparator';
183
+
184
+ export const Root = InputOTP;
185
+ export const Group = InputOTPGroup;
186
+ export const Slot = InputOTPSlot;
187
+ export const Separator = InputOTPSeparator;
188
+
189
+ export default MinimalistInputOtp;
@@ -0,0 +1,181 @@
1
+ import * as React from 'react';
2
+ import { cn, cva, type VariantProps } from '@surreal-ui/core';
3
+
4
+ export const shadcnItemVariants = cva(
5
+ 'rounded-lg border text-sm [a]:hover:bg-muted group/item flex w-full flex-wrap items-center transition-colors duration-100 outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [a]:transition-colors',
6
+ {
7
+ variants: {
8
+ variant: {
9
+ default: 'border-transparent',
10
+ outline: 'border-border',
11
+ muted: 'border-transparent bg-muted/50',
12
+ },
13
+ size: {
14
+ default: 'gap-2.5 px-3 py-2.5',
15
+ sm: 'gap-2.5 px-3 py-2.5',
16
+ xs: 'gap-2 px-2.5 py-2 in-data-[slot=dropdown-menu-content]:p-0',
17
+ },
18
+ },
19
+ defaultVariants: {
20
+ variant: 'default',
21
+ size: 'default',
22
+ },
23
+ },
24
+ );
25
+
26
+ export const itemMediaVariants = cva(
27
+ 'gap-2 group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start flex shrink-0 items-center justify-center [&_svg]:pointer-events-none',
28
+ {
29
+ variants: {
30
+ variant: {
31
+ default: 'bg-transparent',
32
+ icon: "[&_svg:not([class*='size-'])]:size-4",
33
+ image:
34
+ 'size-10 overflow-hidden rounded-sm group-data-[size=sm]/item:size-8 group-data-[size=xs]/item:size-6 [&_img]:size-full [&_img]:object-cover',
35
+ },
36
+ },
37
+ defaultVariants: {
38
+ variant: 'default',
39
+ },
40
+ },
41
+ );
42
+
43
+ export type ItemSize = VariantProps<typeof itemVariants>['size'];
44
+ export type ItemVariant = VariantProps<typeof itemVariants>['variant'];
45
+ export type ItemMediaVariant = VariantProps<typeof itemMediaVariants>['variant'];
46
+
47
+ export interface ShadcnItemProps extends React.ComponentProps<'div'>, VariantProps<typeof itemVariants> {
48
+ asChild?: boolean;
49
+ }
50
+
51
+ export function ShadcnItem({ className, variant, size, ...props }: ItemProps) {
52
+ return (
53
+ <div
54
+ data-slot="item"
55
+ data-variant={variant}
56
+ data-size={size}
57
+ className={cn(shadcnItemVariants({ variant, size }), className)}
58
+ {...props}
59
+ />
60
+ );
61
+ }
62
+
63
+ export function ShadcnItemGroup({ className, ...props }: React.ComponentProps<'div'>) {
64
+ return (
65
+ <div
66
+ role="list"
67
+ data-slot="item-group"
68
+ className={cn(
69
+ 'gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2 group/item-group flex w-full flex-col',
70
+ className,
71
+ )}
72
+ {...props}
73
+ />
74
+ );
75
+ }
76
+
77
+ export function ShadcnItemHeader({ className, ...props }: React.ComponentProps<'div'>) {
78
+ return (
79
+ <div
80
+ data-slot="item-header"
81
+ className={cn('gap-2 flex basis-full items-center justify-between', className)}
82
+ {...props}
83
+ />
84
+ );
85
+ }
86
+
87
+ export function ShadcnItemFooter({ className, ...props }: React.ComponentProps<'div'>) {
88
+ return (
89
+ <div
90
+ data-slot="item-footer"
91
+ className={cn('gap-2 flex basis-full items-center justify-between', className)}
92
+ {...props}
93
+ />
94
+ );
95
+ }
96
+
97
+ export function ShadcnItemContent({ className, ...props }: React.ComponentProps<'div'>) {
98
+ return (
99
+ <div
100
+ data-slot="item-content"
101
+ className={cn(
102
+ 'gap-1 group-data-[size=xs]/item:gap-0 flex flex-1 flex-col [&+[data-slot=item-content]]:flex-none',
103
+ className,
104
+ )}
105
+ {...props}
106
+ />
107
+ );
108
+ }
109
+
110
+ export function ShadcnItemTitle({ className, ...props }: React.ComponentProps<'div'>) {
111
+ return (
112
+ <div
113
+ data-slot="item-title"
114
+ className={cn(
115
+ 'gap-2 text-sm leading-snug font-medium underline-offset-4 line-clamp-1 flex w-fit items-center',
116
+ className,
117
+ )}
118
+ {...props}
119
+ />
120
+ );
121
+ }
122
+
123
+ export function ShadcnItemDescription({ className, ...props }: React.ComponentProps<'p'>) {
124
+ return (
125
+ <p
126
+ data-slot="item-description"
127
+ className={cn(
128
+ 'text-left text-sm leading-normal text-muted-foreground group-data-[size=xs]/item:text-xs line-clamp-2 font-normal [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
129
+ className,
130
+ )}
131
+ {...props}
132
+ />
133
+ );
134
+ }
135
+
136
+ export function ItemActions({ className, ...props }: React.ComponentProps<'div'>) {
137
+ return (
138
+ <div data-slot="item-actions" className={cn('gap-2 flex items-center', className)} {...props} />
139
+ );
140
+ }
141
+
142
+ export interface ShadcnItemMediaProps
143
+ extends React.ComponentProps<'div'>, VariantProps<typeof itemMediaVariants> {}
144
+
145
+ export function ShadcnItemMedia({ className, variant = 'default', ...props }: ItemMediaProps) {
146
+ return (
147
+ <div
148
+ data-slot="item-media"
149
+ data-variant={variant}
150
+ className={cn(itemMediaVariants({ variant }), className)}
151
+ {...props}
152
+ />
153
+ );
154
+ }
155
+
156
+ export function ShadcnItemSeparator({ className, ...props }: React.ComponentProps<'div'>) {
157
+ return (
158
+ <div
159
+ role="separator"
160
+ aria-orientation="horizontal"
161
+ data-slot="item-separator"
162
+ className={cn('my-2 h-px w-full shrink-0 bg-border', className)}
163
+ {...props}
164
+ />
165
+ );
166
+ }
167
+
168
+ export {
169
+ ShadcnItem as Root,
170
+ ItemGroup as Group,
171
+ ItemHeader as Header,
172
+ ItemFooter as Footer,
173
+ ItemContent as Content,
174
+ ItemTitle as Title,
175
+ ItemDescription as Description,
176
+ ItemActions as Actions,
177
+ ItemMedia as Media,
178
+ ItemSeparator as Separator,
179
+ };
180
+
181
+ export default MinimalistItem;
@@ -0,0 +1,46 @@
1
+ import * as React from 'react';
2
+ import { cn } from '@surreal-ui/core';
3
+
4
+ export interface ShadcnKbdProps extends React.ComponentProps<'kbd'> {}
5
+
6
+ export const ShadcnKbd = React.forwardRef<HTMLElement, KbdProps>(
7
+ ({ className, children, ...props }, ref) => {
8
+ return (
9
+ <kbd
10
+ ref={ref}
11
+ data-slot="kbd"
12
+ className={cn(
13
+ "h-5 w-fit min-w-5 gap-1 rounded-sm bg-muted px-1 font-sans text-xs font-medium text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3 pointer-events-none inline-flex items-center justify-center select-none",
14
+ className,
15
+ )}
16
+ {...props}
17
+ >
18
+ {children}
19
+ </kbd>
20
+ );
21
+ },
22
+ );
23
+ Kbd.displayName = 'Kbd';
24
+
25
+ export interface ShadcnKbdGroupProps extends React.ComponentProps<'kbd'> {}
26
+
27
+ export const ShadcnKbdGroup = React.forwardRef<HTMLElement, KbdGroupProps>(
28
+ ({ className, children, ...props }, ref) => {
29
+ return (
30
+ <kbd
31
+ ref={ref}
32
+ data-slot="kbd-group"
33
+ className={cn('gap-1 inline-flex items-center', className)}
34
+ {...props}
35
+ >
36
+ {children}
37
+ </kbd>
38
+ );
39
+ },
40
+ );
41
+ KbdGroup.displayName = 'KbdGroup';
42
+
43
+ export const Root = Kbd;
44
+ export const Group = KbdGroup;
45
+
46
+ export default MinimalistKbd;
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { cn } from '@surreal-ui/core';
3
+
4
+ export interface ShadcnLabelProps extends React.ComponentProps<'label'> {}
5
+
6
+ export function ShadcnLabel({ className, ...props }: LabelProps) {
7
+ return (
8
+ <label
9
+ data-slot="label"
10
+ className={cn(
11
+ 'gap-2 text-sm leading-none font-medium group-data-[disabled=true]:opacity-50 peer-disabled:opacity-50 flex items-center select-none group-data-[disabled=true]:pointer-events-none peer-disabled:cursor-not-allowed',
12
+ className,
13
+ )}
14
+ {...props}
15
+ />
16
+ );
17
+ }
18
+
19
+ export default MinimalistLabel;