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

Rename address to addressNL #34

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
});
Viicos marked this conversation as resolved.
Show resolved Hide resolved
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 address component schema
sergei-maertens marked this conversation as resolved.
Show resolved Hide resolved
expectAssignable<EmailComponentSchema>({
id: 'yejak',
type: 'email',
Expand Down