react-native-molecules 0.5.0-beta.27 → 0.5.0-beta.29
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/components/ActivityIndicator/ActivityIndicator.tsx +1 -1
- package/components/Button/utils.ts +1 -1
- package/components/Checkbox/Checkbox.tsx +124 -88
- package/components/Checkbox/CheckboxBase.ios.tsx +2 -4
- package/components/Checkbox/CheckboxBase.tsx +3 -10
- package/components/Checkbox/context.tsx +14 -0
- package/components/Checkbox/index.tsx +11 -4
- package/components/Checkbox/types.ts +63 -29
- package/components/Checkbox/utils.ts +25 -83
- package/components/IconButton/IconButton.tsx +16 -17
- package/components/IconButton/types.ts +8 -0
- package/components/IconButton/utils.ts +25 -0
- package/components/Menu/Menu.tsx +31 -20
- package/components/Menu/index.tsx +2 -1
- package/components/Radio/Radio.tsx +188 -0
- package/components/Radio/RadioBase.ios.tsx +69 -0
- package/components/{RadioButton/RadioButtonAndroid.tsx → Radio/RadioBase.tsx} +27 -63
- package/components/Radio/context.tsx +23 -0
- package/components/Radio/index.tsx +20 -0
- package/components/Radio/types.ts +101 -0
- package/components/Radio/utils.ts +115 -0
- package/package.json +1 -1
- package/components/RadioButton/RadioButton.tsx +0 -138
- package/components/RadioButton/RadioButtonGroup.tsx +0 -97
- package/components/RadioButton/RadioButtonIOS.tsx +0 -92
- package/components/RadioButton/RadioButtonItem.tsx +0 -232
- package/components/RadioButton/index.ts +0 -22
- package/components/RadioButton/utils.ts +0 -165
|
@@ -1,125 +1,161 @@
|
|
|
1
1
|
import { useControlledValue } from '@react-native-molecules/utils/hooks';
|
|
2
|
-
import { forwardRef, memo, useCallback, useMemo } from 'react';
|
|
2
|
+
import { forwardRef, memo, useCallback, useContext, useId, useMemo } from 'react';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { resolveStateVariant } from '../../utils';
|
|
6
6
|
import { Text } from '../Text';
|
|
7
7
|
import CheckboxBase from './CheckboxBase';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
export type Props = CheckBoxBaseProps;
|
|
8
|
+
import { CheckboxItemContext } from './context';
|
|
9
|
+
import type { CheckboxLabelProps, CheckboxProps, CheckboxRowProps } from './types';
|
|
10
|
+
import { checkboxRowStyles } from './utils';
|
|
12
11
|
|
|
12
|
+
/**
|
|
13
|
+
* The checkbox control (the box). Use inside a CheckboxRow, or standalone with `value`/`onValueChange`.
|
|
14
|
+
*/
|
|
13
15
|
const Checkbox = (
|
|
14
16
|
{
|
|
15
17
|
value: valueProp,
|
|
16
|
-
onChange: onChangeProp,
|
|
17
18
|
defaultValue,
|
|
18
|
-
|
|
19
|
+
onValueChange,
|
|
19
20
|
indeterminate,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
containerStyle,
|
|
23
|
-
labelProps,
|
|
24
|
-
position = 'leading',
|
|
25
|
-
accessibilityLabel: accessibilityLabelProp,
|
|
21
|
+
disabled: disabledProp,
|
|
22
|
+
size: sizeProp,
|
|
26
23
|
testID,
|
|
27
|
-
size = 'md',
|
|
28
|
-
style: styleProp,
|
|
29
24
|
...rest
|
|
30
|
-
}:
|
|
25
|
+
}: CheckboxProps,
|
|
31
26
|
ref: any,
|
|
32
27
|
) => {
|
|
33
|
-
const
|
|
28
|
+
const item = useContext(CheckboxItemContext);
|
|
29
|
+
|
|
30
|
+
const [value, setValue] = useControlledValue({
|
|
34
31
|
value: valueProp,
|
|
35
|
-
onChange: onChangeProp,
|
|
36
32
|
defaultValue,
|
|
37
|
-
|
|
33
|
+
onChange: onValueChange,
|
|
34
|
+
disabled: disabledProp,
|
|
38
35
|
});
|
|
39
36
|
|
|
40
|
-
//
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
// Use variants only when label is provided
|
|
47
|
-
if (label) {
|
|
48
|
-
styles.useVariants({
|
|
49
|
-
variant: 'item',
|
|
50
|
-
// @ts-ignore // TODO - fix this
|
|
51
|
-
state: state as States,
|
|
52
|
-
isLeading,
|
|
53
|
-
// @ts-ignore // TODO - fix this
|
|
54
|
-
size,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
37
|
+
// Inside a CheckboxRow the item context drives state; standalone (bare) mode owns its own.
|
|
38
|
+
const checked = item ? item.checked : Boolean(value);
|
|
39
|
+
const disabled = disabledProp ?? item?.disabled;
|
|
40
|
+
const isIndeterminate = item ? item.indeterminate : indeterminate;
|
|
41
|
+
const size = sizeProp ?? item?.size ?? 'md';
|
|
42
|
+
const labelId = item?.labelId;
|
|
57
43
|
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
68
|
-
}, [containerStyle, labelStyle, styleProp]);
|
|
69
|
-
|
|
70
|
-
const onLabelPress = useCallback(() => {
|
|
71
|
-
if (!disabled) {
|
|
72
|
-
onChange(!value);
|
|
73
|
-
}
|
|
74
|
-
}, [onChange, value, disabled]);
|
|
75
|
-
|
|
76
|
-
const accessibilityState = useMemo(
|
|
77
|
-
() => ({
|
|
78
|
-
checked: Boolean(value),
|
|
79
|
-
disabled,
|
|
80
|
-
}),
|
|
81
|
-
[disabled, value],
|
|
44
|
+
const onChange = useCallback(
|
|
45
|
+
(next: boolean) => {
|
|
46
|
+
if (item) {
|
|
47
|
+
item.onToggle();
|
|
48
|
+
} else {
|
|
49
|
+
setValue(next);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
[item, setValue],
|
|
82
53
|
);
|
|
83
54
|
|
|
84
|
-
|
|
85
|
-
const checkboxAccessibilityLabel = label ? undefined : accessibilityLabelProp;
|
|
86
|
-
|
|
87
|
-
const checkbox = (
|
|
55
|
+
return (
|
|
88
56
|
<CheckboxBase
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
{...rest}
|
|
58
|
+
ref={ref}
|
|
59
|
+
value={checked}
|
|
91
60
|
onChange={onChange}
|
|
61
|
+
indeterminate={isIndeterminate}
|
|
92
62
|
disabled={disabled}
|
|
93
|
-
indeterminate={indeterminate}
|
|
94
63
|
size={size}
|
|
95
|
-
style={checkboxStyle}
|
|
96
64
|
testID={testID}
|
|
97
|
-
|
|
98
|
-
{...rest}
|
|
65
|
+
accessibilityLabelledBy={labelId}
|
|
99
66
|
/>
|
|
100
67
|
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The label for a CheckboxRow. Pressing it toggles the checkbox, and it is wired to the control via
|
|
72
|
+
* `nativeID` / `accessibilityLabelledBy` (web `id` / `aria-labelledby`).
|
|
73
|
+
*/
|
|
74
|
+
export const CheckboxLabel = memo(({ children, style, ...rest }: CheckboxLabelProps) => {
|
|
75
|
+
const item = useContext(CheckboxItemContext);
|
|
76
|
+
|
|
77
|
+
const state = resolveStateVariant({
|
|
78
|
+
disabled: !!item?.disabled,
|
|
79
|
+
checked: !!item?.checked,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
checkboxRowStyles.useVariants({ state: state as any });
|
|
101
83
|
|
|
102
|
-
if (!
|
|
103
|
-
return
|
|
84
|
+
if (!item) {
|
|
85
|
+
return (
|
|
86
|
+
<Text style={style} {...rest}>
|
|
87
|
+
{children}
|
|
88
|
+
</Text>
|
|
89
|
+
);
|
|
104
90
|
}
|
|
105
91
|
|
|
106
92
|
return (
|
|
107
|
-
<
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{...labelProps}
|
|
117
|
-
style={labelStyles}>
|
|
118
|
-
{label}
|
|
119
|
-
</Text>
|
|
120
|
-
{!isLeading && checkbox}
|
|
121
|
-
</View>
|
|
93
|
+
<Text
|
|
94
|
+
nativeID={item.labelId}
|
|
95
|
+
onPress={item.disabled ? undefined : item.onToggle}
|
|
96
|
+
disabled={item.disabled}
|
|
97
|
+
selectable={false}
|
|
98
|
+
style={[checkboxRowStyles.label, style]}
|
|
99
|
+
{...rest}>
|
|
100
|
+
{children}
|
|
101
|
+
</Text>
|
|
122
102
|
);
|
|
123
|
-
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
CheckboxLabel.displayName = 'Checkbox_Label';
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A row that binds checked state to a Checkbox control and its Checkbox.Label. The row itself is not
|
|
109
|
+
* pressable — only the Checkbox and Checkbox.Label inside it are. Children may be in any order.
|
|
110
|
+
*/
|
|
111
|
+
export const CheckboxRow = memo(
|
|
112
|
+
forwardRef(
|
|
113
|
+
(
|
|
114
|
+
{
|
|
115
|
+
value: valueProp,
|
|
116
|
+
defaultValue,
|
|
117
|
+
onValueChange,
|
|
118
|
+
indeterminate,
|
|
119
|
+
disabled,
|
|
120
|
+
size,
|
|
121
|
+
style,
|
|
122
|
+
children,
|
|
123
|
+
...rest
|
|
124
|
+
}: CheckboxRowProps,
|
|
125
|
+
ref: any,
|
|
126
|
+
) => {
|
|
127
|
+
const labelId = useId();
|
|
128
|
+
|
|
129
|
+
const [value, setValue] = useControlledValue({
|
|
130
|
+
value: valueProp,
|
|
131
|
+
defaultValue,
|
|
132
|
+
onChange: onValueChange,
|
|
133
|
+
disabled,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const checked = Boolean(value);
|
|
137
|
+
|
|
138
|
+
const onToggle = useCallback(() => {
|
|
139
|
+
if (disabled) return;
|
|
140
|
+
setValue(!checked);
|
|
141
|
+
}, [disabled, setValue, checked]);
|
|
142
|
+
|
|
143
|
+
const contextValue = useMemo(
|
|
144
|
+
() => ({ checked, onToggle, disabled, indeterminate, size, labelId }),
|
|
145
|
+
[checked, onToggle, disabled, indeterminate, size, labelId],
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<CheckboxItemContext.Provider value={contextValue}>
|
|
150
|
+
<View ref={ref} style={[checkboxRowStyles.row, style]} {...rest}>
|
|
151
|
+
{children}
|
|
152
|
+
</View>
|
|
153
|
+
</CheckboxItemContext.Provider>
|
|
154
|
+
);
|
|
155
|
+
},
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
CheckboxRow.displayName = 'Checkbox_Row';
|
|
124
160
|
|
|
125
161
|
export default memo(forwardRef(Checkbox));
|
|
@@ -4,12 +4,10 @@ import { View } from 'react-native';
|
|
|
4
4
|
import { resolveStateVariant } from '../../utils';
|
|
5
5
|
import { Icon } from '../Icon';
|
|
6
6
|
import { TouchableRipple } from '../TouchableRipple';
|
|
7
|
-
import type {
|
|
7
|
+
import type { CheckboxBaseProps, States } from './types';
|
|
8
8
|
import { iconSizeMap, styles } from './utils';
|
|
9
9
|
|
|
10
|
-
export type Props = Omit<
|
|
11
|
-
value: boolean;
|
|
12
|
-
};
|
|
10
|
+
export type Props = Omit<CheckboxBaseProps, 'uncheckedColor'>;
|
|
13
11
|
|
|
14
12
|
const CheckboxIOS = (
|
|
15
13
|
{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { forwardRef, memo,
|
|
2
|
-
import { type ViewProps } from 'react-native';
|
|
1
|
+
import { forwardRef, memo, useCallback, useMemo } from 'react';
|
|
3
2
|
|
|
4
3
|
import { useActionState } from '../../hooks';
|
|
5
4
|
import { resolveStateVariant } from '../../utils';
|
|
@@ -7,16 +6,10 @@ import { tokenStylesParser } from '../../utils/tokenStylesParser';
|
|
|
7
6
|
import { Icon } from '../Icon';
|
|
8
7
|
import { StateLayer } from '../StateLayer';
|
|
9
8
|
import { TouchableRipple } from '../TouchableRipple';
|
|
10
|
-
import type {
|
|
9
|
+
import type { CheckboxBaseProps, States } from './types';
|
|
11
10
|
import { iconSizeMap, styles } from './utils';
|
|
12
11
|
|
|
13
|
-
export type Props =
|
|
14
|
-
value: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* props for the stateLayer
|
|
17
|
-
*/
|
|
18
|
-
stateLayerProps?: PropsWithoutRef<ViewProps>;
|
|
19
|
-
};
|
|
12
|
+
export type Props = CheckboxBaseProps;
|
|
20
13
|
|
|
21
14
|
const CheckboxAndroid = (
|
|
22
15
|
{
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Size } from './types';
|
|
4
|
+
|
|
5
|
+
export type CheckboxItemContextType = {
|
|
6
|
+
checked: boolean;
|
|
7
|
+
onToggle: () => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
size?: Size;
|
|
11
|
+
labelId: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const CheckboxItemContext = createContext<CheckboxItemContextType | null>(null);
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { getRegisteredComponentWithFallback } from '../../core';
|
|
2
|
-
|
|
2
|
+
// @component ./Checkbox.tsx
|
|
3
|
+
import CheckboxBox, { CheckboxLabel, CheckboxRow as CheckboxRowComponent } from './Checkbox';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
const CheckboxDefault = Object.assign(CheckboxBox, {
|
|
6
|
+
Label: CheckboxLabel,
|
|
7
|
+
Row: CheckboxRowComponent,
|
|
8
|
+
});
|
|
5
9
|
|
|
6
|
-
export
|
|
7
|
-
export
|
|
10
|
+
export const Checkbox = getRegisteredComponentWithFallback('Checkbox', CheckboxDefault);
|
|
11
|
+
export const CheckboxRow = CheckboxRowComponent;
|
|
12
|
+
|
|
13
|
+
export type { CheckboxLabelProps, CheckboxProps, CheckboxRowProps } from './types';
|
|
14
|
+
export { checkboxRowStyles, styles as checkboxStyles } from './utils';
|
|
@@ -1,46 +1,45 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
import type { TextProps, ViewProps } from 'react-native';
|
|
2
3
|
|
|
3
4
|
import type { TouchableRippleProps } from '../TouchableRipple';
|
|
4
5
|
|
|
5
6
|
export type Size = 'sm' | 'md' | 'lg';
|
|
6
7
|
export type States = 'disabled' | 'checked' | 'hovered' | 'checkedAndHovered';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Internal props for the platform control (CheckboxBase).
|
|
11
|
+
*/
|
|
12
|
+
export type CheckboxBaseProps = Omit<TouchableRippleProps, 'children'> & {
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
14
|
+
* Whether the checkbox is checked.
|
|
11
15
|
*/
|
|
12
|
-
value
|
|
13
|
-
/**
|
|
14
|
-
* defaultValue of checkbox.
|
|
15
|
-
*/
|
|
16
|
-
defaultValue?: boolean;
|
|
16
|
+
value: boolean;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Called when the checkbox is pressed.
|
|
19
19
|
*/
|
|
20
20
|
onChange?: (newValue: boolean) => void;
|
|
21
21
|
/**
|
|
22
|
-
* Whether
|
|
22
|
+
* Whether the checkbox is in the indeterminate state (overrides `value`).
|
|
23
23
|
*/
|
|
24
24
|
indeterminate?: boolean;
|
|
25
25
|
/**
|
|
26
|
-
* Whether checkbox is disabled.
|
|
26
|
+
* Whether the checkbox is disabled.
|
|
27
27
|
*/
|
|
28
28
|
disabled?: boolean;
|
|
29
29
|
/**
|
|
30
|
-
* Size of the
|
|
31
|
-
* Should be a number or a Design Token
|
|
30
|
+
* Size of the checkbox.
|
|
32
31
|
*/
|
|
33
32
|
size?: Size;
|
|
34
33
|
/**
|
|
35
|
-
* Custom color for
|
|
34
|
+
* Custom color for the checked checkbox.
|
|
36
35
|
*/
|
|
37
|
-
|
|
36
|
+
color?: string;
|
|
38
37
|
/**
|
|
39
|
-
* Custom color for checkbox.
|
|
38
|
+
* Custom color for the unchecked checkbox.
|
|
40
39
|
*/
|
|
41
|
-
|
|
40
|
+
uncheckedColor?: string;
|
|
42
41
|
/**
|
|
43
|
-
* Accessibility label for the touchable.
|
|
42
|
+
* Accessibility label for the touchable.
|
|
44
43
|
*/
|
|
45
44
|
accessibilityLabel?: string;
|
|
46
45
|
/**
|
|
@@ -48,25 +47,60 @@ export type CheckBoxBaseProps = Omit<TouchableRippleProps, 'children'> & {
|
|
|
48
47
|
*/
|
|
49
48
|
testID?: string;
|
|
50
49
|
/**
|
|
51
|
-
*
|
|
50
|
+
* Props for the state layer.
|
|
51
|
+
*/
|
|
52
|
+
stateLayerProps?: PropsWithoutRef<ViewProps>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The checkbox control (the box). Use inside a CheckboxRow, or standalone with `value`/`onValueChange`.
|
|
57
|
+
*/
|
|
58
|
+
export type CheckboxProps = Omit<CheckboxBaseProps, 'value' | 'onChange'> & {
|
|
59
|
+
/**
|
|
60
|
+
* Whether the checkbox is checked (controlled).
|
|
61
|
+
*/
|
|
62
|
+
value?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Default checked state (uncontrolled).
|
|
65
|
+
*/
|
|
66
|
+
defaultValue?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Called when the checked state changes.
|
|
69
|
+
*/
|
|
70
|
+
onValueChange?: (newValue: boolean) => void;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type CheckboxRowProps = ViewProps & {
|
|
74
|
+
/**
|
|
75
|
+
* Whether the checkbox is checked (controlled).
|
|
76
|
+
*/
|
|
77
|
+
value?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Default checked state (uncontrolled).
|
|
80
|
+
*/
|
|
81
|
+
defaultValue?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Called when the checked state changes.
|
|
52
84
|
*/
|
|
53
|
-
|
|
85
|
+
onValueChange?: (newValue: boolean) => void;
|
|
54
86
|
/**
|
|
55
|
-
*
|
|
87
|
+
* Whether the checkbox is in the indeterminate state.
|
|
56
88
|
*/
|
|
57
|
-
|
|
89
|
+
indeterminate?: boolean;
|
|
58
90
|
/**
|
|
59
|
-
*
|
|
91
|
+
* Disables the row (control + label).
|
|
60
92
|
*/
|
|
61
|
-
|
|
93
|
+
disabled?: boolean;
|
|
62
94
|
/**
|
|
63
|
-
*
|
|
95
|
+
* Size applied to the checkbox.
|
|
64
96
|
*/
|
|
65
|
-
|
|
97
|
+
size?: Size;
|
|
66
98
|
/**
|
|
67
|
-
* Checkbox control
|
|
99
|
+
* Checkbox control and Checkbox.Label, in any order.
|
|
68
100
|
*/
|
|
69
|
-
|
|
101
|
+
children: ReactNode;
|
|
102
|
+
};
|
|
70
103
|
|
|
71
|
-
|
|
104
|
+
export type CheckboxLabelProps = TextProps & {
|
|
105
|
+
children: ReactNode;
|
|
72
106
|
};
|
|
@@ -21,17 +21,14 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
|
|
|
21
21
|
sm: {
|
|
22
22
|
padding: PADDING,
|
|
23
23
|
borderRadius: 16,
|
|
24
|
-
// iconSize: iconSizeMap.sm,
|
|
25
24
|
},
|
|
26
25
|
md: {
|
|
27
26
|
padding: PADDING,
|
|
28
27
|
borderRadius: 18,
|
|
29
|
-
// iconSize: iconSizeMap.md,
|
|
30
28
|
},
|
|
31
29
|
lg: {
|
|
32
30
|
padding: PADDING,
|
|
33
31
|
borderRadius: 20,
|
|
34
|
-
// iconSize: iconSizeMap.lg,
|
|
35
32
|
},
|
|
36
33
|
},
|
|
37
34
|
},
|
|
@@ -81,57 +78,6 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
|
|
|
81
78
|
},
|
|
82
79
|
},
|
|
83
80
|
},
|
|
84
|
-
itemContainer: {
|
|
85
|
-
flexDirection: 'row',
|
|
86
|
-
alignItems: 'center',
|
|
87
|
-
justifyContent: 'space-between',
|
|
88
|
-
},
|
|
89
|
-
label: {
|
|
90
|
-
flexShrink: 1,
|
|
91
|
-
flexGrow: 1,
|
|
92
|
-
variants: {
|
|
93
|
-
variant: {
|
|
94
|
-
item: {
|
|
95
|
-
color: theme.colors.onSurface,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
isLeading: {
|
|
99
|
-
true: {
|
|
100
|
-
textAlign: 'right',
|
|
101
|
-
paddingLeft: 0,
|
|
102
|
-
paddingRight: theme.spacings['2'],
|
|
103
|
-
},
|
|
104
|
-
false: {
|
|
105
|
-
textAlign: 'left',
|
|
106
|
-
paddingLeft: theme.spacings['2'],
|
|
107
|
-
paddingRight: 0,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
compoundVariants: [
|
|
112
|
-
{
|
|
113
|
-
variant: 'item',
|
|
114
|
-
size: 'sm',
|
|
115
|
-
styles: {
|
|
116
|
-
...theme.typescale.bodyMedium,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
variant: 'item',
|
|
121
|
-
size: 'md',
|
|
122
|
-
styles: {
|
|
123
|
-
...theme.typescale.bodyMedium,
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
variant: 'item',
|
|
128
|
-
size: 'lg',
|
|
129
|
-
styles: {
|
|
130
|
-
...theme.typescale.bodyLarge,
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
81
|
icon: {
|
|
136
82
|
color: theme.colors.onSurfaceVariant,
|
|
137
83
|
|
|
@@ -150,36 +96,32 @@ const checkboxStylesDefault = StyleSheet.create(theme => ({
|
|
|
150
96
|
},
|
|
151
97
|
},
|
|
152
98
|
},
|
|
153
|
-
|
|
154
|
-
// if (variant === 'android') {
|
|
155
|
-
// return {
|
|
156
|
-
// root: {
|
|
157
|
-
// ...(size === 'sm' && { width: 32, height: 32 }),
|
|
158
|
-
// ...(size === 'md' && { width: 36, height: 36 }),
|
|
159
|
-
// ...(size === 'lg' && { width: 40, height: 40 }),
|
|
160
|
-
// },
|
|
161
|
-
// stateLayer: {
|
|
162
|
-
// ...(state === 'hovered' && {
|
|
163
|
-
// backgroundColor: theme.colors.stateLayer.hover.onSurface,
|
|
164
|
-
// }),
|
|
165
|
-
// ...(state === 'checkedAndHovered' && {
|
|
166
|
-
// backgroundColor: theme.colors.stateLayer.hover.primary,
|
|
167
|
-
// }),
|
|
168
|
-
// },
|
|
169
|
-
// } as any;
|
|
170
|
-
// }
|
|
99
|
+
}));
|
|
171
100
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
101
|
+
const checkboxRowStylesDefault = StyleSheet.create(theme => ({
|
|
102
|
+
row: {
|
|
103
|
+
flexDirection: 'row',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
},
|
|
106
|
+
label: {
|
|
107
|
+
flexShrink: 1,
|
|
108
|
+
flexGrow: 1,
|
|
109
|
+
color: theme.colors.onSurface,
|
|
110
|
+
...theme.typescale.bodyLarge,
|
|
111
|
+
|
|
112
|
+
variants: {
|
|
113
|
+
state: {
|
|
114
|
+
checked: {},
|
|
115
|
+
checkedAndHovered: {},
|
|
116
|
+
hovered: {},
|
|
117
|
+
disabled: { color: theme.colors.onSurfaceDisabled },
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
183
121
|
}));
|
|
184
122
|
|
|
185
123
|
export const styles = getRegisteredComponentStylesWithFallback('Checkbox', checkboxStylesDefault);
|
|
124
|
+
export const checkboxRowStyles = getRegisteredComponentStylesWithFallback(
|
|
125
|
+
'Checkbox_Row',
|
|
126
|
+
checkboxRowStylesDefault,
|
|
127
|
+
);
|