-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b72225
commit 59647b5
Showing
11 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type DeviceOAuthConfigType = { | ||
clientId: string | ||
audience: string | ||
scopes: string[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { css } from '@emotion/react' | ||
|
||
export const datePicker = css` | ||
width: 100%; | ||
.react-date-picker { | ||
display: block; | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FC, forwardRef, useEffect, useState } from 'react' | ||
import { default as ReactDatePicker } from 'react-datepicker' | ||
import isFunction from 'lodash/isFunction' | ||
|
||
import { Props } from './DatePicker.types' | ||
|
||
import 'react-datepicker/dist/react-datepicker.css' | ||
import FormInput from '../FormInput' | ||
import IconCalendar from '../Icon/components/IconCalendar' | ||
import * as styles from './DatePicker.styles' | ||
|
||
const DatePicker: FC<Props> = (props) => { | ||
const { className, dataTestId, defaultValue, id, locale, onChange, value } = props | ||
const [startDate, setStartDate] = useState<Date | null>(defaultValue ?? new Date()) | ||
|
||
useEffect(() => { | ||
if (value) { | ||
setStartDate(value) | ||
} | ||
}, [value]) | ||
|
||
const ExampleCustomInput = forwardRef(({ value, onClick }: any, ref) => ( | ||
<FormInput icon={<IconCalendar onClick={onClick} />} inputRef={ref} onChange={() => {}} onClick={onClick} value={value} /> | ||
)) | ||
|
||
return ( | ||
<div className={className} css={styles.datePicker} data-test-id={dataTestId} id={id}> | ||
<ReactDatePicker | ||
customInput={<ExampleCustomInput />} | ||
locale={locale} | ||
onChange={(date) => { | ||
setStartDate(date) | ||
isFunction(onChange) && onChange(date) | ||
}} | ||
selected={startDate} | ||
wrapperClassName='react-date-picker' | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
DatePicker.displayName = 'DatePicker' | ||
|
||
export default DatePicker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export type Props = { | ||
className?: string | ||
dataTestId?: string | ||
defaultValue?: Date | null | ||
id?: string | ||
locale?: string | ||
onChange?: (date: Date | null) => void | ||
value?: Date | null | ||
} | ||
|
||
export const defaultProps: Partial<Props> = { | ||
locale: 'en-GB', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './DatePicker' | ||
export * from './DatePicker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Auto-generated file created by svgr-cli source svg-template.js | ||
// Do not edit directly | ||
import * as React from 'react' | ||
import type { SVGProps } from 'react' | ||
import { Ref, forwardRef, memo } from 'react' | ||
const SvgIconCalendar = (props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => ( | ||
<svg xmlns='http://www.w3.org/2000/svg' width={props.width || 16} height={props.height || 16} viewBox='0 0 24 24' ref={ref} {...props}> | ||
<path fill='currentcolor' d='M6 1v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2v2H8V1zM5 5h14v2H5zm0 4h14v10H5z' /> | ||
</svg> | ||
) | ||
const ForwardRef = forwardRef(SvgIconCalendar) | ||
const Memo = memo(ForwardRef) | ||
export default Memo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters