@qoretechnologies/reqore 0.44.0 → 0.45.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 (222) hide show
  1. package/package.json +1 -1
  2. package/tests.json +1 -1
  3. package/.eslintrc.js +0 -40
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  6. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  7. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  8. package/.github/workflows/beta_release.yml +0 -100
  9. package/.github/workflows/tests.yml +0 -84
  10. package/.gitpod.yml +0 -11
  11. package/.jest-test-results.json +0 -1
  12. package/.prettierrc +0 -7
  13. package/.vscode/settings.json +0 -0
  14. package/__tests__/breadcrumbs.test.tsx +0 -75
  15. package/__tests__/button.test.tsx +0 -218
  16. package/__tests__/checkbox.test.tsx +0 -45
  17. package/__tests__/collection.test.tsx +0 -243
  18. package/__tests__/containers/paging.test.tsx +0 -138
  19. package/__tests__/control_group.test.tsx +0 -32
  20. package/__tests__/drawer.test.tsx +0 -140
  21. package/__tests__/dropdown.test.tsx +0 -381
  22. package/__tests__/effect.test.tsx +0 -70
  23. package/__tests__/heading.test.tsx +0 -58
  24. package/__tests__/helpers/colors.test.tsx +0 -18
  25. package/__tests__/helpers/table.test.tsx +0 -67
  26. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  27. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  28. package/__tests__/hooks/useTheme.test.tsx +0 -31
  29. package/__tests__/icon.test.tsx +0 -53
  30. package/__tests__/input.test.tsx +0 -482
  31. package/__tests__/layout.test.tsx +0 -37
  32. package/__tests__/menu.test.tsx +0 -65
  33. package/__tests__/messages.test.tsx +0 -79
  34. package/__tests__/modal.test.tsx +0 -204
  35. package/__tests__/multiselect.test.tsx +0 -458
  36. package/__tests__/navbar.test.tsx +0 -31
  37. package/__tests__/notifications.test.tsx +0 -178
  38. package/__tests__/pagination.test.tsx +0 -437
  39. package/__tests__/panel.test.tsx +0 -243
  40. package/__tests__/popover.test.tsx +0 -282
  41. package/__tests__/radiogroup.test.tsx +0 -47
  42. package/__tests__/setup.js +0 -8
  43. package/__tests__/stories/Collection.stories.tsx +0 -0
  44. package/__tests__/table.test.tsx +0 -647
  45. package/__tests__/tabs.test.tsx +0 -321
  46. package/__tests__/tag.test.tsx +0 -160
  47. package/__tests__/textarea.test.tsx +0 -467
  48. package/__tests__/timeAgo.test.tsx +0 -27
  49. package/__tests__/tree.test.tsx +0 -58
  50. package/build-storybook.log +0 -491
  51. package/chromatic.config.json +0 -1
  52. package/icons.ts +0 -1
  53. package/migration-storybook.log +0 -56
  54. package/public/logo-dark.png +0 -0
  55. package/public/logo.png +0 -0
  56. package/public/q-symbol-small.png +0 -0
  57. package/public/q-symbol.png +0 -0
  58. package/public/qoreLogo-dark.png +0 -0
  59. package/public/qoreLogo.png +0 -0
  60. package/src/components/Breadcrumbs/index.tsx +0 -254
  61. package/src/components/Breadcrumbs/item.tsx +0 -44
  62. package/src/components/Button/index.tsx +0 -633
  63. package/src/components/Checkbox/index.tsx +0 -388
  64. package/src/components/Collection/index.tsx +0 -426
  65. package/src/components/Collection/item.tsx +0 -267
  66. package/src/components/Columns/column.tsx +0 -27
  67. package/src/components/Columns/index.tsx +0 -41
  68. package/src/components/Comment/index.tsx +0 -141
  69. package/src/components/CommentFeed/index.tsx +0 -34
  70. package/src/components/Content/index.tsx +0 -34
  71. package/src/components/Content/wrapper.tsx +0 -36
  72. package/src/components/ControlGroup/index.tsx +0 -523
  73. package/src/components/DatePicker/index.tsx +0 -347
  74. package/src/components/Drawer/backdrop.tsx +0 -54
  75. package/src/components/Drawer/index.tsx +0 -365
  76. package/src/components/Dropdown/index.tsx +0 -153
  77. package/src/components/Dropdown/item.tsx +0 -33
  78. package/src/components/Dropdown/list.tsx +0 -222
  79. package/src/components/Effect/index.tsx +0 -464
  80. package/src/components/ExportModal/index.tsx +0 -99
  81. package/src/components/Header/index.tsx +0 -81
  82. package/src/components/Icon/index.tsx +0 -184
  83. package/src/components/Input/index.tsx +0 -295
  84. package/src/components/InputClearButton/index.tsx +0 -59
  85. package/src/components/InternalPopover/index.tsx +0 -303
  86. package/src/components/KeyValueTable/index.tsx +0 -192
  87. package/src/components/Label/index.tsx +0 -10
  88. package/src/components/Layout/content.tsx +0 -31
  89. package/src/components/Layout/index.tsx +0 -55
  90. package/src/components/Menu/divider.tsx +0 -92
  91. package/src/components/Menu/index.tsx +0 -141
  92. package/src/components/Menu/item.tsx +0 -137
  93. package/src/components/Menu/section.tsx +0 -81
  94. package/src/components/Message/index.tsx +0 -220
  95. package/src/components/Modal/index.tsx +0 -26
  96. package/src/components/MultiSelect/index.tsx +0 -288
  97. package/src/components/Navbar/divider.tsx +0 -50
  98. package/src/components/Navbar/group.tsx +0 -53
  99. package/src/components/Navbar/index.tsx +0 -82
  100. package/src/components/Navbar/item.tsx +0 -92
  101. package/src/components/Notifications/index.tsx +0 -57
  102. package/src/components/Notifications/notification.tsx +0 -362
  103. package/src/components/Paging/index.tsx +0 -321
  104. package/src/components/Panel/LabelEditor.tsx +0 -67
  105. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  106. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  107. package/src/components/Panel/index.tsx +0 -912
  108. package/src/components/Panel/panel.screenshot.tsx +0 -29
  109. package/src/components/Paragraph/index.tsx +0 -43
  110. package/src/components/Popover/index.tsx +0 -68
  111. package/src/components/RadioGroup/index.tsx +0 -71
  112. package/src/components/Slider/index.tsx +0 -358
  113. package/src/components/Spacer/index.tsx +0 -142
  114. package/src/components/Spinner/index.tsx +0 -74
  115. package/src/components/Table/body.tsx +0 -109
  116. package/src/components/Table/cell.tsx +0 -136
  117. package/src/components/Table/header.tsx +0 -236
  118. package/src/components/Table/headerCell.tsx +0 -203
  119. package/src/components/Table/helpers.ts +0 -308
  120. package/src/components/Table/index.tsx +0 -797
  121. package/src/components/Table/row.tsx +0 -288
  122. package/src/components/Table/value.tsx +0 -28
  123. package/src/components/Tabs/content.tsx +0 -68
  124. package/src/components/Tabs/index.tsx +0 -124
  125. package/src/components/Tabs/item.tsx +0 -198
  126. package/src/components/Tabs/list.tsx +0 -381
  127. package/src/components/Tag/group.tsx +0 -73
  128. package/src/components/Tag/index.tsx +0 -463
  129. package/src/components/Textarea/index.tsx +0 -277
  130. package/src/components/TimeAgo/index.tsx +0 -15
  131. package/src/components/Tree/index.tsx +0 -271
  132. package/src/constants/animations.ts +0 -9
  133. package/src/constants/colors.ts +0 -13
  134. package/src/constants/paging.ts +0 -93
  135. package/src/constants/sizes.ts +0 -185
  136. package/src/constants/theme.ts +0 -122
  137. package/src/containers/Paging.tsx +0 -136
  138. package/src/containers/PopoverProvider.tsx +0 -124
  139. package/src/containers/ReqoreProvider.tsx +0 -289
  140. package/src/containers/ThemeProvider.tsx +0 -12
  141. package/src/containers/UIProvider.tsx +0 -101
  142. package/src/context/PopoverContext.tsx +0 -11
  143. package/src/context/ReqoreContext.tsx +0 -47
  144. package/src/context/ThemeContext.tsx +0 -4
  145. package/src/helpers/animations.ts +0 -13
  146. package/src/helpers/colors.ts +0 -335
  147. package/src/helpers/time.ts +0 -21
  148. package/src/helpers/utils.ts +0 -152
  149. package/src/hooks/useAutoFocus.ts +0 -106
  150. package/src/hooks/useCloneThroughFragments.ts +0 -39
  151. package/src/hooks/useCombinedRefs.ts +0 -26
  152. package/src/hooks/useLatestZIndex.ts +0 -13
  153. package/src/hooks/useOutsideClick.ts +0 -29
  154. package/src/hooks/usePaging.ts +0 -128
  155. package/src/hooks/usePopover.tsx +0 -220
  156. package/src/hooks/useQueryWithDelay.ts +0 -30
  157. package/src/hooks/useReqore.ts +0 -12
  158. package/src/hooks/useReqoreContext.ts +0 -16
  159. package/src/hooks/useReqoreEffect.ts +0 -49
  160. package/src/hooks/useTextareaAutoSize.ts +0 -22
  161. package/src/hooks/useTheme.ts +0 -48
  162. package/src/hooks/useTooltip.ts +0 -40
  163. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  164. package/src/icons.json +0 -2295
  165. package/src/index.tsx +0 -80
  166. package/src/mock/breadcrumbs.ts +0 -146
  167. package/src/mock/collectionData.tsx +0 -380
  168. package/src/mock/data.json +0 -11000
  169. package/src/mock/icons.ts +0 -32
  170. package/src/mock/menu.ts +0 -93
  171. package/src/mock/multiSelect.ts +0 -71
  172. package/src/mock/object.json +0 -317
  173. package/src/mock/styleMock.js +0 -1
  174. package/src/mock/tableData.ts +0 -64
  175. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  176. package/src/stories/Button/Button.stories.tsx +0 -405
  177. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  178. package/src/stories/Collection/Collection.stories.tsx +0 -317
  179. package/src/stories/Columns/Columns.stories.tsx +0 -158
  180. package/src/stories/Comment/Comment.stories.tsx +0 -136
  181. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  182. package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
  183. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  184. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  185. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  186. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  187. package/src/stories/Header/Header.stories.tsx +0 -108
  188. package/src/stories/Icon/Icon.stories.tsx +0 -162
  189. package/src/stories/Input/Input.stories.tsx +0 -220
  190. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  191. package/src/stories/Label/Label.stories.tsx +0 -33
  192. package/src/stories/Menu/Menu.stories.tsx +0 -367
  193. package/src/stories/Message/Message.stories.tsx +0 -167
  194. package/src/stories/Modal/Manager.stories.tsx +0 -192
  195. package/src/stories/Modal/Modal.stories.tsx +0 -252
  196. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  197. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  198. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  199. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  200. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  201. package/src/stories/Paging/Paging.stories.tsx +0 -255
  202. package/src/stories/Panel/Panel.stories.tsx +0 -753
  203. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  204. package/src/stories/Popover/Popover.stories.tsx +0 -510
  205. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  206. package/src/stories/Slider/Slider.stories.tsx +0 -173
  207. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  208. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  209. package/src/stories/Table/Table.stories.tsx +0 -571
  210. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  211. package/src/stories/Tag/Tag.stories.tsx +0 -381
  212. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  213. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  214. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  215. package/src/stories/Tree/Tree.stories.tsx +0 -124
  216. package/src/stories/Wrapper.tsx +0 -13
  217. package/src/stories/utils/args.ts +0 -151
  218. package/src/stories/utils.ts +0 -39
  219. package/src/styles.ts +0 -124
  220. package/src/types/global.ts +0 -211
  221. package/src/types/icons.ts +0 -2272
  222. package/tsconfig.prod.json +0 -26
