@bundle-stats/ui 3.2.0-beta.1 → 3.2.1-beta.10
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/.babelrc.js +3 -3
- package/CHANGELOG.md +11 -4
- package/lib/assets/icons/arrow.svg +1 -0
- package/lib/assets/icons/cancel.svg +1 -0
- package/lib/assets/icons/clock.svg +1 -0
- package/lib/assets/icons/close.svg +1 -0
- package/lib/assets/icons/commit.svg +1 -0
- package/lib/assets/icons/filter.svg +1 -0
- package/lib/assets/icons/help.svg +1 -0
- package/lib/assets/icons/menu.svg +1 -0
- package/lib/{ui/icon/assets → assets/icons}/sort.svg +0 -0
- package/lib/assets/icons/warning.svg +1 -0
- package/lib/assets/icons.svg +1 -0
- package/lib/components/browsertime-table/browsertime-table.stories.js +1 -0
- package/lib/components/bundle-assets/bundle-assets.js +3 -3
- package/lib/components/bundle-assets/bundle-assets.stories.js +19 -7
- package/lib/components/bundle-assets/bundle-assets.utils.js +95 -28
- package/lib/components/bundle-assets/index.js +115 -4
- package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +17 -18
- package/lib/components/bundle-modules/bundle-modules.js +3 -3
- package/lib/components/bundle-modules/bundle-modules.utils.js +152 -0
- package/lib/components/bundle-modules/index.js +135 -4
- package/lib/components/bundle-packages/bundle-packages.js +3 -3
- package/lib/components/bundle-packages/{bundle-packages.container.js → bundle-packages.utils.js} +8 -42
- package/lib/components/bundle-packages/index.js +111 -3
- package/lib/components/job-meta/job-meta.js +1 -1
- package/lib/components/metrics-table/metrics-table.js +3 -7
- package/lib/components/metrics-table-search/metrics-table-search.js +2 -1
- package/lib/components/metrics-table-search/metrics-table-search.module.css +2 -1
- package/lib/components/summary/summary.js +52 -34
- package/lib/hooks/rows-filter.js +28 -0
- package/lib/hooks/rows-sort.js +54 -0
- package/lib/{hocs/with-search.js → hooks/search-params.js} +16 -65
- package/lib/layout/box/box.js +2 -2
- package/lib/layout/stack/stack.js +13 -3
- package/lib/ui/icon/icon.js +4 -191
- package/lib/ui/sort-dropdown/sort-dropdown.js +12 -13
- package/lib/ui/sort-dropdown/sort-dropdown.stories.js +2 -2
- package/lib/utils.js +6 -3
- package/lib-esm/app/app.js +60 -70
- package/lib-esm/app/app.stories.js +50 -71
- package/lib-esm/app/header/header.js +5 -3
- package/lib-esm/assets/icons/arrow.svg +1 -0
- package/lib-esm/assets/icons/cancel.svg +1 -0
- package/lib-esm/assets/icons/clock.svg +1 -0
- package/lib-esm/assets/icons/close.svg +1 -0
- package/lib-esm/assets/icons/commit.svg +1 -0
- package/lib-esm/assets/icons/filter.svg +1 -0
- package/lib-esm/assets/icons/help.svg +1 -0
- package/lib-esm/assets/icons/menu.svg +1 -0
- package/lib-esm/{ui/icon/assets → assets/icons}/sort.svg +0 -0
- package/lib-esm/assets/icons/warning.svg +1 -0
- package/lib-esm/assets/icons.svg +1 -0
- package/lib-esm/components/asset-info/asset-info.js +21 -17
- package/lib-esm/components/asset-info/asset-info.stories.js +29 -33
- package/lib-esm/components/browsertime-table/browsertime-table.js +6 -4
- package/lib-esm/components/browsertime-table/browsertime-table.stories.js +11 -14
- package/lib-esm/components/bundle-assets/bundle-assets.constants.js +17 -15
- package/lib-esm/components/bundle-assets/bundle-assets.js +107 -97
- package/lib-esm/components/bundle-assets/bundle-assets.stories.js +58 -63
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js +65 -21
- package/lib-esm/components/bundle-assets/index.js +89 -2
- package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +51 -53
- package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.stories.js +9 -13
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +14 -13
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +13 -19
- package/lib-esm/components/bundle-modules/bundle-modules.constants.js +17 -15
- package/lib-esm/components/bundle-modules/bundle-modules.js +112 -110
- package/lib-esm/components/bundle-modules/bundle-modules.stories.js +46 -58
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js +98 -0
- package/lib-esm/components/bundle-modules/index.js +114 -3
- package/lib-esm/components/bundle-packages/bundle-packages.constants.js +17 -15
- package/lib-esm/components/bundle-packages/bundle-packages.js +71 -69
- package/lib-esm/components/bundle-packages/bundle-packages.stories.js +34 -46
- package/lib-esm/components/bundle-packages/bundle-packages.utils.js +44 -0
- package/lib-esm/components/bundle-packages/index.js +87 -2
- package/lib-esm/components/component-link.js +10 -13
- package/lib-esm/components/delta/delta.js +8 -6
- package/lib-esm/components/delta/delta.stories.js +26 -38
- package/lib-esm/components/duplicate-packages-warning/duplicate-packages-warning.js +11 -9
- package/lib-esm/components/duplicate-packages-warning/duplicate-packages-warning.stories.js +20 -26
- package/lib-esm/components/job-header/job-header.js +14 -11
- package/lib-esm/components/job-header/job-header.stories.js +12 -18
- package/lib-esm/components/job-meta/job-meta.js +15 -18
- package/lib-esm/components/job-meta/job-meta.stories.js +10 -12
- package/lib-esm/components/job-name/job-name.js +9 -12
- package/lib-esm/components/job-name/job-name.stories.js +15 -23
- package/lib-esm/components/jobs-header/jobs-header.js +12 -12
- package/lib-esm/components/jobs-header/jobs-header.stories.js +80 -86
- package/lib-esm/components/lighthouse-table/lighthouse-table.js +6 -4
- package/lib-esm/components/lighthouse-table/lighthouse-table.stories.js +10 -14
- package/lib-esm/components/metric/metric.js +15 -19
- package/lib-esm/components/metric/metric.stories.js +36 -58
- package/lib-esm/components/metrics-table/metrics-table.js +128 -139
- package/lib-esm/components/metrics-table/metrics-table.stories.js +27 -35
- package/lib-esm/components/metrics-table-options/metrics-table-options.js +16 -19
- package/lib-esm/components/metrics-table-options/metrics-table-options.stories.js +6 -12
- package/lib-esm/components/metrics-table-search/metrics-table-search.js +17 -18
- package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +2 -1
- package/lib-esm/components/metrics-table-search/metrics-table-search.stories.js +4 -9
- package/lib-esm/components/metrics-table-title/metrics-table-title.js +9 -7
- package/lib-esm/components/module-info/module-info.js +15 -13
- package/lib-esm/components/module-info/module-info.stories.js +20 -22
- package/lib-esm/components/summary/summary.js +52 -36
- package/lib-esm/components/summary/summary.stories.js +31 -46
- package/lib-esm/components/summary-item/summary-item.js +27 -28
- package/lib-esm/components/summary-item/summary-item.stories.js +40 -50
- package/lib-esm/components/total-size-type-title/total-size-type-title.js +4 -2
- package/lib-esm/constants.js +25 -30
- package/lib-esm/hooks/rows-filter.js +20 -0
- package/lib-esm/hooks/rows-sort.js +22 -0
- package/lib-esm/hooks/search-params.js +170 -0
- package/lib-esm/layout/box/box.js +14 -21
- package/lib-esm/layout/box/box.stories.js +34 -46
- package/lib-esm/layout/flex-stack/flex-stack.js +9 -12
- package/lib-esm/layout/flex-stack/flex-stack.stories.js +39 -49
- package/lib-esm/layout/footer/footer.js +11 -11
- package/lib-esm/layout/footer/footer.stories.js +7 -11
- package/lib-esm/layout/header/header.js +10 -14
- package/lib-esm/layout/header/header.stories.js +50 -44
- package/lib-esm/layout/stack/stack.js +13 -8
- package/lib-esm/layout/stack/stack.stories.js +39 -49
- package/lib-esm/layout/sub-header/sub-header.js +14 -12
- package/lib-esm/layout/sub-header/sub-header.stories.js +57 -69
- package/lib-esm/prototypes/typography.stories.js +49 -58
- package/lib-esm/query-state.js +13 -16
- package/lib-esm/stories/wrapper.js +6 -12
- package/lib-esm/ui/alert/alert.js +6 -4
- package/lib-esm/ui/alert/alert.stories.js +14 -24
- package/lib-esm/ui/container/container.js +6 -9
- package/lib-esm/ui/container/container.stories.js +15 -17
- package/lib-esm/ui/dropdown/dropdown.js +13 -11
- package/lib-esm/ui/dropdown/dropdown.stories.js +22 -26
- package/lib-esm/ui/empty-set/empty-set.js +12 -12
- package/lib-esm/ui/empty-set/empty-set.stories.js +11 -19
- package/lib-esm/ui/file-name/file-name.js +6 -4
- package/lib-esm/ui/file-name/file-name.stories.js +12 -16
- package/lib-esm/ui/filters/filters.container.js +57 -76
- package/lib-esm/ui/filters/filters.js +71 -77
- package/lib-esm/ui/filters/filters.stories.js +82 -100
- package/lib-esm/ui/filters/filters.utils.js +26 -24
- package/lib-esm/ui/filters/index.js +1 -1
- package/lib-esm/ui/horizontal-bar-chart/horizontal-bar-chart.js +68 -78
- package/lib-esm/ui/horizontal-bar-chart/horizontal-bar-chart.stories.js +67 -77
- package/lib-esm/ui/icon/icon.js +13 -202
- package/lib-esm/ui/icon/icon.stories.js +16 -24
- package/lib-esm/ui/input/input.js +7 -10
- package/lib-esm/ui/input/input.stories.js +8 -12
- package/lib-esm/ui/loader/loader.js +6 -9
- package/lib-esm/ui/loader/loader.stories.js +5 -9
- package/lib-esm/ui/logo/logo.constants.js +6 -6
- package/lib-esm/ui/logo/logo.js +15 -15
- package/lib-esm/ui/logo/logo.stories.js +14 -22
- package/lib-esm/ui/panels/panels.js +13 -23
- package/lib-esm/ui/panels/panels.stories.js +14 -16
- package/lib-esm/ui/popover/popover.js +11 -9
- package/lib-esm/ui/popover/popover.stories.js +7 -11
- package/lib-esm/ui/skeleton/skeleton.js +6 -9
- package/lib-esm/ui/skeleton/skeleton.stories.js +2 -4
- package/lib-esm/ui/sort-dropdown/sort-dropdown.js +38 -38
- package/lib-esm/ui/sort-dropdown/sort-dropdown.stories.js +14 -16
- package/lib-esm/ui/table/table.js +26 -31
- package/lib-esm/ui/table/table.stories.js +84 -102
- package/lib-esm/ui/tabs/tabs.js +13 -21
- package/lib-esm/ui/tabs/tabs.stories.js +4 -6
- package/lib-esm/ui/toolbar/toolbar.js +7 -5
- package/lib-esm/ui/toolbar/toolbar.stories.js +14 -16
- package/lib-esm/ui/tooltip/tooltip.js +13 -16
- package/lib-esm/ui/tooltip/tooltip.stories.js +8 -12
- package/lib-esm/utils.js +20 -24
- package/package.json +30 -33
- package/src/assets/icons/arrow.svg +1 -0
- package/src/assets/icons/cancel.svg +1 -0
- package/src/assets/icons/clock.svg +1 -0
- package/src/assets/icons/close.svg +1 -0
- package/src/assets/icons/commit.svg +1 -0
- package/src/assets/icons/filter.svg +1 -0
- package/src/assets/icons/help.svg +1 -0
- package/src/assets/icons/menu.svg +1 -0
- package/src/{ui/icon/assets → assets/icons}/sort.svg +0 -0
- package/src/assets/icons/warning.svg +1 -0
- package/src/assets/icons.svg +1 -0
- package/src/components/bundle-assets/bundle-assets.jsx +3 -3
- package/src/components/bundle-assets/bundle-assets.utils.js +96 -17
- package/src/components/bundle-assets/index.jsx +89 -0
- package/src/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.jsx +15 -15
- package/src/components/bundle-modules/bundle-modules.jsx +3 -3
- package/src/components/bundle-modules/bundle-modules.utils.js +101 -0
- package/src/components/bundle-modules/index.jsx +107 -0
- package/src/components/bundle-packages/bundle-packages.jsx +3 -3
- package/src/components/bundle-packages/bundle-packages.utils.js +47 -0
- package/src/components/bundle-packages/index.jsx +84 -0
- package/src/components/job-meta/job-meta.jsx +1 -3
- package/src/components/metrics-table/metrics-table.jsx +2 -7
- package/src/components/metrics-table-search/metrics-table-search.jsx +1 -0
- package/src/components/metrics-table-search/metrics-table-search.module.css +2 -1
- package/src/components/summary/summary.jsx +26 -10
- package/src/hooks/rows-filter.js +16 -0
- package/src/hooks/rows-sort.js +24 -0
- package/src/hooks/search-params.js +153 -0
- package/src/layout/box/box.jsx +1 -1
- package/src/layout/stack/stack.jsx +2 -2
- package/src/ui/icon/icon.jsx +7 -42
- package/src/ui/sort-dropdown/sort-dropdown.jsx +11 -11
- package/src/utils.jsx +5 -3
- package/lib/components/bundle-assets/bundle-assets.container.js +0 -140
- package/lib/components/bundle-modules/bundle-modules.container.js +0 -222
- package/lib/hocs/with-custom-sort.js +0 -75
- package/lib/hocs/with-filtered-items.js +0 -54
- package/lib/ui/icon/assets/arrow.svg +0 -4
- package/lib/ui/icon/assets/branch.svg +0 -3
- package/lib/ui/icon/assets/cancel.svg +0 -4
- package/lib/ui/icon/assets/clock.svg +0 -3
- package/lib/ui/icon/assets/close.svg +0 -4
- package/lib/ui/icon/assets/commit.svg +0 -3
- package/lib/ui/icon/assets/filter.svg +0 -4
- package/lib/ui/icon/assets/help.svg +0 -4
- package/lib/ui/icon/assets/job.svg +0 -3
- package/lib/ui/icon/assets/menu.svg +0 -4
- package/lib/ui/icon/assets/package.svg +0 -3
- package/lib/ui/icon/assets/pull-request.svg +0 -3
- package/lib/ui/icon/assets/repository.svg +0 -3
- package/lib/ui/icon/assets/warning.svg +0 -4
- package/lib-esm/components/bundle-assets/bundle-assets.container.js +0 -119
- package/lib-esm/components/bundle-modules/bundle-modules.container.js +0 -175
- package/lib-esm/components/bundle-packages/bundle-packages.container.js +0 -91
- package/lib-esm/hocs/with-custom-sort.js +0 -43
- package/lib-esm/hocs/with-filtered-items.js +0 -35
- package/lib-esm/hocs/with-search.js +0 -214
- package/lib-esm/ui/icon/assets/arrow.svg +0 -4
- package/lib-esm/ui/icon/assets/branch.svg +0 -3
- package/lib-esm/ui/icon/assets/cancel.svg +0 -4
- package/lib-esm/ui/icon/assets/clock.svg +0 -3
- package/lib-esm/ui/icon/assets/close.svg +0 -4
- package/lib-esm/ui/icon/assets/commit.svg +0 -3
- package/lib-esm/ui/icon/assets/filter.svg +0 -4
- package/lib-esm/ui/icon/assets/help.svg +0 -4
- package/lib-esm/ui/icon/assets/job.svg +0 -3
- package/lib-esm/ui/icon/assets/menu.svg +0 -4
- package/lib-esm/ui/icon/assets/package.svg +0 -3
- package/lib-esm/ui/icon/assets/pull-request.svg +0 -3
- package/lib-esm/ui/icon/assets/repository.svg +0 -3
- package/lib-esm/ui/icon/assets/warning.svg +0 -4
- package/src/components/bundle-assets/bundle-assets.container.js +0 -146
- package/src/components/bundle-assets/index.js +0 -4
- package/src/components/bundle-modules/bundle-modules.container.js +0 -158
- package/src/components/bundle-modules/index.js +0 -4
- package/src/components/bundle-packages/bundle-packages.container.js +0 -93
- package/src/components/bundle-packages/index.js +0 -4
- package/src/hocs/with-custom-sort.jsx +0 -35
- package/src/hocs/with-filtered-items.jsx +0 -34
- package/src/hocs/with-search.jsx +0 -184
- package/src/ui/icon/assets/arrow.svg +0 -4
- package/src/ui/icon/assets/branch.svg +0 -3
- package/src/ui/icon/assets/cancel.svg +0 -4
- package/src/ui/icon/assets/clock.svg +0 -3
- package/src/ui/icon/assets/close.svg +0 -4
- package/src/ui/icon/assets/commit.svg +0 -3
- package/src/ui/icon/assets/filter.svg +0 -4
- package/src/ui/icon/assets/help.svg +0 -4
- package/src/ui/icon/assets/job.svg +0 -3
- package/src/ui/icon/assets/menu.svg +0 -4
- package/src/ui/icon/assets/package.svg +0 -3
- package/src/ui/icon/assets/pull-request.svg +0 -3
- package/src/ui/icon/assets/repository.svg +0 -3
- package/src/ui/icon/assets/warning.svg +0 -4
|
@@ -1,122 +1,104 @@
|
|
|
1
1
|
import _get from "lodash/get";
|
|
2
|
-
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
-
|
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
|
|
9
2
|
import React, { useCallback, useState } from 'react';
|
|
10
3
|
import { storiesOf } from '@storybook/react';
|
|
11
4
|
import { getWrapperDecorator } from '../../stories';
|
|
12
5
|
import { Filters } from '.';
|
|
13
|
-
|
|
6
|
+
const stories = storiesOf('UI/Filters', module);
|
|
14
7
|
stories.addDecorator(getWrapperDecorator({
|
|
15
8
|
paddingLeft: '200px'
|
|
16
9
|
}));
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
const FiltersState = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
children
|
|
14
|
+
} = _ref;
|
|
15
|
+
const [values, setValues] = useState({
|
|
22
16
|
changed: true,
|
|
23
17
|
'assetType.entrypoint': true
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
setValues(_objectSpread(_objectSpread({}, values), newValues));
|
|
18
|
+
});
|
|
19
|
+
const handleSetValues = useCallback(newValues => {
|
|
20
|
+
setValues({ ...values,
|
|
21
|
+
...newValues
|
|
22
|
+
});
|
|
30
23
|
console.info(newValues);
|
|
31
24
|
}, [values]);
|
|
32
25
|
return children(values, handleSetValues);
|
|
33
26
|
};
|
|
34
27
|
|
|
35
|
-
stories.add('default',
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
label: 'Changed',
|
|
42
|
-
defaultValue: _get(values, 'changed', true)
|
|
43
|
-
},
|
|
44
|
-
fileTypes: {
|
|
45
|
-
label: 'File types',
|
|
46
|
-
CSS: {
|
|
47
|
-
label: 'CSS',
|
|
48
|
-
defaultValue: _get(values, 'fileTypes.CSS', true)
|
|
49
|
-
},
|
|
50
|
-
JS: {
|
|
51
|
-
label: 'JS',
|
|
52
|
-
defaultValue: _get(values, 'fileTypes.JS', true)
|
|
53
|
-
},
|
|
54
|
-
HTML: {
|
|
55
|
-
label: 'HTML',
|
|
56
|
-
defaultValue: _get(values, 'fileTypes.HTML', true)
|
|
57
|
-
},
|
|
58
|
-
OTHER: {
|
|
59
|
-
label: 'Asset that is not CSS, JS or HTML',
|
|
60
|
-
defaultValue: _get(values, 'fileTypes.OTHER', true)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
stories.add('overflow', function () {
|
|
68
|
-
return /*#__PURE__*/React.createElement(FiltersState, null, function (values, setValues) {
|
|
69
|
-
return /*#__PURE__*/React.createElement(Filters, {
|
|
70
|
-
onChange: setValues,
|
|
71
|
-
filters: {
|
|
72
|
-
changed: {
|
|
73
|
-
label: 'Changed',
|
|
74
|
-
defaultValue: _get(values, 'changed', true)
|
|
75
|
-
},
|
|
76
|
-
chunks: _objectSpread({
|
|
77
|
-
label: 'Chunks'
|
|
78
|
-
}, Array(22).fill('').reduce(function (agg, value, currentIndex) {
|
|
79
|
-
var _objectSpread2;
|
|
80
|
-
|
|
81
|
-
return _objectSpread(_objectSpread({}, agg), {}, (_objectSpread2 = {}, _objectSpread2["chunk-" + currentIndex] = {
|
|
82
|
-
label: "Chunk " + (currentIndex + 1),
|
|
83
|
-
defaultValue: _get(values, "chunks.chunk-" + currentIndex)
|
|
84
|
-
}, _objectSpread2));
|
|
85
|
-
}, {}))
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
stories.add('disable options', function () {
|
|
91
|
-
return /*#__PURE__*/React.createElement(Filters, {
|
|
92
|
-
onChange: function onChange(state) {
|
|
93
|
-
console.log(state); // eslint-disable-line no-console
|
|
28
|
+
stories.add('default', () => /*#__PURE__*/React.createElement(FiltersState, null, (values, setValues) => /*#__PURE__*/React.createElement(Filters, {
|
|
29
|
+
onChange: setValues,
|
|
30
|
+
filters: {
|
|
31
|
+
changed: {
|
|
32
|
+
label: 'Changed',
|
|
33
|
+
defaultValue: _get(values, 'changed', true)
|
|
94
34
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
35
|
+
fileTypes: {
|
|
36
|
+
label: 'File types',
|
|
37
|
+
CSS: {
|
|
38
|
+
label: 'CSS',
|
|
39
|
+
defaultValue: _get(values, 'fileTypes.CSS', true)
|
|
40
|
+
},
|
|
41
|
+
JS: {
|
|
42
|
+
label: 'JS',
|
|
43
|
+
defaultValue: _get(values, 'fileTypes.JS', true)
|
|
100
44
|
},
|
|
101
|
-
|
|
102
|
-
label: '
|
|
103
|
-
defaultValue:
|
|
45
|
+
HTML: {
|
|
46
|
+
label: 'HTML',
|
|
47
|
+
defaultValue: _get(values, 'fileTypes.HTML', true)
|
|
104
48
|
},
|
|
105
|
-
|
|
106
|
-
label: '
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
49
|
+
OTHER: {
|
|
50
|
+
label: 'Asset that is not CSS, JS or HTML',
|
|
51
|
+
defaultValue: _get(values, 'fileTypes.OTHER', true)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
})));
|
|
56
|
+
stories.add('overflow', () => /*#__PURE__*/React.createElement(FiltersState, null, (values, setValues) => /*#__PURE__*/React.createElement(Filters, {
|
|
57
|
+
onChange: setValues,
|
|
58
|
+
filters: {
|
|
59
|
+
changed: {
|
|
60
|
+
label: 'Changed',
|
|
61
|
+
defaultValue: _get(values, 'changed', true)
|
|
62
|
+
},
|
|
63
|
+
chunks: {
|
|
64
|
+
label: 'Chunks',
|
|
65
|
+
...Array(22).fill('').reduce((agg, value, currentIndex) => ({ ...agg,
|
|
66
|
+
[`chunk-${currentIndex}`]: {
|
|
67
|
+
label: `Chunk ${currentIndex + 1}`,
|
|
68
|
+
defaultValue: _get(values, `chunks.chunk-${currentIndex}`)
|
|
118
69
|
}
|
|
70
|
+
}), {})
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
})));
|
|
74
|
+
stories.add('disable options', () => /*#__PURE__*/React.createElement(Filters, {
|
|
75
|
+
onChange: state => {
|
|
76
|
+
console.log(state); // eslint-disable-line no-console
|
|
77
|
+
},
|
|
78
|
+
filters: {
|
|
79
|
+
changed: {
|
|
80
|
+
label: 'Changed',
|
|
81
|
+
defaultValue: false,
|
|
82
|
+
disabled: true
|
|
83
|
+
},
|
|
84
|
+
entrypoint: {
|
|
85
|
+
label: 'Entrypoint',
|
|
86
|
+
defaultValue: false
|
|
87
|
+
},
|
|
88
|
+
fileTypes: {
|
|
89
|
+
label: 'File types',
|
|
90
|
+
CSS: {
|
|
91
|
+
label: 'CSS',
|
|
92
|
+
defaultValue: true
|
|
93
|
+
},
|
|
94
|
+
JS: {
|
|
95
|
+
label: 'JS',
|
|
96
|
+
defaultValue: true
|
|
97
|
+
},
|
|
98
|
+
HTML: {
|
|
99
|
+
label: 'HTML',
|
|
100
|
+
defaultValue: true
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
const FILTER_SUFFIX_MAX_LENGTH = 18;
|
|
2
|
+
const ELLIPSES = '...';
|
|
3
|
+
const JOIN = ', ';
|
|
4
|
+
export const LABELS = {
|
|
5
5
|
NONE: 'none',
|
|
6
6
|
ALL: 'all'
|
|
7
7
|
};
|
|
@@ -10,15 +10,16 @@ export var LABELS = {
|
|
|
10
10
|
* @return {String}
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
13
|
+
export const getGroupFiltersLabelSuffix = filters => {
|
|
14
|
+
const filterCount = filters.length; // eslint-disable-next-line no-unused-vars
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const checkedFilters = filters.filter(_ref => {
|
|
17
|
+
let [_, {
|
|
18
|
+
defaultValue
|
|
19
|
+
}] = _ref;
|
|
19
20
|
return defaultValue;
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
const filterCheckedCount = checkedFilters.length;
|
|
22
23
|
|
|
23
24
|
if (filterCheckedCount === 0) {
|
|
24
25
|
return LABELS.NONE;
|
|
@@ -29,38 +30,39 @@ export var getGroupFiltersLabelSuffix = function getGroupFiltersLabelSuffix(filt
|
|
|
29
30
|
} // eslint-disable-next-line no-unused-vars
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const checkedFilterLabels = checkedFilters.map(_ref2 => {
|
|
34
|
+
let [_, {
|
|
35
|
+
label
|
|
36
|
+
}] = _ref2;
|
|
35
37
|
return label;
|
|
36
38
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
let suffix = '';
|
|
40
|
+
let inlinedLabelCount = 0;
|
|
41
|
+
let done = false;
|
|
40
42
|
|
|
41
|
-
for (
|
|
43
|
+
for (let i = 0; !done && i < checkedFilterLabels.length && FILTER_SUFFIX_MAX_LENGTH - suffix.length >= 0; i++ // eslint-disable-line no-plusplus
|
|
42
44
|
) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
const availableSpace = FILTER_SUFFIX_MAX_LENGTH - suffix.length;
|
|
46
|
+
const label = checkedFilterLabels[i];
|
|
47
|
+
let normalizedLabel = '';
|
|
46
48
|
|
|
47
49
|
if (availableSpace - label.length >= 0) {
|
|
48
50
|
// Label is fitting in the available space
|
|
49
51
|
normalizedLabel = label;
|
|
50
52
|
} else if (availableSpace >= 6) {
|
|
51
53
|
// Available space is allowing crop
|
|
52
|
-
normalizedLabel =
|
|
54
|
+
normalizedLabel = `${label.substr(0, availableSpace - 3)}${ELLIPSES}`;
|
|
53
55
|
} else {// noop - the label will not fit
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
if (normalizedLabel) {
|
|
57
|
-
suffix =
|
|
59
|
+
suffix = `${suffix}${suffix ? JOIN : ''}${normalizedLabel}`;
|
|
58
60
|
inlinedLabelCount = i + 1;
|
|
59
61
|
} else {
|
|
60
62
|
done = true;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
+
const skippedLabels = filterCheckedCount - inlinedLabelCount;
|
|
67
|
+
return `${suffix}${skippedLabels > 0 ? ` +${skippedLabels}` : ''}`;
|
|
66
68
|
};
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import _sum from "lodash/sum";
|
|
2
2
|
import _round from "lodash/round";
|
|
3
3
|
import _get from "lodash/get";
|
|
4
|
-
|
|
5
|
-
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
|
6
|
-
|
|
7
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
-
|
|
9
4
|
import React from 'react';
|
|
10
5
|
import PropTypes from 'prop-types';
|
|
11
6
|
import cx from 'classnames';
|
|
@@ -13,47 +8,43 @@ import { getColors } from '../../utils';
|
|
|
13
8
|
import { Tooltip } from '../tooltip';
|
|
14
9
|
import css from './horizontal-bar-chart.module.css';
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_this = _React$Component.call(this, props) || this;
|
|
23
|
-
_this.textRef = /*#__PURE__*/React.createRef();
|
|
24
|
-
_this.ref = /*#__PURE__*/React.createRef();
|
|
25
|
-
_this.state = {
|
|
11
|
+
class HorizontalBarChartItem extends React.Component {
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
14
|
+
this.textRef = /*#__PURE__*/React.createRef();
|
|
15
|
+
this.ref = /*#__PURE__*/React.createRef();
|
|
16
|
+
this.state = {
|
|
26
17
|
isTextOverflowing: true
|
|
27
18
|
};
|
|
28
|
-
return _this;
|
|
29
19
|
}
|
|
30
20
|
|
|
31
|
-
|
|
21
|
+
componentDidMount() {
|
|
22
|
+
const wrapperWidth = _get(this, 'ref.current.clientWidth', 0);
|
|
32
23
|
|
|
33
|
-
|
|
34
|
-
var wrapperWidth = _get(this, 'ref.current.clientWidth', 0);
|
|
35
|
-
|
|
36
|
-
var textWidth = _get(this, 'textRef.current.scrollWidth', 0);
|
|
24
|
+
const textWidth = _get(this, 'textRef.current.scrollWidth', 0);
|
|
37
25
|
|
|
38
26
|
if (wrapperWidth >= textWidth + 2 * 4) {
|
|
39
27
|
this.setState({
|
|
40
28
|
isTextOverflowing: false
|
|
41
29
|
});
|
|
42
30
|
}
|
|
43
|
-
}
|
|
31
|
+
}
|
|
44
32
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
render() {
|
|
34
|
+
const {
|
|
35
|
+
color,
|
|
36
|
+
label,
|
|
37
|
+
getItemTooltip,
|
|
38
|
+
width
|
|
39
|
+
} = this.props;
|
|
40
|
+
const {
|
|
41
|
+
isTextOverflowing
|
|
42
|
+
} = this.state;
|
|
43
|
+
const tooltipContent = getItemTooltip();
|
|
53
44
|
return /*#__PURE__*/React.createElement("span", {
|
|
54
45
|
className: cx(css.item, isTextOverflowing && css.textOverflowed),
|
|
55
46
|
style: {
|
|
56
|
-
width
|
|
47
|
+
width,
|
|
57
48
|
background: color
|
|
58
49
|
},
|
|
59
50
|
ref: this.ref
|
|
@@ -65,10 +56,9 @@ var HorizontalBarChartItem = /*#__PURE__*/function (_React$Component) {
|
|
|
65
56
|
className: css.itemLabel,
|
|
66
57
|
ref: this.textRef
|
|
67
58
|
}, label)));
|
|
68
|
-
}
|
|
59
|
+
}
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
}(React.Component);
|
|
61
|
+
}
|
|
72
62
|
|
|
73
63
|
HorizontalBarChartItem.propTypes = {
|
|
74
64
|
width: PropTypes.string.isRequired,
|
|
@@ -77,57 +67,57 @@ HorizontalBarChartItem.propTypes = {
|
|
|
77
67
|
getItemTooltip: PropTypes.func
|
|
78
68
|
};
|
|
79
69
|
HorizontalBarChartItem.defaultProps = {
|
|
80
|
-
getItemTooltip:
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
70
|
+
getItemTooltip: () => null
|
|
83
71
|
};
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return entry;
|
|
92
|
-
}));
|
|
93
|
-
};
|
|
73
|
+
const getTotalValues = values => _sum(values.map(entry => {
|
|
74
|
+
if (typeof entry === 'object') {
|
|
75
|
+
return entry.value;
|
|
76
|
+
}
|
|
94
77
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
78
|
+
return entry;
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
export const HorizontalBarChart = props => {
|
|
82
|
+
const {
|
|
83
|
+
className,
|
|
84
|
+
data,
|
|
85
|
+
maxValue
|
|
86
|
+
} = props;
|
|
87
|
+
const {
|
|
88
|
+
labels,
|
|
89
|
+
values
|
|
90
|
+
} = data;
|
|
91
|
+
const defaultColors = getColors(labels.length);
|
|
92
|
+
const total = maxValue || getTotalValues(values);
|
|
93
|
+
const entries = values.reduce((agg, entry, index) => {
|
|
94
|
+
const {
|
|
95
|
+
value,
|
|
96
|
+
color = defaultColors[index],
|
|
97
|
+
label = labels[index],
|
|
98
|
+
getItemTooltip
|
|
99
|
+
} = typeof entry === 'object' ? entry : {
|
|
105
100
|
value: entry
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return [].concat(agg, [{
|
|
116
|
-
value: value,
|
|
117
|
-
width: width,
|
|
118
|
-
color: color,
|
|
119
|
-
label: label,
|
|
120
|
-
getItemTooltip: getItemTooltip
|
|
121
|
-
}]);
|
|
101
|
+
};
|
|
102
|
+
const width = `${_round(value / total * 100, 2)}%`;
|
|
103
|
+
return [...agg, {
|
|
104
|
+
value,
|
|
105
|
+
width,
|
|
106
|
+
color,
|
|
107
|
+
label,
|
|
108
|
+
getItemTooltip
|
|
109
|
+
}];
|
|
122
110
|
}, []);
|
|
123
111
|
return /*#__PURE__*/React.createElement("div", {
|
|
124
112
|
className: cx(css.root, className)
|
|
125
|
-
}, entries.map(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
113
|
+
}, entries.map((_ref, index) => {
|
|
114
|
+
let {
|
|
115
|
+
color,
|
|
116
|
+
getItemTooltip,
|
|
117
|
+
label,
|
|
118
|
+
width
|
|
119
|
+
} = _ref;
|
|
120
|
+
const key = index;
|
|
131
121
|
return /*#__PURE__*/React.createElement(HorizontalBarChartItem, {
|
|
132
122
|
key: key,
|
|
133
123
|
width: width,
|
|
@@ -2,83 +2,73 @@ import React from 'react';
|
|
|
2
2
|
import { storiesOf } from '@storybook/react';
|
|
3
3
|
import { getWrapperDecorator } from '../../stories';
|
|
4
4
|
import { HorizontalBarChart } from '.';
|
|
5
|
-
|
|
5
|
+
const stories = storiesOf('UI/HorizontalBarChart', module);
|
|
6
6
|
stories.addDecorator(getWrapperDecorator({
|
|
7
7
|
paddingTop: '128px'
|
|
8
8
|
}));
|
|
9
|
-
stories.add('default',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
color: 'blue',
|
|
76
|
-
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
77
|
-
}, {
|
|
78
|
-
value: 20,
|
|
79
|
-
color: 'pink',
|
|
80
|
-
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
81
|
-
}]
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
9
|
+
stories.add('default', () => /*#__PURE__*/React.createElement(HorizontalBarChart, {
|
|
10
|
+
data: {
|
|
11
|
+
labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
|
|
12
|
+
values: [300, 200, 300, 0, 20]
|
|
13
|
+
}
|
|
14
|
+
}));
|
|
15
|
+
stories.add('empty values', () => /*#__PURE__*/React.createElement(HorizontalBarChart, {
|
|
16
|
+
data: {
|
|
17
|
+
labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
|
|
18
|
+
values: [0, 0, 0, 0, 0]
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
stories.add('with maxValue', () => /*#__PURE__*/React.createElement(HorizontalBarChart, {
|
|
22
|
+
data: {
|
|
23
|
+
labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
|
|
24
|
+
values: [300, 200, 300, 0, 20]
|
|
25
|
+
},
|
|
26
|
+
maxValue: 1200
|
|
27
|
+
}));
|
|
28
|
+
stories.add('with custom colors', () => /*#__PURE__*/React.createElement(HorizontalBarChart, {
|
|
29
|
+
data: {
|
|
30
|
+
labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
|
|
31
|
+
values: [{
|
|
32
|
+
value: 300,
|
|
33
|
+
color: 'red'
|
|
34
|
+
}, {
|
|
35
|
+
value: 200,
|
|
36
|
+
color: 'green'
|
|
37
|
+
}, {
|
|
38
|
+
value: 300,
|
|
39
|
+
color: 'orange'
|
|
40
|
+
}, {
|
|
41
|
+
value: 0,
|
|
42
|
+
color: 'blue'
|
|
43
|
+
}, {
|
|
44
|
+
value: 20,
|
|
45
|
+
color: 'pink'
|
|
46
|
+
}]
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
stories.add('with custom label', () => /*#__PURE__*/React.createElement(HorizontalBarChart, {
|
|
50
|
+
data: {
|
|
51
|
+
labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
|
|
52
|
+
values: [{
|
|
53
|
+
value: 300,
|
|
54
|
+
color: 'red',
|
|
55
|
+
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
56
|
+
}, {
|
|
57
|
+
value: 200,
|
|
58
|
+
color: 'green',
|
|
59
|
+
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
60
|
+
}, {
|
|
61
|
+
value: 300,
|
|
62
|
+
color: 'orange',
|
|
63
|
+
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
64
|
+
}, {
|
|
65
|
+
value: 0,
|
|
66
|
+
color: 'blue',
|
|
67
|
+
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
68
|
+
}, {
|
|
69
|
+
value: 20,
|
|
70
|
+
color: 'pink',
|
|
71
|
+
label: /*#__PURE__*/React.createElement("h3", null, "JS")
|
|
72
|
+
}]
|
|
73
|
+
}
|
|
74
|
+
}));
|