Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 0df84ce

Browse files
committed
Targeting ES5 version of native.js. Fixes #654
1 parent 18e552c commit 0df84ce

File tree

2 files changed

+189
-188
lines changed

2 files changed

+189
-188
lines changed

native.js

Lines changed: 1 addition & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -1,188 +1 @@
1-
/* eslint-disable react/prop-types */
2-
import React from 'react';
3-
import {
4-
MapView,
5-
Picker,
6-
DatePickerIOS,
7-
Switch,
8-
TextInput,
9-
SegmentedControlIOS,
10-
Slider,
11-
Text,
12-
View,
13-
} from 'react-native';
14-
15-
import {
16-
modelReducer,
17-
formReducer,
18-
modeled,
19-
actions,
20-
combineForms,
21-
initialFieldState,
22-
actionTypes,
23-
Control,
24-
Form,
25-
Fieldset,
26-
Errors,
27-
batched,
28-
form,
29-
getField,
30-
track,
31-
} from './src/index';
32-
import omit from './src/utils/omit';
33-
34-
function getTextValue(value) {
35-
if (typeof value === 'string' || typeof value === 'number') {
36-
return `${value}`;
37-
}
38-
39-
return '';
40-
}
41-
42-
const noop = () => undefined;
43-
44-
Control.MapView = (props) => (
45-
<Control
46-
component={MapView}
47-
updateOn="blur"
48-
mapProps={{
49-
onResponderGrant: ({ onFocus }) => onFocus,
50-
onRegionChange: ({ onChange }) => onChange,
51-
onRegionChangeComplete: ({ onBlur }) => onBlur,
52-
region: ({ modelValue }) => modelValue,
53-
...props.mapProps,
54-
}}
55-
{...omit(props, 'mapProps')}
56-
/>
57-
);
58-
59-
Control.Picker = (props) => (
60-
<Control
61-
component={Picker}
62-
mapProps={{
63-
onResponderGrant: ({ onFocus }) => onFocus,
64-
onResponderRelease: ({ onBlur }) => onBlur,
65-
selectedValue: ({ modelValue }) => modelValue,
66-
onValueChange: ({ onChange }) => onChange,
67-
onChange: noop,
68-
...props.mapProps,
69-
}}
70-
{...omit(props, 'mapProps')}
71-
/>
72-
);
73-
74-
Control.Switch = (props) => (
75-
<Control
76-
component={Switch}
77-
mapProps={{
78-
onResponderGrant: ({ onFocus }) => onFocus,
79-
onResponderRelease: ({ onBlur }) => onBlur,
80-
value: ({ modelValue }) => !!modelValue,
81-
onValueChange: ({ onChange }) => onChange,
82-
onChange: noop,
83-
...props.mapProps,
84-
}}
85-
{...omit(props, 'mapProps')}
86-
/>
87-
);
88-
89-
Control.TextInput = (props) => (
90-
<Control
91-
component={TextInput}
92-
mapProps={{
93-
onResponderGrant: ({ onFocus }) => onFocus,
94-
value: (_props) => ((!_props.defaultValue && !_props.hasOwnProperty('value'))
95-
? getTextValue(_props.viewValue)
96-
: _props.value),
97-
onChangeText: ({ onChange }) => onChange,
98-
onChange: noop,
99-
onBlur: ({ onBlur, viewValue }) => () => onBlur(viewValue),
100-
onFocus: ({ onFocus }) => onFocus,
101-
...props.mapProps,
102-
}}
103-
{...omit(props, 'mapProps')}
104-
/>
105-
);
106-
107-
Control.DatePickerIOS = (props) => (
108-
<Control
109-
component={DatePickerIOS}
110-
mapProps={{
111-
onResponderGrant: ({ onFocus }) => onFocus,
112-
onResponderRelease: ({ onBlur }) => onBlur,
113-
date: ({ modelValue }) => modelValue,
114-
onDateChange: ({ onChange }) => onChange,
115-
onChange: noop,
116-
...props.mapProps,
117-
}}
118-
{...omit(props, 'mapProps')}
119-
/>
120-
);
121-
122-
Control.SegmentedControlIOS = (props) => (
123-
<Control
124-
component={SegmentedControlIOS}
125-
mapProps={{
126-
onResponderGrant: ({ onFocus }) => onFocus,
127-
selectedIndex: ({ values, modelValue }) => values.indexOf(modelValue),
128-
onValueChange: ({ onChange }) => onChange,
129-
onChange: noop,
130-
...props.mapProps,
131-
}}
132-
{...omit(props, 'mapProps')}
133-
/>
134-
);
135-
136-
Control.Slider = (props) => (
137-
<Control
138-
component={Slider}
139-
mapProps={{
140-
value: ({ modelValue }) => modelValue,
141-
onResponderGrant: ({ onFocus }) => onFocus,
142-
onSlidingComplete: ({ onBlur }) => onBlur,
143-
onValueChange: ({ onChange }) => onChange,
144-
onChange: noop,
145-
...props.mapProps,
146-
}}
147-
{...omit(props, 'mapProps')}
148-
/>
149-
);
150-
151-
const NativeForm = (props) => <Form component={View} {...omit(props, 'mapProps')} />;
152-
const NativeFieldset = (props) => <Fieldset component={View} {...omit(props, 'mapProps')} />;
153-
const NativeErrors = (props) => (
154-
<Errors
155-
wrapper={View}
156-
component={Text}
157-
{...props}
158-
/>
159-
);
160-
161-
export {
162-
// Reducers
163-
formReducer,
164-
modelReducer,
165-
combineForms,
166-
167-
// Constants
168-
initialFieldState,
169-
actions,
170-
actionTypes,
171-
172-
// Components
173-
Control,
174-
NativeForm as Form,
175-
NativeErrors as Errors,
176-
NativeFieldset as Fieldset,
177-
178-
// Enhancers
179-
modeled,
180-
batched,
181-
182-
// Selectors
183-
form,
184-
185-
// Utilities
186-
getField,
187-
track,
188-
};
1+
module.exports = require('./lib/native');

