@bundle-stats/ui 3.3.0-alpha.1 → 3.4.0-alpha.1
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 +94 -13
- 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 +53 -67
- 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/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 +35 -50
- 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/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 +142 -145
- package/src/app/app.module.css +11 -4
- package/src/app/header/header.jsx +0 -10
- 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 +2 -0
- package/src/components/bundle-modules/bundle-modules.jsx +36 -36
- 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/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 +1 -1
- package/src/components/summary-item/summary-item.jsx +21 -27
- package/src/components/summary-item/summary-item.module.css +1 -23
- package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
- 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/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 -7
- 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/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/ui/popover/index.js +0 -1
- package/src/ui/popover/popover.jsx +0 -79
- package/src/ui/popover/popover.module.css +0 -66
|
@@ -4,7 +4,8 @@ import React from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import cx from 'classnames';
|
|
6
6
|
import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { HoverCard } from '../../ui/hover-card';
|
|
8
|
+
import { Icon } from '../../ui/icon';
|
|
8
9
|
import { Skeleton } from '../../ui/skeleton';
|
|
9
10
|
import { Stack } from '../../layout/stack';
|
|
10
11
|
import { FlexStack } from '../../layout/flex-stack';
|
|
@@ -13,31 +14,24 @@ import { Delta } from '../delta';
|
|
|
13
14
|
import { BudgetInfo } from '../budget-info';
|
|
14
15
|
import css from './summary-item.module.css';
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
+
const MetricInfo = _ref => {
|
|
17
18
|
let {
|
|
18
19
|
description,
|
|
19
20
|
url
|
|
20
21
|
} = _ref;
|
|
21
|
-
|
|
22
|
-
// Workaround cases where the parent is a link
|
|
23
|
-
const readMoreOnClick = () => {
|
|
24
|
-
window.open(url);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
22
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
28
23
|
space: "xxxsmall"
|
|
29
|
-
}, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("
|
|
30
|
-
|
|
31
|
-
className: css.
|
|
32
|
-
onClick: readMoreOnClick
|
|
24
|
+
}, /*#__PURE__*/React.createElement("p", null, description), url && /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("a", {
|
|
25
|
+
href: url,
|
|
26
|
+
className: css.readMoreLink
|
|
33
27
|
}, "Read more")));
|
|
34
28
|
};
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
MetricInfo.propTypes = {
|
|
37
31
|
description: PropTypes.string.isRequired,
|
|
38
32
|
url: PropTypes.string
|
|
39
33
|
};
|
|
40
|
-
|
|
34
|
+
MetricInfo.defaultProps = {
|
|
41
35
|
url: ''
|
|
42
36
|
};
|
|
43
37
|
export const SummaryItem = _ref2 => {
|
|
@@ -65,7 +59,7 @@ export const SummaryItem = _ref2 => {
|
|
|
65
59
|
const showMetricDescriptionTooltip = showMetricDescription && (metric == null ? void 0 : metric.description);
|
|
66
60
|
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
67
61
|
return /*#__PURE__*/React.createElement(Stack, _extends({
|
|
68
|
-
space: "
|
|
62
|
+
space: "xxxsmall",
|
|
69
63
|
as: Component,
|
|
70
64
|
className: rootClassName
|
|
71
65
|
}, props), /*#__PURE__*/React.createElement(FlexStack, {
|
|
@@ -74,10 +68,12 @@ export const SummaryItem = _ref2 => {
|
|
|
74
68
|
className: css.title
|
|
75
69
|
}, /*#__PURE__*/React.createElement("span", {
|
|
76
70
|
className: css.titleLabel
|
|
77
|
-
}, metric.label), showMetricDescriptionTooltip && /*#__PURE__*/React.createElement(
|
|
71
|
+
}, metric.label), showMetricDescriptionTooltip && /*#__PURE__*/React.createElement(HoverCard, {
|
|
78
72
|
className: css.icon,
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
label: /*#__PURE__*/React.createElement(Icon, {
|
|
74
|
+
glyph: "help"
|
|
75
|
+
})
|
|
76
|
+
}, /*#__PURE__*/React.createElement(MetricInfo, metric)), budget && /*#__PURE__*/React.createElement(BudgetInfo, {
|
|
81
77
|
className: css.budgetInfo,
|
|
82
78
|
metricId: id,
|
|
83
79
|
budgetInsight: budget
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
.title {
|
|
7
|
+
align-items: center;
|
|
7
8
|
color: var(--color-text-ultra-light);
|
|
8
9
|
font-weight: bold;
|
|
9
10
|
font-size: var(--size-xsmall);
|
|
@@ -12,29 +13,6 @@
|
|
|
12
13
|
white-space: nowrap;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
.titleLabel {
|
|
16
|
-
flex: 0 0 auto;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.readMoreBtn {
|
|
20
|
-
appearance: none;
|
|
21
|
-
padding: 0;
|
|
22
|
-
border: 0;
|
|
23
|
-
background: none;
|
|
24
|
-
cursor: pointer;
|
|
25
|
-
/* simulate link */
|
|
26
|
-
color: var(--color-primary);
|
|
27
|
-
text-decoration: underline;
|
|
28
|
-
line-height: var(--space-small);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.readMoreBtn:hover,
|
|
32
|
-
.readMoreBtn:active,
|
|
33
|
-
.readMoreBtn:focus {
|
|
34
|
-
color: var(--color-primary-dark);
|
|
35
|
-
text-decoration: none;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
16
|
.budgetInfo {
|
|
39
17
|
position: absolute;
|
|
40
18
|
right: 0;
|
|
@@ -5,7 +5,8 @@ import config from '../../config.json';
|
|
|
5
5
|
import I18N from '../../i18n';
|
|
6
6
|
import { FlexStack } from '../../layout/flex-stack';
|
|
7
7
|
import { Stack } from '../../layout/stack';
|
|
8
|
-
import {
|
|
8
|
+
import { Icon } from '../../ui/icon';
|
|
9
|
+
import { HoverCard } from '../../ui/hover-card';
|
|
9
10
|
import css from './total-size-type-title.module.css';
|
|
10
11
|
export const TotalSizeTypeTitle = _ref => {
|
|
11
12
|
let {
|
|
@@ -14,8 +15,10 @@ export const TotalSizeTypeTitle = _ref => {
|
|
|
14
15
|
return /*#__PURE__*/React.createElement(FlexStack, {
|
|
15
16
|
space: "xxxsmall",
|
|
16
17
|
className: cx(css.title, className)
|
|
17
|
-
}, /*#__PURE__*/React.createElement("span", null, I18N.ASSET_TOTALS), /*#__PURE__*/React.createElement(
|
|
18
|
-
|
|
18
|
+
}, /*#__PURE__*/React.createElement("span", null, I18N.ASSET_TOTALS), /*#__PURE__*/React.createElement(HoverCard, {
|
|
19
|
+
label: /*#__PURE__*/React.createElement(Icon, {
|
|
20
|
+
glyph: "help"
|
|
21
|
+
})
|
|
19
22
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
20
23
|
space: "xxxsmall"
|
|
21
24
|
}, /*#__PURE__*/React.createElement("p", null, I18N.ASSET_TOTALS_INFO), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement("a", {
|
package/lib-esm/css/default.css
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
+
@import url("~modern-css-reset/dist/reset.css");
|
|
2
|
+
|
|
1
3
|
:root {
|
|
2
4
|
--chart-height: 180px;
|
|
3
5
|
}
|
|
4
6
|
|
|
7
|
+
/** modern-css-reset updates */
|
|
8
|
+
pre,
|
|
9
|
+
ul,
|
|
10
|
+
ol,
|
|
11
|
+
button {
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
5
15
|
html {
|
|
16
|
+
font-family: var(--font-family);
|
|
6
17
|
font-size: 81.25%;
|
|
7
|
-
line-height: 1.
|
|
18
|
+
line-height: 1.6;
|
|
8
19
|
}
|
|
9
20
|
|
|
10
21
|
body {
|
|
22
|
+
background: var(--color-background);
|
|
11
23
|
color: var(--color-text);
|
|
12
24
|
}
|
|
13
25
|
|
|
14
|
-
h1, h2, h3, h4, h5 {
|
|
15
|
-
margin-bottom: var(--space-small);
|
|
26
|
+
h1, h2, h3, h4, h5, h6 {
|
|
16
27
|
color: var(--color-heading);
|
|
17
28
|
font-weight: 500;
|
|
18
29
|
}
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
--size-xxlarge: 1.424rem;
|
|
24
24
|
--size-xxxlarge: 1.602rem;
|
|
25
25
|
|
|
26
|
-
--line-height:
|
|
26
|
+
--line-height: 1.6em;
|
|
27
27
|
|
|
28
28
|
/*
|
|
29
29
|
* Color scheme:
|
|
30
|
-
* http://mcg.mbitson.com/#!?mcgpalette0=%23dd555e&mcgpalette1=%2363bf5e&mcgpalette2=%23f7e37d&mcgpalette3=%23636568&mcgpalette4=%233385d6&themename=mcgtheme
|
|
31
30
|
* https://coolors.co/3385d6-dd555e-63bf5e-f7e37d-192339
|
|
31
|
+
* http://mcg.mbitson.com/#!?mcgpalette0=%23dd555e&mcgpalette1=%2363bf5e&mcgpalette2=%23f7e37d&mcgpalette3=%235b5d60&mcgpalette4=%233385d6&themename=mcgtheme
|
|
32
32
|
*/
|
|
33
33
|
--color-gray-25: #fafafa;
|
|
34
|
-
--color-gray-50: #
|
|
35
|
-
--color-gray-100: #
|
|
36
|
-
--color-gray-200: #
|
|
37
|
-
--color-gray-300: #
|
|
38
|
-
--color-gray-400: #
|
|
39
|
-
--color-gray-500: #
|
|
40
|
-
--color-gray-600: #
|
|
41
|
-
--color-gray-700: #
|
|
42
|
-
--color-gray-800: #
|
|
43
|
-
--color-gray-900: #
|
|
34
|
+
--color-gray-50: #e4e4e5;
|
|
35
|
+
--color-gray-100: #cececf;
|
|
36
|
+
--color-gray-200: #adaeb0;
|
|
37
|
+
--color-gray-300: #8c8e90;
|
|
38
|
+
--color-gray-400: #747578;
|
|
39
|
+
--color-gray-500: #5b5d60;
|
|
40
|
+
--color-gray-600: #535558;
|
|
41
|
+
--color-gray-700: #494b4e;
|
|
42
|
+
--color-gray-800: #404144;
|
|
43
|
+
--color-gray-900: #2f3033;
|
|
44
44
|
|
|
45
45
|
--color-gray-ultra-light: var(--color-gray-200);
|
|
46
46
|
--color-gray-light: var(--color-gray-300);
|
|
47
47
|
--color-gray: var(--color-gray-500);
|
|
48
|
-
--color-gray-dark: var(--color-gray-
|
|
49
|
-
--color-gray-ultra-dark: var(--color-gray-
|
|
48
|
+
--color-gray-dark: var(--color-gray-600);
|
|
49
|
+
--color-gray-ultra-dark: var(--color-gray-700);
|
|
50
50
|
|
|
51
51
|
--color-red-25: #fdf5f6;
|
|
52
52
|
--color-red-50: #fbebec;
|
|
@@ -181,9 +181,9 @@
|
|
|
181
181
|
--layer-high: 1000;
|
|
182
182
|
--layer-xhigh: 10000;
|
|
183
183
|
|
|
184
|
-
--radius-small:
|
|
185
|
-
--radius-medium: var(--space-
|
|
186
|
-
--radius-large: var(--space-
|
|
184
|
+
--radius-small: 3px;
|
|
185
|
+
--radius-medium: var(--space-xxxsmall);
|
|
186
|
+
--radius-large: var(--space-xxsmall);
|
|
187
187
|
|
|
188
188
|
/** Layout */
|
|
189
189
|
--max-width: 80rem;
|
|
@@ -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,
|