@qoretechnologies/reqore 0.34.3 → 0.34.5
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__/collection.test.tsx +30 -0
- package/__tests__/drawer.test.tsx +1 -1
- package/__tests__/dropdown.test.tsx +5 -2
- 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/__tests__/stories/Collection.stories.tsx +0 -0
- 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.d.ts.map +1 -1
- package/dist/components/Collection/index.js +1 -1
- 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 +4 -4
- 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/index.d.ts.map +1 -1
- package/dist/components/Dropdown/index.js +5 -1
- package/dist/components/Dropdown/index.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 +31 -1
- 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 +36 -20
- 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 +2 -1
- package/dist/containers/Paging.d.ts.map +1 -1
- 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 +1 -0
- package/src/components/ControlGroup/index.tsx +3 -2
- package/src/components/Drawer/index.tsx +4 -10
- package/src/components/Dropdown/index.tsx +28 -15
- package/src/components/Header/index.tsx +9 -3
- package/src/components/Paging/index.tsx +37 -1
- package/src/components/Panel/NonResponsiveActions.tsx +79 -0
- package/src/components/Panel/index.tsx +129 -76
- package/src/components/Tag/group.tsx +1 -1
- package/src/containers/Paging.tsx +7 -3
- 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 +17 -1
- package/src/stories/Panel/Panel.stories.tsx +13 -3
- package/tests.json +1 -1
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
|
|
|
@@ -27,7 +27,9 @@ const Template: Story<IReqorePaginationProps<any> & { pagingOptions?: IReqorePag
|
|
|
27
27
|
<ReqorePagination<any>
|
|
28
28
|
{...paging}
|
|
29
29
|
{...args}
|
|
30
|
-
scrollContainer={
|
|
30
|
+
scrollContainer={
|
|
31
|
+
args.scrollToTopOnPageChange || !!args.changePageOnScroll ? scrollContainer : undefined
|
|
32
|
+
}
|
|
31
33
|
/>
|
|
32
34
|
</ReqoreControlGroup>
|
|
33
35
|
);
|
|
@@ -142,6 +144,20 @@ WithLabels.args = {
|
|
|
142
144
|
} as IReqorePagingOptions<any>,
|
|
143
145
|
};
|
|
144
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
|
+
|
|
145
161
|
export const ScrollToTop: Story<
|
|
146
162
|
IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
|
|
147
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({});
|