@qoretechnologies/reqore 0.25.9 → 0.26.0

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 (151) hide show
  1. package/__tests__/dropdown.test.tsx +133 -12
  2. package/__tests__/effect.test.tsx +70 -0
  3. package/dist/components/Button/index.d.ts +3 -2
  4. package/dist/components/Button/index.d.ts.map +1 -1
  5. package/dist/components/Button/index.js +15 -14
  6. package/dist/components/Button/index.js.map +1 -1
  7. package/dist/components/Collection/item.d.ts +2 -2
  8. package/dist/components/Collection/item.d.ts.map +1 -1
  9. package/dist/components/Collection/item.js +6 -3
  10. package/dist/components/Collection/item.js.map +1 -1
  11. package/dist/components/ControlGroup/index.d.ts.map +1 -1
  12. package/dist/components/ControlGroup/index.js +4 -1
  13. package/dist/components/ControlGroup/index.js.map +1 -1
  14. package/dist/components/Dropdown/index.d.ts +8 -7
  15. package/dist/components/Dropdown/index.d.ts.map +1 -1
  16. package/dist/components/Dropdown/index.js +12 -5
  17. package/dist/components/Dropdown/index.js.map +1 -1
  18. package/dist/components/Dropdown/item.d.ts +2 -2
  19. package/dist/components/Dropdown/item.d.ts.map +1 -1
  20. package/dist/components/Dropdown/item.js.map +1 -1
  21. package/dist/components/Dropdown/list.d.ts +9 -2
  22. package/dist/components/Dropdown/list.d.ts.map +1 -1
  23. package/dist/components/Dropdown/list.js +13 -5
  24. package/dist/components/Dropdown/list.js.map +1 -1
  25. package/dist/components/Effect/index.d.ts +29 -0
  26. package/dist/components/Effect/index.d.ts.map +1 -0
  27. package/dist/components/Effect/index.js +117 -0
  28. package/dist/components/Effect/index.js.map +1 -0
  29. package/dist/components/Header/index.d.ts +14 -8
  30. package/dist/components/Header/index.d.ts.map +1 -1
  31. package/dist/components/Header/index.js +52 -33
  32. package/dist/components/Header/index.js.map +1 -1
  33. package/dist/components/Input/index.d.ts +3 -2
  34. package/dist/components/Input/index.d.ts.map +1 -1
  35. package/dist/components/Input/index.js +8 -7
  36. package/dist/components/Input/index.js.map +1 -1
  37. package/dist/components/InternalPopover/index.d.ts.map +1 -1
  38. package/dist/components/InternalPopover/index.js +0 -1
  39. package/dist/components/InternalPopover/index.js.map +1 -1
  40. package/dist/components/Menu/index.js +1 -1
  41. package/dist/components/Menu/index.js.map +1 -1
  42. package/dist/components/Menu/item.d.ts +5 -11
  43. package/dist/components/Menu/item.d.ts.map +1 -1
  44. package/dist/components/Menu/item.js +4 -4
  45. package/dist/components/Menu/item.js.map +1 -1
  46. package/dist/components/Message/index.d.ts +3 -6
  47. package/dist/components/Message/index.d.ts.map +1 -1
  48. package/dist/components/Message/index.js +2 -1
  49. package/dist/components/Message/index.js.map +1 -1
  50. package/dist/components/Notifications/notification.d.ts +3 -2
  51. package/dist/components/Notifications/notification.d.ts.map +1 -1
  52. package/dist/components/Notifications/notification.js +3 -2
  53. package/dist/components/Notifications/notification.js.map +1 -1
  54. package/dist/components/Panel/index.d.ts +5 -3
  55. package/dist/components/Panel/index.d.ts.map +1 -1
  56. package/dist/components/Panel/index.js +17 -27
  57. package/dist/components/Panel/index.js.map +1 -1
  58. package/dist/components/Popover/index.d.ts +1 -1
  59. package/dist/components/Popover/index.d.ts.map +1 -1
  60. package/dist/components/Popover/index.js +2 -2
  61. package/dist/components/Popover/index.js.map +1 -1
  62. package/dist/components/Tabs/item.d.ts +1 -1
  63. package/dist/components/Tabs/item.d.ts.map +1 -1
  64. package/dist/components/Tabs/item.js +6 -5
  65. package/dist/components/Tabs/item.js.map +1 -1
  66. package/dist/components/Tag/index.d.ts +2 -2
  67. package/dist/components/Tag/index.d.ts.map +1 -1
  68. package/dist/components/Tag/index.js +6 -4
  69. package/dist/components/Tag/index.js.map +1 -1
  70. package/dist/components/Textarea/index.d.ts +2 -2
  71. package/dist/components/Textarea/index.d.ts.map +1 -1
  72. package/dist/components/Textarea/index.js +8 -7
  73. package/dist/components/Textarea/index.js.map +1 -1
  74. package/dist/constants/sizes.d.ts +7 -0
  75. package/dist/constants/sizes.d.ts.map +1 -1
  76. package/dist/constants/sizes.js +8 -1
  77. package/dist/constants/sizes.js.map +1 -1
  78. package/dist/constants/theme.d.ts +1 -0
  79. package/dist/constants/theme.d.ts.map +1 -1
  80. package/dist/constants/theme.js.map +1 -1
  81. package/dist/containers/ReqoreProvider.d.ts +2 -2
  82. package/dist/containers/ReqoreProvider.d.ts.map +1 -1
  83. package/dist/containers/ReqoreProvider.js +7 -5
  84. package/dist/containers/ReqoreProvider.js.map +1 -1
  85. package/dist/containers/UIProvider.d.ts +9 -3
  86. package/dist/containers/UIProvider.d.ts.map +1 -1
  87. package/dist/containers/UIProvider.js +3 -2
  88. package/dist/containers/UIProvider.js.map +1 -1
  89. package/dist/context/ReqoreContext.d.ts +2 -0
  90. package/dist/context/ReqoreContext.d.ts.map +1 -1
  91. package/dist/context/ReqoreContext.js +4 -1
  92. package/dist/context/ReqoreContext.js.map +1 -1
  93. package/dist/helpers/colors.js +1 -1
  94. package/dist/helpers/colors.js.map +1 -1
  95. package/dist/hooks/usePopover.d.ts.map +1 -1
  96. package/dist/hooks/usePopover.js +23 -9
  97. package/dist/hooks/usePopover.js.map +1 -1
  98. package/dist/hooks/useWhyDidYouUpdate.d.ts +2 -0
  99. package/dist/hooks/useWhyDidYouUpdate.d.ts.map +1 -0
  100. package/dist/hooks/useWhyDidYouUpdate.js +47 -0
  101. package/dist/hooks/useWhyDidYouUpdate.js.map +1 -0
  102. package/dist/index.d.ts +2 -1
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +6 -2
  105. package/dist/index.js.map +1 -1
  106. package/dist/types/global.d.ts +13 -0
  107. package/dist/types/global.d.ts.map +1 -1
  108. package/package.json +2 -1
  109. package/src/components/Button/index.tsx +34 -23
  110. package/src/components/Collection/item.tsx +6 -3
  111. package/src/components/ControlGroup/index.tsx +1 -0
  112. package/src/components/Dropdown/index.tsx +62 -36
  113. package/src/components/Dropdown/item.tsx +3 -6
  114. package/src/components/Dropdown/list.tsx +82 -56
  115. package/src/components/Effect/index.tsx +134 -0
  116. package/src/components/Header/index.tsx +33 -28
  117. package/src/components/Input/index.tsx +15 -7
  118. package/src/components/InternalPopover/index.tsx +0 -2
  119. package/src/components/Menu/index.tsx +1 -1
  120. package/src/components/Menu/item.tsx +8 -17
  121. package/src/components/Message/index.tsx +13 -5
  122. package/src/components/Notifications/notification.tsx +6 -3
  123. package/src/components/Panel/index.tsx +83 -79
  124. package/src/components/Popover/index.tsx +40 -38
  125. package/src/components/Tabs/item.tsx +92 -79
  126. package/src/components/Tag/index.tsx +16 -7
  127. package/src/components/Textarea/index.tsx +14 -7
  128. package/src/constants/sizes.ts +8 -0
  129. package/src/constants/theme.ts +1 -0
  130. package/src/containers/ReqoreProvider.tsx +16 -8
  131. package/src/containers/UIProvider.tsx +15 -13
  132. package/src/context/ReqoreContext.tsx +5 -0
  133. package/src/helpers/colors.ts +1 -1
  134. package/src/hooks/usePopover.tsx +34 -20
  135. package/src/hooks/useWhyDidYouUpdate.ts +32 -0
  136. package/src/index.tsx +10 -1
  137. package/src/mock/collectionData.tsx +55 -2
  138. package/src/stories/Button/Button.stories.tsx +15 -2
  139. package/src/stories/Collection/Collection.stories.tsx +1 -1
  140. package/src/stories/Dropdown/Dropdown.stories.tsx +62 -34
  141. package/src/stories/Header/Header.stories.tsx +71 -0
  142. package/src/stories/Input/Input.stories.tsx +12 -0
  143. package/src/stories/Menu/Menu.stories.tsx +14 -0
  144. package/src/stories/Message/Message.stories.tsx +13 -0
  145. package/src/stories/Notifications/Notification.stories.tsx +7 -2
  146. package/src/stories/Panel/Panel.stories.tsx +41 -5
  147. package/src/stories/Tabs/Tabs.stories.tsx +23 -23
  148. package/src/stories/Tag/Tag.stories.tsx +16 -0
  149. package/src/stories/TextArea/TextArea.stories.tsx +18 -0
  150. package/src/types/global.ts +14 -0
  151. package/tests.json +1 -1
