aport-tools 4.3.6 → 4.4.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/forms/FormContext.d.ts +8 -0
- package/dist/forms/Stepper.d.ts +11 -0
- package/dist/index.esm.js +124 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +123 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
@@ -7,9 +7,17 @@ interface FormContextProps {
|
|
7
7
|
handleSubmit: () => void;
|
8
8
|
}
|
9
9
|
export declare const useFormContext: () => FormContextProps;
|
10
|
+
interface StepperProps {
|
11
|
+
steps: string[];
|
12
|
+
presseable?: boolean;
|
13
|
+
onPress?: (stepIndex: number) => void;
|
14
|
+
step: number;
|
15
|
+
totalSteps: number;
|
16
|
+
}
|
10
17
|
interface FormProps {
|
11
18
|
children: ReactNode;
|
12
19
|
onSubmit: (values: Record<string, any>) => Promise<Record<string, string[]>>;
|
20
|
+
stepper?: StepperProps;
|
13
21
|
}
|
14
22
|
export declare const Form: React.FC<FormProps>;
|
15
23
|
export {};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react";
|
2
|
+
interface StepperProps {
|
3
|
+
steps?: string[];
|
4
|
+
currentStep: number;
|
5
|
+
presseable?: boolean;
|
6
|
+
onPress?: (stepIndex: number) => void;
|
7
|
+
stepStyle?: "circular" | "square";
|
8
|
+
totalSteps: number;
|
9
|
+
}
|
10
|
+
declare const Stepper: React.FC<StepperProps>;
|
11
|
+
export default Stepper;
|
package/dist/index.esm.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
/*! aport-tools v4.
|
1
|
+
/*! aport-tools v4.4.1 | ISC */
|
2
2
|
import React, { useContext, useState, createContext, useCallback, useMemo } from 'react';
|
3
|
-
import { StyleSheet, Text as Text$1,
|
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
|
|
@@ -97,6 +97,119 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
97
97
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
98
98
|
};
|
99
99
|
|
100
|
+
var Stepper = function Stepper(_a) {
|
101
|
+
var steps = _a.steps,
|
102
|
+
currentStep = _a.currentStep,
|
103
|
+
_b = _a.presseable,
|
104
|
+
presseable = _b === void 0 ? false : _b,
|
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
|
+
};
|
124
|
+
return /*#__PURE__*/React.createElement(View, {
|
125
|
+
style: styles$9.container
|
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
|
+
}],
|
135
|
+
disabled: !presseable,
|
136
|
+
onPress: function onPress() {
|
137
|
+
return _onPress && _onPress(index);
|
138
|
+
}
|
139
|
+
}, /*#__PURE__*/React.createElement(View, {
|
140
|
+
style: [styles$9.step, stepStyle === "square" && styles$9.squareStep, currentStep >= index && styles$9.activeStep]
|
141
|
+
}, /*#__PURE__*/React.createElement(Text$1, {
|
142
|
+
style: styles$9.stepLabel
|
143
|
+
}, index + 1)), steps && /*#__PURE__*/React.createElement(Text$1, {
|
144
|
+
style: styles$9.stepText
|
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
|
+
}))));
|
154
|
+
}));
|
155
|
+
};
|
156
|
+
var styles$9 = StyleSheet.create({
|
157
|
+
container: {
|
158
|
+
flexDirection: "row",
|
159
|
+
alignItems: "center",
|
160
|
+
justifyContent: "space-between",
|
161
|
+
marginBottom: 16
|
162
|
+
},
|
163
|
+
stepContainer: {
|
164
|
+
alignItems: "center",
|
165
|
+
flex: 1
|
166
|
+
},
|
167
|
+
step: {
|
168
|
+
width: 30,
|
169
|
+
height: 30,
|
170
|
+
borderRadius: 15,
|
171
|
+
// Default to circular
|
172
|
+
backgroundColor: "#aaaaaa",
|
173
|
+
alignItems: "center",
|
174
|
+
justifyContent: "center",
|
175
|
+
marginBottom: 4
|
176
|
+
},
|
177
|
+
squareStep: {
|
178
|
+
borderRadius: 5 // Square shape
|
179
|
+
},
|
180
|
+
activeStep: {
|
181
|
+
backgroundColor: "#3498db"
|
182
|
+
},
|
183
|
+
stepLabel: {
|
184
|
+
color: "#ffffff",
|
185
|
+
fontWeight: "bold"
|
186
|
+
},
|
187
|
+
stepText: {
|
188
|
+
fontSize: 12,
|
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
|
210
|
+
}
|
211
|
+
});
|
212
|
+
|
100
213
|
// src/forms/FormContext.tsx
|
101
214
|
var FormContext = /*#__PURE__*/createContext(undefined);
|
102
215
|
var useFormContext = function useFormContext() {
|
@@ -108,7 +221,8 @@ var useFormContext = function useFormContext() {
|
|
108
221
|
};
|
109
222
|
var Form = function Form(_a) {
|
110
223
|
var children = _a.children,
|
111
|
-
onSubmit = _a.onSubmit
|
224
|
+
onSubmit = _a.onSubmit,
|
225
|
+
stepper = _a.stepper;
|
112
226
|
var _b = useState({}),
|
113
227
|
formValues = _b[0],
|
114
228
|
setFormValues = _b[1];
|
@@ -149,7 +263,13 @@ var Form = function Form(_a) {
|
|
149
263
|
setErrors: setErrors,
|
150
264
|
handleSubmit: handleSubmit
|
151
265
|
}
|
152
|
-
},
|
266
|
+
}, stepper && (/*#__PURE__*/React.createElement(Stepper, {
|
267
|
+
steps: stepper.steps,
|
268
|
+
currentStep: stepper.step,
|
269
|
+
presseable: stepper.presseable,
|
270
|
+
onPress: stepper.onPress,
|
271
|
+
totalSteps: stepper.totalSteps
|
272
|
+
})), children);
|
153
273
|
};
|
154
274
|
|
155
275
|
// src/fonts/Text.tsx
|