@page-speed/forms 0.3.1 → 0.3.2

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 (2) hide show
  1. package/README.md +81 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -579,6 +579,87 @@ import { FileInput } from '@page-speed/forms/inputs';
579
579
  - Multiple file support
580
580
  - Accessible file selection
581
581
 
582
+ ### File Upload Implementation
583
+
584
+ The `FileInput` component uses a **two-phase upload process** optimized for Rails API integration. Files are uploaded immediately to temporary storage and return unique tokens, which are then associated with your form submission.
585
+
586
+ **Quick Example:**
587
+
588
+ ```tsx
589
+ const [uploadTokens, setUploadTokens] = useState<string[]>([]);
590
+
591
+ const handleFileUpload = async (files: File[]) => {
592
+ const formData = new FormData();
593
+ formData.append("contact_form_upload[file_upload]", files[0]);
594
+
595
+ const response = await fetch("/api/contact_form_uploads", {
596
+ method: "POST",
597
+ body: formData,
598
+ });
599
+
600
+ const data = await response.json();
601
+ setUploadTokens([data.token]);
602
+ };
603
+
604
+ // In your form submission:
605
+ onSubmit: async (values) => {
606
+ await submitForm({
607
+ ...values,
608
+ contact_form_upload_tokens: uploadTokens,
609
+ });
610
+ }
611
+ ```
612
+
613
+ **Comprehensive Guide:**
614
+
615
+ For complete file upload documentation, including:
616
+ - Two-phase upload process and flow diagrams
617
+ - Rails API integration with endpoint specifications
618
+ - Multiple working examples (resume uploads, image galleries, document forms)
619
+ - Progress tracking and error handling patterns
620
+ - Image cropping implementation
621
+ - File validation strategies
622
+ - Best practices and common patterns
623
+ - Troubleshooting guide
624
+
625
+ See the **[File Upload Guide](./docs/FILE_UPLOADS.md)** for detailed information.
626
+
627
+ ## Styling
628
+
629
+ All components in `@page-speed/forms` are **intentionally unstyled** to provide maximum flexibility and framework-agnostic design. Components use predictable BEM class names (e.g., `.text-input`, `.select-trigger`, `.field-label`) as styling hooks, allowing you to apply any design system or custom styles.
630
+
631
+ **Quick Example:**
632
+
633
+ ```css
634
+ /* Your custom CSS */
635
+ .text-input {
636
+ height: 2.25rem;
637
+ border: 1px solid #d1d5db;
638
+ border-radius: 0.375rem;
639
+ padding: 0.5rem 0.75rem;
640
+ }
641
+
642
+ .text-input:focus {
643
+ outline: none;
644
+ border-color: #3b82f6;
645
+ }
646
+
647
+ .text-input--error {
648
+ border-color: #ef4444;
649
+ }
650
+ ```
651
+
652
+ **Comprehensive Guide:**
653
+
654
+ For complete styling documentation, including:
655
+ - BEM class reference for all components
656
+ - Multiple styling approaches (Vanilla CSS, Tailwind, CSS Modules, CSS-in-JS)
657
+ - Complete examples (shadcn/ui, Material Design, custom brands)
658
+ - Best practices and common patterns
659
+ - Dark mode support
660
+
661
+ See the **[Styling Guide](./docs/STYLES.md)** for detailed information.
662
+
582
663
  ## Performance Notes
583
664
 
584
665
  Performance is a core facet of everything we build at OpenSite AI. The library is optimized for minimal re-renders and efficient form state updates, ensuring your applications remain responsive and fast.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@page-speed/forms",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Ultra-high-performance React form library with field-level reactivity and tree-shakable architecture",
5
5
  "keywords": [
6
6
  "react",