Skip to content

Commit fac625d

Browse files
committed
feat(Pickers): add popup style/positioning props
1 parent 52272a2 commit fac625d

File tree

6 files changed

+33
-3
lines changed

6 files changed

+33
-3
lines changed

src/components/DatePicker/DatePicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {
1616
FocusableProps,
1717
InputDOMProps,
1818
KeyboardEvents,
19+
PopupStyleProps,
1920
StyleProps,
2021
TextInputProps,
2122
} from '../types';
@@ -37,7 +38,8 @@ export interface DatePickerProps<T = DateTime>
3738
DomProps,
3839
InputDOMProps,
3940
StyleProps,
40-
AccessibilityProps {
41+
AccessibilityProps,
42+
PopupStyleProps {
4143
children?: (props: CalendarProps<T>) => React.ReactNode;
4244
disablePortal?: boolean;
4345
disableFocusTrap?: boolean;

src/components/DatePicker/hooks/useDatePickerProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ export function useDatePickerProps<T extends DateTime | RangeValue<DateTime>>(
151151
},
152152
modal: !props.disableFocusTrap,
153153
disablePortal: props.disablePortal,
154+
placement: props.popupPlacement,
155+
offset: props.popupOffset,
156+
className: props.popupClassName,
157+
style: props.popupStyle,
154158
},
155159
calendarProps: {
156160
ref: calendarRef,

src/components/RelativeDateField/RelativeDateField.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type {
1414
FocusableProps,
1515
InputDOMProps,
1616
KeyboardEvents,
17+
PopupStyleProps,
1718
StyleProps,
1819
TextInputExtendProps,
1920
TextInputProps,
@@ -36,7 +37,8 @@ export interface RelativeDateFieldProps
3637
StyleProps,
3738
AccessibilityProps,
3839
FocusableProps,
39-
KeyboardEvents {
40+
KeyboardEvents,
41+
PopupStyleProps {
4042
/**
4143
* Show time field in popup
4244
* @default false
@@ -103,6 +105,10 @@ export function RelativeDateField(props: RelativeDateFieldProps) {
103105
setOpen(false);
104106
}
105107
}}
108+
placement={props.popupPlacement}
109+
offset={props.popupOffset}
110+
className={props.popupClassName}
111+
style={props.popupStyle}
106112
>
107113
<div className={b('popup-content')}>
108114
<Calendar {...calendarProps} />

src/components/RelativeDatePicker/RelativeDatePicker.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {
2222
FocusableProps,
2323
InputDOMProps,
2424
KeyboardEvents,
25+
PopupStyleProps,
2526
StyleProps,
2627
TextInputProps,
2728
} from '../types';
@@ -42,7 +43,8 @@ export interface RelativeDatePickerProps
4243
DomProps,
4344
InputDOMProps,
4445
StyleProps,
45-
AccessibilityProps {
46+
AccessibilityProps,
47+
PopupStyleProps {
4648
children?: (props: CalendarProps) => React.ReactNode;
4749
/** Handler that is called when the popup's open state changes. */
4850
onOpenChange?: (open: boolean) => void;

src/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ export function useRelativeDatePickerProps(
213213
: datePickerState.dateFieldState.displayValue,
214214
);
215215
},
216+
placement: props.popupPlacement,
217+
offset: props.popupOffset,
218+
className: props.popupClassName,
219+
style: props.popupStyle,
216220
},
217221
calendarProps: {
218222
ref: calendarRef,

src/components/types/datePicker.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {DateTime} from '@gravity-ui/date-utils';
2+
import type {CSSProperties, PopupOffset, PopupPlacement} from '@gravity-ui/uikit';
23

34
import type {InputBase, Validation, ValueBase} from './inputs';
45

@@ -28,3 +29,14 @@ export interface PopupTriggerProps<Args extends unknown[] = []> {
2829
/** Handler that is called when the popup's open state changes. */
2930
onOpenChange?: (open: boolean, ...args: Args) => void;
3031
}
32+
33+
export interface PopupStyleProps {
34+
/** Sets the CSS className for the popup element. */
35+
popupClassName?: string;
36+
/** Sets the CSS style attribute for the popup element. */
37+
popupStyle?: CSSProperties;
38+
/** Popup placement */
39+
popupPlacement?: PopupPlacement;
40+
/** Popup offset relative to anchor */
41+
popupOffset?: PopupOffset;
42+
}

0 commit comments

Comments
 (0)