@towsila/expo-ui-library 1.5.9 → 1.5.12
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/package.json
CHANGED
|
@@ -21,32 +21,21 @@ interface Props {
|
|
|
21
21
|
function splitIntoSteps(fields: Field[]): Field[][] {
|
|
22
22
|
const info = fields.filter((f) => f.type !== "password");
|
|
23
23
|
const security = fields.filter((f) => f.type === "password");
|
|
24
|
-
|
|
25
|
-
console.log("DEBUG splitIntoSteps:", {
|
|
26
|
-
totalFields: fields.length,
|
|
27
|
-
infoFields: info.length,
|
|
28
|
-
securityFields: security.length,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
24
|
const steps: Field[][] = [];
|
|
32
25
|
|
|
33
|
-
// Split info fields if more than 3
|
|
34
26
|
if (info.length > 4) {
|
|
35
|
-
console.log("SPLITTING INFO FIELDS");
|
|
36
27
|
const mid = Math.ceil(info.length / 2);
|
|
37
28
|
steps.push(info.slice(0, mid));
|
|
38
29
|
steps.push(info.slice(mid));
|
|
39
30
|
} else if (info.length > 0) {
|
|
40
|
-
console.log("NOT SPLITTING, ADDING ALL");
|
|
41
31
|
steps.push(info);
|
|
42
32
|
}
|
|
43
33
|
|
|
44
34
|
// Add security fields as separate step
|
|
45
35
|
if (security.length > 0) {
|
|
46
|
-
console.log("ADDING SECURITY STEP");
|
|
47
36
|
steps.push(security);
|
|
48
37
|
}
|
|
49
|
-
|
|
38
|
+
|
|
50
39
|
return steps;
|
|
51
40
|
}
|
|
52
41
|
|
|
@@ -113,11 +102,6 @@ export const DynamicForm: React.FC<Props> = ({
|
|
|
113
102
|
);
|
|
114
103
|
|
|
115
104
|
return (
|
|
116
|
-
<ScrollView
|
|
117
|
-
contentContainerStyle={{ flexGrow: 1 }}
|
|
118
|
-
showsVerticalScrollIndicator={false}
|
|
119
|
-
bounces={false}
|
|
120
|
-
>
|
|
121
105
|
<View style={{ gap: 4, paddingBottom: 20 }}>
|
|
122
106
|
|
|
123
107
|
{/* Stepper — only show if more than 1 step */}
|
|
@@ -168,6 +152,5 @@ export const DynamicForm: React.FC<Props> = ({
|
|
|
168
152
|
</View>
|
|
169
153
|
)}
|
|
170
154
|
</View>
|
|
171
|
-
</ScrollView>
|
|
172
155
|
);
|
|
173
156
|
};
|
|
@@ -17,11 +17,26 @@ interface Props {
|
|
|
17
17
|
nextLabel?: string;
|
|
18
18
|
backLabel?: string;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
function splitIntoSteps(fields: Field[]): Field[][] {
|
|
22
22
|
const info = fields.filter((f) => f.type !== "password");
|
|
23
23
|
const security = fields.filter((f) => f.type === "password");
|
|
24
|
-
|
|
24
|
+
const steps: Field[][] = [];
|
|
25
|
+
|
|
26
|
+
if (info.length > 4) {
|
|
27
|
+
const mid = Math.ceil(info.length / 2);
|
|
28
|
+
steps.push(info.slice(0, mid));
|
|
29
|
+
steps.push(info.slice(mid));
|
|
30
|
+
} else if (info.length > 0) {
|
|
31
|
+
steps.push(info);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Add security fields as separate step
|
|
35
|
+
if (security.length > 0) {
|
|
36
|
+
steps.push(security);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return steps;
|
|
25
40
|
}
|
|
26
41
|
|
|
27
42
|
export const SharpDynamicForm: React.FC<Props> = ({
|
|
@@ -13,18 +13,12 @@ registerValidator("email", (value) => {
|
|
|
13
13
|
return "";
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
registerValidator("password", (value, field) => {
|
|
17
|
-
|
|
18
|
-
if (!value) return "Password is required";
|
|
19
|
-
if (value.length < min) return `Password must be at least ${min} characters`;
|
|
20
|
-
if (!/[!@#$%^&*(),.?":{}|<>]/.test(value)) return "Password must contain at least one special character";
|
|
21
|
-
return "";
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
registerValidator("confirmPassword", (value, _, formState) => {
|
|
25
|
-
if (!value) return "Please confirm your password";
|
|
16
|
+
registerValidator("password", (value, field, formState) => {
|
|
17
|
+
if (!value) return "Please enter a password";
|
|
26
18
|
if (value.length < 8) return "Password must be at least 8 characters";
|
|
27
|
-
|
|
19
|
+
if (field.name === "confirmPassword" && value !== formState["password"]) {
|
|
20
|
+
return "Passwords do not match";
|
|
21
|
+
}
|
|
28
22
|
return "";
|
|
29
23
|
});
|
|
30
24
|
|