@bitrise/bitkit 9.38.3 → 9.39.0-alpha-chakra.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.38.3",
4
+ "version": "9.39.0-alpha-chakra.2",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -0,0 +1,33 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import CheckboxGroup from './CheckboxGroup';
3
+ import Checkbox from './Checkbox';
4
+
5
+ export default {
6
+ component: Checkbox,
7
+ argTypes: {
8
+ onChange: {
9
+ action: 'onChange event',
10
+ },
11
+ },
12
+ } as ComponentMeta<typeof Checkbox>;
13
+
14
+ const Template: ComponentStory<typeof Checkbox> = (props) => <Checkbox {...props} />;
15
+
16
+ export const WithProps = Template.bind({});
17
+ WithProps.args = {
18
+ children: 'Checkbox',
19
+ isDisabled: false,
20
+ isIndeterminate: false,
21
+ };
22
+
23
+ export const InGroup: ComponentStory<typeof CheckboxGroup> = (props) => (
24
+ <CheckboxGroup {...props} display="flex" gap="24">
25
+ <Checkbox value="1">Checkbox 1</Checkbox>
26
+ <Checkbox value="2">Checkbox 2</Checkbox>
27
+ <Checkbox value="3">Checkbox 3</Checkbox>
28
+ </CheckboxGroup>
29
+ );
30
+
31
+ InGroup.args = {
32
+ defaultValue: ['1', '3'],
33
+ };
@@ -0,0 +1,49 @@
1
+ import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
+
3
+ const CheckboxTheme: ComponentStyleConfig = {
4
+ baseStyle: {
5
+ icon: {
6
+ color: 'neutral.100',
7
+ },
8
+ container: {
9
+ alignItems: 'flex-start',
10
+ _disabled: {
11
+ cursor: 'not-allowed',
12
+ ':hover > span:first-of-type': {
13
+ borderColor: 'neutral.90',
14
+ },
15
+ },
16
+ ':hover > span:first-of-type': {
17
+ borderColor: 'neutral.70',
18
+ },
19
+ },
20
+ control: {
21
+ width: '24',
22
+ height: '24',
23
+ border: '1px solid',
24
+ borderColor: 'neutral.90',
25
+ borderRadius: '4',
26
+ boxShadow: 'inner',
27
+ transitionDuration: '200ms',
28
+ _checked: {
29
+ backgroundColor: 'purple.50',
30
+ _disabled: {
31
+ backgroundColor: 'neutral.80',
32
+ },
33
+ },
34
+ _hover: {
35
+ borderColor: 'neutral.70',
36
+ },
37
+ // TODO: change it to _focusVisible when the Chakra updated to v2
38
+ _focus: {
39
+ boxShadow: 'outline',
40
+ },
41
+ },
42
+ label: {
43
+ userSelect: 'none',
44
+ _disabled: { color: 'neutral.60' },
45
+ },
46
+ },
47
+ };
48
+
49
+ export default CheckboxTheme;
@@ -0,0 +1,22 @@
1
+ import { Checkbox as ChakraCheckbox, CheckboxProps as ChakraCheckboxProps, forwardRef } from '@chakra-ui/react';
2
+ import Icon from '../../Icon/Icon';
3
+
4
+ export type CheckboxProps = Omit<ChakraCheckboxProps, 'icon' | 'iconColor' | 'iconSize'>;
5
+
6
+ const CustomIcon = (props: CheckboxProps) => {
7
+ // eslint-disable-next-line @typescript-eslint/naming-convention
8
+ const { __css, isChecked, isIndeterminate } = props;
9
+ if (!isChecked) {
10
+ return null;
11
+ }
12
+ return <Icon __css={__css} name={isIndeterminate ? 'MinusClose' : 'Tick'} />;
13
+ };
14
+
15
+ /**
16
+ * Checkbox component is used in forms when a user needs to select multiple values from several options.
17
+ */
18
+ const Checkbox = forwardRef<CheckboxProps, 'input'>((props, ref) => {
19
+ return <ChakraCheckbox icon={<CustomIcon />} {...props} ref={ref} />;
20
+ });
21
+
22
+ export default Checkbox;
@@ -0,0 +1,26 @@
1
+ import { CheckboxGroup as ChakraCheckboxGroup, CheckboxGroupProps as ChakraCheckboxGroupProps } from '@chakra-ui/react';
2
+ import Box, { BoxProps } from '../../Box/Box';
3
+
4
+ export type CheckboxGroupProps = ChakraCheckboxGroupProps & BoxProps;
5
+
6
+ /**
7
+ * CheckboxGroup component to help manage the checked state of its children Checkbox components and conveniently pass a few shared style props to each.
8
+ * Composes Box.
9
+ */
10
+ const CheckboxGroup = (props: CheckboxGroupProps) => {
11
+ const { children, defaultValue, isDisabled, isNative, onChange, value, ...boxProps } = props;
12
+ const groupProps = {
13
+ defaultValue,
14
+ isDisabled,
15
+ isNative,
16
+ onChange,
17
+ value,
18
+ };
19
+ return (
20
+ <ChakraCheckboxGroup {...groupProps}>
21
+ <Box {...boxProps}>{children}</Box>
22
+ </ChakraCheckboxGroup>
23
+ );
24
+ };
25
+
26
+ export default CheckboxGroup;
@@ -0,0 +1,25 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import RadioGroup from './RadioGroup';
3
+ import Radio from './Radio';
4
+
5
+ export default {
6
+ component: Radio,
7
+ argTypes: {
8
+ onChange: {
9
+ action: 'onChange event',
10
+ },
11
+ },
12
+ } as ComponentMeta<typeof Radio>;
13
+
14
+ export const InGroup: ComponentStory<typeof RadioGroup> = (props) => (
15
+ <RadioGroup {...props} display="flex" gap="24">
16
+ <Radio value="1">Radio 1</Radio>
17
+ <Radio value="2">Radio 2</Radio>
18
+ <Radio value="3">Radio 3</Radio>
19
+ </RadioGroup>
20
+ );
21
+
22
+ InGroup.args = {
23
+ defaultValue: '2',
24
+ name: 'radioName',
25
+ };
@@ -0,0 +1,51 @@
1
+ import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
+
3
+ const RadioTheme: ComponentStyleConfig = {
4
+ baseStyle: {
5
+ icon: {
6
+ color: 'neutral.100',
7
+ },
8
+ container: {
9
+ _disabled: {
10
+ cursor: 'not-allowed',
11
+ ':hover > span:first-of-type': {
12
+ borderColor: 'neutral.90',
13
+ },
14
+ },
15
+ ':hover > span:first-of-type': {
16
+ borderColor: 'neutral.70',
17
+ },
18
+ },
19
+ control: {
20
+ width: '24',
21
+ height: '24',
22
+ border: '1px solid',
23
+ borderColor: 'neutral.90',
24
+ borderRadius: '12',
25
+ boxShadow: 'inner',
26
+ _checked: {
27
+ _before: {
28
+ content: `""`,
29
+ display: 'inline-block',
30
+ width: '12',
31
+ height: '12',
32
+ borderRadius: '50%',
33
+ backgroundColor: 'purple.40',
34
+ },
35
+ },
36
+ _hover: {
37
+ borderColor: 'neutral.70',
38
+ },
39
+ // TODO: change it to _focusVisible when the Chakra updated to v2
40
+ _focus: {
41
+ boxShadow: 'outline',
42
+ },
43
+ },
44
+ label: {
45
+ userSelect: 'none',
46
+ _disabled: { color: 'neutral.60' },
47
+ },
48
+ },
49
+ };
50
+
51
+ export default RadioTheme;
@@ -0,0 +1,12 @@
1
+ import { Radio as ChakraRadio, RadioProps as ChakraRadioProps, forwardRef } from '@chakra-ui/react';
2
+
3
+ export type RadioProps = ChakraRadioProps;
4
+
5
+ /**
6
+ * Radios are used when only one choice may be selected in a series of options.
7
+ */
8
+ const Radio = forwardRef<RadioProps, 'input'>((props, ref) => {
9
+ return <ChakraRadio {...props} ref={ref} />;
10
+ });
11
+
12
+ export default Radio;
@@ -0,0 +1,27 @@
1
+ import { RadioGroup as ChakraRadioGroup, RadioGroupProps as ChakraRadioGroupProps } from '@chakra-ui/react';
2
+ import Box, { BoxProps } from '../../Box/Box';
3
+
4
+ export type RadioGroupProps = ChakraRadioGroupProps & BoxProps;
5
+
6
+ /**
7
+ * RadioGroup component to help manage Radio components and conveniently pass a few shared style props to each.
8
+ * Composes Box.
9
+ */
10
+ const RadioGroup = (props: RadioGroupProps) => {
11
+ const { children, defaultValue, isDisabled, isFocusable, isNative, onChange, value, ...boxProps } = props;
12
+ const groupProps = {
13
+ defaultValue,
14
+ isDisabled,
15
+ isFocusable,
16
+ isNative,
17
+ onChange,
18
+ value,
19
+ };
20
+ return (
21
+ <ChakraRadioGroup {...groupProps}>
22
+ <Box {...boxProps}>{children}</Box>
23
+ </ChakraRadioGroup>
24
+ );
25
+ };
26
+
27
+ export default RadioGroup;
package/src/index.ts CHANGED
@@ -117,3 +117,6 @@ export { default as List } from './Components/List/List';
117
117
 
