@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,355 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ChevronLeft, ChevronRight, ChevronDown } from 'lucide-react';
|
|
3
|
-
import { cn } from '@surreal-ui/core';
|
|
4
|
-
|
|
5
|
-
export interface ShadcnCalendarProps extends Omit<
|
|
6
|
-
React.HTMLAttributes<HTMLDivElement>,
|
|
7
|
-
'onChange'
|
|
8
|
-
> {
|
|
9
|
-
value?: Date | string | null;
|
|
10
|
-
defaultValue?: Date | string | null;
|
|
11
|
-
locale?: string;
|
|
12
|
-
weekdayFormat?: 'short' | 'narrow' | 'long';
|
|
13
|
-
captionLayout?: 'label' | 'dropdown' | 'dropdown-months' | 'dropdown-years';
|
|
14
|
-
minDate?: Date;
|
|
15
|
-
maxDate?: Date;
|
|
16
|
-
disableDaysOutsideMonth?: boolean;
|
|
17
|
-
onChange?: (date: Date) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function ShadcnCalendar({
|
|
21
|
-
value: controlledValue,
|
|
22
|
-
defaultValue = null,
|
|
23
|
-
locale = 'en-US',
|
|
24
|
-
weekdayFormat = 'short',
|
|
25
|
-
captionLayout = 'label',
|
|
26
|
-
minDate,
|
|
27
|
-
maxDate,
|
|
28
|
-
disableDaysOutsideMonth = false,
|
|
29
|
-
onChange,
|
|
30
|
-
className,
|
|
31
|
-
...props
|
|
32
|
-
}: CalendarProps) {
|
|
33
|
-
const [internalDate, setInternalDate] = React.useState<Date | null>(() => {
|
|
34
|
-
if (controlledValue) return new Date(controlledValue);
|
|
35
|
-
if (defaultValue) return new Date(defaultValue);
|
|
36
|
-
return null;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const selectedDate =
|
|
40
|
-
controlledValue !== undefined
|
|
41
|
-
? controlledValue
|
|
42
|
-
? new Date(controlledValue)
|
|
43
|
-
: null
|
|
44
|
-
: internalDate;
|
|
45
|
-
|
|
46
|
-
const [currentMonth, setCurrentMonth] = React.useState<Date>(() => {
|
|
47
|
-
const initial = selectedDate || new Date();
|
|
48
|
-
return new Date(initial.getFullYear(), initial.getMonth(), 1);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
const monthNames = React.useMemo(
|
|
52
|
-
() => [
|
|
53
|
-
'January',
|
|
54
|
-
'February',
|
|
55
|
-
'March',
|
|
56
|
-
'April',
|
|
57
|
-
'May',
|
|
58
|
-
'June',
|
|
59
|
-
'July',
|
|
60
|
-
'August',
|
|
61
|
-
'September',
|
|
62
|
-
'October',
|
|
63
|
-
'November',
|
|
64
|
-
'December'
|
|
65
|
-
],
|
|
66
|
-
[]
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
const weekdays = React.useMemo(() => {
|
|
70
|
-
const days: string[] = [];
|
|
71
|
-
const temp = new Date(2023, 0, 1); // Sunday
|
|
72
|
-
for (let i = 0; i < 7; i++) {
|
|
73
|
-
days.push(new Intl.DateTimeFormat(locale, { weekday: weekdayFormat }).format(temp));
|
|
74
|
-
temp.setDate(temp.getDate() + 1);
|
|
75
|
-
}
|
|
76
|
-
return days;
|
|
77
|
-
}, [locale, weekdayFormat]);
|
|
78
|
-
|
|
79
|
-
const monthYearLabel = React.useMemo(() => {
|
|
80
|
-
const month = new Intl.DateTimeFormat(locale, { month: 'long' }).format(currentMonth);
|
|
81
|
-
const year = new Intl.DateTimeFormat(locale, { year: 'numeric' }).format(currentMonth);
|
|
82
|
-
return { month, year };
|
|
83
|
-
}, [locale, currentMonth]);
|
|
84
|
-
|
|
85
|
-
const yearList = React.useMemo(() => {
|
|
86
|
-
const startYear = currentMonth.getFullYear() - 10;
|
|
87
|
-
return Array.from({ length: 21 }, (_, i) => startYear + i);
|
|
88
|
-
}, [currentMonth]);
|
|
89
|
-
|
|
90
|
-
const calendarGrid = React.useMemo(() => {
|
|
91
|
-
const year = currentMonth.getFullYear();
|
|
92
|
-
const month = currentMonth.getMonth();
|
|
93
|
-
const firstDay = new Date(year, month, 1);
|
|
94
|
-
const lastDay = new Date(year, month + 1, 0);
|
|
95
|
-
|
|
96
|
-
const startOffset = firstDay.getDay();
|
|
97
|
-
const daysInMonth = lastDay.getDate();
|
|
98
|
-
const prevMonthLastDay = new Date(year, month, 0).getDate();
|
|
99
|
-
|
|
100
|
-
const today = new Date();
|
|
101
|
-
today.setHours(0, 0, 0, 0);
|
|
102
|
-
|
|
103
|
-
const weeks: Array<
|
|
104
|
-
Array<{
|
|
105
|
-
date: Date;
|
|
106
|
-
isCurrentMonth: boolean;
|
|
107
|
-
isToday: boolean;
|
|
108
|
-
isSelected: boolean;
|
|
109
|
-
isDisabled: boolean;
|
|
110
|
-
}>
|
|
111
|
-
> = [];
|
|
112
|
-
let currentWeek: Array<{
|
|
113
|
-
date: Date;
|
|
114
|
-
isCurrentMonth: boolean;
|
|
115
|
-
isToday: boolean;
|
|
116
|
-
isSelected: boolean;
|
|
117
|
-
isDisabled: boolean;
|
|
118
|
-
}> = [];
|
|
119
|
-
|
|
120
|
-
for (let i = startOffset - 1; i >= 0; i--) {
|
|
121
|
-
const d = new Date(year, month - 1, prevMonthLastDay - i);
|
|
122
|
-
d.setHours(0, 0, 0, 0);
|
|
123
|
-
currentWeek.push({
|
|
124
|
-
date: d,
|
|
125
|
-
isCurrentMonth: false,
|
|
126
|
-
isToday: d.getTime() === today.getTime(),
|
|
127
|
-
isSelected:
|
|
128
|
-
!!selectedDate &&
|
|
129
|
-
d.getFullYear() === selectedDate.getFullYear() &&
|
|
130
|
-
d.getMonth() === selectedDate.getMonth() &&
|
|
131
|
-
d.getDate() === selectedDate.getDate(),
|
|
132
|
-
isDisabled:
|
|
133
|
-
disableDaysOutsideMonth || (!!minDate && d < minDate) || (!!maxDate && d > maxDate)
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
for (let day = 1; day <= daysInMonth; day++) {
|
|
138
|
-
const d = new Date(year, month, day);
|
|
139
|
-
d.setHours(0, 0, 0, 0);
|
|
140
|
-
const isSelected =
|
|
141
|
-
!!selectedDate &&
|
|
142
|
-
d.getFullYear() === selectedDate.getFullYear() &&
|
|
143
|
-
d.getMonth() === selectedDate.getMonth() &&
|
|
144
|
-
d.getDate() === selectedDate.getDate();
|
|
145
|
-
currentWeek.push({
|
|
146
|
-
date: d,
|
|
147
|
-
isCurrentMonth: true,
|
|
148
|
-
isToday: d.getTime() === today.getTime(),
|
|
149
|
-
isSelected,
|
|
150
|
-
isDisabled: (!!minDate && d < minDate) || (!!maxDate && d > maxDate)
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
if (currentWeek.length === 7) {
|
|
154
|
-
weeks.push(currentWeek);
|
|
155
|
-
currentWeek = [];
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (currentWeek.length > 0) {
|
|
160
|
-
let nextDay = 1;
|
|
161
|
-
while (currentWeek.length < 7) {
|
|
162
|
-
const d = new Date(year, month + 1, nextDay);
|
|
163
|
-
d.setHours(0, 0, 0, 0);
|
|
164
|
-
currentWeek.push({
|
|
165
|
-
date: d,
|
|
166
|
-
isCurrentMonth: false,
|
|
167
|
-
isToday: d.getTime() === today.getTime(),
|
|
168
|
-
isSelected:
|
|
169
|
-
!!selectedDate &&
|
|
170
|
-
d.getFullYear() === selectedDate.getFullYear() &&
|
|
171
|
-
d.getMonth() === selectedDate.getMonth() &&
|
|
172
|
-
d.getDate() === selectedDate.getDate(),
|
|
173
|
-
isDisabled:
|
|
174
|
-
disableDaysOutsideMonth || (!!minDate && d < minDate) || (!!maxDate && d > maxDate)
|
|
175
|
-
});
|
|
176
|
-
nextDay++;
|
|
177
|
-
}
|
|
178
|
-
weeks.push(currentWeek);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return weeks;
|
|
182
|
-
}, [currentMonth, selectedDate, disableDaysOutsideMonth, minDate, maxDate]);
|
|
183
|
-
|
|
184
|
-
const handleSelect = (date: Date, disabled: boolean) => {
|
|
185
|
-
if (disabled) return;
|
|
186
|
-
if (controlledValue === undefined) {
|
|
187
|
-
setInternalDate(date);
|
|
188
|
-
}
|
|
189
|
-
onChange?.(date);
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
return (
|
|
193
|
-
<div
|
|
194
|
-
data-slot="calendar"
|
|
195
|
-
className={cn(
|
|
196
|
-
'p-3 rounded-lg border border-border bg-background text-foreground shadow-sm inline-block select-none',
|
|
197
|
-
className
|
|
198
|
-
)}
|
|
199
|
-
{...props}
|
|
200
|
-
>
|
|
201
|
-
<div className="flex flex-col gap-4">
|
|
202
|
-
<div className="relative flex items-center justify-between pt-1">
|
|
203
|
-
<div className="flex items-center gap-1.5 text-sm font-semibold pl-1">
|
|
204
|
-
{captionLayout === 'dropdown' || captionLayout === 'dropdown-months' ? (
|
|
205
|
-
<div className="relative flex items-center">
|
|
206
|
-
<select
|
|
207
|
-
aria-label="Select month"
|
|
208
|
-
value={currentMonth.getMonth()}
|
|
209
|
-
onChange={(e) => {
|
|
210
|
-
const m = parseInt(e.target.value, 10);
|
|
211
|
-
setCurrentMonth(new Date(currentMonth.getFullYear(), m, 1));
|
|
212
|
-
}}
|
|
213
|
-
className="appearance-none bg-transparent hover:bg-accent hover:text-accent-foreground text-sm font-medium py-1 ps-2 pe-6 rounded-md border border-input cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring"
|
|
214
|
-
>
|
|
215
|
-
{monthNames.map((name, idx) => (
|
|
216
|
-
<option key={name} value={idx}>
|
|
217
|
-
{name}
|
|
218
|
-
</option>
|
|
219
|
-
))}
|
|
220
|
-
</select>
|
|
221
|
-
<ChevronDown className="pointer-events-none absolute right-1.5 size-3.5 text-muted-foreground" />
|
|
222
|
-
</div>
|
|
223
|
-
) : (
|
|
224
|
-
<span>{monthYearLabel.month}</span>
|
|
225
|
-
)}
|
|
226
|
-
|
|
227
|
-
{captionLayout === 'dropdown' || captionLayout === 'dropdown-years' ? (
|
|
228
|
-
<div className="relative flex items-center">
|
|
229
|
-
<select
|
|
230
|
-
aria-label="Select year"
|
|
231
|
-
value={currentMonth.getFullYear()}
|
|
232
|
-
onChange={(e) => {
|
|
233
|
-
const y = parseInt(e.target.value, 10);
|
|
234
|
-
setCurrentMonth(new Date(y, currentMonth.getMonth(), 1));
|
|
235
|
-
}}
|
|
236
|
-
className="appearance-none bg-transparent hover:bg-accent hover:text-accent-foreground text-sm font-medium py-1 ps-2 pe-6 rounded-md border border-input cursor-pointer focus:outline-none focus:ring-1 focus:ring-ring"
|
|
237
|
-
>
|
|
238
|
-
{yearList.map((y) => (
|
|
239
|
-
<option key={y} value={y}>
|
|
240
|
-
{y}
|
|
241
|
-
</option>
|
|
242
|
-
))}
|
|
243
|
-
</select>
|
|
244
|
-
<ChevronDown className="pointer-events-none absolute right-1.5 size-3.5 text-muted-foreground" />
|
|
245
|
-
</div>
|
|
246
|
-
) : (
|
|
247
|
-
<span>{monthYearLabel.year}</span>
|
|
248
|
-
)}
|
|
249
|
-
</div>
|
|
250
|
-
|
|
251
|
-
<div className="flex items-center gap-1">
|
|
252
|
-
<button
|
|
253
|
-
type="button"
|
|
254
|
-
onClick={() =>
|
|
255
|
-
setCurrentMonth(
|
|
256
|
-
new Date(currentMonth.getFullYear(), currentMonth.getMonth() - 1, 1)
|
|
257
|
-
)
|
|
258
|
-
}
|
|
259
|
-
aria-label="Previous Month"
|
|
260
|
-
className="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
261
|
-
>
|
|
262
|
-
<ChevronLeft className="size-4" />
|
|
263
|
-
</button>
|
|
264
|
-
<button
|
|
265
|
-
type="button"
|
|
266
|
-
onClick={() =>
|
|
267
|
-
setCurrentMonth(
|
|
268
|
-
new Date(currentMonth.getFullYear(), currentMonth.getMonth() + 1, 1)
|
|
269
|
-
)
|
|
270
|
-
}
|
|
271
|
-
aria-label="Next Month"
|
|
272
|
-
className="inline-flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
273
|
-
>
|
|
274
|
-
<ChevronRight className="size-4" />
|
|
275
|
-
</button>
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
|
|
279
|
-
<div className="w-full">
|
|
280
|
-
<div className="grid grid-cols-7 mb-1">
|
|
281
|
-
{weekdays.map((day, idx) => (
|
|
282
|
-
<div
|
|
283
|
-
key={idx}
|
|
284
|
-
className="size-8 flex items-center justify-center text-[0.8rem] font-medium text-muted-foreground"
|
|
285
|
-
>
|
|
286
|
-
{day.slice(0, 2)}
|
|
287
|
-
</div>
|
|
288
|
-
))}
|
|
289
|
-
</div>
|
|
290
|
-
|
|
291
|
-
<div className="grid grid-cols-7 gap-y-1">
|
|
292
|
-
{calendarGrid.flatMap((week, wIdx) =>
|
|
293
|
-
week.map((cell, cIdx) => (
|
|
294
|
-
<button
|
|
295
|
-
key={`${wIdx}-${cIdx}`}
|
|
296
|
-
type="button"
|
|
297
|
-
disabled={cell.isDisabled}
|
|
298
|
-
onClick={() => handleSelect(cell.date, cell.isDisabled)}
|
|
299
|
-
className={cn(
|
|
300
|
-
'size-8 flex items-center justify-center rounded-md text-sm font-normal transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
301
|
-
!cell.isCurrentMonth && 'text-muted-foreground opacity-40',
|
|
302
|
-
cell.isToday &&
|
|
303
|
-
!cell.isSelected &&
|
|
304
|
-
'bg-accent text-accent-foreground font-semibold',
|
|
305
|
-
cell.isSelected &&
|
|
306
|
-
'bg-primary text-primary-foreground font-medium hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',
|
|
307
|
-
!cell.isSelected &&
|
|
308
|
-
!cell.isDisabled &&
|
|
309
|
-
'hover:bg-accent hover:text-accent-foreground',
|
|
310
|
-
cell.isDisabled && 'pointer-events-none opacity-20'
|
|
311
|
-
)}
|
|
312
|
-
>
|
|
313
|
-
{cell.date.getDate()}
|
|
314
|
-
</button>
|
|
315
|
-
))
|
|
316
|
-
)}
|
|
317
|
-
</div>
|
|
318
|
-
</div>
|
|
319
|
-
</div>
|
|
320
|
-
</div>
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Subcomponent exports
|
|
325
|
-
export const ShadcnCalendarHeader = React.forwardRef<
|
|
326
|
-
HTMLDivElement,
|
|
327
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
328
|
-
>(({ className, ...props }, ref) => (
|
|
329
|
-
<div
|
|
330
|
-
ref={ref}
|
|
331
|
-
className={cn(
|
|
332
|
-
'flex h-7 w-full items-center justify-center gap-1.5 text-sm font-medium',
|
|
333
|
-
className
|
|
334
|
-
)}
|
|
335
|
-
{...props}
|
|
336
|
-
/>
|
|
337
|
-
));
|
|
338
|
-
CalendarHeader.displayName = 'CalendarHeader';
|
|
339
|
-
|
|
340
|
-
export const CalendarMonths = React.forwardRef<
|
|
341
|
-
HTMLDivElement,
|
|
342
|
-
React.HTMLAttributes<HTMLDivElement>
|
|
343
|
-
>(({ className, ...props }, ref) => (
|
|
344
|
-
<div ref={ref} className={cn('relative flex flex-col gap-4 md:flex-row', className)} {...props} />
|
|
345
|
-
));
|
|
346
|
-
CalendarMonths.displayName = 'CalendarMonths';
|
|
347
|
-
|
|
348
|
-
export const CalendarMonth = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
349
|
-
({ className, ...props }, ref) => (
|
|
350
|
-
<div ref={ref} className={cn('flex w-full flex-col gap-4', className)} {...props} />
|
|
351
|
-
)
|
|
352
|
-
);
|
|
353
|
-
CalendarMonth.displayName = 'CalendarMonth';
|
|
354
|
-
|
|
355
|
-
export default MinimalistCalendar;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { Eye, SunMoon } from 'lucide-react';
|
|
3
|
-
|
|
4
|
-
interface ModernCardProps {
|
|
5
|
-
title: string;
|
|
6
|
-
screenshot?: string;
|
|
7
|
-
themeSupport?: string;
|
|
8
|
-
bgTheme?: string;
|
|
9
|
-
onBgThemeChange?: (theme: string) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const ModernCard: React.FC<ModernCardProps> = ({
|
|
13
|
-
title,
|
|
14
|
-
screenshot = '',
|
|
15
|
-
themeSupport = 'light-and-dark',
|
|
16
|
-
bgTheme: externalBgTheme,
|
|
17
|
-
onBgThemeChange
|
|
18
|
-
}) => {
|
|
19
|
-
const [internalBgTheme, setInternalBgTheme] = useState('dark-grid');
|
|
20
|
-
const bgTheme = externalBgTheme !== undefined ? externalBgTheme : internalBgTheme;
|
|
21
|
-
const setBgTheme = (theme: string) => {
|
|
22
|
-
if (onBgThemeChange) onBgThemeChange(theme);
|
|
23
|
-
setInternalBgTheme(theme);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<section className="rounded-3xl border border-slate-800 overflow-hidden bg-slate-900/50 shadow-2xl space-y-0">
|
|
28
|
-
<div className="px-6 py-3 bg-slate-900/90 border-b border-slate-800 flex flex-wrap items-center justify-between gap-4">
|
|
29
|
-
<div className="flex items-center gap-2 text-xs font-medium text-slate-300">
|
|
30
|
-
<Eye className="w-4 h-4 text-indigo-400" />
|
|
31
|
-
<span>Actual Rendered Component Preview</span>
|
|
32
|
-
{themeSupport === 'light-and-dark' && (
|
|
33
|
-
<span className="inline-flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-300 border border-emerald-500/20">
|
|
34
|
-
<SunMoon className="w-3 h-3 text-emerald-400" /> Light & Dark Modes
|
|
35
|
-
</span>
|
|
36
|
-
)}
|
|
37
|
-
</div>
|
|
38
|
-
<div className="flex items-center gap-1.5 bg-slate-950 p-1 rounded-xl border border-slate-800/80 text-xs">
|
|
39
|
-
<button
|
|
40
|
-
onClick={() => setBgTheme('dark-grid')}
|
|
41
|
-
className={`px-2.5 py-1 rounded-lg transition-colors ${bgTheme === 'dark-grid' ? 'bg-indigo-600 text-white' : 'text-slate-400 hover:text-white'}`}
|
|
42
|
-
>
|
|
43
|
-
Dark Grid
|
|
44
|
-
</button>
|
|
45
|
-
<button
|
|
46
|
-
onClick={() => setBgTheme('glass-gradient')}
|
|
47
|
-
className={`px-2.5 py-1 rounded-lg transition-colors ${bgTheme === 'glass-gradient' ? 'bg-indigo-600 text-white' : 'text-slate-400 hover:text-white'}`}
|
|
48
|
-
>
|
|
49
|
-
Glass Gradient
|
|
50
|
-
</button>
|
|
51
|
-
<button
|
|
52
|
-
onClick={() => setBgTheme('light')}
|
|
53
|
-
className={`px-2.5 py-1 rounded-lg transition-colors ${bgTheme === 'light' ? 'bg-indigo-600 text-white' : 'text-slate-400 hover:text-white'}`}
|
|
54
|
-
>
|
|
55
|
-
Light Mode
|
|
56
|
-
</button>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
<div
|
|
60
|
-
className={`min-h-[280px] p-8 flex items-center justify-center transition-all ${
|
|
61
|
-
bgTheme === 'dark-grid'
|
|
62
|
-
? 'bg-slate-950 bg-grid-pattern'
|
|
63
|
-
: bgTheme === 'glass-gradient'
|
|
64
|
-
? 'bg-gradient-to-tr from-indigo-900 via-purple-900 to-slate-900'
|
|
65
|
-
: 'bg-slate-100 text-slate-900'
|
|
66
|
-
}`}
|
|
67
|
-
>
|
|
68
|
-
{screenshot ? (
|
|
69
|
-
<div className="max-w-lg w-full rounded-2xl overflow-hidden border border-slate-700/50 shadow-2xl bg-slate-900 p-2">
|
|
70
|
-
<img
|
|
71
|
-
src={screenshot}
|
|
72
|
-
alt={`Rendered preview of ${title}`}
|
|
73
|
-
className="w-full h-auto rounded-xl object-contain"
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
) : (
|
|
77
|
-
<div className="p-8 rounded-2xl bg-slate-900 border border-slate-800 text-center space-y-3 max-w-sm">
|
|
78
|
-
<h3 className="text-base font-bold text-white">{title}</h3>
|
|
79
|
-
<p className="text-xs text-slate-400">
|
|
80
|
-
Encapsulated multi-platform component package preview.
|
|
81
|
-
</p>
|
|
82
|
-
</div>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
|
-
</section>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export default MinimalistCard;
|