feat: data-driven converter forms with createFormHook pattern#6
Merged
Conversation
- Extract duplicated FieldError into shared FieldErrorMessage component - Extract conditionalInputValidation helper in validation-schemas.ts - Remove dead BetterReadonly/NeverOnSet types from utils.ts - Remove unused @tanstack/zod-form-adapter dependency - Simplify useThemeController setTheme logic - Remove empty prop types from Header and Layout - Use cn() in Loader for className composition
chore: idiomatic TypeScript simplifications
Introduce ConverterConfig<T>, FieldConfig, and SelectOption types that describe converter forms declaratively. Create config objects for all four converters (binary, base64, hex, URL encoder) that encode field layout, validation schema, default values, and conversion logic.
Replace loose options object with a typed ConverterConfig parameter. Absorb focus-management logic from useFormHelpers (registerInputRef, focusFirstError). Replace manual store.subscribe() with reactive useStore selector for mode changes. Wrap handleReset and focusFirstError in useCallback. onSubmit now delegates to config.onSubmit and handles try/catch + setOutput internally.
Create composable field wrappers that pair TanStack Form's form.Field render-prop with the existing FormSelect/FormTextArea primitives and FieldErrorMessage. ConvertActions encapsulates the Reset + Convert button pair with form.Subscribe for canSubmit/isSubmitting state. Update barrel export to include new components.
Import useStore from @tanstack/react-form instead of @tanstack/react-store to match the store version used by form-core. Use loosely typed form prop (any) in SelectField, TextAreaField, ConvertActions, and FieldRenderer to accommodate ReactFormExtendedApi which adds Field/Subscribe beyond the base FormApi type. Add ConverterPage generic renderer and export from barrel.
- Replace useEffect+useRef mode-change detection with TanStack Form listeners API on the mode field's AppField - Add ConverterFormBase interface (mode + input) as generic constraint - Make FieldConfig<T> generic to eliminate visibleWhen double-cast - Remove useStore import from useConverterForm (no longer needed)
Field components (SelectField, TextAreaField) cannot use useFormContext because it only works inside formComponents registered with createFormHook. Access the form state via field.form.state instead.
✅ Deploy Preview for devkit-app ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConverterPagerenderer — pages reduced to ~5 lines eachcreateFormHookContexts+createFormHook) to eliminate allform: anytypes via React contextuseEffect+useRefmode-change detection with TanStack Form'slistenersAPI on the mode fielduseConverterForm, deleting the separate hookuseStoresubscriptions (mode-only re-renders)Test plan
npm run build)npm run lint)anytypes in src/