@qoretechnologies/reqore 0.44.0 → 0.46.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 (226) hide show
  1. package/dist/constants/theme.d.ts +8 -1
  2. package/dist/constants/theme.d.ts.map +1 -1
  3. package/dist/constants/theme.js +16 -2
  4. package/dist/constants/theme.js.map +1 -1
  5. package/package.json +1 -1
  6. package/tests.json +1 -1
  7. package/.eslintrc.js +0 -40
  8. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  9. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  10. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  11. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  12. package/.github/workflows/beta_release.yml +0 -100
  13. package/.github/workflows/tests.yml +0 -84
  14. package/.gitpod.yml +0 -11
  15. package/.jest-test-results.json +0 -1
  16. package/.prettierrc +0 -7
  17. package/.vscode/settings.json +0 -0
  18. package/__tests__/breadcrumbs.test.tsx +0 -75
  19. package/__tests__/button.test.tsx +0 -218
  20. package/__tests__/checkbox.test.tsx +0 -45
  21. package/__tests__/collection.test.tsx +0 -243
  22. package/__tests__/containers/paging.test.tsx +0 -138
  23. package/__tests__/control_group.test.tsx +0 -32
  24. package/__tests__/drawer.test.tsx +0 -140
  25. package/__tests__/dropdown.test.tsx +0 -381
  26. package/__tests__/effect.test.tsx +0 -70
  27. package/__tests__/heading.test.tsx +0 -58
  28. package/__tests__/helpers/colors.test.tsx +0 -18
  29. package/__tests__/helpers/table.test.tsx +0 -67
  30. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  31. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  32. package/__tests__/hooks/useTheme.test.tsx +0 -31
  33. package/__tests__/icon.test.tsx +0 -53
  34. package/__tests__/input.test.tsx +0 -482
  35. package/__tests__/layout.test.tsx +0 -37
  36. package/__tests__/menu.test.tsx +0 -65
  37. package/__tests__/messages.test.tsx +0 -79
  38. package/__tests__/modal.test.tsx +0 -204
  39. package/__tests__/multiselect.test.tsx +0 -458
  40. package/__tests__/navbar.test.tsx +0 -31
  41. package/__tests__/notifications.test.tsx +0 -178
  42. package/__tests__/pagination.test.tsx +0 -437
  43. package/__tests__/panel.test.tsx +0 -243
  44. package/__tests__/popover.test.tsx +0 -282
  45. package/__tests__/radiogroup.test.tsx +0 -47
  46. package/__tests__/setup.js +0 -8
  47. package/__tests__/stories/Collection.stories.tsx +0 -0
  48. package/__tests__/table.test.tsx +0 -647
  49. package/__tests__/tabs.test.tsx +0 -321
  50. package/__tests__/tag.test.tsx +0 -160
  51. package/__tests__/textarea.test.tsx +0 -467
  52. package/__tests__/timeAgo.test.tsx +0 -27
  53. package/__tests__/tree.test.tsx +0 -58
  54. package/build-storybook.log +0 -491
  55. package/chromatic.config.json +0 -1
  56. package/icons.ts +0 -1
  57. package/migration-storybook.log +0 -56
  58. package/public/logo-dark.png +0 -0
  59. package/public/logo.png +0 -0
  60. package/public/q-symbol-small.png +0 -0
  61. package/public/q-symbol.png +0 -0
  62. package/public/qoreLogo-dark.png +0 -0
  63. package/public/qoreLogo.png +0 -0
  64. package/src/components/Breadcrumbs/index.tsx +0 -254
  65. package/src/components/Breadcrumbs/item.tsx +0 -44
  66. package/src/components/Button/index.tsx +0 -633
  67. package/src/components/Checkbox/index.tsx +0 -388
  68. package/src/components/Collection/index.tsx +0 -426
  69. package/src/components/Collection/item.tsx +0 -267
  70. package/src/components/Columns/column.tsx +0 -27
  71. package/src/components/Columns/index.tsx +0 -41
  72. package/src/components/Comment/index.tsx +0 -141
  73. package/src/components/CommentFeed/index.tsx +0 -34
  74. package/src/components/Content/index.tsx +0 -34
  75. package/src/components/Content/wrapper.tsx +0 -36
  76. package/src/components/ControlGroup/index.tsx +0 -523
  77. package/src/components/DatePicker/index.tsx +0 -347
  78. package/src/components/Drawer/backdrop.tsx +0 -54
  79. package/src/components/Drawer/index.tsx +0 -365
  80. package/src/components/Dropdown/index.tsx +0 -153
  81. package/src/components/Dropdown/item.tsx +0 -33
  82. package/src/components/Dropdown/list.tsx +0 -222
  83. package/src/components/Effect/index.tsx +0 -464
  84. package/src/components/ExportModal/index.tsx +0 -99
  85. package/src/components/Header/index.tsx +0 -81
  86. package/src/components/Icon/index.tsx +0 -184
  87. package/src/components/Input/index.tsx +0 -295
  88. package/src/components/InputClearButton/index.tsx +0 -59
  89. package/src/components/InternalPopover/index.tsx +0 -303
  90. package/src/components/KeyValueTable/index.tsx +0 -192
  91. package/src/components/Label/index.tsx +0 -10
  92. package/src/components/Layout/content.tsx +0 -31
  93. package/src/components/Layout/index.tsx +0 -55
  94. package/src/components/Menu/divider.tsx +0 -92
  95. package/src/components/Menu/index.tsx +0 -141
  96. package/src/components/Menu/item.tsx +0 -137
  97. package/src/components/Menu/section.tsx +0 -81
  98. package/src/components/Message/index.tsx +0 -220
  99. package/src/components/Modal/index.tsx +0 -26
  100. package/src/components/MultiSelect/index.tsx +0 -288
  101. package/src/components/Navbar/divider.tsx +0 -50
  102. package/src/components/Navbar/group.tsx +0 -53
  103. package/src/components/Navbar/index.tsx +0 -82
  104. package/src/components/Navbar/item.tsx +0 -92
  105. package/src/components/Notifications/index.tsx +0 -57
  106. package/src/components/Notifications/notification.tsx +0 -362
  107. package/src/components/Paging/index.tsx +0 -321
  108. package/src/components/Panel/LabelEditor.tsx +0 -67
  109. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  110. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  111. package/src/components/Panel/index.tsx +0 -912
  112. package/src/components/Panel/panel.screenshot.tsx +0 -29
  113. package/src/components/Paragraph/index.tsx +0 -43
  114. package/src/components/Popover/index.tsx +0 -68
  115. package/src/components/RadioGroup/index.tsx +0 -71
  116. package/src/components/Slider/index.tsx +0 -358
  117. package/src/components/Spacer/index.tsx +0 -142
  118. package/src/components/Spinner/index.tsx +0 -74
  119. package/src/components/Table/body.tsx +0 -109
  120. package/src/components/Table/cell.tsx +0 -136
  121. package/src/components/Table/header.tsx +0 -236
  122. package/src/components/Table/headerCell.tsx +0 -203
  123. package/src/components/Table/helpers.ts +0 -308
  124. package/src/components/Table/index.tsx +0 -797
  125. package/src/components/Table/row.tsx +0 -288
  126. package/src/components/Table/value.tsx +0 -28
  127. package/src/components/Tabs/content.tsx +0 -68
  128. package/src/components/Tabs/index.tsx +0 -124
  129. package/src/components/Tabs/item.tsx +0 -198
  130. package/src/components/Tabs/list.tsx +0 -381
  131. package/src/components/Tag/group.tsx +0 -73
  132. package/src/components/Tag/index.tsx +0 -463
  133. package/src/components/Textarea/index.tsx +0 -277
  134. package/src/components/TimeAgo/index.tsx +0 -15
  135. package/src/components/Tree/index.tsx +0 -271
  136. package/src/constants/animations.ts +0 -9
  137. package/src/constants/colors.ts +0 -13
  138. package/src/constants/paging.ts +0 -93
  139. package/src/constants/sizes.ts +0 -185
  140. package/src/constants/theme.ts +0 -122
  141. package/src/containers/Paging.tsx +0 -136
  142. package/src/containers/PopoverProvider.tsx +0 -124
  143. package/src/containers/ReqoreProvider.tsx +0 -289
  144. package/src/containers/ThemeProvider.tsx +0 -12
  145. package/src/containers/UIProvider.tsx +0 -101
  146. package/src/context/PopoverContext.tsx +0 -11
  147. package/src/context/ReqoreContext.tsx +0 -47
  148. package/src/context/ThemeContext.tsx +0 -4
  149. package/src/helpers/animations.ts +0 -13
  150. package/src/helpers/colors.ts +0 -335
  151. package/src/helpers/time.ts +0 -21
  152. package/src/helpers/utils.ts +0 -152
  153. package/src/hooks/useAutoFocus.ts +0 -106
  154. package/src/hooks/useCloneThroughFragments.ts +0 -39
  155. package/src/hooks/useCombinedRefs.ts +0 -26
  156. package/src/hooks/useLatestZIndex.ts +0 -13
  157. package/src/hooks/useOutsideClick.ts +0 -29
  158. package/src/hooks/usePaging.ts +0 -128
  159. package/src/hooks/usePopover.tsx +0 -220
  160. package/src/hooks/useQueryWithDelay.ts +0 -30
  161. package/src/hooks/useReqore.ts +0 -12
  162. package/src/hooks/useReqoreContext.ts +0 -16
  163. package/src/hooks/useReqoreEffect.ts +0 -49
  164. package/src/hooks/useTextareaAutoSize.ts +0 -22
  165. package/src/hooks/useTheme.ts +0 -48
  166. package/src/hooks/useTooltip.ts +0 -40
  167. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  168. package/src/icons.json +0 -2295
  169. package/src/index.tsx +0 -80
  170. package/src/mock/breadcrumbs.ts +0 -146
  171. package/src/mock/collectionData.tsx +0 -380
  172. package/src/mock/data.json +0 -11000
  173. package/src/mock/icons.ts +0 -32
  174. package/src/mock/menu.ts +0 -93
  175. package/src/mock/multiSelect.ts +0 -71
  176. package/src/mock/object.json +0 -317
  177. package/src/mock/styleMock.js +0 -1
  178. package/src/mock/tableData.ts +0 -64
  179. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  180. package/src/stories/Button/Button.stories.tsx +0 -405
  181. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  182. package/src/stories/Collection/Collection.stories.tsx +0 -317
  183. package/src/stories/Columns/Columns.stories.tsx +0 -158
  184. package/src/stories/Comment/Comment.stories.tsx +0 -136
  185. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  186. package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
  187. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  188. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  189. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  190. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  191. package/src/stories/Header/Header.stories.tsx +0 -108
  192. package/src/stories/Icon/Icon.stories.tsx +0 -162
  193. package/src/stories/Input/Input.stories.tsx +0 -220
  194. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  195. package/src/stories/Label/Label.stories.tsx +0 -33
  196. package/src/stories/Menu/Menu.stories.tsx +0 -367
  197. package/src/stories/Message/Message.stories.tsx +0 -167
  198. package/src/stories/Modal/Manager.stories.tsx +0 -192
  199. package/src/stories/Modal/Modal.stories.tsx +0 -252
  200. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  201. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  202. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  203. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  204. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  205. package/src/stories/Paging/Paging.stories.tsx +0 -255
  206. package/src/stories/Panel/Panel.stories.tsx +0 -753
  207. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  208. package/src/stories/Popover/Popover.stories.tsx +0 -510
  209. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  210. package/src/stories/Slider/Slider.stories.tsx +0 -173
  211. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  212. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  213. package/src/stories/Table/Table.stories.tsx +0 -571
  214. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  215. package/src/stories/Tag/Tag.stories.tsx +0 -381
  216. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  217. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  218. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  219. package/src/stories/Tree/Tree.stories.tsx +0 -124
  220. package/src/stories/Wrapper.tsx +0 -13
  221. package/src/stories/utils/args.ts +0 -151
  222. package/src/stories/utils.ts +0 -39
  223. package/src/styles.ts +0 -124
  224. package/src/types/global.ts +0 -211
  225. package/src/types/icons.ts +0 -2272
  226. package/tsconfig.prod.json +0 -26
