@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,459 @@
|
|
|
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
|
+
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
|
+
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import * as R from 'ramda';
|
|
8
|
+
import cx from 'classnames';
|
|
9
|
+
import { getHierarchicalId } from '../VirtualizedTree/VirtualizedTree';
|
|
10
|
+
import IconButton from '@material-ui/core/Button';
|
|
11
|
+
import Dialog from '@material-ui/core/Dialog';
|
|
12
|
+
import DialogTitle from '@material-ui/core/DialogTitle';
|
|
13
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
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
|
+
import Paper from '@material-ui/core/Paper';
|
|
18
|
+
import Grid from '@material-ui/core/Grid';
|
|
19
|
+
import Typography from '@material-ui/core/Typography';
|
|
20
|
+
import PlaylistAddCheckIcon from '@material-ui/icons/PlaylistAddCheck';
|
|
21
|
+
import CloseIcon from '@material-ui/icons/Close';
|
|
22
|
+
import HintIcon from '@material-ui/icons/EmojiObjects';
|
|
23
|
+
import Draggable from 'react-draggable';
|
|
24
|
+
import { Button, Spotlight, VirtualizedTree } from '..';
|
|
25
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
26
|
+
|
|
27
|
+
var PaperComponent = function PaperComponent(props) {
|
|
28
|
+
return React.createElement(
|
|
29
|
+
Draggable,
|
|
30
|
+
{ handle: '#draggable-dialog-title', cancel: '[class*="MuiDialogContent-root"]' },
|
|
31
|
+
React.createElement(Paper, _extends({ style: { minWidth: '75%', height: 700 } }, props))
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
var useStyles = makeStyles(function (theme) {
|
|
36
|
+
return {
|
|
37
|
+
header: {
|
|
38
|
+
color: 'black',
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'space-between',
|
|
42
|
+
width: '100%'
|
|
43
|
+
},
|
|
44
|
+
headerLabel: {
|
|
45
|
+
display: 'flex',
|
|
46
|
+
alignItems: 'center'
|
|
47
|
+
},
|
|
48
|
+
closeButton: {
|
|
49
|
+
color: 'grey !important',
|
|
50
|
+
padding: 0
|
|
51
|
+
},
|
|
52
|
+
selectMode: {
|
|
53
|
+
marginLeft: 10,
|
|
54
|
+
'& .MuiInputBase-root': {
|
|
55
|
+
height: 32
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
topElements: {
|
|
59
|
+
display: 'flex',
|
|
60
|
+
flexDirection: 'row',
|
|
61
|
+
alignItems: 'center'
|
|
62
|
+
},
|
|
63
|
+
narrowTop: {
|
|
64
|
+
flexDirection: 'column',
|
|
65
|
+
alignItems: 'flex-start'
|
|
66
|
+
},
|
|
67
|
+
spotlight: { width: '45%' },
|
|
68
|
+
narrowSpotlight: { width: '100%' },
|
|
69
|
+
selectionButton: {
|
|
70
|
+
marginLeft: 24,
|
|
71
|
+
height: 32
|
|
72
|
+
},
|
|
73
|
+
narrowSelectionButton: {
|
|
74
|
+
height: 32,
|
|
75
|
+
marginTop: 5
|
|
76
|
+
},
|
|
77
|
+
selectionMenu: {
|
|
78
|
+
width: '50%',
|
|
79
|
+
position: 'absolute',
|
|
80
|
+
top: 105,
|
|
81
|
+
right: 24,
|
|
82
|
+
zIndex: 1
|
|
83
|
+
},
|
|
84
|
+
narrowSelectionMenu: {
|
|
85
|
+
width: '100%'
|
|
86
|
+
},
|
|
87
|
+
selectModeContainer: {
|
|
88
|
+
display: 'flex',
|
|
89
|
+
flexDirection: 'row',
|
|
90
|
+
flexWrap: 'wrap'
|
|
91
|
+
},
|
|
92
|
+
selectedItem: {
|
|
93
|
+
backgroundColor: theme.palette.secondary.main
|
|
94
|
+
},
|
|
95
|
+
selectModeItem: {
|
|
96
|
+
boxShadow: 'none',
|
|
97
|
+
display: 'flex',
|
|
98
|
+
width: 110,
|
|
99
|
+
height: 200,
|
|
100
|
+
flexDirection: 'column',
|
|
101
|
+
justifyContent: 'flex-end',
|
|
102
|
+
'& img': {
|
|
103
|
+
width: 110,
|
|
104
|
+
height: 140
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
hint: {
|
|
108
|
+
marginLeft: 10,
|
|
109
|
+
marginRight: 10,
|
|
110
|
+
display: 'flex',
|
|
111
|
+
flexDirection: 'row'
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export var getScopeGetters = function getScopeGetters(items, groupedItems, disableAccessor) {
|
|
117
|
+
return {
|
|
118
|
+
all: function all() {
|
|
119
|
+
return R.reject(disableAccessor, items);
|
|
120
|
+
},
|
|
121
|
+
single: function single(item) {
|
|
122
|
+
return [item];
|
|
123
|
+
},
|
|
124
|
+
children: function children(item) {
|
|
125
|
+
var childItems = R.propOr([], getHierarchicalId(item), groupedItems);
|
|
126
|
+
return R.reject(disableAccessor, R.prepend(item, childItems));
|
|
127
|
+
},
|
|
128
|
+
branch: function branch(item) {
|
|
129
|
+
var reccurse = function reccurse(_item) {
|
|
130
|
+
var childItems = R.pipe(R.propOr([], getHierarchicalId(_item)), R.map(reccurse), R.unnest)(groupedItems);
|
|
131
|
+
|
|
132
|
+
return R.prepend(_item, childItems);
|
|
133
|
+
};
|
|
134
|
+
var items = reccurse(item);
|
|
135
|
+
return R.reject(disableAccessor, items);
|
|
136
|
+
},
|
|
137
|
+
level: function level(item) {
|
|
138
|
+
var parentId = R.propOr('#ROOT', 'parentId', item);
|
|
139
|
+
var items = R.prop(parentId, groupedItems);
|
|
140
|
+
return R.reject(disableAccessor, items);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
146
|
+
var isOpen = _ref.isOpen,
|
|
147
|
+
onSelect = _ref.onSelect,
|
|
148
|
+
options = _ref.options,
|
|
149
|
+
selected = _ref.selected,
|
|
150
|
+
classes = _ref.classes,
|
|
151
|
+
isNarrow = _ref.isNarrow,
|
|
152
|
+
hint = _ref.hint;
|
|
153
|
+
|
|
154
|
+
if (!isOpen) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
return React.createElement(
|
|
158
|
+
'div',
|
|
159
|
+
{ className: isNarrow ? classes.narrowSelectionMenu : classes.selectionMenu },
|
|
160
|
+
React.createElement(
|
|
161
|
+
Card,
|
|
162
|
+
null,
|
|
163
|
+
React.createElement(
|
|
164
|
+
CardContent,
|
|
165
|
+
{ className: classes.selectModeContainer },
|
|
166
|
+
R.map(function (_ref2) {
|
|
167
|
+
var _cx;
|
|
168
|
+
|
|
169
|
+
var value = _ref2.value,
|
|
170
|
+
label = _ref2.label,
|
|
171
|
+
imgSrc = _ref2.imgSrc;
|
|
172
|
+
return React.createElement(
|
|
173
|
+
Button,
|
|
174
|
+
_extends({}, value === selected ? { variant: 'contained', color: 'secondary' } : {}, {
|
|
175
|
+
key: value,
|
|
176
|
+
onClick: function onClick() {
|
|
177
|
+
return onSelect(value);
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
React.createElement(
|
|
181
|
+
Paper,
|
|
182
|
+
{
|
|
183
|
+
className: cx(classes.selectModeItem, (_cx = {}, _cx[classes.selectedItem] = value === selected, _cx)),
|
|
184
|
+
key: value
|
|
185
|
+
},
|
|
186
|
+
React.createElement(
|
|
187
|
+
Typography,
|
|
188
|
+
{ variant: 'body2' },
|
|
189
|
+
label
|
|
190
|
+
),
|
|
191
|
+
React.createElement('img', { src: imgSrc, alt: value })
|
|
192
|
+
)
|
|
193
|
+
);
|
|
194
|
+
}, options)
|
|
195
|
+
),
|
|
196
|
+
React.createElement(
|
|
197
|
+
'div',
|
|
198
|
+
{ className: classes.hint },
|
|
199
|
+
React.createElement(HintIcon, null),
|
|
200
|
+
React.createElement(
|
|
201
|
+
Typography,
|
|
202
|
+
{ variant: 'body2' },
|
|
203
|
+
hint
|
|
204
|
+
)
|
|
205
|
+
)
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
SelectionModeMenu.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
210
|
+
classes: PropTypes.object,
|
|
211
|
+
hint: PropTypes.string,
|
|
212
|
+
isNarrow: PropTypes.bool,
|
|
213
|
+
isOpen: PropTypes.bool,
|
|
214
|
+
onSelect: PropTypes.func,
|
|
215
|
+
options: PropTypes.array,
|
|
216
|
+
selected: PropTypes.string
|
|
217
|
+
} : {};
|
|
218
|
+
|
|
219
|
+
var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
220
|
+
var _cx2;
|
|
221
|
+
|
|
222
|
+
var id = props.id,
|
|
223
|
+
title = props.title,
|
|
224
|
+
items = props.items,
|
|
225
|
+
labelRenderer = props.labelRenderer,
|
|
226
|
+
onClose = props.onClose,
|
|
227
|
+
changeSelection = props.changeSelection,
|
|
228
|
+
isOpen = props.isOpen,
|
|
229
|
+
isNarrow = props.isNarrow,
|
|
230
|
+
labels = props.labels,
|
|
231
|
+
imgs = props.imgs,
|
|
232
|
+
disableAccessor = props.disableAccessor,
|
|
233
|
+
rest = _objectWithoutProperties(props, ['id', 'title', 'items', 'labelRenderer', 'onClose', 'changeSelection', 'isOpen', 'isNarrow', 'labels', 'imgs', 'disableAccessor']);
|
|
234
|
+
|
|
235
|
+
var _useState = useState(''),
|
|
236
|
+
term = _useState[0].term,
|
|
237
|
+
setSpotlight = _useState[1];
|
|
238
|
+
|
|
239
|
+
var _useState2 = useState('single'),
|
|
240
|
+
selectionMode = _useState2[0],
|
|
241
|
+
setSelectionMode = _useState2[1];
|
|
242
|
+
|
|
243
|
+
var _useState3 = useState(false),
|
|
244
|
+
isOpenSelectionMenu = _useState3[0],
|
|
245
|
+
setIsOpenSelectionMenu = _useState3[1];
|
|
246
|
+
|
|
247
|
+
var _useState4 = useState({}),
|
|
248
|
+
selection = _useState4[0],
|
|
249
|
+
setSelection = _useState4[1];
|
|
250
|
+
|
|
251
|
+
var classes = useStyles();
|
|
252
|
+
|
|
253
|
+
var groupedItemsByParentId = R.groupBy(R.propOr('#ROOT', 'parentId'), items);
|
|
254
|
+
|
|
255
|
+
var recurse = R.filter(function (item) {
|
|
256
|
+
var isValidItem = R.isEmpty(term) || R.isNil(term) ? true : R.includes(R.toLower(term), R.toLower(labelRenderer(item)));
|
|
257
|
+
if (isValidItem) {
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
if (R.has(getHierarchicalId(item), groupedItemsByParentId)) {
|
|
261
|
+
var filtered = recurse(R.prop(getHierarchicalId(item), groupedItemsByParentId));
|
|
262
|
+
if (!R.isEmpty(filtered)) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
var filteredItems = R.isEmpty(term) || R.isNil(term) ? items : recurse(items);
|
|
270
|
+
var selectionItems = R.map(function (item) {
|
|
271
|
+
return _extends({}, item, {
|
|
272
|
+
isSelected: R.has(item.id, selection) ? !item.isSelected : !!item.isSelected
|
|
273
|
+
});
|
|
274
|
+
}, filteredItems);
|
|
275
|
+
var groupedFilteredItems = R.groupBy(R.propOr('#ROOT', 'parentId'), selectionItems);
|
|
276
|
+
|
|
277
|
+
var selectionOptions = [{
|
|
278
|
+
value: 'single',
|
|
279
|
+
label: R.prop('singleSelection', labels),
|
|
280
|
+
imgSrc: R.prop('singleSelection', imgs)
|
|
281
|
+
}, {
|
|
282
|
+
value: 'children',
|
|
283
|
+
label: R.prop('childrenSelection', labels),
|
|
284
|
+
imgSrc: R.prop('childrenSelection', imgs)
|
|
285
|
+
}, {
|
|
286
|
+
value: 'branch',
|
|
287
|
+
label: R.prop('branchSelection', labels),
|
|
288
|
+
imgSrc: R.prop('branchSelection', imgs)
|
|
289
|
+
}, {
|
|
290
|
+
value: 'level',
|
|
291
|
+
label: R.prop('levelSelection', labels),
|
|
292
|
+
imgSrc: R.prop('levelSelection', imgs)
|
|
293
|
+
}, { value: 'all', label: R.prop('allSelection', labels), imgSrc: R.prop('allSelection', imgs) }];
|
|
294
|
+
|
|
295
|
+
var isDisabled = function isDisabled(item) {
|
|
296
|
+
return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
|
|
297
|
+
};
|
|
298
|
+
var scopeGetters = getScopeGetters(selectionItems, groupedFilteredItems, isDisabled);
|
|
299
|
+
|
|
300
|
+
var onChangeSelection = function onChangeSelection(ids) {
|
|
301
|
+
var nextSelection = R.reduce(function (acc, id) {
|
|
302
|
+
return R.has(id, acc) ? R.dissoc(id, acc) : R.assoc(id, id, acc);
|
|
303
|
+
}, selection, ids);
|
|
304
|
+
setSelection(nextSelection);
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
var handleSubmit = function handleSubmit() {
|
|
308
|
+
changeSelection(id, R.values(selection));
|
|
309
|
+
setSelection({});
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
return React.createElement(
|
|
313
|
+
Dialog,
|
|
314
|
+
{
|
|
315
|
+
open: isOpen,
|
|
316
|
+
PaperComponent: PaperComponent,
|
|
317
|
+
'aria-labelledby': 'draggable-dialog-title',
|
|
318
|
+
onClose: onClose
|
|
319
|
+
},
|
|
320
|
+
React.createElement(
|
|
321
|
+
DialogTitle,
|
|
322
|
+
{ style: { cursor: 'move' }, id: 'draggable-dialog-title' },
|
|
323
|
+
React.createElement(
|
|
324
|
+
'div',
|
|
325
|
+
{ className: classes.header },
|
|
326
|
+
React.createElement(
|
|
327
|
+
'div',
|
|
328
|
+
{ className: classes.headerLabel },
|
|
329
|
+
React.createElement(PlaylistAddCheckIcon, { color: 'primary' }),
|
|
330
|
+
'\xA0',
|
|
331
|
+
title
|
|
332
|
+
),
|
|
333
|
+
onClose && React.createElement(
|
|
334
|
+
IconButton,
|
|
335
|
+
{ className: classes.closeButton, onClick: onClose },
|
|
336
|
+
React.createElement(CloseIcon, null)
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
),
|
|
340
|
+
React.createElement(
|
|
341
|
+
DialogContent,
|
|
342
|
+
null,
|
|
343
|
+
React.createElement(
|
|
344
|
+
Grid,
|
|
345
|
+
{ container: true },
|
|
346
|
+
React.createElement(
|
|
347
|
+
Grid,
|
|
348
|
+
{ item: true, xs: 12, className: cx(classes.topElements, (_cx2 = {}, _cx2[classes.narrowTop] = isNarrow, _cx2)) },
|
|
349
|
+
React.createElement(
|
|
350
|
+
'div',
|
|
351
|
+
{ className: isNarrow ? classes.narrowSpotlight : classes.spotlight },
|
|
352
|
+
React.createElement(Spotlight, {
|
|
353
|
+
placeholder: R.prop('placeholder', labels),
|
|
354
|
+
term: term,
|
|
355
|
+
hasCommit: false,
|
|
356
|
+
spotlight: { fields: {} },
|
|
357
|
+
action: setSpotlight
|
|
358
|
+
})
|
|
359
|
+
),
|
|
360
|
+
React.createElement(
|
|
361
|
+
'div',
|
|
362
|
+
null,
|
|
363
|
+
React.createElement(
|
|
364
|
+
Button,
|
|
365
|
+
{
|
|
366
|
+
'aria-label': 'selection mode',
|
|
367
|
+
className: isNarrow ? classes.narrowSelectionButton : classes.selectionButton,
|
|
368
|
+
onClick: function onClick() {
|
|
369
|
+
return setIsOpenSelectionMenu(!isOpenSelectionMenu);
|
|
370
|
+
},
|
|
371
|
+
color: 'primary',
|
|
372
|
+
variant: 'contained',
|
|
373
|
+
alternative: 'siscc'
|
|
374
|
+
},
|
|
375
|
+
R.prop('selectionMode', labels)
|
|
376
|
+
),
|
|
377
|
+
'\xA0',
|
|
378
|
+
R.prop(selectionMode + 'Selection', labels)
|
|
379
|
+
)
|
|
380
|
+
),
|
|
381
|
+
React.createElement(
|
|
382
|
+
Grid,
|
|
383
|
+
{ item: true, xs: 12 },
|
|
384
|
+
React.createElement(SelectionModeMenu, {
|
|
385
|
+
classes: classes,
|
|
386
|
+
isOpen: isOpenSelectionMenu,
|
|
387
|
+
isNarrow: isNarrow,
|
|
388
|
+
options: selectionOptions,
|
|
389
|
+
onSelect: function onSelect(value) {
|
|
390
|
+
setSelectionMode(value);
|
|
391
|
+
setIsOpenSelectionMenu(false);
|
|
392
|
+
},
|
|
393
|
+
selected: selectionMode,
|
|
394
|
+
hint: R.prop('hint', labels)
|
|
395
|
+
}),
|
|
396
|
+
React.createElement(VirtualizedTree, _extends({}, rest, {
|
|
397
|
+
disableAccessor: disableAccessor,
|
|
398
|
+
labels: labels,
|
|
399
|
+
labelRenderer: labelRenderer,
|
|
400
|
+
items: selectionItems,
|
|
401
|
+
changeSelection: onChangeSelection,
|
|
402
|
+
withExpandControl: true,
|
|
403
|
+
maxTreeHeight: 500,
|
|
404
|
+
getItemScope: R.prop(selectionMode, scopeGetters)
|
|
405
|
+
}))
|
|
406
|
+
)
|
|
407
|
+
)
|
|
408
|
+
),
|
|
409
|
+
React.createElement(
|
|
410
|
+
DialogActions,
|
|
411
|
+
null,
|
|
412
|
+
R.is(Function, onClose) && React.createElement(
|
|
413
|
+
Button,
|
|
414
|
+
{ onClick: onClose, color: 'primary' },
|
|
415
|
+
R.prop('cancel', labels)
|
|
416
|
+
),
|
|
417
|
+
R.is(Function, changeSelection) && React.createElement(
|
|
418
|
+
Button,
|
|
419
|
+
{
|
|
420
|
+
disabled: R.isEmpty(selection),
|
|
421
|
+
onClick: handleSubmit,
|
|
422
|
+
color: 'primary',
|
|
423
|
+
variant: 'contained',
|
|
424
|
+
alternative: 'siscc'
|
|
425
|
+
},
|
|
426
|
+
R.prop('apply', labels)
|
|
427
|
+
)
|
|
428
|
+
)
|
|
429
|
+
);
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
AdvancedFilterDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
433
|
+
id: PropTypes.string,
|
|
434
|
+
accessibility: PropTypes.bool,
|
|
435
|
+
changeSelection: PropTypes.func,
|
|
436
|
+
disableAccessor: PropTypes.func,
|
|
437
|
+
HTMLRenderer: PropTypes.func,
|
|
438
|
+
imgs: PropTypes.object,
|
|
439
|
+
isRtl: PropTypes.bool,
|
|
440
|
+
isNarrow: PropTypes.bool,
|
|
441
|
+
isOpen: PropTypes.bool,
|
|
442
|
+
items: PropTypes.array,
|
|
443
|
+
labels: PropTypes.shape({
|
|
444
|
+
placeholder: PropTypes.string,
|
|
445
|
+
disableItemLabel: PropTypes.string,
|
|
446
|
+
singleSelection: PropTypes.string,
|
|
447
|
+
childrenSelection: PropTypes.string,
|
|
448
|
+
branchSelection: PropTypes.string,
|
|
449
|
+
levelSelection: PropTypes.string,
|
|
450
|
+
allSelection: PropTypes.string,
|
|
451
|
+
apply: PropTypes.string,
|
|
452
|
+
cancel: PropTypes.string
|
|
453
|
+
}),
|
|
454
|
+
onClose: PropTypes.func,
|
|
455
|
+
labelRenderer: PropTypes.func,
|
|
456
|
+
title: PropTypes.string
|
|
457
|
+
} : {};
|
|
458
|
+
|
|
459
|
+
export default AdvancedFilterDialog;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @memberOf VISIONS
|
|
4
|
+
* @name AdvancedFilterDialog
|
|
5
|
+
* @tag component
|
|
6
|
+
* @api public
|
|
7
|
+
* @props
|
|
8
|
+
* AdvancedFilterDialog.propTypes = {
|
|
9
|
+
* items: {
|
|
10
|
+
* id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
11
|
+
* label: PropTypes.string,
|
|
12
|
+
* parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
13
|
+
* isSelected: PropTypes.bool,
|
|
14
|
+
* isDisabled: PropTypes.bool,
|
|
15
|
+
* count: PropTypes.number,
|
|
16
|
+
* path: PropTypes.arrayOf(PropTypes.shape({
|
|
17
|
+
* id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
18
|
+
* label: PropTypes.string,
|
|
19
|
+
* parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
20
|
+
* isSelected: PropTypes.bool,
|
|
21
|
+
* })),
|
|
22
|
+
* },
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export { default } from './AdvancedFilterDialog';
|
|
@@ -0,0 +1,142 @@
|
|
|
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, { useState, Fragment } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import * as R from 'ramda';
|
|
6
|
+
import Container from '@material-ui/core/Container';
|
|
7
|
+
import PlaylistAddCheckIcon from '@material-ui/icons/PlaylistAddCheck';
|
|
8
|
+
import { ExpansionPanel, Tag as InternalTag, VerticalButton, Spotlight, VirtualizedTree } from '../';
|
|
9
|
+
import { useStyles } from '../ScopeList/styles';
|
|
10
|
+
import { useTheme } from '@material-ui/core';
|
|
11
|
+
import { getIsRtl } from '../utils';
|
|
12
|
+
|
|
13
|
+
var getCounter = function getCounter(items, displayAccessor, tagAccessor) {
|
|
14
|
+
var count = R.pipe(R.filter(R.prop('isSelected')), R.length)(items);
|
|
15
|
+
var total = R.pipe(R.when(R.always(R.is(Function, displayAccessor)), R.filter(displayAccessor)), R.length)(items);
|
|
16
|
+
if (R.is(Function, tagAccessor)) {
|
|
17
|
+
return tagAccessor(count, total);
|
|
18
|
+
}
|
|
19
|
+
return count + '/' + total;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var HierarchicalFilter = function HierarchicalFilter(props) {
|
|
23
|
+
var id = props.id,
|
|
24
|
+
items = props.items,
|
|
25
|
+
changeSelection = props.changeSelection,
|
|
26
|
+
onChangeActivePanel = props.onChangeActivePanel,
|
|
27
|
+
activePanelId = props.activePanelId,
|
|
28
|
+
Tag = props.Tag,
|
|
29
|
+
testId = props.testId,
|
|
30
|
+
accessibility = props.accessibility,
|
|
31
|
+
_props$expansionPanel = props.expansionPanelProps,
|
|
32
|
+
expansionPanelProps = _props$expansionPanel === undefined ? {} : _props$expansionPanel,
|
|
33
|
+
_props$labelRenderer = props.labelRenderer,
|
|
34
|
+
labelRenderer = _props$labelRenderer === undefined ? R.prop('label') : _props$labelRenderer,
|
|
35
|
+
toggleBulk = props.toggleBulk,
|
|
36
|
+
label = props.label,
|
|
37
|
+
labels = props.labels,
|
|
38
|
+
tagAccessor = props.tagAccessor,
|
|
39
|
+
displayAccessor = props.displayAccessor;
|
|
40
|
+
|
|
41
|
+
var _useState = useState({ term: '' }),
|
|
42
|
+
term = _useState[0].term,
|
|
43
|
+
setSpotlight = _useState[1];
|
|
44
|
+
|
|
45
|
+
var classes = useStyles({ accessibility: accessibility });
|
|
46
|
+
var theme = useTheme();
|
|
47
|
+
var isRtl = getIsRtl(theme);
|
|
48
|
+
var Chip = R.isNil(Tag) ? InternalTag : Tag;
|
|
49
|
+
var tagValue = getCounter(items, displayAccessor, tagAccessor);
|
|
50
|
+
var groupedItemsByParentId = R.groupBy(R.propOr('#ROOT', 'parentId'), items);
|
|
51
|
+
var hasSpotligt = R.length(items) >= 8;
|
|
52
|
+
var recurse = R.filter(function (item) {
|
|
53
|
+
var isValidItem = R.isEmpty(term) || R.isNil(term) ? true : R.includes(R.toLower(term), R.toLower(labelRenderer(item)));
|
|
54
|
+
if (isValidItem) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (R.has(item.id, groupedItemsByParentId)) {
|
|
58
|
+
var filtered = recurse(R.prop(item.id, groupedItemsByParentId));
|
|
59
|
+
if (!R.isEmpty(filtered)) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
var filteredItems = R.isEmpty(term) || R.isNil(term) ? items : recurse(items);
|
|
67
|
+
|
|
68
|
+
var onSelect = function onSelect(values) {
|
|
69
|
+
changeSelection(id, values);
|
|
70
|
+
};
|
|
71
|
+
return React.createElement(
|
|
72
|
+
ExpansionPanel,
|
|
73
|
+
_extends({
|
|
74
|
+
isOpen: R.equals(id, activePanelId),
|
|
75
|
+
id: id,
|
|
76
|
+
testId: '' + testId,
|
|
77
|
+
label: labelRenderer({ id: id, label: label }),
|
|
78
|
+
onChangeActivePanel: onChangeActivePanel,
|
|
79
|
+
overflow: true,
|
|
80
|
+
topElementComponent: React.createElement(
|
|
81
|
+
Fragment,
|
|
82
|
+
null,
|
|
83
|
+
React.createElement(
|
|
84
|
+
Container,
|
|
85
|
+
{ disableGutters: true, className: classes.spotlightContainer },
|
|
86
|
+
hasSpotligt && React.createElement(Spotlight, {
|
|
87
|
+
className: { container: classes.middle },
|
|
88
|
+
fullWidth: true,
|
|
89
|
+
hasClearAll: true,
|
|
90
|
+
placeholder: R.prop('placeholder', labels),
|
|
91
|
+
term: term,
|
|
92
|
+
hasCommit: false,
|
|
93
|
+
spotlight: { fields: {} },
|
|
94
|
+
action: setSpotlight
|
|
95
|
+
}),
|
|
96
|
+
R.is(Function, toggleBulk) && React.createElement(
|
|
97
|
+
VerticalButton,
|
|
98
|
+
{
|
|
99
|
+
'aria-label': R.prop('advancedSelection')(labels),
|
|
100
|
+
classes: { root: classes.bulkSelectionIcon },
|
|
101
|
+
onClick: toggleBulk
|
|
102
|
+
},
|
|
103
|
+
React.createElement(PlaylistAddCheckIcon, { color: 'primary' })
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
),
|
|
107
|
+
tag: React.createElement(
|
|
108
|
+
Chip,
|
|
109
|
+
{ items: items },
|
|
110
|
+
tagValue
|
|
111
|
+
),
|
|
112
|
+
isBlank: R.isEmpty(items)
|
|
113
|
+
}, expansionPanelProps),
|
|
114
|
+
React.createElement(VirtualizedTree, _extends({}, props, { items: filteredItems, changeSelection: onSelect, isRtl: isRtl }))
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
HierarchicalFilter.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
119
|
+
id: PropTypes.string,
|
|
120
|
+
accessibility: PropTypes.bool,
|
|
121
|
+
activePanelId: PropTypes.string,
|
|
122
|
+
changeSelection: PropTypes.func,
|
|
123
|
+
onChangeActivePanel: PropTypes.func,
|
|
124
|
+
disableAccessor: PropTypes.func,
|
|
125
|
+
displayAccessor: PropTypes.func,
|
|
126
|
+
HTMLRenderer: PropTypes.func,
|
|
127
|
+
isRtl: PropTypes.bool,
|
|
128
|
+
items: PropTypes.array,
|
|
129
|
+
label: PropTypes.string,
|
|
130
|
+
labels: PropTypes.shape({
|
|
131
|
+
disableItemLabel: PropTypes.string,
|
|
132
|
+
placeholder: PropTypes.string
|
|
133
|
+
}),
|
|
134
|
+
labelRenderer: PropTypes.func,
|
|
135
|
+
Tag: PropTypes.func,
|
|
136
|
+
testId: PropTypes.string,
|
|
137
|
+
expansionPanelProps: PropTypes.object,
|
|
138
|
+
toggleBulk: PropTypes.func,
|
|
139
|
+
tagAccessor: PropTypes.func
|
|
140
|
+
} : {};
|
|
141
|
+
|
|
142
|
+
export default HierarchicalFilter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @memberOf VISIONS
|
|
4
|
+
* @name HierarchicalFilter
|
|
5
|
+
* @tag component
|
|
6
|
+
* @api public
|
|
7
|
+
* @props
|
|
8
|
+
* HierarchicalFilter.propTypes = {
|
|
9
|
+
* items: {
|
|
10
|
+
* id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
11
|
+
* label: PropTypes.string,
|
|
12
|
+
* parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
13
|
+
* isSelected: PropTypes.bool,
|
|
14
|
+
* isDisabled: PropTypes.bool,
|
|
15
|
+
* count: PropTypes.number,
|
|
16
|
+
* path: PropTypes.arrayOf(PropTypes.shape({
|
|
17
|
+
* id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
18
|
+
* label: PropTypes.string,
|
|
19
|
+
* parentId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
20
|
+
* isSelected: PropTypes.bool,
|
|
21
|
+
* })),
|
|
22
|
+
* },
|
|
23
|
+
* }
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export { default } from './HierarchicalFilter';
|
package/es/ScopeList/Item.js
CHANGED
|
@@ -56,7 +56,9 @@ var Item = function Item(_ref) {
|
|
|
56
56
|
labelRenderer = _ref.labelRenderer,
|
|
57
57
|
HTMLRenderer = _ref.HTMLRenderer,
|
|
58
58
|
hierarchicalId = _ref.hierarchicalId,
|
|
59
|
-
labels = _ref.labels
|
|
59
|
+
labels = _ref.labels,
|
|
60
|
+
_ref$depth = _ref.depth,
|
|
61
|
+
depth = _ref$depth === undefined ? 0 : _ref$depth;
|
|
60
62
|
|
|
61
63
|
var _React$useState = React.useState(false),
|
|
62
64
|
isTooltipShown = _React$useState[0],
|
|
@@ -90,6 +92,7 @@ var Item = function Item(_ref) {
|
|
|
90
92
|
secondaryTypographyProps: { color: 'inherit' },
|
|
91
93
|
classes: { root: classes.listItem },
|
|
92
94
|
className: cx((_cx2 = {}, _cx2[classes.accessibilityItemHover] = accessibility, _cx2[classes.listItemSelected] = R.and(isSelected, R.not(isDisabled)), _cx2[classes.listItemHover] = R.not(isDisabled), _cx2)),
|
|
95
|
+
style: { marginLeft: depth * 20 + 'px' },
|
|
93
96
|
title: isDisabled ? R.propOr('', 'disableItemLabel')(labels) + ' ' + label : label,
|
|
94
97
|
primary: React.createElement(
|
|
95
98
|
'div',
|
|
@@ -234,7 +237,8 @@ Item.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
234
237
|
labelRenderer: PropTypes.func,
|
|
235
238
|
HTMLRenderer: PropTypes.func,
|
|
236
239
|
hierarchicalId: PropTypes.string,
|
|
237
|
-
labels: PropTypes.object
|
|
240
|
+
labels: PropTypes.object,
|
|
241
|
+
depth: PropTypes.number
|
|
238
242
|
} : {};
|
|
239
243
|
|
|
240
244
|
export default Item;
|