@qoretechnologies/reqore 0.43.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 (243) hide show
  1. package/dist/components/Button/index.d.ts +1 -0
  2. package/dist/components/Button/index.d.ts.map +1 -1
  3. package/dist/components/Button/index.js +6 -2
  4. package/dist/components/Button/index.js.map +1 -1
  5. package/dist/components/DatePicker/index.d.ts +29 -0
  6. package/dist/components/DatePicker/index.d.ts.map +1 -0
  7. package/dist/components/DatePicker/index.js +147 -0
  8. package/dist/components/DatePicker/index.js.map +1 -0
  9. package/dist/components/Effect/index.d.ts +1 -1
  10. package/dist/components/Effect/index.d.ts.map +1 -1
  11. package/dist/components/Effect/index.js.map +1 -1
  12. package/dist/components/Input/index.d.ts +3 -1
  13. package/dist/components/Input/index.d.ts.map +1 -1
  14. package/dist/components/Input/index.js +5 -1
  15. package/dist/components/Input/index.js.map +1 -1
  16. package/dist/components/InternalPopover/index.d.ts +2 -0
  17. package/dist/components/InternalPopover/index.d.ts.map +1 -1
  18. package/dist/components/InternalPopover/index.js +5 -4
  19. package/dist/components/InternalPopover/index.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -0
  23. package/dist/index.js.map +1 -1
  24. package/package.json +4 -1
  25. package/tests.json +1 -1
  26. package/.eslintrc.js +0 -40
  27. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  28. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  29. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  30. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  31. package/.github/workflows/beta_release.yml +0 -100
  32. package/.github/workflows/tests.yml +0 -84
  33. package/.gitpod.yml +0 -11
  34. package/.jest-test-results.json +0 -1
  35. package/.prettierrc +0 -7
  36. package/.vscode/settings.json +0 -0
  37. package/__tests__/breadcrumbs.test.tsx +0 -75
  38. package/__tests__/button.test.tsx +0 -218
  39. package/__tests__/checkbox.test.tsx +0 -45
  40. package/__tests__/collection.test.tsx +0 -243
  41. package/__tests__/containers/paging.test.tsx +0 -138
  42. package/__tests__/control_group.test.tsx +0 -32
  43. package/__tests__/drawer.test.tsx +0 -140
  44. package/__tests__/dropdown.test.tsx +0 -381
  45. package/__tests__/effect.test.tsx +0 -70
  46. package/__tests__/heading.test.tsx +0 -58
  47. package/__tests__/helpers/colors.test.tsx +0 -18
  48. package/__tests__/helpers/table.test.tsx +0 -67
  49. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  50. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  51. package/__tests__/hooks/useTheme.test.tsx +0 -31
  52. package/__tests__/icon.test.tsx +0 -53
  53. package/__tests__/input.test.tsx +0 -482
  54. package/__tests__/layout.test.tsx +0 -37
  55. package/__tests__/menu.test.tsx +0 -65
  56. package/__tests__/messages.test.tsx +0 -79
  57. package/__tests__/modal.test.tsx +0 -204
  58. package/__tests__/multiselect.test.tsx +0 -458
  59. package/__tests__/navbar.test.tsx +0 -31
  60. package/__tests__/notifications.test.tsx +0 -178
  61. package/__tests__/pagination.test.tsx +0 -437
  62. package/__tests__/panel.test.tsx +0 -243
  63. package/__tests__/popover.test.tsx +0 -282
  64. package/__tests__/radiogroup.test.tsx +0 -47
  65. package/__tests__/setup.js +0 -8
  66. package/__tests__/stories/Collection.stories.tsx +0 -0
  67. package/__tests__/table.test.tsx +0 -647
  68. package/__tests__/tabs.test.tsx +0 -321
  69. package/__tests__/tag.test.tsx +0 -160
  70. package/__tests__/textarea.test.tsx +0 -467
  71. package/__tests__/timeAgo.test.tsx +0 -27
  72. package/__tests__/tree.test.tsx +0 -58
  73. package/build-storybook.log +0 -491
  74. package/chromatic.config.json +0 -1
  75. package/icons.ts +0 -1
  76. package/migration-storybook.log +0 -56
  77. package/public/logo-dark.png +0 -0
  78. package/public/logo.png +0 -0
  79. package/public/q-symbol-small.png +0 -0
  80. package/public/q-symbol.png +0 -0
  81. package/public/qoreLogo-dark.png +0 -0
  82. package/public/qoreLogo.png +0 -0
  83. package/src/components/Breadcrumbs/index.tsx +0 -254
  84. package/src/components/Breadcrumbs/item.tsx +0 -44
  85. package/src/components/Button/index.tsx +0 -628
  86. package/src/components/Checkbox/index.tsx +0 -388
  87. package/src/components/Collection/index.tsx +0 -426
  88. package/src/components/Collection/item.tsx +0 -267
  89. package/src/components/Columns/column.tsx +0 -27
  90. package/src/components/Columns/index.tsx +0 -41
  91. package/src/components/Comment/index.tsx +0 -141
  92. package/src/components/CommentFeed/index.tsx +0 -34
  93. package/src/components/Content/index.tsx +0 -34
  94. package/src/components/Content/wrapper.tsx +0 -36
  95. package/src/components/ControlGroup/index.tsx +0 -523
  96. package/src/components/Drawer/backdrop.tsx +0 -54
  97. package/src/components/Drawer/index.tsx +0 -365
  98. package/src/components/Dropdown/index.tsx +0 -153
  99. package/src/components/Dropdown/item.tsx +0 -33
  100. package/src/components/Dropdown/list.tsx +0 -222
  101. package/src/components/Effect/index.tsx +0 -463
  102. package/src/components/ExportModal/index.tsx +0 -99
  103. package/src/components/Header/index.tsx +0 -81
  104. package/src/components/Icon/index.tsx +0 -184
  105. package/src/components/Input/index.tsx +0 -282
  106. package/src/components/InputClearButton/index.tsx +0 -59
  107. package/src/components/InternalPopover/index.tsx +0 -303
  108. package/src/components/KeyValueTable/index.tsx +0 -192
  109. package/src/components/Label/index.tsx +0 -10
  110. package/src/components/Layout/content.tsx +0 -31
  111. package/src/components/Layout/index.tsx +0 -55
  112. package/src/components/Menu/divider.tsx +0 -92
  113. package/src/components/Menu/index.tsx +0 -141
  114. package/src/components/Menu/item.tsx +0 -137
  115. package/src/components/Menu/section.tsx +0 -81
  116. package/src/components/Message/index.tsx +0 -220
  117. package/src/components/Modal/index.tsx +0 -26
  118. package/src/components/MultiSelect/index.tsx +0 -288
  119. package/src/components/Navbar/divider.tsx +0 -50
  120. package/src/components/Navbar/group.tsx +0 -53
  121. package/src/components/Navbar/index.tsx +0 -82
  122. package/src/components/Navbar/item.tsx +0 -92
  123. package/src/components/Notifications/index.tsx +0 -57
  124. package/src/components/Notifications/notification.tsx +0 -362
  125. package/src/components/Paging/index.tsx +0 -321
  126. package/src/components/Panel/LabelEditor.tsx +0 -67
  127. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  128. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  129. package/src/components/Panel/index.tsx +0 -912
  130. package/src/components/Panel/panel.screenshot.tsx +0 -29
  131. package/src/components/Paragraph/index.tsx +0 -43
  132. package/src/components/Popover/index.tsx +0 -68
  133. package/src/components/RadioGroup/index.tsx +0 -71
  134. package/src/components/Slider/index.tsx +0 -358
  135. package/src/components/Spacer/index.tsx +0 -142
  136. package/src/components/Spinner/index.tsx +0 -74
  137. package/src/components/Table/body.tsx +0 -109
  138. package/src/components/Table/cell.tsx +0 -136
  139. package/src/components/Table/header.tsx +0 -236
  140. package/src/components/Table/headerCell.tsx +0 -203
  141. package/src/components/Table/helpers.ts +0 -308
  142. package/src/components/Table/index.tsx +0 -797
  143. package/src/components/Table/row.tsx +0 -288
  144. package/src/components/Table/value.tsx +0 -28
  145. package/src/components/Tabs/content.tsx +0 -68
  146. package/src/components/Tabs/index.tsx +0 -124
  147. package/src/components/Tabs/item.tsx +0 -198
  148. package/src/components/Tabs/list.tsx +0 -381
  149. package/src/components/Tag/group.tsx +0 -73
  150. package/src/components/Tag/index.tsx +0 -463
  151. package/src/components/Textarea/index.tsx +0 -277
  152. package/src/components/TimeAgo/index.tsx +0 -15
  153. package/src/components/Tree/index.tsx +0 -271
  154. package/src/constants/animations.ts +0 -9
  155. package/src/constants/colors.ts +0 -13
  156. package/src/constants/paging.ts +0 -93
  157. package/src/constants/sizes.ts +0 -185
  158. package/src/constants/theme.ts +0 -122
  159. package/src/containers/Paging.tsx +0 -136
  160. package/src/containers/PopoverProvider.tsx +0 -124
  161. package/src/containers/ReqoreProvider.tsx +0 -289
  162. package/src/containers/ThemeProvider.tsx +0 -12
  163. package/src/containers/UIProvider.tsx +0 -101
  164. package/src/context/PopoverContext.tsx +0 -11
  165. package/src/context/ReqoreContext.tsx +0 -47
  166. package/src/context/ThemeContext.tsx +0 -4
  167. package/src/helpers/animations.ts +0 -13
  168. package/src/helpers/colors.ts +0 -335
  169. package/src/helpers/time.ts +0 -21
  170. package/src/helpers/utils.ts +0 -152
  171. package/src/hooks/useAutoFocus.ts +0 -106
  172. package/src/hooks/useCloneThroughFragments.ts +0 -39
  173. package/src/hooks/useCombinedRefs.ts +0 -26
  174. package/src/hooks/useLatestZIndex.ts +0 -13
  175. package/src/hooks/useOutsideClick.ts +0 -29
  176. package/src/hooks/usePaging.ts +0 -128
  177. package/src/hooks/usePopover.tsx +0 -220
  178. package/src/hooks/useQueryWithDelay.ts +0 -30
  179. package/src/hooks/useReqore.ts +0 -12
  180. package/src/hooks/useReqoreContext.ts +0 -16
  181. package/src/hooks/useReqoreEffect.ts +0 -49
  182. package/src/hooks/useTextareaAutoSize.ts +0 -22
  183. package/src/hooks/useTheme.ts +0 -48
  184. package/src/hooks/useTooltip.ts +0 -40
  185. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  186. package/src/icons.json +0 -2295
  187. package/src/index.tsx +0 -79
  188. package/src/mock/breadcrumbs.ts +0 -146
  189. package/src/mock/collectionData.tsx +0 -380
  190. package/src/mock/data.json +0 -11000
  191. package/src/mock/icons.ts +0 -32
  192. package/src/mock/menu.ts +0 -93
  193. package/src/mock/multiSelect.ts +0 -71
  194. package/src/mock/object.json +0 -317
  195. package/src/mock/styleMock.js +0 -1
  196. package/src/mock/tableData.ts +0 -64
  197. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  198. package/src/stories/Button/Button.stories.tsx +0 -405
  199. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  200. package/src/stories/Collection/Collection.stories.tsx +0 -317
  201. package/src/stories/Columns/Columns.stories.tsx +0 -158
  202. package/src/stories/Comment/Comment.stories.tsx +0 -136
  203. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  204. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  205. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  206. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  207. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  208. package/src/stories/Header/Header.stories.tsx +0 -108
  209. package/src/stories/Icon/Icon.stories.tsx +0 -162
  210. package/src/stories/Input/Input.stories.tsx +0 -220
  211. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  212. package/src/stories/Label/Label.stories.tsx +0 -33
  213. package/src/stories/Menu/Menu.stories.tsx +0 -367
  214. package/src/stories/Message/Message.stories.tsx +0 -167
  215. package/src/stories/Modal/Manager.stories.tsx +0 -192
  216. package/src/stories/Modal/Modal.stories.tsx +0 -252
  217. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  218. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  219. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  220. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  221. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  222. package/src/stories/Paging/Paging.stories.tsx +0 -255
  223. package/src/stories/Panel/Panel.stories.tsx +0 -753
  224. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  225. package/src/stories/Popover/Popover.stories.tsx +0 -510
  226. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  227. package/src/stories/Slider/Slider.stories.tsx +0 -173
  228. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  229. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  230. package/src/stories/Table/Table.stories.tsx +0 -571
  231. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  232. package/src/stories/Tag/Tag.stories.tsx +0 -381
  233. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  234. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  235. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  236. package/src/stories/Tree/Tree.stories.tsx +0 -124
  237. package/src/stories/Wrapper.tsx +0 -13
  238. package/src/stories/utils/args.ts +0 -151
  239. package/src/stories/utils.ts +0 -39
  240. package/src/styles.ts +0 -124
  241. package/src/types/global.ts +0 -211
  242. package/src/types/icons.ts +0 -2272
  243. 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;