@jetbrains/ring-ui-built 7.0.66 → 7.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/_helpers/anchor.js +12 -17
- package/components/_helpers/avatar-info.js +4 -5
- package/components/_helpers/button.classes.js +20 -21
- package/components/_helpers/caption.js +3 -3
- package/components/_helpers/card.js +26 -32
- package/components/_helpers/dialog-body-scroll-preventer.js +1 -2
- package/components/_helpers/icon-svg.js +9 -12
- package/components/_helpers/input.js +78 -86
- package/components/_helpers/loader-core.js +260 -0
- package/components/_helpers/query-assist-suggestions.js +0 -1
- package/components/_helpers/select-filter.js +19 -26
- package/components/_helpers/services-link.js +9 -12
- package/components/_helpers/sidebar.js +36 -44
- package/components/_helpers/tab-link.js +9 -11
- package/components/_helpers/theme.js +20 -24
- package/components/_helpers/title.js +12 -17
- package/components/alert/alert.js +41 -49
- package/components/alert/container.js +9 -12
- package/components/alert-service/alert-service.js +23 -32
- package/components/analytics/analytics-custom-plugin.js +12 -17
- package/components/analytics/analytics.js +1 -3
- package/components/auth/auth-core.js +128 -170
- package/components/auth/auth.js +3 -10
- package/components/auth/background-flow.js +5 -8
- package/components/auth/down-notification.js +9 -17
- package/components/auth/iframe-flow.js +13 -19
- package/components/auth/request-builder.js +4 -9
- package/components/auth/response-parser.js +9 -12
- package/components/auth/storage.js +12 -18
- package/components/auth/token-validator.js +19 -30
- package/components/auth/window-flow.js +22 -27
- package/components/auth-dialog/auth-dialog.js +40 -48
- package/components/auth-dialog-service/auth-dialog-service.js +10 -13
- package/components/avatar/avatar.figma.js +6 -6
- package/components/avatar/avatar.js +58 -59
- package/components/avatar/fallback-avatar.js +8 -11
- package/components/avatar-stack/avatar-stack.figma.js +10 -11
- package/components/avatar-stack/avatar-stack.js +25 -31
- package/components/banner/banner.js +0 -6
- package/components/breadcrumbs/breadcrumbs.figma.js +8 -6
- package/components/breadcrumbs/breadcrumbs.js +4 -5
- package/components/button/button.figma.js +15 -10
- package/components/button/button.js +59 -64
- package/components/button-group/button-group.js +11 -15
- package/components/button-group/caption.js +0 -1
- package/components/button-set/button-set.js +9 -12
- package/components/button-toolbar/button-toolbar.js +8 -11
- package/components/caret/caret.js +20 -28
- package/components/checkbox/checkbox-group.figma.js +8 -10
- package/components/checkbox/checkbox.figma.js +5 -5
- package/components/checkbox/checkbox.js +27 -35
- package/components/clipboard/clipboard-fallback.js +3 -3
- package/components/clipboard/clipboard.js +3 -16
- package/components/code/code.js +8 -14
- package/components/collapse/collapse-content.js +10 -15
- package/components/collapse/collapse-control.js +5 -7
- package/components/collapse/collapse.js +9 -11
- package/components/collapse/utils.js +1 -1
- package/components/confirm/confirm.js +17 -26
- package/components/confirm-service/confirm-service.js +30 -31
- package/components/content-layout/content-layout.js +21 -28
- package/components/content-layout/sidebar.js +0 -2
- package/components/contenteditable/contenteditable.js +23 -28
- package/components/control-help/control-help.js +8 -10
- package/components/control-label/control-label.js +12 -17
- package/components/data-list/data-list.js +57 -65
- package/components/data-list/data-list.mock.js +0 -4
- package/components/data-list/item.js +65 -72
- package/components/data-list/selection.js +11 -19
- package/components/data-list/title.js +0 -4
- package/components/date-picker/consts.js +3 -4
- package/components/date-picker/date-input.js +25 -33
- package/components/date-picker/date-picker.js +179 -193
- package/components/date-picker/date-popup.js +135 -127
- package/components/date-picker/day.d.ts +1 -1
- package/components/date-picker/day.js +24 -30
- package/components/date-picker/month-names.js +7 -12
- package/components/date-picker/month-slider.js +16 -22
- package/components/date-picker/month.js +3 -5
- package/components/date-picker/months.js +6 -6
- package/components/date-picker/weekdays.js +0 -1
- package/components/date-picker/years.js +20 -26
- package/components/dialog/dialog-body-scroll-preventer.js +0 -1
- package/components/dialog/dialog.js +73 -83
- package/components/dropdown/anchor.js +0 -4
- package/components/dropdown/dropdown.js +98 -114
- package/components/dropdown-menu/dropdown-menu.js +80 -79
- package/components/editable-heading/editable-heading.js +48 -54
- package/components/error-bubble/error-bubble.figma.js +4 -4
- package/components/error-bubble/error-bubble.js +9 -13
- package/components/error-message/error-message.js +1 -6
- package/components/footer/footer.js +11 -15
- package/components/global/compose-refs.js +1 -4
- package/components/global/compose.js +1 -4
- package/components/global/configuration.js +3 -3
- package/components/global/controls-height.js +0 -1
- package/components/global/create-stateful-context.js +10 -14
- package/components/global/data-tests.js +2 -10
- package/components/global/dom.js +6 -19
- package/components/global/focus-sensor-hoc.js +74 -87
- package/components/global/fuzzy-highlight.js +3 -8
- package/components/global/get-uid.js +1 -1
- package/components/global/inject-styles.js +5 -6
- package/components/global/listeners.js +2 -11
- package/components/global/memoize.js +0 -2
- package/components/global/normalize-indent.js +2 -6
- package/components/global/promise-with-timeout.js +4 -5
- package/components/global/react-dom-renderer.js +4 -9
- package/components/global/rerender-hoc.js +8 -11
- package/components/global/schedule-raf.js +1 -2
- package/components/global/theme.js +0 -5
- package/components/global/trivial-template-tag.js +1 -6
- package/components/global/url.js +2 -6
- package/components/global/use-event-callback.js +2 -3
- package/components/grid/col.js +7 -18
- package/components/grid/grid.js +9 -14
- package/components/grid/row.js +7 -11
- package/components/group/group.js +9 -12
- package/components/header/header-icon.js +8 -13
- package/components/header/header.js +16 -27
- package/components/header/links.js +7 -10
- package/components/header/logo.js +12 -16
- package/components/header/profile.js +73 -83
- package/components/header/services-link.js +0 -2
- package/components/header/services.js +32 -43
- package/components/header/smart-profile.js +44 -59
- package/components/header/smart-services.js +33 -45
- package/components/header/tray.js +8 -10
- package/components/heading/heading.js +27 -27
- package/components/http/http.js +120 -125
- package/components/http/http.mock.js +6 -10
- package/components/hub-source/hub-source-user.js +6 -13
- package/components/hub-source/hub-source-users-groups.js +8 -12
- package/components/hub-source/hub-source.js +8 -10
- package/components/i18n/i18n-context.js +4 -7
- package/components/i18n/i18n.js +5 -5
- package/components/icon/icon-svg.js +0 -4
- package/components/icon/icon.js +28 -32
- package/components/icon/index.js +0 -4
- package/components/input/input.figma.js +8 -8
- package/components/input/input.js +0 -4
- package/components/island/adaptive-island-hoc.js +19 -23
- package/components/island/content.js +70 -75
- package/components/island/header.js +21 -21
- package/components/island/island.js +11 -14
- package/components/link/clickable-link.js +30 -37
- package/components/link/link.js +27 -29
- package/components/list/list-custom.js +6 -11
- package/components/list/list-item.js +49 -56
- package/components/list/list-separator.js +0 -1
- package/components/list/list-title.js +0 -1
- package/components/list/list-users-groups-source.js +14 -22
- package/components/list/list.classes.js +8 -9
- package/components/list/list.js +387 -404
- package/components/loader/loader-core.js +2 -265
- package/components/loader/loader.d.ts +8 -0
- package/components/loader/loader.js +43 -29
- package/components/loader-inline/loader-inline.js +9 -12
- package/components/loader-screen/loader-screen.js +10 -14
- package/components/login-dialog/login-dialog.js +46 -54
- package/components/login-dialog/service.js +13 -15
- package/components/message/message.js +65 -79
- package/components/old-browsers-message/old-browsers-message-stop.js +0 -3
- package/components/old-browsers-message/old-browsers-message.js +1 -4
- package/components/old-browsers-message/white-list.js +5 -7
- package/components/pager/pager.js +73 -88
- package/components/panel/panel.js +9 -12
- package/components/permissions/permissions-cache.js +6 -8
- package/components/permissions/permissions.js +19 -21
- package/components/popup/popup.js +136 -145
- package/components/popup/popup.target.js +8 -10
- package/components/popup/position-css.js +19 -27
- package/components/popup/position.js +22 -28
- package/components/popup-menu/popup-menu.js +27 -37
- package/components/progress-bar/progress-bar.js +26 -32
- package/components/query-assist/query-assist-suggestions.js +0 -6
- package/components/query-assist/query-assist.js +432 -468
- package/components/radio/radio-item.js +30 -40
- package/components/radio/radio.js +6 -10
- package/components/scrollable-section/scrollable-section.js +7 -10
- package/components/select/select-filter.js +0 -6
- package/components/select/select-popup.js +155 -174
- package/components/select/select.js +464 -479
- package/components/shortcuts/core.js +40 -45
- package/components/shortcuts/shortcut-title.js +0 -1
- package/components/shortcuts/shortcuts-hoc.js +9 -15
- package/components/shortcuts/shortcuts.js +3 -5
- package/components/slider/slider.js +53 -66
- package/components/slider/slider.utils.js +1 -4
- package/components/storage/storage-local.js +2 -8
- package/components/storage/storage.js +0 -5
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +21 -30
- package/components/table/cell.js +3 -4
- package/components/table/disable-hover-hoc.js +24 -28
- package/components/table/header-cell.js +30 -38
- package/components/table/header.js +20 -28
- package/components/table/multitable.js +81 -101
- package/components/table/row-with-focus-sensor.js +17 -28
- package/components/table/row.js +89 -99
- package/components/table/selection-adapter.js +0 -2
- package/components/table/selection-shortcuts-hoc.js +159 -161
- package/components/table/selection.js +23 -31
- package/components/table/simple-table.js +16 -22
- package/components/table/smart-table.js +19 -26
- package/components/table/table.js +137 -146
- package/components/tabs/collapsible-more.js +34 -47
- package/components/tabs/collapsible-tab.js +28 -33
- package/components/tabs/collapsible-tabs.js +16 -24
- package/components/tabs/custom-item.js +3 -6
- package/components/tabs/dumb-tabs.js +48 -64
- package/components/tabs/smart-tabs.js +14 -23
- package/components/tabs/tab-link.js +0 -2
- package/components/tabs/tab.js +0 -1
- package/components/tabs/tabs.js +0 -7
- package/components/tag/tag.js +30 -35
- package/components/tags-input/tags-input.js +192 -218
- package/components/tags-list/tags-list.js +26 -31
- package/components/text/text.js +16 -19
- package/components/toggle/toggle.js +19 -23
- package/components/tooltip/tooltip.js +110 -121
- package/components/upload/upload.js +19 -28
- package/components/user-agreement/service.js +247 -252
- package/components/user-agreement/toolbox.eula.js +160 -1
- package/components/user-agreement/user-agreement.js +23 -32
- package/components/user-card/card.js +0 -5
- package/components/user-card/smart-user-card-tooltip.js +41 -50
- package/components/user-card/tooltip.js +32 -38
- package/components/user-card/user-card.js +0 -5
- package/package.json +9 -3
- package/components/_helpers/_rollupPluginBabelHelpers.js +0 -72
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import { a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import { jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { PureComponent } from 'react';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
|
|
6
5
|
var styles = {"panel":"ring-panel-panel"};
|
|
7
6
|
|
|
8
|
-
const _excluded = ["className", "children"];
|
|
9
7
|
/**
|
|
10
8
|
* @name Panel
|
|
11
9
|
*/
|
|
12
10
|
class Panel extends PureComponent {
|
|
13
11
|
render() {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
props = _objectWithoutProperties(_this$props, _excluded);
|
|
12
|
+
const {
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
...props
|
|
16
|
+
} = this.props;
|
|
20
17
|
const classes = classNames(styles.panel, className);
|
|
21
|
-
return jsx("div",
|
|
22
|
-
"data-test": 'ring-panel'
|
|
23
|
-
|
|
18
|
+
return jsx("div", {
|
|
19
|
+
"data-test": 'ring-panel',
|
|
20
|
+
...props,
|
|
24
21
|
className: classes,
|
|
25
22
|
children: children
|
|
26
|
-
})
|
|
23
|
+
});
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Converts an array of cached permissions to a a map of a permission key
|
|
5
3
|
* to the respective cached permission.
|
|
@@ -14,6 +12,7 @@ import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
|
14
12
|
* @private
|
|
15
13
|
*/
|
|
16
14
|
class PermissionCache {
|
|
15
|
+
static GLOBAL_PROJECT_ID = 'global';
|
|
17
16
|
/**
|
|
18
17
|
* Convert an array of projects to a set of project ids.
|
|
19
18
|
*
|
|
@@ -31,13 +30,13 @@ class PermissionCache {
|
|
|
31
30
|
}
|
|
32
31
|
return projectIdSet;
|
|
33
32
|
}
|
|
33
|
+
namesConverter;
|
|
34
34
|
constructor(permissions, namesConverter) {
|
|
35
|
-
_defineProperty(this, "namesConverter", void 0);
|
|
36
|
-
_defineProperty(this, "_permissions", void 0);
|
|
37
|
-
_defineProperty(this, "permissionCache", void 0);
|
|
38
35
|
this.namesConverter = namesConverter || (key => key);
|
|
39
36
|
this.set(permissions);
|
|
40
37
|
}
|
|
38
|
+
_permissions;
|
|
39
|
+
permissionCache;
|
|
41
40
|
set(permissions) {
|
|
42
41
|
const permissionCache = (permissions || []).reduce((_permissionCache, permission) => {
|
|
43
42
|
const key = this.namesConverter(permission.permission.key);
|
|
@@ -195,7 +194,7 @@ class PermissionCache {
|
|
|
195
194
|
throw new Error("Operator ')' was expected");
|
|
196
195
|
}
|
|
197
196
|
} else {
|
|
198
|
-
result =
|
|
197
|
+
result = t !== undefined && this.testPermission(t, projectId);
|
|
199
198
|
}
|
|
200
199
|
return result;
|
|
201
200
|
}
|
|
@@ -207,7 +206,7 @@ class PermissionCache {
|
|
|
207
206
|
testPermission(permissionName, projectId) {
|
|
208
207
|
const permissionCache = this.permissionCache;
|
|
209
208
|
const convertedName = this.namesConverter(permissionName);
|
|
210
|
-
const cachedPermission =
|
|
209
|
+
const cachedPermission = permissionCache?.[permissionName] || convertedName && permissionCache?.[convertedName];
|
|
211
210
|
// Hasn't the permission in any project
|
|
212
211
|
if (!cachedPermission) {
|
|
213
212
|
return false;
|
|
@@ -223,6 +222,5 @@ class PermissionCache {
|
|
|
223
222
|
return true;
|
|
224
223
|
}
|
|
225
224
|
}
|
|
226
|
-
_defineProperty(PermissionCache, "GLOBAL_PROJECT_ID", 'global');
|
|
227
225
|
|
|
228
226
|
export { PermissionCache as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import PermissionCache from './permissions-cache.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -26,21 +25,18 @@ import PermissionCache from './permissions-cache.js';
|
|
|
26
25
|
* @constructor
|
|
27
26
|
*/
|
|
28
27
|
class Permissions {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
query
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
28
|
+
/**
|
|
29
|
+
* @const {string}
|
|
30
|
+
*/
|
|
31
|
+
static API_PERMISSION_CACHE_PATH = 'permissions/cache';
|
|
32
|
+
query;
|
|
33
|
+
namesConverter;
|
|
34
|
+
_auth;
|
|
35
|
+
_datasource;
|
|
36
|
+
_promise;
|
|
37
|
+
_subscribed;
|
|
38
|
+
_permissionCache;
|
|
39
|
+
constructor(auth, config = {}) {
|
|
44
40
|
this.query = Permissions.getPermissionQuery(config.services);
|
|
45
41
|
this.namesConverter = config.prefix ? Permissions.getDefaultNamesConverter(config.prefix) : config.namesConverter;
|
|
46
42
|
if (!auth) {
|
|
@@ -52,6 +48,12 @@ class Permissions {
|
|
|
52
48
|
this._subscribed = false;
|
|
53
49
|
this._permissionCache = new PermissionCache(null, this.namesConverter);
|
|
54
50
|
}
|
|
51
|
+
_defaultDatasource = query => this._auth.http.get(Permissions.API_PERMISSION_CACHE_PATH, {
|
|
52
|
+
query: {
|
|
53
|
+
fields: 'permission/key,global,projects(id)',
|
|
54
|
+
query
|
|
55
|
+
}
|
|
56
|
+
});
|
|
55
57
|
/**
|
|
56
58
|
* Returns function, which cuts off prefix from server-side permission name
|
|
57
59
|
*
|
|
@@ -70,7 +72,7 @@ class Permissions {
|
|
|
70
72
|
if (!services || !services.length) {
|
|
71
73
|
return undefined;
|
|
72
74
|
}
|
|
73
|
-
return services.map(service =>
|
|
75
|
+
return services.map(service => `service:{${service}}`).join(' or ');
|
|
74
76
|
}
|
|
75
77
|
set(cachedPermissions) {
|
|
76
78
|
this._permissionCache.set(cachedPermissions);
|
|
@@ -167,9 +169,5 @@ class Permissions {
|
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
|
-
/**
|
|
171
|
-
* @const {string}
|
|
172
|
-
*/
|
|
173
|
-
_defineProperty(Permissions, "API_PERMISSION_CACHE_PATH", 'permissions/cache');
|
|
174
172
|
|
|
175
173
|
export { Permissions as default };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
3
|
-
import 'core-js/modules/es.string.replace.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
2
|
import { PureComponent } from 'react';
|
|
7
3
|
import { createPortal } from 'react-dom';
|
|
@@ -14,14 +10,13 @@ import joinDataTestAttributes from '../global/data-tests.js';
|
|
|
14
10
|
import TabTrap from '../tab-trap/tab-trap.js';
|
|
15
11
|
import { getConfiguration } from '../global/configuration.js';
|
|
16
12
|
import position from './position.js';
|
|
17
|
-
import { DEFAULT_DIRECTIONS, MaxHeight, MinWidth, Dimension, Directions
|
|
13
|
+
import { DEFAULT_DIRECTIONS, Display, MaxHeight, MinWidth, Dimension, Directions } from './popup.consts.js';
|
|
18
14
|
import { PopupTargetContext, PopupTarget } from './popup.target.js';
|
|
19
|
-
import {
|
|
15
|
+
import { supportsCSSAnchorPositioning, setCSSAnchorPositioning } from './position-css.js';
|
|
20
16
|
import '../shortcuts/core.js';
|
|
21
17
|
import 'combokeys';
|
|
22
18
|
import '../global/sniffer.js';
|
|
23
19
|
import 'sniffr';
|
|
24
|
-
import 'core-js/modules/es.array.sort.js';
|
|
25
20
|
|
|
26
21
|
var styles = {"popup":"ring-popup-popup ring-global-font","cssAnchoredPopup":"ring-popup-cssAnchoredPopup","largeBorderRadius":"ring-popup-largeBorderRadius","hidden":"ring-popup-hidden","showing":"ring-popup-showing","attached":"ring-popup-attached"};
|
|
27
22
|
|
|
@@ -56,123 +51,37 @@ const stop = event => {
|
|
|
56
51
|
event.stopPropagation();
|
|
57
52
|
}
|
|
58
53
|
};
|
|
59
|
-
const getPopupContainer = target => typeof target === 'string' ? document.querySelector(
|
|
54
|
+
const getPopupContainer = target => typeof target === 'string' ? document.querySelector(`[data-portaltarget=${target}]`) : target;
|
|
60
55
|
/**
|
|
61
56
|
* @constructor
|
|
62
57
|
* @name Popup
|
|
63
58
|
* @extends {ReactComponent}
|
|
64
59
|
*/
|
|
65
60
|
class Popup extends PureComponent {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.popup = el;
|
|
91
|
-
this._redraw();
|
|
92
|
-
});
|
|
93
|
-
_defineProperty(this, "containerRef", el => {
|
|
94
|
-
this.container = el;
|
|
95
|
-
});
|
|
96
|
-
_defineProperty(this, "_updateDirection", newDirection => {
|
|
97
|
-
if (this.state.direction !== newDirection) {
|
|
98
|
-
this.setState({
|
|
99
|
-
direction: newDirection
|
|
100
|
-
});
|
|
101
|
-
if (this.props.onDirectionChange) {
|
|
102
|
-
this.props.onDirectionChange(newDirection);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
_defineProperty(this, "_updatePosition", () => {
|
|
107
|
-
const popup = this.popup;
|
|
108
|
-
const anchor = this._getAnchor();
|
|
109
|
-
if (popup) {
|
|
110
|
-
if (this.shouldUseCssPositioning() && anchor) {
|
|
111
|
-
// Use CSS Anchor positioning
|
|
112
|
-
setCSSAnchorPositioning({
|
|
113
|
-
popup,
|
|
114
|
-
anchor,
|
|
115
|
-
uid: this.uid,
|
|
116
|
-
minWidth: this.props.minWidth,
|
|
117
|
-
top: this.props.top,
|
|
118
|
-
left: this.props.left,
|
|
119
|
-
directions: this.props.directions,
|
|
120
|
-
offset: this.props.offset
|
|
121
|
-
});
|
|
122
|
-
} else {
|
|
123
|
-
popup.style.position = 'absolute';
|
|
124
|
-
if (this.isVisible()) {
|
|
125
|
-
const {
|
|
126
|
-
styles: style,
|
|
127
|
-
direction
|
|
128
|
-
} = this.position();
|
|
129
|
-
Object.entries(style).forEach(_ref => {
|
|
130
|
-
let [key, value] = _ref;
|
|
131
|
-
const propKey = key;
|
|
132
|
-
if (typeof value === 'number') {
|
|
133
|
-
popup.style[propKey] = "".concat(value, "px");
|
|
134
|
-
} else {
|
|
135
|
-
popup.style[propKey] = value.toString();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
if (direction) {
|
|
139
|
-
this._updateDirection(direction);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
this.setState(this.calculateDisplay);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
_defineProperty(this, "_redraw", () => {
|
|
147
|
-
if (this.isVisible()) {
|
|
148
|
-
this.redrawScheduler(this._updatePosition);
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
_defineProperty(this, "_listenersEnabled", void 0);
|
|
152
|
-
_defineProperty(this, "_prevTimeout", void 0);
|
|
153
|
-
_defineProperty(this, "_onEscPress", evt => {
|
|
154
|
-
this.props.onEscPress(evt);
|
|
155
|
-
this._onCloseAttempt(evt, true);
|
|
156
|
-
});
|
|
157
|
-
/**
|
|
158
|
-
* @param {jQuery.Event} evt
|
|
159
|
-
* @private
|
|
160
|
-
*/
|
|
161
|
-
_defineProperty(this, "_onDocumentClick", evt => {
|
|
162
|
-
var _this$_getAnchor;
|
|
163
|
-
if (this.container && evt.target instanceof Node && this.container.contains(evt.target) || !this._listenersEnabled || this.props.dontCloseOnAnchorClick && evt.target instanceof Node && (_this$_getAnchor = this._getAnchor()) !== null && _this$_getAnchor !== void 0 && _this$_getAnchor.contains(evt.target) ||
|
|
164
|
-
// ignore clicks in shadow DOM, e.g., Grammarly suggestions
|
|
165
|
-
evt.target instanceof Element && evt.target.shadowRoot) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
this.props.onOutsideClick(evt);
|
|
169
|
-
this._onCloseAttempt(evt, false);
|
|
170
|
-
});
|
|
171
|
-
_defineProperty(this, "shortcutsScope", this.uid);
|
|
172
|
-
_defineProperty(this, "shortcutsMap", {
|
|
173
|
-
esc: this._onEscPress
|
|
174
|
-
});
|
|
175
|
-
}
|
|
61
|
+
static defaultProps = {
|
|
62
|
+
shortcuts: true,
|
|
63
|
+
hidden: false,
|
|
64
|
+
onOutsideClick() {},
|
|
65
|
+
onEscPress() {},
|
|
66
|
+
onCloseAttempt() {},
|
|
67
|
+
dontCloseOnAnchorClick: false,
|
|
68
|
+
keepMounted: false,
|
|
69
|
+
directions: DEFAULT_DIRECTIONS,
|
|
70
|
+
autoPositioning: true,
|
|
71
|
+
autoPositioningOnScroll: true,
|
|
72
|
+
autoCorrectTopOverflow: true,
|
|
73
|
+
left: 0,
|
|
74
|
+
top: 0,
|
|
75
|
+
offset: 0,
|
|
76
|
+
sidePadding: 8,
|
|
77
|
+
attached: false,
|
|
78
|
+
trapFocus: false,
|
|
79
|
+
autoFocusFirst: false,
|
|
80
|
+
legacy: false
|
|
81
|
+
};
|
|
82
|
+
state = {
|
|
83
|
+
display: Display.SHOWING
|
|
84
|
+
};
|
|
176
85
|
componentDidMount() {
|
|
177
86
|
if (!this.props.hidden) {
|
|
178
87
|
this._setListenersEnabled(true);
|
|
@@ -195,6 +104,11 @@ class Popup extends PureComponent {
|
|
|
195
104
|
componentWillUnmount() {
|
|
196
105
|
this._setListenersEnabled(false);
|
|
197
106
|
}
|
|
107
|
+
popup;
|
|
108
|
+
node;
|
|
109
|
+
parent;
|
|
110
|
+
container;
|
|
111
|
+
ringPopupTarget;
|
|
198
112
|
shouldUseShortcuts() {
|
|
199
113
|
const {
|
|
200
114
|
shortcuts,
|
|
@@ -202,6 +116,33 @@ class Popup extends PureComponent {
|
|
|
202
116
|
} = this.props;
|
|
203
117
|
return shortcuts && !hidden;
|
|
204
118
|
}
|
|
119
|
+
listeners = new Listeners();
|
|
120
|
+
redrawScheduler = scheduleRAF(true);
|
|
121
|
+
uid = getUID('popup-');
|
|
122
|
+
calculateDisplay = prevState => ({
|
|
123
|
+
...prevState,
|
|
124
|
+
display: this.props.hidden ? Display.SHOWING : Display.SHOWN
|
|
125
|
+
});
|
|
126
|
+
static PopupProps = {
|
|
127
|
+
Directions,
|
|
128
|
+
Dimension,
|
|
129
|
+
MinWidth,
|
|
130
|
+
MaxHeight
|
|
131
|
+
};
|
|
132
|
+
portalRef = el => {
|
|
133
|
+
this.node = el;
|
|
134
|
+
this.parent = el && el.parentElement;
|
|
135
|
+
if (el && this.getContainer()) {
|
|
136
|
+
this._redraw();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
popupRef = el => {
|
|
140
|
+
this.popup = el;
|
|
141
|
+
this._redraw();
|
|
142
|
+
};
|
|
143
|
+
containerRef = el => {
|
|
144
|
+
this.container = el;
|
|
145
|
+
};
|
|
205
146
|
getContainer() {
|
|
206
147
|
const target = this.props.target || this.ringPopupTarget;
|
|
207
148
|
return target && getPopupContainer(target);
|
|
@@ -234,15 +175,71 @@ class Popup extends PureComponent {
|
|
|
234
175
|
minWidth
|
|
235
176
|
});
|
|
236
177
|
}
|
|
178
|
+
_updateDirection = newDirection => {
|
|
179
|
+
if (this.state.direction !== newDirection) {
|
|
180
|
+
this.setState({
|
|
181
|
+
direction: newDirection
|
|
182
|
+
});
|
|
183
|
+
if (this.props.onDirectionChange) {
|
|
184
|
+
this.props.onDirectionChange(newDirection);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
};
|
|
237
188
|
shouldUseCssPositioning() {
|
|
238
189
|
if (!supportsCSSAnchorPositioning()) {
|
|
239
190
|
return false;
|
|
240
191
|
}
|
|
241
192
|
return this.props.cssPositioning !== undefined ? this.props.cssPositioning : getConfiguration().popupsCssPositioning;
|
|
242
193
|
}
|
|
194
|
+
_updatePosition = () => {
|
|
195
|
+
const popup = this.popup;
|
|
196
|
+
const anchor = this._getAnchor();
|
|
197
|
+
if (popup) {
|
|
198
|
+
if (this.shouldUseCssPositioning() && anchor) {
|
|
199
|
+
// Use CSS Anchor positioning
|
|
200
|
+
setCSSAnchorPositioning({
|
|
201
|
+
popup,
|
|
202
|
+
anchor,
|
|
203
|
+
uid: this.uid,
|
|
204
|
+
minWidth: this.props.minWidth,
|
|
205
|
+
top: this.props.top,
|
|
206
|
+
left: this.props.left,
|
|
207
|
+
directions: this.props.directions,
|
|
208
|
+
offset: this.props.offset
|
|
209
|
+
});
|
|
210
|
+
} else {
|
|
211
|
+
popup.style.position = 'absolute';
|
|
212
|
+
if (this.isVisible()) {
|
|
213
|
+
const {
|
|
214
|
+
styles: style,
|
|
215
|
+
direction
|
|
216
|
+
} = this.position();
|
|
217
|
+
Object.entries(style).forEach(([key, value]) => {
|
|
218
|
+
const propKey = key;
|
|
219
|
+
if (typeof value === 'number') {
|
|
220
|
+
popup.style[propKey] = `${value}px`;
|
|
221
|
+
} else {
|
|
222
|
+
popup.style[propKey] = value.toString();
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
if (direction) {
|
|
226
|
+
this._updateDirection(direction);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
this.setState(this.calculateDisplay);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
_redraw = () => {
|
|
234
|
+
if (this.isVisible()) {
|
|
235
|
+
this.redrawScheduler(this._updatePosition);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
243
238
|
_getAnchor() {
|
|
244
239
|
return this.props.anchorElement || this.parent;
|
|
245
240
|
}
|
|
241
|
+
_listenersEnabled;
|
|
242
|
+
_prevTimeout;
|
|
246
243
|
/**
|
|
247
244
|
* @param {boolean} enable
|
|
248
245
|
* @private
|
|
@@ -285,6 +282,23 @@ class Popup extends PureComponent {
|
|
|
285
282
|
_onCloseAttempt(evt, isEsc) {
|
|
286
283
|
this.props.onCloseAttempt(evt, isEsc);
|
|
287
284
|
}
|
|
285
|
+
_onEscPress = evt => {
|
|
286
|
+
this.props.onEscPress(evt);
|
|
287
|
+
this._onCloseAttempt(evt, true);
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* @param {jQuery.Event} evt
|
|
291
|
+
* @private
|
|
292
|
+
*/
|
|
293
|
+
_onDocumentClick = evt => {
|
|
294
|
+
if (this.container && evt.target instanceof Node && this.container.contains(evt.target) || !this._listenersEnabled || this.props.dontCloseOnAnchorClick && evt.target instanceof Node && this._getAnchor()?.contains(evt.target) ||
|
|
295
|
+
// ignore clicks in shadow DOM, e.g., Grammarly suggestions
|
|
296
|
+
evt.target instanceof Element && evt.target.shadowRoot) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
this.props.onOutsideClick(evt);
|
|
300
|
+
this._onCloseAttempt(evt, false);
|
|
301
|
+
};
|
|
288
302
|
getInternalContent() {
|
|
289
303
|
const {
|
|
290
304
|
trapFocus,
|
|
@@ -297,6 +311,10 @@ class Popup extends PureComponent {
|
|
|
297
311
|
children: children
|
|
298
312
|
}) : children;
|
|
299
313
|
}
|
|
314
|
+
shortcutsScope = this.uid;
|
|
315
|
+
shortcutsMap = {
|
|
316
|
+
esc: this._onEscPress
|
|
317
|
+
};
|
|
300
318
|
render() {
|
|
301
319
|
const {
|
|
302
320
|
className,
|
|
@@ -361,32 +379,5 @@ class Popup extends PureComponent {
|
|
|
361
379
|
});
|
|
362
380
|
}
|
|
363
381
|
}
|
|
364
|
-
_defineProperty(Popup, "defaultProps", {
|
|
365
|
-
shortcuts: true,
|
|
366
|
-
hidden: false,
|
|
367
|
-
onOutsideClick() {},
|
|
368
|
-
onEscPress() {},
|
|
369
|
-
onCloseAttempt() {},
|
|
370
|
-
dontCloseOnAnchorClick: false,
|
|
371
|
-
keepMounted: false,
|
|
372
|
-
directions: DEFAULT_DIRECTIONS,
|
|
373
|
-
autoPositioning: true,
|
|
374
|
-
autoPositioningOnScroll: true,
|
|
375
|
-
autoCorrectTopOverflow: true,
|
|
376
|
-
left: 0,
|
|
377
|
-
top: 0,
|
|
378
|
-
offset: 0,
|
|
379
|
-
sidePadding: 8,
|
|
380
|
-
attached: false,
|
|
381
|
-
trapFocus: false,
|
|
382
|
-
autoFocusFirst: false,
|
|
383
|
-
legacy: false
|
|
384
|
-
});
|
|
385
|
-
_defineProperty(Popup, "PopupProps", {
|
|
386
|
-
Directions,
|
|
387
|
-
Dimension,
|
|
388
|
-
MinWidth,
|
|
389
|
-
MaxHeight
|
|
390
|
-
});
|
|
391
382
|
|
|
392
383
|
export { PopupTarget, PopupTargetContext, Popup as default, getPopupContainer };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import { jsx } from 'react/jsx-runtime';
|
|
3
2
|
import { createContext, forwardRef } from 'react';
|
|
4
3
|
|
|
5
|
-
const _excluded = ["id", "children"];
|
|
6
4
|
const PopupTargetContext = /*#__PURE__*/createContext(undefined);
|
|
7
|
-
const PopupTarget = /*#__PURE__*/forwardRef(function PopupTarget(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const PopupTarget = /*#__PURE__*/forwardRef(function PopupTarget({
|
|
6
|
+
id,
|
|
7
|
+
children,
|
|
8
|
+
...restProps
|
|
9
|
+
}, ref) {
|
|
10
|
+
const target = jsx("div", {
|
|
11
|
+
...restProps,
|
|
14
12
|
"data-portaltarget": id,
|
|
15
13
|
ref: ref,
|
|
16
14
|
children: typeof children !== 'function' && children
|
|
17
|
-
})
|
|
15
|
+
});
|
|
18
16
|
return jsx(PopupTargetContext.Provider, {
|
|
19
17
|
value: id,
|
|
20
18
|
children: typeof children === 'function' ? children(target) : target
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
1
|
import { getRect } from '../global/dom.js';
|
|
3
2
|
import { calculateMinWidth } from './position.js';
|
|
4
3
|
import { Directions } from './popup.consts.js';
|
|
5
|
-
import '../_helpers/_rollupPluginBabelHelpers.js';
|
|
6
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
7
|
-
import 'core-js/modules/es.array.sort.js';
|
|
8
4
|
|
|
9
|
-
const supportsCSSAnchorPositioning = () =>
|
|
10
|
-
var _CSS, _CSS$supports;
|
|
11
|
-
return (_CSS = CSS) === null || _CSS === void 0 || (_CSS$supports = _CSS.supports) === null || _CSS$supports === void 0 ? void 0 : _CSS$supports.call(_CSS, 'anchor-name', 'none');
|
|
12
|
-
};
|
|
5
|
+
const supportsCSSAnchorPositioning = () => CSS?.supports?.('anchor-name', 'none');
|
|
13
6
|
const getPositionArea = direction => {
|
|
14
7
|
switch (direction) {
|
|
15
8
|
case Directions.BOTTOM_RIGHT:
|
|
@@ -41,40 +34,39 @@ const getPositionArea = direction => {
|
|
|
41
34
|
}
|
|
42
35
|
};
|
|
43
36
|
const getPositionFallbacks = directions => directions.slice(1).map(direction => getPositionArea(direction)[1]).join(', ');
|
|
44
|
-
const setCSSAnchorPositioning =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const anchorName = anchor.style.getPropertyValue('anchor-name') || "--anchor-".concat(uid);
|
|
37
|
+
const setCSSAnchorPositioning = ({
|
|
38
|
+
popup,
|
|
39
|
+
anchor,
|
|
40
|
+
uid,
|
|
41
|
+
minWidth,
|
|
42
|
+
top,
|
|
43
|
+
left,
|
|
44
|
+
directions,
|
|
45
|
+
offset
|
|
46
|
+
}) => {
|
|
47
|
+
const anchorName = anchor.style.getPropertyValue('anchor-name') || `--anchor-${uid}`;
|
|
56
48
|
if (!anchor.style.getPropertyValue('anchor-name')) {
|
|
57
49
|
anchor.style.setProperty('anchor-name', anchorName);
|
|
58
50
|
}
|
|
59
51
|
popup.style.setProperty('position-anchor', anchorName);
|
|
60
52
|
const calculatedMinWidth = calculateMinWidth(getRect(anchor).width, minWidth);
|
|
61
|
-
if (calculatedMinWidth) {
|
|
62
|
-
popup.style.minWidth =
|
|
53
|
+
if (calculatedMinWidth !== null) {
|
|
54
|
+
popup.style.minWidth = `${calculatedMinWidth}px`;
|
|
63
55
|
}
|
|
64
56
|
if (top) {
|
|
65
|
-
popup.style.transform =
|
|
57
|
+
popup.style.transform = `translateY(${top}px)`;
|
|
66
58
|
}
|
|
67
59
|
if (left) {
|
|
68
|
-
popup.style.left =
|
|
60
|
+
popup.style.left = `${left}px`;
|
|
69
61
|
}
|
|
70
62
|
const [initialPositionStyle, initialPositionName] = getPositionArea(directions[0]);
|
|
71
63
|
popup.style.setProperty('position-area', initialPositionStyle);
|
|
72
64
|
if (offset) {
|
|
73
|
-
popup.style.setProperty('--ring-popup-offset',
|
|
65
|
+
popup.style.setProperty('--ring-popup-offset', `${offset}px`);
|
|
74
66
|
if (initialPositionName.startsWith('--bottom') || initialPositionName.startsWith('--top')) {
|
|
75
|
-
popup.style.margin =
|
|
67
|
+
popup.style.margin = `${offset}px 0`;
|
|
76
68
|
} else {
|
|
77
|
-
popup.style.margin =
|
|
69
|
+
popup.style.margin = `0 ${offset}px`;
|
|
78
70
|
}
|
|
79
71
|
}
|
|
80
72
|
// Add fallbacks for better positioning if there are multiple directions
|