feat: Form element rendering improvements and alignments #395
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.
Please check if the PR fulfills these requirements
What kind of change does this PR introduce?
Feature.
What is the current behavior?
Form elements that rendered multiple options, such as Select, CheckboxGroup, RadioGroup, CheckboxButtons and RadioButtons did not use the same API. The rendering mechanism was individual to each of them as well, not providing an optimal DX.
What is the new behavior?
Form elements that render multiple options, such as Select, CheckboxGroup, RadioGroup, CheckboxButtons and RadioButtons now use an
options
prop, where each option uses the following format:The
id
is required and will be always used to set themodelValue
of the form element. The options array usage would look as follows:Each of the above mentioned components now also has a
label
prop that is used as fallback if the option item does not provide alabel
field. The componentlabel
prop and optionlabel
field introduce a new concept calledRenderable
to Inkline. Which can be one of the following:Label
{{address.country}}
(option: FormOption) =>
Hello ${option.id}`(option: FormOption) => h('strong', {}, option.id)
markRaw(MyComponent)
Does this PR introduce a breaking change?
The
ISelect
,ICheckboxGroup
andIRadioGroup
will need to be updated to use the format above.