@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
|
@@ -4,37 +4,51 @@ 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 { RADIUS_FROM_SIZE } from '../../constants/sizes';
|
|
7
|
-
import {
|
|
8
|
-
import ReqoreThemeProvider from '../../containers/ThemeProvider';
|
|
7
|
+
import { IReqoreTheme } from '../../constants/theme';
|
|
9
8
|
import {
|
|
10
9
|
changeDarkness,
|
|
11
10
|
changeLightness,
|
|
12
11
|
getMainBackgroundColor,
|
|
13
12
|
getReadableColor,
|
|
14
13
|
} from '../../helpers/colors';
|
|
14
|
+
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
15
15
|
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
16
|
+
import { useTooltip } from '../../hooks/useTooltip';
|
|
17
|
+
import {
|
|
18
|
+
IReqoreIntent,
|
|
19
|
+
IWithReqoreCustomTheme,
|
|
20
|
+
IWithReqoreFlat,
|
|
21
|
+
IWithReqoreSize,
|
|
22
|
+
IWithReqoreTooltip,
|
|
23
|
+
} from '../../types/global';
|
|
16
24
|
import { IReqoreIconName } from '../../types/icons';
|
|
17
|
-
import ReqoreButton from '../Button';
|
|
25
|
+
import ReqoreButton, { IReqoreButtonProps } from '../Button';
|
|
26
|
+
import { StyledCollectionItemContent } from '../Collection/item';
|
|
18
27
|
import ReqoreControlGroup from '../ControlGroup';
|
|
19
28
|
import ReqoreDropdown from '../Dropdown';
|
|
20
29
|
import { IReqoreDropdownItemProps } from '../Dropdown/item';
|
|
21
30
|
import ReqoreIcon from '../Icon';
|
|
22
31
|
|
|
23
|
-
export interface IReqorePanelAction {
|
|
24
|
-
|
|
25
|
-
label?: string;
|
|
32
|
+
export interface IReqorePanelAction extends IReqoreButtonProps, IWithReqoreTooltip, IReqoreIntent {
|
|
33
|
+
label?: string | number;
|
|
26
34
|
onClick?: () => void;
|
|
27
|
-
intent?: TReqoreIntent;
|
|
28
35
|
actions?: IReqoreDropdownItemProps[];
|
|
29
|
-
|
|
30
|
-
id?: string;
|
|
36
|
+
customContent?: () => string | React.ReactNode;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
export interface IReqorePanelBottomAction extends IReqorePanelAction {
|
|
34
40
|
position: 'left' | 'right';
|
|
35
41
|
}
|
|
36
42
|
|
|
37
|
-
export interface
|
|
43
|
+
export interface IReqorePanelContent {}
|
|
44
|
+
|
|
45
|
+
export interface IReqorePanelProps
|
|
46
|
+
extends IWithReqoreSize,
|
|
47
|
+
IWithReqoreCustomTheme,
|
|
48
|
+
IWithReqoreFlat,
|
|
49
|
+
IReqoreIntent,
|
|
50
|
+
IWithReqoreTooltip,
|
|
51
|
+
React.HTMLAttributes<HTMLDivElement> {
|
|
38
52
|
as?: any;
|
|
39
53
|
children?: any;
|
|
40
54
|
icon?: IReqoreIconName;
|
|
@@ -43,11 +57,8 @@ export interface IReqorePanelProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
43
57
|
isCollapsed?: boolean;
|
|
44
58
|
onClose?: () => void;
|
|
45
59
|
rounded?: boolean;
|
|
46
|
-
actions?: IReqorePanelAction[];
|
|
60
|
+
actions?: (IReqorePanelAction | IReqorePanelAction[])[];
|
|
47
61
|
bottomActions?: IReqorePanelBottomAction[];
|
|
48
|
-
customTheme?: IReqoreCustomTheme;
|
|
49
|
-
intent?: TReqoreIntent;
|
|
50
|
-
flat?: boolean;
|
|
51
62
|
unMountContentOnCollapse?: boolean;
|
|
52
63
|
onCollapseChange?: (isCollapsed?: boolean) => void;
|
|
53
64
|
fill?: boolean;
|
|
@@ -55,6 +66,8 @@ export interface IReqorePanelProps extends React.HTMLAttributes<HTMLDivElement>
|
|
|
55
66
|
contentStyle?: React.CSSProperties;
|
|
56
67
|
opacity?: number;
|
|
57
68
|
blur?: number;
|
|
69
|
+
minimal?: boolean;
|
|
70
|
+
headerSize?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
export interface IStyledPanel extends IReqorePanelProps {
|
|
@@ -76,6 +89,26 @@ export const StyledPanel = styled.div<IStyledPanel>`
|
|
|
76
89
|
position: relative;
|
|
77
90
|
z-index: 1;
|
|
78
91
|
backdrop-filter: ${({ blur, opacity }) => (blur && opacity < 1 ? `blur(${blur}px)` : undefined)};
|
|
92
|
+
transition: 0.3s ease-in-out;
|
|
93
|
+
|
|
94
|
+
${({ interactive, theme, opacity = 1 }) =>
|
|
95
|
+
interactive
|
|
96
|
+
? css`
|
|
97
|
+
cursor: pointer;
|
|
98
|
+
|
|
99
|
+
&:hover {
|
|
100
|
+
background-color: ${rgba(changeDarkness(getMainBackgroundColor(theme), 0.06), opacity)};
|
|
101
|
+
|
|
102
|
+
${StyledCollectionItemContent}:after {
|
|
103
|
+
background: linear-gradient(
|
|
104
|
+
to top,
|
|
105
|
+
${rgba(changeDarkness(getMainBackgroundColor(theme), 0.06), opacity)} 0%,
|
|
106
|
+
transparent 100%
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`
|
|
111
|
+
: undefined}
|
|
79
112
|
|
|
80
113
|
${({ fill, isCollapsed }) =>
|
|
81
114
|
!isCollapsed && fill
|
|
@@ -125,7 +158,10 @@ export const StyledPanelBottomActions = styled(StyledPanelTitle)`
|
|
|
125
158
|
export const StyledPanelContent = styled.div<IStyledPanel>`
|
|
126
159
|
display: ${({ isCollapsed }) => (isCollapsed ? 'none' : undefined)};
|
|
127
160
|
min-height: ${({ isCollapsed }) => (isCollapsed ? undefined : '40px')};
|
|
128
|
-
padding: ${({ padded }) => (!padded ? undefined : '
|
|
161
|
+
padding: ${({ padded }) => (!padded ? undefined : '15px')};
|
|
162
|
+
// The padding is not needed when the panel is minimal and has title, since
|
|
163
|
+
// the title already has padding and is transparent
|
|
164
|
+
padding-top: ${({ minimal, hasLabel }) => (minimal && hasLabel ? '0px' : undefined)};
|
|
129
165
|
flex: 1;
|
|
130
166
|
overflow: auto;
|
|
131
167
|
`;
|
|
@@ -134,6 +170,7 @@ export const StyledPanelTitleLabel = styled.span`
|
|
|
134
170
|
white-space: nowrap;
|
|
135
171
|
text-overflow: ellipsis;
|
|
136
172
|
overflow: hidden;
|
|
173
|
+
margin: 0;
|
|
137
174
|
`;
|
|
138
175
|
|
|
139
176
|
export const StyledPanelTitleHeader = styled.div`
|
|
@@ -168,12 +205,18 @@ export const ReqorePanel = forwardRef(
|
|
|
168
205
|
onCollapseChange,
|
|
169
206
|
padded = true,
|
|
170
207
|
contentStyle,
|
|
208
|
+
headerSize = 4,
|
|
209
|
+
minimal,
|
|
210
|
+
tooltip,
|
|
171
211
|
...rest
|
|
172
212
|
}: IReqorePanelProps,
|
|
173
213
|
ref
|
|
174
214
|
) => {
|
|
175
215
|
const [_isCollapsed, setIsCollapsed] = useState(isCollapsed || false);
|
|
176
216
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
217
|
+
const { targetRef } = useCombinedRefs(ref);
|
|
218
|
+
|
|
219
|
+
useTooltip(targetRef.current, tooltip);
|
|
177
220
|
|
|
178
221
|
useUpdateEffect(() => {
|
|
179
222
|
setIsCollapsed(!!isCollapsed);
|
|
@@ -206,33 +249,50 @@ export const ReqorePanel = forwardRef(
|
|
|
206
249
|
[leftBottomActions, rightBottomActions]
|
|
207
250
|
);
|
|
208
251
|
|
|
209
|
-
const renderActions = (
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
252
|
+
const renderActions = (
|
|
253
|
+
actionOrActions: IReqorePanelAction | IReqorePanelAction[],
|
|
254
|
+
index: number
|
|
255
|
+
) => {
|
|
256
|
+
if (Array.isArray(actionOrActions)) {
|
|
257
|
+
return (
|
|
258
|
+
<ReqoreControlGroup stack minimal>
|
|
259
|
+
{actionOrActions.map(renderActions)}
|
|
260
|
+
</ReqoreControlGroup>
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const { id, actions, label, intent, className, customContent, ...rest }: IReqorePanelAction =
|
|
265
|
+
actionOrActions;
|
|
266
|
+
|
|
267
|
+
if (size(actions)) {
|
|
268
|
+
return (
|
|
269
|
+
<ReqoreDropdown
|
|
270
|
+
{...rest}
|
|
271
|
+
key={index}
|
|
272
|
+
label={label}
|
|
273
|
+
componentProps={{
|
|
274
|
+
intent,
|
|
275
|
+
id,
|
|
276
|
+
minimal: true,
|
|
277
|
+
className,
|
|
278
|
+
onClick: (e: React.MouseEvent<HTMLButtonElement>) => {
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
},
|
|
281
|
+
}}
|
|
282
|
+
items={actions}
|
|
283
|
+
/>
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (customContent) {
|
|
288
|
+
return customContent();
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return (
|
|
233
292
|
<ReqoreButton
|
|
234
293
|
{...rest}
|
|
235
294
|
id={id}
|
|
295
|
+
key={index}
|
|
236
296
|
className={className}
|
|
237
297
|
customTheme={theme}
|
|
238
298
|
intent={intent}
|
|
@@ -248,86 +308,97 @@ export const ReqorePanel = forwardRef(
|
|
|
248
308
|
{label}
|
|
249
309
|
</ReqoreButton>
|
|
250
310
|
);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const HTMLheaderElement = useMemo(() => {
|
|
314
|
+
return `h${headerSize}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
315
|
+
}, [headerSize]);
|
|
316
|
+
|
|
317
|
+
const interactive: boolean = !!(
|
|
318
|
+
rest.onClick ||
|
|
319
|
+
rest.onMouseOver ||
|
|
320
|
+
rest.onMouseEnter ||
|
|
321
|
+
rest.onDoubleClick ||
|
|
322
|
+
rest.onContextMenu
|
|
323
|
+
);
|
|
251
324
|
|
|
252
325
|
return (
|
|
253
|
-
<
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
</
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
</StyledPanel>
|
|
330
|
-
</ReqoreThemeProvider>
|
|
326
|
+
<StyledPanel
|
|
327
|
+
{...rest}
|
|
328
|
+
as={rest.as || 'div'}
|
|
329
|
+
ref={targetRef}
|
|
330
|
+
isCollapsed={_isCollapsed}
|
|
331
|
+
rounded={rounded}
|
|
332
|
+
flat={flat}
|
|
333
|
+
className={`${className || ''} reqore-panel`}
|
|
334
|
+
interactive={interactive}
|
|
335
|
+
theme={theme}
|
|
336
|
+
>
|
|
337
|
+
{hasTitleBar && (
|
|
338
|
+
<StyledPanelTitle
|
|
339
|
+
flat={flat}
|
|
340
|
+
isCollapsed={_isCollapsed}
|
|
341
|
+
collapsible={collapsible}
|
|
342
|
+
className='reqore-panel-title'
|
|
343
|
+
onClick={handleCollapseClick}
|
|
344
|
+
theme={theme}
|
|
345
|
+
opacity={rest.opacity ?? (minimal ? 0 : 1)}
|
|
346
|
+
>
|
|
347
|
+
<StyledPanelTitleHeader>
|
|
348
|
+
{icon && <ReqoreIcon icon={icon} margin='right' />}
|
|
349
|
+
{typeof label === 'string' ? (
|
|
350
|
+
<StyledPanelTitleLabel as={HTMLheaderElement}>{label}</StyledPanelTitleLabel>
|
|
351
|
+
) : (
|
|
352
|
+
label
|
|
353
|
+
)}
|
|
354
|
+
</StyledPanelTitleHeader>
|
|
355
|
+
<ReqoreControlGroup minimal>
|
|
356
|
+
{actions.map(renderActions)}
|
|
357
|
+
{collapsible && (
|
|
358
|
+
<ReqoreButton
|
|
359
|
+
customTheme={theme}
|
|
360
|
+
icon={_isCollapsed ? 'ArrowDownSLine' : 'ArrowUpSLine'}
|
|
361
|
+
onClick={handleCollapseClick}
|
|
362
|
+
tooltip={_isCollapsed ? 'Expand' : 'Collapse'}
|
|
363
|
+
/>
|
|
364
|
+
)}
|
|
365
|
+
{onClose && (
|
|
366
|
+
<ReqoreButton
|
|
367
|
+
customTheme={theme}
|
|
368
|
+
icon='CloseLine'
|
|
369
|
+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
370
|
+
e.stopPropagation();
|
|
371
|
+
onClose?.();
|
|
372
|
+
}}
|
|
373
|
+
/>
|
|
374
|
+
)}
|
|
375
|
+
</ReqoreControlGroup>
|
|
376
|
+
</StyledPanelTitle>
|
|
377
|
+
)}
|
|
378
|
+
{!_isCollapsed || (_isCollapsed && !unMountContentOnCollapse) ? (
|
|
379
|
+
<StyledPanelContent
|
|
380
|
+
className='reqore-panel-content'
|
|
381
|
+
hasLabel={!!label}
|
|
382
|
+
isCollapsed={_isCollapsed}
|
|
383
|
+
style={contentStyle}
|
|
384
|
+
padded={padded}
|
|
385
|
+
minimal={minimal}
|
|
386
|
+
>
|
|
387
|
+
{children}
|
|
388
|
+
</StyledPanelContent>
|
|
389
|
+
) : null}
|
|
390
|
+
{hasBottomActions && !_isCollapsed ? (
|
|
391
|
+
<StyledPanelBottomActions
|
|
392
|
+
flat={flat}
|
|
393
|
+
className='reqore-panel-bottom-actions'
|
|
394
|
+
theme={theme}
|
|
395
|
+
opacity={rest.opacity ?? (minimal ? 0 : 1)}
|
|
396
|
+
>
|
|
397
|
+
<ReqoreControlGroup minimal>{leftBottomActions.map(renderActions)}</ReqoreControlGroup>
|
|
398
|
+
<ReqoreControlGroup minimal>{rightBottomActions.map(renderActions)}</ReqoreControlGroup>
|
|
399
|
+
</StyledPanelBottomActions>
|
|
400
|
+
) : null}
|
|
401
|
+
</StyledPanel>
|
|
331
402
|
);
|
|
332
403
|
}
|
|
333
404
|
);
|
|
@@ -16,7 +16,7 @@ import { IReqoreTableHeaderStyle, StyledTableHeader } from './headerCell';
|
|
|
16
16
|
import { fixSort, flipSortDirection, sortTableData } from './helpers';
|
|
17
17
|
|
|
18
18
|
export type TReqoreTableColumnContent =
|
|
19
|
-
| React.FC<{ [key: string]: any; _selectId?: string }>
|
|
19
|
+
| React.FC<{ [key: string]: any; _selectId?: string | number }>
|
|
20
20
|
| 'time-ago'
|
|
21
21
|
| 'tag'
|
|
22
22
|
| `tag:${TReqoreIntent}`
|
|
@@ -39,13 +39,13 @@ export interface IReqoreTableColumn extends IReqoreIntent {
|
|
|
39
39
|
icon?: IReqoreIconName;
|
|
40
40
|
iconSize?: string;
|
|
41
41
|
tooltip?: string;
|
|
42
|
-
cellTooltip?: (data: { [key: string]: any; _selectId?: string }) => string | JSX.Element;
|
|
43
|
-
onCellClick?: (data: { [key: string]: any; _selectId?: string }) => void;
|
|
42
|
+
cellTooltip?: (data: { [key: string]: any; _selectId?: string | number }) => string | JSX.Element;
|
|
43
|
+
onCellClick?: (data: { [key: string]: any; _selectId?: string | number }) => void;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface IReqoreTableRowData {
|
|
47
47
|
[key: string]: any;
|
|
48
|
-
_selectId?: string;
|
|
48
|
+
_selectId?: string | number;
|
|
49
49
|
_intent?: TReqoreIntent;
|
|
50
50
|
_disabled?: boolean;
|
|
51
51
|
}
|
|
@@ -146,7 +146,7 @@ const ReqoreTable = ({
|
|
|
146
146
|
const [leftScroll, setLeftScroll] = useState<number>(0);
|
|
147
147
|
const [_data, setData] = useState<IReqoreTableData>(data || []);
|
|
148
148
|
const [_sort, setSort] = useState<IReqoreTableSort>(fixSort(sort));
|
|
149
|
-
const [_selected, setSelected] = useState<string[]>([]);
|
|
149
|
+
const [_selected, setSelected] = useState<(string | number)[]>([]);
|
|
150
150
|
const [_selectedQuant, setSelectedQuant] = useState<'all' | 'none' | 'some'>('none');
|
|
151
151
|
const [wrapperRef, sizes] = useMeasure();
|
|
152
152
|
const theme = useReqoreTheme('main', customTheme, intent);
|
|
@@ -197,7 +197,7 @@ const ReqoreTable = ({
|
|
|
197
197
|
});
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
const handleSelectClick = (selectId: string) => {
|
|
200
|
+
const handleSelectClick = (selectId: string | number) => {
|
|
201
201
|
setSelected((current) => {
|
|
202
202
|
let newSelected = [...current];
|
|
203
203
|
const isSelected = newSelected.find((selected) => selectId === selected);
|
|
@@ -216,7 +216,7 @@ const ReqoreTable = ({
|
|
|
216
216
|
switch (_selectedQuant) {
|
|
217
217
|
case 'none':
|
|
218
218
|
case 'some': {
|
|
219
|
-
const selectableData: string[] = _data
|
|
219
|
+
const selectableData: (string | number)[] = _data
|
|
220
220
|
.filter((datum) => datum._selectId ?? false)
|
|
221
221
|
.map((datum) => datum._selectId);
|
|
222
222
|
|
|
@@ -23,8 +23,8 @@ export interface IReqoreTableRowOptions {
|
|
|
23
23
|
columns: IReqoreTableColumn[];
|
|
24
24
|
data?: IReqoreTableData;
|
|
25
25
|
selectable?: boolean;
|
|
26
|
-
onSelectClick?: (selectId: string) => void;
|
|
27
|
-
selected?: string[];
|
|
26
|
+
onSelectClick?: (selectId: string | number) => void;
|
|
27
|
+
selected?: (string | number)[];
|
|
28
28
|
onRowClick?: IReqoreTableRowClick;
|
|
29
29
|
striped?: boolean;
|
|
30
30
|
selectedRowIntent?: TReqoreIntent;
|
|
@@ -28,7 +28,8 @@ export interface IReqoreTagProps
|
|
|
28
28
|
IWithReqoreTooltip,
|
|
29
29
|
IReqoreDisabled {
|
|
30
30
|
size?: TSizes;
|
|
31
|
-
label?: string;
|
|
31
|
+
label?: string | number;
|
|
32
|
+
labelKey?: string | number;
|
|
32
33
|
onRemoveClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
33
34
|
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
34
35
|
icon?: IReqoreIconName;
|
|
@@ -59,11 +60,23 @@ export const StyledTag = styled.div<IReqoreTagStyle>`
|
|
|
59
60
|
min-width: ${({ size }) => SIZE_TO_PX[size]}px;
|
|
60
61
|
border-radius: ${({ badge, size }) => (badge ? 20 : RADIUS_FROM_SIZE[size])}px;
|
|
61
62
|
width: ${({ width }) => width || undefined};
|
|
63
|
+
transition: all 0.2s ease-out;
|
|
62
64
|
|
|
63
|
-
${({ theme, color }) =>
|
|
65
|
+
${({ theme, color, labelKey }) =>
|
|
64
66
|
css`
|
|
65
67
|
background-color: ${color || changeLightness(theme.main, 0.1)};
|
|
66
68
|
color: ${color ? getReadableColorFrom(color) : getReadableColor(theme, undefined, undefined)};
|
|
69
|
+
|
|
70
|
+
${StyledTagContentWrapper} {
|
|
71
|
+
background-color: ${labelKey ? changeLightness(color || theme.main, 0.05) : undefined};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
${StyledTagContent} {
|
|
75
|
+
background-color: ${labelKey ? changeLightness(color || theme.main, 0.1) : undefined};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
${StyledTagContentKey} {
|
|
79
|
+
background-color: ${labelKey ? changeLightness(color || theme.main, 0.05) : undefined};
|
|
67
80
|
}
|
|
68
81
|
`}
|
|
69
82
|
|
|
@@ -90,23 +103,29 @@ export const StyledTag = styled.div<IReqoreTagStyle>`
|
|
|
90
103
|
`;
|
|
91
104
|
|
|
92
105
|
const StyledTagContentWrapper = styled.div<{ size: TSizes }>`
|
|
93
|
-
padding: 0 ${({ size }) => PADDING_FROM_SIZE[size]}px;
|
|
94
106
|
display: flex;
|
|
95
107
|
align-items: center;
|
|
96
108
|
justify-content: center;
|
|
97
109
|
flex-shrink: 0;
|
|
98
110
|
flex: 1;
|
|
99
111
|
overflow: hidden;
|
|
112
|
+
height: 100%;
|
|
100
113
|
`;
|
|
101
114
|
|
|
102
115
|
const StyledTagContent = styled.span<{ size: TSizes }>`
|
|
116
|
+
padding: 0 ${({ size }) => PADDING_FROM_SIZE[size]}px;
|
|
103
117
|
height: 100%;
|
|
118
|
+
display: flex;
|
|
104
119
|
align-items: center;
|
|
105
120
|
overflow: hidden;
|
|
106
121
|
text-overflow: ellipsis;
|
|
107
122
|
white-space: nowrap;
|
|
108
123
|
`;
|
|
109
124
|
|
|
125
|
+
const StyledTagContentKey = styled(StyledTagContent)`
|
|
126
|
+
font-weight: 800;
|
|
127
|
+
`;
|
|
128
|
+
|
|
110
129
|
const StyledButtonWrapper = styled.div<IReqoreTagStyle>`
|
|
111
130
|
flex-shrink: 0;
|
|
112
131
|
font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
|
|
@@ -115,7 +134,7 @@ const StyledButtonWrapper = styled.div<IReqoreTagStyle>`
|
|
|
115
134
|
display: flex;
|
|
116
135
|
justify-content: center;
|
|
117
136
|
align-items: center;
|
|
118
|
-
transition:
|
|
137
|
+
transition: all 0.2s ease-out;
|
|
119
138
|
|
|
120
139
|
${({ theme, color }) =>
|
|
121
140
|
css`
|
|
@@ -138,6 +157,7 @@ const ReqoreTag = forwardRef(
|
|
|
138
157
|
{
|
|
139
158
|
tooltip,
|
|
140
159
|
label,
|
|
160
|
+
labelKey,
|
|
141
161
|
icon,
|
|
142
162
|
rightIcon,
|
|
143
163
|
className,
|
|
@@ -163,6 +183,7 @@ const ReqoreTag = forwardRef(
|
|
|
163
183
|
return (
|
|
164
184
|
<StyledTag
|
|
165
185
|
{...rest}
|
|
186
|
+
labelKey={labelKey}
|
|
166
187
|
color={customColor}
|
|
167
188
|
className={`${className || ''} reqore-tag`}
|
|
168
189
|
size={size}
|
|
@@ -176,9 +197,10 @@ const ReqoreTag = forwardRef(
|
|
|
176
197
|
<ReqoreIcon
|
|
177
198
|
icon={icon}
|
|
178
199
|
size={`${TEXT_FROM_SIZE[size]}px`}
|
|
179
|
-
margin={label || rightIcon ? '
|
|
200
|
+
margin={label || rightIcon ? 'left' : 'both'}
|
|
180
201
|
/>
|
|
181
202
|
)}
|
|
203
|
+
{labelKey && <StyledTagContentKey size={size}>{labelKey}</StyledTagContentKey>}
|
|
182
204
|
{label && <StyledTagContent size={size}>{label}</StyledTagContent>}
|
|
183
205
|
{rightIcon && (
|
|
184
206
|
<ReqoreIcon
|
package/src/constants/theme.ts
CHANGED
|
@@ -100,3 +100,12 @@ export const DEFAULT_THEME: IReqoreTheme = {
|
|
|
100
100
|
intents: DEFAULT_INTENTS,
|
|
101
101
|
notifications: {},
|
|
102
102
|
};
|
|
103
|
+
|
|
104
|
+
export const ReqoreIntents: { [key: string]: TReqoreIntent } = {
|
|
105
|
+
INFO: 'info',
|
|
106
|
+
SUCCESS: 'success',
|
|
107
|
+
PENDING: 'pending',
|
|
108
|
+
WARNING: 'warning',
|
|
109
|
+
DANGER: 'danger',
|
|
110
|
+
MUTED: 'muted',
|
|
111
|
+
};
|
package/src/hooks/usePopover.tsx
CHANGED
|
@@ -29,6 +29,7 @@ export interface IPopover {
|
|
|
29
29
|
closeOnOutsideClick?: boolean;
|
|
30
30
|
closeOnAnyClick?: boolean;
|
|
31
31
|
delay?: number;
|
|
32
|
+
blur?: number;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export interface IPopoverOptions extends IPopover {
|
|
@@ -88,7 +89,7 @@ const usePopover = ({
|
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
useUpdateEffect(() => {
|
|
91
|
-
if (show) {
|
|
92
|
+
if (content && show) {
|
|
92
93
|
updatePopover?.(current, {
|
|
93
94
|
id: current,
|
|
94
95
|
content,
|
|
@@ -100,13 +101,13 @@ const usePopover = ({
|
|
|
100
101
|
closeOnAnyClick: handler === 'hover' || handler === 'hoverStay',
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
|
-
}, [content]);
|
|
104
|
+
}, [content?.toString()]);
|
|
104
105
|
|
|
105
106
|
useEffect(() => {
|
|
106
107
|
if (openOnMount && targetElement) {
|
|
107
108
|
_addPopover();
|
|
108
109
|
}
|
|
109
|
-
}, [targetElement]);
|
|
110
|
+
}, [targetElement?.toString()]);
|
|
110
111
|
|
|
111
112
|
useEffect(() => {
|
|
112
113
|
if (targetElement && content) {
|
|
@@ -135,9 +136,10 @@ const usePopover = ({
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
};
|
|
138
|
-
}, [targetElement, content, current, currentPopover]);
|
|
139
|
+
}, [targetElement?.toString(), content?.toString(), current, currentPopover]);
|
|
139
140
|
|
|
140
141
|
useUnmount(() => {
|
|
142
|
+
console.log('UNMOUNTING POPOVER', content);
|
|
141
143
|
cancelTimeout();
|
|
142
144
|
});
|
|
143
145
|
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { IReqoreTooltip, TReqoreTooltipProp } from '../types/global';
|
|
2
3
|
import usePopover from './usePopover';
|
|
3
4
|
|
|
4
5
|
export const useTooltip = (
|
|
5
6
|
targetElement: HTMLElement | undefined,
|
|
6
|
-
tooltip?:
|
|
7
|
+
tooltip?: TReqoreTooltipProp
|
|
7
8
|
): void => {
|
|
8
|
-
const
|
|
9
|
+
const [element, setElement] = useState<HTMLElement | undefined>(undefined);
|
|
10
|
+
const [data, setData] = useState<string | IReqoreTooltip | undefined>(undefined);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (targetElement && tooltip) {
|
|
14
|
+
setElement(targetElement);
|
|
15
|
+
setData(tooltip);
|
|
16
|
+
}
|
|
17
|
+
}, [targetElement?.toString(), JSON.stringify(tooltip)]);
|
|
18
|
+
|
|
19
|
+
const popoverData = typeof data === 'string' ? { content: data } : data;
|
|
9
20
|
|
|
10
21
|
usePopover({
|
|
11
22
|
...popoverData,
|
|
12
|
-
targetElement,
|
|
23
|
+
targetElement: element,
|
|
13
24
|
show: !!popoverData?.content,
|
|
14
25
|
});
|
|
15
26
|
};
|
package/src/index.tsx
CHANGED
|
@@ -2,6 +2,7 @@ export { default as ReqoreBreadcrumbs } from './components/Breadcrumbs';
|
|
|
2
2
|
export { default as ReqoreBreadcrumbsItem } from './components/Breadcrumbs/item';
|
|
3
3
|
export { default as ReqoreButton } from './components/Button';
|
|
4
4
|
export { default as ReqoreCheckbox } from './components/Checkbox';
|
|
5
|
+
export { ReqoreCollection } from './components/Collection';
|
|
5
6
|
export { ReqoreColumns } from './components/Columns';
|
|
6
7
|
export { ReqoreColumn } from './components/Columns/column';
|
|
7
8
|
export { ReqoreComment } from './components/Comment';
|