@bitrise/bitkit 13.124.0 → 13.125.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,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import { ReactNode, useId } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
FormControl,
|
|
4
4
|
FormControlProps,
|
|
@@ -15,7 +15,11 @@ import Skeleton from '../Skeleton/Skeleton';
|
|
|
15
15
|
import SkeletonBox from '../Skeleton/SkeletonBox';
|
|
16
16
|
import ToggleComponent from './ToggleComponent';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
type VariantLabel =
|
|
19
|
+
| { variant: undefined; label?: ReactNode }
|
|
20
|
+
| { variant: 'dynamic'; label?: ReactNode }
|
|
21
|
+
| { variant: 'fixed'; label: ReactNode };
|
|
22
|
+
export type ToggleProps = Omit<FormControlProps, 'label' | 'onBlur' | 'onChange'> & {
|
|
19
23
|
'data-testid'?: string;
|
|
20
24
|
defaultChecked?: SwitchProps['defaultChecked'];
|
|
21
25
|
id?: SwitchProps['id'];
|
|
@@ -23,26 +27,25 @@ export interface ToggleProps extends Omit<FormControlProps, 'label' | 'onBlur' |
|
|
|
23
27
|
isDisabled?: SwitchProps['isDisabled'];
|
|
24
28
|
isLoading?: boolean;
|
|
25
29
|
helperText?: ReactNode;
|
|
26
|
-
label: ReactNode;
|
|
27
30
|
name?: string;
|
|
28
31
|
onBlur?: SwitchProps['onBlur'];
|
|
29
32
|
onChange?: SwitchProps['onChange'];
|
|
30
33
|
tooltip?: Omit<TooltipProps, 'children'>;
|
|
31
34
|
value?: SwitchProps['value'];
|
|
32
35
|
valueText?: ReactNode;
|
|
33
|
-
|
|
34
|
-
}
|
|
36
|
+
} & VariantLabel;
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* The Toggle component is used as an alternative for the checkbox component.
|
|
38
40
|
*/
|
|
39
41
|
const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
|
|
42
|
+
const fallbackId = useId();
|
|
40
43
|
const {
|
|
41
44
|
'aria-label': ariaLabel,
|
|
42
45
|
'data-testid': dataTestid,
|
|
43
46
|
defaultChecked,
|
|
44
47
|
helperText,
|
|
45
|
-
id,
|
|
48
|
+
id: externalId,
|
|
46
49
|
isChecked,
|
|
47
50
|
isDisabled,
|
|
48
51
|
isInvalid,
|
|
@@ -58,6 +61,7 @@ const Toggle = forwardRef<ToggleProps, 'div'>((props, ref) => {
|
|
|
58
61
|
variant = 'dynamic',
|
|
59
62
|
...rest
|
|
60
63
|
} = props;
|
|
64
|
+
const id = externalId || fallbackId;
|
|
61
65
|
const size: 'sm' | 'md' = variant === 'dynamic' ? 'md' : 'sm';
|
|
62
66
|
const css = useMultiStyleConfig('Switch', { withTooltip: !!tooltip, size, variant });
|
|
63
67
|
const formControlProps = {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
|
|
2
|
-
import { ColorScheme } from '
|
|
2
|
+
import { ColorScheme } from '../../types/bitkit';
|
|
3
3
|
|
|
4
4
|
const { defineMultiStyleConfig } = createMultiStyleConfigHelpers(['card', 'icon']);
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type NotificationColorScheme = Exclude<ColorScheme, 'orange' | 'neutral'>;
|
|
7
|
+
|
|
8
|
+
const colorSchemeToStatus = (colorScheme: NotificationColorScheme) => {
|
|
7
9
|
switch (colorScheme) {
|
|
8
10
|
case 'blue':
|
|
9
11
|
return 'info';
|
|
@@ -18,7 +20,7 @@ const colorSchemeToStatus = (colorScheme: ColorScheme) => {
|
|
|
18
20
|
}
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
const getIconColor = ({ colorScheme }: { colorScheme:
|
|
23
|
+
const getIconColor = ({ colorScheme }: { colorScheme: NotificationColorScheme }) => {
|
|
22
24
|
switch (colorScheme) {
|
|
23
25
|
case 'blue':
|
|
24
26
|
return 'sys/info/base';
|
|
@@ -33,15 +35,15 @@ const getIconColor = ({ colorScheme }: { colorScheme: ColorScheme }) => {
|
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
37
|
|
|
36
|
-
const getBackgroundColor = ({ colorScheme }: { colorScheme:
|
|
38
|
+
const getBackgroundColor = ({ colorScheme }: { colorScheme: NotificationColorScheme }) => {
|
|
37
39
|
return `status/${colorSchemeToStatus(colorScheme)}/bg`;
|
|
38
40
|
};
|
|
39
41
|
|
|
40
|
-
const getBorderColor = ({ colorScheme }: { colorScheme:
|
|
42
|
+
const getBorderColor = ({ colorScheme }: { colorScheme: NotificationColorScheme }) => {
|
|
41
43
|
return `status/${colorSchemeToStatus(colorScheme)}/border`;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
|
-
const getTextColor = ({ colorScheme }: { colorScheme:
|
|
46
|
+
const getTextColor = ({ colorScheme }: { colorScheme: NotificationColorScheme }) => {
|
|
45
47
|
switch (colorScheme) {
|
|
46
48
|
case 'blue':
|
|
47
49
|
return 'text/primary';
|
|
@@ -58,7 +60,7 @@ const getTextColor = ({ colorScheme }: { colorScheme: ColorScheme }) => {
|
|
|
58
60
|
|
|
59
61
|
const NotificationTheme = defineMultiStyleConfig({
|
|
60
62
|
baseStyle: ({ colorScheme }: { colorScheme: string }) => {
|
|
61
|
-
const cs = colorScheme as
|
|
63
|
+
const cs = colorScheme as NotificationColorScheme;
|
|
62
64
|
return {
|
|
63
65
|
card: {
|
|
64
66
|
bg: getBackgroundColor({ colorScheme: cs }),
|
package/src/index.ts
CHANGED
|
@@ -203,6 +203,9 @@ export { default as Tr } from './Components/Table/Tr';
|
|
|
203
203
|
export type { ToggleProps } from './Components/Toggle/Toggle';
|
|
204
204
|
export { default as Toggle } from './Components/Toggle/Toggle';
|
|
205
205
|
|
|
206
|
+
export type { ToggleComponentProps } from './Components/Toggle/ToggleComponent';
|
|
207
|
+
export { default as ToggleComponent } from './Components/Toggle/ToggleComponent';
|
|
208
|
+
|
|
206
209
|
export type { CollapseProps } from './Components/Collapse/Collapse';
|
|
207
210
|
export { default as Collapse } from './Components/Collapse/Collapse';
|
|
208
211
|
|