@bundle-stats/ui 4.1.4-alpha.0 → 4.1.5-alpha.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/README.md +26 -0
- package/lib/components/metrics-table-options/metrics-table-options.js +5 -18
- package/lib/components/summary-item/summary-item.js +1 -1
- package/lib/css/default.css +0 -5
- package/lib/css/variables.css +3 -0
- package/lib/ui/dropdown/dropdown.js +27 -4
- package/lib/ui/dropdown/dropdown.module.css +19 -10
- package/lib/ui/dropdown/dropdown.stories.js +28 -11
- package/lib/ui/empty-set/empty-set.js +1 -1
- package/lib/ui/filters/filters.module.css +8 -4
- package/lib/ui/hover-card/hover-card.module.css +1 -1
- package/lib/ui/input/input.module.css +1 -0
- package/lib/ui/sort-dropdown/sort-dropdown.js +9 -11
- package/lib/ui/tooltip/tooltip.module.css +1 -1
- package/lib-esm/components/metrics-table-options/metrics-table-options.js +5 -18
- package/lib-esm/components/summary-item/summary-item.js +1 -1
- package/lib-esm/css/default.css +0 -5
- package/lib-esm/css/variables.css +3 -0
- package/lib-esm/ui/dropdown/dropdown.js +24 -4
- package/lib-esm/ui/dropdown/dropdown.module.css +19 -10
- package/lib-esm/ui/dropdown/dropdown.stories.js +19 -9
- package/lib-esm/ui/empty-set/empty-set.js +1 -1
- package/lib-esm/ui/filters/filters.module.css +8 -4
- package/lib-esm/ui/hover-card/hover-card.module.css +1 -1
- package/lib-esm/ui/input/input.module.css +1 -0
- package/lib-esm/ui/sort-dropdown/sort-dropdown.js +7 -9
- package/lib-esm/ui/tooltip/tooltip.module.css +1 -1
- package/package.json +6 -5
- package/src/components/metrics-table-options/metrics-table-options.jsx +10 -29
- package/src/components/summary-item/summary-item.jsx +1 -1
- package/src/css/default.css +0 -5
- package/src/css/variables.css +3 -0
- package/src/ui/dropdown/dropdown.jsx +19 -3
- package/src/ui/dropdown/dropdown.module.css +19 -10
- package/src/ui/empty-set/empty-set.jsx +1 -1
- package/src/ui/filters/filters.module.css +8 -4
- package/src/ui/hover-card/hover-card.module.css +1 -1
- package/src/ui/input/input.module.css +1 -0
- package/src/ui/sort-dropdown/sort-dropdown.jsx +20 -24
- package/src/ui/tooltip/tooltip.module.css +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
# @bundle-stats/ui
|
|
2
2
|
|
|
3
3
|
UI components for BundleStats projects.
|
|
4
|
+
|
|
5
|
+
## Packages
|
|
6
|
+
|
|
7
|
+
### [`bundle-stats`](https://github.com/relative-ci/bundle-stats/tree/master/packages/cli)
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/bundle-stats) [](https://www.npmjs.com/package/bundle-stats)
|
|
10
|
+
|
|
11
|
+
CLI to generate bundle stats report.
|
|
12
|
+
|
|
13
|
+
### [`bundle-stats-webpack-plugin`](https://github.com/relative-ci/bundle-stats/tree/master/packages/webpack-plugin)
|
|
14
|
+
|
|
15
|
+
[](https://www.npmjs.com/package/bundle-stats-webpack-plugin) [](https://www.npmjs.com/package/bundle-stats-webpack-plugin)
|
|
16
|
+
|
|
17
|
+
Webpack plugin to generate bundle stats report.
|
|
18
|
+
|
|
19
|
+
### [`gatsby-plugin-bundle-stats`](https://github.com/relative-ci/bundle-stats/tree/master/packages/gatsby-plugin)
|
|
20
|
+
|
|
21
|
+
[](https://www.npmjs.com/package/gatsby-plugin-bundle-stats) [](https://www.npmjs.com/package/gatsby-plugin-bundle-stats)
|
|
22
|
+
|
|
23
|
+
[Gatsby](https://www.gatsbyjs.org) plugin for [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/webpack-plugin).
|
|
24
|
+
|
|
25
|
+
### [`next-plugin-bundle-stats`](https://github.com/relative-ci/bundle-stats/tree/master/packages/next-plugin)
|
|
26
|
+
|
|
27
|
+
[](https://www.npmjs.com/package/next-plugin-bundle-stats) [](https://www.npmjs.com/package/next-plugin-bundle-stats)
|
|
28
|
+
|
|
29
|
+
[Next.js](https://nextjs.org) plugin for [bundle-stats](https://github.com/relative-ci/bundle-stats/tree/master/packages/webpack-plugin).
|
|
@@ -21,24 +21,11 @@ var MetricsTableOptions = function MetricsTableOptions(props) {
|
|
|
21
21
|
return /*#__PURE__*/_react["default"].createElement(_dropdown.Dropdown, _extends({
|
|
22
22
|
className: className,
|
|
23
23
|
glyph: "menu"
|
|
24
|
-
}, restProps),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return function () {
|
|
30
|
-
handler();
|
|
31
|
-
menu.toggle();
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, handleResetFilters && /*#__PURE__*/_react["default"].createElement(MenuItem, _extends({}, menu, {
|
|
35
|
-
className: menuItemClassName,
|
|
36
|
-
onClick: getButtonOnClick(handleResetFilters)
|
|
37
|
-
}), _i18n["default"].RESET_FILTERS), handleViewAll && /*#__PURE__*/_react["default"].createElement(MenuItem, _extends({}, menu, {
|
|
38
|
-
className: menuItemClassName,
|
|
39
|
-
onClick: getButtonOnClick(handleViewAll)
|
|
40
|
-
}), _i18n["default"].VIEW_ALL));
|
|
41
|
-
});
|
|
24
|
+
}, restProps), handleResetFilters && /*#__PURE__*/_react["default"].createElement(_dropdown.Dropdown.Item, {
|
|
25
|
+
onClick: handleResetFilters
|
|
26
|
+
}, _i18n["default"].RESET_FILTERS), handleViewAll && /*#__PURE__*/_react["default"].createElement(_dropdown.Dropdown.Item, {
|
|
27
|
+
onClick: handleViewAll
|
|
28
|
+
}, _i18n["default"].VIEW_ALL));
|
|
42
29
|
};
|
|
43
30
|
exports.MetricsTableOptions = MetricsTableOptions;
|
|
44
31
|
MetricsTableOptions.propTypes = {
|
|
@@ -70,7 +70,7 @@ var SummaryItem = function SummaryItem(_ref2) {
|
|
|
70
70
|
var showMetricDescriptionTooltip = showMetricDescription && (metric === null || metric === void 0 ? void 0 : metric.description);
|
|
71
71
|
var rootClassName = (0, _classnames["default"])(_summaryItemModule["default"].root, className, _summaryItemModule["default"][size], showDelta && _summaryItemModule["default"].showDelta);
|
|
72
72
|
return /*#__PURE__*/_react["default"].createElement(_stack.Stack, _extends({
|
|
73
|
-
space: "
|
|
73
|
+
space: "xxxsmall",
|
|
74
74
|
as: Component,
|
|
75
75
|
className: rootClassName
|
|
76
76
|
}, props), /*#__PURE__*/_react["default"].createElement(_flexStack.FlexStack, {
|
package/lib/css/default.css
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
@import url("~modern-css-reset/dist/reset.css");
|
|
2
2
|
|
|
3
|
-
:root {
|
|
4
|
-
--chart-height: 180px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
/** modern-css-reset updates */
|
|
8
4
|
pre,
|
|
9
5
|
ul,
|
|
@@ -31,7 +27,6 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
31
27
|
|
|
32
28
|
h1 {
|
|
33
29
|
font-size: var(--size-xxxlarge);
|
|
34
|
-
line-height: var(--space-xlarge)
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
h2 {
|
package/lib/css/variables.css
CHANGED
|
@@ -183,6 +183,9 @@
|
|
|
183
183
|
--layer-high: 1000;
|
|
184
184
|
--layer-xhigh: 10000;
|
|
185
185
|
|
|
186
|
+
--shadow-layer: 0 0 var(--space-xxxsmall) var(--color-shadow);
|
|
187
|
+
--shadow-layer-high: 0 0 var(--space-xxsmall) var(--color-shadow);
|
|
188
|
+
|
|
186
189
|
--radius-small: 3px;
|
|
187
190
|
--radius-medium: 5px;
|
|
188
191
|
--radius-large: 9px;
|
|
@@ -11,7 +11,29 @@ var _menu = require("ariakit/menu");
|
|
|
11
11
|
var _flexStack = require("../../layout/flex-stack");
|
|
12
12
|
var _icon = require("../icon");
|
|
13
13
|
var _dropdownModule = _interopRequireDefault(require("./dropdown.module.css"));
|
|
14
|
+
var _excluded = ["className", "isActive"];
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
17
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
+
var Item = function Item(_ref) {
|
|
20
|
+
var _ref$className = _ref.className,
|
|
21
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
22
|
+
_ref$isActive = _ref.isActive,
|
|
23
|
+
isActive = _ref$isActive === void 0 ? false : _ref$isActive,
|
|
24
|
+
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement(_menu.MenuItem, _extends({
|
|
26
|
+
className: (0, _classnames["default"])(_dropdownModule["default"].item, className, isActive && _dropdownModule["default"].itemActive)
|
|
27
|
+
}, restProps));
|
|
28
|
+
};
|
|
29
|
+
Item.propTypes = {
|
|
30
|
+
className: _propTypes["default"].string,
|
|
31
|
+
isActive: _propTypes["default"].bool
|
|
32
|
+
};
|
|
33
|
+
Item.defaultProps = {
|
|
34
|
+
className: '',
|
|
35
|
+
isActive: false
|
|
36
|
+
};
|
|
15
37
|
var Dropdown = function Dropdown(props) {
|
|
16
38
|
var className = props.className,
|
|
17
39
|
buttonClassName = props.buttonClassName,
|
|
@@ -41,10 +63,10 @@ var Dropdown = function Dropdown(props) {
|
|
|
41
63
|
"aria-label": ariaLabel || label,
|
|
42
64
|
className: _dropdownModule["default"].dropdown
|
|
43
65
|
}, typeof children === 'function' ? children({
|
|
44
|
-
MenuItem:
|
|
66
|
+
MenuItem: Item,
|
|
45
67
|
menu: menuState,
|
|
46
|
-
menuItemClassName: _dropdownModule["default"].
|
|
47
|
-
menuItemActiveClassName: _dropdownModule["default"].
|
|
68
|
+
menuItemClassName: _dropdownModule["default"].item,
|
|
69
|
+
menuItemActiveClassName: _dropdownModule["default"].itemActive
|
|
48
70
|
}) : children));
|
|
49
71
|
};
|
|
50
72
|
exports.Dropdown = Dropdown;
|
|
@@ -68,4 +90,5 @@ Dropdown.propTypes = {
|
|
|
68
90
|
glyph: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]),
|
|
69
91
|
/** Content */
|
|
70
92
|
children: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element, _propTypes["default"].func]).isRequired
|
|
71
|
-
};
|
|
93
|
+
};
|
|
94
|
+
Dropdown.Item = Item;
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
color: var(--color-text-light);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
.button[aria-expanded=true],
|
|
23
24
|
.button:hover,
|
|
24
25
|
.button:focus,
|
|
25
26
|
.button:active {
|
|
26
27
|
outline: none;
|
|
27
|
-
box-shadow:
|
|
28
|
+
box-shadow: var(--shadow-layer);
|
|
28
29
|
border-color: var(--color-outline-dark);
|
|
29
30
|
color: var(--color-text);
|
|
30
31
|
}
|
|
@@ -34,26 +35,26 @@
|
|
|
34
35
|
left: 0;
|
|
35
36
|
top: 100%;
|
|
36
37
|
border-radius: var(--radius-medium);
|
|
37
|
-
box-shadow:
|
|
38
|
+
box-shadow: var(--shadow-layer-high);
|
|
38
39
|
background: var(--color-background);
|
|
39
|
-
min-width:
|
|
40
|
+
min-width: 12em;
|
|
40
41
|
z-index: var(--layer-high);
|
|
41
|
-
padding: var(--space-
|
|
42
|
+
padding: var(--space-xxxsmall);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
.dropdown:focus {
|
|
45
46
|
outline: none;
|
|
46
|
-
box-shadow: 0 2px var(--space-xsmall) var(--color-shadow);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.
|
|
49
|
+
.item {
|
|
50
50
|
display: block;
|
|
51
51
|
appearance: none;
|
|
52
52
|
cursor: pointer;
|
|
53
53
|
width: 100%;
|
|
54
54
|
outline: none;
|
|
55
55
|
border: 0;
|
|
56
|
-
|
|
56
|
+
border-radius: var(--radius-small);
|
|
57
|
+
padding: calc(var(--space-xxxsmall) / 2) var(--space-xxxsmall);
|
|
57
58
|
background: none;
|
|
58
59
|
text-align: left;
|
|
59
60
|
color: var(--color-text-light);
|
|
@@ -62,14 +63,22 @@
|
|
|
62
63
|
text-decoration: none;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
.
|
|
66
|
+
.item[data-active-item],
|
|
67
|
+
.item:hover,
|
|
68
|
+
.item:focus,
|
|
69
|
+
.item:active {
|
|
70
|
+
background: var(--color-highlight);
|
|
66
71
|
color: var(--color-text);
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
.
|
|
74
|
+
.itemActive {
|
|
75
|
+
background: var(--color-highlight-info);
|
|
70
76
|
color: var(--color-primary);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
.
|
|
79
|
+
.itemActive:hover,
|
|
80
|
+
.itemActive:focus,
|
|
81
|
+
.itemActive:active {
|
|
82
|
+
background: var(--color-highlight-info);
|
|
74
83
|
color: var(--color-primary-dark);
|
|
75
84
|
}
|
|
@@ -1,27 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.WithRenderFn = exports.Defualt = void 0;
|
|
3
7
|
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
var _react2 = require("@storybook/react");
|
|
5
8
|
var _stories = require("../../stories");
|
|
6
9
|
var _ = require(".");
|
|
7
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
var _default = {
|
|
12
|
+
title: 'UI/Dropdown',
|
|
13
|
+
component: _.Dropdown,
|
|
14
|
+
decorators: [(0, _stories.getWrapperDecorator)()]
|
|
15
|
+
};
|
|
16
|
+
exports["default"] = _default;
|
|
17
|
+
var Defualt = function Defualt() {
|
|
11
18
|
return /*#__PURE__*/_react["default"].createElement(_.Dropdown, {
|
|
12
19
|
glyph: "filter",
|
|
13
20
|
label: "Toggle"
|
|
14
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
15
|
-
}
|
|
16
|
-
|
|
21
|
+
}, /*#__PURE__*/_react["default"].createElement(_.Dropdown.Item, null, "Option 1"), /*#__PURE__*/_react["default"].createElement(_.Dropdown.Item, null, "Option 2"));
|
|
22
|
+
};
|
|
23
|
+
exports.Defualt = Defualt;
|
|
24
|
+
var WithRenderFn = function WithRenderFn() {
|
|
17
25
|
return /*#__PURE__*/_react["default"].createElement(_.Dropdown, {
|
|
18
26
|
glyph: "filter",
|
|
19
27
|
label: "Toggle"
|
|
20
28
|
}, function (_ref) {
|
|
21
|
-
var
|
|
22
|
-
|
|
29
|
+
var MenuItem = _ref.MenuItem,
|
|
30
|
+
menuItemClassName = _ref.menuItemClassName,
|
|
31
|
+
menu = _ref.menu;
|
|
32
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(MenuItem, {
|
|
33
|
+
className: menuItemClassName
|
|
34
|
+
}, "Option 1"), /*#__PURE__*/_react["default"].createElement(MenuItem, {
|
|
35
|
+
className: menuItemClassName
|
|
36
|
+
}, "Option 2"), /*#__PURE__*/_react["default"].createElement(MenuItem, {
|
|
37
|
+
className: menuItemClassName
|
|
38
|
+
}, "Option 3"), /*#__PURE__*/_react["default"].createElement("button", {
|
|
23
39
|
type: "button",
|
|
24
40
|
onClick: menu.toggle
|
|
25
|
-
}, "Toggle dropdown");
|
|
41
|
+
}, "Toggle dropdown"));
|
|
26
42
|
});
|
|
27
|
-
}
|
|
43
|
+
};
|
|
44
|
+
exports.WithRenderFn = WithRenderFn;
|
|
@@ -32,7 +32,7 @@ var EmptySet = function EmptySet(props) {
|
|
|
32
32
|
onClick: handleViewAll
|
|
33
33
|
}, _i18n["default"].VIEW_ALL)] : []));
|
|
34
34
|
return /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
|
|
35
|
-
space: "
|
|
35
|
+
space: "xxxsmall",
|
|
36
36
|
className: _emptySetModule["default"].root
|
|
37
37
|
}, /*#__PURE__*/_react["default"].createElement("p", null, message), filtered && actions.map(function (action, index) {
|
|
38
38
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, index > 0 && ' or ', action);
|
|
@@ -28,16 +28,17 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.filterOnlyButton {
|
|
31
|
-
padding: var(--space-xxxsmall)
|
|
31
|
+
padding: var(--space-xxxsmall);
|
|
32
32
|
display: none;
|
|
33
33
|
appearance: none;
|
|
34
34
|
border: none;
|
|
35
|
-
background: linear-gradient(90deg, rgba(255, 255, 255, 0
|
|
35
|
+
background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--color-highlight) 30%);
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
position: absolute;
|
|
38
38
|
right: 0;
|
|
39
39
|
top: 0;
|
|
40
40
|
bottom: 0;
|
|
41
|
+
font-size: var(--size-small);
|
|
41
42
|
line-height: var(--space-xsmall);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -78,8 +79,11 @@
|
|
|
78
79
|
border: 1px solid var(--color-outline);
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
.filterStandalone:hover
|
|
82
|
+
.filterStandalone:hover .filterCheckbox,
|
|
83
|
+
.filterStandalone:active .filterCheckbox,
|
|
84
|
+
.filterStandalone:focus .filterCheckbox {
|
|
82
85
|
z-index: var(--layout-xlow); /* show collapsed border */
|
|
86
|
+
box-shadow: var(--shadow-layer);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
.filterStandalone:hover .filterCheckbox {
|
|
@@ -102,7 +106,7 @@
|
|
|
102
106
|
margin-top: var(--space-xxxsmall);
|
|
103
107
|
padding-top: var(--space-xxxsmall);
|
|
104
108
|
padding-bottom: var(--space-xxxsmall);
|
|
105
|
-
margin-bottom: calc(0px - var(--space-
|
|
109
|
+
margin-bottom: calc(0px - var(--space-xxxsmall));
|
|
106
110
|
border-top: 1px solid var(--color-outline);
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
width: calc(100vw - 2 * var(--space-small));
|
|
23
23
|
max-width: 340px;
|
|
24
24
|
outline: none;
|
|
25
|
-
filter: drop-shadow(
|
|
25
|
+
filter: drop-shadow(var(--shadow-layer-high));
|
|
26
26
|
will-change: filter;
|
|
27
27
|
background: var(--color-light);
|
|
28
28
|
font-size: var(--size-small);
|
|
@@ -11,7 +11,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
var _dropdown = require("../dropdown");
|
|
12
12
|
var _icon = require("../icon");
|
|
13
13
|
var _sortDropdownModule = _interopRequireDefault(require("./sort-dropdown.module.css"));
|
|
14
|
-
var _excluded = ["
|
|
14
|
+
var _excluded = ["as", "id", "label", "isActive", "direction", "defaultDirection", "getButtonOnClick"];
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -26,18 +26,17 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
26
26
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
27
27
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
28
28
|
var Item = function Item(_ref) {
|
|
29
|
-
var
|
|
30
|
-
Component = _ref.as,
|
|
29
|
+
var Component = _ref.as,
|
|
31
30
|
id = _ref.id,
|
|
32
31
|
label = _ref.label,
|
|
33
|
-
|
|
32
|
+
isActive = _ref.isActive,
|
|
34
33
|
direction = _ref.direction,
|
|
35
34
|
defaultDirection = _ref.defaultDirection,
|
|
36
35
|
getButtonOnClick = _ref.getButtonOnClick,
|
|
37
36
|
restProps = _objectWithoutProperties(_ref, _excluded);
|
|
38
37
|
var buttonProps = (0, _react.useMemo)(function () {
|
|
39
38
|
var resolveNextDirection = defaultDirection;
|
|
40
|
-
if (
|
|
39
|
+
if (isActive) {
|
|
41
40
|
resolveNextDirection = direction === 'asc' ? 'desc' : 'asc';
|
|
42
41
|
}
|
|
43
42
|
if (resolveNextDirection === 'desc') {
|
|
@@ -51,9 +50,10 @@ var Item = function Item(_ref) {
|
|
|
51
50
|
onClick: getButtonOnClick(id, 'asc'),
|
|
52
51
|
title: "Order data by ".concat(label, " ascending")
|
|
53
52
|
};
|
|
54
|
-
}, [
|
|
53
|
+
}, [isActive, direction, defaultDirection, id, label]);
|
|
55
54
|
return /*#__PURE__*/_react["default"].createElement(Component, _extends({}, restProps, buttonProps, {
|
|
56
|
-
|
|
55
|
+
isActive: isActive,
|
|
56
|
+
className: (0, _classnames["default"])(_sortDropdownModule["default"].item, isActive && _sortDropdownModule["default"].itemActive, buttonProps.className)
|
|
57
57
|
}), /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
58
58
|
className: _sortDropdownModule["default"].itemIcon,
|
|
59
59
|
glyph: "arrow"
|
|
@@ -66,7 +66,7 @@ Item.propTypes = {
|
|
|
66
66
|
as: _propTypes["default"].element.isRequired,
|
|
67
67
|
id: _propTypes["default"].string.isRequired,
|
|
68
68
|
label: _propTypes["default"].string.isRequired,
|
|
69
|
-
|
|
69
|
+
isActive: _propTypes["default"].bool.isRequired,
|
|
70
70
|
direction: _propTypes["default"].string.isRequired,
|
|
71
71
|
defaultDirection: _propTypes["default"].string.isRequired,
|
|
72
72
|
getButtonOnClick: _propTypes["default"].func.isRequired
|
|
@@ -108,16 +108,14 @@ var SortDropdown = function SortDropdown(props) {
|
|
|
108
108
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
109
109
|
key = _ref4[0],
|
|
110
110
|
item = _ref4[1];
|
|
111
|
-
var isActive = field === key;
|
|
112
111
|
return /*#__PURE__*/_react["default"].createElement(Item, {
|
|
113
112
|
key: key,
|
|
114
113
|
as: MenuItem,
|
|
115
|
-
|
|
114
|
+
isActive: field === key,
|
|
116
115
|
id: key,
|
|
117
116
|
label: item.label,
|
|
118
117
|
direction: direction,
|
|
119
118
|
defaultDirection: item.defaultDirection,
|
|
120
|
-
active: isActive,
|
|
121
119
|
getButtonOnClick: getButtonOnClick
|
|
122
120
|
});
|
|
123
121
|
}));
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
background: var(--color-light);
|
|
17
17
|
max-width: 24em;
|
|
18
18
|
color: var(--color-text);
|
|
19
|
-
filter: drop-shadow(
|
|
19
|
+
filter: drop-shadow(var(--shadow-layer));
|
|
20
20
|
will-change: filter;
|
|
21
21
|
font-size: var(--size-xsmall);
|
|
22
22
|
line-height: var(--space-small);
|
|
@@ -13,24 +13,11 @@ export const MetricsTableOptions = props => {
|
|
|
13
13
|
return /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
14
14
|
className: className,
|
|
15
15
|
glyph: "menu"
|
|
16
|
-
}, restProps),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = _ref;
|
|
22
|
-
const getButtonOnClick = handler => () => {
|
|
23
|
-
handler();
|
|
24
|
-
menu.toggle();
|
|
25
|
-
};
|
|
26
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, handleResetFilters && /*#__PURE__*/React.createElement(MenuItem, _extends({}, menu, {
|
|
27
|
-
className: menuItemClassName,
|
|
28
|
-
onClick: getButtonOnClick(handleResetFilters)
|
|
29
|
-
}), I18N.RESET_FILTERS), handleViewAll && /*#__PURE__*/React.createElement(MenuItem, _extends({}, menu, {
|
|
30
|
-
className: menuItemClassName,
|
|
31
|
-
onClick: getButtonOnClick(handleViewAll)
|
|
32
|
-
}), I18N.VIEW_ALL));
|
|
33
|
-
});
|
|
16
|
+
}, restProps), handleResetFilters && /*#__PURE__*/React.createElement(Dropdown.Item, {
|
|
17
|
+
onClick: handleResetFilters
|
|
18
|
+
}, I18N.RESET_FILTERS), handleViewAll && /*#__PURE__*/React.createElement(Dropdown.Item, {
|
|
19
|
+
onClick: handleViewAll
|
|
20
|
+
}, I18N.VIEW_ALL));
|
|
34
21
|
};
|
|
35
22
|
MetricsTableOptions.propTypes = {
|
|
36
23
|
className: PropTypes.string,
|
|
@@ -62,7 +62,7 @@ export const SummaryItem = _ref2 => {
|
|
|
62
62
|
const showMetricDescriptionTooltip = showMetricDescription && (metric == null ? void 0 : metric.description);
|
|
63
63
|
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
64
64
|
return /*#__PURE__*/React.createElement(Stack, _extends({
|
|
65
|
-
space: "
|
|
65
|
+
space: "xxxsmall",
|
|
66
66
|
as: Component,
|
|
67
67
|
className: rootClassName
|
|
68
68
|
}, props), /*#__PURE__*/React.createElement(FlexStack, {
|
package/lib-esm/css/default.css
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
@import url("~modern-css-reset/dist/reset.css");
|
|
2
2
|
|
|
3
|
-
:root {
|
|
4
|
-
--chart-height: 180px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
/** modern-css-reset updates */
|
|
8
4
|
pre,
|
|
9
5
|
ul,
|
|
@@ -31,7 +27,6 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
31
27
|
|
|
32
28
|
h1 {
|
|
33
29
|
font-size: var(--size-xxxlarge);
|
|
34
|
-
line-height: var(--space-xlarge)
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
h2 {
|
|
@@ -183,6 +183,9 @@
|
|
|
183
183
|
--layer-high: 1000;
|
|
184
184
|
--layer-xhigh: 10000;
|
|
185
185
|
|
|
186
|
+
--shadow-layer: 0 0 var(--space-xxxsmall) var(--color-shadow);
|
|
187
|
+
--shadow-layer-high: 0 0 var(--space-xxsmall) var(--color-shadow);
|
|
188
|
+
|
|
186
189
|
--radius-small: 3px;
|
|
187
190
|
--radius-medium: 5px;
|
|
188
191
|
--radius-large: 9px;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import cx from 'classnames';
|
|
@@ -5,6 +6,24 @@ import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu';
|
|
|
5
6
|
import { FlexStack } from '../../layout/flex-stack';
|
|
6
7
|
import { Icon } from '../icon';
|
|
7
8
|
import css from './dropdown.module.css';
|
|
9
|
+
const Item = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
className = '',
|
|
12
|
+
isActive = false,
|
|
13
|
+
...restProps
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/React.createElement(MenuItem, _extends({
|
|
16
|
+
className: cx(css.item, className, isActive && css.itemActive)
|
|
17
|
+
}, restProps));
|
|
18
|
+
};
|
|
19
|
+
Item.propTypes = {
|
|
20
|
+
className: PropTypes.string,
|
|
21
|
+
isActive: PropTypes.bool
|
|
22
|
+
};
|
|
23
|
+
Item.defaultProps = {
|
|
24
|
+
className: '',
|
|
25
|
+
isActive: false
|
|
26
|
+
};
|
|
8
27
|
export const Dropdown = props => {
|
|
9
28
|
const {
|
|
10
29
|
className,
|
|
@@ -36,10 +55,10 @@ export const Dropdown = props => {
|
|
|
36
55
|
"aria-label": ariaLabel || label,
|
|
37
56
|
className: css.dropdown
|
|
38
57
|
}, typeof children === 'function' ? children({
|
|
39
|
-
MenuItem,
|
|
58
|
+
MenuItem: Item,
|
|
40
59
|
menu: menuState,
|
|
41
|
-
menuItemClassName: css.
|
|
42
|
-
menuItemActiveClassName: css.
|
|
60
|
+
menuItemClassName: css.item,
|
|
61
|
+
menuItemActiveClassName: css.itemActive
|
|
43
62
|
}) : children));
|
|
44
63
|
};
|
|
45
64
|
Dropdown.defaultProps = {
|
|
@@ -62,4 +81,5 @@ Dropdown.propTypes = {
|
|
|
62
81
|
glyph: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
63
82
|
/** Content */
|
|
64
83
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired
|
|
65
|
-
};
|
|
84
|
+
};
|
|
85
|
+
Dropdown.Item = Item;
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
color: var(--color-text-light);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
.button[aria-expanded=true],
|
|
23
24
|
.button:hover,
|
|
24
25
|
.button:focus,
|
|
25
26
|
.button:active {
|
|
26
27
|
outline: none;
|
|
27
|
-
box-shadow:
|
|
28
|
+
box-shadow: var(--shadow-layer);
|
|
28
29
|
border-color: var(--color-outline-dark);
|
|
29
30
|
color: var(--color-text);
|
|
30
31
|
}
|
|
@@ -34,26 +35,26 @@
|
|
|
34
35
|
left: 0;
|
|
35
36
|
top: 100%;
|
|
36
37
|
border-radius: var(--radius-medium);
|
|
37
|
-
box-shadow:
|
|
38
|
+
box-shadow: var(--shadow-layer-high);
|
|
38
39
|
background: var(--color-background);
|
|
39
|
-
min-width:
|
|
40
|
+
min-width: 12em;
|
|
40
41
|
z-index: var(--layer-high);
|
|
41
|
-
padding: var(--space-
|
|
42
|
+
padding: var(--space-xxxsmall);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
.dropdown:focus {
|
|
45
46
|
outline: none;
|
|
46
|
-
box-shadow: 0 2px var(--space-xsmall) var(--color-shadow);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.
|
|
49
|
+
.item {
|
|
50
50
|
display: block;
|
|
51
51
|
appearance: none;
|
|
52
52
|
cursor: pointer;
|
|
53
53
|
width: 100%;
|
|
54
54
|
outline: none;
|
|
55
55
|
border: 0;
|
|
56
|
-
|
|
56
|
+
border-radius: var(--radius-small);
|
|
57
|
+
padding: calc(var(--space-xxxsmall) / 2) var(--space-xxxsmall);
|
|
57
58
|
background: none;
|
|
58
59
|
text-align: left;
|
|
59
60
|
color: var(--color-text-light);
|
|
@@ -62,14 +63,22 @@
|
|
|
62
63
|
text-decoration: none;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
.
|
|
66
|
+
.item[data-active-item],
|
|
67
|
+
.item:hover,
|
|
68
|
+
.item:focus,
|
|
69
|
+
.item:active {
|
|
70
|
+
background: var(--color-highlight);
|
|
66
71
|
color: var(--color-text);
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
.
|
|
74
|
+
.itemActive {
|
|
75
|
+
background: var(--color-highlight-info);
|
|
70
76
|
color: var(--color-primary);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
.
|
|
79
|
+
.itemActive:hover,
|
|
80
|
+
.itemActive:focus,
|
|
81
|
+
.itemActive:active {
|
|
82
|
+
background: var(--color-highlight-info);
|
|
74
83
|
color: var(--color-primary-dark);
|
|
75
84
|
}
|
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { storiesOf } from '@storybook/react';
|
|
3
2
|
import { getWrapperDecorator } from '../../stories';
|
|
4
3
|
import { Dropdown } from '.';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export default {
|
|
5
|
+
title: 'UI/Dropdown',
|
|
6
|
+
component: Dropdown,
|
|
7
|
+
decorators: [getWrapperDecorator()]
|
|
8
|
+
};
|
|
9
|
+
export const Defualt = () => /*#__PURE__*/React.createElement(Dropdown, {
|
|
8
10
|
glyph: "filter",
|
|
9
11
|
label: "Toggle"
|
|
10
|
-
}, /*#__PURE__*/React.createElement(
|
|
11
|
-
|
|
12
|
+
}, /*#__PURE__*/React.createElement(Dropdown.Item, null, "Option 1"), /*#__PURE__*/React.createElement(Dropdown.Item, null, "Option 2"));
|
|
13
|
+
export const WithRenderFn = () => /*#__PURE__*/React.createElement(Dropdown, {
|
|
12
14
|
glyph: "filter",
|
|
13
15
|
label: "Toggle"
|
|
14
16
|
}, _ref => {
|
|
15
17
|
let {
|
|
18
|
+
MenuItem,
|
|
19
|
+
menuItemClassName,
|
|
16
20
|
menu
|
|
17
21
|
} = _ref;
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
22
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MenuItem, {
|
|
23
|
+
className: menuItemClassName
|
|
24
|
+
}, "Option 1"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
25
|
+
className: menuItemClassName
|
|
26
|
+
}, "Option 2"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
27
|
+
className: menuItemClassName
|
|
28
|
+
}, "Option 3"), /*#__PURE__*/React.createElement("button", {
|
|
19
29
|
type: "button",
|
|
20
30
|
onClick: menu.toggle
|
|
21
|
-
}, "Toggle dropdown");
|
|
22
|
-
})
|
|
31
|
+
}, "Toggle dropdown"));
|
|
32
|
+
});
|
|
@@ -21,7 +21,7 @@ export const EmptySet = props => {
|
|
|
21
21
|
onClick: handleViewAll
|
|
22
22
|
}, I18N.VIEW_ALL)] : [])];
|
|
23
23
|
return /*#__PURE__*/React.createElement(Stack, {
|
|
24
|
-
space: "
|
|
24
|
+
space: "xxxsmall",
|
|
25
25
|
className: css.root
|
|
26
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,16 +28,17 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.filterOnlyButton {
|
|
31
|
-
padding: var(--space-xxxsmall)
|
|
31
|
+
padding: var(--space-xxxsmall);
|
|
32
32
|
display: none;
|
|
33
33
|
appearance: none;
|
|
34
34
|
border: none;
|
|
35
|
-
background: linear-gradient(90deg, rgba(255, 255, 255, 0
|
|
35
|
+
background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--color-highlight) 30%);
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
position: absolute;
|
|
38
38
|
right: 0;
|
|
39
39
|
top: 0;
|
|
40
40
|
bottom: 0;
|
|
41
|
+
font-size: var(--size-small);
|
|
41
42
|
line-height: var(--space-xsmall);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -78,8 +79,11 @@
|
|
|
78
79
|
border: 1px solid var(--color-outline);
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
.filterStandalone:hover
|
|
82
|
+
.filterStandalone:hover .filterCheckbox,
|
|
83
|
+
.filterStandalone:active .filterCheckbox,
|
|
84
|
+
.filterStandalone:focus .filterCheckbox {
|
|
82
85
|
z-index: var(--layout-xlow); /* show collapsed border */
|
|
86
|
+
box-shadow: var(--shadow-layer);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
.filterStandalone:hover .filterCheckbox {
|
|
@@ -102,7 +106,7 @@
|
|
|
102
106
|
margin-top: var(--space-xxxsmall);
|
|
103
107
|
padding-top: var(--space-xxxsmall);
|
|
104
108
|
padding-bottom: var(--space-xxxsmall);
|
|
105
|
-
margin-bottom: calc(0px - var(--space-
|
|
109
|
+
margin-bottom: calc(0px - var(--space-xxxsmall));
|
|
106
110
|
border-top: 1px solid var(--color-outline);
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
width: calc(100vw - 2 * var(--space-small));
|
|
23
23
|
max-width: 340px;
|
|
24
24
|
outline: none;
|
|
25
|
-
filter: drop-shadow(
|
|
25
|
+
filter: drop-shadow(var(--shadow-layer-high));
|
|
26
26
|
will-change: filter;
|
|
27
27
|
background: var(--color-light);
|
|
28
28
|
font-size: var(--size-small);
|
|
@@ -7,11 +7,10 @@ import { Icon } from '../icon';
|
|
|
7
7
|
import css from './sort-dropdown.module.css';
|
|
8
8
|
const Item = _ref => {
|
|
9
9
|
let {
|
|
10
|
-
className,
|
|
11
10
|
as: Component,
|
|
12
11
|
id,
|
|
13
12
|
label,
|
|
14
|
-
|
|
13
|
+
isActive,
|
|
15
14
|
direction,
|
|
16
15
|
defaultDirection,
|
|
17
16
|
getButtonOnClick,
|
|
@@ -19,7 +18,7 @@ const Item = _ref => {
|
|
|
19
18
|
} = _ref;
|
|
20
19
|
const buttonProps = useMemo(() => {
|
|
21
20
|
let resolveNextDirection = defaultDirection;
|
|
22
|
-
if (
|
|
21
|
+
if (isActive) {
|
|
23
22
|
resolveNextDirection = direction === 'asc' ? 'desc' : 'asc';
|
|
24
23
|
}
|
|
25
24
|
if (resolveNextDirection === 'desc') {
|
|
@@ -33,9 +32,10 @@ const Item = _ref => {
|
|
|
33
32
|
onClick: getButtonOnClick(id, 'asc'),
|
|
34
33
|
title: `Order data by ${label} ascending`
|
|
35
34
|
};
|
|
36
|
-
}, [
|
|
35
|
+
}, [isActive, direction, defaultDirection, id, label]);
|
|
37
36
|
return /*#__PURE__*/React.createElement(Component, _extends({}, restProps, buttonProps, {
|
|
38
|
-
|
|
37
|
+
isActive: isActive,
|
|
38
|
+
className: cx(css.item, isActive && css.itemActive, buttonProps.className)
|
|
39
39
|
}), /*#__PURE__*/React.createElement(Icon, {
|
|
40
40
|
className: css.itemIcon,
|
|
41
41
|
glyph: "arrow"
|
|
@@ -48,7 +48,7 @@ Item.propTypes = {
|
|
|
48
48
|
as: PropTypes.element.isRequired,
|
|
49
49
|
id: PropTypes.string.isRequired,
|
|
50
50
|
label: PropTypes.string.isRequired,
|
|
51
|
-
|
|
51
|
+
isActive: PropTypes.bool.isRequired,
|
|
52
52
|
direction: PropTypes.string.isRequired,
|
|
53
53
|
defaultDirection: PropTypes.string.isRequired,
|
|
54
54
|
getButtonOnClick: PropTypes.func.isRequired
|
|
@@ -90,16 +90,14 @@ export const SortDropdown = props => {
|
|
|
90
90
|
className: css.items
|
|
91
91
|
}, Object.entries(fields).map(_ref3 => {
|
|
92
92
|
let [key, item] = _ref3;
|
|
93
|
-
const isActive = field === key;
|
|
94
93
|
return /*#__PURE__*/React.createElement(Item, {
|
|
95
94
|
key: key,
|
|
96
95
|
as: MenuItem,
|
|
97
|
-
|
|
96
|
+
isActive: field === key,
|
|
98
97
|
id: key,
|
|
99
98
|
label: item.label,
|
|
100
99
|
direction: direction,
|
|
101
100
|
defaultDirection: item.defaultDirection,
|
|
102
|
-
active: isActive,
|
|
103
101
|
getButtonOnClick: getButtonOnClick
|
|
104
102
|
});
|
|
105
103
|
}));
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
background: var(--color-light);
|
|
17
17
|
max-width: 24em;
|
|
18
18
|
color: var(--color-text);
|
|
19
|
-
filter: drop-shadow(
|
|
19
|
+
filter: drop-shadow(var(--shadow-layer));
|
|
20
20
|
will-change: filter;
|
|
21
21
|
font-size: var(--size-xsmall);
|
|
22
22
|
line-height: var(--space-small);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundle-stats/ui",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5-alpha.0",
|
|
4
4
|
"description": "UI components for BundleStats projects.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -64,15 +64,16 @@
|
|
|
64
64
|
"enzyme-to-json": "3.6.2",
|
|
65
65
|
"hex-rgb": "5.0.0",
|
|
66
66
|
"identity-obj-proxy": "3.0.0",
|
|
67
|
-
"jest": "
|
|
67
|
+
"jest": "29.3.1",
|
|
68
68
|
"jest-date-mock": "1.0.8",
|
|
69
|
+
"jest-environment-jsdom": "29.3.1",
|
|
69
70
|
"lodash": "4.17.21",
|
|
70
71
|
"postcss": "8.4.19",
|
|
71
72
|
"prop-types": "15.8.1",
|
|
72
73
|
"react": "16.14.0",
|
|
73
74
|
"react-dom": "16.14.0",
|
|
74
75
|
"react-router-dom": "5.3.4",
|
|
75
|
-
"react-test-renderer": "
|
|
76
|
+
"react-test-renderer": "18.2.0",
|
|
76
77
|
"rimraf": "3.0.2"
|
|
77
78
|
},
|
|
78
79
|
"peerDependencies": {
|
|
@@ -85,12 +86,12 @@
|
|
|
85
86
|
"react-router-dom": "^5.0.0"
|
|
86
87
|
},
|
|
87
88
|
"dependencies": {
|
|
88
|
-
"@bundle-stats/utils": "^4.1.
|
|
89
|
+
"@bundle-stats/utils": "^4.1.5-alpha.0",
|
|
89
90
|
"ariakit": "^2.0.0-next.41",
|
|
90
91
|
"date-fns": "^2.28.0",
|
|
91
92
|
"modern-css-reset": "^1.4.0",
|
|
92
93
|
"query-string": "^7.1.0",
|
|
93
94
|
"use-query-params": "^2.0.0"
|
|
94
95
|
},
|
|
95
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "3f5b443f86d7b29c35dd8d7a894018b8e1b82014"
|
|
96
97
|
}
|
|
@@ -9,35 +9,16 @@ export const MetricsTableOptions = (props) => {
|
|
|
9
9
|
|
|
10
10
|
return (
|
|
11
11
|
<Dropdown className={className} glyph="menu" {...restProps}>
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{...menu}
|
|
23
|
-
className={menuItemClassName}
|
|
24
|
-
onClick={getButtonOnClick(handleResetFilters)}
|
|
25
|
-
>
|
|
26
|
-
{I18N.RESET_FILTERS}
|
|
27
|
-
</MenuItem>
|
|
28
|
-
)}
|
|
29
|
-
{handleViewAll && (
|
|
30
|
-
<MenuItem
|
|
31
|
-
{...menu}
|
|
32
|
-
className={menuItemClassName}
|
|
33
|
-
onClick={getButtonOnClick(handleViewAll)}
|
|
34
|
-
>
|
|
35
|
-
{I18N.VIEW_ALL}
|
|
36
|
-
</MenuItem>
|
|
37
|
-
)}
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
}}
|
|
12
|
+
{handleResetFilters && (
|
|
13
|
+
<Dropdown.Item onClick={handleResetFilters}>
|
|
14
|
+
{I18N.RESET_FILTERS}
|
|
15
|
+
</Dropdown.Item>
|
|
16
|
+
)}
|
|
17
|
+
{handleViewAll && (
|
|
18
|
+
<Dropdown.Item onClick={handleViewAll}>
|
|
19
|
+
{I18N.VIEW_ALL}
|
|
20
|
+
</Dropdown.Item>
|
|
21
|
+
)}
|
|
41
22
|
</Dropdown>
|
|
42
23
|
);
|
|
43
24
|
};
|
|
@@ -64,7 +64,7 @@ export const SummaryItem = ({
|
|
|
64
64
|
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
|
-
<Stack space="
|
|
67
|
+
<Stack space="xxxsmall" as={Component} className={rootClassName} {...props}>
|
|
68
68
|
<FlexStack space="xxxsmall" alignItems="center" as="h3" className={css.title}>
|
|
69
69
|
<span>
|
|
70
70
|
{metric.label}
|
package/src/css/default.css
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
@import url("~modern-css-reset/dist/reset.css");
|
|
2
2
|
|
|
3
|
-
:root {
|
|
4
|
-
--chart-height: 180px;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
3
|
/** modern-css-reset updates */
|
|
8
4
|
pre,
|
|
9
5
|
ul,
|
|
@@ -31,7 +27,6 @@ h1, h2, h3, h4, h5, h6 {
|
|
|
31
27
|
|
|
32
28
|
h1 {
|
|
33
29
|
font-size: var(--size-xxxlarge);
|
|
34
|
-
line-height: var(--space-xlarge)
|
|
35
30
|
}
|
|
36
31
|
|
|
37
32
|
h2 {
|
package/src/css/variables.css
CHANGED
|
@@ -183,6 +183,9 @@
|
|
|
183
183
|
--layer-high: 1000;
|
|
184
184
|
--layer-xhigh: 10000;
|
|
185
185
|
|
|
186
|
+
--shadow-layer: 0 0 var(--space-xxxsmall) var(--color-shadow);
|
|
187
|
+
--shadow-layer-high: 0 0 var(--space-xxsmall) var(--color-shadow);
|
|
188
|
+
|
|
186
189
|
--radius-small: 3px;
|
|
187
190
|
--radius-medium: 5px;
|
|
188
191
|
--radius-large: 9px;
|
|
@@ -7,6 +7,20 @@ import { FlexStack } from '../../layout/flex-stack';
|
|
|
7
7
|
import { Icon } from '../icon';
|
|
8
8
|
import css from './dropdown.module.css';
|
|
9
9
|
|
|
10
|
+
const Item = ({ className = '', isActive = false, ...restProps }) => (
|
|
11
|
+
<MenuItem className={cx(css.item, className, isActive && css.itemActive)} {...restProps} />
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
Item.propTypes = {
|
|
15
|
+
className: PropTypes.string,
|
|
16
|
+
isActive: PropTypes.bool,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
Item.defaultProps = {
|
|
20
|
+
className: '',
|
|
21
|
+
isActive: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
10
24
|
export const Dropdown = (props) => {
|
|
11
25
|
const { className, buttonClassName, label, ariaLabel, glyph, children } = props;
|
|
12
26
|
const rootClassName = cx(css.root, className);
|
|
@@ -23,10 +37,10 @@ export const Dropdown = (props) => {
|
|
|
23
37
|
<Menu state={menuState} aria-label={ariaLabel || label} className={css.dropdown}>
|
|
24
38
|
{typeof children === 'function'
|
|
25
39
|
? children({
|
|
26
|
-
MenuItem,
|
|
40
|
+
MenuItem: Item,
|
|
27
41
|
menu: menuState,
|
|
28
|
-
menuItemClassName: css.
|
|
29
|
-
menuItemActiveClassName: css.
|
|
42
|
+
menuItemClassName: css.item,
|
|
43
|
+
menuItemActiveClassName: css.itemActive,
|
|
30
44
|
})
|
|
31
45
|
: children}
|
|
32
46
|
</Menu>
|
|
@@ -61,3 +75,5 @@ Dropdown.propTypes = {
|
|
|
61
75
|
/** Content */
|
|
62
76
|
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,
|
|
63
77
|
};
|
|
78
|
+
|
|
79
|
+
Dropdown.Item = Item;
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
color: var(--color-text-light);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
.button[aria-expanded=true],
|
|
23
24
|
.button:hover,
|
|
24
25
|
.button:focus,
|
|
25
26
|
.button:active {
|
|
26
27
|
outline: none;
|
|
27
|
-
box-shadow:
|
|
28
|
+
box-shadow: var(--shadow-layer);
|
|
28
29
|
border-color: var(--color-outline-dark);
|
|
29
30
|
color: var(--color-text);
|
|
30
31
|
}
|
|
@@ -34,26 +35,26 @@
|
|
|
34
35
|
left: 0;
|
|
35
36
|
top: 100%;
|
|
36
37
|
border-radius: var(--radius-medium);
|
|
37
|
-
box-shadow:
|
|
38
|
+
box-shadow: var(--shadow-layer-high);
|
|
38
39
|
background: var(--color-background);
|
|
39
|
-
min-width:
|
|
40
|
+
min-width: 12em;
|
|
40
41
|
z-index: var(--layer-high);
|
|
41
|
-
padding: var(--space-
|
|
42
|
+
padding: var(--space-xxxsmall);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
.dropdown:focus {
|
|
45
46
|
outline: none;
|
|
46
|
-
box-shadow: 0 2px var(--space-xsmall) var(--color-shadow);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
.
|
|
49
|
+
.item {
|
|
50
50
|
display: block;
|
|
51
51
|
appearance: none;
|
|
52
52
|
cursor: pointer;
|
|
53
53
|
width: 100%;
|
|
54
54
|
outline: none;
|
|
55
55
|
border: 0;
|
|
56
|
-
|
|
56
|
+
border-radius: var(--radius-small);
|
|
57
|
+
padding: calc(var(--space-xxxsmall) / 2) var(--space-xxxsmall);
|
|
57
58
|
background: none;
|
|
58
59
|
text-align: left;
|
|
59
60
|
color: var(--color-text-light);
|
|
@@ -62,14 +63,22 @@
|
|
|
62
63
|
text-decoration: none;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
|
-
.
|
|
66
|
+
.item[data-active-item],
|
|
67
|
+
.item:hover,
|
|
68
|
+
.item:focus,
|
|
69
|
+
.item:active {
|
|
70
|
+
background: var(--color-highlight);
|
|
66
71
|
color: var(--color-text);
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
.
|
|
74
|
+
.itemActive {
|
|
75
|
+
background: var(--color-highlight-info);
|
|
70
76
|
color: var(--color-primary);
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
.
|
|
79
|
+
.itemActive:hover,
|
|
80
|
+
.itemActive:focus,
|
|
81
|
+
.itemActive:active {
|
|
82
|
+
background: var(--color-highlight-info);
|
|
74
83
|
color: var(--color-primary-dark);
|
|
75
84
|
}
|
|
@@ -28,16 +28,17 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.filterOnlyButton {
|
|
31
|
-
padding: var(--space-xxxsmall)
|
|
31
|
+
padding: var(--space-xxxsmall);
|
|
32
32
|
display: none;
|
|
33
33
|
appearance: none;
|
|
34
34
|
border: none;
|
|
35
|
-
background: linear-gradient(90deg, rgba(255, 255, 255, 0
|
|
35
|
+
background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--color-highlight) 30%);
|
|
36
36
|
cursor: pointer;
|
|
37
37
|
position: absolute;
|
|
38
38
|
right: 0;
|
|
39
39
|
top: 0;
|
|
40
40
|
bottom: 0;
|
|
41
|
+
font-size: var(--size-small);
|
|
41
42
|
line-height: var(--space-xsmall);
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -78,8 +79,11 @@
|
|
|
78
79
|
border: 1px solid var(--color-outline);
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
.filterStandalone:hover
|
|
82
|
+
.filterStandalone:hover .filterCheckbox,
|
|
83
|
+
.filterStandalone:active .filterCheckbox,
|
|
84
|
+
.filterStandalone:focus .filterCheckbox {
|
|
82
85
|
z-index: var(--layout-xlow); /* show collapsed border */
|
|
86
|
+
box-shadow: var(--shadow-layer);
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
.filterStandalone:hover .filterCheckbox {
|
|
@@ -102,7 +106,7 @@
|
|
|
102
106
|
margin-top: var(--space-xxxsmall);
|
|
103
107
|
padding-top: var(--space-xxxsmall);
|
|
104
108
|
padding-bottom: var(--space-xxxsmall);
|
|
105
|
-
margin-bottom: calc(0px - var(--space-
|
|
109
|
+
margin-bottom: calc(0px - var(--space-xxxsmall));
|
|
106
110
|
border-top: 1px solid var(--color-outline);
|
|
107
111
|
}
|
|
108
112
|
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
width: calc(100vw - 2 * var(--space-small));
|
|
23
23
|
max-width: 340px;
|
|
24
24
|
outline: none;
|
|
25
|
-
filter: drop-shadow(
|
|
25
|
+
filter: drop-shadow(var(--shadow-layer-high));
|
|
26
26
|
will-change: filter;
|
|
27
27
|
background: var(--color-light);
|
|
28
28
|
font-size: var(--size-small);
|
|
@@ -7,20 +7,20 @@ import { Icon } from '../icon';
|
|
|
7
7
|
import css from './sort-dropdown.module.css';
|
|
8
8
|
|
|
9
9
|
const Item = ({
|
|
10
|
-
className,
|
|
11
10
|
as: Component,
|
|
12
11
|
id,
|
|
13
12
|
label,
|
|
14
|
-
|
|
13
|
+
isActive,
|
|
15
14
|
direction,
|
|
16
15
|
defaultDirection,
|
|
17
16
|
getButtonOnClick,
|
|
18
|
-
...restProps
|
|
17
|
+
...restProps
|
|
18
|
+
}) => {
|
|
19
19
|
|
|
20
20
|
const buttonProps = useMemo(() => {
|
|
21
21
|
let resolveNextDirection = defaultDirection;
|
|
22
22
|
|
|
23
|
-
if (
|
|
23
|
+
if (isActive) {
|
|
24
24
|
resolveNextDirection = direction === 'asc' ? 'desc' : 'asc';
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -36,13 +36,14 @@ const Item = ({
|
|
|
36
36
|
onClick: getButtonOnClick(id, 'asc'),
|
|
37
37
|
title: `Order data by ${label} ascending`,
|
|
38
38
|
};
|
|
39
|
-
}, [
|
|
39
|
+
}, [isActive, direction, defaultDirection, id, label]);
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
42
|
<Component
|
|
43
43
|
{...restProps}
|
|
44
44
|
{...buttonProps}
|
|
45
|
-
|
|
45
|
+
isActive={isActive}
|
|
46
|
+
className={cx(css.item, isActive && css.itemActive, buttonProps.className)}
|
|
46
47
|
>
|
|
47
48
|
<Icon className={css.itemIcon} glyph="arrow" />
|
|
48
49
|
<span className={css.itemLabel}>{label}</span>
|
|
@@ -55,7 +56,7 @@ Item.propTypes = {
|
|
|
55
56
|
as: PropTypes.element.isRequired,
|
|
56
57
|
id: PropTypes.string.isRequired,
|
|
57
58
|
label: PropTypes.string.isRequired,
|
|
58
|
-
|
|
59
|
+
isActive: PropTypes.bool.isRequired,
|
|
59
60
|
direction: PropTypes.string.isRequired,
|
|
60
61
|
defaultDirection: PropTypes.string.isRequired,
|
|
61
62
|
getButtonOnClick: PropTypes.func.isRequired,
|
|
@@ -81,23 +82,18 @@ export const SortDropdown = (props) => {
|
|
|
81
82
|
|
|
82
83
|
return (
|
|
83
84
|
<div className={css.items}>
|
|
84
|
-
{Object.entries(fields).map(([key, item]) =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
active={isActive}
|
|
97
|
-
getButtonOnClick={getButtonOnClick}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
})}
|
|
85
|
+
{Object.entries(fields).map(([key, item]) => (
|
|
86
|
+
<Item
|
|
87
|
+
key={key}
|
|
88
|
+
as={MenuItem}
|
|
89
|
+
isActive={field === key}
|
|
90
|
+
id={key}
|
|
91
|
+
label={item.label}
|
|
92
|
+
direction={direction}
|
|
93
|
+
defaultDirection={item.defaultDirection}
|
|
94
|
+
getButtonOnClick={getButtonOnClick}
|
|
95
|
+
/>
|
|
96
|
+
))}
|
|
101
97
|
</div>
|
|
102
98
|
);
|
|
103
99
|
}}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
background: var(--color-light);
|
|
17
17
|
max-width: 24em;
|
|
18
18
|
color: var(--color-text);
|
|
19
|
-
filter: drop-shadow(
|
|
19
|
+
filter: drop-shadow(var(--shadow-layer));
|
|
20
20
|
will-change: filter;
|
|
21
21
|
font-size: var(--size-xsmall);
|
|
22
22
|
line-height: var(--space-small);
|