@jetbrains/ring-ui 7.0.0-beta.8 → 7.0.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/babel.config.js +20 -14
- package/components/alert/alert.css +7 -7
- package/components/alert/alert.d.ts +2 -2
- package/components/alert/alert.js +10 -12
- package/components/alert/container.js +1 -1
- package/components/alert-service/alert-service.js +4 -2
- package/components/analytics/analytics__custom-plugin.js +1 -1
- package/components/auth/auth.js +1 -1
- package/components/auth/auth__core.js +36 -36
- package/components/auth/background-flow.js +2 -2
- package/components/auth/down-notification.js +3 -1
- package/components/auth/iframe-flow.js +4 -2
- package/components/auth/request-builder.js +5 -5
- package/components/auth/storage.js +10 -9
- package/components/auth/token-validator.js +8 -15
- package/components/auth-dialog/auth-dialog.js +8 -8
- package/components/auth-dialog-service/auth-dialog-service.js +4 -4
- package/components/avatar/avatar.js +9 -7
- package/components/avatar/fallback-avatar.js +15 -12
- package/components/button/button.css +36 -25
- package/components/button/button.js +9 -9
- package/components/button/button__classes.d.ts +1 -1
- package/components/button/button__classes.js +3 -4
- package/components/button-group/button-group.css +25 -13
- package/components/button-group/caption.js +1 -1
- package/components/button-toolbar/button-toolbar.d.ts +1 -1
- package/components/button-toolbar/button-toolbar.js +2 -2
- package/components/caret/caret.js +8 -8
- package/components/checkbox/checkbox.css +8 -5
- package/components/checkbox/checkbox.js +1 -1
- package/components/clipboard/clipboard-fallback.js +2 -6
- package/components/clipboard/clipboard.js +5 -5
- package/components/code/code.d.ts +1 -1
- package/components/code/code.js +2 -2
- package/components/code/highlight.css +3 -1
- package/components/collapse/collapse-content.d.ts +1 -2
- package/components/collapse/collapse-content.js +25 -14
- package/components/collapse/collapse-context.js +1 -1
- package/components/collapse/collapse-control.js +5 -3
- package/components/collapse/collapse.css +21 -20
- package/components/collapse/collapse.js +2 -2
- package/components/confirm/confirm.d.ts +2 -2
- package/components/confirm/confirm.js +2 -2
- package/components/confirm-service/confirm-service.d.ts +1 -1
- package/components/confirm-service/confirm-service.js +6 -6
- package/components/content-layout/content-layout.css +6 -5
- package/components/content-layout/content-layout.js +7 -6
- package/components/content-layout/sidebar.js +5 -5
- package/components/contenteditable/contenteditable.d.ts +1 -1
- package/components/contenteditable/contenteditable.js +3 -4
- package/components/control-label/control-label.js +5 -3
- package/components/data-list/data-list.css +3 -3
- package/components/data-list/data-list.d.ts +2 -2
- package/components/data-list/data-list.js +6 -7
- package/components/data-list/data-list.mock.js +57 -47
- package/components/data-list/item.js +14 -16
- package/components/data-list/selection.js +5 -7
- package/components/data-list/title.js +5 -6
- package/components/date-picker/consts.js +2 -2
- package/components/date-picker/date-input.js +4 -4
- package/components/date-picker/date-picker.css +23 -18
- package/components/date-picker/date-picker.d.ts +2 -1
- package/components/date-picker/date-picker.js +13 -19
- package/components/date-picker/date-popup.js +30 -36
- package/components/date-picker/day.js +6 -9
- package/components/date-picker/formats.js +647 -1
- package/components/date-picker/month-names.js +6 -8
- package/components/date-picker/month-slider.js +2 -2
- package/components/date-picker/month.js +1 -3
- package/components/date-picker/months.js +2 -6
- package/components/date-picker/weekdays.js +2 -3
- package/components/date-picker/years.js +3 -3
- package/components/dialog/dialog.d.ts +1 -0
- package/components/dialog/dialog.js +20 -13
- package/components/dialog/dialog__body-scroll-preventer.js +1 -1
- package/components/dropdown/dropdown.css +2 -4
- package/components/dropdown/dropdown.d.ts +2 -2
- package/components/dropdown/dropdown.js +5 -5
- package/components/dropdown-menu/dropdown-menu.js +5 -5
- package/components/editable-heading/editable-heading.css +5 -2
- package/components/editable-heading/editable-heading.js +21 -19
- package/components/error-bubble/error-bubble.js +1 -1
- package/components/error-message/error-message.js +2 -4
- package/components/footer/footer.js +11 -15
- package/components/form/form.stories.js +45 -63
- package/components/global/create-stateful-context.js +2 -4
- package/components/global/data-tests.js +5 -6
- package/components/global/dom.js +8 -11
- package/components/global/focus-sensor-hoc.js +5 -6
- package/components/global/fuzzy-highlight.js +1 -1
- package/components/global/get-event-key.js +2 -2
- package/components/global/global.css +0 -3
- package/components/global/linear-function.js +1 -1
- package/components/global/normalize-indent.js +2 -6
- package/components/global/react-dom-renderer.js +2 -3
- package/components/global/theme.d.ts +4 -2
- package/components/global/theme.js +14 -12
- package/components/global/url.js +8 -8
- package/components/global/variables.css +1 -8
- package/components/global/variables_dark.css +0 -1
- package/components/grid/col.js +6 -6
- package/components/grid/grid.css +174 -173
- package/components/grid/grid.js +1 -1
- package/components/grid/row.js +13 -6
- package/components/group/group.js +1 -1
- package/components/header/header-icon.js +2 -2
- package/components/header/header.css +19 -15
- package/components/header/header.js +3 -5
- package/components/header/links.js +1 -1
- package/components/header/logo.js +1 -1
- package/components/header/profile.d.ts +2 -2
- package/components/header/profile.js +9 -9
- package/components/header/services-link.js +1 -1
- package/components/header/services.js +4 -5
- package/components/header/smart-profile.js +4 -3
- package/components/header/smart-services.js +9 -5
- package/components/header/tray.js +1 -1
- package/components/heading/heading.css +0 -1
- package/components/heading/heading.js +2 -2
- package/components/http/http.d.ts +3 -3
- package/components/http/http.js +25 -29
- package/components/http/http.mock.js +9 -6
- package/components/hub-source/hub-source.js +5 -7
- package/components/hub-source/hub-source__user.js +1 -1
- package/components/hub-source/hub-source__users-groups.js +6 -7
- package/components/i18n/README.md +3 -4
- package/components/i18n/i18n-context.js +2 -4
- package/components/icon/icon.css +1 -1
- package/components/icon/icon.js +7 -9
- package/components/icon/icon__svg.js +6 -6
- package/components/input/input.css +1 -1
- package/components/input/input.js +11 -14
- package/components/input-size/input-size.stories.js +42 -22
- package/components/island/adaptive-island-hoc.js +1 -1
- package/components/island/content.js +4 -6
- package/components/island/header.js +8 -10
- package/components/island/island.css +5 -5
- package/components/island/island.js +1 -1
- package/components/link/clickableLink.js +3 -1
- package/components/link/link.js +5 -3
- package/components/list/consts.js +1 -1
- package/components/list/list.d.ts +1 -1
- package/components/list/list.js +35 -57
- package/components/list/list__custom.js +3 -5
- package/components/list/list__hint.js +3 -1
- package/components/list/list__item.js +11 -9
- package/components/list/list__link.js +1 -1
- package/components/list/list__separator.js +2 -2
- package/components/list/list__title.js +7 -3
- package/components/list/list__users-groups-source.js +6 -8
- package/components/loader/loader.js +1 -1
- package/components/loader/loader__core.js +5 -5
- package/components/loader-inline/loader-inline.css +0 -3
- package/components/loader-inline/loader-inline.js +5 -7
- package/components/loader-screen/loader-screen.js +1 -1
- package/components/login-dialog/login-dialog.js +4 -4
- package/components/login-dialog/service.js +5 -5
- package/components/markdown/markdown.css +6 -6
- package/components/markdown/markdown.d.ts +2 -2
- package/components/markdown/markdown.js +4 -6
- package/components/message/message.css +2 -1
- package/components/message/message.js +30 -21
- package/components/old-browsers-message/old-browsers-message.js +2 -2
- package/components/old-browsers-message/white-list.js +2 -3
- package/components/pager/pager.js +28 -29
- package/components/permissions/permissions.js +8 -13
- package/components/permissions/permissions__cache.js +6 -7
- package/components/popup/popup.consts.js +8 -2
- package/components/popup/popup.js +27 -33
- package/components/popup/popup.target.js +4 -4
- package/components/popup/position.js +21 -28
- package/components/popup-menu/popup-menu.js +1 -1
- package/components/progress-bar/progress-bar.css +10 -8
- package/components/progress-bar/progress-bar.d.ts +2 -2
- package/components/progress-bar/progress-bar.js +2 -2
- package/components/query-assist/query-assist.css +0 -3
- package/components/query-assist/query-assist.js +73 -84
- package/components/query-assist/query-assist__suggestions.js +10 -9
- package/components/radio/radio.css +6 -2
- package/components/radio/radio.js +1 -3
- package/components/scrollable-section/scrollable-section.css +5 -6
- package/components/scrollable-section/scrollable-section.js +1 -1
- package/components/select/select.css +5 -7
- package/components/select/select.d.ts +1 -1
- package/components/select/select.js +96 -110
- package/components/select/select__filter.js +1 -1
- package/components/select/select__popup.js +40 -51
- package/components/shortcuts/core.js +8 -6
- package/components/shortcuts/shortcut-title.js +6 -6
- package/components/shortcuts/shortcuts.js +1 -1
- package/components/sidebar/sidebar.css +3 -1
- package/components/slider/slider.css +14 -14
- package/components/slider/slider.js +7 -7
- package/components/tab-trap/tab-trap.js +7 -9
- package/components/table/cell.js +3 -1
- package/components/table/disable-hover-hoc.js +2 -2
- package/components/table/header-cell.js +5 -3
- package/components/table/header.d.ts +2 -10
- package/components/table/header.js +10 -12
- package/components/table/multitable.js +5 -3
- package/components/table/row.d.ts +0 -1
- package/components/table/row.js +20 -27
- package/components/table/selection-adapter.js +1 -1
- package/components/table/selection-shortcuts-hoc.js +2 -2
- package/components/table/selection.d.ts +2 -3
- package/components/table/selection.js +4 -5
- package/components/table/simple-table.js +4 -4
- package/components/table/smart-table.js +5 -5
- package/components/table/table.css +8 -9
- package/components/table/table.d.ts +0 -1
- package/components/table/table.js +22 -23
- package/components/table/table.stories.json +45 -16
- package/components/tabs/collapsible-more.d.ts +1 -1
- package/components/tabs/collapsible-more.js +13 -16
- package/components/tabs/collapsible-tab.js +2 -2
- package/components/tabs/collapsible-tabs.d.ts +2 -2
- package/components/tabs/collapsible-tabs.js +13 -22
- package/components/tabs/dumb-tabs.js +6 -9
- package/components/tabs/smart-tabs.js +4 -4
- package/components/tabs/tab-link.js +1 -3
- package/components/tabs/tabs.css +7 -9
- package/components/tag/tag.css +7 -7
- package/components/tag/tag.d.ts +1 -1
- package/components/tag/tag.js +9 -12
- package/components/tags-input/tags-input.js +15 -19
- package/components/tags-list/tags-list.d.ts +2 -2
- package/components/tags-list/tags-list.js +6 -5
- package/components/text/text.js +5 -3
- package/components/toggle/toggle.css +12 -10
- package/components/toggle/toggle.d.ts +2 -2
- package/components/toggle/toggle.js +4 -3
- package/components/tooltip/tooltip.d.ts +4 -1
- package/components/tooltip/tooltip.js +19 -10
- package/components/user-agreement/service.js +15 -13
- package/components/user-agreement/user-agreement.js +3 -5
- package/components/user-card/card.js +10 -9
- package/components/user-card/smart-user-card-tooltip.js +5 -7
- package/components/user-card/tooltip.js +4 -4
- package/components/user-card/user-card.css +4 -0
- package/jslint-xml.js +20 -19
- package/package.json +66 -58
- package/postcss.config.js +3 -4
- package/typings.d.ts +2 -4
- package/webpack.config.js +20 -25
- package/components/badge/badge.css +0 -42
- package/components/badge/badge.d.ts +0 -14
- package/components/badge/badge.js +0 -29
- package/components/island-legacy/content-legacy.d.ts +0 -5
- package/components/island-legacy/content-legacy.js +0 -12
- package/components/island-legacy/header-legacy.d.ts +0 -5
- package/components/island-legacy/header-legacy.js +0 -14
- package/components/island-legacy/island-legacy.css +0 -98
- package/components/island-legacy/island-legacy.d.ts +0 -7
- package/components/island-legacy/island-legacy.js +0 -14
- package/components/table-legacy/table-legacy.css +0 -346
- package/components/table-legacy/table-legacy__toolbar.css +0 -25
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
max-width: calc(var(--ring-unit) * 40);
|
|
11
11
|
|
|
12
|
-
padding: calc(var(--ring-unit) * 1.5) calc(var(--ring-unit) * 1.5) calc(var(--ring-unit) * 2)
|
|
12
|
+
padding: calc(var(--ring-unit) * 1.5) calc(var(--ring-unit) * 1.5) calc(var(--ring-unit) * 2)
|
|
13
|
+
calc(var(--ring-unit) * 5);
|
|
13
14
|
|
|
14
15
|
text-align: left;
|
|
15
16
|
|
|
@@ -10,8 +10,8 @@ import Theme, { ThemeProvider, WithThemeClasses } from '../global/theme';
|
|
|
10
10
|
import darkStyles from '../global/variables_dark.css';
|
|
11
11
|
import styles from './message.css';
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
* @name Message
|
|
14
|
+
*/
|
|
15
15
|
const UNIT = 8;
|
|
16
16
|
const TAIL_SIZE = 11;
|
|
17
17
|
const getTailOffsets = (offset) => ({
|
|
@@ -19,14 +19,14 @@ const getTailOffsets = (offset) => ({
|
|
|
19
19
|
[Directions.BOTTOM_LEFT]: {
|
|
20
20
|
top: 0,
|
|
21
21
|
right: offset - UNIT - TAIL_SIZE,
|
|
22
|
-
transform: 'rotate(135deg)'
|
|
22
|
+
transform: 'rotate(135deg)',
|
|
23
23
|
},
|
|
24
24
|
[Directions.BOTTOM_CENTER]: { top: 0, left: offset + UNIT, transform: 'rotate(135deg)' },
|
|
25
25
|
[Directions.TOP_RIGHT]: { bottom: -TAIL_SIZE, left: offset - UNIT, transform: 'rotate(-45deg)' },
|
|
26
26
|
[Directions.TOP_LEFT]: {
|
|
27
27
|
bottom: -TAIL_SIZE,
|
|
28
28
|
right: offset + UNIT - TAIL_SIZE,
|
|
29
|
-
transform: 'rotate(-45deg)'
|
|
29
|
+
transform: 'rotate(-45deg)',
|
|
30
30
|
},
|
|
31
31
|
[Directions.TOP_CENTER]: { bottom: -TAIL_SIZE, left: offset - UNIT, transform: 'rotate(-45deg)' },
|
|
32
32
|
[Directions.RIGHT_TOP]: { bottom: offset + UNIT - TAIL_SIZE, left: 0, transform: 'rotate(45deg)' },
|
|
@@ -35,10 +35,10 @@ const getTailOffsets = (offset) => ({
|
|
|
35
35
|
[Directions.LEFT_TOP]: {
|
|
36
36
|
bottom: offset - UNIT - TAIL_SIZE,
|
|
37
37
|
right: -TAIL_SIZE,
|
|
38
|
-
transform: 'rotate(-135deg)'
|
|
38
|
+
transform: 'rotate(-135deg)',
|
|
39
39
|
},
|
|
40
40
|
[Directions.LEFT_BOTTOM]: { top: offset + UNIT, right: -TAIL_SIZE, transform: 'rotate(-135deg)' },
|
|
41
|
-
[Directions.LEFT_CENTER]: { top: offset + UNIT, right: -TAIL_SIZE, transform: 'rotate(-135deg)' }
|
|
41
|
+
[Directions.LEFT_CENTER]: { top: offset + UNIT, right: -TAIL_SIZE, transform: 'rotate(-135deg)' },
|
|
42
42
|
});
|
|
43
43
|
/**
|
|
44
44
|
* Displays a popup containing a message.
|
|
@@ -47,12 +47,20 @@ export default class Message extends Component {
|
|
|
47
47
|
static defaultProps = {
|
|
48
48
|
icon: gift,
|
|
49
49
|
directions: [
|
|
50
|
-
Directions.TOP_RIGHT,
|
|
51
|
-
Directions.
|
|
52
|
-
Directions.
|
|
53
|
-
Directions.
|
|
50
|
+
Directions.TOP_RIGHT,
|
|
51
|
+
Directions.TOP_LEFT,
|
|
52
|
+
Directions.TOP_CENTER,
|
|
53
|
+
Directions.BOTTOM_RIGHT,
|
|
54
|
+
Directions.BOTTOM_LEFT,
|
|
55
|
+
Directions.BOTTOM_CENTER,
|
|
56
|
+
Directions.RIGHT_TOP,
|
|
57
|
+
Directions.RIGHT_BOTTOM,
|
|
58
|
+
Directions.RIGHT_CENTER,
|
|
59
|
+
Directions.LEFT_TOP,
|
|
60
|
+
Directions.LEFT_BOTTOM,
|
|
61
|
+
Directions.LEFT_CENTER,
|
|
54
62
|
],
|
|
55
|
-
theme: Theme.DARK
|
|
63
|
+
theme: Theme.DARK,
|
|
56
64
|
};
|
|
57
65
|
state = {};
|
|
58
66
|
static Directions = Directions;
|
|
@@ -75,33 +83,34 @@ export default class Message extends Component {
|
|
|
75
83
|
return DEFAULT_OFFSET;
|
|
76
84
|
}
|
|
77
85
|
const offset = Math.floor(anchor.offsetWidth / 2);
|
|
78
|
-
const isOpenedToRight = this.state.direction != null &&
|
|
79
|
-
[Directions.TOP_RIGHT, Directions.BOTTOM_RIGHT].includes(this.state.direction);
|
|
86
|
+
const isOpenedToRight = this.state.direction != null && [Directions.TOP_RIGHT, Directions.BOTTOM_RIGHT].includes(this.state.direction);
|
|
80
87
|
if (popupProps?.left && isOpenedToRight) {
|
|
81
88
|
return offset - popupProps?.left;
|
|
82
89
|
}
|
|
83
90
|
return offset;
|
|
84
91
|
}
|
|
85
92
|
render() {
|
|
86
|
-
const { children, className, tailClassName, title, icon, popupProps, buttonProps, onClose, onDismiss, translations, theme } = this.props;
|
|
93
|
+
const { children, className, tailClassName, title, icon, popupProps, buttonProps, onClose, onDismiss, translations, theme, } = this.props;
|
|
87
94
|
const classes = classNames(styles.message, className, {
|
|
88
|
-
[darkStyles.dark]: theme === Theme.DARK
|
|
95
|
+
[darkStyles.dark]: theme === Theme.DARK,
|
|
89
96
|
});
|
|
90
97
|
const tailClasses = classNames(styles.tail, tailClassName);
|
|
91
|
-
const popupDirections = this.props.direction
|
|
92
|
-
? [this.props.direction]
|
|
93
|
-
: this.props.directions;
|
|
98
|
+
const popupDirections = this.props.direction ? [this.props.direction] : this.props.directions;
|
|
94
99
|
const { direction } = this.state;
|
|
95
100
|
return (<I18nContext.Consumer>
|
|
96
101
|
{({ translate }) => (<WithThemeClasses theme={theme}>
|
|
97
102
|
{themeClasses => (<Popup ref={this.popupRef} hidden={false} directions={popupDirections} className={classNames(classes, themeClasses)} offset={UNIT * 2} onDirectionChange={this._onDirectionChange} {...popupProps}>
|
|
98
103
|
<ThemeProvider theme={theme} passToPopups>
|
|
99
|
-
{direction &&
|
|
104
|
+
{direction && <div className={tailClasses} style={getTailOffsets(this.getTailOffset())[direction]}/>}
|
|
100
105
|
|
|
101
106
|
{icon && <Icon className={styles.icon} glyph={icon}/>}
|
|
102
|
-
{title && <h1 data-test="rgMessageTitle" className={styles.title}>
|
|
107
|
+
{title && (<h1 data-test="rgMessageTitle" className={styles.title}>
|
|
108
|
+
{title}
|
|
109
|
+
</h1>)}
|
|
103
110
|
{children && <div className={styles.description}>{children}</div>}
|
|
104
|
-
{(onClose || buttonProps) && (<Button className={styles.gotIt} onClick={onClose} primary {...buttonProps}>
|
|
111
|
+
{(onClose || buttonProps) && (<Button className={styles.gotIt} onClick={onClose} primary {...buttonProps}>
|
|
112
|
+
{translations?.gotIt ?? translate('gotIt')}
|
|
113
|
+
</Button>)}
|
|
105
114
|
{onDismiss && (<Button onClick={onDismiss} text>
|
|
106
115
|
{translations?.dismiss ?? translate('dismiss')}
|
|
107
116
|
</Button>)}
|
|
@@ -15,10 +15,10 @@ function changeSmileClickListener(event) {
|
|
|
15
15
|
const target = (event.target || event.srcElement);
|
|
16
16
|
smileChanges++;
|
|
17
17
|
function rand(min, max) {
|
|
18
|
-
return Math.round(
|
|
18
|
+
return Math.round(Math.random() * (max - min)) + min;
|
|
19
19
|
}
|
|
20
20
|
function getRandomEye() {
|
|
21
|
-
return eyes[rand(0,
|
|
21
|
+
return eyes[rand(0, eyes.length - 1)];
|
|
22
22
|
}
|
|
23
23
|
function getRandomSmile() {
|
|
24
24
|
if (smileChanges >= MAX_SMILE_CHANGES) {
|
|
@@ -9,15 +9,14 @@ if (!SUPPORTED_BROWSERS) {
|
|
|
9
9
|
}
|
|
10
10
|
const SUPPORTED = SUPPORTED_BROWSERS || [];
|
|
11
11
|
const WHITE_LISTED_BROWSERS = ['chrome', 'firefox', 'safari', 'edge'];
|
|
12
|
-
export const WHITE_LIST = SUPPORTED.
|
|
13
|
-
reduce((acc, item) => {
|
|
12
|
+
export const WHITE_LIST = SUPPORTED.reduce((acc, item) => {
|
|
14
13
|
const [, browserName, version] = item.match(/(\S+)\s(\S+)/) ?? [];
|
|
15
14
|
if (!WHITE_LISTED_BROWSERS.includes(browserName)) {
|
|
16
15
|
return acc;
|
|
17
16
|
}
|
|
18
17
|
return {
|
|
19
18
|
...acc,
|
|
20
|
-
[browserName]: parseInt(version, 10)
|
|
19
|
+
[browserName]: parseInt(version, 10),
|
|
21
20
|
};
|
|
22
21
|
}, {});
|
|
23
22
|
export function isBrowserInWhiteList() {
|
|
@@ -28,7 +28,7 @@ export default class Pager extends PureComponent {
|
|
|
28
28
|
loader: false,
|
|
29
29
|
loaderNavigation: false,
|
|
30
30
|
onPageSizeChange: () => { },
|
|
31
|
-
onLoadPage: () => { }
|
|
31
|
+
onLoadPage: () => { },
|
|
32
32
|
};
|
|
33
33
|
static contextType = I18nContext;
|
|
34
34
|
getSelectOptions() {
|
|
@@ -36,7 +36,7 @@ export default class Pager extends PureComponent {
|
|
|
36
36
|
const { translate } = this.context;
|
|
37
37
|
const data = pageSizes.map(size => ({
|
|
38
38
|
key: size,
|
|
39
|
-
label: `${size} ${this.props.translations?.perPage ?? translate('perPage')}
|
|
39
|
+
label: `${size} ${this.props.translations?.perPage ?? translate('perPage')}`,
|
|
40
40
|
}));
|
|
41
41
|
const selected = data.find(it => it.key === pageSize);
|
|
42
42
|
return { selected, data };
|
|
@@ -93,18 +93,16 @@ export default class Pager extends PureComponent {
|
|
|
93
93
|
}
|
|
94
94
|
getPageSizeSelector() {
|
|
95
95
|
const selectOptions = this.getSelectOptions();
|
|
96
|
-
return !this.props.disablePageSizeSelector &&
|
|
97
|
-
(<div data-test="ring-pager-page-size-selector" className={style.pageSize}>
|
|
96
|
+
return (!this.props.disablePageSizeSelector && (<div data-test="ring-pager-page-size-selector" className={style.pageSize}>
|
|
98
97
|
<Select data={selectOptions.data} selected={selectOptions.selected} onSelect={this.handlePageSizeChange} type={Select.Type.INLINE} disabled={this.props.loader}/>
|
|
99
|
-
</div>);
|
|
98
|
+
</div>));
|
|
100
99
|
}
|
|
101
100
|
getPagerLinks() {
|
|
102
101
|
const { translate } = this.context;
|
|
103
102
|
const prevLinkAvailable = this.props.currentPage !== 1;
|
|
104
|
-
const nextLinkAvailable = this.props.openTotal ||
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
const prevIcon = (<Icon glyph={chevronLeftIcon} key="icon"/>);
|
|
103
|
+
const nextLinkAvailable = this.props.openTotal || this.props.currentPage !== this.getTotalPages();
|
|
104
|
+
const nextIcon = <Icon glyph={chevronRightIcon} key="icon"/>;
|
|
105
|
+
const prevIcon = <Icon glyph={chevronLeftIcon} key="icon"/>;
|
|
108
106
|
const prevText = this.props.translations?.previousPage ?? translate('previousPage');
|
|
109
107
|
const nextText = this.props.translations?.nextPage ?? translate('nextPage');
|
|
110
108
|
const nextLinkContent = [<span key="text">{nextText}</span>, nextIcon];
|
|
@@ -113,20 +111,22 @@ export default class Pager extends PureComponent {
|
|
|
113
111
|
const nextLinkHref = this.generateHref(this.props.currentPage + 1);
|
|
114
112
|
const disabledLinkClasses = classNames({
|
|
115
113
|
[style.link]: true,
|
|
116
|
-
[style.linkDisabled]: true
|
|
114
|
+
[style.linkDisabled]: true,
|
|
117
115
|
});
|
|
118
116
|
return (<div className={style.links}>
|
|
119
|
-
{prevLinkAvailable && (!this.props.loader || this.props.loaderNavigation)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
</span>
|
|
117
|
+
{prevLinkAvailable && (!this.props.loader || this.props.loaderNavigation) ? (<Link href={prevLinkHref} className={style.link} {...this.getClickProps(this.handlePrevClick)}>
|
|
118
|
+
{prevLinkContent}
|
|
119
|
+
</Link>) : (<span className={disabledLinkClasses}>
|
|
120
|
+
{prevIcon}
|
|
121
|
+
<span key="text">{prevText}</span>
|
|
122
|
+
</span>)}
|
|
124
123
|
|
|
125
|
-
{nextLinkAvailable && (!this.props.loader || this.props.loaderNavigation)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
{nextLinkAvailable && (!this.props.loader || this.props.loaderNavigation) ? (<Link href={nextLinkHref} className={style.link} {...this.getClickProps(this.handleNextClick)}>
|
|
125
|
+
{nextLinkContent}
|
|
126
|
+
</Link>) : (<span className={disabledLinkClasses}>
|
|
127
|
+
<span key="text">{nextText}</span>
|
|
128
|
+
{nextIcon}
|
|
129
|
+
</span>)}
|
|
130
130
|
</div>);
|
|
131
131
|
}
|
|
132
132
|
generateHref(page) {
|
|
@@ -168,16 +168,14 @@ export default class Pager extends PureComponent {
|
|
|
168
168
|
for (let i = start; i <= end; i++) {
|
|
169
169
|
buttons.push(this.getButton(i, i, i, i === currentPage));
|
|
170
170
|
}
|
|
171
|
-
const lastPageButtonAvailable = !this.props.disableLastPageButton &&
|
|
172
|
-
(end < totalPages && !this.props.openTotal) ||
|
|
171
|
+
const lastPageButtonAvailable = (!this.props.disableLastPageButton && end < totalPages && !this.props.openTotal) ||
|
|
173
172
|
(this.props.openTotal && this.props.canLoadLastPageWithOpenTotal);
|
|
174
173
|
return (<div>
|
|
175
174
|
{this.getPagerLinks()}
|
|
176
175
|
|
|
177
176
|
<div className={style.actions}>
|
|
178
177
|
<ButtonToolbar>
|
|
179
|
-
{start > 1 &&
|
|
180
|
-
this.getButton(1, this.props.translations?.firstPage ?? translate('firstPage'))}
|
|
178
|
+
{start > 1 && this.getButton(1, this.props.translations?.firstPage ?? translate('firstPage'))}
|
|
181
179
|
|
|
182
180
|
<ButtonGroup>
|
|
183
181
|
{start > 1 && this.getButton(start - 1, '...')}
|
|
@@ -186,10 +184,13 @@ export default class Pager extends PureComponent {
|
|
|
186
184
|
|
|
187
185
|
{end < totalPages && this.getButton(end + 1, '...')}
|
|
188
186
|
|
|
189
|
-
{end === totalPages && this.props.openTotal && (<Button href={this.generateHref(end + 1)} disabled={this.props.loader} {...this.getClickProps(this.handleLoadMore(end + 1))}>
|
|
187
|
+
{end === totalPages && this.props.openTotal && (<Button href={this.generateHref(end + 1)} disabled={this.props.loader} {...this.getClickProps(this.handleLoadMore(end + 1))}>
|
|
188
|
+
{'...'}
|
|
189
|
+
</Button>)}
|
|
190
190
|
</ButtonGroup>
|
|
191
191
|
|
|
192
|
-
{lastPageButtonAvailable &&
|
|
192
|
+
{lastPageButtonAvailable &&
|
|
193
|
+
this.getButton(this.props.openTotal ? -1 : totalPages, this.props.translations?.lastPage ?? translate('lastPage'))}
|
|
193
194
|
</ButtonToolbar>
|
|
194
195
|
|
|
195
196
|
{this.getPageSizeSelector()}
|
|
@@ -199,9 +200,7 @@ export default class Pager extends PureComponent {
|
|
|
199
200
|
render() {
|
|
200
201
|
const classes = classNames(style.pager, this.props.className);
|
|
201
202
|
return (<div data-test="ring-pager" className={classes}>
|
|
202
|
-
{this.getTotalPages() > 1 || this.props.openTotal
|
|
203
|
-
? this.getPagerContent()
|
|
204
|
-
: this.getPageSizeSelector()}
|
|
203
|
+
{this.getTotalPages() > 1 || this.props.openTotal ? this.getPagerContent() : this.getPageSizeSelector()}
|
|
205
204
|
</div>);
|
|
206
205
|
}
|
|
207
206
|
}
|
|
@@ -37,9 +37,7 @@ export default class Permissions {
|
|
|
37
37
|
_permissionCache;
|
|
38
38
|
constructor(auth, config = {}) {
|
|
39
39
|
this.query = Permissions.getPermissionQuery(config.services);
|
|
40
|
-
this.namesConverter = config.prefix
|
|
41
|
-
? Permissions.getDefaultNamesConverter(config.prefix)
|
|
42
|
-
: config.namesConverter;
|
|
40
|
+
this.namesConverter = config.prefix ? Permissions.getDefaultNamesConverter(config.prefix) : config.namesConverter;
|
|
43
41
|
if (!auth) {
|
|
44
42
|
throw new Error('Parameter auth is required');
|
|
45
43
|
}
|
|
@@ -49,12 +47,12 @@ export default class Permissions {
|
|
|
49
47
|
this._subscribed = false;
|
|
50
48
|
this._permissionCache = new PermissionCache(null, this.namesConverter);
|
|
51
49
|
}
|
|
52
|
-
_defaultDatasource = (query) =>
|
|
50
|
+
_defaultDatasource = (query) => this._auth.http.get(Permissions.API_PERMISSION_CACHE_PATH, {
|
|
53
51
|
query: {
|
|
54
52
|
fields: 'permission/key,global,projects(id)',
|
|
55
|
-
query
|
|
56
|
-
}
|
|
57
|
-
})
|
|
53
|
+
query,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
58
56
|
/**
|
|
59
57
|
* Returns function, which cuts off prefix from server-side permission name
|
|
60
58
|
*
|
|
@@ -111,11 +109,9 @@ export default class Permissions {
|
|
|
111
109
|
return cache;
|
|
112
110
|
}
|
|
113
111
|
if (hasCacheControl('NO_STORE', options)) {
|
|
114
|
-
return this._loadPermissions().
|
|
115
|
-
then(cachedPermissions => new PermissionCache(cachedPermissions, this.namesConverter));
|
|
112
|
+
return this._loadPermissions().then(cachedPermissions => new PermissionCache(cachedPermissions, this.namesConverter));
|
|
116
113
|
}
|
|
117
|
-
const permissions = this._loadPermissions().
|
|
118
|
-
then(cachedPermissions => this.set(cachedPermissions));
|
|
114
|
+
const permissions = this._loadPermissions().then(cachedPermissions => this.set(cachedPermissions));
|
|
119
115
|
this._setCache(permissions);
|
|
120
116
|
return permissions;
|
|
121
117
|
function hasCacheControl(value, _options) {
|
|
@@ -168,8 +164,7 @@ export default class Permissions {
|
|
|
168
164
|
*/
|
|
169
165
|
bindVariable(object, propertyName, permissions, projectId) {
|
|
170
166
|
object[propertyName] = false;
|
|
171
|
-
return this.check(permissions, projectId).
|
|
172
|
-
then(permitted => {
|
|
167
|
+
return this.check(permissions, projectId).then(permitted => {
|
|
173
168
|
object[propertyName] = permitted;
|
|
174
169
|
return permitted;
|
|
175
170
|
});
|
|
@@ -43,7 +43,7 @@ export default class PermissionCache {
|
|
|
43
43
|
if (key) {
|
|
44
44
|
_permissionCache[key] = {
|
|
45
45
|
global: permission.global,
|
|
46
|
-
projectIdSet: this.constructor._toProjectIdSet(permission.projects)
|
|
46
|
+
projectIdSet: this.constructor._toProjectIdSet(permission.projects),
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
return _permissionCache;
|
|
@@ -139,7 +139,7 @@ export default class PermissionCache {
|
|
|
139
139
|
let result = this.and(lexems, projectId);
|
|
140
140
|
while (lexems.length > 0 && lexems[0] !== ')') {
|
|
141
141
|
if (lexems.shift() !== '|') {
|
|
142
|
-
throw new Error(
|
|
142
|
+
throw new Error("Operator '|' was expected");
|
|
143
143
|
}
|
|
144
144
|
result = this.and(lexems, projectId) || result;
|
|
145
145
|
}
|
|
@@ -173,7 +173,7 @@ export default class PermissionCache {
|
|
|
173
173
|
lexems.shift();
|
|
174
174
|
}
|
|
175
175
|
const result = this.term(lexems, projectId);
|
|
176
|
-
return
|
|
176
|
+
return notCounter % 2 === 0 ? result : !result;
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
179
|
* @param {string[]} lexems
|
|
@@ -191,7 +191,7 @@ export default class PermissionCache {
|
|
|
191
191
|
result = this.or(lexems, projectId);
|
|
192
192
|
// Expect ')'
|
|
193
193
|
if (lexems.shift() !== ')') {
|
|
194
|
-
throw new Error(
|
|
194
|
+
throw new Error("Operator ')' was expected");
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
else {
|
|
@@ -207,8 +207,7 @@ export default class PermissionCache {
|
|
|
207
207
|
testPermission(permissionName, projectId) {
|
|
208
208
|
const permissionCache = this.permissionCache;
|
|
209
209
|
const convertedName = this.namesConverter(permissionName);
|
|
210
|
-
const cachedPermission = permissionCache?.[permissionName] ||
|
|
211
|
-
convertedName && permissionCache?.[convertedName];
|
|
210
|
+
const cachedPermission = permissionCache?.[permissionName] || (convertedName && permissionCache?.[convertedName]);
|
|
212
211
|
// Hasn't the permission in any project
|
|
213
212
|
if (!cachedPermission) {
|
|
214
213
|
return false;
|
|
@@ -219,7 +218,7 @@ export default class PermissionCache {
|
|
|
219
218
|
}
|
|
220
219
|
if (projectId) {
|
|
221
220
|
// if projectId is specified check that the permission is given in the project
|
|
222
|
-
return cachedPermission.projectIdSet != null &&
|
|
221
|
+
return cachedPermission.projectIdSet != null && projectId in cachedPermission.projectIdSet;
|
|
223
222
|
}
|
|
224
223
|
else {
|
|
225
224
|
return true;
|
|
@@ -18,8 +18,14 @@ export var Directions;
|
|
|
18
18
|
* @type {Array.<string>}
|
|
19
19
|
*/
|
|
20
20
|
export const DEFAULT_DIRECTIONS = [
|
|
21
|
-
Directions.BOTTOM_RIGHT,
|
|
22
|
-
Directions.
|
|
21
|
+
Directions.BOTTOM_RIGHT,
|
|
22
|
+
Directions.BOTTOM_LEFT,
|
|
23
|
+
Directions.TOP_LEFT,
|
|
24
|
+
Directions.TOP_RIGHT,
|
|
25
|
+
Directions.RIGHT_TOP,
|
|
26
|
+
Directions.RIGHT_BOTTOM,
|
|
27
|
+
Directions.LEFT_TOP,
|
|
28
|
+
Directions.LEFT_BOTTOM,
|
|
23
29
|
];
|
|
24
30
|
/**
|
|
25
31
|
* @enum {number}
|
|
@@ -20,7 +20,7 @@ const isPossibleClientSideNavigation = (event) => {
|
|
|
20
20
|
const target = event.target;
|
|
21
21
|
const link = target.closest('a');
|
|
22
22
|
// Taken from https://github.com/nanostores/router/blob/80a333db4cf0789fda21a02715ebabca15192642/index.js#L58-L69
|
|
23
|
-
return link &&
|
|
23
|
+
return (link &&
|
|
24
24
|
event.button === 0 && // Left mouse button
|
|
25
25
|
link.target !== '_blank' && // Not for new tab
|
|
26
26
|
link.origin === location.origin && // Not external link
|
|
@@ -31,14 +31,14 @@ const isPossibleClientSideNavigation = (event) => {
|
|
|
31
31
|
!event.metaKey && // Not open in new tab by user
|
|
32
32
|
!event.ctrlKey && // Not open in new tab by user
|
|
33
33
|
!event.shiftKey && // Not open in new window by user
|
|
34
|
-
!event.defaultPrevented;
|
|
34
|
+
!event.defaultPrevented);
|
|
35
35
|
};
|
|
36
36
|
const stop = (event) => {
|
|
37
37
|
if (!isPossibleClientSideNavigation(event)) {
|
|
38
38
|
event.stopPropagation();
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
export const getPopupContainer = (target) =>
|
|
41
|
+
export const getPopupContainer = (target) => typeof target === 'string' ? document.querySelector(`[data-portaltarget=${target}]`) : target;
|
|
42
42
|
/**
|
|
43
43
|
* @constructor
|
|
44
44
|
* @name Popup
|
|
@@ -64,10 +64,10 @@ export default class Popup extends PureComponent {
|
|
|
64
64
|
attached: false,
|
|
65
65
|
trapFocus: false,
|
|
66
66
|
autoFocusFirst: false,
|
|
67
|
-
legacy: false
|
|
67
|
+
legacy: false,
|
|
68
68
|
};
|
|
69
69
|
state = {
|
|
70
|
-
display: Display.SHOWING
|
|
70
|
+
display: Display.SHOWING,
|
|
71
71
|
};
|
|
72
72
|
componentDidMount() {
|
|
73
73
|
if (!this.props.client) {
|
|
@@ -109,15 +109,13 @@ export default class Popup extends PureComponent {
|
|
|
109
109
|
uid = getUID('popup-');
|
|
110
110
|
calculateDisplay = (prevState) => ({
|
|
111
111
|
...prevState,
|
|
112
|
-
display: this.props.hidden
|
|
113
|
-
? Display.SHOWING
|
|
114
|
-
: Display.SHOWN
|
|
112
|
+
display: this.props.hidden ? Display.SHOWING : Display.SHOWN,
|
|
115
113
|
});
|
|
116
114
|
static PopupProps = {
|
|
117
115
|
Directions,
|
|
118
116
|
Dimension,
|
|
119
117
|
MinWidth,
|
|
120
|
-
MaxHeight
|
|
118
|
+
MaxHeight,
|
|
121
119
|
};
|
|
122
120
|
portalRef = (el) => {
|
|
123
121
|
this.node = el;
|
|
@@ -152,7 +150,7 @@ export default class Popup extends PureComponent {
|
|
|
152
150
|
left,
|
|
153
151
|
offset,
|
|
154
152
|
maxHeight,
|
|
155
|
-
minWidth
|
|
153
|
+
minWidth,
|
|
156
154
|
});
|
|
157
155
|
}
|
|
158
156
|
_updateDirection = (newDirection) => {
|
|
@@ -239,11 +237,9 @@ export default class Popup extends PureComponent {
|
|
|
239
237
|
* @private
|
|
240
238
|
*/
|
|
241
239
|
_onDocumentClick = (evt) => {
|
|
242
|
-
if (this.container && evt.target instanceof Node && this.container.contains(evt.target) ||
|
|
240
|
+
if ((this.container && evt.target instanceof Node && this.container.contains(evt.target)) ||
|
|
243
241
|
!this._listenersEnabled ||
|
|
244
|
-
(this.props.dontCloseOnAnchorClick &&
|
|
245
|
-
evt.target instanceof Node &&
|
|
246
|
-
this._getAnchor()?.contains(evt.target))) {
|
|
242
|
+
(this.props.dontCloseOnAnchorClick && evt.target instanceof Node && this._getAnchor()?.contains(evt.target))) {
|
|
247
243
|
return;
|
|
248
244
|
}
|
|
249
245
|
this.props.onOutsideClick(evt);
|
|
@@ -251,26 +247,23 @@ export default class Popup extends PureComponent {
|
|
|
251
247
|
};
|
|
252
248
|
getInternalContent() {
|
|
253
249
|
const { trapFocus, autoFocusFirst, children } = this.props;
|
|
254
|
-
return trapFocus
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
</TabTrap>)
|
|
258
|
-
: children;
|
|
250
|
+
return trapFocus ? (<TabTrap autoFocusFirst={autoFocusFirst} focusBackOnExit>
|
|
251
|
+
{children}
|
|
252
|
+
</TabTrap>) : (children);
|
|
259
253
|
}
|
|
260
254
|
shortcutsScope = this.uid;
|
|
261
255
|
shortcutsMap = {
|
|
262
|
-
esc: this._onEscPress
|
|
256
|
+
esc: this._onEscPress,
|
|
263
257
|
};
|
|
264
258
|
render() {
|
|
265
|
-
const { className, style, hidden, attached, keepMounted, client, onMouseDown, onMouseUp, onMouseOver, onMouseOut, onContextMenu, 'data-test': dataTest } = this.props;
|
|
259
|
+
const { className, style, hidden, attached, keepMounted, client, onMouseDown, onMouseUp, onMouseOver, onMouseOut, onContextMenu, 'data-test': dataTest, } = this.props;
|
|
266
260
|
const showing = this.state.display === Display.SHOWING;
|
|
267
261
|
const classes = classNames(className, styles.popup, {
|
|
268
262
|
[styles.attached]: attached,
|
|
269
263
|
[styles.hidden]: hidden,
|
|
270
|
-
[styles.showing]: showing
|
|
264
|
+
[styles.showing]: showing,
|
|
271
265
|
});
|
|
272
|
-
const direction = (this.state.direction || '').
|
|
273
|
-
toLowerCase().replace(/[_]/g, '-');
|
|
266
|
+
const direction = (this.state.direction || '').toLowerCase().replace(/[_]/g, '-');
|
|
274
267
|
return (<PopupTargetContext.Consumer>
|
|
275
268
|
{value => {
|
|
276
269
|
this.ringPopupTarget = value;
|
|
@@ -279,16 +272,17 @@ export default class Popup extends PureComponent {
|
|
|
279
272
|
onClick={stop}
|
|
280
273
|
// This handler only blocks bubbling through React portal
|
|
281
274
|
role="presentation" ref={this.portalRef}>
|
|
282
|
-
{this.shouldUseShortcuts() &&
|
|
283
|
-
(<Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>)}
|
|
275
|
+
{this.shouldUseShortcuts() && <Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>}
|
|
284
276
|
|
|
285
|
-
{(client || this.state.client) &&
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
277
|
+
{(client || this.state.client) &&
|
|
278
|
+
(keepMounted || !hidden) &&
|
|
279
|
+
createPortal(<PopupTarget id={this.uid} ref={this.containerRef} onMouseOver={onMouseOver} onFocus={onMouseOver} onMouseOut={onMouseOut} onBlur={onMouseOut} onContextMenu={onContextMenu}>
|
|
280
|
+
<div data-test={dataTests('ring-popup', dataTest)} data-test-shown={!hidden && !showing} data-test-direction={direction} ref={this.popupRef} className={classes} style={style} onMouseDown={onMouseDown} onMouseUp={onMouseUp}
|
|
281
|
+
// mouse handlers are used to track clicking on inner elements
|
|
282
|
+
role="presentation">
|
|
283
|
+
{this.getInternalContent()}
|
|
284
|
+
</div>
|
|
285
|
+
</PopupTarget>, this.getContainer() || document.body)}
|
|
292
286
|
</span>);
|
|
293
287
|
}}
|
|
294
288
|
</PopupTargetContext.Consumer>);
|
|
@@ -2,9 +2,9 @@ import { createContext, forwardRef } from 'react';
|
|
|
2
2
|
export const PopupTargetContext = createContext(undefined);
|
|
3
3
|
export const PopupTarget = forwardRef(function PopupTarget({ id, children, ...restProps }, ref) {
|
|
4
4
|
const target = (<div {...restProps} data-portaltarget={id} ref={ref}>
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
{typeof children !== 'function' && children}
|
|
6
|
+
</div>);
|
|
7
7
|
return (<PopupTargetContext.Provider value={id}>
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
{typeof children === 'function' ? children(target) : target}
|
|
9
|
+
</PopupTargetContext.Provider>);
|
|
10
10
|
});
|