imperijal-components 0.0.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/INSTALL_AND_USAGE.md +288 -0
- package/PUBLISHING.md +306 -0
- package/README.md +35 -0
- package/package.json +22 -0
- package/packages/date-time-picker/README.md +78 -0
- package/packages/date-time-picker/package.json +82 -0
- package/packages/date-time-picker/src/components/date-calendar-panel.tsx +63 -0
- package/packages/date-time-picker/src/components/date-quick-chips.tsx +45 -0
- package/packages/date-time-picker/src/components/date-time-picker-content.tsx +121 -0
- package/packages/date-time-picker/src/components/date-time-picker.tsx +92 -0
- package/packages/date-time-picker/src/components/time-slot-grid.tsx +122 -0
- package/packages/date-time-picker/src/components/use-date-time-selection.ts +83 -0
- package/packages/date-time-picker/src/index.ts +19 -0
- package/packages/date-time-picker/src/lib/local-input-value.ts +45 -0
- package/packages/date-time-picker/src/lib/quick-dates.ts +59 -0
- package/packages/date-time-picker/src/lib/time-slots.ts +46 -0
- package/packages/date-time-picker/src/lib/utils.ts +6 -0
- package/packages/date-time-picker/src/styles.css +19 -0
- package/packages/date-time-picker/src/ui/button.tsx +51 -0
- package/packages/date-time-picker/src/ui/calendar.tsx +159 -0
- package/packages/date-time-picker/src/ui/collapsible.tsx +23 -0
- package/packages/date-time-picker/src/ui/popover.tsx +41 -0
- package/packages/date-time-picker/tsconfig.json +8 -0
- package/packages/date-time-picker/tsup.config.ts +23 -0
- package/pnpm-workspace.yaml +2 -0
- package/tsconfig.base.json +17 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { DateTimePicker, type DateTimePickerProps } from './components/date-time-picker';
|
|
2
|
+
export {
|
|
3
|
+
DateTimePickerContent,
|
|
4
|
+
type DateTimePickerContentProps,
|
|
5
|
+
} from './components/date-time-picker-content';
|
|
6
|
+
export { useDateTimeSelection } from './components/use-date-time-selection';
|
|
7
|
+
export {
|
|
8
|
+
toLocalInputValue,
|
|
9
|
+
parseLocalInputValue,
|
|
10
|
+
combineLocalDateTime,
|
|
11
|
+
formatLocalInputDisplay,
|
|
12
|
+
} from './lib/local-input-value';
|
|
13
|
+
export {
|
|
14
|
+
generateTimeSlots,
|
|
15
|
+
timeSlotKey,
|
|
16
|
+
type TimeSlot,
|
|
17
|
+
type TimeSlotConfig,
|
|
18
|
+
} from './lib/time-slots';
|
|
19
|
+
export { getQuickDateOptions, type QuickDateOption } from './lib/quick-dates';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for the `datetime-local` value format: `YYYY-MM-DDTHH:mm`
|
|
3
|
+
* (local time, no seconds, no timezone suffix).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Format a Date as a datetime-local string. */
|
|
7
|
+
export function toLocalInputValue(d: Date): string {
|
|
8
|
+
const pad = (n: number) => String(n).padStart(2, '0');
|
|
9
|
+
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Parse a datetime-local string into a Date, or null if invalid. */
|
|
13
|
+
export function parseLocalInputValue(value: string): Date | null {
|
|
14
|
+
if (!value || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(value)) return null;
|
|
15
|
+
const d = new Date(value);
|
|
16
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Combine a calendar date with hours/minutes into a datetime-local string. */
|
|
20
|
+
export function combineLocalDateTime(
|
|
21
|
+
date: Date,
|
|
22
|
+
hours: number,
|
|
23
|
+
minutes: number,
|
|
24
|
+
): string {
|
|
25
|
+
const d = new Date(date);
|
|
26
|
+
d.setHours(hours, minutes, 0, 0);
|
|
27
|
+
return toLocalInputValue(d);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Human-readable label for the trigger button. */
|
|
31
|
+
export function formatLocalInputDisplay(
|
|
32
|
+
value: string,
|
|
33
|
+
placeholder?: string,
|
|
34
|
+
): string {
|
|
35
|
+
const d = parseLocalInputValue(value);
|
|
36
|
+
if (!d) return placeholder ?? 'Select date & time';
|
|
37
|
+
return d.toLocaleString(undefined, {
|
|
38
|
+
month: 'short',
|
|
39
|
+
day: 'numeric',
|
|
40
|
+
year: 'numeric',
|
|
41
|
+
hour: '2-digit',
|
|
42
|
+
minute: '2-digit',
|
|
43
|
+
hour12: false,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addDays,
|
|
3
|
+
format,
|
|
4
|
+
isSaturday,
|
|
5
|
+
isSunday,
|
|
6
|
+
nextSaturday,
|
|
7
|
+
nextSunday,
|
|
8
|
+
startOfDay,
|
|
9
|
+
} from 'date-fns';
|
|
10
|
+
|
|
11
|
+
export type QuickDateOption = {
|
|
12
|
+
id: string;
|
|
13
|
+
label: string;
|
|
14
|
+
sublabel: string;
|
|
15
|
+
date: Date;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function upcomingSaturday(reference: Date): Date {
|
|
19
|
+
return isSaturday(reference) ? startOfDay(reference) : nextSaturday(reference);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function upcomingSunday(reference: Date): Date {
|
|
23
|
+
return isSunday(reference) ? startOfDay(reference) : nextSunday(reference);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Quick-pick chips: Today, Tomorrow, upcoming Sat/Sun. */
|
|
27
|
+
export function getQuickDateOptions(reference = new Date()): QuickDateOption[] {
|
|
28
|
+
const today = startOfDay(reference);
|
|
29
|
+
const tomorrow = addDays(today, 1);
|
|
30
|
+
const saturday = upcomingSaturday(today);
|
|
31
|
+
const sunday = upcomingSunday(today);
|
|
32
|
+
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
id: 'today',
|
|
36
|
+
label: 'Today',
|
|
37
|
+
sublabel: format(today, 'MMM d'),
|
|
38
|
+
date: today,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'tomorrow',
|
|
42
|
+
label: 'Tomorrow',
|
|
43
|
+
sublabel: format(tomorrow, 'MMM d'),
|
|
44
|
+
date: tomorrow,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'saturday',
|
|
48
|
+
label: format(saturday, 'EEE'),
|
|
49
|
+
sublabel: format(saturday, 'MMM d'),
|
|
50
|
+
date: saturday,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: 'sunday',
|
|
54
|
+
label: format(sunday, 'EEE'),
|
|
55
|
+
sublabel: format(sunday, 'MMM d'),
|
|
56
|
+
date: sunday,
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type TimeSlot = {
|
|
2
|
+
hours: number;
|
|
3
|
+
minutes: number;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type TimeSlotConfig = {
|
|
8
|
+
startHour?: number;
|
|
9
|
+
endHour?: number;
|
|
10
|
+
intervalMinutes?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const DEFAULT_CONFIG: Required<TimeSlotConfig> = {
|
|
14
|
+
startHour: 5,
|
|
15
|
+
endHour: 24,
|
|
16
|
+
intervalMinutes: 30,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** Generate half-hour (or custom) time slots for the picker grid. */
|
|
20
|
+
export function generateTimeSlots(config: TimeSlotConfig = {}): TimeSlot[] {
|
|
21
|
+
const { startHour, endHour, intervalMinutes } = {
|
|
22
|
+
...DEFAULT_CONFIG,
|
|
23
|
+
...config,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const slots: TimeSlot[] = [];
|
|
27
|
+
let totalMinutes = startHour * 60;
|
|
28
|
+
const endMinutes = endHour * 60;
|
|
29
|
+
|
|
30
|
+
while (totalMinutes < endMinutes) {
|
|
31
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
32
|
+
const minutes = totalMinutes % 60;
|
|
33
|
+
slots.push({
|
|
34
|
+
hours,
|
|
35
|
+
minutes,
|
|
36
|
+
label: `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`,
|
|
37
|
+
});
|
|
38
|
+
totalMinutes += intervalMinutes;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return slots;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function timeSlotKey(hours: number, minutes: number): string {
|
|
45
|
+
return `${hours}:${minutes}`;
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional theme tokens for apps that don't already use shadcn-style CSS variables.
|
|
3
|
+
* Import in your global CSS: @import '@imperijal/date-time-picker/styles.css';
|
|
4
|
+
*/
|
|
5
|
+
.imperijal-date-time-picker {
|
|
6
|
+
--background: #ffffff;
|
|
7
|
+
--foreground: #0b1c30;
|
|
8
|
+
--popover: #ffffff;
|
|
9
|
+
--popover-foreground: #0b1c30;
|
|
10
|
+
--primary: #004ac6;
|
|
11
|
+
--primary-foreground: #ffffff;
|
|
12
|
+
--secondary: #5c5f61;
|
|
13
|
+
--muted-foreground: #737686;
|
|
14
|
+
--accent: #eff4ff;
|
|
15
|
+
--accent-foreground: #0b1c30;
|
|
16
|
+
--border: #c3c6d7;
|
|
17
|
+
--input: #c3c6d7;
|
|
18
|
+
--ring: #2563eb;
|
|
19
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../lib/utils';
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*="size-"])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
|
|
14
|
+
outline:
|
|
15
|
+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground',
|
|
16
|
+
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
|
|
20
|
+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
|
|
21
|
+
icon: 'size-9',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: 'default',
|
|
26
|
+
size: 'default',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
function Button({
|
|
32
|
+
className,
|
|
33
|
+
variant,
|
|
34
|
+
size,
|
|
35
|
+
asChild = false,
|
|
36
|
+
...props
|
|
37
|
+
}: React.ComponentProps<'button'> &
|
|
38
|
+
VariantProps<typeof buttonVariants> & {
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
}) {
|
|
41
|
+
const Comp = asChild ? Slot : 'button';
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Comp
|
|
45
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { Button, buttonVariants };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import {
|
|
5
|
+
ChevronDownIcon,
|
|
6
|
+
ChevronLeftIcon,
|
|
7
|
+
ChevronRightIcon,
|
|
8
|
+
} from 'lucide-react';
|
|
9
|
+
import { DayButton, DayPicker, getDefaultClassNames } from 'react-day-picker';
|
|
10
|
+
|
|
11
|
+
import { cn } from '../lib/utils';
|
|
12
|
+
import { Button, buttonVariants } from './button';
|
|
13
|
+
|
|
14
|
+
function Calendar({
|
|
15
|
+
className,
|
|
16
|
+
classNames,
|
|
17
|
+
showOutsideDays = true,
|
|
18
|
+
captionLayout = 'label',
|
|
19
|
+
buttonVariant = 'ghost',
|
|
20
|
+
formatters,
|
|
21
|
+
components,
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DayPicker> & {
|
|
24
|
+
buttonVariant?: React.ComponentProps<typeof Button>['variant'];
|
|
25
|
+
}) {
|
|
26
|
+
const defaultClassNames = getDefaultClassNames();
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<DayPicker
|
|
30
|
+
showOutsideDays={showOutsideDays}
|
|
31
|
+
className={cn(
|
|
32
|
+
'bg-background group/calendar p-3 [--cell-size:2.5rem]',
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
captionLayout={captionLayout}
|
|
36
|
+
formatters={{
|
|
37
|
+
formatMonthDropdown: (date) =>
|
|
38
|
+
date.toLocaleString('default', { month: 'short' }),
|
|
39
|
+
...formatters,
|
|
40
|
+
}}
|
|
41
|
+
classNames={{
|
|
42
|
+
root: cn('w-fit', defaultClassNames.root),
|
|
43
|
+
months: cn(
|
|
44
|
+
'flex gap-4 flex-col md:flex-row relative',
|
|
45
|
+
defaultClassNames.months,
|
|
46
|
+
),
|
|
47
|
+
month: cn('flex flex-col w-full gap-4', defaultClassNames.month),
|
|
48
|
+
nav: cn(
|
|
49
|
+
'flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between',
|
|
50
|
+
defaultClassNames.nav,
|
|
51
|
+
),
|
|
52
|
+
button_previous: cn(
|
|
53
|
+
buttonVariants({ variant: buttonVariant }),
|
|
54
|
+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
|
|
55
|
+
defaultClassNames.button_previous,
|
|
56
|
+
),
|
|
57
|
+
button_next: cn(
|
|
58
|
+
buttonVariants({ variant: buttonVariant }),
|
|
59
|
+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
|
|
60
|
+
defaultClassNames.button_next,
|
|
61
|
+
),
|
|
62
|
+
month_caption: cn(
|
|
63
|
+
'flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)',
|
|
64
|
+
defaultClassNames.month_caption,
|
|
65
|
+
),
|
|
66
|
+
caption_label: cn(
|
|
67
|
+
'select-none font-medium text-sm',
|
|
68
|
+
defaultClassNames.caption_label,
|
|
69
|
+
),
|
|
70
|
+
table: 'w-full border-collapse',
|
|
71
|
+
weekdays: cn('flex', defaultClassNames.weekdays),
|
|
72
|
+
weekday: cn(
|
|
73
|
+
'text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none',
|
|
74
|
+
defaultClassNames.weekday,
|
|
75
|
+
),
|
|
76
|
+
week: cn('flex w-full mt-2', defaultClassNames.week),
|
|
77
|
+
day: cn(
|
|
78
|
+
'relative w-full h-full p-0 text-center group/day aspect-square select-none',
|
|
79
|
+
defaultClassNames.day,
|
|
80
|
+
),
|
|
81
|
+
outside: cn(
|
|
82
|
+
'text-muted-foreground aria-selected:text-muted-foreground',
|
|
83
|
+
defaultClassNames.outside,
|
|
84
|
+
),
|
|
85
|
+
disabled: cn(
|
|
86
|
+
'text-muted-foreground opacity-50',
|
|
87
|
+
defaultClassNames.disabled,
|
|
88
|
+
),
|
|
89
|
+
hidden: cn('invisible', defaultClassNames.hidden),
|
|
90
|
+
...classNames,
|
|
91
|
+
}}
|
|
92
|
+
components={{
|
|
93
|
+
Chevron: ({ className, orientation, ...chevronProps }) => {
|
|
94
|
+
if (orientation === 'left') {
|
|
95
|
+
return (
|
|
96
|
+
<ChevronLeftIcon
|
|
97
|
+
className={cn('size-4', className)}
|
|
98
|
+
{...chevronProps}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (orientation === 'right') {
|
|
103
|
+
return (
|
|
104
|
+
<ChevronRightIcon
|
|
105
|
+
className={cn('size-4', className)}
|
|
106
|
+
{...chevronProps}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return (
|
|
111
|
+
<ChevronDownIcon
|
|
112
|
+
className={cn('size-4', className)}
|
|
113
|
+
{...chevronProps}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
},
|
|
117
|
+
DayButton: CalendarDayButton,
|
|
118
|
+
...components,
|
|
119
|
+
}}
|
|
120
|
+
{...props}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function CalendarDayButton({
|
|
126
|
+
className,
|
|
127
|
+
day,
|
|
128
|
+
modifiers,
|
|
129
|
+
...props
|
|
130
|
+
}: React.ComponentProps<typeof DayButton>) {
|
|
131
|
+
const defaultClassNames = getDefaultClassNames();
|
|
132
|
+
const ref = React.useRef<HTMLButtonElement>(null);
|
|
133
|
+
|
|
134
|
+
React.useEffect(() => {
|
|
135
|
+
if (modifiers.focused) ref.current?.focus();
|
|
136
|
+
}, [modifiers.focused]);
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<Button
|
|
140
|
+
ref={ref}
|
|
141
|
+
variant="ghost"
|
|
142
|
+
size="icon"
|
|
143
|
+
data-selected-single={
|
|
144
|
+
modifiers.selected &&
|
|
145
|
+
!modifiers.range_start &&
|
|
146
|
+
!modifiers.range_end &&
|
|
147
|
+
!modifiers.range_middle
|
|
148
|
+
}
|
|
149
|
+
className={cn(
|
|
150
|
+
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground flex aspect-square size-auto w-full min-w-(--cell-size) font-normal',
|
|
151
|
+
defaultClassNames.day,
|
|
152
|
+
className,
|
|
153
|
+
)}
|
|
154
|
+
{...props}
|
|
155
|
+
/>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { Calendar };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
4
|
+
|
|
5
|
+
function Collapsible({
|
|
6
|
+
...props
|
|
7
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
|
|
8
|
+
return <CollapsiblePrimitive.Root {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function CollapsibleTrigger({
|
|
12
|
+
...props
|
|
13
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
|
|
14
|
+
return <CollapsiblePrimitive.CollapsibleTrigger {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CollapsibleContent({
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
|
|
20
|
+
return <CollapsiblePrimitive.CollapsibleContent {...props} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { Collapsible, CollapsibleTrigger, CollapsibleContent };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
5
|
+
|
|
6
|
+
import { cn } from '../lib/utils';
|
|
7
|
+
|
|
8
|
+
function Popover({
|
|
9
|
+
...props
|
|
10
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
|
11
|
+
return <PopoverPrimitive.Root {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function PopoverTrigger({
|
|
15
|
+
...props
|
|
16
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
|
17
|
+
return <PopoverPrimitive.Trigger {...props} />;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function PopoverContent({
|
|
21
|
+
className,
|
|
22
|
+
align = 'center',
|
|
23
|
+
sideOffset = 4,
|
|
24
|
+
...props
|
|
25
|
+
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
|
26
|
+
return (
|
|
27
|
+
<PopoverPrimitive.Portal>
|
|
28
|
+
<PopoverPrimitive.Content
|
|
29
|
+
align={align}
|
|
30
|
+
sideOffset={sideOffset}
|
|
31
|
+
className={cn(
|
|
32
|
+
'bg-popover text-popover-foreground z-50 w-72 origin-[--radix-popover-content-transform-origin] rounded-md border p-4 shadow-md outline-none',
|
|
33
|
+
className,
|
|
34
|
+
)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
</PopoverPrimitive.Portal>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { Popover, PopoverTrigger, PopoverContent };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
format: ['esm', 'cjs'],
|
|
6
|
+
dts: true,
|
|
7
|
+
sourcemap: true,
|
|
8
|
+
clean: true,
|
|
9
|
+
treeshake: true,
|
|
10
|
+
external: [
|
|
11
|
+
'react',
|
|
12
|
+
'react-dom',
|
|
13
|
+
'date-fns',
|
|
14
|
+
'lucide-react',
|
|
15
|
+
'react-day-picker',
|
|
16
|
+
'@radix-ui/react-popover',
|
|
17
|
+
'@radix-ui/react-collapsible',
|
|
18
|
+
'@radix-ui/react-slot',
|
|
19
|
+
'class-variance-authority',
|
|
20
|
+
'clsx',
|
|
21
|
+
'tailwind-merge',
|
|
22
|
+
],
|
|
23
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"resolveJsonModule": true
|
|
16
|
+
}
|
|
17
|
+
}
|