@bundle-stats/ui 4.8.3 → 4.8.4
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/bundle-assets/bundle-assets.js +28 -27
- package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib/components/bundle-modules/bundle-modules.i18n.js +12 -0
- package/lib/components/bundle-modules/bundle-modules.i18n.js.map +1 -0
- package/lib/components/bundle-modules/bundle-modules.js +12 -99
- package/lib/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib/components/bundle-modules/bundle-modules.utils.js +108 -1
- package/lib/components/bundle-modules/bundle-modules.utils.js.map +1 -1
- package/lib/components/bundle-modules/index.js +6 -45
- package/lib/components/bundle-modules/index.js.map +1 -1
- package/lib/components/entry-info/entry-info.i18n.js +7 -0
- package/lib/components/entry-info/entry-info.i18n.js.map +1 -0
- package/lib/components/entry-info/entry-info.js +27 -3
- package/lib/components/entry-info/entry-info.js.map +1 -1
- package/lib/components/job-name/job-name.js +1 -1
- package/lib/components/job-name/job-name.js.map +1 -1
- package/lib/components/metric-run-info/metric-run-info.js +10 -5
- package/lib/components/metric-run-info/metric-run-info.js.map +1 -1
- package/lib/components/metrics-table/index.js +1 -1
- package/lib/components/metrics-table/index.js.map +1 -1
- package/lib/components/metrics-table/metrics-table.i18n.js +12 -0
- package/lib/components/metrics-table/metrics-table.i18n.js.map +1 -0
- package/lib/components/metrics-table/metrics-table.js +50 -69
- package/lib/components/metrics-table/metrics-table.js.map +1 -1
- package/lib/components/metrics-table/metrics-table.module.css +2 -2
- package/lib/components/sort-button/sort-button.js +10 -4
- package/lib/components/sort-button/sort-button.js.map +1 -1
- package/lib/components/sort-button/sort-button.module.css +9 -9
- package/lib/hooks/rows-sort.js +1 -1
- package/lib/hooks/rows-sort.js.map +1 -1
- package/lib/ui/filters/filters.i18n.js +6 -0
- package/lib/ui/filters/filters.i18n.js.map +1 -0
- package/lib/ui/filters/filters.js +16 -54
- package/lib/ui/filters/filters.js.map +1 -1
- package/lib/ui/filters/filters.utils.js +27 -11
- package/lib/ui/filters/filters.utils.js.map +1 -1
- package/lib/ui/filters/index.js +0 -8
- package/lib/ui/filters/index.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.js +28 -27
- package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib-esm/components/bundle-modules/bundle-modules.i18n.js +9 -0
- package/lib-esm/components/bundle-modules/bundle-modules.i18n.js.map +1 -0
- package/lib-esm/components/bundle-modules/bundle-modules.js +13 -101
- package/lib-esm/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js +83 -1
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js.map +1 -1
- package/lib-esm/components/bundle-modules/index.js +9 -45
- package/lib-esm/components/bundle-modules/index.js.map +1 -1
- package/lib-esm/components/entry-info/entry-info.i18n.js +4 -0
- package/lib-esm/components/entry-info/entry-info.i18n.js.map +1 -0
- package/lib-esm/components/entry-info/entry-info.js +4 -3
- package/lib-esm/components/entry-info/entry-info.js.map +1 -1
- package/lib-esm/components/job-name/job-name.js +1 -1
- package/lib-esm/components/job-name/job-name.js.map +1 -1
- package/lib-esm/components/metric-run-info/metric-run-info.js +10 -5
- package/lib-esm/components/metric-run-info/metric-run-info.js.map +1 -1
- package/lib-esm/components/metrics-table/index.js +1 -1
- package/lib-esm/components/metrics-table/index.js.map +1 -1
- package/lib-esm/components/metrics-table/metrics-table.i18n.js +9 -0
- package/lib-esm/components/metrics-table/metrics-table.i18n.js.map +1 -0
- package/lib-esm/components/metrics-table/metrics-table.js +37 -79
- package/lib-esm/components/metrics-table/metrics-table.js.map +1 -1
- package/lib-esm/components/metrics-table/metrics-table.module.css +2 -2
- package/lib-esm/components/sort-button/sort-button.js +10 -4
- package/lib-esm/components/sort-button/sort-button.js.map +1 -1
- package/lib-esm/components/sort-button/sort-button.module.css +9 -9
- package/lib-esm/hooks/rows-sort.js +1 -1
- package/lib-esm/hooks/rows-sort.js.map +1 -1
- package/lib-esm/ui/filters/filters.i18n.js +3 -0
- package/lib-esm/ui/filters/filters.i18n.js.map +1 -0
- package/lib-esm/ui/filters/filters.js +16 -54
- package/lib-esm/ui/filters/filters.js.map +1 -1
- package/lib-esm/ui/filters/filters.utils.js +27 -11
- package/lib-esm/ui/filters/filters.utils.js.map +1 -1
- package/lib-esm/ui/filters/index.js +0 -8
- package/lib-esm/ui/filters/index.js.map +1 -1
- package/package.json +10 -10
- package/src/components/bundle-assets/bundle-assets.jsx +28 -30
- package/src/components/bundle-modules/bundle-modules.i18n.ts +8 -0
- package/src/components/bundle-modules/bundle-modules.tsx +200 -0
- package/src/components/bundle-modules/bundle-modules.types.d.ts +24 -0
- package/src/components/bundle-modules/bundle-modules.utils.ts +208 -0
- package/src/components/bundle-modules/index.tsx +102 -0
- package/src/components/entry-info/entry-info.i18n.ts +3 -0
- package/src/components/entry-info/entry-info.tsx +10 -4
- package/src/components/job-name/job-name.jsx +7 -1
- package/src/components/metric-run-info/metric-run-info.tsx +12 -5
- package/src/components/metrics-table/index.tsx +14 -0
- package/src/components/metrics-table/metrics-table.i18n.ts +10 -0
- package/src/components/metrics-table/metrics-table.module.css +2 -2
- package/src/components/metrics-table/metrics-table.stories.tsx +225 -0
- package/src/components/metrics-table/metrics-table.tsx +301 -0
- package/src/components/sort-button/sort-button.module.css +9 -9
- package/src/components/sort-button/sort-button.tsx +14 -6
- package/src/hooks/rows-sort.ts +9 -9
- package/src/types.d.ts +11 -0
- package/src/ui/filters/__tests__/filters.utils.ts +98 -0
- package/src/ui/filters/filters.i18n.ts +2 -0
- package/src/ui/filters/{filters.jsx → filters.tsx} +63 -72
- package/src/ui/filters/{filters.utils.js → filters.utils.ts} +38 -21
- package/src/ui/filters/{index.jsx → index.tsx} +14 -17
- package/types/components/bundle-modules/bundle-modules.d.ts +21 -62
- package/types/components/bundle-modules/bundle-modules.i18n.d.ts +8 -0
- package/types/components/bundle-modules/bundle-modules.utils.d.ts +28 -5
- package/types/components/bundle-modules/index.d.ts +13 -22
- package/types/components/entry-info/entry-info.i18n.d.ts +3 -0
- package/types/components/job-name/job-name.d.ts +1 -1
- package/types/components/metrics-table/index.d.ts +4 -1
- package/types/components/metrics-table/metrics-table.d.ts +25 -47
- package/types/components/metrics-table/metrics-table.i18n.d.ts +8 -0
- package/types/components/sort-button/sort-button.d.ts +2 -2
- package/types/hooks/rows-sort.d.ts +4 -4
- package/types/layout/box/box.d.ts +1 -1
- package/types/layout/flex-stack/flex-stack.d.ts +1 -1
- package/types/ui/filters/filters.d.ts +24 -14
- package/types/ui/filters/filters.i18n.d.ts +2 -0
- package/types/ui/filters/filters.utils.d.ts +7 -6
- package/types/ui/filters/index.d.ts +8 -12
- package/types/ui/table/table.d.ts +5 -5
- package/types/ui/tooltip/tooltip.d.ts +1 -1
- package/src/components/bundle-modules/bundle-modules.jsx +0 -291
- package/src/components/bundle-modules/bundle-modules.utils.js +0 -82
- package/src/components/bundle-modules/index.jsx +0 -113
- package/src/components/metrics-table/index.jsx +0 -11
- package/src/components/metrics-table/metrics-table.jsx +0 -309
- package/src/ui/filters/__tests__/filters-dropdown.utils.js +0 -74
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export function MetricsTable(props: any): React.JSX.Element;
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import { MetricsTable as BaseComponent } from './metrics-table';
|
|
3
|
+
type MetricsTableProps = Omit<React.ComponentProps<typeof BaseComponent>, 'showAllItems' | 'setShowAllItems'>;
|
|
4
|
+
export declare const MetricsTable: (props: MetricsTableProps) => React.JSX.Element;
|
|
5
|
+
export {};
|
|
@@ -1,48 +1,26 @@
|
|
|
1
|
-
export function MetricsTable({ className, renderRowHeader, runs, items, emptyMessage, showHeaderSum, title, showAllItems, setShowAllItems, sort, updateSort, ...restProps }: {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
className: any;
|
|
4
|
-
renderRowHeader: any;
|
|
5
|
-
runs: any;
|
|
6
|
-
items: any;
|
|
7
|
-
emptyMessage: any;
|
|
8
|
-
showHeaderSum: any;
|
|
9
|
-
title: any;
|
|
10
|
-
showAllItems: any;
|
|
11
|
-
setShowAllItems: any;
|
|
12
|
-
sort: any;
|
|
13
|
-
updateSort: any;
|
|
14
|
-
}): React.JSX.Element;
|
|
15
|
-
export namespace MetricsTable {
|
|
16
|
-
namespace defaultProps {
|
|
17
|
-
let className: string;
|
|
18
|
-
function renderRowHeader(item: any): any;
|
|
19
|
-
let emptyMessage: string;
|
|
20
|
-
let showHeaderSum: boolean;
|
|
21
|
-
let title: string;
|
|
22
|
-
}
|
|
23
|
-
namespace propTypes {
|
|
24
|
-
let className_1: PropTypes.Requireable<string>;
|
|
25
|
-
export { className_1 as className };
|
|
26
|
-
let renderRowHeader_1: PropTypes.Requireable<(...args: any[]) => any>;
|
|
27
|
-
export { renderRowHeader_1 as renderRowHeader };
|
|
28
|
-
export let runs: PropTypes.Validator<(PropTypes.InferProps<{
|
|
29
|
-
internalBuildNumber: PropTypes.Requireable<number>;
|
|
30
|
-
}> | null | undefined)[]>;
|
|
31
|
-
export let items: PropTypes.Validator<(PropTypes.InferProps<{
|
|
32
|
-
key: PropTypes.Requireable<string>;
|
|
33
|
-
label: PropTypes.Requireable<string>;
|
|
34
|
-
runs: PropTypes.Requireable<(PropTypes.InferProps<{
|
|
35
|
-
displayValue: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
36
|
-
displayDelta: PropTypes.Requireable<NonNullable<string | number | null | undefined>>;
|
|
37
|
-
}> | null | undefined)[]>;
|
|
38
|
-
}> | null | undefined)[]>;
|
|
39
|
-
let emptyMessage_1: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
40
|
-
export { emptyMessage_1 as emptyMessage };
|
|
41
|
-
let showHeaderSum_1: PropTypes.Requireable<boolean>;
|
|
42
|
-
export { showHeaderSum_1 as showHeaderSum };
|
|
43
|
-
let title_1: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
44
|
-
export { title_1 as title };
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
1
|
import React from 'react';
|
|
48
|
-
import
|
|
2
|
+
import { type MetricRunInfo } from '@bundle-stats/utils';
|
|
3
|
+
import { Table } from '../../ui/table';
|
|
4
|
+
interface Item {
|
|
5
|
+
key: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
changed: boolean;
|
|
8
|
+
biggerIsBetter: boolean;
|
|
9
|
+
runs: Array<MetricRunInfo | null>;
|
|
10
|
+
}
|
|
11
|
+
interface MetricsTableProps extends Omit<React.ComponentProps<typeof Table>, 'title'> {
|
|
12
|
+
runs: Array<{
|
|
13
|
+
internalBuildNumber: number;
|
|
14
|
+
}>;
|
|
15
|
+
items: Array<Item>;
|
|
16
|
+
title?: React.ReactNode;
|
|
17
|
+
showHeaderSum?: boolean;
|
|
18
|
+
sort?: any;
|
|
19
|
+
updateSort?: (val: any) => void;
|
|
20
|
+
renderRowHeader?: (item: Item) => React.ReactNode;
|
|
21
|
+
emptyMessage?: React.ReactNode;
|
|
22
|
+
showAllItems: boolean;
|
|
23
|
+
setShowAllItems: (value: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
export declare const MetricsTable: ({ className, runs, items, showHeaderSum, title, sort, updateSort, renderRowHeader, emptyMessage, showAllItems, setShowAllItems, ...restProps }: MetricsTableProps) => React.JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const BASELINE_TITLE = "Baseline";
|
|
2
|
+
export declare const CURRENT_TITLE = "Current";
|
|
3
|
+
export declare const SORT_VALUE = "value";
|
|
4
|
+
export declare const SORT_CHANGE = "change";
|
|
5
|
+
export declare const SORT_PERCENTUAL_CHANGE = "percentual change";
|
|
6
|
+
export declare const EMPTY_MESSAGE = "No items found.";
|
|
7
|
+
export declare const SHOW_ALL = "Show all";
|
|
8
|
+
export declare const SHOW_LESS = "Show less";
|
|
@@ -4,8 +4,8 @@ interface SortButtonProps {
|
|
|
4
4
|
fieldPath: string;
|
|
5
5
|
fieldName: string;
|
|
6
6
|
label: string;
|
|
7
|
-
sort
|
|
8
|
-
updateSort
|
|
7
|
+
sort?: SortAction;
|
|
8
|
+
updateSort?: (params: SortAction) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare const SortButton: (props: SortButtonProps & React.ComponentProps<'div'>) => React.JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import type { SortAction } from '../types';
|
|
3
3
|
interface UseRowsSortParams {
|
|
4
4
|
rows: Array<unknown>;
|
|
5
|
-
initialField
|
|
6
|
-
initialDirection
|
|
7
|
-
getCustomSort: (item:
|
|
5
|
+
initialField?: string;
|
|
6
|
+
initialDirection?: SortAction['direction'];
|
|
7
|
+
getCustomSort: (item: any) => Array<string | number | boolean>;
|
|
8
8
|
}
|
|
9
|
-
export declare const getSortFn: (fieldPath: string, getCustomSort: UseRowsSortParams['getCustomSort']) => (item: unknown) =>
|
|
9
|
+
export declare const getSortFn: (fieldPath: string, getCustomSort: UseRowsSortParams['getCustomSort']) => (item: unknown) => any;
|
|
10
10
|
export declare const useRowsSort: ({ rows, initialField, initialDirection, getCustomSort, }: UseRowsSortParams) => {
|
|
11
11
|
sort: {
|
|
12
12
|
field: string;
|
|
@@ -9,5 +9,5 @@ interface BoxProps<T extends React.ElementType> {
|
|
|
9
9
|
outline?: boolean;
|
|
10
10
|
outlineHover?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare const Box: <T extends React.ElementType<any> = "div">(props: BoxProps<T> & Omit<React.ComponentProps<T>, keyof BoxProps<T>>) => React.JSX.Element;
|
|
12
|
+
export declare const Box: <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements> = "div">(props: BoxProps<T> & Omit<React.ComponentProps<T>, keyof BoxProps<T>>) => React.JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -7,5 +7,5 @@ interface FlexStackProps<T extends React.ElementType> {
|
|
|
7
7
|
inline?: boolean;
|
|
8
8
|
alignItems?: 'top' | 'center' | 'bottom';
|
|
9
9
|
}
|
|
10
|
-
export declare const FlexStack: <T extends React.ElementType<any> = "div">(props: FlexStackProps<T> & Omit<React.ComponentProps<T>, keyof FlexStackProps<T>>) => React.JSX.Element;
|
|
10
|
+
export declare const FlexStack: <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements> = "div">(props: FlexStackProps<T> & Omit<React.ComponentProps<T>, keyof FlexStackProps<T>>) => React.JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
export function Filters(props: any): React.JSX.Element;
|
|
2
|
-
export namespace Filters {
|
|
3
|
-
namespace defaultProps {
|
|
4
|
-
let className: string;
|
|
5
|
-
}
|
|
6
|
-
namespace propTypes {
|
|
7
|
-
let className_1: PropTypes.Requireable<string>;
|
|
8
|
-
export { className_1 as className };
|
|
9
|
-
export let values: PropTypes.Validator<object>;
|
|
10
|
-
export let filters: PropTypes.Validator<object>;
|
|
11
|
-
export let toggleFilter: PropTypes.Validator<(...args: any[]) => any>;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
1
|
import React from 'react';
|
|
15
|
-
import
|
|
2
|
+
import type { FilterFieldsData, FilterGroupFieldData } from '../../types';
|
|
3
|
+
interface FilterProps extends React.ComponentProps<'input'> {
|
|
4
|
+
as?: React.ElementType;
|
|
5
|
+
buttonClassName?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
name: string;
|
|
8
|
+
getOnOnlyClick?: (name: string) => () => void;
|
|
9
|
+
}
|
|
10
|
+
interface FilterGroupProps extends React.ComponentProps<'div'> {
|
|
11
|
+
buttonClassName?: string;
|
|
12
|
+
groupKey: string;
|
|
13
|
+
data: FilterGroupFieldData;
|
|
14
|
+
values: Record<string, boolean>;
|
|
15
|
+
onCheckboxChange: FilterProps['onChange'];
|
|
16
|
+
toggleFilters: (newFilters: Record<string, boolean>) => void;
|
|
17
|
+
}
|
|
18
|
+
interface FiltersProps extends React.ComponentProps<'div'> {
|
|
19
|
+
values: Record<string, boolean>;
|
|
20
|
+
filters: FilterFieldsData;
|
|
21
|
+
toggleFilter: (name: string, value: boolean) => void;
|
|
22
|
+
toggleFilters: FilterGroupProps['toggleFilters'];
|
|
23
|
+
}
|
|
24
|
+
export declare const Filters: (props: FiltersProps) => React.JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
import type { FilterFieldData, FilterFieldsData, FilterGroupFieldData } from '../../types';
|
|
2
|
+
export declare const LABELS: {
|
|
3
|
+
NONE: string;
|
|
4
|
+
ALL: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const getGroupFiltersLabelSuffix: (filters: FilterGroupFieldData['children']) => string;
|
|
7
|
+
export declare const getInitialValues: (key: string, filtersData: FilterFieldsData | FilterFieldData | FilterGroupFieldData | string) => Record<string, boolean>;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
export function Filters(props: any): React.JSX.Element;
|
|
2
|
-
export namespace Filters {
|
|
3
|
-
namespace defaultProps {
|
|
4
|
-
let onChange: null;
|
|
5
|
-
}
|
|
6
|
-
namespace propTypes {
|
|
7
|
-
export let filters: PropTypes.Validator<object>;
|
|
8
|
-
let onChange_1: PropTypes.Requireable<(...args: any[]) => any>;
|
|
9
|
-
export { onChange_1 as onChange };
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
1
|
import React from 'react';
|
|
13
|
-
import
|
|
2
|
+
import { FilterFieldsData } from '../../types';
|
|
3
|
+
import { Filters as BaseComponent } from './filters';
|
|
4
|
+
interface FiltersProps extends Omit<React.ComponentProps<typeof BaseComponent>, 'onChange' | 'filters' | 'values' | 'toggleFilter' | 'toggleFilters'> {
|
|
5
|
+
onChange?: (newValues: Record<string, boolean>) => void;
|
|
6
|
+
filters: FilterFieldsData;
|
|
7
|
+
}
|
|
8
|
+
export declare const Filters: (props: FiltersProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -6,10 +6,10 @@ interface TableProps {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const Table: {
|
|
8
8
|
(props: TableProps & React.ComponentProps<'table'>): React.JSX.Element;
|
|
9
|
-
THead: React.ElementType<any>;
|
|
10
|
-
TBody: React.ElementType<any>;
|
|
11
|
-
Tr: React.ElementType<any>;
|
|
12
|
-
Th: React.ElementType<any>;
|
|
13
|
-
Td: React.ElementType<any>;
|
|
9
|
+
THead: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
|
|
10
|
+
TBody: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
|
|
11
|
+
Tr: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
|
|
12
|
+
Th: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
|
|
13
|
+
Td: React.ElementType<any, keyof React.JSX.IntrinsicElements>;
|
|
14
14
|
};
|
|
15
15
|
export {};
|
|
@@ -7,5 +7,5 @@ interface TooltipProps<T extends React.ElementType> {
|
|
|
7
7
|
containerRef?: React.RefObject<HTMLElement>;
|
|
8
8
|
darkMode?: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const Tooltip: <T extends React.ElementType<any> = "span">(props: TooltipProps<T> & Omit<React.ComponentProps<T>, keyof TooltipProps<T>>) => React.JSX.Element;
|
|
10
|
+
export declare const Tooltip: <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements> = "span">(props: TooltipProps<T> & Omit<React.ComponentProps<T>, keyof TooltipProps<T>>) => React.JSX.Element;
|
|
11
11
|
export {};
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import isEmpty from 'lodash/isEmpty';
|
|
5
|
-
import get from 'lodash/get';
|
|
6
|
-
import {
|
|
7
|
-
FILE_TYPE_LABELS,
|
|
8
|
-
MODULE_SOURCE_FILE_TYPES,
|
|
9
|
-
MODULE_SOURCE_TYPE,
|
|
10
|
-
MODULE_CHUNK,
|
|
11
|
-
MODULE_FILTERS,
|
|
12
|
-
MODULE_FILE_TYPE,
|
|
13
|
-
SECTIONS,
|
|
14
|
-
COMPONENT,
|
|
15
|
-
} from '@bundle-stats/utils';
|
|
16
|
-
|
|
17
|
-
import config from '../../config.json';
|
|
18
|
-
import I18N from '../../i18n';
|
|
19
|
-
import { ComponentLink } from '../component-link';
|
|
20
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
21
|
-
import { EmptySet } from '../../ui/empty-set';
|
|
22
|
-
import { FileName } from '../../ui/file-name';
|
|
23
|
-
import { Filters } from '../../ui/filters';
|
|
24
|
-
import { Tag } from '../../ui/tag';
|
|
25
|
-
import { Toolbar } from '../../ui/toolbar';
|
|
26
|
-
import { MetricsTable } from '../metrics-table';
|
|
27
|
-
import { MetricsTableSearch } from '../metrics-table-search';
|
|
28
|
-
import { MetricsTableOptions } from '../metrics-table-options';
|
|
29
|
-
import { MetricsTableTitle } from '../metrics-table-title';
|
|
30
|
-
import { ModuleInfo } from '../module-info';
|
|
31
|
-
import css from './bundle-modules.module.css';
|
|
32
|
-
|
|
33
|
-
const getFilters = ({ filters, compareMode, chunks }) => {
|
|
34
|
-
const chunkFilter = { label: 'Chunk' };
|
|
35
|
-
chunks?.forEach((chunk) => {
|
|
36
|
-
chunkFilter[chunk.id] = {
|
|
37
|
-
label: chunk.name,
|
|
38
|
-
defaultValue: filters[`${MODULE_CHUNK}.${chunk.id}`] ?? true,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
[MODULE_FILTERS.CHANGED]: {
|
|
44
|
-
label: 'Changed',
|
|
45
|
-
defaultValue: filters.changed,
|
|
46
|
-
disabled: !compareMode,
|
|
47
|
-
},
|
|
48
|
-
[MODULE_FILTERS.DUPLICATED]: {
|
|
49
|
-
label: 'Duplicate',
|
|
50
|
-
defaultValue: filters[MODULE_FILTERS.DUPLICATED],
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
// When chunks data is available, list available chunks as filters
|
|
54
|
-
...(!isEmpty(chunks) && {
|
|
55
|
-
[MODULE_CHUNK]: chunkFilter,
|
|
56
|
-
}),
|
|
57
|
-
|
|
58
|
-
[MODULE_SOURCE_TYPE]: {
|
|
59
|
-
label: 'Source',
|
|
60
|
-
[MODULE_FILTERS.FIRST_PARTY]: {
|
|
61
|
-
label: 'First party',
|
|
62
|
-
defaultValue: get(filters, `${MODULE_SOURCE_TYPE}.${MODULE_FILTERS.FIRST_PARTY}`, true),
|
|
63
|
-
},
|
|
64
|
-
[MODULE_FILTERS.THIRD_PARTY]: {
|
|
65
|
-
label: 'Third party',
|
|
66
|
-
defaultValue: get(filters, `${MODULE_SOURCE_TYPE}.${MODULE_FILTERS.THIRD_PARTY}`, true),
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
// Module source types
|
|
71
|
-
[MODULE_FILE_TYPE]: {
|
|
72
|
-
label: 'File type',
|
|
73
|
-
...MODULE_SOURCE_FILE_TYPES.reduce(
|
|
74
|
-
(agg, fileType) => ({
|
|
75
|
-
...agg,
|
|
76
|
-
[fileType]: {
|
|
77
|
-
label: FILE_TYPE_LABELS[fileType],
|
|
78
|
-
defaultValue: get(filters, `${MODULE_FILE_TYPE}.${fileType}`, true),
|
|
79
|
-
},
|
|
80
|
-
}),
|
|
81
|
-
{},
|
|
82
|
-
),
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const RowHeader = ({ row, filters, search, customComponentLink: CustomComponentLink }) => (
|
|
88
|
-
<CustomComponentLink
|
|
89
|
-
section={SECTIONS.MODULES}
|
|
90
|
-
params={{ [COMPONENT.BUNDLE_MODULES]: { filters, search, entryId: row.key } }}
|
|
91
|
-
className={css.name}
|
|
92
|
-
>
|
|
93
|
-
{row.duplicated && (
|
|
94
|
-
<Tag className={css.nameTagDuplicated} size="small" kind={Tag.KINDS.DANGER} />
|
|
95
|
-
)}
|
|
96
|
-
<FileName className={css.nameText} name={row.label} />
|
|
97
|
-
</CustomComponentLink>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
RowHeader.propTypes = {
|
|
101
|
-
row: PropTypes.shape({
|
|
102
|
-
label: PropTypes.string,
|
|
103
|
-
duplicated: PropTypes.bool,
|
|
104
|
-
}).isRequired,
|
|
105
|
-
search: PropTypes.string,
|
|
106
|
-
filters: PropTypes.object,
|
|
107
|
-
customComponentLink: PropTypes.elementType.isRequired,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
RowHeader.defaultProps = {
|
|
111
|
-
chunks: [],
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const BundleModules = ({
|
|
115
|
-
className,
|
|
116
|
-
jobs,
|
|
117
|
-
items,
|
|
118
|
-
chunks,
|
|
119
|
-
totalRowCount,
|
|
120
|
-
updateFilters,
|
|
121
|
-
resetFilters,
|
|
122
|
-
resetAllFilters,
|
|
123
|
-
filters,
|
|
124
|
-
entryId,
|
|
125
|
-
sort,
|
|
126
|
-
updateSort,
|
|
127
|
-
search,
|
|
128
|
-
updateSearch,
|
|
129
|
-
hasActiveFilters,
|
|
130
|
-
customComponentLink: CustomComponentLink,
|
|
131
|
-
allItems,
|
|
132
|
-
hideEntryInfo,
|
|
133
|
-
}) => {
|
|
134
|
-
const rootClassName = cx(css.root, className);
|
|
135
|
-
|
|
136
|
-
const jobLabels = jobs?.map((job) => job?.label);
|
|
137
|
-
|
|
138
|
-
const dropdownFilters = useMemo(
|
|
139
|
-
() => getFilters({ filters, chunks, compareMode: jobs.length > 1 }),
|
|
140
|
-
[jobs, filters, chunks]
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
const metricsTableTitle = useMemo(() => (
|
|
144
|
-
<MetricsTableTitle
|
|
145
|
-
title={I18N.MODULES}
|
|
146
|
-
info={`${items.length}/${totalRowCount}`}
|
|
147
|
-
popoverInfo={I18N.MODULES_INFO}
|
|
148
|
-
popoverHref={config.documentation.modules}
|
|
149
|
-
/>
|
|
150
|
-
), [items, totalRowCount]);
|
|
151
|
-
|
|
152
|
-
const renderRowHeader = useCallback(
|
|
153
|
-
(row) => (
|
|
154
|
-
<RowHeader
|
|
155
|
-
row={row}
|
|
156
|
-
filters={filters}
|
|
157
|
-
search={search}
|
|
158
|
-
customComponentLink={CustomComponentLink}
|
|
159
|
-
/>
|
|
160
|
-
),
|
|
161
|
-
[jobs, chunks, CustomComponentLink, filters, search],
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
const emptyMessage = useMemo(() => (
|
|
165
|
-
<EmptySet
|
|
166
|
-
resources="modules"
|
|
167
|
-
filtered={totalRowCount !== 0}
|
|
168
|
-
handleResetFilters={resetFilters}
|
|
169
|
-
handleViewAll={resetAllFilters}
|
|
170
|
-
/>
|
|
171
|
-
), [totalRowCount, resetFilters, resetAllFilters]);
|
|
172
|
-
|
|
173
|
-
const entryItem = useMemo(() => {
|
|
174
|
-
if (!entryId) {
|
|
175
|
-
return null;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return allItems.find(({ key }) => key === entryId)
|
|
179
|
-
}, [allItems, entryId]);
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<>
|
|
183
|
-
<div className={rootClassName}>
|
|
184
|
-
<Toolbar
|
|
185
|
-
className={css.toolbar}
|
|
186
|
-
renderActions={({ actionClassName }) => (
|
|
187
|
-
<FlexStack space="xxsmall" className={cx(css.dropdown, actionClassName)}>
|
|
188
|
-
<MetricsTableOptions
|
|
189
|
-
handleViewAll={resetAllFilters}
|
|
190
|
-
handleResetFilters={resetFilters}
|
|
191
|
-
/>
|
|
192
|
-
</FlexStack>
|
|
193
|
-
)}
|
|
194
|
-
>
|
|
195
|
-
<FlexStack space="xxsmall">
|
|
196
|
-
<MetricsTableSearch
|
|
197
|
-
className={css.toolbarSearch}
|
|
198
|
-
search={search}
|
|
199
|
-
updateSearch={updateSearch}
|
|
200
|
-
placeholder="Search by name"
|
|
201
|
-
/>
|
|
202
|
-
<Filters
|
|
203
|
-
className={css.tableDropdown}
|
|
204
|
-
filters={dropdownFilters}
|
|
205
|
-
onChange={updateFilters}
|
|
206
|
-
hasActiveFilters={hasActiveFilters}
|
|
207
|
-
/>
|
|
208
|
-
</FlexStack>
|
|
209
|
-
</Toolbar>
|
|
210
|
-
|
|
211
|
-
<MetricsTable
|
|
212
|
-
className={css.table}
|
|
213
|
-
items={items}
|
|
214
|
-
runs={jobs}
|
|
215
|
-
renderRowHeader={renderRowHeader}
|
|
216
|
-
emptyMessage={emptyMessage}
|
|
217
|
-
showHeaderSum
|
|
218
|
-
title={metricsTableTitle}
|
|
219
|
-
sort={sort}
|
|
220
|
-
updateSort={updateSort}
|
|
221
|
-
/>
|
|
222
|
-
</div>
|
|
223
|
-
{entryItem && (
|
|
224
|
-
<ModuleInfo
|
|
225
|
-
className={css.moduleInfo}
|
|
226
|
-
item={entryItem}
|
|
227
|
-
chunks={chunks}
|
|
228
|
-
chunkIds={chunks?.map(({ id }) => id)}
|
|
229
|
-
labels={jobLabels}
|
|
230
|
-
customComponentLink={CustomComponentLink}
|
|
231
|
-
onClose={hideEntryInfo}
|
|
232
|
-
/>
|
|
233
|
-
)}
|
|
234
|
-
</>
|
|
235
|
-
);
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
BundleModules.defaultProps = {
|
|
239
|
-
className: '',
|
|
240
|
-
items: [],
|
|
241
|
-
jobs: [],
|
|
242
|
-
totalRowCount: 0,
|
|
243
|
-
hasActiveFilters: false,
|
|
244
|
-
customComponentLink: ComponentLink,
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
BundleModules.propTypes = {
|
|
248
|
-
/** Adopted child class name */
|
|
249
|
-
className: PropTypes.string,
|
|
250
|
-
|
|
251
|
-
/** Rows data */
|
|
252
|
-
items: PropTypes.array, // eslint-disable-line react/forbid-prop-types
|
|
253
|
-
|
|
254
|
-
/** Jobs data */
|
|
255
|
-
jobs: PropTypes.array, // eslint-disable-line react/forbid-prop-types
|
|
256
|
-
|
|
257
|
-
/** Chunks data */
|
|
258
|
-
chunks: PropTypes.arrayOf(
|
|
259
|
-
PropTypes.shape({
|
|
260
|
-
id: PropTypes.string,
|
|
261
|
-
name: PropTypes.string,
|
|
262
|
-
}),
|
|
263
|
-
).isRequired,
|
|
264
|
-
|
|
265
|
-
/** total row count */
|
|
266
|
-
totalRowCount: PropTypes.number,
|
|
267
|
-
|
|
268
|
-
/** Update filters handler */
|
|
269
|
-
updateFilters: PropTypes.func.isRequired,
|
|
270
|
-
|
|
271
|
-
/** Reset filters handler */
|
|
272
|
-
resetFilters: PropTypes.func.isRequired,
|
|
273
|
-
resetAllFilters: PropTypes.func.isRequired,
|
|
274
|
-
|
|
275
|
-
/** Filters data */
|
|
276
|
-
filters: PropTypes.shape({
|
|
277
|
-
changed: PropTypes.bool,
|
|
278
|
-
}).isRequired,
|
|
279
|
-
|
|
280
|
-
hasActiveFilters: PropTypes.bool,
|
|
281
|
-
|
|
282
|
-
sort: PropTypes.shape({
|
|
283
|
-
sortBy: PropTypes.string,
|
|
284
|
-
direction: PropTypes.string,
|
|
285
|
-
}).isRequired,
|
|
286
|
-
updateSort: PropTypes.func.isRequired,
|
|
287
|
-
search: PropTypes.string.isRequired,
|
|
288
|
-
updateSearch: PropTypes.func.isRequired,
|
|
289
|
-
customComponentLink: PropTypes.elementType,
|
|
290
|
-
hideEntryInfo: PropTypes.func.isRequired,
|
|
291
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import intersection from 'lodash/intersection';
|
|
2
|
-
import union from 'lodash/union';
|
|
3
|
-
import { MODULE_PATH_PACKAGES } from '@bundle-stats/utils/lib-esm/webpack';
|
|
4
|
-
import {
|
|
5
|
-
MODULE_CHUNK,
|
|
6
|
-
MODULE_FILTERS,
|
|
7
|
-
MODULE_FILE_TYPE,
|
|
8
|
-
MODULE_SOURCE_TYPE,
|
|
9
|
-
getModuleSourceFileType,
|
|
10
|
-
} from '@bundle-stats/utils';
|
|
11
|
-
|
|
12
|
-
export const addRowFlags = (row) => {
|
|
13
|
-
const { key, runs } = row;
|
|
14
|
-
|
|
15
|
-
// @NOTE Assign instead destructuring for perf reasons
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line no-param-reassign
|
|
18
|
-
row.thirdParty = Boolean(key.match(MODULE_PATH_PACKAGES));
|
|
19
|
-
// eslint-disable-next-line no-param-reassign
|
|
20
|
-
row.duplicated = Boolean(runs.find((run) => run?.duplicated === true));
|
|
21
|
-
// eslint-disable-next-line no-param-reassign
|
|
22
|
-
row.fileType = getModuleSourceFileType(row.key);
|
|
23
|
-
|
|
24
|
-
return row;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const getCustomSort = (item) => [!item.changed, item.key];
|
|
28
|
-
|
|
29
|
-
export const generateGetRowFilter =
|
|
30
|
-
({ chunkIds }) =>
|
|
31
|
-
(filters) => {
|
|
32
|
-
// eslint-disable-line prettier/prettier
|
|
33
|
-
// List of chunkIds with filter value set to `true`
|
|
34
|
-
const checkedChunkIds = [];
|
|
35
|
-
|
|
36
|
-
chunkIds.forEach((chunkId) => {
|
|
37
|
-
if (filters[`${MODULE_CHUNK}.${chunkId}`]) {
|
|
38
|
-
checkedChunkIds.push(chunkId);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const hasChunkFilters = checkedChunkIds.length !== chunkIds.length;
|
|
43
|
-
|
|
44
|
-
return (row) => {
|
|
45
|
-
// Skip not changed rows
|
|
46
|
-
if (filters[MODULE_FILTERS.CHANGED] && !row.changed) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Skip not duplicated rows
|
|
51
|
-
if (filters[MODULE_FILTERS.DUPLICATED] && !row.duplicated) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Skip not matching source type
|
|
56
|
-
if (
|
|
57
|
-
!(
|
|
58
|
-
(filters[`${MODULE_SOURCE_TYPE}.${MODULE_FILTERS.FIRST_PARTY}`] &&
|
|
59
|
-
row.thirdParty === false) ||
|
|
60
|
-
(filters[`${MODULE_SOURCE_TYPE}.${MODULE_FILTERS.THIRD_PARTY}`] &&
|
|
61
|
-
row.thirdParty === true)
|
|
62
|
-
)
|
|
63
|
-
) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Skip not matching source file types
|
|
68
|
-
if (!filters[`${MODULE_FILE_TYPE}.${row.fileType}`]) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Filter if any of the chunkIds are checked
|
|
73
|
-
if (hasChunkFilters) {
|
|
74
|
-
const rowRunsChunkIds = row?.runs?.map((run) => run?.chunkIds || []) || [];
|
|
75
|
-
const rowChunkIds = union(...rowRunsChunkIds);
|
|
76
|
-
const matchedChunkIds = intersection(rowChunkIds, checkedChunkIds);
|
|
77
|
-
return matchedChunkIds.length > 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return true;
|
|
81
|
-
};
|
|
82
|
-
};
|