diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.component.ts b/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.component.ts index d0100569b..cdfa1504b 100644 --- a/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.component.ts +++ b/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.component.ts @@ -15,22 +15,7 @@ import { coerceNumberProperty, } from "@angular/cdk/coercion"; import { BackgroundProviderService } from "../background-provider/service/background-provider.service"; - -type Space = - | "xxsmall" - | "xsmall" - | "small" - | "medium" - | "large" - | "xlarge" - | "xxlarge"; - -type Margin = { - top?: Space; - bottom?: Space; - left?: Space; - right?: Space; -}; +import { Space, Spacing, SwitchProperties } from "./dxc-switch.types"; @Component({ selector: "dxc-switch", @@ -94,11 +79,12 @@ export class DxcSwitchComponent implements OnChanges { * Size of the margin to be applied to the component ('xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge'). * You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes. */ - @Input() margin: Space | Margin; + @Input() margin: Space | Spacing; /** * Size of the component. */ - @Input() size: "small" | "medium" | "large" | "fillParent" | "fitContent" = "fitContent"; + @Input() size: "small" | "medium" | "large" | "fillParent" | "fitContent" = + "fitContent"; /** * Value of the tabindex. */ @@ -111,14 +97,14 @@ export class DxcSwitchComponent implements OnChanges { } private _tabIndexValue = 0; /** - * This event will be emitted when the user changes the state of the switch. + * This event will be emitted when the user changes the state of the switch. * The new value of the checked property will be passed as a parameter. */ @Output() onChange: EventEmitter; renderedChecked: boolean; - defaultInputs = new BehaviorSubject({ + defaultInputs = new BehaviorSubject({ value: null, checked: false, disabled: false, diff --git a/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.types.ts b/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.types.ts new file mode 100644 index 000000000..3e0243dab --- /dev/null +++ b/projects/dxc-ngx-cdk/src/lib/dxc-switch/dxc-switch.types.ts @@ -0,0 +1,28 @@ +export interface SwitchProperties { + margin?: Space | Spacing; + checked?: boolean; + value?: string; + disabled?: boolean; + required?: boolean; + label?: string; + name?: string; + labelPosition?: "before" | "after"; + size?: "small" | "medium" | "large" | "fillParent" | "fitContent"; + tabIndexValue?: number; +} + +export type Space = + | "xxsmall" + | "xsmall" + | "small" + | "medium" + | "large" + | "xlarge" + | "xxlarge"; + +export type Spacing = { + top?: Space; + bottom?: Space; + left?: Space; + right?: Space; +};