@jetbrains/ring-ui 5.0.86 → 5.0.88
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.
|
@@ -23,7 +23,7 @@ export interface PositionAttrs {
|
|
|
23
23
|
autoCorrectTopOverflow: boolean;
|
|
24
24
|
}
|
|
25
25
|
export declare const positionPropKeys: readonly ["directions", "autoPositioning", "autoCorrectTopOverflow", "sidePadding", "top", "left", "offset", "maxHeight", "minWidth"];
|
|
26
|
-
export declare function maxHeightForDirection(direction: Directions, anchorNode: Element, containerNode?: Element | null): number
|
|
26
|
+
export declare function maxHeightForDirection(direction: Directions, anchorNode: Element, containerNode?: Element | null): number;
|
|
27
27
|
export default function position(attrs: PositionAttrs): {
|
|
28
28
|
styles: PositionStyles;
|
|
29
29
|
direction: Directions | null;
|
|
@@ -76,25 +76,6 @@ const defaultcontainerRect = {
|
|
|
76
76
|
top: 0,
|
|
77
77
|
left: 0
|
|
78
78
|
};
|
|
79
|
-
function handleTopOffScreen({ sidePadding, styles, anchorRect, maxHeight, popupScrollHeight, direction, scroll }) {
|
|
80
|
-
const BORDER_COMPENSATION = 1;
|
|
81
|
-
const { TOP_LEFT, TOP_RIGHT, TOP_CENTER, RIGHT_TOP, LEFT_TOP } = Directions;
|
|
82
|
-
const openedToTop = direction != null && [TOP_LEFT, TOP_RIGHT, TOP_CENTER, RIGHT_TOP, LEFT_TOP].includes(direction);
|
|
83
|
-
if (!openedToTop) {
|
|
84
|
-
return styles;
|
|
85
|
-
}
|
|
86
|
-
const isAttachedToAnchorTop = direction != null && [TOP_LEFT, TOP_CENTER, TOP_RIGHT].includes(direction);
|
|
87
|
-
const attachingPointY = (isAttachedToAnchorTop ? anchorRect.top : anchorRect.bottom);
|
|
88
|
-
const effectiveHeight = maxHeight && typeof maxHeight === 'number'
|
|
89
|
-
? Math.min(popupScrollHeight, maxHeight)
|
|
90
|
-
: popupScrollHeight;
|
|
91
|
-
const hypotheticalTop = attachingPointY - effectiveHeight;
|
|
92
|
-
if (hypotheticalTop <= sidePadding) {
|
|
93
|
-
styles.top = sidePadding + scroll.top;
|
|
94
|
-
styles.maxHeight = attachingPointY - sidePadding + BORDER_COMPENSATION;
|
|
95
|
-
}
|
|
96
|
-
return styles;
|
|
97
|
-
}
|
|
98
79
|
export function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
99
80
|
const container = containerNode || document.documentElement;
|
|
100
81
|
const domRect = anchorNode.getBoundingClientRect();
|
|
@@ -104,7 +85,7 @@ export function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
104
85
|
// XXX
|
|
105
86
|
// If container is the document element
|
|
106
87
|
// then we check client height too because we may have situation when
|
|
107
|
-
// "height" from "getBoundingClientRect" less
|
|
88
|
+
// "height" from "getBoundingClientRect" less than "clientHeight".
|
|
108
89
|
container === document.documentElement ? container.clientHeight : 0);
|
|
109
90
|
const bottomMaxHeight = Math.max(containerHeight - (topMaxHeight + domRect.height), 0);
|
|
110
91
|
switch (direction) {
|
|
@@ -126,7 +107,8 @@ export function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
126
107
|
case Directions.LEFT_CENTER:
|
|
127
108
|
return (domRect.height / 2) + Math.min(bottomMaxHeight / 2, topMaxHeight / 2);
|
|
128
109
|
default:
|
|
129
|
-
|
|
110
|
+
const exhaustiveCheck = direction;
|
|
111
|
+
throw new Error(exhaustiveCheck);
|
|
130
112
|
}
|
|
131
113
|
}
|
|
132
114
|
export default function position(attrs) {
|
|
@@ -178,16 +160,11 @@ export default function position(attrs) {
|
|
|
178
160
|
else if (maxHeight) {
|
|
179
161
|
styles.maxHeight = maxHeight;
|
|
180
162
|
}
|
|
181
|
-
if (autoCorrectTopOverflow) {
|
|
182
|
-
styles =
|
|
183
|
-
|
|
184
|
-
styles
|
|
185
|
-
|
|
186
|
-
maxHeight,
|
|
187
|
-
direction: chosenDirection,
|
|
188
|
-
popupScrollHeight: popup?.scrollHeight ?? 0,
|
|
189
|
-
scroll
|
|
190
|
-
});
|
|
163
|
+
if (autoCorrectTopOverflow && chosenDirection && anchor) {
|
|
164
|
+
styles.maxHeight = maxHeightForDirection(chosenDirection, anchor, container) - sidePadding;
|
|
165
|
+
if (styles.top === 0) {
|
|
166
|
+
styles.top = sidePadding;
|
|
167
|
+
}
|
|
191
168
|
}
|
|
192
169
|
if (minWidth === MinWidth.TARGET || minWidth === 'target') {
|
|
193
170
|
styles.minWidth = anchorRect.width;
|
package/dist/popup/position.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface PositionAttrs {
|
|
|
23
23
|
autoCorrectTopOverflow: boolean;
|
|
24
24
|
}
|
|
25
25
|
export declare const positionPropKeys: readonly ["directions", "autoPositioning", "autoCorrectTopOverflow", "sidePadding", "top", "left", "offset", "maxHeight", "minWidth"];
|
|
26
|
-
export declare function maxHeightForDirection(direction: Directions, anchorNode: Element, containerNode?: Element | null): number
|
|
26
|
+
export declare function maxHeightForDirection(direction: Directions, anchorNode: Element, containerNode?: Element | null): number;
|
|
27
27
|
export default function position(attrs: PositionAttrs): {
|
|
28
28
|
styles: PositionStyles;
|
|
29
29
|
direction: Directions | null;
|
package/dist/popup/position.js
CHANGED
|
@@ -101,38 +101,6 @@ const defaultcontainerRect = {
|
|
|
101
101
|
top: 0,
|
|
102
102
|
left: 0
|
|
103
103
|
};
|
|
104
|
-
function handleTopOffScreen(_ref) {
|
|
105
|
-
let {
|
|
106
|
-
sidePadding,
|
|
107
|
-
styles,
|
|
108
|
-
anchorRect,
|
|
109
|
-
maxHeight,
|
|
110
|
-
popupScrollHeight,
|
|
111
|
-
direction,
|
|
112
|
-
scroll
|
|
113
|
-
} = _ref;
|
|
114
|
-
const BORDER_COMPENSATION = 1;
|
|
115
|
-
const {
|
|
116
|
-
TOP_LEFT,
|
|
117
|
-
TOP_RIGHT,
|
|
118
|
-
TOP_CENTER,
|
|
119
|
-
RIGHT_TOP,
|
|
120
|
-
LEFT_TOP
|
|
121
|
-
} = Directions;
|
|
122
|
-
const openedToTop = direction != null && [TOP_LEFT, TOP_RIGHT, TOP_CENTER, RIGHT_TOP, LEFT_TOP].includes(direction);
|
|
123
|
-
if (!openedToTop) {
|
|
124
|
-
return styles;
|
|
125
|
-
}
|
|
126
|
-
const isAttachedToAnchorTop = direction != null && [TOP_LEFT, TOP_CENTER, TOP_RIGHT].includes(direction);
|
|
127
|
-
const attachingPointY = isAttachedToAnchorTop ? anchorRect.top : anchorRect.bottom;
|
|
128
|
-
const effectiveHeight = maxHeight && typeof maxHeight === 'number' ? Math.min(popupScrollHeight, maxHeight) : popupScrollHeight;
|
|
129
|
-
const hypotheticalTop = attachingPointY - effectiveHeight;
|
|
130
|
-
if (hypotheticalTop <= sidePadding) {
|
|
131
|
-
styles.top = sidePadding + scroll.top;
|
|
132
|
-
styles.maxHeight = attachingPointY - sidePadding + BORDER_COMPENSATION;
|
|
133
|
-
}
|
|
134
|
-
return styles;
|
|
135
|
-
}
|
|
136
104
|
function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
137
105
|
const container = containerNode || document.documentElement;
|
|
138
106
|
const domRect = anchorNode.getBoundingClientRect();
|
|
@@ -142,7 +110,7 @@ function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
142
110
|
// XXX
|
|
143
111
|
// If container is the document element
|
|
144
112
|
// then we check client height too because we may have situation when
|
|
145
|
-
// "height" from "getBoundingClientRect" less
|
|
113
|
+
// "height" from "getBoundingClientRect" less than "clientHeight".
|
|
146
114
|
container === document.documentElement ? container.clientHeight : 0);
|
|
147
115
|
const bottomMaxHeight = Math.max(containerHeight - (topMaxHeight + domRect.height), 0);
|
|
148
116
|
switch (direction) {
|
|
@@ -164,7 +132,8 @@ function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
164
132
|
case Directions.LEFT_CENTER:
|
|
165
133
|
return domRect.height / 2 + Math.min(bottomMaxHeight / 2, topMaxHeight / 2);
|
|
166
134
|
default:
|
|
167
|
-
|
|
135
|
+
const exhaustiveCheck = direction;
|
|
136
|
+
throw new Error(exhaustiveCheck);
|
|
168
137
|
}
|
|
169
138
|
}
|
|
170
139
|
function position(attrs) {
|
|
@@ -208,13 +177,13 @@ function position(attrs) {
|
|
|
208
177
|
concat(directions[0]).filter(direction => directionsMatrix[direction]).map(direction => ({
|
|
209
178
|
styles: directionsMatrix[direction],
|
|
210
179
|
direction
|
|
211
|
-
})).sort((
|
|
180
|
+
})).sort((_ref, _ref2) => {
|
|
212
181
|
let {
|
|
213
182
|
styles: stylesA
|
|
214
|
-
} =
|
|
183
|
+
} = _ref;
|
|
215
184
|
let {
|
|
216
185
|
styles: stylesB
|
|
217
|
-
} =
|
|
186
|
+
} = _ref2;
|
|
218
187
|
const overflowA = verticalOverflow(stylesA, scroll, overflowAttrs) + horizontalOverflow(stylesA, scroll, overflowAttrs);
|
|
219
188
|
const overflowB = verticalOverflow(stylesB, scroll, overflowAttrs) + horizontalOverflow(stylesB, scroll, overflowAttrs);
|
|
220
189
|
return overflowA - overflowB;
|
|
@@ -235,17 +204,11 @@ function position(attrs) {
|
|
|
235
204
|
} else if (maxHeight) {
|
|
236
205
|
styles.maxHeight = maxHeight;
|
|
237
206
|
}
|
|
238
|
-
if (autoCorrectTopOverflow) {
|
|
239
|
-
|
|
240
|
-
styles
|
|
241
|
-
sidePadding
|
|
242
|
-
|
|
243
|
-
anchorRect,
|
|
244
|
-
maxHeight,
|
|
245
|
-
direction: chosenDirection,
|
|
246
|
-
popupScrollHeight: (_popup$scrollHeight = popup?.scrollHeight) !== null && _popup$scrollHeight !== void 0 ? _popup$scrollHeight : 0,
|
|
247
|
-
scroll
|
|
248
|
-
});
|
|
207
|
+
if (autoCorrectTopOverflow && chosenDirection && anchor) {
|
|
208
|
+
styles.maxHeight = maxHeightForDirection(chosenDirection, anchor, container) - sidePadding;
|
|
209
|
+
if (styles.top === 0) {
|
|
210
|
+
styles.top = sidePadding;
|
|
211
|
+
}
|
|
249
212
|
}
|
|
250
213
|
if (minWidth === MinWidth.TARGET || minWidth === 'target') {
|
|
251
214
|
styles.minWidth = anchorRect.width;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetbrains/ring-ui",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.88",
|
|
4
4
|
"description": "JetBrains UI library",
|
|
5
5
|
"author": "JetBrains",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"typecheck-ci": "node tsc-teamcity",
|
|
65
65
|
"prerelease-ci": "git pull",
|
|
66
66
|
"release-ci": "npm version $NPM_VERSION_PARAMS && npm publish --access=public $NPM_PUBLISH_PARAMS",
|
|
67
|
+
"postrelease-ci": "git push --follow-tags",
|
|
67
68
|
"prepublishOnly": "pinst --disable",
|
|
68
69
|
"postpublish": "pinst --enable"
|
|
69
70
|
},
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
"@babel/eslint-parser": "^7.19.1",
|
|
78
79
|
"@jetbrains/eslint-config": "^5.4.1",
|
|
79
80
|
"@jetbrains/stylelint-config": "^3.0.2",
|
|
80
|
-
"@primer/octicons": "^17.10.
|
|
81
|
+
"@primer/octicons": "^17.10.1",
|
|
81
82
|
"@rollup/plugin-babel": "^6.0.3",
|
|
82
83
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
83
84
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -107,8 +108,8 @@
|
|
|
107
108
|
"@types/react-dom": "^18.0.10",
|
|
108
109
|
"@types/sinon": "^10.0.13",
|
|
109
110
|
"@types/sinon-chai": "^3.2.9",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
111
|
-
"@typescript-eslint/parser": "^5.
|
|
111
|
+
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
112
|
+
"@typescript-eslint/parser": "^5.48.0",
|
|
112
113
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
|
|
113
114
|
"angular": "^1.8.3",
|
|
114
115
|
"angular-mocks": "^1.8.3",
|
|
@@ -123,7 +124,7 @@
|
|
|
123
124
|
"core-js": "^3.27.1",
|
|
124
125
|
"cpy-cli": "^3.1.1",
|
|
125
126
|
"enzyme": "^3.11.0",
|
|
126
|
-
"eslint": "^8.
|
|
127
|
+
"eslint": "^8.31.0",
|
|
127
128
|
"eslint-import-resolver-webpack": "^0.13.2",
|
|
128
129
|
"eslint-plugin-angular": "^4.1.0",
|
|
129
130
|
"eslint-plugin-bdd": "^2.1.1",
|
|
@@ -133,7 +134,7 @@
|
|
|
133
134
|
"events": "^3.3.0",
|
|
134
135
|
"glob": "^8.0.3",
|
|
135
136
|
"html-webpack-plugin": "^5.5.0",
|
|
136
|
-
"husky": "^8.0.
|
|
137
|
+
"husky": "^8.0.3",
|
|
137
138
|
"identity-obj-proxy": "^3.0.0",
|
|
138
139
|
"imports-loader": "^4.0.1",
|
|
139
140
|
"jest": "~29.3.1",
|
|
@@ -156,7 +157,7 @@
|
|
|
156
157
|
"react-test-renderer": "^18.2.0",
|
|
157
158
|
"regenerator-runtime": "^0.13.11",
|
|
158
159
|
"rimraf": "^3.0.2",
|
|
159
|
-
"rollup": "^3.9.
|
|
160
|
+
"rollup": "^3.9.1",
|
|
160
161
|
"rollup-plugin-clear": "^2.0.7",
|
|
161
162
|
"rollup-plugin-styles": "^4.0.0",
|
|
162
163
|
"sinon": "^15.0.1",
|