@sis-cc/dotstatsuite-visions 12.18.0 → 12.20.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.
@@ -0,0 +1,370 @@
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 Box from '@mui/material/Box';
10
+ import AdvancedSelection from './AdvancedSelection';
11
+ import { Paper, Tab, Tabs, Typography } from '@mui/material';
12
+ import makeStyles from '@mui/styles/makeStyles';
13
+ import CloseIcon from '@mui/icons-material/Close';
14
+ import IconButton from '@mui/material/Button';
15
+ import BackIcon from '@mui/icons-material/ArrowBack';
16
+ import { Button, Tag as InternalTag } from '..';
17
+
18
+ var useStyles = makeStyles(function (theme) {
19
+ return {
20
+ label: _extends({
21
+ textTransform: 'none',
22
+ color: theme.palette.grey[700]
23
+ }, R.pathOr({}, ['mixins', 'expansionPanel', 'title'], theme)),
24
+ labelSelected: {
25
+ color: theme.palette.primary.main
26
+ },
27
+ tabSelected: {
28
+ backgroundColor: theme.palette.action.hover + ' !important',
29
+ '&:hover': {
30
+ backgroundColor: theme.palette.action.selected + ' !important'
31
+ }
32
+ },
33
+ tab: {
34
+ '&:hover': {
35
+ backgroundColor: '' + theme.palette.action.selected
36
+ }
37
+ },
38
+ tabPanel: {
39
+ backgroundColor: theme.palette.background.default,
40
+ position: 'absolute',
41
+ top: '176px',
42
+ zIndex: 1000,
43
+ width: '80vw',
44
+ height: '100vh',
45
+ left: '200px'
46
+ }
47
+ };
48
+ });
49
+
50
+ var TabPanel = function TabPanel(props) {
51
+ var children = props.children,
52
+ open = props.open,
53
+ item = props.item,
54
+ classes = props.classes,
55
+ labels = props.labels,
56
+ onClose = props.onClose,
57
+ isNarrow = props.isNarrow,
58
+ setOpen = props.setOpen,
59
+ other = _objectWithoutProperties(props, ['children', 'open', 'item', 'classes', 'labels', 'onClose', 'isNarrow', 'setOpen']);
60
+
61
+ return React.createElement(
62
+ 'div',
63
+ _extends({
64
+ role: 'tabpanel',
65
+ hidden: !open,
66
+ id: 'vertical-tabpanel-' + item.index,
67
+ 'aria-labelledby': 'vertical-tab-' + item.index,
68
+ className: isNarrow ? classes.tabPanelNarrow : classes.tabPanel
69
+ }, other),
70
+ open && React.createElement(
71
+ Box,
72
+ { sx: { p: 3 } },
73
+ isNarrow && React.createElement(
74
+ IconButton,
75
+ {
76
+ onClick: function onClick() {
77
+ return setOpen(false);
78
+ },
79
+ 'data-testid': 'back_button',
80
+ 'aria-label': R.prop('cancel', labels),
81
+ sx: {
82
+ padding: 0,
83
+ float: 'left'
84
+ },
85
+ size: 'large'
86
+ },
87
+ React.createElement(BackIcon, null)
88
+ ),
89
+ React.createElement(
90
+ IconButton,
91
+ {
92
+ onClick: onClose,
93
+ 'aria-label': R.prop('cancel', labels),
94
+ sx: {
95
+ color: 'grey !important',
96
+ padding: 0,
97
+ float: 'right'
98
+ },
99
+ size: 'large'
100
+ },
101
+ React.createElement(CloseIcon, null)
102
+ ),
103
+ children
104
+ )
105
+ );
106
+ };
107
+ TabPanel.propTypes = process.env.NODE_ENV !== "production" ? {
108
+ item: PropTypes.object,
109
+ open: PropTypes.bool,
110
+ classes: PropTypes.object,
111
+ labels: PropTypes.object,
112
+ onClose: PropTypes.func,
113
+ children: PropTypes.node,
114
+ isNarrow: PropTypes.bool,
115
+ setOpen: PropTypes.func
116
+ } : {};
117
+
118
+ var PaperComponent = function PaperComponent(props) {
119
+ var _cx;
120
+
121
+ var classes = useStyles();
122
+ return React.createElement(
123
+ Paper,
124
+ props,
125
+ React.createElement(
126
+ Box,
127
+ { sx: { display: 'flex', justifyContent: 'space-between', width: '100%' } },
128
+ React.createElement(
129
+ Typography,
130
+ {
131
+ noWrap: true,
132
+ variant: 'body2',
133
+ title: props.label,
134
+ className: cx(classes.label, (_cx = {}, _cx[classes.labelSelected] = props.selected, _cx))
135
+ },
136
+ props.label
137
+ ),
138
+ props.tag
139
+ )
140
+ );
141
+ };
142
+ PaperComponent.propTypes = process.env.NODE_ENV !== "production" ? {
143
+ label: PropTypes.string,
144
+ tag: PropTypes.elementType,
145
+ selected: PropTypes.bool
146
+ } : {};
147
+
148
+ var DynamicDrawer = function DynamicDrawer(props) {
149
+ var classNames = useStyles();
150
+
151
+ var _useState = useState(false),
152
+ open = _useState[0],
153
+ setOpen = _useState[1];
154
+
155
+ var _useState2 = useState({}),
156
+ filter = _useState2[0],
157
+ setFilter = _useState2[1];
158
+
159
+ var _useState3 = useState({}),
160
+ selection = _useState3[0],
161
+ setSelection = _useState3[1];
162
+
163
+ var _useState4 = useState({}),
164
+ allSelection = _useState4[0],
165
+ setAllSelection = _useState4[1];
166
+
167
+ var getCounter = function getCounter(items, tagAccessor) {
168
+ var selectedItemsIds = R.reduce(function (acc, item) {
169
+ if (R.prop('isSelected', item)) {
170
+ return R.append(item.id, acc);
171
+ }
172
+ return acc;
173
+ }, [], items);
174
+ var itemsIds = R.pluck('id', items);
175
+ var count = R.pipe(R.uniq, R.length)(selectedItemsIds);
176
+ var total = R.pipe(R.uniq, R.length)(itemsIds);
177
+ if (R.is(Function, tagAccessor)) {
178
+ return tagAccessor(count, total);
179
+ }
180
+ return count + '/' + total;
181
+ };
182
+
183
+ var list = props.list,
184
+ labelRenderer = props.labelRenderer,
185
+ onClick = props.onClick,
186
+ handleChangePanel = props.handleChangePanel,
187
+ isNarrow = props.isNarrow,
188
+ labels = props.labels,
189
+ _props$disableAccesso = props.disableAccessor,
190
+ disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
191
+ expandAll = props.expandAll,
192
+ collapseAll = props.collapseAll,
193
+ expandedIds = props.expandedIds,
194
+ allItems = props.allItems,
195
+ periodPanel = props.periodPanel,
196
+ classes = props.classes,
197
+ _props$testId = props.testId,
198
+ testId = _props$testId === undefined ? 'tabs' : _props$testId,
199
+ tagAccessor = props.tagAccessor,
200
+ tagAriaLabel = props.tagAriaLabel,
201
+ children = props.children,
202
+ rest = _objectWithoutProperties(props, ['list', 'labelRenderer', 'onClick', 'handleChangePanel', 'isNarrow', 'labels', 'disableAccessor', 'expandAll', 'collapseAll', 'expandedIds', 'allItems', 'periodPanel', 'classes', 'testId', 'tagAccessor', 'tagAriaLabel', 'children']);
203
+
204
+ var handleChange = function handleChange(e, item) {
205
+ console.log({ item: item, selection: selection, allSelection: allSelection });
206
+ setSelection(_extends({}, allSelection[item.id]));
207
+ handleChangePanel(item.id, allSelection);
208
+ setFilter(item);
209
+ setOpen(true);
210
+ };
211
+ var handleSubmit = function handleSubmit() {
212
+ onClick(allSelection);
213
+ setAllSelection({});
214
+ setSelection({});
215
+ setOpen(false);
216
+ };
217
+ var handleClose = function handleClose() {
218
+ setOpen(false);
219
+ setAllSelection({});
220
+ setSelection({});
221
+ };
222
+ var isHidden = open && isNarrow;
223
+ var isNotHiddenButton = !R.isEmpty(allSelection) && isNarrow;
224
+
225
+ return React.createElement(
226
+ 'div',
227
+ { style: { display: 'flex', flexDirection: 'row' } },
228
+ React.createElement(
229
+ Tabs,
230
+ {
231
+ orientation: 'vertical',
232
+ variant: 'scrollable',
233
+ value: false,
234
+ onChange: handleChange,
235
+ 'aria-label': 'filters',
236
+ 'data-testid': testId,
237
+ sx: {
238
+ display: isHidden ? 'none' : 'flex',
239
+ width: '100%',
240
+ height: '100%',
241
+ borderRight: 1,
242
+ borderColor: 'divider'
243
+ }
244
+ },
245
+ R.map(function (item) {
246
+ var _cx2;
247
+
248
+ var Chip = R.isNil(item.tag) ? InternalTag : item.tag;
249
+ var tagValueLabel = R.isNil(item.tag) && getCounter(item.values, tagAriaLabel);
250
+
251
+ return React.createElement(Tab, {
252
+ key: item.id,
253
+ id: filter.id,
254
+ 'data-testid': item.id + '-tab',
255
+ component: function component(props) {
256
+ return PaperComponent(_extends({
257
+ label: labelRenderer(item),
258
+ selected: filter.id === item.id,
259
+ tag: R.isNil(item.tag) ? React.createElement(
260
+ Chip,
261
+ { items: item.values, tagValueLabel: tagValueLabel },
262
+ getCounter(item.values, tagAccessor)
263
+ ) : item.tag
264
+ }, props));
265
+ },
266
+ label: labelRenderer(item),
267
+ 'aria-label': labelRenderer(item),
268
+ value: item,
269
+ 'aria-selected': filter.id === item.id,
270
+ className: cx(classNames.tab, (_cx2 = {}, _cx2[classNames.tabSelected] = filter.id === item.id, _cx2)),
271
+ sx: {
272
+ alignItems: 'start',
273
+ maxWidth: '100%'
274
+ },
275
+ wrapped: true
276
+ });
277
+ })(list),
278
+ open && !isNarrow && React.createElement(
279
+ Button,
280
+ {
281
+ sx: { float: 'bottom', margin: '10px' },
282
+ 'aria-label': R.prop('apply', labels),
283
+ id: 'apply_button',
284
+ variant: 'contained',
285
+ onClick: handleSubmit
286
+ },
287
+ R.prop('apply', labels)
288
+ ),
289
+ isNotHiddenButton && React.createElement(
290
+ Button,
291
+ {
292
+ sx: { float: 'bottom', margin: '10px' },
293
+ 'aria-label': R.prop('apply', labels),
294
+ id: 'apply_button',
295
+ variant: 'contained',
296
+ onClick: handleSubmit
297
+ },
298
+ R.prop('apply', labels)
299
+ )
300
+ ),
301
+ React.createElement(
302
+ TabPanel,
303
+ {
304
+ item: filter,
305
+ 'data-testid': testId + '_panel',
306
+ open: open,
307
+ labels: labels,
308
+ classes: classes,
309
+ onClose: handleClose,
310
+ isNarrow: isNarrow,
311
+ setOpen: setOpen
312
+ },
313
+ R.equals(filter.id, periodPanel) ? children : React.createElement(AdvancedSelection, _extends({
314
+ id: filter.id,
315
+ items: filter.values,
316
+ isOpen: open,
317
+ labelRenderer: labelRenderer,
318
+ disableAccessor: disableAccessor ? R.pipe(R.prop('isEnabled'), R.not) : undefined,
319
+ labels: labels,
320
+ isNarrow: isNarrow,
321
+ expandAll: expandAll,
322
+ collapseAll: collapseAll,
323
+ expandedIds: expandedIds,
324
+ allItems: allItems,
325
+ selection: selection,
326
+ setSelection: setSelection,
327
+ setAllSelection: setAllSelection,
328
+ allSelection: allSelection
329
+ }, rest, {
330
+ filter: filter
331
+ }))
332
+ )
333
+ );
334
+ };
335
+ DynamicDrawer.propTypes = process.env.NODE_ENV !== "production" ? {
336
+ classes: PropTypes.object,
337
+ testId: PropTypes.string,
338
+ list: PropTypes.array,
339
+ labelAccessor: PropTypes.func,
340
+ tagAccessor: PropTypes.func,
341
+ tagValueLabel: PropTypes.func,
342
+ tag: PropTypes.elementType,
343
+ tagAriaLabel: PropTypes.func,
344
+ handleChangePanel: PropTypes.func,
345
+ displayChildren: PropTypes.func,
346
+ labels: PropTypes.shape({
347
+ placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
348
+ disableItemLabel: PropTypes.string,
349
+ singleSelection: PropTypes.string,
350
+ childrenSelection: PropTypes.string,
351
+ branchSelection: PropTypes.string,
352
+ levelSelection: PropTypes.string,
353
+ selectAll: PropTypes.string,
354
+ deselectAll: PropTypes.string,
355
+ apply: PropTypes.string,
356
+ cancel: PropTypes.string
357
+ }),
358
+ labelRenderer: PropTypes.func,
359
+ expandAll: PropTypes.func,
360
+ collapseAll: PropTypes.func,
361
+ expandedIds: PropTypes.object,
362
+ allItems: PropTypes.array,
363
+ onClick: PropTypes.func,
364
+ periodPanel: PropTypes.string,
365
+ isNarrow: PropTypes.bool,
366
+ disableAccessor: PropTypes.func,
367
+ children: PropTypes.node
368
+ } : {};
369
+
370
+ export default DynamicDrawer;
@@ -0,0 +1,85 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import * as R from 'ramda';
4
+ import { Box, Button, Paper, Typography } from '@mui/material';
5
+ import { Tooltip } from '..';
6
+
7
+ var mapIndexed = R.addIndex(R.map);
8
+ var ButtonCarousel = function ButtonCarousel(_ref) {
9
+ var selectionModes = _ref.selectionModes,
10
+ selectionMode = _ref.selectionMode,
11
+ setSelectionMode = _ref.setSelectionMode,
12
+ classes = _ref.classes;
13
+
14
+ return React.createElement(
15
+ Box,
16
+ {
17
+ sx: {
18
+ overflowX: 'auto',
19
+ overflowY: 'hidden',
20
+ whiteSpace: 'nowrap',
21
+ display: 'block', // allow horizontal scrolling
22
+ width: '100%',
23
+ maxWidth: '100%',
24
+ '&::-webkit-scrollbar': { display: 'none' }, // optional: hide scrollbar
25
+ scrollbarWidth: 'none'
26
+ }
27
+ },
28
+ mapIndexed(function (_ref2) {
29
+ var value = _ref2.value,
30
+ label = _ref2.label,
31
+ img = _ref2.img;
32
+ return React.createElement(
33
+ Tooltip,
34
+ {
35
+ key: value,
36
+ classes: { tooltip: classes.tooltip },
37
+ title: React.createElement('img', { style: { width: '72px', height: '90px' }, src: img, alt: value }),
38
+ tabIndex: -1
39
+ },
40
+ React.createElement(
41
+ Button,
42
+ {
43
+ className: classes.selectButton,
44
+ selected: value === selectionMode,
45
+ onClick: function onClick() {
46
+ setSelectionMode(value);
47
+ },
48
+ 'aria-pressed': value === selectionMode,
49
+ 'aria-label': label,
50
+ tabIndex: 0,
51
+ sx: {
52
+ flex: '0 0 auto', // Prevents buttons from shrinking
53
+ scrollSnapAlign: 'center',
54
+ minWidth: 120, // Minimum width for buttons
55
+ whiteSpace: 'nowrap'
56
+ }
57
+ },
58
+ React.createElement(
59
+ Paper,
60
+ { elevation: 0, className: classes.selectModeItem, key: value },
61
+ React.createElement(
62
+ Typography,
63
+ null,
64
+ label
65
+ ),
66
+ !R.isNil(img) && R.is(String, img) && React.createElement('img', { src: img, alt: value })
67
+ )
68
+ )
69
+ );
70
+ }, selectionModes)
71
+ );
72
+ };
73
+
74
+ export default ButtonCarousel;
75
+
76
+ ButtonCarousel.propTypes = process.env.NODE_ENV !== "production" ? {
77
+ selectionModes: PropTypes.arrayOf(PropTypes.shape({
78
+ value: PropTypes.string.isRequired,
79
+ label: PropTypes.string.isRequired,
80
+ img: PropTypes.string
81
+ })).isRequired,
82
+ selectionMode: PropTypes.string.isRequired,
83
+ setSelectionMode: PropTypes.func.isRequired,
84
+ classes: PropTypes.object.isRequired
85
+ } : {};
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @memberOf VISIONS
3
+ * @name DynamicDrawer
4
+ * @tag component
5
+ * @api public
6
+ * @props
7
+ * DynamicDrawer.propTypes = {
8
+ * classes: PropTypes.object,
9
+ * testId: PropTypes.string,
10
+ * list: PropTypes.array,
11
+ * labelAccessor: PropTypes.func,
12
+ * tagAccessor: PropTypes.func,
13
+ * tagValueLabel: PropTypes.func,
14
+ * tag: PropTypes.elementType,
15
+ * tagAriaLabel: PropTypes.func,
16
+ * handleChangePanel: PropTypes.func,
17
+ * displayChildren: PropTypes.func,
18
+ * labels: PropTypes.shape({
19
+ * placeholder: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
20
+ * disableItemLabel: PropTypes.string,
21
+ * singleSelection: PropTypes.string,
22
+ * childrenSelection: PropTypes.string,
23
+ * branchSelection: PropTypes.string,
24
+ * levelSelection: PropTypes.string,
25
+ * selectAll: PropTypes.string,
26
+ * deselectAll: PropTypes.string,
27
+ * apply: PropTypes.string,
28
+ * cancel: PropTypes.string,
29
+ * }),
30
+ * labelRenderer: PropTypes.func,
31
+ * expandAll: PropTypes.func,
32
+ * collapseAll: PropTypes.func,
33
+ * expandedIds: PropTypes.object,
34
+ * allItems: PropTypes.array,
35
+ * onClick: PropTypes.func,
36
+ * periodPanel: PropTypes.string,
37
+ * isNarrow: PropTypes.bool,
38
+ * disableAccessor: PropTypes.func,
39
+ * children: PropTypes.node,
40
+ * },
41
+ * }
42
+ */
43
+
44
+ export { default } from './DynamicDrawer';