{"version":3,"file":"ngx-com-components-spinner.mjs","sources":["../../../projects/com/components/spinner/spinner.variants.ts","../../../projects/com/components/spinner/spinner.component.ts","../../../projects/com/components/spinner/index.ts","../../../projects/com/components/spinner/ngx-com-components-spinner.ts"],"sourcesContent":["import { cva } from 'class-variance-authority';\n\n/** Spinner size variants. */\nexport type SpinnerSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';\n\n/** Spinner color variants. */\nexport type SpinnerColor = 'current' | 'primary' | 'accent' | 'warn' | 'success' | 'muted';\n\n/** Label position relative to spinner. */\nexport type SpinnerLabelPosition = 'right' | 'bottom';\n\n/**\n * CVA variants for the spinning circle element.\n *\n * Creates a circular track with a faded ring and a colored arc that rotates.\n * Uses `border` for the track and `border-t-*` for the spinning arc.\n *\n * @tokens `--color-primary`, `--color-accent`, `--color-warn`, `--color-success`, `--color-muted-foreground`\n */\nexport const spinnerVariants: (props?: {\n  size?: SpinnerSize;\n  color?: SpinnerColor;\n}) => string = cva(\n  [\n    'com-spinner__circle',\n    'inline-block shrink-0 rounded-pill border-solid',\n    'animate-[com-spin_0.6s_linear_infinite]',\n  ],\n  {\n    variants: {\n      size: {\n        xs: 'size-3 border-[1.5px]',\n        sm: 'size-4 border-2',\n        md: 'size-5 border-2',\n        lg: 'size-8 border-[2.5px]',\n        xl: 'size-10 border-3',\n      },\n      color: {\n        current: 'border-current/20 border-t-current',\n        primary: 'text-primary border-current/20 border-t-current',\n        accent: 'text-accent border-current/20 border-t-current',\n        warn: 'text-warn border-current/20 border-t-current',\n        success: 'text-success border-current/20 border-t-current',\n        muted: 'text-muted-foreground border-current/20 border-t-current',\n      },\n    },\n    defaultVariants: {\n      size: 'md',\n      color: 'current',\n    },\n  }\n);\n\n/**\n * CVA variants for the spinner container layout.\n *\n * Controls flex direction and gap based on label position.\n * Only applies when a visible label is present.\n *\n * @tokens none (layout only)\n */\nexport const spinnerContainerVariants: (props?: {\n  labelPosition?: SpinnerLabelPosition;\n}) => string = cva(\n  ['inline-flex items-center justify-center'],\n  {\n    variants: {\n      labelPosition: {\n        right: 'flex-row gap-2',\n        bottom: 'flex-col gap-1.5',\n      },\n    },\n    defaultVariants: {\n      labelPosition: 'right',\n    },\n  }\n);\n\n/** Label font size classes mapped to spinner size. */\nexport const SPINNER_LABEL_SIZES: Record<SpinnerSize, string> = {\n  xs: 'text-xs',\n  sm: 'text-xs',\n  md: 'text-sm',\n  lg: 'text-sm',\n  xl: 'text-base',\n};\n","import {\n  ChangeDetectionStrategy,\n  Component,\n  computed,\n  input,\n  ViewEncapsulation,\n} from '@angular/core';\nimport type { InputSignal, Signal } from '@angular/core';\nimport {\n  spinnerVariants,\n  spinnerContainerVariants,\n  SPINNER_LABEL_SIZES,\n} from './spinner.variants';\nimport type {\n  SpinnerSize,\n  SpinnerColor,\n  SpinnerLabelPosition,\n} from './spinner.variants';\n\n/**\n * A minimal, CSS-only loading indicator.\n *\n * Drop-in anywhere: inside buttons, next to inline text, centered in cards,\n * or as a page-level overlay. The animation is fast (0.6s) for a snappy feel.\n *\n * @tokens `--color-primary`, `--color-accent`, `--color-warn`, `--color-success`, `--color-muted-foreground`\n *\n * @example Simplest usage (inherits parent text color)\n * ```html\n * <com-spinner />\n * ```\n *\n * @example Inside a button (inline, inherits button text color)\n * ```html\n * <button class=\"btn-primary\" [disabled]=\"saving\">\n *   @if (saving) {\n *     <com-spinner size=\"xs\" />\n *   }\n *   Save\n * </button>\n * ```\n *\n * @example With visible label\n * ```html\n * <com-spinner label=\"Loading results...\" />\n * ```\n *\n * @example Centered in a card\n * ```html\n * <div class=\"flex items-center justify-center p-8\">\n *   <com-spinner size=\"lg\" color=\"primary\" label=\"Loading...\" labelPosition=\"bottom\" />\n * </div>\n * ```\n *\n * @example Inline with text\n * ```html\n * <p class=\"text-muted-foreground\">\n *   <com-spinner size=\"xs\" /> Checking availability...\n * </p>\n * ```\n *\n * @example Color variants\n * ```html\n * <com-spinner color=\"primary\" />\n * <com-spinner color=\"accent\" />\n * <com-spinner color=\"warn\" />\n * ```\n *\n * @example Large page-level\n * ```html\n * <com-spinner size=\"xl\" color=\"primary\" label=\"Preparing your dashboard...\" labelPosition=\"bottom\" />\n * ```\n */\n@Component({\n  selector: 'com-spinner',\n  exportAs: 'comSpinner',\n  template: `\n    <span [class]=\"spinnerClasses()\" aria-hidden=\"true\"></span>\n    @if (label()) {\n      <span class=\"select-none text-muted-foreground\" [class]=\"labelSizeClass()\">\n        {{ label() }}\n      </span>\n    } @else {\n      <span class=\"sr-only\">Loading</span>\n    }\n  `,\n  styles: `\n    @keyframes com-spin {\n      to {\n        transform: rotate(360deg);\n      }\n    }\n\n    .sr-only {\n      position: absolute;\n      width: 1px;\n      height: 1px;\n      padding: 0;\n      margin: -1px;\n      overflow: hidden;\n      clip: rect(0, 0, 0, 0);\n      white-space: nowrap;\n      border: 0;\n    }\n  `,\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    role: 'status',\n    '[class]': 'containerClasses()',\n  },\n})\nexport class ComSpinner {\n  /**\n   * Optional loading text (e.g., \"Loading...\", \"Saving...\").\n   * When omitted, \"Loading\" is rendered for screen readers only (sr-only).\n   * When provided, the label is visible next to or below the spinner.\n   */\n  readonly label: InputSignal<string | undefined> = input<string>();\n\n  /**\n   * Position of the label relative to the spinner.\n   * Only relevant when a visible `label` is provided.\n   */\n  readonly labelPosition: InputSignal<SpinnerLabelPosition> = input<SpinnerLabelPosition>('right');\n\n  /** Size of the spinner. */\n  readonly size: InputSignal<SpinnerSize> = input<SpinnerSize>('md');\n\n  /**\n   * Color of the spinner.\n   * `current` inherits from `currentColor` to match surrounding text.\n   */\n  readonly color: InputSignal<SpinnerColor> = input<SpinnerColor>('current');\n\n  /** @internal Computed classes for the spinning circle. */\n  protected readonly spinnerClasses: Signal<string> = computed(() =>\n    spinnerVariants({\n      size: this.size(),\n      color: this.color(),\n    })\n  );\n\n  /** @internal Computed classes for the container/host. */\n  protected readonly containerClasses: Signal<string> = computed(() =>\n    this.label()\n      ? spinnerContainerVariants({ labelPosition: this.labelPosition() })\n      : spinnerContainerVariants()\n  );\n\n  /** @internal Computed label font size class. */\n  protected readonly labelSizeClass: Signal<string> = computed(\n    () => SPINNER_LABEL_SIZES[this.size()]\n  );\n}\n","// Public API for the spinner component\n\n// Main component\nexport { ComSpinner } from './spinner.component';\n\n// Variants (for advanced customization)\nexport {\n  spinnerVariants,\n  spinnerContainerVariants,\n  SPINNER_LABEL_SIZES,\n} from './spinner.variants';\n\nexport type {\n  SpinnerSize,\n  SpinnerColor,\n  SpinnerLabelPosition,\n} from './spinner.variants';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAWA;;;;;;;AAOG;AACI,MAAM,eAAe,GAGb,GAAG,CAChB;IACE,qBAAqB;IACrB,iDAAiD;IACjD,yCAAyC;CAC1C,EACD;AACE,IAAA,QAAQ,EAAE;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,uBAAuB;AAC3B,YAAA,EAAE,EAAE,iBAAiB;AACrB,YAAA,EAAE,EAAE,iBAAiB;AACrB,YAAA,EAAE,EAAE,uBAAuB;AAC3B,YAAA,EAAE,EAAE,kBAAkB;AACvB,SAAA;AACD,QAAA,KAAK,EAAE;AACL,YAAA,OAAO,EAAE,oCAAoC;AAC7C,YAAA,OAAO,EAAE,iDAAiD;AAC1D,YAAA,MAAM,EAAE,gDAAgD;AACxD,YAAA,IAAI,EAAE,8CAA8C;AACpD,YAAA,OAAO,EAAE,iDAAiD;AAC1D,YAAA,KAAK,EAAE,0DAA0D;AAClE,SAAA;AACF,KAAA;AACD,IAAA,eAAe,EAAE;AACf,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,KAAK,EAAE,SAAS;AACjB,KAAA;AACF,CAAA;AAGH;;;;;;;AAOG;MACU,wBAAwB,GAEtB,GAAG,CAChB,CAAC,yCAAyC,CAAC,EAC3C;AACE,IAAA,QAAQ,EAAE;AACR,QAA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