From ac1fc1dcb244a5d3d9f91f8a5b691f5106674ff4 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:16:12 +0100 Subject: [PATCH 1/2] Rename `address` to `addressNL` --- .../components/{address.ts => addressNL.ts} | 8 +- src/formio/components/index.ts | 2 +- src/formio/index.ts | 4 +- test-d/formio/components/addressNL.test-d.ts | 78 +++++++++++++++++++ test-d/formio/components/email.test-d.ts | 2 +- 5 files changed, 86 insertions(+), 8 deletions(-) rename src/formio/components/{address.ts => addressNL.ts} (56%) create mode 100644 test-d/formio/components/addressNL.test-d.ts diff --git a/src/formio/components/address.ts b/src/formio/components/addressNL.ts similarity index 56% rename from src/formio/components/address.ts rename to src/formio/components/addressNL.ts index 32e5839..3e7e1ec 100644 --- a/src/formio/components/address.ts +++ b/src/formio/components/addressNL.ts @@ -10,13 +10,13 @@ export interface AddressData { houseNumberAddition: string; } -export type AddressInputSchema = InputComponentSchema; +export type AddressNLInputSchema = InputComponentSchema; /** * @group Form.io components * @category Concrete types */ -export interface AddressComponentSchema - extends Omit { - type: 'address'; +export interface AddressNLComponentSchema + extends Omit { + type: 'addressNL'; } diff --git a/src/formio/components/index.ts b/src/formio/components/index.ts index 70e30e5..331302f 100644 --- a/src/formio/components/index.ts +++ b/src/formio/components/index.ts @@ -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'; diff --git a/src/formio/index.ts b/src/formio/index.ts index 50b1679..549739f 100644 --- a/src/formio/index.ts +++ b/src/formio/index.ts @@ -1,5 +1,5 @@ import { - AddressComponentSchema, + AddressNLComponentSchema, BsnComponentSchema, CheckboxComponentSchema, ColumnsComponentSchema, @@ -69,7 +69,7 @@ export type AnyComponentSchema = | LicensePlateComponentSchema | BsnComponentSchema | NpFamilyMembersComponentSchema - | AddressComponentSchema + | AddressNLComponentSchema // layout | ContentComponentSchema | ColumnsComponentSchema diff --git a/test-d/formio/components/addressNL.test-d.ts b/test-d/formio/components/addressNL.test-d.ts new file mode 100644 index 0000000..00056c7 --- /dev/null +++ b/test-d/formio/components/addressNL.test-d.ts @@ -0,0 +1,78 @@ +import {expectAssignable, expectNotAssignable} from 'tsd'; + +import {AddressNLComponentSchema} from '../../../lib'; + +// minimal Address (NL) component schema +expectAssignable({ + id: 'yejak', + type: 'addressNL', + key: 'someAddressNL', + label: 'Some AddressNL', +}); + +// appropriate default value type +expectAssignable({ + id: 'yejak', + type: 'addressNL', + key: 'someAddressNL', + label: 'Some AddressNL', + defaultValue: { + postcode: '', + houseNumber: '', + houseLetter: '', + houseNumberAddition: '', + }, +}); + +// full, correct schema +expectAssignable({ + 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({ + id: 'yejak', + type: 'addressNL', + key: 'someAddressNL', + label: 'Some AddressNL', + validateOn: 'change', + disabled: true, + placeholder: '', + hideLabel: true, +}); diff --git a/test-d/formio/components/email.test-d.ts b/test-d/formio/components/email.test-d.ts index e69a5f8..0ada6a4 100644 --- a/test-d/formio/components/email.test-d.ts +++ b/test-d/formio/components/email.test-d.ts @@ -2,7 +2,7 @@ import {expectAssignable, expectNotAssignable} from 'tsd'; import {EmailComponentSchema} from '../../../lib'; -// minimal textfield component schema +// minimal address component schema expectAssignable({ id: 'yejak', type: 'email', From 8978bdfb16afb17bb1320ab6ad55eb7965352d1d Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Mon, 4 Dec 2023 15:23:10 +0100 Subject: [PATCH 2/2] PR feedback --- test-d/formio/components/addressNL.test-d.ts | 2 +- test-d/formio/components/email.test-d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test-d/formio/components/addressNL.test-d.ts b/test-d/formio/components/addressNL.test-d.ts index 00056c7..7f5727b 100644 --- a/test-d/formio/components/addressNL.test-d.ts +++ b/test-d/formio/components/addressNL.test-d.ts @@ -75,4 +75,4 @@ expectNotAssignable({ disabled: true, placeholder: '', hideLabel: true, -}); +} as const); diff --git a/test-d/formio/components/email.test-d.ts b/test-d/formio/components/email.test-d.ts index 0ada6a4..fe177b3 100644 --- a/test-d/formio/components/email.test-d.ts +++ b/test-d/formio/components/email.test-d.ts @@ -2,7 +2,7 @@ import {expectAssignable, expectNotAssignable} from 'tsd'; import {EmailComponentSchema} from '../../../lib'; -// minimal address component schema +// minimal email component schema expectAssignable({ id: 'yejak', type: 'email',