@bitrise/bitkit 12.18.0 → 12.20.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/Table/ClickableRow.tsx +27 -0
- package/src/Components/Table/SelectableRow.tsx +45 -0
- package/src/Components/Table/Table.theme.ts +0 -6
- package/src/Components/Table/Tr.tsx +1 -11
- package/src/Components/Tag/Tag.theme.ts +104 -0
- package/src/Components/Tag/Tag.tsx +56 -0
- package/src/index.ts +9 -0
- package/src/theme.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { LinkBox, LinkOverlay } from '@chakra-ui/react';
|
|
3
|
+
import Link, { LinkProps } from '../Link/Link';
|
|
4
|
+
import Td from './Td';
|
|
5
|
+
import Tr, { RowProps } from './Tr';
|
|
6
|
+
|
|
7
|
+
export interface ClickableRowProps extends RowProps {
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
linkProps?: Omit<LinkProps, 'children'>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const ClickableRow = (props: ClickableRowProps) => {
|
|
13
|
+
const { children, label, linkProps, ...rest } = props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<LinkBox as={Tr} {...rest}>
|
|
17
|
+
<Td>
|
|
18
|
+
<LinkOverlay as={Link} {...linkProps}>
|
|
19
|
+
{label}
|
|
20
|
+
</LinkOverlay>
|
|
21
|
+
</Td>
|
|
22
|
+
{children}
|
|
23
|
+
</LinkBox>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default ClickableRow;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { LinkBox, LinkOverlay } from '@chakra-ui/react';
|
|
3
|
+
import Radio from '../Form/Radio/Radio';
|
|
4
|
+
import Td from './Td';
|
|
5
|
+
import Tr, { RowProps } from './Tr';
|
|
6
|
+
|
|
7
|
+
export interface SelectableRowProps extends RowProps {
|
|
8
|
+
id: string;
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
value: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const SelectableRow = (props: SelectableRowProps) => {
|
|
14
|
+
const { children, id, label, value, ...rest } = props;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<LinkBox
|
|
18
|
+
as={Tr}
|
|
19
|
+
_hover={{
|
|
20
|
+
td: { background: 'neutral.95' },
|
|
21
|
+
':has(input:checked)': {
|
|
22
|
+
td: { background: 'purple.93' },
|
|
23
|
+
},
|
|
24
|
+
}}
|
|
25
|
+
sx={{
|
|
26
|
+
':has(input:checked)': {
|
|
27
|
+
td: { background: 'purple.95' },
|
|
28
|
+
},
|
|
29
|
+
}}
|
|
30
|
+
{...rest}
|
|
31
|
+
>
|
|
32
|
+
<Td>
|
|
33
|
+
<Radio id={id} value={value} />
|
|
34
|
+
</Td>
|
|
35
|
+
<Td>
|
|
36
|
+
<LinkOverlay as="label" cursor="pointer" htmlFor={id}>
|
|
37
|
+
{label}
|
|
38
|
+
</LinkOverlay>
|
|
39
|
+
</Td>
|
|
40
|
+
{children}
|
|
41
|
+
</LinkBox>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default SelectableRow;
|
|
@@ -40,12 +40,6 @@ const Tabletheme: SystemStyleObject = {
|
|
|
40
40
|
borderTopLeftRadius: '4',
|
|
41
41
|
borderTopRightRadius: '4',
|
|
42
42
|
},
|
|
43
|
-
clickableTr: {
|
|
44
|
-
cursor: 'pointer',
|
|
45
|
-
'&:hover > td': {
|
|
46
|
-
backgroundColor: 'neutral.95',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
43
|
th: {
|
|
50
44
|
paddingX: '16',
|
|
51
45
|
paddingY: '12',
|
|
@@ -10,12 +10,7 @@ import {
|
|
|
10
10
|
import IconButton from '../IconButton/IconButton';
|
|
11
11
|
import Td from './Td';
|
|
12
12
|
|
|
13
|
-
type RowProps = ChakraTableRowProps
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated - Please use it only when really necessary, we are working on a new table-like components with clickable items
|
|
16
|
-
*/
|
|
17
|
-
onClick?: ChakraTableRowProps['onClick'];
|
|
18
|
-
};
|
|
13
|
+
export type RowProps = ChakraTableRowProps;
|
|
19
14
|
|
|
20
15
|
type NonExpandableProps = ChakraTableRowProps & {
|
|
21
16
|
expandableContent?: never;
|
|
@@ -38,14 +33,9 @@ const Tr = forwardRef<TableRowProps, 'tr'>((props, ref) => {
|
|
|
38
33
|
const css = useTableStyles();
|
|
39
34
|
|
|
40
35
|
const properties: ChakraTableRowProps = {
|
|
41
|
-
onClick,
|
|
42
36
|
...rest,
|
|
43
37
|
};
|
|
44
38
|
|
|
45
|
-
if (onClick) {
|
|
46
|
-
properties.sx = css.clickableTr;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
39
|
const onToggleClick = useCallback(() => {
|
|
50
40
|
const nextOpen = !isOpen;
|
|
51
41
|
onToggle();
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
|
|
2
|
+
import { rem } from '../../utils/utils';
|
|
3
|
+
|
|
4
|
+
const { defineMultiStyleConfig, definePartsStyle } = createMultiStyleConfigHelpers([
|
|
5
|
+
'container',
|
|
6
|
+
'icon',
|
|
7
|
+
'label',
|
|
8
|
+
'closeButton',
|
|
9
|
+
'skeleton',
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const sizes = {
|
|
13
|
+
sm: definePartsStyle({
|
|
14
|
+
container: {
|
|
15
|
+
paddingX: rem(7),
|
|
16
|
+
paddingY: rem(1),
|
|
17
|
+
},
|
|
18
|
+
label: {
|
|
19
|
+
fontSize: '1',
|
|
20
|
+
lineHeight: rem(16),
|
|
21
|
+
},
|
|
22
|
+
closeButton: {
|
|
23
|
+
height: '20',
|
|
24
|
+
width: '20',
|
|
25
|
+
marginRight: rem(-6),
|
|
26
|
+
},
|
|
27
|
+
}),
|
|
28
|
+
md: definePartsStyle({
|
|
29
|
+
container: {
|
|
30
|
+
paddingX: rem(11),
|
|
31
|
+
paddingY: rem(3),
|
|
32
|
+
},
|
|
33
|
+
label: {
|
|
34
|
+
fontSize: '2',
|
|
35
|
+
lineHeight: rem(24),
|
|
36
|
+
},
|
|
37
|
+
closeButton: {
|
|
38
|
+
height: '24',
|
|
39
|
+
width: '24',
|
|
40
|
+
marginRight: rem(-7),
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const baseStyle = definePartsStyle(({ colorScheme }) => {
|
|
46
|
+
const scheme = {
|
|
47
|
+
color: `${colorScheme}.40`,
|
|
48
|
+
backgroundColor: `${colorScheme}.93`,
|
|
49
|
+
borderColor: `${colorScheme}.80`,
|
|
50
|
+
};
|
|
51
|
+
if (colorScheme === 'neutral') {
|
|
52
|
+
scheme.color = 'purple.10';
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
container: {
|
|
56
|
+
border: '1px solid',
|
|
57
|
+
borderRadius: '4',
|
|
58
|
+
...scheme,
|
|
59
|
+
_disabled: {
|
|
60
|
+
cursor: 'not-allowed',
|
|
61
|
+
backgroundColor: 'neutral.95',
|
|
62
|
+
borderColor: 'neutral.90',
|
|
63
|
+
color: 'neutral.80',
|
|
64
|
+
},
|
|
65
|
+
_loading: {
|
|
66
|
+
cursor: 'wait',
|
|
67
|
+
backgroundColor: 'neutral.93',
|
|
68
|
+
borderColor: 'neutral.93',
|
|
69
|
+
color: 'neutral.60',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
icon: {
|
|
73
|
+
marginInlineEnd: '4',
|
|
74
|
+
},
|
|
75
|
+
label: {
|
|
76
|
+
display: 'inline',
|
|
77
|
+
},
|
|
78
|
+
closeButton: {
|
|
79
|
+
marginInlineStart: '4',
|
|
80
|
+
borderRadius: rem(2),
|
|
81
|
+
_hover: {
|
|
82
|
+
backgroundColor: `${colorScheme}.90`,
|
|
83
|
+
},
|
|
84
|
+
_focus: {
|
|
85
|
+
boxShadow: '0 0 0 1px var(--colors-purple-70) inset',
|
|
86
|
+
},
|
|
87
|
+
_disabled: {
|
|
88
|
+
pointerEvents: 'none',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
skeleton: {
|
|
92
|
+
minWidth: '32',
|
|
93
|
+
height: '8',
|
|
94
|
+
backgroundColor: 'neutral.80',
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const TagTheme = defineMultiStyleConfig({
|
|
100
|
+
baseStyle,
|
|
101
|
+
sizes,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export default TagTheme;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Tag as ChakraTag, TagCloseButton, TagProps as ChakraTagProps, useMultiStyleConfig } from '@chakra-ui/react';
|
|
2
|
+
import Icon from '../Icon/Icon';
|
|
3
|
+
import Skeleton from '../Skeleton/Skeleton';
|
|
4
|
+
import SkeletonBox from '../Skeleton/SkeletonBox';
|
|
5
|
+
import Text from '../Text/Text';
|
|
6
|
+
import Tooltip from '../Tooltip/Tooltip';
|
|
7
|
+
|
|
8
|
+
export interface TagProps extends Omit<ChakraTagProps, 'colorScheme' | 'size' | 'variant'> {
|
|
9
|
+
closeButtonTooltip?: string;
|
|
10
|
+
colorScheme?: 'neutral' | 'blue' | 'green' | 'red' | 'yellow' | 'purple';
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
onClose?: () => void;
|
|
14
|
+
size?: 'sm' | 'md';
|
|
15
|
+
withIcon?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Tag = (props: TagProps) => {
|
|
19
|
+
const { children, closeButtonTooltip, isDisabled, isLoading, onClose, withIcon, ...tagProps } = props;
|
|
20
|
+
const style = useMultiStyleConfig('Tag', tagProps);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<ChakraTag
|
|
24
|
+
aria-disabled={isDisabled}
|
|
25
|
+
data-disabled={isDisabled || undefined}
|
|
26
|
+
aria-busy={isLoading}
|
|
27
|
+
data-loading={isLoading || undefined}
|
|
28
|
+
{...tagProps}
|
|
29
|
+
>
|
|
30
|
+
{withIcon && <Icon name="Tick" size={tagProps.size === 'sm' ? '16' : '24'} __css={style.icon} />}
|
|
31
|
+
<Text as="span" hasEllipsis sx={style.label}>
|
|
32
|
+
{isLoading ? (
|
|
33
|
+
<Skeleton isActive>
|
|
34
|
+
<SkeletonBox sx={style.skeleton} />
|
|
35
|
+
</Skeleton>
|
|
36
|
+
) : (
|
|
37
|
+
children
|
|
38
|
+
)}
|
|
39
|
+
</Text>
|
|
40
|
+
{!!onClose && (
|
|
41
|
+
<Tooltip isDisabled={!closeButtonTooltip} label={closeButtonTooltip}>
|
|
42
|
+
<TagCloseButton isDisabled={isDisabled || isLoading} onClick={onClose}>
|
|
43
|
+
<Icon name="CloseSmall" size="16" />
|
|
44
|
+
</TagCloseButton>
|
|
45
|
+
</Tooltip>
|
|
46
|
+
)}
|
|
47
|
+
</ChakraTag>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
Tag.defaultProps = {
|
|
52
|
+
colorScheme: 'neutral',
|
|
53
|
+
size: 'md',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default Tag;
|
package/src/index.ts
CHANGED
|
@@ -276,3 +276,12 @@ export { default as ContentSwitcherItem } from './Components/ContentSwitcher/Con
|
|
|
276
276
|
export type { DrawerProps } from './Components/Drawer/Drawer';
|
|
277
277
|
export { default as Drawer } from './Components/Drawer/Drawer';
|
|
278
278
|
export { default as useDrawer } from './Components/Drawer/useDrawer';
|
|
279
|
+
|
|
280
|
+
export type { ClickableRowProps } from './Components/Table/ClickableRow';
|
|
281
|
+
export { default as ClickableRow } from './Components/Table/ClickableRow';
|
|
282
|
+
|
|
283
|
+
export type { SelectableRowProps } from './Components/Table/SelectableRow';
|
|
284
|
+
export { default as SelectableRow } from './Components/Table/SelectableRow';
|
|
285
|
+
|
|
286
|
+
export type { TagProps } from './Components/Tag/Tag';
|
|
287
|
+
export { default as Tag } from './Components/Tag/Tag';
|
package/src/theme.ts
CHANGED
|
@@ -35,6 +35,7 @@ import Slider from './Components/Slider/Slider.theme';
|
|
|
35
35
|
import Sidebar from './Components/Sidebar/Sidebar.theme';
|
|
36
36
|
import SidebarItem from './Components/Sidebar/SidebarItem.theme';
|
|
37
37
|
import ContentSwitcher from './Components/ContentSwitcher/ContentSwitcher.theme';
|
|
38
|
+
import Tag from './Components/Tag/Tag.theme';
|
|
38
39
|
|
|
39
40
|
import breakpoints from './Foundations/Breakpoints/Breakpoints';
|
|
40
41
|
import colors from './Foundations/Colors/Colors';
|
|
@@ -117,6 +118,7 @@ const theme = {
|
|
|
117
118
|
Progress: ProgressBar,
|
|
118
119
|
Slider,
|
|
119
120
|
ContentSwitcher,
|
|
121
|
+
Tag,
|
|
120
122
|
},
|
|
121
123
|
};
|
|
122
124
|
|