@bundle-stats/ui 3.3.0-alpha.1 → 3.3.1-beta.8
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/CHANGELOG.md +65 -13
- package/build-storybook.log +4691 -0
- package/lib/app/app.js +137 -102
- package/lib/app/app.module.css +11 -4
- package/lib/app/header/header.js +1 -10
- package/lib/components/asset-info/asset-info.module.css +1 -0
- package/lib/components/bundle-assets/bundle-assets.js +104 -52
- package/lib/components/bundle-assets/bundle-assets.module.css +24 -26
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +13 -3
- package/lib/components/bundle-modules/bundle-modules.js +68 -68
- package/lib/components/bundle-modules/bundle-modules.module.css +11 -2
- package/lib/components/bundle-modules/bundle-modules.utils.js +14 -10
- package/lib/components/bundle-modules/index.js +4 -4
- package/lib/components/bundle-packages/bundle-packages.js +100 -44
- package/lib/components/bundle-packages/bundle-packages.module.css +17 -21
- package/lib/components/delta/delta.module.css +1 -0
- package/lib/components/job-header/job-header.js +3 -1
- package/lib/components/job-header/job-header.module.css +6 -8
- package/lib/components/jobs-header/jobs-header.module.css +5 -0
- package/lib/components/metrics-table/metrics-table.js +72 -59
- package/lib/components/metrics-table/metrics-table.module.css +18 -7
- package/lib/components/metrics-table-search/metrics-table-search.module.css +5 -4
- package/lib/components/metrics-table-title/metrics-table-title.js +9 -7
- package/lib/components/metrics-table-title/metrics-table-title.module.css +2 -0
- package/lib/components/module-info/module-info.js +2 -2
- package/lib/components/module-info/module-info.module.css +1 -0
- package/lib/components/summary/summary.js +1 -1
- package/lib/components/summary-item/summary-item.js +15 -18
- package/lib/components/summary-item/summary-item.module.css +1 -23
- package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
- package/lib/constants.js +1 -1
- package/lib/css/default.css +14 -3
- package/lib/css/variables.css +17 -17
- package/lib/hooks/search-params.js +31 -31
- package/lib/layout/box/box.module.css +9 -0
- package/lib/layout/footer/footer.module.css +1 -1
- package/lib/layout/index.js +8 -0
- package/lib/layout/separator.js +48 -0
- package/lib/layout/separator.module.css +5 -0
- package/lib/ui/dropdown/dropdown.js +21 -26
- package/lib/ui/dropdown/dropdown.module.css +11 -12
- package/lib/ui/dropdown/dropdown.stories.js +2 -9
- package/lib/ui/empty-set/empty-set.js +5 -4
- package/lib/ui/empty-set/empty-set.module.css +2 -2
- package/lib/ui/filters/filters.container.js +1 -1
- package/lib/ui/filters/filters.js +22 -7
- package/lib/ui/filters/filters.module.css +3 -3
- package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +1 -1
- package/lib/ui/hover-card/hover-card.js +102 -0
- package/lib/ui/hover-card/hover-card.module.css +29 -0
- package/lib/ui/hover-card/hover-card.stories.js +56 -0
- package/lib/ui/hover-card/index.js +18 -0
- package/lib/ui/icon/icon.js +6 -6
- package/lib/ui/icon/icon.module.css +1 -0
- package/lib/ui/index.js +8 -8
- package/lib/ui/table/table.js +5 -74
- package/lib/ui/table/table.module.css +41 -25
- package/lib/ui/table/table.stories.js +1 -1
- package/lib/ui/{popover → tag}/index.js +4 -4
- package/lib/ui/tag/tag.js +72 -0
- package/lib/ui/tag/tag.module.css +55 -0
- package/lib/ui/tag/tag.stories.js +38 -0
- package/lib/ui/tooltip/tooltip.js +10 -9
- package/lib/ui/tooltip/tooltip.module.css +2 -1
- package/lib-esm/app/app.js +132 -102
- package/lib-esm/app/app.module.css +11 -4
- package/lib-esm/app/header/header.js +1 -9
- package/lib-esm/components/asset-info/asset-info.module.css +1 -0
- package/lib-esm/components/bundle-assets/bundle-assets.js +97 -56
- package/lib-esm/components/bundle-assets/bundle-assets.module.css +24 -26
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +7 -3
- package/lib-esm/components/bundle-modules/bundle-modules.js +50 -51
- package/lib-esm/components/bundle-modules/bundle-modules.module.css +11 -2
- package/lib-esm/components/bundle-modules/bundle-modules.utils.js +14 -6
- package/lib-esm/components/bundle-modules/index.js +5 -3
- package/lib-esm/components/bundle-packages/bundle-packages.js +88 -41
- package/lib-esm/components/bundle-packages/bundle-packages.module.css +17 -21
- package/lib-esm/components/delta/delta.module.css +1 -0
- package/lib-esm/components/job-header/job-header.js +2 -1
- package/lib-esm/components/job-header/job-header.module.css +6 -8
- package/lib-esm/components/jobs-header/jobs-header.module.css +5 -0
- package/lib-esm/components/metrics-table/metrics-table.js +61 -53
- package/lib-esm/components/metrics-table/metrics-table.module.css +18 -7
- package/lib-esm/components/metrics-table-search/metrics-table-search.module.css +5 -4
- package/lib-esm/components/metrics-table-title/metrics-table-title.js +8 -7
- package/lib-esm/components/metrics-table-title/metrics-table-title.module.css +2 -0
- package/lib-esm/components/module-info/module-info.js +2 -2
- package/lib-esm/components/module-info/module-info.module.css +1 -0
- package/lib-esm/components/summary/summary.js +1 -1
- package/lib-esm/components/summary-item/summary-item.js +14 -18
- package/lib-esm/components/summary-item/summary-item.module.css +1 -23
- package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
- package/lib-esm/constants.js +1 -1
- package/lib-esm/css/default.css +14 -3
- package/lib-esm/css/variables.css +17 -17
- package/lib-esm/hooks/search-params.js +27 -28
- package/lib-esm/layout/box/box.module.css +9 -0
- package/lib-esm/layout/footer/footer.module.css +1 -1
- package/lib-esm/layout/index.js +1 -0
- package/lib-esm/layout/separator.js +28 -0
- package/lib-esm/layout/separator.module.css +5 -0
- package/lib-esm/ui/dropdown/dropdown.js +20 -25
- package/lib-esm/ui/dropdown/dropdown.module.css +11 -12
- package/lib-esm/ui/dropdown/dropdown.stories.js +2 -7
- package/lib-esm/ui/empty-set/empty-set.js +4 -4
- package/lib-esm/ui/empty-set/empty-set.module.css +2 -2
- package/lib-esm/ui/filters/filters.js +20 -5
- package/lib-esm/ui/filters/filters.module.css +3 -3
- package/lib-esm/ui/hover-card/hover-card.js +83 -0
- package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
- package/lib-esm/ui/hover-card/hover-card.stories.js +35 -0
- package/lib-esm/ui/hover-card/index.js +1 -0
- package/lib-esm/ui/icon/icon.js +3 -3
- package/lib-esm/ui/icon/icon.module.css +1 -0
- package/lib-esm/ui/index.js +1 -1
- package/lib-esm/ui/table/table.js +5 -65
- package/lib-esm/ui/table/table.module.css +41 -25
- package/lib-esm/ui/table/table.stories.js +1 -1
- package/lib-esm/ui/tag/index.js +1 -0
- package/lib-esm/ui/tag/tag.js +45 -0
- package/lib-esm/ui/tag/tag.module.css +55 -0
- package/lib-esm/ui/tag/tag.stories.js +23 -0
- package/lib-esm/ui/tooltip/tooltip.js +10 -9
- package/lib-esm/ui/tooltip/tooltip.module.css +2 -1
- package/package.json +33 -31
- package/src/app/app.jsx +136 -146
- package/src/app/app.module.css +11 -4
- package/src/app/header/header.jsx +1 -11
- package/src/assets/icons.svg +0 -8
- package/src/components/asset-info/asset-info.module.css +1 -0
- package/src/components/bundle-assets/bundle-assets.jsx +85 -31
- package/src/components/bundle-assets/bundle-assets.module.css +24 -26
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -25
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/src/components/bundle-modules/bundle-modules.jsx +53 -36
- package/src/components/bundle-modules/bundle-modules.module.css +11 -2
- package/src/components/bundle-modules/bundle-modules.utils.js +16 -4
- package/src/components/bundle-modules/index.jsx +3 -0
- package/src/components/bundle-packages/bundle-packages.jsx +89 -39
- package/src/components/bundle-packages/bundle-packages.module.css +17 -21
- package/src/components/delta/delta.module.css +1 -0
- package/src/components/index.js +0 -1
- package/src/components/job-header/job-header.jsx +2 -1
- package/src/components/job-header/job-header.module.css +6 -8
- package/src/components/jobs-header/jobs-header.module.css +5 -0
- package/src/components/metrics-table/metrics-table.jsx +53 -44
- package/src/components/metrics-table/metrics-table.module.css +18 -7
- package/src/components/metrics-table-search/metrics-table-search.module.css +5 -4
- package/src/components/metrics-table-title/metrics-table-title.jsx +20 -21
- package/src/components/metrics-table-title/metrics-table-title.module.css +2 -0
- package/src/components/module-info/module-info.jsx +3 -7
- package/src/components/module-info/module-info.module.css +1 -0
- package/src/components/summary/summary.jsx +7 -8
- package/src/components/summary/summary.module.css +1 -1
- package/src/components/summary-item/summary-item.jsx +23 -40
- package/src/components/summary-item/summary-item.module.css +1 -34
- package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
- package/src/constants.js +11 -7
- package/src/css/default.css +14 -3
- package/src/css/variables.css +17 -17
- package/src/hooks/search-params.js +42 -33
- package/src/layout/box/box.module.css +9 -0
- package/src/layout/footer/footer.module.css +1 -1
- package/src/layout/index.js +1 -0
- package/src/layout/separator.jsx +25 -0
- package/src/layout/separator.module.css +5 -0
- package/src/ui/alert/alert.jsx +2 -7
- package/src/ui/dropdown/dropdown.jsx +16 -22
- package/src/ui/dropdown/dropdown.module.css +11 -12
- package/src/ui/empty-set/empty-set.jsx +25 -21
- package/src/ui/empty-set/empty-set.module.css +2 -2
- package/src/ui/filters/filters.jsx +64 -53
- package/src/ui/filters/filters.module.css +3 -3
- package/src/ui/hover-card/hover-card.jsx +73 -0
- package/src/ui/hover-card/hover-card.module.css +29 -0
- package/src/ui/hover-card/index.js +1 -0
- package/src/ui/icon/icon.jsx +11 -9
- package/src/ui/icon/icon.module.css +1 -0
- package/src/ui/index.js +1 -1
- package/src/ui/table/table.jsx +5 -52
- package/src/ui/table/table.module.css +41 -25
- package/src/ui/tag/index.js +1 -0
- package/src/ui/tag/tag.jsx +49 -0
- package/src/ui/tag/tag.module.css +55 -0
- package/src/ui/tooltip/tooltip.jsx +10 -14
- package/src/ui/tooltip/tooltip.module.css +2 -1
- package/storybook-static/favicon.ico +0 -0
- package/lib/ui/popover/popover.js +0 -92
- package/lib/ui/popover/popover.module.css +0 -66
- package/lib/ui/popover/popover.stories.js +0 -26
- package/lib-esm/ui/popover/index.js +0 -1
- package/lib-esm/ui/popover/popover.js +0 -71
- package/lib-esm/ui/popover/popover.module.css +0 -66
- package/lib-esm/ui/popover/popover.stories.js +0 -14
- package/src/assets/icons/alert-circle.svg +0 -1
- package/src/assets/icons/check-circle.svg +0 -1
- package/src/components/budget-info/budget-info.jsx +0 -65
- package/src/components/budget-info/budget-info.module.css +0 -40
- package/src/components/budget-info/index.js +0 -1
- package/src/components/budget-insights/budget-insights.jsx +0 -157
- package/src/components/budget-insights/budget-insights.module.css +0 -53
- package/src/components/budget-insights/index.js +0 -1
- package/src/ui/popover/index.js +0 -1
- package/src/ui/popover/popover.jsx +0 -79
- package/src/ui/popover/popover.module.css +0 -66
|
@@ -6,9 +6,11 @@ const ACTION_SET_SEARCH = 'SET_SEARCH';
|
|
|
6
6
|
const ACTION_RESET_DEFAULT = 'RESET_DEFAULT';
|
|
7
7
|
const ACTION_RESET_ALL = 'RESET_ALL';
|
|
8
8
|
const ACTION_SET = 'SET';
|
|
9
|
+
const SEARCH_DEFAULT = '';
|
|
10
|
+
const SEARCH_DEFAULT_PATTERN = /.*/;
|
|
9
11
|
|
|
10
12
|
const getSearchPattern = search => {
|
|
11
|
-
let searchPattern =
|
|
13
|
+
let searchPattern = SEARCH_DEFAULT_PATTERN;
|
|
12
14
|
|
|
13
15
|
if (!search || !search.trim()) {
|
|
14
16
|
return searchPattern;
|
|
@@ -39,49 +41,46 @@ const getSearchReducer = _ref => {
|
|
|
39
41
|
switch (type) {
|
|
40
42
|
case ACTION_SET_FILTERS:
|
|
41
43
|
{
|
|
42
|
-
|
|
44
|
+
const newState = {
|
|
43
45
|
filters: payload,
|
|
44
46
|
search: state.search
|
|
45
|
-
});
|
|
46
|
-
return { ...state,
|
|
47
|
-
filters: payload
|
|
48
47
|
};
|
|
48
|
+
setParentState(newState);
|
|
49
|
+
return newState;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
case ACTION_SET_SEARCH:
|
|
52
53
|
{
|
|
53
|
-
|
|
54
|
+
const newState = {
|
|
54
55
|
filters: state.filters,
|
|
55
56
|
search: payload
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
};
|
|
58
|
+
setParentState(newState);
|
|
59
|
+
return { ...newState,
|
|
59
60
|
searchPattern: getSearchPattern(payload)
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
case ACTION_RESET_DEFAULT:
|
|
64
65
|
{
|
|
65
|
-
|
|
66
|
-
filters: defaultFilters,
|
|
67
|
-
search: ''
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
66
|
+
const newState = {
|
|
70
67
|
filters: defaultFilters,
|
|
71
|
-
search:
|
|
68
|
+
search: SEARCH_DEFAULT
|
|
69
|
+
};
|
|
70
|
+
setParentState(newState);
|
|
71
|
+
return { ...newState,
|
|
72
72
|
searchPattern: getSearchPattern()
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
case ACTION_RESET_ALL:
|
|
77
77
|
{
|
|
78
|
-
|
|
78
|
+
const newState = {
|
|
79
79
|
filters: allEntriesFilters,
|
|
80
|
-
search:
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
search: '',
|
|
80
|
+
search: SEARCH_DEFAULT
|
|
81
|
+
};
|
|
82
|
+
setParentState(newState);
|
|
83
|
+
return { ...newState,
|
|
85
84
|
searchPattern: getSearchPattern()
|
|
86
85
|
};
|
|
87
86
|
}
|
|
@@ -104,7 +103,7 @@ export const generateState = (filters, search) => ({
|
|
|
104
103
|
});
|
|
105
104
|
export const useSearchParams = _ref2 => {
|
|
106
105
|
let {
|
|
107
|
-
search: parentSearch,
|
|
106
|
+
search: parentSearch = SEARCH_DEFAULT,
|
|
108
107
|
filters: parentFilters,
|
|
109
108
|
defaultFilters,
|
|
110
109
|
allEntriesFilters,
|
|
@@ -124,7 +123,7 @@ export const useSearchParams = _ref2 => {
|
|
|
124
123
|
|
|
125
124
|
useLayoutEffect(() => {
|
|
126
125
|
// Run a deep comparison to prevent circular setState triggering
|
|
127
|
-
if (parentSearch === search
|
|
126
|
+
if (parentSearch === search && _isEqual(initialFilters, filters)) {
|
|
128
127
|
return;
|
|
129
128
|
}
|
|
130
129
|
|
|
@@ -132,7 +131,7 @@ export const useSearchParams = _ref2 => {
|
|
|
132
131
|
type: ACTION_SET,
|
|
133
132
|
payload: generateState(initialFilters, parentSearch)
|
|
134
133
|
});
|
|
135
|
-
}, [search, filters,
|
|
134
|
+
}, [dispatch, search, filters, parentSearch, initialFilters]);
|
|
136
135
|
/** Callbacks */
|
|
137
136
|
|
|
138
137
|
const handleUpdateSearch = useCallback(newValue => {
|
|
@@ -140,23 +139,23 @@ export const useSearchParams = _ref2 => {
|
|
|
140
139
|
type: ACTION_SET_SEARCH,
|
|
141
140
|
payload: newValue
|
|
142
141
|
});
|
|
143
|
-
}, []);
|
|
142
|
+
}, [dispatch]);
|
|
144
143
|
const handleUpdateFilters = useCallback(newFilters => {
|
|
145
144
|
dispatch({
|
|
146
145
|
type: ACTION_SET_FILTERS,
|
|
147
146
|
payload: newFilters
|
|
148
147
|
});
|
|
149
|
-
}, []);
|
|
148
|
+
}, [dispatch]);
|
|
150
149
|
const handleResetFilters = useCallback(() => {
|
|
151
150
|
dispatch({
|
|
152
151
|
type: ACTION_RESET_DEFAULT
|
|
153
152
|
});
|
|
154
|
-
}, []);
|
|
153
|
+
}, [dispatch]);
|
|
155
154
|
const handleResetAllFilters = useCallback(() => {
|
|
156
155
|
dispatch({
|
|
157
156
|
type: ACTION_RESET_ALL
|
|
158
157
|
});
|
|
159
|
-
}, []);
|
|
158
|
+
}, [dispatch]);
|
|
160
159
|
return {
|
|
161
160
|
search,
|
|
162
161
|
searchPattern,
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
.outline {
|
|
6
6
|
border: 1px solid var(--color-outline);
|
|
7
|
+
border-radius: var(--radius-medium);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.outline > :first-child {
|
|
11
|
+
border-radius: var(--radius-medium) var(--radius-medium) 0 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.outline > :last-child {
|
|
15
|
+
border-radius: 0 0 var(--radius-medium) var(--radius-medium);
|
|
7
16
|
}
|
|
8
17
|
|
|
9
18
|
.padding-xxxsmall {
|
package/lib-esm/layout/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { Box } from './box';
|
|
2
2
|
export { Footer } from './footer';
|
|
3
3
|
export { Header } from './header';
|
|
4
|
+
export { Separator } from './separator';
|
|
4
5
|
export { SubHeader } from './sub-header';
|
|
5
6
|
export { Stack } from './stack';
|
|
6
7
|
export { FlexStack } from './flex-stack';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import css from './separator.module.css';
|
|
7
|
+
const propTypes = {
|
|
8
|
+
className: PropTypes.string
|
|
9
|
+
};
|
|
10
|
+
const defaultProps = {
|
|
11
|
+
className: ''
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @param {PropTypes.InferProps<typeof propTypes>} props
|
|
15
|
+
* @return {React.FunctionComponentElement}
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export const Separator = props => {
|
|
19
|
+
const {
|
|
20
|
+
className,
|
|
21
|
+
...restProps
|
|
22
|
+
} = props;
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
24
|
+
className: cx(css.root, className)
|
|
25
|
+
}, restProps));
|
|
26
|
+
};
|
|
27
|
+
Separator.propTypes = propTypes;
|
|
28
|
+
Separator.defaultProps = defaultProps;
|
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import PropTypes from 'prop-types';
|
|
5
3
|
import cx from 'classnames';
|
|
6
|
-
import { Menu,
|
|
4
|
+
import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu';
|
|
7
5
|
import { FlexStack } from '../../layout/flex-stack';
|
|
8
6
|
import { Icon } from '../icon';
|
|
9
7
|
import css from './dropdown.module.css';
|
|
10
8
|
export const Dropdown = props => {
|
|
11
9
|
const {
|
|
12
10
|
className,
|
|
11
|
+
buttonClassName,
|
|
13
12
|
label,
|
|
14
13
|
ariaLabel,
|
|
15
14
|
glyph,
|
|
16
|
-
activeLabel,
|
|
17
15
|
children
|
|
18
16
|
} = props;
|
|
19
|
-
const rootClassName = cx(css.root,
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
className:
|
|
17
|
+
const rootClassName = cx(css.root, className);
|
|
18
|
+
const menuState = useMenuState();
|
|
19
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: rootClassName
|
|
21
|
+
}, /*#__PURE__*/React.createElement(MenuButton, {
|
|
22
|
+
state: menuState,
|
|
23
|
+
className: cx(css.button, buttonClassName),
|
|
26
24
|
tabIndex: null
|
|
27
|
-
}
|
|
28
|
-
space: "xxxsmall"
|
|
29
|
-
className: css.label
|
|
25
|
+
}, /*#__PURE__*/React.createElement(FlexStack, {
|
|
26
|
+
space: "xxxsmall"
|
|
30
27
|
}, glyph && /*#__PURE__*/React.createElement(Icon, {
|
|
31
28
|
className: css.labelIcon,
|
|
32
29
|
glyph: glyph
|
|
33
|
-
}), label)), /*#__PURE__*/React.createElement(Menu,
|
|
30
|
+
}), label)), /*#__PURE__*/React.createElement(Menu, {
|
|
31
|
+
state: menuState,
|
|
34
32
|
"aria-label": ariaLabel || label,
|
|
35
33
|
className: css.dropdown
|
|
36
|
-
}
|
|
34
|
+
}, typeof children === 'function' ? children({
|
|
37
35
|
MenuItem,
|
|
38
|
-
menu,
|
|
36
|
+
menu: menuState,
|
|
39
37
|
menuItemClassName: css.menuItem,
|
|
40
38
|
menuItemActiveClassName: css.menuItemActive
|
|
41
39
|
}) : children));
|
|
42
40
|
};
|
|
43
41
|
Dropdown.defaultProps = {
|
|
44
42
|
className: '',
|
|
43
|
+
buttonClassName: '',
|
|
45
44
|
label: null,
|
|
46
45
|
ariaLabel: '',
|
|
47
|
-
glyph: null
|
|
48
|
-
activeLabel: false
|
|
46
|
+
glyph: null
|
|
49
47
|
};
|
|
50
48
|
Dropdown.propTypes = {
|
|
51
49
|
/** Adopted child class name */
|
|
52
50
|
className: PropTypes.string,
|
|
53
51
|
|
|
52
|
+
/** Button adopted child class name */
|
|
53
|
+
buttonClassName: PropTypes.string,
|
|
54
|
+
|
|
54
55
|
/** Button label */
|
|
55
56
|
label: PropTypes.node,
|
|
56
57
|
|
|
@@ -60,12 +61,6 @@ Dropdown.propTypes = {
|
|
|
60
61
|
/** Icon glyph */
|
|
61
62
|
glyph: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
62
63
|
|
|
63
|
-
/** Dropdown open state */
|
|
64
|
-
open: PropTypes.bool.isRequired,
|
|
65
|
-
|
|
66
|
-
/** Active label flag */
|
|
67
|
-
activeLabel: PropTypes.bool,
|
|
68
|
-
|
|
69
64
|
/** Content */
|
|
70
65
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired
|
|
71
66
|
};
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
.root {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.button {
|
|
2
6
|
background: none;
|
|
3
7
|
border: none;
|
|
4
8
|
padding: 0;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.root:focus {
|
|
8
|
-
outline: none;
|
|
9
|
-
box-shadow: 0 0 var(--space-xxxsmall) var(--color-shadow);
|
|
10
|
-
}
|
|
11
9
|
|
|
12
|
-
.label {
|
|
13
10
|
border: 1px solid var(--color-outline);
|
|
11
|
+
border-radius: var(--radius-small);
|
|
14
12
|
padding: calc(var(--space-xxsmall) - 1px);
|
|
15
13
|
display: flex;
|
|
16
14
|
align-items: center;
|
|
@@ -24,7 +22,11 @@
|
|
|
24
22
|
color: var(--color-text-light);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
.
|
|
25
|
+
.button:hover,
|
|
26
|
+
.button:focus,
|
|
27
|
+
.button:active {
|
|
28
|
+
outline: none;
|
|
29
|
+
box-shadow: 0 0 var(--space-xxxsmall) var(--color-shadow);
|
|
28
30
|
border-color: var(--color-outline-dark);
|
|
29
31
|
color: var(--color-text);
|
|
30
32
|
}
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
position: absolute;
|
|
34
36
|
left: 0;
|
|
35
37
|
top: 100%;
|
|
38
|
+
border-radius: var(--radius-medium);
|
|
36
39
|
box-shadow: 0 2px var(--space-xxsmall) var(--color-shadow);
|
|
37
40
|
background: var(--color-background);
|
|
38
41
|
min-width: 180px;
|
|
@@ -45,10 +48,6 @@
|
|
|
45
48
|
box-shadow: 0 2px var(--space-xsmall) var(--color-shadow);
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
.activeLabel .label {
|
|
49
|
-
color: var(--color-text);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
51
|
.menuItem {
|
|
53
52
|
display: block;
|
|
54
53
|
appearance: none;
|
|
@@ -8,20 +8,15 @@ stories.add('default', () => /*#__PURE__*/React.createElement(Dropdown, {
|
|
|
8
8
|
glyph: "filter",
|
|
9
9
|
label: "Toggle"
|
|
10
10
|
}, /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", null, "Option 1"), /*#__PURE__*/React.createElement("li", null, "Option 2"))));
|
|
11
|
-
stories.add('with right alignement', () => /*#__PURE__*/React.createElement(Dropdown, {
|
|
12
|
-
glyph: "filter",
|
|
13
|
-
label: "Toggle",
|
|
14
|
-
align: "right"
|
|
15
|
-
}, /*#__PURE__*/React.createElement("ul", null, /*#__PURE__*/React.createElement("li", null, "Option 1"), /*#__PURE__*/React.createElement("li", null, "Option 2"))));
|
|
16
11
|
stories.add('with render function', () => /*#__PURE__*/React.createElement(Dropdown, {
|
|
17
12
|
glyph: "filter",
|
|
18
13
|
label: "Toggle"
|
|
19
14
|
}, _ref => {
|
|
20
15
|
let {
|
|
21
|
-
|
|
16
|
+
menu
|
|
22
17
|
} = _ref;
|
|
23
18
|
return /*#__PURE__*/React.createElement("button", {
|
|
24
19
|
type: "button",
|
|
25
|
-
onClick:
|
|
20
|
+
onClick: menu.toggle
|
|
26
21
|
}, "Toggle dropdown");
|
|
27
22
|
}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { Stack } from '../../layout/stack';
|
|
3
4
|
import I18N from '../../i18n';
|
|
4
5
|
import css from './empty-set.module.css';
|
|
5
6
|
export const EmptySet = props => {
|
|
@@ -19,11 +20,10 @@ export const EmptySet = props => {
|
|
|
19
20
|
type: "button",
|
|
20
21
|
onClick: handleViewAll
|
|
21
22
|
}, I18N.VIEW_ALL)] : [])];
|
|
22
|
-
return /*#__PURE__*/React.createElement(
|
|
23
|
+
return /*#__PURE__*/React.createElement(Stack, {
|
|
24
|
+
space: "xxsmall",
|
|
23
25
|
className: css.root
|
|
24
|
-
}, /*#__PURE__*/React.createElement("p",
|
|
25
|
-
className: css.text
|
|
26
|
-
}, message), filtered && actions.map((action, index) => /*#__PURE__*/React.createElement(React.Fragment, null, index > 0 && ' or ', action)));
|
|
26
|
+
}, /*#__PURE__*/React.createElement("p", null, message), filtered && actions.map((action, index) => /*#__PURE__*/React.createElement(React.Fragment, null, index > 0 && ' or ', action)));
|
|
27
27
|
};
|
|
28
28
|
EmptySet.propTypes = {
|
|
29
29
|
resources: PropTypes.string.isRequired,
|
|
@@ -13,6 +13,7 @@ import css from './filters.module.css';
|
|
|
13
13
|
const Filter = props => {
|
|
14
14
|
const {
|
|
15
15
|
className,
|
|
16
|
+
buttonClassName,
|
|
16
17
|
label,
|
|
17
18
|
name,
|
|
18
19
|
getOnOnlyClick,
|
|
@@ -25,7 +26,7 @@ const Filter = props => {
|
|
|
25
26
|
}, /*#__PURE__*/React.createElement(FlexStack, {
|
|
26
27
|
space: "xxxsmall",
|
|
27
28
|
as: "label",
|
|
28
|
-
className: css.filterCheckbox
|
|
29
|
+
className: cx(css.filterCheckbox, buttonClassName)
|
|
29
30
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
30
31
|
className: css.filterInput,
|
|
31
32
|
type: "checkbox",
|
|
@@ -43,17 +44,21 @@ const Filter = props => {
|
|
|
43
44
|
|
|
44
45
|
Filter.propTypes = {
|
|
45
46
|
className: PropTypes.string,
|
|
47
|
+
buttonClassName: PropTypes.string,
|
|
46
48
|
name: PropTypes.string.isRequired,
|
|
47
49
|
label: PropTypes.string.isRequired,
|
|
48
50
|
getOnOnlyClick: PropTypes.func
|
|
49
51
|
};
|
|
50
52
|
Filter.defaultProps = {
|
|
51
53
|
className: '',
|
|
54
|
+
buttonClassName: '',
|
|
52
55
|
getOnOnlyClick: null
|
|
53
56
|
};
|
|
54
57
|
|
|
55
58
|
const FilterGroup = props => {
|
|
56
59
|
const {
|
|
60
|
+
className,
|
|
61
|
+
buttonClassName,
|
|
57
62
|
groupKey,
|
|
58
63
|
data,
|
|
59
64
|
values,
|
|
@@ -98,6 +103,8 @@ const FilterGroup = props => {
|
|
|
98
103
|
};
|
|
99
104
|
|
|
100
105
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
106
|
+
className: className,
|
|
107
|
+
buttonClassName: buttonClassName,
|
|
101
108
|
label: dropdownLabel,
|
|
102
109
|
ariaLabel: `${groupLabel}: ${filterSuffix}`
|
|
103
110
|
}, _ref4 => {
|
|
@@ -147,6 +154,8 @@ const FilterGroup = props => {
|
|
|
147
154
|
};
|
|
148
155
|
|
|
149
156
|
FilterGroup.propTypes = {
|
|
157
|
+
className: PropTypes.string,
|
|
158
|
+
buttonClassName: PropTypes.string,
|
|
150
159
|
groupKey: PropTypes.string.isRequired,
|
|
151
160
|
data: PropTypes.object.isRequired,
|
|
152
161
|
// eslint-disable-line react/forbid-prop-types
|
|
@@ -155,6 +164,10 @@ FilterGroup.propTypes = {
|
|
|
155
164
|
onCheckboxChange: PropTypes.func.isRequired,
|
|
156
165
|
toggleFilters: PropTypes.func.isRequired
|
|
157
166
|
};
|
|
167
|
+
FilterGroup.defaultProps = {
|
|
168
|
+
className: '',
|
|
169
|
+
buttonClassName: ''
|
|
170
|
+
};
|
|
158
171
|
export const Filters = props => {
|
|
159
172
|
const {
|
|
160
173
|
className,
|
|
@@ -175,6 +188,7 @@ export const Filters = props => {
|
|
|
175
188
|
return /*#__PURE__*/React.createElement("form", {
|
|
176
189
|
className: rootClassName
|
|
177
190
|
}, /*#__PURE__*/React.createElement(FlexStack, {
|
|
191
|
+
space: "xxsmall",
|
|
178
192
|
className: css.items
|
|
179
193
|
}, Object.entries(filters).map(_ref7 => {
|
|
180
194
|
let [name, data] = _ref7;
|
|
@@ -183,6 +197,7 @@ export const Filters = props => {
|
|
|
183
197
|
return /*#__PURE__*/React.createElement(Filter, {
|
|
184
198
|
key: name,
|
|
185
199
|
className: cx(css.item, css.filterStandalone),
|
|
200
|
+
buttonClassName: css.itemButton,
|
|
186
201
|
name: name,
|
|
187
202
|
label: data.label,
|
|
188
203
|
onChange: onCheckboxChange,
|
|
@@ -191,16 +206,16 @@ export const Filters = props => {
|
|
|
191
206
|
});
|
|
192
207
|
}
|
|
193
208
|
|
|
194
|
-
return /*#__PURE__*/React.createElement(
|
|
195
|
-
className: css.item
|
|
196
|
-
|
|
209
|
+
return /*#__PURE__*/React.createElement(FilterGroup, {
|
|
210
|
+
className: css.item,
|
|
211
|
+
buttonClassName: css.itemButton,
|
|
197
212
|
key: name,
|
|
198
213
|
groupKey: name,
|
|
199
214
|
data: data,
|
|
200
215
|
values: values,
|
|
201
216
|
onCheckboxChange: onCheckboxChange,
|
|
202
217
|
toggleFilters: toggleFilters
|
|
203
|
-
})
|
|
218
|
+
});
|
|
204
219
|
})));
|
|
205
220
|
};
|
|
206
221
|
Filters.defaultProps = {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.filterInput {
|
|
14
|
+
border-radius: var(--radius-small) 0 0 var(--radius-small);
|
|
14
15
|
flex: 0 0 auto;
|
|
15
16
|
height: 1em;
|
|
16
17
|
cursor: pointer;
|
|
@@ -131,9 +132,8 @@
|
|
|
131
132
|
.item {
|
|
132
133
|
position: relative;
|
|
133
134
|
flex: 0 0 auto;
|
|
134
|
-
margin-right: -1px;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
.
|
|
138
|
-
|
|
137
|
+
.itemButton {
|
|
138
|
+
border-radius: var(--radius-small);
|
|
139
139
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React, { useCallback } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { Hovercard, HovercardAnchor, HovercardArrow, useHovercard, useHovercardState } from 'ariakit/hovercard';
|
|
7
|
+
import css from './hover-card.module.css';
|
|
8
|
+
|
|
9
|
+
const resolveComponent = (as, href) => {
|
|
10
|
+
if (as) {
|
|
11
|
+
return as;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (href) {
|
|
15
|
+
return 'a';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return 'span';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const HoverCard = props => {
|
|
22
|
+
const {
|
|
23
|
+
className,
|
|
24
|
+
hoverCardClassName,
|
|
25
|
+
href,
|
|
26
|
+
as,
|
|
27
|
+
label,
|
|
28
|
+
children
|
|
29
|
+
} = props;
|
|
30
|
+
const state = useHovercardState({
|
|
31
|
+
gutter: 8
|
|
32
|
+
});
|
|
33
|
+
const hoverCardProps = useHovercard({
|
|
34
|
+
state,
|
|
35
|
+
portal: true
|
|
36
|
+
}); // Fallback to span if no href
|
|
37
|
+
|
|
38
|
+
const Component = resolveComponent(as, href);
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
className: cx(css.root, className)
|
|
41
|
+
}, /*#__PURE__*/React.createElement(HovercardAnchor, {
|
|
42
|
+
state: state,
|
|
43
|
+
href: href,
|
|
44
|
+
className: css.anchor,
|
|
45
|
+
as: Component
|
|
46
|
+
}, label), /*#__PURE__*/React.createElement(Hovercard, _extends({}, hoverCardProps, {
|
|
47
|
+
state: state,
|
|
48
|
+
className: cx(css.hoverCard, hoverCardClassName),
|
|
49
|
+
style: {
|
|
50
|
+
zIndex: 10000
|
|
51
|
+
}
|
|
52
|
+
}), /*#__PURE__*/React.createElement(HovercardArrow, {
|
|
53
|
+
size: 24
|
|
54
|
+
}), typeof children === 'function' ? children({
|
|
55
|
+
close: state.hide
|
|
56
|
+
}) : children));
|
|
57
|
+
};
|
|
58
|
+
HoverCard.propTypes = {
|
|
59
|
+
/** Adopted child class name */
|
|
60
|
+
className: PropTypes.string,
|
|
61
|
+
|
|
62
|
+
/** Adopted child class name for hover card */
|
|
63
|
+
hoverCardClassName: PropTypes.string,
|
|
64
|
+
|
|
65
|
+
/** Anchor label */
|
|
66
|
+
label: PropTypes.node,
|
|
67
|
+
|
|
68
|
+
/** Anchor href */
|
|
69
|
+
href: PropTypes.string,
|
|
70
|
+
|
|
71
|
+
/** Anchor component */
|
|
72
|
+
as: PropTypes.elementType,
|
|
73
|
+
|
|
74
|
+
/** Hover card component */
|
|
75
|
+
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired
|
|
76
|
+
};
|
|
77
|
+
HoverCard.defaultProps = {
|
|
78
|
+
className: '',
|
|
79
|
+
hoverCardClassName: '',
|
|
80
|
+
label: '',
|
|
81
|
+
as: '',
|
|
82
|
+
href: ''
|
|
83
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.anchor {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
color: inherit;
|
|
8
|
+
text-decoration: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.anchor:hover {
|
|
12
|
+
color: var(--color-primary);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.anchor:focus {
|
|
16
|
+
outline: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hoverCard {
|
|
20
|
+
padding: var(--space-xsmall) var(--space-small);
|
|
21
|
+
border-radius: var(--radius-medium);
|
|
22
|
+
width: calc(100vw - 2 * var(--space-small));
|
|
23
|
+
max-width: 360px;
|
|
24
|
+
outline: none;
|
|
25
|
+
filter: drop-shadow(0 0 var(--space-xxsmall) var(--color-shadow));
|
|
26
|
+
will-change: filter;
|
|
27
|
+
background: var(--color-light);
|
|
28
|
+
font-size: var(--size-small);
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { HoverCard } from '.';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'UI/HoverCard',
|
|
7
|
+
component: HoverCard
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const Template = props => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HoverCard, _extends({}, props, {
|
|
11
|
+
style: {
|
|
12
|
+
zIndex: 2
|
|
13
|
+
}
|
|
14
|
+
})), /*#__PURE__*/React.createElement("p", {
|
|
15
|
+
style: {
|
|
16
|
+
position: 'relative',
|
|
17
|
+
zIndex: 1,
|
|
18
|
+
maxWidth: 360
|
|
19
|
+
}
|
|
20
|
+
}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras in neque ante. Curabitur vehicula, lorem sit amet fringilla dapibus, justo mauris varius elit, ut fermentum leo velit eget risus"));
|
|
21
|
+
|
|
22
|
+
export const Default = () => /*#__PURE__*/React.createElement(Template, {
|
|
23
|
+
label: "main.js"
|
|
24
|
+
}, /*#__PURE__*/React.createElement("h1", null, "main.js"), /*#__PURE__*/React.createElement("p", null, "info"));
|
|
25
|
+
export const WithRenderFn = () => /*#__PURE__*/React.createElement(Template, {
|
|
26
|
+
label: "main.js"
|
|
27
|
+
}, _ref => {
|
|
28
|
+
let {
|
|
29
|
+
close
|
|
30
|
+
} = _ref;
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h1", null, "main.js"), /*#__PURE__*/React.createElement("p", null, "info"), /*#__PURE__*/React.createElement("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
onClick: close
|
|
34
|
+
}, "close"));
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hover-card';
|