@bitrise/bitkit 9.10.0 → 9.11.2

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": "9.10.0",
4
+ "version": "9.11.2",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -6,7 +6,7 @@ export default {
6
6
  component: Box,
7
7
  } as ComponentMeta<typeof Box>;
8
8
 
9
- const Template: ComponentStory<typeof Box> = ({ ...props }) => <Box {...props} />;
9
+ const Template: ComponentStory<typeof Box> = (props) => <Box {...props} />;
10
10
 
11
11
  export const WithProps = Template.bind({});
12
12
  WithProps.args = {
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import { Box as ChakraBox, BoxProps } from '@chakra-ui/react';
3
3
 
4
4
  /**
@@ -6,9 +6,9 @@ import { Box as ChakraBox, BoxProps } from '@chakra-ui/react';
6
6
  *
7
7
  * And this is our CSS-in-JS component, you can use this with style props.
8
8
  */
9
- const Box = (props: BoxProps) => {
10
- return <ChakraBox {...props} />;
11
- };
9
+ const Box = forwardRef<HTMLDivElement, BoxProps>((props, ref) => {
10
+ return <ChakraBox {...props} ref={ref} />;
11
+ });
12
12
 
13
13
  export { BoxProps } from '@chakra-ui/react';
14
14
 
@@ -15,7 +15,4 @@ WithProps.args = sortObjectByKey({
15
15
  children: 'Button',
16
16
  isDanger: false,
17
17
  isDisabled: false,
18
- href: '#',
19
- target: '_self',
20
- type: 'button',
21
18
  });
@@ -1,34 +1,23 @@
1
- import React, { forwardRef, HTMLAttributeAnchorTarget } from 'react';
1
+ import React, { HTMLAttributeAnchorTarget, forwardRef } from 'react';
2
2
  import { Button as ChakraButton, ButtonProps as ChackraButtonProps } from '@chakra-ui/react';
3
3
  import Icon from '../../Old/Icon/Icon';
4
4
  import { TypeIconName } from '../../Old/Icon/tsx';
5
5
 
6
- export interface LinkProps extends ChackraButtonProps {
7
- as: 'a';
8
- target?: HTMLAttributeAnchorTarget;
9
- }
10
-
11
6
  export interface ButtonProps extends ChackraButtonProps {
12
- as?: 'button';
13
- }
14
-
15
- export type Props = {
16
- children: string;
17
- className?: string;
7
+ as?: 'a' | 'button';
8
+ href?: string;
18
9
  isDanger?: boolean;
19
- isDisabled?: boolean;
20
10
  leftIconName?: TypeIconName;
21
- onClick?: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
22
- ref?: ChackraButtonProps['itemRef'];
23
11
  rightIconName?: TypeIconName;
24
12
  size?: 'small' | 'medium';
13
+ target?: HTMLAttributeAnchorTarget;
25
14
  variant?: 'primary' | 'secondary' | 'tertiary';
26
- } & (LinkProps | ButtonProps);
15
+ }
27
16
 
28
17
  /**
29
18
  * The Button component is used to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.
30
19
  */
