@radix-ng/primitives 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/avatar/index.d.ts +1 -1
  2. package/avatar/src/avatar-context.token.d.ts +7 -0
  3. package/avatar/src/avatar-fallback.directive.d.ts +3 -9
  4. package/avatar/src/avatar-image.directive.d.ts +11 -11
  5. package/avatar/src/avatar-root.directive.d.ts +3 -6
  6. package/avatar/src/types.d.ts +2 -0
  7. package/checkbox/index.d.ts +1 -1
  8. package/checkbox/src/checkbox-button.directive.d.ts +1 -1
  9. package/checkbox/src/checkbox-indicator.directive.d.ts +1 -1
  10. package/checkbox/src/checkbox-input.directive.d.ts +1 -1
  11. package/checkbox/src/checkbox.directive.d.ts +3 -3
  12. package/checkbox/src/checkbox.token.d.ts +3 -3
  13. package/cropper/README.md +1 -0
  14. package/cropper/index.d.ts +15 -0
  15. package/cropper/src/cropper-context.token.d.ts +12 -0
  16. package/cropper/src/cropper-crop-area.directive.d.ts +6 -0
  17. package/cropper/src/cropper-description.directive.d.ts +6 -0
  18. package/cropper/src/cropper-image.component.d.ts +10 -0
  19. package/cropper/src/cropper-root.directive.d.ts +91 -0
  20. package/fesm2022/radix-ng-primitives-avatar.mjs +82 -86
  21. package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
  22. package/fesm2022/radix-ng-primitives-checkbox.mjs +13 -16
  23. package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
  24. package/fesm2022/radix-ng-primitives-cropper.mjs +680 -0
  25. package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -0
  26. package/fesm2022/radix-ng-primitives-stepper.mjs +1 -14
  27. package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
  28. package/hover-card/src/hover-card-root.directive.d.ts +4 -4
  29. package/package.json +5 -1
  30. package/popover/src/popover-root.directive.d.ts +4 -4
  31. package/tooltip/src/tooltip-root.directive.d.ts +4 -4
  32. package/stepper/src/utils/getActiveElement.d.ts +0 -1
package/avatar/index.d.ts CHANGED
@@ -5,8 +5,8 @@ import * as i3 from "./src/avatar-image.directive";
5
5
  export * from './src/avatar-fallback.directive';
6
6
  export * from './src/avatar-image.directive';
7
7
  export * from './src/avatar-root.directive';
8
- export type { RdxImageLoadingStatus } from './src/avatar-root.directive';
9
8
  export * from './src/avatar.config';
