@bitrise/bitkit 12.18.0 → 12.19.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": "12.18.0",
4
+ "version": "12.19.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -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();
package/src/index.ts CHANGED
@@ -276,3 +276,9 @@ 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';