@bitrise/bitkit 9.39.0-alpha-chakra.1 → 9.39.0-alpha-form.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 +1 -1
- package/src/Components/Form/Checkbox/Checkbox.stories.tsx +36 -0
- package/src/Components/{Checkbox → Form/Checkbox}/Checkbox.theme.ts +4 -1
- package/src/Components/Form/Checkbox/Checkbox.tsx +22 -0
- package/src/Components/Form/Checkbox/CheckboxGroup.tsx +26 -0
- package/src/Components/Form/Radio/Radio.stories.tsx +28 -0
- package/src/Components/Form/Radio/Radio.theme.ts +56 -0
- package/src/Components/Form/Radio/Radio.tsx +12 -0
- package/src/Components/Form/Radio/RadioGroup.tsx +27 -0
- package/src/index.ts +11 -2
- package/src/theme.ts +3 -1
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/Components/Checkbox/Checkbox.stories.tsx +0 -16
- package/src/Components/Checkbox/Checkbox.tsx +0 -14
package/package.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
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">
|
|
26
|
+
Checkbox 1<br />
|
|
27
|
+
asddssadsda
|
|
28
|
+
</Checkbox>
|
|
29
|
+
<Checkbox value="2">Checkbox 2</Checkbox>
|
|
30
|
+
<Checkbox value="3">Checkbox 3</Checkbox>
|
|
31
|
+
</CheckboxGroup>
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
InGroup.args = {
|
|
35
|
+
defaultValue: ['1', '3'],
|
|
36
|
+
};
|
|
@@ -6,6 +6,7 @@ const CheckboxTheme: ComponentStyleConfig = {
|
|
|
6
6
|
color: 'neutral.100',
|
|
7
7
|
},
|
|
8
8
|
container: {
|
|
9
|
+
alignItems: 'flex-start',
|
|
9
10
|
_disabled: {
|
|
10
11
|
cursor: 'not-allowed',
|
|
11
12
|
':hover > span:first-of-type': {
|
|
@@ -23,6 +24,7 @@ const CheckboxTheme: ComponentStyleConfig = {
|
|
|
23
24
|
borderColor: 'neutral.90',
|
|
24
25
|
borderRadius: '4',
|
|
25
26
|
boxShadow: 'inner',
|
|
27
|
+
transitionDuration: '200ms',
|
|
26
28
|
_checked: {
|
|
27
29
|
backgroundColor: 'purple.50',
|
|
28
30
|
_disabled: {
|
|
@@ -32,7 +34,8 @@ const CheckboxTheme: ComponentStyleConfig = {
|
|
|
32
34
|
_hover: {
|
|
33
35
|
borderColor: 'neutral.70',
|
|
34
36
|
},
|
|
35
|
-
|
|
37
|
+
// TODO: change it to _focusVisible when the Chakra updated to v2
|
|
38
|
+
_focus: {
|
|
36
39
|
boxShadow: 'outline',
|
|
37
40
|
},
|
|
38
41
|
},
|
|
@@ -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 alignItems="flex-start" 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,28 @@
|
|
|
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">
|
|
17
|
+
Radio 1<br />
|
|
18
|
+
asdasddsa
|
|
19
|
+
</Radio>
|
|
20
|
+
<Radio value="2">Radio 2</Radio>
|
|
21
|
+
<Radio value="3">Radio 3</Radio>
|
|
22
|
+
</RadioGroup>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
InGroup.args = {
|
|
26
|
+
defaultValue: '2',
|
|
27
|
+
name: 'radioName',
|
|
28
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
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: '12',
|
|
26
|
+
boxShadow: 'inner',
|
|
27
|
+
_before: {
|
|
28
|
+
content: `""`,
|
|
29
|
+
display: 'inline-block',
|
|
30
|
+
width: '12',
|
|
31
|
+
height: '12',
|
|
32
|
+
borderRadius: '50%',
|
|
33
|
+
backgroundColor: 'transparent',
|
|
34
|
+
transitionDuration: '200ms',
|
|
35
|
+
},
|
|
36
|
+
_checked: {
|
|
37
|
+
_before: {
|
|
38
|
+
backgroundColor: 'purple.40',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
_hover: {
|
|
42
|
+
borderColor: 'neutral.70',
|
|
43
|
+
},
|
|
44
|
+
// TODO: change it to _focusVisible when the Chakra updated to v2
|
|
45
|
+
_focus: {
|
|
46
|
+
boxShadow: 'outline',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
label: {
|
|
50
|
+
userSelect: 'none',
|
|
51
|
+
_disabled: { color: 'neutral.60' },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
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
|
@@ -118,5 +118,14 @@ export { default as List } from './Components/List/List';
|
|
|
118
118
|
export type { ListItemProps } from './Components/List/ListItem';
|
|
119
119
|
export { default as ListItem } from './Components/List/ListItem';
|
|
120
120
|
|
|
121
|
-
export type { CheckboxProps } from './Components/Checkbox/Checkbox';
|
|
122
|
-
export { default as Checkbox } from './Components/Checkbox/Checkbox';
|
|
121
|
+
export type { CheckboxProps } from './Components/Form/Checkbox/Checkbox';
|
|
122
|
+
export { default as Checkbox } from './Components/Form/Checkbox/Checkbox';
|
|
123
|
+
|
|
124
|
+
export type { CheckboxGroupProps } from './Components/Form/Checkbox/CheckboxGroup';
|
|
125
|
+
export { default as CheckboxGroup } from './Components/Form/Checkbox/CheckboxGroup';
|
|
126
|
+
|
|
127
|
+
export type { RadioProps } from './Components/Form/Radio/Radio';
|
|
128
|
+
export { default as Radio } from './Components/Form/Radio/Radio';
|
|
129
|
+
|
|
130
|
+
export type { RadioGroupProps } from './Components/Form/Radio/RadioGroup';
|
|
131
|
+
export { default as RadioGroup } from './Components/Form/Radio/RadioGroup';
|
package/src/theme.ts
CHANGED
|
@@ -2,7 +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/Checkbox/Checkbox.theme';
|
|
5
|
+
import Checkbox from './Components/Form/Checkbox/Checkbox.theme';
|
|
6
6
|
import ColorButton from './Components/ColorButton/ColorButton.theme';
|
|
7
7
|
import Dialog from './Components/Dialog/Dialog.theme';
|
|
8
8
|
import Divider from './Components/Divider/Divider.theme';
|
|
@@ -10,6 +10,7 @@ import EmptyState from './Components/EmptyState/EmptyState.theme';
|
|
|
10
10
|
import Link from './Components/Link/Link.theme';
|
|
11
11
|
import List from './Components/List/List.theme';
|
|
12
12
|
import Menu from './Components/Menu/Menu.theme';
|
|
13
|
+
import Radio from './Components/Form/Radio/Radio.theme';
|
|
13
14
|
import Select from './Components/Select/Select.theme';
|
|
14
15
|
import Tabs from './Components/Tabs/Tabs.theme';
|
|
15
16
|
import Text from './Components/Text/Text.theme';
|
|
@@ -74,6 +75,7 @@ const theme = {
|
|
|
74
75
|
List,
|
|
75
76
|
Menu,
|
|
76
77
|
Modal: Dialog,
|
|
78
|
+
Radio,
|
|
77
79
|
Select,
|
|
78
80
|
Tabs,
|
|
79
81
|
Text,
|