@jetbrains/ring-ui 5.0.92 → 5.0.94
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/components/popup/position.d.ts +1 -1
- package/components/popup/position.js +34 -13
- package/components/query-assist/query-assist.css +12 -6
- package/components/query-assist/query-assist.js +2 -1
- package/dist/_helpers/query-assist__suggestions.js +1 -1
- package/dist/popup/position.d.ts +1 -1
- package/dist/popup/position.js +51 -18
- package/dist/query-assist/query-assist.js +2 -2
- package/dist/style.css +1 -1
- package/package.json +7 -7
|
@@ -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 | null;
|
|
27
27
|
export default function position(attrs: PositionAttrs): {
|
|
28
28
|
styles: PositionStyles;
|
|
29
29
|
direction: Directions | null;
|
|
@@ -46,9 +46,7 @@ function verticalOverflow(styles, scrollingCoordinates, attrs) {
|
|
|
46
46
|
const viewportMinX = scrollingCoordinates.top + attrs.sidePadding;
|
|
47
47
|
const viewportMaxX = scrollingCoordinates.top + containerHeight - attrs.sidePadding;
|
|
48
48
|
const topOverflow = Math.max(viewportMinX - styles.top, 0);
|
|
49
|
-
const popupHeight = attrs.
|
|
50
|
-
? Math.min(attrs.popup.scrollHeight, attrs.maxHeight)
|
|
51
|
-
: attrs.popup.scrollHeight;
|
|
49
|
+
const popupHeight = attrs.popup.clientHeight;
|
|
52
50
|
const verticalDiff = styles.top + popupHeight - viewportMaxX;
|
|
53
51
|
const bottomOverflow = Math.max(verticalDiff, 0);
|
|
54
52
|
return topOverflow + bottomOverflow;
|
|
@@ -78,6 +76,25 @@ const defaultcontainerRect = {
|
|
|
78
76
|
top: 0,
|
|
79
77
|
left: 0
|
|
80
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
|
+
}
|
|
81
98
|
export function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
82
99
|
const container = containerNode || document.documentElement;
|
|
83
100
|
const domRect = anchorNode.getBoundingClientRect();
|
|
@@ -87,7 +104,7 @@ export function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
87
104
|
// XXX
|
|
88
105
|
// If container is the document element
|
|
89
106
|
// then we check client height too because we may have situation when
|
|
90
|
-
// "height" from "getBoundingClientRect" less
|
|
107
|
+
// "height" from "getBoundingClientRect" less then "clientHeight".
|
|
91
108
|
container === document.documentElement ? container.clientHeight : 0);
|
|
92
109
|
const bottomMaxHeight = Math.max(containerHeight - (topMaxHeight + domRect.height), 0);
|
|
93
110
|
switch (direction) {
|
|
@@ -109,8 +126,7 @@ export function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
109
126
|
case Directions.LEFT_CENTER:
|
|
110
127
|
return (domRect.height / 2) + Math.min(bottomMaxHeight / 2, topMaxHeight / 2);
|
|
111
128
|
default:
|
|
112
|
-
|
|
113
|
-
throw new Error(exhaustiveCheck);
|
|
129
|
+
return null;
|
|
114
130
|
}
|
|
115
131
|
}
|
|
116
132
|
export default function position(attrs) {
|
|
@@ -130,7 +146,7 @@ export default function position(attrs) {
|
|
|
130
146
|
const overflowAttrs = { ...attrs, popup };
|
|
131
147
|
const directionsMatrix = getPositionStyles(popup, anchorRect, anchorLeft, anchorTop, offset);
|
|
132
148
|
if (!autoPositioning || directions.length === 1) {
|
|
133
|
-
styles =
|
|
149
|
+
styles = directionsMatrix[directions[0]];
|
|
134
150
|
chosenDirection = directions[0];
|
|
135
151
|
}
|
|
136
152
|
else {
|
|
@@ -145,7 +161,7 @@ export default function position(attrs) {
|
|
|
145
161
|
horizontalOverflow(stylesB, scroll, overflowAttrs);
|
|
146
162
|
return overflowA - overflowB;
|
|
147
163
|
});
|
|
148
|
-
styles =
|
|
164
|
+
styles = sortedByIncreasingOverflow[0].styles;
|
|
149
165
|
chosenDirection = sortedByIncreasingOverflow[0].direction;
|
|
150
166
|
}
|
|
151
167
|
// because of the anchor negative margin top and left also may become negative
|
|
@@ -162,11 +178,16 @@ export default function position(attrs) {
|
|
|
162
178
|
else if (maxHeight) {
|
|
163
179
|
styles.maxHeight = maxHeight;
|
|
164
180
|
}
|
|
165
|
-
if (autoCorrectTopOverflow
|
|
166
|
-
styles
|
|
167
|
-
|
|
168
|
-
styles
|
|
169
|
-
|
|
181
|
+
if (autoCorrectTopOverflow) {
|
|
182
|
+
styles = handleTopOffScreen({
|
|
183
|
+
sidePadding,
|
|
184
|
+
styles,
|
|
185
|
+
anchorRect,
|
|
186
|
+
maxHeight,
|
|
187
|
+
direction: chosenDirection,
|
|
188
|
+
popupScrollHeight: popup?.scrollHeight ?? 0,
|
|
189
|
+
scroll
|
|
190
|
+
});
|
|
170
191
|
}
|
|
171
192
|
if (minWidth === MinWidth.TARGET || minWidth === 'target') {
|
|
172
193
|
styles.minWidth = anchorRect.width;
|
|
@@ -242,12 +242,6 @@
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
.loaderOnTheRight {
|
|
246
|
-
right: 1px;
|
|
247
|
-
|
|
248
|
-
left: auto;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
245
|
.input::-webkit-scrollbar {
|
|
252
246
|
display: none;
|
|
253
247
|
}
|
|
@@ -263,3 +257,15 @@
|
|
|
263
257
|
.loaderActive {
|
|
264
258
|
padding-right: calc(var(--ring-input-padding-inline) - var(--ring-input-padding-block));
|
|
265
259
|
}
|
|
260
|
+
|
|
261
|
+
.loaderOnTheRight {
|
|
262
|
+
padding-right: 0;
|
|
263
|
+
|
|
264
|
+
@nest [dir=rtl] & {
|
|
265
|
+
padding-left: 0;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.inputRevertOrder {
|
|
270
|
+
order: -1;
|
|
271
|
+
}
|
|
@@ -777,7 +777,8 @@ export default class QueryAssist extends Component {
|
|
|
777
777
|
const inputClasses = classNames(this.props.inputClassName, {
|
|
778
778
|
[`${styles.input} ring-js-shortcuts`]: true,
|
|
779
779
|
[styles.inputGap]: actions.length || this.isRenderingGlassOrLoader() && !glass,
|
|
780
|
-
[styles.inputGap2]: actions.length === 2
|
|
780
|
+
[styles.inputGap2]: actions.length === 2,
|
|
781
|
+
[styles.inputRevertOrder]: !glass
|
|
781
782
|
});
|
|
782
783
|
const placeholderStyles = classNames({
|
|
783
784
|
[styles.placeholder]: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import List from '../list/list.js';
|
|
3
3
|
|
|
4
|
-
var modules_da7ab055 = {"unit":"8px","button-shadow":"inset 0 0 0 1px","height":"var(--ring-button-height)","loaderWidth":"64px","overInputZIndex":"2","inputGap":"24px","light":"light_rui_d22e","heightS":"heightS_rui_d22e","heightM":"heightM_rui_d22e","heightL":"heightL_rui_d22e","button":"button_rui_d22e","active":"active_rui_d22e","withIcon":"withIcon_rui_d22e","icon":"icon_rui_d22e","primary":"primary_rui_d22e","loader":"loader_rui_d22e","loaderBackground":"loaderBackground_rui_d22e","danger":"danger_rui_d22e","text":"text_rui_d22e","content":"content_rui_d22e","text-loading":"text-loading_rui_d22e","inline":"inline_rui_d22e","withNormalIcon":"withNormalIcon_rui_d22e","withDangerIcon":"withDangerIcon_rui_d22e","progress":"progress_rui_d22e","delayed":"delayed_rui_d22e","short":"short_rui_d22e","dropdownIcon":"dropdownIcon_rui_d22e","queryAssist":"queryAssist_rui_d22e","error":"error_rui_d22e","queryAssistDisabled":"queryAssistDisabled_rui_d22e","huge":"huge_rui_d22e","actions":"actions_rui_d22e","input":"input_rui_d22e","letter-text":"letter-text_rui_d22e","letterDefault":"letterDefault_rui_d22e","letter-field-name":"letter-field-name_rui_d22e","letter-field-value":"letter-field-value_rui_d22e","letter-operator":"letter-operator_rui_d22e","letter-error":"letter-error_rui_d22e","highlight":"highlight_rui_d22e","service":"service_rui_d22e","placeholder":"placeholder_rui_d22e resetButton_rui_8bff","letter":"letter_rui_d22e","rightSearchButton":"rightSearchButton_rui_d22e","clear":"clear_rui_d22e","
|
|
4
|
+
var modules_da7ab055 = {"unit":"8px","button-shadow":"inset 0 0 0 1px","height":"var(--ring-button-height)","loaderWidth":"64px","overInputZIndex":"2","inputGap":"24px","light":"light_rui_d22e","heightS":"heightS_rui_d22e","heightM":"heightM_rui_d22e","heightL":"heightL_rui_d22e","button":"button_rui_d22e","active":"active_rui_d22e","withIcon":"withIcon_rui_d22e","icon":"icon_rui_d22e","primary":"primary_rui_d22e","loader":"loader_rui_d22e","loaderBackground":"loaderBackground_rui_d22e","danger":"danger_rui_d22e","text":"text_rui_d22e","content":"content_rui_d22e","text-loading":"text-loading_rui_d22e","inline":"inline_rui_d22e","withNormalIcon":"withNormalIcon_rui_d22e","withDangerIcon":"withDangerIcon_rui_d22e","progress":"progress_rui_d22e","delayed":"delayed_rui_d22e","short":"short_rui_d22e","dropdownIcon":"dropdownIcon_rui_d22e","queryAssist":"queryAssist_rui_d22e","error":"error_rui_d22e","queryAssistDisabled":"queryAssistDisabled_rui_d22e","huge":"huge_rui_d22e","actions":"actions_rui_d22e","input":"input_rui_d22e","letter-text":"letter-text_rui_d22e","letterDefault":"letterDefault_rui_d22e","letter-field-name":"letter-field-name_rui_d22e","letter-field-value":"letter-field-value_rui_d22e","letter-operator":"letter-operator_rui_d22e","letter-error":"letter-error_rui_d22e","highlight":"highlight_rui_d22e","service":"service_rui_d22e","placeholder":"placeholder_rui_d22e resetButton_rui_8bff","letter":"letter_rui_d22e","rightSearchButton":"rightSearchButton_rui_d22e","clear":"clear_rui_d22e","withoutGlass":"withoutGlass_rui_d22e","loaderActive":"loaderActive_rui_d22e","loaderOnTheRight":"loaderOnTheRight_rui_d22e","inputRevertOrder":"inputRevertOrder_rui_d22e"};
|
|
5
5
|
|
|
6
6
|
const ICON_ID_LENGTH = 44;
|
|
7
7
|
class QueryAssistSuggestions {
|
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 | null;
|
|
27
27
|
export default function position(attrs: PositionAttrs): {
|
|
28
28
|
styles: PositionStyles;
|
|
29
29
|
direction: Directions | null;
|
package/dist/popup/position.js
CHANGED
|
@@ -81,7 +81,7 @@ function verticalOverflow(styles, scrollingCoordinates, attrs) {
|
|
|
81
81
|
const viewportMinX = scrollingCoordinates.top + attrs.sidePadding;
|
|
82
82
|
const viewportMaxX = scrollingCoordinates.top + containerHeight - attrs.sidePadding;
|
|
83
83
|
const topOverflow = Math.max(viewportMinX - styles.top, 0);
|
|
84
|
-
const popupHeight = attrs.
|
|
84
|
+
const popupHeight = attrs.popup.clientHeight;
|
|
85
85
|
const verticalDiff = styles.top + popupHeight - viewportMaxX;
|
|
86
86
|
const bottomOverflow = Math.max(verticalDiff, 0);
|
|
87
87
|
return topOverflow + bottomOverflow;
|
|
@@ -101,6 +101,38 @@ 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
|
+
}
|
|
104
136
|
function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
105
137
|
const container = containerNode || document.documentElement;
|
|
106
138
|
const domRect = anchorNode.getBoundingClientRect();
|
|
@@ -110,7 +142,7 @@ function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
110
142
|
// XXX
|
|
111
143
|
// If container is the document element
|
|
112
144
|
// then we check client height too because we may have situation when
|
|
113
|
-
// "height" from "getBoundingClientRect" less
|
|
145
|
+
// "height" from "getBoundingClientRect" less then "clientHeight".
|
|
114
146
|
container === document.documentElement ? container.clientHeight : 0);
|
|
115
147
|
const bottomMaxHeight = Math.max(containerHeight - (topMaxHeight + domRect.height), 0);
|
|
116
148
|
switch (direction) {
|
|
@@ -132,8 +164,7 @@ function maxHeightForDirection(direction, anchorNode, containerNode) {
|
|
|
132
164
|
case Directions.LEFT_CENTER:
|
|
133
165
|
return domRect.height / 2 + Math.min(bottomMaxHeight / 2, topMaxHeight / 2);
|
|
134
166
|
default:
|
|
135
|
-
|
|
136
|
-
throw new Error(exhaustiveCheck);
|
|
167
|
+
return null;
|
|
137
168
|
}
|
|
138
169
|
}
|
|
139
170
|
function position(attrs) {
|
|
@@ -169,9 +200,7 @@ function position(attrs) {
|
|
|
169
200
|
};
|
|
170
201
|
const directionsMatrix = getPositionStyles(popup, anchorRect, anchorLeft, anchorTop, offset);
|
|
171
202
|
if (!autoPositioning || directions.length === 1) {
|
|
172
|
-
styles =
|
|
173
|
-
...directionsMatrix[directions[0]]
|
|
174
|
-
};
|
|
203
|
+
styles = directionsMatrix[directions[0]];
|
|
175
204
|
chosenDirection = directions[0];
|
|
176
205
|
} else {
|
|
177
206
|
const sortedByIncreasingOverflow = directions.
|
|
@@ -179,20 +208,18 @@ function position(attrs) {
|
|
|
179
208
|
concat(directions[0]).filter(direction => directionsMatrix[direction]).map(direction => ({
|
|
180
209
|
styles: directionsMatrix[direction],
|
|
181
210
|
direction
|
|
182
|
-
})).sort((
|
|
211
|
+
})).sort((_ref2, _ref3) => {
|
|
183
212
|
let {
|
|
184
213
|
styles: stylesA
|
|
185
|
-
} =
|
|
214
|
+
} = _ref2;
|
|
186
215
|
let {
|
|
187
216
|
styles: stylesB
|
|
188
|
-
} =
|
|
217
|
+
} = _ref3;
|
|
189
218
|
const overflowA = verticalOverflow(stylesA, scroll, overflowAttrs) + horizontalOverflow(stylesA, scroll, overflowAttrs);
|
|
190
219
|
const overflowB = verticalOverflow(stylesB, scroll, overflowAttrs) + horizontalOverflow(stylesB, scroll, overflowAttrs);
|
|
191
220
|
return overflowA - overflowB;
|
|
192
221
|
});
|
|
193
|
-
styles =
|
|
194
|
-
...sortedByIncreasingOverflow[0].styles
|
|
195
|
-
};
|
|
222
|
+
styles = sortedByIncreasingOverflow[0].styles;
|
|
196
223
|
chosenDirection = sortedByIncreasingOverflow[0].direction;
|
|
197
224
|
}
|
|
198
225
|
// because of the anchor negative margin top and left also may become negative
|
|
@@ -208,11 +235,17 @@ function position(attrs) {
|
|
|
208
235
|
} else if (maxHeight) {
|
|
209
236
|
styles.maxHeight = maxHeight;
|
|
210
237
|
}
|
|
211
|
-
if (autoCorrectTopOverflow
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
238
|
+
if (autoCorrectTopOverflow) {
|
|
239
|
+
var _popup$scrollHeight;
|
|
240
|
+
styles = handleTopOffScreen({
|
|
241
|
+
sidePadding,
|
|
242
|
+
styles,
|
|
243
|
+
anchorRect,
|
|
244
|
+
maxHeight,
|
|
245
|
+
direction: chosenDirection,
|
|
246
|
+
popupScrollHeight: (_popup$scrollHeight = popup?.scrollHeight) !== null && _popup$scrollHeight !== void 0 ? _popup$scrollHeight : 0,
|
|
247
|
+
scroll
|
|
248
|
+
});
|
|
216
249
|
}
|
|
217
250
|
if (minWidth === MinWidth.TARGET || minWidth === 'target') {
|
|
218
251
|
styles.minWidth = anchorRect.width;
|
|
@@ -776,9 +776,9 @@ class QueryAssist extends Component {
|
|
|
776
776
|
const inputClasses = classNames(this.props.inputClassName, {
|
|
777
777
|
[`${modules_da7ab055.input} ring-js-shortcuts`]: true,
|
|
778
778
|
[modules_da7ab055.inputGap]: actions.length || this.isRenderingGlassOrLoader() && !glass,
|
|
779
|
-
[modules_da7ab055.inputGap2]: actions.length === 2
|
|
779
|
+
[modules_da7ab055.inputGap2]: actions.length === 2,
|
|
780
|
+
[modules_da7ab055.inputRevertOrder]: !glass
|
|
780
781
|
});
|
|
781
|
-
|
|
782
782
|
const placeholderStyles = classNames({
|
|
783
783
|
[modules_da7ab055.placeholder]: true,
|
|
784
784
|
[modules_da7ab055.withoutGlass]: !this.isRenderingGlassOrLoader() || !renderLoader && huge
|