@sis-cc/dotstatsuite-visions 12.17.0 → 12.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.
@@ -340,6 +340,7 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
340
340
  React.createElement(
341
341
  Tooltip,
342
342
  {
343
+ role: 'tooltip',
343
344
  variant: 'light',
344
345
  title: React.createElement(
345
346
  Typography,
@@ -349,7 +350,11 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
349
350
  'aria-label': R.prop('hint', labels),
350
351
  tabIndex: 0
351
352
  },
352
- React.createElement(HintIcon, null)
353
+ React.createElement(
354
+ IconButton,
355
+ null,
356
+ React.createElement(HintIcon, null)
357
+ )
353
358
  ),
354
359
  React.createElement(
355
360
  Typography,
@@ -89,7 +89,7 @@ var Mode = function Mode(_ref2) {
89
89
  { className: classes.content },
90
90
  React.createElement(
91
91
  Typography,
92
- { variant: 'h6', className: classes.title },
92
+ { variant: 'h6', className: classes.title, 'aria-label': title, tabIndex: 0 },
93
93
  title
94
94
  ),
95
95
  React.createElement(
@@ -111,6 +111,7 @@ var Mode = function Mode(_ref2) {
111
111
  label,
112
112
  warningMessage && React.createElement(Warning, { title: warningMessage })
113
113
  ),
114
+ 'aria-label': label,
114
115
  value: value
115
116
  });
116
117
  })(modes)
