bootstrap-rn 0.3.5 → 0.3.6
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/lib/commonjs/components/Image.js.map +1 -1
- package/lib/commonjs/components/forms/RadioGroup.js.map +1 -1
- package/lib/commonjs/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/commonjs/components/modal/Modal.js +1 -1
- package/lib/commonjs/components/modal/Modal.js.map +1 -1
- package/lib/commonjs/components/modal/ModalBody.js +1 -1
- package/lib/commonjs/components/modal/ModalBody.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasBody.js.map +1 -1
- package/lib/commonjs/style/makeUtilities.js.map +1 -1
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/forms/RadioGroup.js.map +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/modal/Modal.js +1 -1
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/ModalBody.js +1 -1
- package/lib/module/components/modal/ModalBody.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasBody.js.map +1 -1
- package/lib/module/style/makeUtilities.js.map +1 -1
- package/lib/types/components/forms/Picker.d.ts +4 -4
- package/lib/types/components/forms/Picker.d.ts.map +1 -1
- package/lib/types/components/forms/PickerItem.d.ts +1 -1
- package/lib/types/components/forms/PickerItem.d.ts.map +1 -1
- package/lib/types/components/forms/Radio.d.ts +1 -1
- package/lib/types/components/forms/Radio.d.ts.map +1 -1
- package/lib/types/components/forms/RadioContext.d.ts +2 -2
- package/lib/types/components/forms/RadioContext.d.ts.map +1 -1
- package/lib/types/components/forms/RadioGroup.d.ts +2 -2
- package/lib/types/components/forms/RadioGroup.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts +2 -2
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts.map +1 -1
- package/lib/types/components/modal/Modal.d.ts +3 -4
- package/lib/types/components/modal/Modal.d.ts.map +1 -1
- package/lib/types/components/modal/ModalBody.d.ts +3 -6
- package/lib/types/components/modal/ModalBody.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasBody.d.ts +3 -4
- package/lib/types/components/offcanvas/OffcanvasBody.d.ts.map +1 -1
- package/lib/types/style/makeUtilities.d.ts +6 -2
- package/lib/types/style/makeUtilities.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Image.tsx +1 -1
- package/src/components/forms/Picker.tsx +191 -191
- package/src/components/forms/PickerItem.tsx +32 -32
- package/src/components/forms/Radio.tsx +37 -37
- package/src/components/forms/RadioContext.ts +13 -13
- package/src/components/forms/RadioGroup.tsx +42 -40
- package/src/components/forms/internals/PickerNative.tsx +193 -195
- package/src/components/forms/internals/PickerNativeContext.ts +14 -14
- package/src/components/forms/internals/PickerNativeItem.tsx +59 -59
- package/src/components/forms/internals/PickerWebItem.tsx +36 -36
- package/src/components/modal/Modal.tsx +234 -233
- package/src/components/modal/ModalBody.tsx +52 -56
- package/src/components/offcanvas/OffcanvasBody.tsx +64 -66
- package/src/style/makeUtilities.ts +79 -76
package/package.json
CHANGED
package/src/components/Image.tsx
CHANGED
|
@@ -11,7 +11,7 @@ export interface ImageProps extends Omit<BaseImageProps, 'style'> {
|
|
|
11
11
|
styleName?: StyleName;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const Image = React.forwardRef<
|
|
14
|
+
const Image = React.forwardRef<ImageRef, ImageProps>((props, ref) => {
|
|
15
15
|
const { style, styleName, ...elementProps } = props;
|
|
16
16
|
|
|
17
17
|
const media = useMedia();
|
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
import React, { useState, useMemo } from 'react';
|
|
2
|
-
import { Platform, NativeSyntheticEvent, TargetedEvent } from 'react-native';
|
|
3
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
4
|
-
import css from '../../style/css';
|
|
5
|
-
import useMedia from '../../hooks/useMedia';
|
|
6
|
-
import { getStyles, each } from '../../utils';
|
|
7
|
-
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
8
|
-
import { escapeSvg } from '../../theme/functions';
|
|
9
|
-
import useStyle from '../../hooks/useStyle';
|
|
10
|
-
import useModifier from '../../hooks/useModifier';
|
|
11
|
-
import PickerWeb from './internals/PickerWeb';
|
|
12
|
-
import PickerNative from './internals/PickerNative';
|
|
13
|
-
import PickerItem from './PickerItem';
|
|
14
|
-
import PickerContext from './PickerContext';
|
|
15
|
-
import type {
|
|
16
|
-
FormValidationState,
|
|
17
|
-
ThemeVariables,
|
|
18
|
-
UseFormFieldProps,
|
|
19
|
-
} from '../../types';
|
|
20
|
-
import type { PressableProps, PressableRef } from '../Pressable';
|
|
21
|
-
|
|
22
|
-
export interface MenuComponentProps {
|
|
23
|
-
children: React.ReactElement | React.ReactElement[];
|
|
24
|
-
selectedValue?:
|
|
25
|
-
onValueChange: (value
|
|
26
|
-
onClose: () => void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface PickerProps extends UseFormFieldProps, PressableProps {
|
|
30
|
-
children: React.ReactElement | React.ReactElement[];
|
|
31
|
-
selectedValue?:
|
|
32
|
-
onValueChange?: (value
|
|
33
|
-
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
34
|
-
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
35
|
-
placeholder?: string;
|
|
36
|
-
placeholderTextColor?: string;
|
|
37
|
-
size?: 'sm' | 'lg';
|
|
38
|
-
disabled?: boolean;
|
|
39
|
-
valid?: boolean;
|
|
40
|
-
invalid?: boolean;
|
|
41
|
-
useNativeComponent?: boolean;
|
|
42
|
-
autoFocus?: boolean;
|
|
43
|
-
MenuComponent?: React.FC<MenuComponentProps>;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const styles = StyleSheet.create({
|
|
47
|
-
select: css`
|
|
48
|
-
opacity: 1;
|
|
49
|
-
`,
|
|
50
|
-
'.form-select': css`
|
|
51
|
-
width: 100%;
|
|
52
|
-
padding: $form-select-padding-y $form-select-indicator-padding
|
|
53
|
-
$form-select-padding-y $form-select-padding-x;
|
|
54
|
-
font-family: $form-select-font-family;
|
|
55
|
-
font-size: $form-select-font-size;
|
|
56
|
-
font-weight: $form-select-font-weight;
|
|
57
|
-
line-height: $form-select-font-size * $form-select-line-height;
|
|
58
|
-
color: $form-select-color;
|
|
59
|
-
background-color: $form-select-bg;
|
|
60
|
-
background-image: ${(t: ThemeVariables) =>
|
|
61
|
-
escapeSvg(t['form-select-indicator'])};
|
|
62
|
-
background-repeat: no-repeat;
|
|
63
|
-
background-position: $form-select-bg-position;
|
|
64
|
-
background-size: $form-select-bg-size;
|
|
65
|
-
border: $form-select-border-width solid $form-select-border-color;
|
|
66
|
-
border-radius: $form-select-border-radius;
|
|
67
|
-
@include platform(web) {
|
|
68
|
-
appearance: none;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&:focus {
|
|
72
|
-
border-color: $form-select-focus-border-color;
|
|
73
|
-
@include platform(web) {
|
|
74
|
-
outline-width: 0;
|
|
75
|
-
box-shadow: $form-select-focus-box-shadow;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
`,
|
|
79
|
-
'.form-select.disabled': css`
|
|
80
|
-
color: $form-select-disabled-color;
|
|
81
|
-
background-color: $form-select-disabled-bg;
|
|
82
|
-
border-color: $form-select-disabled-border-color;
|
|
83
|
-
`,
|
|
84
|
-
'.form-select-sm': css`
|
|
85
|
-
padding-top: $form-select-padding-y-sm;
|
|
86
|
-
padding-bottom: $form-select-padding-y-sm;
|
|
87
|
-
padding-left: $form-select-padding-x-sm;
|
|
88
|
-
font-size: $form-select-font-size-sm;
|
|
89
|
-
border-radius: $form-select-border-radius-sm;
|
|
90
|
-
`,
|
|
91
|
-
'.form-select-lg': css`
|
|
92
|
-
padding-top: $form-select-padding-y-lg;
|
|
93
|
-
padding-bottom: $form-select-padding-y-lg;
|
|
94
|
-
padding-left: $form-select-padding-x-lg;
|
|
95
|
-
font-size: $form-select-font-size-lg;
|
|
96
|
-
border-radius: $form-select-border-radius-lg;
|
|
97
|
-
`,
|
|
98
|
-
...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
|
|
99
|
-
[`.form-select:${state}`]: css`
|
|
100
|
-
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
101
|
-
|
|
102
|
-
&:focus {
|
|
103
|
-
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
104
|
-
@include platform(web) {
|
|
105
|
-
box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
|
|
106
|
-
rgba(
|
|
107
|
-
${(t: ThemeVariables) => data(t).color},
|
|
108
|
-
$input-btn-focus-color-opacity
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
`,
|
|
113
|
-
})),
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
const Picker = React.forwardRef<PressableRef, PickerProps>((props, ref) => {
|
|
117
|
-
const [modifierProps, modifierRef] = useModifier('useFormField', props, ref);
|
|
118
|
-
|
|
119
|
-
const {
|
|
120
|
-
children,
|
|
121
|
-
onFocus = () => {},
|
|
122
|
-
onBlur = () => {},
|
|
123
|
-
placeholderTextColor = StyleSheet.value('input-placeholder-color'),
|
|
124
|
-
size,
|
|
125
|
-
disabled = false,
|
|
126
|
-
valid = false,
|
|
127
|
-
invalid = false,
|
|
128
|
-
useNativeComponent = false,
|
|
129
|
-
autoFocus = false,
|
|
130
|
-
style,
|
|
131
|
-
styleName,
|
|
132
|
-
...elementProps
|
|
133
|
-
} = modifierProps;
|
|
134
|
-
|
|
135
|
-
const media = useMedia();
|
|
136
|
-
const [focused, setFocused] = useState(autoFocus);
|
|
137
|
-
|
|
138
|
-
const classes = getStyles(styles, [
|
|
139
|
-
'select',
|
|
140
|
-
'.form-select',
|
|
141
|
-
disabled && '.form-select.disabled',
|
|
142
|
-
size === 'sm' && '.form-select-sm',
|
|
143
|
-
size === 'lg' && '.form-select-lg',
|
|
144
|
-
valid && '.form-select:valid',
|
|
145
|
-
invalid && '.form-select:invalid',
|
|
146
|
-
]);
|
|
147
|
-
|
|
148
|
-
const resolveStyle = useStyle([classes, style], styleName);
|
|
149
|
-
|
|
150
|
-
const BasePicker =
|
|
151
|
-
Platform.OS === 'web' && !useNativeComponent ? PickerWeb : PickerNative;
|
|
152
|
-
|
|
153
|
-
const contextValue = useMemo(
|
|
154
|
-
() => ({
|
|
155
|
-
useNativeComponent,
|
|
156
|
-
}),
|
|
157
|
-
[useNativeComponent],
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
return (
|
|
161
|
-
<PickerContext.Provider value={contextValue}>
|
|
162
|
-
<BasePicker
|
|
163
|
-
{...elementProps}
|
|
164
|
-
ref={modifierRef}
|
|
165
|
-
placeholderTextColor={placeholderTextColor}
|
|
166
|
-
onFocus={(event) => {
|
|
167
|
-
setFocused(true);
|
|
168
|
-
onFocus(event);
|
|
169
|
-
}}
|
|
170
|
-
onBlur={(event) => {
|
|
171
|
-
setFocused(false);
|
|
172
|
-
onBlur(event);
|
|
173
|
-
}}
|
|
174
|
-
disabled={disabled}
|
|
175
|
-
autoFocus={autoFocus}
|
|
176
|
-
style={resolveStyle({
|
|
177
|
-
media,
|
|
178
|
-
interaction: { focus: focused, focusVisible: focused },
|
|
179
|
-
})}
|
|
180
|
-
>
|
|
181
|
-
{children}
|
|
182
|
-
</BasePicker>
|
|
183
|
-
</PickerContext.Provider>
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
Picker.displayName = 'Picker';
|
|
188
|
-
|
|
189
|
-
export default Object.assign(Picker, {
|
|
190
|
-
Item: PickerItem,
|
|
191
|
-
});
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
|
+
import { Platform, NativeSyntheticEvent, TargetedEvent } from 'react-native';
|
|
3
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
4
|
+
import css from '../../style/css';
|
|
5
|
+
import useMedia from '../../hooks/useMedia';
|
|
6
|
+
import { getStyles, each } from '../../utils';
|
|
7
|
+
import { FORM_VALIDATION_STATES } from '../../theme/proxies';
|
|
8
|
+
import { escapeSvg } from '../../theme/functions';
|
|
9
|
+
import useStyle from '../../hooks/useStyle';
|
|
10
|
+
import useModifier from '../../hooks/useModifier';
|
|
11
|
+
import PickerWeb from './internals/PickerWeb';
|
|
12
|
+
import PickerNative from './internals/PickerNative';
|
|
13
|
+
import PickerItem from './PickerItem';
|
|
14
|
+
import PickerContext from './PickerContext';
|
|
15
|
+
import type {
|
|
16
|
+
FormValidationState,
|
|
17
|
+
ThemeVariables,
|
|
18
|
+
UseFormFieldProps,
|
|
19
|
+
} from '../../types';
|
|
20
|
+
import type { PressableProps, PressableRef } from '../Pressable';
|
|
21
|
+
|
|
22
|
+
export interface MenuComponentProps {
|
|
23
|
+
children: React.ReactElement | React.ReactElement[];
|
|
24
|
+
selectedValue?: string | null | undefined;
|
|
25
|
+
onValueChange: (value: string) => void;
|
|
26
|
+
onClose: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PickerProps extends UseFormFieldProps, PressableProps {
|
|
30
|
+
children: React.ReactElement | React.ReactElement[];
|
|
31
|
+
selectedValue?: string | null | undefined;
|
|
32
|
+
onValueChange?: (value: string) => void;
|
|
33
|
+
onFocus?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
34
|
+
onBlur?: (e: NativeSyntheticEvent<TargetedEvent>) => void;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
placeholderTextColor?: string;
|
|
37
|
+
size?: 'sm' | 'lg';
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
valid?: boolean;
|
|
40
|
+
invalid?: boolean;
|
|
41
|
+
useNativeComponent?: boolean;
|
|
42
|
+
autoFocus?: boolean;
|
|
43
|
+
MenuComponent?: React.FC<MenuComponentProps>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
select: css`
|
|
48
|
+
opacity: 1;
|
|
49
|
+
`,
|
|
50
|
+
'.form-select': css`
|
|
51
|
+
width: 100%;
|
|
52
|
+
padding: $form-select-padding-y $form-select-indicator-padding
|
|
53
|
+
$form-select-padding-y $form-select-padding-x;
|
|
54
|
+
font-family: $form-select-font-family;
|
|
55
|
+
font-size: $form-select-font-size;
|
|
56
|
+
font-weight: $form-select-font-weight;
|
|
57
|
+
line-height: $form-select-font-size * $form-select-line-height;
|
|
58
|
+
color: $form-select-color;
|
|
59
|
+
background-color: $form-select-bg;
|
|
60
|
+
background-image: ${(t: ThemeVariables) =>
|
|
61
|
+
escapeSvg(t['form-select-indicator'])};
|
|
62
|
+
background-repeat: no-repeat;
|
|
63
|
+
background-position: $form-select-bg-position;
|
|
64
|
+
background-size: $form-select-bg-size;
|
|
65
|
+
border: $form-select-border-width solid $form-select-border-color;
|
|
66
|
+
border-radius: $form-select-border-radius;
|
|
67
|
+
@include platform(web) {
|
|
68
|
+
appearance: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
&:focus {
|
|
72
|
+
border-color: $form-select-focus-border-color;
|
|
73
|
+
@include platform(web) {
|
|
74
|
+
outline-width: 0;
|
|
75
|
+
box-shadow: $form-select-focus-box-shadow;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`,
|
|
79
|
+
'.form-select.disabled': css`
|
|
80
|
+
color: $form-select-disabled-color;
|
|
81
|
+
background-color: $form-select-disabled-bg;
|
|
82
|
+
border-color: $form-select-disabled-border-color;
|
|
83
|
+
`,
|
|
84
|
+
'.form-select-sm': css`
|
|
85
|
+
padding-top: $form-select-padding-y-sm;
|
|
86
|
+
padding-bottom: $form-select-padding-y-sm;
|
|
87
|
+
padding-left: $form-select-padding-x-sm;
|
|
88
|
+
font-size: $form-select-font-size-sm;
|
|
89
|
+
border-radius: $form-select-border-radius-sm;
|
|
90
|
+
`,
|
|
91
|
+
'.form-select-lg': css`
|
|
92
|
+
padding-top: $form-select-padding-y-lg;
|
|
93
|
+
padding-bottom: $form-select-padding-y-lg;
|
|
94
|
+
padding-left: $form-select-padding-x-lg;
|
|
95
|
+
font-size: $form-select-font-size-lg;
|
|
96
|
+
border-radius: $form-select-border-radius-lg;
|
|
97
|
+
`,
|
|
98
|
+
...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
|
|
99
|
+
[`.form-select:${state}`]: css`
|
|
100
|
+
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
101
|
+
|
|
102
|
+
&:focus {
|
|
103
|
+
border-color: ${(t: ThemeVariables) => data(t).color};
|
|
104
|
+
@include platform(web) {
|
|
105
|
+
box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
|
|
106
|
+
rgba(
|
|
107
|
+
${(t: ThemeVariables) => data(t).color},
|
|
108
|
+
$input-btn-focus-color-opacity
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
`,
|
|
113
|
+
})),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const Picker = React.forwardRef<PressableRef, PickerProps>((props, ref) => {
|
|
117
|
+
const [modifierProps, modifierRef] = useModifier('useFormField', props, ref);
|
|
118
|
+
|
|
119
|
+
const {
|
|
120
|
+
children,
|
|
121
|
+
onFocus = () => {},
|
|
122
|
+
onBlur = () => {},
|
|
123
|
+
placeholderTextColor = StyleSheet.value('input-placeholder-color'),
|
|
124
|
+
size,
|
|
125
|
+
disabled = false,
|
|
126
|
+
valid = false,
|
|
127
|
+
invalid = false,
|
|
128
|
+
useNativeComponent = false,
|
|
129
|
+
autoFocus = false,
|
|
130
|
+
style,
|
|
131
|
+
styleName,
|
|
132
|
+
...elementProps
|
|
133
|
+
} = modifierProps;
|
|
134
|
+
|
|
135
|
+
const media = useMedia();
|
|
136
|
+
const [focused, setFocused] = useState(autoFocus);
|
|
137
|
+
|
|
138
|
+
const classes = getStyles(styles, [
|
|
139
|
+
'select',
|
|
140
|
+
'.form-select',
|
|
141
|
+
disabled && '.form-select.disabled',
|
|
142
|
+
size === 'sm' && '.form-select-sm',
|
|
143
|
+
size === 'lg' && '.form-select-lg',
|
|
144
|
+
valid && '.form-select:valid',
|
|
145
|
+
invalid && '.form-select:invalid',
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
const resolveStyle = useStyle([classes, style], styleName);
|
|
149
|
+
|
|
150
|
+
const BasePicker =
|
|
151
|
+
Platform.OS === 'web' && !useNativeComponent ? PickerWeb : PickerNative;
|
|
152
|
+
|
|
153
|
+
const contextValue = useMemo(
|
|
154
|
+
() => ({
|
|
155
|
+
useNativeComponent,
|
|
156
|
+
}),
|
|
157
|
+
[useNativeComponent],
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<PickerContext.Provider value={contextValue}>
|
|
162
|
+
<BasePicker
|
|
163
|
+
{...elementProps}
|
|
164
|
+
ref={modifierRef}
|
|
165
|
+
placeholderTextColor={placeholderTextColor}
|
|
166
|
+
onFocus={(event) => {
|
|
167
|
+
setFocused(true);
|
|
168
|
+
onFocus(event);
|
|
169
|
+
}}
|
|
170
|
+
onBlur={(event) => {
|
|
171
|
+
setFocused(false);
|
|
172
|
+
onBlur(event);
|
|
173
|
+
}}
|
|
174
|
+
disabled={disabled}
|
|
175
|
+
autoFocus={autoFocus}
|
|
176
|
+
style={resolveStyle({
|
|
177
|
+
media,
|
|
178
|
+
interaction: { focus: focused, focusVisible: focused },
|
|
179
|
+
})}
|
|
180
|
+
>
|
|
181
|
+
{children}
|
|
182
|
+
</BasePicker>
|
|
183
|
+
</PickerContext.Provider>
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
Picker.displayName = 'Picker';
|
|
188
|
+
|
|
189
|
+
export default Object.assign(Picker, {
|
|
190
|
+
Item: PickerItem,
|
|
191
|
+
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import PickerContext from './PickerContext';
|
|
4
|
-
import useForcedContext from '../../hooks/useForcedContext';
|
|
5
|
-
import PickerWebItem from './internals/PickerWebItem';
|
|
6
|
-
import PickerNativeItem from './internals/PickerNativeItem';
|
|
7
|
-
import type { ViewProps, ViewRef } from '../View';
|
|
8
|
-
|
|
9
|
-
export interface PickerItemProps extends ViewProps {
|
|
10
|
-
label: string;
|
|
11
|
-
value
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const PickerItem = React.forwardRef<ViewRef, PickerItemProps>((props, ref) => {
|
|
16
|
-
const { label, value, disabled = false } = props;
|
|
17
|
-
|
|
18
|
-
const { useNativeComponent } = useForcedContext(PickerContext);
|
|
19
|
-
|
|
20
|
-
const BasePickerItem =
|
|
21
|
-
Platform.OS === 'web' && !useNativeComponent
|
|
22
|
-
? PickerWebItem
|
|
23
|
-
: PickerNativeItem;
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<BasePickerItem ref={ref} label={label} value={value} disabled={disabled} />
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
PickerItem.displayName = 'PickerItem';
|
|
31
|
-
|
|
32
|
-
export default PickerItem;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import PickerContext from './PickerContext';
|
|
4
|
+
import useForcedContext from '../../hooks/useForcedContext';
|
|
5
|
+
import PickerWebItem from './internals/PickerWebItem';
|
|
6
|
+
import PickerNativeItem from './internals/PickerNativeItem';
|
|
7
|
+
import type { ViewProps, ViewRef } from '../View';
|
|
8
|
+
|
|
9
|
+
export interface PickerItemProps extends ViewProps {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const PickerItem = React.forwardRef<ViewRef, PickerItemProps>((props, ref) => {
|
|
16
|
+
const { label, value, disabled = false } = props;
|
|
17
|
+
|
|
18
|
+
const { useNativeComponent } = useForcedContext(PickerContext);
|
|
19
|
+
|
|
20
|
+
const BasePickerItem =
|
|
21
|
+
Platform.OS === 'web' && !useNativeComponent
|
|
22
|
+
? PickerWebItem
|
|
23
|
+
: PickerNativeItem;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<BasePickerItem ref={ref} label={label} value={value} disabled={disabled} />
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
PickerItem.displayName = 'PickerItem';
|
|
31
|
+
|
|
32
|
+
export default PickerItem;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { PressableRef } from '../Pressable';
|
|
3
|
-
import useForcedContext from '../../hooks/useForcedContext';
|
|
4
|
-
import FormCheckInput, { FormCheckInputProps } from './FormCheckInput';
|
|
5
|
-
import RadioGroup from './RadioGroup';
|
|
6
|
-
import RadioContext from './RadioContext';
|
|
7
|
-
|
|
8
|
-
export interface RadioProps
|
|
9
|
-
extends Omit<FormCheckInputProps, 'value' | 'type'> {
|
|
10
|
-
value
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const Radio = React.forwardRef<PressableRef, RadioProps>((props, ref) => {
|
|
14
|
-
const { value, ...elementProps } = props;
|
|
15
|
-
|
|
16
|
-
const { selectedValue, onValueChange, disabled } =
|
|
17
|
-
useForcedContext(RadioContext);
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<FormCheckInput
|
|
21
|
-
{...elementProps}
|
|
22
|
-
ref={ref}
|
|
23
|
-
type="radio"
|
|
24
|
-
value={value === selectedValue}
|
|
25
|
-
onValueChange={() => {
|
|
26
|
-
onValueChange(value);
|
|
27
|
-
}}
|
|
28
|
-
disabled={disabled}
|
|
29
|
-
/>
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
Radio.displayName = 'Radio';
|
|
34
|
-
|
|
35
|
-
export default Object.assign(Radio, {
|
|
36
|
-
Group: RadioGroup,
|
|
37
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PressableRef } from '../Pressable';
|
|
3
|
+
import useForcedContext from '../../hooks/useForcedContext';
|
|
4
|
+
import FormCheckInput, { FormCheckInputProps } from './FormCheckInput';
|
|
5
|
+
import RadioGroup from './RadioGroup';
|
|
6
|
+
import RadioContext from './RadioContext';
|
|
7
|
+
|
|
8
|
+
export interface RadioProps
|
|
9
|
+
extends Omit<FormCheckInputProps, 'value' | 'type'> {
|
|
10
|
+
value: boolean | number | string | object | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Radio = React.forwardRef<PressableRef, RadioProps>((props, ref) => {
|
|
14
|
+
const { value, ...elementProps } = props;
|
|
15
|
+
|
|
16
|
+
const { selectedValue, onValueChange, disabled } =
|
|
17
|
+
useForcedContext(RadioContext);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<FormCheckInput
|
|
21
|
+
{...elementProps}
|
|
22
|
+
ref={ref}
|
|
23
|
+
type="radio"
|
|
24
|
+
value={value === selectedValue}
|
|
25
|
+
onValueChange={() => {
|
|
26
|
+
onValueChange(value);
|
|
27
|
+
}}
|
|
28
|
+
disabled={disabled}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
Radio.displayName = 'Radio';
|
|
34
|
+
|
|
35
|
+
export default Object.assign(Radio, {
|
|
36
|
+
Group: RadioGroup,
|
|
37
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type RadioContextType = {
|
|
4
|
-
selectedValue?: boolean | number | string | object;
|
|
5
|
-
onValueChange: (value
|
|
6
|
-
disabled: boolean;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const RadioContext = React.createContext<RadioContextType | null>(null);
|
|
10
|
-
|
|
11
|
-
RadioContext.displayName = 'RadioContext';
|
|
12
|
-
|
|
13
|
-
export default RadioContext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type RadioContextType = {
|
|
4
|
+
selectedValue?: boolean | number | string | object | null | undefined;
|
|
5
|
+
onValueChange: (value: boolean | number | string | object | null) => void;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const RadioContext = React.createContext<RadioContextType | null>(null);
|
|
10
|
+
|
|
11
|
+
RadioContext.displayName = 'RadioContext';
|
|
12
|
+
|
|
13
|
+
export default RadioContext;
|
|
@@ -1,40 +1,42 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import View, { ViewProps, ViewRef } from '../View';
|
|
3
|
-
import RadioContext from './RadioContext';
|
|
4
|
-
|
|
5
|
-
export interface RadioGroupProps extends ViewProps {
|
|
6
|
-
selectedValue?: boolean | number | string | object;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import View, { ViewProps, ViewRef } from '../View';
|
|
3
|
+
import RadioContext from './RadioContext';
|
|
4
|
+
|
|
5
|
+
export interface RadioGroupProps extends ViewProps {
|
|
6
|
+
selectedValue?: boolean | number | string | object | null | undefined;
|
|
7
|
+
// We cannot determine the type used for value in Radio components.
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
onValueChange?: (value: any) => void;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const RadioGroup = React.forwardRef<ViewRef, RadioGroupProps>((props, ref) => {
|
|
14
|
+
const {
|
|
15
|
+
children,
|
|
16
|
+
selectedValue,
|
|
17
|
+
onValueChange = () => {},
|
|
18
|
+
disabled = false,
|
|
19
|
+
...elementProps
|
|
20
|
+
} = props;
|
|
21
|
+
|
|
22
|
+
const contextValue = useMemo(
|
|
23
|
+
() => ({
|
|
24
|
+
selectedValue,
|
|
25
|
+
onValueChange,
|
|
26
|
+
disabled,
|
|
27
|
+
}),
|
|
28
|
+
[selectedValue, onValueChange, disabled],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View {...elementProps} ref={ref} role="radiogroup">
|
|
33
|
+
<RadioContext.Provider value={contextValue}>
|
|
34
|
+
{children}
|
|
35
|
+
</RadioContext.Provider>
|
|
36
|
+
</View>
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
41
|
+
|
|
42
|
+
export default RadioGroup;
|