@qoretechnologies/reqore 0.25.3 → 0.25.5
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__/table.test.tsx +1 -1
- package/__tests__/tree.test.tsx +14 -19
- package/dist/components/Collection/item.d.ts +1 -1
- package/dist/components/Collection/item.d.ts.map +1 -1
- package/dist/components/Collection/item.js +7 -7
- package/dist/components/Collection/item.js.map +1 -1
- package/dist/components/InternalPopover/index.d.ts.map +1 -1
- package/dist/components/InternalPopover/index.js +35 -21
- package/dist/components/InternalPopover/index.js.map +1 -1
- package/dist/components/Message/index.d.ts +3 -2
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +26 -9
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/Notifications/notification.d.ts +1 -0
- package/dist/components/Notifications/notification.d.ts.map +1 -1
- package/dist/components/Notifications/notification.js +19 -11
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Panel/index.d.ts +2 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +11 -8
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +9 -8
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Tree/index.d.ts +4 -2
- package/dist/components/Tree/index.d.ts.map +1 -1
- package/dist/components/Tree/index.js +26 -48
- package/dist/components/Tree/index.js.map +1 -1
- package/dist/constants/sizes.d.ts +8 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +9 -1
- package/dist/constants/sizes.js.map +1 -1
- package/dist/containers/PopoverProvider.d.ts.map +1 -1
- package/dist/containers/PopoverProvider.js +2 -0
- package/dist/containers/PopoverProvider.js.map +1 -1
- package/dist/hooks/usePopover.d.ts +4 -1
- package/dist/hooks/usePopover.d.ts.map +1 -1
- package/dist/hooks/usePopover.js +36 -23
- package/dist/hooks/usePopover.js.map +1 -1
- package/dist/hooks/useTooltip.js +1 -1
- package/dist/hooks/useTooltip.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Collection/item.tsx +3 -2
- package/src/components/InternalPopover/index.tsx +33 -7
- package/src/components/Message/index.tsx +18 -7
- package/src/components/Notifications/notification.tsx +11 -2
- package/src/components/Panel/index.tsx +22 -4
- package/src/components/Tag/index.tsx +23 -27
- package/src/components/Tree/index.tsx +95 -102
- package/src/constants/sizes.ts +9 -0
- package/src/containers/PopoverProvider.tsx +2 -0
- package/src/hooks/usePopover.tsx +20 -2
- package/src/hooks/useTooltip.ts +1 -1
- package/src/mock/collectionData.tsx +2 -0
- package/src/stories/Input/Input.stories.tsx +1 -1
- package/src/stories/Message/Message.stories.tsx +7 -0
- package/src/stories/Panel/Panel.stories.tsx +2 -1
- package/src/stories/Popover/Popover.stories.tsx +85 -16
- package/src/stories/Tag/Tag.stories.tsx +7 -4
- package/src/stories/Tree/Tree.stories.tsx +7 -1
- package/tests.json +1 -1
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { cloneDeep } from 'lodash';
|
|
2
|
-
import size from 'lodash/size';
|
|
3
|
-
import { rgba } from 'polished';
|
|
1
|
+
import { cloneDeep, size as lodashSize } from 'lodash';
|
|
4
2
|
import { useContext, useState } from 'react';
|
|
5
|
-
import styled
|
|
6
|
-
import { ReqoreTextarea } from '../..';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { ReqoreMessage, ReqoreTextarea } from '../..';
|
|
7
5
|
import { IReqoreTheme } from '../../constants/theme';
|
|
8
6
|
import ReqoreContext from '../../context/ReqoreContext';
|
|
9
|
-
import { changeLightness } from '../../helpers/colors';
|
|
10
7
|
import { getLineCount, getTypeFromValue } from '../../helpers/utils';
|
|
8
|
+
import { IWithReqoreSize } from '../../types/global';
|
|
11
9
|
import ReqoreButton from '../Button';
|
|
12
10
|
import ReqoreControlGroup from '../ControlGroup';
|
|
13
11
|
import ReqoreTag from '../Tag';
|
|
14
12
|
|
|
15
|
-
export interface IReqoreTreeProps {
|
|
13
|
+
export interface IReqoreTreeProps extends IWithReqoreSize {
|
|
16
14
|
data: Object | Array<any>;
|
|
17
15
|
mode?: 'tree' | 'copy';
|
|
18
16
|
expanded?: boolean;
|
|
19
17
|
showTypes?: boolean;
|
|
20
18
|
onItemClick?: (value: any, path?: string[]) => void;
|
|
21
19
|
withLabelCopy?: boolean;
|
|
20
|
+
showControls?: boolean;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
const StyledTreeWrapper = styled.div`
|
|
@@ -31,35 +30,19 @@ export interface ITreeStyle {
|
|
|
31
30
|
theme: IReqoreTheme;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
const StyledLabel = styled.span<ITreeStyle>`
|
|
35
|
-
display: inline-block;
|
|
36
|
-
line-height: 30px;
|
|
37
|
-
padding: 0 10px;
|
|
38
|
-
transition: all 0.2s ease-out;
|
|
39
|
-
|
|
40
|
-
${({ interactive, theme }: ITreeStyle) =>
|
|
41
|
-
interactive &&
|
|
42
|
-
css`
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
|
|
45
|
-
&:hover {
|
|
46
|
-
background-color: ${rgba(changeLightness(theme.main, 0.3), 0.2)};
|
|
47
|
-
border-radius: 5px;
|
|
48
|
-
}
|
|
49
|
-
`}
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
33
|
export const ReqoreTree = ({
|
|
53
34
|
data,
|
|
54
35
|
mode = 'tree',
|
|
36
|
+
size = 'normal',
|
|
55
37
|
expanded,
|
|
56
38
|
showTypes,
|
|
57
39
|
onItemClick,
|
|
58
40
|
withLabelCopy,
|
|
41
|
+
showControls = true,
|
|
59
42
|
}: IReqoreTreeProps) => {
|
|
60
43
|
const [_mode, setMode] = useState<'tree' | 'copy'>(mode);
|
|
61
44
|
const [items, setItems] = useState({});
|
|
62
|
-
const [allExpanded, setAllExpanded] = useState(expanded);
|
|
45
|
+
const [allExpanded, setAllExpanded] = useState(expanded || !showControls);
|
|
63
46
|
const [_showTypes, setShowTypes] = useState(showTypes);
|
|
64
47
|
const { addNotification } = useContext(ReqoreContext);
|
|
65
48
|
|
|
@@ -108,54 +91,59 @@ export const ReqoreTree = ({
|
|
|
108
91
|
items[stateKey] ||
|
|
109
92
|
(allExpanded && items[stateKey] !== false);
|
|
110
93
|
|
|
111
|
-
if (isObject &&
|
|
94
|
+
if (isObject && lodashSize(data[key]) === 0) {
|
|
112
95
|
isObject = false;
|
|
113
96
|
isExpandable = false;
|
|
114
97
|
}
|
|
115
98
|
|
|
116
99
|
return (
|
|
117
100
|
<div key={index} style={{ margin: level === 1 ? '15px 0' : `15px` }}>
|
|
118
|
-
|
|
119
|
-
{
|
|
101
|
+
{isObject ? (
|
|
102
|
+
<ReqoreControlGroup size={size}>
|
|
120
103
|
<ReqoreButton
|
|
121
104
|
className='reqore-tree-toggle'
|
|
122
|
-
icon={isExpandable ? 'ArrowDownSFill' : 'ArrowRightSFill'}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
105
|
+
icon={isObject ? (isExpandable ? 'ArrowDownSFill' : 'ArrowRightSFill') : undefined}
|
|
106
|
+
intent={isObject && isExpandable ? 'info' : undefined}
|
|
107
|
+
onClick={isObject ? () => handleItemClick(stateKey, isExpandable) : undefined}
|
|
108
|
+
flat
|
|
126
109
|
>
|
|
127
110
|
{displayKey}
|
|
128
111
|
</ReqoreButton>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
{_showTypes ? <ReqoreTag label={dataType} className='reqore-tree-type' /> : null}
|
|
113
|
+
</ReqoreControlGroup>
|
|
114
|
+
) : (
|
|
115
|
+
<ReqoreControlGroup size={size}>
|
|
116
|
+
<ReqoreTag
|
|
117
|
+
label={displayKey}
|
|
118
|
+
actions={
|
|
119
|
+
withLabelCopy
|
|
120
|
+
? [
|
|
121
|
+
{
|
|
122
|
+
icon: 'FileCopy2Fill',
|
|
123
|
+
onClick: () => {
|
|
124
|
+
navigator.clipboard.writeText(JSON.stringify(data[key]));
|
|
125
|
+
addNotification({
|
|
126
|
+
content: 'Successfuly copied to clipboard',
|
|
127
|
+
id: Date.now().toString(),
|
|
128
|
+
type: 'success',
|
|
129
|
+
duration: 3000,
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
]
|
|
134
|
+
: undefined
|
|
135
|
+
}
|
|
136
|
+
/>
|
|
137
|
+
{_showTypes ? <ReqoreTag className='reqore-tree-type' label={dataType} /> : null}
|
|
138
|
+
<ReqoreMessage
|
|
139
|
+
flat
|
|
140
|
+
onClick={() => onItemClick(data[key], [...path, key])}
|
|
135
141
|
className='reqore-tree-label'
|
|
136
|
-
interactive={!!onItemClick}
|
|
137
|
-
onClick={onItemClick ? () => onItemClick(data[key], [...path, key]) : undefined}
|
|
138
142
|
>
|
|
139
143
|
{JSON.stringify(data[key])}
|
|
140
|
-
</
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
<ReqoreButton
|
|
144
|
-
className='reqore-tree-copy'
|
|
145
|
-
icon='FileCopy2Fill'
|
|
146
|
-
onClick={() => {
|
|
147
|
-
navigator.clipboard.writeText(JSON.stringify(data[key]));
|
|
148
|
-
addNotification({
|
|
149
|
-
content: 'Successfuly copied to clipboard',
|
|
150
|
-
id: Date.now().toString(),
|
|
151
|
-
type: 'success',
|
|
152
|
-
duration: 3000,
|
|
153
|
-
});
|
|
154
|
-
}}
|
|
155
|
-
minimal
|
|
156
|
-
/>
|
|
157
|
-
)}
|
|
158
|
-
</ReqoreControlGroup>
|
|
144
|
+
</ReqoreMessage>
|
|
145
|
+
</ReqoreControlGroup>
|
|
146
|
+
)}
|
|
159
147
|
{isExpandable && isObject
|
|
160
148
|
? renderTree(data[key], stateKey, level + 1, [...path, key])
|
|
161
149
|
: null}
|
|
@@ -188,21 +176,23 @@ export const ReqoreTree = ({
|
|
|
188
176
|
|
|
189
177
|
return (
|
|
190
178
|
<StyledTreeWrapper className='reqore-tree'>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
179
|
+
{showControls && (
|
|
180
|
+
<ReqoreControlGroup stack size={size}>
|
|
181
|
+
{isDeep() && !allExpanded ? (
|
|
182
|
+
<ReqoreButton
|
|
183
|
+
flat
|
|
184
|
+
className='reqore-tree-expand-all'
|
|
185
|
+
icon='ArrowDownFill'
|
|
186
|
+
onClick={handleExpandClick}
|
|
187
|
+
key='expand-button'
|
|
188
|
+
>
|
|
189
|
+
Expand all
|
|
190
|
+
</ReqoreButton>
|
|
191
|
+
) : null}
|
|
192
|
+
{isDeep() &&
|
|
193
|
+
(allExpanded || lodashSize(items) > 0 ? (
|
|
205
194
|
<ReqoreButton
|
|
195
|
+
flat
|
|
206
196
|
className='reqore-tree-collapse-all'
|
|
207
197
|
icon='ArrowUpFill'
|
|
208
198
|
onClick={handleCollapseClick}
|
|
@@ -211,34 +201,36 @@ export const ReqoreTree = ({
|
|
|
211
201
|
{' '}
|
|
212
202
|
Collapse all{' '}
|
|
213
203
|
</ReqoreButton>
|
|
214
|
-
) : null}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
204
|
+
) : null)}
|
|
205
|
+
<ReqoreButton
|
|
206
|
+
flat
|
|
207
|
+
className='reqore-tree-show-types'
|
|
208
|
+
icon='CodeBoxFill'
|
|
209
|
+
active={_showTypes}
|
|
210
|
+
onClick={handleTypesClick}
|
|
211
|
+
>
|
|
212
|
+
Show types
|
|
213
|
+
</ReqoreButton>
|
|
214
|
+
<ReqoreButton
|
|
215
|
+
flat
|
|
216
|
+
className='reqore-tree-as-tree'
|
|
217
|
+
active={_mode === 'tree'}
|
|
218
|
+
onClick={handleTreeClick}
|
|
219
|
+
icon='Menu2Fill'
|
|
220
|
+
>
|
|
221
|
+
Tree View
|
|
222
|
+
</ReqoreButton>
|
|
223
|
+
<ReqoreButton
|
|
224
|
+
flat
|
|
225
|
+
className='reqore-tree-as-text'
|
|
226
|
+
onClick={handleCopyClick}
|
|
227
|
+
active={_mode === 'copy'}
|
|
228
|
+
icon='ClipboardFill'
|
|
229
|
+
>
|
|
230
|
+
Text View
|
|
231
|
+
</ReqoreButton>
|
|
232
|
+
</ReqoreControlGroup>
|
|
233
|
+
)}
|
|
242
234
|
|
|
243
235
|
{_mode === 'tree' && <div>{renderTree(data, true)}</div>}
|
|
244
236
|
|
|
@@ -247,6 +239,7 @@ export const ReqoreTree = ({
|
|
|
247
239
|
className='reqore-tree-textarea'
|
|
248
240
|
id='tree-content'
|
|
249
241
|
defaultValue={textData}
|
|
242
|
+
size={size}
|
|
250
243
|
rows={lineCount > 20 ? 20 : lineCount}
|
|
251
244
|
/>
|
|
252
245
|
)}
|
package/src/constants/sizes.ts
CHANGED
|
@@ -27,6 +27,8 @@ const PopoverProvider: React.FC<IReqorePopoverProviderProps> = ({ children, uiSc
|
|
|
27
27
|
!popperRef.current.contains(event.target) &&
|
|
28
28
|
!targetElement?.contains(event.target as Node))
|
|
29
29
|
) {
|
|
30
|
+
targetElement.style.position = 'initial';
|
|
31
|
+
targetElement.style.zIndex = 'initial';
|
|
30
32
|
removePopover(id);
|
|
31
33
|
}
|
|
32
34
|
});
|
package/src/hooks/usePopover.tsx
CHANGED
|
@@ -30,6 +30,9 @@ export interface IPopover {
|
|
|
30
30
|
closeOnAnyClick?: boolean;
|
|
31
31
|
delay?: number;
|
|
32
32
|
blur?: number;
|
|
33
|
+
opaque?: boolean;
|
|
34
|
+
maxWidth?: string;
|
|
35
|
+
maxHeight?: string;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
export interface IPopoverOptions extends IPopover {
|
|
@@ -47,6 +50,7 @@ const usePopover = ({
|
|
|
47
50
|
closeOnOutsideClick = true,
|
|
48
51
|
openOnMount = false,
|
|
49
52
|
delay,
|
|
53
|
+
...rest
|
|
50
54
|
}: IPopoverOptions) => {
|
|
51
55
|
const { addPopover, removePopover, updatePopover, popovers } = useContext(PopoverContext);
|
|
52
56
|
const { current }: MutableRefObject<string> = useRef(shortid.generate());
|
|
@@ -61,7 +65,9 @@ const usePopover = ({
|
|
|
61
65
|
|
|
62
66
|
const _addPopover = () => {
|
|
63
67
|
if (currentPopover) {
|
|
64
|
-
|
|
68
|
+
if (handler !== 'hoverStay') {
|
|
69
|
+
_removePopover?.();
|
|
70
|
+
}
|
|
65
71
|
} else if (show) {
|
|
66
72
|
timeout = setTimeout(() => {
|
|
67
73
|
addPopover?.({
|
|
@@ -73,12 +79,23 @@ const usePopover = ({
|
|
|
73
79
|
useTargetWidth,
|
|
74
80
|
closeOnOutsideClick,
|
|
75
81
|
closeOnAnyClick: handler === 'hover' || handler === 'hoverStay',
|
|
82
|
+
...rest,
|
|
76
83
|
});
|
|
84
|
+
|
|
85
|
+
if (rest?.blur > 0) {
|
|
86
|
+
targetElement.style.position = 'relative';
|
|
87
|
+
targetElement.style.zIndex = '999999';
|
|
88
|
+
}
|
|
77
89
|
}, delay || 0);
|
|
78
90
|
}
|
|
79
91
|
};
|
|
80
92
|
|
|
81
93
|
const _removePopover = () => {
|
|
94
|
+
if (rest?.blur > 0) {
|
|
95
|
+
targetElement.style.position = 'initial';
|
|
96
|
+
targetElement.style.zIndex = 'initial';
|
|
97
|
+
}
|
|
98
|
+
|
|
82
99
|
cancelTimeout();
|
|
83
100
|
removePopover?.(current);
|
|
84
101
|
};
|
|
@@ -99,6 +116,7 @@ const usePopover = ({
|
|
|
99
116
|
useTargetWidth,
|
|
100
117
|
closeOnOutsideClick,
|
|
101
118
|
closeOnAnyClick: handler === 'hover' || handler === 'hoverStay',
|
|
119
|
+
...rest,
|
|
102
120
|
});
|
|
103
121
|
}
|
|
104
122
|
}, [content?.toString()]);
|
|
@@ -125,6 +143,7 @@ const usePopover = ({
|
|
|
125
143
|
return () => {
|
|
126
144
|
if (targetElement && content) {
|
|
127
145
|
cancelTimeout();
|
|
146
|
+
|
|
128
147
|
targetElement.removeEventListener(startEvent, _addPopover);
|
|
129
148
|
|
|
130
149
|
if (endEvent) {
|
|
@@ -139,7 +158,6 @@ const usePopover = ({
|
|
|
139
158
|
}, [targetElement?.toString(), content?.toString(), current, currentPopover]);
|
|
140
159
|
|
|
141
160
|
useUnmount(() => {
|
|
142
|
-
console.log('UNMOUNTING POPOVER', content);
|
|
143
161
|
cancelTimeout();
|
|
144
162
|
});
|
|
145
163
|
|
package/src/hooks/useTooltip.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const useTooltip = (
|
|
|
14
14
|
setElement(targetElement);
|
|
15
15
|
setData(tooltip);
|
|
16
16
|
}
|
|
17
|
-
}, [targetElement?.toString(),
|
|
17
|
+
}, [targetElement?.toString(), tooltip?.toString()]);
|
|
18
18
|
|
|
19
19
|
const popoverData = typeof data === 'string' ? { content: data } : data;
|
|
20
20
|
|
|
@@ -29,6 +29,8 @@ export default [
|
|
|
29
29
|
{
|
|
30
30
|
label: 'Test with tooltip',
|
|
31
31
|
tooltip: 'This is a test item',
|
|
32
|
+
headerSize: 2,
|
|
33
|
+
contentSize: 'huge',
|
|
32
34
|
content:
|
|
33
35
|
'Hello I am a test item content and I am very long so I will wrap to the next line and I will be very long',
|
|
34
36
|
tags: [
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
const Template: Story<IReqoreInputProps> = (args: IReqoreInputProps) => {
|
|
17
17
|
const [value, setValue] = useState('Input value');
|
|
18
18
|
|
|
19
|
-
const handleValueChange = (e) => {
|
|
19
|
+
const handleValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
20
20
|
setValue(e.target.value);
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
2
|
import ReqoreInput from '../../components/Input';
|
|
3
3
|
import { IReqorePanelProps, ReqorePanel } from '../../components/Panel';
|
|
4
|
-
import { argManager, FlatArg, IntentArg } from '../utils/args';
|
|
4
|
+
import { argManager, FlatArg, IconArg, IntentArg } from '../utils/args';
|
|
5
5
|
|
|
6
6
|
const { createArg } = argManager<IReqorePanelProps>();
|
|
7
7
|
|
|
@@ -46,6 +46,7 @@ export default {
|
|
|
46
46
|
name: 'Header Size',
|
|
47
47
|
description: 'The size of the header',
|
|
48
48
|
}),
|
|
49
|
+
...IconArg(),
|
|
49
50
|
},
|
|
50
51
|
} as Meta<IReqorePanelProps>;
|
|
51
52
|
|
|
@@ -2,64 +2,109 @@ import { Meta, Story } from '@storybook/react/types-6-0';
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { IReqorePopoverProps } from '../../components/Popover';
|
|
4
4
|
import usePopover from '../../hooks/usePopover';
|
|
5
|
-
import { ReqoreButton, ReqorePopover } from '../../index';
|
|
5
|
+
import { ReqoreButton, ReqoreMessage, ReqorePanel, ReqorePopover } from '../../index';
|
|
6
|
+
import { argManager } from '../utils/args';
|
|
7
|
+
|
|
8
|
+
const { createArg } = argManager<IReqorePopoverProps>();
|
|
6
9
|
|
|
7
10
|
export default {
|
|
8
11
|
title: 'Components/Popover',
|
|
12
|
+
argTypes: {
|
|
13
|
+
...createArg('opaque', {
|
|
14
|
+
defaultValue: false,
|
|
15
|
+
name: 'Opaque',
|
|
16
|
+
description: 'Makes the popover opaque',
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
}),
|
|
19
|
+
...createArg('blur', {
|
|
20
|
+
defaultValue: 0,
|
|
21
|
+
name: 'Blur',
|
|
22
|
+
description: 'Makes the popover blurred',
|
|
23
|
+
type: 'number',
|
|
24
|
+
}),
|
|
25
|
+
...createArg('maxHeight', {
|
|
26
|
+
defaultValue: undefined,
|
|
27
|
+
name: 'Max Height',
|
|
28
|
+
description: 'Sets the max height of the popover',
|
|
29
|
+
type: 'string',
|
|
30
|
+
}),
|
|
31
|
+
...createArg('maxWidth', {
|
|
32
|
+
defaultValue: undefined,
|
|
33
|
+
name: 'Max Width',
|
|
34
|
+
description: 'Sets the max width of the popover',
|
|
35
|
+
type: 'string',
|
|
36
|
+
}),
|
|
37
|
+
...createArg('content', {
|
|
38
|
+
defaultValue: 'This is a popover',
|
|
39
|
+
name: 'Content',
|
|
40
|
+
description: 'The content of the popover',
|
|
41
|
+
type: 'string',
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
9
44
|
} as Meta<IReqorePopoverProps>;
|
|
10
45
|
|
|
11
|
-
const HoverButton = () => {
|
|
46
|
+
const HoverButton = (args: any) => {
|
|
12
47
|
return (
|
|
13
|
-
<ReqorePopover component={ReqoreButton}
|
|
48
|
+
<ReqorePopover component={ReqoreButton} isReqoreComponent {...args}>
|
|
14
49
|
Hover popover
|
|
15
50
|
</ReqorePopover>
|
|
16
51
|
);
|
|
17
52
|
};
|
|
18
53
|
|
|
19
|
-
const ClickButton = (
|
|
54
|
+
const ClickButton = (args: any) => {
|
|
20
55
|
const [refElement, setRefElement] = useState(null);
|
|
21
56
|
|
|
22
57
|
usePopover({
|
|
23
58
|
targetElement: refElement,
|
|
24
|
-
content: content || 'I am a tooltip on click',
|
|
25
59
|
handler: 'click',
|
|
26
|
-
placement,
|
|
27
60
|
closeOnOutsideClick: true,
|
|
28
61
|
noArrow: true,
|
|
29
62
|
useTargetWidth: true,
|
|
63
|
+
...args,
|
|
30
64
|
});
|
|
31
65
|
|
|
32
66
|
return <ReqoreButton ref={setRefElement}>Click popover</ReqoreButton>;
|
|
33
67
|
};
|
|
34
68
|
|
|
35
|
-
const DelayButton = (
|
|
69
|
+
const DelayButton = (args: any) => {
|
|
36
70
|
const [refElement, setRefElement] = useState(null);
|
|
37
71
|
|
|
38
72
|
usePopover({
|
|
39
73
|
targetElement: refElement,
|
|
40
|
-
|
|
41
|
-
placement,
|
|
74
|
+
|
|
42
75
|
delay: 500,
|
|
76
|
+
...args,
|
|
43
77
|
});
|
|
44
78
|
|
|
45
79
|
return <ReqoreButton ref={setRefElement}>Tooltip with delay of 500ms</ReqoreButton>;
|
|
46
80
|
};
|
|
47
81
|
|
|
82
|
+
const HoverStayButton = (args: any) => {
|
|
83
|
+
const [refElement, setRefElement] = useState(null);
|
|
84
|
+
|
|
85
|
+
usePopover({
|
|
86
|
+
targetElement: refElement,
|
|
87
|
+
handler: 'hoverStay',
|
|
88
|
+
...args,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<ReqoreButton ref={setRefElement}>Tooltip with hover start and click end events</ReqoreButton>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
48
96
|
const Template: Story<IReqorePopoverProps> = (args: IReqorePopoverProps) => {
|
|
49
97
|
return (
|
|
50
98
|
<>
|
|
51
|
-
<HoverButton />
|
|
99
|
+
<HoverButton {...args} />
|
|
52
100
|
<br />
|
|
53
101
|
<ClickButton {...args} />
|
|
54
102
|
<br />
|
|
55
103
|
<DelayButton {...args} />
|
|
56
104
|
<br />
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
isReqoreComponent
|
|
61
|
-
openOnMount
|
|
62
|
-
>
|
|
105
|
+
<HoverStayButton {...args} />
|
|
106
|
+
<br />
|
|
107
|
+
<ReqorePopover {...args} component={ReqoreButton} isReqoreComponent openOnMount>
|
|
63
108
|
Auto open popover
|
|
64
109
|
</ReqorePopover>
|
|
65
110
|
</>
|
|
@@ -67,3 +112,27 @@ const Template: Story<IReqorePopoverProps> = (args: IReqorePopoverProps) => {
|
|
|
67
112
|
};
|
|
68
113
|
|
|
69
114
|
export const Basic = Template.bind({});
|
|
115
|
+
export const CustomContent = Template.bind({});
|
|
116
|
+
CustomContent.args = {
|
|
117
|
+
content: (
|
|
118
|
+
<ReqorePanel label='This is a test' flat>
|
|
119
|
+
<ReqoreMessage flat>
|
|
120
|
+
In to am attended desirous raptures declared diverted confined at. Collected instantly
|
|
121
|
+
remaining up certainly to necessary as. Over walk dull into
|
|
122
|
+
</ReqoreMessage>
|
|
123
|
+
</ReqorePanel>
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const Blurred = Template.bind({});
|
|
128
|
+
Blurred.args = {
|
|
129
|
+
blur: 4,
|
|
130
|
+
content: (
|
|
131
|
+
<ReqorePanel label='This is a test' flat>
|
|
132
|
+
<ReqoreMessage flat>
|
|
133
|
+
In to am attended desirous raptures declared diverted confined at. Collected instantly
|
|
134
|
+
remaining up certainly to necessary as. Over walk dull into
|
|
135
|
+
</ReqoreMessage>
|
|
136
|
+
</ReqorePanel>
|
|
137
|
+
),
|
|
138
|
+
};
|
|
@@ -28,6 +28,12 @@ export default {
|
|
|
28
28
|
disable: true,
|
|
29
29
|
},
|
|
30
30
|
}),
|
|
31
|
+
...createArg('rightIcon', {
|
|
32
|
+
defaultValue: 'EBike2Line',
|
|
33
|
+
name: 'Right Icon',
|
|
34
|
+
description: 'Right icon',
|
|
35
|
+
control: 'text',
|
|
36
|
+
}),
|
|
31
37
|
...createArg('actions', {
|
|
32
38
|
defaultValue: [
|
|
33
39
|
{
|
|
@@ -37,10 +43,6 @@ export default {
|
|
|
37
43
|
intent: 'info',
|
|
38
44
|
tooltip: { content: 'I am a tooltip' },
|
|
39
45
|
},
|
|
40
|
-
{
|
|
41
|
-
icon: 'PsychotherapyFill',
|
|
42
|
-
onClick: noop,
|
|
43
|
-
},
|
|
44
46
|
{
|
|
45
47
|
icon: 'SpyFill',
|
|
46
48
|
onClick: noop,
|
|
@@ -71,6 +73,7 @@ const Template: Story<IReqoreTagGroup & IReqoreTagProps> = ({ columns, ...args }
|
|
|
71
73
|
/>
|
|
72
74
|
<ReqoreTag label='Danger Tag' icon='AlarmWarningLine' intent='danger' {...args} />
|
|
73
75
|
<ReqoreTag label='Custom Color Tag' icon='AlarmWarningLine' color='#38fdb2' {...args} />
|
|
76
|
+
<ReqoreTag label='No Buttons Tag' icon='CarLine' color='#0b4578' rightIcon={args.rightIcon} />
|
|
74
77
|
</ReqoreTagGroup>
|
|
75
78
|
);
|
|
76
79
|
};
|
|
@@ -2,7 +2,7 @@ import { Meta, Story } from '@storybook/react/types-6-0';
|
|
|
2
2
|
import { noop } from 'lodash';
|
|
3
3
|
import { IReqoreTreeProps, ReqoreTree } from '../../components/Tree';
|
|
4
4
|
import MockObject from '../../mock/object.json';
|
|
5
|
-
import { argManager } from '../utils/args';
|
|
5
|
+
import { argManager, SizeArg } from '../utils/args';
|
|
6
6
|
|
|
7
7
|
const { createArg } = argManager<IReqoreTreeProps>();
|
|
8
8
|
|
|
@@ -27,6 +27,7 @@ export default {
|
|
|
27
27
|
control: 'boolean',
|
|
28
28
|
defaultValue: false,
|
|
29
29
|
}),
|
|
30
|
+
...SizeArg,
|
|
30
31
|
},
|
|
31
32
|
} as Meta<IReqoreTreeProps>;
|
|
32
33
|
|
|
@@ -41,3 +42,8 @@ export const TextView = Template.bind({});
|
|
|
41
42
|
TextView.args = {
|
|
42
43
|
mode: 'copy',
|
|
43
44
|
};
|
|
45
|
+
|
|
46
|
+
export const NoControls = Template.bind({});
|
|
47
|
+
NoControls.args = {
|
|
48
|
+
showControls: false,
|
|
49
|
+
};
|