{"version":3,"file":"ngwr-stepper.mjs","sources":["../../../projects/lib/stepper/tokens.ts","../../../projects/lib/stepper/step.ts","../../../projects/lib/stepper/stepper.ts","../../../projects/lib/stepper/stepper.html","../../../projects/lib/stepper/ngwr-stepper.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\n/** Surface a {@link WrStepper} provides for its child `<wr-step>`s. */\nexport interface WrStepperContext {\n  /** Index of the currently visible step. */\n  readonly active: Signal<number>;\n  /** Linear mode — steps after the latest completed one are locked. */\n  readonly linear: Signal<boolean>;\n}\n\nexport const WR_STEPPER = new InjectionToken<WrStepperContext>('WR_STEPPER');\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, signal } from '@angular/core';\n\nimport { WR_STEPPER } from './tokens';\n\n/**\n * One step in a {@link WrStepper}. Project as a child:\n *\n * ```html\n * <wr-stepper>\n *   <wr-step label=\"Account\"> … </wr-step>\n *   <wr-step label=\"Profile\" description=\"Optional\"> … </wr-step>\n * </wr-stepper>\n * ```\n *\n * The stepper hides every step except the active one via a host class —\n * each step still mounts once, so component state survives navigation.\n *\n * @see https://ngwr.dev/components/stepper\n */\n@Component({\n  selector: 'wr-step',\n  template: '<ng-content />',\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    class: 'wr-step',\n    '[class.wr-step--active]': 'isActive()',\n  },\n})\nexport class WrStep {\n  /** Header label. */\n  readonly label = input<string>('');\n\n  /** Secondary text shown under the label. */\n  readonly description = input<string>('');\n\n  /** Marks the step as optional in the header. */\n  readonly optional = input(false, { transform: coerceBooleanProperty });\n\n  /**\n   * Override completion state. When unset, the stepper auto-derives it\n   * from the active index (any step before `active` is completed).\n   */\n  readonly completed = input<boolean | null>(null);\n\n  /** Disables the header — also blocks header clicks. */\n  readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n  /** Stepper-assigned index. Set by the parent when contentChildren updates. */\n  readonly _index = signal(-1);\n\n  private readonly stepper = inject(WR_STEPPER);\n\n  protected readonly isActive = computed(() => this._index() === this.stepper.active());\n}\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 {\n  Component,\n  ViewEncapsulation,\n  computed,\n  contentChildren,\n  effect,\n  forwardRef,\n  input,\n  model,\n} from '@angular/core';\n\nimport { WrStep } from './step';\nimport { WR_STEPPER, type WrStepperContext } from './tokens';\n\n/**\n * Multi-step wizard container. Children are `<wr-step>` components — the\n * stepper renders one numbered header per step (with connectors) and the\n * body of the currently active one.\n *\n * Two-way bind `[(active)]` to the active step index. Set `linear=\"true\"`\n * to forbid jumping past incomplete steps.\n *\n * @example\n * ```html\n * <wr-stepper [(active)]=\"step\" linear>\n *   <wr-step label=\"Account\">…</wr-step>\n *   <wr-step label=\"Profile\">…</wr-step>\n *   <wr-step label=\"Confirm\">…</wr-step>\n * </wr-stepper>\n * ```\n *\n * @see https://ngwr.dev/components/stepper\n */\n@Component({\n  selector: 'wr-stepper',\n  templateUrl: './stepper.html',\n  encapsulation: ViewEncapsulation.None,\n  host: { '[class]': 'classes()' },\n  providers: [\n    {\n      provide: WR_STEPPER,\n      // eslint-disable-next-line @angular-eslint/no-forward-ref\n      useExisting: forwardRef(() => WrStepper),\n    },\n  ],\n})\nexport class WrStepper implements WrStepperContext {\n  /** Index of the currently visible step. */\n  readonly active = model(0);\n\n  /** Layout direction. @default 'horizontal' */\n  readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n  /** Lock steps after the latest completed one. @default false */\n  readonly linear = input(false, { transform: coerceBooleanProperty });\n\n  /**\n   * Drop a horizontal stepper to a vertical layout when its own box is too\n   * narrow for the row (a container query on its own width, not the\n   * viewport — so it adapts inside a narrow column or side panel). No effect\n   * when `orientation` is already `vertical`. @default false\n   */\n  readonly responsive = input(false, { transform: coerceBooleanProperty });\n\n  protected readonly steps = contentChildren(WrStep);\n\n  protected readonly classes = computed(() => {\n    const parts = ['wr-stepper', `wr-stepper--${this.orientation()}`];\n    if (this.linear()) parts.push('wr-stepper--linear');\n    if (this.responsive()) parts.push('wr-stepper--responsive');\n    return parts.join(' ');\n  });\n\n  constructor() {\n    // Push each step's index down so it can compute its own active state.\n    effect(() => {\n      this.steps().forEach((step, i) => step._index.set(i));\n    });\n  }\n\n  /** Is the step at `index` considered completed? */\n  protected isCompleted(index: number): boolean {\n    const override = this.steps()[index]?.completed();\n    if (override !== null && override !== undefined) return override;\n    return index < this.active();\n  }\n\n  /** Is the step at `index` reachable for direct header clicks? */\n  protected isReachable(index: number): boolean {\n    if (this.steps()[index]?.disabled()) return false;\n    if (!this.linear()) return true;\n    if (index <= this.active()) return true;\n    for (let i = 0; i < index; i++) {\n      if (!this.isCompleted(i)) return false;\n    }\n    return true;\n  }\n\n  protected onHeaderClick(index: number): void {\n    if (this.isReachable(index)) this.goTo(index);\n  }\n\n  // Imperative API\n\n  goTo(index: number): void {\n    const last = this.steps().length - 1;\n    if (last < 0) return;\n    const clamped = Math.min(Math.max(0, index), last);\n    this.active.set(clamped);\n  }\n\n  next(): void {\n    this.goTo(this.active() + 1);\n  }\n\n  prev(): void {\n    this.goTo(this.active() - 1);\n  }\n}\n","<ol class=\"wr-stepper__headers\" role=\"list\">\n  @for (step of steps(); track $index) {\n    <li\n      class=\"wr-stepper__header\"\n      [class.wr-stepper__header--active]=\"$index === active()\"\n      [class.wr-stepper__header--completed]=\"isCompleted($index)\"\n      [class.wr-stepper__header--reachable]=\"isReachable($index)\"\n      [class.wr-stepper__header--disabled]=\"step.disabled()\"\n    >\n      <button\n        type=\"button\"\n        class=\"wr-stepper__header-button\"\n        [disabled]=\"!isReachable($index) || step.disabled()\"\n        [attr.aria-current]=\"$index === active() ? 'step' : null\"\n        (click)=\"onHeaderClick($index)\"\n      >\n        <span class=\"wr-stepper__indicator\" aria-hidden=\"true\">\n          @if (isCompleted($index)) {\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\">\n              <path\n                d=\"M3 7.5 L6 10.5 L11 4.5\"\n                fill=\"none\"\n                stroke=\"currentColor\"\n                stroke-width=\"1.75\"\n                stroke-linecap=\"round\"\n                stroke-linejoin=\"round\"\n              />\n            </svg>\n          } @else {\n            {{ $index + 1 }}\n          }\n        </span>\n        <span class=\"wr-stepper__label\">\n          {{ step.label() }}\n          @if (step.optional()) {\n            <small class=\"wr-stepper__optional\">optional</small>\n          }\n          @if (step.description()) {\n            <small class=\"wr-stepper__description\">{{ step.description() }}</small>\n          }\n        </span>\n      </button>\n      @if (!$last) {\n        <span class=\"wr-stepper__connector\" aria-hidden=\"true\"></span>\n      }\n    </li>\n  }\n</ol>\n\n<div class=\"wr-stepper__body\">\n  <ng-content />\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;MAYU,UAAU,GAAG,IAAI,cAAc,CAAmB,YAAY;;ACjB3E;;;;;AAKG;AAOH;;;;;;;;;;;;;;AAcG;MAUU,MAAM,CAAA;;IAER,KAAK,GAAG,KAAK,CAAS,EAAE;8EAAC;;IAGzB,WAAW,GAAG,KAAK,CAAS,EAAE;oFAAC;;IAG/B,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;AAEtE;;;AAGG;IACM,SAAS,GAAG,KAAK,CAAiB,IAAI;kFAAC;;IAGvC,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,qBAAqB,EAAA,CAAG;;AAG7D,IAAA,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;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