Skip to content

Commit

Permalink
✨ [#2] Remove multiple when not multipleCapable
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Oct 30, 2023
1 parent ce5b7b5 commit 5d55edd
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 42 deletions.
1 change: 0 additions & 1 deletion src/formio/components/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ export interface CheckboxComponentSchema
extends Omit<CheckboxInputSchema, 'hideLabel' | 'disabled'> {
type: 'checkbox';
defaultValue: boolean;
multiple?: false;
}
1 change: 0 additions & 1 deletion src/formio/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export * from './phonenumber';
export * from './postcode';
export * from './iban';
export * from './licenseplate';
export * from './radio';
export * from './number';
export * from './checkbox';
export * from './selectboxes';
Expand Down
1 change: 0 additions & 1 deletion src/formio/components/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export type RadioInputSchema = InputComponentSchema<string | null, Validator, Tr
interface BaseRadioSchema {
type: 'radio';
defaultValue: string | null;
multiple?: false;
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/formio/components/selectboxes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type SelectboxesInputSchema = InputComponentSchema<
interface BaseSelectboxesSchema {
type: 'selectboxes';
defaultValue: Record<string, boolean>;
multiple?: false;
}

/**
Expand Down
9 changes: 3 additions & 6 deletions src/formio/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@ export type AnyComponentSchema =
| PostcodeComponentSchema
| FileComponentSchema
| NumberComponentSchema
<<<<<<< HEAD
| CheckboxComponentSchema
| SelectboxesComponentSchema
| CurrencyComponentSchema
| RadioComponentSchema
// special types
| IbanComponentSchema
| LicensePlateComponentSchema
=======
| CheckboxComponentSchema
| SelectboxesComponentSchema
| RadioComponentSchema
>>>>>>> dab8ef2 ( [#2] Apply feedback and add `radio` component)
// layout
| ContentComponentSchema;

Expand Down
15 changes: 2 additions & 13 deletions test-d/formio/components/checkbox.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ expectAssignable<CheckboxComponentSchema>({
});


// multiple false and appropriate default value type
expectAssignable<CheckboxComponentSchema>({
id: 'yejak',
type: 'checkbox',
key: 'someCheckbox',
label: 'Some checkbox',
multiple: false,
defaultValue: true,
});

// full, correct schema
expectAssignable<CheckboxComponentSchema>({
id: 'yejak',
Expand All @@ -34,7 +24,6 @@ expectAssignable<CheckboxComponentSchema>({
showInSummary: true,
showInEmail: false,
showInPDF: true,
multiple: false,
hidden: false,
clearOnHide: true,
isSensitiveData: true,
Expand Down Expand Up @@ -66,13 +55,13 @@ expectAssignable<CheckboxComponentSchema>({
validateOn: 'blur',
});

// multiple true not allowed
// multiple not allowed
expectNotAssignable<CheckboxComponentSchema>({
id: 'yejak',
type: 'checkbox',
key: 'someCheckbox',
label: 'Some checkbox',
multiple: true,
multiple: 'dummy',
});

// defaultValue not allowed
Expand Down
21 changes: 2 additions & 19 deletions test-d/formio/components/selectboxes.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,12 @@ expectAssignable<SelectboxesComponentSchema>({
},
});

// multiple false and appropriate default value type
expectAssignable<SelectboxesComponentSchema>({
id: 'yejak',
type: 'selectboxes',
key: 'someSelectboxes',
label: 'Some selectboxes',
multiple: false,
defaultValue: {dummy: true},
openForms: {
dataSrc: 'variable',
itemsExpression: 'dummy',
translations: {},
},
});

// values translations
expectAssignable<SelectboxesComponentSchema>({
id: 'yejak',
type: 'selectboxes',
key: 'someSelectboxes',
label: 'Some selectboxes',
multiple: false,
defaultValue: {dummy: true},
openForms: {
dataSrc: 'manual',
Expand Down Expand Up @@ -92,7 +76,6 @@ expectAssignable<SelectboxesComponentSchema>({
showInSummary: true,
showInEmail: false,
showInPDF: true,
multiple: false,
hidden: false,
clearOnHide: true,
isSensitiveData: true,
Expand Down Expand Up @@ -134,13 +117,13 @@ expectNotAssignable<SelectboxesComponentSchema>({
label: 'Some selectboxes',
});

// multiple true not allowed
// multiple not allowed
expectNotAssignable<SelectboxesComponentSchema>({
id: 'yejak',
type: 'selectboxes',
key: 'someSelectboxes',
label: 'Some selectboxes',
multiple: true,
multiple: 'dummy',
openForms: {
dataSrc: 'variable',
itemsExpression: 'dummy',
Expand Down

0 comments on commit 5d55edd

Please sign in to comment.