@@ -0,0 +1,483 @@
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 { getEvolvedDisableAccessor, getHierarchicalId, getScopeGetters } from '../VirtualizedTree/utils';
10
+ import IconButton from '@mui/material/Button';
11
+ import Paper from '@mui/material/Paper';
12
+ import Grid from '@mui/material/Grid';
13
+ import Typography from '@mui/material/Typography';
14
+ import { Button, Spotlight, Tooltip, VirtualizedTree } from '..';
15
+ import { withExpansionTree } from '../VirtualizedTree/withExpansionTree';
16
+ import { withSpotlight } from '../VirtualizedTree/withSpotlight';
17
+ import makeStyles from '@mui/styles/makeStyles';
18
+ import HintIcon from '@mui/icons-material/EmojiObjects';
19
+ import singleImg from '../AdvancedFilterDialog/images/single-selection.png';
20
+ import childrenImg from '../AdvancedFilterDialog/images/children-selection.png';
21
+ import branchImg from '../AdvancedFilterDialog/images/branch-selection.png';
22
+ import levelImg from '../AdvancedFilterDialog/images/level-selection.png';
23
+ import { Divider } from '@mui/material';
24
+
25
+ var useStyles = makeStyles(function (theme) {
26
+ return {
27
+ header: {
28
+ color: 'black',
29
+ display: 'flex',
30
+ alignItems: 'center',
31
+ justifyContent: 'space-between',
32
+ width: '100%'
33
+ },
34
+ headerLabel: {
35
+ fontSize: '16px',
36
+ fontFamily: 'PT Sans Narrow',
37
+ fontWeight: '700',
38
+ color: theme.palette.grey[700]
39
+ },
40
+ selectionTitle: {
41
+ fontSize: '12px',
42
+ fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
43
+ fontWeight: '500',
44
+ color: theme.palette.grey['A700']
45
+ },
46
+ closeButton: {
47
+ color: 'grey !important',
48
+ padding: 0
49
+ },
50
+ selectMode: {
51
+ marginLeft: 10,
52
+ '& .MuiInputBase-root': {
53
+ height: 32
54
+ }
55
+ },
56
+ narrowTop: {
57
+ flexDirection: 'column',
58
+ alignItems: 'flex-start'
59
+ },
60
+ spotlight: { width: '45%' },
61
+ selection: {
62
+ display: 'flex',
63
+ alignItems: 'center'
64
+ },
65
+ narrowSpotlight: { width: '100%' },
66
+ selectionButton: {
67
+ marginLeft: 24,
68
+ marginRight: 15,
69
+ height: 32
70
+ },
71
+ narrowSelectionButton: {
72
+ height: 32,
73
+ marginTop: 15,
74
+ marginRight: 10
75
+ },
76
+ selectionMenu: {
77
+ width: '50%',
78
+ maxHeight: '100%',
79
+ position: 'absolute',
80
+ top: 110,
81
+ right: 48,
82
+ zIndex: 1
83
+ },
84
+ narrowSelectionMenu: {
85
+ width: '100%'
86
+ },
87
+ selectModeContainer: {
88
+ display: 'flex',
89
+ flexDirection: 'column',
90
+ flexWrap: 'wrap',
91
+ alignItems: 'flex-start'
92
+ },
93
+ selectButton: {
94
+ color: theme.palette.primary.main,
95
+ '&:hover': {
96
+ color: theme.palette.primary.main,
97
+ backgroundColor: theme.palette.action.hover
98
+ }
99
+ },
100
+ selectModeItem: {
101
+ boxShadow: 'none',
102
+ display: 'flex',
103
+ backgroundColor: 'transparent',
104
+ flexDirection: 'row-reverse',
105
+ alignItems: 'center',
106
+ '& p': {
107
+ paddingLeft: '5px',
108
+ fontSize: '12px',
109
+ fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
110
+ color: theme.palette.primary.main,
111
+ fontWeight: '500',
112
+ lineHeight: 1.43,
113
+ textAlign: 'left'
114
+ },
115
+ '& img': {
116
+ width: 21,
117
+ height: 24
118
+ }
119
+ },
120
+ hint: {
121
+ display: 'flex',
122
+ flexDirection: 'row',
123
+ alignItems: 'center',
124
+ marginRight: 7,
125
+ color: theme.palette.primary.main
126
+ },
127
+ divider: {
128
+ backgroundColor: theme.palette.primary.light
129
+ },
130
+ actions: {
131
+ justifyContent: 'flex-end'
132
+ },
133
+ ellipsis: {
134
+ whiteSpace: 'nowrap',
135
+ overflow: 'hidden',
136
+ textOverflow: 'ellipsis'
137
+ },
138
+ tooltip: {
139
+ backgroundColor: theme.palette.action.hover
140
+ },
141
+ subheader: {
142
+ display: 'flex',
143
+ flexDirection: 'column',
144
+ alignItems: 'flex-start',
145
+ justifyContent: 'space-between'
146
+ },
147
+ narrowHeader: {
148
+ alignItems: 'flex-start'
149
+ },
150
+ topElements: {
151
+ display: 'flex',
152
+ flexDirection: 'row',
153
+ justifyContent: 'space-between'
154
+ }
155
+ };
156
+ });
157
+
158
+ var AdvancedSelection = function AdvancedSelection(props) {
159
+ var _cx, _cx2, _cx3;
160
+
161
+ var id = props.id,
162
+ items = props.items,
163
+ labelRenderer = props.labelRenderer,
164
+ isNarrow = props.isNarrow,
165
+ labels = props.labels,
166
+ _props$disableAccesso = props.disableAccessor,
167
+ disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
168
+ expandAll = props.expandAll,
169
+ collapseAll = props.collapseAll,
170
+ selection = props.selection,
171
+ setSelection = props.setSelection,
172
+ allSelection = props.allSelection,
173
+ setAllSelection = props.setAllSelection,
174
+ spotlight = props.spotlight,
175
+ setSpotlight = props.setSpotlight,
176
+ expandedIds = props.expandedIds,
177
+ allItems = props.allItems,
178
+ filter = props.filter,
179
+ rest = _objectWithoutProperties(props, ['id', 'items', 'labelRenderer', 'isNarrow', 'labels', 'disableAccessor', 'expandAll', 'collapseAll', 'selection', 'setSelection', 'allSelection', 'setAllSelection', 'spotlight', 'setSpotlight', 'expandedIds', 'allItems', 'filter']);
180
+
181
+ var _useState = useState('single'),
182
+ selectionMode = _useState[0],
183
+ setSelectionMode = _useState[1];
184
+
185
+ var classes = useStyles();
186
+ var getTotal = function getTotal(items, spotlightAcc) {
187
+ var itemsIds = R.pluck('id', items);
188
+ var total = R.pipe(R.uniq, R.length)(itemsIds);
189
+ if (R.is(Function, spotlightAcc)) {
190
+ return spotlightAcc(total);
191
+ }
192
+ return total;
193
+ };
194
+
195
+ var selectionItems = R.map(function (item) {
196
+ return _extends({}, item, {
197
+ isSelected: R.has(item.id, selection) ? !item.isSelected : !!item.isSelected
198
+ });
199
+ }, items);
200
+ var indexedFilteredItems = R.indexBy(getHierarchicalId, selectionItems);
201
+
202
+ var selectionOptions = [{
203
+ value: 'single',
204
+ label: R.prop('singleSelection', labels),
205
+ img: singleImg
206
+ }, {
207
+ value: 'children',
208
+ label: R.prop('childrenSelection', labels),
209
+ img: childrenImg
210
+ }, {
211
+ value: 'branch',
212
+ label: R.prop('branchSelection', labels),
213
+ img: branchImg
214
+ }, {
215
+ value: 'level',
216
+ label: R.prop('levelSelection', labels),
217
+ img: levelImg
218
+ }];
219
+
220
+ var _allGroupedItems = R.pipe(R.map(function (item) {
221
+ return _extends({}, item, {
222
+ isSelected: R.has(item.id, selection) ? !item.isSelected : !!item.isSelected
223
+ });
224
+ }), R.groupBy(R.propOr('#ROOT', 'parentId')))(allItems);
225
+
226
+ var isChildInSelectionScope = function isChildInSelectionScope(child, ancestor) {
227
+ if (!R.has(getHierarchicalId(child), indexedFilteredItems)) {
228
+ return false;
229
+ }
230
+ if (selectionMode === 'single' || selectionMode === 'level') {
231
+ return false;
232
+ }
233
+ if (selectionMode === 'children') {
234
+ return child.parentId === getHierarchicalId(ancestor);
235
+ }
236
+ return true;
237
+ };
238
+
239
+ var _disableAccessor = getEvolvedDisableAccessor(_allGroupedItems, disableAccessor, isChildInSelectionScope);
240
+
241
+ var isDisabled = function isDisabled(item) {
242
+ return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
243
+ };
244
+ var scopeGetter = R.prop(selectionMode, getScopeGetters);
245
+
246
+ var onChangeSelection = function onChangeSelection(ids) {
247
+ var _extends2;
248
+
249
+ var nextSelection = R.reduce(function (acc, id) {
250
+ return R.has(id, acc) ? R.dissoc(id, acc) : R.assoc(id, id, acc);
251
+ }, selection, ids);
252
+ setSelection(nextSelection);
253
+ setAllSelection(_extends({}, allSelection, (_extends2 = {}, _extends2[id] = R.values(nextSelection), _extends2)));
254
+ };
255
+
256
+ var rejectonlyDisabledItems = function rejectonlyDisabledItems(item) {
257
+ return _disableAccessor(item);
258
+ };
259
+ var getSelectedItems = function getSelectedItems(item) {
260
+ return R.propOr(false, 'isSelected')(item);
261
+ };
262
+
263
+ var selectAll = function selectAll() {
264
+ var _extends3;
265
+
266
+ var imposedIds = R.reduce(function (acc, item) {
267
+ return R.uniq(R.concat(R.propOr([], 'imposedIds', item), acc));
268
+ }, [])(items);
269
+ var ids = R.pluck('id', R.reject(getSelectedItems, R.reject(rejectonlyDisabledItems, items)));
270
+ var allIds = R.concat(imposedIds, ids);
271
+ var nextSelection = R.reduce(function (acc, id) {
272
+ return R.has(id, acc) ? acc : R.assoc(id, id, acc);
273
+ }, {}, allIds);
274
+ setSelection(nextSelection);
275
+ setAllSelection(_extends({}, allSelection, (_extends3 = {}, _extends3[id] = R.values(nextSelection), _extends3)));
276
+ };
277
+
278
+ var deselectAll = function deselectAll() {
279
+ var _extends4;
280
+
281
+ var itemIds = R.pipe(R.filter(getSelectedItems), R.pluck('id'))(items);
282
+ var ids = R.difference(itemIds, selection);
283
+ var nextSelection = R.reduce(function (acc, id) {
284
+ return R.has(id, acc) ? acc : R.assoc(id, id, acc);
285
+ }, {}, ids);
286
+ setSelection(nextSelection);
287
+ setAllSelection(_extends({}, allSelection, (_extends4 = {}, _extends4[id] = R.values(nextSelection), _extends4)));
288
+ };
289
+ var mapIndexed = R.addIndex(R.map);
290
+ return React.createElement(
291
+ Grid,
292
+ { container: true },
293
+ React.createElement(
294
+ Grid,
295
+ {
296
+ item: true,
297
+ container: true,
298
+ xs: 12,
299
+ className: cx(classes.topElements, (_cx = {}, _cx[classes.narrowTop] = isNarrow, _cx))
300
+ },
301
+ React.createElement(
302
+ 'div',
303
+ { className: classes.spotlight },
304
+ React.createElement(Spotlight, {
305
+ hasClearAll: true,
306
+ placeholder: getTotal(items, R.prop('placeholder', labels)),
307
+ term: spotlight.term,
308
+ hasCommit: false,
309
+ spotlight: { fields: {} },
310
+ action: setSpotlight
311
+ })
312
+ )
313
+ ),
314
+ React.createElement(
315
+ Grid,
316
+ { item: true, xs: 8 },
317
+ React.createElement(
318
+ 'div',
319
+ { style: { display: 'flex', flexDirection: isNarrow ? 'column' : 'row' } },
320
+ React.createElement(
321
+ 'div',
322
+ null,
323
+ React.createElement(
324
+ Button,
325
+ { onClick: collapseAll, color: 'primary' },
326
+ R.prop('colapseAll', labels)
327
+ ),
328
+ React.createElement(
329
+ Button,
330
+ { style: { marginLeft: 10 }, onClick: expandAll, color: 'primary' },
331
+ R.prop('expandAll', labels)
332
+ )
333
+ ),
334
+ React.createElement(
335
+ 'div',
336
+ null,
337
+ React.createElement(
338
+ Button,
339
+ { onClick: selectAll, color: 'primary' },
340
+ R.prop('selectAll', labels)
341
+ ),
342
+ React.createElement(
343
+ Button,
344
+ { style: { marginLeft: 10 }, onClick: deselectAll, color: 'primary' },
345
+ R.prop('deselectAll', labels)
346
+ )
347
+ )
348
+ ),
349
+ React.createElement(Divider, { className: classes.divider }),
350
+ React.createElement(VirtualizedTree, _extends({}, rest, {
351
+ disableAccessor: _disableAccessor,
352
+ isGreyed: isDisabled,
353
+ labels: labels,
354
+ labelRenderer: labelRenderer,
355
+ items: selectionItems,
356
+ changeSelection: function changeSelection(selection, ids) {
357
+ return onChangeSelection(selection, ids, filter);
358
+ },
359
+ withExpandControl: true
360
+ // treeHeight={"100vh"}
361
+ , scopeGetter: scopeGetter,
362
+ expandedIds: expandedIds
363
+ }))
364
+ ),
365
+ React.createElement(
366
+ Grid,
367
+ { item: true, container: true, xs: 4 },
368
+ React.createElement(
369
+ 'div',
370
+ { className: cx(classes.selectModeContainer, (_cx2 = {}, _cx2[classes.narrowHeader] = isNarrow, _cx2)) },
371
+ React.createElement(
372
+ 'div',
373
+ { className: classes.hint },
374
+ React.createElement(
375
+ Tooltip,
376
+ {
377
+ role: 'tooltip',
378
+ variant: 'light',
379
+ title: React.createElement(
380
+ Typography,
381
+ { variant: 'body2' },
382
+ R.prop('hint', labels)
383
+ ),
384
+ 'aria-label': R.prop('hint', labels),
385
+ tabIndex: 0
386
+ },
387
+ React.createElement(
388
+ IconButton,
389
+ null,
390
+ React.createElement(HintIcon, null)
391
+ )
392
+ ),
393
+ React.createElement(
394
+ Typography,
395
+ {
396
+ className: classes.selectionTitle,
397
+ 'aria-label': R.prop('selectionMode', labels),
398
+ tabIndex: 0
399
+ },
400
+ R.prop('selectionMode', labels)
401
+ )
402
+ ),
403
+ React.createElement(
404
+ 'div',
405
+ { className: cx(classes.selectModeContainer, (_cx3 = {}, _cx3[classes.narrowHeader] = isNarrow, _cx3)) },
406
+ mapIndexed(function (_ref) {
407
+ var value = _ref.value,
408
+ label = _ref.label,
409
+ img = _ref.img;
410
+ return React.createElement(
411
+ Tooltip,
412
+ {
413
+ key: value,
414
+ classes: { tooltip: classes.tooltip },
415
+ title: React.createElement('img', { style: { width: '72px', height: '90px' }, src: img, alt: value }),
416
+ tabIndex: -1
417
+ },
418
+ React.createElement(
419
+ Button,
420
+ {
421
+ className: classes.selectButton,
422
+ selected: value === selectionMode,
423
+ onClick: function onClick() {
424
+ setSelectionMode(value);
425
+ },
426
+ 'aria-pressed': value === selectionMode,
427
+ 'aria-label': label,
428
+ tabIndex: 0
429
+ },
430
+ React.createElement(
431
+ Paper,
432
+ { elevation: 0, className: classes.selectModeItem, key: value },
433
+ React.createElement(
434
+ Typography,
435
+ null,
436
+ label
437
+ ),
438
+ !R.isNil(img) && R.is(String, img) && React.createElement('img', { src: img, alt: value })
439
+ )
440
+ )
441
+ );
442
+ }, selectionOptions)
443
+ )
444
+ )
445
+ )
446
+ );
447
+ };
448
+
449
+ AdvancedSelection.propTypes = process.env.NODE_ENV !== "production" ? {
450
+ id: PropTypes.string,
451
+ accessibility: PropTypes.bool,
452
+ disableAccessor: PropTypes.func,
453
+ HTMLRenderer: PropTypes.func,
454
+ filter: PropTypes.object,
455
+ selection: PropTypes.object,
456
+ allSelection: PropTypes.object,
457
+ setAllSelection: PropTypes.func,
458
+ setSelection: PropTypes.func,
459
+ isRtl: PropTypes.bool,
460
+ isNarrow: PropTypes.bool,
461
+ items: PropTypes.array,
462
+ labels: PropTypes.shape({
463
+ placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
464
+ disableItemLabel: PropTypes.string,
465
+ singleSelection: PropTypes.string,
466
+ childrenSelection: PropTypes.string,
467
+ branchSelection: PropTypes.string,
468
+ levelSelection: PropTypes.string,
469
+ selectAll: PropTypes.string,
470
+ deselectAll: PropTypes.string,
471
+ apply: PropTypes.string,
472
+ cancel: PropTypes.string
473
+ }),
474
+ labelRenderer: PropTypes.func,
475
+ expandAll: PropTypes.func,
476
+ collapseAll: PropTypes.func,
477
+ spotlight: PropTypes.object,
478
+ setSpotlight: PropTypes.func,
479
+ expandedIds: PropTypes.object,
480
+ allItems: PropTypes.array
481
+ } : {};
482
+
483
+ export default withSpotlight(withExpansionTree(AdvancedSelection));