@bitrise/bitkit 12.24.0-alpha-checkablerow.2 → 12.25.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/Dropdown/Dropdown.tsx +3 -0
- package/src/Components/Form/Checkbox/Checkbox.theme.ts +0 -5
- package/src/Components/Form/Radio/Radio.theme.ts +0 -5
- package/src/Components/{ContentSwitcher/ContentSwitcher.context.ts → SegmentedControl/SegmentedControl.context.ts} +2 -2
- package/src/Components/{ContentSwitcher/ContentSwitcher.theme.ts → SegmentedControl/SegmentedControl.theme.ts} +8 -6
- package/src/Components/{ContentSwitcher/ContentSwitcher.tsx → SegmentedControl/SegmentedControl.tsx} +8 -8
- package/src/Components/{ContentSwitcher/ContentSwitcherItem.tsx → SegmentedControl/SegmentedControlItem.tsx} +6 -6
- package/src/Components/Table/SelectableRow.tsx +3 -8
- package/src/index.ts +4 -7
- package/src/theme.ts +2 -2
- package/src/Components/Table/CheckableRow.tsx +0 -55
package/package.json
CHANGED
|
@@ -229,6 +229,9 @@ function useDropdown<T>({
|
|
|
229
229
|
if (currentOption) {
|
|
230
230
|
setFormLabel(currentOption.label);
|
|
231
231
|
setSelectedIndex(currentOption.index);
|
|
232
|
+
} else {
|
|
233
|
+
setFormLabel(null);
|
|
234
|
+
setSelectedIndex(null);
|
|
232
235
|
}
|
|
233
236
|
}, [refdChildren, formValue]);
|
|
234
237
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UseRadioGroupReturn } from '@chakra-ui/react';
|
|
2
2
|
import { createContext } from '@chakra-ui/react-utils';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface SegmentedControlContextType {
|
|
5
5
|
getRadioProps: UseRadioGroupReturn['getRadioProps'];
|
|
6
6
|
isGroupDisabled?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export const [
|
|
8
|
+
export const [SegmentedControlContext, useSegmentedControlContext] = createContext<SegmentedControlContextType>();
|
|
@@ -2,7 +2,7 @@ import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
|
|
|
2
2
|
|
|
3
3
|
const itemHelpers = createMultiStyleConfigHelpers(['container', 'item']);
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const SegmentedControlTheme = itemHelpers.defineMultiStyleConfig({
|
|
6
6
|
baseStyle: {
|
|
7
7
|
container: {
|
|
8
8
|
display: 'flex',
|
|
@@ -18,14 +18,14 @@ const ContentSwitcherTheme = itemHelpers.defineMultiStyleConfig({
|
|
|
18
18
|
cursor: 'pointer',
|
|
19
19
|
fontSize: '3',
|
|
20
20
|
lineHeight: '2.375rem',
|
|
21
|
-
color: '
|
|
21
|
+
color: 'neutral.40',
|
|
22
22
|
textAlign: 'center',
|
|
23
|
+
fontWeight: 'demiBold',
|
|
23
24
|
border: '1px solid',
|
|
24
25
|
borderColor: 'transparent',
|
|
25
26
|
borderRadius: '4',
|
|
26
27
|
_checked: {
|
|
27
|
-
|
|
28
|
-
color: 'purple.40',
|
|
28
|
+
color: 'purple.10',
|
|
29
29
|
backgroundColor: 'neutral.100',
|
|
30
30
|
borderColor: 'separator.primary',
|
|
31
31
|
_hover: {
|
|
@@ -43,17 +43,19 @@ const ContentSwitcherTheme = itemHelpers.defineMultiStyleConfig({
|
|
|
43
43
|
_hover: {
|
|
44
44
|
backgroundColor: 'neutral.93',
|
|
45
45
|
borderColor: 'neutral.93',
|
|
46
|
+
color: 'neutral.10',
|
|
46
47
|
_disabled: {
|
|
47
48
|
backgroundColor: 'transparent',
|
|
48
49
|
borderColor: 'transparent',
|
|
50
|
+
color: 'neutral.70',
|
|
49
51
|
},
|
|
50
52
|
},
|
|
51
53
|
_disabled: {
|
|
52
54
|
cursor: 'not-allowed',
|
|
53
|
-
color: 'neutral.
|
|
55
|
+
color: 'neutral.70',
|
|
54
56
|
},
|
|
55
57
|
},
|
|
56
58
|
},
|
|
57
59
|
});
|
|
58
60
|
|
|
59
|
-
export default
|
|
61
|
+
export default SegmentedControlTheme;
|
package/src/Components/{ContentSwitcher/ContentSwitcher.tsx → SegmentedControl/SegmentedControl.tsx}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { useMultiStyleConfig, useRadioGroup, UseRadioGroupProps, forwardRef } from '@chakra-ui/react';
|
|
3
3
|
import Box, { BoxProps } from '../Box/Box';
|
|
4
|
-
import {
|
|
4
|
+
import { SegmentedControlContext, SegmentedControlContextType } from './SegmentedControl.context';
|
|
5
5
|
|
|
6
|
-
export type
|
|
6
|
+
export type SegmentedControlProps = BoxProps & UseRadioGroupProps;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This is a custom radio button group, based on: https://chakra-ui.com/docs/components/radio/usage#custom-radio-buttons.
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
11
|
+
const SegmentedControl = forwardRef<SegmentedControlProps, 'div'>((props, ref) => {
|
|
12
12
|
const { defaultValue, isDisabled, name, onChange, value, ...rest } = props;
|
|
13
13
|
|
|
14
14
|
const { getRootProps, getRadioProps } = useRadioGroup({
|
|
@@ -19,7 +19,7 @@ const ContentSwitcher = forwardRef<ContentSwitcherProps, 'div'>((props, ref) =>
|
|
|
19
19
|
value,
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
const ctx = useMemo<
|
|
22
|
+
const ctx = useMemo<SegmentedControlContextType>(
|
|
23
23
|
() => ({
|
|
24
24
|
getRadioProps,
|
|
25
25
|
isGroupDisabled: isDisabled,
|
|
@@ -29,13 +29,13 @@ const ContentSwitcher = forwardRef<ContentSwitcherProps, 'div'>((props, ref) =>
|
|
|
29
29
|
|
|
30
30
|
const group = getRootProps();
|
|
31
31
|
|
|
32
|
-
const theme = useMultiStyleConfig('
|
|
32
|
+
const theme = useMultiStyleConfig('SegmentedControl');
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
|
-
<
|
|
35
|
+
<SegmentedControlContext value={ctx}>
|
|
36
36
|
<Box __css={theme.container} ref={ref} {...group} {...rest} />
|
|
37
|
-
</
|
|
37
|
+
</SegmentedControlContext>
|
|
38
38
|
);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
export default
|
|
41
|
+
export default SegmentedControl;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { useMultiStyleConfig, useRadio } from '@chakra-ui/react';
|
|
2
2
|
import Box from '../Box/Box';
|
|
3
|
-
import {
|
|
3
|
+
import { useSegmentedControlContext } from './SegmentedControl.context';
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface SegmentedControlItemProps {
|
|
6
6
|
children: string;
|
|
7
7
|
isDisabled?: boolean;
|
|
8
8
|
value: string;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
const { getRadioProps, isGroupDisabled } =
|
|
11
|
+
const SegmentedControlItem = (props: SegmentedControlItemProps) => {
|
|
12
|
+
const { getRadioProps, isGroupDisabled } = useSegmentedControlContext();
|
|
13
13
|
|
|
14
14
|
const { children, isDisabled, value } = props;
|
|
15
15
|
|
|
16
16
|
const { getInputProps, getCheckboxProps } = useRadio(getRadioProps({ value }));
|
|
17
17
|
|
|
18
|
-
const theme = useMultiStyleConfig('
|
|
18
|
+
const theme = useMultiStyleConfig('SegmentedControl');
|
|
19
19
|
|
|
20
20
|
const isItemDisabled = isGroupDisabled || isDisabled;
|
|
21
21
|
|
|
@@ -27,4 +27,4 @@ const ContentSwitcherItem = (props: ContentSwitcherItemProps) => {
|
|
|
27
27
|
);
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export default
|
|
30
|
+
export default SegmentedControlItem;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { LinkBox, LinkOverlay } from '@chakra-ui/react';
|
|
3
3
|
import Radio from '../Form/Radio/Radio';
|
|
4
|
-
import Tooltip, { TooltipProps } from '../Tooltip/Tooltip';
|
|
5
4
|
import Td from './Td';
|
|
6
5
|
import Tr, { RowProps } from './Tr';
|
|
7
6
|
|
|
8
7
|
export interface SelectableRowProps extends RowProps {
|
|
9
8
|
id: string;
|
|
10
|
-
isDisabled?: boolean;
|
|
11
9
|
label: ReactNode;
|
|
12
|
-
tooltipProps?: Omit<TooltipProps, 'children'>;
|
|
13
10
|
value: string;
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
const SelectableRow = (props: SelectableRowProps) => {
|
|
17
|
-
const { children, id,
|
|
14
|
+
const { children, id, label, value, ...rest } = props;
|
|
18
15
|
|
|
19
16
|
return (
|
|
20
17
|
<LinkBox
|
|
@@ -34,12 +31,10 @@ const SelectableRow = (props: SelectableRowProps) => {
|
|
|
34
31
|
{...rest}
|
|
35
32
|
>
|
|
36
33
|
<Td>
|
|
37
|
-
<
|
|
38
|
-
<Radio id={id} isDisabled={isDisabled} value={value} zIndex="1" />
|
|
39
|
-
</Tooltip>
|
|
34
|
+
<Radio id={id} value={value} />
|
|
40
35
|
</Td>
|
|
41
36
|
<Td>
|
|
42
|
-
<LinkOverlay as="label" cursor=
|
|
37
|
+
<LinkOverlay as="label" cursor="pointer" htmlFor={id}>
|
|
43
38
|
{label}
|
|
44
39
|
</LinkOverlay>
|
|
45
40
|
</Td>
|
package/src/index.ts
CHANGED
|
@@ -267,11 +267,11 @@ export {
|
|
|
267
267
|
export { default as SidebarItem } from './Components/Sidebar/SidebarItem';
|
|
268
268
|
export { SidebarItemIcon, SidebarItemLabel, SidebarItemDateExtra } from './Components/Sidebar/SidebarItem';
|
|
269
269
|
|
|
270
|
-
export type {
|
|
271
|
-
export { default as
|
|
270
|
+
export type { SegmentedControlProps } from './Components/SegmentedControl/SegmentedControl';
|
|
271
|
+
export { default as SegmentedControl } from './Components/SegmentedControl/SegmentedControl';
|
|
272
272
|
|
|
273
|
-
export type {
|
|
274
|
-
export { default as
|
|
273
|
+
export type { SegmentedControlItemProps } from './Components/SegmentedControl/SegmentedControlItem';
|
|
274
|
+
export { default as SegmentedControlItem } from './Components/SegmentedControl/SegmentedControlItem';
|
|
275
275
|
|
|
276
276
|
export type { DrawerProps } from './Components/Drawer/Drawer';
|
|
277
277
|
export { default as Drawer } from './Components/Drawer/Drawer';
|
|
@@ -283,8 +283,5 @@ export { default as ClickableRow } from './Components/Table/ClickableRow';
|
|
|
283
283
|
export type { SelectableRowProps } from './Components/Table/SelectableRow';
|
|
284
284
|
export { default as SelectableRow } from './Components/Table/SelectableRow';
|
|
285
285
|
|
|
286
|
-
export type { CheckableRowProps } from './Components/Table/CheckableRow';
|
|
287
|
-
export { default as CheckableRow } from './Components/Table/CheckableRow';
|
|
288
|
-
|
|
289
286
|
export type { TagProps } from './Components/Tag/Tag';
|
|
290
287
|
export { default as Tag } from './Components/Tag/Tag';
|
package/src/theme.ts
CHANGED
|
@@ -34,7 +34,7 @@ import ProgressBar from './Components/ProgressBar/ProgressBar.theme';
|
|
|
34
34
|
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
|
-
import
|
|
37
|
+
import SegmentedControl from './Components/SegmentedControl/SegmentedControl.theme';
|
|
38
38
|
import Tag from './Components/Tag/Tag.theme';
|
|
39
39
|
|
|
40
40
|
import breakpoints from './Foundations/Breakpoints/Breakpoints';
|
|
@@ -117,7 +117,7 @@ const theme = {
|
|
|
117
117
|
SidebarItem,
|
|
118
118
|
Progress: ProgressBar,
|
|
119
119
|
Slider,
|
|
120
|
-
|
|
120
|
+
SegmentedControl,
|
|
121
121
|
Tag,
|
|
122
122
|
},
|
|
123
123
|
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { LinkBox, LinkOverlay } from '@chakra-ui/react';
|
|
3
|
-
import Checkbox from '../Form/Checkbox/Checkbox';
|
|
4
|
-
import Tooltip, { TooltipProps } from '../Tooltip/Tooltip';
|
|
5
|
-
import Td, { TableCellProps } from './Td';
|
|
6
|
-
import Tr, { RowProps } from './Tr';
|
|
7
|
-
|
|
8
|
-
export interface CheckableRowProps extends RowProps {
|
|
9
|
-
firstCellStyle?: TableCellProps;
|
|
10
|
-
id: string;
|
|
11
|
-
isDisabled?: boolean;
|
|
12
|
-
label: ReactNode;
|
|
13
|
-
name: string;
|
|
14
|
-
secondCellStyle?: TableCellProps;
|
|
15
|
-
tooltipProps?: Omit<TooltipProps, 'children'>;
|
|
16
|
-
value: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const CheckableRow = (props: CheckableRowProps) => {
|
|
20
|
-
const { children, firstCellStyle, id, isDisabled, label, name, secondCellStyle, tooltipProps, value, ...rest } =
|
|
21
|
-
props;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<LinkBox
|
|
25
|
-
as={Tr}
|
|
26
|
-
transform="scale(1)"
|
|
27
|
-
_hover={{
|
|
28
|
-
td: { background: 'neutral.95' },
|
|
29
|
-
':has(input:checked)': {
|
|
30
|
-
td: { background: 'purple.93' },
|
|
31
|
-
},
|
|
32
|
-
}}
|
|
33
|
-
sx={{
|
|
34
|
-
':has(input:checked)': {
|
|
35
|
-
td: { background: 'purple.95' },
|
|
36
|
-
},
|
|
37
|
-
}}
|
|
38
|
-
{...rest}
|
|
39
|
-
>
|
|
40
|
-
<Td {...firstCellStyle}>
|
|
41
|
-
<Tooltip isDisabled={!tooltipProps} placement="right" shouldWrapChildren {...tooltipProps}>
|
|
42
|
-
<Checkbox id={id} isDisabled={isDisabled} name={name} value={value} zIndex="1" />
|
|
43
|
-
</Tooltip>
|
|
44
|
-
</Td>
|
|
45
|
-
<Td {...secondCellStyle}>
|
|
46
|
-
<LinkOverlay as="label" cursor={isDisabled ? 'not-allowed' : 'pointer'} htmlFor={id}>
|
|
47
|
-
{label}
|
|
48
|
-
</LinkOverlay>
|
|
49
|
-
</Td>
|
|
50
|
-
{children}
|
|
51
|
-
</LinkBox>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default CheckableRow;
|