@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,74 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { ReqoreIcon, ReqoreP } from '../..';
|
|
3
|
-
import { TSizes } from '../../constants/sizes';
|
|
4
|
-
import { TReqoreIntent } from '../../constants/theme';
|
|
5
|
-
import { IWithReqoreEffect } from '../../types/global';
|
|
6
|
-
import ReqoreControlGroup, { IReqoreControlGroupProps } from '../ControlGroup';
|
|
7
|
-
import { IReqoreEffect, TReqoreEffectColor } from '../Effect';
|
|
8
|
-
import { IReqoreIconProps } from '../Icon';
|
|
9
|
-
|
|
10
|
-
export interface IReqoreSpinnerProps
|
|
11
|
-
extends Omit<IReqoreControlGroupProps, 'children' | 'size'>,
|
|
12
|
-
IWithReqoreEffect {
|
|
13
|
-
size?: TSizes | string;
|
|
14
|
-
intent?: TReqoreIntent;
|
|
15
|
-
children?: any;
|
|
16
|
-
type?: 2 | 3 | 4 | 5;
|
|
17
|
-
iconColor?: TReqoreEffectColor;
|
|
18
|
-
labelEffect?: IReqoreEffect;
|
|
19
|
-
iconMargin?: 'right' | 'left' | 'both';
|
|
20
|
-
centered?: boolean;
|
|
21
|
-
iconProps?: IReqoreIconProps;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const ReqoreSpinner = ({
|
|
25
|
-
size,
|
|
26
|
-
intent,
|
|
27
|
-
children,
|
|
28
|
-
type,
|
|
29
|
-
iconColor,
|
|
30
|
-
labelEffect,
|
|
31
|
-
effect,
|
|
32
|
-
iconMargin,
|
|
33
|
-
centered,
|
|
34
|
-
iconProps,
|
|
35
|
-
...rest
|
|
36
|
-
}: IReqoreSpinnerProps) => {
|
|
37
|
-
const renderContent = useCallback(() => {
|
|
38
|
-
return (
|
|
39
|
-
<ReqoreIcon
|
|
40
|
-
icon={!type ? 'LoaderLine' : `Loader${type}Line`}
|
|
41
|
-
color={iconColor || intent}
|
|
42
|
-
size={size}
|
|
43
|
-
effect={effect}
|
|
44
|
-
animation='spin'
|
|
45
|
-
className='reqore-spinner'
|
|
46
|
-
margin={iconMargin || (children ? 'right' : undefined)}
|
|
47
|
-
{...iconProps}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
}, [size, intent, type, children, iconColor]);
|
|
51
|
-
|
|
52
|
-
if (children) {
|
|
53
|
-
return (
|
|
54
|
-
<ReqoreControlGroup
|
|
55
|
-
{...rest}
|
|
56
|
-
vertical={centered}
|
|
57
|
-
horizontalAlign={centered ? 'center' : undefined}
|
|
58
|
-
verticalAlign='center'
|
|
59
|
-
>
|
|
60
|
-
{renderContent()}
|
|
61
|
-
<ReqoreP
|
|
62
|
-
size={size}
|
|
63
|
-
intent={intent}
|
|
64
|
-
effect={labelEffect}
|
|
65
|
-
className='reqore-spinner-wrapper'
|
|
66
|
-
>
|
|
67
|
-
{children}
|
|
68
|
-
</ReqoreP>
|
|
69
|
-
</ReqoreControlGroup>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return <>{renderContent()}</>;
|
|
74
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import count from 'lodash/size';
|
|
2
|
-
import { forwardRef, memo, useMemo } from 'react';
|
|
3
|
-
import { useMount } from 'react-use';
|
|
4
|
-
import { FixedSizeList as List } from 'react-window';
|
|
5
|
-
import styled from 'styled-components';
|
|
6
|
-
import { TABLE_SIZE_TO_PX } from '../../constants/sizes';
|
|
7
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
8
|
-
import ReqoreTableRow, { IReqoreTableRowOptions } from './row';
|
|
9
|
-
|
|
10
|
-
export interface IReqoreTableSectionBodyProps extends IReqoreTableRowOptions {
|
|
11
|
-
height: number;
|
|
12
|
-
refs: {
|
|
13
|
-
left: React.RefObject<HTMLDivElement>;
|
|
14
|
-
right: React.RefObject<HTMLDivElement>;
|
|
15
|
-
main: React.RefObject<HTMLDivElement>;
|
|
16
|
-
header: React.RefObject<HTMLDivElement>;
|
|
17
|
-
};
|
|
18
|
-
type: 'left' | 'right' | 'main';
|
|
19
|
-
onScrollChange?: (isScrolled: boolean) => void;
|
|
20
|
-
setHoveredRow?: (index: number) => void;
|
|
21
|
-
hoveredRow?: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const StyledList = styled(List)`
|
|
25
|
-
::-webkit-scrollbar {
|
|
26
|
-
display: none;
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const ReqoreTableBody = forwardRef<HTMLDivElement, IReqoreTableSectionBodyProps>(
|
|
31
|
-
(
|
|
32
|
-
{
|
|
33
|
-
data,
|
|
34
|
-
height,
|
|
35
|
-
size = 'normal',
|
|
36
|
-
refs,
|
|
37
|
-
type,
|
|
38
|
-
onScrollChange,
|
|
39
|
-
...rest
|
|
40
|
-
}: IReqoreTableSectionBodyProps,
|
|
41
|
-
ref
|
|
42
|
-
) => {
|
|
43
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
44
|
-
|
|
45
|
-
useMount(() => {
|
|
46
|
-
targetRef.current?.addEventListener('wheel', (e) => {
|
|
47
|
-
// Only scroll if the element is scrollable
|
|
48
|
-
if (refs[type].current?.scrollHeight > refs[type].current?.clientHeight) {
|
|
49
|
-
if (e.deltaY) {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
|
|
52
|
-
const currentScroll = refs[type].current?.scrollTop + e.deltaY;
|
|
53
|
-
|
|
54
|
-
onScrollChange?.(currentScroll > 0);
|
|
55
|
-
|
|
56
|
-
refs[type].current?.scrollTo({ top: currentScroll });
|
|
57
|
-
|
|
58
|
-
if (type === 'left') {
|
|
59
|
-
refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
|
|
60
|
-
refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
|
|
61
|
-
} else if (type === 'main') {
|
|
62
|
-
refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
|
|
63
|
-
refs.right.current?.scrollTo({ top: refs.right.current?.scrollTop + e.deltaY });
|
|
64
|
-
} else if (type === 'right') {
|
|
65
|
-
refs.main.current?.scrollTo({ top: refs.main.current?.scrollTop + e.deltaY });
|
|
66
|
-
refs.left.current?.scrollTo({ top: refs.left.current?.scrollTop + e.deltaY });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (e.deltaX && type === 'main') {
|
|
71
|
-
refs.header.current?.scrollTo({ left: refs.main.current?.scrollLeft + e.deltaX });
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const rowHeight = useMemo(
|
|
78
|
-
() => (rest.flat ? TABLE_SIZE_TO_PX[size] : TABLE_SIZE_TO_PX[size] + 1),
|
|
79
|
-
[size, rest.flat]
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
const itemCount = useMemo(() => count(data), [data]);
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<StyledList
|
|
86
|
-
outerRef={targetRef}
|
|
87
|
-
itemCount={itemCount}
|
|
88
|
-
// If the defined height is less than the count of items' height
|
|
89
|
-
// use that height instead
|
|
90
|
-
height={
|
|
91
|
-
(!height && height !== 0) || height > itemCount * rowHeight
|
|
92
|
-
? itemCount * rowHeight
|
|
93
|
-
: height
|
|
94
|
-
}
|
|
95
|
-
className='reqore-table-body'
|
|
96
|
-
itemSize={rest.flat ? TABLE_SIZE_TO_PX[size] : TABLE_SIZE_TO_PX[size] + 1}
|
|
97
|
-
itemData={{
|
|
98
|
-
data,
|
|
99
|
-
size,
|
|
100
|
-
...rest,
|
|
101
|
-
}}
|
|
102
|
-
>
|
|
103
|
-
{ReqoreTableRow}
|
|
104
|
-
</StyledList>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
export default memo(ReqoreTableBody);
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { lighten, rgba } from 'polished';
|
|
2
|
-
import { forwardRef, memo } from 'react';
|
|
3
|
-
import styled, { css } from 'styled-components';
|
|
4
|
-
import { IReqoreTableColumn } from '.';
|
|
5
|
-
import { TEXT_FROM_SIZE } from '../../constants/sizes';
|
|
6
|
-
import { changeLightness, getReadableColorFrom } from '../../helpers/colors';
|
|
7
|
-
import { alignToFlexAlign } from '../../helpers/utils';
|
|
8
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
9
|
-
import { useTooltip } from '../../hooks/useTooltip';
|
|
10
|
-
import { IWithReqoreTooltip } from '../../types/global';
|
|
11
|
-
import { TReqoreColor } from '../Effect';
|
|
12
|
-
import { IReqoreTableCellStyle } from './row';
|
|
13
|
-
|
|
14
|
-
export interface IReqoreCustomTableBodyCellProps extends IReqoreTableBodyCellProps {}
|
|
15
|
-
export interface IReqoreCustomTableBodyCell extends React.FC<IReqoreCustomTableBodyCellProps> {}
|
|
16
|
-
export interface IReqoreTableBodyCellProps
|
|
17
|
-
extends Partial<IReqoreTableColumn>,
|
|
18
|
-
React.HTMLAttributes<HTMLDivElement>,
|
|
19
|
-
IWithReqoreTooltip {
|
|
20
|
-
children?: React.ReactNode;
|
|
21
|
-
padded?: IReqoreTableColumn['cell']['padded'];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const StyledTableCell = styled.div<IReqoreTableCellStyle>`
|
|
25
|
-
${({ width, minWidth, maxWidth, grow }) =>
|
|
26
|
-
css`
|
|
27
|
-
width: ${width}px;
|
|
28
|
-
min-width: ${minWidth}px;
|
|
29
|
-
max-width: ${maxWidth}px;
|
|
30
|
-
|
|
31
|
-
flex-grow: ${grow || (width ? undefined : 1)};
|
|
32
|
-
`}
|
|
33
|
-
|
|
34
|
-
${({
|
|
35
|
-
theme,
|
|
36
|
-
align,
|
|
37
|
-
interactive,
|
|
38
|
-
interactiveCell,
|
|
39
|
-
intent,
|
|
40
|
-
size,
|
|
41
|
-
flat,
|
|
42
|
-
striped,
|
|
43
|
-
even,
|
|
44
|
-
selected,
|
|
45
|
-
selectedIntent,
|
|
46
|
-
disabled,
|
|
47
|
-
hovered,
|
|
48
|
-
padded,
|
|
49
|
-
}: IReqoreTableCellStyle) => {
|
|
50
|
-
const getBackgroundColor = (): TReqoreColor => {
|
|
51
|
-
let color = theme.main;
|
|
52
|
-
let opacity = 0;
|
|
53
|
-
// Is there any intent
|
|
54
|
-
if (intent || (selected && selectedIntent)) {
|
|
55
|
-
color = theme.intents[intent || selectedIntent];
|
|
56
|
-
opacity += 0.02;
|
|
57
|
-
}
|
|
58
|
-
// Is the table striped and this row odd
|
|
59
|
-
if (striped && !even) {
|
|
60
|
-
opacity += 0.05;
|
|
61
|
-
}
|
|
62
|
-
// Is this row selected
|
|
63
|
-
if (selected) {
|
|
64
|
-
opacity += 0.02;
|
|
65
|
-
}
|
|
66
|
-
// Is this row hovered
|
|
67
|
-
if (hovered) {
|
|
68
|
-
opacity += 0.08;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Set the color as transparent if opacity is 0
|
|
72
|
-
if (opacity === 0) {
|
|
73
|
-
return 'transparent';
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return changeLightness(color, opacity);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const backgroundColor = getBackgroundColor();
|
|
80
|
-
|
|
81
|
-
return css`
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
justify-content: ${align ? alignToFlexAlign(align) : 'flex-start'};
|
|
85
|
-
flex-shrink: 0;
|
|
86
|
-
border-bottom: ${!flat ? '1px solid ' : undefined};
|
|
87
|
-
|
|
88
|
-
height: 100%;
|
|
89
|
-
padding: ${!padded || padded === 'both' || padded === 'vertical' ? 0 : undefined}
|
|
90
|
-
${!padded || padded === 'both' || padded === 'horizontal' ? '10px' : undefined};
|
|
91
|
-
font-size: ${TEXT_FROM_SIZE[size]}px;
|
|
92
|
-
background-color: ${backgroundColor === 'transparent'
|
|
93
|
-
? 'transparent'
|
|
94
|
-
: rgba(getBackgroundColor(), 0.8)};
|
|
95
|
-
color: ${getReadableColorFrom(
|
|
96
|
-
backgroundColor === 'transparent' ? theme.main : backgroundColor,
|
|
97
|
-
!hovered
|
|
98
|
-
)};
|
|
99
|
-
border-color: ${changeLightness(
|
|
100
|
-
backgroundColor === 'transparent' ? theme.main : backgroundColor,
|
|
101
|
-
0.1
|
|
102
|
-
)};
|
|
103
|
-
transition: background-color 0.2s ease-out;
|
|
104
|
-
opacity: ${disabled ? 0.2 : 1};
|
|
105
|
-
pointer-events: ${disabled ? 'none' : undefined};
|
|
106
|
-
cursor: ${interactive || interactiveCell ? 'pointer' : 'default'};
|
|
107
|
-
|
|
108
|
-
${interactiveCell &&
|
|
109
|
-
css`
|
|
110
|
-
&:hover {
|
|
111
|
-
background-color: ${lighten(0.2, getBackgroundColor())};
|
|
112
|
-
}
|
|
113
|
-
`}
|
|
114
|
-
|
|
115
|
-
p.reqore-table-text {
|
|
116
|
-
overflow: hidden;
|
|
117
|
-
white-space: nowrap;
|
|
118
|
-
text-overflow: ellipsis;
|
|
119
|
-
margin: 0;
|
|
120
|
-
padding: 0;
|
|
121
|
-
}
|
|
122
|
-
`;
|
|
123
|
-
}}
|
|
124
|
-
`;
|
|
125
|
-
|
|
126
|
-
export const ReqoreTableBodyCell = memo(
|
|
127
|
-
forwardRef<HTMLButtonElement, IReqoreTableBodyCellProps>(
|
|
128
|
-
(props: IReqoreTableBodyCellProps, ref) => {
|
|
129
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
130
|
-
|
|
131
|
-
useTooltip(targetRef.current, props.tooltip);
|
|
132
|
-
|
|
133
|
-
return <StyledTableCell {...props} ref={targetRef} />;
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
);
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { omit } from 'lodash';
|
|
2
|
-
import { forwardRef, memo, useCallback } from 'react';
|
|
3
|
-
import { useMount } from 'react-use';
|
|
4
|
-
import styled, { css } from 'styled-components';
|
|
5
|
-
import { IReqoreTableColumn, IReqoreTableSort } from '.';
|
|
6
|
-
import { SIZE_TO_PX, TSizes } from '../../constants/sizes';
|
|
7
|
-
import { IReqoreTheme } from '../../constants/theme';
|
|
8
|
-
import { changeLightness } from '../../helpers/colors';
|
|
9
|
-
import { alignToFlexAlign } from '../../helpers/utils';
|
|
10
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
11
|
-
import { IWithReqoreSize } from '../../types/global';
|
|
12
|
-
import { IReqoreButtonProps } from '../Button';
|
|
13
|
-
import { IReqoreTableHeaderCellProps, ReqoreTableHeaderCell } from './headerCell';
|
|
14
|
-
import { getOnlyShownColumns } from './helpers';
|
|
15
|
-
|
|
16
|
-
export type TColumnsUpdater = <T extends keyof IReqoreTableColumn>(
|
|
17
|
-
id: string,
|
|
18
|
-
key: T,
|
|
19
|
-
value: IReqoreTableColumn[T]
|
|
20
|
-
) => void;
|
|
21
|
-
|
|
22
|
-
export interface IReqoreCustomHeaderCellProps
|
|
23
|
-
extends Pick<
|
|
24
|
-
IReqoreTableHeaderCellProps,
|
|
25
|
-
'sortData' | 'onSortChange' | 'onColumnsUpdate' | 'onFilterChange'
|
|
26
|
-
>,
|
|
27
|
-
Omit<IReqoreTableColumn, 'cell' | 'header'>,
|
|
28
|
-
Omit<IReqoreButtonProps, 'maxWidth' | 'content'> {
|
|
29
|
-
hasColumns?: boolean;
|
|
30
|
-
}
|
|
31
|
-
export interface IReqoreCustomHeaderCellComponent extends React.FC<IReqoreCustomHeaderCellProps> {}
|
|
32
|
-
|
|
33
|
-
export interface IReqoreTableSectionProps extends IWithReqoreSize {
|
|
34
|
-
columns: IReqoreTableColumn[];
|
|
35
|
-
onSortChange?: (sort: string) => void;
|
|
36
|
-
sortData: IReqoreTableSort;
|
|
37
|
-
hasVerticalScroll: boolean;
|
|
38
|
-
onColumnsUpdate: TColumnsUpdater;
|
|
39
|
-
onFilterChange?: (dataId: string, value: any) => void;
|
|
40
|
-
component?: IReqoreCustomHeaderCellComponent;
|
|
41
|
-
heightAsGroup?: boolean;
|
|
42
|
-
scrollable?: boolean;
|
|
43
|
-
bodyRef: React.RefObject<HTMLDivElement>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface IReqoreTableSectionStyle {
|
|
47
|
-
leftScroll: number;
|
|
48
|
-
hasVerticalScroll: boolean;
|
|
49
|
-
theme: IReqoreTheme;
|
|
50
|
-
heightAsGroup?: boolean;
|
|
51
|
-
size?: TSizes;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const StyledTableHeaderWrapper = styled.div<IReqoreTableSectionStyle>`
|
|
55
|
-
${({ heightAsGroup, size }) => css`
|
|
56
|
-
display: flex;
|
|
57
|
-
|
|
58
|
-
overflow-x: auto;
|
|
59
|
-
overflow-y: hidden;
|
|
60
|
-
::-webkit-scrollbar {
|
|
61
|
-
display: none;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
flex-shrink: 0;
|
|
65
|
-
flex-flow: column;
|
|
66
|
-
height: ${heightAsGroup ? `${SIZE_TO_PX[size] * 2}px` : undefined};
|
|
67
|
-
|
|
68
|
-
${({ theme }) => css`
|
|
69
|
-
background-color: ${theme.main};
|
|
70
|
-
`}
|
|
71
|
-
`}
|
|
72
|
-
`;
|
|
73
|
-
|
|
74
|
-
export interface IReqoreTableHeaderStyle {
|
|
75
|
-
width?: number;
|
|
76
|
-
grow?: number;
|
|
77
|
-
theme: IReqoreTheme;
|
|
78
|
-
align?: 'center' | 'left' | 'right';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const StyledColumnGroupHeader = styled.div<IReqoreTableHeaderStyle>`
|
|
82
|
-
${({ align, theme }) => css`
|
|
83
|
-
background-color: ${changeLightness(theme.main, 0.035)};
|
|
84
|
-
justify-content: ${align ? alignToFlexAlign(align) : 'flex-start'};
|
|
85
|
-
`}
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
const StyledColumnGroup = styled.div<IReqoreTableHeaderStyle>`
|
|
89
|
-
display: flex;
|
|
90
|
-
flex-flow: column;
|
|
91
|
-
flex-shrink: 0;
|
|
92
|
-
width: ${({ width }) => width}px;
|
|
93
|
-
max-width: ${({ maxWidth = 9999 }) => maxWidth}px;
|
|
94
|
-
min-width: ${({ minWidth, width }) => minWidth || width}px;
|
|
95
|
-
|
|
96
|
-
${({ grow }) =>
|
|
97
|
-
grow &&
|
|
98
|
-
css`
|
|
99
|
-
flex-grow: ${grow};
|
|
100
|
-
`}
|
|
101
|
-
`;
|
|
102
|
-
|
|
103
|
-
const StyledColumnGroupHeaders = styled.div`
|
|
104
|
-
display: flex;
|
|
105
|
-
`;
|
|
106
|
-
|
|
107
|
-
const StyledTableHeaderRow = styled.div<{ theme: IReqoreTheme }>`
|
|
108
|
-
display: flex;
|
|
109
|
-
flex: 1;
|
|
110
|
-
|
|
111
|
-
${StyledColumnGroupHeader} {
|
|
112
|
-
font-size: 13px;
|
|
113
|
-
font-weight: 600;
|
|
114
|
-
padding: 5px 10px;
|
|
115
|
-
|
|
116
|
-
display: flex;
|
|
117
|
-
flex-shrink: 0;
|
|
118
|
-
align-items: center;
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
|
|
122
|
-
const ReqoreTableHeader = forwardRef<HTMLDivElement, IReqoreTableSectionProps>(
|
|
123
|
-
(
|
|
124
|
-
{
|
|
125
|
-
columns,
|
|
126
|
-
onSortChange,
|
|
127
|
-
sortData,
|
|
128
|
-
hasVerticalScroll,
|
|
129
|
-
onColumnsUpdate,
|
|
130
|
-
onFilterChange,
|
|
131
|
-
size,
|
|
132
|
-
component,
|
|
133
|
-
heightAsGroup,
|
|
134
|
-
scrollable,
|
|
135
|
-
bodyRef,
|
|
136
|
-
}: IReqoreTableSectionProps,
|
|
137
|
-
ref
|
|
138
|
-
) => {
|
|
139
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
140
|
-
|
|
141
|
-
useMount(() => {
|
|
142
|
-
if (scrollable) {
|
|
143
|
-
targetRef.current?.addEventListener('wheel', (e) => {
|
|
144
|
-
if (e.deltaX) {
|
|
145
|
-
e.preventDefault();
|
|
146
|
-
|
|
147
|
-
targetRef.current?.scrollTo({ left: targetRef.current?.scrollLeft + e.deltaX });
|
|
148
|
-
bodyRef.current?.scrollTo({ left: bodyRef.current?.scrollLeft + e.deltaX });
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
const renderHeaderCell = useCallback(
|
|
155
|
-
(
|
|
156
|
-
headerCellComponent: IReqoreCustomHeaderCellComponent,
|
|
157
|
-
props: IReqoreCustomHeaderCellProps
|
|
158
|
-
) => {
|
|
159
|
-
const HeaderCell = headerCellComponent || component || ReqoreTableHeaderCell;
|
|
160
|
-
|
|
161
|
-
return <HeaderCell key={props.dataId} {...props} />;
|
|
162
|
-
},
|
|
163
|
-
[component]
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const renderColumns = (columns: IReqoreTableColumn[]) =>
|
|
167
|
-
getOnlyShownColumns(columns).map(
|
|
168
|
-
({
|
|
169
|
-
grow,
|
|
170
|
-
align,
|
|
171
|
-
dataId,
|
|
172
|
-
header: { columns, onClick, component: headerComponent, ...rest },
|
|
173
|
-
...colRest
|
|
174
|
-
}) =>
|
|
175
|
-
columns ? (
|
|
176
|
-
<StyledColumnGroup
|
|
177
|
-
grow={getOnlyShownColumns(columns).reduce((gr, col) => gr + col.grow, 0)}
|
|
178
|
-
key={dataId}
|
|
179
|
-
className='reqore-table-column-group'
|
|
180
|
-
width={getOnlyShownColumns(columns).reduce(
|
|
181
|
-
(wid, col) => wid + (col.resizedWidth || col.width || 80),
|
|
182
|
-
0
|
|
183
|
-
)}
|
|
184
|
-
maxWidth={getOnlyShownColumns(columns).reduce((wid, col) => wid + col.maxWidth, 0)}
|
|
185
|
-
minWidth={getOnlyShownColumns(columns).reduce((wid, col) => wid + col.minWidth, 0)}
|
|
186
|
-
>
|
|
187
|
-
{renderHeaderCell(headerComponent, {
|
|
188
|
-
...rest,
|
|
189
|
-
...omit(colRest, ['cell']),
|
|
190
|
-
dataId,
|
|
191
|
-
size,
|
|
192
|
-
readOnly: !onClick,
|
|
193
|
-
onClick,
|
|
194
|
-
rounded: false,
|
|
195
|
-
textAlign: align,
|
|
196
|
-
className: 'reqore-table-column-group-header',
|
|
197
|
-
resizable: false,
|
|
198
|
-
hideable: false,
|
|
199
|
-
hasColumns: true,
|
|
200
|
-
})}
|
|
201
|
-
<StyledColumnGroupHeaders className='reqore-table-headers'>
|
|
202
|
-
{renderColumns(columns)}
|
|
203
|
-
</StyledColumnGroupHeaders>
|
|
204
|
-
</StyledColumnGroup>
|
|
205
|
-
) : (
|
|
206
|
-
renderHeaderCell(headerComponent, {
|
|
207
|
-
...rest,
|
|
208
|
-
...omit(colRest, ['cell']),
|
|
209
|
-
onClick,
|
|
210
|
-
dataId,
|
|
211
|
-
size,
|
|
212
|
-
sortData,
|
|
213
|
-
grow,
|
|
214
|
-
align,
|
|
215
|
-
onSortChange,
|
|
216
|
-
onColumnsUpdate,
|
|
217
|
-
onFilterChange,
|
|
218
|
-
})
|
|
219
|
-
)
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
return (
|
|
223
|
-
<StyledTableHeaderWrapper
|
|
224
|
-
className='reqore-table-header-wrapper'
|
|
225
|
-
hasVerticalScroll={hasVerticalScroll}
|
|
226
|
-
heightAsGroup={heightAsGroup}
|
|
227
|
-
size={size}
|
|
228
|
-
ref={targetRef}
|
|
229
|
-
>
|
|
230
|
-
<StyledTableHeaderRow>{renderColumns(columns)}</StyledTableHeaderRow>
|
|
231
|
-
</StyledTableHeaderWrapper>
|
|
232
|
-
);
|
|
233
|
-
}
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
export default memo(ReqoreTableHeader);
|