Skip to content

Commit

Permalink
Removed EuiDatePicker accepting deprecated values for `popoverPosit…
Browse files Browse the repository at this point in the history
…ion`
  • Loading branch information
cee-chen committed May 4, 2022
1 parent 89799ea commit 8a7babb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ exports[`EuiDatePicker localization inherits locale from context 1`] = `
</span>
`;

exports[`EuiDatePicker popoverPlacement top-end is rendered 1`] = `
exports[`EuiDatePicker popoverPlacement upRight is rendered 1`] = `
<EuiDatePicker
adjustDateOnChange={true}
aria-label="aria-label"
Expand All @@ -877,7 +877,7 @@ exports[`EuiDatePicker popoverPlacement top-end is rendered 1`] = `
fullWidth={false}
inputRef={[Function]}
isLoading={false}
popoverPlacement="top-end"
popoverPlacement="upRight"
shadow={true}
shouldCloseOnSelect={true}
showIcon={true}
Expand Down
4 changes: 2 additions & 2 deletions src/components/date_picker/date_picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('EuiDatePicker', () => {
});

describe('popoverPlacement', () => {
test('top-end is rendered', () => {
test('upRight is rendered', () => {
const component = mount(
<EuiDatePicker {...requiredProps} popoverPlacement="top-end" />
<EuiDatePicker {...requiredProps} popoverPlacement="upRight" />
);

expect(component).toMatchSnapshot();
Expand Down
48 changes: 2 additions & 46 deletions src/components/date_picker/date_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,6 @@ import { ReactDatePicker, ReactDatePickerProps } from './react-datepicker';
export const euiDatePickerDefaultDateFormat = 'MM/DD/YYYY';
export const euiDatePickerDefaultTimeFormat = 'hh:mm A';

type popperPlacement =
| 'bottom'
| 'bottom-end'
| 'bottom-start'
| 'left'
| 'left-end'
| 'left-start'
| 'right'
| 'right-end'
| 'right-start'
| 'top'
| 'top-end'
| 'top-start';

const mapAnchorPositions: {
[key in popperPlacement]: PopoverAnchorPosition;
} = {
'bottom-start': 'downLeft',
bottom: 'downCenter',
'bottom-end': 'downRight',
'left-start': 'leftUp',
left: 'leftCenter',
'left-end': 'leftDown',
'right-start': 'rightUp',
right: 'rightCenter',
'right-end': 'rightDown',
'top-start': 'upLeft',
top: 'upCenter',
'top-end': 'upRight',
};

function isPopperPlacement(position?: string): position is popperPlacement {
return position != null && Object.keys(mapAnchorPositions).includes(position);
}

// EuiDatePicker only supports a subset of props from react-datepicker.
const unsupportedProps = [
// We don't want to show multiple months next to each other
Expand Down Expand Up @@ -149,11 +114,9 @@ interface EuiExtendedDatePickerProps
/**
* Sets the placement of the popover.
*
* DEPRECATED: 'bottom', 'bottom-end', 'bottom-start', 'left', 'left-end', 'left-start', right', 'right-end', 'right-start', 'top', 'top-end', 'top-start'
*
* **Use [EuiPopover](/#/layout/popover) values**: 'upCenter', 'upLeft', 'upRight', downCenter', 'downLeft', 'downRight', 'leftCenter', 'leftUp', 'leftDown', 'rightCenter', 'rightUp', 'rightDown'.
*/
popoverPlacement?: PopoverAnchorPosition | popperPlacement;
popoverPlacement?: PopoverAnchorPosition;
}

type _EuiDatePickerProps = CommonProps & EuiExtendedDatePickerProps;
Expand Down Expand Up @@ -205,7 +168,7 @@ export class EuiDatePicker extends Component<_EuiDatePickerProps> {
openToDate,
placeholder,
popperClassName,
popoverPlacement: _popoverPlacement,
popoverPlacement,
selected,
shadow,
shouldCloseOnSelect,
Expand Down Expand Up @@ -253,13 +216,6 @@ export class EuiDatePicker extends Component<_EuiDatePickerProps> {
fullDateFormat = `${dateFormat} ${timeFormat}`;
}

let popoverPlacement: PopoverAnchorPosition;
if (isPopperPlacement(_popoverPlacement)) {
popoverPlacement = mapAnchorPositions[_popoverPlacement];
} else {
popoverPlacement = _popoverPlacement!;
}

return (
<span className={classes}>
<EuiFormControlLayout
Expand Down
2 changes: 1 addition & 1 deletion src/components/date_picker/date_picker_range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const EuiDatePickerRange: FunctionComponent<EuiDatePickerRangeProps> = ({
showIcon: false,
fullWidth: fullWidth,
readOnly: readOnly,
popoverPlacement: 'bottom-end',
popoverPlacement: 'downRight',
className: classNames(
'euiDatePickerRange__end',
endDateControl.props.className
Expand Down

0 comments on commit 8a7babb

Please sign in to comment.