@bundle-stats/ui 4.2.0-beta.4 → 4.2.0-beta.6

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 (59) hide show
  1. package/lib/app/app.js +9 -3
  2. package/lib/app/app.js.map +1 -1
  3. package/lib/assets/icons.svg +9 -1
  4. package/lib/assets/icons.svg.js +6 -0
  5. package/lib/assets/icons.svg.js.map +1 -1
  6. package/lib/components/index.js +3 -3
  7. package/lib/components/index.js.map +1 -1
  8. package/lib/components/{duplicate-packages-insight → insights}/index.js +1 -1
  9. package/lib/components/insights/index.js.map +1 -0
  10. package/lib/components/insights/insights.js +58 -0
  11. package/lib/components/insights/insights.js.map +1 -0
  12. package/lib/components/insights/insights.module.css +34 -0
  13. package/lib/ui/icon/icon.js +2 -0
  14. package/lib/ui/icon/icon.js.map +1 -1
  15. package/lib-esm/app/app.js +10 -4
  16. package/lib-esm/app/app.js.map +1 -1
  17. package/lib-esm/assets/icons.svg +9 -1
  18. package/lib-esm/assets/icons.svg.js +6 -0
  19. package/lib-esm/assets/icons.svg.js.map +1 -1
  20. package/lib-esm/components/index.js +1 -1
  21. package/lib-esm/components/index.js.map +1 -1
  22. package/lib-esm/components/insights/index.js +2 -0
  23. package/lib-esm/components/insights/index.js.map +1 -0
  24. package/lib-esm/components/insights/insights.js +51 -0
  25. package/lib-esm/components/insights/insights.js.map +1 -0
  26. package/lib-esm/components/insights/insights.module.css +34 -0
  27. package/lib-esm/ui/icon/icon.js +2 -0
  28. package/lib-esm/ui/icon/icon.js.map +1 -1
  29. package/package.json +3 -3
  30. package/src/app/app.jsx +18 -8
  31. package/src/assets/icons/error.svg +6 -0
  32. package/src/assets/icons/info.svg +6 -0
  33. package/src/assets/icons.svg +9 -1
  34. package/src/assets/icons.svg.jsx +26 -0
  35. package/src/components/index.js +1 -1
  36. package/src/components/insights/index.ts +1 -0
  37. package/src/components/insights/insights.module.css +34 -0
  38. package/src/components/insights/insights.stories.tsx +53 -0
  39. package/src/components/insights/insights.tsx +101 -0
  40. package/src/ui/icon/icon.jsx +2 -0
  41. package/types/components/index.d.ts +1 -1
  42. package/types/components/insights/index.d.ts +1 -0
  43. package/types/components/insights/insights.d.ts +8 -0
  44. package/types/ui/icon/icon.d.ts +2 -0
  45. package/lib/components/duplicate-packages-insight/duplicate-packages-insight.js +0 -34
  46. package/lib/components/duplicate-packages-insight/duplicate-packages-insight.js.map +0 -1
  47. package/lib/components/duplicate-packages-insight/duplicate-packages-insight.module.css +0 -18
  48. package/lib/components/duplicate-packages-insight/index.js.map +0 -1
  49. package/lib-esm/components/duplicate-packages-insight/duplicate-packages-insight.js +0 -27
  50. package/lib-esm/components/duplicate-packages-insight/duplicate-packages-insight.js.map +0 -1
  51. package/lib-esm/components/duplicate-packages-insight/duplicate-packages-insight.module.css +0 -18
  52. package/lib-esm/components/duplicate-packages-insight/index.js +0 -2
  53. package/lib-esm/components/duplicate-packages-insight/index.js.map +0 -1
  54. package/src/components/duplicate-packages-insight/duplicate-packages-insight.module.css +0 -18
  55. package/src/components/duplicate-packages-insight/duplicate-packages-insight.stories.tsx +0 -66
  56. package/src/components/duplicate-packages-insight/duplicate-packages-insight.tsx +0 -86
  57. package/src/components/duplicate-packages-insight/index.ts +0 -1
  58. package/types/components/duplicate-packages-insight/duplicate-packages-insight.d.ts +0 -11
  59. package/types/components/duplicate-packages-insight/index.d.ts +0 -1
