@qoretechnologies/reqore 0.32.3 → 0.34.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/__tests__/collection.test.tsx +144 -5
- package/__tests__/containers/paging.test.tsx +106 -0
- package/__tests__/hooks/useLatestZIndex.test.tsx +10 -0
- package/__tests__/hooks/useReqorePaging.test.tsx +255 -0
- package/__tests__/hooks/useTheme.test.tsx +31 -0
- package/__tests__/pagination.test.tsx +305 -0
- package/__tests__/popover.test.tsx +20 -6
- package/__tests__/setup.js +8 -0
- package/__tests__/tree.test.tsx +0 -1
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +11 -7
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Collection/index.d.ts +4 -3
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +31 -13
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +9 -2
- package/dist/components/Dropdown/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/Dropdown/list.d.ts +6 -1
- package/dist/components/Dropdown/list.d.ts.map +1 -1
- package/dist/components/Dropdown/list.js +13 -5
- package/dist/components/Dropdown/list.js.map +1 -1
- package/dist/components/Menu/index.d.ts +1 -0
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +4 -1
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/item.d.ts +1 -0
- package/dist/components/Menu/item.d.ts.map +1 -1
- package/dist/components/Menu/item.js +14 -2
- package/dist/components/Menu/item.js.map +1 -1
- package/dist/components/MultiSelect/index.d.ts +1 -1
- package/dist/components/MultiSelect/index.d.ts.map +1 -1
- package/dist/components/Paging/index.d.ts +32 -0
- package/dist/components/Paging/index.d.ts.map +1 -0
- package/dist/components/Paging/index.js +127 -0
- package/dist/components/Paging/index.js.map +1 -0
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +2 -2
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/Tag/index.d.ts +3 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +10 -7
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/constants/colors.d.ts +2 -9
- package/dist/constants/colors.d.ts.map +1 -1
- package/dist/constants/colors.js +3 -1
- package/dist/constants/colors.js.map +1 -1
- package/dist/constants/paging.d.ts +17 -0
- package/dist/constants/paging.d.ts.map +1 -0
- package/dist/constants/paging.js +45 -0
- package/dist/constants/paging.js.map +1 -0
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js +8 -7
- package/dist/constants/theme.js.map +1 -1
- package/dist/containers/Paging.d.ts +15 -0
- package/dist/containers/Paging.d.ts.map +1 -0
- package/dist/containers/Paging.js +51 -0
- package/dist/containers/Paging.js.map +1 -0
- package/dist/containers/ReqoreProvider.d.ts.map +1 -1
- package/dist/containers/ReqoreProvider.js +2 -2
- package/dist/containers/ReqoreProvider.js.map +1 -1
- package/dist/containers/UIProvider.d.ts.map +1 -1
- package/dist/containers/UIProvider.js +9 -3
- package/dist/containers/UIProvider.js.map +1 -1
- package/dist/hooks/useCombinedRefs.d.ts +2 -2
- package/dist/hooks/useCombinedRefs.d.ts.map +1 -1
- package/dist/hooks/useCombinedRefs.js.map +1 -1
- package/dist/hooks/usePaging.d.ts +28 -0
- package/dist/hooks/usePaging.d.ts.map +1 -0
- package/dist/hooks/usePaging.js +85 -0
- package/dist/hooks/usePaging.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/components/Button/index.tsx +18 -10
- package/src/components/Collection/index.tsx +78 -49
- package/src/components/ControlGroup/index.tsx +1 -1
- package/src/components/Dropdown/index.tsx +27 -12
- package/src/components/Dropdown/list.tsx +49 -24
- package/src/components/Menu/index.tsx +3 -2
- package/src/components/Menu/item.tsx +16 -2
- package/src/components/MultiSelect/index.tsx +1 -1
- package/src/components/Paging/index.tsx +260 -0
- package/src/components/Panel/index.tsx +4 -1
- package/src/components/Tag/index.tsx +9 -7
- package/src/constants/colors.ts +5 -1
- package/src/constants/paging.ts +67 -0
- package/src/constants/theme.ts +8 -7
- package/src/containers/Paging.tsx +90 -0
- package/src/containers/ReqoreProvider.tsx +3 -3
- package/src/containers/UIProvider.tsx +17 -4
- package/src/hooks/useCombinedRefs.ts +2 -2
- package/src/hooks/usePaging.ts +114 -0
- package/src/index.tsx +3 -0
- package/src/mock/collectionData.tsx +19 -0
- package/src/mock/tableData.ts +1 -0
- package/src/stories/Button/Button.stories.tsx +25 -8
- package/src/stories/Collection/Collection.stories.tsx +51 -42
- package/src/stories/Dropdown/Dropdown.stories.tsx +71 -29
- package/src/stories/Menu/Menu.stories.tsx +4 -0
- package/src/stories/Paging/Paging.stories.tsx +202 -0
- package/src/stories/Tag/Tag.stories.tsx +50 -0
- package/tests.json +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { merge, size } from 'lodash';
|
|
2
|
+
import { useEffect, useMemo } from 'react';
|
|
3
|
+
import { useUpdateEffect } from 'react-use';
|
|
4
|
+
import usePagination, { usePaginationReturn } from 'react-use-pagination-hook';
|
|
5
|
+
|
|
6
|
+
export interface IReqorePagingOptions<T> {
|
|
7
|
+
items: T[];
|
|
8
|
+
startPage?: number;
|
|
9
|
+
pagesToShow?: number;
|
|
10
|
+
itemsPerPage?: number;
|
|
11
|
+
infinite?: boolean;
|
|
12
|
+
enabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IReqorePagingResult<T>
|
|
16
|
+
extends Pick<usePaginationReturn, 'setPage' | 'currentPage'> {
|
|
17
|
+
pages: number[];
|
|
18
|
+
allPages: number[];
|
|
19
|
+
items: T[];
|
|
20
|
+
itemsPerPage: number;
|
|
21
|
+
itemsLeft: number;
|
|
22
|
+
isLastPage: boolean;
|
|
23
|
+
isFirstPage: boolean;
|
|
24
|
+
next: usePaginationReturn['goNext'];
|
|
25
|
+
back: usePaginationReturn['goBefore'];
|
|
26
|
+
first: () => void;
|
|
27
|
+
last: () => void;
|
|
28
|
+
pageCount: number;
|
|
29
|
+
infinite: boolean;
|
|
30
|
+
renderControls: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const defaultPagingOptions: IReqorePagingOptions<any> = {
|
|
34
|
+
items: [],
|
|
35
|
+
itemsPerPage: 10,
|
|
36
|
+
infinite: false,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const useReqorePaging = <T>(
|
|
40
|
+
options: IReqorePagingOptions<T> = defaultPagingOptions
|
|
41
|
+
): IReqorePagingResult<T> => {
|
|
42
|
+
const {
|
|
43
|
+
items,
|
|
44
|
+
itemsPerPage,
|
|
45
|
+
infinite,
|
|
46
|
+
pagesToShow,
|
|
47
|
+
startPage,
|
|
48
|
+
enabled = true,
|
|
49
|
+
}: IReqorePagingOptions<T> = merge({}, defaultPagingOptions, options);
|
|
50
|
+
const allPageCount = useMemo(() => Math.ceil(size(items) / itemsPerPage), [items, itemsPerPage]);
|
|
51
|
+
const { pagelist, currentPage, setPage, setTotalPage, goNext, goBefore } = usePagination({
|
|
52
|
+
numOfPage: allPageCount,
|
|
53
|
+
totalPage: allPageCount,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setPage(startPage || 1);
|
|
58
|
+
}, [startPage]);
|
|
59
|
+
|
|
60
|
+
useUpdateEffect(() => {
|
|
61
|
+
setPage(1);
|
|
62
|
+
setTotalPage(Math.ceil(size(items) / itemsPerPage));
|
|
63
|
+
}, [size(items), itemsPerPage]);
|
|
64
|
+
|
|
65
|
+
const slicedItems: T[] = useMemo(() => {
|
|
66
|
+
return items.slice(infinite ? 0 : (currentPage - 1) * itemsPerPage, currentPage * itemsPerPage);
|
|
67
|
+
}, [items, currentPage, itemsPerPage, infinite]);
|
|
68
|
+
|
|
69
|
+
const pages: number[] = useMemo(() => {
|
|
70
|
+
if (!pagesToShow || pagesToShow >= allPageCount) {
|
|
71
|
+
return pagelist;
|
|
72
|
+
}
|
|
73
|
+
// Get the middle of the desired page count
|
|
74
|
+
const middle = Math.ceil(pagesToShow / 2);
|
|
75
|
+
// Get the start number of the pages to show
|
|
76
|
+
// If the current page is the last page, we need to subtract the number of pages to show from the total number of pages
|
|
77
|
+
const start =
|
|
78
|
+
currentPage === allPageCount ? allPageCount - pagesToShow : Math.max(currentPage - middle, 0);
|
|
79
|
+
// Get the end number of the pages to show
|
|
80
|
+
// If the start number is 0, we need to add the number of pages to show to the total number of pages
|
|
81
|
+
const end = Math.min(start + pagesToShow, allPageCount);
|
|
82
|
+
|
|
83
|
+
let newPages = pagelist.slice(start, end);
|
|
84
|
+
// Always remove the first page
|
|
85
|
+
newPages = newPages.filter((page) => page !== 1);
|
|
86
|
+
// Always remove the last page
|
|
87
|
+
newPages = newPages.filter((page) => page !== allPageCount);
|
|
88
|
+
// Add the first and last page
|
|
89
|
+
newPages = [1, ...newPages, allPageCount];
|
|
90
|
+
|
|
91
|
+
return newPages;
|
|
92
|
+
}, [pagesToShow, allPageCount, currentPage, pagelist]);
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
pages,
|
|
96
|
+
allPages: pagelist,
|
|
97
|
+
pageCount: allPageCount,
|
|
98
|
+
items: enabled ? slicedItems : items,
|
|
99
|
+
itemsPerPage,
|
|
100
|
+
itemsLeft: items.length - slicedItems.length,
|
|
101
|
+
infinite,
|
|
102
|
+
setPage,
|
|
103
|
+
currentPage,
|
|
104
|
+
next: goNext,
|
|
105
|
+
back: goBefore,
|
|
106
|
+
renderControls:
|
|
107
|
+
enabled &&
|
|
108
|
+
!(allPageCount === 1 || allPageCount === 0 || (infinite && currentPage === allPageCount)),
|
|
109
|
+
isLastPage: currentPage === allPageCount,
|
|
110
|
+
isFirstPage: currentPage === 1,
|
|
111
|
+
first: () => setPage(1),
|
|
112
|
+
last: () => setPage(allPageCount),
|
|
113
|
+
};
|
|
114
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -37,6 +37,7 @@ export { default as ReqoreNavbarGroup } from './components/Navbar/group';
|
|
|
37
37
|
export { default as ReqoreNavbarItem } from './components/Navbar/item';
|
|
38
38
|
export { default as ReqoreNotificationsWrapper } from './components/Notifications';
|
|
39
39
|
export { default as ReqoreNotification } from './components/Notifications/notification';
|
|
40
|
+
export { ReqorePagination } from './components/Paging';
|
|
40
41
|
export { ReqorePanel } from './components/Panel';
|
|
41
42
|
export { ReqoreP, ReqoreP as ReqoreParagraph } from './components/Paragraph';
|
|
42
43
|
export { default as ReqorePopover } from './components/Popover';
|
|
@@ -57,11 +58,13 @@ export { ReqoreTree } from './components/Tree';
|
|
|
57
58
|
export { Colors as ReqoreColors } from './constants/colors';
|
|
58
59
|
export { ReqoreSizes } from './constants/sizes';
|
|
59
60
|
export { ReqoreIntents } from './constants/theme';
|
|
61
|
+
export { ReqorePaginationContainer } from './containers/Paging';
|
|
60
62
|
export { default as ReqoreNotifications } from './containers/ReqoreProvider';
|
|
61
63
|
export { default as ReqoreUIProvider } from './containers/UIProvider';
|
|
62
64
|
export { default as ReqoreContext } from './context/ReqoreContext';
|
|
63
65
|
export { default as ReqoreThemeContext } from './context/ThemeContext';
|
|
64
66
|
export { default as useLatestZIndex } from './hooks/useLatestZIndex';
|
|
67
|
+
export { useReqorePaging } from './hooks/usePaging';
|
|
65
68
|
export { useReqore } from './hooks/useReqore';
|
|
66
69
|
export { useReqoreProperty } from './hooks/useReqoreContext';
|
|
67
70
|
export { useReqoreTheme } from './hooks/useTheme';
|
|
@@ -5,6 +5,25 @@ import ReqoreMessage from '../components/Message';
|
|
|
5
5
|
import { ReqoreP } from '../components/Paragraph';
|
|
6
6
|
import { ReqoreSpacer } from '../components/Spacer';
|
|
7
7
|
import ReqoreTag from '../components/Tag';
|
|
8
|
+
import data from './data.json';
|
|
9
|
+
|
|
10
|
+
export const bigCollection = data.slice(0, 100).map((datum) => ({
|
|
11
|
+
label: `${datum.firstName} ${datum.lastName}`,
|
|
12
|
+
badge: datum.id,
|
|
13
|
+
size: 'small',
|
|
14
|
+
expandable: true,
|
|
15
|
+
content: datum.address,
|
|
16
|
+
tags: [
|
|
17
|
+
{
|
|
18
|
+
labelKey: 'Age',
|
|
19
|
+
label: datum.age,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
labelKey: 'Occupation',
|
|
23
|
+
label: datum.occupation,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
})) as IReqoreCollectionItemProps[];
|
|
8
27
|
|
|
9
28
|
export default [
|
|
10
29
|
{
|
package/src/mock/tableData.ts
CHANGED
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
|
|
20
20
|
const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
21
21
|
return (
|
|
22
|
-
|
|
22
|
+
<ReqoreControlGroup vertical gapSize='big'>
|
|
23
23
|
<ReqoreControlGroup size={buttonProps.size} wrap>
|
|
24
24
|
<ReqoreButton {...buttonProps} icon='BankFill' rightIcon={null} />
|
|
25
25
|
<ReqoreButton {...buttonProps} />
|
|
@@ -27,7 +27,7 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
27
27
|
{...buttonProps}
|
|
28
28
|
icon='BankFill'
|
|
29
29
|
rightIcon={null}
|
|
30
|
-
|
|
30
|
+
iconsAlign='center'
|
|
31
31
|
style={{ width: '100px' }}
|
|
32
32
|
/>
|
|
33
33
|
<ReqoreButton {...buttonProps}>Default</ReqoreButton>
|
|
@@ -47,7 +47,6 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
47
47
|
Read only
|
|
48
48
|
</ReqoreButton>
|
|
49
49
|
</ReqoreControlGroup>
|
|
50
|
-
<br />
|
|
51
50
|
<ReqoreControlGroup size={buttonProps.size} wrap>
|
|
52
51
|
<ReqoreButton {...buttonProps} active flat={false} tooltip='hello'>
|
|
53
52
|
Active Not Flat
|
|
@@ -72,13 +71,33 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
72
71
|
Disabled not flat
|
|
73
72
|
</ReqoreButton>
|
|
74
73
|
</ReqoreControlGroup>
|
|
75
|
-
<br />
|
|
76
74
|
<ReqoreControlGroup fluid wrap>
|
|
77
75
|
<ReqoreButton {...buttonProps} fluid>
|
|
78
76
|
Fluid button
|
|
79
77
|
</ReqoreButton>
|
|
80
78
|
</ReqoreControlGroup>
|
|
81
|
-
<
|
|
79
|
+
<ReqoreControlGroup fluid wrap>
|
|
80
|
+
<ReqoreButton {...buttonProps} fluid textAlign='center'>
|
|
81
|
+
Fluid button with centered text
|
|
82
|
+
</ReqoreButton>
|
|
83
|
+
</ReqoreControlGroup>
|
|
84
|
+
<ReqoreControlGroup fluid wrap>
|
|
85
|
+
<ReqoreButton {...buttonProps} fluid textAlign='center' iconsAlign='center'>
|
|
86
|
+
Fluid button with centered text & icons
|
|
87
|
+
</ReqoreButton>
|
|
88
|
+
<ReqoreButton
|
|
89
|
+
{...buttonProps}
|
|
90
|
+
rightIcon={null}
|
|
91
|
+
fluid
|
|
92
|
+
textAlign='center'
|
|
93
|
+
iconsAlign='center'
|
|
94
|
+
>
|
|
95
|
+
Fluid button with centered text & icons
|
|
96
|
+
</ReqoreButton>
|
|
97
|
+
<ReqoreButton {...buttonProps} icon={null} fluid textAlign='center' iconsAlign='center'>
|
|
98
|
+
Fluid button with centered text & icons
|
|
99
|
+
</ReqoreButton>
|
|
100
|
+
</ReqoreControlGroup>
|
|
82
101
|
<ReqoreControlGroup fluid wrap>
|
|
83
102
|
<ReqoreButton {...buttonProps}>Left text</ReqoreButton>
|
|
84
103
|
<ReqoreButton
|
|
@@ -112,7 +131,6 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
112
131
|
Right text
|
|
113
132
|
</ReqoreButton>
|
|
114
133
|
</ReqoreControlGroup>
|
|
115
|
-
<br />
|
|
116
134
|
<ReqoreControlGroup wrap>
|
|
117
135
|
<ReqoreButton
|
|
118
136
|
{...buttonProps}
|
|
@@ -171,7 +189,6 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
171
189
|
wrap
|
|
172
190
|
/>
|
|
173
191
|
</ReqoreControlGroup>
|
|
174
|
-
<br />
|
|
175
192
|
<ReqoreControlGroup wrap>
|
|
176
193
|
<ReqoreButton {...buttonProps} readOnly badge={10} onClick={alert}>
|
|
177
194
|
Read only with badge
|
|
@@ -225,7 +242,7 @@ const Template: ComponentStory<typeof ReqoreButton> = (buttonProps) => {
|
|
|
225
242
|
With modified Badge
|
|
226
243
|
</ReqoreButton>
|
|
227
244
|
</ReqoreControlGroup>
|
|
228
|
-
|
|
245
|
+
</ReqoreControlGroup>
|
|
229
246
|
);
|
|
230
247
|
};
|
|
231
248
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react';
|
|
2
|
-
import { ReqoreButton, ReqoreControlGroup } from '../..';
|
|
2
|
+
import { ReqoreButton, ReqoreControlGroup, ReqoreVerticalSpacer } from '../..';
|
|
3
3
|
import { IReqoreCollectionProps, ReqoreCollection } from '../../components/Collection';
|
|
4
4
|
import { IReqoreColumnsProps } from '../../components/Columns';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
5
|
+
import { PADDING_FROM_SIZE } from '../../constants/sizes';
|
|
6
|
+
import items, { bigCollection } from '../../mock/collectionData';
|
|
7
|
+
|
|
8
|
+
import { argManager, IntentArg, SizeArg } from '../utils/args';
|
|
8
9
|
|
|
9
10
|
export interface IColumnsStoryArgs extends IReqoreColumnsProps {
|
|
10
11
|
multipleColumns?: boolean;
|
|
@@ -143,34 +144,38 @@ export const ChildrenBeforeAndAfter = Template.bind({});
|
|
|
143
144
|
ChildrenBeforeAndAfter.args = {
|
|
144
145
|
label: 'Collection of items',
|
|
145
146
|
items,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
<
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
147
|
+
contentRenderer: (children) => (
|
|
148
|
+
<>
|
|
149
|
+
<ReqoreControlGroup horizontalAlign='center' fluid>
|
|
150
|
+
<ReqoreButton fluid> I could be a filter of some kind</ReqoreButton>
|
|
151
|
+
</ReqoreControlGroup>
|
|
152
|
+
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />
|
|
153
|
+
{children}
|
|
154
|
+
<ReqoreVerticalSpacer height={PADDING_FROM_SIZE.normal} />
|
|
155
|
+
<ReqoreControlGroup horizontalAlign='center' fluid>
|
|
156
|
+
<ReqoreControlGroup fluid={false} fixed>
|
|
157
|
+
<ReqoreButton fixed textAlign='center'>
|
|
158
|
+
1
|
|
159
|
+
</ReqoreButton>
|
|
160
|
+
<ReqoreButton fixed textAlign='center'>
|
|
161
|
+
2
|
|
162
|
+
</ReqoreButton>
|
|
163
|
+
<ReqoreButton fixed textAlign='center'>
|
|
164
|
+
3
|
|
165
|
+
</ReqoreButton>
|
|
166
|
+
<ReqoreButton fixed textAlign='center'>
|
|
167
|
+
4
|
|
168
|
+
</ReqoreButton>
|
|
169
|
+
</ReqoreControlGroup>
|
|
166
170
|
</ReqoreControlGroup>
|
|
167
|
-
|
|
171
|
+
</>
|
|
168
172
|
),
|
|
169
173
|
};
|
|
170
174
|
|
|
171
175
|
export const FilteringSearchingPaging = Template.bind({});
|
|
172
176
|
FilteringSearchingPaging.args = {
|
|
173
177
|
inputProps: {
|
|
178
|
+
fluid: true,
|
|
174
179
|
focusRules: {
|
|
175
180
|
type: 'keypress',
|
|
176
181
|
shortcut: 'letters',
|
|
@@ -183,24 +188,28 @@ FilteringSearchingPaging.args = {
|
|
|
183
188
|
sortButtonProps: {
|
|
184
189
|
fixed: false,
|
|
185
190
|
},
|
|
191
|
+
paging: 'buttons',
|
|
186
192
|
size: 'big',
|
|
187
193
|
padded: false,
|
|
188
194
|
fill: true,
|
|
189
|
-
items:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
195
|
+
items: bigCollection,
|
|
196
|
+
} as IReqoreCollectionProps;
|
|
197
|
+
|
|
198
|
+
export const CustomFilteringSearchingPaging = Template.bind({});
|
|
199
|
+
CustomFilteringSearchingPaging.args = {
|
|
200
|
+
inputProps: {
|
|
201
|
+
fluid: true,
|
|
202
|
+
focusRules: {
|
|
203
|
+
type: 'auto',
|
|
204
|
+
clearOnFocus: true,
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
paging: {
|
|
208
|
+
itemsPerPage: 25,
|
|
209
|
+
scrollToTopOnPageChange: true,
|
|
210
|
+
},
|
|
211
|
+
size: 'small',
|
|
212
|
+
padded: false,
|
|
213
|
+
height: '300px',
|
|
214
|
+
items: bigCollection,
|
|
206
215
|
} as IReqoreCollectionProps;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/react/types-6-0';
|
|
2
|
-
import { useState } from 'react';
|
|
3
2
|
import ReqoreButton from '../../components/Button';
|
|
4
3
|
import { IReqoreDropdownProps } from '../../components/Dropdown';
|
|
5
|
-
import { ReqoreControlGroup, ReqoreDropdown, ReqoreInput
|
|
4
|
+
import { ReqoreControlGroup, ReqoreDropdown, ReqoreInput } from '../../index';
|
|
6
5
|
import { argManager } from '../utils/args';
|
|
7
6
|
|
|
8
7
|
const { createArg, disableArg } = argManager<IReqoreDropdownProps>();
|
|
@@ -11,7 +10,7 @@ export default {
|
|
|
11
10
|
title: 'Components/Dropdown',
|
|
12
11
|
parameters: {
|
|
13
12
|
chromatic: {
|
|
14
|
-
delay:
|
|
13
|
+
delay: 1500,
|
|
15
14
|
},
|
|
16
15
|
},
|
|
17
16
|
argTypes: {
|
|
@@ -130,30 +129,25 @@ export default {
|
|
|
130
129
|
} as Meta<IReqoreDropdownProps>;
|
|
131
130
|
|
|
132
131
|
const Template: Story<IReqoreDropdownProps> = (args: IReqoreDropdownProps) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (args.multiSelect) {
|
|
132
|
+
if (args.scrollToSelected || args.paging) {
|
|
136
133
|
return (
|
|
137
|
-
|
|
138
|
-
<
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
))}
|
|
155
|
-
</ReqoreControlGroup>
|
|
156
|
-
</>
|
|
134
|
+
<ReqoreControlGroup>
|
|
135
|
+
<ReqoreDropdown
|
|
136
|
+
{...args}
|
|
137
|
+
label={args.label}
|
|
138
|
+
isDefaultOpen
|
|
139
|
+
filterable
|
|
140
|
+
scrollToSelected={args.scrollToSelected}
|
|
141
|
+
paging={args.paging}
|
|
142
|
+
items={Array(130)
|
|
143
|
+
.fill(null)
|
|
144
|
+
.map((_, i) => ({
|
|
145
|
+
label: `Item ${i}`,
|
|
146
|
+
value: `item-${i}`,
|
|
147
|
+
selected: i === 55,
|
|
148
|
+
}))}
|
|
149
|
+
/>
|
|
150
|
+
</ReqoreControlGroup>
|
|
157
151
|
);
|
|
158
152
|
}
|
|
159
153
|
|
|
@@ -226,7 +220,55 @@ CustomComponent.args = {
|
|
|
226
220
|
component: ReqoreInput,
|
|
227
221
|
placeholder: 'Custom component',
|
|
228
222
|
};
|
|
229
|
-
export const
|
|
230
|
-
|
|
231
|
-
|
|
223
|
+
export const ScrollToSelectedItem = Template.bind({});
|
|
224
|
+
ScrollToSelectedItem.args = {
|
|
225
|
+
scrollToSelected: true,
|
|
226
|
+
label: 'Dropdown that scrolls to selected item',
|
|
227
|
+
};
|
|
228
|
+
export const WithPaging: Story<IReqoreDropdownProps> = Template.bind({});
|
|
229
|
+
WithPaging.args = {
|
|
230
|
+
paging: {
|
|
231
|
+
itemsPerPage: 50,
|
|
232
|
+
},
|
|
233
|
+
label: 'Dropdown with paging',
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export const WithLoadMore: Story<IReqoreDropdownProps> = Template.bind({});
|
|
237
|
+
WithLoadMore.args = {
|
|
238
|
+
paging: {
|
|
239
|
+
fluid: true,
|
|
240
|
+
infinite: true,
|
|
241
|
+
scrollOnLoadMore: true,
|
|
242
|
+
loadMoreLabel: 'Load additional items...',
|
|
243
|
+
showLabels: true,
|
|
244
|
+
includeBottomControls: false,
|
|
245
|
+
},
|
|
246
|
+
label: 'Dropdown with load more',
|
|
232
247
|
};
|
|
248
|
+
|
|
249
|
+
export const WithCustomPaging: Story<IReqoreDropdownProps> = Template.bind({});
|
|
250
|
+
WithCustomPaging.args = {
|
|
251
|
+
paging: {
|
|
252
|
+
fluid: true,
|
|
253
|
+
infinite: true,
|
|
254
|
+
scrollOnLoadMore: true,
|
|
255
|
+
pageControlsPosition: 'both',
|
|
256
|
+
loadMoreLabel: 'Load additional items...',
|
|
257
|
+
showLabels: true,
|
|
258
|
+
loadMoreButtonProps: {
|
|
259
|
+
textAlign: 'center',
|
|
260
|
+
effect: {
|
|
261
|
+
gradient: {
|
|
262
|
+
colors: 'info',
|
|
263
|
+
animate: 'hover',
|
|
264
|
+
},
|
|
265
|
+
textSize: 'small',
|
|
266
|
+
uppercase: true,
|
|
267
|
+
spaced: 3,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
label: 'Dropdown with custom paging',
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
WithCustomPaging.play = () => {};
|
|
@@ -192,6 +192,10 @@ export const Minimal = Template.bind({});
|
|
|
192
192
|
Minimal.args = {
|
|
193
193
|
minimal: true,
|
|
194
194
|
};
|
|
195
|
+
export const NoPadding = Template.bind({});
|
|
196
|
+
NoPadding.args = {
|
|
197
|
+
padded: false,
|
|
198
|
+
};
|
|
195
199
|
export const NotFlat = Template.bind({});
|
|
196
200
|
NotFlat.args = {
|
|
197
201
|
flat: false,
|