@@ -1,185 +0,0 @@
1
- export type TSizes = 'tiny' | 'small' | 'normal' | 'big' | 'huge';
2
- export type TWeights = 'soft' | 'normal' | 'heavy';
3
-
4
- export const ReqoreSizes = {
5
- TINY: 'tiny',
6
- SMALL: 'small',
7
- NORMAL: 'normal',
8
- BIG: 'big',
9
- HUGE: 'huge',
10
- };
11
-
12
- export const SIZES = ['tiny', 'small', 'normal', 'big', 'huge'] as const;
13
-
14
- export const SIZE_TO_MODIFIER = {
15
- tiny: 0.6,
16
- small: 0.8,
17
- normal: 1,
18
- big: 1.2,
19
- huge: 1.4,
20
- };
21
-
22
- export const LINE_SIZE_TO_NUMBER = {
23
- none: 0,
24
- tiny: 1,
25
- small: 1,
26
- normal: 1.5,
27
- big: 2,
28
- huge: 3,
29
- };
30
-
31
- export const SIZE_TO_NUMBER = {
32
- none: 0,
33
- tiny: 1,
34
- small: 2,
35
- normal: 3,
36
- big: 4,
37
- huge: 5,
38
- };
39
-
40
- export const NUMBER_TO_SIZE = {
41
- 1: 'tiny',
42
- 2: 'small',
43
- 3: 'normal',
44
- 4: 'big',
45
- 5: 'huge',
46
- };
47
-
48
- export const HEADER_SIZE_TO_NUMBER = {
49
- tiny: 5,
50
- small: 4,
51
- normal: 3,
52
- big: 2,
53
- huge: 1,
54
- };
55
-
56
- export const SIZE_TO_PX = {
57
- tiny: 18,
58
- small: 24,
59
- normal: 30,
60
- big: 40,
61
- huge: 50,
62
- };
63
-
64
- export const BADGE_SIZE_TO_PX = {
65
- tiny: 14,
66
- small: 20,
67
- normal: 26,
68
- big: 32,
69
- huge: 38,
70
- };
71
-
72
- export const TABS_SIZE_TO_PX = {
73
- tiny: 20,
74
- small: 30,
75
- normal: 40,
76
- big: 50,
77
- huge: 60,
78
- };
79
-
80
- export const TABLE_SIZE_TO_PX = {
81
- tiny: 20,
82
- small: 30,
83
- normal: 40,
84
- big: 50,
85
- huge: 60,
86
- };
87
-
88
- export const TABS_PADDING_TO_PX = {
89
- tiny: 5,
90
- small: 5,
91
- normal: 5,
92
- big: 5,
93
- huge: 5,
94
- };
95
-
96
- export const MARGIN_FROM_SIZE = {
97
- tiny: 0,
98
- small: 0,
99
- normal: 10,
100
- big: 20,
101
- huge: 30,
102
- };
103
-
104
- export const TEXT_FROM_SIZE = {
105
- tiny: 9,
106
- small: 12,
107
- normal: 15,
108
- big: 18,
109
- huge: 21,
110
- };
111
-
112
- export const CONTROL_TEXT_FROM_SIZE = {
113
- tiny: 7,
114
- small: 10,
115
- normal: 13,
116
- big: 16,
117
- huge: 19,
118
- };
119
-
120
- export const ICON_FROM_SIZE = {
121
- tiny: 13,
122
- small: 17,
123
- normal: 20,
124
- big: 26,
125
- huge: 33,
126
- };
127
-
128
- export const HALF_PADDING_FROM_SIZE = {
129
- tiny: 2,
130
- small: 4,
131
- normal: 5,
132
- big: 7,
133
- huge: 9,
134
- };
135
-
136
- export const PADDING_FROM_SIZE = {
137
- tiny: 5,
138
- small: 8,
139
- normal: 11,
140
- big: 14,
141
- huge: 17,
142
- };
143
-
144
- export const RADIUS_FROM_SIZE = {
145
- tiny: 4,
146
- small: 5,
147
- normal: 5.5,
148
- big: 7,
149
- huge: 9,
150
- };
151
-
152
- export const GAP_FROM_SIZE = {
153
- tiny: 1,
154
- small: 3,
155
- normal: 5,
156
- big: 18,
157
- huge: 30,
158
- };
159
-
160
- export const ICON_FROM_HEADER_SIZE = {
161
- 1: 23,
162
- 2: 20,
163
- 3: 17,
164
- 4: 14,
165
- 5: 11,
166
- 6: 8,
167
- };
168
-
169
- export const ICON_WRAPPER_FROM_HEADER_SIZE = {
170
- huge: 34,
171
- big: 26,
172
- normal: 19,
173
- small: 17,
174
- tiny: 15,
175
- };
176
-
177
- export const WEIGHT_TO_NUMBER = {
178
- thin: 100,
179
- light: 250,
180
- normal: 400,
181
- bold: 550,
182
- thick: 700,
183
- };
184
-
185
- export const PILL_RADIUS_MODIFIER = 2.5;
@@ -1,122 +0,0 @@
1
- import {
2
- TReqoreEffectColor,
3
- TReqoreEffectGradientAnimationTrigger,
4
- TReqoreHexColor,
5
- } from '../components/Effect';
6
- import { Colors } from './colors';
7
-
8
- export interface IReqoreSidebarTheme {
9
- main?: TReqoreHexColor;
10
- color?: TReqoreHexColor;
11
- border?: TReqoreHexColor;
12
- item?: {
13
- color?: TReqoreHexColor;
14
- background?: TReqoreHexColor;
15
- border?: TReqoreHexColor;
16
- hoverColor?: TReqoreHexColor;
17
- hoverBackground?: TReqoreHexColor;
18
- activeColor?: TReqoreHexColor;
19
- activeBackground?: TReqoreHexColor;
20
- };
21
- subItem?: {
22
- color?: TReqoreHexColor;
23
- border?: TReqoreHexColor;
24
- background?: TReqoreHexColor;
25
- hoverColor?: TReqoreHexColor;
26
- hoverBackground?: TReqoreHexColor;
27
- activeColor?: TReqoreHexColor;
28
- activeBackground?: TReqoreHexColor;
29
- };
30
- icon?: {
31
- color?: TReqoreHexColor;
32
- hoverColor?: TReqoreHexColor;
33
- activeColor?: TReqoreHexColor;
34
- };
35
- section?: {
36
- background?: TReqoreHexColor;
37
- };
38
- }
39
-
40
- export interface IReqoreBreadcrumbsTheme {
41
- main?: TReqoreHexColor;
42
- item?: {
43
- color?: TReqoreHexColor;
44
- hoverColor?: TReqoreHexColor;
45
- activeColor?: TReqoreHexColor;
46
- };
47
- }
48
-
49
- export interface IReqoreNavbarTheme {
50
- main?: TReqoreHexColor;
51
- color?: TReqoreHexColor;
52
- border?: TReqoreHexColor;
53
- background?: TReqoreHexColor;
54
- hoverColor?: TReqoreHexColor;
55
- }
56
-
57
- export interface IReqoreTheme {
58
- main: TReqoreHexColor;
59
- originalMain?: TReqoreHexColor;
60
- text?: {
61
- color?: TReqoreHexColor;
62
- dim?: boolean;
63
- };
64
- intents: IReqoreIntents;
65
- sidebar?: IReqoreSidebarTheme;
66
- notifications: IReqoreIntents;
67
- popover?: {
68
- main: TReqoreHexColor;
69
- };
70
- header?: IReqoreNavbarTheme;
71
- footer?: IReqoreNavbarTheme;
72
- breadcrumbs?: IReqoreBreadcrumbsTheme;
73
- buttons?: IReqoreCustomTheme;
74
- }
75
-
76
- export interface IReqoreCustomTheme {
77
- main?: TReqoreEffectColor;
78
- text?: {
79
- color?: TReqoreEffectColor;
80
- dim?: boolean;
81
- };
82
- gradient?: boolean;
83
- animate?: TReqoreEffectGradientAnimationTrigger;
84
- }
85
-
86
- export interface IReqoreIntents {
87
- info?: TReqoreHexColor;
88
- success?: TReqoreHexColor;
89
- pending?: TReqoreHexColor;
90
- warning?: TReqoreHexColor;
91
- danger?: TReqoreHexColor;
92
- muted?: TReqoreHexColor;
93
- }
94
-
95
- export type TReqoreIntent = 'info' | 'success' | 'pending' | 'warning' | 'danger' | 'muted';
96
-
97
- export const DEFAULT_INTENTS: IReqoreIntents = {
98
- info: Colors.BLUE,
99
- success: Colors.GREEN,
100
- pending: Colors.YELLOW,
101
- warning: Colors.ORANGE,
102
- danger: Colors.RED,
103
- muted: Colors.GRAY,
104
- };
105
-
106
- export const DEFAULT_THEME: IReqoreTheme = {
107
- main: Colors.DARK_THEME,
108
- text: {
109
- dim: true,
110
- },
111
- intents: DEFAULT_INTENTS,
112
- notifications: {},
113
- };
114
-
115
- export const ReqoreIntents: { [key: string]: TReqoreIntent } = {
116
- INFO: 'info',
117
- SUCCESS: 'success',
118
- PENDING: 'pending',
119
- WARNING: 'warning',
120
- DANGER: 'danger',
121
- MUTED: 'muted',
122
- };
@@ -1,136 +0,0 @@
1
- import { memo, useMemo } from 'react';
2
- import {
3
- IReqorePaginationComponentProps,
4
- IReqorePaginationProps,
5
- ReqorePagination,
6
- } from '../components/Paging';
7
- import { ReqoreVerticalSpacer } from '../components/Spacer';
8
- import {
9
- getPaginationOptionsFromType,
10
- TReqorePaginationType,
11
- TReqorePaginationTypeResult,
12
- } from '../constants/paging';
13
- import { PADDING_FROM_SIZE, TSizes } from '../constants/sizes';
14
- import { IReqorePagingResult, useReqorePaging } from '../hooks/usePaging';
15
-
16
- export interface IReqorePagingContainerProps<T> {
17
- type?: TReqorePaginationType<T>;
18
- items: T[];
19
- scrollContainer?: IReqorePaginationComponentProps['scrollContainer'];
20
- children: (
21
- items: T[],
22
- Controls: JSX.Element,
23
- options: TReqorePaginationTypeResult<T>
24
- ) => React.ReactNode;
25
- size?: TSizes;
26
- }
27
-
28
- function PagingControls<T>({
29
- withSpacer,
30
- position,
31
- pagingData,
32
- componentOptions,
33
- scrollContainer,
34
- size,
35
- ...pagingProps
36
- }: Partial<IReqorePaginationProps<T>> &
37
- Partial<TReqorePaginationTypeResult<T>> & {
38
- withSpacer?: boolean;
39
- position?: 'top' | 'bottom';
40
- pagingData: Omit<IReqorePagingResult<T>, 'items'>;
41
- }) {
42
- return pagingData.renderControls ? (
43
- <>
44
- {withSpacer && position === 'bottom' ? (
45
- <ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
46
- ) : null}
47
- <ReqorePagination
48
- key={`reqore-pagination-${position}`}
49
- size={size}
50
- {...pagingData}
51
- {...componentOptions}
52
- scrollContainer={scrollContainer}
53
- {...pagingProps}
54
- />
55
- {withSpacer && position === 'top' ? (
56
- <ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
57
- ) : null}
58
- </>
59
- ) : null;
60
- }
61
-
62
- function PagingContainer<T>({
63
- type,
64
- items,
65
- scrollContainer,
66
- children,
67
- size = 'normal',
68
- }: IReqorePagingContainerProps<T>) {
69
- const {
70
- pagingOptions = {},
71
- componentOptions = {},
72
- pageControlsPosition = 'bottom',
73
- includeTopControls = true,
74
- includeBottomControls = true,
75
- } = useMemo(() => getPaginationOptionsFromType(type), [type]);
76
-
77
- const { items: finalItems, ...pagingData } = useReqorePaging({
78
- items,
79
- ...pagingOptions,
80
- enabled: !!type,
81
- });
82
-
83
- return (
84
- <>
85
- {includeTopControls && (pageControlsPosition === 'top' || pageControlsPosition === 'both') ? (
86
- <PagingControls<T>
87
- key='top-paging'
88
- position='top'
89
- withSpacer
90
- scrollContainer={scrollContainer}
91
- size={size}
92
- pagingData={pagingData}
93
- pagingOptions={pagingOptions}
94
- componentOptions={componentOptions}
95
- autoLoadMore={false}
96
- scrollOnLoadMore={false}
97
- />
98
- ) : null}
99
-
100
- {children(
101
- finalItems,
102
- <PagingControls
103
- key='custom-paging'
104
- scrollContainer={scrollContainer}
105
- size={size}
106
- pagingData={pagingData}
107
- pagingOptions={pagingOptions}
108
- componentOptions={componentOptions}
109
- />,
110
- {
111
- pagingOptions,
112
- componentOptions,
113
- pageControlsPosition,
114
- includeTopControls,
115
- includeBottomControls,
116
- }
117
- )}
118
-
119
- {includeBottomControls &&
120
- (pageControlsPosition === 'bottom' || pageControlsPosition === 'both') ? (
121
- <PagingControls<T>
122
- key='bottom-paging'
123
- position='bottom'
124
- withSpacer
125
- scrollContainer={scrollContainer}
126
- size={size}
127
- pagingData={pagingData}
128
- pagingOptions={pagingOptions}
129
- componentOptions={componentOptions}
130
- />
131
- ) : null}
132
- </>
133
- );
134
- }
135
-
136
- export const ReqorePaginationContainer = memo(PagingContainer) as typeof PagingContainer;
@@ -1,124 +0,0 @@
1
- import { size } from 'lodash';
2
- import React, { MutableRefObject, useCallback, useEffect, useState } from 'react';
3
- import { useReqoreProperty } from '..';
4
- import Popover from '../components/InternalPopover';
5
- import PopoverContext from '../context/PopoverContext';
6
- import { IPopoverOptions } from '../hooks/usePopover';
7
-
8
- export interface IReqorePopoverProviderProps {
9
- children: any;
10
- uiScale?: number;
11
- }
12
-
13
- export interface IPopoverData extends IPopoverOptions {
14
- id: string;
15
- popperRef?: MutableRefObject<any>;
16
- }
17
-
18
- const PopoverProvider: React.FC<IReqorePopoverProviderProps> = ({ children, uiScale }) => {
19
- const [popovers, setPopovers] = useState<IPopoverData[]>([]);
20
- const closePopoversOnEscPress = useReqoreProperty('closePopoversOnEscPress');
21
-
22
- const handleClick = useCallback(
23
- (event: MouseEvent) => {
24
- popovers.forEach(({ popperRef, closeOnAnyClick, closeOnOutsideClick, id, targetElement }) => {
25
- if (closeOnAnyClick) {
26
- removePopover(id);
27
- return;
28
- }
29
-
30
- if (
31
- closeOnOutsideClick &&
32
- !(popperRef?.current && popperRef.current.contains(event.target)) &&
33
- !targetElement?.contains(event.target as Node)
34
- ) {
35
- removePopover(id);
36
- }
37
- });
38
- },
39
- [popovers]
40
- );
41
-
42
- // Close last popover when ESC is pressed
43
- const handleKeyDown = useCallback(
44
- (event: KeyboardEvent) => {
45
- if (event.key === 'Escape') {
46
- const lastPopover = popovers[popovers.length - 1];
47
-
48
- if (lastPopover) {
49
- removePopover(lastPopover.id);
50
- }
51
- }
52
- },
53
- [popovers]
54
- );
55
-
56
- const removePopover = (id: string) => {
57
- // Get the popover
58
- const popover = popovers.find((p) => p.id === id);
59
-
60
- if (popover) {
61
- // Remove the blur
62
- if (popover.blur) {
63
- // Remove the blur
64
- document.getElementById(`reqore-blur-${id}`)?.remove();
65
- // Remove the z index class
66
- popover.targetElement.classList.remove('reqore-blur-z-index');
67
- }
68
- // Remove the popover
69
- setPopovers((cur: IPopoverData[]) => [...cur].filter((p) => p.id !== id));
70
- }
71
- };
72
-
73
- useEffect(() => {
74
- document.addEventListener('click', handleClick, true);
75
-
76
- if (closePopoversOnEscPress) {
77
- document.addEventListener('keydown', handleKeyDown);
78
- }
79
-
80
- return () => {
81
- document.removeEventListener('click', handleClick, true);
82
- document.removeEventListener('keydown', handleKeyDown);
83
- };
84
- }, [popovers]);
85
-
86
- useEffect(() => {
87
- if (!size(popovers)) {
88
- document.removeEventListener('click', handleClick, true);
89
- document.removeEventListener('keydown', handleKeyDown);
90
- }
91
- }, [popovers]);
92
-
93
- return (
94
- <PopoverContext.Provider
95
- value={{
96
- uiScale,
97
- addPopover: (popoverData: IPopoverData) => {
98
- setPopovers((cur: IPopoverData[]) => [...cur, popoverData]);
99
- },
100
- updatePopover: (popoverId: string, popoverData: Partial<IPopoverData>) => {
101
- setPopovers((cur: IPopoverData[]) =>
102
- [...cur].reduce<IPopoverData[]>((newPopovers, popover) => {
103
- if (popover.id === popoverId) {
104
- return [...newPopovers, { ...popover, ...popoverData }];
105
- }
106
-
107
- return [...newPopovers, popover];
108
- }, [])
109
- );
110
- },
111
- isPopoverOpen: (popoverId: string) => !!popovers.find((p) => p.id === popoverId),
112
- removePopover,
113
- popovers,
114
- }}
115
- >
116
- {popovers.map((popover: IPopoverData) => (
117
- <Popover {...popover} key={popover.id} />
118
- ))}
119
- {children}
120
- </PopoverContext.Provider>
121
- );
122
- };
123
-
124
- export default PopoverProvider;