@bundle-stats/ui 4.13.0-beta.7 → 4.13.0-beta.9
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-modules/bundle-modules.js +2 -1
- package/lib/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib/components/metrics-display-selector/metrics-display-selector.js +2 -2
- package/lib/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
- package/lib/components/metrics-table-header/metrics-table-header.js +7 -7
- package/lib/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib/components/metrics-table-header/metrics-table-header.module.css +11 -4
- package/lib/components/metrics-table-options/metrics-table-options.js +2 -2
- package/lib/components/metrics-table-options/metrics-table-options.js.map +1 -1
- package/lib/components/metrics-table-title/metrics-table-title.js +1 -1
- package/lib/components/metrics-table-title/metrics-table-title.js.map +1 -1
- package/lib/components/metrics-table-title/metrics-table-title.module.css +1 -0
- package/lib/components/metrics-treemap/metrics-treemap.js +8 -10
- package/lib/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.module.css +14 -16
- package/lib/ui/dropdown/dropdown.js +9 -39
- package/lib/ui/dropdown/dropdown.js.map +1 -1
- package/lib/ui/dropdown/index.js.map +1 -1
- package/lib/ui/filters/filters.js +32 -34
- package/lib/ui/filters/filters.js.map +1 -1
- package/lib/ui/filters/filters.module.css +48 -67
- package/lib-esm/components/bundle-modules/bundle-modules.js +2 -1
- package/lib-esm/components/bundle-modules/bundle-modules.js.map +1 -1
- package/lib-esm/components/metrics-display-selector/metrics-display-selector.js +2 -2
- package/lib-esm/components/metrics-display-selector/metrics-display-selector.js.map +1 -1
- package/lib-esm/components/metrics-table-header/metrics-table-header.js +7 -7
- package/lib-esm/components/metrics-table-header/metrics-table-header.js.map +1 -1
- package/lib-esm/components/metrics-table-header/metrics-table-header.module.css +11 -4
- package/lib-esm/components/metrics-table-options/metrics-table-options.js +3 -3
- package/lib-esm/components/metrics-table-options/metrics-table-options.js.map +1 -1
- package/lib-esm/components/metrics-table-title/metrics-table-title.js +1 -1
- package/lib-esm/components/metrics-table-title/metrics-table-title.js.map +1 -1
- package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +1 -0
- package/lib-esm/components/metrics-treemap/metrics-treemap.js +8 -10
- package/lib-esm/components/metrics-treemap/metrics-treemap.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.module.css +14 -16
- package/lib-esm/ui/dropdown/dropdown.js +7 -38
- package/lib-esm/ui/dropdown/dropdown.js.map +1 -1
- package/lib-esm/ui/dropdown/index.js.map +1 -1
- package/lib-esm/ui/filters/filters.js +33 -35
- package/lib-esm/ui/filters/filters.js.map +1 -1
- package/lib-esm/ui/filters/filters.module.css +48 -67
- package/package.json +5 -5
- package/src/components/bundle-modules/bundle-modules.tsx +3 -2
- package/src/components/metrics-display-selector/metrics-display-selector.tsx +4 -4
- package/src/components/metrics-table-header/metrics-table-header.module.css +11 -4
- package/src/components/metrics-table-header/metrics-table-header.tsx +7 -7
- package/src/components/metrics-table-options/metrics-table-options.jsx +4 -10
- package/src/components/metrics-table-title/metrics-table-title.jsx +1 -1
- package/src/components/metrics-table-title/metrics-table-title.module.css +1 -0
- package/src/components/metrics-treemap/metrics-treemap.module.css +14 -16
- package/src/components/metrics-treemap/metrics-treemap.tsx +31 -31
- package/src/ui/dropdown/dropdown.stories.tsx +25 -0
- package/src/ui/dropdown/dropdown.tsx +67 -0
- package/src/ui/filters/filters.module.css +48 -67
- package/src/ui/filters/filters.stories.tsx +109 -0
- package/src/ui/filters/filters.tsx +128 -166
- package/types/components/metrics-display-selector/metrics-display-selector.d.ts +2 -2
- package/types/ui/dropdown/dropdown.d.ts +13 -47
- package/types/ui/dropdown/index.d.ts +1 -1
- package/types/ui/filters/filters.d.ts +2 -7
- package/src/ui/dropdown/dropdown.jsx +0 -88
- /package/src/ui/dropdown/{index.js → index.ts} +0 -0
|
@@ -5,85 +5,51 @@ import type { FilterFieldsData, FilterGroupFieldData } from '../../types';
|
|
|
5
5
|
import { FlexStack } from '../../layout/flex-stack';
|
|
6
6
|
import { Stack } from '../../layout/stack';
|
|
7
7
|
import { Button } from '../button';
|
|
8
|
-
import {
|
|
8
|
+
import { ControlGroup } from '../control-group';
|
|
9
|
+
import { Dropdown, DropdownItem } from '../dropdown';
|
|
9
10
|
import { InputSearch } from '../input-search';
|
|
10
11
|
import * as I18N from './filters.i18n';
|
|
11
12
|
import { getGroupFiltersLabelSuffix, LABELS } from './filters.utils';
|
|
12
13
|
import css from './filters.module.css';
|
|
13
14
|
|
|
14
|
-
interface
|
|
15
|
-
as?: React.ElementType;
|
|
16
|
-
buttonClassName?: string;
|
|
15
|
+
interface FilterBooleanProps extends React.ComponentProps<'input'> {
|
|
17
16
|
label: string;
|
|
18
|
-
name: string;
|
|
19
|
-
getOnOnlyClick?: (name: string) => () => void;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
const Filter = (props:
|
|
23
|
-
const {
|
|
24
|
-
className = '',
|
|
25
|
-
as: Component = 'div',
|
|
26
|
-
buttonClassName = '',
|
|
27
|
-
label,
|
|
28
|
-
name,
|
|
29
|
-
getOnOnlyClick,
|
|
30
|
-
...inputProps
|
|
31
|
-
} = props;
|
|
32
|
-
|
|
33
|
-
const id = `filter-${name}`;
|
|
34
|
-
const rootClassName = cx(css.filter, className);
|
|
19
|
+
const Filter = (props: FilterBooleanProps) => {
|
|
20
|
+
const { className = '', label, name, ...inputProps } = props;
|
|
35
21
|
|
|
36
22
|
return (
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
kind="info"
|
|
55
|
-
solid
|
|
56
|
-
size="small"
|
|
57
|
-
type="button"
|
|
58
|
-
onClick={getOnOnlyClick(name)}
|
|
59
|
-
className={css.filterOnlyButton}
|
|
60
|
-
>
|
|
61
|
-
{I18N.ONLY}
|
|
62
|
-
</Button>
|
|
63
|
-
)}
|
|
64
|
-
</Component>
|
|
23
|
+
<FlexStack
|
|
24
|
+
space="xxxsmall"
|
|
25
|
+
alignItems="center"
|
|
26
|
+
as="label"
|
|
27
|
+
className={cx(css.filter, className)}
|
|
28
|
+
>
|
|
29
|
+
<input
|
|
30
|
+
type="checkbox"
|
|
31
|
+
id={`filter-${name}`}
|
|
32
|
+
name={name}
|
|
33
|
+
{...inputProps}
|
|
34
|
+
className={css.filterControl}
|
|
35
|
+
/>
|
|
36
|
+
<span title={label} className={css.filterLabel}>
|
|
37
|
+
{label}
|
|
38
|
+
</span>
|
|
39
|
+
</FlexStack>
|
|
65
40
|
);
|
|
66
41
|
};
|
|
67
42
|
|
|
68
43
|
interface FilterGroupProps extends React.ComponentProps<'div'> {
|
|
69
|
-
buttonClassName?: string;
|
|
70
44
|
groupKey: string;
|
|
71
45
|
data: FilterGroupFieldData;
|
|
72
46
|
values: Record<string, boolean>;
|
|
73
|
-
onCheckboxChange:
|
|
47
|
+
onCheckboxChange: FilterBooleanProps['onChange'];
|
|
74
48
|
toggleFilters: (newFilters: Record<string, boolean>) => void;
|
|
75
49
|
}
|
|
76
50
|
|
|
77
51
|
const FilterGroup = (props: FilterGroupProps) => {
|
|
78
|
-
const {
|
|
79
|
-
className = '',
|
|
80
|
-
buttonClassName = '',
|
|
81
|
-
groupKey,
|
|
82
|
-
data,
|
|
83
|
-
values,
|
|
84
|
-
onCheckboxChange,
|
|
85
|
-
toggleFilters,
|
|
86
|
-
} = props;
|
|
52
|
+
const { className = '', groupKey, data, values, onCheckboxChange, toggleFilters } = props;
|
|
87
53
|
|
|
88
54
|
const [search, setSearch] = useState('');
|
|
89
55
|
|
|
@@ -99,7 +65,9 @@ const FilterGroup = (props: FilterGroupProps) => {
|
|
|
99
65
|
<>
|
|
100
66
|
{`${groupLabel}:`}
|
|
101
67
|
|
|
102
|
-
<span className={cx(hasCustomFilterSuffix && css.
|
|
68
|
+
<span className={cx(hasCustomFilterSuffix && css.filterGroupLabelSuffixCustom)}>
|
|
69
|
+
{filterSuffix}
|
|
70
|
+
</span>
|
|
103
71
|
</>
|
|
104
72
|
);
|
|
105
73
|
|
|
@@ -130,88 +98,79 @@ const FilterGroup = (props: FilterGroupProps) => {
|
|
|
130
98
|
|
|
131
99
|
return (
|
|
132
100
|
<Dropdown
|
|
133
|
-
|
|
134
|
-
buttonClassName={buttonClassName}
|
|
101
|
+
buttonClassName={className}
|
|
135
102
|
label={dropdownLabel}
|
|
136
103
|
ariaLabel={`${groupLabel}: ${filterSuffix}`}
|
|
137
104
|
>
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
>
|
|
163
|
-
{I18N.GROUP_SEARCH_CLEAR}
|
|
164
|
-
</Button>
|
|
165
|
-
</div>
|
|
166
|
-
</Stack>
|
|
167
|
-
)}
|
|
168
|
-
{filteredGroupItems.map(({ key: itemKey, ...itemData }) => {
|
|
169
|
-
const id = [groupKey, itemKey].join('.');
|
|
170
|
-
const getOnOnlyClick = () => getOnGroupCheck(false, { [id]: true });
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<Filter
|
|
174
|
-
key={id}
|
|
175
|
-
className={menuItemClassName}
|
|
176
|
-
as={MenuItem}
|
|
177
|
-
name={id}
|
|
178
|
-
label={itemData.label}
|
|
179
|
-
onChange={onCheckboxChange}
|
|
180
|
-
checked={values[id]}
|
|
181
|
-
disabled={itemData.disabled}
|
|
182
|
-
getOnOnlyClick={getOnOnlyClick}
|
|
183
|
-
/>
|
|
184
|
-
);
|
|
185
|
-
})}
|
|
105
|
+
{groupItems.length > 10 && (
|
|
106
|
+
<div className={css.filterGroupSearchWrapper}>
|
|
107
|
+
<InputSearch
|
|
108
|
+
defaultValue={search}
|
|
109
|
+
onChange={setSearch}
|
|
110
|
+
placeholder={I18N.GROUP_SEARCH}
|
|
111
|
+
debounceWait={0}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
<div className={css.filterGroupItems}>
|
|
116
|
+
{filteredGroupItems.length === 0 && (
|
|
117
|
+
<Stack className={css.filterGroupSearchNotFound}>
|
|
118
|
+
<p>{I18N.GROUP_NOT_FOUND}</p>
|
|
119
|
+
<div>
|
|
120
|
+
<Button
|
|
121
|
+
size="small"
|
|
122
|
+
kind="primary"
|
|
123
|
+
type="button"
|
|
124
|
+
onClick={() => setSearch('')}
|
|
125
|
+
className={css.filterGroupSearchNotFoundClear}
|
|
126
|
+
>
|
|
127
|
+
{I18N.GROUP_SEARCH_CLEAR}
|
|
128
|
+
</Button>
|
|
186
129
|
</div>
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
130
|
+
</Stack>
|
|
131
|
+
)}
|
|
132
|
+
{filteredGroupItems.map(({ key: itemKey, ...itemData }) => {
|
|
133
|
+
const id = [groupKey, itemKey].join('.');
|
|
134
|
+
const getOnOnlyClick = () => getOnGroupCheck(false, { [id]: true });
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<DropdownItem key={id} className={css.filterGroupItem}>
|
|
138
|
+
<Filter
|
|
139
|
+
label={itemData.label}
|
|
140
|
+
name={id}
|
|
141
|
+
onChange={onCheckboxChange}
|
|
142
|
+
checked={values[id]}
|
|
143
|
+
disabled={itemData.disabled}
|
|
144
|
+
className={css.filterGroupItemFilter}
|
|
145
|
+
/>
|
|
146
|
+
<Button
|
|
147
|
+
kind="info"
|
|
148
|
+
solid
|
|
149
|
+
size="small"
|
|
150
|
+
type="button"
|
|
151
|
+
onClick={getOnOnlyClick()}
|
|
152
|
+
disabled={itemData.disabled}
|
|
153
|
+
className={css.filterGroupOnlyButton}
|
|
154
|
+
>
|
|
155
|
+
{I18N.ONLY}
|
|
156
|
+
</Button>
|
|
157
|
+
</DropdownItem>
|
|
158
|
+
);
|
|
159
|
+
})}
|
|
160
|
+
</div>
|
|
161
|
+
{filteredGroupItems.length !== 0 && (
|
|
162
|
+
<div className={css.filterGroupActions}>
|
|
163
|
+
{areAllGroupItemsChecked ? (
|
|
164
|
+
<DropdownItem id="clear-all" onClick={getOnGroupCheck(false)} role="button">
|
|
165
|
+
{I18N.CLEAR}
|
|
166
|
+
</DropdownItem>
|
|
167
|
+
) : (
|
|
168
|
+
<DropdownItem id="clear-all" onClick={getOnGroupCheck(true)} role="button">
|
|
169
|
+
{I18N.CHECK}
|
|
170
|
+
</DropdownItem>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
215
174
|
</Dropdown>
|
|
216
175
|
);
|
|
217
176
|
};
|
|
@@ -226,6 +185,9 @@ interface FiltersProps extends React.ComponentProps<'div'> {
|
|
|
226
185
|
export const Filters = (props: FiltersProps) => {
|
|
227
186
|
const { className = '', values, filters, toggleFilter, toggleFilters } = props;
|
|
228
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Toggle filter value on checkbox change
|
|
190
|
+
*/
|
|
229
191
|
const onCheckboxChange = useCallback(
|
|
230
192
|
(event: any) => {
|
|
231
193
|
const { name } = event.target;
|
|
@@ -233,41 +195,41 @@ export const Filters = (props: FiltersProps) => {
|
|
|
233
195
|
},
|
|
234
196
|
[toggleFilter, values],
|
|
235
197
|
);
|
|
236
|
-
|
|
198
|
+
|
|
199
|
+
const filterList = Object.entries(filters);
|
|
200
|
+
const filterCount = filterList.length;
|
|
237
201
|
|
|
238
202
|
return (
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if ('defaultValue' in data) {
|
|
243
|
-
return (
|
|
244
|
-
<Filter
|
|
245
|
-
key={name}
|
|
246
|
-
className={cx(css.item, css.filterStandalone)}
|
|
247
|
-
buttonClassName={css.itemButton}
|
|
248
|
-
name={name}
|
|
249
|
-
label={data.label}
|
|
250
|
-
onChange={onCheckboxChange}
|
|
251
|
-
checked={values[name]}
|
|
252
|
-
disabled={data.disabled as boolean}
|
|
253
|
-
/>
|
|
254
|
-
);
|
|
255
|
-
}
|
|
203
|
+
<ControlGroup className={cx(css.root, className)}>
|
|
204
|
+
{filterList.map(([name, data], index) => {
|
|
205
|
+
const lastItem = index === filterCount - 1;
|
|
256
206
|
|
|
207
|
+
if ('defaultValue' in data) {
|
|
257
208
|
return (
|
|
258
|
-
<
|
|
259
|
-
|
|
260
|
-
|
|
209
|
+
<Filter
|
|
210
|
+
name={name}
|
|
211
|
+
label={data.label}
|
|
212
|
+
onChange={onCheckboxChange}
|
|
213
|
+
checked={values[name]}
|
|
214
|
+
disabled={data.disabled as boolean}
|
|
261
215
|
key={name}
|
|
262
|
-
|
|
263
|
-
data={data}
|
|
264
|
-
values={values}
|
|
265
|
-
onCheckboxChange={onCheckboxChange}
|
|
266
|
-
toggleFilters={toggleFilters}
|
|
216
|
+
className={cx(css.filterSingle, lastItem && css.itemLast)}
|
|
267
217
|
/>
|
|
268
218
|
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<FilterGroup
|
|
223
|
+
groupKey={name}
|
|
224
|
+
data={data}
|
|
225
|
+
values={values}
|
|
226
|
+
onCheckboxChange={onCheckboxChange}
|
|
227
|
+
toggleFilters={toggleFilters}
|
|
228
|
+
className={cx(lastItem && css.itemLast)}
|
|
229
|
+
key={name}
|
|
230
|
+
/>
|
|
231
|
+
);
|
|
232
|
+
})}
|
|
233
|
+
</ControlGroup>
|
|
272
234
|
);
|
|
273
235
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MetricsDisplayType } from '../../constants';
|
|
3
|
-
import {
|
|
3
|
+
import { ControlGroup } from '../../ui/control-group';
|
|
4
4
|
interface MetricsDisplaySelectorProps {
|
|
5
5
|
value: MetricsDisplayType;
|
|
6
6
|
onSelect: (newValue: MetricsDisplayType) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const MetricsDisplaySelector: (props: MetricsDisplaySelectorProps & Omit<React.ComponentProps<typeof
|
|
8
|
+
export declare const MetricsDisplaySelector: (props: MetricsDisplaySelectorProps & Omit<React.ComponentProps<typeof ControlGroup>, 'onSelect' | 'value'>) => React.JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,50 +1,16 @@
|
|
|
1
|
-
export function Dropdown(props: any): React.JSX.Element;
|
|
2
|
-
export namespace Dropdown {
|
|
3
|
-
export namespace defaultProps {
|
|
4
|
-
let className: string;
|
|
5
|
-
let buttonClassName: string;
|
|
6
|
-
let label: null;
|
|
7
|
-
let ariaLabel: string;
|
|
8
|
-
let glyph: null;
|
|
9
|
-
let disabled: boolean;
|
|
10
|
-
}
|
|
11
|
-
export namespace propTypes {
|
|
12
|
-
let className_1: PropTypes.Requireable<string>;
|
|
13
|
-
export { className_1 as className };
|
|
14
|
-
let buttonClassName_1: PropTypes.Requireable<string>;
|
|
15
|
-
export { buttonClassName_1 as buttonClassName };
|
|
16
|
-
let label_1: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
17
|
-
export { label_1 as label };
|
|
18
|
-
let ariaLabel_1: PropTypes.Requireable<string>;
|
|
19
|
-
export { ariaLabel_1 as ariaLabel };
|
|
20
|
-
let glyph_1: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
21
|
-
export { glyph_1 as glyph };
|
|
22
|
-
let disabled_1: PropTypes.Requireable<boolean>;
|
|
23
|
-
export { disabled_1 as disabled };
|
|
24
|
-
export let children: PropTypes.Validator<NonNullable<NonNullable<string | PropTypes.ReactElementLike | ((...args: any[]) => any) | null | undefined>>>;
|
|
25
|
-
}
|
|
26
|
-
export { Item };
|
|
27
|
-
}
|
|
28
1
|
import React from 'react';
|
|
29
|
-
import
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export { propTypes_1 as propTypes };
|
|
42
|
-
export namespace defaultProps_1 {
|
|
43
|
-
let className_3: string;
|
|
44
|
-
export { className_3 as className };
|
|
45
|
-
let isActive_1: boolean;
|
|
46
|
-
export { isActive_1 as isActive };
|
|
47
|
-
}
|
|
48
|
-
export { defaultProps_1 as defaultProps };
|
|
2
|
+
import { MenuItem } from 'ariakit/menu';
|
|
3
|
+
interface DropdownItemProps {
|
|
4
|
+
isActive?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const DropdownItem: (props: DropdownItemProps & React.ComponentProps<typeof MenuItem>) => React.JSX.Element;
|
|
7
|
+
interface DropdownProps {
|
|
8
|
+
buttonClassName?: string;
|
|
9
|
+
dropdownClassName?: string;
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
ariaLabel?: string;
|
|
12
|
+
glyph?: string;
|
|
13
|
+
disabled?: boolean;
|
|
49
14
|
}
|
|
15
|
+
export declare const Dropdown: (props: DropdownProps & React.ComponentProps<'div'>) => React.JSX.Element;
|
|
50
16
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './dropdown';
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FilterFieldsData, FilterGroupFieldData } from '../../types';
|
|
3
|
-
interface
|
|
4
|
-
as?: React.ElementType;
|
|
5
|
-
buttonClassName?: string;
|
|
3
|
+
interface FilterBooleanProps extends React.ComponentProps<'input'> {
|
|
6
4
|
label: string;
|
|
7
|
-
name: string;
|
|
8
|
-
getOnOnlyClick?: (name: string) => () => void;
|
|
9
5
|
}
|
|
10
6
|
interface FilterGroupProps extends React.ComponentProps<'div'> {
|
|
11
|
-
buttonClassName?: string;
|
|
12
7
|
groupKey: string;
|
|
13
8
|
data: FilterGroupFieldData;
|
|
14
9
|
values: Record<string, boolean>;
|
|
15
|
-
onCheckboxChange:
|
|
10
|
+
onCheckboxChange: FilterBooleanProps['onChange'];
|
|
16
11
|
toggleFilters: (newFilters: Record<string, boolean>) => void;
|
|
17
12
|
}
|
|
18
13
|
interface FiltersProps extends React.ComponentProps<'div'> {
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu';
|
|
5
|
-
|
|
6
|
-
import { Button, BUTTON_SIZE } from '../button';
|
|
7
|
-
import css from './dropdown.module.css';
|
|
8
|
-
|
|
9
|
-
const Item = ({ className = '', isActive = false, ...restProps }) => (
|
|
10
|
-
<MenuItem className={cx(css.item, className, isActive && css.itemActive)} {...restProps} />
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
Item.propTypes = {
|
|
14
|
-
className: PropTypes.string,
|
|
15
|
-
isActive: PropTypes.bool,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
Item.defaultProps = {
|
|
19
|
-
className: '',
|
|
20
|
-
isActive: false,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const Dropdown = (props) => {
|
|
24
|
-
const { className, buttonClassName, label, ariaLabel, glyph, disabled, children } = props;
|
|
25
|
-
const rootClassName = cx(css.root, className);
|
|
26
|
-
const menuState = useMenuState();
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div className={rootClassName}>
|
|
30
|
-
<MenuButton
|
|
31
|
-
as={Button}
|
|
32
|
-
outline
|
|
33
|
-
size={BUTTON_SIZE.SMALL}
|
|
34
|
-
glyph={glyph}
|
|
35
|
-
disabled={disabled}
|
|
36
|
-
state={menuState}
|
|
37
|
-
tabIndex={null}
|
|
38
|
-
className={cx(css.button, buttonClassName)}
|
|
39
|
-
>
|
|
40
|
-
{label}
|
|
41
|
-
</MenuButton>
|
|
42
|
-
<Menu state={menuState} aria-label={ariaLabel || label} className={css.dropdown}>
|
|
43
|
-
{typeof children === 'function'
|
|
44
|
-
? children({
|
|
45
|
-
MenuItem: Item,
|
|
46
|
-
menu: menuState,
|
|
47
|
-
menuItemClassName: css.item,
|
|
48
|
-
menuItemActiveClassName: css.itemActive,
|
|
49
|
-
})
|
|
50
|
-
: children}
|
|
51
|
-
</Menu>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
Dropdown.defaultProps = {
|
|
57
|
-
className: '',
|
|
58
|
-
buttonClassName: '',
|
|
59
|
-
label: null,
|
|
60
|
-
ariaLabel: '',
|
|
61
|
-
glyph: null,
|
|
62
|
-
disabled: false,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
Dropdown.propTypes = {
|
|
66
|
-
/** Adopted child class name */
|
|
67
|
-
className: PropTypes.string,
|
|
68
|
-
|
|
69
|
-
/** Button adopted child class name */
|
|
70
|
-
buttonClassName: PropTypes.string,
|
|
71
|
-
|
|
72
|
-
/** Button label */
|
|
73
|
-
label: PropTypes.node,
|
|
74
|
-
|
|
75
|
-
/** Aria label */
|
|
76
|
-
ariaLabel: PropTypes.string,
|
|
77
|
-
|
|
78
|
-
/** Icon glyph */
|
|
79
|
-
glyph: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
80
|
-
|
|
81
|
-
/** Dropdown button disabled attribute */
|
|
82
|
-
disabled: PropTypes.bool,
|
|
83
|
-
|
|
84
|
-
/** Content */
|
|
85
|
-
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
Dropdown.Item = Item;
|
|
File without changes
|