@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/table.js
DELETED
|
@@ -1,903 +0,0 @@
|
|
|
1
|
-
import { b as _defineProperty, _ as _objectWithoutProperties, a as _extends, c as _objectSpread2 } from './_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import { arrayMove, List } from 'react-movable';
|
|
6
|
-
import { c as composeRefs, f as focusSensorHOC, d as disableHoverHOC, s as selectionShortcutsHOC } from './_helpers/disable-hover-hoc.js';
|
|
7
|
-
import { g as getUID } from './_helpers/get-uid.js';
|
|
8
|
-
import Shortcuts from './shortcuts.js';
|
|
9
|
-
import Loader from './loader.js';
|
|
10
|
-
import Selection from './selection.js';
|
|
11
|
-
import { Waypoint } from 'react-waypoint';
|
|
12
|
-
import Checkbox from './checkbox.js';
|
|
13
|
-
import sortableIcon from '@jetbrains/icons/unsorted-10px';
|
|
14
|
-
import chevronDown from '@jetbrains/icons/chevron-10px';
|
|
15
|
-
import Icon from './icon.js';
|
|
16
|
-
import { j as joinDataTestAttributes } from './_helpers/data-tests.js';
|
|
17
|
-
import chevronRightIcon from '@jetbrains/icons/chevron-right';
|
|
18
|
-
import chevronDownIcon from '@jetbrains/icons/chevron-down';
|
|
19
|
-
import dragIcon from '@jetbrains/icons/drag';
|
|
20
|
-
import { B as Button } from './_helpers/button.js';
|
|
21
|
-
import Tooltip from './tooltip.js';
|
|
22
|
-
import 'combokeys';
|
|
23
|
-
import './_helpers/sniffer.js';
|
|
24
|
-
import 'sniffr';
|
|
25
|
-
import './_helpers/dom.js';
|
|
26
|
-
import '@jetbrains/icons/checkmark';
|
|
27
|
-
import '@jetbrains/icons/remove-10px';
|
|
28
|
-
import 'util-deprecate';
|
|
29
|
-
import './_helpers/memoize.js';
|
|
30
|
-
import 'focus-visible';
|
|
31
|
-
import './_helpers/theme.js';
|
|
32
|
-
import './_helpers/clickableLink.js';
|
|
33
|
-
import './_helpers/popup.js';
|
|
34
|
-
import 'react-dom';
|
|
35
|
-
import './_helpers/schedule-raf.js';
|
|
36
|
-
import './tab-trap.js';
|
|
37
|
-
import './_helpers/popup.target.js';
|
|
38
|
-
|
|
39
|
-
var modules_1db4bbca = {"unit":"8px","height":"32px","compensate":"2px","compensated":"30px","top":"-3px","row":"table_row__5765cfc6","dragHandle":"table_dragHandle__5765cfc6","tableWrapper":"table_tableWrapper__5765cfc6","table":"table_table__5765cfc6","userSelectNone":"table_userSelectNone__5765cfc6","headerCell":"table_headerCell__5765cfc6 global_fontSmallerLower__0f8f4370 global_fontSmaller__0f8f4370 global_fontLower__0f8f4370 global_font__0f8f4370","headerCellSorted":"table_headerCellSorted__5765cfc6","headerCellSortable":"table_headerCellSortable__5765cfc6","sorter":"table_sorter__5765cfc6","sortedUp":"table_sortedUp__5765cfc6","icon":"table_icon__5765cfc6","caption":"table_caption__5765cfc6","tableHead":"table_tableHead__5765cfc6","subHeaderFixed":"table_subHeaderFixed__5765cfc6","subHeader":"table_subHeader__5765cfc6","rowSelected":"table_rowSelected__5765cfc6","rowFocused":"table_rowFocused__5765cfc6","cell":"table_cell__5765cfc6 global_ellipsis__0f8f4370","loadingOverlay":"table_loadingOverlay__5765cfc6","cellUnlimited":"table_cellUnlimited__5765cfc6","cellRight":"table_cellRight__5765cfc6","metaColumn":"table_metaColumn__5765cfc6","headerMetaColumn":"table_headerMetaColumn__5765cfc6","visibleDragHandle":"table_visibleDragHandle__5765cfc6","rowCollapseExpandButton":"table_rowCollapseExpandButton__5765cfc6","draggingRow":"table_draggingRow__5765cfc6","tableMessage":"table_tableMessage__5765cfc6"};
|
|
40
|
-
|
|
41
|
-
class HeaderCell extends PureComponent {
|
|
42
|
-
constructor(...args) {
|
|
43
|
-
super(...args);
|
|
44
|
-
|
|
45
|
-
_defineProperty(this, "onClick", () => {
|
|
46
|
-
if (this.sortable) {
|
|
47
|
-
const {
|
|
48
|
-
column,
|
|
49
|
-
onSort,
|
|
50
|
-
sortOrder
|
|
51
|
-
} = this.props;
|
|
52
|
-
onSort({
|
|
53
|
-
column,
|
|
54
|
-
order: !(this.sorted && sortOrder)
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
onChildrenClick(e) {
|
|
61
|
-
e.stopPropagation();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
render() {
|
|
65
|
-
const _this$props = this.props,
|
|
66
|
-
{
|
|
67
|
-
className,
|
|
68
|
-
column,
|
|
69
|
-
onSort,
|
|
70
|
-
sortKey,
|
|
71
|
-
sortOrder,
|
|
72
|
-
'data-test': dataTest
|
|
73
|
-
} = _this$props,
|
|
74
|
-
restProps = _objectWithoutProperties(_this$props, ["className", "column", "onSort", "sortKey", "sortOrder", "data-test"]);
|
|
75
|
-
|
|
76
|
-
this.sortable = column.sortable === true;
|
|
77
|
-
this.sorted = sortKey === column.id;
|
|
78
|
-
const glyph = this.sorted ? chevronDown : sortableIcon;
|
|
79
|
-
const classes = classNames(className, column.headerClassName, {
|
|
80
|
-
[modules_1db4bbca.headerCell]: true,
|
|
81
|
-
[modules_1db4bbca.headerCellSortable]: this.sortable,
|
|
82
|
-
[modules_1db4bbca.headerCellSorted]: this.sorted,
|
|
83
|
-
[modules_1db4bbca.sortedUp]: sortOrder && this.sorted,
|
|
84
|
-
[modules_1db4bbca.cellRight]: column.rightAlign
|
|
85
|
-
});
|
|
86
|
-
return /*#__PURE__*/React.createElement("th", _extends({}, restProps, {
|
|
87
|
-
className: classes,
|
|
88
|
-
onClick: this.onClick,
|
|
89
|
-
"data-test": joinDataTestAttributes('ring-table-header-cell', dataTest)
|
|
90
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
91
|
-
onClick: this.onChildrenClick,
|
|
92
|
-
role: "presentation"
|
|
93
|
-
}, this.props.children), column.getHeaderValue ? column.getHeaderValue() : column.title, this.sortable && /*#__PURE__*/React.createElement("span", {
|
|
94
|
-
className: modules_1db4bbca.sorter
|
|
95
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
96
|
-
glyph: glyph,
|
|
97
|
-
className: modules_1db4bbca.icon
|
|
98
|
-
})));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
_defineProperty(HeaderCell, "propTypes", {
|
|
104
|
-
children: PropTypes.any,
|
|
105
|
-
className: PropTypes.string,
|
|
106
|
-
column: PropTypes.object.isRequired,
|
|
107
|
-
onSort: PropTypes.func,
|
|
108
|
-
sortKey: PropTypes.string,
|
|
109
|
-
sortOrder: PropTypes.bool,
|
|
110
|
-
'data-test': PropTypes.string
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
_defineProperty(HeaderCell, "defaultProps", {
|
|
114
|
-
onSort: () => {}
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const waypointChild = /*#__PURE__*/React.createElement("tr", {
|
|
118
|
-
"data-test": "ring-table-header-row"
|
|
119
|
-
});
|
|
120
|
-
class Header extends PureComponent {
|
|
121
|
-
constructor(...args) {
|
|
122
|
-
super(...args);
|
|
123
|
-
|
|
124
|
-
_defineProperty(this, "state", {
|
|
125
|
-
fixed: false,
|
|
126
|
-
headerWidth: null,
|
|
127
|
-
widths: []
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
_defineProperty(this, "id", getUID('table-header-'));
|
|
131
|
-
|
|
132
|
-
_defineProperty(this, "onCheckboxFocus", event => {
|
|
133
|
-
event.target.blur();
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
_defineProperty(this, "storeColumnsRowNode", node => {
|
|
137
|
-
if (node) {
|
|
138
|
-
this._columnsRowNode = node;
|
|
139
|
-
this.calculateColumnsWidths(node);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
_defineProperty(this, "onScrollIn", () => {
|
|
144
|
-
this.calculateColumnsWidths(this._columnsRowNode);
|
|
145
|
-
this.setState({
|
|
146
|
-
fixed: false
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
_defineProperty(this, "onScrollOut", ({
|
|
151
|
-
currentPosition
|
|
152
|
-
}) => {
|
|
153
|
-
if (currentPosition !== 'above') {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
this.calculateColumnsWidths(this._columnsRowNode);
|
|
158
|
-
this.setState({
|
|
159
|
-
fixed: true
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
calculateColumnsWidths(columnsRowNode) {
|
|
165
|
-
this.setState({
|
|
166
|
-
headerWidth: columnsRowNode.clientWidth,
|
|
167
|
-
widths: [...columnsRowNode.childNodes].map(column => column.clientWidth)
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
createCells(widths = []) {
|
|
172
|
-
const {
|
|
173
|
-
selectable,
|
|
174
|
-
draggable,
|
|
175
|
-
columns,
|
|
176
|
-
checked,
|
|
177
|
-
checkboxDisabled,
|
|
178
|
-
onCheckboxChange,
|
|
179
|
-
onSort,
|
|
180
|
-
sortKey,
|
|
181
|
-
sortOrder
|
|
182
|
-
} = this.props;
|
|
183
|
-
const metaColumnClasses = classNames(modules_1db4bbca.metaColumn, modules_1db4bbca.headerMetaColumn);
|
|
184
|
-
const metaColumn = /*#__PURE__*/React.createElement("div", {
|
|
185
|
-
className: metaColumnClasses
|
|
186
|
-
}, selectable && /*#__PURE__*/React.createElement(Checkbox, {
|
|
187
|
-
"aria-labelledby": this.id,
|
|
188
|
-
disabled: checkboxDisabled,
|
|
189
|
-
checked: checked,
|
|
190
|
-
onChange: onCheckboxChange,
|
|
191
|
-
onFocus: this.onCheckboxFocus
|
|
192
|
-
}));
|
|
193
|
-
return columns.map((column, index) => {
|
|
194
|
-
const columnStyle = widths[index] ? {
|
|
195
|
-
width: widths[index]
|
|
196
|
-
} : null;
|
|
197
|
-
const props = {
|
|
198
|
-
column,
|
|
199
|
-
onSort,
|
|
200
|
-
sortKey,
|
|
201
|
-
sortOrder,
|
|
202
|
-
style: columnStyle
|
|
203
|
-
};
|
|
204
|
-
return /*#__PURE__*/React.createElement(HeaderCell, _extends({
|
|
205
|
-
key: column.id,
|
|
206
|
-
"data-test": column.id
|
|
207
|
-
}, props), index === 0 && (draggable || selectable) && metaColumn);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
render() {
|
|
212
|
-
const {
|
|
213
|
-
caption,
|
|
214
|
-
sticky,
|
|
215
|
-
topStickOffset
|
|
216
|
-
} = this.props;
|
|
217
|
-
const {
|
|
218
|
-
fixed,
|
|
219
|
-
widths,
|
|
220
|
-
headerWidth
|
|
221
|
-
} = this.state;
|
|
222
|
-
const regularCells = this.createCells();
|
|
223
|
-
return /*#__PURE__*/React.createElement("thead", {
|
|
224
|
-
id: this.id,
|
|
225
|
-
"data-test": "ring-table-header",
|
|
226
|
-
className: modules_1db4bbca.tableHead
|
|
227
|
-
}, caption && /*#__PURE__*/React.createElement("tr", {
|
|
228
|
-
"data-test": "ring-table-header-row"
|
|
229
|
-
}, /*#__PURE__*/React.createElement("th", {
|
|
230
|
-
className: classNames(modules_1db4bbca.headerCell, modules_1db4bbca.caption),
|
|
231
|
-
colSpan: regularCells.length + 1,
|
|
232
|
-
"data-test": "ring-table-header-cell"
|
|
233
|
-
}, caption)), sticky && /*#__PURE__*/React.createElement(Waypoint, {
|
|
234
|
-
topOffset: topStickOffset,
|
|
235
|
-
onEnter: this.onScrollIn,
|
|
236
|
-
onLeave: this.onScrollOut
|
|
237
|
-
}, waypointChild), /*#__PURE__*/React.createElement("tr", {
|
|
238
|
-
className: modules_1db4bbca.subHeader,
|
|
239
|
-
ref: this.storeColumnsRowNode,
|
|
240
|
-
"data-test": "ring-table-header-row"
|
|
241
|
-
}, regularCells), fixed && sticky && /*#__PURE__*/React.createElement("tr", {
|
|
242
|
-
className: modules_1db4bbca.subHeaderFixed,
|
|
243
|
-
style: {
|
|
244
|
-
width: headerWidth,
|
|
245
|
-
top: topStickOffset
|
|
246
|
-
},
|
|
247
|
-
"data-test": "ring-table-header-row"
|
|
248
|
-
}, this.createCells(widths)));
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
_defineProperty(Header, "propTypes", {
|
|
254
|
-
caption: PropTypes.string,
|
|
255
|
-
selectable: PropTypes.bool,
|
|
256
|
-
draggable: PropTypes.bool,
|
|
257
|
-
checked: PropTypes.bool,
|
|
258
|
-
checkboxDisabled: PropTypes.bool,
|
|
259
|
-
sticky: PropTypes.bool,
|
|
260
|
-
topStickOffset: PropTypes.string,
|
|
261
|
-
onCheckboxChange: PropTypes.func,
|
|
262
|
-
columns: PropTypes.array.isRequired,
|
|
263
|
-
onSort: PropTypes.func,
|
|
264
|
-
sortKey: PropTypes.string,
|
|
265
|
-
sortOrder: PropTypes.bool
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
_defineProperty(Header, "defaultProps", {
|
|
269
|
-
selectable: true,
|
|
270
|
-
draggable: false,
|
|
271
|
-
checked: true,
|
|
272
|
-
sticky: true,
|
|
273
|
-
topStickOffset: '0px',
|
|
274
|
-
onSort: () => {},
|
|
275
|
-
onCheckboxChange: () => {},
|
|
276
|
-
sortKey: 'id',
|
|
277
|
-
sortOrder: true
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
class Cell extends PureComponent {
|
|
281
|
-
render() {
|
|
282
|
-
const classes = classNames(modules_1db4bbca.cell, this.props.className);
|
|
283
|
-
return /*#__PURE__*/React.createElement("td", _extends({}, this.props, {
|
|
284
|
-
className: classes,
|
|
285
|
-
"data-test": joinDataTestAttributes('ring-table-cell', this.props['data-test'])
|
|
286
|
-
}), this.props.children);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
_defineProperty(Cell, "propTypes", {
|
|
292
|
-
children: PropTypes.any,
|
|
293
|
-
className: PropTypes.string,
|
|
294
|
-
'data-test': PropTypes.string
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
const DragHandle = ({
|
|
298
|
-
alwaysShowDragHandle
|
|
299
|
-
}) => {
|
|
300
|
-
const classes = classNames(modules_1db4bbca.dragHandle, {
|
|
301
|
-
[modules_1db4bbca.visibleDragHandle]: alwaysShowDragHandle
|
|
302
|
-
});
|
|
303
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
304
|
-
"data-movable-handle": true,
|
|
305
|
-
title: "Drag",
|
|
306
|
-
className: classes,
|
|
307
|
-
icon: dragIcon
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
DragHandle.propTypes = {
|
|
312
|
-
alwaysShowDragHandle: PropTypes.bool
|
|
313
|
-
};
|
|
314
|
-
class Row extends PureComponent {
|
|
315
|
-
constructor(...args) {
|
|
316
|
-
super(...args);
|
|
317
|
-
|
|
318
|
-
_defineProperty(this, "id", getUID('table-row-'));
|
|
319
|
-
|
|
320
|
-
_defineProperty(this, "onMouseEnter", () => {
|
|
321
|
-
const {
|
|
322
|
-
item,
|
|
323
|
-
onHover
|
|
324
|
-
} = this.props;
|
|
325
|
-
onHover(item);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
_defineProperty(this, "onClick", e => {
|
|
329
|
-
const {
|
|
330
|
-
item
|
|
331
|
-
} = this.props;
|
|
332
|
-
this.props.onClick(item, e);
|
|
333
|
-
|
|
334
|
-
if (e.shiftKey) {
|
|
335
|
-
this.toggleSelection();
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
_defineProperty(this, "onCheckboxFocus", () => {
|
|
340
|
-
this.props.onFocusRestore();
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
_defineProperty(this, "onCheckboxChange", () => {
|
|
344
|
-
this.toggleSelection();
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
_defineProperty(this, "onDoubleClick", () => {
|
|
348
|
-
const {
|
|
349
|
-
item
|
|
350
|
-
} = this.props;
|
|
351
|
-
this.props.onDoubleClick(item);
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
_defineProperty(this, "rowRef", el => {
|
|
355
|
-
this.row = el;
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
toggleSelection() {
|
|
360
|
-
const {
|
|
361
|
-
selectable,
|
|
362
|
-
selected,
|
|
363
|
-
onSelect,
|
|
364
|
-
item
|
|
365
|
-
} = this.props;
|
|
366
|
-
|
|
367
|
-
if (selectable) {
|
|
368
|
-
onSelect(item, !selected);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
render() {
|
|
373
|
-
const _this$props = this.props,
|
|
374
|
-
{
|
|
375
|
-
item,
|
|
376
|
-
columns,
|
|
377
|
-
selectable,
|
|
378
|
-
selected,
|
|
379
|
-
showFocus,
|
|
380
|
-
draggable,
|
|
381
|
-
alwaysShowDragHandle,
|
|
382
|
-
level,
|
|
383
|
-
collapsible,
|
|
384
|
-
parentCollapsible,
|
|
385
|
-
collapsed,
|
|
386
|
-
onCollapse,
|
|
387
|
-
onExpand,
|
|
388
|
-
showDisabledSelection,
|
|
389
|
-
checkboxTooltip,
|
|
390
|
-
innerRef,
|
|
391
|
-
focused,
|
|
392
|
-
autofocus,
|
|
393
|
-
onFocusReset,
|
|
394
|
-
onFocusRestore,
|
|
395
|
-
onHover,
|
|
396
|
-
className,
|
|
397
|
-
'data-test': dataTest
|
|
398
|
-
} = _this$props,
|
|
399
|
-
restProps = _objectWithoutProperties(_this$props, ["item", "columns", "selectable", "selected", "showFocus", "draggable", "alwaysShowDragHandle", "level", "collapsible", "parentCollapsible", "collapsed", "onCollapse", "onExpand", "showDisabledSelection", "checkboxTooltip", "innerRef", "focused", "autofocus", "onFocusReset", "onFocusRestore", "onHover", "className", "data-test"]);
|
|
400
|
-
|
|
401
|
-
const classes = classNames(className, {
|
|
402
|
-
[modules_1db4bbca.row]: true,
|
|
403
|
-
[modules_1db4bbca.rowFocused]: showFocus,
|
|
404
|
-
[modules_1db4bbca.rowSelected]: selected
|
|
405
|
-
});
|
|
406
|
-
const testAttrs = {
|
|
407
|
-
'data-test-focused': showFocus || undefined,
|
|
408
|
-
'data-test-selected': selected || undefined
|
|
409
|
-
};
|
|
410
|
-
const metaColumnClasses = modules_1db4bbca.metaColumn;
|
|
411
|
-
const SUBITEM_OFFSET = 30;
|
|
412
|
-
const COLLAPSIBLE_PARENT_OFFSET = 20;
|
|
413
|
-
const gap = level * SUBITEM_OFFSET + (parentCollapsible ? COLLAPSIBLE_PARENT_OFFSET : 0);
|
|
414
|
-
const metaColumnStyle = {
|
|
415
|
-
paddingLeft: `${gap}px`
|
|
416
|
-
};
|
|
417
|
-
const metaColumn = /*#__PURE__*/React.createElement("div", {
|
|
418
|
-
className: metaColumnClasses,
|
|
419
|
-
style: metaColumnStyle
|
|
420
|
-
}, draggable && /*#__PURE__*/React.createElement(DragHandle, {
|
|
421
|
-
alwaysShowDragHandle: alwaysShowDragHandle
|
|
422
|
-
}), selectable && /*#__PURE__*/React.createElement(Tooltip, {
|
|
423
|
-
title: checkboxTooltip
|
|
424
|
-
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
425
|
-
"aria-labelledby": this.id,
|
|
426
|
-
className: showFocus ? 'ring-checkbox_focus' : '',
|
|
427
|
-
checked: selected,
|
|
428
|
-
onFocus: this.onCheckboxFocus,
|
|
429
|
-
onChange: this.onCheckboxChange,
|
|
430
|
-
tabIndex: "-1"
|
|
431
|
-
})), !selectable && showDisabledSelection && /*#__PURE__*/React.createElement(Tooltip, {
|
|
432
|
-
title: checkboxTooltip
|
|
433
|
-
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
434
|
-
"aria-labelledby": this.id,
|
|
435
|
-
checked: selected,
|
|
436
|
-
disabled: true
|
|
437
|
-
})), collapsible && collapsed && /*#__PURE__*/React.createElement(Button, {
|
|
438
|
-
className: modules_1db4bbca.rowCollapseExpandButton,
|
|
439
|
-
icon: chevronRightIcon,
|
|
440
|
-
onClick: () => onExpand(item)
|
|
441
|
-
}), collapsible && !collapsed && /*#__PURE__*/React.createElement(Button, {
|
|
442
|
-
className: modules_1db4bbca.rowCollapseExpandButton,
|
|
443
|
-
icon: chevronDownIcon,
|
|
444
|
-
onClick: () => onCollapse(item)
|
|
445
|
-
}));
|
|
446
|
-
const cells = columns.map((column, index) => {
|
|
447
|
-
const getValue = column.getValue || (() => item[column.id]);
|
|
448
|
-
|
|
449
|
-
const getDataTest = column.getDataTest || (() => column.id);
|
|
450
|
-
|
|
451
|
-
const value = getValue(item, column);
|
|
452
|
-
const cellClasses = classNames({
|
|
453
|
-
[modules_1db4bbca.cellRight]: column.rightAlign
|
|
454
|
-
}, column.className);
|
|
455
|
-
return /*#__PURE__*/React.createElement(Cell, {
|
|
456
|
-
key: column.id,
|
|
457
|
-
className: cellClasses,
|
|
458
|
-
"data-test": getDataTest(item, column)
|
|
459
|
-
}, index === 0 && (draggable || selectable || showDisabledSelection) && metaColumn, value);
|
|
460
|
-
});
|
|
461
|
-
return /*#__PURE__*/React.createElement("tr", _extends({
|
|
462
|
-
id: this.id,
|
|
463
|
-
ref: composeRefs(this.rowRef, innerRef),
|
|
464
|
-
className: classes,
|
|
465
|
-
tabIndex: "0",
|
|
466
|
-
"data-test": joinDataTestAttributes('ring-table-row', dataTest)
|
|
467
|
-
}, testAttrs, restProps, {
|
|
468
|
-
onMouseMove: this.onMouseEnter,
|
|
469
|
-
onClick: this.onClick,
|
|
470
|
-
onDoubleClick: this.onDoubleClick
|
|
471
|
-
}), cells);
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
_defineProperty(Row, "propTypes", {
|
|
477
|
-
className: PropTypes.string,
|
|
478
|
-
item: PropTypes.object.isRequired,
|
|
479
|
-
columns: PropTypes.array.isRequired,
|
|
480
|
-
selectable: PropTypes.bool,
|
|
481
|
-
showFocus: PropTypes.bool,
|
|
482
|
-
draggable: PropTypes.bool,
|
|
483
|
-
alwaysShowDragHandle: PropTypes.bool,
|
|
484
|
-
selected: PropTypes.bool,
|
|
485
|
-
onHover: PropTypes.func,
|
|
486
|
-
onSelect: PropTypes.func,
|
|
487
|
-
onDoubleClick: PropTypes.func,
|
|
488
|
-
onClick: PropTypes.func,
|
|
489
|
-
onFocusRestore: PropTypes.func,
|
|
490
|
-
level: PropTypes.number,
|
|
491
|
-
collapsible: PropTypes.bool,
|
|
492
|
-
parentCollapsible: PropTypes.bool,
|
|
493
|
-
collapsed: PropTypes.bool,
|
|
494
|
-
onCollapse: PropTypes.func,
|
|
495
|
-
onExpand: PropTypes.func,
|
|
496
|
-
showDisabledSelection: PropTypes.bool,
|
|
497
|
-
checkboxTooltip: PropTypes.string,
|
|
498
|
-
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
499
|
-
focused: PropTypes.bool,
|
|
500
|
-
autofocus: PropTypes.bool,
|
|
501
|
-
onFocusReset: PropTypes.func,
|
|
502
|
-
'data-test': PropTypes.string
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
_defineProperty(Row, "defaultProps", {
|
|
506
|
-
selectable: true,
|
|
507
|
-
showFocus: false,
|
|
508
|
-
draggable: false,
|
|
509
|
-
alwaysShowDragHandle: false,
|
|
510
|
-
selected: false,
|
|
511
|
-
onHover: () => {},
|
|
512
|
-
onSelect: () => {},
|
|
513
|
-
onDoubleClick: () => {},
|
|
514
|
-
onClick: () => {},
|
|
515
|
-
onFocusRestore: () => {},
|
|
516
|
-
level: 0,
|
|
517
|
-
collapsible: false,
|
|
518
|
-
parentCollapsible: false,
|
|
519
|
-
collapsed: false,
|
|
520
|
-
onCollapse: () => {},
|
|
521
|
-
onExpand: () => {}
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
const RowWithFocusSensor = focusSensorHOC(Row);
|
|
525
|
-
class RowWithFocusSensorCallbacks extends PureComponent {
|
|
526
|
-
constructor(...args) {
|
|
527
|
-
super(...args);
|
|
528
|
-
|
|
529
|
-
_defineProperty(this, "onFocus", () => {
|
|
530
|
-
this.props.onFocus(this.props.item);
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
_defineProperty(this, "onSelect", (item, selected) => {
|
|
534
|
-
this.props.onSelect(item, selected);
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
_defineProperty(this, "onCollapse", () => {
|
|
538
|
-
this.props.onCollapse(this.props.item);
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
_defineProperty(this, "onExpand", () => {
|
|
542
|
-
this.props.onExpand(this.props.item);
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
render() {
|
|
547
|
-
return /*#__PURE__*/React.createElement(RowWithFocusSensor, _extends({}, this.props, {
|
|
548
|
-
onFocus: this.onFocus,
|
|
549
|
-
onSelect: this.onSelect,
|
|
550
|
-
onCollapse: this.onCollapse,
|
|
551
|
-
onExpand: this.onExpand
|
|
552
|
-
}));
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
_defineProperty(RowWithFocusSensorCallbacks, "propTypes", Row.propTypes);
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* Interactive table with selection and keyboard navigation support.
|
|
561
|
-
*/
|
|
562
|
-
|
|
563
|
-
class Table extends PureComponent {
|
|
564
|
-
constructor(...args) {
|
|
565
|
-
super(...args);
|
|
566
|
-
|
|
567
|
-
_defineProperty(this, "state", {
|
|
568
|
-
shortcutsScope: getUID('ring-table-'),
|
|
569
|
-
userSelectNone: false
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
_defineProperty(this, "onMouseDown", e => {
|
|
573
|
-
if (e.shiftKey) {
|
|
574
|
-
this.setState({
|
|
575
|
-
userSelectNone: true
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
_defineProperty(this, "onMouseUp", () => {
|
|
581
|
-
if (this.state.userSelectNone) {
|
|
582
|
-
this.setState({
|
|
583
|
-
userSelectNone: false
|
|
584
|
-
});
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
_defineProperty(this, "onRowFocus", row => {
|
|
589
|
-
const {
|
|
590
|
-
selection,
|
|
591
|
-
onSelect
|
|
592
|
-
} = this.props;
|
|
593
|
-
onSelect(selection.focus(row));
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
_defineProperty(this, "onRowSelect", (row, selected) => {
|
|
597
|
-
const {
|
|
598
|
-
selection,
|
|
599
|
-
onSelect
|
|
600
|
-
} = this.props;
|
|
601
|
-
|
|
602
|
-
if (selected) {
|
|
603
|
-
onSelect(selection.select(row));
|
|
604
|
-
} else {
|
|
605
|
-
onSelect(selection.deselect(row));
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
|
|
609
|
-
_defineProperty(this, "onSortEnd", ({
|
|
610
|
-
oldIndex,
|
|
611
|
-
newIndex
|
|
612
|
-
}) => {
|
|
613
|
-
const data = arrayMove(this.props.data, oldIndex, newIndex);
|
|
614
|
-
this.props.onReorder({
|
|
615
|
-
data,
|
|
616
|
-
oldIndex,
|
|
617
|
-
newIndex
|
|
618
|
-
});
|
|
619
|
-
});
|
|
620
|
-
|
|
621
|
-
_defineProperty(this, "onCheckboxChange", e => {
|
|
622
|
-
const {
|
|
623
|
-
checked
|
|
624
|
-
} = e.target;
|
|
625
|
-
const {
|
|
626
|
-
selection,
|
|
627
|
-
onSelect
|
|
628
|
-
} = this.props;
|
|
629
|
-
|
|
630
|
-
if (checked) {
|
|
631
|
-
onSelect(selection.selectAll());
|
|
632
|
-
} else {
|
|
633
|
-
onSelect(selection.reset());
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
this.restoreFocusWithoutScroll();
|
|
637
|
-
});
|
|
638
|
-
|
|
639
|
-
_defineProperty(this, "restoreFocusWithoutScroll", () => {
|
|
640
|
-
const {
|
|
641
|
-
scrollX,
|
|
642
|
-
scrollY
|
|
643
|
-
} = window;
|
|
644
|
-
this.props.onFocusRestore();
|
|
645
|
-
window.scrollTo(scrollX, scrollY);
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
componentDidMount() {
|
|
650
|
-
document.addEventListener('mouseup', this.onMouseUp);
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
componentDidUpdate({
|
|
654
|
-
data,
|
|
655
|
-
selection,
|
|
656
|
-
onSelect,
|
|
657
|
-
selectable,
|
|
658
|
-
remoteSelection
|
|
659
|
-
}) {
|
|
660
|
-
if (data !== this.props.data && remoteSelection) {
|
|
661
|
-
onSelect(selection.cloneWith({
|
|
662
|
-
data: this.props.data
|
|
663
|
-
}));
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
if (!this.props.selectable && this.props.selectable !== selectable) {
|
|
667
|
-
onSelect(selection.resetSelection());
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
componentWillUnmount() {
|
|
672
|
-
document.removeEventListener('mouseup', this.onMouseUp);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
render() {
|
|
676
|
-
const {
|
|
677
|
-
data,
|
|
678
|
-
selection,
|
|
679
|
-
columns,
|
|
680
|
-
caption,
|
|
681
|
-
getItemKey,
|
|
682
|
-
selectable,
|
|
683
|
-
focused,
|
|
684
|
-
isItemSelectable,
|
|
685
|
-
getItemLevel,
|
|
686
|
-
getItemClassName,
|
|
687
|
-
getItemDataTest,
|
|
688
|
-
draggable,
|
|
689
|
-
alwaysShowDragHandle,
|
|
690
|
-
loading,
|
|
691
|
-
onSort,
|
|
692
|
-
sortKey,
|
|
693
|
-
sortOrder,
|
|
694
|
-
loaderClassName,
|
|
695
|
-
stickyHeader,
|
|
696
|
-
stickyHeaderOffset,
|
|
697
|
-
isItemCollapsible,
|
|
698
|
-
isParentCollapsible,
|
|
699
|
-
isItemCollapsed,
|
|
700
|
-
onItemCollapse,
|
|
701
|
-
onItemExpand,
|
|
702
|
-
isDisabledSelectionVisible,
|
|
703
|
-
getCheckboxTooltip,
|
|
704
|
-
onItemDoubleClick,
|
|
705
|
-
onItemClick,
|
|
706
|
-
renderEmpty
|
|
707
|
-
} = this.props; // NOTE: Do not construct new object per render because it causes all rows rerendering
|
|
708
|
-
|
|
709
|
-
const headerProps = {
|
|
710
|
-
caption,
|
|
711
|
-
selectable,
|
|
712
|
-
draggable,
|
|
713
|
-
columns,
|
|
714
|
-
onSort,
|
|
715
|
-
sortKey,
|
|
716
|
-
sortOrder,
|
|
717
|
-
sticky: stickyHeader,
|
|
718
|
-
topStickOffset: stickyHeaderOffset
|
|
719
|
-
};
|
|
720
|
-
const selectedSize = selection.getSelected().size;
|
|
721
|
-
const allSelectedSize = selection.selectAll().getSelected().size;
|
|
722
|
-
headerProps.checked = selectedSize > 0 && selectedSize === allSelectedSize;
|
|
723
|
-
headerProps.onCheckboxChange = this.onCheckboxChange;
|
|
724
|
-
headerProps.checkboxDisabled = this.props.data.length === 0;
|
|
725
|
-
const wrapperClasses = classNames({
|
|
726
|
-
[modules_1db4bbca.tableWrapper]: true,
|
|
727
|
-
[modules_1db4bbca.loading]: loading
|
|
728
|
-
});
|
|
729
|
-
const classes = classNames(this.props.className, {
|
|
730
|
-
[modules_1db4bbca.table]: true,
|
|
731
|
-
[modules_1db4bbca.multiSelection]: selection.getSelected().size > 0,
|
|
732
|
-
[modules_1db4bbca.userSelectNone]: this.state.userSelectNone,
|
|
733
|
-
[modules_1db4bbca.disabledHover]: this.props.disabledHover
|
|
734
|
-
});
|
|
735
|
-
|
|
736
|
-
const renderList = ({
|
|
737
|
-
children,
|
|
738
|
-
props
|
|
739
|
-
}) => {
|
|
740
|
-
const empty = /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
741
|
-
colSpan: this.props.columns.length || '1',
|
|
742
|
-
className: modules_1db4bbca.tableMessage
|
|
743
|
-
}, renderEmpty ? renderEmpty() : null));
|
|
744
|
-
const tbody = (children || []).length > 0 ? children : empty;
|
|
745
|
-
return /*#__PURE__*/React.createElement("table", {
|
|
746
|
-
className: classes,
|
|
747
|
-
"data-test": "ring-table"
|
|
748
|
-
}, /*#__PURE__*/React.createElement(Header, headerProps), /*#__PURE__*/React.createElement("tbody", _extends({}, props, {
|
|
749
|
-
"data-test": "ring-table-body"
|
|
750
|
-
}), tbody));
|
|
751
|
-
};
|
|
752
|
-
|
|
753
|
-
const renderItem = ({
|
|
754
|
-
value,
|
|
755
|
-
index,
|
|
756
|
-
props = {},
|
|
757
|
-
isDragged
|
|
758
|
-
}) => {
|
|
759
|
-
const {
|
|
760
|
-
ref
|
|
761
|
-
} = props,
|
|
762
|
-
restProps = _objectWithoutProperties(props, ["ref"]);
|
|
763
|
-
|
|
764
|
-
const row = /*#__PURE__*/React.createElement(RowWithFocusSensorCallbacks, _extends({
|
|
765
|
-
innerRef: ref,
|
|
766
|
-
key: getItemKey(value),
|
|
767
|
-
level: getItemLevel(value),
|
|
768
|
-
index: index,
|
|
769
|
-
item: value,
|
|
770
|
-
showFocus: selection.isFocused(value),
|
|
771
|
-
autofocus: selection.isFocused(value),
|
|
772
|
-
focused: selection.isFocused(value),
|
|
773
|
-
selectable: selectable && isItemSelectable(value),
|
|
774
|
-
selected: selectable && selection.isSelected(value),
|
|
775
|
-
onFocus: this.onRowFocus,
|
|
776
|
-
onSelect: this.onRowSelect,
|
|
777
|
-
onDoubleClick: onItemDoubleClick,
|
|
778
|
-
onClick: onItemClick,
|
|
779
|
-
collapsible: isItemCollapsible(value),
|
|
780
|
-
parentCollapsible: isParentCollapsible(value),
|
|
781
|
-
collapsed: isItemCollapsed(value),
|
|
782
|
-
onCollapse: onItemCollapse,
|
|
783
|
-
onExpand: onItemExpand,
|
|
784
|
-
showDisabledSelection: isDisabledSelectionVisible(value),
|
|
785
|
-
checkboxTooltip: getCheckboxTooltip(value),
|
|
786
|
-
className: classNames(getItemClassName(value), {
|
|
787
|
-
[modules_1db4bbca.draggingRow]: isDragged
|
|
788
|
-
}),
|
|
789
|
-
draggable: draggable,
|
|
790
|
-
alwaysShowDragHandle: alwaysShowDragHandle,
|
|
791
|
-
columns: columns,
|
|
792
|
-
"data-test": getItemDataTest(value)
|
|
793
|
-
}, restProps));
|
|
794
|
-
return isDragged ? /*#__PURE__*/React.createElement("table", {
|
|
795
|
-
style: _objectSpread2(_objectSpread2({}, props.style), {}, {
|
|
796
|
-
borderSpacing: 0
|
|
797
|
-
})
|
|
798
|
-
}, /*#__PURE__*/React.createElement("tbody", null, row)) : row;
|
|
799
|
-
};
|
|
800
|
-
|
|
801
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
802
|
-
className: wrapperClasses,
|
|
803
|
-
"data-test": "ring-table-wrapper",
|
|
804
|
-
ref: this.props.innerRef
|
|
805
|
-
}, focused && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
806
|
-
map: this.props.shortcutsMap,
|
|
807
|
-
scope: this.state.shortcutsScope
|
|
808
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
809
|
-
role: "presentation",
|
|
810
|
-
onMouseDown: this.onMouseDown
|
|
811
|
-
}, draggable ? /*#__PURE__*/React.createElement(List, {
|
|
812
|
-
values: data,
|
|
813
|
-
renderList: renderList,
|
|
814
|
-
renderItem: renderItem,
|
|
815
|
-
onChange: this.onSortEnd
|
|
816
|
-
}) : renderList({
|
|
817
|
-
children: data.map((value, index) => renderItem({
|
|
818
|
-
value,
|
|
819
|
-
index
|
|
820
|
-
}))
|
|
821
|
-
})), loading && /*#__PURE__*/React.createElement("div", {
|
|
822
|
-
className: modules_1db4bbca.loadingOverlay
|
|
823
|
-
}, /*#__PURE__*/React.createElement(Loader, {
|
|
824
|
-
className: loaderClassName
|
|
825
|
-
})));
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
_defineProperty(Table, "propTypes", {
|
|
831
|
-
className: PropTypes.string,
|
|
832
|
-
loaderClassName: PropTypes.string,
|
|
833
|
-
data: PropTypes.array.isRequired,
|
|
834
|
-
columns: PropTypes.array.isRequired,
|
|
835
|
-
caption: PropTypes.string,
|
|
836
|
-
isItemSelectable: PropTypes.func,
|
|
837
|
-
stickyHeader: PropTypes.bool,
|
|
838
|
-
stickyHeaderOffset: PropTypes.string,
|
|
839
|
-
loading: PropTypes.bool,
|
|
840
|
-
getItemKey: PropTypes.func,
|
|
841
|
-
getItemClassName: PropTypes.func,
|
|
842
|
-
getItemDataTest: PropTypes.func,
|
|
843
|
-
onSort: PropTypes.func,
|
|
844
|
-
onReorder: PropTypes.func,
|
|
845
|
-
sortKey: PropTypes.string,
|
|
846
|
-
sortOrder: PropTypes.bool,
|
|
847
|
-
draggable: PropTypes.bool,
|
|
848
|
-
alwaysShowDragHandle: PropTypes.bool,
|
|
849
|
-
getItemLevel: PropTypes.func,
|
|
850
|
-
isItemCollapsible: PropTypes.func,
|
|
851
|
-
isParentCollapsible: PropTypes.func,
|
|
852
|
-
isItemCollapsed: PropTypes.func,
|
|
853
|
-
onItemCollapse: PropTypes.func,
|
|
854
|
-
onItemExpand: PropTypes.func,
|
|
855
|
-
isDisabledSelectionVisible: PropTypes.func,
|
|
856
|
-
getCheckboxTooltip: PropTypes.func,
|
|
857
|
-
innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func]),
|
|
858
|
-
// focusSensorHOC
|
|
859
|
-
focused: PropTypes.bool,
|
|
860
|
-
onFocusRestore: PropTypes.func,
|
|
861
|
-
// selectionShortcutsHOC
|
|
862
|
-
selection: PropTypes.instanceOf(Selection).isRequired,
|
|
863
|
-
selectable: PropTypes.bool,
|
|
864
|
-
onSelect: PropTypes.func,
|
|
865
|
-
onItemDoubleClick: PropTypes.func,
|
|
866
|
-
onItemClick: PropTypes.func,
|
|
867
|
-
shortcutsMap: PropTypes.object,
|
|
868
|
-
// disableHoverHOC
|
|
869
|
-
disabledHover: PropTypes.bool,
|
|
870
|
-
remoteSelection: PropTypes.bool,
|
|
871
|
-
renderEmpty: PropTypes.func
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
_defineProperty(Table, "defaultProps", {
|
|
875
|
-
isItemSelectable: () => true,
|
|
876
|
-
loading: false,
|
|
877
|
-
onSort: () => {},
|
|
878
|
-
onReorder: () => {},
|
|
879
|
-
getItemKey: item => item.id,
|
|
880
|
-
sortKey: 'id',
|
|
881
|
-
sortOrder: true,
|
|
882
|
-
draggable: false,
|
|
883
|
-
alwaysShowDragHandle: false,
|
|
884
|
-
stickyHeader: true,
|
|
885
|
-
getItemLevel: () => 0,
|
|
886
|
-
getItemClassName: () => null,
|
|
887
|
-
getItemDataTest: () => null,
|
|
888
|
-
isItemCollapsible: () => false,
|
|
889
|
-
isParentCollapsible: () => false,
|
|
890
|
-
isItemCollapsed: () => false,
|
|
891
|
-
onItemCollapse: () => {},
|
|
892
|
-
onItemExpand: () => {},
|
|
893
|
-
onItemDoubleClick: () => {},
|
|
894
|
-
onItemClick: () => {},
|
|
895
|
-
remoteSelection: false,
|
|
896
|
-
isDisabledSelectionVisible: () => {},
|
|
897
|
-
getCheckboxTooltip: () => {}
|
|
898
|
-
});
|
|
899
|
-
|
|
900
|
-
var table = disableHoverHOC(selectionShortcutsHOC(focusSensorHOC(Table)));
|
|
901
|
-
|
|
902
|
-
export default table;
|
|
903
|
-
export { Table };
|