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