{"version":3,"file":"primeng-selectbutton.mjs","sources":["../../src/app/components/selectbutton/selectbutton.ts","../../src/app/components/selectbutton/primeng-selectbutton.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, EventEmitter, Input, NgModule, Output, TemplateRef, ViewEncapsulation, forwardRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { LicenseManager } from 'primeng/api';\nimport { RippleModule } from 'primeng/ripple';\nimport { ObjectUtils } from 'primeng/utils';\n\nexport const SELECTBUTTON_VALUE_ACCESSOR: any = {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => SelectButton),\n multi: true\n};\n\n@Component({\n selector: 'p-selectButton',\n template: `\n
\n \n \n \n {{ getOptionLabel(option) }}\n \n \n \n \n
\n \n `,\n providers: [SELECTBUTTON_VALUE_ACCESSOR],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['../button/button.css'],\n host: {\n class: 'p-element'\n }\n})\nexport class SelectButton implements ControlValueAccessor, AfterViewInit {\n @Input() options: any[];\n\n @Input() optionLabel: string;\n\n @Input() optionValue: string;\n\n @Input() optionDisabled: string;\n\n @Input() tabindex: number = 0;\n\n @Input() multiple: boolean;\n\n @Input() style: any;\n\n @Input() styleClass: string;\n\n @Input() ariaLabelledBy: string;\n\n @Input() disabled: boolean;\n\n @Input() dataKey: string;\n\n @Output() onOptionClick: EventEmitter = new EventEmitter();\n\n @Output() onChange: EventEmitter = new EventEmitter();\n\n @ContentChild(TemplateRef) itemTemplate;\n\n value: any;\n\n onModelChange: Function = () => {};\n\n onModelTouched: Function = () => {};\n\n constructor(public cd: ChangeDetectorRef) {}\n\n ngAfterViewInit() {\n LicenseManager.check();\n }\n\n getOptionLabel(option: any) {\n return this.optionLabel ? ObjectUtils.resolveFieldData(option, this.optionLabel) : option.label != undefined ? option.label : option;\n }\n\n getOptionValue(option: any) {\n return this.optionValue ? ObjectUtils.resolveFieldData(option, this.optionValue) : this.optionLabel || option.value === undefined ? option : option.value;\n }\n\n isOptionDisabled(option: any) {\n return this.optionDisabled ? ObjectUtils.resolveFieldData(option, this.optionDisabled) : option.disabled !== undefined ? option.disabled : false;\n }\n\n writeValue(value: any): void {\n this.value = value;\n this.cd.markForCheck();\n }\n\n registerOnChange(fn: Function): void {\n this.onModelChange = fn;\n }\n\n registerOnTouched(fn: Function): void {\n this.onModelTouched = fn;\n }\n\n setDisabledState(val: boolean): void {\n this.disabled = val;\n this.cd.markForCheck();\n }\n\n onItemClick(event, option: any, index: number) {\n if (this.disabled || this.isOptionDisabled(option)) {\n return;\n }\n\n if (this.multiple) {\n if (this.isSelected(option)) this.removeOption(option);\n else this.value = [...(this.value || []), this.getOptionValue(option)];\n\n this.onModelChange(this.value);\n\n this.onChange.emit({\n originalEvent: event,\n value: this.value\n });\n } else {\n let value = this.getOptionValue(option);\n\n if (this.value !== value) {\n this.value = this.getOptionValue(option);\n this.onModelChange(this.value);\n\n this.onChange.emit({\n originalEvent: event,\n value: this.value\n });\n }\n }\n\n this.onOptionClick.emit({\n originalEvent: event,\n option: option,\n index: index\n });\n }\n\n onBlur() {\n this.onModelTouched();\n }\n\n removeOption(option: any): void {\n this.value = this.value.filter((val) => !ObjectUtils.equals(val, this.getOptionValue(option), this.dataKey));\n }\n\n isSelected(option: any) {\n let selected = false;\n let optionValue = this.getOptionValue(option);\n\n if (this.multiple) {\n if (this.value && Array.isArray(this.value)) {\n for (let val of this.value) {\n if (ObjectUtils.equals(val, optionValue, this.dataKey)) {\n selected = true;\n break;\n }\n }\n }\n } else {\n selected = ObjectUtils.equals(this.getOptionValue(option), this.value, this.dataKey);\n }\n\n return selected;\n }\n}\n\n@NgModule({\n imports: [CommonModule, RippleModule],\n exports: [SelectButton],\n declarations: [SelectButton]\n})\nexport class SelectButtonModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport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