@@ -1,362 +0,0 @@
1
- import { animated, useTransition } from '@react-spring/web';
2
- import { rgba } from 'polished';
3
- import React, { forwardRef, useEffect, useState } from 'react';
4
- import { useMount, useUnmount } from 'react-use';
5
- import styled, { css, keyframes } from 'styled-components';
6
- import { SPRING_CONFIG } from '../../constants/animations';
7
- import { PADDING_FROM_SIZE, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
8
- import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
9
- import ReqoreThemeProvider from '../../containers/ThemeProvider';
10
- import { fadeIn } from '../../helpers/animations';
11
- import {
12
- changeDarkness,
13
- changeLightness,
14
- getNotificationIntent,
15
- getReadableColor,
16
- } from '../../helpers/colors';
17
- import { useReqoreTheme } from '../../hooks/useTheme';
18
- import {
19
- IWithReqoreCustomTheme,
20
- IWithReqoreEffect,
21
- IWithReqoreMinimal,
22
- IWithReqoreOpaque,
23
- } from '../../types/global';
24
- import { IReqoreIconName } from '../../types/icons';
25
- import { StyledEffect } from '../Effect';
26
- import { ReqoreHeading } from '../Header';
27
- import ReqoreIcon from '../Icon';
28
- import { ReqoreSpinner } from '../Spinner';
29
-
30
- export type IReqoreNotificationType = TReqoreIntent;
31
-
32
- export interface IReqoreNotificationProps
33
- extends IWithReqoreEffect,
34
- IWithReqoreMinimal,
35
- IWithReqoreOpaque,
36
- IWithReqoreCustomTheme {
37
- type?: IReqoreNotificationType;
38
- intent?: TReqoreIntent;
39
- title?: string;
40
- content: string | React.ReactNode;
41
- icon?: IReqoreIconName;
42
- onClose?: () => any;
43
- onClick?: () => any;
44
- duration?: number;
45
- onFinish?: () => any;
46
- fluid?: boolean;
47
- flat?: boolean;
48
- size?: TSizes;
49
- }
50
-
51
- export interface IReqoreNotificationStyle extends IWithReqoreOpaque {
52
- theme: IReqoreTheme;
53
- type?: IReqoreNotificationType;
54
- clickable?: boolean;
55
- timeout?: number;
56
- intent?: TReqoreIntent;
57
- hasShadow?: boolean;
58
- fluid?: boolean;
59
- flat?: boolean;
60
- minimal?: boolean;
61
- size?: TSizes;
62
- asMessage?: boolean;
63
- margin?: 'top' | 'bottom' | 'both' | 'none';
64
- }
65
-
66
- const timeoutAnimation = keyframes`
67
- 0% {
68
- width: 100%;
69
- }
70
- 100% {
71
- width: 0;
72
- }
73
- `;
74
-
75
- export const StyledReqoreNotification = styled(StyledEffect)<IReqoreNotificationStyle>`
76
- min-width: ${({ fluid }) => (!fluid ? '30px' : undefined)};
77
- max-width: ${({ maxWidth, fluid, fixed }) => maxWidth || (fluid && !fixed ? '100%' : undefined)};
78
- border-radius: 5px;
79
- display: flex;
80
- flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
81
- align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
82
- overflow: hidden;
83
- position: relative;
84
- transition: all 0.2s ease-out;
85
-
86
- ${({ margin, size = 'normal' }) => css`
87
- margin-top: ${margin === 'top' || margin === 'both'
88
- ? `${PADDING_FROM_SIZE[size]}px`
89
- : undefined};
90
- margin-bottom: ${margin === 'bottom' || margin === 'both'
91
- ? `${PADDING_FROM_SIZE[size]}px`
92
- : undefined};
93
- `};
94
-
95
- // Do not fade in the component if it's a message
96
- ${({ asMessage }) => {
97
- if (asMessage) {
98
- return undefined;
99
- }
100
- return css`
101
- animation: 0.2s ${fadeIn} ease-in;
102
- `;
103
- }}
104
-
105
- &:not(:first-child) {
106
- margin-top: ${({ asMessage, size }) =>
107
- asMessage ? undefined : `${PADDING_FROM_SIZE[size]}px`};
108
- }
109
-
110
- ${({
111
- theme,
112
- type,
113
- intent,
114
- clickable,
115
- timeout,
116
- hasShadow,
117
- flat,
118
- minimal,
119
- opaque = true,
120
- }: IReqoreNotificationStyle) => css`
121
- background-color: ${minimal
122
- ? 'transparent'
123
- : opaque
124
- ? changeLightness(theme.main, 0.1)
125
- : rgba(getNotificationIntent(theme, intent || type), 0.3)};
126
- border: ${flat ? 0 : '1px solid'};
127
- border-color: ${changeLightness(getNotificationIntent(theme, intent || type), 0.2)};
128
-
129
- ${hasShadow &&
130
- css`
131
- box-shadow: 0px 0px 30px 10px ${rgba('#000000', 0.3)};
132
- `}
133
-
134
- ${timeout &&
135
- css`
136
- &::before {
137
- content: '';
138
- position: absolute;
139
- display: block;
140
- top: 0;
141
- height: 3px;
142
- background-color: ${changeLightness(getNotificationIntent(theme, intent || type), 0.2)};
143
- animation-name: ${timeoutAnimation};
144
- animation-duration: ${timeout}ms;
145
- }
146
- `}
147
-
148
- color: ${minimal || !opaque
149
- ? 'inherit'
150
- : getReadableColor(theme, null, null, true, minimal ? theme.originalMain : undefined)};
151
-
152
- ${clickable &&
153
- css`
154
- cursor: pointer;
155
- &:hover {
156
- background-color: ${minimal
157
- ? 'transparent'
158
- : opaque
159
- ? changeDarkness(theme.main, 0.002)
160
- : rgba(getNotificationIntent(theme, intent || type), 0.4)};
161
- border-color: ${changeLightness(getNotificationIntent(theme, intent || type), 0.25)};
162
- }
163
- `}
164
- `}
165
- `;
166
-
167
- export const StyledIconWrapper = styled.div<IReqoreNotificationStyle>`
168
- flex: 0 1 auto;
169
- flex-shrink: 0;
170
- display: flex;
171
- justify-content: center;
172
- align-items: center;
173
- transition: all 0.2s ease-out;
174
-
175
- ${({ clickable, theme, intent, type }) =>
176
- clickable &&
177
- css`
178
- margin-top: unset;
179
- height: unset;
180
-
181
- .reqore-icon {
182
- transform: scale(0.85);
183
- }
184
-
185
- &:hover {
186
- cursor: pointer;
187
- background-color: ${changeLightness(getNotificationIntent(theme, intent || type), 0.02)};
188
- .reqore-icon {
189
- transform: scale(1);
190
- }
191
- }
192
- `}
193
- `;
194
-
195
- export const StyledNotificationInnerContent = styled.div<IReqoreNotificationStyle>`
196
- flex: 1;
197
- display: flex;
198
- flex-flow: column;
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;
210
- padding: ${({ size = 'normal' }: IReqoreNotificationStyle) => `${PADDING_FROM_SIZE[size]}px`};
211
- `;
212
-
213
- export const StyledNotificationTitle = styled.h4`
214
- margin: 0 0 5px 0;
215
- padding: 0;
216
- display: flex;
217
- align-items: center;
218
- `;
219
-
220
- export const StyledNotificationContent = styled.div`
221
- margin: 0;
222
- padding: 0;
223
- flex: 1;
224
- font-size: ${({ size = 'normal' }) => TEXT_FROM_SIZE[size]}px;
225
- overflow-wrap: anywhere;
226
- display: flex;
227
- flex-flow: column;
228
- justify-content: center;
229
-
230
- ${({ hasTitle, size = 'normal' }) =>
231
- hasTitle &&
232
- css`
233
- padding-top: ${PADDING_FROM_SIZE[size]}px;
234
- `}
235
- `;
236
-
237
- export const typeToIcon: { [type: string]: IReqoreIconName } = {
238
- info: 'InformationLine',
239
- pending: 'TimerLine',
240
- warning: 'AlarmWarningLine',
241
- danger: 'ErrorWarningLine',
242
- success: 'CheckFill',
243
- muted: 'Forbid2Line',
244
- };
245
-
246
- const ReqoreNotification = forwardRef<HTMLDivElement, IReqoreNotificationProps>(
247
- (
248
- {
249
- type,
250
- intent,
251
- icon,
252
- title,
253
- content,
254
- onClose,
255
- onClick,
256
- duration,
257
- onFinish,
258
- flat,
259
- minimal,
260
- opaque = true,
261
- size = 'normal',
262
- customTheme,
263
- },
264
- ref: any
265
- ) => {
266
- const [internalTimeout, setInternalTimeout] = useState(null);
267
- const theme = useReqoreTheme('main', customTheme, type || intent, 'notifications');
268
-
269
- const transitions = useTransition(true, {
270
- from: { opacity: 0, transform: 'scale(0.9)' },
271
- enter: { opacity: 1, transform: 'scale(1)' },
272
- leave: { opacity: 0, transform: 'scale(0.9)' },
273
- config: SPRING_CONFIG,
274
- });
275
-
276
- useMount(() => {
277
- if (duration) {
278
- setInternalTimeout(
279
- setTimeout(() => {
280
- onFinish && onFinish();
281
- }, duration)
282
- );
283
- }
284
- });
285
-
286
- useEffect(() => {
287
- if (internalTimeout) {
288
- clearTimeout(internalTimeout);
289
- setInternalTimeout(
290
- setTimeout(() => {
291
- onFinish && onFinish();
292
- }, duration)
293
- );
294
- }
295
- }, [duration, type, intent, content, title]);
296
-
297
- useUnmount(() => {
298
- clearTimeout(internalTimeout);
299
- });
300
-
301
- return transitions((styles, item) =>
302
- item ? (
303
- <ReqoreThemeProvider>
304
- <StyledReqoreNotification
305
- as={animated.div}
306
- key={`${duration}${type || intent}${title}${content}`}
307
- type={type || intent}
308
- hasShadow
309
- timeout={duration}
310
- clickable={!!onClick}
311
- onClick={() => onClick?.()}
312
- flat={flat}
313
- minimal={minimal}
314
- className='reqore-notification'
315
- ref={ref}
316
- style={styles}
317
- size={size}
318
- opaque={opaque}
319
- theme={theme}
320
- maxWidth='450px'
321
- >
322
- <StyledNotificationContentWrapper size={size} theme={theme}>
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>
342
- </StyledNotificationContentWrapper>
343
- <StyledIconWrapper
344
- type={type || intent}
345
- size={size}
346
- clickable
347
- className='reqore-notification-close'
348
- onClick={(event) => {
349
- event.stopPropagation();
350
- onClose && onClose();
351
- }}
352
- >
353
- <ReqoreIcon icon='CloseFill' margin='both' size={size} />
354
- </StyledIconWrapper>
355
- </StyledReqoreNotification>
356
- </ReqoreThemeProvider>
357
- ) : null
358
- );
359
- }
360
- );
361
-
362
- export default ReqoreNotification;
@@ -1,321 +0,0 @@
1
- import { debounce } from 'lodash';
2
- import { memo, useEffect, useRef, useState } from 'react';
3
- import { useUnmount, useUpdateEffect } from 'react-use';
4
- import styled from 'styled-components';
5
- import { ReqoreDropdown } from '../..';
6
- import { IReqorePagingResult } from '../../hooks/usePaging';
7
- import ReqoreButton, { IReqoreButtonProps, StyledButton } from '../Button';
8
- import ReqoreControlGroup, { IReqoreControlGroupProps } from '../ControlGroup';
9
- import { IReqoreDropdownProps } from '../Dropdown';
10
- import { IReqoreDropdownItemProps } from '../Dropdown/item';
11
-
12
- export interface IReqorePaginationComponentProps
13
- extends Omit<IReqoreControlGroupProps, 'children'> {
14
- pageButtonProps?: IReqoreButtonProps;
15
- activePageButtonProps?: IReqoreButtonProps;
16
- listPageButtonProps?: IReqoreDropdownProps;
17
- controlPageButtonProps?: IReqoreButtonProps;
18
- loadMoreButtonProps?: IReqoreButtonProps;
19
- loadAllButtonProps?: IReqoreButtonProps;
20
- firstPageLabel?: string;
21
- lastPageLabel?: string;
22
- nextPageLabel?: string;
23
- previousPageLabel?: string;
24
- pageLabel?: string;
25
- loadMoreLabel?: string;
26
- loadAllLabel?: string;
27
- showPages?: boolean;
28
- showControls?: boolean;
29
- showLoadAllButton?: boolean;
30
- showPagesAs?: 'buttons' | 'list';
31
- showLabels?: boolean;
32
- scrollOnLoadMore?: boolean;
33
- autoLoadMore?: boolean;
34
- changePageOnScroll?: 'vertical' | 'horizontal';
35
- scrollContainer?: HTMLElement;
36
- scrollToTopOnPageChange?: boolean;
37
- }
38
- export interface IReqorePaginationProps<T>
39
- extends Omit<IReqorePagingResult<T>, 'items'>,
40
- IReqorePaginationComponentProps {}
41
-
42
- export const StyledPagesWrapper = styled(ReqoreControlGroup)`
43
- width: unset;
44
- flex: 0 auto;
45
- justify-content: center;
46
-
47
- & > ${StyledButton} {
48
- margin: 0;
49
- }
50
- `;
51
-
52
- function Pagination<T>({
53
- back,
54
- first,
55
- currentPage,
56
- isLastPage,
57
- isFirstPage,
58
- pageCount,
59
- pages,
60
- last,
61
- next,
62
- setPage,
63
- infinite,
64
- itemsLeft,
65
- showPagesAs = 'buttons',
66
- pageButtonProps = {},
67
- activePageButtonProps = {},
68
- listPageButtonProps = {},
69
- controlPageButtonProps = {},
70
- loadMoreButtonProps = {},
71
- loadAllButtonProps = {},
72
- firstPageLabel = 'First',
73
- lastPageLabel = 'Last',
74
- nextPageLabel = 'Next',
75
- previousPageLabel = 'Back',
76
- pageLabel = 'Page',
77
- loadMoreLabel = 'Load more',
78
- loadAllLabel = 'Load all',
79
- showLabels,
80
- showPages = true,
81
- showControls = true,
82
- showLoadAllButton = true,
83
- scrollOnLoadMore,
84
- autoLoadMore,
85
- itemsPerPage,
86
- renderControls,
87
- scrollContainer,
88
- scrollToTopOnPageChange = true,
89
- changePageOnScroll,
90
- ...rest
91
- }: IReqorePaginationProps<T>) {
92
- const [loadMoreRef, setLoadMoreRef] = useState<HTMLButtonElement>(undefined);
93
- const [scrollTargetRef, setScrollTargetRef] = useState<HTMLDivElement>(undefined);
94
- const observer = useRef<IntersectionObserver>(null);
95
-
96
- useUpdateEffect(() => {
97
- // If scroll container is defined, do not scroll to load more button
98
- // because it will be scrolled to the bottom of the container
99
- // resulting in infinite scroll
100
- if (!scrollContainer && scrollTargetRef && scrollOnLoadMore && !isLastPage && !isFirstPage) {
101
- scrollTargetRef.scrollIntoView({
102
- behavior: 'smooth',
103
- block: 'end',
104
- inline: 'start',
105
- });
106
- }
107
- }, [currentPage, scrollTargetRef, scrollContainer, scrollOnLoadMore, isLastPage, isFirstPage]);
108
-
109
- // Scroll to bottom on load more
110
- // Scroll container has power over scroll target
111
- useUpdateEffect(() => {
112
- if (scrollContainer && scrollOnLoadMore && !isFirstPage) {
113
- scrollContainer.scrollBy?.({
114
- top: scrollContainer.scrollHeight,
115
- behavior: 'smooth',
116
- });
117
- }
118
- }, [currentPage, scrollContainer, scrollOnLoadMore, isFirstPage]);
119
-
120
- // Scroll to top on page change
121
- useUpdateEffect(() => {
122
- if (scrollContainer && scrollToTopOnPageChange && !infinite) {
123
- scrollContainer.scrollTo?.({
124
- top: 0,
125
- behavior: 'smooth',
126
- });
127
- }
128
- }, [currentPage, scrollContainer, scrollToTopOnPageChange, infinite]);
129
-
130
- // Switch pages when user scrolls and holds the Shift key
131
- useEffect(() => {
132
- const handleScroll = debounce((e: WheelEvent) => {
133
- const deltaKey = changePageOnScroll === 'vertical' ? 'deltaY' : 'deltaX';
134
- // Only change pages when user holds the shift key
135
- // aka horizontal scroll
136
- if (
137
- changePageOnScroll === 'vertical' ||
138
- (changePageOnScroll === 'horizontal' && e.shiftKey)
139
- ) {
140
- // Do not horizontal scroll
141
- e.preventDefault();
142
- // If the user scrolls to the right, go to the next page
143
- if (e[deltaKey] > 20) {
144
- next();
145
- // If the user scrolls to the left, go to the previous page
146
- } else if (e[deltaKey] < -20) {
147
- back();
148
- }
149
- }
150
- }, 30);
151
-
152
- if (scrollContainer && changePageOnScroll) {
153
- scrollContainer.addEventListener('wheel', handleScroll);
154
- }
155
-
156
- return () => {
157
- if (scrollContainer) {
158
- scrollContainer.removeEventListener('wheel', handleScroll);
159
- }
160
- };
161
- }, [currentPage, scrollContainer, changePageOnScroll]);
162
-
163
- useUpdateEffect(() => {
164
- if (loadMoreRef && autoLoadMore) {
165
- observer.current = new IntersectionObserver(
166
- (entries: IntersectionObserverEntry[]) => {
167
- entries.forEach((entry) => {
168
- if (entry.isIntersecting) {
169
- next();
170
- }
171
- });
172
- },
173
- {
174
- threshold: 0.8,
175
- }
176
- );
177
-
178
- observer.current.observe(loadMoreRef);
179
- }
180
- }, [loadMoreRef, autoLoadMore, isLastPage]);
181
-
182
- useUnmount(() => {
183
- observer.current?.disconnect();
184
- });
185
-
186
- if (!renderControls) {
187
- return null;
188
- }
189
-
190
- return (
191
- <ReqoreControlGroup
192
- {...rest}
193
- className={`${rest.className || ''} reqore-pagination-wrapper`}
194
- style={{ justifyContent: 'center' }}
195
- >
196
- {infinite && !isLastPage ? (
197
- <ReqoreControlGroup vertical>
198
- <div className='reqore-auto-scroll-target' ref={setScrollTargetRef} />
199
- <ReqoreControlGroup stack>
200
- <ReqoreButton
201
- icon='ArrowDropDownLine'
202
- badge={itemsPerPage}
203
- iconsAlign='center'
204
- {...loadMoreButtonProps}
205
- onClick={next}
206
- ref={setLoadMoreRef}
207
- style={{
208
- scrollMarginTop: '200px',
209
- }}
210
- >
211
- {showLabels && loadMoreLabel}
212
- </ReqoreButton>
213
- {showLoadAllButton && (
214
- <ReqoreButton
215
- icon='ArrowDropDownLine'
216
- badge={itemsLeft}
217
- iconsAlign='center'
218
- {...loadAllButtonProps}
219
- onClick={last}
220
- style={{
221
- scrollMarginTop: '200px',
222
- }}
223
- >
224
- {showLabels && loadAllLabel}
225
- </ReqoreButton>
226
- )}
227
- </ReqoreControlGroup>
228
- </ReqoreControlGroup>
229
- ) : null}
230
- {!infinite ? (
231
- <>
232
- {showPagesAs === 'list' || (showControls && !showPages) ? (
233
- <ReqoreButton
234
- icon='RewindMiniLine'
235
- fixed
236
- {...controlPageButtonProps}
237
- onClick={first}
238
- disabled={isFirstPage}
239
- tooltip={!showLabels && firstPageLabel}
240
- >
241
- {showLabels && firstPageLabel}
242
- </ReqoreButton>
243
- ) : null}
244
- {showControls && (
245
- <ReqoreButton
246
- icon='ArrowDropLeftLine'
247
- fixed
248
- {...controlPageButtonProps}
249
- onClick={back}
250
- disabled={isFirstPage}
251
- tooltip={!showLabels && previousPageLabel}
252
- >
253
- {showLabels && previousPageLabel}
254
- </ReqoreButton>
255
- )}
256
- {showPages && (
257
- <StyledPagesWrapper wrap horizontalAlign='center'>
258
- {showPagesAs === 'buttons' ? (
259
- pages.map((page) => (
260
- <ReqoreButton
261
- textAlign='center'
262
- fixed
263
- key={page}
264
- onClick={() => setPage(page)}
265
- active={page === currentPage}
266
- {...(page === currentPage ? activePageButtonProps : pageButtonProps)}
267
- >
268
- {page}
269
- </ReqoreButton>
270
- ))
271
- ) : (
272
- <ReqoreDropdown
273
- filterable
274
- label={`${showLabels ? `${pageLabel} ` : ''}${currentPage} / ${pageCount}`}
275
- items={pages.map((page) => ({
276
- label: `${showLabels ? `${pageLabel} ` : ''}${page}`,
277
- onClick: () => setPage(page),
278
- selected: page === currentPage,
279
- ...(page === currentPage
280
- ? (activePageButtonProps as IReqoreDropdownItemProps)
281
- : (pageButtonProps as IReqoreDropdownItemProps)),
282
- }))}
283
- placement='bottom'
284
- inputProps={{ focusRules: { type: 'auto', viewportOnly: true } }}
285
- scrollToSelected
286
- {...listPageButtonProps}
287
- />
288
- )}
289
- </StyledPagesWrapper>
290
- )}
291
- {showControls && (
292
- <ReqoreButton
293
- icon='ArrowDropRightLine'
294
- fixed
295
- {...controlPageButtonProps}
296
- onClick={next}
297
- disabled={isLastPage}
298
- tooltip={!showLabels && nextPageLabel}
299
- >
300
- {showLabels && nextPageLabel}
301
- </ReqoreButton>
302
- )}
303
- {showPagesAs === 'list' || (showControls && !showPages) ? (
304
- <ReqoreButton
305
- icon='SpeedMiniLine'
306
- fixed
307
- {...controlPageButtonProps}
308
- onClick={last}
309
- disabled={isLastPage}
310
- tooltip={!showLabels && lastPageLabel}
311
- >
312
- {showLabels && lastPageLabel}
313
- </ReqoreButton>
314
- ) : null}
315
- </>
316
- ) : null}
317
- </ReqoreControlGroup>
318
- );
319
- }
320
-
321
- export const ReqorePagination = memo(Pagination) as typeof Pagination;