@qoretechnologies/reqore 0.38.0 → 0.38.1

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.
Files changed (59) hide show
  1. package/__tests__/dropdown.test.tsx +10 -8
  2. package/__tests__/table.test.tsx +0 -1
  3. package/dist/components/Dropdown/index.d.ts +2 -2
  4. package/dist/components/Dropdown/index.d.ts.map +1 -1
  5. package/dist/components/Dropdown/index.js +5 -5
  6. package/dist/components/Dropdown/index.js.map +1 -1
  7. package/dist/components/Dropdown/item.d.ts +6 -5
  8. package/dist/components/Dropdown/item.d.ts.map +1 -1
  9. package/dist/components/Dropdown/item.js +14 -6
  10. package/dist/components/Dropdown/item.js.map +1 -1
  11. package/dist/components/Dropdown/list.d.ts +4 -2
  12. package/dist/components/Dropdown/list.d.ts.map +1 -1
  13. package/dist/components/Dropdown/list.js +33 -7
  14. package/dist/components/Dropdown/list.js.map +1 -1
  15. package/dist/components/Menu/index.js +4 -4
  16. package/dist/components/Menu/index.js.map +1 -1
  17. package/dist/components/Menu/item.d.ts +1 -1
  18. package/dist/components/Menu/item.d.ts.map +1 -1
  19. package/dist/components/Menu/item.js +6 -6
  20. package/dist/components/Menu/item.js.map +1 -1
  21. package/dist/components/Message/index.d.ts.map +1 -1
  22. package/dist/components/Message/index.js +3 -4
  23. package/dist/components/Message/index.js.map +1 -1
  24. package/dist/components/MultiSelect/index.js +2 -2
  25. package/dist/components/MultiSelect/index.js.map +1 -1
  26. package/dist/components/Notifications/notification.d.ts +1 -0
  27. package/dist/components/Notifications/notification.d.ts.map +1 -1
  28. package/dist/components/Notifications/notification.js +10 -21
  29. package/dist/components/Notifications/notification.js.map +1 -1
  30. package/dist/components/Panel/LabelEditor.d.ts.map +1 -1
  31. package/dist/components/Panel/LabelEditor.js +1 -1
  32. package/dist/components/Panel/LabelEditor.js.map +1 -1
  33. package/dist/components/Panel/index.d.ts.map +1 -1
  34. package/dist/components/Panel/index.js +22 -16
  35. package/dist/components/Panel/index.js.map +1 -1
  36. package/dist/components/Textarea/index.d.ts +4 -0
  37. package/dist/components/Textarea/index.d.ts.map +1 -1
  38. package/dist/components/Textarea/index.js +20 -5
  39. package/dist/components/Textarea/index.js.map +1 -1
  40. package/package.json +1 -1
  41. package/src/components/Dropdown/index.tsx +16 -14
  42. package/src/components/Dropdown/item.tsx +26 -10
  43. package/src/components/Dropdown/list.tsx +80 -30
  44. package/src/components/Menu/index.tsx +2 -2
  45. package/src/components/Menu/item.tsx +93 -85
  46. package/src/components/Message/index.tsx +39 -35
  47. package/src/components/MultiSelect/index.tsx +2 -2
  48. package/src/components/Notifications/notification.tsx +34 -30
  49. package/src/components/Panel/LabelEditor.tsx +1 -0
  50. package/src/components/Panel/index.tsx +24 -17
  51. package/src/components/Textarea/index.tsx +77 -27
  52. package/src/stories/Dropdown/Dropdown.stories.tsx +58 -0
  53. package/src/stories/Dropdown/DropdownTests.stories.tsx +78 -0
  54. package/src/stories/Message/Message.stories.tsx +13 -5
  55. package/src/stories/MultiSelect/MultiSelect.stories.tsx +2 -2
  56. package/src/stories/Panel/Panel.stories.tsx +86 -0
  57. package/src/stories/TextArea/TextArea.stories.tsx +49 -0
  58. package/src/stories/TextArea/TextAreaTests.stories.tsx +103 -0
  59. package/tests.json +1 -1
@@ -1,17 +1,33 @@
1
- import { ReqoreMenuDivider, ReqoreMenuItem } from '../..';
2
- import { IReqoreMenuDividerProps } from '../Menu/divider';
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 Omit<IReqoreDropdownItem, 'value' | 'onClick'> {}
7
+ export interface IReqoreDropdownItemProps extends IReqoreDropdownItem {
8
+ onItemClick: (item: IReqoreDropdownItem) => void;
9
+ scrollIntoView?: boolean;
10
+ }
6
11
 
