-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(types): add types for forms collection #1415
Conversation
🚀 Deployed on https://pr-1415--dhis2-ui.netlify.app |
Passing run #3082 ↗︎
Details:
Review all test suite changes for PR #1415 ↗︎ |
> | ||
|
||
export type CheckboxFieldFFProps = FieldRenderProps<CheckBoxValue> & | ||
CheckboxOverriddenProps & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's hard to tell if this contains all the types or not .. shouldn't validationText
be explicitly defined here since it's not part of FieldRenderProps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validationText
will be part of CheckBoxOverridenProps
- since it's part of CheckboxFieldProps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought-process for this:
These are just wrappers of field-components, and pass along the rest
-props. Thus, these should have the same propTypes as the base component. However, it also "overrides" some props, eg. onChange
and checked
- that comes from the input
-prop. These should thus not be part of the props. Some other props are wrapped (eg. onBlur
), but in the end they have the same signature - and it calls the onBlur
in the prop as well as the one in input
. This should be part of the prop-types. This is why I use Omit
- keeping all props except those that are controlled by internal logic / input
/meta
.
It does make it a bit hard to see at a glance what props are valid, but I don't want to duplicate all the types from the base object manually - when it's uses spread internally after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now realize the overriden
-type should probably be called CheckboxRestProps
. The resulting type is actually the opposite of the "overridden"-props - the overridenProps is the union given to Omit
...
type CheckBoxValue = CheckboxFieldProps['value'] | ||
type CheckboxOverriddenProps = Omit< | ||
CheckboxFieldProps, | ||
'onChange' | 'value' | 'checked' | 'name' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should onBlur be omitted too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onChange
is the only handler that won't be called. onBlur
and onFocus
will call both the callback on input.onBlur
and the passed onBlur
in root-props. onChange
just calls the one on input
. This seems consistent for all FF components. See here https://github.com/dhis2/ui/blob/feat/types-fieldff/collections/forms/src/CheckboxFieldFF/CheckboxFieldFF.js#L33-L35 .
# [8.15.0-alpha.1](v8.14.2-alpha.1...v8.15.0-alpha.1) (2023-10-19) ### Features * **types:** add types for forms collection ([#1415](#1415)) ([2e9d91a](2e9d91a))
# [8.16.0-alpha.1](v8.15.0...v8.16.0-alpha.1) (2023-11-28) ### Bug Fixes * **package:** include types in exports field ([e16036b](e16036b)) * minor type fixes ([#1416](#1416)) ([71f4537](71f4537)) * **types:** add type declarations for components ([#1399](#1399)) ([d3e74c5](d3e74c5)) ### Features * **types:** add types for forms collection ([#1415](#1415)) ([2e9d91a](2e9d91a))
* fix(types): add type declarations for components (#1399) * fix: add types for popers * style: prettier constants decl * fix: rexport types from ui * fix: generate type script * chore: ignore declaration files * fix: add types for icons * fix: add types for alert, box, button * fix: add types for input * fix: add types for calendar * fix: add types for checkbox * fix: add types card, center, chip, cover, css * fix: add types for divier and field * fix: add types for file-input * fix: add types for logo, modal, node * fix: add types for headerbar, help, intersection, label, layer * fix: add types for legend, loader, menu, notice-box * fix: add types for orgunit-tree * fix: add types for portal, tab, tooltip * fix: add types for equired, statusicon, tag, useravatar * fix: add types for pagination * fix: edit input payloads, add radio types * fix: add types for segmented-control * fix: add types for select * fix: add types for selector-bar,switch * fix: add types for sharing-dialog and modal * fix: add types for transfer * fix: add types for textarea * fix: add types for table * fix: rexport declarations from collections/ui * style: run prettier * fix: remove generate-types script * fix: name conflicts * fix: name conflicts in rexport * chore: add @types/react to dependencies * fix: typo * style: run prettier on icons * fix: move files to types-folder and update packages * chore: eslint ignore *.d.ts * chore: run prettier * fix: fix types in package.json * fix: add forward prop types to datacell * style: prettier on package.json * style: prettier * fix: cleanup * chore: use range for peer-dep @react/types * fix: fix onClick type for layer * chore: move @types/react to peerdep * refactor(org unit tree): rename root error & loading to match exported name * chore(transferoption): add missing onClick/onDoubleClick prop TS types * chore(org unit tree): add missing / fix public TS types * fix(selector-bar): add types for selector-bar-item * style: fix selector-bar style --------- Co-authored-by: Jan-Gerke Salomon <[email protected]> Co-authored-by: Jan-Gerke Salomon <[email protected]> * chore(release): cut 8.14.2-alpha.1 [skip release] ## [8.14.2-alpha.1](v8.14.1...v8.14.2-alpha.1) (2023-10-12) ### Bug Fixes * **types:** add type declarations for components ([#1399](#1399)) ([d3e74c5](d3e74c5)) * feat(types): add types for forms collection (#1415) * feat: add types for FF field-wrappers * feat(types): add types for transformers and validators * fix: mirror folder-structure for types * fix: remove old-types structure * fix(types): cleanup * style: run prettier * refactor: rename overridden type name to rest * style: run prettier * fix(types): make selected payload always present * chore(release): cut 8.15.0-alpha.1 [skip release] # [8.15.0-alpha.1](v8.14.2-alpha.1...v8.15.0-alpha.1) (2023-10-19) ### Features * **types:** add types for forms collection ([#1415](#1415)) ([2e9d91a](2e9d91a)) * fix: minor type fixes (#1416) * fix(types): make value and name always present in eventpayload * fix(types): export payloads and handlers * style: run prettier * chore(release): cut 8.15.0-alpha.2 [skip release] # [8.15.0-alpha.2](v8.15.0-alpha.1...v8.15.0-alpha.2) (2023-10-20) ### Bug Fixes * minor type fixes ([#1416](#1416)) ([71f4537](71f4537)) * chore(changelog): merge changelog correctly * fix(package): include types in exports field * chore(release): cut 8.15.0-alpha.3 [skip release] # [8.15.0-alpha.3](v8.15.0-alpha.2...v8.15.0-alpha.3) (2023-11-20) ### Bug Fixes * **package:** include types in exports field ([e16036b](e16036b)) * **pagination:** add row padding on small screens and demo stories ([b373859](b373859)) * **portal:** get default mount node at execution time ([20ab2ca](20ab2ca)) * **translations:** sync translations from transifex (master) ([f7cc472](f7cc472)) * **translations:** sync translations from transifex (master) ([7ea15fe](7ea15fe)) * **translations:** sync translations from transifex (master) ([fb22f68](fb22f68)) * **translations:** sync translations from transifex (master) ([071453c](071453c)) * **translations:** sync translations from transifex (master) ([4a8b0b3](4a8b0b3)) * **translations:** sync translations from transifex (master) ([ac1b242](ac1b242)) * **translations:** sync translations from transifex (master) ([28e0da7](28e0da7)) * chore(changelog): merge changelog * chore(release): cut 8.16.0-alpha.1 [skip release] # [8.16.0-alpha.1](v8.15.0...v8.16.0-alpha.1) (2023-11-28) ### Bug Fixes * **package:** include types in exports field ([e16036b](e16036b)) * minor type fixes ([#1416](#1416)) ([71f4537](71f4537)) * **types:** add type declarations for components ([#1399](#1399)) ([d3e74c5](d3e74c5)) ### Features * **types:** add types for forms collection ([#1415](#1415)) ([2e9d91a](2e9d91a)) * fix(types): minor type fixes (#1434) [skip release] * fix(types): add types for sharedPropTypes * docs(types): align type comments with propTypes * chore(changelog): align changelog with master * chore(release): cut 8.16.0-alpha.2 [skip release] # [8.16.0-alpha.2](v8.16.0-alpha.1...v8.16.0-alpha.2) (2023-11-29) ### Bug Fixes * **prop-type:** fix deprecation of buttonVariantPropType ([#1433](#1433)) ([81644a8](81644a8)) * **types:** minor type fixes ([#1434](#1434)) [skip release] ([5e1068d](5e1068d)) --------- Co-authored-by: Jan-Gerke Salomon <[email protected]> Co-authored-by: Jan-Gerke Salomon <[email protected]> Co-authored-by: @dhis2-bot <[email protected]>
# [9.0.0](v8.16.0...v9.0.0) (2023-12-08) ### Bug Fixes * **constants:** remove buttonVariantProptype from constants ([#1436](#1436)) ([d4dc535](d4dc535)) * **package:** include types in exports field ([e16036b](e16036b)) * **types:** add type declarations for components ([#1399](#1399)) ([d3e74c5](d3e74c5)) * **types:** minor type fixes ([#1434](#1434)) [skip release] ([5e1068d](5e1068d)) * minor type fixes ([#1416](#1416)) ([71f4537](71f4537)) ### Features * **types:** add types for forms collection ([#1415](#1415)) ([2e9d91a](2e9d91a)) ### BREAKING CHANGES * **constants:** `buttonVariantPropType` has been removed from constants. This is mostly intended for internal use, but was part of the public API.
Add type declarations form
collections/forms
.Description
After trying out the alpha version in the new
maintenance-app
, I got some type errors because types for theFinal-form
-wrappers did not exist.Checklist
All points above should be relevant for feature PRs. For bugfixes, some points might not be relevant. In that case, just check them anyway to signal the work is done.