@bundle-stats/ui 3.2.0-beta.1 → 3.2.1-beta.3

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.
Files changed (255) hide show
  1. package/.babelrc.js +3 -3
  2. package/CHANGELOG.md +20 -4
  3. package/lib/assets/icons/arrow.svg +1 -0
  4. package/lib/assets/icons/cancel.svg +1 -0
  5. package/lib/assets/icons/clock.svg +1 -0
  6. package/lib/assets/icons/close.svg +1 -0
  7. package/lib/assets/icons/commit.svg +1 -0
  8. package/lib/assets/icons/filter.svg +1 -0
  9. package/lib/assets/icons/help.svg +1 -0
  10. package/lib/assets/icons/menu.svg +1 -0
  11. package/lib/{ui/icon/assets → assets/icons}/sort.svg +0 -0
  12. package/lib/assets/icons/warning.svg +1 -0
  13. package/lib/assets/icons.svg +1 -0
  14. package/lib/components/bundle-assets/bundle-assets.js +3 -3
  15. package/lib/components/bundle-assets/bundle-assets.stories.js +19 -7
  16. package/lib/components/bundle-assets/bundle-assets.utils.js +95 -28
  17. package/lib/components/bundle-assets/index.js +115 -4
  18. package/lib/components/bundle-modules/bundle-modules.js +3 -3
  19. package/lib/components/bundle-modules/bundle-modules.utils.js +152 -0
  20. package/lib/components/bundle-modules/index.js +135 -4
  21. package/lib/components/bundle-packages/bundle-packages.js +3 -3
  22. package/lib/components/bundle-packages/{bundle-packages.container.js → bundle-packages.utils.js} +8 -42
  23. package/lib/components/bundle-packages/index.js +111 -3
  24. package/lib/components/metrics-table/metrics-table.js +3 -7
  25. package/lib/components/metrics-table-search/metrics-table-search.js +2 -1
  26. package/lib/components/metrics-table-search/metrics-table-search.module.css +2 -1
  27. package/lib/hooks/rows-filter.js +28 -0
  28. package/lib/hooks/rows-sort.js +54 -0
  29. package/lib/{hocs/with-search.js → hooks/search-params.js} +15 -64
  30. package/lib/ui/icon/icon.js +4 -191
  31. package/lib/ui/sort-dropdown/sort-dropdown.js +12 -13
  32. package/lib/ui/sort-dropdown/sort-dropdown.stories.js +2 -2
  33. package/lib/utils.js +6 -3
  34. package/lib-esm/app/app.js +60 -70
  35. package/lib-esm/app/app.stories.js +50 -71
  36. package/lib-esm/app/header/header.js +5 -3
  37. package/lib-esm/assets/icons/arrow.svg +1 -0
  38. package/lib-esm/assets/icons/cancel.svg +1 -0
  39. package/lib-esm/assets/icons/clock.svg +1 -0
  40. package/lib-esm/assets/icons/close.svg +1 -0
  41. package/lib-esm/assets/icons/commit.svg +1 -0
  42. package/lib-esm/assets/icons/filter.svg +1 -0
  43. package/lib-esm/assets/icons/help.svg +1 -0
  44. package/lib-esm/assets/icons/menu.svg +1 -0
  45. package/lib-esm/{ui/icon/assets → assets/icons}/sort.svg +0 -0
  46. package/lib-esm/assets/icons/warning.svg +1 -0
  47. package/lib-esm/assets/icons.svg +1 -0
  48. package/lib-esm/components/asset-info/asset-info.js +21 -17
  49. package/lib-esm/components/asset-info/asset-info.stories.js +29 -33
  50. package/lib-esm/components/browsertime-table/browsertime-table.js +6 -4
  51. package/lib-esm/components/browsertime-table/browsertime-table.stories.js +9 -13
  52. package/lib-esm/components/bundle-assets/bundle-assets.constants.js +17 -15
  53. package/lib-esm/components/bundle-assets/bundle-assets.js +107 -97
  54. package/lib-esm/components/bundle-assets/bundle-assets.stories.js +58 -63
  55. package/lib-esm/components/bundle-assets/bundle-assets.utils.js +65 -21
  56. package/lib-esm/components/bundle-assets/index.js +89 -2
  57. package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +49 -51
  58. package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.stories.js +9 -13
  59. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +14 -13
  60. package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +13 -19
  61. package/lib-esm/components/bundle-modules/bundle-modules.constants.js +17 -15
  62. package/lib-esm/components/bundle-modules/bundle-modules.js +112 -110
  63. package/lib-esm/components/bundle-modules/bundle-modules.stories.js +46 -58
  64. package/lib-esm/components/bundle-modules/bundle-modules.utils.js +98 -0
  65. package/lib-esm/components/bundle-modules/index.js +114 -3
  66. package/lib-esm/components/bundle-packages/bundle-packages.constants.js +17 -15
  67. package/lib-esm/components/bundle-packages/bundle-packages.js +71 -69
  68. package/lib-esm/components/bundle-packages/bundle-packages.stories.js +34 -46
  69. package/lib-esm/components/bundle-packages/bundle-packages.utils.js +44 -0
  70. package/lib-esm/components/bundle-packages/index.js +87 -2
  71. package/lib-esm/components/component-link.js +10 -13
  72. package/lib-esm/components/delta/delta.js +8 -6
  73. package/lib-esm/components/delta/delta.stories.js +26 -38
  74. package/lib-esm/components/duplicate-packages-warning/duplicate-packages-warning.js +11 -9
  75. package/lib-esm/components/duplicate-packages-warning/duplicate-packages-warning.stories.js +20 -26
  76. package/lib-esm/components/job-header/job-header.js +14 -11
  77. package/lib-esm/components/job-header/job-header.stories.js +12 -18
  78. package/lib-esm/components/job-meta/job-meta.js +15 -18
  79. package/lib-esm/components/job-meta/job-meta.stories.js +10 -12
  80. package/lib-esm/components/job-name/job-name.js +9 -12
  81. package/lib-esm/components/job-name/job-name.stories.js +15 -23
  82. package/lib-esm/components/jobs-header/jobs-header.js +12 -12
  83. package/lib-esm/components/jobs-header/jobs-header.stories.js +80 -86
  84. package/lib-esm/components/lighthouse-table/lighthouse-table.js +6 -4
  85. package/lib-esm/components/lighthouse-table/lighthouse-table.stories.js +10 -14
  86. package/lib-esm/components/metric/metric.js +15 -19
  87. package/lib-esm/components/metric/metric.stories.js +36 -58
  88. package/lib-esm/components/metrics-table/metrics-table.js +128 -139
  89. package/lib-esm/components/metrics-table/metrics-table.stories.js +27 -35
  90. package/lib-esm/components/metrics-table-options/metrics-table-options.js +16 -19
  91. package/lib-esm/components/metrics-table-options/metrics-table-options.stories.js +6 -12
  92. package/lib-esm/components/metrics-table-search/metrics-table-search.js +17 -18
  93. package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +2 -1
  94. package/lib-esm/components/metrics-table-search/metrics-table-search.stories.js +4 -9
  95. package/lib-esm/components/metrics-table-title/metrics-table-title.js +9 -7
  96. package/lib-esm/components/module-info/module-info.js +15 -13
  97. package/lib-esm/components/module-info/module-info.stories.js +20 -22
  98. package/lib-esm/components/summary/summary.js +25 -27
  99. package/lib-esm/components/summary/summary.stories.js +31 -46
  100. package/lib-esm/components/summary-item/summary-item.js +27 -28
  101. package/lib-esm/components/summary-item/summary-item.stories.js +40 -50
  102. package/lib-esm/components/total-size-type-title/total-size-type-title.js +4 -2
  103. package/lib-esm/constants.js +25 -30
  104. package/lib-esm/hooks/rows-filter.js +20 -0
  105. package/lib-esm/hooks/rows-sort.js +22 -0
  106. package/lib-esm/hooks/search-params.js +170 -0
  107. package/lib-esm/layout/box/box.js +12 -19
  108. package/lib-esm/layout/box/box.stories.js +34 -46
  109. package/lib-esm/layout/flex-stack/flex-stack.js +9 -12
  110. package/lib-esm/layout/flex-stack/flex-stack.stories.js +39 -49
  111. package/lib-esm/layout/footer/footer.js +11 -11
  112. package/lib-esm/layout/footer/footer.stories.js +7 -11
  113. package/lib-esm/layout/header/header.js +10 -14
  114. package/lib-esm/layout/header/header.stories.js +50 -44
  115. package/lib-esm/layout/stack/stack.js +8 -6
  116. package/lib-esm/layout/stack/stack.stories.js +39 -49
  117. package/lib-esm/layout/sub-header/sub-header.js +14 -12
  118. package/lib-esm/layout/sub-header/sub-header.stories.js +57 -69
  119. package/lib-esm/prototypes/typography.stories.js +49 -58
  120. package/lib-esm/query-state.js +13 -16
  121. package/lib-esm/stories/wrapper.js +6 -12
  122. package/lib-esm/ui/alert/alert.js +6 -4
  123. package/lib-esm/ui/alert/alert.stories.js +14 -24
  124. package/lib-esm/ui/container/container.js +6 -9
  125. package/lib-esm/ui/container/container.stories.js +15 -17
  126. package/lib-esm/ui/dropdown/dropdown.js +13 -11
  127. package/lib-esm/ui/dropdown/dropdown.stories.js +22 -26
  128. package/lib-esm/ui/empty-set/empty-set.js +12 -12
  129. package/lib-esm/ui/empty-set/empty-set.stories.js +11 -19
  130. package/lib-esm/ui/file-name/file-name.js +6 -4
  131. package/lib-esm/ui/file-name/file-name.stories.js +12 -16
  132. package/lib-esm/ui/filters/filters.container.js +57 -76
  133. package/lib-esm/ui/filters/filters.js +71 -77
  134. package/lib-esm/ui/filters/filters.stories.js +82 -100
  135. package/lib-esm/ui/filters/filters.utils.js +26 -24
  136. package/lib-esm/ui/filters/index.js +1 -1
  137. package/lib-esm/ui/horizontal-bar-chart/horizontal-bar-chart.js +68 -78
  138. package/lib-esm/ui/horizontal-bar-chart/horizontal-bar-chart.stories.js +67 -77
  139. package/lib-esm/ui/icon/icon.js +13 -202
  140. package/lib-esm/ui/icon/icon.stories.js +16 -24
  141. package/lib-esm/ui/input/input.js +7 -10
  142. package/lib-esm/ui/input/input.stories.js +8 -12
  143. package/lib-esm/ui/loader/loader.js +6 -9
  144. package/lib-esm/ui/loader/loader.stories.js +5 -9
  145. package/lib-esm/ui/logo/logo.constants.js +6 -6
  146. package/lib-esm/ui/logo/logo.js +15 -15
  147. package/lib-esm/ui/logo/logo.stories.js +14 -22
  148. package/lib-esm/ui/panels/panels.js +13 -23
  149. package/lib-esm/ui/panels/panels.stories.js +14 -16
  150. package/lib-esm/ui/popover/popover.js +11 -9
  151. package/lib-esm/ui/popover/popover.stories.js +7 -11
  152. package/lib-esm/ui/skeleton/skeleton.js +6 -9
  153. package/lib-esm/ui/skeleton/skeleton.stories.js +2 -4
  154. package/lib-esm/ui/sort-dropdown/sort-dropdown.js +38 -38
  155. package/lib-esm/ui/sort-dropdown/sort-dropdown.stories.js +14 -16
  156. package/lib-esm/ui/table/table.js +26 -31
  157. package/lib-esm/ui/table/table.stories.js +84 -102
  158. package/lib-esm/ui/tabs/tabs.js +13 -21
  159. package/lib-esm/ui/tabs/tabs.stories.js +4 -6
  160. package/lib-esm/ui/toolbar/toolbar.js +7 -5
  161. package/lib-esm/ui/toolbar/toolbar.stories.js +14 -16
  162. package/lib-esm/ui/tooltip/tooltip.js +13 -16
  163. package/lib-esm/ui/tooltip/tooltip.stories.js +8 -12
  164. package/lib-esm/utils.js +20 -24
  165. package/package.json +25 -33
  166. package/src/assets/icons/arrow.svg +1 -0
  167. package/src/assets/icons/cancel.svg +1 -0
  168. package/src/assets/icons/clock.svg +1 -0
  169. package/src/assets/icons/close.svg +1 -0
  170. package/src/assets/icons/commit.svg +1 -0
  171. package/src/assets/icons/filter.svg +1 -0
  172. package/src/assets/icons/help.svg +1 -0
  173. package/src/assets/icons/menu.svg +1 -0
  174. package/src/{ui/icon/assets → assets/icons}/sort.svg +0 -0
  175. package/src/assets/icons/warning.svg +1 -0
  176. package/src/assets/icons.svg +1 -0
  177. package/src/components/bundle-assets/bundle-assets.jsx +3 -3
  178. package/src/components/bundle-assets/bundle-assets.utils.js +96 -17
  179. package/src/components/bundle-assets/index.jsx +89 -0
  180. package/src/components/bundle-modules/bundle-modules.jsx +3 -3
  181. package/src/components/bundle-modules/bundle-modules.utils.js +101 -0
  182. package/src/components/bundle-modules/index.jsx +107 -0
  183. package/src/components/bundle-packages/bundle-packages.jsx +3 -3
  184. package/src/components/bundle-packages/bundle-packages.utils.js +47 -0
  185. package/src/components/bundle-packages/index.jsx +84 -0
  186. package/src/components/metrics-table/metrics-table.jsx +2 -7
  187. package/src/components/metrics-table-search/metrics-table-search.jsx +1 -0
  188. package/src/components/metrics-table-search/metrics-table-search.module.css +2 -1
  189. package/src/hooks/rows-filter.js +16 -0
  190. package/src/hooks/rows-sort.js +24 -0
  191. package/src/hooks/search-params.js +153 -0
  192. package/src/ui/icon/icon.jsx +7 -42
  193. package/src/ui/sort-dropdown/sort-dropdown.jsx +11 -11
  194. package/src/utils.jsx +5 -3
  195. package/lib/components/bundle-assets/bundle-assets.container.js +0 -140
  196. package/lib/components/bundle-modules/bundle-modules.container.js +0 -222
  197. package/lib/hocs/with-custom-sort.js +0 -75
  198. package/lib/hocs/with-filtered-items.js +0 -54
  199. package/lib/ui/icon/assets/arrow.svg +0 -4
  200. package/lib/ui/icon/assets/branch.svg +0 -3
  201. package/lib/ui/icon/assets/cancel.svg +0 -4
  202. package/lib/ui/icon/assets/clock.svg +0 -3
  203. package/lib/ui/icon/assets/close.svg +0 -4
  204. package/lib/ui/icon/assets/commit.svg +0 -3
  205. package/lib/ui/icon/assets/filter.svg +0 -4
  206. package/lib/ui/icon/assets/help.svg +0 -4
  207. package/lib/ui/icon/assets/job.svg +0 -3
  208. package/lib/ui/icon/assets/menu.svg +0 -4
  209. package/lib/ui/icon/assets/package.svg +0 -3
  210. package/lib/ui/icon/assets/pull-request.svg +0 -3
  211. package/lib/ui/icon/assets/repository.svg +0 -3
  212. package/lib/ui/icon/assets/warning.svg +0 -4
  213. package/lib-esm/components/bundle-assets/bundle-assets.container.js +0 -119
  214. package/lib-esm/components/bundle-modules/bundle-modules.container.js +0 -175
  215. package/lib-esm/components/bundle-packages/bundle-packages.container.js +0 -91
  216. package/lib-esm/hocs/with-custom-sort.js +0 -43
  217. package/lib-esm/hocs/with-filtered-items.js +0 -35
  218. package/lib-esm/hocs/with-search.js +0 -214
  219. package/lib-esm/ui/icon/assets/arrow.svg +0 -4
  220. package/lib-esm/ui/icon/assets/branch.svg +0 -3
  221. package/lib-esm/ui/icon/assets/cancel.svg +0 -4
  222. package/lib-esm/ui/icon/assets/clock.svg +0 -3
  223. package/lib-esm/ui/icon/assets/close.svg +0 -4
  224. package/lib-esm/ui/icon/assets/commit.svg +0 -3
  225. package/lib-esm/ui/icon/assets/filter.svg +0 -4
  226. package/lib-esm/ui/icon/assets/help.svg +0 -4
  227. package/lib-esm/ui/icon/assets/job.svg +0 -3
  228. package/lib-esm/ui/icon/assets/menu.svg +0 -4
  229. package/lib-esm/ui/icon/assets/package.svg +0 -3
  230. package/lib-esm/ui/icon/assets/pull-request.svg +0 -3
  231. package/lib-esm/ui/icon/assets/repository.svg +0 -3
  232. package/lib-esm/ui/icon/assets/warning.svg +0 -4
  233. package/src/components/bundle-assets/bundle-assets.container.js +0 -146
  234. package/src/components/bundle-assets/index.js +0 -4
  235. package/src/components/bundle-modules/bundle-modules.container.js +0 -158
  236. package/src/components/bundle-modules/index.js +0 -4
  237. package/src/components/bundle-packages/bundle-packages.container.js +0 -93
  238. package/src/components/bundle-packages/index.js +0 -4
  239. package/src/hocs/with-custom-sort.jsx +0 -35
  240. package/src/hocs/with-filtered-items.jsx +0 -34
  241. package/src/hocs/with-search.jsx +0 -184
  242. package/src/ui/icon/assets/arrow.svg +0 -4
  243. package/src/ui/icon/assets/branch.svg +0 -3
  244. package/src/ui/icon/assets/cancel.svg +0 -4
  245. package/src/ui/icon/assets/clock.svg +0 -3
  246. package/src/ui/icon/assets/close.svg +0 -4
  247. package/src/ui/icon/assets/commit.svg +0 -3
  248. package/src/ui/icon/assets/filter.svg +0 -4
  249. package/src/ui/icon/assets/help.svg +0 -4
  250. package/src/ui/icon/assets/job.svg +0 -3
  251. package/src/ui/icon/assets/menu.svg +0 -4
  252. package/src/ui/icon/assets/package.svg +0 -3
  253. package/src/ui/icon/assets/pull-request.svg +0 -3
  254. package/src/ui/icon/assets/repository.svg +0 -3
  255. 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
