@bitrise/bitkit 13.327.0 → 13.328.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "13.327.0",
4
+ "version": "13.328.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -0,0 +1,96 @@
1
+ import { createMultiStyleConfigHelpers } from 'chakra-ui-2--styled-system';
2
+ import { rem } from '../../utils/utils';
3
+
4
+ const { defineMultiStyleConfig } = createMultiStyleConfigHelpers([
5
+ 'container',
6
+ 'text',
7
+ 'divider',
8
+ 'button',
9
+ 'progressIndicator',
10
+ ]);
11
+
12
+ const PaginationLoadMoreTheme = defineMultiStyleConfig({
13
+ baseStyle: {
14
+ container: {
15
+ display: 'flex',
16
+ flexDirection: 'row',
17
+ alignItems: 'center',
18
+ paddingX: '16',
19
+ },
20
+ text: {
21
+ textColor: 'text/secondary',
22
+ },
23
+ progressIndicator: {
24
+ textColor: 'text/tertiary',
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ gap: '8',
28
+ },
29
+ },
30
+ sizes: {
31
+ xs: {
32
+ container: {
33
+ height: rem(32),
34
+ gap: '12',
35
+ },
36
+ text: {
37
+ textStyle: 'body/sm/regular',
38
+ },
39
+ divider: {
40
+ height: rem(20),
41
+ },
42
+ progressIndicator: {
43
+ textStyle: 'body/sm/regular',
44
+ },
45
+ },
46
+ sm: {
47
+ container: {
48
+ height: rem(48),
49
+ gap: '8',
50
+ },
51
+ text: {
52
+ textStyle: 'body/md/regular',
53
+ },
54
+ divider: {
55
+ height: rem(24),
56
+ marginLeft: '8',
57
+ },
58
+ button: {
59
+ '*': {
60
+ px: 4,
61
+ },
62
+ },
63
+ progressIndicator: {
64
+ pl: 12,
65
+ textStyle: 'body/md/regular',
66
+ },
67
+ },
68
+ md: {
69
+ container: {
70
+ height: rem(56),
71
+ gap: '12',
72
+ },
73
+ text: {
74
+ textStyle: 'body/md/regular',
75
+ },
76
+ divider: {
77
+ height: rem(24),
78
+ marginLeft: '12',
79
+ },
80
+ button: {
81
+ '*': {
82
+ px: 4,
83
+ },
84
+ },
85
+ progressIndicator: {
86
+ pl: 12,
87
+ textStyle: 'body/md/regular',
88
+ },
89
+ },
90
+ },
91
+ defaultProps: {
92
+ size: 'sm',
93
+ },
94
+ });
95
+
96
+ export default PaginationLoadMoreTheme;
@@ -0,0 +1,74 @@
1
+ import { useMultiStyleConfig } from 'chakra-ui-2--react';
2
+ import Box from '../Box/Box';
3
+ import Text from '../Text/Text';
4
+ import LinkButton from '../LinkButton/LinkButton';
5
+ import Divider from '../Divider/Divider';
6
+ import ProgressSpinner from '../ProgressSpinner/ProgressSpinner';
7
+ import Button from '../Button/Button';
8
+
9
+ export type PaginationLoadMoreProps = {
10
+ loadedCount: number;
11
+ totalCount: number;
12
+ onLoadMore: () => void;
13
+ isLoading: boolean;
14
+ size?: 'xs' | 'sm' | 'md';
15
+ loadMoreCount?: number;
16
+ };
17
+
18
+ const PaginationLoadMore = ({
19
+ loadedCount,
20
+ totalCount,
21
+ onLoadMore,
22
+ isLoading,
23
+ size = 'sm',
24
+ loadMoreCount = 10,
25
+ }: PaginationLoadMoreProps) => {
26
+ const styles = useMultiStyleConfig('PaginationLoadMore', { size });
27
+
28
+ const hasMore = loadedCount < totalCount;
29
+
30
+ const loadMoreButton = () => {
31
+ if (size === 'xs') {
32
+ return (
33
+ <LinkButton size="sm" onClick={onLoadMore}>
34
+ Load {loadMoreCount} more
35
+ </LinkButton>
36
+ );
37
+ }
38
+
39
+ return (
40
+ <Button variant="tertiary" size={size} onClick={onLoadMore}>
41
+ Load {loadMoreCount} more
42
+ </Button>
43
+ );
44
+ };
45
+
46
+ const renderLoadMoreAction = () => {
47
+ if (!hasMore) return null;
48
+
49
+ return (
50
+ <>
51
+ <Divider orientation="vertical" size="1" sx={styles.divider} />
52
+ {isLoading ? (
53
+ <Box sx={styles.progressIndicator}>
54
+ <ProgressSpinner color="sys/interactive/base" size="16" />
55
+ Loading more...
56
+ </Box>
57
+ ) : (
58
+ loadMoreButton()
59
+ )}
60
+ </>
61
+ );
62
+ };
63
+
64
+ return (
65
+ <Box sx={styles.container}>
66
+ <Text as="span" sx={styles.text}>
67
+ Showing {loadedCount} of {totalCount}
68
+ </Text>
69
+ {renderLoadMoreAction()}
70
+ </Box>
71
+ );
72
+ };
73
+
74
+ export default PaginationLoadMore;
@@ -53,6 +53,7 @@ import DraggableCard from './DraggableCard/DraggableCard.theme';
53
53
  import SelectableTag from './SelectableTag/SelectableTag.theme';
54
54
  import DataWidget from './DataWidget/DataWidget.theme';
55
55
  import TreeView from './TreeView/TreeView.theme';
56
+ import PaginationLoadMore from './PaginationLoadMore/PaginationLoadMore.theme';
56
57
 
57
58
  const components = {
58
59
  Accordion,
@@ -88,6 +89,7 @@ const components = {
88
89
  Note,
89
90
  NoteCard,
90
91
  NumberInput,
92
+ PaginationLoadMore,
91
93
  Popover,
92
94
  Progress: ProgressBar,
93
95
  ProgressIndicator,
package/src/index.ts CHANGED
@@ -334,6 +334,9 @@ export { default as TablePagination } from './Components/Table/TablePagination';
334
334
  export type { PaginationProps } from './Components/Pagination/Pagination';
335
335
  export { default as Pagination } from './Components/Pagination/Pagination';
336
336
 
337
+ export type { PaginationLoadMoreProps } from './Components/PaginationLoadMore/PaginationLoadMore';
338
+ export { default as PaginationLoadMore } from './Components/PaginationLoadMore/PaginationLoadMore';
339
+
337
340
  export type { ProgressIndicatorProps } from './Components/ProgressIndicator/ProgressIndicator';
338
341
  export { default as ProgressIndicator } from './Components/ProgressIndicator/ProgressIndicator';
339
342