9
+ export type { RdxImageLoadingStatus } from './src/types';
10
10
  export declare class RdxCheckboxModule {
11
11
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxCheckboxModule, never>;
12
12
  static ɵmod: i0.ɵɵNgModuleDeclaration<RdxCheckboxModule, never, [typeof i1.RdxAvatarRootDirective, typeof i2.RdxAvatarFallbackDirective, typeof i3.RdxAvatarImageDirective], [typeof i1.RdxAvatarRootDirective, typeof i2.RdxAvatarFallbackDirective, typeof i3.RdxAvatarImageDirective]>;
@@ -0,0 +1,7 @@
1
+ import { InjectionToken, WritableSignal } from '@angular/core';
2
+ import { RdxImageLoadingStatus } from './types';
3
+ export interface AvatarContextToken {
4
+ imageLoadingStatus: WritableSignal<RdxImageLoadingStatus>;
5
+ }
6
+ export declare const AVATAR_ROOT_CONTEXT: InjectionToken<AvatarContextToken>;
7
+ export declare function injectAvatarRootContext(): AvatarContextToken;
@@ -1,12 +1,10 @@
1
- import { OnDestroy } from '@angular/core';
2
- import { RdxAvatarRootContext } from './avatar-root.directive';
3
1
  import * as i0 from "@angular/core";
4
2
  /**
5
3
  * @group Components
6
4
  */
7
- export declare class RdxAvatarFallbackDirective implements OnDestroy {
8
- protected readonly avatarRoot: RdxAvatarRootContext;
5
+ export declare class RdxAvatarFallbackDirective {
9
6
  private readonly config;
7
+ protected readonly rootContext: import("./avatar-context.token").AvatarContextToken;
10
8
  /**
11
9
  * Useful for delaying rendering so it only appears for those with slower connections.
12
10
  *
@@ -14,13 +12,9 @@ export declare class RdxAvatarFallbackDirective implements OnDestroy {
14
12
  * @defaultValue 0
15
13
  */
16
14
  readonly delayMs: import("@angular/core").InputSignal<number>;
17
- readonly shouldRender: import("@angular/core").Signal<boolean>;
18
15
  protected readonly canRender: import("@angular/core").WritableSignal<boolean>;
19
- private timeoutId;
16
+ private timeout;
20
17
  constructor();
21
- private startDelayTimer;
22
- private clearDelayTimer;
23
- ngOnDestroy(): void;
24
18
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxAvatarFallbackDirective, never>;
25
19
  static ɵdir: i0.ɵɵDirectiveDeclaration<RdxAvatarFallbackDirective, "span[rdxAvatarFallback]", ["rdxAvatarFallback"], { "delayMs": { "alias": "delayMs"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
26
20
  }
@@ -1,16 +1,17 @@
1
- import { OnInit } from '@angular/core';
2
- import { RdxImageLoadingStatus } from './avatar-root.directive';
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import { HTMLAttributeReferrerPolicy, RdxImageLoadingStatus } from './types';
3
3
  import * as i0 from "@angular/core";
4
4
  /**
5
5
  * @group Components
6
6
  */
7
- export declare class RdxAvatarImageDirective implements OnInit {
8
- private readonly avatarRoot;
9
- private readonly elementRef;
7
+ export declare class RdxAvatarImageDirective implements OnInit, OnDestroy {
8
+ private readonly platformId;
9
+ protected readonly rootContext: import("./avatar-context.token").AvatarContextToken;
10
10
  /**
11
11
  * @group Props
12
12
  */
13
13
  readonly src: import("@angular/core").InputSignal<string | undefined>;
14
+ readonly referrerPolicy: import("@angular/core").InputSignal<HTMLAttributeReferrerPolicy | undefined>;
14
15
  /**
15
16
  * A callback providing information about the loading status of the image.
16
17
  * This is useful in case you want to control more precisely what to render as the image is loading.
@@ -18,12 +19,11 @@ export declare class RdxAvatarImageDirective implements OnInit {
18
19
  * @group Emits
19
20
  */
20
21
  readonly onLoadingStatusChange: import("@angular/core").OutputEmitterRef<RdxImageLoadingStatus>;
21
- protected readonly imageLoadingStatus: import("@angular/core").Signal<RdxImageLoadingStatus>;
22
+ private readonly isMounted;
23
+ private readonly loadingStatus;
24
+ constructor();
22
25
  ngOnInit(): void;
23
- onLoad(): void;
24
- onError(): void;
25
- private setImageStatus;
26
- get nativeElement(): any;
26
+ ngOnDestroy(): void;
27
27
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxAvatarImageDirective, never>;
28
- static ɵdir: i0.ɵɵDirectiveDeclaration<RdxAvatarImageDirective, "img[rdxAvatarImage]", ["rdxAvatarImage"], { "src": { "alias": "src"; "required": false; "isSignal": true; }; }, { "onLoadingStatusChange": "onLoadingStatusChange"; }, never, never, true, never>;
28
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxAvatarImageDirective, "img[rdxAvatarImage]", ["rdxAvatarImage"], { "src": { "alias": "src"; "required": false; "isSignal": true; }; "referrerPolicy": { "alias": "referrerPolicy"; "required": false; "isSignal": true; }; }, { "onLoadingStatusChange": "onLoadingStatusChange"; }, never, never, true, never>;
29
29
  }
@@ -1,11 +1,8 @@
1
+ import { AvatarContextToken } from './avatar-context.token';
2
+ import { RdxImageLoadingStatus } from './types';
1
3
  import * as i0 from "@angular/core";
2
- export type RdxImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
3
- export declare class RdxAvatarRootContext {
4
+ export declare class RdxAvatarRootDirective implements AvatarContextToken {
4
5
  readonly imageLoadingStatus: import("@angular/core").WritableSignal<RdxImageLoadingStatus>;
5
- static ɵfac: i0.ɵɵFactoryDeclaration<RdxAvatarRootContext, never>;
6
- static ɵprov: i0.ɵɵInjectableDeclaration<RdxAvatarRootContext>;
7
- }
8
- export declare class RdxAvatarRootDirective {
9
6
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxAvatarRootDirective, never>;
10
7
  static ɵdir: i0.ɵɵDirectiveDeclaration<RdxAvatarRootDirective, "span[rdxAvatarRoot]", ["rdxAvatarRoot"], {}, {}, never, never, true, never>;
11
8
  }
@@ -0,0 +1,2 @@
1
+ export type RdxImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
2
+ export type HTMLAttributeReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
@@ -11,6 +11,6 @@ export type { CheckboxState } from './src/checkbox.directive';
11
11
  export * from './src/checkbox.token';
12
12
  export declare class RdxCheckboxModule {
13
13
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxCheckboxModule, never>;
14
- static ɵmod: i0.ɵɵNgModuleDeclaration<RdxCheckboxModule, never, [typeof i1.RdxCheckboxInputDirective, typeof i2.RdxCheckboxDirective, typeof i3.RdxCheckboxButtonDirective, typeof i4.RdxCheckboxIndicatorDirective], [typeof i1.RdxCheckboxInputDirective, typeof i2.RdxCheckboxDirective, typeof i3.RdxCheckboxButtonDirective, typeof i4.RdxCheckboxIndicatorDirective]>;
14
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RdxCheckboxModule, never, [typeof i1.RdxCheckboxInputDirective, typeof i2.RdxCheckboxRootDirective, typeof i3.RdxCheckboxButtonDirective, typeof i4.RdxCheckboxIndicatorDirective], [typeof i1.RdxCheckboxInputDirective, typeof i2.RdxCheckboxRootDirective, typeof i3.RdxCheckboxButtonDirective, typeof i4.RdxCheckboxIndicatorDirective]>;
15
15
  static ɵinj: i0.ɵɵInjectorDeclaration<RdxCheckboxModule>;
16
16
  }
@@ -1,6 +1,6 @@
1
1
  import * as i0 from "@angular/core";
2
2
  export declare class RdxCheckboxButtonDirective {
3
- protected readonly checkbox: import("@radix-ng/primitives/checkbox").RdxCheckboxDirective;
3
+ protected readonly checkbox: import("@radix-ng/primitives/checkbox").RdxCheckboxRootDirective;
4
4
  readonly id: import("@angular/core").InputSignal<string | null>;
5
5
  protected readonly elementId: import("@angular/core").Signal<string | null>;
6
6
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxCheckboxButtonDirective, never>;
@@ -1,6 +1,6 @@
1
1
  import * as i0 from "@angular/core";
2
2
  export declare class RdxCheckboxIndicatorDirective {
3
- protected readonly checkbox: import("@radix-ng/primitives/checkbox").RdxCheckboxDirective;
3
+ protected readonly checkbox: import("@radix-ng/primitives/checkbox").RdxCheckboxRootDirective;
4
4
  static ɵfac: i0.ɵɵFactoryDeclaration<RdxCheckboxIndicatorDirective, never>;
5
5
  static ɵdir: i0.ɵɵDirectiveDeclaration<RdxCheckboxIndicatorDirective, "[rdxCheckboxIndicator]", never, {}, {}, never, never, true, never>;
6
6
  }
@@ -1,7 +1,7 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import * as i1 from "@radix-ng/primitives/visually-hidden";
3
3
  export declare class RdxCheckboxInputDirective {
4
- protected readonly checkbox: import("@radix-ng/primitives/checkbox").RdxCheckboxDirective;
4
+ protected readonly checkbox: import("@radix-ng/primitives/checkbox").RdxCheckboxRootDirective;
5
5
  readonly id: import("@angular/core").InputSignal<string | undefined>;
6
6
  protected readonly elementId: import("@angular/core").Signal<string | undefined>;
7
7
  protected readonly value: import("@angular/core").Signal<"" | "on" | "off">;
@@ -5,7 +5,7 @@ export type CheckboxState = 'unchecked' | 'checked' | 'indeterminate';
5
5
  /**
6
6
  * @group Components
7
7
  */
8
- export declare class RdxCheckboxDirective implements ControlValueAccessor, OnChanges {
8
+ export declare class RdxCheckboxRootDirective implements ControlValueAccessor, OnChanges {
9
9
  /**
10
10
  * The controlled checked state of the checkbox. Must be used in conjunction with onCheckedChange.
11
11
  * @group Props
@@ -77,8 +77,8 @@ export declare class RdxCheckboxDirective implements ControlValueAccessor, OnCha
77
77
  * @internal
78
78
  */
79
79
  setDisabledState(isDisabled: boolean): void;
80
- static ɵfac: i0.ɵɵFactoryDeclaration<RdxCheckboxDirective, never>;
81
- static ɵdir: i0.ɵɵDirectiveDeclaration<RdxCheckboxDirective, "[rdxCheckboxRoot]", never, { "checked": { "alias": "checked"; "required": false; }; "indeterminate": { "alias": "indeterminate"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "required": { "alias": "required"; "required": false; }; }, { "checkedChange": "checkedChange"; "indeterminateChange": "indeterminateChange"; }, never, never, true, never>;
80
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxCheckboxRootDirective, never>;
81
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxCheckboxRootDirective, "[rdxCheckboxRoot]", never, { "checked": { "alias": "checked"; "required": false; }; "indeterminate": { "alias": "indeterminate"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "required": { "alias": "required"; "required": false; }; }, { "checkedChange": "checkedChange"; "indeterminateChange": "indeterminateChange"; }, never, never, true, never>;
82
82
  static ngAcceptInputType_checked: unknown;
83
83
  static ngAcceptInputType_indeterminate: unknown;
84
84
  static ngAcceptInputType_disabled: unknown;
@@ -1,4 +1,4 @@
1
1
  import { InjectionToken } from '@angular/core';
2
- import type { RdxCheckboxDirective } from './checkbox.directive';
3
- export declare const RdxCheckboxToken: InjectionToken<RdxCheckboxDirective>;
4
- export declare function injectCheckbox(): RdxCheckboxDirective;
2
+ import type { RdxCheckboxRootDirective } from './checkbox.directive';
3
+ export declare const RdxCheckboxToken: InjectionToken<RdxCheckboxRootDirective>;
4
+ export declare function injectCheckbox(): RdxCheckboxRootDirective;
@@ -0,0 +1 @@
1
+ # @radix-ng/primitives/cropper
@@ -0,0 +1,15 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./src/cropper-root.directive";
3
+ import * as i2 from "./src/cropper-image.component";
4
+ import * as i3 from "./src/cropper-crop-area.directive";
5
+ import * as i4 from "./src/cropper-description.directive";
6
+ export * from './src/cropper-context.token';
7
+ export * from './src/cropper-crop-area.directive';
8
+ export * from './src/cropper-description.directive';
9
+ export * from './src/cropper-image.component';
10
+ export * from './src/cropper-root.directive';
11
+ export declare class RdxCropperModule {
12
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxCropperModule, never>;
13
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RdxCropperModule, never, [typeof i1.RdxCropperRootDirective, typeof i2.RdxCropperImageComponent, typeof i3.RdxCropperCropAreaDirective, typeof i4.RdxCropperDescriptionDirective], [typeof i1.RdxCropperRootDirective, typeof i2.RdxCropperImageComponent, typeof i3.RdxCropperCropAreaDirective, typeof i4.RdxCropperDescriptionDirective]>;
14
+ static ɵinj: i0.ɵɵInjectorDeclaration<RdxCropperModule>;
15
+ }
@@ -0,0 +1,12 @@
1
+ import { InjectionToken, InputSignal, WritableSignal } from '@angular/core';
2
+ export interface CropperContextToken {
3
+ image: InputSignal<string>;
4
+ getImageProps: () => {
5
+ [key: string]: any;
6
+ };
7
+ getImageWrapperStyle: () => Record<string, string>;
8
+ getCropAreaStyle: () => Record<string, string>;
9
+ descriptionId: WritableSignal<string>;
10
+ }
11
+ export declare const CROPPER_ROOT_CONTEXT: InjectionToken<CropperContextToken>;
12
+ export declare function injectCropperRootContext(): CropperContextToken;
@@ -0,0 +1,6 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class RdxCropperCropAreaDirective {
3
+ readonly rootContext: import("./cropper-context.token").CropperContextToken;
4
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxCropperCropAreaDirective, never>;
5
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxCropperCropAreaDirective, "[rdxCropperCropArea]", never, {}, {}, never, never, true, never>;
6
+ }
@@ -0,0 +1,6 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class RdxCropperDescriptionDirective {
3
+ readonly rootContext: import("./cropper-context.token").CropperContextToken;
4
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxCropperDescriptionDirective, never>;
5
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxCropperDescriptionDirective, "[rdxCropperDescription]", never, {}, {}, never, never, true, never>;
6
+ }
@@ -0,0 +1,10 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class RdxCropperImageComponent {
3
+ protected readonly rootContext: import("./cropper-context.token").CropperContextToken;
4
+ readonly imgClass: import("@angular/core").InputSignal<string | undefined>;
5
+ readonly imgStyles: import("@angular/core").InputSignal<string | undefined>;
6
+ protected readonly imgClasses: import("@angular/core").Signal<string | undefined>;
7
+ protected readonly imgStyless: import("@angular/core").Signal<string | undefined>;
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxCropperImageComponent, never>;
9
+ static ɵcmp: i0.ɵɵComponentDeclaration<RdxCropperImageComponent, "[rdxCropperImage]", never, { "imgClass": { "alias": "imgClass"; "required": false; "isSignal": true; }; "imgStyles": { "alias": "imgStyles"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
10
+ }
@@ -0,0 +1,91 @@
1
+ import { NumberInput } from '@angular/cdk/coercion';
2
+ import { CropperContextToken } from './cropper-context.token';
3
+ import * as i0 from "@angular/core";
4
+ export type Area = {
5
+ x: number;
6
+ y: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ export declare class RdxCropperRootDirective implements CropperContextToken {
11
+ private readonly elementRef;
12
+ private readonly CROPPER_DESC_WARN_MESSAGE;
13
+ readonly image: import("@angular/core").InputSignal<string>;
14
+ readonly cropPadding: import("@angular/core").InputSignalWithTransform<number, unknown>;
15
+ readonly aspectRatio: import("@angular/core").InputSignalWithTransform<number, unknown>;
16
+ readonly minZoom: import("@angular/core").InputSignalWithTransform<number, unknown>;
17
+ readonly maxZoom: import("@angular/core").InputSignalWithTransform<number, unknown>;
18
+ readonly zoomSensitivity: import("@angular/core").InputSignalWithTransform<number, unknown>;
19
+ readonly keyboardStep: import("@angular/core").InputSignalWithTransform<number, unknown>;
20
+ readonly zoom: import("@angular/core").InputSignalWithTransform<number | undefined, NumberInput>;
21
+ readonly onCropChange: import("@angular/core").OutputEmitterRef<Area | null>;
22
+ readonly onZoomChange: import("@angular/core").OutputEmitterRef<number>;
23
+ private readonly imgWidth;
24
+ private readonly imgHeight;
25
+ private readonly cropAreaWidth;
26
+ private readonly cropAreaHeight;
27
+ private readonly imageWrapperWidth;
28
+ private readonly imageWrapperHeight;
29
+ private readonly offsetX;
30
+ private readonly offsetY;
31
+ private readonly internalZoom;
32
+ private readonly isDragging;
33
+ readonly descriptionId: import("@angular/core").WritableSignal<string>;
34
+ private readonly isZoomControlled;
35
+ protected readonly effectiveZoom: import("@angular/core").Signal<number>;
36
+ protected readonly zoomValueText: import("@angular/core").Signal<string>;
37
+ private readonly dragStartPoint;
38
+ private readonly dragStartOffset;
39
+ private readonly latestRestrictedOffset;
40
+ private readonly latestZoom;
41
+ private readonly isInitialSetupDone;
42
+ private readonly initialPinchDistance;
43
+ private readonly initialPinchZoom;
44
+ private readonly isPinching;
45
+ private readonly hasWarned;
46
+ constructor();
47
+ private updateZoom;
48
+ private initializeContainerDimensions;
49
+ private setupImageLoadEffect;
50
+ private setupDimensionsEffects;
51
+ private restrictOffset;
52
+ private calculateCropData;
53
+ private setupCropCalculationEffect;
54
+ private setupAccessibilityWarningEffect;
55
+ private setupEventListenersEffect;
56
+ private handleInteractionEnd;
57
+ /**
58
+ * @ignore
59
+ */
60
+ onMouseDown(e: MouseEvent): void;
61
+ private handleWheel;
62
+ private getPinchDistance;
63
+ private getPinchCenter;
64
+ private handleTouchStart;
65
+ private handleTouchMove;
66
+ private handleTouchEnd;
67
+ /**
68
+ * @ignore
69
+ */
70
+ onKeyDown(e: KeyboardEvent): void;
71
+ /**
72
+ * @ignore
73
+ */
74
+ onKeyUp(e: KeyboardEvent): void;
75
+ /**
76
+ * @ignore
77
+ */
78
+ getImageProps(): {
79
+ [key: string]: any;
80
+ };
81
+ /**
82
+ * @ignore
83
+ */
84
+ getImageWrapperStyle(): Record<string, string>;
85
+ /**
86
+ * @ignore
87
+ */
88
+ getCropAreaStyle(): Record<string, string>;
89
+ static ɵfac: i0.ɵɵFactoryDeclaration<RdxCropperRootDirective, never>;
90
+ static ɵdir: i0.ɵɵDirectiveDeclaration<RdxCropperRootDirective, "[rdxCropperRoot]", never, { "image": { "alias": "image"; "required": true; "isSignal": true; }; "cropPadding": { "alias": "cropPadding"; "required": false; "isSignal": true; }; "aspectRatio": { "alias": "aspectRatio"; "required": false; "isSignal": true; }; "minZoom": { "alias": "minZoom"; "required": false; "isSignal": true; }; "maxZoom": { "alias": "maxZoom"; "required": false; "isSignal": true; }; "zoomSensitivity": { "alias": "zoomSensitivity"; "required": false; "isSignal": true; }; "keyboardStep": { "alias": "keyboardStep"; "required": false; "isSignal": true; }; "zoom": { "alias": "zoom"; "required": false; "isSignal": true; }; }, { "onCropChange": "onCropChange"; "onZoomChange": "onZoomChange"; }, never, never, true, never>;
91
+ }
@@ -1,29 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, Injectable, Directive, InjectionToken, inject, input, computed, effect, ElementRef, output, NgModule } from '@angular/core';
2
+ import { InjectionToken, inject, input, signal, Directive, PLATFORM_ID, output, NgModule } from '@angular/core';
3
+ import { watch, provideToken } from '@radix-ng/primitives/core';
4
+ import { isPlatformBrowser } from '@angular/common';
3
5
 
4
- class RdxAvatarRootContext {
5
- constructor() {
6
- this.imageLoadingStatus = signal('loading');
7
- }
8
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootContext, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
9
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootContext }); }
10
- }
11
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootContext, decorators: [{
12
- type: Injectable
13
- }] });
14
- class RdxAvatarRootDirective {
15
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
16
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: RdxAvatarRootDirective, isStandalone: true, selector: "span[rdxAvatarRoot]", providers: [RdxAvatarRootContext], exportAs: ["rdxAvatarRoot"], ngImport: i0 }); }
6
+ const AVATAR_ROOT_CONTEXT = new InjectionToken('AVATAR_ROOT_CONTEXT');
7
+ function injectAvatarRootContext() {
8
+ return inject(AVATAR_ROOT_CONTEXT);
17
9
  }
18
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootDirective, decorators: [{
19
- type: Directive,
20
- args: [{
21
- selector: 'span[rdxAvatarRoot]',
22
- exportAs: 'rdxAvatarRoot',
23
- standalone: true,
24
- providers: [RdxAvatarRootContext]
25
- }]
26
- }] });
27
10
 
28
11
  const defaultAvatarConfig = {
29
12
  delayMs: 0
@@ -46,8 +29,8 @@ function injectAvatarConfig() {
46
29
  */
47
30
  class RdxAvatarFallbackDirective {
48
31
  constructor() {
49
- this.avatarRoot = inject(RdxAvatarRootContext);
50
32
  this.config = injectAvatarConfig();
33
+ this.rootContext = injectAvatarRootContext();
51
34
  /**
52
35
  * Useful for delaying rendering so it only appears for those with slower connections.
53
36
  *
@@ -55,51 +38,32 @@ class RdxAvatarFallbackDirective {
55
38
  * @defaultValue 0
56
39
  */
57
40
  this.delayMs = input(this.config.delayMs);
58
- this.shouldRender = computed(() => this.canRender() && this.avatarRoot.imageLoadingStatus() !== 'loaded');
59
41
  this.canRender = signal(false);
60
- this.timeoutId = null;
61
- effect(() => {
62
- const status = this.avatarRoot.imageLoadingStatus();
63
- if (status === 'loading') {
64
- this.startDelayTimer();
65
- }
66
- else {
67
- this.clearDelayTimer();
68
- this.canRender.set(true);
42
+ watch([this.rootContext.imageLoadingStatus], ([value]) => {
43
+ if (value === 'loading') {
44
+ this.canRender.set(false);
45
+ if (this.delayMs()) {
46
+ this.timeout = setTimeout(() => {
47
+ this.canRender.set(true);
48
+ clearTimeout(this.timeout);
49
+ }, this.delayMs());
50
+ }
51
+ else {
52
+ this.canRender.set(true);
53
+ }
69
54
  }
70
55
  });
71
56
  }
72
- startDelayTimer() {
73
- this.clearDelayTimer();
74
- if (this.delayMs() > 0) {
75
- this.timeoutId = setTimeout(() => {
76
- this.canRender.set(true);
77
- }, this.delayMs());
78
- }
79
- else {
80
- this.canRender.set(true);
81
- }
82
- }
83
- clearDelayTimer() {
84
- if (this.timeoutId !== null) {
85
- clearTimeout(this.timeoutId);
86
- this.timeoutId = null;
87
- }
88
- }
89
- ngOnDestroy() {
90
- this.clearDelayTimer();
91
- }
92
57
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarFallbackDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
93
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.4", type: RdxAvatarFallbackDirective, isStandalone: true, selector: "span[rdxAvatarFallback]", inputs: { delayMs: { classPropertyName: "delayMs", publicName: "delayMs", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.display": "shouldRender() ? null : \"none\" " } }, exportAs: ["rdxAvatarFallback"], ngImport: i0 }); }
58
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.4", type: RdxAvatarFallbackDirective, isStandalone: true, selector: "span[rdxAvatarFallback]", inputs: { delayMs: { classPropertyName: "delayMs", publicName: "delayMs", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.display": "canRender() && rootContext.imageLoadingStatus() !== \"loaded\" ? null : \"none\" " } }, exportAs: ["rdxAvatarFallback"], ngImport: i0 }); }
94
59
  }
