formRegistry
A registry object that maps eachQrTypeKey to its corresponding Preact form component. This registry is used by the CardContentInput component to dynamically render the appropriate form based on the selected QR type.
Type Signature
Registry Mappings
| QR Type Key | Component | File Path |
|---|---|---|
QrTypeKey.PlainText | TextForm | src/components/forms/text/text-form.tsx |
QrTypeKey.Url | UrlForm | src/components/forms/url/url-form.tsx |
QrTypeKey.Wifi | WifiForm | src/components/forms/wifi/wifi-form.tsx |
QrTypeKey.VCard | VCardForm | src/components/forms/v-card-form/v-card-form.tsx |
QrTypeKey.Payment | PaymentForm | src/components/forms/payment-form/payment-form.tsx |
QrTypeKey.Event | EventForm | src/components/forms/event-form/event-form.tsx |
Usage Example
Fromsrc/components/qr-code-app/cards/content-input-card/card-content-input.tsx:14:
Form Component Interface
All form components in the registry follow a consistent interface:T is the specific data type for that QR code format (e.g., UrlQrData, WifiQrData, etc.).
Adding New QR Types
To add a new QR type to the registry:- Create a new form component in
src/components/forms/ - Import the component in
src/domain/form/form-registry.ts - Add a new entry to the
formRegistryobject mapping theQrTypeKeyto your component - Ensure your component implements the
FormProps<T>interface
Source Reference
Implemented insrc/domain/form/form-registry.ts:9-16.