@sis-cc/dotstatsuite-visions 10.5.2 → 10.6.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 +19 -114
- package/es/AdvancedFilterDialog/SelectionModeMenu.js +85 -0
- package/es/HierarchicalFilter/HierarchicalFilter.js +25 -9
- package/es/PeriodPicker/PeriodPicker.js +9 -0
- package/es/Select/Select.js +10 -1
- 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/HierarchicalFilter/HierarchicalFilter.js +28 -11
- package/lib/PeriodPicker/PeriodPicker.js +9 -0
- package/lib/Select/Select.js +13 -1
- 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 +365 -184
- package/umd/@sis-cc/dotstatsuite-visions.min.js +9 -9
- package/umd/@sis-cc/dotstatsuite-visions.min.js.map +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export var getHierarchicalId = function getHierarchicalId(item) {
|
|
4
|
+
return R.prop('hierarchicalId', item) || R.prop('id', item);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export var getDescendants = function getDescendants(id, groupedItems) {
|
|
8
|
+
var reccurse = function reccurse(_id) {
|
|
9
|
+
var children = R.propOr([], _id, groupedItems);
|
|
10
|
+
return R.pipe(R.map(function (item) {
|
|
11
|
+
var __id = getHierarchicalId(item);
|
|
12
|
+
var descendants = reccurse(__id);
|
|
13
|
+
return R.prepend(item, descendants);
|
|
14
|
+
}), R.unnest)(children);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return reccurse(id);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export var isItemSelected = function isItemSelected(selectIds) {
|
|
21
|
+
return function (item) {
|
|
22
|
+
if (!R.isEmpty(selectIds) && R.has(getHierarchicalId(item), selectIds)) {
|
|
23
|
+
return !item.isSelected;
|
|
24
|
+
}
|
|
25
|
+
return !!item.isSelected;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export var getDepth = function getDepth(indexedItems) {
|
|
30
|
+
return function (item) {
|
|
31
|
+
if (R.isNil(item.parentId)) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
var parent = R.prop(item.parentId, indexedItems);
|
|
35
|
+
return getDepth(indexedItems)(parent) + 1;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var getDuplicates = function getDuplicates(items, indexedItems) {
|
|
40
|
+
var itemsIds = R.pluck('id', items);
|
|
41
|
+
var grouped = R.pipe(R.values, R.groupBy(R.prop('id')))(indexedItems);
|
|
42
|
+
return R.pipe(R.props(itemsIds), R.unnest)(grouped);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export var getDeprecatedIds = function getDeprecatedIds(ids, items, selectedIds) {
|
|
46
|
+
var groupedItemsByParentId = items.groupedItemsByParentId,
|
|
47
|
+
indexedItemsById = items.indexedItemsById;
|
|
48
|
+
|
|
49
|
+
var _ids = ids;
|
|
50
|
+
var reccurse = function reccurse(scopeIds) {
|
|
51
|
+
var scopeItems = R.props(scopeIds, indexedItemsById);
|
|
52
|
+
var grouped = R.groupBy(R.propOr('#ROOT', 'parentId'), scopeItems);
|
|
53
|
+
var refined = R.omit(R.append('#ROOT', _ids), grouped);
|
|
54
|
+
|
|
55
|
+
var deprecatedParents = R.reduce(function (acc, id) {
|
|
56
|
+
var _item = R.prop(id, indexedItemsById);
|
|
57
|
+
if (!isItemSelected(selectedIds)(_item)) {
|
|
58
|
+
return acc;
|
|
59
|
+
}
|
|
60
|
+
var _itemsIds = R.has('hierarchicalId', _item) ? R.pipe(R.values, R.filter(R.propEq('id', _item.id)), R.map(getHierarchicalId))(indexedItemsById) : [id];
|
|
61
|
+
|
|
62
|
+
if (R.propOr(true, 'isEnabled', _item)) {
|
|
63
|
+
return acc;
|
|
64
|
+
}
|
|
65
|
+
var children = R.pipe(R.props(_itemsIds), R.unnest)(groupedItemsByParentId);
|
|
66
|
+
var selectedChild = R.find(function (child) {
|
|
67
|
+
return !R.includes(getHierarchicalId(child), _ids) && isItemSelected(selectedIds)(child);
|
|
68
|
+
}, children);
|
|
69
|
+
if (R.isNil(selectedChild)) {
|
|
70
|
+
return R.concat(acc, _itemsIds);
|
|
71
|
+
}
|
|
72
|
+
return acc;
|
|
73
|
+
}, [], R.keys(refined));
|
|
74
|
+
|
|
75
|
+
if (!R.isEmpty(deprecatedParents)) {
|
|
76
|
+
_ids = R.concat(_ids, deprecatedParents);
|
|
77
|
+
var deprecatedAncestors = reccurse(deprecatedParents);
|
|
78
|
+
return R.concat(deprecatedParents, deprecatedAncestors);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return deprecatedParents;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return reccurse(ids);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export var getSingleDisableAccessor = function getSingleDisableAccessor(groupedItems, disableAccessor) {
|
|
88
|
+
// items => total list
|
|
89
|
+
return function (item, selectedIds) {
|
|
90
|
+
if (!isItemSelected(selectedIds)(item) && disableAccessor(item)) {
|
|
91
|
+
var descendants = getDescendants(getHierarchicalId(item), groupedItems);
|
|
92
|
+
var validDescendant = R.find(isItemSelected(selectedIds), descendants);
|
|
93
|
+
return R.isNil(validDescendant);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export var getHierDisableAccessor = function getHierDisableAccessor(groupedItems, spotlightedGroupedItems, disableAccessor) {
|
|
100
|
+
var accessor = function accessor(item, selectedIds) {
|
|
101
|
+
if (!isItemSelected(selectedIds)(item) && disableAccessor(item)) {
|
|
102
|
+
var spotlightedDescendants = getDescendants(getHierarchicalId(item), spotlightedGroupedItems);
|
|
103
|
+
var validSpotlightedDescendant = R.find(function (_item) {
|
|
104
|
+
return !accessor(_item, spotlightedGroupedItems);
|
|
105
|
+
}, spotlightedDescendants);
|
|
106
|
+
if (R.isNil(validSpotlightedDescendant)) {
|
|
107
|
+
var descendants = getDescendants(getHierarchicalId(item), groupedItems);
|
|
108
|
+
var validDescendant = R.find(isItemSelected(selectedIds), descendants);
|
|
109
|
+
return R.isNil(validDescendant);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
return accessor;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export var getScopeGetters = {
|
|
118
|
+
all: function all(items) {
|
|
119
|
+
return function () {
|
|
120
|
+
return R.reject(R.prop('isDisabled'), R.values(items.indexedItemsById));
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
single: function single() {
|
|
124
|
+
return function (item) {
|
|
125
|
+
return [item];
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
children: function children(items) {
|
|
129
|
+
return function (item) {
|
|
130
|
+
var childItems = R.propOr([], getHierarchicalId(item), items.groupedItemsByParentId);
|
|
131
|
+
return R.reject(R.prop('isDisabled'), R.prepend(item, childItems));
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
branch: function branch(items) {
|
|
135
|
+
return function (item) {
|
|
136
|
+
var descendants = getDescendants(getHierarchicalId(item), items.groupedItemsByParentId);
|
|
137
|
+
var res = R.reject(R.prop('isDisabled'), R.prepend(item, descendants));
|
|
138
|
+
return res;
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
level: function level(items) {
|
|
142
|
+
return function (item) {
|
|
143
|
+
var indexed = items.indexedItemsById;
|
|
144
|
+
var depth = getDepth(indexed)(item);
|
|
145
|
+
return R.filter(function (it) {
|
|
146
|
+
return !R.prop('isDisabled', it) && getDepth(indexed)(it) === depth;
|
|
147
|
+
}, R.values(indexed));
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
};
|
|
@@ -5,7 +5,7 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in ob
|
|
|
5
5
|
/* eslint react/prop-types: 0 */
|
|
6
6
|
import React, { useState, useEffect } from 'react';
|
|
7
7
|
import * as R from 'ramda';
|
|
8
|
-
import { getHierarchicalId } from './
|
|
8
|
+
import { getHierarchicalId } from './utils';
|
|
9
9
|
|
|
10
10
|
var withExpansionTree = function withExpansionTree(Component) {
|
|
11
11
|
return function (_ref) {
|
|
@@ -5,7 +5,7 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in ob
|
|
|
5
5
|
/* eslint react/prop-types: 0 */
|
|
6
6
|
import * as R from 'ramda';
|
|
7
7
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
8
|
-
import { getHierarchicalId } from './
|
|
8
|
+
import { getHierarchicalId } from './utils';
|
|
9
9
|
|
|
10
10
|
export var spotlightFilter = function spotlightFilter(term) {
|
|
11
11
|
var labelRenderer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : R.prop('label');
|
|
@@ -55,6 +55,7 @@ var withSpotlight = function withSpotlight(Component) {
|
|
|
55
55
|
}, [term, items]);
|
|
56
56
|
|
|
57
57
|
return React.createElement(Component, _extends({}, rest, {
|
|
58
|
+
allItems: items,
|
|
58
59
|
items: filteredItems,
|
|
59
60
|
labelRenderer: labelRenderer,
|
|
60
61
|
hasSpotlight: R.length(items) >= 8,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.getScopeGetters = undefined;
|
|
5
4
|
|
|
6
5
|
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; };
|
|
7
6
|
|
|
@@ -21,7 +20,7 @@ var _classnames = require('classnames');
|
|
|
21
20
|
|
|
22
21
|
var _classnames2 = _interopRequireDefault(_classnames);
|
|
23
22
|
|
|
24
|
-
var
|
|
23
|
+
var _utils = require('../VirtualizedTree/utils');
|
|
25
24
|
|
|
26
25
|
var _Button = require('@material-ui/core/Button');
|
|
27
26
|
|
|
@@ -43,14 +42,6 @@ var _DialogActions = require('@material-ui/core/DialogActions');
|
|
|
43
42
|
|
|
44
43
|
var _DialogActions2 = _interopRequireDefault(_DialogActions);
|
|
45
44
|
|
|
46
|
-
var _Card = require('@material-ui/core/Card');
|
|
47
|
-
|
|
48
|
-
var _Card2 = _interopRequireDefault(_Card);
|
|
49
|
-
|
|
50
|
-
var _CardContent = require('@material-ui/core/CardContent');
|
|
51
|
-
|
|
52
|
-
var _CardContent2 = _interopRequireDefault(_CardContent);
|
|
53
|
-
|
|
54
45
|
var _Paper = require('@material-ui/core/Paper');
|
|
55
46
|
|
|
56
47
|
var _Paper2 = _interopRequireDefault(_Paper);
|
|
@@ -67,10 +58,6 @@ var _Close = require('@material-ui/icons/Close');
|
|
|
67
58
|
|
|
68
59
|
var _Close2 = _interopRequireDefault(_Close);
|
|
69
60
|
|
|
70
|
-
var _EmojiObjects = require('@material-ui/icons/EmojiObjects');
|
|
71
|
-
|
|
72
|
-
var _EmojiObjects2 = _interopRequireDefault(_EmojiObjects);
|
|
73
|
-
|
|
74
61
|
var _ExpandMore = require('@material-ui/icons/ExpandMore');
|
|
75
62
|
|
|
76
63
|
var _ExpandMore2 = _interopRequireDefault(_ExpandMore);
|
|
@@ -83,6 +70,10 @@ var _reactDraggable = require('react-draggable');
|
|
|
83
70
|
|
|
84
71
|
var _reactDraggable2 = _interopRequireDefault(_reactDraggable);
|
|
85
72
|
|
|
73
|
+
var _SelectionModeMenu = require('./SelectionModeMenu');
|
|
74
|
+
|
|
75
|
+
var _SelectionModeMenu2 = _interopRequireDefault(_SelectionModeMenu);
|
|
76
|
+
|
|
86
77
|
var _ = require('..');
|
|
87
78
|
|
|
88
79
|
var _withExpansionTree = require('../VirtualizedTree/withExpansionTree');
|
|
@@ -247,110 +238,6 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
247
238
|
};
|
|
248
239
|
});
|
|
249
240
|
|
|
250
|
-
var getScopeGetters = exports.getScopeGetters = function getScopeGetters(items, groupedItems, disableAccessor) {
|
|
251
|
-
var indexed = R.indexBy(_VirtualizedTree.getHierarchicalId, items);
|
|
252
|
-
return {
|
|
253
|
-
all: function all() {
|
|
254
|
-
return R.reject(disableAccessor, items);
|
|
255
|
-
},
|
|
256
|
-
single: function single(item) {
|
|
257
|
-
return [item];
|
|
258
|
-
},
|
|
259
|
-
children: function children(item) {
|
|
260
|
-
var childItems = R.propOr([], (0, _VirtualizedTree.getHierarchicalId)(item), groupedItems);
|
|
261
|
-
return R.reject(disableAccessor, R.prepend(item, childItems));
|
|
262
|
-
},
|
|
263
|
-
branch: function branch(item) {
|
|
264
|
-
var reccurse = function reccurse(_item) {
|
|
265
|
-
var childItems = R.pipe(R.propOr([], (0, _VirtualizedTree.getHierarchicalId)(_item)), R.map(reccurse), R.unnest)(groupedItems);
|
|
266
|
-
|
|
267
|
-
return R.prepend(_item, childItems);
|
|
268
|
-
};
|
|
269
|
-
var items = reccurse(item);
|
|
270
|
-
return R.reject(disableAccessor, items);
|
|
271
|
-
},
|
|
272
|
-
level: function level(item) {
|
|
273
|
-
var depth = (0, _VirtualizedTree.getDepth)(indexed)(item);
|
|
274
|
-
return R.filter(function (it) {
|
|
275
|
-
return !disableAccessor(it) && (0, _VirtualizedTree.getDepth)(indexed)(it) === depth;
|
|
276
|
-
}, items);
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
282
|
-
var isOpen = _ref.isOpen,
|
|
283
|
-
onSelect = _ref.onSelect,
|
|
284
|
-
options = _ref.options,
|
|
285
|
-
selected = _ref.selected,
|
|
286
|
-
classes = _ref.classes,
|
|
287
|
-
isNarrow = _ref.isNarrow,
|
|
288
|
-
hint = _ref.hint,
|
|
289
|
-
maxHeight = _ref.maxHeight;
|
|
290
|
-
|
|
291
|
-
if (!isOpen) {
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
return _react2.default.createElement(
|
|
295
|
-
'div',
|
|
296
|
-
{ className: isNarrow ? classes.narrowSelectionMenu : classes.selectionMenu },
|
|
297
|
-
_react2.default.createElement(
|
|
298
|
-
_Card2.default,
|
|
299
|
-
{ style: { maxHeight: maxHeight - 5, overflow: 'auto' } },
|
|
300
|
-
_react2.default.createElement(
|
|
301
|
-
_CardContent2.default,
|
|
302
|
-
{ className: classes.selectModeContainer },
|
|
303
|
-
R.map(function (_ref2) {
|
|
304
|
-
var value = _ref2.value,
|
|
305
|
-
label = _ref2.label,
|
|
306
|
-
img = _ref2.img;
|
|
307
|
-
return _react2.default.createElement(
|
|
308
|
-
_.Button,
|
|
309
|
-
{
|
|
310
|
-
className: classes.selectButton,
|
|
311
|
-
selected: value === selected,
|
|
312
|
-
key: value,
|
|
313
|
-
onClick: function onClick() {
|
|
314
|
-
return onSelect(value);
|
|
315
|
-
}
|
|
316
|
-
},
|
|
317
|
-
_react2.default.createElement(
|
|
318
|
-
_Paper2.default,
|
|
319
|
-
{ className: classes.selectModeItem, key: value },
|
|
320
|
-
_react2.default.createElement(
|
|
321
|
-
_Typography2.default,
|
|
322
|
-
{ variant: 'body2' },
|
|
323
|
-
label
|
|
324
|
-
),
|
|
325
|
-
!R.isNil(img) && R.is(String, img) && _react2.default.createElement('img', { src: img, alt: value })
|
|
326
|
-
)
|
|
327
|
-
);
|
|
328
|
-
}, options)
|
|
329
|
-
),
|
|
330
|
-
_react2.default.createElement(
|
|
331
|
-
'div',
|
|
332
|
-
{ className: classes.hint },
|
|
333
|
-
_react2.default.createElement(_EmojiObjects2.default, null),
|
|
334
|
-
_react2.default.createElement(
|
|
335
|
-
_Typography2.default,
|
|
336
|
-
{ variant: 'body2' },
|
|
337
|
-
hint
|
|
338
|
-
)
|
|
339
|
-
)
|
|
340
|
-
)
|
|
341
|
-
);
|
|
342
|
-
};
|
|
343
|
-
SelectionModeMenu.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
344
|
-
classes: _propTypes2.default.object,
|
|
345
|
-
hint: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array]),
|
|
346
|
-
isNarrow: _propTypes2.default.bool,
|
|
347
|
-
isOpen: _propTypes2.default.bool,
|
|
348
|
-
onSelect: _propTypes2.default.func,
|
|
349
|
-
options: _propTypes2.default.array,
|
|
350
|
-
selected: _propTypes2.default.string,
|
|
351
|
-
maxHeight: _propTypes2.default.number
|
|
352
|
-
} : {};
|
|
353
|
-
|
|
354
241
|
var icons = {
|
|
355
242
|
single: _smallSingleSelection2.default,
|
|
356
243
|
children: _smallChildrenSelection2.default,
|
|
@@ -371,13 +258,15 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
371
258
|
isOpen = props.isOpen,
|
|
372
259
|
isNarrow = props.isNarrow,
|
|
373
260
|
labels = props.labels,
|
|
374
|
-
|
|
261
|
+
_props$disableAccesso = props.disableAccessor,
|
|
262
|
+
disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
|
|
375
263
|
expandAll = props.expandAll,
|
|
376
264
|
collapseAll = props.collapseAll,
|
|
377
265
|
spotlight = props.spotlight,
|
|
378
266
|
setSpotlight = props.setSpotlight,
|
|
379
267
|
expandedIds = props.expandedIds,
|
|
380
|
-
|
|
268
|
+
allItems = props.allItems,
|
|
269
|
+
rest = _objectWithoutProperties(props, ['id', 'title', 'items', 'labelRenderer', 'onClose', 'changeSelection', 'isOpen', 'isNarrow', 'labels', 'disableAccessor', 'expandAll', 'collapseAll', 'spotlight', 'setSpotlight', 'expandedIds', 'allItems']);
|
|
381
270
|
|
|
382
271
|
var _useState = (0, _react.useState)('single'),
|
|
383
272
|
selectionMode = _useState[0],
|
|
@@ -433,10 +322,16 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
433
322
|
img: _allSelection2.default
|
|
434
323
|
}];
|
|
435
324
|
|
|
325
|
+
var _allGroupedItems = R.pipe(R.map(function (item) {
|
|
326
|
+
return _extends({}, item, {
|
|
327
|
+
isSelected: R.has(item.id, selection) ? !item.isSelected : !!item.isSelected
|
|
328
|
+
});
|
|
329
|
+
}), R.groupBy(R.propOr('#ROOT', 'parentId')))(allItems);
|
|
330
|
+
var _disableAccessor = selectionMode === 'single' || selectionMode === 'level' ? (0, _utils.getSingleDisableAccessor)(_allGroupedItems, disableAccessor) : (0, _utils.getHierDisableAccessor)(_allGroupedItems, groupedFilteredItems, disableAccessor);
|
|
436
331
|
var isDisabled = function isDisabled(item) {
|
|
437
332
|
return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
|
|
438
333
|
};
|
|
439
|
-
var
|
|
334
|
+
var scopeGetter = R.prop(selectionMode, _utils.getScopeGetters);
|
|
440
335
|
|
|
441
336
|
var onChangeSelection = function onChangeSelection(ids) {
|
|
442
337
|
var nextSelection = R.reduce(function (acc, id) {
|
|
@@ -541,7 +436,7 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
541
436
|
_react2.default.createElement(
|
|
542
437
|
_Grid2.default,
|
|
543
438
|
{ item: true, xs: 12 },
|
|
544
|
-
_react2.default.createElement(
|
|
439
|
+
_react2.default.createElement(_SelectionModeMenu2.default, {
|
|
545
440
|
classes: classes,
|
|
546
441
|
isOpen: isOpenSelectionMenu,
|
|
547
442
|
isNarrow: isNarrow,
|
|
@@ -555,14 +450,15 @@ var AdvancedFilterDialog = function AdvancedFilterDialog(props) {
|
|
|
555
450
|
maxHeight: listHeight
|
|
556
451
|
}),
|
|
557
452
|
_react2.default.createElement(_.VirtualizedTree, _extends({}, rest, {
|
|
558
|
-
disableAccessor:
|
|
453
|
+
disableAccessor: _disableAccessor,
|
|
454
|
+
isGreyed: isDisabled,
|
|
559
455
|
labels: labels,
|
|
560
456
|
labelRenderer: labelRenderer,
|
|
561
457
|
items: selectionItems,
|
|
562
458
|
changeSelection: onChangeSelection,
|
|
563
459
|
withExpandControl: true,
|
|
564
460
|
treeHeight: listHeight,
|
|
565
|
-
|
|
461
|
+
scopeGetter: scopeGetter,
|
|
566
462
|
expandedIds: expandedIds
|
|
567
463
|
}))
|
|
568
464
|
)
|
|
@@ -645,7 +541,9 @@ AdvancedFilterDialog.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
645
541
|
collapseAll: _propTypes2.default.func,
|
|
646
542
|
spotlight: _propTypes2.default.object,
|
|
647
543
|
setSpotlight: _propTypes2.default.func,
|
|
648
|
-
expandedIds: _propTypes2.default.object
|
|
544
|
+
expandedIds: _propTypes2.default.object,
|
|
545
|
+
allItems: _propTypes2.default.array
|
|
649
546
|
} : {};
|
|
650
547
|
|
|
651
|
-
exports.default = (0, _withSpotlight.withSpotlight)((0, _withExpansionTree.withExpansionTree)(AdvancedFilterDialog));
|
|
548
|
+
exports.default = (0, _withSpotlight.withSpotlight)((0, _withExpansionTree.withExpansionTree)(AdvancedFilterDialog));
|
|
549
|
+
module.exports = exports['default'];
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
|
|
5
|
+
var _react = require('react');
|
|
6
|
+
|
|
7
|
+
var _react2 = _interopRequireDefault(_react);
|
|
8
|
+
|
|
9
|
+
var _propTypes = require('prop-types');
|
|
10
|
+
|
|
11
|
+
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
12
|
+
|
|
13
|
+
var _ramda = require('ramda');
|
|
14
|
+
|
|
15
|
+
var R = _interopRequireWildcard(_ramda);
|
|
16
|
+
|
|
17
|
+
var _Card = require('@material-ui/core/Card');
|
|
18
|
+
|
|
19
|
+
var _Card2 = _interopRequireDefault(_Card);
|
|
20
|
+
|
|
21
|
+
var _CardContent = require('@material-ui/core/CardContent');
|
|
22
|
+
|
|
23
|
+
var _CardContent2 = _interopRequireDefault(_CardContent);
|
|
24
|
+
|
|
25
|
+
var _Paper = require('@material-ui/core/Paper');
|
|
26
|
+
|
|
27
|
+
var _Paper2 = _interopRequireDefault(_Paper);
|
|
28
|
+
|
|
29
|
+
var _Typography = require('@material-ui/core/Typography');
|
|
30
|
+
|
|
31
|
+
var _Typography2 = _interopRequireDefault(_Typography);
|
|
32
|
+
|
|
33
|
+
var _EmojiObjects = require('@material-ui/icons/EmojiObjects');
|
|
34
|
+
|
|
35
|
+
var _EmojiObjects2 = _interopRequireDefault(_EmojiObjects);
|
|
36
|
+
|
|
37
|
+
var _ = require('..');
|
|
38
|
+
|
|
39
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
40
|
+
|
|
41
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
|
+
|
|
43
|
+
var SelectionModeMenu = function SelectionModeMenu(_ref) {
|
|
44
|
+
var isOpen = _ref.isOpen,
|
|
45
|
+
onSelect = _ref.onSelect,
|
|
46
|
+
options = _ref.options,
|
|
47
|
+
selected = _ref.selected,
|
|
48
|
+
classes = _ref.classes,
|
|
49
|
+
isNarrow = _ref.isNarrow,
|
|
50
|
+
hint = _ref.hint,
|
|
51
|
+
maxHeight = _ref.maxHeight;
|
|
52
|
+
|
|
53
|
+
if (!isOpen) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return _react2.default.createElement(
|
|
57
|
+
'div',
|
|
58
|
+
{ className: isNarrow ? classes.narrowSelectionMenu : classes.selectionMenu },
|
|
59
|
+
_react2.default.createElement(
|
|
60
|
+
_Card2.default,
|
|
61
|
+
{ style: { maxHeight: maxHeight - 5, overflow: 'auto' } },
|
|
62
|
+
_react2.default.createElement(
|
|
63
|
+
_CardContent2.default,
|
|
64
|
+
{ className: classes.selectModeContainer },
|
|
65
|
+
R.map(function (_ref2) {
|
|
66
|
+
var value = _ref2.value,
|
|
67
|
+
label = _ref2.label,
|
|
68
|
+
img = _ref2.img;
|
|
69
|
+
return _react2.default.createElement(
|
|
70
|
+
_.Button,
|
|
71
|
+
{
|
|
72
|
+
className: classes.selectButton,
|
|
73
|
+
selected: value === selected,
|
|
74
|
+
key: value,
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
return onSelect(value);
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
_react2.default.createElement(
|
|
80
|
+
_Paper2.default,
|
|
81
|
+
{ className: classes.selectModeItem, key: value },
|
|
82
|
+
_react2.default.createElement(
|
|
83
|
+
_Typography2.default,
|
|
84
|
+
{ variant: 'body2' },
|
|
85
|
+
label
|
|
86
|
+
),
|
|
87
|
+
!R.isNil(img) && R.is(String, img) && _react2.default.createElement('img', { src: img, alt: value })
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
}, options)
|
|
91
|
+
),
|
|
92
|
+
_react2.default.createElement(
|
|
93
|
+
'div',
|
|
94
|
+
{ className: classes.hint },
|
|
95
|
+
_react2.default.createElement(_EmojiObjects2.default, null),
|
|
96
|
+
_react2.default.createElement(
|
|
97
|
+
_Typography2.default,
|
|
98
|
+
{ variant: 'body2' },
|
|
99
|
+
hint
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
SelectionModeMenu.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
107
|
+
classes: _propTypes2.default.object,
|
|
108
|
+
hint: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array]),
|
|
109
|
+
isNarrow: _propTypes2.default.bool,
|
|
110
|
+
isOpen: _propTypes2.default.bool,
|
|
111
|
+
onSelect: _propTypes2.default.func,
|
|
112
|
+
options: _propTypes2.default.array,
|
|
113
|
+
selected: _propTypes2.default.string,
|
|
114
|
+
maxHeight: _propTypes2.default.number
|
|
115
|
+
} : {};
|
|
116
|
+
|
|
117
|
+
exports.default = SelectionModeMenu;
|
|
118
|
+
module.exports = exports['default'];
|
|
@@ -30,19 +30,23 @@ var _withExpansionTree = require('../VirtualizedTree/withExpansionTree');
|
|
|
30
30
|
|
|
31
31
|
var _withSpotlight = require('../VirtualizedTree/withSpotlight');
|
|
32
32
|
|
|
33
|
+
var _utils = require('../VirtualizedTree/utils');
|
|
34
|
+
|
|
33
35
|
var _styles = require('../ScopeList/styles');
|
|
34
36
|
|
|
35
37
|
var _core = require('@material-ui/core');
|
|
36
38
|
|
|
37
|
-
var
|
|
39
|
+
var _utils2 = require('../utils');
|
|
38
40
|
|
|
39
41
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
40
42
|
|
|
41
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
44
|
|
|
43
|
-
var getCounter = function getCounter(items,
|
|
44
|
-
var count = R.pipe(R.filter(
|
|
45
|
-
|
|
45
|
+
var getCounter = function getCounter(items, disableAccessor, tagAccessor) {
|
|
46
|
+
var count = R.pipe(R.filter(function (item) {
|
|
47
|
+
return R.prop('isSelected', item) && !disableAccessor(item);
|
|
48
|
+
}), R.map(R.prop('id')), R.uniq, R.length)(items);
|
|
49
|
+
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);
|
|
46
50
|
if (R.is(Function, tagAccessor)) {
|
|
47
51
|
return tagAccessor(count, total);
|
|
48
52
|
}
|
|
@@ -66,17 +70,24 @@ var HierarchicalFilter = function HierarchicalFilter(props) {
|
|
|
66
70
|
label = props.label,
|
|
67
71
|
labels = props.labels,
|
|
68
72
|
tagAccessor = props.tagAccessor,
|
|
69
|
-
displayAccessor = props.displayAccessor,
|
|
70
73
|
expandedIds = props.expandedIds,
|
|
71
74
|
spotlight = props.spotlight,
|
|
72
75
|
setSpotlight = props.setSpotlight,
|
|
73
|
-
hasSpotlight = props.hasSpotlight
|
|
76
|
+
hasSpotlight = props.hasSpotlight,
|
|
77
|
+
_props$disableAccesso = props.disableAccessor,
|
|
78
|
+
disableAccessor = _props$disableAccesso === undefined ? R.always(false) : _props$disableAccesso,
|
|
79
|
+
allItems = props.allItems;
|
|
74
80
|
|
|
75
81
|
var classes = (0, _styles.useStyles)({ accessibility: accessibility });
|
|
76
82
|
var theme = (0, _core.useTheme)();
|
|
77
|
-
var isRtl = (0,
|
|
83
|
+
var isRtl = (0, _utils2.getIsRtl)(theme);
|
|
78
84
|
var Chip = R.isNil(Tag) ? _.Tag : Tag;
|
|
79
|
-
var
|
|
85
|
+
var _allGroupedItems = R.groupBy(R.propOr('#ROOT', 'parentId'), allItems);
|
|
86
|
+
var _disableAccessor = (0, _utils.getSingleDisableAccessor)(_allGroupedItems, disableAccessor);
|
|
87
|
+
var tagValue = getCounter(items, _disableAccessor, tagAccessor);
|
|
88
|
+
var isDisabled = function isDisabled(item) {
|
|
89
|
+
return R.is(Function, disableAccessor) ? disableAccessor(item) : false;
|
|
90
|
+
};
|
|
80
91
|
|
|
81
92
|
var onSelect = function onSelect(values) {
|
|
82
93
|
changeSelection(id, values);
|
|
@@ -136,7 +147,13 @@ var HierarchicalFilter = function HierarchicalFilter(props) {
|
|
|
136
147
|
tagValue
|
|
137
148
|
)
|
|
138
149
|
}, expansionPanelProps),
|
|
139
|
-
_react2.default.createElement(_.VirtualizedTree, _extends({}, props, {
|
|
150
|
+
_react2.default.createElement(_.VirtualizedTree, _extends({}, props, {
|
|
151
|
+
items: items,
|
|
152
|
+
changeSelection: onSelect,
|
|
153
|
+
isRtl: isRtl,
|
|
154
|
+
disableAccessor: _disableAccessor,
|
|
155
|
+
isGreyed: isDisabled
|
|
156
|
+
}))
|
|
140
157
|
);
|
|
141
158
|
};
|
|
142
159
|
|
|
@@ -147,7 +164,6 @@ HierarchicalFilter.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
147
164
|
changeSelection: _propTypes2.default.func,
|
|
148
165
|
onChangeActivePanel: _propTypes2.default.func,
|
|
149
166
|
disableAccessor: _propTypes2.default.func,
|
|
150
|
-
displayAccessor: _propTypes2.default.func,
|
|
151
167
|
HTMLRenderer: _propTypes2.default.func,
|
|
152
168
|
isRtl: _propTypes2.default.bool,
|
|
153
169
|
items: _propTypes2.default.array,
|
|
@@ -165,7 +181,8 @@ HierarchicalFilter.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
165
181
|
expandedIds: _propTypes2.default.object,
|
|
166
182
|
spotlight: _propTypes2.default.object,
|
|
167
183
|
setSpotlight: _propTypes2.default.func,
|
|
168
|
-
hasSpotlight: _propTypes2.default.bool
|
|
184
|
+
hasSpotlight: _propTypes2.default.bool,
|
|
185
|
+
allItems: _propTypes2.default.array
|
|
169
186
|
} : {};
|
|
170
187
|
|
|
171
188
|
exports.default = (0, _withSpotlight.withSpotlight)((0, _withExpansionTree.withExpansionTree)(HierarchicalFilter));
|
|
@@ -73,6 +73,7 @@ var Period = function Period(_ref) {
|
|
|
73
73
|
|
|
74
74
|
var showFrequency = R.and(R.gt(R.length(frequencies), 1), R.not(frequencyDisabled));
|
|
75
75
|
var destructuringDates = R.map(_lib.getDestructuringDate)(period);
|
|
76
|
+
|
|
76
77
|
var onChangeFrequency = function onChangeFrequency(value) {
|
|
77
78
|
if (R.is(Function, changeFrequency)) return changeFrequency(value);
|
|
78
79
|
};
|
|
@@ -85,10 +86,18 @@ var Period = function Period(_ref) {
|
|
|
85
86
|
return false;
|
|
86
87
|
}
|
|
87
88
|
var dateValue = (0, _lib.getPeriodValue)(fn(destructuringDates));
|
|
89
|
+
|
|
88
90
|
var date = (0, _lib.getDate)(frequency, dateValue, (_getDate = {}, _getDate[id] = Number(value), _getDate), getter === 'end');
|
|
89
91
|
var availableStart = availableBoundaries[0],
|
|
90
92
|
availableEnd = availableBoundaries[1];
|
|
91
93
|
|
|
94
|
+
if (id === 'year') {
|
|
95
|
+
if (_dateFns2.default.isSameYear(date, availableStart)) {
|
|
96
|
+
date = availableStart;
|
|
97
|
+
} else if (_dateFns2.default.isSameYear(date, availableEnd)) {
|
|
98
|
+
date = availableEnd;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
92
101
|
return _dateFns2.default.compareAsc(date, availableStart) === -1 || _dateFns2.default.compareDesc(date, availableEnd) === -1;
|
|
93
102
|
};
|
|
94
103
|
};
|
package/lib/Select/Select.js
CHANGED
|
@@ -28,6 +28,10 @@ var _MenuItem2 = _interopRequireDefault(_MenuItem);
|
|
|
28
28
|
|
|
29
29
|
var _core = require('@material-ui/core');
|
|
30
30
|
|
|
31
|
+
var _classnames = require('classnames');
|
|
32
|
+
|
|
33
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
34
|
+
|
|
31
35
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
32
36
|
|
|
33
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -40,6 +44,9 @@ var useStyles = (0, _styles.makeStyles)(function (theme) {
|
|
|
40
44
|
},
|
|
41
45
|
typo: {
|
|
42
46
|
whiteSpace: 'break-spaces'
|
|
47
|
+
},
|
|
48
|
+
disabledLabel: {
|
|
49
|
+
color: theme.palette.grey[700]
|
|
43
50
|
}
|
|
44
51
|
};
|
|
45
52
|
});
|
|
@@ -143,6 +150,8 @@ var Select = function Select(_ref) {
|
|
|
143
150
|
className: classes.root
|
|
144
151
|
}, textFieldProps),
|
|
145
152
|
R.map(function (item) {
|
|
153
|
+
var _cx;
|
|
154
|
+
|
|
146
155
|
var value = getter('value')(valueAccessor)(item);
|
|
147
156
|
var label = getter('label')(labelAccessor)(item);
|
|
148
157
|
return _react2.default.createElement(
|
|
@@ -158,7 +167,10 @@ var Select = function Select(_ref) {
|
|
|
158
167
|
},
|
|
159
168
|
_react2.default.createElement(
|
|
160
169
|
_core.Typography,
|
|
161
|
-
{
|
|
170
|
+
{
|
|
171
|
+
variant: 'inherit',
|
|
172
|
+
className: (0, _classnames2.default)(classes.typo, (_cx = {}, _cx[classes.disabledLabel] = R.propOr(false, 'disabled')(item), _cx))
|
|
173
|
+
},
|
|
162
174
|
label
|
|
163
175
|
)
|
|
164
176
|
);
|