Format with prettier. Use screen mode for invitation import - dialog mode is broken.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useBlockableInput } from '../../../hooks/useInputLayer.js';
|
||||
import type { ActionWizardState } from './useActionWizard.js';
|
||||
import { useBlockableInput } from "../../../hooks/useInputLayer.js";
|
||||
import type { ActionWizardState } from "./useActionWizard.js";
|
||||
|
||||
/**
|
||||
* Keyboard input handler for the action wizard.
|
||||
@@ -18,30 +18,34 @@ export function useWizardKeyboard(wizard: ActionWizardState): void {
|
||||
}
|
||||
|
||||
// ── Content-area: step-specific input handling ────────
|
||||
if (wizard.focusArea === 'content') {
|
||||
if (wizard.currentStepData?.type === 'role-select') {
|
||||
if (wizard.focusArea === "content") {
|
||||
if (wizard.currentStepData?.type === "role-select") {
|
||||
handleRoleSelectInput(wizard, input, key);
|
||||
return;
|
||||
}
|
||||
if (wizard.currentStepData?.type === 'inputs') {
|
||||
if (wizard.currentStepData?.type === "inputs") {
|
||||
handleInputsStepInput(wizard, input, key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Button bar navigation + activation ────────────────
|
||||
if (wizard.focusArea === 'buttons') {
|
||||
if (wizard.focusArea === "buttons") {
|
||||
handleButtonBarInput(wizard, key);
|
||||
}
|
||||
|
||||
// ── Global shortcuts ──────────────────────────────────
|
||||
if (input === 'c' && wizard.currentStepData?.type === 'publish' && wizard.invitationId) {
|
||||
if (
|
||||
input === "c" &&
|
||||
wizard.currentStepData?.type === "publish" &&
|
||||
wizard.invitationId
|
||||
) {
|
||||
wizard.copyId();
|
||||
}
|
||||
if (input === 'a' && wizard.currentStepData?.type === 'inputs') {
|
||||
if (input === "a" && wizard.currentStepData?.type === "inputs") {
|
||||
wizard.selectAll();
|
||||
}
|
||||
if (input === 'n' && wizard.currentStepData?.type === 'inputs') {
|
||||
if (input === "n" && wizard.currentStepData?.type === "inputs") {
|
||||
wizard.deselectAll();
|
||||
}
|
||||
},
|
||||
@@ -52,10 +56,10 @@ export function useWizardKeyboard(wizard: ActionWizardState): void {
|
||||
// ── Tab cycling ─────────────────────────────────────────────────
|
||||
|
||||
function handleTab(wizard: ActionWizardState): void {
|
||||
if (wizard.focusArea === 'content') {
|
||||
if (wizard.focusArea === "content") {
|
||||
// Within role-select, tab through roles before moving to buttons
|
||||
if (
|
||||
wizard.currentStepData?.type === 'role-select' &&
|
||||
wizard.currentStepData?.type === "role-select" &&
|
||||
wizard.availableRoles.length > 0 &&
|
||||
wizard.selectedRoleIndex < wizard.availableRoles.length - 1
|
||||
) {
|
||||
@@ -65,7 +69,7 @@ function handleTab(wizard: ActionWizardState): void {
|
||||
|
||||
// Within inputs, tab through UTXOs before moving to buttons
|
||||
if (
|
||||
wizard.currentStepData?.type === 'inputs' &&
|
||||
wizard.currentStepData?.type === "inputs" &&
|
||||
wizard.availableUtxos.length > 0 &&
|
||||
wizard.selectedUtxoIndex < wizard.availableUtxos.length - 1
|
||||
) {
|
||||
@@ -74,16 +78,16 @@ function handleTab(wizard: ActionWizardState): void {
|
||||
}
|
||||
|
||||
// Move to button bar
|
||||
wizard.setFocusArea('buttons');
|
||||
wizard.setFocusedButton('next');
|
||||
wizard.setFocusArea("buttons");
|
||||
wizard.setFocusedButton("next");
|
||||
} else {
|
||||
// Cycle through buttons, then wrap back to content
|
||||
if (wizard.focusedButton === 'back') {
|
||||
wizard.setFocusedButton('cancel');
|
||||
} else if (wizard.focusedButton === 'cancel') {
|
||||
wizard.setFocusedButton('next');
|
||||
if (wizard.focusedButton === "back") {
|
||||
wizard.setFocusedButton("cancel");
|
||||
} else if (wizard.focusedButton === "cancel") {
|
||||
wizard.setFocusedButton("next");
|
||||
} else {
|
||||
wizard.setFocusArea('content');
|
||||
wizard.setFocusArea("content");
|
||||
wizard.setFocusedInput(0);
|
||||
wizard.setSelectedUtxoIndex(0);
|
||||
wizard.setSelectedRoleIndex(0);
|
||||
@@ -120,7 +124,7 @@ function handleInputsStepInput(
|
||||
wizard.setSelectedUtxoIndex((p) =>
|
||||
Math.min(wizard.availableUtxos.length - 1, p + 1),
|
||||
);
|
||||
} else if (key.return || input === ' ') {
|
||||
} else if (key.return || input === " ") {
|
||||
wizard.toggleUtxoSelection(wizard.selectedUtxoIndex);
|
||||
}
|
||||
}
|
||||
@@ -133,17 +137,17 @@ function handleButtonBarInput(
|
||||
): void {
|
||||
if (key.leftArrow) {
|
||||
wizard.setFocusedButton((p) =>
|
||||
p === 'next' ? 'cancel' : p === 'cancel' ? 'back' : 'back',
|
||||
p === "next" ? "cancel" : p === "cancel" ? "back" : "back",
|
||||
);
|
||||
} else if (key.rightArrow) {
|
||||
wizard.setFocusedButton((p) =>
|
||||
p === 'back' ? 'cancel' : p === 'cancel' ? 'next' : 'next',
|
||||
p === "back" ? "cancel" : p === "cancel" ? "next" : "next",
|
||||
);
|
||||
}
|
||||
|
||||
if (key.return) {
|
||||
if (wizard.focusedButton === 'back') wizard.previousStep();
|
||||
else if (wizard.focusedButton === 'cancel') wizard.cancel();
|
||||
else if (wizard.focusedButton === 'next') wizard.nextStep();
|
||||
if (wizard.focusedButton === "back") wizard.previousStep();
|
||||
else if (wizard.focusedButton === "cancel") wizard.cancel();
|
||||
else if (wizard.focusedButton === "next") wizard.nextStep();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user