@sonamu-kit/react-components 0.1.0 → 0.1.2

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 (146) hide show
  1. package/dist/components/index.d.ts +65 -0
  2. package/dist/components/ui/accordion.d.ts +7 -0
  3. package/dist/components/ui/alert-dialog.d.ts +20 -0
  4. package/dist/components/ui/alert.d.ts +8 -0
  5. package/dist/components/ui/aspect-ratio.d.ts +3 -0
  6. package/dist/components/ui/async-select.d.ts +36 -0
  7. package/dist/components/ui/avatar.d.ts +6 -0
  8. package/dist/components/ui/badge.d.ts +9 -0
  9. package/dist/components/ui/breadcrumb.d.ts +19 -0
  10. package/dist/components/ui/button.d.ts +13 -0
  11. package/dist/components/ui/calendar.d.ts +5 -0
  12. package/dist/components/ui/card.d.ts +9 -0
  13. package/dist/components/ui/carousel.d.ts +18 -0
  14. package/dist/components/ui/checkbox.d.ts +8 -0
  15. package/dist/components/ui/collapsible.d.ts +5 -0
  16. package/dist/components/ui/combobox.d.ts +20 -0
  17. package/dist/components/ui/command.d.ts +80 -0
  18. package/dist/components/ui/common-modal.d.ts +28 -0
  19. package/dist/components/ui/context-menu.d.ts +27 -0
  20. package/dist/components/ui/date-input.d.ts +7 -0
  21. package/dist/components/ui/date-picker.d.ts +26 -0
  22. package/dist/components/ui/date-selector-multiple.d.ts +38 -0
  23. package/dist/components/ui/dialog.d.ts +19 -0
  24. package/dist/components/ui/drawer.d.ts +22 -0
  25. package/dist/components/ui/dropdown-menu.d.ts +27 -0
  26. package/dist/components/ui/form.d.ts +23 -0
  27. package/dist/components/ui/hover-card.d.ts +6 -0
  28. package/dist/components/ui/image-uploader.d.ts +14 -0
  29. package/dist/components/ui/input-otp.d.ts +34 -0
  30. package/dist/components/ui/input.d.ts +7 -0
  31. package/dist/components/ui/label.d.ts +5 -0
  32. package/dist/components/ui/menubar.d.ts +28 -0
  33. package/dist/components/ui/month-picker-multiple.d.ts +41 -0
  34. package/dist/components/ui/multi-image-uploader.d.ts +15 -0
  35. package/dist/components/ui/multi-select.d.ts +229 -0
  36. package/dist/components/ui/navigation-menu.d.ts +12 -0
  37. package/dist/components/ui/pagination.d.ts +10 -0
  38. package/dist/components/ui/popover.d.ts +7 -0
  39. package/dist/components/ui/progress.d.ts +4 -0
  40. package/dist/components/ui/radio-group.d.ts +5 -0
  41. package/dist/components/ui/resizable.d.ts +23 -0
  42. package/dist/components/ui/scroll-area.d.ts +5 -0
  43. package/dist/components/ui/select.d.ts +20 -0
  44. package/dist/components/ui/separator.d.ts +4 -0
  45. package/dist/components/ui/sheet.d.ts +25 -0
  46. package/dist/components/ui/sidebar.d.ts +69 -0
  47. package/dist/components/ui/skeleton.d.ts +2 -0
  48. package/dist/components/ui/slider.d.ts +8 -0
  49. package/dist/components/ui/sonner.d.ts +4 -0
  50. package/dist/components/ui/switch.d.ts +8 -0
  51. package/dist/components/ui/table.d.ts +24 -0
  52. package/dist/components/ui/tabs.d.ts +7 -0
  53. package/dist/components/ui/textarea.d.ts +7 -0
  54. package/dist/components/ui/toast.d.ts +15 -0
  55. package/dist/components/ui/toaster.d.ts +1 -0
  56. package/dist/components/ui/toggle-group.d.ts +12 -0
  57. package/dist/components/ui/toggle.d.ts +12 -0
  58. package/dist/components/ui/tooltip.d.ts +7 -0
  59. package/dist/hooks/index.d.ts +1 -0
  60. package/dist/hooks/use-toast.d.ts +44 -0
  61. package/dist/index.d.ts +3 -0
  62. package/dist/lib/caster.d.ts +3 -0
  63. package/dist/lib/helpers.d.ts +72 -0
  64. package/dist/lib/index.d.ts +6 -0
  65. package/{src/lib/lazy-upload.ts → dist/lib/lazy-upload.d.ts} +1 -12
  66. package/dist/lib/use-mobile.d.ts +1 -0
  67. package/dist/lib/utils.d.ts +2 -0
  68. package/dist/react-components.es.js +28375 -0
  69. package/package.json +105 -76
  70. package/COMPONENTS_LIST.md +0 -106
  71. package/COMPONENTS_STATUS.md +0 -114
  72. package/HELPERS_GUIDE.md +0 -489
  73. package/MIGRATION_PLAN.md +0 -404
  74. package/SETUP_GUIDE.md +0 -125
  75. package/components.json +0 -21
  76. package/postcss.config.js +0 -6
  77. package/src/components/index.ts +0 -315
  78. package/src/components/ui/accordion.tsx +0 -54
  79. package/src/components/ui/alert-dialog.tsx +0 -115
  80. package/src/components/ui/alert.tsx +0 -49
  81. package/src/components/ui/aspect-ratio.tsx +0 -5
  82. package/src/components/ui/async-select.tsx +0 -186
  83. package/src/components/ui/avatar.tsx +0 -45
  84. package/src/components/ui/badge.tsx +0 -38
  85. package/src/components/ui/breadcrumb.tsx +0 -102
  86. package/src/components/ui/button.tsx +0 -54
  87. package/src/components/ui/calendar.tsx +0 -193
  88. package/src/components/ui/card.tsx +0 -65
  89. package/src/components/ui/carousel.tsx +0 -243
  90. package/src/components/ui/checkbox.tsx +0 -67
  91. package/src/components/ui/collapsible.tsx +0 -9
  92. package/src/components/ui/combobox.tsx +0 -135
  93. package/src/components/ui/command.tsx +0 -143
  94. package/src/components/ui/common-modal.tsx +0 -95
  95. package/src/components/ui/context-menu.tsx +0 -189
  96. package/src/components/ui/date-picker.tsx +0 -112
  97. package/src/components/ui/date-selector-multiple.tsx +0 -197
  98. package/src/components/ui/dialog.tsx +0 -104
  99. package/src/components/ui/drawer.tsx +0 -100
  100. package/src/components/ui/dropdown-menu.tsx +0 -189
  101. package/src/components/ui/form.tsx +0 -171
  102. package/src/components/ui/hover-card.tsx +0 -27
  103. package/src/components/ui/image-uploader.tsx +0 -251
  104. package/src/components/ui/input-otp.tsx +0 -69
  105. package/src/components/ui/input.tsx +0 -38
  106. package/src/components/ui/label.tsx +0 -19
  107. package/src/components/ui/menubar.tsx +0 -231
  108. package/src/components/ui/month-picker-multiple.tsx +0 -351
  109. package/src/components/ui/multi-image-uploader.tsx +0 -283
  110. package/src/components/ui/multi-select.tsx +0 -1143
  111. package/src/components/ui/navigation-menu.tsx +0 -120
  112. package/src/components/ui/pagination.tsx +0 -72
  113. package/src/components/ui/popover.tsx +0 -42
  114. package/src/components/ui/progress.tsx +0 -25
  115. package/src/components/ui/radio-group.tsx +0 -38
  116. package/src/components/ui/resizable.tsx +0 -42
  117. package/src/components/ui/scroll-area.tsx +0 -46
  118. package/src/components/ui/select.tsx +0 -235
  119. package/src/components/ui/separator.tsx +0 -24
  120. package/src/components/ui/sheet.tsx +0 -119
  121. package/src/components/ui/sidebar.tsx +0 -683
  122. package/src/components/ui/skeleton.tsx +0 -7
  123. package/src/components/ui/slider.tsx +0 -57
  124. package/src/components/ui/sonner.tsx +0 -39
  125. package/src/components/ui/switch.tsx +0 -63
  126. package/src/components/ui/table.tsx +0 -94
  127. package/src/components/ui/tabs.tsx +0 -53
  128. package/src/components/ui/textarea.tsx +0 -34
  129. package/src/components/ui/toast.tsx +0 -122
  130. package/src/components/ui/toaster.tsx +0 -29
  131. package/src/components/ui/toggle-group.tsx +0 -55
  132. package/src/components/ui/toggle.tsx +0 -41
  133. package/src/components/ui/tooltip.tsx +0 -28
  134. package/src/hooks/index.ts +0 -2
  135. package/src/hooks/use-toast.ts +0 -189
  136. package/src/icons.d.ts +0 -1
  137. package/src/index.ts +0 -4
  138. package/src/lib/caster.ts +0 -66
  139. package/src/lib/helpers.ts +0 -394
  140. package/src/lib/index.ts +0 -31
  141. package/src/lib/use-mobile.ts +0 -19
  142. package/src/lib/utils.ts +0 -6
  143. package/src/styles/globals.css +0 -658
  144. package/tailwind.config.ts +0 -8
  145. package/tsconfig.json +0 -31
  146. package/tsconfig.node.json +0 -11
