dom.d.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import type { FormEncType, FormMethod } from "@remix-run/router";
  2. import type { RelativeRoutingType } from "react-router";
  3. export declare const defaultMethod = "get";
  4. export declare function isHtmlElement(object: any): object is HTMLElement;
  5. export declare function isButtonElement(object: any): object is HTMLButtonElement;
  6. export declare function isFormElement(object: any): object is HTMLFormElement;
  7. export declare function isInputElement(object: any): object is HTMLInputElement;
  8. declare type LimitedMouseEvent = Pick<MouseEvent, "button" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">;
  9. export declare function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string): boolean;
  10. export declare type ParamKeyValuePair = [string, string];
  11. export declare type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
  12. /**
  13. * Creates a URLSearchParams object using the given initializer.
  14. *
  15. * This is identical to `new URLSearchParams(init)` except it also
  16. * supports arrays as values in the object form of the initializer
  17. * instead of just strings. This is convenient when you need multiple
  18. * values for a given key, but don't want to use an array initializer.
  19. *
  20. * For example, instead of:
  21. *
  22. * let searchParams = new URLSearchParams([
  23. * ['sort', 'name'],
  24. * ['sort', 'price']
  25. * ]);
  26. *
  27. * you can do:
  28. *
  29. * let searchParams = createSearchParams({
  30. * sort: ['name', 'price']
  31. * });
  32. */
  33. export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
  34. export declare function getSearchParamsForLocation(locationSearch: string, defaultSearchParams: URLSearchParams | null): URLSearchParams;
  35. export interface SubmitOptions {
  36. /**
  37. * The HTTP method used to submit the form. Overrides `<form method>`.
  38. * Defaults to "GET".
  39. */
  40. method?: FormMethod;
  41. /**
  42. * The action URL path used to submit the form. Overrides `<form action>`.
  43. * Defaults to the path of the current route.
  44. *
  45. * Note: It is assumed the path is already resolved. If you need to resolve a
  46. * relative path, use `useFormAction`.
  47. */
  48. action?: string;
  49. /**
  50. * The action URL used to submit the form. Overrides `<form encType>`.
  51. * Defaults to "application/x-www-form-urlencoded".
  52. */
  53. encType?: FormEncType;
  54. /**
  55. * Set `true` to replace the current entry in the browser's history stack
  56. * instead of creating a new one (i.e. stay on "the same page"). Defaults
  57. * to `false`.
  58. */
  59. replace?: boolean;
  60. /**
  61. * Determines whether the form action is relative to the route hierarchy or
  62. * the pathname. Use this if you want to opt out of navigating the route
  63. * hierarchy and want to instead route based on /-delimited URL segments
  64. */
  65. relative?: RelativeRoutingType;
  66. /**
  67. * In browser-based environments, prevent resetting scroll after this
  68. * navigation when using the <ScrollRestoration> component
  69. */
  70. preventScrollReset?: boolean;
  71. }
  72. export declare function getFormSubmissionInfo(target: HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | {
  73. [name: string]: string;
  74. } | null, defaultAction: string, options: SubmitOptions): {
  75. url: URL;
  76. method: string;
  77. encType: string;
  78. formData: FormData;
  79. };
  80. export {};