{"version":3,"file":"talenra-ngx-base-button.mjs","sources":["../../../projects/ngx-base/button/src/button/button.types.ts","../../../projects/ngx-base/button/src/button/button.component.ts","../../../projects/ngx-base/button/src/button/button.component.html","../../../projects/ngx-base/button/talenra-ngx-base-button.ts"],"sourcesContent":["/**\n * Values accepted by the `ButtonComponent`'s `kind` property.\n *\n * ```html\n * <button talenra-button label=\"Label\" kind=\"secondary\"></button>\n * ```\n *\n * ### Import\n *\n * ```typescript\n * import { ButtonKind } from '@talenra/ngx-base/button';\n * ```\n *\n * @see {@link ButtonComponent}\n */\nexport const ButtonKind = {\n  Ghost: 'ghost',\n  Primary: 'primary',\n  Secondary: 'secondary',\n} as const;\n\n/**\n * Type of values accepted by the `ButtonComponent`'s `kind` property.\n *\n * ### Import\n *\n * ```typescript\n * import { TButtonKind } from '@talenra/ngx-base/button';\n * ```\n *\n * @see {@link ButtonComponent}\n */\nexport type TButtonKind = (typeof ButtonKind)[keyof typeof ButtonKind];\n\n/**\n * Values accepted by the `ButtonComponent`'s `size` property.\n *\n * ```html\n * <button talenra-button label=\"Label\" size=\"s\"></button>\n * ```\n *\n * ### Import\n *\n * ```typescript\n * import { ButtonSize } from '@talenra/ngx-base/button';\n * ```\n *\n * @see {@link ButtonComponent}\n * @see {@link ButtonKind}\n */\nexport const ButtonSize = {\n  S: 's',\n  M: 'm',\n} as const;\n\n/**\n * Type of values accepted by the `ButtonComponent`'s `size` property.\n *\n * ### Import\n *\n * ```typescript\n * import { TButtonSize } from '@talenra/ngx-base/button';\n * ```\n *\n * @see {@link ButtonComponent}\n * @see {@link ButtonSize}\n */\nexport type TButtonSize = (typeof ButtonSize)[keyof typeof ButtonSize];\n","import { ChangeDetectionStrategy, Component, ElementRef, booleanAttribute, inject, input } from '@angular/core';\nimport { IconComponent } from '@talenra/ngx-base/icons';\nimport { deprecationWarning } from '@talenra/ngx-base/dev-kit';\nimport { ButtonKind, ButtonSize, TButtonKind, TButtonSize } from './button.types';\n\n/**\n * Button in different sizes and style variants.\n *\n * ```html\n * <button talenra-button label=\"Button Label\"></button>\n * <button talenra-button label=\"Submit\" kind=\"secondary\" size=\"s\" disabled type=\"submit\"></button>\n * ```\n *\n * ## Label\n *\n * If a Button's width is limited (e.g by CSS or a parent element), the label is truncated as required (using ellipsis).\n *\n * - **DO** use input property `label` to set the Button's label.\n * - **DO NOT** inject text to the button element to set the Button's label.\n * - **DO NOT** inject HTML child elements as the result will most probably not comply with the style guide.\n *\n * ## Kind\n *\n * The button's kind determines its visual style.\n *\n * - primary → default, e.g. \"submit\"\n * - secondary → secondary action, e.g. \"cancel\"\n * - ghost → no background, e.g. icon-only buttons\n *\n * ## Size\n *\n * The button's size determines its height and font-size.\n *\n * - m → medium (default)\n * - s → small\n *\n * ## Icon\n *\n * Buttons can have an optional icon. If used in combination with a label, the icon is always placed on the left side of\n * the label.\n *\n * ```html\n * <button talenra-button label=\"Reload\" icon=\"refresh\"></button>\n * ```\n *\n * To render an icon-only button, just omit the label text. The icon will be rendered in the center of the button.\n *\n * ```html\n * <button talenra-button size=\"s\" icon=\"refresh\"></button>\n * ```\n *\n * ## Waiting (Spinner)\n *\n * While `waiting` is true, the button's label and icon are hidden and a loading indicator (spinner) is presented to the\n * user instead.\n *\n * ```html\n * <button talenra-button label=\"My Label\" waiting></button>\n * <button talenra-button label=\"My Label\" [waiting]=\"myCondition\"></button>\n * ```\n *\n * ### Import\n *\n * ```typescript\n * import { ButtonComponent } from '@talenra/ngx-base/button';\n * ```\n *\n * <example-url>../../#/button</example-url>\n */\n@Component({\n  selector: 'button[talenra-button]',\n  templateUrl: './button.component.html',\n  styleUrls: ['./button.component.scss', './loading-indicator.scss'],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  host: {\n    '[disabled]': 'disabled()',\n    '[class.waiting]': 'waiting()',\n    '[class.has-icon]': '!!icon()',\n    '[class.icon-only]': 'icon() && !label()',\n    '[class]': '`size--${this.size()} kind--${this.kind()}`',\n  },\n  imports: [IconComponent],\n})\nexport class ButtonComponent {\n  /**\n   * Prevents the user from interacting with the button: it cannot be pressed or focused.\n   *\n   * \"Why don't you use the button element's native `disabled` attribute?\" — We favour the\n   * input property as the native attribute can be quirky to set dynamically (cmp. example below).\n   *\n   * @example\n   * <!-- DO use the input property -->\n   * <button talenra-button disabled>\n   * <button talenra-button [disabled]=\"myCondition\">\n   *\n   * <!-- DON'T use the element's disabled attribute -->\n   * <button talenra-button [attr.disabled]=\"condition ? 'disabled' : null\">\n   */\n  public disabled = input<boolean, unknown>(false, { transform: booleanAttribute });\n\n  /**\n   * Determines the visual kind of button to be rendered.\n   *\n   * @example\n   * <button talenra-button label=\"Label\" kind=\"secondary\"></button>\n   *\n   * @see {@link ButtonKind}\n   */\n  public kind = input<TButtonKind>(ButtonKind.Primary);\n\n  /**\n   * Determines the size or the \"visual weight\" of the button. Currently affects the\n   * button's height only.\n   *\n   * @example\n   * <button talenra-button label=\"Label\" size=\"s\"></button>\n   *\n   * @see {@link ButtonSize}\n   */\n  public size = input<TButtonSize>(ButtonSize.M);\n\n  /**\n   * The button's label presented to the user.\n   *\n   * @example\n   * <button talenra-button label=\"My Label\"></button>\n   */\n  public label = input<string>('');\n\n  /**\n   * While `waiting` is true, the button's label and icon are hidden and a loading\n   * indicator (spinner) is presented to the user instead.\n   *\n   * @example\n   * <button talenra-button label=\"Label\" waiting></button>\n   * <button talenra-button label=\"Label\" [waiting]=\"myCondition\"></button>\n   */\n  public waiting = input<boolean, unknown>(false, { transform: booleanAttribute });\n\n  /**\n   * The name of the icon to be rendered. e.g. `refresh`. Check `@talenra/icons` for a list of all icons available.\n   *\n   * @example\n   * <button talenra-button label=\"Refresh\" icon=\"refresh\"></button>\n   *\n   * Omit the label text to render an icon-only button:\n   * @example\n   * <button talenra-button icon=\"refresh\"></button>\n   *\n   * @see {@link IconComponent}\n   */\n  public icon = input<string>('');\n\n  /**\n   * Returns whether the button is currently focussed.\n   *\n   * @deprecated Get in touch with us if you require this feature.\n   */\n  public get hasFocus(): boolean {\n    deprecationWarning({\n      submodule: 'button',\n      className: this.constructor.name,\n      member: 'Property `hasFocus`',\n      instructions: 'Please get in touch with us if you think we should keep support for `hasFocus`.',\n    });\n    return this.elementRef.nativeElement === document.activeElement;\n  }\n\n  private elementRef = inject(ElementRef);\n\n  /** Sets the focus to the button. */\n  public focus(): void {\n    this.elementRef.nativeElement.focus();\n  }\n}\n","@if (label()) {\n  <span class=\"label\">{{ label() }}</span>\n}\n@if (icon()) {\n  <talenra-icon class=\"icon\" [name]=\"icon()\" />\n}\n<div class=\"spinner\">\n  <div class=\"indicator\">\n    <div></div>\n    <div></div>\n    <div></div>\n    <div></div>\n  </div>\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;AAcG;AACU,MAAA,UAAU,GAAG;AACxB,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,SAAS,EAAE,WAAW;;AAgBxB;;;;;;;;;;;;;;;AAeG;AACU,MAAA,UAAU,GAAG;AACxB,IAAA,CAAC,EAAE,GAAG;AACN,IAAA,CAAC,EAAE,GAAG;;;AC/CR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DG;MAeU,eAAe,CAAA;AAd5B,IAAA,WAAA,GAAA;AAeE;;;;;;;;;;;;;AAaG;QACI,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAmB,KAAK,EAAE,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;AAEjF;;;;;;;AAOG;AACI,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAc,UAAU,CAAC,OAAO,CAAC;AAEpD;;;;;;;;AAQG;AACI,QAAA,IAAA,CAAA,IAAI,GAAG,KAAK,CAAc,UAAU,CAAC,CAAC,CAAC;AAE9C;;;;;AAKG;AACI,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAS,EA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