aport-tools 4.3.6 → 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.3.6 | ISC */
1
+ /*! aport-tools v4.4.1 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
@@ -118,6 +118,119 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
118
118
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
119
119
  };
120
120
 
121
+ var Stepper = function Stepper(_a) {
122
+ var steps = _a.steps,
123
+ currentStep = _a.currentStep,
124
+ _b = _a.presseable,
125
+ presseable = _b === void 0 ? false : _b,
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
+ };
145
+ return /*#__PURE__*/React.createElement(reactNative.View, {
146
+ style: styles$9.container
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
+ }],
156
+ disabled: !presseable,
157
+ onPress: function onPress() {
158
+ return _onPress && _onPress(index);
159
+ }
160
+ }, /*#__PURE__*/React.createElement(reactNative.View, {
161
+ style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && styles$9.activeStep]
162
+ }, /*#__PURE__*/React.createElement(reactNative.Text, {
163
+ style: styles$9.stepLabel
164
+ }, index + 1)), steps && /*#__PURE__*/React.createElement(reactNative.Text, {
165
+ style: styles$9.stepText
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
+ }))));
175
+ }));
176
+ };
177
+ var styles$9 = reactNative.StyleSheet.create({
178
+ container: {
179
+ flexDirection: "row",
180
+ alignItems: "center",
181
+ justifyContent: "space-between",
182
+ marginBottom: 16
183
+ },
184
+ stepContainer: {
185
+ alignItems: "center",
186
+ flex: 1
187
+ },
188
+ step: {
189
+ width: 30,
190
+ height: 30,
191
+ borderRadius: 15,
192
+ // Default to circular
193
+ backgroundColor: "#aaaaaa",
194
+ alignItems: "center",
195
+ justifyContent: "center",
196
+ marginBottom: 4
197
+ },
198
+ squareStep: {
199
+ borderRadius: 5 // Square shape
200
+ },
201
+ activeStep: {
202
+ backgroundColor: "#3498db"
203
+ },
204
+ stepLabel: {
205
+ color: "#ffffff",
206
+ fontWeight: "bold"
207
+ },
208
+ stepText: {
209
+ fontSize: 12,
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
231
+ }
232
+ });
233
+
121
234
  // src/forms/FormContext.tsx
122
235
  var FormContext = /*#__PURE__*/React.createContext(undefined);
123
236
  var useFormContext = function useFormContext() {
@@ -129,7 +242,8 @@ var useFormContext = function useFormContext() {
129
242
  };
130
243
  var Form = function Form(_a) {
131
244
  var children = _a.children,
132
- onSubmit = _a.onSubmit;
245
+ onSubmit = _a.onSubmit,
246
+ stepper = _a.stepper;
133
247
  var _b = React.useState({}),
134
248
  formValues = _b[0],
135
249
  setFormValues = _b[1];
@@ -170,7 +284,13 @@ var Form = function Form(_a) {
170
284
  setErrors: setErrors,
171
285
  handleSubmit: handleSubmit
172
286
  }
173
- }, children);
287
+ }, stepper && (/*#__PURE__*/React.createElement(Stepper, {
288
+ steps: stepper.steps,
289
+ currentStep: stepper.step,
290
+ presseable: stepper.presseable,
291
+ onPress: stepper.onPress,
292
+ totalSteps: stepper.totalSteps
293
+ })), children);
174
294
  };
175
295
 
176
296
  // src/fonts/Text.tsx