@bitrise/bitkit 10.12.0-alpha-table.1 → 10.12.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 +1 -1
- package/src/Components/Dropdown/Dropdown.stories.tsx +9 -0
- package/src/Components/Dropdown/Dropdown.theme.ts +2 -0
- package/src/Components/Dropdown/Dropdown.tsx +2 -1
- package/src/Components/Dropdown/DropdownButton.tsx +5 -3
- package/src/index.ts +0 -24
- package/src/old.ts +14 -14
- package/src/theme.ts +1 -3
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/Components/Table/Table.stories.tsx +0 -154
- package/src/Components/Table/Table.theme.ts +0 -84
- package/src/Components/Table/Table.tsx +0 -22
- package/src/Components/Table/TableCaption.tsx +0 -27
- package/src/Components/Table/TableContainer.tsx +0 -9
- package/src/Components/Table/Tbody.tsx +0 -9
- package/src/Components/Table/Td.tsx +0 -22
- package/src/Components/Table/Th.tsx +0 -50
- package/src/Components/Table/Thead.tsx +0 -9
- package/src/Components/Table/Tr.tsx +0 -61
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
-
import Box from '../Box/Box';
|
|
3
|
-
import Table from './Table';
|
|
4
|
-
import TableContainer from './TableContainer';
|
|
5
|
-
import Th from './Th';
|
|
6
|
-
import Thead from './Thead';
|
|
7
|
-
import Tbody from './Tbody';
|
|
8
|
-
import Tr from './Tr';
|
|
9
|
-
import Td from './Td';
|
|
10
|
-
import TableCaption from './TableCaption';
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: 'Components/Table',
|
|
14
|
-
component: Table,
|
|
15
|
-
args: {
|
|
16
|
-
isFixed: false,
|
|
17
|
-
},
|
|
18
|
-
} as ComponentMeta<typeof Table>;
|
|
19
|
-
|
|
20
|
-
const Template: ComponentStory<typeof Table> = (props) => (
|
|
21
|
-
<TableContainer>
|
|
22
|
-
<Table {...props} />
|
|
23
|
-
</TableContainer>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const BasicVersion = Template.bind({});
|
|
27
|
-
BasicVersion.args = {
|
|
28
|
-
children: (
|
|
29
|
-
<>
|
|
30
|
-
<TableCaption description="Table decription">Basic Table</TableCaption>
|
|
31
|
-
<Thead>
|
|
32
|
-
<Tr>
|
|
33
|
-
<Th>To convert</Th>
|
|
34
|
-
<Th>into</Th>
|
|
35
|
-
<Th textAlign="right">multiply by</Th>
|
|
36
|
-
</Tr>
|
|
37
|
-
</Thead>
|
|
38
|
-
<Tbody>
|
|
39
|
-
<Tr>
|
|
40
|
-
<Td>inches</Td>
|
|
41
|
-
<Td>millimetres (mm)</Td>
|
|
42
|
-
<Td textAlign="right">25.4</Td>
|
|
43
|
-
</Tr>
|
|
44
|
-
<Tr>
|
|
45
|
-
<Td colSpan={3} textAlign="right" variant="separator">
|
|
46
|
-
Separator
|
|
47
|
-
</Td>
|
|
48
|
-
</Tr>
|
|
49
|
-
<Tr>
|
|
50
|
-
<Td>feet</Td>
|
|
51
|
-
<Td>centimetres (cm)</Td>
|
|
52
|
-
<Td textAlign="right">30.48</Td>
|
|
53
|
-
</Tr>
|
|
54
|
-
<Tr>
|
|
55
|
-
<Td>yards</Td>
|
|
56
|
-
<Td>metres (m)</Td>
|
|
57
|
-
<Td textAlign="right">0.91444</Td>
|
|
58
|
-
</Tr>
|
|
59
|
-
</Tbody>
|
|
60
|
-
</>
|
|
61
|
-
),
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const SortableColumns = Template.bind({});
|
|
65
|
-
SortableColumns.args = {
|
|
66
|
-
children: (
|
|
67
|
-
<>
|
|
68
|
-
<TableCaption description="You have to implelement the logic">Sortable columns</TableCaption>
|
|
69
|
-
<Thead>
|
|
70
|
-
<Tr>
|
|
71
|
-
<Th isSortable>isSortable: true</Th>
|
|
72
|
-
<Th isSortable sortedBy="ascending">
|
|
73
|
-
sortedBy: ascending
|
|
74
|
-
</Th>
|
|
75
|
-
<Th isSortable sortedBy="descending">
|
|
76
|
-
sortedBy: descending
|
|
77
|
-
</Th>
|
|
78
|
-
<Th>isSortable: false</Th>
|
|
79
|
-
</Tr>
|
|
80
|
-
</Thead>
|
|
81
|
-
<Tbody>
|
|
82
|
-
<Tr>
|
|
83
|
-
<Td>1</Td>
|
|
84
|
-
<Td>foo</Td>
|
|
85
|
-
<Td>bar</Td>
|
|
86
|
-
<Td>baz</Td>
|
|
87
|
-
</Tr>
|
|
88
|
-
<Tr>
|
|
89
|
-
<Td>2</Td>
|
|
90
|
-
<Td>foo</Td>
|
|
91
|
-
<Td>bar</Td>
|
|
92
|
-
<Td>baz</Td>
|
|
93
|
-
</Tr>
|
|
94
|
-
</Tbody>
|
|
95
|
-
</>
|
|
96
|
-
),
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const onRowClick = () => {};
|
|
100
|
-
|
|
101
|
-
export const ClickableRows = Template.bind({});
|
|
102
|
-
ClickableRows.args = {
|
|
103
|
-
children: (
|
|
104
|
-
<>
|
|
105
|
-
<TableCaption description="You can add onClick to the Tr">
|
|
106
|
-
Clickable rows - This is a temporary solution, please use it only when it really necessary
|
|
107
|
-
</TableCaption>
|
|
108
|
-
<Thead>
|
|
109
|
-
<Tr>
|
|
110
|
-
<Th>Workflow</Th>
|
|
111
|
-
</Tr>
|
|
112
|
-
</Thead>
|
|
113
|
-
<Tbody>
|
|
114
|
-
<Tr onClick={onRowClick}>
|
|
115
|
-
<Td>ci-rspec-apps</Td>
|
|
116
|
-
</Tr>
|
|
117
|
-
<Tr onClick={onRowClick}>
|
|
118
|
-
<Td>ci-rspes</Td>
|
|
119
|
-
</Tr>
|
|
120
|
-
<Tr onClick={onRowClick}>
|
|
121
|
-
<Td>ci-be-lint</Td>
|
|
122
|
-
</Tr>
|
|
123
|
-
</Tbody>
|
|
124
|
-
</>
|
|
125
|
-
),
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const ExpandableRows = Template.bind({});
|
|
129
|
-
ExpandableRows.args = {
|
|
130
|
-
children: (
|
|
131
|
-
<>
|
|
132
|
-
<TableCaption description="Click on a row">Expandable rows</TableCaption>
|
|
133
|
-
<Thead>
|
|
134
|
-
<Tr>
|
|
135
|
-
<Th colSpan={2}>ID</Th>
|
|
136
|
-
<Th>Status</Th>
|
|
137
|
-
<Th>Time</Th>
|
|
138
|
-
</Tr>
|
|
139
|
-
</Thead>
|
|
140
|
-
<Tbody>
|
|
141
|
-
<Tr expandableContent={<Box paddingY="12">😎</Box>}>
|
|
142
|
-
<Td>f6963af857c8f2fe</Td>
|
|
143
|
-
<Td>Success</Td>
|
|
144
|
-
<Td>May 29, 2022 10:11:32am</Td>
|
|
145
|
-
</Tr>
|
|
146
|
-
<Tr expandableContent={<Box paddingY="12">🥳</Box>}>
|
|
147
|
-
<Td>f6963af857c8f2fe</Td>
|
|
148
|
-
<Td>Aborted</Td>
|
|
149
|
-
<Td>May 29, 2022 9:12:50am</Td>
|
|
150
|
-
</Tr>
|
|
151
|
-
</Tbody>
|
|
152
|
-
</>
|
|
153
|
-
),
|
|
154
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { SystemStyleObject } from '@chakra-ui/theme-tools';
|
|
2
|
-
|
|
3
|
-
export const separatorStyle: SystemStyleObject = {
|
|
4
|
-
backgroundColor: 'neutral.93',
|
|
5
|
-
color: 'neutral.50',
|
|
6
|
-
fontSize: '1',
|
|
7
|
-
fontWeight: 'bold',
|
|
8
|
-
lineHeight: '1',
|
|
9
|
-
textTransform: 'uppercase',
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const Tabletheme: SystemStyleObject = {
|
|
13
|
-
baseStyle: {
|
|
14
|
-
caption: {
|
|
15
|
-
textAlign: 'left',
|
|
16
|
-
marginBottom: '24',
|
|
17
|
-
},
|
|
18
|
-
captionTitle: {
|
|
19
|
-
fontSize: '4',
|
|
20
|
-
lineHeight: '4',
|
|
21
|
-
fontWeight: 'bold',
|
|
22
|
-
color: 'purple.10',
|
|
23
|
-
},
|
|
24
|
-
captionDescription: {
|
|
25
|
-
marginTop: '4',
|
|
26
|
-
color: 'neutral.30',
|
|
27
|
-
},
|
|
28
|
-
table: {
|
|
29
|
-
fontVariantNumeric: 'lining-nums tabular-nums',
|
|
30
|
-
borderCollapse: 'separate',
|
|
31
|
-
borderRadius: '4',
|
|
32
|
-
border: '1px solid',
|
|
33
|
-
borderColor: 'neutral.93',
|
|
34
|
-
width: '100%',
|
|
35
|
-
borderSpacing: 0,
|
|
36
|
-
borderBottom: 0,
|
|
37
|
-
},
|
|
38
|
-
thead: {
|
|
39
|
-
backgroundColor: 'neutral.93',
|
|
40
|
-
borderTopLeftRadius: '4',
|
|
41
|
-
borderTopRightRadius: '4',
|
|
42
|
-
},
|
|
43
|
-
clickableTr: {
|
|
44
|
-
cursor: 'pointer',
|
|
45
|
-
_hover: {
|
|
46
|
-
backgroundColor: 'neutral.95',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
th: {
|
|
50
|
-
paddingX: '16',
|
|
51
|
-
paddingY: '12',
|
|
52
|
-
fontWeight: 'bold',
|
|
53
|
-
textAlign: 'left',
|
|
54
|
-
},
|
|
55
|
-
sortButton: {
|
|
56
|
-
display: 'flex',
|
|
57
|
-
gap: '8',
|
|
58
|
-
width: '100%',
|
|
59
|
-
paddingX: '16',
|
|
60
|
-
paddingY: '12',
|
|
61
|
-
fontWeight: 'bold',
|
|
62
|
-
textAlign: 'left',
|
|
63
|
-
_hover: {
|
|
64
|
-
backgroundColor: 'neutral.90',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
td: {
|
|
68
|
-
borderBottom: '1px solid',
|
|
69
|
-
borderColor: 'neutral.93',
|
|
70
|
-
paddingX: '16',
|
|
71
|
-
paddingY: '12',
|
|
72
|
-
textAlign: 'left',
|
|
73
|
-
},
|
|
74
|
-
expandTd: {
|
|
75
|
-
borderBottomColor: 'transparent',
|
|
76
|
-
width: '1%',
|
|
77
|
-
'+ td': {
|
|
78
|
-
paddingLeft: 0,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default Tabletheme;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Table as ChakraTable, TableProps as ChakraTableProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
-
|
|
3
|
-
export interface TableProps extends ChakraTableProps {
|
|
4
|
-
isFixed?: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Table component is used to organize and display data efficiently. It renders a `<table>` element.
|
|
9
|
-
*/
|
|
10
|
-
const Table = forwardRef<TableProps, 'table'>((props, ref) => {
|
|
11
|
-
const { isFixed, ...rest } = props;
|
|
12
|
-
|
|
13
|
-
const properties: ChakraTableProps = {
|
|
14
|
-
sx: {
|
|
15
|
-
tableLayout: isFixed ? 'fixed' : 'auto',
|
|
16
|
-
},
|
|
17
|
-
...rest,
|
|
18
|
-
};
|
|
19
|
-
return <ChakraTable {...properties} ref={ref} />;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export default Table;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TableCaption as ChakraTableCaption,
|
|
3
|
-
TableCaptionProps as ChakraTableCaptionProps,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useMultiStyleConfig,
|
|
6
|
-
} from '@chakra-ui/react';
|
|
7
|
-
import Text from '../Text/Text';
|
|
8
|
-
|
|
9
|
-
export interface TableCaptionProps extends Omit<ChakraTableCaptionProps, 'placement'> {
|
|
10
|
-
description?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const TableCaption = forwardRef<TableCaptionProps, 'caption'>((props, ref) => {
|
|
14
|
-
const { children, description } = props;
|
|
15
|
-
const css = useMultiStyleConfig('Table');
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<ChakraTableCaption {...props} placement="top" ref={ref}>
|
|
19
|
-
<Text as="h5" sx={css.captionTitle}>
|
|
20
|
-
{children}
|
|
21
|
-
</Text>
|
|
22
|
-
{!!description && <Text sx={css.captionDescription}>{description}</Text>}
|
|
23
|
-
</ChakraTableCaption>
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export default TableCaption;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TableContainer as ChakraTableContainer, TableContainerProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
-
|
|
3
|
-
const TableContainer = forwardRef<TableContainerProps, 'tbody'>((props, ref) => {
|
|
4
|
-
return <ChakraTableContainer {...props} ref={ref} />;
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
export type { TableContainerProps };
|
|
8
|
-
|
|
9
|
-
export default TableContainer;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Tbody as ChakraTbody, TableBodyProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
-
|
|
3
|
-
const Tbody = forwardRef<TableBodyProps, 'div'>((props, ref) => {
|
|
4
|
-
return <ChakraTbody {...props} ref={ref} />;
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
export type { TableBodyProps };
|
|
8
|
-
|
|
9
|
-
export default Tbody;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Td as ChakraTd, TableCellProps as ChakraTableCellProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
-
import { separatorStyle } from './Table.theme';
|
|
3
|
-
|
|
4
|
-
export interface TableCellProps extends ChakraTableCellProps {
|
|
5
|
-
variant?: 'default' | 'separator';
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const VARIANTS = {
|
|
9
|
-
default: {},
|
|
10
|
-
separator: separatorStyle,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const Td = forwardRef<TableCellProps, 'td'>((props, ref) => {
|
|
14
|
-
const { variant, ...rest } = props;
|
|
15
|
-
const properties: ChakraTableCellProps = {
|
|
16
|
-
sx: VARIANTS[variant || 'default'],
|
|
17
|
-
...rest,
|
|
18
|
-
};
|
|
19
|
-
return <ChakraTd {...properties} ref={ref} />;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export default Td;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Th as ChakraTh,
|
|
3
|
-
TableColumnHeaderProps as ChakraTableColumnHeaderProps,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useMultiStyleConfig,
|
|
6
|
-
} from '@chakra-ui/react';
|
|
7
|
-
import Box from '../Box/Box';
|
|
8
|
-
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
9
|
-
|
|
10
|
-
type SortType = 'ascending' | 'descending' | undefined;
|
|
11
|
-
|
|
12
|
-
export interface TableColumnHeaderProps extends ChakraTableColumnHeaderProps {
|
|
13
|
-
isSortable?: boolean;
|
|
14
|
-
onSortClick?: (sortDirection?: SortType) => void;
|
|
15
|
-
sortedBy?: SortType;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Th = forwardRef<TableColumnHeaderProps, 'th'>((props, ref) => {
|
|
19
|
-
const { children, isSortable, onSortClick, sortedBy, ...rest } = props;
|
|
20
|
-
const css = useMultiStyleConfig('Table');
|
|
21
|
-
const properties: ChakraTableColumnHeaderProps = {
|
|
22
|
-
children,
|
|
23
|
-
...rest,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (isSortable) {
|
|
27
|
-
let iconName: TypeIconName = 'Request';
|
|
28
|
-
if (sortedBy === 'ascending') {
|
|
29
|
-
iconName = 'ArrowUp';
|
|
30
|
-
} else if (sortedBy === 'descending') {
|
|
31
|
-
iconName = 'ArrowDown';
|
|
32
|
-
}
|
|
33
|
-
const onClick = () => {
|
|
34
|
-
if (onSortClick) {
|
|
35
|
-
onSortClick(sortedBy);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
properties.padding = '0';
|
|
39
|
-
properties.children = (
|
|
40
|
-
<Box as="button" onClick={onClick} sx={css.sortButton}>
|
|
41
|
-
{children}
|
|
42
|
-
<Icon name={iconName} transform={sortedBy ? 'none' : 'rotate(90deg)'} />
|
|
43
|
-
</Box>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return <ChakraTh {...properties} ref={ref} />;
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
export default Th;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Thead as ChakraThead, TableHeadProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
-
|
|
3
|
-
const Thead = forwardRef<TableHeadProps, 'thead'>((props, ref) => {
|
|
4
|
-
return <ChakraThead {...props} ref={ref} />;
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
export type { TableHeadProps };
|
|
8
|
-
|
|
9
|
-
export default Thead;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Children, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Collapse,
|
|
4
|
-
Tr as ChakraTr,
|
|
5
|
-
TableRowProps as ChakraTableRowProps,
|
|
6
|
-
forwardRef,
|
|
7
|
-
useDisclosure,
|
|
8
|
-
useMultiStyleConfig,
|
|
9
|
-
} from '@chakra-ui/react';
|
|
10
|
-
import Icon from '../Icon/Icon';
|
|
11
|
-
import Td from './Td';
|
|
12
|
-
|
|
13
|
-
export interface TableRowProps extends ChakraTableRowProps {
|
|
14
|
-
expandableContent?: ReactNode | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* @deprecated - Please use it only when really necessary, we are working on a new table-like components with clickable items
|
|
17
|
-
*/
|
|
18
|
-
onClick?: ChakraTableRowProps['onClick'];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const Tr = forwardRef<TableRowProps, 'tr'>((props, ref) => {
|
|
22
|
-
const { isOpen, onToggle } = useDisclosure();
|
|
23
|
-
const css = useMultiStyleConfig('Table');
|
|
24
|
-
|
|
25
|
-
const { children, expandableContent, onClick, ...rest } = props;
|
|
26
|
-
const properties: ChakraTableRowProps = {
|
|
27
|
-
onClick,
|
|
28
|
-
...rest,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
if (expandableContent || onClick) {
|
|
32
|
-
properties.role = 'button';
|
|
33
|
-
properties.sx = css.clickableTr;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (expandableContent) {
|
|
37
|
-
const colSpan = Children.count(children) + 1;
|
|
38
|
-
return (
|
|
39
|
-
<>
|
|
40
|
-
<ChakraTr {...properties} ref={ref} onClick={onToggle}>
|
|
41
|
-
<Td sx={css.expandTd}>
|
|
42
|
-
<Icon name="ChevronDown" transform={isOpen ? 'rotate(-180deg)' : 'rotate(0deg)'} transition="300ms" />
|
|
43
|
-
</Td>
|
|
44
|
-
{children}
|
|
45
|
-
</ChakraTr>
|
|
46
|
-
<ChakraTr>
|
|
47
|
-
<Td colSpan={colSpan} paddingY="0" transform={isOpen ? 'none' : 'translateY(-1px)'}>
|
|
48
|
-
<Collapse in={isOpen}>{expandableContent}</Collapse>
|
|
49
|
-
</Td>
|
|
50
|
-
</ChakraTr>
|
|
51
|
-
</>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return (
|
|
55
|
-
<ChakraTr {...properties} ref={ref}>
|
|
56
|
-
{children}
|
|
57
|
-
</ChakraTr>
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export default Tr;
|