react icon indicating copy to clipboard operation
react copied to clipboard

FIO-7733: type the form component

Open brendanbond opened this issue 1 year ago • 3 comments

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-7733

Description

General Updates

  1. Updates the build system to use tsc rather than babel
  2. Removes unused dependencies
  3. Removes test runner dependencies (updated tests to follow!)
  4. Updates eslint ergonomics to ensure React best practices
  5. Pulls EventEmitter from @formio/js
  6. Updates documentation
  7. Removes stale types
  8. Removes stale tests
  9. Adds jest and @testing-library/react so we can write and maintain a modern test suite

Updates to <Form />

  1. Fully types the component and its props
  2. Reorgs the code so as not to instantiate utility functions in the render function
  3. Updates the src prop to resemble the createForm API (i.e. it takes either a form definition or a form url)
  4. Renames some props to conform to idiomatic prop names (see below)
  5. Consolidates effect functions
  6. Updates the render element ref to use useRef

Breaking Changes / Backwards Compatibility

Generally speaking the goal is to be backwards compatible here (see e.g. the getEffectiveProps function), but I would point the reviewer specifically towards the EventEmitter change and broadly towards testing this PR in your own existing application so we can be sure that everything works properly.

Dependencies

How has this PR been tested?

I've loaded this PR into a simple Next.js application to ensure everything works as expected. Also, now that we've moved away from karma, I expect to add more tests in the next major PR to this library.

Checklist:

  • [x] I have completed the above PR template
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation (if applicable)
  • [x] My changes generate no new warnings
  • [ ] My changes include tests that prove my fix is effective (or that my feature works as intended)
  • [x] New and existing unit/integration tests pass locally with my changes
  • [x] Any dependent changes have corresponding PRs that are listed above

brendanbond avatar Feb 23 '24 23:02 brendanbond

@brendanbond Do we need PR to type the FormBuilder ? I do have experience with it.

gyanendrasinghpanwar avatar Mar 20 '24 17:03 gyanendrasinghpanwar

@gyanendrasinghpanwar I started that today, perhaps since i'm going from top to bottom you could go bottom to top and meet in the middle, maybe you could start typing FormGrid?

brendanbond avatar Mar 20 '24 19:03 brendanbond

@brendanbond Absolutely, sounds like a solid plan! I'm ready to collaborate on getting the builder ready. Going from bottom to top works for me. Once we've got that sorted, we can dive into FormGrid or FormEdit. Feel free to share any suggestions or preferences along the way.

gyanendrasinghpanwar avatar Mar 20 '24 19:03 gyanendrasinghpanwar