@qoretechnologies/reqore 0.34.1 → 0.34.3
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__/containers/paging.test.tsx +1 -1
- package/dist/components/Collection/index.d.ts +1 -1
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +4 -3
- 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 +1 -1
- package/dist/components/ControlGroup/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/Paging/index.d.ts.map +1 -1
- package/dist/components/Paging/index.js +10 -6
- package/dist/components/Paging/index.js.map +1 -1
- package/dist/containers/Paging.d.ts +1 -2
- 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/package.json +1 -1
- package/src/components/Collection/index.tsx +14 -4
- package/src/components/ControlGroup/index.tsx +1 -2
- package/src/components/Dropdown/list.tsx +1 -1
- package/src/components/Paging/index.tsx +11 -7
- package/src/containers/Paging.tsx +76 -34
- package/src/stories/Collection/Collection.stories.tsx +10 -0
- package/src/stories/Paging/Paging.stories.tsx +6 -2
- package/tests.json +1 -1
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getPaginationOptionsFromType,
|
|
8
8
|
} from '../constants/paging';
|
|
9
9
|
import { PADDING_FROM_SIZE, TSizes } from '../constants/sizes';
|
|
10
|
-
import { useReqorePaging } from '../hooks/usePaging';
|
|
10
|
+
import { IReqorePagingResult, useReqorePaging } from '../hooks/usePaging';
|
|
11
11
|
|
|
12
12
|
export interface IReqorePagingContainerProps<T> {
|
|
13
13
|
type?: TReqorePaginationType<T>;
|
|
@@ -15,12 +15,46 @@ export interface IReqorePagingContainerProps<T> {
|
|
|
15
15
|
scrollContainer?: HTMLElement;
|
|
16
16
|
children: (
|
|
17
17
|
items: T[],
|
|
18
|
-
Controls:
|
|
18
|
+
Controls: JSX.Element,
|
|
19
19
|
options: TReqorePaginationTypeResult<T>
|
|
20
20
|
) => React.ReactNode;
|
|
21
21
|
size?: TSizes;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
function PagingControls<T>({
|
|
25
|
+
withSpacer,
|
|
26
|
+
position,
|
|
27
|
+
pagingData,
|
|
28
|
+
componentOptions,
|
|
29
|
+
scrollContainer,
|
|
30
|
+
size,
|
|
31
|
+
...pagingProps
|
|
32
|
+
}: Partial<IReqorePaginationProps<T>> &
|
|
33
|
+
Partial<TReqorePaginationTypeResult<T>> & {
|
|
34
|
+
withSpacer?: boolean;
|
|
35
|
+
position?: 'top' | 'bottom';
|
|
36
|
+
pagingData: Omit<IReqorePagingResult<T>, 'items'>;
|
|
37
|
+
}) {
|
|
38
|
+
return pagingData.renderControls ? (
|
|
39
|
+
<>
|
|
40
|
+
{withSpacer && position === 'bottom' ? (
|
|
41
|
+
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
|
|
42
|
+
) : null}
|
|
43
|
+
<ReqorePagination
|
|
44
|
+
key={`reqore-pagination-${position}`}
|
|
45
|
+
size={size}
|
|
46
|
+
{...pagingData}
|
|
47
|
+
{...componentOptions}
|
|
48
|
+
scrollContainer={scrollContainer}
|
|
49
|
+
{...pagingProps}
|
|
50
|
+
/>
|
|
51
|
+
{withSpacer && position === 'top' ? (
|
|
52
|
+
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE[size]} />
|
|
53
|
+
) : null}
|
|
54
|
+
</>
|
|
55
|
+
) : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
24
58
|
function PagingContainer<T>({
|
|
25
59
|
type,
|
|
26
60
|
items,
|
|
@@ -42,46 +76,54 @@ function PagingContainer<T>({
|
|
|
42
76
|
enabled: !!type,
|
|
43
77
|
});
|
|
44
78
|
|
|
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
79
|
return (
|
|
69
80
|
<>
|
|
70
81
|
{includeTopControls && (pageControlsPosition === 'top' || pageControlsPosition === 'both') ? (
|
|
71
|
-
<
|
|
82
|
+
<PagingControls<T>
|
|
83
|
+
key='top-paging'
|
|
84
|
+
position='top'
|
|
85
|
+
withSpacer
|
|
86
|
+
scrollContainer={scrollContainer}
|
|
87
|
+
size={size}
|
|
88
|
+
pagingData={pagingData}
|
|
89
|
+
pagingOptions={pagingOptions}
|
|
90
|
+
componentOptions={componentOptions}
|
|
91
|
+
autoLoadMore={false}
|
|
92
|
+
scrollOnLoadMore={false}
|
|
93
|
+
/>
|
|
72
94
|
) : null}
|
|
73
95
|
|
|
74
|
-
{children(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
{children(
|
|
97
|
+
finalItems,
|
|
98
|
+
<PagingControls
|
|
99
|
+
key='custom-paging'
|
|
100
|
+
scrollContainer={scrollContainer}
|
|
101
|
+
size={size}
|
|
102
|
+
pagingData={pagingData}
|
|
103
|
+
pagingOptions={pagingOptions}
|
|
104
|
+
componentOptions={componentOptions}
|
|
105
|
+
/>,
|
|
106
|
+
{
|
|
107
|
+
pagingOptions,
|
|
108
|
+
componentOptions,
|
|
109
|
+
pageControlsPosition,
|
|
110
|
+
includeTopControls,
|
|
111
|
+
includeBottomControls,
|
|
112
|
+
}
|
|
113
|
+
)}
|
|
81
114
|
|
|
82
115
|
{includeBottomControls &&
|
|
83
116
|
(pageControlsPosition === 'bottom' || pageControlsPosition === 'both') ? (
|
|
84
|
-
<
|
|
117
|
+
<PagingControls<T>
|
|
118
|
+
key='bottom-paging'
|
|
119
|
+
position='bottom'
|
|
120
|
+
withSpacer
|
|
121
|
+
scrollContainer={scrollContainer}
|
|
122
|
+
size={size}
|
|
123
|
+
pagingData={pagingData}
|
|
124
|
+
pagingOptions={pagingOptions}
|
|
125
|
+
componentOptions={componentOptions}
|
|
126
|
+
/>
|
|
85
127
|
) : null}
|
|
86
128
|
</>
|
|
87
129
|
);
|
|
@@ -125,6 +125,16 @@ SelectedFirst.args = {
|
|
|
125
125
|
showSelectedFirst: true,
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
+
export const CustomColumnsData = Template.bind({});
|
|
129
|
+
CustomColumnsData.args = {
|
|
130
|
+
columns: 2,
|
|
131
|
+
columnsGap: '50px',
|
|
132
|
+
minColumnWidth: '100px',
|
|
133
|
+
maxColumnWidth: '200px',
|
|
134
|
+
items,
|
|
135
|
+
label: '2 columns of max 200px width with 50px gap',
|
|
136
|
+
};
|
|
137
|
+
|
|
128
138
|
export const CustomPropsAndTexts = Template.bind({});
|
|
129
139
|
CustomPropsAndTexts.args = {
|
|
130
140
|
label: 'Collection of items',
|
|
@@ -20,11 +20,15 @@ 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={args.scrollToTopOnPageChange ? scrollContainer : undefined}
|
|
31
|
+
/>
|
|
28
32
|
</ReqoreControlGroup>
|
|
29
33
|
);
|
|
30
34
|
};
|