@draftbit/core 46.1.4-e6469c.0 → 46.2.1-327d47.2
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/ActionSheet/index.js.map +1 -1
- package/lib/commonjs/components/CardBlock.js +15 -5
- package/lib/commonjs/components/CardBlock.js.map +1 -1
- package/lib/commonjs/components/Carousel.js +3 -1
- package/lib/commonjs/components/Carousel.js.map +1 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +2 -4
- package/lib/commonjs/components/Checkbox/Checkbox.js.map +1 -1
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js +23 -6
- package/lib/commonjs/components/Checkbox/CheckboxGroupRow.js.map +1 -1
- package/lib/commonjs/components/Checkbox/context.js +1 -1
- package/lib/commonjs/components/Checkbox/context.js.map +1 -1
- package/lib/commonjs/components/CircleImage.js +17 -3
- package/lib/commonjs/components/CircleImage.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 +10 -11
- package/lib/commonjs/components/DatePicker/DatePicker.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.web.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponentType.js.map +1 -1
- package/lib/commonjs/components/DeprecatedButton.js +4 -20
- package/lib/commonjs/components/DeprecatedButton.js.map +1 -1
- package/lib/commonjs/components/DeprecatedCardWrapper.js +2 -14
- package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
- package/lib/commonjs/components/DeprecatedFAB.js +21 -4
- package/lib/commonjs/components/DeprecatedFAB.js.map +1 -1
- package/lib/commonjs/components/HeaderLarge.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 +135 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +161 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js +136 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerTypes.js +6 -0
- package/lib/commonjs/components/Picker/PickerTypes.js.map +1 -0
- package/lib/commonjs/components/RadioButton/RadioButton.js +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +17 -5
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.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/components/Swiper/SwiperItem.js.map +1 -1
- package/lib/commonjs/components/Text.js +38 -11
- package/lib/commonjs/components/Text.js.map +1 -1
- package/lib/commonjs/mappings/CardContainerRating.js.map +1 -1
- package/lib/commonjs/mappings/Checkbox.js.map +1 -1
- package/lib/commonjs/mappings/NumberInput.js +241 -0
- package/lib/commonjs/mappings/NumberInput.js.map +1 -0
- package/lib/commonjs/mappings/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/mappings/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/mappings/Text.js +33 -26
- package/lib/commonjs/mappings/Text.js.map +1 -1
- package/lib/commonjs/mappings/TextArea.js +192 -2
- package/lib/commonjs/mappings/TextArea.js.map +1 -1
- package/lib/commonjs/mappings/TextField.js +191 -2
- package/lib/commonjs/mappings/TextField.js.map +1 -1
- package/lib/commonjs/mappings/TextInput.js +180 -29
- package/lib/commonjs/mappings/TextInput.js.map +1 -1
- package/lib/commonjs/mappings/Video.js.map +1 -1
- package/lib/commonjs/styles/DarkTheme.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/DatePicker/DatePickerComponent.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 +112 -0
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.ios.js +135 -0
- package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.web.js +113 -0
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/module/components/Picker/PickerTypes.js +2 -0
- package/lib/module/components/Picker/PickerTypes.js.map +1 -0
- 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/components/Touchable.js +2 -16
- package/lib/module/components/Touchable.js.map +1 -1
- package/lib/module/mappings/NumberInput.js +231 -0
- package/lib/module/mappings/NumberInput.js.map +1 -0
- package/lib/module/mappings/Surface.js.map +1 -1
- package/lib/module/mappings/Text.js +33 -26
- package/lib/module/mappings/Text.js.map +1 -1
- package/lib/module/mappings/TextArea.js +193 -3
- package/lib/module/mappings/TextArea.js.map +1 -1
- package/lib/module/mappings/TextField.js +192 -3
- package/lib/module/mappings/TextField.js.map +1 -1
- package/lib/module/mappings/TextInput.js +180 -29
- package/lib/module/mappings/TextInput.js.map +1 -1
- package/lib/module/utilities.js +1 -1
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +6 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +7 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +6 -0
- package/lib/typescript/src/components/Picker/PickerTypes.d.ts +18 -0
- package/lib/typescript/src/mappings/NumberInput.d.ts +297 -0
- package/lib/typescript/src/mappings/Text.d.ts +24 -10
- package/lib/typescript/src/mappings/TextArea.d.ts +12 -11
- package/lib/typescript/src/mappings/TextField.d.ts +4 -4
- package/lib/typescript/src/mappings/TextInput.d.ts +3 -254
- 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 +69 -0
- package/src/components/Picker/PickerComponent.android.tsx +116 -0
- package/src/components/Picker/PickerComponent.ios.js +79 -0
- package/src/components/Picker/PickerComponent.ios.tsx +142 -0
- package/src/components/Picker/PickerComponent.web.js +70 -0
- package/src/components/Picker/PickerComponent.web.tsx +117 -0
- package/src/components/Picker/PickerTypes.js +1 -0
- package/src/components/Picker/PickerTypes.ts +18 -0
- 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
- package/src/mappings/NumberInput.js +248 -0
- package/src/mappings/NumberInput.ts +267 -0
- package/src/mappings/Text.js +33 -26
- package/src/mappings/Text.ts +34 -27
- package/src/mappings/TextArea.js +221 -3
- package/src/mappings/TextArea.ts +227 -3
- package/src/mappings/TextField.js +220 -3
- package/src/mappings/TextField.ts +227 -3
- package/src/mappings/TextInput.js +208 -31
- package/src/mappings/TextInput.ts +214 -34
|
@@ -4,25 +4,28 @@ import { View, StyleSheet } from "react-native";
|
|
|
4
4
|
* Portal host is the component which actually renders all Portals.
|
|
5
5
|
*/
|
|
6
6
|
export default class PortalManager extends React.PureComponent {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.state = {
|
|
10
|
+
portals: [],
|
|
11
|
+
};
|
|
12
|
+
this.mount = (key, children) => {
|
|
13
|
+
this.setState((state) => ({
|
|
14
|
+
portals: [...state.portals, { key, children }],
|
|
15
|
+
}));
|
|
16
|
+
};
|
|
17
|
+
this.update = (key, children) => this.setState((state) => ({
|
|
18
|
+
portals: state.portals.map((item) => {
|
|
19
|
+
if (item.key === key) {
|
|
20
|
+
return { ...item, children };
|
|
21
|
+
}
|
|
22
|
+
return item;
|
|
23
|
+
}),
|
|
13
24
|
}));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return { ...item, children };
|
|
19
|
-
}
|
|
20
|
-
return item;
|
|
21
|
-
}),
|
|
22
|
-
}));
|
|
23
|
-
unmount = (key) => this.setState((state) => ({
|
|
24
|
-
portals: state.portals.filter((item) => item.key !== key),
|
|
25
|
-
}));
|
|
25
|
+
this.unmount = (key) => this.setState((state) => ({
|
|
26
|
+
portals: state.portals.filter((item) => item.key !== key),
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
26
29
|
render() {
|
|
27
30
|
return this.state.portals.map(({ key, children }) => (React.createElement(View, { key: key, collapsable: false /* Need collapsable=false here to clip the elevations, otherwise they appear above sibling components */, pointerEvents: "box-none", style: StyleSheet.absoluteFill }, children)));
|
|
28
31
|
}
|
|
@@ -5,6 +5,15 @@ const BAR_WIDTH_ZERO_POSITION = INDETERMINATE_WIDTH_FACTOR / (1 + INDETERMINATE_
|
|
|
5
5
|
export default class ProgressBar extends Component {
|
|
6
6
|
constructor(props) {
|
|
7
7
|
super(props);
|
|
8
|
+
this.handleLayout = (event) => {
|
|
9
|
+
const { width = 150, onLayout } = this.props;
|
|
10
|
+
if (!width) {
|
|
11
|
+
this.setState({ width: event.nativeEvent.layout.width });
|
|
12
|
+
}
|
|
13
|
+
if (onLayout) {
|
|
14
|
+
onLayout(event);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
8
17
|
const { progress: progressP = 0, indeterminate = false } = props;
|
|
9
18
|
const progress = Math.min(Math.max(progressP, 0), 1);
|
|
10
19
|
this.state = {
|
|
@@ -50,15 +59,6 @@ export default class ProgressBar extends Component {
|
|
|
50
59
|
}
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
|
-
handleLayout = (event) => {
|
|
54
|
-
const { width = 150, onLayout } = this.props;
|
|
55
|
-
if (!width) {
|
|
56
|
-
this.setState({ width: event.nativeEvent.layout.width });
|
|
57
|
-
}
|
|
58
|
-
if (onLayout) {
|
|
59
|
-
onLayout(event);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
62
|
animate() {
|
|
63
63
|
const { useNativeDriver = false, indeterminateAnimationDuration = 1000 } = this.props;
|
|
64
64
|
this.state.animationValue.setValue(0);
|
|
@@ -7,10 +7,10 @@ const RadioButton = ({ Icon, disabled = false, color, value = "", selected, unse
|
|
|
7
7
|
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
8
8
|
const realValue = getValueForRadioButton(value);
|
|
9
9
|
const realContextValue = getValueForRadioButton(contextValue);
|
|
10
|
-
const isSelected = selected
|
|
10
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
11
11
|
const handlePress = () => {
|
|
12
|
-
onPress
|
|
13
|
-
onValueChange
|
|
12
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
13
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
14
14
|
};
|
|
15
15
|
return (React.createElement(IconButton, { Icon: Icon, icon: isSelected ? selectedIcon : unselectedIcon, color: isSelected ? color : unselectedColor, disabled: disabled, onPress: handlePress, size: size, style: style, ...rest }));
|
|
16
16
|
};
|
|
@@ -20,7 +20,7 @@ const RadioButtonGroup = ({ direction = Direction.Vertical, value = "", onValueC
|
|
|
20
20
|
const handleValueChange = (newValue) => {
|
|
21
21
|
const realNewValue = getValueForRadioButton(newValue);
|
|
22
22
|
setInternalValue(realNewValue);
|
|
23
|
-
onValueChange
|
|
23
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realNewValue);
|
|
24
24
|
};
|
|
25
25
|
const _containerStyle = [
|
|
26
26
|
{
|
|
@@ -34,10 +34,10 @@ const RadioButtonRow = ({ Icon, label, value = "", color, unselectedColor, onPre
|
|
|
34
34
|
const { value: contextValue, onValueChange, direction: parentDirection, } = useRadioButtonGroupContext();
|
|
35
35
|
const realValue = getValueForRadioButton(value);
|
|
36
36
|
const realContextValue = getValueForRadioButton(contextValue);
|
|
37
|
-
const isSelected = selected
|
|
37
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
38
38
|
const handlePress = () => {
|
|
39
|
-
onPress
|
|
40
|
-
onValueChange
|
|
39
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
40
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
41
41
|
};
|
|
42
42
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
43
43
|
return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|
|
@@ -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
|
}
|