Skip to content

Commit dfeaa2d

Browse files
committed
flags, toast flags, and date range picker no uses onSelected and onViewChange
1 parent da5113b commit dfeaa2d

File tree

7 files changed

+199
-226
lines changed

7 files changed

+199
-226
lines changed

library/src/components/DateRangePicker.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { FC, useEffect, useState } from "react"
1+
import React, { useEffect, useState } from "react"
22
import dayjs, { Dayjs } from "dayjs"
3-
import Calendar from "@atlaskit/calendar"
3+
import Calendar, { ChangeEvent } from "@atlaskit/calendar"
44
import { WeekDay } from "@atlaskit/calendar/types"
55

66
export class EndDateBeforeStartDateError extends Error {}
@@ -34,7 +34,8 @@ export interface DateRangeProps {
3434

3535
disabled?: boolean
3636

37-
onChange?: (start: string, end: string) => void
37+
onDateRangeSelected: (start: string, end: string) => void
38+
onViewChanged?: (e: ChangeEvent) => void
3839
onCollision?: (dateString: string) => void
3940
}
4041

@@ -115,10 +116,6 @@ export function DateRangePicker(props: DateRangeProps) {
115116
: []
116117

117118
function onDateSelect(value: string) {
118-
if (!props.onChange) {
119-
console.log("DateRangePicker: onChange is not defined")
120-
return
121-
}
122119
const pickedDate = dayjs(value)
123120
const collision = checkCollisions(pickedDate, disabledDates)
124121
if (collision) {
@@ -137,7 +134,7 @@ export function DateRangePicker(props: DateRangeProps) {
137134
setEndDate(undefined)
138135
} else {
139136
setEndDate(pickedDate)
140-
props.onChange(
137+
props.onDateRangeSelected(
141138
toDateString(startDate),
142139
toDateString(pickedDate),
143140
)
@@ -189,6 +186,7 @@ export function DateRangePicker(props: DateRangeProps) {
189186
const selectedDate = event.iso
190187
onDateSelect(selectedDate)
191188
}}
189+
onChange={props.onViewChanged}
192190
locale={props.locale}
193191
weekStartDay={props.weekStartDate}
194192
/>

linked-planet-ui-kit-ts-0.3.0.tgz

-257 KB
Binary file not shown.

0 commit comments

Comments
 (0)