@sis-cc/dotstatsuite-visions 10.5.1 → 10.6.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 +19 -114
- package/es/AdvancedFilterDialog/SelectionModeMenu.js +85 -0
- package/es/ExpansionPanel/ExpansionPanel.js +5 -5
- package/es/ExpansionPanel/styles.js +11 -2
- package/es/HierarchicalFilter/HierarchicalFilter.js +25 -9
- package/es/VirtualizedTree/Item.js +7 -7
- package/es/VirtualizedTree/VirtualizedTree.js +39 -35
- package/es/VirtualizedTree/utils.js +150 -0
- package/es/VirtualizedTree/withExpansionTree.js +1 -1
- package/es/VirtualizedTree/withSpotlight.js +2 -1
- package/lib/AdvancedFilterDialog/AdvancedFilterDialog.js +24 -126
- package/lib/AdvancedFilterDialog/SelectionModeMenu.js +118 -0
- package/lib/ExpansionPanel/ExpansionPanel.js +5 -5
- package/lib/ExpansionPanel/styles.js +11 -2
- package/lib/HierarchicalFilter/HierarchicalFilter.js +28 -11
- package/lib/VirtualizedTree/Item.js +7 -7
- package/lib/VirtualizedTree/VirtualizedTree.js +53 -48
- package/lib/VirtualizedTree/utils.js +159 -0
- package/lib/VirtualizedTree/withExpansionTree.js +2 -2
- package/lib/VirtualizedTree/withSpotlight.js +4 -3
- package/package.json +1 -1
- package/umd/@sis-cc/dotstatsuite-visions.js +362 -190
- package/umd/@sis-cc/dotstatsuite-visions.min.js +9 -9
- package/umd/@sis-cc/dotstatsuite-visions.min.js.map +1 -1
|
@@ -6,26 +6,25 @@ import React, { useState, Fragment } from 'react';
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import * as R from 'ramda';
|
|
8
8
|
import cx from 'classnames';
|
|
9
|
-
import {
|
|
9
|
+
import { getSingleDisableAccessor, getHierDisableAccessor, getScopeGetters } from '../VirtualizedTree/utils';
|
|
10
10
|
import IconButton from '@material-ui/core/Button';
|
|
11
11
|
import Dialog from '@material-ui/core/Dialog';
|
|
12
12
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
|
13
13
|
import DialogContent from '@material-ui/core/DialogContent';
|
|
14
14
|
import DialogActions from '@material-ui/core/DialogActions';
|
|
15
|
-
import Card from '@material-ui/core/Card';
|
|
16
|
-
import CardContent from '@material-ui/core/CardContent';
|
|
17
15
|
import Paper from '@material-ui/core/Paper';
|
|
18
16
|
import Grid from '@material-ui/core/Grid';
|
|
19
17
|
import Typography from '@material-ui/core/Typography';
|
|
20
18
|
import CloseIcon from '@material-ui/icons/Close';
|
|
21
|
-
import HintIcon from '@material-ui/icons/EmojiObjects';
|
|
22
19
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
23
20
|
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
|
|
24
21
|
import Draggable from 'react-draggable';
|
|
22
|
+
import SelectionModeMenu from './SelectionModeMenu';
|
|
25
23
|
import { Button, Spotlight, VirtualizedTree } from '..';
|
|
26
24
|
import { withExpansionTree } from '../VirtualizedTree/withExpansionTree';
|
|
27
25
|
import { withSpotlight } from '../VirtualizedTree/withSpotlight';
|
|
28
26
|
import { makeStyles } from '@material-ui/core/styles';
|
|
27
|
+
|
|
29
28
|
import singleImg from './images/single-selection.png';
|
|
30
29
|
import childrenImg from './images/children-selection.png';
|
|
31
30
|
import branchImg from './images/branch-selection.png';
|
|
@@ -148,110 +147,6 @@ var useStyles = makeStyles(function (theme) {
|
|
|
148
147
|
};
|
|
149
148
|
});
|
|
150
149
|
|
|
151
|
-
export var getScopeGetters = function getScopeGetters(items, groupedItems, disableAccessor) {
|
|
152
|
-
var indexed = R.indexBy(getHierarchicalId, items);
|
|
153
|
-
return {
|
|
154
|
-
all: function all() {
|
|
155
|
-
return R.reject(disableAccessor, items);
|
|
156
|
-
},
|
|
157
|
-
single: function single(item) {
|
|
158
|
-
return [item];
|
|
159
|
-
},
|
|
160
|
-
children: function children(item) {
|
|
161
|
-
var childItems = R.propOr([], getHierarchicalId(item), groupedItems);
|
|
162
|
-
return R.reject(disableAccessor, R.prepend(item, childItems));
|
|
163
|
-
},
|
|
164
|
-
branch: function branch(item) {
|
|
165
|
-
var reccurse = function reccurse(_item) {
|
|
166
|
-
var childItems = R.pipe(R.propOr([], getHierarchicalId(_item)), R.map(reccurse), R.unnest)(groupedItems);
|
|
167
|
-
|
|
168
|
-
return R.prepend(_item, childItems);
|
|
169
|
-
};
|
|
170
|
-
var items = reccurse(item);
|
|
171
|
-
return R.reject(disableAccessor, items);
|
|
172
|
-
},
|
|
173
|
-
level: function level(item) {
|
|
174
|
-
var depth = getDepth(indexed)(item);
|
|
175
|
-
return R.filter(function (it) {
|
|
176
|
-
return !disableAccessor(it) && getDepth(indexed)(it) === depth;
|
|
177
|
-
}, items);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
183
|
-
var isOpen = _ref.isOpen,
|
|
184
|
-
onSelect = _ref.onSelect,
|
|
185
|
-
options = _ref.options,
|
|
186
|
-
selected = _ref.selected,
|
|
187
|
-
classes = _ref.classes,
|
|
188
|
-
isNarrow = _ref.isNarrow,
|
|
189
|
-
hint = _ref.hint,
|
|
190
|
-
maxHeight = _ref.maxHeight;
|
|
191
|
-
|
|
192
|
-
if (!isOpen) {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
return React.createElement(
|
|
196
|
-
'div',
|
|
197
|
-
{ className: isNarrow ? classes.narrowSelectionMenu : classes.selectionMenu },
|
|
198
|
-
React.createElement(
|
|
199
|
-
Card,
|
|
200
|
-
{ style: { maxHeight: maxHeight - 5, overflow: 'auto' } },
|
|
201
|
-
React.createElement(
|
|
202
|
-
CardContent,
|
|
203
|
-
{ className: classes.selectModeContainer },
|
|
204
|
-
R.map(function (_ref2) {
|
|
205
|
-
var value = _ref2.value,
|
|
206
|
-
label = _ref2.label,
|
|
207
|
-
img = _ref2.img;
|
|
208
|
-
return React.createElement(
|
|
209
|
-
Button,
|
|
210
|
-
{
|
|
211
|
-
className: classes.selectButton,
|
|
212
|
-
selected: value === selected,
|
|
213
|
-
key: value,
|
|
214
|
-
onClick: function onClick() {
|
|
215
|
-
return onSelect(value);
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
React.createElement(
|
|
219
|
-
Paper,
|
|
220
|
-
{ className: classes.selectModeItem, key: value },
|
|
221
|
-
React.createElement(
|
|
222
|
-
Typography,
|
|
223
|
-
{ variant: 'body2' },
|
|
224
|
-
label
|
|
225
|
-
),
|
|
226
|
-
!R.isNil(img) && R.is(String, img) && React.createElement('img', { src: img, alt: value })
|
|
227
|
-
)
|
|
228
|
-
);
|
|
229
|
-
}, options)
|
|
230
|
-
),
|
|
231
|
-
React.createElement(
|
|
232
|
-
'div',
|
|
233
|
-
{ className: classes.hint },
|
|
234
|
-
React.createElement(HintIcon, null),
|
|
235
|
-
React.createElement(
|
|
236
|
-
Typography,
|
|
237
|
-
{ variant: 'body2' },
|
|
238
|
-
hint
|
|
239
|
-
)
|
|
240
|
-
)
|
|
241
|
-
)
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
SelectionModeMenu.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
245
|
-
classes: PropTypes.object,
|
|
246
|
-
hint: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
247
|
-
isNarrow: PropTypes.bool,
|
|
248
|
-
isOpen: PropTypes.bool,
|
|
249
|
-
onSelect: PropTypes.func,
|
|
250
|
-
options: PropTypes.array,
|
|
251
|
-
selected: PropTypes.string,
|
|
252
|
-
maxHeight: PropTypes.number
|
|
253
|
-
} : {};
|
|
254
|
-
|
|
255
150
|
var icons = {
|
|
256
151
|
single: singleIcon,
|
|
257
152
|
children: childrenIcon,
|
|
@@ -272,13 +167,15 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
272
167
|
isOpen = props.isOpen,
|
|
273
168
|
isNarrow = props.isNarrow,
|
|
274
169
|
labels = props.labels,
|
|
275
|
-
|
|
170
|
+
_props$disableAccesso = props.disableAccessor,
|
|
171
|
+
disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
|
|
276
172
|
expandAll = props.expandAll,
|
|
277
173
|
collapseAll = props.collapseAll,
|
|
278
174
|
spotlight = props.spotlight,
|
|
279
175
|
setSpotlight = props.setSpotlight,
|
|
280
176
|
expandedIds = props.expandedIds,
|
|
281
|
-
|
|
177
|
+
allItems = props.allItems,
|
|
178
|
+
rest = _objectWithoutProperties(props, ['id', 'title', 'items', 'labelRenderer', 'onClose', 'changeSelection', 'isOpen', 'isNarrow', 'labels', 'disableAccessor', 'expandAll', 'collapseAll', 'spotlight', 'setSpotlight', 'expandedIds', 'allItems']);
|
|
282
179
|
|
|
283
180
|
var _useState = useState('single'),
|
|
284
181
|
selectionMode = _useState[0],
|
|
@@ -334,10 +231,16 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
334
231
|
img: allImg
|
|
335
232
|
}];
|
|
336
233
|
|
|
234
|
+
var _allGroupedItems = R.pipe(R.map(function (item) {
|
|
235
|
+
return _extends({}, item, {
|
|
236
|
+
isSelected: R.has(item.id, selection) ? !item.isSelected : !!item.isSelected
|
|
237
|
+
});
|
|
238
|
+
}), R.groupBy(R.propOr('#ROOT', 'parentId')))(allItems);
|
|
239
|
+
var _disableAccessor = selectionMode === 'single' || selectionMode === 'level' ? getSingleDisableAccessor(_allGroupedItems, disableAccessor) : getHierDisableAccessor(_allGroupedItems, groupedFilteredItems, disableAccessor);
|
|
337
240
|
var isDisabled = function isDisabled(item) {
|
|
338
241
|
return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
|
|
339
242
|
};
|
|
340
|
-
var
|
|
243
|
+
var scopeGetter = R.prop(selectionMode, getScopeGetters);
|
|
341
244
|
|
|
342
245
|
var onChangeSelection = function onChangeSelection(ids) {
|
|
343
246
|
var nextSelection = R.reduce(function (acc, id) {
|
|
@@ -456,14 +359,15 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
456
359
|
maxHeight: listHeight
|
|
457
360
|
}),
|
|
458
361
|
React.createElement(VirtualizedTree, _extends({}, rest, {
|
|
459
|
-
disableAccessor:
|
|
362
|
+
disableAccessor: _disableAccessor,
|
|
363
|
+
isGreyed: isDisabled,
|
|
460
364
|
labels: labels,
|
|
461
365
|
labelRenderer: labelRenderer,
|
|
462
366
|
items: selectionItems,
|
|
463
367
|
changeSelection: onChangeSelection,
|
|
464
368
|
withExpandControl: true,
|
|
465
369
|
treeHeight: listHeight,
|
|
466
|
-
|
|
370
|
+
scopeGetter: scopeGetter,
|
|
467
371
|
expandedIds: expandedIds
|
|
468
372
|
}))
|
|
469
373
|
)
|
|
@@ -546,7 +450,8 @@ AdvancedFilterDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
546
450
|
collapseAll: PropTypes.func,
|
|
547
451
|
spotlight: PropTypes.object,
|
|
548
452
|
setSpotlight: PropTypes.func,
|
|
549
|
-
expandedIds: PropTypes.object
|
|
453
|
+
expandedIds: PropTypes.object,
|
|
454
|
+
allItems: PropTypes.array
|
|
550
455
|
} : {};
|
|
551
456
|
|
|
552
457
|
export default withSpotlight(withExpansionTree(AdvancedFilterDialog));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
import Card from '@material-ui/core/Card';
|
|
5
|
+
import CardContent from '@material-ui/core/CardContent';
|
|
6
|
+
import Paper from '@material-ui/core/Paper';
|
|
7
|
+
import Typography from '@material-ui/core/Typography';
|
|
8
|
+
import HintIcon from '@material-ui/icons/EmojiObjects';
|
|
9
|
+
import { Button } from '..';
|
|
10
|
+
|
|
11
|
+
var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
12
|
+
var isOpen = _ref.isOpen,
|
|
13
|
+
onSelect = _ref.onSelect,
|
|
14
|
+
options = _ref.options,
|
|
15
|
+
selected = _ref.selected,
|
|
16
|
+
classes = _ref.classes,
|
|
17
|
+
isNarrow = _ref.isNarrow,
|
|
18
|
+
hint = _ref.hint,
|
|
19
|
+
maxHeight = _ref.maxHeight;
|
|
20
|
+
|
|
21
|
+
if (!isOpen) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return React.createElement(
|
|
25
|
+
'div',
|
|
26
|
+
{ className: isNarrow ? classes.narrowSelectionMenu : classes.selectionMenu },
|
|
27
|
+
React.createElement(
|
|
28
|
+
Card,
|
|
29
|
+
{ style: { maxHeight: maxHeight - 5, overflow: 'auto' } },
|
|
30
|
+
React.createElement(
|
|
31
|
+
CardContent,
|
|
32
|
+
{ className: classes.selectModeContainer },
|
|
33
|
+
R.map(function (_ref2) {
|
|
34
|
+
var value = _ref2.value,
|
|
35
|
+
label = _ref2.label,
|
|
36
|
+
img = _ref2.img;
|
|
37
|
+
return React.createElement(
|
|
38
|
+
Button,
|
|
39
|
+
{
|
|
40
|
+
className: classes.selectButton,
|
|
41
|
+
selected: value === selected,
|
|
42
|
+
key: value,
|
|
43
|
+
onClick: function onClick() {
|
|
44
|
+
return onSelect(value);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
React.createElement(
|
|
48
|
+
Paper,
|
|
49
|
+
{ className: classes.selectModeItem, key: value },
|
|
50
|
+
React.createElement(
|
|
51
|
+
Typography,
|
|
52
|
+
{ variant: 'body2' },
|
|
53
|
+
label
|
|
54
|
+
),
|
|
55
|
+
!R.isNil(img) && R.is(String, img) && React.createElement('img', { src: img, alt: value })
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}, options)
|
|
59
|
+
),
|
|
60
|
+
React.createElement(
|
|
61
|
+
'div',
|
|
62
|
+
{ className: classes.hint },
|
|
63
|
+
React.createElement(HintIcon, null),
|
|
64
|
+
React.createElement(
|
|
65
|
+
Typography,
|
|
66
|
+
{ variant: 'body2' },
|
|
67
|
+
hint
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
SelectionModeMenu.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
75
|
+
classes: PropTypes.object,
|
|
76
|
+
hint: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
77
|
+
isNarrow: PropTypes.bool,
|
|
78
|
+
isOpen: PropTypes.bool,
|
|
79
|
+
onSelect: PropTypes.func,
|
|
80
|
+
options: PropTypes.array,
|
|
81
|
+
selected: PropTypes.string,
|
|
82
|
+
maxHeight: PropTypes.number
|
|
83
|
+
} : {};
|
|
84
|
+
|
|
85
|
+
export default SelectionModeMenu;
|
|
@@ -14,7 +14,7 @@ import { withBlank } from '../utils';
|
|
|
14
14
|
import Tooltip from '../Tooltip';
|
|
15
15
|
|
|
16
16
|
var CustomExpansionPanel = function CustomExpansionPanel(_ref) {
|
|
17
|
-
var _cx, _cx2;
|
|
17
|
+
var _cx, _cx2, _cx3, _cx4, _cx5;
|
|
18
18
|
|
|
19
19
|
var id = _ref.id,
|
|
20
20
|
topElementComponent = _ref.topElementComponent,
|
|
@@ -58,10 +58,10 @@ var CustomExpansionPanel = function CustomExpansionPanel(_ref) {
|
|
|
58
58
|
AccordionSummary,
|
|
59
59
|
{
|
|
60
60
|
'data-testid': testId + '_panel',
|
|
61
|
-
className: classes.container,
|
|
61
|
+
className: cx(classes.container, (_cx2 = {}, _cx2[classes.moreFiltersContainer] = moreFilters, _cx2)),
|
|
62
62
|
classes: {
|
|
63
|
-
content: cx(classes.content, classes.ellipsis),
|
|
64
|
-
expandIcon: classes.iconSummaryPanel
|
|
63
|
+
content: cx(classes.content, classes.ellipsis, (_cx3 = {}, _cx3[classes.moreFiltersContent] = moreFilters, _cx3)),
|
|
64
|
+
expandIcon: cx(classes.iconSummaryPanel, (_cx4 = {}, _cx4[classes.moreFiltersExpandIcon] = moreFilters, _cx4))
|
|
65
65
|
},
|
|
66
66
|
expandIcon: React.createElement(ExpandMoreIcon, null),
|
|
67
67
|
'aria-controls': id,
|
|
@@ -110,7 +110,7 @@ var CustomExpansionPanel = function CustomExpansionPanel(_ref) {
|
|
|
110
110
|
React.createElement(
|
|
111
111
|
AccordionDetails,
|
|
112
112
|
{
|
|
113
|
-
className: cx(classes.details, (
|
|
113
|
+
className: cx(classes.details, (_cx5 = {}, _cx5[classes.overflow] = overflow, _cx5[classes.height] = maxHeight, _cx5))
|
|
114
114
|
},
|
|
115
115
|
children
|
|
116
116
|
)
|
|
@@ -13,6 +13,9 @@ export var useStyles = makeStyles(function (theme) {
|
|
|
13
13
|
alignItems: 'flex-start',
|
|
14
14
|
padding: theme.spacing(0)
|
|
15
15
|
},
|
|
16
|
+
moreFiltersContainer: {
|
|
17
|
+
alignItems: 'flex-end'
|
|
18
|
+
},
|
|
16
19
|
ellipsis: {
|
|
17
20
|
whiteSpace: 'nowrap',
|
|
18
21
|
overflow: 'hidden',
|
|
@@ -24,6 +27,9 @@ export var useStyles = makeStyles(function (theme) {
|
|
|
24
27
|
alignContent: 'space-between',
|
|
25
28
|
margin: theme.spacing(0.5, 0) + ' !important'
|
|
26
29
|
},
|
|
30
|
+
moreFiltersContent: {
|
|
31
|
+
margin: theme.spacing(0, 0) + ' !important'
|
|
32
|
+
},
|
|
27
33
|
details: {
|
|
28
34
|
display: 'flex',
|
|
29
35
|
padding: theme.spacing(0),
|
|
@@ -58,6 +64,9 @@ export var useStyles = makeStyles(function (theme) {
|
|
|
58
64
|
padding: theme.spacing(0.5, 0.5),
|
|
59
65
|
margin: theme.spacing(0, 1, 0, 0)
|
|
60
66
|
},
|
|
67
|
+
moreFiltersExpandIcon: {
|
|
68
|
+
padding: theme.spacing(0, 0.5)
|
|
69
|
+
},
|
|
61
70
|
fullWidth: {
|
|
62
71
|
width: '100%'
|
|
63
72
|
},
|
|
@@ -73,8 +82,8 @@ export var useStyles = makeStyles(function (theme) {
|
|
|
73
82
|
title: {
|
|
74
83
|
padding: 0,
|
|
75
84
|
fontFamily: 'Roboto Slab, serif',
|
|
76
|
-
fontSize:
|
|
77
|
-
color: '
|
|
85
|
+
fontSize: 17,
|
|
86
|
+
color: theme.palette.grey['A700']
|
|
78
87
|
}
|
|
79
88
|
};
|
|
80
89
|
});
|
|
@@ -8,13 +8,16 @@ import ZoomOutMapIcon from '@material-ui/icons/ZoomOutMap';
|
|
|
8
8
|
import { ExpansionPanel, Tag as InternalTag, VerticalButton, Spotlight, VirtualizedTree, Tooltip } from '../';
|
|
9
9
|
import { withExpansionTree } from '../VirtualizedTree/withExpansionTree';
|
|
10
10
|
import { withSpotlight } from '../VirtualizedTree/withSpotlight';
|
|
11
|
+
import { getSingleDisableAccessor } from '../VirtualizedTree/utils';
|
|
11
12
|
import { useStyles } from '../ScopeList/styles';
|
|
12
13
|
import { useTheme } from '@material-ui/core';
|
|
13
14
|
import { getIsRtl } from '../utils';
|
|
14
15
|
|
|
15
|
-
var getCounter = function getCounter(items,
|
|
16
|
-
var count = R.pipe(R.filter(
|
|
17
|
-
|
|
16
|
+
var getCounter = function getCounter(items, disableAccessor, tagAccessor) {
|
|
17
|
+
var count = R.pipe(R.filter(function (item) {
|
|
18
|
+
return R.prop('isSelected', item) && !disableAccessor(item);
|
|
19
|
+
}), R.map(R.prop('id')), R.uniq, R.length)(items);
|
|
20
|
+
var total = R.pipe(R.when(R.always(R.is(Function, disableAccessor)), R.reject(disableAccessor)), R.map(R.prop('id')), R.uniq, R.length)(items);
|
|
18
21
|
if (R.is(Function, tagAccessor)) {
|
|
19
22
|
return tagAccessor(count, total);
|
|
20
23
|
}
|
|
@@ -38,17 +41,24 @@ var HierarchicalFilter = function HierarchicalFilter(props) {
|
|
|
38
41
|
label = props.label,
|
|
39
42
|
labels = props.labels,
|
|
40
43
|
tagAccessor = props.tagAccessor,
|
|
41
|
-
displayAccessor = props.displayAccessor,
|
|
42
44
|
expandedIds = props.expandedIds,
|
|
43
45
|
spotlight = props.spotlight,
|
|
44
46
|
setSpotlight = props.setSpotlight,
|
|
45
|
-
hasSpotlight = props.hasSpotlight
|
|
47
|
+
hasSpotlight = props.hasSpotlight,
|
|
48
|
+
_props$disableAccesso = props.disableAccessor,
|
|
49
|
+
disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
|
|
50
|
+
allItems = props.allItems;
|
|
46
51
|
|
|
47
52
|
var classes = useStyles({ accessibility: accessibility });
|
|
48
53
|
var theme = useTheme();
|
|
49
54
|
var isRtl = getIsRtl(theme);
|
|
50
55
|
var Chip = R.isNil(Tag) ? InternalTag : Tag;
|
|
51
|
-
var
|
|
56
|
+
var _allGroupedItems = R.groupBy(R.propOr('#ROOT', 'parentId'), allItems);
|
|
57
|
+
var _disableAccessor = getSingleDisableAccessor(_allGroupedItems, disableAccessor);
|
|
58
|
+
var tagValue = getCounter(items, _disableAccessor, tagAccessor);
|
|
59
|
+
var isDisabled = function isDisabled(item) {
|
|
60
|
+
return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
|
|
61
|
+
};
|
|
52
62
|
|
|
53
63
|
var onSelect = function onSelect(values) {
|
|
54
64
|
changeSelection(id, values);
|
|
@@ -108,7 +118,13 @@ var HierarchicalFilter = function HierarchicalFilter(props) {
|
|
|
108
118
|
tagValue
|
|
109
119
|
)
|
|
110
120
|
}, expansionPanelProps),
|
|
111
|
-
React.createElement(VirtualizedTree, _extends({}, props, {
|
|
121
|
+
React.createElement(VirtualizedTree, _extends({}, props, {
|
|
122
|
+
items: items,
|
|
123
|
+
changeSelection: onSelect,
|
|
124
|
+
isRtl: isRtl,
|
|
125
|
+
disableAccessor: _disableAccessor,
|
|
126
|
+
isGreyed: isDisabled
|
|
127
|
+
}))
|
|
112
128
|
);
|
|
113
129
|
};
|
|
114
130
|
|
|
@@ -119,7 +135,6 @@ HierarchicalFilter.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
119
135
|
changeSelection: PropTypes.func,
|
|
120
136
|
onChangeActivePanel: PropTypes.func,
|
|
121
137
|
disableAccessor: PropTypes.func,
|
|
122
|
-
displayAccessor: PropTypes.func,
|
|
123
138
|
HTMLRenderer: PropTypes.func,
|
|
124
139
|
isRtl: PropTypes.bool,
|
|
125
140
|
items: PropTypes.array,
|
|
@@ -137,7 +152,8 @@ HierarchicalFilter.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
137
152
|
expandedIds: PropTypes.object,
|
|
138
153
|
spotlight: PropTypes.object,
|
|
139
154
|
setSpotlight: PropTypes.func,
|
|
140
|
-
hasSpotlight: PropTypes.bool
|
|
155
|
+
hasSpotlight: PropTypes.bool,
|
|
156
|
+
allItems: PropTypes.array
|
|
141
157
|
} : {};
|
|
142
158
|
|
|
143
159
|
export default withSpotlight(withExpansionTree(HierarchicalFilter));
|
|
@@ -24,6 +24,7 @@ var Item = function Item(_ref) {
|
|
|
24
24
|
description = _ref$description === undefined ? '' : _ref$description,
|
|
25
25
|
isSelected = _ref.isSelected,
|
|
26
26
|
isDisabled = _ref.isDisabled,
|
|
27
|
+
isGreyed = _ref.isGreyed,
|
|
27
28
|
changeList = _ref.changeList,
|
|
28
29
|
ariaLabel = _ref.ariaLabel,
|
|
29
30
|
NavigateIcon = _ref.NavigateIcon,
|
|
@@ -31,7 +32,6 @@ var Item = function Item(_ref) {
|
|
|
31
32
|
hasChildrenOnLevel = _ref.hasChildrenOnLevel,
|
|
32
33
|
count = _ref.count,
|
|
33
34
|
svgPath = _ref.svgPath,
|
|
34
|
-
testId = _ref.testId,
|
|
35
35
|
style = _ref.style,
|
|
36
36
|
isRtl = _ref.isRtl,
|
|
37
37
|
accessibility = _ref.accessibility,
|
|
@@ -77,6 +77,7 @@ var Item = function Item(_ref) {
|
|
|
77
77
|
React.createElement(NavigateIcon, null)
|
|
78
78
|
),
|
|
79
79
|
React.createElement(ListItemText, _extends({
|
|
80
|
+
'data-testid': 'value_' + id,
|
|
80
81
|
tabIndex: 0,
|
|
81
82
|
'aria-label': isDisabled ? R.propOr('', 'disableItemLabel')(labels) + ' ' + label : label,
|
|
82
83
|
'aria-pressed': isSelected,
|
|
@@ -103,13 +104,13 @@ var Item = function Item(_ref) {
|
|
|
103
104
|
color: 'primary',
|
|
104
105
|
className: cx(classes.labelIcon, (_cx3 = {}, _cx3[classes.disabledLabel] = isDisabled, _cx3))
|
|
105
106
|
},
|
|
106
|
-
isSelected
|
|
107
|
+
isSelected ? React.createElement(CheckedBoxIcon, null) : React.createElement(CheckBoxIcon, null)
|
|
107
108
|
),
|
|
108
109
|
svgPath && React.createElement(
|
|
109
110
|
SvgIcon,
|
|
110
111
|
{
|
|
111
112
|
color: 'primary',
|
|
112
|
-
className: cx(classes.labelIcon, (_cx4 = {}, _cx4[classes.disabledLabel] = isDisabled, _cx4))
|
|
113
|
+
className: cx(classes.labelIcon, (_cx4 = {}, _cx4[classes.disabledLabel] = isGreyed || isDisabled, _cx4))
|
|
113
114
|
},
|
|
114
115
|
React.createElement('path', { d: svgPath })
|
|
115
116
|
),
|
|
@@ -136,10 +137,9 @@ var Item = function Item(_ref) {
|
|
|
136
137
|
React.createElement(
|
|
137
138
|
Typography,
|
|
138
139
|
{
|
|
139
|
-
'data-testid': testId + '_value_' + id,
|
|
140
140
|
color: 'inherit',
|
|
141
141
|
variant: 'body2',
|
|
142
|
-
className: cx(classes.label, (_cx5 = {}, _cx5[classes.disabledLabel] = isDisabled, _cx5[classes.tooltipNotice] = !R.isEmpty(description), _cx5))
|
|
142
|
+
className: cx(classes.label, (_cx5 = {}, _cx5[classes.disabledLabel] = isGreyed || isDisabled, _cx5[classes.tooltipNotice] = !R.isEmpty(description), _cx5))
|
|
143
143
|
},
|
|
144
144
|
label
|
|
145
145
|
)
|
|
@@ -175,7 +175,6 @@ Item.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
175
175
|
svgPath: PropTypes.string,
|
|
176
176
|
style: PropTypes.object,
|
|
177
177
|
isRtl: PropTypes.bool,
|
|
178
|
-
testId: PropTypes.string,
|
|
179
178
|
accessibility: PropTypes.bool,
|
|
180
179
|
index: PropTypes.number,
|
|
181
180
|
labelRenderer: PropTypes.func,
|
|
@@ -183,7 +182,8 @@ Item.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
183
182
|
hierarchicalId: PropTypes.string,
|
|
184
183
|
labels: PropTypes.object,
|
|
185
184
|
depth: PropTypes.number,
|
|
186
|
-
eventsCallbacks: PropTypes.func
|
|
185
|
+
eventsCallbacks: PropTypes.func,
|
|
186
|
+
isGreyed: PropTypes.bool
|
|
187
187
|
} : {};
|
|
188
188
|
|
|
189
189
|
export default Item;
|
|
@@ -11,14 +11,13 @@ import List from '@material-ui/core/List';
|
|
|
11
11
|
import Item from './Item';
|
|
12
12
|
import { useTheme } from '@material-ui/core';
|
|
13
13
|
import { useStyles, height as rowHeight } from '../ScopeList/styles';
|
|
14
|
+
import { getDepth, getHierarchicalId, isItemSelected as _isItemSelected, getDeprecatedIds, getDuplicates } from './utils';
|
|
14
15
|
import { getIsRtl } from '../utils';
|
|
15
16
|
|
|
16
|
-
var
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export var getHierarchicalId = function getHierarchicalId(item) {
|
|
21
|
-
return R.prop('hierarchicalId', item) || R.prop('id', item);
|
|
17
|
+
var singleScopeGetter = function singleScopeGetter() {
|
|
18
|
+
return function (item) {
|
|
19
|
+
return [item];
|
|
20
|
+
};
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
export var getDisplayedIds = function getDisplayedIds(items, grouped, expanded) {
|
|
@@ -43,20 +42,13 @@ export var getHasChildrenOnLevel = function getHasChildrenOnLevel(groupedItems)
|
|
|
43
42
|
};
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
export var getDepth = function getDepth(indexedItems) {
|
|
47
|
-
return function (item) {
|
|
48
|
-
if (R.isNil(item.parentId)) {
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
var parent = R.prop(item.parentId, indexedItems);
|
|
52
|
-
return getDepth(indexedItems)(parent) + 1;
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
|
|
56
45
|
var VirtualizedTree = function VirtualizedTree(props) {
|
|
57
46
|
var accessibility = props.accessibility,
|
|
58
47
|
changeSelection = props.changeSelection,
|
|
59
|
-
|
|
48
|
+
_props$disableAccesso = props.disableAccessor,
|
|
49
|
+
disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
|
|
50
|
+
_props$isGreyed = props.isGreyed,
|
|
51
|
+
isGreyed = _props$isGreyed === undefined ? R.always(false) : _props$isGreyed,
|
|
60
52
|
HTMLRenderer = props.HTMLRenderer,
|
|
61
53
|
items = props.items,
|
|
62
54
|
labelRenderer = props.labelRenderer,
|
|
@@ -66,8 +58,8 @@ var VirtualizedTree = function VirtualizedTree(props) {
|
|
|
66
58
|
collapse = props.collapse,
|
|
67
59
|
_props$maxTreeHeight = props.maxTreeHeight,
|
|
68
60
|
maxTreeHeight = _props$maxTreeHeight === undefined ? 250 : _props$maxTreeHeight,
|
|
69
|
-
_props$
|
|
70
|
-
|
|
61
|
+
_props$scopeGetter = props.scopeGetter,
|
|
62
|
+
scopeGetter = _props$scopeGetter === undefined ? singleScopeGetter : _props$scopeGetter,
|
|
71
63
|
_props$treeHeight = props.treeHeight,
|
|
72
64
|
treeHeight = _props$treeHeight === undefined ? 0 : _props$treeHeight;
|
|
73
65
|
|
|
@@ -94,21 +86,41 @@ var VirtualizedTree = function VirtualizedTree(props) {
|
|
|
94
86
|
setLastItemId = _useState5[1];
|
|
95
87
|
|
|
96
88
|
var _useMemo = useMemo(function () {
|
|
97
|
-
var
|
|
98
|
-
|
|
89
|
+
var refinedItems = R.map(function (item) {
|
|
90
|
+
return _extends({}, item, {
|
|
91
|
+
isSelected: _isItemSelected(selectIds)(item),
|
|
92
|
+
isGreyed: R.is(Function, isGreyed) ? isGreyed(item) : false,
|
|
93
|
+
isDisabled: R.is(Function, disableAccessor) ? disableAccessor(item, selectIds) : false
|
|
94
|
+
});
|
|
95
|
+
}, items);
|
|
96
|
+
var indexedItemsById = R.indexBy(getHierarchicalId, refinedItems);
|
|
97
|
+
var groupedItemsByParentId = R.groupBy(R.propOr('#ROOT', 'parentId'), refinedItems);
|
|
99
98
|
return { indexedItemsById: indexedItemsById, groupedItemsByParentId: groupedItemsByParentId };
|
|
100
|
-
}, [items]),
|
|
99
|
+
}, [items, selectIds]),
|
|
101
100
|
indexedItemsById = _useMemo.indexedItemsById,
|
|
102
101
|
groupedItemsByParentId = _useMemo.groupedItemsByParentId;
|
|
103
102
|
|
|
104
103
|
var list = useMemo(function () {
|
|
105
104
|
return getDisplayedIds(R.propOr([], '#ROOT', groupedItemsByParentId), groupedItemsByParentId, expandedIds);
|
|
106
105
|
}, [items, expandedIds]);
|
|
106
|
+
|
|
107
|
+
var getItemScope = scopeGetter({ indexedItemsById: indexedItemsById, groupedItemsByParentId: groupedItemsByParentId });
|
|
108
|
+
|
|
109
|
+
var isItemSelected = _isItemSelected(selectIds);
|
|
110
|
+
|
|
107
111
|
var multiSelect = function multiSelect(id) {
|
|
108
112
|
var item = R.prop(id, indexedItemsById);
|
|
109
113
|
var ids = R.pipe(getItemScope, R.filter(function (v) {
|
|
110
114
|
return v.isSelected === item.isSelected;
|
|
111
|
-
}),
|
|
115
|
+
}), function (items) {
|
|
116
|
+
return getDuplicates(items, indexedItemsById);
|
|
117
|
+
}, R.map(getHierarchicalId))(item);
|
|
118
|
+
|
|
119
|
+
if (isItemSelected(item)) {
|
|
120
|
+
var deprecatedIds = getDeprecatedIds(ids, { indexedItemsById: indexedItemsById, groupedItemsByParentId: groupedItemsByParentId }, selectIds);
|
|
121
|
+
ids = R.concat(ids, deprecatedIds);
|
|
122
|
+
}
|
|
123
|
+
|
|
112
124
|
if (R.has(id, selectIds)) {
|
|
113
125
|
setSelectIds(R.omit(ids, selectIds));
|
|
114
126
|
} else {
|
|
@@ -212,12 +224,6 @@ var VirtualizedTree = function VirtualizedTree(props) {
|
|
|
212
224
|
apply();
|
|
213
225
|
}
|
|
214
226
|
};
|
|
215
|
-
var isItemSelected = function isItemSelected(item) {
|
|
216
|
-
if (!R.isEmpty(selectIds) && R.has(getHierarchicalId(item), selectIds)) {
|
|
217
|
-
return !item.isSelected;
|
|
218
|
-
}
|
|
219
|
-
return !!item.isSelected;
|
|
220
|
-
};
|
|
221
227
|
var ref = useRef();
|
|
222
228
|
var classes = useStyles();
|
|
223
229
|
|
|
@@ -298,9 +304,7 @@ var VirtualizedTree = function VirtualizedTree(props) {
|
|
|
298
304
|
},
|
|
299
305
|
NavigateIcon: R.has(itemId, expandedIds) ? ExpandLessIcon : ExpandMoreIcon,
|
|
300
306
|
isRtl: isRtl,
|
|
301
|
-
isDisabled: R.is(Function, disableAccessor) ? disableAccessor(item) : false,
|
|
302
307
|
eventsCallbacks: eventsCallbacks,
|
|
303
|
-
isSelected: isItemSelected(item),
|
|
304
308
|
HTMLRenderer: HTMLRenderer,
|
|
305
309
|
classes: classes,
|
|
306
310
|
labels: labels,
|
|
@@ -326,9 +330,7 @@ VirtualizedTree.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
326
330
|
isRtl: PropTypes.bool,
|
|
327
331
|
items: PropTypes.array,
|
|
328
332
|
labels: PropTypes.shape({
|
|
329
|
-
disableItemLabel: PropTypes.string
|
|
330
|
-
colapseAll: PropTypes.string,
|
|
331
|
-
expandAll: PropTypes.string
|
|
333
|
+
disableItemLabel: PropTypes.string
|
|
332
334
|
}),
|
|
333
335
|
labelRenderer: PropTypes.func,
|
|
334
336
|
withExpandControl: PropTypes.bool,
|
|
@@ -336,7 +338,9 @@ VirtualizedTree.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
336
338
|
expandedIds: PropTypes.object,
|
|
337
339
|
expand: PropTypes.func,
|
|
338
340
|
collapse: PropTypes.func,
|
|
339
|
-
treeHeight: PropTypes.number
|
|
341
|
+
treeHeight: PropTypes.number,
|
|
342
|
+
isGreyed: PropTypes.func,
|
|
343
|
+
scopeGetter: PropTypes.func
|
|
340
344
|
} : {};
|
|
341
345
|
|
|
342
346
|
export default VirtualizedTree;
|