@jetbrains/ring-ui 4.1.1 → 4.1.2
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/dist/_helpers/_rollupPluginBabelHelpers.js +34 -0
- package/dist/_helpers/anchor.js +32 -0
- package/dist/_helpers/badge.js +3 -0
- package/dist/_helpers/button-group.js +3 -0
- package/dist/_helpers/button-set.js +3 -0
- package/dist/_helpers/button-toolbar.js +3 -0
- package/dist/_helpers/button__classes.js +39 -0
- package/dist/_helpers/card.js +75 -0
- package/dist/_helpers/checkbox.js +3 -0
- package/dist/_helpers/date-picker.js +3 -0
- package/dist/_helpers/dialog__body-scroll-preventer.js +57 -0
- package/dist/_helpers/error-message.js +3 -0
- package/dist/_helpers/footer.js +121 -0
- package/dist/_helpers/grid.js +3 -0
- package/dist/_helpers/group.js +3 -0
- package/dist/_helpers/header.js +3 -0
- package/dist/_helpers/icon.js +3 -0
- package/dist/_helpers/inject-styles.js +22 -0
- package/dist/_helpers/input.js +3 -0
- package/dist/_helpers/island.js +3 -0
- package/dist/_helpers/link.js +3 -0
- package/dist/_helpers/list.js +3 -0
- package/dist/_helpers/loader-screen.js +3 -0
- package/dist/_helpers/panel.js +3 -0
- package/dist/_helpers/query-assist__suggestions.js +95 -0
- package/dist/_helpers/radio.js +3 -0
- package/dist/_helpers/select__filter.js +76 -0
- package/dist/_helpers/services-link.js +40 -0
- package/dist/_helpers/sidebar.js +125 -0
- package/dist/_helpers/table.js +3 -0
- package/dist/_helpers/tabs.js +3 -0
- package/dist/_helpers/title.js +99 -0
- package/dist/alert/alert.js +260 -0
- package/dist/alert/container.js +48 -0
- package/dist/alert-service/alert-service.js +170 -0
- package/dist/analytics/analytics.js +116 -0
- package/dist/analytics/analytics__custom-plugin.js +127 -0
- package/dist/analytics/analytics__fus-plugin.js +101 -0
- package/dist/analytics/analytics__ga-plugin.js +66 -0
- package/dist/analytics/analytics__plugin-utils.js +79 -0
- package/dist/analytics-ng/analytics-ng.js +94 -0
- package/dist/auth/auth.js +93 -0
- package/dist/auth/auth__core.js +1025 -0
- package/dist/auth/background-flow.js +122 -0
- package/dist/auth/down-notification.js +114 -0
- package/dist/auth/iframe-flow.js +150 -0
- package/dist/auth/landing-entry.js +5 -0
- package/dist/auth/landing.js +87 -0
- package/dist/auth/request-builder.js +75 -0
- package/dist/auth/response-parser.js +117 -0
- package/dist/auth/storage.js +280 -0
- package/dist/auth/token-validator.js +176 -0
- package/dist/auth/window-flow.js +133 -0
- package/dist/auth-dialog/auth-dialog.js +134 -0
- package/dist/auth-dialog-service/auth-dialog-service.js +68 -0
- package/dist/auth-ng/auth-ng.js +203 -0
- package/dist/auth-ng/auth-ng.mock.js +33 -0
- package/dist/autofocus-ng/autofocus-ng.js +50 -0
- package/dist/avatar/avatar-example-datauri.js +26 -0
- package/dist/avatar/avatar.js +161 -0
- package/dist/avatar/fallback-avatar.js +141 -0
- package/dist/avatar-editor-ng/avatar-editor-ng.js +164 -0
- package/dist/avatar-editor-ng/avatar-editor-ng__template.js +30 -0
- package/dist/avatar-ng/avatar-ng.js +18 -0
- package/dist/badge/badge.js +50 -0
- package/dist/badge-ng/badge-ng.js +16 -0
- package/dist/breadcrumb-ng/breadcrumb-ng.js +61 -0
- package/dist/button/button.js +123 -0
- package/dist/button/button__classes.js +5 -0
- package/dist/button-group/button-group.js +30 -0
- package/dist/button-group/caption.js +24 -0
- package/dist/button-group-ng/button-group-ng.js +38 -0
- package/dist/button-ng/button-ng.js +223 -0
- package/dist/button-set/button-set.js +26 -0
- package/dist/button-set-ng/button-set-ng.js +19 -0
- package/dist/button-toolbar/button-toolbar.js +29 -0
- package/dist/button-toolbar-ng/button-toolbar-ng.js +23 -0
- package/dist/caret/caret.js +264 -0
- package/dist/checkbox/checkbox.js +108 -0
- package/dist/checkbox-ng/checkbox-ng.js +55 -0
- package/dist/code/code.js +136 -0
- package/dist/compiler-ng/compiler-ng.js +53 -0
- package/dist/confirm/confirm.js +125 -0
- package/dist/confirm-ng/confirm-ng.js +66 -0
- package/dist/confirm-service/confirm-service.js +114 -0
- package/dist/content-layout/content-layout.js +65 -0
- package/dist/content-layout/sidebar.js +6 -0
- package/dist/contenteditable/contenteditable.js +78 -0
- package/dist/data-list/data-list.js +206 -0
- package/dist/data-list/data-list.mock.js +190 -0
- package/dist/data-list/item.js +227 -0
- package/dist/data-list/selection.js +101 -0
- package/dist/data-list/title.js +18 -0
- package/dist/data-list-ng/data-list-ng.js +59 -0
- package/dist/date-picker/consts.js +69 -0
- package/dist/date-picker/date-input.js +173 -0
- package/dist/date-picker/date-picker.js +365 -0
- package/dist/date-picker/date-popup.js +482 -0
- package/dist/date-picker/day.js +119 -0
- package/dist/date-picker/formats.js +3 -0
- package/dist/date-picker/month-names.js +99 -0
- package/dist/date-picker/month-slider.js +83 -0
- package/dist/date-picker/month.js +54 -0
- package/dist/date-picker/months.js +121 -0
- package/dist/date-picker/weekdays.js +32 -0
- package/dist/date-picker/years.js +109 -0
- package/dist/dialog/dialog.js +200 -0
- package/dist/dialog/dialog__body-scroll-preventer.js +2 -0
- package/dist/dialog-ng/dialog-ng.js +601 -0
- package/dist/dialog-ng/dialog-ng__template.js +71 -0
- package/dist/docked-panel-ng/docked-panel-ng.js +170 -0
- package/dist/dropdown/anchor.js +17 -0
- package/dist/dropdown/dropdown.js +234 -0
- package/dist/dropdown-menu/dropdown-menu.js +175 -0
- package/dist/error-bubble/error-bubble.js +57 -0
- package/dist/error-message/error-message.js +55 -0
- package/dist/error-message-ng/error-message-ng.js +53 -0
- package/dist/footer/footer.js +11 -0
- package/dist/footer-ng/footer-ng.js +75 -0
- package/dist/form-ng/form-ng.js +169 -0
- package/dist/global/angular-component-factory.js +82 -0
- package/dist/global/compose.js +9 -0
- package/dist/global/composeRefs.js +15 -0
- package/dist/global/conic-gradient.js +35 -0
- package/dist/global/create-stateful-context.js +54 -0
- package/dist/global/data-tests.js +22 -0
- package/dist/global/dom.js +124 -0
- package/dist/global/focus-sensor-hoc.js +145 -0
- package/dist/global/fuzzy-highlight.js +67 -0
- package/dist/global/get-event-key.js +111 -0
- package/dist/global/get-uid.js +15 -0
- package/dist/global/inject-styles.js +17 -0
- package/dist/global/linear-function.js +17 -0
- package/dist/global/listeners.js +42 -0
- package/dist/global/memoize.js +18 -0
- package/dist/global/normalize-indent.js +28 -0
- package/dist/global/promise-with-timeout.js +13 -0
- package/dist/global/radial-gradient-mask.js +49 -0
- package/dist/global/react-dom-renderer.js +45 -0
- package/dist/global/rerender-hoc.js +51 -0
- package/dist/global/ring-angular-component.js +24 -0
- package/dist/global/schedule-raf.js +31 -0
- package/dist/global/sniffer.js +6 -0
- package/dist/global/supports-css.js +20 -0
- package/dist/global/theme.js +54 -0
- package/dist/global/trivial-template-tag.js +15 -0
- package/dist/global/url.js +163 -0
- package/dist/global/variables_dark.js +57 -0
- package/dist/grid/col.js +60 -0
- package/dist/grid/grid.js +33 -0
- package/dist/grid/row.js +64 -0
- package/dist/group/group.js +31 -0
- package/dist/group-ng/group-ng.js +11 -0
- package/dist/header/header.js +147 -0
- package/dist/header/logo.js +38 -0
- package/dist/header/profile.js +217 -0
- package/dist/header/services-link.js +11 -0
- package/dist/header/services.js +136 -0
- package/dist/header/smart-profile.js +230 -0
- package/dist/header/smart-services.js +160 -0
- package/dist/header/tray-icon.js +45 -0
- package/dist/header/tray.js +31 -0
- package/dist/heading/heading.js +73 -0
- package/dist/http/http.js +216 -0
- package/dist/http/http.mock.js +65 -0
- package/dist/hub-source/hub-source.js +130 -0
- package/dist/hub-source/hub-source__user.js +28 -0
- package/dist/hub-source/hub-source__users-groups.js +62 -0
- package/dist/icon/icon.js +105 -0
- package/dist/icon/icon__constants.js +33 -0
- package/dist/icon/icon__svg.js +81 -0
- package/dist/icon/index.js +10 -0
- package/dist/icon-ng/icon-ng.js +89 -0
- package/dist/input/input.js +228 -0
- package/dist/input-ng/input-ng.js +166 -0
- package/dist/island/adaptive-island-hoc.js +47 -0
- package/dist/island/content.js +156 -0
- package/dist/island/header.js +83 -0
- package/dist/island/island.js +50 -0
- package/dist/island-legacy/content-legacy.js +26 -0
- package/dist/island-legacy/header-legacy.js +28 -0
- package/dist/island-legacy/island-legacy.js +28 -0
- package/dist/island-ng/island-content-ng.js +56 -0
- package/dist/island-ng/island-header-ng.js +32 -0
- package/dist/island-ng/island-ng-class-fixer.js +9 -0
- package/dist/island-ng/island-ng.js +31 -0
- package/dist/link/clickableLink.js +63 -0
- package/dist/link/link.js +114 -0
- package/dist/link-ng/link-ng.js +25 -0
- package/dist/list/consts.js +26 -0
- package/dist/list/list.js +812 -0
- package/dist/list/list__custom.js +85 -0
- package/dist/list/list__hint.js +26 -0
- package/dist/list/list__item.js +204 -0
- package/dist/list/list__link.js +64 -0
- package/dist/list/list__separator.js +30 -0
- package/dist/list/list__title.js +39 -0
- package/dist/list/list__users-groups-source.js +128 -0
- package/dist/loader/loader.js +70 -0
- package/dist/loader/loader__core.js +272 -0
- package/dist/loader-inline/inject-styles.js +11 -0
- package/dist/loader-inline/loader-inline.js +56 -0
- package/dist/loader-inline-ng/loader-inline-ng.js +42 -0
- package/dist/loader-ng/loader-ng.js +43 -0
- package/dist/loader-screen/loader-screen.js +43 -0
- package/dist/loader-screen-ng/loader-screen-ng.js +99 -0
- package/dist/login-dialog/login-dialog.js +186 -0
- package/dist/login-dialog/service.js +69 -0
- package/dist/markdown/code.js +30 -0
- package/dist/markdown/heading.js +23 -0
- package/dist/markdown/link.js +30 -0
- package/dist/markdown/markdown.js +73 -0
- package/dist/message/message.js +233 -0
- package/dist/message-bundle-ng/message-bundle-ng.js +111 -0
- package/dist/old-browsers-message/old-browsers-message.js +100 -0
- package/dist/old-browsers-message/old-browsers-message__stop.js +4 -0
- package/dist/old-browsers-message/white-list.js +33 -0
- package/dist/pager/pager.js +361 -0
- package/dist/pager-ng/pager-ng.js +96 -0
- package/dist/panel/panel.js +31 -0
- package/dist/panel-ng/panel-ng.js +16 -0
- package/dist/permissions/permissions.js +200 -0
- package/dist/permissions/permissions__cache.js +272 -0
- package/dist/permissions-ng/permissions-ng.js +274 -0
- package/dist/place-under-ng/place-under-ng.js +157 -0
- package/dist/popup/popup.consts.js +41 -0
- package/dist/popup/popup.js +389 -0
- package/dist/popup/popup.target.js +26 -0
- package/dist/popup/position.js +279 -0
- package/dist/popup-menu/popup-menu.js +115 -0
- package/dist/progress-bar/progress-bar.js +113 -0
- package/dist/progress-bar-ng/progress-bar-ng.js +15 -0
- package/dist/promised-click-ng/promised-click-ng.js +126 -0
- package/dist/proxy-attrs/proxy-attrs.js +19 -0
- package/dist/query-assist/query-assist.js +1092 -0
- package/dist/query-assist/query-assist__suggestions.js +47 -0
- package/dist/query-assist-ng/query-assist-ng.js +82 -0
- package/dist/radio/radio.js +41 -0
- package/dist/radio/radio__item.js +77 -0
- package/dist/radio-ng/radio-ng.js +63 -0
- package/dist/save-field-ng/save-field-ng.js +335 -0
- package/dist/save-field-ng/save-field-ng__template.js +34 -0
- package/dist/select/select.js +1336 -0
- package/dist/select/select__filter.js +54 -0
- package/dist/select/select__popup.js +546 -0
- package/dist/select-ng/select-ng.js +621 -0
- package/dist/select-ng/select-ng__lazy.js +150 -0
- package/dist/select-ng/select-ng__options.js +145 -0
- package/dist/shortcuts/core.js +245 -0
- package/dist/shortcuts/shortcut-title.js +51 -0
- package/dist/shortcuts/shortcuts-hoc.js +41 -0
- package/dist/shortcuts/shortcuts.js +72 -0
- package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +120 -0
- package/dist/shortcuts-hint-ng/shortcuts-hint-ng__template.js +50 -0
- package/dist/shortcuts-ng/shortcuts-ng.js +261 -0
- package/dist/sidebar-ng/sidebar-ng.js +111 -0
- package/dist/sidebar-ng/sidebar-ng__button-template.js +20 -0
- package/dist/sidebar-ng/sidebar-ng__template.js +12 -0
- package/dist/storage/storage.js +56 -0
- package/dist/storage/storage__fallback.js +214 -0
- package/dist/storage/storage__local.js +151 -0
- package/dist/style.css +1 -0
- package/dist/tab-trap/tab-trap.js +176 -0
- package/dist/table/cell.js +25 -0
- package/dist/table/disable-hover-hoc.js +53 -0
- package/dist/table/header-cell.js +90 -0
- package/dist/table/header.js +191 -0
- package/dist/table/multitable.js +140 -0
- package/dist/table/row-with-focus-sensor.js +81 -0
- package/dist/table/row.js +271 -0
- package/dist/table/selection-adapter.js +14 -0
- package/dist/table/selection-shortcuts-hoc.js +214 -0
- package/dist/table/selection.js +221 -0
- package/dist/table/smart-table.js +119 -0
- package/dist/table/table.js +404 -0
- package/dist/table-legacy-ng/table-legacy-ng.js +501 -0
- package/dist/table-legacy-ng/table-legacy-ng__pager.js +122 -0
- package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +123 -0
- package/dist/table-legacy-ng/table-legacy-ng__selection.js +179 -0
- package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +56 -0
- package/dist/table-ng/smart-table-ng.js +65 -0
- package/dist/table-ng/table-ng.js +64 -0
- package/dist/tabs/collapsible-more.js +196 -0
- package/dist/tabs/collapsible-tab.js +90 -0
- package/dist/tabs/collapsible-tabs.js +360 -0
- package/dist/tabs/custom-item.js +13 -0
- package/dist/tabs/dumb-tabs.js +161 -0
- package/dist/tabs/smart-tabs.js +104 -0
- package/dist/tabs/tab-link.js +41 -0
- package/dist/tabs/tab.js +32 -0
- package/dist/tabs/tabs.js +69 -0
- package/dist/tabs-ng/tabs-ng.js +193 -0
- package/dist/tabs-ng/tabs-ng__template.js +40 -0
- package/dist/tag/tag.js +196 -0
- package/dist/tags-input/tags-input.js +478 -0
- package/dist/tags-input-ng/tags-input-ng.js +89 -0
- package/dist/tags-list/tags-list.js +93 -0
- package/dist/template-ng/template-ng.js +70 -0
- package/dist/text/text.js +36 -0
- package/dist/theme-ng/theme-ng.js +44 -0
- package/dist/title-ng/title-ng.js +114 -0
- package/dist/toggle/toggle.js +77 -0
- package/dist/toggle-ng/toggle-ng.js +16 -0
- package/dist/tooltip/tooltip.js +207 -0
- package/dist/tooltip-ng/tooltip-ng.js +98 -0
- package/dist/user-agreement/service.js +409 -0
- package/dist/user-agreement/toolbox.eula.js +162 -0
- package/dist/user-agreement/user-agreement.js +167 -0
- package/dist/user-card/card.js +17 -0
- package/dist/user-card/smart-user-card-tooltip.js +112 -0
- package/dist/user-card/tooltip.js +93 -0
- package/dist/user-card/user-card.js +49 -0
- package/dist/user-card-ng/user-card-ng.js +59 -0
- package/package.json +2 -2
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { PureComponent } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import closeIcon from '@jetbrains/icons/close';
|
|
6
|
+
import { withTheme } from '../global/theme.js';
|
|
7
|
+
export { default as Theme } from '../global/theme.js';
|
|
8
|
+
import Button from '../button/button.js';
|
|
9
|
+
import getUID from '../global/get-uid.js';
|
|
10
|
+
import Icon from '../icon/icon.js';
|
|
11
|
+
import { m as modules_88cfaf40 } from '../_helpers/input.js';
|
|
12
|
+
import 'focus-visible';
|
|
13
|
+
import '@jetbrains/icons/chevron-10px';
|
|
14
|
+
import '../link/clickableLink.js';
|
|
15
|
+
import '../_helpers/button__classes.js';
|
|
16
|
+
import '../icon/icon__constants.js';
|
|
17
|
+
import 'util-deprecate';
|
|
18
|
+
import '../_helpers/icon.js';
|
|
19
|
+
import '../icon/icon__svg.js';
|
|
20
|
+
import '../global/memoize.js';
|
|
21
|
+
|
|
22
|
+
function noop() {}
|
|
23
|
+
/**
|
|
24
|
+
* @name Input
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const Size = {
|
|
29
|
+
AUTO: 'Auto',
|
|
30
|
+
S: 'S',
|
|
31
|
+
M: 'M',
|
|
32
|
+
L: 'L',
|
|
33
|
+
FULL: 'FULL'
|
|
34
|
+
};
|
|
35
|
+
class Input extends PureComponent {
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "state", {
|
|
40
|
+
empty: true
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "id", getUID('ring-input-'));
|
|
44
|
+
|
|
45
|
+
_defineProperty(this, "underlineRef", el => {
|
|
46
|
+
this.underlineNode = el;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "inputRef", el => {
|
|
50
|
+
const {
|
|
51
|
+
inputRef
|
|
52
|
+
} = this.props;
|
|
53
|
+
this.input = el;
|
|
54
|
+
|
|
55
|
+
if (typeof inputRef === 'function') {
|
|
56
|
+
inputRef(el);
|
|
57
|
+
} else {
|
|
58
|
+
inputRef.current = el;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
_defineProperty(this, "clear", e => {
|
|
63
|
+
this.props.onClear && this.props.onClear(e);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
_defineProperty(this, "handleChange", e => {
|
|
67
|
+
this.props.onChange(e);
|
|
68
|
+
this.checkValue(e.target);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
componentDidMount() {
|
|
73
|
+
this.adapt();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
componentDidUpdate() {
|
|
77
|
+
this.adapt();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getId() {
|
|
81
|
+
return this.props.id || this.id;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
checkValue() {
|
|
85
|
+
this.setState({
|
|
86
|
+
empty: !this.input.value
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
if (this.props.multiline && this.input.scrollHeight > this.input.clientHeight) {
|
|
90
|
+
this.stretch(this.input);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
stretch(el) {
|
|
95
|
+
if (!el || !el.style) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
adapt() {
|
|
103
|
+
this.checkValue();
|
|
104
|
+
this.stretch(this.underlineNode);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
render() {
|
|
108
|
+
const {
|
|
109
|
+
// Modifiers
|
|
110
|
+
theme,
|
|
111
|
+
size,
|
|
112
|
+
active,
|
|
113
|
+
multiline,
|
|
114
|
+
borderless,
|
|
115
|
+
compact,
|
|
116
|
+
// Props
|
|
117
|
+
label,
|
|
118
|
+
error,
|
|
119
|
+
className,
|
|
120
|
+
inputClassName,
|
|
121
|
+
children,
|
|
122
|
+
value,
|
|
123
|
+
onClear,
|
|
124
|
+
disabled,
|
|
125
|
+
inputRef,
|
|
126
|
+
onChange,
|
|
127
|
+
enableShortcuts,
|
|
128
|
+
id,
|
|
129
|
+
placeholder,
|
|
130
|
+
icon,
|
|
131
|
+
renderUnderline,
|
|
132
|
+
...restProps
|
|
133
|
+
} = this.props;
|
|
134
|
+
const minimizeMargins = compact || borderless;
|
|
135
|
+
const {
|
|
136
|
+
empty
|
|
137
|
+
} = this.state;
|
|
138
|
+
const clearable = !!onClear;
|
|
139
|
+
const classes = classNames(modules_88cfaf40.container, className, modules_88cfaf40[theme], [modules_88cfaf40[`size${size}`]], {
|
|
140
|
+
'ring-js-shortcuts': enableShortcuts === true,
|
|
141
|
+
[modules_88cfaf40.active]: active,
|
|
142
|
+
[modules_88cfaf40.error]: error != null,
|
|
143
|
+
[modules_88cfaf40.empty]: empty,
|
|
144
|
+
[modules_88cfaf40.noLabel]: !this.props.label,
|
|
145
|
+
[modules_88cfaf40.withIcon]: icon != null,
|
|
146
|
+
[modules_88cfaf40.clearable]: clearable,
|
|
147
|
+
[modules_88cfaf40.compact]: minimizeMargins
|
|
148
|
+
});
|
|
149
|
+
const inputClasses = classNames(modules_88cfaf40.input, inputClassName);
|
|
150
|
+
const TagName = multiline ? 'textarea' : 'input';
|
|
151
|
+
const text = value != null ? value : children;
|
|
152
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
153
|
+
className: classes,
|
|
154
|
+
"data-test": "ring-input"
|
|
155
|
+
}, icon && /*#__PURE__*/React.createElement(Icon, {
|
|
156
|
+
glyph: icon,
|
|
157
|
+
className: modules_88cfaf40.icon
|
|
158
|
+
}), /*#__PURE__*/React.createElement(TagName, _extends({
|
|
159
|
+
ref: this.inputRef,
|
|
160
|
+
onChange: this.handleChange,
|
|
161
|
+
className: inputClasses,
|
|
162
|
+
value: text,
|
|
163
|
+
rows: multiline ? 1 : null,
|
|
164
|
+
disabled: disabled,
|
|
165
|
+
id: this.getId(),
|
|
166
|
+
placeholder: placeholder,
|
|
167
|
+
"aria-label": typeof label === 'string' && label ? label : placeholder,
|
|
168
|
+
"data-enabled-shortcuts": Array.isArray(enableShortcuts) ? enableShortcuts.join(',') : null
|
|
169
|
+
}, restProps)), clearable && !disabled && /*#__PURE__*/React.createElement(Button, {
|
|
170
|
+
title: "Clear input",
|
|
171
|
+
"data-test": "ring-input-clear",
|
|
172
|
+
className: modules_88cfaf40.clear,
|
|
173
|
+
icon: closeIcon,
|
|
174
|
+
onClick: this.clear
|
|
175
|
+
}), !minimizeMargins && /*#__PURE__*/React.createElement("label", {
|
|
176
|
+
htmlFor: this.getId(),
|
|
177
|
+
className: modules_88cfaf40.label
|
|
178
|
+
}, label), !borderless && /*#__PURE__*/React.createElement("div", {
|
|
179
|
+
className: modules_88cfaf40.underline
|
|
180
|
+
}), !borderless && /*#__PURE__*/React.createElement("div", {
|
|
181
|
+
className: modules_88cfaf40.focusUnderline
|
|
182
|
+
}), !minimizeMargins && /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
className: modules_88cfaf40.errorUnderline
|
|
184
|
+
}), !minimizeMargins && renderUnderline(this.underlineRef, error));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
_defineProperty(Input, "propTypes", {
|
|
190
|
+
value: PropTypes.string,
|
|
191
|
+
theme: PropTypes.string,
|
|
192
|
+
className: PropTypes.string,
|
|
193
|
+
inputClassName: PropTypes.string,
|
|
194
|
+
size: PropTypes.string,
|
|
195
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
196
|
+
active: PropTypes.bool,
|
|
197
|
+
error: PropTypes.string,
|
|
198
|
+
multiline: PropTypes.bool,
|
|
199
|
+
borderless: PropTypes.bool,
|
|
200
|
+
compact: PropTypes.bool,
|
|
201
|
+
onChange: PropTypes.func,
|
|
202
|
+
onClear: PropTypes.func,
|
|
203
|
+
inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
204
|
+
current: PropTypes.instanceOf(HTMLInputElement)
|
|
205
|
+
})]),
|
|
206
|
+
children: PropTypes.string,
|
|
207
|
+
enableShortcuts: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.string)]),
|
|
208
|
+
disabled: PropTypes.bool,
|
|
209
|
+
id: PropTypes.string,
|
|
210
|
+
placeholder: PropTypes.string,
|
|
211
|
+
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
|
|
212
|
+
renderUnderline: PropTypes.func
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
_defineProperty(Input, "defaultProps", {
|
|
216
|
+
size: Size.M,
|
|
217
|
+
onChange: noop,
|
|
218
|
+
inputRef: noop,
|
|
219
|
+
enableShortcuts: ['esc'],
|
|
220
|
+
renderUnderline: (underlineRef, errorText) => /*#__PURE__*/React.createElement("div", {
|
|
221
|
+
className: modules_88cfaf40.errorText,
|
|
222
|
+
ref: underlineRef
|
|
223
|
+
}, errorText)
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
var Input$1 = withTheme()(Input);
|
|
227
|
+
|
|
228
|
+
export { Input, Size, Input$1 as default };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import angular from 'angular';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import closeIcon from '@jetbrains/icons/close';
|
|
5
|
+
import RingAngularComponent from '../global/ring-angular-component.js';
|
|
6
|
+
import { m as modules_88cfaf40 } from '../_helpers/input.js';
|
|
7
|
+
import Theme from '../global/theme.js';
|
|
8
|
+
import ButtonNG from '../button-ng/button-ng.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '../global/dom.js';
|
|
11
|
+
import '../icon-ng/icon-ng.js';
|
|
12
|
+
import '../icon/icon__constants.js';
|
|
13
|
+
import '../template-ng/template-ng.js';
|
|
14
|
+
import '../_helpers/icon.js';
|
|
15
|
+
import '../_helpers/button__classes.js';
|
|
16
|
+
|
|
17
|
+
var modules_c40fa551 = {"errorText":"errorText_rui_e22b","clear":"clear_rui_e22b"};
|
|
18
|
+
|
|
19
|
+
const angularModule = angular.module('Ring.input', [ButtonNG]);
|
|
20
|
+
|
|
21
|
+
class RingInputComponent extends RingAngularComponent {
|
|
22
|
+
$onInit() {
|
|
23
|
+
this.closeIcon = closeIcon;
|
|
24
|
+
|
|
25
|
+
if (!this.ngModelCtrl) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
this.ngModelCtrl.$render = () => {
|
|
30
|
+
this.value = this.ngModelCtrl.$viewValue;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onInputChange() {
|
|
35
|
+
if (!this.ngModelCtrl) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.ngModelCtrl.$setViewValue(this.value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
stretch(el) {
|
|
43
|
+
if (!el) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
onKeyUp() {
|
|
51
|
+
if (!this.inputNode) {
|
|
52
|
+
this.inputNode = this.$inject.$element[0].querySelector('[data-test="ring-input"]');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (this.multiline && this.inputNode.scrollHeight > this.inputNode.clientHeight) {
|
|
56
|
+
this.stretch(this.inputNode);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onClear() {
|
|
61
|
+
this.value = '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getContainerClasses() {
|
|
65
|
+
return classNames(modules_88cfaf40.container, modules_88cfaf40[this.theme || Theme.LIGHT], this.size ? [modules_88cfaf40[`size${this.size}`]] : null, {
|
|
66
|
+
[modules_88cfaf40.active]: this.active,
|
|
67
|
+
[modules_88cfaf40.error]: this.error != null,
|
|
68
|
+
[modules_88cfaf40.empty]: !this.value,
|
|
69
|
+
[modules_88cfaf40.noLabel]: !this.label,
|
|
70
|
+
[modules_88cfaf40.clearable]: this.clearable,
|
|
71
|
+
[modules_88cfaf40.borderless]: this.borderless
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_defineProperty(RingInputComponent, "$inject", ['$element']);
|
|
78
|
+
|
|
79
|
+
_defineProperty(RingInputComponent, "require", {
|
|
80
|
+
ngModelCtrl: '?ngModel'
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
_defineProperty(RingInputComponent, "bindings", {
|
|
84
|
+
name: '@',
|
|
85
|
+
required: '@',
|
|
86
|
+
ngMinlength: '@',
|
|
87
|
+
ngMaxlength: '@',
|
|
88
|
+
placeholder: '@',
|
|
89
|
+
ngModel: '<',
|
|
90
|
+
onChange: '&',
|
|
91
|
+
label: '@',
|
|
92
|
+
hint: '@',
|
|
93
|
+
size: '@',
|
|
94
|
+
theme: '@',
|
|
95
|
+
disabled: '@',
|
|
96
|
+
active: '<',
|
|
97
|
+
error: '@',
|
|
98
|
+
empty: '<',
|
|
99
|
+
clearable: '<',
|
|
100
|
+
borderless: '<',
|
|
101
|
+
multiline: '<'
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_defineProperty(RingInputComponent, "template", `
|
|
105
|
+
<div
|
|
106
|
+
data-test="ring-input-container"
|
|
107
|
+
ng-class="$ctrl.getContainerClasses()"
|
|
108
|
+
>
|
|
109
|
+
<input
|
|
110
|
+
aria-label="{{$ctrl.label || $ctrl.placeholder}}"
|
|
111
|
+
type="text"
|
|
112
|
+
data-test="ring-input"
|
|
113
|
+
class="${modules_88cfaf40.input}"
|
|
114
|
+
name="{{$ctrl.name}}"
|
|
115
|
+
ng-if="!$ctrl.multiline"
|
|
116
|
+
placeholder="{{$ctrl.placeholder}}"
|
|
117
|
+
ng-model="$ctrl.value"
|
|
118
|
+
ng-required="$ctrl.required"
|
|
119
|
+
ng-disabled="$ctrl.disabled"
|
|
120
|
+
ng-minlength="$ctrl.ngMinlength"
|
|
121
|
+
ng-maxlength="$ctrl.ngMaxlength"
|
|
122
|
+
ng-change="$ctrl.onInputChange()"
|
|
123
|
+
ng-keyup="$ctrl.onKeyUp()"
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
<textarea
|
|
127
|
+
aria-label="{{$ctrl.label || $ctrl.placeholder}}"
|
|
128
|
+
data-test="ring-input"
|
|
129
|
+
ng-if="$ctrl.multiline"
|
|
130
|
+
class="${modules_88cfaf40.input}"
|
|
131
|
+
rows="1"
|
|
132
|
+
name="{{$ctrl.name}}"
|
|
133
|
+
placeholder="{{$ctrl.placeholder}}"
|
|
134
|
+
ng-model="$ctrl.value"
|
|
135
|
+
ng-required="$ctrl.required"
|
|
136
|
+
ng-disabled="$ctrl.disabled"
|
|
137
|
+
ng-minlength="$ctrl.ngMinlength"
|
|
138
|
+
ng-maxlength="$ctrl.ngMaxlength"
|
|
139
|
+
ng-change="$ctrl.onInputChange()"
|
|
140
|
+
ng-keyup="$ctrl.onKeyUp()"
|
|
141
|
+
></textarea>
|
|
142
|
+
|
|
143
|
+
<rg-button
|
|
144
|
+
ng-if="$ctrl.clearable"
|
|
145
|
+
data-test="ring-input-clear"
|
|
146
|
+
class="${modules_88cfaf40.clear} ${modules_c40fa551.clear}"
|
|
147
|
+
icon="{{:: $ctrl.closeIcon}}"
|
|
148
|
+
ng-click="$ctrl.onClear()"
|
|
149
|
+
></rg-button>
|
|
150
|
+
|
|
151
|
+
<label
|
|
152
|
+
ng-if="!$ctrl.borderless"
|
|
153
|
+
class="${modules_88cfaf40.label}"
|
|
154
|
+
>{{$ctrl.label}}</label>
|
|
155
|
+
|
|
156
|
+
<div ng-if="!$ctrl.borderless" class="${modules_88cfaf40.underline}"></div>
|
|
157
|
+
<div ng-if="!$ctrl.borderless" class="${modules_88cfaf40.focusUnderline}"></div>
|
|
158
|
+
<div ng-if="!$ctrl.borderless" class="${modules_88cfaf40.errorUnderline}"></div>
|
|
159
|
+
<div ng-if="!$ctrl.borderless && $ctrl.error" class="${modules_88cfaf40.errorText} ${modules_c40fa551.errorText}">{{$ctrl.error}}</div>
|
|
160
|
+
</div>
|
|
161
|
+
`);
|
|
162
|
+
|
|
163
|
+
angularModule.component('rgInput', RingInputComponent);
|
|
164
|
+
var InputNg = angularModule.name;
|
|
165
|
+
|
|
166
|
+
export { InputNg as default };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { createContext, Component } from 'react';
|
|
3
|
+
import { interpolateLinear } from '../global/linear-function.js';
|
|
4
|
+
|
|
5
|
+
const TITLE_RESIZE_END = 20;
|
|
6
|
+
const TITLE_RESIZE_THRESHOLD = 36;
|
|
7
|
+
const PhaseContext = /*#__PURE__*/createContext();
|
|
8
|
+
const ScrollHandlerContext = /*#__PURE__*/createContext();
|
|
9
|
+
function adaptiveIslandHOC(ComposedComponent) {
|
|
10
|
+
var _class, _temp;
|
|
11
|
+
|
|
12
|
+
return _temp = _class = class AdaptiveIsland extends Component {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
|
|
16
|
+
_defineProperty(this, "state", {
|
|
17
|
+
phase: 0
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
_defineProperty(this, "onContentScroll", _ref => {
|
|
21
|
+
let {
|
|
22
|
+
scrollTop,
|
|
23
|
+
scrollHeight,
|
|
24
|
+
clientHeight
|
|
25
|
+
} = _ref;
|
|
26
|
+
|
|
27
|
+
if (scrollHeight - clientHeight >= interpolateLinear(TITLE_RESIZE_THRESHOLD, TITLE_RESIZE_END, this.state.phase)) {
|
|
28
|
+
const phase = Math.min(1, scrollTop / TITLE_RESIZE_END);
|
|
29
|
+
this.setState({
|
|
30
|
+
phase
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
render() {
|
|
37
|
+
return /*#__PURE__*/React.createElement(PhaseContext.Provider, {
|
|
38
|
+
value: this.state.phase
|
|
39
|
+
}, /*#__PURE__*/React.createElement(ScrollHandlerContext.Provider, {
|
|
40
|
+
value: this.onContentScroll
|
|
41
|
+
}, /*#__PURE__*/React.createElement(ComposedComponent, this.props)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}, _defineProperty(_class, "propTypes", ComposedComponent.propTypes), _temp;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { PhaseContext, ScrollHandlerContext, adaptiveIslandHOC as default };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import createResizeDetector from 'element-resize-detector';
|
|
6
|
+
import scheduleRAF from '../global/schedule-raf.js';
|
|
7
|
+
import { m as modules_e6a056e1 } from '../_helpers/island.js';
|
|
8
|
+
import { ScrollHandlerContext } from './adaptive-island-hoc.js';
|
|
9
|
+
import '../global/linear-function.js';
|
|
10
|
+
|
|
11
|
+
const scheduleScrollAction = scheduleRAF();
|
|
12
|
+
|
|
13
|
+
const noop = () => {};
|
|
14
|
+
|
|
15
|
+
const END_DISTANCE = 16;
|
|
16
|
+
|
|
17
|
+
class Content extends Component {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "state", {
|
|
22
|
+
scrolledToTop: true,
|
|
23
|
+
scrolledToBottom: false
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, "resizeDetector", createResizeDetector({
|
|
27
|
+
strategy: 'scroll'
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "setWrapper", node => {
|
|
31
|
+
if (!node) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.wrapperNode = node;
|
|
36
|
+
this.resizeDetector.listenTo(node, this.calculateScrollPosition);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "calculateScrollPosition", () => scheduleScrollAction(() => {
|
|
40
|
+
const {
|
|
41
|
+
scrollableNode
|
|
42
|
+
} = this;
|
|
43
|
+
|
|
44
|
+
if (!scrollableNode) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
scrollTop,
|
|
50
|
+
scrollHeight,
|
|
51
|
+
offsetHeight
|
|
52
|
+
} = scrollableNode;
|
|
53
|
+
const scrolledToTop = scrollTop === 0;
|
|
54
|
+
const scrolledToBottom = offsetHeight + scrollTop >= scrollHeight - END_DISTANCE;
|
|
55
|
+
|
|
56
|
+
if (scrolledToBottom) {
|
|
57
|
+
this.props.onScrollToBottom();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.setState({
|
|
61
|
+
scrolledToTop,
|
|
62
|
+
scrolledToBottom
|
|
63
|
+
});
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
_defineProperty(this, "onScroll", () => {
|
|
67
|
+
this.props.onScroll(this.scrollableNode);
|
|
68
|
+
this.calculateScrollPosition();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
_defineProperty(this, "setScrollableNodeAndCalculatePosition", node => {
|
|
72
|
+
if (!node) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.scrollableNode = node;
|
|
77
|
+
this.calculateScrollPosition();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
componentWillUnmount() {
|
|
82
|
+
this.scrollableNode = null;
|
|
83
|
+
|
|
84
|
+
if (!this.wrapperNode) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.resizeDetector.removeAllListeners(this.wrapperNode);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const {
|
|
93
|
+
children,
|
|
94
|
+
className,
|
|
95
|
+
bottomBorder,
|
|
96
|
+
scrollableWrapperClassName,
|
|
97
|
+
onScroll,
|
|
98
|
+
onScrollToBottom,
|
|
99
|
+
fade,
|
|
100
|
+
...restProps
|
|
101
|
+
} = this.props;
|
|
102
|
+
const {
|
|
103
|
+
scrolledToTop,
|
|
104
|
+
scrolledToBottom
|
|
105
|
+
} = this.state;
|
|
106
|
+
const classes = classNames(modules_e6a056e1.content, className, {
|
|
107
|
+
[modules_e6a056e1.contentWithTopFade]: fade && !scrolledToTop,
|
|
108
|
+
[modules_e6a056e1.contentWithBottomFade]: fade && !scrolledToBottom,
|
|
109
|
+
[modules_e6a056e1.withTransparentBottomBorder]: bottomBorder,
|
|
110
|
+
[modules_e6a056e1.withBottomBorder]: bottomBorder && !scrolledToBottom
|
|
111
|
+
});
|
|
112
|
+
const scrollableWrapperClasses = classNames(modules_e6a056e1.scrollableWrapper, scrollableWrapperClassName);
|
|
113
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, restProps, {
|
|
114
|
+
"data-test": "ring-island-content",
|
|
115
|
+
className: classes
|
|
116
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
// it has to be focusable because it can be scrollable
|
|
118
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
119
|
+
tabIndex: 0,
|
|
120
|
+
"data-scrollable-container": true,
|
|
121
|
+
className: scrollableWrapperClasses,
|
|
122
|
+
ref: this.setScrollableNodeAndCalculatePosition,
|
|
123
|
+
onScroll: fade ? this.onScroll : noop
|
|
124
|
+
}, fade && /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
ref: this.setWrapper
|
|
126
|
+
}, children), !fade && children));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
_defineProperty(Content, "propTypes", {
|
|
132
|
+
children: PropTypes.node,
|
|
133
|
+
className: PropTypes.string,
|
|
134
|
+
scrollableWrapperClassName: PropTypes.string,
|
|
135
|
+
fade: PropTypes.bool,
|
|
136
|
+
bottomBorder: PropTypes.bool,
|
|
137
|
+
onScroll: PropTypes.func,
|
|
138
|
+
onScrollToBottom: PropTypes.func
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
_defineProperty(Content, "defaultProps", {
|
|
142
|
+
fade: true,
|
|
143
|
+
bottomBorder: false,
|
|
144
|
+
onScroll: noop,
|
|
145
|
+
onScrollToBottom: noop
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const ContentWrapper = props => /*#__PURE__*/React.createElement(ScrollHandlerContext.Consumer, null, onScroll => {
|
|
149
|
+
const addProps = onScroll != null ? {
|
|
150
|
+
onScroll,
|
|
151
|
+
bottomBorder: true
|
|
152
|
+
} : {};
|
|
153
|
+
return /*#__PURE__*/React.createElement(Content, _extends({}, props, addProps));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export { ContentWrapper as default };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { interpolateLinear } from '../global/linear-function.js';
|
|
6
|
+
import { m as modules_e6a056e1 } from '../_helpers/island.js';
|
|
7
|
+
import { PhaseContext } from './adaptive-island-hoc.js';
|
|
8
|
+
|
|
9
|
+
const Start = {
|
|
10
|
+
FONT_SIZE: 24,
|
|
11
|
+
LINE_HEIGHT: 28,
|
|
12
|
+
PADDING: 16
|
|
13
|
+
};
|
|
14
|
+
const End = {
|
|
15
|
+
FONT_SIZE: 13,
|
|
16
|
+
LINE_HEIGHT: 28,
|
|
17
|
+
// Compensation
|
|
18
|
+
X: 0.4,
|
|
19
|
+
Y: 0.1,
|
|
20
|
+
SPACING: 1.09
|
|
21
|
+
};
|
|
22
|
+
const BORDER_APPEAR_PHASE = 0.5;
|
|
23
|
+
|
|
24
|
+
class Header extends Component {
|
|
25
|
+
style(name) {
|
|
26
|
+
return interpolateLinear(Start[name] || 0, End[name] || 0, this.props.phase);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
const {
|
|
31
|
+
children,
|
|
32
|
+
className,
|
|
33
|
+
wrapWithTitle,
|
|
34
|
+
border,
|
|
35
|
+
phase,
|
|
36
|
+
...restProps
|
|
37
|
+
} = this.props;
|
|
38
|
+
const classes = classNames(modules_e6a056e1.header, className, {
|
|
39
|
+
[modules_e6a056e1.withBottomBorder]: border || phase >= BORDER_APPEAR_PHASE
|
|
40
|
+
});
|
|
41
|
+
const headerStyle = phase != null ? {
|
|
42
|
+
lineHeight: `${this.style('LINE_HEIGHT')}px`,
|
|
43
|
+
// need to append px because number is a valid line-height value
|
|
44
|
+
paddingTop: this.style('PADDING')
|
|
45
|
+
} : null;
|
|
46
|
+
const scaleFont = phase != null && this.style('FONT_SIZE') / Start.FONT_SIZE;
|
|
47
|
+
const titleStyle = phase != null && phase < 1 ? {
|
|
48
|
+
fontSize: Start.FONT_SIZE,
|
|
49
|
+
transform: `translate(${this.style('X')}px, ${this.style('Y')}px) scale(${scaleFont})`,
|
|
50
|
+
letterSpacing: this.style('SPACING')
|
|
51
|
+
} : null;
|
|
52
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, restProps, {
|
|
53
|
+
"data-test": "ring-island-header",
|
|
54
|
+
className: classes,
|
|
55
|
+
style: headerStyle
|
|
56
|
+
}), wrapWithTitle && /*#__PURE__*/React.createElement("h2", {
|
|
57
|
+
className: modules_e6a056e1.title,
|
|
58
|
+
style: titleStyle
|
|
59
|
+
}, children), !wrapWithTitle && children);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_defineProperty(Header, "propTypes", {
|
|
65
|
+
children: PropTypes.node,
|
|
66
|
+
className: PropTypes.string,
|
|
67
|
+
border: PropTypes.bool,
|
|
68
|
+
wrapWithTitle: PropTypes.bool,
|
|
69
|
+
phase: PropTypes.number
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
_defineProperty(Header, "defaultProps", {
|
|
73
|
+
wrapWithTitle: true
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const HeaderWrapper = props => /*#__PURE__*/React.createElement(PhaseContext.Consumer, null, phase => {
|
|
77
|
+
const addProps = phase != null ? {
|
|
78
|
+
phase
|
|
79
|
+
} : {};
|
|
80
|
+
return /*#__PURE__*/React.createElement(Header, _extends({}, props, addProps));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export { HeaderWrapper as default };
|