@skbkontur/react-ui 6.0.7 → 6.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 +39 -0
- package/components/Autocomplete/Autocomplete.js +15 -4
- package/components/Autocomplete/Autocomplete.js.map +1 -1
- package/components/Button/Button.d.ts +1 -1
- package/components/Button/Button.js +5 -4
- package/components/Button/Button.js.map +1 -1
- package/components/Calendar/CalendarDay.js +3 -0
- package/components/Calendar/CalendarDay.js.map +1 -1
- package/components/Calendar/DayCellView.styles.d.ts +1 -0
- package/components/Calendar/DayCellView.styles.js +6 -3
- package/components/Calendar/DayCellView.styles.js.map +1 -1
- package/components/DatePicker/MobilePicker.js +1 -1
- package/components/DatePicker/MobilePicker.js.map +1 -1
- package/components/DateRangePicker/DateRangePicker.js +1 -1
- package/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/components/FxInput/FxInputRestoreBtn.js +1 -1
- package/components/FxInput/FxInputRestoreBtn.js.map +1 -1
- package/components/Hint/Hint.js +10 -3
- package/components/Hint/Hint.js.map +1 -1
- package/components/Input/Input.d.ts +19 -1
- package/components/Input/Input.js +10 -3
- package/components/Input/Input.js.map +1 -1
- package/components/Input/InputLayout/InputLayout.d.ts +3 -1
- package/components/Input/InputLayout/InputLayout.js +5 -2
- package/components/Input/InputLayout/InputLayout.js.map +1 -1
- package/components/Input/InputLayout/InputLayout.styles.d.ts +6 -0
- package/components/Input/InputLayout/InputLayout.styles.js +19 -1
- package/components/Input/InputLayout/InputLayout.styles.js.map +1 -1
- package/components/Input/InputLayout/InputLayoutAside.d.ts +2 -0
- package/components/Input/InputLayout/InputLayoutAside.js +2 -2
- package/components/Input/InputLayout/InputLayoutAside.js.map +1 -1
- package/components/Input/InputLayout/InputLayoutAsideCounter.d.ts +11 -0
- package/components/Input/InputLayout/InputLayoutAsideCounter.js +74 -0
- package/components/Input/InputLayout/InputLayoutAsideCounter.js.map +1 -0
- package/components/Loader/Loader.d.ts +12 -4
- package/components/Loader/Loader.js +18 -7
- package/components/Loader/Loader.js.map +1 -1
- package/components/MenuItem/MenuItem.d.ts +2 -0
- package/components/MenuItem/MenuItem.js +32 -8
- package/components/MenuItem/MenuItem.js.map +1 -1
- package/components/MenuItem/MenuItem.styles.d.ts +3 -0
- package/components/MenuItem/MenuItem.styles.js +25 -16
- package/components/MenuItem/MenuItem.styles.js.map +1 -1
- package/components/Select/Select.js +11 -1
- package/components/Select/Select.js.map +1 -1
- package/components/SingleToast/SingleToast.d.ts +9 -6
- package/components/SingleToast/SingleToast.js +9 -6
- package/components/SingleToast/SingleToast.js.map +1 -1
- package/components/Spinner/Spinner.d.ts +23 -33
- package/components/Spinner/Spinner.js +23 -19
- package/components/Spinner/Spinner.js.map +1 -1
- package/components/Spinner/Spinner.styles.d.ts +0 -3
- package/components/Spinner/Spinner.styles.js +6 -15
- package/components/Spinner/Spinner.styles.js.map +1 -1
- package/components/Switcher/Switcher.js +1 -0
- package/components/Switcher/Switcher.js.map +1 -1
- package/components/Textarea/Textarea.js +1 -1
- package/components/Textarea/Textarea.js.map +1 -1
- package/components/Textarea/Textarea.styles.d.ts +1 -0
- package/components/Textarea/Textarea.styles.js +7 -4
- package/components/Textarea/Textarea.styles.js.map +1 -1
- package/components/Textarea/TextareaCounter.d.ts +2 -0
- package/components/Textarea/TextareaCounter.js +22 -4
- package/components/Textarea/TextareaCounter.js.map +1 -1
- package/components/Toast/Toast.d.ts +13 -14
- package/components/Toast/Toast.js +3 -3
- package/components/Toast/Toast.js.map +1 -1
- package/components/Toast/ToastView.d.ts +8 -5
- package/components/Toast/ToastView.js +28 -8
- package/components/Toast/ToastView.js.map +1 -1
- package/components/Toast/ToastView.styles.d.ts +7 -0
- package/components/Toast/ToastView.styles.js +30 -8
- package/components/Toast/ToastView.styles.js.map +1 -1
- package/components/TokenInput/TokenInput.d.ts +18 -2
- package/components/TokenInput/TokenInput.js +236 -79
- package/components/TokenInput/TokenInput.js.map +1 -1
- package/components/TokenInput/TokenInput.styles.d.ts +1 -0
- package/components/TokenInput/TokenInput.styles.js +12 -9
- package/components/TokenInput/TokenInput.styles.js.map +1 -1
- package/components/TokenInput/TokenInputMenu.d.ts +2 -1
- package/components/TokenInput/TokenInputMenu.js +1 -1
- package/components/TokenInput/TokenInputMenu.js.map +1 -1
- package/components/TokenInput/TokenInputMobileMenu.d.ts +25 -0
- package/components/TokenInput/TokenInputMobileMenu.js +40 -0
- package/components/TokenInput/TokenInputMobileMenu.js.map +1 -0
- package/components/TokenInput/TokenInputReducer.d.ts +2 -0
- package/components/TokenInput/TokenInputReducer.js +14 -0
- package/components/TokenInput/TokenInputReducer.js.map +1 -1
- package/components/Tooltip/Tooltip.d.ts +4 -0
- package/components/Tooltip/Tooltip.js +50 -11
- package/components/Tooltip/Tooltip.js.map +1 -1
- package/internal/CloseButtonIcon/CloseButtonIcon.js +1 -1
- package/internal/CloseButtonIcon/CloseButtonIcon.js.map +1 -1
- package/internal/CommonWrapper/CommonWrapper.js +5 -0
- package/internal/CommonWrapper/CommonWrapper.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxMenu.js +1 -1
- package/internal/CustomComboBox/ComboBoxMenu.js.map +1 -1
- package/internal/CustomComboBox/ComboBoxView.js +13 -2
- package/internal/CustomComboBox/ComboBoxView.js.map +1 -1
- package/internal/InputLikeText/InputLikeText.d.ts +1 -1
- package/internal/InputLikeText/InputLikeText.js.map +1 -1
- package/internal/Menu/Menu.js +3 -0
- package/internal/Menu/Menu.js.map +1 -1
- package/internal/Menu/Menu.styles.d.ts +1 -0
- package/internal/Menu/Menu.styles.js +13 -10
- package/internal/Menu/Menu.styles.js.map +1 -1
- package/internal/MenuMessage/MenuMessage.js +17 -1
- package/internal/MenuMessage/MenuMessage.js.map +1 -1
- package/internal/MenuMessage/MenuMessage.styles.d.ts +3 -0
- package/internal/MenuMessage/MenuMessage.styles.js +13 -4
- package/internal/MenuMessage/MenuMessage.styles.js.map +1 -1
- package/internal/MobilePopup/MobilePopup.d.ts +8 -0
- package/internal/MobilePopup/MobilePopup.js +34 -11
- package/internal/MobilePopup/MobilePopup.js.map +1 -1
- package/internal/MobilePopup/MobilePopup.styles.d.ts +7 -0
- package/internal/MobilePopup/MobilePopup.styles.js +34 -10
- package/internal/MobilePopup/MobilePopup.styles.js.map +1 -1
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.d.ts +8 -1
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.js +18 -1
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.js.map +1 -1
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.d.ts +3 -0
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.js +14 -4
- package/internal/MobilePopup/MobilePopupFooter/MobilePopupFooter.styles.js.map +1 -1
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.d.ts +4 -0
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.js +48 -11
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.js.map +1 -1
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.d.ts +6 -0
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.js +28 -8
- package/internal/MobilePopup/MobilePopupHeader/MobilePopupHeader.styles.js.map +1 -1
- package/internal/Popup/Popup.d.ts +13 -9
- package/internal/Popup/Popup.js +130 -53
- package/internal/Popup/Popup.js.map +1 -1
- package/internal/Popup/Popup.styles.js +1 -1
- package/internal/Popup/Popup.styles.js.map +1 -1
- package/internal/Popup/PopupHelper.d.ts +8 -0
- package/internal/Popup/PopupHelper.js +39 -0
- package/internal/Popup/PopupHelper.js.map +1 -1
- package/internal/Popup/PopupPin.d.ts +19 -4
- package/internal/Popup/PopupPin.js +109 -8
- package/internal/Popup/PopupPin.js.map +1 -1
- package/internal/Popup/PopupPin.styles.d.ts +2 -0
- package/internal/Popup/PopupPin.styles.js +11 -5
- package/internal/Popup/PopupPin.styles.js.map +1 -1
- package/internal/PopupMenu/PopupMenu.d.ts +2 -1
- package/internal/PopupMenu/PopupMenu.js +21 -18
- package/internal/PopupMenu/PopupMenu.js.map +1 -1
- package/internal/SpinnerIcon/SpinnerIcon.d.ts +3 -3
- package/internal/SpinnerIcon/SpinnerIcon.js +4 -4
- package/internal/SpinnerIcon/SpinnerIcon.js.map +1 -1
- package/internal/icons2022/LoadingIcon.js +1 -1
- package/internal/icons2022/LoadingIcon.js.map +1 -1
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon16Light.d.ts +2 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon16Light.js +21 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon16Light.js.map +1 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon20Regular.d.ts +2 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon20Regular.js +21 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon20Regular.js.map +1 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon24Regular.d.ts +2 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon24Regular.js +21 -0
- package/internal/icons2022/QuestionCircleIcon/QuestionCircleIcon24Regular.js.map +1 -0
- package/internal/themes/BasicTheme.d.ts +83 -4
- package/internal/themes/BasicTheme.js +187 -6
- package/internal/themes/BasicTheme.js.map +1 -1
- package/internal/themes/DarkTheme6_1.d.ts +1 -0
- package/internal/themes/DarkTheme6_1.js +41 -0
- package/internal/themes/DarkTheme6_1.js.map +1 -0
- package/internal/themes/LightTheme6_1.d.ts +1 -0
- package/internal/themes/LightTheme6_1.js +39 -0
- package/internal/themes/LightTheme6_1.js.map +1 -0
- package/lib/getMenuPositions.js +11 -11
- package/lib/getMenuPositions.js.map +1 -1
- package/lib/theming/themes/DarkTheme.d.ts +1 -0
- package/lib/theming/themes/DarkTheme.js +3 -1
- package/lib/theming/themes/DarkTheme.js.map +1 -1
- package/lib/theming/themes/LightTheme.d.ts +1 -0
- package/lib/theming/themes/LightTheme.js +3 -1
- package/lib/theming/themes/LightTheme.js.map +1 -1
- package/package.json +1 -1
package/internal/Popup/Popup.js
CHANGED
|
@@ -81,6 +81,9 @@ export var PopupPinnablePositions = [
|
|
|
81
81
|
];
|
|
82
82
|
export var PopupPositions = __spreadArray(__spreadArray([], PopupPinnablePositions, true), PopupNonPinnablePositions, true);
|
|
83
83
|
export var DefaultPosition = PopupPositions[0];
|
|
84
|
+
var isPopupNonPinnablePosition = function (position) {
|
|
85
|
+
return PopupNonPinnablePositions.includes(position);
|
|
86
|
+
};
|
|
84
87
|
export var DUMMY_LOCATION = {
|
|
85
88
|
position: DefaultPosition,
|
|
86
89
|
coordinates: {
|
|
@@ -88,6 +91,7 @@ export var DUMMY_LOCATION = {
|
|
|
88
91
|
left: -9999,
|
|
89
92
|
},
|
|
90
93
|
isFullyVisible: false,
|
|
94
|
+
pinOffset: 0,
|
|
91
95
|
};
|
|
92
96
|
export var PopupDataTids = {
|
|
93
97
|
root: 'Popup__root',
|
|
@@ -187,7 +191,9 @@ var Popup = /** @class */ (function (_super) {
|
|
|
187
191
|
_this.state.location !== null && _this.setState({ location: null });
|
|
188
192
|
};
|
|
189
193
|
_this.refPopupContentElement = function (element) {
|
|
190
|
-
|
|
194
|
+
if (element) {
|
|
195
|
+
_this.lastPopupContentElement = element;
|
|
196
|
+
}
|
|
191
197
|
};
|
|
192
198
|
_this.handleLayoutEvent = function () {
|
|
193
199
|
if (!_this.state.location) {
|
|
@@ -205,7 +211,8 @@ var Popup = /** @class */ (function (_super) {
|
|
|
205
211
|
if (location) {
|
|
206
212
|
(_b = (_a = _this.props).onPositionChange) === null || _b === void 0 ? void 0 : _b.call(_a, location.position, location.isFullyVisible);
|
|
207
213
|
}
|
|
208
|
-
|
|
214
|
+
var stateChanged = !_this.locationEquals(_this.state.location, location);
|
|
215
|
+
if (stateChanged) {
|
|
209
216
|
_this.setState({ location: location });
|
|
210
217
|
}
|
|
211
218
|
};
|
|
@@ -355,7 +362,7 @@ var Popup = /** @class */ (function (_super) {
|
|
|
355
362
|
var relativeShift = this.getRelativeShift();
|
|
356
363
|
var direction = PopupHelper.getPositionObject(location.position).direction;
|
|
357
364
|
var rootStyle = {
|
|
358
|
-
maxWidth: maxWidth,
|
|
365
|
+
maxWidth: this.getMobileMaxWidth(maxWidth),
|
|
359
366
|
top: location.coordinates.top + relativeShift.top,
|
|
360
367
|
left: location.coordinates.left + relativeShift.left,
|
|
361
368
|
};
|
|
@@ -372,7 +379,9 @@ var Popup = /** @class */ (function (_super) {
|
|
|
372
379
|
_b[_this.styles.transitionExit()] = state === 'exiting',
|
|
373
380
|
_b)))), style: rootStyle, onMouseEnter: _this.handleMouseEnter, onMouseLeave: _this.handleMouseLeave },
|
|
374
381
|
_this.content(children),
|
|
375
|
-
|
|
382
|
+
location !== DUMMY_LOCATION &&
|
|
383
|
+
(!_this.isMobileLayout || _this.props.withoutMobile) &&
|
|
384
|
+
_this.renderPin(location.position))));
|
|
376
385
|
}));
|
|
377
386
|
};
|
|
378
387
|
Popup.prototype.renderChildren = function () {
|
|
@@ -383,7 +392,7 @@ var Popup = /** @class */ (function (_super) {
|
|
|
383
392
|
var hasPin = this.getProps().hasPin;
|
|
384
393
|
var position = PopupHelper.getPositionObject(positionName);
|
|
385
394
|
return (hasPin &&
|
|
386
|
-
!
|
|
395
|
+
!isPopupNonPinnablePosition(positionName) && (React.createElement(PopupPin, { popupElement: this.lastPopupContentElement, popupPosition: positionName, size: pinSize || parseInt(this.theme.popupPinSize), offset: this.getPinOffset(position.align), backgroundColor: backgroundColor || this.theme.popupBackground })));
|
|
387
396
|
};
|
|
388
397
|
Popup.prototype.delayUpdateLocation = function () {
|
|
389
398
|
var _a, _b;
|
|
@@ -404,7 +413,10 @@ var Popup = /** @class */ (function (_super) {
|
|
|
404
413
|
if (isNullable(x) || isNullable(y)) {
|
|
405
414
|
return false;
|
|
406
415
|
}
|
|
407
|
-
return (x.coordinates.left === y.coordinates.left &&
|
|
416
|
+
return (x.coordinates.left === y.coordinates.left &&
|
|
417
|
+
x.coordinates.top === y.coordinates.top &&
|
|
418
|
+
x.position === y.position &&
|
|
419
|
+
x.pinOffset === y.pinOffset);
|
|
408
420
|
};
|
|
409
421
|
Popup.prototype.getOrderedPositions = function () {
|
|
410
422
|
var positions = this.props.positions ? this.props.positions : PopupPinnablePositions;
|
|
@@ -449,8 +461,16 @@ var Popup = /** @class */ (function (_super) {
|
|
|
449
461
|
}
|
|
450
462
|
var position = location.position;
|
|
451
463
|
var coordinates = this.getCoordinates(anchorRect, popupRect, position);
|
|
452
|
-
var
|
|
453
|
-
|
|
464
|
+
var locationAfterPadding = this.applyMobileViewportPadding({
|
|
465
|
+
coordinates: coordinates,
|
|
466
|
+
position: position,
|
|
467
|
+
isFullyVisible: PopupHelper.isFullyVisible(coordinates, popupRect, this.globalObject),
|
|
468
|
+
pinOffset: 0,
|
|
469
|
+
}, popupRect);
|
|
470
|
+
var isFullyVisible = locationAfterPadding.isFullyVisible;
|
|
471
|
+
var canBecomeVisible = !this.isMobileLayout &&
|
|
472
|
+
!isFullyVisible &&
|
|
473
|
+
PopupHelper.canBecomeFullyVisible(position, coordinates, this.globalObject);
|
|
454
474
|
var shouldReuseCurrentLocation =
|
|
455
475
|
// если нужно сохранить первоначальную позицию и Попап целиком
|
|
456
476
|
// находится в пределах вьюпорта (или может быть проскроллен в него)
|
|
@@ -461,27 +481,108 @@ var Popup = /** @class */ (function (_super) {
|
|
|
461
481
|
if (!shouldReuseCurrentLocation) {
|
|
462
482
|
return null;
|
|
463
483
|
}
|
|
464
|
-
return {
|
|
484
|
+
return __assign(__assign({}, locationAfterPadding), { isFullyVisible: isFullyVisible || canBecomeVisible });
|
|
465
485
|
};
|
|
466
486
|
Popup.prototype.tryGetFirstFullyVisibleLocation = function (positions, anchorRect, popupRect) {
|
|
467
487
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
468
488
|
var position = positions_1[_i];
|
|
469
489
|
var coordinates = this.getCoordinates(anchorRect, popupRect, position);
|
|
470
|
-
|
|
471
|
-
|
|
490
|
+
var isFullyVisible = PopupHelper.isFullyVisible(coordinates, popupRect, this.globalObject);
|
|
491
|
+
if (!this.isMobileLayout && isFullyVisible) {
|
|
492
|
+
return { coordinates: coordinates, position: position, isFullyVisible: true, pinOffset: 0 };
|
|
493
|
+
}
|
|
494
|
+
if (this.isMobileLayout) {
|
|
495
|
+
var location_1 = this.buildLocationForPosition(position, anchorRect, popupRect);
|
|
496
|
+
if (location_1.isFullyVisible) {
|
|
497
|
+
return location_1;
|
|
498
|
+
}
|
|
472
499
|
}
|
|
473
500
|
}
|
|
474
501
|
return null;
|
|
475
502
|
};
|
|
476
503
|
Popup.prototype.getFallbackLocation = function (positions, anchorRect, popupRect, tryBestFallbackPosition) {
|
|
504
|
+
if (this.isMobileLayout) {
|
|
505
|
+
var mobileFallback = this.getMobileVerticalFallbackLocation(positions, anchorRect, popupRect);
|
|
506
|
+
if (mobileFallback) {
|
|
507
|
+
return mobileFallback;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
477
510
|
var position = tryBestFallbackPosition
|
|
478
511
|
? this.pickBestFallbackPosition(positions, anchorRect, popupRect)
|
|
479
512
|
: positions[0];
|
|
480
513
|
var coordinates = this.getCoordinates(anchorRect, popupRect, position);
|
|
481
|
-
return {
|
|
514
|
+
return this.applyMobileViewportPadding({
|
|
482
515
|
coordinates: coordinates,
|
|
483
516
|
position: position,
|
|
484
517
|
isFullyVisible: PopupHelper.isFullyVisible(coordinates, popupRect, this.globalObject),
|
|
518
|
+
pinOffset: 0,
|
|
519
|
+
}, popupRect);
|
|
520
|
+
};
|
|
521
|
+
Popup.prototype.getMobileVerticalFallbackLocation = function (positions, anchorRect, popupRect) {
|
|
522
|
+
var _this = this;
|
|
523
|
+
var _a;
|
|
524
|
+
var isFullyVisible = function (position) {
|
|
525
|
+
return _this.buildLocationForPosition(position, anchorRect, popupRect).isFullyVisible;
|
|
526
|
+
};
|
|
527
|
+
var topPosition = positions.find(function (position) { return position.startsWith('top') && isFullyVisible(position); });
|
|
528
|
+
if (topPosition) {
|
|
529
|
+
return this.buildLocationForPosition(topPosition, anchorRect, popupRect);
|
|
530
|
+
}
|
|
531
|
+
var bottomPosition = positions.find(function (position) { return position.startsWith('bottom') && isFullyVisible(position); });
|
|
532
|
+
if (bottomPosition) {
|
|
533
|
+
return this.buildLocationForPosition(bottomPosition, anchorRect, popupRect);
|
|
534
|
+
}
|
|
535
|
+
var fallbackPosition = (_a = positions.find(function (position) { return position.startsWith('bottom'); })) !== null && _a !== void 0 ? _a : positions.find(function (position) { return position.startsWith('top'); });
|
|
536
|
+
if (!fallbackPosition) {
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
return this.buildLocationForPosition(fallbackPosition, anchorRect, popupRect);
|
|
540
|
+
};
|
|
541
|
+
Popup.prototype.buildLocationForPosition = function (position, anchorRect, popupRect) {
|
|
542
|
+
var coordinates = this.getCoordinates(anchorRect, popupRect, position);
|
|
543
|
+
return this.applyMobileViewportPadding({
|
|
544
|
+
coordinates: coordinates,
|
|
545
|
+
position: position,
|
|
546
|
+
isFullyVisible: false,
|
|
547
|
+
pinOffset: 0,
|
|
548
|
+
}, popupRect);
|
|
549
|
+
};
|
|
550
|
+
Popup.prototype.getViewportSidePadding = function () {
|
|
551
|
+
return PopupHelper.getPopupViewportSidePadding(this.theme, this.isMobileLayout);
|
|
552
|
+
};
|
|
553
|
+
Popup.prototype.getMobileMaxWidth = function (maxWidth) {
|
|
554
|
+
var viewportSidePadding = this.getViewportSidePadding();
|
|
555
|
+
if (this.isMobileLayout && isNullable(maxWidth) && viewportSidePadding > 0) {
|
|
556
|
+
return "calc(100dvw - ".concat(viewportSidePadding * 2, "px)");
|
|
557
|
+
}
|
|
558
|
+
return maxWidth;
|
|
559
|
+
};
|
|
560
|
+
Popup.prototype.applyMobileViewportPadding = function (location, popupRect) {
|
|
561
|
+
if (!this.isMobileLayout || this.getViewportSidePadding() === 0) {
|
|
562
|
+
return location;
|
|
563
|
+
}
|
|
564
|
+
var _a = this.normalizeCoordinates(location.coordinates, popupRect), coordinates = _a.coordinates, pinOffset = _a.pinOffset;
|
|
565
|
+
return __assign(__assign({}, location), { coordinates: coordinates, pinOffset: pinOffset, isFullyVisible: PopupHelper.isFullyVisible(coordinates, popupRect, this.globalObject) });
|
|
566
|
+
};
|
|
567
|
+
Popup.prototype.normalizeCoordinates = function (coordinates, popupRect) {
|
|
568
|
+
var viewportSidePadding = this.getViewportSidePadding();
|
|
569
|
+
var normalizedLeft = coordinates.left;
|
|
570
|
+
var pinOffset = 0;
|
|
571
|
+
var viewport = PopupHelper.getViewportAbsoluteRect(this.globalObject);
|
|
572
|
+
var popupRight = normalizedLeft + popupRect.width;
|
|
573
|
+
var distanceToLeft = normalizedLeft - viewport.left;
|
|
574
|
+
var distanceToRight = viewport.left + viewport.width - popupRight;
|
|
575
|
+
if (distanceToLeft < viewportSidePadding) {
|
|
576
|
+
normalizedLeft = viewport.left + viewportSidePadding;
|
|
577
|
+
pinOffset = normalizedLeft - coordinates.left;
|
|
578
|
+
}
|
|
579
|
+
else if (distanceToRight < viewportSidePadding) {
|
|
580
|
+
normalizedLeft = viewport.left + viewport.width - viewportSidePadding - popupRect.width;
|
|
581
|
+
pinOffset = normalizedLeft - coordinates.left;
|
|
582
|
+
}
|
|
583
|
+
return {
|
|
584
|
+
coordinates: __assign(__assign({}, coordinates), { left: Math.round(normalizedLeft) }),
|
|
585
|
+
pinOffset: pinOffset,
|
|
485
586
|
};
|
|
486
587
|
};
|
|
487
588
|
Popup.prototype.pickBestFallbackPosition = function (positions, anchorRect, popupRect) {
|
|
@@ -575,7 +676,7 @@ var Popup = /** @class */ (function (_super) {
|
|
|
575
676
|
}
|
|
576
677
|
var anchorSize = /top|bottom/.test(position.direction) ? anchorRect.width : anchorRect.height;
|
|
577
678
|
var pinSize = this.props.pinSize;
|
|
578
|
-
return Math.max(0, this.getPinOffset(position.align) + (pinSize || parseInt(this.theme.popupPinSize)) - anchorSize / 2);
|
|
679
|
+
return Math.max(0, this.getPinOffset(position.align, false) + (pinSize || parseInt(this.theme.popupPinSize)) - anchorSize / 2);
|
|
579
680
|
};
|
|
580
681
|
Popup.prototype.getCoordinates = function (anchorRect, popupRect, positionName) {
|
|
581
682
|
var marginFromProps = this.props.margin;
|
|
@@ -584,84 +685,60 @@ var Popup = /** @class */ (function (_super) {
|
|
|
584
685
|
: parseInt(this.theme.popupMargin) || 0;
|
|
585
686
|
var position = PopupHelper.getPositionObject(positionName);
|
|
586
687
|
var popupOffset = this.getProps().popupOffset + this.getPinnedPopupOffset(anchorRect, position);
|
|
587
|
-
var
|
|
688
|
+
var getDefaultCoordinates = function () { return ({
|
|
588
689
|
top: anchorRect.top - popupRect.height - margin,
|
|
589
|
-
left:
|
|
590
|
-
};
|
|
690
|
+
left: PopupHelper.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),
|
|
691
|
+
}); };
|
|
591
692
|
switch (position.direction) {
|
|
592
693
|
case 'top':
|
|
593
|
-
return
|
|
694
|
+
return getDefaultCoordinates();
|
|
594
695
|
case 'middle':
|
|
595
696
|
return {
|
|
596
697
|
top: anchorRect.top + anchorRect.height / 2 - popupRect.height / 2,
|
|
597
|
-
left:
|
|
698
|
+
left: PopupHelper.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),
|
|
598
699
|
};
|
|
599
700
|
case 'bottom':
|
|
600
701
|
return {
|
|
601
702
|
top: anchorRect.top + anchorRect.height + margin,
|
|
602
|
-
left:
|
|
703
|
+
left: PopupHelper.getHorizontalPosition(anchorRect, popupRect, position.align, popupOffset),
|
|
603
704
|
};
|
|
604
705
|
case 'left':
|
|
605
706
|
return {
|
|
606
|
-
top:
|
|
707
|
+
top: PopupHelper.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),
|
|
607
708
|
left: anchorRect.left - popupRect.width - margin,
|
|
608
709
|
};
|
|
609
710
|
case 'right':
|
|
610
711
|
return {
|
|
611
|
-
top:
|
|
712
|
+
top: PopupHelper.getVerticalPosition(anchorRect, popupRect, position.align, popupOffset),
|
|
612
713
|
left: anchorRect.left + anchorRect.width + margin,
|
|
613
714
|
};
|
|
614
715
|
default:
|
|
615
716
|
warning(false, "Unexpected align '".concat(position.direction, "'. Must be one of - 'top', 'bottom', 'left', 'right', 'center', 'middle'. Returning default value."));
|
|
616
|
-
return
|
|
717
|
+
return getDefaultCoordinates();
|
|
617
718
|
}
|
|
618
719
|
};
|
|
619
|
-
Popup.prototype.getPinOffset = function (align) {
|
|
720
|
+
Popup.prototype.getPinOffset = function (align, useLocationPinOffset) {
|
|
721
|
+
var _a, _b;
|
|
722
|
+
if (useLocationPinOffset === void 0) { useLocationPinOffset = true; }
|
|
620
723
|
var pinOffset = this.props.pinOffset;
|
|
621
724
|
var defaultPinOffset = pinOffset || parseInt(this.theme.popupPinOffsetY);
|
|
725
|
+
var pinOffsetFromState = useLocationPinOffset && this.isMobileLayout ? ((_b = (_a = this.state.location) === null || _a === void 0 ? void 0 : _a.pinOffset) !== null && _b !== void 0 ? _b : 0) : 0;
|
|
622
726
|
switch (align) {
|
|
623
727
|
case 'top':
|
|
624
728
|
case 'bottom':
|
|
625
729
|
return defaultPinOffset;
|
|
626
730
|
case 'left':
|
|
731
|
+
return (pinOffset || parseInt(this.theme.popupPinOffsetX)) + pinOffsetFromState;
|
|
627
732
|
case 'right':
|
|
628
|
-
return pinOffset || parseInt(this.theme.popupPinOffsetX);
|
|
733
|
+
return (pinOffset || parseInt(this.theme.popupPinOffsetX)) + pinOffsetFromState;
|
|
629
734
|
case 'center':
|
|
630
735
|
case 'middle':
|
|
631
|
-
return
|
|
736
|
+
return -pinOffsetFromState;
|
|
632
737
|
default:
|
|
633
738
|
warning(false, "Unexpected align '".concat(align, "'. Must be one of - 'top', 'bottom', 'left', 'right', 'center', 'middle'. Returning default value."));
|
|
634
739
|
return defaultPinOffset;
|
|
635
740
|
}
|
|
636
741
|
};
|
|
637
|
-
Popup.prototype.getHorizontalPosition = function (anchorRect, popupRect, align, popupOffset) {
|
|
638
|
-
var defaultHorizontalPosition = anchorRect.left - (popupRect.width - anchorRect.width) / 2;
|
|
639
|
-
switch (align) {
|
|
640
|
-
case 'left':
|
|
641
|
-
return anchorRect.left - popupOffset;
|
|
642
|
-
case 'center':
|
|
643
|
-
return defaultHorizontalPosition;
|
|
644
|
-
case 'right':
|
|
645
|
-
return anchorRect.left - (popupRect.width - anchorRect.width) + popupOffset;
|
|
646
|
-
default:
|
|
647
|
-
warning(false, "Unexpected align '".concat(align, "'. Must be one of - 'left', 'center', 'right'. Returning default value."));
|
|
648
|
-
return defaultHorizontalPosition;
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
Popup.prototype.getVerticalPosition = function (anchorRect, popupRect, align, popupOffset) {
|
|
652
|
-
var defaultVerticalPosition = anchorRect.top - popupOffset;
|
|
653
|
-
switch (align) {
|
|
654
|
-
case 'top':
|
|
655
|
-
return defaultVerticalPosition;
|
|
656
|
-
case 'middle':
|
|
657
|
-
return anchorRect.top - (popupRect.height - anchorRect.height) / 2;
|
|
658
|
-
case 'bottom':
|
|
659
|
-
return anchorRect.top - (popupRect.height - anchorRect.height) + popupOffset;
|
|
660
|
-
default:
|
|
661
|
-
warning(false, "Unexpected align '".concat(align, "'. Must be one of - 'top', 'middle', 'bottom'. Returning default value."));
|
|
662
|
-
return defaultVerticalPosition;
|
|
663
|
-
}
|
|
664
|
-
};
|
|
665
742
|
var Popup_1;
|
|
666
743
|
Popup.__KONTUR_REACT_UI__ = 'Popup';
|
|
667
744
|
Popup.displayName = 'Popup';
|