@qoretechnologies/reqore 0.37.0 → 0.37.2
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/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +2 -2
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/Drawer/backdrop.d.ts +10 -0
- package/dist/components/Drawer/backdrop.d.ts.map +1 -0
- package/dist/components/Drawer/backdrop.js +64 -0
- package/dist/components/Drawer/backdrop.js.map +1 -0
- package/dist/components/Drawer/index.d.ts +0 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +4 -20
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/ExportModal/index.d.ts.map +1 -1
- package/dist/components/ExportModal/index.js +1 -1
- package/dist/components/ExportModal/index.js.map +1 -1
- package/dist/components/Navbar/index.d.ts.map +1 -1
- package/dist/components/Navbar/index.js +1 -1
- package/dist/components/Navbar/index.js.map +1 -1
- package/dist/components/Sidebar/index.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +2 -2
- package/dist/components/Sidebar/index.js.map +1 -1
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tabs/index.d.ts.map +1 -1
- package/dist/components/Tabs/item.d.ts.map +1 -1
- package/dist/components/Tabs/item.js +2 -3
- package/dist/components/Tabs/item.js.map +1 -1
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +41 -13
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tree/index.d.ts +4 -0
- package/dist/components/Tree/index.d.ts.map +1 -1
- package/dist/components/Tree/index.js +16 -4
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +50 -48
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +3 -4
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/helpers/utils.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Collection/item.tsx +4 -5
- package/src/components/Drawer/backdrop.tsx +48 -0
- package/src/components/Drawer/index.tsx +4 -23
- package/src/components/ExportModal/index.tsx +1 -0
- package/src/components/Navbar/index.tsx +1 -0
- package/src/components/Sidebar/index.tsx +3 -4
- package/src/components/Tabs/index.tsx +1 -1
- package/src/components/Tabs/item.tsx +2 -5
- package/src/components/Tabs/list.tsx +70 -21
- package/src/components/Tree/index.tsx +18 -3
- package/src/containers/ReqoreProvider.tsx +94 -87
- package/src/containers/UIProvider.tsx +4 -8
- package/src/helpers/utils.ts +1 -1
- package/src/index.tsx +1 -0
- package/src/stories/Drawer/Drawer.stories.tsx +5 -1
- package/src/stories/Modal/Manager.stories.tsx +26 -1
- package/src/stories/Tabs/Tabs.stories.tsx +2 -2
- package/tests.json +1 -1
|
@@ -6,7 +6,7 @@ import styled, { css } from 'styled-components';
|
|
|
6
6
|
import { changeDarkness, getMainBackgroundColor } from '../../helpers/colors';
|
|
7
7
|
import { useReqoreProperty } from '../../hooks/useReqoreContext';
|
|
8
8
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
9
|
-
import {
|
|
9
|
+
import { ReqoreBackdrop } from '../Drawer/backdrop';
|
|
10
10
|
import {
|
|
11
11
|
IReqorePanelAction,
|
|
12
12
|
IReqorePanelBottomAction,
|
|
@@ -150,7 +150,7 @@ export const ReqoreCollectionItem = ({
|
|
|
150
150
|
);
|
|
151
151
|
|
|
152
152
|
const renderContent = () => {
|
|
153
|
-
const handleItemClick = (event) => {
|
|
153
|
+
const handleItemClick = (event?: any) => {
|
|
154
154
|
if (expandable) {
|
|
155
155
|
if (isSelected) {
|
|
156
156
|
setDimensions(originalDimensions.current);
|
|
@@ -194,11 +194,10 @@ export const ReqoreCollectionItem = ({
|
|
|
194
194
|
{position && (
|
|
195
195
|
<>
|
|
196
196
|
<div style={{ ...originalDimensions.current }} />
|
|
197
|
-
<
|
|
197
|
+
<ReqoreBackdrop
|
|
198
198
|
zIndex={getAndIncreaseZIndex()}
|
|
199
199
|
blur={5}
|
|
200
|
-
|
|
201
|
-
onClick={handleItemClick}
|
|
200
|
+
onClose={() => handleItemClick()}
|
|
202
201
|
/>
|
|
203
202
|
</>
|
|
204
203
|
)}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { animated } from '@react-spring/web';
|
|
2
|
+
import { rgba } from 'polished';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { IReqoreDrawerStyle } from '.';
|
|
6
|
+
import { getMainBackgroundColor } from '../../helpers/colors';
|
|
7
|
+
|
|
8
|
+
export interface IReqoreBackdropProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
zIndex?: number;
|
|
10
|
+
blur?: number;
|
|
11
|
+
onClose?: () => void;
|
|
12
|
+
opacity?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const StyledBackdrop = styled(animated.div)<
|
|
16
|
+
IReqoreDrawerStyle & { closable: boolean; zIndex?: number }
|
|
17
|
+
>`
|
|
18
|
+
position: fixed;
|
|
19
|
+
top: 0;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
right: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
backdrop-filter: ${({ blur }) => (blur ? `blur(${blur}px)` : undefined)};
|
|
24
|
+
z-index: ${({ zIndex }) => zIndex};
|
|
25
|
+
background-color: ${({ theme }) => rgba(getMainBackgroundColor(theme), 0.3)};
|
|
26
|
+
cursor: ${({ closable }) => (closable ? 'pointer' : 'initial')};
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
export const ReqoreBackdrop = memo(
|
|
30
|
+
({ onClose, zIndex, blur, opacity, ...rest }: IReqoreBackdropProps) => (
|
|
31
|
+
<StyledBackdrop
|
|
32
|
+
{...rest}
|
|
33
|
+
className={`${rest.className || ''} reqore-drawer-backdrop`}
|
|
34
|
+
onClick={(event) => {
|
|
35
|
+
// Only close if the click is on the backdrop itself
|
|
36
|
+
if (event.target === event.currentTarget) {
|
|
37
|
+
onClose?.();
|
|
38
|
+
}
|
|
39
|
+
}}
|
|
40
|
+
closable={!!onClose}
|
|
41
|
+
zIndex={zIndex}
|
|
42
|
+
blur={blur}
|
|
43
|
+
style={{
|
|
44
|
+
opacity,
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { animated, useTransition } from '@react-spring/web';
|
|
2
|
-
import { rgba } from 'polished';
|
|
3
2
|
import { Resizable } from 're-resizable';
|
|
4
3
|
import { useEffect, useMemo, useState } from 'react';
|
|
5
4
|
import { createPortal } from 'react-dom';
|
|
@@ -8,12 +7,12 @@ import { useReqoreProperty } from '../..';
|
|
|
8
7
|
import { SPRING_CONFIG, SPRING_CONFIG_NO_ANIMATIONS } from '../../constants/animations';
|
|
9
8
|
import { IReqoreTheme } from '../../constants/theme';
|
|
10
9
|
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
11
|
-
import { getMainBackgroundColor } from '../../helpers/colors';
|
|
12
10
|
import useLatestZIndex from '../../hooks/useLatestZIndex';
|
|
13
11
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
14
12
|
import { IReqoreIconName } from '../../types/icons';
|
|
15
13
|
import ReqoreButton from '../Button';
|
|
16
14
|
import { IReqorePanelAction, IReqorePanelProps, ReqorePanel } from '../Panel';
|
|
15
|
+
import { ReqoreBackdrop } from './backdrop';
|
|
17
16
|
|
|
18
17
|
export type TPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
19
18
|
|
|
@@ -97,20 +96,6 @@ export const StyledCloseWrapper = styled.div<IReqoreDrawerStyle>`
|
|
|
97
96
|
|
|
98
97
|
export const StyledDrawerResizable = styled(animated.div)``;
|
|
99
98
|
|
|
100
|
-
export const StyledBackdrop = styled(animated.div)<
|
|
101
|
-
IReqoreDrawerStyle & { closable: boolean; zIndex?: number }
|
|
102
|
-
>`
|
|
103
|
-
position: fixed;
|
|
104
|
-
top: 0;
|
|
105
|
-
bottom: 0;
|
|
106
|
-
right: 0;
|
|
107
|
-
left: 0;
|
|
108
|
-
backdrop-filter: ${({ blur }) => (blur ? `blur(${blur}px)` : undefined)};
|
|
109
|
-
z-index: ${({ zIndex }) => zIndex};
|
|
110
|
-
background-color: ${({ theme }) => rgba(getMainBackgroundColor(theme), 0.3)};
|
|
111
|
-
cursor: ${({ closable }) => (closable ? 'pointer' : 'initial')};
|
|
112
|
-
`;
|
|
113
|
-
|
|
114
99
|
/**
|
|
115
100
|
* It returns an icon name based on the position and whether the panel is hidden or not
|
|
116
101
|
* @param {'top' | 'bottom' | 'left' | 'right'} position - The position of the panel.
|
|
@@ -245,15 +230,11 @@ export const ReqoreDrawer: React.FC<IReqoreDrawerProps> = ({
|
|
|
245
230
|
item ? (
|
|
246
231
|
<ReqoreThemeProvider theme={theme}>
|
|
247
232
|
{hasBackdrop && !_isHidden ? (
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
onClick={() => onClose && onClose()}
|
|
251
|
-
closable={!!onClose}
|
|
233
|
+
<ReqoreBackdrop
|
|
234
|
+
onClose={onClose}
|
|
252
235
|
zIndex={zIndex}
|
|
253
236
|
blur={blur}
|
|
254
|
-
|
|
255
|
-
opacity: styles.opacity,
|
|
256
|
-
}}
|
|
237
|
+
opacity={styles.opacity}
|
|
257
238
|
/>
|
|
258
239
|
) : null}
|
|
259
240
|
<Resizable
|
|
@@ -20,6 +20,7 @@ export interface IReqoreNavbarStyle extends IReqoreNavbarProps {
|
|
|
20
20
|
export const StyledNavbar = styled.div<IReqoreNavbarStyle>`
|
|
21
21
|
${({ theme, type }: IReqoreNavbarStyle) => css`
|
|
22
22
|
height: 50px;
|
|
23
|
+
flex-shrink: 0;
|
|
23
24
|
width: 100%;
|
|
24
25
|
padding: 0 10px;
|
|
25
26
|
color: ${theme[type]?.color ||
|
|
@@ -13,7 +13,7 @@ import useLatestZIndex from '../../hooks/useLatestZIndex';
|
|
|
13
13
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
14
14
|
import { ActiveIconScale, InactiveIconScale, ScaleIconOnHover } from '../../styles';
|
|
15
15
|
import { IReqoreIconName } from '../../types/icons';
|
|
16
|
-
import {
|
|
16
|
+
import { ReqoreBackdrop } from '../Drawer/backdrop';
|
|
17
17
|
import ReqoreIcon from '../Icon';
|
|
18
18
|
import SidebarItem from './item';
|
|
19
19
|
|
|
@@ -423,10 +423,9 @@ const ReqoreSidebar: React.FC<IQorusSidebarProps> = ({
|
|
|
423
423
|
return (
|
|
424
424
|
<>
|
|
425
425
|
{floating && hasFloatingBackdrop && isOpen ? (
|
|
426
|
-
<
|
|
426
|
+
<ReqoreBackdrop
|
|
427
427
|
className='reqore-sidebar-backdrop'
|
|
428
|
-
|
|
429
|
-
closable
|
|
428
|
+
onClose={() => onCloseClick?.()}
|
|
430
429
|
zIndex={zIndex}
|
|
431
430
|
/>
|
|
432
431
|
) : null}
|
|
@@ -9,7 +9,7 @@ import { TReqoreTabsContentPadding } from './content';
|
|
|
9
9
|
import ReqoreTabsList from './list';
|
|
10
10
|
|
|
11
11
|
export interface IReqoreTabsListItem extends Omit<IReqoreButtonProps, 'id'> {
|
|
12
|
-
label: string;
|
|
12
|
+
label: string | number;
|
|
13
13
|
as?: any;
|
|
14
14
|
id: string | number;
|
|
15
15
|
props?: React.HTMLAttributes<any>;
|
|
@@ -2,7 +2,7 @@ import { omit } from 'lodash';
|
|
|
2
2
|
import { forwardRef, memo } from 'react';
|
|
3
3
|
import styled, { css } from 'styled-components';
|
|
4
4
|
import { IReqoreTabsListItem } from '.';
|
|
5
|
-
import {
|
|
5
|
+
import { TSizes } from '../../constants/sizes';
|
|
6
6
|
import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
|
|
7
7
|
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
8
8
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
@@ -29,7 +29,7 @@ export interface IReqoreTabListItemStyle extends IReqoreTabListItemProps {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
|
|
32
|
-
${({ disabled, vertical,
|
|
32
|
+
${({ disabled, vertical, fill, padded }: IReqoreTabListItemStyle) => {
|
|
33
33
|
return css`
|
|
34
34
|
display: flex;
|
|
35
35
|
flex-shrink: 0;
|
|
@@ -37,9 +37,6 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
|
|
|
37
37
|
position: relative;
|
|
38
38
|
align-items: center;
|
|
39
39
|
width: ${vertical ? `100%` : undefined};
|
|
40
|
-
padding: ${`${TABS_PADDING_TO_PX[size!]}px`};
|
|
41
|
-
padding-bottom: ${!vertical && 0};
|
|
42
|
-
padding-right: ${vertical && 0};
|
|
43
40
|
|
|
44
41
|
${vertical
|
|
45
42
|
? css`
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isArray } from 'lodash';
|
|
1
|
+
import { isArray, isObject } from 'lodash';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useMeasure } from 'react-use';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import { IReqoreTabsListItem, IReqoreTabsProps } from '.';
|
|
6
6
|
import { ReqorePopover } from '../..';
|
|
7
7
|
import {
|
|
8
|
+
GAP_FROM_SIZE,
|
|
8
9
|
ICON_FROM_SIZE,
|
|
9
10
|
PADDING_FROM_SIZE,
|
|
10
|
-
TABS_PADDING_TO_PX,
|
|
11
11
|
TEXT_FROM_SIZE,
|
|
12
12
|
TSizes,
|
|
13
13
|
} from '../../constants/sizes';
|
|
@@ -18,12 +18,14 @@ import {
|
|
|
18
18
|
getColorFromMaybeString,
|
|
19
19
|
getNthGradientColor,
|
|
20
20
|
} from '../../helpers/colors';
|
|
21
|
-
import { calculateStringSizeInPixels } from '../../helpers/utils';
|
|
21
|
+
import { calculateStringSizeInPixels, getOneLessSize } from '../../helpers/utils';
|
|
22
22
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
23
|
+
import { IReqoreButtonProps } from '../Button';
|
|
23
24
|
import { TReqoreHexColor } from '../Effect';
|
|
24
25
|
import ReqoreMenu from '../Menu';
|
|
25
26
|
import ReqoreMenuItem, { IReqoreMenuItemProps } from '../Menu/item';
|
|
26
27
|
import { StyledPopover } from '../Popover';
|
|
28
|
+
import { IReqoreTagProps } from '../Tag';
|
|
27
29
|
import ReqoreTabsListItem, { IReqoreTabListItemProps, StyledTabListItem } from './item';
|
|
28
30
|
|
|
29
31
|
export interface IReqoreTabsListProps
|
|
@@ -39,20 +41,30 @@ export interface IReqoreTabsListStyle extends Omit<IReqoreTabsListProps, 'tabs'>
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export const StyledReqoreTabsList = styled.div<IReqoreTabsListStyle>`
|
|
42
|
-
${({ fill, vertical, currentTabColor, width }) => css`
|
|
44
|
+
${({ fill, vertical, size, padded, flat, currentTabColor, width }) => css`
|
|
43
45
|
height: ${vertical ? '100%' : undefined};
|
|
44
46
|
width: ${vertical ? width || '200px' : '100%'};
|
|
45
47
|
flex-flow: ${vertical ? 'column' : 'row'};
|
|
46
48
|
display: flex;
|
|
47
49
|
align-items: center;
|
|
50
|
+
|
|
51
|
+
gap: ${GAP_FROM_SIZE[size]}px;
|
|
52
|
+
|
|
53
|
+
${padded &&
|
|
54
|
+
css`
|
|
55
|
+
padding: 0 ${PADDING_FROM_SIZE[size]}px;
|
|
56
|
+
`}
|
|
57
|
+
|
|
58
|
+
${!flat &&
|
|
59
|
+
css`
|
|
48
60
|
border-${vertical ? 'right' : 'bottom'}: 1px solid ${changeLightness(currentTabColor, 0.175)};
|
|
61
|
+
`}
|
|
49
62
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
63
|
+
|
|
64
|
+
${fill &&
|
|
65
|
+
css`
|
|
66
|
+
justify-content: space-around;
|
|
67
|
+
`}
|
|
56
68
|
|
|
57
69
|
${StyledPopover} {
|
|
58
70
|
> ${StyledTabListItem} {
|
|
@@ -73,8 +85,27 @@ const getMoreLabel = (items: IReqoreTabsListItem[], activeTab?: string | number)
|
|
|
73
85
|
return 'More';
|
|
74
86
|
};
|
|
75
87
|
|
|
76
|
-
const
|
|
77
|
-
|
|
88
|
+
const getBadgeLength = (badge: IReqoreButtonProps['badge'], tabsSize: TSizes = 'normal') => {
|
|
89
|
+
if (!badge) {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (isArray(badge)) {
|
|
94
|
+
return badge.reduce((len, b) => len + getBadgeLength(b), 0);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (isObject(badge)) {
|
|
98
|
+
return getLabelLength(badge, undefined, getOneLessSize(tabsSize)) + PADDING_FROM_SIZE[tabsSize];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
calculateStringSizeInPixels(badge.toString(), TEXT_FROM_SIZE[getOneLessSize(tabsSize)]) +
|
|
103
|
+
PADDING_FROM_SIZE[tabsSize]
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const getLabelLength = (
|
|
108
|
+
item: IReqoreTabsListItem | IReqoreTabsListItem[] | IReqoreTagProps,
|
|
78
109
|
activeTab?: string | number,
|
|
79
110
|
tabsSize: TSizes = 'normal'
|
|
80
111
|
) => {
|
|
@@ -82,11 +113,29 @@ const getLabel = (
|
|
|
82
113
|
return 0;
|
|
83
114
|
}
|
|
84
115
|
|
|
85
|
-
const label: string = isArray(item) ? getMoreLabel(item, activeTab) : item.label;
|
|
86
|
-
const icon: number =
|
|
87
|
-
|
|
116
|
+
const label: string | number = isArray(item) ? getMoreLabel(item, activeTab) : item.label;
|
|
117
|
+
const icon: number =
|
|
118
|
+
isArray(item) || item.icon ? ICON_FROM_SIZE[tabsSize] + PADDING_FROM_SIZE[tabsSize] : 0;
|
|
119
|
+
const rightIcon = (item as IReqoreTagProps).rightIcon
|
|
120
|
+
? ICON_FROM_SIZE[tabsSize] + PADDING_FROM_SIZE[tabsSize]
|
|
121
|
+
: 0;
|
|
122
|
+
const closeIconSize =
|
|
123
|
+
isArray(item) ||
|
|
124
|
+
!(item as IReqoreTabsListItem).onCloseClick ||
|
|
125
|
+
!(item as IReqoreTagProps).onRemoveClick
|
|
126
|
+
? 0
|
|
127
|
+
: ICON_FROM_SIZE[tabsSize] * 2;
|
|
128
|
+
const badgeLength = isArray(item)
|
|
129
|
+
? 0
|
|
130
|
+
: getBadgeLength((item as IReqoreTabsListItem).badge, tabsSize);
|
|
88
131
|
|
|
89
|
-
return
|
|
132
|
+
return (
|
|
133
|
+
calculateStringSizeInPixels(label?.toString(), TEXT_FROM_SIZE[tabsSize]) +
|
|
134
|
+
icon +
|
|
135
|
+
closeIconSize +
|
|
136
|
+
badgeLength +
|
|
137
|
+
rightIcon
|
|
138
|
+
);
|
|
90
139
|
};
|
|
91
140
|
|
|
92
141
|
/**
|
|
@@ -105,15 +154,15 @@ export const getTabsLength = (
|
|
|
105
154
|
): number =>
|
|
106
155
|
items.reduce((len, item) => {
|
|
107
156
|
if (type === 'height') {
|
|
108
|
-
const rows =
|
|
157
|
+
const rows = getLabelLength(item, activeTab, tabsSize) / 4 || 1;
|
|
109
158
|
|
|
110
159
|
return len + rows * 15 + 10;
|
|
111
160
|
}
|
|
112
161
|
|
|
113
162
|
const labelLength: number =
|
|
114
|
-
PADDING_FROM_SIZE[tabsSize] *
|
|
115
|
-
|
|
116
|
-
|
|
163
|
+
PADDING_FROM_SIZE[tabsSize] * 2 +
|
|
164
|
+
GAP_FROM_SIZE[tabsSize] * 2 +
|
|
165
|
+
getLabelLength(item, activeTab, tabsSize);
|
|
117
166
|
|
|
118
167
|
return len + labelLength;
|
|
119
168
|
}, 0);
|
|
@@ -264,7 +313,7 @@ const ReqoreTabsList = ({
|
|
|
264
313
|
} as IReqoreMenuItemProps)}
|
|
265
314
|
tooltip={tooltip}
|
|
266
315
|
{...rest}
|
|
267
|
-
key={index + label}
|
|
316
|
+
key={index + label?.toString()}
|
|
268
317
|
>
|
|
269
318
|
{label}
|
|
270
319
|
</ReqoreMenuItem>
|
|
@@ -2,6 +2,7 @@ import { cloneDeep, size as lodashSize } from 'lodash';
|
|
|
2
2
|
import { useMemo, useState } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { ReqoreMessage, ReqorePanel, useReqoreProperty } from '../..';
|
|
5
|
+
import { GAP_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
5
6
|
import { IReqoreTheme } from '../../constants/theme';
|
|
6
7
|
import { getTypeFromValue } from '../../helpers/utils';
|
|
7
8
|
import { IWithReqoreSize } from '../../types/global';
|
|
@@ -28,12 +29,21 @@ export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
|
|
|
28
29
|
export interface ITreeStyle {
|
|
29
30
|
interactive?: boolean;
|
|
30
31
|
theme: IReqoreTheme;
|
|
32
|
+
level?: number;
|
|
33
|
+
size?: TSizes;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export const StyledTreeLabel = styled(ReqoreMessage)`
|
|
34
37
|
flex-shrink: 1;
|
|
35
38
|
`;
|
|
36
39
|
|
|
40
|
+
export const StyledTreeWrapper = styled.div<ITreeStyle>`
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-flow: column;
|
|
43
|
+
gap: ${({ size }) => GAP_FROM_SIZE[size]}px;
|
|
44
|
+
margin-left: ${({ level, size }) => (level ? level * GAP_FROM_SIZE[size] : 0)}px;
|
|
45
|
+
`;
|
|
46
|
+
|
|
37
47
|
export const ReqoreTree = ({
|
|
38
48
|
data,
|
|
39
49
|
size = 'normal',
|
|
@@ -98,7 +108,7 @@ export const ReqoreTree = ({
|
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
return (
|
|
101
|
-
<
|
|
111
|
+
<StyledTreeWrapper key={index} size={zoomToSize[zoom]} level={level}>
|
|
102
112
|
{isObject ? (
|
|
103
113
|
<ReqoreControlGroup size={zoomToSize[zoom]}>
|
|
104
114
|
<ReqoreButton
|
|
@@ -113,7 +123,7 @@ export const ReqoreTree = ({
|
|
|
113
123
|
{_showTypes ? <ReqoreTag label={dataType} className='reqore-tree-type' /> : null}
|
|
114
124
|
</ReqoreControlGroup>
|
|
115
125
|
) : (
|
|
116
|
-
<ReqoreControlGroup size={zoomToSize[zoom]}>
|
|
126
|
+
<ReqoreControlGroup size={zoomToSize[zoom]} verticalAlign='flex-start'>
|
|
117
127
|
<ReqoreTag
|
|
118
128
|
label={displayKey}
|
|
119
129
|
actions={
|
|
@@ -148,7 +158,7 @@ export const ReqoreTree = ({
|
|
|
148
158
|
{isExpandable && isObject
|
|
149
159
|
? renderTree(data[key], stateKey, level + 1, [...path, key])
|
|
150
160
|
: null}
|
|
151
|
-
</
|
|
161
|
+
</StyledTreeWrapper>
|
|
152
162
|
);
|
|
153
163
|
});
|
|
154
164
|
};
|
|
@@ -226,6 +236,11 @@ export const ReqoreTree = ({
|
|
|
226
236
|
flat
|
|
227
237
|
transparent
|
|
228
238
|
size={size}
|
|
239
|
+
contentStyle={{
|
|
240
|
+
display: 'flex',
|
|
241
|
+
flexFlow: 'column',
|
|
242
|
+
gap: `${GAP_FROM_SIZE[size]}px`,
|
|
243
|
+
}}
|
|
229
244
|
{...rest}
|
|
230
245
|
actions={actions}
|
|
231
246
|
>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { map, size } from 'lodash';
|
|
2
2
|
import React, { useCallback, useRef, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
3
4
|
import { useMedia } from 'react-use';
|
|
4
5
|
import shortid from 'shortid';
|
|
5
6
|
import { useContext } from 'use-context-selector';
|
|
@@ -13,6 +14,7 @@ import { IReqoreTheme, TReqoreIntent } from '../constants/theme';
|
|
|
13
14
|
import ReqoreContext from '../context/ReqoreContext';
|
|
14
15
|
import ThemeContext from '../context/ThemeContext';
|
|
15
16
|
import { IReqoreIconName } from '../types/icons';
|
|
17
|
+
import PopoverProvider from './PopoverProvider';
|
|
16
18
|
import { IReqoreOptions } from './UIProvider';
|
|
17
19
|
|
|
18
20
|
export interface IReqoreNotificationData extends IReqoreNotificationProps {
|
|
@@ -159,99 +161,104 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options = {}
|
|
|
159
161
|
'closePopoversOnEscPress' in options ? options.closePopoversOnEscPress : true,
|
|
160
162
|
}}
|
|
161
163
|
>
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
onClose={() => {
|
|
174
|
-
if (notification.onClose) {
|
|
175
|
-
notification.onClose(notification.id);
|
|
164
|
+
<PopoverProvider uiScale={options?.uiScale}>
|
|
165
|
+
{size(notifications) > 0 ? (
|
|
166
|
+
<ReqoreNotificationsWrapper position={options.notificationsPosition}>
|
|
167
|
+
{notifications.map((notification) => (
|
|
168
|
+
<ReqoreNotification
|
|
169
|
+
{...notification}
|
|
170
|
+
key={notification.id}
|
|
171
|
+
onClick={
|
|
172
|
+
notification.onClick
|
|
173
|
+
? () => void notification.onClick(notification.id)
|
|
174
|
+
: undefined
|
|
176
175
|
}
|
|
176
|
+
onClose={() => {
|
|
177
|
+
if (notification.onClose) {
|
|
178
|
+
notification.onClose(notification.id);
|
|
179
|
+
}
|
|
177
180
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
removeNotification(notification.id);
|
|
182
|
+
}}
|
|
183
|
+
onFinish={() => {
|
|
184
|
+
if (notification.onFinish) {
|
|
185
|
+
notification.onFinish(notification.id);
|
|
186
|
+
}
|
|
184
187
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
188
|
+
removeNotification(notification.id);
|
|
189
|
+
}}
|
|
190
|
+
/>
|
|
191
|
+
))}
|
|
192
|
+
</ReqoreNotificationsWrapper>
|
|
193
|
+
) : null}
|
|
194
|
+
{children}
|
|
195
|
+
{confirmationModal.isOpen && (
|
|
196
|
+
<ReqoreModal
|
|
197
|
+
isOpen
|
|
198
|
+
flat
|
|
199
|
+
opacity={0.9}
|
|
200
|
+
blur={2}
|
|
201
|
+
width='500px'
|
|
202
|
+
intent={confirmationModal.intent}
|
|
203
|
+
label={confirmationModal.title || 'Confirm your action'}
|
|
204
|
+
icon='ErrorWarningFill'
|
|
205
|
+
className='reqore-confirmation-modal'
|
|
206
|
+
bottomActions={[
|
|
207
|
+
{
|
|
208
|
+
label: confirmationModal.cancelLabel || 'Cancel',
|
|
209
|
+
icon: 'CloseLine',
|
|
210
|
+
onClick: () => {
|
|
211
|
+
confirmationModal?.onCancel?.();
|
|
212
|
+
closeConfirmationModal();
|
|
213
|
+
},
|
|
214
|
+
position: 'left',
|
|
210
215
|
},
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
{
|
|
217
|
+
label: confirmationModal.confirmLabel || 'Confirm',
|
|
218
|
+
intent: confirmationModal.confirmButtonIntent || 'success',
|
|
219
|
+
icon: confirmationModal.confirmIcon || 'CheckLine',
|
|
220
|
+
onClick: () => {
|
|
221
|
+
confirmationModal?.onConfirm?.();
|
|
222
|
+
closeConfirmationModal();
|
|
223
|
+
},
|
|
224
|
+
position: 'right',
|
|
220
225
|
},
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
-
]}
|
|
224
|
-
>
|
|
225
|
-
<ReqoreTextEffect
|
|
226
|
-
as='p'
|
|
227
|
-
effect={{ textAlign: 'center', weight: 'bold', textSize: 'big' }}
|
|
226
|
+
]}
|
|
228
227
|
>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
228
|
+
<ReqoreTextEffect
|
|
229
|
+
as='p'
|
|
230
|
+
effect={{ textAlign: 'center', weight: 'bold', textSize: 'big' }}
|
|
231
|
+
>
|
|
232
|
+
{confirmationModal.description || 'Are you sure you want to proceed?'}
|
|
233
|
+
</ReqoreTextEffect>
|
|
234
|
+
</ReqoreModal>
|
|
235
|
+
)}
|
|
236
|
+
{map(modals, (modal, key) =>
|
|
237
|
+
React.isValidElement(modal) ? (
|
|
238
|
+
createPortal(
|
|
239
|
+
React.cloneElement(modal, {
|
|
240
|
+
key,
|
|
241
|
+
isOpen: true,
|
|
242
|
+
onClose: () => {
|
|
243
|
+
removeModal(key);
|
|
244
|
+
modal.props.onClose?.();
|
|
245
|
+
},
|
|
246
|
+
}),
|
|
247
|
+
document.querySelector('#reqore-portal')!
|
|
248
|
+
)
|
|
249
|
+
) : (
|
|
250
|
+
<ReqoreModal
|
|
251
|
+
{...modal}
|
|
252
|
+
key={key}
|
|
253
|
+
isOpen
|
|
254
|
+
onClose={() => {
|
|
255
|
+
removeModal(key);
|
|
256
|
+
modal.onClose?.();
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
)
|
|
260
|
+
)}
|
|
261
|
+
</PopoverProvider>
|
|
255
262
|
</ReqoreContext.Provider>
|
|
256
263
|
</>
|
|
257
264
|
);
|