src/native.js

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/* eslint-disable react/prop-types */
2+
import React from 'react';
3+
import {
4+
MapView,
5+
Picker,
6+
DatePickerIOS,
7+
Switch,
8+
TextInput,
9+
SegmentedControlIOS,
10+
Slider,
11+
Text,
12+
View,
13+
} from 'react-native';
14+
15+
import {
16+
modelReducer,
17+
formReducer,
18+
modeled,
19+
actions,
20+
combineForms,
21+
initialFieldState,
22+
actionTypes,
23+
Control,
24+
Form,
25+
Fieldset,
26+
Errors,
27+
batched,
28+
form,
29+
getField,
30+
track,
31+
} from './index';
32+
import omit from './utils/omit';
33+
34+
function getTextValue(value) {
35+
if (typeof value === 'string' || typeof value === 'number') {
36+
return `${value}`;
37+
}
38+
39+
return '';
40+
}
41+
42+
const noop = () => undefined;
43+
44+
Control.MapView = (props) => (
45+
<Control
46+
component={MapView}
47+
updateOn="blur"
48+
mapProps={{
49+
onResponderGrant: ({ onFocus }) => onFocus,
50+
onRegionChange: ({ onChange }) => onChange,
51+
onRegionChangeComplete: ({ onBlur }) => onBlur,
52+
region: ({ modelValue }) => modelValue,
53+
...props.mapProps,
54+
}}
55+
{...omit(props, 'mapProps')}
56+
/>
57+
);
58+
59+
Control.Picker = (props) => (
60+
<Control
61+
component={Picker}
62+
mapProps={{
63+
onResponderGrant: ({ onFocus }) => onFocus,
64+
onResponderRelease: ({ onBlur }) => onBlur,
65+
selectedValue: ({ modelValue }) => modelValue,
66+
onValueChange: ({ onChange }) => onChange,
67+
onChange: noop,
68+
...props.mapProps,
69+
}}
70+
{...omit(props, 'mapProps')}
71+
/>
72+
);
73+
74+
Control.Switch = (props) => (
75+
<Control
76+
component={Switch}
77+
mapProps={{
78+
onResponderGrant: ({ onFocus }) => onFocus,
79+
onResponderRelease: ({ onBlur }) => onBlur,
80+
value: ({ modelValue }) => !!modelValue,
81+
onValueChange: ({ onChange }) => onChange,
82+
onChange: noop,
83+
...props.mapProps,
84+
}}
85+
{...omit(props, 'mapProps')}
86+
/>
87+
);
88+
89+
Control.TextInput = (props) => (
90+
<Control
91+
component={TextInput}
92+
mapProps={{
93+
onResponderGrant: ({ onFocus }) => onFocus,
94+
value: (_props) => ((!_props.defaultValue && !_props.hasOwnProperty('value'))
95+
? getTextValue(_props.viewValue)
96+
: _props.value),
97+
onChangeText: ({ onChange }) => onChange,
98+
onChange: noop,
99+
onBlur: ({ onBlur, viewValue }) => () => onBlur(viewValue),
100+
onFocus: ({ onFocus }) => onFocus,
101+
...props.mapProps,
102+
}}
103+
{...omit(props, 'mapProps')}
104+
/>
105+
);
106+
107+
Control.DatePickerIOS = (props) => (
108+
<Control
109+
component={DatePickerIOS}
110+
mapProps={{
111+
onResponderGrant: ({ onFocus }) => onFocus,
112+
onResponderRelease: ({ onBlur }) => onBlur,
113+
date: ({ modelValue }) => modelValue,
114+
onDateChange: ({ onChange }) => onChange,
115+
onChange: noop,
116+
...props.mapProps,
117+
}}
118+
{...omit(props, 'mapProps')}
119+
/>
120+
);
121+
122+
Control.SegmentedControlIOS = (props) => (
123+
<Control
124+
component={SegmentedControlIOS}
125+
mapProps={{
126+
onResponderGrant: ({ onFocus }) => onFocus,
127+
selectedIndex: ({ values, modelValue }) => values.indexOf(modelValue),
128+
onValueChange: ({ onChange }) => onChange,
129+
onChange: noop,
130+
...props.mapProps,
131+
}}
132+
{...omit(props, 'mapProps')}
133+
/>
134+
);
135+
136+
Control.Slider = (props) => (
137+
<Control
138+
component={Slider}
139+
mapProps={{
140+
value: ({ modelValue }) => modelValue,
141+
onResponderGrant: ({ onFocus }) => onFocus,
142+
onSlidingComplete: ({ onBlur }) => onBlur,
143+
onValueChange: ({ onChange }) => onChange,
144+
onChange: noop,
145+
...props.mapProps,
146+
}}
147+
{...omit(props, 'mapProps')}
148+
/>
149+
);
150+
151+
const NativeForm = (props) => <Form component={View} {...omit(props, 'mapProps')} />;
152+
const NativeFieldset = (props) => <Fieldset component={View} {...omit(props, 'mapProps')} />;
153+
const NativeErrors = (props) => (
154+
<Errors
155+
wrapper={View}
156+
component={Text}
157+
{...props}
158+
/>
159+
);
160+
161+
export {
162+
// Reducers
163+
formReducer,
164+
modelReducer,
165+
combineForms,
166+
167+
// Constants
168+
initialFieldState,
169+
actions,
170+
actionTypes,
171+
172+
// Components
173+
Control,
174+
NativeForm as Form,
175+
NativeErrors as Errors,
176+
NativeFieldset as Fieldset,
177+
178+
// Enhancers
179+
modeled,
180+
batched,
181+
182+
// Selectors
183+
form,
184+
185+
// Utilities
186+
getField,
187+
track,
188+
};

0 commit comments

Comments
 (0)