@bitrise/bitkit 12.46.0 → 12.48.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.46.0",
4
+ "version": "12.48.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -0,0 +1,43 @@
1
+ import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
+
3
+ const FilterSwitch: ComponentStyleConfig = {
4
+ baseStyle: () => {
5
+ return {
6
+ container: {
7
+ color: 'neutral.40',
8
+ background: 'neutral.95',
9
+ borderRadius: '4',
10
+ border: '1px solid',
11
+ borderColor: 'neutral.80',
12
+ paddingBlock: '6',
13
+ paddingInline: '12',
14
+ cursor: 'pointer',
15
+ position: 'relative',
16
+ textOverflow: 'ellipsis',
17
+ whiteSpace: 'nowrap',
18
+ overflow: 'hidden',
19
+ _hover: {
20
+ background: 'neutral.100',
21
+ },
22
+ _active: {
23
+ color: 'purple.10',
24
+ background: 'neutral.100',
25
+ },
26
+ _checked: {
27
+ background: 'neutral.100',
28
+ color: 'purple.10',
29
+ cursor: 'default',
30
+ },
31
+ },
32
+ label: {
33
+ margin: 0,
34
+ userSelect: 'none',
35
+ _focusVisible: {
36
+ boxShadow: 'outline',
37
+ },
38
+ },
39
+ };
40
+ },
41
+ };
42
+
43
+ export default FilterSwitch;
@@ -0,0 +1,58 @@
1
+ import {
2
+ RadioProps as ChakraRadioProps,
3
+ forwardRef,
4
+ chakra,
5
+ useRadio,
6
+ useMultiStyleConfig,
7
+ useRadioGroupContext,
8
+ } from '@chakra-ui/react';
9
+ import { omitThemingProps } from '@chakra-ui/styled-system';
10
+
11
+ type RadioInputProps = ChakraRadioProps['inputProps'] & {
12
+ 'data-testid'?: string;
13
+ };
14
+
15
+ export interface FilterSwitchProps extends Omit<ChakraRadioProps, 'inputProps'> {
16
+ inputProps?: RadioInputProps;
17
+ }
18
+
19
+ const FilterSwitch = forwardRef<FilterSwitchProps, 'input'>((props, ref) => {
20
+ const group = useRadioGroupContext();
21
+ const { value: valueProp } = props;
22
+
23
+ const styles = useMultiStyleConfig('FilterSwitch', { ...group, ...props });
24
+
25
+ const ownProps = omitThemingProps(props);
26
+
27
+ const {
28
+ children,
29
+ inputProps: htmlInputProps,
30
+ isDisabled = group?.isDisabled,
31
+ isFocusable = group?.isFocusable,
32
+ ...rest
33
+ } = ownProps;
34
+
35
+ const isChecked = group.value === valueProp;
36
+
37
+ const { name } = group;
38
+
39
+ const { getInputProps, getLabelProps, getRootProps, getCheckboxProps } = useRadio({
40
+ ...rest,
41
+ isChecked,
42
+ isFocusable,
43
+ isDisabled,
44
+ onChange: group.onChange,
45
+ name,
46
+ });
47
+
48
+ return (
49
+ <chakra.label {...getRootProps()} __css={styles.container}>
50
+ <chakra.input {...getInputProps(htmlInputProps, ref)} />
51
+ <chakra.span {...getCheckboxProps()} {...getLabelProps()} __css={styles.label}>
52
+ {children}
53
+ </chakra.span>
54
+ </chakra.label>
55
+ );
56
+ });
57
+
58
+ export default FilterSwitch;
@@ -0,0 +1,25 @@
1
+ import { RadioGroup as ChakraRadioGroup, RadioGroupProps } from '@chakra-ui/react';
2
+
3
+ export type { RadioGroupProps };
4
+
5
+ const FilterSwitchGroup = (props: RadioGroupProps) => {
6
+ return (
7
+ <ChakraRadioGroup
8
+ display="flex"
9
+ {...props}
10
+ sx={{
11
+ label: {
12
+ _notFirst: {
13
+ borderLeftRadius: 0,
14
+ borderLeft: 'none',
15
+ },
16
+ _notLast: {
17
+ borderRightRadius: 0,
18
+ },
19
+ },
20
+ }}
21
+ />
22
+ );
23
+ };
24
+
25
+ export default FilterSwitchGroup;
@@ -39,7 +39,18 @@ const Th = forwardRef<TableColumnHeaderProps, 'th'>((props, ref) => {
39
39
  if (isSortable) {
40
40
  const onClick = () => {
41
41
  if (onSortClick) {
42
- onSortClick(sortedBy);
42
+ let nextSortDirection: AriaAttributes['aria-sort'];
43
+ switch (sortedBy) {
44
+ case 'ascending':
45
+ nextSortDirection = 'descending';
46
+ break;
47
+ case 'descending':
48
+ nextSortDirection = 'none';
49
+ break;
50
+ default:
51
+ nextSortDirection = 'ascending';
52
+ }
53
+ onSortClick(nextSortDirection);
43
54
  }
44
55
  };
45
56
  properties.padding = '0';
package/src/index.ts CHANGED
@@ -309,3 +309,8 @@ export { default as FileInput } from './Components/Form/FileInput/FileInput';
309
309
 
310
310
  export type { ToggletipProps as ToggleTooltipProps } from './Components/Toggletip/Toggletip';
311
311
  export { default as Toggletip } from './Components/Toggletip/Toggletip';
312
+
313
+ export type { FilterSwitchProps } from './Components/Form/FilterSwitch/FilterSwitch';
314
+ export { default as FilterSwitch } from './Components/Form/FilterSwitch/FilterSwitch';
315
+
316
+ export { default as FilterSwitchGroup } from './Components/Form/FilterSwitch/FilterSwitchGroup';
package/src/theme.ts CHANGED
@@ -51,6 +51,7 @@ import sizes from './Foundations/Sizes/Sizes';
51
51
  import typography from './Foundations/Typography/Typography';
52
52
  import zIndices from './Foundations/Zindex/Zindex';
53
53
  import Toggletip from './Components/Toggletip/Toggletip.theme';
54
+ import FilterSwitch from './Components/Form/FilterSwitch/FilterSwitch.theme';
54
55
 
55
56
  const theme = {
56
57
  config: {
@@ -100,6 +101,7 @@ const theme = {
100
101
  Drawer,
101
102
  Dropdown,
102
103
  EmptyState,
104
+ FilterSwitch,
103
105
  ...Form,
104
106
  Link,
105
107
  List,