1 | /*
|
2 | * Copyright 2017 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 { Position } from "../../common/position";
|
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 Position.TOP_LEFT:
|
26 | return "top-start";
|
27 | case Position.TOP:
|
28 | return "top";
|
29 | case Position.TOP_RIGHT:
|
30 | return "top-end";
|
31 | case Position.RIGHT_TOP:
|
32 | return "right-start";
|
33 | case Position.RIGHT:
|
34 | return "right";
|
35 | case Position.RIGHT_BOTTOM:
|
36 | return "right-end";
|
37 | case Position.BOTTOM_RIGHT:
|
38 | return "bottom-end";
|
39 | case Position.BOTTOM:
|
40 | return "bottom";
|
41 | case Position.BOTTOM_LEFT:
|
42 | return "bottom-start";
|
43 | case Position.LEFT_BOTTOM:
|
44 | return "left-end";
|
45 | case Position.LEFT:
|
46 | return "left";
|
47 | case Position.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=popoverMigrationUtils.js.map |
\ | No newline at end of file |