minka-ds 0.1.9 → 0.2.1
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,92 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import type { DateRange } from "react-day-picker"
|
|
5
|
+
import { Calendar } from "./calendar"
|
|
6
|
+
import { Input } from "./input"
|
|
7
|
+
import { cn } from "../../lib/utils"
|
|
8
|
+
|
|
9
|
+
export interface DateTimeRange {
|
|
10
|
+
from: Date
|
|
11
|
+
to: Date
|
|
12
|
+
startTime: string
|
|
13
|
+
endTime: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DateTimeRangePickerProps {
|
|
17
|
+
value?: DateTimeRange | null
|
|
18
|
+
onChange: (value: DateTimeRange | null) => void
|
|
19
|
+
maxRangeDays?: number
|
|
20
|
+
className?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function DateTimeRangePicker({
|
|
24
|
+
value,
|
|
25
|
+
onChange,
|
|
26
|
+
maxRangeDays,
|
|
27
|
+
className,
|
|
28
|
+
}: DateTimeRangePickerProps) {
|
|
29
|
+
const range: DateRange | undefined =
|
|
30
|
+
value?.from ? { from: value.from, to: value.to } : undefined
|
|
31
|
+
|
|
32
|
+
function handleRangeSelect(selected: DateRange | undefined) {
|
|
33
|
+
if (!selected?.from) { onChange(null); return }
|
|
34
|
+
onChange({
|
|
35
|
+
from: selected.from,
|
|
36
|
+
to: selected.to ?? selected.from,
|
|
37
|
+
startTime: value?.startTime ?? "",
|
|
38
|
+
endTime: value?.endTime ?? "",
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function handleStartTime(e: React.ChangeEvent<HTMLInputElement>) {
|
|
43
|
+
if (!value?.from) return
|
|
44
|
+
onChange({ ...value, startTime: e.target.value })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function handleEndTime(e: React.ChangeEvent<HTMLInputElement>) {
|
|
48
|
+
if (!value?.from) return
|
|
49
|
+
onChange({ ...value, endTime: e.target.value })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const disabledAfter =
|
|
53
|
+
maxRangeDays && range?.from
|
|
54
|
+
? { after: new Date(range.from.getTime() + maxRangeDays * 86_400_000) }
|
|
55
|
+
: undefined
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className={cn(
|
|
59
|
+
"[border-radius:var(--radius-card)] border border-[var(--color-border-default)] bg-[var(--color-bg-raised)] overflow-hidden w-fit",
|
|
60
|
+
className
|
|
61
|
+
)}>
|
|
62
|
+
<Calendar
|
|
63
|
+
mode="range"
|
|
64
|
+
numberOfMonths={1}
|
|
65
|
+
captionLayout="label"
|
|
66
|
+
selected={range}
|
|
67
|
+
onSelect={handleRangeSelect}
|
|
68
|
+
disabled={disabledAfter}
|
|
69
|
+
/>
|
|
70
|
+
<div className="border-t border-[var(--color-border-default)] px-4 py-3 flex flex-col gap-3">
|
|
71
|
+
<div className="flex flex-col gap-1.5">
|
|
72
|
+
<label className="text-body-sm">Start time</label>
|
|
73
|
+
<Input
|
|
74
|
+
type="time"
|
|
75
|
+
value={value?.startTime ?? ""}
|
|
76
|
+
onChange={handleStartTime}
|
|
77
|
+
disabled={!value?.from}
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
<div className="flex flex-col gap-1.5">
|
|
81
|
+
<label className="text-body-sm">End time</label>
|
|
82
|
+
<Input
|
|
83
|
+
type="time"
|
|
84
|
+
value={value?.endTime ?? ""}
|
|
85
|
+
onChange={handleEndTime}
|
|
86
|
+
disabled={!value?.from}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
)
|
|
92
|
+
}
|
|
@@ -53,6 +53,7 @@ interface SearchBarProps {
|
|
|
53
53
|
onClearFilters?: () => void
|
|
54
54
|
filterValueLabel?: (categoryId: string, value: CategoryValue) => string
|
|
55
55
|
alwaysShowFilterBar?: boolean
|
|
56
|
+
size?: "default" | "sm"
|
|
56
57
|
|
|
57
58
|
children?: React.ReactNode
|
|
58
59
|
className?: string
|
|
@@ -75,6 +76,7 @@ function SearchBar({
|
|
|
75
76
|
onClearFilters,
|
|
76
77
|
filterValueLabel = defaultFilterValueLabel,
|
|
77
78
|
alwaysShowFilterBar = false,
|
|
79
|
+
size = "default",
|
|
78
80
|
children,
|
|
79
81
|
className,
|
|
80
82
|
}: SearchBarProps) {
|
|
@@ -88,7 +90,7 @@ function SearchBar({
|
|
|
88
90
|
{/* Search input row */}
|
|
89
91
|
<InputGroup
|
|
90
92
|
className={cn(
|
|
91
|
-
"h-12",
|
|
93
|
+
size === "sm" ? "h-9" : "h-12",
|
|
92
94
|
showFilterBar && "[border-bottom-left-radius:0] [border-bottom-right-radius:0]"
|
|
93
95
|
)}
|
|
94
96
|
>
|
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-range-picker"
|
|
12
13
|
export * from "./components/ui/cell"
|
|
13
14
|
export * from "./components/ui/button"
|
|
14
15
|
export * from "./components/ui/button-group"
|