UNPKG

4.03 kBTypeScriptView Raw
1import type { FormEncType, HTMLFormMethod, RelativeRoutingType } from "@remix-run/router";
2export declare const defaultMethod: HTMLFormMethod;
3export declare function isHtmlElement(object: any): object is HTMLElement;
4export declare function isButtonElement(object: any): object is HTMLButtonElement;
5export declare function isFormElement(object: any): object is HTMLFormElement;
6export declare function isInputElement(object: any): object is HTMLInputElement;
7type LimitedMouseEvent = Pick<MouseEvent, "button" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">;
8export declare function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string): boolean;
9export type ParamKeyValuePair = [string, string];
10export type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
11/**
12 * Creates a URLSearchParams object using the given initializer.
13 *
14 * This is identical to `new URLSearchParams(init)` except it also
15 * supports arrays as values in the object form of the initializer
16 * instead of just strings. This is convenient when you need multiple
17 * values for a given key, but don't want to use an array initializer.
18 *
19 * For example, instead of:
20 *
21 * let searchParams = new URLSearchParams([
22 * ['sort', 'name'],
23 * ['sort', 'price']
24 * ]);
25 *
26 * you can do:
27 *
28 * let searchParams = createSearchParams({
29 * sort: ['name', 'price']
30 * });
31 */
32export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
33export declare function getSearchParamsForLocation(locationSearch: string, defaultSearchParams: URLSearchParams | null): URLSearchParams;
34type JsonObject = {
35 [Key in string]: JsonValue;
36} & {
37 [Key in string]?: JsonValue | undefined;
38};
39type JsonArray = JsonValue[] | readonly JsonValue[];
40type JsonPrimitive = string | number | boolean | null;
41type JsonValue = JsonPrimitive | JsonObject | JsonArray;
42export type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
43export interface SubmitOptions {
44 /**
45 * The HTTP method used to submit the form. Overrides `<form method>`.
46 * Defaults to "GET".
47 */
48 method?: HTMLFormMethod;
49 /**
50 * The action URL path used to submit the form. Overrides `<form action>`.
51 * Defaults to the path of the current route.
52 */
53 action?: string;
54 /**
55 * The encoding used to submit the form. Overrides `<form encType>`.
56 * Defaults to "application/x-www-form-urlencoded".
57 */
58 encType?: FormEncType;
59 /**
60 * Indicate a specific fetcherKey to use when using navigate=false
61 */
62 fetcherKey?: string;
63 /**
64 * navigate=false will use a fetcher instead of a navigation
65 */
66 navigate?: boolean;
67 /**
68 * Set `true` to replace the current entry in the browser's history stack
69 * instead of creating a new one (i.e. stay on "the same page"). Defaults
70 * to `false`.
71 */
72 replace?: boolean;
73 /**
74 * State object to add to the history stack entry for this navigation
75 */
76 state?: any;
77 /**
78 * Determines whether the form action is relative to the route hierarchy or
79 * the pathname. Use this if you want to opt out of navigating the route
80 * hierarchy and want to instead route based on /-delimited URL segments
81 */
82 relative?: RelativeRoutingType;
83 /**
84 * In browser-based environments, prevent resetting scroll after this
85 * navigation when using the <ScrollRestoration> component
86 */
87 preventScrollReset?: boolean;
88 /**
89 * Enable flushSync for this navigation's state updates
90 */
91 unstable_flushSync?: boolean;
92 /**
93 * Enable view transitions on this submission navigation
94 */
95 unstable_viewTransition?: boolean;
96}
97export declare function getFormSubmissionInfo(target: SubmitTarget, basename: string): {
98 action: string | null;
99 method: string;
100 encType: string;
101 formData: FormData | undefined;
102 body: any;
103};
104export {};