@@ -1,8 +1,9 @@
1
- import { forwardRef } from 'react';
1
+ import { forwardRef, memo } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
  import { IReqoreTabsListItem } from '.';
4
4
  import { TABS_PADDING_TO_PX, TSizes } from '../../constants/sizes';
5
5
  import { IReqoreCustomTheme, IReqoreTheme } from '../../constants/theme';
6
+ import { changeLightness } from '../../helpers/colors';
6
7
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
7
8
  import { useReqoreTheme } from '../../hooks/useTheme';
8
9
  import ReqoreButton from '../Button';
@@ -37,7 +38,16 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
37
38
  padding: ${vertical ? `${TABS_PADDING_TO_PX[size!]}px` : `${TABS_PADDING_TO_PX[size!]}px`};
38
39
  ${active &&
39
40
  css`
40
- background-color: ${activeColor}60;
41
+ &:after {
42
+ width: ${vertical ? '5px' : '1px'};
43
+ height: ${vertical ? '1px' : '5px'};
44
+ left: ${vertical ? '0' : '50%'};
45
+ top: ${vertical ? '50%' : undefined};
46
+ bottom: ${vertical ? undefined : '0'};
47
+ content: '';
48
+ position: absolute;
49
+ background-color: ${activeColor};
50
+ }
41
51
  `}