118
118
  export type { ListItemProps } from './Components/List/ListItem';
119
119
  export { default as ListItem } from './Components/List/ListItem';
120
+
121
+ export type { CheckboxProps } from './Components/Form/Checkbox/Checkbox';
122
+ export { default as Checkbox } from './Components/Form/Checkbox/Checkbox';
package/src/old.ts CHANGED
@@ -43,9 +43,6 @@ export { default as Base } from './Old/Base/Base';
43
43
  export type { Props as BoundsProps } from './Old/Bounds/Bounds';
44
44
  export { default as Bounds } from './Old/Bounds/Bounds';
45
45
 
46
- export type { Props as CheckboxProps } from './Old/Checkbox/Checkbox';
47
- export { default as Checkbox } from './Old/Checkbox/Checkbox';
48
-
49
46
  export type { Props as DatePickerProps } from './Old/DatePicker/DatePicker';
50
47
  export { default as DatePicker } from './Old/DatePicker/DatePicker';
51
48
 
package/src/theme.ts CHANGED
@@ -2,6 +2,7 @@ import Avatar from './Components/Avatar/Avatar.theme';
2
2
  import Badge from './Components/Badge/Badge.theme';
3
3
  import Button from './Components/Button/Button.theme';
4
4
  import Card from './Components/Card/Card.theme';
