aport-tools 4.4.0 → 4.4.1
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/dist/forms/FormContext.d.ts +1 -0
- package/dist/forms/Stepper.d.ts +3 -1
- package/dist/index.esm.js +70 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +69 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/forms/Stepper.d.ts
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
import React from "react";
|
2
2
|
interface StepperProps {
|
3
|
-
steps
|
3
|
+
steps?: string[];
|
4
4
|
currentStep: number;
|
5
5
|
presseable?: boolean;
|
6
6
|
onPress?: (stepIndex: number) => void;
|
7
|
+
stepStyle?: "circular" | "square";
|
8
|
+
totalSteps: number;
|
7
9
|
}
|
8
10
|
declare const Stepper: React.FC<StepperProps>;
|
9
11
|
export default Stepper;
|
package/dist/index.esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
/*! aport-tools v4.4.
|
1
|
+
/*! aport-tools v4.4.1 | ISC */
|
2
2
|
import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
|
3
|
-
import { StyleSheet, View, TouchableOpacity, Text as Text$1, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Image, Alert, ActivityIndicator } from 'react-native';
|
3
|
+
import { StyleSheet, Animated, View, TouchableOpacity, Text as Text$1, TextInput, Modal, Pressable, FlatList, Keyboard, Platform, Image, Alert, ActivityIndicator } from 'react-native';
|
4
4
|
import { ThemeContext } from 'aport-themes';
|
5
5
|
import * as ImagePicker from 'expo-image-picker';
|
6
6
|
|
@@ -102,24 +102,55 @@ var Stepper = function Stepper(_a) {
|
|
102
102
|
currentStep = _a.currentStep,
|
103
103
|
_b = _a.presseable,
|
104
104
|
presseable = _b === void 0 ? false : _b,
|
105
|
-
_onPress = _a.onPress
|
105
|
+
_onPress = _a.onPress,
|
106
|
+
_c = _a.stepStyle,
|
107
|
+
stepStyle = _c === void 0 ? "circular" : _c,
|
108
|
+
totalSteps = _a.totalSteps;
|
109
|
+
var progressAnim = React.useRef(new Animated.Value(0)).current;
|
110
|
+
React.useEffect(function () {
|
111
|
+
Animated.timing(progressAnim, {
|
112
|
+
toValue: currentStep,
|
113
|
+
duration: 300,
|
114
|
+
useNativeDriver: false
|
115
|
+
}).start();
|
116
|
+
}, [currentStep]);
|
117
|
+
var getSeparatorWidth = function getSeparatorWidth(index) {
|
118
|
+
if (currentStep > index && currentStep < index + 1) {
|
119
|
+
// Return the fractional percentage for odd steps
|
120
|
+
return "".concat(((currentStep - index) * 100).toFixed(0), "%");
|
121
|
+
}
|
122
|
+
return currentStep > index ? "100%" : "0%";
|
123
|
+
};
|
106
124
|
return /*#__PURE__*/React.createElement(View, {
|
107
125
|
style: styles$9.container
|
108
|
-
},
|
109
|
-
|
110
|
-
|
111
|
-
|
126
|
+
}, Array.from({
|
127
|
+
length: totalSteps
|
128
|
+
}, function (_, index) {
|
129
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
130
|
+
key: index
|
131
|
+
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
132
|
+
style: [styles$9.stepContainer, presseable && {
|
133
|
+
cursor: "pointer"
|
134
|
+
}],
|
112
135
|
disabled: !presseable,
|
113
136
|
onPress: function onPress() {
|
114
137
|
return _onPress && _onPress(index);
|
115
138
|
}
|
116
139
|
}, /*#__PURE__*/React.createElement(View, {
|
117
|
-
style: styles$9.
|
140
|
+
style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && styles$9.activeStep]
|
118
141
|
}, /*#__PURE__*/React.createElement(Text$1, {
|
119
142
|
style: styles$9.stepLabel
|
120
|
-
}, index + 1)), /*#__PURE__*/React.createElement(Text$1, {
|
143
|
+
}, index + 1)), steps && /*#__PURE__*/React.createElement(Text$1, {
|
121
144
|
style: styles$9.stepText
|
122
|
-
},
|
145
|
+
}, steps[index])), index < totalSteps - 1 && (/*#__PURE__*/React.createElement(View, {
|
146
|
+
style: styles$9.separatorContainer
|
147
|
+
}, /*#__PURE__*/React.createElement(View, {
|
148
|
+
style: styles$9.separatorBackground
|
149
|
+
}), /*#__PURE__*/React.createElement(Animated.View, {
|
150
|
+
style: [styles$9.separatorProgress, {
|
151
|
+
width: getSeparatorWidth(index)
|
152
|
+
}]
|
153
|
+
}))));
|
123
154
|
}));
|
124
155
|
};
|
125
156
|
var styles$9 = StyleSheet.create({
|
@@ -133,27 +164,49 @@ var styles$9 = StyleSheet.create({
|
|
133
164
|
alignItems: "center",
|
134
165
|
flex: 1
|
135
166
|
},
|
136
|
-
|
167
|
+
step: {
|
137
168
|
width: 30,
|
138
169
|
height: 30,
|
139
170
|
borderRadius: 15,
|
171
|
+
// Default to circular
|
172
|
+
backgroundColor: "#aaaaaa",
|
140
173
|
alignItems: "center",
|
141
174
|
justifyContent: "center",
|
142
175
|
marginBottom: 4
|
143
176
|
},
|
177
|
+
squareStep: {
|
178
|
+
borderRadius: 5 // Square shape
|
179
|
+
},
|
144
180
|
activeStep: {
|
145
181
|
backgroundColor: "#3498db"
|
146
182
|
},
|
147
|
-
inactiveStep: {
|
148
|
-
backgroundColor: "#aaaaaa"
|
149
|
-
},
|
150
183
|
stepLabel: {
|
151
184
|
color: "#ffffff",
|
152
185
|
fontWeight: "bold"
|
153
186
|
},
|
154
187
|
stepText: {
|
155
188
|
fontSize: 12,
|
156
|
-
textAlign: "center"
|
189
|
+
textAlign: "center",
|
190
|
+
marginTop: 4
|
191
|
+
},
|
192
|
+
separatorContainer: {
|
193
|
+
flex: 1,
|
194
|
+
height: 4,
|
195
|
+
marginHorizontal: 8,
|
196
|
+
position: "relative"
|
197
|
+
},
|
198
|
+
separatorBackground: {
|
199
|
+
position: "absolute",
|
200
|
+
width: "100%",
|
201
|
+
height: "100%",
|
202
|
+
backgroundColor: "#aaaaaa",
|
203
|
+
borderRadius: 2
|
204
|
+
},
|
205
|
+
separatorProgress: {
|
206
|
+
position: "absolute",
|
207
|
+
height: "100%",
|
208
|
+
backgroundColor: "#3498db",
|
209
|
+
borderRadius: 2
|
157
210
|
}
|
158
211
|
});
|
159
212
|
|
@@ -214,7 +267,8 @@ var Form = function Form(_a) {
|
|
214
267
|
steps: stepper.steps,
|
215
268
|
currentStep: stepper.step,
|
216
269
|
presseable: stepper.presseable,
|
217
|
-
onPress: stepper.onPress
|
270
|
+
onPress: stepper.onPress,
|
271
|
+
totalSteps: stepper.totalSteps
|
218
272
|
})), children);
|
219
273
|
};
|
220
274
|
|