@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,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;