@sis-cc/dotstatsuite-visions 7.18.6 → 7.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/AdvancedFilterDialog/AdvancedFilterDialog.js +459 -0
- package/es/AdvancedFilterDialog/index.js +26 -0
- package/es/HierarchicalFilter/HierarchicalFilter.js +142 -0
- package/es/HierarchicalFilter/index.js +26 -0
- package/es/ScopeList/Item.js +6 -2
- package/es/VirtualizedTree/Item.js +187 -0
- package/es/VirtualizedTree/VirtualizedTree.js +341 -0
- package/es/VirtualizedTree/index.js +38 -0
- package/es/index.js +3 -0
- package/lib/AdvancedFilterDialog/AdvancedFilterDialog.js +524 -0
- package/lib/AdvancedFilterDialog/index.js +16 -0
- package/lib/HierarchicalFilter/HierarchicalFilter.js +169 -0
- package/lib/HierarchicalFilter/index.js +16 -0
- package/lib/ScopeList/Item.js +6 -2
- package/lib/VirtualizedTree/Item.js +223 -0
- package/lib/VirtualizedTree/VirtualizedTree.js +382 -0
- package/lib/VirtualizedTree/index.js +16 -0
- package/lib/index.js +28 -1
- package/package.json +2 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import * as R from 'ramda';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import ListItem from '@material-ui/core/ListItem';
|
|
7
|
+
import Typography from '@material-ui/core/Typography';
|
|
8
|
+
import ListItemText from '@material-ui/core/ListItemText';
|
|
9
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
10
|
+
import SvgIcon from '@material-ui/core/SvgIcon';
|
|
11
|
+
import cx from 'classnames';
|
|
12
|
+
import { Tooltip } from '../';
|
|
13
|
+
|
|
14
|
+
var checkBoxPath = 'M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z';
|
|
15
|
+
var checkPath = 'M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z';
|
|
16
|
+
|
|
17
|
+
var Item = function Item(_ref) {
|
|
18
|
+
var _cx, _extends2, _cx2, _cx3, _cx4, _cx5, _cx6;
|
|
19
|
+
|
|
20
|
+
var classes = _ref.classes,
|
|
21
|
+
id = _ref.id,
|
|
22
|
+
label = _ref.label,
|
|
23
|
+
_ref$description = _ref.description,
|
|
24
|
+
description = _ref$description === undefined ? '' : _ref$description,
|
|
25
|
+
isSelected = _ref.isSelected,
|
|
26
|
+
isDisabled = _ref.isDisabled,
|
|
27
|
+
changeList = _ref.changeList,
|
|
28
|
+
ariaLabel = _ref.ariaLabel,
|
|
29
|
+
NavigateIcon = _ref.NavigateIcon,
|
|
30
|
+
hasChild = _ref.hasChild,
|
|
31
|
+
hasChildrenOnLevel = _ref.hasChildrenOnLevel,
|
|
32
|
+
count = _ref.count,
|
|
33
|
+
svgPath = _ref.svgPath,
|
|
34
|
+
testId = _ref.testId,
|
|
35
|
+
style = _ref.style,
|
|
36
|
+
isRtl = _ref.isRtl,
|
|
37
|
+
accessibility = _ref.accessibility,
|
|
38
|
+
index = _ref.index,
|
|
39
|
+
HTMLRenderer = _ref.HTMLRenderer,
|
|
40
|
+
hierarchicalId = _ref.hierarchicalId,
|
|
41
|
+
labels = _ref.labels,
|
|
42
|
+
_ref$depth = _ref.depth,
|
|
43
|
+
depth = _ref$depth === undefined ? 0 : _ref$depth,
|
|
44
|
+
eventsCallbacks = _ref.eventsCallbacks;
|
|
45
|
+
|
|
46
|
+
var _React$useState = React.useState(false),
|
|
47
|
+
isTooltipShown = _React$useState[0],
|
|
48
|
+
setIsTooltipShown = _React$useState[1];
|
|
49
|
+
|
|
50
|
+
var callbacks = eventsCallbacks(hierarchicalId || id, index);
|
|
51
|
+
var padding = depth * 30 + (depth > 0 && !hasChildrenOnLevel ? 30 : 0) + (!hasChild && hasChildrenOnLevel ? 30 : 0);
|
|
52
|
+
return React.createElement(
|
|
53
|
+
ListItem,
|
|
54
|
+
{
|
|
55
|
+
disableGutters: true,
|
|
56
|
+
classes: { disabled: classes.disabled },
|
|
57
|
+
className: cx(classes.listItemContainer, (_cx = {}, _cx[classes.disableSecondaryAction] = R.not(hasChild), _cx)),
|
|
58
|
+
disabled: isDisabled,
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
style: _extends({}, style, (_extends2 = {
|
|
61
|
+
flexDirection: isRtl ? 'row-reverse' : 'row'
|
|
62
|
+
}, _extends2['' + (isRtl ? 'paddingRight' : 'paddingLeft')] = padding + 'px', _extends2))
|
|
63
|
+
},
|
|
64
|
+
R.and(NavigateIcon, hasChild) && React.createElement(
|
|
65
|
+
IconButton,
|
|
66
|
+
{
|
|
67
|
+
disableRipple: true,
|
|
68
|
+
disableFocusRipple: true,
|
|
69
|
+
className: classes.arrow,
|
|
70
|
+
'aria-label': ariaLabel,
|
|
71
|
+
tabIndex: -1,
|
|
72
|
+
size: 'small',
|
|
73
|
+
color: 'inherit',
|
|
74
|
+
onClick: function onClick() {
|
|
75
|
+
return changeList(hierarchicalId || id);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
React.createElement(NavigateIcon, null)
|
|
79
|
+
),
|
|
80
|
+
React.createElement(ListItemText, _extends({
|
|
81
|
+
tabIndex: 0,
|
|
82
|
+
'aria-label': isDisabled ? R.propOr('', 'disableItemLabel')(labels) + ' ' + label : label,
|
|
83
|
+
'aria-pressed': isSelected,
|
|
84
|
+
'aria-disabled': isDisabled,
|
|
85
|
+
primaryTypographyProps: { noWrap: true, color: 'inherit' },
|
|
86
|
+
secondaryTypographyProps: { color: 'inherit' },
|
|
87
|
+
classes: { root: classes.listItem },
|
|
88
|
+
className: cx((_cx2 = {}, _cx2[classes.accessibilityItemHover] = accessibility, _cx2[classes.listItemSelected] = R.and(isSelected, R.not(isDisabled)), _cx2[classes.listItemHover] = R.not(isDisabled), _cx2)),
|
|
89
|
+
onMouseDown: isDisabled || isTooltipShown ? null : callbacks.onMouseDown,
|
|
90
|
+
onMouseUp: isDisabled || isTooltipShown ? null : callbacks.onMouseUp,
|
|
91
|
+
onMouseEnter: isDisabled || isTooltipShown ? null : callbacks.onMouseEnter
|
|
92
|
+
}, R.pick(['onKeyPress'], callbacks), {
|
|
93
|
+
title: isDisabled ? R.propOr('', 'disableItemLabel')(labels) + ' ' + label : label,
|
|
94
|
+
primary: React.createElement(
|
|
95
|
+
'div',
|
|
96
|
+
{
|
|
97
|
+
className: cx(classes.labelContainer, (_cx3 = {}, _cx3[classes.rtlLabelContainer] = isRtl, _cx3))
|
|
98
|
+
},
|
|
99
|
+
React.createElement(
|
|
100
|
+
SvgIcon,
|
|
101
|
+
{
|
|
102
|
+
color: 'primary',
|
|
103
|
+
className: cx(classes.labelIcon, (_cx4 = {}, _cx4[classes.disabledLabel] = isDisabled, _cx4))
|
|
104
|
+
},
|
|
105
|
+
React.createElement('path', { d: R.and(isSelected, R.not(isDisabled)) ? checkPath : checkBoxPath })
|
|
106
|
+
),
|
|
107
|
+
svgPath && React.createElement(
|
|
108
|
+
SvgIcon,
|
|
109
|
+
{
|
|
110
|
+
color: 'primary',
|
|
111
|
+
className: cx(classes.labelIcon, (_cx5 = {}, _cx5[classes.disabledLabel] = isDisabled, _cx5))
|
|
112
|
+
},
|
|
113
|
+
React.createElement('path', { d: svgPath })
|
|
114
|
+
),
|
|
115
|
+
React.createElement(
|
|
116
|
+
Tooltip,
|
|
117
|
+
{
|
|
118
|
+
title: R.or(R.isNil(HTMLRenderer), R.isEmpty(description)) ? description : React.createElement(HTMLRenderer, { html: description, onClick: function onClick(e) {
|
|
119
|
+
return e.stopPropagation();
|
|
120
|
+
} }),
|
|
121
|
+
enterDelay: 400,
|
|
122
|
+
tabIndex: 0,
|
|
123
|
+
'aria-label': description,
|
|
124
|
+
'aria-hidden': false,
|
|
125
|
+
placement: 'top',
|
|
126
|
+
interactive: Boolean(HTMLRenderer),
|
|
127
|
+
onOpen: function onOpen() {
|
|
128
|
+
return setIsTooltipShown(true);
|
|
129
|
+
},
|
|
130
|
+
onClose: function onClose() {
|
|
131
|
+
return setIsTooltipShown(false);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
React.createElement(
|
|
135
|
+
Typography,
|
|
136
|
+
{
|
|
137
|
+
'data-testid': testId + '_value_' + id,
|
|
138
|
+
color: 'inherit',
|
|
139
|
+
variant: 'body2',
|
|
140
|
+
className: cx(classes.label, (_cx6 = {}, _cx6[classes.disabledLabel] = isDisabled, _cx6[classes.tooltipNotice] = !R.isEmpty(description), _cx6))
|
|
141
|
+
},
|
|
142
|
+
label
|
|
143
|
+
)
|
|
144
|
+
),
|
|
145
|
+
R.not(R.isNil(count)) && React.createElement(
|
|
146
|
+
Typography,
|
|
147
|
+
{ variant: 'body2', className: classes.count },
|
|
148
|
+
'(',
|
|
149
|
+
count,
|
|
150
|
+
')'
|
|
151
|
+
)
|
|
152
|
+
)
|
|
153
|
+
}))
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
Item.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
158
|
+
classes: PropTypes.object,
|
|
159
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
160
|
+
label: PropTypes.string,
|
|
161
|
+
description: PropTypes.string,
|
|
162
|
+
parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
163
|
+
ariaLabel: PropTypes.string,
|
|
164
|
+
NavigateIcon: PropTypes.object,
|
|
165
|
+
isSelected: PropTypes.bool,
|
|
166
|
+
isDisabled: PropTypes.bool,
|
|
167
|
+
hasChild: PropTypes.bool,
|
|
168
|
+
hasChildrenOnLevel: PropTypes.bool,
|
|
169
|
+
isSection: PropTypes.bool,
|
|
170
|
+
changeList: PropTypes.func,
|
|
171
|
+
changeListDescription: PropTypes.string,
|
|
172
|
+
count: PropTypes.number,
|
|
173
|
+
svgPath: PropTypes.string,
|
|
174
|
+
style: PropTypes.object,
|
|
175
|
+
isRtl: PropTypes.bool,
|
|
176
|
+
testId: PropTypes.string,
|
|
177
|
+
accessibility: PropTypes.bool,
|
|
178
|
+
index: PropTypes.number,
|
|
179
|
+
labelRenderer: PropTypes.func,
|
|
180
|
+
HTMLRenderer: PropTypes.func,
|
|
181
|
+
hierarchicalId: PropTypes.string,
|
|
182
|
+
labels: PropTypes.object,
|
|
183
|
+
depth: PropTypes.number,
|
|
184
|
+
eventsCallbacks: PropTypes.func
|
|
185
|
+
} : {};
|
|
186
|
+
|
|
187
|
+
export default Item;
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
2
|
+
|
|
3
|
+
import React, { Fragment, useRef, useEffect, useState, useMemo } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import * as R from 'ramda';
|
|
6
|
+
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer';
|
|
7
|
+
import VirtualizedList from 'react-virtualized/dist/commonjs/List';
|
|
8
|
+
import Button from '@material-ui/core/Button';
|
|
9
|
+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
10
|
+
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
|
|
11
|
+
import List from '@material-ui/core/List';
|
|
12
|
+
import Item from './Item';
|
|
13
|
+
import { useTheme } from '@material-ui/core';
|
|
14
|
+
import { useStyles, height as rowHeight } from '../ScopeList/styles';
|
|
15
|
+
import { getIsRtl } from '../utils';
|
|
16
|
+
|
|
17
|
+
var getSingleItemScope = function getSingleItemScope(item) {
|
|
18
|
+
return [item];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export var getHierarchicalId = function getHierarchicalId(item) {
|
|
22
|
+
return R.prop('hierarchicalId', item) || R.prop('id', item);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export var getDisplayedIds = function getDisplayedIds(items, grouped, expanded) {
|
|
26
|
+
return R.pipe(R.map(function (item) {
|
|
27
|
+
var hierarchicalId = getHierarchicalId(item);
|
|
28
|
+
if (R.has(hierarchicalId, grouped) && R.has(hierarchicalId, expanded)) {
|
|
29
|
+
var children = getDisplayedIds(R.prop(hierarchicalId, grouped), grouped, expanded);
|
|
30
|
+
return R.prepend(hierarchicalId, children);
|
|
31
|
+
}
|
|
32
|
+
return [hierarchicalId];
|
|
33
|
+
}), R.unnest)(items);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export var getHasChildrenOnLevel = function getHasChildrenOnLevel(groupedItems) {
|
|
37
|
+
return function (item) {
|
|
38
|
+
if (R.has(getHierarchicalId(item), groupedItems)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return R.pipe(R.prop(R.propOr('#ROOT', 'parentId', item)), R.find(function (it) {
|
|
42
|
+
return R.has(getHierarchicalId(it), groupedItems);
|
|
43
|
+
}), R.complement(R.isNil))(groupedItems);
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export var getDepth = function getDepth(indexedItems) {
|
|
48
|
+
return function (item) {
|
|
49
|
+
if (R.isNil(item.parentId)) {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
var parent = R.prop(item.parentId, indexedItems);
|
|
53
|
+
return getDepth(indexedItems)(parent) + 1;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var VirtualizedTree = function VirtualizedTree(props) {
|
|
58
|
+
var accessibility = props.accessibility,
|
|
59
|
+
changeSelection = props.changeSelection,
|
|
60
|
+
disableAccessor = props.disableAccessor,
|
|
61
|
+
HTMLRenderer = props.HTMLRenderer,
|
|
62
|
+
items = props.items,
|
|
63
|
+
labelRenderer = props.labelRenderer,
|
|
64
|
+
labels = props.labels,
|
|
65
|
+
withExpandControl = props.withExpandControl,
|
|
66
|
+
_props$maxTreeHeight = props.maxTreeHeight,
|
|
67
|
+
maxTreeHeight = _props$maxTreeHeight === undefined ? 250 : _props$maxTreeHeight,
|
|
68
|
+
_props$getItemScope = props.getItemScope,
|
|
69
|
+
getItemScope = _props$getItemScope === undefined ? getSingleItemScope : _props$getItemScope;
|
|
70
|
+
|
|
71
|
+
var theme = useTheme();
|
|
72
|
+
|
|
73
|
+
var _useState = useState({}),
|
|
74
|
+
expandedIds = _useState[0],
|
|
75
|
+
setExpandedIds = _useState[1];
|
|
76
|
+
|
|
77
|
+
var _useState2 = useState(undefined),
|
|
78
|
+
scrollTop = _useState2[0],
|
|
79
|
+
setScrollTop = _useState2[1];
|
|
80
|
+
|
|
81
|
+
var _useState3 = useState([]),
|
|
82
|
+
shiftIndexes = _useState3[0],
|
|
83
|
+
setShiftIndexes = _useState3[1];
|
|
84
|
+
|
|
85
|
+
var _useState4 = useState({}),
|
|
86
|
+
selectIds = _useState4[0],
|
|
87
|
+
setSelectIds = _useState4[1];
|
|
88
|
+
|
|
89
|
+
var _useState5 = useState(false),
|
|
90
|
+
isMouseDown = _useState5[0],
|
|
91
|
+
setIsMouseDown = _useState5[1];
|
|
92
|
+
|
|
93
|
+
var _useMemo = useMemo(function () {
|
|
94
|
+
var indexedItemsById = R.indexBy(getHierarchicalId, items);
|
|
95
|
+
var groupedItemsByParentId = R.groupBy(R.propOr('#ROOT', 'parentId'), items);
|
|
96
|
+
return { indexedItemsById: indexedItemsById, groupedItemsByParentId: groupedItemsByParentId };
|
|
97
|
+
}, [items]),
|
|
98
|
+
indexedItemsById = _useMemo.indexedItemsById,
|
|
99
|
+
groupedItemsByParentId = _useMemo.groupedItemsByParentId;
|
|
100
|
+
|
|
101
|
+
var list = useMemo(function () {
|
|
102
|
+
return getDisplayedIds(R.propOr([], '#ROOT', groupedItemsByParentId), groupedItemsByParentId, expandedIds);
|
|
103
|
+
}, [items, expandedIds]);
|
|
104
|
+
var multiSelect = function multiSelect(id) {
|
|
105
|
+
var item = R.prop(id, indexedItemsById);
|
|
106
|
+
var ids = R.pipe(getItemScope, R.filter(function (v) {
|
|
107
|
+
return v.isSelected === item.isSelected;
|
|
108
|
+
}), R.map(getHierarchicalId))(item);
|
|
109
|
+
if (R.has(id, selectIds)) {
|
|
110
|
+
setSelectIds(R.omit(ids, selectIds));
|
|
111
|
+
} else {
|
|
112
|
+
setSelectIds(_extends({}, selectIds, R.indexBy(R.identity, ids)));
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var shiftSelect = function shiftSelect(index) {
|
|
116
|
+
if (R.isEmpty(shiftIndexes)) {
|
|
117
|
+
var item = R.nth(index, list);
|
|
118
|
+
var ids = R.pipe(getItemScope, R.filter(function (v) {
|
|
119
|
+
return v.isSelected === item.isSelected;
|
|
120
|
+
}), R.map(getHierarchicalId), R.indexBy(R.identity))(item);
|
|
121
|
+
setShiftIndexes(R.append(index, shiftIndexes));
|
|
122
|
+
setSelectIds(ids);
|
|
123
|
+
} else if (R.length(shiftIndexes) === 1 && index === R.head(shiftIndexes)) {
|
|
124
|
+
setShiftIndexes([]);
|
|
125
|
+
setSelectIds({});
|
|
126
|
+
} else {
|
|
127
|
+
var indexes = [R.head(shiftIndexes), index];
|
|
128
|
+
var isSelected = void 0;
|
|
129
|
+
var _selectIds = R.pipe(R.slice(Math.min.apply(Math, indexes), Math.max.apply(Math, indexes) + 1), function (ids) {
|
|
130
|
+
return R.props(ids, indexedItemsById);
|
|
131
|
+
}, function (items) {
|
|
132
|
+
isSelected = R.pipe(R.head, R.prop('isSelected'))(items);
|
|
133
|
+
return items;
|
|
134
|
+
}, R.map(getItemScope), R.unnest, R.filter(function (v) {
|
|
135
|
+
return v.isSelected === isSelected;
|
|
136
|
+
}), R.map(getHierarchicalId), R.indexBy(R.identity))(list);
|
|
137
|
+
setShiftIndexes(indexes);
|
|
138
|
+
setSelectIds(_selectIds);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var apply = function apply() {
|
|
142
|
+
if (!R.isEmpty(selectIds)) {
|
|
143
|
+
var ids = R.values(selectIds);
|
|
144
|
+
var selection = R.pipe(R.props(ids), R.pluck('id'), R.uniq)(indexedItemsById);
|
|
145
|
+
changeSelection(selection);
|
|
146
|
+
setShiftIndexes([]);
|
|
147
|
+
setSelectIds({});
|
|
148
|
+
setIsMouseDown(false);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var eventsCallbacks = function eventsCallbacks(id, index) {
|
|
152
|
+
return {
|
|
153
|
+
onMouseUp: isMouseDown ? function () {
|
|
154
|
+
apply();
|
|
155
|
+
} : null,
|
|
156
|
+
onMouseDown: function onMouseDown(e) {
|
|
157
|
+
if (e.ctrlKey || e.shiftKey) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
multiSelect(id);
|
|
161
|
+
setIsMouseDown(true);
|
|
162
|
+
},
|
|
163
|
+
onMouseEnter: isMouseDown ? function (e) {
|
|
164
|
+
if (e.ctrlKey || e.shiftKey) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
multiSelect(id);
|
|
168
|
+
} : null,
|
|
169
|
+
onClick: function onClick(e) {
|
|
170
|
+
if (e.ctrlKey) {
|
|
171
|
+
multiSelect(id);
|
|
172
|
+
} else if (e.shiftKey) {
|
|
173
|
+
shiftSelect(index);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
var onKeyUp = function onKeyUp(e) {
|
|
179
|
+
if (e.key === 'Shift' && !R.isEmpty(shiftIndexes)) {
|
|
180
|
+
apply();
|
|
181
|
+
} else if (e.key === 'Control' && !R.isEmpty(selectIds)) {
|
|
182
|
+
apply();
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var isItemSelected = function isItemSelected(item, index) {
|
|
186
|
+
if (!R.isEmpty(shiftIndexes) && index >= Math.min.apply(Math, shiftIndexes) && index <= Math.max.apply(Math, shiftIndexes)) {
|
|
187
|
+
return !item.isSelected;
|
|
188
|
+
}
|
|
189
|
+
if (!R.isEmpty(selectIds) && R.has(getHierarchicalId(item), selectIds)) {
|
|
190
|
+
return !item.isSelected;
|
|
191
|
+
}
|
|
192
|
+
return !!item.isSelected;
|
|
193
|
+
};
|
|
194
|
+
var ref = useRef();
|
|
195
|
+
var classes = useStyles();
|
|
196
|
+
|
|
197
|
+
useEffect(function () {
|
|
198
|
+
var current = ref.current;
|
|
199
|
+
var handler = function handler(event) {
|
|
200
|
+
if (R.or(event.ctrlKey, event.shiftKey)) {
|
|
201
|
+
// ugly hack, to get div element created by react-virtuliase (get scroll height)
|
|
202
|
+
// ReactVirtualized__Grid ReactVirtualized__List made the scrollbar
|
|
203
|
+
var scrollEl = R.path(['children', 0, 'children', 0], current);
|
|
204
|
+
var isBottom = R.gte(R.add(R.prop('scrollTop')(scrollEl), R.prop('clientHeight')(scrollEl)), R.prop('scrollHeight')(scrollEl));
|
|
205
|
+
var nextpos = (scrollTop || scrollEl.scrollTop) + event.deltaY / 2;
|
|
206
|
+
if (R.or(event.deltaY < 0, event.deltaY > 0 && R.not(isBottom))) {
|
|
207
|
+
setScrollTop(nextpos < 0 ? 0 : nextpos);
|
|
208
|
+
}
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
}
|
|
211
|
+
if (R.not(event.ctrlKey) && R.not(event.shiftKey)) {
|
|
212
|
+
setScrollTop(undefined); // should be undefined if the user want use the normal scroll
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
if (scrollTop === 0) {
|
|
216
|
+
setScrollTop(undefined);
|
|
217
|
+
}
|
|
218
|
+
if (R.isNil(current)) return;
|
|
219
|
+
|
|
220
|
+
current.addEventListener('wheel', handler, { passive: false });
|
|
221
|
+
return function () {
|
|
222
|
+
current.removeEventListener('wheel', handler, { passive: false });
|
|
223
|
+
};
|
|
224
|
+
}, [scrollTop]);
|
|
225
|
+
var maxHeight = R.pipe(R.length, R.multiply(rowHeight), R.ifElse(R.gt(maxTreeHeight), R.add(10), R.always(maxTreeHeight)))(list);
|
|
226
|
+
|
|
227
|
+
var expand = function expand(index) {
|
|
228
|
+
var parentId = R.nth(index, list);
|
|
229
|
+
setExpandedIds(R.assoc(parentId, parentId, expandedIds));
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var collapse = function collapse(index) {
|
|
233
|
+
var parentId = R.nth(index, list);
|
|
234
|
+
setExpandedIds(R.dissoc(parentId, expandedIds));
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
var expandAll = function expandAll() {
|
|
238
|
+
setExpandedIds(indexedItemsById);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
var collapseAll = function collapseAll() {
|
|
242
|
+
setExpandedIds({});
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
if (R.isEmpty(list)) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
var isRtl = getIsRtl(theme);
|
|
249
|
+
|
|
250
|
+
return React.createElement(
|
|
251
|
+
Fragment,
|
|
252
|
+
null,
|
|
253
|
+
React.createElement(
|
|
254
|
+
List,
|
|
255
|
+
{ disablePadding: true, style: { height: maxHeight + 2 }, onKeyUp: onKeyUp, ref: ref },
|
|
256
|
+
React.createElement(
|
|
257
|
+
AutoSizer,
|
|
258
|
+
null,
|
|
259
|
+
function (_ref) {
|
|
260
|
+
var height = _ref.height,
|
|
261
|
+
width = _ref.width;
|
|
262
|
+
return React.createElement(VirtualizedList, {
|
|
263
|
+
overscan: 10,
|
|
264
|
+
tabIndex: -1,
|
|
265
|
+
height: height + 2,
|
|
266
|
+
width: width,
|
|
267
|
+
scrollTop: scrollTop // control scroll position with ctrl or shift key
|
|
268
|
+
, rowCount: R.length(list),
|
|
269
|
+
rowHeight: R.add(1)(rowHeight) // 1 is space between elements
|
|
270
|
+
, rowRenderer: function rowRenderer(_ref2) {
|
|
271
|
+
var index = _ref2.index,
|
|
272
|
+
style = _ref2.style;
|
|
273
|
+
|
|
274
|
+
var itemId = R.nth(index, list);
|
|
275
|
+
var item = R.prop(itemId, indexedItemsById);
|
|
276
|
+
return React.createElement(Item, _extends({}, item, {
|
|
277
|
+
id: getHierarchicalId(item),
|
|
278
|
+
label: labelRenderer(item),
|
|
279
|
+
key: getHierarchicalId(item),
|
|
280
|
+
depth: getDepth(indexedItemsById)(item),
|
|
281
|
+
hasChild: R.has(itemId, groupedItemsByParentId),
|
|
282
|
+
hasChildrenOnLevel: getHasChildrenOnLevel(groupedItemsByParentId)(item),
|
|
283
|
+
changeList: R.has(itemId, expandedIds) ? function () {
|
|
284
|
+
return collapse(index);
|
|
285
|
+
} : function () {
|
|
286
|
+
return expand(index);
|
|
287
|
+
},
|
|
288
|
+
NavigateIcon: R.has(itemId, expandedIds) ? ExpandLessIcon : ExpandMoreIcon,
|
|
289
|
+
isRtl: isRtl,
|
|
290
|
+
isDisabled: R.is(Function, disableAccessor) ? disableAccessor(item) : false,
|
|
291
|
+
eventsCallbacks: eventsCallbacks,
|
|
292
|
+
isSelected: isItemSelected(item, index),
|
|
293
|
+
HTMLRenderer: HTMLRenderer,
|
|
294
|
+
classes: classes,
|
|
295
|
+
labels: labels,
|
|
296
|
+
index: index,
|
|
297
|
+
style: style,
|
|
298
|
+
accessibility: accessibility,
|
|
299
|
+
ariaLabel: R.prop('navigateNext')(labels)
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
),
|
|
306
|
+
withExpandControl && React.createElement(
|
|
307
|
+
'div',
|
|
308
|
+
null,
|
|
309
|
+
React.createElement(
|
|
310
|
+
Button,
|
|
311
|
+
{ onClick: collapseAll, color: 'primary' },
|
|
312
|
+
R.prop('colapseAll', labels)
|
|
313
|
+
),
|
|
314
|
+
React.createElement(
|
|
315
|
+
Button,
|
|
316
|
+
{ onClick: expandAll, color: 'primary' },
|
|
317
|
+
R.prop('expandAll', labels)
|
|
318
|
+
)
|
|
319
|
+
)
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
VirtualizedTree.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
324
|
+
accessibility: PropTypes.bool,
|
|
325
|
+
changeSelection: PropTypes.func,
|
|
326
|
+
disableAccessor: PropTypes.func,
|
|
327
|
+
getItemScope: PropTypes.func,
|
|
328
|
+
HTMLRenderer: PropTypes.func,
|
|
329
|
+
isRtl: PropTypes.bool,
|
|
330
|
+
items: PropTypes.array,
|
|
331
|
+
labels: PropTypes.shape({
|
|
332
|
+
disableItemLabel: PropTypes.string,
|
|
333
|
+
colapseAll: PropTypes.string,
|
|
334
|
+
expandAll: PropTypes.string
|
|
335
|
+
}),
|
|
336
|
+
labelRenderer: PropTypes.func,
|
|
337
|
+
withExpandControl: PropTypes.bool,
|
|
338
|
+
maxTreeHeight: PropTypes.number
|
|
339
|
+
} : {};
|
|
340
|
+
|
|
341
|
+
export default VirtualizedTree;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Virtualized Tree visualization of a hierarchical list with handling of single selection
|
|
4
|
+
* and Ctrl and shift binding keys multi selections.
|
|
5
|
+
*
|
|
6
|
+
* @memberOf VISIONS
|
|
7
|
+
* @name VirtualizedTree
|
|
8
|
+
* @tag component
|
|
9
|
+
* @api public
|
|
10
|
+
* @props
|
|
11
|
+
* VirtualizedTree.propTypes = {
|
|
12
|
+
* accessibility: PropTypes.bool,
|
|
13
|
+
* items: PropTypes.arrayOf(PropTypes.shape({
|
|
14
|
+
* id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
15
|
+
* label: PropTypes.string,
|
|
16
|
+
* parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
17
|
+
* isSelected: PropTypes.bool,
|
|
18
|
+
* isDisabled: PropTypes.bool,
|
|
19
|
+
* count: PropTypes.number,
|
|
20
|
+
* path: PropTypes.arrayOf(PropTypes.shape({
|
|
21
|
+
* id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
22
|
+
* label: PropTypes.string,
|
|
23
|
+
* parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
24
|
+
* isSelected: PropTypes.bool,
|
|
25
|
+
* })),
|
|
26
|
+
* [yourDisplayAccessorKey]: PropTypes.bool,
|
|
27
|
+
* })),
|
|
28
|
+
* labels: PropTypes.shape({
|
|
29
|
+
* childrenNavigateDesc: PropTypes.string,
|
|
30
|
+
* navigateNext: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
31
|
+
* backHelper: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
32
|
+
* disableItemLabel: PropTypes.string,
|
|
33
|
+
* }),
|
|
34
|
+
* labelRenderer: PropTypes.func,
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export { default } from './VirtualizedTree';
|
package/es/index.js
CHANGED
|
@@ -43,4 +43,7 @@ export { default as Tooltip } from './Tooltip';
|
|
|
43
43
|
export { default as UserRightForm } from './UserRightForm';
|
|
44
44
|
export { default as VerticalButton } from './VerticalButton';
|
|
45
45
|
export { default as AuthDialog } from './AuthDialog';
|
|
46
|
+
export { default as VirtualizedTree } from './VirtualizedTree';
|
|
47
|
+
export { default as AdvancedFilterDialog } from './AdvancedFilterDialog';
|
|
48
|
+
export { default as HierarchicalFilter } from './HierarchicalFilter';
|
|
46
49
|
export { sisccTheme, innerPalette, T4_BREAKPOINTS } from './theme';
|