minka-ds 0.2.7 → 0.2.8
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/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Calendar } from "./calendar"
|
|
5
|
+
import { Input } from "./input"
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
export interface DateTimeValue {
|
|
9
|
+
date: Date | null
|
|
10
|
+
time: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface DateTimePickerProps {
|
|
14
|
+
value?: DateTimeValue | null
|
|
15
|
+
onChange: (value: DateTimeValue | null) => void
|
|
16
|
+
className?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function DateTimePicker({
|
|
20
|
+
value,
|
|
21
|
+
onChange,
|
|
22
|
+
className,
|
|
23
|
+
}: DateTimePickerProps) {
|
|
24
|
+
function handleDaySelect(selected: Date | undefined) {
|
|
25
|
+
if (!selected) { onChange(null); return }
|
|
26
|
+
onChange({ date: selected, time: value?.time ?? "" })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function handleTime(e: React.ChangeEvent<HTMLInputElement>) {
|
|
30
|
+
if (!value?.date) return
|
|
31
|
+
onChange({ ...value, time: e.target.value })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className={cn(
|
|
36
|
+
"[border-radius:var(--radius-card)] border border-[var(--color-border-default)] bg-[var(--color-bg-raised)] overflow-hidden w-fit",
|
|
37
|
+
className
|
|
38
|
+
)}>
|
|
39
|
+
<Calendar
|
|
40
|
+
mode="single"
|
|
41
|
+
captionLayout="label"
|
|
42
|
+
selected={value?.date ?? undefined}
|
|
43
|
+
onSelect={handleDaySelect}
|
|
44
|
+
/>
|
|
45
|
+
<div className="border-t border-[var(--color-border-default)] px-4 py-3">
|
|
46
|
+
<div className="flex flex-col gap-1.5">
|
|
47
|
+
<label className="text-body-sm">Time</label>
|
|
48
|
+
<Input
|
|
49
|
+
type="time"
|
|
50
|
+
value={value?.time ?? ""}
|
|
51
|
+
onChange={handleTime}
|
|
52
|
+
disabled={!value?.date}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * from "./components/ui/alert"
|
|
|
9
9
|
export * from "./components/ui/badge"
|
|
10
10
|
export * from "./components/ui/breadcrumb"
|
|
11
11
|
export * from "./components/ui/calendar"
|
|
12
|
+
export * from "./components/ui/date-time-picker"
|
|
12
13
|
export * from "./components/ui/date-time-range-picker"
|
|
13
14
|
export * from "./components/ui/cell"
|
|
14
15
|
export * from "./components/ui/button"
|