Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/styled/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@power-rent/react-datepicker-modern",
"version": "1.0.1",
"version": "1.0.2",
"description": "A React datepicker build with styled-components.",
"keywords": [
"datepicker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ export interface DateRangeInputModernProps extends UseDatepickerProps {
initialVisibleMonth?: Date
startDateLabel?: string
endDateLabel?: string
datepickerSelectDateGridTemplateColumns?: string
datepickerBorderRadiusCustom?: string
datepickerWidthCustom?: string
datepickerHeightCustom?: string
datepickerLeftCustom?: string
datepickerTopCustom?: string
}

function DateRangeInputModern({
Expand Down Expand Up @@ -144,6 +150,12 @@ function DateRangeInputModern({
unavailableDates = [],
startDateLabel = 'From',
endDateLabel = 'To',
datepickerSelectDateGridTemplateColumns,
datepickerBorderRadiusCustom,
datepickerWidthCustom,
datepickerHeightCustom,
datepickerLeftCustom,
datepickerTopCustom,
}: DateRangeInputModernProps) {
const ref = useRef(null)
const datepickerWrapperRef = useRef<HTMLDivElement>(null)
Expand All @@ -162,6 +174,9 @@ function DateRangeInputModern({
dateRangeStartDateInputPadding: vertical ? (rtl ? '0 32px 0 8px' : '0 8px 0 32px') : '0 0x',
dateRangeEndDateInputPadding: vertical ? (rtl ? '0 32px 0 8px' : '0 8px 0 32px') : '0 0px',
dateRangeDatepickerWrapperPosition: 'absolute',
datepickerHeight: 'unset',
datepickerLeft: '0px',
datepickerTop: '0px',
...getPlacement(placement, rtl),
})

Expand Down Expand Up @@ -253,8 +268,8 @@ function DateRangeInputModern({
<Box
position={theme.dateRangeDatepickerWrapperPosition}
bottom={theme.dateRangeDatepickerWrapperBottom}
left={theme.dateRangeDatepickerWrapperLeft}
top={theme.dateRangeDatepickerWrapperTop}
left={datepickerLeftCustom || theme.dateRangeDatepickerWrapperLeft}
top={datepickerTopCustom || theme.dateRangeDatepickerWrapperTop}
right={theme.dateRangeDatepickerWrapperRight}
Comment thread
MrsLecter marked this conversation as resolved.
>
{focusedInput !== null && (
Expand Down Expand Up @@ -285,6 +300,10 @@ function DateRangeInputModern({
unavailableDates={unavailableDates}
ref={ref}
initialVisibleMonth={initialVisibleMonth}
datepickerSelectDateGridTemplateColumns={datepickerSelectDateGridTemplateColumns}
datepickerBorderRadius={datepickerBorderRadiusCustom}
datepickerWidth={datepickerWidthCustom}
datepickerHeight={datepickerHeightCustom}
/>
)}
</Box>
Expand Down
34 changes: 29 additions & 5 deletions packages/styled/src/components/Datepicker/Datepicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ interface StyledDatepicker
ZIndexProps,
BoxShadowProps {
rtl: boolean
height: string
left: string
top: string
}
const composeStyledDatepickerStyles = compose(
background,
Expand All @@ -85,7 +88,10 @@ const composeStyledDatepickerStyles = compose(
)

const StyledDatepicker = styled('div')<StyledDatepicker>`
${composeStyledDatepickerStyles}
${composeStyledDatepickerStyles};
height: ${({height}) => height || 'unset'};
left: ${({left}) => left || 'unset'};
top: ${({top}) => top || 'unset'};
${({rtl}) =>
rtl &&
css`
Expand Down Expand Up @@ -141,6 +147,12 @@ export interface DatepickerProps extends UseDatepickerProps {
monthLabelFormat?(date: Date): string
onDayRender?(date: Date): React.ReactNode
unavailableDates?: Date[]
datepickerSelectDateGridTemplateColumns?: string
datepickerWidth?: string
datepickerBorderRadius?: string
datepickerHeight?: string
datepickerLeft?: string
datepickerTop?: string
}

function Datepicker(
Expand Down Expand Up @@ -170,6 +182,12 @@ function Datepicker(
displayFormat = 'MM/dd/yyyy',
phrases = datepickerPhrases,
unavailableDates = [],
datepickerSelectDateGridTemplateColumns = '',
datepickerWidth = '',
datepickerBorderRadius = '',
datepickerHeight = 'unset',
datepickerLeft = '0px',
datepickerTop = '0px',
}: DatepickerProps,
ref?: React.Ref<unknown>,
) {
Expand Down Expand Up @@ -214,11 +232,11 @@ function Datepicker(
const themeContext = useContext(ThemeContext)
const theme: DatepickerTheme = useThemeProps({
datepickerZIndex: null,
datepickerBackground: '#ffffff',
datepickerBackground: '#ffffff !important',
datepickerPadding: vertical ? '16px 16px 0' : '32px',
datepickerBorderRadius: '2px',
datepickerPosition: 'relative',
datepickerWidth: 'fit-content',
datepickerWidth: datepickerWidth || 'fit-content',
datepickerCloseWrapperPosition: vertical ? 'relative' : 'absolute',
datepickerCloseWrapperDisplay: vertical ? 'flex' : 'block',
datepickerCloseWrapperJustifyContent: vertical ? 'flex-end' : 'initial',
Expand Down Expand Up @@ -292,12 +310,15 @@ function Datepicker(
<StyledDatepicker
background={theme.datepickerBackground}
p={theme.datepickerPadding}
borderRadius={theme.datepickerBorderRadius}
borderRadius={datepickerBorderRadius || theme.datepickerBorderRadius}
position={theme.datepickerPosition}
boxShadow={theme.datepickerBoxShadow}
width={theme.datepickerWidth}
height={datepickerHeight}
zIndex={theme.datepickerZIndex}
rtl={rtl}
left={datepickerLeft}
top={datepickerTop}
>
{showClose && (
<CloseWrapper
Expand All @@ -319,7 +340,10 @@ function Datepicker(
<DateWrapper>
<Grid
data-testid="SelectedDatesGrid"
gridTemplateColumns={theme.datepickerSelectDateGridTemplateColumns}
gridTemplateColumns={
datepickerSelectDateGridTemplateColumns ||
theme.datepickerSelectDateGridTemplateColumns
}
gridTemplateRows={theme.datepickerSelectDateGridTemplateRows}
>
<SelectedDate
Expand Down