95
60
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarFallbackDirective, decorators: [{
96
61
  type: Directive,
97
62
  args: [{
98
63
  selector: 'span[rdxAvatarFallback]',
99
- standalone: true,
100
64
  exportAs: 'rdxAvatarFallback',
101
65
  host: {
102
- '[style.display]': 'shouldRender() ? null : "none" '
66
+ '[style.display]': 'canRender() && rootContext.imageLoadingStatus() !== "loaded" ? null : "none" '
103
67
  }
104
68
  }]
105
69
  }], ctorParameters: () => [] });
@@ -109,12 +73,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImpor
109
73
  */
110
74
  class RdxAvatarImageDirective {
111
75
  constructor() {
112
- this.avatarRoot = inject(RdxAvatarRootContext);
113
- this.elementRef = inject((ElementRef));
76
+ this.platformId = inject(PLATFORM_ID);
77
+ this.rootContext = injectAvatarRootContext();
114
78
  /**
115
79
  * @group Props
116
80
  */
117
81
  this.src = input();
82
+ this.referrerPolicy = input();
118
83
  /**
119
84
  * A callback providing information about the loading status of the image.
120
85
  * This is useful in case you want to control more precisely what to render as the image is loading.
@@ -122,48 +87,79 @@ class RdxAvatarImageDirective {
122
87
  * @group Emits
123
88
  */
124
89
  this.onLoadingStatusChange = output();
125
- this.imageLoadingStatus = computed(() => this.avatarRoot.imageLoadingStatus());
126
- }
127
- ngOnInit() {
128
- this.nativeElement.src = this.src();
129
- if (!this.nativeElement.src) {
130
- this.setImageStatus('error');
131
- }
132
- else if (this.nativeElement.complete) {
133
- this.setImageStatus('loaded');
90
+ this.isMounted = signal(false);
91
+ this.loadingStatus = signal('idle');
92
+ const updateStatus = (status) => () => {
93
+ if (this.isMounted()) {
94
+ this.loadingStatus.set(status);
95
+ }
96
+ };
97
+ if (isPlatformBrowser(this.platformId)) {
98
+ watch([this.src, this.referrerPolicy], ([src, referrer]) => {
99
+ if (this.isMounted()) {
100
+ if (!src) {
101
+ this.loadingStatus.set('error');
102
+ }
103
+ else {
104
+ const image = new window.Image();
105
+ this.loadingStatus.set('loading');
106
+ image.onload = updateStatus('loaded');
107
+ image.onerror = updateStatus('error');
108
+ image.src = src;
109
+ if (referrer) {
110
+ image.referrerPolicy = referrer;
111
+ }
112
+ }
113
+ }
114
+ });
115
+ watch([this.loadingStatus], ([value]) => {
116
+ this.onLoadingStatusChange.emit(value);
117
+ if (value !== 'idle') {
118
+ this.rootContext.imageLoadingStatus.set(value);
119
+ }
120
+ });
134
121
  }
135
122
  else {
136
- this.setImageStatus('loading');
123
+ this.loadingStatus.set('idle');
137
124
  }
138
125
  }
139
- onLoad() {
140
- this.setImageStatus('loaded');
141
- }
142
- onError() {
143
- this.setImageStatus('error');
144
- }
145
- setImageStatus(status) {
146
- this.avatarRoot.imageLoadingStatus.set(status);
147
- this.onLoadingStatusChange.emit(status);
126
+ ngOnInit() {
127
+ this.isMounted.set(true);
148
128
  }
149
- get nativeElement() {
150
- return this.elementRef.nativeElement;
129
+ ngOnDestroy() {
130
+ this.isMounted.set(false);
151
131
  }
152
132
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarImageDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
153
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.4", type: RdxAvatarImageDirective, isStandalone: true, selector: "img[rdxAvatarImage]", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onLoadingStatusChange: "onLoadingStatusChange" }, host: { listeners: { "load": "onLoad()", "error": "onError()" }, properties: { "style.display": "(imageLoadingStatus() === \"loaded\")? null : \"none\"" } }, exportAs: ["rdxAvatarImage"], ngImport: i0 }); }
133
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.4", type: RdxAvatarImageDirective, isStandalone: true, selector: "img[rdxAvatarImage]", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, referrerPolicy: { classPropertyName: "referrerPolicy", publicName: "referrerPolicy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onLoadingStatusChange: "onLoadingStatusChange" }, host: { attributes: { "role": "img" }, properties: { "attr.src": "src()", "attr.referrer-policy": "referrerPolicy()", "style.display": "(rootContext.imageLoadingStatus() === \"loaded\") ? null : \"none\"" } }, exportAs: ["rdxAvatarImage"], ngImport: i0 }); }
154
134
  }