@@ -1,86 +0,0 @@
1
- import React from 'react';
2
- import {
3
- BUNDLE_PACKAGES_DUPLICATE,
4
- BUNDLE_PACKAGES_DUPLICATE_NEW,
5
- BUNDLE_PACKAGES_COUNT,
6
- InsightType,
7
- JobSummaryItem,
8
- getMetricRunInfo,
9
- JobInsightDuplicatePackagesV3Data,
10
- getGlobalMetricType,
11
- } from '@bundle-stats/utils';
12
-
13
- import { Alert } from '../../ui/alert';
14
- import { ComponentLink } from '../component-link';
15
- import { Delta } from '../delta';
16
- // @ts-ignore
17
- import css from './duplicate-packages-insight.module.css';
18
-
19
- interface DuplicatePackagesInsightProps extends React.HTMLAttributes<HTMLDivElement> {
20
- type: InsightType;
21
- data: JobInsightDuplicatePackagesV3Data;
22
- summary: JobSummaryItem;
23
- showDelta?: boolean;
24
- customComponentLink?: React.FunctionComponent<React.HTMLAttributes<HTMLLinkElement>>;
25
- }
26
-
27
- const AlertKindMap = new Map([
28
- [InsightType.INFO, 'info'],
29
- [InsightType.ERROR, 'danger'],
30
- [InsightType.WARNING, 'warning'],
31
- ]);
32
-
33
- export const DuplicatePackagesInsight = (props: DuplicatePackagesInsightProps) => {
34
- const {
35
- type,
36
- data,
37
- summary,
38
- showDelta = true,
39
- customComponentLink: CustomComponentLink = ComponentLink,
40
- ...restProps
41
- } = props;
42
-
43
- const metric = getGlobalMetricType('webpack.duplicatePackageCount');
44
-
45
- const metricRunInfo = getMetricRunInfo(metric, summary.current, summary.baseline);
46
-
47
- const hasDuplicatePackages =
48
- metricRunInfo.value > 0 || (metricRunInfo && metricRunInfo.delta !== 0);
49
-
50
- return (
51
- <Alert kind={AlertKindMap.get(type)} {...restProps}>
52
- <span className={css.message}>{data.text}</span>
53
- {hasDuplicatePackages && (
54
- <span className={css.metric}>
55
- {metricRunInfo.value}
56
- {showDelta && typeof metricRunInfo.delta !== 'undefined' && (
57
- <Delta
58
- className={css.delta}
59
- inverted
60
- displayValue={metricRunInfo.displayDelta as string}
61
- deltaType={metricRunInfo.deltaType as string}
62
- />
63
- )}
64
- </span>
65
- )}
66
- <span className={css.link}>
67
- {hasDuplicatePackages &&
68
- (typeof metricRunInfo?.delta !== 'undefined' && metricRunInfo.delta !== 0 ? (
69
- <CustomComponentLink {...(BUNDLE_PACKAGES_DUPLICATE_NEW as any)}>
70
- View duplicate packages
71
- </CustomComponentLink>
72
- ) : (
73
- <CustomComponentLink {...(BUNDLE_PACKAGES_DUPLICATE as any)}>
74
- View duplicate packages
75
- </CustomComponentLink>
76
- ))}
77
-
78
- {!hasDuplicatePackages && (
79
- <CustomComponentLink {...(BUNDLE_PACKAGES_COUNT as any)}>
80
- View packages
81
- </CustomComponentLink>
82
- )}
83
- </span>
84
- </Alert>
85
- );
86
- };
@@ -1 +0,0 @@
1
- export * from './duplicate-packages-insight';
@@ -1,11 +0,0 @@
1
- import React from 'react';
2
- import { InsightType, JobSummaryItem, JobInsightDuplicatePackagesV3Data } from '@bundle-stats/utils';
3
- interface DuplicatePackagesInsightProps extends React.HTMLAttributes<HTMLDivElement> {
4
- type: InsightType;
5
- data: JobInsightDuplicatePackagesV3Data;
6
- summary: JobSummaryItem;
7
- showDelta?: boolean;
8
- customComponentLink?: React.FunctionComponent<React.HTMLAttributes<HTMLLinkElement>>;
9
- }
10
- export declare const DuplicatePackagesInsight: (props: DuplicatePackagesInsightProps) => JSX.Element;
11
- export {};
@@ -1 +0,0 @@
1
- export * from './duplicate-packages-insight';