diff --git a/example/index.tsx b/example/index.tsx index 8a4237e..5310f4a 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -1,5 +1,5 @@ import 'react-app-polyfill/ie11'; -import React, { useState } from 'react'; +import React, { useRef, useState } from 'react'; import ReactDOM from 'react-dom'; import { Box, @@ -12,6 +12,13 @@ import { Heading, HStack, Link, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, StackDivider, Switch, Tab, @@ -22,6 +29,7 @@ import { Text, ThemeConfig, useColorMode, + useDisclosure, VStack, } from '@chakra-ui/react'; import { @@ -51,6 +59,8 @@ const App = () => { const [firstDayOfWeek, setFirstDayOfWeek] = useState(1); const [isSingleChecked, setSingleCheck] = useState(true); const [isRangeChecked, setRangeCheck] = useState(true); + const { isOpen, onOpen, onClose } = useDisclosure(); + const modalRef = useRef(null); return ( { -
- - closeOnSelect: - setSingleCheck(e.currentTarget.checked)} - /> - - - {/* chakra ui add prefix for the trigger for some reasons? */} - - - - - - - - -
-
- - closeOnSelect: - setRangeCheck(e.currentTarget.checked)} - /> - - - - - - - - - - -
+ +
+ + closeOnSelect: + setSingleCheck(e.currentTarget.checked)} + /> + + + {/* chakra ui add prefix for the trigger for some reasons? */} + + + + + + + + +
+
+ + closeOnSelect: + setRangeCheck(e.currentTarget.checked)} + /> + + + + + + + + + + +
+
+ + + + + Modal Title + + + +
Default:
+ + +
+ if {`usePortal={true}`}
+ please add {`portalRef={modalRef}`} +
+ + +
+
+ + + + +
+
+
+
@@ -498,6 +554,7 @@ const RangeCalendarDemo = () => { const Section: React.FC> = ({ title, children, + sectionProps, }) => ( {title} diff --git a/src/range.tsx b/src/range.tsx index c6fb634..8142aec 100644 --- a/src/range.tsx +++ b/src/range.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useRef, useState } from 'react'; import { Props as DayzedHookProps } from 'dayzed'; import { Month_Names_Short, Weekday_Names_Short } from './utils/calanderUtils'; import { @@ -96,6 +96,7 @@ interface RangeProps extends DatepickerProps { id?: string; name?: string; usePortal?: boolean; + portalRef?: React.MutableRefObject; } export type RangeDatepickerProps = RangeProps & VariantProps; @@ -122,6 +123,7 @@ export const RangeDatepicker: React.FC = (props) => { id, name, usePortal, + portalRef, defaultIsOpen, closeOnSelect, selectedDates, @@ -231,7 +233,7 @@ export const RangeDatepicker: React.FC = (props) => { } }} autoComplete="off" - width={'15rem'} + width={'16rem'} isDisabled={disabled} name={name} value={intVal} @@ -258,7 +260,9 @@ export const RangeDatepicker: React.FC = (props) => { ) : null} {children ? children(selectedDates) : null} - + ; } export type VariantProps = @@ -88,6 +89,7 @@ export const SingleDatepicker: React.FC = (props) => { maxDate, configs, usePortal, + portalRef, disabledDates, defaultIsOpen, triggerVariant, @@ -223,7 +225,9 @@ export const SingleDatepicker: React.FC = (props) => { ) : null} {children ? children(selectedDate) : null} - +