@bitrise/bitkit 10.14.0 → 10.16.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/AspectRatio/AspectRatio.stories.tsx +24 -0
- package/src/Components/AspectRatio/AspectRatio.tsx +14 -0
- package/src/Components/Icons/16x16/Sort.tsx +18 -0
- package/src/Components/Icons/16x16/index.ts +2 -1
- package/src/Components/Icons/24x24/Sort.tsx +18 -0
- package/src/Components/Icons/24x24/index.ts +2 -1
- package/src/Components/Table/Table.stories.tsx +154 -0
- package/src/Components/Table/Table.theme.ts +101 -0
- package/src/Components/Table/Table.tsx +22 -0
- package/src/Components/Table/TableCaption.tsx +27 -0
- package/src/Components/Table/TableContainer.tsx +9 -0
- package/src/Components/Table/Tbody.tsx +9 -0
- package/src/Components/Table/Td.tsx +22 -0
- package/src/Components/Table/Th.tsx +44 -0
- package/src/Components/Table/Thead.tsx +9 -0
- package/src/Components/Table/Tr.tsx +73 -0
- package/src/index.ts +27 -0
- package/src/old.ts +14 -14
- package/src/theme.ts +3 -1
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import Image from '../Image/Image';
|
|
3
|
+
import AspectRatio from './AspectRatio';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/AspectRatio',
|
|
7
|
+
component: AspectRatio,
|
|
8
|
+
} as ComponentMeta<typeof AspectRatio>;
|
|
9
|
+
|
|
10
|
+
const Template: ComponentStory<typeof AspectRatio> = (props) => <AspectRatio {...props} />;
|
|
11
|
+
|
|
12
|
+
export const WithImage = Template.bind({});
|
|
13
|
+
WithImage.args = {
|
|
14
|
+
children: <Image alt="Bitrise office" src="bitrise_office.jpg" />,
|
|
15
|
+
maxWidth: 800,
|
|
16
|
+
ratio: 1920 / 1280,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const WithVideo = Template.bind({});
|
|
20
|
+
WithVideo.args = {
|
|
21
|
+
children: <iframe title="Intro to Bitrise" src="https://www.youtube.com/embed/JrCn9xWQ7IM" allowFullScreen />,
|
|
22
|
+
maxWidth: 800,
|
|
23
|
+
ratio: 16 / 9,
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AspectRatio as ChakraAspectRatio, AspectRatioProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AspectRatio component is used to embed responsive videos and maps, etc.
|
|
5
|
+
*
|
|
6
|
+
* https://chakra-ui.com/docs/components/aspect-ratio/usage
|
|
7
|
+
*/
|
|
8
|
+
const AspectRatio = forwardRef<AspectRatioProps, 'div'>((props, ref) => {
|
|
9
|
+
return <ChakraAspectRatio {...props} ref={ref} />;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type { AspectRatioProps };
|
|
13
|
+
|
|
14
|
+
export default AspectRatio;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
const Sort = forwardRef<IconProps, 'svg'>((props, ref) => {
|
|
4
|
+
return (
|
|
5
|
+
<Icon ref={ref} viewBox="0 0 24 24" width="16" height="16" {...props}>
|
|
6
|
+
<path
|
|
7
|
+
d="M7.68341 9.17991L11.6159 4.46093C11.8158 4.22105 12.1842 4.22106 12.3841 4.46093L16.3166 9.17991C16.588 9.50557 16.3564 10 15.9325 10H8.06752C7.6436 10 7.41203 9.50557 7.68341 9.17991Z"
|
|
8
|
+
fill="currentColor"
|
|
9
|
+
/>
|
|
10
|
+
<path
|
|
11
|
+
d="M16.3166 14.8201L12.3841 19.5391C12.1842 19.7789 11.8158 19.7789 11.6159 19.5391L7.68341 14.8201C7.41203 14.4944 7.6436 14 8.06752 14L15.9325 14C16.3564 14 16.588 14.4944 16.3166 14.8201Z"
|
|
12
|
+
fill="currentColor"
|
|
13
|
+
/>
|
|
14
|
+
</Icon>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default Sort;
|
|
@@ -148,6 +148,7 @@ export { default as Settings } from './Settings';
|
|
|
148
148
|
export { default as Ship } from './Ship';
|
|
149
149
|
export { default as ShowPassword } from './ShowPassword';
|
|
150
150
|
export { default as Shuffle } from './Shuffle';
|
|
151
|
+
export { default as Sort } from './Sort';
|
|
151
152
|
export { default as Stability } from './Stability';
|
|
152
153
|
export { default as Stack } from './Stack';
|
|
153
154
|
export { default as Star } from './Star';
|
|
@@ -190,4 +191,4 @@ export { default as Window } from './Window';
|
|
|
190
191
|
export { default as WorkflowFlow } from './WorkflowFlow';
|
|
191
192
|
export { default as Workflow } from './Workflow';
|
|
192
193
|
export { default as Wow } from './Wow';
|
|
193
|
-
export { default as Xamarin } from './Xamarin';
|
|
194
|
+
export { default as Xamarin } from './Xamarin';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Icon, IconProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
+
|
|
3
|
+
const Sort = forwardRef<IconProps, 'svg'>((props, ref) => {
|
|
4
|
+
return (
|
|
5
|
+
<Icon ref={ref} viewBox="0 0 24 24" width="24" height="24" {...props}>
|
|
6
|
+
<path
|
|
7
|
+
d="M7.68341 9.17991L11.6159 4.46093C11.8158 4.22105 12.1842 4.22106 12.3841 4.46093L16.3166 9.17991C16.588 9.50557 16.3564 10 15.9325 10H8.06752C7.6436 10 7.41203 9.50557 7.68341 9.17991Z"
|
|
8
|
+
fill="currentColor"
|
|
9
|
+
/>
|
|
10
|
+
<path
|
|
11
|
+
d="M16.3166 14.8201L12.3841 19.5391C12.1842 19.7789 11.8158 19.7789 11.6159 19.5391L7.68341 14.8201C7.41203 14.4944 7.6436 14 8.06752 14L15.9325 14C16.3564 14 16.588 14.4944 16.3166 14.8201Z"
|
|
12
|
+
fill="currentColor"
|
|
13
|
+
/>
|
|
14
|
+
</Icon>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default Sort;
|
|
@@ -148,6 +148,7 @@ export { default as Settings } from './Settings';
|
|
|
148
148
|
export { default as Ship } from './Ship';
|
|
149
149
|
export { default as ShowPassword } from './ShowPassword';
|
|
150
150
|
export { default as Shuffle } from './Shuffle';
|
|
151
|
+
export { default as Sort } from './Sort';
|
|
151
152
|
export { default as Stability } from './Stability';
|
|
152
153
|
export { default as Stack } from './Stack';
|
|
153
154
|
export { default as Star } from './Star';
|
|
@@ -190,4 +191,4 @@ export { default as Window } from './Window';
|
|
|
190
191
|
export { default as WorkflowFlow } from './WorkflowFlow';
|
|
191
192
|
export { default as Workflow } from './Workflow';
|
|
192
193
|
export { default as Wow } from './Wow';
|
|
193
|
-
export { default as Xamarin } from './Xamarin';
|
|
194
|
+
export { default as Xamarin } from './Xamarin';
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
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 > td': {
|
|
46
|
+
backgroundColor: 'neutral.95',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
th: {
|
|
50
|
+
paddingX: '16',
|
|
51
|
+
paddingY: '12',
|
|
52
|
+
fontWeight: 'bold',
|
|
53
|
+
textAlign: 'left',
|
|
54
|
+
whiteSpace: 'nowrap',
|
|
55
|
+
},
|
|
56
|
+
sortButton: {
|
|
57
|
+
display: 'flex',
|
|
58
|
+
gap: '8',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
width: '100%',
|
|
61
|
+
paddingX: '16',
|
|
62
|
+
paddingY: '12',
|
|
63
|
+
fontWeight: 'bold',
|
|
64
|
+
textAlign: 'left',
|
|
65
|
+
_hover: {
|
|
66
|
+
backgroundColor: 'neutral.90',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
sortIcon: {
|
|
70
|
+
path: {
|
|
71
|
+
fill: 'neutral.80',
|
|
72
|
+
},
|
|
73
|
+
'[aria-sort="none"]:hover & path': {
|
|
74
|
+
fill: 'purple.10',
|
|
75
|
+
},
|
|
76
|
+
'[aria-sort="ascending"] & path:first-child': {
|
|
77
|
+
fill: 'purple.10',
|
|
78
|
+
},
|
|
79
|
+
'[aria-sort="descending"] & path:last-child': {
|
|
80
|
+
fill: 'purple.10',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
td: {
|
|
84
|
+
backgroundColor: 'neutral.100',
|
|
85
|
+
borderBottom: '1px solid',
|
|
86
|
+
borderColor: 'neutral.93',
|
|
87
|
+
paddingX: '16',
|
|
88
|
+
paddingY: '12',
|
|
89
|
+
textAlign: 'left',
|
|
90
|
+
},
|
|
91
|
+
expandTd: {
|
|
92
|
+
borderBottomColor: 'transparent',
|
|
93
|
+
width: '1%',
|
|
94
|
+
'+ td': {
|
|
95
|
+
paddingLeft: 0,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export default Tabletheme;
|
|
@@ -0,0 +1,22 @@
|
|
|
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;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TableCaption as ChakraTableCaption,
|
|
3
|
+
TableCaptionProps as ChakraTableCaptionProps,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useTableStyles,
|
|
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 = useTableStyles();
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 role="cell" {...properties} ref={ref} />;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export default Td;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { AriaAttributes } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Th as ChakraTh,
|
|
4
|
+
TableColumnHeaderProps as ChakraTableColumnHeaderProps,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useTableStyles,
|
|
7
|
+
} from '@chakra-ui/react';
|
|
8
|
+
import Box from '../Box/Box';
|
|
9
|
+
import Icon from '../Icon/Icon';
|
|
10
|
+
|
|
11
|
+
export interface TableColumnHeaderProps extends ChakraTableColumnHeaderProps {
|
|
12
|
+
isSortable?: boolean;
|
|
13
|
+
onSortClick?: (sortDirection?: AriaAttributes['aria-sort']) => void;
|
|
14
|
+
sortedBy?: AriaAttributes['aria-sort'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Th = forwardRef<TableColumnHeaderProps, 'th'>((props, ref) => {
|
|
18
|
+
const { children, isSortable, onSortClick, sortedBy, ...rest } = props;
|
|
19
|
+
const css = useTableStyles();
|
|
20
|
+
const properties: ChakraTableColumnHeaderProps = {
|
|
21
|
+
children,
|
|
22
|
+
...rest,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
if (isSortable) {
|
|
26
|
+
const onClick = () => {
|
|
27
|
+
if (onSortClick) {
|
|
28
|
+
onSortClick(sortedBy);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
properties.padding = '0';
|
|
32
|
+
properties['aria-sort'] = sortedBy || 'none';
|
|
33
|
+
properties.children = (
|
|
34
|
+
<Box as="button" onClick={onClick} sx={css.sortButton}>
|
|
35
|
+
{children}
|
|
36
|
+
<Icon name="Sort" sx={css.sortIcon} />
|
|
37
|
+
</Box>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return <ChakraTh {...properties} ref={ref} />;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export default Th;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Children, ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Collapse,
|
|
4
|
+
Tr as ChakraTr,
|
|
5
|
+
TableRowProps as ChakraTableRowProps,
|
|
6
|
+
forwardRef,
|
|
7
|
+
useDisclosure,
|
|
8
|
+
useTableStyles,
|
|
9
|
+
} from '@chakra-ui/react';
|
|
10
|
+
import IconButton from '../IconButton/IconButton';
|
|
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 = useTableStyles();
|
|
24
|
+
|
|
25
|
+
const { children, expandableContent, onClick, ...rest } = props;
|
|
26
|
+
const properties: ChakraTableRowProps = {
|
|
27
|
+
onClick,
|
|
28
|
+
...rest,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (onClick) {
|
|
32
|
+
properties.sx = css.clickableTr;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//
|
|
36
|
+
if (expandableContent) {
|
|
37
|
+
const colSpan = Children.count(children) + 1;
|
|
38
|
+
return (
|
|
39
|
+
<>
|
|
40
|
+
<ChakraTr {...properties} ref={ref}>
|
|
41
|
+
<Td sx={css.expandTd}>
|
|
42
|
+
<IconButton
|
|
43
|
+
iconName="ChevronDown"
|
|
44
|
+
aria-label="Toggle current row"
|
|
45
|
+
onClick={onToggle}
|
|
46
|
+
size="small"
|
|
47
|
+
variant="tertiary"
|
|
48
|
+
sx={{
|
|
49
|
+
'> svg': {
|
|
50
|
+
transform: isOpen ? 'rotate(-180deg)' : 'rotate(0deg)',
|
|
51
|
+
transition: '300ms',
|
|
52
|
+
},
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
</Td>
|
|
56
|
+
{children}
|
|
57
|
+
</ChakraTr>
|
|
58
|
+
<ChakraTr>
|
|
59
|
+
<Td colSpan={colSpan} paddingY="0" transform={isOpen ? 'none' : 'translateY(-1px)'}>
|
|
60
|
+
<Collapse in={isOpen}>{expandableContent}</Collapse>
|
|
61
|
+
</Td>
|
|
62
|
+
</ChakraTr>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return (
|
|
67
|
+
<ChakraTr {...properties} ref={ref}>
|
|
68
|
+
{children}
|
|
69
|
+
</ChakraTr>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export default Tr;
|
package/src/index.ts
CHANGED
|
@@ -162,3 +162,30 @@ export { default as AccordionItem } from './Components/Accordion/AccordionItem';
|
|
|
162
162
|
|
|
163
163
|
export type { LightBoxProps } from './Components/LightBox/LightBox';
|
|
164
164
|
export { default as LightBox } from './Components/LightBox/LightBox';
|
|
165
|
+
|
|
166
|
+
export type { AspectRatioProps } from './Components/AspectRatio/AspectRatio';
|
|
167
|
+
export { default as AspectRatio } from './Components/AspectRatio/AspectRatio';
|
|
168
|
+
|
|
169
|
+
export type { TableProps } from './Components/Table/Table';
|
|
170
|
+
export { default as Table } from './Components/Table/Table';
|
|
171
|
+
|
|
172
|
+
export type { TableCaptionProps } from './Components/Table/TableCaption';
|
|
173
|
+
export { default as TableCaption } from './Components/Table/TableCaption';
|
|
174
|
+
|
|
175
|
+
export type { TableContainerProps } from './Components/Table/TableContainer';
|
|
176
|
+
export { default as TableContainer } from './Components/Table/TableContainer';
|
|
177
|
+
|
|
178
|
+
export type { TableBodyProps } from './Components/Table/Tbody';
|
|
179
|
+
export { default as Tbody } from './Components/Table/Tbody';
|
|
180
|
+
|
|
181
|
+
export type { TableCellProps } from './Components/Table/Td';
|
|
182
|
+
export { default as Td } from './Components/Table/Td';
|
|
183
|
+
|
|
184
|
+
export type { TableColumnHeaderProps } from './Components/Table/Th';
|
|
185
|
+
export { default as Th } from './Components/Table/Th';
|
|
186
|
+
|
|
187
|
+
export type { TableHeadProps } from './Components/Table/Thead';
|
|
188
|
+
export { default as Thead } from './Components/Table/Thead';
|
|
189
|
+
|
|
190
|
+
export type { TableRowProps } from './Components/Table/Tr';
|
|
191
|
+
export { default as Tr } from './Components/Table/Tr';
|
package/src/old.ts
CHANGED
|
@@ -72,27 +72,27 @@ export { default as SkeletonBox } from './Old/Skeleton/SkeletonBox';
|
|
|
72
72
|
export type { Props as Status500Props } from './Old/Status/Status500';
|
|
73
73
|
export { default as Status500 } from './Old/Status/Status500';
|
|
74
74
|
|
|
75
|
-
export type { Props as
|
|
76
|
-
export { default as
|
|
75
|
+
export type { Props as OldTableProps } from './Old/Table/Table';
|
|
76
|
+
export { default as OldTable } from './Old/Table/Table';
|
|
77
77
|
|
|
78
|
-
export type { Props as
|
|
79
|
-
export { default as
|
|
78
|
+
export type { Props as OldTableBodyProps } from './Old/Table/TableBody';
|
|
79
|
+
export { default as OldTableBody } from './Old/Table/TableBody';
|
|
80
80
|
|
|
81
|
-
export type { Props as
|
|
82
|
-
export { default as
|
|
81
|
+
export type { Props as OldTableCellProps } from './Old/Table/TableCell';
|
|
82
|
+
export { default as OldTableCell } from './Old/Table/TableCell';
|
|
83
83
|
|
|
84
|
-
export type { Props as
|
|
85
|
-
export { default as
|
|
84
|
+
export type { Props as OldTableHeaderProps } from './Old/Table/TableHeader';
|
|
85
|
+
export { default as OldTableHeader } from './Old/Table/TableHeader';
|
|
86
86
|
|
|
87
|
-
export type { Props as
|
|
87
|
+
export type { Props as OldTableHeaderCellProps } from './Old/Table/TableHeaderCell';
|
|
88
88
|
export type { TypeTableSort } from './Old/Table/TableHeaderCell';
|
|
89
|
-
export { default as
|
|
89
|
+
export { default as OldTableHeaderCell } from './Old/Table/TableHeaderCell';
|
|
90
90
|
|
|
91
|
-
export type { Props as
|
|
92
|
-
export { default as
|
|
91
|
+
export type { Props as OldTableHeaderRowProps } from './Old/Table/TableHeaderRow';
|
|
92
|
+
export { default as OldTableHeaderRow } from './Old/Table/TableHeaderRow';
|
|
93
93
|
|
|
94
|
-
export type { Props as
|
|
95
|
-
export { default as
|
|
94
|
+
export type { Props as OldTableRowProps } from './Old/Table/TableRow';
|
|
95
|
+
export { default as OldTableRow } from './Old/Table/TableRow';
|
|
96
96
|
|
|
97
97
|
export type { Props as TextareaProps } from './Old/Textarea/Textarea';
|
|
98
98
|
export { default as Textarea } from './Old/Textarea/Textarea';
|