31
- const Button = forwardRef<HTMLButtonElement, Props>((props: Props, ref) => {
20
+ const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
32
21
  const { as, isDanger, leftIconName, rightIconName, size, variant, ...rest } = props;
33
22
  const properties: ChackraButtonProps = {
34
23
  as,
@@ -42,18 +31,17 @@ const Button = forwardRef<HTMLButtonElement, Props>((props: Props, ref) => {
42
31
  if (rightIconName) {
43
32
  properties.rightIcon = <Icon name={rightIconName} />;
44
33
  }
45
- if (leftIconName || rightIconName) {
34
+ if ((properties.leftIcon || properties.rightIcon) && !properties.iconSpacing) {
46
35
  properties.iconSpacing = size === 'medium' ? '0.625rem' : '0.375rem';
47
36
  }
48
37
 
49
- return <ChakraButton ref={ref} {...properties} />;
38
+ return <ChakraButton {...properties} ref={ref} />;
50
39
  });
51
40
 
52
41
  Button.defaultProps = {
53
- // eslint-disable-next-line react/default-props-match-prop-types
54
42
  as: 'button',
55
43
  size: 'medium',
56
44
  variant: 'primary',
57
- };
45
+ } as ButtonProps;
58
46
 
59
47
  export default Button;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import { Radii } from '../../Foundations/Radii/Radii';
3
3
  import { Shadows } from '../../Foundations/Shadows/Shadows';
4
4
  import { Sizes } from '../../Foundations/Sizes/Sizes';
@@ -13,9 +13,9 @@ export interface CardProps extends BoxProps {
13
13
  /**
14
14
  * Basic container element with default box shadow, border radius and padding.
15
15
  */
16
- const Card = (props: CardProps) => {
17
- return <Box {...props} />;
18
- };
16
+ const Card = forwardRef<HTMLDivElement, CardProps>((props, ref) => {
17
+ return <Box {...props} ref={ref} />;
18
+ });
19
19
 
20
20
  Card.defaultProps = {
21
21
  borderRadius: '12',
@@ -7,7 +7,7 @@ export default {
7
7
  component: IconButton,
8
8
  } as ComponentMeta<typeof IconButton>;
9
9
 
10
- const Template: ComponentStory<typeof IconButton> = ({ ...props }) => <IconButton {...props} />;
10
+ const Template: ComponentStory<typeof IconButton> = (props) => <IconButton {...props} />;
11
11
 
12
12
  export const WithProps = Template.bind({});
13
13
  WithProps.args = sortObjectByKey({
@@ -19,14 +19,14 @@ export interface Props extends IconButtonProps {
19
19
  * TODO:
20
20
  * - Change to Chakra powered Icon component
21
21
  */
22
- const IconButton = forwardRef<HTMLButtonElement, Props>((props: Props, ref) => {
22
+ const IconButton = forwardRef<HTMLButtonElement, Props>((props, ref) => {
23
23
  const { iconName, isDanger, variant, ...rest } = props;
24
24
  const properties: IconButtonProps = {
25
25
  icon: <Icon name={iconName} />,
26
26
  variant: isDanger ? `${variant}--danger` : variant,
27
27
  ...rest,
28
28
  };
29
- return <ChakraIconButton ref={ref} {...properties} />;
29
+ return <ChakraIconButton {...properties} ref={ref} />;
30
30
  });
31
31
 
32
32
  IconButton.defaultProps = {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable jsx-a11y/anchor-is-valid */
1
2
  import { ComponentStory, ComponentMeta } from '@storybook/react';
2
3
  import { sortObjectByKey } from '../../utils/storyUtils';
3
4
  import Text from '../Text/Text';
@@ -12,13 +13,12 @@ const args = sortObjectByKey({
12
13
  ...Link.defaultProps,
13
14
  children: 'The quick brown fox jumps over the lazy dog.',
14
15
  href: '#',
15
- target: '_self',
16
16
  });
17
17
 
18
- export const WithProps: ComponentStory<typeof Link> = ({ ...props }) => <Link {...props} />;
18
+ export const WithProps: ComponentStory<typeof Link> = (props) => <Link {...props} />;
19
19
  WithProps.args = args;
20
20
 
21
- export const InsideText: ComponentStory<typeof Link> = ({ ...props }) => (
21
+ export const InsideText: ComponentStory<typeof Link> = (props) => (
22
22
  <Text size="2">
23
23
  This is a text with link: <Link {...props} />
24
24
  <br />
@@ -1,28 +1,31 @@
1
- import React, { HTMLAttributeAnchorTarget } from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import { Link as ChakraLink, LinkProps as ChakraLinkProps } from '@chakra-ui/react';
3
3
  import { TextSizes } from '../../Foundations/Typography/Typography';
4
4
 
5
5
  export interface LinkProps extends ChakraLinkProps {
6
+ as?: 'a' | 'button';
6
7
  colorScheme?: 'purple' | 'white' | 'gray';
7
8
  isUnderlined?: boolean;
8
9
  size?: TextSizes;
9
- target?: HTMLAttributeAnchorTarget;
10
10
  }
11
11
 
12
12
  /**
13
- * Links are accessible elements used primarily for navigation. This component is styled to resemble a hyperlink and semantically renders an `<a>`
13
+ * Links are accessible elements used primarily for navigation.
14
14
  */
15
- const Link = (props: LinkProps) => {
16
- const { isUnderlined, ...rest } = props;
17
- const properties: ChakraLinkProps = { ...rest };
18
- properties.as = 'a';
15
+ const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, ref) => {
16
+ const { as, isUnderlined, ...rest } = props;
17
+ const properties: ChakraLinkProps = { as, ...rest };
19
18
  if (isUnderlined) {
20
19
  properties.textDecoration = 'underline';
21
20
  }
22
- return <ChakraLink {...properties} />;
23
- };
21
+ if (as === 'button') {
22
+ properties.type = 'button';
23
+ }
24
+ return <ChakraLink {...properties} ref={ref} />;
25
+ });
24
26
 
25
27
  Link.defaultProps = {
28
+ as: 'a',
26
29
  isUnderlined: false,
27
30
  } as LinkProps;
28
31
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { forwardRef } from 'react';
2
2
  import { Text as ChakraText, TextProps as ChakraTextProps } from '@chakra-ui/react';
3
3
  import { TextSizes } from '../../Foundations/Typography/Typography';
4
4
 
@@ -58,7 +58,7 @@ export interface TextProps extends ChakraTextProps {
58
58
  /**
59
59
  * `Text` component is the used to render text and paragraphs within an interface. It renders a `<p>` tag by default.
60
60
  */
61
- const Text = (props: TextProps) => {
61
+ const Text = forwardRef<HTMLParagraphElement, TextProps>((props, ref) => {
62
62
  const { color, fontWeight, size, textTransform } = props;
63
63
  const properties: ChakraTextProps = { ...props };
64
64
  if (size === '1' && (!textTransform || textTransform === 'none')) {
@@ -70,8 +70,8 @@ const Text = (props: TextProps) => {
70
70
  if (color) {
71
71
  properties.color = `text.${color}`;
72
72
  }
73
- return <ChakraText {...properties} />;
74
- };
73
+ return <ChakraText {...properties} ref={ref} />;
74
+ });
75
75
 
76
76
  Text.defaultProps = {
77
77
  as: 'p',
@@ -67,11 +67,6 @@
67
67
  color: var(--color-red--3);
68
68
  }
69
69
 
70
- .Input:focus:focus::placeholder,
71
- .Input__container--invalid .Input:focus::placeholder {
72
- color: transparent;
73
- }
74
-
75
70
  .Input__container:focus-within {
76
71
  border-color: var(--color-grape--3);
77
72
  box-shadow: inset 0 0 0 0.125rem rgba(118, 15, 195, 0.3);
@@ -32,8 +32,3 @@
32
32
  box-shadow: inset 0 0 0 0.125rem rgba(118, 15, 195, 0.3);
33
33
  color: var(--color-grape--5);
34
34
  }
35
-
36
- .TextArea:focus::placeholder,
37
- .TextArea--invalid:focus::placeholder {
38
- color: transparent;
39
- }