@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,426 +0,0 @@
1
- import { map, size } from 'lodash';
2
- import { useCallback, useMemo, useState } from 'react';
3
- import { useUpdateEffect } from 'react-use';
4
- import styled, { css } from 'styled-components';
5
- import { useReqoreProperty } from '../..';
6
- import { TReqorePaginationType } from '../../constants/paging';
7
- import { PADDING_FROM_SIZE } from '../../constants/sizes';
8
- import { ReqorePaginationContainer } from '../../containers/Paging';
9
- import { useQueryWithDelay } from '../../hooks/useQueryWithDelay';
10
- import { IReqoreIconName } from '../../types/icons';
11
- import { IReqoreColumnsProps, StyledColumns } from '../Columns';
12
- import ReqoreControlGroup from '../ControlGroup';
13
- import ReqoreInput, { IReqoreInputProps } from '../Input';
14
- import ReqoreMessage from '../Message';
15
- import {
16
- IReqorePanelAction,
17
- IReqorePanelProps,
18
- IReqorePanelSubAction,
19
- ReqorePanel,
20
- TReqorePanelActions,
21
- } from '../Panel';
22
- import { ReqoreVerticalSpacer } from '../Spacer';
23
- import { getZoomActions, sizeToZoom, sortTableData, zoomToSize } from '../Table/helpers';
24
- import { IReqoreCollectionItemProps, ReqoreCollectionItem } from './item';
25
-
26
- export interface IReqoreCollectionProps extends IReqorePanelProps, IReqoreColumnsProps {
27
- items?: IReqoreCollectionItemProps[];
28
- inputProps?: IReqoreInputProps;
29
- inputInTitle?: boolean;
30
-
31
- sortButtonProps?: IReqorePanelAction;
32
- displayButtonProps?: IReqorePanelAction;
33
- stacked?: boolean;
34
- rounded?: boolean;
35
- height?: string;
36
- fill?: boolean;
37
- maxItemHeight?: number;
38
-
39
- defaultQuery?: string;
40
- defaultZoom?: 0 | 0.5 | 1 | 1.5 | 2;
41
- defaultSort?: 'asc' | 'desc';
42
- defaultSortBy?: string;
43
-
44
- sortKeys?: Record<string, string>;
45
-
46
- filterable?: boolean;
47
- sortable?: boolean;
48
- zoomable?: boolean;
49
-
50
- showAs?: 'list' | 'grid';
51
- showSelectedFirst?: boolean;
52
- selectedIcon?: IReqoreIconName;
53
- searchDelay?: number;
54
-
55
- contentRenderer?: (
56
- children: React.ReactNode,
57
- items: IReqoreCollectionItemProps[],
58
- searchInput?: React.ReactNode
59
- ) => React.ReactNode;
60
-
61
- onQueryChange?: (query: string | number) => void;
62
-
63
- emptyMessage?: string;
64
- sortButtonTooltip?: (sort?: 'asc' | 'desc') => string;
65
- displayButtonTooltip?: (display?: 'list' | 'grid') => string;
66
- inputPlaceholder?: (items?: IReqoreCollectionItemProps[]) => string;
67
-
68
- paging?: TReqorePaginationType<IReqoreCollectionItemProps>;
69
- }
70
-
71
- export const StyledCollectionWrapper = styled(StyledColumns)`
72
- height: ${({ height }) => (height ? `${height}` : 'auto')};
73
- flex: ${({ fill }) => (fill ? 1 : undefined)};
74
-
75
- ${({ rounded, stacked }: IReqoreCollectionProps) =>
76
- (!rounded || stacked) &&
77
- css`
78
- border-radius: ${stacked && rounded ? '10px' : undefined};
79
- `}
80
-
81
- overflow: auto;
82
- position: relative;
83
- `;
84
-
85
- export const zoomToWidth = {
86
- 0: '200px',
87
- 0.5: '300px',
88
- 1: '400px',
89
- 1.5: '500px',
90
- 2: '600px',
91
- };
92
-
93
- export const ReqoreCollection = ({
94
- items,
95
- stacked,
96
- rounded = true,
97
- fill,
98
- maxItemHeight,
99
- filterable,
100
- inputInTitle = true,
101
-
102
- sortable,
103
- zoomable,
104
-
105
- defaultZoom,
106
- showSelectedFirst,
107
- inputProps,
108
- sortButtonProps,
109
- displayButtonProps,
110
- headerSize = 2,
111
- showAs = 'grid',
112
- selectedIcon,
113
- flat = true,
114
- minimal,
115
- transparent = true,
116
-
117
- defaultQuery,
118
- defaultSort = 'asc',
119
- defaultSortBy = 'label',
120
-
121
- sortKeys = {},
122
-
123
- onQueryChange,
124
- contentRenderer = (children, _items, searchInput) => (
125
- <>
126
- {searchInput}
127
- {!!searchInput && <ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />}
128
- {children}
129
- </>
130
- ),
131
- searchDelay = 300,
132
- emptyMessage = 'No data in this collection, try changing your search query or filters',
133
- sortButtonTooltip = (sort) => (sort === 'desc' ? 'Sort ascending' : 'Sort descending'),
134
- displayButtonTooltip = (display) => (display === 'grid' ? 'Show as list' : 'Show as grid'),
135
- inputPlaceholder = (items) => `Search in ${size(items)} items`,
136
- paging,
137
- height,
138
-
139
- // Columns props
140
- minColumnWidth,
141
- maxColumnWidth,
142
- columns,
143
- alignItems,
144
- columnsGap = '10px',
145
-
146
- ...rest
147
- }: IReqoreCollectionProps) => {
148
- const [_showAs, setShowAs] = useState<'list' | 'grid'>(showAs);
149
- const [sort, setSort] = useState<'asc' | 'desc'>(defaultSort);
150
- const [sortBy, setSortBy] = useState<string>(defaultSortBy);
151
- const [contentRef, setContentRef] = useState<HTMLDivElement>(undefined);
152
- const isMobile = useReqoreProperty('isMobile');
153
- const [zoom, setZoom] = useState<number>(defaultZoom || sizeToZoom.normal);
154
-
155
- const { query, setQuery, preQuery, setPreQuery } = useQueryWithDelay(
156
- defaultQuery,
157
- searchDelay,
158
- onQueryChange
159
- );
160
-
161
- useUpdateEffect(() => {
162
- setShowAs(showAs);
163
- }, [showAs]);
164
-
165
- const sortedItems: IReqoreCollectionItemProps[] = useMemo(() => {
166
- if (!sortable) {
167
- return items;
168
- }
169
-
170
- const _sortBy = !!sortKeys[sortBy] ? (v) => v?.metadata?.[sortBy] : sortBy;
171
-
172
- if (showSelectedFirst) {
173
- // Filter out the selected items
174
- const selectedItems = items.filter((item) => item.selected);
175
- // Filter out the unselected items
176
- const unselectedItems = items.filter((item) => !item.selected);
177
- // Sort the selected items
178
- const sortedSelectedItems = sortTableData(selectedItems, {
179
- by: _sortBy,
180
- direction: sort,
181
- });
182
- // Sort the unselected items
183
- const sortedUnselectedItems = sortTableData(unselectedItems, {
184
- by: _sortBy,
185
- direction: sort,
186
- });
187
-
188
- return [...sortedSelectedItems, ...sortedUnselectedItems];
189
- }
190
-
191
- return sortTableData(items, {
192
- by: _sortBy,
193
- direction: sort,
194
- });
195
- }, [items, sort, sortBy, showSelectedFirst, sortable]);
196
-
197
- const filteredItems: IReqoreCollectionItemProps[] = useMemo(() => {
198
- if (!filterable || query === '') {
199
- return sortedItems;
200
- }
201
-
202
- return sortedItems.filter((item) => {
203
- const text = `${item.label}${item.content?.toString()}${item.expandedContent?.toString()}${
204
- item.searchString || ''
205
- }`;
206
-
207
- if (!text) {
208
- return false;
209
- }
210
-
211
- return text.toString().toLowerCase().indexOf(query.toLowerCase()) !== -1;
212
- });
213
- }, [items, query, sortedItems]);
214
-
215
- const handlePreQueryChange = (event: React.ChangeEvent<HTMLInputElement>) => {
216
- setPreQuery(event.target.value);
217
- };
218
-
219
- const finalActions: TReqorePanelActions = useMemo(() => {
220
- let actions: TReqorePanelActions = rest.actions ? [...rest.actions] : [];
221
-
222
- const toolbarGroup: IReqorePanelAction = {
223
- responsive: false,
224
- icon: 'MoreLine',
225
- className: 'reqore-collection-more',
226
- actions: [
227
- {
228
- icon: _showAs === 'grid' ? 'ListUnordered' : 'GridLine',
229
- onClick: () => setShowAs(_showAs === 'grid' ? 'list' : 'grid'),
230
- tooltip: displayButtonTooltip(_showAs),
231
- label: displayButtonTooltip(_showAs),
232
- disabled: !size(filteredItems),
233
- ...displayButtonProps,
234
- },
235
- ],
236
- };
237
-
238
- if (zoomable) {
239
- toolbarGroup.actions = [
240
- ...toolbarGroup.actions,
241
- { divider: true, line: true },
242
- ...getZoomActions('reqore-collection', zoom, setZoom, true),
243
- ];
244
- }
245
-
246
- if (filterable && inputInTitle) {
247
- actions = [
248
- ...actions,
249
- {
250
- as: ReqoreInput,
251
- props: {
252
- key: 'search',
253
- fixed: false,
254
- placeholder: inputPlaceholder(items),
255
- onClearClick: () => {
256
- setQuery('');
257
- setPreQuery('');
258
- },
259
- onChange: handlePreQueryChange,
260
- value: preQuery,
261
- icon: 'Search2Line',
262
- minimal: false,
263
- ...inputProps,
264
- },
265
- },
266
- ];
267
- }
268
-
269
- if (sortable) {
270
- const _sortKeys = {
271
- label: 'Label',
272
- intent: 'Intent',
273
- ...sortKeys,
274
- };
275
-
276
- actions.push({
277
- icon: sort === 'desc' ? 'SortDesc' : 'SortAsc',
278
- tooltip: sortButtonTooltip(sort),
279
- className: 'reqore-collection-sort',
280
- fixed: true,
281
- fluid: false,
282
- disabled: !size(filteredItems),
283
- actions: [
284
- {
285
- divider: true,
286
- label: 'Sort by',
287
- dividerAlign: 'left',
288
- minimal: true,
289
- dividerPadded: 'bottom',
290
- },
291
- ...map(
292
- _sortKeys,
293
- (label, key): IReqorePanelSubAction => ({
294
- label,
295
- selected: sortBy === key,
296
- onClick: () => {
297
- setSortBy(key);
298
- setSort(sort === 'desc' ? 'asc' : 'desc');
299
- },
300
- })
301
- ),
302
- ],
303
- ...sortButtonProps,
304
- });
305
- }
306
-
307
- return [...actions, toolbarGroup];
308
- }, [
309
- filterable,
310
- preQuery,
311
- query,
312
- rest.actions,
313
- _showAs,
314
- sort,
315
- sortable,
316
- filteredItems,
317
- isMobile,
318
- zoom,
319
- zoomable,
320
- ]);
321
-
322
- const renderContent = useCallback(() => {
323
- return contentRenderer(
324
- <>
325
- <ReqorePaginationContainer
326
- key='paging-container'
327
- items={filteredItems}
328
- type={paging}
329
- size={rest.size}
330
- scrollContainer={contentRef}
331
- >
332
- {(finalItems) => (
333
- <>
334
- {!size(finalItems) ? (
335
- <ReqoreMessage flat icon='Search2Line'>
336
- {emptyMessage}
337
- </ReqoreMessage>
338
- ) : (
339
- <StyledCollectionWrapper
340
- columns={columns || (_showAs === 'grid' ? 'auto-fit' : 1)}
341
- columnsGap={stacked ? '0px' : columnsGap}
342
- rounded={rounded}
343
- stacked={stacked}
344
- fill={fill}
345
- ref={setContentRef}
346
- height={height}
347
- alignItems={alignItems}
348
- minColumnWidth={minColumnWidth || zoomToWidth[zoom]}
349
- maxColumnWidth={maxColumnWidth}
350
- className='reqore-collection-content'
351
- >
352
- {finalItems?.map((item, index) => (
353
- <ReqoreCollectionItem
354
- size={zoomToSize[zoom]}
355
- responsiveTitle={false}
356
- {...item}
357
- icon={item.icon || (item.selected ? selectedIcon : undefined)}
358
- key={index}
359
- rounded={!stacked}
360
- maxContentHeight={maxItemHeight}
361
- />
362
- ))}
363
- </StyledCollectionWrapper>
364
- )}
365
- </>
366
- )}
367
- </ReqorePaginationContainer>
368
- </>,
369
- filteredItems,
370
- !inputInTitle && filterable ? (
371
- <ReqoreControlGroup>
372
- <ReqoreInput
373
- key='search'
374
- fixed={false}
375
- placeholder={inputPlaceholder(items)}
376
- onClearClick={() => {
377
- setQuery('');
378
- setPreQuery('');
379
- }}
380
- onChange={handlePreQueryChange}
381
- value={preQuery}
382
- icon='Search2Line'
383
- minimal={false}
384
- size={rest.size}
385
- {...inputProps}
386
- />
387
- </ReqoreControlGroup>
388
- ) : undefined
389
- );
390
- }, [
391
- contentRenderer,
392
- filteredItems,
393
- _showAs,
394
- columnsGap,
395
- emptyMessage,
396
- maxItemHeight,
397
- rest,
398
- rounded,
399
- selectedIcon,
400
- stacked,
401
- zoom,
402
- ]);
403
-
404
- return (
405
- <ReqorePanel
406
- {...rest}
407
- headerSize={headerSize}
408
- style={{
409
- ...rest.style,
410
- }}
411
- fill={fill}
412
- contentStyle={{
413
- overflow: fill ? 'hidden' : 'auto',
414
- display: 'flex',
415
- flexFlow: 'column',
416
- }}
417
- transparent={transparent}
418
- minimal={minimal}
419
- flat={flat}
420
- actions={finalActions}
421
- className={`reqore-collection ${rest.className || ''}`}
422
- >
423
- {renderContent()}
424
- </ReqorePanel>
425
- );
426
- };
@@ -1,267 +0,0 @@
1
- import { map, size } from 'lodash';
2
- import { rgba } from 'polished';
3
- import { useEffect, useRef, useState } from 'react';
4
- import { useDebounce, useMeasure } from 'react-use';
5
- import styled, { css } from 'styled-components';
6
- import { changeDarkness, getMainBackgroundColor } from '../../helpers/colors';
7
- import { useReqoreProperty } from '../../hooks/useReqoreContext';
8
- import { useReqoreTheme } from '../../hooks/useTheme';
9
- import { ReqoreBackdrop } from '../Drawer/backdrop';
10
- import {
11
- IReqorePanelAction,
12
- IReqorePanelBottomAction,
13
- IReqorePanelProps,
14
- ReqorePanel,
15
- } from '../Panel';
16
- import { ReqoreP } from '../Paragraph';
17
- import { ReqoreSpacer } from '../Spacer';
18
- import ReqoreTag, { IReqoreTagProps } from '../Tag';
19
- import ReqoreTagGroup from '../Tag/group';
20
-
21
- export interface IReqoreCollectionItemProps
22
- extends Omit<
23
- IReqorePanelProps,
24
- | 'children'
25
- | 'actions'
26
- | 'collapsible'
27
- | 'onCollapseChange'
28
- | 'isCollapsed'
29
- | 'unMountContentOnCollapse'
30
- | 'bottomActions'
31
- | 'content'
32
- > {
33
- selected?: boolean;
34
- content?: string | number | React.ReactNode;
35
- expandable?: boolean;
36
- expandedContent?: string | React.ReactNode;
37
- expandedActions?: IReqorePanelBottomAction[];
38
- image?: string;
39
- actions?: IReqorePanelAction[];
40
- tags?: IReqoreTagProps[];
41
- maxContentHeight?: number;
42
- showContentFade?: boolean;
43
- searchString?: string;
44
- // Used for passing values and sorting
45
- metadata?: Record<string, any>;
46
- }
47
-
48
- export const StyledCollectionItemContent = styled.div`
49
- max-height: ${({ providedHeight }) => (providedHeight ? `${providedHeight}px` : 'auto')};
50
- overflow: ${({ isSelected }) => (isSelected ? 'auto' : 'hidden')};
51
- position: relative;
52
- transition: 0.3s ease-in-out;
53
- flex: 1;
54
-
55
- ${({ contentOverflows, theme, opacity = 1 }) =>
56
- contentOverflows &&
57
- css`
58
- &:after {
59
- content: '';
60
- position: absolute;
61
- bottom: 0;
62
- left: 0;
63
- right: 0;
64
- height: 100px;
65
- transition: 0.3s ease-in-out;
66
- background: linear-gradient(
67
- to top,
68
- ${rgba(changeDarkness(getMainBackgroundColor(theme), 0.03), opacity)} 0%,
69
- transparent 100%
70
- );
71
- }
72
- `}
73
- `;
74
-
75
- export const ReqoreCollectionItem = ({
76
- flat = true,
77
- minimal = true,
78
- style,
79
- content,
80
- actions,
81
- tags,
82
- expandable,
83
- expandedContent,
84
- expandedActions,
85
- maxContentHeight,
86
- showContentFade = true,
87
- ...rest
88
- }: IReqoreCollectionItemProps) => {
89
- const [isSelected, setIsSelected] = useState(false);
90
- const getAndIncreaseZIndex = useReqoreProperty('getAndIncreaseZIndex');
91
- const ref = useRef<HTMLDivElement>(null);
92
- const [contentRef, sizes] = useMeasure();
93
- const originalDimensions = useRef(null);
94
- const [position, setPosition] = useState(undefined);
95
- const theme = useReqoreTheme('main', rest.customTheme);
96
- const [dimensions, setDimensions] = useState<any>({
97
- minWidth: undefined,
98
- minHeight: undefined,
99
- maxWidth: undefined,
100
- maxHeight: undefined,
101
- width: undefined,
102
- height: undefined,
103
- left: undefined,
104
- top: undefined,
105
- transform: undefined,
106
- });
107
-
108
- useEffect(() => {
109
- if (isSelected) {
110
- setPosition('fixed');
111
- }
112
- }, [isSelected]);
113
-
114
- useDebounce(
115
- () => {
116
- if (isSelected) {
117
- setDimensions({
118
- ...dimensions,
119
- width: undefined,
120
- height: undefined,
121
- left: '50%',
122
- minWidth: '500px',
123
- minHeight: '300px',
124
- maxWidth: '90vw',
125
- maxHeight: '90vh',
126
- top: '50%',
127
- transform: 'translateX(-50%) translateY(-50%)',
128
- });
129
- }
130
- },
131
- 100,
132
- [isSelected]
133
- );
134
-
135
- useDebounce(
136
- () => {
137
- if (!isSelected) {
138
- setPosition(undefined);
139
- setDimensions({
140
- minHeight: undefined,
141
- minWidth: undefined,
142
- maxWidth: undefined,
143
- maxHeight: undefined,
144
- left: undefined,
145
- top: undefined,
146
- transform: 'translateX(0) translateY(0)',
147
- });
148
- }
149
- },
150
- 220,
151
- [isSelected]
152
- );
153
-
154
- const renderContent = () => {
155
- const handleItemClick = (event?: any) => {
156
- if (expandable) {
157
- if (isSelected) {
158
- setDimensions(originalDimensions.current);
159
- } else {
160
- originalDimensions.current = {
161
- left: ref.current.getBoundingClientRect()?.left,
162
- top: ref.current.getBoundingClientRect()?.top,
163
- width: ref.current.getBoundingClientRect()?.width,
164
- height: ref.current.getBoundingClientRect()?.height,
165
- transform: 'translateX(0) translateY(0)',
166
- };
167
-
168
- setDimensions({
169
- left: ref.current.getBoundingClientRect()?.left,
170
- top: ref.current.getBoundingClientRect()?.top,
171
- width: ref.current.getBoundingClientRect()?.width,
172
- height: ref.current.getBoundingClientRect()?.height,
173
- transform: 'translateX(0) translateY(0)',
174
- });
175
- }
176
- setIsSelected(!isSelected);
177
- }
178
-
179
- rest.onClick?.(event);
180
- };
181
-
182
- const actualContent: string | React.ReactNode =
183
- expandedContent && isSelected ? expandedContent : content;
184
-
185
- const actualActions: IReqorePanelAction[] | undefined = isSelected
186
- ? ([
187
- ...(actions || []),
188
- { icon: 'CloseLine', onClick: handleItemClick },
189
- ] as IReqorePanelAction[])
190
- : size(actions)
191
- ? actions
192
- : undefined;
193
-
194
- return (
195
- <>
196
- {position && (
197
- <>
198
- <div style={{ ...originalDimensions.current }} />
199
- <ReqoreBackdrop
200
- zIndex={getAndIncreaseZIndex()}
201
- blur={5}
202
- onClose={() => handleItemClick()}
203
- />
204
- </>
205
- )}
206
- <ReqorePanel
207
- flat={flat}
208
- ref={ref}
209
- minimal={minimal}
210
- {...rest}
211
- responsiveActions={false}
212
- bottomActions={isSelected ? expandedActions : undefined}
213
- style={{
214
- ...style,
215
- position,
216
- zIndex: isSelected ? getAndIncreaseZIndex() : undefined,
217
- ...dimensions,
218
- transformOrigin: 'center',
219
- }}
220
- contentStyle={{
221
- ...rest.contentStyle,
222
- display: 'flex',
223
- flexFlow: 'column',
224
- justifyContent: 'space-between',
225
- }}
226
- onClick={(expandable && !isSelected) || rest.onClick ? handleItemClick : undefined}
227
- actions={actualActions}
228
- className={`reqore-collection-item ${rest.className || ''}`}
229
- >
230
- <StyledCollectionItemContent
231
- theme={theme}
232
- opacity={rest.transparent ? 0 : rest.opacity}
233
- providedHeight={isSelected ? undefined : maxContentHeight}
234
- isSelected={isSelected}
235
- contentOverflows={
236
- !rest.transparent &&
237
- !rest.contentEffect &&
238
- !isSelected &&
239
- sizes?.height > maxContentHeight &&
240
- showContentFade
241
- }
242
- >
243
- <div ref={contentRef}>{actualContent}</div>
244
- </StyledCollectionItemContent>
245
- {showContentFade &&
246
- (rest.contentEffect || rest.transparent) &&
247
- !isSelected &&
248
- sizes?.height > maxContentHeight ? (
249
- <ReqoreP>...</ReqoreP>
250
- ) : null}
251
- {size(tags) ? (
252
- <>
253
- <ReqoreSpacer height={10} />
254
- <ReqoreTagGroup size={isSelected ? 'normal' : 'small'}>
255
- {map(tags, (tagProps, index) => (
256
- <ReqoreTag key={index} {...tagProps} />
257
- ))}
258
- </ReqoreTagGroup>
259
- </>
260
- ) : null}
261
- </ReqorePanel>
262
- </>
263
- );
264
- };
265
-
266
- return renderContent();
267
- };
@@ -1,27 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
-
3
- export interface IReqoreColumnProps
4
- extends Pick<
5
- React.CSSProperties,
6
- 'alignItems' | 'justifyContent' | 'flexFlow' | 'flex' | 'flexShrink' | 'flexGrow'
7
- > {}
8
-
9
- export const ReqoreColumn = styled.div<IReqoreColumnProps>`
10
- ${({
11
- alignItems = 'flex-start',
12
- justifyContent,
13
- flex = '1 0 auto',
14
- flexFlow = 'row',
15
- flexGrow,
16
- flexShrink,
17
- }: IReqoreColumnProps) => css`
18
- display: flex;
19
- align-items: ${alignItems};
20
- justify-content: ${justifyContent};
21
- flex-flow: ${flexFlow};
22
- flex: ${flex};
23
- flex-grow: ${flexGrow};
24
- flex-shrink: ${flexShrink};
25
- overflow-x: hidden;
26
- `}
27
- `;