2025-10-28 22:57:03 +07:00
|
|
|
<script setup lang="ts">
|
2025-11-05 04:14:37 +07:00
|
|
|
import { ref } from 'vue'
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
valid?: boolean
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
|
|
valid: true,
|
|
|
|
|
})
|
2025-10-28 22:57:03 +07:00
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
(e: 'submit', words: string[]): void
|
2025-11-05 04:14:37 +07:00
|
|
|
(e: 'update:words', words: string[]): void
|
|
|
|
|
(e: 'update:valid', valid: boolean): void
|
2025-10-28 22:57:03 +07:00
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const seedWords = ref<string[]>(Array.from({ length: 18 }, () => ''))
|
|
|
|
|
|
|
|
|
|
const inputBoxFocus = (idx: number) => {
|
2025-11-05 04:14:37 +07:00
|
|
|
if (idx < 18) {
|
|
|
|
|
document.getElementById('input-' + idx)?.focus()
|
|
|
|
|
}
|
2025-10-28 22:57:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleGridInput = (index: number, value: string) => {
|
2025-11-05 04:14:37 +07:00
|
|
|
emit('update:valid', true)
|
2025-10-28 22:57:03 +07:00
|
|
|
seedWords.value[index] = value
|
2025-11-07 18:29:58 +07:00
|
|
|
emit(
|
|
|
|
|
'update:words',
|
|
|
|
|
seedWords.value.filter((w) => w.trim())
|
|
|
|
|
)
|
2025-10-28 22:57:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handlePaste = (event: ClipboardEvent) => {
|
|
|
|
|
event.preventDefault()
|
2025-11-05 04:14:37 +07:00
|
|
|
emit('update:valid', true)
|
2025-10-28 22:57:03 +07:00
|
|
|
const pastedData = event.clipboardData?.getData('text') || ''
|
|
|
|
|
const words = pastedData
|
2025-10-29 19:55:44 +07:00
|
|
|
.trim()
|
|
|
|
|
.split(/\s+/)
|
|
|
|
|
.filter((w) => w)
|
2025-10-28 22:57:03 +07:00
|
|
|
|
|
|
|
|
if (words.length === 0) return
|
|
|
|
|
|
2025-11-05 04:14:37 +07:00
|
|
|
const filledWords = Array.from({ length: 18 }, (_, i) => words[i] || '')
|
|
|
|
|
seedWords.value = filledWords
|
2025-11-07 18:29:58 +07:00
|
|
|
emit(
|
|
|
|
|
'update:words',
|
|
|
|
|
words.filter((w) => w.trim())
|
|
|
|
|
)
|
2025-10-28 22:57:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSubmit = () => {
|
2025-10-31 01:22:35 +07:00
|
|
|
const words = seedWords.value.filter((w) => w.trim())
|
|
|
|
|
emit('submit', words)
|
2025-10-28 22:57:03 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
|
handleSubmit,
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-10-31 01:22:35 +07:00
|
|
|
<div class="recover-seed-form">
|
|
|
|
|
<div class="recover-seed-row-radio">
|
2025-10-28 22:57:03 +07:00
|
|
|
<div class="radio active">18 words</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Individual input grid -->
|
2025-10-31 01:22:35 +07:00
|
|
|
<div class="recover-seed-inputs">
|
|
|
|
|
<div class="recover-seed-input-grid">
|
2025-10-28 22:57:03 +07:00
|
|
|
<div v-for="(word, i) in seedWords" :key="i" class="seed-box">
|
|
|
|
|
<input
|
|
|
|
|
:id="'input-' + i"
|
|
|
|
|
type="text"
|
|
|
|
|
inputmode="text"
|
|
|
|
|
autocapitalize="off"
|
|
|
|
|
autocomplete="off"
|
|
|
|
|
spellcheck="false"
|
|
|
|
|
:value="word"
|
|
|
|
|
:placeholder="i + 1 + '.'"
|
|
|
|
|
maxlength="24"
|
|
|
|
|
@keydown.enter="inputBoxFocus(i + 1)"
|
|
|
|
|
@input="handleGridInput(i, ($event.target as HTMLInputElement).value)"
|
2025-10-29 19:55:44 +07:00
|
|
|
@paste="handlePaste($event)"
|
2025-10-28 22:57:03 +07:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-11-05 04:14:37 +07:00
|
|
|
<div v-if="!props.valid" class="error-text">Invalid seed phrase</div>
|
2025-10-28 22:57:03 +07:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-10-31 01:22:35 +07:00
|
|
|
.recover-seed-form {
|
|
|
|
|
.recover-seed-row-radio {
|
2025-10-28 22:57:03 +07:00
|
|
|
display: flex;
|
|
|
|
|
gap: 24px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
.radio {
|
|
|
|
|
background: var(--bg-secondary);
|
|
|
|
|
color: var(--text-secondary);
|
|
|
|
|
border-radius: 14px;
|
|
|
|
|
font-size: 1.08rem;
|
|
|
|
|
padding: 7px 24px 7px 18px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 5px;
|
|
|
|
|
&.active {
|
|
|
|
|
background: var(--primary-color);
|
|
|
|
|
color: var(--text-light);
|
|
|
|
|
}
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-31 01:22:35 +07:00
|
|
|
.recover-seed-inputs {
|
2025-10-28 22:57:03 +07:00
|
|
|
width: 100%;
|
|
|
|
|
}
|
2025-10-31 01:22:35 +07:00
|
|
|
.recover-seed-input-grid {
|
2025-10-28 22:57:03 +07:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(4, 1fr);
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
.seed-box input {
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
border-radius: 9px;
|
|
|
|
|
border: 2px solid var(--border-color);
|
|
|
|
|
background: var(--bg-secondary);
|
|
|
|
|
color: var(--text-secondary);
|
|
|
|
|
outline: none;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
transition:
|
|
|
|
|
border 0.16s,
|
|
|
|
|
box-shadow 0.16s;
|
|
|
|
|
&:focus {
|
|
|
|
|
border-color: var(--primary-color);
|
|
|
|
|
box-shadow: 0 2px 8px var(--shadow-primary);
|
|
|
|
|
}
|
|
|
|
|
&.error {
|
|
|
|
|
border-color: var(--error-color);
|
|
|
|
|
background: var(--bg-secondary);
|
|
|
|
|
color: var(--text-light);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.error-text {
|
|
|
|
|
color: var(--error-color);
|
|
|
|
|
font-size: 0.97em;
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@include screen(mobile) {
|
|
|
|
|
.seed-input-grid {
|
|
|
|
|
gap: 8px;
|
|
|
|
|
grid-template-columns: repeat(3, 1fr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|