@page-speed/forms 0.4.4 → 0.4.6

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.
@@ -275,6 +275,34 @@ interface UseFieldReturn<T = any> {
275
275
  setError: (error: string | undefined) => void;
276
276
  };
277
277
  }
278
+ type FormSubmissionBehavior = "showConfirmation" | "redirect" | "renderCustomComponent";
279
+ interface NewFormSubmissionActionConfig {
280
+ /**
281
+ * Whether to render the "new submission" action.
282
+ * If omitted, defaults to true when `label` is provided.
283
+ */
284
+ enable?: boolean;
285
+ /**
286
+ * Optional custom button label.
287
+ */
288
+ label?: string;
289
+ }
290
+ interface FormSubmissionConfig {
291
+ /**
292
+ * Post-submit UI behavior.
293
+ * @default "showConfirmation"
294
+ */
295
+ behavior?: FormSubmissionBehavior;
296
+ /**
297
+ * Optional custom component rendered after successful submission when
298
+ * behavior is "renderCustomComponent".
299
+ */
300
+ customComponent?: ReactNode;
301
+ /**
302
+ * Optional configuration for allowing a fresh submission in the same session.
303
+ */
304
+ newFormSubmissionAction?: NewFormSubmissionActionConfig;
305
+ }
278
306
  /**
279
307
  * Form component props
280
308
  */
@@ -304,6 +332,30 @@ interface FormProps<T extends FormValues = FormValues> {
304
332
  * @default true
305
333
  */
306
334
  noValidate?: boolean;
335
+ /**
336
+ * Optional submission behavior configuration.
337
+ */
338
+ submissionConfig?: FormSubmissionConfig;
339
+ /**
340
+ * Optional success message shown after successful submission.
341
+ */
342
+ successMessage?: ReactNode;
343
+ /**
344
+ * Optional submission error shown below the form actions.
345
+ */
346
+ submissionError?: ReactNode;
347
+ /**
348
+ * Additional className for success feedback.
349
+ */
350
+ successMessageClassName?: string;
351
+ /**
352
+ * Additional className for error feedback.
353
+ */
354
+ errorMessageClassName?: string;
355
+ /**
356
+ * Optional callback invoked when the user starts a new submission.
357
+ */
358
+ onNewSubmission?: () => void;
307
359
  }
308
360
  /**
309
361
  * Field component props
@@ -400,4 +452,4 @@ interface InputProps<T = string> {
400
452
  "aria-required"?: boolean;
401
453
  }
402
454
 
403
- export type { ErrorHandler as E, FieldValidator as F, InputProps as I, SubmissionStatus as S, TouchedFields as T, UseFormOptions as U, ValidationSchema as V, ValidationMode as a, FormValues as b, UseFormReturn as c, UseFieldOptions as d, UseFieldReturn as e, FormProps as f, FieldProps as g, FormErrors as h, FormHelpers as i, SubmitHandler as j, FormState as k, FormActions as l, FieldInputProps as m, FieldMeta as n };
455
+ export type { ErrorHandler as E, FieldValidator as F, InputProps as I, NewFormSubmissionActionConfig as N, SubmissionStatus as S, TouchedFields as T, UseFormOptions as U, ValidationSchema as V, ValidationMode as a, FormValues as b, UseFormReturn as c, UseFieldOptions as d, UseFieldReturn as e, FormProps as f, FieldProps as g, FormErrors as h, FormSubmissionBehavior as i, FormSubmissionConfig as j, FormHelpers as k, SubmitHandler as l, FormState as m, FormActions as n, FieldInputProps as o, FieldMeta as p };
@@ -275,6 +275,34 @@ interface UseFieldReturn<T = any> {
275
275
  setError: (error: string | undefined) => void;
276
276
  };
277
277
  }
278
+ type FormSubmissionBehavior = "showConfirmation" | "redirect" | "renderCustomComponent";
279
+ interface NewFormSubmissionActionConfig {
280
+ /**
281
+ * Whether to render the "new submission" action.
282
+ * If omitted, defaults to true when `label` is provided.
283
+ */
284
+ enable?: boolean;
285
+ /**
286
+ * Optional custom button label.
287
+ */
288
+ label?: string;
289
+ }
290
+ interface FormSubmissionConfig {
291
+ /**
292
+ * Post-submit UI behavior.
293
+ * @default "showConfirmation"
294
+ */
295
+ behavior?: FormSubmissionBehavior;
296
+ /**
297
+ * Optional custom component rendered after successful submission when
298
+ * behavior is "renderCustomComponent".
299
+ */
300
+ customComponent?: ReactNode;
301
+ /**
302
+ * Optional configuration for allowing a fresh submission in the same session.
303
+ */
304
+ newFormSubmissionAction?: NewFormSubmissionActionConfig;
305
+ }
278
306
  /**
279
307
  * Form component props
280
308
  */
