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

✨ [#2] Implement types for several components #16

Merged
merged 6 commits into from
Oct 30, 2023

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented Oct 24, 2023

Part of #2

@Viicos Viicos linked an issue Oct 24, 2023 that may be closed by this pull request
29 tasks
@Viicos
Copy link
Contributor Author

Viicos commented Oct 24, 2023

Regarding the email component missing validateOn, I wonder if it is really missing, considering the following test:

expectAssignable<EmailComponentSchema>({
id: 'yejak',
type: 'email',
// basic tab
label: 'Some email',
key: 'someEmail',
description: '',
tooltip: 'A tooltip',
showInSummary: true,
showInEmail: false,
showInPDF: true,
multiple: false,
hidden: false,
clearOnHide: true,
isSensitiveData: true,
defaultValue: '',
autocomplete: 'email',
confirmationRecipient: false,
// Advanced tab
conditional: {
show: undefined,
when: '',
eq: '',
},
// Validation tab
validate: {
required: false,
plugins: [],
},
translatedErrors: {nl: {required: 'Geef email.'}},
errors: {required: 'Geef email.'},
// registration tab
registration: {
attribute: '',
},
// translations tab in builder form
openForms: {
translations: {
nl: {label: 'foo'},
},
},
// fixed but not editable
validateOn: 'blur',
});

Copy link
Member

@sergei-maertens sergei-maertens left a comment

Choose a reason for hiding this comment

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

missing tests :)

src/formio/components/checkbox.ts Outdated Show resolved Hide resolved
src/formio/components/selectboxes.ts Outdated Show resolved Hide resolved
src/formio/components/selectboxes.ts Outdated Show resolved Hide resolved
src/formio/components/selectboxes.ts Outdated Show resolved Hide resolved
src/formio/index.ts Outdated Show resolved Hide resolved
@sergei-maertens
Copy link
Member

Regarding the email component missing validateOn, I wonder if it is really missing, considering the following test:

expectAssignable<EmailComponentSchema>({
id: 'yejak',
type: 'email',
// basic tab
label: 'Some email',
key: 'someEmail',
description: '',
tooltip: 'A tooltip',
showInSummary: true,
showInEmail: false,
showInPDF: true,
multiple: false,
hidden: false,
clearOnHide: true,
isSensitiveData: true,
defaultValue: '',
autocomplete: 'email',
confirmationRecipient: false,
// Advanced tab
conditional: {
show: undefined,
when: '',
eq: '',
},
// Validation tab
validate: {
required: false,
plugins: [],
},
translatedErrors: {nl: {required: 'Geef email.'}},
errors: {required: 'Geef email.'},
// registration tab
registration: {
attribute: '',
},
// translations tab in builder form
openForms: {
translations: {
nl: {label: 'foo'},
},
},
// fixed but not editable
validateOn: 'blur',
});

I think I'd prefer having it so that we can do some interesting stuff in the renderer in the future with onBlur / onChange props for validation. Would be nice if the type checker prevents you from wiring up validation behaviour if validateOn doesn't support that particular trigger.

@Viicos Viicos changed the title ✨ [#2] Implement types for checkbox and checkboxes ✨ [#2] Implement types for several components Oct 26, 2023
@Viicos Viicos force-pushed the feature/2-checkbox-types branch 2 times, most recently from 5079107 to dab8ef2 Compare October 26, 2023 14:00
src/formio/common.ts Outdated Show resolved Hide resolved
src/formio/common.ts Outdated Show resolved Hide resolved
src/formio/components/checkbox.ts Outdated Show resolved Hide resolved
src/formio/components/checkbox.ts Outdated Show resolved Hide resolved
src/formio/components/email.ts Outdated Show resolved Hide resolved
src/formio/components/selectboxes.ts Show resolved Hide resolved
test-d/formio/components/radio.test-d.ts Outdated Show resolved Hide resolved
test-d/formio/components/radio.test-d.ts Outdated Show resolved Hide resolved
test-d/formio/components/radio.test-d.ts Outdated Show resolved Hide resolved
test-d/formio/components/radio.test-d.ts Show resolved Hide resolved
@Viicos Viicos force-pushed the feature/2-checkbox-types branch 2 times, most recently from 848bf61 to 5d55edd Compare October 30, 2023 11:33
Copy link
Member

@sergei-maertens sergei-maertens left a comment

Choose a reason for hiding this comment

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

After fixing the tests, feel free to merge this & release a new version :)

@Viicos Viicos force-pushed the feature/2-checkbox-types branch from 10a68e6 to ac53273 Compare October 30, 2023 12:39
@Viicos Viicos merged commit dd1e673 into main Oct 30, 2023
6 checks passed
@Viicos Viicos deleted the feature/2-checkbox-types branch October 30, 2023 12:42
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.

Export Formio Typescript types
2 participants