-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement fieldset component schema type definition #32
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {AnyComponentSchema, LayoutComponentSchema, OFExtensions} from '..'; | ||
|
||
type TranslatableKeys = 'label'; | ||
|
||
/** | ||
* The fieldset component schema. | ||
* | ||
* Fieldsets are used to manage group fields together. They can improve accessibility | ||
* by grouping related fields together. | ||
* | ||
* The `key` property has no effect on the submission data structure (it does not create | ||
* a nesting level, the component is purely presentational). | ||
* | ||
* The label is displayed as the legend element, while the upstream component uses an | ||
* explicit legend property for this purpose. | ||
* | ||
* @group Form.io components | ||
* @category Concrete types | ||
*/ | ||
export interface FieldsetComponentSchema | ||
extends Omit< | ||
LayoutComponentSchema<never>, | ||
| 'placeholder' | ||
| 'multiple' | ||
| 'defaultValue' | ||
| 'errors' | ||
| 'description' | ||
| 'hideLabel' | ||
| 'disabled' | ||
| 'validateOn' | ||
> { | ||
id: string; | ||
key: string; | ||
type: 'fieldset'; | ||
label: string; | ||
/** | ||
* Nested components inside the group/fieldset. | ||
*/ | ||
components: AnyComponentSchema[]; | ||
|
||
// custom properties | ||
/** | ||
* Control whether the fieldset header/legend is displayed or not. | ||
* | ||
* @deprecated This should probably use the built-in `hideLabel` property instead, | ||
* which requires a backend data migration and update to the SDK code. | ||
*/ | ||
hideHeader: boolean; | ||
openForms?: OFExtensions<TranslatableKeys>['openForms']; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {expectAssignable} from 'tsd'; | ||
|
||
import {FieldsetComponentSchema} from '../../../lib'; | ||
|
||
// Minimal schema | ||
expectAssignable<FieldsetComponentSchema>({ | ||
id: 'eqegfc', | ||
type: 'fieldset', | ||
key: 'fieldset', | ||
label: 'Fieldset', | ||
hideHeader: false, | ||
components: [], | ||
}); | ||
|
||
// Full schema | ||
expectAssignable<FieldsetComponentSchema>({ | ||
id: 'eqegfc', | ||
type: 'fieldset', | ||
key: 'fieldset', | ||
label: 'Fieldset', | ||
tooltip: 'A tooltip for the group', | ||
hideHeader: false, | ||
hidden: true, | ||
clearOnHide: true, | ||
components: [ | ||
{ | ||
id: 'wien53il', | ||
type: 'textfield', | ||
key: 'nestedTextField', | ||
label: 'Nested text field', | ||
}, | ||
], | ||
}); |
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.
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'm not sure I understand this sentence:
legend ==
<legend>
?upstream = formio? What does explicit means here?
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.
<legend>
component.legend
exists andcomponent.label
is actually ignoredThere 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.
Ok nice, I'd be interested to see how this will be implemented on the form builder as I've used
<fieldset>
with<legend>
as well.