From 9b3deae335e5e81a8dd2e50530be7d8885c40fc5 Mon Sep 17 00:00:00 2001 From: Francis Targanski <107006413+Ftarganski@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:57:07 -0300 Subject: [PATCH] Update DatePicker Component Width Based on Internal Popover (#160) * Atualizar componente DatePicker para usar Popover em vez de div * Atualizar componente DatePicker para usar Popover em vez de div * Atualizar componente DatePicker para usar Popover em vez de div * Atualizar componente DatePicker para usar Popover em vez de div * Atualizar alinhamento e largura do DatePicker --- package/src/App.tsx | 51 ++++++++++-------------- package/src/library/DatePicker/index.tsx | 39 +++++++++--------- package/src/library/Popover/Content.tsx | 18 ++++++--- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/package/src/App.tsx b/package/src/App.tsx index d3abf5f0..ecb03c44 100644 --- a/package/src/App.tsx +++ b/package/src/App.tsx @@ -1,8 +1,8 @@ import LayoutDefault from './layout/Default' -import { Button, DateRange, Drawer, Form, Icon } from './library' +import { Form, DatePicker } from './library' import { zodResolver } from '@hookform/resolvers/zod' -import { Eraser, X } from '@phosphor-icons/react' +import { Eraser, Calendar as CalendarIcon } from '@phosphor-icons/react' import { useState } from 'react' import { SubmitHandler, useForm } from 'react-hook-form' import { z } from 'zod' @@ -13,6 +13,10 @@ const formSchema = z.object({ type FormSchemaProps = z.infer +type DateRange = { + from: Date | undefined + to?: Date | undefined +} function App() { const [test, setTest] = useState() const { @@ -43,8 +47,6 @@ function App() { } } - console.log(selectedDates) - return ( {/* ================================= TEST AREA ================================= */} - - - - - - - Title - - - - - - - -
Anything
-
- - - - - - -
-
+
+ } + mode="multiple" + options={{ + weekday: 'long', + year: 'numeric', + month: 'long', + day: 'numeric', + }} + /> +
{/* ================================= TEST AREA ================================= */}
diff --git a/package/src/library/DatePicker/index.tsx b/package/src/library/DatePicker/index.tsx index d3cb5662..abf9db2e 100644 --- a/package/src/library/DatePicker/index.tsx +++ b/package/src/library/DatePicker/index.tsx @@ -8,6 +8,8 @@ type DatePickerProps = CalendarProps & { placeholder?: string icon?: InputIconProps['icon'] options?: Intl.DateTimeFormatOptions + className?: string + align?: 'center' | 'start' | 'end' | undefined } export const formatDate = ( @@ -25,7 +27,8 @@ const DatePicker = ({ placeholder, icon, options, - + className, + align, ...rest }: DatePickerProps) => { const formatDates = (dates: Date[]) => { @@ -58,24 +61,22 @@ const DatePicker = ({ } return ( -
- - - - - - - - - - - -
+ + + + + + + + + + + ) } diff --git a/package/src/library/Popover/Content.tsx b/package/src/library/Popover/Content.tsx index 2f77c90b..b87cb466 100644 --- a/package/src/library/Popover/Content.tsx +++ b/package/src/library/Popover/Content.tsx @@ -3,20 +3,28 @@ import { cn } from '@/src/utils/class-merge.helper' import * as RadixPopover from '@radix-ui/react-popover' import { FC } from 'react' -export interface PopoverContentProps extends RadixPopover.PopoverContentProps {} +export interface PopoverContentProps extends RadixPopover.PopoverContentProps { + autoSize?: boolean +} -const PopoverContent: FC = ({ className, ...rest }) => { +const PopoverContent: FC = ({ + className, + autoSize, + ...rest +}) => { return ( ) } - PopoverContent.displayName = 'Popover.Content' - export default PopoverContent