155
135
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarImageDirective, decorators: [{
156
136
  type: Directive,
157
137
  args: [{
158
138
  selector: 'img[rdxAvatarImage]',
159
- standalone: true,
160
139
  exportAs: 'rdxAvatarImage',
161
140
  host: {
162
- '(load)': 'onLoad()',
163
- '(error)': 'onError()',
164
- '[style.display]': '(imageLoadingStatus() === "loaded")? null : "none"'
141
+ role: 'img',
142
+ '[attr.src]': 'src()',
143
+ '[attr.referrer-policy]': 'referrerPolicy()',
144
+ '[style.display]': '(rootContext.imageLoadingStatus() === "loaded") ? null : "none"'
165
145
  }
166
146
  }]
147
+ }], ctorParameters: () => [] });
148
+
149
+ class RdxAvatarRootDirective {
150
+ constructor() {
151
+ this.imageLoadingStatus = signal('loading');
152
+ }
153
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
154
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.4", type: RdxAvatarRootDirective, isStandalone: true, selector: "span[rdxAvatarRoot]", providers: [provideToken(AVATAR_ROOT_CONTEXT, RdxAvatarRootDirective)], exportAs: ["rdxAvatarRoot"], ngImport: i0 }); }
155
+ }
156
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImport: i0, type: RdxAvatarRootDirective, decorators: [{
157
+ type: Directive,
158
+ args: [{
159
+ selector: 'span[rdxAvatarRoot]',
160
+ exportAs: 'rdxAvatarRoot',
161
+ providers: [provideToken(AVATAR_ROOT_CONTEXT, RdxAvatarRootDirective)]
162
+ }]
167
163
  }] });
168
164
 
169
165
  const _imports = [
@@ -192,5 +188,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.4", ngImpor
192
188
  * Generated bundle index. Do not edit.
193
189
  */
194
190
 
195
- export { RdxAvatarConfigToken, RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootContext, RdxAvatarRootDirective, RdxCheckboxModule, defaultAvatarConfig, injectAvatarConfig, provideRdxAvatarConfig };
191
+ export { RdxAvatarConfigToken, RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarRootDirective, RdxCheckboxModule, defaultAvatarConfig, injectAvatarConfig, provideRdxAvatarConfig };
196
192
  //# sourceMappingURL=radix-ng-primitives-avatar.mjs.map