1 line
13 KiB
Plaintext
1 line
13 KiB
Plaintext
|
{"version":3,"file":"primeng-togglebutton.mjs","sources":["../../src/app/components/togglebutton/togglebutton.ts","../../src/app/components/togglebutton/primeng-togglebutton.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { booleanAttribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, EventEmitter, forwardRef, Input, NgModule, numberAttribute, Output, QueryList, TemplateRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { RippleModule } from 'primeng/ripple';\nimport { ToggleButtonChangeEvent } from './togglebutton.interface';\nimport { Nullable } from 'primeng/ts-helpers';\nimport { PrimeTemplate, SharedModule } from 'primeng/api';\nimport { AutoFocusModule } from 'primeng/autofocus';\n\ntype ToggleButtonIconPosition = 'left' | 'right';\n\nexport const TOGGLEBUTTON_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => ToggleButton),\n multi: true\n};\n/**\n * ToggleButton is used to select a boolean value using a button.\n * @group Components\n */\n@Component({\n selector: 'p-toggleButton',\n template: `\n <div\n [ngClass]=\"{ 'p-togglebutton p-button p-component': true, 'p-button-icon-only': onIcon && offIcon && !hasOnLabel && !hasOffLabel, 'p-highlight': checked, 'p-disabled': disabled }\"\n [ngStyle]=\"style\"\n [class]=\"styleClass\"\n (click)=\"toggle($event)\"\n (keydown)=\"onKeyDown($event)\"\n [attr.tabindex]=\"disabled ? null : tabindex\"\n role=\"switch\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-labelledby]=\"ariaLabelledBy\"\n [attr.aria-label]=\"ariaLabel\"\n pRipple\n [attr.data-pc-name]=\"'togglebutton'\"\n [attr.data-pc-section]=\"'root'\"\n pAutoFocus\n [autofocus]=\"autofocus\"\n >\n @if(!iconTemplate) {\n <span\n *ngIf=\"onIcon || offIcon\"\n [class]=\"checked ? this.onIcon : this.offIcon\"\n [ngClass]=\"{ 'p-button-icon': true, 'p-button-icon-left': iconPos === 'left', 'p-button-icon-right': iconPos === 'right' }\"\n [attr.data-pc-section]=\"'icon'\"\n ></span>\n } @else {\n <ng-container *ngTemplateOutlet=\"iconTemplate; context: { $implicit: checked }\"></ng-container>\n }\n <span class=\"p-button-label\" *ngIf=\"onLabel || offLabel\" [attr.data-pc-section]=\"'label'\">{{ checked ? (hasOnLabel ? onLabel : '') : hasOffLabel ? offLabel : '' }}</span>\n </div>\n `,\n providers: [TOGGLEBUTTON_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n styleUrls: ['../button/button.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class ToggleButton implements ControlValueAccessor {\n /**\n * Label for the on state.\n * @group Props\n */\n @Input() onLabel: string | undefined;\n /**\n * Label for the off state.\n * @group Props\n */\n @Input() offLabel: string | undefined;\n /**\n * Icon for the on state.\n * @group Props\n */\n @Input() onIcon: string | undefined;\n /**\n * Icon for the off state.\n * @group Props\n */\n @Input() offIcon: string | undefined;\n /**\n * Defines a string that labels the input for accessibility.\n * @group Props\n */\n @Input() ariaLabel: string | undefined;\n /**\n * Establishes relationships between the component and label(s) where its value should be one or more element IDs.\n * @group Props\n */\n @Input() ariaLabelledBy: string | undefined;\n /**\n * When present, it specifies that the element should be disabled.\n * @group Props\n */\n @Input({ transform: booleanAttribute }) disabled: boolean | undefined;\n /**\n * Inline style of the element.\n * @group Props\n */\n @Input() style: any;\n /**\n
|