|
1 | 1 | import * as React from 'react'; |
2 | 2 | import * as ReactDOM from 'react-dom'; |
3 | 3 | import { usePopper } from './thirdparty/react-popper/usePopper'; |
4 | | -import { Placement, BasePlacement, Modifier } from './thirdparty/popper-core'; |
| 4 | +import { Placement, Modifier } from './thirdparty/popper-core'; |
5 | 5 | import { css } from '@patternfly/react-styles'; |
6 | 6 | import { FindRefWrapper } from './FindRefWrapper'; |
7 | 7 | import '@patternfly/react-styles/css/components/Popper/Popper.css'; |
8 | 8 |
|
9 | | -const hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' }; |
| 9 | +const hash = { |
| 10 | + left: 'right', |
| 11 | + right: 'left', |
| 12 | + bottom: 'top', |
| 13 | + top: 'bottom', |
| 14 | + 'top-start': 'bottom-end', |
| 15 | + 'top-end': 'bottom-start', |
| 16 | + 'bottom-start': 'top-end', |
| 17 | + 'bottom-end': 'top-start', |
| 18 | + 'left-start': 'right-end', |
| 19 | + 'left-end': 'right-start', |
| 20 | + 'right-start': 'left-end', |
| 21 | + 'right-end': 'left-start' |
| 22 | +}; |
10 | 23 |
|
11 | 24 | const getOppositePlacement = (placement: Placement): any => |
12 | 25 | placement.replace( |
13 | | - /left|right|bottom|top/g, |
14 | | - (matched: string) => hash[matched as 'left' | 'right' | 'bottom' | 'top'] as BasePlacement |
| 26 | + /left|right|bottom|top|top-start|top-end|bottom-start|bottom-end|right-start|right-end|left-start|left-end/g, |
| 27 | + (matched: string) => |
| 28 | + hash[ |
| 29 | + matched as |
| 30 | + | 'left' |
| 31 | + | 'right' |
| 32 | + | 'bottom' |
| 33 | + | 'top' |
| 34 | + | 'top-start' |
| 35 | + | 'top-end' |
| 36 | + | 'bottom-start' |
| 37 | + | 'bottom-end' |
| 38 | + | 'right-start' |
| 39 | + | 'right-end' |
| 40 | + | 'left-start' |
| 41 | + | 'left-end' |
| 42 | + ] as Placement |
15 | 43 | ); |
16 | 44 |
|
17 | 45 | /** @deprecated Please use the menuAppendTo prop directly from within the PF component which uses it. */ |
|
0 commit comments