-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,239 additions
and
1,626 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<ol class="list-disc list-inside"> | ||
<slot /> | ||
</ol> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
export function useCodeInput(code: string[]) { | ||
let dataFromPaste: string[] | undefined; | ||
|
||
const keysAllowed: string[] = [ | ||
"0", | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5", | ||
"6", | ||
"7", | ||
"8", | ||
"9", | ||
]; | ||
|
||
function isNumber(event: Event) { | ||
(event.currentTarget as HTMLInputElement).value = ""; | ||
const keyPressed: string = (event as KeyboardEvent).key; | ||
if (!keysAllowed.includes(keyPressed)) { | ||
event.preventDefault(); | ||
} | ||
} | ||
function handleInput(event: Event) { | ||
const inputType = (event as InputEvent).inputType; | ||
let currentActiveElement = event.target as HTMLInputElement; | ||
|
||
if (inputType === "insertText") | ||
(currentActiveElement.nextElementSibling as HTMLElement)?.focus(); | ||
|
||
if (inputType === "insertFromPaste" && dataFromPaste) { | ||
for (const num of dataFromPaste) { | ||
const id: number = parseInt(currentActiveElement.id.split("_")[1]); | ||
currentActiveElement.value = num; | ||
code[id] = num; | ||
if (currentActiveElement.nextElementSibling) { | ||
currentActiveElement = | ||
currentActiveElement.nextElementSibling as HTMLInputElement; | ||
(currentActiveElement.nextElementSibling as HTMLElement)?.focus(); | ||
} | ||
} | ||
} | ||
} | ||
function handleDelete(event: Event) { | ||
// keydown event = move to previous element then only delete number | ||
|
||
const value = (event.target as HTMLInputElement).value; | ||
const currentActiveElement = event.target as HTMLInputElement; | ||
if (!value) | ||
(currentActiveElement.previousElementSibling as HTMLElement)?.focus(); | ||
} | ||
|
||
function onPaste(event: Event) { | ||
dataFromPaste = (event as ClipboardEvent).clipboardData | ||
?.getData("text") | ||
.trim() | ||
.split(""); | ||
|
||
if (dataFromPaste) { | ||
for (const num of dataFromPaste) { | ||
if (!keysAllowed.includes(num)) event.preventDefault(); | ||
} | ||
} | ||
} | ||
|
||
return { isNumber, handleInput, handleDelete, onPaste }; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { appendResponseHeader, H3Event } from "h3"; | ||
|
||
export const useCookieFetch = async (event: H3Event, url: string) => { | ||
const res = await $fetch.raw(url); | ||
const cookies = (res.headers.get("set-cookie") || "").split(","); | ||
for (const cookie of cookies) { | ||
appendResponseHeader(event, "set-cookie", cookie); | ||
} | ||
return res._data; | ||
}; |
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
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.