Skip to content
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

Form with controls and hooks #9

Merged
merged 13 commits into from
Apr 2, 2024

Conversation

Matushl
Copy link
Contributor

@Matushl Matushl commented Mar 22, 2024

Decisions made:

  • removed all actions but submit actions from form (compared to Wue)
  • added i18n with hardcoded translations - there will be need for another task to make messages customizable

Consciously left out (todos for the future PRs):

  • add ui-informed storybook deployment into CI
    • move storybook (and maybe others into root dependencies)
  • add more stories for whole Form, etc
  • add possibility to customize translations (alredy in this PR)
  • setup jest and add tests
  • add ArrayControl (here) + FieldSet (into utima/ui)
  • ? create some general FiledCol as Form ui element (columns was removed completely)

@Matushl Matushl requested review from jsimck and adamhemzal March 22, 2024 16:13
@Matushl Matushl self-assigned this Mar 22, 2024
@Matushl Matushl force-pushed the matushlavacik/form-with-controls-and-hooks branch from b1039a3 to 51c6ddb Compare March 25, 2024 19:23
@Matushl Matushl marked this pull request as ready for review March 25, 2024 19:55
@Matushl Matushl force-pushed the matushlavacik/form-with-controls-and-hooks branch from 0f3376a to 1eab1a7 Compare March 25, 2024 20:10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would omit i18n library from this package completely. This would force use to use it and also I am not really sure, how we would pass correct config into this (you want config as singleton, this would create completely new config without a way to customize it per-project.

I would just pass these as props and we will have to wrap it to custom component to provide translations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about it now... I would probably move all translations to root Form component and pass it down through context. In this case we only need to "wrap" the root component with initial settings.. Or maybe do a completely new context provider which provides these (defined globally like react query provider etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've implemented FormTranslationsContext, it provides english translations as default and you can override them with wrapping your app with provider with value of your translations

export type TextAreaControlProps = Omit<
ComponentProps<typeof FormControl>,
'type' | 'render'
> & { rows: number };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these types are not entirely correct, but we can fix this in later releases, since I need to test something out

/**
* FormWithControls
*/
export * as FormWithControls from './form';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am on the edge with this one, I am leaning towards not defining these aliases in this case and simply having the application use import * as Form from '@utima/ui-informed';.

There would be cases like Form.Form but you could also define custom alias, or use it without one. WHat do you think?

Copy link
Contributor Author

@Matushl Matushl Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't like that if you let it only on the import in final application, then there will be things like Form.useDefaultSubmitActions. But I admit that it's maybe kinda unusual to create this named import inside of package, but on the other hand we are directly offering user of our package "the best way" how to use it and do not mess up with importing Checkbox from utima/ui insted of utima/ui-informed :-D

But I don't have strong opinion on that, I just stated my thoughts and leaving decision up to you (so far I'm not removing it)

@Matushl Matushl requested a review from jsimck March 29, 2024 17:22
@Matushl Matushl merged commit 561015e into main Apr 2, 2024
2 checks passed
@Matushl Matushl deleted the matushlavacik/form-with-controls-and-hooks branch April 2, 2024 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants