@qoretechnologies/reqore 0.25.8 → 0.25.10
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/__tests__/dropdown.test.tsx +133 -12
- package/dist/components/Collection/index.d.ts +2 -2
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +6 -6
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Collection/item.d.ts +2 -2
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +6 -3
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +8 -7
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +12 -5
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Dropdown/item.d.ts +2 -2
- package/dist/components/Dropdown/item.d.ts.map +1 -1
- package/dist/components/Dropdown/item.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +9 -2
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +13 -5
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +0 -1
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +3 -2
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +16 -17
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Popover/index.d.ts +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +4 -2
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +23 -9
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/hooks/useWhyDidYouUpdate.d.ts +2 -0
- package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
- package/dist/hooks/useWhyDidYouUpdate.js +47 -0
- package/dist/hooks/useWhyDidYouUpdate.js.map +1 -0
- package/package.json +1 -1
- package/src/components/Collection/index.tsx +3 -2
- package/src/components/Collection/item.tsx +6 -3
- package/src/components/Dropdown/index.tsx +62 -36
- package/src/components/Dropdown/item.tsx +3 -6
- package/src/components/Dropdown/list.tsx +82 -56
- package/src/components/InternalPopover/index.tsx +0 -2
- package/src/components/Panel/index.tsx +71 -59
- package/src/components/Popover/index.tsx +53 -38
- package/src/hooks/usePopover.tsx +34 -20
- package/src/hooks/useWhyDidYouUpdate.ts +32 -0
- package/src/stories/Collection/Collection.stories.tsx +1 -1
- package/src/stories/Dropdown/Dropdown.stories.tsx +62 -34
- package/src/stories/Panel/Panel.stories.tsx +9 -4
- package/tests.json +1 -1
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { memo, useMemo } from 'react';
|
|
3
3
|
import { ReqorePopover } from '../..';
|
|
4
4
|
import { IPopoverOptions } from '../../hooks/usePopover';
|
|
5
5
|
import { IReqoreIconName } from '../../types/icons';
|
|
6
6
|
import ReqoreButton, { IReqoreButtonProps } from '../Button';
|
|
7
|
-
import {
|
|
8
|
-
import ReqoreDropdownList from './list';
|
|
7
|
+
import ReqoreDropdownList, { IReqoreDropdownItem, TDropdownItemOnClick } from './list';
|
|
9
8
|
|
|
10
|
-
export interface IReqoreDropdownProps
|
|
11
|
-
items?:
|
|
9
|
+
export interface IReqoreDropdownProps extends Partial<IPopoverOptions> {
|
|
10
|
+
items?: IReqoreDropdownItem[];
|
|
12
11
|
multiSelect?: boolean;
|
|
13
12
|
buttonStyle?: React.CSSProperties;
|
|
14
13
|
listStyle?: React.CSSProperties;
|
|
15
14
|
component?: any;
|
|
16
|
-
componentProps?: T;
|
|
17
15
|
filterable?: boolean;
|
|
18
16
|
label?: any;
|
|
19
17
|
children?: any;
|
|
20
|
-
|
|
18
|
+
listWidth?: string;
|
|
21
19
|
icon?: IReqoreIconName;
|
|
22
20
|
rightIcon?: IReqoreIconName;
|
|
23
21
|
caretPosition?: 'left' | 'right';
|
|
24
22
|
isDefaultOpen?: boolean;
|
|
23
|
+
onItemSelect?: TDropdownItemOnClick;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
function ReqoreDropdown<T extends unknown = IReqoreButtonProps>({
|
|
28
27
|
items,
|
|
29
28
|
component,
|
|
30
|
-
componentProps,
|
|
31
29
|
label,
|
|
32
30
|
children,
|
|
33
31
|
multiSelect,
|
|
@@ -40,43 +38,71 @@ const ReqoreDropdown = <T extends unknown = IReqoreButtonProps>({
|
|
|
40
38
|
rightIcon,
|
|
41
39
|
caretPosition = 'left',
|
|
42
40
|
isDefaultOpen = false,
|
|
41
|
+
onItemSelect,
|
|
42
|
+
closeOnOutsideClick,
|
|
43
|
+
blur,
|
|
44
|
+
closeOnAnyClick,
|
|
45
|
+
content,
|
|
46
|
+
delay,
|
|
47
|
+
maxHeight,
|
|
48
|
+
maxWidth,
|
|
49
|
+
noArrow = true,
|
|
50
|
+
opaque,
|
|
51
|
+
openOnMount,
|
|
52
|
+
show,
|
|
53
|
+
targetElement,
|
|
54
|
+
useTargetWidth,
|
|
55
|
+
listWidth,
|
|
43
56
|
...rest
|
|
44
|
-
}: IReqoreDropdownProps
|
|
57
|
+
}: IReqoreDropdownProps & T) {
|
|
58
|
+
const componentProps = useMemo(
|
|
59
|
+
() =>
|
|
60
|
+
({
|
|
61
|
+
...rest,
|
|
62
|
+
icon: caretPosition === 'left' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
63
|
+
rightIcon: caretPosition === 'right' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
64
|
+
style: buttonStyle,
|
|
65
|
+
disabled: !size(items),
|
|
66
|
+
className: `${(rest as any)?.className || ''} reqore-dropdown-control`,
|
|
67
|
+
} as T),
|
|
68
|
+
[items, icon, rightIcon, buttonStyle, caretPosition, rest]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const popoverContent = useMemo(() => {
|
|
72
|
+
return size(items) ? (
|
|
73
|
+
<ReqoreDropdownList
|
|
74
|
+
multiSelect={multiSelect}
|
|
75
|
+
listStyle={listStyle}
|
|
76
|
+
width={useTargetWidth ? '100%' : listWidth}
|
|
77
|
+
items={items}
|
|
78
|
+
filterable={filterable}
|
|
79
|
+
onItemSelect={onItemSelect}
|
|
80
|
+
/>
|
|
81
|
+
) : undefined;
|
|
82
|
+
}, [items]);
|
|
83
|
+
|
|
45
84
|
return (
|
|
46
85
|
<ReqorePopover
|
|
47
|
-
{
|
|
86
|
+
closeOnOutsideClick={closeOnOutsideClick}
|
|
87
|
+
blur={blur}
|
|
88
|
+
closeOnAnyClick={closeOnAnyClick}
|
|
89
|
+
delay={delay}
|
|
90
|
+
maxHeight={maxHeight}
|
|
91
|
+
maxWidth={maxWidth}
|
|
92
|
+
noArrow={noArrow}
|
|
93
|
+
opaque={opaque}
|
|
94
|
+
useTargetWidth={useTargetWidth}
|
|
48
95
|
component={component || ReqoreButton}
|
|
49
|
-
componentProps={
|
|
50
|
-
{
|
|
51
|
-
icon: caretPosition === 'left' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
52
|
-
rightIcon: caretPosition === 'right' ? icon || 'ArrowDownSFill' : rightIcon,
|
|
53
|
-
style: buttonStyle,
|
|
54
|
-
disabled: !size(items),
|
|
55
|
-
...rest,
|
|
56
|
-
...((componentProps || {}) as Object),
|
|
57
|
-
className: `${(componentProps as any)?.className || ''} reqore-dropdown-control`,
|
|
58
|
-
} as T
|
|
59
|
-
}
|
|
96
|
+
componentProps={componentProps}
|
|
60
97
|
noWrapper
|
|
61
98
|
placement={placement || 'bottom-start'}
|
|
62
99
|
handler={handler || 'click'}
|
|
63
100
|
openOnMount={isDefaultOpen}
|
|
64
|
-
content={
|
|
65
|
-
size(items) ? (
|
|
66
|
-
<ReqoreDropdownList
|
|
67
|
-
multiSelect={multiSelect}
|
|
68
|
-
listStyle={listStyle}
|
|
69
|
-
width={rest.useTargetWidth ? '100%' : rest.width}
|
|
70
|
-
items={items}
|
|
71
|
-
filterable={filterable}
|
|
72
|
-
/>
|
|
73
|
-
) : undefined
|
|
74
|
-
}
|
|
75
|
-
noArrow
|
|
101
|
+
content={popoverContent}
|
|
76
102
|
>
|
|
77
103
|
{children || label}
|
|
78
104
|
</ReqorePopover>
|
|
79
105
|
);
|
|
80
|
-
}
|
|
106
|
+
}
|
|
81
107
|
|
|
82
|
-
export default ReqoreDropdown;
|
|
108
|
+
export default memo(ReqoreDropdown) as typeof ReqoreDropdown;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ReqoreMenuDivider, ReqoreMenuItem } from '../..';
|
|
2
2
|
import { IReqoreMenuDividerProps } from '../Menu/divider';
|
|
3
|
-
import {
|
|
3
|
+
import { IReqoreDropdownItem } from './list';
|
|
4
4
|
|
|
5
|
-
export interface IReqoreDropdownItemProps extends
|
|
5
|
+
export interface IReqoreDropdownItemProps extends Omit<IReqoreDropdownItem, 'value' | 'onClick'> {}
|
|
6
6
|
|
|
7
|
-
export const ReqoreDropdownItem = ({
|
|
8
|
-
children,
|
|
9
|
-
...rest
|
|
10
|
-
}: IReqoreDropdownItemProps) => (
|
|
7
|
+
export const ReqoreDropdownItem = ({ children, ...rest }: IReqoreDropdownItemProps) => (
|
|
11
8
|
<ReqoreMenuItem {...rest} rightIcon={rest.selected ? 'CheckLine' : undefined}>
|
|
12
9
|
{children}
|
|
13
10
|
</ReqoreMenuItem>
|
|
@@ -1,80 +1,106 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { IReqoreComponent } from '../../types/global';
|
|
3
3
|
import ReqoreInput from '../Input';
|
|
4
4
|
import ReqoreMenu from '../Menu';
|
|
5
5
|
import ReqoreMenuItem, { IReqoreMenuItemProps } from '../Menu/item';
|
|
6
6
|
import { ReqoreSpacer } from '../Spacer';
|
|
7
7
|
|
|
8
|
+
export type TDropdownItemOnClick = (item: IReqoreDropdownItem) => void;
|
|
9
|
+
export interface IReqoreDropdownItem extends Omit<IReqoreMenuItemProps, 'onClick'> {
|
|
10
|
+
value: any;
|
|
11
|
+
label?: string;
|
|
12
|
+
onClick?: TDropdownItemOnClick;
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
export interface IReqoreDropdownListProps extends IReqoreComponent {
|
|
9
|
-
items?:
|
|
16
|
+
items?: IReqoreDropdownItem[];
|
|
10
17
|
multiSelect?: boolean;
|
|
11
18
|
listStyle?: React.CSSProperties;
|
|
12
19
|
width?: string;
|
|
13
20
|
height?: string;
|
|
14
21
|
filterable?: boolean;
|
|
22
|
+
onItemSelect?: TDropdownItemOnClick;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
|
-
const ReqoreDropdownList = (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const ReqoreDropdownList = memo(
|
|
26
|
+
({
|
|
27
|
+
items,
|
|
28
|
+
multiSelect,
|
|
29
|
+
listStyle,
|
|
30
|
+
_popoverId,
|
|
31
|
+
filterable,
|
|
32
|
+
width,
|
|
33
|
+
height,
|
|
34
|
+
onItemSelect,
|
|
35
|
+
}: IReqoreDropdownListProps) => {
|
|
36
|
+
const [_items, setItems] = useState<IReqoreDropdownItem[]>(items);
|
|
37
|
+
const [query, setQuery] = useState<string>('');
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setItems(items);
|
|
41
|
+
}, [items]);
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
const filteredItems: IReqoreDropdownItem[] = useMemo(() => {
|
|
44
|
+
if (!filterable || query === '') {
|
|
45
|
+
return _items;
|
|
46
|
+
}
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
return _items.filter((item) => {
|
|
49
|
+
const text = item.label || item.value || item.children;
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
if (!text) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
return text.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
|
|
56
|
+
});
|
|
57
|
+
}, [items, query, _items]);
|
|
48
58
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
const handleQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
60
|
+
setQuery(event.target.value);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const handleItemClick = (item: IReqoreDropdownItem): void => {
|
|
64
|
+
if (item.onClick) {
|
|
65
|
+
item.onClick(item);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (onItemSelect) {
|
|
69
|
+
onItemSelect(item);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
52
72
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
return (
|
|
74
|
+
<ReqoreMenu
|
|
75
|
+
_insidePopover={!multiSelect}
|
|
76
|
+
_popoverId={_popoverId}
|
|
77
|
+
style={listStyle}
|
|
78
|
+
width={width}
|
|
79
|
+
maxHeight={height || '300px'}
|
|
80
|
+
>
|
|
81
|
+
{filterable && (
|
|
82
|
+
<>
|
|
83
|
+
<ReqoreInput
|
|
84
|
+
value={query}
|
|
85
|
+
onChange={handleQueryChange}
|
|
86
|
+
placeholder='Filter'
|
|
87
|
+
onClearClick={() => setQuery('')}
|
|
88
|
+
/>
|
|
89
|
+
<ReqoreSpacer height={10} />
|
|
90
|
+
</>
|
|
91
|
+
)}
|
|
92
|
+
{filteredItems.map((item: IReqoreDropdownItem, index: number) => (
|
|
93
|
+
<ReqoreMenuItem
|
|
94
|
+
key={index}
|
|
95
|
+
{...item}
|
|
96
|
+
label={item.label || item.value}
|
|
97
|
+
onClick={() => handleItemClick(item)}
|
|
98
|
+
rightIcon={item.selected ? 'CheckLine' : undefined}
|
|
69
99
|
/>
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
))}
|
|
76
|
-
</ReqoreMenu>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
100
|
+
))}
|
|
101
|
+
</ReqoreMenu>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
79
105
|
|
|
80
106
|
export default ReqoreDropdownList;
|
|
@@ -31,13 +31,13 @@ import ReqoreButton, { IReqoreButtonProps } from '../Button';
|
|
|
31
31
|
import { StyledCollectionItemContent } from '../Collection/item';
|
|
32
32
|
import ReqoreControlGroup from '../ControlGroup';
|
|
33
33
|
import ReqoreDropdown from '../Dropdown';
|
|
34
|
-
import {
|
|
34
|
+
import { IReqoreDropdownItem } from '../Dropdown/list';
|
|
35
35
|
import ReqoreIcon from '../Icon';
|
|
36
36
|
|
|
37
37
|
export interface IReqorePanelAction extends IReqoreButtonProps, IWithReqoreTooltip, IReqoreIntent {
|
|
38
38
|
label?: string | number;
|
|
39
39
|
onClick?: () => void;
|
|
40
|
-
actions?:
|
|
40
|
+
actions?: IReqoreDropdownItem[];
|
|
41
41
|
customContent?: () => string | React.ReactNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -78,6 +78,7 @@ export interface IReqorePanelProps
|
|
|
78
78
|
|
|
79
79
|
export interface IStyledPanel extends IReqorePanelProps {
|
|
80
80
|
theme: IReqoreTheme;
|
|
81
|
+
noHorizontalPadding?: boolean;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export const StyledPanel = styled.div<IStyledPanel>`
|
|
@@ -135,7 +136,8 @@ export const StyledPanelTitle = styled.div<IStyledPanel>`
|
|
|
135
136
|
justify-content: space-between;
|
|
136
137
|
height: 40px;
|
|
137
138
|
align-items: center;
|
|
138
|
-
padding:
|
|
139
|
+
padding: ${({ noHorizontalPadding }: IStyledPanel) =>
|
|
140
|
+
`0 5px 0 ${noHorizontalPadding ? 0 : '15px'}`};
|
|
139
141
|
border-bottom: ${({ theme, isCollapsed, flat, opacity = 1 }) =>
|
|
140
142
|
!isCollapsed && !flat
|
|
141
143
|
? `1px solid ${rgba(changeLightness(getMainBackgroundColor(theme), 0.2), opacity)}`
|
|
@@ -167,7 +169,12 @@ export const StyledPanelBottomActions = styled(StyledPanelTitle)`
|
|
|
167
169
|
export const StyledPanelContent = styled.div<IStyledPanel>`
|
|
168
170
|
display: ${({ isCollapsed }) => (isCollapsed ? 'none' : undefined)};
|
|
169
171
|
min-height: ${({ isCollapsed }) => (isCollapsed ? undefined : '40px')};
|
|
170
|
-
padding: ${({ padded, contentSize }) =>
|
|
172
|
+
padding: ${({ padded, contentSize, noHorizontalPadding }) =>
|
|
173
|
+
!padded
|
|
174
|
+
? undefined
|
|
175
|
+
: noHorizontalPadding
|
|
176
|
+
? `${TEXT_FROM_SIZE[contentSize]}px 0`
|
|
177
|
+
: `${TEXT_FROM_SIZE[contentSize]}px`};
|
|
171
178
|
// The padding is not needed when the panel is minimal and has title, since
|
|
172
179
|
// the title already has padding and is transparent
|
|
173
180
|
padding-top: ${({ minimal, hasLabel }) => (minimal && hasLabel ? '0px' : undefined)};
|
|
@@ -260,66 +267,68 @@ export const ReqorePanel = forwardRef(
|
|
|
260
267
|
[leftBottomActions, rightBottomActions]
|
|
261
268
|
);
|
|
262
269
|
|
|
263
|
-
const renderActions = (
|
|
264
|
-
actionOrActions: IReqorePanelAction | IReqorePanelAction[],
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
const renderActions = useCallback(
|
|
271
|
+
(actionOrActions: IReqorePanelAction | IReqorePanelAction[], index: number) => {
|
|
272
|
+
if (Array.isArray(actionOrActions)) {
|
|
273
|
+
return (
|
|
274
|
+
<ReqoreControlGroup stack minimal>
|
|
275
|
+
{actionOrActions.map(renderActions)}
|
|
276
|
+
</ReqoreControlGroup>
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const {
|
|
281
|
+
id,
|
|
282
|
+
actions,
|
|
283
|
+
label,
|
|
284
|
+
intent,
|
|
285
|
+
className,
|
|
286
|
+
customContent,
|
|
287
|
+
...rest
|
|
288
|
+
}: IReqorePanelAction = actionOrActions;
|
|
289
|
+
|
|
290
|
+
if (size(actions)) {
|
|
291
|
+
return (
|
|
292
|
+
<ReqoreDropdown<IReqoreButtonProps>
|
|
293
|
+
{...rest}
|
|
294
|
+
key={index}
|
|
295
|
+
label={label}
|
|
296
|
+
items={actions}
|
|
297
|
+
intent={intent}
|
|
298
|
+
className={className}
|
|
299
|
+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => e.stopPropagation()}
|
|
300
|
+
id={id}
|
|
301
|
+
/>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (customContent) {
|
|
306
|
+
return customContent();
|
|
307
|
+
}
|
|
277
308
|
|
|
278
|
-
if (size(actions)) {
|
|
279
309
|
return (
|
|
280
|
-
<
|
|
310
|
+
<ReqoreButton
|
|
281
311
|
{...rest}
|
|
312
|
+
id={id}
|
|
282
313
|
key={index}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
314
|
+
className={className}
|
|
315
|
+
customTheme={theme}
|
|
316
|
+
intent={intent}
|
|
317
|
+
onClick={
|
|
318
|
+
rest.onClick
|
|
319
|
+
? (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
320
|
+
e.stopPropagation();
|
|
321
|
+
rest.onClick?.();
|
|
322
|
+
}
|
|
323
|
+
: undefined
|
|
324
|
+
}
|
|
325
|
+
>
|
|
326
|
+
{label}
|
|
327
|
+
</ReqoreButton>
|
|
295
328
|
);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return customContent();
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return (
|
|
303
|
-
<ReqoreButton
|
|
304
|
-
{...rest}
|
|
305
|
-
id={id}
|
|
306
|
-
key={index}
|
|
307
|
-
className={className}
|
|
308
|
-
customTheme={theme}
|
|
309
|
-
intent={intent}
|
|
310
|
-
onClick={
|
|
311
|
-
rest.onClick
|
|
312
|
-
? (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
313
|
-
e.stopPropagation();
|
|
314
|
-
rest.onClick?.();
|
|
315
|
-
}
|
|
316
|
-
: undefined
|
|
317
|
-
}
|
|
318
|
-
>
|
|
319
|
-
{label}
|
|
320
|
-
</ReqoreButton>
|
|
321
|
-
);
|
|
322
|
-
};
|
|
329
|
+
},
|
|
330
|
+
[actions, theme]
|
|
331
|
+
);
|
|
323
332
|
|
|
324
333
|
const HTMLheaderElement = useMemo(() => {
|
|
325
334
|
return `h${headerSize}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
@@ -354,6 +363,7 @@ export const ReqorePanel = forwardRef(
|
|
|
354
363
|
onClick={handleCollapseClick}
|
|
355
364
|
theme={theme}
|
|
356
365
|
opacity={rest.opacity ?? (minimal ? 0 : 1)}
|
|
366
|
+
noHorizontalPadding={rest.opacity === 0}
|
|
357
367
|
>
|
|
358
368
|
<StyledPanelTitleHeader>
|
|
359
369
|
{icon && (
|
|
@@ -401,6 +411,7 @@ export const ReqorePanel = forwardRef(
|
|
|
401
411
|
padded={padded}
|
|
402
412
|
minimal={minimal}
|
|
403
413
|
contentSize={contentSize}
|
|
414
|
+
noHorizontalPadding={rest.opacity === 0}
|
|
404
415
|
>
|
|
405
416
|
{children}
|
|
406
417
|
</StyledPanelContent>
|
|
@@ -411,6 +422,7 @@ export const ReqorePanel = forwardRef(
|
|
|
411
422
|
className='reqore-panel-bottom-actions'
|
|
412
423
|
theme={theme}
|
|
413
424
|
opacity={rest.opacity ?? (minimal ? 0 : 1)}
|
|
425
|
+
noHorizontalPadding={rest.opacity === 0}
|
|
414
426
|
>
|
|
415
427
|
<ReqoreControlGroup minimal>{leftBottomActions.map(renderActions)}</ReqoreControlGroup>
|
|
416
428
|
<ReqoreControlGroup minimal>{rightBottomActions.map(renderActions)}</ReqoreControlGroup>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { memo, useState } from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import usePopover, { IPopoverOptions } from '../../hooks/usePopover';
|
|
4
|
+
import { useWhyDidYouUpdate } from '../../hooks/useWhyDidYouUpdate';
|
|
4
5
|
import { IReqoreComponent } from '../../types/global';
|
|
5
6
|
|
|
6
7
|
export interface IReqorePopoverProps extends IReqoreComponent, IPopoverOptions {
|
|
@@ -17,49 +18,63 @@ export const StyledPopover = styled.span`
|
|
|
17
18
|
overflow: hidden;
|
|
18
19
|
`;
|
|
19
20
|
|
|
20
|
-
const Popover = (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
const Popover = memo(
|
|
22
|
+
({
|
|
23
|
+
component: Component,
|
|
24
|
+
componentProps,
|
|
25
|
+
children,
|
|
26
|
+
isReqoreComponent,
|
|
27
|
+
noWrapper,
|
|
28
|
+
wrapperTag = 'span',
|
|
29
|
+
wrapperStyle = {},
|
|
30
|
+
_insidePopover,
|
|
31
|
+
_popoverId,
|
|
32
|
+
...rest
|
|
33
|
+
}: IReqorePopoverProps) => {
|
|
34
|
+
const [ref, setRef] = useState(undefined);
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
useWhyDidYouUpdate('popover', {
|
|
37
|
+
component: Component,
|
|
38
|
+
componentProps,
|
|
39
|
+
children,
|
|
40
|
+
isReqoreComponent,
|
|
41
|
+
noWrapper,
|
|
42
|
+
wrapperTag,
|
|
43
|
+
wrapperStyle,
|
|
44
|
+
_insidePopover,
|
|
45
|
+
_popoverId,
|
|
46
|
+
...rest,
|
|
47
|
+
});
|
|
48
|
+
usePopover({ targetElement: ref, ...rest });
|
|
49
|
+
|
|
50
|
+
if (isReqoreComponent || noWrapper) {
|
|
51
|
+
return (
|
|
52
|
+
<Component
|
|
53
|
+
{...componentProps}
|
|
54
|
+
_insidePopover={_insidePopover}
|
|
55
|
+
_popoverId={_popoverId}
|
|
56
|
+
ref={setRef}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</Component>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
35
62
|
|
|
36
|
-
if (isReqoreComponent || noWrapper) {
|
|
37
63
|
return (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
<StyledPopover
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
as={wrapperTag}
|
|
68
|
+
className='reqore-popover-wrapper'
|
|
42
69
|
ref={setRef}
|
|
70
|
+
style={wrapperStyle}
|
|
43
71
|
>
|
|
44
|
-
{
|
|
45
|
-
|
|
72
|
+
<Component {...componentProps} _insidePopover={_insidePopover} _popoverId={_popoverId}>
|
|
73
|
+
{children}
|
|
74
|
+
</Component>
|
|
75
|
+
</StyledPopover>
|
|
46
76
|
);
|
|
47
77
|
}
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
<StyledPopover
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
as={wrapperTag}
|
|
54
|
-
className='reqore-popover-wrapper'
|
|
55
|
-
ref={setRef}
|
|
56
|
-
style={wrapperStyle}
|
|
57
|
-
>
|
|
58
|
-
<Component {...componentProps} _insidePopover={_insidePopover} _popoverId={_popoverId}>
|
|
59
|
-
{children}
|
|
60
|
-
</Component>
|
|
61
|
-
</StyledPopover>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
78
|
+
);
|
|
64
79
|
|
|
65
80
|
export default Popover;
|