Skip to content

Commit

Permalink
✨ [#2] Implement types for checkbox and checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Oct 24, 2023
1 parent 05ae49a commit 55c133e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/formio/components/checkbox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {InputComponentSchema} from '..';

type Validator = 'required';
type TranslatableKeys = 'label' | 'description' | 'tooltip';

export type CheckboxInputSchema = InputComponentSchema<string, Validator, TranslatableKeys>;

/**
* @group Form.io components
* @category Concrete types
*/
export interface CheckboxComponentSchema
extends Omit<CheckboxInputSchema, 'hideLabel' | 'disabled'> {
type: 'checkbox';
}
2 changes: 2 additions & 0 deletions src/formio/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Input components
export * from './checkbox';
export * from './textfield';
export * from './email';
export * from './date';
export * from './datetime';
export * from './time';
export * from './phonenumber';
export * from './postcode';
export * from './selectboxes';
export * from './number';
export * from './file';

Expand Down
18 changes: 18 additions & 0 deletions src/formio/components/selectboxes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {InputComponentSchema} from '..';

type Validator = 'required';
type TranslatableKeys = 'label' | 'description' | 'tooltip';

export type SelectboxesInputSchema = InputComponentSchema<string, Validator, TranslatableKeys>;

/**
* @group Form.io components
* @category Concrete types
*/
export interface SelectboxesComponentSchema
extends Omit<SelectboxesInputSchema, 'hideLabel' | 'disabled'> {
type: 'selectboxes';
// OF custom properties
dataSrc: 'manual' | 'variable';
itemsExpression?: string;
}
4 changes: 4 additions & 0 deletions src/formio/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
CheckboxComponentSchema,
ContentComponentSchema,
DateComponentSchema,
DateTimeComponentSchema,
Expand All @@ -7,6 +8,7 @@ import {
NumberComponentSchema,
PhoneNumberComponentSchema,
PostcodeComponentSchema,
SelectboxesComponentSchema,
TextFieldComponentSchema,
TimeComponentSchema,
} from './components';
Expand Down Expand Up @@ -37,12 +39,14 @@ export * from './components';
export type AnyComponentSchema =
// inputs
| TextFieldComponentSchema
| CheckboxComponentSchema
| EmailComponentSchema
| DateComponentSchema
| DateTimeComponentSchema
| TimeComponentSchema
| PhoneNumberComponentSchema
| PostcodeComponentSchema
| SelectboxesComponentSchema
| FileComponentSchema
| NumberComponentSchema
// layout
Expand Down

0 comments on commit 55c133e

Please sign in to comment.