UNPKG

@synergy-design-system/angular

Version:
233 lines (229 loc) 8.56 kB
import * as i0 from '@angular/core'; import { EventEmitter, Output, Input, Component } from '@angular/core'; import '@synergy-design-system/components/components/switch/switch.js'; // --------------------------------------------------------------------- // 🔒 AUTOGENERATED @synergy-design-system/angular wrappers for @synergy-design-system/components // Please do not edit this file directly! // It will get recreated when running pnpm build. // --------------------------------------------------------------------- /** * @summary Switches allow the user to toggle an option on or off. * @documentation https://synergy-design-system.github.io/?path=/docs/components-syn-switch--docs * @status stable * @since 2.0 * * @slot - The switch's label. * @slot help-text - Text that describes how to use the switch. Alternatively, you can use the `help-text` attribute. * * @event syn-blur - Emitted when the control loses focus. * @event syn-change - Emitted when the control's checked state changes. * @event syn-input - Emitted when the control receives input. * @event syn-focus - Emitted when the control gains focus. * @event syn-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied. * * @csspart base - The component's base wrapper. * @csspart control - The control that houses the switch's thumb. * @csspart thumb - The switch's thumb. * @csspart label - The switch's label. * @csspart form-control-help-text - The help text's wrapper. * * @cssproperty --width - The width of the switch. * @cssproperty --height - The height of the switch. * @cssproperty --thumb-size - The size of the thumb. */ class SynSwitchComponent { nativeElement; _ngZone; modelSignal = new AbortController(); constructor(e, ngZone) { this.nativeElement = e.nativeElement; this._ngZone = ngZone; this.nativeElement.addEventListener('syn-blur', (e) => { this.synBlurEvent.emit(e); }); this.nativeElement.addEventListener('syn-change', (e) => { this.synChangeEvent.emit(e); }); this.nativeElement.addEventListener('syn-input', (e) => { this.synInputEvent.emit(e); }); this.nativeElement.addEventListener('syn-focus', (e) => { this.synFocusEvent.emit(e); }); this.nativeElement.addEventListener('syn-invalid', (e) => { this.synInvalidEvent.emit(e); }); this.ngModelUpdateOn = 'syn-input'; } /** * The event that will trigger the ngModel update. * By default, this is set to "syn-input". */ set ngModelUpdateOn(v) { this.modelSignal.abort(); this.modelSignal = new AbortController(); const option = v || 'syn-input'; this.nativeElement.addEventListener(option, () => { this.checkedChange.emit(this.checked); }, { signal: this.modelSignal.signal, }); } get ngModelUpdateOn() { return this.ngModelUpdateOn; } set title(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.title = v)); } get title() { return this.nativeElement.title; } /** * The name of the switch, submitted as a name/value pair with form data. */ set name(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.name = v)); } get name() { return this.nativeElement.name; } /** * The current value of the switch, submitted as a name/value pair with form data. */ set value(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.value = v)); } get value() { return this.nativeElement.value; } /** * The switch's size. */ set size(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.size = v)); } get size() { return this.nativeElement.size; } /** * Disables the switch. */ set disabled(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.disabled = v === '' || v)); } get disabled() { return this.nativeElement.disabled; } /** * Draws the switch in a checked state. */ set checked(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.checked = v === '' || v)); } get checked() { return this.nativeElement.checked; } /** * By default, form controls are associated with the nearest containing `<form>` element. * This attribute allows you to place the form control outside of a form and associate it with the form that has this `id`. * The form must be in the same document or shadow root for this to work. */ set form(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.form = v)); } get form() { return this.nativeElement.form; } /** * Makes the switch a required field. */ set required(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.required = v === '' || v)); } get required() { return this.nativeElement.required; } /** * The switch's help text. * If you need to display HTML, use the `help-text` slot instead. */ set helpText(v) { this._ngZone.runOutsideAngular(() => (this.nativeElement.helpText = v)); } get helpText() { return this.nativeElement.helpText; } /** * Emitted when the control loses focus. */ synBlurEvent = new EventEmitter(); /** * Emitted when the control's checked state changes. */ synChangeEvent = new EventEmitter(); /** * Emitted when the control receives input. */ synInputEvent = new EventEmitter(); /** * Emitted when the control gains focus. */ synFocusEvent = new EventEmitter(); /** * Emitted when the form control has been checked for validity and its constraints aren't satisfied. */ synInvalidEvent = new EventEmitter(); /** * Support for two way data binding */ checkedChange = new EventEmitter(); static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.1", ngImport: i0, type: SynSwitchComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.1", type: SynSwitchComponent, isStandalone: true, selector: "syn-switch", inputs: { ngModelUpdateOn: "ngModelUpdateOn", title: "title", name: "name", value: "value", size: "size", disabled: "disabled", checked: "checked", form: "form", required: "required", helpText: "helpText" }, outputs: { synBlurEvent: "synBlurEvent", synChangeEvent: "synChangeEvent", synInputEvent: "synInputEvent", synFocusEvent: "synFocusEvent", synInvalidEvent: "synInvalidEvent", checkedChange: "checkedChange" }, ngImport: i0, template: '<ng-content></ng-content>', isInline: true }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.1", ngImport: i0, type: SynSwitchComponent, decorators: [{ type: Component, args: [{ selector: 'syn-switch', standalone: true, template: '<ng-content></ng-content>', }] }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.NgZone }], propDecorators: { ngModelUpdateOn: [{ type: Input }], title: [{ type: Input }], name: [{ type: Input }], value: [{ type: Input }], size: [{ type: Input }], disabled: [{ type: Input }], checked: [{ type: Input }], form: [{ type: Input }], required: [{ type: Input }], helpText: [{ type: Input }], synBlurEvent: [{ type: Output }], synChangeEvent: [{ type: Output }], synInputEvent: [{ type: Output }], synFocusEvent: [{ type: Output }], synInvalidEvent: [{ type: Output }], checkedChange: [{ type: Output }] } }); /** * Generated bundle index. Do not edit. */ export { SynSwitchComponent }; //# sourceMappingURL=synergy-design-system-angular-components-switch.mjs.map