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
22 changes: 18 additions & 4 deletions src/components/common/DatePickerPopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface DatePickerRangeProps {
export interface DatePickerBaseProps {
yearsLength?: number;
disabledDate?: Matcher;
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
callableElement: HTMLElement | null;
onClose: () => void;
}
Expand All @@ -70,11 +71,11 @@ export const DatePickerPopup: React.FC<DatePickerPopupProps> = props => {
callableElement,
mode,
yearsLength = 100,
position = 'bottom-left',
} = useCombinedPropsWithKit({
name: 'DatePickerPopup',
props,
});

const [month, setMonth] = useState<Date>(
() => (isDateRange(value) ? value.from : value) ?? new Date(),
);
Expand Down Expand Up @@ -115,10 +116,23 @@ export const DatePickerPopup: React.FC<DatePickerPopupProps> = props => {
const observer = new ResizeObserver(entries => {
entries.forEach(entry => {
const isHTMLElement = entry.target instanceof HTMLElement;

if (isHTMLElement && containerRef.current) {
const rect = entry.target.getBoundingClientRect();
containerRef.current.style.top = `${rect.bottom}px`;
containerRef.current.style.left = `${rect.left}px`;
const callableRect = callableElement?.getBoundingClientRect();
if (position?.includes('top')) {
containerRef.current.style.top = `${122}px`;
}

if (position?.includes('bottom')) {
containerRef.current.style.top = `${rect.bottom}px`;
}

if (position?.includes('left')) {
containerRef.current.style.left = `${rect.left}px`;
} else {
containerRef.current.style.right = `${rect.right - Number(callableRect?.width)}px`;
}
}
});
});
Expand All @@ -132,7 +146,7 @@ export const DatePickerPopup: React.FC<DatePickerPopupProps> = props => {
observer.unobserve(callableElement);
}
};
}, [callableElement]);
}, [callableElement, position]);

useEffect(() => {
const calendarElement = containerRef.current;
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Sidebar/Sidebar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const defaultSidebarProps: SidebarProps = {

const defaultUser = {
fullName: 'John Doe',
email: 'johndoe@gmail.com',
email: 'johndoefermfekrfklmerklfklerfklermfklerklmfmklerfklerfmlekrmf@gmail.com',
photoPlaceholder: '/photo-placeholder.svg',
};

Expand Down
3 changes: 3 additions & 0 deletions src/components/form/DateField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type AllowedDateInputProps = Pick<
| 'yearsLength'
| 'mode'
| 'disabled'
| 'position'
>;
type AllowedFieldProps = Pick<
FieldProps,
Expand Down Expand Up @@ -58,6 +59,7 @@ export const DateField = <
rightElement,
iconAfterElementClassName,
inputClassName,
position,
} = useCombinedPropsWithKit({
name: 'DateField',
props,
Expand Down Expand Up @@ -105,6 +107,7 @@ export const DateField = <
inputClassName={inputClassName}
inputSize={inputSize}
placeholder={placeholder ?? label}
position={position}
rightElement={rightElement}
{...propsByMode}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/components/form/DateInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export type DateInputProps = (DatePickerRangeProps | DatePickerDefaultProps) &
rightElement?: ReactNode;
iconAfterElementClassName?: string;
inputClassName?: string;
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
};

export const DateInput: React.FC<DateInputProps> = (props): ReactElement => {
Expand All @@ -47,6 +48,7 @@ export const DateInput: React.FC<DateInputProps> = (props): ReactElement => {
rightElement,
iconAfterElementClassName,
inputClassName,
position,
} = useCombinedPropsWithKit({
name: 'DateInput',
props,
Expand Down Expand Up @@ -160,6 +162,7 @@ export const DateInput: React.FC<DateInputProps> = (props): ReactElement => {
{...propsByMode}
callableElement={inputRef.current}
disabledDate={disabledDate}
position={position}
onClose={closeCalendar}
/>
)}
Expand Down