@bundle-stats/ui 4.17.0 → 4.18.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/asset-info/asset-info.js +8 -9
- package/lib/components/asset-info/asset-info.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.js +7 -110
- package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.utils.js +101 -23
- package/lib/components/bundle-assets/bundle-assets.utils.js.map +1 -1
- package/lib/components/bundle-assets/index.js +8 -26
- package/lib/components/bundle-assets/index.js.map +1 -1
- package/lib/components/metrics-table/metrics-table.js.map +1 -1
- package/lib/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib/hooks/rows-sort.js +14 -2
- package/lib/hooks/rows-sort.js.map +1 -1
- package/lib/hooks/search-params.js.map +1 -1
- package/lib-esm/components/asset-info/asset-info.js +9 -10
- package/lib-esm/components/asset-info/asset-info.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.js +8 -111
- package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js +98 -22
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js.map +1 -1
- package/lib-esm/components/bundle-assets/index.js +9 -24
- package/lib-esm/components/bundle-assets/index.js.map +1 -1
- package/lib-esm/components/metrics-table/metrics-table.js.map +1 -1
- package/lib-esm/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib-esm/hooks/rows-sort.js +14 -2
- package/lib-esm/hooks/rows-sort.js.map +1 -1
- package/lib-esm/hooks/search-params.js.map +1 -1
- package/package.json +3 -3
- package/src/components/asset-info/asset-info.tsx +31 -28
- package/src/components/bundle-assets/__tests__/add-metric-report-asset-row-data.ts +2 -2
- package/src/components/bundle-assets/bundle-assets.stories.tsx +99 -0
- package/src/components/bundle-assets/{bundle-assets.jsx → bundle-assets.tsx} +65 -147
- package/src/components/bundle-assets/bundle-assets.utils.ts +260 -0
- package/src/components/bundle-assets/{index.jsx → index.tsx} +43 -29
- package/src/components/metrics-table/metrics-table.tsx +3 -3
- package/src/components/metrics-table-header/metrics-table-header.tsx +4 -4
- package/src/components/sort-button/sort-button.tsx +1 -1
- package/src/hooks/rows-sort.ts +21 -3
- package/src/hooks/search-params.js +0 -1
- package/src/types.d.ts +5 -1
- package/types/components/asset-info/asset-info.d.ts +4 -13
- package/types/components/bundle-assets/bundle-assets.d.ts +24 -55
- package/types/components/bundle-assets/bundle-assets.utils.d.ts +17 -5
- package/types/components/bundle-assets/index.d.ts +10 -22
- package/types/components/metrics-table/metrics-table.d.ts +3 -2
- package/types/components/metrics-table-header/metrics-table-header.d.ts +1 -2
- package/types/components/sort-button/sort-button.d.ts +1 -2
- package/types/hooks/rows-sort.d.ts +1 -1
- package/src/components/bundle-assets/bundle-assets.utils.js +0 -149
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ReportMetricRow } from '@bundle-stats/utils';
|
|
3
3
|
import { Table } from '../../ui/table';
|
|
4
|
+
import { MetricsTableHeaderProps } from '../metrics-table-header';
|
|
4
5
|
interface MetricsTableProps extends Omit<React.ComponentProps<typeof Table>, 'title'> {
|
|
5
6
|
runs: Array<{
|
|
6
7
|
label: string;
|
|
@@ -9,8 +10,8 @@ interface MetricsTableProps extends Omit<React.ComponentProps<typeof Table>, 'ti
|
|
|
9
10
|
items: Array<ReportMetricRow>;
|
|
10
11
|
title?: React.ReactNode;
|
|
11
12
|
showHeaderSum?: boolean;
|
|
12
|
-
sort?:
|
|
13
|
-
updateSort?:
|
|
13
|
+
sort?: MetricsTableHeaderProps['sort'];
|
|
14
|
+
updateSort?: MetricsTableHeaderProps['updateSort'];
|
|
14
15
|
renderRowHeader?: (item: ReportMetricRow) => React.ReactNode;
|
|
15
16
|
emptyMessage?: React.ReactNode;
|
|
16
17
|
showAllItems: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ReportMetricRow } from '@bundle-stats/utils';
|
|
3
|
-
interface MetricsTableHeaderProps {
|
|
3
|
+
export interface MetricsTableHeaderProps {
|
|
4
4
|
metricTitle?: React.ReactNode;
|
|
5
5
|
showSum?: boolean;
|
|
6
6
|
jobs: Array<{
|
|
@@ -12,4 +12,3 @@ interface MetricsTableHeaderProps {
|
|
|
12
12
|
updateSort?: (val: any) => void;
|
|
13
13
|
}
|
|
14
14
|
export declare const MetricsTableHeader: (props: MetricsTableHeaderProps & React.ComponentProps<"thead">) => React.JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SortAction } from '../../types';
|
|
3
|
-
interface SortButtonProps {
|
|
3
|
+
export interface SortButtonProps {
|
|
4
4
|
fieldPath: string;
|
|
5
5
|
fieldName: string;
|
|
6
6
|
label: string;
|
|
@@ -8,4 +8,3 @@ interface SortButtonProps {
|
|
|
8
8
|
updateSort?: (params: SortAction) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare const SortButton: (props: SortButtonProps & React.ComponentProps<"div">) => React.JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -3,7 +3,7 @@ export declare const getSortFn: <TRow>(fieldPath: string, getCustomSort: UseRows
|
|
|
3
3
|
interface UseRowsSortParams<TRow> {
|
|
4
4
|
rows: Array<TRow>;
|
|
5
5
|
initialField?: string;
|
|
6
|
-
initialDirection?:
|
|
6
|
+
initialDirection?: string;
|
|
7
7
|
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
8
8
|
setQueryState: (queryParams: {
|
|
9
9
|
sortBy: SortAction['field'];
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @type {import('@bundle-stats/utils').ReportMetricRow} ReportMetricRow
|
|
3
|
-
* @type {import('../../types').ReportMetricAssetRow} ReportMetricAssetRow
|
|
4
|
-
* @type {import('../../types').ReportMetricAssetRowMetaStatus} ReportMetricAssetRowFlagStatus
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { ASSET_ENTRY_TYPE, ASSET_FILE_TYPE, ASSET_FILTERS, getFileType } from '@bundle-stats/utils';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Check if the asset cache is not predictive
|
|
11
|
-
*
|
|
12
|
-
* @param {ReportMetricRow} row
|
|
13
|
-
* @returns {boolean}
|
|
14
|
-
*/
|
|
15
|
-
export const getIsNotPredictive = (row) => {
|
|
16
|
-
const { key, runs } = row;
|
|
17
|
-
|
|
18
|
-
return runs.reduce((agg, current, index) => {
|
|
19
|
-
if (agg) {
|
|
20
|
-
return agg;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (index + 1 === runs.length) {
|
|
24
|
-
return agg;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
current &&
|
|
29
|
-
runs[index + 1] &&
|
|
30
|
-
key !== current.name &&
|
|
31
|
-
current.name === runs[index + 1].name &&
|
|
32
|
-
current.value !== runs[index + 1].value
|
|
33
|
-
) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return agg;
|
|
38
|
-
}, false);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {Array<boolean>}
|
|
43
|
-
* @returns {ReportMetricAssetRowFlagStatus | boolean}
|
|
44
|
-
*/
|
|
45
|
-
export const getAssetMetaStatus = (values) => {
|
|
46
|
-
if (!values.includes(true)) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// filter empty runs
|
|
51
|
-
const metaValues = values.filter((value) => typeof value !== 'undefined');
|
|
52
|
-
|
|
53
|
-
const current = metaValues[0];
|
|
54
|
-
const metaValuesLength = metaValues.length;
|
|
55
|
-
|
|
56
|
-
if (metaValuesLength === 1) {
|
|
57
|
-
return Boolean(current);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const baseline = metaValues[metaValuesLength - 1];
|
|
61
|
-
|
|
62
|
-
if (current && !baseline) {
|
|
63
|
-
return 'added';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!current && baseline) {
|
|
67
|
-
return 'removed';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return true;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Add asset row flags
|
|
75
|
-
*
|
|
76
|
-
* @param {ReportMetricRow} row
|
|
77
|
-
* @returns {ReportMetricAssetRow}
|
|
78
|
-
*/
|
|
79
|
-
export const addMetricReportAssetRowData = (row) => {
|
|
80
|
-
const { changed, runs } = row;
|
|
81
|
-
|
|
82
|
-
// Collect meta for each run
|
|
83
|
-
const runsEntry = [];
|
|
84
|
-
const runsInitial = [];
|
|
85
|
-
const runsChunk = [];
|
|
86
|
-
|
|
87
|
-
runs.forEach((run) => {
|
|
88
|
-
runsEntry.push(run?.isEntry);
|
|
89
|
-
runsInitial.push(run?.isInitial);
|
|
90
|
-
runsChunk.push(run?.isChunk);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const isEntry = getAssetMetaStatus(runsEntry);
|
|
94
|
-
const isInitial = getAssetMetaStatus(runsInitial);
|
|
95
|
-
const isChunk = getAssetMetaStatus(runsChunk);
|
|
96
|
-
const isAsset = !(isEntry || isInitial || isChunk);
|
|
97
|
-
const isNotPredictive = getIsNotPredictive(row);
|
|
98
|
-
const fileType = getFileType(row.key);
|
|
99
|
-
|
|
100
|
-
// Flag asset as changed if name and value are identical, if one of the meta tags is changed
|
|
101
|
-
const assetChanged =
|
|
102
|
-
changed ||
|
|
103
|
-
typeof isEntry !== 'boolean' ||
|
|
104
|
-
typeof isInitial !== 'boolean' ||
|
|
105
|
-
typeof isChunk !== 'boolean';
|
|
106
|
-
|
|
107
|
-
return {
|
|
108
|
-
...row,
|
|
109
|
-
changed: assetChanged,
|
|
110
|
-
isEntry,
|
|
111
|
-
isInitial,
|
|
112
|
-
isChunk,
|
|
113
|
-
isAsset,
|
|
114
|
-
isNotPredictive,
|
|
115
|
-
fileType,
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const getRowFilter = (filters) => (item) => {
|
|
120
|
-
if (filters[ASSET_FILTERS.CHANGED] && !item.changed) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
!(
|
|
126
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.ENTRY}`] && item.isEntry) ||
|
|
127
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.INITIAL}`] && item.isInitial) ||
|
|
128
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.CHUNK}`] && item.isChunk) ||
|
|
129
|
-
(filters[`${ASSET_ENTRY_TYPE}.${ASSET_FILTERS.OTHER}`] && item.isAsset)
|
|
130
|
-
)
|
|
131
|
-
) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (!filters[`${ASSET_FILE_TYPE}.${item.fileType}`]) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return true;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const getCustomSort = (item) => [
|
|
143
|
-
!item.isNotPredictive,
|
|
144
|
-
!item.changed,
|
|
145
|
-
!item.isInitial,
|
|
146
|
-
!item.isEntry,
|
|
147
|
-
!item.isChunk,
|
|
148
|
-
item.key,
|
|
149
|
-
];
|