@qoretechnologies/reqore 0.34.2 → 0.34.4
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/__tests__/button.test.tsx +30 -1
- package/__tests__/containers/paging.test.tsx +1 -1
- package/__tests__/drawer.test.tsx +1 -1
- package/__tests__/heading.test.tsx +58 -0
- package/__tests__/hooks/useReqorePaging.test.tsx +16 -0
- package/__tests__/pagination.test.tsx +104 -3
- package/__tests__/panel.test.tsx +23 -2
- package/dist/components/Button/index.d.ts +3 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +9 -7
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Collection/index.js +1 -2
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +3 -3
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +3 -10
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Dropdown/list.js +1 -1
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Header/index.d.ts +3 -3
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +5 -2
- package/dist/components/Header/index.js.map +1 -1
- package/dist/components/Paging/index.d.ts +2 -1
- package/dist/components/Paging/index.d.ts.map +1 -1
- package/dist/components/Paging/index.js +41 -7
- package/dist/components/Paging/index.js.map +1 -1
- package/dist/components/Panel/NonResponsiveActions.d.ts +18 -0
- package/dist/components/Panel/NonResponsiveActions.d.ts.map +1 -0
- package/dist/components/Panel/NonResponsiveActions.js +47 -0
- package/dist/components/Panel/NonResponsiveActions.js.map +1 -0
- package/dist/components/Panel/index.d.ts +5 -1
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +32 -19
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Tag/group.js +4 -1
- package/dist/components/Tag/group.js.map +1 -1
- package/dist/containers/Paging.d.ts +3 -3
- package/dist/containers/Paging.d.ts.map +1 -1
- package/dist/containers/Paging.js +6 -6
- package/dist/containers/Paging.js.map +1 -1
- package/dist/hooks/usePaging.d.ts +5 -0
- package/dist/hooks/usePaging.d.ts.map +1 -1
- package/dist/hooks/usePaging.js +7 -1
- package/dist/hooks/usePaging.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/index.tsx +19 -14
- package/src/components/Collection/index.tsx +2 -2
- package/src/components/ControlGroup/index.tsx +2 -3
- package/src/components/Drawer/index.tsx +4 -10
- package/src/components/Dropdown/list.tsx +1 -1
- package/src/components/Header/index.tsx +9 -3
- package/src/components/Paging/index.tsx +46 -6
- package/src/components/Panel/NonResponsiveActions.tsx +79 -0
- package/src/components/Panel/index.tsx +128 -75
- package/src/components/Tag/group.tsx +1 -1
- package/src/containers/Paging.tsx +83 -37
- package/src/hooks/usePaging.ts +14 -0
- package/src/stories/Drawer/Drawer.stories.tsx +6 -1
- package/src/stories/Dropdown/Dropdown.stories.tsx +1 -0
- package/src/stories/Header/Header.stories.tsx +6 -8
- package/src/stories/Paging/Paging.stories.tsx +22 -2
- package/src/stories/Panel/Panel.stories.tsx +13 -3
- package/tests.json +1 -1
|
@@ -1,26 +1,64 @@
|
|
|
1
1
|
import { memo, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
IReqorePaginationComponentProps,
|
|
4
|
+
IReqorePaginationProps,
|
|
5
|
+
ReqorePagination,
|
|
6
|
+
} from '../components/Paging';
|
|
3
7
|
import { ReqoreVerticalSpacer } from '../components/Spacer';
|
|
4
8
|
import {
|
|
9
|
+
getPaginationOptionsFromType,
|
|
5
10
|
TReqorePaginationType,
|
|
6
11
|
TReqorePaginationTypeResult,
|
|
7
|
-
getPaginationOptionsFromType,
|
|
8
12
|
} from '../constants/paging';
|
|
9
13
|
import { PADDING_FROM_SIZE, TSizes } from '../constants/sizes';
|
|
10
|
-
import { useReqorePaging } from '../hooks/usePaging';
|
|
14
|
+
import { IReqorePagingResult, useReqorePaging } from '../hooks/usePaging';
|
|
11
15
|
|
|
12
16
|
export interface IReqorePagingContainerProps<T> {
|
|
13
17
|
type?: TReqorePaginationType<T>;
|
|
14
18
|
items: T[];
|
|
15
|
-
scrollContainer?:
|
|
19
|
+
scrollContainer?: IReqorePaginationComponentProps['scrollContainer'];
|
|
16
20
|
children: (
|
|
17
21
|
items: T[],
|
|
18
|
-
Controls:
|
|
22
|
+
Controls: JSX.Element,
|
|
19
23
|
options: TReqorePaginationTypeResult<T>
|
|
20
24
|
) => React.ReactNode;
|
|
21
25
|
size?: TSizes;
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
function PagingControls<T>({
|
|
29
|
+
withSpacer,
|
|
30
|
+
position,
|
|
31
|
+
pagingData,
|
|
32
|
+
componentOptions,
|
|
33
|
+
scrollContainer,
|
|
34
|
+
size,
|
|
35
|
+
...pagingProps
|
|
36
|
+
}: Partial<IReqorePaginationProps<T>> &
|
|
37
|
+
Partial<TReqorePaginationTypeResult<T>> & {
|
|
38
|
+
withSpacer?: boolean;
|
|
39
|
+
position?: 'top' | 'bottom';
|
|
40
|
+
pagingData: Omit<IReqorePagingResult<T>, 'items'>;
|
|
41
|
+
}) {
|
|
42
|
+
return pagingData.renderControls ? (
|
|
43
|
+
<>
|
|
44
|
+
{withSpacer && position === 'bottom' ? (
|
|
45
|
+
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
|
|
46
|
+
) : null}
|
|
47
|
+
<ReqorePagination
|
|
48
|
+
key={`reqore-pagination-${position}`}
|
|
49
|
+
size={size}
|
|
50
|
+
{...pagingData}
|
|
51
|
+
{...componentOptions}
|
|
52
|
+
scrollContainer={scrollContainer}
|
|
53
|
+
{...pagingProps}
|
|
54
|
+
/>
|
|
55
|
+
{withSpacer && position === 'top' ? (
|
|
56
|
+
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
|
|
57
|
+
) : null}
|
|
58
|
+
</>
|
|
59
|
+
) : null;
|
|
60
|
+
}
|
|
61
|
+
|
|
24
62
|
function PagingContainer<T>({
|
|
25
63
|
type,
|
|
26
64
|
items,
|
|
@@ -42,46 +80,54 @@ function PagingContainer<T>({
|
|
|
42
80
|
enabled: !!type,
|
|
43
81
|
});
|
|
44
82
|
|
|
45
|
-
const Controls = ({
|
|
46
|
-
withSpacer,
|
|
47
|
-
position,
|
|
48
|
-
...pagingProps
|
|
49
|
-
}: Partial<IReqorePaginationProps<T>> & { withSpacer?: boolean; position?: 'top' | 'bottom' }) =>
|
|
50
|
-
pagingData.renderControls ? (
|
|
51
|
-
<>
|
|
52
|
-
{withSpacer && position === 'bottom' ? (
|
|
53
|
-
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
|
|
54
|
-
) : null}
|
|
55
|
-
<ReqorePagination
|
|
56
|
-
size={size}
|
|
57
|
-
{...pagingData}
|
|
58
|
-
{...componentOptions}
|
|
59
|
-
scrollContainer={scrollContainer}
|
|
60
|
-
{...pagingProps}
|
|
61
|
-
/>
|
|
62
|
-
{withSpacer && position === 'top' ? (
|
|
63
|
-
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
|
|
64
|
-
) : null}
|
|
65
|
-
</>
|
|
66
|
-
) : null;
|
|
67
|
-
|
|
68
83
|
return (
|
|
69
84
|
<>
|
|
70
85
|
{includeTopControls && (pageControlsPosition === 'top' || pageControlsPosition === 'both') ? (
|
|
71
|
-
<
|
|
86
|
+
<PagingControls<T>
|
|
87
|
+
key='top-paging'
|
|
88
|
+
position='top'
|
|
89
|
+
withSpacer
|
|
90
|
+
scrollContainer={scrollContainer}
|
|
91
|
+
size={size}
|
|
92
|
+
pagingData={pagingData}
|
|
93
|
+
pagingOptions={pagingOptions}
|
|
94
|
+
componentOptions={componentOptions}
|
|
95
|
+
autoLoadMore={false}
|
|
96
|
+
scrollOnLoadMore={false}
|
|
97
|
+
/>
|
|
72
98
|
) : null}
|
|
73
99
|
|
|
74
|
-
{children(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
{children(
|
|
101
|
+
finalItems,
|
|
102
|
+
<PagingControls
|
|
103
|
+
key='custom-paging'
|
|
104
|
+
scrollContainer={scrollContainer}
|
|
105
|
+
size={size}
|
|
106
|
+
pagingData={pagingData}
|
|
107
|
+
pagingOptions={pagingOptions}
|
|
108
|
+
componentOptions={componentOptions}
|
|
109
|
+
/>,
|
|
110
|
+
{
|
|
111
|
+
pagingOptions,
|
|
112
|
+
componentOptions,
|
|
113
|
+
pageControlsPosition,
|
|
114
|
+
includeTopControls,
|
|
115
|
+
includeBottomControls,
|
|
116
|
+
}
|
|
117
|
+
)}
|
|
81
118
|
|
|
82
119
|
{includeBottomControls &&
|
|
83
120
|
(pageControlsPosition === 'bottom' || pageControlsPosition === 'both') ? (
|
|
84
|
-
<
|
|
121
|
+
<PagingControls<T>
|
|
122
|
+
key='bottom-paging'
|
|
123
|
+
position='bottom'
|
|
124
|
+
withSpacer
|
|
125
|
+
scrollContainer={scrollContainer}
|
|
126
|
+
size={size}
|
|
127
|
+
pagingData={pagingData}
|
|
128
|
+
pagingOptions={pagingOptions}
|
|
129
|
+
componentOptions={componentOptions}
|
|
130
|
+
/>
|
|
85
131
|
) : null}
|
|
86
132
|
</>
|
|
87
133
|
);
|
package/src/hooks/usePaging.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { useEffect, useMemo } from 'react';
|
|
|
3
3
|
import { useUpdateEffect } from 'react-use';
|
|
4
4
|
import usePagination, { usePaginationReturn } from 'react-use-pagination-hook';
|
|
5
5
|
|
|
6
|
+
export interface IReqorePageChangeData {
|
|
7
|
+
isFirst?: boolean;
|
|
8
|
+
isLast?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
export interface IReqorePagingOptions<T> {
|
|
7
12
|
items: T[];
|
|
8
13
|
startPage?: number;
|
|
@@ -10,6 +15,7 @@ export interface IReqorePagingOptions<T> {
|
|
|
10
15
|
itemsPerPage?: number;
|
|
11
16
|
infinite?: boolean;
|
|
12
17
|
enabled?: boolean;
|
|
18
|
+
onPageChange?: (page: number, info: IReqorePageChangeData) => void;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export interface IReqorePagingResult<T>
|
|
@@ -46,6 +52,7 @@ export const useReqorePaging = <T>(
|
|
|
46
52
|
pagesToShow,
|
|
47
53
|
startPage,
|
|
48
54
|
enabled = true,
|
|
55
|
+
onPageChange,
|
|
49
56
|
}: IReqorePagingOptions<T> = merge({}, defaultPagingOptions, options);
|
|
50
57
|
const allPageCount = useMemo(() => Math.ceil(size(items) / itemsPerPage), [items, itemsPerPage]);
|
|
51
58
|
const { pagelist, currentPage, setPage, setTotalPage, goNext, goBefore } = usePagination({
|
|
@@ -57,6 +64,13 @@ export const useReqorePaging = <T>(
|
|
|
57
64
|
setPage(startPage || 1);
|
|
58
65
|
}, [startPage]);
|
|
59
66
|
|
|
67
|
+
useUpdateEffect(() => {
|
|
68
|
+
onPageChange?.(currentPage, {
|
|
69
|
+
isFirst: currentPage === 1,
|
|
70
|
+
isLast: currentPage === allPageCount,
|
|
71
|
+
});
|
|
72
|
+
}, [currentPage]);
|
|
73
|
+
|
|
60
74
|
useUpdateEffect(() => {
|
|
61
75
|
setPage(1);
|
|
62
76
|
setTotalPage(Math.ceil(size(items) / itemsPerPage));
|
|
@@ -10,12 +10,17 @@ import {
|
|
|
10
10
|
ReqoreTabsContent,
|
|
11
11
|
useReqoreProperty,
|
|
12
12
|
} from '../../index';
|
|
13
|
-
import { FlatArg, IntentArg
|
|
13
|
+
import { argManager, FlatArg, IntentArg } from '../utils/args';
|
|
14
14
|
|
|
15
15
|
const { createArg } = argManager<IReqoreDrawerProps>();
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
title: 'Components/Drawer',
|
|
19
|
+
parameters: {
|
|
20
|
+
chromatic: {
|
|
21
|
+
viewports: [450, 600, 1440],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
19
24
|
argTypes: {
|
|
20
25
|
...FlatArg,
|
|
21
26
|
...createArg('floating', {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
2
|
import { IReqoreHeadingProps } from '../../components/Header';
|
|
3
|
-
import {
|
|
3
|
+
import { ReqoreControlGroup, ReqoreHeading } from '../../index';
|
|
4
4
|
import { IntentArg } from '../utils/args';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -12,31 +12,29 @@ export default {
|
|
|
12
12
|
|
|
13
13
|
const Template: Story<IReqoreHeadingProps> = (args) => {
|
|
14
14
|
return (
|
|
15
|
-
|
|
15
|
+
<ReqoreControlGroup gapSize='big' vertical>
|
|
16
16
|
<ReqoreHeading size={1} {...args}>
|
|
17
17
|
This is a heading
|
|
18
18
|
</ReqoreHeading>
|
|
19
|
-
<ReqoreVerticalSpacer height={10} />
|
|
20
19
|
<ReqoreHeading size={2} {...args}>
|
|
21
20
|
This is a heading
|
|
22
21
|
</ReqoreHeading>
|
|
23
|
-
<ReqoreVerticalSpacer height={10} />
|
|
24
22
|
<ReqoreHeading size={3} {...args}>
|
|
25
23
|
This is a heading
|
|
26
24
|
</ReqoreHeading>
|
|
27
|
-
<ReqoreVerticalSpacer height={10} />
|
|
28
25
|
<ReqoreHeading size={4} {...args}>
|
|
29
26
|
This is a heading
|
|
30
27
|
</ReqoreHeading>
|
|
31
|
-
<ReqoreVerticalSpacer height={10} />
|
|
32
28
|
<ReqoreHeading size={5} {...args}>
|
|
33
29
|
This is a heading
|
|
34
30
|
</ReqoreHeading>
|
|
35
|
-
<ReqoreVerticalSpacer height={10} />
|
|
36
31
|
<ReqoreHeading size={6} {...args}>
|
|
37
32
|
This is a heading
|
|
38
33
|
</ReqoreHeading>
|
|
39
|
-
|
|
34
|
+
<ReqoreHeading size={1} {...args} tooltip={{ content: 'Nice tooltip', openOnMount: true }}>
|
|
35
|
+
This is a heading with tooltip
|
|
36
|
+
</ReqoreHeading>
|
|
37
|
+
</ReqoreControlGroup>
|
|
40
38
|
);
|
|
41
39
|
};
|
|
42
40
|
|
|
@@ -20,11 +20,17 @@ const Template: Story<IReqorePaginationProps<any> & { pagingOptions?: IReqorePag
|
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
return (
|
|
23
|
-
<ReqoreControlGroup vertical fluid>
|
|
23
|
+
<ReqoreControlGroup vertical fluid key='paging-wrapper'>
|
|
24
24
|
{paging.items.map((item) => (
|
|
25
25
|
<ReqoreTag fixed='key' labelKey={item.id} label={`${item.firstName} ${item.lastName}`} />
|
|
26
26
|
))}
|
|
27
|
-
<ReqorePagination<any>
|
|
27
|
+
<ReqorePagination<any>
|
|
28
|
+
{...paging}
|
|
29
|
+
{...args}
|
|
30
|
+
scrollContainer={
|
|
31
|
+
args.scrollToTopOnPageChange || !!args.changePageOnScroll ? scrollContainer : undefined
|
|
32
|
+
}
|
|
33
|
+
/>
|
|
28
34
|
</ReqoreControlGroup>
|
|
29
35
|
);
|
|
30
36
|
};
|
|
@@ -138,6 +144,20 @@ WithLabels.args = {
|
|
|
138
144
|
} as IReqorePagingOptions<any>,
|
|
139
145
|
};
|
|
140
146
|
|
|
147
|
+
export const NextPageOnVerticalScroll: Story<
|
|
148
|
+
IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
|
|
149
|
+
> = Template.bind({});
|
|
150
|
+
NextPageOnVerticalScroll.args = {
|
|
151
|
+
changePageOnScroll: 'vertical',
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const NextPageOnHorizontalScroll: Story<
|
|
155
|
+
IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
|
|
156
|
+
> = Template.bind({});
|
|
157
|
+
NextPageOnHorizontalScroll.args = {
|
|
158
|
+
changePageOnScroll: 'horizontal',
|
|
159
|
+
};
|
|
160
|
+
|
|
141
161
|
export const ScrollToTop: Story<
|
|
142
162
|
IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
|
|
143
163
|
> = Template.bind({});
|
|
@@ -3,12 +3,17 @@ import { noop } from 'lodash';
|
|
|
3
3
|
import ReqoreInput, { IReqoreInputProps } from '../../components/Input';
|
|
4
4
|
import { IReqorePanelAction, IReqorePanelProps, ReqorePanel } from '../../components/Panel';
|
|
5
5
|
import { ReqoreVerticalSpacer } from '../../components/Spacer';
|
|
6
|
-
import { FlatArg, IconArg, IntentArg, SizeArg
|
|
6
|
+
import { argManager, FlatArg, IconArg, IntentArg, SizeArg } from '../utils/args';
|
|
7
7
|
|
|
8
8
|
const { createArg } = argManager<IReqorePanelProps>();
|
|
9
9
|
|
|
10
10
|
export default {
|
|
11
11
|
title: 'Components/Panel',
|
|
12
|
+
parameters: {
|
|
13
|
+
chromatic: {
|
|
14
|
+
viewports: [450, 600, 1440],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
12
17
|
argTypes: {
|
|
13
18
|
...IntentArg,
|
|
14
19
|
...FlatArg,
|
|
@@ -373,13 +378,18 @@ NoLabel.args = {
|
|
|
373
378
|
badge: undefined,
|
|
374
379
|
};
|
|
375
380
|
|
|
376
|
-
export const
|
|
377
|
-
|
|
381
|
+
export const ImageAsIconLinkAsHeader: Story<IReqorePanelProps> = Template.bind({});
|
|
382
|
+
ImageAsIconLinkAsHeader.args = {
|
|
378
383
|
iconImage:
|
|
379
384
|
'https://avatars.githubusercontent.com/u/44835090?s=400&u=371120ce0755102d2e432f11ad9aa0378c871b45&v=4',
|
|
380
385
|
iconProps: {
|
|
381
386
|
size: '30px',
|
|
382
387
|
},
|
|
388
|
+
headerProps: {
|
|
389
|
+
as: 'a',
|
|
390
|
+
href: 'https://qoretechnologies.com',
|
|
391
|
+
target: '_blank',
|
|
392
|
+
} as React.HTMLAttributes<HTMLAnchorElement>,
|
|
383
393
|
};
|
|
384
394
|
|
|
385
395
|
export const ContentSize: Story<IReqorePanelProps> = Template.bind({});
|