@surreal-ui/react 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,213 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cn } from '@surreal-ui/core';
|
|
3
|
-
|
|
4
|
-
export interface ShadcnSliderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
value?: number[];
|
|
6
|
-
defaultValue?: number[];
|
|
7
|
-
min?: number;
|
|
8
|
-
max?: number;
|
|
9
|
-
step?: number;
|
|
10
|
-
orientation?: 'horizontal' | 'vertical';
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
onValueChange?: (val: number[]) => void;
|
|
13
|
-
onValueCommit?: (val: number[]) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const ShadcnSlider = React.forwardRef<HTMLDivElement, SliderProps>(
|
|
17
|
-
(
|
|
18
|
-
{
|
|
19
|
-
className,
|
|
20
|
-
value: controlledValue,
|
|
21
|
-
defaultValue = [0],
|
|
22
|
-
min = 0,
|
|
23
|
-
max = 100,
|
|
24
|
-
step = 1,
|
|
25
|
-
orientation = 'horizontal',
|
|
26
|
-
disabled = false,
|
|
27
|
-
onValueChange,
|
|
28
|
-
onValueCommit,
|
|
29
|
-
...props
|
|
30
|
-
},
|
|
31
|
-
ref
|
|
32
|
-
) => {
|
|
33
|
-
const [internalValues, setInternalValues] = React.useState<number[]>(
|
|
34
|
-
controlledValue ?? defaultValue
|
|
35
|
-
);
|
|
36
|
-
const [activeIndex, setActiveIndex] = React.useState<number | null>(null);
|
|
37
|
-
const trackRef = React.useRef<HTMLSpanElement | null>(null);
|
|
38
|
-
|
|
39
|
-
React.useEffect(() => {
|
|
40
|
-
if (controlledValue !== undefined) {
|
|
41
|
-
setInternalValues(controlledValue);
|
|
42
|
-
}
|
|
43
|
-
}, [controlledValue]);
|
|
44
|
-
|
|
45
|
-
const getPercentage = React.useCallback(
|
|
46
|
-
(val: number) => {
|
|
47
|
-
return Math.max(0, Math.min(100, ((val - min) / (max - min)) * 100));
|
|
48
|
-
},
|
|
49
|
-
[min, max]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const getValueFromPointer = React.useCallback(
|
|
53
|
-
(e: React.PointerEvent) => {
|
|
54
|
-
if (!trackRef.current) return min;
|
|
55
|
-
const rect = trackRef.current.getBoundingClientRect();
|
|
56
|
-
let percent = 0;
|
|
57
|
-
if (orientation === 'horizontal') {
|
|
58
|
-
percent = (e.clientX - rect.left) / rect.width;
|
|
59
|
-
} else {
|
|
60
|
-
percent = (rect.bottom - e.clientY) / rect.height;
|
|
61
|
-
}
|
|
62
|
-
percent = Math.max(0, Math.min(1, percent));
|
|
63
|
-
const rawVal = min + percent * (max - min);
|
|
64
|
-
const steppedVal = Math.round(rawVal / step) * step;
|
|
65
|
-
return Math.max(min, Math.min(max, steppedVal));
|
|
66
|
-
},
|
|
67
|
-
[min, max, step, orientation]
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const updateValue = React.useCallback(
|
|
71
|
-
(index: number, newVal: number) => {
|
|
72
|
-
setInternalValues((prev) => {
|
|
73
|
-
const next = [...prev];
|
|
74
|
-
next[index] = newVal;
|
|
75
|
-
if (next.length === 2) {
|
|
76
|
-
if (index === 0 && next[0] > next[1]) next[0] = next[1];
|
|
77
|
-
if (index === 1 && next[1] < next[0]) next[1] = next[0];
|
|
78
|
-
}
|
|
79
|
-
if (onValueChange) onValueChange(next);
|
|
80
|
-
return next;
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
[onValueChange]
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
const handlePointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
87
|
-
if (disabled) return;
|
|
88
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
89
|
-
const pointerVal = getValueFromPointer(e);
|
|
90
|
-
let closestIdx = 0;
|
|
91
|
-
let minDiff = Infinity;
|
|
92
|
-
internalValues.forEach((val, idx) => {
|
|
93
|
-
const diff = Math.abs(val - pointerVal);
|
|
94
|
-
if (diff < minDiff) {
|
|
95
|
-
minDiff = diff;
|
|
96
|
-
closestIdx = idx;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
setActiveIndex(closestIdx);
|
|
100
|
-
updateValue(closestIdx, pointerVal);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const handlePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
104
|
-
if (disabled || activeIndex === null) return;
|
|
105
|
-
const pointerVal = getValueFromPointer(e);
|
|
106
|
-
updateValue(activeIndex, pointerVal);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const handlePointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
|
|
110
|
-
if (disabled || activeIndex === null) return;
|
|
111
|
-
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
112
|
-
setActiveIndex(null);
|
|
113
|
-
if (onValueCommit) onValueCommit(internalValues);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const handleKeyDown = (e: React.KeyboardEvent, index: number) => {
|
|
117
|
-
if (disabled) return;
|
|
118
|
-
let delta = 0;
|
|
119
|
-
if (e.key === 'ArrowRight' || e.key === 'ArrowUp') delta = step;
|
|
120
|
-
else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') delta = -step;
|
|
121
|
-
else if (e.key === 'PageUp') delta = step * 10;
|
|
122
|
-
else if (e.key === 'PageDown') delta = -step * 10;
|
|
123
|
-
else if (e.key === 'Home') delta = min - internalValues[index];
|
|
124
|
-
else if (e.key === 'End') delta = max - internalValues[index];
|
|
125
|
-
else return;
|
|
126
|
-
|
|
127
|
-
e.preventDefault();
|
|
128
|
-
const newVal = Math.max(min, Math.min(max, internalValues[index] + delta));
|
|
129
|
-
updateValue(index, newVal);
|
|
130
|
-
if (onValueCommit) onValueCommit(internalValues);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const rangeStyle = React.useMemo(() => {
|
|
134
|
-
if (internalValues.length === 1) {
|
|
135
|
-
const pct = getPercentage(internalValues[0]);
|
|
136
|
-
return orientation === 'horizontal'
|
|
137
|
-
? { left: '0%', width: `${pct}%` }
|
|
138
|
-
: { bottom: '0%', height: `${pct}%` };
|
|
139
|
-
} else {
|
|
140
|
-
const p1 = getPercentage(internalValues[0]);
|
|
141
|
-
const p2 = getPercentage(internalValues[1]);
|
|
142
|
-
const left = Math.min(p1, p2);
|
|
143
|
-
const size = Math.abs(p2 - p1);
|
|
144
|
-
return orientation === 'horizontal'
|
|
145
|
-
? { left: `${left}%`, width: `${size}%` }
|
|
146
|
-
: { bottom: `${left}%`, height: `${size}%` };
|
|
147
|
-
}
|
|
148
|
-
}, [internalValues, getPercentage, orientation]);
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<div
|
|
152
|
-
ref={ref}
|
|
153
|
-
role="group"
|
|
154
|
-
data-slot="slider"
|
|
155
|
-
data-orientation={orientation}
|
|
156
|
-
data-disabled={disabled ? '' : undefined}
|
|
157
|
-
className={cn(
|
|
158
|
-
'relative flex w-full touch-none select-none items-center',
|
|
159
|
-
orientation === 'vertical' ? 'h-full min-h-40 w-auto flex-col' : 'h-auto w-full flex-row',
|
|
160
|
-
disabled && 'opacity-50 pointer-events-none',
|
|
161
|
-
className
|
|
162
|
-
)}
|
|
163
|
-
onPointerDown={handlePointerDown}
|
|
164
|
-
onPointerMove={handlePointerMove}
|
|
165
|
-
onPointerUp={handlePointerUp}
|
|
166
|
-
{...props}
|
|
167
|
-
>
|
|
168
|
-
<span
|
|
169
|
-
ref={trackRef}
|
|
170
|
-
data-slot="slider-track"
|
|
171
|
-
data-orientation={orientation}
|
|
172
|
-
className={cn(
|
|
173
|
-
'relative grow overflow-hidden rounded-full bg-muted',
|
|
174
|
-
orientation === 'horizontal' ? 'h-1.5 w-full' : 'h-full w-1.5'
|
|
175
|
-
)}
|
|
176
|
-
>
|
|
177
|
-
<span
|
|
178
|
-
data-slot="slider-range"
|
|
179
|
-
data-orientation={orientation}
|
|
180
|
-
className="absolute bg-primary"
|
|
181
|
-
style={rangeStyle}
|
|
182
|
-
/>
|
|
183
|
-
</span>
|
|
184
|
-
{internalValues.map((val, idx) => {
|
|
185
|
-
const pct = getPercentage(val);
|
|
186
|
-
return (
|
|
187
|
-
<span
|
|
188
|
-
key={idx}
|
|
189
|
-
role="slider"
|
|
190
|
-
tabIndex={disabled ? -1 : 0}
|
|
191
|
-
aria-valuemin={min}
|
|
192
|
-
aria-valuemax={max}
|
|
193
|
-
aria-valuenow={val}
|
|
194
|
-
aria-orientation={orientation}
|
|
195
|
-
aria-disabled={disabled}
|
|
196
|
-
data-slot="slider-thumb"
|
|
197
|
-
className="absolute block size-4 shrink-0 rounded-full border border-primary bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
|
|
198
|
-
style={
|
|
199
|
-
orientation === 'horizontal'
|
|
200
|
-
? { left: `calc(${pct}% - 8px)`, top: '50%', transform: 'translateY(-50%)' }
|
|
201
|
-
: { bottom: `calc(${pct}% - 8px)`, left: '50%', transform: 'translateX(-50%)' }
|
|
202
|
-
}
|
|
203
|
-
onKeyDown={(e) => handleKeyDown(e, idx)}
|
|
204
|
-
/>
|
|
205
|
-
);
|
|
206
|
-
})}
|
|
207
|
-
</div>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
Slider.displayName = 'Slider';
|
|
212
|
-
|
|
213
|
-
export default MinimalistSlider;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Toaster as Sonner, type ToasterProps } from 'sonner';
|
|
3
|
-
import { Loader2, CircleCheck, OctagonX, Info, TriangleAlert } from 'lucide-react';
|
|
4
|
-
|
|
5
|
-
export interface ToasterComponentProps extends ToasterProps {}
|
|
6
|
-
|
|
7
|
-
export function Toaster({ ...props }: ToasterComponentProps) {
|
|
8
|
-
return (
|
|
9
|
-
<Sonner
|
|
10
|
-
className="toaster group"
|
|
11
|
-
style={
|
|
12
|
-
{
|
|
13
|
-
'--normal-bg': 'var(--color-popover)',
|
|
14
|
-
'--normal-text': 'var(--color-popover-foreground)',
|
|
15
|
-
'--normal-border': 'var(--color-border)'
|
|
16
|
-
} as React.CSSProperties
|
|
17
|
-
}
|
|
18
|
-
icons={{
|
|
19
|
-
loading: <Loader2 className="size-4 animate-spin" />,
|
|
20
|
-
success: <CircleCheck className="size-4" />,
|
|
21
|
-
error: <OctagonX className="size-4" />,
|
|
22
|
-
info: <Info className="size-4" />,
|
|
23
|
-
warning: <TriangleAlert className="size-4" />
|
|
24
|
-
}}
|
|
25
|
-
toastOptions={{
|
|
26
|
-
classNames: {
|
|
27
|
-
toast:
|
|
28
|
-
'group toast group-[.toaster]:bg-popover group-[.toaster]:text-popover-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
|
|
29
|
-
description: 'group-[.toast]:text-muted-foreground',
|
|
30
|
-
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
|
|
31
|
-
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground'
|
|
32
|
-
}
|
|
33
|
-
}}
|
|
34
|
-
{...props}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { toast } from 'sonner';
|
|
40
|
-
|
|
41
|
-
export default MinimalistSonner;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Loader2, type LucideProps } from 'lucide-react';
|
|
4
|
-
import { cn } from '@surreal-ui/core';
|
|
5
|
-
|
|
6
|
-
export interface ShadcnSpinnerProps extends LucideProps {
|
|
7
|
-
className?: string;
|
|
8
|
-
role?: string;
|
|
9
|
-
'aria-label'?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ShadcnSpinner = React.forwardRef<SVGSVGElement, SpinnerProps>(
|
|
13
|
-
(
|
|
14
|
-
{
|
|
15
|
-
className,
|
|
16
|
-
role = 'status',
|
|
17
|
-
'aria-label': ariaLabel = 'Loading',
|
|
18
|
-
color,
|
|
19
|
-
strokeWidth,
|
|
20
|
-
...props
|
|
21
|
-
},
|
|
22
|
-
ref
|
|
23
|
-
) => {
|
|
24
|
-
return (
|
|
25
|
-
<Loader2
|
|
26
|
-
ref={ref}
|
|
27
|
-
role={role}
|
|
28
|
-
aria-label={ariaLabel}
|
|
29
|
-
color={color === null ? undefined : color}
|
|
30
|
-
strokeWidth={strokeWidth === null ? undefined : strokeWidth}
|
|
31
|
-
className={cn('size-4 animate-spin', className)}
|
|
32
|
-
{...props}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
Spinner.displayName = 'Spinner';
|
|
39
|
-
export default MinimalistSpinner;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cn } from '@surreal-ui/core';
|
|
3
|
-
|
|
4
|
-
export interface ShadcnSwitchProps extends Omit<
|
|
5
|
-
React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
6
|
-
'onChange'
|
|
7
|
-
> {
|
|
8
|
-
checked?: boolean;
|
|
9
|
-
defaultChecked?: boolean;
|
|
10
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
11
|
-
size?: 'sm' | 'default';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const ShadcnSwitch = React.forwardRef<HTMLButtonElement, SwitchProps>(
|
|
15
|
-
(
|
|
16
|
-
{
|
|
17
|
-
className,
|
|
18
|
-
checked: controlledChecked,
|
|
19
|
-
defaultChecked = false,
|
|
20
|
-
onCheckedChange,
|
|
21
|
-
disabled = false,
|
|
22
|
-
size = 'default',
|
|
23
|
-
onClick,
|
|
24
|
-
onKeyDown,
|
|
25
|
-
...props
|
|
26
|
-
},
|
|
27
|
-
ref
|
|
28
|
-
) => {
|
|
29
|
-
const [uncontrolledChecked, setUncontrolledChecked] = React.useState(defaultChecked);
|
|
30
|
-
const isControlled = controlledChecked !== undefined;
|
|
31
|
-
const isChecked = isControlled ? controlledChecked : uncontrolledChecked;
|
|
32
|
-
|
|
33
|
-
const toggle = (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
34
|
-
if (disabled) return;
|
|
35
|
-
const next = !isChecked;
|
|
36
|
-
if (!isControlled) {
|
|
37
|
-
setUncontrolledChecked(next);
|
|
38
|
-
}
|
|
39
|
-
onCheckedChange?.(next);
|
|
40
|
-
onClick?.(e);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const handleKeyDown = (e: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
44
|
-
if (e.key === ' ' || e.key === 'Enter') {
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
if (!disabled) {
|
|
47
|
-
const next = !isChecked;
|
|
48
|
-
if (!isControlled) {
|
|
49
|
-
setUncontrolledChecked(next);
|
|
50
|
-
}
|
|
51
|
-
onCheckedChange?.(next);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
onKeyDown?.(e);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<button
|
|
59
|
-
type="button"
|
|
60
|
-
role="switch"
|
|
61
|
-
aria-checked={isChecked}
|
|
62
|
-
aria-disabled={disabled}
|
|
63
|
-
disabled={disabled}
|
|
64
|
-
ref={ref}
|
|
65
|
-
data-slot="switch"
|
|
66
|
-
data-state={isChecked ? 'checked' : 'unchecked'}
|
|
67
|
-
data-size={size}
|
|
68
|
-
onClick={toggle}
|
|
69
|
-
onKeyDown={handleKeyDown}
|
|
70
|
-
className={cn(
|
|
71
|
-
'peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-colors outline-none cursor-pointer select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80',
|
|
72
|
-
className
|
|
73
|
-
)}
|
|
74
|
-
{...props}
|
|
75
|
-
>
|
|
76
|
-
<span
|
|
77
|
-
data-slot="switch-thumb"
|
|
78
|
-
data-state={isChecked ? 'checked' : 'unchecked'}
|
|
79
|
-
className={cn(
|
|
80
|
-
'pointer-events-none block rounded-full bg-background ring-0 transition-transform dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground',
|
|
81
|
-
size === 'sm'
|
|
82
|
-
? 'size-3 data-[state=checked]:translate-x-[10px] data-[state=unchecked]:translate-x-0'
|
|
83
|
-
: 'size-4 data-[state=checked]:translate-x-[14px] data-[state=unchecked]:translate-x-0'
|
|
84
|
-
)}
|
|
85
|
-
/>
|
|
86
|
-
</button>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
Switch.displayName = 'Switch';
|
|
92
|
-
export default MinimalistSwitch;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface PropItem {
|
|
3
|
-
name: string;
|
|
4
|
-
type: string;
|
|
5
|
-
default?: string;
|
|
6
|
-
description: string;
|
|
7
|
-
}
|
|
8
|
-
interface DocProps {
|
|
9
|
-
usage?: string;
|
|
10
|
-
props?: Array<PropItem>;
|
|
11
|
-
}
|
|
12
|
-
interface ComponentProps {
|
|
13
|
-
title: string;
|
|
14
|
-
docs?: DocProps;
|
|
15
|
-
}
|
|
16
|
-
export const TableDocsComponent: React.FC<ComponentProps> = ({ title, docs }) => {
|
|
17
|
-
const usageCode = (docs?.usage || "import Component from '@surreal-ui/react';").trim();
|
|
18
|
-
return (
|
|
19
|
-
<div className="space-y-6">
|
|
20
|
-
<div>
|
|
21
|
-
<h3 className="text-sm font-semibold text-slate-300 uppercase tracking-wider mb-2">
|
|
22
|
-
Usage Example
|
|
23
|
-
</h3>
|
|
24
|
-
<pre className="p-4 rounded-xl bg-slate-950 border border-slate-800 text-xs font-mono text-indigo-200 leading-relaxed overflow-x-auto">
|
|
25
|
-
<code>{usageCode}</code>
|
|
26
|
-
</pre>
|
|
27
|
-
</div>
|
|
28
|
-
<div>
|
|
29
|
-
<h3 className="text-sm font-semibold text-slate-300 uppercase tracking-wider mb-3">
|
|
30
|
-
Props & Component Interface
|
|
31
|
-
</h3>
|
|
32
|
-
{docs?.props && docs.props.length > 0 ? (
|
|
33
|
-
<div className="border border-slate-800 rounded-xl overflow-hidden text-xs">
|
|
34
|
-
<table className="w-full text-left">
|
|
35
|
-
<thead className="bg-slate-950 border-b border-slate-800 text-slate-400">
|
|
36
|
-
<tr>
|
|
37
|
-
<th className="p-3 font-semibold">Name</th>
|
|
38
|
-
<th className="p-3 font-semibold">Type</th>
|
|
39
|
-
<th className="p-3 font-semibold">Default</th>
|
|
40
|
-
<th className="p-3 font-semibold">Description</th>
|
|
41
|
-
</tr>
|
|
42
|
-
</thead>
|
|
43
|
-
<tbody className="divide-y divide-slate-800 text-slate-300">
|
|
44
|
-
{docs.props.map((prop, index) => (
|
|
45
|
-
<tr key={index}>
|
|
46
|
-
<td className="p-3 font-mono font-bold text-indigo-300">{prop.name}</td>
|
|
47
|
-
<td className="p-3 font-mono text-slate-400">{prop.type}</td>
|
|
48
|
-
<td className="p-3 font-mono text-slate-500">{prop.default || '-'}</td>
|
|
49
|
-
<td className="p-3">{prop.description}</td>
|
|
50
|
-
</tr>
|
|
51
|
-
))}
|
|
52
|
-
</tbody>
|
|
53
|
-
</table>
|
|
54
|
-
</div>
|
|
55
|
-
) : (
|
|
56
|
-
<p className="text-xs text-slate-500">
|
|
57
|
-
No prop documentation specified for this package.
|
|
58
|
-
</p>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default MinimalistTable;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cn, cva, type VariantProps } from '@surreal-ui/core';
|
|
3
|
-
|
|
4
|
-
export const tabsListVariants = cva(
|
|
5
|
-
'rounded-lg p-[3px] group-data-horizontal/tabs:h-8 data-[variant=line]:rounded-none group/tabs-list inline-flex w-fit items-center justify-center text-muted-foreground group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col',
|
|
6
|
-
{
|
|
7
|
-
variants: {
|
|
8
|
-
variant: {
|
|
9
|
-
default: 'cn-tabs-list-variant-default bg-muted',
|
|
10
|
-
line: 'cn-tabs-list-variant-line gap-1 bg-transparent'
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
defaultVariants: {
|
|
14
|
-
variant: 'default'
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export type TabsListVariant = VariantProps<typeof tabsListVariants>['variant'];
|
|
20
|
-
|
|
21
|
-
interface TabsContextValue {
|
|
22
|
-
value: string;
|
|
23
|
-
setValue: (value: string) => void;
|
|
24
|
-
orientation: 'horizontal' | 'vertical';
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const TabsContext = React.createContext<TabsContextValue | null>(null);
|
|
28
|
-
|
|
29
|
-
function useTabs() {
|
|
30
|
-
const context = React.useContext(TabsContext);
|
|
31
|
-
if (!context) {
|
|
32
|
-
throw new Error('Tabs compound components must be rendered inside <Tabs>');
|
|
33
|
-
}
|
|
34
|
-
return context;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ShadcnTabsProps extends React.ComponentProps<'div'> {
|
|
38
|
-
value?: string;
|
|
39
|
-
defaultValue?: string;
|
|
40
|
-
onValueChange?: (value: string) => void;
|
|
41
|
-
orientation?: 'horizontal' | 'vertical';
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function ShadcnTabs({
|
|
45
|
-
value: controlledValue,
|
|
46
|
-
defaultValue = '',
|
|
47
|
-
onValueChange,
|
|
48
|
-
orientation = 'horizontal',
|
|
49
|
-
className,
|
|
50
|
-
children,
|
|
51
|
-
...props
|
|
52
|
-
}: TabsProps) {
|
|
53
|
-
const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
|
|
54
|
-
const isControlled = controlledValue !== undefined;
|
|
55
|
-
const currentValue = isControlled ? controlledValue : uncontrolledValue;
|
|
56
|
-
|
|
57
|
-
const setValue = React.useCallback(
|
|
58
|
-
(val: string) => {
|
|
59
|
-
if (!isControlled) {
|
|
60
|
-
setUncontrolledValue(val);
|
|
61
|
-
}
|
|
62
|
-
onValueChange?.(val);
|
|
63
|
-
},
|
|
64
|
-
[isControlled, onValueChange]
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<TabsContext.Provider value={{ value: currentValue, setValue, orientation }}>
|
|
69
|
-
<div
|
|
70
|
-
data-slot="tabs"
|
|
71
|
-
data-orientation={orientation}
|
|
72
|
-
className={cn('gap-2 group/tabs flex data-[orientation=horizontal]:flex-col', className)}
|
|
73
|
-
{...props}
|
|
74
|
-
>
|
|
75
|
-
{children}
|
|
76
|
-
</div>
|
|
77
|
-
</TabsContext.Provider>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface ShadcnTabsListProps
|
|
82
|
-
extends React.ComponentProps<'div'>, VariantProps<typeof tabsListVariants> {}
|
|
83
|
-
|
|
84
|
-
export function ShadcnTabsList({
|
|
85
|
-
className,
|
|
86
|
-
variant = 'default',
|
|
87
|
-
children,
|
|
88
|
-
...props
|
|
89
|
-
}: TabsListProps) {
|
|
90
|
-
return (
|
|
91
|
-
<div
|
|
92
|
-
data-slot="tabs-list"
|
|
93
|
-
data-variant={variant}
|
|
94
|
-
className={cn(tabsListVariants({ variant }), className)}
|
|
95
|
-
{...props}
|
|
96
|
-
>
|
|
97
|
-
{children}
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface ShadcnTabsTriggerProps extends React.ComponentProps<'button'> {
|
|
103
|
-
value: string;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function ShadcnTabsTrigger({
|
|
107
|
-
className,
|
|
108
|
-
value: triggerValue,
|
|
109
|
-
disabled,
|
|
110
|
-
children,
|
|
111
|
-
...props
|
|
112
|
-
}: TabsTriggerProps) {
|
|
113
|
-
const { value, setValue } = useTabs();
|
|
114
|
-
const isActive = value === triggerValue;
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<button
|
|
118
|
-
type="button"
|
|
119
|
-
role="tab"
|
|
120
|
-
aria-selected={isActive}
|
|
121
|
-
data-slot="tabs-trigger"
|
|
122
|
-
data-state={isActive ? 'active' : 'inactive'}
|
|
123
|
-
disabled={disabled}
|
|
124
|
-
tabIndex={isActive ? 0 : -1}
|
|
125
|
-
onClick={() => setValue(triggerValue)}
|
|
126
|
-
className={cn(
|
|
127
|
-
"gap-1.5 rounded-md border border-transparent px-2.5 py-1 text-xs font-medium has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg:not([class*='size-'])]:size-3.5 relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap text-muted-foreground transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
128
|
-
'group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent',
|
|
129
|
-
'data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-xs dark:data-[state=active]:border-border/50 dark:data-[state=active]:bg-background dark:data-[state=active]:text-foreground',
|
|
130
|
-
'after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100',
|
|
131
|
-
className
|
|
132
|
-
)}
|
|
133
|
-
{...props}
|
|
134
|
-
>
|
|
135
|
-
{children}
|
|
136
|
-
</button>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export interface ShadcnTabsContentProps extends React.ComponentProps<'div'> {
|
|
141
|
-
value: string;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export function ShadcnTabsContent({
|
|
145
|
-
className,
|
|
146
|
-
value: contentValue,
|
|
147
|
-
children,
|
|
148
|
-
...props
|
|
149
|
-
}: TabsContentProps) {
|
|
150
|
-
const { value } = useTabs();
|
|
151
|
-
const isActive = value === contentValue;
|
|
152
|
-
|
|
153
|
-
if (!isActive) return null;
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<div
|
|
157
|
-
role="tabpanel"
|
|
158
|
-
tabIndex={0}
|
|
159
|
-
data-slot="tabs-content"
|
|
160
|
-
data-state={isActive ? 'active' : 'inactive'}
|
|
161
|
-
className={cn('text-sm flex-1 outline-none', className)}
|
|
162
|
-
{...props}
|
|
163
|
-
>
|
|
164
|
-
{children}
|
|
165
|
-
</div>
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export { ShadcnTabs as Root, TabsContent as Content, TabsList as List, TabsTrigger as Trigger };
|
|
170
|
-
|
|
171
|
-
export default MinimalistTabs;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { cn } from '@surreal-ui/core';
|
|
3
|
-
|
|
4
|
-
export interface ShadcnTextareaProps extends React.ComponentProps<'textarea'> {}
|
|
5
|
-
|
|
6
|
-
export const ShadcnTextarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
7
|
-
({ className, 'data-slot': dataSlot = 'textarea', ...props }, ref) => {
|
|
8
|
-
return (
|
|
9
|
-
<textarea
|
|
10
|
-
ref={ref}
|
|
11
|
-
data-slot={dataSlot}
|
|
12
|
-
className={cn(
|
|
13
|
-
'rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors 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 flex field-sizing-content min-h-16 w-full outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50',
|
|
14
|
-
className
|
|
15
|
-
)}
|
|
16
|
-
{...props}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
Textarea.displayName = 'Textarea';
|
|
23
|
-
|
|
24
|
-
export default MinimalistTextarea;
|