{"version":3,"file":"ng-forge-dynamic-forms-bootstrap-lazy-select.mjs","mappings":";;;;;;;AA0Dc;;;;AAIH;;AAET;;AAGE;AAEA;AACE;;;;;AAZe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAVlB;;;;AAvCS","names":[],"ignoreList":[],"sources":["../../../../packages/dynamic-forms-bootstrap/src/lib/fields/select/bs-select.component.ts"],"sourcesContent":["import { ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport { FormField } from '@angular/forms/signals';\nimport { FieldOption } from '@ng-forge/dynamic-forms';\nimport { DynamicTextPipe } from '@ng-forge/dynamic-forms/integration';\nimport { NgForgeControl, injectNgForgeField, NgForgeFieldHost } from '@ng-forge/dynamic-forms/integration';\nimport { BsSelectProps } from './bs-select.type';\nimport { AsyncPipe } from '@angular/common';\n\n@Component({\n  selector: 'df-bs-select',\n  imports: [FormField, DynamicTextPipe, AsyncPipe, NgForgeControl],\n  styleUrl: '../../styles/_form-field.scss',\n  hostDirectives: [NgForgeFieldHost],\n  template: `\n    @let f = ngf.field(); @let selectId = ngf.key() + '-select';\n\n    <div class=\"mb-3\">\n      @if (ngf.label(); as label) {\n        <label [for]=\"selectId\" class=\"form-label\">{{ label | dynamicText | async }}</label>\n      }\n      <select\n        ngForgeControl\n        [formField]=\"f\"\n        [id]=\"selectId\"\n        [attr.tabindex]=\"ngf.tabIndex()\"\n        class=\"form-select\"\n        [class.form-select-sm]=\"props()?.size === 'sm'\"\n        [class.form-select-lg]=\"props()?.size === 'lg'\"\n        [class.is-invalid]=\"f().invalid() && f().touched()\"\n        [multiple]=\"props()?.multiple || false\"\n        [attr.size]=\"props()?.htmlSize ?? null\"\n      >\n        @if (ngf.placeholder(); as placeholder) {\n          <option value=\"\" disabled [selected]=\"!f().value()\">{{ placeholder | dynamicText | async }}</option>\n        }\n        @for (option of options(); track option.value) {\n          <option [value]=\"option.value\" [disabled]=\"option.disabled || false\" [selected]=\"isSelected(option.value, f().value())\">\n            {{ option.label | dynamicText | async }}\n          </option>\n        }\n      </select>\n\n      @if (ngf.errorsToDisplay()[0]; as error) {\n        <div class=\"invalid-feedback d-block\" [id]=\"ngf.errorId()\" role=\"alert\">{{ error.message }}</div>\n      } @else if (props()?.hint; as hint) {\n        <div class=\"form-text\" [id]=\"ngf.hintId()\">{{ hint | dynamicText | async }}</div>\n      }\n    </div>\n  `,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  styles: [\n    `\n      :host([hidden]) {\n        display: none !important;\n      }\n    `,\n  ],\n})\nexport default class BsSelectFieldComponent {\n  protected readonly ngf = injectNgForgeField<string>();\n\n  readonly options = input<FieldOption<string>[]>([]);\n  readonly props = input<BsSelectProps>();\n\n  defaultCompare = Object.is;\n\n  protected isSelected(optionValue: string, fieldValue: string | string[] | null): boolean {\n    const compareWith = this.props()?.compareWith || this.defaultCompare;\n\n    if (Array.isArray(fieldValue)) {\n      return fieldValue.some((v) => compareWith(v, optionValue));\n    }\n\n    return fieldValue !== null && compareWith(fieldValue, optionValue);\n  }\n}\n"]}