@surreal-ui/react 0.8.1 → 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.
- package/LICENSE +21 -0
- package/dist/index.js +955 -7227
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +14 -0
- package/package.json +21 -4
- package/CHANGELOG.md +0 -149
- package/src/components/GlassmorphismAlert.tsx +0 -43
- package/src/components/GlassmorphismButton.tsx +0 -20
- package/src/components/GlassmorphismCard.tsx +0 -43
- package/src/components/GlassmorphismEmptyState.tsx +0 -20
- package/src/components/GlassmorphismInputGroup.tsx +0 -148
- package/src/components/GlassmorphismMenubar.tsx +0 -96
- package/src/components/GlassmorphismScrollArea.tsx +0 -67
- package/src/components/GlassmorphismTable.tsx +0 -61
- package/src/components/GlassmorphismTypography.tsx +0 -31
- package/src/components/MinimalistAccordion.tsx +0 -215
- package/src/components/MinimalistAlert.tsx +0 -43
- package/src/components/MinimalistAlertDialog.tsx +0 -318
- package/src/components/MinimalistAspectRatio.tsx +0 -30
- package/src/components/MinimalistAvatar.tsx +0 -149
- package/src/components/MinimalistBadge.tsx +0 -49
- package/src/components/MinimalistBreadcrumb.tsx +0 -109
- package/src/components/MinimalistButton.tsx +0 -86
- package/src/components/MinimalistButtonGroup.tsx +0 -86
- package/src/components/MinimalistCalendar.tsx +0 -355
- package/src/components/MinimalistCard.tsx +0 -89
- package/src/components/MinimalistCarousel.tsx +0 -266
- package/src/components/MinimalistChart.tsx +0 -296
- package/src/components/MinimalistCheckbox.tsx +0 -117
- package/src/components/MinimalistCodeBlock.tsx +0 -203
- package/src/components/MinimalistCollapsible.tsx +0 -134
- package/src/components/MinimalistCommand.tsx +0 -344
- package/src/components/MinimalistContextMenu.tsx +0 -408
- package/src/components/MinimalistDialog.tsx +0 -273
- package/src/components/MinimalistDrawer.tsx +0 -220
- package/src/components/MinimalistDropdownMenu.tsx +0 -431
- package/src/components/MinimalistEmpty.tsx +0 -105
- package/src/components/MinimalistEmptyState.tsx +0 -34
- package/src/components/MinimalistField.tsx +0 -275
- package/src/components/MinimalistForm.tsx +0 -205
- package/src/components/MinimalistHoverCard.tsx +0 -48
- package/src/components/MinimalistInput.tsx +0 -24
- package/src/components/MinimalistInputGroup.tsx +0 -180
- package/src/components/MinimalistInputOtp.tsx +0 -189
- package/src/components/MinimalistItem.tsx +0 -182
- package/src/components/MinimalistKbd.tsx +0 -46
- package/src/components/MinimalistLabel.tsx +0 -19
- package/src/components/MinimalistMenubar.tsx +0 -491
- package/src/components/MinimalistNativeSelect.tsx +0 -77
- package/src/components/MinimalistNavigationMenu.tsx +0 -198
- package/src/components/MinimalistPagination.tsx +0 -152
- package/src/components/MinimalistPopover.tsx +0 -229
- package/src/components/MinimalistProgress.tsx +0 -39
- package/src/components/MinimalistRadioGroup.tsx +0 -115
- package/src/components/MinimalistRangeCalendar.tsx +0 -396
- package/src/components/MinimalistResizable.tsx +0 -54
- package/src/components/MinimalistScrollArea.tsx +0 -41
- package/src/components/MinimalistSelect.tsx +0 -262
- package/src/components/MinimalistSeparator.tsx +0 -45
- package/src/components/MinimalistSheet.tsx +0 -247
- package/src/components/MinimalistSidebar.tsx +0 -638
- package/src/components/MinimalistSkeleton.tsx +0 -16
- package/src/components/MinimalistSlider.tsx +0 -213
- package/src/components/MinimalistSonner.tsx +0 -41
- package/src/components/MinimalistSpinner.tsx +0 -39
- package/src/components/MinimalistSwitch.tsx +0 -92
- package/src/components/MinimalistTable.tsx +0 -65
- package/src/components/MinimalistTabs.tsx +0 -171
- package/src/components/MinimalistTextarea.tsx +0 -24
- package/src/components/MinimalistToggle.tsx +0 -74
- package/src/components/MinimalistToggleGroup.tsx +0 -197
- package/src/components/MinimalistTooltip.tsx +0 -172
- package/src/components/MinimalistTypography.tsx +0 -33
- package/src/components/NeubrutalismCard.tsx +0 -84
- package/src/components/NeubrutalismItem.tsx +0 -48
- package/src/components/ShadcnAccordion.tsx +0 -215
- package/src/components/ShadcnAlertDialog.tsx +0 -318
- package/src/components/ShadcnAspectRatio.tsx +0 -30
- package/src/components/ShadcnAvatar.tsx +0 -149
- package/src/components/ShadcnBadge.tsx +0 -49
- package/src/components/ShadcnBreadcrumb.tsx +0 -109
- package/src/components/ShadcnButton.tsx +0 -86
- package/src/components/ShadcnButtonGroup.tsx +0 -86
- package/src/components/ShadcnCalendar.tsx +0 -355
- package/src/components/ShadcnCarousel.tsx +0 -266
- package/src/components/ShadcnChart.tsx +0 -296
- package/src/components/ShadcnCheckbox.tsx +0 -117
- package/src/components/ShadcnCodeBlock.tsx +0 -203
- package/src/components/ShadcnCollapsible.tsx +0 -134
- package/src/components/ShadcnCommand.tsx +0 -344
- package/src/components/ShadcnContextMenu.tsx +0 -408
- package/src/components/ShadcnDialog.tsx +0 -273
- package/src/components/ShadcnDrawer.tsx +0 -220
- package/src/components/ShadcnDropdownMenu.tsx +0 -431
- package/src/components/ShadcnEmpty.tsx +0 -105
- package/src/components/ShadcnField.tsx +0 -275
- package/src/components/ShadcnForm.tsx +0 -205
- package/src/components/ShadcnHoverCard.tsx +0 -48
- package/src/components/ShadcnInput.tsx +0 -24
- package/src/components/ShadcnInputGroup.tsx +0 -180
- package/src/components/ShadcnInputOtp.tsx +0 -189
- package/src/components/ShadcnItem.tsx +0 -182
- package/src/components/ShadcnKbd.tsx +0 -46
- package/src/components/ShadcnLabel.tsx +0 -19
- package/src/components/ShadcnMenubar.tsx +0 -491
- package/src/components/ShadcnNativeSelect.tsx +0 -77
- package/src/components/ShadcnNavigationMenu.tsx +0 -198
- package/src/components/ShadcnPagination.tsx +0 -152
- package/src/components/ShadcnPopover.tsx +0 -229
- package/src/components/ShadcnProgress.tsx +0 -39
- package/src/components/ShadcnRadioGroup.tsx +0 -115
- package/src/components/ShadcnRangeCalendar.tsx +0 -396
- package/src/components/ShadcnSelect.tsx +0 -262
- package/src/components/ShadcnSeparator.tsx +0 -45
- package/src/components/ShadcnSheet.tsx +0 -247
- package/src/components/ShadcnSidebar.tsx +0 -638
- package/src/components/ShadcnSkeleton.tsx +0 -16
- package/src/components/ShadcnSlider.tsx +0 -213
- package/src/components/ShadcnSonner.tsx +0 -41
- package/src/components/ShadcnSpinner.tsx +0 -39
- package/src/components/ShadcnSwitch.tsx +0 -92
- package/src/components/ShadcnTabs.tsx +0 -171
- package/src/components/ShadcnTextarea.tsx +0 -24
- package/src/components/ShadcnToggle.tsx +0 -74
- package/src/components/ShadcnToggleGroup.tsx +0 -197
- package/src/components/ShadcnTooltip.tsx +0 -172
- package/src/index.ts +0 -124
- package/tsconfig.json +0 -10
|
@@ -1,180 +0,0 @@
|
|
|
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 ShadcnInputGroup;
|
|
@@ -1,189 +0,0 @@
|
|
|
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 ShadcnInputOtp;
|
|
@@ -1,182 +0,0 @@
|
|
|
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
|
|
48
|
-
extends React.ComponentProps<'div'>, VariantProps<typeof itemVariants> {
|
|
49
|
-
asChild?: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function ShadcnItem({ className, variant, size, ...props }: ItemProps) {
|
|
53
|
-
return (
|
|
54
|
-
<div
|
|
55
|
-
data-slot="item"
|
|
56
|
-
data-variant={variant}
|
|
57
|
-
data-size={size}
|
|
58
|
-
className={cn(shadcnItemVariants({ variant, size }), className)}
|
|
59
|
-
{...props}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function ShadcnItemGroup({ className, ...props }: React.ComponentProps<'div'>) {
|
|
65
|
-
return (
|
|
66
|
-
<div
|
|
67
|
-
role="list"
|
|
68
|
-
data-slot="item-group"
|
|
69
|
-
className={cn(
|
|
70
|
-
'gap-4 has-data-[size=sm]:gap-2.5 has-data-[size=xs]:gap-2 group/item-group flex w-full flex-col',
|
|
71
|
-
className
|
|
72
|
-
)}
|
|
73
|
-
{...props}
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function ShadcnItemHeader({ className, ...props }: React.ComponentProps<'div'>) {
|
|
79
|
-
return (
|
|
80
|
-
<div
|
|
81
|
-
data-slot="item-header"
|
|
82
|
-
className={cn('gap-2 flex basis-full items-center justify-between', className)}
|
|
83
|
-
{...props}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function ShadcnItemFooter({ className, ...props }: React.ComponentProps<'div'>) {
|
|
89
|
-
return (
|
|
90
|
-
<div
|
|
91
|
-
data-slot="item-footer"
|
|
92
|
-
className={cn('gap-2 flex basis-full items-center justify-between', className)}
|
|
93
|
-
{...props}
|
|
94
|
-
/>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function ShadcnItemContent({ className, ...props }: React.ComponentProps<'div'>) {
|
|
99
|
-
return (
|
|
100
|
-
<div
|
|
101
|
-
data-slot="item-content"
|
|
102
|
-
className={cn(
|
|
103
|
-
'gap-1 group-data-[size=xs]/item:gap-0 flex flex-1 flex-col [&+[data-slot=item-content]]:flex-none',
|
|
104
|
-
className
|
|
105
|
-
)}
|
|
106
|
-
{...props}
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function ShadcnItemTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
112
|
-
return (
|
|
113
|
-
<div
|
|
114
|
-
data-slot="item-title"
|
|
115
|
-
className={cn(
|
|
116
|
-
'gap-2 text-sm leading-snug font-medium underline-offset-4 line-clamp-1 flex w-fit items-center',
|
|
117
|
-
className
|
|
118
|
-
)}
|
|
119
|
-
{...props}
|
|
120
|
-
/>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function ShadcnItemDescription({ className, ...props }: React.ComponentProps<'p'>) {
|
|
125
|
-
return (
|
|
126
|
-
<p
|
|
127
|
-
data-slot="item-description"
|
|
128
|
-
className={cn(
|
|
129
|
-
'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',
|
|
130
|
-
className
|
|
131
|
-
)}
|
|
132
|
-
{...props}
|
|
133
|
-
/>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function ItemActions({ className, ...props }: React.ComponentProps<'div'>) {
|
|
138
|
-
return (
|
|
139
|
-
<div data-slot="item-actions" className={cn('gap-2 flex items-center', className)} {...props} />
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export interface ShadcnItemMediaProps
|
|
144
|
-
extends React.ComponentProps<'div'>, VariantProps<typeof itemMediaVariants> {}
|
|
145
|
-
|
|
146
|
-
export function ShadcnItemMedia({ className, variant = 'default', ...props }: ItemMediaProps) {
|
|
147
|
-
return (
|
|
148
|
-
<div
|
|
149
|
-
data-slot="item-media"
|
|
150
|
-
data-variant={variant}
|
|
151
|
-
className={cn(itemMediaVariants({ variant }), className)}
|
|
152
|
-
{...props}
|
|
153
|
-
/>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function ShadcnItemSeparator({ className, ...props }: React.ComponentProps<'div'>) {
|
|
158
|
-
return (
|
|
159
|
-
<div
|
|
160
|
-
role="separator"
|
|
161
|
-
aria-orientation="horizontal"
|
|
162
|
-
data-slot="item-separator"
|
|
163
|
-
className={cn('my-2 h-px w-full shrink-0 bg-border', className)}
|
|
164
|
-
{...props}
|
|
165
|
-
/>
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export {
|
|
170
|
-
ShadcnItem as Root,
|
|
171
|
-
ItemGroup as Group,
|
|
172
|
-
ItemHeader as Header,
|
|
173
|
-
ItemFooter as Footer,
|
|
174
|
-
ItemContent as Content,
|
|
175
|
-
ItemTitle as Title,
|
|
176
|
-
ItemDescription as Description,
|
|
177
|
-
ItemActions as Actions,
|
|
178
|
-
ItemMedia as Media,
|
|
179
|
-
ItemSeparator as Separator
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export default ShadcnItem;
|
|
@@ -1,46 +0,0 @@
|
|
|
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 ShadcnKbd;
|
|
@@ -1,19 +0,0 @@
|
|
|
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 ShadcnLabel;
|