@qoretechnologies/reqore 0.24.0 → 0.25.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/__tests__/collection.test.tsx +72 -0
- package/__tests__/panel.test.tsx +35 -2
- package/__tests__/tag.test.tsx +21 -7
- package/dist/components/Collection/index.d.ts +17 -0
- package/dist/components/Collection/index.d.ts.map +1 -0
- package/dist/components/Collection/index.js +165 -0
- package/dist/components/Collection/index.js.map +1 -0
- package/dist/components/Collection/item.d.ts +18 -0
- package/dist/components/Collection/item.d.ts.map +1 -0
- package/dist/components/Collection/item.js +168 -0
- package/dist/components/Collection/item.js.map +1 -0
- package/dist/components/Columns/index.d.ts.map +1 -1
- package/dist/components/Columns/index.js +1 -1
- package/dist/components/Columns/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +5 -3
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.d.ts.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.js +1 -1
- package/dist/components/Panel/index.d.ts +12 -12
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +66 -36
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Table/index.d.ts +4 -4
- package/dist/components/Table/index.d.ts.map +1 -1
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/row.d.ts +2 -2
- package/dist/components/Table/row.d.ts.map +1 -1
- package/dist/components/Tag/index.d.ts +2 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +11 -10
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/constants/theme.d.ts +3 -0
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js +9 -1
- package/dist/constants/theme.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +1 -0
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +5 -4
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/hooks/useTooltip.d.ts +2 -2
- package/dist/hooks/useTooltip.d.ts.map +1 -1
- package/dist/hooks/useTooltip.js +11 -2
- package/dist/hooks/useTooltip.js.map +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/dist/types/global.d.ts +29 -0
- package/dist/types/global.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/components/Collection/index.tsx +189 -0
- package/src/components/Collection/item.tsx +239 -0
- package/src/components/Columns/index.tsx +1 -0
- package/src/components/ControlGroup/index.tsx +5 -2
- package/src/components/Drawer/index.tsx +1 -1
- package/src/components/Dropdown/index.tsx +1 -0
- package/src/components/InternalPopover/index.tsx +1 -1
- package/src/components/Panel/index.tsx +188 -117
- package/src/components/Table/index.tsx +7 -7
- package/src/components/Table/row.tsx +2 -2
- package/src/components/Tag/index.tsx +27 -5
- package/src/constants/theme.ts +9 -0
- package/src/hooks/usePopover.tsx +6 -4
- package/src/hooks/useTooltip.ts +15 -4
- package/src/index.tsx +1 -0
- package/src/mock/collectionData.tsx +228 -0
- package/src/stories/Collection/Collection.stories.tsx +98 -0
- package/src/stories/Columns/Columns.stories.tsx +1 -1
- package/src/stories/Panel/Panel.stories.tsx +22 -0
- package/src/stories/Tag/Tag.stories.tsx +2 -0
- package/src/types/global.ts +31 -0
- package/tests.json +1 -1
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { map, size } from 'lodash';
|
|
2
|
+
import { rgba } from 'polished';
|
|
3
|
+
import { useContext, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useDebounce, useMeasure } from 'react-use';
|
|
5
|
+
import styled, { css } from 'styled-components';
|
|
6
|
+
import ReqoreContext from '../../context/ReqoreContext';
|
|
7
|
+
import { changeDarkness, getMainBackgroundColor } from '../../helpers/colors';
|
|
8
|
+
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
9
|
+
import { StyledBackdrop } from '../Drawer';
|
|
10
|
+
import { IReqoreDropdownItemProps } from '../Dropdown/item';
|
|
11
|
+
import {
|
|
12
|
+
IReqorePanelAction,
|
|
13
|
+
IReqorePanelBottomAction,
|
|
14
|
+
IReqorePanelProps,
|
|
15
|
+
ReqorePanel,
|
|
16
|
+
} from '../Panel';
|
|
17
|
+
import { ReqoreSpacer } from '../Spacer';
|
|
18
|
+
import ReqoreTag, { IReqoreTagProps } from '../Tag';
|
|
19
|
+
import ReqoreTagGroup from '../Tag/group';
|
|
20
|
+
|
|
21
|
+
export interface IReqoreCollectionItemProps
|
|
22
|
+
extends Omit<
|
|
23
|
+
IReqorePanelProps,
|
|
24
|
+
| 'children'
|
|
25
|
+
| 'actions'
|
|
26
|
+
| 'collapsible'
|
|
27
|
+
| 'onCollapseChange'
|
|
28
|
+
| 'isCollapsed'
|
|
29
|
+
| 'unMountContentOnCollapse'
|
|
30
|
+
| 'bottomActions'
|
|
31
|
+
> {
|
|
32
|
+
subHeader?: string;
|
|
33
|
+
content?: string | React.ReactNode;
|
|
34
|
+
expandable?: boolean;
|
|
35
|
+
expandedContent?: string | React.ReactNode;
|
|
36
|
+
expandedActions?: IReqorePanelBottomAction[];
|
|
37
|
+
image?: string;
|
|
38
|
+
actions?: IReqoreDropdownItemProps[];
|
|
39
|
+
tags?: IReqoreTagProps[];
|
|
40
|
+
maxContentHeight?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const StyledCollectionItemContent = styled.div`
|
|
44
|
+
max-height: ${({ providedHeight }) => (providedHeight ? `${providedHeight}px` : 'auto')};
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
position: relative;
|
|
47
|
+
transition: 0.3s ease-in-out;
|
|
48
|
+
|
|
49
|
+
${({ contentOverflows, theme, opacity = 1 }) =>
|
|
50
|
+
contentOverflows &&
|
|
51
|
+
css`
|
|
52
|
+
&:after {
|
|
53
|
+
content: '';
|
|
54
|
+
position: absolute;
|
|
55
|
+
bottom: 0;
|
|
56
|
+
left: 0;
|
|
57
|
+
right: 0;
|
|
58
|
+
height: 100px;
|
|
59
|
+
transition: 0.3s ease-in-out;
|
|
60
|
+
background: linear-gradient(
|
|
61
|
+
to top,
|
|
62
|
+
${rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)} 0%,
|
|
63
|
+
transparent 100%
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
`}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const ReqoreCollectionItem = ({
|
|
70
|
+
flat = true,
|
|
71
|
+
minimal = true,
|
|
72
|
+
style,
|
|
73
|
+
content,
|
|
74
|
+
actions,
|
|
75
|
+
tags,
|
|
76
|
+
expandable,
|
|
77
|
+
expandedContent,
|
|
78
|
+
expandedActions,
|
|
79
|
+
maxContentHeight,
|
|
80
|
+
...rest
|
|
81
|
+
}: IReqoreCollectionItemProps) => {
|
|
82
|
+
const [isSelected, setIsSelected] = useState(false);
|
|
83
|
+
const { getAndIncreaseZIndex } = useContext(ReqoreContext);
|
|
84
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
85
|
+
const [contentRef, sizes] = useMeasure();
|
|
86
|
+
const originalDimensions = useRef(null);
|
|
87
|
+
const [position, setPosition] = useState(undefined);
|
|
88
|
+
const theme = useReqoreTheme('main', rest.customTheme, rest.intent);
|
|
89
|
+
const [dimensions, setDimensions] = useState<any>({
|
|
90
|
+
minWidth: undefined,
|
|
91
|
+
minHeight: undefined,
|
|
92
|
+
maxWidth: undefined,
|
|
93
|
+
maxHeight: undefined,
|
|
94
|
+
width: undefined,
|
|
95
|
+
height: undefined,
|
|
96
|
+
left: undefined,
|
|
97
|
+
top: undefined,
|
|
98
|
+
transform: undefined,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (isSelected) {
|
|
103
|
+
setPosition('fixed');
|
|
104
|
+
}
|
|
105
|
+
}, [isSelected]);
|
|
106
|
+
|
|
107
|
+
useDebounce(
|
|
108
|
+
() => {
|
|
109
|
+
if (isSelected) {
|
|
110
|
+
setDimensions({
|
|
111
|
+
...dimensions,
|
|
112
|
+
width: undefined,
|
|
113
|
+
height: undefined,
|
|
114
|
+
left: '50%',
|
|
115
|
+
minWidth: '500px',
|
|
116
|
+
minHeight: '300px',
|
|
117
|
+
maxWidth: '90vw',
|
|
118
|
+
maxHeight: '90vh',
|
|
119
|
+
top: '50%',
|
|
120
|
+
transform: 'translateX(-50%) translateY(-50%)',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
100,
|
|
125
|
+
[isSelected]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
useDebounce(
|
|
129
|
+
() => {
|
|
130
|
+
if (!isSelected) {
|
|
131
|
+
setPosition(undefined);
|
|
132
|
+
setDimensions({
|
|
133
|
+
minHeight: undefined,
|
|
134
|
+
minWidth: undefined,
|
|
135
|
+
maxWidth: undefined,
|
|
136
|
+
maxHeight: undefined,
|
|
137
|
+
left: undefined,
|
|
138
|
+
top: undefined,
|
|
139
|
+
transform: 'translateX(0) translateY(0)',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
220,
|
|
144
|
+
[isSelected]
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const renderContent = () => {
|
|
148
|
+
const handleItemClick = (event) => {
|
|
149
|
+
if (expandable) {
|
|
150
|
+
if (isSelected) {
|
|
151
|
+
setDimensions(originalDimensions.current);
|
|
152
|
+
} else {
|
|
153
|
+
originalDimensions.current = {
|
|
154
|
+
left: ref.current.getBoundingClientRect()?.left,
|
|
155
|
+
top: ref.current.getBoundingClientRect()?.top,
|
|
156
|
+
width: ref.current.getBoundingClientRect()?.width,
|
|
157
|
+
height: ref.current.getBoundingClientRect()?.height,
|
|
158
|
+
transform: 'translateX(0) translateY(0)',
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
setDimensions({
|
|
162
|
+
left: ref.current.getBoundingClientRect()?.left,
|
|
163
|
+
top: ref.current.getBoundingClientRect()?.top,
|
|
164
|
+
width: ref.current.getBoundingClientRect()?.width,
|
|
165
|
+
height: ref.current.getBoundingClientRect()?.height,
|
|
166
|
+
transform: 'translateX(0) translateY(0)',
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
setIsSelected(!isSelected);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
rest?.onClick?.(event);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const actualContent: string | React.ReactNode =
|
|
176
|
+
expandedContent && isSelected ? expandedContent : content;
|
|
177
|
+
|
|
178
|
+
const actualActions: IReqorePanelAction[] | undefined = isSelected
|
|
179
|
+
? [...(actions || []), { icon: 'CloseLine', onClick: handleItemClick }]
|
|
180
|
+
: size(actions)
|
|
181
|
+
? [{ icon: 'More2Fill', actions }]
|
|
182
|
+
: undefined;
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
{position && (
|
|
187
|
+
<>
|
|
188
|
+
<div style={{ ...originalDimensions.current }} />
|
|
189
|
+
<StyledBackdrop
|
|
190
|
+
zIndex={getAndIncreaseZIndex()}
|
|
191
|
+
blur={5}
|
|
192
|
+
closable
|
|
193
|
+
onClick={handleItemClick}
|
|
194
|
+
/>
|
|
195
|
+
</>
|
|
196
|
+
)}
|
|
197
|
+
<ReqorePanel
|
|
198
|
+
{...rest}
|
|
199
|
+
flat={flat}
|
|
200
|
+
headerSize={3}
|
|
201
|
+
ref={ref}
|
|
202
|
+
minimal={minimal}
|
|
203
|
+
bottomActions={isSelected ? expandedActions : undefined}
|
|
204
|
+
style={{
|
|
205
|
+
...style,
|
|
206
|
+
position,
|
|
207
|
+
zIndex: isSelected ? getAndIncreaseZIndex() : undefined,
|
|
208
|
+
...dimensions,
|
|
209
|
+
transformOrigin: 'center',
|
|
210
|
+
}}
|
|
211
|
+
onClick={(expandable && !isSelected) || rest.onClick ? handleItemClick : undefined}
|
|
212
|
+
actions={actualActions}
|
|
213
|
+
className={`reqore-collection-item ${rest.className || ''}`}
|
|
214
|
+
>
|
|
215
|
+
<StyledCollectionItemContent
|
|
216
|
+
theme={theme}
|
|
217
|
+
opacity={rest.opacity}
|
|
218
|
+
providedHeight={isSelected ? undefined : maxContentHeight}
|
|
219
|
+
contentOverflows={!isSelected && sizes?.height > maxContentHeight}
|
|
220
|
+
>
|
|
221
|
+
<div ref={contentRef}>{actualContent}</div>
|
|
222
|
+
</StyledCollectionItemContent>
|
|
223
|
+
{size(tags) ? (
|
|
224
|
+
<>
|
|
225
|
+
<ReqoreSpacer height={10} />
|
|
226
|
+
<ReqoreTagGroup size={isSelected ? 'normal' : 'small'}>
|
|
227
|
+
{map(tags, (tagProps, index) => (
|
|
228
|
+
<ReqoreTag key={index} {...tagProps} />
|
|
229
|
+
))}
|
|
230
|
+
</ReqoreTagGroup>
|
|
231
|
+
</>
|
|
232
|
+
) : null}
|
|
233
|
+
</ReqorePanel>
|
|
234
|
+
</>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
return isSelected ? renderContent() : renderContent();
|
|
239
|
+
};
|
|
@@ -26,6 +26,7 @@ export const StyledColumns = styled.div<IStyledColumns>`
|
|
|
26
26
|
alignItems = 'normal',
|
|
27
27
|
}: IStyledColumns) => css`
|
|
28
28
|
grid-template-columns: repeat(${columns}, minmax(${minColumnWidth}, ${maxColumnWidth}));
|
|
29
|
+
grid-auto-rows: max-content;
|
|
29
30
|
grid-gap: ${columnsGap};
|
|
30
31
|
align-items: ${alignItems};
|
|
31
32
|
`}
|
|
@@ -69,8 +69,11 @@ const ReqoreControlGroup = ({
|
|
|
69
69
|
{React.Children.map(children, (child) =>
|
|
70
70
|
child
|
|
71
71
|
? React.cloneElement(child, {
|
|
72
|
-
minimal:
|
|
73
|
-
|
|
72
|
+
minimal:
|
|
73
|
+
child.props?.minimal || child.props?.minimal === false
|
|
74
|
+
? child.props.minimal
|
|
75
|
+
: minimal,
|
|
76
|
+
size: child.props?.size || size,
|
|
74
77
|
fluid,
|
|
75
78
|
})
|
|
76
79
|
: null
|
|
@@ -16,7 +16,7 @@ import { IReqorePanelAction, IReqorePanelProps, ReqorePanel } from '../Panel';
|
|
|
16
16
|
|
|
17
17
|
export type TPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
18
18
|
|
|
19
|
-
export interface IReqoreDrawerProps extends IReqorePanelProps {
|
|
19
|
+
export interface IReqoreDrawerProps extends Omit<IReqorePanelProps, 'size'> {
|
|
20
20
|
children?: any;
|
|
21
21
|
isOpen?: boolean;
|
|
22
22
|
isHidden?: boolean;
|
|
@@ -40,7 +40,7 @@ const StyledPopoverWrapper = styled.div<{ theme: IReqoreTheme }>`
|
|
|
40
40
|
z-index: 999999;
|
|
41
41
|
background-color: ${defaultColor};
|
|
42
42
|
color: ${getReadableColor(theme, undefined, undefined, false, defaultColor)};
|
|
43
|
-
border-radius:
|
|
43
|
+
border-radius: 5.5px;
|
|
44
44
|
box-shadow: rgba(31, 26, 34, 0.6) 0px 0px 4px;
|
|
45
45
|
`;
|
|
46
46
|
}}
|