@bundle-stats/ui 3.2.3 → 3.2.4-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/CHANGELOG.md +17 -0
- package/lib/components/bundle-assets/bundle-assets.js +9 -7
- package/lib/components/bundle-assets/bundle-assets.module.css +5 -0
- package/lib/components/bundle-modules/bundle-modules.js +34 -63
- package/lib/components/bundle-modules/bundle-modules.module.css +0 -4
- package/lib/components/bundle-packages/bundle-packages.js +29 -24
- package/lib/components/bundle-packages/bundle-packages.module.css +37 -20
- package/lib/components/metrics-table-title/metrics-table-title.js +7 -3
- package/lib/components/summary-item/summary-item.js +16 -18
- package/lib/components/total-size-type-title/total-size-type-title.js +7 -3
- package/lib/ui/dropdown/dropdown.js +15 -19
- package/lib/ui/filters/filters.js +3 -5
- package/lib/ui/hover-card/hover-card.js +65 -0
- package/lib/ui/hover-card/hover-card.module.css +29 -0
- package/lib/ui/hover-card/hover-card.stories.js +26 -0
- package/lib/ui/{popover → hover-card}/index.js +4 -4
- package/lib/ui/icon/icon.module.css +1 -0
- package/lib/ui/index.js +8 -8
- package/lib/ui/sort-dropdown/sort-dropdown.js +2 -5
- package/lib/ui/tooltip/tooltip.js +22 -14
- package/lib/ui/tooltip/tooltip.module.css +5 -3
- package/lib-esm/components/bundle-assets/bundle-assets.js +9 -7
- package/lib-esm/components/bundle-assets/bundle-assets.module.css +5 -0
- package/lib-esm/components/bundle-modules/bundle-modules.js +17 -29
- package/lib-esm/components/bundle-modules/bundle-modules.module.css +0 -4
- package/lib-esm/components/bundle-packages/bundle-packages.js +28 -23
- package/lib-esm/components/bundle-packages/bundle-packages.module.css +37 -20
- package/lib-esm/components/metrics-table-title/metrics-table-title.js +6 -3
- package/lib-esm/components/summary-item/summary-item.js +15 -18
- package/lib-esm/components/total-size-type-title/total-size-type-title.js +6 -3
- package/lib-esm/ui/dropdown/dropdown.js +9 -19
- package/lib-esm/ui/filters/filters.js +3 -5
- package/lib-esm/ui/hover-card/hover-card.js +45 -0
- package/lib-esm/ui/hover-card/hover-card.module.css +29 -0
- package/lib-esm/ui/hover-card/hover-card.stories.js +9 -0
- package/lib-esm/ui/hover-card/index.js +1 -0
- package/lib-esm/ui/icon/icon.module.css +1 -0
- package/lib-esm/ui/index.js +1 -1
- package/lib-esm/ui/sort-dropdown/sort-dropdown.js +2 -5
- package/lib-esm/ui/tooltip/tooltip.js +15 -14
- package/lib-esm/ui/tooltip/tooltip.module.css +5 -3
- package/package.json +25 -22
- package/src/components/bundle-assets/bundle-assets.jsx +51 -42
- package/src/components/bundle-assets/bundle-assets.module.css +5 -0
- package/src/components/bundle-modules/bundle-modules.jsx +28 -31
- package/src/components/bundle-modules/bundle-modules.module.css +0 -4
- package/src/components/bundle-packages/bundle-packages.jsx +31 -25
- package/src/components/bundle-packages/bundle-packages.module.css +37 -20
- package/src/components/metrics-table-options/metrics-table-options.jsx +1 -1
- package/src/components/metrics-table-title/metrics-table-title.jsx +4 -3
- package/src/components/summary-item/summary-item.jsx +21 -26
- package/src/components/total-size-type-title/total-size-type-title.jsx +6 -9
- package/src/ui/dropdown/dropdown.jsx +14 -18
- package/src/ui/filters/filters.jsx +30 -39
- package/src/ui/hover-card/hover-card.jsx +42 -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.module.css +1 -0
- package/src/ui/index.js +1 -1
- package/src/ui/sort-dropdown/sort-dropdown.jsx +9 -11
- package/src/ui/tooltip/tooltip.jsx +20 -27
- package/src/ui/tooltip/tooltip.module.css +5 -3
- 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
|
@@ -18,25 +18,15 @@ const Filter = (props) => {
|
|
|
18
18
|
<div className={rootClassName}>
|
|
19
19
|
{/* eslint-disable */}
|
|
20
20
|
<FlexStack space="xxxsmall" as="label" className={css.filterCheckbox}>
|
|
21
|
-
|
|
22
|
-
<input
|
|
23
|
-
className={css.filterInput}
|
|
24
|
-
type="checkbox"
|
|
25
|
-
id={id}
|
|
26
|
-
name={name}
|
|
27
|
-
{...inputProps}
|
|
28
|
-
/>
|
|
21
|
+
{/* eslint-enabled */}
|
|
22
|
+
<input className={css.filterInput} type="checkbox" id={id} name={name} {...inputProps} />
|
|
29
23
|
<span className={css.filterLabel} title={label}>
|
|
30
24
|
{label}
|
|
31
25
|
</span>
|
|
32
26
|
</FlexStack>
|
|
33
27
|
|
|
34
28
|
{getOnOnlyClick && (
|
|
35
|
-
<button
|
|
36
|
-
className={css.filterOnlyButton}
|
|
37
|
-
type="button"
|
|
38
|
-
onClick={getOnOnlyClick(name)}
|
|
39
|
-
>
|
|
29
|
+
<button className={css.filterOnlyButton} type="button" onClick={getOnOnlyClick(name)}>
|
|
40
30
|
only
|
|
41
31
|
</button>
|
|
42
32
|
)}
|
|
@@ -62,8 +52,12 @@ const FilterGroup = (props) => {
|
|
|
62
52
|
const { label: groupLabel, ...groupData } = data;
|
|
63
53
|
|
|
64
54
|
const groupItems = Object.entries(groupData);
|
|
65
|
-
const groupCheckboxes = groupItems.filter(
|
|
66
|
-
|
|
55
|
+
const groupCheckboxes = groupItems.filter(
|
|
56
|
+
([itemKey, item]) => typeof item?.defaultValue !== 'undefined',
|
|
57
|
+
);
|
|
58
|
+
const isGroupChecked = groupCheckboxes
|
|
59
|
+
.map(([itemKey]) => get(values, `${groupKey}.${itemKey}`))
|
|
60
|
+
.reduce((agg, val) => agg && val, true);
|
|
67
61
|
|
|
68
62
|
const filterSuffix = getGroupFiltersLabelSuffix(groupItems);
|
|
69
63
|
const hasCustomFilterSuffix = !Object.values(LABELS).includes(filterSuffix);
|
|
@@ -71,27 +65,30 @@ const FilterGroup = (props) => {
|
|
|
71
65
|
<>
|
|
72
66
|
{`${groupLabel}:`}
|
|
73
67
|
|
|
74
|
-
<span className={cx(hasCustomFilterSuffix && css.labelSuffixCustom)}>
|
|
75
|
-
{filterSuffix}
|
|
76
|
-
</span>
|
|
68
|
+
<span className={cx(hasCustomFilterSuffix && css.labelSuffixCustom)}>{filterSuffix}</span>
|
|
77
69
|
</>
|
|
78
70
|
);
|
|
79
71
|
|
|
80
|
-
const getOnGroupCheck =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
const getOnGroupCheck =
|
|
73
|
+
(value, overrides = {}) =>
|
|
74
|
+
() => {
|
|
75
|
+
const newFilters = groupCheckboxes.reduce(
|
|
76
|
+
(agg, [itemKey]) => ({
|
|
77
|
+
...agg,
|
|
78
|
+
[`${groupKey}.${itemKey}`]: value,
|
|
79
|
+
}),
|
|
80
|
+
{},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
toggleFilters({
|
|
84
|
+
...newFilters,
|
|
85
|
+
...overrides,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
91
88
|
|
|
92
89
|
return (
|
|
93
90
|
<Dropdown label={dropdownLabel} ariaLabel={`${groupLabel}: ${filterSuffix}`}>
|
|
94
|
-
{({ MenuItem,
|
|
91
|
+
{({ MenuItem, menuItemClassName }) => {
|
|
95
92
|
return (
|
|
96
93
|
<>
|
|
97
94
|
<div className={css.filterGroupItems}>
|
|
@@ -100,7 +97,7 @@ const FilterGroup = (props) => {
|
|
|
100
97
|
const getOnOnlyClick = () => getOnGroupCheck(false, { [id]: true });
|
|
101
98
|
|
|
102
99
|
return (
|
|
103
|
-
<MenuItem key={id}
|
|
100
|
+
<MenuItem key={id} className={cx(menuItemClassName, css.filterGroupItem)}>
|
|
104
101
|
<Filter
|
|
105
102
|
name={id}
|
|
106
103
|
label={itemData.label}
|
|
@@ -138,7 +135,7 @@ const FilterGroup = (props) => {
|
|
|
138
135
|
</div>
|
|
139
136
|
</>
|
|
140
137
|
);
|
|
141
|
-
|
|
138
|
+
}}
|
|
142
139
|
</Dropdown>
|
|
143
140
|
);
|
|
144
141
|
};
|
|
@@ -152,13 +149,7 @@ FilterGroup.propTypes = {
|
|
|
152
149
|
};
|
|
153
150
|
|
|
154
151
|
export const Filters = (props) => {
|
|
155
|
-
const {
|
|
156
|
-
className,
|
|
157
|
-
values,
|
|
158
|
-
filters,
|
|
159
|
-
toggleFilter,
|
|
160
|
-
toggleFilters,
|
|
161
|
-
} = props;
|
|
152
|
+
const { className, values, filters, toggleFilter, toggleFilters } = props;
|
|
162
153
|
|
|
163
154
|
const onCheckboxChange = ({ target }) => toggleFilter(target.name, target.checked);
|
|
164
155
|
const rootClassName = cx(css.root, className);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import * as BaseHoverCard from '@radix-ui/react-hover-card';
|
|
5
|
+
|
|
6
|
+
import css from './hover-card.module.css';
|
|
7
|
+
|
|
8
|
+
const OFFSET = 8;
|
|
9
|
+
const DELAY = 300;
|
|
10
|
+
|
|
11
|
+
const propTypes = {
|
|
12
|
+
className: PropTypes.string,
|
|
13
|
+
label: PropTypes.element.isRequired,
|
|
14
|
+
side: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
|
|
15
|
+
children: PropTypes.element.isRequired,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const defaultProps = {
|
|
19
|
+
className: '',
|
|
20
|
+
side: 'top',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {PropTypes.InferProps<typeof propTypes>} props
|
|
25
|
+
* @return {React.FunctionComponentElement}
|
|
26
|
+
*/
|
|
27
|
+
export const HoverCard = (props) => {
|
|
28
|
+
const { className, label, side, children } = props;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<BaseHoverCard.Root openDelay={DELAY} closeDelay={DELAY}>
|
|
32
|
+
<BaseHoverCard.Trigger className={cx(css.label, className)}>{label}</BaseHoverCard.Trigger>
|
|
33
|
+
<BaseHoverCard.Content className={css.card} sideOffset={OFFSET} side={side}>
|
|
34
|
+
<BaseHoverCard.Arrow className={css.arrow} offset={OFFSET} />
|
|
35
|
+
{children}
|
|
36
|
+
</BaseHoverCard.Content>
|
|
37
|
+
</BaseHoverCard.Root>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
HoverCard.propTypes = propTypes;
|
|
42
|
+
HoverCard.defaultProps = defaultProps;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.label {
|
|
2
|
+
color: inherit;
|
|
3
|
+
cursor: pointer;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.label:hover,
|
|
7
|
+
.label:focus,
|
|
8
|
+
.label:active {
|
|
9
|
+
color: var(--color-primary);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.label:hover {
|
|
13
|
+
text-decoration: underline;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.card {
|
|
17
|
+
padding: var(--space-small);
|
|
18
|
+
border-radius: var(--radius-small);
|
|
19
|
+
width: 320px;
|
|
20
|
+
outline: none;
|
|
21
|
+
filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
|
|
22
|
+
background: var(--color-light);
|
|
23
|
+
font-size: var(--size-small);
|
|
24
|
+
line-height: 1.6;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.arrow {
|
|
28
|
+
fill: var(--color-light);
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hover-card';
|
package/src/ui/index.js
CHANGED
|
@@ -7,10 +7,10 @@ export { Filters } from './filters';
|
|
|
7
7
|
export { HorizontalBarChart } from './horizontal-bar-chart';
|
|
8
8
|
export { Icon } from './icon';
|
|
9
9
|
export { Input } from './input';
|
|
10
|
+
export { HoverCard } from './hover-card';
|
|
10
11
|
export { Loader } from './loader';
|
|
11
12
|
export { Logo } from './logo';
|
|
12
13
|
export { Panels } from './panels';
|
|
13
|
-
export { Popover } from './popover';
|
|
14
14
|
export { Skeleton } from './skeleton';
|
|
15
15
|
export { SortDropdown } from './sort-dropdown';
|
|
16
16
|
export { Table } from './table';
|
|
@@ -13,11 +13,10 @@ export const SortDropdown = (props) => {
|
|
|
13
13
|
const customLabel = fields[field] ? `Ordered by ${fields[field].label}` : label;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
|
-
<Dropdown className={rootClassName} label={customLabel} glyph="sort"
|
|
17
|
-
{({ MenuItem,
|
|
16
|
+
<Dropdown className={rootClassName} label={customLabel} glyph="sort">
|
|
17
|
+
{({ MenuItem, menuItemClassName, menuItemActiveClassName }) => {
|
|
18
18
|
const getButtonOnClick = (newField, newDirection) => () => {
|
|
19
19
|
onChange({ field: newField, direction: newDirection });
|
|
20
|
-
menu.toggle();
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
return (
|
|
@@ -26,21 +25,20 @@ export const SortDropdown = (props) => {
|
|
|
26
25
|
const buttonProps =
|
|
27
26
|
direction === 'asc'
|
|
28
27
|
? {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
className: css.itemAsc,
|
|
29
|
+
onClick: getButtonOnClick(key, 'desc'),
|
|
30
|
+
title: `Order data by ${item.label} descending`,
|
|
31
|
+
}
|
|
33
32
|
: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
onClick: getButtonOnClick(key, 'asc'),
|
|
34
|
+
title: `Order data by ${item.label} ascending`,
|
|
35
|
+
};
|
|
37
36
|
|
|
38
37
|
const isActive = field === key;
|
|
39
38
|
|
|
40
39
|
return (
|
|
41
40
|
<MenuItem
|
|
42
41
|
key={key}
|
|
43
|
-
{...menu}
|
|
44
42
|
{...buttonProps}
|
|
45
43
|
className={cx(
|
|
46
44
|
buttonProps.className,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import cx from 'classnames';
|
|
4
|
-
import
|
|
5
|
-
Tooltip as UITooltip,
|
|
6
|
-
TooltipArrow as UITooltipArrow,
|
|
7
|
-
TooltipReference as UITooltipReference,
|
|
8
|
-
useTooltipState,
|
|
9
|
-
} from 'reakit/Tooltip';
|
|
4
|
+
import * as BaseTooltip from '@radix-ui/react-tooltip';
|
|
10
5
|
|
|
11
6
|
import css from './tooltip.module.css';
|
|
12
7
|
|
|
8
|
+
const OFFSET = 9;
|
|
9
|
+
const DELAY = 200;
|
|
10
|
+
|
|
13
11
|
export const Tooltip = (props) => {
|
|
14
12
|
const {
|
|
15
13
|
className,
|
|
@@ -22,29 +20,24 @@ export const Tooltip = (props) => {
|
|
|
22
20
|
} = props;
|
|
23
21
|
|
|
24
22
|
const rootClassName = cx(css.root, className);
|
|
25
|
-
const
|
|
26
|
-
baseId: process.env.NODE_ENV === 'test' && 'id-test',
|
|
27
|
-
placement: 'top',
|
|
28
|
-
});
|
|
23
|
+
const tooltipClassName = cx(css.tooltip, darkMode && css.tooltipDarkMode);
|
|
29
24
|
|
|
30
25
|
return (
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)}
|
|
47
|
-
</>
|
|
26
|
+
<BaseTooltip.Provider>
|
|
27
|
+
<BaseTooltip.Root delayDuration={DELAY}>
|
|
28
|
+
<BaseTooltip.Trigger asChild>
|
|
29
|
+
<Component className={rootClassName} {...restProps}>
|
|
30
|
+
{children}
|
|
31
|
+
</Component>
|
|
32
|
+
</BaseTooltip.Trigger>
|
|
33
|
+
{title && (
|
|
34
|
+
<BaseTooltip.Content className={tooltipClassName}>
|
|
35
|
+
<BaseTooltip.Arrow className={css.arrow} startOffset={OFFSET} offset={OFFSET} />
|
|
36
|
+
{title}
|
|
37
|
+
</BaseTooltip.Content>
|
|
38
|
+
)}
|
|
39
|
+
</BaseTooltip.Root>
|
|
40
|
+
</BaseTooltip.Provider>
|
|
48
41
|
);
|
|
49
42
|
};
|
|
50
43
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
.root {
|
|
2
|
+
appearance: none;
|
|
3
|
+
border: none;
|
|
4
|
+
background: none;
|
|
2
5
|
position: relative;
|
|
3
6
|
color: inherit;
|
|
4
7
|
line-height: inherit;
|
|
@@ -20,8 +23,7 @@
|
|
|
20
23
|
line-height: var(--space-small);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
.arrow
|
|
24
|
-
display: block;
|
|
26
|
+
.arrow {
|
|
25
27
|
fill: var(--color-light);
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -30,6 +32,6 @@
|
|
|
30
32
|
color: var(--color-light);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
.tooltipDarkMode .arrow
|
|
35
|
+
.tooltipDarkMode .arrow {
|
|
34
36
|
fill: var(--color-text);
|
|
35
37
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.Popover = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
|
-
var _Popover = require("reakit/Popover");
|
|
17
|
-
|
|
18
|
-
var _icon = require("../icon");
|
|
19
|
-
|
|
20
|
-
var _popoverModule = _interopRequireDefault(require("./popover.module.css"));
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
-
|
|
24
|
-
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); }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
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); }
|
|
29
|
-
|
|
30
|
-
var Popover = function Popover(_ref) {
|
|
31
|
-
var className = _ref.className,
|
|
32
|
-
icon = _ref.icon,
|
|
33
|
-
label = _ref.label,
|
|
34
|
-
ariaLabel = _ref.ariaLabel,
|
|
35
|
-
children = _ref.children;
|
|
36
|
-
var popover = (0, _Popover.usePopoverState)({
|
|
37
|
-
baseId: process.env.NODE_ENV === 'test' && 'id-test',
|
|
38
|
-
gutter: 12,
|
|
39
|
-
modal: true,
|
|
40
|
-
placement: 'top'
|
|
41
|
-
});
|
|
42
|
-
var onCloseButtonClick = (0, _react.useCallback)(function (event) {
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
popover.toggle();
|
|
45
|
-
}, [popover]);
|
|
46
|
-
var onButtonClick = (0, _react.useCallback)(function (event) {
|
|
47
|
-
event.preventDefault();
|
|
48
|
-
popover.toggle();
|
|
49
|
-
}, [popover]);
|
|
50
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Popover.PopoverDisclosure, _extends({
|
|
51
|
-
className: (0, _classnames["default"])(_popoverModule["default"].button, className)
|
|
52
|
-
}, popover, {
|
|
53
|
-
onClick: onButtonClick,
|
|
54
|
-
"aria-label": ariaLabel
|
|
55
|
-
}), icon && (typeof icon === 'string' ? /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
56
|
-
className: _popoverModule["default"].icon,
|
|
57
|
-
glyph: icon
|
|
58
|
-
}) : icon), label && /*#__PURE__*/_react["default"].createElement("span", {
|
|
59
|
-
className: _popoverModule["default"].label
|
|
60
|
-
}, label)), /*#__PURE__*/_react["default"].createElement(_Popover.Popover, _extends({
|
|
61
|
-
className: _popoverModule["default"].popover
|
|
62
|
-
}, popover, {
|
|
63
|
-
tabIndex: 0
|
|
64
|
-
}), /*#__PURE__*/_react["default"].createElement(_Popover.PopoverArrow, _extends({
|
|
65
|
-
className: _popoverModule["default"].arrow
|
|
66
|
-
}, popover, {
|
|
67
|
-
size: 16
|
|
68
|
-
})), typeof children === 'function' ? children({
|
|
69
|
-
popoverToggle: popover.toggle
|
|
70
|
-
}) : children, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
71
|
-
glyph: "close",
|
|
72
|
-
as: "button",
|
|
73
|
-
type: "button",
|
|
74
|
-
className: _popoverModule["default"].closeBtn,
|
|
75
|
-
onClick: onCloseButtonClick
|
|
76
|
-
})));
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
exports.Popover = Popover;
|
|
80
|
-
Popover.propTypes = {
|
|
81
|
-
className: _propTypes["default"].string,
|
|
82
|
-
label: _propTypes["default"].element,
|
|
83
|
-
icon: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element]),
|
|
84
|
-
children: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].element, _propTypes["default"].func]).isRequired,
|
|
85
|
-
ariaLabel: _propTypes["default"].string
|
|
86
|
-
};
|
|
87
|
-
Popover.defaultProps = {
|
|
88
|
-
className: '',
|
|
89
|
-
icon: '',
|
|
90
|
-
label: '',
|
|
91
|
-
ariaLabel: 'View more info'
|
|
92
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: flex-start;
|
|
5
|
-
border: none;
|
|
6
|
-
outline: none;
|
|
7
|
-
padding: 0;
|
|
8
|
-
background: none;
|
|
9
|
-
color: inherit;
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
line-height: inherit;
|
|
12
|
-
text-align: inherit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.button:hover,
|
|
16
|
-
.button:active,
|
|
17
|
-
.button:focus {
|
|
18
|
-
color: var(--color-primary);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.button:hover .label {
|
|
22
|
-
text-decoration: underline;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.popover {
|
|
26
|
-
padding: var(--space-small) var(--space-large) var(--space-small) var(--space-small);
|
|
27
|
-
border-radius: var(--radius-small);
|
|
28
|
-
max-width: 360px;
|
|
29
|
-
outline: none;
|
|
30
|
-
filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
|
|
31
|
-
background: var(--color-light);
|
|
32
|
-
font-size: var(--size-small);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.arrow svg {
|
|
36
|
-
display: block;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.arrow :global .fill {
|
|
40
|
-
fill: var(--color-light);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.arrow :global .stroke {
|
|
44
|
-
fill: var(--color-light);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.closeBtn {
|
|
48
|
-
position: absolute;
|
|
49
|
-
right: 0;
|
|
50
|
-
top: 0;
|
|
51
|
-
width: var(--space-large);
|
|
52
|
-
height: var(--space-large);
|
|
53
|
-
padding: var(--space-xxsmall);
|
|
54
|
-
background: none;
|
|
55
|
-
border: none;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
color: var(--color-text-ultra-light);
|
|
58
|
-
transition: var(--transition-out);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.closeBtn:hover,
|
|
62
|
-
.closeBtn:active,
|
|
63
|
-
.closeBtn:focus {
|
|
64
|
-
color: var(--color-text-light);
|
|
65
|
-
transition: var(--transition-in);
|
|
66
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
|
|
5
|
-
var _react2 = require("@storybook/react");
|
|
6
|
-
|
|
7
|
-
var _stories = require("../../stories");
|
|
8
|
-
|
|
9
|
-
var _ = require(".");
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
|
-
var stories = (0, _react2.storiesOf)('UI/Popover', module);
|
|
14
|
-
stories.addDecorator((0, _stories.getWrapperDecorator)({
|
|
15
|
-
padding: '64px'
|
|
16
|
-
}));
|
|
17
|
-
stories.add('default', function () {
|
|
18
|
-
return /*#__PURE__*/_react["default"].createElement(_.Popover, {
|
|
19
|
-
label: "Job #100"
|
|
20
|
-
}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
|
21
|
-
});
|
|
22
|
-
stories.add('with icon', function () {
|
|
23
|
-
return /*#__PURE__*/_react["default"].createElement(_.Popover, {
|
|
24
|
-
icon: "help"
|
|
25
|
-
}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
|
|
26
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './popover';
|
|
@@ -1,71 +0,0 @@
|
|
|
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 { usePopoverState, Popover as UIPopover, PopoverDisclosure as UIPopoverDisclosure, PopoverArrow as UIPopoverArrow } from 'reakit/Popover';
|
|
7
|
-
import { Icon } from '../icon';
|
|
8
|
-
import css from './popover.module.css';
|
|
9
|
-
export const Popover = _ref => {
|
|
10
|
-
let {
|
|
11
|
-
className,
|
|
12
|
-
icon,
|
|
13
|
-
label,
|
|
14
|
-
ariaLabel,
|
|
15
|
-
children
|
|
16
|
-
} = _ref;
|
|
17
|
-
const popover = usePopoverState({
|
|
18
|
-
baseId: process.env.NODE_ENV === 'test' && 'id-test',
|
|
19
|
-
gutter: 12,
|
|
20
|
-
modal: true,
|
|
21
|
-
placement: 'top'
|
|
22
|
-
});
|
|
23
|
-
const onCloseButtonClick = useCallback(event => {
|
|
24
|
-
event.preventDefault();
|
|
25
|
-
popover.toggle();
|
|
26
|
-
}, [popover]);
|
|
27
|
-
const onButtonClick = useCallback(event => {
|
|
28
|
-
event.preventDefault();
|
|
29
|
-
popover.toggle();
|
|
30
|
-
}, [popover]);
|
|
31
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UIPopoverDisclosure, _extends({
|
|
32
|
-
className: cx(css.button, className)
|
|
33
|
-
}, popover, {
|
|
34
|
-
onClick: onButtonClick,
|
|
35
|
-
"aria-label": ariaLabel
|
|
36
|
-
}), icon && (typeof icon === 'string' ? /*#__PURE__*/React.createElement(Icon, {
|
|
37
|
-
className: css.icon,
|
|
38
|
-
glyph: icon
|
|
39
|
-
}) : icon), label && /*#__PURE__*/React.createElement("span", {
|
|
40
|
-
className: css.label
|
|
41
|
-
}, label)), /*#__PURE__*/React.createElement(UIPopover, _extends({
|
|
42
|
-
className: css.popover
|
|
43
|
-
}, popover, {
|
|
44
|
-
tabIndex: 0
|
|
45
|
-
}), /*#__PURE__*/React.createElement(UIPopoverArrow, _extends({
|
|
46
|
-
className: css.arrow
|
|
47
|
-
}, popover, {
|
|
48
|
-
size: 16
|
|
49
|
-
})), typeof children === 'function' ? children({
|
|
50
|
-
popoverToggle: popover.toggle
|
|
51
|
-
}) : children, /*#__PURE__*/React.createElement(Icon, {
|
|
52
|
-
glyph: "close",
|
|
53
|
-
as: "button",
|
|
54
|
-
type: "button",
|
|
55
|
-
className: css.closeBtn,
|
|
56
|
-
onClick: onCloseButtonClick
|
|
57
|
-
})));
|
|
58
|
-
};
|
|
59
|
-
Popover.propTypes = {
|
|
60
|
-
className: PropTypes.string,
|
|
61
|
-
label: PropTypes.element,
|
|
62
|
-
icon: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
63
|
-
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.func]).isRequired,
|
|
64
|
-
ariaLabel: PropTypes.string
|
|
65
|
-
};
|
|
66
|
-
Popover.defaultProps = {
|
|
67
|
-
className: '',
|
|
68
|
-
icon: '',
|
|
69
|
-
label: '',
|
|
70
|
-
ariaLabel: 'View more info'
|
|
71
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: flex-start;
|
|
5
|
-
border: none;
|
|
6
|
-
outline: none;
|
|
7
|
-
padding: 0;
|
|
8
|
-
background: none;
|
|
9
|
-
color: inherit;
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
line-height: inherit;
|
|
12
|
-
text-align: inherit;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.button:hover,
|
|
16
|
-
.button:active,
|
|
17
|
-
.button:focus {
|
|
18
|
-
color: var(--color-primary);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.button:hover .label {
|
|
22
|
-
text-decoration: underline;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.popover {
|
|
26
|
-
padding: var(--space-small) var(--space-large) var(--space-small) var(--space-small);
|
|
27
|
-
border-radius: var(--radius-small);
|
|
28
|
-
max-width: 360px;
|
|
29
|
-
outline: none;
|
|
30
|
-
filter: drop-shadow(0 0 var(--space-xxxsmall) var(--color-shadow));
|
|
31
|
-
background: var(--color-light);
|
|
32
|
-
font-size: var(--size-small);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.arrow svg {
|
|
36
|
-
display: block;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.arrow :global .fill {
|
|
40
|
-
fill: var(--color-light);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.arrow :global .stroke {
|
|
44
|
-
fill: var(--color-light);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.closeBtn {
|
|
48
|
-
position: absolute;
|
|
49
|
-
right: 0;
|
|
50
|
-
top: 0;
|
|
51
|
-
width: var(--space-large);
|
|
52
|
-
height: var(--space-large);
|
|
53
|
-
padding: var(--space-xxsmall);
|
|
54
|
-
background: none;
|
|
55
|
-
border: none;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
color: var(--color-text-ultra-light);
|
|
58
|
-
transition: var(--transition-out);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.closeBtn:hover,
|
|
62
|
-
.closeBtn:active,
|
|
63
|
-
.closeBtn:focus {
|
|
64
|
-
color: var(--color-text-light);
|
|
65
|
-
transition: var(--transition-in);
|
|
66
|
-
}
|