@atlaskit/top-layer 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/internal/placement-to-try-fallbacks.js +93 -67
- package/dist/es2019/internal/placement-to-try-fallbacks.js +91 -60
- package/dist/esm/internal/placement-to-try-fallbacks.js +93 -66
- package/dist/types/internal/placement-to-try-fallbacks.d.ts +7 -30
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,82 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.placementToTryFallbacks = placementToTryFallbacks;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
7
|
var _resolvePlacement = require("./resolve-placement");
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
9
|
+
* A `position-area` primary edge — the placement axis joined to its edge, e.g.
|
|
10
|
+
* `block-end` or `inline-start`. These are the four edges a popover can sit on.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function slideOnEdge(_ref) {
|
|
14
|
+
var align = _ref.align,
|
|
15
|
+
edgeKey = _ref.edgeKey,
|
|
16
|
+
crossAxis = _ref.crossAxis;
|
|
17
|
+
if (align === 'center') {
|
|
18
|
+
return ["".concat(edgeKey, " span-").concat(crossAxis, "-end"), "".concat(edgeKey, " span-").concat(crossAxis, "-start")];
|
|
19
|
+
}
|
|
20
|
+
// For `align: 'start'` the popover expands toward `end`, so the "near"
|
|
21
|
+
// span is `end` and the "far" span is `start`; `align: 'end'` mirrors
|
|
22
|
+
// this. The bare `edgeKey` (re-centered) sits between them.
|
|
23
|
+
var near = align === 'start' ? 'end' : 'start';
|
|
24
|
+
var far = align === 'start' ? 'start' : 'end';
|
|
25
|
+
return ["".concat(edgeKey, " span-").concat(crossAxis, "-").concat(near), edgeKey, "".concat(edgeKey, " span-").concat(crossAxis, "-").concat(far)];
|
|
26
|
+
}
|
|
27
|
+
function flipDiagonally(_ref2) {
|
|
28
|
+
var axis = _ref2.axis;
|
|
29
|
+
var flipOnMainAxis = axis === 'block' ? 'flip-block' : 'flip-inline';
|
|
30
|
+
var flipToCrossAxis = axis === 'block' ? 'flip-inline' : 'flip-block';
|
|
31
|
+
return "".concat(flipOnMainAxis, " ").concat(flipToCrossAxis);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Returns the `position-try-fallbacks` value for a placement.
|
|
37
36
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Centered on the block-end edge (the default placement):
|
|
39
|
+
* placementToTryFallbacks({ placement: { axis: 'block', edge: 'end', align: 'center' } });
|
|
40
|
+
* // => 'block-end span-inline-end, block-end span-inline-start, flip-block,
|
|
41
|
+
* // block-start span-inline-end, block-start span-inline-start'
|
|
41
42
|
*/
|
|
42
|
-
function placementToTryFallbacks(
|
|
43
|
-
var placement =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
function placementToTryFallbacks(_ref3) {
|
|
44
|
+
var placement = _ref3.placement;
|
|
45
|
+
/**
|
|
46
|
+
* **Build the fallback list**
|
|
47
|
+
*
|
|
48
|
+
* Each entry is a complete alternative position.
|
|
49
|
+
* The browser tries them _in order_ and uses the _first_ one that fits.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
var resolved = (0, _resolvePlacement.getPlacement)({
|
|
53
|
+
placement: placement
|
|
54
|
+
});
|
|
55
|
+
var axis = resolved.axis,
|
|
56
|
+
edge = resolved.edge,
|
|
57
|
+
align = resolved.align;
|
|
50
58
|
var crossAxis = axis === 'block' ? 'inline' : 'block';
|
|
51
59
|
var flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var
|
|
55
|
-
var flipCrossKeyword = axis === 'block' ? 'flip-inline' : 'flip-block';
|
|
60
|
+
var sameEdgeArea = "".concat(axis, "-").concat(edge);
|
|
61
|
+
var oppositeEdgeArea = "".concat(axis, "-").concat(flippedEdge);
|
|
62
|
+
var flipOnMainAxis = axis === 'block' ? 'flip-block' : 'flip-inline';
|
|
56
63
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
/**
|
|
65
|
+
* **Fallback algorithm**
|
|
66
|
+
*
|
|
67
|
+
* We have two things we can do to keep something visible:
|
|
68
|
+
*
|
|
69
|
+
* 1. _Slide_ along edges
|
|
70
|
+
* 2. _Flip_ to another edge
|
|
71
|
+
*
|
|
72
|
+
* _Centered popover_
|
|
73
|
+
*
|
|
74
|
+
* Desired: Sits in middle of main edge
|
|
75
|
+
*
|
|
76
|
+
* Fallbacks:
|
|
77
|
+
* 1: _Slide_ along main edge on the cross axis
|
|
78
|
+
* 2: _Flip_ on main axis to opposite edge (centered)
|
|
79
|
+
* 3: _Slide_ along opposite edge on the cross axis
|
|
80
|
+
*
|
|
81
|
+
* _Start or end aligned popover_
|
|
82
|
+
*
|
|
83
|
+
* Desired: Sits at start / end of main edge
|
|
84
|
+
*
|
|
85
|
+
* Fallbacks:
|
|
86
|
+
* 1: _Slide_ along main edge on the cross axis
|
|
87
|
+
* 2: _Flip_ on main axis to opposite edge
|
|
88
|
+
* 3: _Flip_ on the diagonal (flip main axis + flip cross axis) into the
|
|
89
|
+
* opposite corner. For start / end alignment, this is the clean escape
|
|
90
|
+
* when the popover would otherwise land offscreen on both axes (ie in a
|
|
91
|
+
* corner). Rule 4 gets the job done, but a slide drops the gap
|
|
92
|
+
* as named position-area values don't carry margins).
|
|
93
|
+
* The diagonal flip keeps the gap and the alignment.
|
|
94
|
+
* 4: _Slide_ along opposite edge on the cross axis
|
|
95
|
+
*/
|
|
77
96
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
return [slideOnEdge({
|
|
98
|
+
align: align,
|
|
99
|
+
edgeKey: sameEdgeArea,
|
|
100
|
+
crossAxis: crossAxis
|
|
101
|
+
}), flipOnMainAxis, align !== 'center' ? flipDiagonally({
|
|
102
|
+
axis: axis
|
|
103
|
+
}) : null, slideOnEdge({
|
|
104
|
+
align: align,
|
|
105
|
+
edgeKey: oppositeEdgeArea,
|
|
106
|
+
crossAxis: crossAxis
|
|
107
|
+
})].filter(Boolean).flat().join(', ');
|
|
82
108
|
}
|
|
@@ -1,77 +1,108 @@
|
|
|
1
1
|
import { getPlacement } from './resolve-placement';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
* A `position-area` primary edge — the placement axis joined to its edge, e.g.
|
|
5
|
+
* `block-end` or `inline-start`. These are the four edges a popover can sit on.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function slideOnEdge({
|
|
9
|
+
align,
|
|
10
|
+
edgeKey,
|
|
11
|
+
crossAxis
|
|
12
|
+
}) {
|
|
13
|
+
if (align === 'center') {
|
|
14
|
+
return [`${edgeKey} span-${crossAxis}-end`, `${edgeKey} span-${crossAxis}-start`];
|
|
15
|
+
}
|
|
16
|
+
// For `align: 'start'` the popover expands toward `end`, so the "near"
|
|
17
|
+
// span is `end` and the "far" span is `start`; `align: 'end'` mirrors
|
|
18
|
+
// this. The bare `edgeKey` (re-centered) sits between them.
|
|
19
|
+
const near = align === 'start' ? 'end' : 'start';
|
|
20
|
+
const far = align === 'start' ? 'start' : 'end';
|
|
21
|
+
return [`${edgeKey} span-${crossAxis}-${near}`, edgeKey, `${edgeKey} span-${crossAxis}-${far}`];
|
|
22
|
+
}
|
|
23
|
+
function flipDiagonally({
|
|
24
|
+
axis
|
|
25
|
+
}) {
|
|
26
|
+
const flipOnMainAxis = axis === 'block' ? 'flip-block' : 'flip-inline';
|
|
27
|
+
const flipToCrossAxis = axis === 'block' ? 'flip-inline' : 'flip-block';
|
|
28
|
+
return `${flipOnMainAxis} ${flipToCrossAxis}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns the `position-try-fallbacks` value for a placement.
|
|
30
33
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Centered on the block-end edge (the default placement):
|
|
36
|
+
* placementToTryFallbacks({ placement: { axis: 'block', edge: 'end', align: 'center' } });
|
|
37
|
+
* // => 'block-end span-inline-end, block-end span-inline-start, flip-block,
|
|
38
|
+
* // block-start span-inline-end, block-start span-inline-start'
|
|
34
39
|
*/
|
|
35
40
|
export function placementToTryFallbacks({
|
|
36
41
|
placement
|
|
37
42
|
}) {
|
|
43
|
+
/**
|
|
44
|
+
* **Build the fallback list**
|
|
45
|
+
*
|
|
46
|
+
* Each entry is a complete alternative position.
|
|
47
|
+
* The browser tries them _in order_ and uses the _first_ one that fits.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
const resolved = getPlacement({
|
|
51
|
+
placement
|
|
52
|
+
});
|
|
38
53
|
const {
|
|
39
54
|
axis,
|
|
40
55
|
edge,
|
|
41
56
|
align
|
|
42
|
-
} =
|
|
43
|
-
placement
|
|
44
|
-
});
|
|
57
|
+
} = resolved;
|
|
45
58
|
const crossAxis = axis === 'block' ? 'inline' : 'block';
|
|
46
59
|
const flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const flipCrossKeyword = axis === 'block' ? 'flip-inline' : 'flip-block';
|
|
60
|
+
const sameEdgeArea = `${axis}-${edge}`;
|
|
61
|
+
const oppositeEdgeArea = `${axis}-${flippedEdge}`;
|
|
62
|
+
const flipOnMainAxis = axis === 'block' ? 'flip-block' : 'flip-inline';
|
|
51
63
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
/**
|
|
65
|
+
* **Fallback algorithm**
|
|
66
|
+
*
|
|
67
|
+
* We have two things we can do to keep something visible:
|
|
68
|
+
*
|
|
69
|
+
* 1. _Slide_ along edges
|
|
70
|
+
* 2. _Flip_ to another edge
|
|
71
|
+
*
|
|
72
|
+
* _Centered popover_
|
|
73
|
+
*
|
|
74
|
+
* Desired: Sits in middle of main edge
|
|
75
|
+
*
|
|
76
|
+
* Fallbacks:
|
|
77
|
+
* 1: _Slide_ along main edge on the cross axis
|
|
78
|
+
* 2: _Flip_ on main axis to opposite edge (centered)
|
|
79
|
+
* 3: _Slide_ along opposite edge on the cross axis
|
|
80
|
+
*
|
|
81
|
+
* _Start or end aligned popover_
|
|
82
|
+
*
|
|
83
|
+
* Desired: Sits at start / end of main edge
|
|
84
|
+
*
|
|
85
|
+
* Fallbacks:
|
|
86
|
+
* 1: _Slide_ along main edge on the cross axis
|
|
87
|
+
* 2: _Flip_ on main axis to opposite edge
|
|
88
|
+
* 3: _Flip_ on the diagonal (flip main axis + flip cross axis) into the
|
|
89
|
+
* opposite corner. For start / end alignment, this is the clean escape
|
|
90
|
+
* when the popover would otherwise land offscreen on both axes (ie in a
|
|
91
|
+
* corner). Rule 4 gets the job done, but a slide drops the gap
|
|
92
|
+
* as named position-area values don't carry margins).
|
|
93
|
+
* The diagonal flip keeps the gap and the alignment.
|
|
94
|
+
* 4: _Slide_ along opposite edge on the cross axis
|
|
95
|
+
*/
|
|
72
96
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
return [slideOnEdge({
|
|
98
|
+
align,
|
|
99
|
+
edgeKey: sameEdgeArea,
|
|
100
|
+
crossAxis
|
|
101
|
+
}), flipOnMainAxis, align !== 'center' ? flipDiagonally({
|
|
102
|
+
axis
|
|
103
|
+
}) : null, slideOnEdge({
|
|
104
|
+
align,
|
|
105
|
+
edgeKey: oppositeEdgeArea,
|
|
106
|
+
crossAxis
|
|
107
|
+
})].filter(Boolean).flat().join(', ');
|
|
77
108
|
}
|
|
@@ -1,76 +1,103 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
1
|
import { getPlacement } from './resolve-placement';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
4
|
+
* A `position-area` primary edge — the placement axis joined to its edge, e.g.
|
|
5
|
+
* `block-end` or `inline-start`. These are the four edges a popover can sit on.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function slideOnEdge(_ref) {
|
|
9
|
+
var align = _ref.align,
|
|
10
|
+
edgeKey = _ref.edgeKey,
|
|
11
|
+
crossAxis = _ref.crossAxis;
|
|
12
|
+
if (align === 'center') {
|
|
13
|
+
return ["".concat(edgeKey, " span-").concat(crossAxis, "-end"), "".concat(edgeKey, " span-").concat(crossAxis, "-start")];
|
|
14
|
+
}
|
|
15
|
+
// For `align: 'start'` the popover expands toward `end`, so the "near"
|
|
16
|
+
// span is `end` and the "far" span is `start`; `align: 'end'` mirrors
|
|
17
|
+
// this. The bare `edgeKey` (re-centered) sits between them.
|
|
18
|
+
var near = align === 'start' ? 'end' : 'start';
|
|
19
|
+
var far = align === 'start' ? 'start' : 'end';
|
|
20
|
+
return ["".concat(edgeKey, " span-").concat(crossAxis, "-").concat(near), edgeKey, "".concat(edgeKey, " span-").concat(crossAxis, "-").concat(far)];
|
|
21
|
+
}
|
|
22
|
+
function flipDiagonally(_ref2) {
|
|
23
|
+
var axis = _ref2.axis;
|
|
24
|
+
var flipOnMainAxis = axis === 'block' ? 'flip-block' : 'flip-inline';
|
|
25
|
+
var flipToCrossAxis = axis === 'block' ? 'flip-inline' : 'flip-block';
|
|
26
|
+
return "".concat(flipOnMainAxis, " ").concat(flipToCrossAxis);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns the `position-try-fallbacks` value for a placement.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Centered on the block-end edge (the default placement):
|
|
34
|
+
* placementToTryFallbacks({ placement: { axis: 'block', edge: 'end', align: 'center' } });
|
|
35
|
+
* // => 'block-end span-inline-end, block-end span-inline-start, flip-block,
|
|
36
|
+
* // block-start span-inline-end, block-start span-inline-start'
|
|
35
37
|
*/
|
|
36
|
-
export function placementToTryFallbacks(
|
|
37
|
-
var placement =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
export function placementToTryFallbacks(_ref3) {
|
|
39
|
+
var placement = _ref3.placement;
|
|
40
|
+
/**
|
|
41
|
+
* **Build the fallback list**
|
|
42
|
+
*
|
|
43
|
+
* Each entry is a complete alternative position.
|
|
44
|
+
* The browser tries them _in order_ and uses the _first_ one that fits.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
var resolved = getPlacement({
|
|
48
|
+
placement: placement
|
|
49
|
+
});
|
|
50
|
+
var axis = resolved.axis,
|
|
51
|
+
edge = resolved.edge,
|
|
52
|
+
align = resolved.align;
|
|
44
53
|
var crossAxis = axis === 'block' ? 'inline' : 'block';
|
|
45
54
|
var flippedEdge = edge === 'start' ? 'end' : 'start';
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var flipCrossKeyword = axis === 'block' ? 'flip-inline' : 'flip-block';
|
|
55
|
+
var sameEdgeArea = "".concat(axis, "-").concat(edge);
|
|
56
|
+
var oppositeEdgeArea = "".concat(axis, "-").concat(flippedEdge);
|
|
57
|
+
var flipOnMainAxis = axis === 'block' ? 'flip-block' : 'flip-inline';
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
/**
|
|
60
|
+
* **Fallback algorithm**
|
|
61
|
+
*
|
|
62
|
+
* We have two things we can do to keep something visible:
|
|
63
|
+
*
|
|
64
|
+
* 1. _Slide_ along edges
|
|
65
|
+
* 2. _Flip_ to another edge
|
|
66
|
+
*
|
|
67
|
+
* _Centered popover_
|
|
68
|
+
*
|
|
69
|
+
* Desired: Sits in middle of main edge
|
|
70
|
+
*
|
|
71
|
+
* Fallbacks:
|
|
72
|
+
* 1: _Slide_ along main edge on the cross axis
|
|
73
|
+
* 2: _Flip_ on main axis to opposite edge (centered)
|
|
74
|
+
* 3: _Slide_ along opposite edge on the cross axis
|
|
75
|
+
*
|
|
76
|
+
* _Start or end aligned popover_
|
|
77
|
+
*
|
|
78
|
+
* Desired: Sits at start / end of main edge
|
|
79
|
+
*
|
|
80
|
+
* Fallbacks:
|
|
81
|
+
* 1: _Slide_ along main edge on the cross axis
|
|
82
|
+
* 2: _Flip_ on main axis to opposite edge
|
|
83
|
+
* 3: _Flip_ on the diagonal (flip main axis + flip cross axis) into the
|
|
84
|
+
* opposite corner. For start / end alignment, this is the clean escape
|
|
85
|
+
* when the popover would otherwise land offscreen on both axes (ie in a
|
|
86
|
+
* corner). Rule 4 gets the job done, but a slide drops the gap
|
|
87
|
+
* as named position-area values don't carry margins).
|
|
88
|
+
* The diagonal flip keeps the gap and the alignment.
|
|
89
|
+
* 4: _Slide_ along opposite edge on the cross axis
|
|
90
|
+
*/
|
|
71
91
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
92
|
+
return [slideOnEdge({
|
|
93
|
+
align: align,
|
|
94
|
+
edgeKey: sameEdgeArea,
|
|
95
|
+
crossAxis: crossAxis
|
|
96
|
+
}), flipOnMainAxis, align !== 'center' ? flipDiagonally({
|
|
97
|
+
axis: axis
|
|
98
|
+
}) : null, slideOnEdge({
|
|
99
|
+
align: align,
|
|
100
|
+
edgeKey: oppositeEdgeArea,
|
|
101
|
+
crossAxis: crossAxis
|
|
102
|
+
})].filter(Boolean).flat().join(', ');
|
|
76
103
|
}
|
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import { type TPlacementOptions } from '
|
|
1
|
+
import { type TPlacementOptions } from './resolve-placement';
|
|
2
2
|
/**
|
|
3
|
-
* Returns `position-try-fallbacks` value
|
|
3
|
+
* Returns the `position-try-fallbacks` value for a placement.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* 1. Same edge, start-aligned (shift for near-edge overflow)
|
|
11
|
-
* 2. Same edge, end-aligned (shift for far-edge overflow)
|
|
12
|
-
* 3. Flipped edge, centered
|
|
13
|
-
* 4. Flipped edge, start-aligned
|
|
14
|
-
* 5. Flipped edge, end-aligned
|
|
15
|
-
*
|
|
16
|
-
* For aligned placements (start/end), includes the same-edge centered
|
|
17
|
-
* position as fallbacks so the browser can try centering when the aligned
|
|
18
|
-
* position would overflow, before flipping to the opposite edge.
|
|
19
|
-
*
|
|
20
|
-
* **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
|
|
21
|
-
*
|
|
22
|
-
* When a popup is in a viewport corner (e.g. inline-end align-end at the
|
|
23
|
-
* top-right), flipping only the primary axis (`flip-inline`) moves the popup
|
|
24
|
-
* to the left but keeps the same cross-axis span direction (e.g. upward),
|
|
25
|
-
* which is still off-screen. The combined keyword `flip-inline flip-block`
|
|
26
|
-
* mirrors the popup diagonally. It flips BOTH the position-area AND both
|
|
27
|
-
* inline and block margins simultaneously, placing the popup at the
|
|
28
|
-
* diagonally opposite corner where there is always space.
|
|
29
|
-
*
|
|
30
|
-
* Named `position-area` entries (e.g. `inline-start span-block-end`) in
|
|
31
|
-
* `position-try-fallbacks` do NOT update margins, so only the `flip-*`
|
|
32
|
-
* tactic keywords correctly flip the gap margin along with the position.
|
|
5
|
+
* @example
|
|
6
|
+
* // Centered on the block-end edge (the default placement):
|
|
7
|
+
* placementToTryFallbacks({ placement: { axis: 'block', edge: 'end', align: 'center' } });
|
|
8
|
+
* // => 'block-end span-inline-end, block-end span-inline-start, flip-block,
|
|
9
|
+
* // block-start span-inline-end, block-start span-inline-start'
|
|
33
10
|
*/
|
|
34
11
|
export declare function placementToTryFallbacks({ placement }: {
|
|
35
12
|
placement: TPlacementOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/top-layer",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Low-level layering primitives based on popover and dialog",
|
|
5
5
|
"homepage": "https://atlassian.design/components/top-layer",
|
|
6
6
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|