@dloizides/auth-web 1.18.1 → 1.18.3
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/CHANGELOG.md +17 -0
- package/dist/index.js +36 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.18.3
|
|
4
|
+
|
|
5
|
+
- `useLoginSubmit` has an in-flight ref guard, like `useRegisterForm`. A focused field stays read-only (not
|
|
6
|
+
disabled) during a pending login and RN-web still fires `onSubmitEditing` there, so a second Enter sent a
|
|
7
|
+
second `/bff/login`. jsdom tests now cover a pending submit + a second non-repeat Enter for both forms,
|
|
8
|
+
a valid register submitted by Enter, and an IME-composition Enter not submitting.
|
|
9
|
+
|
|
10
|
+
## 1.18.2
|
|
11
|
+
|
|
12
|
+
**Enter in a text field submits `<RegisterForm>` and `<LoginForm>`.**
|
|
13
|
+
|
|
14
|
+
- Every visible input now has `onSubmitEditing` wired to the same guarded submit as the button, plus
|
|
15
|
+
`returnKeyType="go"`. RN-web renders no `<form>`, so Enter in a field never submitted in any prior
|
|
16
|
+
version (no `onSubmitEditing` anywhere in auth-web history); only a focused button did.
|
|
17
|
+
- An OS key-repeat of a held Enter in a field is ignored (`useSubmitOnEnter`), so a held Enter is still
|
|
18
|
+
one attempt / one login. jsdom tests cover Enter in each of the seven register fields and both login fields.
|
|
19
|
+
|
|
3
20
|
## 1.18.1
|
|
4
21
|
|
|
5
22
|
**Review fixes for the 1.18.0 registration extraction.**
|
package/dist/index.js
CHANGED
|
@@ -618,7 +618,11 @@ function useLoginSubmit({
|
|
|
618
618
|
invalidCredentialsLabel
|
|
619
619
|
}) {
|
|
620
620
|
const [errorText, setErrorText] = react.useState(null);
|
|
621
|
+
const inFlight = react.useRef(false);
|
|
621
622
|
const runLogin = react.useCallback(async () => {
|
|
623
|
+
if (inFlight.current) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
622
626
|
setErrorText(null);
|
|
623
627
|
const trimmedUsername = username.trim();
|
|
624
628
|
const hasMissingField = trimmedUsername.length === 0 || password.length === 0;
|
|
@@ -626,11 +630,14 @@ function useLoginSubmit({
|
|
|
626
630
|
setErrorText(missingFieldsLabel);
|
|
627
631
|
return;
|
|
628
632
|
}
|
|
633
|
+
inFlight.current = true;
|
|
629
634
|
try {
|
|
630
635
|
const user = await login({ username: trimmedUsername, password });
|
|
631
636
|
onSuccess(user);
|
|
632
637
|
} catch {
|
|
633
638
|
setErrorText(invalidCredentialsLabel);
|
|
639
|
+
} finally {
|
|
640
|
+
inFlight.current = false;
|
|
634
641
|
}
|
|
635
642
|
}, [username, password, login, onSuccess, missingFieldsLabel, invalidCredentialsLabel]);
|
|
636
643
|
const handleSubmit = react.useCallback(() => {
|
|
@@ -638,6 +645,21 @@ function useLoginSubmit({
|
|
|
638
645
|
}, [runLogin]);
|
|
639
646
|
return { errorText, handleSubmit };
|
|
640
647
|
}
|
|
648
|
+
function isKeyRepeat(event) {
|
|
649
|
+
const native = event?.nativeEvent;
|
|
650
|
+
return native?.repeat === true;
|
|
651
|
+
}
|
|
652
|
+
function useSubmitOnEnter(submit) {
|
|
653
|
+
return react.useCallback(
|
|
654
|
+
(event) => {
|
|
655
|
+
if (isKeyRepeat(event)) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
submit();
|
|
659
|
+
},
|
|
660
|
+
[submit]
|
|
661
|
+
);
|
|
662
|
+
}
|
|
641
663
|
var BffAuthStatus = /* @__PURE__ */ ((BffAuthStatus2) => {
|
|
642
664
|
BffAuthStatus2["Loading"] = "loading";
|
|
643
665
|
BffAuthStatus2["Authenticated"] = "authenticated";
|
|
@@ -776,6 +798,7 @@ function LoginForm({
|
|
|
776
798
|
missingFieldsLabel: labels.missingFields,
|
|
777
799
|
invalidCredentialsLabel: labels.invalidCredentials
|
|
778
800
|
});
|
|
801
|
+
const handleSubmitEditing = useSubmitOnEnter(handleSubmit);
|
|
779
802
|
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
780
803
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.title, children: labels.title }),
|
|
781
804
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.subtitle, children: labels.subtitle }),
|
|
@@ -791,10 +814,12 @@ function LoginForm({
|
|
|
791
814
|
editable: !isSubmitting,
|
|
792
815
|
placeholder: labels.usernamePlaceholder,
|
|
793
816
|
placeholderTextColor: theme.colors.textSecondary,
|
|
817
|
+
returnKeyType: "go",
|
|
794
818
|
style: styles3.input,
|
|
795
819
|
testID: withTestIdPrefix(AuthTestIds.loginUsernameInput, testIdPrefix),
|
|
796
820
|
value: username,
|
|
797
|
-
onChangeText: setUsername
|
|
821
|
+
onChangeText: setUsername,
|
|
822
|
+
onSubmitEditing: handleSubmitEditing
|
|
798
823
|
}
|
|
799
824
|
)
|
|
800
825
|
] }),
|
|
@@ -811,10 +836,12 @@ function LoginForm({
|
|
|
811
836
|
editable: !isSubmitting,
|
|
812
837
|
placeholder: labels.passwordPlaceholder,
|
|
813
838
|
placeholderTextColor: theme.colors.textSecondary,
|
|
839
|
+
returnKeyType: "go",
|
|
814
840
|
style: styles3.input,
|
|
815
841
|
testID: withTestIdPrefix(AuthTestIds.loginPasswordInput, testIdPrefix),
|
|
816
842
|
value: password,
|
|
817
|
-
onChangeText: setPassword
|
|
843
|
+
onChangeText: setPassword,
|
|
844
|
+
onSubmitEditing: handleSubmitEditing
|
|
818
845
|
}
|
|
819
846
|
)
|
|
820
847
|
] }),
|
|
@@ -4094,6 +4121,7 @@ function RegisterFormFields({
|
|
|
4094
4121
|
theme,
|
|
4095
4122
|
styles: styles3,
|
|
4096
4123
|
onChange,
|
|
4124
|
+
onSubmitEditing,
|
|
4097
4125
|
testIdPrefix
|
|
4098
4126
|
}) {
|
|
4099
4127
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -4113,11 +4141,13 @@ function RegisterFormFields({
|
|
|
4113
4141
|
keyboardType: config.keyboardType ?? "default",
|
|
4114
4142
|
placeholder: copy.placeholder,
|
|
4115
4143
|
placeholderTextColor: theme.colors.textSecondary,
|
|
4144
|
+
returnKeyType: "go",
|
|
4116
4145
|
secureTextEntry: config.secure === true,
|
|
4117
4146
|
style: styles3.input,
|
|
4118
4147
|
testID: withTestIdPrefix(config.testId, testIdPrefix),
|
|
4119
4148
|
value: values[config.key],
|
|
4120
|
-
onChangeText: (text) => onChange(config.key, text)
|
|
4149
|
+
onChangeText: (text) => onChange(config.key, text),
|
|
4150
|
+
onSubmitEditing
|
|
4121
4151
|
}
|
|
4122
4152
|
)
|
|
4123
4153
|
] }, config.key);
|
|
@@ -4342,6 +4372,7 @@ function RegisterForm({
|
|
|
4342
4372
|
const handlePress = react.useCallback(async () => {
|
|
4343
4373
|
routeRegisterOutcome(await submit(), { onSuccess, onError });
|
|
4344
4374
|
}, [onError, onSuccess, submit]);
|
|
4375
|
+
const handleSubmitEditing = useSubmitOnEnter(handlePress);
|
|
4345
4376
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.screen, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.card, testID: withTestIdPrefix(RegisterTestIds.form, testIdPrefix), children: [
|
|
4346
4377
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.title, children: labels.title }),
|
|
4347
4378
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.subtitle, children: labels.subtitle }),
|
|
@@ -4354,7 +4385,8 @@ function RegisterForm({
|
|
|
4354
4385
|
testIdPrefix,
|
|
4355
4386
|
theme,
|
|
4356
4387
|
values: state,
|
|
4357
|
-
onChange: setField
|
|
4388
|
+
onChange: setField,
|
|
4389
|
+
onSubmitEditing: handleSubmitEditing
|
|
4358
4390
|
}
|
|
4359
4391
|
),
|
|
4360
4392
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.fieldGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
|