@qoretechnologies/reqore 0.33.0 → 0.34.1
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 +22 -1
- package/__tests__/containers/paging.test.tsx +106 -0
- package/__tests__/hooks/useReqorePaging.test.tsx +4 -0
- package/__tests__/pagination.test.tsx +4 -0
- package/dist/components/Collection/index.d.ts +5 -9
- package/dist/components/Collection/index.d.ts.map +1 -1
- package/dist/components/Collection/index.js +30 -21
- package/dist/components/Collection/index.js.map +1 -1
- package/dist/components/Dropdown/index.d.ts +5 -1
- 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 +3 -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/Paging/index.d.ts +3 -1
- package/dist/components/Paging/index.d.ts.map +1 -1
- package/dist/components/Paging/index.js +31 -10
- package/dist/components/Paging/index.js.map +1 -1
- 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 +16 -9
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/constants/paging.d.ts +11 -4
- package/dist/constants/paging.d.ts.map +1 -1
- package/dist/constants/paging.js +7 -3
- package/dist/constants/paging.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/hooks/usePaging.d.ts +1 -0
- package/dist/hooks/usePaging.d.ts.map +1 -1
- package/dist/hooks/usePaging.js +2 -0
- package/dist/hooks/usePaging.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Collection/index.tsx +94 -89
- package/src/components/Dropdown/index.tsx +21 -12
- package/src/components/Dropdown/list.tsx +43 -24
- package/src/components/Menu/index.tsx +3 -2
- package/src/components/Paging/index.tsx +32 -4
- package/src/components/Panel/index.tsx +27 -16
- package/src/constants/paging.ts +27 -8
- package/src/containers/Paging.tsx +90 -0
- package/src/hooks/usePaging.ts +4 -0
- package/src/index.tsx +1 -0
- package/src/stories/Collection/Collection.stories.tsx +23 -2
- package/src/stories/Dropdown/Dropdown.stories.tsx +54 -35
- package/src/stories/Menu/Menu.stories.tsx +4 -0
- package/src/stories/Paging/Paging.stories.tsx +19 -1
- package/src/stories/Panel/Panel.stories.tsx +18 -1
- package/tests.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { size } from 'lodash';
|
|
2
2
|
import { darken, rgba } from 'polished';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactElement, forwardRef, useCallback, useMemo, useState } from 'react';
|
|
4
4
|
import { useUpdateEffect } from 'react-use';
|
|
5
5
|
import styled, { css } from 'styled-components';
|
|
6
6
|
import {
|
|
@@ -103,6 +103,7 @@ export interface IReqorePanelProps
|
|
|
103
103
|
iconColor?: TReqoreEffectColor;
|
|
104
104
|
responsiveActions?: boolean;
|
|
105
105
|
responsiveTitle?: boolean;
|
|
106
|
+
getContentRef?: (ref: HTMLDivElement) => any;
|
|
106
107
|
}
|
|
107
108
|
|
|
108
109
|
export interface IStyledPanel extends IReqorePanelProps {
|
|
@@ -298,6 +299,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
298
299
|
responsiveActions = true,
|
|
299
300
|
responsiveTitle = true,
|
|
300
301
|
size: panelSize = 'normal',
|
|
302
|
+
getContentRef,
|
|
301
303
|
...rest
|
|
302
304
|
}: IReqorePanelProps,
|
|
303
305
|
ref
|
|
@@ -370,9 +372,10 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
370
372
|
);
|
|
371
373
|
|
|
372
374
|
const renderResponsiveActions = useCallback(
|
|
373
|
-
(
|
|
374
|
-
|
|
375
|
-
|
|
375
|
+
(align: 'flex-start' | 'center' | 'flex-end' = 'flex-end') =>
|
|
376
|
+
(action: IReqorePanelAction, index: number) => {
|
|
377
|
+
return renderActions(action, index, true, align);
|
|
378
|
+
},
|
|
376
379
|
[actions]
|
|
377
380
|
);
|
|
378
381
|
|
|
@@ -389,14 +392,20 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
389
392
|
);
|
|
390
393
|
|
|
391
394
|
const renderNonResponsiveActions = useCallback(
|
|
392
|
-
(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
+
(align: 'flex-start' | 'center' | 'flex-end' = 'flex-end') =>
|
|
396
|
+
(action: IReqorePanelAction, index: number) => {
|
|
397
|
+
return renderActions(action, index, false, align);
|
|
398
|
+
},
|
|
395
399
|
[actions]
|
|
396
400
|
);
|
|
397
401
|
|
|
398
402
|
const renderActions = useCallback(
|
|
399
|
-
(
|
|
403
|
+
(
|
|
404
|
+
action: IReqorePanelAction,
|
|
405
|
+
index: number,
|
|
406
|
+
includeResponsive,
|
|
407
|
+
align: 'flex-start' | 'center' | 'flex-end' = 'flex-end'
|
|
408
|
+
) => {
|
|
400
409
|
if (
|
|
401
410
|
action.show === false ||
|
|
402
411
|
(includeResponsive && action.responsive === false) ||
|
|
@@ -427,6 +436,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
427
436
|
fixed={rest.fixed}
|
|
428
437
|
fluid={rest.fluid}
|
|
429
438
|
key={index}
|
|
439
|
+
horizontalAlign={align}
|
|
430
440
|
>
|
|
431
441
|
{group.map((action, index) => renderActions(action, index, true))}
|
|
432
442
|
</ReqoreControlGroup>
|
|
@@ -596,18 +606,18 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
596
606
|
customTheme={theme}
|
|
597
607
|
size={panelSize}
|
|
598
608
|
>
|
|
599
|
-
{actions.map(renderResponsiveActions)}
|
|
609
|
+
{actions.map(renderResponsiveActions())}
|
|
600
610
|
</ReqoreControlGroup>
|
|
601
611
|
)}
|
|
602
612
|
{collapsible || onClose || hasNonResponsiveActions(actions) ? (
|
|
603
613
|
<>
|
|
604
614
|
<ReqoreControlGroup
|
|
605
|
-
fixed={
|
|
606
|
-
fluid={isMobile}
|
|
615
|
+
fixed={isMobile ? false : hasResponsiveActions(actions)}
|
|
616
|
+
fluid={isMobile ? true : !hasResponsiveActions(actions)}
|
|
607
617
|
horizontalAlign='flex-end'
|
|
608
618
|
size={panelSize}
|
|
609
619
|
>
|
|
610
|
-
{actions.map(renderNonResponsiveActions)}
|
|
620
|
+
{actions.map(renderNonResponsiveActions())}
|
|
611
621
|
{collapsible && (
|
|
612
622
|
<ReqoreButton
|
|
613
623
|
customTheme={theme}
|
|
@@ -643,6 +653,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
643
653
|
padded={padded}
|
|
644
654
|
minimal={minimal}
|
|
645
655
|
size={contentSize || panelSize}
|
|
656
|
+
ref={getContentRef}
|
|
646
657
|
noHorizontalPadding={noHorizontalPadding}
|
|
647
658
|
>
|
|
648
659
|
{children}
|
|
@@ -659,7 +670,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
659
670
|
>
|
|
660
671
|
{hasNonResponsiveActions(leftBottomActions) ? (
|
|
661
672
|
<ReqoreControlGroup size={panelSize}>
|
|
662
|
-
{leftBottomActions.map(renderNonResponsiveActions)}
|
|
673
|
+
{leftBottomActions.map(renderNonResponsiveActions('flex-start'))}
|
|
663
674
|
</ReqoreControlGroup>
|
|
664
675
|
) : null}
|
|
665
676
|
{hasResponsiveActions(leftBottomActions) && (
|
|
@@ -669,7 +680,7 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
669
680
|
customTheme={theme}
|
|
670
681
|
size={panelSize}
|
|
671
682
|
>
|
|
672
|
-
{leftBottomActions.map(renderResponsiveActions)}
|
|
683
|
+
{leftBottomActions.map(renderResponsiveActions('flex-start'))}
|
|
673
684
|
</ReqoreControlGroup>
|
|
674
685
|
)}
|
|
675
686
|
{hasResponsiveActions(rightBottomActions) && (
|
|
@@ -680,12 +691,12 @@ export const ReqorePanel = forwardRef<HTMLDivElement, IReqorePanelProps>(
|
|
|
680
691
|
customTheme={theme}
|
|
681
692
|
size={panelSize}
|
|
682
693
|
>
|
|
683
|
-
{rightBottomActions.map(renderResponsiveActions)}
|
|
694
|
+
{rightBottomActions.map(renderResponsiveActions())}
|
|
684
695
|
</ReqoreControlGroup>
|
|
685
696
|
)}
|
|
686
697
|
{hasNonResponsiveActions(rightBottomActions) ? (
|
|
687
698
|
<ReqoreControlGroup horizontalAlign='flex-end' size={panelSize}>
|
|
688
|
-
{rightBottomActions.map(renderNonResponsiveActions)}
|
|
699
|
+
{rightBottomActions.map(renderNonResponsiveActions())}
|
|
689
700
|
</ReqoreControlGroup>
|
|
690
701
|
) : null}
|
|
691
702
|
</StyledPanelBottomActions>
|
package/src/constants/paging.ts
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IReqorePaginationProps } from '../components/Paging';
|
|
1
|
+
import { IReqorePaginationComponentProps, IReqorePaginationProps } from '../components/Paging';
|
|
3
2
|
import { IReqorePagingOptions } from '../hooks/usePaging';
|
|
4
3
|
|
|
5
|
-
export type TReqorePaginationType =
|
|
6
|
-
|
|
|
4
|
+
export type TReqorePaginationType<T> =
|
|
5
|
+
| 'buttons'
|
|
7
6
|
| 'list'
|
|
8
7
|
| 'infinite'
|
|
9
8
|
| 'auto-load'
|
|
10
|
-
|
|
|
9
|
+
| IReqoreComponentPagingOptions<T>;
|
|
11
10
|
|
|
12
|
-
export
|
|
11
|
+
export interface IReqoreComponentPagingOptions<T>
|
|
12
|
+
extends Omit<IReqorePagingOptions<T>, 'items'>,
|
|
13
|
+
IReqorePaginationComponentProps {
|
|
14
|
+
pageControlsPosition?: 'top' | 'bottom' | 'both';
|
|
15
|
+
includeTopControls?: boolean;
|
|
16
|
+
includeBottomControls?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type TReqorePaginationTypeResult<T> = {
|
|
13
20
|
pagingOptions?: Omit<IReqorePagingOptions<T>, 'items'>;
|
|
14
21
|
componentOptions?: Partial<Omit<IReqorePaginationProps<T>, 'items'>>;
|
|
15
22
|
pageControlsPosition?: 'top' | 'bottom' | 'both';
|
|
16
|
-
|
|
23
|
+
includeTopControls?: boolean;
|
|
24
|
+
includeBottomControls?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export function getPaginationOptionsFromType<T>(
|
|
28
|
+
type: TReqorePaginationType<T>
|
|
29
|
+
): TReqorePaginationTypeResult<T> {
|
|
17
30
|
if (!type) return {};
|
|
18
31
|
|
|
19
32
|
if (typeof type === 'object') {
|
|
@@ -23,17 +36,21 @@ export function getPaginationOptionsFromType<T>(type: TReqorePaginationType): {
|
|
|
23
36
|
pagesToShow,
|
|
24
37
|
startPage,
|
|
25
38
|
pageControlsPosition = 'bottom',
|
|
39
|
+
includeBottomControls,
|
|
40
|
+
includeTopControls,
|
|
26
41
|
...componentOptions
|
|
27
42
|
} = type;
|
|
28
43
|
return {
|
|
29
44
|
pagingOptions: { infinite, itemsPerPage, pagesToShow, startPage },
|
|
30
45
|
pageControlsPosition,
|
|
31
46
|
componentOptions,
|
|
47
|
+
includeBottomControls,
|
|
48
|
+
includeTopControls,
|
|
32
49
|
};
|
|
33
50
|
}
|
|
34
51
|
|
|
35
52
|
switch (type) {
|
|
36
|
-
case
|
|
53
|
+
case 'buttons':
|
|
37
54
|
return {};
|
|
38
55
|
case 'list':
|
|
39
56
|
return {
|
|
@@ -44,5 +61,7 @@ export function getPaginationOptionsFromType<T>(type: TReqorePaginationType): {
|
|
|
44
61
|
case 'infinite':
|
|
45
62
|
case 'auto-load':
|
|
46
63
|
return { pagingOptions: { infinite: true } };
|
|
64
|
+
default:
|
|
65
|
+
return {};
|
|
47
66
|
}
|
|
48
67
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
|
+
import { IReqorePaginationProps, ReqorePagination } from '../components/Paging';
|
|
3
|
+
import { ReqoreVerticalSpacer } from '../components/Spacer';
|
|
4
|
+
import {
|
|
5
|
+
TReqorePaginationType,
|
|
6
|
+
TReqorePaginationTypeResult,
|
|
7
|
+
getPaginationOptionsFromType,
|
|
8
|
+
} from '../constants/paging';
|
|
9
|
+
import { PADDING_FROM_SIZE, TSizes } from '../constants/sizes';
|
|
10
|
+
import { useReqorePaging } from '../hooks/usePaging';
|
|
11
|
+
|
|
12
|
+
export interface IReqorePagingContainerProps<T> {
|
|
13
|
+
type?: TReqorePaginationType<T>;
|
|
14
|
+
items: T[];
|
|
15
|
+
scrollContainer?: HTMLElement;
|
|
16
|
+
children: (
|
|
17
|
+
items: T[],
|
|
18
|
+
Controls: React.FC<Partial<IReqorePaginationProps<T>>>,
|
|
19
|
+
options: TReqorePaginationTypeResult<T>
|
|
20
|
+
) => React.ReactNode;
|
|
21
|
+
size?: TSizes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function PagingContainer<T>({
|
|
25
|
+
type,
|
|
26
|
+
items,
|
|
27
|
+
scrollContainer,
|
|
28
|
+
children,
|
|
29
|
+
size = 'normal',
|
|
30
|
+
}: IReqorePagingContainerProps<T>) {
|
|
31
|
+
const {
|
|
32
|
+
pagingOptions = {},
|
|
33
|
+
componentOptions = {},
|
|
34
|
+
pageControlsPosition = 'bottom',
|
|
35
|
+
includeTopControls = true,
|
|
36
|
+
includeBottomControls = true,
|
|
37
|
+
} = useMemo(() => getPaginationOptionsFromType(type), [type]);
|
|
38
|
+
|
|
39
|
+
const { items: finalItems, ...pagingData } = useReqorePaging({
|
|
40
|
+
items,
|
|
41
|
+
...pagingOptions,
|
|
42
|
+
enabled: !!type,
|
|
43
|
+
});
|
|
44
|
+
|
|
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
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
{includeTopControls && (pageControlsPosition === 'top' || pageControlsPosition === 'both') ? (
|
|
71
|
+
<Controls autoLoadMore={false} scrollOnLoadMore={false} position='top' withSpacer />
|
|
72
|
+
) : null}
|
|
73
|
+
|
|
74
|
+
{children(finalItems, Controls, {
|
|
75
|
+
pagingOptions,
|
|
76
|
+
componentOptions,
|
|
77
|
+
pageControlsPosition,
|
|
78
|
+
includeTopControls,
|
|
79
|
+
includeBottomControls,
|
|
80
|
+
})}
|
|
81
|
+
|
|
82
|
+
{includeBottomControls &&
|
|
83
|
+
(pageControlsPosition === 'bottom' || pageControlsPosition === 'both') ? (
|
|
84
|
+
<Controls position='bottom' withSpacer />
|
|
85
|
+
) : null}
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const ReqorePaginationContainer = memo(PagingContainer) as typeof PagingContainer;
|
package/src/hooks/usePaging.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface IReqorePagingResult<T>
|
|
|
27
27
|
last: () => void;
|
|
28
28
|
pageCount: number;
|
|
29
29
|
infinite: boolean;
|
|
30
|
+
renderControls: boolean;
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export const defaultPagingOptions: IReqorePagingOptions<any> = {
|
|
@@ -102,6 +103,9 @@ export const useReqorePaging = <T>(
|
|
|
102
103
|
currentPage,
|
|
103
104
|
next: goNext,
|
|
104
105
|
back: goBefore,
|
|
106
|
+
renderControls:
|
|
107
|
+
enabled &&
|
|
108
|
+
!(allPageCount === 1 || allPageCount === 0 || (infinite && currentPage === allPageCount)),
|
|
105
109
|
isLastPage: currentPage === allPageCount,
|
|
106
110
|
isFirstPage: currentPage === 1,
|
|
107
111
|
first: () => setPage(1),
|
package/src/index.tsx
CHANGED
|
@@ -58,6 +58,7 @@ export { ReqoreTree } from './components/Tree';
|
|
|
58
58
|
export { Colors as ReqoreColors } from './constants/colors';
|
|
59
59
|
export { ReqoreSizes } from './constants/sizes';
|
|
60
60
|
export { ReqoreIntents } from './constants/theme';
|
|
61
|
+
export { ReqorePaginationContainer } from './containers/Paging';
|
|
61
62
|
export { default as ReqoreNotifications } from './containers/ReqoreProvider';
|
|
62
63
|
export { default as ReqoreUIProvider } from './containers/UIProvider';
|
|
63
64
|
export { default as ReqoreContext } from './context/ReqoreContext';
|
|
@@ -143,6 +143,7 @@ CustomPropsAndTexts.args = {
|
|
|
143
143
|
export const ChildrenBeforeAndAfter = Template.bind({});
|
|
144
144
|
ChildrenBeforeAndAfter.args = {
|
|
145
145
|
label: 'Collection of items',
|
|
146
|
+
padded: false,
|
|
146
147
|
items,
|
|
147
148
|
contentRenderer: (children) => (
|
|
148
149
|
<>
|
|
@@ -188,9 +189,29 @@ FilteringSearchingPaging.args = {
|
|
|
188
189
|
sortButtonProps: {
|
|
189
190
|
fixed: false,
|
|
190
191
|
},
|
|
191
|
-
paging:
|
|
192
|
+
paging: 'buttons',
|
|
192
193
|
size: 'big',
|
|
193
194
|
padded: false,
|
|
194
|
-
fill: true,
|
|
195
195
|
items: bigCollection,
|
|
196
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: 55,
|
|
209
|
+
scrollToTopOnPageChange: true,
|
|
210
|
+
},
|
|
211
|
+
inputInTitle: false,
|
|
212
|
+
responsiveTitle: true,
|
|
213
|
+
size: 'small',
|
|
214
|
+
padded: false,
|
|
215
|
+
fill: true,
|
|
216
|
+
items: [...bigCollection, ...bigCollection, ...bigCollection, ...bigCollection, ...bigCollection],
|
|
217
|
+
} 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>();
|
|
@@ -130,15 +129,16 @@ export default {
|
|
|
130
129
|
} as Meta<IReqoreDropdownProps>;
|
|
131
130
|
|
|
132
131
|
const Template: Story<IReqoreDropdownProps> = (args: IReqoreDropdownProps) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (args.scrollToSelected) {
|
|
132
|
+
if (args.scrollToSelected || args.paging) {
|
|
136
133
|
return (
|
|
137
134
|
<ReqoreControlGroup>
|
|
138
135
|
<ReqoreDropdown
|
|
139
|
-
|
|
136
|
+
{...args}
|
|
137
|
+
label={args.label}
|
|
140
138
|
isDefaultOpen
|
|
141
|
-
|
|
139
|
+
filterable
|
|
140
|
+
scrollToSelected={args.scrollToSelected}
|
|
141
|
+
paging={args.paging}
|
|
142
142
|
items={Array(130)
|
|
143
143
|
.fill(null)
|
|
144
144
|
.map((_, i) => ({
|
|
@@ -151,31 +151,6 @@ const Template: Story<IReqoreDropdownProps> = (args: IReqoreDropdownProps) => {
|
|
|
151
151
|
);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
if (args.multiSelect) {
|
|
155
|
-
return (
|
|
156
|
-
<>
|
|
157
|
-
<ReqoreControlGroup>
|
|
158
|
-
<ReqoreDropdown
|
|
159
|
-
label='Multi Select'
|
|
160
|
-
multiSelect
|
|
161
|
-
isDefaultOpen
|
|
162
|
-
onItemSelect={({ label }) => setSelected([...selected, label])}
|
|
163
|
-
items={Array(13)
|
|
164
|
-
.fill(null)
|
|
165
|
-
.map((_, i) => ({
|
|
166
|
-
label: `Item ${i}`,
|
|
167
|
-
value: `item-${i}`,
|
|
168
|
-
selected: selected.includes(`Item ${i}`),
|
|
169
|
-
}))}
|
|
170
|
-
/>
|
|
171
|
-
{selected.map((item, index) => (
|
|
172
|
-
<ReqoreTag label={item} key={index} />
|
|
173
|
-
))}
|
|
174
|
-
</ReqoreControlGroup>
|
|
175
|
-
</>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
154
|
return (
|
|
180
155
|
<>
|
|
181
156
|
<ReqoreControlGroup wrap>
|
|
@@ -248,8 +223,52 @@ CustomComponent.args = {
|
|
|
248
223
|
export const ScrollToSelectedItem = Template.bind({});
|
|
249
224
|
ScrollToSelectedItem.args = {
|
|
250
225
|
scrollToSelected: true,
|
|
226
|
+
label: 'Dropdown that scrolls to selected item',
|
|
251
227
|
};
|
|
252
|
-
export const
|
|
253
|
-
|
|
254
|
-
|
|
228
|
+
export const WithPaging: Story<IReqoreDropdownProps> = Template.bind({});
|
|
229
|
+
WithPaging.args = {
|
|
230
|
+
paging: {
|
|
231
|
+
itemsPerPage: 50,
|
|
232
|
+
},
|
|
233
|
+
label: 'Dropdown with paging',
|
|
255
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',
|
|
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,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Story, StoryObj } from '@storybook/react/types-6-0';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { useMount } from 'react-use';
|
|
2
4
|
import { IReqorePaginationProps, ReqorePagination } from '../../components/Paging';
|
|
3
5
|
import { IReqorePagingOptions } from '../../hooks/usePaging';
|
|
4
6
|
import { ReqoreControlGroup, ReqoreTag, useReqorePaging } from '../../index';
|
|
@@ -10,14 +12,19 @@ export default {
|
|
|
10
12
|
|
|
11
13
|
const Template: Story<IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }> =
|
|
12
14
|
(args) => {
|
|
15
|
+
const [scrollContainer, setScrollContainer] = useState<any>(undefined);
|
|
13
16
|
const paging = useReqorePaging<any>({ items: tableData, ...args.pagingOptions });
|
|
14
17
|
|
|
18
|
+
useMount(() => {
|
|
19
|
+
setScrollContainer(document.querySelector('.reqore-content')!);
|
|
20
|
+
});
|
|
21
|
+
|
|
15
22
|
return (
|
|
16
23
|
<ReqoreControlGroup vertical fluid>
|
|
17
24
|
{paging.items.map((item) => (
|
|
18
25
|
<ReqoreTag fixed='key' labelKey={item.id} label={`${item.firstName} ${item.lastName}`} />
|
|
19
26
|
))}
|
|
20
|
-
<ReqorePagination<any> {...paging} {...args} />
|
|
27
|
+
<ReqorePagination<any> {...paging} {...args} scrollContainer={scrollContainer} />
|
|
21
28
|
</ReqoreControlGroup>
|
|
22
29
|
);
|
|
23
30
|
};
|
|
@@ -131,6 +138,17 @@ WithLabels.args = {
|
|
|
131
138
|
} as IReqorePagingOptions<any>,
|
|
132
139
|
};
|
|
133
140
|
|
|
141
|
+
export const ScrollToTop: Story<
|
|
142
|
+
IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
|
|
143
|
+
> = Template.bind({});
|
|
144
|
+
ScrollToTop.args = {
|
|
145
|
+
scrollToTopOnPageChange: true,
|
|
146
|
+
pagingOptions: {
|
|
147
|
+
pagesToShow: 5,
|
|
148
|
+
itemsPerPage: 100,
|
|
149
|
+
} as IReqorePagingOptions<any>,
|
|
150
|
+
};
|
|
151
|
+
|
|
134
152
|
export const Infinite: Story<
|
|
135
153
|
IReqorePaginationProps<any> & { pagingOptions?: IReqorePagingOptions<any> }
|
|
136
154
|
> = Template.bind({});
|
|
@@ -3,7 +3,7 @@ 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 {
|
|
6
|
+
import { FlatArg, IconArg, IntentArg, SizeArg, argManager } from '../utils/args';
|
|
7
7
|
|
|
8
8
|
const { createArg } = argManager<IReqorePanelProps>();
|
|
9
9
|
|
|
@@ -356,6 +356,23 @@ NoActions.args = {
|
|
|
356
356
|
'This is a really long title that should stretch all the way to the right of the panel, all the way to the end and not end in the middle',
|
|
357
357
|
};
|
|
358
358
|
|
|
359
|
+
export const NoLabel: Story<IReqorePanelProps> = Template.bind({});
|
|
360
|
+
NoLabel.args = {
|
|
361
|
+
collapsible: false,
|
|
362
|
+
actions: [
|
|
363
|
+
{
|
|
364
|
+
responsive: false,
|
|
365
|
+
group: [
|
|
366
|
+
{ label: 'Stacked Action 1', icon: 'BallPenLine', intent: 'warning' },
|
|
367
|
+
{ icon: 'CopperCoinFill', intent: 'danger' },
|
|
368
|
+
],
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
label: undefined,
|
|
372
|
+
icon: undefined,
|
|
373
|
+
badge: undefined,
|
|
374
|
+
};
|
|
375
|
+
|
|
359
376
|
export const ImageAsIcon: Story<IReqorePanelProps> = Template.bind({});
|
|
360
377
|
ImageAsIcon.args = {
|
|
361
378
|
iconImage:
|