42
52
 
43
53
  ${fill &&
@@ -64,87 +74,90 @@ export const StyledTabListItem = styled.div<IReqoreTabListItemStyle>`
64
74
  }
65
75
  `;
66
76
 
67
- const ReqoreTabsListItem = forwardRef(
68
- (
69
- {
70
- tooltip,
71
- label,
72
- props,
73
- icon,
74
- active,
75
- as,
76
- disabled,
77
- vertical,
78
- onClick,
79
- activeIntent,
80
- onCloseClick,
81
- fill,
82
- intent,
83
- size = 'normal',
84
- closeIcon,
85
- customTheme,
86
- className,
87
- }: IReqoreTabListItemProps,
88
- ref
89
- ) => {
90
- const { targetRef } = useCombinedRefs(ref);
91
- const theme = useReqoreTheme('main', customTheme);
92
- const _intent = activeIntent || intent;
93
- const activeColor = _intent ? theme.intents[_intent] : theme.main;
77
+ const ReqoreTabsListItem = memo(
78
+ forwardRef(
79
+ (
80
+ {
81
+ tooltip,
82
+ label,
83
+ props,
84
+ icon,
85
+ active,
86
+ as,
87
+ disabled,
88
+ vertical,
89
+ onClick,
90
+ activeIntent,
91
+ onCloseClick,
92
+ fill,
93
+ intent,
94
+ size = 'normal',
95
+ closeIcon,
96
+ customTheme,
97
+ className,
98
+ }: IReqoreTabListItemProps,
99
+ ref
100
+ ) => {
101
+ const { targetRef } = useCombinedRefs(ref);
102
+ const theme = useReqoreTheme('main', customTheme);
103
+ const _intent = activeIntent || intent;
104
+ const activeColor = _intent ? theme.intents[_intent] : changeLightness(theme.main, 0.05);
94
105
 
95
- return (
96
- <StyledTabListItem
97
- ref={targetRef}
98
- {...props}
99
- className={className}
100
- intent={intent}
101
- activeIntent={activeIntent}
102
- activeColor={activeColor}
103
- as={as}
104
- size={size}
105
- active={active}
106
- disabled={disabled}
107
- vertical={vertical}
108
- theme={theme}
109
- fill={fill}
110
- >
111
- {label || icon ? (
112
- <ReqoreControlGroup stack size={size} fluid={fill || vertical}>
113
- <ReqoreButton
114
- flat
115
- fluid={fill || vertical}
116
- icon={icon}
117
- minimal
118
- intent={active ? activeIntent || intent : intent}
119
- active={active}
120
- disabled={disabled}
121
- onClick={onClick}
122
- tooltip={tooltip}
123
- customTheme={customTheme}
124
- className={`reqore-tabs-list-item ${active ? 'reqore-tabs-list-item-active' : ''}`}
125
- >
126
- {label}
127
- </ReqoreButton>
128
- {onCloseClick && !disabled ? (
106
+ return (
107
+ <StyledTabListItem
108
+ ref={targetRef}
109
+ {...props}
110
+ className={className}
111
+ intent={intent}
112
+ activeIntent={activeIntent}
113
+ activeColor={activeColor}
114
+ as={as}
115
+ size={size}
116
+ active={active}
117
+ disabled={disabled}
118
+ vertical={vertical}
119
+ theme={theme}
120
+ fill={fill}
121
+ >
122
+ {label || icon ? (
123
+ <ReqoreControlGroup stack size={size} fluid={fill || vertical}>
129
124
  <ReqoreButton
130
- fixed
131
- flat
132
- icon={closeIcon || 'CloseLine'}
133
- intent={active ? activeIntent || intent : intent}
125
+ flat={!active && !intent}
126
+ fluid={fill || vertical}
127
+ icon={icon}
134
128
  minimal
135
- className='reqore-tabs-list-item-close'
129
+ intent={active ? activeIntent || intent : intent}
130
+ active={active}
131
+ disabled={disabled}
132
+ onClick={onClick}
133
+ tooltip={tooltip}
136
134
  customTheme={customTheme}
137
- onClick={(event) => {
138
- event.stopPropagation();
139
- onCloseClick?.();
140
- }}
141
- />
142
- ) : null}
143
- </ReqoreControlGroup>
144
- ) : null}
145
- </StyledTabListItem>
146
- );
147
- }
135
+ className={`reqore-tabs-list-item ${active ? 'reqore-tabs-list-item-active' : ''}`}
136
+ >
137
+ {label}
138
+ </ReqoreButton>
139
+ {onCloseClick && !disabled ? (
140
+ <ReqoreButton
141
+ fixed
142
+ flat={!active && !intent}
143
+ icon={closeIcon || 'CloseLine'}
144
+ intent={active ? activeIntent || intent : intent}
145
+ minimal
146
+ active={active}
147
+ className='reqore-tabs-list-item-close'
148
+ customTheme={customTheme}
149
+ onClick={(event) => {
150
+ event.stopPropagation();
151
+ onCloseClick?.();
152
+ }}
153
+ />
154
+ ) : null}
155
+ </ReqoreControlGroup>
156
+ ) : null}
157
+ </StyledTabListItem>
158
+ );
159
+ }
160
+ )
148
161
  );
149
162
 
150
163
  export default ReqoreTabsListItem;
@@ -1,4 +1,5 @@
1
1
  import _size from 'lodash/size';
2
+ import { rgba } from 'polished';
2
3
  import React, { forwardRef, useContext } from 'react';
3
4
  import styled, { css } from 'styled-components';
4
5
  import { ReqorePopover } from '../..';
@@ -14,8 +15,14 @@ import ThemeContext from '../../context/ThemeContext';
14
15
  import { changeLightness, getReadableColor, getReadableColorFrom } from '../../helpers/colors';
15
16
  import { useCombinedRefs } from '../../hooks/useCombinedRefs';
16
17
  import { useTooltip } from '../../hooks/useTooltip';
17
- import { IReqoreDisabled, IReqoreIntent, IWithReqoreTooltip } from '../../types/global';
18
+ import {
19
+ IReqoreDisabled,
20
+ IReqoreIntent,
21
+ IWithReqoreEffect,
22
+ IWithReqoreTooltip,
23
+ } from '../../types/global';
18
24
  import { IReqoreIconName } from '../../types/icons';
25
+ import { StyledEffect } from '../Effect';
19
26
  import ReqoreIcon from '../Icon';
20
27
 
21
28
  export interface IReqoreTagAction extends IWithReqoreTooltip, IReqoreDisabled, IReqoreIntent {
@@ -26,7 +33,8 @@ export interface IReqoreTagAction extends IWithReqoreTooltip, IReqoreDisabled, I
26
33
  export interface IReqoreTagProps
27
34
  extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'>,
28
35
  IWithReqoreTooltip,
29
- IReqoreDisabled {
36
+ IReqoreDisabled,
37
+ IWithReqoreEffect {
30
38
  size?: TSizes;
31
39
  label?: string | number;
32
40
  labelKey?: string | number;
@@ -47,7 +55,7 @@ export interface IReqoreTagStyle extends IReqoreTagProps {
47
55
  interactive?: boolean;
48
56
  }
49
57
 
50
- export const StyledTag = styled.div<IReqoreTagStyle>`
58
+ export const StyledTag = styled(StyledEffect)<IReqoreTagStyle>`
51
59
  display: inline-flex;
52
60
  justify-content: center;
53
61
  flex-shrink: 0;
@@ -55,6 +63,7 @@ export const StyledTag = styled.div<IReqoreTagStyle>`
55
63
  font-family: system-ui;
56
64
  font-weight: 600;
57
65
  overflow: hidden;
66
+ vertical-align: middle;
58
67
  font-size: ${({ size }) => TEXT_FROM_SIZE[size]}px;
59
68
  height: ${({ size }) => SIZE_TO_PX[size]}px;
60
69
  min-width: ${({ size }) => SIZE_TO_PX[size]}px;
@@ -67,8 +76,8 @@ export const StyledTag = styled.div<IReqoreTagStyle>`
67
76
  background-color: ${color || changeLightness(theme.main, 0.1)};
68
77
  color: ${color ? getReadableColorFrom(color) : getReadableColor(theme, undefined, undefined)};
69
78
 
70
- ${StyledTagContentKey}, ${StyledTagContentWrapper} {
71
- background-color: ${labelKey ? changeLightness(color || theme.main, 0.05) : undefined};
79
+ ${StyledTagContentWrapper} {
80
+ background-color: ${labelKey ? rgba('#000000', 0.2) : undefined};
72
81
  }
73
82
  `}
74
83
 
@@ -130,14 +139,14 @@ const StyledButtonWrapper = styled.div<IReqoreTagStyle>`
130
139
  align-items: center;
131
140
  transition: all 0.2s ease-out;
132
141
 
133
- ${({ theme, color }) =>
142
+ ${({ color }) =>
134
143
  css`
135
144
  .reqore-icon {
136
145
  transform: scale(0.85);
137
146
  }
138
147
  &:hover {
139
148
  cursor: pointer;
140
- background-color: ${changeLightness(color || theme.main, color ? 0.09 : 0.19)};
149
+ background-color: ${color ? changeLightness(color, 0.09) : rgba('#000000', 0.2)};
141
150
 
142
151
  .reqore-icon {
143
152
  transform: scale(1);
@@ -13,8 +13,10 @@ import {
13
13
  IReqoreIntent,
14
14
  IReqoreReadOnly,
15
15
  IWithReqoreCustomTheme,
16
+ IWithReqoreEffect,
16
17
  IWithReqoreTooltip,
17
18
  } from '../../types/global';
19
+ import { StyledEffect } from '../Effect';
18
20
  import { IReqoreInputStyle } from '../Input';
19
21
  import ReqoreInputClearButton from '../InputClearButton';
20
22
 
@@ -24,7 +26,8 @@ export interface IReqoreTextareaProps
24
26
  IReqoreDisabled,
25
27
  IWithReqoreCustomTheme,
26
28
  IWithReqoreTooltip,
27
- IReqoreIntent {
29
+ IReqoreIntent,
30
+ IWithReqoreEffect {
28
31
  autoFocus?: boolean;
29
32
  width?: number;
30
33
  height?: number;
@@ -53,7 +56,7 @@ export const StyledTextareaWrapper = styled.div<IReqoreTextareaStyle>`
53
56
  overflow: hidden;
54
57
  `;
55
58
 
56
- export const StyledTextarea = styled.textarea<IReqoreTextareaStyle>`
59
+ export const StyledTextarea = styled(StyledEffect)<IReqoreTextareaStyle>`
57
60
  height: 100%;
58
61
  width: 100%;
59
62
  font-size: ${({ _size }) => TEXT_FROM_SIZE[_size]}px;
@@ -62,15 +65,16 @@ export const StyledTextarea = styled.textarea<IReqoreTextareaStyle>`
62
65
  resize: none;
63
66
 
64
67
  background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
65
- minimal ? 'transparent' : rgba(theme.main, 0.3)};
66
- color: ${({ theme }: IReqoreInputStyle) => getReadableColor(theme)};
68
+ minimal ? 'transparent' : rgba(theme.main, 0.1)};
69
+ color: ${({ theme }: IReqoreInputStyle) =>
70
+ getReadableColor(theme, undefined, undefined, true, theme.originalMain)};
67
71
 
68
72
  transition: all 0.2s ease-out;
69
73
 
70
74
  &:active,
71
75
  &:focus {
72
76
  background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
73
- minimal ? 'transparent' : rgba(theme.main, 0.5)};
77
+ minimal ? 'transparent' : rgba(theme.main, 0.15)};
74
78
  }
75
79
 
76
80
  border-radius: ${({ minimal, rounded, _size }) =>
@@ -96,12 +100,14 @@ export const StyledTextarea = styled.textarea<IReqoreTextareaStyle>`
96
100
 
97
101
  &::placeholder {
98
102
  transition: all 0.2s ease-out;
99
- color: ${({ theme }) => rgba(getReadableColor(theme), 0.3)};
103
+ color: ${({ theme }) =>
104
+ rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.3)};
100
105
  }
101
106
 
102
107
  &:focus {
103
108
  &::placeholder {
104
- color: ${({ theme }) => rgba(getReadableColor(theme), 0.5)};
109
+ color: ${({ theme }) =>
110
+ rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.5)};
105
111
  }
106
112
  }
107
113
 
@@ -146,6 +152,7 @@ const ReqoreInput = forwardRef(
146
152
  >
147
153
  <StyledTextarea
148
154
  {...rest}
155
+ as='textarea'
149
156
  className={`${className || ''} reqore-control reqore-textarea`}
150
157
  _size={size}
151
158
  ref={targetRef}
@@ -73,3 +73,11 @@ export const ICON_FROM_HEADER_SIZE = {
73
73
  5: 9,
74
74
  6: 6,
75
75
  };
76
+
77
+ export const WEIGHT_TO_NUMBER = {
78
+ thin: 100,
79
+ light: 250,
80
+ normal: 400,
81
+ bold: 550,
82
+ thick: 700,
83
+ };
@@ -49,6 +49,7 @@ export interface IReqoreNavbarTheme {
49
49
 
50
50
  export interface IReqoreTheme {
51
51
  main: string;
52
+ originalMain?: string;
52
53
  text?: {
53
54
  color?: string;
54
55
  dim?: boolean;
@@ -2,10 +2,8 @@ import { size } from 'lodash';
2
2
  import React, { useRef, useState } from 'react';
3
3
  import { useMedia } from 'react-use';
4
4
  import shortid from 'shortid';
5
- import { ReqoreModal } from '..';
6
- import ReqoreNotificationsWrapper, {
7
- IReqoreNotificationsPosition,
8
- } from '../components/Notifications';
5
+ import { ReqoreModal, ReqoreTextEffect } from '..';
6
+ import ReqoreNotificationsWrapper from '../components/Notifications';
9
7
  import ReqoreNotification, {
10
8
  IReqoreNotificationType,
11
9
  } from '../components/Notifications/notification';
@@ -13,6 +11,7 @@ import { TSizes } from '../constants/sizes';
13
11
  import { TReqoreIntent } from '../constants/theme';
14
12
  import ReqoreContext from '../context/ReqoreContext';
15
13
  import { IReqoreIconName } from '../types/icons';
14
+ import { IReqoreOptions } from './UIProvider';
16
15
 
17
16
  export interface IReqoreNotificationData {
18
17
  title?: string;
@@ -32,7 +31,7 @@ export interface IReqoreNotificationData {
32
31
 
33
32
  export interface IReqoreNotifications {
34
33
  children: any;
35
- position?: IReqoreNotificationsPosition;
34
+ options?: IReqoreOptions;
36
35
  }
37
36
 
38
37
  export interface IReqoreConfirmationModal {
@@ -48,7 +47,7 @@ export interface IReqoreConfirmationModal {
48
47
  intent?: TReqoreIntent;
49
48
  }
50
49
 
51
- const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, position }) => {
50
+ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, options }) => {
52
51
  const [notifications, setNotifications] = useState<IReqoreNotificationData[] | null>([]);
53
52
  const [confirmationModal, setConfirmationModal] = useState<IReqoreConfirmationModal>({});
54
53
  const latestZIndex = useRef<number>(9000);
@@ -110,6 +109,8 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, position })
110
109
  });
111
110
  };
112
111
 
112
+ console.log(options);
113
+
113
114
  return (
114
115
  <>
115
116
  <ReqoreContext.Provider
@@ -122,10 +123,11 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, position })
122
123
  isTablet,
123
124
  isMobileOrTablet,
124
125
  getAndIncreaseZIndex,
126
+ animations: options?.animations || { buttons: true },
125
127
  }}
126
128
  >
127
129
  {size(notifications) > 0 ? (
128
- <ReqoreNotificationsWrapper position={position}>
130
+ <ReqoreNotificationsWrapper position={options?.notificationsPosition}>
129
131
  {notifications.map((notification) => (
130
132
  <ReqoreNotification
131
133
  {...notification}
@@ -159,6 +161,7 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, position })
159
161
  flat
160
162
  opacity={0.9}
161
163
  blur={2}
164
+ width='500px'
162
165
  intent={confirmationModal.intent}
163
166
  label={confirmationModal.title || 'Confirm your action'}
164
167
  icon='ErrorWarningFill'
@@ -184,7 +187,12 @@ const ReqoreProvider: React.FC<IReqoreNotifications> = ({ children, position })
184
187
  },
185
188
  ]}
186
189
  >
187
- {confirmationModal.description || 'Are you sure you want to proceed?'}
190
+ <ReqoreTextEffect
191
+ as='p'
192
+ effect={{ textAlign: 'center', weight: 'bold', textSize: 'big' }}
193
+ >
194
+ {confirmationModal.description || 'Are you sure you want to proceed?'}
195
+ </ReqoreTextEffect>
188
196
  </ReqoreModal>
189
197
  </ReqoreContext.Provider>
190
198
  </>
@@ -10,38 +10,40 @@ import { buildTheme } from '../helpers/colors';
10
10
  import PopoverProvider from './PopoverProvider';
11
11
  import ReqoreProvider from './ReqoreProvider';
12
12
 
13
+ export interface IReqoreOptions {
14
+ withSidebar?: boolean;
15
+ notificationsPosition?: IReqoreNotificationsPosition;
16
+ uiScale?: number;
17
+ animations?: {
18
+ buttons?: boolean;
19
+ };
20
+ }
13
21
  export interface IReqoreUIProviderProps {
14
22
  children: any;
15
23
  theme?: Partial<IReqoreTheme>;
16
- notificationsPosition?: IReqoreNotificationsPosition;
17
- withSidebar?: boolean;
18
- uiScale?: number;
24
+ options?: IReqoreOptions;
19
25
  }
20
26
 
21
27
  const StyledPortal = styled.div`
22
28
  z-index: 9999;
23
29
  `;
24
30
 
25
- const ReqoreUIProvider: React.FC<IReqoreUIProviderProps> = ({
26
- children,
27
- theme,
28
- notificationsPosition,
29
- withSidebar,
30
- uiScale,
31
- }) => {
31
+ const ReqoreUIProvider: React.FC<IReqoreUIProviderProps> = ({ children, theme, options }) => {
32
32
  const [modalPortal, setModalPortal] = useState<any>(false);
33
33
 
34
34
  const _theme: Partial<IReqoreTheme> = cloneDeep(theme || {});
35
35
  const _defaultTheme: IReqoreTheme = cloneDeep(DEFAULT_THEME);
36
36
  const rebuiltTheme: IReqoreTheme = buildTheme(merge(_defaultTheme, _theme));
37
37
 
38
+ console.log(options);
39
+
38
40
  return (
39
41
  <>
40
42
  <ThemeContext.Provider value={{ ...rebuiltTheme }}>
41
- <ReqoreLayoutWrapper withSidebar={withSidebar}>
43
+ <ReqoreLayoutWrapper withSidebar={options?.withSidebar}>
42
44
  {modalPortal ? (
43
- <ReqoreProvider position={notificationsPosition}>
44
- <PopoverProvider uiScale={uiScale}>{children}</PopoverProvider>
45
+ <ReqoreProvider options={options}>
46
+ <PopoverProvider uiScale={options?.uiScale}>{children}</PopoverProvider>
45
47
  </ReqoreProvider>
46
48
  ) : null}
47
49
  </ReqoreLayoutWrapper>
@@ -1,5 +1,6 @@
1
1
  import { createContext } from 'react';
2
2
  import { IReqoreConfirmationModal, IReqoreNotificationData } from '../containers/ReqoreProvider';
3
+ import { IReqoreOptions } from '../containers/UIProvider';
3
4
 
4
5
  export interface IReqoreContext {
5
6
  readonly confirmAction: (data: IReqoreConfirmationModal) => void;
@@ -10,6 +11,7 @@ export interface IReqoreContext {
10
11
  readonly isTablet?: boolean;
11
12
  readonly isMobileOrTablet?: boolean;
12
13
  readonly getAndIncreaseZIndex?: () => number;
14
+ readonly animations?: IReqoreOptions['animations'];
13
15
  }
14
16
 
15
17
  export default createContext<IReqoreContext>({
@@ -17,4 +19,7 @@ export default createContext<IReqoreContext>({
17
19
  notifications: null,
18
20
  addNotification: null,
19
21
  removeNotification: null,
22
+ animations: {
23
+ buttons: true,
24
+ },
20
25
  });
@@ -122,7 +122,7 @@ export const mergeThemes = (element: string, theme: IReqoreTheme, customTheme: a
122
122
  }
123
123
 
124
124
  if (element === 'main' && customTheme) {
125
- merge(clonedTheme, { main: customTheme.main });
125
+ merge(clonedTheme, { main: customTheme.main, originalMain: clonedTheme.main });
126
126
  } else {
127
127
  merge(clonedTheme, { [element]: customTheme || {} });
128
128
  }
@@ -63,30 +63,38 @@ const usePopover = ({
63
63
  [popovers, current]
64
64
  );
65
65
 
66
+ const openPopover = () => {
67
+ addPopover?.({
68
+ id: current,
69
+ content,
70
+ targetElement,
71
+ placement,
72
+ noArrow,
73
+ useTargetWidth,
74
+ closeOnOutsideClick,
75
+ closeOnAnyClick: handler === 'hover' || handler === 'hoverStay',
76
+ ...rest,
77
+ });
78
+
79
+ if (rest?.blur > 0) {
80
+ targetElement.style.position = 'relative';
81
+ targetElement.style.zIndex = '999999';
82
+ }
83
+ };
84
+
66
85
  const _addPopover = () => {
67
86
  if (currentPopover) {
68
87
  if (handler !== 'hoverStay') {
69
88
  _removePopover?.();
70
89
  }
71
90
  } else if (show) {
72
- timeout = setTimeout(() => {
73
- addPopover?.({
74
- id: current,
75
- content,
76
- targetElement,
77
- placement,
78
- noArrow,
79
- useTargetWidth,
80
- closeOnOutsideClick,
81
- closeOnAnyClick: handler === 'hover' || handler === 'hoverStay',
82
- ...rest,
83
- });
84
-
85
- if (rest?.blur > 0) {
86
- targetElement.style.position = 'relative';
87
- targetElement.style.zIndex = '999999';
88
- }
89
- }, delay || 0);
91
+ if (delay) {
92
+ timeout = setTimeout(() => {
93
+ openPopover();
94
+ }, delay);
95
+ } else {
96
+ openPopover();
97
+ }
90
98
  }
91
99
  };
92
100
 
@@ -119,7 +127,7 @@ const usePopover = ({
119
127
  ...rest,
120
128
  });
121
129
  }
122
- }, [content?.toString()]);
130
+ }, [content]);
123
131
 
124
132
  useEffect(() => {
125
133
  if (openOnMount && targetElement) {
@@ -155,7 +163,13 @@ const usePopover = ({
155
163
  }
156
164
  }
157
165
  };
158
- }, [targetElement?.toString(), content?.toString(), current, currentPopover]);
166
+ }, [
167
+ targetElement?.toString(),
168
+ //@ts-ignore
169
+ content,
170
+ current,
171
+ currentPopover,
172
+ ]);
159
173
 
160
174
  useUnmount(() => {
161
175
  cancelTimeout();
@@ -0,0 +1,32 @@
1
+ import { useEffect, useRef } from 'react';
2
+
3
+ export function useWhyDidYouUpdate(name, props) {
4
+ // Get a mutable ref object where we can store props ...
5
+ // ... for comparison next time this hook runs.
6
+ const previousProps: any = useRef();
7
+ useEffect(() => {
8
+ if (previousProps.current) {
9
+ // Get all keys from previous and current props
10
+ const allKeys = Object.keys({ ...previousProps.current, ...props });
11
+ // Use this object to keep track of changed props
12
+ const changesObj = {};
13
+ // Iterate through keys
14
+ allKeys.forEach((key) => {
15
+ // If previous is different from current
16
+ if (previousProps.current[key] !== props[key]) {
17
+ // Add to changesObj
18
+ changesObj[key] = {
19
+ from: previousProps.current[key],
20
+ to: props[key],
21
+ };
22
+ }
23
+ });
24
+ // If changesObj not empty then output to console
25
+ if (Object.keys(changesObj).length) {
26
+ console.log('[why-did-you-update]', name, changesObj);
27
+ }
28
+ }
29
+ // Finally update previousProps with current props for next hook call
30
+ previousProps.current = props;
31
+ });
32
+ }
package/src/index.tsx CHANGED
@@ -12,7 +12,16 @@ export { default as ReqoreControlGroup } from './components/ControlGroup';
12
12
  export { ReqoreDrawer } from './components/Drawer';
13
13
  export { default as ReqoreDropdown } from './components/Dropdown';
14
14
  export { ReqoreDropdownDivider, ReqoreDropdownItem } from './components/Dropdown/item';
15
- export { ReqoreH1, ReqoreH2, ReqoreH3, ReqoreH4, ReqoreH5, ReqoreH6 } from './components/Header';
15
+ export { ReqoreEffect, ReqoreTextEffect } from './components/Effect';
16
+ export {
17
+ ReqoreH1,
18
+ ReqoreH2,
19
+ ReqoreH3,
20
+ ReqoreH4,
21
+ ReqoreH5,
22
+ ReqoreH6,
23
+ ReqoreHeading,
24
+ } from './components/Header';
16
25
  export { default as ReqoreIcon } from './components/Icon';
17
26
  export { default as ReqoreInput } from './components/Input';
18
27
  export { default as ReqoreLayoutContent } from './components/Layout/content';