aport-tools 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,6 +12,7 @@ interface StepperProps {
12
12
  presseable?: boolean;
13
13
  onPress?: (stepIndex: number) => void;
14
14
  step: number;
15
+ totalSteps: number;
15
16
  }
16
17
  interface FormProps {
17
18
  children: ReactNode;
@@ -1,9 +1,11 @@
1
1
  import React from "react";
2
2
  interface StepperProps {
3
- steps: string[];
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.0 | ISC */
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
- }, steps.map(function (label, index) {
109
- return /*#__PURE__*/React.createElement(TouchableOpacity, {
110
- key: index,
111
- style: [styles$9.stepContainer, index <= currentStep ? styles$9.activeStep : styles$9.inactiveStep],
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.stepCircle
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
- }, label));
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
- stepCircle: {
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