{"version":3,"file":"daffodil-design-switch.mjs","names":[],"sources":["../../../libs/design/switch/src/switch/label-position.ts","../../../libs/design/switch/src/switch/switch.component.ts","../../../libs/design/switch/src/switch/switch.component.html","../../../libs/design/switch/src/switch.ts"],"sourcesContent":["export type DaffSwitchLabelPosition = 'left' | 'right' | 'top' | 'bottom';\n\n/**\n * The position of the label relative to the switch.\n */\nexport enum DaffSwitchLabelPositionEnum {\n  LEFT = 'left',\n  RIGHT = 'right',\n  TOP = 'top',\n  BOTTOM = 'bottom',\n}\n","import { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport {\n  ChangeDetectionStrategy,\n  Component,\n  Input,\n  input,\n  model,\n  output,\n} from '@angular/core';\n\nimport {\n  DaffDisableable,\n  DaffDisableableDirective,\n  DaffSizableDirective,\n  DaffSizeSmallType,\n} from '@daffodil/design';\n\nimport {\n  DaffSwitchLabelPosition,\n  DaffSwitchLabelPositionEnum,\n} from './label-position';\n\nlet switchIncrementalId = 0;\n\nexport type DaffSwitchSize = DaffSizeSmallType;\n\n/**\n * The switch component provides a way to toggle between two settings.\n *\n * ```html\n * <daff-switch>Label</daff-switch>\n * ```\n */\n@Component({\n  selector: 'daff-switch',\n  templateUrl: './switch.component.html',\n  styleUrl: './switch.component.scss',\n  hostDirectives: [\n    {\n      directive: DaffSizableDirective,\n      inputs: ['size'],\n    },\n    {\n      directive: DaffDisableableDirective,\n      inputs: ['disabled'],\n    },\n  ],\n  host: {\n    class: 'daff-switch',\n    '[class.checked]': 'checked()',\n    '[class.left]': 'labelPosition() === \"left\"',\n    '[class.right]': 'labelPosition() === \"right\"',\n    '[class.top]': 'labelPosition() === \"top\"',\n    '[class.bottom]': 'labelPosition() === \"bottom\"',\n  },\n  changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class DaffSwitchComponent extends DaffSizableDirective<DaffSwitchSize> implements DaffDisableable {\n  /**\n   * The position of the label relative to the switch.\n   */\n  labelPosition = input<DaffSwitchLabelPosition>(DaffSwitchLabelPositionEnum.LEFT);\n\n  constructor(private disabledDirective: DaffDisableableDirective) {\n    super();\n  }\n\n  /**\n   * Whether the switch is disabled.\n   */\n  @Input() get disabled() {\n    return this.disabledDirective.disabled();\n  }\n  set disabled(value: any) {\n    this.disabledDirective.disabled.set(coerceBooleanProperty(value));\n  }\n\n  /**\n   * Current state of switch (on/off).\n   */\n  checked = model(false);\n\n  /**\n   * @docs-private\n   */\n  labelId: string = 'daff-switch-' + switchIncrementalId++ + '-label';\n\n  /**\n   * The unique id of the switch. Defaults to an autogenerated value. When using this,\n   * it's your responsibility to ensure that the id for each switch is unique.\n   *\n   * It gets assigned to the `for` attribute on the `<label>` inside of the switch.\n   */\n  id = input('daff-switch-' + switchIncrementalId++);\n\n  /**\n   * Output event triggered when the switch has been toggled.\n   */\n  toggled = output<boolean>();\n\n  /**\n   * @docs-private\n   */\n  onToggle() {\n    if (!this.disabled) {\n      this.checked.set(!this.checked());\n      this.toggled.emit(this.checked());\n    }\n  }\n}\n","<label class=\"daff-switch__label\" [id]=\"labelId\" [for]=\"id()\">\n  <ng-content></ng-content>\n</label>\n\n<button class=\"daff-switch__toggle\"\n  type=\"button\"\n  role=\"switch\"\n  (click)=\"onToggle()\"\n  [attr.disabled]=\"disabled ? '' : null\"\n  [attr.aria-checked]=\"checked() ? true : false\"\n  [attr.aria-labelledby]=\"labelId\"\n  [attr.id]=\"id()\">\n</button>","import { DaffSwitchComponent } from './switch/switch.component';\n\n/**\n * @docs-private\n */\nexport const DAFF_SWITCH_COMPONENTS = <const> [\n  DaffSwitchComponent,\n];\n"],"mappings":";;;;;AAKA,IAAY;CAAZ,SAAY,6BAA2B;CACrC,4BAAA,UAAA;CACA,4BAAA,WAAA;CACA,4BAAA,SAAA;CACA,4BAAA,YAAA;AACF,EAAA,CALY,gCAAA,8BAA2B,CAAA,EAAA;ACiBvC,IAAI,sBAAsB;AAmC1B,IAAa,sBAAb,MAAa,4BAA4B,qBAAoC;CAM3E,YAAoB,mBAA2C;EAC7D,MAA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