@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,433 @@
1
+ import * as React from 'react';
2
+ import { I as InputProps } from './types-Cw5CeZP-.js';
3
+
4
+ /**
5
+ * TextInput - High-performance text input component
6
+ *
7
+ * A lightweight, accessible text input with error state support.
8
+ * Designed to work seamlessly with useForm and Field components.
9
+ *
10
+ * Features:
11
+ * - Full accessibility support
12
+ * - Error state styling
13
+ * - Controlled input behavior
14
+ * - All native input attributes supported
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const form = useForm({ initialValues: { email: '' } });
19
+ *
20
+ * <TextInput
21
+ * {...form.getFieldProps('email')}
22
+ * type="email"
23
+ * placeholder="Enter your email"
24
+ * error={!!form.errors.email}
25
+ * aria-invalid={!!form.errors.email}
26
+ * aria-describedby={form.errors.email ? 'email-error' : undefined}
27
+ * />
28
+ * ```
29
+ *
30
+ * @see https://opensite.ai/developers/page-speed/forms/text-input
31
+ */
32
+ declare function TextInput({ name, value, onChange, onBlur, placeholder, disabled, required, error, className, type, ...props }: InputProps<string> & {
33
+ type?: "text" | "email" | "password" | "url" | "tel" | "search";
34
+ }): React.JSX.Element;
35
+ declare namespace TextInput {
36
+ var displayName: string;
37
+ }
38
+
39
+ /**
40
+ * Additional props specific to TextArea
41
+ */
42
+ interface TextAreaProps extends Omit<InputProps<string>, "onChange"> {
43
+ /**
44
+ * Number of visible text rows
45
+ * @default 3
46
+ */
47
+ rows?: number;
48
+ /**
49
+ * Number of visible text columns (characters)
50
+ */
51
+ cols?: number;
52
+ /**
53
+ * Maximum character length
54
+ */
55
+ maxLength?: number;
56
+ /**
57
+ * Minimum character length
58
+ */
59
+ minLength?: number;
60
+ /**
61
+ * Text wrapping behavior
62
+ * - soft: text wraps but newlines not submitted (default)
63
+ * - hard: text wraps and newlines submitted (requires cols)
64
+ * - off: no wrapping
65
+ */
66
+ wrap?: "soft" | "hard" | "off";
67
+ /**
68
+ * Change handler
69
+ */
70
+ onChange: (value: string) => void;
71
+ /**
72
+ * Additional native textarea attributes
73
+ */
74
+ [key: string]: any;
75
+ }
76
+ /**
77
+ * TextArea - High-performance multi-line text input component
78
+ *
79
+ * A lightweight, accessible textarea with error state support.
80
+ * Designed to work seamlessly with useForm and Field components.
81
+ *
82
+ * Features:
83
+ * - Full accessibility support
84
+ * - Error state styling
85
+ * - Controlled input behavior
86
+ * - Configurable rows and columns
87
+ * - Text wrapping options
88
+ * - Character length validation
89
+ * - All native textarea attributes supported
90
+ *
91
+ * @example
92
+ * ```tsx
93
+ * const form = useForm({ initialValues: { bio: '' } });
94
+ *
95
+ * <TextArea
96
+ * {...form.getFieldProps('bio')}
97
+ * rows={5}
98
+ * placeholder="Tell us about yourself"
99
+ * error={!!form.errors.bio}
100
+ * aria-invalid={!!form.errors.bio}
101
+ * aria-describedby={form.errors.bio ? 'bio-error' : undefined}
102
+ * />
103
+ * ```
104
+ *
105
+ * @see https://opensite.ai/developers/page-speed/forms/textarea
106
+ */
107
+ declare function TextArea({ name, value, onChange, onBlur, placeholder, disabled, required, error, className, rows, cols, maxLength, minLength, wrap, ...props }: TextAreaProps): React.JSX.Element;
108
+ declare namespace TextArea {
109
+ var displayName: string;
110
+ }
111
+
112
+ /**
113
+ * Additional props specific to Checkbox
114
+ */
115
+ interface CheckboxProps extends Omit<InputProps<boolean>, "onChange" | "placeholder"> {
116
+ /**
117
+ * Change handler - receives boolean checked state
118
+ */
119
+ onChange: (checked: boolean) => void;
120
+ /**
121
+ * Indeterminate state for partial selections
122
+ * Useful for "select all" checkboxes with some items selected
123
+ * @default false
124
+ */
125
+ indeterminate?: boolean;
126
+ /**
127
+ * Label text for the checkbox
128
+ * Can also wrap checkbox in a label element
129
+ */
130
+ label?: React.ReactNode;
131
+ /**
132
+ * Additional native input attributes
133
+ */
134
+ [key: string]: any;
135
+ }
136
+ /**
137
+ * Checkbox - High-performance boolean input component
138
+ *
139
+ * A lightweight, accessible checkbox with error state support.
140
+ * Designed to work seamlessly with useForm and Field components.
141
+ *
142
+ * Features:
143
+ * - Full accessibility support (ARIA attributes)
144
+ * - Error state styling
145
+ * - Controlled input behavior
146
+ * - Indeterminate state support
147
+ * - Optional label text
148
+ * - All native checkbox attributes supported
149
+ *
150
+ * @example
151
+ * ```tsx
152
+ * const form = useForm({ initialValues: { terms: false } });
153
+ *
154
+ * <Checkbox
155
+ * {...form.getFieldProps('terms')}
156
+ * label="I agree to the terms and conditions"
157
+ * error={!!form.errors.terms}
158
+ * aria-describedby={form.errors.terms ? 'terms-error' : undefined}
159
+ * />
160
+ * ```
161
+ *
162
+ * @example
163
+ * ```tsx
164
+ * // With indeterminate state
165
+ * <Checkbox
166
+ * name="selectAll"
167
+ * value={allSelected}
168
+ * onChange={handleSelectAll}
169
+ * indeterminate={someSelected}
170
+ * label="Select all items"
171
+ * />
172
+ * ```
173
+ *
174
+ * @see https://opensite.ai/developers/page-speed/forms/checkbox
175
+ */
176
+ declare function Checkbox({ name, value, onChange, onBlur, disabled, required, error, className, indeterminate, label, ...props }: CheckboxProps): React.JSX.Element;
177
+ declare namespace Checkbox {
178
+ var displayName: string;
179
+ }
180
+
181
+ /**
182
+ * Radio option type
183
+ */
184
+ interface RadioOption {
185
+ /**
186
+ * The value for this radio option
187
+ */
188
+ value: string;
189
+ /**
190
+ * Display label for the option
191
+ */
192
+ label: React.ReactNode;
193
+ /**
194
+ * Optional description text below the label
195
+ */
196
+ description?: React.ReactNode;
197
+ /**
198
+ * Whether this option is disabled
199
+ */
200
+ disabled?: boolean;
201
+ }
202
+ /**
203
+ * Additional props specific to Radio
204
+ */
205
+ interface RadioProps extends Omit<InputProps<string>, "onChange" | "placeholder"> {
206
+ /**
207
+ * Change handler - receives selected value
208
+ */
209
+ onChange: (value: string) => void;
210
+ /**
211
+ * Array of radio options
212
+ */
213
+ options: RadioOption[];
214
+ /**
215
+ * Layout direction
216
+ * @default "stacked"
217
+ */
218
+ layout?: "inline" | "stacked";
219
+ /**
220
+ * Group-level label
221
+ */
222
+ label?: React.ReactNode;
223
+ /**
224
+ * Additional native input attributes
225
+ */
226
+ [key: string]: any;
227
+ }
228
+ /**
229
+ * Radio - High-performance single selection component
230
+ *
231
+ * A lightweight, accessible radio group with error state support.
232
+ * Designed to work seamlessly with useForm and Field components.
233
+ *
234
+ * Features:
235
+ * - Full accessibility support (ARIA attributes, role="radiogroup")
236
+ * - Error state styling
237
+ * - Controlled input behavior
238
+ * - Keyboard navigation (arrow keys)
239
+ * - Inline or stacked layout
240
+ * - Optional descriptions for each option
241
+ * - Individual option disabled state
242
+ * - All native radio attributes supported
243
+ *
244
+ * @example
245
+ * ```tsx
246
+ * const form = useForm({ initialValues: { plan: 'basic' } });
247
+ *
248
+ * <Radio
249
+ * {...form.getFieldProps('plan')}
250
+ * label="Select your plan"
251
+ * options={[
252
+ * { value: 'basic', label: 'Basic', description: '$9/month' },
253
+ * { value: 'pro', label: 'Pro', description: '$29/month' },
254
+ * { value: 'enterprise', label: 'Enterprise', description: '$99/month' }
255
+ * ]}
256
+ * error={!!form.errors.plan}
257
+ * aria-describedby={form.errors.plan ? 'plan-error' : undefined}
258
+ * />
259
+ * ```
260
+ *
261
+ * @example
262
+ * ```tsx
263
+ * // Inline layout
264
+ * <Radio
265
+ * name="size"
266
+ * value={size}
267
+ * onChange={handleSizeChange}
268
+ * layout="inline"
269
+ * options={[
270
+ * { value: 'sm', label: 'Small' },
271
+ * { value: 'md', label: 'Medium' },
272
+ * { value: 'lg', label: 'Large' }
273
+ * ]}
274
+ * />
275
+ * ```
276
+ *
277
+ * @see https://opensite.ai/developers/page-speed/forms/radio
278
+ */
279
+ declare function Radio({ name, value, onChange, onBlur, disabled, required, error, className, layout, label, options, ...props }: RadioProps): React.JSX.Element;
280
+ declare namespace Radio {
281
+ var displayName: string;
282
+ }
283
+
284
+ /**
285
+ * Select option type
286
+ */
287
+ interface SelectOption {
288
+ /**
289
+ * The value for this option
290
+ */
291
+ value: string;
292
+ /**
293
+ * Display label for the option
294
+ */
295
+ label: React.ReactNode;
296
+ /**
297
+ * Whether this option is disabled
298
+ */
299
+ disabled?: boolean;
300
+ }
301
+ /**
302
+ * Select option group type for organizing options
303
+ */
304
+ interface SelectOptionGroup {
305
+ /**
306
+ * Group label
307
+ */
308
+ label: string;
309
+ /**
310
+ * Options in this group
311
+ */
312
+ options: SelectOption[];
313
+ }
314
+ /**
315
+ * Additional props specific to Select
316
+ */
317
+ interface SelectProps extends Omit<InputProps<string>, "onChange" | "onFocus"> {
318
+ /**
319
+ * Change handler - receives selected value
320
+ */
321
+ onChange: (value: string) => void;
322
+ /**
323
+ * Focus handler
324
+ */
325
+ onFocus?: () => void;
326
+ /**
327
+ * Array of select options (flat structure)
328
+ */
329
+ options?: SelectOption[];
330
+ /**
331
+ * Array of option groups (grouped structure)
332
+ */
333
+ optionGroups?: SelectOptionGroup[];
334
+ /**
335
+ * Placeholder text when no option is selected
336
+ * @default "Select..."
337
+ */
338
+ placeholder?: string;
339
+ /**
340
+ * Enable search/filter functionality
341
+ * @default true
342
+ */
343
+ searchable?: boolean;
344
+ /**
345
+ * Enable clearable button to reset selection
346
+ * @default true
347
+ */
348
+ clearable?: boolean;
349
+ /**
350
+ * Loading state for async options
351
+ * @default false
352
+ */
353
+ loading?: boolean;
354
+ /**
355
+ * Custom render function for options
356
+ */
357
+ renderOption?: (option: SelectOption) => React.ReactNode;
358
+ /**
359
+ * Additional native input attributes
360
+ */
361
+ [key: string]: any;
362
+ }
363
+ /**
364
+ * Select - High-performance dropdown selection component
365
+ *
366
+ * A lightweight, accessible select/dropdown with search, keyboard navigation,
367
+ * and error state support. Designed to work seamlessly with useForm and Field components.
368
+ *
369
+ * Features:
370
+ * - Full accessibility support (ARIA attributes, role="combobox")
371
+ * - Error state styling
372
+ * - Controlled input behavior
373
+ * - Keyboard navigation (arrow keys, Enter, Escape, type-ahead)
374
+ * - Searchable options with filtering
375
+ * - Clearable selection
376
+ * - Option groups support
377
+ * - Loading state for async options
378
+ * - Disabled options support
379
+ * - Click outside to close
380
+ *
381
+ * @example
382
+ * ```tsx
383
+ * const form = useForm({ initialValues: { country: '' } });
384
+ *
385
+ * <Select
386
+ * {...form.getFieldProps('country')}
387
+ * placeholder="Select a country"
388
+ * options={[
389
+ * { value: 'us', label: 'United States' },
390
+ * { value: 'ca', label: 'Canada' },
391
+ * { value: 'mx', label: 'Mexico' }
392
+ * ]}
393
+ * searchable
394
+ * clearable
395
+ * error={!!form.errors.country}
396
+ * aria-describedby={form.errors.country ? 'country-error' : undefined}
397
+ * />
398
+ * ```
399
+ *
400
+ * @example
401
+ * ```tsx
402
+ * // With option groups
403
+ * <Select
404
+ * name="timezone"
405
+ * value={timezone}
406
+ * onChange={handleTimezoneChange}
407
+ * optionGroups={[
408
+ * {
409
+ * label: 'North America',
410
+ * options: [
411
+ * { value: 'est', label: 'Eastern Time' },
412
+ * { value: 'cst', label: 'Central Time' }
413
+ * ]
414
+ * },
415
+ * {
416
+ * label: 'Europe',
417
+ * options: [
418
+ * { value: 'gmt', label: 'GMT' },
419
+ * { value: 'cet', label: 'Central European Time' }
420
+ * ]
421
+ * }
422
+ * ]}
423
+ * />
424
+ * ```
425
+ *
426
+ * @see https://opensite.ai/developers/page-speed/forms/select
427
+ */
428
+ declare function Select({ name, value, onChange, onBlur, onFocus, disabled, required, error, className, placeholder, searchable, clearable, loading, options, optionGroups, renderOption, ...props }: SelectProps): React.JSX.Element;
429
+ declare namespace Select {
430
+ var displayName: string;
431
+ }
432
+
433
+ export { Checkbox, type CheckboxProps, Radio, type RadioOption, type RadioProps, Select, type SelectOption, type SelectOptionGroup, type SelectProps, TextArea, type TextAreaProps, TextInput };