@jetbrains/ring-ui 4.1.0-beta.3 → 4.1.1
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 +13 -0
- package/README.md +17 -15
- package/babel.config.js +3 -2
- package/components/alert/alert.js +9 -3
- package/components/alert/alert.test.js +21 -48
- package/components/alert/container.css +1 -1
- package/components/alert/container.test.js +3 -13
- package/components/alert-service/alert-service.examples.css +18 -0
- package/components/alert-service/alert-service.examples.js +21 -0
- package/components/alert-service/alert-service.js +10 -3
- package/components/analytics/analytics__fus-plugin.js +3 -3
- package/components/analytics/analytics__ga-plugin.js +2 -2
- package/components/auth/auth.test.js +14 -7
- package/components/auth/auth__core.js +64 -33
- package/components/auth-dialog/auth-dialog.css +2 -3
- package/components/auth-dialog/auth-dialog.js +4 -1
- package/components/auth-dialog/auth-dialog.test.js +3 -19
- package/components/avatar/avatar.css +4 -1
- package/components/avatar/avatar.examples.js +3 -2
- package/components/avatar/avatar.js +34 -6
- package/components/avatar/avatar.test.js +20 -17
- package/components/avatar/fallback-avatar.js +136 -0
- package/components/avatar-editor-ng/avatar-editor-ng.css +2 -2
- package/components/avatar-editor-ng/avatar-editor-ng.js +2 -1
- package/components/avatar-editor-ng/{avatar-editor-ng.html → avatar-editor-ng__template.js} +2 -2
- package/components/badge/badge.test.js +13 -20
- package/components/button/button.css +2 -2
- package/components/button/button.js +4 -1
- package/components/button/button.test.js +32 -33
- package/components/button-group/button-group.js +1 -1
- package/components/button-group/caption.js +1 -1
- package/components/button-ng/button-ng.js +1 -1
- package/components/button-set-ng/button-set-ng.js +3 -1
- package/components/checkbox/checkbox.css +1 -1
- package/components/code/code.js +2 -5
- package/components/confirm/confirm.js +1 -0
- package/components/confirm-service/confirm-service.js +5 -5
- package/components/content-layout/content-layout.css +1 -1
- package/components/data-list/data-list.css +1 -1
- package/components/date-picker/date-input.js +5 -4
- package/components/date-picker/date-picker.css +34 -22
- package/components/date-picker/date-picker.js +16 -14
- package/components/date-picker/date-popup.js +22 -7
- package/components/date-picker/month-names.js +8 -5
- package/components/date-picker/month.js +6 -2
- package/components/date-picker/weekdays.js +10 -2
- package/components/dialog/dialog.examples.js +3 -1
- package/components/dialog/dialog.js +10 -5
- package/components/dialog/dialog.test.js +1 -1
- package/components/dialog/dialog__body-scroll-preventer.js +51 -31
- package/components/dialog-ng/dialog-ng.js +10 -10
- package/components/dialog-ng/{dialog-ng.html → dialog-ng__template.js} +2 -2
- package/components/dropdown/dropdown.examples.js +36 -1
- package/components/dropdown/dropdown.test.js +2 -2
- package/components/dropdown-menu/dropdown-menu.examples.js +47 -0
- package/components/dropdown-menu/dropdown-menu.js +117 -0
- package/components/dropdown-menu/dropdown-menu.test.js +76 -0
- package/components/error-bubble/error-bubble-legacy.css +1 -1
- package/components/error-bubble/error-bubble.css +1 -1
- package/components/error-bubble/error-bubble.examples.js +1 -1
- package/components/error-page/error-page.css +2 -2
- package/components/footer-ng/footer-ng.js +13 -3
- package/components/form/form.css +2 -2
- package/components/form-ng/form-ng.js +3 -1
- package/components/global/global.css +1 -1
- package/components/global/theme.js +1 -1
- package/components/global/variables.css +8 -1
- package/components/grid/grid.css +10 -9
- package/components/header/header.css +1 -1
- package/components/header/header.examples.js +7 -8
- package/components/header/profile.js +10 -11
- package/components/http/http.js +1 -1
- package/components/icon/icon.css +5 -4
- package/components/input/input-legacy.css +7 -7
- package/components/island/header.js +2 -2
- package/components/island/island.css +8 -3
- package/components/island-legacy/island-legacy.css +3 -1
- package/components/list/list.js +6 -1
- package/components/list/list__custom.js +9 -3
- package/components/list/list__item.js +8 -2
- package/components/list/list__link.js +2 -1
- package/components/loader-inline/loader-inline.css +1 -1
- package/components/loader-screen/loader-screen.css +1 -1
- package/components/message/message.css +1 -1
- package/components/message/message.examples.js +8 -7
- package/components/pager/pager.js +5 -3
- package/components/permissions/permissions.js +1 -1
- package/components/popup/popup.js +1 -1
- package/components/popup/popup.test.js +15 -13
- package/components/progress-bar/progress-bar.css +1 -1
- package/components/progress-bar/progress-bar.examples.js +3 -3
- package/components/progress-bar/progress-bar.js +5 -2
- package/components/progress-bar/progress-bar.test.js +12 -13
- package/components/progress-bar-ng/progress-bar-ng.examples.js +3 -3
- package/components/query-assist/query-assist.css +13 -3
- package/components/query-assist/query-assist.examples.js +3 -4
- package/components/query-assist/query-assist.js +56 -12
- package/components/query-assist/query-assist.test.js +37 -5
- package/components/save-field-ng/save-field-ng.css +0 -3
- package/components/save-field-ng/save-field-ng.js +3 -1
- package/components/save-field-ng/{save-field-ng.html → save-field-ng__template.js} +2 -2
- package/components/select/select.css +12 -7
- package/components/select/select.examples.js +13 -0
- package/components/select/select.js +30 -43
- package/components/select/select.test.js +4 -5
- package/components/select/select__popup.js +1 -0
- package/components/shortcuts-hint-ng/shortcuts-hint-ng.css +1 -1
- package/components/shortcuts-hint-ng/shortcuts-hint-ng.js +1 -1
- package/components/shortcuts-hint-ng/{shortcuts-hint-ng.html → shortcuts-hint-ng__template.js} +2 -2
- package/components/sidebar/sidebar.css +1 -0
- package/components/sidebar-ng/sidebar-ng.js +6 -2
- package/components/sidebar-ng/{sidebar-ng__button.html → sidebar-ng__button-template.js} +2 -2
- package/components/sidebar-ng/{sidebar-ng.html → sidebar-ng__template.js} +2 -2
- package/components/table/header.js +9 -1
- package/components/table/row.js +2 -1
- package/components/table/table.css +2 -1
- package/components/table-legacy/table-legacy.css +2 -2
- package/components/table-legacy/table-legacy__toolbar.css +2 -2
- package/components/table-legacy-ng/table-legacy-ng.js +38 -5
- package/components/table-legacy-ng/table-legacy-ng__pager.js +7 -1
- package/components/tabs/collapsible-tab.js +2 -2
- package/components/tabs/collapsible-tabs.js +5 -9
- package/components/tabs/tab-link.js +4 -2
- package/components/tabs/tabs.css +32 -5
- package/components/tabs-ng/tabs-ng.js +4 -2
- package/components/tabs-ng/{tabs-ng.html → tabs-ng__template.js} +6 -2
- package/components/tag/tag.css +5 -2
- package/components/tag/tag.examples.js +3 -0
- package/components/tag/tag.js +19 -16
- package/components/tags-input/tag-input.examples.js +1 -1
- package/components/tags-input/tags-input.js +5 -2
- package/components/template-ng/template-ng.js +1 -1
- package/components/tooltip/tooltip.js +7 -2
- package/components/user-agreement/user-agreement.css +1 -5
- package/components/user-agreement/user-agreement.examples.js +7 -6
- package/components/user-agreement/user-agreement.js +11 -3
- package/package.json +85 -83
- package/webpack.config.js +14 -10
- package/components/button-set-ng/button-set-ng.html +0 -1
- package/components/footer-ng/footer-ng.html +0 -13
- package/components/form-ng/form-ng__error-bubble.html +0 -3
- package/components/table-legacy-ng/table-legacy-ng.html +0 -4
- package/components/table-legacy-ng/table-legacy-ng__column.html +0 -12
- package/components/table-legacy-ng/table-legacy-ng__header.html +0 -4
- package/components/table-legacy-ng/table-legacy-ng__pager.html +0 -7
- package/components/table-legacy-ng/table-legacy-ng__row.html +0 -12
- package/components/table-legacy-ng/table-legacy-ng__title.html +0 -9
- package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -123
- package/dist/_helpers/background-flow.js +0 -232
- package/dist/_helpers/badge.js +0 -3
- package/dist/_helpers/button.js +0 -145
- package/dist/_helpers/clickableLink.js +0 -65
- package/dist/_helpers/data-tests.js +0 -15
- package/dist/_helpers/disable-hover-hoc.js +0 -407
- package/dist/_helpers/dom.js +0 -101
- package/dist/_helpers/get-uid.js +0 -15
- package/dist/_helpers/linear-function.js +0 -17
- package/dist/_helpers/list.js +0 -1327
- package/dist/_helpers/logo.js +0 -36
- package/dist/_helpers/memoize.js +0 -17
- package/dist/_helpers/popup.js +0 -691
- package/dist/_helpers/popup.target.js +0 -27
- package/dist/_helpers/rerender-hoc.js +0 -49
- package/dist/_helpers/schedule-raf.js +0 -31
- package/dist/_helpers/sniffer.js +0 -6
- package/dist/_helpers/theme.js +0 -40
- package/dist/_helpers/url.js +0 -125
- package/dist/alert-service.js +0 -149
- package/dist/alert.js +0 -284
- package/dist/analytics.js +0 -116
- package/dist/auth-dialog-service.js +0 -56
- package/dist/auth-dialog.js +0 -122
- package/dist/auth.js +0 -1744
- package/dist/avatar.js +0 -152
- package/dist/badge.js +0 -52
- package/dist/button-group.js +0 -48
- package/dist/button-set.js +0 -27
- package/dist/button-toolbar.js +0 -30
- package/dist/button.js +0 -12
- package/dist/caret.js +0 -262
- package/dist/checkbox.js +0 -108
- package/dist/confirm-service.js +0 -102
- package/dist/confirm.js +0 -113
- package/dist/content-layout.js +0 -184
- package/dist/contenteditable.js +0 -81
- package/dist/data-list.js +0 -466
- package/dist/date-picker.js +0 -1398
- package/dist/dialog.js +0 -223
- package/dist/dropdown.js +0 -250
- package/dist/error-bubble.js +0 -56
- package/dist/error-message.js +0 -53
- package/dist/footer.js +0 -124
- package/dist/grid.js +0 -148
- package/dist/group.js +0 -34
- package/dist/header.js +0 -658
- package/dist/heading.js +0 -76
- package/dist/http.js +0 -207
- package/dist/hub-source.js +0 -130
- package/dist/icon.js +0 -211
- package/dist/input.js +0 -228
- package/dist/island.js +0 -314
- package/dist/link.js +0 -117
- package/dist/list.js +0 -29
- package/dist/loader-inline.js +0 -165
- package/dist/loader-screen.js +0 -45
- package/dist/loader.js +0 -338
- package/dist/login-dialog.js +0 -173
- package/dist/logo.js +0 -8
- package/dist/message.js +0 -226
- package/dist/old-browsers-message.js +0 -129
- package/dist/pager.js +0 -325
- package/dist/panel.js +0 -34
- package/dist/permissions.js +0 -466
- package/dist/popup-menu.js +0 -93
- package/dist/popup.js +0 -16
- package/dist/progress-bar.js +0 -111
- package/dist/proxy-attrs.js +0 -19
- package/dist/query-assist.js +0 -1081
- package/dist/radio.js +0 -112
- package/dist/select.js +0 -1920
- package/dist/selection.js +0 -213
- package/dist/shortcuts.js +0 -307
- package/dist/storage.js +0 -373
- package/dist/style.css +0 -1
- package/dist/tab-trap.js +0 -174
- package/dist/table.js +0 -903
- package/dist/tabs.js +0 -721
- package/dist/tag.js +0 -187
- package/dist/tags-input.js +0 -440
- package/dist/tags-list.js +0 -91
- package/dist/text.js +0 -38
- package/dist/toggle.js +0 -80
- package/dist/tooltip.js +0 -202
- package/dist/user-card.js +0 -218
package/dist/loader-inline.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { c as _objectSpread2, _ as _objectWithoutProperties, a as _extends, b as _defineProperty } from './_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import { T as Theme, w as withTheme } from './_helpers/theme.js';
|
|
6
|
-
import { j as joinDataTestAttributes } from './_helpers/data-tests.js';
|
|
7
|
-
import 'conic-gradient';
|
|
8
|
-
import { m as memoize } from './_helpers/memoize.js';
|
|
9
|
-
import { g as getUID } from './_helpers/get-uid.js';
|
|
10
|
-
|
|
11
|
-
var modules_e49a3529 = {"unit":"8px","loader":"loaderInline_loader__9affcd5c","spin":"loaderInline_spin__9affcd5c","pulse":"loaderInline_pulse__9affcd5c","children":"loaderInline_children__9affcd5c"};
|
|
12
|
-
|
|
13
|
-
var supportsCss = memoize(declaration => {
|
|
14
|
-
const [property, value] = declaration.split(': ');
|
|
15
|
-
const camelCaseProperty = property.replace(/-(\w)/g, (_, letter) => letter.toUpperCase());
|
|
16
|
-
const div = document.createElement('div');
|
|
17
|
-
|
|
18
|
-
if (div.style[camelCaseProperty] === undefined) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (value) {
|
|
23
|
-
div.style[camelCaseProperty] = value;
|
|
24
|
-
return Boolean(div.style[camelCaseProperty]);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return true;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const conicGradient = memoize(({
|
|
31
|
-
stops,
|
|
32
|
-
size
|
|
33
|
-
}) => supportsCss('background-image: conic-gradient(white, black)') ? `conic-gradient(${stops})` : new ConicGradient({
|
|
34
|
-
stops,
|
|
35
|
-
size
|
|
36
|
-
}));
|
|
37
|
-
const conicGradientWithMask = (mask, stops, size) => {
|
|
38
|
-
const gradient = conicGradient({
|
|
39
|
-
stops,
|
|
40
|
-
size
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (!mask.supports && gradient instanceof ConicGradient) {
|
|
44
|
-
Object.defineProperty(gradient, 'svg', {
|
|
45
|
-
value: gradient.svg.replace('<image ', `
|
|
46
|
-
${mask.svgDefs}
|
|
47
|
-
<image mask="url(#${mask.maskId})" `)
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return _objectSpread2(_objectSpread2({}, mask.css), {}, {
|
|
52
|
-
'background-image': gradient.toString()
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const injectStyleSheet = styles => {
|
|
57
|
-
const styleTag = document.createElement('style');
|
|
58
|
-
styleTag.setAttribute('type', 'text/css');
|
|
59
|
-
styleTag.textContent = styles;
|
|
60
|
-
document.head.appendChild(styleTag);
|
|
61
|
-
return styleTag;
|
|
62
|
-
};
|
|
63
|
-
const injectRuleSet = (selector, declarations) => injectStyleSheet(`
|
|
64
|
-
${selector} {
|
|
65
|
-
${Object.entries(declarations).map(([property, value]) => `${property}: ${value};`).join(`
|
|
66
|
-
`)}
|
|
67
|
-
}`);
|
|
68
|
-
|
|
69
|
-
const radialGradient = (length, stops) => `radial-gradient(${length}, ${Object.entries(stops).map(entry => entry.join(' ')).join(', ')})`;
|
|
70
|
-
|
|
71
|
-
var radialGradientMask = ((length, stops) => {
|
|
72
|
-
for (const prefix of ['', '-webkit-']) {
|
|
73
|
-
const property = `${prefix}mask-image`;
|
|
74
|
-
const declaration = `${property}: radial-gradient(black, white)`;
|
|
75
|
-
|
|
76
|
-
if (supportsCss(declaration)) {
|
|
77
|
-
return {
|
|
78
|
-
supports: true,
|
|
79
|
-
css: {
|
|
80
|
-
[property]: radialGradient(length, stops)
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const gradientId = getUID('gradient');
|
|
87
|
-
const maskId = getUID('mask');
|
|
88
|
-
const svgDefs = `
|
|
89
|
-
<svg>
|
|
90
|
-
<defs>
|
|
91
|
-
<radialGradient id="${gradientId}">
|
|
92
|
-
${Object.entries(stops).map(([color, offset]) => `
|
|
93
|
-
<stop offset="${offset}" stop-color="${color}"/>
|
|
94
|
-
`).join('')}
|
|
95
|
-
</radialGradient>
|
|
96
|
-
<mask id="${maskId}">
|
|
97
|
-
<rect height="100%" width="100%" fill="url(#${gradientId})"/>
|
|
98
|
-
</mask>
|
|
99
|
-
</defs>
|
|
100
|
-
</svg>
|
|
101
|
-
`;
|
|
102
|
-
return {
|
|
103
|
-
supports: false,
|
|
104
|
-
css: {},
|
|
105
|
-
maskId,
|
|
106
|
-
svgDefs
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const IMAGE_SIZE = 32;
|
|
111
|
-
var injectStyles = memoize(() => {
|
|
112
|
-
const mask = radialGradientMask(modules_e49a3529.unit, {
|
|
113
|
-
/* eslint-disable no-magic-numbers */
|
|
114
|
-
transparent: `${23 / 32 * 100}%`,
|
|
115
|
-
white: `${25 / 32 * 100}%`
|
|
116
|
-
/* eslint-enable */
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
injectRuleSet(`.${modules_e49a3529.loader}_${[Theme.LIGHT]}::after, .ring-loader-inline::after`, conicGradientWithMask(mask, '#ff00eb,#bd3bff,#008eff, #58ba00,#f48700,#ff00eb', IMAGE_SIZE));
|
|
120
|
-
injectRuleSet(`.${modules_e49a3529.loader}_${[Theme.DARK]}::after, .ring-loader-inline_dark::after`, conicGradientWithMask(mask, '#ff2eef,#d178ff,#289fff,#88d444,#ffe000,#ff2eef', IMAGE_SIZE));
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @name Loader Inline
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
class LoaderInline extends PureComponent {
|
|
128
|
-
componentDidMount() {
|
|
129
|
-
injectStyles();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
render() {
|
|
133
|
-
const _this$props = this.props,
|
|
134
|
-
{
|
|
135
|
-
className,
|
|
136
|
-
theme,
|
|
137
|
-
'data-test': dataTest,
|
|
138
|
-
children
|
|
139
|
-
} = _this$props,
|
|
140
|
-
restProps = _objectWithoutProperties(_this$props, ["className", "theme", "data-test", "children"]);
|
|
141
|
-
|
|
142
|
-
const classes = classNames(modules_e49a3529.loader, className, `${modules_e49a3529.loader}_${theme}`);
|
|
143
|
-
const loader = /*#__PURE__*/React.createElement("div", _extends({}, restProps, {
|
|
144
|
-
"data-test": joinDataTestAttributes('ring-loader-inline', dataTest),
|
|
145
|
-
className: classes
|
|
146
|
-
}));
|
|
147
|
-
return children ? /*#__PURE__*/React.createElement(React.Fragment, null, loader, /*#__PURE__*/React.createElement("span", {
|
|
148
|
-
className: modules_e49a3529.children
|
|
149
|
-
}, children)) : loader;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
_defineProperty(LoaderInline, "propTypes", {
|
|
155
|
-
theme: PropTypes.oneOf(Object.values(Theme)),
|
|
156
|
-
className: PropTypes.string,
|
|
157
|
-
'data-test': PropTypes.string,
|
|
158
|
-
children: PropTypes.node
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
_defineProperty(LoaderInline, "Theme", Theme);
|
|
162
|
-
|
|
163
|
-
var LoaderInline$1 = withTheme()(LoaderInline);
|
|
164
|
-
|
|
165
|
-
export default LoaderInline$1;
|
package/dist/loader-screen.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { _ as _objectWithoutProperties, a as _extends, b as _defineProperty } from './_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import Loader from './loader.js';
|
|
6
|
-
import './_helpers/data-tests.js';
|
|
7
|
-
import './_helpers/dom.js';
|
|
8
|
-
|
|
9
|
-
var modules_122a82e9 = {"loaderScreen":"loaderScreen_loaderScreen__58811ca6","loader":"loaderScreen_loader__58811ca6","loaderWithoutSpacing":"loaderScreen_loaderWithoutSpacing__58811ca6"};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @name Loader Screen
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
class LoaderScreen extends PureComponent {
|
|
16
|
-
render() {
|
|
17
|
-
const _this$props = this.props,
|
|
18
|
-
{
|
|
19
|
-
message,
|
|
20
|
-
className,
|
|
21
|
-
containerClassName
|
|
22
|
-
} = _this$props,
|
|
23
|
-
restProps = _objectWithoutProperties(_this$props, ["message", "className", "containerClassName"]);
|
|
24
|
-
|
|
25
|
-
const containerClasses = classNames(containerClassName, modules_122a82e9.loaderScreen);
|
|
26
|
-
const loaderClasses = classNames(className, modules_122a82e9.loader, {
|
|
27
|
-
[modules_122a82e9.loaderWithoutSpacing]: !message
|
|
28
|
-
});
|
|
29
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
-
className: containerClasses
|
|
31
|
-
}, /*#__PURE__*/React.createElement(Loader, _extends({}, restProps, {
|
|
32
|
-
message: message,
|
|
33
|
-
className: loaderClasses
|
|
34
|
-
})));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
_defineProperty(LoaderScreen, "propTypes", {
|
|
40
|
-
className: PropTypes.string,
|
|
41
|
-
containerClassName: PropTypes.string,
|
|
42
|
-
message: PropTypes.string
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export default LoaderScreen;
|
package/dist/loader.js
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { b as _defineProperty, _ as _objectWithoutProperties, a as _extends } from './_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { j as joinDataTestAttributes } from './_helpers/data-tests.js';
|
|
5
|
-
import { a as getPixelRatio } from './_helpers/dom.js';
|
|
6
|
-
|
|
7
|
-
var modules_00b5ad26 = {"unit":"8px","canvas":"loader_canvas__2113523f","animate":"loader_animate__2113523f","rotation-keyframes":"loader_rotationKeyframes__2113523f","text":"loader_text__2113523f"};
|
|
8
|
-
|
|
9
|
-
const INITIAL_TICKS = 100;
|
|
10
|
-
|
|
11
|
-
class Particle {
|
|
12
|
-
constructor({
|
|
13
|
-
x,
|
|
14
|
-
y,
|
|
15
|
-
radius,
|
|
16
|
-
color
|
|
17
|
-
}) {
|
|
18
|
-
this.radius = radius;
|
|
19
|
-
this.x = x;
|
|
20
|
-
this.y = y;
|
|
21
|
-
this.color = color;
|
|
22
|
-
this.decay = 0.01;
|
|
23
|
-
this.life = 1;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
step() {
|
|
27
|
-
this.life -= this.decay;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
isAlive() {
|
|
31
|
-
return this.life >= 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
draw(ctx) {
|
|
35
|
-
const alpha = this.life >= 0 ? this.life : 0;
|
|
36
|
-
ctx.fillStyle = `rgba(${this.color.r}, ${this.color.g}, ${this.color.b}, ${alpha})`;
|
|
37
|
-
ctx.beginPath();
|
|
38
|
-
ctx.arc(this.x + this.radius, this.y + this.radius, this.radius, 0, Math.PI * 2);
|
|
39
|
-
ctx.fill();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const DETERMINISTIC_VALUE = 0.5;
|
|
45
|
-
|
|
46
|
-
function deterministic() {
|
|
47
|
-
return DETERMINISTIC_VALUE;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class LoaderCore {
|
|
51
|
-
static calculateGradient(startColor, stopColor, position) {
|
|
52
|
-
const calculateChannelValue = (a, b) => a + Math.round((b - a) * position);
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
r: calculateChannelValue(startColor.r, stopColor.r),
|
|
56
|
-
g: calculateChannelValue(startColor.g, stopColor.g),
|
|
57
|
-
b: calculateChannelValue(startColor.b, stopColor.b)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
constructor(containerNode, props) {
|
|
62
|
-
this.props = Object.assign({}, LoaderCore.defaultProps, props);
|
|
63
|
-
this.renderInNode(containerNode);
|
|
64
|
-
this.initializeLoader();
|
|
65
|
-
this.isRunning = !this.props.stop;
|
|
66
|
-
|
|
67
|
-
if (this.isRunning) {
|
|
68
|
-
this.startAnimation();
|
|
69
|
-
} else {
|
|
70
|
-
this.draw();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static getPixelRatio() {
|
|
75
|
-
return getPixelRatio();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
setCanvasSize() {
|
|
79
|
-
const pixelRatio = LoaderCore.getPixelRatio();
|
|
80
|
-
const canvasSize = this.props.size * pixelRatio;
|
|
81
|
-
this.canvas.width = canvasSize;
|
|
82
|
-
this.canvas.height = canvasSize; //Fixate canvas physical size to avoid real size scaling
|
|
83
|
-
|
|
84
|
-
this.canvas.style.width = `${this.props.size}px`;
|
|
85
|
-
this.canvas.style.height = `${this.props.size}px`;
|
|
86
|
-
this.ctx = this.canvas.getContext('2d');
|
|
87
|
-
this.ctx.scale(pixelRatio, pixelRatio);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
initializeLoader() {
|
|
91
|
-
this.setCanvasSize();
|
|
92
|
-
this.height = this.props.size;
|
|
93
|
-
this.width = this.props.size;
|
|
94
|
-
this.particles = []; //Configuration
|
|
95
|
-
|
|
96
|
-
this.baseSpeed = 1.0;
|
|
97
|
-
this.colorIndex = 0;
|
|
98
|
-
this.maxRadius = 10;
|
|
99
|
-
this.minRadius = 6;
|
|
100
|
-
this.colorChangeTick = 40; //State
|
|
101
|
-
|
|
102
|
-
this.x = 0;
|
|
103
|
-
this.y = 0;
|
|
104
|
-
this.radius = 8;
|
|
105
|
-
this.hSpeed = 1.5;
|
|
106
|
-
this.vSpeed = 0.5;
|
|
107
|
-
this.radiusSpeed = 0.05;
|
|
108
|
-
this.tick = 0;
|
|
109
|
-
this.prepareInitialState(INITIAL_TICKS);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
prepareInitialState(ticks) {
|
|
113
|
-
for (let i = 0; i < ticks; i++) {
|
|
114
|
-
this.step();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
handleLimits(coord, radius, speed, limit) {
|
|
119
|
-
const randomFunc = this.props.deterministic ? deterministic : Math.random;
|
|
120
|
-
const randomizedSpeedChange = randomFunc(this.baseSpeed) - this.baseSpeed / 2;
|
|
121
|
-
|
|
122
|
-
if (coord + radius * 2 + this.baseSpeed >= limit) {
|
|
123
|
-
return -(this.baseSpeed + randomizedSpeedChange);
|
|
124
|
-
} else if (coord <= this.baseSpeed) {
|
|
125
|
-
return this.baseSpeed + randomizedSpeedChange;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return speed;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
calculateNextCoordinates() {
|
|
132
|
-
this.x += this.hSpeed;
|
|
133
|
-
this.y += this.vSpeed;
|
|
134
|
-
this.hSpeed = this.handleLimits(this.x, this.radius, this.hSpeed, this.width);
|
|
135
|
-
this.vSpeed = this.handleLimits(this.y, this.radius, this.vSpeed, this.height);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
calculateNextRadius() {
|
|
139
|
-
this.radius += this.radiusSpeed;
|
|
140
|
-
|
|
141
|
-
if (this.radius > this.maxRadius || this.radius < this.minRadius) {
|
|
142
|
-
this.radiusSpeed = -this.radiusSpeed;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
getNextColor() {
|
|
147
|
-
const colors = this.props.colors;
|
|
148
|
-
const currentColor = colors[this.colorIndex];
|
|
149
|
-
const nextColor = colors[this.colorIndex + 1] || colors[0];
|
|
150
|
-
return LoaderCore.calculateGradient(currentColor, nextColor, this.tick / this.colorChangeTick);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
nextTick() {
|
|
154
|
-
this.tick++;
|
|
155
|
-
|
|
156
|
-
if (this.tick > this.colorChangeTick) {
|
|
157
|
-
this.tick = 0;
|
|
158
|
-
this.colorIndex++;
|
|
159
|
-
|
|
160
|
-
if (this.colorIndex > this.props.colors.length - 1) {
|
|
161
|
-
this.colorIndex = 0;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
step() {
|
|
167
|
-
this.nextTick();
|
|
168
|
-
this.calculateNextCoordinates();
|
|
169
|
-
this.calculateNextRadius();
|
|
170
|
-
this.particles.forEach(particle => particle.step());
|
|
171
|
-
this.particles.push(new Particle({
|
|
172
|
-
x: this.x,
|
|
173
|
-
y: this.y,
|
|
174
|
-
radius: this.radius,
|
|
175
|
-
color: this.getNextColor()
|
|
176
|
-
}));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
removeDeadParticles() {
|
|
180
|
-
this.particles = this.particles.filter(it => it.isAlive());
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
draw() {
|
|
184
|
-
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
185
|
-
this.removeDeadParticles();
|
|
186
|
-
this.particles.forEach(particle => particle.draw(this.ctx));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
loop() {
|
|
190
|
-
this.step();
|
|
191
|
-
this.draw();
|
|
192
|
-
|
|
193
|
-
if (this.isRunning) {
|
|
194
|
-
window.requestAnimationFrame(() => this.loop());
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
updateMessage(text) {
|
|
199
|
-
this.textNode.textContent = text || '';
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
stopAnimation() {
|
|
203
|
-
this.isRunning = false;
|
|
204
|
-
this.canvas.classList.remove(modules_00b5ad26.animate);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
startAnimation() {
|
|
208
|
-
this.isRunning = true;
|
|
209
|
-
this.canvas.classList.add(modules_00b5ad26.animate);
|
|
210
|
-
this.loop();
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
destroy() {
|
|
214
|
-
this.isRunning = false;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
renderInNode(node) {
|
|
218
|
-
this.canvas = document.createElement('canvas');
|
|
219
|
-
this.canvas.dataset.test = 'ring-loader';
|
|
220
|
-
this.canvas.classList.add(modules_00b5ad26.canvas);
|
|
221
|
-
this.textNode = document.createElement('div');
|
|
222
|
-
this.textNode.dataset.test = 'ring-loader-text';
|
|
223
|
-
this.textNode.classList.add(modules_00b5ad26.text);
|
|
224
|
-
this.textNode.textContent = this.props.message ? this.props.message : '';
|
|
225
|
-
node.appendChild(this.canvas);
|
|
226
|
-
node.appendChild(this.textNode);
|
|
227
|
-
return node;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
_defineProperty(LoaderCore, "defaultProps", {
|
|
233
|
-
size: 64,
|
|
234
|
-
stop: false,
|
|
235
|
-
deterministic: false,
|
|
236
|
-
colors: [{
|
|
237
|
-
r: 215,
|
|
238
|
-
g: 60,
|
|
239
|
-
b: 234
|
|
240
|
-
}, //#D73CEA
|
|
241
|
-
{
|
|
242
|
-
r: 145,
|
|
243
|
-
g: 53,
|
|
244
|
-
b: 224
|
|
245
|
-
}, //#9135E0
|
|
246
|
-
{
|
|
247
|
-
r: 88,
|
|
248
|
-
g: 72,
|
|
249
|
-
b: 224
|
|
250
|
-
}, //#5848F4
|
|
251
|
-
{
|
|
252
|
-
r: 37,
|
|
253
|
-
g: 183,
|
|
254
|
-
b: 255
|
|
255
|
-
}, //#25B7FF
|
|
256
|
-
{
|
|
257
|
-
r: 89,
|
|
258
|
-
g: 189,
|
|
259
|
-
b: 0
|
|
260
|
-
}, //#59BD00
|
|
261
|
-
{
|
|
262
|
-
r: 251,
|
|
263
|
-
g: 172,
|
|
264
|
-
b: 2
|
|
265
|
-
}, //#FBAC02
|
|
266
|
-
{
|
|
267
|
-
r: 227,
|
|
268
|
-
g: 37,
|
|
269
|
-
b: 129
|
|
270
|
-
} //#E32581
|
|
271
|
-
]
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* @name Loader
|
|
276
|
-
*/
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Displays a large animated loader with an optional caption. Typical use cases: page loading animation, major action animation.
|
|
280
|
-
*/
|
|
281
|
-
|
|
282
|
-
class Loader extends PureComponent {
|
|
283
|
-
constructor(...args) {
|
|
284
|
-
super(...args);
|
|
285
|
-
|
|
286
|
-
_defineProperty(this, "initLoader", el => {
|
|
287
|
-
if (el) {
|
|
288
|
-
this.loader = new LoaderCore(el, this.props);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
componentDidUpdate(prevProps) {
|
|
294
|
-
if (this.loader) {
|
|
295
|
-
if (!prevProps.stop && this.props.stop) {
|
|
296
|
-
this.loader.stopAnimation();
|
|
297
|
-
} else if (prevProps.stop && !this.props.stop) {
|
|
298
|
-
this.loader.startAnimation();
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
componentWillUnmount() {
|
|
304
|
-
this.loader.destroy();
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
render() {
|
|
308
|
-
const _this$props = this.props,
|
|
309
|
-
{
|
|
310
|
-
message,
|
|
311
|
-
size,
|
|
312
|
-
colors,
|
|
313
|
-
'data-test': dataTest,
|
|
314
|
-
stop,
|
|
315
|
-
deterministic
|
|
316
|
-
} = _this$props,
|
|
317
|
-
restProps = _objectWithoutProperties(_this$props, ["message", "size", "colors", "data-test", "stop", "deterministic"]);
|
|
318
|
-
|
|
319
|
-
return /*#__PURE__*/React.createElement("div", _extends({
|
|
320
|
-
"data-test": joinDataTestAttributes('ring-loader', dataTest)
|
|
321
|
-
}, restProps, {
|
|
322
|
-
ref: this.initLoader
|
|
323
|
-
}));
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
_defineProperty(Loader, "propTypes", {
|
|
329
|
-
className: PropTypes.string,
|
|
330
|
-
size: PropTypes.number,
|
|
331
|
-
colors: PropTypes.array,
|
|
332
|
-
message: PropTypes.string,
|
|
333
|
-
'data-test': PropTypes.string,
|
|
334
|
-
stop: PropTypes.bool,
|
|
335
|
-
deterministic: PropTypes.bool
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
export default Loader;
|