1 | /*
|
2 | * Copyright 2021 Palantir Technologies, Inc. All rights reserved.
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import { PopoverPosition } from "./popoverSharedProps";
|
17 | /**
|
18 | * Convert a position to a placement.
|
19 | *
|
20 | * @param position the position to convert
|
21 | */
|
22 | export function positionToPlacement(position) {
|
23 | /* istanbul ignore next */
|
24 | switch (position) {
|
25 | case PopoverPosition.TOP_LEFT:
|
26 | return "top-start";
|
27 | case PopoverPosition.TOP:
|
28 | return "top";
|
29 | case PopoverPosition.TOP_RIGHT:
|
30 | return "top-end";
|
31 | case PopoverPosition.RIGHT_TOP:
|
32 | return "right-start";
|
33 | case PopoverPosition.RIGHT:
|
34 | return "right";
|
35 | case PopoverPosition.RIGHT_BOTTOM:
|
36 | return "right-end";
|
37 | case PopoverPosition.BOTTOM_RIGHT:
|
38 | return "bottom-end";
|
39 | case PopoverPosition.BOTTOM:
|
40 | return "bottom";
|
41 | case PopoverPosition.BOTTOM_LEFT:
|
42 | return "bottom-start";
|
43 | case PopoverPosition.LEFT_BOTTOM:
|
44 | return "left-end";
|
45 | case PopoverPosition.LEFT:
|
46 | return "left";
|
47 | case PopoverPosition.LEFT_TOP:
|
48 | return "left-start";
|
49 | case "auto":
|
50 | case "auto-start":
|
51 | case "auto-end":
|
52 | // Return the string unchanged.
|
53 | return position;
|
54 | default:
|
55 | return assertNever(position);
|
56 | }
|
57 | }
|
58 | /* istanbul ignore next */
|
59 | function assertNever(x) {
|
60 | throw new Error("Unexpected position: " + x);
|
61 | }
|
62 | //# sourceMappingURL=popoverPlacementUtils.js.map |
\ | No newline at end of file |