- var stories = storiesOf('UI/Filters', module);
6
+ const stories = storiesOf('UI/Filters', module);
14
7
  stories.addDecorator(getWrapperDecorator({
15
8
  paddingLeft: '200px'
16
9
  }));
17
10
 
18
- var FiltersState = function FiltersState(_ref) {
19
- var children = _ref.children;
20
-
21
- var _useState = useState({
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
- values = _useState[0],
26
- setValues = _useState[1];
27
-
28
- var handleSetValues = useCallback(function (newValues) {
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', function () {
36
- return /*#__PURE__*/React.createElement(FiltersState, null, function (values, setValues) {
37
- return /*#__PURE__*/React.createElement(Filters, {
38
- onChange: setValues,
39
- filters: {
40
- changed: {
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
- filters: {
96
- changed: {
97
- label: 'Changed',
98
- defaultValue: false,
99
- disabled: true
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
- entrypoint: {
102
- label: 'Entrypoint',
103
- defaultValue: false
45
+ HTML: {
46
+ label: 'HTML',
47
+ defaultValue: _get(values, 'fileTypes.HTML', true)
104
48
  },
105
- fileTypes: {
106
- label: 'File types',
107
- CSS: {
108
- label: 'CSS',
109
- defaultValue: true
110
- },
111
- JS: {
112
- label: 'JS',
113
- defaultValue: true
114
- },
115
- HTML: {
116
- label: 'HTML',
117
- defaultValue: true
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
- var FILTER_SUFFIX_MAX_LENGTH = 18;
2
- var ELLIPSES = '...';
3
- var JOIN = ', ';
4
- export var LABELS = {
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 var getGroupFiltersLabelSuffix = function getGroupFiltersLabelSuffix(filters) {
14
- var filterCount = filters.length; // eslint-disable-next-line no-unused-vars
13
+ export const getGroupFiltersLabelSuffix = filters => {
14
+ const filterCount = filters.length; // eslint-disable-next-line no-unused-vars
15
15
 
16
- var checkedFilters = filters.filter(function (_ref) {
17
- var _ = _ref[0],
18
- defaultValue = _ref[1].defaultValue;
16
+ const checkedFilters = filters.filter(_ref => {
17
+ let [_, {
18
+ defaultValue
19
+ }] = _ref;
19
20
  return defaultValue;
20
21
  });
21
- var filterCheckedCount = checkedFilters.length;
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
- var checkedFilterLabels = checkedFilters.map(function (_ref2) {
33
- var _ = _ref2[0],
34
- label = _ref2[1].label;
33
+ const checkedFilterLabels = checkedFilters.map(_ref2 => {
34
+ let [_, {
35
+ label
36
+ }] = _ref2;
35
37
  return label;
36
38
  });
37
- var suffix = '';
38
- var inlinedLabelCount = 0;
39
- var done = false;
39
+ let suffix = '';
40
+ let inlinedLabelCount = 0;
41
+ let done = false;
40
42
 
41
- for (var i = 0; !done && i < checkedFilterLabels.length && FILTER_SUFFIX_MAX_LENGTH - suffix.length >= 0; i++ // eslint-disable-line no-plusplus
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
- var availableSpace = FILTER_SUFFIX_MAX_LENGTH - suffix.length;
44
- var label = checkedFilterLabels[i];
45
- var normalizedLabel = '';
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 = "" + label.substr(0, availableSpace - 3) + ELLIPSES;
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 = "" + suffix + (suffix ? JOIN : '') + normalizedLabel;
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
- var skippedLabels = filterCheckedCount - inlinedLabelCount;
65
- return "" + suffix + (skippedLabels > 0 ? " +" + skippedLabels : '');
66
+ const skippedLabels = filterCheckedCount - inlinedLabelCount;
67
+ return `${suffix}${skippedLabels > 0 ? ` +${skippedLabels}` : ''}`;
66
68
  };
@@ -1,3 +1,3 @@
1
1
  import { filtersDropdownContainer } from './filters.container';
2
2
  import { Filters as FiltersComponent } from './filters';
3
- export var Filters = filtersDropdownContainer(FiltersComponent);
3
+ export const Filters = filtersDropdownContainer(FiltersComponent);
@@ -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
- var HorizontalBarChartItem = /*#__PURE__*/function (_React$Component) {
17
- _inheritsLoose(HorizontalBarChartItem, _React$Component);
18
-
19
- function HorizontalBarChartItem(props) {
20
- var _this;
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
- var _proto = HorizontalBarChartItem.prototype;
21
+ componentDidMount() {
22
+ const wrapperWidth = _get(this, 'ref.current.clientWidth', 0);
32
23
 
33
- _proto.componentDidMount = function componentDidMount() {
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
- _proto.render = function render() {
46
- var _this$props = this.props,
47
- color = _this$props.color,
48
- label = _this$props.label,
49
- getItemTooltip = _this$props.getItemTooltip,
50
- width = _this$props.width;
51
- var isTextOverflowing = this.state.isTextOverflowing;
52
- var tooltipContent = getItemTooltip();
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: 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
- return HorizontalBarChartItem;
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: function getItemTooltip() {
81
- return null;
82
- }
70
+ getItemTooltip: () => null
83
71
  };
84
72
 
85
- var getTotalValues = function getTotalValues(values) {
86
- return _sum(values.map(function (entry) {
87
- if (typeof entry === 'object') {
88
- return entry.value;
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
- export var HorizontalBarChart = function HorizontalBarChart(props) {
96
- var className = props.className,
97
- data = props.data,
98
- maxValue = props.maxValue;
99
- var labels = data.labels,
100
- values = data.values;
101
- var defaultColors = getColors(labels.length);
102
- var total = maxValue || getTotalValues(values);
103
- var entries = values.reduce(function (agg, entry, index) {
104
- var _ref = typeof entry === 'object' ? entry : {
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
- value = _ref.value,
108
- _ref$color = _ref.color,
109
- color = _ref$color === void 0 ? defaultColors[index] : _ref$color,
110
- _ref$label = _ref.label,
111
- label = _ref$label === void 0 ? labels[index] : _ref$label,
112
- getItemTooltip = _ref.getItemTooltip;
113
-
114
- var width = _round(value / total * 100, 2) + "%";
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(function (_ref2, index) {
126
- var color = _ref2.color,
127
- getItemTooltip = _ref2.getItemTooltip,
128
- label = _ref2.label,
129
- width = _ref2.width;
130
- var key = index;
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
- var stories = storiesOf('UI/HorizontalBarChart', module);
5
+ const stories = storiesOf('UI/HorizontalBarChart', module);
6
6
  stories.addDecorator(getWrapperDecorator({
7
7
  paddingTop: '128px'
8
8
  }));
9
- stories.add('default', function () {
10
- return /*#__PURE__*/React.createElement(HorizontalBarChart, {
11
- data: {
12
- labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
13
- values: [300, 200, 300, 0, 20]
14
- }
15
- });
16
- });
17
- stories.add('empty values', function () {
18
- return /*#__PURE__*/React.createElement(HorizontalBarChart, {
19
- data: {
20
- labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
21
- values: [0, 0, 0, 0, 0]
22
- }
23
- });
24
- });
25
- stories.add('with maxValue', function () {
26
- return /*#__PURE__*/React.createElement(HorizontalBarChart, {
27
- data: {
28
- labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
29
- values: [300, 200, 300, 0, 20]
30
- },
31
- maxValue: 1200
32
- });
33
- });
34
- stories.add('with custom colors', function () {
35
- return /*#__PURE__*/React.createElement(HorizontalBarChart, {
36
- data: {
37
- labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
38
- values: [{
39
- value: 300,
40
- color: 'red'
41
- }, {
42
- value: 200,
43
- color: 'green'
44
- }, {
45
- value: 300,
46
- color: 'orange'
47
- }, {
48
- value: 0,
49
- color: 'blue'
50
- }, {
51
- value: 20,
52
- color: 'pink'
53
- }]
54
- }
55
- });
56
- });
57
- stories.add('with custom label', function () {
58
- return /*#__PURE__*/React.createElement(HorizontalBarChart, {
59
- data: {
60
- labels: ['JS', 'CSS', 'IMG', 'Others', 'HTML'],
61
- values: [{
62
- value: 300,
63
- color: 'red',
64
- label: /*#__PURE__*/React.createElement("h3", null, "JS")
65
- }, {
66
- value: 200,
67
- color: 'green',
68
- label: /*#__PURE__*/React.createElement("h3", null, "JS")
69
- }, {
70
- value: 300,
71
- color: 'orange',
72
- label: /*#__PURE__*/React.createElement("h3", null, "JS")
73
- }, {
74
- value: 0,
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
+ }));