@radix-ng/primitives 1.0.5 → 1.0.7
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.
- package/aspect-ratio/README.md +1 -1
- package/fesm2022/radix-ng-primitives-accordion.mjs +40 -27
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +34 -34
- package/fesm2022/radix-ng-primitives-arrow.mjs +3 -3
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs +11 -35
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-autocomplete.mjs +175 -125
- package/fesm2022/radix-ng-primitives-autocomplete.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-avatar.mjs +92 -35
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-button.mjs +11 -7
- package/fesm2022/radix-ng-primitives-button.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-calendar.mjs +140 -90
- package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +63 -46
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +37 -25
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-combobox.mjs +278 -177
- package/fesm2022/radix-ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-composite.mjs +50 -33
- package/fesm2022/radix-ng-primitives-composite.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-config.mjs +7 -5
- package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-context-menu.mjs +48 -22
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +44 -28
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-cropper.mjs +73 -45
- package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +70 -40
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +93 -67
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-direction-provider.mjs +5 -4
- package/fesm2022/radix-ng-primitives-direction-provider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +20 -16
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-drawer.mjs +107 -81
- package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-editable.mjs +53 -39
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +76 -50
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-fieldset.mjs +8 -7
- package/fesm2022/radix-ng-primitives-fieldset.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs +77 -40
- package/fesm2022/radix-ng-primitives-floating-focus-manager.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-focus-guards.mjs +3 -3
- package/fesm2022/radix-ng-primitives-focus-scope.mjs +7 -5
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-form.mjs +26 -17
- package/fesm2022/radix-ng-primitives-form.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-input.mjs +41 -22
- package/fesm2022/radix-ng-primitives-input.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-label.mjs +11 -8
- package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +274 -154
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +35 -17
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-meter.mjs +41 -30
- package/fesm2022/radix-ng-primitives-meter.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +220 -183
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +93 -61
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-pagination.mjs +48 -38
- package/fesm2022/radix-ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +150 -107
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +79 -47
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-portal.mjs +20 -13
- package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +3 -3
- package/fesm2022/radix-ng-primitives-preview-card.mjs +119 -74
- package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-progress.mjs +73 -46
- package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +58 -40
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-scroll-area.mjs +57 -41
- package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-select.mjs +595 -102
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-separator.mjs +11 -15
- package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +101 -64
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +53 -39
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +25 -20
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +76 -51
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +72 -41
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toast.mjs +75 -56
- package/fesm2022/radix-ng-primitives-toast.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +39 -23
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +36 -36
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +52 -31
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +118 -63
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs +31 -20
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
- package/package.json +2 -2
- package/types/radix-ng-primitives-accordion.d.ts +1 -0
- package/types/radix-ng-primitives-aspect-ratio.d.ts +10 -23
- package/types/radix-ng-primitives-autocomplete.d.ts +3 -1
- package/types/radix-ng-primitives-avatar.d.ts +51 -25
- package/types/radix-ng-primitives-checkbox.d.ts +26 -98
- package/types/radix-ng-primitives-combobox.d.ts +28 -9
- package/types/radix-ng-primitives-context-menu.d.ts +2 -0
- package/types/radix-ng-primitives-dialog.d.ts +6 -3
- package/types/radix-ng-primitives-field.d.ts +33 -207
- package/types/radix-ng-primitives-floating-focus-manager.d.ts +11 -0
- package/types/radix-ng-primitives-form.d.ts +24 -33
- package/types/radix-ng-primitives-label.d.ts +3 -2
- package/types/radix-ng-primitives-menu.d.ts +47 -15
- package/types/radix-ng-primitives-menubar.d.ts +6 -1
- package/types/radix-ng-primitives-navigation-menu.d.ts +8 -6
- package/types/radix-ng-primitives-number-field.d.ts +1 -1
- package/types/radix-ng-primitives-popover.d.ts +12 -4
- package/types/radix-ng-primitives-preview-card.d.ts +18 -5
- package/types/radix-ng-primitives-progress.d.ts +59 -121
- package/types/radix-ng-primitives-radio.d.ts +0 -1
- package/types/radix-ng-primitives-select.d.ts +186 -391
- package/types/radix-ng-primitives-separator.d.ts +0 -7
- package/types/radix-ng-primitives-toggle-group.d.ts +7 -3
- package/types/radix-ng-primitives-toggle.d.ts +8 -8
- package/types/radix-ng-primitives-toolbar.d.ts +2 -0
- package/types/radix-ng-primitives-tooltip.d.ts +17 -3
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, input, signal, Directive, PLATFORM_ID, output, NgModule } from '@angular/core';
|
|
3
|
-
import {
|
|
3
|
+
import { createContext, watch } from '@radix-ng/primitives/core';
|
|
4
4
|
import { isPlatformBrowser } from '@angular/common';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
function injectAvatarRootContext() {
|
|
8
|
-
return inject(AVATAR_ROOT_CONTEXT);
|
|
9
|
-
}
|
|
6
|
+
const [injectAvatarRootContext, provideAvatarRootContext] = createContext('AvatarRootContext', 'components/avatar');
|
|
10
7
|
|
|
11
8
|
const defaultAvatarConfig = {
|
|
12
9
|
delayMs: 0
|
|
@@ -37,8 +34,10 @@ class RdxAvatarFallbackDirective {
|
|
|
37
34
|
* @group Props
|
|
38
35
|
* @defaultValue 0
|
|
39
36
|
*/
|
|
40
|
-
this.delayMs = input(this.config.delayMs,
|
|
41
|
-
|
|
37
|
+
this.delayMs = input(this.config.delayMs, /* @ts-ignore */
|
|
38
|
+
...(ngDevMode ? [{ debugName: "delayMs" }] : /* istanbul ignore next */ []));
|
|
39
|
+
this.canRender = signal(false, /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "canRender" }] : /* istanbul ignore next */ []));
|
|
42
41
|
// Enable the fallback after an optional delay (so it only appears for
|
|
43
42
|
// those on slower connections), independent of the image load status —
|
|
44
43
|
// matches Radix/Base UI. The `display` binding then hides it once the
|
|
@@ -56,10 +55,10 @@ class RdxAvatarFallbackDirective {
|
|
|
56
55
|
}
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
60
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
58
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarFallbackDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
59
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", 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 }); }
|
|
61
60
|
}
|
|
62
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
61
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarFallbackDirective, decorators: [{
|
|
63
62
|
type: Directive,
|
|
64
63
|
args: [{
|
|
65
64
|
selector: 'span[rdxAvatarFallback]',
|
|
@@ -80,8 +79,32 @@ class RdxAvatarImageDirective {
|
|
|
80
79
|
/**
|
|
81
80
|
* @group Props
|
|
82
81
|
*/
|
|
83
|
-
this.src = input(
|
|
84
|
-
|
|
82
|
+
this.src = input(/* @ts-ignore */
|
|
83
|
+
...(ngDevMode ? [undefined, { debugName: "src" }] : /* istanbul ignore next */ []));
|
|
84
|
+
/**
|
|
85
|
+
* A responsive `srcset` for the image. When set without `src`, an empty `src` no longer counts as
|
|
86
|
+
* an error.
|
|
87
|
+
*
|
|
88
|
+
* @group Props
|
|
89
|
+
*/
|
|
90
|
+
this.srcSet = input(/* @ts-ignore */
|
|
91
|
+
...(ngDevMode ? [undefined, { debugName: "srcSet" }] : /* istanbul ignore next */ []));
|
|
92
|
+
/**
|
|
93
|
+
* The `sizes` attribute paired with `srcSet`.
|
|
94
|
+
*
|
|
95
|
+
* @group Props
|
|
96
|
+
*/
|
|
97
|
+
this.sizes = input(/* @ts-ignore */
|
|
98
|
+
...(ngDevMode ? [undefined, { debugName: "sizes" }] : /* istanbul ignore next */ []));
|
|
99
|
+
/**
|
|
100
|
+
* The CORS mode used when fetching the image.
|
|
101
|
+
*
|
|
102
|
+
* @group Props
|
|
103
|
+
*/
|
|
104
|
+
this.crossOrigin = input(/* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [undefined, { debugName: "crossOrigin" }] : /* istanbul ignore next */ []));
|
|
106
|
+
this.referrerPolicy = input(/* @ts-ignore */
|
|
107
|
+
...(ngDevMode ? [undefined, { debugName: "referrerPolicy" }] : /* istanbul ignore next */ []));
|
|
85
108
|
/**
|
|
86
109
|
* A callback providing information about the loading status of the image.
|
|
87
110
|
* This is useful in case you want to control more precisely what to render as the image is loading.
|
|
@@ -89,13 +112,14 @@ class RdxAvatarImageDirective {
|
|
|
89
112
|
* @group Emits
|
|
90
113
|
*/
|
|
91
114
|
this.onLoadingStatusChange = output();
|
|
92
|
-
this.loadingStatus = signal('idle',
|
|
115
|
+
this.loadingStatus = signal('idle', /* @ts-ignore */
|
|
116
|
+
...(ngDevMode ? [{ debugName: "loadingStatus" }] : /* istanbul ignore next */ []));
|
|
93
117
|
// Loading is browser-only; on the server the status stays 'idle'.
|
|
94
118
|
if (!isPlatformBrowser(this.platformId)) {
|
|
95
119
|
return;
|
|
96
120
|
}
|
|
97
|
-
watch([this.src, this.referrerPolicy], ([src, referrer], onCleanup) => {
|
|
98
|
-
if (!src) {
|
|
121
|
+
watch([this.src, this.srcSet, this.sizes, this.crossOrigin, this.referrerPolicy], ([src, srcSet, sizes, crossOrigin, referrer], onCleanup) => {
|
|
122
|
+
if (!src && !srcSet) {
|
|
99
123
|
this.loadingStatus.set('error');
|
|
100
124
|
return;
|
|
101
125
|
}
|
|
@@ -103,11 +127,27 @@ class RdxAvatarImageDirective {
|
|
|
103
127
|
this.loadingStatus.set('loading');
|
|
104
128
|
image.onload = () => this.loadingStatus.set('loaded');
|
|
105
129
|
image.onerror = () => this.loadingStatus.set('error');
|
|
106
|
-
// Set
|
|
130
|
+
// Set the fetch-affecting attributes before `src`/`srcset` so they apply to the request.
|
|
107
131
|
if (referrer) {
|
|
108
132
|
image.referrerPolicy = referrer;
|
|
109
133
|
}
|
|
110
|
-
|
|
134
|
+
if (crossOrigin !== undefined) {
|
|
135
|
+
image.crossOrigin = crossOrigin;
|
|
136
|
+
}
|
|
137
|
+
if (srcSet) {
|
|
138
|
+
image.srcset = srcSet;
|
|
139
|
+
}
|
|
140
|
+
if (sizes) {
|
|
141
|
+
image.sizes = sizes;
|
|
142
|
+
}
|
|
143
|
+
if (src) {
|
|
144
|
+
image.src = src;
|
|
145
|
+
}
|
|
146
|
+
// A cached/already-decoded image is ready synchronously — resolve immediately so the
|
|
147
|
+
// fallback delay isn't started for an image that is already available.
|
|
148
|
+
if (image.complete && image.naturalWidth > 0) {
|
|
149
|
+
this.loadingStatus.set('loaded');
|
|
150
|
+
}
|
|
111
151
|
// Drop handlers for a stale src (or on destroy) so a late load/error
|
|
112
152
|
// can't overwrite the status for the current one.
|
|
113
153
|
onCleanup(() => {
|
|
@@ -116,52 +156,69 @@ class RdxAvatarImageDirective {
|
|
|
116
156
|
});
|
|
117
157
|
});
|
|
118
158
|
watch([this.loadingStatus], ([value]) => {
|
|
119
|
-
|
|
120
|
-
if (value
|
|
121
|
-
|
|
159
|
+
// Base UI fires the callback only once loading actually starts — skip the initial `idle`.
|
|
160
|
+
if (value === 'idle') {
|
|
161
|
+
return;
|
|
122
162
|
}
|
|
163
|
+
this.onLoadingStatusChange.emit(value);
|
|
164
|
+
this.rootContext.imageLoadingStatus.set(value);
|
|
123
165
|
});
|
|
124
166
|
}
|
|
125
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
126
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
167
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarImageDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
168
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", type: RdxAvatarImageDirective, isStandalone: true, selector: "img[rdxAvatarImage]", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, srcSet: { classPropertyName: "srcSet", publicName: "srcSet", isSignal: true, isRequired: false, transformFunction: null }, sizes: { classPropertyName: "sizes", publicName: "sizes", isSignal: true, isRequired: false, transformFunction: null }, crossOrigin: { classPropertyName: "crossOrigin", publicName: "crossOrigin", isSignal: true, isRequired: false, transformFunction: null }, referrerPolicy: { classPropertyName: "referrerPolicy", publicName: "referrerPolicy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onLoadingStatusChange: "onLoadingStatusChange" }, host: { properties: { "attr.src": "src()", "attr.srcset": "srcSet()", "attr.sizes": "sizes()", "attr.crossorigin": "crossOrigin()", "attr.referrerpolicy": "referrerPolicy()", "style.display": "(rootContext.imageLoadingStatus() === \"loaded\") ? null : \"none\"" } }, exportAs: ["rdxAvatarImage"], ngImport: i0 }); }
|
|
127
169
|
}
|
|
128
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarImageDirective, decorators: [{
|
|
129
171
|
type: Directive,
|
|
130
172
|
args: [{
|
|
131
173
|
selector: 'img[rdxAvatarImage]',
|
|
132
174
|
exportAs: 'rdxAvatarImage',
|
|
133
175
|
host: {
|
|
134
|
-
role
|
|
176
|
+
// The host is a native `<img>` (selector `img[rdxAvatarImage]`) — its implicit `img` role is
|
|
177
|
+
// already correct, and forcing `role="img"` here would override any consumer override (Base UI
|
|
178
|
+
// adds no role).
|
|
135
179
|
'[attr.src]': 'src()',
|
|
180
|
+
'[attr.srcset]': 'srcSet()',
|
|
181
|
+
'[attr.sizes]': 'sizes()',
|
|
182
|
+
'[attr.crossorigin]': 'crossOrigin()',
|
|
136
183
|
'[attr.referrerpolicy]': 'referrerPolicy()',
|
|
137
184
|
'[style.display]': '(rootContext.imageLoadingStatus() === "loaded") ? null : "none"'
|
|
138
185
|
}
|
|
139
186
|
}]
|
|
140
|
-
}], ctorParameters: () => [], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], referrerPolicy: [{ type: i0.Input, args: [{ isSignal: true, alias: "referrerPolicy", required: false }] }], onLoadingStatusChange: [{ type: i0.Output, args: ["onLoadingStatusChange"] }] } });
|
|
187
|
+
}], ctorParameters: () => [], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], srcSet: [{ type: i0.Input, args: [{ isSignal: true, alias: "srcSet", required: false }] }], sizes: [{ type: i0.Input, args: [{ isSignal: true, alias: "sizes", required: false }] }], crossOrigin: [{ type: i0.Input, args: [{ isSignal: true, alias: "crossOrigin", required: false }] }], referrerPolicy: [{ type: i0.Input, args: [{ isSignal: true, alias: "referrerPolicy", required: false }] }], onLoadingStatusChange: [{ type: i0.Output, args: ["onLoadingStatusChange"] }] } });
|
|
141
188
|
|
|
189
|
+
const rootContext = () => {
|
|
190
|
+
const root = inject(RdxAvatarRootDirective);
|
|
191
|
+
return {
|
|
192
|
+
imageLoadingStatus: root.imageLoadingStatus
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* @group Components
|
|
197
|
+
*/
|
|
142
198
|
class RdxAvatarRootDirective {
|
|
143
199
|
constructor() {
|
|
144
|
-
this.imageLoadingStatus = signal('idle',
|
|
200
|
+
this.imageLoadingStatus = signal('idle', /* @ts-ignore */
|
|
201
|
+
...(ngDevMode ? [{ debugName: "imageLoadingStatus" }] : /* istanbul ignore next */ []));
|
|
145
202
|
}
|
|
146
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
147
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
203
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarRootDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
204
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.2", type: RdxAvatarRootDirective, isStandalone: true, selector: "span[rdxAvatarRoot]", providers: [provideAvatarRootContext(rootContext)], exportAs: ["rdxAvatarRoot"], ngImport: i0 }); }
|
|
148
205
|
}
|
|
149
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarRootDirective, decorators: [{
|
|
150
207
|
type: Directive,
|
|
151
208
|
args: [{
|
|
152
209
|
selector: 'span[rdxAvatarRoot]',
|
|
153
210
|
exportAs: 'rdxAvatarRoot',
|
|
154
|
-
providers: [
|
|
211
|
+
providers: [provideAvatarRootContext(rootContext)]
|
|
155
212
|
}]
|
|
156
213
|
}] });
|
|
157
214
|
|
|
158
215
|
const _imports = [RdxAvatarRootDirective, RdxAvatarFallbackDirective, RdxAvatarImageDirective];
|
|
159
216
|
class RdxAvatarModule {
|
|
160
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
161
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
162
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
217
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
218
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarModule, imports: [RdxAvatarRootDirective, RdxAvatarFallbackDirective, RdxAvatarImageDirective], exports: [RdxAvatarRootDirective, RdxAvatarFallbackDirective, RdxAvatarImageDirective] }); }
|
|
219
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarModule }); }
|
|
163
220
|
}
|
|
164
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
221
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxAvatarModule, decorators: [{
|
|
165
222
|
type: NgModule,
|
|
166
223
|
args: [{
|
|
167
224
|
imports: [..._imports],
|
|
@@ -173,5 +230,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImpor
|
|
|
173
230
|
* Generated bundle index. Do not edit.
|
|
174
231
|
*/
|
|
175
232
|
|
|
176
|
-
export { RdxAvatarConfigToken, RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarModule, RdxAvatarRootDirective, defaultAvatarConfig, injectAvatarConfig, provideRdxAvatarConfig };
|
|
233
|
+
export { RdxAvatarConfigToken, RdxAvatarFallbackDirective, RdxAvatarImageDirective, RdxAvatarModule, RdxAvatarRootDirective, defaultAvatarConfig, injectAvatarConfig, injectAvatarRootContext, provideAvatarRootContext, provideRdxAvatarConfig };
|
|
177
234
|
//# sourceMappingURL=radix-ng-primitives-avatar.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radix-ng-primitives-avatar.mjs","sources":["../../../packages/primitives/avatar/src/avatar-context.token.ts","../../../packages/primitives/avatar/src/avatar.config.ts","../../../packages/primitives/avatar/src/avatar-fallback.directive.ts","../../../packages/primitives/avatar/src/avatar-image.directive.ts","../../../packages/primitives/avatar/src/avatar-root.directive.ts","../../../packages/primitives/avatar/index.ts","../../../packages/primitives/avatar/radix-ng-primitives-avatar.ts"],"sourcesContent":["import { inject, InjectionToken, WritableSignal } from '@angular/core';\nimport { RdxImageLoadingStatus } from './types';\n\nexport interface AvatarContextToken {\n imageLoadingStatus: WritableSignal<RdxImageLoadingStatus>;\n}\n\nexport const AVATAR_ROOT_CONTEXT = new InjectionToken<AvatarContextToken>('AVATAR_ROOT_CONTEXT');\n\nexport function injectAvatarRootContext(): AvatarContextToken {\n return inject(AVATAR_ROOT_CONTEXT);\n}\n","import { inject, InjectionToken, Provider } from '@angular/core';\n\nexport interface RdxAvatarConfig {\n /**\n * Define a delay before the fallback is shown.\n * This is useful to only show the fallback for those with slower connections.\n * @default 0\n */\n delayMs: number;\n}\n\nexport const defaultAvatarConfig: RdxAvatarConfig = {\n delayMs: 0\n};\n\nexport const RdxAvatarConfigToken = new InjectionToken<RdxAvatarConfig>('RdxAvatarConfigToken');\n\nexport function provideRdxAvatarConfig(config: Partial<RdxAvatarConfig>): Provider[] {\n return [\n {\n provide: RdxAvatarConfigToken,\n useValue: { ...defaultAvatarConfig, ...config }\n }\n ];\n}\n\nexport function injectAvatarConfig(): RdxAvatarConfig {\n return inject(RdxAvatarConfigToken, { optional: true }) ?? defaultAvatarConfig;\n}\n","import { Directive, input, signal } from '@angular/core';\nimport { watch } from '@radix-ng/primitives/core';\nimport { injectAvatarRootContext } from './avatar-context.token';\nimport { injectAvatarConfig } from './avatar.config';\n\n/**\n * @group Components\n */\n@Directive({\n selector: 'span[rdxAvatarFallback]',\n exportAs: 'rdxAvatarFallback',\n host: {\n '[style.display]': 'canRender() && rootContext.imageLoadingStatus() !== \"loaded\" ? null : \"none\"'\n }\n})\nexport class RdxAvatarFallbackDirective {\n private readonly config = injectAvatarConfig();\n\n protected readonly rootContext = injectAvatarRootContext();\n\n /**\n * Useful for delaying rendering so it only appears for those with slower connections.\n *\n * @group Props\n * @defaultValue 0\n */\n readonly delayMs = input<number>(this.config.delayMs);\n\n protected readonly canRender = signal(false);\n\n constructor() {\n // Enable the fallback after an optional delay (so it only appears for\n // those on slower connections), independent of the image load status —\n // matches Radix/Base UI. The `display` binding then hides it once the\n // image has loaded.\n watch([this.delayMs], ([delayMs], onCleanup) => {\n this.canRender.set(false);\n\n if (delayMs) {\n const timeout = setTimeout(() => this.canRender.set(true), delayMs);\n // Cancel a pending delay if delayMs changes or the directive is\n // destroyed before it fires.\n onCleanup(() => clearTimeout(timeout));\n } else {\n this.canRender.set(true);\n }\n });\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { Directive, inject, input, output, PLATFORM_ID, signal } from '@angular/core';\nimport { watch } from '@radix-ng/primitives/core';\nimport { injectAvatarRootContext } from './avatar-context.token';\nimport { HTMLAttributeReferrerPolicy, RdxImageLoadingStatus } from './types';\n\n/**\n * @group Components\n */\n@Directive({\n selector: 'img[rdxAvatarImage]',\n exportAs: 'rdxAvatarImage',\n host: {\n role: 'img',\n '[attr.src]': 'src()',\n '[attr.referrerpolicy]': 'referrerPolicy()',\n '[style.display]': '(rootContext.imageLoadingStatus() === \"loaded\") ? null : \"none\"'\n }\n})\nexport class RdxAvatarImageDirective {\n private readonly platformId = inject(PLATFORM_ID);\n\n protected readonly rootContext = injectAvatarRootContext();\n\n /**\n * @group Props\n */\n readonly src = input<string>();\n\n readonly referrerPolicy = input<HTMLAttributeReferrerPolicy>();\n\n /**\n * A callback providing information about the loading status of the image.\n * This is useful in case you want to control more precisely what to render as the image is loading.\n *\n * @group Emits\n */\n readonly onLoadingStatusChange = output<RdxImageLoadingStatus>();\n\n private readonly loadingStatus = signal<RdxImageLoadingStatus>('idle');\n\n constructor() {\n // Loading is browser-only; on the server the status stays 'idle'.\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n watch([this.src, this.referrerPolicy], ([src, referrer], onCleanup) => {\n if (!src) {\n this.loadingStatus.set('error');\n return;\n }\n\n const image = new window.Image();\n this.loadingStatus.set('loading');\n image.onload = () => this.loadingStatus.set('loaded');\n image.onerror = () => this.loadingStatus.set('error');\n // Set referrerPolicy before src so it applies to the fetch.\n if (referrer) {\n image.referrerPolicy = referrer;\n }\n image.src = src;\n\n // Drop handlers for a stale src (or on destroy) so a late load/error\n // can't overwrite the status for the current one.\n onCleanup(() => {\n image.onload = null;\n image.onerror = null;\n });\n });\n\n watch([this.loadingStatus], ([value]) => {\n this.onLoadingStatusChange.emit(value);\n if (value !== 'idle') {\n this.rootContext.imageLoadingStatus.set(value);\n }\n });\n }\n}\n","import { Directive, signal } from '@angular/core';\nimport { provideToken } from '@radix-ng/primitives/core';\nimport { AVATAR_ROOT_CONTEXT, AvatarContextToken } from './avatar-context.token';\nimport { RdxImageLoadingStatus } from './types';\n\n@Directive({\n selector: 'span[rdxAvatarRoot]',\n exportAs: 'rdxAvatarRoot',\n providers: [provideToken(AVATAR_ROOT_CONTEXT, RdxAvatarRootDirective)]\n})\nexport class RdxAvatarRootDirective implements AvatarContextToken {\n readonly imageLoadingStatus = signal<RdxImageLoadingStatus>('idle');\n}\n","import { NgModule } from '@angular/core';\nimport { RdxAvatarFallbackDirective } from './src/avatar-fallback.directive';\nimport { RdxAvatarImageDirective } from './src/avatar-image.directive';\nimport { RdxAvatarRootDirective } from './src/avatar-root.directive';\n\nexport * from './src/avatar-fallback.directive';\nexport * from './src/avatar-image.directive';\nexport * from './src/avatar-root.directive';\nexport * from './src/avatar.config';\nexport type { RdxImageLoadingStatus } from './src/types';\n\nconst _imports = [RdxAvatarRootDirective, RdxAvatarFallbackDirective, RdxAvatarImageDirective];\n\n@NgModule({\n imports: [..._imports],\n exports: [..._imports]\n})\nexport class RdxAvatarModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAOO,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAqB,qBAAqB,CAAC;SAEhF,uBAAuB,GAAA;AACnC,IAAA,OAAO,MAAM,CAAC,mBAAmB,CAAC;AACtC;;ACAO,MAAM,mBAAmB,GAAoB;AAChD,IAAA,OAAO,EAAE;;MAGA,oBAAoB,GAAG,IAAI,cAAc,CAAkB,sBAAsB;AAExF,SAAU,sBAAsB,CAAC,MAAgC,EAAA;IACnE,OAAO;AACH,QAAA;AACI,YAAA,OAAO,EAAE,oBAAoB;AAC7B,YAAA,QAAQ,EAAE,EAAE,GAAG,mBAAmB,EAAE,GAAG,MAAM;AAChD;KACJ;AACL;SAEgB,kBAAkB,GAAA;AAC9B,IAAA,OAAO,MAAM,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,mBAAmB;AAClF;;ACvBA;;AAEG;MAQU,0BAA0B,CAAA;AAenC,IAAA,WAAA,GAAA;QAdiB,IAAA,CAAA,MAAM,GAAG,kBAAkB,EAAE;QAE3B,IAAA,CAAA,WAAW,GAAG,uBAAuB,EAAE;AAE1D;;;;;AAKG;QACM,IAAA,CAAA,OAAO,GAAG,KAAK,CAAS,IAAI,CAAC,MAAM,CAAC,OAAO,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,SAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAElC,QAAA,IAAA,CAAA,SAAS,GAAG,M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AA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAAf,eAAe,EAAA,OAAA,EAAA,CANV,sBAAsB,EAAE,0BAA0B,EAAE,uBAAuB,CAAA,EAAA,OAAA,EAAA,CAA3E,sBAAsB,EAAE,0BAA0B,EAAE,uBAAuB,CAAA,EAAA,CAAA,CAAA;+GAMhF,eAAe,EAAA,CAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC;AACtB,oBAAA,OAAO,EAAE,CAAC,GAAG,QAAQ;AACxB,iBAAA;;;AChBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"radix-ng-primitives-avatar.mjs","sources":["../../../packages/primitives/avatar/src/avatar-context.token.ts","../../../packages/primitives/avatar/src/avatar.config.ts","../../../packages/primitives/avatar/src/avatar-fallback.directive.ts","../../../packages/primitives/avatar/src/avatar-image.directive.ts","../../../packages/primitives/avatar/src/avatar-root.directive.ts","../../../packages/primitives/avatar/index.ts","../../../packages/primitives/avatar/radix-ng-primitives-avatar.ts"],"sourcesContent":["import { WritableSignal } from '@angular/core';\nimport { createContext } from '@radix-ng/primitives/core';\nimport { RdxImageLoadingStatus } from './types';\n\nexport interface AvatarRootContext {\n imageLoadingStatus: WritableSignal<RdxImageLoadingStatus>;\n}\n\nexport const [injectAvatarRootContext, provideAvatarRootContext] = createContext<AvatarRootContext>(\n 'AvatarRootContext',\n 'components/avatar'\n);\n","import { inject, InjectionToken, Provider } from '@angular/core';\n\nexport interface RdxAvatarConfig {\n /**\n * Define a delay before the fallback is shown.\n * This is useful to only show the fallback for those with slower connections.\n * @default 0\n */\n delayMs: number;\n}\n\nexport const defaultAvatarConfig: RdxAvatarConfig = {\n delayMs: 0\n};\n\nexport const RdxAvatarConfigToken = new InjectionToken<RdxAvatarConfig>('RdxAvatarConfigToken');\n\nexport function provideRdxAvatarConfig(config: Partial<RdxAvatarConfig>): Provider[] {\n return [\n {\n provide: RdxAvatarConfigToken,\n useValue: { ...defaultAvatarConfig, ...config }\n }\n ];\n}\n\nexport function injectAvatarConfig(): RdxAvatarConfig {\n return inject(RdxAvatarConfigToken, { optional: true }) ?? defaultAvatarConfig;\n}\n","import { Directive, input, signal } from '@angular/core';\nimport { watch } from '@radix-ng/primitives/core';\nimport { injectAvatarRootContext } from './avatar-context.token';\nimport { injectAvatarConfig } from './avatar.config';\n\n/**\n * @group Components\n */\n@Directive({\n selector: 'span[rdxAvatarFallback]',\n exportAs: 'rdxAvatarFallback',\n host: {\n '[style.display]': 'canRender() && rootContext.imageLoadingStatus() !== \"loaded\" ? null : \"none\"'\n }\n})\nexport class RdxAvatarFallbackDirective {\n private readonly config = injectAvatarConfig();\n\n protected readonly rootContext = injectAvatarRootContext();\n\n /**\n * Useful for delaying rendering so it only appears for those with slower connections.\n *\n * @group Props\n * @defaultValue 0\n */\n readonly delayMs = input<number>(this.config.delayMs);\n\n protected readonly canRender = signal(false);\n\n constructor() {\n // Enable the fallback after an optional delay (so it only appears for\n // those on slower connections), independent of the image load status —\n // matches Radix/Base UI. The `display` binding then hides it once the\n // image has loaded.\n watch([this.delayMs], ([delayMs], onCleanup) => {\n this.canRender.set(false);\n\n if (delayMs) {\n const timeout = setTimeout(() => this.canRender.set(true), delayMs);\n // Cancel a pending delay if delayMs changes or the directive is\n // destroyed before it fires.\n onCleanup(() => clearTimeout(timeout));\n } else {\n this.canRender.set(true);\n }\n });\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { Directive, inject, input, output, PLATFORM_ID, signal } from '@angular/core';\nimport { watch } from '@radix-ng/primitives/core';\nimport { injectAvatarRootContext } from './avatar-context.token';\nimport { HTMLAttributeReferrerPolicy, RdxImageLoadingStatus } from './types';\n\n/**\n * @group Components\n */\n@Directive({\n selector: 'img[rdxAvatarImage]',\n exportAs: 'rdxAvatarImage',\n host: {\n // The host is a native `<img>` (selector `img[rdxAvatarImage]`) — its implicit `img` role is\n // already correct, and forcing `role=\"img\"` here would override any consumer override (Base UI\n // adds no role).\n '[attr.src]': 'src()',\n '[attr.srcset]': 'srcSet()',\n '[attr.sizes]': 'sizes()',\n '[attr.crossorigin]': 'crossOrigin()',\n '[attr.referrerpolicy]': 'referrerPolicy()',\n '[style.display]': '(rootContext.imageLoadingStatus() === \"loaded\") ? null : \"none\"'\n }\n})\nexport class RdxAvatarImageDirective {\n private readonly platformId = inject(PLATFORM_ID);\n\n protected readonly rootContext = injectAvatarRootContext();\n\n /**\n * @group Props\n */\n readonly src = input<string>();\n\n /**\n * A responsive `srcset` for the image. When set without `src`, an empty `src` no longer counts as\n * an error.\n *\n * @group Props\n */\n readonly srcSet = input<string>();\n\n /**\n * The `sizes` attribute paired with `srcSet`.\n *\n * @group Props\n */\n readonly sizes = input<string>();\n\n /**\n * The CORS mode used when fetching the image.\n *\n * @group Props\n */\n readonly crossOrigin = input<'anonymous' | 'use-credentials' | ''>();\n\n readonly referrerPolicy = input<HTMLAttributeReferrerPolicy>();\n\n /**\n * A callback providing information about the loading status of the image.\n * This is useful in case you want to control more precisely what to render as the image is loading.\n *\n * @group Emits\n */\n readonly onLoadingStatusChange = output<RdxImageLoadingStatus>();\n\n private readonly loadingStatus = signal<RdxImageLoadingStatus>('idle');\n\n constructor() {\n // Loading is browser-only; on the server the status stays 'idle'.\n if (!isPlatformBrowser(this.platformId)) {\n return;\n }\n\n watch(\n [this.src, this.srcSet, this.sizes, this.crossOrigin, this.referrerPolicy],\n ([src, srcSet, sizes, crossOrigin, referrer], onCleanup) => {\n if (!src && !srcSet) {\n this.loadingStatus.set('error');\n return;\n }\n\n const image = new window.Image();\n this.loadingStatus.set('loading');\n image.onload = () => this.loadingStatus.set('loaded');\n image.onerror = () => this.loadingStatus.set('error');\n // Set the fetch-affecting attributes before `src`/`srcset` so they apply to the request.\n if (referrer) {\n image.referrerPolicy = referrer;\n }\n if (crossOrigin !== undefined) {\n image.crossOrigin = crossOrigin;\n }\n if (srcSet) {\n image.srcset = srcSet;\n }\n if (sizes) {\n image.sizes = sizes;\n }\n if (src) {\n image.src = src;\n }\n\n // A cached/already-decoded image is ready synchronously — resolve immediately so the\n // fallback delay isn't started for an image that is already available.\n if (image.complete && image.naturalWidth > 0) {\n this.loadingStatus.set('loaded');\n }\n\n // Drop handlers for a stale src (or on destroy) so a late load/error\n // can't overwrite the status for the current one.\n onCleanup(() => {\n image.onload = null;\n image.onerror = null;\n });\n }\n );\n\n watch([this.loadingStatus], ([value]) => {\n // Base UI fires the callback only once loading actually starts — skip the initial `idle`.\n if (value === 'idle') {\n return;\n }\n this.onLoadingStatusChange.emit(value);\n this.rootContext.imageLoadingStatus.set(value);\n });\n }\n}\n","import { Directive, inject, signal } from '@angular/core';\nimport { AvatarRootContext, provideAvatarRootContext } from './avatar-context.token';\nimport { RdxImageLoadingStatus } from './types';\n\nconst rootContext = (): AvatarRootContext => {\n const root = inject(RdxAvatarRootDirective);\n return {\n imageLoadingStatus: root.imageLoadingStatus\n };\n};\n\n/**\n * @group Components\n */\n@Directive({\n selector: 'span[rdxAvatarRoot]',\n exportAs: 'rdxAvatarRoot',\n providers: [provideAvatarRootContext(rootContext)]\n})\nexport class RdxAvatarRootDirective {\n readonly imageLoadingStatus = signal<RdxImageLoadingStatus>('idle');\n}\n","import { NgModule } from '@angular/core';\nimport { RdxAvatarFallbackDirective } from './src/avatar-fallback.directive';\nimport { RdxAvatarImageDirective } from './src/avatar-image.directive';\nimport { RdxAvatarRootDirective } from './src/avatar-root.directive';\n\nexport * from './src/avatar-context.token';\nexport * from './src/avatar-fallback.directive';\nexport * from './src/avatar-image.directive';\nexport * from './src/avatar-root.directive';\nexport * from './src/avatar.config';\nexport type { HTMLAttributeReferrerPolicy, RdxImageLoadingStatus } from './src/types';\n\nconst _imports = [RdxAvatarRootDirective, RdxAvatarFallbackDirective, RdxAvatarImageDirective];\n\n@NgModule({\n imports: [..._imports],\n exports: [..._imports]\n})\nexport class RdxAvatarModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAQO,MAAM,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,GAAG,aAAa,CAC5E,mBAAmB,EACnB,mBAAmB;;ACChB,MAAM,mBAAmB,GAAoB;AAChD,IAAA,OAAO,EAAE;;MAGA,oBAAoB,GAAG,IAAI,cAAc,CAAkB,sBAAsB;AAExF,SAAU,sBAAsB,CAAC,MAAgC,EAAA;IACnE,OAAO;AACH,QAAA;AACI,YAAA,OAAO,EAAE,oBAAoB;AAC7B,YAAA,QAAQ,EAAE,EAAE,GAAG,mBAAmB,EAAE,GAAG,MAAM;AAChD;KACJ;AACL;SAEgB,kBAAkB,GAAA;AAC9B,IAAA,OAAO,MAAM,CAAC,oBAAoB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,mBAAmB;AAClF;;ACvBA;;AAEG;MAQU,0BAA0B,CAAA;AAenC,IAAA,WAAA,GAAA;QAdiB,IAAA,CAAA,MAAM,GAAG,kBAAkB,EAAE;QAE3B,IAAA,CAAA,WAAW,GAAG,uBAAuB,EAAE;AAE1D;;;;;AAKG;AACM,QAAA,IAAA,CAAA,OAAO,GAAG,KAAK,CAAS,IAAI,CAAC,MAAM,CAAC,OAAO;oFAAC;QAElC,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,KAAK;sFAAC;;;;;AAOxC,QAAA,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,KAAI;AAC3C,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;YAEzB,IAAI,OAAO,EAAE;AACT,gBAAA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;;;g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EAAA,CAAA,CAAA;;2FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC;AACtB,oBAAA,OAAO,EAAE,CAAC,GAAG,QAAQ;AACxB,iBAAA;;;ACjBD;;AAEG;;;;"}
|
|
@@ -27,11 +27,13 @@ class RdxButtonDirective {
|
|
|
27
27
|
* The `type` attribute applied to native `<button>` hosts.
|
|
28
28
|
* @group Props
|
|
29
29
|
*/
|
|
30
|
-
this.type = input('button',
|
|
30
|
+
this.type = input('button', /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
31
32
|
/**
|
|
32
33
|
* @ignore
|
|
33
34
|
*/
|
|
34
|
-
this.isNativeButton = computed(() => this.elementRef.nativeElement.tagName === 'BUTTON',
|
|
35
|
+
this.isNativeButton = computed(() => this.elementRef.nativeElement.tagName === 'BUTTON', /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "isNativeButton" }] : /* istanbul ignore next */ []));
|
|
35
37
|
/**
|
|
36
38
|
* @ignore
|
|
37
39
|
* Express disabled via `aria-disabled` on non-button hosts, or whenever the
|
|
@@ -42,7 +44,8 @@ class RdxButtonDirective {
|
|
|
42
44
|
return undefined;
|
|
43
45
|
}
|
|
44
46
|
return !this.isNativeButton() || this.focusableWhenDisabled() ? 'true' : undefined;
|
|
45
|
-
},
|
|
47
|
+
}, /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "ariaDisabled" }] : /* istanbul ignore next */ []));
|
|
46
49
|
/**
|
|
47
50
|
* @ignore
|
|
48
51
|
*/
|
|
@@ -51,7 +54,8 @@ class RdxButtonDirective {
|
|
|
51
54
|
return undefined;
|
|
52
55
|
}
|
|
53
56
|
return this.disabled() && !this.focusableWhenDisabled() ? -1 : 0;
|
|
54
|
-
},
|
|
57
|
+
}, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "tabIndex" }] : /* istanbul ignore next */ []));
|
|
55
59
|
const element = this.elementRef.nativeElement;
|
|
56
60
|
// Capture-phase listeners registered here run before any consumer
|
|
57
61
|
// `(click)`/`(keydown)` binding on the same element, so a disabled
|
|
@@ -93,10 +97,10 @@ class RdxButtonDirective {
|
|
|
93
97
|
this.elementRef.nativeElement.click();
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
97
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
100
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
101
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.2", type: RdxButtonDirective, isStandalone: true, selector: "[rdxButton]", inputs: { disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, focusableWhenDisabled: { classPropertyName: "focusableWhenDisabled", publicName: "focusableWhenDisabled", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-disabled": "disabled() ? \"\" : undefined", "attr.disabled": "isNativeButton() && disabled() && !focusableWhenDisabled() ? \"\" : undefined", "attr.aria-disabled": "ariaDisabled()", "attr.type": "isNativeButton() ? type() : undefined", "attr.role": "isNativeButton() ? undefined : \"button\"", "attr.tabindex": "tabIndex()" } }, exportAs: ["rdxButton"], ngImport: i0 }); }
|
|
98
102
|
}
|
|
99
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: RdxButtonDirective, decorators: [{
|
|
100
104
|
type: Directive,
|
|
101
105
|
args: [{
|
|
102
106
|
selector: '[rdxButton]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radix-ng-primitives-button.mjs","sources":["../../../packages/primitives/button/src/button.directive.ts","../../../packages/primitives/button/radix-ng-primitives-button.ts"],"sourcesContent":["import { booleanAttribute, computed, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';\nimport { BooleanInput } from '@radix-ng/primitives/core';\n\nexport type RdxButtonType = 'button' | 'submit' | 'reset';\n\nexport interface RdxButtonProps {\n /**\n * Whether the button is disabled.\n * @defaultValue false\n */\n disabled?: boolean;\n\n /**\n * Whether the button should remain focusable when disabled. When `true`,\n * the disabled state is expressed with `aria-disabled` (instead of the\n * native `disabled` attribute) so the control stays in the tab order while\n * its activation is suppressed.\n * @defaultValue false\n */\n focusableWhenDisabled?: boolean;\n\n /**\n * The `type` attribute applied to native `<button>` hosts.\n * @defaultValue 'button'\n */\n type?: RdxButtonType;\n}\n\n/**\n * Headless button behavior, modeled on Base UI's `useButton`.\n *\n * Renders accessible button semantics on a native `<button>` or on any other\n * element (e.g. `<a>`, `<span>`). Carries no styles — state is exposed via\n * `data-disabled` for consumers to style.\n *\n * @group Components\n */\n@Directive({\n selector: '[rdxButton]',\n exportAs: 'rdxButton',\n host: {\n '[attr.data-disabled]': 'disabled() ? \"\" : undefined',\n\n // Native disabled only when we do NOT need it focusable; otherwise we\n // keep it focusable and express the state via aria-disabled below.\n '[attr.disabled]': 'isNativeButton() && disabled() && !focusableWhenDisabled() ? \"\" : undefined',\n '[attr.aria-disabled]': 'ariaDisabled()',\n\n // Native buttons get their type; non-button hosts get button semantics.\n '[attr.type]': 'isNativeButton() ? type() : undefined',\n '[attr.role]': 'isNativeButton() ? undefined : \"button\"',\n '[attr.tabindex]': 'tabIndex()'\n }\n})\nexport class RdxButtonDirective {\n private readonly elementRef = inject(ElementRef<HTMLElement>);\n\n /**\n * Whether the button is disabled.\n * @group Props\n */\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * Keep the button focusable while disabled (uses `aria-disabled`).\n * @group Props\n */\n readonly focusableWhenDisabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * The `type` attribute applied to native `<button>` hosts.\n * @group Props\n */\n readonly type = input<RdxButtonType>('button');\n\n /**\n * @ignore\n */\n protected readonly isNativeButton = computed(() => this.elementRef.nativeElement.tagName === 'BUTTON');\n\n /**\n * @ignore\n * Express disabled via `aria-disabled` on non-button hosts, or whenever the\n * control must stay focusable.\n */\n protected readonly ariaDisabled = computed(() => {\n if (!this.disabled()) {\n return undefined;\n }\n return !this.isNativeButton() || this.focusableWhenDisabled() ? 'true' : undefined;\n });\n\n /**\n * @ignore\n */\n protected readonly tabIndex = computed(() => {\n if (this.isNativeButton()) {\n return undefined;\n }\n return this.disabled() && !this.focusableWhenDisabled() ? -1 : 0;\n });\n\n constructor() {\n const element = this.elementRef.nativeElement;\n\n // Capture-phase listeners registered here run before any consumer\n // `(click)`/`(keydown)` binding on the same element, so a disabled\n // button reliably suppresses activation (the native `disabled`\n // attribute can't be used when the control must stay focusable).\n const onClick = (event: MouseEvent): void => this.handleClick(event);\n const onKeydown = (event: KeyboardEvent): void => this.handleKeydown(event);\n\n element.addEventListener('click', onClick, true);\n element.addEventListener('keydown', onKeydown, true);\n\n inject(DestroyRef).onDestroy(() => {\n element.removeEventListener('click', onClick, true);\n element.removeEventListener('keydown', onKeydown, true);\n });\n }\n\n private handleClick(event: MouseEvent): void {\n if (this.disabled()) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const isActivationKey = event.key === 'Enter' || event.key === ' ';\n if (!isActivationKey) {\n return;\n }\n\n if (this.disabled()) {\n // Native buttons fire a click on Enter/Space; the capture click\n // handler stops it. Non-button hosts never do, so just block here.\n event.preventDefault();\n if (!this.isNativeButton()) {\n event.stopImmediatePropagation();\n }\n return;\n }\n\n // Non-button hosts have no native activation; synthesize a click.\n // Space must not scroll the page.\n if (!this.isNativeButton()) {\n event.preventDefault();\n this.elementRef.nativeElement.click();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA4BA;;;;;;;;AAQG;MAkBU,kBAAkB,CAAA;AAgD3B,IAAA,WAAA,GAAA;AA/CiB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,EAAC,UAAuB,EAAC;AAE7D;;;AAGG;QACM,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAExF;;;AAGG;QACM,IAAA,CAAA,qBAAqB,GAAG,KAAK,CAAwB,KAAK,6FAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAErG;;;AAGG;
|
|
1
|
+
{"version":3,"file":"radix-ng-primitives-button.mjs","sources":["../../../packages/primitives/button/src/button.directive.ts","../../../packages/primitives/button/radix-ng-primitives-button.ts"],"sourcesContent":["import { booleanAttribute, computed, DestroyRef, Directive, ElementRef, inject, input } from '@angular/core';\nimport { BooleanInput } from '@radix-ng/primitives/core';\n\nexport type RdxButtonType = 'button' | 'submit' | 'reset';\n\nexport interface RdxButtonProps {\n /**\n * Whether the button is disabled.\n * @defaultValue false\n */\n disabled?: boolean;\n\n /**\n * Whether the button should remain focusable when disabled. When `true`,\n * the disabled state is expressed with `aria-disabled` (instead of the\n * native `disabled` attribute) so the control stays in the tab order while\n * its activation is suppressed.\n * @defaultValue false\n */\n focusableWhenDisabled?: boolean;\n\n /**\n * The `type` attribute applied to native `<button>` hosts.\n * @defaultValue 'button'\n */\n type?: RdxButtonType;\n}\n\n/**\n * Headless button behavior, modeled on Base UI's `useButton`.\n *\n * Renders accessible button semantics on a native `<button>` or on any other\n * element (e.g. `<a>`, `<span>`). Carries no styles — state is exposed via\n * `data-disabled` for consumers to style.\n *\n * @group Components\n */\n@Directive({\n selector: '[rdxButton]',\n exportAs: 'rdxButton',\n host: {\n '[attr.data-disabled]': 'disabled() ? \"\" : undefined',\n\n // Native disabled only when we do NOT need it focusable; otherwise we\n // keep it focusable and express the state via aria-disabled below.\n '[attr.disabled]': 'isNativeButton() && disabled() && !focusableWhenDisabled() ? \"\" : undefined',\n '[attr.aria-disabled]': 'ariaDisabled()',\n\n // Native buttons get their type; non-button hosts get button semantics.\n '[attr.type]': 'isNativeButton() ? type() : undefined',\n '[attr.role]': 'isNativeButton() ? undefined : \"button\"',\n '[attr.tabindex]': 'tabIndex()'\n }\n})\nexport class RdxButtonDirective {\n private readonly elementRef = inject(ElementRef<HTMLElement>);\n\n /**\n * Whether the button is disabled.\n * @group Props\n */\n readonly disabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * Keep the button focusable while disabled (uses `aria-disabled`).\n * @group Props\n */\n readonly focusableWhenDisabled = input<boolean, BooleanInput>(false, { transform: booleanAttribute });\n\n /**\n * The `type` attribute applied to native `<button>` hosts.\n * @group Props\n */\n readonly type = input<RdxButtonType>('button');\n\n /**\n * @ignore\n */\n protected readonly isNativeButton = computed(() => this.elementRef.nativeElement.tagName === 'BUTTON');\n\n /**\n * @ignore\n * Express disabled via `aria-disabled` on non-button hosts, or whenever the\n * control must stay focusable.\n */\n protected readonly ariaDisabled = computed(() => {\n if (!this.disabled()) {\n return undefined;\n }\n return !this.isNativeButton() || this.focusableWhenDisabled() ? 'true' : undefined;\n });\n\n /**\n * @ignore\n */\n protected readonly tabIndex = computed(() => {\n if (this.isNativeButton()) {\n return undefined;\n }\n return this.disabled() && !this.focusableWhenDisabled() ? -1 : 0;\n });\n\n constructor() {\n const element = this.elementRef.nativeElement;\n\n // Capture-phase listeners registered here run before any consumer\n // `(click)`/`(keydown)` binding on the same element, so a disabled\n // button reliably suppresses activation (the native `disabled`\n // attribute can't be used when the control must stay focusable).\n const onClick = (event: MouseEvent): void => this.handleClick(event);\n const onKeydown = (event: KeyboardEvent): void => this.handleKeydown(event);\n\n element.addEventListener('click', onClick, true);\n element.addEventListener('keydown', onKeydown, true);\n\n inject(DestroyRef).onDestroy(() => {\n element.removeEventListener('click', onClick, true);\n element.removeEventListener('keydown', onKeydown, true);\n });\n }\n\n private handleClick(event: MouseEvent): void {\n if (this.disabled()) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const isActivationKey = event.key === 'Enter' || event.key === ' ';\n if (!isActivationKey) {\n return;\n }\n\n if (this.disabled()) {\n // Native buttons fire a click on Enter/Space; the capture click\n // handler stops it. Non-button hosts never do, so just block here.\n event.preventDefault();\n if (!this.isNativeButton()) {\n event.stopImmediatePropagation();\n }\n return;\n }\n\n // Non-button hosts have no native activation; synthesize a click.\n // Space must not scroll the page.\n if (!this.isNativeButton()) {\n event.preventDefault();\n this.elementRef.nativeElement.click();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AA4BA;;;;;;;;AAQG;MAkBU,kBAAkB,CAAA;AAgD3B,IAAA,WAAA,GAAA;AA/CiB,QAAA,IAAA,CAAA,UAAU,GAAG,MAAM,EAAC,UAAuB,EAAC;AAE7D;;;AAGG;QACM,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAExF;;;AAGG;QACM,IAAA,CAAA,qBAAqB,GAAG,KAAK,CAAwB,KAAK,6FAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAErG;;;AAGG;QACM,IAAA,CAAA,IAAI,GAAG,KAAK,CAAgB,QAAQ;iFAAC;AAE9C;;AAEG;AACgB,QAAA,IAAA,CAAA,cAAc,GAAG,QAAQ,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,KAAK,QAAQ;2FAAC;AAEtG;;;;AAIG;AACgB,QAAA,IAAA,CA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