@inertiajs/core 2.0.16 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiajs/core",
3
- "version": "2.0.16",
3
+ "version": "2.1.0",
4
4
  "license": "MIT",
5
5
  "description": "A framework for creating server-driven single page apps.",
6
6
  "contributors": [
@@ -0,0 +1,5 @@
1
+ import { FormDataConvertible } from './types';
2
+ /**
3
+ * Convert a FormData instance into an object structure.
4
+ */
5
+ export declare function formDataToObject(source: FormData): Record<string, FormDataConvertible>;
package/types/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { Router } from './router';
2
+ export { objectToFormData } from './formData';
3
+ export { formDataToObject } from './formObject';
2
4
  export { default as createHeadManager } from './head';
3
5
  export { hide as hideProgress, reveal as revealProgress, default as setupProgress } from './progress';
4
6
  export { default as shouldIntercept } from './shouldIntercept';
package/types/types.d.ts CHANGED
@@ -263,6 +263,34 @@ export type ProgressSettings = {
263
263
  includeCSS: boolean;
264
264
  color: string;
265
265
  };
266
+ export type FormComponentOptions = Pick<VisitOptions, 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'replace' | 'only' | 'except' | 'reset'>;
267
+ export type FormComponentProps = Partial<Pick<Visit, 'method' | 'headers' | 'queryStringArrayFormat' | 'errorBag' | 'showProgress'> & Omit<VisitCallbacks, 'onPrefetched' | 'onPrefetching'>> & {
268
+ action?: string | {
269
+ url: string;
270
+ method: Method;
271
+ };
272
+ transform?: (data: Record<string, FormDataConvertible>) => Record<string, FormDataConvertible>;
273
+ options?: FormComponentOptions;
274
+ };
275
+ export type FormComponentMethods = {
276
+ clearErrors: (...fields: string[]) => void;
277
+ resetAndClearErrors: (...fields: string[]) => void;
278
+ setError(field: string, value: string): void;
279
+ setError(errors: Record<string, string>): void;
280
+ reset: () => void;
281
+ submit: () => void;
282
+ };
283
+ export type FormComponentState = {
284
+ errors: Record<string, string>;
285
+ hasErrors: boolean;
286
+ processing: boolean;
287
+ progress: Progress | null;
288
+ wasSuccessful: boolean;
289
+ recentlySuccessful: boolean;
290
+ isDirty: boolean;
291
+ };
292
+ export type FormComponentSlotProps = FormComponentMethods & FormComponentState;
293
+ export type FormComponentRef = FormComponentSlotProps;
266
294
  declare global {
267
295
  interface DocumentEventMap {
268
296
  'inertia:before': GlobalEvent<'before'>;