diff --git a/src/formio/components/index.ts b/src/formio/components/index.ts index b8eda7a..0062d6d 100644 --- a/src/formio/components/index.ts +++ b/src/formio/components/index.ts @@ -10,6 +10,7 @@ export * from './postcode'; export * from './iban'; export * from './licenseplate'; export * from './bsn'; +export * from './npFamilyMembers'; export * from './number'; export * from './select'; export * from './checkbox'; diff --git a/src/formio/components/npFamilyMembers.ts b/src/formio/components/npFamilyMembers.ts new file mode 100644 index 0000000..fdb002b --- /dev/null +++ b/src/formio/components/npFamilyMembers.ts @@ -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 { + type: 'npFamilyMembers'; + includePartners: boolean; + includeChildren: boolean; +} diff --git a/src/formio/index.ts b/src/formio/index.ts index adce960..fc96c22 100644 --- a/src/formio/index.ts +++ b/src/formio/index.ts @@ -9,6 +9,7 @@ import { FileComponentSchema, IbanComponentSchema, LicensePlateComponentSchema, + NpFamilyMembersComponentSchema, NumberComponentSchema, PhoneNumberComponentSchema, PostcodeComponentSchema, @@ -62,6 +63,7 @@ export type AnyComponentSchema = | IbanComponentSchema | LicensePlateComponentSchema | BsnComponentSchema + | NpFamilyMembersComponentSchema // layout | ContentComponentSchema; diff --git a/test-d/formio/components/npFamilyMembers.test-d copy.ts b/test-d/formio/components/npFamilyMembers.test-d copy.ts new file mode 100644 index 0000000..8e63061 --- /dev/null +++ b/test-d/formio/components/npFamilyMembers.test-d copy.ts @@ -0,0 +1,100 @@ +import {expectAssignable, expectNotAssignable} from 'tsd'; + +import {NpFamilyMembersComponentSchema} from '../../../lib/'; + +// minimal npFamilyMembers component schema +expectAssignable({ + 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({ + id: '123', + type: 'npFamilyMembers', + key: 'aFamilyMembers', + label: 'A Family Members', + includeChildren: true, + includePartners: true, +} as const); + +// different component type +expectNotAssignable({ + type: 'textfield', +} as const); + +// using unsupported properties +expectNotAssignable({ + id: '123', + type: 'npFamilyMembers', + key: 'aFamilyMembers', + label: 'A Family Members', + includeChildren: true, + includePartners: true, + hideLabel: true, +} as const); + +// No defaultValue allowed +expectNotAssignable({ + id: '123', + type: 'npFamilyMembers', + key: 'aFamilyMembers', + label: 'A Family Members', + includeChildren: true, + includePartners: true, + defaultValue: 1, +}); + +// full, correct schema +expectAssignable({ + 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'}, + }, + }, +});