{"version":3,"file":"ngwr-button.mjs","sources":["../../../projects/lib/button/tokens/button-group.token.ts","../../../projects/lib/button/button.ts","../../../projects/lib/button/button.html","../../../projects/lib/button/button-group.ts","../../../projects/lib/button/ngwr-button.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken, type Signal } from '@angular/core';\n\nimport type { WrButtonShape } from '../interfaces';\n\n/**\n * Contract a child `<wr-btn>` reads from its enclosing `<wr-btn-group>`.\n *\n * @internal\n */\nexport interface WrButtonGroupContext {\n  /** Shape cascade — child buttons fall back to this when they don't set their own. */\n  readonly shape: Signal<WrButtonShape | null>;\n}\n\n/**\n * Token a `<wr-btn>` injects to discover its parent `<wr-btn-group>`. The\n * group provides itself via this token so children can react to the\n * group's `shape` cascade.\n *\n * @internal\n */\nexport const WR_BUTTON_GROUP = new InjectionToken<WrButtonGroupContext>('WR_BUTTON_GROUP');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, inject, input } from '@angular/core';\n\nimport { WrIcon, type WrIconName } from 'ngwr/icon';\nimport { WrSpinner } from 'ngwr/spinner';\nimport type { WrColor } from 'ngwr/theme';\n\nimport type { WrButtonIconPosition, WrButtonShape, WrButtonSize } from './interfaces';\nimport { WR_BUTTON_GROUP } from './tokens';\n\n/**\n * Trigger an action. Renders as a `<wr-btn>` element, or attach to a\n * native `<button>` / `<a>` via the `wr-btn` attribute selector.\n *\n * @example\n * ```html\n * <button wr-btn color=\"primary\">Save</button>\n * <a wr-btn color=\"primary\" outlined>Cancel</a>\n * <wr-btn color=\"danger\" icon=\"trash\">Delete</wr-btn>\n * <wr-btn color=\"primary\" shape=\"pill\">Pill</wr-btn>\n * ```\n *\n * **Squircle?** Wrap with `[wrSquircle]` — the directive is the only\n * way ngwr ships smooth-corner clip-paths:\n *\n * ```html\n * <wr-btn wrSquircle [radius]=\"14\">Squircle</wr-btn>\n * ```\n *\n * Inside a `<wr-btn-group shape=\"…\">`, the group's shape is enforced on\n * every child — child `[shape]` inputs are ignored so the group reads as\n * one coherent control.\n *\n * @see https://ngwr.dev/components/button\n */\n@Component({\n  selector: 'wr-btn, button[wr-btn], a[wr-btn]',\n  templateUrl: './button.html',\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    '[class]': 'classes()',\n    '[attr.disabled]': 'nativeDisabled()',\n    '[attr.aria-busy]': 'loading() ? \"true\" : null',\n  },\n  imports: [WrIcon, WrSpinner],\n})\nexport class WrButton {\n  /** Color variant. Omit for the neutral default style. @default null */\n  readonly color = input<WrColor | null>(null);\n\n  /** Size variant. @default 'md' */\n  readonly size = input<WrButtonSize>('md');\n\n  /**\n   * Corner treatment — `rounded` or `pill`. `null` (default) falls back\n   * to `rounded`. Inside a `<wr-btn-group shape=\"…\">`, the group's shape\n   * ALWAYS wins over this input — the group enforces a consistent corner\n   * treatment across its members.\n   *\n   * @default null\n   */\n  readonly shape = input<WrButtonShape | null>(null);\n\n  /**\n   * Icon name to render alongside the label. The icon is hidden while\n   * `loading` is `true` so the spinner can take its place.\n   *\n   * @default null\n   */\n  readonly icon = input<WrIconName | null>(null);\n\n  /** Position of the icon relative to the label. @default 'start' */\n  readonly iconPosition = input<WrButtonIconPosition>('start');\n\n  /** Disable the button. @default false */\n  readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n  /** Outlined variant — colored text and border on a transparent background. @default false */\n  readonly outlined = input(false, { transform: coerceBooleanProperty });\n\n  /** Stretch the button to fill its parent's width. @default false */\n  readonly block = input(false, { transform: coerceBooleanProperty });\n\n  /** Show a spinner overlaying the label. Layout is preserved. @default false */\n  readonly loading = input(false, { transform: coerceBooleanProperty });\n\n  /**\n   * When `loading` is `true` and this is also `true`, pointer events are\n   * suppressed and the button reports as disabled to assistive tech.\n   *\n   * @default true\n   */\n  readonly isDisabledWhenLoading = input(true, { transform: coerceBooleanProperty });\n\n  private readonly group = inject(WR_BUTTON_GROUP, { optional: true });\n\n  /**\n   * Resolved shape. Inside a `<wr-btn-group>`, the group ALWAYS wins —\n   * child `[shape]` is ignored entirely so the group reads as one\n   * coherent control. Outside a group, the button's own `[shape]` is\n   * used, falling back to `rounded`.\n   */\n  protected readonly effectiveShape = computed<WrButtonShape>(() =>\n    this.group ? (this.group.shape() ?? 'rounded') : (this.shape() ?? 'rounded')\n  );\n\n  protected readonly nativeDisabled = computed<'' | null>(() => {\n    const off = this.disabled() || (this.loading() && this.isDisabledWhenLoading());\n    return off ? '' : null;\n  });\n\n  protected readonly classes = computed(() => {\n    const parts = ['wr-btn'];\n\n    const color = this.color();\n    if (color) parts.push(`wr-btn--${color}`);\n\n    const size = this.size();\n    if (size !== 'md') parts.push(`wr-btn--${size}`);\n\n    const shape = this.effectiveShape();\n    if (shape !== 'rounded') parts.push(`wr-btn--${shape}`);\n\n    if (this.outlined()) parts.push('wr-btn--outlined');\n    if (this.block()) parts.push('wr-btn--block');\n    if (this.loading()) parts.push('wr-btn--loading');\n\n    const hasAdornment = !!this.icon() || this.loading();\n    if (hasAdornment) parts.push(`wr-btn--icon-${this.iconPosition()}`);\n\n    return parts.join(' ');\n  });\n}\n","@if (loading()) {\n  <wr-spinner class=\"wr-btn__spin\" size=\"sm\" />\n}\n\n@if (icon(); as name) {\n  <wr-icon class=\"wr-btn__icon\" [name]=\"name\" />\n}\n\n<span class=\"wr-btn__label\">\n  <ng-content />\n</span>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, computed, forwardRef, input } from '@angular/core';\n\nimport type { WrButtonShape } from './interfaces';\nimport { WR_BUTTON_GROUP, type WrButtonGroupContext } from './tokens';\n\n/**\n * Visually group buttons by merging their borders. Optionally enforce a\n * single corner treatment across every child via `[shape]` — child\n * `<wr-btn>` `[shape]` inputs are ignored when set on the group.\n *\n * @example\n * ```html\n * <wr-btn-group>\n *   <button wr-btn>Left</button>\n *   <button wr-btn>Middle</button>\n *   <button wr-btn>Right</button>\n * </wr-btn-group>\n *\n * <wr-btn-group shape=\"pill\">\n *   <button wr-btn>One</button>\n *   <button wr-btn>Two</button>\n *   <button wr-btn>Three</button>\n * </wr-btn-group>\n * ```\n *\n * @see https://ngwr.dev/components/button-group\n */\n@Component({\n  selector: 'wr-btn-group',\n  template: '<ng-content />',\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    '[class]': 'hostClasses()',\n    role: 'group',\n  },\n  // forwardRef required: WrButtonGroup is self-referenced before its declaration ends.\n  // eslint-disable-next-line @angular-eslint/no-forward-ref\n  providers: [{ provide: WR_BUTTON_GROUP, useExisting: forwardRef(() => WrButtonGroup) }],\n})\nexport class WrButtonGroup implements WrButtonGroupContext {\n  /**\n   * Corner treatment enforced on every child `<wr-btn>`. Child `[shape]`\n   * inputs are ignored when this is set — the group exists to make a\n   * uniform control. `null` (default) leaves children alone.\n   *\n   * @default null\n   */\n  readonly shape = input<WrButtonShape | null>(null);\n\n  protected readonly hostClasses = computed(() => {\n    const parts = ['wr-btn-group'];\n    const s = this.shape();\n    if (s) parts.push(`wr-btn-group--${s}`);\n    return parts.join(' ');\n  });\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAgBH;;;;;;AAMG;AACI,MAAM,eAAe,GAAG,IAAI,cAAc,CAAuB,iBAAiB,CAAC;;AC5B1F;;;;;AAKG;AAYH;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MAYU,QAAQ,CAAA;;IAEV,KAAK,GAAG,KAAK,CAAiB,IAAI;8EAAC;;IAGnC,IAAI,GAAG,KAAK,CAAe,IAAI;6EAAC;AAEzC;;;;;;;AAOG;I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