@jetbrains/ring-ui-built 7.0.0-beta.2 → 7.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/_helpers/_rollupPluginBabelHelpers.js +1 -504
- package/components/_helpers/anchor.js +7 -5
- package/components/_helpers/button__classes.js +15 -13
- package/components/_helpers/caption.js +11 -17
- package/components/_helpers/card.js +92 -96
- package/components/_helpers/dialog__body-scroll-preventer.js +10 -17
- package/components/_helpers/icon__svg.js +27 -23
- package/components/_helpers/input.js +150 -171
- package/components/_helpers/query-assist__suggestions.js +78 -93
- package/components/_helpers/select__filter.js +56 -67
- package/components/_helpers/services-link.js +23 -29
- package/components/_helpers/sidebar.js +91 -93
- package/components/_helpers/tab-link.js +8 -6
- package/components/_helpers/theme.js +41 -50
- package/components/_helpers/title.js +59 -69
- package/components/alert/alert.js +112 -156
- package/components/alert/container.js +32 -39
- package/components/alert-service/alert-service.js +104 -161
- package/components/analytics/analytics.js +12 -20
- package/components/analytics/analytics__custom-plugin.js +52 -68
- package/components/auth/auth.js +2 -27
- package/components/auth/auth__core.d.ts +1 -1
- package/components/auth/auth__core.js +742 -1428
- package/components/auth/background-flow.js +84 -121
- package/components/auth/down-notification.js +31 -69
- package/components/auth/iframe-flow.js +70 -123
- package/components/auth/request-builder.js +46 -77
- package/components/auth/response-parser.js +84 -112
- package/components/auth/storage.js +160 -318
- package/components/auth/token-validator.js +132 -227
- package/components/auth/window-flow.js +84 -121
- package/components/auth-dialog/auth-dialog.js +99 -150
- package/components/auth-dialog-service/auth-dialog-service.js +6 -26
- package/components/avatar/avatar-example-datauri.js +1 -1
- package/components/avatar/avatar.js +94 -123
- package/components/avatar/fallback-avatar.js +20 -34
- package/components/badge/badge.js +32 -38
- package/components/breadcrumbs/breadcrumbs.js +13 -17
- package/components/button/button.js +67 -80
- package/components/button-group/button-group.js +27 -36
- package/components/button-set/button-set.js +19 -27
- package/components/button-toolbar/button-toolbar.js +17 -25
- package/components/caret/caret.js +184 -211
- package/components/checkbox/checkbox.js +69 -86
- package/components/clipboard/clipboard-fallback.js +7 -7
- package/components/clipboard/clipboard.js +36 -128
- package/components/code/code.js +83 -151
- package/components/collapse/collapse-content.js +42 -60
- package/components/collapse/collapse-context.js +2 -2
- package/components/collapse/collapse-control.js +12 -12
- package/components/collapse/collapse.js +12 -17
- package/components/collapse/consts.js +4 -4
- package/components/collapse/utils.js +1 -3
- package/components/confirm/confirm.js +57 -87
- package/components/confirm-service/confirm-service.js +23 -44
- package/components/content-layout/content-layout.js +41 -56
- package/components/content-layout/sidebar.js +1 -1
- package/components/contenteditable/contenteditable.js +38 -46
- package/components/control-help/control-help.js +5 -3
- package/components/control-label/control-label.js +9 -8
- package/components/data-list/data-list.js +113 -156
- package/components/data-list/data-list.mock.js +3 -5
- package/components/data-list/item.js +120 -140
- package/components/data-list/selection.js +77 -135
- package/components/data-list/title.js +2 -10
- package/components/date-picker/consts.js +16 -22
- package/components/date-picker/date-input.js +99 -124
- package/components/date-picker/date-picker.js +140 -184
- package/components/date-picker/date-popup.js +280 -327
- package/components/date-picker/day.js +71 -94
- package/components/date-picker/month-names.js +41 -59
- package/components/date-picker/month-slider.js +42 -61
- package/components/date-picker/month.js +17 -24
- package/components/date-picker/months.js +44 -49
- package/components/date-picker/weekdays.js +12 -21
- package/components/date-picker/years.js +77 -98
- package/components/dialog/dialog.js +151 -187
- package/components/dialog/dialog__body-scroll-preventer.js +0 -3
- package/components/dropdown/anchor.js +0 -6
- package/components/dropdown/dropdown.js +134 -154
- package/components/dropdown-menu/dropdown-menu.js +59 -87
- package/components/editable-heading/editable-heading.js +69 -116
- package/components/error-bubble/error-bubble.js +29 -54
- package/components/error-message/error-message.js +34 -49
- package/components/footer/footer.js +27 -28
- package/components/global/compose.js +1 -8
- package/components/global/composeRefs.d.ts +0 -3
- package/components/global/composeRefs.js +8 -15
- package/components/global/controls-height.js +2 -2
- package/components/global/create-stateful-context.js +14 -13
- package/components/global/data-tests.js +7 -12
- package/components/global/dom.js +49 -82
- package/components/global/focus-sensor-hoc.js +99 -106
- package/components/global/fuzzy-highlight.js +23 -34
- package/components/global/get-event-key.js +8 -8
- package/components/global/get-uid.js +3 -7
- package/components/global/inject-styles.js +7 -14
- package/components/global/listeners.js +28 -47
- package/components/global/memoize.js +6 -10
- package/components/global/normalize-indent.js +19 -46
- package/components/global/promise-with-timeout.js +6 -8
- package/components/global/prop-types.js +3 -5
- package/components/global/react-dom-renderer.js +29 -40
- package/components/global/rerender-hoc.js +16 -32
- package/components/global/schedule-raf.js +4 -4
- package/components/global/sniffer.js +1 -1
- package/components/global/theme.js +1 -18
- package/components/global/trivial-template-tag.js +4 -9
- package/components/global/typescript-utils.js +2 -6
- package/components/global/url.js +20 -23
- package/components/global/use-event-callback.js +7 -4
- package/components/grid/col.js +27 -39
- package/components/grid/grid.js +18 -27
- package/components/grid/row.js +23 -30
- package/components/group/group.js +16 -22
- package/components/header/header-icon.js +19 -31
- package/components/header/header.d.ts +0 -1
- package/components/header/header.js +30 -64
- package/components/header/links.js +6 -3
- package/components/header/logo.js +15 -26
- package/components/header/profile.js +124 -150
- package/components/header/services-link.js +1 -3
- package/components/header/services.js +64 -97
- package/components/header/smart-profile.js +101 -178
- package/components/header/smart-services.js +55 -90
- package/components/header/tray.js +21 -30
- package/components/heading/heading.js +21 -20
- package/components/http/http.js +162 -319
- package/components/http/http.mock.js +50 -98
- package/components/hub-source/hub-source.js +77 -182
- package/components/hub-source/hub-source__user.js +9 -37
- package/components/hub-source/hub-source__users-groups.js +34 -60
- package/components/i18n/i18n-context.js +7 -8
- package/components/i18n/i18n.js +3 -6
- package/components/icon/icon.js +60 -74
- package/components/icon/icon__svg.js +0 -5
- package/components/icon/index.js +0 -5
- package/components/input/input.js +1 -11
- package/components/island/adaptive-island-hoc.js +29 -37
- package/components/island/content.js +100 -110
- package/components/island/header.js +56 -66
- package/components/island/island.js +25 -33
- package/components/island-legacy/content-legacy.js +16 -22
- package/components/island-legacy/header-legacy.js +19 -25
- package/components/island-legacy/island-legacy.js +16 -22
- package/components/link/clickableLink.js +33 -42
- package/components/link/link.js +47 -55
- package/components/list/consts.js +2 -2
- package/components/list/list.js +399 -486
- package/components/list/list__custom.js +51 -61
- package/components/list/list__hint.js +9 -17
- package/components/list/list__item.js +147 -178
- package/components/list/list__link.js +38 -47
- package/components/list/list__separator.js +15 -24
- package/components/list/list__title.js +25 -34
- package/components/list/list__users-groups-source.js +55 -121
- package/components/loader/loader.js +38 -60
- package/components/loader/loader__core.js +123 -184
- package/components/loader-inline/loader-inline.js +24 -32
- package/components/loader-screen/loader-screen.js +24 -40
- package/components/login-dialog/login-dialog.js +81 -121
- package/components/login-dialog/service.js +6 -29
- package/components/markdown/markdown.js +16 -24
- package/components/message/message.js +170 -201
- package/components/old-browsers-message/old-browsers-message.js +11 -14
- package/components/old-browsers-message/old-browsers-message__stop.js +1 -4
- package/components/old-browsers-message/white-list.js +8 -13
- package/components/pager/pager.js +212 -257
- package/components/panel/panel.js +16 -22
- package/components/permissions/permissions.js +118 -161
- package/components/permissions/permissions__cache.js +191 -218
- package/components/popup/popup.consts.js +1 -1
- package/components/popup/popup.js +237 -288
- package/components/popup/popup.target.js +9 -7
- package/components/popup/position.js +94 -101
- package/components/popup-menu/popup-menu.js +33 -67
- package/components/progress-bar/progress-bar.js +57 -68
- package/components/query-assist/query-assist.js +583 -652
- package/components/query-assist/query-assist__suggestions.js +2 -26
- package/components/radio/radio.js +15 -27
- package/components/radio/radio__item.js +52 -62
- package/components/scrollable-section/scrollable-section.js +22 -32
- package/components/select/select.js +693 -793
- package/components/select/select__filter.js +1 -26
- package/components/select/select__popup.js +316 -413
- package/components/shortcuts/core.js +147 -195
- package/components/shortcuts/shortcut-title.js +6 -10
- package/components/shortcuts/shortcuts-hoc.js +23 -41
- package/components/shortcuts/shortcuts.js +41 -64
- package/components/slider/slider.js +93 -112
- package/components/slider/slider.utils.js +16 -23
- package/components/storage/storage.js +3 -27
- package/components/storage/storage__fallback.js +137 -210
- package/components/storage/storage__local.js +89 -147
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +35 -53
- package/components/table/cell.js +11 -21
- package/components/table/disable-hover-hoc.js +27 -42
- package/components/table/header-cell.js +59 -75
- package/components/table/header.js +89 -110
- package/components/table/multitable.js +83 -89
- package/components/table/row-with-focus-sensor.js +25 -57
- package/components/table/row.js +169 -200
- package/components/table/selection-adapter.js +2 -2
- package/components/table/selection-shortcuts-hoc.js +108 -113
- package/components/table/selection.js +150 -217
- package/components/table/simple-table.js +19 -55
- package/components/table/smart-table.js +42 -76
- package/components/table/table.js +267 -327
- package/components/tabs/collapsible-more.js +47 -73
- package/components/tabs/collapsible-tab.js +32 -36
- package/components/tabs/collapsible-tabs.js +89 -148
- package/components/tabs/custom-item.js +4 -2
- package/components/tabs/dumb-tabs.js +60 -92
- package/components/tabs/smart-tabs.js +29 -61
- package/components/tabs/tab-link.js +1 -3
- package/components/tabs/tab.js +15 -24
- package/components/tabs/tabs.js +1 -26
- package/components/tag/tag.d.ts +0 -2
- package/components/tag/tag.js +120 -162
- package/components/tags-input/tags-input.js +222 -304
- package/components/tags-list/tags-list.js +45 -61
- package/components/text/text.js +28 -37
- package/components/toggle/toggle.js +51 -61
- package/components/tooltip/tooltip.js +109 -141
- package/components/user-agreement/service.js +259 -400
- package/components/user-agreement/user-agreement.js +80 -108
- package/components/user-card/card.js +1 -25
- package/components/user-card/smart-user-card-tooltip.js +52 -103
- package/components/user-card/tooltip.js +35 -65
- package/components/user-card/user-card.js +1 -25
- package/package.json +1 -1
- package/components/global/react-render-adapter.d.ts +0 -1
- package/components/global/react-render-adapter.js +0 -6
- package/components/header/tray-icon.d.ts +0 -1
- package/components/header/tray-icon.js +0 -26
@@ -1,254 +1,227 @@
|
|
1
|
-
import { _ as _defineProperty
|
2
|
-
import 'core-js/modules/es.object.to-string.js';
|
1
|
+
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
3
2
|
import 'core-js/modules/es.regexp.exec.js';
|
4
|
-
import 'core-js/modules/es.regexp.to-string.js';
|
5
3
|
import 'core-js/modules/es.string.replace.js';
|
6
4
|
import { getRect } from '../global/dom.js';
|
7
|
-
import 'core-js/modules/es.array.filter.js';
|
8
|
-
import 'core-js/modules/es.array.iterator.js';
|
9
|
-
import 'core-js/modules/es.object.assign.js';
|
10
|
-
import 'core-js/modules/es.object.entries.js';
|
11
|
-
import 'core-js/modules/es.set.js';
|
12
|
-
import 'core-js/modules/es.string.split.js';
|
13
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
14
5
|
import 'core-js/modules/web.dom-collections.iterator.js';
|
15
6
|
|
16
7
|
/**
|
17
8
|
* @name Caret
|
18
9
|
*/
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
class Caret {
|
11
|
+
/**
|
12
|
+
* Line endings normalizer
|
13
|
+
* Borrowed from jQuery
|
14
|
+
* @see https://github.com/jquery/jquery/blob/master/src/attributes/val.js
|
15
|
+
* @param value {*}
|
16
|
+
* @return {*}
|
17
|
+
*/
|
18
|
+
static normalizeNewlines(value) {
|
19
|
+
return typeof value === 'string' ? value.replace(this.returnRE, '') : value;
|
20
|
+
}
|
21
|
+
constructor(target) {
|
22
22
|
_defineProperty(this, "target", void 0);
|
23
23
|
this.target = target;
|
24
24
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
isContentEditable() {
|
26
|
+
return this.target.contentEditable === 'true';
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* Set focus on target if possible
|
30
|
+
*/
|
31
|
+
focus() {
|
32
|
+
if (!document.activeElement || document.activeElement !== this.target) {
|
33
|
+
this.target.focus();
|
29
34
|
}
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Get absolute caret position index
|
38
|
+
* @return {number}
|
39
|
+
*/
|
40
|
+
getAbsolutePosition(node) {
|
41
|
+
let _curNode = node;
|
42
|
+
let curPos = 0;
|
43
|
+
while (_curNode != null && _curNode !== this.target) {
|
44
|
+
while (_curNode.previousSibling) {
|
45
|
+
var _curNode$previousSibl, _curNode$previousSibl2;
|
46
|
+
curPos += (_curNode$previousSibl = (_curNode$previousSibl2 = _curNode.previousSibling.textContent) === null || _curNode$previousSibl2 === void 0 ? void 0 : _curNode$previousSibl2.length) !== null && _curNode$previousSibl !== void 0 ? _curNode$previousSibl : 0;
|
47
|
+
_curNode = _curNode.previousSibling;
|
38
48
|
}
|
49
|
+
_curNode = _curNode.parentNode;
|
39
50
|
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
_curNode = _curNode.previousSibling;
|
54
|
-
}
|
55
|
-
_curNode = _curNode.parentNode;
|
51
|
+
return curPos;
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Get caret position index
|
55
|
+
* @param {Object} [params]
|
56
|
+
* @param {boolean} params.avoidFocus
|
57
|
+
* @return {number}
|
58
|
+
*/
|
59
|
+
getPosition() {
|
60
|
+
let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
61
|
+
if (this.isContentEditable()) {
|
62
|
+
if (!params.avoidFocus) {
|
63
|
+
this.focus();
|
56
64
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
var range1 = selection.getRangeAt(0);
|
78
|
-
var range2 = range1.cloneRange();
|
79
|
-
range2.selectNodeContents(this.target);
|
80
|
-
range2.setEnd(range1.endContainer, range1.endOffset);
|
81
|
-
var _curNode = range1.startContainer;
|
82
|
-
if (this.target === _curNode) {
|
83
|
-
return range1.startOffset === 0 || _curNode.textContent == null ? 0 : _curNode.textContent.length;
|
84
|
-
} else if (!this.target.contains(_curNode)) {
|
85
|
-
return -1;
|
86
|
-
} else if (!_curNode) {
|
87
|
-
return 'selectionStart' in this.target && this.target.selectionStart || -1;
|
88
|
-
}
|
89
|
-
var curPos = this.getAbsolutePosition(_curNode);
|
90
|
-
if (range1.startContainer === range1.endContainer) {
|
91
|
-
if (range1.startOffset === range1.endOffset) {
|
92
|
-
return curPos + range1.startOffset;
|
93
|
-
} else {
|
94
|
-
return {
|
95
|
-
startOffset: curPos + range1.startOffset,
|
96
|
-
endOffset: curPos + range1.endOffset,
|
97
|
-
position: range2.toString().length
|
98
|
-
};
|
99
|
-
}
|
65
|
+
const selection = window.getSelection();
|
66
|
+
if (!(selection !== null && selection !== void 0 && selection.rangeCount)) {
|
67
|
+
return 0;
|
68
|
+
}
|
69
|
+
const range1 = selection.getRangeAt(0);
|
70
|
+
const range2 = range1.cloneRange();
|
71
|
+
range2.selectNodeContents(this.target);
|
72
|
+
range2.setEnd(range1.endContainer, range1.endOffset);
|
73
|
+
const _curNode = range1.startContainer;
|
74
|
+
if (this.target === _curNode) {
|
75
|
+
return range1.startOffset === 0 || _curNode.textContent == null ? 0 : _curNode.textContent.length;
|
76
|
+
} else if (!this.target.contains(_curNode)) {
|
77
|
+
return -1;
|
78
|
+
} else if (!_curNode) {
|
79
|
+
return 'selectionStart' in this.target && this.target.selectionStart || -1;
|
80
|
+
}
|
81
|
+
const curPos = this.getAbsolutePosition(_curNode);
|
82
|
+
if (range1.startContainer === range1.endContainer) {
|
83
|
+
if (range1.startOffset === range1.endOffset) {
|
84
|
+
return curPos + range1.startOffset;
|
100
85
|
} else {
|
101
|
-
var startOffset = curPos + range1.startOffset;
|
102
|
-
var endPos = this.getAbsolutePosition(range1.endContainer);
|
103
|
-
var endOffset = endPos + range1.endOffset;
|
104
86
|
return {
|
105
|
-
startOffset,
|
106
|
-
endOffset,
|
87
|
+
startOffset: curPos + range1.startOffset,
|
88
|
+
endOffset: curPos + range1.endOffset,
|
107
89
|
position: range2.toString().length
|
108
90
|
};
|
109
91
|
}
|
110
|
-
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
* Get relative position of query
|
115
|
-
* @param {Node} curNode
|
116
|
-
* @param {number} position
|
117
|
-
* @return {{_correctedPosition: number, _curNode: Node}}
|
118
|
-
*/
|
119
|
-
}, {
|
120
|
-
key: "getRelativePosition",
|
121
|
-
value: function getRelativePosition(curNode, position) {
|
122
|
-
var curPos = 0;
|
123
|
-
var _curNode = curNode;
|
124
|
-
var nodeTypeText = 3;
|
125
|
-
if (!_curNode) {
|
126
|
-
return {
|
127
|
-
_curNode: this.target,
|
128
|
-
_correctedPosition: position
|
129
|
-
};
|
130
|
-
}
|
131
|
-
if (position === 0) {
|
132
|
-
while (_curNode.nodeType !== nodeTypeText) {
|
133
|
-
_curNode = _curNode.childNodes[0];
|
134
|
-
}
|
135
|
-
var _correctedPosition2 = position;
|
92
|
+
} else {
|
93
|
+
const startOffset = curPos + range1.startOffset;
|
94
|
+
const endPos = this.getAbsolutePosition(range1.endContainer);
|
95
|
+
const endOffset = endPos + range1.endOffset;
|
136
96
|
return {
|
137
|
-
|
138
|
-
|
97
|
+
startOffset,
|
98
|
+
endOffset,
|
99
|
+
position: range2.toString().length
|
139
100
|
};
|
140
101
|
}
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
102
|
+
}
|
103
|
+
return 'selectionStart' in this.target && this.target.selectionStart || -1;
|
104
|
+
}
|
105
|
+
/**
|
106
|
+
* Get relative position of query
|
107
|
+
* @param {Node} curNode
|
108
|
+
* @param {number} position
|
109
|
+
* @return {{_correctedPosition: number, _curNode: Node}}
|
110
|
+
*/
|
111
|
+
getRelativePosition(curNode, position) {
|
112
|
+
let curPos = 0;
|
113
|
+
let _curNode = curNode;
|
114
|
+
const nodeTypeText = 3;
|
115
|
+
if (!_curNode) {
|
116
|
+
return {
|
117
|
+
_curNode: this.target,
|
118
|
+
_correctedPosition: position
|
119
|
+
};
|
120
|
+
}
|
121
|
+
if (position === 0) {
|
122
|
+
while (_curNode.nodeType !== nodeTypeText) {
|
123
|
+
_curNode = _curNode.childNodes[0];
|
158
124
|
}
|
159
|
-
|
125
|
+
const _correctedPosition = position;
|
160
126
|
return {
|
161
127
|
_curNode,
|
162
128
|
_correctedPosition
|
163
129
|
};
|
164
130
|
}
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
var range = new Range();
|
179
|
-
var start = this.getRelativePosition(curNode, position.startOffset);
|
180
|
-
range.setStart(start._curNode, start._correctedPosition);
|
181
|
-
var end = this.getRelativePosition(curNode, position.endOffset);
|
182
|
-
range.setEnd(end._curNode, end._correctedPosition);
|
183
|
-
correctedPosition = range;
|
184
|
-
} else if (position === -1) {
|
185
|
-
var _value$length;
|
186
|
-
var value = isContentEditable ? this.target.textContent : Caret.normalizeNewlines('value' in this.target ? this.target.value : undefined);
|
187
|
-
correctedPosition = (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0;
|
131
|
+
let i = -1;
|
132
|
+
if (_curNode && _curNode.nodeType !== undefined) {
|
133
|
+
while (curPos < position && _curNode.nodeType !== nodeTypeText) {
|
134
|
+
i++;
|
135
|
+
if (_curNode.childNodes[i] != null) {
|
136
|
+
var _curNode$childNodes$i, _curNode$childNodes$i2;
|
137
|
+
curPos += (_curNode$childNodes$i = (_curNode$childNodes$i2 = _curNode.childNodes[i].textContent) === null || _curNode$childNodes$i2 === void 0 ? void 0 : _curNode$childNodes$i2.length) !== null && _curNode$childNodes$i !== void 0 ? _curNode$childNodes$i : 0;
|
138
|
+
if (curPos >= position) {
|
139
|
+
var _curNode$textContent$, _curNode$textContent;
|
140
|
+
_curNode = _curNode.childNodes[i];
|
141
|
+
curPos -= (_curNode$textContent$ = (_curNode$textContent = _curNode.textContent) === null || _curNode$textContent === void 0 ? void 0 : _curNode$textContent.length) !== null && _curNode$textContent$ !== void 0 ? _curNode$textContent$ : 0;
|
142
|
+
i = -1;
|
143
|
+
}
|
188
144
|
} else {
|
189
|
-
|
190
|
-
_curNode = _this$getRelativePosi._curNode,
|
191
|
-
_correctedPosition = _this$getRelativePosi._correctedPosition;
|
192
|
-
curNode = _curNode;
|
193
|
-
correctedPosition = _correctedPosition;
|
145
|
+
break;
|
194
146
|
}
|
195
147
|
}
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
148
|
+
}
|
149
|
+
const _correctedPosition = position - curPos;
|
150
|
+
return {
|
151
|
+
_curNode,
|
152
|
+
_correctedPosition
|
153
|
+
};
|
154
|
+
}
|
155
|
+
/**
|
156
|
+
* Set caret position index
|
157
|
+
* @param {number} position
|
158
|
+
* @return {number}
|
159
|
+
*/
|
160
|
+
setPosition(position) {
|
161
|
+
const isContentEditable = this.isContentEditable();
|
162
|
+
let correctedPosition;
|
163
|
+
let curNode = this.target && this.target.childNodes[0];
|
164
|
+
if (position !== undefined) {
|
165
|
+
if (typeof position === 'object') {
|
166
|
+
const range = new Range();
|
167
|
+
const start = this.getRelativePosition(curNode, position.startOffset);
|
168
|
+
range.setStart(start._curNode, start._correctedPosition);
|
169
|
+
const end = this.getRelativePosition(curNode, position.endOffset);
|
170
|
+
range.setEnd(end._curNode, end._correctedPosition);
|
171
|
+
correctedPosition = range;
|
172
|
+
} else if (position === -1) {
|
173
|
+
var _value$length;
|
174
|
+
const value = isContentEditable ? this.target.textContent : Caret.normalizeNewlines('value' in this.target ? this.target.value : undefined);
|
175
|
+
correctedPosition = (_value$length = value === null || value === void 0 ? void 0 : value.length) !== null && _value$length !== void 0 ? _value$length : 0;
|
176
|
+
} else {
|
177
|
+
const {
|
178
|
+
_curNode,
|
179
|
+
_correctedPosition
|
180
|
+
} = this.getRelativePosition(curNode, position);
|
181
|
+
curNode = _curNode;
|
182
|
+
correctedPosition = _correctedPosition;
|
212
183
|
}
|
213
|
-
return correctedPosition;
|
214
184
|
}
|
215
|
-
|
216
|
-
|
217
|
-
* @return {number}
|
218
|
-
*/
|
219
|
-
}, {
|
220
|
-
key: "getOffset",
|
221
|
-
value: function getOffset() {
|
222
|
-
var offset = 0;
|
223
|
-
var range;
|
185
|
+
if (isContentEditable) {
|
186
|
+
this.focus();
|
224
187
|
try {
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
188
|
+
if (correctedPosition instanceof Range) {
|
189
|
+
var _window$getSelection, _window$getSelection2;
|
190
|
+
(_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 || _window$getSelection.removeAllRanges();
|
191
|
+
(_window$getSelection2 = window.getSelection()) === null || _window$getSelection2 === void 0 || _window$getSelection2.addRange(correctedPosition);
|
192
|
+
} else {
|
193
|
+
var _window$getSelection3;
|
194
|
+
(_window$getSelection3 = window.getSelection()) === null || _window$getSelection3 === void 0 || _window$getSelection3.collapse(curNode || this.target, correctedPosition);
|
195
|
+
}
|
229
196
|
} catch (e) {
|
230
|
-
|
231
|
-
}
|
232
|
-
if (range && range.endOffset !== 0 && range.toString() !== '') {
|
233
|
-
offset = getRect(range).right - getRect(this.target).left - (range.startContainer instanceof HTMLElement && range.startContainer.offsetLeft || 0);
|
197
|
+
// Do nothing
|
234
198
|
}
|
199
|
+
} else if ('setSelectionRange' in this.target && typeof correctedPosition === 'number') {
|
200
|
+
this.target.setSelectionRange(correctedPosition, correctedPosition);
|
201
|
+
}
|
202
|
+
return correctedPosition;
|
203
|
+
}
|
204
|
+
/**
|
205
|
+
* Get caret position in pixels
|
206
|
+
* @return {number}
|
207
|
+
*/
|
208
|
+
getOffset() {
|
209
|
+
let offset = 0;
|
210
|
+
let range;
|
211
|
+
try {
|
212
|
+
var _window$getSelection4, _range;
|
213
|
+
// Both statements may throw
|
214
|
+
range = (_window$getSelection4 = window.getSelection()) === null || _window$getSelection4 === void 0 ? void 0 : _window$getSelection4.getRangeAt(0).cloneRange();
|
215
|
+
(_range = range) === null || _range === void 0 || _range.setStart(range.startContainer, range.startOffset - 1);
|
216
|
+
} catch (e) {
|
235
217
|
return offset;
|
236
218
|
}
|
237
|
-
|
238
|
-
|
239
|
-
value:
|
240
|
-
/**
|
241
|
-
* Line endings normalizer
|
242
|
-
* Borrowed from jQuery
|
243
|
-
* @see https://github.com/jquery/jquery/blob/master/src/attributes/val.js
|
244
|
-
* @param value {*}
|
245
|
-
* @return {*}
|
246
|
-
*/
|
247
|
-
function normalizeNewlines(value) {
|
248
|
-
return typeof value === 'string' ? value.replace(this.returnRE, '') : value;
|
219
|
+
if (range && range.endOffset !== 0 && range.toString() !== '') {
|
220
|
+
offset = getRect(range).right - getRect(this.target).left - (range.startContainer instanceof HTMLElement && range.startContainer.offsetLeft || 0);
|
249
221
|
}
|
250
|
-
|
251
|
-
}
|
222
|
+
return offset;
|
223
|
+
}
|
224
|
+
}
|
252
225
|
/**
|
253
226
|
* Line endings RegExp
|
254
227
|
* @type {RegExp}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { _ as _defineProperty, a as
|
2
|
-
import 'core-js/modules/
|
1
|
+
import { _ as _defineProperty, a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
3
3
|
import { PureComponent } from 'react';
|
4
4
|
import PropTypes from 'prop-types';
|
5
5
|
import classNames from 'classnames';
|
@@ -15,103 +15,86 @@ import '../icon/icon__constants.js';
|
|
15
15
|
import '../_helpers/icon__svg.js';
|
16
16
|
import 'core-js/modules/es.regexp.exec.js';
|
17
17
|
import 'core-js/modules/es.string.replace.js';
|
18
|
-
import 'core-js/modules/es.string.starts-with.js';
|
19
18
|
import '../global/memoize.js';
|
20
|
-
import 'core-js/modules/es.array.iterator.js';
|
21
|
-
import 'core-js/modules/es.map.js';
|
22
|
-
import 'core-js/modules/es.object.to-string.js';
|
23
|
-
import 'core-js/modules/es.weak-map.js';
|
24
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
25
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
26
19
|
import 'memoize-one';
|
27
20
|
|
28
21
|
var modules_3199090e = {"checkboxSize":"14px","light":"light_rui_2ac4","checkbox":"checkbox_rui_219d","cell":"cell_rui_219d","icon":"icon_rui_219d","check":"check_rui_219d icon_rui_219d","minus":"minus_rui_219d icon_rui_219d","input":"input_rui_219d","cellWrapper":"cellWrapper_rui_219d","focus":"focus_rui_219d","label":"label_rui_219d"};
|
29
22
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
args[_key] = arguments[_key];
|
37
|
-
}
|
38
|
-
_this = _callSuper(this, Checkbox, [].concat(args));
|
39
|
-
_defineProperty(_this, "input", void 0);
|
40
|
-
_defineProperty(_this, "inputRef", function (el) {
|
23
|
+
const _excluded = ["children", "label", "className", "containerClassName", "containerStyle", "cellClassName", "labelClassName", "indeterminate", "inputRef", "help"];
|
24
|
+
class Checkbox extends PureComponent {
|
25
|
+
constructor() {
|
26
|
+
super(...arguments);
|
27
|
+
_defineProperty(this, "input", void 0);
|
28
|
+
_defineProperty(this, "inputRef", el => {
|
41
29
|
if (el != null) {
|
42
|
-
el.indeterminate =
|
30
|
+
el.indeterminate = this.props.indeterminate;
|
43
31
|
}
|
44
|
-
|
32
|
+
this.input = el;
|
45
33
|
});
|
46
|
-
_defineProperty(
|
47
|
-
return _this;
|
34
|
+
_defineProperty(this, "composedInputRef", createComposedRef());
|
48
35
|
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
value: function componentDidMount() {
|
53
|
-
if (this.input != null) {
|
54
|
-
this.input.indeterminate = this.props.indeterminate;
|
55
|
-
}
|
36
|
+
componentDidMount() {
|
37
|
+
if (this.input != null) {
|
38
|
+
this.input.indeterminate = this.props.indeterminate;
|
56
39
|
}
|
57
|
-
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
40
|
+
}
|
41
|
+
componentDidUpdate(prevProps) {
|
42
|
+
const {
|
43
|
+
indeterminate
|
44
|
+
} = this.props;
|
45
|
+
if (this.input != null && indeterminate !== prevProps.indeterminate) {
|
46
|
+
this.input.indeterminate = this.props.indeterminate;
|
64
47
|
}
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
children
|
70
|
-
label
|
71
|
-
className
|
72
|
-
containerClassName
|
73
|
-
containerStyle
|
74
|
-
cellClassName
|
75
|
-
labelClassName
|
76
|
-
|
77
|
-
|
78
|
-
help
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
})
|
105
|
-
}), /*#__PURE__*/jsxs("span", {
|
106
|
-
className: labelClasses,
|
107
|
-
children: [label || children, help && /*#__PURE__*/jsx(ControlHelp, {
|
108
|
-
children: help
|
48
|
+
}
|
49
|
+
render() {
|
50
|
+
const _this$props = this.props,
|
51
|
+
{
|
52
|
+
children,
|
53
|
+
label,
|
54
|
+
className,
|
55
|
+
containerClassName,
|
56
|
+
containerStyle,
|
57
|
+
cellClassName,
|
58
|
+
labelClassName,
|
59
|
+
indeterminate,
|
60
|
+
inputRef,
|
61
|
+
help
|
62
|
+
} = _this$props,
|
63
|
+
restProps = _objectWithoutProperties(_this$props, _excluded);
|
64
|
+
const classes = classNames(modules_3199090e.input, className);
|
65
|
+
const containerClasses = classNames(modules_3199090e.checkbox, containerClassName);
|
66
|
+
const cellClasses = classNames(modules_3199090e.cell, cellClassName);
|
67
|
+
const labelClasses = classNames(modules_3199090e.label, labelClassName);
|
68
|
+
return /*#__PURE__*/jsxs("label", {
|
69
|
+
className: containerClasses,
|
70
|
+
style: containerStyle,
|
71
|
+
"data-test": "ring-checkbox",
|
72
|
+
children: [/*#__PURE__*/jsx("input", _objectSpread2(_objectSpread2({}, restProps), {}, {
|
73
|
+
"data-checked": restProps.checked,
|
74
|
+
ref: this.composedInputRef(this.inputRef, inputRef),
|
75
|
+
type: "checkbox",
|
76
|
+
className: classes
|
77
|
+
})), /*#__PURE__*/jsx("div", {
|
78
|
+
className: modules_3199090e.cellWrapper,
|
79
|
+
children: /*#__PURE__*/jsxs("span", {
|
80
|
+
className: cellClasses,
|
81
|
+
children: [/*#__PURE__*/jsx(Icon, {
|
82
|
+
glyph: checkmarkIcon,
|
83
|
+
className: modules_3199090e.check
|
84
|
+
}), /*#__PURE__*/jsx(Icon, {
|
85
|
+
glyph: minusIcon,
|
86
|
+
className: modules_3199090e.minus
|
109
87
|
})]
|
88
|
+
})
|
89
|
+
}), /*#__PURE__*/jsxs("span", {
|
90
|
+
className: labelClasses,
|
91
|
+
children: [label || children, help && /*#__PURE__*/jsx(ControlHelp, {
|
92
|
+
children: help
|
110
93
|
})]
|
111
|
-
})
|
112
|
-
}
|
113
|
-
}
|
114
|
-
}
|
94
|
+
})]
|
95
|
+
});
|
96
|
+
}
|
97
|
+
}
|
115
98
|
_defineProperty(Checkbox, "propTypes", {
|
116
99
|
name: PropTypes.string,
|
117
100
|
label: PropTypes.string,
|