@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
|
@@ -21,7 +21,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
21
21
|
};
|
|
22
22
|
import React from 'react';
|
|
23
23
|
import warning from 'warning';
|
|
24
|
+
import { responsiveLayout } from '../../components/ResponsiveLayout/decorator.js';
|
|
25
|
+
import { getDOMRect } from '../../lib/dom/getDOMRect.js';
|
|
26
|
+
import * as LayoutEvents from '../../lib/LayoutEvents.js';
|
|
24
27
|
import { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';
|
|
28
|
+
import { ThemeContext } from '../../lib/theming/ThemeContext.js';
|
|
25
29
|
import { PopupDataTids } from './Popup.js';
|
|
26
30
|
import { PopupHelper } from './PopupHelper.js';
|
|
27
31
|
import { getStyles } from './PopupPin.styles.js';
|
|
@@ -29,6 +33,12 @@ var PopupPin = /** @class */ (function (_super) {
|
|
|
29
33
|
__extends(PopupPin, _super);
|
|
30
34
|
function PopupPin() {
|
|
31
35
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
+
_this.layoutEventsToken = null;
|
|
37
|
+
_this.layoutUpdateId = null;
|
|
38
|
+
_this.cachedPopupElement = null;
|
|
39
|
+
_this.handleLayoutEvent = function () {
|
|
40
|
+
_this.scheduleRemeasure();
|
|
41
|
+
};
|
|
32
42
|
_this.getPinInlineStyle = function (left, top) {
|
|
33
43
|
var _a, _b;
|
|
34
44
|
var direction = _this.getPopupOppositeDirection();
|
|
@@ -65,7 +75,7 @@ var PopupPin = /** @class */ (function (_super) {
|
|
|
65
75
|
}
|
|
66
76
|
};
|
|
67
77
|
_this.getPinCoordinates = function (popupElement) {
|
|
68
|
-
var popupRect =
|
|
78
|
+
var popupRect = _this.getPopupElementRect(popupElement);
|
|
69
79
|
var _a = _this.positionObject, direction = _a.direction, align = _a.align;
|
|
70
80
|
var defaultPinCoordinates = {
|
|
71
81
|
top: popupRect.height,
|
|
@@ -114,7 +124,7 @@ var PopupPin = /** @class */ (function (_super) {
|
|
|
114
124
|
case 'left':
|
|
115
125
|
return _this.props.offset;
|
|
116
126
|
case 'center':
|
|
117
|
-
return defaultLetfCoordinate;
|
|
127
|
+
return defaultLetfCoordinate + _this.props.offset;
|
|
118
128
|
case 'right':
|
|
119
129
|
return popupRect.width - _this.props.offset - 2 * _this.props.size;
|
|
120
130
|
default:
|
|
@@ -139,22 +149,72 @@ var PopupPin = /** @class */ (function (_super) {
|
|
|
139
149
|
};
|
|
140
150
|
return _this;
|
|
141
151
|
}
|
|
152
|
+
PopupPin.prototype.componentDidMount = function () {
|
|
153
|
+
this.layoutEventsToken = LayoutEvents.addListener(this.handleLayoutEvent, this.globalObject);
|
|
154
|
+
this.scheduleRemeasure();
|
|
155
|
+
};
|
|
156
|
+
PopupPin.prototype.componentDidUpdate = function (prevProps) {
|
|
157
|
+
if (prevProps.popupPosition !== this.props.popupPosition ||
|
|
158
|
+
prevProps.offset !== this.props.offset ||
|
|
159
|
+
prevProps.popupElement !== this.props.popupElement) {
|
|
160
|
+
this.scheduleRemeasure();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
PopupPin.prototype.componentWillUnmount = function () {
|
|
164
|
+
var _a;
|
|
165
|
+
this.cancelScheduledRemeasure();
|
|
166
|
+
(_a = this.layoutEventsToken) === null || _a === void 0 ? void 0 : _a.remove();
|
|
167
|
+
this.layoutEventsToken = null;
|
|
168
|
+
};
|
|
142
169
|
PopupPin.prototype.render = function () {
|
|
170
|
+
var _this = this;
|
|
171
|
+
return (React.createElement(ThemeContext.Consumer, null, function (theme) {
|
|
172
|
+
_this.theme = theme;
|
|
173
|
+
return _this.renderPinContent();
|
|
174
|
+
}));
|
|
175
|
+
};
|
|
176
|
+
PopupPin.prototype.renderPinContent = function () {
|
|
143
177
|
this.styles = getStyles(this.emotion);
|
|
144
|
-
if (
|
|
178
|
+
if (this.props.popupElement) {
|
|
179
|
+
this.cachedPopupElement = this.props.popupElement;
|
|
180
|
+
}
|
|
181
|
+
var popupElement = this.props.popupElement || this.cachedPopupElement;
|
|
182
|
+
if (!popupElement) {
|
|
145
183
|
return null;
|
|
146
184
|
}
|
|
147
185
|
this.positionObject = PopupHelper.getPositionObject(this.props.popupPosition);
|
|
148
|
-
var coords = this.getPinCoordinates(
|
|
149
|
-
if (!coords ||
|
|
186
|
+
var coords = this.getPinCoordinates(popupElement);
|
|
187
|
+
if (!coords || typeof coords.left !== 'number' || typeof coords.top !== 'number') {
|
|
150
188
|
return null;
|
|
151
189
|
}
|
|
152
|
-
var
|
|
190
|
+
var popupRect = this.getPopupElementRect(popupElement);
|
|
191
|
+
var clampedPosition = this.applyEdgeClamp(coords, popupRect);
|
|
192
|
+
var inlineStyle = this.getPinInlineStyle(clampedPosition.left, clampedPosition.top);
|
|
153
193
|
var directionalStyle = this.getPinDirectionalStyle();
|
|
154
194
|
if (!inlineStyle || !directionalStyle) {
|
|
155
195
|
return null;
|
|
156
196
|
}
|
|
157
|
-
|
|
197
|
+
var pinEdgePadding = this.getPinEdgePadding();
|
|
198
|
+
return (React.createElement("div", { "data-tid": PopupDataTids.popupPin, className: this.cx(this.styles.pin(), pinEdgePadding > 0 && this.styles.pinAnimated(), clampedPosition.hidden && this.styles.pinHidden(), directionalStyle), style: inlineStyle }));
|
|
199
|
+
};
|
|
200
|
+
PopupPin.prototype.getPinEdgePadding = function () {
|
|
201
|
+
return PopupHelper.getPopupViewportSidePadding(this.theme, this.isMobileLayout);
|
|
202
|
+
};
|
|
203
|
+
PopupPin.prototype.scheduleRemeasure = function () {
|
|
204
|
+
var _this = this;
|
|
205
|
+
var _a, _b;
|
|
206
|
+
this.cancelScheduledRemeasure();
|
|
207
|
+
this.layoutUpdateId = (_b = (_a = this.globalObject).requestAnimationFrame) === null || _b === void 0 ? void 0 : _b.call(_a, function () {
|
|
208
|
+
_this.layoutUpdateId = null;
|
|
209
|
+
_this.forceUpdate();
|
|
210
|
+
});
|
|
211
|
+
};
|
|
212
|
+
PopupPin.prototype.cancelScheduledRemeasure = function () {
|
|
213
|
+
var _a, _b;
|
|
214
|
+
if (this.layoutUpdateId && this.layoutUpdateId !== null) {
|
|
215
|
+
(_b = (_a = this.globalObject).cancelAnimationFrame) === null || _b === void 0 ? void 0 : _b.call(_a, this.layoutUpdateId);
|
|
216
|
+
this.layoutUpdateId = null;
|
|
217
|
+
}
|
|
158
218
|
};
|
|
159
219
|
PopupPin.prototype.getPopupOppositeDirection = function () {
|
|
160
220
|
var popupDirection = PopupHelper.getPositionObject(this.props.popupPosition).direction;
|
|
@@ -172,10 +232,51 @@ var PopupPin = /** @class */ (function (_super) {
|
|
|
172
232
|
return 'bottom';
|
|
173
233
|
}
|
|
174
234
|
};
|
|
235
|
+
PopupPin.prototype.clampValue = function (value, min, max) {
|
|
236
|
+
return Math.min(Math.max(value, min), max);
|
|
237
|
+
};
|
|
238
|
+
PopupPin.prototype.applyEdgeClamp = function (coords, popupRect) {
|
|
239
|
+
var pinEdgePadding = this.getPinEdgePadding();
|
|
240
|
+
if (pinEdgePadding <= 0) {
|
|
241
|
+
return { left: coords.left, top: coords.top, hidden: false };
|
|
242
|
+
}
|
|
243
|
+
var direction = this.positionObject.direction;
|
|
244
|
+
var pinSpan = 2 * this.props.size;
|
|
245
|
+
if (direction === 'top' || direction === 'bottom') {
|
|
246
|
+
var minLeft = pinEdgePadding;
|
|
247
|
+
var maxLeft = popupRect.width - pinSpan - pinEdgePadding;
|
|
248
|
+
var clampedLeft = this.clampValue(coords.left, minLeft, maxLeft);
|
|
249
|
+
var centerOffset_1 = coords.left - clampedLeft;
|
|
250
|
+
return {
|
|
251
|
+
left: clampedLeft,
|
|
252
|
+
top: coords.top,
|
|
253
|
+
hidden: centerOffset_1 !== 0,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
var minTop = pinEdgePadding;
|
|
257
|
+
var maxTop = popupRect.height - pinSpan - pinEdgePadding;
|
|
258
|
+
var clampedTop = this.clampValue(coords.top, minTop, maxTop);
|
|
259
|
+
var centerOffset = coords.top - clampedTop;
|
|
260
|
+
return {
|
|
261
|
+
left: coords.left,
|
|
262
|
+
top: clampedTop,
|
|
263
|
+
hidden: centerOffset !== 0,
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
PopupPin.prototype.getPopupElementRect = function (popupElement) {
|
|
267
|
+
var rect = getDOMRect(popupElement);
|
|
268
|
+
return {
|
|
269
|
+
top: 0,
|
|
270
|
+
left: 0,
|
|
271
|
+
width: rect.width,
|
|
272
|
+
height: rect.height,
|
|
273
|
+
};
|
|
274
|
+
};
|
|
175
275
|
PopupPin.__KONTUR_REACT_UI__ = 'PopupPin';
|
|
176
276
|
PopupPin.displayName = 'PopupPin';
|
|
177
277
|
PopupPin = __decorate([
|
|
178
|
-
withRenderEnvironment
|
|
278
|
+
withRenderEnvironment,
|
|
279
|
+
responsiveLayout
|
|
179
280
|
], PopupPin);
|
|
180
281
|
return PopupPin;
|
|
181
282
|
}(React.Component));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupPin.js","sourceRoot":"","sources":["../../../internal/Popup/PopupPin.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAwBjD;IAA8B,4BAA8B;IAA5D;;QA2DU,uBAAiB,GAAG,UAAC,IAAY,EAAE,GAAW;;YACpD,IAAM,SAAS,GAAG,KAAI,CAAC,yBAAyB,EAAE,CAAC;YACnD,IAAI,CAAC,SAAS,EAAE,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YAClB,KAAK,QAAQ;gBACX,OAAO,KAAK,CAAC;YACf,KAAK,MAAM;gBACT,OAAO,OAAO,CAAC;YACjB,KAAK,OAAO;gBACV,OAAO,MAAM,CAAC;YAChB;gBACE,OAAO,CACL,KAAK,EACL,0DAAmD,cAAc,yDAAsD,CACxH,CAAC;gBACF,OAAO,QAAQ,CAAC;QACpB,CAAC;IACH,CAAC;IAxDa,4BAAmB,GAAG,UAAU,AAAb,CAAc;IACjC,oBAAW,GAAG,UAAU,AAAb,CAAc;IAF5B,QAAQ;QADpB,qBAAqB;OACT,QAAQ,CA8LpB;IAAD,eAAC;CAAA,AA9LD,CAA8B,KAAK,CAAC,SAAS,GA8L5C;SA9LY,QAAQ","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport React from 'react';\nimport warning from 'warning';\n\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { PopupDataTids } from './Popup.js';\nimport type { PositionObject, Rect } from './PopupHelper.js';\nimport { PopupHelper } from './PopupHelper.js';\nimport { getStyles } from './PopupPin.styles.js';\n\ninterface PopupPinProps {\n /** Цвет фона пина */\n backgroundColor: string;\n\n /** Смещение пина от края попапа. Край задаётся в пропе position вторым словом */\n offset: number;\n\n /** Ссылка на попап */\n popupElement?: Nullable<Element>;\n\n /** Позиция попапа, по которой будет вычислено положение пина */\n popupPosition: string;\n\n /**\n * Сторона пина без учёта границы.\n * Пин представляет собой равносторонний треугольник, высота от попапа\n * до \"носика\" пина будет соответствовать формуле (size* √3)/2\n */\n size: number;\n}\n\n@withRenderEnvironment\nexport class PopupPin extends React.Component<PopupPinProps> {\n public static __KONTUR_REACT_UI__ = 'PopupPin';\n public static displayName = 'PopupPin';\n\n private positionObject!: PositionObject;\n\n private styles!: ReturnType<typeof getStyles>;\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n\n public render() {\n this.styles = getStyles(this.emotion);\n\n if (!this.props.popupElement) {\n return null;\n }\n\n this.positionObject = PopupHelper.getPositionObject(this.props.popupPosition);\n\n const coords = this.getPinCoordinates(this.props.popupElement);\n if (!coords || !coords.left || !coords.top) {\n return null;\n }\n\n const inlineStyle = this.getPinInlineStyle(coords.left, coords.top);\n const directionalStyle = this.getPinDirectionalStyle();\n if (!inlineStyle || !directionalStyle) {\n return null;\n }\n\n return (\n <div\n data-tid={PopupDataTids.popupPin}\n className={this.cx(this.styles.pin(), directionalStyle)}\n style={inlineStyle}\n ></div>\n );\n }\n\n private getPopupOppositeDirection() {\n const popupDirection = PopupHelper.getPositionObject(this.props.popupPosition).direction;\n switch (popupDirection) {\n case 'top':\n return 'bottom';\n case 'bottom':\n return 'top';\n case 'left':\n return 'right';\n case 'right':\n return 'left';\n default:\n warning(\n false,\n `Can't get opposite direction: invalid direction ${popupDirection}. Must be one of - 'top', 'bottom', 'left', 'right'.`,\n );\n return 'bottom';\n }\n }\n\n private getPinInlineStyle = (left: number, top: number) => {\n const direction = this.getPopupOppositeDirection();\n if (!direction) {\n return;\n }\n\n // Добавляем запас в 1px, чтобы пофиксить случайные отделения пинов\n const correctedLeft = left - 1;\n const correctedTop = top - 1;\n const correctedSize = this.props.size + 1;\n\n const defaultPinInlineStyle = {\n [direction]: -this.props.size + 'px',\n left: correctedLeft + 'px',\n width: correctedSize * 2 + 'px',\n height: correctedSize + 'px',\n backgroundColor: this.props.backgroundColor,\n };\n\n switch (direction) {\n case 'top':\n case 'bottom':\n return defaultPinInlineStyle;\n case 'left':\n case 'right':\n return {\n [direction]: -this.props.size + 'px',\n top: correctedTop + 'px',\n height: correctedSize * 2 + 'px',\n width: correctedSize + 'px',\n backgroundColor: this.props.backgroundColor,\n };\n default:\n warning(\n false,\n `Can't get inline style: invalid direction '${direction}'. Must be one of - 'top', 'right', 'bottom', 'left'.`,\n );\n return defaultPinInlineStyle;\n }\n };\n\n private getPinCoordinates = (popupElement: Element) => {\n const popupRect = PopupHelper.getElementAbsoluteRect(popupElement);\n const { direction, align } = this.positionObject;\n\n const defaultPinCoordinates = {\n top: popupRect.height,\n left: this.getPinLeftCoordinate(popupRect, align),\n };\n\n switch (direction) {\n case 'top':\n return defaultPinCoordinates;\n case 'bottom':\n return {\n top: -2 * this.props.size,\n left: this.getPinLeftCoordinate(popupRect, align),\n };\n case 'left':\n return {\n top: this.getPinTopCoordinate(popupRect, align),\n left: popupRect.width,\n };\n case 'right':\n return {\n top: this.getPinTopCoordinate(popupRect, align),\n left: -2 * this.props.size,\n };\n default:\n warning(\n false,\n `Can't get coordinates: invalid direction '${direction}'. Must be one of - 'top', 'right', 'bottom', 'left'.`,\n );\n return defaultPinCoordinates;\n }\n };\n\n private getPinTopCoordinate = (popupRect: Rect, align: string) => {\n const defaultTopCoordinate = this.props.offset;\n switch (align) {\n case 'top':\n return defaultTopCoordinate;\n case 'middle':\n return popupRect.height / 2 - this.props.size;\n case 'bottom':\n return popupRect.height - this.props.offset - 2 * this.props.size;\n default:\n warning(\n false,\n `Can't get top coordinate: invalid align '${align}'. Must be one of - 'top', 'middle', 'bottom'.`,\n );\n return defaultTopCoordinate;\n }\n };\n\n private getPinLeftCoordinate = (popupRect: Rect, align: string) => {\n const defaultLetfCoordinate = popupRect.width / 2 - this.props.size;\n switch (align) {\n case 'left':\n return this.props.offset;\n case 'center':\n return defaultLetfCoordinate;\n case 'right':\n return popupRect.width - this.props.offset - 2 * this.props.size;\n default:\n warning(\n false,\n `Can't get left coordinate: invalid align '${align}'. Must be one of - 'left', 'center', 'right'.`,\n );\n return defaultLetfCoordinate;\n }\n };\n\n private getPinDirectionalStyle = () => {\n switch (this.positionObject.direction) {\n case 'top':\n return this.styles.pinTop();\n case 'bottom':\n return this.styles.pinBottom();\n case 'left':\n return this.styles.pinLeft();\n case 'right':\n return this.styles.pinRight();\n default:\n warning(\n false,\n `Can't get directional style: invalid direction '${this.positionObject.direction}'. Must be one of - 'top', 'right', 'bottom', 'left'.`,\n );\n return this.styles.pinTop();\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3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B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;IA/Na,4BAAmB,GAAG,UAAU,AAAb,CAAc;IACjC,oBAAW,GAAG,UAAU,AAAb,CAAc;IAF5B,QAAQ;QAFpB,qBAAqB;QACrB,gBAAgB;OACJ,QAAQ,CA4TpB;IAAD,eAAC;CAAA,AA5TD,CAA8B,KAAK,CAAC,SAAS,GA4T5C;SA5TY,QAAQ","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport React from 'react';\nimport warning from 'warning';\n\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator.js';\nimport { getDOMRect } from '../../lib/dom/getDOMRect.js';\nimport type { GlobalObject } from '../../lib/globalObject.js';\nimport * as LayoutEvents from '../../lib/LayoutEvents.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { Theme } from '../../lib/theming/Theme.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport { PopupDataTids } from './Popup.js';\nimport type { PositionObject, Rect } from './PopupHelper.js';\nimport { PopupHelper } from './PopupHelper.js';\nimport { getStyles } from './PopupPin.styles.js';\n\ninterface PopupPinProps {\n /** Цвет фона пина */\n backgroundColor: string;\n\n /** Смещение пина от края попапа. Край задаётся в пропе position вторым словом */\n offset: number;\n\n /** Ссылка на попап */\n popupElement?: Nullable<Element>;\n\n /** Позиция попапа, по которой будет вычислено положение пина */\n popupPosition: string;\n\n /**\n * Высота пина в px. Ширина основания = 2 × size для top/bottom, для left/right наоборот.\n */\n size: number;\n}\n\ninterface ClampedPinPosition {\n left: number;\n top: number;\n hidden: boolean;\n}\n\n@withRenderEnvironment\n@responsiveLayout\nexport class PopupPin extends React.Component<PopupPinProps> {\n public static __KONTUR_REACT_UI__ = 'PopupPin';\n public static displayName = 'PopupPin';\n\n private positionObject!: PositionObject;\n private theme!: Theme;\n private isMobileLayout!: boolean;\n\n private styles!: ReturnType<typeof getStyles>;\n private emotion!: Emotion;\n private cx!: Emotion['cx'];\n private globalObject!: GlobalObject;\n private layoutEventsToken: Nullable<ReturnType<typeof LayoutEvents.addListener>> = null;\n private layoutUpdateId: Nullable<number> = null;\n private cachedPopupElement: Nullable<Element> = null;\n\n public componentDidMount() {\n this.layoutEventsToken = LayoutEvents.addListener(this.handleLayoutEvent, this.globalObject);\n this.scheduleRemeasure();\n }\n\n public componentDidUpdate(prevProps: PopupPinProps) {\n if (\n prevProps.popupPosition !== this.props.popupPosition ||\n prevProps.offset !== this.props.offset ||\n prevProps.popupElement !== this.props.popupElement\n ) {\n this.scheduleRemeasure();\n }\n }\n\n public componentWillUnmount() {\n this.cancelScheduledRemeasure();\n this.layoutEventsToken?.remove();\n this.layoutEventsToken = null;\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderPinContent();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderPinContent() {\n this.styles = getStyles(this.emotion);\n\n if (this.props.popupElement) {\n this.cachedPopupElement = this.props.popupElement;\n }\n\n const popupElement = this.props.popupElement || this.cachedPopupElement;\n\n if (!popupElement) {\n return null;\n }\n\n this.positionObject = PopupHelper.getPositionObject(this.props.popupPosition);\n\n const coords = this.getPinCoordinates(popupElement);\n if (!coords || typeof coords.left !== 'number' || typeof coords.top !== 'number') {\n return null;\n }\n\n const popupRect = this.getPopupElementRect(popupElement);\n const clampedPosition = this.applyEdgeClamp(coords, popupRect);\n const inlineStyle = this.getPinInlineStyle(clampedPosition.left, clampedPosition.top);\n const directionalStyle = this.getPinDirectionalStyle();\n if (!inlineStyle || !directionalStyle) {\n return null;\n }\n\n const pinEdgePadding = this.getPinEdgePadding();\n\n return (\n <div\n data-tid={PopupDataTids.popupPin}\n className={this.cx(\n this.styles.pin(),\n pinEdgePadding > 0 && this.styles.pinAnimated(),\n clampedPosition.hidden && this.styles.pinHidden(),\n directionalStyle,\n )}\n style={inlineStyle}\n ></div>\n );\n }\n\n private getPinEdgePadding(): number {\n return PopupHelper.getPopupViewportSidePadding(this.theme, this.isMobileLayout);\n }\n\n private handleLayoutEvent = () => {\n this.scheduleRemeasure();\n };\n\n private scheduleRemeasure() {\n this.cancelScheduledRemeasure();\n this.layoutUpdateId = this.globalObject.requestAnimationFrame?.(() => {\n this.layoutUpdateId = null;\n this.forceUpdate();\n });\n }\n\n private cancelScheduledRemeasure() {\n if (this.layoutUpdateId && this.layoutUpdateId !== null) {\n this.globalObject.cancelAnimationFrame?.(this.layoutUpdateId);\n this.layoutUpdateId = null;\n }\n }\n\n private getPopupOppositeDirection() {\n const popupDirection = PopupHelper.getPositionObject(this.props.popupPosition).direction;\n switch (popupDirection) {\n case 'top':\n return 'bottom';\n case 'bottom':\n return 'top';\n case 'left':\n return 'right';\n case 'right':\n return 'left';\n default:\n warning(\n false,\n `Can't get opposite direction: invalid direction ${popupDirection}. Must be one of - 'top', 'bottom', 'left', 'right'.`,\n );\n return 'bottom';\n }\n }\n\n private getPinInlineStyle = (left: number, top: number) => {\n const direction = this.getPopupOppositeDirection();\n if (!direction) {\n return;\n }\n\n // Добавляем запас в 1px, чтобы пофиксить случайные отделения пинов\n const correctedLeft = left - 1;\n const correctedTop = top - 1;\n const correctedSize = this.props.size + 1;\n\n const defaultPinInlineStyle = {\n [direction]: -this.props.size + 'px',\n left: correctedLeft + 'px',\n width: correctedSize * 2 + 'px',\n height: correctedSize + 'px',\n backgroundColor: this.props.backgroundColor,\n };\n\n switch (direction) {\n case 'top':\n case 'bottom':\n return defaultPinInlineStyle;\n case 'left':\n case 'right':\n return {\n [direction]: -this.props.size + 'px',\n top: correctedTop + 'px',\n height: correctedSize * 2 + 'px',\n width: correctedSize + 'px',\n backgroundColor: this.props.backgroundColor,\n };\n default:\n warning(\n false,\n `Can't get inline style: invalid direction '${direction}'. Must be one of - 'top', 'right', 'bottom', 'left'.`,\n );\n return defaultPinInlineStyle;\n }\n };\n\n private clampValue(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n }\n\n private applyEdgeClamp(coords: { left: number; top: number }, popupRect: Rect): ClampedPinPosition {\n const pinEdgePadding = this.getPinEdgePadding();\n\n if (pinEdgePadding <= 0) {\n return { left: coords.left, top: coords.top, hidden: false };\n }\n\n const { direction } = this.positionObject;\n const pinSpan = 2 * this.props.size;\n\n if (direction === 'top' || direction === 'bottom') {\n const minLeft = pinEdgePadding;\n const maxLeft = popupRect.width - pinSpan - pinEdgePadding;\n const clampedLeft = this.clampValue(coords.left, minLeft, maxLeft);\n const centerOffset = coords.left - clampedLeft;\n\n return {\n left: clampedLeft,\n top: coords.top,\n hidden: centerOffset !== 0,\n };\n }\n\n const minTop = pinEdgePadding;\n const maxTop = popupRect.height - pinSpan - pinEdgePadding;\n const clampedTop = this.clampValue(coords.top, minTop, maxTop);\n const centerOffset = coords.top - clampedTop;\n\n return {\n left: coords.left,\n top: clampedTop,\n hidden: centerOffset !== 0,\n };\n }\n\n private getPopupElementRect(popupElement: Element): Rect {\n const rect = getDOMRect(popupElement);\n\n return {\n top: 0,\n left: 0,\n width: rect.width,\n height: rect.height,\n };\n }\n\n private getPinCoordinates = (popupElement: Element) => {\n const popupRect = this.getPopupElementRect(popupElement);\n const { direction, align } = this.positionObject;\n\n const defaultPinCoordinates = {\n top: popupRect.height,\n left: this.getPinLeftCoordinate(popupRect, align),\n };\n\n switch (direction) {\n case 'top':\n return defaultPinCoordinates;\n case 'bottom':\n return {\n top: -2 * this.props.size,\n left: this.getPinLeftCoordinate(popupRect, align),\n };\n case 'left':\n return {\n top: this.getPinTopCoordinate(popupRect, align),\n left: popupRect.width,\n };\n case 'right':\n return {\n top: this.getPinTopCoordinate(popupRect, align),\n left: -2 * this.props.size,\n };\n default:\n warning(\n false,\n `Can't get coordinates: invalid direction '${direction}'. Must be one of - 'top', 'right', 'bottom', 'left'.`,\n );\n return defaultPinCoordinates;\n }\n };\n\n private getPinTopCoordinate = (popupRect: Rect, align: string) => {\n const defaultTopCoordinate = this.props.offset;\n switch (align) {\n case 'top':\n return defaultTopCoordinate;\n case 'middle':\n return popupRect.height / 2 - this.props.size;\n case 'bottom':\n return popupRect.height - this.props.offset - 2 * this.props.size;\n default:\n warning(\n false,\n `Can't get top coordinate: invalid align '${align}'. Must be one of - 'top', 'middle', 'bottom'.`,\n );\n return defaultTopCoordinate;\n }\n };\n\n private getPinLeftCoordinate = (popupRect: Rect, align: string) => {\n const defaultLetfCoordinate = popupRect.width / 2 - this.props.size;\n switch (align) {\n case 'left':\n return this.props.offset;\n case 'center':\n return defaultLetfCoordinate + this.props.offset;\n case 'right':\n return popupRect.width - this.props.offset - 2 * this.props.size;\n default:\n warning(\n false,\n `Can't get left coordinate: invalid align '${align}'. Must be one of - 'left', 'center', 'right'.`,\n );\n return defaultLetfCoordinate;\n }\n };\n\n private getPinDirectionalStyle = () => {\n switch (this.positionObject.direction) {\n case 'top':\n return this.styles.pinTop();\n case 'bottom':\n return this.styles.pinBottom();\n case 'left':\n return this.styles.pinLeft();\n case 'right':\n return this.styles.pinRight();\n default:\n warning(\n false,\n `Can't get directional style: invalid direction '${this.positionObject.direction}'. Must be one of - 'top', 'right', 'bottom', 'left'.`,\n );\n return this.styles.pinTop();\n }\n };\n}\n"]}
|
|
@@ -9,19 +9,25 @@ export var getStyles = memoizeGetStyles(function (_a) {
|
|
|
9
9
|
pin: function () {
|
|
10
10
|
return css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n "], ["\n position: absolute;\n "])));
|
|
11
11
|
},
|
|
12
|
+
pinAnimated: function () {
|
|
13
|
+
return css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n opacity: 1;\n transition:\n left 0.18s cubic-bezier(0.22, 0.61, 0.36, 1),\n top 0.18s cubic-bezier(0.22, 0.61, 0.36, 1),\n opacity 0.15s ease-out,\n visibility 0.15s ease-out;\n "], ["\n opacity: 1;\n transition:\n left 0.18s cubic-bezier(0.22, 0.61, 0.36, 1),\n top 0.18s cubic-bezier(0.22, 0.61, 0.36, 1),\n opacity 0.15s ease-out,\n visibility 0.15s ease-out;\n "])));
|
|
14
|
+
},
|
|
15
|
+
pinHidden: function () {
|
|
16
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n visibility: hidden;\n opacity: 0;\n "], ["\n visibility: hidden;\n opacity: 0;\n "])));
|
|
17
|
+
},
|
|
12
18
|
pinTop: function () {
|
|
13
|
-
return css(
|
|
19
|
+
return css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n clip-path: polygon(0 0, 50% 100%, 100% 0);\n "], ["\n clip-path: polygon(0 0, 50% 100%, 100% 0);\n "])));
|
|
14
20
|
},
|
|
15
21
|
pinBottom: function () {
|
|
16
|
-
return css(
|
|
22
|
+
return css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n clip-path: polygon(0 100%, 50% 0, 100% 100%);\n "], ["\n clip-path: polygon(0 100%, 50% 0, 100% 100%);\n "])));
|
|
17
23
|
},
|
|
18
24
|
pinLeft: function () {
|
|
19
|
-
return css(
|
|
25
|
+
return css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n clip-path: polygon(0 0, 100% 50%, 0 100%);\n "], ["\n clip-path: polygon(0 0, 100% 50%, 0 100%);\n "])));
|
|
20
26
|
},
|
|
21
27
|
pinRight: function () {
|
|
22
|
-
return css(
|
|
28
|
+
return css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n clip-path: polygon(100% 0, 0 50%, 100% 100%);\n "], ["\n clip-path: polygon(100% 0, 0 50%, 100% 100%);\n "])));
|
|
23
29
|
},
|
|
24
30
|
});
|
|
25
31
|
});
|
|
26
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
32
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
27
33
|
//# sourceMappingURL=PopupPin.styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupPin.styles.js","sourceRoot":"","sources":["../../../internal/Popup/PopupPin.styles.ts"],"names":[],"mappings":";;;;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,IAAM,SAAS,GAAG,gBAAgB,CAAC,UAAC,EAAgB;QAAd,GAAG,SAAA;IAAgB,OAAA,CAAC;QAC/D,GAAG;YACD,OAAO,GAAG,sGAAA,mCAET,KAAC;QACJ,CAAC;QAED,MAAM;YACJ,OAAO,GAAG,6HAAA,0DAET,KAAC;QACJ,CAAC;QAED,SAAS;YACP,OAAO,GAAG,gIAAA,6DAET,KAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,GAAG,6HAAA,0DAET,KAAC;QACJ,CAAC;QAED,QAAQ;YACN,OAAO,GAAG,gIAAA,6DAET,KAAC;QACJ,CAAC;KACF,CAAC;
|
|
1
|
+
{"version":3,"file":"PopupPin.styles.js","sourceRoot":"","sources":["../../../internal/Popup/PopupPin.styles.ts"],"names":[],"mappings":";;;;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,IAAM,SAAS,GAAG,gBAAgB,CAAC,UAAC,EAAgB;QAAd,GAAG,SAAA;IAAgB,OAAA,CAAC;QAC/D,GAAG;YACD,OAAO,GAAG,sGAAA,mCAET,KAAC;QACJ,CAAC;QAED,WAAW;YACT,OAAO,GAAG,mSAAA,gOAOT,KAAC;QACJ,CAAC;QAED,SAAS;YACP,OAAO,GAAG,yHAAA,sDAGT,KAAC;QACJ,CAAC;QAED,MAAM;YACJ,OAAO,GAAG,6HAAA,0DAET,KAAC;QACJ,CAAC;QAED,SAAS;YACP,OAAO,GAAG,gIAAA,6DAET,KAAC;QACJ,CAAC;QAED,OAAO;YACL,OAAO,GAAG,6HAAA,0DAET,KAAC;QACJ,CAAC;QAED,QAAQ;YACN,OAAO,GAAG,gIAAA,6DAET,KAAC;QACJ,CAAC;KACF,CAAC;AAhD8D,CAgD9D,CAAC,CAAC","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\n\nimport { memoizeGetStyles } from '../../lib/theming/Emotion.js';\n\nexport const getStyles = memoizeGetStyles(({ css }: Emotion) => ({\n pin() {\n return css`\n position: absolute;\n `;\n },\n\n pinAnimated() {\n return css`\n opacity: 1;\n transition:\n left 0.18s cubic-bezier(0.22, 0.61, 0.36, 1),\n top 0.18s cubic-bezier(0.22, 0.61, 0.36, 1),\n opacity 0.15s ease-out,\n visibility 0.15s ease-out;\n `;\n },\n\n pinHidden() {\n return css`\n visibility: hidden;\n opacity: 0;\n `;\n },\n\n pinTop() {\n return css`\n clip-path: polygon(0 0, 50% 100%, 100% 0);\n `;\n },\n\n pinBottom() {\n return css`\n clip-path: polygon(0 100%, 50% 0, 100% 100%);\n `;\n },\n\n pinLeft() {\n return css`\n clip-path: polygon(0 0, 100% 50%, 0 100%);\n `;\n },\n\n pinRight() {\n return css`\n clip-path: polygon(100% 0, 0 50%, 100% 100%);\n `;\n },\n}));\n"]}
|
|
@@ -80,12 +80,14 @@ export declare class PopupMenu extends React.Component<PopupMenuProps, PopupMenu
|
|
|
80
80
|
private captionWrapper;
|
|
81
81
|
private savedFocusableElement;
|
|
82
82
|
private menu;
|
|
83
|
+
private shouldRestoreFocusOnClose;
|
|
83
84
|
getRootNode: TGetRootNode;
|
|
84
85
|
private setRootNode;
|
|
85
86
|
render(): JSX.Element;
|
|
86
87
|
private renderMain;
|
|
87
88
|
open: () => void;
|
|
88
89
|
close: () => void;
|
|
90
|
+
componentDidUpdate(_prevProps: PopupMenuProps, prevState: PopupMenuState): void;
|
|
89
91
|
private menuRef;
|
|
90
92
|
private handleOpen;
|
|
91
93
|
private passPropsToCaption;
|
|
@@ -100,6 +102,5 @@ export declare class PopupMenu extends React.Component<PopupMenuProps, PopupMenu
|
|
|
100
102
|
private handleKeyDown;
|
|
101
103
|
private saveFocus;
|
|
102
104
|
private restoreFocus;
|
|
103
|
-
private handleChangeMenuVisible;
|
|
104
105
|
private handleItemSelection;
|
|
105
106
|
}
|
|
@@ -78,6 +78,7 @@ var PopupMenu = /** @class */ (function (_super) {
|
|
|
78
78
|
_this.captionWrapper = null;
|
|
79
79
|
_this.savedFocusableElement = null;
|
|
80
80
|
_this.menu = null;
|
|
81
|
+
_this.shouldRestoreFocusOnClose = false;
|
|
81
82
|
_this.open = function () { return _this.showMenu(); };
|
|
82
83
|
_this.close = function () { return _this.hideMenu(); };
|
|
83
84
|
_this.menuRef = function (element) {
|
|
@@ -120,19 +121,17 @@ var PopupMenu = /** @class */ (function (_super) {
|
|
|
120
121
|
_this.hideMenuWithoutFocusing = function () { return _this.hideMenu(); };
|
|
121
122
|
_this.showMenu = function (firstItemShouldBeSelected) {
|
|
122
123
|
_this.saveFocus();
|
|
124
|
+
_this.shouldRestoreFocusOnClose = false;
|
|
123
125
|
_this.setState({
|
|
124
126
|
menuVisible: true,
|
|
125
127
|
firstItemShouldBeSelected: firstItemShouldBeSelected,
|
|
126
|
-
}, function () {
|
|
127
|
-
_this.handleChangeMenuVisible(false);
|
|
128
128
|
});
|
|
129
129
|
};
|
|
130
130
|
_this.hideMenu = function (restoreFocus) {
|
|
131
|
+
_this.shouldRestoreFocusOnClose = !!restoreFocus;
|
|
131
132
|
_this.setState({
|
|
132
133
|
menuVisible: false,
|
|
133
134
|
firstItemShouldBeSelected: false,
|
|
134
|
-
}, function () {
|
|
135
|
-
_this.handleChangeMenuVisible(!!restoreFocus);
|
|
136
135
|
});
|
|
137
136
|
};
|
|
138
137
|
_this.toggleMenu = function () {
|
|
@@ -164,20 +163,6 @@ var PopupMenu = /** @class */ (function (_super) {
|
|
|
164
163
|
_this.savedFocusableElement = null;
|
|
165
164
|
}
|
|
166
165
|
};
|
|
167
|
-
_this.handleChangeMenuVisible = function (focusShouldBeRestored) {
|
|
168
|
-
if (focusShouldBeRestored) {
|
|
169
|
-
_this.restoreFocus();
|
|
170
|
-
}
|
|
171
|
-
if (_this.state.menuVisible && _this.props.onOpen) {
|
|
172
|
-
_this.props.onOpen();
|
|
173
|
-
}
|
|
174
|
-
if (!_this.state.menuVisible && _this.props.onClose) {
|
|
175
|
-
_this.props.onClose();
|
|
176
|
-
}
|
|
177
|
-
if (typeof _this.props.onChangeMenuState === 'function') {
|
|
178
|
-
_this.props.onChangeMenuState(_this.state.menuVisible, focusShouldBeRestored);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
166
|
_this.handleItemSelection = function (event) {
|
|
182
167
|
if (event.isDefaultPrevented()) {
|
|
183
168
|
return;
|
|
@@ -210,6 +195,24 @@ var PopupMenu = /** @class */ (function (_super) {
|
|
|
210
195
|
this.captionWrapper && this.props.children && (React.createElement(Popup, { id: (_a = this.props.popupMenuId) !== null && _a !== void 0 ? _a : this.rootId, anchorElement: this.captionWrapper, opened: this.state.menuVisible, hasShadow: true, margin: this.props.popupMargin, hasPin: popupHasPin, pinOffset: this.props.popupPinOffset, positions: this.getPositions(), disableAnimations: disableAnimations, onOpen: this.handleOpen, mobileOnCloseRequest: this.hideMenu, width: this.isMobileLayout ? 'auto' : this.props.menuWidth || 'auto' },
|
|
211
196
|
React.createElement(Menu, { maxHeight: this.isMobileLayout ? 'none' : this.props.menuMaxHeight || 'none', onKeyDown: this.handleKeyDown, onItemClick: this.handleItemSelection, preventIconsOffset: this.props.preventIconsOffset, cyclicSelection: false, ref: this.menuRef, initialSelectedItemIndex: this.state.firstItemShouldBeSelected ? 0 : -1, header: this.props.header, footer: this.props.footer }, this.props.children)))))));
|
|
212
197
|
};
|
|
198
|
+
PopupMenu.prototype.componentDidUpdate = function (_prevProps, prevState) {
|
|
199
|
+
var _a, _b, _c, _d, _e, _f;
|
|
200
|
+
if (prevState.menuVisible === this.state.menuVisible) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
var focusShouldBeRestored = !this.state.menuVisible && this.shouldRestoreFocusOnClose;
|
|
204
|
+
if (focusShouldBeRestored) {
|
|
205
|
+
this.restoreFocus();
|
|
206
|
+
}
|
|
207
|
+
if (this.state.menuVisible) {
|
|
208
|
+
(_b = (_a = this.props).onOpen) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
(_d = (_c = this.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
212
|
+
this.shouldRestoreFocusOnClose = false;
|
|
213
|
+
}
|
|
214
|
+
(_f = (_e = this.props).onChangeMenuState) === null || _f === void 0 ? void 0 : _f.call(_e, this.state.menuVisible, focusShouldBeRestored);
|
|
215
|
+
};
|
|
213
216
|
PopupMenu.prototype.getPositions = function () {
|
|
214
217
|
var positions = this.getProps().positions;
|
|
215
218
|
if (positions && isValidPositions(positions)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PopupMenu.js","sourceRoot":"","sources":["../../../internal/PopupMenu/PopupMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIjD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CA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CAAC,CAAC,CAAC,CAAC,CAAC,EACvE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,IAExB,IAAI,CAAC,KAAK,CAAC,QAAQ,CACf,CACD,CACT,CACG,CACM,CACA,CACjB,CAAC;IACJ,CAAC;IAoEO,gCAAY,GAApB;QACE,IAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC;QAC5C,IAAI,SAAS,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;IAlLa,6BAAmB,GAAG,WAAW,AAAd,CAAe;IAClC,qBAAW,GAAG,WAAW,AAAd,CAAe;IAQ1B,sBAAY,GAAiB;QACzC,SAAS,EAAE,SAAS;QACpB,IAAI,EAAE,aAAa,CAAC,OAAO;QAC3B,WAAW,EAAE,IAAI;QACjB,iBAAiB,EAAE,KAAK;KACzB,AALyB,CAKxB;IAIY,cAAI,GAAG,aAAa,AAAhB,CAAiB;IAnBxB,SAAS;QAHrB,qBAAqB;QACrB,QAAQ;QACR,gBAAgB;OACJ,SAAS,CA+QrB;IAAD,gBAAC;CAAA,AA/QD,CAA+B,KAAK,CAAC,SAAS,GA+Q7C;SA/QY,SAAS","sourcesContent":["import type { Emotion } from '@emotion/css/create-instance';\nimport type { AriaAttributes, HTMLAttributes, JSX } from 'react';\nimport React from 'react';\n\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator.js';\nimport { createPropsGetter } from '../../lib/createPropsGetter.js';\nimport {\n isKeyArrowVertical,\n isKeyEnter,\n isKeyEscape,\n isKeySpace,\n someKeys,\n} from '../../lib/events/keyboard/identifiers.js';\nimport type { GlobalObject } from '../../lib/globalObject.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory.js';\nimport { getRandomID } from '../../lib/utils.js';\nimport type { HTMLProps } from '../../typings/html.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport type { CommonProps } from '../CommonWrapper/index.js';\nimport { CommonWrapper } from '../CommonWrapper/index.js';\nimport { Menu } from '../Menu/index.js';\nimport type { MenuProps } from '../Menu/index.js';\nimport { Popup, PopupIds } from '../Popup/index.js';\nimport type { PopupPositionsType } from '../Popup/index.js';\nimport { RenderLayer } from '../RenderLayer/index.js';\nimport { getStyles } from './PopupMenu.styles.js';\nimport { PopupMenuDataTids } from './tids.js';\nimport { isValidPositions } from './validatePositions.js';\n\nexport * from './tids.js';\n\nexport interface PopupMenuCaptionProps {\n opened: boolean;\n openMenu: (firstItemShouldBeSelected?: boolean) => void;\n closeMenu: (restoreFocus?: boolean) => void;\n toggleMenu: () => void;\n /** @ignore */\n corners?: React.CSSProperties;\n}\n\nexport interface PopupMenuProps\n extends\n CommonProps,\n Pick<MenuProps, 'preventIconsOffset'>,\n Pick<HTMLAttributes<HTMLElement>, 'id'>,\n Pick<AriaAttributes, 'aria-label'> {\n children?: React.ReactNode;\n /** Максимальная высота меню */\n menuMaxHeight?: number | string;\n /** Ширина меню */\n menuWidth?: number | string;\n /** Ширина контейнера и caption */\n width?: React.CSSProperties['width'];\n\n /**\n * Элемент или функция возвращающая элемент,\n * если передана, используется вместо ```caption```,\n * в таком случае управлять открытием и закрытием меню\n * придется в этой функции\n */\n caption: React.ReactNode | ((props: PopupMenuCaptionProps) => React.ReactNode);\n\n header?: React.ReactNode;\n footer?: React.ReactNode;\n\n /** Массив разрешенных положений меню относительно caption'а. */\n positions?: PopupPositionsType[];\n /** Колбэк, вызываемый после открытия/закрытия меню */\n onChangeMenuState?: (isOpened: boolean, restoreFocus: boolean) => void;\n /** Пропсы, передающиеся в Popup */\n popupHasPin?: boolean;\n popupMargin?: number;\n popupPinOffset?: number;\n type?: 'dropdown' | 'tooltip';\n disableAnimations?: boolean;\n /** Действие при открытии меню. */\n onOpen?: () => void;\n /** Действие при закрытии меню. */\n onClose?: () => void;\n /** `id` выпадающего меню. */\n popupMenuId?: HTMLProps['id'];\n\n /** @ignore */\n corners?: React.CSSProperties;\n}\n\ninterface PopupMenuState {\n menuVisible: boolean;\n firstItemShouldBeSelected?: boolean;\n}\n\nexport const PopupMenuType = {\n Dropdown: 'dropdown',\n Tooltip: 'tooltip',\n} as const;\n\nconst Positions: PopupPositionsType[] = [\n 'top left',\n 'top center',\n 'top right',\n 'right top',\n 'right middle',\n 'right bottom',\n 'bottom left',\n 'bottom center',\n 'bottom right',\n 'left top',\n 'left middle',\n 'left bottom',\n];\n\ntype DefaultProps = Required<Pick<PopupMenuProps, 'positions' | 'type' | 'popupHasPin' | 'disableAnimations'>>;\n\n@withRenderEnvironment\n@rootNode\n@responsiveLayout\nexport class PopupMenu extends React.Component<PopupMenuProps, PopupMenuState> {\n public static __KONTUR_REACT_UI__ = 'PopupMenu';\n public static displayName = 'PopupMenu';\n\n private globalObject!: GlobalObject;\n private emotion!: Emotion;\n private styles!: ReturnType<typeof getStyles>;\n private isMobileLayout!: boolean;\n private rootId = PopupIds.root + getRandomID();\n\n public static defaultProps: DefaultProps = {\n positions: Positions,\n type: PopupMenuType.Tooltip,\n popupHasPin: true,\n disableAnimations: false,\n };\n\n private getProps = createPropsGetter(PopupMenu.defaultProps);\n\n public static Type = PopupMenuType;\n\n public state = {\n menuVisible: false,\n firstItemShouldBeSelected: false,\n };\n\n private captionWrapper: HTMLSpanElement | null = null;\n private savedFocusableElement: HTMLElement | null = null;\n private menu: Nullable<Menu> = null;\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n\n public render(): JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n return (\n <ThemeContext.Provider\n value={ThemeFactory.create(\n {\n menuOffsetY: theme.popupMenuMenuOffsetY,\n },\n theme,\n )}\n >\n {this.renderMain()}\n </ThemeContext.Provider>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { popupHasPin, disableAnimations } = this.getProps();\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <RenderLayer\n onClickOutside={this.hideMenuWithoutFocusing}\n onFocusOutside={this.hideMenuWithoutFocusing}\n active={this.state.menuVisible}\n >\n <div\n data-tid={PopupMenuDataTids.root}\n className={this.styles.container()}\n style={{ width: this.props.width }}\n >\n {this.renderCaption()}\n {this.captionWrapper && this.props.children && (\n <Popup\n id={this.props.popupMenuId ?? this.rootId}\n anchorElement={this.captionWrapper}\n opened={this.state.menuVisible}\n hasShadow\n margin={this.props.popupMargin}\n hasPin={popupHasPin}\n pinOffset={this.props.popupPinOffset}\n positions={this.getPositions()}\n disableAnimations={disableAnimations}\n onOpen={this.handleOpen}\n mobileOnCloseRequest={this.hideMenu}\n width={this.isMobileLayout ? 'auto' : this.props.menuWidth || 'auto'}\n >\n <Menu\n maxHeight={this.isMobileLayout ? 'none' : this.props.menuMaxHeight || 'none'}\n onKeyDown={this.handleKeyDown}\n onItemClick={this.handleItemSelection}\n preventIconsOffset={this.props.preventIconsOffset}\n cyclicSelection={false}\n ref={this.menuRef}\n initialSelectedItemIndex={this.state.firstItemShouldBeSelected ? 0 : -1}\n header={this.props.header}\n footer={this.props.footer}\n >\n {this.props.children}\n </Menu>\n </Popup>\n )}\n </div>\n </RenderLayer>\n </CommonWrapper>\n );\n }\n\n public open = (): void => this.showMenu();\n public close = (): void => this.hideMenu();\n\n private menuRef = (element: Nullable<Menu>) => {\n this.menu = element;\n };\n\n private handleOpen = () => {\n if (this.menu) {\n this.menu.focus();\n }\n };\n\n private passPropsToCaption = (caption: React.ReactNode) => {\n if (typeof caption === 'string' || typeof caption === 'number') {\n return caption;\n }\n\n return React.cloneElement(caption as React.ReactElement<any>, {\n id: this.props.id,\n 'aria-controls': this.props.popupMenuId ?? this.rootId,\n 'aria-expanded': this.state.menuVisible ? 'true' : 'false',\n 'aria-label': this.props['aria-label'],\n });\n };\n\n private renderCaption = () => {\n if (typeof this.props.caption === 'function') {\n const caption = this.props.caption({\n opened: this.state.menuVisible,\n openMenu: this.showMenu,\n closeMenu: this.hideMenu,\n toggleMenu: this.toggleMenu,\n corners: this.props.corners,\n });\n\n return (\n <span\n data-tid={PopupMenuDataTids.caption}\n className={this.styles.caption()}\n ref={(element) => {\n this.captionWrapper = element;\n }}\n >\n {this.passPropsToCaption(caption)}\n </span>\n );\n }\n\n return (\n <span\n data-tid={PopupMenuDataTids.caption}\n onClick={this.handleCaptionClick}\n onKeyDown={this.handleCaptionKeyDown}\n ref={(element) => {\n this.captionWrapper = element;\n }}\n className={this.styles.caption()}\n >\n {this.passPropsToCaption(this.props.caption)}\n </span>\n );\n };\n\n private hideMenuWithoutFocusing = () => this.hideMenu();\n\n private getPositions(): Readonly<PopupPositionsType[]> {\n const positions = this.getProps().positions;\n if (positions && isValidPositions(positions)) {\n return positions;\n }\n\n return Positions;\n }\n\n private showMenu = (firstItemShouldBeSelected?: boolean): void => {\n this.saveFocus();\n this.setState(\n {\n menuVisible: true,\n firstItemShouldBeSelected,\n },\n () => {\n this.handleChangeMenuVisible(false);\n },\n );\n };\n\n private hideMenu = (restoreFocus?: boolean): void => {\n this.setState(\n {\n menuVisible: false,\n firstItemShouldBeSelected: false,\n },\n () => {\n this.handleChangeMenuVisible(!!restoreFocus);\n },\n );\n };\n\n private toggleMenu = (): void => {\n this.state.menuVisible ? this.hideMenu() : this.showMenu();\n };\n\n private handleCaptionClick = (): void => {\n this.toggleMenu();\n };\n\n private handleCaptionKeyDown = (e: React.KeyboardEvent<HTMLElement>): void => {\n if (someKeys(isKeyEnter, isKeySpace, isKeyArrowVertical)(e)) {\n e.preventDefault();\n this.showMenu(true);\n }\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (isKeyEscape(e)) {\n const restoreFocus = true;\n this.hideMenu(restoreFocus);\n }\n };\n\n private saveFocus = (): void => {\n if (this.globalObject.document) {\n this.savedFocusableElement = this.globalObject.document.activeElement as HTMLElement;\n }\n };\n\n private restoreFocus = (): void => {\n if (this.savedFocusableElement) {\n this.savedFocusableElement.focus();\n this.savedFocusableElement = null;\n }\n };\n\n private handleChangeMenuVisible = (focusShouldBeRestored: boolean): void => {\n if (focusShouldBeRestored) {\n this.restoreFocus();\n }\n\n if (this.state.menuVisible && this.props.onOpen) {\n this.props.onOpen();\n }\n\n if (!this.state.menuVisible && this.props.onClose) {\n this.props.onClose();\n }\n\n if (typeof this.props.onChangeMenuState === 'function') {\n this.props.onChangeMenuState(this.state.menuVisible, focusShouldBeRestored);\n }\n };\n\n private handleItemSelection = (event: React.SyntheticEvent<HTMLElement>): void => {\n if (event.isDefaultPrevented()) {\n return;\n }\n\n if (event.type === 'keydown') {\n event.preventDefault();\n }\n\n const restoreFocus = event.type === 'keydown';\n this.hideMenu(restoreFocus);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PopupMenu.js","sourceRoot":"","sources":["../../../internal/PopupMenu/PopupMenu.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,GACT,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,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'react';\nimport React from 'react';\n\nimport { responsiveLayout } from '../../components/ResponsiveLayout/decorator.js';\nimport { createPropsGetter } from '../../lib/createPropsGetter.js';\nimport {\n isKeyArrowVertical,\n isKeyEnter,\n isKeyEscape,\n isKeySpace,\n someKeys,\n} from '../../lib/events/keyboard/identifiers.js';\nimport type { GlobalObject } from '../../lib/globalObject.js';\nimport { withRenderEnvironment } from '../../lib/renderEnvironment/index.js';\nimport type { TGetRootNode, TSetRootNode } from '../../lib/rootNode/index.js';\nimport { rootNode } from '../../lib/rootNode/index.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport { ThemeFactory } from '../../lib/theming/ThemeFactory.js';\nimport { getRandomID } from '../../lib/utils.js';\nimport type { HTMLProps } from '../../typings/html.js';\nimport type { Nullable } from '../../typings/utility-types.js';\nimport type { CommonProps } from '../CommonWrapper/index.js';\nimport { CommonWrapper } from '../CommonWrapper/index.js';\nimport { Menu } from '../Menu/index.js';\nimport type { MenuProps } from '../Menu/index.js';\nimport { Popup, PopupIds } from '../Popup/index.js';\nimport type { PopupPositionsType } from '../Popup/index.js';\nimport { RenderLayer } from '../RenderLayer/index.js';\nimport { getStyles } from './PopupMenu.styles.js';\nimport { PopupMenuDataTids } from './tids.js';\nimport { isValidPositions } from './validatePositions.js';\n\nexport * from './tids.js';\n\nexport interface PopupMenuCaptionProps {\n opened: boolean;\n openMenu: (firstItemShouldBeSelected?: boolean) => void;\n closeMenu: (restoreFocus?: boolean) => void;\n toggleMenu: () => void;\n /** @ignore */\n corners?: React.CSSProperties;\n}\n\nexport interface PopupMenuProps\n extends\n CommonProps,\n Pick<MenuProps, 'preventIconsOffset'>,\n Pick<HTMLAttributes<HTMLElement>, 'id'>,\n Pick<AriaAttributes, 'aria-label'> {\n children?: React.ReactNode;\n /** Максимальная высота меню */\n menuMaxHeight?: number | string;\n /** Ширина меню */\n menuWidth?: number | string;\n /** Ширина контейнера и caption */\n width?: React.CSSProperties['width'];\n\n /**\n * Элемент или функция возвращающая элемент,\n * если передана, используется вместо ```caption```,\n * в таком случае управлять открытием и закрытием меню\n * придется в этой функции\n */\n caption: React.ReactNode | ((props: PopupMenuCaptionProps) => React.ReactNode);\n\n header?: React.ReactNode;\n footer?: React.ReactNode;\n\n /** Массив разрешенных положений меню относительно caption'а. */\n positions?: PopupPositionsType[];\n /** Колбэк, вызываемый после открытия/закрытия меню */\n onChangeMenuState?: (isOpened: boolean, restoreFocus: boolean) => void;\n /** Пропсы, передающиеся в Popup */\n popupHasPin?: boolean;\n popupMargin?: number;\n popupPinOffset?: number;\n type?: 'dropdown' | 'tooltip';\n disableAnimations?: boolean;\n /** Действие при открытии меню. */\n onOpen?: () => void;\n /** Действие при закрытии меню. */\n onClose?: () => void;\n /** `id` выпадающего меню. */\n popupMenuId?: HTMLProps['id'];\n\n /** @ignore */\n corners?: React.CSSProperties;\n}\n\ninterface PopupMenuState {\n menuVisible: boolean;\n firstItemShouldBeSelected?: boolean;\n}\n\nexport const PopupMenuType = {\n Dropdown: 'dropdown',\n Tooltip: 'tooltip',\n} as const;\n\nconst Positions: PopupPositionsType[] = [\n 'top left',\n 'top center',\n 'top right',\n 'right top',\n 'right middle',\n 'right bottom',\n 'bottom left',\n 'bottom center',\n 'bottom right',\n 'left top',\n 'left middle',\n 'left bottom',\n];\n\ntype DefaultProps = Required<Pick<PopupMenuProps, 'positions' | 'type' | 'popupHasPin' | 'disableAnimations'>>;\n\n@withRenderEnvironment\n@rootNode\n@responsiveLayout\nexport class PopupMenu extends React.Component<PopupMenuProps, PopupMenuState> {\n public static __KONTUR_REACT_UI__ = 'PopupMenu';\n public static displayName = 'PopupMenu';\n\n private globalObject!: GlobalObject;\n private emotion!: Emotion;\n private styles!: ReturnType<typeof getStyles>;\n private isMobileLayout!: boolean;\n private rootId = PopupIds.root + getRandomID();\n\n public static defaultProps: DefaultProps = {\n positions: Positions,\n type: PopupMenuType.Tooltip,\n popupHasPin: true,\n disableAnimations: false,\n };\n\n private getProps = createPropsGetter(PopupMenu.defaultProps);\n\n public static Type = PopupMenuType;\n\n public state = {\n menuVisible: false,\n firstItemShouldBeSelected: false,\n };\n\n private captionWrapper: HTMLSpanElement | null = null;\n private savedFocusableElement: HTMLElement | null = null;\n private menu: Nullable<Menu> = null;\n private shouldRestoreFocusOnClose = false;\n public getRootNode!: TGetRootNode;\n private setRootNode!: TSetRootNode;\n\n public render(): JSX.Element {\n this.styles = getStyles(this.emotion);\n\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n return (\n <ThemeContext.Provider\n value={ThemeFactory.create(\n {\n menuOffsetY: theme.popupMenuMenuOffsetY,\n },\n theme,\n )}\n >\n {this.renderMain()}\n </ThemeContext.Provider>\n );\n }}\n </ThemeContext.Consumer>\n );\n }\n\n private renderMain() {\n const { popupHasPin, disableAnimations } = this.getProps();\n return (\n <CommonWrapper rootNodeRef={this.setRootNode} {...this.props}>\n <RenderLayer\n onClickOutside={this.hideMenuWithoutFocusing}\n onFocusOutside={this.hideMenuWithoutFocusing}\n active={this.state.menuVisible}\n >\n <div\n data-tid={PopupMenuDataTids.root}\n className={this.styles.container()}\n style={{ width: this.props.width }}\n >\n {this.renderCaption()}\n {this.captionWrapper && this.props.children && (\n <Popup\n id={this.props.popupMenuId ?? this.rootId}\n anchorElement={this.captionWrapper}\n opened={this.state.menuVisible}\n hasShadow\n margin={this.props.popupMargin}\n hasPin={popupHasPin}\n pinOffset={this.props.popupPinOffset}\n positions={this.getPositions()}\n disableAnimations={disableAnimations}\n onOpen={this.handleOpen}\n mobileOnCloseRequest={this.hideMenu}\n width={this.isMobileLayout ? 'auto' : this.props.menuWidth || 'auto'}\n >\n <Menu\n maxHeight={this.isMobileLayout ? 'none' : this.props.menuMaxHeight || 'none'}\n onKeyDown={this.handleKeyDown}\n onItemClick={this.handleItemSelection}\n preventIconsOffset={this.props.preventIconsOffset}\n cyclicSelection={false}\n ref={this.menuRef}\n initialSelectedItemIndex={this.state.firstItemShouldBeSelected ? 0 : -1}\n header={this.props.header}\n footer={this.props.footer}\n >\n {this.props.children}\n </Menu>\n </Popup>\n )}\n </div>\n </RenderLayer>\n </CommonWrapper>\n );\n }\n\n public open = (): void => this.showMenu();\n public close = (): void => this.hideMenu();\n\n public componentDidUpdate(_prevProps: PopupMenuProps, prevState: PopupMenuState): void {\n if (prevState.menuVisible === this.state.menuVisible) {\n return;\n }\n\n const focusShouldBeRestored = !this.state.menuVisible && this.shouldRestoreFocusOnClose;\n\n if (focusShouldBeRestored) {\n this.restoreFocus();\n }\n\n if (this.state.menuVisible) {\n this.props.onOpen?.();\n } else {\n this.props.onClose?.();\n this.shouldRestoreFocusOnClose = false;\n }\n\n this.props.onChangeMenuState?.(this.state.menuVisible, focusShouldBeRestored);\n }\n\n private menuRef = (element: Nullable<Menu>) => {\n this.menu = element;\n };\n\n private handleOpen = () => {\n if (this.menu) {\n this.menu.focus();\n }\n };\n\n private passPropsToCaption = (caption: React.ReactNode) => {\n if (typeof caption === 'string' || typeof caption === 'number') {\n return caption;\n }\n\n return React.cloneElement(caption as React.ReactElement<any>, {\n id: this.props.id,\n 'aria-controls': this.props.popupMenuId ?? this.rootId,\n 'aria-expanded': this.state.menuVisible ? 'true' : 'false',\n 'aria-label': this.props['aria-label'],\n });\n };\n\n private renderCaption = () => {\n if (typeof this.props.caption === 'function') {\n const caption = this.props.caption({\n opened: this.state.menuVisible,\n openMenu: this.showMenu,\n closeMenu: this.hideMenu,\n toggleMenu: this.toggleMenu,\n corners: this.props.corners,\n });\n\n return (\n <span\n data-tid={PopupMenuDataTids.caption}\n className={this.styles.caption()}\n ref={(element) => {\n this.captionWrapper = element;\n }}\n >\n {this.passPropsToCaption(caption)}\n </span>\n );\n }\n\n return (\n <span\n data-tid={PopupMenuDataTids.caption}\n onClick={this.handleCaptionClick}\n onKeyDown={this.handleCaptionKeyDown}\n ref={(element) => {\n this.captionWrapper = element;\n }}\n className={this.styles.caption()}\n >\n {this.passPropsToCaption(this.props.caption)}\n </span>\n );\n };\n\n private hideMenuWithoutFocusing = () => this.hideMenu();\n\n private getPositions(): Readonly<PopupPositionsType[]> {\n const positions = this.getProps().positions;\n if (positions && isValidPositions(positions)) {\n return positions;\n }\n\n return Positions;\n }\n\n private showMenu = (firstItemShouldBeSelected?: boolean): void => {\n this.saveFocus();\n this.shouldRestoreFocusOnClose = false;\n this.setState({\n menuVisible: true,\n firstItemShouldBeSelected,\n });\n };\n\n private hideMenu = (restoreFocus?: boolean): void => {\n this.shouldRestoreFocusOnClose = !!restoreFocus;\n this.setState({\n menuVisible: false,\n firstItemShouldBeSelected: false,\n });\n };\n\n private toggleMenu = (): void => {\n this.state.menuVisible ? this.hideMenu() : this.showMenu();\n };\n\n private handleCaptionClick = (): void => {\n this.toggleMenu();\n };\n\n private handleCaptionKeyDown = (e: React.KeyboardEvent<HTMLElement>): void => {\n if (someKeys(isKeyEnter, isKeySpace, isKeyArrowVertical)(e)) {\n e.preventDefault();\n this.showMenu(true);\n }\n };\n\n private handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (isKeyEscape(e)) {\n const restoreFocus = true;\n this.hideMenu(restoreFocus);\n }\n };\n\n private saveFocus = (): void => {\n if (this.globalObject.document) {\n this.savedFocusableElement = this.globalObject.document.activeElement as HTMLElement;\n }\n };\n\n private restoreFocus = (): void => {\n if (this.savedFocusableElement) {\n this.savedFocusableElement.focus();\n this.savedFocusableElement = null;\n }\n };\n\n private handleItemSelection = (event: React.SyntheticEvent<HTMLElement>): void => {\n if (event.isDefaultPrevented()) {\n return;\n }\n\n if (event.type === 'keydown') {\n event.preventDefault();\n }\n\n const restoreFocus = event.type === 'keydown';\n this.hideMenu(restoreFocus);\n };\n}\n"]}
|
|
@@ -12,17 +12,17 @@ export interface SpinnerIconProps {
|
|
|
12
12
|
color?: React.CSSProperties['color'];
|
|
13
13
|
}
|
|
14
14
|
export declare const sizes: {
|
|
15
|
-
readonly
|
|
15
|
+
readonly large: {
|
|
16
16
|
readonly size: 96;
|
|
17
17
|
readonly width: 4;
|
|
18
18
|
readonly radius: 32;
|
|
19
19
|
};
|
|
20
|
-
readonly
|
|
20
|
+
readonly medium: {
|
|
21
21
|
readonly size: 48;
|
|
22
22
|
readonly width: 2;
|
|
23
23
|
readonly radius: 16;
|
|
24
24
|
};
|
|
25
|
-
readonly
|
|
25
|
+
readonly small: {
|
|
26
26
|
readonly size: 16;
|
|
27
27
|
readonly width: 1.5;
|
|
28
28
|
readonly radius: 6;
|
|
@@ -2,17 +2,17 @@ import React from 'react';
|
|
|
2
2
|
import { useEmotion, useStyles } from '../../lib/renderEnvironment/index.js';
|
|
3
3
|
import { getStyles } from './SpinnerIcon.styles.js';
|
|
4
4
|
export var sizes = {
|
|
5
|
-
|
|
5
|
+
large: {
|
|
6
6
|
size: 96,
|
|
7
7
|
width: 4,
|
|
8
8
|
radius: 32,
|
|
9
9
|
},
|
|
10
|
-
|
|
10
|
+
medium: {
|
|
11
11
|
size: 48,
|
|
12
12
|
width: 2,
|
|
13
13
|
radius: 16,
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
small: {
|
|
16
16
|
size: 16,
|
|
17
17
|
width: 1.5,
|
|
18
18
|
radius: 6,
|
|
@@ -25,7 +25,7 @@ export var SpinnerIcon = function (_a) {
|
|
|
25
25
|
var _b, _c;
|
|
26
26
|
var size = _a.size, className = _a.className, inline = _a.inline, width = _a.width, color = _a.color;
|
|
27
27
|
var _size = isSizeAlias(size) ? sizes[size] : size;
|
|
28
|
-
var currentSize = inline ? sizes.
|
|
28
|
+
var currentSize = inline ? sizes.small : _size;
|
|
29
29
|
var cx = useEmotion().cx;
|
|
30
30
|
var styles = useStyles(getStyles);
|
|
31
31
|
return (React.createElement("span", { className: cx(styles.root(), (_b = {}, _b[styles.rootInline()] = inline, _b)) },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpinnerIcon.js","sourceRoot":"","sources":["../../../internal/SpinnerIcon/SpinnerIcon.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,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A,EAAE,GAAK,UAAU,EAAE,GAAjB,CAAkB;IAC5B,IAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IAEpC,OAAO,CACL,8BAAM,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,YAAI,GAAC,MAAM,CAAC,UAAU,EAAE,IAAG,MAAM,MAAG;QACnE,6BACE,OAAO,EAAE,cAAO,WAAW,CAAC,IAAI,cAAI,WAAW,CAAC,IAAI,CAAE,EACtD,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,SAAS;gBACpC,GAAC,MAAM,CAAC,UAAU,EAAE,IAAG,MAAM;oBAC7B,EACF,KAAK,EAAE,WAAW,CAAC,IAAI,EACvB,MAAM,EAAE,WAAW,CAAC,IAAI,EACxB,IAAI,EAAC,MAAM,EACX,MAAM,EAAE,KAAK,EACb,eAAe,EAAE,UAAG,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,eAAK,CAAC,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAE,EACrF,gBAAgB,EAAC,GAAG,EACpB,WAAW,EAAE,KAAK,IAAI,WAAW,CAAC,KAAK,EACvC,SAAS,EAAC,OAAO,iBACL,MAAM;YAElB,gCAAQ,EAAE,EAAE,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE,EAAE,EAAE,WAAW,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,MAAM,GAAI,CACjF,CACD,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from 'react';\n\nimport { useEmotion, useStyles } from '../../lib/renderEnvironment/index.js';\nimport { getStyles } from './SpinnerIcon.styles.js';\n\ninterface SpinnerIconSize {\n size: number;\n width: number;\n radius: number;\n}\n\nexport interface SpinnerIconProps {\n className?: string;\n size: SpinnerIconSize | keyof typeof sizes;\n inline?: boolean;\n width?: number;\n color?: React.CSSProperties['color'];\n}\n\nexport const sizes = {\n large: {\n size: 96,\n width: 4,\n radius: 32,\n },\n medium: {\n size: 48,\n width: 2,\n radius: 16,\n },\n small: {\n size: 16,\n width: 1.5,\n radius: 6,\n },\n} as const;\n\nconst isSizeAlias = (size: unknown): size is keyof typeof sizes => {\n return typeof size === 'string' && size in sizes;\n};\n\nexport const SpinnerIcon = ({ size, className, inline, width, color }: SpinnerIconProps) => {\n const _size = isSizeAlias(size) ? sizes[size] : size;\n const currentSize = inline ? sizes.small : _size;\n\n const { cx } = useEmotion();\n const styles = useStyles(getStyles);\n\n return (\n <span className={cx(styles.root(), { [styles.rootInline()]: inline })}>\n <svg\n viewBox={`0 0 ${currentSize.size} ${currentSize.size}`}\n className={cx(styles.icon(), className, {\n [styles.iconInline()]: inline,\n })}\n width={currentSize.size}\n height={currentSize.size}\n fill=\"none\"\n stroke={color}\n strokeDasharray={`${(10 * currentSize.radius) / 6}, ${(27 * currentSize.radius) / 6}`}\n strokeDashoffset=\"0\"\n strokeWidth={width || currentSize.width}\n focusable=\"false\"\n aria-hidden=\"true\"\n >\n <circle cx={currentSize.size / 2} cy={currentSize.size / 2} r={currentSize.radius} />\n </svg>\n </span>\n );\n};\n"]}
|
|
@@ -22,7 +22,7 @@ var Icon = function (props) {
|
|
|
22
22
|
return (React.createElement(SpinnerIcon, __assign({ className: cx(styles.circle(theme), styles.circleDimmedColor(theme), styles.circleWithoutColorAnimation()) }, props)));
|
|
23
23
|
};
|
|
24
24
|
export var LoadingIcon = iconSizer({
|
|
25
|
-
small: function () { return React.createElement(Icon, { size: "
|
|
25
|
+
small: function () { return React.createElement(Icon, { size: "small" }); },
|
|
26
26
|
medium: function () { return (React.createElement(Icon, { size: {
|
|
27
27
|
size: 20,
|
|
28
28
|
width: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingIcon.js","sourceRoot":"","sources":["../../../internal/icons2022/LoadingIcon.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,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AgB,CAAC;AAE3C,IAAM,IAAI,GAAG,UAAC,KAAuB;IAC3B,IAAA,EAAE,GAAK,UAAU,EAAE,GAAjB,CAAkB;IAC5B,IAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,IAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7C,OAAO,CACL,oBAAC,WAAW,aACV,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,2BAA2B,EAAE,CAAC,IACtG,KAAK,EACT,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,WAAW,GAAG,SAAS,CAClC;IACE,KAAK,EAAE,cAAM,OAAA,oBAAC,IAAI,IAAC,IAAI,EAAC,OAAO,GAAG,EAArB,CAAqB;IAClC,MAAM,EAAE,cAAM,OAAA,CACZ,oBAAC,IAAI,IACH,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;SACV,GACD,CACH,EARa,CAQb;IACD,KAAK,EAAE,cAAM,OAAA,CACX,oBAAC,IAAI,IACH,IAAI,EAAE;YACJ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,CAAC;SACV,GACD,CACH,EARY,CAQZ;CACF,EACD,aAAa,CACd,CAAC","sourcesContent":["import React from 'react';\n\nimport { getStyles } from '../../components/Spinner/Spinner.styles.js';\nimport { useEmotion, useStyles } from '../../lib/renderEnvironment/index.js';\nimport { ThemeContext } from '../../lib/theming/ThemeContext.js';\nimport { SpinnerIcon } from '../SpinnerIcon/SpinnerIcon.js';\nimport type { SpinnerIconProps } from '../SpinnerIcon/SpinnerIcon.js';\nimport { iconSizer } from './iconSizer.js';\n\nconst Icon = (props: SpinnerIconProps) => {\n const { cx } = useEmotion();\n const styles = useStyles(getStyles);\n const theme = React.useContext(ThemeContext);\n return (\n <SpinnerIcon\n className={cx(styles.circle(theme), styles.circleDimmedColor(theme), styles.circleWithoutColorAnimation())}\n {...props}\n />\n );\n};\n\nexport const LoadingIcon = iconSizer<Omit<SpinnerIconProps, 'size'>>(\n {\n small: () => <Icon size=\"small\" />,\n medium: () => (\n <Icon\n size={{\n size: 20,\n width: 1,\n radius: 6,\n }}\n />\n ),\n large: () => (\n <Icon\n size={{\n size: 24,\n width: 1.5,\n radius: 8,\n }}\n />\n ),\n },\n 'LoadingIcon',\n);\n"]}
|