@qoretechnologies/reqore 0.38.0 → 0.38.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__/dropdown.test.tsx +10 -8
- package/__tests__/table.test.tsx +0 -1
- package/build-storybook.log +144 -141
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +4 -4
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +2 -2
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +5 -5
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Dropdown/item.d.ts +6 -5
- package/dist/components/Dropdown/item.d.ts.map +1 -1
- package/dist/components/Dropdown/item.js +14 -6
- package/dist/components/Dropdown/item.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +4 -2
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +33 -7
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js +3 -3
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/InputClearButton/index.d.ts.map +1 -1
- package/dist/components/InputClearButton/index.js +1 -1
- package/dist/components/InputClearButton/index.js.map +1 -1
- package/dist/components/Menu/index.js +4 -4
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts +1 -1
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +6 -6
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/Message/index.d.ts.map +1 -1
- package/dist/components/Message/index.js +3 -4
- package/dist/components/Message/index.js.map +1 -1
- package/dist/components/MultiSelect/index.js +2 -2
- package/dist/components/MultiSelect/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 +10 -21
- package/dist/components/Notifications/notification.js.map +1 -1
- package/dist/components/Panel/LabelEditor.d.ts.map +1 -1
- package/dist/components/Panel/LabelEditor.js +1 -1
- package/dist/components/Panel/LabelEditor.js.map +1 -1
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +26 -16
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Tabs/list.d.ts.map +1 -1
- package/dist/components/Tabs/list.js +3 -4
- package/dist/components/Tabs/list.js.map +1 -1
- package/dist/components/Tag/index.js +2 -2
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +4 -0
- package/dist/components/Textarea/index.d.ts.map +1 -1
- package/dist/components/Textarea/index.js +29 -8
- package/dist/components/Textarea/index.js.map +1 -1
- package/dist/constants/sizes.d.ts +7 -0
- package/dist/constants/sizes.d.ts.map +1 -1
- package/dist/constants/sizes.js +8 -1
- package/dist/constants/sizes.js.map +1 -1
- package/migration-storybook.log +49 -81
- package/package.json +15 -15
- package/src/components/Button/index.tsx +5 -3
- package/src/components/Checkbox/index.tsx +7 -2
- package/src/components/Dropdown/index.tsx +16 -14
- package/src/components/Dropdown/item.tsx +26 -10
- package/src/components/Dropdown/list.tsx +80 -30
- package/src/components/Input/index.tsx +9 -3
- package/src/components/InputClearButton/index.tsx +1 -0
- package/src/components/Menu/index.tsx +2 -2
- package/src/components/Menu/item.tsx +93 -85
- package/src/components/Message/index.tsx +39 -35
- package/src/components/MultiSelect/index.tsx +2 -2
- package/src/components/Notifications/notification.tsx +34 -30
- package/src/components/Panel/LabelEditor.tsx +1 -0
- package/src/components/Panel/index.tsx +28 -17
- package/src/components/Tabs/list.tsx +7 -5
- package/src/components/Tag/index.tsx +3 -3
- package/src/components/Textarea/index.tsx +94 -30
- package/src/constants/sizes.ts +8 -0
- package/src/stories/Button/Button.stories.tsx +5 -0
- package/src/stories/Dropdown/Dropdown.stories.tsx +58 -0
- package/src/stories/Dropdown/DropdownTests.stories.tsx +111 -0
- package/src/stories/Input/Input.stories.tsx +1 -0
- package/src/stories/Message/Message.stories.tsx +13 -5
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +2 -2
- package/src/stories/Panel/Panel.stories.tsx +96 -0
- package/src/stories/TextArea/TextArea.stories.tsx +50 -1
- package/src/stories/TextArea/TextAreaTests.stories.tsx +103 -0
- package/tests.json +1 -1
|
@@ -14,9 +14,7 @@ import ReqoreDropdownList, {
|
|
|
14
14
|
} from './list';
|
|
15
15
|
|
|
16
16
|
export interface IReqoreDropdownProps
|
|
17
|
-
extends Partial<
|
|
18
|
-
Omit<IPopoverOptions, 'openOnMount' | 'show' | 'targetElement' | 'wrapperProps'>
|
|
19
|
-
> {
|
|
17
|
+
extends Partial<Omit<IPopoverOptions, 'openOnMount' | 'targetElement' | 'wrapperProps'>> {
|
|
20
18
|
items?: IReqoreDropdownItem[];
|
|
21
19
|
multiSelect?: boolean;
|
|
22
20
|
buttonStyle?: React.CSSProperties;
|
|
@@ -42,16 +40,18 @@ export interface IReqoreDropdownProps
|
|
|
42
40
|
paging?: TReqorePaginationType<IReqoreDropdownItem>;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
const ReqoreDropdownListWrapper = (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
const ReqoreDropdownListWrapper = memo(
|
|
44
|
+
({
|
|
45
|
+
wrapperProps,
|
|
46
|
+
...rest
|
|
47
|
+
}: IReqoreDropdownListProps & { wrapperProps?: IReqoreDropdownProps['wrapperProps'] }) => {
|
|
48
|
+
return (
|
|
49
|
+
<ReqorePanel flat size='small' {...wrapperProps}>
|
|
50
|
+
<ReqoreDropdownList {...rest} />
|
|
51
|
+
</ReqorePanel>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
55
|
|
|
56
56
|
function ReqoreDropdown<T = IReqoreButtonProps>({
|
|
57
57
|
items,
|
|
@@ -87,6 +87,7 @@ function ReqoreDropdown<T = IReqoreButtonProps>({
|
|
|
87
87
|
inputProps,
|
|
88
88
|
scrollToSelected,
|
|
89
89
|
paging,
|
|
90
|
+
show,
|
|
90
91
|
...rest
|
|
91
92
|
}: IReqoreDropdownProps & T) {
|
|
92
93
|
const componentProps = useMemo(
|
|
@@ -120,7 +121,7 @@ function ReqoreDropdown<T = IReqoreButtonProps>({
|
|
|
120
121
|
filter={filter}
|
|
121
122
|
/>
|
|
122
123
|
) : undefined;
|
|
123
|
-
}, [items]);
|
|
124
|
+
}, [items, onItemSelect]);
|
|
124
125
|
|
|
125
126
|
return (
|
|
126
127
|
<ReqorePopover
|
|
@@ -142,6 +143,7 @@ function ReqoreDropdown<T = IReqoreButtonProps>({
|
|
|
142
143
|
openOnMount={isDefaultOpen}
|
|
143
144
|
content={popoverContent}
|
|
144
145
|
passPopoverData={passPopoverData}
|
|
146
|
+
show={show}
|
|
145
147
|
>
|
|
146
148
|
{children || label}
|
|
147
149
|
</ReqorePopover>
|
|
@@ -1,17 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { size } from 'lodash';
|
|
2
|
+
import { memo, useCallback } from 'react';
|
|
3
|
+
import { ReqoreMenuItem } from '../..';
|
|
4
|
+
import ReqoreMenuDivider, { IReqoreMenuDividerProps } from '../Menu/divider';
|
|
3
5
|
import { IReqoreDropdownItem } from './list';
|
|
4
6
|
|
|
5
|
-
export interface IReqoreDropdownItemProps extends
|
|
7
|
+
export interface IReqoreDropdownItemProps extends IReqoreDropdownItem {
|
|
8
|
+
onItemClick: (item: IReqoreDropdownItem) => void;
|
|
9
|
+
scrollIntoView?: boolean;
|
|
10
|
+
}
|
|
6
11
|
|
|
7
|
-
export const ReqoreDropdownItem = (
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
);
|
|
12
|
+
export const ReqoreDropdownItem = memo(
|
|
13
|
+
({ onItemClick, scrollIntoView, ...rest }: IReqoreDropdownItemProps) => {
|
|
14
|
+
const handleItemClick = useCallback(() => {
|
|
15
|
+
onItemClick(rest);
|
|
16
|
+
}, [onItemClick, rest]);
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
return (
|
|
19
|
+
<ReqoreMenuItem
|
|
20
|
+
{...rest}
|
|
21
|
+
_insidePopover={size(rest.items) ? false : rest._insidePopover}
|
|
22
|
+
label={rest.label || rest.value}
|
|
23
|
+
onClick={handleItemClick}
|
|
24
|
+
rightIcon={rest.selected ? 'CheckLine' : rest.rightIcon}
|
|
25
|
+
scrollIntoView={scrollIntoView}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
);
|
|
14
30
|
|
|
15
|
-
export const ReqoreDropdownDivider = (props:
|
|
31
|
+
export const ReqoreDropdownDivider = (props: IReqoreMenuDividerProps) => (
|
|
16
32
|
<ReqoreMenuDivider {...props} />
|
|
17
33
|
);
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
|
-
import React, { memo, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { TReqorePaginationType } from '../../constants/paging';
|
|
4
4
|
import { PADDING_FROM_SIZE } from '../../constants/sizes';
|
|
5
5
|
import { ReqorePaginationContainer } from '../../containers/Paging';
|
|
6
6
|
import { IReqoreComponent } from '../../types/global';
|
|
7
|
+
import ReqoreButton from '../Button';
|
|
8
|
+
import ReqoreControlGroup from '../ControlGroup';
|
|
7
9
|
import ReqoreInput, { IReqoreInputProps } from '../Input';
|
|
8
10
|
import ReqoreMenu from '../Menu';
|
|
9
|
-
import ReqoreMenuDivider from '../Menu/divider';
|
|
10
|
-
import
|
|
11
|
+
import ReqoreMenuDivider, { IReqoreMenuDividerProps } from '../Menu/divider';
|
|
12
|
+
import { IReqoreMenuItemProps } from '../Menu/item';
|
|
11
13
|
import { ReqoreVerticalSpacer } from '../Spacer';
|
|
12
|
-
import {
|
|
14
|
+
import { ReqoreDropdownItem } from './item';
|
|
13
15
|
|
|
14
16
|
export type TDropdownItemOnClick = (item: IReqoreDropdownItem) => void;
|
|
15
17
|
export interface IReqoreDropdownItem
|
|
16
|
-
extends Omit<IReqoreMenuItemProps, 'onClick' | '
|
|
18
|
+
extends Omit<IReqoreMenuItemProps, 'onClick' | 'onRightIconClick'> {
|
|
17
19
|
value?: any;
|
|
20
|
+
items?: TReqoreDropdownItems;
|
|
18
21
|
onClick?: TDropdownItemOnClick;
|
|
19
22
|
divider?: boolean;
|
|
20
23
|
dividerAlign?: 'left' | 'center' | 'right';
|
|
@@ -40,6 +43,8 @@ export interface IReqoreDropdownListProps extends IReqoreComponent {
|
|
|
40
43
|
inputProps?: IReqoreInputProps;
|
|
41
44
|
scrollToSelected?: boolean;
|
|
42
45
|
paging?: TReqorePaginationType<TReqoreDropdownItem>;
|
|
46
|
+
|
|
47
|
+
_onBackClick?: () => void;
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
const ReqoreDropdownList = memo(
|
|
@@ -58,10 +63,12 @@ const ReqoreDropdownList = memo(
|
|
|
58
63
|
onFilterChange,
|
|
59
64
|
filterPlaceholder,
|
|
60
65
|
filter,
|
|
66
|
+
_onBackClick,
|
|
61
67
|
}: IReqoreDropdownListProps) => {
|
|
62
68
|
const [_items, setItems] = useState<TReqoreDropdownItems>(items);
|
|
63
69
|
const [query, setQuery] = useState<string | number>(onFilterChange ? '' : filter || '');
|
|
64
70
|
const [menuRef, setMenuRef] = useState<HTMLDivElement>(undefined);
|
|
71
|
+
const [selectedItem, setSelectedItem] = useState<IReqoreDropdownItem>(undefined);
|
|
65
72
|
|
|
66
73
|
useEffect(() => {
|
|
67
74
|
setItems(items);
|
|
@@ -95,31 +102,76 @@ const ReqoreDropdownList = memo(
|
|
|
95
102
|
}
|
|
96
103
|
};
|
|
97
104
|
|
|
98
|
-
const handleItemClick = (
|
|
99
|
-
|
|
100
|
-
item.
|
|
101
|
-
|
|
105
|
+
const handleItemClick = useCallback(
|
|
106
|
+
(item: IReqoreDropdownItem): void => {
|
|
107
|
+
if (size(item.items)) {
|
|
108
|
+
setSelectedItem(item);
|
|
102
109
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (item.onClick) {
|
|
114
|
+
item.onClick(item);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (onItemSelect) {
|
|
118
|
+
onItemSelect(item);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[onItemSelect, selectedItem]
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
if (selectedItem) {
|
|
125
|
+
return (
|
|
126
|
+
<ReqoreDropdownList
|
|
127
|
+
{...{
|
|
128
|
+
items: selectedItem.items,
|
|
129
|
+
multiSelect,
|
|
130
|
+
listStyle,
|
|
131
|
+
_popoverId,
|
|
132
|
+
filterable,
|
|
133
|
+
width,
|
|
134
|
+
height,
|
|
135
|
+
onItemSelect,
|
|
136
|
+
inputProps,
|
|
137
|
+
scrollToSelected,
|
|
138
|
+
paging,
|
|
139
|
+
onFilterChange,
|
|
140
|
+
filterPlaceholder,
|
|
141
|
+
filter,
|
|
142
|
+
_onBackClick: () => setSelectedItem(undefined),
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
107
147
|
|
|
108
148
|
return (
|
|
109
149
|
<>
|
|
110
|
-
{filterable
|
|
150
|
+
{filterable || _onBackClick ? (
|
|
111
151
|
<>
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
152
|
+
<ReqoreControlGroup fluid>
|
|
153
|
+
{_onBackClick && (
|
|
154
|
+
<ReqoreButton
|
|
155
|
+
icon='ArrowLeftSLine'
|
|
156
|
+
fluid
|
|
157
|
+
onClick={_onBackClick}
|
|
158
|
+
className='reqore-dropdown-back-button'
|
|
159
|
+
/>
|
|
160
|
+
)}
|
|
161
|
+
{filterable && (
|
|
162
|
+
<ReqoreInput
|
|
163
|
+
value={onFilterChange ? filter : query}
|
|
164
|
+
icon='SearchLine'
|
|
165
|
+
onChange={handleQueryChange}
|
|
166
|
+
placeholder={filterPlaceholder || `Search ${size(_items)} items...`}
|
|
167
|
+
onClearClick={() => (onFilterChange ? onFilterChange('') : setQuery(''))}
|
|
168
|
+
{...inputProps}
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
171
|
+
</ReqoreControlGroup>
|
|
120
172
|
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />
|
|
121
173
|
</>
|
|
122
|
-
)}
|
|
174
|
+
) : null}
|
|
123
175
|
<ReqorePaginationContainer type={paging} items={filteredItems} scrollContainer={menuRef}>
|
|
124
176
|
{(finalItems, Controls, { includeBottomControls }) => (
|
|
125
177
|
<ReqoreMenu
|
|
@@ -132,20 +184,18 @@ const ReqoreDropdownList = memo(
|
|
|
132
184
|
ref={setMenuRef}
|
|
133
185
|
>
|
|
134
186
|
{finalItems.map(
|
|
135
|
-
({
|
|
187
|
+
({ dividerAlign, divider, ...item }: IReqoreDropdownItem, index: number) =>
|
|
136
188
|
divider ? (
|
|
137
189
|
<ReqoreMenuDivider
|
|
138
190
|
key={index}
|
|
139
|
-
{...(item as unknown as
|
|
191
|
+
{...(item as unknown as IReqoreMenuDividerProps)}
|
|
140
192
|
align={dividerAlign}
|
|
141
193
|
/>
|
|
142
194
|
) : (
|
|
143
|
-
<
|
|
144
|
-
key={index}
|
|
195
|
+
<ReqoreDropdownItem
|
|
196
|
+
key={item.label || item.value || index}
|
|
145
197
|
{...item}
|
|
146
|
-
|
|
147
|
-
onClick={() => handleItemClick({ ...item, onClick })}
|
|
148
|
-
rightIcon={item.selected ? 'CheckLine' : undefined}
|
|
198
|
+
onItemClick={handleItemClick}
|
|
149
199
|
scrollIntoView={scrollToSelected && item.selected && !multiSelect}
|
|
150
200
|
/>
|
|
151
201
|
)
|
|
@@ -3,10 +3,10 @@ import { rgba } from 'polished';
|
|
|
3
3
|
import React, { forwardRef, useState } from 'react';
|
|
4
4
|
import styled, { css } from 'styled-components';
|
|
5
5
|
import {
|
|
6
|
+
CONTROL_TEXT_FROM_SIZE,
|
|
6
7
|
PADDING_FROM_SIZE,
|
|
7
8
|
RADIUS_FROM_SIZE,
|
|
8
9
|
SIZE_TO_PX,
|
|
9
|
-
TEXT_FROM_SIZE,
|
|
10
10
|
TSizes,
|
|
11
11
|
} from '../../constants/sizes';
|
|
12
12
|
import { IReqoreTheme } from '../../constants/theme';
|
|
@@ -72,11 +72,17 @@ export const StyledInputWrapper = styled.div<IReqoreInputStyle>`
|
|
|
72
72
|
min-width: 60px;
|
|
73
73
|
flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1 auto' : '0 1 auto')};
|
|
74
74
|
align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
|
|
75
|
-
font-size: ${({ _size }) =>
|
|
75
|
+
font-size: ${({ _size }) => CONTROL_TEXT_FROM_SIZE[_size]}px;
|
|
76
76
|
position: relative;
|
|
77
77
|
overflow: hidden;
|
|
78
78
|
border-radius: ${({ minimal, rounded, _size }) =>
|
|
79
79
|
minimal || rounded === false ? 0 : RADIUS_FROM_SIZE[_size]}px;
|
|
80
|
+
|
|
81
|
+
&:focus-within {
|
|
82
|
+
.reqore-clear-input-button {
|
|
83
|
+
display: flex;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
80
86
|
`;
|
|
81
87
|
|
|
82
88
|
const StyledIconWrapper = styled.div<IReqoreInputStyle>`
|
|
@@ -109,7 +115,7 @@ export const StyledInput = styled(StyledEffect)<IReqoreInputStyle>`
|
|
|
109
115
|
}}px;
|
|
110
116
|
|
|
111
117
|
padding-left: ${({ hasIcon, _size }) => (hasIcon ? SIZE_TO_PX[_size] : 7)}px;
|
|
112
|
-
font-size: ${({ _size }) =>
|
|
118
|
+
font-size: ${({ _size }) => CONTROL_TEXT_FROM_SIZE[_size]}px;
|
|
113
119
|
transition: all 0.2s ease-out;
|
|
114
120
|
border-radius: ${({ minimal, rounded, _size }) =>
|
|
115
121
|
minimal || rounded === false ? 0 : RADIUS_FROM_SIZE[_size]}px;
|
|
@@ -85,8 +85,8 @@ const ReqoreMenu = forwardRef<HTMLDivElement, IReqoreMenuProps>(
|
|
|
85
85
|
{React.Children.map(children, (child) => {
|
|
86
86
|
return child
|
|
87
87
|
? React.cloneElement(child, {
|
|
88
|
-
_insidePopover,
|
|
89
|
-
_popoverId,
|
|
88
|
+
_insidePopover: child.props?._insidePopover ?? _insidePopover,
|
|
89
|
+
_popoverId: child.props?._popoverId ?? _popoverId,
|
|
90
90
|
customTheme: child.props?.customTheme || theme,
|
|
91
91
|
wrap: 'wrap' in (child.props || {}) ? child.props.wrap : wrapText,
|
|
92
92
|
flat: 'flat' in (child.props || {}) ? child.props.flat : flat,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useState } from 'react';
|
|
1
|
+
import React, { forwardRef, memo, useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useContext } from 'use-context-selector';
|
|
3
3
|
import { ReqoreButton, ReqoreControlGroup } from '../..';
|
|
4
4
|
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
@@ -29,101 +29,109 @@ export interface IReqoreMenuItemRightIconStyle {
|
|
|
29
29
|
intent?: TReqoreIntent;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const ReqoreMenuItem =
|
|
33
|
-
(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
32
|
+
const ReqoreMenuItem = memo(
|
|
33
|
+
forwardRef<HTMLButtonElement, IReqoreMenuItemProps>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
children,
|
|
37
|
+
label,
|
|
38
|
+
icon,
|
|
39
|
+
rightIcon,
|
|
40
|
+
as,
|
|
41
|
+
selected,
|
|
42
|
+
onClick,
|
|
43
|
+
onRightIconClick,
|
|
44
|
+
disabled,
|
|
45
|
+
itemId,
|
|
46
|
+
_insidePopover,
|
|
47
|
+
_popoverId,
|
|
48
|
+
tooltip,
|
|
49
|
+
intent,
|
|
50
|
+
flat = true,
|
|
51
|
+
scrollIntoView,
|
|
52
|
+
...rest
|
|
53
|
+
}: IReqoreMenuItemProps,
|
|
54
|
+
ref
|
|
55
|
+
) => {
|
|
56
|
+
const { removePopover } = useContext(PopoverContext);
|
|
57
|
+
const { targetRef } = useCombinedRefs<HTMLButtonElement>(ref);
|
|
58
|
+
const [itemRef, setItemRef] = useState<HTMLButtonElement | null>(null);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
const handleClick = useCallback(
|
|
61
|
+
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
62
|
+
event.persist();
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
onClick?.(event, itemId);
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (_insidePopover && _popoverId) {
|
|
67
|
+
removePopover!(_popoverId);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[itemId, _insidePopover, _popoverId, onClick, removePopover]
|
|
71
|
+
);
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
const handleRightIconClick = useCallback(
|
|
74
|
+
(event: React.MouseEvent<HTMLSpanElement>) => {
|
|
75
|
+
event.persist();
|
|
76
|
+
event.stopPropagation();
|
|
72
77
|
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
if (onRightIconClick) {
|
|
79
|
+
onRightIconClick(itemId, event);
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
if (_insidePopover && _popoverId) {
|
|
82
|
+
removePopover!(_popoverId);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
[itemId, _insidePopover, _popoverId, onRightIconClick, removePopover]
|
|
87
|
+
);
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (scrollIntoView && itemRef) {
|
|
91
|
+
itemRef.scrollIntoView?.({ behavior: 'smooth', block: 'center', inline: 'center' });
|
|
92
|
+
}
|
|
93
|
+
}, [itemRef, scrollIntoView]);
|
|
87
94
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<ReqoreButton
|
|
91
|
-
as={as}
|
|
92
|
-
{...rest}
|
|
93
|
-
flat={flat}
|
|
94
|
-
className={`${rest.className || ''} reqore-menu-item`}
|
|
95
|
-
fluid
|
|
96
|
-
onClick={handleClick}
|
|
97
|
-
active={selected}
|
|
98
|
-
ref={(ref) => {
|
|
99
|
-
targetRef.current = ref || undefined;
|
|
100
|
-
setItemRef(ref);
|
|
101
|
-
}}
|
|
102
|
-
disabled={disabled}
|
|
103
|
-
intent={intent}
|
|
104
|
-
icon={icon}
|
|
105
|
-
rightIcon={onRightIconClick ? undefined : rightIcon}
|
|
106
|
-
tooltip={tooltip}
|
|
107
|
-
>
|
|
108
|
-
{label || children}
|
|
109
|
-
</ReqoreButton>
|
|
110
|
-
{rightIcon && onRightIconClick ? (
|
|
95
|
+
return (
|
|
96
|
+
<ReqoreControlGroup stack={!!onRightIconClick} fluid fill>
|
|
111
97
|
<ReqoreButton
|
|
112
|
-
|
|
98
|
+
as={as}
|
|
99
|
+
{...rest}
|
|
113
100
|
flat={flat}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
101
|
+
className={`${rest.className || ''} reqore-menu-item`}
|
|
102
|
+
fluid
|
|
103
|
+
onClick={handleClick}
|
|
104
|
+
active={selected}
|
|
105
|
+
ref={(ref) => {
|
|
106
|
+
targetRef.current = ref || undefined;
|
|
107
|
+
setItemRef(ref);
|
|
108
|
+
}}
|
|
109
|
+
disabled={disabled}
|
|
120
110
|
intent={intent}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
icon={icon}
|
|
112
|
+
rightIcon={onRightIconClick ? undefined : rightIcon}
|
|
113
|
+
tooltip={tooltip}
|
|
114
|
+
>
|
|
115
|
+
{label || children}
|
|
116
|
+
</ReqoreButton>
|
|
117
|
+
{rightIcon && onRightIconClick ? (
|
|
118
|
+
<ReqoreButton
|
|
119
|
+
icon={rightIcon}
|
|
120
|
+
flat={flat}
|
|
121
|
+
fixed
|
|
122
|
+
minimal={!onRightIconClick}
|
|
123
|
+
customTheme={rest.customTheme}
|
|
124
|
+
className='reqore-menu-item-right-icon'
|
|
125
|
+
onClick={handleRightIconClick}
|
|
126
|
+
readOnly={!onRightIconClick}
|
|
127
|
+
intent={intent}
|
|
128
|
+
active={selected && !!onRightIconClick}
|
|
129
|
+
/>
|
|
130
|
+
) : null}
|
|
131
|
+
</ReqoreControlGroup>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
)
|
|
127
135
|
);
|
|
128
136
|
|
|
129
137
|
export default ReqoreMenuItem;
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
StyledIconWrapper,
|
|
27
27
|
StyledNotificationContent,
|
|
28
28
|
StyledNotificationContentWrapper,
|
|
29
|
+
StyledNotificationInnerContent,
|
|
29
30
|
StyledReqoreNotification,
|
|
30
31
|
typeToIcon,
|
|
31
32
|
} from '../Notifications/notification';
|
|
@@ -153,43 +154,46 @@ const ReqoreMessage = memo(
|
|
|
153
154
|
size={size}
|
|
154
155
|
theme={theme}
|
|
155
156
|
>
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
157
|
+
<StyledNotificationContentWrapper size={size} theme={theme}>
|
|
158
|
+
{leftIcon ? (
|
|
159
|
+
<>
|
|
160
|
+
{intent === 'pending' ? (
|
|
161
|
+
<ReqoreSpinner
|
|
162
|
+
size={size}
|
|
163
|
+
iconColor={iconColor}
|
|
164
|
+
type={5}
|
|
165
|
+
iconMargin={'right'}
|
|
166
|
+
iconProps={iconProps}
|
|
167
|
+
/>
|
|
168
|
+
) : (
|
|
169
|
+
<ReqoreIcon
|
|
170
|
+
icon={leftIcon}
|
|
171
|
+
margin={'right'}
|
|
172
|
+
size={size}
|
|
173
|
+
color={iconColor}
|
|
174
|
+
{...iconProps}
|
|
175
|
+
/>
|
|
176
|
+
)}
|
|
177
|
+
</>
|
|
178
|
+
) : null}
|
|
179
|
+
<StyledNotificationInnerContent>
|
|
180
|
+
{title && (
|
|
181
|
+
<ReqoreHeading
|
|
170
182
|
size={size}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
customTheme={
|
|
184
|
+
rest.effect?.color
|
|
185
|
+
? { text: { color: getColorFromMaybeString(theme, rest.effect.color) } }
|
|
186
|
+
: undefined
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
{title}
|
|
190
|
+
</ReqoreHeading>
|
|
174
191
|
)}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
size={size}
|
|
181
|
-
customTheme={
|
|
182
|
-
rest.effect?.color
|
|
183
|
-
? { text: { color: getColorFromMaybeString(theme, rest.effect.color) } }
|
|
184
|
-
: undefined
|
|
185
|
-
}
|
|
186
|
-
>
|
|
187
|
-
{title}
|
|
188
|
-
</ReqoreHeading>
|
|
189
|
-
)}
|
|
190
|
-
<StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
|
|
191
|
-
{children}
|
|
192
|
-
</StyledNotificationContent>
|
|
192
|
+
|
|
193
|
+
<StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
|
|
194
|
+
{children}
|
|
195
|
+
</StyledNotificationContent>
|
|
196
|
+
</StyledNotificationInnerContent>
|
|
193
197
|
</StyledNotificationContentWrapper>
|
|
194
198
|
{onClose && (
|
|
195
199
|
<StyledIconWrapper
|
|
@@ -124,7 +124,7 @@ export const ReqoreMultiSelect = ({
|
|
|
124
124
|
onItemAdded?.(item.value);
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
[value]
|
|
127
|
+
[value, onValueChange, onItemAdded, onItemRemoved]
|
|
128
128
|
);
|
|
129
129
|
|
|
130
130
|
const handleItemSelect = useCallback(
|
|
@@ -142,7 +142,7 @@ export const ReqoreMultiSelect = ({
|
|
|
142
142
|
|
|
143
143
|
setQuery('');
|
|
144
144
|
},
|
|
145
|
-
[createdItems, value]
|
|
145
|
+
[createdItems, value, items, addRemoveItem]
|
|
146
146
|
);
|
|
147
147
|
|
|
148
148
|
/*
|