@page-speed/forms 0.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.
Files changed (77) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +469 -0
  3. package/dist/builder.cjs +4 -0
  4. package/dist/builder.cjs.map +1 -0
  5. package/dist/builder.d.cts +2 -0
  6. package/dist/builder.d.ts +2 -0
  7. package/dist/builder.js +3 -0
  8. package/dist/builder.js.map +1 -0
  9. package/dist/chunk-2FXAQT7S.cjs +236 -0
  10. package/dist/chunk-2FXAQT7S.cjs.map +1 -0
  11. package/dist/chunk-A3UV7BIN.js +357 -0
  12. package/dist/chunk-A3UV7BIN.js.map +1 -0
  13. package/dist/chunk-P37YLBFA.cjs +138 -0
  14. package/dist/chunk-P37YLBFA.cjs.map +1 -0
  15. package/dist/chunk-WHQMBQNI.js +127 -0
  16. package/dist/chunk-WHQMBQNI.js.map +1 -0
  17. package/dist/chunk-YTTOWHBZ.js +217 -0
  18. package/dist/chunk-YTTOWHBZ.js.map +1 -0
  19. package/dist/chunk-ZQCPEOB6.cjs +382 -0
  20. package/dist/chunk-ZQCPEOB6.cjs.map +1 -0
  21. package/dist/core.cjs +28 -0
  22. package/dist/core.cjs.map +1 -0
  23. package/dist/core.d.cts +143 -0
  24. package/dist/core.d.ts +143 -0
  25. package/dist/core.js +3 -0
  26. package/dist/core.js.map +1 -0
  27. package/dist/index.cjs +28 -0
  28. package/dist/index.cjs.map +1 -0
  29. package/dist/index.d.cts +3 -0
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.js +3 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/inputs.cjs +555 -0
  34. package/dist/inputs.cjs.map +1 -0
  35. package/dist/inputs.d.cts +433 -0
  36. package/dist/inputs.d.ts +433 -0
  37. package/dist/inputs.js +529 -0
  38. package/dist/inputs.js.map +1 -0
  39. package/dist/integration.cjs +4 -0
  40. package/dist/integration.cjs.map +1 -0
  41. package/dist/integration.d.cts +2 -0
  42. package/dist/integration.d.ts +2 -0
  43. package/dist/integration.js +3 -0
  44. package/dist/integration.js.map +1 -0
  45. package/dist/types-Cw5CeZP-.d.cts +387 -0
  46. package/dist/types-Cw5CeZP-.d.ts +387 -0
  47. package/dist/upload.cjs +4 -0
  48. package/dist/upload.cjs.map +1 -0
  49. package/dist/upload.d.cts +2 -0
  50. package/dist/upload.d.ts +2 -0
  51. package/dist/upload.js +3 -0
  52. package/dist/upload.js.map +1 -0
  53. package/dist/validation-rules.cjs +80 -0
  54. package/dist/validation-rules.cjs.map +1 -0
  55. package/dist/validation-rules.d.cts +123 -0
  56. package/dist/validation-rules.d.ts +123 -0
  57. package/dist/validation-rules.js +3 -0
  58. package/dist/validation-rules.js.map +1 -0
  59. package/dist/validation-utils.cjs +48 -0
  60. package/dist/validation-utils.cjs.map +1 -0
  61. package/dist/validation-utils.d.cts +166 -0
  62. package/dist/validation-utils.d.ts +166 -0
  63. package/dist/validation-utils.js +3 -0
  64. package/dist/validation-utils.js.map +1 -0
  65. package/dist/validation-valibot.cjs +94 -0
  66. package/dist/validation-valibot.cjs.map +1 -0
  67. package/dist/validation-valibot.d.cts +92 -0
  68. package/dist/validation-valibot.d.ts +92 -0
  69. package/dist/validation-valibot.js +91 -0
  70. package/dist/validation-valibot.js.map +1 -0
  71. package/dist/validation.cjs +121 -0
  72. package/dist/validation.cjs.map +1 -0
  73. package/dist/validation.d.cts +4 -0
  74. package/dist/validation.d.ts +4 -0
  75. package/dist/validation.js +4 -0
  76. package/dist/validation.js.map +1 -0
  77. package/package.json +133 -0
