@draftbit/core 46.1.3 → 46.2.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/lib/commonjs/components/Carousel.js +3 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/Config.js +3 -3
- package/lib/commonjs/components/Config.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +3 -3
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +4 -5
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +2 -2
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +2 -2
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.web.js +2 -2
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/components/StepIndicator.js +1 -1
- package/lib/commonjs/components/StepIndicator.js.map +1 -1
- package/lib/commonjs/components/Stepper.js +1 -1
- package/lib/commonjs/components/Stepper.js.map +1 -1
- package/lib/commonjs/mappings/ActionSheetItem.js.map +1 -1
- package/lib/commonjs/mappings/BlurView.js.map +1 -1
- package/lib/commonjs/utilities.js +1 -1
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/Carousel.js +3 -1
- package/lib/module/components/Carousel.js.map +1 -1
- package/lib/module/components/Config.js +3 -3
- package/lib/module/components/Config.js.map +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +3 -3
- package/lib/module/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/module/components/Picker/Picker.js +4 -5
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +2 -2
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.ios.js +2 -2
- package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.web.js +2 -2
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButton.js +1 -1
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/StepIndicator.js +1 -1
- package/lib/module/components/StepIndicator.js.map +1 -1
- package/lib/module/components/Stepper.js +1 -1
- package/lib/module/components/Stepper.js.map +1 -1
- package/lib/module/utilities.js +1 -1
- package/lib/module/utilities.js.map +1 -1
- package/package.json +3 -3
- package/src/components/ActionSheet/ActionSheet.js +1 -1
- package/src/components/Carousel.js +4 -2
- package/src/components/Checkbox/Checkbox.js +3 -3
- package/src/components/Checkbox/CheckboxGroupRow.js +2 -2
- package/src/components/Checkbox/CheckboxRow.js +3 -3
- package/src/components/CircularProgress.js +29 -26
- package/src/components/DatePicker/DatePicker.js +1 -1
- package/src/components/NumberInput.js +1 -1
- package/src/components/Picker/Picker.js +8 -8
- package/src/components/Picker/Picker.tsx +8 -6
- package/src/components/Picker/PickerComponent.android.js +2 -1
- package/src/components/Picker/PickerComponent.ios.js +2 -1
- package/src/components/Picker/PickerComponent.web.js +2 -1
- package/src/components/Portal/Portal.js +2 -2
- package/src/components/Portal/PortalConsumer.js +0 -1
- package/src/components/Portal/PortalHost.js +43 -41
- package/src/components/Portal/PortalManager.js +21 -18
- package/src/components/ProgressBar.js +9 -9
- package/src/components/RadioButton/RadioButton.js +3 -3
- package/src/components/RadioButton/RadioButtonGroup.js +1 -1
- package/src/components/RadioButton/RadioButtonRow.js +3 -3
- package/src/components/StepIndicator.js +225 -225
- package/src/components/Stepper.js +2 -2
- package/src/components/Text.js +0 -1
- package/src/components/TextField.js +62 -59
- package/src/constants.js +1 -1
|
@@ -9,6 +9,231 @@ const STEP_STATUS = {
|
|
|
9
9
|
export default class StepIndicator extends Component {
|
|
10
10
|
constructor(props) {
|
|
11
11
|
super(props);
|
|
12
|
+
this.renderProgressBarBackground = () => {
|
|
13
|
+
const { stepCount, direction } = this.props;
|
|
14
|
+
let progressBarBackgroundStyle;
|
|
15
|
+
if (direction === "vertical") {
|
|
16
|
+
progressBarBackgroundStyle = {
|
|
17
|
+
backgroundColor: this.state.customStyles.separatorUnFinishedColor,
|
|
18
|
+
position: "absolute",
|
|
19
|
+
left: (this.state.width - this.state.customStyles.separatorStrokeWidth) / 2,
|
|
20
|
+
top: this.state.height / (2 * stepCount),
|
|
21
|
+
bottom: this.state.height / (2 * stepCount),
|
|
22
|
+
width: this.state.customStyles.separatorStrokeUnfinishedWidth === 0
|
|
23
|
+
? this.state.customStyles.separatorStrokeWidth
|
|
24
|
+
: this.state.customStyles.separatorStrokeUnfinishedWidth,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
progressBarBackgroundStyle = {
|
|
29
|
+
backgroundColor: this.state.customStyles.separatorUnFinishedColor,
|
|
30
|
+
position: "absolute",
|
|
31
|
+
top: (this.state.height - this.state.customStyles.separatorStrokeWidth) /
|
|
32
|
+
2,
|
|
33
|
+
left: this.state.width / (2 * stepCount),
|
|
34
|
+
right: this.state.width / (2 * stepCount),
|
|
35
|
+
height: this.state.customStyles.separatorStrokeUnfinishedWidth === 0
|
|
36
|
+
? this.state.customStyles.separatorStrokeWidth
|
|
37
|
+
: this.state.customStyles.separatorStrokeUnfinishedWidth,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return (React.createElement(View, { onLayout: (event) => {
|
|
41
|
+
if (direction === "vertical") {
|
|
42
|
+
this.setState({ progressBarSize: event.nativeEvent.layout.height }, () => {
|
|
43
|
+
this.onCurrentPositionChanged(this.props.currentPosition);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.setState({ progressBarSize: event.nativeEvent.layout.width }, () => {
|
|
48
|
+
this.onCurrentPositionChanged(this.props.currentPosition);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, style: progressBarBackgroundStyle }));
|
|
52
|
+
};
|
|
53
|
+
this.renderProgressBar = () => {
|
|
54
|
+
const { stepCount, direction } = this.props;
|
|
55
|
+
let progressBarStyle;
|
|
56
|
+
if (direction === "vertical") {
|
|
57
|
+
progressBarStyle = {
|
|
58
|
+
backgroundColor: this.state.customStyles.separatorFinishedColor,
|
|
59
|
+
position: "absolute",
|
|
60
|
+
left: (this.state.width - this.state.customStyles.separatorStrokeWidth) / 2,
|
|
61
|
+
top: this.state.height / (2 * stepCount),
|
|
62
|
+
bottom: this.state.height / (2 * stepCount),
|
|
63
|
+
width: this.state.customStyles.separatorStrokeFinishedWidth === 0
|
|
64
|
+
? this.state.customStyles.separatorStrokeWidth
|
|
65
|
+
: this.state.customStyles.separatorStrokeFinishedWidth,
|
|
66
|
+
height: this.progressAnim,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
progressBarStyle = {
|
|
71
|
+
backgroundColor: this.state.customStyles.separatorFinishedColor,
|
|
72
|
+
position: "absolute",
|
|
73
|
+
top: (this.state.height - this.state.customStyles.separatorStrokeWidth) /
|
|
74
|
+
2,
|
|
75
|
+
left: this.state.width / (2 * stepCount),
|
|
76
|
+
right: this.state.width / (2 * stepCount),
|
|
77
|
+
height: this.state.customStyles.separatorStrokeFinishedWidth === 0
|
|
78
|
+
? this.state.customStyles.separatorStrokeWidth
|
|
79
|
+
: this.state.customStyles.separatorStrokeFinishedWidth,
|
|
80
|
+
width: this.progressAnim,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return React.createElement(Animated.View, { style: progressBarStyle });
|
|
84
|
+
};
|
|
85
|
+
this.renderStepIndicator = () => {
|
|
86
|
+
let steps = [];
|
|
87
|
+
const { stepCount, direction } = this.props;
|
|
88
|
+
for (let position = 0; position < stepCount; position++) {
|
|
89
|
+
steps.push(React.createElement(TouchableWithoutFeedback, { key: position, onPress: () => this.stepPressed(position) },
|
|
90
|
+
React.createElement(View, { style: [
|
|
91
|
+
styles.stepContainer,
|
|
92
|
+
direction === "vertical"
|
|
93
|
+
? { flexDirection: "column" }
|
|
94
|
+
: { flexDirection: "row" },
|
|
95
|
+
] }, this.renderStep(position))));
|
|
96
|
+
}
|
|
97
|
+
return (React.createElement(View, { onLayout: (event) => this.setState({
|
|
98
|
+
width: event.nativeEvent.layout.width,
|
|
99
|
+
height: event.nativeEvent.layout.height,
|
|
100
|
+
}), style: [
|
|
101
|
+
styles.stepIndicatorContainer,
|
|
102
|
+
direction === "vertical"
|
|
103
|
+
? {
|
|
104
|
+
flexDirection: "column",
|
|
105
|
+
width: this.state.customStyles.currentStepIndicatorSize,
|
|
106
|
+
}
|
|
107
|
+
: {
|
|
108
|
+
flexDirection: "row",
|
|
109
|
+
height: this.state.customStyles.currentStepIndicatorSize,
|
|
110
|
+
},
|
|
111
|
+
] }, steps));
|
|
112
|
+
};
|
|
113
|
+
this.renderStepLabels = () => {
|
|
114
|
+
const { labels, direction, currentPosition, renderLabel } = this.props;
|
|
115
|
+
var labelViews = labels.map((label, index) => {
|
|
116
|
+
const selectedStepLabelStyle = index === currentPosition
|
|
117
|
+
? { color: this.state.customStyles.currentStepLabelColor }
|
|
118
|
+
: { color: this.state.customStyles.labelColor };
|
|
119
|
+
return (React.createElement(TouchableWithoutFeedback, { style: styles.stepLabelItem, key: index, onPress: () => this.stepPressed(index) },
|
|
120
|
+
React.createElement(View, { style: styles.stepLabelItem }, renderLabel ? (renderLabel({
|
|
121
|
+
position: index,
|
|
122
|
+
stepStatus: this.getStepStatus(index),
|
|
123
|
+
label,
|
|
124
|
+
currentPosition,
|
|
125
|
+
})) : (React.createElement(Text, { style: [
|
|
126
|
+
styles.stepLabel,
|
|
127
|
+
selectedStepLabelStyle,
|
|
128
|
+
{
|
|
129
|
+
fontSize: this.state.customStyles.labelSize,
|
|
130
|
+
fontFamily: this.state.customStyles.labelFontFamily,
|
|
131
|
+
},
|
|
132
|
+
] }, label)))));
|
|
133
|
+
});
|
|
134
|
+
return (React.createElement(View, { style: [
|
|
135
|
+
styles.stepLabelsContainer,
|
|
136
|
+
direction === "vertical"
|
|
137
|
+
? { flexDirection: "column", paddingHorizontal: 4 }
|
|
138
|
+
: { flexDirection: "row", paddingVertical: 4 },
|
|
139
|
+
{ alignItems: this.state.customStyles.labelAlign },
|
|
140
|
+
] }, labelViews));
|
|
141
|
+
};
|
|
142
|
+
this.renderStep = (position) => {
|
|
143
|
+
const { renderStepIndicator } = this.props;
|
|
144
|
+
let stepStyle;
|
|
145
|
+
let indicatorLabelStyle;
|
|
146
|
+
switch (this.getStepStatus(position)) {
|
|
147
|
+
case STEP_STATUS.CURRENT: {
|
|
148
|
+
stepStyle = {
|
|
149
|
+
backgroundColor: this.state.customStyles.stepIndicatorCurrentColor,
|
|
150
|
+
borderWidth: this.state.customStyles.currentStepStrokeWidth,
|
|
151
|
+
borderColor: this.state.customStyles.stepStrokeCurrentColor,
|
|
152
|
+
height: this.sizeAnim,
|
|
153
|
+
width: this.sizeAnim,
|
|
154
|
+
borderRadius: this.borderRadiusAnim,
|
|
155
|
+
};
|
|
156
|
+
indicatorLabelStyle = {
|
|
157
|
+
fontSize: this.state.customStyles.currentStepIndicatorLabelFontSize,
|
|
158
|
+
color: this.state.customStyles.stepIndicatorLabelCurrentColor,
|
|
159
|
+
};
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case STEP_STATUS.FINISHED: {
|
|
163
|
+
stepStyle = {
|
|
164
|
+
backgroundColor: this.state.customStyles.stepIndicatorFinishedColor,
|
|
165
|
+
borderWidth: this.state.customStyles.stepStrokeWidth,
|
|
166
|
+
borderColor: this.state.customStyles.stepStrokeFinishedColor,
|
|
167
|
+
height: this.state.customStyles.stepIndicatorSize,
|
|
168
|
+
width: this.state.customStyles.stepIndicatorSize,
|
|
169
|
+
borderRadius: this.state.customStyles.stepIndicatorSize / 2,
|
|
170
|
+
};
|
|
171
|
+
indicatorLabelStyle = {
|
|
172
|
+
fontSize: this.state.customStyles.stepIndicatorLabelFontSize,
|
|
173
|
+
color: this.state.customStyles.stepIndicatorLabelFinishedColor,
|
|
174
|
+
};
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
case STEP_STATUS.UNFINISHED: {
|
|
178
|
+
stepStyle = {
|
|
179
|
+
backgroundColor: this.state.customStyles.stepIndicatorUnFinishedColor,
|
|
180
|
+
borderWidth: this.state.customStyles.stepStrokeWidth,
|
|
181
|
+
borderColor: this.state.customStyles.stepStrokeUnFinishedColor,
|
|
182
|
+
height: this.state.customStyles.stepIndicatorSize,
|
|
183
|
+
width: this.state.customStyles.stepIndicatorSize,
|
|
184
|
+
borderRadius: this.state.customStyles.stepIndicatorSize / 2,
|
|
185
|
+
};
|
|
186
|
+
indicatorLabelStyle = {
|
|
187
|
+
overflow: "hidden",
|
|
188
|
+
fontSize: this.state.customStyles.stepIndicatorLabelFontSize,
|
|
189
|
+
color: this.state.customStyles.stepIndicatorLabelUnFinishedColor,
|
|
190
|
+
};
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
default:
|
|
194
|
+
}
|
|
195
|
+
return (React.createElement(Animated.View, { key: "step-indicator", style: [styles.step, stepStyle] }, renderStepIndicator ? (renderStepIndicator({
|
|
196
|
+
position,
|
|
197
|
+
stepStatus: this.getStepStatus(position),
|
|
198
|
+
})) : (React.createElement(Text, { style: indicatorLabelStyle }, `${position + 1}`))));
|
|
199
|
+
};
|
|
200
|
+
this.getStepStatus = (stepPosition) => {
|
|
201
|
+
const { currentPosition } = this.props;
|
|
202
|
+
if (stepPosition === currentPosition) {
|
|
203
|
+
return STEP_STATUS.CURRENT;
|
|
204
|
+
}
|
|
205
|
+
else if (stepPosition < currentPosition) {
|
|
206
|
+
return STEP_STATUS.FINISHED;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
return STEP_STATUS.UNFINISHED;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
this.onCurrentPositionChanged = (position) => {
|
|
213
|
+
let { stepCount } = this.props;
|
|
214
|
+
if (position > stepCount - 1) {
|
|
215
|
+
position = stepCount - 1;
|
|
216
|
+
}
|
|
217
|
+
const animateToPosition = (this.state.progressBarSize / (stepCount - 1)) * position;
|
|
218
|
+
this.sizeAnim.setValue(this.state.customStyles.stepIndicatorSize);
|
|
219
|
+
this.borderRadiusAnim.setValue(this.state.customStyles.stepIndicatorSize / 2);
|
|
220
|
+
Animated.sequence([
|
|
221
|
+
Animated.timing(this.progressAnim, {
|
|
222
|
+
toValue: animateToPosition,
|
|
223
|
+
duration: 200,
|
|
224
|
+
}),
|
|
225
|
+
Animated.parallel([
|
|
226
|
+
Animated.timing(this.sizeAnim, {
|
|
227
|
+
toValue: this.state.customStyles.currentStepIndicatorSize,
|
|
228
|
+
duration: 100,
|
|
229
|
+
}),
|
|
230
|
+
Animated.timing(this.borderRadiusAnim, {
|
|
231
|
+
toValue: this.state.customStyles.currentStepIndicatorSize / 2,
|
|
232
|
+
duration: 100,
|
|
233
|
+
}),
|
|
234
|
+
]),
|
|
235
|
+
]).start();
|
|
236
|
+
};
|
|
12
237
|
const defaultStyles = {
|
|
13
238
|
stepIndicatorSize: 30,
|
|
14
239
|
currentStepIndicatorSize: 40,
|
|
@@ -77,231 +302,6 @@ export default class StepIndicator extends Component {
|
|
|
77
302
|
this.onCurrentPositionChanged(this.props.currentPosition);
|
|
78
303
|
}
|
|
79
304
|
}
|
|
80
|
-
renderProgressBarBackground = () => {
|
|
81
|
-
const { stepCount, direction } = this.props;
|
|
82
|
-
let progressBarBackgroundStyle;
|
|
83
|
-
if (direction === "vertical") {
|
|
84
|
-
progressBarBackgroundStyle = {
|
|
85
|
-
backgroundColor: this.state.customStyles.separatorUnFinishedColor,
|
|
86
|
-
position: "absolute",
|
|
87
|
-
left: (this.state.width - this.state.customStyles.separatorStrokeWidth) / 2,
|
|
88
|
-
top: this.state.height / (2 * stepCount),
|
|
89
|
-
bottom: this.state.height / (2 * stepCount),
|
|
90
|
-
width: this.state.customStyles.separatorStrokeUnfinishedWidth === 0
|
|
91
|
-
? this.state.customStyles.separatorStrokeWidth
|
|
92
|
-
: this.state.customStyles.separatorStrokeUnfinishedWidth,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
progressBarBackgroundStyle = {
|
|
97
|
-
backgroundColor: this.state.customStyles.separatorUnFinishedColor,
|
|
98
|
-
position: "absolute",
|
|
99
|
-
top: (this.state.height - this.state.customStyles.separatorStrokeWidth) /
|
|
100
|
-
2,
|
|
101
|
-
left: this.state.width / (2 * stepCount),
|
|
102
|
-
right: this.state.width / (2 * stepCount),
|
|
103
|
-
height: this.state.customStyles.separatorStrokeUnfinishedWidth === 0
|
|
104
|
-
? this.state.customStyles.separatorStrokeWidth
|
|
105
|
-
: this.state.customStyles.separatorStrokeUnfinishedWidth,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return (React.createElement(View, { onLayout: (event) => {
|
|
109
|
-
if (direction === "vertical") {
|
|
110
|
-
this.setState({ progressBarSize: event.nativeEvent.layout.height }, () => {
|
|
111
|
-
this.onCurrentPositionChanged(this.props.currentPosition);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
this.setState({ progressBarSize: event.nativeEvent.layout.width }, () => {
|
|
116
|
-
this.onCurrentPositionChanged(this.props.currentPosition);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}, style: progressBarBackgroundStyle }));
|
|
120
|
-
};
|
|
121
|
-
renderProgressBar = () => {
|
|
122
|
-
const { stepCount, direction } = this.props;
|
|
123
|
-
let progressBarStyle;
|
|
124
|
-
if (direction === "vertical") {
|
|
125
|
-
progressBarStyle = {
|
|
126
|
-
backgroundColor: this.state.customStyles.separatorFinishedColor,
|
|
127
|
-
position: "absolute",
|
|
128
|
-
left: (this.state.width - this.state.customStyles.separatorStrokeWidth) / 2,
|
|
129
|
-
top: this.state.height / (2 * stepCount),
|
|
130
|
-
bottom: this.state.height / (2 * stepCount),
|
|
131
|
-
width: this.state.customStyles.separatorStrokeFinishedWidth === 0
|
|
132
|
-
? this.state.customStyles.separatorStrokeWidth
|
|
133
|
-
: this.state.customStyles.separatorStrokeFinishedWidth,
|
|
134
|
-
height: this.progressAnim,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
progressBarStyle = {
|
|
139
|
-
backgroundColor: this.state.customStyles.separatorFinishedColor,
|
|
140
|
-
position: "absolute",
|
|
141
|
-
top: (this.state.height - this.state.customStyles.separatorStrokeWidth) /
|
|
142
|
-
2,
|
|
143
|
-
left: this.state.width / (2 * stepCount),
|
|
144
|
-
right: this.state.width / (2 * stepCount),
|
|
145
|
-
height: this.state.customStyles.separatorStrokeFinishedWidth === 0
|
|
146
|
-
? this.state.customStyles.separatorStrokeWidth
|
|
147
|
-
: this.state.customStyles.separatorStrokeFinishedWidth,
|
|
148
|
-
width: this.progressAnim,
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
return React.createElement(Animated.View, { style: progressBarStyle });
|
|
152
|
-
};
|
|
153
|
-
renderStepIndicator = () => {
|
|
154
|
-
let steps = [];
|
|
155
|
-
const { stepCount, direction } = this.props;
|
|
156
|
-
for (let position = 0; position < stepCount; position++) {
|
|
157
|
-
steps.push(React.createElement(TouchableWithoutFeedback, { key: position, onPress: () => this.stepPressed(position) },
|
|
158
|
-
React.createElement(View, { style: [
|
|
159
|
-
styles.stepContainer,
|
|
160
|
-
direction === "vertical"
|
|
161
|
-
? { flexDirection: "column" }
|
|
162
|
-
: { flexDirection: "row" },
|
|
163
|
-
] }, this.renderStep(position))));
|
|
164
|
-
}
|
|
165
|
-
return (React.createElement(View, { onLayout: (event) => this.setState({
|
|
166
|
-
width: event.nativeEvent.layout.width,
|
|
167
|
-
height: event.nativeEvent.layout.height,
|
|
168
|
-
}), style: [
|
|
169
|
-
styles.stepIndicatorContainer,
|
|
170
|
-
direction === "vertical"
|
|
171
|
-
? {
|
|
172
|
-
flexDirection: "column",
|
|
173
|
-
width: this.state.customStyles.currentStepIndicatorSize,
|
|
174
|
-
}
|
|
175
|
-
: {
|
|
176
|
-
flexDirection: "row",
|
|
177
|
-
height: this.state.customStyles.currentStepIndicatorSize,
|
|
178
|
-
},
|
|
179
|
-
] }, steps));
|
|
180
|
-
};
|
|
181
|
-
renderStepLabels = () => {
|
|
182
|
-
const { labels, direction, currentPosition, renderLabel } = this.props;
|
|
183
|
-
var labelViews = labels.map((label, index) => {
|
|
184
|
-
const selectedStepLabelStyle = index === currentPosition
|
|
185
|
-
? { color: this.state.customStyles.currentStepLabelColor }
|
|
186
|
-
: { color: this.state.customStyles.labelColor };
|
|
187
|
-
return (React.createElement(TouchableWithoutFeedback, { style: styles.stepLabelItem, key: index, onPress: () => this.stepPressed(index) },
|
|
188
|
-
React.createElement(View, { style: styles.stepLabelItem }, renderLabel ? (renderLabel({
|
|
189
|
-
position: index,
|
|
190
|
-
stepStatus: this.getStepStatus(index),
|
|
191
|
-
label,
|
|
192
|
-
currentPosition,
|
|
193
|
-
})) : (React.createElement(Text, { style: [
|
|
194
|
-
styles.stepLabel,
|
|
195
|
-
selectedStepLabelStyle,
|
|
196
|
-
{
|
|
197
|
-
fontSize: this.state.customStyles.labelSize,
|
|
198
|
-
fontFamily: this.state.customStyles.labelFontFamily,
|
|
199
|
-
},
|
|
200
|
-
] }, label)))));
|
|
201
|
-
});
|
|
202
|
-
return (React.createElement(View, { style: [
|
|
203
|
-
styles.stepLabelsContainer,
|
|
204
|
-
direction === "vertical"
|
|
205
|
-
? { flexDirection: "column", paddingHorizontal: 4 }
|
|
206
|
-
: { flexDirection: "row", paddingVertical: 4 },
|
|
207
|
-
{ alignItems: this.state.customStyles.labelAlign },
|
|
208
|
-
] }, labelViews));
|
|
209
|
-
};
|
|
210
|
-
renderStep = (position) => {
|
|
211
|
-
const { renderStepIndicator } = this.props;
|
|
212
|
-
let stepStyle;
|
|
213
|
-
let indicatorLabelStyle;
|
|
214
|
-
switch (this.getStepStatus(position)) {
|
|
215
|
-
case STEP_STATUS.CURRENT: {
|
|
216
|
-
stepStyle = {
|
|
217
|
-
backgroundColor: this.state.customStyles.stepIndicatorCurrentColor,
|
|
218
|
-
borderWidth: this.state.customStyles.currentStepStrokeWidth,
|
|
219
|
-
borderColor: this.state.customStyles.stepStrokeCurrentColor,
|
|
220
|
-
height: this.sizeAnim,
|
|
221
|
-
width: this.sizeAnim,
|
|
222
|
-
borderRadius: this.borderRadiusAnim,
|
|
223
|
-
};
|
|
224
|
-
indicatorLabelStyle = {
|
|
225
|
-
fontSize: this.state.customStyles.currentStepIndicatorLabelFontSize,
|
|
226
|
-
color: this.state.customStyles.stepIndicatorLabelCurrentColor,
|
|
227
|
-
};
|
|
228
|
-
break;
|
|
229
|
-
}
|
|
230
|
-
case STEP_STATUS.FINISHED: {
|
|
231
|
-
stepStyle = {
|
|
232
|
-
backgroundColor: this.state.customStyles.stepIndicatorFinishedColor,
|
|
233
|
-
borderWidth: this.state.customStyles.stepStrokeWidth,
|
|
234
|
-
borderColor: this.state.customStyles.stepStrokeFinishedColor,
|
|
235
|
-
height: this.state.customStyles.stepIndicatorSize,
|
|
236
|
-
width: this.state.customStyles.stepIndicatorSize,
|
|
237
|
-
borderRadius: this.state.customStyles.stepIndicatorSize / 2,
|
|
238
|
-
};
|
|
239
|
-
indicatorLabelStyle = {
|
|
240
|
-
fontSize: this.state.customStyles.stepIndicatorLabelFontSize,
|
|
241
|
-
color: this.state.customStyles.stepIndicatorLabelFinishedColor,
|
|
242
|
-
};
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
case STEP_STATUS.UNFINISHED: {
|
|
246
|
-
stepStyle = {
|
|
247
|
-
backgroundColor: this.state.customStyles.stepIndicatorUnFinishedColor,
|
|
248
|
-
borderWidth: this.state.customStyles.stepStrokeWidth,
|
|
249
|
-
borderColor: this.state.customStyles.stepStrokeUnFinishedColor,
|
|
250
|
-
height: this.state.customStyles.stepIndicatorSize,
|
|
251
|
-
width: this.state.customStyles.stepIndicatorSize,
|
|
252
|
-
borderRadius: this.state.customStyles.stepIndicatorSize / 2,
|
|
253
|
-
};
|
|
254
|
-
indicatorLabelStyle = {
|
|
255
|
-
overflow: "hidden",
|
|
256
|
-
fontSize: this.state.customStyles.stepIndicatorLabelFontSize,
|
|
257
|
-
color: this.state.customStyles.stepIndicatorLabelUnFinishedColor,
|
|
258
|
-
};
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
default:
|
|
262
|
-
}
|
|
263
|
-
return (React.createElement(Animated.View, { key: "step-indicator", style: [styles.step, stepStyle] }, renderStepIndicator ? (renderStepIndicator({
|
|
264
|
-
position,
|
|
265
|
-
stepStatus: this.getStepStatus(position),
|
|
266
|
-
})) : (React.createElement(Text, { style: indicatorLabelStyle }, `${position + 1}`))));
|
|
267
|
-
};
|
|
268
|
-
getStepStatus = (stepPosition) => {
|
|
269
|
-
const { currentPosition } = this.props;
|
|
270
|
-
if (stepPosition === currentPosition) {
|
|
271
|
-
return STEP_STATUS.CURRENT;
|
|
272
|
-
}
|
|
273
|
-
else if (stepPosition < currentPosition) {
|
|
274
|
-
return STEP_STATUS.FINISHED;
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
return STEP_STATUS.UNFINISHED;
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
onCurrentPositionChanged = (position) => {
|
|
281
|
-
let { stepCount } = this.props;
|
|
282
|
-
if (position > stepCount - 1) {
|
|
283
|
-
position = stepCount - 1;
|
|
284
|
-
}
|
|
285
|
-
const animateToPosition = (this.state.progressBarSize / (stepCount - 1)) * position;
|
|
286
|
-
this.sizeAnim.setValue(this.state.customStyles.stepIndicatorSize);
|
|
287
|
-
this.borderRadiusAnim.setValue(this.state.customStyles.stepIndicatorSize / 2);
|
|
288
|
-
Animated.sequence([
|
|
289
|
-
Animated.timing(this.progressAnim, {
|
|
290
|
-
toValue: animateToPosition,
|
|
291
|
-
duration: 200,
|
|
292
|
-
}),
|
|
293
|
-
Animated.parallel([
|
|
294
|
-
Animated.timing(this.sizeAnim, {
|
|
295
|
-
toValue: this.state.customStyles.currentStepIndicatorSize,
|
|
296
|
-
duration: 100,
|
|
297
|
-
}),
|
|
298
|
-
Animated.timing(this.borderRadiusAnim, {
|
|
299
|
-
toValue: this.state.customStyles.currentStepIndicatorSize / 2,
|
|
300
|
-
duration: 100,
|
|
301
|
-
}),
|
|
302
|
-
]),
|
|
303
|
-
]).start();
|
|
304
|
-
};
|
|
305
305
|
}
|
|
306
306
|
const styles = StyleSheet.create({
|
|
307
307
|
container: {
|
|
@@ -4,13 +4,13 @@ import { isNumber } from "lodash";
|
|
|
4
4
|
import { withTheme } from "../theming";
|
|
5
5
|
import IconButton from "./IconButton";
|
|
6
6
|
const Stepper = ({ min = -Infinity, max = Infinity, value: valueProp, defaultValue, style, typeStyle, iconSize = 24, iconColor, onChange, theme: { colors, typography }, Icon, }) => {
|
|
7
|
-
const [value, setValue] = useState(defaultValue
|
|
7
|
+
const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : 0);
|
|
8
8
|
const isValidValue = (valueArg) => valueArg >= min && valueArg <= max;
|
|
9
9
|
const handlePlusOrMinus = (type) => {
|
|
10
10
|
const newValue = type === "plus" ? value + 1 : value - 1;
|
|
11
11
|
if (isValidValue(newValue)) {
|
|
12
12
|
setValue(newValue);
|
|
13
|
-
onChange
|
|
13
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
16
|
useEffect(() => {
|
package/src/components/Text.js
CHANGED
|
@@ -2,7 +2,6 @@ import * as React from "react";
|
|
|
2
2
|
import { Text as NativeText, I18nManager } from "react-native";
|
|
3
3
|
import { withTheme } from "../theming";
|
|
4
4
|
class Text extends React.Component {
|
|
5
|
-
_root;
|
|
6
5
|
setNativeProps(args) {
|
|
7
6
|
return this._root && this._root.setNativeProps(args);
|
|
8
7
|
}
|
|
@@ -7,6 +7,67 @@ const FOCUS_ANIMATION_DURATION = 150;
|
|
|
7
7
|
const BLUR_ANIMATION_DURATION = 180;
|
|
8
8
|
const ICON_SIZE = 24;
|
|
9
9
|
class TextField extends React.Component {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.state = {
|
|
13
|
+
labeled: new Animated.Value(this.props.value || this.props.error ? 0 : 1),
|
|
14
|
+
focused: false,
|
|
15
|
+
placeholder: this.props.error ? this.props.placeholder : "",
|
|
16
|
+
labelLayout: {
|
|
17
|
+
measured: false,
|
|
18
|
+
width: 0,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
this._timer = setTimeout(() => { }, 0);
|
|
22
|
+
this._showPlaceholder = () => {
|
|
23
|
+
clearTimeout(this._timer);
|
|
24
|
+
// Set the placeholder in a delay to offset the label animation
|
|
25
|
+
// If we show it immediately, they'll overlap and look ugly
|
|
26
|
+
this._timer = setTimeout(() => this.setState({
|
|
27
|
+
placeholder: this.props.placeholder,
|
|
28
|
+
}), 50);
|
|
29
|
+
};
|
|
30
|
+
this._hidePlaceholder = () => this.setState({
|
|
31
|
+
placeholder: "",
|
|
32
|
+
});
|
|
33
|
+
this._restoreLabel = () => Animated.timing(this.state.labeled, {
|
|
34
|
+
toValue: 1,
|
|
35
|
+
duration: FOCUS_ANIMATION_DURATION,
|
|
36
|
+
useNativeDriver: true,
|
|
37
|
+
}).start();
|
|
38
|
+
this._minmizeLabel = () => Animated.timing(this.state.labeled, {
|
|
39
|
+
toValue: 0,
|
|
40
|
+
duration: BLUR_ANIMATION_DURATION,
|
|
41
|
+
useNativeDriver: true,
|
|
42
|
+
}).start();
|
|
43
|
+
this._handleFocus = () => {
|
|
44
|
+
if (this.props.disabled) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.setState({ focused: true });
|
|
48
|
+
};
|
|
49
|
+
this._handleBlur = () => {
|
|
50
|
+
if (this.props.disabled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.setState({ focused: false });
|
|
54
|
+
};
|
|
55
|
+
this._handleChangeText = (value) => {
|
|
56
|
+
if (this.props.disabled) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (typeof value === "string") {
|
|
60
|
+
this.setState({ value });
|
|
61
|
+
this.props.onChangeText && this.props.onChangeText(value);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.setState({ value: value.nativeEvent.text });
|
|
65
|
+
this.props.onChangeText &&
|
|
66
|
+
this.props.onChangeText(value.nativeEvent.text);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this._root = undefined;
|
|
70
|
+
}
|
|
10
71
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
11
72
|
return {
|
|
12
73
|
value: typeof nextProps.value !== "undefined"
|
|
@@ -14,15 +75,6 @@ class TextField extends React.Component {
|
|
|
14
75
|
: prevState.value,
|
|
15
76
|
};
|
|
16
77
|
}
|
|
17
|
-
state = {
|
|
18
|
-
labeled: new Animated.Value(this.props.value || this.props.error ? 0 : 1),
|
|
19
|
-
focused: false,
|
|
20
|
-
placeholder: this.props.error ? this.props.placeholder : "",
|
|
21
|
-
labelLayout: {
|
|
22
|
-
measured: false,
|
|
23
|
-
width: 0,
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
78
|
componentDidMount() {
|
|
27
79
|
if (this.props.defaultValue) {
|
|
28
80
|
this._handleChangeText(this.props.defaultValue);
|
|
@@ -59,61 +111,12 @@ class TextField extends React.Component {
|
|
|
59
111
|
}
|
|
60
112
|
}
|
|
61
113
|
}
|
|
62
|
-
_timer = setTimeout(() => { }, 0);
|
|
63
114
|
componentWillUnmount() {
|
|
64
115
|
clearTimeout(this._timer);
|
|
65
116
|
}
|
|
66
|
-
_showPlaceholder = () => {
|
|
67
|
-
clearTimeout(this._timer);
|
|
68
|
-
// Set the placeholder in a delay to offset the label animation
|
|
69
|
-
// If we show it immediately, they'll overlap and look ugly
|
|
70
|
-
this._timer = setTimeout(() => this.setState({
|
|
71
|
-
placeholder: this.props.placeholder,
|
|
72
|
-
}), 50);
|
|
73
|
-
};
|
|
74
|
-
_hidePlaceholder = () => this.setState({
|
|
75
|
-
placeholder: "",
|
|
76
|
-
});
|
|
77
|
-
_restoreLabel = () => Animated.timing(this.state.labeled, {
|
|
78
|
-
toValue: 1,
|
|
79
|
-
duration: FOCUS_ANIMATION_DURATION,
|
|
80
|
-
useNativeDriver: true,
|
|
81
|
-
}).start();
|
|
82
|
-
_minmizeLabel = () => Animated.timing(this.state.labeled, {
|
|
83
|
-
toValue: 0,
|
|
84
|
-
duration: BLUR_ANIMATION_DURATION,
|
|
85
|
-
useNativeDriver: true,
|
|
86
|
-
}).start();
|
|
87
|
-
_handleFocus = () => {
|
|
88
|
-
if (this.props.disabled) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
this.setState({ focused: true });
|
|
92
|
-
};
|
|
93
|
-
_handleBlur = () => {
|
|
94
|
-
if (this.props.disabled) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
this.setState({ focused: false });
|
|
98
|
-
};
|
|
99
|
-
_handleChangeText = (value) => {
|
|
100
|
-
if (this.props.disabled) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (typeof value === "string") {
|
|
104
|
-
this.setState({ value });
|
|
105
|
-
this.props.onChangeText && this.props.onChangeText(value);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
this.setState({ value: value.nativeEvent.text });
|
|
109
|
-
this.props.onChangeText &&
|
|
110
|
-
this.props.onChangeText(value.nativeEvent.text);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
117
|
toggleFocus() {
|
|
114
118
|
this.setState((prevState) => ({ focused: !prevState.focused }));
|
|
115
119
|
}
|
|
116
|
-
_root = undefined;
|
|
117
120
|
/**
|
|
118
121
|
* @internal
|
|
119
122
|
*/
|
|
@@ -285,7 +288,7 @@ class TextField extends React.Component {
|
|
|
285
288
|
return (React.createElement(View, { style: [styles.container, styleProp] },
|
|
286
289
|
leftIconName && leftIconMode === "outset" ? (React.createElement(Icon, { ...leftIconProps, style: leftIconStyle })) : null,
|
|
287
290
|
React.createElement(View, { style: applyStyles([containerStyle], {
|
|
288
|
-
height: style
|
|
291
|
+
height: style === null || style === void 0 ? void 0 : style.height,
|
|
289
292
|
backgroundColor: bgColor,
|
|
290
293
|
padding,
|
|
291
294
|
paddingTop,
|
package/src/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
const expo = global.__expo;
|
|
4
|
-
const DEFAULT_STATUSBAR_HEIGHT_EXPO = expo
|
|
4
|
+
const DEFAULT_STATUSBAR_HEIGHT_EXPO = (expo === null || expo === void 0 ? void 0 : expo.Constants)
|
|
5
5
|
? expo.Constants.statusBarHeight
|
|
6
6
|
: 0;
|
|
7
7
|
export const APPROX_STATUSBAR_HEIGHT = Platform.select({
|