-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from open-formulieren/feature/2-family-members
✨ [#2] Implement types for `npFamilyMembers`
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
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
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,21 @@ | ||
import {InputComponentSchema} from '..'; | ||
|
||
type Validator = 'required'; | ||
type TranslatableKeys = 'label' | 'description' | 'tooltip'; | ||
|
||
export type NpFamilyMembersInputSchema = InputComponentSchema< | ||
never, // No value whatsoever, done by the backend | ||
Validator, | ||
TranslatableKeys | ||
>; | ||
|
||
/** | ||
* @group Form.io components | ||
* @category Concrete types | ||
*/ | ||
export interface NpFamilyMembersComponentSchema | ||
extends Omit<NpFamilyMembersInputSchema, 'hideLabel' | 'disabled'> { | ||
type: 'npFamilyMembers'; | ||
includePartners: boolean; | ||
includeChildren: boolean; | ||
} |
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
100 changes: 100 additions & 0 deletions
100
test-d/formio/components/npFamilyMembers.test-d copy.ts
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,100 @@ | ||
import {expectAssignable, expectNotAssignable} from 'tsd'; | ||
|
||
import {NpFamilyMembersComponentSchema} from '../../../lib/'; | ||
|
||
// minimal npFamilyMembers component schema | ||
expectAssignable<NpFamilyMembersComponentSchema>({ | ||
id: '123', | ||
type: 'npFamilyMembers', | ||
key: 'aFamilyMembers', | ||
label: 'A Family Members', | ||
includeChildren: true, | ||
includePartners: true, | ||
} as const); | ||
|
||
// multiple false (implicit) and appropriate default value type | ||
expectAssignable<NpFamilyMembersComponentSchema>({ | ||
id: '123', | ||
type: 'npFamilyMembers', | ||
key: 'aFamilyMembers', | ||
label: 'A Family Members', | ||
includeChildren: true, | ||
includePartners: true, | ||
} as const); | ||
|
||
// different component type | ||
expectNotAssignable<NpFamilyMembersComponentSchema>({ | ||
type: 'textfield', | ||
} as const); | ||
|
||
// using unsupported properties | ||
expectNotAssignable<NpFamilyMembersComponentSchema>({ | ||
id: '123', | ||
type: 'npFamilyMembers', | ||
key: 'aFamilyMembers', | ||
label: 'A Family Members', | ||
includeChildren: true, | ||
includePartners: true, | ||
hideLabel: true, | ||
} as const); | ||
|
||
// No defaultValue allowed | ||
expectNotAssignable<NpFamilyMembersComponentSchema>({ | ||
id: '123', | ||
type: 'npFamilyMembers', | ||
key: 'aFamilyMembers', | ||
label: 'A Family Members', | ||
includeChildren: true, | ||
includePartners: true, | ||
defaultValue: 1, | ||
}); | ||
|
||
// full, correct schema | ||
expectAssignable<NpFamilyMembersComponentSchema>({ | ||
id: '8aosjaw', | ||
type: 'npFamilyMembers', | ||
// basic tab in builder form | ||
label: 'A label', | ||
key: 'test', | ||
includeChildren: true, | ||
includePartners: true, | ||
description: 'Sample description', | ||
tooltip: 'A tooltip', | ||
showInSummary: true, | ||
showInEmail: false, | ||
showInPDF: true, | ||
// multiple: false, | ||
hidden: false, | ||
clearOnHide: true, | ||
isSensitiveData: false, | ||
// advanced tab in builder form | ||
conditional: { | ||
show: undefined, | ||
when: undefined, | ||
eq: undefined, | ||
}, | ||
// validation tab in builder form | ||
validate: { | ||
required: false, | ||
plugins: undefined, | ||
}, | ||
translatedErrors: { | ||
nl: { | ||
required: 'Je moet een waarde opgeven!!!', | ||
}, | ||
}, | ||
errors: { | ||
// translatedErrors is converted into errors by the backend | ||
required: 'Je moet een waarde opgeven!!!', | ||
}, | ||
// registration tab in builder form | ||
registration: { | ||
attribute: '', | ||
}, | ||
// translations tab in builder form | ||
openForms: { | ||
translations: { | ||
nl: {tooltip: 'bar'}, | ||
}, | ||
}, | ||
}); |