{"version":3,"file":"ngwr-spotlight-card.mjs","sources":["../../../projects/lib/spotlight-card/spotlight-card.ts","../../../projects/lib/spotlight-card/spotlight.ts","../../../projects/lib/spotlight-card/ngwr-spotlight-card.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 * Angular adaptation of the SpotlightCard effect by David Haz / reactbits.dev.\n * Original: https://www.reactbits.dev/components/spotlight-card\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, ElementRef, inject, input } from '@angular/core';\n\n/**\n * Cursor-tracked spotlight card. A soft radial highlight follows the\n * pointer inside the card; fades in on hover, out on leave.\n *\n * Project any content as children — the spotlight overlay sits behind\n * the projected DOM (via a `::before` pseudo with `pointer-events: none`)\n * so clicks pass through naturally.\n *\n * @example\n * ```html\n * <wr-spotlight-card spotlightColor=\"rgba(120, 180, 255, 0.25)\">\n *   <h3>Hover me</h3>\n * </wr-spotlight-card>\n * ```\n *\n * @see https://www.reactbits.dev/components/spotlight-card\n */\n@Component({\n  selector: 'wr-spotlight-card',\n  template: '<ng-content />',\n  styleUrl: './spotlight-card.scss',\n  encapsulation: ViewEncapsulation.None,\n  host: {\n    class: 'wr-spotlight-card',\n    '[style.--wr-spotlight-color]': 'spotlightColor()',\n    '[style.--wr-spotlight-radius]': 'radius() + \"%\"',\n    '(mousemove)': 'onMouseMove($event)',\n  },\n})\nexport class WrSpotlightCard {\n  /**\n   * Highlight colour (any CSS colour). When unset, the theme decides:\n   * a dark-ish glow on light surfaces, a light glow on dark.\n   */\n  readonly spotlightColor = input<string | null>(null);\n\n  /** Where the spotlight fades out, as a percentage of the gradient. @default 80 */\n  readonly radius = input(80, { transform: (v: unknown): number => coerceNumberProperty(v, 80) });\n\n  private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n  protected onMouseMove(event: MouseEvent): void {\n    const host = this.el.nativeElement;\n    const rect = host.getBoundingClientRect();\n    host.style.setProperty('--wr-spotlight-x', `${event.clientX - rect.left}px`);\n    host.style.setProperty('--wr-spotlight-y', `${event.clientY - rect.top}px`);\n  }\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 { DestroyRef, Directive, ElementRef, NgZone, inject, input } from '@angular/core';\n\n/**\n * Cursor-follow radial spotlight. Sets the `--wr-spotlight-x` and\n * `--wr-spotlight-y` CSS custom properties on the host based on the\n * pointer position so a `radial-gradient` (or `mask`) in your CSS can\n * follow the cursor.\n *\n * @example\n * ```html\n * <div class=\"card\" wrSpotlight>…</div>\n * ```\n *\n * ```scss\n * .card {\n *   background: radial-gradient(\n *     400px circle at var(--wr-spotlight-x, 50%) var(--wr-spotlight-y, 50%),\n *     rgba(var(--wr-color-primary-rgb), 0.15),\n *     transparent 60%\n *   );\n * }\n * ```\n */\n@Directive({\n  selector: '[wrSpotlight]',\n  host: { '(pointermove)': 'onMove($event)', '(pointerleave)': 'onLeave()' },\n})\nexport class WrSpotlight {\n  /** Optional default coordinates when no pointer is over the host. */\n  readonly resetX = input<string>('50%');\n  readonly resetY = input<string>('50%');\n\n  private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n  private readonly zone = inject(NgZone);\n  private readonly destroyRef = inject(DestroyRef);\n\n  constructor() {\n    const host = this.el.nativeElement;\n    host.style.setProperty('--wr-spotlight-x', this.resetX());\n    host.style.setProperty('--wr-spotlight-y', this.resetY());\n    this.destroyRef.onDestroy(() => {\n      host.style.removeProperty('--wr-spotlight-x');\n      host.style.removeProperty('--wr-spotlight-y');\n    });\n  }\n\n  /** @internal */\n  protected onMove(event: PointerEvent): void {\n    this.zone.runOutsideAngular(() => {\n      const host = this.el.nativeElement;\n      const rect = host.getBoundingClientRect();\n      const x = ((event.clientX - rect.left) / rect.width) * 100;\n      const y = ((event.clientY - rect.top) / rect.height) * 100;\n      host.style.setProperty('--wr-spotlight-x', `${x}%`);\n      host.style.setProperty('--wr-spotlight-y', `${y}%`);\n    });\n  }\n\n  /** @internal */\n  protected onLeave(): void {\n    const host = this.el.nativeElement;\n    host.style.setProperty('--wr-spotlight-x', this.resetX());\n    host.style.setProperty('--wr-spotlight-y', this.resetY());\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;AAQG;AAKH;;;;;;;;;;;;;;;;AAgBG;MAaU,eAAe,CAAA;AAC1B;;;AAGG;IACM,cAAc,GAAG,KAAK,CAAgB,IAAI;uFAAC;;AAG3C,IAAA,MAAM,GAAG,KAAK,CAAC,EAAE,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,QAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,SAAS,EAAE,CAAC,CAAU,KAAa,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG;AAE9E,IAAA,EAAE,GAAG,MAAM,CAA0B,UAAU,CAAC;AAEvD,IAAA,WAAW,CAAC,KAAiB,EAAA;AACrC,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa;AAClC,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,qBAAqB,EAAE;AACzC,QAAA,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAA,EAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAA,EAAA,CAAI,CAAC;AAC5E,QAAA,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,kBAAkB,EAAE,CAAA,EAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAA,EAAA,CAAI,CAAC;IAC7E;uGAjBW,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAf,IAAA,OAAA,IAAA,GAAA,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