Files
SnowLuma/.pnpm-store/v11/files/65/119525341458f52229f6590d929f4f19441286e3105b0122b30b3e757975fdb7169ab8387ecf322f03dcd4badf171594aa302987e8f8eb77012ee453306d71
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

39 lines
1.3 KiB
Plaintext

import { Context } from "../../context.js";
//#region src/jsx/dom/hooks/index.d.ts
type FormStatus = {
pending: false;
data: null;
method: null;
action: null;
} | {
pending: true;
data: FormData;
method: 'get' | 'post';
action: string | ((formData: FormData) => void | Promise<void>);
};
export declare const FormContext: Context<FormStatus>;
export declare const registerAction: (action: Promise<unknown>) => void;
/**
* This hook returns the current form status
* @returns FormStatus
*/
export declare const useFormStatus: () => FormStatus;
/**
* This hook returns the current state and a function to update the state optimistically
* The current state is updated optimistically and then reverted to the original state when all actions are resolved
* @param state
* @param updateState
* @returns [T, (action: N) => void]
*/
export declare const useOptimistic: <T, N>(state: T, updateState: (currentState: T, action: N) => T) => [T, (action: N) => void];
/**
* This hook returns the current state and a function to update the state by form action
* @param fn
* @param initialState
* @param permalink
* @returns [T, (data: FormData) => void]
*/
export declare const useActionState: <T>(fn: Function, initialState: T, permalink?: string) => [T, Function];
//#endregion
export {};