@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.
Files changed (128) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +955 -7227
  3. package/dist/utils.d.ts +9 -0
  4. package/dist/utils.js +14 -0
  5. package/package.json +21 -4
  6. package/CHANGELOG.md +0 -149
  7. package/src/components/GlassmorphismAlert.tsx +0 -43
  8. package/src/components/GlassmorphismButton.tsx +0 -20
  9. package/src/components/GlassmorphismCard.tsx +0 -43
  10. package/src/components/GlassmorphismEmptyState.tsx +0 -20
  11. package/src/components/GlassmorphismInputGroup.tsx +0 -148
  12. package/src/components/GlassmorphismMenubar.tsx +0 -96
  13. package/src/components/GlassmorphismScrollArea.tsx +0 -67
  14. package/src/components/GlassmorphismTable.tsx +0 -61
  15. package/src/components/GlassmorphismTypography.tsx +0 -31
  16. package/src/components/MinimalistAccordion.tsx +0 -215
  17. package/src/components/MinimalistAlert.tsx +0 -43
  18. package/src/components/MinimalistAlertDialog.tsx +0 -318
  19. package/src/components/MinimalistAspectRatio.tsx +0 -30
  20. package/src/components/MinimalistAvatar.tsx +0 -149
  21. package/src/components/MinimalistBadge.tsx +0 -49
  22. package/src/components/MinimalistBreadcrumb.tsx +0 -109
  23. package/src/components/MinimalistButton.tsx +0 -86
  24. package/src/components/MinimalistButtonGroup.tsx +0 -86
  25. package/src/components/MinimalistCalendar.tsx +0 -355
  26. package/src/components/MinimalistCard.tsx +0 -89
  27. package/src/components/MinimalistCarousel.tsx +0 -266
  28. package/src/components/MinimalistChart.tsx +0 -296
  29. package/src/components/MinimalistCheckbox.tsx +0 -117
  30. package/src/components/MinimalistCodeBlock.tsx +0 -203
  31. package/src/components/MinimalistCollapsible.tsx +0 -134
  32. package/src/components/MinimalistCommand.tsx +0 -344
  33. package/src/components/MinimalistContextMenu.tsx +0 -408
  34. package/src/components/MinimalistDialog.tsx +0 -273
  35. package/src/components/MinimalistDrawer.tsx +0 -220
  36. package/src/components/MinimalistDropdownMenu.tsx +0 -431
  37. package/src/components/MinimalistEmpty.tsx +0 -105
  38. package/src/components/MinimalistEmptyState.tsx +0 -34
  39. package/src/components/MinimalistField.tsx +0 -275
  40. package/src/components/MinimalistForm.tsx +0 -205
  41. package/src/components/MinimalistHoverCard.tsx +0 -48
  42. package/src/components/MinimalistInput.tsx +0 -24
  43. package/src/components/MinimalistInputGroup.tsx +0 -180
  44. package/src/components/MinimalistInputOtp.tsx +0 -189
  45. package/src/components/MinimalistItem.tsx +0 -182
  46. package/src/components/MinimalistKbd.tsx +0 -46
  47. package/src/components/MinimalistLabel.tsx +0 -19
  48. package/src/components/MinimalistMenubar.tsx +0 -491
  49. package/src/components/MinimalistNativeSelect.tsx +0 -77
  50. package/src/components/MinimalistNavigationMenu.tsx +0 -198
  51. package/src/components/MinimalistPagination.tsx +0 -152
  52. package/src/components/MinimalistPopover.tsx +0 -229
  53. package/src/components/MinimalistProgress.tsx +0 -39
  54. package/src/components/MinimalistRadioGroup.tsx +0 -115
  55. package/src/components/MinimalistRangeCalendar.tsx +0 -396
  56. package/src/components/MinimalistResizable.tsx +0 -54
  57. package/src/components/MinimalistScrollArea.tsx +0 -41
  58. package/src/components/MinimalistSelect.tsx +0 -262
  59. package/src/components/MinimalistSeparator.tsx +0 -45
  60. package/src/components/MinimalistSheet.tsx +0 -247
  61. package/src/components/MinimalistSidebar.tsx +0 -638
  62. package/src/components/MinimalistSkeleton.tsx +0 -16
  63. package/src/components/MinimalistSlider.tsx +0 -213
  64. package/src/components/MinimalistSonner.tsx +0 -41
  65. package/src/components/MinimalistSpinner.tsx +0 -39
  66. package/src/components/MinimalistSwitch.tsx +0 -92
  67. package/src/components/MinimalistTable.tsx +0 -65
  68. package/src/components/MinimalistTabs.tsx +0 -171
  69. package/src/components/MinimalistTextarea.tsx +0 -24
  70. package/src/components/MinimalistToggle.tsx +0 -74
  71. package/src/components/MinimalistToggleGroup.tsx +0 -197
  72. package/src/components/MinimalistTooltip.tsx +0 -172
  73. package/src/components/MinimalistTypography.tsx +0 -33
  74. package/src/components/NeubrutalismCard.tsx +0 -84
  75. package/src/components/NeubrutalismItem.tsx +0 -48
  76. package/src/components/ShadcnAccordion.tsx +0 -215
  77. package/src/components/ShadcnAlertDialog.tsx +0 -318
  78. package/src/components/ShadcnAspectRatio.tsx +0 -30
  79. package/src/components/ShadcnAvatar.tsx +0 -149
  80. package/src/components/ShadcnBadge.tsx +0 -49
  81. package/src/components/ShadcnBreadcrumb.tsx +0 -109
  82. package/src/components/ShadcnButton.tsx +0 -86
  83. package/src/components/ShadcnButtonGroup.tsx +0 -86
  84. package/src/components/ShadcnCalendar.tsx +0 -355
  85. package/src/components/ShadcnCarousel.tsx +0 -266
  86. package/src/components/ShadcnChart.tsx +0 -296
  87. package/src/components/ShadcnCheckbox.tsx +0 -117
  88. package/src/components/ShadcnCodeBlock.tsx +0 -203
  89. package/src/components/ShadcnCollapsible.tsx +0 -134
  90. package/src/components/ShadcnCommand.tsx +0 -344
  91. package/src/components/ShadcnContextMenu.tsx +0 -408
  92. package/src/components/ShadcnDialog.tsx +0 -273
  93. package/src/components/ShadcnDrawer.tsx +0 -220
  94. package/src/components/ShadcnDropdownMenu.tsx +0 -431
  95. package/src/components/ShadcnEmpty.tsx +0 -105
  96. package/src/components/ShadcnField.tsx +0 -275
  97. package/src/components/ShadcnForm.tsx +0 -205
  98. package/src/components/ShadcnHoverCard.tsx +0 -48
  99. package/src/components/ShadcnInput.tsx +0 -24
  100. package/src/components/ShadcnInputGroup.tsx +0 -180
  101. package/src/components/ShadcnInputOtp.tsx +0 -189
  102. package/src/components/ShadcnItem.tsx +0 -182
  103. package/src/components/ShadcnKbd.tsx +0 -46
  104. package/src/components/ShadcnLabel.tsx +0 -19
  105. package/src/components/ShadcnMenubar.tsx +0 -491
  106. package/src/components/ShadcnNativeSelect.tsx +0 -77
  107. package/src/components/ShadcnNavigationMenu.tsx +0 -198
  108. package/src/components/ShadcnPagination.tsx +0 -152
  109. package/src/components/ShadcnPopover.tsx +0 -229
  110. package/src/components/ShadcnProgress.tsx +0 -39
  111. package/src/components/ShadcnRadioGroup.tsx +0 -115
  112. package/src/components/ShadcnRangeCalendar.tsx +0 -396
  113. package/src/components/ShadcnSelect.tsx +0 -262
  114. package/src/components/ShadcnSeparator.tsx +0 -45
  115. package/src/components/ShadcnSheet.tsx +0 -247
  116. package/src/components/ShadcnSidebar.tsx +0 -638
  117. package/src/components/ShadcnSkeleton.tsx +0 -16
  118. package/src/components/ShadcnSlider.tsx +0 -213
  119. package/src/components/ShadcnSonner.tsx +0 -41
  120. package/src/components/ShadcnSpinner.tsx +0 -39
  121. package/src/components/ShadcnSwitch.tsx +0 -92
  122. package/src/components/ShadcnTabs.tsx +0 -171
  123. package/src/components/ShadcnTextarea.tsx +0 -24
  124. package/src/components/ShadcnToggle.tsx +0 -74
  125. package/src/components/ShadcnToggleGroup.tsx +0 -197
  126. package/src/components/ShadcnTooltip.tsx +0 -172
  127. package/src/index.ts +0 -124
  128. package/tsconfig.json +0 -10