7
- export const ReqoreDropdownItem = ({ children, ...rest }: IReqoreDropdownItemProps) => (
8
- <ReqoreMenuItem {...rest} rightIcon={rest.selected ? 'CheckLine' : undefined}>
9
- {children}
10
- </ReqoreMenuItem>
11
- );
12
+ export const ReqoreDropdownItem = memo(
13
+ ({ onItemClick, scrollIntoView, ...rest }: IReqoreDropdownItemProps) => {
14
+ const handleItemClick = useCallback(() => {
15
+ onItemClick(rest);
16
+ }, [onItemClick, rest]);
12
17
 
13
- export interface IReqoreDropdownDividerProps extends IReqoreMenuDividerProps {}
18
+ return (
19
+ <ReqoreMenuItem
20
+ {...rest}
21
+ _insidePopover={size(rest.items) ? false : undefined}
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: IReqoreDropdownDividerProps) => (
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 ReqoreMenuItem, { IReqoreMenuItemProps } from '../Menu/item';
11
+ import ReqoreMenuDivider, { IReqoreMenuDividerProps } from '../Menu/divider';
12
+ import { IReqoreMenuItemProps } from '../Menu/item';
11
13
  import { ReqoreVerticalSpacer } from '../Spacer';
12
- import { IReqoreDropdownDividerProps } from './item';
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' | 'rightIcon' | 'onRightIconClick'> {
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 = (item: IReqoreDropdownItem): void => {
99
- if (item.onClick) {
100
- item.onClick(item);
101
- }
105
+ const handleItemClick = useCallback(
106
+ (item: IReqoreDropdownItem): void => {
107
+ if (size(item.items)) {
108
+ setSelectedItem(item);
102
109
 
103
- if (onItemSelect) {
104
- onItemSelect(item);
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
- <ReqoreInput
113
- value={onFilterChange ? filter : query}
114
- icon='SearchLine'
115
- onChange={handleQueryChange}
116
- placeholder={filterPlaceholder || `Search ${size(_items)} items...`}
117
- onClearClick={() => (onFilterChange ? onFilterChange('') : setQuery(''))}
118
- {...inputProps}
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
- ({ onClick, dividerAlign, divider, ...item }: IReqoreDropdownItem, index: number) =>
187
+ ({ dividerAlign, divider, ...item }: IReqoreDropdownItem, index: number) =>
136
188
  divider ? (
137
189
  <ReqoreMenuDivider
138
190
  key={index}
139
- {...(item as unknown as IReqoreDropdownDividerProps)}
191
+ {...(item as unknown as IReqoreMenuDividerProps)}
140
192
  align={dividerAlign}
141
193
  />
142
194
  ) : (
143
- <ReqoreMenuItem
144
- key={index}
195
+ <ReqoreDropdownItem
196
+ key={item.label || item.value || index}
145
197
  {...item}
146
- label={item.label || item.value}
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
  )
@@ -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 = forwardRef<HTMLButtonElement, IReqoreMenuItemProps>(
33
- (
34
- {
35
- children,
36
- label,
37
- icon,
38
- rightIcon,
39
- as,
40
- selected,
41
- onClick,
42
- onRightIconClick,
43
- disabled,
44
- itemId,
45
- _insidePopover,
46
- _popoverId,
47
- tooltip,
48
- intent,
49
- flat = true,
50
- scrollIntoView,
51
- ...rest
52
- }: IReqoreMenuItemProps,
53
- ref
54
- ) => {
55
- const { removePopover } = useContext(PopoverContext);
56
- const { targetRef } = useCombinedRefs<HTMLButtonElement>(ref);
57
- const [itemRef, setItemRef] = useState<HTMLButtonElement | null>(null);
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
- const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
60
- event.persist();
60
+ const handleClick = useCallback(
61
+ (event: React.MouseEvent<HTMLButtonElement>) => {
62
+ event.persist();
61
63
 
62
- onClick?.(event, itemId);
64
+ onClick?.(event, itemId);
63
65
 
64
- if (_insidePopover && _popoverId) {
65
- removePopover!(_popoverId);
66
- }
67
- };
66
+ if (_insidePopover && _popoverId) {
67
+ removePopover!(_popoverId);
68
+ }
69
+ },
70
+ [itemId, _insidePopover, _popoverId, onClick]
71
+ );
68
72
 
69
- const handleRightIconClick = (event: React.MouseEvent<HTMLSpanElement>) => {
70
- event.persist();
71
- event.stopPropagation();
73
+ const handleRightIconClick = useCallback(
74
+ (event: React.MouseEvent<HTMLSpanElement>) => {
75
+ event.persist();
76
+ event.stopPropagation();
72
77
 
73
- if (onRightIconClick) {
74
- onRightIconClick(itemId, event);
78
+ if (onRightIconClick) {
79
+ onRightIconClick(itemId, event);
75
80
 
76
- if (_insidePopover && _popoverId) {
77
- removePopover!(_popoverId);
78
- }
79
- }
80
- };
81
+ if (_insidePopover && _popoverId) {
82
+ removePopover!(_popoverId);
83
+ }
84
+ }
85
+ },
86
+ [itemId, _insidePopover, _popoverId, onRightIconClick]
87
+ );
81
88
 
82
- useEffect(() => {
83
- if (scrollIntoView && itemRef) {
84
- itemRef.scrollIntoView?.({ behavior: 'smooth', block: 'center', inline: 'center' });
85
- }
86
- }, [itemRef, scrollIntoView]);
89
+ useEffect(() => {
90
+ if (scrollIntoView && itemRef) {
91
+ itemRef.scrollIntoView?.({ behavior: 'smooth', block: 'center', inline: 'center' });
92
+ }
93
+ }, [itemRef, scrollIntoView]);
87
94
 
88
- return (
89
- <ReqoreControlGroup stack={!!onRightIconClick} fluid fill>
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
- icon={rightIcon}
98
+ as={as}
99
+ {...rest}
113
100
  flat={flat}
114
- fixed
115
- minimal={!onRightIconClick}
116
- customTheme={rest.customTheme}
117
- className='reqore-menu-item-right-icon'
118
- onClick={handleRightIconClick}
119
- readOnly={!onRightIconClick}
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
- active={selected && !!onRightIconClick}
122
- />
123
- ) : null}
124
- </ReqoreControlGroup>
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
- {leftIcon ? (
157
- <StyledIconWrapper intent={intent} size={size} theme={theme}>
158
- {intent === 'pending' ? (
159
- <ReqoreSpinner
160
- size={size}
161
- iconColor={iconColor}
162
- type={5}
163
- iconMargin={flat && minimal ? 'right' : 'both'}
164
- iconProps={iconProps}
165
- />
166
- ) : (
167
- <ReqoreIcon
168
- icon={leftIcon}
169
- margin={flat && minimal ? 'right' : 'both'}
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
- color={iconColor}
172
- {...iconProps}
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
- </StyledIconWrapper>
176
- ) : null}
177
- <StyledNotificationContentWrapper size={size} theme={theme}>
178
- {title && (
179
- <ReqoreHeading
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
  /*
@@ -4,13 +4,7 @@ import React, { forwardRef, useEffect, useState } from 'react';
4
4
  import { useMount, useUnmount } from 'react-use';
5
5
  import styled, { css, keyframes } from 'styled-components';
6
6
  import { SPRING_CONFIG } from '../../constants/animations';
7
- import {
8
- ICON_WRAPPER_FROM_HEADER_SIZE,
9
- PADDING_FROM_SIZE,
10
- TABS_SIZE_TO_PX,
11
- TEXT_FROM_SIZE,
12
- TSizes,
13
- } from '../../constants/sizes';
7
+ import { PADDING_FROM_SIZE, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
14
8
  import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
15
9
  import ReqoreThemeProvider from '../../containers/ThemeProvider';
16
10
  import { fadeIn } from '../../helpers/animations';
@@ -82,7 +76,6 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
82
76
  min-width: ${({ fluid }) => (!fluid ? '30px' : undefined)};
83
77
  max-width: ${({ maxWidth, fluid, fixed }) => maxWidth || (fluid && !fixed ? '100%' : undefined)};
84
78
  border-radius: 5px;
85
- min-height: ${({ size = 'normal' }: IReqoreNotificationStyle) => TABS_SIZE_TO_PX[size]}px;
86
79
  display: flex;
87
80
  flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
88
81
  align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
@@ -172,15 +165,12 @@ export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotification
172
165
  `;
173
166
 
174
167
  export const StyledIconWrapper = styled.div<IReqoreNotificationStyle>`
175
- height: ${({ size = 'normal' }: IReqoreNotificationStyle) =>
176
- ICON_WRAPPER_FROM_HEADER_SIZE[size]}px;
177
168
  flex: 0 1 auto;
178
169
  flex-shrink: 0;
179
170
  display: flex;
180
171
  justify-content: center;
181
172
  align-items: center;
182
173
  transition: all 0.2s ease-out;
183
- margin-top: ${({ size = 'normal' }: IReqoreNotificationStyle) => `${PADDING_FROM_SIZE[size]}px`};
184
174
 
185
175
  ${({ clickable, theme, intent, type }) =>
186
176
  clickable &&
@@ -202,12 +192,21 @@ export const StyledIconWrapper = styled.div<IReqoreNotificationStyle>`
202
192
  `}
203
193
  `;
204
194
 
205
- export const StyledNotificationContentWrapper = styled.div<IReqoreNotificationStyle>`
195
+ export const StyledNotificationInnerContent = styled.div<IReqoreNotificationStyle>`
206
196
  flex: 1;
207
- min-height: ${({ size = 'normal' }: IReqoreNotificationStyle) => TABS_SIZE_TO_PX[size]}px;
208
197
  display: flex;
209
198
  flex-flow: column;
210
199
  justify-content: center;
200
+
201
+ .reqore-heading {
202
+ line-height: 1;
203
+ }
204
+ `;
205
+
206
+ export const StyledNotificationContentWrapper = styled.div<IReqoreNotificationStyle>`
207
+ flex: 1;
208
+ display: flex;
209
+ justify-content: center;
211
210
  padding: ${({ size = 'normal' }: IReqoreNotificationStyle) => `${PADDING_FROM_SIZE[size]}px`};
212
211
  `;
213
212
 
@@ -224,6 +223,9 @@ export const StyledNotificationContent = styled.div`
224
223
  flex: 1;
225
224
  font-size: ${({ size = 'normal' }) => TEXT_FROM_SIZE[size]}px;
226
225
  overflow-wrap: anywhere;
226
+ display: flex;
227
+ flex-flow: column;
228
+ justify-content: center;
227
229
 
228
230
  ${({ hasTitle, size = 'normal' }) =>
229
231
  hasTitle &&
@@ -317,24 +319,26 @@ const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
317
319
  theme={theme}
318
320
  maxWidth='450px'
319
321
  >
320
- {type || intent || icon ? (
321
- <StyledIconWrapper type={type || intent} size={size}>
322
- {intent === 'pending' || type === 'pending' ? (
323
- <ReqoreSpinner size={size} type={5} iconMargin={'both'} />
324
- ) : (
325
- <ReqoreIcon
326
- icon={icon || typeToIcon[type || intent]}
327
- margin={'both'}
328
- size={size}
329
- />
330
- )}
331
- </StyledIconWrapper>
332
- ) : null}
333
322
  <StyledNotificationContentWrapper size={size} theme={theme}>
334
- {title && <ReqoreHeading size={size}>{title}</ReqoreHeading>}
335
- <StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
336
- {content}
337
- </StyledNotificationContent>
323
+ {type || intent || icon ? (
324
+ <>
325
+ {intent === 'pending' || type === 'pending' ? (
326
+ <ReqoreSpinner size={size} type={5} iconMargin={'right'} />
327
+ ) : (
328
+ <ReqoreIcon
329
+ icon={icon || typeToIcon[type || intent]}
330
+ margin={'right'}
331
+ size={size}
332
+ />
333
+ )}
334
+ </>
335
+ ) : null}
336
+ <StyledNotificationInnerContent>
337
+ {title && <ReqoreHeading size={size}>{title}</ReqoreHeading>}
338
+ <StyledNotificationContent theme={theme} hasTitle={!!title} size={size}>
339
+ {content}
340
+ </StyledNotificationContent>
341
+ </StyledNotificationInnerContent>
338
342
  </StyledNotificationContentWrapper>
339
343
  <StyledIconWrapper
340
344
  type={type || intent}
@@ -33,6 +33,7 @@ export const LabelEditor = memo(
33
33
  onClick={(e) => e.stopPropagation()}
34
34
  value={name}
35
35
  minimal
36
+ fluid
36
37
  onChange={(e: any) => setName(e.target.value)}
37
38
  onKeyUp={(e) => {
38
39
  if (e.key === 'Enter') {