@bitrise/bitkit 13.209.0 → 13.210.1-alpha.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": "13.209.0",
4
+ "version": "13.210.1-alpha.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -1,3 +1,6 @@
1
+ const checkboxButtonSize = 24;
2
+ const checkboxButtonLabelGap = 8;
3
+
1
4
  const CheckboxTheme = {
2
5
  baseStyle: {
3
6
  container: {
@@ -49,6 +52,8 @@ const CheckboxTheme = {
49
52
  alignItems: 'center',
50
53
  display: 'flex',
51
54
  gap: '4',
55
+ marginLeft: -checkboxButtonSize,
56
+ paddingLeft: checkboxButtonSize + checkboxButtonLabelGap,
52
57
  userSelect: 'none',
53
58
  },
54
59
  },
@@ -1,3 +1,6 @@
1
+ const radioButtonSize = 24;
2
+ const radioButtonLabelGap = 8;
3
+
1
4
  const RadioTheme = {
2
5
  baseStyle: {
3
6
  container: {
@@ -45,14 +48,16 @@ const RadioTheme = {
45
48
  borderColor: 'neutral.90',
46
49
  borderRadius: '12',
47
50
  boxShadow: 'inner',
48
- height: '24',
49
- width: '24',
51
+ height: radioButtonSize,
52
+ width: radioButtonSize,
50
53
  },
51
54
  icon: {
52
55
  color: 'neutral.100',
53
56
  },
54
57
  label: {
55
58
  _disabled: { color: 'neutral.60' },
59
+ marginLeft: -radioButtonSize,
60
+ paddingLeft: radioButtonSize + radioButtonLabelGap,
56
61
  userSelect: 'none',
57
62
  },
58
63
  },
@@ -2,23 +2,14 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
2
2
 
3
3
  type UseTabsProps<T> = {
4
4
  defaultId?: T;
5
- queryKey?: string;
5
+ onChange?: (id: T, index: number) => void;
6
6
  tabIds: T[];
7
- withHistory?: boolean;
8
7
  };
9
8
 
10
9
  const useTabs = <T extends string>(props: UseTabsProps<T>) => {
11
- const { defaultId, queryKey = 'tab', tabIds, withHistory } = props;
12
-
13
- let searchParams = new URLSearchParams(window.location.search);
10
+ const { defaultId, onChange, tabIds } = props;
14
11
 
15
12
  const defaultIndex = useMemo(() => {
16
- if (withHistory && searchParams.get(queryKey)) {
17
- const tabIndex = tabIds.indexOf(searchParams.get(queryKey) as T);
18
- if (tabIndex !== -1) {
19
- return tabIndex;
20
- }
21
- }
22
13
  if (defaultId) {
23
14
  const tabIndex = tabIds.indexOf(defaultId);
24
15
  if (tabIndex !== -1) {
@@ -35,11 +26,9 @@ const useTabs = <T extends string>(props: UseTabsProps<T>) => {
35
26
  }, []);
36
27
 
37
28
  useEffect(() => {
38
- const queryValue = tabIds[tabIndex];
39
- if (withHistory && queryValue) {
40
- searchParams = new URLSearchParams(window.location.search);
41
- searchParams.set(queryKey, queryValue);
42
- window.parent.history.replaceState(null, '', `?${decodeURIComponent(searchParams.toString())}`);
29
+ if (onChange) {
30
+ const id = tabIds[tabIndex];
31
+ onChange(id, tabIndex);
43
32
  }
44
33
  }, [tabIndex]);
45
34