5
+ import Checkbox from './Components/Form/Checkbox/Checkbox.theme';
5
6
  import ColorButton from './Components/ColorButton/ColorButton.theme';
6
7
  import Dialog from './Components/Dialog/Dialog.theme';
7
8
  import Divider from './Components/Divider/Divider.theme';
@@ -9,6 +10,7 @@ import EmptyState from './Components/EmptyState/EmptyState.theme';
9
10
  import Link from './Components/Link/Link.theme';
10
11
  import List from './Components/List/List.theme';
11
12
  import Menu from './Components/Menu/Menu.theme';
13
+ import Radio from './Components/Form/Radio/Radio.theme';
12
14
  import Select from './Components/Select/Select.theme';
13
15
  import Tabs from './Components/Tabs/Tabs.theme';
14
16
  import Text from './Components/Text/Text.theme';
@@ -65,6 +67,7 @@ const theme = {
65
67
  Badge,
66
68
  Button,
67
69
  Card,
70
+ Checkbox,
68
71
  ColorButton,
69
72
  Divider,
70
73
  EmptyState,
@@ -72,6 +75,7 @@ const theme = {
72
75
  List,
73
76
  Menu,
74
77
  Modal: Dialog,
78
+ Radio,
75
79
  Select,
76
80
  Tabs,
77
81
  Text,