Skip to content

Commit

Permalink
Merge pull request #34 from open-formulieren/rename-address-component
Browse files Browse the repository at this point in the history
Rename `address` to `addressNL`
  • Loading branch information
sergei-maertens authored Dec 4, 2023
2 parents 1c13f2f + 8978bdf commit 3a95cef
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export interface AddressData {
houseNumberAddition: string;
}

export type AddressInputSchema = InputComponentSchema<AddressData, Validator, TranslatableKeys>;
export type AddressNLInputSchema = InputComponentSchema<AddressData, Validator, TranslatableKeys>;

/**
* @group Form.io components
* @category Concrete types
*/
export interface AddressComponentSchema
extends Omit<AddressInputSchema, 'hideLabel' | 'placeholder' | 'disabled' | 'validateOn'> {
type: 'address';
export interface AddressNLComponentSchema
extends Omit<AddressNLInputSchema, 'hideLabel' | 'placeholder' | 'disabled' | 'validateOn'> {
type: 'addressNL';
}
2 changes: 1 addition & 1 deletion src/formio/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './checkbox';
export * from './selectboxes';
export * from './file';
export * from './radio';
export * from './address';
export * from './addressNL';

// Layout components
export * from './content';
Expand Down
4 changes: 2 additions & 2 deletions src/formio/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
AddressComponentSchema,
AddressNLComponentSchema,
BsnComponentSchema,
CheckboxComponentSchema,
ColumnsComponentSchema,
Expand Down Expand Up @@ -69,7 +69,7 @@ export type AnyComponentSchema =
| LicensePlateComponentSchema
| BsnComponentSchema
| NpFamilyMembersComponentSchema
| AddressComponentSchema
| AddressNLComponentSchema
// layout
| ContentComponentSchema
| ColumnsComponentSchema
Expand Down
78 changes: 78 additions & 0 deletions test-d/formio/components/addressNL.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import {expectAssignable, expectNotAssignable} from 'tsd';

import {AddressNLComponentSchema} from '../../../lib';

// minimal Address (NL) component schema
expectAssignable<AddressNLComponentSchema>({
id: 'yejak',
type: 'addressNL',
key: 'someAddressNL',
label: 'Some AddressNL',
});

// appropriate default value type
expectAssignable<AddressNLComponentSchema>({
id: 'yejak',
type: 'addressNL',
key: 'someAddressNL',
label: 'Some AddressNL',
defaultValue: {
postcode: '',
houseNumber: '',
houseLetter: '',
houseNumberAddition: '',
},
});

// full, correct schema
expectAssignable<AddressNLComponentSchema>({
id: 'yejak',
type: 'addressNL',
// basic tab
label: 'Some AddressNL',
key: 'someAddressNL',
description: '',
tooltip: 'A tooltip',
showInSummary: true,
showInEmail: false,
showInPDF: true,
hidden: false,
clearOnHide: true,
isSensitiveData: true,
// 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
});

// Non supported keys
expectNotAssignable<AddressNLComponentSchema>({
id: 'yejak',
type: 'addressNL',
key: 'someAddressNL',
label: 'Some AddressNL',
validateOn: 'change',
disabled: true,
placeholder: '',
hideLabel: true,
} as const);
2 changes: 1 addition & 1 deletion test-d/formio/components/email.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {expectAssignable, expectNotAssignable} from 'tsd';

import {EmailComponentSchema} from '../../../lib';

// minimal textfield component schema
// minimal email component schema
expectAssignable<EmailComponentSchema>({
id: 'yejak',
type: 'email',
Expand Down

0 comments on commit 3a95cef

Please sign in to comment.