@qoretechnologies/reqore 0.30.8 → 0.30.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 +40 -1
- package/__tests__/popover.test.tsx +23 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +4 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ControlGroup/index.js +1 -1
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Dropdown/index.js +1 -1
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +13 -13
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +3 -3
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +8 -4
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +7 -5
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Tabs/item.js +1 -1
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tag/index.js +2 -2
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.js +1 -1
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +6 -3
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts +1 -0
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +33 -4
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +1 -1
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +9 -3
- package/dist/hooks/usePopover.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +4 -1
- package/src/components/ControlGroup/index.tsx +1 -1
- package/src/components/Dropdown/index.tsx +1 -1
- package/src/components/InternalPopover/index.tsx +5 -6
- package/src/components/Message/index.tsx +127 -117
- package/src/components/Panel/index.tsx +55 -40
- package/src/components/Tabs/item.tsx +1 -1
- package/src/components/Tag/index.tsx +1 -1
- package/src/components/Textarea/index.tsx +2 -2
- package/src/containers/PopoverProvider.tsx +5 -3
- package/src/containers/UIProvider.tsx +26 -2
- package/src/hooks/usePopover.tsx +13 -4
- package/src/stories/Columns/Columns.stories.tsx +83 -10
- package/src/stories/Dropdown/Dropdown.stories.tsx +1 -0
- package/src/stories/Panel/Panel.stories.tsx +16 -1
- package/src/stories/Popover/Popover.stories.tsx +138 -5
- package/src/stories/Tag/Tag.stories.tsx +35 -1
- package/src/stories/TextArea/TextArea.stories.tsx +34 -1
- package/tests.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { animated } from '@react-spring/web';
|
|
2
|
-
import React, { forwardRef, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import React, { forwardRef, memo, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { useMount, useUnmount } from 'react-use';
|
|
4
4
|
import { IReqoreTheme } from '../../constants/theme';
|
|
5
5
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
6
6
|
import { getColorFromMaybeString } from '../../helpers/colors';
|
|
7
|
+
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
7
8
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
9
|
+
import { useTooltip } from '../../hooks/useTooltip';
|
|
8
10
|
import {
|
|
9
11
|
IReqoreIntent,
|
|
10
12
|
IWithReqoreCustomTheme,
|
|
@@ -12,6 +14,7 @@ import {
|
|
|
12
14
|
IWithReqoreMinimal,
|
|
13
15
|
IWithReqoreOpaque,
|
|
14
16
|
IWithReqoreSize,
|
|
17
|
+
IWithReqoreTooltip,
|
|
15
18
|
} from '../../types/global';
|
|
16
19
|
import { IReqoreIconName } from '../../types/icons';
|
|
17
20
|
import { TReqoreEffectColor } from '../Effect';
|
|
@@ -32,6 +35,7 @@ export interface IReqoreMessageProps
|
|
|
32
35
|
IReqoreIntent,
|
|
33
36
|
IWithReqoreMinimal,
|
|
34
37
|
IWithReqoreOpaque,
|
|
38
|
+
IWithReqoreTooltip,
|
|
35
39
|
React.HTMLAttributes<HTMLDivElement> {
|
|
36
40
|
title?: string;
|
|
37
41
|
children: any;
|
|
@@ -51,130 +55,136 @@ export interface IReqoreNotificationStyle extends IReqoreMessageProps {
|
|
|
51
55
|
timeout?: number;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
const ReqoreMessage =
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
const ReqoreMessage = memo(
|
|
59
|
+
forwardRef<HTMLDivElement, IReqoreMessageProps>(
|
|
60
|
+
(
|
|
61
|
+
{
|
|
62
|
+
intent,
|
|
63
|
+
icon,
|
|
64
|
+
title,
|
|
65
|
+
children,
|
|
66
|
+
onClose,
|
|
67
|
+
onClick,
|
|
68
|
+
duration,
|
|
69
|
+
onFinish,
|
|
70
|
+
flat,
|
|
71
|
+
minimal,
|
|
72
|
+
size = 'normal',
|
|
73
|
+
customTheme,
|
|
74
|
+
iconColor,
|
|
75
|
+
tooltip,
|
|
76
|
+
...rest
|
|
77
|
+
},
|
|
78
|
+
ref
|
|
79
|
+
) => {
|
|
80
|
+
const [internalTimeout, setInternalTimeout] = useState<NodeJS.Timeout | null>(null);
|
|
81
|
+
const theme = useReqoreTheme('main', customTheme, intent);
|
|
82
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
if (duration) {
|
|
79
|
-
setInternalTimeout(
|
|
80
|
-
setTimeout(() => {
|
|
81
|
-
onFinish && onFinish();
|
|
82
|
-
}, duration)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
84
|
+
useTooltip(targetRef.current, tooltip);
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
}, [duration, intent, children, title]);
|
|
86
|
+
useMount(() => {
|
|
87
|
+
if (duration) {
|
|
88
|
+
setInternalTimeout(
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
onFinish && onFinish();
|
|
91
|
+
}, duration)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (internalTimeout) {
|
|
98
|
+
clearTimeout(internalTimeout);
|
|
99
|
+
setInternalTimeout(
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
onFinish && onFinish();
|
|
102
|
+
}, duration)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}, [duration, intent, children, title]);
|
|
103
106
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
useUnmount(() => {
|
|
108
|
+
if (internalTimeout) {
|
|
109
|
+
clearTimeout(internalTimeout);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
108
112
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
113
|
+
const leftIcon: IReqoreIconName | undefined = useMemo(
|
|
114
|
+
() => icon || (intent ? typeToIcon[intent] : undefined),
|
|
115
|
+
[icon, intent]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<ReqoreThemeProvider>
|
|
120
|
+
<StyledReqoreNotification
|
|
121
|
+
{...rest}
|
|
122
|
+
effect={{
|
|
123
|
+
interactive: !!onClick,
|
|
124
|
+
...rest?.effect,
|
|
125
|
+
}}
|
|
126
|
+
as={animated.div}
|
|
127
|
+
key={`${duration}${intent}${title}${children}`}
|
|
128
|
+
intent={intent}
|
|
129
|
+
timeout={duration}
|
|
130
|
+
clickable={!!onClick}
|
|
131
|
+
onClick={onClick}
|
|
132
|
+
flat={flat}
|
|
133
|
+
minimal={minimal}
|
|
134
|
+
asMessage
|
|
135
|
+
fluid
|
|
136
|
+
className={`${rest?.className || ''} reqore-message`}
|
|
137
|
+
ref={targetRef}
|
|
138
|
+
size={size}
|
|
139
|
+
theme={theme}
|
|
140
|
+
>
|
|
141
|
+
{leftIcon ? (
|
|
142
|
+
<StyledIconWrapper intent={intent} size={size} theme={theme}>
|
|
143
|
+
<ReqoreIcon
|
|
144
|
+
icon={leftIcon}
|
|
145
|
+
margin={flat && minimal ? 'right' : 'both'}
|
|
146
|
+
size={size}
|
|
147
|
+
color={iconColor}
|
|
148
|
+
/>
|
|
149
|
+
</StyledIconWrapper>
|
|
150
|
+
) : null}
|
|
151
|
+
<StyledNotificationContentWrapper size={size} theme={theme}>
|
|
152
|
+
{title && (
|
|
153
|
+
<ReqoreHeading
|
|
154
|
+
size={size}
|
|
155
|
+
customTheme={
|
|
156
|
+
rest.effect?.color
|
|
157
|
+
? { text: { color: getColorFromMaybeString(theme, rest.effect.color) } }
|
|
158
|
+
: undefined
|
|
159
|
+
}
|
|
160
|
+
>
|
|
161
|
+
{title}
|
|
162
|
+
</ReqoreHeading>
|
|
163
|
+
)}
|
|
164
|
+
<StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
|
|
165
|
+
{children}
|
|
166
|
+
</StyledNotificationContent>
|
|
167
|
+
</StyledNotificationContentWrapper>
|
|
168
|
+
{onClose && (
|
|
169
|
+
<StyledIconWrapper
|
|
170
|
+
theme={theme}
|
|
145
171
|
size={size}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
172
|
+
intent={intent}
|
|
173
|
+
clickable
|
|
174
|
+
className='reqore-message-close'
|
|
175
|
+
onClick={(event) => {
|
|
176
|
+
event.stopPropagation();
|
|
177
|
+
onClose && onClose();
|
|
178
|
+
}}
|
|
151
179
|
>
|
|
152
|
-
{
|
|
153
|
-
</
|
|
180
|
+
<ReqoreIcon icon='CloseFill' margin='both' size={size} />
|
|
181
|
+
</StyledIconWrapper>
|
|
154
182
|
)}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
<StyledIconWrapper
|
|
161
|
-
theme={theme}
|
|
162
|
-
size={size}
|
|
163
|
-
intent={intent}
|
|
164
|
-
clickable
|
|
165
|
-
className='reqore-message-close'
|
|
166
|
-
onClick={(event) => {
|
|
167
|
-
event.stopPropagation();
|
|
168
|
-
onClose && onClose();
|
|
169
|
-
}}
|
|
170
|
-
>
|
|
171
|
-
<ReqoreIcon icon='CloseFill' margin='both' size={size} />
|
|
172
|
-
</StyledIconWrapper>
|
|
173
|
-
)}
|
|
174
|
-
</StyledReqoreNotification>
|
|
175
|
-
</ReqoreThemeProvider>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
183
|
+
</StyledReqoreNotification>
|
|
184
|
+
</ReqoreThemeProvider>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
)
|
|
178
188
|
);
|
|
179
189
|
|
|
180
190
|
export default ReqoreMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
2
|
import { darken, rgba } from 'polished';
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef, ReactElement, useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import { useUpdateEffect } from 'react-use';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import {
|
|
@@ -98,6 +98,7 @@ export interface IReqorePanelProps
|
|
|
98
98
|
headerEffect?: IReqoreEffect;
|
|
99
99
|
transparent?: boolean;
|
|
100
100
|
iconColor?: TReqoreEffectColor;
|
|
101
|
+
responsiveActions?: boolean;
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
export interface IStyledPanel extends IReqorePanelProps {
|
|
@@ -286,6 +287,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
286
287
|
badge,
|
|
287
288
|
iconColor,
|
|
288
289
|
fluid,
|
|
290
|
+
responsiveActions = true,
|
|
289
291
|
size: panelSize = 'normal',
|
|
290
292
|
...rest
|
|
291
293
|
}: IReqorePanelProps,
|
|
@@ -316,7 +318,13 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
316
318
|
!!size(actions.filter(isActionShown)) ||
|
|
317
319
|
!!badge ||
|
|
318
320
|
!!icon,
|
|
319
|
-
[label, collapsible, onClose, actions, badge]
|
|
321
|
+
[label, collapsible, onClose, actions, badge, icon]
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
// Return true if the card has a title bar, otherwise return false.
|
|
325
|
+
const hasTitleHeader: boolean = useMemo(
|
|
326
|
+
() => !!label || !!badge || !!icon,
|
|
327
|
+
[label, icon, badge]
|
|
320
328
|
);
|
|
321
329
|
|
|
322
330
|
// If collapsible is true, toggle the isCollapsed state
|
|
@@ -524,45 +532,47 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
524
532
|
opacity={opacity ?? (minimal ? 0 : 1)}
|
|
525
533
|
noHorizontalPadding={noHorizontalPadding}
|
|
526
534
|
>
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
)}
|
|
538
|
-
{typeof label === 'string' ? (
|
|
539
|
-
<ReqoreHeading
|
|
540
|
-
size={headerSize || panelSize}
|
|
541
|
-
customTheme={theme}
|
|
542
|
-
effect={{
|
|
543
|
-
noWrap: true,
|
|
544
|
-
...headerEffect,
|
|
545
|
-
}}
|
|
546
|
-
>
|
|
547
|
-
{label}
|
|
548
|
-
</ReqoreHeading>
|
|
549
|
-
) : (
|
|
550
|
-
label
|
|
551
|
-
)}
|
|
552
|
-
{badge || badge === 0 ? (
|
|
553
|
-
<>
|
|
554
|
-
<ButtonBadge
|
|
555
|
-
color={changeLightness(theme.main, 0.18)}
|
|
556
|
-
size={panelSize}
|
|
557
|
-
content={badge}
|
|
535
|
+
{hasTitleHeader && (
|
|
536
|
+
<StyledPanelTitleHeader>
|
|
537
|
+
{icon && (
|
|
538
|
+
<ReqoreIcon
|
|
539
|
+
size={`${
|
|
540
|
+
ICON_FROM_HEADER_SIZE[headerSize || HEADER_SIZE_TO_NUMBER[panelSize]]
|
|
541
|
+
}px`}
|
|
542
|
+
icon={icon}
|
|
543
|
+
margin='right'
|
|
544
|
+
color={iconColor}
|
|
558
545
|
/>
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
546
|
+
)}
|
|
547
|
+
{typeof label === 'string' ? (
|
|
548
|
+
<ReqoreHeading
|
|
549
|
+
size={headerSize || panelSize}
|
|
550
|
+
customTheme={theme}
|
|
551
|
+
effect={{
|
|
552
|
+
noWrap: true,
|
|
553
|
+
...headerEffect,
|
|
554
|
+
}}
|
|
555
|
+
>
|
|
556
|
+
{label}
|
|
557
|
+
</ReqoreHeading>
|
|
558
|
+
) : (
|
|
559
|
+
label
|
|
560
|
+
)}
|
|
561
|
+
{badge || badge === 0 ? (
|
|
562
|
+
<>
|
|
563
|
+
<ButtonBadge
|
|
564
|
+
color={changeLightness(theme.main, 0.18)}
|
|
565
|
+
size={panelSize}
|
|
566
|
+
content={badge}
|
|
567
|
+
/>
|
|
568
|
+
<ReqoreSpacer width={PADDING_FROM_SIZE.normal} />
|
|
569
|
+
</>
|
|
570
|
+
) : null}
|
|
571
|
+
</StyledPanelTitleHeader>
|
|
572
|
+
)}
|
|
563
573
|
{hasResponsiveActions(actions) && (
|
|
564
574
|
<ReqoreControlGroup
|
|
565
|
-
responsive
|
|
575
|
+
responsive={responsiveActions}
|
|
566
576
|
fluid
|
|
567
577
|
horizontalAlign='flex-end'
|
|
568
578
|
customTheme={theme}
|
|
@@ -634,7 +644,12 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
634
644
|
</>
|
|
635
645
|
) : null}
|
|
636
646
|
{hasResponsiveActions(leftBottomActions) && (
|
|
637
|
-
<ReqoreControlGroup
|
|
647
|
+
<ReqoreControlGroup
|
|
648
|
+
fluid
|
|
649
|
+
responsive={responsiveActions}
|
|
650
|
+
customTheme={theme}
|
|
651
|
+
size={panelSize}
|
|
652
|
+
>
|
|
638
653
|
{leftBottomActions.map(renderResponsiveActions)}
|
|
639
654
|
</ReqoreControlGroup>
|
|
640
655
|
)}
|
|
@@ -642,7 +657,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
642
657
|
<ReqoreControlGroup
|
|
643
658
|
fluid
|
|
644
659
|
horizontalAlign='flex-end'
|
|
645
|
-
responsive
|
|
660
|
+
responsive={responsiveActions}
|
|
646
661
|
customTheme={theme}
|
|
647
662
|
size={panelSize}
|
|
648
663
|
>
|
|
@@ -86,7 +86,7 @@ export const StyledTag = styled(StyledEffect)<IReqoreTagStyle>`
|
|
|
86
86
|
font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
|
|
87
87
|
|
|
88
88
|
min-width: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
89
|
-
max-width: ${({
|
|
89
|
+
max-width: ${({ fixed }) => (!fixed ? '100%' : undefined)};
|
|
90
90
|
flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
|
|
91
91
|
align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
|
|
92
92
|
border-radius: ${({ asBadge, size }) => (asBadge ? 18 : RADIUS_FROM_SIZE[size])}px;
|
|
@@ -165,14 +165,14 @@ const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
|
|
|
165
165
|
ref={targetRef}
|
|
166
166
|
theme={theme}
|
|
167
167
|
rounded={rounded}
|
|
168
|
-
rows={scaleWithContent ?
|
|
168
|
+
rows={scaleWithContent ? rest?.value?.split(/\r\n|\r|\n/).length || 1 : rest.rows}
|
|
169
169
|
/>
|
|
170
170
|
{!rest.readOnly && (
|
|
171
171
|
<ReqoreInputClearButton
|
|
172
172
|
enabled={!rest?.disabled && !!(onClearClick && rest?.onChange)}
|
|
173
173
|
show={rest?.value && rest.value !== ''}
|
|
174
174
|
onClick={onClearClick}
|
|
175
|
-
size=
|
|
175
|
+
size={size}
|
|
176
176
|
/>
|
|
177
177
|
)}
|
|
178
178
|
</StyledTextareaWrapper>
|
|
@@ -59,9 +59,11 @@ const PopoverProvider: React.FC<IReqorePopoverProviderProps> = ({ children, uiSc
|
|
|
59
59
|
|
|
60
60
|
if (popover) {
|
|
61
61
|
// Remove the blur
|
|
62
|
-
if (popover.blur
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
if (popover.blur) {
|
|
63
|
+
// Remove the blur
|
|
64
|
+
document.getElementById(`reqore-blur-${id}`)?.remove();
|
|
65
|
+
// Remove the z index class
|
|
66
|
+
popover.targetElement.classList.remove('reqore-blur-z-index');
|
|
65
67
|
}
|
|
66
68
|
// Remove the popover
|
|
67
69
|
setPopovers((cur: IPopoverData[]) => [...cur].filter((p) => p.id !== id));
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { cloneDeep } from 'lodash';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
+
import { rgba } from 'polished';
|
|
3
4
|
import React, { useState } from 'react';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
+
import styled, { createGlobalStyle } from 'styled-components';
|
|
5
6
|
import ReqoreLayoutWrapper from '../components/Layout';
|
|
6
7
|
import { IReqoreNotificationsPosition } from '../components/Notifications';
|
|
7
8
|
import { DEFAULT_THEME, IReqoreTheme } from '../constants/theme';
|
|
8
9
|
import ThemeContext from '../context/ThemeContext';
|
|
9
|
-
import { buildTheme } from '../helpers/colors';
|
|
10
|
+
import { buildTheme, getMainBackgroundColor } from '../helpers/colors';
|
|
10
11
|
import PopoverProvider from './PopoverProvider';
|
|
11
12
|
import ReqoreProvider from './ReqoreProvider';
|
|
13
|
+
import ReqoreThemeProvider from './ThemeProvider';
|
|
12
14
|
|
|
13
15
|
export interface IReqoreOptions {
|
|
14
16
|
withSidebar?: boolean;
|
|
@@ -22,6 +24,7 @@ export interface IReqoreOptions {
|
|
|
22
24
|
/**
|
|
23
25
|
* Delay in ms before showing the tooltip
|
|
24
26
|
* @default 0
|
|
27
|
+
* Works only for `hover` handler
|
|
25
28
|
* */
|
|
26
29
|
delay?: number;
|
|
27
30
|
};
|
|
@@ -33,6 +36,24 @@ export interface IReqoreUIProviderProps {
|
|
|
33
36
|
options?: IReqoreOptions;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
const GlobalStyle = createGlobalStyle`
|
|
40
|
+
.reqore-blur-wrapper {
|
|
41
|
+
position: fixed;
|
|
42
|
+
top: 0;
|
|
43
|
+
left: 0;
|
|
44
|
+
right: 0;
|
|
45
|
+
bottom: 0;
|
|
46
|
+
z-index: 999998;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
background-color: ${({ theme }) => rgba(getMainBackgroundColor(theme), 0.3)};
|
|
49
|
+
backdrop-filter: blur(3px);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.reqore-blur-z-index {
|
|
53
|
+
z-index: 999999;
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
|
|
36
57
|
const StyledPortal = styled.div`
|
|
37
58
|
z-index: 9999;
|
|
38
59
|
* {
|
|
@@ -50,6 +71,9 @@ const ReqoreUIProvider: React.FC<IReqoreUIProviderProps> = ({ children, theme, o
|
|
|
50
71
|
return (
|
|
51
72
|
<>
|
|
52
73
|
<ThemeContext.Provider value={{ ...rebuiltTheme }}>
|
|
74
|
+
<ReqoreThemeProvider>
|
|
75
|
+
<GlobalStyle />
|
|
76
|
+
</ReqoreThemeProvider>
|
|
53
77
|
<ReqoreLayoutWrapper withSidebar={options?.withSidebar}>
|
|
54
78
|
{modalPortal ? (
|
|
55
79
|
<ReqoreProvider options={options}>
|
package/src/hooks/usePopover.tsx
CHANGED
|
@@ -50,7 +50,7 @@ export interface IPopover
|
|
|
50
50
|
closeOnOutsideClick?: boolean;
|
|
51
51
|
closeOnAnyClick?: boolean;
|
|
52
52
|
delay?: number;
|
|
53
|
-
blur?:
|
|
53
|
+
blur?: boolean;
|
|
54
54
|
transparent?: boolean;
|
|
55
55
|
maxWidth?: string;
|
|
56
56
|
maxHeight?: string;
|
|
@@ -102,9 +102,18 @@ const usePopover = ({
|
|
|
102
102
|
...rest,
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
if (rest.blur
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
if (rest.blur) {
|
|
106
|
+
// Create a div and prepend before the targetElement
|
|
107
|
+
const blurDiv = document.createElement('div');
|
|
108
|
+
|
|
109
|
+
blurDiv.id = `reqore-blur-${current}`;
|
|
110
|
+
blurDiv.classList.add('reqore-blur-wrapper');
|
|
111
|
+
|
|
112
|
+
// Add the blur div before the target element
|
|
113
|
+
targetElement.before(blurDiv);
|
|
114
|
+
|
|
115
|
+
// Add the highest z-index to the target element
|
|
116
|
+
targetElement.classList.add('reqore-blur-z-index');
|
|
108
117
|
}
|
|
109
118
|
};
|
|
110
119
|
|