@@ -1,115 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { Circle } from 'lucide-react';
4
- import { cn } from '@surreal-ui/core';
5
-
6
- interface RadioGroupContextValue {
7
- value?: string;
8
- onValueChange?: (value: string) => void;
9
- disabled?: boolean;
10
- name?: string;
11
- }
12
-
13
- const RadioGroupContext = React.createContext<RadioGroupContextValue | null>(null);
14
-
15
- export interface ShadcnRadioGroupProps extends React.ComponentProps<'div'> {
16
- value?: string;
17
- defaultValue?: string;
18
- onValueChange?: (value: string) => void;
19
- disabled?: boolean;
20
- name?: string;
21
- }
22
-
23
- export function ShadcnRadioGroup({
24
- className,
25
- value: controlledValue,
26
- defaultValue = '',
27
- onValueChange,
28
- disabled = false,
29
- name,
30
- children,
31
- ...props
32
- }: RadioGroupProps) {
33
- const [uncontrolledValue, setUncontrolledValue] = React.useState(defaultValue);
34
- const isControlled = controlledValue !== undefined;
35
- const value = isControlled ? controlledValue : uncontrolledValue;
36
-
37
- const handleValueChange = React.useCallback(
38
- (nextVal: string) => {
39
- if (!isControlled) {
40
- setUncontrolledValue(nextVal);
41
- }
42
- onValueChange?.(nextVal);
43
- },
44
- [isControlled, onValueChange]
45
- );
46
-
47
- return (
48
- <RadioGroupContext.Provider
49
- value={{
50
- value,
51
- onValueChange: handleValueChange,
52
- disabled,
53
- name
54
- }}
55
- >
56
- <div
57
- role="radiogroup"
58
- data-slot="radio-group"
59
- className={cn('grid gap-2 w-full', className)}
60
- {...props}
61
- >
62
- {children}
63
- </div>
64
- </RadioGroupContext.Provider>
65
- );
66
- }
67
-
68
- export interface ShadcnRadioGroupItemProps extends React.ComponentProps<'button'> {
69
- value: string;
70
- }
71
-
72
- export function ShadcnRadioGroupItem({
73
- className,
74
- value,
75
- disabled: itemDisabled,
76
- id,
77
- ...props
78
- }: RadioGroupItemProps) {
79
- const context = React.useContext(RadioGroupContext);
80
- const isChecked = context?.value === value;
81
- const isDisabled = context?.disabled || itemDisabled;
82
-
83
- return (
84
- <button
85
- type="button"
86
- role="radio"
87
- aria-checked={isChecked}
88
- data-state={isChecked ? 'checked' : 'unchecked'}
89
- data-slot="radio-group-item"
90
- disabled={isDisabled}
91
- id={id}
92
- value={value}
93
- onClick={() => {
94
- if (!isDisabled) {
95
- context?.onValueChange?.(value);
96
- }
97
- }}
98
- className={cn(
99
- 'flex size-4 rounded-full border-input 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 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary group/radio-group-item peer relative aspect-square shrink-0 border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50',
100
- isChecked && 'border-primary bg-primary text-primary-foreground',
101
- className
102
- )}
103
- {...props}
104
- >
105
- <div
106
- data-slot="radio-group-indicator"
107
- className="flex size-4 items-center justify-center pointer-events-none"
108
- >
109
- {isChecked && <Circle className="size-2 fill-current text-primary-foreground" />}
110
- </div>
111
- </button>
112
- );
113
- }
114
-
115
- export default MinimalistRadioGroup;
@@ -1,396 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { ChevronLeft, ChevronRight, ChevronDown } from 'lucide-react';
4
- import { cn } from '@surreal-ui/core';
5
-
6
- export interface DateRange {
7
- start?: Date | null;
8
- end?: Date | null;
9
- }
10
-
11
- export interface ShadcnRangeCalendarProps extends Omit<React.ComponentProps<'div'>, 'onChange'> {
12
- value?: DateRange;
13
- defaultValue?: DateRange;
14
- onValueChange?: (range: DateRange) => void;
15
- placeholder?: Date;
16
- numberOfMonths?: number;
17
- locale?: string;
18
- weekdayFormat?: 'short' | 'narrow' | 'long';
19
- captionLayout?: 'dropdown' | 'dropdown-months' | 'dropdown-years' | 'label';
20
- disableDaysOutsideMonth?: boolean;
21
- }
22
-
23
- function isSameDay(d1?: Date | null, d2?: Date | null): boolean {
24
- if (!d1 || !d2) return false;
25
- return (
26
- d1.getFullYear() === d2.getFullYear() &&
27
- d1.getMonth() === d2.getMonth() &&
28
- d1.getDate() === d2.getDate()
29
- );
30
- }
31
-
32
- function isBeforeDay(d1: Date, d2: Date): boolean {
33
- const t1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate()).getTime();
34
- const t2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate()).getTime();
35
- return t1 < t2;
36
- }
37
-
38
- function isAfterDay(d1: Date, d2: Date): boolean {
39
- const t1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate()).getTime();
40
- const t2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate()).getTime();
41
- return t1 > t2;
42
- }
43
-
44
- function isBetweenDays(date: Date, start?: Date | null, end?: Date | null): boolean {
45
- if (!start || !end) return false;
46
- return isAfterDay(date, start) && isBeforeDay(date, end);
47
- }
48
-
49
- export function ShadcnRangeCalendar({
50
- value: controlledValue,
51
- defaultValue = { start: null, end: null },
52
- onValueChange,
53
- placeholder: controlledPlaceholder,
54
- numberOfMonths = 1,
55
- locale = 'en-US',
56
- weekdayFormat = 'short',
57
- captionLayout = 'label',
58
- disableDaysOutsideMonth = false,
59
- className,
60
- children,
61
- ...props
62
- }: RangeCalendarProps) {
63
- const [uncontrolledValue, setUncontrolledValue] = React.useState<DateRange>(defaultValue);
64
- const [currentPlaceholder, setCurrentPlaceholder] = React.useState<Date>(
65
- controlledPlaceholder || new Date()
66
- );
67
- const [hoveredDate, setHoveredDate] = React.useState<Date | null>(null);
68
-
69
- const value = controlledValue !== undefined ? controlledValue : uncontrolledValue;
70
- const placeholder =
71
- controlledPlaceholder !== undefined ? controlledPlaceholder : currentPlaceholder;
72
-
73
- const setPlaceholder = React.useCallback(
74
- (date: Date) => {
75
- if (controlledPlaceholder === undefined) {
76
- setCurrentPlaceholder(date);
77
- }
78
- },
79
- [controlledPlaceholder]
80
- );
81
-
82
- const handleSelectDate = (date: Date) => {
83
- let next: DateRange;
84
- if (!value.start || (value.start && value.end)) {
85
- next = { start: date, end: null };
86
- } else {
87
- if (isBeforeDay(date, value.start)) {
88
- next = { start: date, end: value.start };
89
- } else {
90
- next = { start: value.start, end: date };
91
- }
92
- }
93
- if (controlledValue === undefined) {
94
- setUncontrolledValue(next);
95
- }
96
- onValueChange?.(next);
97
- };
98
-
99
- const prevMonth = () => {
100
- const next = new Date(placeholder);
101
- next.setMonth(next.getMonth() - 1);
102
- setPlaceholder(next);
103
- };
104
-
105
- const nextMonth = () => {
106
- const next = new Date(placeholder);
107
- next.setMonth(next.getMonth() + 1);
108
- setPlaceholder(next);
109
- };
110
-
111
- const weekdays = React.useMemo(() => {
112
- const now = new Date();
113
- const start = new Date(now.setDate(now.getDate() - now.getDay()));
114
- return Array.from({ length: 7 }).map((_, i) => {
115
- const d = new Date(start);
116
- d.setDate(start.getDate() + i);
117
- return new Intl.DateTimeFormat(locale, { weekday: weekdayFormat }).format(d);
118
- });
119
- }, [locale, weekdayFormat]);
120
-
121
- const getMonthData = (offset: number) => {
122
- const target = new Date(placeholder.getFullYear(), placeholder.getMonth() + offset, 1);
123
- const year = target.getFullYear();
124
- const month = target.getMonth();
125
- const firstDayOfWeek = new Date(year, month, 1).getDay();
126
- const daysInMonth = new Date(year, month + 1, 0).getDate();
127
- const daysInPrevMonth = new Date(year, month, 0).getDate();
128
-
129
- const matrix: { date: Date; outside: boolean }[][] = [];
130
- let currentWeek: { date: Date; outside: boolean }[] = [];
131
-
132
- for (let i = firstDayOfWeek - 1; i >= 0; i--) {
133
- currentWeek.push({
134
- date: new Date(year, month - 1, daysInPrevMonth - i),
135
- outside: true
136
- });
137
- }
138
-
139
- for (let day = 1; day <= daysInMonth; day++) {
140
- if (currentWeek.length === 7) {
141
- matrix.push(currentWeek);
142
- currentWeek = [];
143
- }
144
- currentWeek.push({
145
- date: new Date(year, month, day),
146
- outside: false
147
- });
148
- }
149
-
150
- let nextMonthDay = 1;
151
- while (currentWeek.length > 0 && currentWeek.length < 7) {
152
- currentWeek.push({
153
- date: new Date(year, month + 1, nextMonthDay++),
154
- outside: true
155
- });
156
- }
157
- if (currentWeek.length > 0) {
158
- matrix.push(currentWeek);
159
- }
160
-
161
- return { year, month, target, matrix };
162
- };
163
-
164
- return (
165
- <div
166
- data-slot="range-calendar"
167
- className={cn(
168
- 'p-3 bg-background border border-border rounded-lg shadow-sm w-fit select-none',
169
- className
170
- )}
171
- {...props}
172
- >
173
- {children ? (
174
- children
175
- ) : (
176
- <div className="relative flex flex-col gap-4 md:flex-row">
177
- <nav className="absolute inset-x-0 top-0 flex w-full items-center justify-between pointer-events-none z-10">
178
- <button
179
- type="button"
180
- onClick={prevMonth}
181
- aria-label="Previous Month"
182
- className="pointer-events-auto inline-flex size-7 items-center justify-center rounded-md border border-input bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
183
- >
184
- <ChevronLeft className="size-4" />
185
- </button>
186
- <button
187
- type="button"
188
- onClick={nextMonth}
189
- aria-label="Next Month"
190
- className="pointer-events-auto inline-flex size-7 items-center justify-center rounded-md border border-input bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
191
- >
192
- <ChevronRight className="size-4" />
193
- </button>
194
- </nav>
195
-
196
- {Array.from({ length: numberOfMonths }).map((_, idx) => {
197
- const monthData = getMonthData(idx);
198
- return (
199
- <div key={idx} className="flex flex-col gap-3">
200
- <div className="flex h-7 items-center justify-center">
201
- <span className="text-sm font-medium text-foreground">
202
- {new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(
203
- monthData.target
204
- )}
205
- </span>
206
- </div>
207
-
208
- <table className="w-full border-collapse space-y-1">
209
- <thead>
210
- <tr className="flex">
211
- {weekdays.map((day, i) => (
212
- <th
213
- key={i}
214
- className="w-9 rounded-md text-[0.8rem] font-normal text-muted-foreground text-center"
215
- >
216
- {day.slice(0, 2)}
217
- </th>
218
- ))}
219
- </tr>
220
- </thead>
221
- <tbody className="flex flex-col gap-1 mt-2">
222
- {monthData.matrix.map((week, weekIdx) => (
223
- <tr key={weekIdx} className="flex w-full">
224
- {week.map((cell, cellIdx) => {
225
- const isStart = isSameDay(cell.date, value.start);
226
- const isEnd = isSameDay(cell.date, value.end);
227
- const effectiveEnd =
228
- value.end ||
229
- (value.start && hoveredDate && isAfterDay(hoveredDate, value.start)
230
- ? hoveredDate
231
- : null);
232
- const isMiddle = isBetweenDays(cell.date, value.start, effectiveEnd);
233
- const isToday = isSameDay(cell.date, new Date());
234
-
235
- return (
236
- <td
237
- key={cellIdx}
238
- className={cn(
239
- 'relative size-9 p-0 text-center text-sm focus-within:z-20',
240
- isStart && !isEnd && value.end && 'rounded-s-md bg-accent',
241
- isEnd && !isStart && 'rounded-e-md bg-accent',
242
- isMiddle && 'bg-accent rounded-none',
243
- isStart && isEnd && 'rounded-md'
244
- )}
245
- >
246
- {disableDaysOutsideMonth && cell.outside ? (
247
- <div className="size-9" />
248
- ) : (
249
- <button
250
- type="button"
251
- onClick={() => handleSelectDate(cell.date)}
252
- onMouseEnter={() => setHoveredDate(cell.date)}
253
- className={cn(
254
- 'inline-flex size-9 items-center justify-center rounded-md text-sm font-normal transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring select-none',
255
- cell.outside && 'text-muted-foreground opacity-50',
256
- isToday &&
257
- !isStart &&
258
- !isEnd &&
259
- 'bg-accent text-accent-foreground font-semibold',
260
- (isStart || isEnd) &&
261
- 'bg-primary text-primary-foreground font-semibold hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',
262
- isMiddle && 'text-foreground rounded-none hover:bg-accent',
263
- !isStart &&
264
- !isEnd &&
265
- !isMiddle &&
266
- 'hover:bg-accent hover:text-accent-foreground'
267
- )}
268
- >
269
- {cell.date.getDate()}
270
- </button>
271
- )}
272
- </td>
273
- );
274
- })}
275
- </tr>
276
- ))}
277
- </tbody>
278
- </table>
279
- </div>
280
- );
281
- })}
282
- </div>
283
- )}
284
- </div>
285
- );
286
- }
287
-
288
- export const RangeCalendarMonths = ({ className, ...props }: React.ComponentProps<'div'>) => (
289
- <div className={cn('relative flex flex-col gap-4 md:flex-row', className)} {...props} />
290
- );
291
-
292
- export const RangeCalendarNav = ({ className, ...props }: React.ComponentProps<'nav'>) => (
293
- <nav
294
- className={cn(
295
- 'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
296
- className
297
- )}
298
- {...props}
299
- />
300
- );
301
-
302
- export const RangeCalendarPrevButton = ({
303
- className,
304
- ...props
305
- }: React.ComponentProps<'button'>) => (
306
- <button
307
- type="button"
308
- className={cn(
309
- 'inline-flex size-7 items-center justify-center rounded-md border border-input bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground select-none disabled:opacity-50 rtl:rotate-180',
310
- className
311
- )}
312
- {...props}
313
- >
314
- <ChevronLeft className="size-4" />
315
- </button>
316
- );
317
-
318
- export const RangeCalendarNextButton = ({
319
- className,
320
- ...props
321
- }: React.ComponentProps<'button'>) => (
322
- <button
323
- type="button"
324
- className={cn(
325
- 'inline-flex size-7 items-center justify-center rounded-md border border-input bg-transparent text-foreground hover:bg-accent hover:text-accent-foreground select-none disabled:opacity-50 rtl:rotate-180',
326
- className
327
- )}
328
- {...props}
329
- >
330
- <ChevronRight className="size-4" />
331
- </button>
332
- );
333
-
334
- export const RangeCalendarMonth = ({ className, ...props }: React.ComponentProps<'div'>) => (
335
- <div className={cn('flex flex-col gap-3', className)} {...props} />
336
- );
337
-
338
- export const ShadcnRangeCalendarHeader = ({ className, ...props }: React.ComponentProps<'div'>) => (
339
- <div
340
- className={cn(
341
- 'flex h-7 w-full items-center justify-center gap-1.5 text-sm font-medium',
342
- className
343
- )}
344
- {...props}
345
- />
346
- );
347
-
348
- export const RangeCalendarHeading = ({ className, ...props }: React.ComponentProps<'div'>) => (
349
- <div className={cn('px-2 text-sm font-medium', className)} {...props} />
350
- );
351
-
352
- export const RangeCalendarGrid = ({ className, ...props }: React.ComponentProps<'table'>) => (
353
- <table className={cn('mt-4 flex w-full border-collapse flex-col gap-1', className)} {...props} />
354
- );
355
-
356
- export const RangeCalendarGridHead = ({ className, ...props }: React.ComponentProps<'thead'>) => (
357
- <thead className={cn('select-none', className)} {...props} />
358
- );
359
-
360
- export const RangeCalendarGridRow = ({ className, ...props }: React.ComponentProps<'tr'>) => (
361
- <tr className={cn('flex w-full', className)} {...props} />
362
- );
363
-
364
- export const RangeCalendarHeadCell = ({ className, ...props }: React.ComponentProps<'th'>) => (
365
- <th
366
- className={cn(
367
- 'w-9 rounded-md text-[0.8rem] font-normal text-muted-foreground text-center',
368
- className
369
- )}
370
- {...props}
371
- />
372
- );
373
-
374
- export const RangeCalendarGridBody = ({ className, ...props }: React.ComponentProps<'tbody'>) => (
375
- <tbody className={cn('flex flex-col gap-1', className)} {...props} />
376
- );
377
-
378
- export const ShadcnRangeCalendarCell = ({ className, ...props }: React.ComponentProps<'td'>) => (
379
- <td
380
- className={cn('relative size-9 p-0 text-center text-sm focus-within:z-20', className)}
381
- {...props}
382
- />
383
- );
384
-
385
- export const RangeCalendarDay = ({ className, ...props }: React.ComponentProps<'button'>) => (
386
- <button
387
- type="button"
388
- className={cn(
389
- 'flex size-9 flex-col items-center justify-center rounded-md p-0 leading-none font-normal select-none transition-colors hover:bg-accent hover:text-accent-foreground',
390
- className
391
- )}
392
- {...props}
393
- />
394
- );
395
-
396
- export default MinimalistRangeCalendar;
@@ -1,54 +0,0 @@
1
- import React, { useState, useCallback } from 'react';
2
- interface MinimalistResizableProps {
3
- initialWidth?: number;
4
- minWidth?: number;
5
- maxWidth?: number;
6
- children?: React.ReactNode;
7
- }
8
- export const MinimalistResizable: React.FC<MinimalistResizableProps> = ({
9
- initialWidth = 400,
10
- minWidth = 200,
11
- maxWidth = 800,
12
- children
13
- }) => {
14
- const [width, setWidth] = useState(initialWidth);
15
- const [isResizing, setIsResizing] = useState(false);
16
- const handleMouseDown = () => setIsResizing(true);
17
- const handleMouseMove = useCallback(
18
- (e: MouseEvent) => {
19
- if (!isResizing) return;
20
- if (e.clientX >= minWidth && e.clientX <= maxWidth) {
21
- setWidth(e.clientX);
22
- }
23
- },
24
- [isResizing, minWidth, maxWidth]
25
- );
26
- const handleMouseUp = useCallback(() => setIsResizing(false), []);
27
- React.useEffect(() => {
28
- if (isResizing) {
29
- window.addEventListener('mousemove', handleMouseMove);
30
- window.addEventListener('mouseup', handleMouseUp);
31
- }
32
- return () => {
33
- window.removeEventListener('mousemove', handleMouseMove);
34
- window.removeEventListener('mouseup', handleMouseUp);
35
- };
36
- }, [isResizing, handleMouseMove, handleMouseUp]);
37
- return (
38
- <div
39
- className="resizable-container border border-gray-200 relative flex"
40
- style={{ width: `${width}px` }}
41
- >
42
- <div className="content flex-1 p-4">{children}</div>
43
- <div
44
- role="separator"
45
- aria-label="Resize handle"
46
- tabIndex={0}
47
- className="resize-handle w-1 bg-gray-300 hover:bg-gray-400 cursor-ew-resize"
48
- onMouseDown={handleMouseDown}
49
- />
50
- </div>
51
- );
52
- };
53
-
54
- export default MinimalistResizable;
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import { Copy, Check } from 'lucide-react';
3
- interface ModernScrollAreaProps {
4
- activePlatform?: string;
5
- code?: string;
6
- copied?: boolean;
7
- onCopy?: () => void;
8
- }
9
- export const ModernScrollArea: React.FC<ModernScrollAreaProps> = ({
10
- activePlatform = 'react',
11
- code = '',
12
- copied = false,
13
- onCopy = () => {}
14
- }) => {
15
- const formattedCode = React.useMemo(() => (code || '').trim(), [code]);
16
- return (
17
- <div className="relative">
18
- <button
19
- onClick={onCopy}
20
- className="absolute right-4 top-4 px-3 py-1.5 bg-slate-800/80 hover:bg-slate-700 text-slate-200 text-xs font-semibold rounded-lg border border-slate-700 flex items-center gap-1.5 transition-colors z-10"
21
- >
22
- {copied ? (
23
- <>
24
- <Check className="w-3.5 h-3.5 text-emerald-400" />
25
- <span className="text-emerald-400">Copied!</span>
26
- </>
27
- ) : (
28
- <>
29
- <Copy className="w-3.5 h-3.5" />
30
- <span>Copy Code</span>
31
- </>
32
- )}
33
- </button>
34
- <pre className="p-6 rounded-2xl bg-slate-950 border border-slate-800 text-xs font-mono text-indigo-200 overflow-x-auto leading-relaxed">
35
- <code>{formattedCode}</code>
36
- </pre>
37
- </div>
38
- );
39
- };
40
-
41
- export default MinimalistScrollArea;