@qoretechnologies/reqore 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tests.json +1 -1
- package/.eslintrc.js +0 -40
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
- package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
- package/.github/workflows/beta_release.yml +0 -100
- package/.github/workflows/tests.yml +0 -84
- package/.gitpod.yml +0 -11
- package/.jest-test-results.json +0 -1
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -0
- package/__tests__/breadcrumbs.test.tsx +0 -75
- package/__tests__/button.test.tsx +0 -218
- package/__tests__/checkbox.test.tsx +0 -45
- package/__tests__/collection.test.tsx +0 -243
- package/__tests__/containers/paging.test.tsx +0 -138
- package/__tests__/control_group.test.tsx +0 -32
- package/__tests__/drawer.test.tsx +0 -140
- package/__tests__/dropdown.test.tsx +0 -381
- package/__tests__/effect.test.tsx +0 -70
- package/__tests__/heading.test.tsx +0 -58
- package/__tests__/helpers/colors.test.tsx +0 -18
- package/__tests__/helpers/table.test.tsx +0 -67
- package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
- package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
- package/__tests__/hooks/useTheme.test.tsx +0 -31
- package/__tests__/icon.test.tsx +0 -53
- package/__tests__/input.test.tsx +0 -482
- package/__tests__/layout.test.tsx +0 -37
- package/__tests__/menu.test.tsx +0 -65
- package/__tests__/messages.test.tsx +0 -79
- package/__tests__/modal.test.tsx +0 -204
- package/__tests__/multiselect.test.tsx +0 -458
- package/__tests__/navbar.test.tsx +0 -31
- package/__tests__/notifications.test.tsx +0 -178
- package/__tests__/pagination.test.tsx +0 -437
- package/__tests__/panel.test.tsx +0 -243
- package/__tests__/popover.test.tsx +0 -282
- package/__tests__/radiogroup.test.tsx +0 -47
- package/__tests__/setup.js +0 -8
- package/__tests__/stories/Collection.stories.tsx +0 -0
- package/__tests__/table.test.tsx +0 -647
- package/__tests__/tabs.test.tsx +0 -321
- package/__tests__/tag.test.tsx +0 -160
- package/__tests__/textarea.test.tsx +0 -467
- package/__tests__/timeAgo.test.tsx +0 -27
- package/__tests__/tree.test.tsx +0 -58
- package/build-storybook.log +0 -491
- package/chromatic.config.json +0 -1
- package/icons.ts +0 -1
- package/migration-storybook.log +0 -56
- package/public/logo-dark.png +0 -0
- package/public/logo.png +0 -0
- package/public/q-symbol-small.png +0 -0
- package/public/q-symbol.png +0 -0
- package/public/qoreLogo-dark.png +0 -0
- package/public/qoreLogo.png +0 -0
- package/src/components/Breadcrumbs/index.tsx +0 -254
- package/src/components/Breadcrumbs/item.tsx +0 -44
- package/src/components/Button/index.tsx +0 -633
- package/src/components/Checkbox/index.tsx +0 -388
- package/src/components/Collection/index.tsx +0 -426
- package/src/components/Collection/item.tsx +0 -267
- package/src/components/Columns/column.tsx +0 -27
- package/src/components/Columns/index.tsx +0 -41
- package/src/components/Comment/index.tsx +0 -141
- package/src/components/CommentFeed/index.tsx +0 -34
- package/src/components/Content/index.tsx +0 -34
- package/src/components/Content/wrapper.tsx +0 -36
- package/src/components/ControlGroup/index.tsx +0 -523
- package/src/components/DatePicker/index.tsx +0 -347
- package/src/components/Drawer/backdrop.tsx +0 -54
- package/src/components/Drawer/index.tsx +0 -365
- package/src/components/Dropdown/index.tsx +0 -153
- package/src/components/Dropdown/item.tsx +0 -33
- package/src/components/Dropdown/list.tsx +0 -222
- package/src/components/Effect/index.tsx +0 -464
- package/src/components/ExportModal/index.tsx +0 -99
- package/src/components/Header/index.tsx +0 -81
- package/src/components/Icon/index.tsx +0 -184
- package/src/components/Input/index.tsx +0 -295
- package/src/components/InputClearButton/index.tsx +0 -59
- package/src/components/InternalPopover/index.tsx +0 -303
- package/src/components/KeyValueTable/index.tsx +0 -192
- package/src/components/Label/index.tsx +0 -10
- package/src/components/Layout/content.tsx +0 -31
- package/src/components/Layout/index.tsx +0 -55
- package/src/components/Menu/divider.tsx +0 -92
- package/src/components/Menu/index.tsx +0 -141
- package/src/components/Menu/item.tsx +0 -137
- package/src/components/Menu/section.tsx +0 -81
- package/src/components/Message/index.tsx +0 -220
- package/src/components/Modal/index.tsx +0 -26
- package/src/components/MultiSelect/index.tsx +0 -288
- package/src/components/Navbar/divider.tsx +0 -50
- package/src/components/Navbar/group.tsx +0 -53
- package/src/components/Navbar/index.tsx +0 -82
- package/src/components/Navbar/item.tsx +0 -92
- package/src/components/Notifications/index.tsx +0 -57
- package/src/components/Notifications/notification.tsx +0 -362
- package/src/components/Paging/index.tsx +0 -321
- package/src/components/Panel/LabelEditor.tsx +0 -67
- package/src/components/Panel/NonResponsiveActions.tsx +0 -79
- package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
- package/src/components/Panel/index.tsx +0 -912
- package/src/components/Panel/panel.screenshot.tsx +0 -29
- package/src/components/Paragraph/index.tsx +0 -43
- package/src/components/Popover/index.tsx +0 -68
- package/src/components/RadioGroup/index.tsx +0 -71
- package/src/components/Slider/index.tsx +0 -358
- package/src/components/Spacer/index.tsx +0 -142
- package/src/components/Spinner/index.tsx +0 -74
- package/src/components/Table/body.tsx +0 -109
- package/src/components/Table/cell.tsx +0 -136
- package/src/components/Table/header.tsx +0 -236
- package/src/components/Table/headerCell.tsx +0 -203
- package/src/components/Table/helpers.ts +0 -308
- package/src/components/Table/index.tsx +0 -797
- package/src/components/Table/row.tsx +0 -288
- package/src/components/Table/value.tsx +0 -28
- package/src/components/Tabs/content.tsx +0 -68
- package/src/components/Tabs/index.tsx +0 -124
- package/src/components/Tabs/item.tsx +0 -198
- package/src/components/Tabs/list.tsx +0 -381
- package/src/components/Tag/group.tsx +0 -73
- package/src/components/Tag/index.tsx +0 -463
- package/src/components/Textarea/index.tsx +0 -277
- package/src/components/TimeAgo/index.tsx +0 -15
- package/src/components/Tree/index.tsx +0 -271
- package/src/constants/animations.ts +0 -9
- package/src/constants/colors.ts +0 -13
- package/src/constants/paging.ts +0 -93
- package/src/constants/sizes.ts +0 -185
- package/src/constants/theme.ts +0 -122
- package/src/containers/Paging.tsx +0 -136
- package/src/containers/PopoverProvider.tsx +0 -124
- package/src/containers/ReqoreProvider.tsx +0 -289
- package/src/containers/ThemeProvider.tsx +0 -12
- package/src/containers/UIProvider.tsx +0 -101
- package/src/context/PopoverContext.tsx +0 -11
- package/src/context/ReqoreContext.tsx +0 -47
- package/src/context/ThemeContext.tsx +0 -4
- package/src/helpers/animations.ts +0 -13
- package/src/helpers/colors.ts +0 -335
- package/src/helpers/time.ts +0 -21
- package/src/helpers/utils.ts +0 -152
- package/src/hooks/useAutoFocus.ts +0 -106
- package/src/hooks/useCloneThroughFragments.ts +0 -39
- package/src/hooks/useCombinedRefs.ts +0 -26
- package/src/hooks/useLatestZIndex.ts +0 -13
- package/src/hooks/useOutsideClick.ts +0 -29
- package/src/hooks/usePaging.ts +0 -128
- package/src/hooks/usePopover.tsx +0 -220
- package/src/hooks/useQueryWithDelay.ts +0 -30
- package/src/hooks/useReqore.ts +0 -12
- package/src/hooks/useReqoreContext.ts +0 -16
- package/src/hooks/useReqoreEffect.ts +0 -49
- package/src/hooks/useTextareaAutoSize.ts +0 -22
- package/src/hooks/useTheme.ts +0 -48
- package/src/hooks/useTooltip.ts +0 -40
- package/src/hooks/useWhyDidYouUpdate.ts +0 -32
- package/src/icons.json +0 -2295
- package/src/index.tsx +0 -80
- package/src/mock/breadcrumbs.ts +0 -146
- package/src/mock/collectionData.tsx +0 -380
- package/src/mock/data.json +0 -11000
- package/src/mock/icons.ts +0 -32
- package/src/mock/menu.ts +0 -93
- package/src/mock/multiSelect.ts +0 -71
- package/src/mock/object.json +0 -317
- package/src/mock/styleMock.js +0 -1
- package/src/mock/tableData.ts +0 -64
- package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
- package/src/stories/Button/Button.stories.tsx +0 -405
- package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
- package/src/stories/Collection/Collection.stories.tsx +0 -317
- package/src/stories/Columns/Columns.stories.tsx +0 -158
- package/src/stories/Comment/Comment.stories.tsx +0 -136
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
- package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
- package/src/stories/Drawer/Drawer.stories.tsx +0 -294
- package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
- package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
- package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
- package/src/stories/Header/Header.stories.tsx +0 -108
- package/src/stories/Icon/Icon.stories.tsx +0 -162
- package/src/stories/Input/Input.stories.tsx +0 -220
- package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
- package/src/stories/Label/Label.stories.tsx +0 -33
- package/src/stories/Menu/Menu.stories.tsx +0 -367
- package/src/stories/Message/Message.stories.tsx +0 -167
- package/src/stories/Modal/Manager.stories.tsx +0 -192
- package/src/stories/Modal/Modal.stories.tsx +0 -252
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
- package/src/stories/Navbar/Navbar.stories.tsx +0 -119
- package/src/stories/Notifications/Interactive.stories.tsx +0 -117
- package/src/stories/Notifications/Notification.stories.tsx +0 -216
- package/src/stories/Notifications/Notifications.stories.tsx +0 -81
- package/src/stories/Paging/Paging.stories.tsx +0 -255
- package/src/stories/Panel/Panel.stories.tsx +0 -753
- package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
- package/src/stories/Popover/Popover.stories.tsx +0 -510
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
- package/src/stories/Slider/Slider.stories.tsx +0 -173
- package/src/stories/Spacer/Spacer.stories.tsx +0 -100
- package/src/stories/Spinner/Spinner.stories.tsx +0 -82
- package/src/stories/Table/Table.stories.tsx +0 -571
- package/src/stories/Tabs/Tabs.stories.tsx +0 -346
- package/src/stories/Tag/Tag.stories.tsx +0 -381
- package/src/stories/Tag/TagGroup.stories.tsx +0 -307
- package/src/stories/TextArea/TextArea.stories.tsx +0 -287
- package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
- package/src/stories/Tree/Tree.stories.tsx +0 -124
- package/src/stories/Wrapper.tsx +0 -13
- package/src/stories/utils/args.ts +0 -151
- package/src/stories/utils.ts +0 -39
- package/src/styles.ts +0 -124
- package/src/types/global.ts +0 -211
- package/src/types/icons.ts +0 -2272
- 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
|
-
`;
|