@@ -0,0 +1,143 @@
1
+ import { b as FormValues, U as UseFormOptions, c as UseFormReturn, d as UseFieldOptions, e as UseFieldReturn, f as FormProps, g as FieldProps } from './types-Cw5CeZP-.cjs';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, k as FormState, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, a as ValidationMode, V as ValidationSchema } from './types-Cw5CeZP-.cjs';
3
+ import * as React from 'react';
4
+
5
+ /**
6
+ * useForm - High-performance form state management with field-level reactivity
7
+ *
8
+ * Built on @legendapp/state for optimal performance:
9
+ * - Field-level reactivity: Only re-render the specific field that changed
10
+ * - Observable-based state: ~1 re-render per change vs ~10 for traditional hooks
11
+ * - Tree-shakable: Only bundle what you use
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const form = useForm({
16
+ * initialValues: { email: '', password: '' },
17
+ * onSubmit: async (values) => {
18
+ * await login(values);
19
+ * },
20
+ * validationSchema: {
21
+ * email: (value) => !value ? 'Required' : undefined,
22
+ * password: (value) => value.length < 8 ? 'Too short' : undefined,
23
+ * },
24
+ * });
25
+ *
26
+ * return (
27
+ * <form onSubmit={form.handleSubmit}>
28
+ * <input {...form.getFieldProps('email')} />
29
+ * {form.errors.email && <span>{form.errors.email}</span>}
30
+ * </form>
31
+ * );
32
+ * ```
33
+ *
34
+ * @see https://opensite.ai/developers/page-speed/forms/use-form
35
+ */
36
+ declare function useForm<T extends FormValues = FormValues>(options: UseFormOptions<T>): UseFormReturn<T>;
37
+
38
+ /**
39
+ * useField - Field-level reactive hook for form inputs
40
+ *
41
+ * Provides isolated reactivity for individual form fields.
42
+ * Only re-renders when the specific field changes, not when other fields update.
43
+ *
44
+ * Must be used within a FormContext (inside <Form> component).
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * function EmailInput() {
49
+ * const { field, meta, helpers } = useField({ name: 'email' });
50
+ *
51
+ * return (
52
+ * <div>
53
+ * <input {...field} type="email" />
54
+ * {meta.touched && meta.error && <span>{meta.error}</span>}
55
+ * </div>
56
+ * );
57
+ * }
58
+ * ```
59
+ *
60
+ * @see https://opensite.ai/developers/page-speed/forms/use-field
61
+ */
62
+ declare function useField<T = any>(options: UseFieldOptions<T>): UseFieldReturn<T>;
63
+
64
+ /**
65
+ * Form - Progressive enhancement form component
66
+ *
67
+ * Provides form context to child components and handles form submission.
68
+ * Supports progressive enhancement with server-side fallback.
69
+ *
70
+ * Features:
71
+ * - Provides FormContext for useField hook
72
+ * - Handles form submission with validation
73
+ * - Progressive enhancement support (works without JavaScript)
74
+ * - Accessible form semantics
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * const form = useForm({
79
+ * initialValues: { email: '' },
80
+ * onSubmit: async (values) => {
81
+ * await submitForm(values);
82
+ * },
83
+ * });
84
+ *
85
+ * return (
86
+ * <Form form={form} action="/api/submit" method="post">
87
+ * <input {...form.getFieldProps('email')} />
88
+ * <button type="submit">Submit</button>
89
+ * </Form>
90
+ * );
91
+ * ```
92
+ *
93
+ * @see https://opensite.ai/developers/page-speed/forms/form
94
+ */
95
+ declare function Form<T extends FormValues = FormValues>({ form, children, className, action, method, noValidate, ...props }: FormProps<T> & React.FormHTMLAttributes<HTMLFormElement>): React.JSX.Element;
96
+ declare namespace Form {
97
+ var displayName: string;
98
+ }
99
+
100
+ /**
101
+ * Field - Field wrapper component with label, description, and error display
102
+ *
103
+ * Provides a complete field UI with automatic error handling and accessibility.
104
+ * Uses useField hook internally for field-level reactivity.
105
+ *
106
+ * Features:
107
+ * - Automatic label association
108
+ * - Error display with accessibility
109
+ * - Optional description text
110
+ * - Render prop pattern for flexibility
111
+ * - Full accessibility support
112
+ *
113
+ * @example
114
+ * ```tsx
115
+ * <Field name="email" label="Email Address" description="We'll never share your email">
116
+ * {({ field, meta }) => (
117
+ * <input
118
+ * {...field}
119
+ * type="email"
120
+ * className={meta.error && meta.touched ? 'error' : ''}
121
+ * />
122
+ * )}
123
+ * </Field>
124
+ * ```
125
+ *
126
+ * @see https://opensite.ai/developers/page-speed/forms/field
127
+ */
128
+ declare function Field({ name, label, description, children, showError, className, validate, }: FieldProps): React.JSX.Element;
129
+ declare namespace Field {
130
+ var displayName: string;
131
+ }
132
+
133
+ /**
134
+ * FormContext - React context for providing form state to child components
135
+ *
136
+ * Allows useField hook to access form state without prop drilling.
137
+ * Automatically provided by the <Form> component.
138
+ *
139
+ * @internal
140
+ */
141
+ declare const FormContext: React.Context<UseFormReturn<any> | null>;
142
+
143
+ export { Field, FieldProps, Form, FormContext, FormProps, FormValues, UseFieldOptions, UseFieldReturn, UseFormOptions, UseFormReturn, useField, useForm };
package/dist/core.d.ts ADDED
@@ -0,0 +1,143 @@
1
+ import { b as FormValues, U as UseFormOptions, c as UseFormReturn, d as UseFieldOptions, e as UseFieldReturn, f as FormProps, g as FieldProps } from './types-Cw5CeZP-.js';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, k as FormState, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, a as ValidationMode, V as ValidationSchema } from './types-Cw5CeZP-.js';
3
+ import * as React from 'react';
4
+
5
+ /**
6
+ * useForm - High-performance form state management with field-level reactivity
7
+ *
8
+ * Built on @legendapp/state for optimal performance:
9
+ * - Field-level reactivity: Only re-render the specific field that changed
10
+ * - Observable-based state: ~1 re-render per change vs ~10 for traditional hooks
11
+ * - Tree-shakable: Only bundle what you use
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const form = useForm({
16
+ * initialValues: { email: '', password: '' },
17
+ * onSubmit: async (values) => {
18
+ * await login(values);
19
+ * },
20
+ * validationSchema: {
21
+ * email: (value) => !value ? 'Required' : undefined,
22
+ * password: (value) => value.length < 8 ? 'Too short' : undefined,
23
+ * },
24
+ * });
25
+ *
26
+ * return (
27
+ * <form onSubmit={form.handleSubmit}>
28
+ * <input {...form.getFieldProps('email')} />
29
+ * {form.errors.email && <span>{form.errors.email}</span>}
30
+ * </form>
31
+ * );
32
+ * ```
33
+ *
34
+ * @see https://opensite.ai/developers/page-speed/forms/use-form
35
+ */
36
+ declare function useForm<T extends FormValues = FormValues>(options: UseFormOptions<T>): UseFormReturn<T>;
37
+
38
+ /**
39
+ * useField - Field-level reactive hook for form inputs
40
+ *
41
+ * Provides isolated reactivity for individual form fields.
42
+ * Only re-renders when the specific field changes, not when other fields update.
43
+ *
44
+ * Must be used within a FormContext (inside <Form> component).
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * function EmailInput() {
49
+ * const { field, meta, helpers } = useField({ name: 'email' });
50
+ *
51
+ * return (
52
+ * <div>
53
+ * <input {...field} type="email" />
54
+ * {meta.touched && meta.error && <span>{meta.error}</span>}
55
+ * </div>
56
+ * );
57
+ * }
58
+ * ```
59
+ *
60
+ * @see https://opensite.ai/developers/page-speed/forms/use-field
61
+ */
62
+ declare function useField<T = any>(options: UseFieldOptions<T>): UseFieldReturn<T>;
63
+
64
+ /**
65
+ * Form - Progressive enhancement form component
66
+ *
67
+ * Provides form context to child components and handles form submission.
68
+ * Supports progressive enhancement with server-side fallback.
69
+ *
70
+ * Features:
71
+ * - Provides FormContext for useField hook
72
+ * - Handles form submission with validation
73
+ * - Progressive enhancement support (works without JavaScript)
74
+ * - Accessible form semantics
75
+ *
76
+ * @example
77
+ * ```tsx
78
+ * const form = useForm({
79
+ * initialValues: { email: '' },
80
+ * onSubmit: async (values) => {
81
+ * await submitForm(values);
82
+ * },
83
+ * });
84
+ *
85
+ * return (
86
+ * <Form form={form} action="/api/submit" method="post">
87
+ * <input {...form.getFieldProps('email')} />
88
+ * <button type="submit">Submit</button>
89
+ * </Form>
90
+ * );
91
+ * ```
92
+ *
93
+ * @see https://opensite.ai/developers/page-speed/forms/form
94
+ */
95
+ declare function Form<T extends FormValues = FormValues>({ form, children, className, action, method, noValidate, ...props }: FormProps<T> & React.FormHTMLAttributes<HTMLFormElement>): React.JSX.Element;
96
+ declare namespace Form {
97
+ var displayName: string;
98
+ }
99
+
100
+ /**
101
+ * Field - Field wrapper component with label, description, and error display
102
+ *
103
+ * Provides a complete field UI with automatic error handling and accessibility.
104
+ * Uses useField hook internally for field-level reactivity.
105
+ *
106
+ * Features:
107
+ * - Automatic label association
108
+ * - Error display with accessibility
109
+ * - Optional description text
110
+ * - Render prop pattern for flexibility
111
+ * - Full accessibility support
112
+ *
113
+ * @example
114
+ * ```tsx
115
+ * <Field name="email" label="Email Address" description="We'll never share your email">
116
+ * {({ field, meta }) => (
117
+ * <input
118
+ * {...field}
119
+ * type="email"
120
+ * className={meta.error && meta.touched ? 'error' : ''}
121
+ * />
122
+ * )}
123
+ * </Field>
124
+ * ```
125
+ *
126
+ * @see https://opensite.ai/developers/page-speed/forms/field
127
+ */
128
+ declare function Field({ name, label, description, children, showError, className, validate, }: FieldProps): React.JSX.Element;
129
+ declare namespace Field {
130
+ var displayName: string;
131
+ }
132
+
133
+ /**
134
+ * FormContext - React context for providing form state to child components
135
+ *
136
+ * Allows useField hook to access form state without prop drilling.
137
+ * Automatically provided by the <Form> component.
138
+ *
139
+ * @internal
140
+ */
141
+ declare const FormContext: React.Context<UseFormReturn<any> | null>;
142
+
143
+ export { Field, FieldProps, Form, FormContext, FormProps, FormValues, UseFieldOptions, UseFieldReturn, UseFormOptions, UseFormReturn, useField, useForm };
package/dist/core.js ADDED
@@ -0,0 +1,3 @@
1
+ export { Field, Form, FormContext, useField, useForm } from './chunk-A3UV7BIN.js';
2
+ //# sourceMappingURL=core.js.map
3
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"core.js"}
package/dist/index.cjs ADDED
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var chunkZQCPEOB6_cjs = require('./chunk-ZQCPEOB6.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "Field", {
8
+ enumerable: true,
9
+ get: function () { return chunkZQCPEOB6_cjs.Field; }
10
+ });
11
+ Object.defineProperty(exports, "Form", {
12
+ enumerable: true,
13
+ get: function () { return chunkZQCPEOB6_cjs.Form; }
14
+ });
15
+ Object.defineProperty(exports, "FormContext", {
16
+ enumerable: true,
17
+ get: function () { return chunkZQCPEOB6_cjs.FormContext; }
18
+ });
19
+ Object.defineProperty(exports, "useField", {
20
+ enumerable: true,
21
+ get: function () { return chunkZQCPEOB6_cjs.useField; }
22
+ });
23
+ Object.defineProperty(exports, "useForm", {
24
+ enumerable: true,
25
+ get: function () { return chunkZQCPEOB6_cjs.useForm; }
26
+ });
27
+ //# sourceMappingURL=index.cjs.map
28
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,3 @@
1
+ export { Field, Form, FormContext, useField, useForm } from './core.cjs';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, g as FieldProps, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, f as FormProps, k as FormState, b as FormValues, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, d as UseFieldOptions, e as UseFieldReturn, U as UseFormOptions, c as UseFormReturn, a as ValidationMode, V as ValidationSchema } from './types-Cw5CeZP-.cjs';
3
+ import 'react';
@@ -0,0 +1,3 @@
1
+ export { Field, Form, FormContext, useField, useForm } from './core.js';
2
+ export { E as ErrorHandler, m as FieldInputProps, n as FieldMeta, g as FieldProps, F as FieldValidator, l as FormActions, h as FormErrors, i as FormHelpers, f as FormProps, k as FormState, b as FormValues, I as InputProps, S as SubmissionStatus, j as SubmitHandler, T as TouchedFields, d as UseFieldOptions, e as UseFieldReturn, U as UseFormOptions, c as UseFormReturn, a as ValidationMode, V as ValidationSchema } from './types-Cw5CeZP-.js';
3
+ import 'react';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { Field, Form, FormContext, useField, useForm } from './chunk-A3UV7BIN.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}