@@ -304,6 +332,30 @@ interface FormProps<T extends FormValues = FormValues> {
304
332
  * @default true
305
333
  */
306
334
  noValidate?: boolean;
335
+ /**
336
+ * Optional submission behavior configuration.
337
+ */
338
+ submissionConfig?: FormSubmissionConfig;
339
+ /**
340
+ * Optional success message shown after successful submission.
341
+ */
342
+ successMessage?: ReactNode;
343
+ /**
344
+ * Optional submission error shown below the form actions.
345
+ */
346
+ submissionError?: ReactNode;
347
+ /**
348
+ * Additional className for success feedback.
349
+ */
350
+ successMessageClassName?: string;
351
+ /**
352
+ * Additional className for error feedback.
353
+ */
354
+ errorMessageClassName?: string;
355
+ /**
356
+ * Optional callback invoked when the user starts a new submission.
357
+ */
358
+ onNewSubmission?: () => void;
307
359
  }
308
360
  /**
309
361
  * Field component props
@@ -400,4 +452,4 @@ interface InputProps<T = string> {
400
452
  "aria-required"?: boolean;
401
453
  }
402
454
 
403
- export type { ErrorHandler as E, FieldValidator as F, InputProps as I, SubmissionStatus as S, TouchedFields as T, UseFormOptions as U, ValidationSchema as V, ValidationMode as a, FormValues as b, UseFormReturn as c, UseFieldOptions as d, UseFieldReturn as e, FormProps as f, FieldProps as g, FormErrors as h, FormHelpers as i, SubmitHandler as j, FormState as k, FormActions as l, FieldInputProps as m, FieldMeta as n };
455
+ export type { ErrorHandler as E, FieldValidator as F, InputProps as I, NewFormSubmissionActionConfig as N, SubmissionStatus as S, TouchedFields as T, UseFormOptions as U, ValidationSchema as V, ValidationMode as a, FormValues as b, UseFormReturn as c, UseFieldOptions as d, UseFieldReturn as e, FormProps as f, FieldProps as g, FormErrors as h, FormSubmissionBehavior as i, FormSubmissionConfig as j, FormHelpers as k, SubmitHandler as l, FormState as m, FormActions as n, FieldInputProps as o, FieldMeta as p };
@@ -1,4 +1,4 @@
1
- import { F as FieldValidator } from './types-BBif0kuP.cjs';
1
+ import { F as FieldValidator } from './types-4ppM117e.cjs';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FieldValidator } from './types-BBif0kuP.js';
1
+ import { F as FieldValidator } from './types-4ppM117e.js';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FieldValidator, b as FormValues } from './types-BBif0kuP.cjs';
1
+ import { F as FieldValidator, b as FormValues } from './types-4ppM117e.cjs';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FieldValidator, b as FormValues } from './types-BBif0kuP.js';
1
+ import { F as FieldValidator, b as FormValues } from './types-4ppM117e.js';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { b as FormValues, V as ValidationSchema, F as FieldValidator } from './types-BBif0kuP.cjs';
1
+ import { b as FormValues, V as ValidationSchema, F as FieldValidator } from './types-4ppM117e.cjs';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { b as FormValues, V as ValidationSchema, F as FieldValidator } from './types-BBif0kuP.js';
1
+ import { b as FormValues, V as ValidationSchema, F as FieldValidator } from './types-4ppM117e.js';
2
2
  import 'react';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- export { F as FieldValidator, a as ValidationMode, V as ValidationSchema } from './types-BBif0kuP.cjs';
1
+ export { F as FieldValidator, a as ValidationMode, V as ValidationSchema } from './types-4ppM117e.cjs';
2
2
  export { ErrorMessageFn, ValidationRuleOptions, alpha, alphanumeric, compose, creditCard, email, integer, matches, max, maxLength, min, minLength, numeric, oneOf, pattern, phone, postalCode, required, url } from './validation-rules.cjs';
3
3
  export { DebounceOptions, ErrorMessages, MessageTemplate, asyncValidator, crossFieldValidator, debounce, defaultMessages, getErrorMessage, messageRegistry, resetErrorMessages, setErrorMessages, when, withRaceConditionPrevention } from './validation-utils.cjs';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
- export { F as FieldValidator, a as ValidationMode, V as ValidationSchema } from './types-BBif0kuP.js';
1
+ export { F as FieldValidator, a as ValidationMode, V as ValidationSchema } from './types-4ppM117e.js';
2
2
  export { ErrorMessageFn, ValidationRuleOptions, alpha, alphanumeric, compose, creditCard, email, integer, matches, max, maxLength, min, minLength, numeric, oneOf, pattern, phone, postalCode, required, url } from './validation-rules.js';
3
3
  export { DebounceOptions, ErrorMessages, MessageTemplate, asyncValidator, crossFieldValidator, debounce, defaultMessages, getErrorMessage, messageRegistry, resetErrorMessages, setErrorMessages, when, withRaceConditionPrevention } from './validation-utils.js';
4
4
  import 'react';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@page-speed/forms",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "description": "Ultra-high-performance React form library with field-level reactivity and tree-shakable architecture",
5
5
  "keywords": [
6
6
  "react",
@@ -117,7 +117,7 @@
117
117
  "vitest": "^4.0.10"
118
118
  },
119
119
  "dependencies": {
120
- "@opensite/hooks": "2.0.6",
120
+ "@opensite/hooks": "2.0.7",
121
121
  "clsx": "^2.1.1",
122
122
  "tailwind-merge": "^3.4.0"
123
123
  },