@bundle-stats/ui 4.8.4-beta.0 → 4.9.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/bundle-assets/bundle-assets.js +2 -2
- package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib/components/bundle-modules/bundle-modules.js +2 -2
- package/lib/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib/components/bundle-packages/bundle-packages.js +2 -2
- package/lib/components/bundle-packages/bundle-packages.js.map +1 -1
- package/lib/components/index.js +1 -3
- package/lib/components/index.js.map +1 -1
- package/lib/components/metrics-table/metrics-table.i18n.js +4 -4
- package/lib/components/metrics-table/metrics-table.i18n.js.map +1 -1
- package/lib/components/metrics-table/metrics-table.js +3 -3
- package/lib/components/metrics-table/metrics-table.js.map +1 -1
- package/lib/hooks/rows-sort.js +1 -1
- package/lib/hooks/rows-sort.js.map +1 -1
- package/lib/ui/filters/filters.i18n.js +4 -1
- package/lib/ui/filters/filters.i18n.js.map +1 -1
- package/lib/ui/filters/filters.js +22 -6
- package/lib/ui/filters/filters.js.map +1 -1
- package/lib/ui/filters/filters.module.css +29 -0
- package/lib/ui/index.js +3 -1
- package/lib/ui/index.js.map +1 -1
- package/lib/ui/input/index.js.map +1 -1
- package/lib/ui/input/input.js +2 -10
- package/lib/ui/input/input.js.map +1 -1
- package/lib/{components/metrics-table-search → ui/input-search}/index.js +1 -1
- package/lib/ui/input-search/index.js.map +1 -0
- package/lib/ui/input-search/input-search.js +63 -0
- package/lib/ui/input-search/input-search.js.map +1 -0
- package/lib-esm/components/bundle-assets/bundle-assets.js +2 -2
- package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib-esm/components/bundle-modules/bundle-modules.js +2 -2
- package/lib-esm/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib-esm/components/bundle-packages/bundle-packages.js +2 -2
- package/lib-esm/components/bundle-packages/bundle-packages.js.map +1 -1
- package/lib-esm/components/index.js +0 -1
- package/lib-esm/components/index.js.map +1 -1
- package/lib-esm/components/metrics-table/metrics-table.i18n.js +3 -3
- package/lib-esm/components/metrics-table/metrics-table.i18n.js.map +1 -1
- package/lib-esm/components/metrics-table/metrics-table.js +3 -3
- package/lib-esm/components/metrics-table/metrics-table.js.map +1 -1
- 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 -1
- package/lib-esm/ui/filters/filters.js +23 -7
- package/lib-esm/ui/filters/filters.js.map +1 -1
- package/lib-esm/ui/filters/filters.module.css +29 -0
- package/lib-esm/ui/index.js +1 -0
- package/lib-esm/ui/index.js.map +1 -1
- package/lib-esm/ui/input/index.js.map +1 -1
- package/lib-esm/ui/input/input.js +2 -10
- package/lib-esm/ui/input/input.js.map +1 -1
- package/lib-esm/ui/input-search/index.js +2 -0
- package/lib-esm/ui/input-search/index.js.map +1 -0
- package/lib-esm/ui/input-search/input-search.js +33 -0
- package/lib-esm/ui/input-search/input-search.js.map +1 -0
- package/package.json +10 -10
- package/src/components/bundle-assets/bundle-assets.jsx +4 -4
- package/src/components/bundle-modules/bundle-modules.tsx +4 -4
- package/src/components/bundle-packages/bundle-packages.jsx +4 -4
- package/src/components/index.js +0 -1
- package/src/components/metrics-table/metrics-table.i18n.ts +3 -3
- package/src/components/metrics-table/metrics-table.tsx +3 -3
- package/src/hooks/rows-sort.ts +1 -1
- package/src/ui/filters/filters.i18n.ts +3 -0
- package/src/ui/filters/filters.module.css +29 -0
- package/src/ui/filters/filters.tsx +63 -25
- package/src/ui/index.js +1 -0
- package/src/ui/input/input.stories.tsx +13 -0
- package/src/ui/input/input.tsx +16 -0
- package/src/ui/input-search/index.ts +1 -0
- package/src/ui/input-search/input-search.tsx +82 -0
- package/types/components/index.d.ts +0 -1
- package/types/components/metrics-table/metrics-table.i18n.d.ts +3 -3
- package/types/hooks/rows-sort.d.ts +1 -1
- package/types/ui/filters/filters.i18n.d.ts +3 -0
- package/types/ui/index.d.ts +1 -0
- package/types/ui/input/index.d.ts +1 -1
- package/types/ui/input/input.d.ts +5 -18
- package/types/ui/input-search/index.d.ts +1 -0
- package/types/ui/input-search/input-search.d.ts +9 -0
- package/lib/components/metrics-table-search/index.js.map +0 -1
- package/lib/components/metrics-table-search/metrics-table-search.js +0 -73
- package/lib/components/metrics-table-search/metrics-table-search.js.map +0 -1
- package/lib-esm/components/metrics-table-search/index.js +0 -2
- package/lib-esm/components/metrics-table-search/index.js.map +0 -1
- package/lib-esm/components/metrics-table-search/metrics-table-search.js +0 -43
- package/lib-esm/components/metrics-table-search/metrics-table-search.js.map +0 -1
- package/src/components/metrics-table-search/index.js +0 -1
- package/src/components/metrics-table-search/metrics-table-search.jsx +0 -72
- package/src/ui/input/input.jsx +0 -20
- package/types/components/metrics-table-search/index.d.ts +0 -1
- package/types/components/metrics-table-search/metrics-table-search.d.ts +0 -17
- /package/lib/{components/metrics-table-search/metrics-table-search.module.css → ui/input-search/input-search.module.css} +0 -0
- /package/lib-esm/{components/metrics-table-search/metrics-table-search.module.css → ui/input-search/input-search.module.css} +0 -0
- /package/src/ui/input/{index.js → index.ts} +0 -0
- /package/src/{components/metrics-table-search/metrics-table-search.module.css → ui/input-search/input-search.module.css} +0 -0
|
@@ -15,6 +15,7 @@ import config from '../../config.json';
|
|
|
15
15
|
import I18N from '../../i18n';
|
|
16
16
|
import { FlexStack } from '../../layout/flex-stack';
|
|
17
17
|
import { Icon } from '../../ui/icon';
|
|
18
|
+
import { InputSearch } from '../../ui/input-search';
|
|
18
19
|
import { FileName } from '../../ui/file-name';
|
|
19
20
|
import { HoverCard } from '../../ui/hover-card';
|
|
20
21
|
import { Tag } from '../../ui/tag';
|
|
@@ -25,7 +26,6 @@ import { AssetInfo } from '../asset-info';
|
|
|
25
26
|
import { AssetNotPredictive } from '../asset-not-predictive';
|
|
26
27
|
import { ComponentLink } from '../component-link';
|
|
27
28
|
import { MetricsTable } from '../metrics-table';
|
|
28
|
-
import { MetricsTableSearch } from '../metrics-table-search';
|
|
29
29
|
import { MetricsTableOptions } from '../metrics-table-options';
|
|
30
30
|
import { MetricsTableTitle } from '../metrics-table-title';
|
|
31
31
|
import css from './bundle-assets.module.css';
|
|
@@ -235,11 +235,11 @@ export const BundleAssets = (props) => {
|
|
|
235
235
|
)}
|
|
236
236
|
>
|
|
237
237
|
<FlexStack space="xxsmall">
|
|
238
|
-
<
|
|
238
|
+
<InputSearch
|
|
239
239
|
className={css.toolbarSearch}
|
|
240
240
|
placeholder="Search by name"
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
defaultValue={search}
|
|
242
|
+
onChange={updateSearch}
|
|
243
243
|
/>
|
|
244
244
|
<Filters
|
|
245
245
|
className={css.toolbarFilters}
|
|
@@ -7,13 +7,13 @@ import config from '../../config.json';
|
|
|
7
7
|
import I18N from '../../i18n';
|
|
8
8
|
import { ComponentLink } from '../component-link';
|
|
9
9
|
import { FlexStack } from '../../layout/flex-stack';
|
|
10
|
+
import { InputSearch } from '../../ui/input-search';
|
|
10
11
|
import { EmptySet } from '../../ui/empty-set';
|
|
11
12
|
import { FileName } from '../../ui/file-name';
|
|
12
13
|
import { Filters } from '../../ui/filters';
|
|
13
14
|
import { Tag } from '../../ui/tag';
|
|
14
15
|
import { Toolbar } from '../../ui/toolbar';
|
|
15
16
|
import { MetricsTable } from '../metrics-table';
|
|
16
|
-
import { MetricsTableSearch } from '../metrics-table-search';
|
|
17
17
|
import { MetricsTableOptions } from '../metrics-table-options';
|
|
18
18
|
import { MetricsTableTitle } from '../metrics-table-title';
|
|
19
19
|
import { ModuleInfo } from '../module-info';
|
|
@@ -159,11 +159,11 @@ export const BundleModules = (props: BundleModulesProps) => {
|
|
|
159
159
|
)}
|
|
160
160
|
>
|
|
161
161
|
<FlexStack space="xxsmall">
|
|
162
|
-
<
|
|
162
|
+
<InputSearch
|
|
163
163
|
className={css.toolbarSearch}
|
|
164
|
-
search={search}
|
|
165
|
-
updateSearch={updateSearch}
|
|
166
164
|
placeholder={I18N_MODULES.SEARCH}
|
|
165
|
+
defaultValue={search}
|
|
166
|
+
onChange={updateSearch}
|
|
167
167
|
/>
|
|
168
168
|
<Filters
|
|
169
169
|
className={css.tableDropdown}
|
|
@@ -6,13 +6,13 @@ import { COMPONENT, PACKAGE_FILTERS, PACKAGES_SEPARATOR, SECTIONS } from '@bundl
|
|
|
6
6
|
import config from '../../config.json';
|
|
7
7
|
import I18N from '../../i18n';
|
|
8
8
|
import { FlexStack } from '../../layout/flex-stack';
|
|
9
|
+
import { InputSearch } from '../../ui/input-search';
|
|
9
10
|
import { EmptySet } from '../../ui/empty-set';
|
|
10
11
|
import { Filters } from '../../ui/filters';
|
|
11
12
|
import { Tag } from '../../ui/tag';
|
|
12
13
|
import { Toolbar } from '../../ui/toolbar';
|
|
13
14
|
import { ComponentLink } from '../component-link';
|
|
14
15
|
import { MetricsTable } from '../metrics-table';
|
|
15
|
-
import { MetricsTableSearch } from '../metrics-table-search';
|
|
16
16
|
import { MetricsTableOptions } from '../metrics-table-options';
|
|
17
17
|
import { MetricsTableTitle } from '../metrics-table-title';
|
|
18
18
|
import { PackageInfo } from '../package-info';
|
|
@@ -194,11 +194,11 @@ export const BundlePackages = (props) => {
|
|
|
194
194
|
)}
|
|
195
195
|
>
|
|
196
196
|
<FlexStack space="xxsmall">
|
|
197
|
-
<
|
|
197
|
+
<InputSearch
|
|
198
198
|
className={css.toolbarSearch}
|
|
199
199
|
placeholder="Search by name"
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
defaultValue={search}
|
|
201
|
+
onChange={updateSearch}
|
|
202
202
|
/>
|
|
203
203
|
<Filters
|
|
204
204
|
filters={dropdownFilters}
|
package/src/components/index.js
CHANGED
|
@@ -15,7 +15,6 @@ export { Metric } from './metric';
|
|
|
15
15
|
export { MetricRunInfo, MetricRunInfoProps } from './metric-run-info';
|
|
16
16
|
export { MetricsTable } from './metrics-table';
|
|
17
17
|
export { MetricsTableOptions } from './metrics-table-options';
|
|
18
|
-
export { MetricsTableSearch } from './metrics-table-search';
|
|
19
18
|
export { MetricsTableTitle } from './metrics-table-title';
|
|
20
19
|
export { ModuleInfo } from './module-info';
|
|
21
20
|
export { RunInfo, RunInfoProps } from './run-info';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const BASELINE_TITLE = 'Baseline';
|
|
2
2
|
export const CURRENT_TITLE = 'Current';
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const SORT_PERCENTUAL_CHANGE = '
|
|
4
|
+
export const SORT_VALUE = 'value';
|
|
5
|
+
export const SORT_CHANGE = 'change';
|
|
6
|
+
export const SORT_PERCENTUAL_CHANGE = 'percentual change';
|
|
7
7
|
|
|
8
8
|
export const EMPTY_MESSAGE = 'No items found.';
|
|
9
9
|
export const SHOW_ALL = 'Show all';
|
|
@@ -92,7 +92,7 @@ const SumColumn = ({ rows, isBaseline, runIndex, updateSort, sort }: ColumnSumPr
|
|
|
92
92
|
<SortButton
|
|
93
93
|
fieldPath={fieldPath}
|
|
94
94
|
fieldName="value"
|
|
95
|
-
label=
|
|
95
|
+
label={I18N.SORT_VALUE}
|
|
96
96
|
updateSort={updateSort}
|
|
97
97
|
sort={sort}
|
|
98
98
|
>
|
|
@@ -105,7 +105,7 @@ const SumColumn = ({ rows, isBaseline, runIndex, updateSort, sort }: ColumnSumPr
|
|
|
105
105
|
<SortButton
|
|
106
106
|
fieldPath={fieldPath}
|
|
107
107
|
fieldName="delta"
|
|
108
|
-
label=
|
|
108
|
+
label={I18N.SORT_CHANGE}
|
|
109
109
|
updateSort={updateSort}
|
|
110
110
|
sort={sort}
|
|
111
111
|
>
|
|
@@ -118,7 +118,7 @@ const SumColumn = ({ rows, isBaseline, runIndex, updateSort, sort }: ColumnSumPr
|
|
|
118
118
|
<SortButton
|
|
119
119
|
fieldPath={fieldPath}
|
|
120
120
|
fieldName="deltaPercentage"
|
|
121
|
-
label=
|
|
121
|
+
label={I18N.SORT_PERCENTUAL_CHANGE}
|
|
122
122
|
updateSort={updateSort}
|
|
123
123
|
sort={sort}
|
|
124
124
|
>
|
package/src/hooks/rows-sort.ts
CHANGED
|
@@ -116,6 +116,35 @@
|
|
|
116
116
|
text-transform: lowercase;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
.filterGroupSearchWrapper {
|
|
120
|
+
padding-bottom: var(--space-xxxsmall);
|
|
121
|
+
margin-bottom: var(--space-xxxsmall);
|
|
122
|
+
border-bottom: 1px solid var(--color-outline);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.filterGroupSearchNotFound {
|
|
126
|
+
padding: var(--space-xxsmall) 0;
|
|
127
|
+
text-align: center;
|
|
128
|
+
font-size: var(--size-small);
|
|
129
|
+
color: var(--color-text-light);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.filterGroupSearchNotFoundClear {
|
|
133
|
+
outline: none;
|
|
134
|
+
appearance: none;
|
|
135
|
+
border: none;
|
|
136
|
+
background: none;
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
white-space: nowrap;
|
|
139
|
+
color: var(--color-text-dark);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.filterGroupSearchNotFoundClear:hover,
|
|
143
|
+
.filterGroupSearchNotFoundClear:active,
|
|
144
|
+
.filterGroupSearchNotFoundClear:focus {
|
|
145
|
+
color: var(--color-text-dark);
|
|
146
|
+
}
|
|
147
|
+
|
|
119
148
|
.filterGroupItems {
|
|
120
149
|
max-height: calc(10 * (var(--space-small) + 2 * var(--space-xxxsmall)));
|
|
121
150
|
overflow: auto;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import cx from 'classnames';
|
|
3
3
|
|
|
4
4
|
import type { FilterFieldsData, FilterGroupFieldData } from '../../types';
|
|
5
5
|
import { FlexStack } from '../../layout/flex-stack';
|
|
6
|
+
import { Stack } from '../../layout/stack';
|
|
6
7
|
import { Dropdown } from '../dropdown';
|
|
8
|
+
import { InputSearch } from '../input-search';
|
|
7
9
|
import * as I18N from './filters.i18n';
|
|
8
10
|
import { getGroupFiltersLabelSuffix, LABELS } from './filters.utils';
|
|
9
11
|
import css from './filters.module.css';
|
|
@@ -75,6 +77,8 @@ const FilterGroup = (props: FilterGroupProps) => {
|
|
|
75
77
|
toggleFilters,
|
|
76
78
|
} = props;
|
|
77
79
|
|
|
80
|
+
const [search, setSearch] = useState('');
|
|
81
|
+
|
|
78
82
|
const { label: groupLabel, children: groupItems } = data;
|
|
79
83
|
|
|
80
84
|
const areAllGroupItemsChecked = groupItems
|
|
@@ -108,6 +112,14 @@ const FilterGroup = (props: FilterGroupProps) => {
|
|
|
108
112
|
});
|
|
109
113
|
};
|
|
110
114
|
|
|
115
|
+
const filteredGroupItems = useMemo(() => {
|
|
116
|
+
if (!search) {
|
|
117
|
+
return groupItems;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return groupItems.filter((item) => item.label.match(new RegExp(`${search}`, 'i')));
|
|
121
|
+
}, [search, groupItems]);
|
|
122
|
+
|
|
111
123
|
return (
|
|
112
124
|
<Dropdown
|
|
113
125
|
className={className}
|
|
@@ -118,8 +130,32 @@ const FilterGroup = (props: FilterGroupProps) => {
|
|
|
118
130
|
{({ MenuItem, menuItemClassName }) => {
|
|
119
131
|
return (
|
|
120
132
|
<>
|
|
133
|
+
{groupItems.length > 10 && (
|
|
134
|
+
<div className={css.filterGroupSearchWrapper}>
|
|
135
|
+
<InputSearch
|
|
136
|
+
defaultValue={search}
|
|
137
|
+
onChange={setSearch}
|
|
138
|
+
placeholder={I18N.CHUNKS_SEARCH}
|
|
139
|
+
debounceWait={0}
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
121
143
|
<div className={css.filterGroupItems}>
|
|
122
|
-
{
|
|
144
|
+
{filteredGroupItems.length === 0 && (
|
|
145
|
+
<Stack className={css.filterGroupSearchNotFound}>
|
|
146
|
+
<p>{I18N.CHUNKS_NOT_FOUND}</p>
|
|
147
|
+
<div>
|
|
148
|
+
<button
|
|
149
|
+
type="button"
|
|
150
|
+
onClick={() => setSearch('')}
|
|
151
|
+
className={css.filterGroupSearchNotFoundClear}
|
|
152
|
+
>
|
|
153
|
+
{I18N.CHUNKS_SEARCH_CLEAR}
|
|
154
|
+
</button>
|
|
155
|
+
</div>
|
|
156
|
+
</Stack>
|
|
157
|
+
)}
|
|
158
|
+
{filteredGroupItems.map(({ key: itemKey, ...itemData }) => {
|
|
123
159
|
const id = [groupKey, itemKey].join('.');
|
|
124
160
|
const getOnOnlyClick = () => getOnGroupCheck(false, { [id]: true });
|
|
125
161
|
|
|
@@ -138,29 +174,31 @@ const FilterGroup = (props: FilterGroupProps) => {
|
|
|
138
174
|
);
|
|
139
175
|
})}
|
|
140
176
|
</div>
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
177
|
+
{filteredGroupItems.length !== 0 && (
|
|
178
|
+
<div className={css.filterGroupActions}>
|
|
179
|
+
{areAllGroupItemsChecked ? (
|
|
180
|
+
<MenuItem
|
|
181
|
+
id="clear-all"
|
|
182
|
+
as="button"
|
|
183
|
+
className={menuItemClassName}
|
|
184
|
+
type="button"
|
|
185
|
+
onClick={getOnGroupCheck(false)}
|
|
186
|
+
>
|
|
187
|
+
{I18N.CLEAR}
|
|
188
|
+
</MenuItem>
|
|
189
|
+
) : (
|
|
190
|
+
<MenuItem
|
|
191
|
+
id="clear-all"
|
|
192
|
+
as="button"
|
|
193
|
+
className={menuItemClassName}
|
|
194
|
+
type="button"
|
|
195
|
+
onClick={getOnGroupCheck(true)}
|
|
196
|
+
>
|
|
197
|
+
{I18N.CHECK}
|
|
198
|
+
</MenuItem>
|
|
199
|
+
)}
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
164
202
|
</>
|
|
165
203
|
);
|
|
166
204
|
}}
|
package/src/ui/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { HorizontalBarChart } from './horizontal-bar-chart';
|
|
|
8
8
|
export { HoverCard } from './hover-card';
|
|
9
9
|
export { Icon } from './icon';
|
|
10
10
|
export { Input } from './input';
|
|
11
|
+
export { InputSearch } from './input-search';
|
|
11
12
|
export { Loader } from './loader';
|
|
12
13
|
export { Skeleton } from './skeleton';
|
|
13
14
|
export { Table } from './table';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { getWrapperDecorator } from '../../stories';
|
|
4
|
+
import { Input } from '.';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'UI/Input',
|
|
8
|
+
component: Input,
|
|
9
|
+
decorators: [getWrapperDecorator()],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const Default = () => <Input placeholder="Search" />;
|
|
13
|
+
export const WithSize = () => <Input placeholder="Search" size="small" />;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
|
|
4
|
+
import css from './input.module.css';
|
|
5
|
+
|
|
6
|
+
interface InputProps {
|
|
7
|
+
size?: 'small' | 'medium' | 'large';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Input = (props: InputProps & Omit<React.ComponentProps<'input'>, 'size'>) => {
|
|
11
|
+
const { className = '', size = 'medium', ...restProps } = props;
|
|
12
|
+
|
|
13
|
+
const rootClassName = cx(css.root, className, css[size]);
|
|
14
|
+
|
|
15
|
+
return <input className={rootClassName} {...restProps} />;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input-search';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import noop from 'lodash/noop';
|
|
5
|
+
|
|
6
|
+
import { Icon } from '../icon';
|
|
7
|
+
import { Input } from '../input';
|
|
8
|
+
|
|
9
|
+
import css from './input-search.module.css';
|
|
10
|
+
|
|
11
|
+
interface InputSearchProps {
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
onChange?: (newValue: string) => void;
|
|
15
|
+
debounceWait?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const InputSearch = (
|
|
19
|
+
props: InputSearchProps & Omit<React.ComponentProps<'div'>, 'onChange'>,
|
|
20
|
+
) => {
|
|
21
|
+
const {
|
|
22
|
+
className = '',
|
|
23
|
+
placeholder = 'Search',
|
|
24
|
+
defaultValue = '',
|
|
25
|
+
onChange = noop,
|
|
26
|
+
debounceWait = 500,
|
|
27
|
+
} = props;
|
|
28
|
+
const rootClassname = cx(css.root, className);
|
|
29
|
+
|
|
30
|
+
const [value, setValue] = useState(defaultValue);
|
|
31
|
+
|
|
32
|
+
// Update local state when default value changes
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setValue(defaultValue);
|
|
35
|
+
}, [defaultValue]);
|
|
36
|
+
|
|
37
|
+
const debouncedUpdateSearch = useCallback(debounce(onChange, debounceWait), [onChange]);
|
|
38
|
+
|
|
39
|
+
const changeValue = useCallback(
|
|
40
|
+
(newValue: string) => {
|
|
41
|
+
if (newValue !== value) {
|
|
42
|
+
debouncedUpdateSearch(newValue);
|
|
43
|
+
setValue(newValue);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[setValue, value],
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const inputOnChange = useCallback(
|
|
50
|
+
(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
51
|
+
changeValue(event.target.value);
|
|
52
|
+
},
|
|
53
|
+
[changeValue],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const clearButtonOnClick = useCallback(() => {
|
|
57
|
+
changeValue('');
|
|
58
|
+
}, [changeValue]);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className={rootClassname}>
|
|
62
|
+
<Input
|
|
63
|
+
className={css.input}
|
|
64
|
+
placeholder={placeholder}
|
|
65
|
+
onChange={inputOnChange}
|
|
66
|
+
value={value}
|
|
67
|
+
size="small"
|
|
68
|
+
autoComplete="off"
|
|
69
|
+
/>
|
|
70
|
+
{value && (
|
|
71
|
+
<button
|
|
72
|
+
className={css.cancelButton}
|
|
73
|
+
type="button"
|
|
74
|
+
onClick={clearButtonOnClick}
|
|
75
|
+
aria-label="Clear search"
|
|
76
|
+
>
|
|
77
|
+
<Icon className={css.cancelButtonIcon} glyph={Icon.ICONS.CANCEL} />
|
|
78
|
+
</button>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
@@ -14,7 +14,6 @@ export { LighthouseTable } from "./lighthouse-table";
|
|
|
14
14
|
export { Metric } from "./metric";
|
|
15
15
|
export { MetricsTable } from "./metrics-table";
|
|
16
16
|
export { MetricsTableOptions } from "./metrics-table-options";
|
|
17
|
-
export { MetricsTableSearch } from "./metrics-table-search";
|
|
18
17
|
export { MetricsTableTitle } from "./metrics-table-title";
|
|
19
18
|
export { ModuleInfo } from "./module-info";
|
|
20
19
|
export { Summary } from "./summary";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const BASELINE_TITLE = "Baseline";
|
|
2
2
|
export declare const CURRENT_TITLE = "Current";
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const SORT_PERCENTUAL_CHANGE = "
|
|
3
|
+
export declare const SORT_VALUE = "value";
|
|
4
|
+
export declare const SORT_CHANGE = "change";
|
|
5
|
+
export declare const SORT_PERCENTUAL_CHANGE = "percentual change";
|
|
6
6
|
export declare const EMPTY_MESSAGE = "No items found.";
|
|
7
7
|
export declare const SHOW_ALL = "Show all";
|
|
8
8
|
export declare const SHOW_LESS = "Show less";
|
|
@@ -6,7 +6,7 @@ interface UseRowsSortParams {
|
|
|
6
6
|
initialDirection?: SortAction['direction'];
|
|
7
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;
|
package/types/ui/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { HorizontalBarChart } from "./horizontal-bar-chart";
|
|
|
8
8
|
export { HoverCard } from "./hover-card";
|
|
9
9
|
export { Icon } from "./icon";
|
|
10
10
|
export { Input } from "./input";
|
|
11
|
+
export { InputSearch } from "./input-search";
|
|
11
12
|
export { Loader } from "./loader";
|
|
12
13
|
export { Skeleton } from "./skeleton";
|
|
13
14
|
export { Table } from "./table";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './input';
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
export function Input({ className, size, ...restProps }: {
|
|
2
|
-
[x: string]: any;
|
|
3
|
-
className: any;
|
|
4
|
-
size: any;
|
|
5
|
-
}): React.JSX.Element;
|
|
6
|
-
export namespace Input {
|
|
7
|
-
namespace propTypes {
|
|
8
|
-
let className: PropTypes.Requireable<string>;
|
|
9
|
-
let size: PropTypes.Requireable<string>;
|
|
10
|
-
}
|
|
11
|
-
namespace defaultProps {
|
|
12
|
-
let className_1: string;
|
|
13
|
-
export { className_1 as className };
|
|
14
|
-
let size_1: string;
|
|
15
|
-
export { size_1 as size };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
1
|
import React from 'react';
|
|
19
|
-
|
|
2
|
+
interface InputProps {
|
|
3
|
+
size?: 'small' | 'medium' | 'large';
|
|
4
|
+
}
|
|
5
|
+
export declare const Input: (props: InputProps & Omit<React.ComponentProps<'input'>, 'size'>) => React.JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input-search';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface InputSearchProps {
|
|
3
|
+
placeholder?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
onChange?: (newValue: string) => void;
|
|
6
|
+
debounceWait?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const InputSearch: (props: InputSearchProps & Omit<React.ComponentProps<'div'>, 'onChange'>) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/metrics-table-search/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.MetricsTableSearch = void 0;
|
|
30
|
-
const react_1 = __importStar(require("react"));
|
|
31
|
-
const prop_types_1 = __importDefault(require("prop-types"));
|
|
32
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
33
|
-
const debounce_1 = __importDefault(require("lodash/debounce"));
|
|
34
|
-
const icon_1 = require("../../ui/icon");
|
|
35
|
-
const input_1 = require("../../ui/input");
|
|
36
|
-
const metrics_table_search_module_css_1 = __importDefault(require("./metrics-table-search.module.css"));
|
|
37
|
-
const MetricsTableSearch = (props) => {
|
|
38
|
-
const { className, placeholder, search, updateSearch } = props;
|
|
39
|
-
const rootClassname = (0, classnames_1.default)(metrics_table_search_module_css_1.default.root, className);
|
|
40
|
-
const [value, setValue] = (0, react_1.useState)(search);
|
|
41
|
-
(0, react_1.useEffect)(() => {
|
|
42
|
-
setValue(search);
|
|
43
|
-
}, [search]);
|
|
44
|
-
const debouncedUpdateSearch = (0, react_1.useCallback)((0, debounce_1.default)(updateSearch, 500), []);
|
|
45
|
-
const handleChangeValue = (0, react_1.useCallback)((event) => {
|
|
46
|
-
const newValue = event.target.value;
|
|
47
|
-
setValue(newValue);
|
|
48
|
-
if (newValue !== search) {
|
|
49
|
-
debouncedUpdateSearch(newValue);
|
|
50
|
-
}
|
|
51
|
-
}, [search]);
|
|
52
|
-
const handleClearValue = (0, react_1.useCallback)(() => {
|
|
53
|
-
const newValue = '';
|
|
54
|
-
setValue(newValue);
|
|
55
|
-
updateSearch(newValue);
|
|
56
|
-
}, []);
|
|
57
|
-
return (react_1.default.createElement("div", { className: rootClassname },
|
|
58
|
-
react_1.default.createElement(input_1.Input, { className: metrics_table_search_module_css_1.default.input, placeholder: placeholder, onChange: handleChangeValue, value: value, size: "small", autoComplete: "off" }),
|
|
59
|
-
search && (react_1.default.createElement("button", { className: metrics_table_search_module_css_1.default.cancelButton, type: "button", onClick: handleClearValue },
|
|
60
|
-
react_1.default.createElement(icon_1.Icon, { className: metrics_table_search_module_css_1.default.cancelButtonIcon, glyph: icon_1.Icon.ICONS.CANCEL })))));
|
|
61
|
-
};
|
|
62
|
-
exports.MetricsTableSearch = MetricsTableSearch;
|
|
63
|
-
exports.MetricsTableSearch.propTypes = {
|
|
64
|
-
className: prop_types_1.default.string,
|
|
65
|
-
placeholder: prop_types_1.default.string,
|
|
66
|
-
search: prop_types_1.default.string.isRequired,
|
|
67
|
-
updateSearch: prop_types_1.default.func.isRequired,
|
|
68
|
-
};
|
|
69
|
-
exports.MetricsTableSearch.defaultProps = {
|
|
70
|
-
className: '',
|
|
71
|
-
placeholder: '',
|
|
72
|
-
};
|
|
73
|
-
//# sourceMappingURL=metrics-table-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metrics-table-search.js","sourceRoot":"","sources":["../../../src/components/metrics-table-search/metrics-table-search.jsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgE;AAChE,4DAAmC;AACnC,4DAA4B;AAC5B,+DAAuC;AAEvC,wCAAqC;AACrC,0CAAuC;AAEvC,wGAAoD;AAE7C,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,EAAE;IAC1C,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,aAAa,GAAG,IAAA,oBAAE,EAAC,yCAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAE9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAC,MAAM,CAAC,CAAC;IAG3C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,qBAAqB,GAAG,IAAA,mBAAW,EAAC,IAAA,kBAAQ,EAAC,YAAY,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAE3E,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EACnC,CAAC,KAAK,EAAE,EAAE;QACR,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACpC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAGnB,IAAI,QAAQ,KAAK,MAAM,EAAE;YACvB,qBAAqB,CAAC,QAAQ,CAAC,CAAC;SACjC;IACH,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QACxC,MAAM,QAAQ,GAAG,EAAE,CAAC;QACpB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,YAAY,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,uCAAK,SAAS,EAAE,aAAa;QAC3B,8BAAC,aAAK,IACJ,SAAS,EAAE,yCAAG,CAAC,KAAK,EACpB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAC,OAAO,EACZ,YAAY,EAAC,KAAK,GAClB;QACD,MAAM,IAAI,CACT,0CAAQ,SAAS,EAAE,yCAAG,CAAC,YAAY,EAAE,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,gBAAgB;YAC1E,8BAAC,WAAI,IAAC,SAAS,EAAE,yCAAG,CAAC,gBAAgB,EAAE,KAAK,EAAE,WAAI,CAAC,KAAK,CAAC,MAAM,GAAI,CAC5D,CACV,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAjDW,QAAA,kBAAkB,sBAiD7B;AAEF,0BAAkB,CAAC,SAAS,GAAG;IAC7B,SAAS,EAAE,oBAAS,CAAC,MAAM;IAC3B,WAAW,EAAE,oBAAS,CAAC,MAAM;IAC7B,MAAM,EAAE,oBAAS,CAAC,MAAM,CAAC,UAAU;IACnC,YAAY,EAAE,oBAAS,CAAC,IAAI,CAAC,UAAU;CACxC,CAAC;AAEF,0BAAkB,CAAC,YAAY,GAAG;IAChC,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,EAAE;CAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/metrics-table-search/index.js"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|