-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support editable input | min & max dates | dd-mm-yyyy format in…
… CalendarInput (#1504) * feat: support min & max dates * chore: add story CalendarWithEditiableInput * chore: refactor code * fix: improve calendar component for independent use * fix: lint warnings * refactor: use calendar inner components directly to avoid double calls to multi-calendar library * fix: pass isValid to calendarProps * refactor: extract calendar table into shared component * chore: rename passed props * fix: label in storybook * fix: lint issue --------- Co-authored-by: Mozafar Haider <mozafar@dhis2.org>
- v10.3.0
- v10.2.0
- v10.1.13
- v10.1.12
- v10.1.11
- v10.1.10
- v10.1.9
- v10.1.8
- v10.1.7
- v10.1.6
- v10.1.5
- v10.1.4
- v10.1.3
- v10.1.2
- v10.1.1
- v10.1.0
- v10.0.4
- v10.0.3
- v10.0.2
- v10.0.1
- v10.0.0
- v10.0.0-alpha.8
- v10.0.0-alpha.7
- v10.0.0-alpha.6
- v10.0.0-alpha.5
- v10.0.0-alpha.4
- v10.0.0-alpha.3
- v10.0.0-alpha.2
- v10.0.0-alpha.1
- v9.12.0-alpha.4
- v9.12.0-alpha.3
- v9.12.0-alpha.2
- v9.12.0-alpha.1
- v9.9.0-alpha.6
- v9.9.0-alpha.5
- v9.9.0-alpha.4
- v9.9.0-alpha.3
- v9.9.0-alpha.2
1 parent
6341a01
commit 99a78f5
Showing
8 changed files
with
252 additions
and
113 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,92 @@ | ||
import { colors } from '@dhis2/ui-constants' | ||
import PropTypes from 'prop-types' | ||
import React, { useMemo } from 'react' | ||
import { CalendarTable, CalendarTableProps } from './calendar-table.js' | ||
import { | ||
NavigationContainer, | ||
NavigationContainerProps, | ||
} from './navigation-container.js' | ||
|
||
const wrapperBorderColor = colors.grey300 | ||
const backgroundColor = 'none' | ||
|
||
export const CalendarContainer = ({ | ||
date, | ||
width, | ||
cellSize, | ||
calendarWeekDays, | ||
weekDayLabels, | ||
currMonth, | ||
currYear, | ||
nextMonth, | ||
nextYear, | ||
prevMonth, | ||
prevYear, | ||
languageDirection, | ||
}) => { | ||
const navigationProps = useMemo(() => { | ||
return { | ||
currMonth, | ||
currYear, | ||
nextMonth, | ||
nextYear, | ||
prevMonth, | ||
prevYear, | ||
languageDirection, | ||
} | ||
}, [ | ||
currMonth, | ||
currYear, | ||
languageDirection, | ||
nextMonth, | ||
nextYear, | ||
prevMonth, | ||
prevYear, | ||
]) | ||
return ( | ||
<div> | ||
<div | ||
className="calendar-wrapper" | ||
dir={languageDirection} | ||
data-test="calendar" | ||
> | ||
<NavigationContainer {...navigationProps} /> | ||
<CalendarTable | ||
selectedDate={date} | ||
calendarWeekDays={calendarWeekDays} | ||
weekDayLabels={weekDayLabels} | ||
cellSize={cellSize} | ||
width={width} | ||
/> | ||
</div> | ||
<style jsx>{` | ||
.calendar-wrapper { | ||
font-family: Roboto, sans-serif; | ||
font-weight: 400; | ||
font-size: 14px; | ||
background-color: ${backgroundColor}; | ||
display: flex; | ||
flex-direction: column; | ||
border: 1px solid ${wrapperBorderColor}; | ||
border-radius: 3px; | ||
min-width: ${width}; | ||
width: max-content; | ||
box-shadow: 0px 4px 6px -2px #2129340d; | ||
box-shadow: 0px 10px 15px -3px #2129341a; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
} | ||
|
||
CalendarContainer.defaultProps = { | ||
cellSize: '32px', | ||
width: '240px', | ||
} | ||
|
||
CalendarContainer.propTypes = { | ||
/** the currently selected date using an iso-like format YYYY-MM-DD, in the calendar system provided (not iso8601) */ | ||
date: PropTypes.string, | ||
...CalendarTableProps, | ||
...NavigationContainerProps, | ||
} |
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
Oops, something went wrong.