@@ -1,189 +0,0 @@
1
- import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
2
- import * as React from "react";
3
- import CheckIcon from "~icons/lucide/check";
4
- import ChevronRightIcon from "~icons/lucide/chevron-right";
5
- import CircleIcon from "~icons/lucide/circle";
6
-
7
- import { cn } from "../../lib/utils";
8
-
9
- const ContextMenu = ContextMenuPrimitive.Root;
10
-
11
- const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
12
-
13
- const ContextMenuGroup = ContextMenuPrimitive.Group;
14
-
15
- const ContextMenuPortal = ContextMenuPrimitive.Portal;
16
-
17
- const ContextMenuSub = ContextMenuPrimitive.Sub;
18
-
19
- const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
20
-
21
- const ContextMenuSubTrigger = React.forwardRef<
22
- React.ElementRef<typeof ContextMenuPrimitive.SubTrigger>,
23
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & {
24
- inset?: boolean;
25
- }
26
- >(({ className, inset, children, ...props }, ref) => (
27
- <ContextMenuPrimitive.SubTrigger
28
- ref={ref}
29
- className={cn(
30
- "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
31
- inset && "pl-8",
32
- className,
33
- )}
34
- {...props}
35
- >
36
- {children}
37
- <ChevronRightIcon className="ml-auto h-4 w-4" />
38
- </ContextMenuPrimitive.SubTrigger>
39
- ));
40
- ContextMenuSubTrigger.displayName = ContextMenuPrimitive.SubTrigger.displayName;
41
-
42
- const ContextMenuSubContent = React.forwardRef<
43
- React.ElementRef<typeof ContextMenuPrimitive.SubContent>,
44
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>
45
- >(({ className, ...props }, ref) => (
46
- <ContextMenuPrimitive.SubContent
47
- ref={ref}
48
- className={cn(
49
- "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",
50
- className,
51
- )}
52
- {...props}
53
- />
54
- ));
55
- ContextMenuSubContent.displayName = ContextMenuPrimitive.SubContent.displayName;
56
-
57
- const ContextMenuContent = React.forwardRef<
58
- React.ElementRef<typeof ContextMenuPrimitive.Content>,
59
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>
60
- >(({ className, ...props }, ref) => (
61
- <ContextMenuPrimitive.Portal>
62
- <ContextMenuPrimitive.Content
63
- ref={ref}
64
- className={cn(
65
- "z-50 max-h-[--radix-context-menu-content-available-height] min-w-32 overflow-y-auto overflow-x-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-context-menu-content-transform-origin]",
66
- className,
67
- )}
68
- {...props}
69
- />
70
- </ContextMenuPrimitive.Portal>
71
- ));
72
- ContextMenuContent.displayName = ContextMenuPrimitive.Content.displayName;
73
-
74
- const ContextMenuItem = React.forwardRef<
75
- React.ElementRef<typeof ContextMenuPrimitive.Item>,
76
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {
77
- inset?: boolean;
78
- }
79
- >(({ className, inset, ...props }, ref) => (
80
- <ContextMenuPrimitive.Item
81
- ref={ref}
82
- className={cn(
83
- "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
84
- inset && "pl-8",
85
- className,
86
- )}
87
- {...props}
88
- />
89
- ));
90
- ContextMenuItem.displayName = ContextMenuPrimitive.Item.displayName;
91
-
92
- const ContextMenuCheckboxItem = React.forwardRef<
93
- React.ElementRef<typeof ContextMenuPrimitive.CheckboxItem>,
94
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>
95
- >(({ className, children, checked, ...props }, ref) => (
96
- <ContextMenuPrimitive.CheckboxItem
97
- ref={ref}
98
- className={cn(
99
- "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
100
- className,
101
- )}
102
- checked={checked}
103
- {...props}
104
- >
105
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
106
- <ContextMenuPrimitive.ItemIndicator>
107
- <CheckIcon className="h-4 w-4" />
108
- </ContextMenuPrimitive.ItemIndicator>
109
- </span>
110
- {children}
111
- </ContextMenuPrimitive.CheckboxItem>
112
- ));
113
- ContextMenuCheckboxItem.displayName = ContextMenuPrimitive.CheckboxItem.displayName;
114
-
115
- const ContextMenuRadioItem = React.forwardRef<
116
- React.ElementRef<typeof ContextMenuPrimitive.RadioItem>,
117
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>
118
- >(({ className, children, ...props }, ref) => (
119
- <ContextMenuPrimitive.RadioItem
120
- ref={ref}
121
- className={cn(
122
- "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
123
- className,
124
- )}
125
- {...props}
126
- >
127
- <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
128
- <ContextMenuPrimitive.ItemIndicator>
129
- <CircleIcon className="h-2 w-2 fill-current" />
130
- </ContextMenuPrimitive.ItemIndicator>
131
- </span>
132
- {children}
133
- </ContextMenuPrimitive.RadioItem>
134
- ));
135
- ContextMenuRadioItem.displayName = ContextMenuPrimitive.RadioItem.displayName;
136
-
137
- const ContextMenuLabel = React.forwardRef<
138
- React.ElementRef<typeof ContextMenuPrimitive.Label>,
139
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & {
140
- inset?: boolean;
141
- }
142
- >(({ className, inset, ...props }, ref) => (
143
- <ContextMenuPrimitive.Label
144
- ref={ref}
145
- className={cn("px-2 py-1.5 text-sm font-semibold text-foreground", inset && "pl-8", className)}
146
- {...props}
147
- />
148
- ));
149
- ContextMenuLabel.displayName = ContextMenuPrimitive.Label.displayName;
150
-
151
- const ContextMenuSeparator = React.forwardRef<
152
- React.ElementRef<typeof ContextMenuPrimitive.Separator>,
153
- React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>
154
- >(({ className, ...props }, ref) => (
155
- <ContextMenuPrimitive.Separator
156
- ref={ref}
157
- className={cn("-mx-1 my-1 h-px bg-border", className)}
158
- {...props}
159
- />
160
- ));
161
- ContextMenuSeparator.displayName = ContextMenuPrimitive.Separator.displayName;
162
-
163
- const ContextMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
164
- return (
165
- <span
166
- className={cn("ml-auto text-xs tracking-widest text-muted-foreground", className)}
167
- {...props}
168
- />
169
- );
170
- };
171
- ContextMenuShortcut.displayName = "ContextMenuShortcut";
172
-
173
- export {
174
- ContextMenu,
175
- ContextMenuTrigger,
176
- ContextMenuContent,
177
- ContextMenuItem,
178
- ContextMenuCheckboxItem,
179
- ContextMenuRadioItem,
180
- ContextMenuLabel,
181
- ContextMenuSeparator,
182
- ContextMenuShortcut,
183
- ContextMenuGroup,
184
- ContextMenuPortal,
185
- ContextMenuSub,
186
- ContextMenuSubContent,
187
- ContextMenuSubTrigger,
188
- ContextMenuRadioGroup,
189
- };
@@ -1,112 +0,0 @@
1
- "use client";
2
-
3
- import { format } from "date-fns";
4
- import * as React from "react";
5
- import CalendarIcon from "~icons/lucide/calendar";
6
-
7
- import { cn } from "../../lib/utils";
8
- import { Button } from "./button";
9
- import { Calendar } from "./calendar";
10
- import { Popover, PopoverContent, PopoverTrigger } from "./popover";
11
-
12
- interface DatePickerProps {
13
- value?: Date;
14
- onValueChange?: (date: Date | undefined) => void;
15
- placeholder?: string;
16
- disabled?: boolean;
17
- className?: string;
18
- }
19
-
20
- /**
21
- * Date Picker Component
22
- *
23
- * Based on shadcn/ui Date Picker pattern:
24
- * @see https://ui.shadcn.com/docs/components/date-picker
25
- *
26
- * Example usage:
27
- * ```tsx
28
- * const [date, setDate] = useState<Date>()
29
- * <DatePicker value={date} onValueChange={(date) => setDate(date)} />
30
- * ```
31
- */
32
- export function DatePicker({
33
- value,
34
- onValueChange,
35
- placeholder = "Pick a date",
36
- disabled = false,
37
- className,
38
- }: DatePickerProps) {
39
- return (
40
- <Popover>
41
- <PopoverTrigger asChild>
42
- <Button
43
- variant="outline"
44
- disabled={disabled}
45
- data-empty={!value}
46
- className={cn(
47
- "w-full justify-start text-left font-normal",
48
- "data-[empty=true]:text-muted-foreground",
49
- className,
50
- )}
51
- >
52
- <CalendarIcon />
53
- {value ? format(value, "PPP") : <span>{placeholder}</span>}
54
- </Button>
55
- </PopoverTrigger>
56
- <PopoverContent className="w-auto p-0" align="start">
57
- <Calendar
58
- mode="single"
59
- selected={value}
60
- onSelect={(date) => {
61
- onValueChange?.(date);
62
- }}
63
- initialFocus
64
- />
65
- </PopoverContent>
66
- </Popover>
67
- );
68
- }
69
-
70
- /**
71
- * Date Picker with Dropdown Layout
72
- * Useful for selecting dates of birth or past dates
73
- */
74
- export function DatePickerWithDropdown({
75
- value,
76
- onValueChange,
77
- placeholder = "Select date",
78
- disabled = false,
79
- className,
80
- }: DatePickerProps) {
81
- const [open, setOpen] = React.useState(false);
82
-
83
- return (
84
- <Popover open={open} onOpenChange={setOpen}>
85
- <PopoverTrigger asChild>
86
- <Button
87
- variant="outline"
88
- disabled={disabled}
89
- className={cn(
90
- "w-full justify-between font-normal",
91
- !value && "text-muted-foreground",
92
- className,
93
- )}
94
- >
95
- {value ? value.toLocaleDateString() : placeholder}
96
- <CalendarIcon />
97
- </Button>
98
- </PopoverTrigger>
99
- <PopoverContent className="w-auto overflow-hidden p-0" align="start">
100
- <Calendar
101
- mode="single"
102
- selected={value}
103
- captionLayout="dropdown"
104
- onSelect={(selectedDate) => {
105
- onValueChange?.(selectedDate);
106
- setOpen(false);
107
- }}
108
- />
109
- </PopoverContent>
110
- </Popover>
111
- );
112
- }
@@ -1,197 +0,0 @@
1
- "use client";
2
-
3
- import { format } from "date-fns";
4
- import * as React from "react";
5
- import type { DateRange } from "react-day-picker";
6
- import { Button } from "./button";
7
- import { Calendar } from "./calendar";
8
- import { Popover, PopoverContent, PopoverTrigger } from "./popover";
9
-
10
- /** 단일 날짜 또는 날짜 범위 값 */
11
- export type DateSelectorValue =
12
- | { type: "single"; date: Date }
13
- | { type: "range"; from: Date; to: Date };
14
-
15
- interface DateSelectorMultipleProps {
16
- /** Calendar icon component */
17
- CalendarIcon: React.ComponentType<{ className?: string }>;
18
- /** ChevronDown icon component */
19
- ChevronDownIcon: React.ComponentType<{ className?: string }>;
20
- /** Current value */
21
- value?: DateSelectorValue;
22
- /** Callback when value changes */
23
- onChange?: (event: null, data: { value: DateSelectorValue | undefined }) => void;
24
- /** Placeholder text when no value */
25
- placeholder?: string;
26
- /** Date format string for display */
27
- dateFormat?: string;
28
- /** Custom className for trigger button */
29
- className?: string;
30
- /** Number of months to display in range mode */
31
- numberOfMonths?: number;
32
- /** Default to range mode when opening */
33
- defaultRangeMode?: boolean;
34
- }
35
-
36
- export function DateSelectorMultiple({
37
- CalendarIcon,
38
- ChevronDownIcon,
39
- value,
40
- onChange,
41
- placeholder,
42
- dateFormat = "yyyy/MM/dd",
43
- className = "",
44
- numberOfMonths = 2,
45
- defaultRangeMode = false,
46
- }: DateSelectorMultipleProps) {
47
- // Popover open state
48
- const [isOpen, setIsOpen] = React.useState(false);
49
-
50
- // Temp states (managed internally)
51
- const [tempIsRangeMode, setTempIsRangeMode] = React.useState(defaultRangeMode);
52
- const [tempSingleDate, setTempSingleDate] = React.useState<Date | undefined>();
53
- const [tempDateRange, setTempDateRange] = React.useState<DateRange | undefined>();
54
- const [currentMonth, setCurrentMonth] = React.useState<Date>(new Date());
55
-
56
- // Initialize temp states when popover opens
57
- React.useEffect(() => {
58
- if (isOpen) {
59
- if (value?.type === "range") {
60
- setTempIsRangeMode(true);
61
- setTempDateRange({ from: value.from, to: value.to });
62
- setTempSingleDate(undefined);
63
- setCurrentMonth(value.from);
64
- } else if (value?.type === "single") {
65
- setTempIsRangeMode(false);
66
- setTempSingleDate(value.date);
67
- setTempDateRange(undefined);
68
- setCurrentMonth(value.date);
69
- } else {
70
- setTempIsRangeMode(defaultRangeMode);
71
- setTempSingleDate(undefined);
72
- setTempDateRange(undefined);
73
- setCurrentMonth(new Date());
74
- }
75
- }
76
- }, [isOpen, value, defaultRangeMode]);
77
-
78
- const getDisplayDate = () => {
79
- if (!value) {
80
- // 날짜선택이 안된 경우
81
- return placeholder ?? `- ${format(new Date(), dateFormat)}`;
82
- }
83
- if (value.type === "single") {
84
- return format(value.date, dateFormat);
85
- }
86
- return `${format(value.from, dateFormat)} - ${format(value.to, dateFormat)}`;
87
- };
88
-
89
- const isSaveEnabled = () => {
90
- if (tempIsRangeMode) {
91
- return !!(tempDateRange?.from && tempDateRange?.to);
92
- }
93
- return tempSingleDate !== undefined;
94
- };
95
-
96
- const handleModeChange = (isRangeMode: boolean) => {
97
- setTempIsRangeMode(isRangeMode);
98
- if (isRangeMode) {
99
- setTempSingleDate(undefined);
100
- } else {
101
- setTempDateRange(undefined);
102
- }
103
- };
104
-
105
- const handleSave = () => {
106
- if (onChange) {
107
- if (tempIsRangeMode && tempDateRange?.from && tempDateRange?.to) {
108
- onChange(null, {
109
- value: {
110
- type: "range",
111
- from: tempDateRange.from,
112
- to: tempDateRange.to,
113
- },
114
- });
115
- } else if (!tempIsRangeMode && tempSingleDate) {
116
- onChange(null, { value: { type: "single", date: tempSingleDate } });
117
- }
118
- }
119
- setIsOpen(false);
120
- };
121
-
122
- const handleCancel = () => {
123
- setIsOpen(false);
124
- };
125
-
126
- return (
127
- <div className="flex items-center justify-between">
128
- <Popover open={isOpen} onOpenChange={setIsOpen}>
129
- <PopoverTrigger asChild>
130
- <Button variant="outline" className={`gap-2 h-8 text-xs ${className}`}>
131
- <CalendarIcon className="h-4 w-4" />
132
- {getDisplayDate()}
133
- <ChevronDownIcon className="h-4 w-4" />
134
- </Button>
135
- </PopoverTrigger>
136
- <PopoverContent className="w-auto p-0" align="start">
137
- <div className="p-3 border-b space-y-2">
138
- <div className="flex gap-2">
139
- <Button
140
- variant={!tempIsRangeMode ? "default" : "outline"}
141
- size="sm"
142
- onClick={() => handleModeChange(false)}
143
- className="flex-1 h-7 text-xs"
144
- >
145
- Single Date
146
- </Button>
147
- <Button
148
- variant={tempIsRangeMode ? "default" : "outline"}
149
- size="sm"
150
- onClick={() => handleModeChange(true)}
151
- className="flex-1 h-7 text-xs"
152
- >
153
- Date Range
154
- </Button>
155
- </div>
156
- </div>
157
- {tempIsRangeMode ? (
158
- <Calendar
159
- mode="range"
160
- selected={tempDateRange}
161
- onSelect={setTempDateRange}
162
- numberOfMonths={numberOfMonths}
163
- month={currentMonth}
164
- onMonthChange={setCurrentMonth}
165
- disabled={(date) => {
166
- if (!tempDateRange?.from || tempDateRange?.to) return false;
167
- return date < tempDateRange.from;
168
- }}
169
- />
170
- ) : (
171
- <Calendar
172
- mode="single"
173
- selected={tempSingleDate}
174
- onSelect={setTempSingleDate}
175
- month={currentMonth}
176
- onMonthChange={setCurrentMonth}
177
- />
178
- )}
179
- <div className="p-3 border-t flex justify-end gap-2">
180
- <Button variant="outline" size="sm" onClick={handleCancel} className="h-8 text-xs">
181
- Cancel
182
- </Button>
183
- <Button
184
- variant="default"
185
- size="sm"
186
- onClick={handleSave}
187
- disabled={!isSaveEnabled()}
188
- className="h-8 text-xs"
189
- >
190
- Save
191
- </Button>
192
- </div>
193
- </PopoverContent>
194
- </Popover>
195
- </div>
196
- );
197
- }
@@ -1,104 +0,0 @@
1
- "use client";
2
-
3
- import * as DialogPrimitive from "@radix-ui/react-dialog";
4
- import * as React from "react";
5
- import XIcon from "~icons/lucide/x";
6
-
7
- import { cn } from "../../lib/utils";
8
-
9
- const Dialog = DialogPrimitive.Root;
10
-
11
- const DialogTrigger = DialogPrimitive.Trigger;
12
-
13
- const DialogPortal = DialogPrimitive.Portal;
14
-
15
- const DialogClose = DialogPrimitive.Close;
16
-
17
- const DialogOverlay = React.forwardRef<
18
- React.ElementRef<typeof DialogPrimitive.Overlay>,
19
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
20
- >(({ className, ...props }, ref) => (
21
- <DialogPrimitive.Overlay
22
- ref={ref}
23
- className={cn(
24
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
25
- className,
26
- )}
27
- {...props}
28
- />
29
- ));
30
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
31
-
32
- const DialogContent = React.forwardRef<
33
- React.ElementRef<typeof DialogPrimitive.Content>,
34
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
35
- >(({ className, children, ...props }, ref) => (
36
- <DialogPortal>
37
- <DialogOverlay />
38
- <DialogPrimitive.Content
39
- ref={ref}
40
- className={cn(
41
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
42
- className,
43
- )}
44
- {...props}
45
- >
46
- {children}
47
- <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
48
- <XIcon className="h-4 w-4" />
49
- <span className="sr-only">Close</span>
50
- </DialogPrimitive.Close>
51
- </DialogPrimitive.Content>
52
- </DialogPortal>
53
- ));
54
- DialogContent.displayName = DialogPrimitive.Content.displayName;
55
-
56
- const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
57
- <div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
58
- );
59
- DialogHeader.displayName = "DialogHeader";
60
-
61
- const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
62
- <div
63
- className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
64
- {...props}
65
- />
66
- );
67
- DialogFooter.displayName = "DialogFooter";
68
-
69
- const DialogTitle = React.forwardRef<
70
- React.ElementRef<typeof DialogPrimitive.Title>,
71
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
72
- >(({ className, ...props }, ref) => (
73
- <DialogPrimitive.Title
74
- ref={ref}
75
- className={cn("text-lg font-semibold leading-none tracking-tight", className)}
76
- {...props}
77
- />
78
- ));
79
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
80
-
81
- const DialogDescription = React.forwardRef<
82
- React.ElementRef<typeof DialogPrimitive.Description>,
83
- React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
84
- >(({ className, ...props }, ref) => (
85
- <DialogPrimitive.Description
86
- ref={ref}
87
- className={cn("text-sm text-muted-foreground", className)}
88
- {...props}
89
- />
90
- ));
91
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
92
-
93
- export {
94
- Dialog,
95
- DialogPortal,
96
- DialogOverlay,
97
- DialogClose,
98
- DialogTrigger,
99
- DialogContent,
100
- DialogHeader,
101
- DialogFooter,
102
- DialogTitle,
103
- DialogDescription,
104
- };
@@ -1,100 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { Drawer as DrawerPrimitive } from "vaul";
5
-
6
- import { cn } from "../../lib/utils";
7
-
8
- const Drawer = ({
9
- shouldScaleBackground = true,
10
- ...props
11
- }: React.ComponentProps<typeof DrawerPrimitive.Root>) => (
12
- <DrawerPrimitive.Root shouldScaleBackground={shouldScaleBackground} {...props} />
13
- );
14
- Drawer.displayName = "Drawer";
15
-
16
- const DrawerTrigger = DrawerPrimitive.Trigger;
17
-
18
- const DrawerPortal = DrawerPrimitive.Portal;
19
-
20
- const DrawerClose = DrawerPrimitive.Close;
21
-
22
- const DrawerOverlay = React.forwardRef<
23
- React.ElementRef<typeof DrawerPrimitive.Overlay>,
24
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>
25
- >(({ className, ...props }, ref) => (
26
- <DrawerPrimitive.Overlay
27
- ref={ref}
28
- className={cn("fixed inset-0 z-50 bg-black/80", className)}
29
- {...props}
30
- />
31
- ));
32
- DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
33
-
34
- const DrawerContent = React.forwardRef<
35
- React.ElementRef<typeof DrawerPrimitive.Content>,
36
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Content>
37
- >(({ className, children, ...props }, ref) => (
38
- <DrawerPortal>
39
- <DrawerOverlay />
40
- <DrawerPrimitive.Content
41
- ref={ref}
42
- className={cn(
43
- "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background",
44
- className,
45
- )}
46
- {...props}
47
- >
48
- <div className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
49
- {children}
50
- </DrawerPrimitive.Content>
51
- </DrawerPortal>
52
- ));
53
- DrawerContent.displayName = "DrawerContent";
54
-
55
- const DrawerHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
56
- <div className={cn("grid gap-1.5 p-4 text-center sm:text-left", className)} {...props} />
57
- );
58
- DrawerHeader.displayName = "DrawerHeader";
59
-
60
- const DrawerFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
61
- <div className={cn("mt-auto flex flex-col gap-2 p-4", className)} {...props} />
62
- );
63
- DrawerFooter.displayName = "DrawerFooter";
64
-
65
- const DrawerTitle = React.forwardRef<
66
- React.ElementRef<typeof DrawerPrimitive.Title>,
67
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>
68
- >(({ className, ...props }, ref) => (
69
- <DrawerPrimitive.Title
70
- ref={ref}
71
- className={cn("text-lg font-semibold leading-none tracking-tight", className)}
72
- {...props}
73
- />
74
- ));
75
- DrawerTitle.displayName = DrawerPrimitive.Title.displayName;
76
-
77
- const DrawerDescription = React.forwardRef<
78
- React.ElementRef<typeof DrawerPrimitive.Description>,
79
- React.ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>
80
- >(({ className, ...props }, ref) => (
81
- <DrawerPrimitive.Description
82
- ref={ref}
83
- className={cn("text-sm text-muted-foreground", className)}
84
- {...props}
85
- />
86
- ));
87
- DrawerDescription.displayName = DrawerPrimitive.Description.displayName;
88
-
89
- export {
90
- Drawer,
91
- DrawerPortal,
92
- DrawerOverlay,
93
- DrawerTrigger,
94
- DrawerClose,
95
- DrawerContent,
96
- DrawerHeader,
97
- DrawerFooter,
98
- DrawerTitle,
99
- DrawerDescription,
100
- };