Skip to content

Commit

Permalink
fix: date picker
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Jan 1, 2025
1 parent 6cdea07 commit 15fc2ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tremor Date Picker [v1.0.4]
// Tremor Date Picker [v1.0.5]

"use client"

Expand Down Expand Up @@ -56,7 +56,7 @@ const TimeSegment = ({ segment, state }: TimeSegmentProps) => {
const { segmentProps } = useDateSegment(segment, state, ref)

const isColon = segment.type === "literal" && segment.text === ":"
const isSpace = segment.type === "literal" && segment.text === ""
const isSpace = segment.type === "literal" && segment.text === " "

const isDecorator = isColon || isSpace

Expand Down Expand Up @@ -99,7 +99,7 @@ const TimeSegment = ({ segment, state }: TimeSegmentProps) => {
>
{segment.placeholder}
</span>
{segment.isPlaceholder ? "" : segment.text}
{segment.isPlaceholder ? " " : segment.text}
</div>
)
}
Expand Down Expand Up @@ -500,7 +500,7 @@ const SingleDatePicker = ({
)
const [month, setMonth] = React.useState<Date | undefined>(date)

const [time, setTime] = React.useState<TimeValue>(
const [time, setTime] = React.useState<TimeValue | null>(
value
? new Time(value.getHours(), value.getMinutes())
: defaultValue
Expand Down Expand Up @@ -562,7 +562,7 @@ const SingleDatePicker = ({
setDate(newDate)
}

const onTimeChange = (time: TimeValue) => {
const onTimeChange = (time: TimeValue | null) => {
setTime(time)

if (!date) {
Expand Down Expand Up @@ -729,14 +729,14 @@ const RangeDatePicker = ({
)
const [month, setMonth] = React.useState<Date | undefined>(range?.from)

const [startTime, setStartTime] = React.useState<TimeValue>(
const [startTime, setStartTime] = React.useState<TimeValue | null>(
value?.from
? new Time(value.from.getHours(), value.from.getMinutes())
: defaultValue?.from
? new Time(defaultValue.from.getHours(), defaultValue.from.getMinutes())
: new Time(0, 0),
)
const [endTime, setEndTime] = React.useState<TimeValue>(
const [endTime, setEndTime] = React.useState<TimeValue | null>(
value?.to
? new Time(value.to.getHours(), value.to.getMinutes())
: defaultValue?.to
Expand Down Expand Up @@ -814,7 +814,7 @@ const RangeDatePicker = ({
setOpen(open)
}

const onTimeChange = (time: TimeValue, pos: "start" | "end") => {
const onTimeChange = (time: TimeValue | null, pos: "start" | "end") => {
switch (pos) {
case "start":
setStartTime(time)
Expand Down
7 changes: 7 additions & 0 deletions src/components/DatePicker/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Tremor Date Picker Changelog

## 1.0.5

### Changes

- Fix: State types
- Fix: TimeInput visibility

## 1.0.4

### Changes
Expand Down

0 comments on commit 15fc2ed

Please sign in to comment.