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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! aport-tools v4.4.0 | ISC */
1
+ /*! aport-tools v4.4.1 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -123,24 +123,55 @@ var Stepper = function Stepper(_a) {
123
123
  currentStep = _a.currentStep,
124
124
  _b = _a.presseable,
125
125
  presseable = _b === void 0 ? false : _b,
126
- _onPress = _a.onPress;
126
+ _onPress = _a.onPress,
127
+ _c = _a.stepStyle,
128
+ stepStyle = _c === void 0 ? "circular" : _c,
129
+ totalSteps = _a.totalSteps;
130
+ var progressAnim = React.useRef(new reactNative.Animated.Value(0)).current;
131
+ React.useEffect(function () {
132
+ reactNative.Animated.timing(progressAnim, {
133
+ toValue: currentStep,
134
+ duration: 300,
135
+ useNativeDriver: false
136
+ }).start();
137
+ }, [currentStep]);
138
+ var getSeparatorWidth = function getSeparatorWidth(index) {
139
+ if (currentStep > index && currentStep < index + 1) {
140
+ // Return the fractional percentage for odd steps
141
+ return "".concat(((currentStep - index) * 100).toFixed(0), "%");
142
+ }
143
+ return currentStep > index ? "100%" : "0%";
144
+ };
127
145
  return /*#__PURE__*/React.createElement(reactNative.View, {
128
146
  style: styles$9.container
129
- }, steps.map(function (label, index) {
130
- return /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
131
- key: index,
132
- style: [styles$9.stepContainer, index <= currentStep ? styles$9.activeStep : styles$9.inactiveStep],
147
+ }, Array.from({
148
+ length: totalSteps
149
+ }, function (_, index) {
150
+ return /*#__PURE__*/React.createElement(React.Fragment, {
151
+ key: index
152
+ }, /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
153
+ style: [styles$9.stepContainer, presseable && {
154
+ cursor: "pointer"
155
+ }],
133
156
  disabled: !presseable,
134
157
  onPress: function onPress() {
135
158
  return _onPress && _onPress(index);
136
159
  }
137
160
  }, /*#__PURE__*/React.createElement(reactNative.View, {
138
- style: styles$9.stepCircle
161
+ style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && styles$9.activeStep]
139
162
  }, /*#__PURE__*/React.createElement(reactNative.Text, {
140
163
  style: styles$9.stepLabel
141
- }, index + 1)), /*#__PURE__*/React.createElement(reactNative.Text, {
164
+ }, index + 1)), steps && /*#__PURE__*/React.createElement(reactNative.Text, {
142
165
  style: styles$9.stepText
143
- }, label));
166
+ }, steps[index])), index < totalSteps - 1 && (/*#__PURE__*/React.createElement(reactNative.View, {
167
+ style: styles$9.separatorContainer
168
+ }, /*#__PURE__*/React.createElement(reactNative.View, {
169
+ style: styles$9.separatorBackground
170
+ }), /*#__PURE__*/React.createElement(reactNative.Animated.View, {
171
+ style: [styles$9.separatorProgress, {
172
+ width: getSeparatorWidth(index)
173
+ }]
174
+ }))));
144
175
  }));
145
176
  };
146
177
  var styles$9 = reactNative.StyleSheet.create({
@@ -154,27 +185,49 @@ var styles$9 = reactNative.StyleSheet.create({
154
185
  alignItems: "center",
155
186
  flex: 1
156
187
  },
157
- stepCircle: {
188
+ step: {
158
189
  width: 30,
159
190
  height: 30,
160
191
  borderRadius: 15,
192
+ // Default to circular
193
+ backgroundColor: "#aaaaaa",
161
194
  alignItems: "center",
162
195
  justifyContent: "center",
163
196
  marginBottom: 4
164
197
  },
198
+ squareStep: {
199
+ borderRadius: 5 // Square shape
200
+ },
165
201
  activeStep: {
166
202
  backgroundColor: "#3498db"
167
203
  },
168
- inactiveStep: {
169
- backgroundColor: "#aaaaaa"
170
- },
171
204
  stepLabel: {
172
205
  color: "#ffffff",
173
206
  fontWeight: "bold"
174
207
  },
175
208
  stepText: {
176
209
  fontSize: 12,
177
- textAlign: "center"
210
+ textAlign: "center",
211
+ marginTop: 4
212
+ },
213
+ separatorContainer: {
214
+ flex: 1,
215
+ height: 4,
216
+ marginHorizontal: 8,
217
+ position: "relative"
218
+ },
219
+ separatorBackground: {
220
+ position: "absolute",
221
+ width: "100%",
222
+ height: "100%",
223
+ backgroundColor: "#aaaaaa",
224
+ borderRadius: 2
225
+ },
226
+ separatorProgress: {
227
+ position: "absolute",
228
+ height: "100%",
229
+ backgroundColor: "#3498db",
230
+ borderRadius: 2
178
231
  }
179
232
  });
180
233
 
@@ -235,7 +288,8 @@ var Form = function Form(_a) {
235
288
  steps: stepper.steps,
236
289
  currentStep: stepper.step,
237
290
  presseable: stepper.presseable,
238
- onPress: stepper.onPress
291
+ onPress: stepper.onPress,
292
+ totalSteps: stepper.totalSteps
239
293
  })), children);
240
294
  };
241
295