-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9626 from bitfoundation/develop
Version 9.2.1 (#9615)
- Loading branch information
Showing
76 changed files
with
831 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 33 additions & 2 deletions
35
src/BlazorUI/Bit.BlazorUI/Components/Inputs/OtpInput/BitOtpInput.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,46 @@ | ||
namespace BitBlazorUI { | ||
export class OtpInput { | ||
public static setup(dotnetReference: DotNetObject, input: HTMLInputElement) { | ||
private static abortControllers: { [key: string]: AbortController } = {}; | ||
|
||
public static setup(id: string, dotnetObj: DotNetObject, input: HTMLInputElement) { | ||
input.addEventListener('focus', (e: any) => { | ||
e.target?.select(); | ||
}); | ||
|
||
input.addEventListener('paste', async e => { | ||
e.preventDefault(); | ||
let pastedValue = e.clipboardData?.getData('Text'); | ||
await dotnetReference.invokeMethodAsync("SetPastedData", pastedValue); | ||
await dotnetObj.invokeMethodAsync("SetValue", pastedValue); | ||
}); | ||
|
||
OtpInput.setupSmsAutofill(id, dotnetObj); | ||
} | ||
|
||
public static dispose(id: string) { | ||
const ac = OtpInput.abortControllers[id]; | ||
if (!ac) return; | ||
|
||
ac.abort(); | ||
delete OtpInput.abortControllers[id]; | ||
} | ||
|
||
private static setupSmsAutofill(id: string, dotnetObj: DotNetObject) { | ||
if (!('OTPCredential' in window)) return; | ||
|
||
const abortCtrl = new AbortController(); | ||
OtpInput.abortControllers[id] = abortCtrl; | ||
|
||
navigator.credentials.get({ | ||
otp: { transport: ['sms'] }, | ||
signal: abortCtrl.signal | ||
} as any).then(async (otp: any) => { | ||
await dotnetObj.invokeMethodAsync("SetValue", otp.code); | ||
abortCtrl.abort(); | ||
delete OtpInput.abortControllers[id]; | ||
}).catch(async (err: any) => { | ||
abortCtrl.abort(); | ||
delete OtpInput.abortControllers[id]; | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.