| 1 |
|
| 2 | import { FormEncType, HTMLFormMethod } from "../router/utils.js";
|
| 3 | import { RelativeRoutingType } from "../router/router.js";
|
| 4 |
|
| 5 | //#region lib/dom/dom.d.ts
|
| 6 | type ParamKeyValuePair = [string, string];
|
| 7 | type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
| 8 | /**
|
| 9 | Creates a URLSearchParams object using the given initializer.
|
| 10 |
|
| 11 | This is identical to `new URLSearchParams(init)` except it also
|
| 12 | supports arrays as values in the object form of the initializer
|
| 13 | instead of just strings. This is convenient when you need multiple
|
| 14 | values for a given key, but don't want to use an array initializer.
|
| 15 |
|
| 16 | For example, instead of:
|
| 17 |
|
| 18 | ```tsx
|
| 19 | let searchParams = new URLSearchParams([
|
| 20 | ['sort', 'name'],
|
| 21 | ['sort', 'price']
|
| 22 | ]);
|
| 23 | ```
|
| 24 | you can do:
|
| 25 |
|
| 26 | ```
|
| 27 | let searchParams = createSearchParams({
|
| 28 | sort: ['name', 'price']
|
| 29 | });
|
| 30 | ```
|
| 31 |
|
| 32 | @category Utils
|
| 33 | */
|
| 34 | declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
|
| 35 | type JsonObject = { [Key in string]: JsonValue } & { [Key in string]?: JsonValue | undefined };
|
| 36 | type JsonArray = JsonValue[] | readonly JsonValue[];
|
| 37 | type JsonPrimitive = string | number | boolean | null;
|
| 38 | type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
| 39 | type SubmitTarget = HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | JsonValue | null;
|
| 40 | /**
|
| 41 | * Submit options shared by both navigations and fetchers
|
| 42 | */
|
| 43 | interface SharedSubmitOptions {
|
| 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 | * Determines whether the form action is relative to the route hierarchy or
|
| 61 | * the pathname. Use this if you want to opt out of navigating the route
|
| 62 | * hierarchy and want to instead route based on /-delimited URL segments
|
| 63 | */
|
| 64 | relative?: RelativeRoutingType;
|
| 65 | /**
|
| 66 | * In browser-based environments, prevent resetting scroll after this
|
| 67 | * navigation when using the <ScrollRestoration> component
|
| 68 | */
|
| 69 | preventScrollReset?: boolean;
|
| 70 | /**
|
| 71 | * Enable flushSync for this submission's state updates
|
| 72 | */
|
| 73 | flushSync?: boolean;
|
| 74 | /**
|
| 75 | * Specify the default revalidation behavior after this submission
|
| 76 | *
|
| 77 | * If no `shouldRevalidate` functions are present on the active routes, then this
|
| 78 | * value will be used directly. Otherwise it will be passed into `shouldRevalidate`
|
| 79 | * so the route can make the final determination on revalidation. This can be
|
| 80 | * useful when updating search params and you don't want to trigger a revalidation.
|
| 81 | *
|
| 82 | * By default (when not specified), loaders will revalidate according to the routers
|
| 83 | * standard revalidation behavior.
|
| 84 | */
|
| 85 | defaultShouldRevalidate?: boolean;
|
| 86 | }
|
| 87 | /**
|
| 88 | * Submit options available to fetchers
|
| 89 | */
|
| 90 | interface FetcherSubmitOptions extends SharedSubmitOptions {}
|
| 91 | /**
|
| 92 | * Submit options available to navigations
|
| 93 | */
|
| 94 | interface SubmitOptions extends FetcherSubmitOptions {
|
| 95 | /**
|
| 96 | * Set `true` to replace the current entry in the browser's history stack
|
| 97 | * instead of creating a new one (i.e. stay on "the same page"). Defaults
|
| 98 | * to `false`.
|
| 99 | */
|
| 100 | replace?: boolean;
|
| 101 | /**
|
| 102 | * State object to add to the history stack entry for this navigation
|
| 103 | */
|
| 104 | state?: any;
|
| 105 | /**
|
| 106 | * Indicate a specific fetcherKey to use when using navigate=false
|
| 107 | */
|
| 108 | fetcherKey?: string;
|
| 109 | /**
|
| 110 | * navigate=false will use a fetcher instead of a navigation
|
| 111 | */
|
| 112 | navigate?: boolean;
|
| 113 | /**
|
| 114 | * Enable view transitions on this submission navigation
|
| 115 | */
|
| 116 | viewTransition?: boolean;
|
| 117 | }
|
| 118 | //#endregion
|
| 119 | export { FetcherSubmitOptions, ParamKeyValuePair, SubmitOptions, SubmitTarget, URLSearchParamsInit, createSearchParams }; |
| \ | No newline at end of file |