Skip to content

Commit 1648808

Browse files
authored
Separate radioGroup and radioButton to fix their packages (#1388)
1 parent 4ae1bf3 commit 1648808

File tree

11 files changed

+197
-8
lines changed

11 files changed

+197
-8
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import React from 'react';
2+
import { TextStyle, StyleProp, ImageSourcePropType, ImageStyle, ViewStyle, ViewProps } from 'react-native';
3+
import { RadioGroupContextProps } from '../radioGroup/RadioGroupContext';
4+
export declare type RadioButtonProps = RadioGroupContextProps & ViewProps & {
5+
/**
6+
* The identifier value of the radio button. must be different than other RadioButtons in the same group
7+
*/
8+
value?: string | number | boolean;
9+
/**
10+
* When using RadioButton without a RadioGroup, use this prop to toggle selection
11+
*/
12+
selected?: boolean;
13+
/**
14+
* Invoked when pressing the button
15+
*/
16+
onPress?: (selected: boolean) => void;
17+
/**
18+
* Whether the radio button should be disabled
19+
*/
20+
disabled?: boolean;
21+
/**
22+
* The color of the radio button
23+
*/
24+
color?: string;
25+
/**
26+
* The size of the radio button, affect both width & height
27+
*/
28+
size?: number;
29+
/**
30+
* The radio button border radius
31+
*/
32+
borderRadius?: number;
33+
/**
34+
* A label for the radio button description
35+
*/
36+
label?: string;
37+
/**
38+
* Label style
39+
*/
40+
labelStyle?: TextStyle;
41+
/**
42+
* Icon image source
43+
*/
44+
iconSource?: ImageSourcePropType;
45+
/**
46+
* Icon image style
47+
*/
48+
iconStyle?: ImageStyle;
49+
/**
50+
* Should the icon be on the right side of the label
51+
*/
52+
iconOnRight?: boolean;
53+
/**
54+
* Should the content be rendered right to the button
55+
*/
56+
contentOnRight?: boolean;
57+
/**
58+
* Additional styling for the container
59+
*/
60+
containerStyle?: StyleProp<ViewStyle>;
61+
};
62+
export declare type RadioButtonPropTypes = RadioButtonProps;
63+
declare const _default: React.ComponentClass<RadioGroupContextProps & ViewProps & {
64+
/**
65+
* The identifier value of the radio button. must be different than other RadioButtons in the same group
66+
*/
67+
value?: string | number | boolean | undefined;
68+
/**
69+
* When using RadioButton without a RadioGroup, use this prop to toggle selection
70+
*/
71+
selected?: boolean | undefined;
72+
/**
73+
* Invoked when pressing the button
74+
*/
75+
onPress?: ((selected: boolean) => void) | undefined;
76+
/**
77+
* Whether the radio button should be disabled
78+
*/
79+
disabled?: boolean | undefined;
80+
/**
81+
* The color of the radio button
82+
*/
83+
color?: string | undefined;
84+
/**
85+
* The size of the radio button, affect both width & height
86+
*/
87+
size?: number | undefined;
88+
/**
89+
* The radio button border radius
90+
*/
91+
borderRadius?: number | undefined;
92+
/**
93+
* A label for the radio button description
94+
*/
95+
label?: string | undefined;
96+
/**
97+
* Label style
98+
*/
99+
labelStyle?: TextStyle | undefined;
100+
/**
101+
* Icon image source
102+
*/
103+
iconSource?: ImageSourcePropType | undefined;
104+
/**
105+
* Icon image style
106+
*/
107+
iconStyle?: ImageStyle | undefined;
108+
/**
109+
* Should the icon be on the right side of the label
110+
*/
111+
iconOnRight?: boolean | undefined;
112+
/**
113+
* Should the content be rendered right to the button
114+
*/
115+
contentOnRight?: boolean | undefined;
116+
/**
117+
* Additional styling for the container
118+
*/
119+
containerStyle?: StyleProp<ViewStyle>;
120+
} & {
121+
useCustomTheme?: boolean | undefined;
122+
}, any>;
123+
export default _default;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react';
2+
export interface RadioGroupContextProps {
3+
/**
4+
* The identifier value of the radio button. must be different than other RadioButtons in the same group
5+
*/
6+
value?: string | number | boolean;
7+
/**
8+
* Invoked once when value changes, by selecting one of the radio buttons in the group
9+
*/
10+
onValueChange?: (value: string | number | boolean) => void;
11+
}
12+
export declare type RadioGroupContextPropTypes = RadioGroupContextProps;
13+
declare const _default: React.Context<RadioGroupContextProps>;
14+
export default _default;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import React from 'react';
2+
export default function asRadioGroupChild(WrappedComponent: React.ComponentType<any>): any;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React, { PureComponent, GetDerivedStateFromProps } from 'react';
2+
import { BaseComponentInjectedProps, ForwardRefInjectedProps } from '../../commons/new';
3+
import { ViewProps } from '../view';
4+
export declare type RadioGroupProps = ViewProps & {
5+
/**
6+
* The initial value of the selected radio button
7+
*/
8+
initialValue?: string | number | boolean;
9+
/**
10+
* Invoked once when value changes, by selecting one of the radio buttons in the group
11+
*/
12+
onValueChange?: ((value: string) => void) | ((value: number) => void) | ((value: boolean) => void) | ((value: any) => void);
13+
};
14+
export declare type RadioGroupPropTypes = RadioGroupProps;
15+
interface RadioGroupState {
16+
initialValue?: RadioGroupProps['initialValue'];
17+
value?: RadioGroupProps['initialValue'];
18+
}
19+
declare type Props = RadioGroupProps & BaseComponentInjectedProps & ForwardRefInjectedProps;
20+
/**
21+
* @description: Wrap a group of Radio Buttons to automatically control their selection
22+
* @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/RadioButton/Default.gif?raw=true, https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/RadioButton/Alignment.gif?raw=true, https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/RadioButton/Custom.gif?raw=true
23+
* @image: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/RadioButton/Individual.png?raw=true
24+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/RadioButtonScreen.js
25+
*/
26+
declare class RadioGroup extends PureComponent<Props, RadioGroupState> {
27+
static displayName: string;
28+
constructor(props: Props);
29+
static getDerivedStateFromProps: GetDerivedStateFromProps<Props, RadioGroupState>;
30+
getContextProviderValue(): {
31+
value: string | number | boolean | undefined;
32+
onValueChange: (value: string | number | boolean | undefined) => void;
33+
};
34+
onValueChange: (value: RadioGroupProps['initialValue']) => void;
35+
render(): JSX.Element;
36+
}
37+
export { RadioGroup };
38+
declare const _default: React.ComponentClass<ViewProps & {
39+
/**
40+
* The initial value of the selected radio button
41+
*/
42+
initialValue?: string | number | boolean | undefined;
43+
/**
44+
* Invoked once when value changes, by selecting one of the radio buttons in the group
45+
*/
46+
onValueChange?: ((value: string) => void) | ((value: number) => void) | ((value: boolean) => void) | ((value: any) => void) | undefined;
47+
} & {
48+
useCustomTheme?: boolean | undefined;
49+
}, any>;
50+
export default _default;

generatedTypes/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export {default as FloatingButton, FloatingButtonProps} from './components/float
4343
export {default as Hint, HintProps} from './components/hint';
4444
export {default as Image, ImageProps} from './components/image';
4545
export {default as Overlay, OverlayTypes} from './components/overlay';
46-
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton/RadioButton';
47-
export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioButton/RadioGroup';
46+
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton';
47+
export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioGroup';
4848
export {default as SectionsWheelPicker, SectionsWheelPickerProps} from './components/sectionsWheelPicker';
4949
export {default as HapticService, HapticType} from './services/HapticService';
5050
export {default as SegmentedControl, SegmentedControlProps, SegmentedControlItemProps} from './components/segmentedControl';

src/components/radioButton/RadioButton.tsx renamed to src/components/radioButton/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import TouchableOpacity from '../touchableOpacity';
1717
import View from '../view';
1818
import Text from '../text';
1919
import Image from '../image';
20-
import asRadioGroupChild from './asRadioGroupChild';
21-
import {RadioGroupContextProps} from './RadioGroupContext';
20+
import asRadioGroupChild from '../radioGroup/asRadioGroupChild';
21+
import {RadioGroupContextProps} from '../radioGroup/RadioGroupContext';
2222

2323
const DEFAULT_SIZE = 24;
2424
const DEFAULT_COLOR = Colors.primary;

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ export default {
165165
return require('./components/chipsInput').default;
166166
},
167167
get RadioButton() {
168-
return require('./components/radioButton/RadioButton').default;
168+
return require('./components/radioButton').default;
169169
},
170170
get RadioGroup() {
171-
return require('./components/radioButton/RadioGroup').default;
171+
return require('./components/radioGroup').default;
172172
},
173173
get ScrollBar() {
174174
return require('./components/scrollBar').default;

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export {default as ColorSwatch, ColorSwatchProps} from './components/colorPicker
3838
export {default as FloatingButton, FloatingButtonProps} from './components/floatingButton';
3939
export {default as Image, ImageProps} from './components/image';
4040
export {default as Overlay, OverlayTypes} from './components/overlay';
41-
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton/RadioButton';
42-
export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioButton/RadioGroup';
41+
export {default as RadioButton, RadioButtonPropTypes, RadioButtonProps} from './components/radioButton';
42+
export {default as RadioGroup, RadioGroupPropTypes, RadioGroupProps} from './components/radioGroup';
4343
export {default as SectionsWheelPicker, SectionsWheelPickerProps} from './components/sectionsWheelPicker';
4444
export {default as SegmentedControl, SegmentedControlProps, SegmentedControlItemProps} from './components/segmentedControl';
4545
export {default as Switch, SwitchProps} from './components/switch';

0 commit comments

Comments
 (0)