@sis-cc/dotstatsuite-visions 7.19.1 → 7.20.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/es/AdvancedFilterDialog/AdvancedFilterDialog.js +78 -28
- package/es/AdvancedFilterDialog/images/all-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/branch-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/children-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/level-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/single-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/small-all-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/small-branch-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/small-children-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/small-level-selection.png +0 -0
- package/es/AdvancedFilterDialog/images/small-single-selection.png +0 -0
- package/es/Chips/CustomChip.js +109 -0
- package/es/Chips/DeleteChip.js +27 -0
- package/es/Chips/GroupedChips.js +95 -0
- package/es/Chips/index.js +34 -26
- package/es/Chips/styles.js +64 -0
- package/es/Chips/utils.js +11 -0
- package/es/HierarchicalFilter/HierarchicalFilter.js +1 -1
- package/es/VirtualizedTree/Item.js +14 -14
- package/es/VirtualizedTree/VirtualizedTree.js +13 -14
- package/es/index.js +1 -1
- package/lib/AdvancedFilterDialog/AdvancedFilterDialog.js +105 -26
- package/lib/AdvancedFilterDialog/images/all-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/branch-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/children-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/level-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/single-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/small-all-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/small-branch-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/small-children-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/small-level-selection.png +0 -0
- package/lib/AdvancedFilterDialog/images/small-single-selection.png +0 -0
- package/lib/Chips/CustomChip.js +145 -0
- package/lib/Chips/DeleteChip.js +46 -0
- package/lib/Chips/GroupedChips.js +122 -0
- package/lib/Chips/index.js +11 -4
- package/lib/Chips/styles.js +74 -0
- package/lib/Chips/utils.js +20 -0
- package/lib/HierarchicalFilter/HierarchicalFilter.js +1 -1
- package/lib/VirtualizedTree/Item.js +18 -13
- package/lib/VirtualizedTree/VirtualizedTree.js +13 -14
- package/lib/index.js +8 -2
- package/package.json +7 -5
- package/es/Chips/Chips.js +0 -302
- package/lib/Chips/Chips.js +0 -342
|
@@ -2,11 +2,11 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument
|
|
|
2
2
|
|
|
3
3
|
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
|
4
4
|
|
|
5
|
-
import React, { useState } from 'react';
|
|
5
|
+
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 { getHierarchicalId } from '../VirtualizedTree/VirtualizedTree';
|
|
9
|
+
import { getDepth, getHierarchicalId } from '../VirtualizedTree/VirtualizedTree';
|
|
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';
|
|
@@ -23,6 +23,17 @@ import HintIcon from '@material-ui/icons/EmojiObjects';
|
|
|
23
23
|
import Draggable from 'react-draggable';
|
|
24
24
|
import { Button, Spotlight, VirtualizedTree } from '..';
|
|
25
25
|
import { makeStyles } from '@material-ui/core/styles';
|
|
26
|
+
import singleImg from './images/single-selection.png';
|
|
27
|
+
import childrenImg from './images/children-selection.png';
|
|
28
|
+
import branchImg from './images/branch-selection.png';
|
|
29
|
+
import levelImg from './images/level-selection.png';
|
|
30
|
+
import allImg from './images/all-selection.png';
|
|
31
|
+
|
|
32
|
+
import singleIcon from './images/small-single-selection.png';
|
|
33
|
+
import childrenIcon from './images/small-children-selection.png';
|
|
34
|
+
import branchIcon from './images/small-branch-selection.png';
|
|
35
|
+
import levelIcon from './images/small-level-selection.png';
|
|
36
|
+
import allIcon from './images/small-all-selection.png';
|
|
26
37
|
|
|
27
38
|
var PaperComponent = function PaperComponent(props) {
|
|
28
39
|
return React.createElement(
|
|
@@ -65,6 +76,10 @@ var useStyles = makeStyles(function (theme) {
|
|
|
65
76
|
alignItems: 'flex-start'
|
|
66
77
|
},
|
|
67
78
|
spotlight: { width: '45%' },
|
|
79
|
+
selection: {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
alignItems: 'center'
|
|
82
|
+
},
|
|
68
83
|
narrowSpotlight: { width: '100%' },
|
|
69
84
|
selectionButton: {
|
|
70
85
|
marginLeft: 24,
|
|
@@ -78,7 +93,7 @@ var useStyles = makeStyles(function (theme) {
|
|
|
78
93
|
width: '50%',
|
|
79
94
|
position: 'absolute',
|
|
80
95
|
top: 105,
|
|
81
|
-
right:
|
|
96
|
+
right: 48,
|
|
82
97
|
zIndex: 1
|
|
83
98
|
},
|
|
84
99
|
narrowSelectionMenu: {
|
|
@@ -89,16 +104,28 @@ var useStyles = makeStyles(function (theme) {
|
|
|
89
104
|
flexDirection: 'row',
|
|
90
105
|
flexWrap: 'wrap'
|
|
91
106
|
},
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
selectButton: {
|
|
108
|
+
color: theme.palette.primary.main,
|
|
109
|
+
'&:hover': {
|
|
110
|
+
color: theme.palette.primary.main,
|
|
111
|
+
backgroundColor: theme.palette.action.hover
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
selectedButton: {
|
|
115
|
+
backgroundColor: theme.palette.secondary.main,
|
|
116
|
+
'&:hover': {
|
|
117
|
+
backgroundColor: theme.palette.action.selected
|
|
118
|
+
}
|
|
94
119
|
},
|
|
95
120
|
selectModeItem: {
|
|
96
121
|
boxShadow: 'none',
|
|
97
122
|
display: 'flex',
|
|
98
123
|
width: 110,
|
|
99
124
|
height: 200,
|
|
125
|
+
backgroundColor: 'inherit',
|
|
126
|
+
color: 'inherit',
|
|
100
127
|
flexDirection: 'column',
|
|
101
|
-
justifyContent: '
|
|
128
|
+
justifyContent: 'space-between',
|
|
102
129
|
'& img': {
|
|
103
130
|
width: 110,
|
|
104
131
|
height: 140
|
|
@@ -114,6 +141,7 @@ var useStyles = makeStyles(function (theme) {
|
|
|
114
141
|
});
|
|
115
142
|
|
|
116
143
|
export var getScopeGetters = function getScopeGetters(items, groupedItems, disableAccessor) {
|
|
144
|
+
var indexed = R.indexBy(getHierarchicalId, items);
|
|
117
145
|
return {
|
|
118
146
|
all: function all() {
|
|
119
147
|
return R.reject(disableAccessor, items);
|
|
@@ -135,9 +163,10 @@ export var getScopeGetters = function getScopeGetters(items, groupedItems, disab
|
|
|
135
163
|
return R.reject(disableAccessor, items);
|
|
136
164
|
},
|
|
137
165
|
level: function level(item) {
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
166
|
+
var depth = getDepth(indexed)(item);
|
|
167
|
+
return R.filter(function (it) {
|
|
168
|
+
return !disableAccessor(it) && getDepth(indexed)(it) === depth;
|
|
169
|
+
}, items);
|
|
141
170
|
}
|
|
142
171
|
};
|
|
143
172
|
};
|
|
@@ -168,10 +197,12 @@ var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
|
168
197
|
|
|
169
198
|
var value = _ref2.value,
|
|
170
199
|
label = _ref2.label,
|
|
171
|
-
|
|
200
|
+
img = _ref2.img;
|
|
172
201
|
return React.createElement(
|
|
173
202
|
Button,
|
|
174
|
-
_extends({
|
|
203
|
+
_extends({
|
|
204
|
+
className: cx(classes.selectButton, (_cx = {}, _cx[classes.selectedButton] = value === selected, _cx))
|
|
205
|
+
}, value === selected ? { variant: 'contained', color: 'secondary' } : {}, {
|
|
175
206
|
key: value,
|
|
176
207
|
onClick: function onClick() {
|
|
177
208
|
return onSelect(value);
|
|
@@ -179,16 +210,13 @@ var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
|
179
210
|
}),
|
|
180
211
|
React.createElement(
|
|
181
212
|
Paper,
|
|
182
|
-
{
|
|
183
|
-
className: cx(classes.selectModeItem, (_cx = {}, _cx[classes.selectedItem] = value === selected, _cx)),
|
|
184
|
-
key: value
|
|
185
|
-
},
|
|
213
|
+
{ className: classes.selectModeItem, key: value },
|
|
186
214
|
React.createElement(
|
|
187
215
|
Typography,
|
|
188
216
|
{ variant: 'body2' },
|
|
189
217
|
label
|
|
190
218
|
),
|
|
191
|
-
React.createElement('img', { src:
|
|
219
|
+
!R.isNil(img) && R.is(String, img) && React.createElement('img', { src: img, alt: value })
|
|
192
220
|
)
|
|
193
221
|
);
|
|
194
222
|
}, options)
|
|
@@ -216,6 +244,14 @@ SelectionModeMenu.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
216
244
|
selected: PropTypes.string
|
|
217
245
|
} : {};
|
|
218
246
|
|
|
247
|
+
var icons = {
|
|
248
|
+
single: singleIcon,
|
|
249
|
+
children: childrenIcon,
|
|
250
|
+
branch: branchIcon,
|
|
251
|
+
level: levelIcon,
|
|
252
|
+
all: allIcon
|
|
253
|
+
};
|
|
254
|
+
|
|
219
255
|
var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
220
256
|
var _cx2;
|
|
221
257
|
|
|
@@ -228,9 +264,8 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
228
264
|
isOpen = props.isOpen,
|
|
229
265
|
isNarrow = props.isNarrow,
|
|
230
266
|
labels = props.labels,
|
|
231
|
-
imgs = props.imgs,
|
|
232
267
|
disableAccessor = props.disableAccessor,
|
|
233
|
-
rest = _objectWithoutProperties(props, ['id', 'title', 'items', 'labelRenderer', 'onClose', 'changeSelection', 'isOpen', 'isNarrow', 'labels', '
|
|
268
|
+
rest = _objectWithoutProperties(props, ['id', 'title', 'items', 'labelRenderer', 'onClose', 'changeSelection', 'isOpen', 'isNarrow', 'labels', 'disableAccessor']);
|
|
234
269
|
|
|
235
270
|
var _useState = useState(''),
|
|
236
271
|
term = _useState[0].term,
|
|
@@ -277,20 +312,24 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
277
312
|
var selectionOptions = [{
|
|
278
313
|
value: 'single',
|
|
279
314
|
label: R.prop('singleSelection', labels),
|
|
280
|
-
|
|
315
|
+
img: singleImg
|
|
281
316
|
}, {
|
|
282
317
|
value: 'children',
|
|
283
318
|
label: R.prop('childrenSelection', labels),
|
|
284
|
-
|
|
319
|
+
img: childrenImg
|
|
285
320
|
}, {
|
|
286
321
|
value: 'branch',
|
|
287
322
|
label: R.prop('branchSelection', labels),
|
|
288
|
-
|
|
323
|
+
img: branchImg
|
|
289
324
|
}, {
|
|
290
325
|
value: 'level',
|
|
291
326
|
label: R.prop('levelSelection', labels),
|
|
292
|
-
|
|
293
|
-
}, {
|
|
327
|
+
img: levelImg
|
|
328
|
+
}, {
|
|
329
|
+
value: 'all',
|
|
330
|
+
label: R.prop('allSelection', labels),
|
|
331
|
+
img: allImg
|
|
332
|
+
}];
|
|
294
333
|
|
|
295
334
|
var isDisabled = function isDisabled(item) {
|
|
296
335
|
return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
|
|
@@ -359,7 +398,7 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
359
398
|
),
|
|
360
399
|
React.createElement(
|
|
361
400
|
'div',
|
|
362
|
-
|
|
401
|
+
{ className: classes.selection },
|
|
363
402
|
React.createElement(
|
|
364
403
|
Button,
|
|
365
404
|
{
|
|
@@ -375,7 +414,13 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
375
414
|
R.prop('selectionMode', labels)
|
|
376
415
|
),
|
|
377
416
|
'\xA0',
|
|
378
|
-
R.prop(selectionMode + 'Selection', labels)
|
|
417
|
+
R.prop(selectionMode + 'Selection', labels),
|
|
418
|
+
!R.isNil(R.prop(selectionMode, icons)) && R.is(String, R.prop(selectionMode, icons)) && React.createElement(
|
|
419
|
+
Fragment,
|
|
420
|
+
null,
|
|
421
|
+
'\xA0',
|
|
422
|
+
React.createElement('img', { src: R.prop(selectionMode, icons), alt: selectionMode })
|
|
423
|
+
)
|
|
379
424
|
)
|
|
380
425
|
),
|
|
381
426
|
React.createElement(
|
|
@@ -400,7 +445,7 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
400
445
|
items: selectionItems,
|
|
401
446
|
changeSelection: onChangeSelection,
|
|
402
447
|
withExpandControl: true,
|
|
403
|
-
maxTreeHeight:
|
|
448
|
+
maxTreeHeight: 490,
|
|
404
449
|
getItemScope: R.prop(selectionMode, scopeGetters)
|
|
405
450
|
}))
|
|
406
451
|
)
|
|
@@ -411,7 +456,13 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
411
456
|
null,
|
|
412
457
|
R.is(Function, onClose) && React.createElement(
|
|
413
458
|
Button,
|
|
414
|
-
{
|
|
459
|
+
{
|
|
460
|
+
onClick: function onClick() {
|
|
461
|
+
onClose();
|
|
462
|
+
setSelection({});
|
|
463
|
+
},
|
|
464
|
+
color: 'primary'
|
|
465
|
+
},
|
|
415
466
|
R.prop('cancel', labels)
|
|
416
467
|
),
|
|
417
468
|
R.is(Function, changeSelection) && React.createElement(
|
|
@@ -435,7 +486,6 @@ AdvancedFilterDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
435
486
|
changeSelection: PropTypes.func,
|
|
436
487
|
disableAccessor: PropTypes.func,
|
|
437
488
|
HTMLRenderer: PropTypes.func,
|
|
438
|
-
imgs: PropTypes.object,
|
|
439
489
|
isRtl: PropTypes.bool,
|
|
440
490
|
isNarrow: PropTypes.bool,
|
|
441
491
|
isOpen: PropTypes.bool,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import * as R from 'ramda';
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { useTheme } from '@material-ui/core/styles';
|
|
6
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
7
|
+
import Chip from '@material-ui/core/Chip';
|
|
8
|
+
import Cross from '../Icons/Cross';
|
|
9
|
+
import { getIsRtl } from '../utils';
|
|
10
|
+
import Tooltip from '../Tooltip';
|
|
11
|
+
import { useStyles } from './styles';
|
|
12
|
+
import { myTooltipRenderer } from './utils';
|
|
13
|
+
|
|
14
|
+
var shownTooltip = R.pipe(R.dropLast(1), R.either(R.isEmpty, R.isNil), R.not);
|
|
15
|
+
var showMultiLinedTooltip = R.pipe(R.head, R.propOr([], 'parents'), R.isEmpty, R.not);
|
|
16
|
+
|
|
17
|
+
var CustomChip = function CustomChip(_ref) {
|
|
18
|
+
var _cx;
|
|
19
|
+
|
|
20
|
+
var id = _ref.id,
|
|
21
|
+
parentId = _ref.parentId,
|
|
22
|
+
_ref$items = _ref.items,
|
|
23
|
+
items = _ref$items === undefined ? [] : _ref$items,
|
|
24
|
+
label = _ref.label,
|
|
25
|
+
onDelete = _ref.onDelete,
|
|
26
|
+
renderer = _ref.renderer,
|
|
27
|
+
chipClasses = _ref.chipClasses,
|
|
28
|
+
iconClasses = _ref.iconClasses,
|
|
29
|
+
labelClasses = _ref.labelClasses,
|
|
30
|
+
_ref$ariaLabel = _ref.ariaLabel,
|
|
31
|
+
ariaLabel = _ref$ariaLabel === undefined ? 'delete' : _ref$ariaLabel,
|
|
32
|
+
_ref$testId = _ref.testId,
|
|
33
|
+
testId = _ref$testId === undefined ? 'deleteChip-test-id' : _ref$testId;
|
|
34
|
+
|
|
35
|
+
var theme = useTheme();
|
|
36
|
+
var isRtl = getIsRtl(theme);
|
|
37
|
+
var labelRenderer = R.prop('label');
|
|
38
|
+
var classes = useStyles();
|
|
39
|
+
var mapIndexed = R.addIndex(R.map);
|
|
40
|
+
var onChange = R.is(Function)(onDelete) ? function () {
|
|
41
|
+
return onDelete(parentId, R.isNil(id) ? [] : [id]);
|
|
42
|
+
} : null;
|
|
43
|
+
var hasTooltip = shownTooltip(items);
|
|
44
|
+
var hasMultiLinedTooltip = showMultiLinedTooltip(items);
|
|
45
|
+
var multiLinedTooltipRenderer = function multiLinedTooltipRenderer(arr) {
|
|
46
|
+
return mapIndexed(function (item, index) {
|
|
47
|
+
return React.createElement(
|
|
48
|
+
'div',
|
|
49
|
+
{ key: index },
|
|
50
|
+
myTooltipRenderer({ isRtl: isRtl, labelRenderer: labelRenderer })(item),
|
|
51
|
+
React.createElement('br', null)
|
|
52
|
+
);
|
|
53
|
+
})(R.prop('parents')(R.head(arr)));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return React.createElement(
|
|
57
|
+
Tooltip,
|
|
58
|
+
{
|
|
59
|
+
placement: 'top',
|
|
60
|
+
title: hasTooltip ? renderer(items) : hasMultiLinedTooltip ? multiLinedTooltipRenderer(items) : ''
|
|
61
|
+
},
|
|
62
|
+
React.createElement(Chip, {
|
|
63
|
+
'data-testid': testId,
|
|
64
|
+
size: 'small',
|
|
65
|
+
'aria-label': label,
|
|
66
|
+
label: hasTooltip || hasMultiLinedTooltip ? React.createElement(
|
|
67
|
+
Fragment,
|
|
68
|
+
null,
|
|
69
|
+
'...',
|
|
70
|
+
React.createElement(
|
|
71
|
+
'span',
|
|
72
|
+
{ className: classes.childrenIndicator },
|
|
73
|
+
'>'
|
|
74
|
+
),
|
|
75
|
+
label
|
|
76
|
+
) : label,
|
|
77
|
+
deleteIcon: React.createElement(
|
|
78
|
+
IconButton,
|
|
79
|
+
{
|
|
80
|
+
disableRipple: true,
|
|
81
|
+
className: iconClasses,
|
|
82
|
+
'aria-label': ariaLabel + ' ' + label,
|
|
83
|
+
component: 'span',
|
|
84
|
+
tabIndex: -1
|
|
85
|
+
},
|
|
86
|
+
React.createElement(Cross, null)
|
|
87
|
+
),
|
|
88
|
+
clickable: true,
|
|
89
|
+
onDelete: onChange,
|
|
90
|
+
className: cx(chipClasses, (_cx = {}, _cx[classes.tooltipIndicator] = hasTooltip || hasMultiLinedTooltip, _cx)),
|
|
91
|
+
classes: { label: labelClasses }
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
CustomChip.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
97
|
+
testId: PropTypes.string,
|
|
98
|
+
id: PropTypes.string,
|
|
99
|
+
parentId: PropTypes.string,
|
|
100
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
101
|
+
onDelete: PropTypes.func,
|
|
102
|
+
renderer: PropTypes.func,
|
|
103
|
+
chipClasses: PropTypes.string,
|
|
104
|
+
iconClasses: PropTypes.string,
|
|
105
|
+
labelClasses: PropTypes.string,
|
|
106
|
+
ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
107
|
+
items: PropTypes.array
|
|
108
|
+
} : {};
|
|
109
|
+
export default CustomChip;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { useStyles } from './styles';
|
|
5
|
+
import CustomChip from './CustomChip';
|
|
6
|
+
|
|
7
|
+
var DeleteChip = function DeleteChip(_ref) {
|
|
8
|
+
var onDeleteAll = _ref.onDeleteAll,
|
|
9
|
+
clearAllLabel = _ref.clearAllLabel,
|
|
10
|
+
ariaLabel = _ref.ariaLabel;
|
|
11
|
+
|
|
12
|
+
var classes = useStyles();
|
|
13
|
+
return React.createElement(CustomChip, {
|
|
14
|
+
label: clearAllLabel,
|
|
15
|
+
ariaLabel: ariaLabel,
|
|
16
|
+
chipClasses: cx(classes.mainChip, classes.chip),
|
|
17
|
+
onDelete: onDeleteAll,
|
|
18
|
+
iconClasses: classes.icon,
|
|
19
|
+
labelClasses: cx(classes.spaceLabel, classes.formatLabel)
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
DeleteChip.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
23
|
+
onDeleteAll: PropTypes.func,
|
|
24
|
+
ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
25
|
+
clearAllLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
26
|
+
} : {};
|
|
27
|
+
export default DeleteChip;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useTheme } from '@material-ui/core/styles';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import React, { Fragment } from 'react';
|
|
4
|
+
import * as R from 'ramda';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { getIsRtl } from '../utils';
|
|
7
|
+
import { useStyles } from './styles';
|
|
8
|
+
import CustomChip from './CustomChip';
|
|
9
|
+
import { myTooltipRenderer } from './utils';
|
|
10
|
+
|
|
11
|
+
var GroupedChips = function GroupedChips(_ref) {
|
|
12
|
+
var _ref$itemProps = _ref.itemProps,
|
|
13
|
+
itemProps = _ref$itemProps === undefined ? {} : _ref$itemProps,
|
|
14
|
+
onDelete = _ref.onDelete,
|
|
15
|
+
_ref$labelRenderer = _ref.labelRenderer,
|
|
16
|
+
labelRenderer = _ref$labelRenderer === undefined ? R.prop('label') : _ref$labelRenderer,
|
|
17
|
+
tooltipRenderer = _ref.tooltipRenderer,
|
|
18
|
+
ariaLabel = _ref.ariaLabel,
|
|
19
|
+
_ref$reducingNbChips = _ref.reducingNbChips,
|
|
20
|
+
reducingNbChips = _ref$reducingNbChips === undefined ? 15 : _ref$reducingNbChips,
|
|
21
|
+
labels = _ref.labels,
|
|
22
|
+
_ref$testId = _ref.testId,
|
|
23
|
+
testId = _ref$testId === undefined ? 'chips-test-id' : _ref$testId;
|
|
24
|
+
var parentId = itemProps.id,
|
|
25
|
+
isNotRemovable = itemProps.isNotRemovable,
|
|
26
|
+
_itemProps$values = itemProps.values,
|
|
27
|
+
values = _itemProps$values === undefined ? [] : _itemProps$values;
|
|
28
|
+
|
|
29
|
+
var theme = useTheme();
|
|
30
|
+
var isRtl = getIsRtl(theme);
|
|
31
|
+
var classes = useStyles();
|
|
32
|
+
return React.createElement(
|
|
33
|
+
Fragment,
|
|
34
|
+
null,
|
|
35
|
+
React.createElement(CustomChip, {
|
|
36
|
+
testId: testId,
|
|
37
|
+
parentId: parentId,
|
|
38
|
+
label: labelRenderer(itemProps) + ':',
|
|
39
|
+
ariaLabel: ariaLabel,
|
|
40
|
+
chipClasses: cx(classes.mainChip, classes.chip),
|
|
41
|
+
onDelete: isNotRemovable ? null : onDelete,
|
|
42
|
+
iconClasses: classes.icon,
|
|
43
|
+
labelClasses: cx(classes.spaceLabel, classes.formatLabel)
|
|
44
|
+
}),
|
|
45
|
+
R.pipe(R.length, R.flip(R.gt)(reducingNbChips))(values) ? React.createElement(CustomChip, {
|
|
46
|
+
parentId: parentId,
|
|
47
|
+
label: R.length(values) + ' ' + R.prop('reducingChip')(labels),
|
|
48
|
+
chipClasses: cx(classes.secondaryChip, classes.chip),
|
|
49
|
+
onDelete: isNotRemovable ? null : onDelete,
|
|
50
|
+
iconClasses: classes.icon,
|
|
51
|
+
labelClasses: cx(classes.formatLabel)
|
|
52
|
+
}) : R.map(function (items) {
|
|
53
|
+
var lastItem = R.last(items);
|
|
54
|
+
var id = lastItem.id,
|
|
55
|
+
isNotRemovable = lastItem.isNotRemovable;
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
return React.createElement(CustomChip, {
|
|
59
|
+
key: id,
|
|
60
|
+
id: id,
|
|
61
|
+
items: R.pipe(R.length, R.gte(2)) ? items : null,
|
|
62
|
+
renderer: R.is(Function)(tooltipRenderer) ? tooltipRenderer : myTooltipRenderer({ isRtl: isRtl, labelRenderer: labelRenderer }),
|
|
63
|
+
label: labelRenderer(lastItem),
|
|
64
|
+
ariaLabel: ariaLabel,
|
|
65
|
+
parentId: parentId,
|
|
66
|
+
onDelete: isNotRemovable ? null : onDelete,
|
|
67
|
+
chipClasses: cx(classes.secondaryChip, classes.chip),
|
|
68
|
+
iconClasses: classes.icon,
|
|
69
|
+
labelClasses: cx(classes.formatLabel)
|
|
70
|
+
});
|
|
71
|
+
})(values)
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
GroupedChips.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
75
|
+
testId: PropTypes.string,
|
|
76
|
+
itemProps: PropTypes.shape({
|
|
77
|
+
id: PropTypes.string,
|
|
78
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
79
|
+
isNotRemovable: PropTypes.bool,
|
|
80
|
+
values: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.shape({
|
|
81
|
+
id: PropTypes.string,
|
|
82
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
83
|
+
isNotRemovable: PropTypes.bool
|
|
84
|
+
})))
|
|
85
|
+
}),
|
|
86
|
+
onDelete: PropTypes.func,
|
|
87
|
+
labelRenderer: PropTypes.func,
|
|
88
|
+
tooltipRenderer: PropTypes.func,
|
|
89
|
+
ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
90
|
+
reducingNbChips: PropTypes.number,
|
|
91
|
+
labels: PropTypes.shape({
|
|
92
|
+
reducingChip: PropTypes.oneOfType([PropTypes.string, PropTypes.element])
|
|
93
|
+
})
|
|
94
|
+
} : {};
|
|
95
|
+
export default GroupedChips;
|
package/es/Chips/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* GroupedChips, is like a small board of whatever you want to show. You can delete sub item, item with sub item or all items
|
|
3
|
+
* DeleteAllChip, is a chip that deletes all items displayed in the board
|
|
3
4
|
* reducingNbChips: default 15, allow a possibility to reduce many chips to one. You will see the numbers of items inside the chip
|
|
4
5
|
*
|
|
5
6
|
* @memberOf VISIONS
|
|
@@ -7,31 +8,37 @@
|
|
|
7
8
|
* @tag component
|
|
8
9
|
* @api public
|
|
9
10
|
* @demoReady
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
11
|
+
* GroupedChips.propTypes = {
|
|
12
|
+
* testId: PropTypes.string,
|
|
13
|
+
* itemProps: PropTypes.shape({
|
|
14
|
+
* id: PropTypes.string,
|
|
15
|
+
* label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
16
|
+
* isNotRemovable: PropTypes.bool,
|
|
17
|
+
* values: PropTypes.arrayOf(
|
|
18
|
+
* PropTypes.arrayOf(
|
|
19
|
+
* PropTypes.shape({
|
|
20
|
+
* id: PropTypes.string,
|
|
21
|
+
* label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
22
|
+
* isNotRemovable: PropTypes.bool,
|
|
23
|
+
* }),
|
|
24
|
+
* ),
|
|
25
|
+
* ),
|
|
26
|
+
* }),
|
|
27
|
+
* onDelete: PropTypes.func,
|
|
28
|
+
* labelRenderer: PropTypes.func,
|
|
29
|
+
* tooltipRenderer: PropTypes.func,
|
|
30
|
+
* ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
31
|
+
* reducingNbChips: PropTypes.number,
|
|
32
|
+
* labels: PropTypes.shape({
|
|
33
|
+
* reducingChip: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
34
|
+
* }),
|
|
34
35
|
* };
|
|
36
|
+
*
|
|
37
|
+
* DeleteAllChip.propTypes = {
|
|
38
|
+
* onDeleteAll: PropTypes.func,
|
|
39
|
+
* ariaLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
40
|
+
* clearAllLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
41
|
+
};
|
|
35
42
|
* @theme
|
|
36
43
|
* {
|
|
37
44
|
* palette: {
|
|
@@ -58,4 +65,5 @@
|
|
|
58
65
|
* // *tooltip indicator is the dotted line under a chip
|
|
59
66
|
*/
|
|
60
67
|
|
|
61
|
-
export { default } from './
|
|
68
|
+
export { default } from './GroupedChips';
|
|
69
|
+
export { default as DeleteAllChip } from './DeleteChip';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
2
|
+
import * as R from 'ramda';
|
|
3
|
+
|
|
4
|
+
export var useStyles = makeStyles(function (theme) {
|
|
5
|
+
return {
|
|
6
|
+
root: {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexWrap: 'wrap'
|
|
9
|
+
},
|
|
10
|
+
chip: {
|
|
11
|
+
height: 'unset',
|
|
12
|
+
borderRadius: 3,
|
|
13
|
+
minHeight: 25,
|
|
14
|
+
fontSize: 12,
|
|
15
|
+
margin: theme.spacing(0.25)
|
|
16
|
+
},
|
|
17
|
+
mainChip: {
|
|
18
|
+
background: 'none',
|
|
19
|
+
color: theme.palette.text.primary
|
|
20
|
+
},
|
|
21
|
+
secondaryChip: {
|
|
22
|
+
backgroundColor: R.path(['palette', 'tertiary', 'light'])(theme) || theme.palette.grey[100],
|
|
23
|
+
'&:hover, &:focus': {
|
|
24
|
+
backgroundColor: R.path(['palette', 'tertiary', 'dark'])(theme) || theme.palette.grey[300]
|
|
25
|
+
},
|
|
26
|
+
color: theme.palette.primary.main
|
|
27
|
+
},
|
|
28
|
+
icon: {
|
|
29
|
+
color: theme.palette.primary.main,
|
|
30
|
+
cursor: 'pointer',
|
|
31
|
+
margin: 0,
|
|
32
|
+
'&:hover': {
|
|
33
|
+
color: 'inherit'
|
|
34
|
+
},
|
|
35
|
+
'& svg': {
|
|
36
|
+
fontSize: 15
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
divider: {
|
|
40
|
+
margin: theme.spacing(0.5),
|
|
41
|
+
backgroundColor: theme.palette.grey[700]
|
|
42
|
+
},
|
|
43
|
+
dividerHz: {
|
|
44
|
+
width: '100%',
|
|
45
|
+
margin: theme.spacing(0.5),
|
|
46
|
+
backgroundColor: theme.palette.grey[700]
|
|
47
|
+
},
|
|
48
|
+
spaceLabel: {
|
|
49
|
+
paddingLeft: 0
|
|
50
|
+
},
|
|
51
|
+
formatLabel: {
|
|
52
|
+
whiteSpace: 'pre-wrap',
|
|
53
|
+
overflowWrap: 'anywhere'
|
|
54
|
+
},
|
|
55
|
+
tooltip: theme.typography.body2,
|
|
56
|
+
childrenIndicator: {
|
|
57
|
+
margin: '0 2px',
|
|
58
|
+
fontSize: 10
|
|
59
|
+
},
|
|
60
|
+
tooltipIndicator: {
|
|
61
|
+
borderBottom: '1px dotted ' + theme.palette.primary.main
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export var myTooltipRenderer = function myTooltipRenderer(_ref) {
|
|
4
|
+
var isRtl = _ref.isRtl,
|
|
5
|
+
labelRenderer = _ref.labelRenderer;
|
|
6
|
+
return R.pipe(R.map(labelRenderer), R.when(R.always(isRtl), R.reverse), R.join(isRtl ? ' < ' : ' > '));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export var isLast = function isLast(index, list) {
|
|
10
|
+
return index + 1 === R.length(list);
|
|
11
|
+
};
|
|
@@ -93,7 +93,7 @@ var HierarchicalFilter = function HierarchicalFilter(props) {
|
|
|
93
93
|
spotlight: { fields: {} },
|
|
94
94
|
action: setSpotlight
|
|
95
95
|
}),
|
|
96
|
-
R.is(Function, toggleBulk) && React.createElement(
|
|
96
|
+
R.is(Function, toggleBulk) && hasSpotligt && React.createElement(
|
|
97
97
|
VerticalButton,
|
|
98
98
|
{
|
|
99
99
|
'aria-label': R.prop('advancedSelection')(labels),
|